@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.
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "sdsrs"
6
6
  },
7
- "version": "0.16.9",
7
+ "version": "0.17.1",
8
8
  "keywords": [
9
9
  "code-graph",
10
10
  "ast",
@@ -23,17 +23,17 @@ function readAdoptedBy(filePath) {
23
23
  return m ? m[1] : null;
24
24
  } catch { return null; }
25
25
  }
26
- const INDEX_LINE = [
27
- '- [code-graph-mcp](plugin_code_graph_mcp.md) v0.10.0 tools/list 默认 7 核心 + 5 隐藏可调(省启动 token)',
28
- ' - 核心 7(默认暴露):`get_call_graph`/`module_overview`/`semantic_code_search`/`ast_search`/`find_references`/`get_ast_node`/`project_map`',
29
- ' - 进阶 5(隐藏按名可调):`impact_analysis`/`trace_http_chain`/`dependency_graph`/`find_similar_code`/`find_dead_code`',
30
- ' - 场景速查(优先于 Grep):',
31
- ' - X 影响面 → `get_ast_node symbol=X include_impact=true`(或 CLI `code-graph-mcp impact X`)',
32
- ' - 谁调用 X / X 被谁用 → `get_call_graph X` 或 `find_references X`',
33
- ' - X 源码 / 签名 `get_ast_node symbol=X`',
34
- ' - Y 模块长啥样 `module_overview` CLI `code-graph-mcp overview Y/`',
35
- ' - 概念查询(不知精确名)→ `semantic_code_search "Z"`;字面匹配用 Grep',
36
- ].join('\n');
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.9.0: adoption auto-implies quietHooks; no env var needed for the common case.
270
- lines.push('[code-graph] Active quietHooks auto-enabled via adopted state.');
271
- lines.push('[code-graph] Force inject: CODE_GRAPH_QUIET_HOOKS=0 Force silent: =1');
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.9.0 — quietHooks 推导:显式 env override > adopted 状态。
15
- // CODE_GRAPH_QUIET_HOOKS='0' 强制 noisy;'1' 强制 quiet;未设 跟随 adopted。
16
- function computeQuietHooks({ adopted, env = {} } = {}) {
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 !!adopted;
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: adopted quiet by default (rely on MEMORY.md pointer + on-demand
281
- // project_map tool); env '1'/'0' overrides for explicit control.
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({ adopted, env: process.env });
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.9.0 — quietHooks inference from adopted state
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: env "0" forces noisy regardless of adoption', () => {
91
- assert.equal(computeQuietHooks({ adopted: true, env: { CODE_GRAPH_QUIET_HOOKS: '0' } }), false);
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: env "1" forces quiet regardless of adoption', () => {
96
- assert.equal(computeQuietHooks({ adopted: true, env: { CODE_GRAPH_QUIET_HOOKS: '1' } }), true);
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: env unset follows adopted state', () => {
101
- assert.equal(computeQuietHooks({ adopted: true, env: {} }), true);
102
- assert.equal(computeQuietHooks({ adopted: false, env: {} }), false);
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: env unset, no env arg follows adopted state', () => {
106
- assert.equal(computeQuietHooks({ adopted: true }), true);
107
- assert.equal(computeQuietHooks({ adopted: false }), false);
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
- > 本文件自动写入,自动切换 quietHooks(跳过每次 project_map 注入)。
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 段 + 本文件,quietHooks 自动回到 false(下次 SessionStart 恢复 project_map 注入)。
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
- - `CODE_GRAPH_QUIET_HOOKS=0`强制恢复 project_map 注入(即使已 adopted)。
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.16.9",
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.16.9",
39
- "@sdsrs/code-graph-linux-arm64": "0.16.9",
40
- "@sdsrs/code-graph-darwin-x64": "0.16.9",
41
- "@sdsrs/code-graph-darwin-arm64": "0.16.9",
42
- "@sdsrs/code-graph-win32-x64": "0.16.9"
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
  }