Repository navigation
Description
Environment: Git AI 1.7.5 (git-ai-macos-arm64, official release binary), macOS 26 arm64, git 2.54.0, daemon mode (trace2.eventTarget → daemon socket). Reproductions use a throwaway $HOME.
Setup. git-ai install-hooks installs both ~/.config/opencode/plugins/git-ai.ts and git-ai checkpoint claude hooks in ~/.claude/settings.json. The OpenCode plugin oh-my-opencode / oh-my-openagent runs the Claude Code hooks from ~/.claude/settings.json inside OpenCode, so one OpenCode edit triggers both presets with the same session id.
Actual. If the Claude PostToolUse checkpoint is processed first, the note attributes the lines to tool: "claude", model: "unknown" (the Claude preset finds no transcript, presets/claude.rs:75-84). The OpenCode checkpoint, which resolves the model from opencode.db, does not change it. In the other order, the note is correct.
Reproduction (preset payloads only; sandboxed GIT_AI_OPENCODE_STORAGE_PATH with an opencode.db whose session has modelID: claude-opus-5.5):
oc() { printf '{"hook_event_name":"%s","session_id":"ses_fixture_oc_1","tool_use_id":"call1","cwd":"%s","tool_name":"edit","tool_input":{"filePath":"%s/o.ts"}}' "$1" "$PWD" "$PWD" | git-ai checkpoint opencode --hook-input stdin; }
claude() { printf '{"hook_event_name":"%s","session_id":"ses_fixture_oc_1","tool_use_id":"call1","cwd":"%s","transcript_path":"/nonexistent.jsonl","tool_name":"Edit","tool_input":{"file_path":"%s/o.ts"}}' "$1" "$PWD" "$PWD" | git-ai checkpoint claude --hook-input stdin; }
oc PreToolUse; claude PreToolUse
printf 'export const a = 1\nexport const b = 2\n' > o.ts
claude PostToolUse; oc PostToolUse
git add -A && git commit -qm dup && git-ai await --timeout 30 && git notes --ref=ai show HEADNote: "agent_id": {"tool": "claude", "id": "ses_fixture_oc_1", "model": "unknown"}. The same sequence with oc PostToolUse first records tool: opencode, model: claude-opus-5.5.
Expected. One edit gets one attribution with the most specific metadata. Possible fixes: the Claude preset skips payloads when OPENCODE is set (as it already does for Cursor/VS Code Copilot payloads in ClaudePreset::parse), or the installer writes a guarded hook command.
Workaround in use. [ -n "$OPENCODE" ] || exec /path/to/git-ai checkpoint claude --hook-input stdin in both Claude hook commands. Re-running git-ai install-hooks removes the guard: in 1.7.5, install_hooks_at (src/mdm/agents/claude_code.rs) rewrites any git-ai checkpoint command whose text differs from the default. The installer (install.sh runs git-ai install-hooks --env) and git-ai upgrade go through the same code.
(Edited: this issue was originally created by mistake from the tail of #2395; that text has been moved back to #2395.)
Activity
[-]{}, "humans": { "h_4cad400a95f459": { "author": "Fixture Dev <[email protected]>" } } }[/-][+]Claude Code hooks replayed inside OpenCode override the OpenCode checkpoint (`tool: claude`, `model: unknown`)[/+]