@pmelab/gtd 2.8.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -40
- package/bin/gtd-loop +43 -23
- package/dist/gtd.bundle.mjs +2281 -3486
- package/docs/cli.md +187 -288
- package/docs/configuration.md +335 -71
- package/docs/design/configurable-state-machine.md +1439 -0
- package/docs/design/delta-purity-plan.md +283 -0
- package/docs/design/pattern-machine-plan.md +164 -0
- package/docs/design/scripted-actor.md +289 -0
- package/docs/design/state-file-association.md +112 -0
- package/docs/design/steering-file-loops.md +164 -0
- package/docs/design/work-packages.md +194 -0
- package/docs/development.md +55 -36
- package/docs/examples/advanced-workflow.md +428 -0
- package/docs/loop.md +60 -60
- package/docs/upgrading.md +125 -0
- package/package.json +2 -2
- package/schema.json +6 -73
- package/docs/upgrading-from-v1.md +0 -45
- package/docs/workflow.md +0 -428
package/docs/cli.md
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
Usage: gtd [command] [options]
|
|
5
5
|
|
|
6
6
|
Commands:
|
|
7
|
-
step
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
step <actor> Authenticate as <actor>, match the resolved rest's
|
|
8
|
+
declared patterns against the pending changes, and commit
|
|
9
|
+
(or squash) the one resulting transition
|
|
10
|
+
next Print the resolved rest's rendered script/prompt/message
|
|
11
|
+
(no mutation)
|
|
12
|
+
run Execute the resolved rest's emitted script, then step its
|
|
13
|
+
actor (the built-in script driver)
|
|
14
|
+
status Print the resolved rest's state/actor and which declared
|
|
15
|
+
pattern (if any) each pending change matches (no mutation)
|
|
14
16
|
format <file> Format a markdown file in place
|
|
17
|
+
lsp Start the LSP server for .gtd/ steering files (stdio)
|
|
15
18
|
|
|
16
19
|
Options:
|
|
17
20
|
--json Output structured JSON instead of plain text
|
|
@@ -23,334 +26,230 @@ Options:
|
|
|
23
26
|
repository-state work — they run outside a repo and in any repo state. Bare
|
|
24
27
|
`gtd` (no subcommand) is a usage error: it prints the help text and exits 1
|
|
25
28
|
without touching the repository. Every other command must be run from the
|
|
26
|
-
**repository root** — gtd derives
|
|
27
|
-
to cwd, so it refuses with a clear error if invoked from a
|
|
29
|
+
**repository root** — gtd derives the workflow, pending changes, and process
|
|
30
|
+
history relative to cwd, so it refuses with a clear error if invoked from a
|
|
31
|
+
subdirectory.
|
|
28
32
|
|
|
29
33
|
`--json` is the only long option. Any other `--` option (including a typo like
|
|
30
34
|
`--jsn`) is rejected with a usage error rather than silently ignored, so a
|
|
31
35
|
mistyped flag can never degrade a JSON caller to plain-text mode.
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
change workflow state, but while a human review is pending they do maintain the
|
|
35
|
-
review checkout window (closing it to read state, re-arming it on the way out —
|
|
36
|
-
see [Human review gate](workflow.md#human-review-gate)), which transiently moves
|
|
37
|
-
HEAD and the index. The working tree is never touched.
|
|
38
|
-
|
|
39
|
-
## `gtd step` / `gtd step-agent`
|
|
40
|
-
|
|
41
|
-
Both drive the **same fixpoint loop** — gather → resolve → perform the returned
|
|
42
|
-
edge action → repeat — differing only in which actor's turn they are allowed to
|
|
43
|
-
capture:
|
|
44
|
-
|
|
45
|
-
- **`gtd step`** captures the **human** turn at whichever gate is awaiting one.
|
|
46
|
-
- **`gtd step-agent`** captures the **agent** turn.
|
|
47
|
-
|
|
48
|
-
**Fixpoint advance.** A single invocation may author several commits: it authors
|
|
49
|
-
the awaited actor's turn commit, then keeps performing any further mid-chain
|
|
50
|
-
routing (a test run, a routing commit, a package close, …) until it reaches a
|
|
51
|
-
rest where a prompt would be shown, or a fixpoint where nothing changed.
|
|
52
|
-
`gtd step`/`gtd step-agent` never print a prompt themselves — that's
|
|
53
|
-
`gtd next`'s job.
|
|
54
|
-
|
|
55
|
-
**Idempotence.** Re-running the same command again once the tree is settled at a
|
|
56
|
-
rest authors **zero** new commits. It exits 0 while the rest still awaits that
|
|
57
|
-
command's actor (an inert empty agent turn, the idle health check); once the
|
|
58
|
-
rest awaits the _other_ actor, the re-run is an out-of-turn refusal — still zero
|
|
59
|
-
commits, but non-zero exit.
|
|
60
|
-
|
|
61
|
-
**Out-of-turn refusal.** Human and agent turns are strictly separated: the wrong
|
|
62
|
-
mutator always errors, at every state, on clean and dirty trees alike.
|
|
63
|
-
`gtd step-agent` while a human turn is awaited refuses with
|
|
64
|
-
`"<state> awaits a human turn — run \`gtd step\`"`; `gtd
|
|
65
|
-
step`while an agent turn is awaited refuses with`"<state> awaits an agent turn —
|
|
66
|
-
run \`gtd
|
|
67
|
-
step-agent\`"`— exit non-zero, zero commits either way. Human edits made while the agent is awaited (e.g. amendment notes in`.gtd/`package files after the`gtd:
|
|
68
|
-
planning` commit lands) stay pending in the working tree and ride along as input
|
|
69
|
-
to the agent's next captured turn; left unamended, the build proceeds.
|
|
70
|
-
|
|
71
|
-
**Red-test fixpoints exit 0.** A red test run below the fix-attempt cap (or the
|
|
72
|
-
health-fix cap) still writes its findings and commits — it is a normal,
|
|
73
|
-
successful step of the loop, not a failure of the `step`/`step-agent`
|
|
74
|
-
invocation. `step`/`step-agent` only exit non-zero for a genuine refusal or an
|
|
75
|
-
operational error (bad config, missing test binary, corrupted state).
|
|
76
|
-
|
|
77
|
-
**Output.** Plain mode prints one `committed: <subject>` line per commit this
|
|
78
|
-
invocation authored (oldest→newest), then a final `state: <state>` line:
|
|
37
|
+
## `gtd step <actor>`
|
|
79
38
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`--json` emits `{state, actions, commits}` instead (see
|
|
87
|
-
[JSON schemas](#json-schemas)).
|
|
88
|
-
|
|
89
|
-
## `gtd next`
|
|
90
|
-
|
|
91
|
-
Pure prompt emitter — it **never mutates** the repository. It reports whichever
|
|
92
|
-
actor is currently awaited and, if the tree is at a genuine rest, the full
|
|
93
|
-
prompt for that actor.
|
|
94
|
-
|
|
95
|
-
**Purity.** No commits, no file writes, no test runs — `gtd next` only gathers
|
|
96
|
-
and resolves.
|
|
97
|
-
|
|
98
|
-
**Dirty-tree refusal.** If the working tree has pending changes outside the
|
|
99
|
-
steering-file set, `gtd next` refuses rather than guess at a prompt for a state
|
|
100
|
-
that hasn't been captured yet:
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
gtd next: working tree is dirty — run `gtd status` to inspect it, then advance with `gtd step` or `gtd step-agent` (whichever actor is awaited)
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Pending.** If HEAD is mid-chain — bookkeeping the next `step`/`step-agent`
|
|
107
|
-
invocation would perform before reaching a rest — `gtd next` reports
|
|
108
|
-
`pending: true` with no prompt. Mid-chain bookkeeping is invoker-agnostic, so
|
|
109
|
-
either mutator resumes it; the report names the actor whose chain it is. In
|
|
110
|
-
plain mode an agent-driven checkpoint prints `"mid-chain checkpoint — run \`gtd
|
|
111
|
-
step-agent\` to continue, then run \`gtd next\`
|
|
112
|
-
again"`, a human-driven one prints `"mid-chain checkpoint — run \`gtd step\` to
|
|
113
|
-
continue"`.
|
|
114
|
-
|
|
115
|
-
**Agent tail lines.** In plain-mode output, a prompt for the **agent** actor
|
|
116
|
-
ends with the pinned tail:
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
Finish your turn by running `gtd step-agent`. Then run `gtd next` and follow
|
|
120
|
-
its output — repeat this cycle as long as the output is addressed to you (the
|
|
121
|
-
agent); when it awaits the human, stop and hand off.
|
|
122
|
-
```
|
|
39
|
+
Authenticates `<actor>` against the resolved rest and performs the ONE resulting
|
|
40
|
+
transition. Unlike v2, there is no fixpoint chain to drive: the pattern
|
|
41
|
+
machine's `on` edges are direct one-hop transitions, so a single invocation
|
|
42
|
+
authors at most one commit (a normal turn) or performs one squash
|
|
43
|
+
(§[STATES.md](../STATES.md#8-the-squash-lifecycle)) — never both, never a chain
|
|
44
|
+
of several. A caller that wants several transitions issues several invocations.
|
|
123
45
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
46
|
+
- **Out-of-turn refusal** — `<actor>` isn't the resolved state's declared actor:
|
|
47
|
+
exit non-zero, zero commits.
|
|
48
|
+
`gtd step <actor>: out of turn — "<state>" awaits <awaited-actor>`
|
|
49
|
+
- **No-match refusal** — the tree is dirty and no declared `on` pattern matches:
|
|
50
|
+
exit non-zero, zero commits, naming every declared pattern.
|
|
51
|
+
`gtd step <actor>: no declared pattern matches the pending changes at "<state>" — declared patterns: <p1>, <p2>, …`
|
|
52
|
+
- **No-op** — the tree is clean and the state declares no `C` pattern: exit
|
|
53
|
+
**0**, zero commits. This is the default, silent case a loop driver relies on
|
|
54
|
+
(see [Driving the loop](loop.md)).
|
|
55
|
+
- **Commit/squash** — a pattern matched: exit 0, one commit (or one squash)
|
|
56
|
+
authored.
|
|
131
57
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Pure, read-only **dry-run prediction** — the same gather+resolve `gtd next`
|
|
135
|
-
runs, but reporting a prediction of the next turn rather than the actual prompt.
|
|
136
|
-
Performs no git mutation, no test run, no file write — guaranteed side-effect
|
|
137
|
-
free, including on a dirty tree.
|
|
138
|
-
|
|
139
|
-
Prints four fields:
|
|
58
|
+
Plain-mode output is one line:
|
|
140
59
|
|
|
141
60
|
```
|
|
142
|
-
|
|
143
|
-
Awaits: human
|
|
144
|
-
Predicted commit: gtd(human): grilling
|
|
145
|
-
Predicted state: grilling
|
|
61
|
+
committed: gtd(human): grilling
|
|
146
62
|
```
|
|
147
63
|
|
|
148
|
-
|
|
149
|
-
- **Awaits** — the actor (`human` or `agent`) whose turn it is.
|
|
150
|
-
- **Predicted commit** — the subject `step`/`step-agent` would author next, or
|
|
151
|
-
`(none)` at a fixpoint (e.g. idle with nothing to do).
|
|
152
|
-
- **Predicted state** — the state that commit would land in.
|
|
153
|
-
|
|
154
|
-
`gtd status` takes no arguments — extra positional args are rejected.
|
|
64
|
+
or, at a no-op:
|
|
155
65
|
|
|
156
|
-
## `gtd review <target>`
|
|
157
|
-
|
|
158
|
-
A pure mutator that **anchors, then exits** — it never prints a prompt itself.
|
|
159
|
-
Use it to start an ad-hoc human review against an explicit git ref or branch,
|
|
160
|
-
independent of the automatic review base the workflow otherwise computes.
|
|
161
|
-
|
|
162
|
-
1. Refuses on a dirty tree.
|
|
163
|
-
2. Resolves `<target>` via merge-base semantics and computes the diff HEAD adds
|
|
164
|
-
over `merge-base(<target>, HEAD)`.
|
|
165
|
-
3. Refuses if that diff is empty after filtering ("nothing to review").
|
|
166
|
-
4. Authors exactly one commit: `gtd: reviewing <full-hash-of-the-base>`.
|
|
167
|
-
5. Prints a short confirmation pointing at `gtd next` — it does **not** print
|
|
168
|
-
the review prompt itself.
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
gtd review main
|
|
172
|
-
# anchored review at <hash> — run `gtd next` to get the review prompt
|
|
173
|
-
gtd next --json
|
|
174
|
-
# {"actor":"agent", ...} — the review-record prompt scoped to that anchor
|
|
175
66
|
```
|
|
176
|
-
|
|
177
|
-
Errors (all exit 1, message on stderr):
|
|
178
|
-
|
|
179
|
-
- Missing target: `gtd review: missing target argument`
|
|
180
|
-
- Extra arguments:
|
|
181
|
-
`gtd review: too many arguments — expected one target, got: …`
|
|
182
|
-
- Unresolvable ref: `gtd review: cannot resolve ref '<target>': <error message>`
|
|
183
|
-
- Empty diff:
|
|
184
|
-
`gtd review: nothing to review (<target> diff is empty after filtering)`
|
|
185
|
-
|
|
186
|
-
## `gtd questions` / `gtd changesets`
|
|
187
|
-
|
|
188
|
-
Pure, read-only reporters — no dirty-tree check, no mutation — that parse the
|
|
189
|
-
structured content out of the active grilling/architecting and review documents,
|
|
190
|
-
for a future UI:
|
|
191
|
-
|
|
192
|
-
- **`gtd questions`** reads whichever of `.gtd/TODO.md` / `.gtd/ARCHITECTURE.md`
|
|
193
|
-
is present and reports its `## Open Questions` list (see
|
|
194
|
-
[Structured grilling/architecting and review files](workflow.md#structured-grillingarchitecting-and-review-files)).
|
|
195
|
-
Reports an empty list when neither file exists.
|
|
196
|
-
- **`gtd changesets`** reads `.gtd/REVIEW.md`, if present, and reports its
|
|
197
|
-
chunks/file-pointer list. Reports an empty list when the file doesn't exist.
|
|
198
|
-
|
|
199
|
-
Both take no arguments and always exit 0 — a malformed file is reported via the
|
|
200
|
-
`errors` field/lines rather than failing the command (the same diagnosis
|
|
201
|
-
`gtd step-agent` would refuse the agent's next turn capture with).
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
gtd questions --json
|
|
205
|
-
# {"file":".gtd/TODO.md","questions":[{"question":"Which operations?","status":"suggested","text":"add and subtract."}],"errors":[]}
|
|
206
|
-
gtd changesets --json
|
|
207
|
-
# {"file":".gtd/REVIEW.md","shortHash":"abc1234","fullHash":"abc1234...","changesets":[...],"errors":[]}
|
|
67
|
+
nothing to do at "idle"
|
|
208
68
|
```
|
|
209
69
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Formats a markdown file in place with a bundled prettier (`parser: "markdown"`,
|
|
213
|
-
`printWidth: 80`, `proseWrap: "always"`), ignoring the host repo's own
|
|
214
|
-
`.prettierrc` so `.gtd/TODO.md`/`.gtd/REVIEW.md` stay consistently formatted
|
|
215
|
-
regardless of the host project's toolchain. Rejects `--json` (exit 1,
|
|
216
|
-
`gtd format does not accept --json`) — it is a plain file operation, not a v2
|
|
217
|
-
state command.
|
|
218
|
-
|
|
219
|
-
Errors (all exit 1, message on stderr):
|
|
220
|
-
|
|
221
|
-
- Missing path: `gtd format: missing file path argument`
|
|
222
|
-
- Extra arguments: `gtd format: too many arguments — expected one path, got: …`
|
|
223
|
-
- Non-markdown file:
|
|
224
|
-
`gtd format: <file> is not a markdown file (expected .md or .markdown)`
|
|
225
|
-
- File not found: `gtd: skipped formatting <file>: not found`
|
|
226
|
-
|
|
227
|
-
## JSON schemas
|
|
228
|
-
|
|
229
|
-
Pass `--json` to `step`, `step-agent`, `next`, `status`, `review`, `questions`,
|
|
230
|
-
or `changesets` for machine-readable single-line JSON output instead of plain
|
|
231
|
-
text.
|
|
232
|
-
|
|
233
|
-
**`step` / `step-agent`** — `{state, actions, commits}`:
|
|
70
|
+
`--json` emits `{state, subject}` — `subject` is `null` at a no-op:
|
|
234
71
|
|
|
235
72
|
```json
|
|
236
|
-
{
|
|
237
|
-
"state": "architecting",
|
|
238
|
-
"actions": ["capture the human turn as \"gtd(human): grilling\""],
|
|
239
|
-
"commits": ["gtd(human): grilling", "gtd: architecting"]
|
|
240
|
-
}
|
|
73
|
+
{ "state": "grilling", "subject": "gtd(human): grilling" }
|
|
241
74
|
```
|
|
242
75
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
76
|
+
## `gtd next [--json]`
|
|
77
|
+
|
|
78
|
+
Pure emitter of the resolved rest's rendered content — it **never mutates** the
|
|
79
|
+
repository (no commits, no file writes, no script execution). Resolves HEAD
|
|
80
|
+
exactly like `gtd step`, renders that state's declared
|
|
81
|
+
`script`/`prompt`/`message` template, and prints it. `kind` is never `"commit"`
|
|
82
|
+
here: resolution never rests at a commit state (entering one always ends the
|
|
83
|
+
process in the same step that entered it — see
|
|
84
|
+
[STATES.md §5](../STATES.md#5-resolution)).
|
|
247
85
|
|
|
248
|
-
|
|
86
|
+
Plain mode prints the rendered content verbatim (with exactly one trailing
|
|
87
|
+
newline) — never the `model`/`file`/`mode` hints, which are JSON-only. `--json`
|
|
88
|
+
emits `{state, actor, kind, content, model?, file?, mode?}`:
|
|
249
89
|
|
|
250
90
|
```json
|
|
251
91
|
{
|
|
252
92
|
"state": "building",
|
|
253
93
|
"actor": "agent",
|
|
254
|
-
"
|
|
255
|
-
"
|
|
94
|
+
"kind": "prompt",
|
|
95
|
+
"content": "You are an autonomous coding agent. ..."
|
|
256
96
|
}
|
|
257
97
|
```
|
|
258
98
|
|
|
259
99
|
- `state` — the resolved state.
|
|
260
|
-
- `actor` —
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
- `
|
|
270
|
-
|
|
271
|
-
|
|
100
|
+
- `actor` — the state's declared actor.
|
|
101
|
+
- `kind` — `"script"` | `"prompt"` | `"message"` — the dispatch key a driver
|
|
102
|
+
switches on (see [Driving the loop](loop.md)).
|
|
103
|
+
- `content` — the fully rendered template.
|
|
104
|
+
- `model` — the state's opaque `model:` hint, RENDERED through the same template
|
|
105
|
+
context as `content` (see
|
|
106
|
+
[Configuration](configuration.md#model--the-opaque-harness-hint-template-rendered)),
|
|
107
|
+
present only when the state declares one; **omitted entirely** (never `null`)
|
|
108
|
+
when unset.
|
|
109
|
+
- `file` — the state's declared steering file, RENDERED the same way; `mode` —
|
|
110
|
+
its format, verbatim (`"qa"` | `"review"`) (see
|
|
111
|
+
[Configuration](configuration.md#filemode--the-steering-file-association)).
|
|
112
|
+
Both present only when the state declares them; **omitted entirely** (never
|
|
113
|
+
`null`) otherwise.
|
|
114
|
+
|
|
115
|
+
## `gtd run`
|
|
116
|
+
|
|
117
|
+
The built-in driver for a `script`-content rest — the **only** place gtd itself
|
|
118
|
+
spawns a subprocess. Renders the resolved rest exactly like `gtd next`, executes
|
|
119
|
+
its content verbatim via `bash -c` (foreground, inherited stdio, exit code
|
|
120
|
+
deliberately ignored — a check script encodes its outcome in the tree, e.g.
|
|
121
|
+
writing a findings file, never in its exit status), then runs `gtd step <actor>`
|
|
122
|
+
for that state's own actor to capture the outcome in one command. Refuses (exit
|
|
123
|
+
non-zero, no execution, no step) when the resolved rest isn't a script:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
gtd run: "<state>" awaits a <kind> from "<actor>" — nothing scripted to run
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Reports the same `{state, subject}` (or `committed: …` / `nothing to do at "…"`)
|
|
130
|
+
as `gtd step` for the capturing step it performs. Takes no arguments — extra
|
|
131
|
+
positional args are rejected.
|
|
132
|
+
|
|
133
|
+
## `gtd status [--json]`
|
|
134
|
+
|
|
135
|
+
Pure, read-only dry-run reporter — the same resolution `gtd next` performs, but
|
|
136
|
+
reporting the resolved state/actor and, for every pending change, which declared
|
|
137
|
+
`on` pattern (if any) matches it — no mutation, and no CONTENT rendering (the
|
|
138
|
+
`script`/`prompt`/`message`/`commit` template is never rendered here, unlike
|
|
139
|
+
`gtd next`). It DOES render the resolved state's `model:`/`file:` hints (if
|
|
140
|
+
declared) through the same `it.vars`-carrying template context `gtd next` uses —
|
|
141
|
+
see
|
|
142
|
+
[Configuration](configuration.md#model--the-opaque-harness-hint-template-rendered)
|
|
143
|
+
— so a templated `model:`/`file:` failing to render fails `gtd status` too,
|
|
144
|
+
exactly like it would fail `gtd next`.
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
State: working
|
|
148
|
+
Awaits: agent
|
|
149
|
+
Pending:
|
|
150
|
+
A DONE.md -> A DONE.md
|
|
151
|
+
A scratch.txt -> (no match)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
or, on a clean tree: `Pending: (clean)`. A `Model: <value>` line appears right
|
|
155
|
+
after `Awaits:` when the resolved state declares a `model:` hint, and
|
|
156
|
+
`File: <value>`/`Mode: <value>` lines appear after that (in that order) when
|
|
157
|
+
declared — each independently, only when set.
|
|
158
|
+
|
|
159
|
+
`--json` emits
|
|
160
|
+
`{state, actor, changes: [{status, path, pattern}], model?, file?, mode?}` —
|
|
161
|
+
`pattern` is `null` when no declared row matches that change; `model`/`file`/
|
|
162
|
+
`mode` are present only when the resolved state declares them (omitted entirely,
|
|
163
|
+
never `null`, otherwise):
|
|
272
164
|
|
|
273
165
|
```json
|
|
274
166
|
{
|
|
275
|
-
"state": "
|
|
276
|
-
"actor": "
|
|
277
|
-
"
|
|
278
|
-
|
|
167
|
+
"state": "working",
|
|
168
|
+
"actor": "agent",
|
|
169
|
+
"changes": [
|
|
170
|
+
{ "status": "A", "path": "DONE.md", "pattern": "A DONE.md" },
|
|
171
|
+
{ "status": "A", "path": "scratch.txt", "pattern": null }
|
|
172
|
+
]
|
|
279
173
|
}
|
|
280
174
|
```
|
|
281
175
|
|
|
282
|
-
`
|
|
283
|
-
idle with a green health check).
|
|
284
|
-
|
|
285
|
-
**`questions`** — `{file, questions, errors}`:
|
|
286
|
-
|
|
287
|
-
```json
|
|
288
|
-
{
|
|
289
|
-
"file": ".gtd/TODO.md",
|
|
290
|
-
"questions": [
|
|
291
|
-
{
|
|
292
|
-
"question": "Which operations?",
|
|
293
|
-
"status": "suggested",
|
|
294
|
-
"text": "add and subtract."
|
|
295
|
-
}
|
|
296
|
-
],
|
|
297
|
-
"errors": []
|
|
298
|
-
}
|
|
299
|
-
```
|
|
176
|
+
`gtd status` takes no arguments — extra positional args are rejected.
|
|
300
177
|
|
|
301
|
-
|
|
302
|
-
present. `errors` lists any structural problems in the file — the same diagnosis
|
|
303
|
-
that would make `gtd step-agent` refuse the agent's next turn capture.
|
|
178
|
+
## `gtd format <file>`
|
|
304
179
|
|
|
305
|
-
|
|
180
|
+
Formats a markdown file in place with a bundled prettier (`parser: "markdown"`,
|
|
181
|
+
`printWidth: 80`, `proseWrap: "always"`), ignoring the host repo's own
|
|
182
|
+
`.prettierrc` so `.gtd/`-tracked files stay consistently formatted regardless of
|
|
183
|
+
the host project's toolchain. Rejects `--json` (exit 1,
|
|
184
|
+
`gtd format does not accept --json`) — it's a plain file operation, not a state
|
|
185
|
+
command.
|
|
306
186
|
|
|
307
|
-
|
|
308
|
-
{
|
|
309
|
-
"file": ".gtd/REVIEW.md",
|
|
310
|
-
"shortHash": "abc1234",
|
|
311
|
-
"fullHash": "abc1234def5678901234567890123456789abcd",
|
|
312
|
-
"changesets": [
|
|
313
|
-
{
|
|
314
|
-
"title": "Add calculator",
|
|
315
|
-
"description": "New add function for the calculator.",
|
|
316
|
-
"files": [{ "path": "./src/calc.ts", "line": 1, "checked": false }]
|
|
317
|
-
}
|
|
318
|
-
],
|
|
319
|
-
"errors": []
|
|
320
|
-
}
|
|
321
|
-
```
|
|
187
|
+
Errors (all exit 1, message on stderr):
|
|
322
188
|
|
|
323
|
-
|
|
324
|
-
`
|
|
189
|
+
- Missing path: `gtd format: missing file path argument`
|
|
190
|
+
- Extra arguments: `gtd format: too many arguments — expected one path, got: …`
|
|
191
|
+
- Non-markdown file:
|
|
192
|
+
`gtd format: <file> is not a markdown file (expected .md or .markdown)`
|
|
193
|
+
- File not found: `gtd: skipped formatting <file>: not found`
|
|
325
194
|
|
|
326
|
-
|
|
327
|
-
|
|
195
|
+
## `gtd lsp`
|
|
196
|
+
|
|
197
|
+
Starts an LSP server over stdio for `.gtd/` steering files — document symbols
|
|
198
|
+
for a `qa`-mode file's open questions and a `review`-mode file's review
|
|
199
|
+
chunks/hunks, code actions to check/uncheck a hunk or a whole chunk, and
|
|
200
|
+
diagnostics publishing the same parser findings the bundled workflow's
|
|
201
|
+
`.gtd/FORMAT.md` validators produce (see `src/OpenQuestions.ts` /
|
|
202
|
+
`src/ReviewDoc.ts` and
|
|
203
|
+
[STATES.md §10](../STATES.md#10-the-bundled-default-workflow)).
|
|
204
|
+
|
|
205
|
+
**Config-driven** (see
|
|
206
|
+
[docs/design/state-file-association.md](design/state-file-association.md)): the
|
|
207
|
+
server locates the active gtd config the same way the CLI does, from the
|
|
208
|
+
`initialize` request's workspace root (falling back to the open document's own
|
|
209
|
+
directory), renders every state's `file:` into an absolute-path → `mode` map,
|
|
210
|
+
and dispatches on it — first declaring state wins a path conflict. A path the
|
|
211
|
+
map doesn't cover (or no config at all) falls back to the basename dispatch
|
|
212
|
+
(`TODO.md` → `qa`, `REVIEW.md` → `review`), so the server still works standalone
|
|
213
|
+
with no `.gtdrc` in sight. Also registers an `executeCommand`,
|
|
214
|
+
`gtd.openSteeringFile`: resolves the current state exactly like `gtd status`
|
|
215
|
+
(config + git HEAD) and asks the client to show its `file:`
|
|
216
|
+
(`window/showDocument`); a state with no `file:` gets an informational message
|
|
217
|
+
naming the state instead — bind it to an editor keybinding for a "jump to the
|
|
218
|
+
active steering file" command.
|
|
219
|
+
|
|
220
|
+
Dispatched before the repository-root guard and auto-init, like `gtd format`.
|
|
221
|
+
Rejects `--json` (exit 1, `gtd lsp does not accept --json`) and extra positional
|
|
222
|
+
arguments — it's a long-running server, not a state command. Runs until the
|
|
223
|
+
client disconnects (the LSP `exit` notification), then exits cleanly.
|
|
224
|
+
|
|
225
|
+
## Error envelope
|
|
226
|
+
|
|
227
|
+
Every command, in `--json` mode, reports a failure as a machine-readable
|
|
228
|
+
envelope on **stdout**, and still exits 1:
|
|
328
229
|
|
|
329
230
|
```json
|
|
330
231
|
{ "state": "error", "prompt": "<message>" }
|
|
331
232
|
```
|
|
332
233
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
auto-advance flag.
|
|
234
|
+
A human-readable `gtd: <message>` line is still written to **stderr** regardless
|
|
235
|
+
of `--json` — the envelope adds a structured stdout channel, it does not replace
|
|
236
|
+
the plain-text one.
|
|
337
237
|
|
|
338
238
|
## Repository requirements
|
|
339
239
|
|
|
340
|
-
- **Single writer, linear branch.**
|
|
341
|
-
|
|
342
|
-
— it degrades gracefully on the default branch rather than crashing, but do
|
|
343
|
-
not rely on merge commits mid-cycle.
|
|
240
|
+
- **Single writer, linear branch.** A process's history is walked via
|
|
241
|
+
**first-parent** commits only.
|
|
344
242
|
- **Test/build artifacts must be gitignored.** This is **load-bearing**, not a
|
|
345
|
-
style preference: every
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
243
|
+
style preference: every step decision detects "clean" via
|
|
244
|
+
`git diff --name-status HEAD` (tracked changes) unioned with
|
|
245
|
+
`git ls-files --others --exclude-standard` (untracked files), which silently
|
|
246
|
+
omits anything matched by `.gitignore`. If a `script` state's command (or the
|
|
247
|
+
build it triggers) writes tracked-but-untracked output — a `dist/`, a coverage
|
|
248
|
+
report, a log file — into the working tree, the tree never goes clean after a
|
|
249
|
+
green run, and the check's `"C"` pattern never fires. Gitignore every path
|
|
250
|
+
your scripts write before wiring gtd into a repo.
|
|
251
|
+
- **Repository root invocation.** Every state subcommand (`step`/`next`/`run`/
|
|
252
|
+
`status`) must run from the git repository root — the workflow, pending
|
|
253
|
+
changes, and process history are resolved against the process cwd.
|
|
254
|
+
`--help`/`--version`, `format`, and `lsp` skip this guard entirely (and any
|
|
255
|
+
git/`.gtdrc` dependency along with it).
|