@pmelab/gtd 2.8.0 → 3.0.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.
- package/README.md +61 -40
- package/bin/gtd-loop +43 -23
- package/dist/gtd.bundle.mjs +2281 -3486
- package/docs/cli.md +187 -288
- package/docs/configuration.md +335 -71
- package/docs/design/configurable-state-machine.md +1439 -0
- package/docs/design/delta-purity-plan.md +283 -0
- package/docs/design/pattern-machine-plan.md +164 -0
- package/docs/design/scripted-actor.md +289 -0
- package/docs/design/state-file-association.md +112 -0
- package/docs/design/steering-file-loops.md +164 -0
- package/docs/design/work-packages.md +194 -0
- package/docs/development.md +55 -36
- package/docs/examples/advanced-workflow.md +428 -0
- package/docs/loop.md +60 -60
- package/docs/upgrading.md +125 -0
- package/package.json +2 -2
- package/schema.json +6 -73
- package/docs/upgrading-from-v1.md +0 -45
- package/docs/workflow.md +0 -428
package/docs/workflow.md
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
# The workflow
|
|
2
|
-
|
|
3
|
-
gtd drives a turn-taking loop between a human and an autonomous coding agent:
|
|
4
|
-
capture an idea, grill it into a product-level plan, grill that into a technical
|
|
5
|
-
architecture, decompose it into work packages, execute with parallel subagents,
|
|
6
|
-
test, agentically review each package, walk a human through a review, distill
|
|
7
|
-
durable lessons from the cycle into the project's own docs, and finally squash
|
|
8
|
-
the whole cycle into one conventional-commits commit at the end.
|
|
9
|
-
|
|
10
|
-
## How state is derived
|
|
11
|
-
|
|
12
|
-
Internally, gtd is a **pure fold** over git history. The decision core
|
|
13
|
-
(`src/Machine.ts`) is a single IO-free function, `resolve(events)` — **no
|
|
14
|
-
xstate, no actor, no Effect**. The Effect "edge" (`src/Events.ts`) does all the
|
|
15
|
-
git/filesystem IO: it reads the **first-parent** commit subjects since the
|
|
16
|
-
merge-base with the default branch (whole-history fallback when there is no
|
|
17
|
-
default branch, when HEAD equals the merge-base, or when there is no merge-base)
|
|
18
|
-
plus the working tree, turns them into a `COMMIT[]` + single terminal `RESOLVE`
|
|
19
|
-
event stream, and folds them through the machine. The fold lands on exactly
|
|
20
|
-
**one** of 21 states, plus which actor (human or agent) is awaited there. A
|
|
21
|
-
single call resolves to a single state.
|
|
22
|
-
|
|
23
|
-
Steering is entirely **machine-authored commit subjects** — there are no marker
|
|
24
|
-
files, sentinels, or auto-advance tails to parse. A turn commit looks like
|
|
25
|
-
`gtd(human): grilling` or `gtd(agent): building`; a routing commit (bookkeeping
|
|
26
|
-
the machine performs itself between turns) looks like `gtd: tests green`.
|
|
27
|
-
`src/Subjects.ts` is the closed grammar both the machine and the edge read.
|
|
28
|
-
|
|
29
|
-
All workflow state lives under **`.gtd/`**: the product plan (`.gtd/TODO.md`),
|
|
30
|
-
the technical architecture it converges into (`.gtd/ARCHITECTURE.md`), a
|
|
31
|
-
hand-written final architecture (`.gtd/PLAN.md`, an entry file — see
|
|
32
|
-
[Entry points](#entry-points-which-file-starts-the-cycle-where)), work packages
|
|
33
|
-
(`.gtd/01-…/`), review records (`.gtd/REVIEW.md`, `.gtd/FEEDBACK.md`), and loop
|
|
34
|
-
bookkeeping (`.gtd/ERRORS.md`, `.gtd/HEALTH.md`, `.gtd/LEARNINGS.md`,
|
|
35
|
-
`.gtd/SQUASH_MSG.md`). One rule follows for every agent in the loop: **never
|
|
36
|
-
touch `.gtd/`** except the single file a prompt explicitly grants. A `TODO.md`
|
|
37
|
-
or `REVIEW.md` at the repository root is the project's own file — gtd never
|
|
38
|
-
reads, consumes, or deletes it. (Corollary: don't gitignore `.gtd/` — the
|
|
39
|
-
workflow commits its state through it.)
|
|
40
|
-
|
|
41
|
-
A squash commit's message can carry a `## Decisions` section — one entry per
|
|
42
|
-
architecture/product question resolved that cycle. Grilling/architecting read
|
|
43
|
-
every past squash commit's `## Decisions` section back as "Prior decisions"
|
|
44
|
-
context, oldest to newest. See `decisionLog` under
|
|
45
|
-
[Configuration](configuration.md).
|
|
46
|
-
|
|
47
|
-
## States & subjects overview
|
|
48
|
-
|
|
49
|
-
`resolve()` lands on exactly one of **21 states**: `grilling`, `architecting`,
|
|
50
|
-
`grilled`, `planning`, `building`, `testing`, `fixing`, `escalate`,
|
|
51
|
-
`agentic-review`, `close-package`, `review`, `await-review`, `done`, `learning`,
|
|
52
|
-
`await-learning-review`, `learning-apply`, `learning-applied`, `squashing`,
|
|
53
|
-
`idle`, `health-check`, `health-fixing`. Each state has a fixed awaited actor
|
|
54
|
-
(see `awaitedActor` in `src/Machine.ts`): `idle`, `escalate`, `await-review`,
|
|
55
|
-
and `await-learning-review` await the **human**; every other state awaits the
|
|
56
|
-
**agent**.
|
|
57
|
-
|
|
58
|
-
For the full precedence ladder, illegal combinations, and the counter folds that
|
|
59
|
-
drive the fix loops, see [STATES.md](../STATES.md) — this section is a summary.
|
|
60
|
-
|
|
61
|
-
### Turn commits — `gtd(<actor>): <gate>`
|
|
62
|
-
|
|
63
|
-
Authored by `gtd step`/`gtd step-agent` as the first commit of a fresh chain.
|
|
64
|
-
The closed set of gates:
|
|
65
|
-
|
|
66
|
-
| Gate | Authored by |
|
|
67
|
-
| ---------------- | ------------------------------------------------------------------ |
|
|
68
|
-
| `grilling` | human (answers) / agent (product-plan iteration) |
|
|
69
|
-
| `architecting` | human (answers) / agent (architecture iteration) |
|
|
70
|
-
| `grilled` | agent (converged, ready to decompose) / human (PLAN.md entry turn) |
|
|
71
|
-
| `building` | agent (package work, or human feedback while agent is out of turn) |
|
|
72
|
-
| `fixing` | agent (test-fix or review-fix round) |
|
|
73
|
-
| `agentic-review` | agent (writes .gtd/FEEDBACK.md verdict) |
|
|
74
|
-
| `review` | agent (writes .gtd/REVIEW.md) / human (approves or gives feedback) |
|
|
75
|
-
| `squashing` | agent (overwrites .gtd/SQUASH_MSG.md) |
|
|
76
|
-
| `learning` | agent (overwrites .gtd/LEARNINGS.md) / human (accepts or edits) |
|
|
77
|
-
| `learning-apply` | agent (integrates .gtd/LEARNINGS.md into CLAUDE.md/AGENTS.md/docs) |
|
|
78
|
-
| `health-fixing` | agent (idle health-check repair) / human (HEALTH.md entry turn) |
|
|
79
|
-
| `escalate` | human (deletes .gtd/ERRORS.md to resume) |
|
|
80
|
-
|
|
81
|
-
### Routing commits — `gtd: <phase>`
|
|
82
|
-
|
|
83
|
-
Bookkeeping the machine authors itself between turns, never a turn a human or
|
|
84
|
-
agent "wins": `gtd: architecting`, `gtd: grilled`, `gtd: planning`,
|
|
85
|
-
`gtd: tests green`, `gtd: errors`, `gtd: package done`, `gtd: awaiting review`,
|
|
86
|
-
`gtd: review feedback`, `gtd: done`, `gtd: squash template`,
|
|
87
|
-
`gtd: reviewing <hash>` (parameterized, from `gtd review`), `gtd: health-check`,
|
|
88
|
-
`gtd: health-fix`, `gtd: learning template`, `gtd: learning drafted`,
|
|
89
|
-
`gtd: learning approved`, `gtd: learning applied`.
|
|
90
|
-
|
|
91
|
-
Everything else — any non-`gtd` subject, and any `gtd: *` subject outside this
|
|
92
|
-
closed set — is a **boundary commit**: inert as far as the machine's grammar is
|
|
93
|
-
concerned. See [Upgrading from v1](upgrading-from-v1.md) for why this matters on
|
|
94
|
-
upgrade.
|
|
95
|
-
|
|
96
|
-
## Grilling: two phases, product then architecture
|
|
97
|
-
|
|
98
|
-
A dirty tree at a boundary HEAD (a fresh idea, sketched in a file or just left
|
|
99
|
-
as pending code) is captured in **one** human turn: `gtd step` commits
|
|
100
|
-
everything pending as `gtd(human): grilling` — nothing is reverted or seeded,
|
|
101
|
-
the captured files stay in history. `gtd next` hands the agent that turn's diff;
|
|
102
|
-
the agent develops `.gtd/TODO.md` into a concrete **product-level** plan **in
|
|
103
|
-
one turn** — user-facing decisions only, no architecture — proposing a
|
|
104
|
-
**suggested default** for every open question under an enforced
|
|
105
|
-
`## Open Questions` structure (see
|
|
106
|
-
[Structured grilling/architecting and review files](#structured-grillingarchitecting-and-review-files)),
|
|
107
|
-
and leaves `.gtd/TODO.md` uncommitted for `gtd(agent): grilling`.
|
|
108
|
-
|
|
109
|
-
There are no markers to answer — the human either:
|
|
110
|
-
|
|
111
|
-
- **Accepts the suggested defaults**: runs a clean `gtd step` at the answer
|
|
112
|
-
gate. An empty `gtd(human): grilling` turn plus routing `gtd: architecting`
|
|
113
|
-
lands automatically — `.gtd/ARCHITECTURE.md` is seeded from the converged
|
|
114
|
-
`.gtd/TODO.md` content and `.gtd/TODO.md` is deleted, in that one commit.
|
|
115
|
-
- **Edits `.gtd/TODO.md`** with real answers, then runs `gtd step`, which
|
|
116
|
-
captures the edit as a fresh `gtd(human): grilling` turn and hands it back to
|
|
117
|
-
the agent for another round.
|
|
118
|
-
|
|
119
|
-
Technical architecting works exactly the same way, one file later: the agent
|
|
120
|
-
develops `.gtd/ARCHITECTURE.md` into a concrete **technical** plan — file/module
|
|
121
|
-
structure, data model, tech-stack choices — and the human answers or accepts
|
|
122
|
-
defaults at the `architecting` gate. Accepting converges to `gtd: grilled` and
|
|
123
|
-
`gtd next` emits the decompose prompt (which now reads `.gtd/ARCHITECTURE.md`).
|
|
124
|
-
|
|
125
|
-
## Entry points: which file starts the cycle where
|
|
126
|
-
|
|
127
|
-
The entry turn's gate is driven purely by which steering file the human's
|
|
128
|
-
initial dirty tree contains (file _presence_, never content — no CLI flag
|
|
129
|
-
needed). Four entry points:
|
|
130
|
-
|
|
131
|
-
| File in the dirty tree | Entry point |
|
|
132
|
-
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
133
|
-
| none (plain notes/sketches) | **Product grilling** — `gtd(human): grilling`; the agent develops `.gtd/TODO.md` from your notes |
|
|
134
|
-
| `.gtd/TODO.md` | **Product grilling** — same gate; your draft IS the product plan the agent iterates on |
|
|
135
|
-
| `.gtd/ARCHITECTURE.md` | **Technical grilling** — `gtd(human): architecting`; product grilling is skipped, the agent iterates your technical sketch (great for refactorings or test improvements with no product-facing changes) |
|
|
136
|
-
| `.gtd/PLAN.md` | **Decomposition** — `gtd(human): grilled`; the plan is FINAL: a mid-chain hop seeds `.gtd/ARCHITECTURE.md` from it (deleting `.gtd/PLAN.md`) and rests at the decompose prompt — no grilling round ever runs |
|
|
137
|
-
| `.gtd/HEALTH.md` | **Error fixing** — `gtd(human): health-fixing`; your hand-written error description rests at the health-fixing prompt, and the normal health detour takes over (fix → re-test with `testCommand` → cap/escalate → squash/learning tail). The description is a means to make `testCommand` green — a red re-test overwrites it |
|
|
138
|
-
|
|
139
|
-
The entry files are pairwise **illegal combinations** (see
|
|
140
|
-
[STATES.md](../STATES.md) §5.1), so the pick is always unambiguous — a tree
|
|
141
|
-
containing both `.gtd/PLAN.md` and `.gtd/TODO.md` hard-errors instead of
|
|
142
|
-
guessing.
|
|
143
|
-
|
|
144
|
-
One guard worth knowing for the HEALTH.md entry: the loop protocol opens every
|
|
145
|
-
iteration with a clean-tree `gtd step-agent`, and at this one rest that opening
|
|
146
|
-
beat is **inert** while HEAD is still the human's entry turn — so the
|
|
147
|
-
hand-written description is never consumed before an agent has read it.
|
|
148
|
-
|
|
149
|
-
## Structured grilling/architecting and review files
|
|
150
|
-
|
|
151
|
-
`.gtd/TODO.md`, `.gtd/ARCHITECTURE.md`, and `.gtd/REVIEW.md` stay plain,
|
|
152
|
-
human-readable markdown, but each follows an enforced structure so the data can
|
|
153
|
-
be parsed out programmatically (`gtd questions` / `gtd changesets`, both
|
|
154
|
-
`--json`-able, for a future UI) instead of staying opaque prose.
|
|
155
|
-
|
|
156
|
-
**Grilling/architecting** (identical contract, one file and phase apart): an
|
|
157
|
-
OPTIONAL `## Open Questions` section — omitted entirely means zero open
|
|
158
|
-
questions, not an error. Every `###` sub-heading directly under it is one open
|
|
159
|
-
question; its first body line must be `Suggested default: <text>` (the agent's
|
|
160
|
-
proposal) or `Answer: <text>` (a human's answer):
|
|
161
|
-
|
|
162
|
-
```markdown
|
|
163
|
-
# Plan
|
|
164
|
-
|
|
165
|
-
Build a calculator that can add and subtract.
|
|
166
|
-
|
|
167
|
-
## Open Questions
|
|
168
|
-
|
|
169
|
-
### Which operations?
|
|
170
|
-
|
|
171
|
-
Suggested default: add and subtract.
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
**Review**: a `# Review: <short-hash>` header as the first line, an
|
|
175
|
-
`<!-- base: <full-hash> -->` comment, and at least one `##` chunk with a
|
|
176
|
-
non-empty title and at least one `- [ ]` / `- [x]` file-pointer line — the same
|
|
177
|
-
format `@review` already instructs the agent to write (see
|
|
178
|
-
[Human review gate](#human-review-gate) below).
|
|
179
|
-
|
|
180
|
-
Validation applies ONLY to the **agent's own authored draft** at the gate that
|
|
181
|
-
writes the file — never to a human's free-form edits (their answer at the
|
|
182
|
-
grilling/architecting gate, their feedback/approval at the review gate). When
|
|
183
|
-
the active file is malformed, `gtd step-agent` refuses (zero commits, a stderr
|
|
184
|
-
message listing every structural problem) instead of capturing the turn; the
|
|
185
|
-
agent fixes the file and reruns `gtd step-agent`. `gtd questions --json` /
|
|
186
|
-
`gtd changesets --json` surface the same `errors` without blocking anything, so
|
|
187
|
-
an agent (or a UI) can self-check before committing to a turn.
|
|
188
|
-
|
|
189
|
-
## Build lifecycle: budgets
|
|
190
|
-
|
|
191
|
-
Once decomposed, `.gtd/` holds ordered work packages. `gtd next` at
|
|
192
|
-
`gtd: planning`/`gtd: package done` selects the lowest-numbered remaining
|
|
193
|
-
package and inlines only its task files. The agent builds it and leaves the work
|
|
194
|
-
**uncommitted**; the next invocation's edge action commits it (the
|
|
195
|
-
`gtd(agent): building` turn commit) and runs `testCommand`.
|
|
196
|
-
|
|
197
|
-
- **Green** → Agentic Review.
|
|
198
|
-
- **Red, below `fixAttemptCap`** (default 3) → write findings, commit
|
|
199
|
-
`gtd: errors`, rest at **Fixing** for the agent.
|
|
200
|
-
- **Red, at/over the cap** → write `.gtd/ERRORS.md` instead, commit
|
|
201
|
-
`gtd: errors`, rest at **Escalate** — a human gate. Deleting `.gtd/ERRORS.md`
|
|
202
|
-
and landing that deletion as `gtd(human): escalate` resets the budget and
|
|
203
|
-
re-tests from zero in the same invocation.
|
|
204
|
-
|
|
205
|
-
## Agentic review
|
|
206
|
-
|
|
207
|
-
A green test run always rests at **Agentic Review**: the agent reviews the
|
|
208
|
-
package's accumulated diff against its task specs and writes `.gtd/FEEDBACK.md`.
|
|
209
|
-
An **empty** `.gtd/FEEDBACK.md` is the approval signal — the same
|
|
210
|
-
`gtd(agent): agentic-review` turn closes the package (`gtd: package done`,
|
|
211
|
-
removing `.gtd/FEEDBACK.md` and the finished package directory) in one
|
|
212
|
-
invocation. Non-empty findings rest for the fixing prompt; fixing loops back
|
|
213
|
-
through the test gate and re-reviews. Once `reviewFixCount >= reviewThreshold`
|
|
214
|
-
(default 3) within a package, Agentic Review **force-approves** without ever
|
|
215
|
-
writing `.gtd/FEEDBACK.md` — so a package can never review-loop forever. The
|
|
216
|
-
findings round that crosses the threshold still gets its fixing round; the
|
|
217
|
-
force-approve close then fires at the next green re-test instead of another
|
|
218
|
-
review. (Any agentic-review turn that touches `.gtd/FEEDBACK.md` counts toward
|
|
219
|
-
the threshold — including the approval write itself; an approval that crosses
|
|
220
|
-
the threshold simply closes the package as usual.) Setting
|
|
221
|
-
`agenticReview: false` force-approves every package immediately.
|
|
222
|
-
|
|
223
|
-
A **do-nothing agent invocation** — `gtd step-agent` on a clean tree at ANY
|
|
224
|
-
agent-awaited rest whose move is a file artifact (`grilling`, `architecting`,
|
|
225
|
-
`grilled`, `building`, `fixing`, `agentic-review`, `review`, `squashing` while
|
|
226
|
-
`.gtd/SQUASH_MSG.md` still holds the unmodified template, `learning` while
|
|
227
|
-
`.gtd/LEARNINGS.md` still holds the unmodified template, and `learning-apply`
|
|
228
|
-
unconditionally) — is inert: zero commits, no state consumed; `gtd next`
|
|
229
|
-
re-emits the same prompt. This is load-bearing for the loop protocol, whose
|
|
230
|
-
every iteration opens with `gtd step-agent` before the agent has acted: without
|
|
231
|
-
the guard that opening beat would author junk empty turns — and worse, consume
|
|
232
|
-
workflow state (an empty decompose turn would delete `.gtd/ARCHITECTURE.md` with
|
|
233
|
-
no packages written; an empty squashing turn would squash the cycle under the
|
|
234
|
-
placeholder template). The same guards hold at the classification layer for
|
|
235
|
-
histories that already carry such turns: a `gtd(agent): grilled` HEAD only
|
|
236
|
-
routes to `gtd: planning` when packages exist, a `gtd(agent): review` HEAD only
|
|
237
|
-
routes to `gtd: awaiting review` when `.gtd/REVIEW.md` exists, and a squashing
|
|
238
|
-
(or learning) turn only proceeds once its template has been overwritten. The one
|
|
239
|
-
deliberate exception is `health-fixing`, whose empty turn is meaningful (the
|
|
240
|
-
failure may have been environmental — the machine removes `.gtd/HEALTH.md` and
|
|
241
|
-
re-tests) — except while HEAD is still the human's hand-written HEALTH.md entry
|
|
242
|
-
turn (`gtd(human): health-fixing`), where the empty opening beat is inert so the
|
|
243
|
-
description survives until an agent has actually read it. Human gates are
|
|
244
|
-
unaffected: an empty **human** turn stays a signal (accept-defaults at
|
|
245
|
-
grilling/architecting, clean approval at review, accept-the-draft-as-is at the
|
|
246
|
-
learning review gate).
|
|
247
|
-
|
|
248
|
-
## Human review gate
|
|
249
|
-
|
|
250
|
-
Once `.gtd/` is fully closed, the machine writes `.gtd/REVIEW.md` and rests at
|
|
251
|
-
**await-review**, awaiting the human. Approval is any of:
|
|
252
|
-
|
|
253
|
-
- A **clean** `gtd step` (nothing edited) — an empty `gtd(human): review` turn
|
|
254
|
-
plus routing `gtd: done`.
|
|
255
|
-
- Flipping only `- [ ]` → `- [x]` checkboxes in `.gtd/REVIEW.md` — checkbox-only
|
|
256
|
-
edits are also treated as clean approval.
|
|
257
|
-
- Deleting `.gtd/REVIEW.md` outright.
|
|
258
|
-
|
|
259
|
-
Any **substantive** edit — to `.gtd/REVIEW.md` prose, or to the reviewed code
|
|
260
|
-
itself — is feedback: `gtd(human): review` plus routing `gtd: review feedback`,
|
|
261
|
-
`.gtd/REVIEW.md` removed, and `gtd next` re-emits a grilling prompt to the agent
|
|
262
|
-
that inlines the human's finding.
|
|
263
|
-
|
|
264
|
-
**The review diff lives in your editor.** While the gate is pending, gtd holds
|
|
265
|
-
open a _review checkout window_: it saves the real head to
|
|
266
|
-
`refs/gtd/review-head`, then rewinds HEAD and the index to the review base with
|
|
267
|
-
`git reset --mixed`, leaving the working tree untouched. Every editor's standard
|
|
268
|
-
git integration now shows the entire reviewable diff as ordinary uncommitted
|
|
269
|
-
changes — SCM panel, gutter marks, per-file diffs. Review it there:
|
|
270
|
-
|
|
271
|
-
- **Edit** anything (code or `.gtd/REVIEW.md` prose) → feedback.
|
|
272
|
-
- **Discard a hunk** in the editor → that reversion IS the feedback: the agent
|
|
273
|
-
is re-grilled with it.
|
|
274
|
-
- **Delete a surfaced file** → reject-this-file feedback.
|
|
275
|
-
- Touch nothing (or tick checkboxes / delete `.gtd/REVIEW.md`) → approval.
|
|
276
|
-
|
|
277
|
-
Any gtd invocation closes the window first (restoring HEAD/index exactly, so
|
|
278
|
-
only your own edits remain dirty — they land as their own separate
|
|
279
|
-
`gtd(human): review` commit, never mixed into the reviewed work), and
|
|
280
|
-
`gtd next`/`gtd status` re-arm it on their way out. The mechanics are
|
|
281
|
-
crash-safe; details and invariants in [STATES.md](../STATES.md) ("The review
|
|
282
|
-
checkout window").
|
|
283
|
-
|
|
284
|
-
Caveats while a review is pending: don't push (the branch tip rests at the
|
|
285
|
-
review base — the real head is safe under `refs/gtd/review-head`); commits you
|
|
286
|
-
make manually survive as working-tree content and become review feedback, but
|
|
287
|
-
their commit message is discarded; linked `git worktree` checkouts are
|
|
288
|
-
unsupported. If you switch branches mid-review, gtd refuses to touch the foreign
|
|
289
|
-
branch and prints the manual recovery command.
|
|
290
|
-
|
|
291
|
-
## Learning
|
|
292
|
-
|
|
293
|
-
With `learning: true` (the default), `gtd: done` (or the health-fix path's green
|
|
294
|
-
re-test) is **not** a rest — the chain continues straight to
|
|
295
|
-
`gtd: learning template`, writing and committing a `.gtd/LEARNINGS.md` template,
|
|
296
|
-
running _before_ the squash decision so it still sees the pre-squash history.
|
|
297
|
-
`gtd next` then emits the learning prompt: the agent walks the cycle's test
|
|
298
|
-
failures, review feedback, and health-check rounds, keeps only
|
|
299
|
-
durable/generalizable lessons, and overwrites `.gtd/LEARNINGS.md` with them.
|
|
300
|
-
Once `gtd step-agent` captures that draft (`gtd(agent): learning`), it rests at
|
|
301
|
-
**await-learning-review** for a human — who either accepts the draft as-is (an
|
|
302
|
-
empty turn) or edits it; there is no reject path, so the very next `gtd step`
|
|
303
|
-
always proceeds (`gtd(human): learning` → `gtd: learning approved`), resting at
|
|
304
|
-
**learning-apply** for the agent. The agent integrates the approved learnings
|
|
305
|
-
into the project's own docs (`CLAUDE.md`/`AGENTS.md`/wherever fits, its
|
|
306
|
-
judgment); its turn (`gtd(agent): learning-apply`) removes `.gtd/LEARNINGS.md`
|
|
307
|
-
and lands at `gtd: learning applied`, which then runs the same squash decision
|
|
308
|
-
`gtd: done` runs today. With `learning: false`, `gtd: done` behaves exactly as
|
|
309
|
-
it does without this section: no `.gtd/LEARNINGS.md` is ever written. Learning
|
|
310
|
-
and squash are independent flags — either can be on without the other.
|
|
311
|
-
|
|
312
|
-
## Squash
|
|
313
|
-
|
|
314
|
-
With `squash: true` (the default), `gtd: done` (or, once learning has run,
|
|
315
|
-
`gtd: learning applied`) is **not** a rest — the same chain continues straight
|
|
316
|
-
to `gtd: squash template`, writing and committing a `.gtd/SQUASH_MSG.md`
|
|
317
|
-
template. `gtd next` then emits the squashing prompt: the agent overwrites
|
|
318
|
-
`.gtd/SQUASH_MSG.md` with a real conventional-commits message (drawing on
|
|
319
|
-
grilling- and architecting-round decisions from history, and, when this cycle
|
|
320
|
-
resolved any open questions, a `## Decisions` section recording them) and
|
|
321
|
-
finishes its turn. `gtd step-agent` then performs the squash itself:
|
|
322
|
-
`git reset --soft <base>` + `git commit`, collapsing every intermediate `gtd: *`
|
|
323
|
-
commit of the cycle into one — including any review-feedback detours, and the
|
|
324
|
-
learning phase's own commits if learning ran: the squash base is the cycle's
|
|
325
|
-
ORIGINAL start (the first grilling, architecting, or grilled entry turn since
|
|
326
|
-
the previous `gtd: done` boundary — whichever entry point the cycle used — or
|
|
327
|
-
the `gtd: reviewing <hash>` anchor for an ad-hoc review cycle), not the most
|
|
328
|
-
recent re-grilling round — the collapse folds the whole cycle into one, using
|
|
329
|
-
the overwritten message's content verbatim (turn position, not message content,
|
|
330
|
-
triggers the squash). Doc edits made during `learning-apply` survive in the
|
|
331
|
-
squashed tree, not as their own commit. With `squash: false`, `gtd: done` (or
|
|
332
|
-
`gtd: learning applied`) is the resting boundary and no template is ever
|
|
333
|
-
written.
|
|
334
|
-
|
|
335
|
-
## Health check
|
|
336
|
-
|
|
337
|
-
Outside any process (idle, nothing to review, no steering files), `gtd step`
|
|
338
|
-
runs `testCommand` as a health check rather than settling immediately. Green
|
|
339
|
-
settles idle with zero commits. Red below `fixAttemptCap` writes
|
|
340
|
-
`.gtd/HEALTH.md` and rests at **Health Fixing** for the agent; the fixer's own
|
|
341
|
-
turn (`gtd(agent): health-fixing`) removes `.gtd/HEALTH.md` and re-tests in the
|
|
342
|
-
same chain — a green re-test continues to learning (if enabled), then squash (if
|
|
343
|
-
enabled), or idle; red repeats the health-fix loop; red at the cap writes
|
|
344
|
-
`.gtd/ERRORS.md` and escalates.
|
|
345
|
-
|
|
346
|
-
The same detour is also a direct entry point: hand-write `.gtd/HEALTH.md`
|
|
347
|
-
describing the errors and run `gtd step` (see
|
|
348
|
-
[Entry points](#entry-points-which-file-starts-the-cycle-where)).
|
|
349
|
-
|
|
350
|
-
## Escalate / budget reset
|
|
351
|
-
|
|
352
|
-
`.gtd/ERRORS.md` present is always a human gate, regardless of which loop wrote
|
|
353
|
-
it (test-fix or health-fix). Deleting `.gtd/ERRORS.md` and running `gtd step`
|
|
354
|
-
records the deletion as the human's `gtd(human): escalate` turn, which
|
|
355
|
-
**immediately re-tests in the same invocation** — this resets the relevant
|
|
356
|
-
fix-attempt budget to zero.
|
|
357
|
-
|
|
358
|
-
## States & subjects: overview table
|
|
359
|
-
|
|
360
|
-
| State | Awaits | Turn/routing subject at rest |
|
|
361
|
-
| ----------------------- | -------------- | ---------------------------------------------------------------- |
|
|
362
|
-
| `grilling` | human or agent | `gtd(human): grilling` / `gtd(agent): grilling` |
|
|
363
|
-
| `architecting` | human or agent | `gtd: architecting` / `gtd(agent): architecting` |
|
|
364
|
-
| `grilled` | agent | `gtd: grilled` |
|
|
365
|
-
| `planning` | agent | `.gtd/` modified |
|
|
366
|
-
| `building` | agent | `gtd: planning` / `gtd: package done` |
|
|
367
|
-
| `testing` | — (edge-only) | mid-chain only |
|
|
368
|
-
| `fixing` | agent | `gtd: errors` |
|
|
369
|
-
| `escalate` | human | `.gtd/ERRORS.md` present |
|
|
370
|
-
| `agentic-review` | agent | `gtd: tests green` |
|
|
371
|
-
| `close-package` | — (edge-only) | mid-chain only |
|
|
372
|
-
| `review` | agent | `gtd: package done` (no more packages) / `gtd: reviewing <hash>` |
|
|
373
|
-
| `await-review` | human | `gtd: awaiting review` |
|
|
374
|
-
| `done` | — (edge-only) | `gtd: done` |
|
|
375
|
-
| `learning` | agent | `gtd: learning template` |
|
|
376
|
-
| `await-learning-review` | human | `gtd: learning drafted` |
|
|
377
|
-
| `learning-apply` | agent | `gtd: learning approved` |
|
|
378
|
-
| `learning-applied` | — (edge-only) | `gtd: learning applied` |
|
|
379
|
-
| `squashing` | agent | `gtd: squash template` |
|
|
380
|
-
| `idle` | human | no steering files, green health check |
|
|
381
|
-
| `health-check` | — (edge-only) | mid-chain only |
|
|
382
|
-
| `health-fixing` | agent | `.gtd/HEALTH.md` present |
|
|
383
|
-
|
|
384
|
-
See [STATES.md](../STATES.md) for the full precedence ladder, the counter folds,
|
|
385
|
-
and every illegal steering-file combination.
|
|
386
|
-
|
|
387
|
-
## Build orchestration
|
|
388
|
-
|
|
389
|
-
### Decompose
|
|
390
|
-
|
|
391
|
-
The Grilled/Planning states spawn a planning-model subagent that breaks
|
|
392
|
-
`.gtd/ARCHITECTURE.md` into executable work packages under `.gtd/`:
|
|
393
|
-
|
|
394
|
-
```
|
|
395
|
-
.gtd/
|
|
396
|
-
01-auth-module/
|
|
397
|
-
01-define-types.md
|
|
398
|
-
02-implement-login.md
|
|
399
|
-
02-api-endpoints/
|
|
400
|
-
01-create-routes.md
|
|
401
|
-
02-add-middleware.md
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
Rules:
|
|
405
|
-
|
|
406
|
-
- **Packages are sequential, in ordinal dependency order** — `01-`, `02-`, …;
|
|
407
|
-
the set is frozen once written. Package 02 cannot start until 01 is complete.
|
|
408
|
-
- **Each package is green on its own** — the test suite runs after every
|
|
409
|
-
package, so none may leave the tree red for a later package to fix.
|
|
410
|
-
- **Tasks within a package are parallel and file-disjoint** — one subagent per
|
|
411
|
-
task, no isolation; tasks that would touch the same file are merged into one.
|
|
412
|
-
- **Vertical slices, not horizontal** — each package is a thin, end-to-end
|
|
413
|
-
slice; prefer many thin packages over a "set up infrastructure" package.
|
|
414
|
-
- **Task files are self-contained** — description, acceptance-criteria
|
|
415
|
-
checkboxes, relevant file paths, constraints, and edge cases.
|
|
416
|
-
|
|
417
|
-
### Execute
|
|
418
|
-
|
|
419
|
-
Execution is **one package per cycle**. `gtd next` selects the single next
|
|
420
|
-
package itself, names it in the prompt, and inlines its task files' full
|
|
421
|
-
contents — the agent never browses `.gtd/` or picks a package itself. A single
|
|
422
|
-
cycle:
|
|
423
|
-
|
|
424
|
-
1. Spawn parallel execution-model workers for all tasks in the selected package.
|
|
425
|
-
2. Leave all changes **uncommitted**. Do not commit, do not delete the package
|
|
426
|
-
directory, do not run tests.
|
|
427
|
-
3. Finish the turn with `gtd step-agent` — the next hop's edge action commits
|
|
428
|
-
the work (`gtd(agent): building`) and runs `testCommand` to verify it.
|