Skip to content

Commit ab18389

Browse files
sdsrssclaude
andcommitted
feat(cli): stats subcommand + rebuild_index busy signal (v0.13.0)
Three changes driven by real-usage-data review of this repo's own `.code-graph/usage.jsonl`: 1. `code-graph-mcp stats` — new CLI subcommand that aggregates JSONL session metrics (per-tool counts, search totals, index activity). Running on this repo's 153-session, 570-call history surfaced the rebuild_index error pattern motivating change #2. Flags: `--last N`, `--json`. 5 new unit tests on the pure `aggregate_usage_jsonl` helper. 2. `rebuild_index` MCP tool: embedding-busy rejection now returns `Ok({status:"busy", retry_after_ms:2000})` instead of `Err`, matching `run_incremental_with_cache_restore`'s precedent and keeping the usage-metrics `err` counter from inflating on legitimate retry signals. **Contract change** — SDK clients must now distinguish busy success payloads from JSON-RPC errors; JSON-RPC errors on this tool now indicate real failures only. 3. `plugin_code_graph_mcp.md` template: CLI `search` (FTS5-only) and MCP `semantic_code_search` (RRF hybrid of FTS5 + vector) are no longer conflated — the core-7 decision table and CLI cheat sheet now state the difference explicitly. Adopted memory files auto-refresh on next SessionStart (v0.11.0+). Clippy 1.95 parity verified pre-push: `cargo +1.95.0 clippy --no-default-features -- -D warnings` ✓ `cargo +1.95.0 clippy --all-targets -- -D warnings` ✓ 235/235 lib tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4ff57ea commit ab18389

15 files changed

Lines changed: 391 additions & 21 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
},
66
"metadata": {
77
"description": "AST knowledge graph plugin for Claude Code — semantic search, call graph, HTTP tracing, impact analysis",
8-
"version": "0.12.1"
8+
"version": "0.13.0"
99
},
1010
"plugins": [
1111
{
1212
"name": "code-graph-mcp",
1313
"source": "./claude-plugin",
1414
"description": "AST knowledge graph for intelligent code navigation — auto-indexes your codebase and provides semantic search, call graph traversal, HTTP route tracing, and impact analysis via MCP tools",
15-
"version": "0.12.1",
15+
"version": "0.13.0",
1616
"author": {
1717
"name": "sdsrs"
1818
},

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# Changelog
22

3+
## v0.13.0 — `stats` CLI + rebuild_index busy semantics + CLI/MCP search disambiguation
4+
5+
Minor release. Three changes driven by real-usage-data review:
6+
7+
### `stats` subcommand (new)
8+
9+
`code-graph-mcp stats` aggregates `.code-graph/usage.jsonl` across sessions
10+
and prints per-tool counts (`n`, `avg_ms`, `err`, `max_ms`), search totals
11+
(queries, zero-result ratio, hybrid/FTS split, avg quality), and index
12+
activity (full vs incremental, avg full-rebuild time). Flags: `--last N`
13+
limits to the most recent N sessions, `--json` emits structured output.
14+
15+
Motivation: the metrics module has been writing JSONL for months (1MB
16+
rotation), but there was no reader. Running on this repo's own history
17+
surfaced the `rebuild_index` error pattern that motivates change #2.
18+
19+
### `rebuild_index` MCP tool — busy signal is no longer an error
20+
21+
When the server rejects a rebuild request because background embedding is
22+
still running, it now returns `Ok({status: "busy", retry_after_ms: 2000})`
23+
instead of `Err("Background embedding still in progress")`. This matches
24+
the precedent in `run_incremental_with_cache_restore` (which returns
25+
`Ok(())` on the same condition) and keeps the usage-metrics `err` counter
26+
from inflating on legitimate retry signals.
27+
28+
**Contract change** — SDK/script clients of the `rebuild_index` MCP tool
29+
must now distinguish `status: "busy"` success payloads from actual errors.
30+
JSON-RPC-level errors on `rebuild_index` now indicate real failures only
31+
(missing `confirm`, no project root, DB error).
32+
33+
### CLI ↔ MCP search disambiguation
34+
35+
`plugin_code_graph_mcp.md` template previously listed `search "Z"` and
36+
`semantic_code_search` as equivalent intents. They are not: the CLI
37+
`search` command is **FTS5-only** (`src/cli.rs:710``fts5_search`), while
38+
the MCP `semantic_code_search` tool performs **RRF fusion** of FTS5 + vector
39+
similarity (`src/mcp/server/tools.rs:42 → 101`). The template now states
40+
this explicitly in the core-7 decision table and the CLI cheat sheet.
41+
42+
Adopted memory files auto-refresh from the template on the next
43+
SessionStart (v0.11.0+ behavior).
44+
45+
### Clippy 1.95 parity
46+
47+
Four `clippy::manual_checked_ops` and one `clippy::unnecessary_sort_by`
48+
flagged by the 1.95 toolchain in the new `cmd_stats` code path are fixed
49+
before push (local baseline: `cargo +1.95.0 clippy --no-default-features
50+
-- -D warnings && cargo +1.95.0 clippy --all-targets -- -D warnings`,
51+
both green).
52+
353
## v0.12.1 — incremental-index skips non-project directories
454

555
Bugfix release: the PostToolUse `incremental-index` hook no longer creates

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "code-graph-mcp"
3-
version = "0.12.1"
3+
version = "0.13.0"
44
edition = "2021"
55

66
[features]

claude-plugin/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": {
55
"name": "sdsrs"
66
},
7-
"version": "0.12.1",
7+
"version": "0.13.0",
88
"keywords": [
99
"code-graph",
1010
"ast",

claude-plugin/templates/plugin_code_graph_mcp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type: reference
3030
|------|------|----------------|
3131
| "谁调用 X?" / "X 调了啥?" | `get_call_graph` / `callgraph X` | 替代 `grep "X("` |
3232
| "Y 模块长啥样?" | `module_overview` / `overview Y/` | 替代逐文件 Read |
33-
| "找做 Z 的代码"(概念) | `semantic_code_search` / `search "Z"` | 不知道精确名 |
33+
| "找做 Z 的代码"(概念) | MCP `semantic_code_search`(RRF 混合);CLI `search`(纯 FTS5) | 不知道精确名;要向量召回走 MCP |
3434
| "返回 T 类型的函数" | `ast_search --returns T` | 结构化筛选 |
3535
| "X 在哪被引用?" | `find_references` / `refs X` | 含 callers/importers |
3636
| "看 X 的源码 / 签名" | `get_ast_node` / `show X` | `include_impact=true` 含影响面(替代 impact_analysis) |
@@ -76,7 +76,7 @@ type: reference
7676

7777
```
7878
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)
8080
code-graph-mcp ast-search "q" --type fn # 结构化筛选
8181
code-graph-mcp map # 项目架构
8282
code-graph-mcp overview src/mcp/ # 模块总览

npm/darwin-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sdsrs/code-graph-darwin-arm64",
3-
"version": "0.12.1",
3+
"version": "0.13.0",
44
"description": "code-graph-mcp binary for macOS ARM64",
55
"license": "MIT",
66
"repository": {

npm/darwin-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sdsrs/code-graph-darwin-x64",
3-
"version": "0.12.1",
3+
"version": "0.13.0",
44
"description": "code-graph-mcp binary for macOS x64",
55
"license": "MIT",
66
"repository": {

npm/linux-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sdsrs/code-graph-linux-arm64",
3-
"version": "0.12.1",
3+
"version": "0.13.0",
44
"description": "code-graph-mcp binary for Linux ARM64",
55
"license": "MIT",
66
"repository": {

npm/linux-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sdsrs/code-graph-linux-x64",
3-
"version": "0.12.1",
3+
"version": "0.13.0",
44
"description": "code-graph-mcp binary for Linux x64",
55
"license": "MIT",
66
"repository": {

0 commit comments

Comments
 (0)