diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 70b1ed6bd..d96cd0369 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -27,13 +27,13 @@ Always prefer `codegraph` tools for **structural** questions — tracing call hi | Intent / Question | Recommended MCP Tool | | :--- | :--- | -| *"Where is symbol X defined?"* | `codegraph_search` | +| *"Where is symbol X defined?"* | `codegraph_search_symbol` | | *"What callers invoke function Y?"* | `codegraph_callers` | | *"What methods or functions does Y call?"* | `codegraph_callees` | | *"What components or files will break if I modify Z?"* | `codegraph_impact` | -| *"Show me Y's exact signature and internal block"* | `codegraph_node` | +| *"Show me Y's exact signature and internal block"* | `codegraph_symbol` | | *"Give me focused, aggregated context for this task"* | `codegraph_context` | -| *"What files exist under a specific path/ directory?"* | `codegraph_files` | +| *"What files exist under a specific path/ directory?"* | `codegraph_graphcode_files` | | *"Is the local knowledge graph healthy and active?"* | `codegraph_status` | --- diff --git a/Cargo.lock b/Cargo.lock index f96387d15..189c67426 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -720,7 +720,7 @@ checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "codegraph" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "camino", @@ -743,7 +743,7 @@ dependencies = [ [[package]] name = "codegraph-api" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "camino", @@ -760,7 +760,7 @@ dependencies = [ [[package]] name = "codegraph-bench" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "camino", @@ -778,7 +778,7 @@ dependencies = [ [[package]] name = "codegraph-binary" -version = "2.2.0" +version = "2.2.1" dependencies = [ "camino", "codegraph-core", @@ -795,7 +795,7 @@ dependencies = [ [[package]] name = "codegraph-context" -version = "2.2.0" +version = "2.2.1" dependencies = [ "codegraph-core", "codegraph-graph", @@ -807,7 +807,7 @@ dependencies = [ [[package]] name = "codegraph-core" -version = "2.2.0" +version = "2.2.1" dependencies = [ "async-graphql", "camino", @@ -818,7 +818,7 @@ dependencies = [ [[package]] name = "codegraph-docs" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "codegraph-core", @@ -835,7 +835,7 @@ dependencies = [ [[package]] name = "codegraph-extract" -version = "2.2.0" +version = "2.2.1" dependencies = [ "camino", "codegraph-binary", @@ -874,7 +874,7 @@ dependencies = [ [[package]] name = "codegraph-graph" -version = "2.2.0" +version = "2.2.1" dependencies = [ "async-trait", "bincode", @@ -904,7 +904,7 @@ dependencies = [ [[package]] name = "codegraph-graphql" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "async-graphql", @@ -927,7 +927,7 @@ dependencies = [ [[package]] name = "codegraph-installer" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "camino", @@ -943,7 +943,7 @@ dependencies = [ [[package]] name = "codegraph-mcp" -version = "2.2.0" +version = "2.2.1" dependencies = [ "anyhow", "axum", @@ -966,7 +966,7 @@ dependencies = [ [[package]] name = "codegraph-sboxes" -version = "2.2.0" +version = "2.2.1" dependencies = [ "camino", "codegraph-core", diff --git a/Cargo.toml b/Cargo.toml index 9b11c74ff..021e59ff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ ] [workspace.package] -version = "2.2.0" +version = "2.2.1" edition = "2021" rust-version = "1.80" license = "MIT" diff --git a/crates/codegraph-api/src/lib.rs b/crates/codegraph-api/src/lib.rs index d0bf675dc..3ec3af551 100644 --- a/crates/codegraph-api/src/lib.rs +++ b/crates/codegraph-api/src/lib.rs @@ -39,7 +39,7 @@ pub const TIMEOUT_EXPIRE_IMMEDIATELY: u64 = u64::MAX; // ==================== Search session store ==================== /// Loại search tạo resume — dùng validate resume id (không cho cross-tool -/// resume: id của `codegraph_search` không dùng được cho `codegraph_references`). +/// resume: id của `codegraph_search_symbol` không dùng được cho `codegraph_references`). #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ResumeKind { Name, diff --git a/crates/codegraph-api/src/tools.rs b/crates/codegraph-api/src/tools.rs index bf9095749..bcc3e95a1 100644 --- a/crates/codegraph-api/src/tools.rs +++ b/crates/codegraph-api/src/tools.rs @@ -447,7 +447,7 @@ pub async fn dispatch_diff_simulate( let delta = sequence_delta(&before, &after); Ok::(json!({ "draft": true, - "tool": "codegraph_diff_simulate", + "tool": "codegraph_graphcode_diff_simulate", "entry": entry, "args": call_args, "base_ref": base_ref, @@ -494,7 +494,7 @@ pub async fn dispatch_origin_simulate( let delta = sequence_delta(&origin, &working_tree); Ok::(json!({ "draft": true, - "tool": "codegraph_origin_simulate", + "tool": "codegraph_graphcode_origin_simulate", "entry": entry, "args": call_args, "ref": git_ref, diff --git a/crates/codegraph-graphql/src/mutation.rs b/crates/codegraph-graphql/src/mutation.rs index bc52bd662..126a34f1a 100644 --- a/crates/codegraph-graphql/src/mutation.rs +++ b/crates/codegraph-graphql/src/mutation.rs @@ -89,7 +89,7 @@ impl Mutation { /// Sandbox một flow function (compile + run với Rhai mocks). /// `args: JSON` = `{ node?, name?, args?: [i64], mocks?: {callee: rhai}, branchPolicy?, loopCap? }`. - async fn sandbox(&self, ctx: &Context<'_>, args: Value) -> GqlResult { + async fn graphcode_sandbox(&self, ctx: &Context<'_>, args: Value) -> GqlResult { let state = ctx.data::>()?; let sgi = state .session @@ -108,7 +108,7 @@ impl Mutation { /// Diff → draft report (symbols/flows chạm vào unified diff). /// `args: JSON` = `{ diff: "...", entry?, baseRef?, ... }`. - async fn diff(&self, ctx: &Context<'_>, args: Value) -> GqlResult { + async fn graphcode_diff(&self, ctx: &Context<'_>, args: Value) -> GqlResult { let state = ctx.data::>()?; let sgi = state .session @@ -127,7 +127,7 @@ impl Mutation { /// Diff → simulate: so sánh trace sandbox trước/sau MR. `args: JSON` = /// `{ diff, entry?, baseRef?, args?, mocks?, branchPolicy?, loopCap? }`. - async fn diff_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult { + async fn graphcode_diff_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult { let state = ctx.data::>()?; let sgi = state .session @@ -146,7 +146,7 @@ impl Mutation { /// Ref → simulate: so sánh trace trên `git archive ` vs working tree. /// `args: JSON` = `{ entry, ref?, args?, mocks?, branchPolicy?, loopCap? }`. - async fn origin_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult { + async fn graphcode_origin_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult { let state = ctx.data::>()?; let sgi = state .session @@ -166,7 +166,7 @@ impl Mutation { // ── Document mutations ── /// Ingest a document file into the document graph. - async fn doc_ingest( + async fn graphdoc_ingest( &self, ctx: &Context<'_>, path: String, @@ -221,7 +221,7 @@ impl Mutation { } /// Search document nodes. - async fn doc_search( + async fn graphdoc_search( &self, ctx: &Context<'_>, _pattern: String, @@ -247,7 +247,7 @@ impl Mutation { } /// Get document stats. - async fn doc_stats(&self, ctx: &Context<'_>) -> GqlResult { + async fn graphdoc_stats(&self, ctx: &Context<'_>) -> GqlResult { let state = ctx.data::>()?; let stats = state .doc_graph diff --git a/crates/codegraph-graphql/src/query.rs b/crates/codegraph-graphql/src/query.rs index 393543d39..391fb8918 100644 --- a/crates/codegraph-graphql/src/query.rs +++ b/crates/codegraph-graphql/src/query.rs @@ -267,7 +267,11 @@ impl Query { // ── Class / scope / files ── /// Files trong graph, filter theo prefix đường dẫn. - async fn files(&self, ctx: &Context<'_>, prefix: Option) -> GqlResult> { + async fn graphcode_files( + &self, + ctx: &Context<'_>, + prefix: Option, + ) -> GqlResult> { let prefix = prefix.unwrap_or_default(); Ok(api_for(ctx).await?.files(&prefix).await) } @@ -278,14 +282,14 @@ impl Query { } /// Class info: symbol + fields + methods. - async fn class(&self, ctx: &Context<'_>, id: ID) -> GqlResult> { + async fn graphcode_class(&self, ctx: &Context<'_>, id: ID) -> GqlResult> { let id = parse_id(&id)?; Ok(api_for(ctx).await?.class_info(id).await) } /// Liệt kê symbol theo kind (CLASS / INTERFACE / ENUM), phân trang. Gộp cũ /// `list_classes` / `list_interfaces` / `list_enums` thành 1 resolver. - async fn types( + async fn graphcode_list_types( &self, ctx: &Context<'_>, kind: TypeKind, @@ -308,7 +312,11 @@ impl Query { } /// Scope của function (parameters + locals). - async fn function_scope(&self, ctx: &Context<'_>, id: ID) -> GqlResult> { + async fn graphcode_function_scope( + &self, + ctx: &Context<'_>, + id: ID, + ) -> GqlResult> { let id = parse_id(&id)?; Ok(api_for(ctx).await?.function_scope(id).await) } @@ -316,7 +324,7 @@ impl Query { // ── Annotations / dependencies ── /// Tìm symbol theo annotation (vd `@Override`, `@Cacheable`). - async fn search_by_annotation( + async fn graphcode_search_by_annotation( &self, ctx: &Context<'_>, annotation: String, @@ -337,14 +345,14 @@ impl Query { } /// Dependencies ước lượng từ call names (internal/external/total). - async fn dependencies(&self, ctx: &Context<'_>) -> GqlResult { + async fn graphcode_dependencies(&self, ctx: &Context<'_>) -> GqlResult { Ok(api_for(ctx).await?.dependencies().await) } // ── Document queries ── /// List all documents in the document graph. - async fn doc_list(&self, ctx: &Context<'_>) -> GqlResult> { + async fn graphdoc_list(&self, ctx: &Context<'_>) -> GqlResult> { let state = ctx.data::>()?; let stats = state .doc_graph @@ -360,7 +368,7 @@ impl Query { } /// Search document nodes by pattern string. - async fn doc_search( + async fn graphdoc_search( &self, ctx: &Context<'_>, _pattern: String, diff --git a/crates/codegraph-installer/src/instructions-template.md b/crates/codegraph-installer/src/instructions-template.md index cc5111c1c..a5dca1f01 100644 --- a/crates/codegraph-installer/src/instructions-template.md +++ b/crates/codegraph-installer/src/instructions-template.md @@ -12,13 +12,13 @@ for literal text queries. | Question | Tool | |---|---| -| "Where is X defined?" | `codegraph_search` | +| "Where is X defined?" | `codegraph_search_symbol` | | "What calls Y?" | `codegraph_callers` | | "What does Y call?" | `codegraph_callees` | | "What would break if I changed Z?" | `codegraph_impact` | -| "Show me Y's signature / source" | `codegraph_node` | +| "Show me Y's signature / source" | `codegraph_symbol` | | "Give me focused context for a task" | `codegraph_context` | -| "What files exist under path/" | `codegraph_files` | +| "What files exist under path/" | `codegraph_graphcode_files` | | "Is the index healthy?" | `codegraph_status` | ## Rules of thumb diff --git a/crates/codegraph-installer/src/targets/antigravity.rs b/crates/codegraph-installer/src/targets/antigravity.rs index 1eedc801f..765c668bb 100644 --- a/crates/codegraph-installer/src/targets/antigravity.rs +++ b/crates/codegraph-installer/src/targets/antigravity.rs @@ -181,13 +181,13 @@ Always prefer `codegraph` tools for **structural** questions — tracing call hi | Intent / Question | Recommended MCP Tool | | :--- | :--- | -| *"Where is symbol X defined?"* | `codegraph_search` | +| *"Where is symbol X defined?"* | `codegraph_search_symbol` | | *"What callers invoke function Y?"* | `codegraph_callers` | | *"What methods or functions does Y call?"* | `codegraph_callees` | | *"What components or files will break if I modify Z?"* | `codegraph_impact` | -| *"Show me Y's exact signature and internal block"* | `codegraph_node` | +| *"Show me Y's exact signature and internal block"* | `codegraph_symbol` | | *"Give me focused, aggregated context for this task"* | `codegraph_context` | -| *"What files exist under a specific path/ directory?"* | `codegraph_files` | +| *"What files exist under a specific path/ directory?"* | `codegraph_graphcode_files` | | *"Is the local knowledge graph healthy and active?"* | `codegraph_status` | --- diff --git a/crates/codegraph-mcp/src/tools.rs b/crates/codegraph-mcp/src/tools.rs index b58b5d31d..582ebfe45 100644 --- a/crates/codegraph-mcp/src/tools.rs +++ b/crates/codegraph-mcp/src/tools.rs @@ -251,7 +251,7 @@ fn tool_defs() -> Vec { "codegraph_graphcode_sandbox", "Run a sandbox simulation of a function's flow: compile the entry function + its in-flow callees into machine code (Cranelift JIT) and run it with Rhai mocks. `mocks` maps a callee name to a Rhai body (auto-wrapped into `fn (args) { … }` where `args` is the call's i64 array) or a full `fn (args) { … }` script; inline mocks override `[sandbox].mock_dirs` files. Before compiling, every callee that will be mock-dispatched must have a mock (file or `mocks`); if any is unconfigured the call fails with `link failed: no mock configured for callee(s): …`. Returns the entry return value, the ordered mock invocations, control-flow decisions (if/loop/switch taken/skipped), and any callees that still ran without a mock (`missing_mocks`).", json!({ "type": "object", "properties": { - "node": { "type": "integer", "description": "Entry function symbol id (from codegraph_search / codegraph_flow)." }, + "node": { "type": "integer", "description": "Entry function symbol id (from codegraph_search_symbol / codegraph_flow)." }, "name": { "type": "string", "description": "Entry function name (substring → first function match); used when node is omitted." }, "args": { "type": "array", "items": { "type": "integer" }, "description": "Abstract i64 arguments passed to the entry function." }, "mocks": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Callee name → Rhai mock body or full `fn` source." }, diff --git a/crates/codegraph/src/main.rs b/crates/codegraph/src/main.rs index 02c462351..825f76bb6 100644 --- a/crates/codegraph/src/main.rs +++ b/crates/codegraph/src/main.rs @@ -10,7 +10,7 @@ use std::sync::Arc; use codegraph_graph::embeddings::warm_model_cache; /// CLI tối giản: chỉ còn lifecycle (`init`/`deinit`) + MCP server (`serve --mcp`). -/// Mọi query/interact đi qua MCP tools (`codegraph_search`, `codegraph_context`, +/// Mọi query/interact đi qua MCP tools (`codegraph_search_symbol`, `codegraph_context`, /// `codegraph_status`, …) — CLI không lặp lại các lệnh đọc index nữa. #[derive(Parser, Debug)] #[command( diff --git a/docs/specs/07-mcp-server.md b/docs/specs/07-mcp-server.md index 86f94ebc4..79a5524d1 100644 --- a/docs/specs/07-mcp-server.md +++ b/docs/specs/07-mcp-server.md @@ -21,14 +21,13 @@ Serveur MCP minimaliste sur stdio. Pas de SDK Rust officiel mature → hand-roll | Nom MCP | Handler | Args | |---|---|---| -| `codegraph_search` | `db.search_nodes` | `{ query, limit?, kind? }` | -| `codegraph_node` | `db.node_by_id` ou by_name | `{ id?, name? }` | +| `codegraph_search_symbol` | `db.search_nodes` | `{ query, limit?, kind? }` | +| `codegraph_symbol` | `db.node_by_id` ou by_name | `{ id?, name? }` | | `codegraph_callers` | `traversal.callers` | `{ node, depth? }` | | `codegraph_callees` | `traversal.callees` | `{ node, depth? }` | | `codegraph_impact` | `traversal.impact_radius` | `{ node, max_depth? }` | | `codegraph_context` | `context::build` | `{ query, depth?, include_source?, format? }` | -| `codegraph_explore` | `context::explore` | `{ paths[], depth? }` | -| `codegraph_files` | `db.files_under` | `{ path? }` | +| `codegraph_graphcode_files` | `db.files_under` | `{ path? }` | | `codegraph_status` | `db.stats` | `{}` | Chaque tool a un JSON Schema `inputSchema` exposé dans `tools/list`. @@ -69,7 +68,7 @@ JSON-RPC 2.0 standard: ## Tests -- Integration: spawn `codegraph serve --mcp` sur fixture indexé, écris séquence `initialize` → `tools/call codegraph_search`, assert response. +- Integration: spawn `codegraph serve --mcp` sur fixture indexé, écris séquence `initialize` → `tools/call codegraph_search_symbol`, assert response. - Pas de SDK client — fabrique requêtes JSON à la main. ## Pièges diff --git a/packaging/aur/codegraph-rs-bin/PKGBUILD b/packaging/aur/codegraph-rs-bin/PKGBUILD index b19d65bbb..a9a91060e 100644 --- a/packaging/aur/codegraph-rs-bin/PKGBUILD +++ b/packaging/aur/codegraph-rs-bin/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Hung Pham pkgname=codegraph-rs-bin -pkgver=2.2.0 +pkgver=2.2.1 pkgrel=1 pkgdesc="Local-first code intelligence: tree-sitter knowledge graph + MCP server (prebuilt binary)" arch=('x86_64' 'aarch64') diff --git a/packaging/choco/codegraph.nuspec b/packaging/choco/codegraph.nuspec index 98623bfb0..07bd9593c 100644 --- a/packaging/choco/codegraph.nuspec +++ b/packaging/choco/codegraph.nuspec @@ -2,7 +2,7 @@ codegraph - 2.2.0 + 2.2.1 codegraph Hung Pham https://github.com/hungpham10/codegraph-rs diff --git a/packaging/winget/codegraph.yaml b/packaging/winget/codegraph.yaml index 7d550b840..01448faab 100644 --- a/packaging/winget/codegraph.yaml +++ b/packaging/winget/codegraph.yaml @@ -6,7 +6,7 @@ # release time (or automate it in the release pipeline before submitting to # microsoft/winget-pkgs). PackageIdentifier: hungpham10.codegraph -PackageVersion: 2.2.0 +PackageVersion: 2.2.1 PackageName: codegraph Publisher: Hung Pham PublisherUrl: https://github.com/hungpham10/codegraph-rs @@ -18,7 +18,7 @@ PackageUrl: https://github.com/hungpham10/codegraph-rs InstallerType: zip Installers: - Architecture: x64 - InstallerUrl: https://github.com/hungpham10/codegraph-rs/releases/download/v2.2.0/codegraph-x86_64-pc-windows-msvc.zip + InstallerUrl: https://github.com/hungpham10/codegraph-rs/releases/download/v2.2.1/codegraph-x86_64-pc-windows-msvc.zip InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000 InstallerType: zip ManifestType: singleton diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 0d9804718..29344405b 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -5,11 +5,11 @@ # # Usage (pin a version / download the script first): # irm https://raw.githubusercontent.com/hungpham10/codegraph-rs/main/scripts/install.ps1 -OutFile install.ps1 -# .\install.ps1 -Version 2.2.0 +# .\install.ps1 -Version 2.2.1 [CmdletBinding()] param( - # Pin a specific version, e.g. "2.2.0". Empty = latest release. + # Pin a specific version, e.g. "2.2.1". Empty = latest release. [string]$Version )