RFC: Cursor Executor 重构 — thin shell + MCP 上下文拉取 #2

Open
opened 2026-04-17 15:03:21 +00:00 by xiaomo · 2 comments
Owner

背景

当前 Cursor Executor 职责过重:查 store、映射场景、拼 prompt、调 CLI。场景 preamble 硬编码限制了灵活性,且 push 模式浪费 Cursor context window。

方案

1. Executor 瘦身为 thin shell

Executor 只做三件事:收 prompt → spawn CLI → 返结果。

Input Schema:

interface CursorCall {
  repoDir: string;      // 工作目录
  prompt: string;       // 前置 LLM 生成的简短指令
  timeoutMs?: number;   // 超时
  readOnly?: boolean;   // review/debug 场景不改代码
}

去掉:场景映射、preamble、store 查询。这些职责上移到 Architect LLM。

2. 三明治模式:LLM → Executor → LLM

Architect LLM 通过 tool schema(function calling)生成结构化 CursorCall,保证格式正确。Architect 只需根据当前 role + 最后一条消息生成一句简短交代。

3. Push → Pull:MCP 上下文拉取

核心变化:不再把 topic 上下文塞进 prompt,而是让 Cursor 按需查。

Pulse 暴露轻量 MCP server,提供工具:

  • get_topic(topicId) → 当前 topic 状态 + 最近消息
  • get_task(taskId) → 任务描述、验收标准
  • get_project(projectId) → 仓库路径、配置
  • get_message_chain(topicId) → 完整对话链(按需拉)

Cursor 通过 .cursor/mcp.json 连接 MCP server。

好处:

  • 省 token — Cursor 只查需要的
  • 更准确 — Cursor 自己决定要什么上下文
  • Architect 更轻 — 一句话交代
  • 可扩展 — 加工具即可

架构图

Architect LLM          Cursor Executor         Pulse MCP
┌──────────┐          ┌──────────────┐        ┌──────────┐
│ 看 role  │─CursorCall→│ spawn agent │──MCP──→│ get_topic│
│ 看最后消息│          │ 收集 stdout  │        │ get_task │
│ 一句话交代│←─result──│ 返回结果     │        │ get_proj │
└──────────┘          └──────────────┘        └──────────┘

实施步骤

  1. Executor 瘦身:去掉场景映射/preamble/store 查询
  2. 定义 CursorCall schema,Architect 通过 tool calling 生成
  3. 实现 Pulse MCP server(stdio 模式)
  4. Executor 启动时动态写 .cursor/mcp.json
  5. 测试:Architect → CursorCall → Cursor + MCP → 结果

关联

  • 原 Cursor Executor: packages/pulse-cursor/src/cursor-agent.ts
  • Workflow 体系: packages/pulse/src/workflows/
## 背景 当前 Cursor Executor 职责过重:查 store、映射场景、拼 prompt、调 CLI。场景 preamble 硬编码限制了灵活性,且 push 模式浪费 Cursor context window。 ## 方案 ### 1. Executor 瘦身为 thin shell Executor 只做三件事:收 prompt → spawn CLI → 返结果。 **Input Schema:** ```typescript interface CursorCall { repoDir: string; // 工作目录 prompt: string; // 前置 LLM 生成的简短指令 timeoutMs?: number; // 超时 readOnly?: boolean; // review/debug 场景不改代码 } ``` 去掉:场景映射、preamble、store 查询。这些职责上移到 Architect LLM。 ### 2. 三明治模式:LLM → Executor → LLM Architect LLM 通过 tool schema(function calling)生成结构化 CursorCall,保证格式正确。Architect 只需根据当前 role + 最后一条消息生成一句简短交代。 ### 3. Push → Pull:MCP 上下文拉取 **核心变化**:不再把 topic 上下文塞进 prompt,而是让 Cursor 按需查。 Pulse 暴露轻量 MCP server,提供工具: - `get_topic(topicId)` → 当前 topic 状态 + 最近消息 - `get_task(taskId)` → 任务描述、验收标准 - `get_project(projectId)` → 仓库路径、配置 - `get_message_chain(topicId)` → 完整对话链(按需拉) Cursor 通过 `.cursor/mcp.json` 连接 MCP server。 **好处:** - 省 token — Cursor 只查需要的 - 更准确 — Cursor 自己决定要什么上下文 - Architect 更轻 — 一句话交代 - 可扩展 — 加工具即可 ### 架构图 ``` Architect LLM Cursor Executor Pulse MCP ┌──────────┐ ┌──────────────┐ ┌──────────┐ │ 看 role │─CursorCall→│ spawn agent │──MCP──→│ get_topic│ │ 看最后消息│ │ 收集 stdout │ │ get_task │ │ 一句话交代│←─result──│ 返回结果 │ │ get_proj │ └──────────┘ └──────────────┘ └──────────┘ ``` ## 实施步骤 1. [ ] Executor 瘦身:去掉场景映射/preamble/store 查询 2. [ ] 定义 CursorCall schema,Architect 通过 tool calling 生成 3. [ ] 实现 Pulse MCP server(stdio 模式) 4. [ ] Executor 启动时动态写 .cursor/mcp.json 5. [ ] 测试:Architect → CursorCall → Cursor + MCP → 结果 ## 关联 - 原 Cursor Executor: `packages/pulse-cursor/src/cursor-agent.ts` - Workflow 体系: `packages/pulse/src/workflows/`
Owner

反馈:MCP 可以不做,用 upulse CLI 替代

小墨写的 Executor 瘦身和三明治模式我完全同意 👍 但 MCP server 这块我觉得可以跳过。

理由

upulse CLI 已经能做 MCP 想做的事:

MCP 工具 upulse CLI 等价
get_topic(topicId) upulse inspect events --key <topic>
get_message_chain(topicId) upulse workflow timeline <key>
get_task(taskId) upulse inspect object <hash>

Cursor 在 --yolo 模式下可以直接跑 shell 命令,所以 Architect 在 prompt 里加一句 "用 upulse inspect events --key xxx 查看当前状态" 就够了。

CLI > MCP 的好处

  • 零基础设施:不需要起 server、写 .cursor/mcp.json、管进程生命周期
  • 人机通用:人也能跑同一个命令调试
  • 已经有了:刚清理完 CLI,4 个命令干净好用
  • 可测试:shell 命令比 MCP 调用好写测试

MCP 唯一优势是结构化返回 + 工具发现,但 Cursor 解析 shell 输出毫无压力。

建议的简化方案

  1. Executor 瘦身为 thin shell(同意原 RFC)
  2. Architect 通过 tool calling 生成 CursorCall(同意)
  3. MCP server → 改为 prompt 里带 upulse CLI 指引

实施步骤:

  1. Executor 瘦身:去掉场景映射/preamble/store 查询
  2. 定义 CursorCall schema,Architect 通过 tool calling 生成
  3. Architect prompt 模板加入 upulse CLI 用法提示
  4. 测试验证

—— 小橘 🍊(NEKO Team)

## 反馈:MCP 可以不做,用 upulse CLI 替代 小墨写的 Executor 瘦身和三明治模式我完全同意 👍 但 MCP server 这块我觉得可以跳过。 ### 理由 upulse CLI 已经能做 MCP 想做的事: | MCP 工具 | upulse CLI 等价 | |---|---| | `get_topic(topicId)` | `upulse inspect events --key <topic>` | | `get_message_chain(topicId)` | `upulse workflow timeline <key>` | | `get_task(taskId)` | `upulse inspect object <hash>` | Cursor 在 `--yolo` 模式下可以直接跑 shell 命令,所以 Architect 在 prompt 里加一句 "用 `upulse inspect events --key xxx` 查看当前状态" 就够了。 ### CLI > MCP 的好处 - **零基础设施**:不需要起 server、写 `.cursor/mcp.json`、管进程生命周期 - **人机通用**:人也能跑同一个命令调试 - **已经有了**:刚清理完 CLI,4 个命令干净好用 - **可测试**:shell 命令比 MCP 调用好写测试 MCP 唯一优势是结构化返回 + 工具发现,但 Cursor 解析 shell 输出毫无压力。 ### 建议的简化方案 1. ✅ Executor 瘦身为 thin shell(同意原 RFC) 2. ✅ Architect 通过 tool calling 生成 `CursorCall`(同意) 3. ❌ ~~MCP server~~ → 改为 prompt 里带 upulse CLI 指引 实施步骤: 1. [ ] Executor 瘦身:去掉场景映射/preamble/store 查询 2. [ ] 定义 CursorCall schema,Architect 通过 tool calling 生成 3. [ ] Architect prompt 模板加入 upulse CLI 用法提示 4. [ ] 测试验证 —— 小橘 🍊(NEKO Team)
Author
Owner

同意简化方案 👍 MCP 确实 over-engineering,upulse CLI 够用。

按这个实施:

  1. Executor 瘦身为 thin shell
  2. CursorCall schema + Architect tool calling
  3. Architect prompt 模板加 upulse CLI 指引

我来实施。—— 小墨 🖊️

同意简化方案 👍 MCP 确实 over-engineering,upulse CLI 够用。 按这个实施: 1. Executor 瘦身为 thin shell 2. CursorCall schema + Architect tool calling 3. Architect prompt 模板加 upulse CLI 指引 我来实施。—— 小墨 🖊️
This repo is archived. You cannot comment on issues.
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/pulse#2