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.
- package/README.md +163 -77
- package/dist/api/analyze.d.ts.map +1 -1
- package/dist/api/analyze.js +56 -27
- package/dist/api/analyze.js.map +1 -1
- package/dist/api/drift.d.ts.map +1 -1
- package/dist/api/drift.js +26 -20
- package/dist/api/drift.js.map +1 -1
- package/dist/api/generate.d.ts.map +1 -1
- package/dist/api/generate.js +19 -43
- package/dist/api/generate.js.map +1 -1
- package/dist/api/init.d.ts.map +1 -1
- package/dist/api/init.js +6 -5
- package/dist/api/init.js.map +1 -1
- package/dist/api/run.d.ts.map +1 -1
- package/dist/api/run.js +67 -51
- package/dist/api/run.js.map +1 -1
- package/dist/api/specs.d.ts.map +1 -1
- package/dist/api/specs.js +5 -4
- package/dist/api/specs.js.map +1 -1
- package/dist/api/types.d.ts +7 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/verify.d.ts.map +1 -1
- package/dist/api/verify.js +31 -32
- package/dist/api/verify.js.map +1 -1
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +41 -62
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +9 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +273 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/drift.d.ts.map +1 -1
- package/dist/cli/commands/drift.js +18 -32
- package/dist/cli/commands/drift.js.map +1 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +40 -101
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +17 -15
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +2 -1
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/run.d.ts +0 -15
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +61 -111
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/verify.d.ts.map +1 -1
- package/dist/cli/commands/verify.js +18 -52
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/commands/view.d.ts +4 -0
- package/dist/cli/commands/view.d.ts.map +1 -1
- package/dist/cli/commands/view.js +29 -24
- package/dist/cli/commands/view.js.map +1 -1
- package/dist/cli/index.js +22 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/constants.d.ts +254 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +320 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/analyzer/artifact-generator.d.ts +8 -0
- package/dist/core/analyzer/artifact-generator.d.ts.map +1 -1
- package/dist/core/analyzer/artifact-generator.js +59 -11
- package/dist/core/analyzer/artifact-generator.js.map +1 -1
- package/dist/core/analyzer/call-graph.d.ts.map +1 -1
- package/dist/core/analyzer/call-graph.js +135 -1
- package/dist/core/analyzer/call-graph.js.map +1 -1
- package/dist/core/analyzer/dependency-graph.d.ts +32 -0
- package/dist/core/analyzer/dependency-graph.d.ts.map +1 -1
- package/dist/core/analyzer/dependency-graph.js +104 -10
- package/dist/core/analyzer/dependency-graph.js.map +1 -1
- package/dist/core/analyzer/duplicate-detector.d.ts.map +1 -1
- package/dist/core/analyzer/duplicate-detector.js +4 -0
- package/dist/core/analyzer/duplicate-detector.js.map +1 -1
- package/dist/core/analyzer/embedding-service.d.ts +6 -0
- package/dist/core/analyzer/embedding-service.d.ts.map +1 -1
- package/dist/core/analyzer/embedding-service.js +15 -1
- package/dist/core/analyzer/embedding-service.js.map +1 -1
- package/dist/core/analyzer/file-walker.d.ts.map +1 -1
- package/dist/core/analyzer/file-walker.js +4 -3
- package/dist/core/analyzer/file-walker.js.map +1 -1
- package/dist/core/analyzer/http-route-parser.d.ts +111 -0
- package/dist/core/analyzer/http-route-parser.d.ts.map +1 -0
- package/dist/core/analyzer/http-route-parser.js +466 -0
- package/dist/core/analyzer/http-route-parser.js.map +1 -0
- package/dist/core/analyzer/import-parser.d.ts.map +1 -1
- package/dist/core/analyzer/import-parser.js +19 -5
- package/dist/core/analyzer/import-parser.js.map +1 -1
- package/dist/core/analyzer/refactor-analyzer.d.ts.map +1 -1
- package/dist/core/analyzer/refactor-analyzer.js +8 -7
- package/dist/core/analyzer/refactor-analyzer.js.map +1 -1
- package/dist/core/analyzer/repository-mapper.d.ts.map +1 -1
- package/dist/core/analyzer/repository-mapper.js +12 -13
- package/dist/core/analyzer/repository-mapper.js.map +1 -1
- package/dist/core/analyzer/signature-extractor.d.ts +1 -1
- package/dist/core/analyzer/signature-extractor.d.ts.map +1 -1
- package/dist/core/analyzer/signature-extractor.js +69 -1
- package/dist/core/analyzer/signature-extractor.js.map +1 -1
- package/dist/core/analyzer/spec-vector-index.d.ts.map +1 -1
- package/dist/core/analyzer/spec-vector-index.js +4 -3
- package/dist/core/analyzer/spec-vector-index.js.map +1 -1
- package/dist/core/analyzer/vector-index.d.ts.map +1 -1
- package/dist/core/analyzer/vector-index.js +29 -1
- package/dist/core/analyzer/vector-index.js.map +1 -1
- package/dist/core/drift/drift-detector.d.ts.map +1 -1
- package/dist/core/drift/drift-detector.js +7 -6
- package/dist/core/drift/drift-detector.js.map +1 -1
- package/dist/core/drift/git-diff.d.ts.map +1 -1
- package/dist/core/drift/git-diff.js +28 -16
- package/dist/core/drift/git-diff.js.map +1 -1
- package/dist/core/generator/mapping-generator.d.ts.map +1 -1
- package/dist/core/generator/mapping-generator.js +11 -10
- package/dist/core/generator/mapping-generator.js.map +1 -1
- package/dist/core/generator/openspec-compat.d.ts.map +1 -1
- package/dist/core/generator/openspec-compat.js +3 -2
- package/dist/core/generator/openspec-compat.js.map +1 -1
- package/dist/core/generator/openspec-format-generator.js.map +1 -1
- package/dist/core/generator/openspec-writer.d.ts +0 -4
- package/dist/core/generator/openspec-writer.d.ts.map +1 -1
- package/dist/core/generator/openspec-writer.js +30 -41
- package/dist/core/generator/openspec-writer.js.map +1 -1
- package/dist/core/generator/spec-pipeline.d.ts.map +1 -1
- package/dist/core/generator/spec-pipeline.js +4 -4
- package/dist/core/generator/spec-pipeline.js.map +1 -1
- package/dist/core/generator/stages/stage1-survey.d.ts.map +1 -1
- package/dist/core/generator/stages/stage1-survey.js +5 -3
- package/dist/core/generator/stages/stage1-survey.js.map +1 -1
- package/dist/core/generator/stages/stage2-entities.d.ts.map +1 -1
- package/dist/core/generator/stages/stage2-entities.js +10 -9
- package/dist/core/generator/stages/stage2-entities.js.map +1 -1
- package/dist/core/generator/stages/stage3-services.d.ts.map +1 -1
- package/dist/core/generator/stages/stage3-services.js +9 -8
- package/dist/core/generator/stages/stage3-services.js.map +1 -1
- package/dist/core/generator/stages/stage4-api.d.ts.map +1 -1
- package/dist/core/generator/stages/stage4-api.js +10 -9
- package/dist/core/generator/stages/stage4-api.js.map +1 -1
- package/dist/core/generator/stages/stage5-architecture.d.ts.map +1 -1
- package/dist/core/generator/stages/stage5-architecture.js +5 -4
- package/dist/core/generator/stages/stage5-architecture.js.map +1 -1
- package/dist/core/generator/stages/stage6-adr.d.ts.map +1 -1
- package/dist/core/generator/stages/stage6-adr.js +7 -2
- package/dist/core/generator/stages/stage6-adr.js.map +1 -1
- package/dist/core/services/chat-agent.d.ts.map +1 -1
- package/dist/core/services/chat-agent.js +46 -15
- package/dist/core/services/chat-agent.js.map +1 -1
- package/dist/core/services/config-manager.d.ts.map +1 -1
- package/dist/core/services/config-manager.js +32 -26
- package/dist/core/services/config-manager.js.map +1 -1
- package/dist/core/services/gitignore-manager.d.ts.map +1 -1
- package/dist/core/services/gitignore-manager.js +2 -13
- package/dist/core/services/gitignore-manager.js.map +1 -1
- package/dist/core/services/llm-service.d.ts.map +1 -1
- package/dist/core/services/llm-service.js +33 -35
- package/dist/core/services/llm-service.js.map +1 -1
- package/dist/core/services/mcp-handlers/analysis.d.ts.map +1 -1
- package/dist/core/services/mcp-handlers/analysis.js +23 -14
- package/dist/core/services/mcp-handlers/analysis.js.map +1 -1
- package/dist/core/services/mcp-handlers/graph.d.ts.map +1 -1
- package/dist/core/services/mcp-handlers/graph.js +24 -23
- package/dist/core/services/mcp-handlers/graph.js.map +1 -1
- package/dist/core/services/mcp-handlers/semantic.d.ts +1 -1
- package/dist/core/services/mcp-handlers/semantic.d.ts.map +1 -1
- package/dist/core/services/mcp-handlers/semantic.js +17 -16
- package/dist/core/services/mcp-handlers/semantic.js.map +1 -1
- package/dist/core/services/mcp-handlers/utils.d.ts.map +1 -1
- package/dist/core/services/mcp-handlers/utils.js +4 -3
- package/dist/core/services/mcp-handlers/utils.js.map +1 -1
- package/dist/core/services/project-detector.d.ts.map +1 -1
- package/dist/core/services/project-detector.js +2 -13
- package/dist/core/services/project-detector.js.map +1 -1
- package/dist/core/verifier/verification-engine.d.ts +9 -3
- package/dist/core/verifier/verification-engine.d.ts.map +1 -1
- package/dist/core/verifier/verification-engine.js +25 -13
- package/dist/core/verifier/verification-engine.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/command-helpers.d.ts +38 -0
- package/dist/utils/command-helpers.d.ts.map +1 -0
- package/dist/utils/command-helpers.js +82 -0
- package/dist/utils/command-helpers.js.map +1 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +4 -3
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +14 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/progress.d.ts +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +15 -12
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/shutdown.d.ts.map +1 -1
- package/dist/utils/shutdown.js +4 -3
- package/dist/utils/shutdown.js.map +1 -1
- package/package.json +9 -5
- package/src/viewer/InteractiveGraphViewer.jsx +182 -139
- package/src/viewer/components/ArchitectureView.jsx +19 -19
- package/src/viewer/components/ChatPanel.jsx +40 -40
- package/src/viewer/components/ClusterGraph.jsx +34 -22
- package/src/viewer/components/FilterBar.jsx +26 -26
- package/src/viewer/components/FlatGraph.jsx +22 -15
- package/src/viewer/components/MicroComponents.jsx +14 -12
- package/src/viewer/utils/constants.js +17 -0
- package/src/viewer/utils/graph-helpers.js +7 -3
- package/src/viewer/utils/graph-helpers.test.ts +39 -0
- package/src/viewer/utils/themes.js +170 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants for spec-gen
|
|
3
|
+
*
|
|
4
|
+
* Centralises magic numbers so they're easy to find, reason about, and change.
|
|
5
|
+
*/
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// DIRECTORY / PATH NAMES
|
|
8
|
+
// ============================================================================
|
|
9
|
+
/** Hidden directory where spec-gen stores its state */
|
|
10
|
+
export const SPEC_GEN_DIR = '.spec-gen';
|
|
11
|
+
/** Analysis artifacts sub-directory */
|
|
12
|
+
export const SPEC_GEN_ANALYSIS_SUBDIR = 'analysis';
|
|
13
|
+
/** LLM log sub-directory */
|
|
14
|
+
export const SPEC_GEN_LOGS_SUBDIR = 'logs';
|
|
15
|
+
/** Verification reports sub-directory */
|
|
16
|
+
export const SPEC_GEN_VERIFICATION_SUBDIR = 'verification';
|
|
17
|
+
/** Generation outputs sub-directory */
|
|
18
|
+
export const SPEC_GEN_OUTPUTS_SUBDIR = 'outputs';
|
|
19
|
+
/** Spec backups sub-directory */
|
|
20
|
+
export const SPEC_GEN_BACKUPS_SUBDIR = 'backups';
|
|
21
|
+
/** Generation intermediate files sub-directory */
|
|
22
|
+
export const SPEC_GEN_GENERATION_SUBDIR = 'generation';
|
|
23
|
+
/** Run metadata sub-directory */
|
|
24
|
+
export const SPEC_GEN_RUNS_SUBDIR = 'runs';
|
|
25
|
+
/** Config file name inside SPEC_GEN_DIR */
|
|
26
|
+
export const SPEC_GEN_CONFIG_FILENAME = 'config.json';
|
|
27
|
+
/** Relative path to the spec-gen config file */
|
|
28
|
+
export const SPEC_GEN_CONFIG_REL_PATH = `${SPEC_GEN_DIR}/${SPEC_GEN_CONFIG_FILENAME}`;
|
|
29
|
+
/** Relative path to the analysis output directory */
|
|
30
|
+
export const SPEC_GEN_ANALYSIS_REL_PATH = `${SPEC_GEN_DIR}/${SPEC_GEN_ANALYSIS_SUBDIR}`;
|
|
31
|
+
/** Default openspec root directory name */
|
|
32
|
+
export const OPENSPEC_DIR = 'openspec';
|
|
33
|
+
/** Default relative path used when creating a new openspec directory */
|
|
34
|
+
export const DEFAULT_OPENSPEC_PATH = './openspec';
|
|
35
|
+
/** Default openspec specs sub-directory */
|
|
36
|
+
export const OPENSPEC_SPECS_SUBDIR = 'specs';
|
|
37
|
+
/** Default openspec decisions sub-directory */
|
|
38
|
+
export const OPENSPEC_DECISIONS_SUBDIR = 'decisions';
|
|
39
|
+
/** Config file name inside the openspec directory */
|
|
40
|
+
export const OPENSPEC_CONFIG_FILENAME = 'config.yaml';
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// ANALYSIS ARTIFACT FILENAMES
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/** Filename for the repository structure artifact */
|
|
45
|
+
export const ARTIFACT_REPO_STRUCTURE = 'repo-structure.json';
|
|
46
|
+
/** Filename for the dependency graph artifact */
|
|
47
|
+
export const ARTIFACT_DEPENDENCY_GRAPH = 'dependency-graph.json';
|
|
48
|
+
/** Filename for the LLM context artifact */
|
|
49
|
+
export const ARTIFACT_LLM_CONTEXT = 'llm-context.json';
|
|
50
|
+
/** Filename for the requirement mapping artifact */
|
|
51
|
+
export const ARTIFACT_MAPPING = 'mapping.json';
|
|
52
|
+
/** Filename for the refactor priorities artifact */
|
|
53
|
+
export const ARTIFACT_REFACTOR_PRIORITIES = 'refactor-priorities.json';
|
|
54
|
+
/** Filename for the repository map artifact (saved by RepositoryMapper) */
|
|
55
|
+
export const ARTIFACT_REPOSITORY_MAP = 'repository-map.json';
|
|
56
|
+
/** Filename for the generation report saved to outputs/ */
|
|
57
|
+
export const ARTIFACT_GENERATION_REPORT = 'generation-report.json';
|
|
58
|
+
/** Filename for the shutdown state file */
|
|
59
|
+
export const ARTIFACT_SHUTDOWN_STATE = 'shutdown-state.json';
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// LLM / PROVIDER LIMITS
|
|
62
|
+
// ============================================================================
|
|
63
|
+
/** Default maximum context window for Claude models (tokens) */
|
|
64
|
+
export const CLAUDE_MAX_CONTEXT_TOKENS = 200_000;
|
|
65
|
+
/** Default maximum context window for Mistral Vibe (tokens) */
|
|
66
|
+
export const MISTRAL_VIBE_MAX_CONTEXT_TOKENS = 128_000;
|
|
67
|
+
/** Default maximum output tokens for Claude models */
|
|
68
|
+
export const CLAUDE_MAX_OUTPUT_TOKENS = 16_000;
|
|
69
|
+
/** Default maximum output tokens for Mistral Vibe */
|
|
70
|
+
export const MISTRAL_VIBE_MAX_OUTPUT_TOKENS = 4_096;
|
|
71
|
+
/** Maximum buffer size for LLM CLI output (bytes) — 50 MB */
|
|
72
|
+
export const LLM_CLI_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
73
|
+
/** Timeout for LLM CLI calls (ms) — 5 minutes */
|
|
74
|
+
export const LLM_CLI_TIMEOUT_MS = 300_000;
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// ANALYSIS
|
|
77
|
+
// ============================================================================
|
|
78
|
+
/** Default maximum number of files to include in analysis */
|
|
79
|
+
export const DEFAULT_MAX_FILES = 500;
|
|
80
|
+
/** Default maximum number of changed files to check in drift detection */
|
|
81
|
+
export const DEFAULT_DRIFT_MAX_FILES = 100;
|
|
82
|
+
/** How old (ms) an analysis can be before being considered stale (1 hour) */
|
|
83
|
+
export const ANALYSIS_STALE_THRESHOLD_MS = 60 * 60 * 1000;
|
|
84
|
+
/** How old (ms) an analysis can be before being re-used in 'run' (1 hour) */
|
|
85
|
+
export const ANALYSIS_REUSE_THRESHOLD_MS = 60 * 60 * 1000;
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// VIEWER / SERVER
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/** Default port for the Vite viewer server */
|
|
90
|
+
export const DEFAULT_VIEWER_PORT = 5173;
|
|
91
|
+
/** Default host for the Vite viewer server */
|
|
92
|
+
export const DEFAULT_VIEWER_HOST = '127.0.0.1';
|
|
93
|
+
/** Maximum allowed chat request body size (bytes) — 512 KB */
|
|
94
|
+
export const MAX_CHAT_BODY_BYTES = 512 * 1024;
|
|
95
|
+
/** Maximum search query length (characters) */
|
|
96
|
+
export const MAX_QUERY_LENGTH = 1_000;
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// GENERATION
|
|
99
|
+
// ============================================================================
|
|
100
|
+
/** Estimated system prompt overhead per LLM call (tokens) */
|
|
101
|
+
export const LLM_SYSTEM_PROMPT_OVERHEAD_TOKENS = 500;
|
|
102
|
+
/** Estimated output / input token ratio for spec generation tasks */
|
|
103
|
+
export const GENERATION_OUTPUT_RATIO = 0.4;
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// DEFAULT MODELS (per provider)
|
|
106
|
+
// ============================================================================
|
|
107
|
+
export const DEFAULT_ANTHROPIC_MODEL = 'claude-sonnet-4-20250514';
|
|
108
|
+
export const DEFAULT_OPENAI_MODEL = 'gpt-4o';
|
|
109
|
+
export const DEFAULT_OPENAI_COMPAT_MODEL = 'mistral-large-latest';
|
|
110
|
+
export const DEFAULT_GEMINI_MODEL = 'gemini-2.0-flash';
|
|
111
|
+
/** Lighter model used for interactive chat (lower cost, faster) */
|
|
112
|
+
export const DEFAULT_CHAT_OPENAI_MODEL = 'gpt-4o-mini';
|
|
113
|
+
// ============================================================================
|
|
114
|
+
// DOCTOR / ENVIRONMENT CHECKS
|
|
115
|
+
// ============================================================================
|
|
116
|
+
/** Minimum Node.js major version required */
|
|
117
|
+
export const MIN_NODE_MAJOR_VERSION = 20;
|
|
118
|
+
/** Analysis age (hours) beyond which doctor warns it may be stale */
|
|
119
|
+
export const ANALYSIS_AGE_WARNING_HOURS = 24;
|
|
120
|
+
/** Minimum available disk space (MB) before doctor reports failure */
|
|
121
|
+
export const MIN_DISK_SPACE_FAIL_MB = 200;
|
|
122
|
+
/** Minimum available disk space (MB) before doctor reports a warning */
|
|
123
|
+
export const MIN_DISK_SPACE_WARN_MB = 500;
|
|
124
|
+
// ============================================================================
|
|
125
|
+
// LLM SERVICE DEFAULTS
|
|
126
|
+
// ============================================================================
|
|
127
|
+
/** Default maximum number of retries for LLM API calls */
|
|
128
|
+
export const DEFAULT_LLM_MAX_RETRIES = 3;
|
|
129
|
+
/** Default initial retry delay (ms) */
|
|
130
|
+
export const DEFAULT_LLM_INITIAL_DELAY_MS = 1_000;
|
|
131
|
+
/** Default maximum retry delay (ms) */
|
|
132
|
+
export const DEFAULT_LLM_MAX_DELAY_MS = 30_000;
|
|
133
|
+
/** Default timeout for LLM API calls (ms) — 2 minutes */
|
|
134
|
+
export const DEFAULT_LLM_TIMEOUT_MS = 120_000;
|
|
135
|
+
/** Default cost warning threshold (USD) */
|
|
136
|
+
export const DEFAULT_LLM_COST_WARNING_THRESHOLD = 10.0;
|
|
137
|
+
/** Fraction of max context tokens at which a warning is emitted */
|
|
138
|
+
export const CONTEXT_LIMIT_WARNING_RATIO = 0.9;
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// DIFF / GIT
|
|
141
|
+
// ============================================================================
|
|
142
|
+
/** Maximum characters of diff content passed to LLM context */
|
|
143
|
+
export const DIFF_MAX_CHARS = 4_000;
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// GENERATION PIPELINE — per-stage LLM output token budgets
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/** Stage 1 (project survey) max output tokens */
|
|
148
|
+
export const STAGE1_MAX_TOKENS = 3_000;
|
|
149
|
+
/** Stage 2 (entity extraction) max output tokens per file chunk */
|
|
150
|
+
export const STAGE2_MAX_TOKENS = 4_000;
|
|
151
|
+
/** Stage 3 (service analysis) max output tokens per file chunk */
|
|
152
|
+
export const STAGE3_MAX_TOKENS = 4_000;
|
|
153
|
+
/** Stage 4 (API extraction) max output tokens per file chunk */
|
|
154
|
+
export const STAGE4_MAX_TOKENS = 4_000;
|
|
155
|
+
/** Stage 5 (architecture synthesis) max output tokens */
|
|
156
|
+
export const STAGE5_MAX_TOKENS = 3_000;
|
|
157
|
+
/** Stage 6 (ADR enrichment) max output tokens */
|
|
158
|
+
export const STAGE6_MAX_TOKENS = 5_000;
|
|
159
|
+
/** Max file content characters passed per chunk to stages 2–4 */
|
|
160
|
+
export const STAGE_CHUNK_MAX_CHARS = 8_000;
|
|
161
|
+
/** Max characters of skeleton excerpt appended to graph prompt */
|
|
162
|
+
export const SKELETON_EXCERPT_MAX_CHARS = 4_000;
|
|
163
|
+
/** Verification engine: max tokens for file-purpose prediction */
|
|
164
|
+
export const VERIFICATION_PREDICTION_MAX_TOKENS = 1_000;
|
|
165
|
+
/** Drift detector: max tokens for LLM change classification */
|
|
166
|
+
export const DRIFT_CLASSIFICATION_MAX_TOKENS = 200;
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// CHAT AGENT
|
|
169
|
+
// ============================================================================
|
|
170
|
+
/** Max output tokens for chat agent turns (Anthropic) */
|
|
171
|
+
export const CHAT_AGENT_MAX_TOKENS = 4_096;
|
|
172
|
+
/** Characters of API error body included in error messages */
|
|
173
|
+
export const API_ERROR_PREVIEW_LENGTH = 300;
|
|
174
|
+
// ============================================================================
|
|
175
|
+
// ANALYSIS / COST ESTIMATION
|
|
176
|
+
// ============================================================================
|
|
177
|
+
/** Fallback estimated tokens for the project survey phase when not yet computed */
|
|
178
|
+
export const DEFAULT_SURVEY_ESTIMATED_TOKENS = 2_000;
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// REPOSITORY MAPPER — slice limits for summary output
|
|
181
|
+
// ============================================================================
|
|
182
|
+
/** Max high-value files retained after scoring */
|
|
183
|
+
export const HIGH_VALUE_FILES_LIMIT = 50;
|
|
184
|
+
/** Max high-value files shown in text summary */
|
|
185
|
+
export const HIGH_VALUE_FILES_PREVIEW_LIMIT = 20;
|
|
186
|
+
/** Max entry points shown in text summary */
|
|
187
|
+
export const ENTRY_POINTS_PREVIEW_LIMIT = 10;
|
|
188
|
+
/** Max languages shown in text summary */
|
|
189
|
+
export const LANGUAGES_PREVIEW_LIMIT = 10;
|
|
190
|
+
/** Max directories shown in text summary */
|
|
191
|
+
export const DIRECTORIES_PREVIEW_LIMIT = 15;
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// GRAPH ANALYSIS — risk scoring
|
|
194
|
+
// ============================================================================
|
|
195
|
+
/** Risk score weight for fan-in (callers) */
|
|
196
|
+
export const RISK_SCORE_FAN_IN_WEIGHT = 4;
|
|
197
|
+
/** Risk score weight for fan-out (callees) */
|
|
198
|
+
export const RISK_SCORE_FAN_OUT_WEIGHT = 2;
|
|
199
|
+
/** Risk score bonus when the node is a hub */
|
|
200
|
+
export const RISK_SCORE_HUB_BONUS = 20;
|
|
201
|
+
/** Risk score weight for blast radius */
|
|
202
|
+
export const RISK_SCORE_BLAST_RADIUS_WEIGHT = 1.5;
|
|
203
|
+
/** Risk score at or below which a function is considered low-risk */
|
|
204
|
+
export const RISK_SCORE_LOW_THRESHOLD = 20;
|
|
205
|
+
/** Risk score at or below which a function is considered medium-risk */
|
|
206
|
+
export const RISK_SCORE_MEDIUM_THRESHOLD = 45;
|
|
207
|
+
/** Fan-out at or above which a function is treated as a god-function */
|
|
208
|
+
export const GOD_FUNCTION_FAN_OUT_THRESHOLD = 8;
|
|
209
|
+
/** Fan-out threshold for SRP (single-responsibility) refactoring recommendation */
|
|
210
|
+
export const REFACTOR_SRP_FAN_OUT_THRESHOLD = 5;
|
|
211
|
+
/** Maximum fan-in for a node to be a low-risk refactor candidate */
|
|
212
|
+
export const LOW_RISK_MAX_FAN_IN = 2;
|
|
213
|
+
/** Maximum fan-out for a node to be a low-risk refactor candidate */
|
|
214
|
+
export const LOW_RISK_MAX_FAN_OUT = 3;
|
|
215
|
+
/** Default minimum fan-in to be classified as a critical hub */
|
|
216
|
+
export const CRITICAL_HUBS_DEFAULT_MIN_FAN_IN = 3;
|
|
217
|
+
/** Default subgraph traversal depth */
|
|
218
|
+
export const SUBGRAPH_DEFAULT_MAX_DEPTH = 3;
|
|
219
|
+
/** Maximum allowed subgraph traversal depth */
|
|
220
|
+
export const SUBGRAPH_MAX_DEPTH_LIMIT = 20;
|
|
221
|
+
/** Criticality score weight for fan-in */
|
|
222
|
+
export const CRITICALITY_FAN_IN_WEIGHT = 3;
|
|
223
|
+
/** Criticality score weight for fan-out */
|
|
224
|
+
export const CRITICALITY_FAN_OUT_WEIGHT = 1.5;
|
|
225
|
+
/** Criticality score bonus when a node has layer violations */
|
|
226
|
+
export const CRITICALITY_VIOLATION_BONUS = 10;
|
|
227
|
+
/** Fan-in at or above which a hub is treated as heavily depended-upon */
|
|
228
|
+
export const HUB_HIGH_FAN_IN_THRESHOLD = 8;
|
|
229
|
+
/** Fan-out at or above which a hub is treated as an orchestration-heavy god-function */
|
|
230
|
+
export const HUB_HIGH_FAN_OUT_THRESHOLD = 5;
|
|
231
|
+
/** Stability score at or above which a hub can be refactored now */
|
|
232
|
+
export const STABILITY_SCORE_CAN_REFACTOR = 60;
|
|
233
|
+
/** Stability score at or above which a hub can be refactored after stabilising deps */
|
|
234
|
+
export const STABILITY_SCORE_STABILISE_FIRST = 30;
|
|
235
|
+
/** Default number of refactor candidates to return */
|
|
236
|
+
export const LOW_RISK_REFACTOR_CANDIDATES_DEFAULT_LIMIT = 5;
|
|
237
|
+
/** Default number of leaf functions to return */
|
|
238
|
+
export const LEAF_FUNCTIONS_DEFAULT_LIMIT = 20;
|
|
239
|
+
// ============================================================================
|
|
240
|
+
// MAPPING GENERATOR — similarity scoring
|
|
241
|
+
// ============================================================================
|
|
242
|
+
/** Similarity score returned for containment matches (one name includes the other) */
|
|
243
|
+
export const SIMILARITY_CONTAINMENT_SCORE = 0.8;
|
|
244
|
+
/** Weight applied to Jaccard token-overlap similarity */
|
|
245
|
+
export const SIMILARITY_TOKEN_OVERLAP_WEIGHT = 0.7;
|
|
246
|
+
/** Minimum heuristic similarity score to include a function as a candidate match */
|
|
247
|
+
export const HEURISTIC_MATCH_MIN_SCORE = 0.7;
|
|
248
|
+
/** Maximum number of heuristic fallback matches returned per operation */
|
|
249
|
+
export const MAX_HEURISTIC_MATCHES_PER_OP = 2;
|
|
250
|
+
// ============================================================================
|
|
251
|
+
// STAGE 5 — architecture synthesis prompt limits
|
|
252
|
+
// ============================================================================
|
|
253
|
+
/** Max hub functions included in Stage 5 architecture prompt */
|
|
254
|
+
export const STAGE5_HUB_FUNCTIONS_LIMIT = 8;
|
|
255
|
+
/** Max entry points included in Stage 5 architecture prompt */
|
|
256
|
+
export const STAGE5_ENTRY_POINTS_LIMIT = 8;
|
|
257
|
+
/** Max layer violations included in Stage 5 architecture prompt */
|
|
258
|
+
export const STAGE5_VIOLATIONS_LIMIT = 5;
|
|
259
|
+
// ============================================================================
|
|
260
|
+
// ARTIFACT GENERATOR
|
|
261
|
+
// ============================================================================
|
|
262
|
+
/** Approximate tokens per character used for LLM context token estimation (~4 chars/token) */
|
|
263
|
+
export const TOKENS_PER_CHAR_DEFAULT = 0.25;
|
|
264
|
+
/** Max characters of file content included per file in Phase 2 (deep analysis) */
|
|
265
|
+
export const PHASE2_FILE_CONTENT_MAX_CHARS = 10_000;
|
|
266
|
+
/** Max characters of file content included per file in Phase 3 (validation) */
|
|
267
|
+
export const PHASE3_FILE_CONTENT_MAX_CHARS = 5_000;
|
|
268
|
+
/** Max files shown in dependency diagram (Mermaid) */
|
|
269
|
+
export const DEPENDENCY_DIAGRAM_MAX_FILES = 30;
|
|
270
|
+
// ============================================================================
|
|
271
|
+
// MCP HANDLERS
|
|
272
|
+
// ============================================================================
|
|
273
|
+
/** Max number of top refactor issues returned by analyze_codebase */
|
|
274
|
+
export const TOP_REFACTOR_ISSUES_LIMIT = 10;
|
|
275
|
+
/** Composite score semantic weight for suggest_insertion_points */
|
|
276
|
+
export const INSERTION_SEMANTIC_WEIGHT = 0.6;
|
|
277
|
+
/** Composite score structural weight for suggest_insertion_points */
|
|
278
|
+
export const INSERTION_STRUCTURAL_WEIGHT = 0.4;
|
|
279
|
+
/** Structural bonus scores per insertion role */
|
|
280
|
+
export const INSERTION_ROLE_BONUS_ENTRY_POINT = 1.0;
|
|
281
|
+
export const INSERTION_ROLE_BONUS_ORCHESTRATOR = 0.8;
|
|
282
|
+
export const INSERTION_ROLE_BONUS_HUB = 0.6;
|
|
283
|
+
export const INSERTION_ROLE_BONUS_INTERNAL = 0.4;
|
|
284
|
+
export const INSERTION_ROLE_BONUS_UTILITY = 0.3;
|
|
285
|
+
/** Fan-out threshold at or above which a node is classified as an orchestrator */
|
|
286
|
+
export const INSERTION_ORCHESTRATOR_FAN_OUT_THRESHOLD = 5;
|
|
287
|
+
// ============================================================================
|
|
288
|
+
// ANALYSIS ARTIFACT — LLM context file selection
|
|
289
|
+
// ============================================================================
|
|
290
|
+
/** Maximum files included in LLM deep analysis phase */
|
|
291
|
+
export const MAX_DEEP_ANALYSIS_FILES = 20;
|
|
292
|
+
/** Fraction of high-value files selected for LLM deep analysis */
|
|
293
|
+
export const DEEP_ANALYSIS_FILE_RATIO = 0.3;
|
|
294
|
+
/** Maximum files included in LLM validation phase */
|
|
295
|
+
export const MAX_VALIDATION_FILES = 5;
|
|
296
|
+
// ============================================================================
|
|
297
|
+
// GENERATE COMMAND
|
|
298
|
+
// ============================================================================
|
|
299
|
+
/** Estimated cost (USD) above which the generate command prompts for confirmation */
|
|
300
|
+
export const COST_CONFIRMATION_THRESHOLD = 0.5;
|
|
301
|
+
// ============================================================================
|
|
302
|
+
// REFACTOR ANALYZER — priority scoring
|
|
303
|
+
// ============================================================================
|
|
304
|
+
/** Base score added for each fan-in/fan-out excess block */
|
|
305
|
+
export const REFACTOR_EXCESS_BASE_SCORE = 2;
|
|
306
|
+
/** Maximum proportional score boost for excess fan-in */
|
|
307
|
+
export const MAX_FAN_IN_SCORE_BOOST = 3;
|
|
308
|
+
/** Maximum proportional score boost for excess fan-out */
|
|
309
|
+
export const MAX_FAN_OUT_SCORE_BOOST = 3;
|
|
310
|
+
/** Base score added for SRP violations */
|
|
311
|
+
export const SRP_BASE_SCORE = 1.5;
|
|
312
|
+
/** Per-requirement penalty above SRP_MAX_REQUIREMENTS */
|
|
313
|
+
export const SRP_PER_REQUIREMENT_PENALTY = 0.5;
|
|
314
|
+
/** Score added for clone group membership */
|
|
315
|
+
export const CLONE_GROUP_MEMBERSHIP_SCORE = 1.5;
|
|
316
|
+
/** Maximum call-graph depth considered "shallow" (bonus for refactoring) */
|
|
317
|
+
export const SHALLOW_FUNCTION_DEPTH_MAX = 2;
|
|
318
|
+
/** Score bonus for shallow functions with issues */
|
|
319
|
+
export const SHALLOW_FUNCTION_SCORE_BONUS = 0.5;
|
|
320
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AAExC,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;AAEnD,4BAA4B;AAC5B,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE3C,yCAAyC;AACzC,MAAM,CAAC,MAAM,4BAA4B,GAAG,cAAc,CAAC;AAE3D,uCAAuC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AAEjD,iCAAiC;AACjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AAEjD,kDAAkD;AAClD,MAAM,CAAC,MAAM,0BAA0B,GAAG,YAAY,CAAC;AAE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C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,0CAA0C;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,yDAAyD;AACzD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,oDAAoD;AACpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC"}
|
|
@@ -140,6 +140,14 @@ export interface ArtifactGeneratorOptions {
|
|
|
140
140
|
/** Approximate tokens per character for estimation */
|
|
141
141
|
tokensPerChar?: number;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Convert a serialised RepoStructure (from repo-structure.json on disk) back
|
|
145
|
+
* to a minimal RepositoryMap-compatible object. Only the fields that
|
|
146
|
+
* consumers of the cached-analysis path actually use are populated; the
|
|
147
|
+
* file-level arrays (`allFiles`, `highValueFiles`, etc.) are left empty
|
|
148
|
+
* because the original per-file data is not persisted to disk.
|
|
149
|
+
*/
|
|
150
|
+
export declare function repoStructureToRepoMap(rs: RepoStructure): RepositoryMap;
|
|
143
151
|
/**
|
|
144
152
|
* Generates analysis artifacts from repository map and dependency graph
|
|
145
153
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-generator.d.ts","sourceRoot":"","sources":["../../../src/core/analyzer/artifact-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"artifact-generator.d.ts","sourceRoot":"","sources":["../../../src/core/analyzer/artifact-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MA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CAAC,yBAAyB;IAcjC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAajC;;OAEG;YACW,kBAAkB;CAoKjC;AAMD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAG5B;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAG5B"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { writeFile, mkdir, readFile } from 'node:fs/promises';
|
|
8
8
|
import { join, basename } from 'node:path';
|
|
9
|
+
import { TOKENS_PER_CHAR_DEFAULT, PHASE2_FILE_CONTENT_MAX_CHARS, PHASE3_FILE_CONTENT_MAX_CHARS, DEPENDENCY_DIAGRAM_MAX_FILES, ARTIFACT_REPO_STRUCTURE, ARTIFACT_LLM_CONTEXT, ARTIFACT_MAPPING, ARTIFACT_REFACTOR_PRIORITIES, } from '../../constants.js';
|
|
9
10
|
import { toMermaidFormat } from './dependency-graph.js';
|
|
10
11
|
/**
|
|
11
12
|
* Heuristic to detect test/spec files across languages.
|
|
@@ -30,6 +31,47 @@ export function isTestFile(filePath) {
|
|
|
30
31
|
/[A-Z][a-zA-Z0-9]*Spec\.(kt|scala|rb)$/.test(name) // Kotlin/Ruby: FooSpec.kt
|
|
31
32
|
);
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert a serialised RepoStructure (from repo-structure.json on disk) back
|
|
36
|
+
* to a minimal RepositoryMap-compatible object. Only the fields that
|
|
37
|
+
* consumers of the cached-analysis path actually use are populated; the
|
|
38
|
+
* file-level arrays (`allFiles`, `highValueFiles`, etc.) are left empty
|
|
39
|
+
* because the original per-file data is not persisted to disk.
|
|
40
|
+
*/
|
|
41
|
+
export function repoStructureToRepoMap(rs) {
|
|
42
|
+
return {
|
|
43
|
+
metadata: {
|
|
44
|
+
projectName: rs.projectName,
|
|
45
|
+
projectType: (rs.projectType === 'node-typescript' ? 'nodejs' : rs.projectType),
|
|
46
|
+
rootPath: '',
|
|
47
|
+
analyzedAt: '',
|
|
48
|
+
version: '',
|
|
49
|
+
},
|
|
50
|
+
summary: {
|
|
51
|
+
totalFiles: rs.statistics.totalFiles,
|
|
52
|
+
analyzedFiles: rs.statistics.analyzedFiles,
|
|
53
|
+
skippedFiles: rs.statistics.skippedFiles,
|
|
54
|
+
languages: [],
|
|
55
|
+
frameworks: rs.frameworks.map(name => ({
|
|
56
|
+
name,
|
|
57
|
+
category: 'other',
|
|
58
|
+
confidence: 'medium',
|
|
59
|
+
evidence: [],
|
|
60
|
+
})),
|
|
61
|
+
directories: [],
|
|
62
|
+
},
|
|
63
|
+
highValueFiles: [],
|
|
64
|
+
entryPoints: [],
|
|
65
|
+
schemaFiles: [],
|
|
66
|
+
configFiles: [],
|
|
67
|
+
clusters: {
|
|
68
|
+
byDirectory: {},
|
|
69
|
+
byDomain: {},
|
|
70
|
+
byLayer: { presentation: [], business: [], data: [], infrastructure: [] },
|
|
71
|
+
},
|
|
72
|
+
allFiles: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
33
75
|
// ============================================================================
|
|
34
76
|
// ARTIFACT GENERATOR
|
|
35
77
|
// ============================================================================
|
|
@@ -44,7 +86,7 @@ export class AnalysisArtifactGenerator {
|
|
|
44
86
|
outputDir: options.outputDir,
|
|
45
87
|
maxDeepAnalysisFiles: options.maxDeepAnalysisFiles ?? 20,
|
|
46
88
|
maxValidationFiles: options.maxValidationFiles ?? 5,
|
|
47
|
-
tokensPerChar: options.tokensPerChar ??
|
|
89
|
+
tokensPerChar: options.tokensPerChar ?? TOKENS_PER_CHAR_DEFAULT,
|
|
48
90
|
};
|
|
49
91
|
}
|
|
50
92
|
/**
|
|
@@ -72,10 +114,10 @@ export class AnalysisArtifactGenerator {
|
|
|
72
114
|
await mkdir(this.options.outputDir, { recursive: true });
|
|
73
115
|
// Save each artifact
|
|
74
116
|
await Promise.all([
|
|
75
|
-
writeFile(join(this.options.outputDir,
|
|
117
|
+
writeFile(join(this.options.outputDir, ARTIFACT_REPO_STRUCTURE), JSON.stringify(artifacts.repoStructure, null, 2)),
|
|
76
118
|
writeFile(join(this.options.outputDir, 'SUMMARY.md'), artifacts.summaryMarkdown),
|
|
77
119
|
writeFile(join(this.options.outputDir, 'dependencies.mermaid'), artifacts.dependencyDiagram),
|
|
78
|
-
writeFile(join(this.options.outputDir,
|
|
120
|
+
writeFile(join(this.options.outputDir, ARTIFACT_LLM_CONTEXT), JSON.stringify(artifacts.llmContext, null, 2)),
|
|
79
121
|
]);
|
|
80
122
|
return artifacts;
|
|
81
123
|
}
|
|
@@ -488,6 +530,12 @@ export class AnalysisArtifactGenerator {
|
|
|
488
530
|
lines.push(`- ${cycleFiles.join(' → ')}`);
|
|
489
531
|
}
|
|
490
532
|
}
|
|
533
|
+
// HTTP cross-language edges
|
|
534
|
+
if (depGraph.statistics.httpEdgeCount > 0) {
|
|
535
|
+
lines.push('');
|
|
536
|
+
lines.push(`**HTTP Cross-Language Edges**: ${depGraph.statistics.httpEdgeCount} edge(s) detected between JS/TS callers and Python route handlers`);
|
|
537
|
+
lines.push(` (${depGraph.statistics.importEdgeCount} static import edges + ${depGraph.statistics.httpEdgeCount} HTTP edges = ${depGraph.statistics.edgeCount} total)`);
|
|
538
|
+
}
|
|
491
539
|
// Orphans
|
|
492
540
|
if (depGraph.rankings.orphanNodes.length > 0) {
|
|
493
541
|
lines.push('');
|
|
@@ -554,8 +602,8 @@ export class AnalysisArtifactGenerator {
|
|
|
554
602
|
generateDependencyDiagram(depGraph) {
|
|
555
603
|
// Use the built-in Mermaid converter with clustering
|
|
556
604
|
const lines = ['```mermaid'];
|
|
557
|
-
// Generate diagram with top
|
|
558
|
-
const mermaid = toMermaidFormat(depGraph,
|
|
605
|
+
// Generate diagram with top files
|
|
606
|
+
const mermaid = toMermaidFormat(depGraph, DEPENDENCY_DIAGRAM_MAX_FILES);
|
|
559
607
|
lines.push(mermaid);
|
|
560
608
|
lines.push('```');
|
|
561
609
|
return lines.join('\n');
|
|
@@ -569,7 +617,7 @@ export class AnalysisArtifactGenerator {
|
|
|
569
617
|
purpose: 'Initial project categorization',
|
|
570
618
|
files: [
|
|
571
619
|
{
|
|
572
|
-
path:
|
|
620
|
+
path: ARTIFACT_REPO_STRUCTURE,
|
|
573
621
|
tokens: 2000, // Estimate
|
|
574
622
|
},
|
|
575
623
|
],
|
|
@@ -587,7 +635,7 @@ export class AnalysisArtifactGenerator {
|
|
|
587
635
|
const tokens = Math.ceil(content.length * this.options.tokensPerChar);
|
|
588
636
|
phase2Files.push({
|
|
589
637
|
path: file.path,
|
|
590
|
-
content: content.slice(0,
|
|
638
|
+
content: content.slice(0, PHASE2_FILE_CONTENT_MAX_CHARS),
|
|
591
639
|
tokens,
|
|
592
640
|
});
|
|
593
641
|
}
|
|
@@ -622,7 +670,7 @@ export class AnalysisArtifactGenerator {
|
|
|
622
670
|
const tokens = Math.ceil(content.length * this.options.tokensPerChar);
|
|
623
671
|
phase3Files.push({
|
|
624
672
|
path: file.path,
|
|
625
|
-
content: content.slice(0,
|
|
673
|
+
content: content.slice(0, PHASE3_FILE_CONTENT_MAX_CHARS),
|
|
626
674
|
tokens,
|
|
627
675
|
});
|
|
628
676
|
}
|
|
@@ -642,7 +690,7 @@ export class AnalysisArtifactGenerator {
|
|
|
642
690
|
const { CallGraphBuilder, serializeCallGraph } = await import('./call-graph.js');
|
|
643
691
|
const { detectDuplicates } = await import('./duplicate-detector.js');
|
|
644
692
|
const { analyzeForRefactoring } = await import('./refactor-analyzer.js');
|
|
645
|
-
const CALL_GRAPH_LANGS = new Set(['Python', 'TypeScript', 'JavaScript', 'Go', 'Rust', 'Ruby', 'Java']);
|
|
693
|
+
const CALL_GRAPH_LANGS = new Set(['Python', 'TypeScript', 'JavaScript', 'Go', 'Rust', 'Ruby', 'Java', 'C++']);
|
|
646
694
|
const signatures = [];
|
|
647
695
|
const callGraphFiles = [];
|
|
648
696
|
for (const file of repoMap.allFiles) {
|
|
@@ -682,7 +730,7 @@ export class AnalysisArtifactGenerator {
|
|
|
682
730
|
// Refactoring priorities (structural — enriched after generate)
|
|
683
731
|
let mappings;
|
|
684
732
|
try {
|
|
685
|
-
const mappingRaw = await readFile(join(this.options.outputDir,
|
|
733
|
+
const mappingRaw = await readFile(join(this.options.outputDir, ARTIFACT_MAPPING), 'utf-8');
|
|
686
734
|
const mappingJson = JSON.parse(mappingRaw);
|
|
687
735
|
mappings = mappingJson.mappings;
|
|
688
736
|
}
|
|
@@ -692,7 +740,7 @@ export class AnalysisArtifactGenerator {
|
|
|
692
740
|
const refactorReport = analyzeForRefactoring(callGraph, mappings, duplicates);
|
|
693
741
|
// Save refactor priorities
|
|
694
742
|
try {
|
|
695
|
-
await writeFile(join(this.options.outputDir,
|
|
743
|
+
await writeFile(join(this.options.outputDir, ARTIFACT_REFACTOR_PRIORITIES), JSON.stringify(refactorReport, null, 2));
|
|
696
744
|
}
|
|
697
745
|
catch {
|
|
698
746
|
// non-fatal
|