create-anpunkit 2.0.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/bin/cli.js +3 -2
  2. package/package.json +1 -1
  3. package/template/.claude/agents/e2e-runner.md +44 -13
  4. package/template/.claude/agents/implementer.md +13 -7
  5. package/template/.claude/agents/infra-provisioner.md +33 -2
  6. package/template/.claude/agents/planner.md +79 -6
  7. package/template/.claude/agents/researcher.md +19 -8
  8. package/template/.claude/agents/spec-author.md +118 -0
  9. package/template/.claude/agents/test-author.md +76 -43
  10. package/template/.claude/anpunkit-manifest.json +47 -27
  11. package/template/.claude/commands/infra.md +28 -3
  12. package/template/.claude/commands/overview.md +84 -24
  13. package/template/.claude/commands/phase.md +139 -40
  14. package/template/.claude/commands/replan.md +23 -9
  15. package/template/.cursor/commands/infra.md +26 -1
  16. package/template/.cursor/commands/overview.md +83 -23
  17. package/template/.cursor/commands/phase.md +138 -39
  18. package/template/.cursor/commands/replan.md +22 -8
  19. package/template/.gitattributes +1 -0
  20. package/template/AGENTS.md +215 -36
  21. package/template/CLAUDE.md +1 -0
  22. package/template/README.md +59 -23
  23. package/template/anpunkit.png +0 -0
  24. package/template/commands.src/infra.md +28 -3
  25. package/template/commands.src/overview.md +84 -24
  26. package/template/commands.src/phase.md +139 -40
  27. package/template/commands.src/replan.md +23 -9
  28. package/template/docs/DESIGN_LOG.md +192 -1
  29. package/template/index.html +339 -0
  30. package/template/scripts/spec-conformance.sh +93 -0
  31. package/template/scripts/spec-staleness.sh +115 -0
  32. package/template/setup.sh +110 -47
  33. package/template/tests/helpers/spec-assert.py +162 -0
  34. package/template/tests/helpers/spec-assert.ts +158 -0
@@ -1,5 +1,5 @@
1
1
  Caveman ULTRA mode. You are the ORCHESTRATOR. Route work to subagents —
2
- you do NOT implement or debug yourself.
2
+ you do NOT implement, fill specs, or debug yourself.
3
3
 
4
4
  Note: subagents cannot talk to the user. Only YOU can.
5
5
 
@@ -24,8 +24,21 @@ b. PHASE STATE CHECK: Read docs/STATE.md and docs/PLAN.md.
24
24
  c. FINAL PHASE CHECK: Read docs/PLAN.md. Is this the last phase (no further
25
25
  pending phases after this one)? Record this as IS_FINAL_PHASE=true/false.
26
26
 
27
- d. AUTH NUDGE: if INFRA.md exists and auth marker absent, remind me to run
28
- `scripts/auth-setup.sh`. Not a gate just a reminder.
27
+ d. AUTH LIVENESS GATE (hard rule 16): if this phase will run a boundary/E2E suite,
28
+ confirm every credential it needs is live NOW.
29
+ - If INFRA.md has no `AUTH PROOF: PASS` marker -> STOP: "Auth never proven
30
+ reusable. Run `/infra` first."
31
+ - Run `scripts/auth-setup.sh --check` (Entra token obtainable + not expired)
32
+ and, for each external system this phase touches (docs/DATAFLOW.md external
33
+ rows + docs/ENDPOINTS.md auth column), confirm its credential is obtainable
34
+ headlessly. Any failure -> boundary/E2E is BLOCKED; tell me what to run; the
35
+ MOCK suite may still proceed.
36
+
37
+ e. FRONTEND TRIGGER (hard rule 13): read docs/OVERVIEW.md `has_frontend` + the
38
+ frontend root. Set FRONTEND_PHASE=true iff `has_frontend: true` AND this
39
+ phase's `changes` (docs/PLAN.md) include any path under the frontend root.
40
+ This is a PATH MATCH, not a judgment call. Record FRONTEND_PHASE — it gates the
41
+ `ui` boundary run + evidence at CLOSE.
29
42
 
30
43
  ---
31
44
 
@@ -35,52 +48,120 @@ Dispatch `researcher` in IMPL mode scoped to this phase.
35
48
  Returns terse summary + path. Read the file only if needed.
36
49
  Unknowns block the phase -> re-dispatch narrowed. No guessing.
37
50
 
51
+ DATASOURCE DELTA (hard rule 15): if this phase tests against an external
52
+ datasource, compare what it touches to the confirmed BASELINE in
53
+ docs/research/datasource-<name>.md. If it touches a NEW table/column beyond the
54
+ baseline -> surface my understanding of just that delta as a falsifiable claim;
55
+ WAIT for confirm; append it to datasource-<name>.md. If it touches only confirmed
56
+ data -> proceed with a one-line note, no stop. Boundary/E2E against an UNCONFIRMED
57
+ datasource is HARD-BLOCKED (mock still runs). The confirmed baseline is what
58
+ `spec-author` grounds fixtures in.
59
+
38
60
  Then classify the phase:
39
61
 
40
62
  `TDD_PHASE` = the phase adds or changes a PUBLIC CALLABLE SURFACE (endpoint,
41
63
  exported function/class, CLI command, message contract) assertable from the
42
64
  acceptance spec. Size is NOT the criterion.
43
65
 
44
- - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3a → §3b).
66
+ - Clear public surface -> `TDD_PHASE=true` -> run the TDD path (§2 → §3 → §4 → §5 → §6 → §7).
45
67
  - Pure infra/config/doc, no public surface -> `TDD_PHASE=false` -> run the
46
68
  non-TDD path (§2N → §3N).
47
69
  - AMBIGUOUS -> default `TDD_PHASE=true`, but STATE the classification + the reason
48
- to me, so I can override to non-TDD BEFORE SCAFFOLD fires. (Hard rule 11: never
49
- downgrade a TDD phase just to dodge the RED gate.)
70
+ to me, so I can override to non-TDD BEFORE SPEC fill fires. (Hard rule 11: never
71
+ downgrade a TDD phase just to dodge the gates.)
50
72
 
51
73
  =====================================================================
52
74
  ## TDD PATH (TDD_PHASE=true)
53
75
  =====================================================================
54
76
 
55
- ## 2. SCAFFOLD
77
+ ## 2. SPEC FILL + STALENESS
78
+
79
+ a. SKELETON CHECK: confirm docs/spec-phase-<n>.md exists (planner generated it at
80
+ /overview). If MISSING (planner classified it non-TDD, or it's a new phase from
81
+ /replan): generate the skeleton NOW from this phase's PLAN.md `acceptance` +
82
+ `dataflow:` transitions in the planner skeleton format (generated header + named
83
+ `TBD` rows), then `bash scripts/spec-staleness.sh stamp <n>` to stamp its hash.
84
+
85
+ b. Dispatch `spec-author`. It fills each case row with a real input payload
86
+ (`fixtures/<case-id>-input.json`), concrete expected output
87
+ (`fixtures/<case-id>-expected.json`), matcher tokens for volatile fields,
88
+ `error-code` for failures, and `selector/assert/value` `ui` descriptors —
89
+ grounded in the RESEARCH findings + the confirmed datasource baseline.
90
+
91
+ c. CASE-SET-DIVERGENCE (hard re-entry, hard rule 12 / §5.52): if `spec-author`
92
+ returns `CASE-SET-DIVERGENCE` (a required case can't be filled from real facts,
93
+ or research revealed an unlisted/contradicted case) -> STOP. Surface the finding.
94
+ I amend the up-front case-name contract in the skeleton; you re-stamp
95
+ (`bash scripts/spec-staleness.sh stamp <n>`); then re-dispatch `spec-author` to
96
+ re-fill from scratch. AI never amends the case-name set — I own the contract.
97
+
98
+ d. STALENESS (hard rule 17): run `bash scripts/spec-staleness.sh <n>`. Nonzero
99
+ (upstream PLAN acceptance line / DATAFLOW rows drifted since the skeleton was
100
+ stamped, e.g. via /replan) -> regenerate the skeleton header from current
101
+ PLAN/DATAFLOW, re-stamp, re-dispatch `spec-author`. Do NOT hand-edit the hash.
102
+
103
+ ## 3. SPEC REVIEW — human gate (hard rule 12)
104
+
105
+ STOP. Surface the FILLED cases to me as FALSIFIABLE CLAIMS in plain language, e.g.:
106
+ - "POST /orders/submit with an empty line-item list → 422 EMPTY_ORDER."
107
+ - "Successful submit of a 3-line order → 201; order.id is a UUID; order.status is
108
+ 'submitted'."
109
+ Re-run `bash scripts/spec-staleness.sh <n>` at entry (nonzero -> back to §2d).
110
+ SCAFFOLD cannot begin until I confirm. Classify any rejection WITH me (§5.50):
111
+ - WRONG EXPECTED -> fix the case row + `fixtures/<case-id>-expected.json`; no
112
+ re-research. (You may patch the fixture directly per my correction.)
113
+ - WRONG INPUT SHAPE -> re-dispatch `spec-author` with the correction.
114
+ - NEW CASE or CONTRADICTED CASE -> hard re-entry (§2c): I amend the skeleton, you
115
+ re-stamp, re-confirm the amended case(s) + any case sharing their `covers` id
116
+ (the staleness hash certifies the unchanged remainder — not re-read), re-fill.
117
+ Loop until I approve. Unskippable on TDD phases.
118
+
119
+ ## 4. SCAFFOLD
56
120
 
57
121
  Dispatch `implementer` in SCAFFOLD mode: interface stubs only (signatures +
58
- types; bodies raise NotImplementedError / return 501); NO logic, NO tests.
59
- Returns the stub files + the interface surface.
122
+ types; bodies raise NotImplementedError / return 501); NO logic, NO tests, NO
123
+ edits to the spec or fixtures. Returns the stub files + the interface surface.
124
+
125
+ ## 5. RED
60
126
 
61
- ## 3a. RED
127
+ Dispatch `test-author` to EMIT the boundary harness from the locked spec `data`
128
+ rows: one deep-equality assertion per case against `fixtures/<case-id>-expected.json`
129
+ via the kit comparator `tests/helpers/spec-assert.*`, each citing its case with a
130
+ `# spec: <case-id>` comment. It does NOT author assertions — it generates them from
131
+ the spec. Place contract/ENDPOINTS/transition tests in `tests/regression/`,
132
+ phase-local in `tests/phase-<n>/`.
62
133
 
63
- Dispatch `test-author` to write the REAL API suite (+ mock) BLIND against the
64
- stubs + acceptance. Place contract/ENDPOINTS tests in `tests/regression/`,
65
- phase-local tests in `tests/phase-<n>/`. Run the suite.
134
+ If FRONTEND_PHASE (and the phase has `ui` cases): also dispatch `e2e-runner` to EMIT
135
+ Playwright assertions from each `ui` case's `fixtures/<case-id>-ui.json` descriptor,
136
+ each citing `// spec: <case-id>`. Run the suites.
66
137
 
67
- RED GATE = every acceptance test COLLECTS cleanly AND FAILS (assertion /
68
- NotImplemented).
69
- - Any test PASSES on stubs -> STOP (spec trivial or test wrong); show me.
138
+ RED GATE = every case test COLLECTS cleanly AND FAILS (assertion / NotImplemented).
139
+ - Any test PASSES on stubs -> STOP (spec trivial or emitter wrong); show me.
70
140
  - Collection / import / syntax error -> stub mismatch; re-dispatch SCAFFOLD to
71
141
  fix SIGNATURES (not logic); re-run.
72
- - UNDERSPEC -> STOP; ask me to sharpen the acceptance spec.
73
142
 
74
- ## 3b. GREEN
143
+ ## 6. CONFORMANCE GATE (hard rule 18) — replaces the v2.1 human TEST REVIEW
144
+
145
+ Run `bash scripts/spec-conformance.sh <n>`. It loud-fails (and BLOCKS GREEN) if:
146
+ - any `TBD` marker remains in docs/spec-phase-<n>.md or a referenced fixture, OR
147
+ - any case-id in the spec table has no boundary test citing it (`# spec: <case-id>`).
148
+ Nonzero -> fix the gap (re-dispatch `spec-author` for a stray TBD, or `test-author`/
149
+ `e2e-runner` for a missing citation) and re-run. GREEN cannot start until it passes.
150
+
151
+ ## 7. GREEN + BOUNDARY/E2E
75
152
 
76
- Dispatch `implementer` in FILL mode with the phase spec + research + the test
77
- file paths (it MAY read the tests — frozen before logic, no overfit — but must
78
- NOT edit them). Fill to green. Budget 3, WARN@2, STUCK@3.
153
+ Dispatch `implementer` in FILL mode with the FILLED docs/spec-phase-<n>.md + its
154
+ fixtures + research + the generated test file paths (it MAY read the tests — frozen
155
+ before logic, no overfit but must NOT edit tests, spec, or fixtures). Fill to
156
+ green against the spec. Budget 3, WARN@2, STUCK@3.
79
157
 
80
- Dispatch `e2e-runner` IF this phase touches the frontend (reads INFRA.md target;
81
- `scripts/e2e-stack.sh up` / Playwright / `down`).
158
+ Run the BOUNDARY suite (real HTTP/CLI/message; `TEST_MODE=real`). If FRONTEND_PHASE,
159
+ `e2e-runner` runs its emitted `ui` specs — MANDATORY (hard rule 13) — reads INFRA.md
160
+ target, runs `scripts/e2e-stack.sh up` / Playwright / `down`, and captures a
161
+ screenshot at EACH UI-existence assertion regardless of pass/fail to
162
+ docs/evidence/e2e-phase-<n>/, with a summary in docs/research/e2e-<slug>.md.
82
163
 
83
- PHASE GATE (rule 5) -> go to §456 (see GATE below).
164
+ PHASE GATE (rule 5) -> go to §8910 (see GATE below).
84
165
 
85
166
  =====================================================================
86
167
  ## NON-TDD PATH (TDD_PHASE=false)
@@ -95,16 +176,19 @@ includes "deployed URL" before proceeding.
95
176
 
96
177
  ## 3N. TEST (blind)
97
178
 
98
- Dispatch `test-author`. It writes MOCK + REAL API suites from the acceptance
99
- spec — never reads the logic. (e2e-runner only if frontend.)
179
+ Dispatch `test-author`. It writes MOCK + boundary suites from the acceptance
180
+ spec — never reads the logic. (No spec file, SPEC REVIEW, or conformance gate on
181
+ the non-TDD path — no public surface to contract. e2e-runner only if FRONTEND_PHASE.)
100
182
 
101
183
  =====================================================================
102
184
 
103
185
  ## GATE (both paths)
104
186
 
105
- PHASE GATE = current-phase REAL API suite passes AND (if frontend) E2E passes AND
106
- the accumulated mock regression corpus stays green AND every docs/ENDPOINTS.md
107
- entry has a regression test (checked at CLOSE).
187
+ PHASE GATE = current-phase BOUNDARY suite passes AND (FRONTEND_PHASE) the `ui`
188
+ boundary passes WITH evidence captured AND the accumulated mock regression corpus
189
+ stays green AND every docs/ENDPOINTS.md entry has a regression test AND (TDD)
190
+ `spec-conformance.sh` passed AND every REACHABLE docs/DATAFLOW.md transition has a
191
+ filled case in the phase spec (all checked at CLOSE).
108
192
  - GATE PASS -> go to CLOSE.
109
193
  - GATE BLOCKED (SERVICE UNAVAILABLE, STACK NOT READY, AZURE UNAVAILABLE, FLAKE)
110
194
  -> tell me, wait. Not a code bug. For AZURE UNAVAILABLE: suggest `/infra verify`.
@@ -112,17 +196,17 @@ entry has a regression test (checked at CLOSE).
112
196
 
113
197
  ---
114
198
 
115
- ## 4. FIX
199
+ ## 8. FIX
116
200
 
117
201
  Dispatch `debugger` (isolated context) on the specific failure.
118
- - FIXED -> re-run TEST (and the regression corpus).
202
+ - FIXED -> re-run the boundary suite (and the regression corpus).
119
203
  - SERVICE UNAVAILABLE -> tell me, wait. Suggest `/infra verify` if Azure.
120
204
  - WARN (2 attempts failed) -> relay immediately, then let debugger finish attempt 3.
121
205
  - STUCK -> go to ESCALATE.
122
206
 
123
207
  ---
124
208
 
125
- ## 5. ESCALATE — circuit breaker. Mode B.
209
+ ## 9. ESCALATE — circuit breaker. Mode B.
126
210
 
127
211
  FIRST STUCK: STOP. Present to me: the problem, 3 failed hypotheses, the
128
212
  debugger's recommendation, the debug file path. Ask what to do. Wait. Options:
@@ -135,19 +219,32 @@ what to try next. Hand control to me.
135
219
 
136
220
  ---
137
221
 
138
- ## 6. CLOSE
222
+ ## 10. CLOSE
139
223
 
140
- REGRESSION GATE (before closing — Feature 3):
141
- - Run `scripts/regression.sh` (mock corpus). A failure BLOCKS close -> route to FIX.
224
+ REGRESSION + COVERAGE GATES (before closing — all FAIL HARD, do not close):
225
+ - Run `bash scripts/regression.sh` (mock corpus). A failure BLOCKS close -> route to FIX.
142
226
  - ENDPOINTS COVERAGE: every `docs/ENDPOINTS.md` entry MUST have >=1 test in
143
- `tests/regression/`. Zero coverage -> FAIL HARD; do not close.
144
- - IF IS_FINAL_PHASE: additionally run `scripts/regression.sh --real` (full real
227
+ `tests/regression/`. Zero coverage -> FAIL HARD.
228
+ - DATAFLOW COVERAGE (hard rule 14, re-seamed v2.2): every `docs/DATAFLOW.md`
229
+ transition whose trigger is REACHABLE in the code shipped so far MUST have >=1
230
+ FILLED CASE in docs/spec-phase-<n>.md. Zero coverage on a reachable transition ->
231
+ FAIL HARD. Unreachable transitions list as PENDING (not failed). IF
232
+ IS_FINAL_PHASE: any transition still PENDING -> FAIL HARD. (The case→test half is
233
+ already enforced by `spec-conformance.sh` at §6 — every case-id is cited by a
234
+ boundary test, which by placement lands in tests/regression/.)
235
+ - EVIDENCE (FRONTEND_PHASE only, hard rule 13): docs/evidence/e2e-phase-<n>/ must
236
+ contain at least the per-UI-existence-assertion screenshots. Empty -> FAIL HARD.
237
+ - IF IS_FINAL_PHASE: additionally run `bash scripts/regression.sh --real` (full real
145
238
  corpus). A failure blocks close.
146
239
 
147
240
  Mark phase `done` in docs/PLAN.md.
148
241
 
149
- ARCHITECTURE SELF-CHECK: did this phase add/remove/rename an agent, hook, or
150
- command, or change a workflow rule? YES -> run `/log-decision`. NO -> state why not.
242
+ ARCHITECTURE / DATAFLOW SELF-CHECK:
243
+ - Did this phase add/remove/rename an agent, hook, or command, or change a
244
+ workflow rule? YES -> run `/log-decision`. NO -> state why not.
245
+ - Did this phase add/change an object's STATE LIFECYCLE? YES -> update
246
+ docs/DATAFLOW.md (hard rule 9) in this CLOSE, and confirm new reachable
247
+ transitions are covered by a filled case. NO -> state why not.
151
248
 
152
249
  IF IS_FINAL_PHASE — FINAL CLOSE sequence:
153
250
 
@@ -170,6 +267,7 @@ IF IS_FINAL_PHASE — FINAL CLOSE sequence:
170
267
 
171
268
  ## Docs
172
269
  - Full endpoint catalogue: docs/ENDPOINTS.md
270
+ - Object/state flow: docs/DATAFLOW.md
173
271
  - Infrastructure: docs/INFRA.md
174
272
  - Project history: docs/HISTORY.md
175
273
  ```
@@ -189,6 +287,7 @@ After each step, update docs/STATE.md:
189
287
 
190
288
  phase: <n> (in progress)
191
289
  tdd: <true|false>
290
+ frontend_phase: <true|false>
192
291
  completed: <steps done so far>
193
292
  next: <exact next step>
194
293
  blocker: <none or open issue>
@@ -20,10 +20,13 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
20
20
  - A new external service is mentioned (Stripe, Twilio, a new Azure service, etc.)
21
21
  - The change involves architecture (a new integration pattern, auth change, etc.)
22
22
  - A service tier or quota change is implied
23
+ - A new external DATASOURCE or a change to an object's STATE LIFECYCLE
23
24
 
24
25
  If ANY of these signals are present: dispatch `researcher` in DESIGN mode
25
- with the specific new service/pattern as the DESIGN TOPICS list. Show me the
26
- key findings before proceeding to step 3.
26
+ with the specific new service/pattern as the DESIGN TOPICS list. For a new
27
+ datasource, it drafts a DATA UNDERSTANDING; surface it to me as a falsifiable
28
+ claim and confirm (baseline) before proceeding. Show me the key findings
29
+ before step 3.
27
30
 
28
31
  If none: proceed directly to step 3 (impl-research may still be dispatched
29
32
  in step 3 for non-trivial changes per the original logic).
@@ -32,11 +35,13 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
32
35
  was not needed, dispatch `researcher` in IMPL mode to ground the re-plan
33
36
  in facts.
34
37
 
35
- 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md. It must:
38
+ 4. RE-PLAN. Dispatch `planner` with the change + current PLAN.md + DATAFLOW.md.
39
+ It must:
36
40
  - Keep done phases untouched.
37
41
  - Insert / cut / split / merge / reorder only PENDING phases.
38
42
  - Place new phases in correct DEPENDENCY order.
39
43
  - Keep every phase a vertical slice with its own acceptance spec.
44
+ - Preserve the UI-existence criterion on any frontend-touching phase.
40
45
  - Ensure the LAST pending phase still contains the deploy task block.
41
46
  - Renumber pending phases if needed; update STATE.md `phase:` pointer.
42
47
 
@@ -49,11 +54,20 @@ Use when PLAN.md no longer matches reality. Change: $ARGUMENTS
49
54
  reconciled corpus still passes against live services. A failure -> surface it
50
55
  and stop before approval.
51
56
 
52
- 6. SHOW ME the revised phase list + the regression-corpus changes, and STOP for
53
- approval.
57
+ 6. RECONCILE DATAFLOW.md (v2.1). If the re-plan adds, cuts, or re-scopes objects
58
+ or transitions, update docs/DATAFLOW.md in step:
59
+ - A CUT/removed object or transition -> remove its row(s) and retire the
60
+ matching regression test(s).
61
+ - A new object/transition -> add the row(s); mark them PENDING until the phase
62
+ that makes them reachable runs. The deploy-last / "no PENDING at final phase"
63
+ invariant (hard rule 14) still holds.
64
+ - A reorder must not strand a transition as permanently unreachable.
54
65
 
55
- 7. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
66
+ 7. SHOW ME the revised phase list + the regression-corpus changes + the
67
+ DATAFLOW.md changes, and STOP for approval.
68
+
69
+ 8. ARCHITECTURE SELF-CHECK: re-planning is not normally a kit-architecture
56
70
  change. Only run /log-decision if the workflow itself changed (rare).
57
71
 
58
- Report what changed: phases added / cut / split / reordered, and regression
59
- tests retired / consolidated.
72
+ Report what changed: phases added / cut / split / reordered, regression tests
73
+ retired / consolidated, and DATAFLOW rows added / removed.
@@ -5,6 +5,7 @@
5
5
  *.js text eol=lf
6
6
  *.mjs text eol=lf
7
7
  *.ts text eol=lf
8
+ *.py text eol=lf
8
9
  *.json text eol=lf
9
10
  *.md text eol=lf
10
11
  *.ps1 text eol=crlf