spec-gen-cli 1.1.0 → 1.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 (205) hide show
  1. package/README.md +163 -77
  2. package/dist/api/analyze.d.ts.map +1 -1
  3. package/dist/api/analyze.js +56 -27
  4. package/dist/api/analyze.js.map +1 -1
  5. package/dist/api/drift.d.ts.map +1 -1
  6. package/dist/api/drift.js +26 -20
  7. package/dist/api/drift.js.map +1 -1
  8. package/dist/api/generate.d.ts.map +1 -1
  9. package/dist/api/generate.js +19 -43
  10. package/dist/api/generate.js.map +1 -1
  11. package/dist/api/init.d.ts.map +1 -1
  12. package/dist/api/init.js +6 -5
  13. package/dist/api/init.js.map +1 -1
  14. package/dist/api/run.d.ts.map +1 -1
  15. package/dist/api/run.js +67 -51
  16. package/dist/api/run.js.map +1 -1
  17. package/dist/api/specs.d.ts.map +1 -1
  18. package/dist/api/specs.js +5 -4
  19. package/dist/api/specs.js.map +1 -1
  20. package/dist/api/types.d.ts +7 -1
  21. package/dist/api/types.d.ts.map +1 -1
  22. package/dist/api/verify.d.ts.map +1 -1
  23. package/dist/api/verify.js +31 -32
  24. package/dist/api/verify.js.map +1 -1
  25. package/dist/cli/commands/analyze.d.ts.map +1 -1
  26. package/dist/cli/commands/analyze.js +41 -62
  27. package/dist/cli/commands/analyze.js.map +1 -1
  28. package/dist/cli/commands/doctor.d.ts +9 -0
  29. package/dist/cli/commands/doctor.d.ts.map +1 -0
  30. package/dist/cli/commands/doctor.js +273 -0
  31. package/dist/cli/commands/doctor.js.map +1 -0
  32. package/dist/cli/commands/drift.d.ts.map +1 -1
  33. package/dist/cli/commands/drift.js +18 -32
  34. package/dist/cli/commands/drift.js.map +1 -1
  35. package/dist/cli/commands/generate.d.ts.map +1 -1
  36. package/dist/cli/commands/generate.js +40 -101
  37. package/dist/cli/commands/generate.js.map +1 -1
  38. package/dist/cli/commands/init.d.ts.map +1 -1
  39. package/dist/cli/commands/init.js +17 -15
  40. package/dist/cli/commands/init.js.map +1 -1
  41. package/dist/cli/commands/mcp.d.ts.map +1 -1
  42. package/dist/cli/commands/mcp.js +2 -1
  43. package/dist/cli/commands/mcp.js.map +1 -1
  44. package/dist/cli/commands/run.d.ts +0 -15
  45. package/dist/cli/commands/run.d.ts.map +1 -1
  46. package/dist/cli/commands/run.js +61 -111
  47. package/dist/cli/commands/run.js.map +1 -1
  48. package/dist/cli/commands/verify.d.ts.map +1 -1
  49. package/dist/cli/commands/verify.js +18 -52
  50. package/dist/cli/commands/verify.js.map +1 -1
  51. package/dist/cli/commands/view.d.ts +4 -0
  52. package/dist/cli/commands/view.d.ts.map +1 -1
  53. package/dist/cli/commands/view.js +29 -24
  54. package/dist/cli/commands/view.js.map +1 -1
  55. package/dist/cli/index.js +22 -4
  56. package/dist/cli/index.js.map +1 -1
  57. package/dist/constants.d.ts +254 -0
  58. package/dist/constants.d.ts.map +1 -0
  59. package/dist/constants.js +320 -0
  60. package/dist/constants.js.map +1 -0
  61. package/dist/core/analyzer/artifact-generator.d.ts +8 -0
  62. package/dist/core/analyzer/artifact-generator.d.ts.map +1 -1
  63. package/dist/core/analyzer/artifact-generator.js +59 -11
  64. package/dist/core/analyzer/artifact-generator.js.map +1 -1
  65. package/dist/core/analyzer/call-graph.d.ts.map +1 -1
  66. package/dist/core/analyzer/call-graph.js +135 -1
  67. package/dist/core/analyzer/call-graph.js.map +1 -1
  68. package/dist/core/analyzer/dependency-graph.d.ts +32 -0
  69. package/dist/core/analyzer/dependency-graph.d.ts.map +1 -1
  70. package/dist/core/analyzer/dependency-graph.js +104 -10
  71. package/dist/core/analyzer/dependency-graph.js.map +1 -1
  72. package/dist/core/analyzer/duplicate-detector.d.ts.map +1 -1
  73. package/dist/core/analyzer/duplicate-detector.js +4 -0
  74. package/dist/core/analyzer/duplicate-detector.js.map +1 -1
  75. package/dist/core/analyzer/embedding-service.d.ts +6 -0
  76. package/dist/core/analyzer/embedding-service.d.ts.map +1 -1
  77. package/dist/core/analyzer/embedding-service.js +15 -1
  78. package/dist/core/analyzer/embedding-service.js.map +1 -1
  79. package/dist/core/analyzer/file-walker.d.ts.map +1 -1
  80. package/dist/core/analyzer/file-walker.js +4 -3
  81. package/dist/core/analyzer/file-walker.js.map +1 -1
  82. package/dist/core/analyzer/http-route-parser.d.ts +111 -0
  83. package/dist/core/analyzer/http-route-parser.d.ts.map +1 -0
  84. package/dist/core/analyzer/http-route-parser.js +466 -0
  85. package/dist/core/analyzer/http-route-parser.js.map +1 -0
  86. package/dist/core/analyzer/import-parser.d.ts.map +1 -1
  87. package/dist/core/analyzer/import-parser.js +19 -5
  88. package/dist/core/analyzer/import-parser.js.map +1 -1
  89. package/dist/core/analyzer/refactor-analyzer.d.ts.map +1 -1
  90. package/dist/core/analyzer/refactor-analyzer.js +8 -7
  91. package/dist/core/analyzer/refactor-analyzer.js.map +1 -1
  92. package/dist/core/analyzer/repository-mapper.d.ts.map +1 -1
  93. package/dist/core/analyzer/repository-mapper.js +12 -13
  94. package/dist/core/analyzer/repository-mapper.js.map +1 -1
  95. package/dist/core/analyzer/signature-extractor.d.ts +1 -1
  96. package/dist/core/analyzer/signature-extractor.d.ts.map +1 -1
  97. package/dist/core/analyzer/signature-extractor.js +69 -1
  98. package/dist/core/analyzer/signature-extractor.js.map +1 -1
  99. package/dist/core/analyzer/spec-vector-index.d.ts.map +1 -1
  100. package/dist/core/analyzer/spec-vector-index.js +4 -3
  101. package/dist/core/analyzer/spec-vector-index.js.map +1 -1
  102. package/dist/core/analyzer/vector-index.d.ts.map +1 -1
  103. package/dist/core/analyzer/vector-index.js +29 -1
  104. package/dist/core/analyzer/vector-index.js.map +1 -1
  105. package/dist/core/drift/drift-detector.d.ts.map +1 -1
  106. package/dist/core/drift/drift-detector.js +7 -6
  107. package/dist/core/drift/drift-detector.js.map +1 -1
  108. package/dist/core/drift/git-diff.d.ts.map +1 -1
  109. package/dist/core/drift/git-diff.js +28 -16
  110. package/dist/core/drift/git-diff.js.map +1 -1
  111. package/dist/core/generator/mapping-generator.d.ts.map +1 -1
  112. package/dist/core/generator/mapping-generator.js +11 -10
  113. package/dist/core/generator/mapping-generator.js.map +1 -1
  114. package/dist/core/generator/openspec-compat.d.ts.map +1 -1
  115. package/dist/core/generator/openspec-compat.js +3 -2
  116. package/dist/core/generator/openspec-compat.js.map +1 -1
  117. package/dist/core/generator/openspec-format-generator.js.map +1 -1
  118. package/dist/core/generator/openspec-writer.d.ts +0 -4
  119. package/dist/core/generator/openspec-writer.d.ts.map +1 -1
  120. package/dist/core/generator/openspec-writer.js +30 -41
  121. package/dist/core/generator/openspec-writer.js.map +1 -1
  122. package/dist/core/generator/spec-pipeline.d.ts.map +1 -1
  123. package/dist/core/generator/spec-pipeline.js +4 -4
  124. package/dist/core/generator/spec-pipeline.js.map +1 -1
  125. package/dist/core/generator/stages/stage1-survey.d.ts.map +1 -1
  126. package/dist/core/generator/stages/stage1-survey.js +5 -3
  127. package/dist/core/generator/stages/stage1-survey.js.map +1 -1
  128. package/dist/core/generator/stages/stage2-entities.d.ts.map +1 -1
  129. package/dist/core/generator/stages/stage2-entities.js +10 -9
  130. package/dist/core/generator/stages/stage2-entities.js.map +1 -1
  131. package/dist/core/generator/stages/stage3-services.d.ts.map +1 -1
  132. package/dist/core/generator/stages/stage3-services.js +9 -8
  133. package/dist/core/generator/stages/stage3-services.js.map +1 -1
  134. package/dist/core/generator/stages/stage4-api.d.ts.map +1 -1
  135. package/dist/core/generator/stages/stage4-api.js +10 -9
  136. package/dist/core/generator/stages/stage4-api.js.map +1 -1
  137. package/dist/core/generator/stages/stage5-architecture.d.ts.map +1 -1
  138. package/dist/core/generator/stages/stage5-architecture.js +5 -4
  139. package/dist/core/generator/stages/stage5-architecture.js.map +1 -1
  140. package/dist/core/generator/stages/stage6-adr.d.ts.map +1 -1
  141. package/dist/core/generator/stages/stage6-adr.js +7 -2
  142. package/dist/core/generator/stages/stage6-adr.js.map +1 -1
  143. package/dist/core/services/chat-agent.d.ts.map +1 -1
  144. package/dist/core/services/chat-agent.js +46 -15
  145. package/dist/core/services/chat-agent.js.map +1 -1
  146. package/dist/core/services/config-manager.d.ts.map +1 -1
  147. package/dist/core/services/config-manager.js +32 -26
  148. package/dist/core/services/config-manager.js.map +1 -1
  149. package/dist/core/services/gitignore-manager.d.ts.map +1 -1
  150. package/dist/core/services/gitignore-manager.js +2 -13
  151. package/dist/core/services/gitignore-manager.js.map +1 -1
  152. package/dist/core/services/llm-service.d.ts.map +1 -1
  153. package/dist/core/services/llm-service.js +33 -35
  154. package/dist/core/services/llm-service.js.map +1 -1
  155. package/dist/core/services/mcp-handlers/analysis.d.ts.map +1 -1
  156. package/dist/core/services/mcp-handlers/analysis.js +23 -14
  157. package/dist/core/services/mcp-handlers/analysis.js.map +1 -1
  158. package/dist/core/services/mcp-handlers/graph.d.ts.map +1 -1
  159. package/dist/core/services/mcp-handlers/graph.js +24 -23
  160. package/dist/core/services/mcp-handlers/graph.js.map +1 -1
  161. package/dist/core/services/mcp-handlers/semantic.d.ts +1 -1
  162. package/dist/core/services/mcp-handlers/semantic.d.ts.map +1 -1
  163. package/dist/core/services/mcp-handlers/semantic.js +17 -16
  164. package/dist/core/services/mcp-handlers/semantic.js.map +1 -1
  165. package/dist/core/services/mcp-handlers/utils.d.ts.map +1 -1
  166. package/dist/core/services/mcp-handlers/utils.js +4 -3
  167. package/dist/core/services/mcp-handlers/utils.js.map +1 -1
  168. package/dist/core/services/project-detector.d.ts.map +1 -1
  169. package/dist/core/services/project-detector.js +2 -13
  170. package/dist/core/services/project-detector.js.map +1 -1
  171. package/dist/core/verifier/verification-engine.d.ts +9 -3
  172. package/dist/core/verifier/verification-engine.d.ts.map +1 -1
  173. package/dist/core/verifier/verification-engine.js +25 -13
  174. package/dist/core/verifier/verification-engine.js.map +1 -1
  175. package/dist/types/index.d.ts +2 -0
  176. package/dist/types/index.d.ts.map +1 -1
  177. package/dist/utils/command-helpers.d.ts +38 -0
  178. package/dist/utils/command-helpers.d.ts.map +1 -0
  179. package/dist/utils/command-helpers.js +82 -0
  180. package/dist/utils/command-helpers.js.map +1 -0
  181. package/dist/utils/errors.d.ts.map +1 -1
  182. package/dist/utils/errors.js +4 -3
  183. package/dist/utils/errors.js.map +1 -1
  184. package/dist/utils/logger.d.ts.map +1 -1
  185. package/dist/utils/logger.js +14 -3
  186. package/dist/utils/logger.js.map +1 -1
  187. package/dist/utils/progress.d.ts +1 -1
  188. package/dist/utils/progress.d.ts.map +1 -1
  189. package/dist/utils/progress.js +15 -12
  190. package/dist/utils/progress.js.map +1 -1
  191. package/dist/utils/shutdown.d.ts.map +1 -1
  192. package/dist/utils/shutdown.js +4 -3
  193. package/dist/utils/shutdown.js.map +1 -1
  194. package/package.json +9 -5
  195. package/src/viewer/InteractiveGraphViewer.jsx +182 -139
  196. package/src/viewer/components/ArchitectureView.jsx +19 -19
  197. package/src/viewer/components/ChatPanel.jsx +40 -40
  198. package/src/viewer/components/ClusterGraph.jsx +34 -22
  199. package/src/viewer/components/FilterBar.jsx +26 -26
  200. package/src/viewer/components/FlatGraph.jsx +22 -15
  201. package/src/viewer/components/MicroComponents.jsx +14 -12
  202. package/src/viewer/utils/constants.js +17 -0
  203. package/src/viewer/utils/graph-helpers.js +7 -3
  204. package/src/viewer/utils/graph-helpers.test.ts +39 -0
  205. package/src/viewer/utils/themes.js +170 -0
package/README.md CHANGED
@@ -22,6 +22,9 @@ spec-gen init # Detect project type, create config
22
22
  spec-gen analyze # Static analysis (no API key needed)
23
23
  spec-gen generate # Generate specs (requires API key)
24
24
  spec-gen drift # Check for spec drift
25
+
26
+ # Troubleshoot setup issues
27
+ spec-gen doctor # Check environment and configuration
25
28
  ```
26
29
 
27
30
  <details>
@@ -86,8 +89,10 @@ npm run dev
86
89
 
87
90
  Scans your codebase using pure static analysis:
88
91
  - Walks the directory tree, respects .gitignore, scores files by significance
89
- - Parses imports and exports to build a dependency graph
90
- - Clusters related files into business domains automatically
92
+ - Parses imports and exports to build a dependency graph (TypeScript, JavaScript, Python, Go, Rust, Ruby, Java, C++)
93
+ - Detects HTTP cross-language edges: matches `fetch`/`axios`/`ky`/`got` calls in JS/TS files to FastAPI/Flask/Django route definitions in Python files, creating cross-language dependency edges with `exact`, `path`, or `fuzzy` confidence
94
+ - Resolves Python absolute imports (`from services.retriever import X`) to local files
95
+ - Clusters related files into structural business domains automatically
91
96
  - Produces structured context that makes LLM generation more accurate
92
97
 
93
98
  **2. Generate** (API key required)
@@ -143,6 +148,8 @@ graph TD
143
148
  FW[File Walker] --> SS[Significance Scorer]
144
149
  SS --> IP[Import Parser]
145
150
  IP --> DG[Dependency Graph]
151
+ SS --> HR[HTTP Route Parser]
152
+ HR -->|cross-language edges| DG
146
153
  DG --> RM[Repository Mapper]
147
154
  RM --> AG[Artifact Generator]
148
155
  end
@@ -412,6 +419,7 @@ Priority: CLI flags > environment variables > config file > provider defaults.
412
419
  | `spec-gen run` | Full pipeline: init, analyze, generate | Yes |
413
420
  | `spec-gen view` | Launch interactive graph & spec viewer in the browser | No |
414
421
  | `spec-gen mcp` | Start MCP server (stdio, for Cline / Claude Code) | No |
422
+ | `spec-gen doctor` | Check environment and configuration for common issues | No |
415
423
 
416
424
  ### Global Options
417
425
 
@@ -440,6 +448,7 @@ spec-gen drift [options]
440
448
  --json # JSON output
441
449
  --fail-on <severity> # Exit non-zero threshold: error, warning, info
442
450
  --max-files <n> # Max changed files to analyze (default: 100)
451
+ --verbose # Show detailed issue information
443
452
  --install-hook # Install pre-commit hook
444
453
  --uninstall-hook # Remove pre-commit hook
445
454
  ```
@@ -455,6 +464,23 @@ spec-gen generate [options]
455
464
  --no-overwrite # Skip existing files
456
465
  --adr # Also generate ADRs
457
466
  --adr-only # Generate only ADRs
467
+ --reanalyze # Force fresh analysis even if recent exists
468
+ --analysis <path> # Path to existing analysis directory
469
+ --output-dir <path> # Override openspec output location
470
+ -y, --yes # Skip confirmation prompts
471
+ ```
472
+
473
+ ### Run Options
474
+
475
+ ```bash
476
+ spec-gen run [options]
477
+ --force # Reinitialize even if config exists
478
+ --reanalyze # Force fresh analysis even if recent exists
479
+ --model <name> # LLM model to use for generation
480
+ --dry-run # Show what would be done without making changes
481
+ -y, --yes # Skip all confirmation prompts
482
+ --max-files <n> # Maximum files to analyze (default: 500)
483
+ --adr # Also generate Architecture Decision Records
458
484
  ```
459
485
 
460
486
  ### Analyze Options
@@ -467,6 +493,7 @@ spec-gen analyze [options]
467
493
  --exclude <glob> # Additional exclude patterns
468
494
  --force # Force re-analysis (bypass 1-hour cache)
469
495
  --embed # Build semantic vector index after analysis (requires embedding config)
496
+ --reindex-specs # Re-index OpenSpec specs into the vector index without re-running full analysis
470
497
  ```
471
498
 
472
499
  ### Verify Options
@@ -477,52 +504,53 @@ spec-gen verify [options]
477
504
  --threshold <0-1> # Minimum score to pass (default: 0.7)
478
505
  --files <paths> # Specific files to verify
479
506
  --domains <list> # Only verify specific domains
507
+ --verbose # Show detailed prediction vs actual comparison
480
508
  --json # JSON output
481
509
  ```
482
510
 
511
+ ### Doctor
512
+
513
+ `spec-gen doctor` runs a self-diagnostic and surfaces actionable fixes when something is misconfigured or missing:
514
+
515
+ ```bash
516
+ spec-gen doctor # Run all checks
517
+ spec-gen doctor --json # JSON output for scripting
518
+ ```
519
+
520
+ Checks performed:
521
+
522
+ | Check | What it looks for |
523
+ |-------|------------------|
524
+ | Node.js version | ≥ 20 required |
525
+ | Git repository | `.git` directory and `git` binary on PATH |
526
+ | spec-gen config | `.spec-gen/config.json` exists and is parseable |
527
+ | Analysis artifacts | `repo-structure.json` freshness (warns if >24h old) |
528
+ | OpenSpec directory | `openspec/specs/` exists |
529
+ | LLM provider | API key or `claude` CLI detected |
530
+ | Disk space | Warns < 500 MB, fails < 200 MB |
531
+
532
+ Run `spec-gen doctor` whenever setup instructions aren't working — it tells you exactly what to fix and how.
533
+
483
534
  ## MCP Server
484
535
 
485
536
  `spec-gen mcp` starts spec-gen as a [Model Context Protocol](https://modelcontextprotocol.io/) server over stdio, exposing static analysis as tools that any MCP-compatible AI agent (Cline, Roo Code, Kilocode, Claude Code, Cursor...) can call directly -- no API key required.
486
537
 
487
538
  ### Setup
488
539
 
489
- **Claude Code** -- add a `.mcp.json` at your project root (the repo ships one):
540
+ **Claude Code** -- add a `.mcp.json` at your project root:
490
541
 
491
542
  ```json
492
543
  {
493
544
  "mcpServers": {
494
545
  "spec-gen": {
495
- "command": "node",
496
- "args": ["/absolute/path/to/spec-gen/dist/cli/index.js", "mcp"]
546
+ "command": "spec-gen",
547
+ "args": ["mcp"]
497
548
  }
498
549
  }
499
550
  }
500
551
  ```
501
552
 
502
- **Cline / Roo Code / Kilocode** -- add the same block under `mcpServers` in the MCP settings JSON of your editor.
503
-
504
- ### Quick Start
505
-
506
- **1. Build spec-gen**
507
-
508
- ```bash
509
- git clone https://github.com/clay-good/spec-gen
510
- cd spec-gen && npm install && npm run build
511
- ```
512
-
513
- **2. Generate specs once** (required for drift detection and naming alignment)
514
-
515
- ```bash
516
- cd /path/to/your-project
517
- spec-gen init # detect project type, create config
518
- spec-gen generate # generate OpenSpec specs (requires LLM API key)
519
- ```
520
-
521
- **3. Connect your editor**
522
-
523
- #### Claude Code
524
-
525
- The repo ships a `.mcp.json` -- edit the path and you are done:
553
+ or for local development:
526
554
 
527
555
  ```json
528
556
  {
@@ -535,61 +563,54 @@ The repo ships a `.mcp.json` -- edit the path and you are done:
535
563
  }
536
564
  ```
537
565
 
538
- The tools are available directly in any Claude Code conversation. Just ask naturally -- Claude calls the right tools automatically:
539
-
540
- ```
541
- You: Analyse my codebase and tell me what needs refactoring most urgently
542
- Claude: [analyze_codebase -> get_refactor_report -> analyze_impact on top result]
543
- -> Project summary, top issues ranked by priority, risk score and recommended
544
- strategy for the highest-impact function
545
-
546
- You: Are there any duplicate functions I should consolidate?
547
- Claude: [get_duplicate_report]
548
- -> Clone groups sorted by impact (exact / structural / near), file paths, line ranges
549
-
550
- You: Show me everything that calls parseConfig and draw a diagram
551
- Claude: [get_subgraph with direction: "upstream", format: "mermaid"]
552
- -> Mermaid flowchart of the upstream call chain
553
- ```
566
+ **Cline / Roo Code / Kilocode** -- add the same block under `mcpServers` in the MCP settings JSON of your editor.
554
567
 
555
- #### Cline / Roo Code / Kilocode
568
+ ### Cline / Roo Code / Kilocode
556
569
 
557
- Add the same `mcpServers` block in the editor's MCP settings JSON, then install the pre-built slash command workflows:
570
+ For editors with MCP support, after adding the `mcpServers` block to your settings, download the slash command workflows:
558
571
 
559
572
  ```bash
560
- cd /path/to/your-project
561
573
  mkdir -p .clinerules/workflows
562
- cp /path/to/spec-gen/examples/cline-workflows/*.md .clinerules/workflows/
574
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/examples/cline-workflows/spec-gen-analyze-codebase.md -o .clinerules/workflows/spec-gen-analyze-codebase.md
575
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/examples/cline-workflows/spec-gen-check-spec-drift.md -o .clinerules/workflows/spec-gen-check-spec-drift.md
576
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/examples/cline-workflows/spec-gen-plan-refactor.md -o .clinerules/workflows/spec-gen-plan-refactor.md
577
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/examples/cline-workflows/spec-gen-execute-refactor.md -o .clinerules/workflows/spec-gen-execute-refactor.md
578
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/examples/cline-workflows/spec-gen-implement-feature.md -o .clinerules/workflows/spec-gen-implement-feature.md
579
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/examples/cline-workflows/spec-gen-refactor-codebase.md -o .clinerules/workflows/spec-gen-refactor-codebase.md
563
580
  ```
564
581
 
565
- Type one of the following commands in a conversation:
582
+ Available commands:
566
583
 
567
- | Command | Needs API key | What it does |
568
- |---------|:---:|-------------|
569
- | `/spec-gen-analyze-codebase` | No | Architecture overview, call graph highlights, top refactor issues |
570
- | `/spec-gen-check-spec-drift` | No | Detect code changes not reflected in specs; per-kind remediation guidance |
571
- | `/spec-gen-plan-refactor` | No | Static analysis -> impact assessment -> written plan saved to `.spec-gen/refactor-plan.md` (no code changes) |
572
- | `/spec-gen-execute-refactor` | No | Read the plan and apply changes incrementally, with tests and diff verification after each step |
584
+ | Command | What it does |
585
+ |---------|-------------|
586
+ | `/spec-gen-analyze-codebase` | Runs `analyze_codebase`, summarises the results (project type, file count, top 3 refactor issues, detected domains), shows the call graph highlights, and suggests next steps. |
587
+ | `/spec-gen-check-spec-drift` | Runs `check_spec_drift`, presents issues by severity (gap / stale / uncovered / orphaned-spec), shows per-kind remediation commands, and optionally drills into affected file signatures. |
588
+ | `/spec-gen-plan-refactor` | Runs static analysis, picks the highest-priority target with coverage gate, assesses impact and call graph, then writes a detailed plan to `.spec-gen/refactor-plan.md`. No code changes. |
589
+ | `/spec-gen-execute-refactor` | Reads `.spec-gen/refactor-plan.md`, establishes a green baseline, and applies each planned change one at a time -- with diff verification and test run after every step. Optional final step covers dead-code detection and naming alignment (requires `spec-gen generate`). |
590
+ | `/spec-gen-implement-feature` | Plans and implements a new feature with full architectural context: architecture overview, OpenSpec requirements, insertion points, implementation, and drift check. |
591
+ | `/spec-gen-refactor-codebase` | Convenience redirect that runs `/spec-gen-plan-refactor` followed by `/spec-gen-execute-refactor`. |
573
592
 
574
- `analyze_codebase`, `check_spec_drift`, and all refactoring tools run on **pure static analysis** -- no LLM quota consumed. Only `spec-gen generate` (the one-time spec generation step) requires an API key.
593
+ All six commands ask which directory to use, call the MCP tools directly, and guide you through the results without leaving the editor. They work in any editor that supports the `.clinerules/workflows/` convention.
575
594
 
576
- ### Cline Slash Commands
595
+ ### Claude Skills
577
596
 
578
- `examples/cline-workflows/` contains four executable workflow files. Copy them to your project's `.clinerules/workflows/` to activate them as slash commands:
597
+ For Claude Code, copy the skill files to `.claude/skills/` in your project:
579
598
 
580
599
  ```bash
581
- mkdir -p .clinerules/workflows
582
- cp /path/to/spec-gen/examples/cline-workflows/*.md .clinerules/workflows/
600
+ mkdir -p .claude/skills
601
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/skills/claude-spec-gen.md -o .claude/skills/claude-spec-gen.md
602
+ curl -sL https://raw.githubusercontent.com/clay-good/spec-gen/main/skills/openspec-skill.md -o .claude/skills/openspec-skill.md
583
603
  ```
584
604
 
585
- | Command | What it does |
586
- |---------|-------------|
587
- | `/spec-gen-analyze-codebase` | Runs `analyze_codebase`, summarises the results (project type, file count, top 3 refactor issues, detected domains), shows the call graph highlights, and suggests next steps. |
588
- | `/spec-gen-check-spec-drift` | Runs `check_spec_drift`, presents issues by severity (gap / stale / uncovered / orphaned-spec), shows per-kind remediation commands, and optionally drills into affected file signatures. |
589
- | `/spec-gen-plan-refactor` | Runs static analysis, picks the highest-priority target with coverage gate, assesses impact and call graph, then writes a detailed plan to `.spec-gen/refactor-plan.md`. No code changes. |
590
- | `/spec-gen-execute-refactor` | Reads `.spec-gen/refactor-plan.md`, establishes a green baseline, and applies each planned change one at a time -- with diff verification and test run after every step. Optional final step covers dead-code detection and naming alignment (requires `spec-gen generate`). |
605
+ **Spec-Gen Skill** (`claude-spec-gen.md`) Code archaeology skill that guides Claude through:
606
+ - Project type detection and domain identification
607
+ - Entity extraction, service analysis, API extraction
608
+ - Architecture synthesis and OpenSpec spec generation
591
609
 
592
- All four commands ask which directory to use, call the MCP tools directly, and guide you through the results without leaving the editor. They work in Cline, Roo Code, Kilocode, and any editor that supports the `.clinerules/workflows/` convention.
610
+ **OpenSpec Skill** (`openspec-skill.md`) Skill for working with OpenSpec specifications:
611
+ - Semantic spec search with `search_specs`
612
+ - List domains with `list_spec_domains`
613
+ - Navigate requirements and scenarios
593
614
 
594
615
  ### Tools
595
616
 
@@ -600,7 +621,7 @@ All tools run on **pure static analysis** -- no LLM quota consumed.
600
621
  | Tool | Description | Requires prior analysis |
601
622
  |------|-------------|:---:|
602
623
  | `analyze_codebase` | Run full static analysis: repo structure, dependency graph, call graph (hub functions, entry points, layer violations), and top refactoring priorities. Results cached for 1 hour (`force: true` to bypass). | No |
603
- | `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. | Yes |
624
+ | `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 |
604
625
  | `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 |
605
626
  | `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 |
606
627
 
@@ -613,6 +634,7 @@ All tools run on **pure static analysis** -- no LLM quota consumed.
613
634
  | `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 |
614
635
  | `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 |
615
636
  | `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 |
637
+ | `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 |
616
638
 
617
639
  **Navigation**
618
640
 
@@ -630,6 +652,8 @@ All tools run on **pure static analysis** -- no LLM quota consumed.
630
652
  |------|-------------|:---:|
631
653
  | `get_mapping` | Requirement->function mapping produced by `spec-gen generate`. Shows which functions implement which spec requirements, confidence level, and orphan functions with no spec coverage. | Yes (generate) |
632
654
  | `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) |
655
+ | `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 --embed` or `--reindex-specs`. | Yes (generate) |
656
+ | `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) |
633
657
 
634
658
  ### Parameters
635
659
 
@@ -683,6 +707,11 @@ failOn string Minimum severity to report: "error" | "warning" | "info" (d
683
707
  maxFiles number Max changed files to analyze (default: 100)
684
708
  ```
685
709
 
710
+ **`list_spec_domains`**
711
+ ```
712
+ directory string Absolute path to the project directory
713
+ ```
714
+
686
715
  **`analyze_impact`**
687
716
  ```
688
717
  directory string Absolute path to the project directory
@@ -725,11 +754,19 @@ directory string Absolute path to the project directory
725
754
  filePath string Path to the file, relative to the project directory
726
755
  ```
727
756
 
757
+ **`get_god_functions`**
758
+ ```
759
+ directory string Absolute path to the project directory
760
+ filePath string Optional: restrict search to this file (relative path)
761
+ fanOutThreshold number Minimum fan-out to be considered a god function (default: 8)
762
+ ```
763
+
728
764
  **`suggest_insertion_points`**
729
765
  ```
730
- directory string Absolute path to the project directory
731
- query string Natural-language description of the feature to implement
732
- limit number Max candidates to return (default: 5)
766
+ directory string Absolute path to the project directory
767
+ description string Natural-language description of the feature to implement
768
+ limit number Max candidates to return (default: 5)
769
+ language string Filter by language: "TypeScript" | "Python" | "Go" | ...
733
770
  ```
734
771
 
735
772
  **`search_code`**
@@ -741,6 +778,15 @@ language string Filter by language: "TypeScript" | "Python" | "Go" | ...
741
778
  minFanIn number Only return functions with at least this many callers
742
779
  ```
743
780
 
781
+ **`search_specs`**
782
+ ```
783
+ directory string Absolute path to the project directory
784
+ query string Natural language query, e.g. "email validation workflow"
785
+ limit number Maximum number of results to return (default: 10)
786
+ domain string Filter by domain name (e.g. "auth", "analyzer")
787
+ section string Filter by section type: "requirements" | "purpose" | "design" | "architecture" | "entities"
788
+ ```
789
+
744
790
  ### Typical workflow
745
791
 
746
792
  **Scenario A -- Initial exploration**
@@ -879,7 +925,7 @@ Static analysis output is stored in `.spec-gen/analysis/`:
879
925
  | File | Description |
880
926
  |------|-------------|
881
927
  | `repo-structure.json` | Project structure and metadata |
882
- | `dependency-graph.json` | Import/export relationships |
928
+ | `dependency-graph.json` | Import/export relationships and HTTP cross-language edges (JS/TS → Python) |
883
929
  | `llm-context.json` | Context prepared for LLM (signatures, call graph) |
884
930
  | `dependencies.mermaid` | Visual dependency graph |
885
931
  | `SUMMARY.md` | Human-readable analysis summary |
@@ -913,11 +959,14 @@ spec-gen analyze --embed
913
959
  {
914
960
  "embedding": {
915
961
  "baseUrl": "http://localhost:11434/v1",
916
- "model": "nomic-embed-text"
962
+ "model": "nomic-embed-text",
963
+ "batchSize": 64
917
964
  }
918
965
  }
919
966
  ```
920
967
 
968
+ - `batchSize`: Number of texts to embed per API call (default: 64)
969
+
921
970
  The index is stored in `.spec-gen/analysis/vector-index/` and is automatically used by the viewer's search bar and the `search_code` / `suggest_insertion_points` MCP tools.
922
971
 
923
972
  ## Configuration
@@ -952,6 +1001,9 @@ The index is stored in `.spec-gen/analysis/vector-index/` and is automatically u
952
1001
  | `OPENAI_COMPAT_API_KEY` | `openai-compat` | API key for OpenAI-compatible server |
953
1002
  | `OPENAI_COMPAT_BASE_URL` | `openai-compat` | Base URL, e.g. `https://api.mistral.ai/v1` |
954
1003
  | `GEMINI_API_KEY` | `gemini` | Google Gemini API key |
1004
+ | `EMBED_BASE_URL` | embedding | Base URL for the embedding API (e.g. `http://localhost:11434/v1`) |
1005
+ | `EMBED_MODEL` | embedding | Embedding model name (e.g. `nomic-embed-text`) |
1006
+ | `EMBED_API_KEY` | embedding | API key for the embedding service (defaults to `OPENAI_API_KEY`) |
955
1007
  | `DEBUG` | -- | Enable stack traces on errors |
956
1008
  | `CI` | -- | Auto-detected; enables timestamps in output |
957
1009
 
@@ -977,6 +1029,7 @@ The index is stored in `.spec-gen/analysis/vector-index/` and is automatically u
977
1029
  | Rust | Full | Full |
978
1030
  | Ruby | Full | Full |
979
1031
  | Java | Full | Full |
1032
+ | C++ | Full | Full |
980
1033
 
981
1034
  TypeScript projects get the best results due to richer type information.
982
1035
 
@@ -1000,7 +1053,7 @@ spec-gen init && spec-gen analyze && spec-gen generate && spec-gen drift --insta
1000
1053
  spec-gen exposes a typed Node.js API for integration into other tools (like [OpenSpec CLI](https://github.com/Fission-AI/OpenSpec)). Every CLI command has a corresponding API function that returns structured results instead of printing to the console.
1001
1054
 
1002
1055
  ```bash
1003
- npm install spec-gen
1056
+ npm install spec-gen-cli
1004
1057
  ```
1005
1058
 
1006
1059
  ```typescript
@@ -1041,11 +1094,44 @@ console.log(`Analyzed ${analysis.repoMap.summary.analyzedFiles} files`);
1041
1094
  | `specGenVerify(options?)` | Verify spec accuracy | Yes |
1042
1095
  | `specGenDrift(options?)` | Detect spec-to-code drift | No* |
1043
1096
  | `specGenRun(options?)` | Full pipeline: init + analyze + generate | Yes |
1097
+ | `specGenGetSpecRequirements(options?)` | Read requirement blocks from generated specs | No |
1044
1098
 
1045
1099
  \* `specGenDrift` requires an API key only when `llmEnhanced: true`.
1046
1100
 
1047
1101
  All functions accept an optional `onProgress` callback for status updates and throw errors instead of calling `process.exit`. See [src/api/types.ts](src/api/types.ts) for full option and result type definitions.
1048
1102
 
1103
+ ### Error handling
1104
+
1105
+ All API functions throw `Error` on failure. Wrap calls in try-catch for production use:
1106
+
1107
+ ```typescript
1108
+ import { specGenRun } from 'spec-gen-cli';
1109
+
1110
+ try {
1111
+ const result = await specGenRun({ rootPath: '/path/to/project' });
1112
+ console.log(`Done — ${result.generation.report.filesWritten.length} specs written`);
1113
+ } catch (err) {
1114
+ if ((err as Error).message.includes('API key')) {
1115
+ console.error('Set ANTHROPIC_API_KEY or OPENAI_API_KEY');
1116
+ } else {
1117
+ console.error('spec-gen failed:', (err as Error).message);
1118
+ }
1119
+ }
1120
+ ```
1121
+
1122
+ ### Reading generated spec requirements
1123
+
1124
+ After running `specGenGenerate`, you can programmatically query the requirement-to-function mapping:
1125
+
1126
+ ```typescript
1127
+ import { specGenGetSpecRequirements } from 'spec-gen-cli';
1128
+
1129
+ const { requirements } = await specGenGetSpecRequirements({ rootPath: '/path/to/project' });
1130
+ for (const [key, req] of Object.entries(requirements)) {
1131
+ console.log(`${key}: ${req.title} (${req.specFile})`);
1132
+ }
1133
+ ```
1134
+
1049
1135
  ## Examples
1050
1136
 
1051
1137
  | Example | Description |
@@ -1060,11 +1146,11 @@ All functions accept an optional `onProgress` callback for status updates and th
1060
1146
  npm install # Install dependencies
1061
1147
  npm run dev # Development mode (watch)
1062
1148
  npm run build # Build
1063
- npm run test:run # Run tests (1052 unit tests)
1149
+ npm run test:run # Run tests (1526 unit tests)
1064
1150
  npm run typecheck # Type check
1065
1151
  ```
1066
1152
 
1067
- 1052 unit tests covering static analysis, call graph, refactor analysis, spec mapping, drift detection, LLM enhancement, ADR generation, and the full CLI.
1153
+ 1526 unit tests covering static analysis, call graph, refactor analysis, spec mapping, drift detection, LLM enhancement, ADR generation, and the full CLI.
1068
1154
 
1069
1155
  ## Links
1070
1156
 
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/api/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAmC,MAAM,YAAY,CAAC;AAepG;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAwF5F"}
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"}
@@ -5,22 +5,33 @@
5
5
  * No side effects (no process.exit, no console.log).
6
6
  */
7
7
  import { join } from 'node:path';
8
- import { access, stat, mkdir, writeFile } from 'node:fs/promises';
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';
10
+ import { fileExists, readJsonFile } from '../utils/command-helpers.js';
9
11
  import { readSpecGenConfig } from '../core/services/config-manager.js';
10
12
  import { RepositoryMapper } from '../core/analyzer/repository-mapper.js';
11
- import { DependencyGraphBuilder } from '../core/analyzer/dependency-graph.js';
12
- import { AnalysisArtifactGenerator } from '../core/analyzer/artifact-generator.js';
13
+ import { DependencyGraphBuilder, } from '../core/analyzer/dependency-graph.js';
14
+ import { AnalysisArtifactGenerator, repoStructureToRepoMap } from '../core/analyzer/artifact-generator.js';
13
15
  function progress(onProgress, step, status, detail) {
14
16
  onProgress?.({ phase: 'analyze', step, status, detail });
15
17
  }
16
- async function fileExists(path) {
18
+ /**
19
+ * Load cached analysis artifacts from disk.
20
+ * All four artifact files are saved by AnalysisArtifactGenerator.generateAndSave().
21
+ */
22
+ async function loadCachedArtifacts(outputPath, repoStructure) {
23
+ const llmContext = await readJsonFile(join(outputPath, ARTIFACT_LLM_CONTEXT), ARTIFACT_LLM_CONTEXT) ?? { phase1_survey: { purpose: '', files: [] }, phase2_deep: { purpose: '', files: [] }, phase3_validation: { purpose: '', files: [] } };
24
+ let summaryMarkdown = '';
25
+ let dependencyDiagram = '';
17
26
  try {
18
- await access(path);
19
- return true;
27
+ summaryMarkdown = await readFile(join(outputPath, 'SUMMARY.md'), 'utf-8');
20
28
  }
21
- catch {
22
- return false;
29
+ catch { /* optional */ }
30
+ try {
31
+ dependencyDiagram = await readFile(join(outputPath, 'dependencies.mermaid'), 'utf-8');
23
32
  }
33
+ catch { /* optional */ }
34
+ return { repoStructure, summaryMarkdown, dependencyDiagram, llmContext };
24
35
  }
25
36
  /**
26
37
  * Run static analysis on the codebase.
@@ -33,10 +44,11 @@ async function fileExists(path) {
33
44
  export async function specGenAnalyze(options = {}) {
34
45
  const startTime = Date.now();
35
46
  const rootPath = options.rootPath ?? process.cwd();
36
- const maxFiles = options.maxFiles ?? 500;
47
+ const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
37
48
  const excludePatterns = options.excludePatterns ?? [];
49
+ const includePatterns = options.includePatterns ?? [];
38
50
  const force = options.force ?? false;
39
- const outputRelPath = options.outputPath ?? '.spec-gen/analysis/';
51
+ const outputRelPath = options.outputPath ?? `${SPEC_GEN_ANALYSIS_REL_PATH}/`;
40
52
  const outputPath = join(rootPath, outputRelPath);
41
53
  const { onProgress } = options;
42
54
  // Validate config exists
@@ -46,31 +58,47 @@ export async function specGenAnalyze(options = {}) {
46
58
  }
47
59
  // Check for existing recent analysis
48
60
  if (!force) {
49
- const repoStructurePath = join(outputPath, 'repo-structure.json');
61
+ const repoStructurePath = join(outputPath, ARTIFACT_REPO_STRUCTURE);
50
62
  if (await fileExists(repoStructurePath)) {
51
63
  const stats = await stat(repoStructurePath);
52
64
  const age = Date.now() - stats.mtime.getTime();
53
- const oneHour = 60 * 60 * 1000;
54
- if (age < oneHour) {
65
+ if (age < ANALYSIS_STALE_THRESHOLD_MS) {
55
66
  progress(onProgress, 'Recent analysis exists', 'skip', `${Math.floor(age / 60000)} minutes old`);
56
67
  // Load and return existing analysis
57
- const { readFile } = await import('node:fs/promises');
58
- const repoStructureContent = await readFile(repoStructurePath, 'utf-8');
59
- const repoStructure = JSON.parse(repoStructureContent);
60
- const depGraphPath = join(outputPath, 'dependency-graph.json');
61
- let depGraph;
62
- if (await fileExists(depGraphPath)) {
63
- const depGraphContent = await readFile(depGraphPath, 'utf-8');
64
- depGraph = JSON.parse(depGraphContent);
68
+ const repoStructure = await readJsonFile(repoStructurePath, ARTIFACT_REPO_STRUCTURE);
69
+ if (!repoStructure) {
70
+ throw new Error(`Failed to load ${ARTIFACT_REPO_STRUCTURE} — run spec-gen analyze --force to regenerate`);
65
71
  }
72
+ const depGraph = await readJsonFile(join(outputPath, ARTIFACT_DEPENDENCY_GRAPH), ARTIFACT_DEPENDENCY_GRAPH) ?? undefined;
66
73
  return {
67
- repoMap: repoStructure,
74
+ repoMap: repoStructureToRepoMap(repoStructure),
68
75
  depGraph: depGraph ?? {
69
- nodes: [], edges: [], clusters: [], cycles: [],
70
- rankings: { byImportance: [], byConnectivity: [], clusterCenters: [], leafNodes: [], bridgeNodes: [], orphanNodes: [] },
71
- statistics: { nodeCount: 0, edgeCount: 0, clusterCount: 0, cycleCount: 0, avgDegree: 0, density: 0 },
76
+ nodes: [],
77
+ edges: [],
78
+ clusters: [],
79
+ cycles: [],
80
+ structuralClusters: [],
81
+ rankings: {
82
+ byImportance: [],
83
+ byConnectivity: [],
84
+ clusterCenters: [],
85
+ leafNodes: [],
86
+ bridgeNodes: [],
87
+ orphanNodes: [],
88
+ },
89
+ statistics: {
90
+ nodeCount: 0,
91
+ edgeCount: 0,
92
+ importEdgeCount: 0,
93
+ httpEdgeCount: 0,
94
+ clusterCount: 0,
95
+ cycleCount: 0,
96
+ avgDegree: 0,
97
+ density: 0,
98
+ structuralClusterCount: 0,
99
+ },
72
100
  },
73
- artifacts: { repoStructure },
101
+ artifacts: await loadCachedArtifacts(outputPath, repoStructure),
74
102
  duration: Date.now() - startTime,
75
103
  };
76
104
  }
@@ -83,6 +111,7 @@ export async function specGenAnalyze(options = {}) {
83
111
  const mapper = new RepositoryMapper(rootPath, {
84
112
  maxFiles,
85
113
  excludePatterns: excludePatterns.length > 0 ? excludePatterns : undefined,
114
+ includePatterns: includePatterns.length > 0 ? includePatterns : undefined,
86
115
  });
87
116
  const repoMap = await mapper.map();
88
117
  progress(onProgress, 'Scanning directory structure', 'complete', `${repoMap.summary.analyzedFiles} files`);
@@ -101,7 +130,7 @@ export async function specGenAnalyze(options = {}) {
101
130
  });
102
131
  const artifacts = await artifactGenerator.generateAndSave(repoMap, depGraph);
103
132
  // Save dependency graph
104
- await writeFile(join(outputPath, 'dependency-graph.json'), JSON.stringify(depGraph, null, 2));
133
+ await writeFile(join(outputPath, ARTIFACT_DEPENDENCY_GRAPH), JSON.stringify(depGraph, null, 2));
105
134
  progress(onProgress, 'Generating analysis artifacts', 'complete');
106
135
  const duration = Date.now() - startTime;
107
136
  return { repoMap, depGraph, artifacts, duration };
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/api/analyze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAA8B,MAAM,sCAAsC,CAAC;AAC1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAGnF,SAAS,QAAQ,CAAC,UAAwC,EAAE,IAAY,EAAE,MAAkD,EAAE,MAAe;IAC3I,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAA6B,EAAE;IAClE,MAAM,SAAS,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,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE7E,wBAAwB;IACxB,MAAM,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,yBAAyB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAChG,QAAQ,CAAC,UAAU,EAAE,+BAA+B,EAAE,UAAU,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/api/drift.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AAepE;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAwHtF"}
1
+ {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/api/drift.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AAMpE;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAsItF"}