Skip to content

Commit d4db603

Browse files
byapparovclaude
andcommitted
refactor(tool): clarify git.write replaces the safety block (#161 review 2)
- Rename bash-git.txt to bash-git-procedure.txt to match GIT_PROCEDURE. - State in the comment, schema and docs that git.write replaces the short safety rules with the full pre-opt-in procedure, which keeps its own safety protocol. - Use replacer functions for every placeholder, so `$` sequences in the working directory are inserted literally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 334bcdc commit d4db603

6 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ rules, for example: never commit, push or open a pull request unless the user
8181
asks, never commit secrets, never skip hooks, never force push or amend unless
8282
asked, and never change git config.
8383
The built-in commit and pull request procedure is opt-in. Enable it when your
84-
agents should commit or open PRs:
84+
agents should commit or open PRs; it replaces the short rules with the full
85+
procedure, which has its own safety protocol:
8586

8687
```json
8788
{ "git": { "write": true } }

‎packages/cli/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ By default the `bash` tool description includes only the git safety rules:
149149
- never update the git config or use interactive flags (`-i`);
150150
- use `gh` for GitHub tasks.
151151

152-
To include the built-in step-by-step commit and pull request procedure, set
153-
`git.write` in `aictrl.json`, or pass it inline with `AICTRL_CONFIG_CONTENT`:
152+
To use the built-in step-by-step commit and pull request procedure instead, set
153+
`git.write` in `aictrl.json`, or pass it inline with `AICTRL_CONFIG_CONTENT`. It
154+
replaces the short rules above with the full procedure and its own git safety
155+
protocol, as in earlier releases:
154156

155157
```json
156158
{ "git": { "write": true } }

‎packages/cli/src/config/config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ export namespace Config {
11331133
.boolean()
11341134
.optional()
11351135
.describe(
1136-
"Include the built-in git commit and pull request procedure in the bash tool description (default: false). Only the git safety rules are included otherwise",
1136+
"Replace the short git safety rules in the bash tool description with the full built-in commit and pull request procedure (default: false)",
11371137
),
11381138
})
11391139
.optional(),
File renamed without changes.

‎packages/cli/src/tool/bash.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Tool } from "./tool"
44
import path from "path"
55
import DESCRIPTION from "./bash.txt"
66
import GIT_SAFETY from "./bash-git-safety.txt"
7-
import GIT_PROCEDURE from "./bash-git.txt"
7+
import GIT_PROCEDURE from "./bash-git-procedure.txt"
88
import { Log } from "../util/log"
99
import { Config } from "../config/config"
1010
import { Instance } from "../project/instance"
@@ -92,8 +92,9 @@ async function extractEmbeddedCommands(
9292
}
9393

9494
/**
95-
* Every run gets the git safety rules. `git.write` opts in to the full commit and
96-
* pull request procedure. It only changes the prompt; permission rules restrict which git commands run.
95+
* By default the description carries the short git safety block. `git.write` replaces it with the
96+
* full commit and pull request procedure (the pre-opt-in text, which has its own safety protocol).
97+
* It only changes the prompt; permission rules restrict which git commands run.
9798
*/
9899
async function gitInstructions() {
99100
const config = await Config.get()
@@ -108,11 +109,11 @@ export const BashTool = Tool.define("bash", async () => {
108109
const git = await gitInstructions()
109110

110111
return {
111-
// A replacer function inserts the git text literally, without `$` pattern expansion
112+
// Replacer functions insert values literally, without `$` pattern expansion
112113
description: DESCRIPTION.replace("${git}", () => git)
113-
.replaceAll("${directory}", Instance.directory)
114-
.replaceAll("${maxLines}", String(Truncate.MAX_LINES))
115-
.replaceAll("${maxBytes}", String(Truncate.MAX_BYTES)),
114+
.replaceAll("${directory}", () => Instance.directory)
115+
.replaceAll("${maxLines}", () => String(Truncate.MAX_LINES))
116+
.replaceAll("${maxBytes}", () => String(Truncate.MAX_BYTES)),
116117
parameters: z.object({
117118
command: z.string().describe("The command to execute"),
118119
timeout: z.number().describe("Optional timeout in milliseconds").optional(),

‎packages/cli/test/tool/bash.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe("tool.bash", () => {
4545
describe("tool.bash description", () => {
4646
// Golden copy of bash.txt as it was before the git procedure became opt-in (#156).
4747
// It is kept separate from the shipped assets on purpose, so the git.write test proves the
48-
// opt-in reproduces that text. Update it together with any change to bash.txt or bash-git.txt.
48+
// opt-in reproduces that text. Update it together with any change to bash.txt or bash-git-procedure.txt.
4949
const withGit = path.join(__dirname, "fixtures/bash-description-with-git.txt")
5050

5151
async function description(config?: Partial<Config.Info>) {

0 commit comments

Comments
 (0)