Skip to content

Commit

Permalink
helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 20, 2024
1 parent de02907 commit 48be623
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
1 change: 0 additions & 1 deletion genaisrc/gcm.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
script({
title: "git commit message",
description: "Generate a commit message for all staged changes",
model: "openai:gpt-4o",
})

// TODO: update this diff command to match your workspace
Expand Down
60 changes: 60 additions & 0 deletions genaisrc/rv.genai.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
script({
title: "Reviewer",
description: "Review the current files",
system: ["system.annotations"],
tools: ["fs"],
cache: "rv",
parameters: {
errors: {
type: "boolean",
description: "Report errors only",
default: false,
},
},
})

/** ------------------------------------------------
* Configuration
*/
const { errors } = env.vars

/** ------------------------------------------------
* Context
*/
let content = ""
/**
* env.files contains the file selected by the user in VSCode or through the cli arguments.
*/
if (env.files.length) {
content = def("FILE", env.files, {
maxTokens: 5000,
glob: "**/*.{py,ts,cs,rs,c,cpp,h,hpp,js,mjs,mts}", // TODO:
})
} else {
// No files selected, review the current changes
console.log("No files found. Using git diff.")
const { stdout: diff } = await host.exec("git diff -U6")
// customize git diff to filter some files
if (!diff) cancel("No changes found, did you forget to stage your changes?")
content = def("GIT_DIFF", diff, { language: "diff" })
}

$`
## Role
You are an expert developer at all known programming languages.
You are very helpful at reviewing code and providing constructive feedback.
## Task
Report ${errors ? `errors` : `errors and warnings`} in ${content} using the annotation format.
## Guidance
- Use best practices of the programming language of each file.
- If available, provide a URL to the official documentation for the best practice. do NOT invent URLs.
- Analyze ALL the code. Do not be lazy. This is IMPORTANT.
- Use tools to read the entire file content to get more context
${errors ? `- Do not report warnings, only errors.` : ``}
`
// TODO: customize with more rules

0 comments on commit 48be623

Please sign in to comment.