Skip to content

Commit

Permalink
moving samples out of vscode extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Nov 21, 2024
1 parent 3969d3e commit 5b4749e
Show file tree
Hide file tree
Showing 26 changed files with 47 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description: Discover how GenAI simplifies your Git workflow by automating

Coding can be a lot of fun, but let's be honest, sometimes the administrative parts of the process, like crafting the perfect commit message, can be a bit of a drag. 😓 But what if I told you that you could automate that with GenAI? That's right, with a little bit of setup, GenAI can generate commit messages for you, based on your staged changes. 🎉

The script we're discussing can be found [right here on GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/gcm.genai.mts), and it's called `git commit message`. Its purpose is to help you swiftly create commit messages without the mental overhead of crafting them manually every single time.
The script we're discussing can be found [right here on GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/gcm.genai.mts), and it's called `git commit message`. Its purpose is to help you swiftly create commit messages without the mental overhead of crafting them manually every single time.

Let's break down this script, shall we?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Dive into automated code review processes with GenAI, enhancing

## Introducing "Code Review with GenAI" 🧐

Have you ever wished for an extra set of eyes while coding? Well, GenAI has got your back! Let's delve into the "Reviewer" script, which automates the code review process, making it a breeze for developers. This powerful script for the GenAIScript platform can be found [here on GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/prr.genai.mts).
Have you ever wished for an extra set of eyes while coding? Well, GenAI has got your back! Let's delve into the "Reviewer" script, which automates the code review process, making it a breeze for developers. This powerful script for the GenAIScript platform can be found [here on GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/prr.genai.mts).

### What is the Script About?

Expand Down
10 changes: 5 additions & 5 deletions docs/src/content/docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ about the history of markdown:
````markdown wrap
FILE:

```txt file="src/samples/markdown-small.txt"
```text file="src/samples/markdown-small.txt"
What is Markdown?

Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Created by John Gruber in 2004, Markdown is now one of the world’s most popular markup languages.
Expand All @@ -93,7 +93,7 @@ the GenAIScript runtime interprets based on what the prompt requested from the m
````markdown wrap
File src/samples/markdown-small.txt.summary:

```txt
```text
Markdown is a lightweight markup language created by John Gruber in 2004, known for adding formatting elements to plaintext text documents.
```
````
Expand Down Expand Up @@ -138,7 +138,7 @@ A possible trace looks like as follows.
- cat src/rag/markdown.md
- prompting github:gpt-4o

````` wrap
`````text wrap
Saving this summary to the file `markdown.md.txt`.
FILE ./markdown.md.txt:
Expand Down Expand Up @@ -177,13 +177,13 @@ $`
- cat src/rag/markdown.md
- prompting github:gpt-4o (~635 tokens)

```
```md
The file "src/rag/markdown.md" explains that Markdown...
```

- prompting github:gpt-4o (~1625 tokens)

`````
`````md
I'll save the summary to the file `markdown.md.txt`.

FILE markdown.md.txt:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/guides/auto-git-commit-message.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Streamline your Git workflow with an automation script for

In the world of software development, making consistent and informative commit messages is crucial but often overlooked.
This task can become tedious, especially when you are in the flow of coding.
To help with this, we've crafted a [script tailored to automate generating Git commit messages](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/gcm.genai.mts),
To help with this, we've crafted a [script tailored to automate generating Git commit messages](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/gcm.genai.mts),
ensuring they are meaningful and save you time.

The script acts as a regular node.js automation script and uses [runPrompt](/genaiscript/reference/scripts/inner-prompts)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/guides/search-and-transform.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/st.genai.mjs?raw"
import source from "../../../../../packages/sample/genaisrc/samples/st.genai.mjs?raw"

This script is an evolution of the "search and replace" feature from text editor,
where the "replace" step has been replaced by a LLM transformation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:

import { Image } from "astro:assets"
import { Code } from "@astrojs/starlight/components"
import scriptSource from "../../../../../../packages/vscode/genaisrc/copilotchat.genai.mjs?raw"
import scriptSource from "../../../../../../packages/sample/genaisrc/samples/copilotchat.genai.mjs?raw"
import src from "../../../../assets/chat-participant.png"
import alt from "../../../../assets/chat-participant.png.txt?raw"

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/samples/cmt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/cmt.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/cmt.genai.mts?raw"

This sample automates the process of adding comments to source code using an LLM
and validates that the changes haven't introduced any code modifications.
Expand Down Expand Up @@ -138,7 +138,7 @@ const { format, build } = env.vars.build
genaiscript run cmt --vars "build=npm run build" "format=npm run format"
```

## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/cmt.genai.mts))
## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/cmt.genai.mts))

<Code code={source} wrap={true} lang="ts" title="cmt.genai.mts" />

Expand Down
11 changes: 11 additions & 0 deletions docs/src/content/docs/samples/diagram.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Diagram
description: Class diagram generator
sidebar:
order: 1
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/diagram.genai.mts?raw"

This samples analyzes all the code in context and tries to generate a diagram using [mermaid](https://mermaid.js.org/).
2 changes: 1 addition & 1 deletion docs/src/content/docs/samples/gai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar:
order: 100
---
import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/sample/genaisrc/gai.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/gai.genai.mts?raw"
import gasource from "../../../../../.github/workflows/genai-investigator.yml?raw"

This is an in-depth guide to build a script that interactively investigates GitHub Actions failures.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/samples/gcm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/gcm.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/gcm.genai.mts?raw"

The `gcm` script provides a guided flow to create commits with generated messages.
It starts by generating a commit message based on the staged changes in your Git repository
Expand Down Expand Up @@ -96,7 +96,7 @@ Use the [cli](/genaiscript/reference/cli) to run the script:
npx genaiscript run gcm
```

## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/gcm.genai.mts))
## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/gcm.genai.mts))

<Code code={source} wrap={true} lang="ts" title="gcm.genai.mts" />

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/samples/iat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/iat.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/iat.genai.mts?raw"

Alt text is essential for making images accessible to everyone, including those with visual impairments. It provides a textual description of the image, allowing screen readers to convey the content to users who can't see the image.
However, writing alt text for images can be time-consuming, especially when dealing with a large number of images. This is where AI can help. By using a language model like OpenAI's GPT-4, you can generate alt text for images automatically, thus saving you time and effort.
Expand Down Expand Up @@ -146,7 +146,7 @@ The script imports a default safety system message to prevent generating harmful
In Azure OpenAI deployments, you can also turn on [content filters](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter)
to prevent accidentally generating harmful content.

## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/iat.genai.mts))
## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/iat.genai.mts))

<Code code={source} wrap={true} lang="ts" title="iat.genai.mts" />

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/samples/prd.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/prd.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/prd.genai.mts?raw"

Pull requests are an integral part of collaborative software development.
They allow developers to review code changes before merging them into the main codebase.
Expand Down Expand Up @@ -98,7 +98,7 @@ Adding the `-prd` flag will automatically update the pull request description on
npx genaiscript run prd -prd
```

## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/prd.genai.mts))
## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/prd.genai.mts))

<Code code={source} wrap={true} lang="ts" title="prd.genai.mts" />

Expand Down
10 changes: 4 additions & 6 deletions docs/src/content/docs/samples/prr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/prr.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/prr.genai.mts?raw"

Let's delve into the "Reviewer" script, which automates the code review process and makes it easier for developers.

Expand Down Expand Up @@ -45,8 +45,6 @@ console.log(changes)
def("GIT_DIFF", changes, { maxTokens: 20000 })
```



## The Prompt

The prompt is what instructs the AI on what to do. It's a critical part of the script, defining the role, task, and guidelines for the AI to follow during the review process.
Expand Down Expand Up @@ -87,7 +85,7 @@ genaiscript run rv
This will execute the script and provide you with the AI's feedback directly in your terminal or command prompt.
It's like having a virtual code reviewer at your disposal whenever you need it.

## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/rv.genai.mts))
## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/rv.genai.mts))

<Code code={source} wrap={true} lang="ts" title="prr.genai.mts" />

Expand All @@ -96,8 +94,8 @@ It's like having a virtual code reviewer at your disposal whenever you need it.
The following measures are taken to ensure the safety of the generated content.

- This script includes system prompts to prevent prompt injection and harmful content generation.
- [system.safety_jailbreak](/genaiscript/reference/scripts/system#systemsafety_jailbreak)
- [system.safety_harmful_content](/genaiscript/reference/scripts/system#systemsafety_harmful_content)
- [system.safety_jailbreak](/genaiscript/reference/scripts/system#systemsafety_jailbreak)
- [system.safety_harmful_content](/genaiscript/reference/scripts/system#systemsafety_harmful_content)
- The generated description is saved to a file at a specific path, which allows for a manual review before committing the changes.

Additional measures to further enhance safety would be to run [a model with a safety filter](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cuser-prompt%2Cpython-new)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/samples/sc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/sample/genaisrc/sc.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/sc.genai.mts?raw"

Automating and improving the efficiency of proofreading documents is a common need among developers and writers. This script addresses this need by checking and correcting spelling and grammar in Markdown files.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/samples/st.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

import { Code } from "@astrojs/starlight/components"
import source from "../../../../../packages/vscode/genaisrc/st.genai.mts?raw"
import source from "../../../../../packages/sample/genaisrc/samples/st.genai.mts?raw"

Search And Replace is a powerful tool in the developer toolbelt that can save you time and effort...
if you can formulate the right regular expression.
Expand Down Expand Up @@ -136,7 +136,7 @@ To run this script, you'll need the GenAIScript CLI. Check out the [installation
genaiscript run st
```

## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/vscode/genaisrc/st.genai.mts))
## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/samples/st.genai.mts))

<Code code={source} wrap={true} lang="ts" title="st.genai.mts" />

Expand Down
4 changes: 4 additions & 0 deletions packages/sample/genaisrc/samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# auto-generated
genaiscript.d.ts
tsconfig.json
jsconfig.json
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions packages/vscode/genaisrc/diagram.genai.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
script({
title: "Generate a class diagram using mermaid of the code symbols in content.",
group: "copilot",
})
def("CODE", env.files)
$`Generate a class diagram using mermaid of the code symbols in the CODE.`

0 comments on commit 5b4749e

Please sign in to comment.