From 150b6aa82c470caf29537027d2a170bac5d78220 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sat, 29 Nov 2025 18:00:14 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 12 +++++ README.md | 3 ++ commands/symbol.md | 31 +++++++++++++ commands/x-ray.md | 95 ++++++++++++++++++++++++++++++++++++++ plugin.lock.json | 49 ++++++++++++++++++++ 5 files changed, 190 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/symbol.md create mode 100644 commands/x-ray.md create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..431233e --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "codanna", + "description": "Codanna code intelligence integration for Claude Code - semantic search, symbol analysis, and call graph exploration", + "version": "0.1.3", + "author": { + "name": "bartolli" + }, + "commands": [ + "./commands/x-ray.md", + "./commands/symbol.md" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..830210a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# codanna + +Codanna code intelligence integration for Claude Code - semantic search, symbol analysis, and call graph exploration diff --git a/commands/symbol.md b/commands/symbol.md new file mode 100644 index 0000000..cc7aa55 --- /dev/null +++ b/commands/symbol.md @@ -0,0 +1,31 @@ +--- +description: Looks up a symbol by name. Returns its location, signature, line range, documentation, calls, callers, implementations, and definitions. +argument-hint: "" +--- + +## Context + +Symbol to analyze: **$1** + +User's question: **$2** + +## Your task + +Use the Bash tool to fetch symbol information, then answer the user's question. + +**Workflow:** +1. Execute: `node .claude/scripts/codanna/context-provider.js symbol $1` +2. Analyze the symbol details returned (includes `[symbol_id:123]` for all symbols) +3. Answer the question: "$2" + +When answering: +- Reference actual code locations (file:line_range) +- Explain relationships (calls, called_by, implements, defines) +- Use the signature and documentation from the symbol +- Be specific about how the symbol is used in the codebase + +**Following relationships:** +- Use `` for follow-up queries +- Commands: `calls`, `callers`, `describe` accept either format + +Focus on what the code actually shows, not general programming principles. diff --git a/commands/x-ray.md b/commands/x-ray.md new file mode 100644 index 0000000..8d2f11a --- /dev/null +++ b/commands/x-ray.md @@ -0,0 +1,95 @@ +--- +allowed-tools: Bash(node .claude/scripts/codanna/context-provider.js:*) +description: Deep codebase exploration using semantic search and relationship mapping +argument-hint: "" +--- + +## Search Query Analysis + +**User's Original Query**: "$ARGUMENTS" + +### Query Optimization + +Codanna's semantic search works best with technical terms and specific concepts. Analyze the query above and improve it for code search: + +1. **If vague** (e.g., "that parsing thing") → Make it specific (e.g., "language parser implementation") +2. **If a question** (e.g., "how does parsing work?") → Extract keywords (e.g., "parsing implementation process") +3. **If conversational** (e.g., "the stuff that handles languages") → Use technical terms (e.g., "language handler processor") +4. **If too broad** (e.g., "errors") → Add context (e.g., "error handling exception management") + +**OptimizedQuery**: _{Claude: Write your improved query here, then use it below}_ + +Execute this command with your optimized query: + +## Your Workflow + +### Gather Context + +Use the Bash tool to perform semantic code search: + +Execute: `node .claude/scripts/codanna/context-provider.js find "$OptimizedQuery" --limit=5` + +**What Codanna returns:** +- Relevance scores (how well each result matches) +- Symbol signatures and documentation +- Relationships (calls, called_by, implements, defines) +- File locations with line ranges + +### Your Workflow + +1. Analyze the results with their relevance scores (focus on results with score > 0.6 (if possible)) + +2. **To see actual implementation** of interesting results: + - Use the line range from the Location field to read just the relevant code + - Example: If you see "Location: `src/io/exit_code.rs:108-120`" + - Use the Read tool with: + - `file_path`: `src/io/exit_code.rs` (use the working directory from your environment context to construct the absolute path) + - `offset`: 108 (start line) + - `limit`: 13 (calculated as: 120 - 108 + 1) + - Formula: `limit = end_line - start_line + 1` + - Example: `Read(file_path="/full/path/to/src/io/exit_code.rs", offset=108, limit=13)` + +3. **When relationships are shown** (called_by, calls, defines, implements): + - If a relationship looks relevant to answering the query, investigate it + - Execute: `node .claude/scripts/codanna/context-provider.js describe ` + - Example: If you see "Called by: `initialize_registry [symbol_id:123]`", run: `node .claude/scripts/codanna/context-provider.js describe initialize_registry` or `describe symbol_id:123` + - Note: Following 1-2 key relationships per result is typically sufficient + +4. Build a complete picture by following key relationships and reading relevant code sections + +5. **If needed**, repeat with a refined query based on what you learned. + +--- + +## Tips for Efficient Exploration + +**The results include:** +- Relevance scores (how well each result matches the query) +- Symbol documentation and signatures +- Relationships (who calls this, what it calls, what it defines) +- System guidance for follow-up investigation + +**sed (native on unix only):** +- You can also see actual implementation with `sed`: (works native on Unix based environments): + - Use the line range from the Location field to read just the relevant code + - Example: If you see "Location: `src/io/exit_code.rs:108-120`" + - Execute: `sed -n '108,120p' src/io/exit_code.rs` to read lines 108-120 + - This shows the actual code implementation, not just the signature. It works like the Read tool. + +- Add `--lang=rust` (or python, typescript, etc.) to narrow results by language if you work on multi-language projects +- Follow relationships that appear in multiple results (they're likely important) +- Use the `describe` command to get full details about interesting relationships + +**Token awareness:** +- Each search uses ~500 tokens +- Each relationship follow uses ~300 tokens +- Each file read uses ~100-500 tokens (depends on size) +- Staying efficient keeps your context window clean for deeper analysis + +**This command is for exploration:** +- Build understanding of the codebase +- Identify patterns and integration points +- Present findings and await user direction +- Don't start implementing or making changes yet + +Based on the gathered context, engage with the user to narrow focus and help the user with further request. diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..9e9419b --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,49 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:bartolli/codanna-plugins:plugins/codanna-base", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "79db26f44944e974712f0f30a42ff0876e616069", + "treeHash": "936782e7c8017efbca15aebf1d722d06dba1724f079607aabf02b7931bc795df", + "generatedAt": "2025-11-28T10:14:10.681163Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "codanna", + "description": "Codanna code intelligence integration for Claude Code - semantic search, symbol analysis, and call graph exploration", + "version": "0.1.3" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "e55f6786495938311161690bbe17aa8e2e37c40cef58f6e5ac1b09395f70b062" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "366dc9136c674e5f1a024b7ee26cae0b74675374401169c6d35541c94c0ff616" + }, + { + "path": "commands/symbol.md", + "sha256": "c79488cb16f29d65fda211327cd8e7b03f3dc826e6167289cd638bf3b5f75f7a" + }, + { + "path": "commands/x-ray.md", + "sha256": "87cc4cd5fd66b816814e8f3062ff62254ea85135f5198c8cc5cb7b5fa687d63a" + } + ], + "dirSha256": "936782e7c8017efbca15aebf1d722d06dba1724f079607aabf02b7931bc795df" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file