@dawipong/opcflow 0.6.0 → 0.7.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/dist/cli.mjs CHANGED
@@ -735,6 +735,7 @@ __export(kind_exports, {
735
735
  expandPattern: () => expandPattern,
736
736
  getKindRegistry: () => getKindRegistry,
737
737
  inferKind: () => inferKind,
738
+ kindPathTemplate: () => kindPathTemplate,
738
739
  kindSpec: () => kindSpec,
739
740
  normalizeModule: () => normalizeModule
740
741
  });
@@ -766,6 +767,14 @@ function contractKinds(config) {
766
767
  function expandPattern(pattern, config) {
767
768
  return pattern.replace("{prd}", config.docs.prd).replace("{architecture}", config.docs.architecture).replace("{design}", config.docs.design).replace("{acceptance}", config.docs.acceptance);
768
769
  }
770
+ function kindPathTemplate(config, kind, lang) {
771
+ const spec = getKindRegistry(config)[kind];
772
+ if (!spec?.coords || !spec.pathPatterns?.[0]) return null;
773
+ const prefix = expandPattern(spec.pathPatterns[0], config);
774
+ const ext = spec.ext ?? "md";
775
+ const segs = spec.coords.split("/").map((s) => lang === "zh" ? COORD_LABELS_ZH[s] ?? s : s);
776
+ return `${prefix}${segs.join("/")}.${ext}`;
777
+ }
769
778
  function inferKind(relPath, config) {
770
779
  const p = relPath.replace(/\\/g, "/");
771
780
  const registry = getKindRegistry(config);
@@ -783,7 +792,7 @@ function normalizeModule(module, config) {
783
792
  if (!module) return null;
784
793
  return config.moduleMapping[module] ?? module;
785
794
  }
786
- var DEFAULT_KIND_REGISTRY, META_KINDS, PM_KINDS, KIND_TIERS;
795
+ var DEFAULT_KIND_REGISTRY, META_KINDS, PM_KINDS, KIND_TIERS, COORD_LABELS_ZH;
787
796
  var init_kind = __esm({
788
797
  "core/kind.ts"() {
789
798
  "use strict";
@@ -805,7 +814,7 @@ var init_kind = __esm({
805
814
  "api-doc": { level: "module", approval: "human", parents: ["module-prd", "db-doc"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{architecture}/api/"], coords: "{module}", defaultEndpoint: "service" },
806
815
  "design-system": { level: "endpoint", approval: "human", parents: ["baseline"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{design}/systems/"], coords: "{endpoint}" },
807
816
  "design-prompt": { level: "page", approval: "none", parents: ["page-prd", "api-doc", "design-system"], drivesStale: false, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prompts/"], coords: "{endpoint}/{module}/{page}" },
808
- prototype: { level: "page", approval: "thumbs", parents: ["design-prompt", "design-system"], drivesStale: true, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prototypes/"], coords: "{endpoint}/{module}/{page}" },
817
+ prototype: { level: "page", approval: "thumbs", parents: ["design-prompt", "design-system"], drivesStale: true, hashMode: "text-normalize", retrieval: "summary", pathPatterns: ["{design}/prototypes/"], coords: "{endpoint}/{module}/{page}", ext: "html" },
809
818
  acceptance: { level: "page", approval: "human", parents: ["page-prd", "prototype"], drivesStale: true, hashMode: "text-normalize", retrieval: "full", pathPatterns: ["{acceptance}/"], coords: "{endpoint}/{module}/{page}" },
810
819
  code: { level: "module", approval: "machine", parents: ["baseline", "api-doc", "prototype"], drivesStale: false, hashMode: "directory", retrieval: "semantic" },
811
820
  doc: { level: "module", approval: "none", parents: [], drivesStale: false, hashMode: "text-normalize", retrieval: "summary" }
@@ -824,6 +833,7 @@ var init_kind = __esm({
824
833
  ["prototype", "acceptance"],
825
834
  ["code"]
826
835
  ];
836
+ COORD_LABELS_ZH = { "{module}": "{\u6A21\u5757}", "{endpoint}": "{\u7AEF}", "{page}": "{\u9875\u9762}" };
827
837
  }
828
838
  });
829
839
 
@@ -3178,6 +3188,16 @@ function genAgents(ctx, templatesDir) {
3178
3188
  PATH_DESIGN_PROMPTS: expandPath(ctx, "design-prompt"),
3179
3189
  PATH_PROTOTYPES: expandPath(ctx, "prototype"),
3180
3190
  PATH_ACCEPTANCE: expandPath(ctx, "acceptance"),
3191
+ // 路径投影:完整路径模板由 kind 注册表(前缀+coords 文法+ext)推导——
3192
+ // 项目覆盖 coords 后重跑 gen-agents,agent 指示与 scan 解析自动同步(单一真相源)
3193
+ TPL_FLOW: kindPathTemplate(ctx.config, "flow", lang) ?? "",
3194
+ TPL_MODULE_PRD: kindPathTemplate(ctx.config, "module-prd", lang) ?? "",
3195
+ TPL_PAGE_PRD: kindPathTemplate(ctx.config, "page-prd", lang) ?? "",
3196
+ TPL_DB_DOC: kindPathTemplate(ctx.config, "db-doc", lang) ?? "",
3197
+ TPL_DESIGN_SYSTEM: kindPathTemplate(ctx.config, "design-system", lang) ?? "",
3198
+ TPL_DESIGN_PROMPT: kindPathTemplate(ctx.config, "design-prompt", lang) ?? "",
3199
+ TPL_PROTOTYPE: kindPathTemplate(ctx.config, "prototype", lang) ?? "",
3200
+ TPL_ACCEPTANCE: kindPathTemplate(ctx.config, "acceptance", lang) ?? "",
3181
3201
  ENDPOINTS: ctx.config.endpoints.join(" / "),
3182
3202
  PIPELINE: ctx.config.pipeline.join(" \u2192 "),
3183
3203
  CODE_ROOTS: ctx.config.endpoints.map((e) => `| ${e} | ${(ctx.config.codeRoots[e] ?? []).join(blocks.sep) || blocks.todo} |`).join("\n")
@@ -3578,6 +3598,7 @@ __export(core_exports, {
3578
3598
  initProject: () => initProject,
3579
3599
  installGitHooks: () => installGitHooks,
3580
3600
  intakeIssues: () => intakeIssues,
3601
+ kindPathTemplate: () => kindPathTemplate,
3581
3602
  kindSpec: () => kindSpec,
3582
3603
  listArtifacts: () => listArtifacts,
3583
3604
  listEvents: () => listEvents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawipong/opcflow",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
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",
@@ -29,7 +29,7 @@ tech selection (language / framework / ORM / build), directory structure per end
29
29
  | Artifact | Path |
30
30
  | --- | --- |
31
31
  | Database model definition | Per approved TECH.md conventions (path/tech set by the baseline) |
32
- | Database docs | {{PATH_DB_DOCS}}{module}.md |
32
+ | Database docs | {{TPL_DB_DOC}} |
33
33
  | API contract docs | {{PATH_API_DOCS}}{endpoint}/{module}.md (cross-endpoint shared goes in common/) |
34
34
  | Technical baseline (changes go through review) | ARCHITECTURE.md / TECH.md |
35
35
 
@@ -21,9 +21,9 @@ You are @designer. Each of your three artifacts travels a different trust channe
21
21
 
22
22
  | Artifact | Path | Trust channel |
23
23
  | --- | --- | --- |
24
- | Design system (one per endpoint) | {{PATH_DESIGN_SYSTEMS}}{endpoint}.md | **Human approval** (endpoint-level contract; one change makes every prototype for that endpoint stale) |
25
- | Page design prompt | {{PATH_DESIGN_PROMPTS}}{endpoint}/{module}/{page}.md | Register only (working draft, not submitted) |
26
- | HTML prototype | {{PATH_PROTOTYPES}}{endpoint}/{module}/{page}.html | **👍 = feedback + approval in one** (user releases after previewing in opcflow) |
24
+ | Design system (one per endpoint) | {{TPL_DESIGN_SYSTEM}} | **Human approval** (endpoint-level contract; one change makes every prototype for that endpoint stale) |
25
+ | Page design prompt | {{TPL_DESIGN_PROMPT}} | Register only (working draft, not submitted) |
26
+ | HTML prototype | {{TPL_PROTOTYPE}} | **👍 = feedback + approval in one** (user releases after previewing in opcflow) |
27
27
 
28
28
  ## Workflow (page task)
29
29
 
@@ -37,7 +37,7 @@ You are @designer. Each of your three artifacts travels a different trust channe
37
37
 
38
38
  ## Endpoint Design-System Task (once per endpoint)
39
39
 
40
- Write to {{PATH_DESIGN_SYSTEMS}}{endpoint}.md (palette / spacing / font sizes / component forms / **that endpoint's hard constraints** — platform limits, component-library specs, etc. are all legislated here) → register → **submit for review**.
40
+ Write to {{TPL_DESIGN_SYSTEM}} (palette / spacing / font sizes / component forms / **that endpoint's hard constraints** — platform limits, component-library specs, etc. are all legislated here) → register → **submit for review**.
41
41
  For endpoints that already have prototypes or production pages, **reverse-engineer** from the established facts (legislate, don't design from scratch); for a brand-new endpoint, propose an initial version from the approved baseline (the UI stack in TECH.md) and the project's positioning.
42
42
 
43
43
  ## Red Flags
@@ -22,10 +22,10 @@ You are @developer. **Approved contract = implement directly, zero divergence**
22
22
  | Input | Path |
23
23
  | --- | --- |
24
24
  | Technical baseline (selection/directories/protocol conventions) | ARCHITECTURE.md / TECH.md |
25
- | Page PRD (incl. acceptance points) | {{PATH_PAGES}}{endpoint}/{module}/{page}.md |
25
+ | Page PRD (incl. acceptance points) | {{TPL_PAGE_PRD}} |
26
26
  | API contract | {{PATH_API_DOCS}}{endpoint}/{module}.md |
27
- | DB docs | {{PATH_DB_DOCS}}{module}.md |
28
- | 👍-approved prototype (UI truth) | {{PATH_PROTOTYPES}}{endpoint}/{module}/{page}.html |
27
+ | DB docs | {{TPL_DB_DOC}} |
28
+ | 👍-approved prototype (UI truth) | {{TPL_PROTOTYPE}} |
29
29
 
30
30
  ## Code Directory Conventions (config-injected; follow when building code)
31
31
 
@@ -25,9 +25,9 @@ You are @product-manager. Responsibility: translate requirements into **layer-by
25
25
  | Project overview | {{PATH_PROJECT}} | Project-level contract |
26
26
  | Role permission matrix | {{PATH_ROLES}} | Project-level contract |
27
27
  | Domain glossary | {{PATH_GLOSSARY}} | Project-level contract |
28
- | Business flow + entity state machine | {{PATH_FLOWS}}{module}.md | Module-level contract |
29
- | Module PRD | {{PATH_MODULES}}{module}.md | Module-level contract |
30
- | Page PRD | {{PATH_PAGES}}{endpoint}/{module}/{page}.md | Page-level contract |
28
+ | Business flow + entity state machine | {{TPL_FLOW}} | Module-level contract |
29
+ | Module PRD | {{TPL_MODULE_PRD}} | Module-level contract |
30
+ | Page PRD | {{TPL_PAGE_PRD}} | Page-level contract |
31
31
 
32
32
  ## Core Discipline: Layer-by-Layer Confirmation
33
33
 
@@ -20,7 +20,7 @@ You are @qa. **Judgment authority belongs to PM (acceptance points), execution a
20
20
  ## Two-Phase Acceptance
21
21
 
22
22
  **Phase one (before or after developer starts): translate acceptance criteria**
23
- Read the "acceptance points" section of the approved page PRD → translate into executable cases, write to {{PATH_ACCEPTANCE}}{endpoint}/{module}/{page}.md → register output → **submit for review** (it's a contract; developer writes against it).
23
+ Read the "acceptance points" section of the approved page PRD → translate into executable cases, write to {{TPL_ACCEPTANCE}} → register output → **submit for review** (it's a contract; developer writes against it).
24
24
  When a point is ambiguous: **dispute or send back to PM**, do not fill in the wording yourself.
25
25
 
26
26
  **Phase two (after developer finishes): execute acceptance**
@@ -29,7 +29,7 @@ tools: Read, Write, Edit, Glob, Grep, Bash
29
29
  | 产物 | 路径 |
30
30
  | --- | --- |
31
31
  | 数据库模型定义 | 按 approved TECH.md 的约定(路径/技术随基线定) |
32
- | 数据库文档 | {{PATH_DB_DOCS}}{模块}.md |
32
+ | 数据库文档 | {{TPL_DB_DOC}} |
33
33
  | API 契约文档 | {{PATH_API_DOCS}}{端}/{模块}.md(跨端共用放 common/) |
34
34
  | 技术基线(变更走审批) | ARCHITECTURE.md / TECH.md |
35
35
 
@@ -21,9 +21,9 @@ tools: Read, Write, Edit, Glob, Grep, Bash
21
21
 
22
22
  | 产物 | 路径 | 信任通道 |
23
23
  | --- | --- | --- |
24
- | 设计系统(每端一份) | {{PATH_DESIGN_SYSTEMS}}{端}.md | **人工审批**(端级契约,改一次全端原型 stale) |
25
- | 页面设计提示词 | {{PATH_DESIGN_PROMPTS}}{端}/{模块}/{页面}.md | 仅登记(工作底稿,不送审) |
26
- | HTML 原型 | {{PATH_PROTOTYPES}}{端}/{模块}/{页面}.html | **👍 = 反馈+审批合一**(用户在 opcflow 预览后放行) |
24
+ | 设计系统(每端一份) | {{TPL_DESIGN_SYSTEM}} | **人工审批**(端级契约,改一次全端原型 stale) |
25
+ | 页面设计提示词 | {{TPL_DESIGN_PROMPT}} | 仅登记(工作底稿,不送审) |
26
+ | HTML 原型 | {{TPL_PROTOTYPE}} | **👍 = 反馈+审批合一**(用户在 opcflow 预览后放行) |
27
27
 
28
28
  ## 工作流程(页面任务)
29
29
 
@@ -37,7 +37,7 @@ tools: Read, Write, Edit, Glob, Grep, Bash
37
37
 
38
38
  ## 端设计系统任务(每端一次)
39
39
 
40
- 写入 {{PATH_DESIGN_SYSTEMS}}{端}.md(色板/间距/字号/组件形态/**该端硬约束**——平台限制、组件库规范等都在此立法)→ 登记 → **submit 送审**。
40
+ 写入 {{TPL_DESIGN_SYSTEM}}(色板/间距/字号/组件形态/**该端硬约束**——平台限制、组件库规范等都在此立法)→ 登记 → **submit 送审**。
41
41
  已有原型或生产页面的端,从既成事实**反向提炼**(立法,不凭空设计);全新的端,依据 approved 基线(TECH.md 的 UI 栈)与项目定位提出初版。
42
42
 
43
43
  ## Red Flags
@@ -22,10 +22,10 @@ tools: Read, Write, Edit, Glob, Grep, Bash
22
22
  | 输入 | 路径 |
23
23
  | --- | --- |
24
24
  | 技术基线(选型/目录/协议约定) | ARCHITECTURE.md / TECH.md |
25
- | 页面 PRD(含验收要点) | {{PATH_PAGES}}{端}/{模块}/{页面}.md |
25
+ | 页面 PRD(含验收要点) | {{TPL_PAGE_PRD}} |
26
26
  | API 契约 | {{PATH_API_DOCS}}{端}/{模块}.md |
27
- | DB 文档 | {{PATH_DB_DOCS}}{模块}.md |
28
- | 已 👍 原型(UI 真相) | {{PATH_PROTOTYPES}}{端}/{模块}/{页面}.html |
27
+ | DB 文档 | {{TPL_DB_DOC}} |
28
+ | 已 👍 原型(UI 真相) | {{TPL_PROTOTYPE}} |
29
29
 
30
30
  ## 代码目录约定(config 注入,建代码时遵守)
31
31
 
@@ -25,9 +25,9 @@ tools: Read, Write, Edit, Glob, Grep, Bash
25
25
  | 项目全景 | {{PATH_PROJECT}} | 项目级契约 |
26
26
  | 角色权限矩阵 | {{PATH_ROLES}} | 项目级契约 |
27
27
  | 领域术语表 | {{PATH_GLOSSARY}} | 项目级契约 |
28
- | 业务流程+实体状态机 | {{PATH_FLOWS}}{模块}.md | 模块级契约 |
29
- | 模块 PRD | {{PATH_MODULES}}{模块}.md | 模块级契约 |
30
- | 页面 PRD | {{PATH_PAGES}}{端}/{模块}/{页面}.md | 页面级契约 |
28
+ | 业务流程+实体状态机 | {{TPL_FLOW}} | 模块级契约 |
29
+ | 模块 PRD | {{TPL_MODULE_PRD}} | 模块级契约 |
30
+ | 页面 PRD | {{TPL_PAGE_PRD}} | 页面级契约 |
31
31
 
32
32
  ## 核心纪律:逐层确认制
33
33
 
@@ -20,7 +20,7 @@ tools: Read, Write, Edit, Glob, Grep, Bash
20
20
  ## 两段式验收
21
21
 
22
22
  **第一段(developer 开工前后皆可):翻译验收标准**
23
- 读 approved 页面 PRD 的"验收要点"章节 → 翻译成可执行用例,写入 {{PATH_ACCEPTANCE}}{端}/{模块}/{页面}.md → output 登记 → **submit 送审**(它是契约,developer 对着它写)。
23
+ 读 approved 页面 PRD 的"验收要点"章节 → 翻译成可执行用例,写入 {{TPL_ACCEPTANCE}} → output 登记 → **submit 送审**(它是契约,developer 对着它写)。
24
24
  遇到要点含混:**dispute 或退回 PM**,禁止自行脑补口径。
25
25
 
26
26
  **第二段(developer 完成后):执行验收**