gitnexus 1.6.2-rc.16 → 1.6.2-rc.18

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.
@@ -7,6 +7,9 @@ import { compilePatterns, runCompiledPatterns, unquoteLiteral, } from '../tree-s
7
7
  * - Express `router.get(...)` / `app.post(...)` providers
8
8
  * - `fetch(url)` / `fetch(url, { method: 'POST' })` consumers
9
9
  * - `axios.get(url)` / `axios.delete(url)` consumers
10
+ * - `axios({ method, url })` object-form consumers
11
+ * - jQuery `$.get(url)` / `$.post(url, ...)` shorthand consumers
12
+ * - jQuery `$.ajax({ url, method | type })` consumers
10
13
  *
11
14
  * Because the JavaScript and TypeScript tree-sitter grammars share
12
15
  * node type names for every construct we query, pattern sources are
@@ -86,6 +89,45 @@ const AXIOS_SPEC = {
86
89
  arguments: (arguments . [(string) (template_string)] @path))
87
90
  `,
88
91
  };
92
+ // ─── Consumer: jQuery shorthand $.get(url) / $.post(url, ...) ────────
93
+ // `$` is a valid JS identifier, so tree-sitter parses `$.get(...)` as a
94
+ // call_expression whose function is a member_expression on identifier `$`.
95
+ const JQUERY_SHORTHAND_SPEC = {
96
+ meta: {},
97
+ query: `
98
+ (call_expression
99
+ function: (member_expression
100
+ object: (identifier) @obj (#eq? @obj "$")
101
+ property: (property_identifier) @http_method (#match? @http_method "^(get|post)$"))
102
+ arguments: (arguments . [(string) (template_string)] @path))
103
+ `,
104
+ };
105
+ // ─── Consumer: jQuery $.ajax({ url, method|type }) ───────────────────
106
+ // The query captures the options object only; key/value pairs are read
107
+ // programmatically via `readStringProp` below, which tolerates any key
108
+ // order and accepts either `method:` or `type:` (jQuery supports both).
109
+ const JQUERY_AJAX_SPEC = {
110
+ meta: {},
111
+ query: `
112
+ (call_expression
113
+ function: (member_expression
114
+ object: (identifier) @obj (#eq? @obj "$")
115
+ property: (property_identifier) @fn (#eq? @fn "ajax"))
116
+ arguments: (arguments (object) @options))
117
+ `,
118
+ };
119
+ // ─── Consumer: axios({ method, url }) object form ────────────────────
120
+ // Distinct from AXIOS_SPEC above because the call target is an identifier
121
+ // (`axios`) rather than a member expression (`axios.get`). As with the
122
+ // jQuery ajax form, option keys are resolved programmatically.
123
+ const AXIOS_OBJECT_SPEC = {
124
+ meta: {},
125
+ query: `
126
+ (call_expression
127
+ function: (identifier) @fn (#eq? @fn "axios")
128
+ arguments: (arguments (object) @options))
129
+ `,
130
+ };
89
131
  function compileBundle(language, name) {
90
132
  const mk = (spec, suffix) => compilePatterns({
91
133
  name: `${name}-${suffix}`,
@@ -99,6 +141,9 @@ function compileBundle(language, name) {
99
141
  fetchNoOptions: mk(FETCH_NO_OPTIONS_SPEC, 'fetch-no-options'),
100
142
  fetchWithOptions: mk(FETCH_WITH_OPTIONS_SPEC, 'fetch-with-options'),
101
143
  axios: mk(AXIOS_SPEC, 'axios'),
144
+ jqueryShorthand: mk(JQUERY_SHORTHAND_SPEC, 'jquery-shorthand'),
145
+ jqueryAjax: mk(JQUERY_AJAX_SPEC, 'jquery-ajax'),
146
+ axiosObject: mk(AXIOS_OBJECT_SPEC, 'axios-object'),
102
147
  };
103
148
  }
104
149
  const JAVASCRIPT_BUNDLE = compileBundle(JavaScript, 'javascript-http');
@@ -130,6 +175,32 @@ function joinPath(prefix, sub) {
130
175
  return `/${cleanSub}`;
131
176
  return `/${cleanPrefix}/${cleanSub}`;
132
177
  }
178
+ /**
179
+ * Walk `pair` children of an `object` literal and return the unquoted
180
+ * string/template_string value for the first pair whose key matches one
181
+ * of `keyNames`. Returns null when no matching pair is present or the
182
+ * value is not a string literal. Used by the jQuery ajax / axios object
183
+ * consumers to resolve `url` / `method` / `type` keys in any order.
184
+ */
185
+ function readStringProp(objectNode, keyNames) {
186
+ for (let i = 0; i < objectNode.namedChildCount; i++) {
187
+ const pair = objectNode.namedChild(i);
188
+ if (!pair || pair.type !== 'pair')
189
+ continue;
190
+ const keyNode = pair.childForFieldName('key');
191
+ const valueNode = pair.childForFieldName('value');
192
+ if (!keyNode || !valueNode)
193
+ continue;
194
+ if (!keyNames.includes(keyNode.text))
195
+ continue;
196
+ if (valueNode.type !== 'string' && valueNode.type !== 'template_string')
197
+ continue;
198
+ const lit = unquoteLiteral(valueNode.text);
199
+ if (lit !== null)
200
+ return lit;
201
+ }
202
+ return null;
203
+ }
133
204
  /**
134
205
  * For a standalone `decorator` node (child of class_body / program),
135
206
  * find the related `class_declaration` node that it decorates. In
@@ -335,6 +406,65 @@ function scanBundle(bundle, tree) {
335
406
  confidence: 0.7,
336
407
  });
337
408
  }
409
+ // Consumer: jQuery shorthand $.get(url) / $.post(url, ...)
410
+ for (const match of runCompiledPatterns(bundle.jqueryShorthand, tree)) {
411
+ const methodNode = match.captures.http_method;
412
+ const pathNode = match.captures.path;
413
+ if (!methodNode || !pathNode)
414
+ continue;
415
+ const path = unquoteLiteral(pathNode.text);
416
+ if (path === null)
417
+ continue;
418
+ out.push({
419
+ role: 'consumer',
420
+ framework: 'jquery',
421
+ method: methodNode.text.toUpperCase(),
422
+ path,
423
+ name: null,
424
+ confidence: 0.7,
425
+ });
426
+ }
427
+ // Consumer: jQuery $.ajax({ url, method|type }). jQuery accepts either
428
+ // `method:` or `type:`; both default to GET when absent.
429
+ for (const match of runCompiledPatterns(bundle.jqueryAjax, tree)) {
430
+ const optionsNode = match.captures.options;
431
+ if (!optionsNode)
432
+ continue;
433
+ const path = readStringProp(optionsNode, ['url']);
434
+ if (path === null)
435
+ continue;
436
+ const rawMethod = readStringProp(optionsNode, ['method', 'type']);
437
+ const method = (rawMethod ?? 'GET').toUpperCase();
438
+ out.push({
439
+ role: 'consumer',
440
+ framework: 'jquery',
441
+ method,
442
+ path,
443
+ name: null,
444
+ confidence: 0.7,
445
+ });
446
+ }
447
+ // Consumer: axios({ method, url }) object form. Structurally distinct
448
+ // from axios.<verb>(url) (identifier vs member_expression call), so no
449
+ // dedup against the member-form loop above is required.
450
+ for (const match of runCompiledPatterns(bundle.axiosObject, tree)) {
451
+ const optionsNode = match.captures.options;
452
+ if (!optionsNode)
453
+ continue;
454
+ const path = readStringProp(optionsNode, ['url']);
455
+ if (path === null)
456
+ continue;
457
+ const rawMethod = readStringProp(optionsNode, ['method']);
458
+ const method = (rawMethod ?? 'GET').toUpperCase();
459
+ out.push({
460
+ role: 'consumer',
461
+ framework: 'axios',
462
+ method,
463
+ path,
464
+ name: null,
465
+ confidence: 0.7,
466
+ });
467
+ }
338
468
  return out;
339
469
  }
340
470
  export const JAVASCRIPT_HTTP_PLUGIN = {
@@ -1,13 +1,11 @@
1
1
  import { KnowledgeGraph } from '../graph/types.js';
2
2
  import { ASTCache } from './ast-cache.js';
3
- import type { SymbolDefinition, SymbolTableReader } from './model/symbol-table.js';
3
+ import type { SymbolDefinition, SymbolTableReader, HeritageMap, ExtractedHeritage } from './model/index.js';
4
4
  import type { ResolutionContext } from './model/resolution-context.js';
5
5
  import type { TieredCandidates } from './model/resolution-context.js';
6
6
  import type { TypeEnvironment } from './type-env.js';
7
- import type { HeritageMap } from './model/heritage-map.js';
8
7
  import type { BindingAccumulator } from './binding-accumulator.js';
9
8
  import type { ExtractedCall, ExtractedAssignment, ExtractedRoute, ExtractedFetchCall, FileConstructorBindings } from './workers/parse-worker.js';
10
- import type { ExtractedHeritage } from './model/heritage-map.js';
11
9
  import type { LiteralTypeInferrer } from './type-extractors/types.js';
12
10
  import type { SyntaxNode } from './utils/ast-helpers.js';
13
11
  /** Per-file resolved type bindings for exported symbols.
@@ -1,4 +1,4 @@
1
- import { CLASS_TYPES, CALL_TARGET_TYPES } from './model/symbol-table.js';
1
+ import { CLASS_TYPES, CALL_TARGET_TYPES, lookupMethodByOwnerWithMRO } from './model/index.js';
2
2
  import Parser from 'tree-sitter';
3
3
  import { TIER_CONFIDENCE } from './model/resolution-context.js';
4
4
  import { isLanguageAvailable, loadParser, loadLanguage } from '../tree-sitter/parser-loader.js';
@@ -15,7 +15,6 @@ import { getTreeSitterBufferSize } from './constants.js';
15
15
  import { normalizeFetchURL, routeMatches } from './route-extractors/nextjs.js';
16
16
  import { extractTemplateComponents } from './vue-sfc-extractor.js';
17
17
  import { extractReturnTypeName, stripNullable } from './type-extractors/shared.js';
18
- import { lookupMethodByOwnerWithMRO } from './model/resolve.js';
19
18
  /**
20
19
  * Type labels treated as class-like **method-dispatch receivers** by the call
21
20
  * resolver — the set walked by the MRO / heritage path for member and static
@@ -1,5 +1,5 @@
1
1
  import type { TypeEnvironment } from './type-env.js';
2
- import type { SymbolTableReader } from './model/symbol-table.js';
2
+ import type { SymbolTableReader } from './model/index.js';
3
3
  import { SupportedLanguages } from '../../_shared/index.js';
4
4
  /**
5
5
  * Visibility levels used across all supported languages.
@@ -10,11 +10,11 @@
10
10
  * `SymbolTable` by design.
11
11
  */
12
12
  export { type SemanticModel, type MutableSemanticModel, createSemanticModel, } from './semantic-model.js';
13
- export { type SymbolTableReader, type SymbolTableWriter, createSymbolTable, } from './symbol-table.js';
13
+ export { type SymbolTableReader, type SymbolTableWriter, createSymbolTable, type SymbolDefinition, type AddMetadata, CLASS_TYPES, CLASS_TYPES_TUPLE, type ClassLikeLabel, FREE_CALLABLE_TYPES, FREE_CALLABLE_TUPLE, type FreeCallableLabel, CALL_TARGET_TYPES, } from './symbol-table.js';
14
14
  export { type TypeRegistry, type MutableTypeRegistry, createTypeRegistry, } from './type-registry.js';
15
15
  export { type MethodRegistry, type MutableMethodRegistry, createMethodRegistry, } from './method-registry.js';
16
16
  export { type FieldRegistry, type MutableFieldRegistry, createFieldRegistry, } from './field-registry.js';
17
17
  export { lookupMethodByOwnerWithMRO } from './resolve.js';
18
18
  export { type NamedImportBinding, type NamedImportMap, isFileInPackageDir, } from './resolution-context.js';
19
- export { type ExtractedHeritage, type HeritageResolutionStrategy, type HeritageStrategyLookup, } from './heritage-map.js';
19
+ export { type ExtractedHeritage, type HeritageMap, type HeritageResolutionStrategy, type HeritageStrategyLookup, } from './heritage-map.js';
20
20
  export { CALLABLE_ONLY_LABELS, INERT_LABELS, DISPATCH_LABELS, ALL_NODE_LABELS, type LabelBehavior, } from './registration-table.js';
@@ -16,7 +16,7 @@ export { createSemanticModel, } from './semantic-model.js';
16
16
  // SymbolTable is exclusively owned by SemanticModel. Re-exported here
17
17
  // for the rare caller that needs the file/callable interface in
18
18
  // isolation (e.g. tests).
19
- export { createSymbolTable, } from './symbol-table.js';
19
+ export { createSymbolTable, CLASS_TYPES, CLASS_TYPES_TUPLE, FREE_CALLABLE_TYPES, FREE_CALLABLE_TUPLE, CALL_TARGET_TYPES, } from './symbol-table.js';
20
20
  // Type registry (classes, structs, interfaces, enums, records, impls)
21
21
  export { createTypeRegistry, } from './type-registry.js';
22
22
  // Method registry (owner-scoped methods with arity-aware overload lookup)
@@ -12,6 +12,9 @@ import type { MroStrategy } from '../../../_shared/index.js';
12
12
  /**
13
13
  * Gather all ancestor IDs in BFS / topological order.
14
14
  * Returns the linearized list of ancestor IDs (excluding the class itself).
15
+ *
16
+ * Uses a head-pointer BFS (`queue[head++]`) instead of `Array.shift()` to
17
+ * avoid O(n) per-dequeue re-indexing — matching `buildParentMapFromHeritage`.
15
18
  */
16
19
  declare function gatherAncestors(classId: string, parentMap: Map<string, string[]>): string[];
17
20
  /**
@@ -15,13 +15,17 @@
15
15
  /**
16
16
  * Gather all ancestor IDs in BFS / topological order.
17
17
  * Returns the linearized list of ancestor IDs (excluding the class itself).
18
+ *
19
+ * Uses a head-pointer BFS (`queue[head++]`) instead of `Array.shift()` to
20
+ * avoid O(n) per-dequeue re-indexing — matching `buildParentMapFromHeritage`.
18
21
  */
19
22
  function gatherAncestors(classId, parentMap) {
20
23
  const visited = new Set();
21
24
  const order = [];
22
25
  const queue = [...(parentMap.get(classId) ?? [])];
23
- while (queue.length > 0) {
24
- const id = queue.shift();
26
+ let head = 0;
27
+ while (head < queue.length) {
28
+ const id = queue[head++];
25
29
  if (visited.has(id))
26
30
  continue;
27
31
  visited.add(id);
@@ -1,9 +1,8 @@
1
1
  import { KnowledgeGraph } from '../graph/types.js';
2
- import type { SymbolTableWriter } from './model/symbol-table.js';
2
+ import type { SymbolTableWriter, ExtractedHeritage } from './model/index.js';
3
3
  import { ASTCache } from './ast-cache.js';
4
4
  import { WorkerPool } from './workers/worker-pool.js';
5
5
  import type { ExtractedImport, ExtractedCall, ExtractedAssignment, ExtractedRoute, ExtractedFetchCall, ExtractedDecoratorRoute, ExtractedToolDef, FileConstructorBindings, FileScopeBindings, ExtractedORMQuery } from './workers/parse-worker.js';
6
- import type { ExtractedHeritage } from './model/heritage-map.js';
7
6
  export type FileProgressCallback = (current: number, total: number, filePath: string) => void;
8
7
  export interface WorkerExtractedData {
9
8
  imports: ExtractedImport[];
@@ -1,7 +1,7 @@
1
1
  import { type SyntaxNode } from './utils/ast-helpers.js';
2
2
  import { SupportedLanguages } from '../../_shared/index.js';
3
3
  import type { BindingAccumulator } from './binding-accumulator.js';
4
- import type { SemanticModel } from './model/semantic-model.js';
4
+ import type { SemanticModel } from './model/index.js';
5
5
  import type { NodeLabel } from '../../_shared/index.js';
6
6
  /**
7
7
  * Per-file type environment with receiver resolution.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.2-rc.16",
3
+ "version": "1.6.2-rc.18",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",