@dawipong/opcflow 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.
- package/LICENSE +21 -0
- package/README.en.md +253 -0
- package/README.md +239 -0
- package/dist/cli.mjs +4550 -0
- package/package.json +81 -0
- package/preset/.editorconfig +16 -0
- package/preset/.gitattributes +15 -0
- package/preset/.prettierignore +7 -0
- package/preset/.prettierrc +8 -0
- package/preset/package.json +8 -0
- package/templates/agents/en/architect.md +65 -0
- package/templates/agents/en/designer.md +56 -0
- package/templates/agents/en/developer.md +60 -0
- package/templates/agents/en/product-manager.md +58 -0
- package/templates/agents/en/qa.md +62 -0
- package/templates/agents/zh/architect.md +65 -0
- package/templates/agents/zh/designer.md +56 -0
- package/templates/agents/zh/developer.md +60 -0
- package/templates/agents/zh/product-manager.md +58 -0
- package/templates/agents/zh/qa.md +62 -0
- package/web/dist/assets/abnfDiagram-VRR7QNED-CM_SmMdS.js +1 -0
- package/web/dist/assets/arc-a2d6VGyS.js +1 -0
- package/web/dist/assets/architectureDiagram-ZJ3FMSHR-CKwso5u1.js +36 -0
- package/web/dist/assets/blockDiagram-677ZJIJ3-DOlRPtCE.js +132 -0
- package/web/dist/assets/c4Diagram-LMCZKHZV-BVWP4jKU.js +10 -0
- package/web/dist/assets/channel-Bv2v5Ka7.js +1 -0
- package/web/dist/assets/chunk-2Q5K7J3B-Dg1gXqD_.js +1 -0
- package/web/dist/assets/chunk-32BRIVSS-DMEBIyv0.js +1 -0
- package/web/dist/assets/chunk-5VM5RSS4-BfNutGrI.js +15 -0
- package/web/dist/assets/chunk-EX3LRPZG-B0LUaNef.js +231 -0
- package/web/dist/assets/chunk-JWPE2WC7-RWpAfnwW.js +1 -0
- package/web/dist/assets/chunk-MOJQB5TN-CHzjH2SN.js +88 -0
- package/web/dist/assets/chunk-RYQCIY6F-CB84H40n.js +1 -0
- package/web/dist/assets/chunk-V7JOEXUC-hDfVeloC.js +206 -0
- package/web/dist/assets/chunk-VR4S4FIN-C-ISU9mB.js +1 -0
- package/web/dist/assets/chunk-XXDRQBXY-Q-1uA8_v.js +1 -0
- package/web/dist/assets/classDiagram-OUVF2IWQ-C5GMtsqN.js +1 -0
- package/web/dist/assets/classDiagram-v2-EOCWNBFH-C5GMtsqN.js +1 -0
- package/web/dist/assets/cose-bilkent-JH36ORCC-D4aRsqbg.js +1 -0
- package/web/dist/assets/cynefin-VYW2F7L2-Bb_blZYP.js +166 -0
- package/web/dist/assets/cynefinDiagram-TSTJHNR4-CRX9tSwx.js +62 -0
- package/web/dist/assets/cytoscape.esm-D3_iZ_3b.js +321 -0
- package/web/dist/assets/dagre-VKFMJZFB-BHcw1uwS.js +4 -0
- package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/web/dist/assets/diagram-FQU43EPY-BbFIcSGy.js +3 -0
- package/web/dist/assets/diagram-G47NLZAW-D6SEnl9Y.js +24 -0
- package/web/dist/assets/diagram-NH7WQ7WH-Dq4ObETB.js +24 -0
- package/web/dist/assets/diagram-OA4YK3LP-EF9zUKb4.js +30 -0
- package/web/dist/assets/diagram-WEI45ONY-9MSuI1lJ.js +41 -0
- package/web/dist/assets/ebnfDiagram-CCIWWBDH-BKTvNs-v.js +1 -0
- package/web/dist/assets/erDiagram-Q63AITRT-BRZ7eOih.js +85 -0
- package/web/dist/assets/flowDiagram-23GEKE2U-n6RjlBIU.js +156 -0
- package/web/dist/assets/ganttDiagram-NO4QXBWP-DJ8LFx2q.js +292 -0
- package/web/dist/assets/gitGraphDiagram-IHSO6WYX-PBNVnu__.js +106 -0
- package/web/dist/assets/graph-DOmOIIwC.js +1 -0
- package/web/dist/assets/index-BkpgTe8Q.js +674 -0
- package/web/dist/assets/index-CfSIxCYt.css +1 -0
- package/web/dist/assets/infoDiagram-FWYZ7A6U-DpF1ykim.js +2 -0
- package/web/dist/assets/init-Gi6I4Gst.js +1 -0
- package/web/dist/assets/ishikawaDiagram-FXEZZL3T-BcLaz8vn.js +70 -0
- package/web/dist/assets/journeyDiagram-5HDEW3XC-DhDa2tr6.js +139 -0
- package/web/dist/assets/kanban-definition-HUTT4EX6-Cj5MBccm.js +89 -0
- package/web/dist/assets/katex-HP8lGamR.js +257 -0
- package/web/dist/assets/layout-D-LzfAck.js +1 -0
- package/web/dist/assets/linear-D-RAQuF7.js +1 -0
- package/web/dist/assets/map-DxJ2ADlA.js +1 -0
- package/web/dist/assets/mindmap-definition-LN4V7U3C-CDHapI3O.js +96 -0
- package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/web/dist/assets/pegDiagram-2B236MQR-Cga1GKF6.js +1 -0
- package/web/dist/assets/pieDiagram-ENE6RG2P-BtzEbqHl.js +39 -0
- package/web/dist/assets/quadrantDiagram-ABIIQ3AL-CMHXJPd5.js +7 -0
- package/web/dist/assets/railroadDiagram-RFXS5EU6-C5dKOd7a.js +1 -0
- package/web/dist/assets/requirementDiagram-TGXJPOKE-Cjx6LPCa.js +84 -0
- package/web/dist/assets/sankeyDiagram-HTMAVEWB-C8kzAycX.js +40 -0
- package/web/dist/assets/sequenceDiagram-DBY2YBRQ-DwEDppgS.js +162 -0
- package/web/dist/assets/sizeCapture-X5ZJPWSS-CUgsJ-ry.js +1 -0
- package/web/dist/assets/stateDiagram-2N3HPSRC-B4fcb7Qa.js +1 -0
- package/web/dist/assets/stateDiagram-v2-6OUMAXLB-IQXX7rVH.js +1 -0
- package/web/dist/assets/swimlanes-5IMT3BWC-Bw27O3PP.js +2 -0
- package/web/dist/assets/swimlanesDiagram-G3AALYLV-DRko3G58.js +8 -0
- package/web/dist/assets/timeline-definition-FHXFAJF6-Cra4Bj9n.js +120 -0
- package/web/dist/assets/vennDiagram-L72KCM5P-B_Nmy9aH.js +34 -0
- package/web/dist/assets/wardleyDiagram-EHGQE667-BE1omAzb.js +78 -0
- package/web/dist/assets/xychartDiagram-FW5EYKEG-CsNs1p2c.js +7 -0
- package/web/dist/index.html +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dawi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# opcflow
|
|
4
|
+
|
|
5
|
+
**A drift-enforced, spec-anchored execution layer for AI coding.**
|
|
6
|
+
|
|
7
|
+
One template turns Claude Code / Codex / OpenCode / Cursor into a contract-governed, multi-role development pipeline.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
[简体中文](README.md) · **English**
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What it is
|
|
21
|
+
|
|
22
|
+
Once generation is effectively free, **verification is the only bottleneck**. opcflow forges every
|
|
23
|
+
verification you make (approvals, 👍👎, rulings) into machine-readable, invalidatable, propagating
|
|
24
|
+
assets: docs → tasks → outputs form a real relationship graph (a DAG + foreign keys), and any change
|
|
25
|
+
**propagates along the chain and auto-dispatches re-reviews**. You do only three things: **approve
|
|
26
|
+
contracts, thumbs-up/down outputs, and answer rulings**.
|
|
27
|
+
|
|
28
|
+
- **Real relationship graph** — an artifact DAG + task foreign keys, not naming conventions
|
|
29
|
+
- **Five-state trust anchors** — editing approved content auto-invalidates it, downstream auto-goes-stale (state is derived from file content; nobody has to "update the status")
|
|
30
|
+
- **Five-role pipeline** — product-manager → architect → designer → developer → qa, each consuming approved upstream contracts, each with a gate
|
|
31
|
+
- **Change propagation** — `sync` reconciles → invalidate → dispatch review along the graph (deduped)
|
|
32
|
+
- **QA loop** — fail → auto rework → auto re-verify, no human in the loop
|
|
33
|
+
- **Write-gate hooks** — block agents from editing an approved contract (observe mode by default)
|
|
34
|
+
- **Feedback evolution** — 👍👎 and QA verdicts, half-life weighted → skill candidates / Red Flags
|
|
35
|
+
- **Multi-platform** — one definition generates each platform's agent + MCP + hooks (see [PLATFORMS.md](PLATFORMS.md))
|
|
36
|
+
- **Visual opcflow** — tree + markdown/mermaid/prototype/code rendering + review-queue diff + live SSE
|
|
37
|
+
|
|
38
|
+
## Difference from GitHub Spec Kit
|
|
39
|
+
|
|
40
|
+
[Spec Kit](https://github.com/github/spec-kit) is a scaffold for spec-driven development: `/specify →
|
|
41
|
+
/plan → /tasks → implement`, where each phase produces a markdown artifact that feeds the next,
|
|
42
|
+
giving the agent **structured context** instead of ad-hoc prompts. It solves "**how to write a good
|
|
43
|
+
spec before handing it to an agent**."
|
|
44
|
+
|
|
45
|
+
opcflow takes over **execution and verification after the spec**. The two are different layers and
|
|
46
|
+
complementary:
|
|
47
|
+
|
|
48
|
+
| | Spec Kit | opcflow |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| Role of the spec | **One-shot context** for the agent (markdown) | A machine-enforced **approved contract**; a DAG node |
|
|
51
|
+
| Approval | No enforced state; a human reads it | Five-state trust anchor (draft/pending/approved/invalidated), machine-derived |
|
|
52
|
+
| After the spec changes | No linkage; humans must remember to sync | **Auto-invalidate + downstream stale + dispatch review** |
|
|
53
|
+
| Roles | Essentially single-flow (one agent implements) | Five-role pipeline, each with its own gate and output channel |
|
|
54
|
+
| Construction constraints | The spec is advisory | Gates block tasks whose upstream isn't approved; write-gate blocks edits to approved contracts; protocol lints as checkpoints |
|
|
55
|
+
| Acceptance | Not covered | Two-stage QA + fail→rework→re-verify auto loop |
|
|
56
|
+
| Evolution | Not covered | 👍👎/verdict half-life weighting → skill candidates / Red Flags |
|
|
57
|
+
|
|
58
|
+
In one line: **Spec Kit treats the spec as "context for the agent"; opcflow treats it as "an
|
|
59
|
+
approved contract that can go stale, propagate, and block construction," and governs the entire drift
|
|
60
|
+
from contract to code to acceptance.**
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
opcflow is an npm package — it **does not drop source into your project**. Bootstrap from your
|
|
65
|
+
project root with npx, zero install:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# In your project root: pick platforms (multi-select) + endpoints, generate in one shot
|
|
69
|
+
npx -y @dawipong/opcflow init --platforms=claude,cursor --endpoints=service,web
|
|
70
|
+
# backend-only: --endpoints=service (auto-prunes designer, qa kept)
|
|
71
|
+
# set models: --model='{"codex":"gpt-5.1-codex"}' or --model=<single string> (defaults per platform)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
It writes only **generated artifacts** — each platform's agent definitions, MCP registration, hooks,
|
|
75
|
+
`workbench.config.json`, the `docs/` skeleton, and the `.workbench/` database; **no opcflow source**.
|
|
76
|
+
The generated MCP / hook / CLI references all point at `npx -y @dawipong/opcflow <subcommand>`, so no
|
|
77
|
+
reinstall across machines or teammates. `--platforms` defaults to `claude`.
|
|
78
|
+
|
|
79
|
+
> Per-platform layout, Codex trust, Cursor main-agent model, etc. — see **[PLATFORMS.md](PLATFORMS.md)**.
|
|
80
|
+
|
|
81
|
+
Requires Node ≥ 22.
|
|
82
|
+
|
|
83
|
+
## Quick Start
|
|
84
|
+
|
|
85
|
+
1. **Fill in code-dir conventions** — edit `codeRoots` in `workbench.config.json` (each endpoint's code dir, `{module}` placeholder).
|
|
86
|
+
2. **Start the opcflow** (visual approval panel, connects to the project's `.workbench`):
|
|
87
|
+
```bash
|
|
88
|
+
npx -y @dawipong/opcflow serve # → http://127.0.0.1:5620 (--project sets the root, defaults to cwd)
|
|
89
|
+
```
|
|
90
|
+
3. **Give the AI your first requirement** (one sentence). It runs the five-role pipeline, producing contracts layer by layer and submitting them for review.
|
|
91
|
+
4. **Nod in the review queue** — view diffs in the opcflow; approve / reject; thumbs-up prototypes.
|
|
92
|
+
5. **Once all contracts are approved, dispatch:**
|
|
93
|
+
```bash
|
|
94
|
+
npx -y @dawipong/opcflow plan --module=<module> # dispatch architect/designer/developer/qa tasks
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Every later change is tracked: edit an approved contract → auto-invalidate → downstream stale → a
|
|
98
|
+
re-review task appears in the queue.
|
|
99
|
+
|
|
100
|
+
## Agent Authoring Flow (five-role pipeline)
|
|
101
|
+
|
|
102
|
+
```mermaid
|
|
103
|
+
flowchart LR
|
|
104
|
+
U(["⬜ Requirement"]) --> PM["🟦 product-manager<br/>business contracts"]
|
|
105
|
+
PM --> AR["🟦 architect<br/>DB + API contracts"]
|
|
106
|
+
AR --> DE["🟦 designer<br/>design system + prototype"]
|
|
107
|
+
DE --> DV["🟦 developer<br/>code"]
|
|
108
|
+
DV --> QA["🟦 qa<br/>acceptance"]
|
|
109
|
+
QA --> DONE(["✅ module accepted"])
|
|
110
|
+
QA -.->|"fail → rework"| DV
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> 🟦 agent action · ⬜ user gate (approval / 👍) · ⚙️ engine-automatic. Every output must **pass a user
|
|
114
|
+
> gate** before it becomes trusted truth for downstream. All agents share one skeleton: **claim (pass
|
|
115
|
+
> the gate) → consume approved upstream → produce → register → submit/👍/accept → pass the gate →
|
|
116
|
+
> complete**.
|
|
117
|
+
|
|
118
|
+
**The trust protocol, everywhere**: upstream `approved` = truth, use it directly (**no re-derivation, no
|
|
119
|
+
re-confirming**); `draft/pending` = usable but flagged "unreviewed"; `invalidated / under re-review` =
|
|
120
|
+
**forbidden**, wait for re-review; on a substantive objection, use `dispute` to leave a trace and stop —
|
|
121
|
+
never silently deviate.
|
|
122
|
+
|
|
123
|
+
| Role | When it enters / gate | Produces | How it becomes truth |
|
|
124
|
+
| --- | --- | --- | --- |
|
|
125
|
+
| **product-manager** | user gives a requirement | layered business contracts: project → roles/glossary → flow (with entity state machine) → module PRD → page PRD (with acceptance points) | submit layer by layer; **approval required to advance**; all approved → `plan` dispatches |
|
|
126
|
+
| **architect** | gate: flow + module PRD approved | tech baseline (ARCHITECTURE/TECH, task #0), DB docs, API contracts; **sole owner of shared enums** | human approval; no module may start before the baseline is approved |
|
|
127
|
+
| **designer** | gate: that endpoint's design system approved | design system (human-reviewed), design prompts (registered only, not submitted), HTML prototype | prototype released via **👍 = feedback + approval combined** |
|
|
128
|
+
| **developer** | gate: contracts in place; frontend tasks require a 👍'd prototype | code per endpoint (maintained by directory-level scan, not manually registered) | complete gate: machineChecks / protocolLints pass |
|
|
129
|
+
| **qa** | two-stage: define acceptance criteria first (submit), then run after developer completes | acceptance cases (`docs/acceptance/...`), pass/fail | pass → +1 verdict on the code; **fail → auto rework → auto re-verify** until pass |
|
|
130
|
+
|
|
131
|
+
> **Two ways to produce the HTML prototype**: by default the currently connected model produces it
|
|
132
|
+
> directly; or hand the approved **design system** + **page design prompts** to a third-party design
|
|
133
|
+
> platform (e.g. v0, Lovable) to generate the HTML, then drop the file into the matching path
|
|
134
|
+
> `docs/design/prototypes/<endpoint>/<module>/<page>.html` — once `scan` registers it, it goes through
|
|
135
|
+
> the usual 👍 release. Both paths are equivalent in the system; both must pass a user 👍.
|
|
136
|
+
|
|
137
|
+
## CLI Commands & Parameters
|
|
138
|
+
|
|
139
|
+
Every command: `npx -y @dawipong/opcflow <command> [args]`. Global `--project=<path>` sets the project
|
|
140
|
+
root (otherwise it searches upward for `workbench.config.json`). File-path arguments are separated with
|
|
141
|
+
`--` (e.g. `submit --actor=x -- <path>`).
|
|
142
|
+
|
|
143
|
+
**Tasks**
|
|
144
|
+
|
|
145
|
+
| Command | Purpose | Parameters |
|
|
146
|
+
| --- | --- | --- |
|
|
147
|
+
| `list` | list tasks | `--status` `--assignee` `--module` `--role` `--endpoint` `--type` `--stale=true` |
|
|
148
|
+
| `show <id>` | task detail (events / outputs / stale) | `--json=true` |
|
|
149
|
+
| `create` | create a task | required `--role` `--creator`; opt `--module` `--endpoint` `--page` `--type` `--assignee` `--content` |
|
|
150
|
+
| `claim <id>` | claim (passes the gate, auto-snapshots deps) | `--assignee=<role>` |
|
|
151
|
+
| `update <id>` | change status | `--status` `--operator`; `--force=true` bypasses the stale block (traced) |
|
|
152
|
+
| `remove <id>` | delete a task | `--operator`; `--force=true` |
|
|
153
|
+
| `record <id> "note"` | add a note | `--operator` |
|
|
154
|
+
| `input <id> -- <path>` | declare a dependency read outside the gate | `--operator` |
|
|
155
|
+
|
|
156
|
+
**Outputs**
|
|
157
|
+
|
|
158
|
+
| Command | Purpose | Parameters |
|
|
159
|
+
| --- | --- | --- |
|
|
160
|
+
| `output -- <path>` | register an output (auto-links your claimed task) | required `--role` `--endpoint`; opt `--module` `--page` `--task` |
|
|
161
|
+
| `artifacts` | list artifacts | `--module` `--endpoint` `--page` `--kind` |
|
|
162
|
+
| `scan` | full scan & register (docs + codeRoots), derive DAG edges | `--actor` |
|
|
163
|
+
| `move --from=<> --to=<>` | move an artifact (keeps id, keeps approval) | `--actor` |
|
|
164
|
+
|
|
165
|
+
**Trust**
|
|
166
|
+
|
|
167
|
+
| Command | Purpose | Parameters |
|
|
168
|
+
| --- | --- | --- |
|
|
169
|
+
| `submit -- <path>` | submit for review | `--actor` |
|
|
170
|
+
| `approve -- <path>` | approve | `--actor`; `--trivial=true` for tweaks: re-bless downstream + close derived reviews |
|
|
171
|
+
| `reject -- <path>` | reject | `--actor` `--reason` |
|
|
172
|
+
| `feedback -- <path>` | feedback / 👍👎 (release prototype) | `--actor` `--verdict=+1\|-1`; opt `--comment` `--task` |
|
|
173
|
+
| `dispute -- <path>` | trace an objection to approved content and stop for a ruling | `--actor` `--reason` |
|
|
174
|
+
| `queue` | review queue (pending + invalidated) | — |
|
|
175
|
+
| `sync` | reconcile: invalidation propagation + dispatch review | `--actor` |
|
|
176
|
+
|
|
177
|
+
**Flow**
|
|
178
|
+
|
|
179
|
+
| Command | Purpose | Parameters |
|
|
180
|
+
| --- | --- | --- |
|
|
181
|
+
| `plan` | dispatch downstream tasks once contracts are approved | `--module`; opt `--creator` |
|
|
182
|
+
| `qa <id>` | record acceptance result (fail auto-dispatches rework) | `--result=pass\|fail` `--operator`; fail needs `--reason` |
|
|
183
|
+
| `audit` | module contract reconciliation report (settlement status) | `--module` |
|
|
184
|
+
| `graph` | emit a Mermaid dependency graph | `--module` |
|
|
185
|
+
| `lint` | run protocol lints | opt `--role` `--endpoint` |
|
|
186
|
+
| `events` | event stream | `--taskId`/`<id>` `--module` `--event` `--limit` `--json` |
|
|
187
|
+
| `intake` | pull GitHub issues into the queue (standard lane / hotfix) | — |
|
|
188
|
+
|
|
189
|
+
**Evolution / Maintenance**
|
|
190
|
+
|
|
191
|
+
| Command | Purpose | Parameters |
|
|
192
|
+
| --- | --- | --- |
|
|
193
|
+
| `retro` | retrospective: skill candidates / Red Flags / approval throughput | opt `--module` `--json` |
|
|
194
|
+
| `export` | export events/feedback as jsonl | — |
|
|
195
|
+
| `init` | bootstrap a new project | `--endpoints` (required); `--platforms` `--model` `--writehooks=false` `--preset=false` `--hooks=false` |
|
|
196
|
+
| `gen-agents` | regenerate agent definitions from templates | — |
|
|
197
|
+
| `register-meta` | register meta artifacts (agent-def/skill/plan) | `--actor` |
|
|
198
|
+
| `install-hooks` | install git hooks | — |
|
|
199
|
+
| `migrate` | migrate a legacy DB | `--from=<path>` |
|
|
200
|
+
|
|
201
|
+
> On the AI side, prefer the MCP `wb_*` typed tools (same source & transaction as the CLI). **approve/reject are deliberately not exposed to the AI — those are your actions.**
|
|
202
|
+
|
|
203
|
+
## Configuration (workbench.config.json)
|
|
204
|
+
|
|
205
|
+
```jsonc
|
|
206
|
+
{
|
|
207
|
+
"platforms": ["claude", "cursor"], // target platforms (picked by init), default ["claude"]
|
|
208
|
+
"endpoints": ["service", "web"], // your endpoints
|
|
209
|
+
"pipeline": ["product-manager", "architect", "designer", "developer", "qa"], // role pipeline (excluded roles get no tasks)
|
|
210
|
+
"codeRoots": { // [required] code dir per endpoint, {module} placeholder
|
|
211
|
+
"service": ["service/src/modules/{module}"],
|
|
212
|
+
"web": ["web/src/pages/{module}"]
|
|
213
|
+
},
|
|
214
|
+
"moduleMapping": { "userProfile": "user" }, // merge fine modules into coarse ones
|
|
215
|
+
"machineChecks": { "enabled": false, // run on developer complete
|
|
216
|
+
"service": ["cd service && npx tsc --noEmit"] },
|
|
217
|
+
"protocolLints": [ // machine-checkable conventions → lints (violations block complete)
|
|
218
|
+
{ "name": "no-page-size", "grep": "pageSize", "paths": ["service/src"] }
|
|
219
|
+
],
|
|
220
|
+
"gates": {
|
|
221
|
+
"approvalMode": "warn", // warn = unreviewed only warns / enforce = blocks
|
|
222
|
+
"writeGate": "observe" // off / observe (log only) / enforce (block edits to approved contracts)
|
|
223
|
+
},
|
|
224
|
+
"git": { "taskTrailer": "off", "trailerKey": "Task" } // on = inject a Task:#id attribution trailer on commit
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Visual opcflow
|
|
229
|
+
|
|
230
|
+
`npx -y @dawipong/opcflow serve` serves at `http://127.0.0.1:5620`: the artifact tree (colors update live), markdown /
|
|
231
|
+
mermaid / HTML-prototype iframe / code rendering, the **review-queue diff** (approved version vs.
|
|
232
|
+
current), an event timeline, and live SSE refresh. Approve, reject, and thumbs-up/down prototypes right
|
|
233
|
+
here.
|
|
234
|
+
|
|
235
|
+
## Scripts
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
pnpm start # start the opcflow (build frontend + start server; use for first run)
|
|
239
|
+
pnpm run serve # server only, no frontend build (404 if web/dist is missing)
|
|
240
|
+
pnpm run web:build # build the frontend
|
|
241
|
+
pnpm test # core unit tests
|
|
242
|
+
pnpm run typecheck # type check
|
|
243
|
+
pnpm run check:isolation # zero business-coupling check
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Tech Stack
|
|
247
|
+
|
|
248
|
+
TypeScript · better-sqlite3 · Fastify · React 18 + antd 6 · Monaco · mermaid ·
|
|
249
|
+
@modelcontextprotocol/sdk · smol-toml · tsx. Runtime Node ≥ 22.
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
[MIT](LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# opcflow
|
|
4
|
+
|
|
5
|
+
**Drift-enforced、spec-anchored 的 AI 开发执行层。**
|
|
6
|
+
|
|
7
|
+
一套模板,把 Claude Code / Codex / OpenCode / Cursor 变成受契约约束的多角色开发流水线。
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
**简体中文** · [English](README.en.md)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 这是什么
|
|
21
|
+
|
|
22
|
+
生成无限快之后,**验证是唯一瓶颈**。opcflow 把你的每一次验证(审批、👍👎、裁决)铸成
|
|
23
|
+
机器可读、可失效、可传播的资产:文档 → 任务 → 产出形成真实的关系链(DAG + 外键),任何一处
|
|
24
|
+
变更都**自动沿链传播、自动派复审**。你只做三件事:**审批契约、给产物点 👍👎、回答裁决**。
|
|
25
|
+
|
|
26
|
+
- **真实关系链** —— artifact DAG + 任务外键,不是命名约定
|
|
27
|
+
- **五态信任锚点** —— approved 内容被改自动失效,下游自动 stale(状态由文件内容派生,无需谁去"更新状态")
|
|
28
|
+
- **五角色流水线** —— product-manager → architect → designer → developer → qa,各消费上游 approved 契约,各有 gate
|
|
29
|
+
- **变更传播** —— `sync` 对账 → 失效 → 沿图派 review(去重)
|
|
30
|
+
- **QA 闭环** —— fail → 自动 rework → 自动复验,不消耗人
|
|
31
|
+
- **写门禁 hooks** —— agent 改到已 approved 契约时拦截(默认 observe 观察期)
|
|
32
|
+
- **反馈进化** —— 👍👎 与 QA verdict 半衰期加权 → skill 候选 / Red Flags
|
|
33
|
+
- **多平台** —— 一套定义生成四家平台各自的 agent + MCP + hooks(见 [PLATFORMS.md](PLATFORMS.md))
|
|
34
|
+
- **可视化工作台** —— 树 + markdown/mermaid/原型/代码渲染 + 待审队列 diff + SSE 实时
|
|
35
|
+
|
|
36
|
+
## 与 GitHub Spec Kit 的区别
|
|
37
|
+
|
|
38
|
+
[Spec Kit](https://github.com/github/spec-kit) 是 spec-driven development 的脚手架:`/specify → /plan
|
|
39
|
+
→ /tasks → implement`,每个阶段产出一份 markdown 喂给下一阶段,给 agent **结构化上下文**而非
|
|
40
|
+
临时提示词。它解决的是「**如何写出好 spec 再交给 agent**」。
|
|
41
|
+
|
|
42
|
+
opcflow 接管 **spec 之后的执行与验证**,两者是不同层次、可互补:
|
|
43
|
+
|
|
44
|
+
| | Spec Kit | opcflow |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| spec 的角色 | 给 agent 的**一次性上下文**(markdown) | 机器强制的**已批契约**,是 DAG 节点 |
|
|
47
|
+
| 审批 | 无强制状态;人读一读 | 五态信任锚点(draft/pending/approved/invalidated),机器派生 |
|
|
48
|
+
| 改了 spec 之后 | 无联动,靠人记得同步 | **自动失效 + 下游 stale + 派复审** |
|
|
49
|
+
| 角色 | 基本单流程(一个 agent 实现) | 五角色流水线,各有 gate 与产出通道 |
|
|
50
|
+
| 施工约束 | spec 是建议 | gate 拦住上游未批的任务;写门禁拦改已批契约;协议 lint 卡点 |
|
|
51
|
+
| 验收 | 不涉及 | 两段式 QA + fail→rework→复验自动闭环 |
|
|
52
|
+
| 进化 | 不涉及 | 👍👎/verdict 半衰期加权 → skill 候选 / Red Flags |
|
|
53
|
+
|
|
54
|
+
一句话:**Spec Kit 把 spec 当"给 agent 的上下文";opcflow 把 spec 当"会失效、会传播、卡得住施工
|
|
55
|
+
的已批契约",并管住从契约到代码到验收的整条漂移。**
|
|
56
|
+
|
|
57
|
+
## 安装
|
|
58
|
+
|
|
59
|
+
opcflow 是一个 npm 包 —— **不往你的项目里塞源码**。在项目根用 npx 零安装引导:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# 在你的项目根:选平台(多选)+ 端,一键生成
|
|
63
|
+
npx -y @dawipong/opcflow init --platforms=claude,cursor --endpoints=service,web
|
|
64
|
+
# 纯后端: --endpoints=service (自动裁掉 designer,qa 保留)
|
|
65
|
+
# 指定模型: --model='{"codex":"gpt-5.1-codex"}' 或 --model=<单个串>(缺省用各平台默认)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
它只往项目写**生成物** —— 各平台 agent 定义、MCP 注册、hooks、`workbench.config.json`、`docs/` 骨架、
|
|
69
|
+
数据库 `.workbench/`;**不落任何 opcflow 源码**。生成的 MCP / hook / CLI 引用统一指向
|
|
70
|
+
`npx -y @dawipong/opcflow <子命令>`,换机器 / 团队协作免重装。`--platforms` 缺省 `claude`。
|
|
71
|
+
|
|
72
|
+
> 各平台落地格式、Codex trust、Cursor 主 agent 模型等注意点见 **[PLATFORMS.md](PLATFORMS.md)**。
|
|
73
|
+
|
|
74
|
+
需要 Node ≥ 22。
|
|
75
|
+
|
|
76
|
+
## 快速开始
|
|
77
|
+
|
|
78
|
+
1. **填代码目录约定** —— 编辑 `workbench.config.json` 的 `codeRoots`(每个端的代码目录,`{module}` 占位)。
|
|
79
|
+
2. **起工作台**(可视化审批面板,连接项目的 `.workbench`):
|
|
80
|
+
```bash
|
|
81
|
+
npx -y @dawipong/opcflow serve # → http://127.0.0.1:5620(--project 指定项目根,缺省 cwd)
|
|
82
|
+
```
|
|
83
|
+
3. **对 AI 提第一个需求**(一句话)。它走五角色流水线逐层产出契约并送审。
|
|
84
|
+
4. **在待审队列点头** —— 工作台看 diff,approve / 打回 / 给原型 👍。
|
|
85
|
+
5. **契约全 approved 后派发**:
|
|
86
|
+
```bash
|
|
87
|
+
npx -y @dawipong/opcflow plan --module=<模块> # 一键派发 architect/designer/developer/qa 任务
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
之后的每次改动都被追踪:改了已批契约 → 自动失效 → 下游 stale → 待审队列出现复审任务。
|
|
91
|
+
|
|
92
|
+
## Agent 写作流程(五角色流水线)
|
|
93
|
+
|
|
94
|
+
```mermaid
|
|
95
|
+
flowchart LR
|
|
96
|
+
U(["⬜ 需求"]) --> PM["🟦 product-manager<br/>业务契约"]
|
|
97
|
+
PM --> AR["🟦 architect<br/>DB + API 契约"]
|
|
98
|
+
AR --> DE["🟦 designer<br/>设计系统 + 原型"]
|
|
99
|
+
DE --> DV["🟦 developer<br/>代码"]
|
|
100
|
+
DV --> QA["🟦 qa<br/>验收"]
|
|
101
|
+
QA --> DONE(["✅ 模块 accepted"])
|
|
102
|
+
QA -.->|"fail → rework"| DV
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> 🟦 agent 动作 · ⬜ 用户关卡(审批 / 👍) · ⚙️ 引擎自动。每一环的产出都要**过用户关卡**才成为
|
|
106
|
+
> 下游可信真相。所有 agent 共用一套 **claim(过 gate)→ 消费 approved 上游 → 产出 → 登记 → 送审/👍/验收
|
|
107
|
+
> → 过关卡 → complete** 的骨架。
|
|
108
|
+
|
|
109
|
+
**贯穿的信任协议**:上游 `approved` = 真相直接用(**禁重新推导、禁重复确认**);`draft/pending` = 可用但
|
|
110
|
+
标注"未审";`invalidated / 复审中` = **禁用**等复审;有实质异议走 `dispute` 留痕停下,不擅自偏离。
|
|
111
|
+
|
|
112
|
+
| 角色 | 何时介入 / gate | 产出 | 怎么成为真相 |
|
|
113
|
+
| --- | --- | --- | --- |
|
|
114
|
+
| **product-manager** | 用户提需求 | 逐层业务契约:project → roles/glossary → flow(含实体状态机)→ 模块 PRD → 页面 PRD(含验收要点) | 逐层送审,**批准才进下一层**;末层全批 → `plan` 派发 |
|
|
115
|
+
| **architect** | gate:flow + 模块 PRD 已批 | 技术基线(ARCHITECTURE/TECH,0 号任务)、DB 文档、API 契约;**共享枚举唯一变更入口** | 人工审批;基线未批任何模块不得开工 |
|
|
116
|
+
| **designer** | gate:该端设计系统已批 | 设计系统(人审)、设计提示词(仅登记不送审)、HTML 原型 | 原型靠 **👍 = 反馈+审批合一**放行 |
|
|
117
|
+
| **developer** | gate:契约齐备;前端任务要求原型已 👍 | 各端代码(目录级 scan 维护,不手动登记) | complete 闸门:machineChecks / protocolLints 通过 |
|
|
118
|
+
| **qa** | 两段式:先定验收标准(送审),developer 完成后执行 | 验收用例(`docs/acceptance/...`)、pass/fail | pass → 给 code +1 verdict;**fail → 自动 rework → 自动复验**直到 pass |
|
|
119
|
+
|
|
120
|
+
> **HTML 原型的两种产出方式**:默认由当前接入的模型直接产出;也可把 approved 的**设计系统** +
|
|
121
|
+
> **页面设计提示词**交给第三方设计平台(如 v0、Lovable 等)生成 HTML,再把产物文件丢到对应路径
|
|
122
|
+
> `docs/design/prototypes/<端>/<模块>/<页面>.html`,`scan` 登记后照常走 👍 放行——两条路径产出的原型
|
|
123
|
+
> 在体系里等价,都要过用户 👍。
|
|
124
|
+
|
|
125
|
+
## CLI 命令参数
|
|
126
|
+
|
|
127
|
+
所有命令:`npx -y @dawipong/opcflow <命令> [参数]`。全局 `--project=<路径>` 指定项目根(缺省向上找
|
|
128
|
+
`workbench.config.json`)。文件路径参数用 `--` 分隔(如 `submit --actor=x -- <路径>`)。
|
|
129
|
+
|
|
130
|
+
**任务**
|
|
131
|
+
|
|
132
|
+
| 命令 | 作用 | 参数 |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| `list` | 列任务 | `--status` `--assignee` `--module` `--role` `--endpoint` `--type` `--stale=true` |
|
|
135
|
+
| `show <id>` | 任务详情(含事件/产出/stale) | `--json=true` |
|
|
136
|
+
| `create` | 建任务 | 必填 `--role` `--creator`;选 `--module` `--endpoint` `--page` `--type` `--assignee` `--content` |
|
|
137
|
+
| `claim <id>` | 领取(过 gate,自动快照依赖) | `--assignee=<角色>` |
|
|
138
|
+
| `update <id>` | 改状态 | `--status` `--operator`;`--force=true` 越过 stale 拦截(留痕) |
|
|
139
|
+
| `remove <id>` | 删任务 | `--operator`;`--force=true` |
|
|
140
|
+
| `record <id> "备注"` | 加备注 | `--operator` |
|
|
141
|
+
| `input <id> -- <路径>` | 补充申报 gate 之外读过的依赖 | `--operator` |
|
|
142
|
+
|
|
143
|
+
**产出**
|
|
144
|
+
|
|
145
|
+
| 命令 | 作用 | 参数 |
|
|
146
|
+
| --- | --- | --- |
|
|
147
|
+
| `output -- <路径>` | 登记产物(自动关联你领取的任务) | 必填 `--role` `--endpoint`;选 `--module` `--page` `--task` |
|
|
148
|
+
| `artifacts` | 列产物 | `--module` `--endpoint` `--page` `--kind` |
|
|
149
|
+
| `scan` | 全量扫描登记(docs + codeRoots),推导 DAG 边 | `--actor` |
|
|
150
|
+
| `move --from=<> --to=<>` | 移动产物(保 id、不断审批) | `--actor` |
|
|
151
|
+
|
|
152
|
+
**信任**
|
|
153
|
+
|
|
154
|
+
| 命令 | 作用 | 参数 |
|
|
155
|
+
| --- | --- | --- |
|
|
156
|
+
| `submit -- <路径>` | 送审 | `--actor` |
|
|
157
|
+
| `approve -- <路径>` | 批准 | `--actor`;`--trivial=true` 微调:re-bless 下游 + 关派生 review |
|
|
158
|
+
| `reject -- <路径>` | 打回 | `--actor` `--reason` |
|
|
159
|
+
| `feedback -- <路径>` | 反馈 / 👍👎(原型放行) | `--actor` `--verdict=+1\|-1`;选 `--comment` `--task` |
|
|
160
|
+
| `dispute -- <路径>` | 对 approved 内容留痕异议,停下等裁决 | `--actor` `--reason` |
|
|
161
|
+
| `queue` | 待审队列(pending + invalidated) | — |
|
|
162
|
+
| `sync` | 对账:失效传播 + 沿图派 review | `--actor` |
|
|
163
|
+
|
|
164
|
+
**流程**
|
|
165
|
+
|
|
166
|
+
| 命令 | 作用 | 参数 |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| `plan` | 契约全批后一键派发下游任务 | `--module`;选 `--creator` |
|
|
169
|
+
| `qa <id>` | 记验收结果(fail 自动派 rework) | `--result=pass\|fail` `--operator`;fail 需 `--reason` |
|
|
170
|
+
| `audit` | 模块契约对账报告(清算状态) | `--module` |
|
|
171
|
+
| `graph` | 输出 Mermaid 依赖图 | `--module` |
|
|
172
|
+
| `lint` | 跑协议 lint | 选 `--role` `--endpoint` |
|
|
173
|
+
| `events` | 事件流 | `--taskId`/`<id>` `--module` `--event` `--limit` `--json` |
|
|
174
|
+
| `intake` | 拉 GitHub issue 入队(标准道 / hotfix) | — |
|
|
175
|
+
|
|
176
|
+
**进化 / 维护**
|
|
177
|
+
|
|
178
|
+
| 命令 | 作用 | 参数 |
|
|
179
|
+
| --- | --- | --- |
|
|
180
|
+
| `retro` | 复盘:skill 候选 / Red Flag / 审批吞吐 | 选 `--module` `--json` |
|
|
181
|
+
| `export` | 导出 events/feedback 为 jsonl | — |
|
|
182
|
+
| `init` | 新项目引导 | `--endpoints`(必填);`--platforms` `--model` `--writehooks=false` `--preset=false` `--hooks=false` |
|
|
183
|
+
| `gen-agents` | 从模板重生成 agent 定义 | — |
|
|
184
|
+
| `register-meta` | 注册元产物(agent-def/skill/plan) | `--actor` |
|
|
185
|
+
| `install-hooks` | 安装 git hooks | — |
|
|
186
|
+
| `migrate` | 迁移旧库 | `--from=<路径>` |
|
|
187
|
+
|
|
188
|
+
> AI 侧优先用 MCP 的 `wb_*` typed tools(与 CLI 同源同事务);**审批 approve/reject 刻意不暴露给 AI——那是你的动作**。
|
|
189
|
+
|
|
190
|
+
## 配置(workbench.config.json)
|
|
191
|
+
|
|
192
|
+
```jsonc
|
|
193
|
+
{
|
|
194
|
+
"platforms": ["claude", "cursor"], // 目标平台(init 选),缺省 ["claude"]
|
|
195
|
+
"endpoints": ["service", "web"], // 你的端
|
|
196
|
+
"pipeline": ["product-manager", "architect", "designer", "developer", "qa"], // 角色流水线(不含的角色不派任务)
|
|
197
|
+
"codeRoots": { // 【必填】每端代码目录,{module} 占位
|
|
198
|
+
"service": ["service/src/modules/{module}"],
|
|
199
|
+
"web": ["web/src/pages/{module}"]
|
|
200
|
+
},
|
|
201
|
+
"moduleMapping": { "userProfile": "user" }, // 细模块归并到粗模块
|
|
202
|
+
"machineChecks": { "enabled": false, // developer complete 时跑
|
|
203
|
+
"service": ["cd service && npx tsc --noEmit"] },
|
|
204
|
+
"protocolLints": [ // 能机器查的约定 → 降级为 lint(违例阻断 complete)
|
|
205
|
+
{ "name": "no-page-size", "grep": "pageSize", "paths": ["service/src"] }
|
|
206
|
+
],
|
|
207
|
+
"gates": {
|
|
208
|
+
"approvalMode": "warn", // warn=未批只警告 / enforce=阻断
|
|
209
|
+
"writeGate": "observe" // off / observe(只记录)/ enforce(拦改 approved 契约)
|
|
210
|
+
},
|
|
211
|
+
"git": { "taskTrailer": "off", "trailerKey": "Task" } // on=提交注入 Task:#id 归因 trailer
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 可视化工作台
|
|
216
|
+
|
|
217
|
+
`npx -y @dawipong/opcflow serve` 起在 `http://127.0.0.1:5620`:artifact 树(状态实时变色)、markdown / mermaid / HTML 原型
|
|
218
|
+
iframe / 代码渲染、**待审队列 diff**(approved 版本 vs 当前)、事件时间线、SSE 实时刷新。审批、打回、
|
|
219
|
+
给原型 👍👎 都在这里点。
|
|
220
|
+
|
|
221
|
+
## 脚本
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pnpm start # 启动工作台(build 前端 + 起 server;首次用它)
|
|
225
|
+
pnpm run serve # 只起 server,不 build 前端(web/dist 未生成会 404)
|
|
226
|
+
pnpm run web:build # 构建前端
|
|
227
|
+
pnpm test # core 单元测试
|
|
228
|
+
pnpm run typecheck # 类型检查
|
|
229
|
+
pnpm run check:isolation # 零业务耦合校验
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## 技术栈
|
|
233
|
+
|
|
234
|
+
TypeScript · better-sqlite3 · Fastify · React 18 + antd 6 · Monaco · mermaid ·
|
|
235
|
+
@modelcontextprotocol/sdk · smol-toml · tsx。运行时 Node ≥ 22。
|
|
236
|
+
|
|
237
|
+
## 许可
|
|
238
|
+
|
|
239
|
+
[MIT](LICENSE)
|