plans/git_tools.md
Add six current-app Git tools: read-only git_status, git_diff, git_log,
git_show_commit, and git_show_file, plus state-changing
git_restore_file. The read tools remain available in ask and plan modes;
restore is filtered from those modes and restores one historical file into
the working tree without changing the index. Replayed assistant turns also
receive one in-memory Git-context annotation so the agent can connect prior
responses to the relevant repository state.
git_statusgit_status({});
git_diffgit_diff({
scope?: "unstaged" | "staged" | "all"; // defaults to all
path?: string;
context_lines?: number; // defaults to 3, range 0-20
})
unstaged compares the index with the working tree.staged compares HEAD with the index.all compares HEAD with the working tree, including staged and unstaged
tracked changes but not untracked files; git_status reports those.git_loggit_log({
revision?: string; // defaults to HEAD
max_count?: number; // defaults to 20, range 1-100
path?: string;
})
git_show_commitgit_show_commit({
revision: string;
path?: string;
})
git_show_filegit_show_file({
revision: string;
path: string;
start_line_one_indexed?: number;
end_line_one_indexed_inclusive?: number;
})
git_restore_filegit_restore_file({
revision: string;
path: string;
})
modifiesState: true and default consent to always.commitHash exists, append
<dyad-git-context commit="FINAL_HASH"></dyad-git-context>.sourceCommitHash exists, append
<dyad-git-context source_commit="START_HASH" no_commit="true"></dyad-git-context>.source_commit as "HEAD when the turn began," not an exact snapshot of
every working-tree file the assistant saw. Treat commit as the repository
commit recorded after the turn, not proof that every included change was
authored by that assistant response.ModelMessage[] passed to the model.
Do not write them into message content or aiMessagesJson, and do not
render them in the chat UI. Escape attribute values before constructing XML.src/ipc/utils/git_utils.ts: canonicalize refs to commit OIDs; disable
replace refs, pagers, external diffs, and textconv; force literal pathspecs;
avoid shell execution; and bound model-visible output.Validation, missing
repositories/files as NotFound or Precondition, and user-fixable
repository failures as Conflict.src/pro/main/ipc/handlers/local_agent/tools/ and expose compact Git cards
through src/components/chat/DyadMarkdownParser.tsx, showing operation,
scope, short revision, path, and pending/finished state without embedding
full output in the card.git_restore_file appears only in writable agent mode and
participates in consent and blueprint gating.content or
aiMessagesJson.npm run ts; rebuild
before any targeted Playwright snapshot verification.app_name parameter is
added.git_diff does not compare arbitrary revisions in v1;
git_show_commit remains the historical commit-patch interface.HEAD, a branch/tag, or an abbreviated/full commit hash,
but not revision ranges or arbitrary Git options.git checkout HASH -- FILE_PATH index semantics.