Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.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 |
| [auto-claude](auto-claude/) | 1.5.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; since 1.5.0 a run whose session went quiet is taken over by any free session of the repository |
| [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 |

Expand Down
2 changes: 1 addition & 1 deletion auto-claude/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auto-claude",
"version": "1.4.1",
"version": "1.5.0",
"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"
Expand Down
4 changes: 2 additions & 2 deletions auto-claude/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ With `--always-on` (or the `alwaysOn` option), a run does not end when its final
- **Caps.** `maxMerges` and `maxHours` count per cycle; standby time counts toward neither. `maxMergesPerDay` (20) holds a wake back while the last 24 h hold that many merges, told once. 3 deploys failing in a row still stop the run.
- **Memory.** Each cycle adds one line under `## Cycles` in `auto-plan.md`: what woke it, what merged, was held and deployed. On entering standby the session is compacted once (when its context is 30% full or more), keeping the goal, decisions and cycles.
- **Quiet.** In standby a person is told only of a wake (and why), a cycle's end, a failing smoke check or GitHub poll, and the daily cap.
- **Limits.** The worker is the session: if it exits, nothing polls until `/auto-claude resume` in a session (other sessions report it orphaned). An external supervisor, Remote Control or webhook inboxes, and answering a deferred milestone are not part of this.
- **Limits.** The worker is a session: if it exits, nothing polls until another session of the repository takes the run over (below) or `/auto-claude resume`. An external supervisor, Remote Control or webhook inboxes, and answering a deferred milestone are not part of this.

## Deploying

Expand Down Expand Up @@ -153,7 +153,7 @@ A run never asks the person to look at `status` or to run a command. When someth
| The same cause holds two milestones in a row (no runner, gh not logged in) | The run stops and names the cause, instead of holding every later milestone. |
| A tick that fails 3 times in a row | Reported once with its error. `stalled: every tick fails` stays in `status` until a tick gets through. |
| Nothing started, shipped or merged for 15 min | The person is told the cause and that the watchdog is on it: at 15 min, 30 min later, and once more. |
| The owning session goes quiet for 10 min | Other sessions report the run as orphaned. `/auto-claude resume` takes it over there, including the milestone being built. |
| The owning session goes quiet for 10 min (exited, replaced after a reboot, or the person moved to another session) | Any session of the same repository takes the run over by itself, with the milestone being built, once it has been free for 2 min (no turn running), and says so. A busy session only reports the run as orphaned, until it is free. A `.claude/auto-claude.stop` left in place keeps it reported, not taken. Two sessions claiming at once: the claim still in the store after 3 s goes on. `/auto-claude resume` takes it over at once. |

`/auto-claude status` ends with a `stalled:` line naming the cause whenever the run is not moving. Only the owning session receives the unattended rules. Progress shows in the status line piece (`auto·R1·M3/7·PR#12`) and in notifications.

Expand Down
75 changes: 73 additions & 2 deletions auto-claude/hooks/auto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,9 @@ describe('a run, local CI', () => {
w.files.set(GOALS, QUEUE)
await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true })
expect(JSON.stringify(await compose($))).not.toContain('auto-claude:policy')
await w.clock.advance(TICK)
await w.clock.advance(TICK)
// The person is busy in this session: the run is reported, not taken.
await turnStart($)
for (let i = 0; i < 6; i++) await w.clock.advance(TICK)
expect(w.notifies.filter(n => n.includes('went quiet'))).toHaveLength(1)
expect(w.notifies[0]).toContain('/auto-claude resume in this session takes it over')
expect(w.prompts).toEqual([])
Expand Down Expand Up @@ -506,6 +507,76 @@ describe('a run, local CI', () => {
expect((await cmd($, 'status')).text).toContain('auto-claude on')
})

test('a free session of the repository takes over a run whose owner went quiet, with its milestone', async ($, on) => {
const other = { on: true, phase: 'run', root: '/repo', sessionId: 'gone-owner', hint: '', round: 1, startedAt: 0, beatAt: -20 * MIN, remote: 'origin', defaultBranch: 'main', ciMode: 'local', logOffset: 0, started: 1, finished: 0, worktrees: { [BR1]: WT1 }, ships: [], fixes: {}, merges: 0, held: 0, queueEmpty: false }
const loop = { repoRoot: '/repo', seq: 1, retries: 0, current: { condition: 'add() returns a+b', check: 'python3 -m unittest -q test_add', worktree: WT1, branch: BR1, startedAt: 0 } }
const w = world(on, { 'auto:/repo': other, 'loop:/repo': loop })
w.files.set(GOALS, QUEUE)
await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true })
// Not before the session has been free for 2 min.
await w.clock.advance(TICK)
expect(w.prompts).toEqual([])
for (let i = 0; i < 5; i++) await w.clock.advance(TICK)
await w.clock.advance(5_000)
const taken = w.prompts.find(p => p.includes('Continuing (taken over from session gone-own'))
expect(taken).toContain('Milestone #1: add() returns a+b')
expect(w.notifies.some(n => n.includes('this session took the run over'))).toBe(true)
expect(JSON.stringify(await compose($))).toContain('auto-claude:policy')
await meet($, w)
await w.clock.advance(TICK)
expect(w.pushes.some(p => p.includes('HEAD:main'))).toBe(true)
})

test('an owner whose long tick still pulses (a deploy, CodeQL) is not taken over; once the pulse stops it is', { timeoutMs: 30_000 }, async ($, on) => {
const other = { on: true, phase: 'run', root: '/repo', sessionId: 'busy-owner', hint: '', round: 1, startedAt: 0, beatAt: -20 * MIN, remote: 'origin', defaultBranch: 'main', ciMode: 'local', logOffset: 0, started: 1, finished: 1, worktrees: {}, ships: [], fixes: {}, merges: 0, held: 0, queueEmpty: false }
const w = world(on, { 'auto:/repo': other, 'beat:/repo': { sessionId: 'busy-owner', at: 10 * MIN } })
w.files.set(GOALS, QUEUE)
await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true })
for (let i = 0; i < 30; i++) await w.clock.advance(TICK)
expect(w.notifies.some(n => n.includes('took the run over') || n.includes('went quiet'))).toBe(false)
for (let i = 0; i < 12; i++) await w.clock.advance(TICK)
await w.clock.advance(5_000)
expect(w.notifies.some(n => n.includes('took the run over'))).toBe(true)
})

test('a run quiet for more than 12 h is only reported, not taken', async ($, on) => {
const other = { on: true, phase: 'plan', root: '/repo', sessionId: 'old-owner', hint: '', round: 1, startedAt: 0, beatAt: -13 * 60 * MIN, remote: 'origin', defaultBranch: 'main', ciMode: 'local', logOffset: 0, started: 0, finished: 0, worktrees: {}, ships: [], fixes: {}, merges: 0, held: 0, queueEmpty: false }
const w = world(on, { 'auto:/repo': other })
await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true })
for (let i = 0; i < 8; i++) await w.clock.advance(TICK)
expect(w.notifies.some(n => n.includes('took the run over'))).toBe(false)
expect(w.notifies.some(n => n.includes('went quiet'))).toBe(true)
expect(w.prompts).toEqual([])
})

test('taking a run over keeps its deploy brake and time cap, skipping only the dead gap', async ($, on) => {
const other = { on: true, phase: 'run', root: '/repo', sessionId: 'gone-owner', hint: '', round: 1, startedAt: -60 * MIN, beatAt: -20 * MIN, remote: 'origin', defaultBranch: 'main', ciMode: 'local', logOffset: 0, started: 1, finished: 1, worktrees: {}, ships: [], fixes: {}, merges: 0, held: 0, queueEmpty: false, deployFails: 2, holdStreak: 1 }
const w = world(on, { 'auto:/repo': other })
w.files.set(GOALS, QUEUE)
await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true })
for (let i = 0; i < 6; i++) await w.clock.advance(TICK)
await w.clock.advance(5_000)
expect(w.notifies.some(n => n.includes('took the run over'))).toBe(true)
const status = (await cmd($, 'status')).text ?? ''
expect(status).toContain('auto-claude on')
expect(JSON.parse(w.files.get('/repo/.claude/auto-claude.on') ?? '{}')).toMatchObject({ on: true, phase: 'run' })
})

test('a stop file the person left keeps an orphaned run reported, not taken; once it is gone the run is taken', async ($, on) => {
const other = { on: true, phase: 'run', root: '/repo', sessionId: 'gone-owner', hint: '', round: 1, startedAt: 0, beatAt: -20 * MIN, remote: 'origin', defaultBranch: 'main', ciMode: 'local', logOffset: 0, started: 1, finished: 1, worktrees: {}, ships: [], fixes: {}, merges: 0, held: 0, queueEmpty: false }
const w = world(on, { 'auto:/repo': other })
w.files.set(GOALS, QUEUE)
w.files.set('/repo/.claude/auto-claude.stop', '')
await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true })
for (let i = 0; i < 6; i++) await w.clock.advance(TICK)
expect(w.notifies.some(n => n.includes('took the run over'))).toBe(false)
expect(w.notifies.some(n => n.includes('went quiet'))).toBe(true)
w.files.delete('/repo/.claude/auto-claude.stop')
await w.clock.advance(TICK)
await w.clock.advance(5_000)
expect(w.notifies.some(n => n.includes('took the run over'))).toBe(true)
})

test('status names an orphaned owner and how long ago it last ticked', async ($, on) => {
const other = { on: true, phase: 'run', root: '/repo', sessionId: 'gone-session', hint: '', round: 1, startedAt: 0, beatAt: 1_000 - 25 * MIN, remote: 'origin', defaultBranch: 'main', ciMode: 'local', logOffset: 0, started: 1, finished: 1, worktrees: {}, ships: [], fixes: {}, merges: 1, held: 0, queueEmpty: false }
world(on, { 'auto:/repo': other })
Expand Down
Loading
Loading