gitnexus 1.6.2 → 1.6.3-rc.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.
Files changed (117) hide show
  1. package/dist/_shared/index.d.ts +45 -0
  2. package/dist/_shared/index.d.ts.map +1 -1
  3. package/dist/_shared/index.js +33 -0
  4. package/dist/_shared/index.js.map +1 -1
  5. package/dist/_shared/scope-resolution/def-index.d.ts +36 -0
  6. package/dist/_shared/scope-resolution/def-index.d.ts.map +1 -0
  7. package/dist/_shared/scope-resolution/def-index.js +51 -0
  8. package/dist/_shared/scope-resolution/def-index.js.map +1 -0
  9. package/dist/_shared/scope-resolution/evidence-weights.d.ts +69 -0
  10. package/dist/_shared/scope-resolution/evidence-weights.d.ts.map +1 -0
  11. package/dist/_shared/scope-resolution/evidence-weights.js +84 -0
  12. package/dist/_shared/scope-resolution/evidence-weights.js.map +1 -0
  13. package/dist/_shared/scope-resolution/finalize-algorithm.d.ts +139 -0
  14. package/dist/_shared/scope-resolution/finalize-algorithm.d.ts.map +1 -0
  15. package/dist/_shared/scope-resolution/finalize-algorithm.js +479 -0
  16. package/dist/_shared/scope-resolution/finalize-algorithm.js.map +1 -0
  17. package/dist/_shared/scope-resolution/language-classification.d.ts +26 -0
  18. package/dist/_shared/scope-resolution/language-classification.d.ts.map +1 -0
  19. package/dist/_shared/scope-resolution/language-classification.js +44 -0
  20. package/dist/_shared/scope-resolution/language-classification.js.map +1 -0
  21. package/dist/_shared/scope-resolution/method-dispatch-index.d.ts +80 -0
  22. package/dist/_shared/scope-resolution/method-dispatch-index.d.ts.map +1 -0
  23. package/dist/_shared/scope-resolution/method-dispatch-index.js +79 -0
  24. package/dist/_shared/scope-resolution/method-dispatch-index.js.map +1 -0
  25. package/dist/_shared/scope-resolution/module-scope-index.d.ts +46 -0
  26. package/dist/_shared/scope-resolution/module-scope-index.d.ts.map +1 -0
  27. package/dist/_shared/scope-resolution/module-scope-index.js +58 -0
  28. package/dist/_shared/scope-resolution/module-scope-index.js.map +1 -0
  29. package/dist/_shared/scope-resolution/origin-priority.d.ts +14 -0
  30. package/dist/_shared/scope-resolution/origin-priority.d.ts.map +1 -0
  31. package/dist/_shared/scope-resolution/origin-priority.js +21 -0
  32. package/dist/_shared/scope-resolution/origin-priority.js.map +1 -0
  33. package/dist/_shared/scope-resolution/position-index.d.ts +62 -0
  34. package/dist/_shared/scope-resolution/position-index.d.ts.map +1 -0
  35. package/dist/_shared/scope-resolution/position-index.js +134 -0
  36. package/dist/_shared/scope-resolution/position-index.js.map +1 -0
  37. package/dist/_shared/scope-resolution/qualified-name-index.d.ts +44 -0
  38. package/dist/_shared/scope-resolution/qualified-name-index.d.ts.map +1 -0
  39. package/dist/_shared/scope-resolution/qualified-name-index.js +75 -0
  40. package/dist/_shared/scope-resolution/qualified-name-index.js.map +1 -0
  41. package/dist/_shared/scope-resolution/registries/class-registry.d.ts +27 -0
  42. package/dist/_shared/scope-resolution/registries/class-registry.d.ts.map +1 -0
  43. package/dist/_shared/scope-resolution/registries/class-registry.js +30 -0
  44. package/dist/_shared/scope-resolution/registries/class-registry.js.map +1 -0
  45. package/dist/_shared/scope-resolution/registries/context.d.ts +69 -0
  46. package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -0
  47. package/dist/_shared/scope-resolution/registries/context.js +44 -0
  48. package/dist/_shared/scope-resolution/registries/context.js.map +1 -0
  49. package/dist/_shared/scope-resolution/registries/evidence.d.ts +56 -0
  50. package/dist/_shared/scope-resolution/registries/evidence.d.ts.map +1 -0
  51. package/dist/_shared/scope-resolution/registries/evidence.js +150 -0
  52. package/dist/_shared/scope-resolution/registries/evidence.js.map +1 -0
  53. package/dist/_shared/scope-resolution/registries/field-registry.d.ts +26 -0
  54. package/dist/_shared/scope-resolution/registries/field-registry.d.ts.map +1 -0
  55. package/dist/_shared/scope-resolution/registries/field-registry.js +31 -0
  56. package/dist/_shared/scope-resolution/registries/field-registry.js.map +1 -0
  57. package/dist/_shared/scope-resolution/registries/lookup-core.d.ts +81 -0
  58. package/dist/_shared/scope-resolution/registries/lookup-core.d.ts.map +1 -0
  59. package/dist/_shared/scope-resolution/registries/lookup-core.js +332 -0
  60. package/dist/_shared/scope-resolution/registries/lookup-core.js.map +1 -0
  61. package/dist/_shared/scope-resolution/registries/lookup-qualified.d.ts +33 -0
  62. package/dist/_shared/scope-resolution/registries/lookup-qualified.d.ts.map +1 -0
  63. package/dist/_shared/scope-resolution/registries/lookup-qualified.js +56 -0
  64. package/dist/_shared/scope-resolution/registries/lookup-qualified.js.map +1 -0
  65. package/dist/_shared/scope-resolution/registries/method-registry.d.ts +36 -0
  66. package/dist/_shared/scope-resolution/registries/method-registry.d.ts.map +1 -0
  67. package/dist/_shared/scope-resolution/registries/method-registry.js +32 -0
  68. package/dist/_shared/scope-resolution/registries/method-registry.js.map +1 -0
  69. package/dist/_shared/scope-resolution/registries/tie-breaks.d.ts +43 -0
  70. package/dist/_shared/scope-resolution/registries/tie-breaks.d.ts.map +1 -0
  71. package/dist/_shared/scope-resolution/registries/tie-breaks.js +60 -0
  72. package/dist/_shared/scope-resolution/registries/tie-breaks.js.map +1 -0
  73. package/dist/_shared/scope-resolution/resolve-type-ref.d.ts +53 -0
  74. package/dist/_shared/scope-resolution/resolve-type-ref.d.ts.map +1 -0
  75. package/dist/_shared/scope-resolution/resolve-type-ref.js +126 -0
  76. package/dist/_shared/scope-resolution/resolve-type-ref.js.map +1 -0
  77. package/dist/_shared/scope-resolution/scope-id.d.ts +43 -0
  78. package/dist/_shared/scope-resolution/scope-id.d.ts.map +1 -0
  79. package/dist/_shared/scope-resolution/scope-id.js +46 -0
  80. package/dist/_shared/scope-resolution/scope-id.js.map +1 -0
  81. package/dist/_shared/scope-resolution/scope-tree.d.ts +61 -0
  82. package/dist/_shared/scope-resolution/scope-tree.d.ts.map +1 -0
  83. package/dist/_shared/scope-resolution/scope-tree.js +186 -0
  84. package/dist/_shared/scope-resolution/scope-tree.js.map +1 -0
  85. package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +63 -0
  86. package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +1 -0
  87. package/dist/_shared/scope-resolution/shadow/aggregate.js +122 -0
  88. package/dist/_shared/scope-resolution/shadow/aggregate.js.map +1 -0
  89. package/dist/_shared/scope-resolution/shadow/diff.d.ts +59 -0
  90. package/dist/_shared/scope-resolution/shadow/diff.d.ts.map +1 -0
  91. package/dist/_shared/scope-resolution/shadow/diff.js +79 -0
  92. package/dist/_shared/scope-resolution/shadow/diff.js.map +1 -0
  93. package/dist/_shared/scope-resolution/symbol-definition.d.ts +34 -0
  94. package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -0
  95. package/dist/_shared/scope-resolution/symbol-definition.js +12 -0
  96. package/dist/_shared/scope-resolution/symbol-definition.js.map +1 -0
  97. package/dist/_shared/scope-resolution/types.d.ts +356 -0
  98. package/dist/_shared/scope-resolution/types.d.ts.map +1 -0
  99. package/dist/_shared/scope-resolution/types.js +17 -0
  100. package/dist/_shared/scope-resolution/types.js.map +1 -0
  101. package/dist/core/ingestion/call-processor.d.ts +2 -1
  102. package/dist/core/ingestion/language-provider.d.ts +172 -1
  103. package/dist/core/ingestion/model/field-registry.d.ts +1 -1
  104. package/dist/core/ingestion/model/index.d.ts +1 -1
  105. package/dist/core/ingestion/model/index.js +2 -0
  106. package/dist/core/ingestion/model/method-registry.d.ts +1 -1
  107. package/dist/core/ingestion/model/registration-table.d.ts +1 -2
  108. package/dist/core/ingestion/model/resolution-context.d.ts +1 -1
  109. package/dist/core/ingestion/model/resolve.d.ts +1 -1
  110. package/dist/core/ingestion/model/symbol-table.d.ts +1 -23
  111. package/dist/core/ingestion/model/type-registry.d.ts +1 -1
  112. package/dist/core/search/phase-timer.d.ts +72 -0
  113. package/dist/core/search/phase-timer.js +106 -0
  114. package/dist/mcp/local/local-backend.d.ts +48 -1
  115. package/dist/mcp/local/local-backend.js +345 -135
  116. package/dist/mcp/tools.js +19 -1
  117. package/package.json +1 -1
@@ -5,7 +5,7 @@
5
5
  * using only the SemanticModel registries and HeritageMap — NO dependency
6
6
  * on resolution-context.ts (circular dependency risk).
7
7
  */
8
- import type { SymbolDefinition } from './symbol-table.js';
8
+ import type { SymbolDefinition } from '../../../_shared/index.js';
9
9
  import type { SemanticModel } from './semantic-model.js';
10
10
  import type { HeritageMap } from './heritage-map.js';
11
11
  import type { MroStrategy } from '../../../_shared/index.js';
@@ -33,7 +33,7 @@
33
33
  * import from `./model/` here, you are going the wrong way — move the
34
34
  * logic up the dependency chain instead.
35
35
  */
36
- import type { NodeLabel } from '../../../_shared/index.js';
36
+ import type { NodeLabel, SymbolDefinition } from '../../../_shared/index.js';
37
37
  /**
38
38
  * Class-like NodeLabels — used for qualifiedName fallback inside
39
39
  * `SymbolTable.add()` and (via import into `model/registration-table.ts`)
@@ -89,28 +89,6 @@ export declare const FREE_CALLABLE_TYPES: ReadonlySet<NodeLabel>;
89
89
  * `filterCallableCandidates` / `countCallableCandidates`.
90
90
  */
91
91
  export declare const CALL_TARGET_TYPES: ReadonlySet<NodeLabel>;
92
- export interface SymbolDefinition {
93
- nodeId: string;
94
- filePath: string;
95
- type: NodeLabel;
96
- /** Canonical dot-separated qualified type name for class-like symbols
97
- * (e.g. `App.Models.User`). Falls back to the simple symbol name when no
98
- * package/namespace/module scope exists or no explicit qualified metadata is provided. */
99
- qualifiedName?: string;
100
- parameterCount?: number;
101
- /** Number of required (non-optional, non-default) parameters.
102
- * Enables range-based arity filtering: argCount >= requiredParameterCount && argCount <= parameterCount. */
103
- requiredParameterCount?: number;
104
- /** Per-parameter type names for overload disambiguation (e.g. ['int', 'String']).
105
- * Populated when parameter types are resolvable from AST (any typed language). */
106
- parameterTypes?: string[];
107
- /** Raw return type text extracted from AST (e.g. 'User', 'Promise<User>') */
108
- returnType?: string;
109
- /** Declared type for non-callable symbols — fields/properties (e.g. 'Address', 'List<User>') */
110
- declaredType?: string;
111
- /** Links Method/Constructor/Property to owning Class/Struct/Trait nodeId */
112
- ownerId?: string;
113
- }
114
92
  /**
115
93
  * Optional metadata accepted by {@link SymbolTable.add}. Kept as a separate
116
94
  * type alias so callers and wrappers can share the same shape.
@@ -5,7 +5,7 @@
5
5
  * Eagerly-populated indexes keyed by symbol name and qualified name.
6
6
  * Also includes a separate index for Rust Impl blocks.
7
7
  */
8
- import type { SymbolDefinition } from './symbol-table.js';
8
+ import type { SymbolDefinition } from '../../../_shared/index.js';
9
9
  export interface TypeRegistry {
10
10
  /**
11
11
  * Look up class-like definitions (Class, Struct, Interface, Enum, Record, Trait)
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Per-phase wall-clock timing for the search pipeline and similar
3
+ * multi-stage flows. Designed to be called from query() with minimal
4
+ * ceremony and negligible overhead (< 0.1 ms per phase recorded).
5
+ *
6
+ * ### Sequential usage
7
+ *
8
+ * ```ts
9
+ * const t = new PhaseTimer();
10
+ * t.start('bm25'); await bm25Search(...); t.stop();
11
+ * t.start('merge'); doMerge(); t.stop();
12
+ * const phases = t.summary(); // { bm25: 42, merge: 3 }
13
+ * ```
14
+ *
15
+ * ### Concurrent usage (Promise.all)
16
+ *
17
+ * `start`/`stop` assume a single active phase at a time, which is wrong
18
+ * for concurrent work inside `Promise.all` — the second `start` would
19
+ * auto-stop the first and only one of the two would get timed. Use
20
+ * {@link PhaseTimer.time} to wrap each concurrent promise instead:
21
+ *
22
+ * ```ts
23
+ * const [a, b] = await Promise.all([
24
+ * t.time('bm25', bm25Search(...)),
25
+ * t.time('vector', semanticSearch(...)),
26
+ * ]);
27
+ * ```
28
+ *
29
+ * ### Pre-measured durations
30
+ *
31
+ * ```ts
32
+ * t.mark('inherited', 12.5);
33
+ * ```
34
+ */
35
+ export declare class PhaseTimer {
36
+ private phases;
37
+ private current;
38
+ private t0;
39
+ /** Start a new phase. Implicitly stops the previous one, if any. */
40
+ start(phase: string): void;
41
+ /** Stop the current phase. No-op if no phase is active. */
42
+ stop(): void;
43
+ /**
44
+ * Record a pre-measured duration without touching the active phase.
45
+ * Use for concurrent operations inside `Promise.all` where
46
+ * `start`/`stop` would step on each other, or for durations imported
47
+ * from sub-systems. Additive across repeated calls with the same
48
+ * phase name. Ignores negative / non-finite inputs.
49
+ */
50
+ mark(phase: string, durationMs: number): void;
51
+ /**
52
+ * Wrap a promise with automatic timing. Records wall time via
53
+ * {@link PhaseTimer.mark} regardless of which other phases are
54
+ * active — safe to use inside `Promise.all`.
55
+ */
56
+ time<T>(phase: string, promise: Promise<T>): Promise<T>;
57
+ /**
58
+ * Snapshot of accumulated durations rounded to 0.1 ms. Stops the
59
+ * current phase if one is still running.
60
+ */
61
+ summary(): Record<string, number>;
62
+ /**
63
+ * Sum of every recorded phase duration.
64
+ *
65
+ * Note: for phases recorded via {@link PhaseTimer.time} or
66
+ * {@link PhaseTimer.mark} this is the *sum*, not the wall time —
67
+ * concurrent work overlaps and the sum can exceed the end-to-end
68
+ * wall time. Record wall time separately with `mark('wall', …)` if
69
+ * that distinction matters.
70
+ */
71
+ totalMs(): number;
72
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Per-phase wall-clock timing for the search pipeline and similar
3
+ * multi-stage flows. Designed to be called from query() with minimal
4
+ * ceremony and negligible overhead (< 0.1 ms per phase recorded).
5
+ *
6
+ * ### Sequential usage
7
+ *
8
+ * ```ts
9
+ * const t = new PhaseTimer();
10
+ * t.start('bm25'); await bm25Search(...); t.stop();
11
+ * t.start('merge'); doMerge(); t.stop();
12
+ * const phases = t.summary(); // { bm25: 42, merge: 3 }
13
+ * ```
14
+ *
15
+ * ### Concurrent usage (Promise.all)
16
+ *
17
+ * `start`/`stop` assume a single active phase at a time, which is wrong
18
+ * for concurrent work inside `Promise.all` — the second `start` would
19
+ * auto-stop the first and only one of the two would get timed. Use
20
+ * {@link PhaseTimer.time} to wrap each concurrent promise instead:
21
+ *
22
+ * ```ts
23
+ * const [a, b] = await Promise.all([
24
+ * t.time('bm25', bm25Search(...)),
25
+ * t.time('vector', semanticSearch(...)),
26
+ * ]);
27
+ * ```
28
+ *
29
+ * ### Pre-measured durations
30
+ *
31
+ * ```ts
32
+ * t.mark('inherited', 12.5);
33
+ * ```
34
+ */
35
+ export class PhaseTimer {
36
+ phases = new Map();
37
+ current = null;
38
+ t0 = 0;
39
+ /** Start a new phase. Implicitly stops the previous one, if any. */
40
+ start(phase) {
41
+ this.stop();
42
+ this.current = phase;
43
+ this.t0 = performance.now();
44
+ }
45
+ /** Stop the current phase. No-op if no phase is active. */
46
+ stop() {
47
+ if (this.current !== null) {
48
+ const elapsed = performance.now() - this.t0;
49
+ this.phases.set(this.current, (this.phases.get(this.current) ?? 0) + elapsed);
50
+ this.current = null;
51
+ }
52
+ }
53
+ /**
54
+ * Record a pre-measured duration without touching the active phase.
55
+ * Use for concurrent operations inside `Promise.all` where
56
+ * `start`/`stop` would step on each other, or for durations imported
57
+ * from sub-systems. Additive across repeated calls with the same
58
+ * phase name. Ignores negative / non-finite inputs.
59
+ */
60
+ mark(phase, durationMs) {
61
+ if (!Number.isFinite(durationMs) || durationMs < 0)
62
+ return;
63
+ this.phases.set(phase, (this.phases.get(phase) ?? 0) + durationMs);
64
+ }
65
+ /**
66
+ * Wrap a promise with automatic timing. Records wall time via
67
+ * {@link PhaseTimer.mark} regardless of which other phases are
68
+ * active — safe to use inside `Promise.all`.
69
+ */
70
+ async time(phase, promise) {
71
+ const t0 = performance.now();
72
+ try {
73
+ return await promise;
74
+ }
75
+ finally {
76
+ this.mark(phase, performance.now() - t0);
77
+ }
78
+ }
79
+ /**
80
+ * Snapshot of accumulated durations rounded to 0.1 ms. Stops the
81
+ * current phase if one is still running.
82
+ */
83
+ summary() {
84
+ this.stop();
85
+ const out = {};
86
+ for (const [k, v] of this.phases)
87
+ out[k] = Math.round(v * 10) / 10;
88
+ return out;
89
+ }
90
+ /**
91
+ * Sum of every recorded phase duration.
92
+ *
93
+ * Note: for phases recorded via {@link PhaseTimer.time} or
94
+ * {@link PhaseTimer.mark} this is the *sum*, not the wall time —
95
+ * concurrent work overlaps and the sum can exceed the end-to-end
96
+ * wall time. Record wall time separately with `mark('wall', …)` if
97
+ * that distinction matters.
98
+ */
99
+ totalMs() {
100
+ this.stop();
101
+ let t = 0;
102
+ for (const v of this.phases.values())
103
+ t += v;
104
+ return Math.round(t * 10) / 10;
105
+ }
106
+ }
@@ -150,9 +150,56 @@ export declare class LocalBackend {
150
150
  */
151
151
  private aggregateClusters;
152
152
  private overview;
153
+ /**
154
+ * Patch the `type` field on candidates whose `labels(n)[0]` projection
155
+ * came back empty — a known LadybugDB behaviour for several node types.
156
+ *
157
+ * Uses one scoped UNION query across the five priority labels rather
158
+ * than per-candidate round-trips, so cost is a single DB call regardless
159
+ * of how many candidates need enrichment. No-op when every candidate
160
+ * already has a non-empty type.
161
+ *
162
+ * Failures are swallowed: label enrichment is an optimisation for
163
+ * downstream scoring and #480 Class/Interface BFS seeding; if it fails
164
+ * the symbol still resolves, just without the kind-priority bonus.
165
+ */
166
+ private enrichCandidateLabels;
167
+ /**
168
+ * Score a symbol candidate for disambiguation ranking.
169
+ *
170
+ * Deterministic, no DB round-trip:
171
+ * - base 0.50
172
+ * - +0.40 when file_path hint matches (substring, case-insensitive)
173
+ * - +0.20 when kind hint exactly matches the candidate's kind
174
+ * - when no kind hint, a small priority bonus (Class > Interface >
175
+ * Function > Method > Constructor) to preserve the intuition that
176
+ * class-level names are usually what the user wanted.
177
+ *
178
+ * Capped at 1.0. Intentionally simple and inspectable — a future v2 can
179
+ * plug in BM25/embedding signals here without changing the surrounding
180
+ * resolver shape.
181
+ */
182
+ private scoreCandidate;
183
+ /**
184
+ * Shared symbol resolver used by `context` and `impact`.
185
+ *
186
+ * Returns one of:
187
+ * - `{ kind: 'ok', symbol, resolvedLabel }` — single confident match
188
+ * (either direct UID, only one candidate after filtering, Class/
189
+ * Constructor collapse, or a top-scoring candidate with a clear gap
190
+ * to the runner-up).
191
+ * - `{ kind: 'ambiguous', candidates }` — multiple viable matches,
192
+ * sorted by score desc. Each candidate carries a relevance score.
193
+ * - `{ kind: 'not_found' }` — no matches at all.
194
+ *
195
+ * Preserves the #480 Class/Constructor preference: when the only
196
+ * ambiguity is between a Class and its own Constructor (same name,
197
+ * same filePath), the Class wins silently.
198
+ */
199
+ private resolveSymbolCandidates;
153
200
  /**
154
201
  * Context tool — 360-degree symbol view with categorized refs.
155
- * Disambiguation when multiple symbols share a name.
202
+ * Disambiguation (ranked) when multiple symbols share a name.
156
203
  * UID-based direct lookup. No cluster in output.
157
204
  */
158
205
  private context;