Skip to content

Commit

Permalink
Add git branch default tool and enhance PR descriptor tools 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 7, 2024
1 parent 877ea80 commit 6642f85
Show file tree
Hide file tree
Showing 25 changed files with 132 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/src/components/BuiltinTools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LinkCard } from '@astrojs/starlight/components';
<LinkCard title="fs_diff_files" description="Computes a diff between two files." href="/genaiscript/reference/scripts/system#systemfs_diff_files" />
<LinkCard title="fs_find_files" description="Finds file matching a glob pattern. Use pattern to specify a regular expression to search for in the file content." href="/genaiscript/reference/scripts/system#systemfs_find_files" />
<LinkCard title="fs_read_file" description="Reads a file as text from the file system. Returns undefined if the file does not exist." href="/genaiscript/reference/scripts/system#systemfs_read_file" />
<LinkCard title="git_branch_default" description="Gets the default branch using git." href="/genaiscript/reference/scripts/system#systemgit" />

Check failure on line 12 in docs/src/components/BuiltinTools.mdx

View workflow job for this annotation

GitHub Actions / build

A new LinkCard was added without a corresponding description in the documentation.
<LinkCard title="git_branch_current" description="Gets the current branch using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_branch_list" description="List all branches using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_diff" description="Computes file diffs using the git diff command. If the diff is too large, it returns the list of modified/added files." href="/genaiscript/reference/scripts/system#systemgit" />
Expand Down
43 changes: 40 additions & 3 deletions docs/src/content/docs/reference/scripts/system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ defAgent(
"query a repository using Git to accomplish tasks. Provide all the context information available to execute git queries.",
`Your are a helpfull LLM agent that can use the git tools to query the current repository.
Answer the question in QUERY.
- The current repository is the same as github repository.`,
{ model, system: ["system.github_info"], tools: ["git"] }
- The current repository is the same as github repository.
- Prefer using diff to compare files rather than listing files. Listing files is only useful when you need to read the content of the files.
`,
{ model, system: ["system.git_info", "system.github_info"], tools: ["git"] }
)

`````
Expand Down Expand Up @@ -620,6 +622,9 @@ defTool(
const f = await workspace.readText(filename)
const of = await workspace.readText(otherfilename)
return parsers.diff(f, of)
},
{
maxTokens: 20000,
}
)

Expand Down Expand Up @@ -786,6 +791,7 @@ git read operations
Tools to query a git repository.
- tool `git_branch_default`: Gets the default branch using git.
- tool `git_branch_current`: Gets the current branch using git.
- tool `git_branch_list`: List all branches using git.
- tool `git_diff`: Computes file diffs using the git diff command. If the diff is too large, it returns the list of modified/added files.
Expand All @@ -799,6 +805,15 @@ system({
description: "Tools to query a git repository.",
})

defTool(
"git_branch_default",
"Gets the default branch using git.",
{},
async () => {
return await git.defaultBranch()
}
)

defTool(
"git_branch_current",
"Gets the current branch using git.",
Expand Down Expand Up @@ -860,7 +875,8 @@ defTool(
...rest,
})
return res
}
},
{ maxTokens: 20000 }
)

defTool(
Expand Down Expand Up @@ -918,6 +934,27 @@ defTool("git_last_tag", "Gets the last tag using git.", {}, async () => {
`````
### `system.git_info`
Git repository information
`````js wrap title="system.git_info"
system({
title: "Git repository information",
})

const branch = await git.branch()
const defaultBranch = await git.defaultBranch()

$`git: The current branch is ${branch} and the default branch is ${defaultBranch}.`

`````
### `system.github_actions`
github workflows
Expand Down
2 changes: 2 additions & 0 deletions genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/auto/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/core/src/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/core/src/genaisrc/system.agent_git.genai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ defAgent(
"query a repository using Git to accomplish tasks. Provide all the context information available to execute git queries.",
`Your are a helpfull LLM agent that can use the git tools to query the current repository.
Answer the question in QUERY.
- The current repository is the same as github repository.`,
{ model, system: ["system.github_info"], tools: ["git"] }
- The current repository is the same as github repository.
- Prefer using diff to compare files rather than listing files. Listing files is only useful when you need to read the content of the files.
`,
{ model, system: ["system.git_info", "system.github_info"], tools: ["git"] }
)
3 changes: 3 additions & 0 deletions packages/core/src/genaisrc/system.fs_diff_files.genai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ defTool(
const f = await workspace.readText(filename)
const of = await workspace.readText(otherfilename)
return parsers.diff(f, of)
},
{
maxTokens: 20000,
}
)
12 changes: 11 additions & 1 deletion packages/core/src/genaisrc/system.git.genai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ system({
description: "Tools to query a git repository.",
})

defTool(
"git_branch_default",
"Gets the default branch using git.",
{},
async () => {
return await git.defaultBranch()
}
)

defTool(
"git_branch_current",
"Gets the current branch using git.",
Expand Down Expand Up @@ -64,7 +73,8 @@ defTool(
...rest,
})
return res
}
},
{ maxTokens: 20000 }
)

defTool(
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/genaisrc/system.git_info.genai.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
system({
title: "Git repository information",
})

const branch = await git.branch()
const defaultBranch = await git.defaultBranch()

$`git: The current branch is ${branch} and the default branch is ${defaultBranch}.`
2 changes: 2 additions & 0 deletions packages/sample/genaisrc/blog/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/genaisrc/node/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions packages/sample/genaisrc/prd-agent.genai.mts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
script({
title: "Pull Request Descriptor - Agent",
description: "Generate a pull request description from the git diff",
tools: ["agent-ts", "agent-diff"],
tools: ["fs", "git_diff", "git_branch_current", "git_branch_default"],
temperature: 0.5,
})

$`You are an expert software developer and architect.
## Task
Describe a high level summary of the code changes in the current branch with a default branch in a way that a software engineer will understand.
This description will be used as the pull request description.
1. Compute the code different between the current branch and the default branch in this repository.
2. Describe a high level summary of the code changes.
## Instructions
- This description will be used as the pull request description.
- talk like a software engineer
- try to extract the intent of the changes, don't focus on the details
- use bullet points to list the changes
- use emojis to make the description more engaging
- focus on the most important changes
- ignore comments about imports (like added, remove, changed, etc.)
- do NOT add a "pull request description" header
`
25 changes: 25 additions & 0 deletions packages/sample/genaisrc/prd-tools.genai.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
script({
title: "Pull Request Descriptor - Agent",
description: "Generate a pull request description from the git diff",
tools: ["fs", "git_diff", "git_branch_current", "git_branch_default"],
temperature: 0.5,
})

$`You are an expert software developer and architect.
## Task
1. Compute the code different between the current branch and the default branch in this repository.
2. Describe a high level summary of the code changes.
## Instructions
- if the diff is too large, diff each file separately
- This description will be used as the pull request description.
- talk like a software engineer
- try to extract the intent of the changes, don't focus on the details
- use bullet points to list the changes
- use emojis to make the description more engaging
- focus on the most important changes
- ignore comments about imports (like added, remove, changed, etc.)
`
2 changes: 2 additions & 0 deletions packages/sample/genaisrc/python/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/genaisrc/style/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/aici/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/errors/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6642f85

Please sign in to comment.