bmad-module-skill-forge 0.10.0 → 0.10.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/.claude-plugin/marketplace.json +39 -0
  2. package/.gitattributes +16 -0
  3. package/README.md +105 -38
  4. package/docs/404.md +13 -10
  5. package/docs/RELEASING.md +185 -0
  6. package/docs/STABILITY.md +123 -0
  7. package/docs/_data/pinned.yaml +98 -0
  8. package/docs/agents.md +16 -11
  9. package/docs/architecture.md +221 -0
  10. package/docs/bmad-synergy.md +11 -13
  11. package/docs/concepts.md +18 -108
  12. package/docs/examples.md +121 -80
  13. package/docs/getting-started.md +85 -147
  14. package/docs/how-it-works.md +25 -536
  15. package/docs/index.md +44 -27
  16. package/docs/skill-model.md +328 -0
  17. package/docs/troubleshooting.md +39 -0
  18. package/docs/verifying-a-skill.md +232 -0
  19. package/docs/why-skf.md +93 -0
  20. package/docs/workflows.md +119 -13
  21. package/package.json +25 -4
  22. package/src/README.md +23 -25
  23. package/src/forger/forge-tier.yaml +4 -2
  24. package/src/forger/preferences.yaml +7 -1
  25. package/src/knowledge/agentskills-spec.md +1 -1
  26. package/src/knowledge/architecture-verification.md +1 -1
  27. package/src/knowledge/ccc-bridge.md +16 -15
  28. package/src/knowledge/overview.md +11 -11
  29. package/src/knowledge/progressive-capability.md +3 -3
  30. package/src/knowledge/provenance-tracking.md +9 -3
  31. package/src/knowledge/qmd-registry.md +8 -8
  32. package/src/knowledge/skf-knowledge-index.csv +2 -2
  33. package/src/knowledge/skill-lifecycle.md +16 -1
  34. package/src/knowledge/split-body-strategy.md +1 -1
  35. package/src/knowledge/version-paths.md +17 -12
  36. package/src/module-help.csv +18 -17
  37. package/src/shared/health-check.md +372 -0
  38. package/src/shared/references/feasibility-report-schema.md +86 -0
  39. package/src/shared/references/headless-gate-convention.md +62 -0
  40. package/src/shared/references/output-contract-schema.md +35 -0
  41. package/src/shared/references/pipeline-contracts.md +102 -0
  42. package/src/shared/scripts/skf-atomic-write.py +370 -0
  43. package/src/shared/scripts/skf-manifest-ops.py +236 -0
  44. package/src/shared/scripts/skf-preflight.py +164 -0
  45. package/src/shared/scripts/skf-rebuild-managed-sections.py +201 -0
  46. package/src/shared/scripts/skf-severity-classify.py +163 -0
  47. package/src/shared/scripts/skf-skill-inventory.py +210 -0
  48. package/src/shared/scripts/skf-structural-diff.py +257 -0
  49. package/src/shared/scripts/skf-validate-frontmatter.py +318 -0
  50. package/src/shared/scripts/skf-validate-output.py +247 -0
  51. package/src/skf-analyze-source/SKILL.md +57 -0
  52. package/src/skf-analyze-source/assets/skill-brief-schema.md +125 -0
  53. package/src/skf-analyze-source/references/unit-detection-heuristics.md +124 -0
  54. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-01-init.md +6 -66
  55. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-01b-continue.md +4 -59
  56. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-02-scan-project.md +7 -68
  57. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-03-identify-units.md +6 -66
  58. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-04-map-and-detect.md +7 -68
  59. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-05-recommend.md +6 -66
  60. package/src/{workflows/analyze-source → skf-analyze-source}/steps-c/step-06-generate-briefs.md +14 -71
  61. package/src/skf-analyze-source/steps-c/step-07-health-check.md +22 -0
  62. package/src/skf-audit-skill/SKILL.md +59 -0
  63. package/src/{workflows/audit-skill/data → skf-audit-skill/assets}/drift-report-template.md +7 -7
  64. package/src/{workflows/audit-skill/data → skf-audit-skill/references}/severity-rules.md +11 -11
  65. package/src/{workflows/audit-skill → skf-audit-skill}/steps-c/step-01-init.md +24 -68
  66. package/src/{workflows/audit-skill → skf-audit-skill}/steps-c/step-02-re-index.md +36 -71
  67. package/src/{workflows/audit-skill → skf-audit-skill}/steps-c/step-03-structural-diff.md +21 -63
  68. package/src/{workflows/audit-skill → skf-audit-skill}/steps-c/step-04-semantic-diff.md +6 -65
  69. package/src/{workflows/audit-skill → skf-audit-skill}/steps-c/step-05-severity-classify.md +5 -63
  70. package/src/{workflows/audit-skill → skf-audit-skill}/steps-c/step-06-report.md +10 -64
  71. package/src/skf-audit-skill/steps-c/step-07-health-check.md +22 -0
  72. package/src/skf-brief-skill/SKILL.md +53 -0
  73. package/src/{workflows/brief-skill/data → skf-brief-skill/assets}/scope-templates.md +23 -0
  74. package/src/skf-brief-skill/assets/skill-brief-schema.md +206 -0
  75. package/src/{workflows/brief-skill → skf-brief-skill}/steps-c/step-01-gather-intent.md +6 -67
  76. package/src/{workflows/brief-skill → skf-brief-skill}/steps-c/step-02-analyze-target.md +6 -66
  77. package/src/{workflows/brief-skill → skf-brief-skill}/steps-c/step-03-scope-definition.md +12 -68
  78. package/src/{workflows/brief-skill → skf-brief-skill}/steps-c/step-04-confirm-brief.md +5 -63
  79. package/src/{workflows/brief-skill → skf-brief-skill}/steps-c/step-05-write-brief.md +10 -70
  80. package/src/skf-brief-skill/steps-c/step-06-health-check.md +22 -0
  81. package/src/skf-create-skill/SKILL.md +63 -0
  82. package/src/{workflows/create-skill/data → skf-create-skill/assets}/compile-assembly-rules.md +60 -0
  83. package/src/{workflows/create-skill/data → skf-create-skill/assets}/skill-sections.md +92 -23
  84. package/src/skf-create-skill/assets/tessl-dismissal-rules.md +102 -0
  85. package/src/{workflows/create-skill/data → skf-create-skill/references}/extraction-patterns-tracing.md +13 -13
  86. package/src/{workflows/create-skill/data → skf-create-skill/references}/extraction-patterns.md +8 -3
  87. package/src/skf-create-skill/references/source-resolution-protocols.md +239 -0
  88. package/src/{workflows/create-skill/data → skf-create-skill/references}/tier-degradation-rules.md +8 -7
  89. package/src/{workflows/create-skill → skf-create-skill}/steps-c/step-01-load-brief.md +25 -63
  90. package/src/{workflows/create-skill → skf-create-skill}/steps-c/step-02-ecosystem-check.md +8 -64
  91. package/src/skf-create-skill/steps-c/step-03-extract.md +379 -0
  92. package/src/{workflows/create-skill → skf-create-skill}/steps-c/step-03d-component-extraction.md +18 -35
  93. package/src/{workflows/create-skill → skf-create-skill}/steps-c/step-04-enrich.md +12 -69
  94. package/src/{workflows/create-skill → skf-create-skill}/steps-c/step-05-compile.md +71 -75
  95. package/src/skf-create-skill/steps-c/step-06-validate.md +267 -0
  96. package/src/{workflows/create-skill → skf-create-skill}/steps-c/step-07-generate-artifacts.md +30 -74
  97. package/src/skf-create-skill/steps-c/step-08-report.md +145 -0
  98. package/src/skf-create-skill/steps-c/step-09-health-check.md +23 -0
  99. package/src/{workflows/create-skill/steps-c → skf-create-skill/steps-c/sub}/step-02b-ccc-discover.md +8 -66
  100. package/src/skf-create-skill/steps-c/sub/step-03b-fetch-temporal.md +229 -0
  101. package/src/{workflows/create-skill/steps-c → skf-create-skill/steps-c/sub}/step-03c-fetch-docs.md +18 -42
  102. package/src/skf-create-stack-skill/SKILL.md +64 -0
  103. package/src/{workflows/create-stack-skill/data → skf-create-stack-skill/assets}/stack-skill-template.md +2 -1
  104. package/src/{workflows/create-stack-skill/data → skf-create-stack-skill/references}/compose-mode-rules.md +19 -5
  105. package/src/{workflows/create-stack-skill/data → skf-create-stack-skill/references}/integration-patterns.md +1 -1
  106. package/src/{workflows/create-stack-skill/data → skf-create-stack-skill/references}/manifest-patterns.md +10 -10
  107. package/src/{workflows/create-stack-skill → skf-create-stack-skill}/steps-c/step-01-init.md +14 -55
  108. package/src/{workflows/create-stack-skill → skf-create-stack-skill}/steps-c/step-02-detect-manifests.md +29 -63
  109. package/src/{workflows/create-stack-skill → skf-create-stack-skill}/steps-c/step-03-rank-and-confirm.md +9 -59
  110. package/src/{workflows/create-stack-skill → skf-create-stack-skill}/steps-c/step-04-parallel-extract.md +29 -64
  111. package/src/skf-create-stack-skill/steps-c/step-05-detect-integrations.md +164 -0
  112. package/src/{workflows/create-stack-skill → skf-create-stack-skill}/steps-c/step-06-compile-stack.md +7 -60
  113. package/src/skf-create-stack-skill/steps-c/step-07-generate-output.md +328 -0
  114. package/src/{workflows/create-stack-skill → skf-create-stack-skill}/steps-c/step-08-validate.md +17 -63
  115. package/src/skf-create-stack-skill/steps-c/step-09-report.md +128 -0
  116. package/src/skf-create-stack-skill/steps-c/step-10-health-check.md +22 -0
  117. package/src/skf-drop-skill/SKILL.md +57 -0
  118. package/src/{workflows/drop-skill → skf-drop-skill}/steps-c/step-01-select.md +9 -69
  119. package/src/{workflows/drop-skill → skf-drop-skill}/steps-c/step-02-execute.md +30 -106
  120. package/src/skf-drop-skill/steps-c/step-03-report.md +83 -0
  121. package/src/skf-drop-skill/steps-c/step-04-health-check.md +22 -0
  122. package/src/skf-export-skill/SKILL.md +57 -0
  123. package/src/skf-export-skill/assets/managed-section-format.md +138 -0
  124. package/src/{workflows/export-skill/data → skf-export-skill/assets}/snippet-format.md +8 -12
  125. package/src/skf-export-skill/steps-c/step-01-load-skill.md +247 -0
  126. package/src/{workflows/export-skill → skf-export-skill}/steps-c/step-02-package.md +5 -58
  127. package/src/{workflows/export-skill → skf-export-skill}/steps-c/step-03-generate-snippet.md +15 -77
  128. package/src/{workflows/export-skill → skf-export-skill}/steps-c/step-04-update-context.md +59 -133
  129. package/src/{workflows/export-skill → skf-export-skill}/steps-c/step-05-token-report.md +4 -58
  130. package/src/{workflows/export-skill → skf-export-skill}/steps-c/step-06-summary.md +16 -68
  131. package/src/skf-export-skill/steps-c/step-07-health-check.md +22 -0
  132. package/src/skf-forger/SKILL.md +110 -0
  133. package/src/skf-forger/bmad-skill-manifest.yaml +11 -0
  134. package/src/skf-quick-skill/SKILL.md +56 -0
  135. package/src/{workflows/quick-skill/data → skf-quick-skill/references}/registry-resolution.md +6 -6
  136. package/src/{workflows/quick-skill → skf-quick-skill}/steps-c/step-01-resolve-target.md +9 -62
  137. package/src/{workflows/quick-skill → skf-quick-skill}/steps-c/step-02-ecosystem-check.md +5 -59
  138. package/src/{workflows/quick-skill → skf-quick-skill}/steps-c/step-03-quick-extract.md +18 -61
  139. package/src/{workflows/quick-skill → skf-quick-skill}/steps-c/step-04-compile.md +6 -60
  140. package/src/{workflows/quick-skill → skf-quick-skill}/steps-c/step-05-validate.md +58 -78
  141. package/src/skf-quick-skill/steps-c/step-06-write.md +73 -0
  142. package/src/skf-quick-skill/steps-c/step-07-health-check.md +22 -0
  143. package/src/skf-refine-architecture/SKILL.md +57 -0
  144. package/src/{workflows/refine-architecture/data → skf-refine-architecture/references}/refinement-rules.md +16 -16
  145. package/src/{workflows/refine-architecture → skf-refine-architecture}/steps-c/step-01-init.md +6 -63
  146. package/src/{workflows/refine-architecture → skf-refine-architecture}/steps-c/step-02-gap-analysis.md +29 -71
  147. package/src/{workflows/refine-architecture → skf-refine-architecture}/steps-c/step-03-issue-detection.md +5 -65
  148. package/src/{workflows/refine-architecture → skf-refine-architecture}/steps-c/step-04-improvements.md +5 -64
  149. package/src/{workflows/refine-architecture → skf-refine-architecture}/steps-c/step-05-compile.md +5 -56
  150. package/src/{workflows/refine-architecture → skf-refine-architecture}/steps-c/step-06-report.md +11 -64
  151. package/src/skf-refine-architecture/steps-c/step-07-health-check.md +22 -0
  152. package/src/skf-rename-skill/SKILL.md +58 -0
  153. package/src/{workflows/rename-skill → skf-rename-skill}/steps-c/step-01-select.md +12 -73
  154. package/src/{workflows/rename-skill → skf-rename-skill}/steps-c/step-02-execute.md +32 -113
  155. package/src/skf-rename-skill/steps-c/step-03-report.md +83 -0
  156. package/src/skf-rename-skill/steps-c/step-04-health-check.md +22 -0
  157. package/src/skf-setup/SKILL.md +55 -0
  158. package/src/{workflows/setup-forge → skf-setup}/steps-c/step-01-detect-and-tier.md +6 -62
  159. package/src/{workflows/setup-forge → skf-setup}/steps-c/step-01b-ccc-index.md +9 -65
  160. package/src/{workflows/setup-forge → skf-setup}/steps-c/step-02-write-config.md +15 -60
  161. package/src/{workflows/setup-forge → skf-setup}/steps-c/step-03-auto-index.md +7 -66
  162. package/src/skf-setup/steps-c/step-04-report.md +92 -0
  163. package/src/skf-setup/steps-c/step-05-health-check.md +22 -0
  164. package/src/skf-test-skill/SKILL.md +59 -0
  165. package/src/skf-test-skill/references/migration-section-rules.md +114 -0
  166. package/src/skf-test-skill/references/scoring-rules.md +207 -0
  167. package/src/skf-test-skill/references/source-access-protocol.md +109 -0
  168. package/src/skf-test-skill/scripts/compute-score.py +310 -0
  169. package/src/skf-test-skill/steps-c/step-01-init.md +238 -0
  170. package/src/{workflows/test-skill → skf-test-skill}/steps-c/step-02-detect-mode.md +4 -62
  171. package/src/skf-test-skill/steps-c/step-03-coverage-check.md +347 -0
  172. package/src/skf-test-skill/steps-c/step-04-coherence-check.md +239 -0
  173. package/src/{workflows/test-skill → skf-test-skill}/steps-c/step-04b-external-validators.md +42 -77
  174. package/src/skf-test-skill/steps-c/step-05-score.md +266 -0
  175. package/src/skf-test-skill/steps-c/step-06-report.md +290 -0
  176. package/src/skf-test-skill/steps-c/step-07-health-check.md +25 -0
  177. package/src/skf-test-skill/templates/test-report-template.md +58 -0
  178. package/src/skf-update-skill/SKILL.md +58 -0
  179. package/src/{workflows/update-skill/data → skf-update-skill/references}/manual-section-rules.md +6 -6
  180. package/src/{workflows/update-skill/data → skf-update-skill/references}/merge-conflict-rules.md +5 -5
  181. package/src/skf-update-skill/references/remote-source-resolution.md +94 -0
  182. package/src/{workflows/update-skill → skf-update-skill}/steps-c/step-01-init.md +22 -69
  183. package/src/skf-update-skill/steps-c/step-02-detect-changes.md +255 -0
  184. package/src/skf-update-skill/steps-c/step-03-re-extract.md +336 -0
  185. package/src/{workflows/update-skill → skf-update-skill}/steps-c/step-04-merge.md +60 -72
  186. package/src/{workflows/update-skill → skf-update-skill}/steps-c/step-05-validate.md +5 -62
  187. package/src/skf-update-skill/steps-c/step-06-write.md +278 -0
  188. package/src/{workflows/update-skill → skf-update-skill}/steps-c/step-07-report.md +11 -69
  189. package/src/skf-update-skill/steps-c/step-08-health-check.md +22 -0
  190. package/src/skf-verify-stack/SKILL.md +60 -0
  191. package/src/skf-verify-stack/assets/feasibility-report-template.md +76 -0
  192. package/src/{workflows/verify-stack/data → skf-verify-stack/references}/coverage-patterns.md +12 -4
  193. package/src/skf-verify-stack/references/integration-verification-rules.md +78 -0
  194. package/src/skf-verify-stack/steps-c/step-01-init.md +178 -0
  195. package/src/{workflows/verify-stack → skf-verify-stack}/steps-c/step-02-coverage.md +27 -72
  196. package/src/skf-verify-stack/steps-c/step-03-integrations.md +179 -0
  197. package/src/{workflows/verify-stack → skf-verify-stack}/steps-c/step-04-requirements.md +14 -67
  198. package/src/skf-verify-stack/steps-c/step-05-synthesize.md +147 -0
  199. package/src/skf-verify-stack/steps-c/step-06-report.md +156 -0
  200. package/src/skf-verify-stack/steps-c/step-07-health-check.md +25 -0
  201. package/tools/cli/commands/install.js +1 -1
  202. package/tools/cli/commands/status.js +21 -23
  203. package/tools/cli/commands/uninstall.js +11 -19
  204. package/tools/cli/commands/update.js +2 -2
  205. package/tools/cli/lib/ide-skills.js +216 -0
  206. package/tools/cli/lib/installer.js +29 -52
  207. package/tools/cli/lib/manifest.js +11 -5
  208. package/tools/cli/lib/platform-codes.yaml +223 -0
  209. package/tools/cli/lib/ui.js +76 -47
  210. package/tools/validate-docs-drift.js +193 -0
  211. package/src/agents/forger.agent.yaml +0 -114
  212. package/src/workflows/README.md +0 -174
  213. package/src/workflows/analyze-source/data/skill-brief-schema.md +0 -125
  214. package/src/workflows/analyze-source/data/unit-detection-heuristics.md +0 -124
  215. package/src/workflows/analyze-source/workflow.md +0 -61
  216. package/src/workflows/audit-skill/workflow.md +0 -64
  217. package/src/workflows/brief-skill/data/skill-brief-schema.md +0 -159
  218. package/src/workflows/brief-skill/workflow.md +0 -58
  219. package/src/workflows/create-skill/data/source-resolution-protocols.md +0 -200
  220. package/src/workflows/create-skill/steps-c/step-03-extract.md +0 -301
  221. package/src/workflows/create-skill/steps-c/step-03b-fetch-temporal.md +0 -253
  222. package/src/workflows/create-skill/steps-c/step-06-validate.md +0 -254
  223. package/src/workflows/create-skill/steps-c/step-08-report.md +0 -179
  224. package/src/workflows/create-skill/workflow.md +0 -53
  225. package/src/workflows/create-stack-skill/steps-c/step-05-detect-integrations.md +0 -196
  226. package/src/workflows/create-stack-skill/steps-c/step-07-generate-output.md +0 -270
  227. package/src/workflows/create-stack-skill/steps-c/step-09-report.md +0 -150
  228. package/src/workflows/create-stack-skill/workflow.md +0 -59
  229. package/src/workflows/drop-skill/steps-c/step-03-report.md +0 -136
  230. package/src/workflows/drop-skill/workflow.md +0 -63
  231. package/src/workflows/export-skill/data/managed-section-format.md +0 -103
  232. package/src/workflows/export-skill/steps-c/step-01-load-skill.md +0 -237
  233. package/src/workflows/export-skill/workflow.md +0 -58
  234. package/src/workflows/quick-skill/steps-c/step-06-write.md +0 -178
  235. package/src/workflows/quick-skill/workflow.md +0 -58
  236. package/src/workflows/refine-architecture/workflow.md +0 -61
  237. package/src/workflows/rename-skill/steps-c/step-03-report.md +0 -133
  238. package/src/workflows/rename-skill/workflow.md +0 -64
  239. package/src/workflows/setup-forge/steps-c/step-04-report.md +0 -159
  240. package/src/workflows/setup-forge/workflow.md +0 -51
  241. package/src/workflows/shared/health-check.md +0 -231
  242. package/src/workflows/test-skill/data/scoring-rules.md +0 -123
  243. package/src/workflows/test-skill/data/source-access-protocol.md +0 -51
  244. package/src/workflows/test-skill/steps-c/step-01-init.md +0 -217
  245. package/src/workflows/test-skill/steps-c/step-03-coverage-check.md +0 -280
  246. package/src/workflows/test-skill/steps-c/step-04-coherence-check.md +0 -271
  247. package/src/workflows/test-skill/steps-c/step-05-score.md +0 -222
  248. package/src/workflows/test-skill/steps-c/step-06-report.md +0 -208
  249. package/src/workflows/test-skill/templates/test-report-template.md +0 -28
  250. package/src/workflows/test-skill/workflow.md +0 -57
  251. package/src/workflows/update-skill/data/remote-source-resolution.md +0 -57
  252. package/src/workflows/update-skill/steps-c/step-02-detect-changes.md +0 -221
  253. package/src/workflows/update-skill/steps-c/step-03-re-extract.md +0 -256
  254. package/src/workflows/update-skill/steps-c/step-06-write.md +0 -265
  255. package/src/workflows/update-skill/workflow.md +0 -56
  256. package/src/workflows/verify-stack/data/feasibility-report-template.md +0 -63
  257. package/src/workflows/verify-stack/data/integration-verification-rules.md +0 -73
  258. package/src/workflows/verify-stack/steps-c/step-01-init.md +0 -179
  259. package/src/workflows/verify-stack/steps-c/step-03-integrations.md +0 -195
  260. package/src/workflows/verify-stack/steps-c/step-05-synthesize.md +0 -191
  261. package/src/workflows/verify-stack/steps-c/step-06-report.md +0 -200
  262. package/src/workflows/verify-stack/workflow.md +0 -61
  263. package/tools/cli/lib/compiler.js +0 -306
  264. package/tools/cli/lib/ide-commands.js +0 -244
  265. /package/src/{workflows/analyze-source → skf-analyze-source}/templates/analysis-report-template.md +0 -0
  266. /package/src/{workflows/quick-skill/data → skf-quick-skill/assets}/skill-template.md +0 -0
  267. /package/src/{workflows/setup-forge/data → skf-setup/references}/tier-rules.md +0 -0
  268. /package/src/{workflows/test-skill/data → skf-test-skill/assets}/output-section-formats.md +0 -0
@@ -0,0 +1,379 @@
1
+ ---
2
+ nextStepFile: './sub/step-03b-fetch-temporal.md'
3
+ componentExtractionStepFile: './step-03d-component-extraction.md'
4
+ extractionPatternsData: 'references/extraction-patterns.md'
5
+ extractionPatternsTracingData: 'references/extraction-patterns-tracing.md'
6
+ tierDegradationRulesData: 'references/tier-degradation-rules.md'
7
+ sourceResolutionData: 'references/source-resolution-protocols.md'
8
+ # Probe installed SKF module path first, src/ dev-checkout fallback. At first
9
+ # use below, resolve `{atomicWriteHelper}` to the first existing path; HALT if
10
+ # neither candidate exists — losing atomic-write guarantees is not an option.
11
+ atomicWriteProbeOrder:
12
+ - '{project-root}/_bmad/skf/shared/scripts/skf-atomic-write.py'
13
+ - '{project-root}/src/shared/scripts/skf-atomic-write.py'
14
+ ---
15
+
16
+ # Step 3: Extract
17
+
18
+ ## STEP GOAL:
19
+
20
+ To extract all public exports, function signatures, type definitions, and co-import patterns from the source code using tier-appropriate tools, building a complete extraction inventory with confidence-tiered provenance citations.
21
+
22
+ ## Rules
23
+
24
+ - Focus only on extracting exports, signatures, types from source code — do not compile SKILL.md
25
+ - Do not write any output files — extraction stays in context
26
+ - Every extracted item must have a provenance citation: `[AST:{file}:L{line}]` or `[SRC:{file}:L{line}]`
27
+
28
+ ## MANDATORY SEQUENCE
29
+
30
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
31
+
32
+ ### 1. Load Extraction Patterns
33
+
34
+ Load `{extractionPatternsData}` completely. Identify the strategy for the current forge tier.
35
+
36
+ ### 2. Apply Scope Filters
37
+
38
+ From the brief, apply scope and pattern filters:
39
+
40
+ - `scope.type` — determines what to extract (e.g., `full-library`, `specific-modules`, `public-api`, `component-library`, `reference-app`, `docs-only`). Use `reference-app` when the source is a whole app and the skill's value is wiring patterns rather than public exports (embedded-sidecar reference apps, CLI-demo repos, integration-pattern demonstrators). `reference-app` triggers the compile-assembly overrides in `{compileAssemblyRules}` that replace "Key API Summary" with a "Pattern Surface" section and make `stats.exports_documented` semantics pattern-oriented. Do NOT pick `full-library` for reference apps — downstream assembly will remap wiring onto export slots, producing fuzzy counts and an awkward SKILL.md.
41
+ - `scope.include` — file globs to include
42
+ - `scope.exclude` — file globs to exclude
43
+
44
+ Build the filtered file list from the source tree resolved in step-01. Record the result: "**Filtered file count: {N} files in scope**" — this count is the input to the AST Extraction Protocol decision tree in the extraction patterns data file.
45
+
46
+ ### 2a. Discovered Authoritative Files Protocol
47
+
48
+ **Skip this section entirely if `source_type: "docs-only"`** — there is no source tree to scan.
49
+
50
+ Before resolving source access for extraction, scan the source tree for **authoritative AI documentation files** that the brief's scope filters excluded. Project authors increasingly add files specifically written to steer AI assistants (`llms.txt`, `AGENTS.md`, `.cursorrules`, etc.), and these files often contain the **canonical** install command, quick-start, or architecture summary — information that nowhere else in the source tree provides. A brief authored from a scan of `src/**` will frequently exclude these files without the author realizing they exist.
51
+
52
+ This protocol detects such files, prompts the user, and records the decision in the brief so future runs (re-create, update, audit) honor it.
53
+
54
+ **Heuristic scan list (case-insensitive basename match, any directory depth):**
55
+
56
+ - `llms.txt`, `llms-full.txt`
57
+ - `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `COPILOT.md`
58
+ - `.cursorrules`, `.windsurfrules`, `.clinerules`
59
+
60
+ **Procedure:**
61
+
62
+ 1. **Walk the source tree** resolved in step-01 (NOT the filtered file list from §2 — we want files the brief excluded too). Match file basenames against the heuristic list case-insensitively.
63
+
64
+ 2. **Diff against filtered list.** For each match, check whether the path is already present in §2's filtered file list:
65
+ - **Already in scope (matched by `scope.include`):** **remove the path from the filtered file list** and add it directly to `promoted_docs[]` with `{path, heuristic, size_bytes, line_count, content_hash}`. No prompt — the user or a prior amendment already said it belongs in scope, but authoritative docs must never reach §4 code extraction. This is both the "already promoted from a prior run" case and the "user manually added to scope.include" case.
66
+ - **Excluded by brief patterns:** this is a **candidate** for the prompt at step 5.
67
+
68
+ 3. **Check existing amendments.** Before prompting, consult `brief.scope.amendments[]` (see `src/skf-brief-skill/assets/skill-brief-schema.md` for the schema). If any amendment entry has `path == candidate.path`, the decision is already recorded:
69
+ - `action: "promoted"` → the file should already be in `scope.include` (amendments are write-through). No prompt. **Still populate `promoted_docs[]`** for this path — compute its content hash and add a `{path, heuristic, size_bytes, line_count, content_hash}` entry so step-05 §6 writes the `file_entries[]` row. This is the deterministic replay path for re-runs.
70
+ - `action: "skipped"` → user previously declined. No prompt. Do not add to `promoted_docs[]`. Move on.
71
+
72
+ 4. **Load preview.** For each unresolved candidate, read the first 20 lines of the file. Record the line count and file size in bytes.
73
+
74
+ 5. **Prompt.** Present each candidate to the user:
75
+
76
+ ```
77
+ **Discovered authoritative file excluded by brief scope**
78
+
79
+ Path: {relative_path_from_source_root}
80
+ Size: {line_count} lines, {bytes} bytes
81
+ Matched heuristic: {basename}
82
+ Excluded by pattern: {matching_exclude_pattern or "not matched by any scope.include"}
83
+
84
+ First 20 lines:
85
+ {inline preview}
86
+
87
+ This file is typically authored for AI assistants and may contain canonical usage information not present elsewhere in the source. How should extraction handle it?
88
+
89
+ [P] Promote — include in this extraction run AND amend brief for future runs
90
+ [S] Skip — honor the brief exclusion AND record skip in amendments (no re-prompt)
91
+ [U] Update — halt this run and return to skf-brief-skill to refine scope
92
+ ```
93
+
94
+ 6. **Headless mode (`{headless_mode}` is true):** auto-select `[S] Skip` for every candidate. Record amendment entries with `action: "skipped"` and `reason: "headless: no user to prompt"`. A non-interactive run must never silently promote files into scope — the decision requires a human.
95
+
96
+ 7. **Apply decision:**
97
+
98
+ - **[P] Promote:**
99
+ 1. **Do NOT add the path to the filtered file list from §2.** Authoritative documentation files are not code — they must not go through the AST extraction pipeline in §4, which would silently produce no exports (ghost entries). Instead, add the path to a new in-context list `promoted_docs[]` with `{path, heuristic, size_bytes, line_count, content_hash}`. Compute the SHA-256 content hash of the file now.
100
+ 2. Append to `brief.scope.include`: add the exact `candidate.path` as a literal glob (no wildcards — the amendment targets this specific file). This write ensures that a re-run of `skf-create-skill` against the amended brief sees the path in scope and skips re-prompting.
101
+ 3. Append to `brief.scope.amendments[]` a new entry with `action: "promoted"`, `path: candidate.path`, `reason: {user-provided one-sentence reason or auto-generated "authoritative AI docs — matched heuristic {basename}"}`, `heuristic: {basename}`, `date: {today ISO}`, `workflow: "skf-create-skill"`.
102
+ 4. **Write the amended brief back to disk immediately** at `{forge_data_folder}/{skill_name}/skill-brief.yaml`. Immediate write (not deferred to step-07) ensures a crashed run still leaves the amendment recorded. Preserve all other brief fields and formatting. **Use atomic write + backup:** before writing, copy the original brief to `{forge_data_folder}/{skill_name}/skill-brief.yaml.bak` (overwriting any prior `.bak` — the most recent pre-amendment snapshot is the useful one). Then pipe the amended YAML through the shared atomic writer so a crash mid-write cannot corrupt the brief:
103
+
104
+ ```bash
105
+ # 1. Backup
106
+ cp {forge_data_folder}/{skill_name}/skill-brief.yaml \
107
+ {forge_data_folder}/{skill_name}/skill-brief.yaml.bak
108
+
109
+ # 2. Atomic write (stdin → tmp → fsync → rename)
110
+ cat <<'AMENDED_YAML' | python3 {atomicWriteHelper} write \
111
+ --target {forge_data_folder}/{skill_name}/skill-brief.yaml
112
+ {amended brief YAML}
113
+ AMENDED_YAML
114
+ ```
115
+
116
+ The helper stages into `{brief}.skf-tmp`, fsyncs, then `os.replace()`s — readers never see a half-written brief.
117
+ 5. Display: "**Promoted `{path}`** — tracked as documentation file, amendment recorded."
118
+
119
+ - **[S] Skip:**
120
+ 1. Do NOT modify `scope.include` or `scope.exclude`.
121
+ 2. Append to `brief.scope.amendments[]` a new entry with `action: "skipped"`, `path: candidate.path`, `reason: {user-provided reason or auto-generated "user declined promotion at create-skill §2a"}`, `heuristic: {basename}`, `date: {today ISO}`, `workflow: "skf-create-skill"`.
122
+ 3. **Write the amended brief back to disk** so future runs do not re-prompt. Use the same backup-then-atomic-write pattern as the [P] Promote path (copy to `skill-brief.yaml.bak` first, then pipe through `skf-atomic-write.py write --target {brief_path}`).
123
+ 4. Display: "**Skipped `{path}`** — decision recorded in amendments."
124
+
125
+ - **[U] Update:**
126
+ 1. Halt the workflow immediately.
127
+ 2. Display: "**Halting create-skill.** Re-run `skf-brief-skill` to refine the scope filters for `{skill_name}`, then re-run `skf-create-skill`. Decisions for previously prompted candidates were already persisted to the brief; the current candidate was not written."
128
+ 3. Exit with status `halted-for-brief-refinement`.
129
+
130
+ 8. **Summary.** After all candidates are resolved (or none were found), display a one-line summary:
131
+
132
+ - `"Authoritative files scan: {N} candidates, {P} promoted, {S} skipped, {A} pre-decided from amendments."`
133
+ - If N = 0: `"Authoritative files scan: no candidates."`
134
+
135
+ **Record for evidence report:** `authoritative_files_scan: {candidates: N, promoted: P, skipped: S, pre_decided: A, decisions: [{path, action, heuristic, reason}]}` — step-07 includes this in `evidence-report.md`.
136
+
137
+ **How promoted docs reach the provenance map:**
138
+
139
+ Promoted docs do NOT flow through §4 code extraction. Instead:
140
+
141
+ 1. §2a populates the in-context `promoted_docs[]` list with content hashes.
142
+ 2. **Step-05 §6** (provenance-map assembly) reads `promoted_docs[]` and emits one `file_entries[]` entry per promoted doc with `file_type: "doc"`, `extraction_method: "promoted-authoritative"`, `confidence: "T1-low"`, and the pre-computed `content_hash`.
143
+ 3. **Step-07 §2** does NOT copy doc files into the skill package (unlike scripts and assets). The source file remains at its original path; only the provenance map tracks it. Future audit and update workflows compare against this tracking entry via content hash — no file copy is required because the intent is drift detection on the *source*, not bundling documentation into the skill output.
144
+
145
+ **Re-running `skf-create-skill`** reads the amended brief. Files with `action: "promoted"` amendments already appear in `scope.include`, but §2a still runs — it detects the file is in scope AND has an existing amendment, and takes the "pre-decided" silent path. The `promoted_docs[]` list is rebuilt on each run by scanning amendments with `action: "promoted"` (this is the deterministic replay path).
146
+
147
+ **Downstream workflow consumption** (zero code changes required):
148
+
149
+ - **`skf-update-skill`** reads `provenance-map.json`. Promoted docs appear as `file_entries[]` entries. Update-skill Category D (script/asset file changes) iterates `file_entries` and compares content hashes — this works identically for `file_type: "doc"` entries, giving drift detection for free.
150
+ - **`skf-audit-skill`** (after the bounded re-index fix) scans files from `provenance-map.json`. The re-index builds its list from `entries[].source_file ∪ file_entries[].source_file`, so promoted doc paths are naturally included in the audit scan.
151
+
152
+ The brief is the single source of truth for authored scope intent. The provenance map is the single source of truth for extracted state. `scope.amendments[]` is the bridge that records when those two intentionally diverged. `promoted_docs[]` is the in-memory handoff from §2a to step-05 §6; it is not persisted — the persisted form is the `file_entries[]` list in provenance-map.json.
153
+
154
+ ### 2b. Resolve Source Access
155
+
156
+ **If `source_type: "docs-only"`:** skip §2b entirely — there is no source to resolve. Proceed directly to §2c (component library delegation, which is itself skipped for docs-only) and then §3 (Check for Docs-Only Mode). Tag resolution, remote/workspace cloning, source-commit capture, version reconciliation, and deferred CCC discovery all require a source tree and have nothing to do in docs-only mode.
157
+
158
+ Load `{sourceResolutionData}` completely. Follow these protocols in order:
159
+ 1. **Tag Resolution** — run the explicit variant when `brief.target_version` is set, or the implicit variant when only `brief.version` is set (Forge/Deep remote sources only). This sets `source_ref` before any clone happens. Quick tier remote sources skip this.
160
+ 2. **Remote Source Resolution** — workspace or ephemeral clone, cleanup (Forge/Deep tiers).
161
+ 3. **Source Commit Capture** — all tiers.
162
+ 4. **Version Reconciliation** — all tiers.
163
+
164
+ This ensures source code is accessible regardless of which extraction path is taken below (standard, component-library, or docs-only).
165
+
166
+ **Deferred CCC Discovery (Forge+ and Deep — remote sources only):**
167
+
168
+ If ALL of these conditions are true:
169
+ - `tools.ccc` is true in forge-tier.yaml
170
+ - `{ccc_discovery}` is empty (step-02b deferred because source was remote)
171
+ - `remote_clone_path` is set (source resolution succeeded for a remote URL)
172
+ - Tier is Forge+ or Deep
173
+
174
+ Then run CCC indexing and discovery on the resolved clone (workspace or ephemeral):
175
+
176
+ 1. **Check existing index:** If `{remote_clone_path}/.cocoindex_code/` already exists (workspace repo with a persisted CCC index), skip steps 2-3 and proceed directly to step 4 using `ccc search --refresh` instead of plain `ccc search`. The `--refresh` flag tells CCC to re-index if files have changed since the last index, then search. This is the fast path for workspace repos that have been indexed before. **Note:** If `--refresh` is not supported by the installed ccc version, omit the flag — ccc will use the existing index.
177
+
178
+ 2. **Initialize index (first time only):** Run `cd {remote_clone_path} && ccc init`. If init fails, set `{ccc_discovery: []}` and continue — this is not an error.
179
+
180
+ **Apply standard exclusions:** After `ccc init`, apply generic build/dependency exclusions to `{remote_clone_path}/.cocoindex_code/settings.yml`. These are standard artifact patterns, NOT SKF-specific paths (the workspace checkout is a source repo, not an SKF project):
181
+
182
+ ```
183
+ node_modules/, dist/, build/, .git/, vendor/, __pycache__/, .cache/, .next/, .nuxt/, target/, out/, .venv/, .tox/
184
+ ```
185
+
186
+ Read `settings.yml`, append any patterns not already present to the `exclude_patterns` array, write back. **Reuse check:** if an existing `.cocoindex_code/settings.yml` was already present (workspace hit), read its `exclude_patterns` first and diff against the standard-exclusion list above. If ANY standard entry is missing from the existing list, append only the missing entries (preserving any user-added patterns) AND force a re-index by running `ccc index --force` (or the equivalent rebuild flag). If every standard entry is already present, skip the write and skip the forced re-index — the existing index is valid. Record `ccc_exclusions_augmented: {count}` in context for the evidence report.
187
+
188
+ **Note:** Brief-specific `include_patterns` and `exclude_patterns` are NOT written to `settings.yml`. The CCC index is general-purpose — it indexes everything (minus standard artifacts). Brief-specific filtering happens at search result time, not index time. This allows a single workspace CCC index to serve multiple briefs with different scope filters.
189
+
190
+ 3. **Index the clone:** Run `cd {remote_clone_path} && ccc index` with an extended timeout or in background mode. Indexing can take several minutes on large codebases (1000+ files). Use `ccc status` to verify completion — check that `Chunks` and `Files` counts are non-zero. If indexing fails, set `{ccc_discovery: []}` and continue — this is not an error.
191
+
192
+ 4. **Construct semantic query:** Build from brief data: `"{brief.name} {brief.scope}"`. Truncate to 80 characters — keep the full skill name and trim `brief.scope` from the end. If `brief.scope` is very short (< 10 chars), append terms from `brief.description` to fill the remaining space.
193
+
194
+ 5. **Execute search:** Run `ccc_bridge.search(query, remote_clone_path, top_k=20)`:
195
+ - **If existing index was found (step 1):** Use `cd {remote_clone_path} && ccc search --refresh --limit 20 "{query}"` — this re-indexes if files changed, then searches. If `--refresh` is not supported by the installed ccc version, omit the flag — ccc will use the existing index.
196
+ - **Otherwise:** Use `cd {remote_clone_path} && ccc search --limit 20 "{query}"` after indexing in step 3.
197
+ - **Tool resolution:** Use `/ccc` skill search (Claude Code), ccc MCP server (Cursor), or CLI. Note: `ccc search` operates on the index in the current working directory. See `knowledge/tool-resolution.md`.
198
+
199
+ 6. **Store results:** If search succeeds, store as `{ccc_discovery: [{file, score, snippet}]}`. Display: "**CCC semantic discovery: {N} relevant regions identified across {M} unique files.**"
200
+
201
+ If `remote_clone_type == "workspace"` and an existing index was reused, append: "(reused workspace index)"
202
+
203
+ 7. **On failure:** Set `{ccc_discovery: []}`. Display: "CCC discovery unavailable — proceeding with standard extraction." Do NOT halt.
204
+
205
+ **CCC Discovery Integration (Forge+ and Deep with ccc only):**
206
+
207
+ If `{ccc_discovery}` is in context and non-empty (populated by step-02b or deferred discovery above):
208
+ - Sort the filtered file list by CCC relevance score: files appearing in `{ccc_discovery}` results move to the front of the extraction queue, sorted by their relevance score descending
209
+ - Files NOT in CCC results remain in the queue after ranked files — they are not excluded, only deprioritized
210
+ - Display: "**CCC discovery: {N} files pre-ranked by semantic relevance** — extraction will prioritize these first."
211
+
212
+ If `{ccc_discovery}` is empty or not in context: proceed with existing file ordering (no change to current behavior).
213
+
214
+ ### 2c. Component Library Delegation
215
+
216
+ **Skip this section if `source_type` is `"docs-only"` — docs-only skills do not use component extraction.**
217
+
218
+ **If `scope.type: "component-library"` in the brief:**
219
+
220
+ "**Component library detected.** Delegating to specialized extraction strategy for registry-first, props-focused extraction."
221
+
222
+ Load and execute `{componentExtractionStepFile}` completely. When that step completes, it returns control here. Resume at section 5 (Build Extraction Inventory) with the enriched extraction data and `component_catalog[]` from the component extraction step.
223
+
224
+ **Otherwise:** Continue with standard extraction below.
225
+
226
+ ### 3. Check for Docs-Only Mode
227
+
228
+ **If `source_type: "docs-only"` in the brief data:**
229
+
230
+ "**Docs-only mode:** No source code to extract. Documentation content will be fetched from `doc_urls` in step-03c."
231
+
232
+ Build an empty extraction inventory with zero exports. **Set `top_exports = []` explicitly in context** — downstream steps (notably §3b targeted searches and step-04 enrichment fan-out) must see an empty list rather than an undefined/missing field so they can short-circuit deterministically. Set `extraction_mode: "docs-only"` in context. Auto-proceed through Gate 2 (section 6) — display the empty inventory and note that T3 content will be produced by the doc-fetcher step.
233
+
234
+ **If `source_type: "source"` (default):** Continue with extraction below.
235
+
236
+ ### 4. Execute Tier-Dependent Extraction
237
+
238
+ Source resolution, version reconciliation, and CCC discovery were completed in section 2b. Proceed with the tier-specific extraction strategy below.
239
+
240
+ **Quick Tier (No AST tools):**
241
+
242
+ 1. Use `gh_bridge.list_tree(owner, repo, branch)` to map source structure (if remote)
243
+ 2. Identify entry points: index files, main exports, public modules
244
+ 3. Use `gh_bridge.read_file(owner, repo, path)` to read each entry point
245
+ 4. Extract from source text: exported function names, parameter lists, return types
246
+ 5. Infer types from JSDoc, docstrings, type annotations
247
+ 6. Confidence: All results T1-low — `[SRC:{file}:L{line}]`
248
+
249
+ **Tool resolution for gh_bridge:** Use `gh api repos/{owner}/{repo}/git/trees/{branch}?recursive=1` for list_tree, `gh api repos/{owner}/{repo}/contents/{path}` for read_file. If source is local, use direct file listing/reading instead. See `knowledge/tool-resolution.md`.
250
+
251
+ **Forge/Forge+/Deep Tier (AST available):**
252
+
253
+ ⚠️ **CRITICAL:** Before executing AST extraction, load the **AST Extraction Protocol** section from `{extractionPatternsData}`. Follow the decision tree based on the file count from step-01's file tree. This determines whether to use the MCP tool, scoped YAML rules, or CLI streaming. Never use `ast-grep --json` (without `=stream`) — it loads the entire result set into memory and will fail on large codebases. Always use the explicit `run` subcommand with streaming: `ast-grep run -p '{pattern}' --json=stream`.
254
+
255
+ 1. Detect language from brief or file extensions
256
+ 2. Follow the AST Extraction Protocol decision tree from `{extractionPatternsData}`:
257
+ - ≤100 files: use `find_code()` MCP tool with `max_results` and `output_format="text"`
258
+ - ≤500 files: use `find_code_by_rule()` MCP tool with scoped YAML rules
259
+ - >500 files: use CLI `--json=stream` with line-by-line streaming Python — **CRITICAL:** inject the brief's `scope.exclude` patterns into the Python filter's `EXCLUDES` list (use `[]` if absent) so excluded files are discarded before consuming `head -N` slots (see template in extraction patterns data)
260
+ 3. For each export: extract function name, full signature, parameter types, return type, line number
261
+ 4. Use `ast_bridge.detect_co_imports(path, libraries[])` to find integration points
262
+ 5. Build extraction rules YAML data for reproducibility
263
+ 6. Confidence: All results T1 — `[AST:{file}:L{line}]`
264
+
265
+ **Tool resolution for ast_bridge:** Use ast-grep MCP tools (`mcp__ast-grep__find_code`, `mcp__ast-grep__find_code_by_rule`) as specified in the AST Extraction Protocol above, or `ast-grep` CLI. For `detect_co_imports`, use `find_code_by_rule` with a co-import YAML rule scoped to the libraries list. See `knowledge/tool-resolution.md`.
266
+
267
+ **If AST tool is unavailable at Forge/Deep tier** (see `{tierDegradationRulesData}` for full rules):
268
+
269
+ ⚠️ **Warn the user explicitly:** "AST tools are unavailable — extraction will use source reading (T1-low). Run [SF] Setup Forge to detect and configure AST tools for T1 confidence."
270
+
271
+ Degrade to Quick tier extraction. Note the degradation reason in context for the evidence report.
272
+
273
+ **For each file — handle failures gracefully:**
274
+
275
+ - If a file cannot be read: log warning, skip file, continue with remaining files
276
+ - If AST parsing fails on a file: fall back to source reading for that file, continue
277
+
278
+ **Re-export tracing (Forge/Deep only):** After the initial AST scan, check for unresolved public exports from entry points (`__init__.py`, `index.ts`, `lib.rs`). Follow the **Re-Export Tracing** protocol in `{extractionPatternsTracingData}` to resolve them to their definition files.
279
+
280
+ ### 4b. Validate Exports Against Package Entry Point
281
+
282
+ After extraction, validate the collected exports against the package's actual public API surface:
283
+
284
+ - **Python:** Read `{source_root}/__init__.py` — extract imports to build the public export list. Compare against AST results:
285
+ - In AST but not entry point → mark as internal (exclude from `metadata.json` exports)
286
+ - In entry point but not AST → flag as extraction gap (trace via re-export protocol)
287
+ - **TypeScript/JS:** Read `index.ts`/`index.js` — same comparison logic.
288
+ - **Rust:** Read `lib.rs` — extract `pub use` items. Same logic. **Go:** Scan for exported (capitalized) identifiers.
289
+
290
+ Use the entry point as the authoritative source for `metadata.json`'s `exports[]` array.
291
+
292
+ **If entry point is missing or unreadable:** Skip validation with a warning.
293
+
294
+ ### 4c. Detect and Inventory Scripts/Assets
295
+
296
+ **Default resolution:** If `scripts_intent` is absent from the brief, treat as `"detect"` (auto-detection). If `assets_intent` is absent, treat as `"detect"`. Only an explicit `"none"` value disables detection.
297
+
298
+ **If `scripts_intent` is `"none"` AND `assets_intent` is `"none"`:** Skip this section entirely. **If only one is `"none"`:** Skip that category only, proceed with the other.
299
+
300
+ After export extraction, scan the source for scripts and assets using the detection patterns in `{extractionPatternsTracingData}`:
301
+
302
+ 1. Scan source tree for directories/files matching detection heuristics (scripts/, bin/, tools/, cli/ for scripts; assets/, templates/, schemas/, configs/, examples/ for assets)
303
+ 2. For each candidate: verify existence, check size (flag >500 lines), exclude binaries, compute SHA-256 hash
304
+ 3. Extract purpose from header comments, shebang, README references, or schema fields. Record: file_path, purpose, source_path, language/type, content_hash, confidence (T1-low)
305
+
306
+ Add results to `scripts_inventory[]` and `assets_inventory[]` alongside the existing export inventory.
307
+
308
+ ### 5. Build Extraction Inventory
309
+
310
+ Compile all extracted data into a structured inventory:
311
+
312
+ **Per-export entry:**
313
+ - Function/type name
314
+ - Full signature with types
315
+ - Parameters (name, type, required/optional)
316
+ - Return type
317
+ - Source file and line number
318
+ - Provenance citation (`[AST:...]` or `[SRC:...]`)
319
+ - Confidence tier (T1 or T1-low)
320
+
321
+ **Aggregate counts:**
322
+ - Total files scanned
323
+ - Total exports found
324
+ - Exports by type (functions, types/interfaces, constants)
325
+ - Confidence breakdown (T1 count, T1-low count)
326
+ - `top_exports[]` — sorted list of the top 10-20 public API function names by prominence (import frequency or documentation position). This named field is consumed by step-03b for targeted temporal fetching and cache fingerprinting.
327
+
328
+ **Script/asset counts (when detected):**
329
+ - `scripts_found`: count of scripts detected
330
+ - `assets_found`: count of assets detected
331
+
332
+ **Co-import patterns (Forge/Deep only):**
333
+ - Libraries commonly imported alongside extracted exports
334
+ - Integration point suggestions
335
+
336
+ ### 6. Present Extraction Summary (Gate 2)
337
+
338
+ **Docs-only note:** If `docs_only_mode` is active (`extraction_mode: "docs-only"`), display a brief note explaining that T3 content will be added by the doc-fetcher step (step-03c), then auto-proceed past this gate. Example: "Docs-only mode: extraction inventory is empty. Documentation content will be fetched from `doc_urls` in step-03c. Auto-proceeding."
339
+
340
+ Display the extraction findings for user confirmation:
341
+
342
+ "**Extraction complete.**
343
+
344
+ **Files scanned:** {file_count}
345
+ **Exports found:** {export_count} ({function_count} functions, {type_count} types, {constant_count} constants)
346
+ **Confidence:** {t1_count} T1 (AST-verified), {t1_low_count} T1-low (source reading)
347
+ **Tier used:** {tier}
348
+ **Co-import patterns:** {pattern_count} detected
349
+ {if scripts_found > 0: **Scripts detected:** {scripts_found}}
350
+ {if assets_found > 0: **Assets detected:** {assets_found}}
351
+
352
+ **Top exports:**
353
+ {list top 10 exports with signatures}
354
+
355
+ {warnings if any files skipped or degraded}
356
+
357
+ Review the extraction summary above. Select an option to continue."
358
+
359
+ ### 7. Present MENU OPTIONS
360
+
361
+ Display: "**Extraction Summary — Select an Option:** [C] Continue to compilation"
362
+
363
+ #### EXECUTION RULES:
364
+
365
+ - IF docs-only mode (`extraction_mode: "docs-only"`): Auto-proceed immediately to `{nextStepFile}` — no user interaction required
366
+ - OTHERWISE: ALWAYS halt and wait for user input after presenting the extraction summary
367
+ - **GATE [default: C]** — If `{headless_mode}`: auto-proceed with [C] Continue, log: "headless: auto-approve extraction summary"
368
+ - This is Gate 2 — user must confirm before compilation proceeds (except docs-only mode)
369
+ - User may ask questions about the extraction results before continuing
370
+
371
+ #### Menu Handling Logic:
372
+
373
+ - IF C: Confirm extraction inventory is complete. Immediately load, read entire file, then execute `{nextStepFile}`
374
+ - IF Any other comments or queries: answer questions about the extraction results, then redisplay the menu
375
+
376
+ ## CRITICAL STEP COMPLETION NOTE
377
+
378
+ ONLY WHEN the extraction inventory is built with provenance citations and the user has confirmed the extraction summary will you proceed to load `{nextStepFile}` for temporal context fetching.
379
+
@@ -1,8 +1,6 @@
1
1
  ---
2
- name: 'step-03d-component-extraction'
3
- description: 'Component-library extraction strategy — registry detection, props-first extraction, variant consolidation, demo exclusion'
4
2
  returnToStep: './step-03-extract.md'
5
- extractionPatternsData: '../data/extraction-patterns.md'
3
+ extractionPatternsData: 'references/extraction-patterns.md'
6
4
  ---
7
5
 
8
6
  # Step 3d: Component Library Extraction
@@ -11,45 +9,24 @@ extractionPatternsData: '../data/extraction-patterns.md'
11
9
 
12
10
  When `scope.type: "component-library"`, perform specialized extraction that treats the component registry as the primary API surface and props interfaces as API contracts. This step replaces the standard AST extraction flow (step-03 sections 4-4c) and returns control to step-03 section 5 (Build Extraction Inventory).
13
11
 
14
- ## MANDATORY EXECUTION RULES (READ FIRST):
12
+ ## Rules
15
13
 
16
- ### Universal Rules:
17
-
18
- - 📖 CRITICAL: Read the complete step file before taking any action
19
- - 🎯 ALWAYS follow the exact instructions in the step file
20
- - ⚙️ TOOL/SUBPROCESS FALLBACK: If any instruction references a tool you do not have access to, you MUST still achieve the outcome in your main context thread
21
- - ✅ YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
22
-
23
- ### Role Reinforcement:
24
-
25
- - ✅ You are a skill compilation engine performing component-library-specialized extraction
26
- - ✅ Zero hallucination tolerance — every extracted item must trace to source code
27
- - ✅ Component registry is the source of truth for the API surface
28
- - ✅ Props interfaces are the API contracts, not function signatures
29
-
30
- ### Step-Specific Rules:
31
-
32
- - 🎯 Focus ONLY on extracting component catalog, props interfaces, and shared types
33
- - 🚫 FORBIDDEN to compile SKILL.md content — that is step-05
34
- - 🚫 FORBIDDEN to write any output files — extraction stays in context
35
- - 🚫 FORBIDDEN to include content that cannot be cited to a source location
36
- - ⚒️ Every extracted item MUST have a provenance citation: `[AST:{file}:L{line}]` or `[SRC:{file}:L{line}]`
37
-
38
- ## CONTEXT BOUNDARIES:
39
-
40
- - Available: brief_data (including `scope.registry_path`, `scope.ui_variants`, `scope.demo_patterns` if present), tier, source_root (may be `temp_path` from ephemeral clone for remote repos — use the working source path resolved in step-03 section 2a), filtered file list from step-03 section 2, CCC discovery results (if available from step-03 section 2a)
41
- - Focus: Component-specific extraction and inventory building
42
- - Limits: Do NOT compile, assemble, or write output
43
- - Dependencies: Source code accessible (resolved in step-03 section 2a — ephemeral clone for remote repos), scope filters already applied
14
+ - Focus only on extracting component catalog, props interfaces, and shared types
15
+ - Do not compile SKILL.md content (Step 05) or write output files
16
+ - Every extracted item must have a provenance citation: `[AST:{file}:L{line}]` or `[SRC:{file}:L{line}]`
44
17
 
45
18
  ## MANDATORY SEQUENCE
46
19
 
47
20
  **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
48
21
 
22
+ **Prerequisite — §2a already ran.** Step-03 executes `§2a Discovered Authoritative Files Protocol` before delegating to this file. Any promoted authoritative files (`llms.txt`, `AGENTS.md`, etc.) are tracked in the `promoted_docs[]` context list and will be written to `file_entries[]` with `file_type: "doc"` by step-05 §6 — they do NOT appear in the filtered file list that was passed into this step, so Phase 1 demo exclusion below only operates on code files. No special handling is required in this file for promoted docs. See step-03 §2a for the full flow.
23
+
49
24
  ### Phase 1: Demo/Example Exclusion
50
25
 
51
26
  Before extraction, identify and exclude demo/example files to avoid inflating export counts.
52
27
 
28
+ **Note:** For remote sources, the file list from step-03 section 2 was built from the API tree. When scanning for demo directories, scan the local workspace/clone path (`remote_clone_path`) instead of the API-derived file list.
29
+
53
30
  **If `scope.demo_patterns` is specified in the brief:** Use those patterns directly.
54
31
 
55
32
  **Otherwise, auto-detect:**
@@ -65,7 +42,9 @@ Before extraction, identify and exclude demo/example files to avoid inflating ex
65
42
 
66
43
  Confirm exclusion? [Y/n] Or adjust patterns:"
67
44
 
68
- Wait for user response. Apply confirmed patterns to the exclude list. Record `demo_files_excluded: {count}` in context.
45
+ **GATE [default: Y]** if `{headless_mode}` is true: auto-confirm the auto-detected exclusion patterns, log "headless: auto-confirm demo/example exclusion ({N} files, {M} directories)", and append `{step: "step-03d-component-extraction", gate: "demo-exclusion", decision: "Y", value: "{N} files / {M} dirs", rationale: "headless mode — auto-detected demo patterns accepted", timestamp: {ISO}}` to `headless_decisions[]` for evidence-report assembly in step-05 §7. Then proceed without waiting.
46
+
47
+ Wait for user response (interactive only). Apply confirmed patterns to the exclude list. Record `demo_files_excluded: {count}` in context.
69
48
 
70
49
  Update the filtered file list by removing excluded demo files before proceeding.
71
50
 
@@ -106,7 +85,9 @@ Sample entries:
106
85
 
107
86
  Is this the component registry? [Y/n] Or provide the correct path:"
108
87
 
109
- Wait for user response.
88
+ **GATE [default: Y]** — if `{headless_mode}` is true AND `score >= 7` (high-confidence candidate): auto-confirm the registry candidate, log "headless: auto-confirm registry candidate `{path}` (score {score}/9)", and append `{step: "step-03d-component-extraction", gate: "registry-confirm", decision: "Y", value: "{path} score={score}/9", rationale: "headless mode — high-confidence registry candidate auto-accepted", timestamp: {ISO}}` to `headless_decisions[]`. If `score < 7` in headless mode, auto-reject the candidate (treat as "no registry found"), log "headless: auto-reject low-confidence registry candidate (score {score}/9) — below auto-accept threshold 7", record the decision, and fall through to the "no registry found" branch below. Confidence threshold 7 matches the minimum score the heuristic considers "probable enough to risk" without human eyes.
89
+
90
+ Wait for user response (interactive only).
110
91
 
111
92
  **If no registry found and no `registry_path` in brief:**
112
93
 
@@ -114,7 +95,9 @@ Wait for user response.
114
95
  - **[P]** Provide the registry file path
115
96
  - **[S]** Skip registry — proceed with standard props-first extraction only"
116
97
 
117
- Wait for user response.
98
+ **GATE [default: S]** — if `{headless_mode}` is true: auto-select [S] Skip (props-first extraction without registry), log "headless: no registry detected, auto-skip to props-first extraction (no path was provided in brief.scope.registry_path)", and append `{step: "step-03d-component-extraction", gate: "provide-or-skip-registry", decision: "S", rationale: "headless mode — no human to provide registry path", timestamp: {ISO}}` to `headless_decisions[]`. The default is `[S]` rather than `[P]` because providing a path requires user input that headless cannot supply; skipping degrades gracefully to a smaller but valid extraction.
99
+
100
+ Wait for user response (interactive only).
118
101
 
119
102
  ### Phase 3: Parse Registry
120
103
 
@@ -1,6 +1,4 @@
1
1
  ---
2
- name: 'step-04-enrich'
3
- description: 'QMD knowledge enrichment for extracted functions — Deep tier only, skip for Quick/Forge/Forge+'
4
2
  nextStepFile: './step-05-compile.md'
5
3
  ---
6
4
 
@@ -10,42 +8,12 @@ nextStepFile: './step-05-compile.md'
10
8
 
11
9
  To enrich the extraction inventory with temporal context from QMD knowledge searches — issues, PRs, changelogs, and migration notes that add T2-confidence annotations to extracted functions. Deep tier only; Quick, Forge, and Forge+ tiers skip this step entirely.
12
10
 
13
- ## MANDATORY EXECUTION RULES (READ FIRST):
11
+ ## Rules
14
12
 
15
- ### Universal Rules:
16
-
17
- - 📖 CRITICAL: Read the complete step file before taking any action
18
- - 🎯 ALWAYS follow the exact instructions in the step file
19
- - ⚙️ TOOL/SUBPROCESS FALLBACK: If any instruction references a tool you do not have access to, you MUST still achieve the outcome in your main context thread
20
- - ✅ YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
21
-
22
- ### Role Reinforcement:
23
-
24
- - ✅ You are a skill compilation engine performing knowledge enrichment
25
- - ✅ QMD enrichment adds temporal depth — it never replaces AST extraction
26
- - ✅ Enrichment failure is graceful degradation, not an error
27
-
28
- ### Step-Specific Rules:
29
-
30
- - 🎯 Focus ONLY on QMD searches to annotate extracted functions
31
- - 🚫 FORBIDDEN to modify extraction results — enrichment is additive only
32
- - 🚫 FORBIDDEN to begin compilation — that's step-05
33
- - 💬 QMD failures degrade gracefully — continue without enrichment
34
- - ⏱️ Quick, Forge, and Forge+ tiers: skip this step entirely, auto-proceed
35
-
36
- ## EXECUTION PROTOCOLS:
37
-
38
- - 🎯 Follow MANDATORY SEQUENCE exactly
39
- - 💾 Enrichment annotations are added to extraction inventory in context
40
- - 📖 QMD results become T2-confidence annotations
41
- - 🚫 Never replace T1 extraction data with QMD findings
42
-
43
- ## CONTEXT BOUNDARIES:
44
-
45
- - Available: extraction_inventory from step-03, brief_data, tier from step-01
46
- - Focus: Adding temporal context to extracted functions
47
- - Limits: Do NOT modify extraction results, only annotate them
48
- - Dependencies: Extraction inventory must exist from step-03
13
+ - Focus only on QMD searches to annotate extracted functions — enrichment is additive only
14
+ - Do not begin compilation (Step 05)
15
+ - QMD failures degrade gracefully continue without enrichment
16
+ - Quick, Forge, and Forge+ tiers: skip this step entirely, auto-proceed
49
17
 
50
18
  ## MANDATORY SEQUENCE
51
19
 
@@ -88,15 +56,17 @@ For each function, derive the **module context** from the extraction inventory's
88
56
 
89
57
  **Primary searches (BM25 — always runs, no GPU/VRAM dependency):**
90
58
 
91
- 1. **Issues/PRs:** `qmd_bridge.search("{module_context} {function_name}")` — find related discussions scoped by module context
92
- 2. **Changelog entries:** `qmd_bridge.search("{function_name} changelog")` — find version history, breaking changes (kept generic — changelogs rarely use module paths)
93
- 3. **Migration notes:** `qmd_bridge.search("{function_name} migration deprecated breaking")` — find deprecation or migration context using exact keyword matching
59
+ 1. **Issues/PRs:** `qmd_bridge.query(searches=[{type:'lex', query:'{module_context} {function_name}', intent:'issues-prs'}])` — find related discussions scoped by module context
60
+ 2. **Changelog entries:** `qmd_bridge.query(searches=[{type:'lex', query:'{function_name} changelog', intent:'changelog'}])` — find version history, breaking changes (kept generic — changelogs rarely use module paths)
61
+ 3. **Migration notes:** `qmd_bridge.query(searches=[{type:'lex', query:'{function_name} migration deprecated breaking', intent:'migration'}])` — find deprecation or migration context using exact keyword matching
94
62
 
95
63
  **Supplemental search (best-effort — requires GPU/VRAM, may fail):**
96
64
 
97
- 4. **Semantic migration context:** `qmd_bridge.vector_search("{module_context} {function_name} migration deprecated")` — adds semantic matches (synonyms, paraphrases) that BM25 keyword search may miss. Merge results with search #3, deduplicating by document ID. If `vector_search` fails (VRAM, GPU driver, model loading), discard silently — the BM25 results from search #3 provide baseline coverage.
65
+ 4. **Semantic migration context:** `qmd_bridge.query(searches=[{type:'vec', query:'{module_context} {function_name} migration deprecated', intent:'semantic-migration'}])` — adds semantic matches (synonyms, paraphrases) that BM25 keyword search may miss. Merge results with search #3, deduplicating by document ID. If the `vec`-type search fails (VRAM, GPU driver, model loading), discard silently — the BM25 (`lex`) results from search #3 provide baseline coverage.
98
66
 
99
- **Tool resolution for qmd_bridge:** Use QMD MCP tools — `mcp__plugin_qmd-plugin_qmd__search` for BM25 search, `mcp__plugin_qmd-plugin_qmd__vector_search` for semantic search (Claude Code). Cursor: qmd MCP server. CLI: `qmd search "{query}"` / `qmd vector_search "{query}"`. See [knowledge/tool-resolution.md](../../../knowledge/tool-resolution.md).
67
+ **Tool resolution for qmd_bridge:** QMD MCP exposes a single `query` tool that accepts a `searches[]` array. Each entry has a `type` field — `'lex'` for BM25 keyword search, `'vec'` for semantic vector search, `'hyde'` for hypothetical-document retrieval — plus `query` and `intent` fields. Claude Code: `mcp__plugin_qmd-plugin_qmd__query`. Cursor: qmd MCP server. CLI: `qmd search "{query}"` (BM25) / `qmd vector-search "{query}"` (semantic). See `knowledge/tool-resolution.md`.
68
+
69
+ **Tool probe (graceful degradation):** If any tool-not-found error surfaces while invoking `query` (e.g., legacy `vector_search` still expected by an older client, or a bridge returns "tool not registered"), treat it as a non-fatal failure for that function's enrichment and continue with the remaining functions. Do NOT retry against the stale `vector_search` tool name — that name was removed from the QMD MCP server. Record the degradation in context for the evidence report.
100
70
 
101
71
  **For each QMD result:**
102
72
 
@@ -155,30 +125,3 @@ After enrichment is complete (or skipped for non-Deep tiers), immediately load,
155
125
 
156
126
  ONLY WHEN enrichment is complete (Deep tier) or the step is skipped (Quick/Forge/Forge+) will you proceed to load `{nextStepFile}` for SKILL.md compilation.
157
127
 
158
- ---
159
-
160
- ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
161
-
162
- ### ✅ SUCCESS:
163
-
164
- - Quick/Forge/Forge+ tiers: skipped silently with no output, auto-proceeded
165
- - Deep tier: collection inventory checked before searching
166
- - Deep tier: no temporal collections → reported and auto-proceeded (not silently skipped)
167
- - Deep tier: temporal collections exist → QMD searches performed per public API function (10-20, not all exports) with module context derived from extraction inventory source paths
168
- - T2 annotations added with proper provenance citations
169
- - Extraction data unmodified — enrichment is additive only
170
- - QMD failures handled gracefully (skip and continue)
171
- - Auto-proceeded to step-05
172
-
173
- ### ❌ SYSTEM FAILURE:
174
-
175
- - Halting on QMD unavailability or search failures
176
- - Modifying T1 extraction results with QMD data
177
- - Displaying skip messages for Quick/Forge/Forge+ tiers (should be silent)
178
- - Pre-emptively skipping all searches without checking the collection inventory
179
- - Searching all 800+ exports instead of scoping to public API surface (10-20)
180
- - Using bare function names without module context when source path is available in extraction inventory
181
- - Beginning compilation or SKILL.md assembly in this step
182
- - Not labeling QMD annotations as T2 confidence
183
-
184
- **Master Rule:** Enrichment is additive and optional. QMD adds temporal depth but never replaces structural extraction. Failures degrade gracefully.