codesearch-mcp 0.2.3-alpha → 0.3.0-alpha
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/CHANGELOG.md +31 -1
- package/README.md +46 -26
- package/dist/app.js +5 -19
- package/dist/src/chunking/AstChunker.d.ts +12 -0
- package/dist/src/chunking/AstChunker.js +30 -0
- package/dist/src/chunking/CharacterChunkStrategy.d.ts +8 -0
- package/dist/src/chunking/CharacterChunkStrategy.js +15 -0
- package/dist/src/chunking/DeclarationChunkStrategy.d.ts +15 -0
- package/dist/src/chunking/DeclarationChunkStrategy.js +87 -0
- package/dist/src/chunking/FragmentMerger.d.ts +11 -0
- package/dist/src/chunking/FragmentMerger.js +61 -0
- package/dist/src/chunking/ImportOnlyFilter.d.ts +5 -0
- package/dist/src/chunking/ImportOnlyFilter.js +14 -0
- package/dist/src/chunking/LangchainTextSplitter.d.ts +21 -0
- package/dist/src/chunking/LangchainTextSplitter.js +133 -0
- package/dist/src/chunking/MinSizeSplitPolicy.d.ts +9 -0
- package/dist/src/chunking/MinSizeSplitPolicy.js +18 -0
- package/dist/src/chunking/RunPacker.d.ts +12 -0
- package/dist/src/chunking/RunPacker.js +84 -0
- package/dist/src/chunking/create-chunker.d.ts +3 -0
- package/dist/src/chunking/create-chunker.js +15 -0
- package/dist/src/chunking/interfaces.d.ts +27 -0
- package/dist/src/chunking/interfaces.js +2 -0
- package/dist/src/commands/ConfigCommand.js +1 -9
- package/dist/src/commands/EvalCommand.d.ts +4 -3
- package/dist/src/commands/EvalCommand.js +85 -52
- package/dist/src/commands/IndexCommand.js +0 -22
- package/dist/src/commands/McpCommand.js +2 -8
- package/dist/src/commands/WebCommand.js +2 -5
- package/dist/src/config-error.d.ts +0 -4
- package/dist/src/config-error.js +0 -4
- package/dist/src/config-store.d.ts +1 -54
- package/dist/src/config-store.js +8 -69
- package/dist/src/config.d.ts +8 -17
- package/dist/src/config.js +35 -34
- package/dist/src/constants.d.ts +2 -28
- package/dist/src/constants.js +6 -28
- package/dist/src/container.d.ts +6 -0
- package/dist/src/container.js +12 -3
- package/dist/src/db/schema.d.ts +17 -0
- package/dist/src/db/schema.js +1 -6
- package/dist/src/declarations/DeclarationTree.d.ts +19 -0
- package/dist/src/declarations/DeclarationTree.js +66 -0
- package/dist/src/declarations/DeclarationTreeBuilder.d.ts +22 -0
- package/dist/src/declarations/DeclarationTreeBuilder.js +179 -0
- package/dist/src/declarations/SourceLines.d.ts +37 -0
- package/dist/src/declarations/SourceLines.js +415 -0
- package/dist/src/dependency-traversal.d.ts +0 -6
- package/dist/src/dependency-traversal.js +0 -6
- package/dist/src/enriched-prompt.d.ts +0 -6
- package/dist/src/enriched-prompt.js +0 -6
- package/dist/src/error-record.d.ts +12 -0
- package/dist/src/error-record.js +248 -0
- package/dist/src/eval-corpus.d.ts +16 -0
- package/dist/src/eval-corpus.js +169 -0
- package/dist/src/eval-results.d.ts +6 -3
- package/dist/src/eval-results.js +309 -26
- package/dist/src/file-utils.d.ts +0 -5
- package/dist/src/file-utils.js +0 -5
- package/dist/src/graph.d.ts +0 -25
- package/dist/src/graph.js +0 -28
- package/dist/src/hnsw-settings.d.ts +3 -0
- package/dist/src/hnsw-settings.js +24 -0
- package/dist/src/interfaces/IAstParser.d.ts +2 -39
- package/dist/src/interfaces/IChunker.d.ts +3 -12
- package/dist/src/interfaces/ICorpusInspector.d.ts +7 -0
- package/dist/src/interfaces/ICorpusInspector.js +2 -0
- package/dist/src/interfaces/IDatabase.d.ts +2 -22
- package/dist/src/interfaces/IEmbedder.d.ts +0 -9
- package/dist/src/interfaces/ILogger.d.ts +1 -11
- package/dist/src/interfaces/IMcpToolHandler.d.ts +0 -5
- package/dist/src/interfaces/IMonorepoResolver.d.ts +0 -22
- package/dist/src/interfaces/IProjectDiscovery.d.ts +0 -17
- package/dist/src/interfaces/IRetrievalEvaluator.d.ts +134 -12
- package/dist/src/interfaces/ISearcher.d.ts +16 -5
- package/dist/src/interrupt.js +0 -2
- package/dist/src/owner-path.d.ts +9 -10
- package/dist/src/owner-path.js +11 -23
- package/dist/src/project-scope.d.ts +0 -12
- package/dist/src/project-scope.js +0 -12
- package/dist/src/project-selector.d.ts +0 -5
- package/dist/src/project-selector.js +0 -11
- package/dist/src/retrieval-eval.d.ts +14 -6
- package/dist/src/retrieval-eval.js +345 -59
- package/dist/src/search/result-shaping.d.ts +4 -0
- package/dist/src/search/result-shaping.js +19 -0
- package/dist/src/services/AstParserService.d.ts +2 -62
- package/dist/src/services/AstParserService.js +25 -137
- package/dist/src/services/DatabaseService.d.ts +2 -7
- package/dist/src/services/DatabaseService.js +42 -29
- package/dist/src/services/EmbedderFactory.d.ts +0 -4
- package/dist/src/services/EmbedderFactory.js +0 -5
- package/dist/src/services/IndexerService.d.ts +0 -16
- package/dist/src/services/IndexerService.js +16 -45
- package/dist/src/services/InfinityEmbedder.d.ts +0 -21
- package/dist/src/services/InfinityEmbedder.js +0 -15
- package/dist/src/services/LoggerService.d.ts +7 -5
- package/dist/src/services/LoggerService.js +37 -41
- package/dist/src/services/McpServer.d.ts +22 -14
- package/dist/src/services/McpServer.js +70 -37
- package/dist/src/services/MonorepoAwareDiscoveryService.d.ts +1 -45
- package/dist/src/services/MonorepoAwareDiscoveryService.js +1 -51
- package/dist/src/services/NxMonorepoResolver.d.ts +0 -29
- package/dist/src/services/NxMonorepoResolver.js +5 -56
- package/dist/src/services/OpenAICompatibleEmbedder.d.ts +0 -6
- package/dist/src/services/OpenAICompatibleEmbedder.js +0 -14
- package/dist/src/services/ProjectDiscoveryService.d.ts +0 -4
- package/dist/src/services/ProjectDiscoveryService.js +0 -4
- package/dist/src/services/SearcherService.d.ts +9 -116
- package/dist/src/services/SearcherService.js +95 -176
- package/dist/src/services/VoyageEmbedder.d.ts +0 -6
- package/dist/src/services/VoyageEmbedder.js +0 -6
- package/dist/src/services/WebServerService.d.ts +1 -53
- package/dist/src/services/WebServerService.js +11 -57
- package/dist/src/services/http-retry.d.ts +0 -7
- package/dist/src/services/http-retry.js +1 -10
- package/dist/src/services/infinity-provisioning.d.ts +0 -74
- package/dist/src/services/infinity-provisioning.js +5 -88
- package/dist/src/services/legacy-ollama-index.d.ts +0 -16
- package/dist/src/services/legacy-ollama-index.js +0 -23
- package/dist/src/services/reranker.d.ts +0 -9
- package/dist/src/services/reranker.js +46 -12
- package/dist/src/setup.d.ts +11 -23
- package/dist/src/setup.js +98 -71
- package/dist/src/symbol-name.d.ts +0 -12
- package/dist/src/symbol-name.js +0 -13
- package/dist/src/symbol-rows.d.ts +0 -14
- package/dist/src/symbol-rows.js +0 -14
- package/dist/src/tool-call-log.d.ts +2 -0
- package/dist/src/tool-call-log.js +24 -0
- package/dist/src/tools/GetDependenciesTool.js +1 -1
- package/dist/src/tools/GetDependentsTool.js +1 -1
- package/dist/src/tools/SearchCodebaseTool.js +6 -3
- package/dist/src/tools/format-helpers.d.ts +0 -6
- package/dist/src/tools/format-helpers.js +87 -14
- package/dist/src/web/dashboard.d.ts +0 -8
- package/dist/src/web/dashboard.js +7 -10
- package/package.json +2 -2
- package/dist/src/services/AstChunker.d.ts +0 -42
- package/dist/src/services/AstChunker.js +0 -158
- package/docs/web-dashboard.md +0 -206
package/dist/src/eval-results.js
CHANGED
|
@@ -33,20 +33,109 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.degradedNotices = degradedNotices;
|
|
37
|
+
exports.renderSummary = renderSummary;
|
|
38
|
+
exports.renderComparison = renderComparison;
|
|
39
|
+
exports.renderProgress = renderProgress;
|
|
36
40
|
exports.timestampSlug = timestampSlug;
|
|
37
41
|
exports.writeResultFiles = writeResultFiles;
|
|
42
|
+
exports.normaliseResultFile = normaliseResultFile;
|
|
38
43
|
exports.readResultFile = readResultFile;
|
|
39
44
|
const fs = __importStar(require("fs"));
|
|
40
45
|
const path = __importStar(require("path"));
|
|
46
|
+
const CATEGORIES = ['identifier', 'behaviour', 'concept'];
|
|
47
|
+
const STAGE_LABEL = {
|
|
48
|
+
vector: 'vector (reranker input order, not a rerank-off search)',
|
|
49
|
+
reranked: 'reranked',
|
|
50
|
+
};
|
|
41
51
|
function pct(n) {
|
|
42
52
|
return `${(n * 100).toFixed(1)}%`;
|
|
43
53
|
}
|
|
54
|
+
function signed(n, digits = 4) {
|
|
55
|
+
return (n >= 0 ? '+' : '') + n.toFixed(digits);
|
|
56
|
+
}
|
|
57
|
+
function oneCase(count) {
|
|
58
|
+
return count > 0 ? pct(1 / count) : '—';
|
|
59
|
+
}
|
|
44
60
|
function metricsRow(label, m) {
|
|
45
|
-
return `| ${label} | ${m.count} | ${pct(m.hit1)} | ${pct(m.hit5)} | ${m.mrr10.toFixed(4)} |`;
|
|
61
|
+
return `| ${label} | ${m.count} | ${oneCase(m.count)} | ${pct(m.hit1)} | ${pct(m.hit5)} | ${m.mrr10.toFixed(4)} |`;
|
|
46
62
|
}
|
|
47
63
|
function deltaRow(label, d) {
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
return `| ${label} | ${d.count.current} | ${pct(d.hit1.current)} (${signed(d.hit1.delta)}) | ${pct(d.hit5.current)} (${signed(d.hit5.delta)}) | ${d.mrr10.current.toFixed(4)} (${signed(d.mrr10.delta)}) |`;
|
|
65
|
+
}
|
|
66
|
+
function poolRow(label, p) {
|
|
67
|
+
return `| ${label} | ${p.count} | ${oneCase(p.count)} | ${pct(p.recall)} | ${p.short} |`;
|
|
68
|
+
}
|
|
69
|
+
function pairRow(label, p, count) {
|
|
70
|
+
return `| ${label} | ${p.improved} | ${p.worsened} | ${p.unchanged} | ${p.signTestP.toFixed(4)} | ${oneCase(count)} |`;
|
|
71
|
+
}
|
|
72
|
+
function poolValue(v, format, digits) {
|
|
73
|
+
if (v.baseline === null || v.delta === null)
|
|
74
|
+
return `no pool data → ${format(v.current)}`;
|
|
75
|
+
return `${format(v.baseline)} → ${format(v.current)} (${signed(v.delta, digits)})`;
|
|
76
|
+
}
|
|
77
|
+
function poolDeltaRow(label, d) {
|
|
78
|
+
return `| ${label} | ${poolValue(d.recall, pct, 4)} | ${poolValue(d.short, String, 0)} |`;
|
|
79
|
+
}
|
|
80
|
+
function degradedNotices(run) {
|
|
81
|
+
if (run.rerankFailures === 0 || !run.stages.includes('reranked'))
|
|
82
|
+
return [];
|
|
83
|
+
return [`reranked stage degraded: ${run.rerankFailures} rerank failure(s) scored on the vector-order fallback`];
|
|
84
|
+
}
|
|
85
|
+
function caseCount(change) {
|
|
86
|
+
const o = change.overall;
|
|
87
|
+
return o.improved + o.worsened + o.unchanged;
|
|
88
|
+
}
|
|
89
|
+
function categoryCount(change, category) {
|
|
90
|
+
const p = change.byCategory[category];
|
|
91
|
+
return p ? p.improved + p.worsened + p.unchanged : 0;
|
|
92
|
+
}
|
|
93
|
+
function pairTable(change) {
|
|
94
|
+
const lines = ['| Category | Improved | Worsened | Unchanged | Sign-test p | 1 case |', '|---|---|---|---|---|---|'];
|
|
95
|
+
lines.push(pairRow('Overall', change.overall, caseCount(change)));
|
|
96
|
+
for (const category of CATEGORIES) {
|
|
97
|
+
const p = change.byCategory[category];
|
|
98
|
+
if (p)
|
|
99
|
+
lines.push(pairRow(category, p, categoryCount(change, category)));
|
|
100
|
+
}
|
|
101
|
+
if (change.hit5Lost.length > 0)
|
|
102
|
+
lines.push('', `**Lost hit@5:** ${change.hit5Lost.join(', ')}`);
|
|
103
|
+
if (change.hit5Gained.length > 0)
|
|
104
|
+
lines.push('', `**Gained hit@5:** ${change.hit5Gained.join(', ')}`);
|
|
105
|
+
return lines;
|
|
106
|
+
}
|
|
107
|
+
function formatList(values) {
|
|
108
|
+
return values.map(v => (v === null ? 'not sent' : String(v))).join(', ') || '—';
|
|
109
|
+
}
|
|
110
|
+
function corpusLines(metadata) {
|
|
111
|
+
const lines = metadata.corpora.map(c => `${c.root} @ ${c.commit} — ${c.projects.length} project(s), ${c.chunks} chunks, fingerprint ${c.fingerprint}`);
|
|
112
|
+
if (metadata.liveCases > 0)
|
|
113
|
+
lines.push(`${metadata.liveCases} live-corpus case(s) — not comparable over time`);
|
|
114
|
+
return lines.length > 0 ? lines : ['none recorded'];
|
|
115
|
+
}
|
|
116
|
+
function groupLabel(key, group) {
|
|
117
|
+
return `${key === 'live' ? 'live cases' : key} (${group.cases} case(s))`;
|
|
118
|
+
}
|
|
119
|
+
function corpusTable(stages, group) {
|
|
120
|
+
const lines = ['| Stage | Category | Cases | 1 case | hit@5 | MRR@10 |', '|---|---|---|---|---|---|'];
|
|
121
|
+
for (const stage of stages) {
|
|
122
|
+
const m = group.metrics[stage];
|
|
123
|
+
if (!m)
|
|
124
|
+
continue;
|
|
125
|
+
const row = (label, x) => `| ${stage} | ${label} | ${x.count} | ${oneCase(x.count)} | ${pct(x.hit5)} | ${x.mrr10.toFixed(4)} |`;
|
|
126
|
+
lines.push(row('Overall', m.overall));
|
|
127
|
+
for (const category of CATEGORIES) {
|
|
128
|
+
const cm = m.byCategory[category];
|
|
129
|
+
if (cm)
|
|
130
|
+
lines.push(row(category, cm));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
lines.push('', `Pool recall ${pct(group.pool.overall.recall)}, short pools ${group.pool.overall.short}.`);
|
|
134
|
+
for (const sc of group.stageChanges) {
|
|
135
|
+
const o = sc.change.overall;
|
|
136
|
+
lines.push('', `${sc.from} → ${sc.to}: improved ${o.improved}, worsened ${o.worsened}, unchanged ${o.unchanged}, p=${o.signTestP.toFixed(4)}.`);
|
|
137
|
+
}
|
|
138
|
+
return lines;
|
|
50
139
|
}
|
|
51
140
|
function renderMarkdown(result, comparison) {
|
|
52
141
|
const { metadata, run } = result;
|
|
@@ -58,17 +147,50 @@ function renderMarkdown(result, comparison) {
|
|
|
58
147
|
if (metadata.indexMeta) {
|
|
59
148
|
lines.push(`**Index:** ${metadata.indexMeta.provider}/${metadata.indexMeta.model} (${metadata.indexMeta.dimensions} dims)`);
|
|
60
149
|
}
|
|
61
|
-
|
|
62
|
-
lines.push(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
150
|
+
const corpora = corpusLines(metadata);
|
|
151
|
+
lines.push(corpora.length === 1 ? `**Corpus:** ${corpora[0]}` : `**Corpora:** ${corpora.join('; ')}`);
|
|
152
|
+
const c = metadata.conditions;
|
|
153
|
+
if (c) {
|
|
154
|
+
lines.push(`**Search conditions:** threshold ${c.similarityThreshold} | overfetch ${c.overfetch} | candidateFloor ${c.candidateFloor} | fetchLimit ${formatList(c.fetchLimit)} | ef_search ${formatList(c.efSearch)} | iterative scan ${formatList(c.iterativeScan)}`);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
lines.push('**Search conditions:** not recorded');
|
|
158
|
+
}
|
|
159
|
+
for (const stage of run.stages) {
|
|
160
|
+
const m = run.metrics[stage];
|
|
161
|
+
if (!m)
|
|
162
|
+
continue;
|
|
163
|
+
lines.push('', `## Metrics — ${STAGE_LABEL[stage]}`, '', '| Category | Cases | 1 case | hit@1 | hit@5 | MRR@10 |', '|---|---|---|---|---|---|');
|
|
164
|
+
lines.push(metricsRow('Overall', m.overall));
|
|
165
|
+
for (const category of CATEGORIES) {
|
|
166
|
+
const cm = m.byCategory[category];
|
|
167
|
+
if (cm)
|
|
168
|
+
lines.push(metricsRow(category, cm));
|
|
169
|
+
}
|
|
67
170
|
}
|
|
171
|
+
lines.push('', '## Candidate pool', '', '| Category | Cases | 1 case | Pool recall | Short pools |', '|---|---|---|---|---|');
|
|
172
|
+
lines.push(poolRow('Overall', run.pool.overall));
|
|
173
|
+
for (const category of CATEGORIES) {
|
|
174
|
+
const p = run.pool.byCategory[category];
|
|
175
|
+
if (p)
|
|
176
|
+
lines.push(poolRow(category, p));
|
|
177
|
+
}
|
|
178
|
+
for (const sc of run.stageChanges) {
|
|
179
|
+
lines.push('', `## Stage change — ${sc.from} → ${sc.to}`, '', ...pairTable(sc.change));
|
|
180
|
+
}
|
|
181
|
+
const groups = Object.entries(run.byCorpus);
|
|
182
|
+
if (groups.length > 0) {
|
|
183
|
+
lines.push('', '## Per corpus');
|
|
184
|
+
for (const [key, group] of groups)
|
|
185
|
+
lines.push('', `### ${groupLabel(key, group)}`, '', ...corpusTable(run.stages, group));
|
|
186
|
+
}
|
|
187
|
+
const degraded = degradedNotices(run);
|
|
188
|
+
if (degraded.length > 0)
|
|
189
|
+
lines.push('', ...degraded.map(d => `> ⚠ ${d}`));
|
|
68
190
|
if (run.invalid.length > 0) {
|
|
69
191
|
lines.push('', '## Invalid cases', '', '| Case | Reason |', '|---|---|');
|
|
70
|
-
for (const
|
|
71
|
-
lines.push(`| ${
|
|
192
|
+
for (const ic of run.invalid)
|
|
193
|
+
lines.push(`| ${ic.id} | ${ic.reason}: ${ic.invalidExpects.map(e => e.file).join(', ')} |`);
|
|
72
194
|
}
|
|
73
195
|
if (run.warnings.length > 0) {
|
|
74
196
|
lines.push('', '## Warnings (partially invalid)', '', '| Case | Dropped |', '|---|---|');
|
|
@@ -76,39 +198,200 @@ function renderMarkdown(result, comparison) {
|
|
|
76
198
|
lines.push(`| ${w.id} | ${w.droppedExpects.map(e => e.file).join(', ')} |`);
|
|
77
199
|
}
|
|
78
200
|
if (comparison) {
|
|
201
|
+
const cmp = comparison.result;
|
|
79
202
|
lines.push('', `## Comparison against ${comparison.baselinePath}`, '');
|
|
80
|
-
if (
|
|
81
|
-
lines.push('> ⚠ ' +
|
|
203
|
+
if (cmp.conditionWarnings.length > 0) {
|
|
204
|
+
lines.push('> ⚠ ' + cmp.conditionWarnings.join('; '), '');
|
|
205
|
+
}
|
|
206
|
+
for (const sc of cmp.stages) {
|
|
207
|
+
lines.push(`### ${sc.stage}`, '', '| Category | Cases | hit@1 (Δ) | hit@5 (Δ) | MRR@10 (Δ) |', '|---|---|---|---|---|');
|
|
208
|
+
lines.push(deltaRow('Overall', sc.overall));
|
|
209
|
+
for (const category of CATEGORIES) {
|
|
210
|
+
const d = sc.byCategory[category];
|
|
211
|
+
if (d)
|
|
212
|
+
lines.push(deltaRow(category, d));
|
|
213
|
+
}
|
|
214
|
+
lines.push('', `Paired change, baseline → current (${sc.stage}):`, '', ...pairTable(sc.change), '');
|
|
215
|
+
}
|
|
216
|
+
for (const u of cmp.unmatchedStages) {
|
|
217
|
+
lines.push(`**Stage \`${u.stage}\`** is present only in the ${u.side === 'baseline' ? 'baseline' : 'current run'}; not compared.`, '');
|
|
82
218
|
}
|
|
83
|
-
lines.push('
|
|
84
|
-
lines.push(
|
|
85
|
-
for (const category of
|
|
86
|
-
const d =
|
|
219
|
+
lines.push('### Candidate pool', '', '| Category | Pool recall | Short pools |', '|---|---|---|');
|
|
220
|
+
lines.push(poolDeltaRow('Overall', cmp.pool.overall));
|
|
221
|
+
for (const category of CATEGORIES) {
|
|
222
|
+
const d = cmp.pool.byCategory[category];
|
|
87
223
|
if (d)
|
|
88
|
-
lines.push(
|
|
224
|
+
lines.push(poolDeltaRow(category, d));
|
|
89
225
|
}
|
|
90
|
-
if (comparison.result.hit5Lost.length > 0)
|
|
91
|
-
lines.push('', `**Lost hit@5:** ${comparison.result.hit5Lost.join(', ')}`);
|
|
92
|
-
if (comparison.result.hit5Gained.length > 0)
|
|
93
|
-
lines.push('', `**Gained hit@5:** ${comparison.result.hit5Gained.join(', ')}`);
|
|
94
226
|
}
|
|
95
227
|
return lines.join('\n') + '\n';
|
|
96
228
|
}
|
|
97
|
-
|
|
229
|
+
function consoleMetrics(label, m) {
|
|
230
|
+
return ` ${label.padEnd(10)} — hit@1: ${pct(m.hit1)} hit@5: ${pct(m.hit5)} MRR@10: ${m.mrr10.toFixed(4)} (${m.count}, 1 case = ${oneCase(m.count)})`;
|
|
231
|
+
}
|
|
232
|
+
function consolePairs(label, p) {
|
|
233
|
+
return ` ${label.padEnd(10)} — improved ${p.improved} worsened ${p.worsened} unchanged ${p.unchanged} p=${p.signTestP.toFixed(4)}`;
|
|
234
|
+
}
|
|
235
|
+
function renderSummary(result) {
|
|
236
|
+
const { run, metadata } = result;
|
|
237
|
+
const lines = [];
|
|
238
|
+
lines.push('', `Evaluated ${run.cases.length} case(s) (${run.invalid.length} invalid) against ${metadata.embeddingProvider}/${metadata.embeddingModel}`);
|
|
239
|
+
for (const line of corpusLines(metadata))
|
|
240
|
+
lines.push(` corpus: ${line}`);
|
|
241
|
+
for (const stage of run.stages) {
|
|
242
|
+
const m = run.metrics[stage];
|
|
243
|
+
if (!m)
|
|
244
|
+
continue;
|
|
245
|
+
lines.push(`\n[${STAGE_LABEL[stage]}]`);
|
|
246
|
+
lines.push(consoleMetrics('Overall', m.overall));
|
|
247
|
+
for (const category of CATEGORIES) {
|
|
248
|
+
const cm = m.byCategory[category];
|
|
249
|
+
if (cm)
|
|
250
|
+
lines.push(consoleMetrics(category, cm));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
lines.push('\n[candidate pool]');
|
|
254
|
+
const poolLine = (label, p) => ` ${label.padEnd(10)} — recall: ${pct(p.recall)} short: ${p.short} (${p.count})`;
|
|
255
|
+
lines.push(poolLine('Overall', run.pool.overall));
|
|
256
|
+
for (const category of CATEGORIES) {
|
|
257
|
+
const p = run.pool.byCategory[category];
|
|
258
|
+
if (p)
|
|
259
|
+
lines.push(poolLine(category, p));
|
|
260
|
+
}
|
|
261
|
+
for (const sc of run.stageChanges) {
|
|
262
|
+
lines.push(`\n[${sc.from} → ${sc.to}]`);
|
|
263
|
+
lines.push(consolePairs('Overall', sc.change.overall));
|
|
264
|
+
for (const category of CATEGORIES) {
|
|
265
|
+
const p = sc.change.byCategory[category];
|
|
266
|
+
if (p)
|
|
267
|
+
lines.push(consolePairs(category, p));
|
|
268
|
+
}
|
|
269
|
+
if (sc.change.hit5Lost.length > 0)
|
|
270
|
+
lines.push(` Lost hit@5: ${sc.change.hit5Lost.join(', ')}`);
|
|
271
|
+
if (sc.change.hit5Gained.length > 0)
|
|
272
|
+
lines.push(` Gained hit@5: ${sc.change.hit5Gained.join(', ')}`);
|
|
273
|
+
}
|
|
274
|
+
for (const [key, group] of Object.entries(run.byCorpus)) {
|
|
275
|
+
lines.push(`\n[${groupLabel(key, group)}]`);
|
|
276
|
+
for (const stage of run.stages) {
|
|
277
|
+
const m = group.metrics[stage];
|
|
278
|
+
if (!m)
|
|
279
|
+
continue;
|
|
280
|
+
const cats = CATEGORIES.filter(cat => m.byCategory[cat]).map(cat => `${cat} ${m.byCategory[cat].mrr10.toFixed(4)}`).join(' ');
|
|
281
|
+
lines.push(` ${stage.padEnd(10)} — MRR@10: ${m.overall.mrr10.toFixed(4)} hit@5: ${pct(m.overall.hit5)} (${cats})`);
|
|
282
|
+
}
|
|
283
|
+
lines.push(` ${'pool'.padEnd(10)} — recall: ${pct(group.pool.overall.recall)} short: ${group.pool.overall.short}`);
|
|
284
|
+
for (const sc of group.stageChanges)
|
|
285
|
+
lines.push(consolePairs(`${sc.from}→${sc.to}`, sc.change.overall));
|
|
286
|
+
}
|
|
287
|
+
for (const d of degradedNotices(run))
|
|
288
|
+
lines.push(`\n⚠ ${d}`);
|
|
289
|
+
if (run.invalid.length > 0) {
|
|
290
|
+
lines.push('\nInvalid cases:');
|
|
291
|
+
for (const c of run.invalid)
|
|
292
|
+
lines.push(` ${c.id}: ${c.reason} — ${c.invalidExpects.map(e => e.file).join(', ')}`);
|
|
293
|
+
}
|
|
294
|
+
if (run.warnings.length > 0) {
|
|
295
|
+
lines.push('\nWarnings (scored on remaining valid answers):');
|
|
296
|
+
for (const w of run.warnings)
|
|
297
|
+
lines.push(` ${w.id}: dropped ${w.droppedExpects.map(e => e.file).join(', ')}`);
|
|
298
|
+
}
|
|
299
|
+
return lines;
|
|
300
|
+
}
|
|
301
|
+
function renderComparison(baselinePath, cmp) {
|
|
302
|
+
const lines = [`\nComparison against ${baselinePath}:`];
|
|
303
|
+
for (const w of cmp.conditionWarnings)
|
|
304
|
+
lines.push(` ⚠ ${w}`);
|
|
305
|
+
for (const sc of cmp.stages) {
|
|
306
|
+
lines.push(` [${sc.stage}]`);
|
|
307
|
+
lines.push(` MRR@10: ${sc.overall.mrr10.baseline.toFixed(4)} → ${sc.overall.mrr10.current.toFixed(4)} (${signed(sc.overall.mrr10.delta)})`);
|
|
308
|
+
lines.push(` hit@5: ${pct(sc.overall.hit5.baseline)} → ${pct(sc.overall.hit5.current)}`);
|
|
309
|
+
const o = sc.change.overall;
|
|
310
|
+
lines.push(` paired: improved ${o.improved} worsened ${o.worsened} unchanged ${o.unchanged} p=${o.signTestP.toFixed(4)}`);
|
|
311
|
+
if (sc.change.hit5Lost.length > 0)
|
|
312
|
+
lines.push(` Lost hit@5: ${sc.change.hit5Lost.join(', ')}`);
|
|
313
|
+
if (sc.change.hit5Gained.length > 0)
|
|
314
|
+
lines.push(` Gained hit@5: ${sc.change.hit5Gained.join(', ')}`);
|
|
315
|
+
}
|
|
316
|
+
for (const u of cmp.unmatchedStages) {
|
|
317
|
+
lines.push(` [${u.stage}] only in the ${u.side === 'baseline' ? 'baseline' : 'current run'} — not compared`);
|
|
318
|
+
}
|
|
319
|
+
const p = cmp.pool.overall;
|
|
320
|
+
lines.push(` pool recall: ${poolValue(p.recall, pct, 4)}`);
|
|
321
|
+
lines.push(` short pools: ${poolValue(p.short, String, 0)}`);
|
|
322
|
+
for (const category of CATEGORIES) {
|
|
323
|
+
const d = cmp.pool.byCategory[category];
|
|
324
|
+
if (d)
|
|
325
|
+
lines.push(` ${category.padEnd(10)} — recall ${poolValue(d.recall, pct, 4)} short ${poolValue(d.short, String, 0)}`);
|
|
326
|
+
}
|
|
327
|
+
return lines;
|
|
328
|
+
}
|
|
329
|
+
function renderProgress(p) {
|
|
330
|
+
const head = `[${String(p.index).padStart(String(p.total).length)}/${p.total}] ${p.id}`;
|
|
331
|
+
const secs = `(${(p.ms / 1000).toFixed(1)}s)`;
|
|
332
|
+
if (p.invalid)
|
|
333
|
+
return `${head} invalid — ${p.invalid.reason} ${secs}`;
|
|
334
|
+
const ranks = Object.keys(p.result.stages)
|
|
335
|
+
.map(stage => `${stage} ${p.result.stages[stage]?.rank ?? '—'}`)
|
|
336
|
+
.join(' → ');
|
|
337
|
+
return `${head} ${ranks}${p.result.rerankFailed ? ' (rerank failed)' : ''} ${secs}`;
|
|
338
|
+
}
|
|
98
339
|
function timestampSlug(date) {
|
|
99
340
|
const pad = (n) => String(n).padStart(2, '0');
|
|
100
341
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}_${pad(date.getHours())}-${pad(date.getMinutes())}`;
|
|
101
342
|
}
|
|
102
|
-
/** Writes the JSON + Markdown result files for one eval run; returns their paths. */
|
|
103
343
|
function writeResultFiles(resultsDir, suiteLabel, result, now, comparison) {
|
|
104
344
|
fs.mkdirSync(resultsDir, { recursive: true });
|
|
105
|
-
const
|
|
345
|
+
const stem = `eval_${suiteLabel}_${timestampSlug(now)}`;
|
|
346
|
+
const taken = (base) => fs.existsSync(path.join(resultsDir, `${base}.json`)) || fs.existsSync(path.join(resultsDir, `${base}.md`));
|
|
347
|
+
let base = stem;
|
|
348
|
+
for (let n = 2; taken(base); n++)
|
|
349
|
+
base = `${stem}-${n}`;
|
|
106
350
|
const jsonPath = path.join(resultsDir, `${base}.json`);
|
|
107
351
|
const mdPath = path.join(resultsDir, `${base}.md`);
|
|
108
352
|
fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2) + '\n', 'utf-8');
|
|
109
353
|
fs.writeFileSync(mdPath, renderMarkdown(result, comparison), 'utf-8');
|
|
110
354
|
return { jsonPath, mdPath };
|
|
111
355
|
}
|
|
356
|
+
const EMPTY_POOL = { count: 0, recall: 0, short: 0 };
|
|
357
|
+
function normaliseResultFile(raw) {
|
|
358
|
+
const run = raw?.run;
|
|
359
|
+
if (!run || run.stages !== undefined || run.metrics?.overall === undefined)
|
|
360
|
+
return withCorpusMetadata(raw);
|
|
361
|
+
const stage = raw.metadata?.rerankerModel != null ? 'reranked' : 'vector';
|
|
362
|
+
const cases = run.cases.map(c => ({
|
|
363
|
+
id: c.id, project: c.project, category: c.category, query: c.query,
|
|
364
|
+
stages: { [stage]: { rank: c.rank, matched: c.matched } },
|
|
365
|
+
poolRank: null,
|
|
366
|
+
poolSize: 0,
|
|
367
|
+
rerankFailed: false,
|
|
368
|
+
corpus: null,
|
|
369
|
+
}));
|
|
370
|
+
return {
|
|
371
|
+
metadata: { ...raw.metadata, conditions: null, corpora: [], liveCases: cases.length },
|
|
372
|
+
run: {
|
|
373
|
+
cases,
|
|
374
|
+
invalid: run.invalid ?? [],
|
|
375
|
+
warnings: run.warnings ?? [],
|
|
376
|
+
stages: [stage],
|
|
377
|
+
metrics: { [stage]: run.metrics },
|
|
378
|
+
pool: { overall: EMPTY_POOL, byCategory: {} },
|
|
379
|
+
stageChanges: [],
|
|
380
|
+
rerankFailures: 0,
|
|
381
|
+
byCorpus: {},
|
|
382
|
+
},
|
|
383
|
+
legacy: true,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function withCorpusMetadata(file) {
|
|
387
|
+
if (!file?.metadata || file.metadata.corpora !== undefined)
|
|
388
|
+
return file;
|
|
389
|
+
return {
|
|
390
|
+
...file,
|
|
391
|
+
metadata: { ...file.metadata, corpora: [], liveCases: file.run.cases.length },
|
|
392
|
+
run: { ...file.run, cases: file.run.cases.map(c => ({ ...c, corpus: c.corpus ?? null })), byCorpus: file.run.byCorpus ?? {} },
|
|
393
|
+
};
|
|
394
|
+
}
|
|
112
395
|
function readResultFile(filePath) {
|
|
113
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
396
|
+
return normaliseResultFile(JSON.parse(fs.readFileSync(filePath, 'utf-8')));
|
|
114
397
|
}
|
package/dist/src/file-utils.d.ts
CHANGED
|
@@ -19,10 +19,5 @@ export type IndexingExclusion = {
|
|
|
19
19
|
} | {
|
|
20
20
|
kind: 'ragignore';
|
|
21
21
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Why `collectFiles` would skip the file at `relPath` (relative to the project
|
|
24
|
-
* root, `/`-separated), or null when it would collect it. Checks mirror
|
|
25
|
-
* `collectFiles`: file name, `IGNORE_DIRS` segments, `.ragignore` on every prefix.
|
|
26
|
-
*/
|
|
27
22
|
export declare function indexingExclusion(relPath: string, ig: ReturnType<typeof ignore>): IndexingExclusion | null;
|
|
28
23
|
export declare function collectFiles(dir: string, ig: ReturnType<typeof ignore>, rootDir: string): string[];
|
package/dist/src/file-utils.js
CHANGED
|
@@ -80,11 +80,6 @@ function loadIgnore(projectDir) {
|
|
|
80
80
|
function isIndexableFileName(name) {
|
|
81
81
|
return SOURCE_EXTENSIONS.test(name) && !IGNORE_EXTENSIONS.test(name);
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Why `collectFiles` would skip the file at `relPath` (relative to the project
|
|
85
|
-
* root, `/`-separated), or null when it would collect it. Checks mirror
|
|
86
|
-
* `collectFiles`: file name, `IGNORE_DIRS` segments, `.ragignore` on every prefix.
|
|
87
|
-
*/
|
|
88
83
|
function indexingExclusion(relPath, ig) {
|
|
89
84
|
const segments = relPath.split('/');
|
|
90
85
|
if (!isIndexableFileName(segments[segments.length - 1]))
|
package/dist/src/graph.d.ts
CHANGED
|
@@ -12,33 +12,15 @@ export interface GraphData {
|
|
|
12
12
|
nodes: ProjectNode[];
|
|
13
13
|
edges: Edge[];
|
|
14
14
|
}
|
|
15
|
-
/** A single named graph tab (Workspace, or one per nested Nx repo). */
|
|
16
15
|
export interface GraphView {
|
|
17
16
|
name: string;
|
|
18
17
|
nodes: ProjectNode[];
|
|
19
18
|
edges: Edge[];
|
|
20
19
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Build the project graph data (nodes + relation edges) from a project list.
|
|
23
|
-
* Pure apart from reading each project's `.ragmeta.json`. Shared by the console
|
|
24
|
-
* graph, the graph views, and the web dashboard's `/api/graph`.
|
|
25
|
-
*/
|
|
26
20
|
export declare function buildGraphData(projects: {
|
|
27
21
|
name: string;
|
|
28
22
|
path: string;
|
|
29
23
|
}[]): GraphData;
|
|
30
|
-
/**
|
|
31
|
-
* Split a project list into graph tabs. A project whose name contains a `/`
|
|
32
|
-
* belongs to a nested Nx repo (`<repo>/<sub-project>`); everything else is a
|
|
33
|
-
* flat top-level project.
|
|
34
|
-
*
|
|
35
|
-
* - **Workspace** tab: flat projects + one node per Nx repo (collapsed to a
|
|
36
|
-
* single `nxRepo` node); edges from `.ragmeta.json` relations.
|
|
37
|
-
* - **One tab per Nx repo**: its sub-projects as nodes, with edges between them
|
|
38
|
-
* taken from real import dependencies (`projectEdges`, from `code_dependency`).
|
|
39
|
-
*
|
|
40
|
-
* Returns the Workspace view first, then repo views sorted by name.
|
|
41
|
-
*/
|
|
42
24
|
export declare function buildGraphViews(projects: {
|
|
43
25
|
name: string;
|
|
44
26
|
path: string;
|
|
@@ -46,13 +28,6 @@ export declare function buildGraphViews(projects: {
|
|
|
46
28
|
from: string;
|
|
47
29
|
to: string;
|
|
48
30
|
}[], workspaceRoot: string): GraphView[];
|
|
49
|
-
/**
|
|
50
|
-
* Render the full interactive graph page (vis-network + inner tabs, edge-type
|
|
51
|
-
* filters, legend, project toggle list). Used for the standalone
|
|
52
|
-
* `project-graph.html` and served by the web dashboard at `GET /graph` (embedded
|
|
53
|
-
* via iframe) so both share one implementation. Tab 0 is the Workspace view;
|
|
54
|
-
* double-clicking an Nx-repo node opens that repo's tab.
|
|
55
|
-
*/
|
|
56
31
|
export declare function buildHtml(views: GraphView[]): string;
|
|
57
32
|
export declare function generateProjectGraph(projects: {
|
|
58
33
|
name: string;
|
package/dist/src/graph.js
CHANGED
|
@@ -41,11 +41,6 @@ const fs = __importStar(require("fs"));
|
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const file_utils_1 = require("./file-utils");
|
|
43
43
|
const EMPTY_META = { description: null, stack: null, notes: null, relations: null };
|
|
44
|
-
/**
|
|
45
|
-
* Build the project graph data (nodes + relation edges) from a project list.
|
|
46
|
-
* Pure apart from reading each project's `.ragmeta.json`. Shared by the console
|
|
47
|
-
* graph, the graph views, and the web dashboard's `/api/graph`.
|
|
48
|
-
*/
|
|
49
44
|
function buildGraphData(projects) {
|
|
50
45
|
const nodes = projects.map(p => {
|
|
51
46
|
const meta = (0, file_utils_1.readRagMeta)(p.path);
|
|
@@ -53,18 +48,6 @@ function buildGraphData(projects) {
|
|
|
53
48
|
});
|
|
54
49
|
return { nodes, edges: buildEdges(nodes) };
|
|
55
50
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Split a project list into graph tabs. A project whose name contains a `/`
|
|
58
|
-
* belongs to a nested Nx repo (`<repo>/<sub-project>`); everything else is a
|
|
59
|
-
* flat top-level project.
|
|
60
|
-
*
|
|
61
|
-
* - **Workspace** tab: flat projects + one node per Nx repo (collapsed to a
|
|
62
|
-
* single `nxRepo` node); edges from `.ragmeta.json` relations.
|
|
63
|
-
* - **One tab per Nx repo**: its sub-projects as nodes, with edges between them
|
|
64
|
-
* taken from real import dependencies (`projectEdges`, from `code_dependency`).
|
|
65
|
-
*
|
|
66
|
-
* Returns the Workspace view first, then repo views sorted by name.
|
|
67
|
-
*/
|
|
68
51
|
function buildGraphViews(projects, projectEdges, workspaceRoot) {
|
|
69
52
|
const flat = [];
|
|
70
53
|
const groups = new Map();
|
|
@@ -84,7 +67,6 @@ function buildGraphViews(projects, projectEdges, workspaceRoot) {
|
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
const repoNames = [...groups.keys()].sort();
|
|
87
|
-
// Workspace: flat projects + one collapsed node per repo (reads repo-root ragmeta).
|
|
88
70
|
const workspaceProjects = [
|
|
89
71
|
...flat,
|
|
90
72
|
...repoNames.map(repo => ({ name: repo, path: path.join(workspaceRoot, repo) })),
|
|
@@ -95,7 +77,6 @@ function buildGraphViews(projects, projectEdges, workspaceRoot) {
|
|
|
95
77
|
if (repoSet.has(n.name))
|
|
96
78
|
n.nxRepo = true;
|
|
97
79
|
const workspace = { name: 'Workspace', nodes: ws.nodes, edges: ws.edges };
|
|
98
|
-
// Per-repo: sub-project nodes + intra-repo import edges.
|
|
99
80
|
const repoViews = repoNames.map(repo => {
|
|
100
81
|
const subs = groups.get(repo);
|
|
101
82
|
const { nodes } = buildGraphData(subs);
|
|
@@ -151,7 +132,6 @@ function printConsole(views, workspacePath) {
|
|
|
151
132
|
console.log(`\n Full graph: file://${path.join(workspacePath, 'project-graph.html')}`);
|
|
152
133
|
}
|
|
153
134
|
}
|
|
154
|
-
/** Prepare a view for vis-network: colored nodes (+ synthetic nodes for unknown edge targets) and indexed edges. */
|
|
155
135
|
function viewToVis(view) {
|
|
156
136
|
const nodes = view.nodes.map(n => ({
|
|
157
137
|
id: n.name,
|
|
@@ -173,13 +153,6 @@ function viewToVis(view) {
|
|
|
173
153
|
const labels = [...new Set(view.edges.map(e => e.label))].sort();
|
|
174
154
|
return { name: view.name, nodes, edges, labels };
|
|
175
155
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Render the full interactive graph page (vis-network + inner tabs, edge-type
|
|
178
|
-
* filters, legend, project toggle list). Used for the standalone
|
|
179
|
-
* `project-graph.html` and served by the web dashboard at `GET /graph` (embedded
|
|
180
|
-
* via iframe) so both share one implementation. Tab 0 is the Workspace view;
|
|
181
|
-
* double-clicking an Nx-repo node opens that repo's tab.
|
|
182
|
-
*/
|
|
183
156
|
function buildHtml(views) {
|
|
184
157
|
const visViews = views.map(viewToVis);
|
|
185
158
|
return `<!DOCTYPE html>
|
|
@@ -365,7 +338,6 @@ function buildHtml(views) {
|
|
|
365
338
|
</body>
|
|
366
339
|
</html>`;
|
|
367
340
|
}
|
|
368
|
-
// Single entry point — builds the tabbed views, prints a console summary, writes the HTML.
|
|
369
341
|
function generateProjectGraph(projects, projectEdges, workspacePath) {
|
|
370
342
|
const views = buildGraphViews(projects, projectEdges, workspacePath);
|
|
371
343
|
printConsole(views, workspacePath);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ITERATIVE_SCAN_MODE = void 0;
|
|
4
|
+
exports.hnswSettings = hnswSettings;
|
|
5
|
+
exports.supportsIterativeScan = supportsIterativeScan;
|
|
6
|
+
exports.ITERATIVE_SCAN_MODE = 'relaxed_order';
|
|
7
|
+
const EF_SEARCH_DEFAULT = 40;
|
|
8
|
+
const EF_SEARCH_MAX = 1000;
|
|
9
|
+
const ITERATIVE_SCAN_MIN_VERSION = [0, 8, 0];
|
|
10
|
+
function hnswSettings(dbLimit, iterative) {
|
|
11
|
+
return {
|
|
12
|
+
'hnsw.ef_search': Math.min(Math.max(dbLimit, EF_SEARCH_DEFAULT), EF_SEARCH_MAX),
|
|
13
|
+
...(iterative ? { 'hnsw.iterative_scan': exports.ITERATIVE_SCAN_MODE } : {}),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function supportsIterativeScan(version) {
|
|
17
|
+
const segments = version.split('.').map(s => parseInt(s, 10) || 0);
|
|
18
|
+
for (let i = 0; i < ITERATIVE_SCAN_MIN_VERSION.length; i++) {
|
|
19
|
+
const diff = (segments[i] ?? 0) - ITERATIVE_SCAN_MIN_VERSION[i];
|
|
20
|
+
if (diff !== 0)
|
|
21
|
+
return diff > 0;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeclarationTree } from '../declarations/DeclarationTree';
|
|
1
2
|
export interface DepEdge {
|
|
2
3
|
project: string;
|
|
3
4
|
fromFile: string;
|
|
@@ -16,19 +17,9 @@ export interface SymbolEntry {
|
|
|
16
17
|
line: number | null;
|
|
17
18
|
endLine: number | null;
|
|
18
19
|
col: number | null;
|
|
19
|
-
/** Dotted path of enclosing named scopes, outermost first; null for top-level declarations. */
|
|
20
20
|
container: string | null;
|
|
21
21
|
isStatic: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Qualified TypeScript name of the decorated declaration, set only on
|
|
24
|
-
* `graphql-symbols` rows (`graphqlNames`); null on every `symbols`/`members` entry.
|
|
25
|
-
*/
|
|
26
22
|
target?: string | null;
|
|
27
|
-
/**
|
|
28
|
-
* Whether this declaration node has a body (vs. an overload signature).
|
|
29
|
-
* Internal — used only to pick an overload set's representative row before
|
|
30
|
-
* writing to `code_symbol`; never persisted.
|
|
31
|
-
*/
|
|
32
23
|
hasBody?: boolean;
|
|
33
24
|
}
|
|
34
25
|
export interface CallEdge {
|
|
@@ -41,47 +32,19 @@ export interface CallEdge {
|
|
|
41
32
|
line: number | null;
|
|
42
33
|
col: number | null;
|
|
43
34
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Line range of a named scope used only to compute a chunk's owning declaration
|
|
46
|
-
* (`ownerPath`). Method/constructor/accessor ranges carry their enclosing class
|
|
47
|
-
* as `container`; top-level declarations use `container: null`. These are NOT
|
|
48
|
-
* persisted to `code_symbol` — they exist only for chunk ownership.
|
|
49
|
-
*/
|
|
50
|
-
export interface OwnerRange {
|
|
51
|
-
name: string;
|
|
52
|
-
container: string | null;
|
|
53
|
-
line: number;
|
|
54
|
-
endLine: number;
|
|
55
|
-
}
|
|
56
35
|
export interface FileAnalysis {
|
|
57
36
|
edges: DepEdge[];
|
|
58
|
-
/** Top-level declarations only — feeds the chunker and the embedding prompt. */
|
|
59
37
|
symbols: SymbolEntry[];
|
|
60
|
-
/** Members, namespace-level declarations and classes collected from the whole
|
|
61
|
-
* file. Written to `code_symbol` alongside `symbols`; never fed to the
|
|
62
|
-
* chunker or the prompt (see the `symbol-index-members` retrieval-invariance
|
|
63
|
-
* requirement). */
|
|
64
38
|
members: SymbolEntry[];
|
|
65
39
|
calls: CallEdge[];
|
|
66
|
-
|
|
67
|
-
ownerRanges?: OwnerRange[];
|
|
68
|
-
/**
|
|
69
|
-
* GraphQL-named rows (`@Query`/`@Mutation`/`@Subscription`/`@ResolveField`/
|
|
70
|
-
* `@ObjectType`/`@InputType`/`@InterfaceType` of `@nestjs/graphql`). Written to
|
|
71
|
-
* `code_symbol` alongside `symbols`/`members`; never fed to the chunker, the
|
|
72
|
-
* prompt, `buildOwnerRanges` or `extractCalls` (see `graphql-symbols`).
|
|
73
|
-
*/
|
|
40
|
+
declarations?: DeclarationTree;
|
|
74
41
|
graphqlNames: SymbolEntry[];
|
|
75
42
|
}
|
|
76
43
|
export interface AnalyzeProjectOpts {
|
|
77
44
|
skipDependencyResolution?: boolean;
|
|
78
|
-
/** Path to root tsconfig (e.g. tsconfig.base.json) for workspace-wide path aliases */
|
|
79
45
|
rootTsConfigPath?: string;
|
|
80
46
|
}
|
|
81
47
|
export interface IAstParser {
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Use analyzeProject instead for project-wide context.
|
|
84
|
-
*/
|
|
85
48
|
analyzeFile(filePath: string, serviceName: string, projectRoot?: string): Promise<FileAnalysis>;
|
|
86
49
|
analyzeProject(filePaths: string[], serviceName: string, projectRoot?: string, opts?: AnalyzeProjectOpts): Promise<Map<string, FileAnalysis>>;
|
|
87
50
|
clearCache(projectRoot?: string): void;
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** One embeddable unit of source with its 1-based inclusive line range. */
|
|
1
|
+
import type { DeclarationTree } from '../declarations/DeclarationTree';
|
|
3
2
|
export interface ChunkPiece {
|
|
4
3
|
content: string;
|
|
5
4
|
startLine: number;
|
|
6
5
|
endLine: number;
|
|
7
6
|
}
|
|
8
7
|
export interface ChunkOpts {
|
|
9
|
-
/** 'ast' = symbol-aligned boundaries; 'character' = fixed-size recursive splitter. */
|
|
10
8
|
strategy: 'ast' | 'character';
|
|
11
|
-
/** Schema files (.prisma/.graphql/.gql) always use the schema separator splitter. */
|
|
12
9
|
isSchemaFile: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
declarations?: DeclarationTree;
|
|
11
|
+
jsx?: boolean;
|
|
15
12
|
}
|
|
16
13
|
export interface IChunker {
|
|
17
|
-
/**
|
|
18
|
-
* Split source into embeddable pieces. AST strategy aligns boundaries to
|
|
19
|
-
* top-level declaration ranges and never emits a piece longer than the
|
|
20
|
-
* configured chunk size; falls back to the character splitter for schema
|
|
21
|
-
* files, empty-symbol files, or when strategy is 'character'.
|
|
22
|
-
*/
|
|
23
14
|
chunk(code: string, opts: ChunkOpts): Promise<ChunkPiece[]>;
|
|
24
15
|
}
|