bmad-module-skill-forge 1.4.1 → 1.5.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 (231) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +0 -8
  3. package/docs/_data/pinned.yaml +1 -1
  4. package/docs/_internal/STABILITY.md +1 -1
  5. package/docs/architecture.md +2 -2
  6. package/docs/examples.md +1 -1
  7. package/docs/workflows.md +5 -5
  8. package/package.json +2 -2
  9. package/src/README.md +1 -1
  10. package/src/knowledge/ccc-bridge.md +12 -12
  11. package/src/knowledge/qmd-registry.md +5 -5
  12. package/src/shared/health-check.md +5 -5
  13. package/src/shared/references/description-guard-protocol.md +100 -0
  14. package/src/shared/references/output-contract-schema.md +1 -1
  15. package/src/shared/scripts/schemas/skf-brief-result-envelope.v1.json +6 -6
  16. package/src/shared/scripts/schemas/skf-setup-result-envelope.v1.json +9 -3
  17. package/src/shared/scripts/schemas/skf-update-result-envelope.v1.json +149 -0
  18. package/src/shared/scripts/schemas/skill-brief.v1.json +22 -2
  19. package/src/shared/scripts/skf-build-change-manifest.py +420 -0
  20. package/src/shared/scripts/skf-check-workspace-drift.py +321 -0
  21. package/src/shared/scripts/skf-compare-file-hashes.py +357 -0
  22. package/src/shared/scripts/skf-description-guard.py +359 -0
  23. package/src/shared/scripts/skf-detect-language.py +2 -2
  24. package/src/shared/scripts/skf-detect-scripts-assets.py +613 -0
  25. package/src/shared/scripts/skf-detect-tools.py +147 -16
  26. package/src/shared/scripts/skf-detect-workspaces.py +1 -1
  27. package/src/shared/scripts/skf-disqualify-candidates.py +576 -0
  28. package/src/shared/scripts/skf-emit-brief-result-envelope.py +3 -3
  29. package/src/shared/scripts/skf-emit-result-envelope.py +93 -9
  30. package/src/shared/scripts/skf-enumerate-stack-skills.py +514 -0
  31. package/src/shared/scripts/skf-forge-tier-rw.py +11 -11
  32. package/src/shared/scripts/skf-hash-content.py +284 -0
  33. package/src/shared/scripts/skf-load-provenance.py +295 -0
  34. package/src/shared/scripts/skf-manifest-ops.py +22 -6
  35. package/src/shared/scripts/skf-merge-ccc-exclusions.py +34 -4
  36. package/src/shared/scripts/skf-pair-intersect.py +250 -0
  37. package/src/shared/scripts/skf-provenance-gap-dispatch.py +433 -0
  38. package/src/shared/scripts/skf-qmd-classify-collections.py +42 -8
  39. package/src/shared/scripts/skf-recommend-scope-type.py +2 -2
  40. package/src/shared/scripts/skf-render-quick-metadata.py +2 -2
  41. package/src/shared/scripts/skf-resolve-authoritative-files.py +504 -0
  42. package/src/shared/scripts/skf-scan-manifests.py +738 -0
  43. package/src/shared/scripts/skf-scan-skill-md-structure.py +375 -0
  44. package/src/shared/scripts/skf-update-active-symlink.py +315 -0
  45. package/src/shared/scripts/skf-validate-brief-inputs.py +5 -5
  46. package/src/shared/scripts/skf-validate-brief-schema.py +348 -0
  47. package/src/shared/scripts/skf-write-skill-brief.py +61 -5
  48. package/src/skf-analyze-source/SKILL.md +69 -16
  49. package/src/skf-analyze-source/assets/skill-brief-schema.md +1 -1
  50. package/src/skf-analyze-source/customize.toml +55 -0
  51. package/src/skf-analyze-source/{steps-c/step-01b-continue.md → references/continue.md} +12 -12
  52. package/src/skf-analyze-source/{steps-c/step-06-generate-briefs.md → references/generate-briefs.md} +29 -10
  53. package/src/skf-analyze-source/{steps-c/step-07-health-check.md → references/health-check.md} +5 -3
  54. package/src/skf-analyze-source/{steps-c/step-03-identify-units.md → references/identify-units.md} +48 -14
  55. package/src/skf-analyze-source/{steps-c/step-01-init.md → references/init.md} +32 -9
  56. package/src/skf-analyze-source/{steps-c/step-04-map-and-detect.md → references/map-and-detect.md} +52 -25
  57. package/src/skf-analyze-source/{steps-c/step-05-recommend.md → references/recommend.md} +15 -8
  58. package/src/skf-analyze-source/{steps-c/step-02-scan-project.md → references/scan-project.md} +16 -10
  59. package/src/skf-analyze-source/references/unit-detection-heuristics.md +2 -0
  60. package/src/skf-analyze-source/templates/analysis-report-template.md +6 -6
  61. package/src/skf-audit-skill/SKILL.md +66 -15
  62. package/src/skf-audit-skill/assets/drift-report-template.md +6 -5
  63. package/src/skf-audit-skill/customize.toml +49 -0
  64. package/src/skf-audit-skill/{steps-c/step-07-health-check.md → references/health-check.md} +5 -3
  65. package/src/skf-audit-skill/{steps-c/step-01-init.md → references/init.md} +63 -19
  66. package/src/skf-audit-skill/{steps-c/step-02-re-index.md → references/re-index.md} +11 -11
  67. package/src/skf-audit-skill/{steps-c/step-06-report.md → references/report.md} +25 -7
  68. package/src/skf-audit-skill/{steps-c/step-04-semantic-diff.md → references/semantic-diff.md} +6 -6
  69. package/src/skf-audit-skill/{steps-c/step-05-severity-classify.md → references/severity-classify.md} +5 -5
  70. package/src/skf-audit-skill/references/severity-rules.md +2 -0
  71. package/src/skf-audit-skill/{steps-c/step-03-structural-diff.md → references/structural-diff.md} +35 -17
  72. package/src/skf-brief-skill/SKILL.md +49 -19
  73. package/src/skf-brief-skill/assets/description-voice-examples.md +1 -1
  74. package/src/skf-brief-skill/assets/skill-brief-schema.md +32 -2
  75. package/src/skf-brief-skill/customize.toml +44 -0
  76. package/src/skf-brief-skill/{steps-c/step-02-analyze-target.md → references/analyze-target.md} +27 -15
  77. package/src/skf-brief-skill/{steps-c/step-04-confirm-brief.md → references/confirm-brief.md} +13 -10
  78. package/src/skf-brief-skill/references/draft-checkpoint.md +4 -4
  79. package/src/skf-brief-skill/{steps-c/step-01-gather-intent.md → references/gather-intent.md} +35 -29
  80. package/src/skf-brief-skill/references/headless-args.md +9 -9
  81. package/src/skf-brief-skill/references/headless-source-authority-detection.md +1 -1
  82. package/src/skf-brief-skill/{steps-c/step-06-health-check.md → references/health-check.md} +4 -2
  83. package/src/skf-brief-skill/references/portfolio-similarity-check.md +2 -2
  84. package/src/skf-brief-skill/references/qmd-collection-registration.md +2 -2
  85. package/src/skf-brief-skill/{steps-c/step-03-scope-definition.md → references/scope-definition.md} +27 -20
  86. package/src/skf-brief-skill/references/version-resolution.md +2 -2
  87. package/src/skf-brief-skill/{steps-c/step-05-write-brief.md → references/write-brief.md} +29 -16
  88. package/src/skf-create-skill/SKILL.md +25 -19
  89. package/src/skf-create-skill/assets/compile-assembly-rules.md +3 -3
  90. package/src/skf-create-skill/assets/skill-sections.md +5 -5
  91. package/src/skf-create-skill/assets/tessl-dismissal-rules.md +11 -11
  92. package/src/skf-create-skill/customize.toml +35 -0
  93. package/src/skf-create-skill/references/authoritative-files-protocol.md +142 -0
  94. package/src/skf-create-skill/{steps-c/step-05-compile.md → references/compile.md} +16 -16
  95. package/src/skf-create-skill/{steps-c/step-03d-component-extraction.md → references/component-extraction.md} +16 -16
  96. package/src/skf-create-skill/{steps-c/step-02-ecosystem-check.md → references/ecosystem-check.md} +4 -4
  97. package/src/skf-create-skill/{steps-c/step-04-enrich.md → references/enrich.md} +3 -3
  98. package/src/skf-create-skill/{steps-c/step-03-extract.md → references/extract.md} +52 -120
  99. package/src/skf-create-skill/references/extraction-patterns.md +10 -8
  100. package/src/skf-create-skill/{steps-c/step-07-generate-artifacts.md → references/generate-artifacts.md} +11 -11
  101. package/src/skf-create-skill/{steps-c/step-09-health-check.md → references/health-check.md} +4 -2
  102. package/src/skf-create-skill/{steps-c/step-01-load-brief.md → references/load-brief.md} +40 -32
  103. package/src/skf-create-skill/{steps-c/step-08-report.md → references/report.md} +8 -8
  104. package/src/skf-create-skill/references/source-resolution-protocols.md +6 -6
  105. package/src/skf-create-skill/{steps-c/sub/step-02b-ccc-discover.md → references/sub/ccc-discover.md} +5 -5
  106. package/src/skf-create-skill/{steps-c/sub/step-03c-fetch-docs.md → references/sub/fetch-docs.md} +28 -12
  107. package/src/skf-create-skill/{steps-c/sub/step-03b-fetch-temporal.md → references/sub/fetch-temporal.md} +81 -50
  108. package/src/skf-create-skill/{steps-c/step-06-validate.md → references/validate.md} +48 -28
  109. package/src/skf-create-stack-skill/SKILL.md +76 -17
  110. package/src/skf-create-stack-skill/assets/provenance-map-schema.md +102 -0
  111. package/src/skf-create-stack-skill/assets/stack-skill-template.md +1 -1
  112. package/src/skf-create-stack-skill/customize.toml +46 -0
  113. package/src/skf-create-stack-skill/{steps-c/step-06-compile-stack.md → references/compile-stack.md} +6 -5
  114. package/src/skf-create-stack-skill/references/compose-mode-rules.md +3 -1
  115. package/src/skf-create-stack-skill/{steps-c/step-05-detect-integrations.md → references/detect-integrations.md} +37 -11
  116. package/src/skf-create-stack-skill/{steps-c/step-02-detect-manifests.md → references/detect-manifests.md} +32 -28
  117. package/src/skf-create-stack-skill/{steps-c/step-07-generate-output.md → references/generate-output.md} +11 -85
  118. package/src/skf-create-stack-skill/{steps-c/step-10-health-check.md → references/health-check.md} +4 -2
  119. package/src/skf-create-stack-skill/{steps-c/step-01-init.md → references/init.md} +70 -4
  120. package/src/skf-create-stack-skill/references/integration-patterns.md +2 -0
  121. package/src/skf-create-stack-skill/references/manifest-patterns.md +2 -0
  122. package/src/skf-create-stack-skill/{steps-c/step-04-parallel-extract.md → references/parallel-extract.md} +44 -17
  123. package/src/skf-create-stack-skill/{steps-c/step-03-rank-and-confirm.md → references/rank-and-confirm.md} +5 -4
  124. package/src/skf-create-stack-skill/{steps-c/step-09-report.md → references/report.md} +3 -3
  125. package/src/skf-create-stack-skill/{steps-c/step-08-validate.md → references/validate.md} +6 -6
  126. package/src/skf-drop-skill/SKILL.md +84 -12
  127. package/src/skf-drop-skill/customize.toml +57 -0
  128. package/src/skf-drop-skill/{steps-c/step-02-execute.md → references/execute.md} +49 -34
  129. package/src/skf-drop-skill/{steps-c/step-04-health-check.md → references/health-check.md} +6 -4
  130. package/src/skf-drop-skill/{steps-c/step-03-report.md → references/report.md} +13 -5
  131. package/src/skf-drop-skill/{steps-c/step-01-select.md → references/select.md} +63 -15
  132. package/src/skf-export-skill/SKILL.md +85 -16
  133. package/src/skf-export-skill/assets/managed-section-format.md +3 -3
  134. package/src/skf-export-skill/assets/snippet-format.md +2 -2
  135. package/src/skf-export-skill/customize.toml +49 -0
  136. package/src/skf-export-skill/{steps-c/step-03-generate-snippet.md → references/generate-snippet.md} +11 -11
  137. package/src/skf-export-skill/{steps-c/step-07-health-check.md → references/health-check.md} +6 -4
  138. package/src/skf-export-skill/{steps-c/step-01-load-skill.md → references/load-skill.md} +11 -49
  139. package/src/skf-export-skill/references/manifest-rebuild.md +68 -0
  140. package/src/skf-export-skill/references/multi-skill-mode.md +38 -0
  141. package/src/skf-export-skill/references/orphan-context-detection.md +75 -0
  142. package/src/skf-export-skill/references/orphan-row-detection.md +102 -0
  143. package/src/skf-export-skill/{steps-c/step-02-package.md → references/package.md} +7 -7
  144. package/src/skf-export-skill/references/preflight-snippet-root-probe.md +79 -0
  145. package/src/skf-export-skill/{steps-c/step-06-summary.md → references/summary.md} +23 -11
  146. package/src/skf-export-skill/{steps-c/step-05-token-report.md → references/token-report.md} +5 -5
  147. package/src/skf-export-skill/{steps-c/step-04-update-context.md → references/update-context.md} +109 -113
  148. package/src/skf-quick-skill/SKILL.md +63 -123
  149. package/src/skf-quick-skill/customize.toml +44 -0
  150. package/src/skf-quick-skill/references/batch-mode.md +102 -0
  151. package/src/skf-quick-skill/{steps-c/step-04-compile.md → references/compile.md} +10 -10
  152. package/src/skf-quick-skill/{steps-c/step-02-ecosystem-check.md → references/ecosystem-check.md} +5 -5
  153. package/src/skf-quick-skill/{steps-c/step-06-finalize.md → references/finalize.md} +7 -7
  154. package/src/skf-quick-skill/{steps-c/step-07-health-check.md → references/health-check.md} +3 -3
  155. package/src/skf-quick-skill/{steps-c/step-03-quick-extract.md → references/quick-extract.md} +5 -5
  156. package/src/skf-quick-skill/references/registry-resolution.md +2 -0
  157. package/src/skf-quick-skill/{steps-c/step-01-resolve-target.md → references/resolve-target.md} +14 -10
  158. package/src/skf-quick-skill/{steps-c/step-05-write-and-validate.md → references/write-and-validate.md} +4 -4
  159. package/src/skf-refine-architecture/SKILL.md +86 -16
  160. package/src/skf-refine-architecture/customize.toml +49 -0
  161. package/src/skf-refine-architecture/{steps-c/step-05-compile.md → references/compile.md} +4 -4
  162. package/src/skf-refine-architecture/{steps-c/step-02-gap-analysis.md → references/gap-analysis.md} +5 -5
  163. package/src/skf-refine-architecture/{steps-c/step-07-health-check.md → references/health-check.md} +6 -4
  164. package/src/skf-refine-architecture/{steps-c/step-04-improvements.md → references/improvements.md} +5 -5
  165. package/src/skf-refine-architecture/references/init.md +144 -0
  166. package/src/skf-refine-architecture/{steps-c/step-03-issue-detection.md → references/issue-detection.md} +5 -5
  167. package/src/skf-refine-architecture/references/refinement-rules.md +2 -0
  168. package/src/skf-refine-architecture/{steps-c/step-06-report.md → references/report.md} +14 -5
  169. package/src/skf-rename-skill/SKILL.md +82 -12
  170. package/src/skf-rename-skill/customize.toml +52 -0
  171. package/src/skf-rename-skill/{steps-c/step-02-execute.md → references/execute.md} +94 -99
  172. package/src/skf-rename-skill/references/health-check.md +30 -0
  173. package/src/skf-rename-skill/references/rebuild-context.md +110 -0
  174. package/src/skf-rename-skill/{steps-c/step-03-report.md → references/report.md} +13 -5
  175. package/src/skf-rename-skill/{steps-c/step-01-select.md → references/select.md} +59 -20
  176. package/src/skf-setup/SKILL.md +35 -35
  177. package/src/skf-setup/customize.toml +33 -0
  178. package/src/skf-setup/{steps-c/step-03-auto-index.md → references/auto-index.md} +10 -18
  179. package/src/skf-setup/{steps-c/step-01b-ccc-index.md → references/ccc-index.md} +16 -31
  180. package/src/skf-setup/{steps-c/step-01-detect-and-tier.md → references/detect-and-tier.md} +23 -10
  181. package/src/skf-setup/{steps-c/step-05-health-check.md → references/health-check.md} +1 -1
  182. package/src/skf-setup/{steps-c/step-04-report.md → references/report.md} +21 -19
  183. package/src/skf-setup/references/tier-rules.md +1 -1
  184. package/src/skf-setup/{steps-c/step-02-write-config.md → references/write-config.md} +14 -13
  185. package/src/skf-test-skill/SKILL.md +77 -15
  186. package/src/skf-test-skill/customize.toml +54 -0
  187. package/src/skf-test-skill/{steps-c/step-04-coherence-check.md → references/coherence-check.md} +37 -73
  188. package/src/skf-test-skill/{steps-c/step-03-coverage-check.md → references/coverage-check.md} +16 -39
  189. package/src/skf-test-skill/{steps-c/step-02-detect-mode.md → references/detect-mode.md} +4 -26
  190. package/src/skf-test-skill/{steps-c/step-04b-external-validators.md → references/external-validators.md} +6 -28
  191. package/src/skf-test-skill/references/health-check.md +14 -0
  192. package/src/skf-test-skill/{steps-c/step-01-init.md → references/init.md} +21 -37
  193. package/src/skf-test-skill/references/migration-section-rules.md +4 -2
  194. package/src/skf-test-skill/{steps-c/step-06-report.md → references/report.md} +41 -51
  195. package/src/skf-test-skill/{steps-c/step-05-score.md → references/score.md} +26 -43
  196. package/src/skf-test-skill/references/scoring-rules.md +8 -6
  197. package/src/skf-test-skill/references/source-access-protocol.md +7 -5
  198. package/src/skf-test-skill/scripts/compute-score.py +88 -17
  199. package/src/skf-test-skill/templates/test-report-template.md +13 -13
  200. package/src/skf-update-skill/SKILL.md +23 -14
  201. package/src/skf-update-skill/customize.toml +44 -0
  202. package/src/skf-update-skill/{steps-c/step-02-detect-changes.md → references/detect-changes.md} +176 -68
  203. package/src/skf-update-skill/references/health-check.md +32 -0
  204. package/src/skf-update-skill/{steps-c/step-01-init.md → references/init.md} +56 -8
  205. package/src/skf-update-skill/references/manual-section-rules.md +4 -0
  206. package/src/skf-update-skill/references/merge-conflict-rules.md +4 -0
  207. package/src/skf-update-skill/{steps-c/step-04-merge.md → references/merge.md} +8 -8
  208. package/src/skf-update-skill/{steps-c/step-03-re-extract.md → references/re-extract.md} +53 -44
  209. package/src/skf-update-skill/references/remote-source-resolution.md +5 -1
  210. package/src/skf-update-skill/references/report.md +214 -0
  211. package/src/skf-update-skill/{steps-c/step-05-validate.md → references/validate.md} +5 -5
  212. package/src/skf-update-skill/{steps-c/step-06-write.md → references/write.md} +73 -51
  213. package/src/skf-verify-stack/SKILL.md +89 -17
  214. package/src/skf-verify-stack/assets/feasibility-report-template.md +4 -4
  215. package/src/skf-verify-stack/customize.toml +50 -0
  216. package/src/skf-verify-stack/references/coverage-patterns.md +2 -2
  217. package/src/skf-verify-stack/{steps-c/step-02-coverage.md → references/coverage.md} +13 -9
  218. package/src/skf-verify-stack/{steps-c/step-07-health-check.md → references/health-check.md} +7 -5
  219. package/src/skf-verify-stack/references/init.md +170 -0
  220. package/src/skf-verify-stack/references/integration-verification-rules.md +1 -1
  221. package/src/skf-verify-stack/{steps-c/step-03-integrations.md → references/integrations.md} +18 -14
  222. package/src/skf-verify-stack/{steps-c/step-06-report.md → references/report.md} +27 -42
  223. package/src/skf-verify-stack/{steps-c/step-04-requirements.md → references/requirements.md} +13 -9
  224. package/src/skf-verify-stack/{steps-c/step-05-synthesize.md → references/synthesize.md} +14 -10
  225. package/tools/validate-docs-drift.js +1 -1
  226. package/src/skf-refine-architecture/steps-c/step-01-init.md +0 -136
  227. package/src/skf-rename-skill/steps-c/step-04-health-check.md +0 -22
  228. package/src/skf-test-skill/steps-c/step-07-health-check.md +0 -25
  229. package/src/skf-update-skill/steps-c/step-07-report.md +0 -148
  230. package/src/skf-update-skill/steps-c/step-08-health-check.md +0 -22
  231. package/src/skf-verify-stack/steps-c/step-01-init.md +0 -178
@@ -1,13 +1,13 @@
1
1
  ---
2
- nextStepFile: './step-04-compile.md'
2
+ nextStepFile: 'compile.md'
3
3
  publicApiExtractorProbeOrder:
4
4
  - '{project-root}/_bmad/skf/shared/scripts/skf-extract-public-api.py'
5
5
  - '{project-root}/src/shared/scripts/skf-extract-public-api.py'
6
6
  ---
7
7
 
8
- # Step 3: Quick Extract
8
+ <!-- Config: communicate in {communication_language}. -->
9
9
 
10
- Communicate with the user in `{communication_language}`.
10
+ # Step 3: Quick Extract
11
11
 
12
12
  ## STEP GOAL:
13
13
 
@@ -21,7 +21,7 @@ To read the resolved GitHub repository source and extract the public API surface
21
21
 
22
22
  ## MANDATORY SEQUENCE
23
23
 
24
- **Ref-aware source reading:** When `source_ref` is set from tag resolution (see step-01), append `?ref={source_ref}` to all GitHub API content and tree requests (e.g., `gh api repos/{owner}/{repo}/contents/{path}?ref={source_ref}`) to read from the tagged version. When using web browsing, use the tagged URL format (e.g., `github.com/{owner}/{repo}/blob/{source_ref}/{path}`). This ensures extraction reads from the same source version resolved during tag resolution.
24
+ **Ref-aware source reading:** When `source_ref` is set from tag resolution (see step 1), append `?ref={source_ref}` to all GitHub API content and tree requests (e.g., `gh api repos/{owner}/{repo}/contents/{path}?ref={source_ref}`) to read from the tagged version. When using web browsing, use the tagged URL format (e.g., `github.com/{owner}/{repo}/blob/{source_ref}/{path}`). This ensures extraction reads from the same source version resolved during tag resolution.
25
25
 
26
26
  **Parallel-fetch directive:** §1 (README), §2 (manifest), and §3 (entry-point exports) read independent files from the same `?ref={source_ref}` and are safe to issue as one batched tool-call message rather than three sequential round trips. For multi-module Maven (`<modules>`) and multi-project Gradle (`include(...)`) builds, also fetch all submodule `pom.xml` / `build.gradle[.kts]` files in parallel rather than serially per module — N module fetches collapse to O(1) wall-clock time.
27
27
 
@@ -144,7 +144,7 @@ Common causes:
144
144
 
145
145
  Select: [R] Retry with new hints · [P] Proceed anyway (low-confidence skill) · [A] Abort"
146
146
 
147
- - **IF R** — prompt for new `scope_hint` ("New scope hint (e.g. `src/server/`):") and optional new `language_hint` ("New language hint (or empty to keep `{language}`):"). Update the extraction context with the new hints, then **re-execute step-03 from §1** with the new values. Discards the prior empty inventory.
147
+ - **IF R** — prompt for new `scope_hint` ("New scope hint (e.g. `src/server/`):") and optional new `language_hint` ("New language hint (or empty to keep `{language}`):"). Update the extraction context with the new hints, then **re-execute step 3 from §1** with the new values. Discards the prior empty inventory.
148
148
  - **IF P** — log "user accepted zero-exports outcome" and proceed to §5. The compiled skill will be README-content-only with confidence `low`. Record `zero_exports_rescue: "user-accepted"` in the inventory so the result contract summary surfaces it.
149
149
  - **IF A** — HARD HALT with **exit code 3 (resolution-failure)**: "Aborted. Run `/skf-create-skill` from a brief if you want a guided extraction with provenance tracking." Before exiting, emit the error result contract per SKILL.md "Result Contract on HARD HALT" (`phase: "quick-extract"`, `error.code: "resolution-failure"`, `error.details: {exports_found: 0, description_empty: true, language: "{language}", scope: "{scope_hint or 'entire repo'}"}`, `skill_package: null`).
150
150
 
@@ -1,3 +1,5 @@
1
+ <!-- Config: communicate in {communication_language}. -->
2
+
1
3
  # Registry Resolution Patterns
2
4
 
3
5
  ## Package-to-Repo Resolution
@@ -1,14 +1,14 @@
1
1
  ---
2
- nextStepFile: './step-02-ecosystem-check.md'
2
+ nextStepFile: 'ecosystem-check.md'
3
3
  registryResolutionData: 'references/registry-resolution.md'
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
7
  ---
8
8
 
9
- # Step 1: Resolve Target
9
+ <!-- Config: communicate in {communication_language}. -->
10
10
 
11
- Communicate with the user in `{communication_language}`.
11
+ # Step 1: Resolve Target
12
12
 
13
13
  ## STEP GOAL:
14
14
 
@@ -23,7 +23,7 @@ To accept a GitHub URL or package name from the user, resolve it to a GitHub rep
23
23
 
24
24
  ### 1. Accept User Input
25
25
 
26
- **Batch mode:** if `--batch` is active (see SKILL.md "Batch Mode"), the current target was already resolved by On Activation step 4 from the next batch line and placed into the workflow context as `target`, with optional `language_hint` and `scope_hint` per-line modifiers. Skip the prompt below — emit `{"batch":<n>,"target":"<target>","status":"start"}` to stderr and proceed directly to §1b with the batch-supplied values.
26
+ **Batch mode:** if `--batch` is active (see SKILL.md "Batch Mode"), the current target was already resolved by On Activation step 5 from the next batch line and placed into the workflow context as `target`, with optional `language_hint` and `scope_hint` per-line modifiers. Skip the prompt below — emit `{"batch":<n>,"target":"<target>","status":"start"}` to stderr and proceed directly to §1b with the batch-supplied values.
27
27
 
28
28
  **Single-target mode** (default):
29
29
 
@@ -37,9 +37,13 @@ Examples: `cocoindex`, `@tanstack/query`, `https://github.com/tursodatabase/limb
37
37
 
38
38
  **Optional:**
39
39
  - **Language hint:** (if the repo is multi-language)
40
- - **Scope hint:** (specific directories to focus on)"
40
+ - **Scope hint:** (specific directories to focus on)
41
+
42
+ Or type `cancel` / `exit` / `:q` / `[X]` to leave without writing anything."
43
+
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.
41
45
 
42
- Wait for user input. **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."
46
+ **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."
43
47
 
44
48
  ### 1b. Parse Version Targeting
45
49
 
@@ -107,9 +111,9 @@ In interactive mode, wait for corrected input and loop back to step 2. In headle
107
111
 
108
112
  ### 3a. Verify Target Version Tag (when applicable)
109
113
 
110
- Skip this section if `target_version` is null (auto-detect path — version comes from manifest read in step-03).
114
+ Skip this section if `target_version` is null (auto-detect path — version comes from manifest read in step 3).
111
115
 
112
- When the user explicitly supplied `@version` in §1b, verify the tag exists in the resolved repo before extraction. Otherwise step-03 silently reads from the default branch while metadata records the requested version — a quiet provenance bug where the SKILL.md claims version 0.5.0 but the exports actually came from main.
116
+ When the user explicitly supplied `@version` in §1b, verify the tag exists in the resolved repo before extraction. Otherwise step 3 silently reads from the default branch while metadata records the requested version — a quiet provenance bug where the SKILL.md claims version 0.5.0 but the exports actually came from main.
113
117
 
114
118
  Probe both with-and-without v-prefix (the v-prefix is conventional but not universal across ecosystems):
115
119
 
@@ -148,13 +152,13 @@ Determine primary language from:
148
152
 
149
153
  Collect every match into `detected_languages`.
150
154
 
151
- 3. **Single-language case** (`len(detected_languages) <= 1`) — set `language` to the detected value (or HALT in step-01 §3 if zero matches).
155
+ 3. **Single-language case** (`len(detected_languages) <= 1`) — set `language` to the detected value (or HALT in step 1 §3 if zero matches).
152
156
 
153
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.
154
158
 
155
159
  "**`{repo_name}` has manifests for multiple languages:** {detected_languages}.
156
160
 
157
- 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-01 §1.
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.
158
162
 
159
163
  Select: [C] Continue with `{first_match}` · [A] Abort"
160
164
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- nextStepFile: './step-06-finalize.md'
2
+ nextStepFile: 'finalize.md'
3
3
  frontmatterValidatorProbeOrder:
4
4
  - '{project-root}/_bmad/skf/shared/scripts/skf-validate-frontmatter.py'
5
5
  - '{project-root}/src/shared/scripts/skf-validate-frontmatter.py'
@@ -8,13 +8,13 @@ outputValidatorProbeOrder:
8
8
  - '{project-root}/src/shared/scripts/skf-validate-output.py'
9
9
  ---
10
10
 
11
- # Step 5: Write & Validate
11
+ <!-- Config: communicate in {communication_language}. Generated SKILL.md text in {document_output_language}. -->
12
12
 
13
- Communicate with the user in `{communication_language}`. Validation reports are user-facing — render their narrative content in `{document_output_language}`.
13
+ # Step 5: Write & Validate
14
14
 
15
15
  ## STEP GOAL:
16
16
 
17
- To write the compiled SKILL.md, context-snippet.md, and metadata.json to the versioned skill package, then validate them on disk against the agentskills.io specification at community tier. Writing happens here (before step-06 finalization) because `skill-check` is a file-based CLI — it reads artifacts from disk — so the files must exist before validation runs. Report any gaps or issues. Validation is advisory — issues are reported but do not block the workflow.
17
+ To write the compiled SKILL.md, context-snippet.md, and metadata.json to the versioned skill package, then validate them on disk against the agentskills.io specification at community tier. Writing happens here (before step 6 finalization) because `skill-check` is a file-based CLI — it reads artifacts from disk — so the files must exist before validation runs. Report any gaps or issues. Validation is advisory — issues are reported but do not block the workflow.
18
18
 
19
19
  ## Rules
20
20
 
@@ -9,6 +9,14 @@ description: Improve architecture doc using verified skill data and VS feasibili
9
9
 
10
10
  Takes an original architecture document + generated skills + optional VS feasibility report, and produces a refined architecture with gaps filled, issues flagged, and improvements suggested — all backed by specific API evidence from the generated skills. This workflow enhances the original architecture — it never deletes original content, only adds annotations, subsections, and suggestions.
11
11
 
12
+ ## Conventions
13
+
14
+ - Bare paths (e.g. `references/<name>.md`) resolve from the skill root.
15
+ - `references/` holds prompt content carved out of SKILL.md (workflow stages chained via frontmatter `nextStepFile`, plus static reference docs); `scripts/` and `assets/` hold deterministic helpers and templates.
16
+ - `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives, if present).
17
+ - `{project-root}`-prefixed paths resolve from the project working directory.
18
+ - `{skill-name}` resolves to the skill directory's basename.
19
+
12
20
  ## Role
13
21
 
14
22
  You are an architecture refinement analyst operating in Ferris Architect mode. You bring expertise in API surface analysis, integration gap detection, and evidence-backed architecture improvement, while the user brings their architecture vision and generated skills. Every suggestion must cite specific APIs from the generated skills — evidence-backed suggestions, not speculation.
@@ -18,40 +26,102 @@ You are an architecture refinement analyst operating in Ferris Architect mode. Y
18
26
  These rules apply to every step in this workflow:
19
27
 
20
28
  - Never speculate — every gap, issue, or improvement must cite specific APIs, types, or function signatures from the generated skills
21
- - Read each step file completely before taking any action
22
- - Follow the mandatory sequence in each step exactly — do not skip, reorder, or optimize
23
29
  - Only load one step file at a time — never preload future steps
24
30
  - If any instruction references a subprocess or tool you lack, achieve the outcome in your main context thread
25
31
  - Always communicate in `{communication_language}`
32
+ - At any interactive prompt, the inputs `cancel`, `exit`, `[X]`, `q`, or `:q` exit cleanly with exit code 6 (`halt_reason: "user-cancelled"`)
26
33
  - If `{headless_mode}` is true, auto-proceed through confirmation gates with their default action and log each auto-decision
27
34
 
28
35
  ## Stages
29
36
 
30
37
  | # | Step | File | Auto-proceed |
31
38
  |---|------|------|--------------|
32
- | 1 | Initialize & Load Inputs | steps-c/step-01-init.md | No (confirm) |
33
- | 2 | Gap Analysis | steps-c/step-02-gap-analysis.md | Yes |
34
- | 3 | Issue Detection | steps-c/step-03-issue-detection.md | Yes |
35
- | 4 | Improvements | steps-c/step-04-improvements.md | Yes |
36
- | 5 | Compile Refined Architecture | steps-c/step-05-compile.md | No (review) |
37
- | 6 | Report | steps-c/step-06-report.md | Yes |
38
- | 7 | Workflow Health Check | steps-c/step-07-health-check.md | Yes |
39
+ | 1 | Initialize & Load Inputs | references/init.md | No (confirm) |
40
+ | 2 | Gap Analysis | references/gap-analysis.md | Yes |
41
+ | 3 | Issue Detection | references/issue-detection.md | Yes |
42
+ | 4 | Improvements | references/improvements.md | Yes |
43
+ | 5 | Compile Refined Architecture | references/compile.md | No (review) |
44
+ | 6 | Report | references/report.md | Yes |
45
+ | 7 | Workflow Health Check | references/health-check.md | Yes |
39
46
 
40
47
  ## Invocation Contract
41
48
 
42
49
  | Aspect | Detail |
43
50
  |--------|--------|
44
- | **Inputs** | architecture_doc_path [required] |
45
- | **Gates** | step-01: Input Gate [use args] | step-05: Review Gate [C] |
46
- | **Outputs** | refined-architecture-{project_name}.md |
47
- | **Headless** | All gates auto-resolve with default action when `{headless_mode}` is true |
51
+ | **Inputs** | architecture_doc_path [required], vs_report_path [optional] |
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) |
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` |
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
+ | **Exit codes** | See "Exit Codes" below |
57
+
58
+ ## Exit Codes
59
+
60
+ Every HARD HALT in this workflow exits with a stable code so headless automators can branch on the failure class without grepping message text:
61
+
62
+ | Code | Meaning | Raised by |
63
+ | ---- | -------------------- | -------------------------------------------------------------------------------------------- |
64
+ | 0 | success | step 7 (terminal) |
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) |
68
+ | 5 | state-conflict | step 1 §3 (no skills found — refinement requires ≥1 skill) |
69
+ | 6 | user-cancelled | step 1 §1 prompt cancelled; any prompt that accepted `cancel`/`exit`/`:q`; step 5 review gate `[X]` |
70
+ | 7 | inventory-unreliable | step 1 §2 (>20% skill-inventory warnings exceed budget) |
71
+
72
+ ## Result Contract (Headless)
73
+
74
+ When `{headless_mode}` is true, step 6 emits a single-line JSON envelope on **stdout** before chaining to step 7, and every HARD HALT emits the same envelope shape on **stderr** with `status: "error"`:
75
+
76
+ ```
77
+ SKF_REFINE_ARCHITECTURE_RESULT_JSON: {"status":"success|error","refined_path":"…|null","gap_count":0,"issue_count":0,"improvement_count":0,"exit_code":0,"halt_reason":null}
78
+ ```
79
+
80
+ `status` is `"success"` on the terminal happy path, `"error"` on any HALT. `halt_reason` is one of: `null` (success), `"input-missing"`, `"input-invalid"`, `"insufficient-skills"`, `"output-folder-unconfigured"`, `"forge-folder-unconfigured"`, `"inventory-unreliable"`, `"write-failed"`, `"user-cancelled"`. `exit_code` matches the table above.
48
81
 
49
82
  ## On Activation
50
83
 
51
84
  1. Load config from `{project-root}/_bmad/skf/config.yaml` and resolve:
52
85
  - `project_name`, `user_name`, `communication_language`, `document_output_language`
53
- - `skills_output_folder`, `forge_data_folder`, `output_folder`
86
+ - `skills_output_folder`, `forge_data_folder`, `output_folder`, `sidecar_path`
87
+
88
+ 2. **Compute run-scoped variables:**
89
+ - `timestamp` ← UTC `YYYYMMDD-HHmmss` captured at activation time. Fixed for the entire workflow run; report.md reuses this when writing the result contract.
90
+
91
+ 3. **Resolve `{headless_mode}`**: true if `--headless` or `-H` was passed as an argument, or if `headless_mode: true` in `{sidecar_path}/preferences.yaml`. Default: false.
92
+
93
+ 4. **Resolve workflow customization.** Run:
94
+
95
+ ```bash
96
+ python3 {project-root}/_bmad/scripts/resolve_customization.py \
97
+ --skill {skill-root} --key workflow
98
+ ```
99
+
100
+ The script merges the three customization layers per `bmad-customize`'s structural merge rules (scalars override, arrays append):
101
+
102
+ - `{skill-root}/customize.toml` — bundled defaults
103
+ - `_bmad/custom/<skill-name>.toml` under `{project-root}` — team overrides (committed)
104
+ - `_bmad/custom/<skill-name>.user.toml` under `{project-root}` — personal overrides (gitignored)
105
+
106
+ If the script fails or is missing, fall back to reading `{skill-root}/customize.toml` directly — the bundled defaults are an empty string for each path scalar.
107
+
108
+ Apply the path-scalar fallback now so stage files don't have to repeat the conditional logic. For each scalar, if the merged value is empty or absent, use the bundled default:
109
+
110
+ - `{refinementRulesPath}` ← `workflow.refinement_rules_path` if non-empty, else `references/refinement-rules.md`
111
+ - `{outputFolderPath}` ← `workflow.output_folder_path` if non-empty, else `{output_folder}`
112
+
113
+ Stash both as workflow-context variables. Stage files reference them directly — no conditional at the usage site.
114
+
115
+ 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:
116
+
117
+ ```bash
118
+ for dir in "{outputFolderPath}" "{forge_data_folder}"; do
119
+ mkdir -p "$dir" && \
120
+ printf 'probe' > "$dir/.skf-write-probe" && \
121
+ rm "$dir/.skf-write-probe"
122
+ done
123
+ ```
54
124
 
55
- 2. **Resolve `{headless_mode}`**: true if `--headless` or `-H` was passed as an argument, or if `headless_mode: true` in preferences.yaml. Default: false.
125
+ 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`.
56
126
 
57
- 3. Load, read the full file, and then execute `./steps-c/step-01-init.md` to begin the workflow.
127
+ 6. Load, read the full file, and then execute `references/init.md` to begin the workflow.
@@ -0,0 +1,49 @@
1
+ # DO NOT EDIT -- overwritten on every update.
2
+ #
3
+ # Workflow customization surface for skf-refine-architecture.
4
+
5
+ [workflow]
6
+
7
+ # --- Configurable below. Overrides merge per BMad structural rules: ---
8
+ # scalars: override wins • arrays (persistent_facts, activation_steps_*): append
9
+ # arrays-of-tables with `code`/`id`: replace matching items, append new ones.
10
+
11
+ # Steps to run before the standard activation (uv probe, config load).
12
+ # Overrides append. Use for org-wide pre-flight checks (auth, network,
13
+ # compliance) that must precede architecture refinement work.
14
+
15
+ activation_steps_prepend = []
16
+
17
+ # Steps to run after activation but before the first stage executes.
18
+ # Overrides append. Use for context loads or banner customization that
19
+ # should run once activation completes successfully.
20
+
21
+ activation_steps_append = []
22
+
23
+ # Persistent facts the workflow keeps in mind for the whole run
24
+ # (refinement standards, evidence-citation rules, house-style preservation
25
+ # guardrails). Overrides append.
26
+ #
27
+ # Each entry is either:
28
+ # - a literal sentence, e.g. "Refinements must cite specific API signatures, never speculate."
29
+ # - a file reference prefixed with `file:`, e.g.
30
+ # "file:{project-root}/docs/refine-policy.md" (globs supported; file
31
+ # contents are loaded and treated as facts).
32
+
33
+ persistent_facts = [
34
+ "file:{project-root}/**/project-context.md",
35
+ ]
36
+
37
+ # --- Optional asset overrides ---
38
+ #
39
+ # Lift the canonical refinement-rules path so orgs can substitute house-style
40
+ # rules (e.g. add domain-specific gap categories) without forking the skill.
41
+ # Empty string = use the bundled default.
42
+
43
+ refinement_rules_path = ""
44
+
45
+ # Override the destination directory for the refined architecture document.
46
+ # Empty = use {output_folder} from config.yaml. Useful for orgs that want
47
+ # refined-architecture artifacts to land under a curated docs tree.
48
+
49
+ output_folder_path = ""
@@ -1,8 +1,10 @@
1
1
  ---
2
- nextStepFile: './step-06-report.md'
3
- outputFile: '{output_folder}/refined-architecture-{project_name}.md'
2
+ nextStepFile: 'report.md'
3
+ outputFile: '{outputFolderPath}/refined-architecture-{project_name}.md'
4
4
  ---
5
5
 
6
+ <!-- Config: communicate in {communication_language}. Compile the refined architecture document in {document_output_language}. -->
7
+
6
8
  # Step 5: Compile Refined Architecture
7
9
 
8
10
  ## STEP GOAL:
@@ -17,8 +19,6 @@ Produce the refined architecture document by starting with the original as a bas
17
19
 
18
20
  ## MANDATORY SEQUENCE
19
21
 
20
- **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
21
-
22
22
  ### 1. Prepare the Original as Base
23
23
 
24
24
  Load the complete original architecture document.
@@ -1,8 +1,10 @@
1
1
  ---
2
- nextStepFile: './step-03-issue-detection.md'
3
- refinementRulesData: 'references/refinement-rules.md'
2
+ nextStepFile: 'issue-detection.md'
3
+ refinementRulesData: '{refinementRulesPath}'
4
4
  ---
5
5
 
6
+ <!-- Config: communicate in {communication_language}. Append gap-analysis findings to the RA state file in {document_output_language}. -->
7
+
6
8
  # Step 2: Gap Analysis
7
9
 
8
10
  ## STEP GOAL:
@@ -16,8 +18,6 @@ Find undocumented integration paths — library pairs that have compatible APIs
16
18
 
17
19
  ## MANDATORY SEQUENCE
18
20
 
19
- **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
20
-
21
21
  ### 1. Reference Refinement Rules
22
22
 
23
23
  Use the refinement rules loaded in Step 01 from `{refinementRulesData}`. If not available in context, reload from `{refinementRulesData}`.
@@ -129,7 +129,7 @@ Suggestion: {proposed architecture section content}
129
129
 
130
130
  **Proceeding to issue detection (still produces value with 1 skill)...**"
131
131
 
132
- Store all 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. **Do NOT write to `{output_folder}/refined-architecture-{project_name}.md` — that file is created only in step-05.**
132
+ Store all 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. **Do NOT write to `{output_folder}/refined-architecture-{project_name}.md` — that file is created only in step 5.**
133
133
 
134
134
  ### 7. Auto-Proceed to Next Step
135
135
 
@@ -1,10 +1,12 @@
1
1
  ---
2
- # `shared/health-check.md` resolves relative to the SKF module root
3
- # (`_bmad/skf/` when installed, `src/` during development), NOT relative
4
- # to this step file.
2
+ # Note: `shared/health-check.md` resolves relative to the SKF module root
3
+ # ({project-root}/_bmad/skf/ when installed, {project-root}/src/ during
4
+ # development), NOT relative to this step file.
5
5
  nextStepFile: 'shared/health-check.md'
6
6
  ---
7
7
 
8
+ <!-- Config: communicate in {communication_language}. -->
9
+
8
10
  # Step 7: Workflow Health Check
9
11
 
10
12
  ## STEP GOAL:
@@ -13,7 +15,7 @@ Chain to the shared workflow self-improvement health check at `{nextStepFile}`.
13
15
 
14
16
  ## Rules
15
17
 
16
- - No user-facing reports, file writes, or result contracts in this step — those belong in step-06
18
+ - No user-facing reports, file writes, or result contracts in this step — those belong in step 6
17
19
  - Delegate directly to `{nextStepFile}` with no additional commentary
18
20
  - Do not attempt any other action between loading this step and executing `{nextStepFile}`
19
21
 
@@ -1,8 +1,10 @@
1
1
  ---
2
- nextStepFile: './step-05-compile.md'
3
- refinementRulesData: 'references/refinement-rules.md'
2
+ nextStepFile: 'compile.md'
3
+ refinementRulesData: '{refinementRulesPath}'
4
4
  ---
5
5
 
6
+ <!-- Config: communicate in {communication_language}. Append improvement findings to the RA state file in {document_output_language}. -->
7
+
6
8
  # Step 4: Improvement Detection
7
9
 
8
10
  ## STEP GOAL:
@@ -17,8 +19,6 @@ Identify capability expansions — library features documented in the generated
17
19
 
18
20
  ## MANDATORY SEQUENCE
19
21
 
20
- **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
21
-
22
22
  ### 1. Reference Refinement Rules
23
23
 
24
24
  Use the refinement rules loaded in Step 01 from `{refinementRulesData}`. If not available in context, reload from `{refinementRulesData}`.
@@ -102,7 +102,7 @@ Suggestion: {how to incorporate this capability into the architecture}
102
102
 
103
103
  **Proceeding to compile refined architecture...**"
104
104
 
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-05.**
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.**
106
106
 
107
107
  ### 7. Auto-Proceed to Next Step
108
108
 
@@ -0,0 +1,144 @@
1
+ ---
2
+ nextStepFile: 'gap-analysis.md'
3
+ refinementRulesData: '{refinementRulesPath}'
4
+ # Resolve `{enumerateStackSkillsHelper}` by probing
5
+ # `{enumerateStackSkillsProbeOrder}` in order (installed SKF module path
6
+ # first, src/ dev-checkout fallback); first existing path wins. §2 calls
7
+ # it for the deterministic skill inventory (cascade-resolved exports,
8
+ # metadata-hash, confidence-tier mapping) — replacing a hand-rolled
9
+ # subagent fan-out that re-derived the same data on every run.
10
+ enumerateStackSkillsProbeOrder:
11
+ - '{project-root}/_bmad/skf/shared/scripts/skf-enumerate-stack-skills.py'
12
+ - '{project-root}/src/shared/scripts/skf-enumerate-stack-skills.py'
13
+ ---
14
+
15
+ <!-- Config: communicate in {communication_language}. -->
16
+
17
+ # Step 1: Initialize Refinement
18
+
19
+ ## STEP GOAL:
20
+
21
+ Load the architecture document (required), scan the skills folder to build a skill inventory with metadata, load the optional VS feasibility report for context, validate that all inputs exist and meet minimum requirements, and present an initialization summary before auto-proceeding.
22
+
23
+ ## Rules
24
+
25
+ - Focus only on loading inputs, scanning skills, and validating prerequisites — do not perform analysis
26
+ - Present a clear initialization summary so downstream steps have validated inputs
27
+
28
+ ## MANDATORY SEQUENCE
29
+
30
+ ### 1. Accept Input Documents
31
+
32
+ "**Refine Architecture — Evidence-Backed Refinement** (additive — never deletes original content).
33
+
34
+ If you wanted to *verify* the stack first, type `cancel` and run `[VS] Verify Stack`; if no skills exist yet, run `[CS] Create Skill`. Otherwise, please provide the following:
35
+ 1. **Architecture document path** (REQUIRED) — your project's architecture doc to refine
36
+ 2. **VS feasibility report path** (OPTIONAL) — from a previous [VS] Verify Stack run, for additional context
37
+
38
+ Or type `cancel` / `exit` / `:q` at any prompt to abort cleanly."
39
+
40
+ Wait for user input. Store the validated architecture document path as `architecture_doc`. **GATE [default: use args]** — If `{headless_mode}` and `--architecture-doc` was provided: use that path and auto-proceed, log: "headless: using provided architecture path". If `--vs-report-path` was provided, consume it at the VS validation below. If `--architecture-doc` is absent in headless: HALT (exit code 2, `halt_reason: "input-missing"`) and emit the error envelope.
41
+
42
+ - If the user enters `cancel`, `exit`, `[X]`, `q`, or `:q` at any sub-prompt: Display "Cancelled — no refinement was performed." and HALT (exit code 6, `halt_reason: "user-cancelled"`).
43
+
44
+ **Validate architecture document:**
45
+ - Confirm the file exists and is readable
46
+ - If missing or unreadable: "Architecture document not found at `{path}`. Provide a valid path."
47
+ - HALT (exit code 2, `halt_reason: "input-invalid"`) if the user cannot provide a valid path. In headless, emit the error envelope per SKILL.md "Result Contract (Headless)" immediately.
48
+
49
+ **Validate VS report (if provided via `--vs-report-path` or interactive input):**
50
+ - Confirm the file exists and is readable
51
+ - If missing at user-provided path: attempt auto-probe (below) before giving up
52
+ - Store VS report availability as `vs_report_available: true|false` and `vs_report_path`
53
+
54
+ ### 2. Scan Skills Folder
55
+
56
+ **Resolve `{enumerateStackSkillsHelper}`** from `{enumerateStackSkillsProbeOrder}`; first existing path wins.
57
+
58
+ **Primary path — deterministic enumeration via shared helper:**
59
+
60
+ ```bash
61
+ python3 {enumerateStackSkillsHelper} enumerate {skills_output_folder}
62
+ ```
63
+
64
+ The helper walks `{skills_output_folder}`, reads each `metadata.json`, applies the version-aware resolution (export-manifest → `active` symlink → flat fallback), captures the exports cascade (metadata → references → SKILL.md), maps `confidence_tier`, and emits structured JSON with one entry per skill plus a top-level `warnings[]` array. Cache the result as `skill_inventory`.
65
+
66
+ Each helper-emitted entry includes: `skill_name`, `version`, `language`, `confidence_tier`, `exports_documented`, `source_repo`, `source_root`, and a `metadata_hash` for change-detection across runs. The helper's `warnings[]` carries per-skill skip reasons (missing SKILL.md/metadata.json, non-symlink `active`, orphan-versions, schema-version violations).
67
+
68
+ **Failure-budget guard:** If `len(warnings) / (len(skill_inventory) + len(warnings)) > 0.20`, HALT (exit code 7, `halt_reason: "inventory-unreliable"`) with: "Inventory scan unreliable — {len(warnings)}/{total} skills returned skip warnings. Re-run [RA] after skills stabilize." In headless, emit the error envelope.
69
+
70
+ **Fallback path — graceful degradation when the helper is unavailable:** If `{enumerateStackSkillsHelper}` has no existing candidate, fall through to the LLM-driven inventory: walk `{skills_output_folder}` and for each `{skill_package}` read `metadata.json` and extract `name`, `language`, `confidence_tier`, `stats.exports_documented`, `source_repo`/`source_root`. Skip packages missing SKILL.md or metadata.json with a logged warning. Same 20% failure budget applies.
71
+
72
+ ### 3. Validate Minimum Requirements
73
+
74
+ **Check skill count:**
75
+ - At least 1 valid skill must exist
76
+ - If no skills found: "**Cannot proceed.** No skills found in `{skills_output_folder}`. Generate skills with [CS] Create Skill or [QS] Quick Skill, then re-run [RA]."
77
+ - HALT (exit code 5, `halt_reason: "insufficient-skills"`). In headless, emit the error envelope.
78
+ - If exactly 1 valid skill found: "⚠️ Proceeding with 1 skill. Note: gap analysis will find no gaps — pairwise analysis requires at least 2 skills. Step 02 will still execute and issue an appropriate notice. Issue detection and improvement detection will proceed normally."
79
+
80
+ **Check `{outputFolderPath}`** (resolved at activation from `output_folder` config + customize override):
81
+ - Verify the path is non-empty
82
+ - If undefined or empty: "**Cannot proceed.** `output_folder` is not configured in config.yaml. Add an `output_folder` path and re-run [RA]."
83
+ - HALT (exit code 3, `halt_reason: "output-folder-unconfigured"`). In headless, emit the error envelope.
84
+ - The directory existence + writability was probed at On-Activation §5 — if it failed there, this section never runs.
85
+
86
+ **Check forge_data_folder:**
87
+ - Verify `forge_data_folder` was resolved from config.yaml and is non-empty
88
+ - If undefined or empty: "**Cannot proceed.** `forge_data_folder` is not configured in config.yaml. Add a `forge_data_folder` path to your config.yaml and re-run [RA]."
89
+ - HALT (exit code 3, `halt_reason: "forge-folder-unconfigured"`). In headless, emit the error envelope.
90
+ - The directory existence + writability was probed at On-Activation §5.
91
+
92
+ **Check architecture document:**
93
+ - Confirm it was loaded successfully in section 1
94
+ - If not: HALT with error (should not reach here if section 1 validation passed)
95
+
96
+ ### 3b. Auto-Probe VS Report
97
+
98
+ **Auto-probe VS report (if not provided by user in section 1, OR if user-provided path was invalid):**
99
+ - Only attempt if `forge_data_folder` is non-empty and the directory exists (validated above); otherwise skip probe and set `vs_report_available: false`
100
+ - Check for `{forge_data_folder}/feasibility-report-{project_name}.md`
101
+ - If found: "Auto-discovered VS report at `{path}`. Loading for additional context."
102
+ - Store `vs_report_available: true` and `vs_report_path`
103
+ - If not found: `vs_report_available: false` — "Proceeding without VS report — issue detection will rely on skill data only."
104
+
105
+ ### 3c. Reset RA State File
106
+
107
+ Create (or overwrite) `{forge_data_folder}/ra-state-{project_name}.md` with a fresh header:
108
+
109
+ ```markdown
110
+ <!-- RA state for {project_name} — generated {current_date} -->
111
+ ```
112
+
113
+ This ensures steps 02-04 append to a clean slate and context recovery in step 5 never loads stale findings from a prior run.
114
+
115
+ On any write failure (read-only mount, disk full, permissions denied): HALT (exit code 4, `halt_reason: "write-failed"`) with the captured error and emit the error envelope. The On-Activation §5 probe should have caught this earlier — if it surfaces here, the filesystem state changed mid-workflow.
116
+
117
+ ### 4. Load Refinement Rules
118
+
119
+ Load `{refinementRulesData}` for reference by downstream steps.
120
+
121
+ Extract: gap detection rules, issue detection rules, improvement detection rules, citation format, and preservation rules.
122
+
123
+ ### 5. Display Initialization Summary
124
+
125
+ "**Architecture Refinement Initialized**
126
+
127
+ | Field | Value |
128
+ |-------|-------|
129
+ | **Architecture Doc** | {architecture_doc} |
130
+ | **VS Report** | {vs_report_path or 'Not provided — issue detection will use skill data only'} |
131
+ | **Skills Loaded** | {skill_count} |
132
+
133
+ **Skill Inventory:**
134
+
135
+ | Skill | Language | Tier | Exports |
136
+ |-------|----------|------|---------|
137
+ | {skill_name} | {language} | {confidence_tier} | {exports_documented} |
138
+
139
+ **Proceeding to gap analysis...**"
140
+
141
+ ### 6. Auto-Proceed to Next Step
142
+
143
+ Load, read the full file and then execute `{nextStepFile}`.
144
+
@@ -1,8 +1,10 @@
1
1
  ---
2
- nextStepFile: './step-04-improvements.md'
3
- refinementRulesData: 'references/refinement-rules.md'
2
+ nextStepFile: 'improvements.md'
3
+ refinementRulesData: '{refinementRulesPath}'
4
4
  ---
5
5
 
6
+ <!-- Config: communicate in {communication_language}. Append issue-detection findings to the RA state file in {document_output_language}. -->
7
+
6
8
  # Step 3: Issue Detection
7
9
 
8
10
  ## STEP GOAL:
@@ -17,8 +19,6 @@ Find contradictions between what the architecture document claims and what the g
17
19
 
18
20
  ## MANDATORY SEQUENCE
19
21
 
20
- **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
21
-
22
22
  ### 1. Reference Refinement Rules
23
23
 
24
24
  Use the refinement rules loaded in Step 01 from `{refinementRulesData}`. If not available in context, reload from `{refinementRulesData}`.
@@ -114,7 +114,7 @@ Suggestion: {specific correction with API evidence}
114
114
 
115
115
  **Proceeding to improvement detection...**"
116
116
 
117
- Store all issue findings as workflow state for Step 05. To ensure durability across long runs, also append a `<!-- [RA-ISSUES] ... -->` comment block to `{forge_data_folder}/ra-state-{project_name}.md` containing the **complete formatted issue findings** (full citation blocks with architecture claims, skill evidence, VS verdicts, severity, 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-05.**
117
+ Store all issue findings as workflow state for Step 05. To ensure durability across long runs, also append a `<!-- [RA-ISSUES] ... -->` comment block to `{forge_data_folder}/ra-state-{project_name}.md` containing the **complete formatted issue findings** (full citation blocks with architecture claims, skill evidence, VS verdicts, severity, 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.**
118
118
 
119
119
  ### 7. Auto-Proceed to Next Step
120
120
 
@@ -1,3 +1,5 @@
1
+ <!-- Static reference loaded by gap-analysis.md, issue-detection.md, and improvements.md. -->
2
+
1
3
  # Architecture Refinement Rules
2
4
 
3
5
  ## Purpose