@openprd/cli 0.1.0

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 (154) hide show
  1. package/.openprd/README.md +82 -0
  2. package/.openprd/benchmarks/evidence/milvus-io-ai-code-review-gets-better-when-models-debate-claude-vs-gemini-vs-code.md +14 -0
  3. package/.openprd/benchmarks/evidence/nolanlawson-com-using-ai-to-write-better-code-more-slowly.md +14 -0
  4. package/.openprd/benchmarks/index.md +37 -0
  5. package/.openprd/benchmarks/sources.yaml +56 -0
  6. package/.openprd/config.yaml +50 -0
  7. package/.openprd/discovery/config.json +21 -0
  8. package/.openprd/engagements/active/flows.md +30 -0
  9. package/.openprd/engagements/active/handoff.md +9 -0
  10. package/.openprd/engagements/active/intake.md +15 -0
  11. package/.openprd/engagements/active/prd.md +161 -0
  12. package/.openprd/engagements/active/review.html +61 -0
  13. package/.openprd/engagements/active/roles.md +21 -0
  14. package/.openprd/engagements/work-units/wu-20260524015648-6d33ded7.json +23 -0
  15. package/.openprd/exports/.gitkeep +0 -0
  16. package/.openprd/knowledge/index.json +7 -0
  17. package/.openprd/quality/config.json +229 -0
  18. package/.openprd/reviews/v0001.html +1256 -0
  19. package/.openprd/schema/diagram-architecture.schema.yaml +49 -0
  20. package/.openprd/schema/diagram-product-flow.schema.yaml +52 -0
  21. package/.openprd/schema/prd.schema.yaml +121 -0
  22. package/.openprd/sessions/.gitkeep +0 -0
  23. package/.openprd/standards/config.json +88 -0
  24. package/.openprd/standards/file-manual-template.md +28 -0
  25. package/.openprd/standards/folder-readme-template.md +28 -0
  26. package/.openprd/state/.gitkeep +0 -0
  27. package/.openprd/state/changes.json +12 -0
  28. package/.openprd/state/current.json +169 -0
  29. package/.openprd/state/version-index.json +15 -0
  30. package/.openprd/state/versions/.gitkeep +0 -0
  31. package/.openprd/state/versions/v0001.json +121 -0
  32. package/.openprd/state/versions/v0001.md +161 -0
  33. package/.openprd/templates/agent/intake.md +6 -0
  34. package/.openprd/templates/agent/prd.md +21 -0
  35. package/.openprd/templates/b2b/intake.md +6 -0
  36. package/.openprd/templates/b2b/prd.md +24 -0
  37. package/.openprd/templates/base/intake.md +18 -0
  38. package/.openprd/templates/base/prd.md +67 -0
  39. package/.openprd/templates/company/README.md +10 -0
  40. package/.openprd/templates/consumer/intake.md +6 -0
  41. package/.openprd/templates/consumer/prd.md +19 -0
  42. package/.openprd/templates/diagram/architecture.contract.json +53 -0
  43. package/.openprd/templates/diagram/product-flow.contract.json +76 -0
  44. package/.openprd/templates/industry/README.md +16 -0
  45. package/.openprd/templates/manifest.yaml +27 -0
  46. package/.openprd/templates/project/README.md +14 -0
  47. package/.openprd/templates/session/README.md +14 -0
  48. package/AGENTS.md +44 -0
  49. package/CONTRIBUTING.md +30 -0
  50. package/LICENSE +21 -0
  51. package/README.md +727 -0
  52. package/README_CN.md +583 -0
  53. package/SECURITY.md +23 -0
  54. package/bin/openprd.js +5 -0
  55. package/docs/assets/openprd-capability-overview-en.png +0 -0
  56. package/docs/assets/openprd-capability-overview-zh.png +0 -0
  57. package/docs/assets/openprd-learning-html.png +0 -0
  58. package/docs/assets/openprd-quality-html.png +0 -0
  59. package/docs/assets/openprd-review-html.png +0 -0
  60. package/docs/assets/openprd-scenario-overview.png +0 -0
  61. package/docs/assets/openprd-scenario-overview.svg +114 -0
  62. package/docs/assets/openprd-self-evolving-mechanisms-en.png +0 -0
  63. package/docs/assets/openprd-self-evolving-mechanisms-zh.png +0 -0
  64. package/docs/assets/openprd-visual-compare-case-study-en.png +0 -0
  65. package/docs/assets/openprd-visual-compare-case-study-zh.png +0 -0
  66. package/package.json +59 -0
  67. package/scripts/openprd-dev-check.mjs +5 -0
  68. package/scripts/openprd-review-presentation.mjs +82 -0
  69. package/skills/openprd-benchmark-router/SKILL.md +92 -0
  70. package/skills/openprd-benchmark-router/agents/openai.yaml +4 -0
  71. package/skills/openprd-benchmark-router/references/benchmark-sources.md +74 -0
  72. package/skills/openprd-benchmark-router/references/evaluation-lenses.md +66 -0
  73. package/skills/openprd-benchmark-router/references/source-policy.md +35 -0
  74. package/skills/openprd-diagram-review/SKILL.md +91 -0
  75. package/skills/openprd-diagram-review/agents/openai.yaml +4 -0
  76. package/skills/openprd-diagram-review/examples/architecture-zh.md +8 -0
  77. package/skills/openprd-diagram-review/examples/product-flow-zh.md +7 -0
  78. package/skills/openprd-diagram-review/references/cocoon-patterns.md +17 -0
  79. package/skills/openprd-diagram-review/references/diagram-contracts.md +126 -0
  80. package/skills/openprd-diagram-review/references/review-checklist.md +10 -0
  81. package/skills/openprd-discovery-loop/SKILL.md +196 -0
  82. package/skills/openprd-discovery-loop/agents/openai.yaml +3 -0
  83. package/skills/openprd-harness/SKILL.md +179 -0
  84. package/skills/openprd-harness/agents/openai.yaml +4 -0
  85. package/skills/openprd-harness/examples/full-workflow-zh.md +9 -0
  86. package/skills/openprd-harness/references/command-map.md +71 -0
  87. package/skills/openprd-harness/references/examples.md +26 -0
  88. package/skills/openprd-harness/references/usage-guide.md +335 -0
  89. package/skills/openprd-harness/references/workflow-gates.md +51 -0
  90. package/skills/openprd-learning-review/SKILL.md +75 -0
  91. package/skills/openprd-learning-review/agents/openai.yaml +4 -0
  92. package/skills/openprd-learning-review/references/content-contract.md +125 -0
  93. package/skills/openprd-learning-review/references/ebook-reader.md +46 -0
  94. package/skills/openprd-learning-review/references/evidence-manifest.md +55 -0
  95. package/skills/openprd-learning-review/references/genre-library.md +43 -0
  96. package/skills/openprd-learning-review/references/prompt-engineering.md +71 -0
  97. package/skills/openprd-learning-review/references/quality-rubric.md +28 -0
  98. package/skills/openprd-learning-review/references/retrieval-worked-example.md +40 -0
  99. package/skills/openprd-learning-review/references/style-packs/xianxia-cultivation.prompt.md +67 -0
  100. package/skills/openprd-quality/SKILL.md +101 -0
  101. package/skills/openprd-requirement-intake/SKILL.md +76 -0
  102. package/skills/openprd-requirement-intake/agents/openai.yaml +4 -0
  103. package/skills/openprd-requirement-intake/references/prd-template-lenses.md +105 -0
  104. package/skills/openprd-requirement-intake/references/routing-rubric.md +64 -0
  105. package/skills/openprd-router/SKILL.md +40 -0
  106. package/skills/openprd-shared/SKILL.md +142 -0
  107. package/skills/openprd-shared/agents/openai.yaml +4 -0
  108. package/skills/openprd-shared/references/language-and-review.md +50 -0
  109. package/skills/openprd-shared/references/operating-rules.md +65 -0
  110. package/skills/openprd-shared/references/skill-architecture.md +70 -0
  111. package/skills/openprd-standards/SKILL.md +79 -0
  112. package/skills/openprd-standards/agents/openai.yaml +4 -0
  113. package/src/agent-integration.js +1717 -0
  114. package/src/benchmark.js +873 -0
  115. package/src/cli/args.js +460 -0
  116. package/src/cli/print.js +1423 -0
  117. package/src/codex-hook-runner-template.mjs +2422 -0
  118. package/src/dev-standards.js +372 -0
  119. package/src/diagram-core.js +1047 -0
  120. package/src/diagram-workspace.js +262 -0
  121. package/src/discovery.js +709 -0
  122. package/src/fleet.js +531 -0
  123. package/src/fs-utils.js +83 -0
  124. package/src/growth.js +545 -0
  125. package/src/html-artifacts.js +3803 -0
  126. package/src/knowledge.js +668 -0
  127. package/src/language-policy.js +142 -0
  128. package/src/learning-review.js +1655 -0
  129. package/src/loop.js +1290 -0
  130. package/src/openprd.js +1136 -0
  131. package/src/openspec/change-lifecycle.js +359 -0
  132. package/src/openspec/change-validate.js +248 -0
  133. package/src/openspec/constants.js +12 -0
  134. package/src/openspec/execute.js +300 -0
  135. package/src/openspec/generate.js +692 -0
  136. package/src/openspec/paths.js +111 -0
  137. package/src/openspec/tasks.js +352 -0
  138. package/src/prd-core.js +656 -0
  139. package/src/quality-html-artifact.js +1414 -0
  140. package/src/quality-learning.js +658 -0
  141. package/src/quality.js +1262 -0
  142. package/src/review-presentation.js +240 -0
  143. package/src/run-harness.js +1470 -0
  144. package/src/self-update.js +329 -0
  145. package/src/session-binding.js +140 -0
  146. package/src/source-inventory.js +224 -0
  147. package/src/standards.js +914 -0
  148. package/src/time.js +33 -0
  149. package/src/visual-compare.js +216 -0
  150. package/src/work-unit-migration.js +232 -0
  151. package/src/work-unit.js +88 -0
  152. package/src/workspace-core.js +1706 -0
  153. package/src/workspace-registry.js +162 -0
  154. package/src/workspace-workflow.js +1797 -0
@@ -0,0 +1,26 @@
1
+ # Example Requests
2
+
3
+ ## Example 1
4
+
5
+ User:
6
+
7
+ > 用 OpenPrd 帮我把这个 AI 教学产品从需求澄清推进到可以 handoff 的状态。
8
+
9
+ Expected routing:
10
+
11
+ - use `openprd status`
12
+ - use `openprd next`
13
+ - continue through classify/interview/synthesize
14
+ - route to `$openprd-diagram-review` before freeze if the structure is still unclear
15
+
16
+ ## Example 2
17
+
18
+ User:
19
+
20
+ > 这个工作区现在应该先 freeze 还是先补图?
21
+
22
+ Expected routing:
23
+
24
+ - inspect current state
25
+ - inspect next/blockers
26
+ - if system shape still needs confirmation, recommend diagram review first
@@ -0,0 +1,335 @@
1
+ # OpenPrd 使用指南
2
+
3
+ 这份指南是给 **团队成员** 和 **Agent** 的 OpenPrd 实战使用说明。重点不是命令表,而是:
4
+
5
+ - 什么时候先 `clarify`
6
+ - 什么时候先 `diagram`
7
+ - 什么时候检查 `standards`
8
+ - 什么时候可以直接 `freeze`
9
+ - `status` / `next` 该怎么看
10
+ - `batch capture` 怎么用
11
+
12
+ ## 一、先判断你处于哪种场景
13
+
14
+ OpenPrd 现在会区分 3 种场景:
15
+
16
+ ### 1. Cold start (greenfield)
17
+
18
+ 特点:
19
+
20
+ - 项目目录基本是空的
21
+ - `.openprd/` 刚初始化
22
+ - 没有现成产品上下文可复用
23
+
24
+ 协同方式:
25
+
26
+ - 高协同
27
+ - 先问用户
28
+ - 不要自己先写完整 PRD
29
+
30
+ 优先动作:
31
+
32
+ - `openprd clarify`
33
+ - 根据用户回答 `openprd capture`
34
+
35
+ ### 2. Cold start (existing project)
36
+
37
+ 特点:
38
+
39
+ - 项目已有 README / docs / 代码 / 现成能力
40
+ - `.openprd/` 是第一次接入
41
+
42
+ 协同方式:
43
+
44
+ - 先复用现有上下文
45
+ - 但关键产品事实必须让用户确认
46
+
47
+ 优先动作:
48
+
49
+ - `openprd status`
50
+ - `openprd clarify`
51
+ - 用 `openprd capture --source project-derived` 导入已有事实
52
+ - 用 `openprd capture --source user-confirmed` 写回用户确认
53
+ - 用 `openprd standards <path> --verify` 检查 `docs/basic/` 和说明书模板
54
+
55
+ ### 3. Continuing workspace
56
+
57
+ 特点:
58
+
59
+ - 已有 `.openprd/` 历史
60
+ - 已经 synthesize / freeze / handoff 过
61
+
62
+ 协同方式:
63
+
64
+ - 只做增量澄清
65
+ - 不重跑全量初始化
66
+
67
+ 优先动作:
68
+
69
+ - `openprd status`
70
+ - `openprd next`
71
+ - 只补变化部分
72
+ - 每次功能落地前检查 `openprd standards <path> --verify`
73
+
74
+ ---
75
+
76
+ ## 二、什么场景先 `clarify`
77
+
78
+ 优先 `clarify` 的情况:
79
+
80
+ - 项目刚初始化
81
+ - 关键产品字段缺失
82
+ - 用户的目标、范围、成功标准还不清楚
83
+ - 虽然 repo 有内容,但你还不能判断“这次 OpenPrd 到底定义什么”
84
+ - 你手上只有技术上下文,没有用户确认
85
+
86
+ ### 典型信号
87
+
88
+ 如果 `openprd next` 或 `openprd status` 显示:
89
+
90
+ - `Current gate: clarify-user`
91
+
92
+ 那么不要继续往 `synthesize`、`diagram`、`freeze` 推进。
93
+
94
+ ### 推荐操作
95
+
96
+ ```bash
97
+ openprd clarify <path>
98
+ ```
99
+
100
+ 然后把用户回答写回:
101
+
102
+ ```bash
103
+ openprd capture <path> --field problem.problemStatement --value "..."
104
+ openprd capture <path> --field goals.successMetrics --value "..."
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 三、什么场景先 `diagram`
110
+
111
+ 优先 `diagram` 的情况:
112
+
113
+ - 需求的**系统边界**需要确认
114
+ - 依赖、模块、数据/控制流复杂
115
+ - 用户流程、决策点、失败路径复杂
116
+ - freeze 前需要一个 visual artifact 来做协同确认
117
+
118
+ ### 什么时候画 architecture
119
+
120
+ 适用于:
121
+
122
+ - 模块边界
123
+ - 服务依赖
124
+ - control plane / data plane 分工
125
+ - 权限、审核、可靠性边界
126
+
127
+ ```bash
128
+ openprd diagram <path> --type architecture
129
+ ```
130
+
131
+ ### 什么时候画 product-flow
132
+
133
+ 适用于:
134
+
135
+ - onboarding
136
+ - 用户操作步骤
137
+ - decision / error path
138
+ - human + agent 协作流程
139
+
140
+ ```bash
141
+ openprd diagram <path> --type product-flow
142
+ ```
143
+
144
+ ### 什么时候用 `--input`
145
+
146
+ 如果 Agent 已经基于 Skill 生成了结构化 diagram contract:
147
+
148
+ ```bash
149
+ openprd diagram <path> --type product-flow --input flow-contract.json
150
+ ```
151
+
152
+ 这比依赖工具自己推断更稳,也更适合多 Agent 协作。
153
+
154
+ ---
155
+
156
+ ## 四、什么场景可以直接 `freeze`
157
+
158
+ 只有在下面几件事都满足时,才建议 `freeze`:
159
+
160
+ 1. 关键产品字段已经补齐
161
+ 2. 用户确认问题已经基本收敛
162
+ 3. 如果 diagram gate 生效,对应 diagram 已确认
163
+ 4. `openprd next` 不再提示 `clarify-user`
164
+ 5. `openprd next` 不再提示 `diagram`
165
+
166
+ ### 典型信号
167
+
168
+ 如果 `openprd next` 显示:
169
+
170
+ - `Current gate: freeze review`
171
+
172
+ 并且 `Suggested command: openprd freeze .`
173
+
174
+ 这时才适合 freeze。
175
+
176
+ ---
177
+
178
+ ## 五、`status` / `next` 应该怎么看
179
+
180
+ ### `openprd status`
181
+
182
+ 适合回答:
183
+
184
+ - 我现在处于什么场景?
185
+ - 用户应该参与到什么程度?
186
+ - 当前卡在哪一关?
187
+ - 接下来最可能是哪一关?
188
+
189
+ 重点看这 4 个字段:
190
+
191
+ - `Scenario`
192
+ - `User participation mode`
193
+ - `Current gate`
194
+ - `Upcoming gate`
195
+
196
+ 例如:
197
+
198
+ - `Scenario: Cold start (existing project)`
199
+ - `User participation mode: context-plus-confirmation`
200
+ - `Current gate: clarify-user`
201
+ - `Upcoming gate: freeze review`
202
+
203
+ 这说明:
204
+
205
+ - 项目里已有上下文可以用
206
+ - 但当前仍然要先和用户确认
207
+ - 还没到可以 freeze 的阶段
208
+
209
+ ### `openprd next`
210
+
211
+ 适合回答:
212
+
213
+ - 下一步最应该做什么?
214
+ - 为什么是这一步?
215
+ - 建议直接执行什么命令?
216
+ - 当前应该问用户哪些问题?
217
+
218
+ 重点看:
219
+
220
+ - `Next action`
221
+ - `Current gate`
222
+ - `Upcoming gate`
223
+ - `Suggested command`
224
+ - `Suggested questions`
225
+
226
+ ---
227
+
228
+ ## 六、batch capture 怎么用
229
+
230
+ ### 适用场景
231
+
232
+ Agent 一轮把用户问完之后,最好不要一条条写:
233
+
234
+ ```bash
235
+ openprd capture ... --field ...
236
+ openprd capture ... --field ...
237
+ openprd capture ... --field ...
238
+ ```
239
+
240
+ 而是用批量模式。
241
+
242
+ ### 命令
243
+
244
+ ```bash
245
+ openprd capture <path> --json-file answers.json
246
+ ```
247
+
248
+ ### 推荐 JSON 格式
249
+
250
+ ```json
251
+ {
252
+ "problem.problemStatement": {
253
+ "value": "移动端缺少高效的 Agent 会话与节点管理入口",
254
+ "source": "user-confirmed"
255
+ },
256
+ "users.primaryUsers": {
257
+ "value": ["运维人员", "Agent 重度用户"],
258
+ "source": "user-confirmed"
259
+ },
260
+ "constraints.dependencies": {
261
+ "value": ["Auth API", "Node service"],
262
+ "source": "project-derived"
263
+ }
264
+ }
265
+ ```
266
+
267
+ ### source 的意义
268
+
269
+ - `user-confirmed`:用户亲口确认
270
+ - `project-derived`:从项目已有材料提取
271
+ - `agent-inferred`:Agent 的推断
272
+
273
+ 最佳实践:
274
+
275
+ - 产品关键字段优先写成 `user-confirmed`
276
+ - 技术现状、已有系统能力可以写成 `project-derived`
277
+ - 谨慎使用 `agent-inferred`
278
+
279
+ ---
280
+
281
+ ## 七、推荐的最小工作节奏
282
+
283
+ ### 对新项目
284
+
285
+ ```bash
286
+ openprd init <path> --template-pack agent
287
+ openprd status <path>
288
+ openprd clarify <path>
289
+ openprd capture <path> --json-file answers.json
290
+ openprd next <path>
291
+ ```
292
+
293
+ ### 对已有项目首次接入 OpenPrd
294
+
295
+ ```bash
296
+ openprd init <path> --template-pack agent
297
+ openprd status <path>
298
+ openprd clarify <path>
299
+ openprd capture <path> --json-file derived-and-confirmed.json
300
+ openprd classify <path> agent
301
+ openprd next <path>
302
+ ```
303
+
304
+ ### 对继续推进中的 workspace
305
+
306
+ ```bash
307
+ openprd status <path>
308
+ openprd next <path>
309
+ openprd clarify <path>
310
+ openprd capture <path> --json-file delta-answers.json
311
+ ```
312
+
313
+ ---
314
+
315
+ ## 八、团队协作建议
316
+
317
+ ### 给人类看什么
318
+
319
+ - `openprd status`
320
+ - `openprd next`
321
+ - 当前 diagram artifact
322
+ - open questions
323
+
324
+ ### 给 Agent 什么输入
325
+
326
+ - repo / docs / README
327
+ - `.openprd/` 当前状态
328
+ - diagram contract
329
+ - 批量 capture 的 answers.json
330
+
331
+ ### 不要做什么
332
+
333
+ - 不要把 `project-derived` 当成 `user-confirmed`
334
+ - 不要在 `Current gate: clarify-user` 时急着 `synthesize`
335
+ - 不要在 diagram gate 还没过时直接 `freeze`
@@ -0,0 +1,51 @@
1
+ # OpenPrd Workflow Gates
2
+
3
+ ## Clarification Gate
4
+
5
+ Do not synthesize with false confidence. Surface gaps first.
6
+
7
+ Scenario-aware expectations:
8
+
9
+ - `cold-start-greenfield`: high user collaboration before structure is locked
10
+ - `cold-start-existing-project`: reuse existing repo context, but still ask the user to confirm the new workspace boundary
11
+ - `continuing-workspace`: ask only targeted delta questions
12
+
13
+ Examples:
14
+
15
+ - problem statement still vague
16
+ - primary user unclear
17
+ - success metric missing
18
+ - scope not explicit
19
+
20
+ ## Diagram Gate
21
+
22
+ Route to diagram review before freeze if:
23
+
24
+ - architecture still needs confirmation
25
+ - user flow still needs confirmation
26
+ - dependencies or boundaries are important to approval
27
+ - the user explicitly asks for a diagram, flow, or visual explanation
28
+
29
+ ## Freeze Gate
30
+
31
+ Freeze is appropriate when:
32
+
33
+ - the synthesized draft exists
34
+ - the user has reviewed the latest critical artifact(s)
35
+ - there are no blockers hidden behind assumptions that should be reviewed first
36
+
37
+ ## Standards Gate
38
+
39
+ Implementation readiness is appropriate when:
40
+
41
+ - `openprd standards <path> --verify` passes
42
+ - `docs/basic/` reflects the latest product, flow, structure, and tech-stack facts
43
+ - changed files and folders have had their file manuals and folder README docs checked
44
+
45
+ ## Handoff Gate
46
+
47
+ Handoff is appropriate when:
48
+
49
+ - freeze succeeded
50
+ - target system is known
51
+ - the user is ready to move from planning into execution transfer
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: openprd-learning-review
3
+ description: 生成并维护 OpenPrd 复盘学习包、题材参考库、证据清单、图文讲解模块、检索/工作示例模块,以及 HTML 电子书阅读器。
4
+ ---
5
+
6
+ # OpenPrd Learning Review
7
+
8
+ ## 何时使用
9
+
10
+ 当用户希望把 OpenPrd 工作区、已完成的 loop 任务,或某个项目领域整理成复盘学习包时,使用这份 skill。典型触发包括:
11
+
12
+ - 长任务结束,或某个已验证 loop 任务刚完成
13
+ - 用户明确要求复盘某个项目领域或能力面
14
+ - 需要构建或刷新题材模板、证据清单、检索模块或工作示例
15
+ - 需要生成归档在 `.openprd/` 内的 HTML 电子书阅读器
16
+ - 需要把已验证修复或质量复盘连接到可复用的项目经验;此时让 Skill 产物继续经过 `$openprd-quality`,把抽象模式沉淀到 `.openprd/knowledge/skills/`
17
+ - 需要区分“项目经验沉淀”和“操作配置自我成长”;配置缺口、文件识别、命令习惯或用户偏好应进入 `.openprd/growth` 候选,而不是直接写入学习包或共享 Skill
18
+
19
+ ## 核心契约
20
+
21
+ - 严格分离五层:证据清单、无风格学习内容契约、风格提示词包、带风格学习内容、HTML 阅读器。图文比喻卡和图片提示属于内容契约的一部分,不单独分叉渲染器。
22
+ - 默认模式由配置开启;即使自动模式关闭,手动生成也必须可用。
23
+ - 学习包统一归档到 `.openprd/learning/archive/<packageId>/`。
24
+ - 项目级预防 Skill 单独放在 `.openprd/knowledge/skills/`,不要把复发预防规则只埋在学习电子书里。
25
+ - `.openprd/growth/` 只保存待确认配置、规则和偏好候选;经用户确认后才固化为项目共享配置或 user-local 偏好。
26
+ - 每一条结论都必须能追溯到 source id、路径、摘录和 digest。
27
+ - 除专门的 Markdown 阅读稿外,不要把叙事正文和 provenance 元数据混在同一个文件里。
28
+
29
+ ## 工作流程
30
+
31
+ 1. 从 `.openprd/state/current.json`、`.openprd/state/task-graph.json`、当前 PRD 产物、`docs/basic` 和最近的 loop 报告重建上下文。
32
+ 2. 选择主题、题材和可选子风格。默认使用 `internet-product`;对 `xianxia` 默认使用 `cultivation` 提示词包。
33
+ 3. 先构建 `evidence-manifest.json`。凡是无法追溯的句子,都标成推断。
34
+ 4. 先生成中性的 `learning-content.json`,再加载风格提示词包并运行 Agent-in-the-loop 风格迁移;对产品或非技术读者优先补 `visualExplainer` 图文比喻卡。
35
+ 5. 在内容契约里记录提示词包 id、提示词文本、风格迁移报告、图文讲解字段和质量检查结果。
36
+ 6. 把 `reader.html` 渲染为固定电子书界面:有书式目录、章节分页、正文独立滚动、进度、上一章/下一章、字体控制、章节级 source 锚点,以及章节内可选的图文比喻卡与图片槽位。不要把单个检索题放进目录。
37
+ 7. 把 `learning-package.json`、`learning-content.json`、`learning-content.md`、`evidence-manifest.json` 和 `reader.html` 一起写入归档目录。
38
+ 8. 更新 `.openprd/learning/index.json` 和 `.openprd/learning/current.json`,让后续任务能快速找到最新学习包。
39
+ 9. 当配置允许自动打开时,在学习包创建后自动打开阅读器。
40
+ 10. 如果学习包记录的是已验证修复、重复问题、隐藏调试路径或 Agent 误判,运行或建议运行 `openprd quality <path> --learn --from <eval-report>`,把抽象模式沉淀成未来可触发的项目 Skill。
41
+
42
+ ## 章节结构
43
+
44
+ 每个学习包都尽量覆盖这些模块:
45
+
46
+ - 解释学习包为何存在的叙事开场
47
+ - 点名相关 `.openprd/` 文件和工作流状态的系统地图章节
48
+ - 帮助产品或非技术读者先建立直觉的图文比喻卡
49
+ - 区分事实、claim 和推断的 provenance 章节
50
+ - 让读者回忆关键机制的检索模块
51
+ - 展示如何迁移到新场景的工作示例模块
52
+ - 告诉读者下一步做什么的收束章节
53
+
54
+ ## 扩展规则
55
+
56
+ - 新增题材时,扩展题材参考库,不要分叉渲染器。
57
+ - 内容契约必须版本化;当结构变化时,引入新的 schema 版本。
58
+ - 即使文风变化,证据清单中的 source id 和路径也必须保留。
59
+ - 保持 HTML 阅读器稳定,确保历史归档学习包在未来仍可重新打开。
60
+
61
+ ## 参考资料
62
+
63
+ - `references/prompt-engineering.md`
64
+ - `references/style-packs/xianxia-cultivation.prompt.md`
65
+ - `references/genre-library.md`
66
+ - `references/content-contract.md`
67
+ - `references/evidence-manifest.md`
68
+ - `references/ebook-reader.md`
69
+ - `references/retrieval-worked-example.md`
70
+ - `references/quality-rubric.md`
71
+
72
+ ## 输出期望
73
+
74
+ 最终产物应该像真正可阅读的学习材料,而不是套了浏览器壳的 JSON 导出。内容是主角,阅读器只是稳定的承载框架。
75
+ 如果目标读者不是工程师,优先把它做成“先看懂,再深读”的图文短课,而不是技术复盘手册。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "OpenPrd Learning Review"
3
+ short_description: "Generate project learning books, visual explainer cards, and genre templates"
4
+ default_prompt: "Use $openprd-learning-review to design or generate OpenPrd learning-review packages, visual explainer cards, evidence manifests, and HTML ebook-reader artifacts."
@@ -0,0 +1,125 @@
1
+ # Learning Content Contract
2
+
3
+ The contract must stay versioned and renderer-independent.
4
+
5
+ ## Top-Level Fields
6
+
7
+ - `schema`
8
+ - `version`
9
+ - `packageId`
10
+ - `generatedAt`
11
+ - `title`
12
+ - `topic`
13
+ - `subtitle`
14
+ - `genre`
15
+ - `stylePromptPack`
16
+ - `stylePromptEngineering`
17
+ - `styleTransfer`
18
+ - `trigger`
19
+ - `sourceScope`
20
+ - `audience`
21
+ - `snapshot`
22
+ - `learningGoals`
23
+ - `overviewParagraphs`
24
+ - `outline`
25
+ - `chapters`
26
+ - `evidenceManifestPath`
27
+ - `packagePaths`
28
+ - `related`
29
+ - `nextActions`
30
+
31
+ ## Chapter Shape
32
+
33
+ Each chapter should support:
34
+
35
+ - `id`
36
+ - `label`
37
+ - `semanticTitle`
38
+ - `summary`
39
+ - `visualExplainer`
40
+ - `paragraphs`
41
+ - `retrievalBlocks`
42
+ - `workedExamples`
43
+ - `evidenceIds`
44
+
45
+ ## Block Shape
46
+
47
+ ### Retrieval Block
48
+
49
+ - `prompt`
50
+ - `hint`
51
+ - `answer`
52
+
53
+ ### Worked Example
54
+
55
+ - `title`
56
+ - `scenario`
57
+ - `steps`
58
+ - `principle`
59
+
60
+ ### Visual Explainer
61
+
62
+ - `title`
63
+ - `analogy`
64
+ - `scene`
65
+ - `whyItMatters`
66
+ - `takeaways`
67
+ - `image`
68
+
69
+ ### Visual Explainer Image
70
+
71
+ - `path`
72
+ - `alt`
73
+ - `caption`
74
+ - `prompt`
75
+
76
+ ## Rules
77
+
78
+ - Facts belong to evidence.
79
+ - Narrative belongs to the contract.
80
+ - Prompt engineering belongs to `stylePromptEngineering`.
81
+ - Style migration audit belongs to `styleTransfer`.
82
+ - Rendering belongs to the HTML reader.
83
+ - The outline should stay chapter-oriented; retrieval questions remain in chapter body content instead of separate TOC leaf nodes.
84
+ - `visualExplainer` helps readers form intuition faster, but it cannot replace evidence or introduce unsupported facts.
85
+ - If `visualExplainer.image.path` is present, prefer a relative path under `packagePaths.assetsDir` so the archived reader stays portable.
86
+ - Claims that cannot be supported by the manifest should be marked as inference.
87
+ - Version the contract whenever the shape changes.
88
+
89
+ ## Minimal Example
90
+
91
+ ```json
92
+ {
93
+ "schema": "openprd.learning-content.v1",
94
+ "version": 1,
95
+ "packageId": "lr-20260512-120000-openprd-review",
96
+ "title": "《OpenPrd 复盘学习书》",
97
+ "genre": {
98
+ "id": "internet-product",
99
+ "label": "互联网产品"
100
+ },
101
+ "chapters": [
102
+ {
103
+ "id": "chapter-1",
104
+ "label": "问题地图",
105
+ "semanticTitle": "从任务完成回到工作区事实",
106
+ "summary": "先把发生了什么说清楚。",
107
+ "visualExplainer": {
108
+ "title": "像开业前先做联合质检",
109
+ "analogy": "先别急着开门营业,而是让不同角色独立检查风险。",
110
+ "scene": "产品负责人先看用户旅程,工程负责人再看实现风险。",
111
+ "whyItMatters": "非技术读者可以先抓住机制,再回到证据细节。",
112
+ "takeaways": ["先独立看", "后统一判", "再决定做不做"],
113
+ "image": {
114
+ "path": "assets/chapter-1.png",
115
+ "alt": "开业前联合质检的图文示意",
116
+ "caption": "图片只帮助理解,不替代证据。"
117
+ }
118
+ },
119
+ "retrievalBlocks": [],
120
+ "workedExamples": [],
121
+ "evidenceIds": ["current-state", "task-graph"]
122
+ }
123
+ ]
124
+ }
125
+ ```
@@ -0,0 +1,46 @@
1
+ # HTML Ebook Reader
2
+
3
+ The reader is the fixed output shell. It should be stable enough that archived packages remain readable later.
4
+
5
+ ## Layout
6
+
7
+ - left: book-like outline with chapter-level navigation and section nodes, but without individual retrieval-question entries
8
+ - center: chapter reader with one chapter shown at a time
9
+ - chapter body may contain an optional `visualExplainer` card with image, analogy, scene, and takeaways
10
+ - no persistent right evidence panel; evidence lives in archive files and chapter-level source anchors
11
+
12
+ ## Required Controls
13
+
14
+ - previous chapter
15
+ - next chapter
16
+ - font size down
17
+ - font size up
18
+ - progress indicator
19
+
20
+ ## Reader Behavior
21
+
22
+ - Use chapter paging for next/prev navigation and keep scrolling confined to the chapter body.
23
+ - Highlight the active chapter in the TOC.
24
+ - Keep source anchors available without competing with the text.
25
+ - If a chapter includes a `visualExplainer`, place it near the top of the chapter so non-technical readers can form intuition before reading dense text.
26
+ - Collapse into a single column on narrow screens.
27
+ - Open automatically when the package is created and auto-open is enabled.
28
+
29
+ ## Visual Rules
30
+
31
+ - Use a calm, paper-like palette.
32
+ - Keep typography readable and avoid over-decorating the page.
33
+ - Visual explainer cards can be stronger in color and layout than the正文, but they must still feel like part of the same reading surface.
34
+ - Do not let side panels compete with the text.
35
+ - Keep all text and controls stable across resize.
36
+
37
+ ## Output Files
38
+
39
+ - `reader.html`
40
+ - `assets/` (optional generated images for visual explainers)
41
+ - `learning-content.json`
42
+ - `learning-content.md`
43
+ - `evidence-manifest.json`
44
+ - `learning-package.json`
45
+ - `.openprd/learning/index.json`
46
+ - `.openprd/learning/current.json`