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
@@ -1,9 +1,12 @@
1
1
  ---
2
2
  nextStepFile: 'ecosystem-check.md'
3
- registryResolutionData: 'references/registry-resolution.md'
3
+ registryResolutionData: '{registryResolutionPath}'
4
4
  packageResolverProbeOrder:
5
5
  - '{project-root}/_bmad/skf/shared/scripts/skf-resolve-package.py'
6
6
  - '{project-root}/src/shared/scripts/skf-resolve-package.py'
7
+ detectLanguageProbeOrder:
8
+ - '{project-root}/_bmad/skf/shared/scripts/skf-detect-language.py'
9
+ - '{project-root}/src/shared/scripts/skf-detect-language.py'
7
10
  ---
8
11
 
9
12
  <!-- Config: communicate in {communication_language}. -->
@@ -19,7 +22,7 @@ To accept a GitHub URL or package name from the user, resolve it to a GitHub rep
19
22
  - Focus only on resolving the target to a GitHub repository — do not begin extraction or compilation
20
23
  - If resolution fails, hard halt with actionable guidance
21
24
 
22
- ## MANDATORY SEQUENCE
25
+ ## Steps
23
26
 
24
27
  ### 1. Accept User Input
25
28
 
@@ -41,7 +44,7 @@ Examples: `cocoindex`, `@tanstack/query`, `https://github.com/tursodatabase/limb
41
44
 
42
45
  Or type `cancel` / `exit` / `:q` / `[X]` to leave without writing anything."
43
46
 
44
- Wait for user input. **Cancel branch** — if the user types `cancel`, `exit`, `:q`, `[X]`, or selects `[X] Cancel and exit`, display `"Cancelled — no files were written."` and HARD HALT with **exit code 6 (user-cancelled)** per the SKILL.md exit-code map. Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "resolve-target"`, `error.code: "user-cancelled"`, `skill_package: null`). Cancellation here is non-destructive — no files have been written yet.
47
+ Wait for user input. **Cancel branch** — if the user types `cancel`, `exit`, `:q`, `[X]`, or selects `[X] Cancel and exit`, display `"Cancelled — no files were written."` and HARD HALT with **exit code 6 (user-cancelled)** per the exit-code map in `references/halt-contract.md`. Before exiting, emit the error result contract per `references/halt-contract.md` (`phase: "resolve-target"`, `error.code: "user-cancelled"`, `skill_package: null`). Cancellation here is non-destructive — no files have been written yet.
45
48
 
46
49
  **GATE [default: use args]** — If `{headless_mode}` and a target (URL or package name) was provided as argument: use it as the target input and auto-proceed, log: "headless: using provided target". If no target provided in headless mode, HALT with: "headless mode requires a target argument."
47
50
 
@@ -79,7 +82,7 @@ If you are describing a skill you want to **create from scratch** rather than co
79
82
 
80
83
  Otherwise, paste the package name or GitHub URL of the library you want to wrap, and quick-skill will resolve it."
81
84
 
82
- **GATE [default: HALT]** — In headless mode, emit the same redirect message and HALT with **exit code 3 (resolution-failure)** per the SKILL.md exit-code map. Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `skill_package: null`). Do not attempt registry lookups against prose input; that wastes ~3-4 round trips and produces a less actionable error message than the redirect above.
85
+ **GATE [default: HALT]** — In headless mode, emit the same redirect message and HALT with **exit code 3 (resolution-failure)** per the exit-code map in `references/halt-contract.md`. Before exiting, emit the error result contract per `references/halt-contract.md` (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `skill_package: null`). Do not attempt registry lookups against prose input; that wastes ~3-4 round trips and produces a less actionable error message than the redirect above.
83
86
 
84
87
  ### 3. Registry Resolution
85
88
 
@@ -107,7 +110,7 @@ Check:
107
110
 
108
111
  **Provide the GitHub URL directly to continue.**"
109
112
 
110
- In interactive mode, wait for corrected input and loop back to step 2. In headless mode, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `skill_package: null`) and exit 3.
113
+ In interactive mode, wait for corrected input and loop back to step 2. In headless mode, emit the error result contract per `references/halt-contract.md` (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `skill_package: null`) and exit 3.
111
114
 
112
115
  ### 3a. Verify Target Version Tag (when applicable)
113
116
 
@@ -135,35 +138,36 @@ Recent tags in this repo:
135
138
 
136
139
  Re-run with one of these tags, or omit the `@version` suffix to auto-detect from the default branch."
137
140
 
138
- Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `error.details: {requested_version: "{target_version}", available_tags: [...top 5]}`, `skill_package: null`). In headless mode, exit immediately; do not loop.
141
+ Before exiting, emit the error result contract per `references/halt-contract.md` (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `error.details: {requested_version: "{target_version}", available_tags: [...top 5]}`, `skill_package: null`). In headless mode, exit immediately; do not loop.
139
142
 
140
143
  ### 4. Detect Language
141
144
 
142
- Determine primary language from:
145
+ **Resolve `{detectLanguageHelper}`** from `{detectLanguageProbeOrder}`; first existing path wins. If no candidate exists (e.g. Python/`uv` unavailable), fall back to the manifest-priority walk documented in the helper's `--help` — `package.json` → JavaScript/TypeScript (TypeScript when a `tsconfig.json` is also present), `Cargo.toml` → Rust, `pyproject.toml`/`setup.py`/`setup.cfg` → Python, `go.mod` → Go, `pom.xml` → Java, `build.gradle.kts` → Kotlin, `build.gradle` → Kotlin when `src/main/kotlin/` exists else Java, `*.csproj`/`*.sln` → C#, `Gemfile` → Ruby, then extension frequency — applied by hand.
143
146
 
144
- 1. **User-provided language hint** (overrides detection — skip the ambiguity gate below).
145
- 2. **Manifest-presence scan** — check the repo root for ALL of these (priority order = first hit wins on auto-pick):
146
- - `package.json` → JavaScript/TypeScript
147
- - `pyproject.toml` or `setup.py` → Python
148
- - `Cargo.toml` → Rust
149
- - `go.mod` → Go
150
- - `pom.xml` → Java (or Kotlin if `src/main/kotlin/` is present)
151
- - `build.gradle.kts` or `build.gradle` → Kotlin (or Java if only `src/main/java/` is present)
147
+ Determine primary language:
152
148
 
153
- Collect every match into `detected_languages`.
149
+ 1. **User-provided language hint** (overrides detection) — set `language` to the hint and skip straight to §5. The disambiguation gate below does not run.
154
150
 
155
- 3. **Single-language case** (`len(detected_languages) <= 1`)set `language` to the detected value (or HALT in step 1 §3 if zero matches).
151
+ 2. **Delegate the rule walk to `{detectLanguageHelper}`**it is the single source of truth for the manifest → language rule table (including the `package.json` JS-vs-TS disambiguation); do not restate or re-derive it here. Fetch the repo file listing once (`gh api repos/{owner}/{repo}/git/trees/{source_ref or default branch}?recursive=1`, reading the `path` values), then hand the flat list to the script:
156
152
 
157
- 4. **Multi-language case** (`len(detected_languages) > 1`) — surface the choice rather than silently picking the first match. Multi-language repos (Python + JS bindings, or monorepos with mixed manifests) otherwise produce a skill for whichever manifest probe hits first, with no signal that the user might have wanted the other one.
153
+ ```bash
154
+ echo '{"tree": [<flat list of repo-relative file paths>]}' | uv run {detectLanguageHelper}
155
+ ```
156
+
157
+ The script returns `{language, confidence, detection_source, detected_languages}` after walking the deterministic rule table (manifest presence first, then extension-frequency fallback). `detected_languages` is the ordered, deduplicated set of every manifest-level match in priority order, with `detected_languages[0]` equal to the winning `language`.
158
+
159
+ 3. **Auto-pick** — set `language` to the returned `language`. If `detected_languages` is empty (the script recognized no manifest and no source extensions — `language` is `"unknown"`), treat it as a zero-match resolution and HALT with the step 1 §3 resolution-failure guidance so the user can supply a language hint or a different target.
160
+
161
+ 4. **Multi-language gate** (`len(detected_languages) > 1`) — the script found manifests for more than one language. Surface the choice rather than silently keeping the first match. Multi-language repos (Python + JS bindings, or monorepos with mixed manifests) otherwise produce a skill for whichever manifest sorts first in priority order, with no signal that the user might have wanted the other one.
158
162
 
159
163
  "**`{repo_name}` has manifests for multiple languages:** {detected_languages}.
160
164
 
161
- Primary guess: **{first_match}** (manifest-priority order). If you wanted a different language, abort and re-run with `--language-hint <lang>` or with the optional language hint at step 1 §1.
165
+ Primary guess: **{language}** (`detected_languages[0]`, manifest-priority order). If you wanted a different language, abort and re-run with `--language-hint <lang>` or with the optional language hint at step 1 §1.
162
166
 
163
- Select: [C] Continue with `{first_match}` · [A] Abort"
167
+ Select: [C] Continue with `{language}` · [A] Abort"
164
168
 
165
- - **IF C** — log "user accepted multi-manifest pick: `{first_match}`" and set `language` to the first match.
166
- - **IF A** — HARD HALT with **exit code 3 (resolution-failure)**: "Aborted to disambiguate language. Re-run with a `language_hint`." Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `error.details: {detected_languages: [...], auto_pick: "{first_match}"}`, `skill_package: null`).
169
+ - **IF C** — log "user accepted multi-manifest pick: `{language}`" and keep `language`.
170
+ - **IF A** — HARD HALT with **exit code 3 (resolution-failure)**: "Aborted to disambiguate language. Re-run with a `language_hint`." Before exiting, emit the error result contract per `references/halt-contract.md` (`phase: "resolve-target"`, `error.code: "resolution-failure"`, `error.details: {detected_languages: [...], auto_pick: "{language}"}`, `skill_package: null`).
167
171
  - **GATE [default: C]** — Headless mode auto-proceeds with the manifest-priority pick; record `detected_languages` and `language_resolution: "auto-picked-first"` in the extraction context so the result contract surfaces the ambiguity downstream.
168
172
 
169
173
  ### 5. Confirm Resolution
@@ -179,16 +183,5 @@ Determine primary language from:
179
183
 
180
184
  ### 6. Proceed to Next Step
181
185
 
182
- #### Menu Handling Logic:
183
-
184
- - After successful resolution confirmation, immediately load, read entire file, then execute {nextStepFile}
185
-
186
- #### EXECUTION RULES:
187
-
188
- - This is an init step with auto-proceed after successful resolution
189
- - Proceed directly to next step after confirmation
190
-
191
- ## CRITICAL STEP COMPLETION NOTE
192
-
193
- ONLY WHEN the target has been successfully resolved to a GitHub repository with confirmed URL, name, and detected language will you load and read fully `{nextStepFile}` to execute the ecosystem check.
186
+ Once the target is resolved to a GitHub repository with confirmed URL, name, and detected language, load and execute {nextStepFile} for the ecosystem check.
194
187
 
@@ -18,12 +18,10 @@ To write the compiled SKILL.md, context-snippet.md, and metadata.json to the ver
18
18
 
19
19
  ## Rules
20
20
 
21
- - Write exactly what was compiled — do not modify content during writing
22
- - Validation is advisory — report issues but never block output
23
- - Do not modify compiled content post-validation — report only
21
+ - Write exactly what was compiled — do not modify content during writing or after validation
24
22
  - Community-tier validation (lighter than official requirements)
25
23
 
26
- ## MANDATORY SEQUENCE
24
+ ## Steps
27
25
 
28
26
  ### 1. Create Output Directory
29
27
 
@@ -39,7 +37,7 @@ If `{skill_package}` already exists, confirm with user before overwriting:
39
37
  "**Directory `{skill_package}` already exists.** Overwrite will replace the prior compiled output; validation results, result contracts, and any manual tweaks from the previous run will not be preserved. Overwrite existing files? [Y/N]"
40
38
 
41
39
  - **If user selects Y:** Proceed to section 2.
42
- - **If user selects N:** HARD HALT with **exit code 5 (overwrite-cancelled)** per the SKILL.md exit-code map: "Overwrite cancelled. Existing skill preserved. Run [QS] with a different skill name or remove the existing directory manually." Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "write-and-validate"`, `error.code: "overwrite-cancelled"`, `skill_package` set to the existing path that was preserved). Disk write of the `-latest.json` envelope is REQUIRED here since `{skill_package}` is known.
40
+ - **If user selects N:** HARD HALT with **exit code 5 (overwrite-cancelled)** per the exit-code map in `references/halt-contract.md`: "Overwrite cancelled. Existing skill preserved. Run [QS] with a different skill name or remove the existing directory manually." Before exiting, emit the error result contract per `references/halt-contract.md` (`phase: "write-and-validate"`, `error.code: "overwrite-cancelled"`, `skill_package` set to the existing path that was preserved). Write the `-latest.json` envelope to disk here `{skill_package}` is known, so consumers that hardcode that path see a deterministic file even on this cancelled run.
43
41
 
44
42
  **GATE [default: Y]** — If `{headless_mode}` is true, auto-proceed with Y and log: "headless: overwriting existing `{skill_package}`".
45
43
 
@@ -53,7 +51,7 @@ Write the three compiled artifacts to the skill package so that validation in se
53
51
 
54
52
  Confirm after each write: "Written: SKILL.md" / "Written: context-snippet.md" / "Written: metadata.json". When `--skip-snippet` is active, log "Skipped: context-snippet.md (--skip-snippet)" instead of the snippet write confirmation.
55
53
 
56
- **If any write fails — HARD HALT (exit code 4, write-failure):** Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "write-and-validate"`, `error.code: "write-failure"`, `error.details: {failed_path: <path>, error: <details>}`, `skill_package` set, `outputs` listing any files that did write successfully before the failure).
54
+ **If any write fails — HARD HALT (exit code 4, write-failure):** Before exiting, emit the error result contract per `references/halt-contract.md` (`phase: "write-and-validate"`, `error.code: "write-failure"`, `error.details: {failed_path: <path>, error: <details>}`, `skill_package` set, `outputs` listing any files that did write successfully before the failure).
57
55
 
58
56
  "**Write failed:** Could not write to `{file_path}`.
59
57
 
@@ -71,8 +69,6 @@ Run: `npx skill-check -h`
71
69
  - If succeeds (returns usage information): Continue to automated validation (section 4)
72
70
  - If fails (command not found or error): Skip to manual fallback in section 4
73
71
 
74
- **Important:** Use the verification command. Do not assume availability — empirical check required.
75
-
76
72
  ### 4. Validate SKILL.md via skill-check (if available)
77
73
 
78
74
  **If `npx skill-check` is available**, run automated validation + security scan in one invocation against the skill package written in section 2 (security scan is enabled by default when `--no-security-scan` is omitted, so the same call covers §6 and avoids paying the npx startup cost twice):
@@ -84,24 +80,24 @@ npx skill-check check {skill_package} --fix --format json
84
80
  This validates frontmatter, description, body limits, links, and formatting; runs the security scan; and auto-fixes deterministic issues (field ordering, slug format, required fields, trailing newlines).
85
81
 
86
82
  **Parse JSON output** to extract:
87
- - `scores[].score` — overall score (0-100); match the entry by `relativePath`/`skillId` (older skill-check builds exposed this as a top-level `qualityScore`)
83
+ - `scores[].score` — overall score (0-100); match the entry by `relativePath`/`skillId`
88
84
  - `diagnostics[]` — remaining issues after auto-fix
89
85
  - `fixed[]` — issues automatically corrected
90
86
  - `security[]` (when present) — security findings, recorded as advisory warnings (security issues do not block output)
91
87
 
92
88
  Record quality score, remaining diagnostics, and security findings as validation issues.
93
89
 
94
- **If skill-check is NOT available**, run the shared frontmatter validator instead of an LLM-walked checklist. Resolve `{frontmatterValidator}` from `{frontmatterValidatorProbeOrder}`; first existing path wins. If no candidate exists, log a high-severity issue ("frontmatter validator unavailable — both `npx skill-check` and `skf-validate-frontmatter.py` missing") and skip frontmatter validation.
90
+ **If skill-check is not available**, run the shared frontmatter validator. Resolve `{frontmatterValidator}` from `{frontmatterValidatorProbeOrder}`; first existing path wins. If no candidate exists, log a high-severity issue ("frontmatter validator unavailable — both `npx skill-check` and `skf-validate-frontmatter.py` missing") and skip frontmatter validation.
95
91
 
96
92
  ```bash
97
93
  uv run {frontmatterValidator} {skill_package}/SKILL.md --skill-dir-name {repo_name}
98
94
  ```
99
95
 
100
- The validator emits JSON with `status` (`pass`/`fail`), `issues[]` (each with `severity`, `code`, `message`), and `frontmatter` (the parsed name/description). It checks frontmatter delimiters, name format (Unicode letters + digits + hyphens, no consecutive/trailing hyphens), name-directory match, description presence and length, and unknown fields against the agentskills.io spec — the same shape this step would otherwise hand-walk. Record each `issues[]` entry as a validation issue with its reported severity. Missing frontmatter or missing required fields are high-severity — skills without valid frontmatter will fail `npx skills add` and `npx skill-check check`.
96
+ The validator emits JSON with `status` (`pass`/`fail`), `issues[]` (each with `severity`, `code`, `message`), and `frontmatter` (the parsed name/description). It checks frontmatter delimiters, name format (Unicode letters + digits + hyphens, no consecutive/trailing hyphens), name-directory match, description presence and length, and unknown fields against the agentskills.io spec. Record each `issues[]` entry as a validation issue with its reported severity. Missing frontmatter or missing required fields are high-severity — skills without valid frontmatter will fail `npx skills add` and `npx skill-check check`.
101
97
 
102
98
  ### 5. Validate Body, Snippet, and Metadata via skf-validate-output.py
103
99
 
104
- Run the shared output validator against the on-disk skill package — it performs the body-structure, snippet-format, and metadata-shape checks that this step previously walked by hand. Pass `--skip-frontmatter` since §4 has already covered frontmatter.
100
+ Run the shared output validator against the on-disk skill package — it performs the body-structure, snippet-format, and metadata-shape checks. Pass `--skip-frontmatter` since §4 has already covered frontmatter.
105
101
 
106
102
  **Resolve `{outputValidator}`:** probe `{outputValidatorProbeOrder}` (installed first, dev fallback); first existing path wins. If neither candidate exists, log a high-severity issue ("output validator unavailable — `skf-validate-output.py` missing") and skip body/snippet/metadata validation.
107
103
 
@@ -111,7 +107,7 @@ python3 {outputValidator} {skill_package} --generated-by quick-skill --skip-fron
111
107
 
112
108
  The validator emits JSON with `result` (PASS/FAIL), `validation.skill_md.body[]`, `validation.context_snippet.issues[]`, `validation.metadata.issues[]`, and a severity-bucketed `summary`. Record each issue as a validation issue at its reported severity.
113
109
 
114
- Coverage replaces these former hand-walked checklists:
110
+ The validator covers:
115
111
 
116
112
  - **Body structure** — Overview, Description, Key Exports, Usage sections present (medium when missing)
117
113
  - **Context snippet** — `[{name} v{version}]|root: ...` first line, `|IMPORTANT:` second line, ~80–120-token length
@@ -149,16 +145,5 @@ Set `validation_result` with pass/fail status, quality score, and issues list.
149
145
 
150
146
  ### 8. Auto-Proceed to Finalize
151
147
 
152
- #### Menu Handling Logic:
153
-
154
- - After validation report, immediately load, read entire file, then execute {nextStepFile}
155
-
156
- #### EXECUTION RULES:
157
-
158
- - This is an auto-proceed step — validation is advisory
159
- - Proceed directly to finalize step after reporting results
160
-
161
- ## CRITICAL STEP COMPLETION NOTE
162
-
163
- ONLY WHEN deliverables have been written to `{skill_package}` and validation checks are complete and results reported will you load and read fully `{nextStepFile}` to execute finalization.
148
+ Once deliverables are written to `{skill_package}` and validation is reported (advisory), load and execute {nextStepFile} to finalize.
164
149
 
@@ -50,8 +50,8 @@ These rules apply to every step in this workflow:
50
50
  |--------|--------|
51
51
  | **Inputs** | architecture_doc_path [required], vs_report_path [optional] |
52
52
  | **Flags** | `--headless` / `-H` (auto-resolve all gates); `--architecture-doc <path>` (skip step 1 prompt for the required input); `--vs-report-path <path>` (skip step 1 prompt for the optional VS report); `--scope-skills <names>` (comma-separated in-scope skill names; overrides scope derivation in gap analysis) |
53
- | **Gates** | step 1: Input Gate [use args] | step 5: Review Gate [C] |
54
- | **Outputs** | `refined-architecture-{project_name}.md` at `{outputFolderPath}`, plus `refine-architecture-result-{timestamp}.json` and `refine-architecture-result-latest.json` |
53
+ | **Gates** | step 1: Input Gate [use args] | step 5: Review Gate [C] continue / [X] cancel | step 6: Exit menu [R] review / [X] exit |
54
+ | **Outputs** | `refined-architecture-{arch_project_name}.md` at `{outputFolderPath}` (`{arch_project_name}` = the architecture doc's frontmatter `project_name`, else config `project_name` — resolved in init.md), plus `refine-architecture-result-{timestamp}.json` and `refine-architecture-result-latest.json` |
55
55
  | **Headless** | All gates auto-resolve with default action when `{headless_mode}` is true. Per-flag args (`--architecture-doc`, `--vs-report-path`) consumed at the gates that would otherwise prompt. |
56
56
  | **Exit codes** | See "Exit Codes" below |
57
57
 
@@ -63,8 +63,8 @@ Every HARD HALT in this workflow exits with a stable code so headless automators
63
63
  | ---- | -------------------- | -------------------------------------------------------------------------------------------- |
64
64
  | 0 | success | step 7 (terminal) |
65
65
  | 2 | input-missing / input-invalid | step 1 §1 (headless missing `architecture-doc` arg, or invalid path) → `input-missing`; non-existent file → `input-invalid` |
66
- | 3 | resolution-failure | step 1 §3 (`output_folder` or `forge_data_folder` unconfigured) |
67
- | 4 | write-failure | On-Activation §3 pre-flight write probe; step 1 §3c (RA state file write failed); step 5 §6 (refined-architecture write failed); step 6 §3 (result-contract write failed) |
66
+ | 3 | resolution-failure | On-Activation §5 (`output_folder` or `forge_data_folder` unconfigured) |
67
+ | 4 | write-failure | On-Activation §5 pre-flight write probe; step 1 §3c (RA state file write failed); step 5 §6 (refined-architecture write failed); step 6 §3 (result-contract write failed) |
68
68
  | 5 | state-conflict | step 1 §3 (no skills found — refinement requires ≥1 skill) |
69
69
  | 6 | user-cancelled | step 1 §1 prompt cancelled; any prompt that accepted `cancel`/`exit`/`:q`; step 5 review gate `[X]` |
70
70
  | 7 | inventory-unreliable | step 1 §2 (>20% skill-inventory warnings exceed budget) |
@@ -110,10 +110,17 @@ SKF_REFINE_ARCHITECTURE_RESULT_JSON: {"status":"success|error","refined_path":"
110
110
 
111
111
  - `{refinementRulesPath}` ← `workflow.refinement_rules_path` if non-empty, else `references/refinement-rules.md`
112
112
  - `{outputFolderPath}` ← `workflow.output_folder_path` if non-empty, else `{output_folder}`
113
+ - `{onCompleteCommand}` ← `workflow.on_complete` if non-empty, else empty (no-op — report.md skips the hook invocation entirely)
113
114
 
114
- Stash both as workflow-context variables. Stage files reference them directly — no conditional at the usage site.
115
+ Stash all three as workflow-context variables. Stage files reference them directly — no conditional at the usage site.
115
116
 
116
- 5. **Pre-flight write probe.** Verify both `{outputFolderPath}` and `{forge_data_folder}` are writable. A read-only mount, full disk, or permissions-denied path otherwise only surfaces at init.md §3c's RA state file write by then the user has already gone through input prompts:
117
+ Also apply the array surfaces (not silent no-ops): run `workflow.activation_steps_prepend` now, treat `workflow.persistent_facts` as standing context for the run (`file:`-prefixed entries load their file/glob contents as facts), then run `workflow.activation_steps_append` after activation.
118
+
119
+ 5. **Pre-flight config + write probe.** Assert both output paths are configured, then probe writability — order matters: an empty path makes `mkdir -p ""` fail, which would misreport a *missing config* (exit 3) as a *write failure* (exit 4) and collapse the distinction the Result Contract draws.
120
+
121
+ **Config-completeness (exit 3).** If `{outputFolderPath}` is empty: HALT (exit code 3, `halt_reason: "output-folder-unconfigured"`) — "`output_folder` is not configured in config.yaml. Add an `output_folder` path and re-run [RA]." If `{forge_data_folder}` is empty: HALT (exit code 3, `halt_reason: "forge-folder-unconfigured"`) — "`forge_data_folder` is not configured in config.yaml. Add a `forge_data_folder` path and re-run [RA]."
122
+
123
+ **Write probe (exit 4).** With both paths now non-empty, verify each is writable — a read-only mount, full disk, or permissions-denied path otherwise only surfaces at init.md §3c's RA state file write, by which point the user has already gone through input prompts:
117
124
 
118
125
  ```bash
119
126
  for dir in "{outputFolderPath}" "{forge_data_folder}"; do
@@ -123,6 +130,6 @@ SKF_REFINE_ARCHITECTURE_RESULT_JSON: {"status":"success|error","refined_path":"
123
130
  done
124
131
  ```
125
132
 
126
- On any non-zero exit: HALT (exit code 4, `halt_reason: "write-failed"`). In headless mode, emit the error envelope per **Result Contract (Headless)** with `refined_path: null`.
133
+ On any non-zero exit: HALT (exit code 4, `halt_reason: "write-failed"`). In headless mode, every HALT above emits the error envelope per **Result Contract (Headless)** with `refined_path: null`.
127
134
 
128
135
  6. Load, read the full file, and then execute `references/init.md` to begin the workflow.
@@ -1,6 +1,8 @@
1
1
  # DO NOT EDIT -- overwritten on every update.
2
2
  #
3
3
  # Workflow customization surface for skf-refine-architecture.
4
+ # Team overrides: _bmad/custom/skf-refine-architecture.toml (under {project-root})
5
+ # Personal overrides: _bmad/custom/skf-refine-architecture.user.toml (under {project-root})
4
6
 
5
7
  [workflow]
6
8
 
@@ -47,3 +49,10 @@ refinement_rules_path = ""
47
49
  # refined-architecture artifacts to land under a curated docs tree.
48
50
 
49
51
  output_folder_path = ""
52
+
53
+ # Optional post-completion hook. When non-empty, invoked with
54
+ # `--result-path=<path>` after the refined architecture and result JSON are
55
+ # finalized (step 6). Use to index the refined doc, notify, or chain the next
56
+ # workflow. Failures are logged to workflow_warnings[] but never fail the run.
57
+
58
+ on_complete = ""
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  nextStepFile: 'report.md'
3
- outputFile: '{outputFolderPath}/refined-architecture-{project_name}.md'
3
+ # {arch_project_name} resolved in init.md (arch-doc frontmatter project_name, else config project_name).
4
+ outputFile: '{outputFolderPath}/refined-architecture-{arch_project_name}.md'
4
5
  ---
5
6
 
6
7
  <!-- Config: communicate in {communication_language}. Compile the refined architecture document in {document_output_language}. -->
@@ -23,7 +24,7 @@ Produce the refined architecture document by starting with the original as a bas
23
24
 
24
25
  Load the complete original architecture document.
25
26
 
26
- This is the base. Every line of the original MUST appear in the refined document, unmodified.
27
+ This is the base. Every line of the original appears in the refined document unmodified — the workflow only adds annotations and subsections; dropping or rewording original content silently discards the user's architecture.
27
28
 
28
29
  **Context recovery check:** If gap, issue, or improvement findings from Steps 02-04 are not available in context (e.g., due to context degradation in long runs), attempt to read the durability state from `{forge_data_folder}/ra-state-{project_name}.md`. Parse the `<!-- [RA-GAPS] -->`, `<!-- [RA-ISSUES] -->`, and `<!-- [RA-IMPROVEMENTS] -->` comment blocks to recover the complete formatted findings (each block contains full citation text with evidence, not just counts). If a section is still missing or contains only summary counts after recovery, HALT (exit code 8, `halt_reason: "recovery-failed"`): "⚠️ Context for the [Gaps|Issues|Improvements] analysis was lost and the durability state is insufficient to reconstruct findings. Re-run [RA] from the beginning — step 01 will reset the state file, then steps 02-04 will rebuild all findings." In headless, emit the error envelope per SKILL.md "Result Contract (Headless)" with `refined_path: null`.
29
30
 
@@ -112,6 +113,8 @@ Append a `## Refinement Summary` section containing:
112
113
 
113
114
  Write the complete refined architecture to `{outputFile}`.
114
115
 
116
+ On any write failure (read-only mount, disk full, permissions denied): HALT (exit code 4, `halt_reason: "write-failed"`) with the captured error. In headless, emit the error envelope per SKILL.md "Result Contract (Headless)" with `refined_path: null`. The On-Activation §5 write probe should have caught an unwritable output folder earlier — if it surfaces here, the filesystem state changed mid-workflow.
117
+
115
118
  ### 7. Present Compiled Document for Review
116
119
 
117
120
  "**Refined architecture compiled. Please review:**
@@ -134,16 +137,15 @@ Please review the refinements:
134
137
 
135
138
  ### 8. Present MENU OPTIONS
136
139
 
137
- Display: **Select:** [C] Continue to Final Report
140
+ Display: **Select:** [C] Continue to Final Report | [X] Cancel
138
141
 
139
- #### EXECUTION RULES:
142
+ #### GATE [default: C]
140
143
 
141
- - ALWAYS halt and wait for user input after presenting compilation
142
- - **GATE [default: C]** — If `{headless_mode}`: auto-proceed with [C] Continue, log: "headless: auto-approve compiled architecture"
143
- - ONLY proceed to next step when user approves and selects 'C'
144
+ This is a review gate: halt for the user's decision and do not chain onward until they approve — an unreviewed compile ships un-vetted refinements. Headless auto-selects [C] (log: "headless: auto-approve compiled architecture").
144
145
 
145
146
  #### Menu Handling Logic:
146
147
 
147
148
  - IF C: Load, read entire file, then execute {nextStepFile}
149
+ - IF cancel / exit / [X] / q / :q: HALT (exit code 6, `halt_reason: "user-cancelled"`) — display "Cancelled — refinement not finalized." In headless, emit the error envelope per SKILL.md "Result Contract (Headless)" with `refined_path: null`. These global cancel tokens pre-empt the feedback branch below.
148
150
  - IF Any other: Process as feedback, adjust specific refinements in the document, rewrite {outputFile}, redisplay preview, then [Redisplay Menu Options](#8-present-menu-options)
149
151
 
@@ -22,21 +22,15 @@ Find undocumented integration paths — library pairs that have compatible APIs
22
22
 
23
23
  Use the refinement rules loaded in Step 01 from `{refinementRulesData}`. If not available in context, reload from `{refinementRulesData}`.
24
24
 
25
- Extract: gap classification (Missing Integration Path, Undocumented Data Flow, Absent Bridge Layer), detection method, and citation format.
25
+ Extract: gap classification (Missing Integration Path, Undocumented Data Flow, Absent Bridge Layer) and detection method.
26
26
 
27
27
  ### 2. Extract Integration Claims from Architecture
28
28
 
29
29
  Parse the architecture document for statements describing two or more technologies working together.
30
30
 
31
- **Detection method — prose-based co-mention analysis:**
32
- - Identify sentences or paragraphs where two or more technology names appear together
33
- - Look for integration verbs: "connects to", "communicates with", "wraps", "extends", "consumes", "produces", "bridges", "integrates with", "sits between", "feeds into", "receives from"
34
- - Look for data flow descriptions: "{A} sends data to {B}", "{A} results are consumed by {B}"
35
- - Look for layer boundary descriptions: "{A} at the API layer connects to {B} at the data layer"
31
+ **Detection method — prose-based co-mention analysis:** From prose text, find sentences or paragraphs where two or more technology names appear in an *integration relationship* — data flowing between them, one wrapping/bridging/extending/consuming another, or a layer boundary connecting them — not mere co-mention in the same document.
36
32
 
37
- **CRITICAL:** Do NOT parse Mermaid diagram syntax. Use only prose text for co-mention detection.
38
-
39
- **Mermaid Limitation Warning:** If `` ```mermaid `` blocks are present in the architecture document, inform the user: "Integration paths documented exclusively in Mermaid diagrams are excluded from co-mention analysis and may appear as false-positive gaps. Consider adding prose descriptions for diagram-only integration paths." Display this warning informatively and immediately continue — this does not halt or modify the analysis sequence.
33
+ **Mermaid limitation:** Detect co-mentions from prose text only, not from Mermaid diagram syntax an integration drawn only in a diagram would otherwise surface as a false-positive gap. If `` ```mermaid `` blocks are present in the architecture document, inform the user: "Integration paths documented exclusively in Mermaid diagrams are excluded from co-mention analysis and may appear as false-positive gaps. Consider adding prose descriptions for diagram-only integration paths." Display this warning informatively and immediately continue — this does not halt or modify the analysis sequence.
40
34
 
41
35
  **Build documented pairs list:**
42
36
  - Each pair: `{library_a, library_b, architectural_context}`
@@ -44,7 +38,7 @@ Parse the architecture document for statements describing two or more technologi
44
38
 
45
39
  ### 2b. Establish Document Scope
46
40
 
47
- The skill inventory (Step 01 §2) can span a wider product surface than the architecture document under refinement. Pairs drawn from a different surface are NOT actionable gaps for THIS document — surfacing them injects irrelevant integration recommendations (e.g. wiring real-time A/V libraries into an admin-dashboard architecture).
41
+ The skill inventory (Step 01 §2) can span a wider product surface than the architecture document under refinement. Pairs drawn from a different surface are not actionable gaps for this document — surfacing them injects irrelevant integration recommendations (e.g. wiring real-time A/V libraries into an admin-dashboard architecture).
48
42
 
49
43
  Resolve the in-scope skill set:
50
44
 
@@ -53,15 +47,15 @@ Resolve the in-scope skill set:
53
47
 
54
48
  `{out_of_scope_skills}` = inventory skills not in `{in_scope_skills}`. A library pair is **out-of-scope** when either of its libraries is in `{out_of_scope_skills}`.
55
49
 
56
- **Safe default:** If scope cannot be derived (e.g. the architecture references no inventory skill by name) and no `{scope_skills}` was provided, treat ALL skills as in-scope and note: "Could not derive document scope — analyzing all skill pairs." This preserves prior behavior rather than hiding gaps.
50
+ **Safe default:** If scope cannot be derived (e.g. the architecture references no inventory skill by name) and no `{scope_skills}` was provided, treat all skills as in-scope and note: "Could not derive document scope — analyzing all skill pairs." This keeps borderline gaps visible rather than hiding them.
57
51
 
58
52
  Store `{in_scope_skills}` and `{out_of_scope_skills}` as workflow state — Step 03 (issue detection) reuses them.
59
53
 
60
- ### 3. Generate All Possible Library Pairs
54
+ ### 3. Read the Pre-Computed Library Pairs
61
55
 
62
- From the skill inventory, generate all unique combinations of library pairs.
56
+ Read the pre-computed unique library pairs from `skill_inventory.pairs` (the enumerate helper's `--pairs` output cached in Step 01 §2 — the complete, deterministic pair set). Do not re-derive it in-context: a silently dropped or duplicated pair is a missed integration gap, this workflow's headline output.
63
57
 
64
- For N skills, this produces N*(N-1)/2 unique pairs.
58
+ If `skill_inventory.pairs` is absent (the helper was unavailable and the Step 01 §2 fallback path ran), derive the pairs from the inventory as a graceful-degradation fallback only.
65
59
 
66
60
  ### 4. Load Skill API Surfaces for Cross-Reference
67
61
 
@@ -69,10 +63,10 @@ For N skills, this produces N*(N-1)/2 unique pairs.
69
63
 
70
64
  For each library in the skill inventory, delegate reading to a parallel subagent. Launch up to **8 subagents concurrently** (batch larger inventories in rounds of 8).
71
65
 
72
- **Each subagent receives one skill's SKILL.md path and MUST:**
73
- 1. Read the SKILL.md file
74
- 2. Extract the API surface
75
- 3. ONLY return this compact JSON — no prose, no extra commentary:
66
+ **Each subagent receives one skill's SKILL.md path and:**
67
+ 1. Reads the SKILL.md file
68
+ 2. Extracts the API surface
69
+ 3. Returns only this compact JSON — no prose or extra commentary:
76
70
 
77
71
  ```json
78
72
  {
@@ -89,7 +83,7 @@ For each library in the skill inventory, delegate reading to a parallel subagent
89
83
  - `data_formats`: any data format indicators found in the SKILL.md
90
84
  - If a field has no matches, return an empty array `[]`
91
85
 
92
- **Parent collects all subagent JSON summaries.** Do not load full SKILL.md content into parent context.
86
+ **Parent collects all subagent JSON summaries.** Do not load full SKILL.md content into parent context. Store the collected summaries as `{skill_api_surfaces}` workflow state — Step 03 (issue detection) and Step 04 (improvements) reuse them exactly like `{in_scope_skills}`, rather than re-reading each SKILL.md into the parent. This §4 delegate-the-read (compact-JSON return, no full-file load in parent) is the canonical API-surface read pattern for the workflow.
93
87
 
94
88
  **From metadata.json (read in parent — lightweight), also extract:**
95
89
  - `language` — primary programming language
@@ -97,21 +91,21 @@ For each library in the skill inventory, delegate reading to a parallel subagent
97
91
 
98
92
  ### 5. Cross-Reference: Identify Gaps
99
93
 
100
- For each possible library pair NOT already documented in the architecture:
94
+ For each library pair in `skill_inventory.pairs` (from §3) not already documented in the architecture:
101
95
 
102
96
  **Check API compatibility:**
103
97
  - Does Library A export types or data that Library B can consume?
104
98
  - Do both libraries share a compatible protocol or data format?
105
99
  - Are they in the same language or is there a bridge mechanism available?
106
100
 
107
- **Scope routing (from §2b):** Before classifying, check the pair's scope. If the pair is **out-of-scope** (either library is in `{out_of_scope_skills}`), do NOT add it to the gap list even when its APIs are compatible — record it in the informational **Out-of-Scope** bucket instead (a compatible pair that belongs to a different product surface than this architecture). Only **in-scope** pairs proceed to gap classification below.
101
+ **Scope routing (from §2b):** Before classifying, check the pair's scope. If the pair is **out-of-scope** (either library is in `{out_of_scope_skills}`), do not add it to the gap list even when its APIs are compatible — record it in the informational **Out-of-Scope** bucket instead (a compatible pair that belongs to a different product surface than this architecture). Only **in-scope** pairs proceed to gap classification below.
108
102
 
109
103
  **If compatible APIs exist (in-scope pair) but NO architecture mention:**
110
104
  - Classify the gap type (Missing Integration Path, Undocumented Data Flow, or Absent Bridge Layer)
111
105
  - Document the connecting APIs from both skills
112
106
  - Propose a brief architecture section describing the integration
113
107
 
114
- **Apply the citation format from {refinementRulesData}:**
108
+ **Cite each gap in this format:**
115
109
  ```
116
110
  **[GAP]**: {description}
117
111
 
@@ -125,37 +119,14 @@ Suggestion: {proposed architecture section content}
125
119
 
126
120
  **If no compatible APIs:** Skip this pair — not all pairs need to integrate.
127
121
 
128
- ### 6. Display Gap Analysis Results
129
-
130
- "**Pass 1: Gap Analysis — Undocumented Integration Paths**
131
-
132
- **Gaps Found (in-scope):** {count}
133
-
134
- {IF gaps found:}
135
- | # | Library A | Library B | Gap Type | Connecting APIs |
136
- |---|-----------|-----------|----------|-----------------|
137
- | {n} | {lib_a} | {lib_b} | {gap_type} | {brief API description} |
138
-
139
- {For each gap, display the full citation with evidence and suggestion}
140
-
141
- {IF out-of-scope compatible pairs exist (from §2b/§5):}
142
- **Out of scope for this document:** {oos_count} compatible pair(s) involve skills outside this architecture's surface — `{out_of_scope_skills}` — and were NOT counted as gaps. Listed for awareness only:
143
-
144
- | Library A | Library B | Reason |
145
- |-----------|-----------|--------|
146
- | {lib_a} | {lib_b} | out-of-scope — not referenced in this architecture |
147
-
148
- If any of these belongs in this architecture, re-run with `--scope-skills` naming the skills to include.
149
-
150
- {IF no gaps found AND N > 1:}
151
- **No undocumented integration paths detected.** The architecture document covers all compatible in-scope library pairs.
122
+ ### 6. Report Gaps & Store Findings
152
123
 
153
- {IF no gaps found AND N == 1:}
154
- **⚠️ Gap analysis skipped — only 1 skill loaded.** Pairwise integration analysis requires at least 2 skills. If the architecture references multiple libraries, those without a matching skill are invisible to gap analysis. **Recommendation:** Generate skills for all architecture libraries with [CS] or [QS] before running [RA] for comprehensive gap detection.
124
+ Report the in-scope gap count, then list each gap as a row of **# / Library A / Library B / Gap Type / Connecting APIs** followed by its full §5 citation. Two signals are not inferable from the counts and must survive regardless of format:
155
125
 
156
- **Proceeding to issue detection (still produces value with 1 skill)...**"
126
+ - **N == 1 (only one skill loaded):** gap analysis is skipped — pairwise integration analysis needs ≥2 skills, and libraries without a matching skill are invisible to it. Recommend generating skills for all architecture libraries with [CS] or [QS] before re-running [RA], and note issue detection still runs.
127
+ - **Out-of-scope compatible pairs exist (from §2b/§5):** list them separately for awareness only — they were not counted as gaps — and note that re-running with `--scope-skills` (naming the skills to include) pulls any that belong into scope.
157
128
 
158
- Store all **in-scope** gap findings as workflow state for Step 05. To ensure durability across long runs, also append a `<!-- [RA-GAPS] ... -->` comment block to `{forge_data_folder}/ra-state-{project_name}.md` containing the **complete formatted gap findings** (full citation blocks with evidence and suggestions, not just counts) — Step 05 can read this back if context degrades. Record out-of-scope pairs under a separate `<!-- [RA-OUT-OF-SCOPE] ... -->` marker (NOT `[RA-GAPS]`) so Step 05 does not compile them into the refined document — they are informational only. **Do NOT write to `{output_folder}/refined-architecture-{project_name}.md` — that file is created only in step 5.**
129
+ Store the **in-scope** gap findings per the Finding Storage rule (refinement rules), under a `<!-- [RA-GAPS] ... -->` block. Record out-of-scope pairs under a separate `<!-- [RA-OUT-OF-SCOPE] ... -->` marker so Step 05 leaves them out of the refined document — they are informational only.
159
130
 
160
131
  ### 7. Auto-Proceed to Next Step
161
132
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  # Note: `shared/health-check.md` resolves relative to the SKF module root
3
3
  # ({project-root}/_bmad/skf/ when installed, {project-root}/src/ during
4
- # development), NOT relative to this step file.
4
+ # development), not relative to this step file.
5
5
  nextStepFile: 'shared/health-check.md'
6
6
  ---
7
7
 
@@ -23,7 +23,7 @@ Identify capability expansions — library features documented in the generated
23
23
 
24
24
  Use the refinement rules loaded in Step 01 from `{refinementRulesData}`. If not available in context, reload from `{refinementRulesData}`.
25
25
 
26
- Extract: improvement classification (Unused Capability, Cross-Library Synergy, Alternative Pattern), detection method, and citation format.
26
+ Extract: improvement classification (Unused Capability, Cross-Library Synergy, Alternative Pattern) and detection method.
27
27
 
28
28
  ### 2. Build Architecture Usage Map
29
29
 
@@ -39,15 +39,13 @@ This creates a map of `{library} -> {described_usage[]}` for comparison against
39
39
 
40
40
  For each skill in the inventory:
41
41
 
42
- **Load the full API surface from SKILL.md:**
43
- - All exported functions with signatures
44
- - All exported types and interfaces
45
- - All documented capabilities and features
46
- - All protocol support indicators
42
+ **Start from the surfaces already collected.** Reuse `{skill_api_surfaces}` (the compact `{exports, protocols, data_formats}` summaries from Step 02 §4) for exports, types, and protocol support — do not re-read SKILL.md in the parent.
43
+
44
+ **For the fuller capability read** — documented capabilities and features that go beyond §4's exports/protocols/data_formats extraction — delegate to parallel subagents mirroring Step 02 §4 (the canonical delegate-the-read pattern): each subagent reads one SKILL.md and returns compact JSON listing that skill's documented capabilities/features; the parent collects the summaries without loading full SKILL.md content. Reload a file directly only if its summary is unavailable or context has compacted.
47
45
 
48
46
  **Compare against the architecture usage map:**
49
47
  - Which exports does the architecture reference or imply usage of?
50
- - Which exports are NOT referenced in the architecture at all?
48
+ - Which exports are not referenced in the architecture at all?
51
49
 
52
50
  **For each unreferenced capability:**
53
51
  - Evaluate relevance: would this capability strengthen the architecture?
@@ -66,7 +64,7 @@ Examine pairs of skills for complementary capabilities not exploited in the arch
66
64
 
67
65
  ### 5. Document Each Improvement
68
66
 
69
- For each detected improvement, apply the citation format from {refinementRulesData}:
67
+ For each detected improvement, cite it in this format:
70
68
 
71
69
  ```
72
70
  **[IMPROVEMENT]**: {description}
@@ -84,25 +82,11 @@ Suggestion: {how to incorporate this capability into the architecture}
84
82
  - **Medium:** Capabilities that add convenience or efficiency improvements
85
83
  - **Low:** Capabilities that are nice-to-have but not impactful
86
84
 
87
- ### 6. Display Improvement Suggestions
88
-
89
- "**Pass 3: Improvement Detection — Untapped Capabilities**
90
-
91
- **Improvements Found:** {count} ({high_count} high value, {medium_count} medium, {low_count} low)
92
-
93
- {IF improvements found:}
94
- | # | Library | Improvement Type | Value | Summary |
95
- |---|---------|-----------------|-------|---------|
96
- | {n} | {lib} | {type} | {value} | {brief description} |
97
-
98
- {For each improvement, display the full citation with evidence and suggestion}
99
-
100
- {IF no improvements found:}
101
- **No untapped capabilities detected.** The architecture fully leverages the skill API surfaces.
85
+ ### 6. Report Improvements & Store Findings
102
86
 
103
- **Proceeding to compile refined architecture...**"
87
+ Report the improvement count with its high/medium/low value breakdown, then list each improvement as a row of **# / Library / Improvement Type / Value / Summary** followed by its full §5 citation.
104
88
 
105
- Store all improvement findings as workflow state for Step 05. To ensure durability across long runs, also append a `<!-- [RA-IMPROVEMENTS] ... -->` comment block to `{forge_data_folder}/ra-state-{project_name}.md` containing the **complete formatted improvement findings** (full citation blocks with evidence, value ratings, and suggestions — not just counts) — Step 05 can read this back if context degrades. **Do NOT write to `{output_folder}/refined-architecture-{project_name}.md` — that file is created only in step 5.**
89
+ Store the improvement findings per the Finding Storage rule (refinement rules), under a `<!-- [RA-IMPROVEMENTS] ... -->` block (its citations carry the evidence, value rating, and suggestion).
106
90
 
107
91
  ### 7. Auto-Proceed to Next Step
108
92