代码编织
](https://www.npmjs.com/package/codeweave)   ](https://www.npmjs.com/package/codeweave)
通过MCP(一个用于代码库的自托管、零-API-key上下文服务器)使任何回购都能立即做好AI准备。
codeweave与您的AI编码工具一起在本地运行。它将整个仓库索引到一个快速的SQLite数据库中,并将其作为 主控程序 服务器,为AI助手提供有关代码的深入、准确的上下文——文件树、全文搜索、git历史、依赖关系、堆栈检测和编码约定——而无需将代码发送给第三方。
______________________________________________________________________
快速开始
# 1. Install globally (or use npx)
npm install -g codeweave
# 2. Generate a config in your project root
cd /path/to/your/project
codeweave init
# 3. Start the MCP server
codeweave start然后将codeweave添加到您的AI客户端(请参阅 AI客户端设置 在......下面
______________________________________________________________________
特性
| 特性 | 描述 |
|---|---|
| 文件树 | 带注释的JSON树,每个文件都有语言标签 |
| 全文搜索 | 带波特词干的SQLite FTS5——亚毫秒级查询 |
| 文件内容 | 带可选行范围切片的行号文件内容 |
| Git历史记录 | 最近提交的作者、日期和更改的文件 |
| 依赖图 | 解析自 package.json, Cargo.toml, go.mod, pyproject.toml,还有6个 |
| 堆栈检测 | 自动检测语言、框架、数据库、测试运行器、样式 |
| 公约检测 | 文件命名样式、导入模式、组件结构 |
| 文件监视器 | 用300ms去抖动在\<1s内重新索引更改的文件 |
| 增量索引 | 基于mtime的缓存——热启动时间\<30ms |
| API密钥为零 | 完全在本地运行。没有云。没有遥测。 |
______________________________________________________________________
AI客户端设置
codeweave使用stdio MCP传输,并与任何兼容MCP的客户端配合使用。
克劳德代码
添加 .claude/settings.json 在项目根目录中:
{
"mcpServers": {
"codeweave": {
"command": "npx",
"args": ["codeweave"],
"cwd": "."
}
}
}光标
添加 .cursor/mcp.json 在项目根目录中:
{
"mcpServers": {
"codeweave": {
"command": "npx",
"args": ["codeweave"],
"cwd": "${workspaceFolder}"
}
}
}泽德
添加 ~/.config/zed/settings.json:
{
"context_servers": {
"codeweave": {
"command": {
"path": "npx",
"args": ["codeweave"]
}
}
}
}Continue.dev
添加 .continue/config.json:
{
"mcpServers": [
{
"name": "codeweave",
"command": "npx",
"args": ["codeweave"]
}
]
}______________________________________________________________________
CLI 参考
codeweave [command] [options]
Commands:
start Start the MCP server (default)
init Generate codeweave.config.js in the current directory
status Show indexing stats for the current repo
Options:
--verbose Enable debug logging
-V, --version Show version number
-h, --help Show help查看完整 CLI参考→
______________________________________________________________________
配置
跑 codeweave init 生成a codeweave.config.js。所有字段都是可选的——默认值适用于大多数项目。
// codeweave.config.js
export default {
// Directories to index (relative to config file)
include: ['src'],
// Extra patterns to exclude beyond .gitignore
exclude: ['**/*.generated.ts'],
// Files larger than this are truncated (KB)
maxFileSizeKB: 100,
// How many git commits to read
gitDepth: 50,
// Port for future HTTP transport
port: 3333,
// Enable verbose/debug logging
verbose: false,
};查看完整 配置参考→
______________________________________________________________________
MCP工具
codeweave公开了7个人工智能助手可以调用的MCP工具:
| 工具 | 说明 |
|---|---|
get_file_tree | 带注释的文件树,可按语言过滤 |
get_file | 带有行号和可选行范围的文件内容 |
search_codebase | 使用片段上下文进行全文搜索 |
get_conventions | 检测到命名样式、导入模式、测试框架 |
get_dependencies | 解析清单文件中的所有依赖项 |
get_git_history | 最近的提交,可按文件路径过滤 |
get_stack_info | 检测到的语言、框架、数据库、工具 |
查看完整 API 参考→
______________________________________________________________________
建筑
your repo on disk
│
▼
┌─────────────────────────────────────────────────────┐
│ codeweave process │
│ │
│ ┌──────────┐ ┌──────────┐ ┌───────────────────┐ │
│ │ File │ │ Git │ │ Manifest Parser │ │
│ │ Scanner │ │ Reader │ │ (9 formats) │ │
│ └────┬─────┘ └────┬─────┘ └────────┬──────────┘ │
│ │ │ │ │
│ └──────────────┴─────────────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ SQLite DB │ │
│ │ (WAL + FTS5) │◄──────────────────┤
│ └────────┬────────┘ File Watcher │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ get_file_tree search_codebase get_stack_info │
│ get_file get_conventions get_dependencies │
│ get_git_history │
│ │ │
│ └──────────────────────────────────────────┐ │
│ MCP Server (stdio) │ │
└───────────────────────────────────────────────────┘
│
┌─────────┘
▼
AI client (Claude Code, Cursor, Zed…)关键设计决策:
- SQLite在内存中 --完整的文件内容存储在磁盘上,而不是Node.js堆中。无论仓库大小如何,内存使用率都保持不变。
- FTS5搬运工标记器 --处理词干的全文搜索(
authenticate→authenticat)没有任何外部依赖。 - mtime缓存 --未更改的文件永远不会被重新读取。1K文件仓库的热启动需要大约28毫秒。
- 标准运输 --没有端口冲突,没有防火墙规则。适用于AI客户端可以生成子流程的任何环境。
______________________________________________________________________
支持的堆栈
codeweave检测并解析:
语言: TypeScript、JavaScript、Python、Go、Rust、Dart、Ruby、PHP、Java、Kotlin、Swift等
框架: Next.js、Nuxt、Remix、SvelteKit、Astro、Vite+React、Express、Fastify、NestJS、Hono、Django、Flask、FastAPI、Rails、Laravel、Symfony、Angular、Vue、Svelte
数据库: Prisma、TypeORM、Drizzle、MongoDB、PostgreSQL、MySQL、SQLite、Redis、Sequelize
清单格式: package.json, pubspec.yaml, Cargo.toml, go.mod, requirements.txt, pyproject.toml, composer.json, Gemfile, build.gradle
______________________________________________________________________
贡献
欢迎投稿!请阅读 贡献.md 了解如何分叉、开发、测试和提交PR的指南。
git clone https://github.com/MdAbdullahAlMahmud/codeweave.git
cd codeweave
npm install
npm test # run tests
npm run typecheck # type check
npm run lint # lint______________________________________________________________________
许可证
麻省理工学院©阿卜杜拉——见 许可证 了解详情。
