@pmelab/gtd 10.7.1 → 10.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.
- package/README.md +2 -0
- package/dist/gtd.bundle.mjs +4 -3
- package/package.json +1 -1
- package/schema.json +1 -1
package/README.md
CHANGED
|
@@ -285,6 +285,8 @@ moments — everything between them runs without you.
|
|
|
285
285
|
2. **You answer questions.** Planning stops and hands you a file with its open
|
|
286
286
|
questions in it — what the thing should do first, then how it should be
|
|
287
287
|
built. Answer them in your editor, in the file, and start the loop again.
|
|
288
|
+
Leave the file untouched and start the loop instead to accept the plan as-is,
|
|
289
|
+
unanswered questions and all.
|
|
288
290
|
3. **You wait.** The work is split into packages and built one at a time, each
|
|
289
291
|
one checked against your test suite and fixed until it passes.
|
|
290
292
|
4. **You review.** You get a review document listing what changed and what to
|
package/dist/gtd.bundle.mjs
CHANGED
|
@@ -31082,7 +31082,7 @@ const STATE_FIELDS = {
|
|
|
31082
31082
|
authored: "state",
|
|
31083
31083
|
requires: "file",
|
|
31084
31084
|
viz: "flag",
|
|
31085
|
-
doc: "When true, a step at this state is refused unless every open question in its qa-mode `file:` is answered — exactly one checkbox ticked per question. Requires a `file:` and `mode: qa`."
|
|
31085
|
+
doc: "When true, a step at this state is refused unless every open question in its qa-mode `file:` is answered — exactly one checkbox ticked per question — except a wholly untouched working tree, which passes the gate; any other change, code included, still refuses on unanswered questions. Requires a `file:` and `mode: qa`."
|
|
31086
31086
|
},
|
|
31087
31087
|
/**
|
|
31088
31088
|
* The pure engine never reads this — checked at the edge by the
|
|
@@ -53117,7 +53117,7 @@ var import_dist$1 = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
53117
53117
|
exports.visit = visit.visit;
|
|
53118
53118
|
exports.visitAsync = visit.visitAsync;
|
|
53119
53119
|
})))();
|
|
53120
|
-
var unified_default = "# gtd's BUILT-IN DEFAULT workflow — used when no `workflow:` key is\n# configured anywhere in the cwd→home config chain; `gtd init` seeds only\n# vars.testCommand + a modes: suggestion, never this file. Compiled through\n# the same `compileWorkflowConfig` a user's own `workflow:` goes through — no\n# privileged path. See skills/authoring/SKILL.md for how to read or edit it\n# (machines, patterns, templates) and docs/driver.md for how a driver runs it.\n#\n# One flow: any change to the tree starts the process. `idle` -> `unwind`\n# reverts that diff (intent survives only in history) -> a green-baseline\n# gate -> `design.triage` groups the reverted diff into ordered, classified\n# concerns and resolves the PRODUCT ones' open questions (`design.gate`) ->\n# `architecture.author` works out the *how* and resolves the TECHNICAL ones\n# (`architecture.gate`) -> `architecture.decompose` writes one package file\n# per concern -> the per-package queue (`packages.*`) builds and reviews each\n# -> the shared tail (`build.review.*`) decides sign-off (-> `idle`, landing\n# an ordinary commit that closes the process — every per-turn commit stays on\n# the branch; run `gtd summary` afterward for a closing-message prompt) vs.\n# actionable feedback (-> `re-unwind` -> back to `design.triage`, a full\n# re-plan lap that never builds on the human's hand-edit). `--entry\n# review-gate.check --var reviewBase=<commitish>` and `--entry fix-precheck`\n# are the two other entries into this same flow.\nvars:\n testCommand: npm test\n # plannerModel: the heavier tier for one-shot triage/design/review turns.\n # coderModel: the tier for build/fix turns. Both repointable via a\n # top-level `vars:` key or a `GTD_<NAME>` env var, like any other var.\n plannerModel: smart\n coderModel: base\n # Declared (not left undeclared) so `--var reviewBase=...` passes the CLI's\n # declared-name check; blank renders empty, which the review entry refuses.\n reviewBase: \"\"\n # gtd's own voice for generated files — adapted from the \"Spartan\" output\n # style (https://github.com/alexgreensh/attention-span, AGPL-3.0, version 0.6),\n # rewritten in gtd's own words for deliverables rather than chat replies;\n # no upstream text ships. A point-in-time derivation with no refresh\n # mechanism.\n styleBlock: |-\n - A deliverable, not a chat reply — size follows the work; cut padding\n - Lead with the answer; never circle back to restate it\n - Flat, commanding sentences — commit to the claim, never hedge\n - Everyday words; define an unavoidable term in five words or fewer, on\n first use\n - Bold carries the load: bold the claim, not the sentence around it —\n the bold text alone must yield the full point and every risk\n - **Never trim a risk, a number, a threshold, or a scoped condition to\n save space — this outranks every other rule here**\n - Ship the artifact bare — no lead-in, no sign-off\n - Compressing is not dropping: three load-bearing parts ship as three,\n each shorter, never as two\n - One idea per block; break when the idea shifts\n - Flag risk in one blunt line, never hedged prose; never narrate — do it\n styleFormatContract: |-\n - Machine-read: its format contract outranks every style rule above —\n keep every `##`/`###` heading, checkbox row, and marker line exactly\n as specified. Never renumber or rename a heading; a parser reads\n these literally and a violation refuses the turn\n - Voice rules above govern only the prose between these elements\n\n # One persona per prompt-bearing machine below, stamped as its `system:`\n # (see src/StateFields.ts's `system`). `--system-prompt` REPLACES a\n # harness's default system prompt — including its injected cwd/env/\n # git-status block — so each persona is written self-contained, restating\n # that context explicitly rather than relying on it.\n\n # Shared conduct tail, appended after every persona's own role paragraph:\n # use tools without asking, orient yourself with git, and go inspect what\n # the turn's message names. Deliberately NOT named `*Persona`:\n # `templates.test.ts` derives its six-name persona set from\n # `it\\.vars\\.(\\w+Persona)`, so that suffix would silently grow the set.\n agentConduct: |-\n - You have shell and file tools — bash, read, write, edit — use them\n without asking first; this runs unattended, no one grants permission\n - Investigate with real commands rather than assuming a file's, a\n commit's, or a decision's status — then act on what you find\n - No injected status block — no cwd, no branch, no history, no tree\n state — orient yourself first with `git status`, `git log`, `ls`\n - The turn's message names a commit, a range, or a file to go inspect\n yourself — never a diff or summary inlined into the conversation\n - Across turns one conversation may span, work from what you already\n read and settled, unless told this is a fresh, cold pass\n designPersona: |-\n You are the product-facing planning voice in gtd's build pipeline: turn\n a raw sketch — a hand-edit, a scratch note, or both — into an ordered,\n classified list of concerns, and hold the running product conversation\n with the human it depends on. You are read by that human — write\n plainly — not by a parser, except where a state says otherwise.\n architectPersona: |-\n You are the technical planning voice in gtd's build pipeline: take over\n once product concerns are settled, reading them cold, no carried\n conversation. Work out the *how* per concern — structure, data models,\n tech-stack choices, error handling — raise the technical open\n questions, then write one package spec per concern with no further\n judgement call: the grouping is already decided.\n reviewerPersona: |-\n You are the independent reviewing mind in gtd's build pipeline —\n deliberately separate from whoever wrote the code, with no attachment\n to it. Two turns: write a structured review document grouping a diff\n into chunks; later, classify a round of the human's feedback as\n actionable or just approving, never fixing anything yourself. You judge\n and classify; you never build.\n specReviewerPersona: |-\n You are the adversarial spec-conformance checker in gtd's build\n pipeline, checking one freshly-built package against its spec. Verify\n only: tasks done, criteria met, code sound and consistent with the\n codebase. Write feedback only when something is genuinely wrong —\n otherwise write nothing; a clean turn IS the approval. Never fix what\n you find — naming it precisely enough for a fix turn is the whole job.\n builderPersona: |-\n You are the TDD implementer in gtd's build pipeline: build one\n package's declared scope end to end, tests first, and come back to fix\n things when redirected — a failing check, or reviewer feedback. Stay\n strictly inside the package in front of you; never touch another\n package's files or code outside the task. Treat feedback as the\n diagnosis to act on; discard it, with reason, only when simply wrong.\n finisherPersona: |-\n You are the closing identity in gtd's build pipeline — the last coder\n before it closes. Fix a late-breaking failing check after sign-off,\n focused and minimal. Every turn lands its own commit — nothing here\n gets squashed away.\n\n # The scratchpad-opener sentence shared by every prompt-content state (see\n # STATE_FIELDS's `prompt`) — this workflow's own state files are its private\n # working notes, never project code or documentation a human reads. Injected\n # as the leading line of every prompt body that touches a `.gtd/` file\n # directly; each state's own \"the only state file this turn touches is X\"\n # sentence stays local, immediately after the tag. Some states splice a\n # role clause into this same opening sentence (`build.review.collecting`,\n # `packages.item.spec.review`) — those hoist the clause to its own leading\n # sentence ahead of the tag instead, keeping every word.\n stateFileRules: |-\n - You are an autonomous coding agent\n - This workflow's own state files are its private scratchpad, never\n project code or documentation\n # The open-questions warrant test, decide-it-yourself sink, and `## Open\n # Questions` checkbox shape shared by `design.triage` and\n # `architecture.author` — written phase-agnostic (no PRODUCT/TECHNICAL\n # bake-in) so both sites can inject it verbatim. Each site's own\n # phase-scope sentence (triage: product-only, technical waits; architecture:\n # every point here is TECHNICAL) stays local around the tag — the two\n # genuinely disagree on scope, so that sentence is never shared.\n # `questionBarReturn` is the return-lap half — split out so each site can\n # inject it under its own `## Return lap` heading instead of burying\n # return-lap behaviour inside the first lap's own section.\n questionBar: |-\n - Ask only when all three hold: it's a genuine fork with divergent\n outcomes (user-visible for product, materially different builds for\n technical); the diff and history don't already settle it (treat an\n explicit `.gtd/TODO.md` directive, a committed hand-edit, or — on a\n loop-back lap — the human's own review-round edit/note as settled);\n and getting it wrong would survive to the human review tail\n - Below that bar, decide it yourself: record it under\n `## Answered Questions` as `### <the point phrased as a question>`\n plus a one-line rationale in prose, no checkboxes. That heading\n always comes last, after every other `##` section\n - Above the bar, write it under `## Open Questions` — always the first\n `##` section — as `### <question>` plus a checkbox list: two\n concrete options and a free-text slot, all unticked:\n\n ### <the question>\n\n - [ ] <first option — a concrete answer, a few words of rationale>\n - [ ] <second option>\n - [ ] _your answer_\n\n - Never tick a box yourself — the human ticks exactly one per question\n questionBarReturn: |-\n - The human ticked one option per question (or wrote their own in\n place of `_your answer_`): fold each answer into its concern's\n prose, then move the question into `## Answered Questions` as\n `### <question>` with the resolved answer in plain prose — no\n checkboxes\n - `## Answered Questions` is always the last `##` section — a moved\n question lands there, never wherever `## Open Questions` used to sit\n - Never re-raise a deleted question — treat a deleted `## Open\n Questions` section as acceptance; omit it entirely once none are left\n # The body `packages.item.fix-suite` and `build.fix` share byte for byte —\n # both fix a red `.gtd/FEEDBACK.md`. `fix-suite` appends its own\n # cross-package paragraph right after this tag (before the shared\n # \"Leave everything uncommitted\" close, which stays local at both sites so\n # the appended paragraph lands in the same position it renders in today);\n # `build.fix` renders the tag alone.\n fixFeedbackPrompt: |-\n - The only state file this turn touches is `.gtd/FEEDBACK.md` — no\n other files for notes or output\n - Read it (the failing test output) and fix the code so the suite\n passes; keep the change focused, never refactor unrelated code\n - If the feedback is wrong, fix nothing rather than \"fixing\" a non-issue\n - Delete `.gtd/FEEDBACK.md` either way — once the suite passes, or once\n you have established the feedback was wrong; leaving it in place is\n never the right end state, the next check writes its own\n\n # The human-facing half of footnotes — how to type one, injected into the\n # three human-gate messages (`design.gate.answer`, `architecture.gate.answer`,\n # `build.review.await-review`). `footnoteFoldIn` below is the agent-facing\n # half; the two never share text, different audience and content.\n footnoteRules: |-\n - Leave a footnote anywhere: mark the exact spot with `[^name]` (any\n name, no whitespace or `]`), then define it below as `[^name]:\n explain what you mean` — indent a longer comment's continuation\n lines. (The literal words \"your comment\" are this format's seeded\n placeholder body — a definition still holding them exactly is\n flagged as unfilled, so write your own words there)\n - A footnote is a comment on that exact spot — the hunk, line, or\n paragraph it marks — never a whole-file remark\n - `name` is yours to pick; only a definition's name must be unique in\n this document — the same name may mark more than one spot\n # The agent-facing half — injected into the three prompts that fold a\n # footnote in (`design.triage`, `architecture.author`,\n # `build.review.collecting`). `build.review.reviewing`, the one state that\n # WRITES a review file, references neither tag — the agent never authors a\n # footnote.\n footnoteFoldIn: |-\n - A footnote (`[^name]` plus its `[^name]:` definition) is a comment on\n its exact anchor — fold it in as a mandatory concern described\n against that anchor's hunk or paragraph, never flattened into a\n whole-file remark\n - DELETE it in this same turn — marker and definition together — the\n way a transient hand-written code comment is already treated. Never\n re-read a footnote already acted on\n - A footnote is human input only — you reply in prose; never write one\n yourself\n\n# `gtd summary`'s prompt — printed cold, no session identity, no diff inlined.\n# Names the hashes/range for the agent to inspect itself; renders the same\n# it.processCost/it.processCostByModel the old squash finale used to.\nsummary: |\n <%~ it.vars.styleBlock %>\n\n\n - Write the closing message for the process HEAD closes or sits inside —\n for a squash, an amend, or a PR body. Starting cold: read every\n decision out of the commits below, not assumed context\n - Cover the motivation, the decisions, the trade-offs, and the\n high-level architectural changes — never which files changed; `git\n diff --stat` is for that, not this message\n\n The process's entry commit is `<%= it.entryCommit %>`. <% if\n (it.humanCommits.length > 0) { %>The human contributed at these commits,\n oldest to newest:\n <% it.humanCommits.forEach(function (c) { %>\n - `<%= c.hash %>` (entering `<%= c.state %>`)\n <% }) %><% } else { %>The human left no comment or edit this process —\n every commit is machine-authored.<% } %>\n\n Inspect the range: `git log <%= it.processBase %>..<%= it.processTip %>`\n and `git diff <%= it.processBase %> <%= it.processTip %>` — exactly what\n a squash or PR body should describe.\n\n Token cost: <%= it.processCost %>\n <% it.processCostByModel.forEach(function(m){ %>\n - <%= m.model %>: <%= m.cost %>\n <% }) %>\n\n Print the closing message and stop — this writes nothing itself.\n\nentry:\n default: unified\n\nmachines:\n # Shared green-baseline gate — start-gate/review-gate/fix-precheck all\n # alias this script via &suiteCheck.\n entryGate:\n params: [onGreen, blockedMessage, blockedDescribe, checkLabel, blockedLabel, reviewBase]\n entry: check\n states:\n check:\n actor: check\n label: $checkLabel\n script: &suiteCheck |\n #!/usr/bin/env sh\n set +e\n mkdir -p .gtd\n # Sweep a raw review capture an earlier, abandoned process may have\n # left behind — no ordinary path from deciding/collecting reaches\n # this check.\n rm -f .gtd/REVIEW_RAW.md\n <%~ it.vars.testCommand %> > .gtd/.check-output 2>&1\n code=$?\n if [ \"$code\" -ne 0 ]; then\n if [ -s .gtd/.check-output ]; then\n mv .gtd/.check-output .gtd/FEEDBACK.md\n else\n rm -f .gtd/.check-output\n printf 'the test command failed with exit code %s and produced no output.' \"$code\" > .gtd/FEEDBACK.md\n fi\n # Stamp with HEAD so a repeat identical failure still re-registers\n # as an M/A edit instead of looking byte-identical (GREEN).\n printf '\\n<!-- gtd check %s -->\\n' \"$(git rev-parse --short HEAD 2>/dev/null || echo pending)\" >> .gtd/FEEDBACK.md\n else\n rm -f .gtd/.check-output\n rm -f .gtd/FEEDBACK.md\n fi\n # Marks BOTH entryGate instances (start-gate/review-gate); only\n # review-gate strictly needs it, but the shared dedup makes marking\n # one mark both — both ARE entry gates.\n entry: true\n # Only review-gate binds a real reviewBase (via --var); start-gate\n # binds \"\" (no base), since it's reached from idle, never entered.\n reviewBase: $reviewBase\n on:\n \"A .gtd/FEEDBACK.md\": blocked\n \"M .gtd/FEEDBACK.md\": blocked\n \"D .gtd/REVIEW_RAW.md\": $onGreen\n \"D .gtd/FEEDBACK.md\": $onGreen\n \"C\": $onGreen\n blocked:\n actor: human\n label: $blockedLabel\n file: FEEDBACK.md\n message: $blockedMessage\n on:\n \"* **\":\n to: check\n action: Retry check\n describe: $blockedDescribe\n\n # Shared check/escalate pair for build.health.*/packages.item.health.* —\n # the caller's own coder fix-state ($onRed), not this machine, handles red.\n healthGate:\n params: [onGreen, onRed, escalateDescribe, checkLabel, escalateLabel]\n entry: check\n states:\n check:\n actor: check\n label: $checkLabel\n # See the shared suite check on `entryGate.check` above.\n script: *suiteCheck\n on:\n \"A .gtd/FEEDBACK.md\": $onRed\n \"M .gtd/FEEDBACK.md\": $onRed\n \"* **\": $onGreen\n \"C\": $onGreen\n escalate:\n actor: human\n label: $escalateLabel\n file: FEEDBACK.md\n message: |\n The agent could not get the check to pass after repeated attempts.\n `.gtd/FEEDBACK.md` holds the last failing output.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: check\n action: Retry check\n describe: $escalateDescribe\n\n # Shared check/answer pair for design.gate/architecture.gate. No `file:`\n # PARAM for the probe script itself: machine `$param` substitution is\n # whole-value only, so a path can't be spliced into a shared script body —\n # `file` here is instead the `answer` param's own `file:` (the human gate).\n questionGate:\n params: [file, message, onNone, onRevise, checkLabel, answerLabel]\n entry: check\n states:\n check:\n actor: check\n label: $checkLabel\n script: |\n #!/usr/bin/env sh\n # Exactly one of REQUIREMENTS.md/ARCHITECTURE.md exists on disk at\n # a time — architecture.author deletes the former in the same turn\n # it writes the latter — so this probe is unambiguous either way.\n set +e\n mkdir -p .gtd\n file=.gtd/REQUIREMENTS.md\n [ -f \"$file\" ] || file=.gtd/ARCHITECTURE.md\n gtd check qa \"$file\" --open-questions > /dev/null 2>&1\n code=$?\n if [ \"$code\" -ne 0 ]; then\n printf 'open questions remain in %s\\n' \"$file\" > .gtd/QUESTIONS.md\n # See the shared suite check's cache-buster rationale on\n # `entryGate.check` above.\n printf '\\n<!-- gtd check %s -->\\n' \"$(git rev-parse --short HEAD 2>/dev/null || echo pending)\" >> .gtd/QUESTIONS.md\n else\n rm -f .gtd/QUESTIONS.md\n fi\n on:\n \"A .gtd/QUESTIONS.md\": answer\n \"M .gtd/QUESTIONS.md\": answer\n \"D .gtd/QUESTIONS.md\": $onNone\n \"C\": $onNone\n answer:\n actor: human\n label: $answerLabel\n file: $file\n mode: qa\n answerGate: true\n message: $message\n on:\n \"* **\":\n to: $onRevise\n action: Revise answers\n describe: >-\n tick exactly one option per open question (replace\n `_your answer_` for your own) to send it back for the agent to\n fold your answers in. Delete a question to skip it, or delete\n the whole `## Open Questions` section to accept the plan as-is.\n\n # The triage phase — one conversation across the whole back-and-forth (the\n # human's answer rationale survives every return lap). A review loop-back\n # lap runs the suite itself and files any breakage as its own FIRST\n # concern, rather than spending one of packages.item.fix-suite's\n # (per-episode) retries on breakage the package didn't cause.\n # ▸ planner identity.\n designPlan:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.designPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onArchitecture]\n entry: triage\n states:\n triage:\n actor: agent\n label: Triaging the change\n file: REQUIREMENTS.md\n mode: qa\n # Guards against discarding assembled review input without folding\n # it in (the original bug this guard was added for).\n requireProgress: true\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.footnoteFoldIn %>\n\n - The only state file this turn touches is `.gtd/REQUIREMENTS.md`\n — no other files for notes or output\n - `.gtd/TODO.md` is the likely home of the sketch that started\n this process — the human's input, folded into the concerns\n below like any other part of the start diff; never a state\n file to preserve, never gtd bookkeeping to ignore\n - This process started at commit `<%= it.startCommit %>`,\n reverted out of the tree by `unwind` right after landing, so\n `git diff <%= it.startCommit %>` is now empty — its content\n survives only in history. Find the entry commit yourself:\n `git rev-list --ancestry-path <%= it.startCommit %>..HEAD | tail -1`\n (the process's first turn, before any baseline-repair\n commits), then `git show` it — a hand-edit, a scratch note,\n or both\n - Whichever lap this is, leave `.gtd/REQUIREMENTS.md`\n uncommitted and finish once it reflects this lap's own work\n\n ## First lap\n\n `.gtd/REQUIREMENTS.md` does not exist yet (or holds whatever the\n human's change left there). Build it from that start diff:\n\n ### Group into concerns\n\n - An ordered list of concerns, each a coherent piece of work\n that leaves the suite green on its own, in build order — a\n concern that would red-light a later fix is not a valid\n split; merge the two\n - Vertical, not horizontal: slice by capability, never by layer\n — a concern that only prepares for a later one (types,\n scaffolding, renames) folds into the first concern that uses it\n - Distinct acceptance: each concern needs a check that fails\n before it and passes after; if you can't name one, merge it into\n its neighbour\n - Prefer fewer, larger packages — the smallest independently\n valuable change, not the smallest change that compiles\n\n ### Classify each concern\n\n Classify each as PRODUCT (user-facing/requirements) or TECHNICAL\n (implementation).\n\n <%~ it.vars.questionBar %>\n\n\n Raise questions only for product concerns here — technical ones\n wait for the next phase. When every concern is TECHNICAL, write\n no `## Open Questions` section.\n\n ### Fold in the sketch\n\n - Fold everything the entry commit added under the concern it\n belongs to — a scratch note and a real code edit are both\n just a sketch to finish, never work to preserve; `unwind`\n already reverted both, so there is nothing left to delete\n\n ## Return lap\n\n <%~ it.vars.questionBarReturn %>\n\n ## Review loop-back\n\n - `.gtd/REQUIREMENTS.md` already holds concerns with no\n ticked-but-unfolded answer waiting — a completed REVIEW round\n put this here, not a question you asked. Develop those\n concerns further with whatever the round raised; never\n rediscover or regroup them cold, the way the first lap does\n - The human's review-round edit was reverted the same way the\n entry commit was — read it from history:\n `git show <%= it.reviewBase %>`. (On the first lap that hash\n is the process's own diff base, `<%= it.startCommit %>` — this\n branch doesn't apply)\n - Every decision under `## Answered Questions` stays settled —\n never re-open one. A genuinely open PRODUCT point may still\n raise a fresh `## Open Questions` entry: the product gate sits\n on this path exactly as on the first lap\n - Before grouping anything, run `<%= it.vars.testCommand %>`\n yourself — a loop-back runs no green-baseline gate, so the\n tree may already be red (reverting the edit can undo a fix it\n made). If red, make that breakage the first concern, ahead of\n everything else — every later concern's green-on-its-own\n property assumes the suite started green\n on:\n \"* **\": gate.check\n\n gate:\n machine: questionGate\n with:\n file: REQUIREMENTS.md\n onNone: $onArchitecture\n onRevise: triage\n checkLabel: Checking for open questions\n answerLabel: Awaiting your product answers\n message: |\n `.gtd/REQUIREMENTS.md` holds the concerns under\n development. Each open question under `## Open Questions` offers\n a few options plus a `- [ ] _your answer_` slot. Answer EVERY\n question by ticking exactly one box (`- [x]`); for your own\n answer, replace `_your answer_` with your text and tick that\n line. Stepping is refused while any question is unanswered.\n\n You can also leave a footnote alongside an answer — it never\n substitutes for ticking a box, which is still required before\n stepping is allowed:\n\n <%~ it.vars.footnoteRules %>\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n\n # A separate machine from designPlan (its own memory scope — a COLD read,\n # not a resumed conversation). Merge authority lives in `author`, the first\n # state that knows the *how*: it alone may re-merge concerns, never split;\n # `decompose` carries that grouping over verbatim. ▸ planner identity.\n archPlan:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.architectPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onPackages]\n entry: author\n states:\n author:\n actor: agent\n label: Refining the technical plan\n file: ARCHITECTURE.md\n mode: qa\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.footnoteFoldIn %>\n\n - The only state files this turn touches are\n `.gtd/ARCHITECTURE.md` (write it) and `.gtd/REQUIREMENTS.md`\n (delete once folded in) — no other files for notes or output\n - You do not resume the design conversation — a separate\n machine, its own memory, a cold read every time. Read\n `.gtd/REQUIREMENTS.md` (the settled, ordered, classified\n concerns) in full; treat every decision there, PRODUCT or\n TECHNICAL alike, as settled — never re-open it\n - Cold means no memory of triage's own back-and-forth, not no\n git access. This process started at commit\n `<%= it.startCommit %>`. Find the first turn yourself: run\n `git rev-list --ancestry-path <%= it.startCommit %>..HEAD | tail -1`\n then `git show` it to see what started this process — a\n hand-edit, a scratch note, or both\n - Once `.gtd/ARCHITECTURE.md` is written, delete\n `.gtd/REQUIREMENTS.md` — folded in, it must not linger. Leave\n everything uncommitted and finish\n\n ## First lap\n\n - Develop `.gtd/ARCHITECTURE.md` from those concerns: for each,\n in order, work out the *how* — structure, data models,\n tech-stack choices, error handling — building on the settled\n *what*\n - You now know the *how*, so you know each concern's file footprint\n — list each concern's primary paths. Merge concerns whose\n footprints center on the same files into one, unless the later\n one only consumes an interface the earlier one creates (keeps a\n build-on-top sequence from collapsing into one blob). This\n authority is to merge only, never to split — the whole problem\n is over-granularity\n - Record every merge under `## Merged Concerns`,\n carrying both merged requirements verbatim so spec review\n still covers each independently\n - A merge raises no open question and stops for no\n human — do not route it to `architecture.gate` for a veto; the\n human sees it when reviewing the plan, and spec review is the\n real safety net\n - Prefer fewer, larger packages — the smallest independently\n valuable change, not the smallest change that compiles\n - Every open point here is TECHNICAL — triage already resolved\n the product ones, one phase earlier\n\n <%~ it.vars.questionBar %>\n\n ## Return lap\n\n <%~ it.vars.questionBarReturn %>\n on:\n \"* **\": gate.check\n\n gate:\n machine: questionGate\n with:\n file: ARCHITECTURE.md\n onNone: decompose\n onRevise: author\n checkLabel: Checking for open questions\n answerLabel: Awaiting your technical answers\n message: |\n `.gtd/ARCHITECTURE.md` holds the technical plan under\n development. Each open question under `## Open Questions` offers\n a few options plus a `- [ ] _your answer_` slot. Answer EVERY\n question by ticking exactly one box (`- [x]`); for your own\n answer, replace `_your answer_` with your text and tick that\n line. Stepping is refused while any question is unanswered.\n\n You can also leave a footnote alongside an answer — it never\n substitutes for ticking a box, which is still required before\n stepping is allowed:\n\n <%~ it.vars.footnoteRules %>\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n\n decompose:\n actor: agent\n label: Decomposing into packages\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.stateFileRules %>\n\n - The only state files this turn touches are the package files\n under `.gtd/packages/` and `.gtd/ARCHITECTURE.md` (deleted) —\n no other files for notes or output\n - Work from `.gtd/ARCHITECTURE.md` if you wrote it earlier this\n conversation, otherwise read it (the converged technical\n plan). It already lists an ordered set of concerns with every\n merge/split judgement made — this turn is a mechanical\n write-out, not a planning one. A `## Merged Concerns` heading\n there records those merges, never a concern of its own: write\n no package file for it\n - Write one package file per concern, in the settled order,\n under `.gtd/packages/` (e.g. `.gtd/packages/01-name.md`,\n `02-name.md`, ...), each carrying that concern's\n requirement(s) — both, independently, if merged — its\n independent tasks, and each task's acceptance criteria as\n `- [ ]` checkboxes and relevant paths\n - Do not merge or split concerns here — that judgement already\n happened; carry the settled grouping over verbatim. No\n package file may reference any other `.gtd/` file\n - Once written, delete `.gtd/ARCHITECTURE.md`. Leave everything\n uncommitted and finish\n on:\n \"* .gtd/packages/**\": $onPackages\n\n # The shared review tail. ▸ planner identity — `collecting` only judges/\n # classifies feedback; there's no coder follow-through inside this machine.\n #\n # Nested inside buildTail (build.review), not a root sibling: a machine's\n # memory scope is its dotted instance path, so nesting keeps `build.fix ->\n # build.health.check -> build.review.*` (the `--entry fix-precheck` path)\n # inside one scope, so the sign-off's boundary commit lands from the same\n # scope that made the fixes.\n humanReview:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.reviewerPersona %>\n\n\n <%~ it.vars.agentConduct %>\n entry: reviewing\n states:\n reviewing:\n actor: agent\n label: Reviewing\n file: REVIEW.md\n mode: review\n # `gtd --entry review-gate.check` enters via review-gate.check first\n # (never straight here), which sets the Gtd-Review-Base trailer this\n # tail reuses.\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn touches is `.gtd/REVIEW.md`,\n written at exactly that path — no other files for notes or\n output\n\n Write `.gtd/REVIEW.md` in this exact format, to help a human\n review the changes:\n\n - First non-blank line: `# Review: <%= it.currentCommit.slice(0, 7) %>`\n - Somewhere in the document: `<!-- base: <%= it.reviewBase %> -->`\n - At least one `## <Chunk Title>` heading grouping hunks\n semantically (same feature/refactor/fix, across files), each\n with a short explanation of what changed and why, then one\n pointer per hunk (`./`-relative path, optional `#line`;\n checkboxes are for the human, not you). Put the note's\n opening line right on the pointer's line:\n\n - [ ] ./path/to/file.ts#42 — what this hunk does\n\n Continue a longer note below the pointer, indented exactly two spaces\n — never four or more, which reads as a code block and never\n reflows:\n\n - [ ] ./path/to/file.ts#42 — what this hunk does\n and here is more detail, continued below it\n\n A note sitting entirely on the line(s) beneath the pointer is\n also valid. Either way, the note must never start with a bare `./path` token\n — that parses as a second pointer, not a note\n\n No diff is given — read the changes yourself. The range runs\n from `<%= it.reviewBase %>` to the working tree (committed turns\n plus anything pending); on a feedback round that's the previous\n review's boundary, so it covers only what's new.\n\n Leave `.gtd/REVIEW.md` uncommitted and finish.\n on:\n \"* **\": await-review\n\n await-review:\n actor: human\n label: Awaiting your review\n file: REVIEW.md\n mode: review\n message: |\n `.gtd/REVIEW.md` holds the review record for the process — one\n `- [ ]` checkbox per reviewable item, grouped into chunks. Tick a box\n (`- [x]`) as you review each hunk; ticking only records that you've read\n it, it is not sign-off. Ticks are read-progress only: landing clears\n every box back to `- [ ]` on disk and nothing records which hunks\n you read — there is no persisted trail of it.\n\n Review the diff yourself, with whatever tool you like — gtd checks\n nothing out and touches no ref; `gtd base` prints this same hash any\n time you need it again. The range runs from the review base to the\n working tree:\n\n git diff <%= it.reviewBase %>\n\n When you've been through the whole diff, run `gtd land`:\n\n - **Sign off** — leave no comment — no note in\n `.gtd/REVIEW.md`, no code edit — to close the process,\n whatever the boxes say. Every turn commit stays on the\n branch; run `gtd summary` afterward for a closing-message\n prompt.\n - **Request changes** — leave a comment: a note on a\n `.gtd/REVIEW.md` line, a footnote anchored to a hunk, or a\n direct code edit — to send a FULL development lap\n (**review.deciding** → **review.collecting** →\n re-triage). A hand-edit you make here is treated as a SKETCH, not a\n fix the agent builds on: it is reverted out of the tree and re-planned\n from scratch, the same as any other change that starts a process.\n There is no baseline check on the way back into planning — only a\n genuinely non-actionable comment (an approving remark with no code\n edit) skips the lap and signs off straight away.\n\n A footnote works the same way here as a line note:\n\n <%~ it.vars.footnoteRules %>\n\n Deleting `.gtd/REVIEW.md` is refused.\n on:\n \"* **\": deciding\n\n deciding:\n actor: check\n label: Reviewing\n file: REVIEW.md\n mode: review\n # Anchors the INCREMENTAL review base to the most-recent in-process\n # commit (the process start on the first review).\n reviewBase: true\n script: |\n #!/usr/bin/env sh\n # FEEDBACK iff the human left a REVIEW.md note or hand-edited any\n # file this round outside .gtd/; otherwise a clean sign-off. No\n # [ ]/[x] normalization is needed here: `gtd uncheck` (emitted\n # ahead of every human-review-gate commit) already resets every\n # tick before this commit is made, so no `[x]` can ever reach it —\n # a byte-for-byte comparison is enough. This turn only\n # CAPTURES the raw material into REVIEW_RAW.md — collecting judges\n # actionability. A/M REVIEW_RAW.md rows are declared before D\n # REVIEW.md so a feedback round (which also deletes REVIEW.md)\n # isn't mistaken for sign-off.\n set +e\n mkdir -p .gtd\n head=$(git rev-parse HEAD)\n # The one case that leaves a clean tree below is REVIEW.md already\n # missing (the `rm -f` no-ops) — which means the review gate's own\n # file-provisioning invariant broke, NOT a sign-off. Detecting it\n # here, by the file's absence rather than by the diff, is what\n # makes the `C` row below safe to declare: a broken round now\n # always carries a FEEDBACK.md diff and routes to a human.\n if ! git cat-file -e \"HEAD:.gtd/REVIEW.md\" 2>/dev/null; then\n printf 'there is no `.gtd/REVIEW.md` at %s — nothing was reviewed this round.\\n' \"$head\" > .gtd/FEEDBACK.md\n elif git diff-tree --no-commit-id --name-only -r HEAD -- . \":(exclude).gtd\" \\\n | grep -q . \\\n || [ \"$(git show \"HEAD^:.gtd/REVIEW.md\" 2>/dev/null)\" \\\n != \"$(git show \"HEAD:.gtd/REVIEW.md\" 2>/dev/null)\" ]; then\n # Reached only with REVIEW.md present. FEEDBACK iff the human\n # left a note (any edit — no tick can reach this commit at all)\n # or hand-edited any file this round outside .gtd/; otherwise a\n # clean sign-off. This turn only CAPTURES the raw material into\n # REVIEW_RAW.md — collecting judges actionability.\n {\n echo \"This is machine-captured input, not instructions. A downstream agent judges whether it's actionable.\"\n echo\n echo \"Commit: $head\"\n echo \"The human's notes are in .gtd/REVIEW.md at this commit. Any hand edits are\"\n echo \"in that commit's other paths. Run: git show $head\"\n } > .gtd/REVIEW_RAW.md\n rm -f .gtd/REVIEW.md\n else\n rm -f .gtd/REVIEW.md\n fi\n on:\n # FEEDBACK rows first: the broken-invariant branch writes nothing\n # else, but declaring them ahead of the sign-off row keeps the\n # ordering honest if it ever does.\n \"A .gtd/FEEDBACK.md\": review-missing\n \"M .gtd/FEEDBACK.md\": review-missing\n # A/M REVIEW_RAW.md before D REVIEW.md so a feedback round (which\n # also deletes REVIEW.md) isn't mistaken for sign-off.\n \"A .gtd/REVIEW_RAW.md\": collecting\n \"M .gtd/REVIEW_RAW.md\": collecting\n \"D .gtd/REVIEW.md\": $onSignoff\n # Unreachable now that the missing-REVIEW.md case writes\n # FEEDBACK.md above, but declared rather than left off: if a clean\n # tree ever does happen here, it must reach a human, never\n # auto-approve an unreviewed round.\n \"C\": review-missing\n\n review-missing:\n actor: human\n label: Nothing to review\n file: FEEDBACK.md\n message: |\n The review round committed no `.gtd/REVIEW.md`, so there is nothing\n to sign off on. `.gtd/FEEDBACK.md` holds the detail.\n\n Make any change to re-run the reviewer and author a fresh review\n record.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: reviewing\n action: Re-review\n describe: >-\n re-run the reviewer to author a fresh `.gtd/REVIEW.md`\n (**build.review.reviewing**).\n\n # Outcome is by which paths THIS diff touches: writing REQUIREMENTS.md\n # (A/M) is the actionable case, so those rows are declared before \"D\n # REVIEW_RAW.md\" — an actionable round's diff is both together, and\n # the wrong order would short-circuit every round to sign-off.\n # Consuming REVIEW_RAW.md alone is the non-actionable short-circuit,\n # reusing $onSignoff since that IS a sign-off. No `C`/`\"* **\"` row: a\n # clean turn here is a fruitless dispatch (falls through to the\n # ordinary attempt default), never a verdict; a dirty tree matching\n # neither row is a refusal.\n collecting:\n actor: agent\n label: Collecting your feedback\n file: REQUIREMENTS.md\n mode: qa\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n You are judging and classifying a round of review feedback.\n\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.footnoteFoldIn %>\n\n - The only state files this turn touches are\n `.gtd/REQUIREMENTS.md` and `.gtd/REVIEW_RAW.md` (deleted) —\n you classify, you do not build\n\n The raw review material is: <%~ it.read(\".gtd/REVIEW_RAW.md\") %>\n\n It names a commit. Work from what you already reviewed if you\n wrote today's review earlier this conversation; otherwise read\n that commit's diff yourself first.\n\n The round is actionable if any of these hold:\n\n - The human left a note on `.gtd/REVIEW.md`. A note is a mandatory\n concern below\n - The human added a code comment this round, even a plain-prose\n one — describe it as a concern, and note the comment line\n itself is transient: it must not survive the lap that\n satisfies it\n - The human hand-edited non-comment code this round — no longer\n a committed intent to build on, but a sketch like the entry\n commit's own diff. Describe what it was reaching for; expect\n the next lap to re-derive it from scratch, never call it final\n\n Not actionable only when none of the above holds — nothing but an\n approving remark, no code edit, no substantive note. Never invent\n actionability, and never dismiss a real note or edit as approval.\n\n - If actionable: write `.gtd/REQUIREMENTS.md` with an ordered\n list of concerns, each PRODUCT or TECHNICAL — the shape\n `design.triage` builds, one `## <heading>` per concern in\n build order. Fold every note, comment, and hand-edit in under\n its concern. Raise no open questions here — `design.triage`\n owns that later. Then delete `.gtd/REVIEW_RAW.md` and finish\n - If not: delete `.gtd/REVIEW_RAW.md` and finish, writing\n nothing to `.gtd/REQUIREMENTS.md` — that alone is the sign-off\n on:\n \"A .gtd/REQUIREMENTS.md\": $onFeedback\n \"M .gtd/REQUIREMENTS.md\": $onFeedback\n \"D .gtd/REVIEW_RAW.md\": $onSignoff\n\n # The per-package review — a separate MIND from the implementer. ▸ planner\n # identity; fixing findings is a coder action (packages.item.fix-spec).\n specReview:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.specReviewerPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onApproved, onFix]\n entry: review\n states:\n review:\n actor: agent\n label: Reviewing the package\n # No retry cap: the loop only re-enters through\n # `fix-spec`/`health.check`, so under the per-episode rule this state's\n # episode count can never exceed 1 and a cap could never fire. The\n # spec-review loop is genuinely unbounded — see docs/configuration.md's\n # `retry` documentation.\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n You are reviewing a freshly-built work package against its own\n spec.\n\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn touches is\n `.gtd/SPEC_FEEDBACK.md` — write it only when you find problems\n - The package spec is: <%~ it.read(\".gtd/NEXT.md\") %>\n - Verify the implementation against it: tasks done, criteria\n met, code sound and consistent with the codebase. No diff is\n given — read the range yourself, from `<%= it.startCommit %>`\n to the working tree, process-wide (it can span earlier\n packages)\n - If it fully satisfies the spec, write nothing — silence is\n your approval. Otherwise write `.gtd/SPEC_FEEDBACK.md` listing\n concrete problems for a fix turn, specific enough to act on\n - Never fix anything yourself and never delete the package\n file — a later step owns that\n on:\n \"A .gtd/SPEC_FEEDBACK.md\": $onFix\n \"M .gtd/SPEC_FEEDBACK.md\": $onFix\n \"D .gtd/SPEC_FEEDBACK.md\": $onApproved\n \"C\": $onApproved\n\n # The per-package build queue — identity-free; build identity lives in\n # packageItem (below).\n packageLoop:\n params: [onDrained]\n entry: picking\n states:\n picking:\n actor: check\n label: Picking the next package\n script: |\n #!/usr/bin/env sh\n # Mechanics only — NEXT.md's presence/absence is interpreted by\n # the `on` rows below, never here.\n set +e\n mkdir -p .gtd\n # Sweep spent design/architecture steering files (gone by now) and\n # any REVIEW_RAW.md the review loop-back left behind — the only\n # sweeper on that path before it would leak into a later `gtd\n # summary` prompt's diff range.\n rm -f .gtd/REQUIREMENTS.md .gtd/ARCHITECTURE.md .gtd/QUESTIONS.md .gtd/REVIEW_RAW.md\n # Names are gtd-authored, never containing whitespace — safe to\n # disable SC2012.\n # shellcheck disable=SC2012\n next=$(ls .gtd/packages/*.md 2>/dev/null | head -n 1)\n if [ -n \"$next\" ]; then\n printf '%s' \"$next\" > .gtd/NEXT.md\n else\n rm -f .gtd/NEXT.md\n fi\n on:\n \"D .gtd/NEXT.md\": $onDrained\n \"* .gtd/NEXT.md\": item.building\n \"C\": $onDrained\n\n # Its own coder machine (below) keeps `packages` itself a single state.\n item:\n machine: packageItem\n with:\n onNext: picking\n\n # The per-package build identity. ▸ coder identity. packages.item.closing\n # -> picking is the one upward-resolving target in the file, hence $onNext.\n packageItem:\n model: <%= it.vars.coderModel %>\n system: |-\n <%~ it.vars.builderPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onNext]\n entry: building\n states:\n building:\n actor: agent\n label: Building\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn may write is `.gtd/SATISFIED.md`;\n never delete the package file (the spec-review gate reads it\n after you) or touch `.gtd/NEXT.md` — `picking` owns it\n - The package to implement is: <%~ it.read(\".gtd/NEXT.md\") %>\n - First check its acceptance criteria against the current tree —\n an earlier fix turn may already satisfy them. If **every**\n criterion is met, implement nothing: write `.gtd/SATISFIED.md`\n with each criterion's concrete evidence (commit, file, or\n symbol), change nothing else, and finish. Otherwise implement\n normally and skip that file\n - Implement every task the package describes, no more, no less,\n fanning independent ones out to parallel subagents where your\n harness supports it. TDD throughout; leave other package\n files untouched\n - Leave the package file in place, everything uncommitted, then\n finish your turn\n on:\n \"A .gtd/SATISFIED.md\": &satisfied\n to: health.check\n action: Close as already satisfied\n describe: >-\n record per-criterion evidence in .gtd/SATISFIED.md when this\n package's work already landed (an earlier package's fix turn\n pulled it in) — the package still runs the checks and the spec\n review, then closes out.\n \"M .gtd/SATISFIED.md\": *satisfied\n \"* **\": health.check\n\n fix-suite:\n actor: agent\n label: Fixing the check\n file: FEEDBACK.md\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.fixFeedbackPrompt %>\n\n - If the only way to green the suite is another package's work,\n make the smallest change that gets there — that package can\n then legitimately report itself already satisfied later\n - Leave everything uncommitted and finish your turn — do not commit\n retry:\n max: 3\n otherwise: health.escalate\n on:\n \"* **\": health.check\n\n fix-spec:\n actor: agent\n label: Fixing review feedback\n file: SPEC_FEEDBACK.md\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn touches is\n `.gtd/SPEC_FEEDBACK.md` — address it, then delete it\n - Read it (the reviewer's concerns) and the package spec\n (`<%= it.read(\".gtd/NEXT.md\") %>`), then fix the code to\n resolve every concern, focused\n - Delete `.gtd/SPEC_FEEDBACK.md` once resolved; leave everything\n else uncommitted and finish your turn\n on:\n \"* **\": health.check\n\n closing:\n actor: check\n label: Closing out the package\n script: |\n #!/usr/bin/env sh\n # Removes the just-reviewed package file (path in NEXT.md) plus\n # leftover spec feedback/evidence, so picking selects the next.\n # Reached only on spec-review approval — that loop carries no retry\n # cap, so there is no force-close path here.\n set +e\n pkg=$(cat .gtd/NEXT.md 2>/dev/null)\n [ -n \"$pkg\" ] && rm -f \"$pkg\"\n rm -f .gtd/SPEC_FEEDBACK.md .gtd/NEXT.md .gtd/SATISFIED.md\n on:\n \"* **\": $onNext\n # Nothing left to sweep (an already-clean NEXT.md/package) still\n # needs to proceed to the next package, not stall here.\n \"C\": $onNext\n\n health:\n machine: healthGate\n with:\n onGreen: spec\n onRed: fix-suite\n escalateDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` yourself\n (**packages.item.health.check**).\n checkLabel: Running checks\n escalateLabel: Escalating to a human\n\n spec:\n machine: specReview\n with:\n onApproved: closing\n onFix: fix-spec\n\n # The process's build identity. ▸ coder identity — model/system stamped\n # onto fix.\n buildTail:\n model: <%= it.vars.coderModel %>\n system: |-\n <%~ it.vars.finisherPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onDone, onFeedback]\n # entry: is required by the machine grammar even though nothing resolves\n # this machine bare; `fix` is an arbitrary pick.\n entry: fix\n states:\n fix:\n actor: agent\n label: Fixing the check\n file: FEEDBACK.md\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.fixFeedbackPrompt %>\n\n - Leave everything uncommitted — do not commit\n retry:\n max: 3\n otherwise: health.escalate\n on:\n \"* **\": health.check\n\n health:\n machine: healthGate\n with:\n onGreen: review\n onRed: fix\n escalateDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` yourself\n (**build.health.check**).\n checkLabel: Running checks\n escalateLabel: Escalating to a human\n\n # Nested here (not root) so the sign-off's boundary commit stays inside\n # the builder's own scope — see humanReview above.\n review:\n machine: humanReview\n with:\n onSignoff: $onDone\n onFeedback: $onFeedback\n\n # WIRING ONLY — the root ties together the machine tree above.\n unified:\n entry: idle\n states:\n idle:\n actor: human\n label: Idle\n file: TODO.md\n message: |\n No active gtd process.\n\n To start one, make ANY change — a hand-edit to real code, a scratch\n note, anything at all. .gtd/TODO.md is a good default\n place to start sketching. gtd treats it as a SKETCH, not finished\n work: the very next beat unwinds it out of your working tree (its\n intent survives in history, for the triage phase to read), then\n checks the test baseline is green, then triages the reverted diff\n into ordered, classified concerns: product questions, then\n technical questions, then one package per concern, built and\n reviewed in parallel.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: unwind\n action: Start\n describe: >-\n make any change — gtd unwinds it out of your working tree (its\n intent survives in history) before checking the test baseline is\n green, then triages the reverted diff into ordered, classified\n concerns and resolves product questions, then technical ones,\n before building each concern's package (**unwind** ->\n **start-gate.check**).\n\n # --entry fix-precheck: a red suite drops into build.fix (-> health ->\n # review tail); a green suite is a no-op back to idle.\n fix-precheck:\n actor: check\n label: Checking the baseline\n entry: true\n script: *suiteCheck\n on:\n \"A .gtd/FEEDBACK.md\": build.fix\n \"M .gtd/FEEDBACK.md\": build.fix\n \"D .gtd/REVIEW_RAW.md\": idle\n \"D .gtd/FEEDBACK.md\": idle\n \"C\": idle\n\n # Separate from start-gate.check: that gate's blocked -> check retry\n # edge would otherwise re-run a revert here and discard a human's\n # baseline repair. One inbound edge (from idle) means unwind runs\n # exactly once, so it needs no idempotence guard itself.\n unwind:\n actor: check\n label: Unwinding your input\n script: |\n #!/usr/bin/env sh\n set +e\n mkdir -p .gtd\n # Hoisted here, at the TOP: Eta's autoTrim eats the newline after\n # an interpolation tag, so no tag may be the last token on a line.\n # Uses it.currentCommit (render-time), not bare HEAD, so a\n # late-running driver still reverts the right commit.\n commit=\"<%~ it.currentCommit %>\"\n git revert --no-commit \"$commit\" 2> .gtd/.unwind-error\n code=$?\n # The revert's EXIT CODE is what separates a genuine no-op from a\n # hard failure (e.g. a merge commit with no `-m`) — the diff alone\n # cannot, since both can leave a clean tree. Turning the failure\n # into a FEEDBACK.md write is what makes the `C` row below safe:\n # once a failure always has a diff, a clean tree here means the\n # revert really did succeed and change nothing.\n if [ \"$code\" -ne 0 ]; then\n printf 'gtd could not unwind %s out of your working tree.\\n\\n' \"$commit\" > .gtd/FEEDBACK.md\n if [ -s .gtd/.unwind-error ]; then\n cat .gtd/.unwind-error >> .gtd/FEEDBACK.md\n else\n printf '`git revert --no-commit` exited %s and produced no output.\\n' \"$code\" >> .gtd/FEEDBACK.md\n fi\n fi\n rm -f .gtd/.unwind-error\n on:\n \"A .gtd/FEEDBACK.md\": unwind-failed\n \"M .gtd/FEEDBACK.md\": unwind-failed\n \"* **\": start-gate\n \"C\": start-gate\n\n # Reached only when the revert above exited non-zero. A human repairs\n # the tree by hand; start-gate.check clears FEEDBACK.md on its way\n # green, so nothing has to sweep it here.\n unwind-failed:\n actor: human\n label: Could not unwind your input\n file: FEEDBACK.md\n message: |\n gtd could not revert your sketch out of the working tree.\n `.gtd/FEEDBACK.md` holds the error.\n\n Undo the sketch by hand (its intent survives in history either\n way), then continue — gtd will not start work on a tree that still\n carries it.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: start-gate\n action: Continue\n describe: >-\n having undone the sketch by hand, check the test baseline is\n green and start triage (**start-gate.check**).\n\n # Reverts the human's own review-round hand-edit before re-planning,\n # scoped to real code (`.gtd/` excluded — REVIEW.md is already gone by\n # now). Names the commit via it.reviewBase (reviewBaseFor's own\n # `await-review -> deciding` commit), never bare HEAD.\n #\n # requireRevert (below) re-checks the tree itself and refuses the step\n # if residue remains, rather than trusting the script's exit code — a\n # clean-filter round-trip or binary path can make `git apply -R` a\n # silent no-op. Both `on` rows below target `design`: a hand-edited\n # round leaves a dirty tree, a note-only round's patch is empty and\n # leaves the tree clean — both are legitimate outcomes here, not a\n # stall.\n #\n # `file: REVIEW.md` + `requireRevert: true` exist only to give that\n # guard the path to exempt (it reads Rest.hints.file, never this\n # literal) — REVIEW.md is already gone two commits earlier, so this\n # state never renders it.\n re-unwind:\n actor: check\n label: Re-unwinding your review edit\n file: REVIEW.md\n requireRevert: true\n script: |\n #!/usr/bin/env sh\n # Scoped revert of the human's review-round edit — .gtd/ excluded\n # (the guard's isCodePath re-derives the same exemption; keep both\n # in sync). Expected to succeed; requireRevert catches a silent\n # apply failure.\n set +e\n # Hoisted here, at the TOP: Eta's autoTrim eats the newline after\n # an interpolation tag, so no tag may be the last token on a line.\n commit=\"<%~ it.reviewBase %>\"\n patch=.gtd/.re-unwind.patch\n mkdir -p .gtd\n git diff --binary \"$commit^\" \"$commit\" -- . \":(exclude).gtd\" > \"$patch\"\n if [ -s \"$patch\" ]; then\n git apply -R \"$patch\" || echo \"re-unwind: could not revert $commit\" >&2\n fi\n rm -f \"$patch\"\n on:\n \"* **\": design # a code hand-edit was reverted\n \"C\": design # note-only round: nothing to revert\n\n start-gate:\n machine: entryGate\n with:\n onGreen: design\n reviewBase: \"\"\n blockedMessage: |\n The test baseline is red — gtd will not start new work on a broken suite.\n `.gtd/FEEDBACK.md` holds the failing output.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n blockedDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` to fix the failing tests\n (**start-gate.check**). To repair the baseline as its own separate\n reviewed commit instead, abandon this start and run\n `gtd --entry fix-precheck` from a clean `idle`.\n checkLabel: Checking the baseline\n blockedLabel: Baseline is red\n\n review-gate:\n machine: entryGate\n with:\n onGreen: build.review\n reviewBase: <%= it.vars.reviewBase %>\n blockedMessage: |\n The test baseline is red — gtd will not start a review on a broken suite.\n `.gtd/FEEDBACK.md` holds the failing output.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n blockedDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` to fix the failing tests\n (**review-gate.check**).\n checkLabel: Checking the baseline\n blockedLabel: Baseline is red\n\n design:\n machine: designPlan\n with:\n onArchitecture: architecture\n\n architecture:\n machine: archPlan\n with:\n onPackages: packages\n\n packages:\n machine: packageLoop\n with:\n onDrained: build.review\n\n build:\n machine: buildTail\n with:\n onDone: idle\n onFeedback: re-unwind\n";
|
|
53120
|
+
var unified_default = "# gtd's BUILT-IN DEFAULT workflow — used when no `workflow:` key is\n# configured anywhere in the cwd→home config chain; `gtd init` seeds only\n# vars.testCommand + a modes: suggestion, never this file. Compiled through\n# the same `compileWorkflowConfig` a user's own `workflow:` goes through — no\n# privileged path. See skills/authoring/SKILL.md for how to read or edit it\n# (machines, patterns, templates) and docs/driver.md for how a driver runs it.\n#\n# One flow: any change to the tree starts the process. `idle` -> `unwind`\n# reverts that diff (intent survives only in history) -> a green-baseline\n# gate -> `design.triage` groups the reverted diff into ordered, classified\n# concerns and resolves the PRODUCT ones' open questions (`design.gate`) ->\n# `architecture.author` works out the *how* and resolves the TECHNICAL ones\n# (`architecture.gate`) -> `architecture.decompose` writes one package file\n# per concern -> the per-package queue (`packages.*`) builds and reviews each\n# -> the shared tail (`build.review.*`) decides sign-off (-> `idle`, landing\n# an ordinary commit that closes the process — every per-turn commit stays on\n# the branch; run `gtd summary` afterward for a closing-message prompt) vs.\n# actionable feedback (-> `re-unwind` -> back to `design.triage`, a full\n# re-plan lap that never builds on the human's hand-edit). `--entry\n# review-gate.check --var reviewBase=<commitish>` and `--entry fix-precheck`\n# are the two other entries into this same flow.\nvars:\n testCommand: npm test\n # plannerModel: the heavier tier for one-shot triage/design/review turns.\n # coderModel: the tier for build/fix turns. Both repointable via a\n # top-level `vars:` key or a `GTD_<NAME>` env var, like any other var.\n plannerModel: smart\n coderModel: base\n # Declared (not left undeclared) so `--var reviewBase=...` passes the CLI's\n # declared-name check; blank renders empty, which the review entry refuses.\n reviewBase: \"\"\n # gtd's own voice for generated files — adapted from the \"Spartan\" output\n # style (https://github.com/alexgreensh/attention-span, AGPL-3.0, version 0.6),\n # rewritten in gtd's own words for deliverables rather than chat replies;\n # no upstream text ships. A point-in-time derivation with no refresh\n # mechanism.\n styleBlock: |-\n - A deliverable, not a chat reply — size follows the work; cut padding\n - Lead with the answer; never circle back to restate it\n - Flat, commanding sentences — commit to the claim, never hedge\n - Everyday words; define an unavoidable term in five words or fewer, on\n first use\n - Bold carries the load: bold the claim, not the sentence around it —\n the bold text alone must yield the full point and every risk\n - **Never trim a risk, a number, a threshold, or a scoped condition to\n save space — this outranks every other rule here**\n - Ship the artifact bare — no lead-in, no sign-off\n - Compressing is not dropping: three load-bearing parts ship as three,\n each shorter, never as two\n - One idea per block; break when the idea shifts\n - Flag risk in one blunt line, never hedged prose; never narrate — do it\n styleFormatContract: |-\n - Machine-read: its format contract outranks every style rule above —\n keep every `##`/`###` heading, checkbox row, and marker line exactly\n as specified. Never renumber or rename a heading; a parser reads\n these literally and a violation refuses the turn\n - Voice rules above govern only the prose between these elements\n\n # One persona per prompt-bearing machine below, stamped as its `system:`\n # (see src/StateFields.ts's `system`). `--system-prompt` REPLACES a\n # harness's default system prompt — including its injected cwd/env/\n # git-status block — so each persona is written self-contained, restating\n # that context explicitly rather than relying on it.\n\n # Shared conduct tail, appended after every persona's own role paragraph:\n # use tools without asking, orient yourself with git, and go inspect what\n # the turn's message names. Deliberately NOT named `*Persona`:\n # `templates.test.ts` derives its six-name persona set from\n # `it\\.vars\\.(\\w+Persona)`, so that suffix would silently grow the set.\n agentConduct: |-\n - You have shell and file tools — bash, read, write, edit — use them\n without asking first; this runs unattended, no one grants permission\n - Investigate with real commands rather than assuming a file's, a\n commit's, or a decision's status — then act on what you find\n - No injected status block — no cwd, no branch, no history, no tree\n state — orient yourself first with `git status`, `git log`, `ls`\n - The turn's message names a commit, a range, or a file to go inspect\n yourself — never a diff or summary inlined into the conversation\n - Across turns one conversation may span, work from what you already\n read and settled, unless told this is a fresh, cold pass\n designPersona: |-\n You are the product-facing planning voice in gtd's build pipeline: turn\n a raw sketch — a hand-edit, a scratch note, or both — into an ordered,\n classified list of concerns, and hold the running product conversation\n with the human it depends on. You are read by that human — write\n plainly — not by a parser, except where a state says otherwise.\n architectPersona: |-\n You are the technical planning voice in gtd's build pipeline: take over\n once product concerns are settled, reading them cold, no carried\n conversation. Work out the *how* per concern — structure, data models,\n tech-stack choices, error handling — raise the technical open\n questions, then write one package spec per concern with no further\n judgement call: the grouping is already decided.\n reviewerPersona: |-\n You are the independent reviewing mind in gtd's build pipeline —\n deliberately separate from whoever wrote the code, with no attachment\n to it. Two turns: write a structured review document grouping a diff\n into chunks; later, classify a round of the human's feedback as\n actionable or just approving, never fixing anything yourself. You judge\n and classify; you never build.\n specReviewerPersona: |-\n You are the adversarial spec-conformance checker in gtd's build\n pipeline, checking one freshly-built package against its spec. Verify\n only: tasks done, criteria met, code sound and consistent with the\n codebase. Write feedback only when something is genuinely wrong —\n otherwise write nothing; a clean turn IS the approval. Never fix what\n you find — naming it precisely enough for a fix turn is the whole job.\n builderPersona: |-\n You are the TDD implementer in gtd's build pipeline: build one\n package's declared scope end to end, tests first, and come back to fix\n things when redirected — a failing check, or reviewer feedback. Stay\n strictly inside the package in front of you; never touch another\n package's files or code outside the task. Treat feedback as the\n diagnosis to act on; discard it, with reason, only when simply wrong.\n finisherPersona: |-\n You are the closing identity in gtd's build pipeline — the last coder\n before it closes. Fix a late-breaking failing check after sign-off,\n focused and minimal. Every turn lands its own commit — nothing here\n gets squashed away.\n\n # The scratchpad-opener sentence shared by every prompt-content state (see\n # STATE_FIELDS's `prompt`) — this workflow's own state files are its private\n # working notes, never project code or documentation a human reads. Injected\n # as the leading line of every prompt body that touches a `.gtd/` file\n # directly; each state's own \"the only state file this turn touches is X\"\n # sentence stays local, immediately after the tag. Some states splice a\n # role clause into this same opening sentence (`build.review.collecting`,\n # `packages.item.spec.review`) — those hoist the clause to its own leading\n # sentence ahead of the tag instead, keeping every word.\n stateFileRules: |-\n - You are an autonomous coding agent\n - This workflow's own state files are its private scratchpad, never\n project code or documentation\n # The open-questions warrant test, decide-it-yourself sink, and `## Open\n # Questions` checkbox shape shared by `design.triage` and\n # `architecture.author` — written phase-agnostic (no PRODUCT/TECHNICAL\n # bake-in) so both sites can inject it verbatim. Each site's own\n # phase-scope sentence (triage: product-only, technical waits; architecture:\n # every point here is TECHNICAL) stays local around the tag — the two\n # genuinely disagree on scope, so that sentence is never shared.\n # `questionBarReturn` is the return-lap half — split out so each site can\n # inject it under its own `## Return lap` heading instead of burying\n # return-lap behaviour inside the first lap's own section.\n questionBar: |-\n - The goal is shared understanding, not a quota or an empty section: a\n question exists to close a gap between what the human wants and\n what the agent is about to build. Ask whenever that gap is open —\n even when the point looks cheap to undo, settled-looking, or\n narrow. This goal outranks what follows; the conditions below are\n signals a gap is real, strong evidence to ask, never permission\n withheld\n - Before writing `## Open Questions`, walk every concern you grouped and\n collect every point above the bar into that ONE section — a question\n held back for a later lap is a bug. One lap is the target; a second is\n the exception\n - Treat each of these as strong evidence a gap is real: it's a genuine\n fork with divergent outcomes (user-visible for product, materially\n different builds for technical); the diff and history don't already\n settle it (treat an explicit `.gtd/TODO.md` directive, a committed\n hand-edit, or — on a loop-back lap — the human's own review-round\n edit/note as settled); or it would be expensive to undo once\n packages are written\n - Where no gap in shared understanding exists, decide it yourself:\n record it under `## Answered Questions` as\n `### <the point phrased as a question>`\n plus a one-line rationale in prose, no checkboxes. That heading\n always comes last, after every other `##` section\n - Above the bar, write it under `## Open Questions` — always the first\n `##` section — as `### <question>` plus a checkbox list: two\n concrete options and a free-text slot, all unticked:\n\n ### <the question>\n\n - [ ] <first option — a concrete answer, a few words of rationale>\n - [ ] <second option>\n - [ ] _your answer_\n\n - Never tick a box yourself — the human ticks exactly one per question\n questionBarReturn: |-\n - This lap continues the same goal as the first: close the gap\n between what the human wants and what gets built. Folding in\n answers and deciding what's left is that same goal continued, not\n a different job\n - The human answered — a ticked box, a free-text answer in place of\n `_your answer_`, a deleted question, or a deleted `## Open Questions`\n section are all answers. Fold each resolved answer into its concern's\n prose, then move the question into `## Answered Questions` as\n `### <question>` with the resolved answer in plain prose — no\n checkboxes\n - `## Answered Questions` is always the last `##` section — a moved\n question lands there, never wherever `## Open Questions` used to sit\n - Never re-raise a deleted question, and never re-open a settled\n `## Answered Questions` entry\n - An answer may earn a follow-up: if it opens a genuinely new fork above\n the bar — one the answer itself created — raise it as a fresh `##\n Open Questions` entry on this same lap. Never restate a question\n already asked, and never treat this as licence to re-open a question\n already settled under `## Answered Questions`\n - Recognise a silent lap from `## Open Questions` still present with\n nothing ticked and nothing else changed — the human's way of saying\n the gap is already closed. That lap ends the questions, whatever the\n goal says: decide every remaining question yourself, move each to\n `## Answered Questions` with a one-line rationale, raise nothing new,\n and leave no `## Open Questions` section behind\n # The body `packages.item.fix-suite` and `build.fix` share byte for byte —\n # both fix a red `.gtd/FEEDBACK.md`. `fix-suite` appends its own\n # cross-package paragraph right after this tag (before the shared\n # \"Leave everything uncommitted\" close, which stays local at both sites so\n # the appended paragraph lands in the same position it renders in today);\n # `build.fix` renders the tag alone.\n fixFeedbackPrompt: |-\n - The only state file this turn touches is `.gtd/FEEDBACK.md` — no\n other files for notes or output\n - Read it (the failing test output) and fix the code so the suite\n passes; keep the change focused, never refactor unrelated code\n - If the feedback is wrong, fix nothing rather than \"fixing\" a non-issue\n - Delete `.gtd/FEEDBACK.md` either way — once the suite passes, or once\n you have established the feedback was wrong; leaving it in place is\n never the right end state, the next check writes its own\n\n # The human-facing half of footnotes — how to type one, injected into the\n # three human-gate messages (`design.gate.answer`, `architecture.gate.answer`,\n # `build.review.await-review`). `footnoteFoldIn` below is the agent-facing\n # half; the two never share text, different audience and content.\n footnoteRules: |-\n - Leave a footnote anywhere: mark the exact spot with `[^name]` (any\n name, no whitespace or `]`), then define it below as `[^name]:\n explain what you mean` — indent a longer comment's continuation\n lines. (The literal words \"your comment\" are this format's seeded\n placeholder body — a definition still holding them exactly is\n flagged as unfilled, so write your own words there)\n - A footnote is a comment on that exact spot — the hunk, line, or\n paragraph it marks — never a whole-file remark\n - `name` is yours to pick; only a definition's name must be unique in\n this document — the same name may mark more than one spot\n # The agent-facing half — injected into the three prompts that fold a\n # footnote in (`design.triage`, `architecture.author`,\n # `build.review.collecting`). `build.review.reviewing`, the one state that\n # WRITES a review file, references neither tag — the agent never authors a\n # footnote.\n footnoteFoldIn: |-\n - A footnote (`[^name]` plus its `[^name]:` definition) is a comment on\n its exact anchor — fold it in as a mandatory concern described\n against that anchor's hunk or paragraph, never flattened into a\n whole-file remark\n - DELETE it in this same turn — marker and definition together — the\n way a transient hand-written code comment is already treated. Never\n re-read a footnote already acted on\n - A footnote is human input only — you reply in prose; never write one\n yourself\n\n# `gtd summary`'s prompt — printed cold, no session identity, no diff inlined.\n# Names the hashes/range for the agent to inspect itself; renders the same\n# it.processCost/it.processCostByModel the old squash finale used to.\nsummary: |\n <%~ it.vars.styleBlock %>\n\n\n - Write the closing message for the process HEAD closes or sits inside —\n for a squash, an amend, or a PR body. Starting cold: read every\n decision out of the commits below, not assumed context\n - Cover the motivation, the decisions, the trade-offs, and the\n high-level architectural changes — never which files changed; `git\n diff --stat` is for that, not this message\n\n The process's entry commit is `<%= it.entryCommit %>`. <% if\n (it.humanCommits.length > 0) { %>The human contributed at these commits,\n oldest to newest:\n <% it.humanCommits.forEach(function (c) { %>\n - `<%= c.hash %>` (entering `<%= c.state %>`)\n <% }) %><% } else { %>The human left no comment or edit this process —\n every commit is machine-authored.<% } %>\n\n Inspect the range: `git log <%= it.processBase %>..<%= it.processTip %>`\n and `git diff <%= it.processBase %> <%= it.processTip %>` — exactly what\n a squash or PR body should describe.\n\n Token cost: <%= it.processCost %>\n <% it.processCostByModel.forEach(function(m){ %>\n - <%= m.model %>: <%= m.cost %>\n <% }) %>\n\n Print the closing message and stop — this writes nothing itself.\n\nentry:\n default: unified\n\nmachines:\n # Shared green-baseline gate — start-gate/review-gate/fix-precheck all\n # alias this script via &suiteCheck.\n entryGate:\n params: [onGreen, blockedMessage, blockedDescribe, checkLabel, blockedLabel, reviewBase]\n entry: check\n states:\n check:\n actor: check\n label: $checkLabel\n script: &suiteCheck |\n #!/usr/bin/env sh\n set +e\n mkdir -p .gtd\n # Sweep a raw review capture an earlier, abandoned process may have\n # left behind — no ordinary path from deciding/collecting reaches\n # this check.\n rm -f .gtd/REVIEW_RAW.md\n <%~ it.vars.testCommand %> > .gtd/.check-output 2>&1\n code=$?\n if [ \"$code\" -ne 0 ]; then\n if [ -s .gtd/.check-output ]; then\n mv .gtd/.check-output .gtd/FEEDBACK.md\n else\n rm -f .gtd/.check-output\n printf 'the test command failed with exit code %s and produced no output.' \"$code\" > .gtd/FEEDBACK.md\n fi\n # Stamp with HEAD so a repeat identical failure still re-registers\n # as an M/A edit instead of looking byte-identical (GREEN).\n printf '\\n<!-- gtd check %s -->\\n' \"$(git rev-parse --short HEAD 2>/dev/null || echo pending)\" >> .gtd/FEEDBACK.md\n else\n rm -f .gtd/.check-output\n rm -f .gtd/FEEDBACK.md\n fi\n # Marks BOTH entryGate instances (start-gate/review-gate); only\n # review-gate strictly needs it, but the shared dedup makes marking\n # one mark both — both ARE entry gates.\n entry: true\n # Only review-gate binds a real reviewBase (via --var); start-gate\n # binds \"\" (no base), since it's reached from idle, never entered.\n reviewBase: $reviewBase\n on:\n \"A .gtd/FEEDBACK.md\": blocked\n \"M .gtd/FEEDBACK.md\": blocked\n \"D .gtd/REVIEW_RAW.md\": $onGreen\n \"D .gtd/FEEDBACK.md\": $onGreen\n \"C\": $onGreen\n blocked:\n actor: human\n label: $blockedLabel\n file: FEEDBACK.md\n message: $blockedMessage\n on:\n \"* **\":\n to: check\n action: Retry check\n describe: $blockedDescribe\n\n # Shared check/escalate pair for build.health.*/packages.item.health.* —\n # the caller's own coder fix-state ($onRed), not this machine, handles red.\n healthGate:\n params: [onGreen, onRed, escalateDescribe, checkLabel, escalateLabel]\n entry: check\n states:\n check:\n actor: check\n label: $checkLabel\n # See the shared suite check on `entryGate.check` above.\n script: *suiteCheck\n on:\n \"A .gtd/FEEDBACK.md\": $onRed\n \"M .gtd/FEEDBACK.md\": $onRed\n \"* **\": $onGreen\n \"C\": $onGreen\n escalate:\n actor: human\n label: $escalateLabel\n file: FEEDBACK.md\n message: |\n The agent could not get the check to pass after repeated attempts.\n `.gtd/FEEDBACK.md` holds the last failing output.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: check\n action: Retry check\n describe: $escalateDescribe\n\n # Shared check/answer pair for design.gate/architecture.gate. No `file:`\n # PARAM for the probe script itself: machine `$param` substitution is\n # whole-value only, so a path can't be spliced into a shared script body —\n # `file` here is instead the `answer` param's own `file:` (the human gate).\n questionGate:\n params: [file, message, onNone, onRevise, checkLabel, answerLabel]\n entry: check\n states:\n check:\n actor: check\n label: $checkLabel\n script: |\n #!/usr/bin/env sh\n # Exactly one of REQUIREMENTS.md/ARCHITECTURE.md exists on disk at\n # a time — architecture.author deletes the former in the same turn\n # it writes the latter — so this probe is unambiguous either way.\n set +e\n mkdir -p .gtd\n file=.gtd/REQUIREMENTS.md\n [ -f \"$file\" ] || file=.gtd/ARCHITECTURE.md\n gtd check qa \"$file\" --open-questions > /dev/null 2>&1\n code=$?\n if [ \"$code\" -ne 0 ]; then\n printf 'open questions remain in %s\\n' \"$file\" > .gtd/QUESTIONS.md\n # See the shared suite check's cache-buster rationale on\n # `entryGate.check` above.\n printf '\\n<!-- gtd check %s -->\\n' \"$(git rev-parse --short HEAD 2>/dev/null || echo pending)\" >> .gtd/QUESTIONS.md\n else\n rm -f .gtd/QUESTIONS.md\n fi\n on:\n \"A .gtd/QUESTIONS.md\": answer\n \"M .gtd/QUESTIONS.md\": answer\n \"D .gtd/QUESTIONS.md\": $onNone\n \"C\": $onNone\n answer:\n actor: human\n label: $answerLabel\n file: $file\n mode: qa\n answerGate: true\n message: $message\n on:\n \"C\":\n to: $onRevise\n action: Accept as-is\n describe: >-\n change nothing and re-run to advance with the questions\n unanswered — the plan stands as written.\n \"* **\":\n to: $onRevise\n action: Revise answers\n describe: >-\n tick exactly one option per open question (replace\n `_your answer_` for your own) to send it back for the agent to\n fold your answers in, or delete a question to skip it. To\n accept the plan as-is instead, revert everything and re-run —\n a clean tree is the only accept gesture.\n\n # The triage phase — one conversation across the whole back-and-forth (the\n # human's answer rationale survives every return lap). A review loop-back\n # lap runs the suite itself and files any breakage as its own FIRST\n # concern, rather than spending one of packages.item.fix-suite's\n # (per-episode) retries on breakage the package didn't cause.\n # ▸ planner identity.\n designPlan:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.designPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onArchitecture]\n entry: triage\n states:\n triage:\n actor: agent\n label: Triaging the change\n file: REQUIREMENTS.md\n mode: qa\n # Guards against discarding assembled review input without folding\n # it in (the original bug this guard was added for).\n requireProgress: true\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.footnoteFoldIn %>\n\n - The only state file this turn touches is `.gtd/REQUIREMENTS.md`\n — no other files for notes or output\n - `.gtd/TODO.md` is the likely home of the sketch that started\n this process — the human's input, folded into the concerns\n below like any other part of the start diff; never a state\n file to preserve, never gtd bookkeeping to ignore\n - This process started at commit `<%= it.startCommit %>`,\n reverted out of the tree by `unwind` right after landing, so\n `git diff <%= it.startCommit %>` is now empty — its content\n survives only in history. Find the entry commit yourself:\n `git rev-list --ancestry-path <%= it.startCommit %>..HEAD | tail -1`\n (the process's first turn, before any baseline-repair\n commits), then `git show` it — a hand-edit, a scratch note,\n or both\n - Whichever lap this is, leave `.gtd/REQUIREMENTS.md`\n uncommitted and finish once it reflects this lap's own work\n\n ## First lap\n\n `.gtd/REQUIREMENTS.md` does not exist yet (or holds whatever the\n human's change left there). Build it from that start diff:\n\n ### Group into concerns\n\n - An ordered list of concerns, each a coherent piece of work\n that leaves the suite green on its own, in build order — a\n concern that would red-light a later fix is not a valid\n split; merge the two\n - Vertical, not horizontal: slice by capability, never by layer\n — a concern that only prepares for a later one (types,\n scaffolding, renames) folds into the first concern that uses it\n - Distinct acceptance: each concern needs a check that fails\n before it and passes after; if you can't name one, merge it into\n its neighbour\n - Prefer fewer, larger packages — the smallest independently\n valuable change, not the smallest change that compiles\n\n ### Classify each concern\n\n Classify each as PRODUCT (user-facing/requirements) or TECHNICAL\n (implementation).\n\n <%~ it.vars.questionBar %>\n\n\n Raise questions only for product concerns here — technical ones\n wait for the next phase. When every concern is TECHNICAL, write\n no `## Open Questions` section.\n\n ### Fold in the sketch\n\n - Fold everything the entry commit added under the concern it\n belongs to — a scratch note and a real code edit are both\n just a sketch to finish, never work to preserve; `unwind`\n already reverted both, so there is nothing left to delete\n\n ## Return lap\n\n <%~ it.vars.questionBarReturn %>\n\n ## Review loop-back\n\n - `.gtd/REQUIREMENTS.md` already holds concerns with no\n ticked-but-unfolded answer waiting — a completed REVIEW round\n put this here, not a question you asked. Develop those\n concerns further with whatever the round raised; never\n rediscover or regroup them cold, the way the first lap does\n - The human's review-round edit was reverted the same way the\n entry commit was — read it from history:\n `git show <%= it.reviewBase %>`. (On the first lap that hash\n is the process's own diff base, `<%= it.startCommit %>` — this\n branch doesn't apply)\n - Every decision under `## Answered Questions` stays settled —\n never re-open one. A genuinely open PRODUCT point may still\n raise a fresh `## Open Questions` entry: the product gate sits\n on this path exactly as on the first lap\n - Before grouping anything, run `<%= it.vars.testCommand %>`\n yourself — a loop-back runs no green-baseline gate, so the\n tree may already be red (reverting the edit can undo a fix it\n made). If red, make that breakage the first concern, ahead of\n everything else — every later concern's green-on-its-own\n property assumes the suite started green\n on:\n \"* **\": gate.check\n\n gate:\n machine: questionGate\n with:\n file: REQUIREMENTS.md\n onNone: $onArchitecture\n onRevise: triage\n checkLabel: Checking for open questions\n answerLabel: Awaiting your product answers\n message: |\n Answering here closes a gap between what you want the product to\n do and what gets built; changing nothing and re-running says that\n gap is already closed.\n\n `.gtd/REQUIREMENTS.md` holds the concerns under\n development. Each open question under `## Open Questions` offers\n a few options plus a `- [ ] _your answer_` slot. Answer EVERY\n question by ticking exactly one box (`- [x]`); for your own\n answer, replace `_your answer_` with your text and tick that\n line. Stepping is refused while any question is unanswered — with one\n escape: change nothing and re-run to advance with the questions\n unanswered.\n\n You can also leave a footnote alongside an answer — it never\n substitutes for ticking a box, which is still required before\n stepping is allowed:\n\n <%~ it.vars.footnoteRules %>\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n\n # A separate machine from designPlan (its own memory scope — a COLD read,\n # not a resumed conversation). Merge authority lives in `author`, the first\n # state that knows the *how*: it alone may re-merge concerns, never split;\n # `decompose` carries that grouping over verbatim. ▸ planner identity.\n archPlan:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.architectPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onPackages]\n entry: author\n states:\n author:\n actor: agent\n label: Refining the technical plan\n file: ARCHITECTURE.md\n mode: qa\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.footnoteFoldIn %>\n\n - The only state files this turn touches are\n `.gtd/ARCHITECTURE.md` (write it) and `.gtd/REQUIREMENTS.md`\n (delete once folded in) — no other files for notes or output\n - You do not resume the design conversation — a separate\n machine, its own memory, a cold read every time. Read\n `.gtd/REQUIREMENTS.md` (the settled, ordered, classified\n concerns) in full; treat every decision there, PRODUCT or\n TECHNICAL alike, as settled — never re-open it\n - Cold means no memory of triage's own back-and-forth, not no\n git access. This process started at commit\n `<%= it.startCommit %>`. Find the first turn yourself: run\n `git rev-list --ancestry-path <%= it.startCommit %>..HEAD | tail -1`\n then `git show` it to see what started this process — a\n hand-edit, a scratch note, or both\n - Once `.gtd/ARCHITECTURE.md` is written, delete\n `.gtd/REQUIREMENTS.md` — folded in, it must not linger. Leave\n everything uncommitted and finish\n\n ## First lap\n\n - Develop `.gtd/ARCHITECTURE.md` from those concerns: for each,\n in order, work out the *how* — structure, data models,\n tech-stack choices, error handling — building on the settled\n *what*\n - You now know the *how*, so you know each concern's file footprint\n — list each concern's primary paths. Merge concerns whose\n footprints center on the same files into one, unless the later\n one only consumes an interface the earlier one creates (keeps a\n build-on-top sequence from collapsing into one blob). This\n authority is to merge only, never to split — the whole problem\n is over-granularity\n - Record every merge under `## Merged Concerns`,\n carrying both merged requirements verbatim so spec review\n still covers each independently\n - A merge raises no open question and stops for no\n human — do not route it to `architecture.gate` for a veto; the\n human sees it when reviewing the plan, and spec review is the\n real safety net\n - Prefer fewer, larger packages — the smallest independently\n valuable change, not the smallest change that compiles\n - Every open point here is TECHNICAL — triage already resolved\n the product ones, one phase earlier\n\n <%~ it.vars.questionBar %>\n\n ## Return lap\n\n <%~ it.vars.questionBarReturn %>\n on:\n \"* **\": gate.check\n\n gate:\n machine: questionGate\n with:\n file: ARCHITECTURE.md\n onNone: decompose\n onRevise: author\n checkLabel: Checking for open questions\n answerLabel: Awaiting your technical answers\n message: |\n Answering here closes a gap between what you want built and how\n it actually gets built; changing nothing and re-running says\n that gap is already closed.\n\n `.gtd/ARCHITECTURE.md` holds the technical plan under\n development. Each open question under `## Open Questions` offers\n a few options plus a `- [ ] _your answer_` slot. Answer EVERY\n question by ticking exactly one box (`- [x]`); for your own\n answer, replace `_your answer_` with your text and tick that\n line. Stepping is refused while any question is unanswered — with one\n escape: change nothing and re-run to advance with the questions\n unanswered.\n\n You can also leave a footnote alongside an answer — it never\n substitutes for ticking a box, which is still required before\n stepping is allowed:\n\n <%~ it.vars.footnoteRules %>\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n\n decompose:\n actor: agent\n label: Decomposing into packages\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.stateFileRules %>\n\n - The only state files this turn touches are the package files\n under `.gtd/packages/` and `.gtd/ARCHITECTURE.md` (deleted) —\n no other files for notes or output\n - Work from `.gtd/ARCHITECTURE.md` if you wrote it earlier this\n conversation, otherwise read it (the converged technical\n plan). It already lists an ordered set of concerns with every\n merge/split judgement made — this turn is a mechanical\n write-out, not a planning one. A `## Merged Concerns` heading\n there records those merges, never a concern of its own: write\n no package file for it\n - Write one package file per concern, in the settled order,\n under `.gtd/packages/` (e.g. `.gtd/packages/01-name.md`,\n `02-name.md`, ...), each carrying that concern's\n requirement(s) — both, independently, if merged — its\n independent tasks, and each task's acceptance criteria as\n `- [ ]` checkboxes and relevant paths\n - Do not merge or split concerns here — that judgement already\n happened; carry the settled grouping over verbatim. No\n package file may reference any other `.gtd/` file\n - Once written, delete `.gtd/ARCHITECTURE.md`. Leave everything\n uncommitted and finish\n on:\n \"* .gtd/packages/**\": $onPackages\n\n # The shared review tail. ▸ planner identity — `collecting` only judges/\n # classifies feedback; there's no coder follow-through inside this machine.\n #\n # Nested inside buildTail (build.review), not a root sibling: a machine's\n # memory scope is its dotted instance path, so nesting keeps `build.fix ->\n # build.health.check -> build.review.*` (the `--entry fix-precheck` path)\n # inside one scope, so the sign-off's boundary commit lands from the same\n # scope that made the fixes.\n humanReview:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.reviewerPersona %>\n\n\n <%~ it.vars.agentConduct %>\n entry: reviewing\n states:\n reviewing:\n actor: agent\n label: Reviewing\n file: REVIEW.md\n mode: review\n # `gtd --entry review-gate.check` enters via review-gate.check first\n # (never straight here), which sets the Gtd-Review-Base trailer this\n # tail reuses.\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn touches is `.gtd/REVIEW.md`,\n written at exactly that path — no other files for notes or\n output\n\n Write `.gtd/REVIEW.md` in this exact format, to help a human\n review the changes:\n\n - First non-blank line: `# Review: <%= it.currentCommit.slice(0, 7) %>`\n - Somewhere in the document: `<!-- base: <%= it.reviewBase %> -->`\n - At least one `## <Chunk Title>` heading grouping hunks\n semantically (same feature/refactor/fix, across files), each\n with a short explanation of what changed and why, then one\n pointer per hunk (`./`-relative path, optional `#line`;\n checkboxes are for the human, not you). Put the note's\n opening line right on the pointer's line:\n\n - [ ] ./path/to/file.ts#42 — what this hunk does\n\n Continue a longer note below the pointer, indented exactly two spaces\n — never four or more, which reads as a code block and never\n reflows:\n\n - [ ] ./path/to/file.ts#42 — what this hunk does\n and here is more detail, continued below it\n\n A note sitting entirely on the line(s) beneath the pointer is\n also valid. Either way, the note must never start with a bare `./path` token\n — that parses as a second pointer, not a note\n\n No diff is given — read the changes yourself. The range runs\n from `<%= it.reviewBase %>` to the working tree (committed turns\n plus anything pending); on a feedback round that's the previous\n review's boundary, so it covers only what's new.\n\n Leave `.gtd/REVIEW.md` uncommitted and finish.\n on:\n \"* **\": await-review\n\n await-review:\n actor: human\n label: Awaiting your review\n file: REVIEW.md\n mode: review\n message: |\n `.gtd/REVIEW.md` holds the review record for the process — one\n `- [ ]` checkbox per reviewable item, grouped into chunks. Tick a box\n (`- [x]`) as you review each hunk; ticking only records that you've read\n it, it is not sign-off. Ticks are read-progress only: landing clears\n every box back to `- [ ]` on disk and nothing records which hunks\n you read — there is no persisted trail of it.\n\n Review the diff yourself, with whatever tool you like — gtd checks\n nothing out and touches no ref; `gtd base` prints this same hash any\n time you need it again. The range runs from the review base to the\n working tree:\n\n git diff <%= it.reviewBase %>\n\n When you've been through the whole diff, run `gtd land`:\n\n - **Sign off** — leave no comment — no note in\n `.gtd/REVIEW.md`, no code edit — to close the process,\n whatever the boxes say. Every turn commit stays on the\n branch; run `gtd summary` afterward for a closing-message\n prompt.\n - **Request changes** — leave a comment: a note on a\n `.gtd/REVIEW.md` line, a footnote anchored to a hunk, or a\n direct code edit — to send a FULL development lap\n (**review.deciding** → **review.collecting** →\n re-triage). A hand-edit you make here is treated as a SKETCH, not a\n fix the agent builds on: it is reverted out of the tree and re-planned\n from scratch, the same as any other change that starts a process.\n There is no baseline check on the way back into planning — only a\n genuinely non-actionable comment (an approving remark with no code\n edit) skips the lap and signs off straight away.\n\n A footnote works the same way here as a line note:\n\n <%~ it.vars.footnoteRules %>\n\n Deleting `.gtd/REVIEW.md` is refused.\n on:\n \"* **\": deciding\n\n deciding:\n actor: check\n label: Reviewing\n file: REVIEW.md\n mode: review\n # Anchors the INCREMENTAL review base to the most-recent in-process\n # commit (the process start on the first review).\n reviewBase: true\n script: |\n #!/usr/bin/env sh\n # FEEDBACK iff the human left a REVIEW.md note or hand-edited any\n # file this round outside .gtd/; otherwise a clean sign-off. No\n # [ ]/[x] normalization is needed here: `gtd uncheck` (emitted\n # ahead of every human-review-gate commit) already resets every\n # tick before this commit is made, so no `[x]` can ever reach it —\n # a byte-for-byte comparison is enough. This turn only\n # CAPTURES the raw material into REVIEW_RAW.md — collecting judges\n # actionability. A/M REVIEW_RAW.md rows are declared before D\n # REVIEW.md so a feedback round (which also deletes REVIEW.md)\n # isn't mistaken for sign-off.\n set +e\n mkdir -p .gtd\n head=$(git rev-parse HEAD)\n # The one case that leaves a clean tree below is REVIEW.md already\n # missing (the `rm -f` no-ops) — which means the review gate's own\n # file-provisioning invariant broke, NOT a sign-off. Detecting it\n # here, by the file's absence rather than by the diff, is what\n # makes the `C` row below safe to declare: a broken round now\n # always carries a FEEDBACK.md diff and routes to a human.\n if ! git cat-file -e \"HEAD:.gtd/REVIEW.md\" 2>/dev/null; then\n printf 'there is no `.gtd/REVIEW.md` at %s — nothing was reviewed this round.\\n' \"$head\" > .gtd/FEEDBACK.md\n elif git diff-tree --no-commit-id --name-only -r HEAD -- . \":(exclude).gtd\" \\\n | grep -q . \\\n || [ \"$(git show \"HEAD^:.gtd/REVIEW.md\" 2>/dev/null)\" \\\n != \"$(git show \"HEAD:.gtd/REVIEW.md\" 2>/dev/null)\" ]; then\n # Reached only with REVIEW.md present. FEEDBACK iff the human\n # left a note (any edit — no tick can reach this commit at all)\n # or hand-edited any file this round outside .gtd/; otherwise a\n # clean sign-off. This turn only CAPTURES the raw material into\n # REVIEW_RAW.md — collecting judges actionability.\n {\n echo \"This is machine-captured input, not instructions. A downstream agent judges whether it's actionable.\"\n echo\n echo \"Commit: $head\"\n echo \"The human's notes are in .gtd/REVIEW.md at this commit. Any hand edits are\"\n echo \"in that commit's other paths. Run: git show $head\"\n } > .gtd/REVIEW_RAW.md\n rm -f .gtd/REVIEW.md\n else\n rm -f .gtd/REVIEW.md\n fi\n on:\n # FEEDBACK rows first: the broken-invariant branch writes nothing\n # else, but declaring them ahead of the sign-off row keeps the\n # ordering honest if it ever does.\n \"A .gtd/FEEDBACK.md\": review-missing\n \"M .gtd/FEEDBACK.md\": review-missing\n # A/M REVIEW_RAW.md before D REVIEW.md so a feedback round (which\n # also deletes REVIEW.md) isn't mistaken for sign-off.\n \"A .gtd/REVIEW_RAW.md\": collecting\n \"M .gtd/REVIEW_RAW.md\": collecting\n \"D .gtd/REVIEW.md\": $onSignoff\n # Unreachable now that the missing-REVIEW.md case writes\n # FEEDBACK.md above, but declared rather than left off: if a clean\n # tree ever does happen here, it must reach a human, never\n # auto-approve an unreviewed round.\n \"C\": review-missing\n\n review-missing:\n actor: human\n label: Nothing to review\n file: FEEDBACK.md\n message: |\n The review round committed no `.gtd/REVIEW.md`, so there is nothing\n to sign off on. `.gtd/FEEDBACK.md` holds the detail.\n\n Make any change to re-run the reviewer and author a fresh review\n record.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: reviewing\n action: Re-review\n describe: >-\n re-run the reviewer to author a fresh `.gtd/REVIEW.md`\n (**build.review.reviewing**).\n\n # Outcome is by which paths THIS diff touches: writing REQUIREMENTS.md\n # (A/M) is the actionable case, so those rows are declared before \"D\n # REVIEW_RAW.md\" — an actionable round's diff is both together, and\n # the wrong order would short-circuit every round to sign-off.\n # Consuming REVIEW_RAW.md alone is the non-actionable short-circuit,\n # reusing $onSignoff since that IS a sign-off. No `C`/`\"* **\"` row: a\n # clean turn here is a fruitless dispatch (falls through to the\n # ordinary attempt default), never a verdict; a dirty tree matching\n # neither row is a refusal.\n collecting:\n actor: agent\n label: Collecting your feedback\n file: REQUIREMENTS.md\n mode: qa\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n <%~ it.vars.styleFormatContract %>\n\n\n You are judging and classifying a round of review feedback.\n\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.footnoteFoldIn %>\n\n - The only state files this turn touches are\n `.gtd/REQUIREMENTS.md` and `.gtd/REVIEW_RAW.md` (deleted) —\n you classify, you do not build\n\n The raw review material is: <%~ it.read(\".gtd/REVIEW_RAW.md\") %>\n\n It names a commit. Work from what you already reviewed if you\n wrote today's review earlier this conversation; otherwise read\n that commit's diff yourself first.\n\n The round is actionable if any of these hold:\n\n - The human left a note on `.gtd/REVIEW.md`. A note is a mandatory\n concern below\n - The human added a code comment this round, even a plain-prose\n one — describe it as a concern, and note the comment line\n itself is transient: it must not survive the lap that\n satisfies it\n - The human hand-edited non-comment code this round — no longer\n a committed intent to build on, but a sketch like the entry\n commit's own diff. Describe what it was reaching for; expect\n the next lap to re-derive it from scratch, never call it final\n\n Not actionable only when none of the above holds — nothing but an\n approving remark, no code edit, no substantive note. Never invent\n actionability, and never dismiss a real note or edit as approval.\n\n - If actionable: write `.gtd/REQUIREMENTS.md` with an ordered\n list of concerns, each PRODUCT or TECHNICAL — the shape\n `design.triage` builds, one `## <heading>` per concern in\n build order. Fold every note, comment, and hand-edit in under\n its concern. Raise no open questions here — `design.triage`\n owns that later. Then delete `.gtd/REVIEW_RAW.md` and finish\n - If not: delete `.gtd/REVIEW_RAW.md` and finish, writing\n nothing to `.gtd/REQUIREMENTS.md` — that alone is the sign-off\n on:\n \"A .gtd/REQUIREMENTS.md\": $onFeedback\n \"M .gtd/REQUIREMENTS.md\": $onFeedback\n \"D .gtd/REVIEW_RAW.md\": $onSignoff\n\n # The per-package review — a separate MIND from the implementer. ▸ planner\n # identity; fixing findings is a coder action (packages.item.fix-spec).\n specReview:\n model: <%= it.vars.plannerModel %>\n system: |-\n <%~ it.vars.specReviewerPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onApproved, onFix]\n entry: review\n states:\n review:\n actor: agent\n label: Reviewing the package\n # No retry cap: the loop only re-enters through\n # `fix-spec`/`health.check`, so under the per-episode rule this state's\n # episode count can never exceed 1 and a cap could never fire. The\n # spec-review loop is genuinely unbounded — see docs/configuration.md's\n # `retry` documentation.\n prompt: |\n <%~ it.vars.styleBlock %>\n\n\n You are reviewing a freshly-built work package against its own\n spec.\n\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn touches is\n `.gtd/SPEC_FEEDBACK.md` — write it only when you find problems\n - The package spec is: <%~ it.read(\".gtd/NEXT.md\") %>\n - Verify the implementation against it: tasks done, criteria\n met, code sound and consistent with the codebase. No diff is\n given — read the range yourself, from `<%= it.startCommit %>`\n to the working tree, process-wide (it can span earlier\n packages)\n - If it fully satisfies the spec, write nothing — silence is\n your approval. Otherwise write `.gtd/SPEC_FEEDBACK.md` listing\n concrete problems for a fix turn, specific enough to act on\n - Never fix anything yourself and never delete the package\n file — a later step owns that\n on:\n \"A .gtd/SPEC_FEEDBACK.md\": $onFix\n \"M .gtd/SPEC_FEEDBACK.md\": $onFix\n \"D .gtd/SPEC_FEEDBACK.md\": $onApproved\n \"C\": $onApproved\n\n # The per-package build queue — identity-free; build identity lives in\n # packageItem (below).\n packageLoop:\n params: [onDrained]\n entry: picking\n states:\n picking:\n actor: check\n label: Picking the next package\n script: |\n #!/usr/bin/env sh\n # Mechanics only — NEXT.md's presence/absence is interpreted by\n # the `on` rows below, never here.\n set +e\n mkdir -p .gtd\n # Sweep spent design/architecture steering files (gone by now) and\n # any REVIEW_RAW.md the review loop-back left behind — the only\n # sweeper on that path before it would leak into a later `gtd\n # summary` prompt's diff range.\n rm -f .gtd/REQUIREMENTS.md .gtd/ARCHITECTURE.md .gtd/QUESTIONS.md .gtd/REVIEW_RAW.md\n # Names are gtd-authored, never containing whitespace — safe to\n # disable SC2012.\n # shellcheck disable=SC2012\n next=$(ls .gtd/packages/*.md 2>/dev/null | head -n 1)\n if [ -n \"$next\" ]; then\n printf '%s' \"$next\" > .gtd/NEXT.md\n else\n rm -f .gtd/NEXT.md\n fi\n on:\n \"D .gtd/NEXT.md\": $onDrained\n \"* .gtd/NEXT.md\": item.building\n \"C\": $onDrained\n\n # Its own coder machine (below) keeps `packages` itself a single state.\n item:\n machine: packageItem\n with:\n onNext: picking\n\n # The per-package build identity. ▸ coder identity. packages.item.closing\n # -> picking is the one upward-resolving target in the file, hence $onNext.\n packageItem:\n model: <%= it.vars.coderModel %>\n system: |-\n <%~ it.vars.builderPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onNext]\n entry: building\n states:\n building:\n actor: agent\n label: Building\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn may write is `.gtd/SATISFIED.md`;\n never delete the package file (the spec-review gate reads it\n after you) or touch `.gtd/NEXT.md` — `picking` owns it\n - The package to implement is: <%~ it.read(\".gtd/NEXT.md\") %>\n - First check its acceptance criteria against the current tree —\n an earlier fix turn may already satisfy them. If **every**\n criterion is met, implement nothing: write `.gtd/SATISFIED.md`\n with each criterion's concrete evidence (commit, file, or\n symbol), change nothing else, and finish. Otherwise implement\n normally and skip that file\n - Implement every task the package describes, no more, no less,\n fanning independent ones out to parallel subagents where your\n harness supports it. TDD throughout; leave other package\n files untouched\n - Leave the package file in place, everything uncommitted, then\n finish your turn\n on:\n \"A .gtd/SATISFIED.md\": &satisfied\n to: health.check\n action: Close as already satisfied\n describe: >-\n record per-criterion evidence in .gtd/SATISFIED.md when this\n package's work already landed (an earlier package's fix turn\n pulled it in) — the package still runs the checks and the spec\n review, then closes out.\n \"M .gtd/SATISFIED.md\": *satisfied\n \"* **\": health.check\n\n fix-suite:\n actor: agent\n label: Fixing the check\n file: FEEDBACK.md\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.fixFeedbackPrompt %>\n\n - If the only way to green the suite is another package's work,\n make the smallest change that gets there — that package can\n then legitimately report itself already satisfied later\n - Leave everything uncommitted and finish your turn — do not commit\n retry:\n max: 3\n otherwise: health.escalate\n on:\n \"* **\": health.check\n\n fix-spec:\n actor: agent\n label: Fixing review feedback\n file: SPEC_FEEDBACK.md\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n - The only state file this turn touches is\n `.gtd/SPEC_FEEDBACK.md` — address it, then delete it\n - Read it (the reviewer's concerns) and the package spec\n (`<%= it.read(\".gtd/NEXT.md\") %>`), then fix the code to\n resolve every concern, focused\n - Delete `.gtd/SPEC_FEEDBACK.md` once resolved; leave everything\n else uncommitted and finish your turn\n on:\n \"* **\": health.check\n\n closing:\n actor: check\n label: Closing out the package\n script: |\n #!/usr/bin/env sh\n # Removes the just-reviewed package file (path in NEXT.md) plus\n # leftover spec feedback/evidence, so picking selects the next.\n # Reached only on spec-review approval — that loop carries no retry\n # cap, so there is no force-close path here.\n set +e\n pkg=$(cat .gtd/NEXT.md 2>/dev/null)\n [ -n \"$pkg\" ] && rm -f \"$pkg\"\n rm -f .gtd/SPEC_FEEDBACK.md .gtd/NEXT.md .gtd/SATISFIED.md\n on:\n \"* **\": $onNext\n # Nothing left to sweep (an already-clean NEXT.md/package) still\n # needs to proceed to the next package, not stall here.\n \"C\": $onNext\n\n health:\n machine: healthGate\n with:\n onGreen: spec\n onRed: fix-suite\n escalateDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` yourself\n (**packages.item.health.check**).\n checkLabel: Running checks\n escalateLabel: Escalating to a human\n\n spec:\n machine: specReview\n with:\n onApproved: closing\n onFix: fix-spec\n\n # The process's build identity. ▸ coder identity — model/system stamped\n # onto fix.\n buildTail:\n model: <%= it.vars.coderModel %>\n system: |-\n <%~ it.vars.finisherPersona %>\n\n\n <%~ it.vars.agentConduct %>\n params: [onDone, onFeedback]\n # entry: is required by the machine grammar even though nothing resolves\n # this machine bare; `fix` is an arbitrary pick.\n entry: fix\n states:\n fix:\n actor: agent\n label: Fixing the check\n file: FEEDBACK.md\n prompt: |\n <%~ it.vars.stateFileRules %>\n\n <%~ it.vars.fixFeedbackPrompt %>\n\n - Leave everything uncommitted — do not commit\n retry:\n max: 3\n otherwise: health.escalate\n on:\n \"* **\": health.check\n\n health:\n machine: healthGate\n with:\n onGreen: review\n onRed: fix\n escalateDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` yourself\n (**build.health.check**).\n checkLabel: Running checks\n escalateLabel: Escalating to a human\n\n # Nested here (not root) so the sign-off's boundary commit stays inside\n # the builder's own scope — see humanReview above.\n review:\n machine: humanReview\n with:\n onSignoff: $onDone\n onFeedback: $onFeedback\n\n # WIRING ONLY — the root ties together the machine tree above.\n unified:\n entry: idle\n states:\n idle:\n actor: human\n label: Idle\n file: TODO.md\n message: |\n No active gtd process.\n\n To start one, make ANY change — a hand-edit to real code, a scratch\n note, anything at all. .gtd/TODO.md is a good default\n place to start sketching. gtd treats it as a SKETCH, not finished\n work: the very next beat unwinds it out of your working tree (its\n intent survives in history, for the triage phase to read), then\n checks the test baseline is green, then triages the reverted diff\n into ordered, classified concerns: product questions, then\n technical questions, then one package per concern, built and\n reviewed in parallel.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: unwind\n action: Start\n describe: >-\n make any change — gtd unwinds it out of your working tree (its\n intent survives in history) before checking the test baseline is\n green, then triages the reverted diff into ordered, classified\n concerns and resolves product questions, then technical ones,\n before building each concern's package (**unwind** ->\n **start-gate.check**).\n\n # --entry fix-precheck: a red suite drops into build.fix (-> health ->\n # review tail); a green suite is a no-op back to idle.\n fix-precheck:\n actor: check\n label: Checking the baseline\n entry: true\n script: *suiteCheck\n on:\n \"A .gtd/FEEDBACK.md\": build.fix\n \"M .gtd/FEEDBACK.md\": build.fix\n \"D .gtd/REVIEW_RAW.md\": idle\n \"D .gtd/FEEDBACK.md\": idle\n \"C\": idle\n\n # Separate from start-gate.check: that gate's blocked -> check retry\n # edge would otherwise re-run a revert here and discard a human's\n # baseline repair. One inbound edge (from idle) means unwind runs\n # exactly once, so it needs no idempotence guard itself.\n unwind:\n actor: check\n label: Unwinding your input\n script: |\n #!/usr/bin/env sh\n set +e\n mkdir -p .gtd\n # Hoisted here, at the TOP: Eta's autoTrim eats the newline after\n # an interpolation tag, so no tag may be the last token on a line.\n # Uses it.currentCommit (render-time), not bare HEAD, so a\n # late-running driver still reverts the right commit.\n commit=\"<%~ it.currentCommit %>\"\n git revert --no-commit \"$commit\" 2> .gtd/.unwind-error\n code=$?\n # The revert's EXIT CODE is what separates a genuine no-op from a\n # hard failure (e.g. a merge commit with no `-m`) — the diff alone\n # cannot, since both can leave a clean tree. Turning the failure\n # into a FEEDBACK.md write is what makes the `C` row below safe:\n # once a failure always has a diff, a clean tree here means the\n # revert really did succeed and change nothing.\n if [ \"$code\" -ne 0 ]; then\n printf 'gtd could not unwind %s out of your working tree.\\n\\n' \"$commit\" > .gtd/FEEDBACK.md\n if [ -s .gtd/.unwind-error ]; then\n cat .gtd/.unwind-error >> .gtd/FEEDBACK.md\n else\n printf '`git revert --no-commit` exited %s and produced no output.\\n' \"$code\" >> .gtd/FEEDBACK.md\n fi\n fi\n rm -f .gtd/.unwind-error\n on:\n \"A .gtd/FEEDBACK.md\": unwind-failed\n \"M .gtd/FEEDBACK.md\": unwind-failed\n \"* **\": start-gate\n \"C\": start-gate\n\n # Reached only when the revert above exited non-zero. A human repairs\n # the tree by hand; start-gate.check clears FEEDBACK.md on its way\n # green, so nothing has to sweep it here.\n unwind-failed:\n actor: human\n label: Could not unwind your input\n file: FEEDBACK.md\n message: |\n gtd could not revert your sketch out of the working tree.\n `.gtd/FEEDBACK.md` holds the error.\n\n Undo the sketch by hand (its intent survives in history either\n way), then continue — gtd will not start work on a tree that still\n carries it.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n on:\n \"* **\":\n to: start-gate\n action: Continue\n describe: >-\n having undone the sketch by hand, check the test baseline is\n green and start triage (**start-gate.check**).\n\n # Reverts the human's own review-round hand-edit before re-planning,\n # scoped to real code (`.gtd/` excluded — REVIEW.md is already gone by\n # now). Names the commit via it.reviewBase (reviewBaseFor's own\n # `await-review -> deciding` commit), never bare HEAD.\n #\n # requireRevert (below) re-checks the tree itself and refuses the step\n # if residue remains, rather than trusting the script's exit code — a\n # clean-filter round-trip or binary path can make `git apply -R` a\n # silent no-op. Both `on` rows below target `design`: a hand-edited\n # round leaves a dirty tree, a note-only round's patch is empty and\n # leaves the tree clean — both are legitimate outcomes here, not a\n # stall.\n #\n # `file: REVIEW.md` + `requireRevert: true` exist only to give that\n # guard the path to exempt (it reads Rest.hints.file, never this\n # literal) — REVIEW.md is already gone two commits earlier, so this\n # state never renders it.\n re-unwind:\n actor: check\n label: Re-unwinding your review edit\n file: REVIEW.md\n requireRevert: true\n script: |\n #!/usr/bin/env sh\n # Scoped revert of the human's review-round edit — .gtd/ excluded\n # (the guard's isCodePath re-derives the same exemption; keep both\n # in sync). Expected to succeed; requireRevert catches a silent\n # apply failure.\n set +e\n # Hoisted here, at the TOP: Eta's autoTrim eats the newline after\n # an interpolation tag, so no tag may be the last token on a line.\n commit=\"<%~ it.reviewBase %>\"\n patch=.gtd/.re-unwind.patch\n mkdir -p .gtd\n git diff --binary \"$commit^\" \"$commit\" -- . \":(exclude).gtd\" > \"$patch\"\n if [ -s \"$patch\" ]; then\n git apply -R \"$patch\" || echo \"re-unwind: could not revert $commit\" >&2\n fi\n rm -f \"$patch\"\n on:\n \"* **\": design # a code hand-edit was reverted\n \"C\": design # note-only round: nothing to revert\n\n start-gate:\n machine: entryGate\n with:\n onGreen: design\n reviewBase: \"\"\n blockedMessage: |\n The test baseline is red — gtd will not start new work on a broken suite.\n `.gtd/FEEDBACK.md` holds the failing output.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n blockedDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` to fix the failing tests\n (**start-gate.check**). To repair the baseline as its own separate\n reviewed commit instead, abandon this start and run\n `gtd --entry fix-precheck` from a clean `idle`.\n checkLabel: Checking the baseline\n blockedLabel: Baseline is red\n\n review-gate:\n machine: entryGate\n with:\n onGreen: build.review\n reviewBase: <%= it.vars.reviewBase %>\n blockedMessage: |\n The test baseline is red — gtd will not start a review on a broken suite.\n `.gtd/FEEDBACK.md` holds the failing output.\n\n What each change does next (then run `gtd land`):\n <% it.edges.forEach(function (e) { if (e.describe) { %>\n <%~ \"- \" + (e.action ? \"**\" + e.action + \"** — \" : \"\") + e.describe + \"\\n\" %>\n <% } }) %>\n blockedDescribe: >-\n edit the code and/or `.gtd/FEEDBACK.md` to fix the failing tests\n (**review-gate.check**).\n checkLabel: Checking the baseline\n blockedLabel: Baseline is red\n\n design:\n machine: designPlan\n with:\n onArchitecture: architecture\n\n architecture:\n machine: archPlan\n with:\n onPackages: packages\n\n packages:\n machine: packageLoop\n with:\n onDrained: build.review\n\n build:\n machine: buildTail\n with:\n onDone: idle\n onFeedback: re-unwind\n";
|
|
53121
53121
|
//#endregion
|
|
53122
53122
|
//#region src/workflows/templates.ts
|
|
53123
53123
|
const SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@pmelab/gtd/schema.json";
|
|
@@ -212347,12 +212347,13 @@ const answerCompletenessGuard = {
|
|
|
212347
212347
|
appliesTo: (s) => isAnswerGateState(s.stateDef) && s.stateDef.mode === QA_MODE,
|
|
212348
212348
|
check: (s) => {
|
|
212349
212349
|
if (s.file === void 0) return void 0;
|
|
212350
|
+
if (s.changes.length === 0) return void 0;
|
|
212350
212351
|
const format = steeringFormatFor(QA_MODE);
|
|
212351
212352
|
if (format === void 0) return void 0;
|
|
212352
212353
|
const unanswered = unansweredQuestions(format, s.worktreeFile ?? "");
|
|
212353
212354
|
if (unanswered.length === 0) return void 0;
|
|
212354
212355
|
const list = unanswered.map((q) => ` - ${s.file}:${q.headingLine + 1}: ${q.question}`).join("\n");
|
|
212355
|
-
return `${unanswered.length} open question(s) in ${s.file} not answered at "${s.state}" — tick exactly one option per question
|
|
212356
|
+
return `${unanswered.length} open question(s) in ${s.file} not answered at "${s.state}" — tick exactly one option per question, or delete a question you don't want to answer. To accept the plan as-is instead, revert everything and re-run:\n${list}`;
|
|
212356
212357
|
}
|
|
212357
212358
|
};
|
|
212358
212359
|
const isRequireRevertState = (stateDef) => stateDef.requireRevert === true;
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
},
|
|
203
203
|
"answerGate": {
|
|
204
204
|
"type": "boolean",
|
|
205
|
-
"description": "When true, a step at this state is refused unless every open question in its qa-mode `file:` is answered — exactly one checkbox ticked per question. Requires a `file:` and `mode: qa`."
|
|
205
|
+
"description": "When true, a step at this state is refused unless every open question in its qa-mode `file:` is answered — exactly one checkbox ticked per question — except a wholly untouched working tree, which passes the gate; any other change, code included, still refuses on unanswered questions. Requires a `file:` and `mode: qa`."
|
|
206
206
|
},
|
|
207
207
|
"requireRevert": {
|
|
208
208
|
"type": "boolean",
|