@ngockhoale/ukit 2.0.7 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/manifests/platform.full.yaml +11 -0
- package/package.json +1 -1
- package/templates/.claude/agents/code-reviewer.md +21 -0
- package/templates/.claude/agents/feature-implementer.md +30 -2
- package/templates/.claude/agents/handoff-planner.md +101 -5
- package/templates/.claude/commands/ukit/handoff-create.md +32 -2
- package/templates/.claude/commands/ukit/handoff-fullstack.md +208 -22
- package/templates/.claude/commands/ukit/handoff-implement.md +109 -18
- package/templates/.claude/commands/ukit/handoff-review.md +100 -31
- package/templates/.claude/hooks/context-hardcap-gate.sh +67 -0
- package/templates/.claude/hooks/context-window-guard.sh +34 -1
- package/templates/.claude/hooks/handoff-model-guard.sh +12 -0
- package/templates/.claude/hooks/handoff-resume.sh +90 -0
- package/templates/.claude/settings.json +9 -1
- package/templates/docs/AI_HANDOFF/RULES.md +52 -2
- package/templates/ukit/storage/config.json +15 -1
|
@@ -22,6 +22,66 @@ $ARGUMENTS
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
+
## Autonomy Contract — read before anything else
|
|
26
|
+
|
|
27
|
+
This command is a **one-shot pipeline**. The human is not watching. Treat every phase below
|
|
28
|
+
as unattended: they may walk away after submitting `$ARGUMENTS` and come back to a finished
|
|
29
|
+
result.
|
|
30
|
+
|
|
31
|
+
**The single question window is P0, before any file is written.** If `$ARGUMENTS` leaves a
|
|
32
|
+
choice that would change what gets built — not how it gets built — batch every such question
|
|
33
|
+
into **one** `AskUserQuestion` call (max 4 questions, each with a `(Recommended)` first
|
|
34
|
+
option) and resolve them all at once. Record the answers in `PLAN.md` §1.
|
|
35
|
+
|
|
36
|
+
**After P0 closes, do not ask the human anything until the Final Report.** Every decision
|
|
37
|
+
point in the phases below has a defined automatic resolution. Take it. Specifically:
|
|
38
|
+
|
|
39
|
+
| Situation | Old behavior | Required behavior now |
|
|
40
|
+
|-----------|--------------|----------------------|
|
|
41
|
+
| Scope spans multiple subsystems | wait for confirmation | decompose into sequential cycles, run cycle 1 now, queue the rest in `INDEX.md` |
|
|
42
|
+
| Plan review returns `Issues Found` | up to 3 rounds, then stop | 1 revision round; if round 2 still has findings, apply them and proceed — log to `## Plan Review Log` |
|
|
43
|
+
| Two same-wave tasks share a file | STOP | move the later task to the next wave (add the dependency), continue |
|
|
44
|
+
| INDEX has `pending_review`/`blocked` tasks | STOP | **resume** — see Resume below |
|
|
45
|
+
| Reviewer returns `changes_requested`/`critical_block` | report and stop | run the Phase 4 auto-fix loop (max 2 rounds) |
|
|
46
|
+
| Verification command fails | stop | fix and re-verify inside the auto-fix loop |
|
|
47
|
+
|
|
48
|
+
Escalate to the human **only** for: a blocker outside the repo (missing credential, external
|
|
49
|
+
service down), or a task still failing after both auto-fix rounds. Even then, finish every
|
|
50
|
+
other task first and report what was left undone.
|
|
51
|
+
|
|
52
|
+
**Never pause to ask for `/compact`.** Context is managed structurally — subagents write full
|
|
53
|
+
logs to disk and return short summaries (see 3b), and the run cursor makes the pipeline
|
|
54
|
+
resumable. If compaction does happen, the run resumes from the cursor automatically.
|
|
55
|
+
|
|
56
|
+
### Run cursor — write after every step
|
|
57
|
+
|
|
58
|
+
Maintain `docs/AI_HANDOFF/RUN.md`. Rewrite it (whole file, 6 lines) immediately after every
|
|
59
|
+
numbered step completes:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Command: handoff-fullstack
|
|
63
|
+
Goal: <one sentence from $ARGUMENTS>
|
|
64
|
+
Base: <BASE branch>
|
|
65
|
+
Phase: <P1|P2|P2.5|P3|I1|I2|I3|I4|R1|R2|R3|R4|R5|done>
|
|
66
|
+
Cursor: wave <N> batch <M> — <what just finished>
|
|
67
|
+
Next: <the exact next step to run>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This file is the resume contract. It costs one small write per step and is what turns an
|
|
71
|
+
interrupted run into a continuable one.
|
|
72
|
+
|
|
73
|
+
### Resume — when the run is re-invoked mid-flight
|
|
74
|
+
|
|
75
|
+
If `docs/AI_HANDOFF/RUN.md` exists with `Phase:` not `done`, this is a **continuation, not a
|
|
76
|
+
new cycle**. Do NOT re-plan, do NOT overwrite `PLAN.md`, do NOT ask the human whether to
|
|
77
|
+
continue. Read the cursor, then jump straight to `Next:` and carry on. Tasks already `done`
|
|
78
|
+
or `pending_review` are skipped; only `ready`, `in_progress`, `changes_requested` and
|
|
79
|
+
`blocked` tasks are picked up.
|
|
80
|
+
|
|
81
|
+
Only when `RUN.md` is absent or `Phase: done` does `$ARGUMENTS` start a fresh cycle.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
25
85
|
## Phase 1+2 — Plan (strong model)
|
|
26
86
|
|
|
27
87
|
### P1 — Read context (lite model)
|
|
@@ -45,7 +105,7 @@ The planner agent does the following (use P1 summary — do NOT re-read files):
|
|
|
45
105
|
|
|
46
106
|
1. **Guard — check INDEX statuses:**
|
|
47
107
|
- All tasks are `ready` (planning only) → re-run is allowed: overwrite `PLAN.md` and `TASK-xxx.md` freely (iterative refinement).
|
|
48
|
-
- Any task has status `pending_review`, `changes_requested`, `merge_conflict`, or `blocked` → **
|
|
108
|
+
- Any task has status `pending_review`, `changes_requested`, `merge_conflict`, or `blocked` → **do not overwrite, and do not stop either.** Mid-flight work exists. Skip the rest of P2 entirely, write the run cursor with `Phase: I1`, and hand control back to the orchestrator to resume from Phase 3 with the surviving tasks (see Resume in the Autonomy Contract). Overwriting is what is unsafe here — stopping is not required.
|
|
49
109
|
- No tasks → fresh cycle, proceed.
|
|
50
110
|
|
|
51
111
|
2. **Resolve base branch:**
|
|
@@ -91,12 +151,19 @@ The planner agent does the following (use P1 summary — do NOT re-read files):
|
|
|
91
151
|
|
|
92
152
|
### P2.5 — Independent plan review (strong model, separate agent)
|
|
93
153
|
|
|
94
|
-
**Loop cap — check first:** count `### Round` entries in PLAN.md's `## Plan Review Log` (0 if the section doesn't exist yet).
|
|
154
|
+
**Loop cap — check first:** count `### Round` entries in PLAN.md's `## Plan Review Log` (0 if the section doesn't exist yet).
|
|
155
|
+
|
|
156
|
+
- count = 0 → run the review below.
|
|
157
|
+
- count = 1 and the round returned `Issues Found` → planner revises once, then run **one** more review round.
|
|
158
|
+
- count ≥ 2 → do NOT invoke the reviewer again. **Do not stop and do not ask the human.** Have the planner apply every outstanding finding directly to `PLAN.md` and the affected `TASK-xxx.md` files, append `### Round <N> — findings applied without re-review` to the Plan Review Log listing what was changed, then proceed to P3.
|
|
159
|
+
|
|
160
|
+
The gate still does its job — two independent opus passes shape the plan before a line of code
|
|
161
|
+
is written. What it no longer does is hand a stalled plan back to a human who isn't there.
|
|
95
162
|
|
|
96
163
|
**Claude Code — MANDATORY, do this before anything else in P2.5:** call the Agent tool with `subagent_type: "code-reviewer"`, passing `REVIEW_TARGET_TYPE=plan` and the path to `docs/AI_HANDOFF/PLAN.md`. This MUST be a separate agent invocation from P2's `handoff-planner` call (fresh context) — same-session self-review defeats the purpose of an independent gate.
|
|
97
164
|
|
|
98
165
|
1. Reviewer reads `PLAN.md` only (no diff, no task files, no executor report), checks Completeness / Consistency / Clarity / Scope / YAGNI — see `.claude/agents/code-reviewer.md` → Spec/Plan Review — and appends its verdict to PLAN.md's `## Plan Review Log` (new round entry, prior rounds kept).
|
|
99
|
-
2. `Issues Found` → route back to P2: `handoff-planner` revises `PLAN.md` and the affected `TASK-xxx.md` files to address every finding, then re-submit for
|
|
166
|
+
2. `Issues Found` → route back to P2: `handoff-planner` revises `PLAN.md` and the affected `TASK-xxx.md` files to address every finding, then re-submit for one more P2.5 review round — subject to the loop cap above.
|
|
100
167
|
3. `Approved` → append `PLAN_REVIEW: Approved by <reviewer model>` to PLAN.md's `## Planner Report` footer, then proceed to P3.
|
|
101
168
|
|
|
102
169
|
> Other tools without subagent support: manually switch to the strong model in a **separate** chat/session from P2, paste PLAN.md, review using the Spec/Plan Review checklist in `.claude/agents/code-reviewer.md`.
|
|
@@ -129,7 +196,11 @@ Verify working tree is clean after the plan commit:
|
|
|
129
196
|
git status # must be clean — plan commit already done in P3
|
|
130
197
|
```
|
|
131
198
|
|
|
132
|
-
If working tree is dirty
|
|
199
|
+
If the working tree is dirty, do not stop. Commit the stragglers as a checkpoint so they stay
|
|
200
|
+
recoverable and the wave copy-back starts from a known state:
|
|
201
|
+
```bash
|
|
202
|
+
git add -A && git commit -m "handoff: checkpoint before implement"
|
|
203
|
+
```
|
|
133
204
|
|
|
134
205
|
### I2 — Infer wave groups
|
|
135
206
|
|
|
@@ -139,13 +210,17 @@ Read each `docs/AI_HANDOFF/tasks/TASK-xxx.md` for `Dependencies` field:
|
|
|
139
210
|
- Chain A→B→C = 3 waves of 1 task each (sequential)
|
|
140
211
|
- Independent A, B, C = 1 wave of 3 tasks (parallel)
|
|
141
212
|
|
|
142
|
-
**Conflict check — mandatory, before spawning any wave.** For every pair of tasks landing
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
213
|
+
**Conflict check — mandatory, before spawning any wave.** For every pair of tasks landing in
|
|
214
|
+
the same wave, compare their `Target Files` lists. If any file path appears in both, **resolve
|
|
215
|
+
it automatically — do not stop.** Keep the lower-numbered task in the current wave and push
|
|
216
|
+
the other one into the next wave by adding `Dependencies: TASK-<lower>` to its task file. Two
|
|
217
|
+
tasks that touch the same file are safe as long as they never run concurrently, and
|
|
218
|
+
serializing them is the one resolution that is always correct. Note the demotion in the wave
|
|
219
|
+
plan and in `RUN.md`.
|
|
220
|
+
|
|
221
|
+
This is the code-level safety net for the planner's own §2 Scope constraint (same-wave tasks
|
|
222
|
+
must not share a file) in case it slipped through review. Only mark a task `needs_breakdown`
|
|
223
|
+
if it is missing required fields — never merely for sharing a file.
|
|
149
224
|
|
|
150
225
|
**Batch each wave — mandatory.** Read `handoff.maxParallelAgents` from
|
|
151
226
|
`.ukit/storage/config.json` (default **10**). A wave with more tasks than that is split
|
|
@@ -195,6 +270,20 @@ Executor Report (append to task file — do NOT touch INDEX.md):
|
|
|
195
270
|
Verification Output: <paste full output>
|
|
196
271
|
Status: PASS | FAIL
|
|
197
272
|
Note: <issues or "none">
|
|
273
|
+
|
|
274
|
+
Then RETURN TO THE ORCHESTRATOR AT MOST 10 LINES, in exactly this shape:
|
|
275
|
+
TASK: TASK-xxx
|
|
276
|
+
STATUS: PASS | FAIL
|
|
277
|
+
EXECUTOR_MODEL: <exact model ID>
|
|
278
|
+
FILES: <comma-separated changed paths>
|
|
279
|
+
RED: confirmed | not-confirmed
|
|
280
|
+
VERIFY: <n> commands, all pass | <first failing command + one-line reason>
|
|
281
|
+
NOTE: <one line or "none">
|
|
282
|
+
|
|
283
|
+
Do NOT repeat RED_OUTPUT or verification logs in the returned message. They are already
|
|
284
|
+
written to the task file on disk, which is where the reviewer reads them from. Pasting
|
|
285
|
+
them back a second time is what blows up the orchestrator's context window and kills the
|
|
286
|
+
run mid-pipeline.
|
|
198
287
|
```
|
|
199
288
|
|
|
200
289
|
**3c — Copy changes back + delete worktrees** (orchestrator, after each task reports):
|
|
@@ -235,6 +324,36 @@ git branch -D handoff/task-xxx
|
|
|
235
324
|
|
|
236
325
|
Worktrees are **always deleted immediately** — no exceptions.
|
|
237
326
|
|
|
327
|
+
**3d — Wave boundary: commit + context checkpoint** (orchestrator, after every wave)
|
|
328
|
+
|
|
329
|
+
A wave boundary is the only safe place to shed context, because everything of value is
|
|
330
|
+
already on disk (task files hold the full logs, git holds the code). Do all four, in order:
|
|
331
|
+
|
|
332
|
+
1. **Checkpoint the code** — one commit per wave, so every wave is independently revertible:
|
|
333
|
+
```bash
|
|
334
|
+
git add -A && git commit -m "handoff: wave <N> — TASK-00x, TASK-00y"
|
|
335
|
+
```
|
|
336
|
+
Do not push here; the single push happens at R5.
|
|
337
|
+
|
|
338
|
+
2. **Update the run cursor** — rewrite `docs/AI_HANDOFF/RUN.md` with `Phase: I3`,
|
|
339
|
+
`Cursor: wave <N> done`, `Next: wave <N+1>` (or `I4` if that was the last wave).
|
|
340
|
+
|
|
341
|
+
3. **Collapse the wave in working memory.** From this point on, refer to the finished wave
|
|
342
|
+
only by its one-line-per-task summary (`TASK-xxx PASS <files>`). Do not re-read the task
|
|
343
|
+
files, do not restate executor reports, do not quote diffs from earlier waves. Anything
|
|
344
|
+
the reviewer needs, the reviewer reads from disk itself.
|
|
345
|
+
|
|
346
|
+
4. **Check the pressure before spawning the next wave.** If a UKit context warning has fired
|
|
347
|
+
this run, or the wave just finished involved more than ~5 agents, state one line —
|
|
348
|
+
`context checkpoint: wave <N> collapsed, <M> tasks summarized` — and continue anyway. Do
|
|
349
|
+
not ask the human to run `/compact`, and do not abandon the run. If the session is
|
|
350
|
+
compacted or restarted for any reason, `RUN.md` plus the `SessionStart` resume hook bring
|
|
351
|
+
the pipeline back exactly here.
|
|
352
|
+
|
|
353
|
+
With a ~200k window and per-task returns capped at 10 lines (3b), a wave of 10 tasks costs
|
|
354
|
+
the orchestrator roughly 100 lines instead of the thousands that pasted RED and verification
|
|
355
|
+
logs used to cost. That difference is what makes a multi-wave cycle finish in one run.
|
|
356
|
+
|
|
238
357
|
### I4 — Consolidate + update INDEX (lite model)
|
|
239
358
|
|
|
240
359
|
**Claude Code — MANDATORY:** call the Agent tool with `subagent_type: "ukit-small-task-maintainer"` for I4. After all waves complete, ask it to:
|
|
@@ -267,7 +386,13 @@ git status # should show modified/new files, no handoff branches/worktrees
|
|
|
267
386
|
git diff --stat # summary of all changes
|
|
268
387
|
```
|
|
269
388
|
|
|
270
|
-
|
|
389
|
+
Because 3d commits each wave, the changes under review are in **commits since the plan commit**, not only in the working tree. Resolve the review range once and use it everywhere below:
|
|
390
|
+
```bash
|
|
391
|
+
PLAN_COMMIT=$(git log --format=%H --grep='^handoff: plan' -n 1)
|
|
392
|
+
git diff $PLAN_COMMIT # all handoff changes: committed waves + anything uncommitted
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
If that diff is empty → implement was not completed. Do not stop: re-enter Phase 3 from the run cursor with the remaining `ready` tasks.
|
|
271
396
|
|
|
272
397
|
> Orchestrator (this session) handles the R1 guard check directly.
|
|
273
398
|
|
|
@@ -297,8 +422,8 @@ If any command fails → verdict `critical_block`. Stop. Do NOT proceed to R4.
|
|
|
297
422
|
### R4 — Review unified diff + append verdict (strong model)
|
|
298
423
|
|
|
299
424
|
```bash
|
|
300
|
-
git diff
|
|
301
|
-
git status
|
|
425
|
+
git diff $PLAN_COMMIT # every handoff change: committed waves + working tree
|
|
426
|
+
git status # overview of modified/new/deleted files
|
|
302
427
|
```
|
|
303
428
|
|
|
304
429
|
Review as one unified diff — correctness, regression risk, security, edge cases, maintainability. Cross-reference each task's intent in `docs/AI_HANDOFF/tasks/TASK-xxx.md`.
|
|
@@ -317,21 +442,70 @@ FINDINGS:
|
|
|
317
442
|
NEXT_STATUS_FOR_INDEX: <status>
|
|
318
443
|
```
|
|
319
444
|
|
|
320
|
-
|
|
445
|
+
Then return to the orchestrator **at most 6 lines** — the full verdict is already on disk:
|
|
446
|
+
```
|
|
447
|
+
TASK: TASK-xxx
|
|
448
|
+
VERDICT: approved | approved_minor | changes_requested | critical_block
|
|
449
|
+
REVIEWER_MODEL: <exact model ID>
|
|
450
|
+
VERIFICATION_RERUN: PASS | FAIL
|
|
451
|
+
BLOCKING: <one line per critical/important finding, or "none">
|
|
452
|
+
```
|
|
453
|
+
Do not paste the diff, the findings prose, or verification logs back into the orchestrator.
|
|
454
|
+
|
|
455
|
+
### R4.5 — Auto-fix loop (max 2 rounds)
|
|
456
|
+
|
|
457
|
+
Any task with `changes_requested` or `critical_block` enters this loop. **Do not report to
|
|
458
|
+
the human and stop** — that is the single biggest reason a cycle used to stretch across days.
|
|
459
|
+
|
|
460
|
+
For round in 1..2:
|
|
461
|
+
|
|
462
|
+
1. Collect every task still not `approved`/`approved_minor`. If none, exit the loop.
|
|
463
|
+
2. Group them into waves exactly as I2 does (dependencies + the same auto-serializing file
|
|
464
|
+
conflict rule). Spawn one `feature-implementer` per task **in parallel**, at most
|
|
465
|
+
`handoff.maxParallelAgents`, each in a fresh worktree per 3a. Each agent gets:
|
|
466
|
+
- the task file path (it reads its own `## Reviewer Verdict` from disk — do not paste
|
|
467
|
+
findings into the prompt),
|
|
468
|
+
- the instruction: fix every `critical` and `important` finding, leave `minor` alone
|
|
469
|
+
unless trivially safe, keep the existing tests green, add a regression test for each
|
|
470
|
+
critical finding, then re-run §Verification Commands and append a new
|
|
471
|
+
`## Executor Report (fix round <N>)` to the task file.
|
|
472
|
+
- the same ≤10-line return contract as 3b.
|
|
473
|
+
3. Copy back and delete worktrees per 3c. Commit the round:
|
|
474
|
+
```bash
|
|
475
|
+
git add -A && git commit -m "handoff: fix round <N> — TASK-00x"
|
|
476
|
+
```
|
|
477
|
+
4. Re-review **only the tasks touched this round**, in parallel, per R2–R4. A reviewer must
|
|
478
|
+
still differ from the executor model, and still re-runs verification itself.
|
|
479
|
+
5. Update `INDEX.md` and `RUN.md`. If everything is now approved, exit the loop.
|
|
321
480
|
|
|
322
|
-
|
|
481
|
+
After round 2, any task still not approved is genuinely stuck: leave it `blocked`, record why
|
|
482
|
+
in its `## Discussion` thread, and carry it into the Final Report. **Every other task still
|
|
483
|
+
proceeds to R5** — one stubborn task must never hold the whole cycle hostage.
|
|
323
484
|
|
|
324
|
-
|
|
485
|
+
### R5 — Commit + push (orchestrator)
|
|
486
|
+
|
|
487
|
+
R4.5 has already run, so by this point every task is either approved or genuinely stuck.
|
|
488
|
+
|
|
489
|
+
Update `docs/AI_HANDOFF/INDEX.md`: approved tasks → `done`; anything still failing after both
|
|
490
|
+
fix rounds → `blocked`.
|
|
491
|
+
|
|
492
|
+
Commit whatever remains uncommitted (the per-wave commits from 3d are already in), then push
|
|
493
|
+
once — this is the run's only push:
|
|
325
494
|
|
|
326
495
|
```bash
|
|
327
|
-
git add
|
|
496
|
+
git add -A && git commit -m "handoff: implement <goal>" # skip if nothing left to commit
|
|
497
|
+
git push origin $BASE
|
|
328
498
|
```
|
|
329
499
|
|
|
330
|
-
Replace `<goal>` with the one-sentence goal from ACTIVE.md.
|
|
500
|
+
Replace `<goal>` with the one-sentence goal from ACTIVE.md. Push without asking — `git push`
|
|
501
|
+
is in the settings `allow` list precisely so a one-shot run never stalls at the last step.
|
|
502
|
+
Force-push stays denied, so this can only ever fast-forward.
|
|
331
503
|
|
|
332
|
-
**
|
|
504
|
+
**If some tasks are `blocked`:** still push. The approved work is reviewed, tested, and
|
|
505
|
+
committed; withholding it helps no one, and the per-wave commits make any subset revertible.
|
|
506
|
+
Name the blocked tasks in the Final Report.
|
|
333
507
|
|
|
334
|
-
|
|
508
|
+
Finally set `Phase: done` in `docs/AI_HANDOFF/RUN.md`.
|
|
335
509
|
|
|
336
510
|
---
|
|
337
511
|
|
|
@@ -362,7 +536,19 @@ Re-run assertions after removal to confirm clean state.
|
|
|
362
536
|
handoff-fullstack complete:
|
|
363
537
|
Cycle: <ID>
|
|
364
538
|
Tasks: <N> approved, <M> blocked
|
|
365
|
-
|
|
539
|
+
Fix rounds used: <0|1|2>
|
|
540
|
+
Git: <K> wave commits + pushed to <branch>
|
|
366
541
|
Worktrees: all cleaned
|
|
367
542
|
Branches: all cleaned
|
|
543
|
+
Blocked (needs you): <TASK-xxx — one-line reason> | none
|
|
368
544
|
```
|
|
545
|
+
|
|
546
|
+
Then, as the last line of the run:
|
|
547
|
+
|
|
548
|
+
> Cycle finished. Run `/compact` before starting the next cycle — this session is carrying
|
|
549
|
+
> the whole pipeline's history and the next cycle deserves a clean window.
|
|
550
|
+
|
|
551
|
+
This is the **only** place in the pipeline that may ask for a compaction. Asking at a cycle
|
|
552
|
+
boundary costs nothing: all state is in git, `INDEX.md` and `RUN.md`, so a compacted or
|
|
553
|
+
brand-new session picks the next cycle up with no loss. Asking mid-cycle is forbidden — see
|
|
554
|
+
the Autonomy Contract.
|
|
@@ -8,7 +8,48 @@
|
|
|
8
8
|
$ARGUMENTS
|
|
9
9
|
_Empty = all `ready` tasks. Or: "TASK-001" for a specific task._
|
|
10
10
|
|
|
11
|
-
> **
|
|
11
|
+
> **Commits: yes, one per wave. Push: no.** Each wave is checkpointed to git so any step is
|
|
12
|
+
> revertible, but nothing leaves the machine — `/ukit:handoff-review` decides what gets pushed.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Autonomy Contract — read before anything else
|
|
17
|
+
|
|
18
|
+
Run every `ready` task to completion in this one invocation. The human is not watching and
|
|
19
|
+
will not answer mid-run.
|
|
20
|
+
|
|
21
|
+
**Ask nothing after the run starts.** Every decision below has a defined automatic
|
|
22
|
+
resolution — take it, and note it in the wave summary:
|
|
23
|
+
|
|
24
|
+
| Situation | Required behavior |
|
|
25
|
+
|-----------|------------------|
|
|
26
|
+
| Working tree dirty at Step 1 | commit a checkpoint, continue |
|
|
27
|
+
| Two same-wave tasks share a file | move the later task to the next wave, continue |
|
|
28
|
+
| A task's agent reports FAIL | leave it `blocked`, finish every other task, report at the end |
|
|
29
|
+
| Context warning fires | collapse the finished wave to one line per task, continue |
|
|
30
|
+
| No `ready` tasks but `changes_requested` ones exist | treat those as the work — this is a fix pass |
|
|
31
|
+
|
|
32
|
+
Escalate only for a blocker outside the repo. Never pause mid-wave to ask for `/compact`:
|
|
33
|
+
context is managed structurally (short agent returns + wave-boundary collapse), and the run
|
|
34
|
+
cursor makes an interrupted run resumable. A compaction request belongs at the end of the
|
|
35
|
+
command, never inside it.
|
|
36
|
+
|
|
37
|
+
### Run cursor — write after every step
|
|
38
|
+
|
|
39
|
+
Maintain `docs/AI_HANDOFF/RUN.md`, rewritten (whole file) after every numbered step:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Command: handoff-implement
|
|
43
|
+
Goal: <one sentence>
|
|
44
|
+
Base: <BASE>
|
|
45
|
+
Phase: <1|2|3|4|done>
|
|
46
|
+
Cursor: wave <N> batch <M> — <what just finished>
|
|
47
|
+
Next: <the exact next step to run>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If this file already exists with `Phase:` not `done` when the command starts, this is a
|
|
51
|
+
**continuation**: read the cursor, jump to `Next:`, skip tasks already `pending_review` or
|
|
52
|
+
`done`. Do not restart from Step 1 and do not ask whether to continue.
|
|
12
53
|
|
|
13
54
|
---
|
|
14
55
|
|
|
@@ -16,14 +57,19 @@ _Empty = all `ready` tasks. Or: "TASK-001" for a specific task._
|
|
|
16
57
|
|
|
17
58
|
Read `docs/AI_HANDOFF/ACTIVE.md` → get `Base: <BASE>`.
|
|
18
59
|
Read `docs/AI_HANDOFF/INDEX.md` → collect `ready` tasks (or specific task from $ARGUMENTS).
|
|
19
|
-
If no ready tasks
|
|
60
|
+
If there are no `ready` tasks, check for `changes_requested`/`blocked` ones and run those
|
|
61
|
+
instead. Only if nothing is actionable → report and stop.
|
|
20
62
|
|
|
21
|
-
Verify working tree
|
|
63
|
+
Verify working tree state:
|
|
22
64
|
```bash
|
|
23
|
-
git status
|
|
65
|
+
git status
|
|
24
66
|
```
|
|
25
67
|
|
|
26
|
-
If working tree is dirty
|
|
68
|
+
If the working tree is dirty, do not stop — commit a checkpoint so the wave copy-back starts
|
|
69
|
+
from a known state and the pre-existing edits stay recoverable:
|
|
70
|
+
```bash
|
|
71
|
+
git add -A && git commit -m "handoff: checkpoint before implement"
|
|
72
|
+
```
|
|
27
73
|
|
|
28
74
|
## Step 2 — Build wave groups
|
|
29
75
|
|
|
@@ -35,12 +81,16 @@ Read each `tasks/TASK-xxx.md` for `Dependencies` field:
|
|
|
35
81
|
|
|
36
82
|
### Conflict check — mandatory, before spawning any wave
|
|
37
83
|
|
|
38
|
-
For every pair of tasks landing in the same wave, compare their `Target Files` lists. If
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
84
|
+
For every pair of tasks landing in the same wave, compare their `Target Files` lists. If any
|
|
85
|
+
file path appears in both, **resolve it automatically — do not stop.** Keep the
|
|
86
|
+
lower-numbered task in the current wave and push the other into the next wave by adding
|
|
87
|
+
`Dependencies: TASK-<lower>` to its task file. Two tasks touching the same file are safe as
|
|
88
|
+
long as they never run concurrently, and serializing them is the one resolution that is
|
|
89
|
+
always correct.
|
|
90
|
+
|
|
91
|
+
This is the code-level safety net for the planner's own §2 Scope constraint (same-wave tasks
|
|
92
|
+
must not share a file) in case it slipped through review. Only mark a task `needs_breakdown`
|
|
93
|
+
when it is missing required fields — never merely for sharing a file.
|
|
44
94
|
|
|
45
95
|
### Batch each wave — mandatory
|
|
46
96
|
|
|
@@ -96,6 +146,19 @@ Executor Report (append to task file — do NOT touch INDEX.md):
|
|
|
96
146
|
Verification Output: <paste>
|
|
97
147
|
Status: PASS | FAIL
|
|
98
148
|
Note: <issues or "none">
|
|
149
|
+
|
|
150
|
+
Then RETURN TO THE ORCHESTRATOR AT MOST 10 LINES, in exactly this shape:
|
|
151
|
+
TASK: TASK-xxx
|
|
152
|
+
STATUS: PASS | FAIL
|
|
153
|
+
EXECUTOR_MODEL: <exact model ID>
|
|
154
|
+
FILES: <comma-separated changed paths>
|
|
155
|
+
RED: confirmed | not-confirmed
|
|
156
|
+
VERIFY: <n> commands, all pass | <first failing command + one-line reason>
|
|
157
|
+
NOTE: <one line or "none">
|
|
158
|
+
|
|
159
|
+
Do NOT repeat RED_OUTPUT or verification logs in the returned message. They are already on
|
|
160
|
+
disk in the task file, which is where the reviewer reads them from. Pasting them back a
|
|
161
|
+
second time is what blows up the orchestrator's context window and kills the run mid-wave.
|
|
99
162
|
```
|
|
100
163
|
|
|
101
164
|
> Other tools without subagent support: open each task in a separate session with the code model.
|
|
@@ -144,21 +207,44 @@ git branch -D handoff/task-xxx
|
|
|
144
207
|
**Orchestrator writes INDEX.md** — agents never touch INDEX directly.
|
|
145
208
|
**Worktrees are always deleted immediately** — no exceptions.
|
|
146
209
|
|
|
147
|
-
### 3d —
|
|
148
|
-
|
|
210
|
+
### 3d — Wave boundary: commit + context checkpoint
|
|
211
|
+
|
|
212
|
+
A wave boundary is the only safe place to shed context, because everything of value is
|
|
213
|
+
already on disk (task files hold the full logs, git holds the code). Do all four, in order:
|
|
214
|
+
|
|
215
|
+
1. **Checkpoint the code** — one commit per wave, so every wave is independently revertible:
|
|
216
|
+
```bash
|
|
217
|
+
git add -A && git commit -m "handoff: wave <N> — TASK-00x, TASK-00y"
|
|
218
|
+
```
|
|
219
|
+
Do not push. `/ukit:handoff-review` owns that decision.
|
|
220
|
+
|
|
221
|
+
2. **Update the run cursor** — rewrite `docs/AI_HANDOFF/RUN.md` with `Cursor: wave <N> done`,
|
|
222
|
+
`Next: wave <N+1>` (or `Step 4` if that was the last wave).
|
|
223
|
+
|
|
224
|
+
3. **Collapse the wave in working memory.** From here on, refer to the finished wave only by
|
|
225
|
+
its one-line-per-task summary. Do not re-read task files, restate executor reports, or
|
|
226
|
+
quote earlier diffs. The reviewer reads what it needs from disk itself.
|
|
227
|
+
|
|
228
|
+
4. **Continue.** If a UKit context warning has fired, say one line —
|
|
229
|
+
`context checkpoint: wave <N> collapsed` — and start the next wave anyway. Do not ask for
|
|
230
|
+
`/compact` here. If the session ends regardless, `RUN.md` plus the `SessionStart` resume
|
|
231
|
+
hook bring the run back to exactly this point.
|
|
232
|
+
|
|
233
|
+
Then create the next wave's worktrees from `$BASE` and repeat 3a–3c.
|
|
149
234
|
|
|
150
235
|
## Step 4 — Finalize: verify cleanup
|
|
151
236
|
|
|
152
237
|
All waves complete. Verify:
|
|
153
238
|
|
|
154
239
|
```bash
|
|
155
|
-
git worktree list
|
|
240
|
+
git worktree list # must show only main worktree
|
|
156
241
|
git branch | grep handoff # must be empty
|
|
157
|
-
git
|
|
158
|
-
git
|
|
242
|
+
git log --oneline -n 10 # one commit per wave
|
|
243
|
+
git status # clean, or only trailing edits from the last wave
|
|
159
244
|
```
|
|
160
245
|
|
|
161
|
-
All changes are
|
|
246
|
+
All changes are committed as **one commit per wave on `$BASE`**, nothing pushed. No branches
|
|
247
|
+
or worktrees remain. Set `Phase: done` in `docs/AI_HANDOFF/RUN.md`.
|
|
162
248
|
|
|
163
249
|
## Step 5 — Report
|
|
164
250
|
|
|
@@ -166,8 +252,13 @@ All changes are in the **main working tree as uncommitted files**. No branches o
|
|
|
166
252
|
Wave summary:
|
|
167
253
|
Wave 1: TASK-001 [pending_review], TASK-002 [blocked]
|
|
168
254
|
Wave 2: TASK-003 [pending_review]
|
|
255
|
+
Commits: <K> wave commits on <BASE>, not pushed
|
|
169
256
|
All worktrees and branches removed.
|
|
170
|
-
|
|
257
|
+
Blocked (needs you): <TASK-xxx — one-line reason> | none
|
|
171
258
|
```
|
|
172
259
|
|
|
173
260
|
**Next:** switch to strong model → `/ukit:handoff-review`
|
|
261
|
+
|
|
262
|
+
If this session is now heavy, this is the right moment to `/compact` — the wave commits,
|
|
263
|
+
`INDEX.md` and `RUN.md` hold all the state the review phase needs. Suggest it here, at the
|
|
264
|
+
command boundary, never inside a wave.
|