bmad-module-skill-forge 2.0.0 → 2.0.1

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 (235) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.nvmrc +1 -1
  3. package/docs/_data/pinned.yaml +1 -1
  4. package/package.json +2 -2
  5. package/src/knowledge/skill-lifecycle.md +1 -1
  6. package/src/module-help.csv +2 -2
  7. package/src/shared/scripts/skf-comention-pairs.py +350 -0
  8. package/src/shared/scripts/skf-count-tokens.py +222 -0
  9. package/src/shared/scripts/skf-detect-docs.py +232 -1
  10. package/src/shared/scripts/skf-detect-language.py +77 -0
  11. package/src/shared/scripts/skf-detect-tools.py +105 -2
  12. package/src/shared/scripts/skf-enumerate-stack-skills.py +111 -2
  13. package/src/shared/scripts/skf-find-cycles.py +246 -0
  14. package/src/shared/scripts/skf-hash-content.py +487 -2
  15. package/src/shared/scripts/skf-manifest-ops.py +67 -1
  16. package/src/shared/scripts/skf-rebuild-managed-sections.py +180 -0
  17. package/src/shared/scripts/skf-recommend-scope-type.py +1 -2
  18. package/src/shared/scripts/skf-render-metadata-stats.py +499 -0
  19. package/src/shared/scripts/skf-rewrite-skill-name.py +308 -0
  20. package/src/shared/scripts/skf-shard-body.py +461 -0
  21. package/src/shared/scripts/skf-skill-inventory.py +139 -3
  22. package/src/shared/scripts/skf-structural-diff.py +307 -67
  23. package/src/shared/scripts/skf-validate-brief-schema.py +39 -1
  24. package/src/shared/scripts/skf-validate-feasibility-report.py +234 -0
  25. package/src/shared/scripts/skf-validate-frontmatter.py +17 -12
  26. package/src/shared/scripts/skf-validate-output.py +443 -10
  27. package/src/shared/scripts/skf-validate-pins.py +1 -1
  28. package/src/shared/scripts/skf-verify-no-trace.py +214 -0
  29. package/src/shared/scripts/skf-verify-provenance-completeness.py +439 -0
  30. package/src/skf-analyze-source/SKILL.md +17 -32
  31. package/src/skf-analyze-source/customize.toml +2 -0
  32. package/src/skf-analyze-source/references/auto-docs-only.md +116 -0
  33. package/src/skf-analyze-source/references/continue.md +8 -13
  34. package/src/skf-analyze-source/references/generate-briefs.md +28 -12
  35. package/src/skf-analyze-source/references/headless-contract.md +33 -0
  36. package/src/skf-analyze-source/references/health-check.md +1 -2
  37. package/src/skf-analyze-source/references/identify-units.md +25 -36
  38. package/src/skf-analyze-source/references/init.md +12 -25
  39. package/src/skf-analyze-source/references/map-and-detect.md +8 -20
  40. package/src/skf-analyze-source/references/recommend.md +4 -14
  41. package/src/skf-analyze-source/references/scan-project.md +3 -11
  42. package/src/skf-analyze-source/references/step-auto-scope.md +42 -180
  43. package/src/skf-analyze-source/references/unit-detection-heuristics.md +2 -2
  44. package/src/skf-audit-skill/SKILL.md +9 -6
  45. package/src/skf-audit-skill/customize.toml +2 -0
  46. package/src/skf-audit-skill/references/init.md +58 -32
  47. package/src/skf-audit-skill/references/re-index.md +15 -34
  48. package/src/skf-audit-skill/references/report.md +11 -58
  49. package/src/skf-audit-skill/references/semantic-diff.md +4 -22
  50. package/src/skf-audit-skill/references/severity-classify.md +53 -87
  51. package/src/skf-audit-skill/references/step-doc-drift.md +49 -19
  52. package/src/skf-audit-skill/references/structural-diff.md +43 -68
  53. package/src/skf-brief-skill/SKILL.md +7 -36
  54. package/src/skf-brief-skill/assets/scope-templates.md +1 -1
  55. package/src/skf-brief-skill/customize.toml +14 -0
  56. package/src/skf-brief-skill/references/analyze-target.md +6 -14
  57. package/src/skf-brief-skill/references/confirm-brief.md +2 -14
  58. package/src/skf-brief-skill/references/draft-checkpoint.md +8 -8
  59. package/src/skf-brief-skill/references/gather-intent.md +19 -22
  60. package/src/skf-brief-skill/references/headless-args.md +1 -1
  61. package/src/skf-brief-skill/references/health-check.md +1 -22
  62. package/src/skf-brief-skill/references/invocation-contract.md +37 -0
  63. package/src/skf-brief-skill/references/scope-definition.md +4 -14
  64. package/src/skf-brief-skill/references/step-auto-brief.md +1 -5
  65. package/src/skf-brief-skill/references/step-auto-validate.md +1 -5
  66. package/src/skf-brief-skill/references/version-resolution.md +1 -1
  67. package/src/skf-brief-skill/references/write-brief.md +17 -10
  68. package/src/skf-campaign/SKILL.md +15 -84
  69. package/src/skf-campaign/customize.toml +2 -0
  70. package/src/skf-campaign/manifest.yaml +4 -0
  71. package/src/skf-campaign/references/campaign-contracts.md +67 -0
  72. package/src/skf-campaign/references/campaign-directive-spec.md +14 -103
  73. package/src/skf-campaign/references/step-01-setup.md +4 -5
  74. package/src/skf-campaign/references/step-02-strategy.md +8 -3
  75. package/src/skf-campaign/references/step-03-pins.md +1 -1
  76. package/src/skf-campaign/references/step-04-provenance.md +1 -1
  77. package/src/skf-campaign/references/step-05-skill-loop.md +1 -1
  78. package/src/skf-campaign/references/step-06-batch.md +7 -6
  79. package/src/skf-campaign/references/step-11-maintenance.md +2 -2
  80. package/src/skf-campaign/references/step-resume.md +9 -8
  81. package/src/skf-campaign/scripts/campaign-deps.py +10 -1
  82. package/src/skf-campaign/scripts/campaign-render-batch.py +199 -0
  83. package/src/skf-campaign/scripts/campaign-status.py +162 -0
  84. package/src/skf-campaign/templates/campaign-brief-template.yaml +1 -1
  85. package/src/skf-create-skill/SKILL.md +14 -3
  86. package/src/skf-create-skill/assets/compile-assembly-rules.md +17 -38
  87. package/src/skf-create-skill/assets/skill-sections.md +9 -100
  88. package/src/skf-create-skill/assets/tessl-dismissal-rules.md +4 -13
  89. package/src/skf-create-skill/customize.toml +13 -0
  90. package/src/skf-create-skill/references/authoritative-files-protocol.md +7 -7
  91. package/src/skf-create-skill/references/compile.md +34 -47
  92. package/src/skf-create-skill/references/component-extraction.md +8 -35
  93. package/src/skf-create-skill/references/ecosystem-check.md +9 -25
  94. package/src/skf-create-skill/references/enrich.md +4 -17
  95. package/src/skf-create-skill/references/extract.md +14 -29
  96. package/src/skf-create-skill/references/extraction-patterns-tracing.md +1 -1
  97. package/src/skf-create-skill/references/extraction-patterns.md +7 -7
  98. package/src/skf-create-skill/references/generate-artifacts.md +9 -23
  99. package/src/skf-create-skill/references/health-check.md +1 -1
  100. package/src/skf-create-skill/references/load-brief.md +16 -18
  101. package/src/skf-create-skill/references/report.md +12 -15
  102. package/src/skf-create-skill/references/source-resolution-protocols.md +3 -3
  103. package/src/skf-create-skill/references/step-auto-shard.md +52 -25
  104. package/src/skf-create-skill/references/step-doc-rot.md +30 -12
  105. package/src/skf-create-skill/references/step-doc-sources.md +2 -2
  106. package/src/skf-create-skill/references/sub/ccc-discover.md +2 -13
  107. package/src/skf-create-skill/references/sub/fetch-docs.md +8 -50
  108. package/src/skf-create-skill/references/sub/fetch-temporal.md +5 -20
  109. package/src/skf-create-skill/references/tier-degradation-rules.md +6 -8
  110. package/src/skf-create-skill/references/validate.md +59 -28
  111. package/src/skf-create-skill/scripts/scan-doc-rot.py +245 -0
  112. package/src/skf-create-stack-skill/SKILL.md +15 -9
  113. package/src/skf-create-stack-skill/assets/provenance-map-schema.md +1 -1
  114. package/src/skf-create-stack-skill/customize.toml +10 -0
  115. package/src/skf-create-stack-skill/references/compile-stack.md +7 -8
  116. package/src/skf-create-stack-skill/references/compose-mode-rules.md +2 -13
  117. package/src/skf-create-stack-skill/references/detect-integrations.md +49 -54
  118. package/src/skf-create-stack-skill/references/detect-manifests.md +37 -30
  119. package/src/skf-create-stack-skill/references/generate-output.md +24 -75
  120. package/src/skf-create-stack-skill/references/init.md +9 -81
  121. package/src/skf-create-stack-skill/references/manifest-patterns.md +5 -35
  122. package/src/skf-create-stack-skill/references/parallel-extract.md +12 -27
  123. package/src/skf-create-stack-skill/references/rank-and-confirm.md +6 -6
  124. package/src/skf-create-stack-skill/references/report.md +27 -62
  125. package/src/skf-create-stack-skill/references/validate.md +35 -31
  126. package/src/skf-drop-skill/SKILL.md +20 -23
  127. package/src/skf-drop-skill/customize.toml +10 -0
  128. package/src/skf-drop-skill/references/execute.md +51 -31
  129. package/src/skf-drop-skill/references/headless-contract.md +18 -0
  130. package/src/skf-drop-skill/references/health-check.md +1 -13
  131. package/src/skf-drop-skill/references/report.md +42 -10
  132. package/src/skf-drop-skill/references/select.md +88 -48
  133. package/src/skf-drop-skill/scripts/dir-sizes.py +116 -0
  134. package/src/skf-export-skill/SKILL.md +17 -14
  135. package/src/skf-export-skill/assets/managed-section-format.md +2 -5
  136. package/src/skf-export-skill/customize.toml +10 -6
  137. package/src/skf-export-skill/references/generate-snippet.md +21 -35
  138. package/src/skf-export-skill/references/load-skill.md +44 -42
  139. package/src/skf-export-skill/references/multi-skill-mode.md +1 -1
  140. package/src/skf-export-skill/references/orphan-context-detection.md +11 -3
  141. package/src/skf-export-skill/references/package.md +27 -33
  142. package/src/skf-export-skill/references/preflight-snippet-root-probe.md +24 -5
  143. package/src/skf-export-skill/references/result-envelope.md +28 -0
  144. package/src/skf-export-skill/references/summary.md +11 -5
  145. package/src/skf-export-skill/references/token-report.md +42 -24
  146. package/src/skf-export-skill/references/update-context.md +32 -33
  147. package/src/skf-forger/SKILL.md +27 -39
  148. package/src/skf-forger/references/pipeline-mode.md +34 -0
  149. package/src/skf-forger/scripts/parse-pipeline.py +270 -0
  150. package/src/skf-quick-skill/SKILL.md +10 -60
  151. package/src/skf-quick-skill/customize.toml +9 -0
  152. package/src/skf-quick-skill/references/batch-mode.md +6 -4
  153. package/src/skf-quick-skill/references/compile.md +15 -52
  154. package/src/skf-quick-skill/references/ecosystem-check.md +5 -20
  155. package/src/skf-quick-skill/references/finalize.md +12 -6
  156. package/src/skf-quick-skill/references/halt-contract.md +54 -0
  157. package/src/skf-quick-skill/references/health-check.md +3 -4
  158. package/src/skf-quick-skill/references/quick-extract.md +7 -18
  159. package/src/skf-quick-skill/references/registry-resolution.md +1 -23
  160. package/src/skf-quick-skill/references/resolve-target.md +27 -34
  161. package/src/skf-quick-skill/references/write-and-validate.md +10 -25
  162. package/src/skf-refine-architecture/SKILL.md +14 -7
  163. package/src/skf-refine-architecture/customize.toml +9 -0
  164. package/src/skf-refine-architecture/references/compile.md +9 -7
  165. package/src/skf-refine-architecture/references/gap-analysis.md +21 -50
  166. package/src/skf-refine-architecture/references/health-check.md +1 -1
  167. package/src/skf-refine-architecture/references/improvements.md +9 -25
  168. package/src/skf-refine-architecture/references/init.md +9 -16
  169. package/src/skf-refine-architecture/references/issue-detection.md +10 -25
  170. package/src/skf-refine-architecture/references/refinement-rules.md +4 -16
  171. package/src/skf-refine-architecture/references/report.md +13 -10
  172. package/src/skf-rename-skill/SKILL.md +11 -21
  173. package/src/skf-rename-skill/customize.toml +10 -0
  174. package/src/skf-rename-skill/references/execute.md +107 -78
  175. package/src/skf-rename-skill/references/exit-codes.md +12 -0
  176. package/src/skf-rename-skill/references/report.md +16 -8
  177. package/src/skf-rename-skill/references/select.md +69 -42
  178. package/src/skf-rename-skill/scripts/skf-validate-rename-name.py +161 -0
  179. package/src/skf-setup/SKILL.md +20 -12
  180. package/src/skf-setup/customize.toml +10 -0
  181. package/src/skf-setup/references/auto-index.md +9 -10
  182. package/src/skf-setup/references/ccc-index.md +14 -15
  183. package/src/skf-setup/references/detect-and-tier.md +6 -8
  184. package/src/skf-setup/references/report.md +22 -31
  185. package/src/skf-setup/references/tier-rules.md +2 -32
  186. package/src/skf-setup/references/write-config.md +9 -10
  187. package/src/skf-test-skill/SKILL.md +10 -8
  188. package/src/skf-test-skill/customize.toml +2 -0
  189. package/src/skf-test-skill/references/coherence-check.md +19 -31
  190. package/src/skf-test-skill/references/coverage-check.md +109 -75
  191. package/src/skf-test-skill/references/detect-mode.md +10 -41
  192. package/src/skf-test-skill/references/external-validators.md +11 -19
  193. package/src/skf-test-skill/references/init.md +38 -20
  194. package/src/skf-test-skill/references/migration-section-rules.md +4 -4
  195. package/src/skf-test-skill/references/report.md +60 -40
  196. package/src/skf-test-skill/references/score.md +32 -64
  197. package/src/skf-test-skill/references/scoring-rules.md +6 -62
  198. package/src/skf-test-skill/references/source-access-protocol.md +6 -6
  199. package/src/skf-test-skill/references/step-hard-gate.md +1 -3
  200. package/src/skf-test-skill/scripts/aggregate-coherence.py +276 -0
  201. package/src/skf-test-skill/scripts/check-metadata-coherence.py +359 -0
  202. package/src/skf-test-skill/scripts/combine-external-scores.py +190 -0
  203. package/src/skf-test-skill/scripts/compute-score.py +131 -1
  204. package/src/skf-test-skill/scripts/reconcile-coverage.py +327 -0
  205. package/src/skf-test-skill/scripts/validate-inventory.py +251 -0
  206. package/src/skf-test-skill/scripts/verify-declared-numerator.py +192 -0
  207. package/src/skf-update-skill/SKILL.md +17 -5
  208. package/src/skf-update-skill/customize.toml +14 -0
  209. package/src/skf-update-skill/references/detect-changes.md +19 -37
  210. package/src/skf-update-skill/references/health-check.md +3 -9
  211. package/src/skf-update-skill/references/init.md +39 -32
  212. package/src/skf-update-skill/references/manual-section-rules.md +1 -2
  213. package/src/skf-update-skill/references/merge-conflict-rules.md +1 -52
  214. package/src/skf-update-skill/references/merge.md +13 -57
  215. package/src/skf-update-skill/references/re-extract.md +12 -24
  216. package/src/skf-update-skill/references/report.md +14 -7
  217. package/src/skf-update-skill/references/validate.md +32 -30
  218. package/src/skf-update-skill/references/write.md +86 -51
  219. package/src/skf-update-skill/scripts/skf-new-file-diff.py +167 -0
  220. package/src/skf-verify-stack/SKILL.md +11 -21
  221. package/src/skf-verify-stack/customize.toml +12 -3
  222. package/src/skf-verify-stack/references/coverage-patterns.md +1 -29
  223. package/src/skf-verify-stack/references/coverage.md +21 -10
  224. package/src/skf-verify-stack/references/exit-codes.md +14 -0
  225. package/src/skf-verify-stack/references/health-check.md +1 -1
  226. package/src/skf-verify-stack/references/init.md +20 -25
  227. package/src/skf-verify-stack/references/integration-verification-rules.md +10 -19
  228. package/src/skf-verify-stack/references/integrations.md +44 -49
  229. package/src/skf-verify-stack/references/report.md +28 -34
  230. package/src/skf-verify-stack/references/requirements.md +3 -3
  231. package/src/skf-verify-stack/references/synthesize.md +36 -39
  232. package/src/skf-verify-stack/scripts/skf-coverage-tally.py +196 -0
  233. package/src/skf-verify-stack/scripts/skf-report-delta.py +256 -0
  234. package/src/skf-verify-stack/scripts/skf-verdict-rollup.py +258 -0
  235. package/src/skf-rename-skill/references/rebuild-context.md +0 -110
@@ -99,9 +99,9 @@ The helper handles v2-schema enforcement, v1→v2 migration, and the `platforms`
99
99
 
100
100
  Determine the set of skills to include in the rebuilt index:
101
101
 
102
- 1. Start with all skill names listed in the manifest's `exports` object (if manifest exists)
103
- 2. For each skill, record its `active_version` from the manifest (v2 schema)
104
- 3. **Integrity guard `active_version` must resolve to a versions entry:** Check that `versions[active_version]` exists as a key. If `active_version` is set but there is no matching entry under `versions`, the manifest is inconsistent (possible corruption or a botched v1→v2 migration). Skip this skill and log a loud warning: "**Manifest integrity warning:** `{skill-name}.active_version = v{active_version}` has no matching entry under `versions`. Skipping. Re-run `[EX] Export Skill` on `{skill-name}` to repair the manifest entry."
102
+ 1. Start with the manifest `exports` entries that survived the §4a integrity guard — those whose `active_version` resolves to a key in `versions` (if manifest exists)
103
+ 2. For each surviving skill, record its `active_version` from the manifest (v2 schema)
104
+ 3. The §4a integrity guard already skipped (and warned about) any entry whose `active_version` has no matching `versions` key, so build only from those survivors no re-check or re-warning here.
105
105
  4. **Exclude deprecated skills:** If the `active_version` entry in `versions.{active_version}` has `status: "deprecated"`, skip this skill entirely — it has been dropped via drop-skill workflow and must not appear in the managed section. Log: "Skipping {skill-name} — active version v{active_version} is deprecated"
106
106
  5. Add the current export target skill name (ensures it is always included even before manifest is written) — use the version from `{resolved_skill_package}/metadata.json` as its `active_version`
107
107
  6. This is the **exported skill set** — each entry has a skill name and its resolved `active_version`
@@ -114,7 +114,9 @@ Instead of globbing `{skills_output_folder}/*/context-snippet.md`, resolve snipp
114
114
  1. Resolve `{skill_package}` using the skill's `active_version`: `{skills_output_folder}/{skill-name}/{active_version}/{skill-name}/`
115
115
  2. Read `{skill_package}/context-snippet.md`
116
116
  3. **If snippet exists:** Add to skill index
117
- 4. **If snippet does not exist at the versioned path:** Check for `active` symlink at `{skills_output_folder}/{skill-name}/active/{skill-name}/context-snippet.md`. If still not found, skip with warning: "Snippet missing for {skill-name} v{active_version} — skipping from managed section"
117
+ 4. **If snippet does not exist at the versioned path:** Check for `active` symlink at `{skills_output_folder}/{skill-name}/active/{skill-name}/context-snippet.md`.
118
+ 5. **If still not found, try the flat layout:** Read `{skills_output_folder}/{skill-name}/context-snippet.md` — a skill still on the pre-versioned flat layout (see `knowledge/version-paths.md` "Migration: Flat to Versioned"). This mirrors the flat-path fallback used when resolving a skill's SKILL.md in `load-skill.md` §1, so a manifest entry (or a first-export `--all` entry) that is still flat on disk is not silently dropped from the managed section.
119
+ 6. **If none of the three paths yields a snippet, skip with warning:** "Snippet missing for {skill-name} v{active_version} — skipping from managed section"
118
120
 
119
121
  **Skills NOT in the exported skill set are never scanned** — they have not been through export-skill and must not appear in the managed section (ADR-K).
120
122
 
@@ -126,15 +128,21 @@ A managed-section row becomes orphaned when a `[skill-name v...]` entry already
126
128
 
127
129
  **Cheap pre-check (always run before §5 assembly).** Scan **every** target context file (not just the first), deduplicate by `(skill_name, version)`, and present one consolidated gate. Asymmetric orphans — a row present in `.cursorrules` but absent from `CLAUDE.md`, or vice versa — must be detected; otherwise the §4 rebuild loop silently overwrites the orphan-bearing file's content (ADR-J violation: silent loss of user content).
128
130
 
129
- 1. Initialize `orphan_managed_rows = []` (a list of `{skill_name, version, snippet_text, source_files: []}` entries `source_files` carries provenance for the gate display and the audit `deviations[]` entry).
130
- 2. **Iterate every entry in `target_context_files`:**
131
- a. Read the prior managed section from `{entry.context_file}`. If the file does not exist or has no `<!-- SKF:BEGIN -->` marker, skip this entry it has no orphans by definition.
132
- b. Parse the `[skill-name v...]` rows between `<!-- SKF:BEGIN -->` and `<!-- SKF:END -->` into `file_rows` — a list of `{skill_name, version, snippet_text}` triples (capture the original snippet line(s) verbatim so they can be re-emitted unchanged if (b) is chosen).
133
- c. For each `row` in `file_rows`:
134
- - If `row.skill_name` is in the exported skill set built in 4b (manifest entries plus current-export targets), skip — not an orphan.
135
- - Otherwise look up `(row.skill_name, row.version)` in `orphan_managed_rows`:
136
- - If already present, append `entry.context_file` to that row's `source_files` list (deduplicated). Keep the first-encountered `snippet_text` — divergent snippets across files for the same `(skill, version)` are themselves a user-content asymmetry but the `(b) Preserve verbatim` semantic writes one canonical row to every target file, so picking the first is deterministic and avoids silently choosing.
137
- - If new, append `{skill_name: row.skill_name, version: row.version, snippet_text: row.snippet_text, source_files: [entry.context_file]}`.
131
+ The parse / dedup-by-`(skill_name, version)` / set-diff-against-the-exported-set is deterministic marker surgery with one correct answer per input — a mis-parsed row silently drops an installed skill from the rebuilt managed section (the ADR-J/K regression this gate guards against). Delegate it to `{rebuildManagedSectionsHelper}` (resolve from `{rebuildManagedSectionsProbeOrder}` in frontmatter first existing path wins; if no candidate exists, the same HALT as §9 applies: exit code 4, `halt_reason: "context-rebuild-failed"`). Do not re-derive the rows in-prompt.
132
+
133
+ 1. Run the detector once across **every** target context file — pass each `target_context_files[].context_file` as a positional argument, and the comma-joined list of skill **names** from the exported skill set built in §4b (version is not needed for the orphan test) as `--exported-skills`:
134
+
135
+ ```bash
136
+ python3 {rebuildManagedSectionsHelper} orphan-detect {context-file-1} {context-file-2} --exported-skills {name1,name2,…}
137
+ ```
138
+
139
+ 2. Set `orphan_managed_rows = result["orphan_managed_rows"]`. The helper reads each context file that exists and has a `<!-- SKF:BEGIN -->` marker, parses its `[skill-name v...]` rows, drops those whose `skill_name` is in the exported set, and deduplicates the survivors by `(skill_name, version)` — first-seen `snippet_text` wins (divergent snippets across files for the same `(skill, version)` are a user-content asymmetry, but `(b) Preserve verbatim` writes one canonical row to every target file, so first-seen is deterministic), and each file the row appears in is appended to a sorted `source_files`. The returned shape is:
140
+
141
+ ```json
142
+ {"status": "ok", "orphan_managed_rows": [{"skill_name": "…", "version": "…", "snippet_text": "…", "source_files": ["…"]}]}
143
+ ```
144
+
145
+ Each entry's `snippet_text` is the byte-exact prior snippet (re-emitted unchanged if (b) is chosen — the only surviving copy of an orphan's snippet is this known-exact string, never model-reconstructed); `source_files` carries provenance for the gate display and the audit `deviations[]` entry. A missing file, a file with no marker, or a section with no skill rows contributes nothing — the helper already handles those, so the list is empty in those cases.
138
146
 
139
147
  **If `orphan_managed_rows` is non-empty:** load `references/orphan-row-detection.md` and follow its (a) Drop / (b) Preserve verbatim / (c) Cancel gate protocol. The reference handles user prompting (with per-orphan `source_files` provenance), headless default (Preserve verbatim), `deviations[]` recording (including `source_files` per orphan for audit), and §6 result-contract integration.
140
148
 
@@ -211,7 +219,7 @@ Assemble the managed section in **two shapes** — the §9 write paths consume d
211
219
  **Case 4: Malformed markers (file contains `<!-- SKF:BEGIN` but no `<!-- SKF:END -->`)**
212
220
  - Action: HALT (exit code 5, `halt_reason: "malformed-markers"`) with warning: "Malformed SKF markers detected in `{target-file}` — `<!-- SKF:BEGIN` found but `<!-- SKF:END -->` is missing. Please restore the end marker manually before running export."
213
221
  - Do NOT attempt to write or append — the file is in an inconsistent state.
214
- - In headless mode, emit the error envelope per SKILL.md "Result Contract (Headless)" with `manifest_path: null`, `context_files_updated: []`.
222
+ - In headless mode, emit the error envelope per `references/result-envelope.md` with `manifest_path: null`, `context_files_updated: []`.
215
223
 
216
224
  ### 7. Present Change Preview
217
225
 
@@ -253,18 +261,13 @@ Display: "**Select:** [C] Continue — write changes to {target-file} | [X] Canc
253
261
 
254
262
  Display: "**Select:** [C] Continue — write changes to all targets | [X] Cancel and exit"
255
263
 
256
- #### Menu Handling Logic:
257
-
258
- - IF C: Write the changes to all target files (or single target), verify each write succeeded, then load, read entire file, then execute {nextStepFile}
259
- - IF X (or `cancel` / `exit` / `:q`): Display "Cancelled — no context files were written." and HALT (exit code 6, `halt_reason: "user-cancelled"`). In headless, emit the error envelope per SKILL.md "Result Contract (Headless)" with the resolved `skills`, `context_files_updated: []`, and `manifest_path: null`.
260
- - IF Any other: help user respond, then [Redisplay Menu Options](#8-present-menu-options)
264
+ #### Gate handling
261
265
 
262
- #### EXECUTION RULES:
263
-
264
- - ALWAYS halt and wait for user input after presenting menu
265
- - **GATE [default: C]** — If `{headless_mode}`: auto-proceed with [C] Continue, log: "headless: auto-approve context file update"
266
- - ONLY proceed to next step when user selects 'C'
267
- - In dry-run mode, auto-proceed without writing
266
+ - **[C]** — write the changes to all target files (or the single target), verify each write succeeded, then load, read entirely, and execute `{nextStepFile}`.
267
+ - **[X]** / `cancel` / `exit` / `:q` — Display "Cancelled — no context files were written." and HALT (exit code 6, `halt_reason: "user-cancelled"`). In headless, emit the error envelope per `references/result-envelope.md` with the resolved `skills`, `context_files_updated: []`, and `manifest_path: null`.
268
+ - **Any other input** help the user respond, then redisplay this gate.
269
+ - **Headless** [default C]: auto-approve with [C], log "headless: auto-approve context file update".
270
+ - **Dry-run**: auto-proceed without writing.
268
271
 
269
272
  ### 9. Write and Verify (Non-Dry-Run Only)
270
273
 
@@ -274,7 +277,7 @@ After user confirms with 'C', resolve the helpers in parallel — these are inde
274
277
  - `{atomicWriteHelper}` ← first existing path in `{atomicWriteProbeOrder}` (used for Case 1)
275
278
  - `{manifestOpsHelper}` ← first existing path in `{manifestOpsProbeOrder}` (used in §9b)
276
279
 
277
- If any helper has no existing candidate, HALT (exit code 4, `halt_reason: "context-rebuild-failed"`) and emit the error envelope per SKILL.md "Result Contract (Headless)" — the rewrite's safety guarantees depend on these helpers and a fall-through to LLM-driven writes would silently regress atomicity, marker preservation, and the Case 4 malformed-marker HARD HALT contract.
280
+ If any helper has no existing candidate, HALT (exit code 4, `halt_reason: "context-rebuild-failed"`) and emit the error envelope per `references/result-envelope.md` — the rewrite's safety guarantees depend on these helpers and a fall-through to LLM-driven writes would silently regress atomicity, marker preservation, and the Case 4 malformed-marker HARD HALT contract.
278
281
 
279
282
  **Stage content via a shell-safe channel (all cases).** Managed-section snippets routinely contain backticks and `$` — API names like `` `Room::connect(...)` ``, tokens like `$threshold` and `${…}`. Inlining them as a double-quoted shell argument (`--content "…"`) or via `echo "…"` lets bash run command substitution and variable expansion, silently corrupting the written bytes — and because the helper's byte-identity verify runs against the already-corrupted string, it would still report success. No quoting style is safe (content can also contain single quotes, e.g. `'eager' | 'on-demand'`), so **never** inline the section into the command. Instead write the assembled section to a staging file with your file-write tool (which performs no shell interpretation), then feed it to the helper via stdin redirection — the helper reads stdin whenever `--content` is absent:
280
283
 
@@ -313,7 +316,7 @@ The helper performs the surgical between-marker swap with post-write verificatio
313
316
  **Verification (deferred to helpers):** the `replace`/`insert`/`write` actions above each perform their own verification. Treat any non-zero exit as a write failure:
314
317
 
315
318
  - HALT (exit code 4, `halt_reason: "context-rebuild-failed"`) and report `{target-file}: {captured stderr}`.
316
- - In headless mode, emit the error envelope.
319
+ - In headless mode, emit the error envelope per `references/result-envelope.md`.
317
320
  - Continue to the next target file only on success — partial-batch writes are acceptable in single-skill mode but the overall envelope reports per-target outcomes.
318
321
 
319
322
  On success per file, report: "**{target-file} updated successfully.** Verified by `{rebuildManagedSectionsHelper}` (or `{atomicWriteHelper}` for Case 1)."
@@ -322,7 +325,7 @@ On success per file, report: "**{target-file} updated successfully.** Verified b
322
325
 
323
326
  **This section executes ONCE after all context-file iterations complete** (outside the per-context-file loop defined in section 3). Only IDEs whose target context files were successfully written and verified in section 9 are recorded.
324
327
 
325
- **`ides` field definition:** `ides` is the list of IDE identifiers from `config.yaml.ides` (e.g. `claude-code`, `cursor`, `github-copilot`) whose context files were successfully written and verified in section 9. It is NOT the context file name (`CLAUDE.md`) and NOT the skill root path (`.claude/skills/`). Each IDE → context file → skill root mapping is defined in `skf-export-skill/assets/managed-section-format.md`.
328
+ **`ides` field definition:** `ides` is the list of IDE identifiers from `config.yaml.ides` (e.g. `claude-code`, `cursor`, `github-copilot`) whose context files were successfully written and verified in section 9. It is NOT the context file name (`CLAUDE.md`) and NOT the skill root path (`.claude/skills/`). Each IDE → context file → skill root mapping is defined in `{managedSectionData}`.
326
329
 
327
330
  1. Read `{skills_output_folder}/.export-manifest.json` (or start with `{"schema_version": "2", "exports": {}}` if it does not exist)
328
331
  2. Ensure `schema_version` is `"2"` (if v1 was migrated in section 4a, the migrated structure is already in context). If any version entry still has a legacy `platforms` key, rename it to `ides` in place (see §4a).
@@ -356,9 +359,5 @@ On success per file, report: "**{target-file} updated successfully.** Verified b
356
359
 
357
360
  **Dry-run mode:** Do NOT update the manifest. Display: "**[DRY RUN] Export manifest would be updated for {skill-name-list} — ides: {ides_written}.**" (list every skill in `skill_batch`)
358
361
 
359
- **Error handling:** If `{manifestOpsHelper}` exits non-zero, HALT (exit code 4, `halt_reason: "manifest-write-failed"`) with the captured `stderr`. The managed section was already written successfully; the operator's recovery path is to manually reconcile the on-disk managed section with the manifest, then re-run `[EX] Export Skill --all` to refresh the manifest. In headless mode, emit the error envelope per SKILL.md "Result Contract (Headless)" with `manifest_path: null` and the partial `context_files_updated` list.
360
-
361
- ## CRITICAL STEP COMPLETION NOTE
362
-
363
- ONLY WHEN the user confirms changes by selecting 'C' (or auto-proceed in dry-run) and the write is verified will you load and read fully `{nextStepFile}` to execute the token report.
362
+ **Error handling:** If `{manifestOpsHelper}` exits non-zero, HALT (exit code 4, `halt_reason: "manifest-write-failed"`) with the captured `stderr`. The managed section was already written successfully; the operator's recovery path is to manually reconcile the on-disk managed section with the manifest, then re-run `[EX] Export Skill --all` to refresh the manifest. In headless mode, emit the error envelope per `references/result-envelope.md` with `manifest_path: null` and the partial `context_files_updated` list.
364
363
 
@@ -7,7 +7,7 @@ description: Skill compilation specialist — the forge master. Use when the use
7
7
 
8
8
  ## Overview
9
9
 
10
- This skill provides the Skill Forge's resident agent Ferris, the forge master. Ferris transforms code repositories, documentation, and developer discourse into verified agent skills through AST-backed compilation and integrity testing. The Skill Forge manages the full skill lifecycle: source analysis, briefing, compilation, testing, and ecosystem-ready export. Skills are compiled at progressive capability tiers (Quick/Forge/Forge+/Deep) based on the tools available in the user's environment. Ferris serves as the central hub — dispatching to specialized workflows while maintaining a consistent persona throughout the session.
10
+ Resident agent of the Skill Forge — the central hub that dispatches to specialized workflows across the skill lifecycle (source analysis, briefing, compilation, testing, ecosystem export) while holding one persona for the whole session.
11
11
 
12
12
  ## Identity & Principles
13
13
 
@@ -53,9 +53,8 @@ Say "dismiss" or "exit persona" to leave Ferris at any time.
53
53
 
54
54
  - **GUARD (config):** Verify `{project-root}/_bmad/skf/config.yaml` exists. If missing — HARD HALT: "**Cannot initialize.** SKF config not found. Run the `skf-setup` skill to initialize your forge environment."
55
55
  - **GUARD (sidecar):** Verify `{sidecar_path}` resolves to an actual directory path (not a literal `{sidecar_path}` string). If it does not resolve — HARD HALT: "**Cannot initialize.** `sidecar_path` is not defined in your installed config.yaml. Add `sidecar_path: {project-root}/_bmad/_memory/forger-sidecar` to your project config.yaml and retry. This is a known installer issue with `prompt: false` config variables."
56
- - Load COMPLETE file `{sidecar_path}/preferences.yaml`
57
- - Load COMPLETE file `{sidecar_path}/forge-tier.yaml`
58
- - ONLY write STATE files to `{project-root}/_bmad/_memory/forger-sidecar/` — reading from knowledge/ and workflow files is expected
56
+ - Load `{sidecar_path}/preferences.yaml` and `{sidecar_path}/forge-tier.yaml` in full. If either is absent — a first run before `skf-setup` populated the sidecar — treat it as empty defaults and continue; the first-run path below handles a null tier.
57
+ - Write state files only to `{project-root}/_bmad/_memory/forger-sidecar/`; reading from knowledge/ and workflow files elsewhere is expected.
59
58
  - When a workflow step directs knowledge consultation, consult `{project-root}/_bmad/skf/knowledge/skf-knowledge-index.csv` to select the relevant fragment(s) and load only those files. If the CSV is missing or empty, inform the user and continue without knowledge augmentation
60
59
  - Load the referenced fragment(s) from `{project-root}/_bmad/skf/` using the path in the `fragment_file` column (e.g., `knowledge/overview.md` resolves to `{project-root}/_bmad/skf/knowledge/overview.md`) before giving recommendations on the topic the step directed
61
60
 
@@ -64,58 +63,47 @@ Say "dismiss" or "exit persona" to leave Ferris at any time.
64
63
  1. Load config from `{project-root}/_bmad/skf/config.yaml` and resolve:
65
64
  - `project_name`, `output_folder`, `user_name`, `communication_language`, `document_output_language`, `sidecar_path`, `skills_output_folder`, `forge_data_folder`
66
65
 
67
- 2. Execute Critical Actions above. Load `preferences.yaml` and `forge-tier.yaml` in parallel.
66
+ 2. Execute the Critical Actions above, loading `preferences.yaml` and `forge-tier.yaml` in parallel.
68
67
 
69
- 3. **Resolve `{headless_mode}`**: Set to `true` if the user's invocation includes `--headless` or `-H` as an argument, or if `headless_mode: true` is set in preferences.yaml. Default: `false`. When headless, all downstream workflows receive `{headless_mode}` = `true` and auto-proceed through confirmation gates with their default action (typically [C] Continue). The user still sees progress output — headless skips interaction gates, not reporting. See `shared/references/headless-gate-convention.md` for the full gate-type specification and resolution rules.
68
+ 3. **Resolve `{headless_mode}`**: `true` if the invocation includes `--headless`/`-H` or preferences sets `headless_mode: true`, else `false`; pass it to all downstream workflows. Headless skips interaction gates, not progress reporting. See `shared/references/headless-gate-convention.md` for gate-type resolution.
70
69
 
71
70
  4. **Detect user context** from forge-tier.yaml:
72
- - If `tier` is null/missing → first-run user. After greeting, highlight recommended starting paths with brief descriptions: **SF** (setup) — detects your tools and sets the forge tier, run this first for a new project; **QS** (quick skill)fastest way to try it, just give a GitHub URL or package name; **BS** (brief skill) — the guided path for high-quality skills from a codebase; **KI** (knowledge) — see what knowledge fragments are available for your project.
71
+ - If `tier` is null/missing → first-run user. After greeting, highlight the recommended starting paths: **SF** (run this first — detects tools, sets the forge tier), **QS** (fastest trial — give a GitHub URL or package name), **BS** (guided path for a high-quality skill from a codebase), **KI** (see available knowledge fragments).
73
72
  - If returning user with `compact_greeting: true` in preferences → greet briefly and ask what they'd like to work on. Show the capabilities table only if they ask.
74
73
  - Otherwise → present the full capabilities table.
75
74
 
76
75
  5. **Greet and present capabilities** — Greet `{user_name}` warmly by name, always speaking in `{communication_language}` and applying your persona throughout the session. Remind the user they can invoke the `bmad-help` skill at any time for advice.
77
76
 
78
- **STOP and WAIT for user input** Do NOT execute menu items automatically. Accept number, menu code, or fuzzy command match.
77
+ The menu is a choice point — wait for the user's input rather than firing a workflow they never picked. Accept a number, a menu code, or a fuzzy command match.
79
78
 
80
- **CRITICAL Handling:** When user responds with a code, line number, or skill, check if the input contains **multiple codes** (space-separated or arrow-separated). If so, enter **Pipeline Mode** below. Otherwise, invoke the corresponding skill by its exact registered name from the Capabilities table. DO NOT invent capabilities on the fly. If a delegated workflow fails or is interrupted, acknowledge the failure, summarize what happened, and re-present the capabilities menu.
79
+ 6. **Surface any interrupted pipeline** glob `{sidecar_path}/pipeline-result-latest.json`. If it exists and its overall pipeline status (`summary.status`) is `failed` or `partial`, read the recorded per-step status for the workflow it halted on and the workflows still pending, and include a resume offer in the greeting as the recommended next action. Accepting it re-enters Pipeline Mode with the pending codes; the user may pick any menu code instead. If the file is absent or its status is `success`, stay silent.
81
80
 
82
- ## Pipeline Mode
81
+ **Dispatch** when the user responds with a code, number, or command:
82
+
83
+ - **Multiple codes** (space- or arrow-separated, or a pipeline alias) → enter **Pipeline Mode** below.
84
+ - **`KI` or `WS`** → run the matching handler under **Inline Actions** below (these rows carry no registered skill).
85
+ - **Any other single code** → invoke the skill named in its Capabilities row, by that exact name. Dispatching to a name not in the table invents a capability that does not exist, so match the input to an exact registered skill first.
86
+ - If a delegated workflow fails or is interrupted, acknowledge the failure, summarize what happened, and re-present the capabilities menu.
83
87
 
84
- When the user provides multiple workflow codes (e.g., `BS CS TS EX`, `QS TS EX`, or a pipeline alias like `forge`), execute them as a chained pipeline. Load `shared/references/pipeline-contracts.md` for the full specification.
88
+ ## Inline Actions
85
89
 
86
- **Pipeline activation:**
90
+ These menu codes resolve to a handler here, not a registered skill:
87
91
 
88
- 1. **Parse the sequence** — split codes, expand aliases (`forge-auto` → `AN[auto] BS[auto] CS TS[min:90] EX`, `forge` `BS CS TS EX`, `forge-quick` `QS TS EX`, `maintain` `AS US TS EX`), extract any bracket arguments (`CS[cocoindex]`, `TS[min:80]`)
89
- **Deprecated aliases:** If the parsed alias is `deepwiki`, expand it exactly as `forge-auto` and set `{pipeline_alias}` to `forge-auto`, but first emit a one-time notice:
92
+ - **KI** — Load and display `{project-root}/_bmad/skf/knowledge/skf-knowledge-index.csv`, the cross-cutting knowledge fragments available for JiT loading. If the CSV is missing, inform the user and suggest running SF (setup).
93
+ - **WS** Show the current lifecycle position, active skill briefs, and forge tier status.
94
+
95
+ ## Pipeline Mode
90
96
 
91
- > ⚠️ **`deepwiki` is now `forge-auto`.** The alias was renamed to avoid confusion with the DeepWiki MCP this pipeline auto-forges a verified skill from source and does **not** call that MCP. `deepwiki` still works as a deprecated alias; prefer `forge-auto <repo-url>` going forward.
97
+ When the user provides multiple workflow codes (e.g. `BS CS TS EX`, `QS TS EX`) or a pipeline alias (`forge`, `forge-auto`, `forge-quick`, `maintain`), execute them as a chained pipeline. Load `references/pipeline-mode.md` for the run procedure parsing, sequence validation, the execute loop, circuit breakers, result contract, and special behaviors and `shared/references/pipeline-contracts.md` for the alias, data-flow, and threshold tables.
92
98
 
93
- **Removed aliases:** If the parsed alias is `onboard`, do NOT expand it. Instead, HALT with:
99
+ Only the alias names need recognizing here; `pipeline-mode.md` step 1 expands them against the pipeline-contracts.md table. One expansion is pinned here because its test gate is non-default: `forge-auto` → `AN[auto] BS[auto] CS TS[min:90] EX`, whose `TS[min:90]` matches init.md §1b's `forge-auto` → 90. Each chained workflow runs with `{pipeline_alias}` set to the alias name (`forge-auto`, `forge`, `forge-quick`, `maintain`) or `null` for ad-hoc code sequences.
94
100
 
95
- > 🚫 **onboard has been removed.** Use `forge-auto <repo-url>` instead. forge-auto auto-scopes, auto-briefs, and tests at 90% quality. Run `forge-auto` with any GitHub URL, doc URL, or `--pin <version>`.
101
+ Two alias gotchas must be caught here, at recognition, before that procedure runs:
96
102
 
97
- 2. **Validate the sequence** — check for anti-patterns (EX before TS, CS without BS, duplicates). If found, warn the user and ask to confirm or adjust. In `{headless_mode}`, warn but proceed.
98
- 3. **Set `{headless_mode}` = true** — pipelines auto-activate headless mode for all workflows in the chain. The user committed to the sequence by providing it.
99
- 4. **Execute left to right** — for each workflow in the sequence:
100
- - a. **Report start**: "Pipeline [{current}/{total}]: Starting {code} ({description})..."
101
- - b. **Resolve inputs** from the previous workflow's output using the Data Flow table in pipeline-contracts.md. If the previous workflow produced a `skill_name`, `brief_path`, or other handoff data, pass it as the input argument.
102
- - c. **Invoke the workflow** with `{headless_mode}` = true, `{pipeline_alias}` set to the alias name (`forge-auto`, `forge`, `forge-quick`, `maintain`, or `null` for ad-hoc sequences; a `deepwiki` invocation resolves to `forge-auto`), and any resolved arguments.
103
- - d. **Check circuit breaker** after completion. Load the output artifact and validate against the threshold (default or user-specified via `[min:N]`). If the check fails: halt the pipeline, report what completed and what remains.
104
- - e. **Report completion**: "Pipeline [{current}/{total}]: {code} complete — {brief summary of output}."
105
- 5. **Pipeline summary** — after all workflows complete (or on halt), present a summary:
106
- - Completed workflows with key outputs
107
- - Failed/halted workflow (if any) with the halt reason
108
- - Remaining workflows that were not executed
109
- - Next steps recommendation
110
- 6. **Result Contract** — write the pipeline result contract per `shared/references/output-contract-schema.md`: the per-run record at `{sidecar_path}/pipeline-result-{YYYYMMDD-HHmmss}.json` (UTC timestamp, resolution to seconds) and a copy at `{sidecar_path}/pipeline-result-latest.json` (stable path for pipeline consumers — copy, not symlink). Include one entry per completed workflow in `outputs` (referencing each workflow's own `-latest.json` result record); include per-step status and the overall pipeline status in `summary`.
103
+ **Deprecated (`deepwiki`):** expand it exactly as `forge-auto` and set `{pipeline_alias}` = `forge-auto`, but first emit a one-time notice:
111
104
 
112
- **forge-auto pipeline note:** `forge-auto <repo-url> --pin <version>` the `--pin` argument is passed to AN's pipeline data context alongside the `[auto]` flag. AN's `step-auto-scope.md §0b` consumes it for pin resolution.
105
+ > ⚠️ **`deepwiki` is now `forge-auto`.** The alias was renamed to avoid confusion with the DeepWiki MCP — this pipeline auto-forges a verified skill from source and does **not** call that MCP. `deepwiki` still works as a deprecated alias; prefer `forge-auto <repo-url>` going forward.
113
106
 
114
- **Special pipeline behaviors:**
115
- - `AN` in a pipeline with `CS`: if AN produces multiple recommended briefs, auto-select all and process sequentially in batch mode. If only one unit found, auto-select it.
116
- - `AS` followed by `US`: if `summary.severity` in `audit-skill-result-latest.json` is CLEAN, skip US and report "No drift detected — skipping update."
117
- - `TS` followed by `EX`: if test result is FAIL and score is below the circuit breaker threshold, halt before EX.
107
+ **Removed (`onboard`):** do NOT expand it. HALT with:
118
108
 
119
- **Inline action handling:**
120
- - **KI**: Load and display `{project-root}/_bmad/skf/knowledge/skf-knowledge-index.csv` — cross-cutting knowledge fragments available for JiT loading. If the CSV is missing, inform the user and suggest running SF (setup).
121
- - **WS**: Show current lifecycle position, active skill briefs, and forge tier status.
109
+ > 🚫 **onboard has been removed.** Use `forge-auto <repo-url>` instead. forge-auto auto-scopes, auto-briefs, and tests at 90% quality. Run `forge-auto` with any GitHub URL, doc URL, or `--pin <version>`.
@@ -0,0 +1,34 @@
1
+ # Pipeline Mode Execution
2
+
3
+ The forger enters this procedure when the user supplies multiple workflow codes (e.g. `BS CS TS EX`, `QS TS EX`) or a pipeline alias (`forge`, `forge-auto`, `forge-quick`, `maintain`). It chains the workflows left to right, forwarding each output to the next input.
4
+
5
+ Load `shared/references/pipeline-contracts.md` for the alias-expansion table, the Data Flow output→input map, circuit-breaker thresholds, bracket syntax, and the anti-pattern list. This file covers the run procedure that consumes those tables.
6
+
7
+ ## Activation
8
+
9
+ 1. **Parse the sequence** — run `uv run scripts/parse-pipeline.py '<sequence>'` (from the skf-forger skill root). It tokenizes (space or arrow separated), expands aliases, classifies each bracket argument (`CS[cocoindex]` → target, `TS[min:80]` → circuit-breaker override, `AN[auto]` → mode flag), and returns the normalized `plan`/`codes` plus any `anti_patterns` as JSON. Consume that output rather than re-deriving the expansion or checks by hand. `deepwiki`/`onboard` are already resolved at recognition before this procedure runs, so the sequence reaching this step is normalized. If the script cannot run, fall back to expanding aliases against the pipeline-contracts.md alias table and applying its anti-pattern table by hand.
10
+
11
+ 2. **Validate the sequence** — the parse output's `anti_patterns` array already lists any matches (EX before TS, CS without a brief, duplicate codes, US without AS), each with a message and suggestion. If it is non-empty, warn the user and ask to confirm or adjust. In `{headless_mode}`, warn but proceed.
12
+
13
+ 3. **Force `{headless_mode}` = true** — pipelines auto-activate headless mode for every workflow in the chain; the user committed to the sequence by providing it.
14
+
15
+ 4. **Execute left to right** — for each workflow:
16
+ - a. **Report start:** "Pipeline [{current}/{total}]: Starting {code} ({description})..."
17
+ - b. **Resolve inputs** from the previous workflow's output using the Data Flow table in pipeline-contracts.md. Pass any produced `skill_name`, `brief_path`, or other handoff data as the input argument.
18
+ - c. **Invoke the workflow** with `{headless_mode}` = true, `{pipeline_alias}` set to the alias name (`forge-auto`, `forge`, `forge-quick`, `maintain`, or `null` for ad-hoc sequences), and any resolved arguments.
19
+ - d. **Check the circuit breaker** after completion — load the output artifact and validate it against the threshold (default, or user-specified via `[min:N]`). On failure, halt the pipeline and report what completed and what remains.
20
+ - e. **Report completion:** "Pipeline [{current}/{total}]: {code} complete — {brief summary of output}."
21
+
22
+ 5. **Pipeline summary** — after all workflows complete (or on halt), present: completed workflows with key outputs; the failed/halted workflow (if any) with its halt reason; remaining unexecuted workflows; and a next-steps recommendation.
23
+
24
+ 6. **Result contract** — write the pipeline result contract per `shared/references/output-contract-schema.md`: the per-run record at `{sidecar_path}/pipeline-result-{YYYYMMDD-HHmmss}.json` (UTC timestamp, resolution to seconds) and a copy at `{sidecar_path}/pipeline-result-latest.json` (stable path for consumers — copy, not symlink). Include one entry per completed workflow in `outputs` (each referencing that workflow's own `-latest.json` record); record per-step status for every workflow in the sequence — completed, halted, and not-yet-run — plus the overall pipeline status (`summary.status` — one of `success`, `failed`, or `partial`) in `summary`. On a `failed`/`partial` status, the forger's On Activation resume check reads that per-step record to offer continuation of the not-yet-run workflows.
25
+
26
+ ## forge-auto argument passing
27
+
28
+ `forge-auto <repo-url> --pin <version>` — the `--pin` argument flows to AN's pipeline data context alongside the `[auto]` flag. AN's `step-auto-scope.md §0b` consumes it for pin resolution.
29
+
30
+ ## Special behaviors
31
+
32
+ - **`AN` with `CS`:** if AN produces multiple recommended briefs, auto-select all and process them sequentially in batch mode. If only one unit is found, auto-select it.
33
+ - **`AS` followed by `US`:** if `summary.severity` in `audit-skill-result-latest.json` is CLEAN, skip US and report "No drift detected — skipping update."
34
+ - **`TS` followed by `EX`:** if the test result is FAIL and the score is below the circuit-breaker threshold, halt before EX.
@@ -0,0 +1,270 @@
1
+ #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.10"
4
+ # ///
5
+ """Deterministic parse + validation of a forger pipeline invocation.
6
+
7
+ Pipeline Mode (references/pipeline-mode.md §1-2) turns a raw code sequence
8
+ (`BS CS[cocoindex] TS[min:80] EX`, `AN -> CS -> TS -> EX`, or a bare alias like
9
+ `forge-auto`) into a normalized run plan and a list of sequence anti-patterns.
10
+ Splitting the tokens, expanding aliases against a fixed table, classifying each
11
+ bracket argument, and detecting anti-patterns (duplicates, ordering, missing
12
+ prerequisites) is set/order plumbing with exactly one correct answer per input —
13
+ so it runs here, not in the prompt. The prompt keeps only the judgment the
14
+ script cannot make: interpreting the user's freeform request into a code
15
+ sequence, and deciding whether to proceed past a warned anti-pattern.
16
+
17
+ The alias-expansion and anti-pattern tables mirror
18
+ `src/shared/references/pipeline-contracts.md` (the human-readable contract);
19
+ this script is the executable form the forger consumes.
20
+
21
+ CLI usage:
22
+ uv run scripts/parse-pipeline.py 'BS CS TS EX' # positional
23
+ uv run scripts/parse-pipeline.py 'forge-auto' # bare alias
24
+ echo 'AN -> CS -> TS -> EX' | uv run scripts/parse-pipeline.py --stdin
25
+
26
+ Output (stdout, one object):
27
+ {
28
+ "raw": "<input>",
29
+ "alias": "forge" | null, # set when the input was a lone alias
30
+ "deprecated_alias": "deepwiki" | null,
31
+ "removed_alias": "onboard" | null,
32
+ "expanded": ["BS", "CS", "TS", "EX"], # normalized tokens (post-expansion)
33
+ "plan": [{"code","min","mode","target"}, ...],
34
+ "codes": ["BS", "CS", "TS", "EX"],
35
+ "unknown_codes": [],
36
+ "anti_patterns": [{"pattern","message","suggestion"}, ...],
37
+ "valid": <bool> # runnable: real codes, no unknowns, not removed
38
+ }
39
+
40
+ Exit codes:
41
+ 0 — parsed, runnable (anti-patterns and a deprecated alias are warnings)
42
+ 1 — no input provided (usage error)
43
+ 2 — removed alias (e.g. `onboard`) — the forger HALTs
44
+ 3 — nothing runnable (empty, or unknown codes) — the forger corrects course
45
+ """
46
+
47
+ from __future__ import annotations
48
+
49
+ import argparse
50
+ import json
51
+ import re
52
+ import sys
53
+
54
+ # Workflow codes that can appear in a pipeline. KI/WS are inline actions, not
55
+ # pipeline steps; `campaign` is a standalone workflow, not a pipeline code.
56
+ KNOWN_CODES = frozenset(
57
+ {"SF", "AN", "BS", "CS", "QS", "SS", "US", "AS", "VS", "RA", "TS", "EX", "RS", "DS"}
58
+ )
59
+
60
+ # Only these accept a `min:N` circuit-breaker override; on other codes a
61
+ # `min:N` bracket is ignored (recorded as `min: null`).
62
+ CIRCUIT_BREAKER_CODES = frozenset({"AN", "CS", "TS", "AS", "VS"})
63
+
64
+ # Alias table — mirrors pipeline-contracts.md. `forge-auto`'s TS[min:90] gate is
65
+ # non-default and is kept in lockstep with init.md §1b's forge-auto → 90 lookup.
66
+ ALIASES = {
67
+ "forge-auto": ["AN[auto]", "BS[auto]", "CS", "TS[min:90]", "EX"],
68
+ "forge": ["BS", "CS", "TS", "EX"],
69
+ "forge-quick": ["QS", "TS", "EX"],
70
+ "maintain": ["AS", "US", "TS", "EX"],
71
+ }
72
+ DEPRECATED_ALIASES = {"deepwiki": "forge-auto"} # renamed; still expands
73
+ REMOVED_ALIASES = {"onboard"} # no expansion — the forger HALTs
74
+
75
+ _TOKEN_RE = re.compile(r"^([A-Za-z]+)(?:\[([^\]]*)\])?$")
76
+ _ARROWS = re.compile(r"->|→|—>|»")
77
+
78
+
79
+ def _tokenize(raw):
80
+ """Split a raw sequence on whitespace and arrow separators."""
81
+ normalized = _ARROWS.sub(" ", raw)
82
+ return [t for t in normalized.split() if t]
83
+
84
+
85
+ def _classify_bracket(code, value):
86
+ """Return (min, mode, target) for a bracket value on a given code."""
87
+ if value is None or value == "":
88
+ return None, None, None
89
+ m = re.fullmatch(r"min:(\d+)", value)
90
+ if m:
91
+ # min:N only applies to circuit-breaker codes; ignored elsewhere.
92
+ return (int(m.group(1)) if code in CIRCUIT_BREAKER_CODES else None), None, None
93
+ if value == "auto":
94
+ return None, "auto", None
95
+ return None, None, value
96
+
97
+
98
+ def _detect_anti_patterns(codes):
99
+ """Deterministic sequence checks — mirrors pipeline-contracts.md."""
100
+ found = []
101
+
102
+ # Duplicate codes.
103
+ seen = set()
104
+ dupes = []
105
+ for c in codes:
106
+ if c in seen and c not in dupes:
107
+ dupes.append(c)
108
+ seen.add(c)
109
+ if dupes:
110
+ found.append(
111
+ {
112
+ "pattern": "duplicate-codes",
113
+ "codes": dupes,
114
+ "message": f"same workflow appears more than once: {', '.join(dupes)}",
115
+ "suggestion": "remove the duplicate",
116
+ }
117
+ )
118
+
119
+ # EX before TS (equivalently, TS after EX).
120
+ ex_idxs = [i for i, c in enumerate(codes) if c == "EX"]
121
+ ts_idxs = [i for i, c in enumerate(codes) if c == "TS"]
122
+ if ex_idxs and ts_idxs and min(ex_idxs) < max(ts_idxs):
123
+ found.append(
124
+ {
125
+ "pattern": "ex-before-ts",
126
+ "codes": ["EX", "TS"],
127
+ "message": "EX (export) runs before TS (test) — exporting an untested skill",
128
+ "suggestion": "move TS before EX",
129
+ }
130
+ )
131
+
132
+ # CS without BS or AN.
133
+ if "CS" in codes and "BS" not in codes and "AN" not in codes:
134
+ found.append(
135
+ {
136
+ "pattern": "cs-without-brief",
137
+ "codes": ["CS"],
138
+ "message": "CS (compile) has no preceding BS or AN — compiling without a brief",
139
+ "suggestion": "use QS for the quick path, or add AN/BS to produce a brief",
140
+ }
141
+ )
142
+
143
+ # US without AS.
144
+ if "US" in codes and "AS" not in codes:
145
+ found.append(
146
+ {
147
+ "pattern": "us-without-audit",
148
+ "codes": ["US"],
149
+ "message": "US (update) has no preceding AS — updating without an audit",
150
+ "suggestion": "run AS first to detect what changed",
151
+ }
152
+ )
153
+
154
+ return found
155
+
156
+
157
+ def parse_pipeline(raw):
158
+ """Parse and validate a raw pipeline sequence. Deterministic."""
159
+ tokens = _tokenize(raw)
160
+ result = {
161
+ "raw": raw,
162
+ "alias": None,
163
+ "deprecated_alias": None,
164
+ "removed_alias": None,
165
+ "expanded": [],
166
+ "plan": [],
167
+ "codes": [],
168
+ "unknown_codes": [],
169
+ "anti_patterns": [],
170
+ "valid": False,
171
+ }
172
+ if not tokens:
173
+ return result
174
+
175
+ # Alias handling — only when the sequence is a lone alias token.
176
+ if len(tokens) == 1:
177
+ lone = tokens[0].lower()
178
+ if lone in REMOVED_ALIASES:
179
+ result["removed_alias"] = lone
180
+ return result
181
+ if lone in DEPRECATED_ALIASES:
182
+ result["deprecated_alias"] = lone
183
+ target = DEPRECATED_ALIASES[lone]
184
+ result["alias"] = target
185
+ tokens = list(ALIASES[target])
186
+ elif lone in ALIASES:
187
+ result["alias"] = lone
188
+ tokens = list(ALIASES[lone])
189
+
190
+ result["expanded"] = []
191
+ for tok in tokens:
192
+ m = _TOKEN_RE.match(tok)
193
+ if not m:
194
+ result["unknown_codes"].append(tok)
195
+ continue
196
+ code = m.group(1).upper()
197
+ value = m.group(2)
198
+ result["expanded"].append(
199
+ f"{code}[{value}]" if value not in (None, "") else code
200
+ )
201
+ if code not in KNOWN_CODES:
202
+ result["unknown_codes"].append(tok)
203
+ continue
204
+ min_n, mode, target = _classify_bracket(code, value)
205
+ result["codes"].append(code)
206
+ result["plan"].append(
207
+ {"code": code, "min": min_n, "mode": mode, "target": target}
208
+ )
209
+
210
+ result["anti_patterns"] = _detect_anti_patterns(result["codes"])
211
+ result["valid"] = bool(result["codes"]) and not result["unknown_codes"]
212
+ return result
213
+
214
+
215
+ # --- CLI --------------------------------------------------------------------
216
+
217
+
218
+ def _build_parser():
219
+ parser = argparse.ArgumentParser(
220
+ prog="parse-pipeline",
221
+ description=(
222
+ "Deterministic parse + validation of a forger pipeline invocation "
223
+ "(pipeline-mode.md §1-2): tokenize, expand aliases, classify bracket "
224
+ "arguments, and detect sequence anti-patterns, returning a normalized "
225
+ "run plan as JSON."
226
+ ),
227
+ formatter_class=argparse.RawDescriptionHelpFormatter,
228
+ )
229
+ src = parser.add_mutually_exclusive_group()
230
+ src.add_argument(
231
+ "sequence",
232
+ nargs="?",
233
+ help="Raw pipeline sequence as a positional argument.",
234
+ )
235
+ src.add_argument(
236
+ "--stdin",
237
+ action="store_true",
238
+ help="Read the raw sequence from stdin.",
239
+ )
240
+ return parser
241
+
242
+
243
+ def _resolve_input(args):
244
+ if args.stdin:
245
+ return sys.stdin.read()
246
+ if args.sequence is not None:
247
+ return args.sequence
248
+ return ""
249
+
250
+
251
+ def main(argv=None):
252
+ parser = _build_parser()
253
+ args = parser.parse_args(argv)
254
+ raw = _resolve_input(args)
255
+ if not raw.strip():
256
+ parser.print_usage(file=sys.stderr)
257
+ print("error: no input provided (positional arg or --stdin)", file=sys.stderr)
258
+ return 1
259
+
260
+ result = parse_pipeline(raw)
261
+ print(json.dumps(result, indent=2))
262
+ if result["removed_alias"]:
263
+ return 2
264
+ if not result["valid"]:
265
+ return 3
266
+ return 0
267
+
268
+
269
+ if __name__ == "__main__":
270
+ raise SystemExit(main())