gitnexus 1.6.3-rc.35 → 1.6.3-rc.37

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.
@@ -13,6 +13,32 @@ const __filename = fileURLToPath(import.meta.url);
13
13
  const __dirname = path.dirname(__filename);
14
14
  const GITNEXUS_START_MARKER = '<!-- gitnexus:start -->';
15
15
  const GITNEXUS_END_MARKER = '<!-- gitnexus:end -->';
16
+ /**
17
+ * Find the index of a section marker that occupies its own line.
18
+ * Unlike `indexOf`, this rejects inline prose references like
19
+ * `` See the `<!-- gitnexus:start -->` block `` that appear
20
+ * mid-sentence (#1041). A marker counts as section-position only when:
21
+ * - preceded by newline or start-of-file, AND
22
+ * - followed by newline, `\r` (CRLF files), or end-of-file.
23
+ * The generator always emits each marker alone on its line, so this
24
+ * matches every legitimate section and none of the inline mentions.
25
+ *
26
+ * `startFrom` lets the end-marker lookup start after the already-found
27
+ * start marker, avoiding a scan from 0 and guaranteeing we never pick
28
+ * up an end marker that appears earlier in the file than the start.
29
+ */
30
+ function findSectionMarkerIndex(content, marker, startFrom = 0) {
31
+ let idx = content.indexOf(marker, startFrom);
32
+ while (idx !== -1) {
33
+ const atLineStart = idx === 0 || content[idx - 1] === '\n';
34
+ const endPos = idx + marker.length;
35
+ const atLineEnd = endPos === content.length || content[endPos] === '\n' || content[endPos] === '\r';
36
+ if (atLineStart && atLineEnd)
37
+ return idx;
38
+ idx = content.indexOf(marker, idx + 1);
39
+ }
40
+ return -1;
41
+ }
16
42
  /**
17
43
  * Generate the full GitNexus context content.
18
44
  *
@@ -123,9 +149,14 @@ async function upsertGitNexusSection(filePath, content) {
123
149
  return 'created';
124
150
  }
125
151
  const existingContent = await fs.readFile(filePath, 'utf-8');
126
- // Check if GitNexus section already exists
127
- const startIdx = existingContent.indexOf(GITNEXUS_START_MARKER);
128
- const endIdx = existingContent.indexOf(GITNEXUS_END_MARKER);
152
+ // Check if GitNexus section already exists. Matching is restricted
153
+ // to markers that occupy their own line so that inline prose
154
+ // references (e.g. `` See the `<!-- gitnexus:start -->` block `` in
155
+ // the shipped CLAUDE.md) are NOT treated as section delimiters
156
+ // (#1041). The end-marker scan starts after the start-marker so it
157
+ // can never pick up an earlier end in the file.
158
+ const startIdx = findSectionMarkerIndex(existingContent, GITNEXUS_START_MARKER);
159
+ const endIdx = findSectionMarkerIndex(existingContent, GITNEXUS_END_MARKER, startIdx === -1 ? 0 : startIdx);
129
160
  if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
130
161
  // Replace existing section
131
162
  const before = existingContent.substring(0, startIdx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.3-rc.35",
3
+ "version": "1.6.3-rc.37",
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",