spec-gen-cli 1.2.6 → 1.2.8

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 (198) hide show
  1. package/README.md +175 -55
  2. package/dist/api/analyze.d.ts.map +1 -1
  3. package/dist/api/analyze.js +6 -1
  4. package/dist/api/analyze.js.map +1 -1
  5. package/dist/api/audit.d.ts +10 -0
  6. package/dist/api/audit.d.ts.map +1 -0
  7. package/dist/api/audit.js +117 -0
  8. package/dist/api/audit.js.map +1 -0
  9. package/dist/api/generate.d.ts.map +1 -1
  10. package/dist/api/generate.js +10 -1
  11. package/dist/api/generate.js.map +1 -1
  12. package/dist/api/index.d.ts +3 -2
  13. package/dist/api/index.d.ts.map +1 -1
  14. package/dist/api/index.js +1 -0
  15. package/dist/api/index.js.map +1 -1
  16. package/dist/api/run.d.ts.map +1 -1
  17. package/dist/api/run.js +5 -1
  18. package/dist/api/run.js.map +1 -1
  19. package/dist/api/types.d.ts +15 -4
  20. package/dist/api/types.d.ts.map +1 -1
  21. package/dist/cli/commands/analyze.d.ts +3 -0
  22. package/dist/cli/commands/analyze.d.ts.map +1 -1
  23. package/dist/cli/commands/analyze.js +112 -17
  24. package/dist/cli/commands/analyze.js.map +1 -1
  25. package/dist/cli/commands/audit.d.ts +9 -0
  26. package/dist/cli/commands/audit.d.ts.map +1 -0
  27. package/dist/cli/commands/audit.js +98 -0
  28. package/dist/cli/commands/audit.js.map +1 -0
  29. package/dist/cli/commands/drift.d.ts.map +1 -1
  30. package/dist/cli/commands/drift.js +8 -10
  31. package/dist/cli/commands/drift.js.map +1 -1
  32. package/dist/cli/commands/generate.d.ts.map +1 -1
  33. package/dist/cli/commands/generate.js +15 -37
  34. package/dist/cli/commands/generate.js.map +1 -1
  35. package/dist/cli/commands/mcp.d.ts +102 -2
  36. package/dist/cli/commands/mcp.d.ts.map +1 -1
  37. package/dist/cli/commands/mcp.js +134 -2
  38. package/dist/cli/commands/mcp.js.map +1 -1
  39. package/dist/cli/commands/run.d.ts.map +1 -1
  40. package/dist/cli/commands/run.js +9 -47
  41. package/dist/cli/commands/run.js.map +1 -1
  42. package/dist/cli/commands/setup.d.ts +17 -0
  43. package/dist/cli/commands/setup.d.ts.map +1 -0
  44. package/dist/cli/commands/setup.js +201 -0
  45. package/dist/cli/commands/setup.js.map +1 -0
  46. package/dist/cli/commands/verify.d.ts.map +1 -1
  47. package/dist/cli/commands/verify.js +7 -8
  48. package/dist/cli/commands/verify.js.map +1 -1
  49. package/dist/cli/index.js +14 -8
  50. package/dist/cli/index.js.map +1 -1
  51. package/dist/constants.d.ts +14 -0
  52. package/dist/constants.d.ts.map +1 -1
  53. package/dist/constants.js +14 -0
  54. package/dist/constants.js.map +1 -1
  55. package/dist/core/analyzer/ai-config-generator.d.ts +54 -0
  56. package/dist/core/analyzer/ai-config-generator.d.ts.map +1 -0
  57. package/dist/core/analyzer/ai-config-generator.js +85 -0
  58. package/dist/core/analyzer/ai-config-generator.js.map +1 -0
  59. package/dist/core/analyzer/artifact-generator.d.ts +27 -2
  60. package/dist/core/analyzer/artifact-generator.d.ts.map +1 -1
  61. package/dist/core/analyzer/artifact-generator.js +86 -8
  62. package/dist/core/analyzer/artifact-generator.js.map +1 -1
  63. package/dist/core/analyzer/codebase-digest.d.ts.map +1 -1
  64. package/dist/core/analyzer/codebase-digest.js +12 -11
  65. package/dist/core/analyzer/codebase-digest.js.map +1 -1
  66. package/dist/core/analyzer/env-extractor.d.ts +33 -0
  67. package/dist/core/analyzer/env-extractor.d.ts.map +1 -0
  68. package/dist/core/analyzer/env-extractor.js +196 -0
  69. package/dist/core/analyzer/env-extractor.js.map +1 -0
  70. package/dist/core/analyzer/http-route-parser.d.ts +36 -1
  71. package/dist/core/analyzer/http-route-parser.d.ts.map +1 -1
  72. package/dist/core/analyzer/http-route-parser.js +276 -0
  73. package/dist/core/analyzer/http-route-parser.js.map +1 -1
  74. package/dist/core/analyzer/middleware-extractor.d.ts +29 -0
  75. package/dist/core/analyzer/middleware-extractor.d.ts.map +1 -0
  76. package/dist/core/analyzer/middleware-extractor.js +195 -0
  77. package/dist/core/analyzer/middleware-extractor.js.map +1 -0
  78. package/dist/core/analyzer/schema-extractor.d.ts +41 -0
  79. package/dist/core/analyzer/schema-extractor.d.ts.map +1 -0
  80. package/dist/core/analyzer/schema-extractor.js +229 -0
  81. package/dist/core/analyzer/schema-extractor.js.map +1 -0
  82. package/dist/core/analyzer/spec-snapshot-generator.d.ts +17 -0
  83. package/dist/core/analyzer/spec-snapshot-generator.d.ts.map +1 -0
  84. package/dist/core/analyzer/spec-snapshot-generator.js +201 -0
  85. package/dist/core/analyzer/spec-snapshot-generator.js.map +1 -0
  86. package/dist/core/analyzer/ui-component-extractor.d.ts +43 -0
  87. package/dist/core/analyzer/ui-component-extractor.d.ts.map +1 -0
  88. package/dist/core/analyzer/ui-component-extractor.js +245 -0
  89. package/dist/core/analyzer/ui-component-extractor.js.map +1 -0
  90. package/dist/core/generator/openspec-format-generator.d.ts.map +1 -1
  91. package/dist/core/generator/openspec-format-generator.js +8 -0
  92. package/dist/core/generator/openspec-format-generator.js.map +1 -1
  93. package/dist/core/generator/spec-pipeline.d.ts +9 -0
  94. package/dist/core/generator/spec-pipeline.d.ts.map +1 -1
  95. package/dist/core/generator/spec-pipeline.js +94 -2
  96. package/dist/core/generator/spec-pipeline.js.map +1 -1
  97. package/dist/core/generator/stages/stage1-survey.d.ts.map +1 -1
  98. package/dist/core/generator/stages/stage1-survey.js +43 -0
  99. package/dist/core/generator/stages/stage1-survey.js.map +1 -1
  100. package/dist/core/generator/stages/stage2-entities.d.ts.map +1 -1
  101. package/dist/core/generator/stages/stage2-entities.js +6 -2
  102. package/dist/core/generator/stages/stage2-entities.js.map +1 -1
  103. package/dist/core/generator/stages/stage3-services.d.ts.map +1 -1
  104. package/dist/core/generator/stages/stage3-services.js +9 -2
  105. package/dist/core/generator/stages/stage3-services.js.map +1 -1
  106. package/dist/core/generator/stages/stage4-api.d.ts.map +1 -1
  107. package/dist/core/generator/stages/stage4-api.js +6 -2
  108. package/dist/core/generator/stages/stage4-api.js.map +1 -1
  109. package/dist/core/services/llm-service.d.ts +26 -10
  110. package/dist/core/services/llm-service.d.ts.map +1 -1
  111. package/dist/core/services/llm-service.js +171 -16
  112. package/dist/core/services/llm-service.js.map +1 -1
  113. package/dist/core/services/mcp-handlers/analysis.d.ts +32 -1
  114. package/dist/core/services/mcp-handlers/analysis.d.ts.map +1 -1
  115. package/dist/core/services/mcp-handlers/analysis.js +185 -2
  116. package/dist/core/services/mcp-handlers/analysis.js.map +1 -1
  117. package/dist/core/verifier/verification-engine.d.ts +67 -6
  118. package/dist/core/verifier/verification-engine.d.ts.map +1 -1
  119. package/dist/core/verifier/verification-engine.js +316 -90
  120. package/dist/core/verifier/verification-engine.js.map +1 -1
  121. package/dist/types/index.d.ts +70 -1
  122. package/dist/types/index.d.ts.map +1 -1
  123. package/dist/types/pipeline.d.ts +9 -0
  124. package/dist/types/pipeline.d.ts.map +1 -1
  125. package/dist/utils/command-helpers.d.ts +30 -0
  126. package/dist/utils/command-helpers.d.ts.map +1 -1
  127. package/dist/utils/command-helpers.js +69 -1
  128. package/dist/utils/command-helpers.js.map +1 -1
  129. package/examples/bmad/README.md +113 -0
  130. package/examples/bmad/agents/architect.md +226 -0
  131. package/examples/bmad/agents/dev-brownfield.md +69 -0
  132. package/examples/bmad/setup/architect.customize.yaml +14 -0
  133. package/examples/bmad/tasks/implement-story.md +254 -0
  134. package/examples/bmad/tasks/onboarding.md +169 -0
  135. package/examples/bmad/tasks/refactor.md +178 -0
  136. package/examples/bmad/tasks/sprint-planning.md +168 -0
  137. package/examples/bmad/templates/story.md +108 -0
  138. package/examples/cline-workflows/spec-gen-analyze-codebase.md +100 -0
  139. package/examples/cline-workflows/spec-gen-check-spec-drift.md +102 -0
  140. package/examples/cline-workflows/spec-gen-execute-refactor.md +194 -0
  141. package/examples/cline-workflows/spec-gen-implement-feature.md +238 -0
  142. package/examples/cline-workflows/spec-gen-plan-refactor.md +255 -0
  143. package/examples/cline-workflows/spec-gen-refactor-codebase.md +16 -0
  144. package/examples/drift-demo/openspec/config.yaml +14 -0
  145. package/examples/drift-demo/openspec/specs/architecture/spec.md +30 -0
  146. package/examples/drift-demo/openspec/specs/auth/spec.md +71 -0
  147. package/examples/drift-demo/openspec/specs/database/spec.md +33 -0
  148. package/examples/drift-demo/openspec/specs/overview/spec.md +20 -0
  149. package/examples/drift-demo/openspec/specs/projects/spec.md +55 -0
  150. package/examples/drift-demo/openspec/specs/tasks/spec.md +78 -0
  151. package/examples/drift-demo/package.json +21 -0
  152. package/examples/drift-demo/src/auth/auth-middleware.ts +30 -0
  153. package/examples/drift-demo/src/auth/auth-routes.ts +29 -0
  154. package/examples/drift-demo/src/auth/auth-service.ts +45 -0
  155. package/examples/drift-demo/src/database/connection.ts +27 -0
  156. package/examples/drift-demo/src/index.ts +16 -0
  157. package/examples/drift-demo/src/projects/project-model.ts +15 -0
  158. package/examples/drift-demo/src/projects/project-service.ts +34 -0
  159. package/examples/drift-demo/src/tasks/task-model.ts +37 -0
  160. package/examples/drift-demo/src/tasks/task-routes.ts +53 -0
  161. package/examples/drift-demo/src/tasks/task-service.ts +60 -0
  162. package/examples/drift-demo/src/utils/validation.ts +11 -0
  163. package/examples/drift-demo/tests/auth.test.ts +4 -0
  164. package/examples/drift-demo/tests/tasks.test.ts +4 -0
  165. package/examples/drift-demo/tsconfig.json +10 -0
  166. package/examples/drift-test/run-drift-test.sh +1087 -0
  167. package/examples/gsd/README.md +119 -0
  168. package/examples/gsd/commands/gsd/spec-gen-drift.md +111 -0
  169. package/examples/gsd/commands/gsd/spec-gen-orient.md +191 -0
  170. package/examples/mistral-vibe/README.md +101 -0
  171. package/examples/mistral-vibe/antipatterns-template.md +18 -0
  172. package/examples/mistral-vibe/skills/spec-gen-analyze-codebase/SKILL.md +123 -0
  173. package/examples/mistral-vibe/skills/spec-gen-brainstorm/SKILL.md +379 -0
  174. package/examples/mistral-vibe/skills/spec-gen-debug/SKILL.md +320 -0
  175. package/examples/mistral-vibe/skills/spec-gen-execute-refactor/SKILL.md +210 -0
  176. package/examples/mistral-vibe/skills/spec-gen-generate/SKILL.md +245 -0
  177. package/examples/mistral-vibe/skills/spec-gen-implement-story/SKILL.md +274 -0
  178. package/examples/mistral-vibe/skills/spec-gen-plan-refactor/SKILL.md +251 -0
  179. package/examples/openspec-analysis/README.md +59 -0
  180. package/examples/openspec-analysis/SUMMARY.md +72 -0
  181. package/examples/openspec-analysis/config.json +16 -0
  182. package/examples/openspec-analysis/dependencies.mermaid +35 -0
  183. package/examples/openspec-analysis/dependency-graph.json +12116 -0
  184. package/examples/openspec-analysis/llm-context.json +119 -0
  185. package/examples/openspec-analysis/repo-structure.json +871 -0
  186. package/examples/openspec-cli/README.md +67 -0
  187. package/examples/openspec-cli/openspec/config.yaml +26 -0
  188. package/examples/openspec-cli/openspec/specs/architecture/spec.md +178 -0
  189. package/examples/openspec-cli/openspec/specs/artifact-graph/spec.md +143 -0
  190. package/examples/openspec-cli/openspec/specs/cli/spec.md +138 -0
  191. package/examples/openspec-cli/openspec/specs/overview/spec.md +60 -0
  192. package/examples/openspec-cli/openspec/specs/parsing/spec.md +123 -0
  193. package/examples/openspec-cli/openspec/specs/validation/spec.md +108 -0
  194. package/examples/spec-kit/README.md +104 -0
  195. package/examples/spec-kit/commands/drift.md +87 -0
  196. package/examples/spec-kit/commands/orient.md +138 -0
  197. package/examples/spec-kit/extension.yml +54 -0
  198. package/package.json +3 -6
package/README.md CHANGED
@@ -18,10 +18,11 @@ npm install -g spec-gen-cli
18
18
  cd /path/to/your-project
19
19
 
20
20
  # Run the pipeline
21
- spec-gen init # Detect project type, create config
22
- spec-gen analyze # Static analysis (no API key needed)
23
- spec-gen generate # Generate specs (requires API key)
24
- spec-gen drift # Check for spec drift
21
+ spec-gen init # Detect project type, create config
22
+ spec-gen analyze --ai-configs # Static analysis + generate context files (CLAUDE.md, .cursorrules…)
23
+ spec-gen setup # Install workflow skills (Vibe, Cline, GSD, BMAD)
24
+ spec-gen generate # Generate specs (requires API key)
25
+ spec-gen drift # Check for spec drift
25
26
 
26
27
  # Troubleshoot setup issues
27
28
  spec-gen doctor # Check environment and configuration
@@ -94,6 +95,8 @@ Scans your codebase using pure static analysis:
94
95
  - Resolves Python absolute imports (`from services.retriever import X`) to local files
95
96
  - Synthesizes cross-file dependency edges from call-graph data for languages without file-level imports (Swift, C++), so the dependency graph and viewer are meaningful even in single-module projects
96
97
  - Clusters related files into structural business domains automatically
98
+ - Extracts DB schema tables (Prisma, TypeORM, Drizzle, SQLAlchemy), HTTP routes (Express, NestJS, Next.js, FastAPI, Flask), UI components (React, Vue, Svelte, Angular), middleware chains, and environment variables — saved as structured JSON artifacts in `.spec-gen/analysis/`
99
+ - Generates AI tool config files (`CLAUDE.md`, `.cursorrules`, `.clinerules/`, `.vibe/skills/`, etc.) with `--ai-configs`
97
100
  - Produces structured context that makes LLM generation more accurate
98
101
 
99
102
  **2. Generate** (API key required)
@@ -309,7 +312,7 @@ spec-gen drift --no-color # Plain output for CI logs
309
312
 
310
313
  ## LLM Providers
311
314
 
312
- spec-gen supports eight providers. The default is Anthropic Claude.
315
+ spec-gen supports nine providers. The default is Anthropic Claude.
313
316
 
314
317
  | Provider | `provider` value | API key env var | Default model |
315
318
  |----------|-----------------|-----------------|---------------|
@@ -321,6 +324,7 @@ spec-gen supports eight providers. The default is Anthropic Claude.
321
324
  | Gemini CLI | `gemini-cli` | *(none)* | *(CLI default)* |
322
325
  | Claude Code | `claude-code` | *(none)* | *(CLI default)* |
323
326
  | Mistral Vibe | `mistral-vibe` | *(none)* | *(CLI default)* |
327
+ | Cursor Agent CLI | `cursor-agent` | *(none)* | *(CLI default)* |
324
328
 
325
329
  ### Selecting a provider
326
330
 
@@ -417,13 +421,14 @@ No API key is required — the copilot-api proxy handles authentication via your
417
421
 
418
422
  ### CLI-based providers (no API key)
419
423
 
420
- Three providers route LLM calls through local CLI tools instead of HTTP APIs. No API key or configuration is needed — just have the CLI installed and on your PATH.
424
+ Four providers route LLM calls through local CLI tools instead of HTTP APIs. No API key or configuration is needed — just have the CLI installed and on your PATH.
421
425
 
422
426
  | Provider | CLI binary | Install |
423
- |----------|-----------|---------|
427
+ |----------|-----------|----------------|
424
428
  | `claude-code` | `claude` | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (requires Claude Max/Pro subscription) |
425
429
  | `gemini-cli` | `gemini` | [Gemini CLI](https://github.com/google-gemini/gemini-cli) (free tier with Google account) |
426
430
  | `mistral-vibe` | `vibe` | [Mistral Vibe](https://github.com/mistralai/mistral-vibe) (standalone binary) |
431
+ | `cursor-agent` | `cursor-agent` | [Cursor CLI](https://cursor.com/docs/cli/overview) (Cursor subscription / CLI auth) |
427
432
 
428
433
  ```json
429
434
  {
@@ -472,11 +477,13 @@ Priority: CLI flags > environment variables > config file > provider defaults.
472
477
  | `spec-gen verify` | Verify spec accuracy | Yes |
473
478
  | `spec-gen drift` | Detect spec drift (static) | No |
474
479
  | `spec-gen drift --use-llm` | Detect spec drift (LLM-enhanced) | Yes |
480
+ | `spec-gen audit` | Report spec coverage gaps: uncovered functions, hub gaps, stale domains | No |
475
481
  | `spec-gen run` | Full pipeline: init, analyze, generate | Yes |
476
482
  | `spec-gen view` | Launch interactive graph & spec viewer in the browser | No |
483
+ | `spec-gen setup` | Install workflow skills into the project (Vibe, Cline, GSD, BMAD) | No |
477
484
  | `spec-gen mcp` | Start MCP server (stdio, for Cline / Claude Code) | No |
478
485
  | `spec-gen doctor` | Check environment and configuration for common issues | No |
479
- | `spec-gen refresh-stories` | Re-annotate story files with stale risk context | No |
486
+ | `spec-gen refresh-stories` | Refresh story files with latest structural context after each commit | No |
480
487
 
481
488
  ### Global Options
482
489
 
@@ -549,10 +556,39 @@ spec-gen analyze [options]
549
556
  --include <glob> # Additional include patterns
550
557
  --exclude <glob> # Additional exclude patterns
551
558
  --force # Force re-analysis (bypass 1-hour cache)
559
+ --ai-configs # Generate AI tool config files (CLAUDE.md, .cursorrules, .clinerules/spec-gen.md,
560
+ # .github/copilot-instructions.md, .windsurf/rules.md, .vibe/skills/spec-gen.md)
561
+ # Safe to re-run — skips files that already exist, marks pre-existing ones.
552
562
  --no-embed # Skip building the semantic vector index (index is built by default when embedding is configured)
553
563
  --reindex-specs # Re-index OpenSpec specs into the vector index without re-running full analysis
554
564
  ```
555
565
 
566
+ ### Setup Options
567
+
568
+ ```bash
569
+ spec-gen setup [options]
570
+ --tools <list> Comma-separated tools to install: vibe, cline, gsd, bmad (default: interactive prompt)
571
+ --dir <path> Project root directory (default: current directory)
572
+ ```
573
+
574
+ Installs workflow skills from the spec-gen package into the project. Skills are static assets — identical across projects — so this command only needs to be run once at project onboarding and again after upgrading spec-gen.
575
+
576
+ Files installed:
577
+
578
+ | Tool | Destination | Skills |
579
+ |------|-------------|--------|
580
+ | `vibe` | `.vibe/skills/spec-gen-{name}/SKILL.md` | analyze-codebase, brainstorm, debug, execute-refactor, generate, implement-story, plan-refactor |
581
+ | `cline` | `.clinerules/workflows/spec-gen-{name}.md` | analyze-codebase, check-spec-drift, execute-refactor, implement-feature, plan-refactor, refactor-codebase |
582
+ | `gsd` | `.claude/commands/gsd/spec-gen-{name}.md` | orient, drift |
583
+ | `bmad` | `_bmad/spec-gen/{agents,tasks}/` | agents: architect, dev-brownfield — tasks: implement-story, onboarding, refactor, sprint-planning |
584
+
585
+ Never overwrites existing files. Combine with `analyze --ai-configs` for a complete agent setup:
586
+
587
+ ```bash
588
+ spec-gen analyze --ai-configs # project-specific context files
589
+ spec-gen setup # workflow skills
590
+ ```
591
+
556
592
  ### Verify Options
557
593
 
558
594
  ```bash
@@ -614,7 +650,27 @@ This is structural signal, not prose. It complements `openspec/specs/overview/sp
614
650
 
615
651
  ### Setup
616
652
 
617
- After running `spec-gen analyze`, wire the generated digest into your agent's context:
653
+ Two commands, run once per project:
654
+
655
+ ```bash
656
+ spec-gen analyze --ai-configs # generate project-specific context files
657
+ spec-gen setup # install workflow skills
658
+ ```
659
+
660
+ **`analyze --ai-configs`** generates files that are specific to this project — they reference `.spec-gen/analysis/CODEBASE.md` and embed the project name. Safe to re-run (skips existing files).
661
+
662
+ **`spec-gen setup`** copies static workflow assets from the spec-gen package that are identical across all projects. Run once at onboarding; re-run after upgrading spec-gen to get new or updated skills.
663
+
664
+ ```
665
+ spec-gen setup [--tools vibe,cline,gsd,bmad]
666
+
667
+ Mistral Vibe -> .vibe/skills/spec-gen-{name}/SKILL.md (7 skills)
668
+ Cline / Roo -> .clinerules/workflows/spec-gen-{name}.md (6 workflows)
669
+ GSD -> .claude/commands/gsd/spec-gen-{name}.md (2 commands)
670
+ BMAD -> _bmad/spec-gen/{agents,tasks}/ (2 agents, 4 tasks)
671
+ ```
672
+
673
+ Wire the generated digest into your agent's context:
618
674
 
619
675
  **Claude Code** — add to `CLAUDE.md`:
620
676
 
@@ -622,7 +678,7 @@ After running `spec-gen analyze`, wire the generated digest into your agent's co
622
678
  @.spec-gen/analysis/CODEBASE.md
623
679
  @openspec/specs/overview/spec.md
624
680
 
625
- ## spec-gen MCP tools — when to use them
681
+ ## spec-gen MCP workflow
626
682
 
627
683
  | Situation | Tool |
628
684
  |-----------|------|
@@ -633,8 +689,19 @@ After running `spec-gen analyze`, wire the generated digest into your agent's co
633
689
  | Reading a spec before writing code | `get_spec` |
634
690
  | Checking if code still matches spec | `check_spec_drift` |
635
691
  | Finding spec requirements by meaning | `search_specs` |
692
+ | Checking spec coverage before starting a feature | `audit_spec_coverage` |
693
+
694
+ **Follow this sequence for every task:**
695
+
696
+ 1. **`orient "<task description>"`** — always start here. Returns relevant functions, files, spec domains, call paths, and insertion points in one call.
697
+ 2. **If the task involves data models, APIs, or config** — call the relevant inventory tool:
698
+ `get_schema_inventory` · `get_route_inventory` · `get_env_vars` · `get_ui_components` · `get_middleware_inventory`
699
+ 3. **If debugging a call flow** ("how does X reach Y?") — `trace_execution_path`
700
+ 4. **Before modifying a function** — `get_subgraph` to understand blast radius
701
+ 5. **Before opening a PR** — `check_spec_drift`
636
702
 
637
- For all other cases (reading a file, grepping, listing files) use native tools directly.
703
+ **On-demand** (when orient's results aren't enough):
704
+ `search_code` · `suggest_insertion_points` · `get_spec <domain>` · `search_specs` · `analyze_impact` · `get_function_body` · `get_function_skeleton`
638
705
  ```
639
706
 
640
707
  **Cline / Roo Code / Kilocode** — create `.clinerules/spec-gen.md`:
@@ -652,29 +719,46 @@ Always use these before writing or modifying code.
652
719
  - Read `openspec/specs/overview/spec.md` — functional domain map: what the system does,
653
720
  which domains exist, data-flow requirements.
654
721
 
655
- ## MCP tools — use these instead of grep/read when exploring
722
+ ## spec-gen MCP workflow
656
723
 
657
- - **Orient first**: call `orient` at the start of every task — it returns relevant functions,
658
- files, specs, call paths, and insertion points in one shot.
659
- - **Finding code**: use `search_code` when you don't know which file or function handles a concept.
660
- - **Call topology**: use `get_subgraph` or `analyze_impact` when you need to understand
661
- how calls flow across multiple files (not just a single file).
662
- - **Adding a feature**: call `suggest_insertion_points` before deciding where to add code —
663
- it accounts for the dependency graph, not just filenames.
664
- - **Reading specs**: call `get_spec <domain>` before writing code in that domain;
665
- use `search_specs` to find requirements by meaning when you don't know the domain name.
666
- - **Checking drift**: call `check_spec_drift` after modifying a file to verify it still
667
- matches its spec — do not skip this step before opening a PR.
724
+ **Follow this sequence for every task:**
668
725
 
669
- Use native tools (Read, Grep, Glob) only for cases not covered above.
726
+ 1. **`orient "<task description>"`** — always start here. Returns relevant functions, files, spec domains, call paths, and insertion points in one call.
727
+ 2. **If the task involves data models, APIs, or config** — call the relevant inventory tool:
728
+ `get_schema_inventory` · `get_route_inventory` · `get_env_vars` · `get_ui_components` · `get_middleware_inventory`
729
+ 3. **If debugging a call flow** ("how does X reach Y?") — `trace_execution_path`
730
+ 4. **Before modifying a function** — `get_subgraph` to understand blast radius
731
+ 5. **Before opening a PR** — `check_spec_drift`
732
+
733
+ **On-demand** (when orient's results aren't enough):
734
+ `search_code` · `suggest_insertion_points` · `get_spec <domain>` · `search_specs` · `analyze_impact` · `get_function_body` · `get_function_skeleton`
670
735
  ```
671
736
 
672
- `CODEBASE.md` gives the agent passive architectural context. `overview/spec.md` gives the functional domain map. The table tells it when the passive context isn't enough and an active MCP tool call is warranted.
737
+ `CODEBASE.md` gives the agent passive architectural context. `overview/spec.md` gives the functional domain map. The workflow tells it exactly what to call and when, without requiring the agent to choose from a menu.
673
738
 
674
739
  > **Tip:** `spec-gen analyze` prints these snippets after every run as a reminder.
675
740
 
676
741
  > **Note:** `.spec-gen/analysis/` is git-ignored — each developer generates it locally. Re-run `spec-gen analyze` after significant structural changes to keep the digest current.
677
742
 
743
+ **Mistral Vibe (Devstral)** — inject CODEBASE.md into Vibe's global context:
744
+
745
+ > **Vibe shows "0 skills" after setup?** Check `~/.vibe/config.toml` — if `enabled_skills` is set to a pattern like `["SKILL-*"]` (the old naming format), it won't match the new `spec-gen-*` names. Change it to `["spec-gen-*"]` or `["*"]` to load all skills.
746
+
747
+ 1. Run `spec-gen analyze` to generate `.spec-gen/analysis/CODEBASE.md`
748
+ 2. Append it to `~/.vibe/prompts/spec-gen.md` so Devstral absorbs it at every session start:
749
+
750
+ ```bash
751
+ cat .spec-gen/analysis/CODEBASE.md >> ~/.vibe/prompts/spec-gen.md
752
+ ```
753
+
754
+ Or install the Vibe skill (creates a `/spec-gen` slash command in `.vibe/skills/spec-gen.md`):
755
+
756
+ ```bash
757
+ spec-gen analyze --ai-configs # creates .vibe/skills/spec-gen.md
758
+ ```
759
+
760
+ Then invoke `/spec-gen` inside Vibe to get architecture context on demand.
761
+
678
762
  ---
679
763
 
680
764
  ## MCP Server
@@ -787,7 +871,7 @@ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/skills/opensp
787
871
 
788
872
  All tools run on **pure static analysis** -- no LLM quota consumed.
789
873
 
790
- **Analysis**
874
+ **Run analysis**
791
875
 
792
876
  | Tool | Description | Requires prior analysis |
793
877
  |------|-------------|:---:|
@@ -796,30 +880,43 @@ All tools run on **pure static analysis** -- no LLM quota consumed.
796
880
  | `get_signatures` | Compact function/class signatures per file. Filter by path substring with `filePattern`. Useful for understanding a module's public API without reading full source. | Yes |
797
881
  | `get_duplicate_report` | Detect duplicate code: Type 1 (exact clones), Type 2 (structural -- renamed variables), Type 3 (near-clones with Jaccard similarity >= 0.7). Groups sorted by impact. | Yes |
798
882
 
799
- **Refactoring**
800
-
801
- | Tool | Description | Requires prior analysis |
802
- |------|-------------|:---:|
803
- | `get_refactor_report` | Prioritized list of functions with structural issues: unreachable code, hub overload (high fan-in), god functions (high fan-out), SRP violations, cyclic dependencies. | Yes |
804
- | `analyze_impact` | Deep impact analysis for a specific function: fan-in/fan-out, upstream call chain, downstream critical path, risk score (0-100), blast radius, and recommended strategy. | Yes |
805
- | `get_low_risk_refactor_candidates` | Safest functions to refactor first: low fan-in, low fan-out, not a hub, no cyclic involvement. Best starting point for incremental, low-risk sessions. | Yes |
806
- | `get_leaf_functions` | Functions that make no internal calls (leaves of the call graph). Zero downstream blast radius. Sorted by fan-in by default -- most-called leaves have the best unit-test ROI. | Yes |
807
- | `get_critical_hubs` | Highest-impact hub functions ranked by criticality. Each hub gets a stability score (0-100) and a recommended approach: extract, split, facade, or delegate. | Yes |
808
- | `get_god_functions` | Detect god functions (high fan-out, likely orchestrators) in the project or in a specific file, and return their call-graph neighborhood. Use this to identify which functions need to be refactored and understand what logical blocks to extract. | Yes |
809
-
810
- **Navigation**
883
+ **Explore & Navigate**
811
884
 
812
885
  | Tool | Description | Requires prior analysis |
813
886
  |------|-------------|:---:|
814
887
  | `orient` | **Single entry point for any new task.** Given a natural-language task description, returns in one call: relevant functions, source files, spec domains, call neighbourhoods, insertion-point candidates, and matching spec sections. Start here. | Yes (+ embedding) |
888
+ | `search_code` | Natural-language semantic search over indexed functions. Returns the closest matches by meaning with similarity score, call-graph neighbourhood enrichment, and spec-linked peer functions. Falls back to BM25 keyword search when no embedding server is configured. | Yes (+ embedding) |
889
+ | `suggest_insertion_points` | Semantic search over the vector index to find the best existing functions to extend or hook into when implementing a new feature. Returns ranked candidates with role and strategy. Falls back to BM25 keyword search when no embedding server is configured. | Yes (+ embedding) |
815
890
  | `get_subgraph` | Depth-limited subgraph centred on a function. Direction: `downstream` (what it calls), `upstream` (who calls it), or `both`. Output as JSON or Mermaid diagram. | Yes |
816
- | `get_architecture_overview` | High-level cluster map: roles (entry layer, orchestrator, core utilities, API layer, internal), inter-cluster dependencies, global entry points, and critical hubs. No LLM required. | Yes |
817
- | `get_function_skeleton` | Noise-stripped view of a source file: logs, inline comments, and non-JSDoc block comments removed. Signatures, control flow, return/throw, and call expressions preserved. Returns reduction %. | No |
891
+ | `trace_execution_path` | Find all call-graph paths between two functions (DFS, configurable depth/max-paths). Use this when debugging: "how does request X reach function Y?" Returns shortest path, all paths sorted by hops, and a step-by-step chain per path. | Yes |
818
892
  | `get_function_body` | Return the exact source code of a named function in a file. | No |
893
+ | `get_function_skeleton` | Noise-stripped view of a source file: logs, inline comments, and non-JSDoc block comments removed. Signatures, control flow, return/throw, and call expressions preserved. Returns reduction %. | No |
819
894
  | `get_file_dependencies` | Return the file-level import dependencies for a given source file (imports, imported-by, or both). | Yes |
820
- | `trace_execution_path` | Find all call-graph paths between two functions (DFS, configurable depth/max-paths). Use this when debugging: "how does request X reach function Y?" Returns shortest path, all paths sorted by hops, and a step-by-step chain per path. | Yes |
821
- | `suggest_insertion_points` | Semantic search over the vector index to find the best existing functions to extend or hook into when implementing a new feature. Returns ranked candidates with role and strategy. Falls back to BM25 keyword search when no embedding server is configured. | Yes (+ embedding) |
822
- | `search_code` | Natural-language semantic search over indexed functions. Returns the closest matches by meaning with similarity score, call-graph neighbourhood enrichment, and spec-linked peer functions. Falls back to BM25 keyword search when no embedding server is configured. | Yes (+ embedding) |
895
+ | `get_architecture_overview` | High-level cluster map: roles (entry layer, orchestrator, core utilities, API layer, internal), inter-cluster dependencies, global entry points, and critical hubs. No LLM required. | Yes |
896
+ | `get_signatures` | Compact function/class signatures per file. Filter by path substring with `filePattern`. Useful for understanding a module's public API without reading full source. | Yes |
897
+
898
+ **Stack inventory**
899
+
900
+ | Tool | Description | Requires prior analysis |
901
+ |------|-------------|:---:|
902
+ | `get_route_inventory` | All detected HTTP routes with method, path, handler, and framework. Supports Express, NestJS, Next.js, FastAPI, Flask, and more. | Yes |
903
+ | `get_schema_inventory` | ORM schema tables with field names and types. Supports Prisma, TypeORM, Drizzle, and SQLAlchemy. | Yes |
904
+ | `get_ui_components` | Detected UI components with framework, props, and source file. Supports React, Vue, Svelte, and Angular. | Yes |
905
+ | `get_env_vars` | Env vars referenced in source code with `required` (no fallback) and `hasDefault` flags. Supports JS/TS, Python, Go, and Ruby. | Yes |
906
+ | `get_middleware_inventory` | Detected middleware with type (auth/cors/rate-limit/validation/logging/error-handler) and framework. | Yes |
907
+
908
+ **Code quality**
909
+
910
+ | Tool | Description | Requires prior analysis |
911
+ |------|-------------|:---:|
912
+ | `get_call_graph` | Hub functions (high fan-in), entry points (no internal callers), and architectural layer violations. Supports TypeScript, JavaScript, Python, Go, Rust, Ruby, Java, C++. | Yes |
913
+ | `get_refactor_report` | Prioritized list of functions with structural issues: unreachable code, hub overload (high fan-in), god functions (high fan-out), SRP violations, cyclic dependencies. | Yes |
914
+ | `get_critical_hubs` | Highest-impact hub functions ranked by criticality. Each hub gets a stability score (0-100) and a recommended approach: extract, split, facade, or delegate. | Yes |
915
+ | `get_god_functions` | Detect god functions (high fan-out, likely orchestrators) in the project or in a specific file, and return their call-graph neighborhood. Use this to identify which functions need to be refactored and understand what logical blocks to extract. | Yes |
916
+ | `analyze_impact` | Deep impact analysis for a specific function: fan-in/fan-out, upstream call chain, downstream critical path, risk score (0-100), blast radius, and recommended strategy. | Yes |
917
+ | `get_low_risk_refactor_candidates` | Safest functions to refactor first: low fan-in, low fan-out, not a hub, no cyclic involvement. Best starting point for incremental, low-risk sessions. | Yes |
918
+ | `get_leaf_functions` | Functions that make no internal calls (leaves of the call graph). Zero downstream blast radius. Sorted by fan-in by default -- most-called leaves have the best unit-test ROI. | Yes |
919
+ | `get_duplicate_report` | Detect duplicate code: Type 1 (exact clones), Type 2 (structural -- renamed variables), Type 3 (near-clones with Jaccard similarity >= 0.7). Groups sorted by impact. | Yes |
823
920
 
824
921
  **Specs**
825
922
 
@@ -831,8 +928,14 @@ All tools run on **pure static analysis** -- no LLM quota consumed.
831
928
  | `check_spec_drift` | Detect code changes not reflected in OpenSpec specs. Compares git-changed files against spec coverage maps. Issues: gap / stale / uncovered / orphaned-spec / adr-gap. | Yes (generate) |
832
929
  | `search_specs` | Semantic search over OpenSpec specifications to find requirements, design notes, and architecture decisions by meaning. Returns linked source files for graph highlighting. Use this when asked "which spec covers X?" or "where should we implement Z?". Requires a spec index built with `spec-gen analyze` or `--reindex-specs`. | Yes (generate) |
833
930
  | `list_spec_domains` | List all OpenSpec domains available in this project. Use this to discover what domains exist before doing a targeted `search_specs` call. | Yes (generate) |
834
- | `generate_change_proposal` | Given a story/task description, chains `orient` + `search_specs` + `analyze_impact` to produce a structured change proposal at `openspec/changes/{slug}/proposal.md` with affected domains, risk scores, and insertion points. | Yes |
835
- | `annotate_story` | Reads a story/task markdown file, runs structural analysis, and patches a `## Risk Context` section in-place with domains, risk scores, blocking refactors, and insertion points. | Yes |
931
+ | `audit_spec_coverage` | Parity audit: uncovered functions (in call graph, no spec), hub gaps (high fan-in + no spec), orphan requirements (spec with no implementation found), and stale domains (source changed after spec). Run before starting a feature to understand coverage health. No LLM required. | Yes (analyze) |
932
+
933
+ **Story Management**
934
+
935
+ | Tool | Description | Requires prior analysis |
936
+ |------|-------------|:---:|
937
+ | `generate_change_proposal` | Generate a structured change proposal for a feature: affected functions, risk score, insertion points, spec impact, and a ready-to-use story file. Use during sprint planning or before implementing a non-trivial change. | Yes |
938
+ | `annotate_story` | Annotate an existing story file with structural context: risk score, affected functions, recommended insertion point, and spec domain links. Prepares a story for the dev agent so it can skip the orientation step. | Yes |
836
939
 
837
940
  ### Parameters
838
941
 
@@ -1063,16 +1166,30 @@ description string Natural-language summary of the story for structural ana
1063
1166
  3. check_spec_drift({ directory }) # verify after implementation
1064
1167
  ```
1065
1168
 
1066
- **Scenario E -- Agentic workflow (risk-gated implementation)**
1169
+ **Scenario E -- Coverage audit before implementing**
1067
1170
  ```
1068
- 1. generate_change_proposal({ directory, description, slug }) # proposal.md with risk + domains
1069
- 2. annotate_story({ directory, storyFilePath, description }) # patch story with risk_context
1070
- 3. orient({ directory, task: "..." }) # scope functions + insertion points
1071
- 4. analyze_impact({ directory, symbol: "topFunction" }) # confirm risk before coding
1072
- 5. check_spec_drift({ directory }) # verify after implementation
1171
+ 1. audit_spec_coverage({ directory })
1172
+ # Before writing code: surfaces stale domains, uncovered hub functions,
1173
+ # orphan requirements. 0 LLM calls, ~200ms.
1174
+ 2. If staleDomains includes your target: spec-gen generate --domains $DOMAIN
1175
+ 3. If hubGaps includes a function you'll touch: flag it in your risk check
1073
1176
  ```
1074
1177
 
1075
- See [docs/agentic-workflows/](docs/agentic-workflows/) for full integration patterns with BMAD, Mistral Vibe, spec-kit, and Claude Code.
1178
+ ---
1179
+
1180
+ ## Agentic Workflows
1181
+
1182
+ spec-gen integrates with structured agentic workflows so AI agents follow a consistent process: orient → risk check → spec check → implement → drift verify.
1183
+
1184
+ | Integration | Description | Location |
1185
+ |-------------|-------------|----------|
1186
+ | **BMAD** | Brownfield agent workflow with architect + dev agents. Architect annotates stories with risk context at planning time; dev agent uses it to skip orientation on low-risk stories. | `examples/bmad/` |
1187
+ | **Mistral Vibe** | Skills for Mistral-powered agents (brainstorm, implement story, debug, plan/execute refactor). Includes small-model constraints (≤50-line edits). | `examples/mistral-vibe/` |
1188
+ | **GSD** | Minimal slash commands for `spec-gen orient` and `spec-gen drift` — drop into any agent that supports custom commands. | `examples/gsd/` |
1189
+ | **spec-kit** | Extension layer adding structural risk analysis to any existing agent setup. | `examples/spec-kit/` |
1190
+ | **Cline** | Workflow markdown files for Cline / Roo Code / Kilocode. Copy to `.clinerules/workflows/`. | `examples/cline-workflows/` |
1191
+
1192
+ Each integration ships with a README explaining setup and the step-by-step workflow.
1076
1193
 
1077
1194
  ## Interactive Graph Viewer
1078
1195
 
@@ -1195,6 +1312,8 @@ Static analysis output is stored in `.spec-gen/analysis/`:
1195
1312
  | `call-graph.json` | Function-level call graph (8 languages: TS/JS, Python, Go, Rust, Ruby, Java, C++, Swift) |
1196
1313
  | `refactor-priorities.json` | Refactoring issues by file and function |
1197
1314
  | `mapping.json` | Requirement->function mapping (produced by `generate`) |
1315
+ | `spec-snapshot.json` | Compact coverage summary: git state, per-domain coverage %, uncovered hub functions (auto-updated after `analyze` and `generate`) |
1316
+ | `audit-report.json` | Latest parity audit report (produced by `spec-gen audit`) |
1198
1317
  | `vector-index/` | LanceDB semantic index (produced by `--embed`) |
1199
1318
 
1200
1319
  `spec-gen analyze` also writes **`ARCHITECTURE.md`** to your project root -- a Markdown overview of module clusters, entry points, and critical hubs, refreshed on every run.
@@ -1292,7 +1411,7 @@ The index is stored in `.spec-gen/analysis/vector-index/` and is automatically u
1292
1411
  export OPENAI_COMPAT_API_KEY=ollama # OpenAI-compatible local server
1293
1412
  export GEMINI_API_KEY=... # Google Gemini
1294
1413
  ```
1295
- Or use a CLI-based provider (`claude-code`, `gemini-cli`, `mistral-vibe`) which requires no API key — just the CLI tool on your PATH.
1414
+ Or use a CLI-based provider (`claude-code`, `gemini-cli`, `mistral-vibe`, `cursor-agent`) which requires no API key — just the CLI tool on your PATH.
1296
1415
  - `analyze`, `drift`, and `init` require no API key
1297
1416
 
1298
1417
  ## Supported Languages
@@ -1369,6 +1488,7 @@ console.log(`Analyzed ${analysis.repoMap.summary.analyzedFiles} files`);
1369
1488
  | `specGenVerify(options?)` | Verify spec accuracy | Yes |
1370
1489
  | `specGenDrift(options?)` | Detect spec-to-code drift | No* |
1371
1490
  | `specGenRun(options?)` | Full pipeline: init + analyze + generate | Yes |
1491
+ | `specGenAudit(options?)` | Parity audit: uncovered functions, hub gaps, orphan requirements, stale domains | No |
1372
1492
  | `specGenGetSpecRequirements(options?)` | Read requirement blocks from generated specs | No |
1373
1493
 
1374
1494
  \* `specGenDrift` requires an API key only when `llmEnhanced: true`.
@@ -1425,11 +1545,11 @@ for (const [key, req] of Object.entries(requirements)) {
1425
1545
  npm install # Install dependencies
1426
1546
  npm run dev # Development mode (watch)
1427
1547
  npm run build # Build
1428
- npm run test:run # Run tests (2200+ unit tests)
1548
+ npm run test:run # Run tests (2300+ unit tests)
1429
1549
  npm run typecheck # Type check
1430
1550
  ```
1431
1551
 
1432
- 2200+ unit tests covering static analysis, call graph (including Swift), refactor analysis, spec mapping, drift detection, LLM enhancement, ADR generation, MCP handlers, change proposals, cross-file edge synthesis, and the full CLI.
1552
+ 2300+ unit tests covering static analysis, call graph (including Swift), refactor analysis, spec mapping, drift detection, LLM enhancement, ADR generation, MCP handlers, change proposals, cross-file edge synthesis, and the full CLI.
1433
1553
 
1434
1554
  ## Links
1435
1555
 
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/api/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAoB,MAAM,YAAY,CAAC;AAiCrF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CA4H5F"}
1
+ {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/api/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAoB,MAAM,YAAY,CAAC;AAkCrF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAiI5F"}
@@ -6,12 +6,13 @@
6
6
  */
7
7
  import { join } from 'node:path';
8
8
  import { readFile, stat, mkdir, writeFile } from 'node:fs/promises';
9
- import { ANALYSIS_STALE_THRESHOLD_MS, DEFAULT_MAX_FILES, SPEC_GEN_ANALYSIS_REL_PATH, ARTIFACT_REPO_STRUCTURE, ARTIFACT_DEPENDENCY_GRAPH, ARTIFACT_LLM_CONTEXT } from '../constants.js';
9
+ import { ANALYSIS_STALE_THRESHOLD_MS, DEFAULT_MAX_FILES, SPEC_GEN_ANALYSIS_REL_PATH, ARTIFACT_REPO_STRUCTURE, ARTIFACT_DEPENDENCY_GRAPH, ARTIFACT_LLM_CONTEXT, OPENSPEC_DIR } from '../constants.js';
10
10
  import { fileExists, readJsonFile } from '../utils/command-helpers.js';
11
11
  import { readSpecGenConfig } from '../core/services/config-manager.js';
12
12
  import { RepositoryMapper } from '../core/analyzer/repository-mapper.js';
13
13
  import { DependencyGraphBuilder, } from '../core/analyzer/dependency-graph.js';
14
14
  import { AnalysisArtifactGenerator, repoStructureToRepoMap } from '../core/analyzer/artifact-generator.js';
15
+ import { SpecSnapshotGenerator } from '../core/analyzer/spec-snapshot-generator.js';
15
16
  function progress(onProgress, step, status, detail) {
16
17
  onProgress?.({ phase: 'analyze', step, status, detail });
17
18
  }
@@ -132,6 +133,10 @@ export async function specGenAnalyze(options = {}) {
132
133
  // Save dependency graph
133
134
  await writeFile(join(outputPath, ARTIFACT_DEPENDENCY_GRAPH), JSON.stringify(depGraph, null, 2));
134
135
  progress(onProgress, 'Generating analysis artifacts', 'complete');
136
+ // Generate spec snapshot (non-fatal — snapshot is a derived artifact)
137
+ const openspecRelPath = specGenConfig.openspecPath ?? OPENSPEC_DIR;
138
+ const snapshotGenerator = new SpecSnapshotGenerator(rootPath, openspecRelPath);
139
+ await snapshotGenerator.generate().catch(() => { });
135
140
  const duration = Date.now() - startTime;
136
141
  return { repoMap, depGraph, artifacts, duration };
137
142
  }
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/api/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,E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AAS,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * spec-gen audit — programmatic API
3
+ *
4
+ * Compares current codebase state to the spec snapshot to report coverage gaps.
5
+ * No LLM required.
6
+ */
7
+ import type { AuditReport } from '../types/index.js';
8
+ import type { AuditApiOptions } from './types.js';
9
+ export declare function specGenAudit(options?: AuditApiOptions): Promise<AuditReport>;
10
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/api/audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EACV,WAAW,EAIZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA4ClD,wBAAsB,YAAY,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAmFtF"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * spec-gen audit — programmatic API
3
+ *
4
+ * Compares current codebase state to the spec snapshot to report coverage gaps.
5
+ * No LLM required.
6
+ */
7
+ import { join } from 'node:path';
8
+ import { readFile, writeFile } from 'node:fs/promises';
9
+ import { readSpecGenConfig } from '../core/services/config-manager.js';
10
+ import { SpecSnapshotGenerator } from '../core/analyzer/spec-snapshot-generator.js';
11
+ import { SPEC_GEN_DIR, SPEC_GEN_ANALYSIS_SUBDIR, ARTIFACT_LLM_CONTEXT, ARTIFACT_MAPPING, ARTIFACT_AUDIT_REPORT, OPENSPEC_DIR, } from '../constants.js';
12
+ const DEFAULT_MAX_UNCOVERED = 50;
13
+ const DEFAULT_HUB_THRESHOLD = 5;
14
+ // ============================================================================
15
+ // HELPERS
16
+ // ============================================================================
17
+ function buildCoveredSet(mapping) {
18
+ const covered = new Set();
19
+ for (const m of mapping.mappings) {
20
+ for (const fn of m.functions) {
21
+ if (fn.name && fn.name !== '*') {
22
+ covered.add(`${fn.file}::${fn.name}`);
23
+ covered.add(fn.name);
24
+ }
25
+ }
26
+ }
27
+ return covered;
28
+ }
29
+ function isNodeCovered(node, covered) {
30
+ return covered.has(`${node.filePath}::${node.name}`) || covered.has(node.name);
31
+ }
32
+ function toAuditFunction(node, isHub) {
33
+ return {
34
+ name: node.name,
35
+ file: node.filePath,
36
+ kind: node.className ? 'method' : 'function',
37
+ fanIn: node.fanIn,
38
+ fanOut: node.fanOut,
39
+ isHub,
40
+ };
41
+ }
42
+ // ============================================================================
43
+ // PUBLIC API
44
+ // ============================================================================
45
+ export async function specGenAudit(options = {}) {
46
+ const rootPath = options.rootPath ?? process.cwd();
47
+ const maxUncovered = options.maxUncovered ?? DEFAULT_MAX_UNCOVERED;
48
+ const hubThreshold = options.hubThreshold ?? DEFAULT_HUB_THRESHOLD;
49
+ const shouldSave = options.save ?? true;
50
+ const analysisDir = join(rootPath, SPEC_GEN_DIR, SPEC_GEN_ANALYSIS_SUBDIR);
51
+ // Load (or refresh) snapshot
52
+ const specGenConfig = await readSpecGenConfig(rootPath);
53
+ const openspecRelPath = specGenConfig?.openspecPath ?? OPENSPEC_DIR;
54
+ const snapshotGen = new SpecSnapshotGenerator(rootPath, openspecRelPath);
55
+ const snapshot = await snapshotGen.generate().catch(() => null);
56
+ // Load raw artifacts for deep analysis
57
+ const [llmContextRaw, mappingRaw] = await Promise.all([
58
+ readFile(join(analysisDir, ARTIFACT_LLM_CONTEXT), 'utf-8').catch(() => null),
59
+ readFile(join(analysisDir, ARTIFACT_MAPPING), 'utf-8').catch(() => null),
60
+ ]);
61
+ const llmContext = llmContextRaw ? JSON.parse(llmContextRaw) : null;
62
+ const mapping = mappingRaw ? JSON.parse(mappingRaw) : null;
63
+ const callGraph = llmContext?.callGraph;
64
+ const allNodes = callGraph?.nodes ?? [];
65
+ const hubNodes = new Set((callGraph?.hubFunctions ?? []).map(n => n.id));
66
+ // Build coverage set
67
+ const covered = mapping ? buildCoveredSet(mapping) : new Set();
68
+ // 1. Uncovered functions
69
+ const uncoveredNodes = allNodes.filter(n => !isNodeCovered(n, covered));
70
+ const uncoveredFunctions = uncoveredNodes
71
+ .slice(0, maxUncovered)
72
+ .map(n => toAuditFunction(n, hubNodes.has(n.id) || n.fanIn >= hubThreshold));
73
+ // 2. Hub gaps (hubs with no spec coverage)
74
+ const hubGaps = allNodes
75
+ .filter(n => (hubNodes.has(n.id) || n.fanIn >= hubThreshold) && !isNodeCovered(n, covered))
76
+ .map(n => toAuditFunction(n, true));
77
+ // 3. Orphan requirements (requirements in mapping with no matched function)
78
+ const orphanRequirements = mapping
79
+ ? mapping.mappings
80
+ .filter(m => m.functions.length === 0 || m.functions.every(f => f.name === '*'))
81
+ .map(m => ({ requirement: m.requirement, domain: m.domain, specFile: m.specFile }))
82
+ : [];
83
+ // 4. Stale domains (source files modified after spec)
84
+ const staleDomains = snapshot
85
+ ? snapshot.domains
86
+ .filter(d => d.sourcesModifiedAt > d.specModifiedAt)
87
+ .map(d => ({
88
+ name: d.name,
89
+ specFile: d.specFile,
90
+ specModifiedAt: d.specModifiedAt,
91
+ sourcesModifiedAt: d.sourcesModifiedAt,
92
+ staleSince: d.sourcesModifiedAt,
93
+ }))
94
+ : [];
95
+ const coveredCount = allNodes.length - uncoveredNodes.length;
96
+ const report = {
97
+ generatedAt: new Date().toISOString(),
98
+ summary: {
99
+ totalFunctions: allNodes.length,
100
+ coveredFunctions: coveredCount,
101
+ coveragePct: allNodes.length > 0 ? Math.round((coveredCount / allNodes.length) * 100) : 0,
102
+ uncoveredCount: uncoveredNodes.length,
103
+ hubGapCount: hubGaps.length,
104
+ orphanRequirementCount: orphanRequirements.length,
105
+ staleDomainCount: staleDomains.length,
106
+ },
107
+ uncoveredFunctions,
108
+ hubGaps,
109
+ orphanRequirements,
110
+ staleDomains,
111
+ };
112
+ if (shouldSave) {
113
+ await writeFile(join(analysisDir, ARTIFACT_AUDIT_REPORT), JSON.stringify(report, null, 2));
114
+ }
115
+ return report;
116
+ }
117
+ //# sour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AG,OAAO,CAAC,cAAc,CAAC,CAmO/F"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/api/generate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAoB,MAAM,YAAY,CAAC;AA8DvF;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,cAAc,CAAC,CA4O/F"}