@dawipong/opcflow 0.2.0 → 0.2.1

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/README.en.md CHANGED
@@ -141,94 +141,30 @@ never silently deviate.
141
141
  > `docs/design/prototypes/<endpoint>/<module>/<page>.html` — once `scan` registers it, it goes through
142
142
  > the usual 👍 release. Both paths are equivalent in the system; both must pass a user 👍.
143
143
 
144
- ## CLI Commands & Parameters
144
+ ## CLI Commands
145
145
 
146
- Every command: `opcflow <command> [args]` (after global install; or `npx -y @dawipong/opcflow <command>` without installing). Global `--project=<path>` sets the project
147
- root (otherwise it searches upward for `workbench.config.json`). File-path arguments are separated with
148
- `--` (e.g. `submit --actor=x -- <path>`).
146
+ `opcflow <command> [args]` (after a global install; or `npx -y @dawipong/opcflow <command>` without installing). Approval actions (approve/reject) are human-only; the AI uses the MCP `wb_*` typed tools.
149
147
 
150
- **Tasks**
148
+ **Each command's purpose, when to use it, and parameters are in [COMMANDS.en.md](COMMANDS.en.md).** At a glance:
151
149
 
152
- | Command | Purpose | Parameters |
153
- | --- | --- | --- |
154
- | `list` | list tasks | `--status` `--assignee` `--module` `--role` `--endpoint` `--type` `--stale=true` |
155
- | `show <id>` | task detail (events / outputs / stale) | `--json=true` |
156
- | `create` | create a task | required `--role` `--creator`; opt `--module` `--endpoint` `--page` `--type` `--assignee` `--content` |
157
- | `claim <id>` | claim (passes the gate, auto-snapshots deps) | `--assignee=<role>` |
158
- | `update <id>` | change status | `--status` `--operator`; `--force=true` bypasses the stale block (traced) |
159
- | `remove <id>` | delete a task | `--operator`; `--force=true` |
160
- | `record <id> "note"` | add a note | `--operator` |
161
- | `input <id> -- <path>` | declare a dependency read outside the gate | `--operator` |
162
-
163
- **Outputs**
164
-
165
- | Command | Purpose | Parameters |
166
- | --- | --- | --- |
167
- | `output -- <path>` | register an output (auto-links your claimed task) | required `--role` `--endpoint`; opt `--module` `--page` `--task` |
168
- | `artifacts` | list artifacts | `--module` `--endpoint` `--page` `--kind` |
169
- | `scan` | full scan & register (docs + codeRoots), derive DAG edges | `--actor` |
170
- | `move --from=<> --to=<>` | move an artifact (keeps id, keeps approval) | `--actor` |
171
-
172
- **Trust**
173
-
174
- | Command | Purpose | Parameters |
175
- | --- | --- | --- |
176
- | `submit -- <path>` | submit for review | `--actor` |
177
- | `approve -- <path>` | approve | `--actor`; `--trivial=true` for tweaks: re-bless downstream + close derived reviews |
178
- | `reject -- <path>` | reject | `--actor` `--reason` |
179
- | `feedback -- <path>` | feedback / 👍👎 (release prototype) | `--actor` `--verdict=+1\|-1`; opt `--comment` `--task` |
180
- | `dispute -- <path>` | trace an objection to approved content and stop for a ruling | `--actor` `--reason` |
181
- | `queue` | review queue (pending + invalidated) | — |
182
- | `sync` | reconcile: invalidation propagation + dispatch review | `--actor` |
183
-
184
- **Flow**
185
-
186
- | Command | Purpose | Parameters |
187
- | --- | --- | --- |
188
- | `plan` | dispatch downstream tasks once contracts are approved | `--module`; opt `--creator` |
189
- | `qa <id>` | record acceptance result (fail auto-dispatches rework) | `--result=pass\|fail` `--operator`; fail needs `--reason` |
190
- | `audit` | module contract reconciliation report (settlement status) | `--module` |
191
- | `graph` | emit a Mermaid dependency graph | `--module` |
192
- | `lint` | run protocol lints | opt `--role` `--endpoint` |
193
- | `events` | event stream | `--taskId`/`<id>` `--module` `--event` `--limit` `--json` |
194
- | `intake` | pull GitHub issues into the queue (standard lane / hotfix) | — |
195
-
196
- **Evolution / Maintenance**
197
-
198
- | Command | Purpose | Parameters |
199
- | --- | --- | --- |
200
- | `retro` | retrospective: skill candidates / Red Flags / approval throughput | opt `--module` `--json` |
201
- | `export` | export events/feedback as jsonl | — |
202
- | `init` | bootstrap a new project | `--endpoints` (required); `--platforms` `--model` `--writehooks=false` `--preset=false` `--hooks=false` |
203
- | `gen-agents` | regenerate agent definitions from templates | — |
204
- | `register-meta` | register meta artifacts (agent-def/skill/plan) | `--actor` |
205
- | `install-hooks` | install git hooks | — |
206
- | `migrate` | migrate a legacy DB | `--from=<path>` |
207
-
208
- > 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.**
150
+ - **Tasks** `list` · `show` · `create` · `claim` · `update` · `remove` · `record` · `input`
151
+ - **Outputs** `output` · `artifacts` · `scan` · `move`
152
+ - **Trust** `submit` · `approve` · `reject` · `feedback` · `dispute` · `queue` · `sync`
153
+ - **Flow** `plan` · `qa` · `audit` · `graph` · `lint` · `events` · `intake`
154
+ - **Evolution / Maintenance** `retro` · `export` · `init` · `gen-agents` · `register-meta` · `install-hooks` · `migrate`
155
+ - **Service & Integration** `serve` · `mcp` · `hook` · `postcommit` (mostly auto-invoked by platform / git)
209
156
 
210
157
  ## Configuration (workbench.config.json)
211
158
 
159
+ Generated by `init`, hand-edited afterwards — each project's coordinate system and discipline switches. **Every field's purpose, default, and when to tune it is in [CONFIG.en.md](CONFIG.en.md).**
160
+
212
161
  ```jsonc
213
162
  {
214
- "platforms": ["claude", "cursor"], // target platforms (picked by init), default ["claude"]
163
+ "platforms": ["claude", "cursor"], // target platforms
215
164
  "endpoints": ["service", "web"], // your endpoints
216
- "pipeline": ["product-manager", "architect", "designer", "developer", "qa"], // role pipeline (excluded roles get no tasks)
217
- "codeRoots": { // [required] code dir per endpoint, {module} placeholder
218
- "service": ["service/src/modules/{module}"],
219
- "web": ["web/src/pages/{module}"]
220
- },
221
- "moduleMapping": { "userProfile": "user" }, // merge fine modules into coarse ones
222
- "machineChecks": { "enabled": false, // run on developer complete
223
- "service": ["cd service && npx tsc --noEmit"] },
224
- "protocolLints": [ // machine-checkable conventions → lints (violations block complete)
225
- { "name": "no-page-size", "grep": "pageSize", "paths": ["service/src"] }
226
- ],
227
- "gates": {
228
- "approvalMode": "warn", // warn = unreviewed only warns / enforce = blocks
229
- "writeGate": "observe" // off / observe (log only) / enforce (block edits to approved contracts)
230
- },
231
- "git": { "taskTrailer": "off", "trailerKey": "Task" } // on = inject a Task:#id attribution trailer on commit
165
+ "pipeline": ["product-manager", "architect", "designer", "developer", "qa"],
166
+ "codeRoots": { "service": ["service/src/modules/{module}"] }, // [required] code dir per endpoint, {module} placeholder
167
+ "gates": { "approvalMode": "warn", "writeGate": "observe" } // approval / write-gate discipline levels
232
168
  }
233
169
  ```
234
170
 
package/README.md CHANGED
@@ -129,93 +129,30 @@ flowchart LR
129
129
  > `docs/design/prototypes/<端>/<模块>/<页面>.html`,`scan` 登记后照常走 👍 放行——两条路径产出的原型
130
130
  > 在体系里等价,都要过用户 👍。
131
131
 
132
- ## CLI 命令参数
132
+ ## CLI 命令
133
133
 
134
- 所有命令:`opcflow <命令> [参数]`(全局装后即用;或 `npx -y @dawipong/opcflow <命令>` 免装)。全局 `--project=<路径>` 指定项目根(缺省向上找
135
- `workbench.config.json`)。文件路径参数用 `--` 分隔(如 `submit --actor=x -- <路径>`)。
134
+ `opcflow <命令> [参数]`(全局装后即用;或 `npx -y @dawipong/opcflow <命令>` 免装)。审批类动作(approve/reject)只给人,AI 侧走 MCP 的 `wb_*` typed tools。
136
135
 
137
- **任务**
136
+ **每条命令的作用、使用场景与参数见 [COMMANDS.md](COMMANDS.md)。** 速览:
138
137
 
139
- | 命令 | 作用 | 参数 |
140
- | --- | --- | --- |
141
- | `list` | 列任务 | `--status` `--assignee` `--module` `--role` `--endpoint` `--type` `--stale=true` |
142
- | `show <id>` | 任务详情(含事件/产出/stale) | `--json=true` |
143
- | `create` | 建任务 | 必填 `--role` `--creator`;选 `--module` `--endpoint` `--page` `--type` `--assignee` `--content` |
144
- | `claim <id>` | 领取( gate,自动快照依赖) | `--assignee=<角色>` |
145
- | `update <id>` | 改状态 | `--status` `--operator`;`--force=true` 越过 stale 拦截(留痕) |
146
- | `remove <id>` | 删任务 | `--operator`;`--force=true` |
147
- | `record <id> "备注"` | 加备注 | `--operator` |
148
- | `input <id> -- <路径>` | 补充申报 gate 之外读过的依赖 | `--operator` |
149
-
150
- **产出**
151
-
152
- | 命令 | 作用 | 参数 |
153
- | --- | --- | --- |
154
- | `output -- <路径>` | 登记产物(自动关联你领取的任务) | 必填 `--role` `--endpoint`;选 `--module` `--page` `--task` |
155
- | `artifacts` | 列产物 | `--module` `--endpoint` `--page` `--kind` |
156
- | `scan` | 全量扫描登记(docs + codeRoots),推导 DAG 边 | `--actor` |
157
- | `move --from=<> --to=<>` | 移动产物(保 id、不断审批) | `--actor` |
158
-
159
- **信任**
160
-
161
- | 命令 | 作用 | 参数 |
162
- | --- | --- | --- |
163
- | `submit -- <路径>` | 送审 | `--actor` |
164
- | `approve -- <路径>` | 批准 | `--actor`;`--trivial=true` 微调:re-bless 下游 + 关派生 review |
165
- | `reject -- <路径>` | 打回 | `--actor` `--reason` |
166
- | `feedback -- <路径>` | 反馈 / 👍👎(原型放行) | `--actor` `--verdict=+1\|-1`;选 `--comment` `--task` |
167
- | `dispute -- <路径>` | 对 approved 内容留痕异议,停下等裁决 | `--actor` `--reason` |
168
- | `queue` | 待审队列(pending + invalidated) | — |
169
- | `sync` | 对账:失效传播 + 沿图派 review | `--actor` |
170
-
171
- **流程**
172
-
173
- | 命令 | 作用 | 参数 |
174
- | --- | --- | --- |
175
- | `plan` | 契约全批后一键派发下游任务 | `--module`;选 `--creator` |
176
- | `qa <id>` | 记验收结果(fail 自动派 rework) | `--result=pass\|fail` `--operator`;fail 需 `--reason` |
177
- | `audit` | 模块契约对账报告(清算状态) | `--module` |
178
- | `graph` | 输出 Mermaid 依赖图 | `--module` |
179
- | `lint` | 跑协议 lint | 选 `--role` `--endpoint` |
180
- | `events` | 事件流 | `--taskId`/`<id>` `--module` `--event` `--limit` `--json` |
181
- | `intake` | 拉 GitHub issue 入队(标准道 / hotfix) | — |
182
-
183
- **进化 / 维护**
184
-
185
- | 命令 | 作用 | 参数 |
186
- | --- | --- | --- |
187
- | `retro` | 复盘:skill 候选 / Red Flag / 审批吞吐 | 选 `--module` `--json` |
188
- | `export` | 导出 events/feedback 为 jsonl | — |
189
- | `init` | 新项目引导 | `--endpoints`(必填);`--platforms` `--model` `--writehooks=false` `--preset=false` `--hooks=false` |
190
- | `gen-agents` | 从模板重生成 agent 定义 | — |
191
- | `register-meta` | 注册元产物(agent-def/skill/plan) | `--actor` |
192
- | `install-hooks` | 安装 git hooks | — |
193
- | `migrate` | 迁移旧库 | `--from=<路径>` |
194
-
195
- > AI 侧优先用 MCP 的 `wb_*` typed tools(与 CLI 同源同事务);**审批 approve/reject 刻意不暴露给 AI——那是你的动作**。
138
+ - **任务** `list` · `show` · `create` · `claim` · `update` · `remove` · `record` · `input`
139
+ - **产出** `output` · `artifacts` · `scan` · `move`
140
+ - **信任** `submit` · `approve` · `reject` · `feedback` · `dispute` · `queue` · `sync`
141
+ - **流程** `plan` · `qa` · `audit` · `graph` · `lint` · `events` · `intake`
142
+ - **进化 / 维护** `retro` · `export` · `init` · `gen-agents` · `register-meta` · `install-hooks` · `migrate`
143
+ - **服务与集成** `serve` · `mcp` · `hook` · `postcommit`(多由平台 / git 自动调用)
196
144
 
197
145
  ## 配置(workbench.config.json)
198
146
 
147
+ `init` 生成、之后手工编辑,是每个项目的坐标系与纪律开关。**每个字段的作用、默认值与何时调,见 [CONFIG.md](CONFIG.md)。**
148
+
199
149
  ```jsonc
200
150
  {
201
- "platforms": ["claude", "cursor"], // 目标平台(init 选),缺省 ["claude"]
151
+ "platforms": ["claude", "cursor"], // 目标平台
202
152
  "endpoints": ["service", "web"], // 你的端
203
- "pipeline": ["product-manager", "architect", "designer", "developer", "qa"], // 角色流水线(不含的角色不派任务)
204
- "codeRoots": { // 【必填】每端代码目录,{module} 占位
205
- "service": ["service/src/modules/{module}"],
206
- "web": ["web/src/pages/{module}"]
207
- },
208
- "moduleMapping": { "userProfile": "user" }, // 细模块归并到粗模块
209
- "machineChecks": { "enabled": false, // developer complete 时跑
210
- "service": ["cd service && npx tsc --noEmit"] },
211
- "protocolLints": [ // 能机器查的约定 → 降级为 lint(违例阻断 complete)
212
- { "name": "no-page-size", "grep": "pageSize", "paths": ["service/src"] }
213
- ],
214
- "gates": {
215
- "approvalMode": "warn", // warn=未批只警告 / enforce=阻断
216
- "writeGate": "observe" // off / observe(只记录)/ enforce(拦改 approved 契约)
217
- },
218
- "git": { "taskTrailer": "off", "trailerKey": "Task" } // on=提交注入 Task:#id 归因 trailer
153
+ "pipeline": ["product-manager", "architect", "designer", "developer", "qa"],
154
+ "codeRoots": { "service": ["service/src/modules/{module}"] }, // 【必填】每端代码目录,{module} 占位
155
+ "gates": { "approvalMode": "warn", "writeGate": "observe" } // 审批 / 写门禁纪律档位
219
156
  }
220
157
  ```
221
158
 
package/dist/cli.mjs CHANGED
@@ -2528,7 +2528,7 @@ function deriveEdges(ctx) {
2528
2528
  return created;
2529
2529
  }
2530
2530
  function scanArtifacts(ctx, actor = "system") {
2531
- const summary = { registered: 0, refreshed: 0, edges: 0, skipped: [] };
2531
+ const summary = { registered: 0, refreshed: 0, remapped: 0, edges: 0, skipped: [] };
2532
2532
  const files = [];
2533
2533
  for (const dir of Object.values(ctx.config.docs)) {
2534
2534
  const abs = join10(ctx.root, dir);
@@ -2537,7 +2537,12 @@ function scanArtifacts(ctx, actor = "system") {
2537
2537
  for (const p of ["ARCHITECTURE.md", "TECH.md"]) {
2538
2538
  if (existsSync9(join10(ctx.root, p))) files.push(p);
2539
2539
  }
2540
- const exists = ctx.db.prepare("SELECT id, content_hash FROM artifacts WHERE path = ?");
2540
+ const exists = ctx.db.prepare(
2541
+ "SELECT id, kind, module, endpoint, page, content_hash FROM artifacts WHERE path = ?"
2542
+ );
2543
+ const remap = ctx.db.prepare(
2544
+ "UPDATE artifacts SET kind = ?, module = ?, endpoint = ?, page = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?"
2545
+ );
2541
2546
  const insert = ctx.db.prepare(
2542
2547
  "INSERT INTO artifacts (kind, module, endpoint, page, path, content_hash) VALUES (?, ?, ?, ?, ?, ?)"
2543
2548
  );
@@ -2547,6 +2552,27 @@ function scanArtifacts(ctx, actor = "system") {
2547
2552
  const before = row.content_hash;
2548
2553
  const after = refreshArtifact(ctx, { id: row.id }, actor);
2549
2554
  if (after.content_hash !== before) summary.refreshed++;
2555
+ if (row.kind !== kind || row.module !== coords.module || row.endpoint !== coords.endpoint || row.page !== coords.page) {
2556
+ const tx2 = ctx.db.transaction(() => {
2557
+ remap.run(kind, coords.module, coords.endpoint, coords.page, row.id);
2558
+ logEvent(ctx.db, {
2559
+ entityType: "artifact",
2560
+ entityId: row.id,
2561
+ event: "coords_remapped",
2562
+ actor,
2563
+ payload: {
2564
+ path: relPath,
2565
+ from: { kind: row.kind, module: row.module, endpoint: row.endpoint, page: row.page },
2566
+ to: { kind, module: coords.module, endpoint: coords.endpoint, page: coords.page }
2567
+ },
2568
+ module: coords.module,
2569
+ endpoint: coords.endpoint,
2570
+ page: coords.page
2571
+ });
2572
+ });
2573
+ tx2();
2574
+ summary.remapped++;
2575
+ }
2550
2576
  return;
2551
2577
  }
2552
2578
  const hash = hashPath(join10(ctx.root, relPath));
@@ -4411,7 +4437,7 @@ async function runCommand(ctx, command, a) {
4411
4437
  }
4412
4438
  case "scan": {
4413
4439
  const s = scanArtifacts(ctx, a.actor || "system");
4414
- console.log(chalk.green(`\u2705 \u626B\u63CF\u5B8C\u6210:\u65B0\u767B\u8BB0 ${s.registered},\u5185\u5BB9\u5237\u65B0 ${s.refreshed},\u65B0\u589E\u8FB9 ${s.edges},\u6392\u9664\u5143\u4EA7\u7269 ${s.skipped.length}`));
4440
+ console.log(chalk.green(`\u2705 \u626B\u63CF\u5B8C\u6210:\u65B0\u767B\u8BB0 ${s.registered},\u5185\u5BB9\u5237\u65B0 ${s.refreshed},\u91CD\u6302\u5750\u6807 ${s.remapped},\u65B0\u589E\u8FB9 ${s.edges},\u6392\u9664\u5143\u4EA7\u7269 ${s.skipped.length}`));
4415
4441
  break;
4416
4442
  }
4417
4443
  case "move": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawipong/opcflow",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Spec-anchored, drift-enforced execution layer for AI coding agents — artifact DAG, trust gates, multi-role pipeline; generates agents/MCP/hooks for Claude Code, Codex, OpenCode & Cursor.",
5
5
  "license": "MIT",
6
6
  "author": "Dawi",