GitNexus/gitnexus/test
azizur100389 e262dda35b
fix(cli): only match <!-- gitnexus:* --> markers at section position (#1041) (#1042)
`upsertGitNexusSection` in ai-context.ts uses `indexOf` to locate the
bounds of the GitNexus section in CLAUDE.md / AGENTS.md before
replacement. `indexOf` matches the first occurrence of the marker
anywhere in the file, including inline prose references in backtick-
quoted fragments mid-sentence.

The shipped CLAUDE.md contains exactly such a reference ("See the
`<!-- gitnexus:start --> … <!-- gitnexus:end -->` block in AGENTS.md
for the canonical MCP tools..."). Running `gitnexus analyze` on a
fresh install matches those inline markers as section delimiters and
replaces the prose between them with the full ~100-line injected
block, breaking the backtick and corrupting markdown for every user.

Fix: new private `findSectionMarkerIndex` helper that only matches
markers occupying their own line — preceded by `\n` or start-of-file,
followed by `\n` / `\r` (CRLF files) / end-of-file. `\r` is explicit
so CRLF-terminated sections on Windows (core.autocrlf = true) still
match. The generator always emits markers alone on their line, so
every legitimate section continues to update in place; only inline
prose references now fall through to the append branch, which leaves
existing content untouched.

Two new unit tests:
- #1041 regression — seed CLAUDE.md with the shipped inline prose
  line, run analyze twice, assert inline prose preserved verbatim
  and marker counts stay at 2/2 (1 inline + 1 section-position)
- CRLF handling — seed a CRLF file with inline prose + legitimate
  section, run analyze, assert section replaced in place, inline
  prose preserved, stale stub content removed

No destructive ops, no bypass flags, no new deps. Behaviour change
is strictly narrowing — files that previously updated correctly
still do; files that previously got corrupted now fall through to
the safer append branch.

Closes #1041.
2026-04-23 07:58:07 +01:00
..
fixtures fix(group): surface friendly error when group name not found (#903 regression test) (#989) 2026-04-21 15:52:36 +01:00
helpers Fix security issues and critical bugs found in code review (#709) 2026-04-10 05:20:29 +01:00
integration feat(cli): Fingerprint indexed repos by remote URL to detect sibling-clone graph drift (#982) 2026-04-21 21:58:54 +01:00
unit fix(cli): only match <!-- gitnexus:* --> markers at section position (#1041) (#1042) 2026-04-23 07:58:07 +01:00
utils ci: add macOS to cross-platform test matrix (#208) 2026-03-07 10:38:32 +00:00
global-setup.ts feat: upgrade @ladybugdb/core to 0.15.2 and remove segfault workarounds (#374) 2026-03-19 08:25:43 +00:00
vitest.d.ts refactor: migrate from KuzuDB to LadybugDB v0.15 (#275) 2026-03-15 15:53:01 +00:00