Skip to content

Commit 0557118

Browse files
authored
Merge pull request #5 from echoVic/feature/acp-integration
Feature/acp integration
2 parents 41e0784 + ab1b699 commit 0557118

32 files changed

Lines changed: 2901 additions & 113 deletions

.blade/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"allow": [
44
"TestTool",
55
"Bash(git status)",
6-
"Bash(git diff *)"
6+
"Bash(git diff *)",
7+
"Bash(ls -l)",
8+
"Write(**/*.md)"
79
],
810
"ask": [],
911
"deny": []

.claude/settings.local.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@
6565
"Bash(pnpm approve-builds:*)",
6666
"Bash(git reset:*)",
6767
"Bash(cloc:*)",
68-
"Bash(grep:*)"
68+
"Bash(grep:*)",
69+
"WebFetch(domain:zed.dev)",
70+
"WebFetch(domain:agentclientprotocol.com)",
71+
"WebFetch(domain:www.npmjs.com)",
72+
"WebFetch(domain:deepwiki.com)"
6973
],
7074
"deny": [],
7175
"ask": [],

BLADE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,46 @@ always respond in Chinese
2929
- **HookExecutor.ts**: Hook 执行器
3030
- **Matcher.ts**: 匹配器,决定 Hook 是否触发
3131
- **SecureProcessExecutor.ts**: 安全进程执行器
32+
- **OutputParser.ts**: Hook 输出解析器,解析 Hook 命令的输出
33+
- **HookExecutionGuard.ts**: Hook 执行保护器,保证单次工具调用只触发一次 Hook
3234

3335
### 3. Context 管理 (`src/context/`)
3436
统一管理会话和上下文:
3537
- **ContextManager.ts**: 核心上下文管理器,支持内存/持久化存储
3638
- **CompactionService.ts**: 上下文压缩服务,防止 token 超限
3739
- **TokenCounter.ts**: Token 计数器
40+
- **FileAnalyzer.ts**: 文件分析服务,从对话中提取重点文件并读取内容
3841

3942
### 4. Tool 系统 (`src/tools/`)
4043
- **builtin/**: 内置工具(文件操作、Git、网络等)
4144
- **registry/**: 工具注册表
4245
- **execution/**: 工具执行管线
4346
- **validation/**: 工具参数验证
4447
- **MCP 集成**: 支持 Model Context Protocol 扩展
48+
- **FileLockManager.ts**: 文件锁管理器,防止对同一文件的并发编辑
4549

4650
### 5. 服务层 (`src/services/`)
4751
- **OpenAIChatService.ts**: OpenAI API 服务
4852
- **AnthropicChatService.ts**: Anthropic API 服务
53+
- **GptOpenaiPlatformChatService.ts**: 通用 OpenAI 平台兼容服务,支持自定义 API 端点
4954
- **SessionService.ts**: 会话管理服务
5055

5156
### 6. Slash 命令 (`src/slash-commands/`)
5257
- **builtinCommands.ts**: 内置命令(/compact, /init, /model 等)
58+
- **ide.ts**: IDE 集成命令(/ide, /ide status, /ide connect, /ide install, /ide disconnect)
5359
- **UIActionMapper.ts**: UI 动作映射器
5460

5561
### 7. MCP 集成 (`src/mcp/`)
5662
- **McpRegistry.ts**: MCP 注册表
5763
- **McpClient.ts**: MCP 客户端
5864
- **loadProjectMcpConfig.ts**: 项目 MCP 配置加载
65+
- **HealthMonitor.ts**: MCP 健康监控器,周期性检查连接状态并自动触发重连
5966

6067
### 8. UI 层 (`src/ui/`)
6168
- **App.tsx**: 主应用组件
6269
- **components/**: UI 组件(BladeInterface, LoadingIndicator 等)
6370
- **contexts/**: React Context(SessionContext, AppContext 等)
71+
- **utils/security.ts**: 安全工具函数,处理敏感信息的格式化和过滤
6472

6573
### 9. 配置系统 (`src/config/`)
6674
- **ConfigManager.ts**: 配置管理器
@@ -70,6 +78,12 @@ always respond in Chinese
7078
- **blade.tsx**: 入口文件
7179
- **commands/**: 命令实现(config, doctor, mcp, update 等)
7280

81+
### 11. IDE 集成 (`src/ide/`)
82+
- **ideClient.ts**: IDE 客户端,处理与 IDE 的 WebSocket 通信
83+
- **ideContext.ts**: IDE 上下文,管理 IDE 相关信息和状态
84+
- **ideInstaller.ts**: IDE 安装器,检测和安装 VS Code 插件
85+
- **detectIde.ts**: IDE 检测器,检测当前运行环境
86+
7387
## 开发命令
7488

7589
### 构建与运行
@@ -104,9 +118,26 @@ bun run test:cli
104118
# 覆盖率测试
105119
bun run test:coverage
106120

121+
# 分类覆盖率测试
122+
bun run test:unit:coverage
123+
bun run test:integration:coverage
124+
bun run test:cli:coverage
125+
107126
# 监听模式
108127
bun run test:watch
109128

129+
# 分类监听测试
130+
bun run test:unit:watch
131+
bun run test:integration:watch
132+
bun run test:cli:watch
133+
134+
# 调试和详细测试
135+
bun run test:debug
136+
bun run test:verbose
137+
138+
# 性能测试
139+
bun run test:performance
140+
110141
# CI 模式(带覆盖率)
111142
bun run test:ci
112143
```
@@ -223,6 +254,9 @@ Agent 实例不保存会话状态,所有状态通过 context 参数传入。
223254
5. **性能**: 注意 token 使用,大文件操作需要流式处理
224255
6. **测试**: 新功能必须包含测试用例
225256
7. **文档**: 公共 API 需要 JSDoc 注释
257+
8. **并发安全**: 文件操作使用 FileLockManager 确保并发安全
258+
9. **安全过滤**: 敏感信息(如 API Key)在输出时会被自动过滤
259+
10. **健康监控**: MCP 连接支持健康监控和自动重连机制
226260

227261
## 项目结构
228262
```
@@ -239,6 +273,7 @@ src/
239273
├── prompts/ # 提示词管理
240274
├── services/ # 服务层
241275
├── slash-commands/ # Slash 命令
276+
├── store/ # 全局状态管理 (基于 Zustand)
242277
├── tools/ # 工具系统
243278
├── ui/ # UI 组件
244279
└── utils/ # 工具函数

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"@vscode/ripgrep": "^1.17.0"
115115
},
116116
"dependencies": {
117+
"@agentclientprotocol/sdk": "^0.12.0",
117118
"@inkjs/ui": "^2.0.0",
118119
"@modelcontextprotocol/sdk": "^1.17.4",
119120
"ahooks": "^3.9.5",

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)