@cleocode/nexus 2026.9.8 → 2026.9.10
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/dist/src/code/parser.d.ts +19 -1
- package/dist/src/code/parser.d.ts.map +1 -1
- package/dist/src/code/parser.js +61 -1
- package/dist/src/code/parser.js.map +1 -1
- package/dist/src/intelligence/impact.d.ts +9 -0
- package/dist/src/intelligence/impact.d.ts.map +1 -1
- package/dist/src/intelligence/impact.js +25 -13
- package/dist/src/intelligence/impact.js.map +1 -1
- package/dist/src/pipeline/call-processor.d.ts +4 -1
- package/dist/src/pipeline/call-processor.d.ts.map +1 -1
- package/dist/src/pipeline/call-processor.js +43 -3
- package/dist/src/pipeline/call-processor.js.map +1 -1
- package/dist/src/pipeline/community-processor.d.ts.map +1 -1
- package/dist/src/pipeline/community-processor.js +6 -27
- package/dist/src/pipeline/community-processor.js.map +1 -1
- package/dist/src/pipeline/extractors/typescript-extractor.d.ts +27 -35
- package/dist/src/pipeline/extractors/typescript-extractor.d.ts.map +1 -1
- package/dist/src/pipeline/extractors/typescript-extractor.js +100 -213
- package/dist/src/pipeline/extractors/typescript-extractor.js.map +1 -1
- package/dist/src/pipeline/filesystem-walker.d.ts +9 -5
- package/dist/src/pipeline/filesystem-walker.d.ts.map +1 -1
- package/dist/src/pipeline/filesystem-walker.js +154 -79
- package/dist/src/pipeline/filesystem-walker.js.map +1 -1
- package/dist/src/pipeline/heritage-processor.d.ts.map +1 -1
- package/dist/src/pipeline/heritage-processor.js +29 -4
- package/dist/src/pipeline/heritage-processor.js.map +1 -1
- package/dist/src/pipeline/import-processor.d.ts +28 -6
- package/dist/src/pipeline/import-processor.d.ts.map +1 -1
- package/dist/src/pipeline/import-processor.js +68 -45
- package/dist/src/pipeline/import-processor.js.map +1 -1
- package/dist/src/pipeline/index.d.ts +32 -20
- package/dist/src/pipeline/index.d.ts.map +1 -1
- package/dist/src/pipeline/index.js +173 -148
- package/dist/src/pipeline/index.js.map +1 -1
- package/dist/src/pipeline/knowledge-graph.d.ts +3 -1
- package/dist/src/pipeline/knowledge-graph.d.ts.map +1 -1
- package/dist/src/pipeline/knowledge-graph.js +36 -2
- package/dist/src/pipeline/knowledge-graph.js.map +1 -1
- package/dist/src/pipeline/lexical-scope.d.ts +60 -0
- package/dist/src/pipeline/lexical-scope.d.ts.map +1 -0
- package/dist/src/pipeline/lexical-scope.js +362 -0
- package/dist/src/pipeline/lexical-scope.js.map +1 -0
- package/dist/src/pipeline/parse-loop.d.ts +49 -2
- package/dist/src/pipeline/parse-loop.d.ts.map +1 -1
- package/dist/src/pipeline/parse-loop.js +346 -144
- package/dist/src/pipeline/parse-loop.js.map +1 -1
- package/dist/src/pipeline/processors/access-processor.d.ts +27 -14
- package/dist/src/pipeline/processors/access-processor.d.ts.map +1 -1
- package/dist/src/pipeline/processors/access-processor.js +106 -27
- package/dist/src/pipeline/processors/access-processor.js.map +1 -1
- package/dist/src/pipeline/structure-processor.d.ts.map +1 -1
- package/dist/src/pipeline/structure-processor.js +1 -0
- package/dist/src/pipeline/structure-processor.js.map +1 -1
- package/dist/src/pipeline/symbol-table.d.ts +41 -3
- package/dist/src/pipeline/symbol-table.d.ts.map +1 -1
- package/dist/src/pipeline/symbol-table.js +104 -2
- package/dist/src/pipeline/symbol-table.js.map +1 -1
- package/dist/src/pipeline/workers/parse-worker.d.ts +29 -92
- package/dist/src/pipeline/workers/parse-worker.d.ts.map +1 -1
- package/dist/src/pipeline/workers/parse-worker.js +49 -1110
- package/dist/src/pipeline/workers/parse-worker.js.map +1 -1
- package/dist/src/pipeline/workers/worker-pool.d.ts +6 -4
- package/dist/src/pipeline/workers/worker-pool.d.ts.map +1 -1
- package/dist/src/pipeline/workers/worker-pool.js +112 -22
- package/dist/src/pipeline/workers/worker-pool.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-graph.js","sourceRoot":"","sources":["../../../src/pipeline/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"knowledge-graph.js","sourceRoot":"","sources":["../../../src/pipeline/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsDzC,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAE9E,yEAAyE;AACzE,kFAAkF;AAClF,+DAA+D;AAE/D,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E,+EAA+E;AAC/E,MAAM,UAAU,GAAG,GAAG,CAAC;AAgCvB;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC3C,MAAM,SAAS,GAAoB,EAAE,CAAC;IACtC,+DAA+D;IAC/D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAEvC,SAAS,OAAO,CAAC,IAAe;QAC9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACxB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,SAAS,iBAAiB,CAAC,EAAU;QACnC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QAC3D,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG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CAAC;YACzE,CAAC;QACH,CAAC;QAED,yBAAyB;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC;YACzD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;YACpD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC;YAC7E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK;QACL,SAAS;QACT,OAAO;QACP,WAAW;QACX,KAAK;QACL,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Shared TypeScript/JavaScript lexical ownership and binding model. @task T12264 */
|
|
2
|
+
import type { GraphLexicalBinding, GraphLexicalResolution, GraphLexicalScope, GraphSourceSpan } from '@cleocode/contracts/graph';
|
|
3
|
+
import type Parser from 'tree-sitter';
|
|
4
|
+
/** Callable/class declaration identity used by every reference extractor. */
|
|
5
|
+
export interface LexicalDeclaration {
|
|
6
|
+
/** Qualified graph identity; anonymous identities also include their generation. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Visible name or explicit anonymous label. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Graph declaration kind. */
|
|
11
|
+
kind: 'function' | 'method' | 'class';
|
|
12
|
+
/** Owning declaration, absent for module-level declarations. */
|
|
13
|
+
parentId?: string;
|
|
14
|
+
/** Original declaration syntax. */
|
|
15
|
+
node: Parser.SyntaxNode;
|
|
16
|
+
/** Original declaration range. */
|
|
17
|
+
span: GraphSourceSpan;
|
|
18
|
+
}
|
|
19
|
+
/** One AST model shared by declaration, call, and access extraction. */
|
|
20
|
+
export interface LexicalScopeModel {
|
|
21
|
+
/** Explicit supported language; no equivalent capability is inferred for other parsers. */
|
|
22
|
+
language: 'typescript' | 'javascript';
|
|
23
|
+
/** Caller-supplied generation identity for the analyzed source. */
|
|
24
|
+
generation: string;
|
|
25
|
+
/** Publication identity allocated before extraction; absent on standalone source analysis. */
|
|
26
|
+
publicationGeneration?: string;
|
|
27
|
+
/** Lexical scope inventory. */
|
|
28
|
+
scopes: readonly GraphLexicalScope[];
|
|
29
|
+
/** Binding inventory including locals that have no known callable target. */
|
|
30
|
+
bindings: readonly GraphLexicalBinding[];
|
|
31
|
+
/** All nested and object callables/classes, not only module declarations. */
|
|
32
|
+
declarations: readonly LexicalDeclaration[];
|
|
33
|
+
/** Retain an original AST range with explicit UTF-16 offset semantics. */
|
|
34
|
+
spanOf(node: Parser.SyntaxNode): GraphSourceSpan;
|
|
35
|
+
/** Find the innermost scope covering an original UTF-16 offset. */
|
|
36
|
+
scopeAt(offset: number): GraphLexicalScope;
|
|
37
|
+
/** Resolve a visible name without consulting unrelated global declarations. */
|
|
38
|
+
resolve(name: string, offset: number): GraphLexicalResolution;
|
|
39
|
+
/** Identify the actual enclosing declaration, including anonymous callbacks. */
|
|
40
|
+
ownerAt(offset: number): string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build one lexical model over original TypeScript or JavaScript syntax.
|
|
44
|
+
* @param root - Native program node retaining original Unicode and UTF-16 spans.
|
|
45
|
+
* @param filePath - Repository-relative source identity.
|
|
46
|
+
* @param generation - Explicit source generation; required for anonymous identity.
|
|
47
|
+
* @param language - Supported lexical language, never inferred for another grammar.
|
|
48
|
+
* @param publicationGeneration - Optional preallocated publication identity for anonymous symbols.
|
|
49
|
+
* @returns The scope, declaration and binding model shared by reference extractors.
|
|
50
|
+
* @remarks This models lexical bindings, not runtime values, dynamic dispatch or
|
|
51
|
+
* closure invocation. Unknown locals block global fallback. Duplicate nearest
|
|
52
|
+
* bindings return candidates instead of silently choosing the first declaration.
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const model = buildLexicalScopeModel(tree.rootNode, 'src/auth.ts', sourceHash, 'typescript');
|
|
56
|
+
* const binding = model.resolve('orgNameTaken', call.startIndex);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildLexicalScopeModel(root: Parser.SyntaxNode, filePath: string, generation: string, language: string, publicationGeneration?: string): LexicalScopeModel;
|
|
60
|
+
//# sourceMappingURL=lexical-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical-scope.d.ts","sourceRoot":"","sources":["../../../src/pipeline/lexical-scope.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,oFAAoF;IACpF,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;IACtC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,kCAAkC;IAClC,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,wEAAwE;AACxE,MAAM,WAAW,iBAAiB;IAChC,2FAA2F;IAC3F,QAAQ,EAAE,YAAY,GAAG,YAAY,CAAC;IACtC,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,+BAA+B;IAC/B,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrC,6EAA6E;IAC7E,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACzC,6EAA6E;IAC7E,YAAY,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC5C,0EAA0E;IAC1E,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,GAAG,eAAe,CAAC;IACjD,mEAAmE;IACnE,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAC3C,+EAA+E;IAC/E,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,sBAAsB,CAAC;IAC9D,gFAAgF;IAChF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AA2ED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,CAAC,UAAU,EACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,qBAAqB,CAAC,EAAE,MAAM,GAC7B,iBAAiB,CAqSnB"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
const FUNCTIONS = new Set([
|
|
2
|
+
'function_declaration',
|
|
3
|
+
'generator_function_declaration',
|
|
4
|
+
'function_expression',
|
|
5
|
+
'generator_function',
|
|
6
|
+
'arrow_function',
|
|
7
|
+
'method_definition',
|
|
8
|
+
]);
|
|
9
|
+
const CLASSES = new Set(['class_declaration', 'abstract_class_declaration', 'class']);
|
|
10
|
+
function span(node) {
|
|
11
|
+
return {
|
|
12
|
+
startIndex: node.startIndex,
|
|
13
|
+
endIndex: node.endIndex,
|
|
14
|
+
startLine: node.startPosition.row + 1,
|
|
15
|
+
endLine: node.endPosition.row + 1,
|
|
16
|
+
startColumn: node.startPosition.column,
|
|
17
|
+
endColumn: node.endPosition.column,
|
|
18
|
+
offsetEncoding: 'utf16',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function segment(name) {
|
|
22
|
+
return name.replaceAll('%', '%25').replaceAll('.', '%2E').replaceAll(':', '%3A');
|
|
23
|
+
}
|
|
24
|
+
function propertyName(node) {
|
|
25
|
+
if (!node || node.type === 'computed_property_name')
|
|
26
|
+
return undefined;
|
|
27
|
+
if (node.type === 'string')
|
|
28
|
+
return node.namedChildren.find((child) => child.type === 'string_fragment')?.text;
|
|
29
|
+
return node.text;
|
|
30
|
+
}
|
|
31
|
+
/** Collect only binding patterns, never property keys or type annotation identifiers. */
|
|
32
|
+
function patternNames(node) {
|
|
33
|
+
if (!node)
|
|
34
|
+
return [];
|
|
35
|
+
if (node.type === 'identifier' || node.type === 'shorthand_property_identifier_pattern')
|
|
36
|
+
return [node];
|
|
37
|
+
if (node.type === 'pair_pattern')
|
|
38
|
+
return patternNames(node.childForFieldName('value'));
|
|
39
|
+
if (node.type === 'assignment_pattern' || node.type === 'object_assignment_pattern') {
|
|
40
|
+
return patternNames(node.childForFieldName('left') ?? node.namedChild(0));
|
|
41
|
+
}
|
|
42
|
+
if (node.type === 'required_parameter' || node.type === 'optional_parameter') {
|
|
43
|
+
return patternNames(node.childForFieldName('pattern') ?? node.childForFieldName('name'));
|
|
44
|
+
}
|
|
45
|
+
if (['object_pattern', 'array_pattern', 'rest_pattern', 'formal_parameters'].includes(node.type)) {
|
|
46
|
+
return node.namedChildren.flatMap(patternNames);
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
/** Property path for object literal methods/callbacks without inventing lexical object scopes. */
|
|
51
|
+
function objectPath(node) {
|
|
52
|
+
const names = [];
|
|
53
|
+
let current = node;
|
|
54
|
+
while (current?.parent) {
|
|
55
|
+
const parent = current.parent;
|
|
56
|
+
if (parent.type === 'pair' && parent.childForFieldName('value')?.id === current.id) {
|
|
57
|
+
const key = propertyName(parent.childForFieldName('key'));
|
|
58
|
+
if (!key)
|
|
59
|
+
return [];
|
|
60
|
+
names.unshift(segment(key));
|
|
61
|
+
}
|
|
62
|
+
else if (parent.type === 'variable_declarator') {
|
|
63
|
+
const name = parent.childForFieldName('name');
|
|
64
|
+
if (name?.type === 'identifier')
|
|
65
|
+
names.unshift(segment(name.text));
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
else if (parent.type !== 'object' && parent.type !== 'pair')
|
|
69
|
+
break;
|
|
70
|
+
current = parent;
|
|
71
|
+
}
|
|
72
|
+
return names;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build one lexical model over original TypeScript or JavaScript syntax.
|
|
76
|
+
* @param root - Native program node retaining original Unicode and UTF-16 spans.
|
|
77
|
+
* @param filePath - Repository-relative source identity.
|
|
78
|
+
* @param generation - Explicit source generation; required for anonymous identity.
|
|
79
|
+
* @param language - Supported lexical language, never inferred for another grammar.
|
|
80
|
+
* @param publicationGeneration - Optional preallocated publication identity for anonymous symbols.
|
|
81
|
+
* @returns The scope, declaration and binding model shared by reference extractors.
|
|
82
|
+
* @remarks This models lexical bindings, not runtime values, dynamic dispatch or
|
|
83
|
+
* closure invocation. Unknown locals block global fallback. Duplicate nearest
|
|
84
|
+
* bindings return candidates instead of silently choosing the first declaration.
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const model = buildLexicalScopeModel(tree.rootNode, 'src/auth.ts', sourceHash, 'typescript');
|
|
88
|
+
* const binding = model.resolve('orgNameTaken', call.startIndex);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function buildLexicalScopeModel(root, filePath, generation, language, publicationGeneration) {
|
|
92
|
+
if (language !== 'typescript' && language !== 'javascript')
|
|
93
|
+
throw new Error(`E_SCOPE_LANGUAGE: lexical bindings unsupported for ${language}`);
|
|
94
|
+
if (!generation)
|
|
95
|
+
throw new Error('Lexical source generation is required');
|
|
96
|
+
if (publicationGeneration === '')
|
|
97
|
+
throw new Error('Publication generation cannot be empty');
|
|
98
|
+
const moduleId = `${filePath}::__file__`;
|
|
99
|
+
const moduleScope = {
|
|
100
|
+
id: moduleId,
|
|
101
|
+
kind: 'module',
|
|
102
|
+
ownerId: moduleId,
|
|
103
|
+
span: span(root),
|
|
104
|
+
};
|
|
105
|
+
const scopes = [moduleScope];
|
|
106
|
+
const byId = new Map([[moduleId, moduleScope]]);
|
|
107
|
+
const bindings = [];
|
|
108
|
+
const declarations = [];
|
|
109
|
+
const scopedBindings = new Map();
|
|
110
|
+
function addBinding(scope, node, name, kind, detail = {}) {
|
|
111
|
+
const binding = {
|
|
112
|
+
id: `${scope.id}::binding:${segment(name)}@${node.startIndex}`,
|
|
113
|
+
name,
|
|
114
|
+
scopeId: scope.id,
|
|
115
|
+
kind,
|
|
116
|
+
span: span(node),
|
|
117
|
+
...detail,
|
|
118
|
+
};
|
|
119
|
+
bindings.push(binding);
|
|
120
|
+
let names = scopedBindings.get(scope.id);
|
|
121
|
+
if (!names) {
|
|
122
|
+
names = new Map();
|
|
123
|
+
scopedBindings.set(scope.id, names);
|
|
124
|
+
}
|
|
125
|
+
const candidates = names.get(name) ?? [];
|
|
126
|
+
candidates.push(binding);
|
|
127
|
+
names.set(name, candidates);
|
|
128
|
+
}
|
|
129
|
+
function childScope(node, parent, kind, ownerId = parent.ownerId) {
|
|
130
|
+
const scope = {
|
|
131
|
+
id: `${parent.id}::${kind}@${node.startIndex}:${node.endIndex}`,
|
|
132
|
+
parentId: parent.id,
|
|
133
|
+
kind,
|
|
134
|
+
ownerId,
|
|
135
|
+
span: span(node),
|
|
136
|
+
};
|
|
137
|
+
scopes.push(scope);
|
|
138
|
+
byId.set(scope.id, scope);
|
|
139
|
+
return scope;
|
|
140
|
+
}
|
|
141
|
+
function importBindings(node, scope) {
|
|
142
|
+
const rawSource = node.childForFieldName('source')?.text;
|
|
143
|
+
if (!rawSource)
|
|
144
|
+
return;
|
|
145
|
+
const importSource = rawSource.slice(1, -1);
|
|
146
|
+
const typeOnly = /^import\s+type\b/.test(node.text);
|
|
147
|
+
const clause = node.namedChildren.find((child) => child.type === 'import_clause');
|
|
148
|
+
if (!clause)
|
|
149
|
+
return;
|
|
150
|
+
for (const child of clause.namedChildren) {
|
|
151
|
+
if (child.type === 'identifier')
|
|
152
|
+
addBinding(scope, child, child.text, 'import', {
|
|
153
|
+
importSource,
|
|
154
|
+
importedName: 'default',
|
|
155
|
+
typeOnly,
|
|
156
|
+
});
|
|
157
|
+
if (child.type === 'namespace_import') {
|
|
158
|
+
const name = child.namedChildren.find((item) => item.type === 'identifier');
|
|
159
|
+
if (name)
|
|
160
|
+
addBinding(scope, name, name.text, 'import', {
|
|
161
|
+
importSource,
|
|
162
|
+
importedName: '*',
|
|
163
|
+
typeOnly,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (child.type === 'named_imports')
|
|
167
|
+
for (const specifier of child.namedChildren) {
|
|
168
|
+
const imported = specifier.childForFieldName('name');
|
|
169
|
+
const local = specifier.childForFieldName('alias') ?? imported;
|
|
170
|
+
if (imported && local)
|
|
171
|
+
addBinding(scope, local, local.text, 'import', {
|
|
172
|
+
importSource,
|
|
173
|
+
importedName: imported.text,
|
|
174
|
+
typeOnly: typeOnly || /^type\s/.test(specifier.text),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function variableOwner(node, scope) {
|
|
180
|
+
let owner = scope;
|
|
181
|
+
if (node.parent?.type === 'variable_declaration') {
|
|
182
|
+
while (owner.parentId && !['function', 'module'].includes(owner.kind)) {
|
|
183
|
+
const parent = byId.get(owner.parentId);
|
|
184
|
+
if (!parent)
|
|
185
|
+
throw new Error('Lexical parent scope missing');
|
|
186
|
+
owner = parent;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return owner;
|
|
190
|
+
}
|
|
191
|
+
function walk(node, scope) {
|
|
192
|
+
if (node.type === 'import_statement') {
|
|
193
|
+
importBindings(node, scope);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (FUNCTIONS.has(node.type) || CLASSES.has(node.type)) {
|
|
197
|
+
const isClass = CLASSES.has(node.type);
|
|
198
|
+
const parent = node.parent;
|
|
199
|
+
const declaratorName = parent?.type === 'variable_declarator' ? parent.childForFieldName('name') : null;
|
|
200
|
+
const pairName = parent?.type === 'pair' ? propertyName(parent.childForFieldName('key')) : undefined;
|
|
201
|
+
const explicitName = declaratorName?.type === 'identifier'
|
|
202
|
+
? declaratorName.text
|
|
203
|
+
: (pairName ?? propertyName(node.childForFieldName('name')));
|
|
204
|
+
const anonymous = !explicitName;
|
|
205
|
+
const name = explicitName ??
|
|
206
|
+
`<anonymous@${node.startIndex}:${node.endIndex}#${encodeURIComponent(publicationGeneration ?? generation)}>`;
|
|
207
|
+
const path = objectPath(node);
|
|
208
|
+
if (node.type === 'method_definition')
|
|
209
|
+
path.push(segment(name));
|
|
210
|
+
const localName = path.length > 0 ? path.join('.') : segment(name);
|
|
211
|
+
const prefix = scope.kind === 'module'
|
|
212
|
+
? `${filePath}::`
|
|
213
|
+
: `${scope.ownerId}.${scope.kind === 'block' || scope.kind === 'catch' ? `block@${scope.span.startIndex}.` : ''}`;
|
|
214
|
+
const id = prefix + localName;
|
|
215
|
+
const property = node.type === 'method_definition' || pairName !== undefined;
|
|
216
|
+
declarations.push({
|
|
217
|
+
id,
|
|
218
|
+
name,
|
|
219
|
+
kind: isClass ? 'class' : property ? 'method' : 'function',
|
|
220
|
+
parentId: scope.ownerId === moduleId ? undefined : scope.ownerId,
|
|
221
|
+
node,
|
|
222
|
+
span: span(node),
|
|
223
|
+
});
|
|
224
|
+
const isDeclaration = node.type.endsWith('_declaration');
|
|
225
|
+
if (!anonymous && !property && (isDeclaration || declaratorName?.type === 'identifier')) {
|
|
226
|
+
addBinding(parent?.type === 'variable_declarator' ? variableOwner(parent, scope) : scope, declaratorName ?? node.childForFieldName('name') ?? node, name, isClass ? 'class' : 'function', { targetId: id });
|
|
227
|
+
}
|
|
228
|
+
const inner = childScope(node, scope, isClass ? 'class' : 'function', id);
|
|
229
|
+
const internalName = node.childForFieldName('name');
|
|
230
|
+
if (!isDeclaration && internalName?.type === 'identifier' && !property)
|
|
231
|
+
addBinding(inner, internalName, internalName.text, isClass ? 'class' : 'function', {
|
|
232
|
+
targetId: id,
|
|
233
|
+
});
|
|
234
|
+
if (!isClass) {
|
|
235
|
+
const params = node.childForFieldName('parameters') ?? node.childForFieldName('parameter');
|
|
236
|
+
for (const parameter of patternNames(params))
|
|
237
|
+
addBinding(inner, parameter, parameter.text, 'parameter');
|
|
238
|
+
}
|
|
239
|
+
for (const child of node.namedChildren)
|
|
240
|
+
walk(child, inner);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (['for_statement', 'for_in_statement', 'switch_body'].includes(node.type)) {
|
|
244
|
+
const inner = childScope(node, scope, 'block');
|
|
245
|
+
if (node.type === 'for_in_statement' && node.childForFieldName('kind')) {
|
|
246
|
+
let owner = inner;
|
|
247
|
+
if (node.childForFieldName('kind')?.text === 'var') {
|
|
248
|
+
while (owner.parentId && !['function', 'module'].includes(owner.kind)) {
|
|
249
|
+
const parent = byId.get(owner.parentId);
|
|
250
|
+
if (!parent)
|
|
251
|
+
throw new Error('Lexical parent scope missing');
|
|
252
|
+
owner = parent;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
for (const name of patternNames(node.childForFieldName('left')))
|
|
256
|
+
addBinding(owner, name, name.text, 'local');
|
|
257
|
+
}
|
|
258
|
+
for (const child of node.namedChildren)
|
|
259
|
+
walk(child, inner);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (node.type === 'statement_block') {
|
|
263
|
+
const isFunctionBody = node.parent &&
|
|
264
|
+
FUNCTIONS.has(node.parent.type) &&
|
|
265
|
+
node.parent.childForFieldName('body')?.id === node.id;
|
|
266
|
+
const inner = isFunctionBody ? scope : childScope(node, scope, 'block');
|
|
267
|
+
for (const child of node.namedChildren)
|
|
268
|
+
walk(child, inner);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (node.type === 'catch_clause') {
|
|
272
|
+
const inner = childScope(node, scope, 'catch');
|
|
273
|
+
for (const name of patternNames(node.childForFieldName('parameter')))
|
|
274
|
+
addBinding(inner, name, name.text, 'catch');
|
|
275
|
+
for (const child of node.namedChildren)
|
|
276
|
+
walk(child, inner);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (node.type === 'variable_declarator') {
|
|
280
|
+
const value = node.childForFieldName('value');
|
|
281
|
+
const pattern = node.childForFieldName('name');
|
|
282
|
+
if (!(pattern?.type === 'identifier' &&
|
|
283
|
+
value &&
|
|
284
|
+
(FUNCTIONS.has(value.type) || CLASSES.has(value.type)))) {
|
|
285
|
+
const owner = variableOwner(node, scope);
|
|
286
|
+
for (const name of patternNames(pattern))
|
|
287
|
+
addBinding(owner, name, name.text, 'local');
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for (const child of node.namedChildren)
|
|
291
|
+
walk(child, scope);
|
|
292
|
+
}
|
|
293
|
+
for (const child of root.namedChildren)
|
|
294
|
+
walk(child, moduleScope);
|
|
295
|
+
function scopeAt(offset) {
|
|
296
|
+
let selected = moduleScope;
|
|
297
|
+
for (const scope of scopes)
|
|
298
|
+
if (offset >= scope.span.startIndex &&
|
|
299
|
+
offset < scope.span.endIndex &&
|
|
300
|
+
scope.span.endIndex - scope.span.startIndex <=
|
|
301
|
+
selected.span.endIndex - selected.span.startIndex)
|
|
302
|
+
selected = scope;
|
|
303
|
+
return selected;
|
|
304
|
+
}
|
|
305
|
+
function resolve(name, offset) {
|
|
306
|
+
let scope = scopeAt(offset);
|
|
307
|
+
while (scope) {
|
|
308
|
+
const found = scopedBindings.get(scope.id)?.get(name);
|
|
309
|
+
if (found?.length) {
|
|
310
|
+
if (found.length > 1)
|
|
311
|
+
return {
|
|
312
|
+
kind: 'ambiguous',
|
|
313
|
+
bindings: found,
|
|
314
|
+
reason: 'Multiple bindings in the nearest lexical scope',
|
|
315
|
+
};
|
|
316
|
+
const binding = found[0];
|
|
317
|
+
if (binding.typeOnly)
|
|
318
|
+
return {
|
|
319
|
+
kind: 'shadowed',
|
|
320
|
+
bindings: found,
|
|
321
|
+
reason: 'Type-only binding cannot supply a runtime value',
|
|
322
|
+
};
|
|
323
|
+
if (binding.kind === 'import')
|
|
324
|
+
return {
|
|
325
|
+
kind: 'import',
|
|
326
|
+
bindings: found,
|
|
327
|
+
reason: 'Explicit lexical import requires source-module resolution',
|
|
328
|
+
};
|
|
329
|
+
if (binding.targetId)
|
|
330
|
+
return {
|
|
331
|
+
kind: 'resolved',
|
|
332
|
+
bindings: found,
|
|
333
|
+
reason: 'Lexical declaration establishes the callable or class identity',
|
|
334
|
+
};
|
|
335
|
+
return {
|
|
336
|
+
kind: 'shadowed',
|
|
337
|
+
bindings: found,
|
|
338
|
+
reason: `Nearest ${binding.kind} binding has no statically established callable target`,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
scope = scope.parentId ? byId.get(scope.parentId) : undefined;
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
kind: 'unbound',
|
|
345
|
+
bindings: [],
|
|
346
|
+
reason: 'No lexical or imported binding; global names are candidates only',
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
return {
|
|
350
|
+
language,
|
|
351
|
+
generation,
|
|
352
|
+
publicationGeneration,
|
|
353
|
+
scopes,
|
|
354
|
+
bindings,
|
|
355
|
+
declarations,
|
|
356
|
+
spanOf: span,
|
|
357
|
+
scopeAt,
|
|
358
|
+
resolve,
|
|
359
|
+
ownerAt: (offset) => scopeAt(offset).ownerId,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
//# sourceMappingURL=lexical-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical-scope.js","sourceRoot":"","sources":["../../../src/pipeline/lexical-scope.ts"],"names":[],"mappings":"AAiDA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,sBAAsB;IACtB,gCAAgC;IAChC,qBAAqB;IACrB,oBAAoB;IACpB,gBAAgB;IAChB,mBAAm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module pipeline/parse-loop
|
|
33
33
|
*/
|
|
34
|
-
import {
|
|
34
|
+
import type { GraphIndexFileReport, GraphNode, ParserExecutionLimits, ParserExecutionPort } from '@cleocode/contracts';
|
|
35
|
+
import { type ExtractedCall, type ExtractedHeritage, type ExtractedReExport } from './extractors/typescript-extractor.js';
|
|
35
36
|
import type { ScannedFile } from './filesystem-walker.js';
|
|
36
|
-
import type { BarrelExportMap, ImportResolutionContext, NamedImportMap, TsconfigPaths } from './import-processor.js';
|
|
37
|
+
import type { BarrelExportMap, ExtractedImport, ImportResolutionContext, NamedImportMap, TsconfigPaths } from './import-processor.js';
|
|
37
38
|
import type { KnowledgeGraph } from './knowledge-graph.js';
|
|
38
39
|
import { type ExtractedAccess } from './processors/access-processor.js';
|
|
39
40
|
import type { SymbolTable } from './symbol-table.js';
|
|
41
|
+
/**
|
|
42
|
+
* Common extraction result shape shared across all language extractors.
|
|
43
|
+
* Each extractor returns this interface so the parse loop can handle them uniformly.
|
|
44
|
+
*
|
|
45
|
+
* `reExports` is optional: only TypeScript/JavaScript extractors produce re-export
|
|
46
|
+
* records. Python, Go, and Rust extractors omit this field.
|
|
47
|
+
*
|
|
48
|
+
* `accesses` is populated by the access-processor after the language extractor
|
|
49
|
+
* runs. It is optional here so existing extractors need not be modified.
|
|
50
|
+
*/
|
|
51
|
+
export interface CommonExtractionResult {
|
|
52
|
+
/** Original declarations and qualified graph identities. */
|
|
53
|
+
definitions: GraphNode[];
|
|
54
|
+
/** Imported bindings and source paths. */
|
|
55
|
+
imports: ExtractedImport[];
|
|
56
|
+
/** Type inheritance evidence. */
|
|
57
|
+
heritage: ExtractedHeritage[];
|
|
58
|
+
/** Static call evidence with unresolved references retained. */
|
|
59
|
+
calls: ExtractedCall[];
|
|
60
|
+
/** Optional barrel re-export bindings. */
|
|
61
|
+
reExports?: ExtractedReExport[];
|
|
62
|
+
/** Optional property access evidence. */
|
|
63
|
+
accesses?: ExtractedAccess[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract a file through the same native parser and language capabilities in either realm.
|
|
67
|
+
* @param source - Original Unicode source text.
|
|
68
|
+
* @param filePath - Repository-relative source path used for symbol identities.
|
|
69
|
+
* @param limits - Native source-byte and synchronous parsing deadline limits.
|
|
70
|
+
* @param publicationGeneration - Optional immutable publication identity passed by the pipeline.
|
|
71
|
+
* @returns Declarations, references, imports, heritage and access evidence.
|
|
72
|
+
* @remarks Static extraction does not establish complete runtime-call discovery.
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const extracted = extractOriginalSource('export const 文 = 1;', 'source.ts');
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function extractOriginalSource(source: string, filePath: string, limits?: ParserExecutionLimits, publicationGeneration?: string): CommonExtractionResult;
|
|
40
79
|
/** Options for the sequential parse loop. */
|
|
41
80
|
export interface ParseLoopOptions {
|
|
81
|
+
/** Immutable graph publication identity shared by direct and worker extraction. */
|
|
82
|
+
publicationGeneration?: string;
|
|
83
|
+
/** Per-file native source/deadline limits and caller cancellation. */
|
|
84
|
+
parserLimits?: ParserExecutionLimits;
|
|
85
|
+
/** Existing runtime process containment; Nexus never imports core. */
|
|
86
|
+
parserExecution?: ParserExecutionPort;
|
|
87
|
+
/** Report extraction availability and failures for trustworthy graph publication. */
|
|
88
|
+
onFileReport?: (report: GraphIndexFileReport) => void;
|
|
42
89
|
/** Optional tsconfig path aliases for import resolution. */
|
|
43
90
|
tsconfigPaths?: TsconfigPaths | null;
|
|
44
91
|
/** Named import map to populate (for Tier 2a resolution in later waves). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-loop.d.ts","sourceRoot":"","sources":["../../../src/pipeline/parse-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"parse-loop.d.ts","sourceRoot":"","sources":["../../../src/pipeline/parse-loop.ts"],"names":[],"mapp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