diff --git a/README.md b/README.md index d1be259..37ec0fd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Claude Code mods (plugins with a hooks module), served as a local folder marketp | mod | version | what it does | | --- | --- | --- | | [harness](harness/) | 0.5.0 | The integrated harness: the user's Claude rules enforced at the tool call, session tooling and workflow automation (formerly house-rules) | -| [auto-claude](auto-claude/) | 1.4.0 | Unattended run of a repository through to live: plans the long-term goal, milestones and deploy; its own loop builds and judges each milestone in a worktree; ships each (push, PR, required CI, merge), deploys and smoke-checks it; a watchdog repairs or routes around stalls; replans until the final check passes. Absorbed goal-mode in 1.0.0; since 1.1.0 the session never rests: the next milestone is built, stacked, while a PR waits on CI; since 1.3.0 a line can wait on a training run or cache build (`:: after:`, `wait_until`) without ending the run; since 1.4.0 `--always-on` stands by after the final check and wakes for new cycles from Linear, the live smoke check, the default branch's CI and labelled GitHub issues | +| [auto-claude](auto-claude/) | 1.4.1 | Unattended run of a repository through to live: plans the long-term goal, milestones and deploy; its own loop builds and judges each milestone in a worktree; ships each (push, PR, required CI, merge), deploys and smoke-checks it; a watchdog repairs or routes around stalls; replans until the final check passes. Absorbed goal-mode in 1.0.0; since 1.1.0 the session never rests: the next milestone is built, stacked, while a PR waits on CI; since 1.3.0 a line can wait on a training run or cache build (`:: after:`, `wait_until`) without ending the run; since 1.4.0 `--always-on` stands by after the final check and wakes for new cycles from Linear, the live smoke check, the default branch's CI and labelled GitHub issues | | [model-tier](model-tier/) | 0.11.0 | Routes each main-loop turn to fable, opus, sonnet or haiku and a reasoning effort by task complexity, with a `set_tier` tool the model calls to correct either | | [refactor](refactor/) | 0.1.3 | Enforces the architecture a repo declares in `.claude/architecture.json` at Edit/Write (layer direction, forbidden imports), notes code smells with the refactoring.guru technique to apply, `/arch audit` for violations and import cycles | diff --git a/auto-claude/.claude-plugin/plugin.json b/auto-claude/.claude-plugin/plugin.json index 3aa5a93..549e4e9 100644 --- a/auto-claude/.claude-plugin/plugin.json +++ b/auto-claude/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "auto-claude", - "version": "1.4.0", + "version": "1.4.1", "description": "Finishes a repository's work unattended and live: Claude plans the long-term end state, its milestones and how it deploys; the built-in loop builds each milestone in its own worktree and judges it; auto-claude ships it (push, PR, CI, merge when green), deploys and smoke-checks it, and a watchdog keeps the run moving until the final check passes. With --always-on it does not end there: it stands by with no model turn and wakes for a new cycle when Linear, the live smoke check, the default branch's CI or a labelled GitHub issue gives it work (1.4.0). Absorbs goal-mode's loop (1.0.0).", "author": { "name": "unohee" diff --git a/auto-claude/hooks/auto.test.ts b/auto-claude/hooks/auto.test.ts index c80d95f..6d52932 100644 --- a/auto-claude/hooks/auto.test.ts +++ b/auto-claude/hooks/auto.test.ts @@ -530,6 +530,18 @@ describe('a run, local CI', () => { expect(text).toContain('no "Deploy:') }) + test('a reload while the session sits in a removed worktree keeps ticking the run', async ($, on) => { + const w = world(on) + await planned($, w) + await meet($, w) + const beat = () => (JSON.parse(w.files.get('/repo/.claude/auto-claude.on') ?? '{}') as { at?: number }).at ?? 0 + w.gone.add('/repo/worktrees/goal-01-landed') + await $.session.start({ cwd: '/repo/worktrees/goal-01-landed', surface: 'terminal', isInteractive: true }) + const before = beat() + await w.clock.advance(TICK) + expect(beat()).toBeGreaterThan(before) + }) + test('start from a session whose directory was a removed worktree finds the repository above it', async ($, on) => { const w = world(on) await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true }) diff --git a/auto-claude/hooks/register.ts b/auto-claude/hooks/register.ts index f4803e4..5c50d07 100644 --- a/auto-claude/hooks/register.ts +++ b/auto-claude/hooks/register.ts @@ -188,9 +188,17 @@ async function show($: EngineInterface, r: AutoRecord | undefined) { // used to read as "Not inside a git repository". async function sessionRoot($: EngineInterface): Promise<{ root?: string; cwd: string; used: string }> { const cwd = await $.session.cwd() + const dir = await existingDir($, cwd) + return { root: await repoRoot($, dir), cwd, used: dir } +} + +// The session's directory, or the nearest one above it that still exists: a +// session left in a milestone worktree the driver removed after its merge has a +// directory git cannot start in. +async function existingDir($: EngineInterface, cwd: string): Promise { let dir = cwd while (dir !== '/' && !(await $.fs.exists(dir).catch(() => true))) dir = dir.slice(0, dir.lastIndexOf('/')) || '/' - return { root: await repoRoot($, dir), cwd, used: dir } + return dir } const notInRepo = (s: { cwd: string; used: string }) => @@ -1339,7 +1347,9 @@ export const register: Register = (on, options) => { setOnFinish(() => { $.clock.after(100, () => void tick($, caps, pollMs)) }) - const root = await repoRoot($, e.cwd).catch(() => undefined) + // A reload while the session sits in a removed worktree used to leave no root: + // every tick returned at once, and the run stood still without a word. + const root = await repoRoot($, await existingDir($, e.cwd)).catch(() => undefined) activeRoot = root const r = root === undefined ? undefined : await readRecord($, root) if (r?.on === true && r.phase === 'run' && r.sessionId === (await $.session.id())) await recoverLoop($, r).catch(() => undefined)