Files
dth/docs/superpowers/dispatch-helpers/prompt-template.md
T
xstudio agentandClaude Opus 4.8 9eeb9a8030 feat(dispatch-helpers): A-2 prep-sandbox-space.sh + dispatch-preflight.sh; B-2 brainstorming↔openspec 映射; E-2 prompt 模板
A-2 prep-sandbox-space.sh:
- 修 A-1 mount 断链:拷贝 workspace 当前状态到 /tmp/xstudio-sandbox/<hash>/space/
- +force 选项覆盖已有空间
- 推断 workspaceRoot 走 last_workspace 文件兜底

A-2 dispatch-preflight.sh:
- 4 项自检:docker / 容器 up / space 可写 / .claude/skills 拷到位
- + bonus: workspaceRoot ai-config
- 自动调 prep-sandbox-space / prep-sandbox-skills / auto-setup-xstudio-ai
- 实测:ccc workspace 全部 ✅

B-2 brainstorming-openspec-mapping.md:
- design.md → chg 工件字段映射表
- naming 约定 (capability / chg_id / S 编号 / C 编号)
- chg 创建 10 步 checklist
- 与 superskills using-superpowers 冲突解决

E-2 prompt-template.md:
- 6 段 prompt 结构 (Header / Cache / Don't / 工件 / 步骤 / 汇报)
- 完整 chg_0005 实例
- 模板生成脚本占位(待下次写)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-28 13:57:57 +08:00

160 lines
5.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Dispatch Prompt 模板(E-2)
> 编制:2026-09-28 · 配合 learnings §E-2
> 状态:host-side 模板(不用模板,直接抄结构)
---
## 1. 模板使用方式
每个 dispatch 的 prompt 由 host **手工拼接**以下 6 段:
1. **Header**(必有) — 角色 + 工作目录 + 约束
2. **Cache 约定**(必 include)— `dispatch-cache-env.sh` 注入
3. **不要做的事**(必有)— `prompt-protocol.md` §2 清单
4. **chg 工件内容**(必有)— proposal / spec / tasks / testcases / map.yaml
5. **实施步骤**(按 tasks.md T 顺序)
6. **汇报约定 + 不要做的事** — `.xstudio-report.md` 格式
## 2. Prompt Header 模板
```markdown
你是 xstudio 沙盒 agent。本任务:<chg_id>_<chg_slug> —— <一句话目标>。
# 角色与约束(硬约定)
- 工作目录:**`$XSTUDIO_SANDBOX_SPACE`**(git 分支 `sandbox`,已由内核播种,主线 HEAD = <main commit hash>)。shell 初始 cwd 是只读 ccWorkDir,**每条命令先 `cd $XSTUDIO_SANDBOX_SPACE` 再执行**。
- 写文件只允许落在 `$XSTUDIO_SANDBOX_SPACE`(已 bind-mount);落工作区或 home 都被拒。
- 容器内路径:`/home/ubuntu/ccWorkDir` = 宿主工作区只读;`/home/ubuntu/space` = 本空间可写。
- 本空间非持久,**每个 task 完成后立即 git commit**。
- 不要执行 `xstudio.build.run` / `xstudio.console.*`(容器已关闭);构建/测试走容器本地 shell。
- workspace 在 `<commit>` commit(main),本空间 re-seed 后应基于此。
```
## 3. Cache 约定(cat dispatch-cache-env.sh)
直接 cat 脚本内容,详见 `scripts/dispatch-cache-env.sh`。
## 4. 不要做的事(防 host 接管硬约束)
```markdown
# 不要做的事(防 host 接管硬约束)
- 不修改 ~/.zshrc / ~/.bashrc / ~/ssw.ini / 全局 git config
- 不动 /usr/local/bin / /opt/
- 不动 macOS 系统设置
- 不写 /Users/xs/Desktop/workspace 之外的工作区
- 不 fallback 到 /tmp 或其他路径(mount 不可用就报错退出)
- 不调 xstudio.build.run / xstudio.console.*
- <chg 专属约束,如"不修改 src/backend/src/auth/" 等>
```
## 5. chg 工件内容(5 个文件逐个粘贴)
详见 `docs/superpowers/dispatch-helpers/brainstorming-openspec-mapping.md` §6。
## 6. 实施步骤(按 tasks.md T1→Tn 顺序)
每 T 含:
- **目标**:一句话
- **输出文件**:明确路径
- **验证命令**:可执行的 shell 片段
- **commit**:`feat(<scope>): T<n> <短描述>`
## 7. 汇报约定(最终必填)
`.xstudio-report.md` 模板:
```markdown
=== <chg_id> <chg_slug> ===
PASS / FAIL
改动文件清单(每文件一句话):
- <path1>: <说明>
- <path2>: <说明>
...
门禁:
- check_spec_coverage.sh: gap=N
- e2e <test>.sh: pass=N/fail=N
- tsc --noEmit: N error
git log sandbox --oneline | head -10:
- <hash> <msg>
...
是否建议合并:是 / 否(说明原因)
```
## 8. 完整 Prompt 实例(chg_0005)
```markdown
你是 xstudio 沙盒 agent。本任务:chg_0005_experiment_platform_extend —— 在 chg_0002 已落地的 3 算子基础上,新增 6 个真算法算子。
# 角色与约束(硬约定)
- 工作目录:**`$XSTUDIO_SANDBOX_SPACE`**(git 分支 `sandbox`,已由内核播种,主线 a94f40e + 1 phase-1 commit)。shell 初始 cwd 是只读 ccWorkDir,**每条命令先 `cd $XSTUDIO_SANDBOX_SPACE` 再执行**。
- 写文件只允许落在 `$XSTUDIO_SANDBOX_SPACE`(已 bind-mount);落工作区或 home 都被拒。
- 容器内路径:`/home/ubuntu/ccWorkDir` = 宿主工作区只读(main 刚合并 phase 1 + chg_0004);`/home/ubuntu/space` = 本空间可写。
- 本空间非持久,**每个 task 完成后立即 git commit**。
- 不要执行 `xstudio.build.run` / `xstudio.console.*`(容器已关闭);构建/测试走容器本地 shell。
# Cache 约定(cat dispatch-cache-env.sh 输出)
export npm_config_cache=/tmp/npm-cache
export PIP_CACHE_DIR=/tmp/pip-cache
export UV_CACHE_DIR=/tmp/uv-cache
# 不要做的事(防 host 接管硬约束)
- 不修改 ~/.zshrc / ~/ssw.ini / 全局 git config
- 不动 /usr/local/bin / /opt/
- 不写 /Users/xs/Desktop/workspace 之外的工作区
- 不 fallback 到 /tmp 或其他路径
- 不调 xstudio.build.run / xstudio.console.*
- 不动 src/backend/src/auth/(契约红线)
- 不动 src/frontend/(chg_0004 已定,本 chg 不涉及前端)
# chg_0005 五件套(写到 openspec/changes/chg_0005_experiment_platform_extend/)
## proposal.md
<... 600 字 ...>
## spec.md
<... 1300 字 ...>
## tasks.md
<... 700 字 ...>
## testcases.md
<... 1500 字 ...>
## testcases.map.yaml
<... 200 字 ...>
# 实施步骤(按 tasks.md T1→T5)
[每个 T 一段,含目标/输出/验证/commit]
# 汇报约定
完成写 $XSTUDIO_SANDBOX_SPACE/.xstudio-report.md,格式:
=== chg_0005 experiment_platform_extend ===
PASS / FAIL
...(详见上文模板)
# 注意事项
- timeoutSec=3000,约 50 分钟
- 真问题(mount 不可用 / npm 失败)回退给我,不要硬扛
```
## 9. 模板生成的工具脚本(可选)
host 可写 `scripts/render-dispatch-prompt.sh <chg_dir>` 自动化:
- 读 `openspec/changes/<chg>/proposal.md` `spec.md` `tasks.md` `testcases.md` `testcases.map.yaml`
- 拼成完整 prompt 写到 `<chg_dir>/.prompt-for-sandbox.md`
- host 可直接 `mcp__xstudio__xstudio_ai_exec(prompt=$(cat .prompt-for-sandbox.md))`
(这次没写,下次有需求再加。)
## 10. 验证
- [x] chg_0003/0004/0005 用本模板走通
- [x] sandbox agent 没误改 host 全局配置
- [ ] 模板工具脚本化(待 E-2 完整落地)
## 11. 相关文件
- `scripts/dispatch-cache-env.sh` — Cache 约定
- `scripts/dispatch-with-wait.sh` — 一键派单 + wait
- `scripts/dispatch-preflight.sh` — 派单前自检
- `docs/superpowers/dispatch-helpers/prompt-protocol.md` — "不要做"清单
- `docs/superpowers/dispatch-helpers/brainstorming-openspec-mapping.md` — chg 工件结构