|
1 | 1 | import { getAccountToken } from "./accounts"; |
2 | 2 | import { capturePageScreenshot } from "./browser-capture"; |
3 | | -import { shellQuote } from "./command-sandbox"; |
4 | 3 | import * as settingsStore from "./settings-store"; |
5 | 4 | import * as terminalManager from "./terminal-manager"; |
6 | 5 | import { AGENT_TOOLS } from "./agent-tools/schema"; |
@@ -35,6 +34,7 @@ import { |
35 | 34 | killAllBackgroundCommands, |
36 | 35 | killBackgroundCommandsForWorkspace, |
37 | 36 | } from "./agent-tools/execution"; |
| 37 | +import { gitStatus, gitDiff, gitLog, gitCommit } from "./agent-tools/git"; |
38 | 38 |
|
39 | 39 | export { AGENT_TOOLS }; |
40 | 40 | export { |
@@ -67,30 +67,7 @@ export { |
67 | 67 | killAllBackgroundCommands, |
68 | 68 | killBackgroundCommandsForWorkspace, |
69 | 69 | }; |
70 | | - |
71 | | -function gitCommand(workspaceRoot: string, args: string): Promise<string> { |
72 | | - return runCommand(workspaceRoot, `git ${args}`, "."); |
73 | | -} |
74 | | - |
75 | | -export function gitStatus(workspaceRoot: string): Promise<string> { |
76 | | - return gitCommand(workspaceRoot, "status"); |
77 | | -} |
78 | | - |
79 | | -export function gitDiff(workspaceRoot: string, staged = false, relativePath?: string): Promise<string> { |
80 | | - const target = relativePath ? ` -- ${shellQuote(relativePath)}` : ""; |
81 | | - return gitCommand(workspaceRoot, `diff${staged ? " --staged" : ""}${target}`); |
82 | | -} |
83 | | - |
84 | | -export function gitLog(workspaceRoot: string, count = 10): Promise<string> { |
85 | | - return gitCommand(workspaceRoot, `log -n ${Math.max(1, Math.min(count, 100))} --oneline`); |
86 | | -} |
87 | | - |
88 | | -export async function gitCommit(workspaceRoot: string, message: string): Promise<string> { |
89 | | - await gitCommand(workspaceRoot, "add -A"); |
90 | | - // JSON.stringify escapes `"` and `\` but not `$` or backticks, and the |
91 | | - // result is handed to `sh -c` — so it is not a shell-quoting function. |
92 | | - return gitCommand(workspaceRoot, `commit -m ${shellQuote(message)}`); |
93 | | -} |
| 70 | +export { gitStatus, gitDiff, gitLog, gitCommit }; |
94 | 71 |
|
95 | 72 | const WEB_FETCH_TIMEOUT_MS = 15_000; |
96 | 73 | const MAX_FETCH_CHARS = 30_000; |
|
0 commit comments