gitnexus 1.6.4-rc.28 → 1.6.4-rc.29

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.
@@ -31,15 +31,26 @@ export function emitPythonScopeCaptures(sourceText, _filePath, cachedTree) {
31
31
  // here at the use site.
32
32
  let tree = cachedTree;
33
33
  if (tree === undefined) {
34
- tree = getPythonParser().parse(sourceText, undefined, {
35
- bufferSize: getTreeSitterBufferSize(sourceText),
36
- });
34
+ try {
35
+ tree = getPythonParser().parse(sourceText, undefined, {
36
+ bufferSize: getTreeSitterBufferSize(sourceText),
37
+ });
38
+ }
39
+ catch (err) {
40
+ throw scopeExtractionError('parse', _filePath, err);
41
+ }
37
42
  recordCacheMiss();
38
43
  }
39
44
  else {
40
45
  recordCacheHit();
41
46
  }
42
- const rawMatches = getPythonScopeQuery().matches(tree.rootNode);
47
+ let rawMatches;
48
+ try {
49
+ rawMatches = getPythonScopeQuery().matches(tree.rootNode);
50
+ }
51
+ catch (err) {
52
+ throw scopeExtractionError('scope query', _filePath, err);
53
+ }
43
54
  const out = [];
44
55
  for (const m of rawMatches) {
45
56
  // Group captures by their tag name. Tree-sitter strips the leading
@@ -112,3 +123,7 @@ export function emitPythonScopeCaptures(sourceText, _filePath, cachedTree) {
112
123
  }
113
124
  return out;
114
125
  }
126
+ function scopeExtractionError(stage, filePath, err) {
127
+ const reason = err instanceof Error ? err.message : String(err);
128
+ return new Error(`[python] tree-sitter ${stage} failed for ${filePath}: ${reason}; skipping scope extraction for this file`);
129
+ }
@@ -74,6 +74,7 @@ export function extract(matches, filePath, provider) {
74
74
  const partitioned = partitionByTopic(matches);
75
75
  // ── Pass 1: build the scope tree ─────────────────────────────────────
76
76
  const scopeDrafts = pass1BuildScopes(partitioned.scope, filePath, provider);
77
+ const moduleScope = ensureModuleScope(scopeDrafts, matches.length, filePath);
77
78
  const scopes = scopeDrafts.map(draftToScope);
78
79
  // buildScopeTree validates invariants (throws on violation) and exposes
79
80
  // the lookup contract consumed by Passes 2-5.
@@ -87,11 +88,6 @@ export function extract(matches, filePath, provider) {
87
88
  // "what's the parent chain?" queries, not for content queries.
88
89
  const scopeTree = buildScopeTree(scopes);
89
90
  const positionIndex = buildPositionIndex(scopes);
90
- const moduleScope = scopeDrafts.find((s) => s.kind === 'Module');
91
- if (moduleScope === undefined) {
92
- throw new Error(`ScopeExtractor: no Module scope found for '${filePath}'. ` +
93
- `Provider must emit at least one @scope.module capture per file.`);
94
- }
95
91
  // ── Pass 2: attach declarations + local bindings ────────────────────
96
92
  const localDefs = [];
97
93
  pass2AttachDeclarations(partitioned.declaration, scopeDrafts, positionIndex, localDefs, filePath, provider, scopeTree);
@@ -174,6 +170,19 @@ function topicOf(match) {
174
170
  }
175
171
  return 'unknown';
176
172
  }
173
+ function ensureModuleScope(scopeDrafts, matchCount, filePath) {
174
+ const moduleScope = scopeDrafts.find((s) => s.kind === 'Module');
175
+ if (moduleScope !== undefined)
176
+ return moduleScope;
177
+ if (scopeDrafts.length === 0 && matchCount === 0) {
178
+ const range = { startLine: 0, startCol: 0, endLine: 0, endCol: 0 };
179
+ const synthetic = makeDraft(makeScopeId({ filePath, range, kind: 'Module' }), null, 'Module', range, filePath);
180
+ scopeDrafts.push(synthetic);
181
+ return synthetic;
182
+ }
183
+ throw new Error(`ScopeExtractor: no Module scope found for '${filePath}'. ` +
184
+ `Provider must emit at least one @scope.module capture per file.`);
185
+ }
177
186
  function draftToScope(draft) {
178
187
  const frozenBindings = new Map();
179
188
  for (const [name, refs] of draft.bindings) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.4-rc.28",
3
+ "version": "1.6.4-rc.29",
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",