From f4dd56dfb54dc8a937d6d206ac233d7ff1cecdfb Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 3 Oct 2024 04:40:52 +0000 Subject: [PATCH] Enhance git tool descriptions and update GitHub actions handling --- docs/genaisrc/genaiscript.d.ts | 1 - docs/src/components/BuiltinTools.mdx | 13 ++- .../content/docs/reference/scripts/system.mdx | 81 +++++++++++-------- genaisrc/genaiscript.d.ts | 1 - packages/auto/genaiscript.d.ts | 1 - packages/core/src/genaisrc/genaiscript.d.ts | 1 - .../src/genaisrc/system.agent_git.genai.mjs | 5 +- .../core/src/genaisrc/system.git.genai.mjs | 37 ++++++--- .../genaisrc/system.github_actions.genai.mjs | 8 +- .../genaisrc/system.github_issues.genai.mjs | 8 +- .../genaisrc/system.github_pulls.genai.mjs | 8 +- .../sample/genaisrc/blog/genaiscript.d.ts | 1 - packages/sample/genaisrc/genaiscript.d.ts | 1 - .../sample/genaisrc/github-agent.genai.mts | 8 +- .../sample/genaisrc/node/genaiscript.d.ts | 1 - .../sample/genaisrc/python/genaiscript.d.ts | 1 - .../sample/genaisrc/style/genaiscript.d.ts | 1 - packages/sample/src/aici/genaiscript.d.ts | 1 - packages/sample/src/errors/genaiscript.d.ts | 1 - packages/sample/src/genaiscript.d.ts | 1 - packages/sample/src/makecode/genaiscript.d.ts | 1 - packages/sample/src/tla/genaiscript.d.ts | 1 - packages/sample/src/vision/genaiscript.d.ts | 1 - packages/vscode/genaisrc/genaiscript.d.ts | 1 - slides/genaisrc/genaiscript.d.ts | 1 - 25 files changed, 104 insertions(+), 81 deletions(-) diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index 6076b5b620..1525a81067 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -14,14 +14,13 @@ import { LinkCard } from '@astrojs/starlight/components'; - - - - - - + + + + + + - diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index 97fab298ee..5e0d0a2da6 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -188,12 +188,13 @@ defTool( (_) => { _.def("QUERY", query) - _.$`Your are a helpfull LLM agent that can query Git to accomplish tasks. + _.$`Your are a helpfull LLM agent that can use git tools to query a repository. Analyze and answer QUERY. - Assume that your answer will be analyzed by an LLM, not a human. - - If you cannot answer the query, return an empty string. + - If you are missing information, reply "MISSING_INFO: ". + - If you cannot answer the query, return "NO_ANSWER: ". ` }, { @@ -853,43 +854,49 @@ defTool( git read operations -Various tools to explore git. +Tools to query a git repository. -- tool `git_branch_current`: Gets the current branch. -- tool `git_branch_list`: List all branches. -- tool `git_diff`: Generates concise file diffs. -- tool `git_log`: Generates a log of commits. -- tool `git_status`: Generates a status of the repository. -- tool `git_last_tag`: Gets the last tag. +- tool `git_branch_current`: Gets the current branch using git. +- tool `git_branch_list`: List all branches using git. +- tool `git_diff`: Generates concise file diffs using git. +- tool `git_log`: Generates a log of commits using git. +- tool `git_status`: Generates a status of the repository using git. +- tool `git_last_tag`: Gets the last tag using git. `````js wrap title="system.git" system({ title: "git read operations", - description: "Various tools to explore git.", + description: "Tools to query a git repository.", }) -defTool("git_branch_current", "Gets the current branch.", {}, async () => { - return await git.branch() -}) +defTool( + "git_branch_current", + "Gets the current branch using git.", + {}, + async () => { + return await git.branch() + } +) -defTool("git_branch_list", "List all branches.", {}, async () => { +defTool("git_branch_list", "List all branches using git.", {}, async () => { return await git.exec("branch") }) defTool( "git_diff", - "Generates concise file diffs.", + "Generates concise file diffs using git.", { type: "object", properties: { base: { type: "string", description: - "Base branch to compare against. Use 'BASE' to compare against the repository default branch.", + "Base branch, ref, commit sha to compare against. Use 'DEFAULT' to compare against the repository default branch.", }, head: { type: "string", - description: "Head branch to compare", + description: + "Head branch, ref, commit sha to compare. Use 'HEAD' to compare against the current branch.", }, staged: { type: "boolean", @@ -915,7 +922,7 @@ defTool( defTool( "git_log", - "Generates a log of commits.", + "Generates a log of commits using git.", { type: "object", properties: { @@ -944,11 +951,16 @@ defTool( } ) -defTool("git_status", "Generates a status of the repository.", {}, async () => { - return await git.exec(["status", "--porcelain"]) -}) +defTool( + "git_status", + "Generates a status of the repository using git.", + {}, + async () => { + return await git.exec(["status", "--porcelain"]) + } +) -defTool("git_last_tag", "Gets the last tag.", {}, async () => { +defTool("git_last_tag", "Gets the last tag using git.", {}, async () => { return await git.lastTag() }) @@ -962,7 +974,6 @@ github workflows Queries results from workflows in GitHub actions. - tool `github_actions_workflows_list`: List all workflows as a list of 'id: name' pair. -- tool `github_actions_runs_list`: List all runs for a workflow or the entire repository. Use 'git_actions_list_workflows' to list workflows. Omit 'workflow_id' to list all runs. - tool `github_actions_jobs_list`: List all jobs for a run. - tool `github_actions_job_logs_get`: Download workflow job log. If the log is too large, use 'github_actions_job_logs_diff' to compare logs. - tool `github_actions_job_logs_diff`: Diffs two workflow job logsr. @@ -990,7 +1001,10 @@ defTool( defTool( "github_actions_runs_list", - "List all runs for a workflow or the entire repository. Use 'git_actions_list_workflows' to list workflows. Omit 'workflow_id' to list all runs.", + `List all runs for a workflow or the entire repository. + Use 'git_actions_list_workflows' to list workflows. + Omit 'workflow_id' to list all runs. + head_sha is the commit hash.`, { type: "object", properties: { @@ -1006,8 +1020,7 @@ defTool( status: { type: "string", enum: ["success", "failure"], - description: - "Filter runs by completion status: success, failured.", + description: "Filter runs by completion status", }, }, }, @@ -1201,6 +1214,7 @@ defTool( properties: { state: { type: "string", + enum: ["open", "closed", "all"], description: "state of the issue from 'open, 'closed', 'all'. Default is 'open'.", }, @@ -1210,12 +1224,13 @@ defTool( }, sort: { type: "string", - description: - "What to sort by: 'created', 'updated', 'comments'", + enum: ["created", "updated", "comments"], + description: "What to sort by", }, direction: { type: "string", - description: "Direction to sort: 'asc', 'desc'", + enum: ["asc", "desc"], + description: "Direction to sort", }, }, }, @@ -1313,6 +1328,7 @@ defTool( properties: { state: { type: "string", + enum: ["open", "closed", "all"], description: "state of the pull request from 'open, 'closed', 'all'. Default is 'open'.", }, @@ -1322,12 +1338,13 @@ defTool( }, sort: { type: "string", - description: - "What to sort by: 'created', 'updated', 'comments'", + enum: ["created", "updated", "comments"], + description: "What to sort by", }, direction: { type: "string", - description: "Direction to sort: 'asc', 'desc'", + enum: ["asc", "desc"], + description: "Direction to sort", }, }, }, diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/core/src/genaisrc/system.agent_git.genai.mjs b/packages/core/src/genaisrc/system.agent_git.genai.mjs index 2ce30304ac..437eb1415c 100644 --- a/packages/core/src/genaisrc/system.agent_git.genai.mjs +++ b/packages/core/src/genaisrc/system.agent_git.genai.mjs @@ -20,12 +20,13 @@ defTool( (_) => { _.def("QUERY", query) - _.$`Your are a helpfull LLM agent that can query Git to accomplish tasks. + _.$`Your are a helpfull LLM agent that can use git tools to query a repository. Analyze and answer QUERY. - Assume that your answer will be analyzed by an LLM, not a human. - - If you cannot answer the query, return an empty string. + - If you are missing information, reply "MISSING_INFO: ". + - If you cannot answer the query, return "NO_ANSWER: ". ` }, { diff --git a/packages/core/src/genaisrc/system.git.genai.mjs b/packages/core/src/genaisrc/system.git.genai.mjs index 43835ce113..7b99943dbb 100644 --- a/packages/core/src/genaisrc/system.git.genai.mjs +++ b/packages/core/src/genaisrc/system.git.genai.mjs @@ -1,30 +1,36 @@ system({ title: "git read operations", - description: "Various tools to explore git.", + description: "Tools to query a git repository.", }) -defTool("git_branch_current", "Gets the current branch.", {}, async () => { - return await git.branch() -}) +defTool( + "git_branch_current", + "Gets the current branch using git.", + {}, + async () => { + return await git.branch() + } +) -defTool("git_branch_list", "List all branches.", {}, async () => { +defTool("git_branch_list", "List all branches using git.", {}, async () => { return await git.exec("branch") }) defTool( "git_diff", - "Generates concise file diffs.", + "Generates concise file diffs using git.", { type: "object", properties: { base: { type: "string", description: - "Base branch to compare against. Use 'BASE' to compare against the repository default branch.", + "Base branch, ref, commit sha to compare against. Use 'DEFAULT' to compare against the repository default branch.", }, head: { type: "string", - description: "Head branch to compare", + description: + "Head branch, ref, commit sha to compare. Use 'HEAD' to compare against the current branch.", }, staged: { type: "boolean", @@ -50,7 +56,7 @@ defTool( defTool( "git_log", - "Generates a log of commits.", + "Generates a log of commits using git.", { type: "object", properties: { @@ -79,10 +85,15 @@ defTool( } ) -defTool("git_status", "Generates a status of the repository.", {}, async () => { - return await git.exec(["status", "--porcelain"]) -}) +defTool( + "git_status", + "Generates a status of the repository using git.", + {}, + async () => { + return await git.exec(["status", "--porcelain"]) + } +) -defTool("git_last_tag", "Gets the last tag.", {}, async () => { +defTool("git_last_tag", "Gets the last tag using git.", {}, async () => { return await git.lastTag() }) diff --git a/packages/core/src/genaisrc/system.github_actions.genai.mjs b/packages/core/src/genaisrc/system.github_actions.genai.mjs index 2a60deebf0..be1608a692 100644 --- a/packages/core/src/genaisrc/system.github_actions.genai.mjs +++ b/packages/core/src/genaisrc/system.github_actions.genai.mjs @@ -20,7 +20,10 @@ defTool( defTool( "github_actions_runs_list", - "List all runs for a workflow or the entire repository. Use 'git_actions_list_workflows' to list workflows. Omit 'workflow_id' to list all runs.", + `List all runs for a workflow or the entire repository. + Use 'git_actions_list_workflows' to list workflows. + Omit 'workflow_id' to list all runs. + head_sha is the commit hash.`, { type: "object", properties: { @@ -36,8 +39,7 @@ defTool( status: { type: "string", enum: ["success", "failure"], - description: - "Filter runs by completion status: success, failured.", + description: "Filter runs by completion status", }, }, }, diff --git a/packages/core/src/genaisrc/system.github_issues.genai.mjs b/packages/core/src/genaisrc/system.github_issues.genai.mjs index 767d6e7c17..01bf1bb850 100644 --- a/packages/core/src/genaisrc/system.github_issues.genai.mjs +++ b/packages/core/src/genaisrc/system.github_issues.genai.mjs @@ -10,6 +10,7 @@ defTool( properties: { state: { type: "string", + enum: ["open", "closed", "all"], description: "state of the issue from 'open, 'closed', 'all'. Default is 'open'.", }, @@ -19,12 +20,13 @@ defTool( }, sort: { type: "string", - description: - "What to sort by: 'created', 'updated', 'comments'", + enum: ["created", "updated", "comments"], + description: "What to sort by", }, direction: { type: "string", - description: "Direction to sort: 'asc', 'desc'", + enum: ["asc", "desc"], + description: "Direction to sort", }, }, }, diff --git a/packages/core/src/genaisrc/system.github_pulls.genai.mjs b/packages/core/src/genaisrc/system.github_pulls.genai.mjs index f61a82f184..1af1ca8444 100644 --- a/packages/core/src/genaisrc/system.github_pulls.genai.mjs +++ b/packages/core/src/genaisrc/system.github_pulls.genai.mjs @@ -10,6 +10,7 @@ defTool( properties: { state: { type: "string", + enum: ["open", "closed", "all"], description: "state of the pull request from 'open, 'closed', 'all'. Default is 'open'.", }, @@ -19,12 +20,13 @@ defTool( }, sort: { type: "string", - description: - "What to sort by: 'created', 'updated', 'comments'", + enum: ["created", "updated", "comments"], + description: "What to sort by", }, direction: { type: "string", - description: "Direction to sort: 'asc', 'desc'", + enum: ["asc", "desc"], + description: "Direction to sort", }, }, }, diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/genaisrc/github-agent.genai.mts b/packages/sample/genaisrc/github-agent.genai.mts index 0ea123798b..79608ad500 100644 --- a/packages/sample/genaisrc/github-agent.genai.mts +++ b/packages/sample/genaisrc/github-agent.genai.mts @@ -3,4 +3,10 @@ script({ tests: {}, }) -$`Investigate the status of failed github workflows and identify the root cause of the failure.` +$`Investigate the status of failed github workflows, pick one failed run and identify the root cause of the failure. + +- Correlate the failure with the relevant commits, pull requests or issues. +- Compare the source code between the failed run and the last successful run before that run. + +In your report, include html links to the relevant runs, commits, pull requests or issues. +` diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list" diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index cd8bb880d9..5a1c42d6d7 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -125,7 +125,6 @@ type SystemToolId = OptionsOrString< | "github_actions_job_logs_diff" | "github_actions_job_logs_get" | "github_actions_jobs_list" - | "github_actions_runs_list" | "github_actions_workflows_list" | "github_files_get" | "github_files_list"