@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
package/README.md ADDED
@@ -0,0 +1,727 @@
1
+ # OpenPrd
2
+
3
+ [简体中文](./README_CN.md) | English
4
+
5
+ > AI-native PRD workspace and lifecycle CLI for requirement clarification, HTML-first review surfaces, diagram confirmation, and handoff.
6
+
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)
8
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20.19.0-339933.svg)](https://nodejs.org/)
9
+ [![GitHub stars](https://img.shields.io/github/stars/mileson/openprd?style=social)](https://github.com/mileson/openprd)
10
+
11
+ OpenPrd is a lightweight **PRD harness** for teams and agents that need more than “write a document”. It gives you a local workspace, a clarification-first workflow, policy-based review gates, diagram artifacts, and a structured change/spec/task workflow.
12
+
13
+ Instead of hiding key decisions in prompts or terminal logs, OpenPrd keeps people and agents aligned around stable HTML artifacts such as `review.html`, learning readers, and quality reports.
14
+
15
+ ![OpenPrd capability overview](./docs/assets/openprd-capability-overview-en.png)
16
+
17
+ ## Why OpenPrd
18
+
19
+ OpenPrd is designed for the gap between:
20
+
21
+ - vague product ideas that need clarification
22
+ - agent-assisted requirement drafting
23
+ - human confirmation at the right decision points before implementation
24
+ - structured handoff into execution systems
25
+
26
+ It is especially useful when you want:
27
+
28
+ - **clarify before drafting** instead of jumping straight to implementation
29
+ - **source-aware capture** so user-confirmed facts stay separate from repo-derived, agent-inferred, or agent-normalized context
30
+ - **policy-based review gates** that keep stable artifacts without forcing the same stop every time
31
+ - **agent-facing skills** shipped with the tool, not hidden in a local environment
32
+
33
+ ## Where OpenPrd Is Different
34
+
35
+ OpenPrd lives in a different spot than tools that are centered only on spec files
36
+ or only on coding execution.
37
+
38
+ | Tool | Center of gravity | Main user-facing artifacts | Best fit |
39
+ |------|-------------------|----------------------------|----------|
40
+ | **OpenPrd** | Requirement clarification, HTML-first collaboration, and delivery gates | `review.html`, learning readers, quality reports, diagrams, structured change/task state | Teams that need humans and agents to stay aligned through planning, review, execution, and ship decisions |
41
+ | **OpenSpec** | Spec and change lifecycle | Markdown proposals, specs, design docs, tasks | Teams that want disciplined spec deltas and a clean change-management workflow |
42
+ | **Superpowers** | Skill-driven coding execution | Skills, plans, worktree/subagent flows, code-review checkpoints | Engineering-heavy teams optimizing how AI agents plan, code, review, and finish branches |
43
+
44
+ OpenPrd is strongest when the hard part is not just "what code should be written,"
45
+ but "what should people confirm, what should stay visible, and what evidence is
46
+ enough to move forward."
47
+
48
+ ## Common Real-World Scenarios
49
+
50
+ Recent Codex project usage kept clustering around the same kinds of work: fuzzy
51
+ product requests, existing-product redesigns, release/publish flows, production
52
+ incident closure, and reusable learning handoff.
53
+
54
+ | Scenario | Why OpenPrd stands out here | Main artifacts |
55
+ |----------|-----------------------------|----------------|
56
+ | Fuzzy product request before anyone codes | Clarify first, separate user-confirmed facts from agent inference, then turn the result into a stable review surface. | `clarify`, `capture`, `synthesize`, `review.html` |
57
+ | Existing flow or auth-entry redesign | Reconstruct current behavior from repo and runtime evidence before proposing the next change. | `discovery`, `diagram`, `review.html`, `change` |
58
+ | Visual or product-flow confirmation | Keep architecture, product flow, or UI replication reviewable instead of burying decisions in chat. | `diagram`, `visual-compare`, side-by-side JPG reviews |
59
+ | Long-running agent implementation chain | Turn accepted work into dependency-ready tasks and run one focused agent session per task with verify gates. | `tasks`, `loop`, prompts, progress logs, verification reports |
60
+ | Release, publish, or handoff readiness | Make "ready to ship" a visible decision with standards, regression evidence, abuse/cost guardrails, and workspace health. | `quality`, `run --verify`, `doctor`, `handoff` |
61
+ | Learning handoff after a fix or project | Package the final requirement, reasoning, and outcome into something new collaborators can actually study. | learning reader, `.openprd/knowledge/skills/`, docs sync |
62
+
63
+ ## HTML-First Collaboration Surfaces
64
+
65
+ OpenPrd produces stable, shareable HTML surfaces so product owners, engineers,
66
+ and agents can look at the same artifact before work moves forward.
67
+
68
+ ### `review.html`
69
+
70
+ Use a review-ready PRD surface instead of asking teammates to reconstruct the
71
+ latest requirement state from chat history.
72
+
73
+ ![OpenPrd review HTML](./docs/assets/openprd-review-html.png)
74
+
75
+ ### Learning reader
76
+
77
+ Turn a finished requirement, fix, or workflow into a readable learning package
78
+ that new collaborators can study without replaying the whole thread.
79
+
80
+ ![OpenPrd learning HTML](./docs/assets/openprd-learning-html.png)
81
+
82
+ ### Quality regression report
83
+
84
+ Summarize readiness, required gates, evidence coverage, and manual decisions in
85
+ one human-readable quality surface before handoff, release, or publish.
86
+
87
+ ![OpenPrd quality HTML](./docs/assets/openprd-quality-html.png)
88
+
89
+ ### Auto-optimized reference-to-screenshot comparison
90
+
91
+ Put the reference and implementation into one side-by-side artifact for staged
92
+ UI review, especially for auth-entry redesign, localized legal pages, and modal
93
+ replication work.
94
+
95
+ ![Auto-optimized reference-to-screenshot comparison](./docs/assets/openprd-visual-compare-case-study-en.png)
96
+
97
+ ## Self-Evolving Collaboration
98
+
99
+ OpenPrd gets easier to work with over time through two visible loops. One loop
100
+ keeps proven team habits as reusable `Project-Level Skill`s. The other keeps
101
+ `Dynamic Parameter Config` adaptive, so different project situations start with
102
+ different collaboration defaults instead of the same generic checklist.
103
+
104
+ ![OpenPrd self-evolving collaboration](./docs/assets/openprd-self-evolving-mechanisms-en.png)
105
+
106
+ ### Scenario 1: Project-Level Skill
107
+
108
+ When a team reaches the same conclusion in real work more than once, OpenPrd
109
+ can keep that conclusion close to the project instead of leaving it buried in
110
+ chat.
111
+
112
+ - Example: a login-entry redesign confirms that log in, sign up, and password reset should all stay on the official site.
113
+ - What gets reused next time: related page checks, release review points, and the preferred path through similar requests.
114
+ - Why it matters: the next similar request starts from a shared playbook, and new teammates can follow the same steps without retelling the whole history.
115
+
116
+ ### Scenario 2: Dynamic Parameter Config
117
+
118
+ Not every project should start the same way. OpenPrd can keep different
119
+ collaboration defaults for different situations and bring them back
120
+ automatically.
121
+
122
+ - Example: a greenfield request starts with goal clarification and scope alignment, while an inherited project starts with current-state reconstruction and boundary mapping.
123
+ - What changes automatically: what to ask first, what to inspect first, and what proof to gather before handoff.
124
+ - Why it matters: teams spend less time re-explaining how this kind of project should run and more time moving with the right setup from the start.
125
+
126
+ ## Features
127
+
128
+ - **Clarification-first workflow**: `clarify -> capture -> classify -> interview -> synthesize -> diagram -> freeze -> handoff`
129
+ - **Scenario-aware collaboration**: distinguish greenfield cold start, existing-project cold start, and continuing workspaces
130
+ - **Self-evolving collaboration**: turn confirmed project habits into reusable `Project-Level Skill`s and adapt `Dynamic Parameter Config` by scenario
131
+ - **Source-aware capture**: mark inputs as `user-confirmed`, `project-derived`, `agent-inferred`, or `agent-normalized`
132
+ - **Diagram review artifacts**: generate both architecture and product-flow diagrams
133
+ - **UI visual comparison artifacts**: combine reference images and implementation screenshots into side-by-side JPG reviews for visual replication work
134
+ - **Contract-driven diagrams**: render from validated JSON contracts
135
+ - **Review status tracking**: use `pending-confirmation`, `confirmed`, and `needs-revision`
136
+ - **OpenPrd discovery mode**: initialize durable coverage runs for existing projects, reference projects, or unclear requirements
137
+ - **Project standards**: initialize and verify `docs/basic/`, file manual templates, and folder README templates as part of execution quality gates
138
+ - **Quality Regression Reports**: review overall regression status, per-requirement module status, test-block results, observability, business cost and abuse guardrails, smoke coverage, performance baselines, and project knowledge through HTML reports
139
+ - **Project knowledge skills**: turn verified fixes and recurring diagnosis patterns into reusable `.openprd/knowledge/skills/` experience skills
140
+ - **OpenPrd change and task execution**: materialize PRD snapshots into change files, validate them, apply accepted specs, archive changes, and advance structured tasks by dependency order
141
+ - **Long-running agent loop**: turn accepted change tasks into one-task-per-session Codex or Claude execution prompts with verification, progress logs, and optional task commits
142
+ - **Default agent integration**: generate Codex, Claude, and Cursor guidance from one OpenPrd source, including Codex hooks with `codex_hooks = true`
143
+ - **Agent harness skills**: repo-local skills for shared rules, workflow control, and diagram review
144
+
145
+ ## Tech Stack
146
+
147
+ | Layer | Technology |
148
+ |-------|------------|
149
+ | Runtime | Node.js 20+ |
150
+ | CLI | Native Node ESM |
151
+ | Config / state | JSON + YAML |
152
+ | Diagram renderer | Self-contained HTML + inline SVG |
153
+ | Image processing | `sharp` for JPG / PNG / WebP visual comparison artifacts |
154
+ | Testing | `node --test` |
155
+ | Agent guidance | Repo-local `skills/` + `AGENTS.md` + Codex / Claude / Cursor generated adapters |
156
+
157
+ ## One-line Install
158
+
159
+ Install directly from GitHub:
160
+
161
+ ```bash
162
+ npm install -g git+https://github.com/mileson/openprd.git
163
+ ```
164
+
165
+ Then verify:
166
+
167
+ ```bash
168
+ openprd --help
169
+ ```
170
+
171
+ Update the installed CLI later with a dry-run first:
172
+
173
+ ```bash
174
+ openprd self-update --dry-run
175
+ openprd self-update
176
+ ```
177
+
178
+ ## Quick Start
179
+
180
+ ### 1. Initialize a workspace
181
+
182
+ ```bash
183
+ openprd init /path/to/project --template-pack agent
184
+ ```
185
+
186
+ `init` creates `.openprd/`, `docs/basic/`, `AGENTS.md`, and generated Codex / Claude / Cursor guidance. Codex projects also get `.codex/config.toml`, `.codex/hooks.json`, `.codex/hooks/openprd-hook.mjs`, and user-level Codex `codex_hooks = true`.
187
+
188
+ Codex hooks default to `lite`: `UserPromptSubmit`, a lightweight `PreToolUse`
189
+ write gate, and a lightweight `Stop` end-of-turn review. Context is injected for prompts that explicitly mention OpenPrd,
190
+ PRD, deep research/benchmarking, replication, standards, fleet, documentation
191
+ standards, or look like new product/module/workflow requirements. The lite write
192
+ gate only matches direct editing tools so read-only shell exploration stays
193
+ quiet, while `Stop` reviews whether the current turn produced a reusable project
194
+ pattern; use `guarded` when shell commands should also pass through the write gate,
195
+ and `full` only for temporary deep diagnostics.
196
+ Concrete bugfix prompts with diagnostic evidence such as errors, logs, repro
197
+ steps, or root-cause investigation skip requirement intake when the user asks to
198
+ fix directly; confirmation wording also accepts phrases like "confirm the fix".
199
+
200
+ ### 2. Check the current collaboration state
201
+
202
+ ```bash
203
+ openprd status /path/to/project
204
+ openprd next /path/to/project
205
+ ```
206
+
207
+ ### 3. Clarify with the user
208
+
209
+ ```bash
210
+ openprd clarify /path/to/project
211
+ ```
212
+
213
+ Clarification stays in the conversation as an inline outline or short checklist. The formal HTML review surface is `review.html` after synthesis.
214
+
215
+ ### 4. Capture answers back into the workspace
216
+
217
+ Single field:
218
+
219
+ ```bash
220
+ openprd capture /path/to/project \
221
+ --field problem.problemStatement \
222
+ --value "Mobile users cannot efficiently manage agent sessions on the go" \
223
+ --source user-confirmed
224
+ ```
225
+
226
+ Batch capture:
227
+
228
+ ```bash
229
+ openprd capture /path/to/project --json-file answers.json
230
+ ```
231
+
232
+ If `openprd synthesize` reports that the generated `spec.md` would still fail the
233
+ Simplified Chinese preflight, normalize the wording with
234
+ `--source agent-normalized` before recording the current `review.html` artifact.
235
+
236
+ ### 5. Draft and review
237
+
238
+ ```bash
239
+ openprd synthesize /path/to/project \
240
+ --title "Moticlaw Mobile" \
241
+ --owner "Moticlaw" \
242
+ --problem "Mobile users lack a direct-first client for node selection and agent interaction." \
243
+ --why-now "The control plane already exists and the missing piece is a mobile entry point."
244
+
245
+ openprd review-presentation /path/to/project --template
246
+ openprd review-presentation /path/to/project \
247
+ --presentation review-presentation.json \
248
+ --write \
249
+ --fail-on-violation
250
+
251
+ openprd diagram /path/to/project --type architecture --open
252
+ openprd diagram /path/to/project --type product-flow --open
253
+ openprd review /path/to/project --open
254
+ openprd review /path/to/project --mark confirmed --version <id> --digest <sha256> --work-unit <id>
255
+ ```
256
+
257
+ `review.html` is the stable review artifact for the current PRD, but the default
258
+ approval policy is `decision-points`, not “always stop here”. In a normal lane,
259
+ the user reviews that stable artifact first and then the exact copied
260
+ `--version`, `--digest`, and `--work-unit` tuple is recorded. In a
261
+ `silent-record` lane, OpenPrd can record the exact current artifact without an
262
+ extra stop only when the user already made direct execution intent explicit and
263
+ explicitly opted out of additional review confirmation. Do not treat
264
+ implementation approval as permission to mark a different review artifact, and
265
+ do not treat review recording as execution authorization. After the current
266
+ artifact is recorded, generate the OpenPrd change and task breakdown. If the
267
+ user originally asked to implement, execution can continue once tasks are ready;
268
+ otherwise wait for an explicit execution request:
269
+
270
+ ```bash
271
+ openprd change /path/to/project --generate --change <change-id>
272
+ openprd tasks /path/to/project --change <change-id>
273
+ ```
274
+
275
+ ### 6. Freeze and handoff
276
+
277
+ ```bash
278
+ openprd freeze /path/to/project
279
+ openprd handoff /path/to/project --target openprd
280
+ ```
281
+
282
+ ### 7. Start OpenPrd discovery mode
283
+
284
+ Users can ask in natural language:
285
+
286
+ ```text
287
+ Use OpenPrd to deeply complete this project.
288
+ Use OpenPrd to comprehensively mine this reference project into the new project.
289
+ Keep digging into this requirement until OpenPrd coverage is complete.
290
+ ```
291
+
292
+ Discovery and loop execution require explicit depth or execution intent. For
293
+ planning, architecture review, impact analysis, or "which files would change?"
294
+ questions, agents should inspect state and answer read-only instead of advancing
295
+ coverage or launching loop tasks.
296
+
297
+ Agents route those requests internally. The underlying command is:
298
+
299
+ ```bash
300
+ openprd discovery /path/to/project --mode brownfield
301
+ openprd discovery /path/to/project --resume
302
+ openprd discovery /path/to/project --advance --claim "Users can start a session from the dashboard" --evidence src/app.ts
303
+ openprd discovery /path/to/project --verify
304
+ openprd change /path/to/project --generate --change <change-id>
305
+ openprd change /path/to/project --validate --change <change-id>
306
+ openprd standards /path/to/project --verify
307
+ openprd tasks /path/to/project --change <change-id>
308
+ openprd tasks /path/to/project --change <change-id> --advance --verify --item T001.01
309
+ openprd change /path/to/project --apply --change <change-id>
310
+ openprd change /path/to/project --archive --change <change-id>
311
+ openprd specs /path/to/project
312
+ openprd changes /path/to/project
313
+ ```
314
+
315
+ Discovery verification also checks the active OpenPrd change structure, spec deltas,
316
+ `docs/basic/` standards, and long-running task files. Keep `tasks.md` as the first
317
+ entry, cap each task file at 25 substantive checkbox tasks, and continue with
318
+ `tasks-002.md`, `tasks-003.md`, etc. The final checkbox in every non-final file
319
+ should hand off to the next file so agents can resume in order. A project can use
320
+ a stricter local cap with `.openprd/discovery/config.json` at
321
+ `taskSharding.maxItemsPerFile`.
322
+
323
+ That 25-item limit is only a sharding cap, not a decomposition target. Prefer task
324
+ titles that describe concrete implementation units, wiring boundaries, entry
325
+ surfaces, integration closures, and regression passes instead of mirroring PRD
326
+ section labels like "primary flow", "requirement", or "acceptance goal".
327
+
328
+ When a task needs a stable id for long-running execution, keep the metadata small:
329
+
330
+ ```md
331
+ - [ ] T009.07 Port legacy database import preview
332
+ - type: implementation
333
+ - deps: T001.14, T007.06
334
+ - done: preview shows counts, conflicts, skipped items, warnings
335
+ - verify: npm run test -- migration
336
+ - oracle: compare sample import output against the legacy preview and record mismatches
337
+ ```
338
+
339
+ Use `type` to distinguish `implementation`, `verification`, `documentation`, and
340
+ `governance` work. `deps` is only needed when the task depends on earlier task ids.
341
+ `done` is the completion condition, and `verify` is the command or review step
342
+ that proves it. For `implementation`, `verification`, and `documentation` tasks,
343
+ `verify` must exercise the real work, such as `openprd run . --verify`, test
344
+ commands, or an explicit manual review step; do not use `openprd change . --validate`
345
+ as the only proof. Use `oracle` when the task must compare against a reference
346
+ implementation, golden data set, screenshot baseline, or other explicit source
347
+ of truth; `openprd loop --finish` then requires `--notes` or `--evidence` so the
348
+ comparison result is recorded.
349
+
350
+ `tasks` lists the next dependency-ready task by default. `--advance` marks
351
+ one task complete, and `--verify` runs that task's `verify` command before marking
352
+ it complete. Execution events are stored outside the task files so the task metadata
353
+ stays small.
354
+
355
+ ## Project Standards
356
+
357
+ `openprd init` creates a project standards contract:
358
+
359
+ - `docs/basic/file-structure.md`
360
+ - `docs/basic/app-flow.md`
361
+ - `docs/basic/prd.md`
362
+ - `docs/basic/frontend-guidelines.md`
363
+ - `docs/basic/backend-structure.md`
364
+ - `docs/basic/tech-stack.md`
365
+ - `.openprd/standards/file-manual-template.md`
366
+ - `.openprd/standards/folder-readme-template.md`
367
+
368
+ Use:
369
+
370
+ ```bash
371
+ openprd standards /path/to/project --verify
372
+ ```
373
+
374
+ OpenPrd generated changes include standards maintenance tasks, and change validation
375
+ checks the standards contract. The canonical project docs path is only
376
+ `docs/basic/`.
377
+
378
+ During implementation, standards maintenance is an explicit impact check, not a
379
+ best-effort cleanup. For every added or modified source file, agents should check
380
+ whether `docs/basic/`, the file manual, or the containing folder README is missing
381
+ or stale. Missing docs must be created; existing docs should be updated whenever
382
+ the change affects responsibilities, flows, structure, dependencies, or product
383
+ behavior. If no documentation update is needed, agents should say the check was
384
+ performed and why the existing docs still match the code.
385
+
386
+ ## Auto-optimized reference-to-screenshot comparison
387
+
388
+ When UI work already has a reference effect image, design image, user-provided
389
+ screenshot, or agent-generated mock, the agent should capture the implemented
390
+ UI and generate a side-by-side review image before claiming visual completion:
391
+
392
+ ```bash
393
+ openprd visual-compare /path/to/project \
394
+ --reference effect-image.png \
395
+ --actual implementation-screenshot.jpg
396
+ ```
397
+
398
+ The default output is a compact JPG under
399
+ `.openprd/harness/visual-reviews/`. The left panel is labeled `效果图`; the
400
+ right panel is labeled `实现截图`. Inputs can be common image formats supported
401
+ by `sharp`. The output can be adjusted when needed:
402
+
403
+ ```bash
404
+ openprd visual-compare /path/to/project \
405
+ --reference effect-image.png \
406
+ --actual implementation-screenshot.jpg \
407
+ --out review.webp \
408
+ --format webp \
409
+ --quality 82 \
410
+ --max-panel-width 1180
411
+ ```
412
+
413
+ Agents should inspect the generated image and keep iterating until there are no
414
+ obvious visual differences. The final response for reference-driven UI work
415
+ should include the generated review image path and note whether differences
416
+ remain.
417
+
418
+ ## Quality Regression Reports
419
+
420
+ `openprd init` also creates a quality contract:
421
+
422
+ - `.openprd/quality/config.json`
423
+ - `.openprd/quality/reports/`
424
+ - `.openprd/knowledge/`
425
+
426
+ Use:
427
+
428
+ ```bash
429
+ openprd quality /path/to/project --verify
430
+ ```
431
+
432
+ The command writes both JSON and HTML reports under `.openprd/quality/reports/`.
433
+ The HTML regression report is the human-readable quality surface: overall
434
+ regression status, per-requirement module status, test-block pass/fail results,
435
+ missing items, and the small set of gaps that need a person to decide whether
436
+ they are in scope for the current delivery. EVO is OpenPrd's internal shorthand
437
+ for the evaluation/verification quality layer; the visible report does not ask
438
+ users to know that acronym. A script or fixture being present only proves
439
+ capability; required gates need current evidence or an explicit waiver.
440
+
441
+ When a requirement involves free users, quotas, AI calls, third-party APIs,
442
+ generation, storage, downloads, or other metered costs, `quality --verify`
443
+ also checks for cost drivers, user-level limits, negative abuse-path
444
+ verification, usage/cost monitoring, alert thresholds, and stop-loss actions.
445
+
446
+ `openprd quality --verify` is blocking by default when required test blocks are
447
+ not production-ready. `openprd run --verify` repeats that quality gate so final
448
+ readiness cannot ignore the report. Agents should not claim readiness until
449
+ every required test block is either passing with evidence or explicitly out of
450
+ scope for the scenario.
451
+
452
+ For UI work with an existing reference image, visual readiness also requires a
453
+ current `openprd visual-compare` artifact under `.openprd/harness/visual-reviews/`.
454
+ If the combined image still shows obvious differences, the task should return to
455
+ implementation instead of treating the gap as ready.
456
+
457
+ After a fix has been verified and reviewed, promote the abstract pattern into
458
+ project knowledge:
459
+
460
+ ```bash
461
+ openprd quality /path/to/project --learn --review --from .openprd/harness/turn-state.json
462
+ openprd quality /path/to/project --learn --from <report-id-or-json>
463
+ openprd quality /path/to/project --learn --from ./diagnostics/incident-2026-05-24
464
+ ```
465
+
466
+ `--learn --review` first writes a pending knowledge candidate under
467
+ `.openprd/knowledge/candidates/` plus a draft skill under
468
+ `.openprd/knowledge/drafts/`. Once the draft is worth keeping, `--learn --from`
469
+ promotes it into incident, pattern, and experience skill artifacts under
470
+ `.openprd/knowledge/` so future tasks can retrieve the lesson instead of
471
+ rediscovering it. `--from` now accepts either a quality report JSON or an
472
+ extracted diagnostics directory / evidence file that already contains
473
+ `diagnostic-report`, `runtime-events`, `timeline`, or `root-cause-candidates`
474
+ artifacts, so a verified fix can be promoted directly into a reusable
475
+ troubleshooting skill.
476
+
477
+ ## Agent Setup
478
+
479
+ OpenPrd can install the project harness into the agent environment so users do not
480
+ need to remember which skill, command, or hook to invoke:
481
+
482
+ ```bash
483
+ openprd setup /path/to/project
484
+ openprd doctor /path/to/project
485
+ openprd self-update --dry-run
486
+ openprd self-update
487
+ openprd update /path/to/project
488
+ openprd update /path/to/project --hook-profile lite
489
+ openprd upgrade /path/to/project --dry-run
490
+ openprd upgrade /path/to/project
491
+ openprd upgrade /path/to/projects --fleet --dry-run
492
+ openprd fleet /path/to/projects --dry-run
493
+ openprd fleet /path/to/projects --sync-registry
494
+ openprd fleet /path/to/projects --backfill-work-units
495
+ openprd run /path/to/project --context
496
+ openprd run /path/to/project --verify
497
+ openprd loop /path/to/project --plan --change <change-id>
498
+ openprd loop /path/to/project --run --agent codex --dry-run
499
+ ```
500
+
501
+ Installing the CLI alone does not mutate a project or user config. The full
502
+ Codex/Claude/Cursor adapter set is installed when the user runs `openprd init`
503
+ or `openprd setup` inside a project.
504
+
505
+ `setup` and `init` generate:
506
+
507
+ - `AGENTS.md` managed OpenPrd rules
508
+ - `.codex/skills/`, `.codex/prompts/`, `.codex/config.toml`, `.codex/hooks.json`, and `.codex/hooks/openprd-hook.mjs`
509
+ - user-level Codex config with `features.codex_hooks = true`
510
+ - `.claude/skills/`, `.claude/commands/openprd/`, and `CLAUDE.md`
511
+ - `.cursor/rules/openprd.mdc` and `.cursor/commands/`
512
+ - `.openprd/harness/install-manifest.json`, `hook-state.json`, `events.jsonl`, `drift-report.json`, and `visual-reviews/`
513
+
514
+ `doctor` verifies that the generated rules, Codex hooks feature flag, standards,
515
+ and workspace validation are healthy. `update` refreshes the generated adapter
516
+ files from the canonical OpenPrd source while preserving unrelated user hook
517
+ groups.
518
+
519
+ `self-update` updates the OpenPrd CLI itself from the public GitHub npm source.
520
+ `upgrade` composes the two update layers: it first runs `self-update`, then
521
+ re-resolves the installed `openprd` executable and runs either `update <project>`
522
+ or, with `--fleet`, `fleet <root> --update-openprd`. Both commands support
523
+ `--dry-run`; dry-run prints the planned install and refresh commands without
524
+ modifying the CLI, project, registry, or harness state.
525
+
526
+ The harness is stateful, but hooks are proportional to the chosen profile.
527
+ Default `lite` keeps a lightweight `PreToolUse` write gate for requirement
528
+ intake and limits it to direct editing tools, while `Stop` performs a lightweight
529
+ end-of-turn knowledge review instead of full telemetry. This avoids read-only shell hook
530
+ noise while still nudging the agent to capture reusable project patterns. `guarded` also gates shell tools, while
531
+ `full` restores SessionStart/PreToolUse/PostToolUse/Stop telemetry for temporary
532
+ diagnostics. High-risk actions such as freeze, handoff, accepted spec
533
+ apply/archive, commit, push, release, or publish are gated by
534
+ `openprd run . --verify`, which covers standards, workspace validation, active
535
+ change validation, and active discovery verification.
536
+
537
+ `openprd run . --context` is the Ralph-style loop surface for agents. It selects
538
+ the next executable unit from active change tasks, discovery coverage, or normal
539
+ OpenPrd workflow state, and records hook turns in `.openprd/harness/iterations.jsonl`.
540
+
541
+ ### Long-Running Agent Loop
542
+
543
+ For implementation work that should behave like the harness pattern described by
544
+ Anthropic's long-running agent guidance, use `openprd loop`. The loop is stricter
545
+ than `run --context`: it creates a durable feature list, writes a single-task
546
+ prompt, starts a fresh Codex or Claude session for exactly one task, verifies the
547
+ task, and can commit that task before moving on.
548
+
549
+ For reference-driven UI tasks, the loop prompt and generated guidance require the
550
+ agent to capture an implementation screenshot, run `openprd visual-compare`, and
551
+ review the side-by-side JPG before finishing the task.
552
+
553
+ `openprd run --context` may surface loop commands as execution commands, but they
554
+ are not automatic instructions. Agents should run `openprd loop --run`,
555
+ `openprd tasks --advance`, `openprd discovery --advance`, or commit commands only
556
+ when the current user message explicitly asks for development, implementation,
557
+ task continuation, deep research/benchmarking, replication, or commit. Read-only
558
+ planning and review turns should stop at the module/file plan.
559
+
560
+ Loop is recommended from the substantive implementation task count, not from every
561
+ checkbox. When a change has 10 or more pending/total `implementation` tasks,
562
+ `run --context` recommends an isolated worktree or equivalent environment plus a
563
+ single-task Loop session.
564
+
565
+ ```bash
566
+ openprd loop . --init
567
+ openprd loop . --plan --change <change-id>
568
+ openprd loop . --next
569
+ openprd loop . --prompt --agent codex
570
+ openprd loop . --run --agent codex --dry-run
571
+ openprd loop . --run --agent claude --dry-run
572
+ openprd loop . --verify --item T001.01
573
+ openprd loop . --finish --item T001.01 --commit --message "Complete T001.01"
574
+ ```
575
+
576
+ The loop writes its durable state under `.openprd/harness/`:
577
+
578
+ - `feature-list.json` is the ordered implementation task list.
579
+ - Each loop task carries a human-readable `taskHandle` such as
580
+ `change-id:T001.01:task-title`, so another conversation can continue the same
581
+ task without relying on a chat-specific UUID.
582
+ - `progress.md` is the human-readable progress log.
583
+ - `failed-approaches.md` is the dead-end ledger for mismatches, rejected fixes,
584
+ and why they failed, so the next session does not retry the same path.
585
+ - `agent-sessions.jsonl` records each prompt/run/finish event, including the
586
+ task handle and task title for cross-session lookup.
587
+ - `bootstrap.sh` is the startup check each fresh agent session runs.
588
+ - `loop-state.json` stores the current task id, task handle, task title, and
589
+ the last agent session metadata.
590
+ - `loop-prompts/` stores generated single-task prompts for audit and reuse.
591
+
592
+ Use `--dry-run` first when you want OpenPrd to prepare the prompt and exact command
593
+ without launching an agent. Use `--agent codex` or `--agent claude` for the default
594
+ CLI integrations. Use `--agent-command "<custom command>"` only when you want to
595
+ pipe the OpenPrd prompt into a project-specific wrapper.
596
+
597
+ For historical projects, use `fleet` instead of hand-writing shell loops. By
598
+ default it scans and reports only, while also telling you how many known
599
+ OpenPrd workspaces already exist in the global registry and how many are outside
600
+ the current root. `--sync-registry` backfills initialized `.openprd/`
601
+ workspaces into `~/.openprd/registry/workspaces.jsonl`. `--update-openprd`
602
+ refreshes projects that already contain `.openprd/` and also backfills
603
+ historical PRD work unit bindings. Project standards or validation gaps are
604
+ reported as health items, but they do not block generated guidance updates. Use
605
+ `--backfill-work-units` when you only want to refresh versioned review artifacts
606
+ and identity bindings, while agent-only or plain projects stay untouched unless
607
+ explicitly selected with `--setup-missing`.
608
+
609
+ ## How to Read `status` and `next`
610
+
611
+ OpenPrd is not just a command runner. It exposes collaboration state.
612
+
613
+ ### `openprd status`
614
+
615
+ Use it to understand:
616
+
617
+ - current scenario
618
+ - user participation mode
619
+ - current gate
620
+ - upcoming gate
621
+
622
+ Example signals:
623
+
624
+ - `Scenario: Cold start (existing project)`
625
+ - `User participation mode: context-plus-confirmation`
626
+ - `Current gate: clarify-user`
627
+ - `Upcoming gate: architecture diagram review`
628
+
629
+ ### `openprd next`
630
+
631
+ Use it to understand:
632
+
633
+ - what should happen next
634
+ - why that step is recommended
635
+ - which questions should be asked now
636
+
637
+ ## Diagram Contracts
638
+
639
+ OpenPrd supports:
640
+
641
+ - `architecture`
642
+ - `product-flow`
643
+
644
+ You can let the tool infer a draft from the current workspace, or supply an explicit contract:
645
+
646
+ ```bash
647
+ openprd diagram /path/to/project \
648
+ --type product-flow \
649
+ --input ./product-flow-contract.json
650
+ ```
651
+
652
+ The diagram contract is validated against built-in schema files in `.openprd/schema/`.
653
+
654
+ ## Agent Skills
655
+
656
+ This repository ships a repo-local `skills/` directory modeled after the `lark-shared + domain skills` pattern used by `larksuite/cli`.
657
+
658
+ - `skills/openprd-shared/` — shared guardrails and language/review rules
659
+ - `skills/openprd-harness/` — main OpenPrd workflow sequencing
660
+ - `skills/openprd-standards/` — project docs, file manual, and folder README standards
661
+ - `skills/openprd-diagram-review/` — diagram generation and review loop guidance
662
+ - `skills/openprd-discovery-loop/` — sustained OpenPrd coverage discovery
663
+
664
+ Agents entering this repository should read:
665
+
666
+ - `AGENTS.md`
667
+
668
+ ## Project Structure
669
+
670
+ ```text
671
+ .
672
+ ├── AGENTS.md
673
+ ├── bin/
674
+ ├── src/
675
+ ├── skills/
676
+ ├── test/
677
+ ├── docs/
678
+ │ └── basic/
679
+ ├── openprd/
680
+ │ ├── changes/
681
+ │ ├── specs/
682
+ │ └── archive/
683
+ └── .openprd/
684
+ ├── schema/
685
+ ├── templates/
686
+ ├── engagements/
687
+ ├── state/
688
+ └── exports/
689
+ ```
690
+
691
+ Key directories:
692
+
693
+ - `src/` — CLI logic, PRD core, diagram rendering
694
+ - `docs/basic/` — project-level baseline docs maintained by OpenPrd standards
695
+ - `skills/` — repo-local agent skill system
696
+ - `.openprd/` — shipped workspace seed
697
+ - `test/` — regression coverage for clarify / capture / diagram / gate logic
698
+
699
+ ## Agent Prompt Examples
700
+
701
+ You can steer agents with prompts like:
702
+
703
+ ```text
704
+ Use $openprd-harness to initialize and advance an OpenPrd workspace for this product idea.
705
+ ```
706
+
707
+ ```text
708
+ Use $openprd-diagram-review to generate a product-flow review artifact before freeze.
709
+ ```
710
+
711
+ ## Contributing
712
+
713
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
714
+
715
+ ## Security
716
+
717
+ See [SECURITY.md](./SECURITY.md).
718
+
719
+ ## License
720
+
721
+ MIT — see [LICENSE](./LICENSE).
722
+
723
+ ## Author
724
+
725
+ - X: [Mileson07](https://x.com/Mileson07)
726
+ - Xiaohongshu: [超级峰](https://xhslink.com/m/4LnJ9aB1f97)
727
+ - Douyin: [超级峰](https://v.douyin.com/rH645q7trd8/)