其他
在 cmux 中需要生成可持久审查的 HTML…
适用于请求 HTML artifact、walkthrough、证据页、演示页、artifact preview,或需要一个便于 dogfood/验证/理解变更的 cmux workspace 布局时。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 35/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 39/100 ×0.15
适用场景
在 cmux 中需要生成可持久审查的 H特定
解决思路
- 读取 `cmux-workspace` skill,再执行打开 pane、tab、browser、logs、screenshots、videos 或 generated documents。
- 将 caller cmux workspace 作为默认目标,而不是硬性要求。
- 对与任务绑定的证据(dogfood proof、failure logs、verification pages),默认放到 caller workspace 的右侧 helper pane,紧邻触发的工作。
- 当 artifact 是独立且持久的(design doc、report、reference page 用户会回来查看)、拆分 caller workspace 会挤压活动终端,或用户要求放到别处时,优先使用专用/新 workspace;用 `cmux new-workspace` 增量创建;仅当用户要求现在查看 artifact(明确说 “open it” 也算)时才切换到它;绝不要投机性调用 `select-workspace`/`focus-pane`。
- 如果不确定哪种 workspace 合适,询问用户,或选择干扰最小的选项并说明放在哪里,以便用户改向。
- 优先使用真实命令输出、logs、screenshots、traces、timings;不要编造证据。
- 最终面向用户的 artifact 不要放在 `/tmp`。
- 将最终 artifact 放在按分支限定的持久目录树:`BRANCH="$(git -C <worktree-or-repo> branch --show-current 2>/dev/null || echo task)"`、`ASSET_ROOT="/cmux-assets/${BRANCH:-task}/<artifact-slug>"`、`mkdir -p "$ASSET_ROOT"`。
- 如果 `/cmux-assets` 无法创建或写入,使用当前 repo checkout 下的 `cmux-assets/<branch>/<artifact-slug>` 并说明该 fallback;`/tmp` 只作 scratch。
- 在打开或报告前,将已采纳的 logs、screenshots、frames、videos、transcripts 复制到持久目录树。
- Step 1:收集能解释任务的最小真实 artifact 集:command transcript 或 terminal output。
- 收集 relevant logs。
- 收集 screenshots、frames、video 或 browser snapshots。
- 收集带精确时长的 timing table。
- 收集有用的 code references 或 PR links。
- 收集 cleanup state 和 remaining blockers。
- 使用简洁名称,如 `run-transcript.md`、`server.log`、`failure.log`、`screenshot.png`、`index.html`。
- Step 2:创建可独立在文件系统运行的 standalone HTML document。
- HTML 中包含被测或变更内容的 plain-language summary。
- HTML 中包含短 timeline 或 step table。
- HTML 中包含 key timings。
- HTML 中包含指向本地已复制 logs/media 的相对路径 links。
- HTML 中包含 observed failures 和直接 next action。
- HTML 中包含若创建外部资源的 cleanup status。
- 使用适合工程评审的简单、密集 UI。
- 避免 marketing sections、giant hero layouts、decorative gradients 或 hidden evidence。
- 对交互式 artifact,可以创建小型 React website 代替单个静态文档。
- React website 保持在同一个持久 `ASSET_ROOT` 下,例如 `package.json`、`server.ts`、`src/main.jsx`、`src/styles.css`、`public/`。
- 优先使用无需安装的设置,使用现有 repo dependencies 或 browser ESM imports。
- 如果安装了 `bun` 且 hosting 有助于用户操作 UI,在可见的 cmux helper terminal 中运行前台 Bun server,然后在 browser surface 中打开精确 local URL。
- 不要为 hosted artifacts 使用隐藏的 `tmux`、`nohup`、detached background servers 或 generic localhost pages。
- 如果 `bun` 不可用或 hosting 没有价值,回退到文件系统 `index.html`。
- Step 3:将最终 `index.html` 作为 browser surface 打开,导航到其 `file://` URL,且不改变焦点。
- 默认目标是 caller workspace 的右侧 helper pane,但根据 Prerequisites 可以是专用或新 workspace(独立持久 artifact,或拆分 caller workspace 会挤压活动终端)。
- 使用单独 workspace 时,向 surface/pane 命令传 `--workspace <that-workspace>`,而不是 `${CMUX_WORKSPACE_ID}`。
- 不要用 `cmux open` 打开 HTML artifacts,因为那会创建 file preview 而不是在浏览器中实际运行 artifact。
- 在 browser artifact 处理完后,再用 `cmux open` 打开 raw evidence,如 logs、Markdown transcripts、screenshots、videos。
- 先检查同一 `index.html` artifact 是否已在目标 workspace 或 helper pane 中打开。
- 如果已作为 browser surface 打开,保留该精确 surface,必要时导航到 artifact URL,然后在更新 `index.html` 后、handoff 前始终 reload:`FILE_URL="$(node -e 'const {pathToFileURL}=require("url"); console.log(pathToFileURL(process.argv[1]).href)' "$ASSET_ROOT/index.html")"`、`cmux browser --surface surface:<existing-artifact-browser> goto "$FILE_URL" --snapshot-after`、`cmux browser --surface surface:<existing-artifact-browser> reload --snapshot-after`。
- 重写同一文件后不要认为 `goto` 足够;browser surfaces 可能保留 stale file content;`reload --snapshot-after` 是当前可见 artifact 已刷新的证据。
- 如果现有 artifact 以 file preview 或其他不可 reload 的 surface 打开,关闭该精确 stale artifact surface,然后在同一 helper pane 中打开一个 browser surface。
- 如果同一 artifact 有重复 surfaces,若有 browser surface 则保留一个,关闭 stale duplicates,并导航或 reload 保留的 browser。
- 不要为同一 artifact 留下多个 `index.html` tabs,因为会让当前版本不明确。
- 将 artifact 放在自己的 pane 中,与工作并排;目标是证据可见在终端旁边,而不是藏在后面。
- 如果 caller workspace 已有合适的 right helper pane,复用它。
- 如果 workspace 是单 pane(只有 active terminal),不要将 artifact 作为该 pane 中的另一个 surface:`new-surface --pane <active-pane>` 会使其成为堆叠在终端后面的 background tab,用户看不到变化;应创建 right split。
- 使用 `new-pane --direction right` 直接在 new right pane 中打开 browser,或 `split-off` 已在 active pane 中创建的 surface。
- 单 pane workspace 命令:`cmux new-pane --workspace "${CMUX_WORKSPACE_ID:-}" --direction right --type browser --url "$FILE_URL" --focus false`。
- 已有专用 right helper pane 命令:`cmux new-surface --workspace "${CMUX_WORKSPACE_ID:-}" --pane pane:<right-helper> --type browser --url "$FILE_URL" --focus false`。
- Recovery 命令:若 artifact 作为 background tab 落在 active terminal 的 pane 中,使用 `cmux split-off --surface surface:<artifact-browser> right --focus false` 将该精确 surface 分到右侧。
- 用 `cmux open "$ASSET_ROOT/failure.log" --workspace "${CMUX_WORKSPACE_ID:-}" --pane pane:<right-helper> --no-focus` 打开 raw evidence。
- 对 hosted React artifacts,在同一 target workspace/pane 中创建或复用 helper terminal。
- 在 helper terminal 中运行 server。
- 验证 server visibly running。
- 然后打开 served URL。
- Hosted React helper terminal 命令:`cmux new-surface --workspace "${CMUX_WORKSPACE_ID:-}" --pane pane:<right-helper> --type terminal --focus false`。
- `cmux send --surface surface:<helper-terminal> "cd '$ASSET_ROOT' && PORT=<port> bun run server.ts\n"`。
- `curl -fsS "http://127.0.0.1:<port>/healthz"`。
- `cmux new-surface --workspace "${CMUX_WORKSPACE_ID:-}" --pane pane:<right-helper> --type browser --url "http://127.0.0.1:<port>/" --focus false`。
- 按 `cmux-workspace` skill 精确解析 helper pane。
- 明显时复用已有 right helper pane;不存在时用 right split(`new-pane --direction right` 或 `split-off`)创建,而不是把 artifact 堆在 active terminal 后面。
- 如果 `cmux open` 因 caller env stale 失败,用 `cmux identify --json` 输出重试一次,仍失败则报告精确路径。
- Step 4:在报告完成前验证:`test -f "$ASSET_ROOT/index.html"`。
- `ls -la "$ASSET_ROOT"`。
- 对 hosted artifacts,也在 handoff 前验证 server:`curl -fsS "http://127.0.0.1:<port>/healthz"`。
- `cmux read-screen --workspace "${CMUX_WORKSPACE_ID:-}" --surface surface:<helper-terminal> --lines 20`。
- 如果在 cmux 中打开,运行 `cmux list-pane-surfaces --workspace "${CMUX_WORKSPACE_ID:-}" --json` 或最接近等价命令来验证 tabs 已创建。
- 验证目标 helper pane 中 artifact `index.html` 只有一个可见 surface。
- 如果命令输出仍显示同一 artifact path/title 的 duplicates,在报告完成前关闭 stale duplicates。
- 验证 artifact 落在自己的 pane 中,与工作并排,而不是 active terminal pane 中的 background tab。
- 从 `list-panes --json` 确认 workspace 有一个单独 pane 持有 artifact browser surface(non-selected surface 与 active terminal 共用 pane 意味着它藏在终端后面)。
- 如果被埋住,在报告完成前用 `split-off` 将该 surface 分到右侧。
- 如果 artifact 在本任务前已打开,验证保留的 browser surface 在最终写入后已 reload。
- 若最终写入发生在最后一次 browser 命令之后,重新运行 reload。
- Rules:不要将最终 artifact 只留在 `/tmp`。
- 除非 linked transcript 显示通过,否则不要声称运行通过。
- 不要将 secrets 粘贴到 artifacts;复制 logs 前 redact API keys、tokens、cookies、Authorization headers。
- 不要抢占焦点;使用显式 workspace 和 pane refs 加 `--no-focus` 或 `--focus false`。
- Caller workspace 是默认,不是硬性要求;独立持久 artifacts 可打开在专用或新 workspace;增量创建,且仅在用户要求现在查看时才切换。
- 当存在具体 artifact path 或 deep link 时,不要打开 top-level repo 或 generic localhost page。
- 保持最终聊天回答简短,包含持久 artifact path 以及具体 next action。
适用边界 · 注意事项
- 没有 cmux 环境,或不能使用 cmux workspace/surface/pane/browser 命令时不适用;该技能依赖 cmux。
- 只需要临时草稿、不需要持久审查/复现证据,且可接受放在 `/tmp` 时,不必使用这套持久 artifact 流程。
- 无法提供真实命令输出、日志、截图、时间等证据,或需要伪造证据时不适用。