diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..09655b8 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,28 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write|Bash", + "hooks": [ + { + "type": "command", + "command": "git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph update --skip-flows --repo \"/home/v6ole/PythonProject/NetBrain_MCP\" || true", + "timeout": 30 + } + ] + } + ], + "SessionStart": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph status --repo \"/home/v6ole/PythonProject/NetBrain_MCP\" || echo 'Not a git repo, skipping'", + "timeout": 10 + } + ] + } + ] + } +} diff --git a/.claude/skills/debug-issue/skill.md b/.claude/skills/debug-issue/skill.md new file mode 100644 index 0000000..ef1b38a --- /dev/null +++ b/.claude/skills/debug-issue/skill.md @@ -0,0 +1,27 @@ +--- +name: Debug Issue +description: Systematically debug issues using graph-powered code navigation +--- + +## Debug Issue + +Use the knowledge graph to systematically trace and debug issues. + +### Steps + +1. Use `semantic_search_nodes` to find code related to the issue. +2. Use `query_graph` with `callers_of` and `callees_of` to trace call chains. +3. Use `get_flow` to see full execution paths through suspected areas. +4. Run `detect_changes` to check if recent changes caused the issue. +5. Use `get_impact_radius` on suspected files to see what else is affected. + +### Tips + +- Check both callers and callees to understand the full context. +- Look at affected flows to find the entry point that triggers the bug. +- Recent changes are the most common source of new issues. + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.claude/skills/explore-codebase/skill.md b/.claude/skills/explore-codebase/skill.md new file mode 100644 index 0000000..dc7ad10 --- /dev/null +++ b/.claude/skills/explore-codebase/skill.md @@ -0,0 +1,28 @@ +--- +name: Explore Codebase +description: Navigate and understand codebase structure using the knowledge graph +--- + +## Explore Codebase + +Use the code-review-graph MCP tools to explore and understand the codebase. + +### Steps + +1. Run `list_graph_stats` to see overall codebase metrics. +2. Run `get_architecture_overview` for high-level community structure. +3. Use `list_communities` to find major modules, then `get_community` for details. +4. Use `semantic_search_nodes` to find specific functions or classes. +5. Use `query_graph` with patterns like `callers_of`, `callees_of`, `imports_of` to trace relationships. +6. Use `list_flows` and `get_flow` to understand execution paths. + +### Tips + +- Start broad (stats, architecture) then narrow down to specific areas. +- Use `children_of` on a file to see all its functions and classes. +- Use `find_large_functions` to identify complex code. + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.claude/skills/refactor-safely/skill.md b/.claude/skills/refactor-safely/skill.md new file mode 100644 index 0000000..cf84420 --- /dev/null +++ b/.claude/skills/refactor-safely/skill.md @@ -0,0 +1,28 @@ +--- +name: Refactor Safely +description: Plan and execute safe refactoring using dependency analysis +--- + +## Refactor Safely + +Use the knowledge graph to plan and execute refactoring with confidence. + +### Steps + +1. Use `refactor_tool` with mode="suggest" for community-driven refactoring suggestions. +2. Use `refactor_tool` with mode="dead_code" to find unreferenced code. +3. For renames, use `refactor_tool` with mode="rename" to preview all affected locations. +4. Use `apply_refactor_tool` with the refactor_id to apply renames. +5. After changes, run `detect_changes` to verify the refactoring impact. + +### Safety Checks + +- Always preview before applying (rename mode gives you an edit list). +- Check `get_impact_radius` before major refactors. +- Use `get_affected_flows` to ensure no critical paths are broken. +- Run `find_large_functions` to identify decomposition targets. + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.claude/skills/review-changes/skill.md b/.claude/skills/review-changes/skill.md new file mode 100644 index 0000000..6bb3558 --- /dev/null +++ b/.claude/skills/review-changes/skill.md @@ -0,0 +1,29 @@ +--- +name: Review Changes +description: Perform a structured code review using change detection and impact +--- + +## Review Changes + +Perform a thorough, risk-aware code review using the knowledge graph. + +### Steps + +1. Run `detect_changes` to get risk-scored change analysis. +2. Run `get_affected_flows` to find impacted execution paths. +3. For each high-risk function, run `query_graph` with pattern="tests_for" to check test coverage. +4. Run `get_impact_radius` to understand the blast radius. +5. For any untested changes, suggest specific test cases. + +### Output Format + +Provide findings grouped by risk level (high/medium/low) with: +- What changed and why it matters +- Test coverage status +- Suggested improvements +- Overall merge recommendation + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.cursorrules b/.cursorrules new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/.cursorrules @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/.gemini/hooks/crg-session-start.sh b/.gemini/hooks/crg-session-start.sh new file mode 100755 index 0000000..bf9943c --- /dev/null +++ b/.gemini/hooks/crg-session-start.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# code-review-graph: session start status (Gemini CLI hook) +# Must output ONLY JSON on stdout. Logs go to stderr. Never blocks the session. +set -euo pipefail + +cat > /dev/null || true + +msg="$(code-review-graph status --repo "/home/v6ole/PythonProject/NetBrain_MCP" 2>&1 | head -n 1 || true)" + +CRG_MSG="$msg" python3 -c ' +import json,os +m=os.environ.get("CRG_MSG","") +print(json.dumps({"systemMessage":m,"suppressOutput":True})) +' 2>/dev/null || echo '{"suppressOutput": true}' +exit 0 diff --git a/.gemini/hooks/crg-update.sh b/.gemini/hooks/crg-update.sh new file mode 100755 index 0000000..8ad8157 --- /dev/null +++ b/.gemini/hooks/crg-update.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# code-review-graph: incremental update after write/replace (Gemini CLI hook) +# Must output ONLY JSON on stdout. Low-noise: no systemMessage. +set -euo pipefail + +cat > /dev/null || true + +code-review-graph update --skip-flows --repo "/home/v6ole/PythonProject/NetBrain_MCP" >/dev/null 2>&1 || true +echo '{"suppressOutput": true}' +exit 0 diff --git a/.gemini/settings.json b/.gemini/settings.json new file mode 100644 index 0000000..1e574a0 --- /dev/null +++ b/.gemini/settings.json @@ -0,0 +1,30 @@ +{ + "hooks": { + "SessionStart": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "bash .gemini/hooks/crg-session-start.sh", + "name": "code-review-graph status", + "timeout": 10000 + } + ] + } + ], + "AfterTool": [ + { + "matcher": "write_file|replace", + "hooks": [ + { + "type": "command", + "command": "bash .gemini/hooks/crg-update.sh", + "name": "code-review-graph update", + "timeout": 30000 + } + ] + } + ] + } +} diff --git a/.gemini/skills/debug-issue/SKILL.md b/.gemini/skills/debug-issue/SKILL.md new file mode 100644 index 0000000..b1926f9 --- /dev/null +++ b/.gemini/skills/debug-issue/SKILL.md @@ -0,0 +1,27 @@ +--- +name: debug-issue +description: Systematically debug issues using graph-powered code navigation +--- + +## Debug Issue + +Use the knowledge graph to systematically trace and debug issues. + +### Steps + +1. Use `semantic_search_nodes` to find code related to the issue. +2. Use `query_graph` with `callers_of` and `callees_of` to trace call chains. +3. Use `get_flow` to see full execution paths through suspected areas. +4. Run `detect_changes` to check if recent changes caused the issue. +5. Use `get_impact_radius` on suspected files to see what else is affected. + +### Tips + +- Check both callers and callees to understand the full context. +- Look at affected flows to find the entry point that triggers the bug. +- Recent changes are the most common source of new issues. + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.gemini/skills/explore-codebase/SKILL.md b/.gemini/skills/explore-codebase/SKILL.md new file mode 100644 index 0000000..38afda2 --- /dev/null +++ b/.gemini/skills/explore-codebase/SKILL.md @@ -0,0 +1,28 @@ +--- +name: explore-codebase +description: Navigate and understand codebase structure using the knowledge graph +--- + +## Explore Codebase + +Use the code-review-graph MCP tools to explore and understand the codebase. + +### Steps + +1. Run `list_graph_stats` to see overall codebase metrics. +2. Run `get_architecture_overview` for high-level community structure. +3. Use `list_communities` to find major modules, then `get_community` for details. +4. Use `semantic_search_nodes` to find specific functions or classes. +5. Use `query_graph` with patterns like `callers_of`, `callees_of`, `imports_of` to trace relationships. +6. Use `list_flows` and `get_flow` to understand execution paths. + +### Tips + +- Start broad (stats, architecture) then narrow down to specific areas. +- Use `children_of` on a file to see all its functions and classes. +- Use `find_large_functions` to identify complex code. + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.gemini/skills/refactor-safely/SKILL.md b/.gemini/skills/refactor-safely/SKILL.md new file mode 100644 index 0000000..c6e721a --- /dev/null +++ b/.gemini/skills/refactor-safely/SKILL.md @@ -0,0 +1,28 @@ +--- +name: refactor-safely +description: Plan and execute safe refactoring using dependency analysis +--- + +## Refactor Safely + +Use the knowledge graph to plan and execute refactoring with confidence. + +### Steps + +1. Use `refactor_tool` with mode="suggest" for community-driven refactoring suggestions. +2. Use `refactor_tool` with mode="dead_code" to find unreferenced code. +3. For renames, use `refactor_tool` with mode="rename" to preview all affected locations. +4. Use `apply_refactor_tool` with the refactor_id to apply renames. +5. After changes, run `detect_changes` to verify the refactoring impact. + +### Safety Checks + +- Always preview before applying (rename mode gives you an edit list). +- Check `get_impact_radius` before major refactors. +- Use `get_affected_flows` to ensure no critical paths are broken. +- Run `find_large_functions` to identify decomposition targets. + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.gemini/skills/review-changes/SKILL.md b/.gemini/skills/review-changes/SKILL.md new file mode 100644 index 0000000..7d1f106 --- /dev/null +++ b/.gemini/skills/review-changes/SKILL.md @@ -0,0 +1,29 @@ +--- +name: review-changes +description: Perform a structured code review using change detection and impact +--- + +## Review Changes + +Perform a thorough, risk-aware code review using the knowledge graph. + +### Steps + +1. Run `detect_changes` to get risk-scored change analysis. +2. Run `get_affected_flows` to find impacted execution paths. +3. For each high-risk function, run `query_graph` with pattern="tests_for" to check test coverage. +4. Run `get_impact_radius` to understand the blast radius. +5. For any untested changes, suggest specific test cases. + +### Output Format + +Provide findings grouped by risk level (high/medium/low) with: +- What changed and why it matters +- Test coverage status +- Suggested improvements +- Overall merge recommendation + +## Token Efficiency Rules +- ALWAYS start with `get_minimal_context(task="")` before any other graph tool. +- Use `detail_level="minimal"` on all calls. Only escalate to "standard" when minimal is insufficient. +- Target: complete any review/debug/refactor task in ≤5 tool calls and ≤800 total output tokens. diff --git a/.github/code-review-graph.instruction.md b/.github/code-review-graph.instruction.md new file mode 100644 index 0000000..28bbc6d --- /dev/null +++ b/.github/code-review-graph.instruction.md @@ -0,0 +1,46 @@ +--- +applyTo: '**' +description: >- + Use code-review-graph MCP tools for token-efficient + codebase exploration and code review. +--- + + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using file/search tools to +explore the codebase.** The graph is faster, cheaper (fewer +tokens), and gives you structural context (callers, dependents, +test coverage) that file scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` +- **Understanding impact**: `get_impact_radius` +- **Code review**: `detect_changes` + `get_review_context` +- **Finding relationships**: `query_graph` callers_of/callees_of +- **Architecture questions**: `get_architecture_overview` + +Fall back to file/search tools **only** when the graph doesn't +cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Risk-scored change analysis | +| `get_review_context` | Token-efficient source snippets | +| `get_impact_radius` | Blast radius of a change | +| `get_affected_flows` | Impacted execution paths | +| `query_graph` | Trace callers, callees, imports, tests | +| `semantic_search_nodes` | Find functions/classes by keyword | +| `get_architecture_overview` | High-level structure | +| `refactor_tool` | Rename planning, dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/.gitignore b/.gitignore index 36b13f1..d2739a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +<<<<<<< HEAD # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ @@ -174,3 +175,5 @@ cython_debug/ # PyPI configuration file .pypirc +# Added by code-review-graph +.code-review-graph/ diff --git a/.kiro/steering/code-review-graph.md b/.kiro/steering/code-review-graph.md new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/.kiro/steering/code-review-graph.md @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 0000000..fea55fc --- /dev/null +++ b/.mcp.json @@ -0,0 +1,14 @@ +{ + "mcpServers": { + "code-review-graph": { + "command": "/usr/bin/python3", + "args": [ + "-m", + "code_review_graph", + "serve" + ], + "cwd": "/home/v6ole/PythonProject/NetBrain_MCP", + "type": "stdio" + } + } +} diff --git a/.opencode.json b/.opencode.json new file mode 100644 index 0000000..8106aec --- /dev/null +++ b/.opencode.json @@ -0,0 +1,15 @@ +{ + "mcpServers": { + "code-review-graph": { + "command": "/usr/bin/python3", + "args": [ + "-m", + "code_review_graph", + "serve" + ], + "cwd": "/home/v6ole/PythonProject/NetBrain_MCP", + "type": "stdio", + "env": [] + } + } +} diff --git a/.qoder/mcp.json b/.qoder/mcp.json new file mode 100644 index 0000000..fea55fc --- /dev/null +++ b/.qoder/mcp.json @@ -0,0 +1,14 @@ +{ + "mcpServers": { + "code-review-graph": { + "command": "/usr/bin/python3", + "args": [ + "-m", + "code_review_graph", + "serve" + ], + "cwd": "/home/v6ole/PythonProject/NetBrain_MCP", + "type": "stdio" + } + } +} diff --git a/.qoder/settings.json b/.qoder/settings.json new file mode 100644 index 0000000..09655b8 --- /dev/null +++ b/.qoder/settings.json @@ -0,0 +1,28 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write|Bash", + "hooks": [ + { + "type": "command", + "command": "git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph update --skip-flows --repo \"/home/v6ole/PythonProject/NetBrain_MCP\" || true", + "timeout": 30 + } + ] + } + ], + "SessionStart": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "git rev-parse --git-dir >/dev/null 2>&1 && code-review-graph status --repo \"/home/v6ole/PythonProject/NetBrain_MCP\" || echo 'Not a git repo, skipping'", + "timeout": 10 + } + ] + } + ] + } +} diff --git a/.vscode/mcp.json b/.vscode/mcp.json new file mode 100644 index 0000000..e0084d1 --- /dev/null +++ b/.vscode/mcp.json @@ -0,0 +1,14 @@ +{ + "servers": { + "code-review-graph": { + "command": "/usr/bin/python3", + "args": [ + "-m", + "code_review_graph", + "serve" + ], + "cwd": "/home/v6ole/PythonProject/NetBrain_MCP", + "type": "stdio" + } + } +} diff --git a/.windsurfrules b/.windsurfrules new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/.windsurfrules @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/QODER.md b/QODER.md new file mode 100644 index 0000000..d3dc9b4 --- /dev/null +++ b/QODER.md @@ -0,0 +1,38 @@ + +## MCP Tools: code-review-graph + +**IMPORTANT: This project has a knowledge graph. ALWAYS use the +code-review-graph MCP tools BEFORE using Grep/Glob/Read to explore +the codebase.** The graph is faster, cheaper (fewer tokens), and gives +you structural context (callers, dependents, test coverage) that file +scanning cannot. + +### When to use graph tools FIRST + +- **Exploring code**: `semantic_search_nodes` or `query_graph` instead of Grep +- **Understanding impact**: `get_impact_radius` instead of manually tracing imports +- **Code review**: `detect_changes` + `get_review_context` instead of reading entire files +- **Finding relationships**: `query_graph` with callers_of/callees_of/imports_of/tests_for +- **Architecture questions**: `get_architecture_overview` + `list_communities` + +Fall back to Grep/Glob/Read **only** when the graph doesn't cover what you need. + +### Key Tools + +| Tool | Use when | +| ------ | ---------- | +| `detect_changes` | Reviewing code changes — gives risk-scored analysis | +| `get_review_context` | Need source snippets for review — token-efficient | +| `get_impact_radius` | Understanding blast radius of a change | +| `get_affected_flows` | Finding which execution paths are impacted | +| `query_graph` | Tracing callers, callees, imports, tests, dependencies | +| `semantic_search_nodes` | Finding functions/classes by name or keyword | +| `get_architecture_overview` | Understanding high-level codebase structure | +| `refactor_tool` | Planning renames, finding dead code | + +### Workflow + +1. The graph auto-updates on file changes (via hooks). +2. Use `detect_changes` for code review. +3. Use `get_affected_flows` to understand impact. +4. Use `query_graph` pattern="tests_for" to check coverage. diff --git a/__pycache__/device_connector.cpython-312.pyc b/__pycache__/device_connector.cpython-312.pyc index b9a01d3..e0b45c2 100644 Binary files a/__pycache__/device_connector.cpython-312.pyc and b/__pycache__/device_connector.cpython-312.pyc differ diff --git a/__pycache__/device_prompts.cpython-312.pyc b/__pycache__/device_prompts.cpython-312.pyc index 98f9e99..13121ba 100644 Binary files a/__pycache__/device_prompts.cpython-312.pyc and b/__pycache__/device_prompts.cpython-312.pyc differ diff --git a/__pycache__/network_devices.cpython-312.pyc b/__pycache__/network_devices.cpython-312.pyc index bc04856..c09b0e3 100644 Binary files a/__pycache__/network_devices.cpython-312.pyc and b/__pycache__/network_devices.cpython-312.pyc differ diff --git a/__pycache__/server.cpython-312.pyc b/__pycache__/server.cpython-312.pyc index 8e24717..cf20cf2 100644 Binary files a/__pycache__/server.cpython-312.pyc and b/__pycache__/server.cpython-312.pyc differ diff --git a/server.py b/server.py index b71b5e9..8b1347a 100644 --- a/server.py +++ b/server.py @@ -421,8 +421,8 @@ async def connect_device(device_id: str, credential_id: str) -> Dict[str, Any]: command = "show version" else: command = "show version" - - logger.info(f"尝试获取版本信息,平台: {platform},命令: {command}") + + logger.info(f"尝试获取版本信息,平台: {platform},命令: {command}") # 直接使用Scrapli连接对象发送命令 if hasattr(connector.connection, "send_command"): diff --git a/templates/command_templates/__pycache__/__init__.cpython-312.pyc b/templates/command_templates/__pycache__/__init__.cpython-312.pyc index 2919c03..fadeab3 100644 Binary files a/templates/command_templates/__pycache__/__init__.cpython-312.pyc and b/templates/command_templates/__pycache__/__init__.cpython-312.pyc differ