@sdsrs/code-graph 0.16.9 → 0.17.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.
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/scripts/adopt.js +17 -14
- package/claude-plugin/scripts/session-init.js +17 -7
- package/claude-plugin/scripts/session-init.test.js +32 -13
- package/claude-plugin/templates/plugin_code_graph_mcp.md +11 -4
- package/package.json +6 -6
|
@@ -23,17 +23,17 @@ function readAdoptedBy(filePath) {
|
|
|
23
23
|
return m ? m[1] : null;
|
|
24
24
|
} catch { return null; }
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
|
|
26
|
+
// One-liner per MEMORY.md spec ("each entry should be one line"). All routing
|
|
27
|
+
// triggers from prior multi-line block preserved verbatim — collapsing to single
|
|
28
|
+
// line is a structural fix, not a signal change. Decision table lives in the
|
|
29
|
+
// linked plugin_code_graph_mcp.md; this line is the router. Tag syntax
|
|
30
|
+
// `[tag1, tag2]` per spec for explicit keyword matching.
|
|
31
|
+
const INDEX_LINE =
|
|
32
|
+
'- [code-graph-mcp](plugin_code_graph_mcp.md) ' +
|
|
33
|
+
'[impact, callgraph, refs, overview, semantic, ast-search, dead-code, similar, deps, trace] — ' +
|
|
34
|
+
'改 X 影响面/谁调用 X/X 被谁用/看 X 源码/Y 模块长啥样/概念查询 优先于 Grep;字面匹配走 Grep。' +
|
|
35
|
+
'核心 7(get_call_graph/module_overview/semantic_code_search/ast_search/find_references/get_ast_node/project_map)' +
|
|
36
|
+
'+ 进阶 5(impact_analysis/trace_http_chain/dependency_graph/find_similar_code/find_dead_code),决策表见全文';
|
|
37
37
|
const TEMPLATE_PATH = path.resolve(__dirname, '..', 'templates', 'plugin_code_graph_mcp.md');
|
|
38
38
|
const TARGET_NAME = 'plugin_code_graph_mcp.md';
|
|
39
39
|
|
|
@@ -266,9 +266,12 @@ function formatResult(action, result) {
|
|
|
266
266
|
if (result.healed) lines.push(`[code-graph] Healed malformed sentinel block → ${result.indexPath}`);
|
|
267
267
|
else if (result.indexed) lines.push(`[code-graph] Indexed → ${result.indexPath}`);
|
|
268
268
|
else lines.push(`[code-graph] Index already up-to-date — no write`);
|
|
269
|
-
// v0.
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
// v0.17.0: SessionStart project_map injection is OFF by default (regardless
|
|
270
|
+
// of adoption). Adoption now only governs MEMORY.md sentinel + decision-table
|
|
271
|
+
// refresh; the noisy hook needs an explicit opt-in.
|
|
272
|
+
lines.push('[code-graph] Active. SessionStart project_map injection: OFF (default).');
|
|
273
|
+
lines.push('[code-graph] Opt in to map dump: CODE_GRAPH_VERBOSE_HOOKS=1');
|
|
274
|
+
lines.push('[code-graph] Legacy override: CODE_GRAPH_QUIET_HOOKS=0 (force noisy) / =1 (force quiet)');
|
|
272
275
|
return lines.join('\n');
|
|
273
276
|
}
|
|
274
277
|
if (action === 'unadopt') {
|
|
@@ -11,13 +11,22 @@ const {
|
|
|
11
11
|
const { readBinaryVersion, isDevMode, getNewestMtime } = require('./version-utils');
|
|
12
12
|
const { maybeAutoAdopt, isAdopted } = require('./adopt');
|
|
13
13
|
|
|
14
|
-
// v0.
|
|
15
|
-
//
|
|
16
|
-
|
|
14
|
+
// v0.17.0 — quietHooks: unconditional quiet 默认。
|
|
15
|
+
// 项目地图与 MEMORY.md plugin contract + on-demand `project_map` 工具高度重叠,
|
|
16
|
+
// 默认每次 SessionStart 都注入 ≈2.3 KB 是不必要的常驻上下文成本。
|
|
17
|
+
// 优先级(高到低):
|
|
18
|
+
// 1. legacy CODE_GRAPH_QUIET_HOOKS='0' → forced noisy(向后兼容)
|
|
19
|
+
// 2. legacy CODE_GRAPH_QUIET_HOOKS='1' → forced quiet(向后兼容)
|
|
20
|
+
// 3. CODE_GRAPH_VERBOSE_HOOKS='1' → opt-in noisy(新)
|
|
21
|
+
// 4. 默认 → quiet
|
|
22
|
+
// `adopted` 参数已弃用(unconditional 默认不再依赖该信号),保留接口签名只为
|
|
23
|
+
// 不破坏既有调用 / 测试。
|
|
24
|
+
function computeQuietHooks({ env = {} } = {}) {
|
|
17
25
|
const envQuiet = env.CODE_GRAPH_QUIET_HOOKS;
|
|
18
26
|
if (envQuiet === '0') return false;
|
|
19
27
|
if (envQuiet === '1') return true;
|
|
20
|
-
return
|
|
28
|
+
if (env.CODE_GRAPH_VERBOSE_HOOKS === '1') return false;
|
|
29
|
+
return true;
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
function launchBackgroundAutoUpdate(spawnFn = spawn, env = process.env) {
|
|
@@ -277,10 +286,11 @@ function runSessionInit() {
|
|
|
277
286
|
}
|
|
278
287
|
}
|
|
279
288
|
|
|
280
|
-
// quietHooks:
|
|
281
|
-
//
|
|
289
|
+
// quietHooks: default quiet (project_map injection duplicates MEMORY.md +
|
|
290
|
+
// on-demand tool). CODE_GRAPH_VERBOSE_HOOKS=1 to opt in to the dump;
|
|
291
|
+
// legacy CODE_GRAPH_QUIET_HOOKS=0/1 still force the old behavior.
|
|
282
292
|
const adopted = isAdopted();
|
|
283
|
-
const quietHooks = computeQuietHooks({
|
|
293
|
+
const quietHooks = computeQuietHooks({ env: process.env });
|
|
284
294
|
|
|
285
295
|
const mapInjected = binaryCheck.available && !quietHooks ? injectProjectMap() : false;
|
|
286
296
|
const consistencyIssues = binaryCheck.available
|
|
@@ -84,27 +84,46 @@ test('consistencyCheck returns empty array when binary version matches plugin',
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
// ──────────────────────────────────────────────────────────────────────────
|
|
87
|
-
// v0.
|
|
87
|
+
// v0.17.0 — quietHooks: unconditional quiet default
|
|
88
|
+
// Priority: legacy QUIET_HOOKS=0/1 > new VERBOSE_HOOKS=1 > default true.
|
|
89
|
+
// `adopted` param is dead (unconditional default does not consult it) but
|
|
90
|
+
// the destructured signature still accepts it for backward compat.
|
|
88
91
|
// ──────────────────────────────────────────────────────────────────────────
|
|
89
92
|
|
|
90
|
-
test('computeQuietHooks:
|
|
91
|
-
assert.equal(computeQuietHooks({
|
|
92
|
-
assert.equal(computeQuietHooks({ adopted: false, env: { CODE_GRAPH_QUIET_HOOKS: '0' } }), false);
|
|
93
|
+
test('computeQuietHooks: legacy QUIET_HOOKS="0" forces noisy', () => {
|
|
94
|
+
assert.equal(computeQuietHooks({ env: { CODE_GRAPH_QUIET_HOOKS: '0' } }), false);
|
|
93
95
|
});
|
|
94
96
|
|
|
95
|
-
test('computeQuietHooks:
|
|
96
|
-
assert.equal(computeQuietHooks({
|
|
97
|
-
assert.equal(computeQuietHooks({ adopted: false, env: { CODE_GRAPH_QUIET_HOOKS: '1' } }), true);
|
|
97
|
+
test('computeQuietHooks: legacy QUIET_HOOKS="1" forces quiet', () => {
|
|
98
|
+
assert.equal(computeQuietHooks({ env: { CODE_GRAPH_QUIET_HOOKS: '1' } }), true);
|
|
98
99
|
});
|
|
99
100
|
|
|
100
|
-
test('computeQuietHooks:
|
|
101
|
-
assert.equal(computeQuietHooks({
|
|
102
|
-
|
|
101
|
+
test('computeQuietHooks: VERBOSE_HOOKS="1" opts in to noisy', () => {
|
|
102
|
+
assert.equal(computeQuietHooks({ env: { CODE_GRAPH_VERBOSE_HOOKS: '1' } }), false);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('computeQuietHooks: legacy QUIET_HOOKS="1" wins over VERBOSE_HOOKS="1"', () => {
|
|
106
|
+
// Conflicting opt-ins: legacy explicit-quiet wins over new verbose opt-in.
|
|
107
|
+
// (Legacy QUIET_HOOKS="0" + VERBOSE_HOOKS="1" both mean noisy — no conflict.)
|
|
108
|
+
assert.equal(
|
|
109
|
+
computeQuietHooks({ env: { CODE_GRAPH_QUIET_HOOKS: '1', CODE_GRAPH_VERBOSE_HOOKS: '1' } }),
|
|
110
|
+
true
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('computeQuietHooks: env unset → quiet by default', () => {
|
|
115
|
+
assert.equal(computeQuietHooks({ env: {} }), true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('computeQuietHooks: no args → quiet by default', () => {
|
|
119
|
+
assert.equal(computeQuietHooks(), true);
|
|
103
120
|
});
|
|
104
121
|
|
|
105
|
-
test('computeQuietHooks:
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
test('computeQuietHooks: legacy `adopted` param is ignored under new default', () => {
|
|
123
|
+
// adopted=true used to imply quiet; now quiet is unconditional.
|
|
124
|
+
// adopted=false used to imply noisy; now still quiet by default.
|
|
125
|
+
assert.equal(computeQuietHooks({ adopted: true, env: {} }), true);
|
|
126
|
+
assert.equal(computeQuietHooks({ adopted: false, env: {} }), true);
|
|
108
127
|
});
|
|
109
128
|
|
|
110
129
|
test('consistencyCheck returns version-mismatch when versions differ', (t) => {
|
|
@@ -8,13 +8,19 @@ type: reference
|
|
|
8
8
|
> Invited-memory 模式:MCP `instructions` 仅留指针,决策细则集中在此。
|
|
9
9
|
>
|
|
10
10
|
> **v0.9.0 起**:插件(`/plugin install`)模式下首次 SessionStart 自动 adopt,
|
|
11
|
-
>
|
|
11
|
+
> 本文件自动写入到项目 memory 目录。
|
|
12
12
|
> 退出:`CODE_GRAPH_NO_AUTO_ADOPT=1` 阻止,`code-graph-mcp unadopt` 回退。
|
|
13
|
-
> 手动强控:`CODE_GRAPH_QUIET_HOOKS=0` 强制注入 / `=1` 强制静默(覆盖 adoption 推导)。
|
|
14
13
|
>
|
|
15
14
|
> **v0.11.0 起**:已 adopt 的项目在下次 SessionStart 会自动对齐到插件 shipped
|
|
16
15
|
> 的最新决策表(本文件 SHA 与 template 差异时覆盖)。手动编辑会被覆盖——
|
|
17
16
|
> 要锁定自己的版本,设 `CODE_GRAPH_NO_TEMPLATE_REFRESH=1`(不影响首次 adopt)。
|
|
17
|
+
>
|
|
18
|
+
> **v0.17.0 起**:SessionStart `project_map` 注入 **默认 OFF**(不再随 adoption
|
|
19
|
+
> 切换)。本文件 + 7 个工具描述已经覆盖路由所需的全部决策信息,每次会话再
|
|
20
|
+
> dump ≈2.3 KB 的项目地图是冗余的常驻上下文成本。
|
|
21
|
+
> 显式启用:`CODE_GRAPH_VERBOSE_HOOKS=1` —— Bash 调 `code-graph-mcp map --compact`
|
|
22
|
+
> 也是等价的按需替代。
|
|
23
|
+
> 向后兼容:`CODE_GRAPH_QUIET_HOOKS=0` 强制 noisy / `=1` 强制 quiet(优先级最高)。
|
|
18
24
|
|
|
19
25
|
## 何时调用 MCP/CLI(替代多步 Grep/Read)
|
|
20
26
|
|
|
@@ -100,7 +106,8 @@ code-graph-mcp health-check # 索引健康
|
|
|
100
106
|
|
|
101
107
|
## 卸载 / 回退
|
|
102
108
|
|
|
103
|
-
- `code-graph-mcp unadopt` — 精确移除 sentinel 段 +
|
|
109
|
+
- `code-graph-mcp unadopt` — 精确移除 sentinel 段 + 本文件。
|
|
104
110
|
- `CODE_GRAPH_NO_AUTO_ADOPT=1`(`~/.claude/settings.json` env) — 阻止未来自动 adopt,不影响已 adopted 状态。
|
|
105
111
|
- `CODE_GRAPH_NO_TEMPLATE_REFRESH=1`(v0.11.0+) — 锁定本文件不随插件升级刷新;允许手动编辑长久保留。
|
|
106
|
-
- `
|
|
112
|
+
- `CODE_GRAPH_VERBOSE_HOOKS=1`(v0.17.0+) — opt in 到 SessionStart `project_map` 注入(默认 OFF)。
|
|
113
|
+
- `CODE_GRAPH_QUIET_HOOKS=0` — 强制恢复 `project_map` 注入;优先级高于 VERBOSE_HOOKS(向后兼容路径)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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.
|
|
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.17.1",
|
|
39
|
+
"@sdsrs/code-graph-linux-arm64": "0.17.1",
|
|
40
|
+
"@sdsrs/code-graph-darwin-x64": "0.17.1",
|
|
41
|
+
"@sdsrs/code-graph-darwin-arm64": "0.17.1",
|
|
42
|
+
"@sdsrs/code-graph-win32-x64": "0.17.1"
|
|
43
43
|
}
|
|
44
44
|
}
|