bmad-module-skill-forge 0.2.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 (154) hide show
  1. package/.nvmrc +1 -0
  2. package/LICENSE +26 -0
  3. package/README.md +213 -0
  4. package/docs/404.md +20 -0
  5. package/docs/agents.md +73 -0
  6. package/docs/architecture.md +301 -0
  7. package/docs/examples.md +144 -0
  8. package/docs/getting-started.md +198 -0
  9. package/docs/index.md +75 -0
  10. package/docs/workflows.md +190 -0
  11. package/package.json +109 -0
  12. package/src/agents/forger.agent.yaml +93 -0
  13. package/src/forger/README.md +17 -0
  14. package/src/forger/forge-tier.yaml +13 -0
  15. package/src/forger/preferences.yaml +10 -0
  16. package/src/knowledge/agentskills-spec.md +158 -0
  17. package/src/knowledge/confidence-tiers.md +153 -0
  18. package/src/knowledge/manual-section-integrity.md +156 -0
  19. package/src/knowledge/overview.md +56 -0
  20. package/src/knowledge/progressive-capability.md +120 -0
  21. package/src/knowledge/provenance-tracking.md +163 -0
  22. package/src/knowledge/skf-knowledge-index.csv +9 -0
  23. package/src/knowledge/skill-lifecycle.md +150 -0
  24. package/src/knowledge/zero-hallucination.md +101 -0
  25. package/src/module-help.csv +12 -0
  26. package/src/module.yaml +22 -0
  27. package/src/workflows/README.md +148 -0
  28. package/src/workflows/analyze-source/data/skill-brief-schema.md +75 -0
  29. package/src/workflows/analyze-source/data/unit-detection-heuristics.md +88 -0
  30. package/src/workflows/analyze-source/steps-c/step-01-init.md +191 -0
  31. package/src/workflows/analyze-source/steps-c/step-01b-continue.md +144 -0
  32. package/src/workflows/analyze-source/steps-c/step-02-scan-project.md +208 -0
  33. package/src/workflows/analyze-source/steps-c/step-03-identify-units.md +199 -0
  34. package/src/workflows/analyze-source/steps-c/step-04-map-and-detect.md +222 -0
  35. package/src/workflows/analyze-source/steps-c/step-05-recommend.md +236 -0
  36. package/src/workflows/analyze-source/steps-c/step-06-generate-briefs.md +239 -0
  37. package/src/workflows/analyze-source/templates/analysis-report-template.md +41 -0
  38. package/src/workflows/analyze-source/validation-report.md +657 -0
  39. package/src/workflows/analyze-source/workflow-plan-analyze-source.md +385 -0
  40. package/src/workflows/analyze-source/workflow.md +61 -0
  41. package/src/workflows/audit-skill/data/drift-report-template.md +62 -0
  42. package/src/workflows/audit-skill/data/severity-rules.md +52 -0
  43. package/src/workflows/audit-skill/steps-c/step-01-init.md +195 -0
  44. package/src/workflows/audit-skill/steps-c/step-02-re-index.md +191 -0
  45. package/src/workflows/audit-skill/steps-c/step-03-structural-diff.md +194 -0
  46. package/src/workflows/audit-skill/steps-c/step-04-semantic-diff.md +199 -0
  47. package/src/workflows/audit-skill/steps-c/step-05-severity-classify.md +210 -0
  48. package/src/workflows/audit-skill/steps-c/step-06-report.md +217 -0
  49. package/src/workflows/audit-skill/validation-report.md +545 -0
  50. package/src/workflows/audit-skill/workflow-plan-audit-skill.md +318 -0
  51. package/src/workflows/audit-skill/workflow.md +63 -0
  52. package/src/workflows/brief-skill/data/skill-brief-schema.md +82 -0
  53. package/src/workflows/brief-skill/steps-c/step-01-gather-intent.md +184 -0
  54. package/src/workflows/brief-skill/steps-c/step-02-analyze-target.md +203 -0
  55. package/src/workflows/brief-skill/steps-c/step-03-scope-definition.md +225 -0
  56. package/src/workflows/brief-skill/steps-c/step-04-confirm-brief.md +185 -0
  57. package/src/workflows/brief-skill/steps-c/step-05-write-brief.md +156 -0
  58. package/src/workflows/brief-skill/validation-report.md +630 -0
  59. package/src/workflows/brief-skill/workflow-plan-brief-skill.md +360 -0
  60. package/src/workflows/brief-skill/workflow.md +57 -0
  61. package/src/workflows/create-skill/data/extraction-patterns.md +63 -0
  62. package/src/workflows/create-skill/data/skill-sections.md +166 -0
  63. package/src/workflows/create-skill/steps-c/step-01-load-brief.md +176 -0
  64. package/src/workflows/create-skill/steps-c/step-02-ecosystem-check.md +143 -0
  65. package/src/workflows/create-skill/steps-c/step-03-extract.md +184 -0
  66. package/src/workflows/create-skill/steps-c/step-04-enrich.md +152 -0
  67. package/src/workflows/create-skill/steps-c/step-05-compile.md +198 -0
  68. package/src/workflows/create-skill/steps-c/step-06-validate.md +162 -0
  69. package/src/workflows/create-skill/steps-c/step-07-generate-artifacts.md +165 -0
  70. package/src/workflows/create-skill/steps-c/step-08-report.md +160 -0
  71. package/src/workflows/create-skill/validation-report.md +189 -0
  72. package/src/workflows/create-skill/workflow-plan-create-skill.md +491 -0
  73. package/src/workflows/create-skill/workflow.md +52 -0
  74. package/src/workflows/create-stack-skill/data/integration-patterns.md +61 -0
  75. package/src/workflows/create-stack-skill/data/manifest-patterns.md +35 -0
  76. package/src/workflows/create-stack-skill/data/stack-skill-template.md +110 -0
  77. package/src/workflows/create-stack-skill/steps-c/step-01-init.md +142 -0
  78. package/src/workflows/create-stack-skill/steps-c/step-02-detect-manifests.md +145 -0
  79. package/src/workflows/create-stack-skill/steps-c/step-03-rank-and-confirm.md +161 -0
  80. package/src/workflows/create-stack-skill/steps-c/step-04-parallel-extract.md +155 -0
  81. package/src/workflows/create-stack-skill/steps-c/step-05-detect-integrations.md +154 -0
  82. package/src/workflows/create-stack-skill/steps-c/step-06-compile-stack.md +160 -0
  83. package/src/workflows/create-stack-skill/steps-c/step-07-generate-output.md +202 -0
  84. package/src/workflows/create-stack-skill/steps-c/step-08-validate.md +193 -0
  85. package/src/workflows/create-stack-skill/steps-c/step-09-report.md +137 -0
  86. package/src/workflows/create-stack-skill/validation-report.md +401 -0
  87. package/src/workflows/create-stack-skill/workflow-plan-create-stack-skill.md +481 -0
  88. package/src/workflows/create-stack-skill/workflow.md +59 -0
  89. package/src/workflows/export-skill/data/managed-section-format.md +70 -0
  90. package/src/workflows/export-skill/data/snippet-format.md +32 -0
  91. package/src/workflows/export-skill/steps-c/step-01-load-skill.md +184 -0
  92. package/src/workflows/export-skill/steps-c/step-02-package.md +153 -0
  93. package/src/workflows/export-skill/steps-c/step-03-generate-snippet.md +166 -0
  94. package/src/workflows/export-skill/steps-c/step-04-update-context.md +222 -0
  95. package/src/workflows/export-skill/steps-c/step-05-token-report.md +126 -0
  96. package/src/workflows/export-skill/steps-c/step-06-summary.md +167 -0
  97. package/src/workflows/export-skill/validation-report.md +263 -0
  98. package/src/workflows/export-skill/workflow-plan-export-skill.md +369 -0
  99. package/src/workflows/export-skill/workflow.md +56 -0
  100. package/src/workflows/quick-skill/data/registry-resolution.md +91 -0
  101. package/src/workflows/quick-skill/data/skill-template.md +66 -0
  102. package/src/workflows/quick-skill/steps-c/step-01-resolve-target.md +165 -0
  103. package/src/workflows/quick-skill/steps-c/step-02-ecosystem-check.md +143 -0
  104. package/src/workflows/quick-skill/steps-c/step-03-quick-extract.md +177 -0
  105. package/src/workflows/quick-skill/steps-c/step-04-compile.md +180 -0
  106. package/src/workflows/quick-skill/steps-c/step-05-validate.md +150 -0
  107. package/src/workflows/quick-skill/steps-c/step-06-write.md +160 -0
  108. package/src/workflows/quick-skill/validation-report.md +543 -0
  109. package/src/workflows/quick-skill/workflow-plan-quick-skill.md +405 -0
  110. package/src/workflows/quick-skill/workflow.md +56 -0
  111. package/src/workflows/setup-forge/data/tier-rules.md +50 -0
  112. package/src/workflows/setup-forge/steps-c/step-01-detect-and-tier.md +140 -0
  113. package/src/workflows/setup-forge/steps-c/step-02-write-config.md +141 -0
  114. package/src/workflows/setup-forge/steps-c/step-03-auto-index.md +116 -0
  115. package/src/workflows/setup-forge/steps-c/step-04-report.md +131 -0
  116. package/src/workflows/setup-forge/validation-report.md +504 -0
  117. package/src/workflows/setup-forge/workflow-plan-setup-forge.md +428 -0
  118. package/src/workflows/setup-forge/workflow.md +49 -0
  119. package/src/workflows/test-skill/data/output-section-formats.md +96 -0
  120. package/src/workflows/test-skill/data/scoring-rules.md +74 -0
  121. package/src/workflows/test-skill/steps-c/step-01-init.md +185 -0
  122. package/src/workflows/test-skill/steps-c/step-02-detect-mode.md +162 -0
  123. package/src/workflows/test-skill/steps-c/step-03-coverage-check.md +222 -0
  124. package/src/workflows/test-skill/steps-c/step-04-coherence-check.md +249 -0
  125. package/src/workflows/test-skill/steps-c/step-05-score.md +222 -0
  126. package/src/workflows/test-skill/steps-c/step-06-report.md +175 -0
  127. package/src/workflows/test-skill/templates/test-report-template.md +24 -0
  128. package/src/workflows/test-skill/validation-report.md +390 -0
  129. package/src/workflows/test-skill/workflow-plan-test-skill.md +288 -0
  130. package/src/workflows/test-skill/workflow.md +57 -0
  131. package/src/workflows/update-skill/data/manual-section-rules.md +44 -0
  132. package/src/workflows/update-skill/data/merge-conflict-rules.md +62 -0
  133. package/src/workflows/update-skill/steps-c/step-01-init.md +208 -0
  134. package/src/workflows/update-skill/steps-c/step-02-detect-changes.md +184 -0
  135. package/src/workflows/update-skill/steps-c/step-03-re-extract.md +187 -0
  136. package/src/workflows/update-skill/steps-c/step-04-merge.md +230 -0
  137. package/src/workflows/update-skill/steps-c/step-05-validate.md +187 -0
  138. package/src/workflows/update-skill/steps-c/step-06-write.md +204 -0
  139. package/src/workflows/update-skill/steps-c/step-07-report.md +201 -0
  140. package/src/workflows/update-skill/validation-report.md +559 -0
  141. package/src/workflows/update-skill/workflow-plan-update-skill.md +441 -0
  142. package/src/workflows/update-skill/workflow.md +56 -0
  143. package/tools/cli/commands/install.js +33 -0
  144. package/tools/cli/commands/status.js +195 -0
  145. package/tools/cli/commands/uninstall.js +226 -0
  146. package/tools/cli/commands/update.js +63 -0
  147. package/tools/cli/lib/compiler.js +306 -0
  148. package/tools/cli/lib/ide-commands.js +244 -0
  149. package/tools/cli/lib/installer.js +307 -0
  150. package/tools/cli/lib/manifest.js +109 -0
  151. package/tools/cli/lib/ui.js +277 -0
  152. package/tools/cli/lib/version-check.js +86 -0
  153. package/tools/cli/skf-cli.js +45 -0
  154. package/tools/skf-npx-wrapper.js +36 -0
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: 'step-01-load-brief'
3
+ description: 'Load skill-brief.yaml, validate structure, resolve source code location, load forge tier'
4
+ nextStepFile: './step-02-ecosystem-check.md'
5
+ forgeTierFile: '{project-root}/_bmad/_memory/forger-sidecar/forge-tier.yaml'
6
+ preferencesFile: '{project-root}/_bmad/_memory/forger-sidecar/preferences.yaml'
7
+ ---
8
+
9
+ # Step 1: Load Brief
10
+
11
+ ## STEP GOAL:
12
+
13
+ To load and validate the skill-brief.yaml compilation config, resolve the source code location, and load the forge tier from sidecar to determine available capabilities for the compilation pipeline.
14
+
15
+ ## MANDATORY EXECUTION RULES (READ FIRST):
16
+
17
+ ### Universal Rules:
18
+
19
+ - 📖 CRITICAL: Read the complete step file before taking any action
20
+ - 🎯 ALWAYS follow the exact instructions in the step file
21
+ - ⚙️ 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
22
+ - ✅ YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
23
+
24
+ ### Role Reinforcement:
25
+
26
+ - ✅ You are a skill compilation engine performing initialization
27
+ - ✅ This is an autonomous init step — no user interaction needed
28
+ - ✅ Load data, validate structure, resolve paths, determine capabilities
29
+
30
+ ### Step-Specific Rules:
31
+
32
+ - 🎯 Focus ONLY on loading brief, resolving source, and determining tier
33
+ - 🚫 FORBIDDEN to begin extraction or compilation — that's steps 03-05
34
+ - 🚫 FORBIDDEN to write any output files — this step only loads and validates
35
+ - 💬 Report initialization status clearly
36
+
37
+ ## EXECUTION PROTOCOLS:
38
+
39
+ - 🎯 Follow MANDATORY SEQUENCE exactly
40
+ - 💾 All loaded data remains in context for subsequent steps
41
+ - 📖 Validate brief structure before proceeding
42
+ - 🚫 Halt with actionable error if prerequisites are missing
43
+
44
+ ## CONTEXT BOUNDARIES:
45
+
46
+ - Available: User's skill name or brief path from Ferris menu invocation
47
+ - Focus: Loading inputs and determining capabilities
48
+ - Limits: Do NOT begin any extraction or compilation work
49
+ - Dependencies: forge-tier.yaml must exist (from setup-forge workflow)
50
+
51
+ ## MANDATORY SEQUENCE
52
+
53
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
54
+
55
+ ### 1. Load Forge Tier
56
+
57
+ Load `{forgeTierFile}` completely.
58
+
59
+ **If file does not exist:**
60
+ Halt with: "Forge halted: No forge configuration found. Run [SF] Setup Forge first to detect tools and set your tier."
61
+
62
+ **If file exists:**
63
+ Extract and report:
64
+ - `tier`: Quick, Forge, or Deep
65
+ - `tools`: which tools are available (gh, ast-grep, qmd)
66
+ - `tier_override`: if set, use override tier instead of detected
67
+
68
+ Check for `tier_override` in `{preferencesFile}`. If `tier_override` is set and differs from detected tier, use the override value.
69
+
70
+ ### 2. Discover Skill Brief
71
+
72
+ **If user provided a specific brief path or skill name:**
73
+ - Search `{project-root}/forge-data/{skill-name}/skill-brief.yaml`
74
+ - If found, load it completely
75
+
76
+ **If user invoked with --batch flag:**
77
+ - Search specified directory for all `skill-brief.yaml` files
78
+ - List discovered briefs with skill names
79
+ - Store list for batch loop processing
80
+ - For this run, load the FIRST brief (batch loops back for remaining)
81
+
82
+ **If no brief found:**
83
+ Halt with: "No skill brief found. Run [BS] Brief Skill to create one, or use [QS] Quick Skill for brief-less generation."
84
+
85
+ ### 3. Validate Brief Structure
86
+
87
+ Check that the loaded skill-brief.yaml contains required fields:
88
+
89
+ **Required fields:**
90
+ - `name` — skill identifier (kebab-case)
91
+ - `version` — source version to compile against
92
+ - `source_repo` — GitHub owner/repo or local path
93
+ - `language` — primary source language
94
+ - `scope` — what to extract (e.g., "all public exports", specific modules)
95
+
96
+ **Optional fields:**
97
+ - `source_branch` — branch to use (default: main/master)
98
+ - `source_authority` — official/community/internal (default: community)
99
+ - `include_patterns` — file glob patterns to include
100
+ - `exclude_patterns` — file glob patterns to exclude
101
+ - `description` — human description of the skill
102
+
103
+ **If required fields missing:**
104
+ Halt with specific error: "Brief validation failed: missing required field `{field}`. Update your skill-brief.yaml and re-run."
105
+
106
+ ### 4. Resolve Source Code Location
107
+
108
+ **If source_repo is a GitHub URL or owner/repo format:**
109
+ - Verify repository exists via `gh_bridge.list_tree(owner, repo, branch)`
110
+ - If branch not specified, detect default branch
111
+ - Store resolved: owner, repo, branch, file tree
112
+
113
+ **If source_repo is a local path:**
114
+ - Verify path exists and contains source files
115
+ - Store resolved: local path, file listing
116
+
117
+ **If source cannot be resolved:**
118
+ Halt with: "Source not found: `{source_repo}`. Verify the repository exists and is accessible."
119
+
120
+ ### 5. Report Initialization
121
+
122
+ Display initialization summary:
123
+
124
+ "**Forge initialized.**
125
+
126
+ **Skill:** {name} v{version}
127
+ **Source:** {source_repo} @ {branch}
128
+ **Language:** {language}
129
+ **Scope:** {scope}
130
+ **Tier:** {tier} — {tier_description}
131
+ **Tools:** {available_tools_list}
132
+
133
+ Proceeding to ecosystem check..."
134
+
135
+ Where tier_description follows positive capability framing:
136
+ - Quick: "Source reading and spec validation"
137
+ - Forge: "AST-backed structural extraction"
138
+ - Deep: "Full intelligence — structural + contextual + temporal"
139
+
140
+ ### 6. Menu Handling Logic
141
+
142
+ **Auto-proceed step — no user interaction.**
143
+
144
+ After initialization is complete and all data is loaded, immediately load, read entire file, then execute `{nextStepFile}`.
145
+
146
+ #### EXECUTION RULES:
147
+
148
+ - This is an auto-proceed initialization step with no user choices
149
+ - Proceed directly to next step after successful initialization
150
+ - If any prerequisite check fails, HALT with actionable error — do NOT proceed
151
+
152
+ ## CRITICAL STEP COMPLETION NOTE
153
+
154
+ ONLY WHEN forge-tier.yaml is loaded, skill-brief.yaml is validated, and source code location is resolved will you proceed to load `{nextStepFile}` for ecosystem check.
155
+
156
+ ---
157
+
158
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
159
+
160
+ ### ✅ SUCCESS:
161
+
162
+ - Forge tier loaded from sidecar with tool availability
163
+ - Skill brief loaded and all required fields validated
164
+ - Source code location resolved and accessible
165
+ - Initialization summary displayed with tier and capabilities
166
+ - Auto-proceeded to step-02
167
+
168
+ ### ❌ SYSTEM FAILURE:
169
+
170
+ - Proceeding without forge-tier.yaml (missing prerequisite)
171
+ - Proceeding with invalid or incomplete brief
172
+ - Not resolving source code location before proceeding
173
+ - Beginning extraction or compilation work in this step
174
+ - Not displaying initialization summary
175
+
176
+ **Master Rule:** This step ONLY loads and validates. It does NOT extract, compile, or write files.
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: 'step-02-ecosystem-check'
3
+ description: 'Check agentskills.io ecosystem for existing official skill before compilation'
4
+ nextStepFile: './step-03-extract.md'
5
+ ---
6
+
7
+ # Step 2: Ecosystem Check
8
+
9
+ ## STEP GOAL:
10
+
11
+ To search the agentskills.io ecosystem for an existing official skill matching the brief, advise the user if one is found, and allow them to decide whether to proceed with compilation or install the existing skill.
12
+
13
+ ## MANDATORY EXECUTION RULES (READ FIRST):
14
+
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 ecosystem discovery
25
+ - ✅ This step is advisory — ecosystem check results never block compilation
26
+ - ✅ Tool unavailability is never an error — it's a graceful skip condition
27
+
28
+ ### Step-Specific Rules:
29
+
30
+ - 🎯 Focus ONLY on ecosystem search and presenting findings
31
+ - 🚫 FORBIDDEN to begin any extraction or compilation work
32
+ - 🚫 FORBIDDEN to halt the workflow if the ecosystem check fails or times out
33
+ - 💬 If a match is found, present it factually — let the user decide
34
+ - ⏱️ Enforce 5-second timeout on ecosystem queries
35
+
36
+ ## EXECUTION PROTOCOLS:
37
+
38
+ - 🎯 Follow MANDATORY SEQUENCE exactly
39
+ - 💾 All loaded data remains in context for subsequent steps
40
+ - 📖 Ecosystem check is advisory — never blocking
41
+ - 🚫 Do not modify any files — this step only queries and reports
42
+
43
+ ## CONTEXT BOUNDARIES:
44
+
45
+ - Available: brief_data (name, version, source_repo, language, scope) and tier from step-01
46
+ - Focus: Searching for existing skills in the ecosystem
47
+ - Limits: Do NOT begin extraction, compilation, or file writing
48
+ - Dependencies: skill-brief.yaml must be loaded and validated from step-01
49
+
50
+ ## MANDATORY SEQUENCE
51
+
52
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
53
+
54
+ ### 1. Check Ecosystem for Existing Skill
55
+
56
+ **If skills_ref tool is available:**
57
+
58
+ Query the ecosystem using the skill name from the brief:
59
+ - `skills_ref.check_ecosystem(brief.name)`
60
+ - Enforce 5-second timeout — if the query does not return within 5 seconds, treat as no match
61
+ - Cache results for 24 hours (if re-running same skill)
62
+
63
+ **If skills_ref tool is NOT available:**
64
+
65
+ Skip silently. Tool unavailability is not an error. Proceed as if no match was found.
66
+
67
+ ### 2. Evaluate Results
68
+
69
+ **If match found (official skill exists):**
70
+
71
+ Present the finding to the user:
72
+
73
+ "**Ecosystem match found.**
74
+
75
+ **Existing skill:** {matched_skill_name} v{matched_version}
76
+ **Source:** {matched_source}
77
+ **Authority:** {official/community}
78
+ **Compatibility:** {compatibility_notes}
79
+
80
+ An existing skill already covers this source. You can:
81
+ - **[P] Proceed** — compile your own version anyway (useful for customization or different scope)
82
+ - **[I] Install** — install the existing skill instead of compiling
83
+ - **[A] Abort** — cancel this compilation"
84
+
85
+ **If no match found:**
86
+
87
+ Auto-proceed silently to next step. Do not display any message about the ecosystem check — absence of a match is the expected case.
88
+
89
+ **If timeout or error:**
90
+
91
+ Auto-proceed silently. Log a note in context: "Ecosystem check skipped (timeout/error) — proceeding with compilation."
92
+
93
+ ### 3. Menu Handling Logic
94
+
95
+ **Conditional menu — only displayed if a match was found.**
96
+
97
+ #### If Match Found — Present MENU OPTIONS:
98
+
99
+ Display: "**Ecosystem match found — Select an Option:** [P] Proceed with compilation [I] Install existing [A] Abort"
100
+
101
+ #### EXECUTION RULES:
102
+
103
+ - ALWAYS halt and wait for user input after presenting menu
104
+ - This menu ONLY appears when an ecosystem match is found
105
+ - If no match, timeout, or tool unavailable — auto-proceed with no menu
106
+
107
+ #### Menu Handling Logic:
108
+
109
+ - IF P: Note user's decision to proceed despite existing skill. Immediately load, read entire file, then execute `{nextStepFile}`
110
+ - IF I: Display: "Install the existing skill using: `[SF] Setup Forge → install {matched_skill_name}`" then halt workflow. Do not proceed to extraction.
111
+ - IF A: Display: "Compilation aborted. Return to Ferris menu to select another action." then halt workflow.
112
+ - IF no match/timeout/error: Auto-proceed — immediately load, read entire file, then execute `{nextStepFile}`
113
+ - IF Any other comments or queries: help user respond then redisplay the menu
114
+
115
+ ## CRITICAL STEP COMPLETION NOTE
116
+
117
+ ONLY WHEN the ecosystem check is complete (match evaluated, user decision made if applicable) will you proceed to load `{nextStepFile}` for source extraction.
118
+
119
+ If no match is found, this step auto-proceeds with no user interaction.
120
+
121
+ ---
122
+
123
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
124
+
125
+ ### ✅ SUCCESS:
126
+
127
+ - Ecosystem check attempted (or gracefully skipped if tool unavailable)
128
+ - 5-second timeout enforced on ecosystem queries
129
+ - Match presented factually with clear options if found
130
+ - No-match case auto-proceeds silently
131
+ - User decision respected (Proceed/Install/Abort)
132
+ - Auto-proceeded to step-03 (when no match or user chose Proceed)
133
+
134
+ ### ❌ SYSTEM FAILURE:
135
+
136
+ - Halting the workflow because ecosystem check failed or timed out
137
+ - Treating tool unavailability as an error
138
+ - Displaying "no match found" messages (absence should be silent)
139
+ - Beginning extraction or compilation work in this step
140
+ - Proceeding without user decision when a match IS found
141
+ - Not enforcing the 5-second timeout
142
+
143
+ **Master Rule:** This step is advisory. Tool failures and timeouts are silent skips, not errors. Only a confirmed match requires user interaction.
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: 'step-03-extract'
3
+ description: 'Tier-dependent source code extraction — AST or source reading for exports, signatures, and types'
4
+ nextStepFile: './step-04-enrich.md'
5
+ extractionPatternsData: '../data/extraction-patterns.md'
6
+ ---
7
+
8
+ # Step 3: Extract
9
+
10
+ ## STEP GOAL:
11
+
12
+ 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.
13
+
14
+ ## MANDATORY EXECUTION RULES (READ FIRST):
15
+
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 structural extraction
26
+ - ✅ Zero hallucination tolerance — every extracted item must trace to source code
27
+ - ✅ Confidence tier labeling is mandatory for every extraction result
28
+
29
+ ### Step-Specific Rules:
30
+
31
+ - 🎯 Focus ONLY on extracting exports, signatures, types from source code
32
+ - 🚫 FORBIDDEN to compile SKILL.md content — that's step-05
33
+ - 🚫 FORBIDDEN to write any output files — extraction stays in context
34
+ - 🚫 FORBIDDEN to include content that cannot be cited to a source location
35
+ - ⚒️ Every extracted item MUST have a provenance citation: `[AST:{file}:L{line}]` or `[SRC:{file}:L{line}]`
36
+
37
+ ## EXECUTION PROTOCOLS:
38
+
39
+ - 🎯 Follow MANDATORY SEQUENCE exactly
40
+ - 💾 Build extraction inventory in context — do not write files
41
+ - 📖 Load extraction patterns data file for tier-specific strategy
42
+ - 🚫 If an export cannot be verified, exclude it — do not guess
43
+
44
+ ## CONTEXT BOUNDARIES:
45
+
46
+ - Available: brief_data, tier, source_location, file_tree from step-01; ecosystem_status from step-02
47
+ - Focus: Source code extraction and inventory building
48
+ - Limits: Do NOT compile, assemble, or write any output
49
+ - Dependencies: Source code must be accessible (resolved in step-01)
50
+
51
+ ## MANDATORY SEQUENCE
52
+
53
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
54
+
55
+ ### 1. Load Extraction Patterns
56
+
57
+ Load `{extractionPatternsData}` completely. Identify the strategy for the current forge tier.
58
+
59
+ ### 2. Apply Scope Filters
60
+
61
+ From the brief, apply scope and pattern filters:
62
+
63
+ - `scope` — determines what to extract (e.g., "all public exports", specific modules)
64
+ - `include_patterns` — file globs to include (if specified)
65
+ - `exclude_patterns` — file globs to exclude (if specified)
66
+
67
+ Build the filtered file list from the source tree resolved in step-01.
68
+
69
+ ### 3. Execute Tier-Dependent Extraction
70
+
71
+ **Quick Tier (No AST tools):**
72
+
73
+ 1. Use `gh_bridge.list_tree(owner, repo, branch)` to map source structure (if remote)
74
+ 2. Identify entry points: index files, main exports, public modules
75
+ 3. Use `gh_bridge.read_file(owner, repo, path)` to read each entry point
76
+ 4. Extract from source text: exported function names, parameter lists, return types
77
+ 5. Infer types from JSDoc, docstrings, type annotations
78
+ 6. Confidence: All results T1-low — `[SRC:{file}:L{line}]`
79
+
80
+ **Forge/Deep Tier (AST available):**
81
+
82
+ 1. Detect language from brief or file extensions
83
+ 2. Use `ast_bridge.scan_definitions(path, language)` for each file in scope
84
+ 3. For each export: extract function name, full signature, parameter types, return type, line number
85
+ 4. Use `ast_bridge.detect_co_imports(path, libraries[])` to find integration points
86
+ 5. Build extraction rules YAML data for reproducibility
87
+ 6. Confidence: All results T1 — `[AST:{file}:L{line}]`
88
+
89
+ **If AST tool is unavailable at Forge/Deep tier:**
90
+
91
+ Degrade to Quick tier extraction silently. Note the degradation in context for the evidence report.
92
+
93
+ **For each file — handle failures gracefully:**
94
+
95
+ - If a file cannot be read: log warning, skip file, continue with remaining files
96
+ - If AST parsing fails on a file: fall back to source reading for that file, continue
97
+
98
+ ### 4. Build Extraction Inventory
99
+
100
+ Compile all extracted data into a structured inventory:
101
+
102
+ **Per-export entry:**
103
+ - Function/type name
104
+ - Full signature with types
105
+ - Parameters (name, type, required/optional)
106
+ - Return type
107
+ - Source file and line number
108
+ - Provenance citation (`[AST:...]` or `[SRC:...]`)
109
+ - Confidence tier (T1 or T1-low)
110
+
111
+ **Aggregate counts:**
112
+ - Total files scanned
113
+ - Total exports found
114
+ - Exports by type (functions, types/interfaces, constants)
115
+ - Confidence breakdown (T1 count, T1-low count)
116
+
117
+ **Co-import patterns (Forge/Deep only):**
118
+ - Libraries commonly imported alongside extracted exports
119
+ - Integration point suggestions
120
+
121
+ ### 5. Present Extraction Summary (Gate 2)
122
+
123
+ Display the extraction findings for user confirmation:
124
+
125
+ "**Extraction complete.**
126
+
127
+ **Files scanned:** {file_count}
128
+ **Exports found:** {export_count} ({function_count} functions, {type_count} types, {constant_count} constants)
129
+ **Confidence:** {t1_count} T1 (AST-verified), {t1_low_count} T1-low (source reading)
130
+ **Tier used:** {tier}
131
+ **Co-import patterns:** {pattern_count} detected
132
+
133
+ **Top exports:**
134
+ {list top 10 exports with signatures}
135
+
136
+ {warnings if any files skipped or degraded}
137
+
138
+ Review the extraction summary above. Select an option to continue."
139
+
140
+ ### 6. Present MENU OPTIONS
141
+
142
+ Display: "**Extraction Summary — Select an Option:** [C] Continue to compilation"
143
+
144
+ #### EXECUTION RULES:
145
+
146
+ - ALWAYS halt and wait for user input after presenting the extraction summary
147
+ - This is Gate 2 — user must confirm before compilation proceeds
148
+ - User may ask questions about the extraction results before continuing
149
+
150
+ #### Menu Handling Logic:
151
+
152
+ - IF C: Confirm extraction inventory is complete. Immediately load, read entire file, then execute `{nextStepFile}`
153
+ - IF Any other comments or queries: answer questions about the extraction results, then redisplay the menu
154
+
155
+ ## CRITICAL STEP COMPLETION NOTE
156
+
157
+ 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 QMD enrichment.
158
+
159
+ ---
160
+
161
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
162
+
163
+ ### ✅ SUCCESS:
164
+
165
+ - Extraction patterns loaded and tier-appropriate strategy applied
166
+ - Scope filters applied from brief
167
+ - All accessible source files in scope scanned
168
+ - Every extracted item has a provenance citation with confidence tier
169
+ - Extraction inventory built with aggregate counts
170
+ - Graceful degradation if AST tools unavailable
171
+ - Gate 2 summary presented with export counts and confidence breakdown
172
+ - User confirmed before proceeding
173
+
174
+ ### ❌ SYSTEM FAILURE:
175
+
176
+ - Including exports without provenance citations
177
+ - Guessing or hallucinating function signatures not in source
178
+ - Not applying scope/include/exclude filters from the brief
179
+ - Halting on individual file read failures instead of skipping
180
+ - Not presenting Gate 2 summary for user confirmation
181
+ - Beginning compilation or SKILL.md assembly in this step
182
+ - Not reporting confidence tier breakdown
183
+
184
+ **Master Rule:** Zero hallucination — every extraction must trace to source code. Uncitable content is excluded, not guessed.
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: 'step-04-enrich'
3
+ description: 'QMD knowledge enrichment for extracted functions — Deep tier only, skip for Quick/Forge'
4
+ nextStepFile: './step-05-compile.md'
5
+ ---
6
+
7
+ # Step 4: Enrich
8
+
9
+ ## STEP GOAL:
10
+
11
+ 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 and Forge tiers skip this step entirely.
12
+
13
+ ## MANDATORY EXECUTION RULES (READ FIRST):
14
+
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 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
49
+
50
+ ## MANDATORY SEQUENCE
51
+
52
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
53
+
54
+ ### 1. Check Tier Eligibility
55
+
56
+ **If tier is Quick or Forge:**
57
+
58
+ Auto-proceed silently. Display no message. Immediately load, read entire file, then execute `{nextStepFile}`.
59
+
60
+ **If tier is Deep:**
61
+
62
+ Continue to step 2.
63
+
64
+ ### 2. QMD Enrichment Searches (Deep Tier Only)
65
+
66
+ For each major exported function in the extraction inventory, search QMD collections for temporal context:
67
+
68
+ **Search targets per function:**
69
+
70
+ 1. **Issues/PRs:** `qmd_bridge.search("{function_name}")` — find related discussions, bug reports, feature requests
71
+ 2. **Changelog entries:** `qmd_bridge.search("{function_name} changelog")` — find version history, breaking changes
72
+ 3. **Migration notes:** `qmd_bridge.vector_search("{function_name} migration deprecated")` — find deprecation or migration context
73
+
74
+ **For each QMD result:**
75
+
76
+ - Create a T2 annotation: `[QMD:{collection}:{doc}]`
77
+ - Classify temporal relevance:
78
+ - **T2-past:** Historical context (why it was built, what it replaced)
79
+ - **T2-future:** Forward-looking context (planned changes, deprecation warnings)
80
+
81
+ **Handling QMD failures:**
82
+
83
+ - If qmd_bridge is unavailable: skip all enrichment, note in context
84
+ - If individual search fails: skip that function's enrichment, continue with others
85
+ - If QMD returns no results for a function: no annotation added (absence is normal)
86
+
87
+ ### 3. Annotate Extraction Inventory
88
+
89
+ Add enrichment annotations to the extraction inventory without modifying extraction data:
90
+
91
+ **Per-function enrichment (if found):**
92
+ - Related issues/PRs with summary
93
+ - Changelog history (version changes, breaking changes)
94
+ - Migration/deprecation context
95
+ - T2 provenance citation for each annotation
96
+
97
+ **Enrichment summary counts:**
98
+ - Functions enriched: {count} of {total}
99
+ - T2 annotations added: {count}
100
+ - T2-past annotations: {count}
101
+ - T2-future annotations: {count}
102
+
103
+ ### 4. Report Enrichment (Deep Tier Only)
104
+
105
+ Display brief enrichment summary:
106
+
107
+ "**Enrichment complete.**
108
+
109
+ **Functions enriched:** {enriched_count} of {total_count}
110
+ **T2 annotations:** {t2_count} ({t2_past} historical, {t2_future} forward-looking)
111
+
112
+ Proceeding to compilation..."
113
+
114
+ ### 5. Menu Handling Logic
115
+
116
+ **Auto-proceed step — no user interaction.**
117
+
118
+ After enrichment is complete (or skipped for non-Deep tiers), immediately load, read entire file, then execute `{nextStepFile}`.
119
+
120
+ #### EXECUTION RULES:
121
+
122
+ - This is an auto-proceed step with no user choices
123
+ - Quick/Forge tiers skip directly to next step with no output
124
+ - Deep tier displays brief enrichment summary then auto-proceeds
125
+ - QMD failures do not halt — degrade and proceed
126
+
127
+ ## CRITICAL STEP COMPLETION NOTE
128
+
129
+ ONLY WHEN enrichment is complete (Deep tier) or the step is skipped (Quick/Forge) will you proceed to load `{nextStepFile}` for SKILL.md compilation.
130
+
131
+ ---
132
+
133
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
134
+
135
+ ### ✅ SUCCESS:
136
+
137
+ - Quick/Forge tiers: skipped silently with no output, auto-proceeded
138
+ - Deep tier: QMD searches performed per extracted function
139
+ - T2 annotations added with proper provenance citations
140
+ - Extraction data unmodified — enrichment is additive only
141
+ - QMD failures handled gracefully (skip and continue)
142
+ - Auto-proceeded to step-05
143
+
144
+ ### ❌ SYSTEM FAILURE:
145
+
146
+ - Halting on QMD unavailability or search failures
147
+ - Modifying T1 extraction results with QMD data
148
+ - Displaying skip messages for Quick/Forge tiers (should be silent)
149
+ - Beginning compilation or SKILL.md assembly in this step
150
+ - Not labeling QMD annotations as T2 confidence
151
+
152
+ **Master Rule:** Enrichment is additive and optional. QMD adds temporal depth but never replaces structural extraction. Failures degrade gracefully.