IDE Device Agent
wescode 的 IDE 能力定位为 Device Agent:零额外 tool schema footprint。
定位
wescode 的 IDE 能力从 v1.0 起明确定位为 wescode 自己的 Device Agent。
所有 IDE 能力通过 CellSpec.HostEnvironment 透明注入——LLM 只看到 wesgine 标准 read / exec / edit 工具。
能力清单
| 能力 | Capability | 实现机制 | LLM 感知 |
|---|---|---|---|
| Buffer Overlay | wescode_buffer | Host.Files() 拦截 read → 编辑器内存内容 | ❌ 透明 |
| Exec 三分类 | wescode_terminal | Host.Shell() 拦截 exec → 静默/验证/交互 | ❌ 透明 |
| Editor 状态 | wescode_editor | Host.Editor() → 焦点文件/光标 | ❌ 透明 |
| Diff 预览 | wescode_diff | 私有 RPC wescode/showDiff | ❌ 应用层 |
| 通知 | wescode_notify | 私有 RPC + diagnostics/set | ❌ 应用层 |
| 文件定位 | wescode_reveal | 私有 RPC wescode/revealInExplorer | ❌ 应用层 |
Buffer Overlay
AI 的 read 工具优先读编辑器内存中的最新内容:
WescodeBufferSync监听onDidChangeContent,debounce 400ms- 后端
BufferStore维护(cellID, path) → content OverlayFileProvider先查BufferStore,未命中才落到磁盘- 保存时自动清除 overlay
- 大文件(>1MB)不同步
路径归一化
normalizePath 使用 filepath.EvalSymlinks 解析 symlink:
- macOS
/var→/private/var不导致 overlay 失效 - 确保 Go 后端和编辑器使用同一路径标识
INV-EDIT-01
AI 编辑后 buffer === disk(无 dirty 状态)
InlineDiffController.confirmDiff() 在画 diff 前调用 textFileService.revert(uri)。
- Accept:清 decoration + 清 checkpoint
- Reject:磁盘回滚 +
revert()再同步 - 关闭文件永远不弹保存对话框
协议现状
wescode 使用自建 JSON-RPC(不是 MCP 标准),但语义完全等价。
v2 可能统一到 MCP 协议,让 device agent 与其他 device agent 共享注册路径。
可选标准 Adapter
与 IDE Device Agent 正交:
| Adapter | 用途 |
|---|---|
CellSpec.Playwright | 用户浏览器自动化 |
CellSpec.Desktop | OS 级桌面自动化 |
约束
- Tools 只在当前 workspace 对应 Cell 内可见
- Extension 关闭 → tools 从 Cell 视图消失
- 用户切 workspace → 换 Cell → tools 归属对应 workspace
相关文档
- Exec 三分类 →
exec-routing.md - 工作区即 Cell →
workspace-cell.md - 编辑引擎 →
edit-engine.md