79 lines
4.5 KiB
Markdown
79 lines
4.5 KiB
Markdown
# Extension 规划
|
||
|
||
## 共享能力
|
||
|
||
| Extension | 职责 | 公开能力与 Tool |
|
||
|---|---|---|
|
||
| `workspace` | Workspace、Conversation、Message、Artifact | `WorkspaceService`;默认不提供 Tool |
|
||
| `models` | 模型注册、选择、流式调用、Embedding 和 Fallback | `ModelService`;接收 `models.providers` |
|
||
| `tools` | Tool 注册、Schema 校验、执行、取消和安全拦截 | `ToolService`;可提供 `tools.search`、`tools.describe` |
|
||
| `agent` | 一次 Agent Run、上下文构建、模型与 Tool 循环 | `AgentService`;接收 `agent.contextContributors` |
|
||
| `tasks` | Goal、Plan、子 Agent、任务依赖、等待和恢复 | `TaskService`;`tasks.update_plan`、`tasks.delegate`、`tasks.wait` |
|
||
| `memory` | 用户偏好、事实、经验和长期记忆 | `MemoryService`;`memory.recall`、`memory.propose`、`memory.forget` |
|
||
| `knowledge` | 知识来源、索引、检索和引用 | `KnowledgeService`;`knowledge.search`、`knowledge.open_source` |
|
||
| `project` | 项目路径、文件、搜索、Patch、项目识别和验证 | `ProjectService`;`project.read`、`project.search`、`project.apply_patch`、`project.run_checks` |
|
||
| `shell` | 命令、PTY、输出流、超时和取消 | `ShellService`;`shell.run`、`shell.read`、`shell.cancel` |
|
||
| `git` | Repository、Diff、分支、Commit 和 Worktree | `GitService`;`git.status`、`git.diff`、`git.log`、`git.create_worktree` |
|
||
| `automation` | Workflow、Scheduler、提醒、重试和执行历史 | `AutomationService`;`automation.create`、`automation.schedule`、`automation.pause`、`automation.run_now` |
|
||
| `security` | 风险规则、授权、审批和安全记录 | `SecurityService`;接收 `security.approvalChannels`,不提供 Tool |
|
||
| `secrets` | Keychain、凭据引用、授权范围和轮换 | `SecretsService`;不向模型提供明文凭据 |
|
||
| `browser` | 浏览器 Session 和页面操作 | `BrowserService`;`browser.open`、`browser.read`、`browser.click`、`browser.type` |
|
||
| `computer` | 屏幕、窗口、应用、键鼠和剪贴板 | `ComputerService`;`computer.screenshot`、`computer.open_app`、`computer.click`、`computer.type` |
|
||
| `evolution` | 自身修改候选、验证和发布提案 | `EvolutionService`;`evolution.prepare`、`evolution.validate` |
|
||
|
||
`browser`、`computer` 和 `evolution` 在实现对应能力时创建。
|
||
|
||
## Provider
|
||
|
||
- 模型 Provider:`deepseek` 以及实际接入的其他模型;
|
||
- Tool Provider:GitHub、MCP 和其他实际接入的外部系统;
|
||
- Provider 管理自己的协议、配置、资源和故障,向所属扩展点注册实现;
|
||
- 一个 Provider 可以提供多个 Tool,一个 Tool 不对应一个 Extension。
|
||
|
||
## 产品入口
|
||
|
||
- `cli`:终端输入、命令、展示和审批通道;
|
||
- `web`:HTTP、WebSocket、页面和 Web 会话;
|
||
- `desktop`:窗口、快捷键、通知和原生平台集成。
|
||
|
||
产品入口不拥有共享业务能力。
|
||
|
||
## 协作关系
|
||
|
||
```text
|
||
模型 Provider ────────────────> models
|
||
|
||
workspace / memory / knowledge ─> agent.contextContributors
|
||
|
||
project / shell / git
|
||
browser / computer / 外部 Provider ─> tools.providers
|
||
|
||
tasks ────────────────> agent
|
||
automation ───────────> tasks / agent / tools
|
||
agent ────────────────> workspace / models / tools / memory / knowledge
|
||
tools ────────────────> security
|
||
外部 Provider ────────> secrets
|
||
evolution ────────────> project / shell / git
|
||
|
||
cli / web / desktop ──> workspace / agent / tasks / automation / security
|
||
```
|
||
|
||
## 不单独拆分
|
||
|
||
- Conversation、Message、Artifact 归 `workspace`;
|
||
- Context、Agent Profile 和声明式 Skill 归 `agent`;
|
||
- Workflow、Scheduler 和 Notification 请求归 `automation`;
|
||
- Policy、Approval 和 Audit 归 `security`;
|
||
- 项目文件归 `project`,进程归 `shell`,仓库归 `git`;
|
||
- Run 由实际执行者拥有,不创建通用 Run Extension;
|
||
- 页面、命令、Parser、Prompt、模板和单个 Tool 不是 Extension;
|
||
- 数据迁移、校验和清理由数据所有者实现。
|
||
|
||
## 创建规则
|
||
|
||
- 规划中的 Extension 只有开始实现时才创建源码;
|
||
- `catalog.ts` 只登记已实现并发生跨 Extension 协作的 ID、Hook 和 Event;
|
||
- 不创建占位目录、文件、Factory、ID 或 Hook;
|
||
- Extension 内部文件划分不作统一限制;
|
||
- 当前保持单包,只有独立构建、发布或进程隔离时才拆包。
|