code-intelligence
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Intelligence Skill
Code Intelligence 技能
Advanced codebase analysis and search tools inspired by hybrid memory systems. This skill enables the agent to understand code relationships, search semantically, and analyze the impact of changes.
受混合内存系统启发的高级代码库分析与搜索工具。该技能使Agent能够理解代码关系、进行语义搜索并分析变更的影响。
Setup
设置
bash
cd /job/.pi/skills/code-intelligence
npm installbash
cd /job/.pi/skills/code-intelligence
npm installTools
工具
Index Codebase
索引代码库
Build a searchable index of the codebase:
bash
node index.js --scan /path/to/projectThis creates:
- Symbol table (functions, classes, exports)
- Import/dependency graph
- File metadata index
构建代码库的可搜索索引:
bash
node index.js --scan /path/to/project这将生成:
- 符号表(函数、类、导出项)
- 导入/依赖图谱
- 文件元数据索引
Semantic Search
语义搜索
Search for code by meaning, not just text:
bash
undefined按含义搜索代码,而非仅按文本:
bash
undefinedFind code related to authentication
Find code related to authentication
node search.js "authentication middleware"
node search.js "authentication middleware"
Find where database connections are established
Find where database connections are established
node search.js "database connection setup"
node search.js "database connection setup"
Search with filters
Search with filters
node search.js "user validation" --type function --ext js,ts
undefinednode search.js "user validation" --type function --ext js,ts
undefinedRelationship Analysis
关系分析
Understand code dependencies:
bash
undefined理解代码依赖:
bash
undefinedWhat depends on this file?
What depends on this file?
node deps.js --dependents src/utils/api.js
node deps.js --dependents src/utils/api.js
What does this file import?
What does this file import?
node deps.js --imports src/utils/api.js
node deps.js --imports src/utils/api.js
Show full dependency chain
Show full dependency chain
node deps.js --chain src/app.js
undefinednode deps.js --chain src/app.js
undefinedImpact Analysis
影响分析
Predict what might break with changes:
bash
undefined预测变更可能导致的问题:
bash
undefinedAnalyze impact of modifying a function
Analyze impact of modifying a function
node impact.js src/utils/auth.js --function verifyToken
node impact.js src/utils/auth.js --function verifyToken
Check impact of file changes
Check impact of file changes
node impact.js src/config/database.js
undefinednode impact.js src/config/database.js
undefinedCode Q&A
代码问答
Ask questions about the codebase:
bash
node ask.js "Where is the JWT secret configured?"
node ask.js "How does error handling work in this project?"
node ask.js "What functions use the database connection?"针对代码库提问:
bash
node ask.js "Where is the JWT secret configured?"
node ask.js "How does error handling work in this project?"
node ask.js "What functions use the database connection?"Architecture
架构
The skill uses a layered approach:
- Parser Layer: Tree-sitter for AST parsing
- Index Layer: SQLite for fast lookups + JSON for graph data
- Search Layer: Hybrid keyword + semantic matching
- Analysis Layer: Graph algorithms for relationship mapping
该技能采用分层架构:
- 解析层:使用Tree-sitter进行AST解析
- 索引层:SQLite用于快速查询 + JSON用于图谱数据
- 搜索层:混合关键词+语义匹配
- 分析层:图谱算法用于关系映射
Output Format
输出格式
All tools output JSON for programmatic use or formatted text for readability:
bash
undefined所有工具均输出JSON供程序化使用,或输出格式化文本以提升可读性:
bash
undefinedJSON output (for piping to other tools)
JSON output (for piping to other tools)
node search.js "auth" --json
node search.js "auth" --json
Formatted text (default)
Formatted text (default)
node search.js "auth"
undefinednode search.js "auth"
undefinedWhen to Use
使用场景
- Understanding large or unfamiliar codebases
- Finding all usages of a function or variable
- Assessing risk before making changes
- Discovering patterns across the codebase
- Answering "where is X?" questions
- Code review preparation
- Refactoring planning
- 理解大型或陌生的代码库
- 查找函数或变量的所有用法
- 在变更前评估风险
- 发现代码库中的模式
- 解答“X在哪里?”这类问题
- 代码审查准备
- 重构规划
Requirements
要求
- Node.js ≥18
- Tree-sitter parsers for supported languages (auto-installed)
- Node.js ≥18
- 支持语言对应的Tree-sitter解析器(自动安装)
Supported Languages
支持的语言
- JavaScript/TypeScript
- Python
- Rust
- Go
- Java
- Ruby
- And more via tree-sitter
- JavaScript/TypeScript
- Python
- Rust
- Go
- Java
- Ruby
- 更多语言可通过tree-sitter扩展
Data Storage
数据存储
Index files are stored in :
.code-intelligence/- - SQLite database
index.db - - Dependency graph
graph.json - - Parsed AST cache
cache/
Add to your .
.code-intelligence/.gitignore索引文件存储在目录下:
.code-intelligence/- - SQLite数据库
index.db - - 依赖图谱
graph.json - - 已解析的AST缓存
cache/
将添加到你的中。
.code-intelligence/.gitignore