@haaaiawd/anws 2.3.0 → 2.4.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 (92) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +52 -22
  3. package/lib/diff.js +5 -2
  4. package/lib/init.js +217 -96
  5. package/lib/install-state.js +18 -3
  6. package/lib/manifest.js +376 -79
  7. package/lib/prompt.js +68 -0
  8. package/lib/resources/index.js +36 -2
  9. package/lib/update.js +12 -6
  10. package/package.json +48 -47
  11. package/templates/.agents/skills/anws-system/SKILL.md +108 -108
  12. package/templates/.agents/skills/code-reviewer/SKILL.md +170 -115
  13. package/templates/.agents/skills/concept-modeler/SKILL.md +230 -179
  14. package/templates/.agents/skills/craft-authoring/SKILL.md +186 -183
  15. package/templates/.agents/skills/craft-authoring/references/BUNDLE_POLICY.md +61 -0
  16. package/templates/.agents/skills/design-reviewer/SKILL.md +265 -190
  17. package/templates/.agents/skills/e2e-testing-guide/SKILL.md +246 -135
  18. package/templates/.agents/skills/nexus-mapper/SKILL.md +321 -321
  19. package/templates/.agents/skills/output-contract/SKILL.md +37 -0
  20. package/templates/.agents/skills/report-template/SKILL.md +92 -92
  21. package/templates/.agents/skills/sequential-thinking/SKILL.md +222 -225
  22. package/templates/.agents/skills/spec-writer/SKILL.md +75 -30
  23. package/templates/.agents/skills/system-architect/SKILL.md +538 -678
  24. package/templates/.agents/skills/system-designer/SKILL.md +601 -601
  25. package/templates/.agents/skills/task-planner/SKILL.md +1 -2
  26. package/templates/.agents/skills/task-reviewer/SKILL.md +428 -388
  27. package/templates/.agents/skills/tech-evaluator/SKILL.md +252 -144
  28. package/templates/.agents/workflows/blueprint.md +157 -69
  29. package/templates/.agents/workflows/challenge.md +331 -497
  30. package/templates/.agents/workflows/change.md +182 -339
  31. package/templates/.agents/workflows/craft.md +159 -197
  32. package/templates/.agents/workflows/design-system.md +202 -674
  33. package/templates/.agents/workflows/explore.md +187 -399
  34. package/templates/.agents/workflows/forge.md +650 -609
  35. package/templates/.agents/workflows/genesis.md +439 -351
  36. package/templates/.agents/workflows/probe.md +219 -241
  37. package/templates/.agents/workflows/quickstart.md +302 -123
  38. package/templates/.agents/workflows/upgrade.md +145 -182
  39. package/templates_en/.agents/skills/anws-system/SKILL.md +108 -0
  40. package/templates_en/.agents/skills/code-reviewer/SKILL.md +170 -0
  41. package/templates_en/.agents/skills/concept-modeler/SKILL.md +230 -0
  42. package/templates_en/.agents/skills/craft-authoring/SKILL.md +179 -0
  43. package/templates_en/.agents/skills/craft-authoring/references/BUNDLE_POLICY.md +60 -0
  44. package/templates_en/.agents/skills/craft-authoring/references/PROMPT_QUALITY_RUBRIC.md +92 -0
  45. package/templates_en/.agents/skills/craft-authoring/references/SCORECARD_TEMPLATE.md +52 -0
  46. package/templates_en/.agents/skills/design-reviewer/SKILL.md +265 -0
  47. package/templates_en/.agents/skills/e2e-testing-guide/SKILL.md +246 -0
  48. package/templates_en/.agents/skills/nexus-mapper/SKILL.md +306 -0
  49. package/templates_en/.agents/skills/nexus-mapper/references/language-customization.md +167 -0
  50. package/templates_en/.agents/skills/nexus-mapper/references/output-schema.md +311 -0
  51. package/templates_en/.agents/skills/nexus-mapper/references/probe-protocol.md +246 -0
  52. package/templates_en/.agents/skills/nexus-mapper/scripts/extract_ast.py +706 -0
  53. package/templates_en/.agents/skills/nexus-mapper/scripts/git_detective.py +194 -0
  54. package/templates_en/.agents/skills/nexus-mapper/scripts/languages.json +127 -0
  55. package/templates_en/.agents/skills/nexus-mapper/scripts/query_graph.py +556 -0
  56. package/templates_en/.agents/skills/nexus-mapper/scripts/requirements.txt +6 -0
  57. package/templates_en/.agents/skills/nexus-query/SKILL.md +114 -0
  58. package/templates_en/.agents/skills/nexus-query/scripts/extract_ast.py +706 -0
  59. package/templates_en/.agents/skills/nexus-query/scripts/git_detective.py +194 -0
  60. package/templates_en/.agents/skills/nexus-query/scripts/languages.json +127 -0
  61. package/templates_en/.agents/skills/nexus-query/scripts/query_graph.py +556 -0
  62. package/templates_en/.agents/skills/nexus-query/scripts/requirements.txt +6 -0
  63. package/templates_en/.agents/skills/output-contract/SKILL.md +37 -0
  64. package/templates_en/.agents/skills/report-template/SKILL.md +85 -0
  65. package/templates_en/.agents/skills/report-template/references/REPORT_TEMPLATE.md +100 -0
  66. package/templates_en/.agents/skills/runtime-inspector/SKILL.md +101 -0
  67. package/templates_en/.agents/skills/sequential-thinking/SKILL.md +214 -0
  68. package/templates_en/.agents/skills/spec-writer/SKILL.md +153 -0
  69. package/templates_en/.agents/skills/spec-writer/references/prd_template.md +177 -0
  70. package/templates_en/.agents/skills/system-architect/SKILL.md +538 -0
  71. package/templates_en/.agents/skills/system-architect/references/rfc_template.md +59 -0
  72. package/templates_en/.agents/skills/system-designer/SKILL.md +534 -0
  73. package/templates_en/.agents/skills/system-designer/references/system-design-detail-template.md +187 -0
  74. package/templates_en/.agents/skills/system-designer/references/system-design-template.md +605 -0
  75. package/templates_en/.agents/skills/task-planner/SKILL.md +251 -0
  76. package/templates_en/.agents/skills/task-planner/references/TASK_TEMPLATE_05A.md +109 -0
  77. package/templates_en/.agents/skills/task-planner/references/TASK_TEMPLATE_05B.md +176 -0
  78. package/templates_en/.agents/skills/task-reviewer/SKILL.md +428 -0
  79. package/templates_en/.agents/skills/tech-evaluator/SKILL.md +252 -0
  80. package/templates_en/.agents/skills/tech-evaluator/references/ADR_TEMPLATE.md +78 -0
  81. package/templates_en/.agents/workflows/blueprint.md +200 -0
  82. package/templates_en/.agents/workflows/challenge.md +331 -0
  83. package/templates_en/.agents/workflows/change.md +182 -0
  84. package/templates_en/.agents/workflows/craft.md +159 -0
  85. package/templates_en/.agents/workflows/design-system.md +202 -0
  86. package/templates_en/.agents/workflows/explore.md +187 -0
  87. package/templates_en/.agents/workflows/forge.md +651 -0
  88. package/templates_en/.agents/workflows/genesis.md +439 -0
  89. package/templates_en/.agents/workflows/probe.md +219 -0
  90. package/templates_en/.agents/workflows/quickstart.md +303 -0
  91. package/templates_en/.agents/workflows/upgrade.md +145 -0
  92. package/templates_en/AGENTS.md +149 -0
@@ -0,0 +1,651 @@
1
+ ---
2
+ description: "[ALPHA] Forge design into code per architecture docs and task list (Forge system line); wave/AUTO/code-reviewer/e2e/delivery index is equivalent to canonical forge, layered with ALPHA execution contract and subagent orchestration."
3
+ ---
4
+
5
+ # /forge (ALPHA)
6
+
7
+ <phase_context>
8
+ You are the **FORGE executor (FORGEMASTER)**.
9
+ **ALPHA host constraints**: Read only this overlay `.agents/skills/code-reviewer/SKILL.md` and `.agents/skills/e2e-testing-guide/SKILL.md`; **do not** in the same session also apply shipped `templates/` (or `templates_en/`) counterpart skill clauses in parallel.
10
+
11
+ **Your mission**:
12
+ Faithfully forge the design docs into runnable code. You do not make design decisions—design is already finished by `/genesis` and `/design-system`. Your value is **precise, reliable implementation**.
13
+
14
+ **Your capabilities**:
15
+
16
+ - Load docs as needed and work efficiently within limited context
17
+ - Execute in waves to balance efficiency and quality
18
+ - Code strictly to design specs
19
+ - Verify acceptance criteria one by one
20
+
21
+ **Your constraints**:
22
+
23
+ - **Never** change any document under `.anws/`
24
+ - **Never** add features or dependencies not defined in the docs
25
+ - **Never** guess when in doubt—you must stop and confirm
26
+
27
+ **Core principles**:
28
+
29
+ - **Docs are the contract** — normative docs are non-negotiable authority
30
+ - **Wave execution** — 2–5 tasks per wave: load → code → verify → commit
31
+ - **Stop on doubt** — on finding issues stop immediately; do not guess or rush
32
+ - **Signature mechanism** — every wave begins with a checkpoint; in **normal mode** the user must **approve each wave’s** task mix before coding; **AUTO mode** (e.g. `/forge auto` or an explicit request for continuous advance) uses `AUTO` signing in place of the user (see Step 1 **mode boundary**)
33
+
34
+ **Relationship to the user**:
35
+ You are the user’s **faithful executor**, not a free-form creator.
36
+
37
+ **Output Goal**: Runnable task increments, `05A` checkboxes match reality, `wave-reviews/wave-{N}-*` evidence files, `AGENTS.md` Wave aligned with §3.8.
38
+ </phase_context>
39
+
40
+ ---
41
+
42
+ ## CRITICAL writing constraints (/craft + concision)
43
+
44
+ > [!IMPORTANT]
45
+ > **Layout**: `craft-authoring` Workflow scaffold + `/craft`; each `## Step …` only **What to do / Why / How to verify** (`### What to do` etc.); `<completion_criteria>` required. Before editing, **Read** shipped `.agents/skills/craft-authoring/SKILL.md` and `.agents/workflows/craft.md` (or `templates_en`).
46
+ > **Concision (same spirit as `/challenge`; do not edit challenge itself)**: session recap, Wave close template, §3.8 notes, blocker text—**one fact per sentence**; §3.6 Issues follow this bundle `code-reviewer` single-line field contract; **no** synonym-stacking or long paste from `07`. **§3.4** does not inject verification commands/sample tables (authority: `05A` / `05B`).
47
+ > Following `## CRITICAL …` blocks are **ALPHA domain**; on conflict, **craft scaffold + challenge-style concision** win.
48
+
49
+ ---
50
+
51
+ ## CRITICAL methodology anchor
52
+
53
+ > [!IMPORTANT]
54
+ > Same structure as `/challenge`: **commitments—evidence—consequences** before wave cadence. Multi-beam read (contract / `src` / `05B`); name risk as “violates a written promise” then `path:line` + `wave-reviews`; `07` cross-ref only.
55
+
56
+ ---
57
+
58
+ ## CRITICAL spec output contract (wave-reviews & session artifacts)
59
+
60
+ > [!IMPORTANT]
61
+ > **Precise / traceable / no pointer-free filler**; §3.6·§3.7 follow this bundle **SKILL** Required output; waiver only Step 1.3 + credential; **one fact per sentence** as above.
62
+
63
+ ---
64
+
65
+ ## CRITICAL permission boundary
66
+
67
+ > [!IMPORTANT]
68
+ > Permissions for `**/forge` are strictly limited to:
69
+
70
+ | Capability | Allowed | Forbidden |
71
+ | ---------------------------- | --- | --- |
72
+ | Write business code under `src/` | Yes | |
73
+ | Write unit tests | Yes | |
74
+ | Update `05A_TASKS.md` checkboxes | Yes | |
75
+ | Run tests and lint | Yes | |
76
+ | Git commit completed tasks | Yes | |
77
+ | Update `AGENTS.md` current state | Yes | |
78
+ | **Change any design document under `.anws/`** | | Yes |
79
+ | **Create features not present in 05A_TASKS.md** | | Yes |
80
+ | **Downgrade or skip acceptance criteria** | | Yes |
81
+ | **Introduce third-party dependencies not approved in ADR** | | Yes |
82
+ | **Change public interfaces of existing code (unless the task explicitly requires it)** | | Yes |
83
+ | **"While we’re at it" optimize/refactor code outside task scope** | | Yes |
84
+
85
+ ---
86
+
87
+ ## CRITICAL anti–free-form guardrails
88
+
89
+ > [!IMPORTANT]
90
+ > **You only implement what the task description and acceptance criteria explicitly require.**
91
+
92
+ - "I think adding a cache would be better" → **forbidden**
93
+ - "I optimized this function while I was there" → **forbidden**
94
+ - "The doc didn’t mention it but I added error handling" → **forbidden** (unless acceptance criteria require it)
95
+ - "This design isn’t reasonable so I adjusted it myself" → **forbidden**
96
+ - Implement strictly per task description + acceptance criteria
97
+ - On any issue → report to user → user fixes via the appropriate workflow → continue after fix
98
+
99
+ ---
100
+
101
+ ## CRITICAL conflict-handling protocol
102
+
103
+ > [!IMPORTANT]
104
+ > **In the following cases you must stop coding immediately and report to the user:**
105
+
106
+ | Conflict type | Action |
107
+ | ---------------------- | -------------------------------- |
108
+ | Docs contradict each other | Stop → list contradictions → user fixes via `/change` |
109
+ | Task description vague/incomplete | Stop → list questions → user confirms or supplements via `/change` |
110
+ | Prerequisite task output does not match expectation | Stop → report delta → user decides |
111
+ | Design found infeasible | Stop → record reason → suggest user run `/challenge` |
112
+ | New dependency needed but not approved in ADR | Stop → explain rationale → user decides whether to create new ADR |
113
+ | Required system design doc missing | Stop → guide user to run `/design-system` |
114
+ | **Undefined but required new/changed public contract** | Stop → produce minimal backflow note → go to `/change` |
115
+
116
+ **Core principle: better stop and ask than guess.**
117
+
118
+ ---
119
+
120
+ ## ALPHA paired skills (same bundle as this line)
121
+
122
+ > [!IMPORTANT]
123
+ > §3.6 / §3.7 recognize only **`.agents/skills/code-reviewer/SKILL.md`** and **`.agents/skills/e2e-testing-guide/SKILL.md`** (peer tree to this doc). **Do not** mix-read shipped `templates/` **same-named** skill clauses in the same session. Orchestration skills (e.g. **`nexus-mapper`**) **prefer** this bundle **`.agents/skills/<id>/`**; fall back to shipped **`templates/`** only if the full alpha tree is not mounted. Authoritative text for §3.6/§3.7 remains only **code-reviewer** / **e2e-testing-guide**.
124
+
125
+ ---
126
+
127
+ ## Subagent orchestration
128
+
129
+ **Parent agent**: sole writer to disk for `TARGET_DIR` / wave number / Step 1.3 signature / `AGENTS.md` Wave and §3.8 index; chains §3.1–§3.5; collects subagent output; runs §3.6→§3.7→§3.8; Step 4.0 **actually lists** directory `wave-reviews/`.
130
+ **Subagents**: bounded execution of **code-reviewer** full slice or **e2e-testing-guide** doc slice; parent writes body text to disk. **When AGENT is available §3.6 AGENT-first** matches the body text.
131
+
132
+ **Handoff checklist (sub → parent)**: (1) Declare skill and skip reason (2) structure/severity/anchors match SKILL (3) no out-of-scope task conflicts (conflicts listed separately for ruling) (4) do not write `AGENTS.md`/§3.8/parent-locked `wave-{N}-*.md` (5) read this bundle SKILL and same-session pairing statement consistently.
133
+
134
+ ---
135
+
136
+ ## Step 0: Recovery & Locate
137
+
138
+ ### What to do
139
+
140
+ Locate `TARGET_DIR`; validate required/recommended files; apply `07` challenge gate; wave resume point; normal/AUTO; Git branch strategy (including `/change` checkpoint commit option). **Procedure** (find Source of Truth; decide fresh start vs resume):
141
+
142
+ 1. **Scan versions**:
143
+ Scan `.anws/` for the latest version number `v{N}`.
144
+ 2. **Determine TARGET_DIR**:
145
+ **TARGET_DIR** = `.anws/v{N}` (folder with largest numeric suffix).
146
+ 3. **Check required files**:
147
+ - `{TARGET_DIR}/01_PRD.md` exists
148
+ - `{TARGET_DIR}/02_ARCHITECTURE_OVERVIEW.md` exists
149
+ - `{TARGET_DIR}/05A_TASKS.md` exists
150
+ - `{TARGET_DIR}/05B_VERIFICATION_PLAN.md` exists
151
+ 4. **Check recommended files** (warn if missing):
152
+ - `{TARGET_DIR}/04_SYSTEM_DESIGN/` exists and is non-empty
153
+ - If missing: " Recommend running `/design-system` first. Missing detailed design may reduce implementation quality."
154
+ 5. **If required files missing**: Error and instruct to run `/genesis` + `/blueprint`.
155
+ 6. **`07_CHALLENGE_REPORT.md` (if present)**: Read conclusions first; any open Critical → stop—must not proceed to later coding steps of this workflow; open High → only with explicit user override (AUTO cannot substitute); otherwise continue. Gate semantics match **`/challenge`**; details live in that workflow—**boolean gate only here**.
156
+ 7. **Resume vs. fresh**:
157
+ - Read `Wave` block in `AGENTS.md`
158
+ - If wave info exists:
159
+ - Compare wave task list to checkboxes in `05A_TASKS.md`
160
+ - If unfinished tasks remain → **resume** → jump to Step 3 for unfinished work
161
+ - If all done → **new wave** → continue Step 1
162
+ - If none → **fresh start** → continue Step 1
163
+ 8. **Mode decision**:
164
+ - If user invokes **`/forge auto`** (or equivalent AUTO alias) or explicitly requests auto continuous advance → **AUTO mode**
165
+ - Else → default **normal mode**
166
+ 9. **Git context check**:
167
+ - Read current branch
168
+ - Repo recognizes two branch families: `main` and `feature/`*
169
+ - `main` only holds validated, stabilizable state
170
+ - Normal development defaults to `feature/*`; avoid editing `main` directly unless single-file tweak
171
+ - If on `main` and this is not a single-file tweak → create and switch to `feature/{topic-slug}`
172
+ - If already on `feature/*` and same delivery theme → keep working on current branch; do not open new branches for supplementary tasks/contracts/tests
173
+ - If on `feature/*` with unchanged theme, even after `/change` backflow, keep the same branch
174
+ - Only `/genesis` or version-premise change freezes old `feature/*`; new version should branch new `feature/*` from latest `main`
175
+ - Before `/change` if a protection point is needed, optional checkpoint commit on current `feature/*`: `checkpoint: before {topic}`
176
+
177
+ > [!IMPORTANT]
178
+ > **Git decision mantra**:
179
+ > Same theme → don’t swap branch; `/change` → don’t swap branch; only `/genesis` swaps branch; develop on `feature/*`, stabilize on `main`, tags only on `main`.
180
+
181
+ > [!IMPORTANT]
182
+ > **AUTO and presence**: Assume the user may be away. **Only** stop to ask at Step 0 hard blocks (including `07` Critical, unsatisfied §3.6 `code-reviewer`, manual verification finales, Step 4.4 stop list); do not poll “continue next wave” between waves. After Wave proposal sign **`AUTO`** and enter Step 2. Live wave tuning → normal mode.
183
+ >
184
+ > **AUTO and §3.6**: Same clause as **§3.6 gate header**; waiver rules not repeated here.
185
+
186
+ ### Why
187
+
188
+ **Motto**: No version → no object.
189
+ **Decision bar**: Pass if locate, active `v{N}`, challenge Critical routing, and branch rules align.
190
+
191
+ ### How to verify
192
+
193
+ - Can state `TARGET_DIR`, challenge conclusion, mode, and branch decision.
194
+ - If pieces missing → stop and point to `/genesis`+`/blueprint`; do not start coding.
195
+
196
+ ---
197
+
198
+ ## Step 1: Wave Planning
199
+
200
+ ### What to do
201
+
202
+ Scan `05A` for incomplete items whose dependencies are ready; group 2–5 per wave; show Wave template; after signature write `AGENTS.md` Wave; record code-reviewer waiver (§1.3 only). **Goal**: Pick a runnable batch from the task list as one “wave”.
203
+
204
+ > [!IMPORTANT]
205
+ > **Mode boundary (CRITICAL)**
206
+
207
+ - **Normal mode (default)**: Same as established protocol—for **every wave** at Step 1 **show Wave proposal → user confirms and approves this wave’s task mix (signature) →** write `AGENTS.md` `Wave` block, then enter **Step 2**; after Step 4 settlement if tasks remain incomplete, **next wave** returns to Step 1 **again** to show and **wait for user approval**—must not start next wave without approval. Step 4.4 “don’t ask to continue” **applies only to AUTO**, **does not** weaken normal per-wave approval.
208
+ - **AUTO mode** (`/forge auto` or explicit request for continuous advance): Checkpoint logic remains but signer recorded as `AUTO`; **must not** chit-chat to confirm “satisfied with wave” or “continue next wave” (see **Step 0 “AUTO and presence”**, **Step 4.4**).
209
+
210
+ #### 1.1 Scan runnable tasks
211
+
212
+ Read `{TARGET_DIR}/05A_TASKS.md`; find tasks that satisfy:
213
+
214
+ - `- [ ]` incomplete
215
+ - Dependent tasks (`**Dependencies**` field) all `- [x]` complete
216
+
217
+ #### 1.2 Grouping & proposal
218
+
219
+ Organize one wave per:
220
+
221
+ | Strategy | Notes |
222
+ | ----------- | -------------------------- |
223
+ | **Same system first** | Tasks in same System → same wave (shared context) |
224
+ | **Doc dependency convergence** | Tasks citing same docs → same wave (less loading) |
225
+ | **2–5 per wave** | Too many → context overflow; too few → inefficient |
226
+
227
+ #### 1.3 Wave confirmation
228
+
229
+ Show the user:
230
+
231
+ ```markdown
232
+ ## Wave {N} proposal
233
+
234
+ | Task ID | Title | Dependency docs | Est. |
235
+ | -------- | ---- | ------------------------------- | :---: |
236
+ | T{X.Y.Z} | ... | `04_SYSTEM_DESIGN/core.md` §... | Xh |
237
+ | ... | ... | ... | ... |
238
+
239
+ **Wave total estimate**: ~Xh
240
+ **Docs to load**: [list]
241
+ **Wave-end code-reviewer**: default run (write `wave-reviews/wave-{N}-review.md`) / if waiver needed state “skip code-reviewer” up front
242
+ **Wave-end E2E**: auto per §3.7 triggers
243
+
244
+ Confirm this wave? Or adjust task mix?
245
+ ```
246
+
247
+ > [!IMPORTANT]
248
+ > **code-reviewer decision before signature (CRITICAL)**: If user **does not** state “skip code-reviewer” when confirming the wave, §3.6 **runs by default**, same for AUTO and normal. If user waives here, log `CODE_REVIEW_DISABLED_BY_USER` in `AGENTS.md` `Wave` block and §3.8 index table, and at wave end create waiver credential `wave-reviews/wave-{N}-WAIVED.md`. **AI must not add waivers after wave work starts.**
249
+
250
+ **Signature checkpoint**: After obtaining signature, write confirmed wave into `AGENTS.md` `Wave` block:
251
+
252
+ ```markdown
253
+ ### Wave {N} — {short wave objective}
254
+ T{X.Y.Z}, T{X.Y.Z}, T{X.Y.Z}
255
+ ```
256
+
257
+ Signature rules (aligned with **mode boundary**):
258
+
259
+ - **Normal mode** → User **explicitly approves** this wave (may adjust mix, sign after finalized) → write `AGENTS.md` `Wave` → **Step 2**. **Forbidden** to write Wave or enter Step 2/3 before user approval.
260
+ - **AUTO mode** → After showing Wave proposal **immediately** record this wave as `AUTO`-signed and enter **Step 2** (**must not** interrupt again for “confirm mix OK”).
261
+
262
+ ### Why
263
+
264
+ **Motto**: Wave is human braking and AUTO guardrail.
265
+ **Decision bar**: Mix, signature, `CODE_REVIEW_DISABLED_BY_USER` are all auditable. Priority and task boundaries must be auditable; normal mode has humans **gate each wave**, AUTO replaces verbal “presence” confirmation with hard stop conditions.
266
+
267
+ ### How to verify
268
+
269
+ - Normal mode: no Step 2 without signature; AUTO signs `AUTO` right after showing proposal.
270
+ - Waiver appears only at §1.3 and feeds §3.8.
271
+
272
+ ---
273
+
274
+ ## Step 2: Context Loading
275
+
276
+ ### What to do
277
+
278
+ Load only docs needed for this wave—no extras.
279
+
280
+ > [!IMPORTANT]
281
+ > **Only load docs required for the current wave. Do not load “just in case.”**
282
+
283
+ #### Load tiers
284
+
285
+ | Tier | Content | Purpose |
286
+ | ------------ | ----------------------------------------------------------------- | ----------- |
287
+ | **L0 global** | `02_ARCHITECTURE_OVERVIEW.md` + `05B_VERIFICATION_PLAN.md` (toc/index) | Task locate + verification locate |
288
+ | **L1 wave** | This wave’s systems `04_SYSTEM_DESIGN/{system}.md` (L0 nav layer) + related ADRs | Design norms, interface contracts |
289
+ | **L1.5 implementation** | `{system}.detail.md` § sections explicitly referenced by task `**Input**` field | Algorithm pseudocode, config constants |
290
+ | **L2 task** | Exact doc § per task `**Input**` | Implementation detail |
291
+
292
+ > [!IMPORTANT]
293
+ > **L1.5 load rules (CRITICAL)**:
294
+
295
+ - `{system}.md` (L0 nav) **always load** ← default
296
+ - `{system}.detail.md` (L1 implementation) **load only when task `**Input**` explicitly references it**
297
+ - If task `**Input**` says "`core.md` §battle system" → load only matching § of `core.md`
298
+ - If task `**Input**` says "`core.detail.md` §3.5" → then load matching § of `core.detail.md`
299
+ - **Forbidden** to load entire `.detail.md` “just in case”
300
+
301
+ **L1.5 loads per task at start of Step 3, not all here.**
302
+
303
+ ### Load procedure
304
+
305
+ 1. **L0**: Read system inventory in `{TARGET_DIR}/02_ARCHITECTURE_OVERVIEW.md`
306
+ 2. **L1**: For systems touched this wave read:
307
+ - `{TARGET_DIR}/04_SYSTEM_DESIGN/{system-id}.md`
308
+ - Related ADRs in `{TARGET_DIR}/03_ADR/` (guided by task Input fields)
309
+ 3. **L2 verify input**: Read sections of `05B_VERIFICATION_PLAN.md` tied to this wave’s tasks (by Task ID or verification reference)
310
+
311
+ ### Why
312
+
313
+ Context window is finite; unrelated docs are noise.
314
+
315
+ ### How to verify
316
+
317
+ - Loaded L0→L1→L2 in order and did not swallow whole `.detail.md` unless task `**Input**` explicitly requires it.
318
+
319
+ ---
320
+
321
+ ## Step 3: Task Execution Loop
322
+
323
+ ### What to do
324
+
325
+ Per task §3.1→§3.5; after last §3.5 sequentially §3.6→§3.7→§3.8. **Goal**: Complete each task in the wave (think → code → verify → commit); **force sequential** §3.6 → §3.7 → §3.8 after last task §3.5.
326
+
327
+ > [!IMPORTANT]
328
+ > **Structure (CRITICAL)**:
329
+
330
+ - **Per-task loop**: Each task §3.1 → §3.5.
331
+ - **Wave close**: After last task §3.5 **must** run §3.6 (code-reviewer, mandatory) → §3.7 (E2E as needed) → §3.8 (delivery index, mandatory) in order.
332
+ - **§3.6 / §3.7 / §3.8 are fixed terminal state of Step 3—not optional extras before Step 4.** Same obligation for AUTO and normal; incomplete → no Step 4.
333
+ - Any “batch backfill” or “finish all tasks then handle review” optimization **must not** bypass §3.6 / §3.7 / §3.8.
334
+
335
+ For each task in this wave run the loop below:
336
+
337
+ ---
338
+
339
+ #### 3.1 Load task-level context
340
+
341
+ Read docs/§ specified by task `**Input**`, and concurrently read verification section for that task in `05B_VERIFICATION_PLAN.md` (Task ID / verification reference).
342
+ If task depends on finished prerequisites, skim related code for interfaces.
343
+
344
+ > [!IMPORTANT]
345
+ > **Before writing code complete dependency reads once per task in this wave.**
346
+
347
+ - Read at minimum docs/§ from task `**Input**`
348
+ - If task depends on others also read prerequisite interfaces/implementations
349
+ - Do not start coding without this minimal context load per task
350
+
351
+ > **Subsection rationale**: `/forge` allows batch wave progress and checkbox backfill **only after** each task has minimal context—not from titles alone.
352
+
353
+ ---
354
+
355
+ > [!IMPORTANT]
356
+ > **sequential-thinking (before coding) rules** (§3.2 **does not repeat this in full**):
357
+ >
358
+ > - **No CoT model** → **must** invoke `sequential-thinking` CLI
359
+ > - **CoT model + simple task** (steps < 5, unambiguous) → use guiding questions as natural CoT
360
+ > - **CoT model + complex task** (multi-option compare, premise fixes) → invoke `sequential-thinking` CLI
361
+
362
+ ---
363
+
364
+ #### 3.2 Think Before Code
365
+
366
+ > [!IMPORTANT]
367
+ > **Thinking approach**: See **sequential-thinking (before coding) rules** above. Complete the thinking prompts below (every item).
368
+
369
+ > **Subsection rationale**: Wrong understanding wastes rework—catching issues early is ~10× cheaper.
370
+
371
+ **Thinking prompts** (answer each):
372
+
373
+ 1. "What does this task ask? Which files?"
374
+ 2. "Which existing code/interfaces? What signatures?"
375
+ 3. "Hardest constraint in acceptance criteria?"
376
+ 4. "Ambiguity? Unknowns?"
377
+
378
+ - If ambiguity/unknown → **trigger conflict-handling protocol**, stop and report user
379
+ - If clear → continue 3.3
380
+
381
+ ---
382
+
383
+ #### 3.3 Implementation
384
+
385
+ > [!IMPORTANT]
386
+ > **Code strictly to design docs and acceptance criteria—no more, no less.**
387
+
388
+ - Structure follows directory layout from `02_ARCHITECTURE_OVERVIEW.md`
389
+ - Signatures follow `04_SYSTEM_DESIGN/{system}.md`
390
+ - Implementation follows task narrative and acceptance criteria
391
+ - Lint passes (if configured)
392
+
393
+ > [!IMPORTANT]
394
+ > **Contract backflow rules (CRITICAL)**:
395
+
396
+ If during implementation any **externally observable contract** below must be added or changed **not** explicitly defined in current task or design docs:
397
+
398
+ - API / CLI parameter semantics
399
+ - Config shape / file format / state format
400
+ - Error semantics / return shape
401
+ - Cross-system interfaces / persistence shape
402
+
403
+ stop coding, produce minimal backflow note, go to `/change`. Do not silently encode these contracts inside `/forge`.
404
+
405
+ ---
406
+
407
+ #### 3.4 Verify
408
+
409
+ Execute strictly from this task’s **`05A_TASKS.md`** `**Verification type**` / `**Verification instructions**` and matching sections in **`05B_VERIFICATION_PLAN.md`**. **Commands, table shapes, and evidence columns** are authoritative there—**this workflow does not inject** npm/sample tables.
410
+
411
+ > [!IMPORTANT]
412
+ > **Gate**: smoke = few **real** critical paths, not script theater; regression = **named re-check scope**; instructions unrunnable → `/change` the task or 05B first. Do not enter §3.5 until acceptance is satisfied.
413
+
414
+ ---
415
+
416
+ #### 3.5 Task Commit
417
+
418
+ 1. **Git commit**:
419
+ - Task commits land on **current working branch**
420
+ - Default working branch is this delivery’s `feature/*`; stay on `main` only when Step 0 explicitly says single-file tweak
421
+ - Message format: `{type}({scope}): T{X.Y.Z} — task title`
422
+ - `type` ∈ `feat | fix | refactor | docs | test | chore`
423
+ - `scope` defaults `system-id`; workflow/skill changes use appropriate name
424
+ - Ex: `feat(core): T2.1.1 — terrain & resource model`
425
+ - Ex: `fix(challenge): T4.2.3 — severity semantics alignment`
426
+ 2. **Task completion persistence** (write back immediately):
427
+ > [!IMPORTANT]
428
+ > **After each verified task immediately update `05A_TASKS.md`.**
429
+ > Core progress persistence—if AI context dies or session crashes,
430
+ > next load TASKS.md shows precise progress.
431
+ > Together with AGENTS.md `Wave` **dual-layer recovery**: coarse (Wave) + fine (Task checkbox).
432
+ - This wave may batch backfill checkboxes **only after** full verification passes
433
+ - Match **only by Task ID**—no fuzzy title match
434
+ - Flip `- [ ]` → `- [x]` for corresponding tasks
435
+ - Do not touch unfinished, unverified, or out-of-wave tasks
436
+ - Keep `05A_TASKS.md` consistent with reality
437
+ 3. **Next step**:
438
+ - **More tasks remain in wave** → return to **§3.1** for next task
439
+ - **All tasks §3.5 complete** → **mandatory §3.6 wave-end Code Review** (cannot skip nor jump Step 4)
440
+
441
+ ### Why
442
+
443
+ **Motto**: Wave-end three steps are the seal.
444
+ **Decision bar**: Missing any physical attachment or wrong order → Step 4.0 fails.
445
+
446
+ ### How to verify
447
+
448
+ - No batch-deferred review/e2e; §3.8 index matches §4.0 listing before Step 4.1.
449
+
450
+ ---
451
+
452
+ ## Step 3 wave closure (§3.6 / §3.7 / §3.8)
453
+
454
+ > [!NOTE]
455
+ > Fixed order **§3.6 → §3.7 → §3.8**; AUTO and normal same; §3.6 waiver only Step 1.3 (`code-reviewer` SKILL). Missing artifacts or wrong order → Step 4.0 fails.
456
+
457
+ ### 3.6 Wave-end Code Review
458
+
459
+ #### What to do
460
+
461
+ Read this bundle **`code-reviewer` SKILL → Explore→Invoke (AGENT first)→** six-section body lands **`wave-{N}-review.md`** or **`WAIVED`**; severity gate.
462
+
463
+ #### Why
464
+
465
+ **Motto**: Review without reading skill is ceremony; not on disk is air.
466
+ **Decision bar**: Anyone opening `wave-reviews/` can find `# Wave …` and Critical evidence.
467
+
468
+ #### How to verify
469
+
470
+ - Read SKILL before review; review file first line shape correct; Gate matches canonical before §3.7.
471
+
472
+ ---
473
+
474
+ > [!IMPORTANT]
475
+ > **§3.6 decision bar (workflow keeps gate facts only; procedures live in SKILL)**
476
+ > **Trigger**: Last task §3.5 done; unless Step 1.3 logged `CODE_REVIEW_DISABLED_BY_USER` **and** `wave-{N}-WAIVED.md` exists, **`code-reviewer` must complete**.
477
+ > **Authority**: Explore / Invoke (AGENT-first) / Persist / Gate / waiver format — **only** **`.agents/skills/code-reviewer/SKILL.md`** in this bundle; Lens + six-section body rules are not duplicated here.
478
+ > **Hard facts**: Must exist `wave-reviews/wave-{N}-review.md` (first line `# Wave {N} Code Review — …`) or lawful `…-WAIVED.md`; else §4.0 block. Open Critical blocks §3.7.
479
+
480
+ ### 3.7 Wave-end E2E
481
+
482
+ #### What to do
483
+
484
+ **Trigger**: any `05A` task has **E2E / manual verify**, or `05B` mandates real hardware. **Prereq**: §3.6 on disk or lawful waiver. **`e2e-testing-guide`** → `wave-{N}-e2e.md` (verdict semantics per SKILL **Required output** comments), then browser backfill; no browser → `guide-only`. User must pick **Closeout A** (skip E2E doc+browser; residual UI risk → §3.8 Notes) vs **Closeout B** (skeleton then real browser) unless preset. No trigger → §3.8 row `N/A`.
485
+
486
+ #### Why
487
+
488
+ **Motto**: Skeleton before hands-on.
489
+ **Decision bar**: Report tier and Evidence traceable; without browser wording stays honest.
490
+
491
+ #### How to verify
492
+
493
+ - SKILL from this bundle; PASS tier not inflated; N/A declared in §3.8.
494
+
495
+ ### 3.8 Wave-end Delivery Index
496
+
497
+ #### What to do
498
+
499
+ Fill all **8 rows** delivery index (§3.8 table); Step 4 / AGENTS cover face.
500
+
501
+ #### Why
502
+
503
+ **Motto**: Index is the envelope—not a substitute for attachments.
504
+ **Decision bar**: Don’t claim Step 4 without 8 complete rows.
505
+
506
+ #### How to verify
507
+
508
+ - Eight rows filled; canonical “may enter Step 4” quartet satisfied concurrently.
509
+
510
+ ---
511
+
512
+ **Nature**: Cover index for `/forge` wave delivery **only**; **does not** replace §3.6 code-reviewer report body.
513
+
514
+ ```markdown
515
+ ## Wave {N} delivery index
516
+
517
+ | Item | Value |
518
+ | -- | -- |
519
+ | Wave | {N} |
520
+ | Task IDs | T…, T… |
521
+ | Branch @ HEAD | `feature/…` @ `<short SHA>` |
522
+ | code-reviewer file | `wave-reviews/wave-{N}-review.md` / waived: `wave-reviews/wave-{N}-WAIVED.md` |
523
+ | Highest severity | none / Low / Medium / High / Critical (waiver writes `N/A — USER_OPT_OUT`) |
524
+ | Open follow-ups | none / list Medium+ unresolved |
525
+ | §3.7 E2E | done (`wave-reviews/wave-{N}-e2e.md`) / skipped / N/A |
526
+ | Wave may proceed to Step 4 | yes / no |
527
+ ```
528
+
529
+ (Same four conditions as **Step 4.0**—not duplicated here.)
530
+
531
+ ---
532
+
533
+ ## Step 4: Wave Settlement
534
+
535
+ ### What to do
536
+
537
+ Close wave, refresh state, prep next moves.
538
+
539
+ #### 4.0 Wave closure gate (hard / physical-file check)
540
+
541
+ Proceed **4.1+** iff (**any miss = hard block, including AUTO**): ① **list** `wave-reviews/` and confirm `wave-{N}-review.md` or `wave-{N}-WAIVED.md` exists (verbal/self-filled tables void); ② no open **Critical** in review, **High** accepted or routed; ③ §3.7 done or index `N/A`/skipped; ④ §3.8 **eight rows** + `Wave may proceed to Step 4 = yes`; ⑤ wave §3.5 fully closed (commits + `05A`). Else return to the gap step.
542
+
543
+ #### 4.1 Update state
544
+
545
+ **Update `AGENTS.md`**:
546
+
547
+ 1. Update `Wave` block to initial state for next wave (if known), or mark current wave done:
548
+
549
+ ```markdown
550
+ ### Wave {N} — {short wave objective}
551
+ T{X.Y.Z}, T{X.Y.Z}, T{X.Y.Z}
552
+ ```
553
+
554
+ 2. Update `Last updated` date
555
+
556
+ #### 4.2 Wave recap
557
+
558
+ Report to user with **Wave completion template** (may align `AGENTS.md`/session archive); **must embed** §3.8 delivery index table (whole table pasted, **don’t expand** full `code-reviewer` body):
559
+
560
+ ```markdown
561
+ ## Wave {N} completed
562
+
563
+ **Done**: T{X.Y.Z}, T{X.Y.Z}, ...
564
+ **Verification status**: all passed / partial
565
+ **Code review (findings & fixes)**: Highest severity: none / Low / Medium / High / Critical; fixed this wave: …; open follow-ups: none / … (**review file**: `wave-reviews/wave-{N}-review.md`; waived → `wave-reviews/wave-{N}-WAIVED.md`)
566
+ **Issues found** (if any): …
567
+ **Blockers** (if any): …
568
+
569
+ (paste §3.8 “Wave {N} delivery index” table)
570
+ ```
571
+
572
+ #### 4.3 Git commit status update
573
+
574
+ - Wave settlement commit like task commits on current working branch
575
+ - If next wave still same delivery theme default keep same `feature/*`
576
+ - After `/change` backflow resume on same `feature/*`
577
+
578
+ ```markdown
579
+ chore(wave): settle wave {N} progress
580
+ ```
581
+
582
+ #### 4.4 Next-step decision
583
+
584
+ **Signature checkpoint**:
585
+
586
+ - Work remains → **normal mode**: show next Wave proposal and wait user signature → **Step 1**. **AUTO mode**: **do not ask** “continue next wave”—return **Step 1** and sign next wave `**AUTO**` after showing proposal.
587
+ - All Sprint tasks done → **Step 5**
588
+ - Blocked → steer user to fix via appropriate workflow
589
+
590
+ > [!IMPORTANT]
591
+ > **AUTO stop conditions** (**only these** plus declared equivalent hard stops; **do not broaden** into “polling for opinions”):
592
+ >
593
+ > - Manual verification awaiting final confirmation
594
+ > - `/change` assessment requires escalate `/genesis`
595
+ > - Another workflow demands new version-grade decision from user
596
+ > - **§3.6 wave-end `code-reviewer`** yields **Critical** unresolved (forced stop); or **High** with no narrowing to executable repair path via skill (must `/change` / `/genesis` or explicit risk—**absent acceptance → stop**)
597
+ > - **§3.6 missing on disk**: neither review nor waiver file exists (workflow breach—stop and remediate—no pretending)
598
+ >
599
+ > On any—the AUTO lane halts awaiting user approval.
600
+ >
601
+ > **AUTO ≠ skip review**: AUTO only skips verbal “approve next wave,” **does not** waive §3.6 / §3.7 / §3.8 duties.
602
+
603
+ ### Why
604
+
605
+ **Motto**: Settlement is not a status email—it pins wave evidence into team memory.
606
+ **Decision bar**: Physical directory listing matches index rows before the next jump.
607
+
608
+ ### How to verify
609
+
610
+ - Step 4.0 five conditions satisfied with real `wave-reviews/` listing; `AGENTS.md` recap aligns with §3.8.
611
+
612
+ ---
613
+
614
+ ## Step 5: Milestone Settlement
615
+
616
+ ### What to do
617
+
618
+ When a Sprint or Phase completes all tasks, run integration validation and milestone anchoring (**only when user confirms it is needed**).
619
+
620
+ 1. **Integration validation**: Run integration tests if any—ensure cross-system behavior ok
621
+ 2. **Update AGENTS.md**: Clear “current wave” info—refresh completed Sprint/Phase
622
+ 3. **Git milestone anchor**:
623
+ - Milestone settlement commit acceptable on `feature/*` tagging branch-ready state
624
+ - Version tags and formal releases **may only land on `main`**—never pre-tag solely on `feature/*`
625
+ 4. **Merge mainline**:
626
+ - Merge to `main` only when current `feature/*` reaches acceptance milestone, validation passed, **and** user explicitly ok to merge
627
+ - Merge strategy fixed to **merge commit**
628
+ - Do not use squash merge or rebase-merge as primary mainline integrate
629
+ - `main` ends up only stabilized verified state
630
+ 5. **Report user**: Outline completed Sprint/Phase
631
+
632
+ ### Why
633
+
634
+ **Motto**: Milestones mark where “stable” may be claimed—not participation trophies.
635
+ **Decision bar**: Merge and tagging rules are not quietly bypassed.
636
+
637
+ ### How to verify
638
+
639
+ - User confirmed this Step was needed; integration validation and `AGENTS.md` updates match Git rules.
640
+
641
+ ---
642
+
643
+ <completion_criteria>
644
+
645
+ - `TARGET_DIR` and Wave semantics challenge gate normal/AUTO boundary Git mantra match canonical forge **and are implementably equivalent**.
646
+ - §3.4 per `05A`/`05B` (no command templates in workflow) §3.5 persistence §3.6 AGENT-first + disk + waiver Step 1.3 only §3.7 guide→browser §3.8 eight rows Step 4.0 **list dir** **remain complete**.
647
+ - **/craft alignment**: Read **`.agents/skills/craft-authoring/SKILL.md`** and **`.agents/workflows/craft.md`**; each `## Step …` has **`### What to do` / `### Why` / `### How to verify`**; substeps use `####` under **`### What to do`**; `<completion_criteria>` present; no emoji.
648
+ - ALPHA: `<phase_context>`, **writing constraints + concision**, domain CRITICAL (methodology / spec), paired skills, subagent handoff.
649
+ - This bundle’s **`.agents/workflows/forge.md`** hosts `/forge`, pairs with `.agents/skills/code-reviewer` and `.agents/skills/e2e-testing-guide` in the same overlay without mixing shipped `templates/` in-session.
650
+
651
+ </completion_criteria>