@sdsrs/code-graph 0.127.0 → 0.128.0
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.
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/scripts/auto-update.js +38 -4
- package/claude-plugin/scripts/lifecycle.js +15 -3
- package/claude-plugin/scripts/pre-edit-guide.js +30 -4
- package/claude-plugin/scripts/pre-grep-guide.js +14 -0
- package/claude-plugin/templates/code-graph-snapshot.yml +1 -1
- package/package.json +6 -6
|
@@ -700,6 +700,16 @@ async function downloadAndInstall(latest, {
|
|
|
700
700
|
let pluginUpdated = false;
|
|
701
701
|
let binaryUpdated = false;
|
|
702
702
|
let marketplaceRefreshed = false;
|
|
703
|
+
// JS-02 (audit 2026-08-29): declared out here so it can be RETURNED. It used
|
|
704
|
+
// to live inside the `if (pluginUpdated)` block, correctly stopping the
|
|
705
|
+
// manifest from advancing, and then evaporate — the caller saw
|
|
706
|
+
// `pluginUpdated: true`, wrote `updateAttempts: 0, updateAvailable: false,
|
|
707
|
+
// suspendedAt: null`, and re-read the un-advanced registry next round. With
|
|
708
|
+
// `updateAvailable:false` the recheck interval is 30 minutes, so a registry
|
|
709
|
+
// that stays broken drives ~48 full download-and-install rounds a day —
|
|
710
|
+
// exactly the treadmill MAX_UPDATE_ATTEMPTS and the suspension mechanism
|
|
711
|
+
// exist to stop, both of which stayed dormant because every round "succeeded".
|
|
712
|
+
let repointBlocked = false;
|
|
703
713
|
|
|
704
714
|
try {
|
|
705
715
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
@@ -808,7 +818,6 @@ async function downloadAndInstall(latest, {
|
|
|
808
818
|
// behind, the ordinary check interval retries the whole install and
|
|
809
819
|
// re-reports, and the repoint lands by itself the moment the file is
|
|
810
820
|
// repaired. `missing` is not blocked: no registry means nothing to repoint.
|
|
811
|
-
let repointBlocked = false;
|
|
812
821
|
if (installedRead.corrupt) {
|
|
813
822
|
// Value unusable — the bytes are not ours to guess at.
|
|
814
823
|
const why = installedRead.error
|
|
@@ -848,7 +857,28 @@ async function downloadAndInstall(latest, {
|
|
|
848
857
|
repointBlocked = true;
|
|
849
858
|
}
|
|
850
859
|
}
|
|
851
|
-
|
|
860
|
+
// JS-05 (audit 2026-08-29): `plugins[PLUGIN_ID]` was assumed to be a
|
|
861
|
+
// non-empty array. A registry holding `[]` — or any other truthy
|
|
862
|
+
// non-array — made `[0].installPath = …` throw a TypeError, which the
|
|
863
|
+
// outer catch reported as "Plugin download/extract failed": a diagnosis
|
|
864
|
+
// pointing at the download for a malformed local file. `activeInstallPath`
|
|
865
|
+
// in lifecycle.js already reads this same field the careful way; this is
|
|
866
|
+
// the sibling that did not.
|
|
867
|
+
const records = installed && installed.plugins && installed.plugins[PLUGIN_ID];
|
|
868
|
+
const repointable =
|
|
869
|
+
Array.isArray(records) && records[0] && typeof records[0] === 'object';
|
|
870
|
+
if (installed && !repointable && installed.plugins && installed.plugins[PLUGIN_ID]) {
|
|
871
|
+
// Present but not the shape we can write into (`[]`, or a truthy
|
|
872
|
+
// non-array). Blocked, NOT skipped: a silent skip here would feed the
|
|
873
|
+
// JS-02 treadmill through a new door.
|
|
874
|
+
console.error(
|
|
875
|
+
`[code-graph] plugin ${latest.version} is installed, but this plugin's entry in ` +
|
|
876
|
+
`${installedPath} is malformed (expected a non-empty array) — it still points at ` +
|
|
877
|
+
'the previous version. Run `/plugin update` or repair that file by hand.'
|
|
878
|
+
);
|
|
879
|
+
repointBlocked = true;
|
|
880
|
+
}
|
|
881
|
+
if (repointable) {
|
|
852
882
|
installed.plugins[PLUGIN_ID][0].installPath = pluginDst;
|
|
853
883
|
installed.plugins[PLUGIN_ID][0].version = latest.version;
|
|
854
884
|
installed.plugins[PLUGIN_ID][0].lastUpdated = new Date().toISOString();
|
|
@@ -900,7 +930,7 @@ async function downloadAndInstall(latest, {
|
|
|
900
930
|
binaryUpdated = true;
|
|
901
931
|
}
|
|
902
932
|
|
|
903
|
-
return { pluginUpdated, binaryUpdated, marketplaceRefreshed };
|
|
933
|
+
return { pluginUpdated, binaryUpdated, marketplaceRefreshed, repointBlocked };
|
|
904
934
|
} catch (e) {
|
|
905
935
|
console.error(`[code-graph] Plugin download/extract failed: ${e.message}`);
|
|
906
936
|
return { pluginUpdated: false, binaryUpdated: false, marketplaceRefreshed };
|
|
@@ -1278,7 +1308,11 @@ async function checkForUpdate({ installMissing = false, force = false, requestJs
|
|
|
1278
1308
|
return { updateAvailable: true, suspended: true, from: installedVersion, to: latest.version };
|
|
1279
1309
|
}
|
|
1280
1310
|
const result = await downloadAndInstall(latest);
|
|
1281
|
-
|
|
1311
|
+
// A refused repoint is NOT a success (JS-02): the bytes landed, but the
|
|
1312
|
+
// registry Claude Code reads still names the old version, so the next round
|
|
1313
|
+
// sees the same update available. Counting it as success reset the attempt
|
|
1314
|
+
// counter and the suspension stamp every time.
|
|
1315
|
+
const success = result.pluginUpdated && !result.repointBlocked;
|
|
1282
1316
|
// Suspension clock. It restarts when the daily retry is spent and fails,
|
|
1283
1317
|
// which is what keeps `retryDue` from staying true and turning the retry
|
|
1284
1318
|
// back into a per-session treadmill; it clears on success and on a new
|
|
@@ -639,9 +639,18 @@ function unadoptRegisteredProjects() {
|
|
|
639
639
|
for (const project of (res && res.list) || []) {
|
|
640
640
|
try {
|
|
641
641
|
const r = unadopt({ cwd: project });
|
|
642
|
-
|
|
642
|
+
// Three outcomes, not two (audit 2026-08-29 JS-06). A project whose block
|
|
643
|
+
// the user already removed by hand comes back with nothing pruned and NO
|
|
644
|
+
// error — which used to land in the "Could NOT clean" list, sending them
|
|
645
|
+
// to hand-edit a file that is already clean. `unadopt` reports real
|
|
646
|
+
// failure separately (`claudeMdUnreadable` / `claudeMdUnwritable`, the
|
|
647
|
+
// same pair adopt.js folds into its own `cleanupFailed`), so use it rather
|
|
648
|
+
// than inferring failure from "nothing happened".
|
|
649
|
+
const cleaned = !!(r && (r.blockPruned || r.fileRemoved || r.claudeMdRemoved));
|
|
650
|
+
const failed = !!(r && (r.claudeMdUnreadable || r.claudeMdUnwritable));
|
|
651
|
+
out.push({ project, cleaned, failed });
|
|
643
652
|
} catch (e) {
|
|
644
|
-
out.push({ project, cleaned: false, error: (e && e.message) || String(e) });
|
|
653
|
+
out.push({ project, cleaned: false, failed: true, error: (e && e.message) || String(e) });
|
|
645
654
|
}
|
|
646
655
|
}
|
|
647
656
|
reportUnadoptSweep(out);
|
|
@@ -659,7 +668,9 @@ function unadoptRegisteredProjects() {
|
|
|
659
668
|
function reportUnadoptSweep(entries) {
|
|
660
669
|
try {
|
|
661
670
|
const cleaned = entries.filter((e) => e && e.cleaned).map((e) => e.project);
|
|
662
|
-
|
|
671
|
+
// Only genuine failures. "Nothing to clean" is neither a success worth
|
|
672
|
+
// announcing nor a problem worth sending someone to fix (JS-06).
|
|
673
|
+
const failed = entries.filter((e) => e && !e.cleaned && e.failed).map((e) => e.project);
|
|
663
674
|
if (!cleaned.length && !failed.length) return;
|
|
664
675
|
const lines = [];
|
|
665
676
|
if (cleaned.length) {
|
|
@@ -1825,6 +1836,7 @@ module.exports = {
|
|
|
1825
1836
|
install, uninstall, update, healthCheck, scanForBrokenPaths, checkScopeConflict,
|
|
1826
1837
|
isPluginExplicitlyDisabled, isPluginInactive, isPluginUninstalled, removeCacheResidue,
|
|
1827
1838
|
cleanupDisabledStatusline, unadoptRegisteredProjects,
|
|
1839
|
+
reportUnadoptSweep, // exported so its three-way bucketing is testable (audit 2026-08-29 JS-06)
|
|
1828
1840
|
readManifest, readJson, readJsonResult, readSettingsForWrite, writeJsonAtomic,
|
|
1829
1841
|
backupCorruptFile, // auto-update.js repoints installed_plugins.json and owes the same preserve-then-proceed route
|
|
1830
1842
|
migrateOldPluginIds, // exported so its failure arms are testable (audit 2026-08-22 P2-10)
|
|
@@ -45,20 +45,46 @@ if (!oldStr || oldStr.length < 10) process.exit(0);
|
|
|
45
45
|
|
|
46
46
|
// --- Extract function/method signature from the edited text ---
|
|
47
47
|
// Match function definitions across languages: Rust, JS/TS, Python, Go, Java/C#/Kotlin, Ruby, PHP
|
|
48
|
+
//
|
|
49
|
+
// Every unbounded run that is FOLLOWED BY A REQUIRED LITERAL carries an explicit
|
|
50
|
+
// `{1,128}` cap — longer than any real identifier, short enough that the engine
|
|
51
|
+
// gives up after 128 steps per start position. Without it those three patterns
|
|
52
|
+
// are quadratic: on a long
|
|
53
|
+
// unbroken \w run with no `name(...)` construct in it, the greedy run swallows to
|
|
54
|
+
// the end at EVERY start position and then backtracks a character at a time.
|
|
55
|
+
// Measured at HEAD on this box, pattern 4 alone: 10 KB 28 ms, 100 KB 2.8 s,
|
|
56
|
+
// 200 KB 11.0 s, 400 KB 43.4 s — doubling the input quadrupled the time.
|
|
57
|
+
//
|
|
58
|
+
// This needs no malice to hit. `old_string` is whatever the model is editing, so
|
|
59
|
+
// one benign blob without brackets — a base64 asset, a hex dump, a minified
|
|
60
|
+
// bundle, a long snake_case table — stalls a BLOCKING PreToolUse hook for
|
|
61
|
+
// seconds. Real code is unaffected either way (225 KB of this repo's own
|
|
62
|
+
// source: 0.3 ms), because a bracket ends the run almost immediately.
|
|
63
|
+
//
|
|
64
|
+
// The runs that are NOT capped are the ones nothing is required after
|
|
65
|
+
// (`fn\s+(\w+)`, `def\s+(\w+)`, …): those anchor on a keyword first and their
|
|
66
|
+
// trailing capture cannot backtrack, so a cap there would only truncate a long
|
|
67
|
+
// symbol name.
|
|
48
68
|
const fnPatterns = [
|
|
49
69
|
/(?:pub\s+)?(?:async\s+)?fn\s+(\w+)/, // Rust
|
|
50
70
|
/(?:export\s+)?(?:async\s+)?function\s+(\w+)/, // JS/TS
|
|
51
|
-
/(?:const|let|var)\s+(\w
|
|
52
|
-
/(?:async\s+)?(\w
|
|
71
|
+
/(?:const|let|var)\s+(\w{1,128})\s*=\s*(?:async\s+)?(?:\([^)]*\)|_)\s*=>/, // JS arrow
|
|
72
|
+
/(?:async\s+)?(\w{1,128})\s*\([^)]*\)\s*\{/, // JS method / Go func
|
|
53
73
|
/def\s+(\w+)/, // Python/Ruby
|
|
54
74
|
/func\s+(\w+)/, // Go/Swift
|
|
55
|
-
/(?:public|private|protected|static|override|virtual|abstract|internal)\s+\S
|
|
75
|
+
/(?:public|private|protected|static|override|virtual|abstract|internal)\s+\S{1,128}\s+(\w{1,128})\s*\(/, // Java/C#/Kotlin
|
|
56
76
|
/(?:public\s+)?function\s+(\w+)/, // PHP
|
|
57
77
|
];
|
|
58
78
|
|
|
79
|
+
// Second bound, on the INPUT rather than the patterns: a signature sits at the
|
|
80
|
+
// head of the edited hunk, so matching past the first 8 KB buys nothing and
|
|
81
|
+
// costs linearly. Belt to the caps' braces — it also bounds whatever pattern a
|
|
82
|
+
// future author adds to the array without reading the note above.
|
|
83
|
+
const scanned = oldStr.length > 8192 ? oldStr.slice(0, 8192) : oldStr;
|
|
84
|
+
|
|
59
85
|
let symbol = null;
|
|
60
86
|
for (const pat of fnPatterns) {
|
|
61
|
-
const m =
|
|
87
|
+
const m = scanned.match(pat);
|
|
62
88
|
if (m) {
|
|
63
89
|
// Find the first captured group
|
|
64
90
|
symbol = m[1] || m[2];
|
|
@@ -291,6 +291,20 @@ const { resolveProjectRoot } = require('./project-root');
|
|
|
291
291
|
// (the exact shape that would re-create the answered:false glob failure).
|
|
292
292
|
function rebaseRelativePaths(cmd, relPrefix, rootDir, exists = fs.existsSync) {
|
|
293
293
|
if (!cmd || typeof cmd !== 'string' || !relPrefix || !rootDir) return cmd;
|
|
294
|
+
// SEC-05 (audit 2026-08-29): one `exists()` syscall per surviving token, and
|
|
295
|
+
// this runs BEFORE every length gate in the file — `shouldHint`'s 1000-char
|
|
296
|
+
// sanity check (:159) and the 2000-char ones on the sed/tail extractors are all
|
|
297
|
+
// downstream of it, so the guard sat below the thing it was guarding. Measured
|
|
298
|
+
// with a counting stub: 100k tokens is 100,001 probes, 2.2 s of real
|
|
299
|
+
// `fs.existsSync` on this box, paid inside a BLOCKING PreToolUse hook.
|
|
300
|
+
//
|
|
301
|
+
// The bound is the loosest one the file already uses, so nothing that any
|
|
302
|
+
// downstream gate would still have processed changes behavior: a command this
|
|
303
|
+
// long is past the sed/tail extractors' limit and twice past `shouldHint`'s.
|
|
304
|
+
// Placed here rather than at the two call sites because both of them
|
|
305
|
+
// (`pre-grep-guide` runMain, `post-grep-inject` runMain) need it, and a guard
|
|
306
|
+
// that lives in the callers is one refactor away from being dropped.
|
|
307
|
+
if (cmd.length > 2000) return cmd;
|
|
294
308
|
const prefix = relPrefix.split(path.sep).join('/');
|
|
295
309
|
// Shell sits outside any known source dir (docs/, target/, …) — don't guess.
|
|
296
310
|
if (!SRC_PATH_TOKEN.test(prefix + '/')) return cmd;
|
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
node-version: '20'
|
|
36
36
|
- name: Build snapshot
|
|
37
37
|
run: |
|
|
38
|
-
npx -y -p @sdsrs/code-graph@0.
|
|
38
|
+
npx -y -p @sdsrs/code-graph@0.128.0 code-graph-mcp snapshot create --out snapshot.db
|
|
39
39
|
zstd -9 snapshot.db -o snapshot.db.zst
|
|
40
40
|
mv snapshot.db.zst "code-graph-snapshot-${GITHUB_SHA:0:7}.db.zst"
|
|
41
41
|
- name: Upload to release
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.128.0",
|
|
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.
|
|
39
|
-
"@sdsrs/code-graph-linux-arm64": "0.
|
|
40
|
-
"@sdsrs/code-graph-darwin-x64": "0.
|
|
41
|
-
"@sdsrs/code-graph-darwin-arm64": "0.
|
|
42
|
-
"@sdsrs/code-graph-win32-x64": "0.
|
|
38
|
+
"@sdsrs/code-graph-linux-x64": "0.128.0",
|
|
39
|
+
"@sdsrs/code-graph-linux-arm64": "0.128.0",
|
|
40
|
+
"@sdsrs/code-graph-darwin-x64": "0.128.0",
|
|
41
|
+
"@sdsrs/code-graph-darwin-arm64": "0.128.0",
|
|
42
|
+
"@sdsrs/code-graph-win32-x64": "0.128.0"
|
|
43
43
|
}
|
|
44
44
|
}
|