@veewo/gitnexus 1.3.4
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 +234 -0
- package/dist/benchmark/agent-context/evaluators.d.ts +9 -0
- package/dist/benchmark/agent-context/evaluators.js +196 -0
- package/dist/benchmark/agent-context/evaluators.test.d.ts +1 -0
- package/dist/benchmark/agent-context/evaluators.test.js +39 -0
- package/dist/benchmark/agent-context/io.d.ts +2 -0
- package/dist/benchmark/agent-context/io.js +23 -0
- package/dist/benchmark/agent-context/io.test.d.ts +1 -0
- package/dist/benchmark/agent-context/io.test.js +19 -0
- package/dist/benchmark/agent-context/report.d.ts +2 -0
- package/dist/benchmark/agent-context/report.js +59 -0
- package/dist/benchmark/agent-context/report.test.d.ts +1 -0
- package/dist/benchmark/agent-context/report.test.js +85 -0
- package/dist/benchmark/agent-context/runner.d.ts +46 -0
- package/dist/benchmark/agent-context/runner.js +111 -0
- package/dist/benchmark/agent-context/runner.test.d.ts +1 -0
- package/dist/benchmark/agent-context/runner.test.js +79 -0
- package/dist/benchmark/agent-context/tool-runner.d.ts +7 -0
- package/dist/benchmark/agent-context/tool-runner.js +18 -0
- package/dist/benchmark/agent-context/tool-runner.test.d.ts +1 -0
- package/dist/benchmark/agent-context/tool-runner.test.js +11 -0
- package/dist/benchmark/agent-context/types.d.ts +40 -0
- package/dist/benchmark/agent-context/types.js +1 -0
- package/dist/benchmark/analyze-runner.d.ts +16 -0
- package/dist/benchmark/analyze-runner.js +51 -0
- package/dist/benchmark/analyze-runner.test.d.ts +1 -0
- package/dist/benchmark/analyze-runner.test.js +37 -0
- package/dist/benchmark/evaluators.d.ts +6 -0
- package/dist/benchmark/evaluators.js +10 -0
- package/dist/benchmark/evaluators.test.d.ts +1 -0
- package/dist/benchmark/evaluators.test.js +12 -0
- package/dist/benchmark/io.d.ts +7 -0
- package/dist/benchmark/io.js +25 -0
- package/dist/benchmark/io.test.d.ts +1 -0
- package/dist/benchmark/io.test.js +35 -0
- package/dist/benchmark/neonspark-candidates.d.ts +19 -0
- package/dist/benchmark/neonspark-candidates.js +94 -0
- package/dist/benchmark/neonspark-candidates.test.d.ts +1 -0
- package/dist/benchmark/neonspark-candidates.test.js +43 -0
- package/dist/benchmark/neonspark-materialize.d.ts +19 -0
- package/dist/benchmark/neonspark-materialize.js +111 -0
- package/dist/benchmark/neonspark-materialize.test.d.ts +1 -0
- package/dist/benchmark/neonspark-materialize.test.js +124 -0
- package/dist/benchmark/neonspark-sync.d.ts +3 -0
- package/dist/benchmark/neonspark-sync.js +53 -0
- package/dist/benchmark/neonspark-sync.test.d.ts +1 -0
- package/dist/benchmark/neonspark-sync.test.js +20 -0
- package/dist/benchmark/report.d.ts +1 -0
- package/dist/benchmark/report.js +7 -0
- package/dist/benchmark/runner.d.ts +48 -0
- package/dist/benchmark/runner.js +302 -0
- package/dist/benchmark/runner.test.d.ts +1 -0
- package/dist/benchmark/runner.test.js +50 -0
- package/dist/benchmark/scoring.d.ts +16 -0
- package/dist/benchmark/scoring.js +27 -0
- package/dist/benchmark/scoring.test.d.ts +1 -0
- package/dist/benchmark/scoring.test.js +24 -0
- package/dist/benchmark/tool-runner.d.ts +6 -0
- package/dist/benchmark/tool-runner.js +17 -0
- package/dist/benchmark/types.d.ts +36 -0
- package/dist/benchmark/types.js +1 -0
- package/dist/cli/ai-context.d.ts +22 -0
- package/dist/cli/ai-context.js +184 -0
- package/dist/cli/ai-context.test.d.ts +1 -0
- package/dist/cli/ai-context.test.js +30 -0
- package/dist/cli/analyze-multi-scope-regression.test.d.ts +1 -0
- package/dist/cli/analyze-multi-scope-regression.test.js +22 -0
- package/dist/cli/analyze-options.d.ts +7 -0
- package/dist/cli/analyze-options.js +56 -0
- package/dist/cli/analyze-options.test.d.ts +1 -0
- package/dist/cli/analyze-options.test.js +36 -0
- package/dist/cli/analyze.d.ts +14 -0
- package/dist/cli/analyze.js +384 -0
- package/dist/cli/augment.d.ts +13 -0
- package/dist/cli/augment.js +33 -0
- package/dist/cli/benchmark-agent-context.d.ts +29 -0
- package/dist/cli/benchmark-agent-context.js +61 -0
- package/dist/cli/benchmark-agent-context.test.d.ts +1 -0
- package/dist/cli/benchmark-agent-context.test.js +80 -0
- package/dist/cli/benchmark-unity.d.ts +15 -0
- package/dist/cli/benchmark-unity.js +31 -0
- package/dist/cli/benchmark-unity.test.d.ts +1 -0
- package/dist/cli/benchmark-unity.test.js +18 -0
- package/dist/cli/claude-hooks.d.ts +22 -0
- package/dist/cli/claude-hooks.js +97 -0
- package/dist/cli/clean.d.ts +10 -0
- package/dist/cli/clean.js +60 -0
- package/dist/cli/eval-server.d.ts +30 -0
- package/dist/cli/eval-server.js +372 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +182 -0
- package/dist/cli/list.d.ts +6 -0
- package/dist/cli/list.js +33 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +34 -0
- package/dist/cli/repo-manager-alias.test.d.ts +1 -0
- package/dist/cli/repo-manager-alias.test.js +40 -0
- package/dist/cli/scope-filter.test.d.ts +1 -0
- package/dist/cli/scope-filter.test.js +49 -0
- package/dist/cli/serve.d.ts +4 -0
- package/dist/cli/serve.js +6 -0
- package/dist/cli/setup.d.ts +8 -0
- package/dist/cli/setup.js +311 -0
- package/dist/cli/setup.test.d.ts +1 -0
- package/dist/cli/setup.test.js +31 -0
- package/dist/cli/status.d.ts +6 -0
- package/dist/cli/status.js +27 -0
- package/dist/cli/tool.d.ts +40 -0
- package/dist/cli/tool.js +94 -0
- package/dist/cli/version.test.d.ts +1 -0
- package/dist/cli/version.test.js +19 -0
- package/dist/cli/wiki.d.ts +15 -0
- package/dist/cli/wiki.js +361 -0
- package/dist/config/ignore-service.d.ts +1 -0
- package/dist/config/ignore-service.js +210 -0
- package/dist/config/supported-languages.d.ts +12 -0
- package/dist/config/supported-languages.js +15 -0
- package/dist/core/augmentation/engine.d.ts +26 -0
- package/dist/core/augmentation/engine.js +213 -0
- package/dist/core/embeddings/embedder.d.ts +60 -0
- package/dist/core/embeddings/embedder.js +251 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
- package/dist/core/embeddings/embedding-pipeline.js +329 -0
- package/dist/core/embeddings/index.d.ts +9 -0
- package/dist/core/embeddings/index.js +9 -0
- package/dist/core/embeddings/text-generator.d.ts +24 -0
- package/dist/core/embeddings/text-generator.js +182 -0
- package/dist/core/embeddings/types.d.ts +87 -0
- package/dist/core/embeddings/types.js +32 -0
- package/dist/core/graph/graph.d.ts +2 -0
- package/dist/core/graph/graph.js +66 -0
- package/dist/core/graph/types.d.ts +61 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/ingestion/ast-cache.d.ts +11 -0
- package/dist/core/ingestion/ast-cache.js +34 -0
- package/dist/core/ingestion/call-processor.d.ts +15 -0
- package/dist/core/ingestion/call-processor.js +327 -0
- package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
- package/dist/core/ingestion/cluster-enricher.js +170 -0
- package/dist/core/ingestion/community-processor.d.ts +39 -0
- package/dist/core/ingestion/community-processor.js +312 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +39 -0
- package/dist/core/ingestion/entry-point-scoring.js +260 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
- package/dist/core/ingestion/filesystem-walker.js +80 -0
- package/dist/core/ingestion/framework-detection.d.ts +39 -0
- package/dist/core/ingestion/framework-detection.js +235 -0
- package/dist/core/ingestion/heritage-processor.d.ts +20 -0
- package/dist/core/ingestion/heritage-processor.js +197 -0
- package/dist/core/ingestion/import-processor.d.ts +38 -0
- package/dist/core/ingestion/import-processor.js +778 -0
- package/dist/core/ingestion/parsing-processor.d.ts +15 -0
- package/dist/core/ingestion/parsing-processor.js +291 -0
- package/dist/core/ingestion/pipeline.d.ts +5 -0
- package/dist/core/ingestion/pipeline.js +323 -0
- package/dist/core/ingestion/process-processor.d.ts +51 -0
- package/dist/core/ingestion/process-processor.js +309 -0
- package/dist/core/ingestion/scope-filter.d.ts +25 -0
- package/dist/core/ingestion/scope-filter.js +100 -0
- package/dist/core/ingestion/structure-processor.d.ts +2 -0
- package/dist/core/ingestion/structure-processor.js +36 -0
- package/dist/core/ingestion/symbol-table.d.ts +33 -0
- package/dist/core/ingestion/symbol-table.js +38 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +12 -0
- package/dist/core/ingestion/tree-sitter-queries.js +398 -0
- package/dist/core/ingestion/utils.d.ts +10 -0
- package/dist/core/ingestion/utils.js +50 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +59 -0
- package/dist/core/ingestion/workers/parse-worker.js +672 -0
- package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
- package/dist/core/ingestion/workers/worker-pool.js +120 -0
- package/dist/core/kuzu/csv-generator.d.ts +29 -0
- package/dist/core/kuzu/csv-generator.js +336 -0
- package/dist/core/kuzu/kuzu-adapter.d.ts +101 -0
- package/dist/core/kuzu/kuzu-adapter.js +753 -0
- package/dist/core/kuzu/schema.d.ts +53 -0
- package/dist/core/kuzu/schema.js +407 -0
- package/dist/core/search/bm25-index.d.ts +23 -0
- package/dist/core/search/bm25-index.js +95 -0
- package/dist/core/search/hybrid-search.d.ts +49 -0
- package/dist/core/search/hybrid-search.js +118 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +4 -0
- package/dist/core/tree-sitter/parser-loader.js +44 -0
- package/dist/core/wiki/generator.d.ts +110 -0
- package/dist/core/wiki/generator.js +786 -0
- package/dist/core/wiki/graph-queries.d.ts +80 -0
- package/dist/core/wiki/graph-queries.js +238 -0
- package/dist/core/wiki/html-viewer.d.ts +10 -0
- package/dist/core/wiki/html-viewer.js +297 -0
- package/dist/core/wiki/llm-client.d.ts +40 -0
- package/dist/core/wiki/llm-client.js +162 -0
- package/dist/core/wiki/prompts.d.ts +53 -0
- package/dist/core/wiki/prompts.js +174 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/mcp/core/embedder.d.ts +27 -0
- package/dist/mcp/core/embedder.js +108 -0
- package/dist/mcp/core/kuzu-adapter.d.ts +34 -0
- package/dist/mcp/core/kuzu-adapter.js +231 -0
- package/dist/mcp/local/local-backend.d.ts +160 -0
- package/dist/mcp/local/local-backend.js +1646 -0
- package/dist/mcp/resources.d.ts +31 -0
- package/dist/mcp/resources.js +407 -0
- package/dist/mcp/server.d.ts +23 -0
- package/dist/mcp/server.js +251 -0
- package/dist/mcp/staleness.d.ts +15 -0
- package/dist/mcp/staleness.js +29 -0
- package/dist/mcp/tools.d.ts +24 -0
- package/dist/mcp/tools.js +195 -0
- package/dist/server/api.d.ts +10 -0
- package/dist/server/api.js +344 -0
- package/dist/server/mcp-http.d.ts +13 -0
- package/dist/server/mcp-http.js +100 -0
- package/dist/storage/git.d.ts +6 -0
- package/dist/storage/git.js +32 -0
- package/dist/storage/repo-manager.d.ts +125 -0
- package/dist/storage/repo-manager.js +257 -0
- package/dist/types/pipeline.d.ts +34 -0
- package/dist/types/pipeline.js +18 -0
- package/hooks/claude/gitnexus-hook.cjs +135 -0
- package/hooks/claude/pre-tool-use.sh +78 -0
- package/hooks/claude/session-start.sh +42 -0
- package/package.json +92 -0
- package/skills/gitnexus-cli.md +82 -0
- package/skills/gitnexus-debugging.md +89 -0
- package/skills/gitnexus-exploring.md +78 -0
- package/skills/gitnexus-guide.md +64 -0
- package/skills/gitnexus-impact-analysis.md +97 -0
- package/skills/gitnexus-refactoring.md +121 -0
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heritage Processor
|
|
3
|
+
*
|
|
4
|
+
* Extracts class inheritance relationships:
|
|
5
|
+
* - EXTENDS: Class extends another Class (TS, JS, Python)
|
|
6
|
+
* - IMPLEMENTS: Class implements an Interface (TS only)
|
|
7
|
+
*/
|
|
8
|
+
import Parser from 'tree-sitter';
|
|
9
|
+
import { loadParser, loadLanguage } from '../tree-sitter/parser-loader.js';
|
|
10
|
+
import { LANGUAGE_QUERIES } from './tree-sitter-queries.js';
|
|
11
|
+
import { generateId } from '../../lib/utils.js';
|
|
12
|
+
import { getLanguageFromFilename, yieldToEventLoop } from './utils.js';
|
|
13
|
+
export const processHeritage = async (graph, files, astCache, symbolTable, onProgress) => {
|
|
14
|
+
const parser = await loadParser();
|
|
15
|
+
for (let i = 0; i < files.length; i++) {
|
|
16
|
+
const file = files[i];
|
|
17
|
+
onProgress?.(i + 1, files.length);
|
|
18
|
+
if (i % 20 === 0)
|
|
19
|
+
await yieldToEventLoop();
|
|
20
|
+
// 1. Check language support
|
|
21
|
+
const language = getLanguageFromFilename(file.path);
|
|
22
|
+
if (!language)
|
|
23
|
+
continue;
|
|
24
|
+
const queryStr = LANGUAGE_QUERIES[language];
|
|
25
|
+
if (!queryStr)
|
|
26
|
+
continue;
|
|
27
|
+
// 2. Load the language
|
|
28
|
+
await loadLanguage(language, file.path);
|
|
29
|
+
// 3. Get AST
|
|
30
|
+
let tree = astCache.get(file.path);
|
|
31
|
+
let wasReparsed = false;
|
|
32
|
+
if (!tree) {
|
|
33
|
+
// Use larger bufferSize for files > 32KB
|
|
34
|
+
try {
|
|
35
|
+
tree = parser.parse(file.content, undefined, { bufferSize: 1024 * 256 });
|
|
36
|
+
}
|
|
37
|
+
catch (parseError) {
|
|
38
|
+
// Skip files that can't be parsed
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
wasReparsed = true;
|
|
42
|
+
// Cache re-parsed tree for potential future use
|
|
43
|
+
astCache.set(file.path, tree);
|
|
44
|
+
}
|
|
45
|
+
let query;
|
|
46
|
+
let matches;
|
|
47
|
+
try {
|
|
48
|
+
const language = parser.getLanguage();
|
|
49
|
+
query = new Parser.Query(language, queryStr);
|
|
50
|
+
matches = query.matches(tree.rootNode);
|
|
51
|
+
}
|
|
52
|
+
catch (queryError) {
|
|
53
|
+
console.warn(`Heritage query error for ${file.path}:`, queryError);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// 4. Process heritage matches
|
|
57
|
+
matches.forEach(match => {
|
|
58
|
+
const captureMap = {};
|
|
59
|
+
match.captures.forEach(c => {
|
|
60
|
+
captureMap[c.name] = c.node;
|
|
61
|
+
});
|
|
62
|
+
// EXTENDS: Class extends another Class
|
|
63
|
+
if (captureMap['heritage.class'] && captureMap['heritage.extends']) {
|
|
64
|
+
const className = captureMap['heritage.class'].text;
|
|
65
|
+
const parentClassName = captureMap['heritage.extends'].text;
|
|
66
|
+
// Resolve both class IDs
|
|
67
|
+
const childId = symbolTable.lookupExact(file.path, className) ||
|
|
68
|
+
symbolTable.lookupFuzzy(className)[0]?.nodeId ||
|
|
69
|
+
generateId('Class', `${file.path}:${className}`);
|
|
70
|
+
const parentId = symbolTable.lookupFuzzy(parentClassName)[0]?.nodeId ||
|
|
71
|
+
generateId('Class', `${parentClassName}`);
|
|
72
|
+
if (childId && parentId && childId !== parentId) {
|
|
73
|
+
const relId = generateId('EXTENDS', `${childId}->${parentId}`);
|
|
74
|
+
graph.addRelationship({
|
|
75
|
+
id: relId,
|
|
76
|
+
sourceId: childId,
|
|
77
|
+
targetId: parentId,
|
|
78
|
+
type: 'EXTENDS',
|
|
79
|
+
confidence: 1.0,
|
|
80
|
+
reason: '',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// IMPLEMENTS: Class implements Interface (TypeScript only)
|
|
85
|
+
if (captureMap['heritage.class'] && captureMap['heritage.implements']) {
|
|
86
|
+
const className = captureMap['heritage.class'].text;
|
|
87
|
+
const interfaceName = captureMap['heritage.implements'].text;
|
|
88
|
+
// Resolve class and interface IDs
|
|
89
|
+
const classId = symbolTable.lookupExact(file.path, className) ||
|
|
90
|
+
symbolTable.lookupFuzzy(className)[0]?.nodeId ||
|
|
91
|
+
generateId('Class', `${file.path}:${className}`);
|
|
92
|
+
const interfaceId = symbolTable.lookupFuzzy(interfaceName)[0]?.nodeId ||
|
|
93
|
+
generateId('Interface', `${interfaceName}`);
|
|
94
|
+
if (classId && interfaceId) {
|
|
95
|
+
const relId = generateId('IMPLEMENTS', `${classId}->${interfaceId}`);
|
|
96
|
+
graph.addRelationship({
|
|
97
|
+
id: relId,
|
|
98
|
+
sourceId: classId,
|
|
99
|
+
targetId: interfaceId,
|
|
100
|
+
type: 'IMPLEMENTS',
|
|
101
|
+
confidence: 1.0,
|
|
102
|
+
reason: '',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// IMPLEMENTS (Rust): impl Trait for Struct
|
|
107
|
+
if (captureMap['heritage.trait'] && captureMap['heritage.class']) {
|
|
108
|
+
const structName = captureMap['heritage.class'].text;
|
|
109
|
+
const traitName = captureMap['heritage.trait'].text;
|
|
110
|
+
// Resolve struct and trait IDs
|
|
111
|
+
const structId = symbolTable.lookupExact(file.path, structName) ||
|
|
112
|
+
symbolTable.lookupFuzzy(structName)[0]?.nodeId ||
|
|
113
|
+
generateId('Struct', `${file.path}:${structName}`);
|
|
114
|
+
const traitId = symbolTable.lookupFuzzy(traitName)[0]?.nodeId ||
|
|
115
|
+
generateId('Trait', `${traitName}`);
|
|
116
|
+
if (structId && traitId) {
|
|
117
|
+
const relId = generateId('IMPLEMENTS', `${structId}->${traitId}`);
|
|
118
|
+
graph.addRelationship({
|
|
119
|
+
id: relId,
|
|
120
|
+
sourceId: structId,
|
|
121
|
+
targetId: traitId,
|
|
122
|
+
type: 'IMPLEMENTS',
|
|
123
|
+
confidence: 1.0,
|
|
124
|
+
reason: 'trait-impl',
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
// Tree is now owned by the LRU cache — no manual delete needed
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Fast path: resolve pre-extracted heritage from workers.
|
|
134
|
+
* No AST parsing — workers already extracted className + parentName + kind.
|
|
135
|
+
*/
|
|
136
|
+
export const processHeritageFromExtracted = async (graph, extractedHeritage, symbolTable, onProgress) => {
|
|
137
|
+
const total = extractedHeritage.length;
|
|
138
|
+
for (let i = 0; i < extractedHeritage.length; i++) {
|
|
139
|
+
if (i % 500 === 0) {
|
|
140
|
+
onProgress?.(i, total);
|
|
141
|
+
await yieldToEventLoop();
|
|
142
|
+
}
|
|
143
|
+
const h = extractedHeritage[i];
|
|
144
|
+
if (h.kind === 'extends') {
|
|
145
|
+
const childId = symbolTable.lookupExact(h.filePath, h.className) ||
|
|
146
|
+
symbolTable.lookupFuzzy(h.className)[0]?.nodeId ||
|
|
147
|
+
generateId('Class', `${h.filePath}:${h.className}`);
|
|
148
|
+
const parentId = symbolTable.lookupFuzzy(h.parentName)[0]?.nodeId ||
|
|
149
|
+
generateId('Class', `${h.parentName}`);
|
|
150
|
+
if (childId && parentId && childId !== parentId) {
|
|
151
|
+
graph.addRelationship({
|
|
152
|
+
id: generateId('EXTENDS', `${childId}->${parentId}`),
|
|
153
|
+
sourceId: childId,
|
|
154
|
+
targetId: parentId,
|
|
155
|
+
type: 'EXTENDS',
|
|
156
|
+
confidence: 1.0,
|
|
157
|
+
reason: '',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (h.kind === 'implements') {
|
|
162
|
+
const classId = symbolTable.lookupExact(h.filePath, h.className) ||
|
|
163
|
+
symbolTable.lookupFuzzy(h.className)[0]?.nodeId ||
|
|
164
|
+
generateId('Class', `${h.filePath}:${h.className}`);
|
|
165
|
+
const interfaceId = symbolTable.lookupFuzzy(h.parentName)[0]?.nodeId ||
|
|
166
|
+
generateId('Interface', `${h.parentName}`);
|
|
167
|
+
if (classId && interfaceId) {
|
|
168
|
+
graph.addRelationship({
|
|
169
|
+
id: generateId('IMPLEMENTS', `${classId}->${interfaceId}`),
|
|
170
|
+
sourceId: classId,
|
|
171
|
+
targetId: interfaceId,
|
|
172
|
+
type: 'IMPLEMENTS',
|
|
173
|
+
confidence: 1.0,
|
|
174
|
+
reason: '',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else if (h.kind === 'trait-impl') {
|
|
179
|
+
const structId = symbolTable.lookupExact(h.filePath, h.className) ||
|
|
180
|
+
symbolTable.lookupFuzzy(h.className)[0]?.nodeId ||
|
|
181
|
+
generateId('Struct', `${h.filePath}:${h.className}`);
|
|
182
|
+
const traitId = symbolTable.lookupFuzzy(h.parentName)[0]?.nodeId ||
|
|
183
|
+
generateId('Trait', `${h.parentName}`);
|
|
184
|
+
if (structId && traitId) {
|
|
185
|
+
graph.addRelationship({
|
|
186
|
+
id: generateId('IMPLEMENTS', `${structId}->${traitId}`),
|
|
187
|
+
sourceId: structId,
|
|
188
|
+
targetId: traitId,
|
|
189
|
+
type: 'IMPLEMENTS',
|
|
190
|
+
confidence: 1.0,
|
|
191
|
+
reason: 'trait-impl',
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
onProgress?.(total, total);
|
|
197
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { KnowledgeGraph } from '../graph/types.js';
|
|
2
|
+
import { ASTCache } from './ast-cache.js';
|
|
3
|
+
import type { ExtractedImport } from './workers/parse-worker.js';
|
|
4
|
+
export type ImportMap = Map<string, Set<string>>;
|
|
5
|
+
export declare const createImportMap: () => ImportMap;
|
|
6
|
+
/** Pre-built lookup structures for import resolution. Build once, reuse across chunks. */
|
|
7
|
+
export interface ImportResolutionContext {
|
|
8
|
+
allFilePaths: Set<string>;
|
|
9
|
+
allFileList: string[];
|
|
10
|
+
normalizedFileList: string[];
|
|
11
|
+
suffixIndex: SuffixIndex;
|
|
12
|
+
resolveCache: Map<string, string | null>;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildImportResolutionContext(allPaths: string[]): ImportResolutionContext;
|
|
15
|
+
/**
|
|
16
|
+
* Build a suffix index for O(1) endsWith lookups.
|
|
17
|
+
* Maps every possible path suffix to its original file path.
|
|
18
|
+
* e.g. for "src/com/example/Foo.java":
|
|
19
|
+
* "Foo.java" -> "src/com/example/Foo.java"
|
|
20
|
+
* "example/Foo.java" -> "src/com/example/Foo.java"
|
|
21
|
+
* "com/example/Foo.java" -> "src/com/example/Foo.java"
|
|
22
|
+
* etc.
|
|
23
|
+
*/
|
|
24
|
+
export interface SuffixIndex {
|
|
25
|
+
/** Exact suffix lookup (case-sensitive) */
|
|
26
|
+
get(suffix: string): string | undefined;
|
|
27
|
+
/** Case-insensitive suffix lookup */
|
|
28
|
+
getInsensitive(suffix: string): string | undefined;
|
|
29
|
+
/** Get all files in a directory suffix */
|
|
30
|
+
getFilesInDir(dirSuffix: string, extension: string): string[];
|
|
31
|
+
}
|
|
32
|
+
export declare const processImports: (graph: KnowledgeGraph, files: {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}[], astCache: ASTCache, importMap: ImportMap, onProgress?: (current: number, total: number) => void, repoRoot?: string, allPaths?: string[]) => Promise<void>;
|
|
36
|
+
export declare const processImportsFromExtracted: (graph: KnowledgeGraph, files: {
|
|
37
|
+
path: string;
|
|
38
|
+
}[], extractedImports: ExtractedImport[], importMap: ImportMap, onProgress?: (current: number, total: number) => void, repoRoot?: string, prebuiltCtx?: ImportResolutionContext) => Promise<void>;
|