You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements the CodingAgentDriver interface (#4262, this batch — foundational, must land first) for the "run a local CLI as a subprocess" case: claude (Claude Code CLI) or codex, invoked NOT for a review opinion (the existing createClaudeCodeAi/createCodexAi use in src/selfhost/ai.ts) but to actually edit files in a scoped local working directory. The subprocess-spawning, secret-redaction, and per-effort-timeout machinery this needs already exists in src/selfhost/ai.ts for the review use case — this issue reuses it rather than re-inventing it.
Deliverables
packages/gittensory-engine/src/miner/cli-subprocess-driver.ts (path coordinated with feat(miner-hands): define the CodingAgentDriver interface seam #4262's src/miner/ home) implementing CodingAgentDriver by spawning claude/codex as a subprocess against the scoped working directory, using an injected SpawnFn-shaped function — the exact type from src/selfhost/ai.ts:627-641, generalized so this package doesn't import from src/ directly (packages/gittensory-engine is meant to stand alone).
Reuse (not duplicate) redactSecrets's behavior (src/selfhost/ai.ts:724-731) on any subprocess stderr/output this driver surfaces in errors or logs — a coding-agent invocation is exactly as capable of echoing a leaked token as the existing review invocation is.
Reuse the per-effort timeout ladder pattern (CLAUDE_EFFORT_TIMEOUT_MS/CODEX_EFFORT_TIMEOUT_MS, src/selfhost/ai.ts:185-186, and resolveCliTimeoutFrom, :188-192) rather than one fixed timeout — a coding-agent invocation legitimately runs far longer than a review call (it edits files, runs commands, iterates), so this needs its own ceiling, sized independently from the review ladder (mirror the pattern, don't import/share its constants directly).
Unlike createClaudeCodeAi's review invocation (--permission-mode plan --disallowedTools Bash,Edit,Write,WebFetch,WebSearch, src/selfhost/ai.ts:809), this driver's whole point is letting the CLI edit files — it must NOT reuse that disallowed-tools flag set. Document explicitly which flags differ and why, so a future reader doesn't assume this is a copy-paste of the review call.
Tests with an injected fake SpawnFn (no real subprocess spawned in CI), covering: success with changed files, non-zero exit, timeout, and a redacted-secret-in-stderr case — mirroring the existing createClaudeCodeAi/createCodexAi test patterns.
References
src/selfhost/ai.ts:627-641 (SpawnFn type)
src/selfhost/ai.ts:644-711 (defaultSpawn — the real child_process.spawn wiring this driver's production SpawnFn should mirror, including timeout/kill handling)
src/selfhost/ai.ts:772-838 (createClaudeCodeAi — closest existing example of spawning claude as a subprocess, albeit for review not editing)
src/selfhost/ai.ts:349-404 (SUBSCRIPTION_CLI_ENV_ALLOWLIST, subscriptionCliEnv — env isolation this driver should also apply; generalized further in a separate issue in this batch)
Implements the
CodingAgentDriverinterface (#4262, this batch — foundational, must land first) for the "run a local CLI as a subprocess" case:claude(Claude Code CLI) orcodex, invoked NOT for a review opinion (the existingcreateClaudeCodeAi/createCodexAiuse insrc/selfhost/ai.ts) but to actually edit files in a scoped local working directory. The subprocess-spawning, secret-redaction, and per-effort-timeout machinery this needs already exists insrc/selfhost/ai.tsfor the review use case — this issue reuses it rather than re-inventing it.Deliverables
packages/gittensory-engine/src/miner/cli-subprocess-driver.ts(path coordinated with feat(miner-hands): define the CodingAgentDriver interface seam #4262'ssrc/miner/home) implementingCodingAgentDriverby spawningclaude/codexas a subprocess against the scoped working directory, using an injectedSpawnFn-shaped function — the exact type fromsrc/selfhost/ai.ts:627-641, generalized so this package doesn't import fromsrc/directly (packages/gittensory-engineis meant to stand alone).redactSecrets's behavior (src/selfhost/ai.ts:724-731) on any subprocess stderr/output this driver surfaces in errors or logs — a coding-agent invocation is exactly as capable of echoing a leaked token as the existing review invocation is.CLAUDE_EFFORT_TIMEOUT_MS/CODEX_EFFORT_TIMEOUT_MS,src/selfhost/ai.ts:185-186, andresolveCliTimeoutFrom,:188-192) rather than one fixed timeout — a coding-agent invocation legitimately runs far longer than a review call (it edits files, runs commands, iterates), so this needs its own ceiling, sized independently from the review ladder (mirror the pattern, don't import/share its constants directly).createClaudeCodeAi's review invocation (--permission-mode plan --disallowedTools Bash,Edit,Write,WebFetch,WebSearch,src/selfhost/ai.ts:809), this driver's whole point is letting the CLI edit files — it must NOT reuse that disallowed-tools flag set. Document explicitly which flags differ and why, so a future reader doesn't assume this is a copy-paste of the review call.SpawnFn(no real subprocess spawned in CI), covering: success with changed files, non-zero exit, timeout, and a redacted-secret-in-stderr case — mirroring the existingcreateClaudeCodeAi/createCodexAitest patterns.References
src/selfhost/ai.ts:627-641(SpawnFntype)src/selfhost/ai.ts:644-711(defaultSpawn— the realchild_process.spawnwiring this driver's productionSpawnFnshould mirror, including timeout/kill handling)src/selfhost/ai.ts:724-731(redactSecrets)src/selfhost/ai.ts:185-200(CLAUDE_EFFORT_TIMEOUT_MS/CODEX_EFFORT_TIMEOUT_MS,resolveCliTimeoutFrom,resolveClaudeCliTimeoutMs,resolveCodexCliTimeoutMs)src/selfhost/ai.ts:772-838(createClaudeCodeAi— closest existing example of spawningclaudeas a subprocess, albeit for review not editing)src/selfhost/ai.ts:349-404(SUBSCRIPTION_CLI_ENV_ALLOWLIST,subscriptionCliEnv— env isolation this driver should also apply; generalized further in a separate issue in this batch)CodingAgentDriverinterface this implements