@sdsrs/code-graph 0.12.0 → 0.13.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.
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "sdsrs"
6
6
  },
7
- "version": "0.12.0",
7
+ "version": "0.13.0",
8
8
  "keywords": [
9
9
  "code-graph",
10
10
  "ast",
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+ const test = require('node:test');
3
+ const assert = require('node:assert/strict');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+ const { spawnSync } = require('child_process');
8
+
9
+ const { findBinary } = require('./find-binary');
10
+
11
+ test('incremental-index bails silently when cwd is not a git repo', (t) => {
12
+ const bin = findBinary();
13
+ if (!bin) {
14
+ // Binary not built — skip rather than fail; matches session-init.test.js convention.
15
+ return;
16
+ }
17
+ const tmpRoot = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'code-graph-no-git-')));
18
+ t.after(() => fs.rmSync(tmpRoot, { recursive: true, force: true }));
19
+
20
+ const result = spawnSync(bin, ['incremental-index', '--quiet'], {
21
+ cwd: tmpRoot,
22
+ timeout: 8000,
23
+ stdio: ['pipe', 'pipe', 'pipe'],
24
+ });
25
+ assert.equal(result.status, 0, `expected exit 0, got ${result.status}; stderr: ${result.stderr}`);
26
+ assert.equal(
27
+ fs.existsSync(path.join(tmpRoot, '.code-graph')),
28
+ false,
29
+ '.code-graph must not be created outside a git repo',
30
+ );
31
+ });
32
+
33
+ test('incremental-index runs inside a minimal git repo without creating stray state', (t) => {
34
+ const bin = findBinary();
35
+ if (!bin) return;
36
+ const tmpRoot = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'code-graph-git-')));
37
+ t.after(() => fs.rmSync(tmpRoot, { recursive: true, force: true }));
38
+
39
+ fs.mkdirSync(path.join(tmpRoot, '.git'));
40
+ const result = spawnSync(bin, ['incremental-index', '--quiet'], {
41
+ cwd: tmpRoot,
42
+ timeout: 8000,
43
+ stdio: ['pipe', 'pipe', 'pipe'],
44
+ });
45
+ assert.equal(result.status, 0, `expected exit 0, got ${result.status}; stderr: ${result.stderr}`);
46
+ // Index may or may not materialize for an empty repo; the contract is that the guard does NOT block this case.
47
+ });
@@ -30,7 +30,7 @@ type: reference
30
30
  |------|------|----------------|
31
31
  | "谁调用 X?" / "X 调了啥?" | `get_call_graph` / `callgraph X` | 替代 `grep "X("` |
32
32
  | "Y 模块长啥样?" | `module_overview` / `overview Y/` | 替代逐文件 Read |
33
- | "找做 Z 的代码"(概念) | `semantic_code_search` / `search "Z"` | 不知道精确名 |
33
+ | "找做 Z 的代码"(概念) | MCP `semantic_code_search`(RRF 混合);CLI `search`(纯 FTS5) | 不知道精确名;要向量召回走 MCP |
34
34
  | "返回 T 类型的函数" | `ast_search --returns T` | 结构化筛选 |
35
35
  | "X 在哪被引用?" | `find_references` / `refs X` | 含 callers/importers |
36
36
  | "看 X 的源码 / 签名" | `get_ast_node` / `show X` | `include_impact=true` 含影响面(替代 impact_analysis) |
@@ -76,7 +76,7 @@ type: reference
76
76
 
77
77
  ```
78
78
  code-graph-mcp grep "pattern" [path] # ripgrep + AST 上下文
79
- code-graph-mcp search "concept" # FTS5 语义搜索
79
+ code-graph-mcp search "concept" # FTS5(要混合检索走 MCP semantic_code_search)
80
80
  code-graph-mcp ast-search "q" --type fn # 结构化筛选
81
81
  code-graph-mcp map # 项目架构
82
82
  code-graph-mcp overview src/mcp/ # 模块总览
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdsrs/code-graph",
3
- "version": "0.12.0",
3
+ "version": "0.13.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": {
@@ -34,10 +34,10 @@
34
34
  "node": ">=16"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@sdsrs/code-graph-linux-x64": "0.12.0",
38
- "@sdsrs/code-graph-linux-arm64": "0.12.0",
39
- "@sdsrs/code-graph-darwin-x64": "0.12.0",
40
- "@sdsrs/code-graph-darwin-arm64": "0.12.0",
41
- "@sdsrs/code-graph-win32-x64": "0.12.0"
37
+ "@sdsrs/code-graph-linux-x64": "0.13.0",
38
+ "@sdsrs/code-graph-linux-arm64": "0.13.0",
39
+ "@sdsrs/code-graph-darwin-x64": "0.13.0",
40
+ "@sdsrs/code-graph-darwin-arm64": "0.13.0",
41
+ "@sdsrs/code-graph-win32-x64": "0.13.0"
42
42
  }
43
43
  }