gitnexus 1.6.6-rc.2 → 1.6.6-rc.21
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/_shared/index.d.ts +1 -1
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts +8 -0
- package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.d.ts +18 -1
- package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/lookup-core.d.ts +4 -2
- package/dist/_shared/scope-resolution/registries/lookup-core.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/lookup-core.js +8 -23
- package/dist/_shared/scope-resolution/registries/lookup-core.js.map +1 -1
- package/dist/cli/analyze.js +65 -3
- package/dist/cli/eval-server.d.ts +14 -3
- package/dist/cli/eval-server.js +79 -9
- package/dist/cli/index.js +3 -1
- package/dist/cli/serve.js +6 -1
- package/dist/cli/setup.js +6 -4
- package/dist/cli/wiki.d.ts +1 -0
- package/dist/cli/wiki.js +32 -8
- package/dist/core/ingestion/languages/cpp/captures.js +165 -9
- package/dist/core/ingestion/languages/cpp/constraint-filter.js +102 -32
- package/dist/core/ingestion/languages/cpp/type-classifier.d.ts +9 -9
- package/dist/core/ingestion/languages/cpp/type-classifier.js +12 -8
- package/dist/core/ingestion/languages/java.js +35 -0
- package/dist/core/ingestion/languages/javascript/arity.d.ts +11 -0
- package/dist/core/ingestion/languages/javascript/arity.js +11 -0
- package/dist/core/ingestion/languages/javascript/captures.d.ts +30 -0
- package/dist/core/ingestion/languages/javascript/captures.js +655 -0
- package/dist/core/ingestion/languages/javascript/import-target.d.ts +29 -0
- package/dist/core/ingestion/languages/javascript/import-target.js +53 -0
- package/dist/core/ingestion/languages/javascript/index.d.ts +48 -0
- package/dist/core/ingestion/languages/javascript/index.js +48 -0
- package/dist/core/ingestion/languages/javascript/interpret.d.ts +29 -0
- package/dist/core/ingestion/languages/javascript/interpret.js +41 -0
- package/dist/core/ingestion/languages/javascript/merge-bindings.d.ts +16 -0
- package/dist/core/ingestion/languages/javascript/merge-bindings.js +18 -0
- package/dist/core/ingestion/languages/javascript/query.d.ts +52 -0
- package/dist/core/ingestion/languages/javascript/query.js +413 -0
- package/dist/core/ingestion/languages/javascript/scope-resolver.d.ts +37 -0
- package/dist/core/ingestion/languages/javascript/scope-resolver.js +73 -0
- package/dist/core/ingestion/languages/javascript/simple-hooks.d.ts +32 -0
- package/dist/core/ingestion/languages/javascript/simple-hooks.js +37 -0
- package/dist/core/ingestion/languages/typescript/simple-hooks.d.ts +10 -0
- package/dist/core/ingestion/languages/typescript/simple-hooks.js +4 -1
- package/dist/core/ingestion/languages/typescript.js +15 -0
- package/dist/core/ingestion/model/field-registry.d.ts +17 -3
- package/dist/core/ingestion/model/field-registry.js +19 -4
- package/dist/core/ingestion/model/owned-members-lookup.d.ts +19 -0
- package/dist/core/ingestion/model/owned-members-lookup.js +43 -0
- package/dist/core/ingestion/model/type-registry.d.ts +9 -0
- package/dist/core/ingestion/model/type-registry.js +18 -0
- package/dist/core/ingestion/registry-primary-flag.js +1 -0
- package/dist/core/ingestion/resolve-references.d.ts +3 -1
- package/dist/core/ingestion/resolve-references.js +5 -1
- package/dist/core/ingestion/scope-extractor.js +4 -0
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +1 -0
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +37 -7
- package/dist/core/ingestion/scope-resolution/passes/overload-narrowing.d.ts +2 -0
- package/dist/core/ingestion/scope-resolution/passes/overload-narrowing.js +8 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +2 -0
- package/dist/core/ingestion/scope-resolution/pipeline/reconcile-ownership.d.ts +4 -2
- package/dist/core/ingestion/scope-resolution/pipeline/reconcile-ownership.js +48 -9
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +2 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +2 -0
- package/dist/core/lbug/lbug-adapter.d.ts +3 -1
- package/dist/core/lbug/lbug-adapter.js +33 -19
- package/dist/core/lbug/lbug-config.d.ts +1 -1
- package/dist/core/lbug/lbug-config.js +1 -1
- package/dist/core/lbug/pool-adapter.d.ts +19 -7
- package/dist/core/lbug/pool-adapter.js +70 -44
- package/dist/core/lbug/query-params.d.ts +1 -0
- package/dist/core/lbug/query-params.js +21 -0
- package/dist/core/search/bm25-index.js +4 -6
- package/dist/core/wiki/generator.d.ts +13 -0
- package/dist/core/wiki/generator.js +45 -4
- package/dist/core/wiki/llm-client.d.ts +1 -1
- package/dist/core/wiki/llm-client.js +23 -6
- package/dist/mcp/local/local-backend.d.ts +18 -3
- package/dist/mcp/local/local-backend.js +127 -11
- package/dist/mcp/tools.js +10 -0
- package/dist/server/api.d.ts +3 -0
- package/dist/server/api.js +58 -30
- package/package.json +3 -3
- package/web/assets/agent-SmDhIVj9.js +608 -0
- package/web/assets/{architectureDiagram-UL44E2DR-DvIkEGkp.js → architectureDiagram-UL44E2DR-ChS6kfgC.js} +1 -1
- package/web/assets/{chunk-LCXTWHL2-CqJ0oo1x.js → chunk-LCXTWHL2-CikfiTEP.js} +1 -1
- package/web/assets/{chunk-RG4AUYOV-D0M6vdq9.js → chunk-RG4AUYOV-D0pH0sP0.js} +1 -1
- package/web/assets/{classDiagram-KGZ6W3CR-BB-saqC1.js → classDiagram-KGZ6W3CR-VJjLBrQ3.js} +1 -1
- package/web/assets/{classDiagram-v2-72OJOZXJ-Bp2bAlS5.js → classDiagram-v2-72OJOZXJ-CL_v399n.js} +1 -1
- package/web/assets/{diagram-3NCE3AQN-BUxnDPOY.js → diagram-3NCE3AQN-DTTuOnDj.js} +1 -1
- package/web/assets/{diagram-GF46GFSD-BJTyqqvI.js → diagram-GF46GFSD-Di3e_png.js} +1 -1
- package/web/assets/{diagram-QXG6HAR7-DilMHamP.js → diagram-QXG6HAR7-CVQY1hhk.js} +1 -1
- package/web/assets/{diagram-WEQXMOUZ-8KUrarg1.js → diagram-WEQXMOUZ-BoxS7CN3.js} +1 -1
- package/web/assets/{erDiagram-L5TCEMPS-Doj9mSiW.js → erDiagram-L5TCEMPS-CLTuHusW.js} +1 -1
- package/web/assets/{flowDiagram-H6V6AXG4-BOSR-i3p.js → flowDiagram-H6V6AXG4-CQfVb2C4.js} +1 -1
- package/web/assets/{index-j4-NuleT.js → index-BuC2I_Cj.js} +5 -5
- package/web/assets/{infoDiagram-3YFTVSEB-Ce_TvtaV.js → infoDiagram-3YFTVSEB-BOk6LlXV.js} +1 -1
- package/web/assets/{ishikawaDiagram-BNXS4ZKH-4MXIDCSF.js → ishikawaDiagram-BNXS4ZKH-C0sASGB6.js} +1 -1
- package/web/assets/{kanban-definition-75IXJCU3-yYdfm8Kk.js → kanban-definition-75IXJCU3-DT9Lizpz.js} +1 -1
- package/web/assets/{mindmap-definition-2TDM6QVE-DFNEKM77.js → mindmap-definition-2TDM6QVE-BEYaB7hb.js} +1 -1
- package/web/assets/{pieDiagram-CU6KROY3-iZAqpvhd.js → pieDiagram-CU6KROY3-DCgHNkyY.js} +1 -1
- package/web/assets/{requirementDiagram-JXO7QTGE-CtDijhnf.js → requirementDiagram-JXO7QTGE-D6vDU9M2.js} +1 -1
- package/web/assets/{sequenceDiagram-VS2MUI6T-BdjvyCHM.js → sequenceDiagram-VS2MUI6T-CJrGCTXy.js} +1 -1
- package/web/assets/{stateDiagram-7D4R322I-e5odN9fG.js → stateDiagram-7D4R322I-BvxQnQyL.js} +1 -1
- package/web/assets/{stateDiagram-v2-36443NZ5-vPsvjR2D.js → stateDiagram-v2-36443NZ5-D8ziO9W2.js} +1 -1
- package/web/assets/{timeline-definition-O6YCAMPW-DPAksNQp.js → timeline-definition-O6YCAMPW-B45j2q3m.js} +1 -1
- package/web/assets/{vennDiagram-MWXL3ELB-Dtlfdt7J.js → vennDiagram-MWXL3ELB-CRkZRDhi.js} +1 -1
- package/web/assets/{wardleyDiagram-CUQ6CDDI-B23uRMUC.js → wardleyDiagram-CUQ6CDDI-BekUytZJ.js} +1 -1
- package/web/assets/{xychartDiagram-N2JHSOCM-DxwHeksW.js → xychartDiagram-N2JHSOCM-BeMqwSgr.js} +1 -1
- package/web/index.html +1 -1
- package/web/assets/agent-D2kLt6Dl.js +0 -597
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import-target resolver for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* Delegates to the TypeScript `resolveTsTarget` standard-strategy resolver
|
|
5
|
+
* with `language: SupportedLanguages.JavaScript` so the resolver tries
|
|
6
|
+
* `.js` / `.jsx` extensions in addition to (or instead of) `.ts` / `.tsx`.
|
|
7
|
+
*
|
|
8
|
+
* The `TsResolveContext.language` flag already exists in `import-target.ts`
|
|
9
|
+
* and the resolver (`resolveImportPath`) already branches on it — this
|
|
10
|
+
* adapter just wires the right value in.
|
|
11
|
+
*
|
|
12
|
+
* CJS `require()` calls reference the same module-path strings as ESM
|
|
13
|
+
* `import` statements, so the resolver handles them uniformly without any
|
|
14
|
+
* CJS-specific logic here.
|
|
15
|
+
*
|
|
16
|
+
* No `tsconfig.json` path-alias support (JavaScript projects don't use
|
|
17
|
+
* `tsconfig.json` compilerOptions.paths in general). Projects that DO use
|
|
18
|
+
* tsconfig-based aliases alongside JavaScript can still resolve via the
|
|
19
|
+
* standard extension-suffix fallback; the alias branch is a no-op when
|
|
20
|
+
* `tsconfigPaths` is null.
|
|
21
|
+
*/
|
|
22
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
23
|
+
import { resolveTsTarget } from '../typescript/import-target.js';
|
|
24
|
+
/**
|
|
25
|
+
* Build a memoized `resolveImportTarget` adapter for JavaScript.
|
|
26
|
+
* Caches the derived arrays and per-pass resolve cache across
|
|
27
|
+
* `resolveImportTarget` calls within a single workspace pass.
|
|
28
|
+
*/
|
|
29
|
+
export function makeJsResolveImportTarget() {
|
|
30
|
+
let cached = null;
|
|
31
|
+
return (targetRaw, fromFile, allFilePaths) => {
|
|
32
|
+
if (cached === null || cached.key !== allFilePaths) {
|
|
33
|
+
const allFileList = Array.from(allFilePaths);
|
|
34
|
+
cached = {
|
|
35
|
+
key: allFilePaths,
|
|
36
|
+
allFilePaths: new Set(allFilePaths),
|
|
37
|
+
allFileList,
|
|
38
|
+
normalizedFileList: allFileList.map((f) => f.toLowerCase()),
|
|
39
|
+
resolveCache: new Map(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const ws = {
|
|
43
|
+
fromFile,
|
|
44
|
+
language: SupportedLanguages.JavaScript,
|
|
45
|
+
allFilePaths: cached.allFilePaths,
|
|
46
|
+
allFileList: cached.allFileList,
|
|
47
|
+
normalizedFileList: cached.normalizedFileList,
|
|
48
|
+
resolveCache: cached.resolveCache,
|
|
49
|
+
tsconfigPaths: null,
|
|
50
|
+
};
|
|
51
|
+
return resolveTsTarget(targetRaw, ws);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JavaScript scope-resolution hooks (RFC #909 Ring 3, issue #928).
|
|
3
|
+
*
|
|
4
|
+
* Public API barrel. Consumers should import from this file rather
|
|
5
|
+
* than the individual modules.
|
|
6
|
+
*
|
|
7
|
+
* Module layout (each file is a single concern):
|
|
8
|
+
*
|
|
9
|
+
* - `query.ts` — JS scope query string + lazy parser/query
|
|
10
|
+
* singletons (`getJsParser`, `getJsScopeQuery`)
|
|
11
|
+
* - `captures.ts` — `emitJsScopeCaptures` — runs the JS scope query,
|
|
12
|
+
* synthesizes CJS require() imports and JSDoc-
|
|
13
|
+
* derived type bindings, delegates arity synthesis
|
|
14
|
+
* and destructuring/instanceof passes to shared
|
|
15
|
+
* or TypeScript utilities
|
|
16
|
+
* - `interpret.ts` — `interpretJsImport` / `interpretJsTypeBinding`
|
|
17
|
+
* (delegate to TypeScript interpreters — same
|
|
18
|
+
* capture-marker vocabulary)
|
|
19
|
+
* - `simple-hooks.ts` — `jsBindingScopeFor` (var hoisting),
|
|
20
|
+
* `jsImportOwningScope`, `jsReceiverBinding`
|
|
21
|
+
* (all delegate to TypeScript counterparts)
|
|
22
|
+
* - `merge-bindings.ts` — `jsMergeBindings` (LEGB via typescriptMergeBindings)
|
|
23
|
+
* - `arity.ts` — `jsArityCompatibility` (delegates to TS function)
|
|
24
|
+
* - `import-target.ts` — `makeJsResolveImportTarget` (memoized adapter)
|
|
25
|
+
* - `scope-resolver.ts` — `javascriptScopeResolver` wiring object
|
|
26
|
+
*
|
|
27
|
+
* ## Known limitations
|
|
28
|
+
*
|
|
29
|
+
* 1. **JSDoc coverage** — `@param {T} name`, `@returns {T}` / `@return {T}`,
|
|
30
|
+
* and `@type {T}` on variable declarations are synthesized. `@typedef`
|
|
31
|
+
* is not yet synthesized (tracked in #1646).
|
|
32
|
+
* 2. **CJS chained destructuring** — `const { X: { Y } } = require(...)`
|
|
33
|
+
* (nested destructuring) emits only the outer `X` binding; `Y` is not
|
|
34
|
+
* resolved.
|
|
35
|
+
* 3. **Dynamic require** — `require(computedPath)` is skipped (non-literal
|
|
36
|
+
* argument — cannot statically resolve the target).
|
|
37
|
+
* 4. **`module.exports` / `exports.X`** — CJS export forms are not yet
|
|
38
|
+
* modeled as re-exports. The finalize algorithm treats the exporting
|
|
39
|
+
* module as a namespace; importers that do `const X = require('./m')`
|
|
40
|
+
* bind the module namespace, and member-call resolution walks the
|
|
41
|
+
* class graph from there.
|
|
42
|
+
*/
|
|
43
|
+
export { emitJsScopeCaptures } from './captures.js';
|
|
44
|
+
export { interpretJsImport, interpretJsTypeBinding } from './interpret.js';
|
|
45
|
+
export { jsMergeBindings } from './merge-bindings.js';
|
|
46
|
+
export { jsArityCompatibility } from './arity.js';
|
|
47
|
+
export { makeJsResolveImportTarget } from './import-target.js';
|
|
48
|
+
export { jsBindingScopeFor, jsImportOwningScope, jsReceiverBinding } from './simple-hooks.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JavaScript scope-resolution hooks (RFC #909 Ring 3, issue #928).
|
|
3
|
+
*
|
|
4
|
+
* Public API barrel. Consumers should import from this file rather
|
|
5
|
+
* than the individual modules.
|
|
6
|
+
*
|
|
7
|
+
* Module layout (each file is a single concern):
|
|
8
|
+
*
|
|
9
|
+
* - `query.ts` — JS scope query string + lazy parser/query
|
|
10
|
+
* singletons (`getJsParser`, `getJsScopeQuery`)
|
|
11
|
+
* - `captures.ts` — `emitJsScopeCaptures` — runs the JS scope query,
|
|
12
|
+
* synthesizes CJS require() imports and JSDoc-
|
|
13
|
+
* derived type bindings, delegates arity synthesis
|
|
14
|
+
* and destructuring/instanceof passes to shared
|
|
15
|
+
* or TypeScript utilities
|
|
16
|
+
* - `interpret.ts` — `interpretJsImport` / `interpretJsTypeBinding`
|
|
17
|
+
* (delegate to TypeScript interpreters — same
|
|
18
|
+
* capture-marker vocabulary)
|
|
19
|
+
* - `simple-hooks.ts` — `jsBindingScopeFor` (var hoisting),
|
|
20
|
+
* `jsImportOwningScope`, `jsReceiverBinding`
|
|
21
|
+
* (all delegate to TypeScript counterparts)
|
|
22
|
+
* - `merge-bindings.ts` — `jsMergeBindings` (LEGB via typescriptMergeBindings)
|
|
23
|
+
* - `arity.ts` — `jsArityCompatibility` (delegates to TS function)
|
|
24
|
+
* - `import-target.ts` — `makeJsResolveImportTarget` (memoized adapter)
|
|
25
|
+
* - `scope-resolver.ts` — `javascriptScopeResolver` wiring object
|
|
26
|
+
*
|
|
27
|
+
* ## Known limitations
|
|
28
|
+
*
|
|
29
|
+
* 1. **JSDoc coverage** — `@param {T} name`, `@returns {T}` / `@return {T}`,
|
|
30
|
+
* and `@type {T}` on variable declarations are synthesized. `@typedef`
|
|
31
|
+
* is not yet synthesized (tracked in #1646).
|
|
32
|
+
* 2. **CJS chained destructuring** — `const { X: { Y } } = require(...)`
|
|
33
|
+
* (nested destructuring) emits only the outer `X` binding; `Y` is not
|
|
34
|
+
* resolved.
|
|
35
|
+
* 3. **Dynamic require** — `require(computedPath)` is skipped (non-literal
|
|
36
|
+
* argument — cannot statically resolve the target).
|
|
37
|
+
* 4. **`module.exports` / `exports.X`** — CJS export forms are not yet
|
|
38
|
+
* modeled as re-exports. The finalize algorithm treats the exporting
|
|
39
|
+
* module as a namespace; importers that do `const X = require('./m')`
|
|
40
|
+
* bind the module namespace, and member-call resolution walks the
|
|
41
|
+
* class graph from there.
|
|
42
|
+
*/
|
|
43
|
+
export { emitJsScopeCaptures } from './captures.js';
|
|
44
|
+
export { interpretJsImport, interpretJsTypeBinding } from './interpret.js';
|
|
45
|
+
export { jsMergeBindings } from './merge-bindings.js';
|
|
46
|
+
export { jsArityCompatibility } from './arity.js';
|
|
47
|
+
export { makeJsResolveImportTarget } from './import-target.js';
|
|
48
|
+
export { jsBindingScopeFor, jsImportOwningScope, jsReceiverBinding } from './simple-hooks.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture-match → semantic-shape interpreters for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* `interpretJsImport` delegates to `interpretTsImport` for all cases
|
|
5
|
+
* because `emitJsScopeCaptures` synthesizes the same
|
|
6
|
+
* `@import.kind/name/alias/source` markers for both ESM and CJS imports.
|
|
7
|
+
*
|
|
8
|
+
* The `@import.kind` values emitted for CJS by `captures.ts`:
|
|
9
|
+
*
|
|
10
|
+
* - `'named'` : `const { X } = require('./m')` → named import
|
|
11
|
+
* - `'named-alias'` : `const { X: Y } = require('./m')` → aliased import
|
|
12
|
+
* - `'namespace'` : `const X = require('./m')` → namespace import
|
|
13
|
+
* - `'side-effect'` : `require('./m')` bare expression → side-effect
|
|
14
|
+
*
|
|
15
|
+
* These match the kinds `interpretTsImport` already handles for ESM
|
|
16
|
+
* (`import { X }`, `import { X as Y }`, `import * as X`, `import './m'`),
|
|
17
|
+
* so no new branch is needed here.
|
|
18
|
+
*
|
|
19
|
+
* `interpretJsTypeBinding` handles the JS-only `@type-binding.class-field`
|
|
20
|
+
* tag before delegating to `interpretTsTypeBinding`. The class-field tag
|
|
21
|
+
* is emitted by `synthesizeConstructorFieldBindings` and should produce
|
|
22
|
+
* `source = 'annotation'` — the same strength as an explicit type
|
|
23
|
+
* annotation. Remapping it to `@type-binding.annotation` achieves this
|
|
24
|
+
* without adding a JS-specific branch to the shared TS interpreter
|
|
25
|
+
* (DoD.md §2.2).
|
|
26
|
+
*/
|
|
27
|
+
import type { CaptureMatch, ParsedImport, ParsedTypeBinding } from '../../../../_shared/index.js';
|
|
28
|
+
export declare function interpretJsImport(captures: CaptureMatch): ParsedImport | null;
|
|
29
|
+
export declare function interpretJsTypeBinding(captures: CaptureMatch): ParsedTypeBinding | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture-match → semantic-shape interpreters for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* `interpretJsImport` delegates to `interpretTsImport` for all cases
|
|
5
|
+
* because `emitJsScopeCaptures` synthesizes the same
|
|
6
|
+
* `@import.kind/name/alias/source` markers for both ESM and CJS imports.
|
|
7
|
+
*
|
|
8
|
+
* The `@import.kind` values emitted for CJS by `captures.ts`:
|
|
9
|
+
*
|
|
10
|
+
* - `'named'` : `const { X } = require('./m')` → named import
|
|
11
|
+
* - `'named-alias'` : `const { X: Y } = require('./m')` → aliased import
|
|
12
|
+
* - `'namespace'` : `const X = require('./m')` → namespace import
|
|
13
|
+
* - `'side-effect'` : `require('./m')` bare expression → side-effect
|
|
14
|
+
*
|
|
15
|
+
* These match the kinds `interpretTsImport` already handles for ESM
|
|
16
|
+
* (`import { X }`, `import { X as Y }`, `import * as X`, `import './m'`),
|
|
17
|
+
* so no new branch is needed here.
|
|
18
|
+
*
|
|
19
|
+
* `interpretJsTypeBinding` handles the JS-only `@type-binding.class-field`
|
|
20
|
+
* tag before delegating to `interpretTsTypeBinding`. The class-field tag
|
|
21
|
+
* is emitted by `synthesizeConstructorFieldBindings` and should produce
|
|
22
|
+
* `source = 'annotation'` — the same strength as an explicit type
|
|
23
|
+
* annotation. Remapping it to `@type-binding.annotation` achieves this
|
|
24
|
+
* without adding a JS-specific branch to the shared TS interpreter
|
|
25
|
+
* (DoD.md §2.2).
|
|
26
|
+
*/
|
|
27
|
+
import { interpretTsImport, interpretTsTypeBinding } from '../typescript/interpret.js';
|
|
28
|
+
export function interpretJsImport(captures) {
|
|
29
|
+
return interpretTsImport(captures);
|
|
30
|
+
}
|
|
31
|
+
export function interpretJsTypeBinding(captures) {
|
|
32
|
+
// @type-binding.class-field is a JS-only tag emitted by
|
|
33
|
+
// synthesizeConstructorFieldBindings. Remap it to the standard
|
|
34
|
+
// @type-binding.annotation tag so interpretTsTypeBinding assigns
|
|
35
|
+
// source = 'annotation' without a JS-specific branch in shared code.
|
|
36
|
+
if (captures['@type-binding.class-field'] !== undefined) {
|
|
37
|
+
const { '@type-binding.class-field': classField, ...rest } = captures;
|
|
38
|
+
return interpretTsTypeBinding({ ...rest, '@type-binding.annotation': classField });
|
|
39
|
+
}
|
|
40
|
+
return interpretTsTypeBinding(captures);
|
|
41
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding-merge precedence for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* JavaScript has no TypeScript declaration-merging (no `interface + class`
|
|
5
|
+
* coexisting in the same scope, no `namespace + class` dual-space declarations).
|
|
6
|
+
* However, `typescriptMergeBindings` handles these by falling back to
|
|
7
|
+
* `['value']` for any `NodeLabel` not explicitly mapped to multiple spaces —
|
|
8
|
+
* which is what every JavaScript declaration produces. The result is pure
|
|
9
|
+
* LEGB precedence without any cross-space logic, which is exactly what
|
|
10
|
+
* JavaScript needs.
|
|
11
|
+
*
|
|
12
|
+
* Reuse rather than reimplementing to keep the single source of truth for
|
|
13
|
+
* the tier (local 0 / import-namespace-reexport 1 / wildcard 2) ordering.
|
|
14
|
+
*/
|
|
15
|
+
import type { BindingRef } from '../../../../_shared/index.js';
|
|
16
|
+
export declare function jsMergeBindings(bindings: readonly BindingRef[]): readonly BindingRef[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding-merge precedence for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* JavaScript has no TypeScript declaration-merging (no `interface + class`
|
|
5
|
+
* coexisting in the same scope, no `namespace + class` dual-space declarations).
|
|
6
|
+
* However, `typescriptMergeBindings` handles these by falling back to
|
|
7
|
+
* `['value']` for any `NodeLabel` not explicitly mapped to multiple spaces —
|
|
8
|
+
* which is what every JavaScript declaration produces. The result is pure
|
|
9
|
+
* LEGB precedence without any cross-space logic, which is exactly what
|
|
10
|
+
* JavaScript needs.
|
|
11
|
+
*
|
|
12
|
+
* Reuse rather than reimplementing to keep the single source of truth for
|
|
13
|
+
* the tier (local 0 / import-namespace-reexport 1 / wildcard 2) ordering.
|
|
14
|
+
*/
|
|
15
|
+
import { typescriptMergeBindings } from '../typescript/merge-bindings.js';
|
|
16
|
+
export function jsMergeBindings(bindings) {
|
|
17
|
+
return typescriptMergeBindings(bindings);
|
|
18
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter query for JavaScript scope captures (RFC §5.1, Ring 3).
|
|
3
|
+
*
|
|
4
|
+
* Subset of the TypeScript scope query (`languages/typescript/query.ts`)
|
|
5
|
+
* compiled against `tree-sitter-javascript`. TypeScript-only node types
|
|
6
|
+
* (`interface_declaration`, `type_alias_declaration`, `enum_declaration`,
|
|
7
|
+
* `internal_module`, `abstract_class_declaration`, `function_signature`,
|
|
8
|
+
* `method_signature`, `abstract_method_signature`, `type_annotation`,
|
|
9
|
+
* `public_field_definition`) are dropped because:
|
|
10
|
+
*
|
|
11
|
+
* 1. The JS grammar doesn't define them — the query compiler would
|
|
12
|
+
* throw `InvalidNodeType` if they were included.
|
|
13
|
+
* 2. JavaScript has no static type annotations, so the `@type-binding.*`
|
|
14
|
+
* patterns derived from TS annotation nodes don't apply.
|
|
15
|
+
*
|
|
16
|
+
* What IS shared with the TypeScript query:
|
|
17
|
+
*
|
|
18
|
+
* - Scope patterns: `program`, `class_declaration`, `(class)` (the JS
|
|
19
|
+
* grammar node for class expressions — NOT `class_expression`, which
|
|
20
|
+
* does not exist in `tree-sitter-javascript`), `function_declaration`,
|
|
21
|
+
* `generator_function_declaration`, `function_expression`,
|
|
22
|
+
* `arrow_function`, `method_definition`.
|
|
23
|
+
* - Declaration patterns for functions, classes, const/let/var,
|
|
24
|
+
* object-property arrows (Zustand, TanStack, etc.), and HOC-wrapped
|
|
25
|
+
* variable declarations (forwardRef / memo / useCallback / useMemo).
|
|
26
|
+
* - Import patterns: `import_statement`, `export_statement` re-exports,
|
|
27
|
+
* and dynamic `import()` (represented as `call_expression(import)` in
|
|
28
|
+
* both grammars — the `import` leaf node exists in tree-sitter-javascript
|
|
29
|
+
* as well as tree-sitter-typescript).
|
|
30
|
+
* - Type-binding patterns that work without static annotations:
|
|
31
|
+
* constructor inference (`new User()`), call-result alias
|
|
32
|
+
* (`const u = getUser()`), member-access alias (`const a = u.addr`),
|
|
33
|
+
* identifier alias, assignment rebind, and for-of element bindings.
|
|
34
|
+
* JSDoc-derived type bindings (`@param {User} u`, `@returns {User}`)
|
|
35
|
+
* are handled separately in `captures.ts` via comment-node scanning.
|
|
36
|
+
* - Reference patterns: free calls, member calls, constructor calls,
|
|
37
|
+
* write-access, read-access, and dynamic import.
|
|
38
|
+
*
|
|
39
|
+
* CJS `require()` is NOT captured here; it is handled in `captures.ts`
|
|
40
|
+
* by scanning parent context (destructured vs. namespace) of `call_expression`
|
|
41
|
+
* nodes whose callee is the identifier `require`.
|
|
42
|
+
*
|
|
43
|
+
* Grammar version: `tree-sitter-javascript` pinned in gitnexus/package.json.
|
|
44
|
+
*
|
|
45
|
+
* Exposes lazy `Parser` and `Query` singletons so callers don't pay
|
|
46
|
+
* tree-sitter init cost per file.
|
|
47
|
+
*/
|
|
48
|
+
import Parser from 'tree-sitter';
|
|
49
|
+
export declare function getJsParser(filePath?: string): Parser;
|
|
50
|
+
export declare function getJsScopeQuery(filePath?: string): Parser.Query;
|
|
51
|
+
/** Validate that a cached Tree was produced by the JS grammar. */
|
|
52
|
+
export declare function jsCachedTreeMatchesGrammar(tree: unknown): boolean;
|