haiku-method 3.12.0 → 3.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haiku-method",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "description": "H·AI·K·U methodology — universal lifecycle orchestration with hat-based workflows, completion criteria, and automatic context preservation.",
5
5
  "homepage": "https://haikumethod.ai",
6
6
  "repository": {
@@ -0,0 +1,207 @@
1
+ ---
2
+ name: zap
3
+ description: Zero-ceremony single-unit execution — run one task directly through a stage's hat loop without intent or workflow scaffolding
4
+ ---
5
+
6
+ # Zap
7
+
8
+ Run a single task directly through a stage's hat loop. No intent file, no unit decomposition, no workflow tick — just the studio's hat sequence applied inline to the work.
9
+
10
+ **Use for:** bug fixes, typos, config tweaks, small refactors — any task where the cost of a mistake is "edit and re-run," not "rollback a pipeline."
11
+
12
+ **Not for:** tasks that span multiple stages, need architecture decisions, or involve multiple sub-systems. Use `/haiku:quick` or `/haiku:start` for those.
13
+
14
+ ## Arguments
15
+
16
+ - `studio` — Studio slug (e.g. `software`, `marketing`, `documentation`). Optional — defaults to `software` if the project has a git repo and no other context narrows it.
17
+ - `stage` — Stage within the studio (e.g. `development`, `inception`, `design`). Optional — defaults to the most execution-oriented stage in the studio (e.g. `development` for `software`).
18
+
19
+ ## Process
20
+
21
+ ### 0. Preflight — clean working tree
22
+
23
+ Run `git status --porcelain`. If the working tree has uncommitted changes (staged or unstaged), stop and ask the user via `AskUserQuestion`:
24
+ - options: `["Commit/stash my changes first, then re-run zap", "Proceed anyway (zap may sweep my unrelated changes into its commit)"]`
25
+
26
+ If the user picks the first option: acknowledge and stop. Don't try to commit/stash for them.
27
+ If the user picks the second option: continue, but record the pre-existing dirty paths so the builder can be told to leave them alone.
28
+
29
+ If the tree is clean, continue.
30
+
31
+ ### 1. Resolve studio and stage
32
+
33
+ **If studio is provided:**
34
+ 1. Call `haiku_studio_list` to get the available studios.
35
+ 2. If the provided studio is not in the list, surface the issue with `AskUserQuestion` and let the user pick from the real list.
36
+ 3. Then call `haiku_studio_stage_get { studio, stage }` to validate the stage. If `found: false`, the stage (not the studio) is the problem — surface the studio's actual `stages:` list and let the user pick.
37
+
38
+ **If studio is NOT provided:**
39
+ 1. Call `haiku_studio_list`.
40
+ 2. Check project context (language files, existing `.haiku/settings.yml`) to infer the best fit.
41
+ 3. Default to `software` if it exists and no other signal is stronger.
42
+
43
+ **If stage is NOT provided:** use the studio's primary execution stage. For `software` this is `development`. For others, pick the build-class stage from the studio's `stages:` list (the one that produces code/artifacts, not research or design).
44
+
45
+ ### 2. Load stage context
46
+
47
+ Call `haiku_studio_stage_get { studio: "<studio>", stage: "<stage>" }`.
48
+
49
+ The response contains:
50
+ - `hats` — ordered list of hat names (e.g. `["planner", "builder", "reviewer"]`)
51
+ - `stage_md` — absolute path to the STAGE.md file
52
+ - `body` — the stage's prose description
53
+
54
+ Derive the hats directory path: `dirname(stage_md) + "/hats/"`. Each hat file lives at `<hats_dir>/<hat>.md`.
55
+
56
+ Read every hat file in the `hats:` list with the Read tool before dispatching.
57
+
58
+ ### 3. Clarify the task (brief prelaboration)
59
+
60
+ If the user's task description is vague (no clear action, no clear target, or under one sentence), ask ONE focused question via `AskUserQuestion` with pre-populated `options[]`. Otherwise skip.
61
+
62
+ **Do NOT** run a full elaboration phase — one question at most.
63
+
64
+ ### 4. Run the hat loop
65
+
66
+ Execute each hat in the `hats:` list as a **sequential** subagent. Each hat receives the prior hat's output. Do NOT parallelize.
67
+
68
+ For each hat, spawn a subagent (Task tool) with the prompt below. Wait for it to return before spawning the next one.
69
+
70
+ The hat's role is determined by its position in the list:
71
+ - **First hat** → planner role
72
+ - **Last hat** → verifier role (must return PASS/FAIL)
73
+ - **Any middle hats** → builder/doer role
74
+
75
+ Hat names that contain `verif`, `review`, `check`, or `assess` always get verifier role regardless of position. Hat names that contain `plan` or `design` always get planner role regardless of position. The hat's own mandate file (`hats/<hat>.md`) is the primary source of behavioral instruction; the per-hat instructions below are zap-specific framing on top of that mandate.
76
+
77
+ ---
78
+
79
+ #### Hat subagent prompt
80
+
81
+ ```
82
+ You are executing a zap task as the **<HAT>** hat in stage **<STAGE>** of studio **<STUDIO>**.
83
+
84
+ This is a zap run — no workflow engine, no unit files, no haiku_* tool calls. Work directly on the repo.
85
+
86
+ ## Stage scope
87
+
88
+ <STAGE.md body — paste verbatim>
89
+
90
+ ## Your mandate: <HAT>
91
+
92
+ <hat.md body — paste verbatim>
93
+
94
+ Note: this mandate was written for the workflow-engine context. Where it references units, feedback files, or haiku_* tools, translate that as: work directly on the repo, return your output as plain text to the parent. Do NOT call any haiku_* tools.
95
+
96
+ ## Task
97
+
98
+ <user's task description>
99
+
100
+ <if retry: prepend a "## Prior failure context" block here with the verifier's FAIL reason>
101
+
102
+ <if not the first hat:>
103
+ ## Input from prior hat (<PRIOR_HAT>)
104
+
105
+ <prior hat's returned output — paste verbatim>
106
+
107
+ <if user opted to proceed with a dirty tree:>
108
+ ## Pre-existing uncommitted changes (do NOT modify)
109
+
110
+ <list of files from git status --porcelain at preflight>
111
+
112
+ ## Instructions
113
+
114
+ <role-specific instructions — see below>
115
+ ```
116
+
117
+ ---
118
+
119
+ #### Per-role instructions
120
+
121
+ **Planner role (first hat, or any hat with `plan`/`design` in the name):**
122
+ ```
123
+ 1. Read the task and stage scope above.
124
+ 2. Produce a concise implementation plan:
125
+ - Files to inspect or modify (with reasoning)
126
+ - Step-by-step approach (3–5 items)
127
+ - Risks or edge cases to watch for
128
+ 3. Return your plan as plain text. Do NOT implement — planning only.
129
+ ```
130
+
131
+ **Builder/doer role (middle hats, default for hats not matching planner or verifier name patterns):**
132
+ ```
133
+ 1. Read the prior hat's output above and the hat mandate.
134
+ 2. Apply your hat's role to the task. If your mandate is "build/implement," write the code. If your mandate is "critique/refine prior output," critique it and emit a revised plan or revised work as appropriate.
135
+ 3. If you wrote or modified files, run any project quality gates (tests, lint, typecheck) and fix failures.
136
+ 4. Do NOT commit. Leave changes uncommitted in the working tree — the parent skill commits once at the end after the verifier passes.
137
+ 5. Return a summary:
138
+ - Files you created/modified (exact paths)
139
+ - Quality gate results (commands run, pass/fail)
140
+ - One-paragraph description of what changed and why
141
+ ```
142
+
143
+ **Verifier role (last hat, or any hat with `verif`/`review`/`check`/`assess` in the name):**
144
+ ```
145
+ 1. Read the task description and the prior hat outputs (especially the builder's summary).
146
+ 2. Inspect the actual uncommitted changes with `git status --porcelain` and `git diff` to confirm they match the summary.
147
+ 3. Verify the work meets the task's success criteria:
148
+ - Does the change address exactly what was asked?
149
+ - Is the code internally consistent and free of obvious regressions?
150
+ - Are there edge cases the builder missed that the stage scope would flag?
151
+ 4. Your final message MUST be structured exactly as one of these two formats:
152
+
153
+ On success (single line, then a Files block):
154
+ ```
155
+ PASS — <one-sentence summary of what was verified>
156
+ Files:
157
+ <path1>
158
+ <path2>
159
+ ...
160
+ ```
161
+
162
+ On failure (single line, no files block):
163
+ ```
164
+ FAIL — <specific reason the task is not complete or correct>
165
+ ```
166
+
167
+ The Files block on PASS lists the exact paths the parent should stage. Include only paths you confirmed via `git diff` are part of the task's intended change. Exclude any pre-existing dirty paths that were called out in the prompt.
168
+
169
+ 5. Do NOT run quality gates — that was the builder's job. Focus on correctness and fit.
170
+ 6. Do NOT commit, amend, or otherwise mutate the git tree.
171
+ 7. Do NOT call any haiku_* tools.
172
+ ```
173
+
174
+ ---
175
+
176
+ ### 5. Handle the verifier verdict
177
+
178
+ Parse the verifier's first line for the `PASS` or `FAIL` token (anchored to the start of the first line, followed by ` — `). Initialize a retry counter at 0 before the first hat-loop run.
179
+
180
+ **If `PASS`:**
181
+ 1. Read the `Files:` block from the verifier's output. Stage exactly those paths: `git add <path1> <path2> ...`. Do NOT use `git add -A` or `git add .` — that would sweep in any pre-existing dirty paths the user opted into.
182
+ 2. Commit with a brief message derived from the task description and verifier summary: `git commit -m "<message>"`.
183
+ 3. Report success to the user: files committed, commands run, verifier's PASS line.
184
+
185
+ **If `FAIL`:**
186
+ 1. Surface the failure reason to the user.
187
+ 2. If the retry counter is **less than 2**, ask via `AskUserQuestion`:
188
+ - options: `["Retry the hat loop with this failure as context", "Abandon — I'll fix it manually"]`
189
+ 3. If the retry counter is **2 or more**, do NOT offer retry. Tell the user: "Two retries already used — zap isn't converging. Discard the uncommitted changes (`git restore .`) and either fix manually or use `/haiku:start` for a structured run." Stop.
190
+
191
+ If the user picks retry:
192
+ - Increment the retry counter.
193
+ - Do NOT touch the working tree — the builder's prior uncommitted changes carry forward as the new starting state.
194
+ - Re-run from step 4, prepending `## Prior failure context: <verifier's FAIL reason>` to the task description.
195
+
196
+ If the user picks abandon: acknowledge, leave the uncommitted changes in place (the user said they'd fix manually), and stop.
197
+
198
+ **If a hat subagent errors out** (returns no output, throws, or crashes): treat it as a `FAIL` with reason `"<HAT> subagent errored: <error message>"` and route through the failure path above. Do not silently retry.
199
+
200
+ ## Guardrails
201
+
202
+ - **Scope check:** if the task description spans multiple stages (e.g. "redesign the auth flow AND implement the backend AND write the tests"), recommend `/haiku:quick` or `/haiku:start` and explain why. Don't blindly zap a multi-stage task through a single stage's hat loop.
203
+ - **Stage validation:** if `haiku_studio_stage_get` returns `found: false` after a valid studio, the stage is the problem — surface the studio's `stages:` list, not a generic "studio/stage not found."
204
+ - **Stateless:** no `.haiku/` files are written. If the user needs formal traceability, suggest `/haiku:quick`.
205
+ - **Hat count:** most stages have 3 hats. If a stage has more (adversarial loops, etc.), run all of them in sequence — the hat order in `hats:` is the authority. Role assignment uses the name-pattern rules in step 4.
206
+ - **Retry cap:** at most 2 retries (3 total attempts). Past that, the skill stops and tells the user to bail out to `/haiku:start` or fix manually.
207
+ - **Commit safety:** only the parent skill commits, only after verifier PASS, only the exact files the builder reported. The builder, planner, and verifier never commit.