Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .agents/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |

---
Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ members = [
]

[workspace.package]
version = "2.2.0"
version = "2.2.1"
edition = "2021"
rust-version = "1.80"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion crates/codegraph-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/codegraph-api/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ pub async fn dispatch_diff_simulate(
let delta = sequence_delta(&before, &after);
Ok::<Value, Error>(json!({
"draft": true,
"tool": "codegraph_diff_simulate",
"tool": "codegraph_graphcode_diff_simulate",
"entry": entry,
"args": call_args,
"base_ref": base_ref,
Expand Down Expand Up @@ -494,7 +494,7 @@ pub async fn dispatch_origin_simulate(
let delta = sequence_delta(&origin, &working_tree);
Ok::<Value, Error>(json!({
"draft": true,
"tool": "codegraph_origin_simulate",
"tool": "codegraph_graphcode_origin_simulate",
"entry": entry,
"args": call_args,
"ref": git_ref,
Expand Down
14 changes: 7 additions & 7 deletions crates/codegraph-graphql/src/mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
async fn graphcode_sandbox(&self, ctx: &Context<'_>, args: Value) -> GqlResult<String> {
let state = ctx.data::<Arc<AppState>>()?;
let sgi = state
.session
Expand All @@ -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<String> {
async fn graphcode_diff(&self, ctx: &Context<'_>, args: Value) -> GqlResult<String> {
let state = ctx.data::<Arc<AppState>>()?;
let sgi = state
.session
Expand All @@ -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<String> {
async fn graphcode_diff_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult<String> {
let state = ctx.data::<Arc<AppState>>()?;
let sgi = state
.session
Expand All @@ -146,7 +146,7 @@ impl Mutation {

/// Ref → simulate: so sánh trace trên `git archive <ref>` vs working tree.
/// `args: JSON` = `{ entry, ref?, args?, mocks?, branchPolicy?, loopCap? }`.
async fn origin_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult<String> {
async fn graphcode_origin_simulate(&self, ctx: &Context<'_>, args: Value) -> GqlResult<String> {
let state = ctx.data::<Arc<AppState>>()?;
let sgi = state
.session
Expand All @@ -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,
Expand Down Expand Up @@ -221,7 +221,7 @@ impl Mutation {
}

/// Search document nodes.
async fn doc_search(
async fn graphdoc_search(
&self,
ctx: &Context<'_>,
_pattern: String,
Expand All @@ -247,7 +247,7 @@ impl Mutation {
}

/// Get document stats.
async fn doc_stats(&self, ctx: &Context<'_>) -> GqlResult<String> {
async fn graphdoc_stats(&self, ctx: &Context<'_>) -> GqlResult<String> {
let state = ctx.data::<Arc<AppState>>()?;
let stats = state
.doc_graph
Expand Down
24 changes: 16 additions & 8 deletions crates/codegraph-graphql/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) -> GqlResult<Vec<FileInfo>> {
async fn graphcode_files(
&self,
ctx: &Context<'_>,
prefix: Option<String>,
) -> GqlResult<Vec<FileInfo>> {
let prefix = prefix.unwrap_or_default();
Ok(api_for(ctx).await?.files(&prefix).await)
}
Expand All @@ -278,14 +282,14 @@ impl Query {
}

/// Class info: symbol + fields + methods.
async fn class(&self, ctx: &Context<'_>, id: ID) -> GqlResult<Option<ClassInfo>> {
async fn graphcode_class(&self, ctx: &Context<'_>, id: ID) -> GqlResult<Option<ClassInfo>> {
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,
Expand All @@ -308,15 +312,19 @@ impl Query {
}

/// Scope của function (parameters + locals).
async fn function_scope(&self, ctx: &Context<'_>, id: ID) -> GqlResult<Option<FunctionScope>> {
async fn graphcode_function_scope(
&self,
ctx: &Context<'_>,
id: ID,
) -> GqlResult<Option<FunctionScope>> {
let id = parse_id(&id)?;
Ok(api_for(ctx).await?.function_scope(id).await)
}

// ── 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,
Expand All @@ -337,14 +345,14 @@ impl Query {
}

/// Dependencies ước lượng từ call names (internal/external/total).
async fn dependencies(&self, ctx: &Context<'_>) -> GqlResult<DependenciesReport> {
async fn graphcode_dependencies(&self, ctx: &Context<'_>) -> GqlResult<DependenciesReport> {
Ok(api_for(ctx).await?.dependencies().await)
}

// ── Document queries ──

/// List all documents in the document graph.
async fn doc_list(&self, ctx: &Context<'_>) -> GqlResult<Vec<DocStatsView>> {
async fn graphdoc_list(&self, ctx: &Context<'_>) -> GqlResult<Vec<DocStatsView>> {
let state = ctx.data::<Arc<AppState>>()?;
let stats = state
.doc_graph
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions crates/codegraph-installer/src/instructions-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/codegraph-installer/src/targets/antigravity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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` |

---
Expand Down
2 changes: 1 addition & 1 deletion crates/codegraph-mcp/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn tool_defs() -> Vec<ToolDef> {
"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 <name>(args) { … }` where `args` is the call's i64 array) or a full `fn <name>(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." },
Expand Down
2 changes: 1 addition & 1 deletion crates/codegraph/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 4 additions & 5 deletions docs/specs/07-mcp-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packaging/aur/codegraph-rs-bin/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: Hung Pham <hung0913208@icloud.com>
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')
Expand Down
Loading
Loading