gitnexus 1.6.10-rc.16 → 1.6.10-rc.17

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.
@@ -814,7 +814,7 @@ const processFileGroup = (files, language, queryString, result, onFileProcessed)
814
814
  try {
815
815
  tree = parseSourceSafe(parser, parseContent, undefined, {
816
816
  bufferSize: getTreeSitterBufferSize(parseContent),
817
- });
817
+ }, file.path);
818
818
  }
819
819
  catch (err) {
820
820
  reportWarning(`Failed to parse file ${file.path}: ${err instanceof Error ? err.message : String(err)}`);
@@ -42,7 +42,7 @@ export declare function getParseDiagnostics(tree: Parser.Tree): {
42
42
  /**
43
43
  * Parse `sourceText` safely on every platform.
44
44
  *
45
- * This is the single "parse safely" entry point and its contract covers three
45
+ * This is the single "parse safely" entry point and its contract covers four
46
46
  * concerns:
47
47
  *
48
48
  * 1. **Windows crash workaround.** Inputs longer than 32 767 chars are fed
@@ -62,7 +62,12 @@ export declare function getParseDiagnostics(tree: Parser.Tree): {
62
62
  * the tree is **returned anyway** — error recovery is a downgrade, never a
63
63
  * drop. Callers wanting the boolean use {@link parseHadErrors}.
64
64
  *
65
- * @param label optional context (e.g. file path) attached to timeout errors
66
- * and degraded-parse logs. Non-breaking trailing param.
65
+ * 4. **Embedded NUL recovery.** U+0000 is replaced with one ASCII space in
66
+ * the parser-only input. The one-for-one substitution keeps tree indices
67
+ * aligned with the original source while preventing language lexers from
68
+ * swallowing declarations during error recovery.
69
+ *
70
+ * @param label optional context (e.g. file path) attached to timeout errors,
71
+ * recovery warnings, and degraded-parse logs. Non-breaking trailing param.
67
72
  */
68
73
  export declare function parseSourceSafe(parser: Parser, sourceText: string, oldTree?: Parser.Tree, options?: Parser.Options, label?: string): Parser.Tree;
@@ -155,7 +155,7 @@ export function getParseDiagnostics(tree) {
155
155
  /**
156
156
  * Parse `sourceText` safely on every platform.
157
157
  *
158
- * This is the single "parse safely" entry point and its contract covers three
158
+ * This is the single "parse safely" entry point and its contract covers four
159
159
  * concerns:
160
160
  *
161
161
  * 1. **Windows crash workaround.** Inputs longer than 32 767 chars are fed
@@ -175,22 +175,36 @@ export function getParseDiagnostics(tree) {
175
175
  * the tree is **returned anyway** — error recovery is a downgrade, never a
176
176
  * drop. Callers wanting the boolean use {@link parseHadErrors}.
177
177
  *
178
- * @param label optional context (e.g. file path) attached to timeout errors
179
- * and degraded-parse logs. Non-breaking trailing param.
178
+ * 4. **Embedded NUL recovery.** U+0000 is replaced with one ASCII space in
179
+ * the parser-only input. The one-for-one substitution keeps tree indices
180
+ * aligned with the original source while preventing language lexers from
181
+ * swallowing declarations during error recovery.
182
+ *
183
+ * @param label optional context (e.g. file path) attached to timeout errors,
184
+ * recovery warnings, and degraded-parse logs. Non-breaking trailing param.
180
185
  */
181
186
  export function parseSourceSafe(parser, sourceText, oldTree, options, label) {
187
+ let parserInput = sourceText;
188
+ if (sourceText.includes('\0')) {
189
+ let nullByteCount = 0;
190
+ parserInput = sourceText.replaceAll('\0', () => {
191
+ nullByteCount += 1;
192
+ return ' ';
193
+ });
194
+ logger.warn({ ...(label ? { file: label } : {}), nullByteCount }, 'replaced embedded NUL bytes before tree-sitter parsing');
195
+ }
182
196
  const budgetMs = resolveParseTimeoutMs();
183
197
  const armed = armParseBudget(parser, budgetMs);
184
198
  let tree;
185
199
  try {
186
- if (sourceText.length <= DIRECT_PARSE_LIMIT_CHARS) {
187
- tree = parser.parse(sourceText, oldTree, options);
200
+ if (parserInput.length <= DIRECT_PARSE_LIMIT_CHARS) {
201
+ tree = parser.parse(parserInput, oldTree, options);
188
202
  }
189
203
  else {
190
204
  const input = (index) => {
191
- if (index >= sourceText.length)
205
+ if (index >= parserInput.length)
192
206
  return null;
193
- return sourceText.slice(index, index + SAFE_PARSE_CHUNK_CHARS);
207
+ return parserInput.slice(index, index + SAFE_PARSE_CHUNK_CHARS);
194
208
  };
195
209
  tree = parser.parse(input, oldTree, options);
196
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.10-rc.16",
3
+ "version": "1.6.10-rc.17",
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",