@sdsrs/code-graph 0.189.0 → 0.190.1

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.
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "sdsrs"
6
6
  },
7
- "version": "0.189.0",
7
+ "version": "0.190.1",
8
8
  "keywords": [
9
9
  "code-graph",
10
10
  "ast",
@@ -379,13 +379,17 @@ function stripAndHealSeams(text, re) {
379
379
  // start a match at a marker we cannot prove we wrote, and when in doubt delete
380
380
  // less. A stale block left behind is visible and removable; deleted prose is not.
381
381
  function stripSentinelBlock(text) {
382
- // Line-anchored. A marker mentioned mid-sentence ("the block starts with
383
- // `<!-- code-graph-mcp:begin v2 -->` — don't edit inside it") is prose, not a
384
- // block opener; matching it ate everything from that sentence to the end of
385
- // the real block below it.
386
- const BEGIN_LINE = `^[ \\t]*${SENTINEL_BEGIN_SRC}[ \\t]*$`;
387
- const END_LINE = `^[ \\t]*${escapeRegex(SENTINEL_END)}[ \\t]*$`;
382
+ return stripOrphanMarkers(stripWellFormedBlocks(text));
383
+ }
384
+
385
+ // Line-anchored. A marker mentioned mid-sentence ("the block starts with
386
+ // `<!-- code-graph-mcp:begin v2 -->` — don't edit inside it") is prose, not a
387
+ // block opener; matching it ate everything from that sentence to the end of
388
+ // the real block below it.
389
+ const BEGIN_LINE = `^[ \\t]*${SENTINEL_BEGIN_SRC}[ \\t]*$`;
390
+ const END_LINE = `^[ \\t]*${escapeRegex(SENTINEL_END)}[ \\t]*$`;
388
391
 
392
+ function stripWellFormedBlocks(text) {
389
393
  // Match ANY begin version (v1 legacy MEMORY.md block, v2 CLAUDE.md block) so a
390
394
  // single strip handles both the new target and the legacy migration cleanup.
391
395
  //
@@ -397,7 +401,12 @@ function stripSentinelBlock(text) {
397
401
  `${BEGIN_LINE}(?:(?!${SENTINEL_BEGIN_SRC})[\\s\\S])*?${END_LINE}\\n?`,
398
402
  'gm'
399
403
  );
400
- let out = stripAndHealSeams(text, wellFormed);
404
+ return stripAndHealSeams(text, wellFormed);
405
+ }
406
+
407
+ // Runs after stripWellFormedBlocks, so every marker line left is an orphan.
408
+ // What this removes is the only thing adopt reports as "healed".
409
+ function stripOrphanMarkers(text) {
401
410
  // Orphan BEGIN with no matching END (truncation / partial edit): remove the
402
411
  // MARKER LINE ONLY, never the content after it.
403
412
  //
@@ -416,7 +425,7 @@ function stripSentinelBlock(text) {
416
425
  // line-anchored BEGIN *and* END, so a leftover fragment does not block
417
426
  // re-adoption — the next adopt writes a fresh, well-formed block.
418
427
  const orphanBegin = new RegExp(`${BEGIN_LINE}\\n?`, 'gm');
419
- out = stripAndHealSeams(out, orphanBegin);
428
+ let out = stripAndHealSeams(text, orphanBegin);
420
429
  // Orphan END line by itself — same rule, one line, nothing around it. Written
421
430
  // as the same line-anchored removal the other two passes use (the old
422
431
  // split/filter/join spelling was a third predicate for "is this our END line",
@@ -594,8 +603,11 @@ function adopt({ cwd, templatePath, home } = {}) {
594
603
  const registryRecorded = recordAdopted(effectiveCwd, home);
595
604
  return { ok: true, detailPath: dPath, claudeMdPath: cPath, detailWritten, claudeMdWritten: false, created: false, healed: false, registryRecorded };
596
605
  }
597
- const cleaned = exists ? stripSentinelBlock(current) : '';
598
- const healed = exists && cleaned !== current;
606
+ // Replacing a well-formed block (an older plugin version's) is a refresh;
607
+ // only removing an orphan marker line is a repair worth reporting.
608
+ const withoutBlocks = exists ? stripWellFormedBlocks(current) : '';
609
+ const cleaned = stripOrphanMarkers(withoutBlocks);
610
+ const healed = cleaned !== withoutBlocks;
599
611
  const base = cleaned.replace(/\n+$/, '');
600
612
  const prefix = base ? base + '\n\n' : '';
601
613
  try {
@@ -911,6 +923,18 @@ function unadoptCommand() {
911
923
  return `node ${shellQuote(__filename)} unadopt`;
912
924
  }
913
925
 
926
+ // `git ls-files --error-unmatch` exits 0 only for a path in the index. Every
927
+ // failure (no git, not a repository, untracked, missing directory) reads as
928
+ // "not tracked": the line this gates is advice to commit the file.
929
+ function isGitTracked(file) {
930
+ try {
931
+ require('child_process').execFileSync('git',
932
+ ['ls-files', '--error-unmatch', '--', path.basename(file)],
933
+ { cwd: path.dirname(file), stdio: 'ignore', timeout: 5000, windowsHide: true });
934
+ return true;
935
+ } catch { return false; }
936
+ }
937
+
914
938
  function formatResult(action, result) {
915
939
  if (!result.ok && result.reason === 'windows-not-supported') {
916
940
  return '[code-graph] adopt/unadopt are POSIX-only on this build. ' +
@@ -946,8 +970,10 @@ function formatResult(action, result) {
946
970
  else lines.push('[code-graph] CLAUDE.md block already up-to-date — no write');
947
971
  if (result.healed) lines.push('[code-graph] Healed a malformed prior block.');
948
972
  lines.push(`[code-graph] Detail table → ${result.detailPath}`);
949
- lines.push('[code-graph] CLAUDE.md is git-tracked — commit the block, or gitignore');
950
- lines.push('[code-graph] .claude/plugin_code_graph_mcp.md (a generated copy) as you prefer.');
973
+ if (isGitTracked(result.claudeMdPath)) {
974
+ lines.push('[code-graph] CLAUDE.md is git-tracked — commit the block, or gitignore');
975
+ lines.push('[code-graph] .claude/plugin_code_graph_mcp.md (a generated copy) as you prefer.');
976
+ }
951
977
  lines.push(`[code-graph] Reverse: ${unadoptCommand()}`);
952
978
  lines.push('[code-graph] Opt out: CODE_GRAPH_NO_AUTO_ADOPT=1 in ~/.claude/settings.json env');
953
979
  return lines.join('\n');
@@ -41,7 +41,7 @@ jobs:
41
41
  # refuses a snapshot that has no checksum sidecar.
42
42
  - name: Build snapshot
43
43
  run: |
44
- npx -y -p @sdsrs/code-graph@0.189.0 code-graph-mcp snapshot create --out "code-graph-snapshot-${GITHUB_SHA:0:7}.db.zst"
44
+ npx -y -p @sdsrs/code-graph@0.190.1 code-graph-mcp snapshot create --out "code-graph-snapshot-${GITHUB_SHA:0:7}.db.zst"
45
45
  - name: Upload to release
46
46
  env:
47
47
  GH_TOKEN: ${{ github.token }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdsrs/code-graph",
3
- "version": "0.189.0",
3
+ "version": "0.190.1",
4
4
  "description": "MCP server that indexes codebases into an AST knowledge graph with semantic search, call graph traversal, and HTTP route tracing",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,10 +35,10 @@
35
35
  "node": ">=16"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@sdsrs/code-graph-linux-x64": "0.189.0",
39
- "@sdsrs/code-graph-linux-arm64": "0.189.0",
40
- "@sdsrs/code-graph-darwin-x64": "0.189.0",
41
- "@sdsrs/code-graph-darwin-arm64": "0.189.0",
42
- "@sdsrs/code-graph-win32-x64": "0.189.0"
38
+ "@sdsrs/code-graph-linux-x64": "0.190.1",
39
+ "@sdsrs/code-graph-linux-arm64": "0.190.1",
40
+ "@sdsrs/code-graph-darwin-x64": "0.190.1",
41
+ "@sdsrs/code-graph-darwin-arm64": "0.190.1",
42
+ "@sdsrs/code-graph-win32-x64": "0.190.1"
43
43
  }
44
44
  }