@entelligentsia/forgecli 0.6.6 → 0.7.6

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 (183) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +28 -1
  3. package/dist/bin/forge.js +20 -0
  4. package/dist/bin/forge.js.map +1 -1
  5. package/dist/extensions/forgecli/approve.d.ts +24 -0
  6. package/dist/extensions/forgecli/approve.js +202 -0
  7. package/dist/extensions/forgecli/approve.js.map +1 -0
  8. package/dist/extensions/forgecli/audience-gate.d.ts +4 -0
  9. package/dist/extensions/forgecli/audience-gate.js +8 -5
  10. package/dist/extensions/forgecli/audience-gate.js.map +1 -1
  11. package/dist/extensions/forgecli/collate.d.ts +24 -0
  12. package/dist/extensions/forgecli/collate.js +199 -0
  13. package/dist/extensions/forgecli/collate.js.map +1 -0
  14. package/dist/extensions/forgecli/commit.d.ts +24 -0
  15. package/dist/extensions/forgecli/commit.js +202 -0
  16. package/dist/extensions/forgecli/commit.js.map +1 -0
  17. package/dist/extensions/forgecli/fix-bug.d.ts +75 -0
  18. package/dist/extensions/forgecli/fix-bug.js +1133 -0
  19. package/dist/extensions/forgecli/fix-bug.js.map +1 -0
  20. package/dist/extensions/forgecli/forge-commands.js +7 -0
  21. package/dist/extensions/forgecli/forge-commands.js.map +1 -1
  22. package/dist/extensions/forgecli/forge-init.js +16 -8
  23. package/dist/extensions/forgecli/forge-init.js.map +1 -1
  24. package/dist/extensions/forgecli/forge-subagent.d.ts +29 -0
  25. package/dist/extensions/forgecli/forge-subagent.js +14 -1
  26. package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
  27. package/dist/extensions/forgecli/hook-dispatcher.d.ts +53 -1
  28. package/dist/extensions/forgecli/hook-dispatcher.js +47 -1
  29. package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
  30. package/dist/extensions/forgecli/hooks/post-init-hook.d.ts +15 -0
  31. package/dist/extensions/forgecli/hooks/post-init-hook.js +127 -0
  32. package/dist/extensions/forgecli/hooks/post-init-hook.js.map +1 -0
  33. package/dist/extensions/forgecli/hooks/post-sprint-hook.d.ts +37 -0
  34. package/dist/extensions/forgecli/hooks/post-sprint-hook.js +166 -0
  35. package/dist/extensions/forgecli/hooks/post-sprint-hook.js.map +1 -0
  36. package/dist/extensions/forgecli/index.js +47 -0
  37. package/dist/extensions/forgecli/index.js.map +1 -1
  38. package/dist/extensions/forgecli/review-code.d.ts +24 -0
  39. package/dist/extensions/forgecli/review-code.js +202 -0
  40. package/dist/extensions/forgecli/review-code.js.map +1 -0
  41. package/dist/extensions/forgecli/review-plan.d.ts +24 -0
  42. package/dist/extensions/forgecli/review-plan.js +203 -0
  43. package/dist/extensions/forgecli/review-plan.js.map +1 -0
  44. package/dist/extensions/forgecli/run-sprint.d.ts +18 -0
  45. package/dist/extensions/forgecli/run-sprint.js +33 -1
  46. package/dist/extensions/forgecli/run-sprint.js.map +1 -1
  47. package/dist/extensions/forgecli/run-task.d.ts +21 -2
  48. package/dist/extensions/forgecli/run-task.js +33 -9
  49. package/dist/extensions/forgecli/run-task.js.map +1 -1
  50. package/dist/extensions/forgecli/session-registry.d.ts +10 -0
  51. package/dist/extensions/forgecli/session-registry.js +9 -0
  52. package/dist/extensions/forgecli/session-registry.js.map +1 -1
  53. package/dist/extensions/forgecli/validate.d.ts +24 -0
  54. package/dist/extensions/forgecli/validate.js +202 -0
  55. package/dist/extensions/forgecli/validate.js.map +1 -0
  56. package/dist/extensions/forgecli/wf-engine/engine.d.ts +23 -0
  57. package/dist/extensions/forgecli/wf-engine/engine.js +384 -0
  58. package/dist/extensions/forgecli/wf-engine/engine.js.map +1 -0
  59. package/dist/extensions/forgecli/wf-engine/event-parser.d.ts +6 -0
  60. package/dist/extensions/forgecli/wf-engine/event-parser.js +29 -0
  61. package/dist/extensions/forgecli/wf-engine/event-parser.js.map +1 -0
  62. package/dist/extensions/forgecli/wf-engine/id-gen.d.ts +6 -0
  63. package/dist/extensions/forgecli/wf-engine/id-gen.js +17 -0
  64. package/dist/extensions/forgecli/wf-engine/id-gen.js.map +1 -0
  65. package/dist/extensions/forgecli/wf-engine/loader.d.ts +2 -0
  66. package/dist/extensions/forgecli/wf-engine/loader.js +100 -0
  67. package/dist/extensions/forgecli/wf-engine/loader.js.map +1 -0
  68. package/dist/extensions/forgecli/wf-engine/predicate.d.ts +7 -0
  69. package/dist/extensions/forgecli/wf-engine/predicate.js +36 -0
  70. package/dist/extensions/forgecli/wf-engine/predicate.js.map +1 -0
  71. package/dist/extensions/forgecli/wf-engine/prompt-compiler.d.ts +15 -0
  72. package/dist/extensions/forgecli/wf-engine/prompt-compiler.js +23 -0
  73. package/dist/extensions/forgecli/wf-engine/prompt-compiler.js.map +1 -0
  74. package/dist/extensions/forgecli/wf-engine/register.d.ts +9 -0
  75. package/dist/extensions/forgecli/wf-engine/register.js +59 -0
  76. package/dist/extensions/forgecli/wf-engine/register.js.map +1 -0
  77. package/dist/extensions/forgecli/wf-engine/remit-check.d.ts +6 -0
  78. package/dist/extensions/forgecli/wf-engine/remit-check.js +42 -0
  79. package/dist/extensions/forgecli/wf-engine/remit-check.js.map +1 -0
  80. package/dist/extensions/forgecli/wf-engine/state-store.d.ts +13 -0
  81. package/dist/extensions/forgecli/wf-engine/state-store.js +43 -0
  82. package/dist/extensions/forgecli/wf-engine/state-store.js.map +1 -0
  83. package/dist/extensions/forgecli/wf-engine/types.d.ts +66 -0
  84. package/dist/extensions/forgecli/wf-engine/types.js +2 -0
  85. package/dist/extensions/forgecli/wf-engine/types.js.map +1 -0
  86. package/dist/extensions/forgecli/wf-engine/worker.d.ts +11 -0
  87. package/dist/extensions/forgecli/wf-engine/worker.js +50 -0
  88. package/dist/extensions/forgecli/wf-engine/worker.js.map +1 -0
  89. package/dist/forge-payload/.base-pack/workflows/_fragments/context-injection.md +10 -4
  90. package/dist/forge-payload/.base-pack/workflows/fix_bug.md +12 -0
  91. package/dist/forge-payload/.schemas/bug.schema.json +4 -2
  92. package/dist/forge-payload/.schemas/event.schema.json +22 -3
  93. package/dist/forge-payload/commands/add-pipeline.md +342 -0
  94. package/dist/forge-payload/commands/add-task.md +269 -0
  95. package/dist/forge-payload/commands/ask.md +43 -0
  96. package/dist/forge-payload/commands/calibrate.md +356 -0
  97. package/dist/forge-payload/commands/config.md +202 -0
  98. package/dist/forge-payload/commands/enhance.md +38 -0
  99. package/dist/forge-payload/commands/health.md +225 -0
  100. package/dist/forge-payload/commands/init.md +165 -0
  101. package/dist/forge-payload/commands/materialize.md +119 -0
  102. package/dist/forge-payload/commands/migrate.md +160 -0
  103. package/dist/forge-payload/commands/quiz-agent.md +38 -0
  104. package/dist/forge-payload/commands/regenerate.md +673 -0
  105. package/dist/forge-payload/commands/remove.md +174 -0
  106. package/dist/forge-payload/commands/report-bug.md +191 -0
  107. package/dist/forge-payload/commands/store-query.md +73 -0
  108. package/dist/forge-payload/commands/store-repair.md +187 -0
  109. package/dist/forge-payload/commands/update-tools.md +56 -0
  110. package/dist/forge-payload/commands/update.md +1376 -0
  111. package/dist/forge-payload/tools/preflight-gate.cjs +2 -1
  112. package/dist/forge-payload/tools/read-verdict.cjs +41 -8
  113. package/dist/forge-payload/tools/store-cli.cjs +4 -3
  114. package/node_modules/argparse/CHANGELOG.md +216 -0
  115. package/node_modules/argparse/LICENSE +254 -0
  116. package/node_modules/argparse/README.md +84 -0
  117. package/node_modules/argparse/argparse.js +3707 -0
  118. package/node_modules/argparse/lib/sub.js +67 -0
  119. package/node_modules/argparse/lib/textwrap.js +440 -0
  120. package/node_modules/argparse/package.json +31 -0
  121. package/node_modules/cliui/CHANGELOG.md +121 -0
  122. package/node_modules/color-convert/CHANGELOG.md +54 -0
  123. package/node_modules/esprima/ChangeLog +235 -0
  124. package/node_modules/js-yaml/LICENSE +21 -0
  125. package/node_modules/js-yaml/README.md +247 -0
  126. package/node_modules/js-yaml/bin/js-yaml.js +126 -0
  127. package/node_modules/js-yaml/dist/js-yaml.js +3880 -0
  128. package/node_modules/js-yaml/dist/js-yaml.min.js +2 -0
  129. package/node_modules/js-yaml/dist/js-yaml.mjs +3856 -0
  130. package/node_modules/js-yaml/index.js +47 -0
  131. package/node_modules/js-yaml/lib/common.js +59 -0
  132. package/node_modules/js-yaml/lib/dumper.js +965 -0
  133. package/node_modules/js-yaml/lib/exception.js +55 -0
  134. package/node_modules/js-yaml/lib/loader.js +1733 -0
  135. package/node_modules/js-yaml/lib/schema/core.js +11 -0
  136. package/node_modules/js-yaml/lib/schema/default.js +22 -0
  137. package/node_modules/js-yaml/lib/schema/failsafe.js +17 -0
  138. package/node_modules/js-yaml/lib/schema/json.js +19 -0
  139. package/node_modules/js-yaml/lib/schema.js +121 -0
  140. package/node_modules/js-yaml/lib/snippet.js +101 -0
  141. package/node_modules/js-yaml/lib/type/binary.js +125 -0
  142. package/node_modules/js-yaml/lib/type/bool.js +35 -0
  143. package/node_modules/js-yaml/lib/type/float.js +97 -0
  144. package/node_modules/js-yaml/lib/type/int.js +156 -0
  145. package/node_modules/js-yaml/lib/type/map.js +8 -0
  146. package/node_modules/js-yaml/lib/type/merge.js +12 -0
  147. package/node_modules/js-yaml/lib/type/null.js +35 -0
  148. package/node_modules/js-yaml/lib/type/omap.js +44 -0
  149. package/node_modules/js-yaml/lib/type/pairs.js +53 -0
  150. package/node_modules/js-yaml/lib/type/seq.js +8 -0
  151. package/node_modules/js-yaml/lib/type/set.js +29 -0
  152. package/node_modules/js-yaml/lib/type/str.js +8 -0
  153. package/node_modules/js-yaml/lib/type/timestamp.js +88 -0
  154. package/node_modules/js-yaml/lib/type.js +66 -0
  155. package/node_modules/js-yaml/package.json +66 -0
  156. package/node_modules/mz/HISTORY.md +66 -0
  157. package/node_modules/proper-lockfile/CHANGELOG.md +108 -0
  158. package/node_modules/source-map/CHANGELOG.md +301 -0
  159. package/node_modules/thenify/History.md +11 -0
  160. package/node_modules/thenify-all/History.md +11 -0
  161. package/node_modules/y18n/CHANGELOG.md +100 -0
  162. package/node_modules/yargs/CHANGELOG.md +88 -0
  163. package/node_modules/yargs-parser/CHANGELOG.md +263 -0
  164. package/package.json +6 -2
  165. package/workflows/lead-qualifier/prompts/digest.md +44 -0
  166. package/workflows/lead-qualifier/prompts/draft-outreach.md +44 -0
  167. package/workflows/lead-qualifier/prompts/enrich.md +52 -0
  168. package/workflows/lead-qualifier/prompts/intake.md +48 -0
  169. package/workflows/lead-qualifier/prompts/mark-cold.md +38 -0
  170. package/workflows/lead-qualifier/prompts/score.md +45 -0
  171. package/workflows/lead-qualifier/workflow.yaml +95 -0
  172. package/workflows/research-brief/prompts/brief-synthesize.md +43 -0
  173. package/workflows/research-brief/prompts/intake.md +51 -0
  174. package/workflows/research-brief/prompts/source-critique.md +38 -0
  175. package/workflows/research-brief/prompts/source-score.md +38 -0
  176. package/workflows/research-brief/prompts/source-summarize.md +54 -0
  177. package/workflows/research-brief/workflow.yaml +66 -0
  178. package/dist/extensions/forgecli/session-monitor-widget.d.ts +0 -37
  179. package/dist/extensions/forgecli/session-monitor-widget.js +0 -320
  180. package/dist/extensions/forgecli/session-monitor-widget.js.map +0 -1
  181. package/dist/extensions/forgecli/session-monitor.d.ts +0 -2
  182. package/dist/extensions/forgecli/session-monitor.js +0 -135
  183. package/dist/extensions/forgecli/session-monitor.js.map +0 -1
@@ -0,0 +1,673 @@
1
+ ---
2
+ name: regenerate
3
+ description: Use when the engineering knowledge base has been enriched by sprints and you want to refresh the generated workflows, templates, tools, or knowledge-base docs
4
+ ---
5
+
6
+ # /forge:regenerate
7
+
8
+ Re-run generation phases using the current state of the project.
9
+
10
+ ## Locate the Forge plugin
11
+
12
+ ```
13
+ FORGE_ROOT: !`echo "${CLAUDE_PLUGIN_ROOT}"`
14
+ ```
15
+
16
+ Read `.forge/config.json`. If it does not exist, stop and tell the user to run
17
+ `/forge:init` first.
18
+
19
+ Resolve tools from the plugin:
20
+ ```
21
+ FORGE_ROOT: !`echo "${CLAUDE_PLUGIN_ROOT}"`
22
+ ```
23
+
24
+ All tool invocations in this command use `node "$FORGE_ROOT/tools/<tool>.cjs"`.
25
+
26
+ ## Hero
27
+
28
+ Open the run with the forge hero + a one-line subtitle (parses
29
+ `$ARGUMENTS` to mention the target):
30
+
31
+ ```sh
32
+ node "$FORGE_ROOT/tools/banners.cjs" forge
33
+ node "$FORGE_ROOT/tools/banners.cjs" --subtitle "Re-running generation against current meta-definitions ($ARGUMENTS or full)"
34
+ ```
35
+
36
+ Each category section below opens with a `banners.cjs --badge {key}` call
37
+ before its "Generating ..." line. The badge map:
38
+
39
+ | Category | Banner key |
40
+ |----------|-----------|
41
+ | personas | `bloom` |
42
+ | skills | `tide` |
43
+ | templates | `drift` |
44
+ | workflows | `ember` |
45
+ | commands | `lumen` |
46
+ | knowledge-base | `oracle` |
47
+
48
+ `banners.cjs` strips ANSI in `NO_COLOR` / non-tty / `--plain` contexts.
49
+
50
+ ## Fast-mode awareness
51
+
52
+ Regenerate respects `.forge/config.json` `mode`. Read it once at the top of
53
+ the command and reuse:
54
+
55
+ ```sh
56
+ CONFIG_MODE=$(node "$FORGE_ROOT/tools/manage-config.cjs" get mode 2>/dev/null || echo "full")
57
+ ```
58
+
59
+ If `CONFIG_MODE` is not `"fast"` (i.e. `"full"` or anything else), every
60
+ category below behaves exactly as it always has — no filtering, no mode
61
+ write. The fast-mode handling only kicks in when `CONFIG_MODE == "fast"`.
62
+
63
+ ### Materialized detection (fast mode only)
64
+
65
+ A target file is **materialized** if:
66
+
67
+ | Namespace | Materialized if… |
68
+ |---|---|
69
+ | `.forge/workflows/<id>.md` | File exists AND its first non-blank line does not begin with `<!-- FORGE FAST-MODE STUB` |
70
+ | `.forge/personas/<role>.md` | File exists |
71
+ | `.forge/skills/<role>-skills.md` | File exists |
72
+ | `.forge/templates/<STEM>.md` | File exists |
73
+ | `.claude/commands/<name>` | Always present in fast mode — no filter needed |
74
+
75
+ For each meta source enumerated below, derive the target path using the
76
+ existing single-file mapping rules in each category and apply the test.
77
+
78
+ The stub sentinel `<!-- FORGE FAST-MODE STUB` is written by `/forge:init`
79
+ Phase 7 fast branch — see `forge/init/sdlc-init.md`.
80
+
81
+ ### Single-file variants in fast mode
82
+
83
+ For any single-file invocation (e.g. `/forge:regenerate workflows:plan_task`)
84
+ where `CONFIG_MODE == "fast"`:
85
+ - If the target is materialized → regenerate as normal.
86
+ - If the target is a stub or missing → emit
87
+ `〇 Fast mode: <path> is a stub and will self-refresh on first use. Nothing to regenerate.`
88
+ and exit 0 (no manifest changes).
89
+
90
+ ### Default (no-args) in fast mode
91
+
92
+ The default run filters every category through the materialized check and
93
+ emits a per-category summary footer. **It does NOT write `mode`** — mode
94
+ promotion is a separate, explicit decision owned by `/forge:config mode full`.
95
+
96
+ ## Arguments
97
+
98
+ $ARGUMENTS
99
+
100
+ Parse the argument to identify the target category and optional sub-target.
101
+ Sub-targets may be passed either as a second positional argument or embedded
102
+ with a colon delimiter (both forms are equivalent):
103
+
104
+ ```
105
+ /forge:regenerate # workflows + commands + templates + personas (default)
106
+ /forge:regenerate personas # .forge/personas/ — all persona files
107
+ /forge:regenerate personas engineer # single persona file only
108
+ /forge:regenerate personas:engineer # same — colon form (from migration entries)
109
+ /forge:regenerate skills # .forge/skills/ role-specific skills
110
+ /forge:regenerate skills engineer # single skill file only
111
+ /forge:regenerate skills:engineer # same — colon form (from migration entries)
112
+ /forge:regenerate workflows # full workflow rebuild
113
+ /forge:regenerate workflows plan_task # single workflow file only
114
+ /forge:regenerate workflows:plan_task # same — colon form (from migration entries)
115
+ /forge:regenerate workflows sprint_plan # single workflow file only
116
+ /forge:regenerate commands # .claude/commands/ slash command wrappers
117
+ /forge:regenerate templates # document templates only
118
+ /forge:regenerate templates PLAN_TEMPLATE # single template file only
119
+ /forge:regenerate templates:PLAN_TEMPLATE # same — colon form (from migration entries)
120
+ /forge:regenerate knowledge-base # all three sub-targets (merge mode)
121
+ /forge:regenerate knowledge-base architecture
122
+ /forge:regenerate knowledge-base:architecture # colon form (from migration entries)
123
+ /forge:regenerate knowledge-base business-domain
124
+ /forge:regenerate knowledge-base stack-checklist
125
+ ```
126
+
127
+ When parsing the argument, split on `:` first: if the argument is
128
+ `"workflows:plan_task"`, treat it as category=`workflows`,
129
+ sub-target=`plan_task`. If no `:` is present, the second positional word
130
+ (if any) is the sub-target. The sub-target is always optional.
131
+
132
+ ---
133
+
134
+ ## Category: `personas` — full rebuild or single file
135
+
136
+ Re-generate `.forge/personas/` from the meta-persona definitions and the current knowledge base.
137
+
138
+ **If a sub-target is provided** (e.g. `/forge:regenerate personas engineer`
139
+ or the colon form `personas:engineer`), regenerate only the single persona
140
+ file `.forge/personas/<sub-target>.md` from `$FORGE_ROOT/meta/personas/meta-<sub-target>.md`.
141
+
142
+ If `CONFIG_MODE == "fast"`: apply the single-file materialized check
143
+ (persona is materialized iff `.forge/personas/<sub-target>.md` exists). If
144
+ not materialized, emit the stub-or-missing message and exit 0. Otherwise
145
+ proceed.
146
+
147
+ Before writing, remove any existing manifest entry for this specific file (handles rename case):
148
+ ```sh
149
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" remove .forge/personas/<sub-target>.md 2>/dev/null || true
150
+ ```
151
+ Generate the single file (no fan-out needed for one file). All manifest and hash
152
+ steps below apply to that single file.
153
+
154
+ **If no sub-target** — full rebuild, fanned out in parallel:
155
+
156
+ 1. Build the project brief:
157
+ ```sh
158
+ node "$FORGE_ROOT/tools/build-init-context.cjs" \
159
+ --config .forge/config.json --personas .forge/personas \
160
+ --templates .forge/templates --kb "$(node "$FORGE_ROOT/tools/manage-config.cjs" get paths.engineering 2>/dev/null || echo engineering)" \
161
+ --out .forge/init-context.md --json-out .forge/init-context.json
162
+ ```
163
+ 2. Enumerate `$FORGE_ROOT/meta/personas/meta-*.md` (exclude README.md).
164
+ Let `M_total` = the enumerated count.
165
+
166
+ **If `CONFIG_MODE == "fast"`**: filter the enumeration to only entries
167
+ whose target file `.forge/personas/<role>.md` exists (materialized check).
168
+ Let `N_materialized` = the filtered count.
169
+ - If `N_materialized == 0`: emit `〇 Fast mode: no materialized personas to regenerate.` and return 0 (no manifest changes).
170
+ - Otherwise continue with the filtered set; do NOT clear the namespace
171
+ (skip step 4) — clearing would remove manifest entries for stubs/missing
172
+ entries that we are intentionally leaving alone. Instead, only `remove`
173
+ manifest entries for the files we are about to regenerate (mirrors the
174
+ single-file pattern):
175
+ ```sh
176
+ for each filtered entry:
177
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" remove .forge/personas/<role>.md 2>/dev/null || true
178
+ ```
179
+
180
+ 3. Render the personas badge, then emit the count:
181
+ ```sh
182
+ node "$FORGE_ROOT/tools/banners.cjs" --badge bloom
183
+ ```
184
+ Then emit: `Generating personas (<N> files in parallel)...` — use `N_materialized` in fast mode, `M_total` in full mode.
185
+ 4. **Full mode only**: clear stale entries (skip in fast mode — see step 2):
186
+ ```sh
187
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" clear-namespace .forge/personas/
188
+ ```
189
+ 5. **Spawn the persona subagents in a SINGLE Agent tool message** using
190
+ `$FORGE_ROOT/init/generation/generate-persona.md` as the per-subagent rulebook
191
+ (same fan-out pattern as `/forge:init` Phase 4). Spawn one per filtered
192
+ entry — every entry in fast mode, every meta source in full mode.
193
+ 6. Collect results. For each `done:` result → emit ` 〇 <filename>.md`.
194
+ Retry failures once. Any still failing: surface the id list.
195
+ 7. Emit ` 〇 personas — <N> files written` (fast mode appends ` (M-N deferred)` when `N < M`).
196
+
197
+ ---
198
+
199
+ ## Category: `skills` — full rebuild or single file
200
+
201
+ Re-generate `.forge/skills/` from the meta-skill templates and project config.
202
+
203
+ **If a sub-target is provided** (e.g. `/forge:regenerate skills engineer`
204
+ or the colon form `skills:engineer`), regenerate only the single skill file
205
+ `.forge/skills/<sub-target>-skills.md` from
206
+ `$FORGE_ROOT/meta/skills/meta-<sub-target>-skills.md`.
207
+
208
+ If `CONFIG_MODE == "fast"`: apply the single-file materialized check
209
+ (skill is materialized iff `.forge/skills/<sub-target>-skills.md` exists).
210
+ If not materialized, emit the stub-or-missing message and exit 0. Otherwise
211
+ proceed.
212
+
213
+ Before writing, remove any existing manifest entry for this specific file:
214
+ ```sh
215
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" remove .forge/skills/<sub-target>-skills.md 2>/dev/null || true
216
+ ```
217
+ Generate the single file (no fan-out needed). All manifest and hash steps below
218
+ apply to that single file.
219
+
220
+ **If no sub-target** — full rebuild, fanned out in parallel:
221
+
222
+ 1. Build the project brief (same command as in `personas` above).
223
+ 2. Enumerate `$FORGE_ROOT/meta/skills/meta-*-skills.md`. Let `M_total` =
224
+ the enumerated count.
225
+
226
+ **If `CONFIG_MODE == "fast"`**: filter to entries whose target file
227
+ `.forge/skills/<role>-skills.md` exists. Let `N_materialized` = filtered
228
+ count.
229
+ - If `N_materialized == 0`: emit `〇 Fast mode: no materialized skills to regenerate.` and return 0.
230
+ - Otherwise continue with the filtered set; skip step 4 (do not clear
231
+ namespace), and `remove` manifest entries only for the filtered files.
232
+
233
+ 3. Render the skills badge, then emit the count:
234
+ ```sh
235
+ node "$FORGE_ROOT/tools/banners.cjs" --badge tide
236
+ ```
237
+ Then emit: `Generating skills (<N> files in parallel)...`
238
+ 4. **Full mode only**: clear stale entries (skip in fast mode):
239
+ ```sh
240
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" clear-namespace .forge/skills/
241
+ ```
242
+ 5. **Spawn the skill subagents in a SINGLE Agent tool message** using
243
+ `$FORGE_ROOT/init/generation/generate-skill.md` as the per-subagent rulebook.
244
+ 6. Collect results. Retry failures once. Any still failing: surface the id list.
245
+ 7. For each completed file, check manifest (warn on modified), emit ` 〇 <filename>.md`.
246
+ Fast mode appends `〇 skills — <N> files written (M-N deferred)` when `N < M`.
247
+
248
+ ---
249
+
250
+ ## Category: `workflows` — full rebuild or single file
251
+
252
+ Re-generate `.forge/workflows/` from the meta-workflow definitions and the
253
+ current knowledge base. Covers both atomic workflows and orchestration.
254
+
255
+ **If a sub-target is provided** (e.g. `/forge:regenerate workflows plan_task`
256
+ or the colon form `workflows:plan_task`), regenerate only the single workflow
257
+ file `.forge/workflows/<sub-target>.md`.
258
+
259
+ **Special case — `_fragments` sub-target (directory fan-out):**
260
+
261
+ `_fragments` is a directory in `$FORGE_ROOT/meta/workflows/_fragments/`, not a
262
+ single file. When the sub-target is `_fragments` (or when
263
+ `$FORGE_ROOT/meta/workflows/<sub-target>` resolves to a directory rather than a
264
+ file), use directory fan-out mode instead of single-file mode:
265
+
266
+ 1. Enumerate all `.md` files in `$FORGE_ROOT/meta/workflows/_fragments/`.
267
+ 2. Ensure `.forge/workflows/_fragments/` directory exists (create if absent).
268
+ 3. For each fragment file, copy verbatim (no placeholder substitution) to
269
+ `.forge/workflows/_fragments/<filename>`.
270
+ 4. Record a manifest hash for each copied file:
271
+ ```sh
272
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" record .forge/workflows/_fragments/<filename>
273
+ ```
274
+ 5. Emit `〇 workflows:_fragments — N fragment files copied`.
275
+
276
+ > **Note:** When invoked as `/forge:regenerate workflows:_fragments`, this command
277
+ > fans out to copy all fragment files (currently four: `context-injection.md`,
278
+ > `progress-reporting.md`, `event-emission-schema.md`, `finalize.md`). Verify the
279
+ > result with `ls .forge/workflows/_fragments/`.
280
+
281
+ For all other sub-targets (non-directory), continue with the standard single-file
282
+ path below.
283
+
284
+ If `CONFIG_MODE == "fast"`: apply the single-file materialized check —
285
+ the workflow file must exist AND its first non-blank line must NOT begin
286
+ with `<!-- FORGE FAST-MODE STUB`. If the file is a stub or missing, emit
287
+ the stub-or-missing message and exit 0. Otherwise proceed.
288
+
289
+ Before writing, remove any existing
290
+ manifest entry for this specific file:
291
+ ```sh
292
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" remove .forge/workflows/<sub-target>.md 2>/dev/null || true
293
+ ```
294
+ Generate the single file (no fan-out needed). Check manifest (warn on modified),
295
+ write, record hash.
296
+
297
+ **If no sub-target** — full rebuild using the same parallel fan-out as `/forge:init` Phase 7:
298
+
299
+ 1. Build the project brief:
300
+ ```sh
301
+ node "$FORGE_ROOT/tools/build-init-context.cjs" \
302
+ --config .forge/config.json --personas .forge/personas \
303
+ --templates .forge/templates \
304
+ --kb "$(node "$FORGE_ROOT/tools/manage-config.cjs" get paths.engineering 2>/dev/null || echo engineering)" \
305
+ --out .forge/init-context.md --json-out .forge/init-context.json
306
+ ```
307
+ 2. Read `$FORGE_ROOT/init/workflow-gen-plan.json` (16-entry fan-out table).
308
+ Let `M_total` = the entry count.
309
+
310
+ **If `CONFIG_MODE == "fast"`**: filter to entries whose target file
311
+ `.forge/workflows/<id>.md` is materialized (exists AND first non-blank
312
+ line does not begin with `<!-- FORGE FAST-MODE STUB`).
313
+ Let `N_materialized` = filtered count.
314
+ - If `N_materialized == 0`: emit `〇 Fast mode: no materialized workflows to regenerate.` and return 0 (no manifest changes, orchestration skipped — orchestration only makes sense with a complete workflow set).
315
+ - Otherwise continue with the filtered set.
316
+
317
+ 3. Render the workflows badge, then emit the count:
318
+ ```sh
319
+ node "$FORGE_ROOT/tools/banners.cjs" --badge ember
320
+ ```
321
+ Then emit: `Generating workflows (<N> atomic + orchestration, parallel)...` —
322
+ in fast mode, omit the orchestration suffix when filtering applies.
323
+ 4. Check each (filtered) file for manual modifications before any clearing:
324
+ ```sh
325
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" check .forge/workflows/{filename}.md
326
+ ```
327
+ For any exit 1 (modified): warn `△ .forge/workflows/{filename}.md has been manually
328
+ modified. Overwriting will discard your changes. Proceed? (yes / no / show diff)`
329
+ Collect answers before proceeding.
330
+ 5. **Full mode only**: clear stale entries (skip in fast mode — clearing
331
+ would drop manifest entries for stubs we are intentionally leaving alone):
332
+ ```sh
333
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" clear-namespace .forge/workflows/
334
+ ```
335
+ In fast mode, only `remove` manifest entries for the filtered files
336
+ that are about to be regenerated.
337
+ 6. **Spawn the atomic workflow subagents in a SINGLE Agent tool message** using
338
+ `$FORGE_ROOT/init/generation/generate-workflows.md` as the per-subagent rulebook
339
+ (same fan-out pattern as `/forge:init` Phase 7d). Spawn one per filtered
340
+ entry.
341
+ 7. Collect results. Retry failures once in a single Agent call.
342
+ 8. **Full mode only**: spawn orchestration subagent. **In fast mode this
343
+ step is skipped** — orchestration depends on the complete workflow set
344
+ being present and refreshed; running it against a partially materialised
345
+ project would produce stale references. Orchestration files
346
+ (`orchestrate_task.md`, `run_sprint.md`) refresh on full promotion or
347
+ when workflows is fully rebuilt.
348
+ ```
349
+ Read $FORGE_ROOT/init/generation/generate-orchestration.md and follow it.
350
+ FORGE_ROOT: {FORGE_ROOT}
351
+ Input: $FORGE_ROOT/meta/workflows/meta-orchestrate.md + .forge/workflows/
352
+ Output: .forge/workflows/orchestrate_task.md and .forge/workflows/run_sprint.md
353
+ ```
354
+ 9. For each written file: record hash `node "$FORGE_ROOT/tools/generation-manifest.cjs" record .forge/workflows/{filename}.md`
355
+ 10. Emit ` 〇 workflows — <N> files written` (full mode: 18; fast mode:
356
+ `〇 workflows — N of M files regenerated (others remain as stubs)`).
357
+
358
+ **Do NOT touch:** `.claude/commands/`, `.forge/config.json`, or any knowledge base file.
359
+
360
+ ---
361
+
362
+ ## Category: `commands` — full rebuild
363
+
364
+ Re-generate `.claude/commands/` slash command wrappers from the current
365
+ `.forge/workflows/`. This is a thin generation step — each command file
366
+ is just a wrapper that loads its workflow and passes arguments.
367
+
368
+ Run this when:
369
+ - Workflow files have been renamed (e.g. after a 0.5.0 upgrade)
370
+ - A new workflow was added and its command wrapper is missing
371
+ - A command wrapper is pointing at a workflow that no longer exists
372
+
373
+ 1. Read `.forge/config.json` for paths
374
+ 2. Enumerate `.forge/workflows/` to know what workflow files currently exist
375
+ 3. Render the commands badge, then emit the count:
376
+ ```sh
377
+ node "$FORGE_ROOT/tools/banners.cjs" --badge lumen
378
+ ```
379
+ Then emit: `Generating commands (<N> files)...`
380
+ 4. Clear stale entries for this namespace:
381
+ ```sh
382
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" clear-namespace .claude/commands/
383
+ ```
384
+ 5. Re-generate `.claude/commands/` following
385
+ `$FORGE_ROOT/init/generation/generate-commands.md`
386
+ The idempotency check will overwrite any command that references a
387
+ missing or renamed workflow, and skip any that are already correct.
388
+ 6. For each file being written:
389
+ - Emit: ` ⋯ <filename>.md...`
390
+ - Write the file
391
+ - Record hash: `node "$FORGE_ROOT/tools/generation-manifest.cjs" record .claude/commands/{filename}.md`
392
+ - Emit: ` 〇 <filename>.md`
393
+
394
+ **DO NOT** touch any `.claude/commands/` file that is not in the output list
395
+ in `generate-commands.md`. Custom commands (`supervisor-code.md`, project-specific
396
+ wrappers, etc.) must never be written, overwritten, or deleted by this step.
397
+ Retired Forge command files (`engineer.md`, `supervisor.md`) are cleaned up
398
+ separately by Step 5b-pre in `/forge:update` — not here.
399
+
400
+ ---
401
+
402
+ ## Category: `templates` — full rebuild or single file
403
+
404
+ Re-generate `.forge/templates/` from the meta-template definitions and the
405
+ current knowledge base.
406
+
407
+ **If a sub-target is provided** (e.g. `/forge:regenerate templates PLAN_TEMPLATE`
408
+ or the colon form `templates:PLAN_TEMPLATE`), regenerate only the single template
409
+ file `.forge/templates/<sub-target>.md`. Determine the source meta file from
410
+ `$FORGE_ROOT/init/generation/generate-template.md`'s filename mapping (e.g.
411
+ `PLAN_TEMPLATE` → `meta-plan.md`).
412
+
413
+ If `CONFIG_MODE == "fast"`: apply the single-file materialized check
414
+ (template is materialized iff `.forge/templates/<sub-target>.md` exists).
415
+ If not materialized, emit the stub-or-missing message and exit 0. Otherwise
416
+ proceed.
417
+
418
+ Before writing, remove any existing manifest
419
+ entry:
420
+ ```sh
421
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" remove .forge/templates/<sub-target>.md 2>/dev/null || true
422
+ ```
423
+ Generate the single file (no fan-out needed). Record hash after writing.
424
+
425
+ **If no sub-target** — full rebuild, fanned out in parallel:
426
+
427
+ 1. Build the project brief (same command as in `personas` above).
428
+ 2. Enumerate `$FORGE_ROOT/meta/templates/meta-*.md`. Let `M_total` =
429
+ the enumerated count.
430
+
431
+ **If `CONFIG_MODE == "fast"`**: filter to entries whose target file
432
+ `.forge/templates/<STEM>.md` exists (use the same filename mapping as
433
+ the single-file variant). Let `N_materialized` = filtered count.
434
+ - If `N_materialized == 0`: emit `〇 Fast mode: no materialized templates to regenerate.` and return 0.
435
+ - Otherwise continue with the filtered set; skip step 5 (do not clear
436
+ namespace), and only `remove` manifest entries for the filtered files.
437
+
438
+ 3. Render the templates badge, then emit the count:
439
+ ```sh
440
+ node "$FORGE_ROOT/tools/banners.cjs" --badge drift
441
+ ```
442
+ Then emit: `Generating templates (<N> files in parallel)...`
443
+ 4. Check each (filtered) file for manual modifications (warn on modified, same pattern as workflows).
444
+ 5. **Full mode only**: clear stale entries (skip in fast mode):
445
+ ```sh
446
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" clear-namespace .forge/templates/
447
+ ```
448
+ 6. **Spawn the template subagents in a SINGLE Agent tool message** using
449
+ `$FORGE_ROOT/init/generation/generate-template.md` as the per-subagent rulebook.
450
+ 7. Collect results. Retry failures once. Any still failing: surface the id list.
451
+ 8. For each written file: record hash, emit ` 〇 <filename>.md`.
452
+ 9. Re-record the one-shot init artifact not regenerated from a meta file:
453
+ ```sh
454
+ if [ -f ".forge/templates/CUSTOM_COMMAND_TEMPLATE.md" ]; then
455
+ node "$FORGE_ROOT/tools/generation-manifest.cjs" record .forge/templates/CUSTOM_COMMAND_TEMPLATE.md
456
+ fi
457
+ ```
458
+ Fast-mode footer: emit `〇 templates — <N> files written (M-N deferred)` when `N < M`.
459
+
460
+ ---
461
+
462
+ ## Category: `knowledge-base` — merge mode
463
+
464
+ **This is not a full rebuild.** The knowledge base accumulates writeback from
465
+ every sprint. Overwriting it from scratch destroys that accumulated knowledge.
466
+
467
+ Render the knowledge-base badge, then emit the status line:
468
+
469
+ ```sh
470
+ node "$FORGE_ROOT/tools/banners.cjs" --badge oracle
471
+ ```
472
+
473
+ Then emit: `Generating knowledge-base...`
474
+
475
+ Instead: re-run the relevant discovery prompts scoped to what has changed,
476
+ compute a delta against the existing docs, and merge only new content in.
477
+
478
+ **Per sub-target, emit merge-level status lines (not per-file):**
479
+
480
+ ```
481
+ ⋯ merging <sub-target> docs...
482
+ 〇 <sub-target> — N additions
483
+ ```
484
+
485
+ **Merge rule (applies to all sub-targets):**
486
+ - Additive only — never remove or overwrite existing sections or entries.
487
+ - `[?]` markers from prior generation may be updated if the re-scan can now
488
+ confirm or correct them.
489
+ - If the re-scan detects something that contradicts existing content, flag it
490
+ as a `[CONFLICT]` comment for human review — do not resolve it silently.
491
+ - Show all proposed additions as a diff and prompt before writing.
492
+
493
+ ---
494
+
495
+ ### Sub-target: `architecture`
496
+
497
+ **Trigger:** new subsystems, services, or integrations have been added to the
498
+ codebase since the architecture docs were last written.
499
+
500
+ **Re-run discovery (in parallel):**
501
+ - `$FORGE_ROOT/init/discovery/discover-stack.md`
502
+ - `$FORGE_ROOT/init/discovery/discover-processes.md`
503
+ - `$FORGE_ROOT/init/discovery/discover-routing.md`
504
+
505
+ **Read existing docs:**
506
+ - `engineering/architecture/*.md`
507
+
508
+ **Merge into:**
509
+
510
+ | Discovery output | Target doc | Merge action |
511
+ |-----------------|-----------|-------------|
512
+ | New framework or runtime | `stack.md` | Append to technology inventory |
513
+ | New service or process | `processes.md` | Append new service section |
514
+ | New API route group | `routing.md` | Append route group |
515
+ | New deployment target | `deployment.md` | Append environment section |
516
+ | Any new sub-system with no existing doc | Create new sub-doc + link from `INDEX.md` |
517
+
518
+ ---
519
+
520
+ ### Sub-target: `business-domain`
521
+
522
+ **Trigger:** new ORM models, schema tables, or domain types have been added
523
+ to the codebase. `forge:health` will flag these as orphaned entities.
524
+
525
+ **Re-run discovery:**
526
+ - `$FORGE_ROOT/init/discovery/discover-database.md`
527
+
528
+ **Read existing doc:**
529
+ - `engineering/business-domain/entity-model.md`
530
+
531
+ **Merge into `entity-model.md`:**
532
+ - Entities present in discovery output but absent from the doc → append new
533
+ entity sections with fields and relationships.
534
+ - New fields on an existing entity → add within the existing entity section,
535
+ marked `[NEW]` for team review.
536
+ - Entities no longer found in the codebase → flag with `[NOT FOUND IN SCAN]`
537
+ comment but do not remove (may be soft-deleted, feature-flagged, or in a
538
+ migration).
539
+
540
+ ---
541
+
542
+ ### Sub-target: `stack-checklist`
543
+
544
+ **Trigger:** new libraries or frameworks have been adopted mid-project that
545
+ are not yet represented in review checklist items.
546
+
547
+ **Re-run discovery:**
548
+ - `$FORGE_ROOT/init/discovery/discover-stack.md`
549
+ - `$FORGE_ROOT/init/discovery/discover-testing.md`
550
+
551
+ **Read existing doc:**
552
+ - `engineering/stack-checklist.md`
553
+
554
+ **Merge into `stack-checklist.md`:**
555
+ - Libraries detected but not yet in the checklist → append new checklist items.
556
+ - Never remove or modify existing items (they encode accumulated review knowledge).
557
+
558
+ ---
559
+
560
+ ## Default (no argument)
561
+
562
+ Run all five categories respecting dependencies — with maximum parallelism:
563
+
564
+ 1. **Build brief** (once, synchronous):
565
+ ```sh
566
+ node "$FORGE_ROOT/tools/build-init-context.cjs" \
567
+ --config .forge/config.json --personas .forge/personas \
568
+ --templates .forge/templates \
569
+ --kb "$(node "$FORGE_ROOT/tools/manage-config.cjs" get paths.engineering 2>/dev/null || echo engineering)" \
570
+ --out .forge/init-context.md --json-out .forge/init-context.json
571
+ ```
572
+
573
+ 2. **Personas + Templates in parallel** (both need only KB, not each other):
574
+ Spawn persona fan-out and template fan-out in a **SINGLE Agent tool message**
575
+ (all persona subagents + all template subagents together). Wait for all to return.
576
+
577
+ 3. **Skills + Workflows in parallel** (skills need personas; workflows need personas + templates — both now ready):
578
+ Spawn skill fan-out and workflow fan-out (16 atomic) in a **SINGLE Agent tool message**.
579
+ Wait for all to return.
580
+
581
+ 4. **Orchestration + Commands in parallel** (both need workflows — now ready):
582
+ Spawn orchestration and commands subagents in a **SINGLE Agent tool message**.
583
+ Wait for both.
584
+
585
+ This runs in 4 serial steps instead of 5 sequential category passes, with all
586
+ fan-outs parallelised within each step.
587
+
588
+ Each category honours the materialized filter described in **Fast-mode
589
+ awareness** above. The default run **does NOT write `mode`** — promotion
590
+ is owned by `/forge:config mode full`. Mode stays `fast` until the user
591
+ runs that command.
592
+
593
+ ### Fast-mode completion footer
594
+
595
+ When `CONFIG_MODE == "fast"`, after all four steps succeed, emit a summary
596
+ footer (use the per-category counts collected during each fan-out):
597
+
598
+ ```
599
+ 〇 Regenerate complete (fast mode)
600
+ personas — N of M regenerated
601
+ templates — N of M regenerated
602
+ skills — N of M regenerated
603
+ workflows — N of M regenerated (others remain as stubs)
604
+ commands — always present, regenerated normally
605
+
606
+ 〇 To promote to full mode: /forge:config mode full
607
+ ```
608
+
609
+ Full-mode projects are unaffected — the mode check short-circuits to the
610
+ existing full-rebuild behaviour. No filter, no footer.
611
+
612
+ ## On error
613
+
614
+ If any step above fails unexpectedly, describe what went wrong and ask:
615
+
616
+ > "This looks like a Forge bug. Would you like to file a report to help improve it? Run `/forge:report-bug` — I'll pre-fill the report from this conversation."
617
+
618
+ ---
619
+
620
+ ## Post-regeneration persona pack
621
+
622
+ Rebuild the compact persona/skill reference pack at
623
+ `.forge/cache/persona-pack.json`. This is consumed by `meta-orchestrate` and
624
+ `meta-fix-bug` to inject persona references (not verbatim prose) into
625
+ subagent prompts when `FORGE_PROMPT_MODE=reference` (the default).
626
+
627
+ The pack compiles YAML frontmatter from `$FORGE_ROOT/meta/personas/meta-*.md`
628
+ and `$FORGE_ROOT/meta/skills/meta-*.md`. It is safe to rebuild on every
629
+ regenerate run (cost: ~50ms, 16 files).
630
+
631
+ ```sh
632
+ node "$FORGE_ROOT/tools/build-persona-pack.cjs" \
633
+ --out .forge/cache/persona-pack.json
634
+ ```
635
+
636
+ - Exit 0: emit `〇 persona pack refreshed`
637
+ - Exit 1: surface the stderr message (it includes the offending file path
638
+ for missing-frontmatter or malformed-YAML errors) and advise the user
639
+ to file a bug if the error is unexpected.
640
+
641
+ ## Post-regeneration context pack
642
+
643
+ Rebuild the architecture context pack at `.forge/cache/context-pack.md` and
644
+ `.forge/cache/context-pack.json`. This is injected into subagent prompts by
645
+ `meta-orchestrate` and `meta-fix-bug` to reduce per-phase architecture doc reads.
646
+
647
+ The pack summarises `engineering/architecture/*.md` (skips `*.draft.md`). If
648
+ the existing pack has `manual: true` in its frontmatter, the builder skips
649
+ and leaves it intact.
650
+
651
+ ```sh
652
+ ENGINEERING=$(node "$FORGE_ROOT/tools/manage-config.cjs" get paths.engineering 2>/dev/null || echo engineering)
653
+ node "$FORGE_ROOT/tools/build-context-pack.cjs" \
654
+ --arch-dir "$ENGINEERING/architecture" \
655
+ --out-md .forge/cache/context-pack.md \
656
+ --out-json .forge/cache/context-pack.json
657
+ ```
658
+
659
+ - Exit 0: emit `〇 context pack refreshed`
660
+ - Exit 1: surface the stderr message — most likely the architecture directory
661
+ does not exist yet (run after the knowledge-base category is populated).
662
+ This is non-fatal for regenerate: emit a warning and continue.
663
+
664
+ ## Post-regeneration verification
665
+
666
+ After all requested targets have been regenerated, verify structural completeness:
667
+
668
+ ```sh
669
+ node "$FORGE_ROOT/tools/check-structure.cjs" --path .
670
+ ```
671
+
672
+ - If exit 0: emit `〇 All expected generated files are present.`
673
+ - If exit 1: list the missing files by namespace and suggest running `/forge:regenerate <namespace>` for the affected category or categories.