diff --git a/gitnexus/src/cli/ai-context.ts b/gitnexus/src/cli/ai-context.ts index c6b098807..dec8f420d 100644 --- a/gitnexus/src/cli/ai-context.ts +++ b/gitnexus/src/cli/ai-context.ts @@ -384,7 +384,7 @@ async function upsertGitNexusSection( const statsLine = noStats ? `${statsPrefix} **${projectName}**` : `${statsPrefix} **${projectName}** (${newStatsInner})`; - const updatedSection = existingSection.replace(statsPattern, statsLine); + const updatedSection = existingSection.replace(statsPattern, () => statsLine); // Count-only delta — leave the committed lean block alone (#2907). A // project rename, or --no-stats dropping the parenthetical, still writes. if (stripVolatileCounts(updatedSection) === stripVolatileCounts(existingSection)) { diff --git a/gitnexus/test/unit/ai-context.test.ts b/gitnexus/test/unit/ai-context.test.ts index 418274073..75056a836 100644 --- a/gitnexus/test/unit/ai-context.test.ts +++ b/gitnexus/test/unit/ai-context.test.ts @@ -1511,7 +1511,7 @@ indexed by GitNexus as **OldName** (10 symbols, 20 relationships, 3 execution fl `; await fs.writeFile(path.join(dir, 'CLAUDE.md'), original, 'utf-8'); - const result = await generateAIContextFiles(dir, storage, 'NewName', { + const result = await generateAIContextFiles(dir, storage, 'Repo$1Name', { nodes: 55, edges: 66, processes: 7, @@ -1519,7 +1519,7 @@ indexed by GitNexus as **OldName** (10 symbols, 20 relationships, 3 execution fl expect(result.files).toContain('CLAUDE.md (updated)'); expect(await fs.readFile(path.join(dir, 'CLAUDE.md'), 'utf-8')).toContain( - 'indexed by GitNexus as **NewName** (55 symbols, 66 relationships, 7 execution flows). Custom.', + 'indexed by GitNexus as **Repo$1Name** (55 symbols, 66 relationships, 7 execution flows). Custom.', ); } finally { await fs.rm(dir, { recursive: true, force: true });