gitnexus 1.4.7 → 1.4.9
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 +29 -1
- package/dist/cli/ai-context.d.ts +1 -1
- package/dist/cli/ai-context.js +1 -1
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +54 -21
- package/dist/cli/index-repo.d.ts +15 -0
- package/dist/cli/index-repo.js +115 -0
- package/dist/cli/index.js +13 -3
- package/dist/cli/setup.js +90 -10
- package/dist/cli/wiki.d.ts +4 -0
- package/dist/cli/wiki.js +174 -53
- package/dist/config/supported-languages.d.ts +33 -1
- package/dist/config/supported-languages.js +32 -0
- package/dist/core/embeddings/embedder.d.ts +6 -1
- package/dist/core/embeddings/embedder.js +65 -5
- package/dist/core/embeddings/embedding-pipeline.js +11 -9
- package/dist/core/embeddings/http-client.d.ts +31 -0
- package/dist/core/embeddings/http-client.js +179 -0
- package/dist/core/embeddings/index.d.ts +1 -0
- package/dist/core/embeddings/index.js +1 -0
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/graph/graph.js +9 -1
- package/dist/core/graph/types.d.ts +11 -2
- package/dist/core/ingestion/call-processor.d.ts +66 -2
- package/dist/core/ingestion/call-processor.js +650 -30
- package/dist/core/ingestion/call-routing.d.ts +9 -18
- package/dist/core/ingestion/call-routing.js +0 -19
- package/dist/core/ingestion/cobol/cobol-copy-expander.d.ts +57 -0
- package/dist/core/ingestion/cobol/cobol-copy-expander.js +385 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +210 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +1509 -0
- package/dist/core/ingestion/cobol/jcl-parser.d.ts +68 -0
- package/dist/core/ingestion/cobol/jcl-parser.js +217 -0
- package/dist/core/ingestion/cobol/jcl-processor.d.ts +33 -0
- package/dist/core/ingestion/cobol/jcl-processor.js +229 -0
- package/dist/core/ingestion/cobol-processor.d.ts +54 -0
- package/dist/core/ingestion/cobol-processor.js +1186 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +17 -0
- package/dist/core/ingestion/entry-point-scoring.js +52 -28
- package/dist/core/ingestion/export-detection.d.ts +47 -8
- package/dist/core/ingestion/export-detection.js +29 -50
- package/dist/core/ingestion/field-extractor.d.ts +29 -0
- package/dist/core/ingestion/field-extractor.js +25 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.js +108 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.js +73 -0
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/dart.js +76 -0
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +11 -0
- package/dist/core/ingestion/field-extractors/configs/go.js +64 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +44 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.js +134 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.js +118 -0
- package/dist/core/ingestion/field-extractors/configs/php.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/php.js +67 -0
- package/dist/core/ingestion/field-extractors/configs/python.d.ts +12 -0
- package/dist/core/ingestion/field-extractors/configs/python.js +91 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.d.ts +16 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.js +75 -0
- package/dist/core/ingestion/field-extractors/configs/rust.d.ts +9 -0
- package/dist/core/ingestion/field-extractors/configs/rust.js +55 -0
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/swift.js +63 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +60 -0
- package/dist/core/ingestion/field-extractors/generic.d.ts +46 -0
- package/dist/core/ingestion/field-extractors/generic.js +111 -0
- package/dist/core/ingestion/field-extractors/typescript.d.ts +77 -0
- package/dist/core/ingestion/field-extractors/typescript.js +291 -0
- package/dist/core/ingestion/field-types.d.ts +59 -0
- package/dist/core/ingestion/field-types.js +2 -0
- package/dist/core/ingestion/framework-detection.d.ts +97 -2
- package/dist/core/ingestion/framework-detection.js +114 -14
- package/dist/core/ingestion/heritage-processor.js +62 -66
- package/dist/core/ingestion/import-processor.d.ts +9 -10
- package/dist/core/ingestion/import-processor.js +150 -196
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.d.ts +6 -9
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.js +20 -2
- package/dist/core/ingestion/import-resolvers/dart.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/dart.js +44 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.d.ts +4 -5
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.js +17 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.d.ts +10 -1
- package/dist/core/ingestion/import-resolvers/jvm.js +159 -0
- package/dist/core/ingestion/import-resolvers/php.d.ts +25 -0
- package/dist/core/ingestion/import-resolvers/php.js +80 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.d.ts +9 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.js +35 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.js +7 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.js +41 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.d.ts +15 -7
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.js +22 -3
- package/dist/core/ingestion/import-resolvers/swift.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/swift.js +23 -0
- package/dist/core/ingestion/import-resolvers/types.d.ts +44 -0
- package/dist/core/ingestion/import-resolvers/types.js +6 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.d.ts +2 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +7 -0
- package/dist/core/ingestion/language-config.d.ts +6 -0
- package/dist/core/ingestion/language-config.js +13 -0
- package/dist/core/ingestion/language-provider.d.ts +121 -0
- package/dist/core/ingestion/language-provider.js +24 -0
- package/dist/core/ingestion/languages/c-cpp.d.ts +12 -0
- package/dist/core/ingestion/languages/c-cpp.js +71 -0
- package/dist/core/ingestion/languages/cobol.d.ts +1 -0
- package/dist/core/ingestion/languages/cobol.js +26 -0
- package/dist/core/ingestion/languages/csharp.d.ts +8 -0
- package/dist/core/ingestion/languages/csharp.js +49 -0
- package/dist/core/ingestion/languages/dart.d.ts +12 -0
- package/dist/core/ingestion/languages/dart.js +58 -0
- package/dist/core/ingestion/languages/go.d.ts +11 -0
- package/dist/core/ingestion/languages/go.js +28 -0
- package/dist/core/ingestion/languages/index.d.ts +38 -0
- package/dist/core/ingestion/languages/index.js +63 -0
- package/dist/core/ingestion/languages/java.d.ts +9 -0
- package/dist/core/ingestion/languages/java.js +29 -0
- package/dist/core/ingestion/languages/kotlin.d.ts +9 -0
- package/dist/core/ingestion/languages/kotlin.js +53 -0
- package/dist/core/ingestion/languages/php.d.ts +8 -0
- package/dist/core/ingestion/languages/php.js +145 -0
- package/dist/core/ingestion/languages/python.d.ts +12 -0
- package/dist/core/ingestion/languages/python.js +39 -0
- package/dist/core/ingestion/languages/ruby.d.ts +9 -0
- package/dist/core/ingestion/languages/ruby.js +44 -0
- package/dist/core/ingestion/languages/rust.d.ts +12 -0
- package/dist/core/ingestion/languages/rust.js +44 -0
- package/dist/core/ingestion/languages/swift.d.ts +12 -0
- package/dist/core/ingestion/languages/swift.js +133 -0
- package/dist/core/ingestion/languages/typescript.d.ts +10 -0
- package/dist/core/ingestion/languages/typescript.js +60 -0
- package/dist/core/ingestion/markdown-processor.d.ts +17 -0
- package/dist/core/ingestion/markdown-processor.js +124 -0
- package/dist/core/ingestion/mro-processor.js +22 -18
- package/dist/core/ingestion/named-binding-processor.d.ts +18 -0
- package/dist/core/ingestion/named-binding-processor.js +42 -0
- package/dist/core/ingestion/named-bindings/csharp.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/csharp.js +37 -0
- package/dist/core/ingestion/named-bindings/java.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/java.js +29 -0
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/kotlin.js +36 -0
- package/dist/core/ingestion/named-bindings/php.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/php.js +61 -0
- package/dist/core/ingestion/named-bindings/python.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/python.js +49 -0
- package/dist/core/ingestion/named-bindings/rust.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/rust.js +64 -0
- package/dist/core/ingestion/named-bindings/types.d.ts +16 -0
- package/dist/core/ingestion/named-bindings/types.js +6 -0
- package/dist/core/ingestion/named-bindings/typescript.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/typescript.js +58 -0
- package/dist/core/ingestion/parsing-processor.d.ts +6 -2
- package/dist/core/ingestion/parsing-processor.js +125 -85
- package/dist/core/ingestion/pipeline.d.ts +10 -0
- package/dist/core/ingestion/pipeline.js +1235 -317
- package/dist/core/ingestion/resolution-context.d.ts +5 -0
- package/dist/core/ingestion/resolution-context.js +8 -5
- package/dist/core/ingestion/route-extractors/expo.d.ts +1 -0
- package/dist/core/ingestion/route-extractors/expo.js +36 -0
- package/dist/core/ingestion/route-extractors/middleware.d.ts +47 -0
- package/dist/core/ingestion/route-extractors/middleware.js +143 -0
- package/dist/core/ingestion/route-extractors/nextjs.d.ts +3 -0
- package/dist/core/ingestion/route-extractors/nextjs.js +76 -0
- package/dist/core/ingestion/route-extractors/php.d.ts +7 -0
- package/dist/core/ingestion/route-extractors/php.js +21 -0
- package/dist/core/ingestion/route-extractors/response-shapes.d.ts +20 -0
- package/dist/core/ingestion/route-extractors/response-shapes.js +290 -0
- package/dist/core/ingestion/symbol-table.d.ts +16 -0
- package/dist/core/ingestion/symbol-table.js +20 -6
- package/dist/core/ingestion/tree-sitter-queries.d.ts +10 -9
- package/dist/core/ingestion/tree-sitter-queries.js +274 -11
- package/dist/core/ingestion/type-env.d.ts +42 -18
- package/dist/core/ingestion/type-env.js +481 -106
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +5 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +119 -0
- package/dist/core/ingestion/type-extractors/csharp.js +149 -16
- package/dist/core/ingestion/type-extractors/dart.d.ts +15 -0
- package/dist/core/ingestion/type-extractors/dart.js +371 -0
- package/dist/core/ingestion/type-extractors/jvm.js +169 -66
- package/dist/core/ingestion/type-extractors/rust.js +35 -1
- package/dist/core/ingestion/type-extractors/shared.d.ts +1 -15
- package/dist/core/ingestion/type-extractors/shared.js +14 -112
- package/dist/core/ingestion/type-extractors/swift.js +338 -7
- package/dist/core/ingestion/type-extractors/types.d.ts +40 -8
- package/dist/core/ingestion/type-extractors/typescript.js +141 -9
- package/dist/core/ingestion/utils/ast-helpers.d.ts +83 -0
- package/dist/core/ingestion/utils/ast-helpers.js +817 -0
- package/dist/core/ingestion/utils/call-analysis.d.ts +73 -0
- package/dist/core/ingestion/utils/call-analysis.js +527 -0
- package/dist/core/ingestion/utils/event-loop.d.ts +5 -0
- package/dist/core/ingestion/utils/event-loop.js +5 -0
- package/dist/core/ingestion/utils/language-detection.d.ts +9 -0
- package/dist/core/ingestion/utils/language-detection.js +70 -0
- package/dist/core/ingestion/utils/verbose.d.ts +1 -0
- package/dist/core/ingestion/utils/verbose.js +7 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +55 -5
- package/dist/core/ingestion/workers/parse-worker.js +415 -225
- package/dist/core/lbug/csv-generator.js +51 -1
- package/dist/core/lbug/lbug-adapter.d.ts +10 -0
- package/dist/core/lbug/lbug-adapter.js +75 -4
- package/dist/core/lbug/schema.d.ts +8 -4
- package/dist/core/lbug/schema.js +65 -4
- package/dist/core/tree-sitter/parser-loader.js +7 -1
- package/dist/core/wiki/cursor-client.d.ts +31 -0
- package/dist/core/wiki/cursor-client.js +127 -0
- package/dist/core/wiki/generator.d.ts +28 -9
- package/dist/core/wiki/generator.js +115 -18
- package/dist/core/wiki/graph-queries.d.ts +4 -0
- package/dist/core/wiki/graph-queries.js +7 -1
- package/dist/core/wiki/llm-client.d.ts +2 -0
- package/dist/core/wiki/llm-client.js +8 -4
- package/dist/core/wiki/prompts.d.ts +3 -3
- package/dist/core/wiki/prompts.js +6 -0
- package/dist/mcp/core/embedder.js +11 -3
- package/dist/mcp/core/lbug-adapter.d.ts +5 -0
- package/dist/mcp/core/lbug-adapter.js +23 -2
- package/dist/mcp/local/local-backend.d.ts +38 -5
- package/dist/mcp/local/local-backend.js +804 -63
- package/dist/mcp/resources.js +2 -0
- package/dist/mcp/tools.js +73 -4
- package/dist/server/api.d.ts +19 -1
- package/dist/server/api.js +66 -6
- package/dist/storage/git.d.ts +12 -0
- package/dist/storage/git.js +21 -0
- package/dist/storage/repo-manager.d.ts +3 -0
- package/package.json +25 -16
- package/dist/core/ingestion/named-binding-extraction.d.ts +0 -61
- package/dist/core/ingestion/named-binding-extraction.js +0 -363
- package/dist/core/ingestion/resolvers/index.d.ts +0 -18
- package/dist/core/ingestion/resolvers/index.js +0 -13
- package/dist/core/ingestion/resolvers/jvm.js +0 -87
- package/dist/core/ingestion/resolvers/php.d.ts +0 -15
- package/dist/core/ingestion/resolvers/php.js +0 -35
- package/dist/core/ingestion/type-extractors/index.d.ts +0 -22
- package/dist/core/ingestion/type-extractors/index.js +0 -31
- package/dist/core/ingestion/utils.d.ts +0 -138
- package/dist/core/ingestion/utils.js +0 -1290
- package/scripts/patch-tree-sitter-swift.cjs +0 -74
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Embedding Client
|
|
3
|
+
*
|
|
4
|
+
* Shared fetch+retry logic for OpenAI-compatible /v1/embeddings endpoints.
|
|
5
|
+
* Imported by both the core embedder (batch) and MCP embedder (query).
|
|
6
|
+
*/
|
|
7
|
+
const HTTP_TIMEOUT_MS = 30_000;
|
|
8
|
+
const HTTP_MAX_RETRIES = 2;
|
|
9
|
+
const HTTP_RETRY_BACKOFF_MS = 1_000;
|
|
10
|
+
const HTTP_BATCH_SIZE = 64;
|
|
11
|
+
const DEFAULT_DIMS = 384;
|
|
12
|
+
/**
|
|
13
|
+
* Build config from the current process.env snapshot.
|
|
14
|
+
* Returns null when GITNEXUS_EMBEDDING_URL + GITNEXUS_EMBEDDING_MODEL are unset.
|
|
15
|
+
* Not cached — env vars are read fresh so late configuration takes effect.
|
|
16
|
+
*/
|
|
17
|
+
const readConfig = () => {
|
|
18
|
+
const baseUrl = process.env.GITNEXUS_EMBEDDING_URL;
|
|
19
|
+
const model = process.env.GITNEXUS_EMBEDDING_MODEL;
|
|
20
|
+
if (!baseUrl || !model)
|
|
21
|
+
return null;
|
|
22
|
+
const rawDims = process.env.GITNEXUS_EMBEDDING_DIMS;
|
|
23
|
+
let dimensions;
|
|
24
|
+
if (rawDims !== undefined) {
|
|
25
|
+
const parsed = parseInt(rawDims, 10);
|
|
26
|
+
if (Number.isNaN(parsed) || parsed <= 0) {
|
|
27
|
+
throw new Error(`GITNEXUS_EMBEDDING_DIMS must be a positive integer, got "${rawDims}"`);
|
|
28
|
+
}
|
|
29
|
+
dimensions = parsed;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
baseUrl: baseUrl.replace(/\/+$/, ''),
|
|
33
|
+
model,
|
|
34
|
+
apiKey: process.env.GITNEXUS_EMBEDDING_API_KEY ?? 'unused',
|
|
35
|
+
dimensions,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Check whether HTTP embedding mode is active (env vars are set).
|
|
40
|
+
*/
|
|
41
|
+
export const isHttpMode = () => readConfig() !== null;
|
|
42
|
+
/**
|
|
43
|
+
* Return the configured embedding dimensions for HTTP mode, or undefined
|
|
44
|
+
* if HTTP mode is not active or no explicit dimensions are set.
|
|
45
|
+
*/
|
|
46
|
+
export const getHttpDimensions = () => readConfig()?.dimensions;
|
|
47
|
+
/**
|
|
48
|
+
* Return a safe representation of a URL for error messages.
|
|
49
|
+
* Strips query string (may contain tokens) and userinfo.
|
|
50
|
+
*/
|
|
51
|
+
const safeUrl = (url) => {
|
|
52
|
+
try {
|
|
53
|
+
const u = new URL(url);
|
|
54
|
+
return `${u.protocol}//${u.host}${u.pathname}`;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return '<invalid-url>';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Send a single batch of texts to the embedding endpoint with retry.
|
|
62
|
+
*
|
|
63
|
+
* @param url - Full endpoint URL (e.g. https://host/v1/embeddings)
|
|
64
|
+
* @param batch - Texts to embed
|
|
65
|
+
* @param model - Model name for the request body
|
|
66
|
+
* @param apiKey - Bearer token (only used in Authorization header)
|
|
67
|
+
* @param batchIndex - Logical batch number (for error context)
|
|
68
|
+
* @param attempt - Current retry attempt (internal)
|
|
69
|
+
*/
|
|
70
|
+
const httpEmbedBatch = async (url, batch, model, apiKey, batchIndex = 0, attempt = 0) => {
|
|
71
|
+
let resp;
|
|
72
|
+
try {
|
|
73
|
+
resp = await fetch(url, {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
signal: AbortSignal.timeout(HTTP_TIMEOUT_MS),
|
|
76
|
+
headers: {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify({ input: batch, model }),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
// Timeouts should not be retried — the server is unresponsive.
|
|
85
|
+
// AbortSignal.timeout() throws DOMException with name 'TimeoutError'.
|
|
86
|
+
const isTimeout = err instanceof DOMException && err.name === 'TimeoutError';
|
|
87
|
+
if (isTimeout) {
|
|
88
|
+
throw new Error(`Embedding request timed out after ${HTTP_TIMEOUT_MS}ms (${safeUrl(url)}, batch ${batchIndex})`);
|
|
89
|
+
}
|
|
90
|
+
// DNS, connection errors — retry with backoff
|
|
91
|
+
if (attempt < HTTP_MAX_RETRIES) {
|
|
92
|
+
const delay = HTTP_RETRY_BACKOFF_MS * (attempt + 1);
|
|
93
|
+
await new Promise(r => setTimeout(r, delay));
|
|
94
|
+
return httpEmbedBatch(url, batch, model, apiKey, batchIndex, attempt + 1);
|
|
95
|
+
}
|
|
96
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
97
|
+
throw new Error(`Embedding request failed (${safeUrl(url)}, batch ${batchIndex}): ${reason}`);
|
|
98
|
+
}
|
|
99
|
+
if (!resp.ok) {
|
|
100
|
+
const status = resp.status;
|
|
101
|
+
if ((status === 429 || status >= 500) && attempt < HTTP_MAX_RETRIES) {
|
|
102
|
+
const delay = HTTP_RETRY_BACKOFF_MS * (attempt + 1);
|
|
103
|
+
await new Promise(r => setTimeout(r, delay));
|
|
104
|
+
return httpEmbedBatch(url, batch, model, apiKey, batchIndex, attempt + 1);
|
|
105
|
+
}
|
|
106
|
+
throw new Error(`Embedding endpoint returned ${status} (${safeUrl(url)}, batch ${batchIndex})`);
|
|
107
|
+
}
|
|
108
|
+
const data = (await resp.json());
|
|
109
|
+
return data.data;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Embed texts via the HTTP backend, splitting into batches.
|
|
113
|
+
* Reads config from env vars on every call.
|
|
114
|
+
*
|
|
115
|
+
* @param texts - Array of texts to embed
|
|
116
|
+
* @returns Array of Float32Array embedding vectors
|
|
117
|
+
*/
|
|
118
|
+
export const httpEmbed = async (texts) => {
|
|
119
|
+
if (texts.length === 0)
|
|
120
|
+
return [];
|
|
121
|
+
const config = readConfig();
|
|
122
|
+
if (!config)
|
|
123
|
+
throw new Error('HTTP embedding not configured');
|
|
124
|
+
const url = `${config.baseUrl}/embeddings`;
|
|
125
|
+
const allVectors = [];
|
|
126
|
+
for (let i = 0; i < texts.length; i += HTTP_BATCH_SIZE) {
|
|
127
|
+
const batch = texts.slice(i, i + HTTP_BATCH_SIZE);
|
|
128
|
+
const batchIndex = Math.floor(i / HTTP_BATCH_SIZE);
|
|
129
|
+
const items = await httpEmbedBatch(url, batch, config.model, config.apiKey, batchIndex);
|
|
130
|
+
if (items.length !== batch.length) {
|
|
131
|
+
throw new Error(`Embedding endpoint returned ${items.length} vectors for ${batch.length} texts ` +
|
|
132
|
+
`(${safeUrl(url)}, batch ${batchIndex})`);
|
|
133
|
+
}
|
|
134
|
+
for (const item of items) {
|
|
135
|
+
const vec = new Float32Array(item.embedding);
|
|
136
|
+
// Fail fast on dimension mismatch rather than inserting bad vectors
|
|
137
|
+
// into the FLOAT[N] column which would cause a cryptic Kuzu error.
|
|
138
|
+
const expected = config.dimensions ?? DEFAULT_DIMS;
|
|
139
|
+
if (vec.length !== expected) {
|
|
140
|
+
const hint = config.dimensions
|
|
141
|
+
? 'Update GITNEXUS_EMBEDDING_DIMS to match your model output.'
|
|
142
|
+
: `Set GITNEXUS_EMBEDDING_DIMS=${vec.length} to match your model output.`;
|
|
143
|
+
throw new Error(`Embedding dimension mismatch: endpoint returned ${vec.length}d vector, ` +
|
|
144
|
+
`but expected ${expected}d. ${hint}`);
|
|
145
|
+
}
|
|
146
|
+
allVectors.push(vec);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return allVectors;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Embed a single query text via the HTTP backend.
|
|
153
|
+
* Convenience for MCP search where only one vector is needed.
|
|
154
|
+
*
|
|
155
|
+
* @param text - Query text to embed
|
|
156
|
+
* @returns Embedding vector as number array
|
|
157
|
+
*/
|
|
158
|
+
export const httpEmbedQuery = async (text) => {
|
|
159
|
+
const config = readConfig();
|
|
160
|
+
if (!config)
|
|
161
|
+
throw new Error('HTTP embedding not configured');
|
|
162
|
+
const url = `${config.baseUrl}/embeddings`;
|
|
163
|
+
const items = await httpEmbedBatch(url, [text], config.model, config.apiKey);
|
|
164
|
+
if (!items.length) {
|
|
165
|
+
throw new Error(`Embedding endpoint returned empty response (${safeUrl(url)})`);
|
|
166
|
+
}
|
|
167
|
+
const embedding = items[0].embedding;
|
|
168
|
+
// Same dimension checks as httpEmbed — catch mismatches before they
|
|
169
|
+
// reach the Kuzu FLOAT[N] cast in search queries.
|
|
170
|
+
const expected = config.dimensions ?? DEFAULT_DIMS;
|
|
171
|
+
if (embedding.length !== expected) {
|
|
172
|
+
const hint = config.dimensions
|
|
173
|
+
? 'Update GITNEXUS_EMBEDDING_DIMS to match your model output.'
|
|
174
|
+
: `Set GITNEXUS_EMBEDDING_DIMS=${embedding.length} to match your model output.`;
|
|
175
|
+
throw new Error(`Embedding dimension mismatch: endpoint returned ${embedding.length}d vector, ` +
|
|
176
|
+
`but expected ${expected}d. ${hint}`);
|
|
177
|
+
}
|
|
178
|
+
return embedding;
|
|
179
|
+
};
|
|
@@ -34,7 +34,7 @@ export interface EmbeddingProgress {
|
|
|
34
34
|
* Configuration for the embedding pipeline
|
|
35
35
|
*/
|
|
36
36
|
export interface EmbeddingConfig {
|
|
37
|
-
/** Model identifier for transformers.js */
|
|
37
|
+
/** Model identifier for transformers.js (local) or the HTTP endpoint model name */
|
|
38
38
|
modelId: string;
|
|
39
39
|
/** Number of nodes to embed in each batch */
|
|
40
40
|
batchSize: number;
|
package/dist/core/graph/graph.js
CHANGED
|
@@ -27,7 +27,14 @@ export const createKnowledgeGraph = () => {
|
|
|
27
27
|
return true;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Remove
|
|
30
|
+
* Remove a single relationship by id.
|
|
31
|
+
* Returns true if the relationship existed and was removed, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
const removeRelationship = (relationshipId) => {
|
|
34
|
+
return relationshipMap.delete(relationshipId);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Remove all nodes (and their relationships) belonging to a file.
|
|
31
38
|
*/
|
|
32
39
|
const removeNodesByFile = (filePath) => {
|
|
33
40
|
let removed = 0;
|
|
@@ -62,5 +69,6 @@ export const createKnowledgeGraph = () => {
|
|
|
62
69
|
addRelationship,
|
|
63
70
|
removeNode,
|
|
64
71
|
removeNodesByFile,
|
|
72
|
+
removeRelationship,
|
|
65
73
|
};
|
|
66
74
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type NodeLabel = 'Project' | 'Package' | 'Module' | 'Folder' | 'File' | 'Class' | 'Function' | 'Method' | 'Variable' | 'Interface' | 'Enum' | 'Decorator' | 'Import' | 'Type' | 'CodeElement' | 'Community' | 'Process' | 'Struct' | 'Macro' | 'Typedef' | 'Union' | 'Namespace' | 'Trait' | 'Impl' | 'TypeAlias' | 'Const' | 'Static' | 'Property' | 'Record' | 'Delegate' | 'Annotation' | 'Constructor' | 'Template';
|
|
1
|
+
export type NodeLabel = 'Project' | 'Package' | 'Module' | 'Folder' | 'File' | 'Class' | 'Function' | 'Method' | 'Variable' | 'Interface' | 'Enum' | 'Decorator' | 'Import' | 'Type' | 'CodeElement' | 'Community' | 'Process' | 'Struct' | 'Macro' | 'Typedef' | 'Union' | 'Namespace' | 'Trait' | 'Impl' | 'TypeAlias' | 'Const' | 'Static' | 'Property' | 'Record' | 'Delegate' | 'Annotation' | 'Constructor' | 'Template' | 'Section' | 'Route' | 'Tool';
|
|
2
2
|
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
3
3
|
export type NodeProperties = {
|
|
4
4
|
name: string;
|
|
@@ -23,9 +23,17 @@ export type NodeProperties = {
|
|
|
23
23
|
entryPointScore?: number;
|
|
24
24
|
entryPointReason?: string;
|
|
25
25
|
parameterCount?: number;
|
|
26
|
+
level?: number;
|
|
26
27
|
returnType?: string;
|
|
28
|
+
declaredType?: string;
|
|
29
|
+
visibility?: string;
|
|
30
|
+
isStatic?: boolean;
|
|
31
|
+
isReadonly?: boolean;
|
|
32
|
+
responseKeys?: string[];
|
|
33
|
+
errorKeys?: string[];
|
|
34
|
+
middleware?: string[];
|
|
27
35
|
};
|
|
28
|
-
export type RelationshipType = 'CONTAINS' | 'CALLS' | 'INHERITS' | 'OVERRIDES' | 'IMPORTS' | 'USES' | 'DEFINES' | 'DECORATES' | 'IMPLEMENTS' | 'EXTENDS' | 'HAS_METHOD' | 'HAS_PROPERTY' | 'ACCESSES' | 'MEMBER_OF' | 'STEP_IN_PROCESS';
|
|
36
|
+
export type RelationshipType = 'CONTAINS' | 'CALLS' | 'INHERITS' | 'OVERRIDES' | 'IMPORTS' | 'USES' | 'DEFINES' | 'DECORATES' | 'IMPLEMENTS' | 'EXTENDS' | 'HAS_METHOD' | 'HAS_PROPERTY' | 'ACCESSES' | 'MEMBER_OF' | 'STEP_IN_PROCESS' | 'HANDLES_ROUTE' | 'FETCHES' | 'HANDLES_TOOL' | 'ENTRY_POINT_OF' | 'WRAPS' | 'QUERIES';
|
|
29
37
|
export interface GraphNode {
|
|
30
38
|
id: string;
|
|
31
39
|
label: NodeLabel;
|
|
@@ -63,4 +71,5 @@ export interface KnowledgeGraph {
|
|
|
63
71
|
addRelationship: (relationship: GraphRelationship) => void;
|
|
64
72
|
removeNode: (nodeId: string) => boolean;
|
|
65
73
|
removeNodesByFile: (filePath: string) => number;
|
|
74
|
+
removeRelationship: (relationshipId: string) => boolean;
|
|
66
75
|
}
|
|
@@ -1,11 +1,58 @@
|
|
|
1
1
|
import { KnowledgeGraph } from '../graph/types.js';
|
|
2
2
|
import { ASTCache } from './ast-cache.js';
|
|
3
|
+
import type { SymbolTable } from './symbol-table.js';
|
|
3
4
|
import type { ResolutionContext } from './resolution-context.js';
|
|
4
|
-
import type { ExtractedCall, ExtractedAssignment, ExtractedHeritage, ExtractedRoute, FileConstructorBindings } from './workers/parse-worker.js';
|
|
5
|
+
import type { ExtractedCall, ExtractedAssignment, ExtractedHeritage, ExtractedRoute, ExtractedFetchCall, FileConstructorBindings } from './workers/parse-worker.js';
|
|
6
|
+
/** Per-file resolved type bindings for exported symbols.
|
|
7
|
+
* Populated during call processing, consumed by Phase 14 re-resolution pass. */
|
|
8
|
+
export type ExportedTypeMap = Map<string, Map<string, string>>;
|
|
9
|
+
/** Build a map of imported callee names → return types for cross-file call-result binding.
|
|
10
|
+
* Consulted ONLY when SymbolTable has no unambiguous local match (local-first principle). */
|
|
11
|
+
export declare function buildImportedReturnTypes(filePath: string, namedImportMap: ReadonlyMap<string, ReadonlyMap<string, {
|
|
12
|
+
sourcePath: string;
|
|
13
|
+
exportedName: string;
|
|
14
|
+
}>>, symbolTable: {
|
|
15
|
+
lookupExactFull(filePath: string, name: string): {
|
|
16
|
+
returnType?: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}): ReadonlyMap<string, string>;
|
|
19
|
+
/** Build cross-file RAW return types for imported callables.
|
|
20
|
+
* Unlike buildImportedReturnTypes (which stores extractReturnTypeName output),
|
|
21
|
+
* this stores the raw declared return type string (e.g., 'User[]', 'List<User>').
|
|
22
|
+
* Used by lookupRawReturnType for for-loop element extraction via extractElementTypeFromString. */
|
|
23
|
+
export declare function buildImportedRawReturnTypes(filePath: string, namedImportMap: ReadonlyMap<string, ReadonlyMap<string, {
|
|
24
|
+
sourcePath: string;
|
|
25
|
+
exportedName: string;
|
|
26
|
+
}>>, symbolTable: {
|
|
27
|
+
lookupExactFull(filePath: string, name: string): {
|
|
28
|
+
returnType?: string;
|
|
29
|
+
} | undefined;
|
|
30
|
+
}): ReadonlyMap<string, string>;
|
|
31
|
+
/** Build ExportedTypeMap from graph nodes — used for worker path where TypeEnv
|
|
32
|
+
* is not available in the main thread. Collects returnType/declaredType from
|
|
33
|
+
* exported symbols that have callables with known return types. */
|
|
34
|
+
export declare function buildExportedTypeMapFromGraph(graph: KnowledgeGraph, symbolTable: SymbolTable): ExportedTypeMap;
|
|
35
|
+
/** Seed cross-file receiver types into pre-extracted call records.
|
|
36
|
+
* Fills missing receiverTypeName for single-hop imported variables
|
|
37
|
+
* using ExportedTypeMap + namedImportMap — zero disk I/O, zero AST re-parsing.
|
|
38
|
+
* Mutates calls in-place. Runs BEFORE processCallsFromExtracted. */
|
|
39
|
+
export declare function seedCrossFileReceiverTypes(calls: ExtractedCall[], namedImportMap: ReadonlyMap<string, ReadonlyMap<string, {
|
|
40
|
+
sourcePath: string;
|
|
41
|
+
exportedName: string;
|
|
42
|
+
}>>, exportedTypeMap: ReadonlyMap<string, ReadonlyMap<string, string>>): {
|
|
43
|
+
enrichedCount: number;
|
|
44
|
+
};
|
|
5
45
|
export declare const processCalls: (graph: KnowledgeGraph, files: {
|
|
6
46
|
path: string;
|
|
7
47
|
content: string;
|
|
8
|
-
}[], astCache: ASTCache, ctx: ResolutionContext, onProgress?: (current: number, total: number) => void
|
|
48
|
+
}[], astCache: ASTCache, ctx: ResolutionContext, onProgress?: (current: number, total: number) => void, exportedTypeMap?: ExportedTypeMap,
|
|
49
|
+
/** Phase 14: pre-resolved cross-file bindings to seed into buildTypeEnv. Keyed by filePath → Map<localName, typeName>. */
|
|
50
|
+
importedBindingsMap?: ReadonlyMap<string, ReadonlyMap<string, string>>,
|
|
51
|
+
/** Phase 14 E3: cross-file return types for imported callables. Keyed by filePath → Map<calleeName, returnType>.
|
|
52
|
+
* Consulted ONLY when SymbolTable has no unambiguous match (local-first principle). */
|
|
53
|
+
importedReturnTypesMap?: ReadonlyMap<string, ReadonlyMap<string, string>>,
|
|
54
|
+
/** Phase 14 E3: cross-file RAW return types for for-loop element extraction. Keyed by filePath → Map<calleeName, rawReturnType>. */
|
|
55
|
+
importedRawReturnTypesMap?: ReadonlyMap<string, ReadonlyMap<string, string>>) => Promise<ExtractedHeritage[]>;
|
|
9
56
|
/**
|
|
10
57
|
* Fast path: resolve pre-extracted call sites from workers.
|
|
11
58
|
* No AST parsing — workers already extracted calledName + sourceId.
|
|
@@ -21,3 +68,20 @@ export declare const processAssignmentsFromExtracted: (graph: KnowledgeGraph, as
|
|
|
21
68
|
* Resolve pre-extracted Laravel routes to CALLS edges from route files to controller methods.
|
|
22
69
|
*/
|
|
23
70
|
export declare const processRoutesFromExtracted: (graph: KnowledgeGraph, extractedRoutes: ExtractedRoute[], ctx: ResolutionContext, onProgress?: (current: number, total: number) => void) => Promise<void>;
|
|
71
|
+
export declare const extractConsumerAccessedKeys: (content: string) => string[];
|
|
72
|
+
/**
|
|
73
|
+
* Create FETCHES edges from extracted fetch() calls to matching Route nodes.
|
|
74
|
+
* When consumerContents is provided, extracts property access patterns from
|
|
75
|
+
* consumer files and encodes them in the edge reason field.
|
|
76
|
+
*/
|
|
77
|
+
export declare const processNextjsFetchRoutes: (graph: KnowledgeGraph, fetchCalls: ExtractedFetchCall[], routeRegistry: Map<string, string>, // routeURL → handlerFilePath
|
|
78
|
+
consumerContents?: Map<string, string>) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Extract fetch() calls from source files (sequential path).
|
|
81
|
+
* Workers handle this via tree-sitter captures in parse-worker; this function
|
|
82
|
+
* provides the same extraction for the sequential fallback path.
|
|
83
|
+
*/
|
|
84
|
+
export declare const extractFetchCallsFromFiles: (files: {
|
|
85
|
+
path: string;
|
|
86
|
+
content: string;
|
|
87
|
+
}[], astCache: ASTCache) => Promise<ExtractedFetchCall[]>;
|