kaizen-agent 1.7.9 → 1.8.0

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.
Files changed (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +694 -658
  3. package/agents/kaizen-builder.md +82 -77
  4. package/agents/kaizen-planner.md +250 -250
  5. package/agents/kaizen-reviewer.md +127 -127
  6. package/cli/board.test.ts +55 -0
  7. package/cli/dashboard.ts +1188 -1187
  8. package/cli/install.ts +76 -3
  9. package/cli/publish-gh.sh +27 -27
  10. package/cli/release.sh +45 -45
  11. package/cli/settings.ts +7 -3
  12. package/cli/sources.test.ts +494 -0
  13. package/cli/sources.ts +323 -0
  14. package/cli/state.test.ts +422 -197
  15. package/cli/state.ts +989 -700
  16. package/cli/web.ts +182 -11
  17. package/commands/kaizen-abort.md +5 -5
  18. package/commands/kaizen-approve.md +5 -5
  19. package/commands/kaizen-auto.md +6 -6
  20. package/commands/kaizen-backlog.md +5 -5
  21. package/commands/kaizen-config.md +5 -5
  22. package/commands/kaizen-full.md +5 -5
  23. package/commands/kaizen-gather.md +5 -0
  24. package/commands/kaizen-init.md +5 -5
  25. package/commands/kaizen-install.md +5 -5
  26. package/commands/kaizen-lite.md +5 -5
  27. package/commands/kaizen-plan.md +6 -6
  28. package/commands/kaizen-reject.md +6 -6
  29. package/commands/kaizen-review.md +6 -6
  30. package/commands/kaizen-run.md +5 -5
  31. package/commands/kaizen-status.md +5 -5
  32. package/package.json +3 -1
  33. package/skills/kaizen/README.md +283 -281
  34. package/skills/kaizen/SKILL.md +334 -440
  35. package/skills/kaizen/adapters.md +84 -77
  36. package/skills/kaizen/config.default.yml +181 -167
  37. package/skills/kaizen/gather.md +50 -0
  38. package/skills/kaizen/install.md +42 -0
  39. package/skills/kaizen/settings.md +52 -0
  40. package/skills/kaizen/spec-build.md +131 -119
  41. package/skills/kaizen/spec-main.md +109 -104
  42. package/skills/kaizen/spec-plan.md +201 -201
  43. package/skills/kaizen/spec-review.md +121 -121
  44. package/skills/kaizen/spec.md +154 -153
  45. package/skills/kaizen/status.md +43 -0
  46. package/skills/kaizen-help/SKILL.md +131 -129
  47. package/web/board.html +292 -125
@@ -0,0 +1,52 @@
1
+ # Kaizen — settings
2
+
3
+ Read for `/kaizen config`. Nothing else needs this file.
4
+
5
+ `/kaizen config` reads the same chain — `.kaizen/config.yml`, then `~/.kaizen/config.yml`,
6
+ then `config.default.yml` — and prints the current value of each setting below with a
7
+ one-line meaning. Then it offers the settings as choices — the tool's structured
8
+ question mechanism, one option per legal value, never free text — and writes back
9
+ whichever the user picks. Write to whichever file in the chain already exists,
10
+ nearest first, so a change lands globally unless this project keeps its own config.
11
+
12
+ | Setting | Values | What it decides |
13
+ |---|---|---|
14
+ | `preset` | `low`, `medium`, `ultra` | Quick preset: low (inline/manual), medium (balanced), ultra (autonomous) |
15
+ | `mode` | `approve`, `auto`, `plan-only`, `review-only` | Where a run stops |
16
+ | `runner` | `full`, `lite` | Whether each stage is its own cold agent, or this session runs them all |
17
+ | `build.executor` | `subagent`, `inline`, `ask` | Who carries out the approved plan |
18
+ | `approvals.plan` | `true`, `false` | Stop and show the plan before anything is built |
19
+ | `approvals.review` | `true`, `false` | Stop after the review, before the run is called done |
20
+ | `approvals.each_file` | `true`, `false` | Confirm every individual edit |
21
+ | `auto_fix.enabled` | `true`, `false` | Fix findings without asking, or hand every one over |
22
+ | `auto_fix.min_severity` | `critical`, `high`, `medium`, `low` | How bad a finding must be to be fixed automatically |
23
+ | `auto_fix.max_iterations` | `1`–`5` | Fix and recheck rounds before what is left is escalated |
24
+ | `review.write_memory` | `true`, `false` | Let the reviewer append lessons to `memory.md` |
25
+ | `git.auto_commit` | `true`, `false` | Commit the work when a run finishes |
26
+ | `git.branch_before_implement` | `true`, `false` | Branch before building when on the default branch |
27
+ | `ui.mouse` | `false`, `true` | Click to select, click again to act; while on, the terminal cannot select text |
28
+ | `subagents.model` | `inherit`, `opus`, `sonnet`, `haiku` | Model the stage subagents run on (Claude Code only) |
29
+ | `subagents.effort` | `inherit`, `low`, `medium`, `high` | Reasoning effort for the stage subagents (Claude Code only) |
30
+ | `sources.every` | `off`, `1h`, `6h`, `24h` | How often the web board checks request sources for new ideas while it runs |
31
+ | `agent.default` | `auto`, `claude`, `codex`, `agy`, `opencode`, `gemini` | Coding agent to launch from dashboard backlog |
32
+
33
+ Rules for writing the file:
34
+
35
+ - **Change the value in place.** `config.yml` ships with a comment above every key
36
+ explaining it; rewriting the file from a parsed object throws all of them away.
37
+ Edit the one line.
38
+ - **Only what the user picked.** A key the user did not touch stays absent if it was
39
+ absent — an absent key inherits the default, and writing every key out freezes
40
+ today's defaults into the project forever.
41
+ - If `.kaizen/` does not exist yet, run `init` first, then continue.
42
+ - After writing, print the setting and its new value, and nothing else. No summary of
43
+ the whole file.
44
+
45
+ Settings not in the table — the review checks, backlog and state paths, and the per-tool
46
+ `agent.<cmd>.model` / `agent.<cmd>.effort` the board launches a session with — are edited by
47
+ hand in `config.yml`, which is commented throughout. Say so rather than offering a
48
+ picker with thirty options.
49
+
50
+ `kaizen settings` in a terminal opens the same settings as a full-screen browser, for
51
+ someone who would rather see the whole file at once. Mention it when the user is
52
+ changing several at a time.
@@ -1,119 +1,131 @@
1
- # Kaizen — implement stage
2
-
3
- Read with [`spec.md`](spec.md) (core: track, intake, resume). This file is the
4
- builder's contract. The planner and reviewer do not read it.
5
-
6
- ---
7
- ## Stage 2 — Implement
8
-
9
- **Agent:** builder. **Input:** `01-plan.md`, `02-approval.md`, the track.
10
- **Output:** the deliverable itself, plus `03-impl.md`.
11
-
12
- The builder produces whatever the track's deliverable is — code, a chapter, the
13
- campaign copy, the runbook — and nothing else.
14
-
15
- This file is the contract whether the builder is a dispatched agent or the main
16
- thread working inline (see `build.executor`). Working inline changes who is typing,
17
- not what is owed: the plan is still the scope, a step that turns out wrong still
18
- stops the stage instead of being improvised around, and `03-impl.md` is still written
19
- before the reviewer is called. The temptation inline is to skip the file because the
20
- work is already visible in the conversation — but the reviewer never sees that
21
- conversation, and reads the file instead.
22
-
23
- Rules:
24
-
25
- - Work only within the plan's scope. Something out of scope that clearly needs doing
26
- is written to `03-impl.md` as a note, not produced.
27
- - If a step turns out to be impossible or wrong, stop and report. Do not improvise a
28
- different approach — that silently discards the approval the plan received.
29
- - Match what is already there: a codebase's conventions and idioms, a manuscript's
30
- voice and structure, a brand's tone. New work should be indistinguishable in style
31
- from the surrounding material.
32
- - Carry out the plan's verification and record the real result, whatever the track's
33
- verification is.
34
- - Every technique the plan's `reason`-tier gate covers — a new dependency, a new
35
- abstraction, a new file, a new section — is allowed, and costs one written line
36
- saying what it serves. The line is the price of the technique, not a request for
37
- permission. No line means the reviewer records a finding.
38
- - The `git.*` settings apply only where the work sits in a git repository. In a plain
39
- folder there is no branch to make and no commit to skip, and that absence is not a
40
- finding.
41
-
42
- **Baseline first, in any track with an existing suite of checks.** Before changing
43
- anything, run whatever already proves the existing material correct — the test suite,
44
- the linter, the link checker, the fact-check pass — and record the result in
45
- `03-impl.md`. Run it again after. Two results, before and after, are what turn "my
46
- change works" into "nothing else broke". A check already failing before the change is
47
- not this run's finding; a check that passed before and fails after is, and it stops
48
- the stage.
49
-
50
- **Keep the working transcript small.** Everything the builder reads stays in its
51
- context and is re-read on every request that follows, so a full test-suite dump at the
52
- start of the stage is paid for again at every step after it. Pipe long output through
53
- a filter that keeps the decisive lines — the failure count, the failing test names, the
54
- first error — and read the full output only when a check actually fails. The same holds
55
- for reading material: open the manifest's paths at the ranges the plan names, not whole
56
- files, and never re-read a file this stage already changed. `03-impl.md` records the
57
- result, not the transcript.
58
-
59
- **Read the plan's File manifest instead of searching.** The planner already located
60
- every path this run touches. Search the material only for what the manifest does not
61
- cover, and note in `03-impl.md` what was missing from it.
62
-
63
- `03-impl.md` must list: what was produced or changed with a one-line reason each,
64
- deviations from the plan and why, verification carried out with its actual result,
65
- and anything deliberately left undone. Report failures honestly; a false claim of
66
- success poisons the review stage, which trusts this report.
67
-
68
- **A `## Preview` section says how to see the result.** For an app or service: the
69
- commands to start it locally and the URL to open, copied from the material's own README
70
- where one exists. For anything else — a document, copy, a runbook, a memo — the path
71
- to open, or the result itself when it fits in a screen. The board shows this section on
72
- the run's card, so a person can try the work without reading the rest of the report.
73
-
74
- **The gate block closes the stage.** `03-impl.md` ends with one line per gate item
75
- from the plan's Verification section:
76
-
77
- ```
78
- G-01 PASS: ran `php artisan test --filter=Payroll` — 214 passed, 0 failed
79
- G-02 PASS: cash→transfer switch exercised in the UI; bank rows validated, 422 gone
80
- G-03 FAIL: payslip PDF still prints the old label
81
- ```
82
-
83
- A `PASS` states what was actually done and what came back — the command and its
84
- output, the page opened and what appeared, the person who read it and what they
85
- understood. `PASS` on its own is not a result, and neither is a restatement of the
86
- gate item; both are read as an admission the check did not happen.
87
-
88
- **Work that was never executed cannot pass.** In any track where the deliverable can
89
- be run, opened, or read by someone, doing so is part of building it: the suite run,
90
- the page opened and clicked, the runbook walked start to finish, the copy read aloud.
91
- A gate item whose evidence is an argument that the code should work is a `FAIL`.
92
-
93
- The stage does not hand off with a `FAIL` standing. Fix it and re-run the gate, or —
94
- if it cannot be fixed inside the plan's scope — stop and report, exactly as with an
95
- impossible step. A `FAIL` carried into review wastes the reviewer's pass on something
96
- already known to be broken.
97
-
98
- ## Stage 4 — Fix loop
99
-
100
- Governed by `auto_fix`. See the skill's fix-loop section for the exact behavior.
101
-
102
- Each iteration writes `05-iterations/NN-fix.md` (what the builder changed) and
103
- `NN-recheck.md` (what the reviewer found afterward). The loop ends when the reviewer
104
- reports nothing at or above the threshold, or `max_iterations` is reached.
105
-
106
- A finding the loop could not close is escalated to the user with the reviewer's
107
- description intact — never quietly downgraded to make the run look clean.
108
-
109
- **An iteration reads the finding, the work, and the gate.** Not the plan. Fixing a
110
- named defect needs the reviewer's line, the diff so far, and the gate the result must
111
- still pass; it does not need the framing, the alternatives rejected, or the out-of-scope
112
- list, all of which were settled before the finding existed. Read `01-plan.md` only when
113
- a finding turns on what was approved — a scope question, or a fix that would take the
114
- work outside it.
115
-
116
- Fix what the finding names and stop. A second defect noticed while fixing the first is
117
- a note in the iteration file, not a second fix: it has not been reviewed, and the
118
- recheck is scoped to what the iteration claims to have changed.
119
-
1
+ # Kaizen — implement stage
2
+
3
+ Read with [`spec.md`](spec.md) (core: track, intake, resume). This file is the
4
+ builder's contract. The planner and reviewer do not read it.
5
+
6
+ ---
7
+ ## Stage 2 — Implement
8
+
9
+ **Agent:** builder. **Input:** `01-plan.md`, `02-approval.md`, the track.
10
+ **Output:** the deliverable itself, plus `03-impl.md`.
11
+
12
+ The builder produces whatever the track's deliverable is — code, a chapter, the
13
+ campaign copy, the runbook — and nothing else.
14
+
15
+ This file is the contract whether the builder is a dispatched agent or the main
16
+ thread working inline (see `build.executor`). Working inline changes who is typing,
17
+ not what is owed: the plan is still the scope, a step that turns out wrong still
18
+ stops the stage instead of being improvised around, and `03-impl.md` is still written
19
+ before the reviewer is called. The temptation inline is to skip the file because the
20
+ work is already visible in the conversation — but the reviewer never sees that
21
+ conversation, and reads the file instead.
22
+
23
+ Rules:
24
+
25
+ - Work only within the plan's scope. Something out of scope that clearly needs doing
26
+ is written to `03-impl.md` as a note, not produced.
27
+ - If a step turns out to be impossible or wrong, stop and report. Do not improvise a
28
+ different approach — that silently discards the approval the plan received.
29
+ - Match what is already there: a codebase's conventions and idioms, a manuscript's
30
+ voice and structure, a brand's tone. New work should be indistinguishable in style
31
+ from the surrounding material.
32
+ - Carry out the plan's verification and record the real result, whatever the track's
33
+ verification is.
34
+ - Every technique the plan's `reason`-tier gate covers — a new dependency, a new
35
+ abstraction, a new file, a new section — is allowed, and costs one written line
36
+ saying what it serves. The line is the price of the technique, not a request for
37
+ permission. No line means the reviewer records a finding.
38
+ - The `git.*` settings apply only where the work sits in a git repository. In a plain
39
+ folder there is no branch to make and no commit to skip, and that absence is not a
40
+ finding.
41
+
42
+ **Baseline first, in any track with an existing suite of checks.** Before changing
43
+ anything, run whatever already proves the existing material correct — the test suite,
44
+ the linter, the link checker, the fact-check pass — and record the result in
45
+ `03-impl.md`. Run it again after. Two results, before and after, are what turn "my
46
+ change works" into "nothing else broke". A check already failing before the change is
47
+ not this run's finding; a check that passed before and fails after is, and it stops
48
+ the stage.
49
+
50
+ **Keep the working transcript small.** Everything the builder reads stays in its
51
+ context and is re-read on every request that follows, so a full test-suite dump at the
52
+ start of the stage is paid for again at every step after it. Pipe long output through
53
+ a filter that keeps the decisive lines — the failure count, the failing test names, the
54
+ first error — and read the full output only when a check actually fails. The same holds
55
+ for reading material: open the manifest's paths at the ranges the plan names, not whole
56
+ files, and never re-read a file this stage already changed. `03-impl.md` records the
57
+ result, not the transcript.
58
+
59
+ **Read the plan's File manifest instead of searching.** The planner already located
60
+ every path this run touches. Search the material only for what the manifest does not
61
+ cover, and note in `03-impl.md` what was missing from it.
62
+
63
+ `03-impl.md` must list: what was produced or changed with a one-line reason each,
64
+ deviations from the plan and why, verification carried out with its actual result,
65
+ and anything deliberately left undone. Write each changed path in backticks, relative
66
+ to the repository, and no other path that way: the board commits a run by the changed
67
+ files its report names, so a changed path written any other way is left out of the
68
+ commit, and a backticked path the run did not change is taken into it. Report failures honestly; a false claim of
69
+ success poisons the review stage, which trusts this report.
70
+
71
+ **A `## Preview` section says how to see the result.** For an app or service: the
72
+ commands to start it locally and the URL to open, copied from the material's own README
73
+ where one exists. For anything else — a document, copy, a runbook, a memo — the path
74
+ to open, or the result itself when it fits in a screen. The board shows this section on
75
+ the run's card, so a person can try the work without reading the rest of the report.
76
+
77
+ **A `## Commit` section is the commit message for the work**, where the work sits in a
78
+ git repository. The first line is a Conventional Commits subject,
79
+ `<type>(<scope>): <what changed>`, with the type one of `feat`, `fix`, `refactor`,
80
+ `perf`, `docs`, `test`, `build`, `ci`, `chore`, `style`, `revert`, the scope optional,
81
+ and at most 72 characters. It says what this run produced, not what was asked: the
82
+ request is often a symptom or a wish, and the log should read as what changed. A body
83
+ may follow after a blank line. The board offers this message at commit and push and
84
+ refuses one without a type. A fix iteration that changes what the work is rewrites it.
85
+
86
+ **The gate block closes the stage.** `03-impl.md` ends with one line per gate item
87
+ from the plan's Verification section:
88
+
89
+ ```
90
+ G-01 PASS: ran `php artisan test --filter=Payroll` — 214 passed, 0 failed
91
+ G-02 PASS: cash→transfer switch exercised in the UI; bank rows validated, 422 gone
92
+ G-03 FAIL: payslip PDF still prints the old label
93
+ ```
94
+
95
+ A `PASS` states what was actually done and what came back — the command and its
96
+ output, the page opened and what appeared, the person who read it and what they
97
+ understood. `PASS` on its own is not a result, and neither is a restatement of the
98
+ gate item; both are read as an admission the check did not happen.
99
+
100
+ **Work that was never executed cannot pass.** In any track where the deliverable can
101
+ be run, opened, or read by someone, doing so is part of building it: the suite run,
102
+ the page opened and clicked, the runbook walked start to finish, the copy read aloud.
103
+ A gate item whose evidence is an argument that the code should work is a `FAIL`.
104
+
105
+ The stage does not hand off with a `FAIL` standing. Fix it and re-run the gate, or —
106
+ if it cannot be fixed inside the plan's scope — stop and report, exactly as with an
107
+ impossible step. A `FAIL` carried into review wastes the reviewer's pass on something
108
+ already known to be broken.
109
+
110
+ ## Stage 4 — Fix loop
111
+
112
+ Governed by `auto_fix`. See the skill's fix-loop section for the exact behavior.
113
+
114
+ Each iteration writes `05-iterations/NN-fix.md` (what the builder changed) and
115
+ `NN-recheck.md` (what the reviewer found afterward). The loop ends when the reviewer
116
+ reports nothing at or above the threshold, or `max_iterations` is reached.
117
+
118
+ A finding the loop could not close is escalated to the user with the reviewer's
119
+ description intact — never quietly downgraded to make the run look clean.
120
+
121
+ **An iteration reads the finding, the work, and the gate.** Not the plan. Fixing a
122
+ named defect needs the reviewer's line, the diff so far, and the gate the result must
123
+ still pass; it does not need the framing, the alternatives rejected, or the out-of-scope
124
+ list, all of which were settled before the finding existed. Read `01-plan.md` only when
125
+ a finding turns on what was approved — a scope question, or a fix that would take the
126
+ work outside it.
127
+
128
+ Fix what the finding names and stop. A second defect noticed while fixing the first is
129
+ a note in the iteration file, not a second fix: it has not been reviewed, and the
130
+ recheck is scoped to what the iteration claims to have changed.
131
+
@@ -1,104 +1,109 @@
1
- # Kaizen — main thread
2
-
3
- Read with [`spec.md`](spec.md) (core: track, intake, resume). Backlog bookkeeping and
4
- the final approval. No subagent reads this file.
5
-
6
- ---
7
- ## Backlog
8
-
9
- Every run produces work it deliberately does not do. Three sources, all already
10
- written down by the time a run ends:
11
-
12
- 1. Out of scope suggestions the planner listed and the user did not fold into the
13
- approved scope.
14
- 2. Findings below `auto_fix.min_severity`, and findings the fix loop could not close.
15
- 3. Debts deferred at an approval because they fell outside the approved scope.
16
-
17
- Without capture these survive only in the conversation that produced them.
18
-
19
- `backlog.enabled: false` skips both capture points — the `02-approval.md` append at
20
- plan approval and the `06-backlog.md` append at final approval — for that run. The run
21
- still executes normally; it simply ends without a backlog file.
22
-
23
- **Where it lives.** Each run holds its own backlog at `runs/<id>/06-backlog.md`, beside
24
- the plan and the review that produced the items. There is no central backlog file to
25
- keep in sync, and no copying: provenance is the directory the item sits in.
26
-
27
- `<state.dir>/backlog.md`, beside `memory.md`, exists for exactly one purpose — an
28
- orphanage. Before `state.keep_runs` prunes a run directory, that run's **open** items
29
- are moved into it, so pruning never destroys outstanding work. Items already `done` or
30
- `rejected` are pruned with their run. Nothing else is ever written there, and
31
- `06-backlog.md` is never replaced by it.
32
-
33
- `/kaizen backlog` reads `<state.dir>/backlog.md` as well as every
34
- `runs/*/06-backlog.md`, and prints its open items last, under an **Orphaned** group —
35
- otherwise a rescued item would be invisible to the only command that lists outstanding
36
- work. Orphaned items count towards the open backlog count `/kaizen status` reports.
37
-
38
- An abandoned run — `stage: "abandoned"`, set by `/kaizen abort` — is not open work. Its
39
- `06-backlog.md` is left as it stands, and its items are neither printed by `/kaizen
40
- backlog` nor counted.
41
-
42
- **Item format.** One item per line:
43
-
44
- ```
45
- - <status>: <item text> | <reason>
46
- ```
47
-
48
- `<status>` is `open`, `done`, or `rejected`. A finding moved into the backlog keeps the
49
- reviewer's line verbatim — `<where>: <severity>: <problem>. <fix>.` — so nothing is
50
- rewritten in transit. `rejected` requires a reason after `|` on the same line; "not
51
- doing this" with no reason is how the same suggestion returns three runs later. `done`
52
- may carry a reason the same way, and usually names the run that closed it.
53
-
54
- Items are appended, never deleted. Closing an item means editing its status in place;
55
- it stays in its run's file as record. `/kaizen backlog` prints `open` items only, so
56
- the active list is bounded by what is genuinely outstanding rather than by history.
57
-
58
- Because a `<where>` reference must still resolve after its run closes, it is written as
59
- a path relative to the repository, not to the run directory.
60
-
61
- **Who writes it.** The main thread, at two file writes that already happen
62
- unconditionally:
63
-
64
- | Capture point | Stage | What gets appended |
65
- |---|---|---|
66
- | Writing `02-approval.md`, when the decision is an approval | Plan approval | Every out-of-scope suggestion not folded into the approved scope, and anything cut from scope at the approval |
67
- | Setting `stage: "done"` | Final approval | Findings still open, findings below the fix threshold, and out-of-scope notes the builder wrote into `03-impl.md` |
68
-
69
- Neither is optional and neither is a separate step to remember — a run cannot finish
70
- without touching both files.
71
-
72
- No subagent writes the backlog. The reviewer runs *before* the fix loop and cannot know
73
- which of its findings will be closed; it would log items that get fixed minutes later.
74
- The planner is not present at the approval where its suggestions are accepted or
75
- declined. This also keeps the workflow working under adapters where there are no
76
- subagents at all.
77
-
78
- ---
79
-
80
- ## Final approval
81
-
82
- Controlled by `approvals.review`, skipped in `auto`.
83
-
84
- Report: what was built, verification results, findings fixed, findings still open,
85
- and anything the builder noted as out of scope. Where the run used `runner: lite`, say
86
- so in that report — the reviewer saw the work, and nobody should read a same-session
87
- review as an independent one because the output looked the same. Then stop. Committing, pushing, or
88
- opening a pull request happens only if the user asks.
89
-
90
- **Open findings are offered by number.** List them with the reviewer's numbering
91
- intact and let the user name which to fix — "fix 2 and 5". A number not named is not
92
- touched, and goes to the backlog as `open` like any other deferred item. This is the
93
- same granularity the fix loop already works at; the only change is that the user
94
- picks the subset instead of accepting or declining the whole review.
95
-
96
- Before setting `stage: "done"`, append the same three categories just reported —
97
- findings still open, findings below the fix threshold, and the builder's out-of-scope
98
- notes from `03-impl.md` — to `runs/<id>/06-backlog.md`, each as `open`, in the format
99
- given in *Backlog* above. Every input is already assembled at this moment; the only
100
- change is that it is written down rather than spoken and discarded.
101
-
102
- Set `stage: "done"` in `state.json` once the user accepts.
103
-
104
- ---
1
+ # Kaizen — main thread
2
+
3
+ Read with [`spec.md`](spec.md) (core: track, intake, resume). Backlog bookkeeping and
4
+ the final approval. No subagent reads this file.
5
+
6
+ ---
7
+ ## Backlog
8
+
9
+ Every run produces work it deliberately does not do. Three sources, all already
10
+ written down by the time a run ends:
11
+
12
+ 1. Out of scope suggestions the planner listed and the user did not fold into the
13
+ approved scope.
14
+ 2. Findings below `auto_fix.min_severity`, and findings the fix loop could not close.
15
+ 3. Debts deferred at an approval because they fell outside the approved scope.
16
+
17
+ Without capture these survive only in the conversation that produced them.
18
+
19
+ `backlog.enabled: false` skips both capture points — the `02-approval.md` append at
20
+ plan approval and the `06-backlog.md` append at final approval — for that run. The run
21
+ still executes normally; it simply ends without a backlog file.
22
+
23
+ **Where it lives.** Each run holds its own backlog at `runs/<id>/06-backlog.md`, beside
24
+ the plan and the review that produced the items. There is no central backlog file to
25
+ keep in sync, and no copying: provenance is the directory the item sits in.
26
+
27
+ `<state.dir>/backlog.md`, beside `memory.md`, exists for exactly one purpose — an
28
+ orphanage. Before `state.keep_runs` prunes a run directory, that run's **open** items
29
+ are moved into it, so pruning never destroys outstanding work. Items already `done` or
30
+ `rejected` are pruned with their run. Nothing else is ever written there, and
31
+ `06-backlog.md` is never replaced by it.
32
+
33
+ **Pruning is the CLI's job, never a stage's.** `kaizen prune` in a terminal lists the
34
+ finished runs beyond `state.keep_runs`, and `kaizen prune --yes` rescues their open
35
+ items and deletes them. No agent deletes a run directory by hand: when the count is
36
+ over the limit, say so at the final report and name the command.
37
+
38
+ `/kaizen backlog` reads `<state.dir>/backlog.md` as well as every
39
+ `runs/*/06-backlog.md`, and prints its open items last, under an **Orphaned** group —
40
+ otherwise a rescued item would be invisible to the only command that lists outstanding
41
+ work. Orphaned items count towards the open backlog count `/kaizen status` reports.
42
+
43
+ An abandoned run — `stage: "abandoned"`, set by `/kaizen abort` — is not open work. Its
44
+ `06-backlog.md` is left as it stands, and its items are neither printed by `/kaizen
45
+ backlog` nor counted.
46
+
47
+ **Item format.** One item per line:
48
+
49
+ ```
50
+ - <status>: <item text> | <reason>
51
+ ```
52
+
53
+ `<status>` is `open`, `done`, or `rejected`. A finding moved into the backlog keeps the
54
+ reviewer's line verbatim — `<where>: <severity>: <problem>. <fix>.` — so nothing is
55
+ rewritten in transit. `rejected` requires a reason after `|` on the same line; "not
56
+ doing this" with no reason is how the same suggestion returns three runs later. `done`
57
+ may carry a reason the same way, and usually names the run that closed it.
58
+
59
+ Items are appended, never deleted. Closing an item means editing its status in place;
60
+ it stays in its run's file as record. `/kaizen backlog` prints `open` items only, so
61
+ the active list is bounded by what is genuinely outstanding rather than by history.
62
+
63
+ Because a `<where>` reference must still resolve after its run closes, it is written as
64
+ a path relative to the repository, not to the run directory.
65
+
66
+ **Who writes it.** The main thread, at two file writes that already happen
67
+ unconditionally:
68
+
69
+ | Capture point | Stage | What gets appended |
70
+ |---|---|---|
71
+ | Writing `02-approval.md`, when the decision is an approval | Plan approval | Every out-of-scope suggestion not folded into the approved scope, and anything cut from scope at the approval |
72
+ | Setting `stage: "done"` | Final approval | Findings still open, findings below the fix threshold, and out-of-scope notes the builder wrote into `03-impl.md` |
73
+
74
+ Neither is optional and neither is a separate step to remember — a run cannot finish
75
+ without touching both files.
76
+
77
+ No subagent writes the backlog. The reviewer runs *before* the fix loop and cannot know
78
+ which of its findings will be closed; it would log items that get fixed minutes later.
79
+ The planner is not present at the approval where its suggestions are accepted or
80
+ declined. This also keeps the workflow working under adapters where there are no
81
+ subagents at all.
82
+
83
+ ---
84
+
85
+ ## Final approval
86
+
87
+ Controlled by `approvals.review`, skipped in `auto`.
88
+
89
+ Report: what was built, verification results, findings fixed, findings still open,
90
+ and anything the builder noted as out of scope. Where the run used `runner: lite`, say
91
+ so in that report — the reviewer saw the work, and nobody should read a same-session
92
+ review as an independent one because the output looked the same. Then stop. Committing, pushing, or
93
+ opening a pull request happens only if the user asks.
94
+
95
+ **Open findings are offered by number.** List them with the reviewer's numbering
96
+ intact and let the user name which to fix — "fix 2 and 5". A number not named is not
97
+ touched, and goes to the backlog as `open` like any other deferred item. This is the
98
+ same granularity the fix loop already works at; the only change is that the user
99
+ picks the subset instead of accepting or declining the whole review.
100
+
101
+ Before setting `stage: "done"`, append the same three categories just reported —
102
+ findings still open, findings below the fix threshold, and the builder's out-of-scope
103
+ notes from `03-impl.md` — to `runs/<id>/06-backlog.md`, each as `open`, in the format
104
+ given in *Backlog* above. Every input is already assembled at this moment; the only
105
+ change is that it is written down rather than spoken and discarded.
106
+
107
+ Set `stage: "done"` in `state.json` once the user accepts.
108
+
109
+ ---