havoc-rao/dsh-git-commit-agent ↗★ 0
dsh-git-commit-agent
Dedicated Git commit planning and execution agent for DSH: analyses status/diff, materialises an exact add/commit plan, binds user approval to a plan revision, and runs a restricted git CLI executor.
설치
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:havoc-rao/dsh-git-commit-agentdsh-git-commit-agent
A dedicated Git commit planning and execution agent for DSH.
The agent reads real repository state, proposes a small set of logically
coherent commits, shows the user an exact per-commit preview, and — only after
the user approves one specific plan revision — runs a restricted git executor
that stages exactly what was approved and verifies the result.
Planning and execution have different authority. Conversation never grants git write access.
GitLens entry ──▶ dedicated native session ──▶ status/diff analysis
│
plan revision + digest
│
user previews & approves (one revision)
│
restricted executor: exact stage → verify tree → git commit
│
report commits / partial failure / reconcile
Status
| Phase | State |
|---|---|
| P0 — host API verification | done, evidence in docs/P0-VERIFICATION.md |
| P1 — interactive planning (no real commit) | done: dedicated session composition, status/diff/read tools, whole-file plans, versioning, exact preview, old-revision invalidation |
| P2 — approval + execution loop | done: exact approval binding, executor, real add/commit, cancel, partial failure, hooks, reconciliation |
| P3 — hunk-level splitting, chat approval protocol | not started (by design) |
| GitLens button + DiffPane plan preview | implemented in src/client/ against the delivered better-sidebar seams; the boot graph carries the entry and the bundle is served — the browser render itself is not yet verified (see docs/P0-VERIFICATION.md §8.7) |
| Live DSH host integration | verified twice on 2026-09-14 (headless profile, scratch DSH_HOME): bare mount with inject: ['tools'] only, restricted 8-tool surface, guard denial, session visibility, uninstall disposal and a real commit — see docs/P0-VERIFICATION.md §7. The two rounds found and fixed three defects (missing lazy agents lookup; followup payload shape; default dataDir ignoring DSH_HOME) |
| Agent preset registration | implemented: the plugin registers itself as the git-commit agent preset through the host's ctx.agentPresets.register() (the same API the declarative @deepseek-ai/dsh-agent-preset plugin wraps), so it appears as a card in Settings → Agent presets; dedicated sessions bind that preset (meta.agentPreset + agentPresets.mount, the webhook session creator's pattern). Not yet verified on a live host (see Preset registration) |
122 automated tests pass against real, isolated git repositories (npm test).
Open remote repository
The command palette includes 打开远程仓库 / Open Remote Repository for the
active session, preferring its selected GitLens repository/worktree when available,
including clean checkouts. It reads fetch remotes through an authenticated,
session-scoped read-only endpoint, without contacting the remote or changing Git
state. origin opens directly; a single other remote also opens directly. If
there are multiple remotes without origin, the new tab presents a link chooser.
HTTP(S), git://, ssh://, and SCP-style git@host:owner/repo.git addresses
are converted to HTTPS repository pages. Credentials, query/fragment, and the
terminal .git suffix are removed; SSH/Git transport ports are not reused as web
ports. Local paths and unsupported transports are excluded. This opens the
configured remote (which may be a fork), not an automatically discovered upstream.
Custom SSH host aliases or separate SSH/Web domains need a real web-address
mapping and cannot be reliably inferred by this action. The current endpoint
supports local session repositories; detected SSH execution providers and remote
workspace mirrors fail closed rather than reading Git configuration on the wrong
machine.
Plan Inspector (including no active session)
With better-sidebar's inspectors feature, the plugin registers two stable
Inspector types: dsh-gca-plan (a publication snapshot) and dsh-gca-plans
(the recent-plan entry). The recent list uses the authenticated read-only
/git-commit-agent/api/plan-index route; it supports workspace-path filtering
and pagination without returning historical patches in list responses. The
current store keeps worktree paths rather than a separate registered workspace
identity, so the filter currently matches an exact worktree path.
明细 and 查看差异 on a transcript card navigate to the exact commit in one Inspector, rather than expanding a second copy of its details. Overview, commit index, dependency links, exclusions and revision delta navigate within that page. Diff is the saved publication patch (plain text), never a recomputed worktree diff. Truncated and unavailable historical previews remain explicit.
The source session belongs to the resource identity, not to its display seat. Opening a resource does not activate or resume its source session. Stable kinds allow the sidebar to restore references before any transcript mounts. Reopening the same revision updates its location; opening another revision uses a distinct resource id. Inspector mode does not poll full historical payloads or auto-open background publications; explicit navigation and list refresh never steal focus. Viewing is read-only and never constitutes approval.
Older sidebar installations without inspectors retain the session-scoped
native Plan tab fallback below (they cannot provide the no-session Inspector).
Full plan in the existing right sidebar (legacy fallback)
The prepare-plan transcript card now has 在侧栏查看完整计划. The page shows commit groups, the complete multi-line message, rationale, dependencies, file status/layer/rename/binary markers, stats, exclusions, warnings/blockers and the full revision/digest identity. Each group retains 查看差异. This is a read-only publication snapshot, not an approval surface; it remains available after an approval decision or execution.
While a dedicated commit session is mounted in the native right sidebar, the
client polls the plugin's authenticated, read-only plan route every two seconds.
The first successful response on initial load, every session switch or remount
is a historical baseline: it registers the pages without revealing them. Only
new identities seen subsequently in that same mounted session reveal a page.
Hidden browser documents do not reveal new plans. No private session event
source, conversation pagination hooks, approval listeners or apply_plan calls
are involved.
Native sidebar params/meta are transient and native opens ignore a seed's id.
Each revision therefore registers a hidden, stable tab kind encoding its session,
task, plan, revision and digest; repeated opens focus that same native page.
Payloads are stored atomically in private plugin presentation files and recovered
through /git-commit-agent/api/plan; legacy publications are recovered from the
session's durable successful prepare-tool results through a public read handle.
Recovery never recomputes patches from today's worktree. Missing historical
payloads are reported as unavailable, not invented. The sidebar layout itself
is managed by the host: if refresh collapses it, reopen the historical card.
Run npm run build for host artifacts. This package's hand-written client module
is already its served artifact; a browser refresh loads it. A running host must
reload/restart its existing plugin instance to mount new host HTTP routes (a
browser refresh alone cannot replace host code). Do not start another server to
update the original GUI. Authenticated browser rendering remains a separate
manual check when this agent has no browser session/cookie.
Command palette modes
The command palette offers two independent actions (search commit / 提交):
- 在当前工作区启动 Commit Agent / Start Commit Agent in Current Workspace: keeps the original behavior — creates a dedicated session in the current registered workspace, installs the plugin's restricted tools, applies the configured default model, and submits the planning request.
- 将提交规划 prompt 填入当前会话 / Fill Commit Planning Prompt in Current Session: fills and focuses the current session input box only. Review/edit the prompt and send it manually. It does not create or navigate to another session, change the model/preset, install tools, or automatically submit. The prompt follows the configured prompt language and asks the agent to use its existing tools to inspect changes and directly stage/commit under a one-time authorization for this commit task, with a brief result report rather than a lengthy plan or another confirmation round. Ambiguous scope or changes after inspection require clarification; tool approvals remain in force, and amend/push are not authorized. This is an ordinary agent conversation, not the plugin's revision/digest-bound approval and restricted executor workflow.
Both actions require the current main-view session to belong to a registered workspace. Input mode refuses to replace existing text, inline references or attachments, or a composer in a non-plain admission phase; send/clear the draft first. Existing session capabilities are preserved, not replaced with a new tool surface (including when the current session is already a dedicated commit agent).
Prerequisites
- A default model, or an explicit one. The dedicated session drives a real
agent turn. Configure
agentOptionsin the cordis row, or make sure the profile has a default model selected; otherwise the first turn ends at prompt assembly withprompt variable "{{model}}" has no value. - A writable data directory. It defaults to
$DSH_HOME/git-commit-agent(DSH_HOMEis respected; falls back to~/.dsh/git-commit-agent). Pointconfig.dataDirelsewhere if that is not writable — an unusable path fails loudly asDATA_DIR_UNAVAILABLEbefore any session is created. - Session persistence, if you want
resumeto work after a restart.
Install
dsh plugin --profile add dsh-git-commit-agent
The bundle mounts itself through dsh.bundle.patch in package.json and
cordis.patch.yml. See that file for the optional config block
(dataDir, lockDir, agentOptions).
The plugin mounts with inject: ['tools']. The agent registry is used lazily;
calling the dedicated-session API on a host without one fails with a clear
INTERNAL error instead of degrading silently.
Agent preset registration
On a host with the agent-preset registry (agentPresets service), the plugin
registers itself as the git-commit agent preset from apply():
ctx.agentPresets.register({
id: 'git-commit', // COMMIT_AGENT_PRESET_ID
name: 'Git Commit Agent',
order: 30,
plugins: [{ id: 'tool-fs', name: '@deepseek-ai/dsh-tool-fs' }],
})
This is the same API the declarative @deepseek-ai/dsh-agent-preset plugin
row wraps (PresetDefinition), just invoked from the plugin's own mount so the
definition cannot drift from this plugin's code. What it buys:
- the preset appears as a card in Settings → Agent presets
(
ui-agent-presetAgentPresetSection): viewable (its composition YAML) and selectable as the default — with zero client-side changes; - dedicated sessions bind that preset: the create/resume
setupcallsagentPresets.mount(agentCtx, 'git-commit')and the session header recordsagentPreset: git-commit, exactly like DSH's webhook session creator.
The composition supplies only the official native filesystem tools. Git capabilities
arrive from this plugin's host-plane installation (agent/created +
session-git-commit- prefix + restrict/guard), so the preset must not
declare dsh-git-commit-agent as a composition row — that would mount a second
plugin instance inside the preset scope (a second service, shared store, races)
and fail the registry's root-realm service-leak audit, marking the card broken.
Registration waits for the registry through Cordis
ctx.inject(['agentPresets'], callback); patch row order does not guarantee
service readiness. The dependency child owns unregistration, including teardown
while the registration promise is pending. Minimal embedders without inject
retain the one-shot lookup fallback. A successful registration logs
dsh-git-commit-agent: preset git-commit registered.
Current limitation: selecting this preset for an ordinary session does not install the Git-specific tools or the dedicated authorization scope: that installation still requires the dedicated session-id prefix. The ordinary session receives the preset's native filesystem tools under normal host policy. Do not treat this entry as a complete, independently usable default agent preset. A future composition entry must supply the tools and prompt by preset scope rather than by session id.
Prompt language preference
Both session entry paths (the GitLens button and the host startDedicatedSession
API) seed a prompt in one language, chosen from a single durable preference:
- the plugin declares a volatile settings field
promptLanguage(zh|en|follow-ui) on its own profile entry — the locale-preference template; the preset-card Configure button writes it throughconfigFormswith no custom persistence; follow-uidelegates to the active UI locale; a pinned value wins;- the host plane (no UI locale of its own, e.g. the business API) defaults to
en; the client plane falls back to its historical Chinese default only when neither a preference nor a UI locale is available; - the language is resolved at session admission and frozen into the first prompt; a settings change never rewrites a running session's text, and the client UI strings, the approval copy and the prompt language remain three independent text planes.
- the prompt itself is not the whole story: both the system prompt and the
first user message require the agent to drive the entire workflow through
the five tools (never guessing state or describing a plan without
commit_agent_prepare_plan) and require every user-facing message — analysis, plan explanation, suggested commit messages and progress reports — to be presented in the prompt's language (中文 forzh, English foren), so the session reads fluently in the chosen language even though the third planes (button labels, approval copy) keep their own translations.
Implementation: src/shared/config.ts owns the shared resolver, src/host/session.ts
builds both languages (default en), src/client/ mirrors the same rules.
Both fields become editable through the preset-card Configure button
(settings.agentPreset.card.action slot).
Default LLM model preference
Both session entry paths (the GitLens button and the host startDedicatedSession
API) can pin which LLM model the dedicated session runs on, chosen from the
host's model list (the same provider-grouped catalog the settings models
page renders):
- the plugin declares a volatile settings field
defaultModel({ provider, model }) on its own profile entry; the preset-card Configure dialog renders a picker populated fromremote.session.modelCatalog()and writes the exact route throughconfigForms; - no default model is a valid preference: the picker's first option is
"follow the host default (not specified)", which clears the field — the
deployment
agentOptionsrow or the host default model then applies; - precedence at session admission: stored
defaultModel(user's explicit choice, from the Configure dialog) → d