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,195 @@
1
+ ---
2
+ name: 'step-01-init'
3
+ description: 'Load existing skill, provenance map, and detect forge tier for drift analysis'
4
+
5
+ nextStepFile: './step-02-re-index.md'
6
+ outputFile: '{forge_data_folder}/{skill_name}/drift-report-{timestamp}.md'
7
+ templateFile: '../data/drift-report-template.md'
8
+ ---
9
+
10
+ # Step 1: Initialize Audit
11
+
12
+ ## STEP GOAL:
13
+
14
+ Load the existing skill artifacts, provenance map, and forge tier configuration to establish the baseline for drift detection. Create the drift report document and present a baseline summary for user confirmation before proceeding with analysis.
15
+
16
+ ## MANDATORY EXECUTION RULES (READ FIRST):
17
+
18
+ ### Universal Rules:
19
+
20
+ - 🛑 NEVER generate content without user input
21
+ - 📖 CRITICAL: Read the complete step file before taking any action
22
+ - 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
23
+ - 📋 YOU ARE A FACILITATOR, not a content generator
24
+ - ⚙️ TOOL/SUBPROCESS FALLBACK: If any instruction references a subprocess, subagent, or tool you do not have access to, you MUST still achieve the outcome in your main context thread
25
+ - ✅ YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
26
+
27
+ ### Role Reinforcement:
28
+
29
+ - ✅ You are a skill auditor operating in Ferris Audit mode
30
+ - ✅ Every finding must trace to actual code with file:line citations
31
+ - ✅ You enforce the zero-hallucination principle: structural truth over semantic guessing
32
+ - ✅ You bring AST analysis expertise, the source code provides ground truth
33
+
34
+ ### Step-Specific Rules:
35
+
36
+ - 🎯 Focus only on loading skill artifacts and establishing the baseline
37
+ - 🚫 FORBIDDEN to perform any diff or analysis — that happens in later steps
38
+ - 🚫 FORBIDDEN to proceed if skill path is invalid or SKILL.md not found
39
+ - 💬 Present baseline summary clearly so user can confirm before analysis begins
40
+
41
+ ## EXECUTION PROTOCOLS:
42
+
43
+ - 🎯 Discover and load all required input artifacts
44
+ - 💾 Create drift report from {templateFile} with populated frontmatter
45
+ - 📖 Track loaded artifacts in report frontmatter
46
+ - 🚫 Do not proceed to analysis without user confirmation at the gate
47
+
48
+ ## CONTEXT BOUNDARIES:
49
+
50
+ - Available: User-provided skill path, SKF module config variables
51
+ - Focus: Loading and validating all inputs needed for drift analysis
52
+ - Limits: Do not analyze or compare — only load and baseline
53
+ - Dependencies: setup-forge must be completed (forge-tier.yaml exists), skill must have been created by create-skill (provenance-map.json exists)
54
+
55
+ ## MANDATORY SEQUENCE
56
+
57
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise unless user explicitly requests a change.
58
+
59
+ ### 1. Get Skill Path
60
+
61
+ "**Audit Skill — Drift Detection**
62
+
63
+ Which skill would you like to audit? Please provide the skill name or path."
64
+
65
+ **If user provides skill name (not full path):**
66
+ - Resolve to `{skills_output_folder}/{skill_name}/`
67
+
68
+ **If user provides full path:**
69
+ - Use as provided
70
+
71
+ **Validate:** Check that `SKILL.md` exists at the resolved path.
72
+ - If missing → "Skill not found at `{resolved_path}`. Check the path and try again."
73
+ - If found → Continue
74
+
75
+ ### 2. Load Forge Tier
76
+
77
+ Load `{sidecar_path}/forge-tier.yaml` to detect available tools.
78
+
79
+ **If file missing:**
80
+ - "Setup-forge has not been run. Cannot determine tool availability. Run `[SF] Setup Forge` first."
81
+ - HALT workflow
82
+
83
+ **If found:**
84
+ - Extract tier level: Quick / Forge / Deep
85
+ - Extract available tools: gh_bridge, ast_bridge, qmd_bridge
86
+
87
+ ### 3. Load Skill Artifacts
88
+
89
+ Load the following from the skill directory:
90
+
91
+ **Required:**
92
+ - `SKILL.md` — The skill document to audit
93
+ - `metadata.json` — Skill metadata (version, created date, export count)
94
+
95
+ **Extract from metadata.json:**
96
+ - `skill_name`, `version`, `created` date, `forge_tier` used during creation
97
+ - `source_root` — Original source code path
98
+
99
+ ### 4. Load Provenance Map
100
+
101
+ Search for provenance map at `{forge_data_folder}/{skill_name}/provenance-map.json`
102
+
103
+ **If found:**
104
+ - Load and extract: export list, file mappings, extraction timestamps, confidence tiers
105
+ - Record provenance map age (days since last extraction)
106
+
107
+ **If missing:**
108
+ - "No provenance map found for `{skill_name}`. This skill may not have been created by create-skill."
109
+ - "**Degraded mode available:** I can perform text-based comparison without provenance data. Findings will have T1-low confidence."
110
+ - "**[D]egraded mode** — proceed with text-diff only"
111
+ - "**[X]** — abort audit"
112
+ - Wait for user selection. If D, set `degraded_mode: true`. If X, halt workflow.
113
+
114
+ ### 5. Resolve Source Path
115
+
116
+ **If provenance map loaded:**
117
+ - Use `source_root` from provenance map as source code path
118
+ - Verify source path still exists and is accessible
119
+
120
+ **If degraded mode:**
121
+ - Ask user: "Please provide the path to the current source code."
122
+
123
+ **Validate:** Confirm source directory exists and contains expected files.
124
+
125
+ ### 6. Create Drift Report
126
+
127
+ Create `{outputFile}` from `{templateFile}`:
128
+
129
+ - Populate frontmatter: skill_name, skill_path, source_path, forge_tier, date, user_name
130
+ - Set `stepsCompleted: ['step-01-init']`
131
+ - Fill Audit Summary skeleton with loaded baseline data
132
+
133
+ ### 7. Present Baseline Summary (User Gate)
134
+
135
+ "**Audit Baseline Loaded**
136
+
137
+ | Field | Value |
138
+ |-------|-------|
139
+ | **Skill** | {skill_name} v{version} |
140
+ | **Created** | {created_date} |
141
+ | **Source** | {source_path} |
142
+ | **Forge Tier** | {current_tier} (created at {original_tier}) |
143
+ | **Provenance Age** | {days} days since last extraction |
144
+ | **Export Count** | {count} exports in provenance map |
145
+ | **Mode** | {normal / degraded} |
146
+
147
+ **Analysis plan based on tier:**
148
+ - {Quick: text-diff comparison (T1-low confidence)}
149
+ - {Forge: AST structural comparison (T1 confidence)}
150
+ - {Deep: AST structural + QMD semantic comparison (T1 + T2 confidence)}
151
+
152
+ **Ready to begin drift analysis?**"
153
+
154
+ ### 8. Present MENU OPTIONS
155
+
156
+ Display: "**Select:** [C] Continue to Analysis"
157
+
158
+ #### Menu Handling Logic:
159
+
160
+ - IF C: Save baseline to {outputFile}, update frontmatter stepsCompleted, then load, read entire file, then execute {nextStepFile}
161
+ - IF Any other: help user, then [Redisplay Menu Options](#8-present-menu-options)
162
+
163
+ #### EXECUTION RULES:
164
+
165
+ - ALWAYS halt and wait for user input after presenting menu
166
+ - ONLY proceed to next step when user selects 'C'
167
+
168
+ ## CRITICAL STEP COMPLETION NOTE
169
+
170
+ ONLY WHEN C is selected and the drift report has been created with baseline data populated, will you then load and read fully `{nextStepFile}` to execute and begin source re-indexing.
171
+
172
+ ---
173
+
174
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
175
+
176
+ ### ✅ SUCCESS:
177
+
178
+ - Skill artifacts loaded (SKILL.md, metadata.json)
179
+ - Forge tier detected from sidecar
180
+ - Provenance map loaded (or degraded mode confirmed)
181
+ - Source path resolved and validated
182
+ - Drift report created from template with populated frontmatter
183
+ - Baseline summary presented to user
184
+ - User confirmed via [C] Continue
185
+
186
+ ### ❌ SYSTEM FAILURE:
187
+
188
+ - Proceeding without valid skill path
189
+ - Not loading provenance map or offering degraded mode
190
+ - Not detecting forge tier
191
+ - Performing analysis in this step (analysis is Steps 02-05)
192
+ - Proceeding without user confirmation at the gate
193
+ - Hardcoded paths instead of frontmatter variables
194
+
195
+ **Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: 'step-02-re-index'
3
+ description: 'Re-scan source code with current tier tools to build fresh extraction snapshot'
4
+
5
+ nextStepFile: './step-03-structural-diff.md'
6
+ outputFile: '{forge_data_folder}/{skill_name}/drift-report-{timestamp}.md'
7
+ ---
8
+
9
+ # Step 2: Re-Index Source
10
+
11
+ ## STEP GOAL:
12
+
13
+ Re-scan the source code using the current forge tier tools to build a fresh extraction snapshot. This snapshot will be compared against the original provenance map in Step 03 to detect structural drift.
14
+
15
+ ## MANDATORY EXECUTION RULES (READ FIRST):
16
+
17
+ ### Universal Rules:
18
+
19
+ - 🛑 NEVER generate content without user input
20
+ - 📖 CRITICAL: Read the complete step file before taking any action
21
+ - 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
22
+ - ⚙️ TOOL/SUBPROCESS FALLBACK: If any instruction references a subprocess, subagent, or tool you do not have access to, you MUST still achieve the outcome in your main context thread
23
+ - ✅ YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
24
+
25
+ ### Role Reinforcement:
26
+
27
+ - ✅ You are a skill auditor operating in Ferris Audit mode
28
+ - ✅ Every extraction must be precise — file paths, line numbers, signatures
29
+ - ✅ You enforce zero-hallucination: only extract what actually exists in source
30
+
31
+ ### Step-Specific Rules:
32
+
33
+ - 🎯 Focus only on extracting current source state — do NOT compare yet
34
+ - 🚫 FORBIDDEN to perform any diff or comparison — that happens in Step 03
35
+ - 🚫 FORBIDDEN to skip files or take shortcuts in extraction
36
+ - 💬 Use subprocess Pattern 2 (per-file deep analysis) when available for AST extraction
37
+ - ⚙️ If subprocess unavailable, perform extraction in main thread file by file
38
+
39
+ ## EXECUTION PROTOCOLS:
40
+
41
+ - 🎯 Extract all public exports from source using tier-appropriate tools
42
+ - 💾 Store current extraction as internal state for Step 03
43
+ - 📖 Update {outputFile} frontmatter stepsCompleted when complete
44
+ - 🚫 Do not append analysis sections to drift report — only update frontmatter
45
+
46
+ ## CONTEXT BOUNDARIES:
47
+
48
+ - Available: Source path, forge tier, tool availability (from Step 01)
49
+ - Focus: Building a complete current-state extraction snapshot
50
+ - Limits: Extract only — no comparison, no judgment, no severity
51
+ - Dependencies: Step 01 must have loaded skill baseline and validated source path
52
+
53
+ ## MANDATORY SEQUENCE
54
+
55
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise unless user explicitly requests a change.
56
+
57
+ ### 1. Determine Extraction Strategy
58
+
59
+ Based on forge tier detected in Step 01:
60
+
61
+ **Quick tier (no AST tools):**
62
+ - Read source files via gh_bridge or direct file I/O
63
+ - Extract export names by text pattern matching (function/class/type declarations)
64
+ - Confidence label: T1-low
65
+
66
+ **Forge tier (ast-grep available):**
67
+ - Use ast_bridge to perform AST extraction per source file
68
+ - Extract: export name, type (function/class/type/const), full signature, file path, line number
69
+ - Confidence label: T1
70
+
71
+ **Deep tier (ast-grep + QMD available):**
72
+ - Forge extraction (above) PLUS
73
+ - Query qmd_bridge for temporal context: when exports were added, modification history, usage frequency
74
+ - Confidence labels: T1 for structural, T2 for temporal context
75
+
76
+ ### 2. Scan Source Files
77
+
78
+ Identify all source files in the source directory that contain public exports.
79
+
80
+ "**Scanning source files...**"
81
+
82
+ - List all relevant source files (exclude test files, config files, build artifacts)
83
+ - Count files to process
84
+ - Report: "Found {count} source files to extract."
85
+
86
+ ### 3. Extract Current Exports
87
+
88
+ **DO NOT BE LAZY — For EACH source file, launch a subprocess that:**
89
+ 1. Loads the source file
90
+ 2. Extracts all public exports using tier-appropriate method
91
+ 3. Records: export name, type, signature, file path, line number, confidence tier
92
+ 4. Returns structured findings to parent
93
+
94
+ **If subprocess unavailable:** Perform extraction in main thread, processing each file sequentially.
95
+
96
+ **Build extraction snapshot:**
97
+ ```
98
+ {
99
+ "extraction_date": "{timestamp}",
100
+ "forge_tier": "{tier}",
101
+ "source_root": "{source_path}",
102
+ "files_scanned": {count},
103
+ "exports": [
104
+ {
105
+ "name": "{export_name}",
106
+ "type": "function|class|type|const|interface",
107
+ "signature": "{full signature}",
108
+ "file": "{relative_path}",
109
+ "line": {line_number},
110
+ "confidence": "T1|T1-low|T2"
111
+ }
112
+ ]
113
+ }
114
+ ```
115
+
116
+ ### 4. Deep Tier Enhancement (Deep Only)
117
+
118
+ **IF forge tier is Deep:**
119
+
120
+ Query qmd_bridge for temporal context on each extracted export:
121
+ - When was this export first added?
122
+ - Has it been modified recently?
123
+ - What is its usage frequency across the codebase?
124
+
125
+ Append temporal metadata to each export in the snapshot.
126
+
127
+ **IF forge tier is Quick or Forge:**
128
+ Skip this section. Temporal context requires Deep tier.
129
+
130
+ ### 5. Validate Extraction Completeness
131
+
132
+ "**Extraction complete.**
133
+
134
+ | Metric | Value |
135
+ |--------|-------|
136
+ | Files scanned | {count} |
137
+ | Exports found | {total_exports} |
138
+ | Functions | {function_count} |
139
+ | Classes | {class_count} |
140
+ | Types/Interfaces | {type_count} |
141
+ | Constants | {const_count} |
142
+ | Confidence | {T1/T1-low/T2} |
143
+
144
+ **Proceeding to structural comparison...**"
145
+
146
+ ### 6. Update Report and Auto-Proceed
147
+
148
+ Update {outputFile} frontmatter:
149
+ - Append `'step-02-re-index'` to `stepsCompleted`
150
+
151
+ ### 7. Present MENU OPTIONS
152
+
153
+ Display: "**Proceeding to structural diff...**"
154
+
155
+ #### Menu Handling Logic:
156
+
157
+ - After extraction is complete and frontmatter updated, immediately load, read entire file, then execute {nextStepFile}
158
+
159
+ #### EXECUTION RULES:
160
+
161
+ - This is an auto-proceed analysis step with no user choices
162
+ - Proceed directly to next step after extraction
163
+
164
+ ## CRITICAL STEP COMPLETION NOTE
165
+
166
+ ONLY WHEN the extraction snapshot is complete with all source files processed will you then load and read fully `{nextStepFile}` to execute and begin structural comparison.
167
+
168
+ ---
169
+
170
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
171
+
172
+ ### ✅ SUCCESS:
173
+
174
+ - All source files scanned (none skipped)
175
+ - All public exports extracted with file:line references
176
+ - Confidence tier labels applied to every extraction
177
+ - Tier-appropriate tools used (AST for Forge+, text for Quick)
178
+ - Deep tier temporal context added if applicable
179
+ - Extraction snapshot complete and validated
180
+ - Frontmatter stepsCompleted updated
181
+
182
+ ### ❌ SYSTEM FAILURE:
183
+
184
+ - Skipping source files or being lazy with extraction
185
+ - Not recording file:line references for each export
186
+ - Performing comparison in this step (comparison is Step 03)
187
+ - Missing confidence tier labels
188
+ - Hardcoded paths instead of frontmatter variables
189
+ - Not using subprocess Pattern 2 when available
190
+
191
+ **Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: 'step-03-structural-diff'
3
+ description: 'Compare original provenance map extractions against current scan to detect structural drift'
4
+
5
+ nextStepFile: './step-04-semantic-diff.md'
6
+ outputFile: '{forge_data_folder}/{skill_name}/drift-report-{timestamp}.md'
7
+ ---
8
+
9
+ # Step 3: Structural Diff
10
+
11
+ ## STEP GOAL:
12
+
13
+ Compare the original provenance map extractions from create-skill against the current re-index snapshot from Step 02 to detect structural drift. Identify added, removed, and changed exports with file:line citations and confidence tier labels.
14
+
15
+ ## MANDATORY EXECUTION RULES (READ FIRST):
16
+
17
+ ### Universal Rules:
18
+
19
+ - 🛑 NEVER generate content without user input
20
+ - 📖 CRITICAL: Read the complete step file before taking any action
21
+ - 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
22
+ - ⚙️ TOOL/SUBPROCESS FALLBACK: If any instruction references a subprocess, subagent, or tool you do not have access to, you MUST still achieve the outcome in your main context thread
23
+ - ✅ YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
24
+
25
+ ### Role Reinforcement:
26
+
27
+ - ✅ You are a skill auditor performing structural comparison
28
+ - ✅ Every drift finding must have a file:line citation from either the provenance map or current scan
29
+ - ✅ Zero hallucination — only report drift that is structurally verifiable
30
+
31
+ ### Step-Specific Rules:
32
+
33
+ - 🎯 Focus only on structural comparison — added/removed/changed exports
34
+ - 🚫 FORBIDDEN to classify severity — that happens in Step 05
35
+ - 🚫 FORBIDDEN to suggest remediation — that happens in Step 06
36
+ - 💬 Use subprocess Pattern 4 (parallel execution) when available to compare export categories simultaneously
37
+ - ⚙️ If subprocess unavailable, compare categories sequentially in main thread
38
+
39
+ ## EXECUTION PROTOCOLS:
40
+
41
+ - 🎯 Compare provenance map exports against current extraction snapshot
42
+ - 💾 Append ## Structural Drift section to {outputFile}
43
+ - 📖 Update {outputFile} frontmatter stepsCompleted when complete
44
+ - 🚫 Only structural findings — no semantic or severity analysis
45
+
46
+ ## CONTEXT BOUNDARIES:
47
+
48
+ - Available: Provenance map (from Step 01), current extraction snapshot (from Step 02), forge tier
49
+ - Focus: Structural export-level comparison only
50
+ - Limits: Do not classify severity, do not analyze semantics, do not suggest fixes
51
+ - Dependencies: Steps 01 and 02 must be complete
52
+
53
+ ## MANDATORY SEQUENCE
54
+
55
+ **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise unless user explicitly requests a change.
56
+
57
+ ### 1. Prepare Comparison Sets
58
+
59
+ Load both datasets:
60
+
61
+ **Baseline (from provenance map):**
62
+ - Export list with names, types, signatures, file paths, line numbers
63
+
64
+ **Current (from Step 02 extraction):**
65
+ - Export list with names, types, signatures, file paths, line numbers
66
+
67
+ Normalize both sets for comparison:
68
+ - Match by export name (primary key)
69
+ - Group by file for location-aware comparison
70
+
71
+ ### 2. Detect Added Exports
72
+
73
+ **Launch subprocess (Pattern 4 — parallel execution):**
74
+
75
+ Find exports that exist in current scan but NOT in provenance map.
76
+
77
+ For each added export, record:
78
+ - Export name, type, signature
79
+ - File path and line number (from current scan)
80
+ - Confidence tier (T1 if AST-backed, T1-low if text-based)
81
+
82
+ **If subprocess unavailable:** Iterate current exports, check against provenance map set.
83
+
84
+ ### 3. Detect Removed Exports
85
+
86
+ Find exports that exist in provenance map but NOT in current scan.
87
+
88
+ For each removed export, record:
89
+ - Export name, type, signature (from provenance map)
90
+ - Original file path and line number
91
+ - Confidence tier (T1 if AST-backed, T1-low if text-based)
92
+
93
+ **Special check:** If export name exists but in a different file, classify as MOVED (not removed).
94
+
95
+ ### 4. Detect Changed Exports
96
+
97
+ Find exports that exist in BOTH sets but have differences.
98
+
99
+ Compare:
100
+ - **Signature changes:** Parameter count, parameter types, return type
101
+ - **Type changes:** Function became class, const became function, etc.
102
+ - **Location changes:** Same name/signature but different file or line number (MOVED)
103
+
104
+ For each changed export, record:
105
+ - Export name
106
+ - Original signature → Current signature
107
+ - Original location → Current location
108
+ - What changed (signature / type / location)
109
+ - Confidence tier
110
+
111
+ ### 5. Compile Structural Drift Section
112
+
113
+ Append to {outputFile}:
114
+
115
+ ```markdown
116
+ ## Structural Drift
117
+
118
+ **Comparison:** Provenance map ({provenance_date}) vs Current scan ({scan_date})
119
+ **Method:** {Quick: text-diff / Forge: AST structural / Deep: AST structural}
120
+
121
+ ### Added Exports ({count})
122
+
123
+ | Export | Type | Signature | Location | Confidence |
124
+ |--------|------|-----------|----------|------------|
125
+ | {name} | {type} | {signature} | {file}:{line} | {T1/T1-low} |
126
+
127
+ ### Removed Exports ({count})
128
+
129
+ | Export | Type | Original Signature | Original Location | Confidence |
130
+ |--------|------|-------------------|-------------------|------------|
131
+ | {name} | {type} | {signature} | {file}:{line} | {T1/T1-low} |
132
+
133
+ ### Changed Exports ({count})
134
+
135
+ | Export | Change Type | Before | After | Location | Confidence |
136
+ |--------|------------|--------|-------|----------|------------|
137
+ | {name} | {signature/type/location} | {old} | {new} | {file}:{line} | {T1/T1-low} |
138
+
139
+ ### Summary
140
+
141
+ | Category | Count |
142
+ |----------|-------|
143
+ | Added | {added_count} |
144
+ | Removed | {removed_count} |
145
+ | Changed | {changed_count} |
146
+ | **Total Drift Items** | {total} |
147
+ ```
148
+
149
+ ### 6. Update Report and Auto-Proceed
150
+
151
+ Update {outputFile} frontmatter:
152
+ - Append `'step-03-structural-diff'` to `stepsCompleted`
153
+
154
+ ### 7. Present MENU OPTIONS
155
+
156
+ Display: "**Structural diff complete. {total} drift items found. Proceeding to semantic diff...**"
157
+
158
+ #### Menu Handling Logic:
159
+
160
+ - After structural diff section is appended and frontmatter updated, immediately load, read entire file, then execute {nextStepFile}
161
+
162
+ #### EXECUTION RULES:
163
+
164
+ - This is an auto-proceed analysis step with no user choices
165
+ - Proceed directly to next step after completion
166
+
167
+ ## CRITICAL STEP COMPLETION NOTE
168
+
169
+ ONLY WHEN the ## Structural Drift section has been appended to {outputFile} with all findings documented will you then load and read fully `{nextStepFile}` to execute and begin semantic diff analysis.
170
+
171
+ ---
172
+
173
+ ## 🚨 SYSTEM SUCCESS/FAILURE METRICS
174
+
175
+ ### ✅ SUCCESS:
176
+
177
+ - All three categories compared: added, removed, changed
178
+ - Every finding has file:line citation
179
+ - Confidence tier labels on all findings
180
+ - Moved exports distinguished from removed+added
181
+ - Structured table format in drift report
182
+ - Summary counts accurate
183
+ - Frontmatter stepsCompleted updated
184
+
185
+ ### ❌ SYSTEM FAILURE:
186
+
187
+ - Missing any comparison category (added/removed/changed)
188
+ - Findings without file:line citations
189
+ - Missing confidence tier labels
190
+ - Classifying severity in this step (severity is Step 05)
191
+ - Not detecting moved exports (false removed + false added)
192
+ - Hardcoded paths instead of frontmatter variables
193
+
194
+ **Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.