@openprd/cli 0.1.11 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.openprd/changes/adaptive-project-framing/.openprd.yaml +2 -0
  2. package/.openprd/changes/adaptive-project-framing/design.md +47 -0
  3. package/.openprd/changes/adaptive-project-framing/proposal.md +35 -0
  4. package/.openprd/changes/adaptive-project-framing/specs/agent-requirements/spec.md +16 -0
  5. package/.openprd/changes/adaptive-project-framing/task-events.jsonl +20 -0
  6. package/.openprd/changes/adaptive-project-framing/tasks.md +340 -0
  7. package/.openprd/changes/docs-anti-pollution-and-design-direction-review/.openprd.yaml +2 -0
  8. package/.openprd/changes/docs-anti-pollution-and-design-direction-review/design.md +34 -0
  9. package/.openprd/changes/docs-anti-pollution-and-design-direction-review/proposal.md +23 -0
  10. package/.openprd/changes/docs-anti-pollution-and-design-direction-review/specs/agent-requirements/spec.md +16 -0
  11. package/.openprd/changes/docs-anti-pollution-and-design-direction-review/task-events.jsonl +14 -0
  12. package/.openprd/changes/docs-anti-pollution-and-design-direction-review/tasks.md +238 -0
  13. package/.openprd/changes/loop-isolated-worktree-commit/.openprd.yaml +2 -0
  14. package/.openprd/changes/loop-isolated-worktree-commit/design.md +53 -0
  15. package/.openprd/changes/loop-isolated-worktree-commit/proposal.md +38 -0
  16. package/.openprd/changes/loop-isolated-worktree-commit/specs/agent-requirements/spec.md +16 -0
  17. package/.openprd/changes/loop-isolated-worktree-commit/task-events.jsonl +22 -0
  18. package/.openprd/changes/loop-isolated-worktree-commit/tasks.md +357 -0
  19. package/.openprd/changes/openprd/.openprd.yaml +2 -0
  20. package/.openprd/changes/openprd/design.md +46 -0
  21. package/.openprd/changes/openprd/proposal.md +36 -0
  22. package/.openprd/changes/openprd/specs/agent-requirements/spec.md +16 -0
  23. package/.openprd/changes/openprd/task-events.jsonl +23 -0
  24. package/.openprd/changes/openprd/tasks.md +242 -0
  25. package/.openprd/changes/openprd-generated-change/.openprd.yaml +2 -0
  26. package/.openprd/changes/openprd-generated-change/design.md +50 -0
  27. package/.openprd/changes/openprd-generated-change/proposal.md +37 -0
  28. package/.openprd/changes/openprd-generated-change/specs/agent-requirements/spec.md +16 -0
  29. package/.openprd/changes/openprd-generated-change/task-events.jsonl +21 -0
  30. package/.openprd/changes/openprd-generated-change/tasks.md +357 -0
  31. package/.openprd/changes/pm-human-in-the-loop/.openprd.yaml +2 -0
  32. package/.openprd/changes/pm-human-in-the-loop/design.md +38 -0
  33. package/.openprd/changes/pm-human-in-the-loop/proposal.md +29 -0
  34. package/.openprd/changes/pm-human-in-the-loop/specs/agent-requirements/spec.md +16 -0
  35. package/.openprd/changes/pm-human-in-the-loop/task-events.jsonl +18 -0
  36. package/.openprd/changes/pm-human-in-the-loop/tasks.md +306 -0
  37. package/.openprd/changes/test-strategy-router/.openprd.yaml +2 -0
  38. package/.openprd/changes/test-strategy-router/design.md +65 -0
  39. package/.openprd/changes/test-strategy-router/proposal.md +45 -0
  40. package/.openprd/changes/test-strategy-router/specs/agent-requirements/spec.md +16 -0
  41. package/.openprd/changes/test-strategy-router/task-events.jsonl +1 -0
  42. package/.openprd/changes/test-strategy-router/tasks.md +132 -0
  43. package/.openprd/changes/verify-boundaries-and-historical-refresh/.openprd.yaml +2 -0
  44. package/.openprd/changes/verify-boundaries-and-historical-refresh/design.md +28 -0
  45. package/.openprd/changes/verify-boundaries-and-historical-refresh/proposal.md +23 -0
  46. package/.openprd/changes/verify-boundaries-and-historical-refresh/specs/agent-requirements/spec.md +16 -0
  47. package/.openprd/changes/verify-boundaries-and-historical-refresh/task-events.jsonl +11 -0
  48. package/.openprd/changes/verify-boundaries-and-historical-refresh/tasks.md +66 -0
  49. package/.openprd/changes/vibe-coding-dev-check/.openprd.yaml +2 -0
  50. package/.openprd/changes/vibe-coding-dev-check/design.md +37 -0
  51. package/.openprd/changes/vibe-coding-dev-check/proposal.md +28 -0
  52. package/.openprd/changes/vibe-coding-dev-check/specs/agent-requirements/spec.md +16 -0
  53. package/.openprd/changes/vibe-coding-dev-check/task-events.jsonl +18 -0
  54. package/.openprd/changes/vibe-coding-dev-check/tasks.md +306 -0
  55. package/.openprd/design/README.md +11 -6
  56. package/.openprd/design/README_EN.md +4 -1
  57. package/.openprd/design/active/asset-spec.md +6 -0
  58. package/.openprd/design/active/direction-plan.md +5 -5
  59. package/.openprd/design/active/selected-direction.md +2 -0
  60. package/.openprd/design/anti-slop.md +26 -1
  61. package/.openprd/design/assets/surface-presets.md +6 -0
  62. package/.openprd/design/checklists/ui-quality-gate.md +7 -0
  63. package/.openprd/design/lenses/frontend-lenses.md +28 -0
  64. package/.openprd/design/recipes/content-experience.md +8 -1
  65. package/.openprd/design/recipes/operational-tool.md +7 -0
  66. package/.openprd/design/recipes/product-launch.md +8 -1
  67. package/.openprd/design/templates/README.md +6 -3
  68. package/.openprd/design/templates/README_EN.md +6 -3
  69. package/.openprd/design/templates/ops-dashboard.html +8 -1
  70. package/.openprd/design/templates/product-launch.html +2 -1
  71. package/.openprd/design/themes/theme-catalog.json +23 -5
  72. package/.openprd/engagements/active/prd.md +137 -112
  73. package/.openprd/standards/config.json +7 -1
  74. package/AGENTS.md +13 -3
  75. package/README.md +127 -14
  76. package/README_EN.md +156 -13
  77. package/package.json +1 -1
  78. package/scripts/dev-check-wrapup-copy.mjs +46 -21
  79. package/skills/openprd-diagram-review/SKILL.md +27 -2
  80. package/skills/openprd-diagram-review/references/explanation-svg-patterns.md +131 -0
  81. package/skills/openprd-discovery-loop/SKILL.md +2 -2
  82. package/skills/openprd-frontend-design/SKILL.md +44 -20
  83. package/skills/openprd-frontend-design/references/design-asset-contract.md +6 -0
  84. package/skills/openprd-frontend-design/references/direction-engine.md +29 -4
  85. package/skills/openprd-harness/SKILL.md +22 -16
  86. package/skills/openprd-quality/SKILL.md +10 -8
  87. package/skills/openprd-requirement-intake/SKILL.md +2 -0
  88. package/skills/openprd-router/SKILL.md +2 -1
  89. package/skills/openprd-shared/SKILL.md +26 -16
  90. package/skills/openprd-standards/SKILL.md +4 -2
  91. package/src/agent-canonical-content.js +810 -0
  92. package/src/agent-integration.js +258 -777
  93. package/src/canvas-app-client-app.js +838 -0
  94. package/src/canvas-app-client-helpers.js +1138 -0
  95. package/src/canvas-app-styles.js +898 -0
  96. package/src/canvas-app.html.js +135 -0
  97. package/src/canvas-binding.js +414 -0
  98. package/src/canvas-codex-relay.js +430 -0
  99. package/src/canvas-i18n.js +282 -0
  100. package/src/canvas-scene.js +377 -0
  101. package/src/canvas-session-store.js +148 -0
  102. package/src/canvas-workspace.js +1264 -0
  103. package/src/cli/args.js +72 -4
  104. package/src/cli/basic-print.js +3 -0
  105. package/src/cli/canvas-print.js +106 -0
  106. package/src/cli/doctor-print.js +20 -0
  107. package/src/cli/print.js +2 -0
  108. package/src/cli/quality-commands.js +222 -0
  109. package/src/cli/quality-print.js +28 -2
  110. package/src/cli/run-print.js +5 -0
  111. package/src/cli/workflow-print.js +3 -0
  112. package/src/codex-app-server-relay.js +251 -0
  113. package/src/codex-hook-runner-template.mjs +978 -58
  114. package/src/design-starter-support.js +2 -2
  115. package/src/design-starter.js +39 -3
  116. package/src/dev-standards.js +125 -10
  117. package/src/diagram-core.js +6 -20
  118. package/src/discovery.js +2 -8
  119. package/src/docs-compact.js +125 -0
  120. package/src/execution-strategy.js +1 -1
  121. package/src/fleet.js +9 -3
  122. package/src/guide.js +227 -0
  123. package/src/html-artifacts.js +428 -7
  124. package/src/knowledge.js +45 -11
  125. package/src/language-policy.js +63 -3
  126. package/src/learning-review.js +1 -1
  127. package/src/loop.js +1 -1
  128. package/src/openprd.js +68 -131
  129. package/src/openspec/change-validate.js +2 -2
  130. package/src/openspec/constants.js +6 -7
  131. package/src/openspec/execute.js +2 -2
  132. package/src/openspec/generate.js +318 -102
  133. package/src/openspec/migration.js +168 -0
  134. package/src/openspec/paths.js +1 -22
  135. package/src/prd-core.js +1 -1
  136. package/src/quality-visual-review.js +257 -14
  137. package/src/quality.js +46 -8
  138. package/src/review-presentation.js +60 -0
  139. package/src/run-harness.js +41 -3
  140. package/src/session-evidence.js +363 -0
  141. package/src/standards.js +64 -0
  142. package/src/test-strategy.js +7 -4
  143. package/src/visual-compare-centering.js +622 -0
  144. package/src/visual-compare-core.js +1123 -0
  145. package/src/visual-compare.js +620 -698
  146. package/src/workspace-core.js +94 -4
  147. package/src/workspace-workflow.js +46 -1
package/README.md CHANGED
@@ -100,9 +100,15 @@ OpenPrd 会生成可以直接分享的 HTML 面板,让产品、研发和 Agent
100
100
  ### 效果图与截图拼图对比,自动优化
101
101
 
102
102
  把效果图和实现截图放进同一张左右对比图里,适合登录入口改造、条款页本地化、弹窗复刻这类阶段性评审。
103
+ 视觉证据会跟随当前任务语境选择语言:中文需求默认输出中文标签,英文需求默认输出英文标签;需要固定语言时可显式传入 `--locale zh-CN` 或 `--locale en`,证据板里的标题、摘要和检查项也会一起跟随。
103
104
 
104
105
  ![效果图与截图拼图对比,自动优化](https://raw.githubusercontent.com/mileson/openprd/main/docs/assets/openprd-visual-compare-case-study-zh.png)
105
106
 
107
+ ```bash
108
+ openprd visual-compare . --reference ref.png --actual actual.png --locale zh-CN
109
+ openprd visual-compare . --board verification-board.json --locale en
110
+ ```
111
+
106
112
  ## 自我成长机制
107
113
 
108
114
  OpenPrd 会沿着两条看得见的循环,越用越贴合你们的协作方式。一条循环把真实项目里反复验证过的做法沉淀成可复用的 `项目级 Skill`;另一条循环把不同场景下更合适的协作设置沉淀成 `动态参数配置`,让下次启动时直接带上更合适的默认做法。
@@ -211,7 +217,7 @@ openprd init /path/to/project --template-pack agent
211
217
  npx @openprd/cli@latest init /path/to/project --template-pack agent
212
218
  ```
213
219
 
214
- `init` 会创建 `.openprd/`、`docs/basic/`、`AGENTS.md`,并生成 Codex / Claude / Cursor 三端引导。Codex 项目会同时写入 `.codex/config.toml`、`.codex/hooks.json`、`.codex/hooks/openprd-hook.mjs`,并开启用户级 Codex `hooks = true`。
220
+ `init` 会创建 `.openprd/`、`docs/basic/`、`AGENTS.md`,并生成 Codex / Claude / Cursor 三端引导。`.openprd/` 是项目内唯一的 OpenPrd 工作区;change、spec、task 和 archive 产物都会收敛到 `.openprd/changes/`、`.openprd/specs/` 和 `.openprd/archive/changes/`,不再在仓库根目录生成单独的 `openprd/` 目录。Codex 项目会同时写入 `.codex/config.toml`、`.codex/hooks.json`、`.codex/hooks/openprd-hook.mjs`,并开启用户级 Codex `hooks = true`。
215
221
 
216
222
  Codex hooks 默认使用 `lite` 模式:安装 `UserPromptSubmit`、轻量
217
223
  `PreToolUse` 写入门禁,以及轻量 `Stop` 收工回顾。明确提到 OpenPrd、PRD、深度调研、深度对标、复刻、
@@ -309,13 +315,17 @@ openprd review /path/to/project --mark confirmed --version <id> --digest <sha256
309
315
  ```
310
316
 
311
317
  `review.html` 是当前 PRD 的稳定评审稿,但默认 approval policy 是
312
- `decision-points`,不是“每次都必须停在这里”。常规 lane 下,用户先看稳定
313
- artifact,再用页面复制出来的精确 `--version`、`--digest`、`--work-unit`
314
- 记录确认;`silent-record` lane 只有在用户一开始已经明确要求直接做、并显式
315
- 表示不需要额外评审或确认时,才允许直接记录当前这份精确 artifact。不要把
316
- 实现授权当成给任意评审稿补确认,也不要把评审记录当成实现授权。当前 artifact
317
- 记录完成后,再生成 OpenPrd change 和任务拆解;如果用户原始意图已明确要求
318
- 实现,tasks 就绪后即可直接执行,否则等待一句明确的执行指令:
318
+ `decision-points`,不是“每次都必须停在这里”。常规 lane 下,一句自然语言
319
+ 确认(例如“确认这版,继续”,容忍“确认 v0276 评审稿”这类版本号插写)就足够:
320
+ hook 会自动把确认绑定到当前精确的 `--version`、`--digest`、`--work-unit`,
321
+ Agent 不允许反过来向用户索要 digest、work-unit 或完整命令。当这句确认同时
322
+ 带有“继续执行”意图,或此前已确认过需求摘要时,一次确认会解锁整条链:评审
323
+ 记录、change、tasks 与实现全程直通,不再逐环节停下(一次确认合同)。
324
+ `silent-record` lane 只有在用户一开始已经明确要求直接做、并显式表示不需要
325
+ 额外评审或确认时,才允许直接记录当前这份精确 artifact。不要把实现授权当成
326
+ 给任意评审稿补确认,也不要把评审记录当成实现授权。当前 artifact 记录完成后,
327
+ 再生成 OpenPrd change 和任务拆解;如果用户原始意图已明确要求实现,tasks
328
+ 就绪后即可直接执行,否则等待一句明确的执行指令:
319
329
 
320
330
  ```bash
321
331
  openprd change /path/to/project --generate --change <change-id>
@@ -443,6 +453,42 @@ OpenPrd 生成的 change 会包含标准化维护任务,change 校验也会检
443
453
  或产品行为变化影响,也必须同步更新。如果无需更新,应说明已经完成影响判定以及
444
454
  为什么现有文档仍然准确。
445
455
 
456
+ ## 生图路由:自动选对免费生图工具
457
+
458
+ 图片、封面图、效果图、图标等生图请求按三层路由自动选工具,不需要用户指定:
459
+
460
+ 1. **工具面判定**:Codex 环境用原生 `imagegen`(Image 2),Cursor 环境用内置
461
+ `GenerateImage`——两者都是对话工具内的免费能力,优先直接使用。
462
+ 2. **已存偏好**:都不可用或无法判断时,先读
463
+ `.openprd/harness/image-generation-preference.json` 里用户已确认的偏好,
464
+ 有就直接用,不再重复询问。
465
+ 3. **询问并持久化**:没有偏好时才问用户一次,答复以 `user-confirmed` 来源
466
+ 写回该文件,作为下次默认。
467
+
468
+ 成本护栏:任何情况下都不允许在用户未明确指定时,擅自调用用户本地或自有的
469
+ 付费生图 API(例如 OpenAI / Stability key)。路由协议由 install manifest 和
470
+ `.openprd/harness/runtime-environment.json` 的 `imageGenerationRouting` 字段承载。
471
+
472
+ ## 画布协同:标注改图闭环
473
+
474
+ `openprd canvas .` 打开与当前对话绑定的本地 Excalidraw 画布后,AI 生成的图会
475
+ 直接落到画布上,你可以在图上直接画圈、写字做标注,然后点击“发送给 Codex”,
476
+ 剩下的交给 Agent:
477
+
478
+ 1. **标注即指令**:画布检测到选区里同时有原图和你的手绘标注时,会把这次交接
479
+ 标记为标注改图请求,把标注截图和结构化元数据(原图 ID、标注 ID)一起交给
480
+ Agent,Agent 把标注当作修改指令生成新图。
481
+ 2. **旁位回填,不覆盖原图**:Agent 通过 `POST /api/insert-image` 用原图作 anchor
482
+ 把新图放到旁边(右/左/上/下可选),你可以左右对比原图和新版,再继续在新图
483
+ 上标注,形成多轮迭代闭环。
484
+ 3. **结构化读画布**:Agent 通过 `GET /api/selection` 读到你正在圈选哪些元素的
485
+ ID、坐标、尺寸和文本,不再只靠截图猜。
486
+ 4. **尺寸契约**:AI 生图占位卡的宽高和比例会作为 `sizeContract` 写进生图提示,
487
+ 生成的图片按占位卡比例出图,回填不变形。
488
+
489
+ 唤起方式:在对话里自然地说“打开画布一起看”“我在画布上标注了,按标注改图”
490
+ 这类话,hook 会自动注入画布协同指引;也可以直接运行 `openprd canvas . --daemon --open`。
491
+
446
492
  ## 效果图与截图拼图对比,自动优化
447
493
 
448
494
  当界面任务已经有效果图、设计稿、用户给图或 Agent 自己生成的 mock 时,Agent
@@ -482,6 +528,65 @@ openprd visual-compare /path/to/project \
482
528
  Agent 必须查看生成图并继续对标,直到没有明显视觉差异。最终回复里应给出本次
483
529
  生成的对比图路径,并说明对比后是否仍有差异。
484
530
 
531
+ 如果新功能或改动包含同构列表、卡片、网格或表格,或者用户反馈“没对齐”“排版
532
+ 漂移”,Agent 还要把真实截图、辅助线、容器轨道量测和内部内容槽位量测放到一张对齐证据板里:
533
+
534
+ ```bash
535
+ openprd visual-compare /path/to/project \
536
+ --board alignment-board.json
537
+ ```
538
+
539
+ `alignment-board.json` 使用 `mode: "alignment-board"`,记录截图、辅助线、
540
+ 容器分组和内容槽位分组。容器轨道包括卡片外框、列宽、行顶、间距等;
541
+ 内容槽位包括标题、副标题、标签、描述、状态、价格、按钮、图标和操作区等
542
+ 相同文案类型/相同组件槽位的 x/y/宽高/baseline spread。列表卡片、卡片网格和
543
+ 表格这类重复结构属于默认触发场景,不需要等用户先指出“没有对齐”;只量外框、
544
+ 列宽或行顶不算完整对齐验收。
545
+
546
+ 如果要判断单个 logo、icon、avatar、badge、按钮图形或图片裁切内部是否居中,
547
+ 或者用户反馈“偏心”“视觉重心不对”,Agent 应先裁出目标元素,再生成内部居中证据板:
548
+
549
+ ```bash
550
+ openprd visual-compare /path/to/project \
551
+ --board centering-board.json
552
+ ```
553
+
554
+ 最小语法如下:
555
+
556
+ ```json
557
+ {
558
+ "mode": "centering-board",
559
+ "title": "Logo 内部居中检查",
560
+ "image": ".openprd/harness/screenshots/logo.png",
561
+ "thresholdPx": 8,
562
+ "subject": {
563
+ "mode": "auto",
564
+ "weight": "contrast"
565
+ }
566
+ }
567
+ ```
568
+
569
+ 如果自动 mask 把背景、阴影或透明边缘算进主体,可以显式指定颜色范围:
570
+
571
+ ```json
572
+ {
573
+ "mode": "centering-board",
574
+ "image": ".openprd/harness/screenshots/logo.png",
575
+ "subject": {
576
+ "mode": "range",
577
+ "ranges": [
578
+ { "r": [180, 255], "g": [140, 255], "b": [0, 120] },
579
+ { "r": [210, 255], "g": [210, 255], "b": [200, 255] }
580
+ ],
581
+ "weight": "luma"
582
+ }
583
+ }
584
+ ```
585
+
586
+ `centering-board` 会输出红色画布中心线、绿色主体外接框、黄色视觉重心点,
587
+ 并在 metadata 里记录主体外接框中心偏移和视觉重心偏移。单张原始截图或
588
+ “看起来居中”的主观判断不能替代这张证据板。
589
+
485
590
  ## 回归测试与质量评估报告
486
591
 
487
592
  `openprd init` 同时会创建质量契约:
@@ -510,7 +615,10 @@ openprd quality /path/to/project --verify
510
615
  `openprd run --verify` 会再次执行这个质量门禁。Agent 不得在本期必测块缺证据或需关注时宣称就绪。
511
616
  如果界面任务已有参考图,视觉就绪还需要 `.openprd/harness/visual-reviews/`
512
617
  下存在本次 `openprd visual-compare --reference/--actual` 产物;如果没有参考图但改动界面,
513
- 还需要存在 `openprd visual-compare --before/--after` 修改前后产物。对比图仍有明显差异或漂移时,应回到实现继续调整。
618
+ 还需要存在 `openprd visual-compare --before/--after` 修改前后产物。普通截图实测需要截图实测证据板;
619
+ 同构列表、卡片、网格或表格还需要对齐辅助线证据板,并同时覆盖容器轨道和内部内容槽位;
620
+ 单个素材、图标、头像、徽标、按钮图形或图片内部居中/视觉重心判断需要内部居中证据板。
621
+ 对比图仍有明显差异、坐标偏差或漂移时,应回到实现继续调整。
514
622
 
515
623
  当一个问题已经修复并完成验证后,可以把抽象模式沉淀为项目级经验:
516
624
 
@@ -568,10 +676,12 @@ openprd loop /path/to/project --run --agent codex --dry-run
568
676
 
569
677
  `doctor` 会检查三端引导、Codex hooks 开关、项目标准化和 OpenPrd 工作区验证是否健康,同时展示像 Context7 / DeepWiki 这类可选增强建议。`update` 会从 OpenPrd 的统一源刷新这些生成文件,并保留用户自己已有的 hook 分组。
570
678
 
679
+ 新版本更新会自动识别旧项目遗留的根目录 `openprd/changes/`、`openprd/specs/` 和 `openprd/archive/changes/`,并把内容迁移到 `.openprd/` 对应位置;无冲突时会删除空的旧 `openprd/` 目录。若同名文件内容不同,旧文件会保留在原处并让本次更新失败,避免静默覆盖用户数据。
680
+
571
681
  `self-update` 只更新 OpenPrd CLI 自身,默认使用公开 npm 包。
572
682
  `upgrade` 会编排两层更新:先执行 `self-update`,再重新解析安装后的
573
683
  `openprd` 可执行文件,然后执行 `update <project>`;加 `--fleet` 时会执行
574
- `fleet <root> --update-openprd`,只刷新已有 `.openprd/` 的历史项目。两个入口都支持
684
+ `fleet <root> --update-openprd`,刷新已有 `.openprd/` 的历史项目,并识别只有旧根目录 `openprd/` 工作产物的项目完成迁移。两个入口都支持
575
685
  `--dry-run`,预演时只打印安装和刷新命令,不修改 CLI、项目、registry 或 harness 状态。
576
686
 
577
687
  这套 harness 是有状态的,但 hook 重量由 profile 控制。默认 `lite` 保留轻量
@@ -589,7 +699,9 @@ Claude Code 中优先用 Playwright、MCP 浏览器自动化或项目已有 e2e
589
699
  通过后,`loop --finish` 会写入阶段性测试报告,并可在隔离 worktree 中为该任务生成独立 commit。
590
700
  界面任务完成前必须运行 `openprd visual-compare`:已有参考图时截实现图并走
591
701
  `--reference/--actual`,没有参考图但改动界面时先留修改前截图、完成后留修改后截图并走
592
- `--before/--after`,查看左右对比 JPG 后才能完成任务。
702
+ `--before/--after`,普通截图实测走 `--board <verification-board.json>`,同构列表、卡片、网格或表格走
703
+ `--board <alignment-board.json>`,单元素内部居中/视觉重心问题走
704
+ `--board <centering-board.json>`,查看证据图后才能完成任务。
593
705
 
594
706
  `openprd run --context` 可能展示 loop 相关执行命令,但它不是自动执行指令。
595
707
  只有当用户当前明确要求开发、实现、继续任务、深度调研、深度对标、复刻落地或
@@ -636,10 +748,11 @@ Loop 状态会沉淀在 `.openprd/harness/`:
636
748
  OpenPrd 面向用户的时间统一使用上海时区的 `YYYY-MM-DD HH:mm:ss` 格式,不输出
637
749
  `T`、`Z` 或毫秒后缀。除命令、字段名、文件路径、API 名称、品牌名和产品名等必要
638
750
  专有术语外,生成文档、进度日志、proposal、prompt、测试报告,以及 Agent 产出的
639
- `spec.md` 与 tasks 默认使用简体中文。结构字段优先使用“新增需求”“需求”“场景”
640
- “当”“则”等中文表达,同时继续兼容历史 OpenSpec 英文结构字段。
751
+ `spec.md` 与 tasks 默认跟随当前输入和 PRD 快照的主语言:中文语境使用简体中文,
752
+ 英文语境保持英文,无法判断时回退到简体中文。结构字段继续兼容历史英文
753
+ 结构字段;明确要求 `zh-CN` 的图示和合同场景仍会强制使用中文。
641
754
 
642
- 历史项目不要手写 shell 循环批量改。使用 `fleet` 先扫描报告;它现在会顺带提示全局 registry 里已经登记了多少 OpenPrd 工作区、当前 root 外还有多少已知项目。`--sync-registry` 用来把当前 root 下已初始化的 `.openprd/` 工作区回填到 `~/.openprd/registry/workspaces.jsonl`。`--update-openprd` 只刷新已经有 `.openprd/` 的项目,项目自身 standards 或 validate 缺口会作为“项目健康需关注”报告,但不阻断生成引导更新;只有 agent 配置或普通项目默认保持不变,除非显式用 `--setup-missing` 接管。
755
+ 历史项目不要手写 shell 循环批量改。使用 `fleet` 先扫描报告;它现在会顺带提示全局 registry 里已经登记了多少 OpenPrd 工作区、当前 root 外还有多少已知项目。`--sync-registry` 用来把当前 root 下已初始化的 `.openprd/` 工作区回填到 `~/.openprd/registry/workspaces.jsonl`。`--update-openprd` 会刷新已有 `.openprd/` 的项目,也会把只包含旧根目录 `openprd/changes/`、`openprd/specs/` 或 `openprd/archive/changes/` 的历史项目识别为 OpenPrd 工作区并迁移到 `.openprd/`;项目自身 standards 或 validate 缺口会作为“项目健康需关注”报告,但不阻断生成引导更新。只有 agent 配置或普通项目默认保持不变,除非显式用 `--setup-missing` 接管。
643
756
 
644
757
  ## 怎么看 `status` / `next`
645
758
 
package/README_EN.md CHANGED
@@ -130,9 +130,18 @@ one human-readable quality surface before handoff, release, or publish.
130
130
  Put the reference and implementation into one side-by-side artifact for staged
131
131
  UI review, especially for auth-entry redesign, localized legal pages, and modal
132
132
  replication work.
133
+ Visual evidence follows the current task language by default: Chinese requests
134
+ produce Chinese labels, English requests produce English labels, and
135
+ `--locale zh-CN` or `--locale en` can pin the output language for side-by-side labels,
136
+ board titles, summaries, and checks.
133
137
 
134
138
  ![Auto-optimized reference-to-screenshot comparison](https://raw.githubusercontent.com/mileson/openprd/main/docs/assets/openprd-visual-compare-case-study-en.png)
135
139
 
140
+ ```bash
141
+ openprd visual-compare . --reference ref.png --actual actual.png --locale zh-CN
142
+ openprd visual-compare . --board verification-board.json --locale en
143
+ ```
144
+
136
145
  ## Self-Evolving Collaboration
137
146
 
138
147
  OpenPrd gets easier to work with over time through two visible loops. One loop
@@ -172,6 +181,7 @@ automatically.
172
181
  - **Project-level benchmark registry**: support `benchmark add / observe / approve / verify` so repeatedly adopted external sources can become durable project references
173
182
  - **Diagram review artifacts**: generate both architecture and product-flow diagrams
174
183
  - **UI visual comparison artifacts**: combine reference images and implementation screenshots into side-by-side JPG reviews for visual replication work
184
+ - **Language-aware visual evidence**: localize comparison labels and board copy from the active request language, with `--locale` / `--lang` overrides when a project needs a fixed output language
175
185
  - **Contract-driven diagrams**: render from validated JSON contracts
176
186
  - **Review status tracking**: use `pending-confirmation`, `confirmed`, and `needs-revision`
177
187
  - **Project release/version ledger**: optionally track project versions such as `0.1.23`, version-scoped change items, and local git tag coordination without mixing them with internal PRD `v000x` versions
@@ -355,16 +365,23 @@ openprd review /path/to/project --mark confirmed --version <id> --digest <sha256
355
365
 
356
366
  `review.html` is the stable review artifact for the current PRD, but the default
357
367
  approval policy is `decision-points`, not “always stop here”. In a normal lane,
358
- the user reviews that stable artifact first and then the exact copied
359
- `--version`, `--digest`, and `--work-unit` tuple is recorded. In a
360
- `silent-record` lane, OpenPrd can record the exact current artifact without an
361
- extra stop only when the user already made direct execution intent explicit and
362
- explicitly opted out of additional review confirmation. Do not treat
363
- implementation approval as permission to mark a different review artifact, and
364
- do not treat review recording as execution authorization. After the current
365
- artifact is recorded, generate the OpenPrd change and task breakdown. If the
366
- user originally asked to implement, execution can continue once tasks are ready;
367
- otherwise wait for an explicit execution request:
368
+ one plain natural-language confirmation (for example “确认这版,继续”, including
369
+ wording with an inline version id such as “确认 v0276 评审稿”) is enough: the
370
+ hook binds it to the exact current `--version`, `--digest`, and `--work-unit`
371
+ tuple automatically, and the agent must never ask the user to paste a digest,
372
+ work-unit id, or a full command. When that confirmation also carries a
373
+ continue-execution intent, or a requirement summary was already confirmed
374
+ earlier, one confirmation authorizes the whole chain: review recording, change,
375
+ tasks, and implementation proceed without further stops (the one-time
376
+ confirmation contract). In a `silent-record` lane, OpenPrd can record the exact
377
+ current artifact without an extra stop only when the user already made direct
378
+ execution intent explicit and explicitly opted out of additional review
379
+ confirmation. Do not treat implementation approval as permission to mark a
380
+ different review artifact, and do not treat review recording as execution
381
+ authorization. After the current artifact is recorded, generate the OpenPrd
382
+ change and task breakdown. If the user originally asked to implement, execution
383
+ can continue once tasks are ready; otherwise wait for an explicit execution
384
+ request:
368
385
 
369
386
  ```bash
370
387
  openprd change /path/to/project --generate --change <change-id>
@@ -501,6 +518,50 @@ the change affects responsibilities, flows, structure, dependencies, or product
501
518
  behavior. If no documentation update is needed, agents should say the check was
502
519
  performed and why the existing docs still match the code.
503
520
 
521
+ ## Image-generation routing: pick the right free tool automatically
522
+
523
+ Image requests (covers, mockups, icons, effect images) follow a three-layer
524
+ routing protocol, so users never have to specify a provider:
525
+
526
+ 1. **Surface built-ins first**: Codex uses native `imagegen` (Image 2), Cursor
527
+ uses the built-in `GenerateImage` tool — both are free inside their surfaces.
528
+ 2. **Persisted preference**: when no built-in tool is available, OpenPrd reads
529
+ the user-confirmed preference from
530
+ `.openprd/harness/image-generation-preference.json` and reuses it silently.
531
+ 3. **Ask once, persist**: only when no preference exists does OpenPrd ask the
532
+ user once, then writes the answer back with a `user-confirmed` source as the
533
+ future default.
534
+
535
+ Cost guardrail: OpenPrd never silently calls the user’s own paid image APIs
536
+ (for example OpenAI or Stability keys) unless the user explicitly picked one.
537
+ The routing contract ships in the install manifest and
538
+ `.openprd/harness/runtime-environment.json` under `imageGenerationRouting`.
539
+
540
+ ## Canvas collaboration: the annotation-to-revision loop
541
+
542
+ `openprd canvas .` opens a local Excalidraw canvas bound to the current
543
+ conversation. AI-generated images land on the canvas, you draw circles and
544
+ notes directly on top of them, click “Send to Codex”, and the agent takes over:
545
+
546
+ 1. **Annotations become edit instructions**: when a selection contains both an
547
+ image and hand-drawn annotations, the handoff is tagged as an
548
+ annotation-edit request with structured metadata (source image IDs,
549
+ annotation IDs), and the agent treats the marks as revision instructions.
550
+ 2. **Side-by-side insertion, never overwriting**: the agent calls
551
+ `POST /api/insert-image` with the original image as the anchor to place the
552
+ revised image beside it (right/left/above/below), so you can compare both
553
+ versions and annotate the new one for another round.
554
+ 3. **Structured canvas reads**: `GET /api/selection` gives the agent the IDs,
555
+ coordinates, sizes, and text of whatever you selected — no more guessing
556
+ from screenshots.
557
+ 4. **Size contract**: placeholder card width/height/aspect ratio travel as a
558
+ `sizeContract` inside the generation prompt, so images come back at the
559
+ right ratio without distortion.
560
+
561
+ To invoke it, just say things like “open the canvas” or “I annotated the image
562
+ on the canvas, revise it accordingly” — the hook injects the collaboration
563
+ guidance automatically. You can also run `openprd canvas . --daemon --open`.
564
+
504
565
  ## Auto-optimized reference-to-screenshot comparison
505
566
 
506
567
  When UI work already has a reference effect image, design image, user-provided
@@ -547,6 +608,71 @@ obvious visual differences. The final response for reference-driven UI work
547
608
  should include the generated review image path and note whether differences
548
609
  remain.
549
610
 
611
+ When a new feature or visible change contains repeated homogeneous lists, cards,
612
+ grids, or tables, or when the user reports misalignment, the agent should also
613
+ capture the real UI, overlay guide lines, and measure both container-track and
614
+ internal content-slot coordinate spread in one alignment evidence board:
615
+
616
+ ```bash
617
+ openprd visual-compare /path/to/project \
618
+ --board alignment-board.json
619
+ ```
620
+
621
+ Use `mode: "alignment-board"` in the board JSON. Include the screenshot, guide
622
+ lines, container groups, content-slot groups, and x/y/width/height/baseline
623
+ spread. Container tracks include card edges, columns, row tops, and gaps.
624
+ Internal content slots include titles, subtitles, tags, descriptions, status,
625
+ prices, buttons, icons, and action areas. Repeated card lists, card grids, and
626
+ tables are default triggers even when the user did not explicitly complain
627
+ about alignment; measuring only outer frames, columns, or row tops is not enough.
628
+
629
+ When a single logo, icon, avatar, badge, button graphic, or image crop needs
630
+ internal centering review, or when the user reports that its visual weight feels
631
+ off-center, crop the target if needed and generate a centering evidence board:
632
+
633
+ ```bash
634
+ openprd visual-compare /path/to/project \
635
+ --board centering-board.json
636
+ ```
637
+
638
+ Minimal syntax:
639
+
640
+ ```json
641
+ {
642
+ "mode": "centering-board",
643
+ "title": "Logo internal centering check",
644
+ "image": ".openprd/harness/screenshots/logo.png",
645
+ "thresholdPx": 8,
646
+ "subject": {
647
+ "mode": "auto",
648
+ "weight": "contrast"
649
+ }
650
+ }
651
+ ```
652
+
653
+ If the automatic mask includes background, shadow, or transparent padding, use
654
+ explicit color ranges:
655
+
656
+ ```json
657
+ {
658
+ "mode": "centering-board",
659
+ "image": ".openprd/harness/screenshots/logo.png",
660
+ "subject": {
661
+ "mode": "range",
662
+ "ranges": [
663
+ { "r": [180, 255], "g": [140, 255], "b": [0, 120] },
664
+ { "r": [210, 255], "g": [210, 255], "b": [200, 255] }
665
+ ],
666
+ "weight": "luma"
667
+ }
668
+ }
669
+ ```
670
+
671
+ `centering-board` draws the red canvas center, green active subject bounds, and
672
+ yellow visual centroid, then stores bounding-box center offset and
673
+ visual-centroid offset in metadata. A raw screenshot or subjective “looks
674
+ centered” note is not a substitute for this board.
675
+
550
676
  ## Quality Regression Reports
551
677
 
552
678
  `openprd init` also creates a quality contract:
@@ -584,8 +710,14 @@ scope for the scenario.
584
710
 
585
711
  For UI work with an existing reference image, visual readiness also requires a
586
712
  current `openprd visual-compare` artifact under `.openprd/harness/visual-reviews/`.
587
- If the combined image still shows obvious differences, the task should return to
588
- implementation instead of treating the gap as ready.
713
+ Before/after UI changes require a before/after artifact, screenshot-based
714
+ runtime checks require a verification board, and homogeneous lists, cards,
715
+ grids, or tables require an alignment board that covers both container tracks
716
+ and internal content slots. Single-logo, icon, avatar, badge, button graphic, or
717
+ image-crop internal-centering reviews require a centering board. If the combined image still shows
718
+ obvious differences, coordinate drift, or layout spread beyond the intended
719
+ threshold, the task should return to implementation instead of treating the gap
720
+ as ready.
589
721
 
590
722
  After a fix has been verified and reviewed, promote the abstract pattern into
591
723
  project knowledge:
@@ -688,7 +820,11 @@ task, and can commit that task before moving on.
688
820
  For UI tasks, the loop prompt and generated guidance require the agent to run
689
821
  `openprd visual-compare` before finishing: use `--reference/--actual` when a
690
822
  reference image exists, or `--before/--after` when the agent must verify a UI
691
- change without an explicit reference image.
823
+ change without an explicit reference image. Use `--board <verification-board.json>`
824
+ for screenshot-based runtime evidence, and `--board <alignment-board.json>` for
825
+ homogeneous lists, cards, grids, or tables; the alignment board must cover both
826
+ outer tracks and internal content slots. Use `--board <centering-board.json>` for
827
+ single-element internal-centering or visual-centroid checks.
692
828
 
693
829
  `openprd run --context` may surface loop commands as execution commands, but they
694
830
  are not automatic instructions. Agents should run `openprd loop --run`,
@@ -736,6 +872,13 @@ without launching an agent. Use `--agent codex` or `--agent claude` for the defa
736
872
  CLI integrations. Use `--agent-command "<custom command>"` only when you want to
737
873
  pipe the OpenPrd prompt into a project-specific wrapper.
738
874
 
875
+ User-facing generated docs, progress logs, proposals, prompts, test reports, and
876
+ agent-produced specs/tasks follow the primary language of the current request
877
+ and PRD snapshot. Chinese contexts use Simplified Chinese, English contexts stay
878
+ English, and ambiguous contexts fall back to `zh-CN`; command names, field names,
879
+ paths, APIs, product names, and explicitly `zh-CN` diagram contracts remain
880
+ unchanged.
881
+
739
882
  For historical projects, use `fleet` instead of hand-writing shell loops. By
740
883
  default it scans and reports only, while also telling you how many known
741
884
  OpenPrd workspaces already exist in the global registry and how many are outside
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openprd/cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.19",
4
4
  "description": "AI-native PRD workspace and lifecycle CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,8 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  export const DEV_CHECK_WRAPUP_COPY_LIMIT = 20;
4
- const WRAPUP_FIELDS = ['规模信号', '预警原因', '本次处理结果', '后续建议'];
5
- const VALIDATE_USAGE = 'Usage: echo \'{"rows":[{"影响对象":"src/example.js","规模信号":"701 行(> 700 行/文件)","预警原因":"文件偏大,维护成本升","本次处理结果":"本轮小改,未扩职责","后续建议":"继续改前先拆小"}]}\' | node scripts/dev-check-wrapup-copy.mjs --validate';
4
+ // 自动优化模式(默认)与仅推荐模式使用不同表头;字段别名成对等价。
5
+ const WRAPUP_FIELD_ALIASES = [
6
+ ['源文件规模', '规模信号'],
7
+ ['优化原因', '预警原因'],
8
+ ['本次处理结果'],
9
+ ['后续建议'],
10
+ ];
11
+ const VALIDATE_USAGE = 'Usage: echo \'{"rows":[{"影响对象":"src/example.js","源文件规模":"701 行(> 700 行/文件)","优化原因":"文件偏大,维护成本升","本次处理结果":"本轮小改,未扩职责","后续建议":"继续改前先拆小"}]}\' | node scripts/dev-check-wrapup-copy.mjs --validate(仅推荐模式对应字段为“规模信号 / 预警原因”)';
6
12
 
7
13
  function countChars(value) {
8
14
  return Array.from(String(value ?? ''));
@@ -11,14 +17,15 @@ function countChars(value) {
11
17
  function validateCompactRows(rows = [], limit = DEV_CHECK_WRAPUP_COPY_LIMIT) {
12
18
  for (const [index, row] of rows.entries()) {
13
19
  const rowLabel = row?.影响对象 ? String(row.影响对象) : (row?.影响位置 ? String(row.影响位置) : `第 ${index + 1} 行`);
14
- for (const field of WRAPUP_FIELDS) {
15
- const value = row?.[field];
16
- if (typeof value !== 'string') {
17
- throw new Error(`后续建议校验失败:${rowLabel} 缺少字段“${field}”。${VALIDATE_USAGE}`);
20
+ for (const aliases of WRAPUP_FIELD_ALIASES) {
21
+ const field = aliases.find((name) => typeof row?.[name] === 'string');
22
+ if (!field) {
23
+ throw new Error(`收口表格校验失败:${rowLabel} 缺少字段“${aliases.join('/')}”。${VALIDATE_USAGE}`);
18
24
  }
25
+ const value = row[field];
19
26
  const actual = countChars(value).length;
20
27
  if (actual > limit) {
21
- throw new Error(`后续建议校验失败:${rowLabel} 的“${field}”有 ${actual} 个字,超过 ${limit} 字上限。当前内容:“${value}”。请缩短后重试。`);
28
+ throw new Error(`收口表格校验失败:${rowLabel} 的“${field}”有 ${actual} 个字,超过 ${limit} 字上限。当前内容:“${value}”。请缩短后重试。`);
22
29
  }
23
30
  }
24
31
  }
@@ -56,29 +63,45 @@ function reasonText(file) {
56
63
  return '待补充';
57
64
  }
58
65
 
59
- function currentResultText(file) {
60
- if (file.status === 'warning') return '这次先完成需求,暂不拆分';
61
- if (file.status === 'attention') return '本轮小改,未扩职责';
66
+ function currentResultText(file, autoRefactor) {
67
+ if (file.status === 'warning') {
68
+ return autoRefactor ? '本轮执行拆分后回填' : '这次先完成需求,暂不拆分';
69
+ }
70
+ if (file.status === 'attention') {
71
+ return autoRefactor ? '按需小步拆分后回填' : '本轮小改,未扩职责';
72
+ }
62
73
  if (file.status === 'error') return '本轮失败,未收口';
63
74
  if (file.status === 'ok') return '本轮已回顾';
64
75
  return '待确认';
65
76
  }
66
77
 
67
- function followUpText(file) {
68
- if (file.status === 'warning') return '优先拆出独立职责';
69
- if (file.status === 'attention') return '继续改前先拆小';
78
+ function followUpText(file, autoRefactor) {
79
+ if (file.status === 'warning') {
80
+ return autoRefactor ? '拆完重跑测试验证' : '优先拆出独立职责';
81
+ }
82
+ if (file.status === 'attention') {
83
+ return autoRefactor ? '保持职责边界清晰' : '继续改前先拆小';
84
+ }
70
85
  if (file.status === 'error') return '先修复后重跑';
71
86
  if (file.status === 'ok') return '无需额外动作';
72
87
  return '待确认';
73
88
  }
74
89
 
75
- export function buildCompactDevCheckWrapUpRows(files = []) {
76
- return files.map((file) => ({
77
- 规模信号: thresholdText(file),
78
- 预警原因: reasonText(file),
79
- 本次处理结果: currentResultText(file),
80
- 后续建议: followUpText(file),
81
- }));
90
+ export function buildCompactDevCheckWrapUpRows(files = [], options = {}) {
91
+ const autoRefactor = Boolean(options.autoRefactor);
92
+ return files.map((file) => (autoRefactor
93
+ ? {
94
+ 源文件规模: thresholdText(file),
95
+ 优化原因: reasonText(file),
96
+ 本次处理结果: currentResultText(file, autoRefactor),
97
+ 后续建议: followUpText(file, autoRefactor),
98
+ }
99
+ : {
100
+ 规模信号: thresholdText(file),
101
+ 预警原因: reasonText(file),
102
+ 本次处理结果: currentResultText(file, autoRefactor),
103
+ 后续建议: followUpText(file, autoRefactor),
104
+ }));
82
105
  }
83
106
 
84
107
  async function readStdin() {
@@ -95,7 +118,9 @@ async function main() {
95
118
  const payload = raw.trim() ? JSON.parse(raw) : {};
96
119
  const rows = validateOnly
97
120
  ? (Array.isArray(payload.rows) ? payload.rows : [])
98
- : buildCompactDevCheckWrapUpRows(Array.isArray(payload.files) ? payload.files : []);
121
+ : buildCompactDevCheckWrapUpRows(Array.isArray(payload.files) ? payload.files : [], {
122
+ autoRefactor: Boolean(payload.autoRefactor),
123
+ });
99
124
  validateCompactRows(rows);
100
125
  process.stdout.write(JSON.stringify({
101
126
  ok: true,
@@ -1,25 +1,37 @@
1
1
  ---
2
2
  name: openprd-diagram-review
3
- description: 生成并迭代 OpenPrd 图示产物,供用户确认。适用于架构图、产品流程图、用户旅程、流程图、系统边界图、依赖图,以及 freeze 前的可视化评审场景。
3
+ description: 生成并迭代 OpenPrd 图示产物,供用户确认或理解。适用于解释型 SVG、架构图、产品流程图、用户旅程、流程图、系统边界图、依赖图,以及 freeze 前的可视化评审场景。
4
4
  ---
5
5
 
6
6
  # OpenPrd Diagram Review
7
7
 
8
8
  ## 概览
9
9
 
10
- 这份 skill 用来判断当前需要哪种图、生成可渲染的 diagram contract、调用 OpenPrd 当前支持的渲染能力,并把结果变成和用户往返确认的评审循环,而不是一次性出图。
10
+ 这份 skill 用来判断当前需要哪种图:轻量解释图、正式 diagram contract,或需要用户往返确认的评审循环。不要把所有图都当成 freeze 前评审图;很多时候用户只是需要先看懂问题。
11
11
 
12
12
  ## 动手前
13
13
 
14
14
  1. 读取 `skills/openprd-shared/SKILL.md`
15
15
  2. 重建当前工作区状态,判断用户究竟想确认什么
16
16
  3. 决定用户需要的是:
17
+ - `explanation-svg` 轻量解释图
17
18
  - `architecture` 视图
18
19
  - `product-flow` 视图
19
20
  4. 不要虚构今天还不存在的 OpenPrd diagram 命令
20
21
 
21
22
  ## 图示类型选择
22
23
 
24
+ 当用户在问这些内容时,优先选 `explanation-svg`:
25
+
26
+ - 为什么会这样
27
+ - 这两个方案差在哪里
28
+ - 当前状态怎么走到目标状态
29
+ - 过去、现在、未来的关系
30
+ - 因果、依赖、边界、风险传播
31
+ - Agent 要向用户解释需求场景、问题结构、决策取舍或下一步路径
32
+
33
+ `explanation-svg` 是对话辅助。它可以用内联 SVG、HTML 片段或 Markdown 中的 SVG 代码块表达;它不需要写入 `.openprd/engagements/active/`,也不替代 `openprd diagram`、`review.html`、`visual-compare` 或测试证据。
34
+
23
35
  当用户在问这些内容时,选 `architecture`:
24
36
 
25
37
  - 模块
@@ -41,6 +53,17 @@ description: 生成并迭代 OpenPrd 图示产物,供用户确认。适用于
41
53
 
42
54
  - 当用户行为和流程仍不清楚时,先做 `product-flow` contract
43
55
  - 流程清楚后,再做架构评审
56
+ - 如果只是为了让用户先理解取舍,不进入定稿评审,先给 `explanation-svg`
57
+
58
+ ## 解释型 SVG 规则
59
+
60
+ - 输出顺序优先是:一句结论、SVG 图、最多 3 条补充说明或开放问题。
61
+ - 图中每个节点只放短标签和 1 行例子;正文解释放到图下,不要把 SVG 变成文字墙截图。
62
+ - 优先使用 2 到 5 个节点、明确箭头、颜色分组、虚线边界、少量图例;避免复杂渐变、装饰背景和难读小字。
63
+ - 适合的图形包括:双栏对比、时间线、状态转移、边界/责任图、决策树、风险传播、因果反推。
64
+ - 图中用户可见文案跟随用户当前主语言;中文语境用简体中文,专有名词可保留,但不要在中文语境下整句英文。
65
+ - 如果没有足够事实支撑图中的节点或箭头,先把缺口写成“待确认”,不要把推测画成事实。
66
+ - 需要模板时读取 `references/explanation-svg-patterns.md`。
44
67
 
45
68
  ## 当前工具能力
46
69
 
@@ -52,6 +75,7 @@ description: 生成并迭代 OpenPrd 图示产物,供用户确认。适用于
52
75
 
53
76
  因此:
54
77
 
78
+ - 对 `explanation-svg`,直接在对话或临时 HTML/SVG artifact 中生成轻量图,不声称已进入正式 diagram 评审
55
79
  - 对 `architecture`,直接调用内置命令
56
80
  - 对 `product-flow`,即使还没有专门渲染器,也先生成结构化 contract 和评审清单
57
81
  - 如果工具还没有专用流程渲染器,就不要假装它已经存在
@@ -87,5 +111,6 @@ description: 生成并迭代 OpenPrd 图示产物,供用户确认。适用于
87
111
  ## 需要时阅读这些参考资料
88
112
 
89
113
  - `references/diagram-contracts.md`:架构图和产品流程图 contract
114
+ - `references/explanation-svg-patterns.md`:解释型 SVG 的触发场景、图形模板和文案边界
90
115
  - `references/review-checklist.md`:渲染后应该问用户什么
91
116
  - `references/cocoon-patterns.md`:从 `Cocoon-AI/architecture-diagram-generator` 借来的可复用模式