create-yss-spec 3.3.4 → 3.3.7
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.md +2 -2
- package/package.json +1 -1
- package/src/template/instance-runtime.js +8 -2
- package/src/validation/snapshot.js +7 -0
- package/template/.agents/skills/.strategic-design-skills-manifest.json +7 -5
- package/template/.agents/skills/archify/SKILL.md +1 -1
- package/template/.agents/skills/code-review/SKILL.md +6 -0
- package/template/.agents/skills/i-have-adhd/LICENSE +21 -0
- package/template/.agents/skills/i-have-adhd/SKILL.md +26 -0
- package/template/.agents/skills/i-have-adhd/agents/openai.yaml +6 -0
- package/template/.agents/skills/i-have-adhd/references/yss-adaptation.md +21 -0
- package/template/.agents/skills/i-have-adhd/tests/verify-integration.mjs +63 -0
- package/template/.agents/skills/prototype-review/SKILL.md +2 -0
- package/template/.agents/skills/yss-implementation-contract-compiler/SKILL.md +6 -0
- package/template/.agents/skills/yss-implementation-contract-compiler/references/boundaries.md +10 -0
- package/template/.agents/skills/yss-openapi-governance/SKILL.md +6 -0
- package/template/.agents/skills/yss-product-lifecycle/SKILL.md +3 -1
- package/template/.agents/skills/yss-product-lifecycle/references/orchestration-contract.yaml +12 -0
- package/template/.agents/skills/yss-prototype-stage/SKILL.md +6 -0
- package/template/.agents/skills/yss-research/SKILL.md +6 -0
- package/template/.agents/skills/yss-stage-decision/SKILL.md +19 -4
- package/template/.agents/skills/yss-stage-decision/references/domain-strategy-contract.md +4 -3
- package/template/.agents/skills/yss-stage-decision/references/domain-strategy-v2.schema.json +8 -0
- package/template/.agents/skills/yss-stage-decision/references/domain-strategy-v3.schema.json +8 -0
- package/template/.agents/skills/yss-stage-decision/references/domain-strategy.schema.json +75 -5
- package/template/.agents/skills/yss-stage-decision/references/stage-decision-package-contract.md +4 -4
- package/template/.agents/skills/yss-stage-decision/references/stage-decision-package-v2.schema.json +8 -0
- package/template/.agents/skills/yss-stage-decision/references/stage-decision-package-v3.schema.json +8 -0
- package/template/.agents/skills/yss-stage-decision/references/stage-decision-package.schema.json +59 -9
- package/template/.agents/skills/yss-stage-decision/references/validation-rules.md +2 -2
- package/template/.agents/skills/yss-stage-decision/scripts/migrate-contract-v3.mjs +143 -0
- package/template/.agents/skills/yss-stage-decision/scripts/validate-domain-strategy.mjs +46 -4
- package/template/.agents/skills/yss-stage-decision/scripts/validate-stage-decision-package.mjs +48 -4
- package/template/.agents/skills/yss-stage-decision/tests/fixtures/valid-stage-decision-package.yaml +42 -13
- package/template/.agents/skills/yss-stage-decision/tests/fixtures/valid-supplier-domain.yaml +37 -5
- package/template/.agents/skills/yss-stage-decision/tests/run-scenarios.mjs +116 -23
- package/template/.agents/skills/yss-technical-design/SKILL.md +6 -0
- package/template/.codex/skills/archify/SKILL.md +1 -1
- package/template/.codex/skills/code-review/SKILL.md +6 -0
- package/template/.codex/skills/i-have-adhd/LICENSE +21 -0
- package/template/.codex/skills/i-have-adhd/SKILL.md +26 -0
- package/template/.codex/skills/i-have-adhd/agents/openai.yaml +6 -0
- package/template/.codex/skills/i-have-adhd/references/yss-adaptation.md +21 -0
- package/template/.codex/skills/i-have-adhd/tests/verify-integration.mjs +63 -0
- package/template/.codex/skills/prototype-review/SKILL.md +2 -0
- package/template/.codex/skills/yss-implementation-contract-compiler/SKILL.md +6 -0
- package/template/.codex/skills/yss-implementation-contract-compiler/references/boundaries.md +10 -0
- package/template/.codex/skills/yss-openapi-governance/SKILL.md +6 -0
- package/template/.codex/skills/yss-product-lifecycle/SKILL.md +3 -1
- package/template/.codex/skills/yss-product-lifecycle/references/orchestration-contract.yaml +12 -0
- package/template/.codex/skills/yss-prototype-stage/SKILL.md +6 -0
- package/template/.codex/skills/yss-research/SKILL.md +6 -0
- package/template/.codex/skills/yss-stage-decision/SKILL.md +19 -4
- package/template/.codex/skills/yss-stage-decision/references/domain-strategy-contract.md +4 -3
- package/template/.codex/skills/yss-stage-decision/references/domain-strategy-v2.schema.json +8 -0
- package/template/.codex/skills/yss-stage-decision/references/domain-strategy-v3.schema.json +8 -0
- package/template/.codex/skills/yss-stage-decision/references/domain-strategy.schema.json +75 -5
- package/template/.codex/skills/yss-stage-decision/references/stage-decision-package-contract.md +4 -4
- package/template/.codex/skills/yss-stage-decision/references/stage-decision-package-v2.schema.json +8 -0
- package/template/.codex/skills/yss-stage-decision/references/stage-decision-package-v3.schema.json +8 -0
- package/template/.codex/skills/yss-stage-decision/references/stage-decision-package.schema.json +59 -9
- package/template/.codex/skills/yss-stage-decision/references/validation-rules.md +2 -2
- package/template/.codex/skills/yss-stage-decision/scripts/migrate-contract-v3.mjs +143 -0
- package/template/.codex/skills/yss-stage-decision/scripts/validate-domain-strategy.mjs +46 -4
- package/template/.codex/skills/yss-stage-decision/scripts/validate-stage-decision-package.mjs +48 -4
- package/template/.codex/skills/yss-stage-decision/tests/fixtures/valid-stage-decision-package.yaml +42 -13
- package/template/.codex/skills/yss-stage-decision/tests/fixtures/valid-supplier-domain.yaml +37 -5
- package/template/.codex/skills/yss-stage-decision/tests/run-scenarios.mjs +116 -23
- package/template/.codex/skills/yss-technical-design/SKILL.md +6 -0
- package/template/.cursor/skills/archify/SKILL.md +1 -1
- package/template/.cursor/skills/code-review/SKILL.md +6 -0
- package/template/.cursor/skills/i-have-adhd/LICENSE +21 -0
- package/template/.cursor/skills/i-have-adhd/SKILL.md +26 -0
- package/template/.cursor/skills/i-have-adhd/agents/openai.yaml +6 -0
- package/template/.cursor/skills/i-have-adhd/references/yss-adaptation.md +21 -0
- package/template/.cursor/skills/i-have-adhd/tests/verify-integration.mjs +63 -0
- package/template/.cursor/skills/prototype-review/SKILL.md +2 -0
- package/template/.cursor/skills/yss-implementation-contract-compiler/SKILL.md +6 -0
- package/template/.cursor/skills/yss-implementation-contract-compiler/references/boundaries.md +10 -0
- package/template/.cursor/skills/yss-openapi-governance/SKILL.md +6 -0
- package/template/.cursor/skills/yss-product-lifecycle/SKILL.md +3 -1
- package/template/.cursor/skills/yss-product-lifecycle/references/orchestration-contract.yaml +12 -0
- package/template/.cursor/skills/yss-prototype-stage/SKILL.md +6 -0
- package/template/.cursor/skills/yss-research/SKILL.md +6 -0
- package/template/.cursor/skills/yss-stage-decision/SKILL.md +19 -4
- package/template/.cursor/skills/yss-stage-decision/references/domain-strategy-contract.md +4 -3
- package/template/.cursor/skills/yss-stage-decision/references/domain-strategy-v2.schema.json +8 -0
- package/template/.cursor/skills/yss-stage-decision/references/domain-strategy-v3.schema.json +8 -0
- package/template/.cursor/skills/yss-stage-decision/references/domain-strategy.schema.json +75 -5
- package/template/.cursor/skills/yss-stage-decision/references/stage-decision-package-contract.md +4 -4
- package/template/.cursor/skills/yss-stage-decision/references/stage-decision-package-v2.schema.json +8 -0
- package/template/.cursor/skills/yss-stage-decision/references/stage-decision-package-v3.schema.json +8 -0
- package/template/.cursor/skills/yss-stage-decision/references/stage-decision-package.schema.json +59 -9
- package/template/.cursor/skills/yss-stage-decision/references/validation-rules.md +2 -2
- package/template/.cursor/skills/yss-stage-decision/scripts/migrate-contract-v3.mjs +143 -0
- package/template/.cursor/skills/yss-stage-decision/scripts/validate-domain-strategy.mjs +46 -4
- package/template/.cursor/skills/yss-stage-decision/scripts/validate-stage-decision-package.mjs +48 -4
- package/template/.cursor/skills/yss-stage-decision/tests/fixtures/valid-stage-decision-package.yaml +42 -13
- package/template/.cursor/skills/yss-stage-decision/tests/fixtures/valid-supplier-domain.yaml +37 -5
- package/template/.cursor/skills/yss-stage-decision/tests/run-scenarios.mjs +116 -23
- package/template/.cursor/skills/yss-technical-design/SKILL.md +6 -0
- package/template/.pi/skills/archify/SKILL.md +1 -1
- package/template/.pi/skills/code-review/SKILL.md +6 -0
- package/template/.pi/skills/i-have-adhd/LICENSE +21 -0
- package/template/.pi/skills/i-have-adhd/SKILL.md +26 -0
- package/template/.pi/skills/i-have-adhd/agents/openai.yaml +6 -0
- package/template/.pi/skills/i-have-adhd/references/yss-adaptation.md +21 -0
- package/template/.pi/skills/i-have-adhd/tests/verify-integration.mjs +63 -0
- package/template/.pi/skills/prototype-review/SKILL.md +2 -0
- package/template/.pi/skills/yss-implementation-contract-compiler/SKILL.md +6 -0
- package/template/.pi/skills/yss-implementation-contract-compiler/references/boundaries.md +10 -0
- package/template/.pi/skills/yss-openapi-governance/SKILL.md +6 -0
- package/template/.pi/skills/yss-product-lifecycle/SKILL.md +3 -1
- package/template/.pi/skills/yss-product-lifecycle/references/orchestration-contract.yaml +12 -0
- package/template/.pi/skills/yss-prototype-stage/SKILL.md +6 -0
- package/template/.pi/skills/yss-research/SKILL.md +6 -0
- package/template/.pi/skills/yss-stage-decision/SKILL.md +19 -4
- package/template/.pi/skills/yss-stage-decision/references/domain-strategy-contract.md +4 -3
- package/template/.pi/skills/yss-stage-decision/references/domain-strategy-v2.schema.json +8 -0
- package/template/.pi/skills/yss-stage-decision/references/domain-strategy-v3.schema.json +8 -0
- package/template/.pi/skills/yss-stage-decision/references/domain-strategy.schema.json +75 -5
- package/template/.pi/skills/yss-stage-decision/references/stage-decision-package-contract.md +4 -4
- package/template/.pi/skills/yss-stage-decision/references/stage-decision-package-v2.schema.json +8 -0
- package/template/.pi/skills/yss-stage-decision/references/stage-decision-package-v3.schema.json +8 -0
- package/template/.pi/skills/yss-stage-decision/references/stage-decision-package.schema.json +59 -9
- package/template/.pi/skills/yss-stage-decision/references/validation-rules.md +2 -2
- package/template/.pi/skills/yss-stage-decision/scripts/migrate-contract-v3.mjs +143 -0
- package/template/.pi/skills/yss-stage-decision/scripts/validate-domain-strategy.mjs +46 -4
- package/template/.pi/skills/yss-stage-decision/scripts/validate-stage-decision-package.mjs +48 -4
- package/template/.pi/skills/yss-stage-decision/tests/fixtures/valid-stage-decision-package.yaml +42 -13
- package/template/.pi/skills/yss-stage-decision/tests/fixtures/valid-supplier-domain.yaml +37 -5
- package/template/.pi/skills/yss-stage-decision/tests/run-scenarios.mjs +116 -23
- package/template/.pi/skills/yss-technical-design/SKILL.md +6 -0
- package/template/docs/agents/yss-skill-registry.yaml +22 -0
- package/template/docs/plan/templates/plan-template.md +8 -4
- package/template/docs/process/document-writing.md +77 -0
- package/template/docs/process/frontend-backend-delivery.md +7 -4
- package/template/docs/process/schemas/backend-delivery.schema.json +4 -0
- package/template/docs/process/schemas/frontend-delivery-acceptance-v1.schema.json +200 -0
- package/template/docs/process/schemas/frontend-delivery-acceptance.schema.json +37 -3
- package/template/docs/process/schemas/frontend-strategic-preflight.schema.json +32 -0
- package/template/docs/process/schemas/lifecycle-checkpoint.schema.json +2 -1
- package/template/docs/process/schemas/strategic-consumer-feedback.schema.json +40 -0
- package/template/docs/process/schemas/strategic-design-handoff-v3.schema.json +743 -0
- package/template/docs/process/schemas/strategic-design-handoff-v4.schema.json +712 -0
- package/template/docs/process/schemas/strategic-feedback-adjudication.schema.json +42 -0
- package/template/docs/process/schemas/strategic-handoff-domain-strategy-v3.schema.json +216 -0
- package/template/docs/process/schemas/strategic-handoff-import-receipt.schema.json +39 -0
- package/template/docs/process/schemas/strategic-handoff-stage-decision-package-v3.schema.json +148 -0
- package/template/docs/process/strategic-handoff-package.md +37 -4
- package/template/docs/process/templates/lifecycle-checkpoint-template.yaml +1 -0
- package/template/docs/process/templates/stage-checkpoint-template.md +1 -0
- package/template/docs/templates/examples/lifecycle-writing-examples.md +138 -0
- package/template/docs/templates/spec-template.md +16 -3
- package/template/docs/templates/vertical-slice-ticket-template.md +8 -4
- package/template/scripts/lib/approval-record.mjs +2 -1
- package/template/scripts/lib/backend-delivery.mjs +15 -3
- package/template/scripts/lib/frontend-delivery-boundary.mjs +20 -4
- package/template/scripts/lib/frontend-delivery.mjs +66 -2
- package/template/scripts/lib/profile-skill-sync.mjs +336 -0
- package/template/scripts/lib/strategic-feedback.mjs +33 -0
- package/template/scripts/lib/strategic-handoff-consumption.mjs +5 -0
- package/template/scripts/lib/strategic-handoff-io.mjs +1 -0
- package/template/scripts/lib/strategic-handoff.mjs +101 -10
- package/template/scripts/lib/user-decision-reuse.mjs +38 -0
- package/template/scripts/strategic-feedback +10 -0
- package/template/scripts/sync-profile-skills +43 -0
- package/template/scripts/verify-frontend-strategic-preflight +12 -0
- package/template/skills-lock.json +38 -20
- package/template.manifest.json +1 -0
- package/template.snapshot.json +6 -5
|
@@ -7,6 +7,8 @@ description: 编排 YSS 产品或模块从机会调研到 Spec、原型、技术
|
|
|
7
7
|
|
|
8
8
|
生命周期单一主控:识别请求、仓库身份和最近可信阶段,计算可执行 frontier,派发并验收工作单元;业务设计、实现和独立审查交给专项 skill。
|
|
9
9
|
|
|
10
|
+
文档按 `document_writing` 条件调用 `i-have-adhd`,并传递 `docs/process/document-writing.md` 规范。
|
|
11
|
+
|
|
10
12
|
## 事实源与按需加载
|
|
11
13
|
|
|
12
14
|
先读 `yss-project.yaml`、`CONTEXT.md`、相关 ADR、父 Ticket/checkpoint 和当前资产,按需加载合同子树:
|
|
@@ -25,7 +27,7 @@ description: 编排 YSS 产品或模块从机会调研到 Spec、原型、技术
|
|
|
25
27
|
scripts/query-lifecycle-context --mode route --stage stage.plan --work-unit work-unit.plan-requirements --include execution_efficiency
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
`--include` 接受编排合同的顶层键;非法模式、ID
|
|
30
|
+
`--include` 接受编排合同的顶层键;非法模式、ID 或合同键必须失败。结果为权威投影;细节按需读 `references/orchestration.md`、`references/state-model.md`、`references/artifact-dependencies.md`、`references/user-decisions.md` 和 `references/matt-yss-adapter.md`,证据充分即停止加载。
|
|
29
31
|
|
|
30
32
|
按 `execution_efficiency` 合并查询、复用未变资料并验证当前资产;产品流转不重跑模板套件。词汇对账、恢复核验及门禁不变,执行细节见 `references/orchestration.md`。
|
|
31
33
|
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
schema_version: 1
|
|
2
|
+
document_writing:
|
|
3
|
+
supporting_skill: i-have-adhd
|
|
4
|
+
condition: lifecycle-document-output
|
|
5
|
+
scope: current-document-work-only
|
|
6
|
+
dispatch: pass-condition-and-reference-to-document-owner
|
|
7
|
+
reference: docs/process/document-writing.md
|
|
8
|
+
examples: docs/templates/examples/lifecycle-writing-examples.md
|
|
9
|
+
load_when: [lifecycle-document-draft, lifecycle-document-revision, progress-or-decision-presentation]
|
|
10
|
+
dispatch_input: include-reference-for-document-work
|
|
11
|
+
artifact_ownership: unchanged
|
|
12
|
+
gate_and_status_semantics: unchanged
|
|
13
|
+
|
|
2
14
|
backend_architecture_identity_policy:
|
|
3
15
|
source: docs/agents/yss-skill-registry.yaml#architecture_profiles
|
|
4
16
|
schema: docs/process/schemas/backend-architecture-identity.schema.json
|
|
@@ -7,6 +7,12 @@ description: Use when a YSS feature has product-design impact on a primary flow,
|
|
|
7
7
|
|
|
8
8
|
把产品设计影响收敛为跨 Agent 一致的原型交付物、证据和生命周期回流合同。它不替代 `yss-product-lifecycle` 的门禁裁决,也不把原型当作生产前端代码。
|
|
9
9
|
|
|
10
|
+
文档输出时按 `lifecycle-document-output` 条件调用 `i-have-adhd`,读取 `docs/process/document-writing.md`;作用域仅限当前产物,派发时传递条件及引用。
|
|
11
|
+
|
|
12
|
+
## 文档写作
|
|
13
|
+
|
|
14
|
+
起草或修订交互说明、状态说明和设计结论前,读取 `docs/process/document-writing.md` 的共用写法及产品设计指引;原型视觉和行为仍消费当前设计合同。
|
|
15
|
+
|
|
10
16
|
## 进入条件与主入口
|
|
11
17
|
|
|
12
18
|
- 先由 `yss-product-lifecycle` 判断产品设计影响;无行为变化的孤立视觉修复记录 `not-applicable`,不创建空资产。
|
|
@@ -9,6 +9,12 @@ Investigate facts that a YSS decision depends on. Produce evidence and bounded c
|
|
|
9
9
|
|
|
10
10
|
`research` is a deprecated compatibility alias. Use `yss-research` in new assets and routing.
|
|
11
11
|
|
|
12
|
+
文档输出时按 `lifecycle-document-output` 条件调用 `i-have-adhd`,读取 `docs/process/document-writing.md`;作用域仅限当前产物,派发时传递条件及引用。
|
|
13
|
+
|
|
14
|
+
## 文档写作
|
|
15
|
+
|
|
16
|
+
撰写研究简报或结论前,读取 `docs/process/document-writing.md` 的共用写法和研究指引;既有证据结构、来源限定和校验器要求保持完整。
|
|
17
|
+
|
|
12
18
|
## Profiles
|
|
13
19
|
|
|
14
20
|
- `technical-evidence`: standards, official documentation, source code, third-party APIs, framework behavior, protocols, or implementation constraints. Decision-bearing claims must trace to primary sources.
|
|
@@ -7,6 +7,12 @@ description: 编排 Plan 到 Spec 入口的方案决策与业务边界、协作
|
|
|
7
7
|
|
|
8
8
|
`yss-stage-decision` 是由生命周期主控调度的上游决策技能,负责把需求、产品、商务输入和业务边界与规则设计结果整理成可审查、可版本化、可被下游消费的方案决策包。它不替代生命周期主控,也不生成产品代码、原型、OpenAPI 或垂直切片 Ticket。
|
|
9
9
|
|
|
10
|
+
文档输出时按 `lifecycle-document-output` 条件调用 `i-have-adhd`,读取 `docs/process/document-writing.md`;作用域仅限当前产物,派发时传递条件及引用。
|
|
11
|
+
|
|
12
|
+
## 文档写作
|
|
13
|
+
|
|
14
|
+
撰写方案决策包和业务边界说明前,读取 `docs/process/document-writing.md` 的共用写法及 Plan 指引;原业务规则、决定依据和未决项完整保留。
|
|
15
|
+
|
|
10
16
|
## 适用边界
|
|
11
17
|
|
|
12
18
|
- 适用于 `project-instance` 的 Plan → Spec 入口。
|
|
@@ -18,13 +24,22 @@ description: 编排 Plan 到 Spec 入口的方案决策与业务边界、协作
|
|
|
18
24
|
|
|
19
25
|
Plan 的目标与退出条件由 `docs/process/lifecycle-registry.yaml` 持有;从 `docs/plan/templates/plan-template.md` 汇总输入。旧资产按 `docs/process/plan-migration.md` 重新整理并核查,关键未决项不得延期到 Spec,非关键项记录责任人、解决时点与接收方。
|
|
20
26
|
|
|
21
|
-
1. 读取 `yss-project.yaml`、`CONTEXT.md`、既有 Plan/Spec、ADR
|
|
27
|
+
1. 读取 `yss-project.yaml`、`CONTEXT.md`、既有 Plan/Spec、ADR 和当前 profile 的主索引/checkpoint;按 `yss-product-lifecycle` 的 `request-triage` 区分事实确认、产品决定、门禁确认和普通澄清。
|
|
22
28
|
2. 分离事实、决策、假设、约束和未决项;技术事实走 `yss-research` 的 `technical-evidence`,领域边界、业务规则、MVP、非目标、成功标准或阶段推进依据等决策证据走 `strategy-evidence`,市场/竞品事实走 `competitive-intelligence`。
|
|
23
29
|
3. 从业务故事、已发生的事实、规则、责任人和失败路径识别业务板块与业务责任区,不从数据库表或调用链直接反推边界。
|
|
24
30
|
4. 为每个业务责任区建立统一业务词汇;对跨责任区协作记录规则提供方、规则使用方、业务决策权、信息传递方向和口径转换负责人。
|
|
25
31
|
5. 记录待确认的关键业务对象,不提前指定技术模型。
|
|
26
|
-
6. 生成 schema
|
|
27
|
-
7. 运行 Schema
|
|
32
|
+
6. 生成 schema v3 `domain_strategy` 和 `stage_decision_package`,使用稳定规则、场景、决定、假设、约束、成功标准、测试 seam 和 downstream mapping ID,并以 `context_snapshot` 绑定根 `CONTEXT.md`、术语身份、完整文档 digest、引用术语 digest和证据。
|
|
33
|
+
7. 运行 Schema、唯一性、悬空引用、根路径、术语引用、digest、语义一致性和传播验证;发现关键冲突时返回 `blocked`,不得生成 `approved` 包。v2 仅只读;修改或重发必须使用 `scripts/migrate-contract-v3.mjs` 显式迁移为 `draft` 并重新批准。v1 字符串引用先用 `scripts/migrate-context-references.mjs` 迁移到 v2;歧义引用不得猜测。
|
|
34
|
+
|
|
35
|
+
## 控制面引用
|
|
36
|
+
|
|
37
|
+
- 用户决定遵循 `docs/process/lifecycle/references/user-decisions.md`:决定必须绑定资产、版本、范围和证据;范围、风险、摘要或失效条件变化后重新确认。
|
|
38
|
+
- checkpoint 是唯一机器状态源,业务 Ticket 只保存追踪引用,不复制阶段状态。
|
|
39
|
+
- 每次批准、重发和消费者流转前执行 `context_reconciliation`,核验 `CONTEXT.md` 的全文与引用术语双摘要。
|
|
40
|
+
- 技术事实与第三方行为走 `yss-research` 的 `technical-evidence`;产品策略依据走 `strategy-evidence`;市场与竞品判断走 `competitive-intelligence`。
|
|
41
|
+
- 修改本 Skill 时只编辑 `.agents/skills` 权威副本,再由 `maintaining-skills` 生成投影和 `skills-lock.json`。
|
|
42
|
+
- 本 Skill 只能标记影响、提出待解决问题和选择消费者能力;不得预选后端架构族,不得进入技术设计或实现流程,也不得授权实现。
|
|
28
43
|
|
|
29
44
|
## 语义方向规则
|
|
30
45
|
|
|
@@ -50,7 +65,7 @@ Plan 的目标与退出条件由 `docs/process/lifecycle-registry.yaml` 持有
|
|
|
50
65
|
- 不在业务方案设计阶段生成技术模型、生产代码或 API 契约。
|
|
51
66
|
- 不把模板 Fixture 当作具体项目的业务事实。
|
|
52
67
|
|
|
53
|
-
详细合同、字段和验证规则见 `references/domain-strategy-contract.md`、`references/stage-decision-package-contract.md` 与 `references/validation-rules.md
|
|
68
|
+
详细合同、字段和验证规则见 `references/domain-strategy-contract.md`、`references/stage-decision-package-contract.md` 与 `references/validation-rules.md`。当前机器可读合同分别为 `references/domain-strategy-v3.schema.json` 和 `references/stage-decision-package-v3.schema.json`;v2 schema 仅用于历史读取。对应验证器为 `scripts/validate-domain-strategy.mjs` 与 `scripts/validate-stage-decision-package.mjs`。
|
|
54
69
|
|
|
55
70
|
## 战略交接快照包
|
|
56
71
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## 顶层结构
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
当前机器可读合同使用 `references/domain-strategy-v3.schema.json`;`references/domain-strategy-v2.schema.json` 仅用于历史读取。顶层必须包含:
|
|
6
6
|
|
|
7
|
-
- `schema_version:
|
|
7
|
+
- `schema_version: 3`、`domain_strategy_id`、`domain_version`、`status`、`traceability_version: 1`;
|
|
8
|
+
- 带稳定 `rule_id` 与证据的 `rule_catalog`;
|
|
8
9
|
- `contexts`、`subdomains`、`relationships`、`scenarios`;
|
|
9
10
|
- `concept_candidates`、`invariants`、`context_snapshot`;
|
|
10
11
|
- `downstream_mapping`、`evidence_refs`、`approval`。
|
|
@@ -29,4 +30,4 @@
|
|
|
29
30
|
|
|
30
31
|
## 便携交付的逐条追溯
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
正式导出要求场景 `rule_refs / critical / success_results / evidence_refs` 和不变量 `rule_ref / evidence_refs`。`downstream_mapping` 必须使用稳定 `mapping_id`、来源 ID、消费者能力、影响项、传播规则和证据。已有 v2 文档继续只读兼容;修改或重发须显式迁移为 v3 `draft` 并重新批准。具体合同见 `docs/process/strategic-handoff-package.md`,不得由导出器发明业务身份。
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://yss.local/schemas/domain-strategy-v2-compat.json",
|
|
4
|
+
"allOf": [
|
|
5
|
+
{"$ref": "domain-strategy.schema.json"},
|
|
6
|
+
{"properties": {"schema_version": {"const": 2}}, "required": ["schema_version"]}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://yss.local/schemas/domain-strategy-v3.json",
|
|
4
|
+
"allOf": [
|
|
5
|
+
{"$ref": "domain-strategy.schema.json"},
|
|
6
|
+
{"properties": {"schema_version": {"const": 3}}, "required": ["schema_version"]}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://yss.local/schemas/domain-strategy-
|
|
3
|
+
"$id": "https://yss.local/schemas/domain-strategy-current.json",
|
|
4
4
|
"title": "YSS 业务边界与规则设计",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"required": ["schema_version", "domain_strategy_id", "domain_version", "status", "contexts", "subdomains", "relationships", "scenarios", "concept_candidates", "invariants", "context_snapshot", "downstream_mapping", "evidence_refs", "approval"],
|
|
7
7
|
"properties": {
|
|
8
8
|
"traceability_version": {"const": 1},
|
|
9
|
-
"rule_catalog": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["rule_id", "statement", "responsible_context", "status"], "properties": {"rule_id": {"type": "string", "pattern": "^rule\\.[a-z0-9][a-z0-9-]*$"}, "statement": {"type": "string", "minLength": 1}, "responsible_context": {"type": "string", "minLength": 1}, "status": {"const": "confirmed"}}}, "minItems": 1},
|
|
10
|
-
"schema_version": {"
|
|
9
|
+
"rule_catalog": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["rule_id", "statement", "responsible_context", "status"], "properties": {"rule_id": {"type": "string", "pattern": "^rule\\.[a-z0-9][a-z0-9-]*$"}, "statement": {"type": "string", "minLength": 1}, "responsible_context": {"type": "string", "minLength": 1}, "status": {"const": "confirmed"}, "evidence_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "minLength": 1}}}}, "minItems": 1},
|
|
10
|
+
"schema_version": {"enum": [2, 3]},
|
|
11
11
|
"domain_strategy_id": {"type": "string", "pattern": "^domain-strategy\\.[a-z0-9][a-z0-9-]*$"},
|
|
12
12
|
"domain_version": {"type": "string", "pattern": "^v[0-9]+$"},
|
|
13
13
|
"status": {"enum": ["draft", "ready-for-human", "approved", "stale", "blocked"]},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"concept_candidates": {"type": "array", "items": {"$ref": "#/$defs/concept"}},
|
|
19
19
|
"invariants": {"type": "array", "items": {"$ref": "#/$defs/invariant"}},
|
|
20
20
|
"context_snapshot": {"$ref": "#/$defs/contextSnapshot"},
|
|
21
|
-
"downstream_mapping": {"type": "array"
|
|
21
|
+
"downstream_mapping": {"type": "array"},
|
|
22
22
|
"evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
|
|
23
23
|
"approval": {"$ref": "#/$defs/approval"}
|
|
24
24
|
},
|
|
@@ -132,6 +132,20 @@
|
|
|
132
132
|
"reapproval_condition": {"type": "string", "minLength": 1}
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
|
+
"mappingV3": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"additionalProperties": false,
|
|
138
|
+
"required": ["mapping_id", "source_refs", "consumer_capability", "impacts", "propagation", "reapproval_condition", "evidence_refs"],
|
|
139
|
+
"properties": {
|
|
140
|
+
"mapping_id": {"type": "string", "pattern": "^mapping\\.[a-z0-9][a-z0-9-]*$"},
|
|
141
|
+
"source_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^(rule|scenario|invariant)\\.[a-z0-9][a-z0-9-]*$"}},
|
|
142
|
+
"consumer_capability": {"enum": ["backend-technical-design", "frontend-engineering-design", "delivery-coordination"]},
|
|
143
|
+
"impacts": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "minLength": 1}},
|
|
144
|
+
"propagation": {"enum": ["direct", "transitive", "not-applicable", "stale"]},
|
|
145
|
+
"reapproval_condition": {"type": "string", "minLength": 1},
|
|
146
|
+
"evidence_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "minLength": 1}}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
135
149
|
"approval": {
|
|
136
150
|
"type": "object",
|
|
137
151
|
"required": ["approval_ref", "approver", "persisted_ref", "current_version"],
|
|
@@ -142,5 +156,61 @@
|
|
|
142
156
|
"current_version": {"type": "string", "pattern": "^v[0-9]+$"}
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
|
-
}
|
|
159
|
+
},
|
|
160
|
+
"allOf": [
|
|
161
|
+
{
|
|
162
|
+
"if": {"properties": {"schema_version": {"const": 3}}, "required": ["schema_version"]},
|
|
163
|
+
"then": {
|
|
164
|
+
"required": ["traceability_version", "rule_catalog"],
|
|
165
|
+
"properties": {
|
|
166
|
+
"traceability_version": {"const": 1},
|
|
167
|
+
"rule_catalog": {
|
|
168
|
+
"items": {
|
|
169
|
+
"required": ["evidence_refs"],
|
|
170
|
+
"properties": {
|
|
171
|
+
"evidence_refs": {
|
|
172
|
+
"type": "array",
|
|
173
|
+
"minItems": 1,
|
|
174
|
+
"uniqueItems": true,
|
|
175
|
+
"items": {"type": "string", "minLength": 1}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"scenarios": {
|
|
181
|
+
"items": {
|
|
182
|
+
"required": ["rule_refs", "critical", "success_results", "evidence_refs"],
|
|
183
|
+
"properties": {
|
|
184
|
+
"evidence_refs": {
|
|
185
|
+
"type": "array",
|
|
186
|
+
"minItems": 1,
|
|
187
|
+
"uniqueItems": true,
|
|
188
|
+
"items": {"type": "string", "minLength": 1}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"invariants": {
|
|
194
|
+
"items": {
|
|
195
|
+
"required": ["rule_ref", "evidence_refs"],
|
|
196
|
+
"properties": {
|
|
197
|
+
"evidence_refs": {
|
|
198
|
+
"type": "array",
|
|
199
|
+
"minItems": 1,
|
|
200
|
+
"uniqueItems": true,
|
|
201
|
+
"items": {"type": "string", "minLength": 1}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"downstream_mapping": {"items": {"$ref": "#/$defs/mappingV3"}}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
"else": {
|
|
210
|
+
"properties": {
|
|
211
|
+
"downstream_mapping": {"items": {"$ref": "#/$defs/mapping"}}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
]
|
|
146
216
|
}
|
package/template/.codex/skills/yss-stage-decision/references/stage-decision-package-contract.md
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
## 必须包含
|
|
6
6
|
|
|
7
|
-
- 问题陈述、目标用户、MVP
|
|
8
|
-
-
|
|
7
|
+
- 问题陈述、目标用户、MVP、非目标,以及带稳定 ID、来源 ID 和证据的成功标准与可执行测试 seam;
|
|
8
|
+
- 带稳定 ID、来源 ID 和证据的已确认决策、假设、约束,以及有责任人的未决项;
|
|
9
9
|
- `context_snapshot`:只引用根 `CONTEXT.md`,并绑定结构化术语身份、全文摘要和引用集摘要;
|
|
10
10
|
- `domain_strategy_ref`:领域战略合同的稳定 ID、版本、digest 和批准状态;
|
|
11
11
|
- UI/API/Data/Backend/Frontend/跨仓/高风险影响面布尔值;
|
|
12
|
-
-
|
|
12
|
+
- 每个消费者能力的稳定 `mapping_id`、领域来源 ID、传播方式、重新批准条件、证据引用和批准记录。`approval.approval_ref` 必须指向可读取且通过 `scripts/verify-approval-record` 的 `gate.stage-decision-package-approved` 会签记录;`approval.approver` 必须与记录中的 `role_id` 一致。
|
|
13
13
|
|
|
14
14
|
## 未决项规则
|
|
15
15
|
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
|
|
20
20
|
只有 `approved` 且引用的领域战略为 `approved`、版本当前的阶段包,才可以进入 Spec synthesis。任何领域战略 digest、版本或影响面变化都使阶段包 `stale`,并要求重新评估。
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
新写入阶段包使用 `schema_version: 3`,且只能引用 Domain Strategy v3。v2 仅只读;修改或重新交付须用 `scripts/migrate-contract-v3.mjs` 生成未批准的 `draft` 后补齐来源并重新批准。旧版字符串路径或 Markdown 锚点先通过上下文迁移器读取;无法唯一映射到 `<ContextId>/<EnglishIdentifier>` 时返回 `migration-required`,不得猜测。
|
package/template/.codex/skills/yss-stage-decision/references/stage-decision-package-v2.schema.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://yss.local/schemas/stage-decision-package-v2-compat.json",
|
|
4
|
+
"allOf": [
|
|
5
|
+
{"$ref": "stage-decision-package.schema.json"},
|
|
6
|
+
{"properties": {"schema_version": {"const": 2}}, "required": ["schema_version"]}
|
|
7
|
+
]
|
|
8
|
+
}
|
package/template/.codex/skills/yss-stage-decision/references/stage-decision-package-v3.schema.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://yss.local/schemas/stage-decision-package-v3.json",
|
|
4
|
+
"allOf": [
|
|
5
|
+
{"$ref": "stage-decision-package.schema.json"},
|
|
6
|
+
{"properties": {"schema_version": {"const": 3}}, "required": ["schema_version"]}
|
|
7
|
+
]
|
|
8
|
+
}
|
package/template/.codex/skills/yss-stage-decision/references/stage-decision-package.schema.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://yss.local/schemas/stage-decision-package-
|
|
3
|
+
"$id": "https://yss.local/schemas/stage-decision-package-current.json",
|
|
4
4
|
"title": "YSS Stage Decision Package",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"required": ["schema_version", "stage_decision_id", "package_version", "status", "problem_statement", "target_users", "mvp", "non_goals", "success_criteria", "test_seams", "confirmed_decisions", "assumptions", "constraints", "unresolved_items", "context_snapshot", "domain_strategy_ref", "impact_assessment", "downstream_mapping", "evidence_refs", "approval"],
|
|
7
7
|
"properties": {
|
|
8
|
-
"schema_version": {"
|
|
8
|
+
"schema_version": {"enum": [2, 3]},
|
|
9
9
|
"stage_decision_id": {"type": "string", "pattern": "^stage-decision\\.[a-z0-9][a-z0-9-]*$"},
|
|
10
10
|
"package_version": {"type": "string", "pattern": "^v[0-9]+$"},
|
|
11
11
|
"status": {"enum": ["draft", "ready-for-human", "approved", "stale", "blocked"]},
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"target_users": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
|
|
14
14
|
"mvp": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
|
|
15
15
|
"non_goals": {"type": "array", "items": {"type": "string", "minLength": 1}},
|
|
16
|
-
"success_criteria": {"type": "array", "minItems": 1
|
|
17
|
-
"test_seams": {"type": "array", "minItems": 1
|
|
18
|
-
"confirmed_decisions": {"type": "array", "minItems": 1
|
|
19
|
-
"assumptions": {"type": "array"
|
|
20
|
-
"constraints": {"type": "array"
|
|
16
|
+
"success_criteria": {"type": "array", "minItems": 1},
|
|
17
|
+
"test_seams": {"type": "array", "minItems": 1},
|
|
18
|
+
"confirmed_decisions": {"type": "array", "minItems": 1},
|
|
19
|
+
"assumptions": {"type": "array"},
|
|
20
|
+
"constraints": {"type": "array"},
|
|
21
21
|
"unresolved_items": {"type": "array", "items": {"$ref": "#/$defs/unresolved"}},
|
|
22
22
|
"context_snapshot": {"$ref": "#/$defs/contextSnapshot"},
|
|
23
23
|
"domain_strategy_ref": {"$ref": "#/$defs/domainRef"},
|
|
24
24
|
"impact_assessment": {"$ref": "#/$defs/impact"},
|
|
25
|
-
"downstream_mapping": {"type": "array", "minItems": 1
|
|
25
|
+
"downstream_mapping": {"type": "array", "minItems": 1},
|
|
26
26
|
"evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
|
|
27
27
|
"approval": {"$ref": "#/$defs/approval"}
|
|
28
28
|
},
|
|
@@ -84,6 +84,31 @@
|
|
|
84
84
|
"reapproval_condition": {"type": "string", "minLength": 1}
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
+
"recordV3": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"additionalProperties": false,
|
|
90
|
+
"required": ["id", "statement", "evidence_refs"],
|
|
91
|
+
"properties": {
|
|
92
|
+
"id": {"type": "string", "pattern": "^(success-criterion|test-seam|decision|assumption|constraint)\\.[a-z0-9][a-z0-9-]*$"},
|
|
93
|
+
"statement": {"type": "string", "minLength": 1},
|
|
94
|
+
"source_refs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "pattern": "^(rule|scenario|invariant)\\.[a-z0-9][a-z0-9-]*$"}},
|
|
95
|
+
"evidence_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "minLength": 1}},
|
|
96
|
+
"status": {"enum": ["confirmed", "candidate", "stale"]}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"mappingV3": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"required": ["mapping_id", "source_refs", "consumer_capability", "propagation", "reapproval_condition", "evidence_refs"],
|
|
103
|
+
"properties": {
|
|
104
|
+
"mapping_id": {"type": "string", "pattern": "^mapping\\.[a-z0-9][a-z0-9-]*$"},
|
|
105
|
+
"source_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^(rule|scenario|invariant)\\.[a-z0-9][a-z0-9-]*$"}},
|
|
106
|
+
"consumer_capability": {"enum": ["backend-technical-design", "frontend-engineering-design", "delivery-coordination"]},
|
|
107
|
+
"propagation": {"enum": ["direct", "transitive", "not-applicable", "stale"]},
|
|
108
|
+
"reapproval_condition": {"type": "string", "minLength": 1},
|
|
109
|
+
"evidence_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "minLength": 1}}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
87
112
|
"approval": {
|
|
88
113
|
"type": "object",
|
|
89
114
|
"required": ["approval_ref", "approver", "persisted_ref", "current_version"],
|
|
@@ -94,5 +119,30 @@
|
|
|
94
119
|
"current_version": {"type": "string", "pattern": "^v[0-9]+$"}
|
|
95
120
|
}
|
|
96
121
|
}
|
|
97
|
-
}
|
|
122
|
+
},
|
|
123
|
+
"allOf": [
|
|
124
|
+
{
|
|
125
|
+
"if": {"properties": {"schema_version": {"const": 3}}, "required": ["schema_version"]},
|
|
126
|
+
"then": {
|
|
127
|
+
"properties": {
|
|
128
|
+
"success_criteria": {"items": {"$ref": "#/$defs/recordV3"}},
|
|
129
|
+
"test_seams": {"items": {"$ref": "#/$defs/recordV3"}},
|
|
130
|
+
"confirmed_decisions": {"items": {"$ref": "#/$defs/recordV3"}},
|
|
131
|
+
"assumptions": {"items": {"$ref": "#/$defs/recordV3"}},
|
|
132
|
+
"constraints": {"items": {"$ref": "#/$defs/recordV3"}},
|
|
133
|
+
"downstream_mapping": {"items": {"$ref": "#/$defs/mappingV3"}}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"else": {
|
|
137
|
+
"properties": {
|
|
138
|
+
"success_criteria": {"items": {"type": "string", "minLength": 1}},
|
|
139
|
+
"test_seams": {"items": {"type": "string", "minLength": 1}},
|
|
140
|
+
"confirmed_decisions": {"items": {"type": "string", "minLength": 1}},
|
|
141
|
+
"assumptions": {"items": {"type": "string", "minLength": 1}},
|
|
142
|
+
"constraints": {"items": {"type": "string", "minLength": 1}},
|
|
143
|
+
"downstream_mapping": {"items": {"$ref": "#/$defs/mapping"}}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
]
|
|
98
148
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
验证分为结构、引用和语义三层:
|
|
4
4
|
|
|
5
|
-
1. **结构**:Schema
|
|
6
|
-
2.
|
|
5
|
+
1. **结构**:Schema 版本、全局稳定 ID 唯一性、状态枚举、必填字段、条件字段和非空证据格式。
|
|
6
|
+
2. **引用**:上下文端点、规则、场景、不变量、决定、测试 seam、`context_snapshot.term_refs` 和下游 mapping 来源必须可解析;`context_ref` 必须精确为根 `CONTEXT.md`,双摘要必须与当前内容一致。
|
|
7
7
|
3. **语义**:禁止关系自环、未知上下文、未批准 Shared Kernel、未解释的语义/技术方向差异、职责重叠、无责任人的不变量和跨上下文直接共享实体。
|
|
8
8
|
|
|
9
9
|
以下情况必须 `blocked`:关键规则所有权未知、关键术语冲突、上下文边界未定、关键失败场景缺失、事件语义无法解释、领域专家确认缺失。
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
import { parseDocument } from "../../../../scripts/vendor/yaml.mjs";
|
|
7
|
+
|
|
8
|
+
function blocked(message) {
|
|
9
|
+
process.stderr.write(`${JSON.stringify({ result: "blocked", reason_code: "migration-required", errors: [message] }, null, 2)}\n`);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function parse(source, label) {
|
|
14
|
+
const document = parseDocument(source, { maxAliasCount: 0, uniqueKeys: true });
|
|
15
|
+
if (document.errors.length) throw new TypeError(`${label} YAML 非法: ${document.errors[0].message}`);
|
|
16
|
+
const value = document.toJS({ maxAliasCount: 0 });
|
|
17
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError(`${label} 必须是对象`);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function nextVersion(value) {
|
|
22
|
+
const matched = String(value ?? "v2").match(/^v(\d+)$/);
|
|
23
|
+
return `v${Math.max(3, Number(matched?.[1] ?? 2) + 1)}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function token(value, fallback) {
|
|
27
|
+
const normalized = String(value ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
28
|
+
return normalized || fallback;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resetApproval(value, version) {
|
|
32
|
+
value.status = "draft";
|
|
33
|
+
value.approval = {
|
|
34
|
+
approval_ref: "migration-required",
|
|
35
|
+
approver: "unassigned",
|
|
36
|
+
persisted_ref: value.approval?.persisted_ref || "migration-output-not-persisted",
|
|
37
|
+
current_version: version
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function migrateDomain(input) {
|
|
42
|
+
const output = structuredClone(input);
|
|
43
|
+
if (output.schema_version !== 2) throw new TypeError("Domain Strategy 迁移仅支持 schema_version: 2");
|
|
44
|
+
const evidence = Array.isArray(output.evidence_refs) && output.evidence_refs.length ? output.evidence_refs : ["migration-required:evidence"];
|
|
45
|
+
const rules = [];
|
|
46
|
+
const statementToId = new Map();
|
|
47
|
+
for (const [scenarioIndex, scenario] of (output.scenarios ?? []).entries()) {
|
|
48
|
+
scenario.rule_refs = [];
|
|
49
|
+
for (const [ruleIndex, statement] of (scenario.rules ?? []).entries()) {
|
|
50
|
+
let ruleId = statementToId.get(statement);
|
|
51
|
+
if (!ruleId) {
|
|
52
|
+
ruleId = `rule.${token(scenario.scenario_id?.replace(/^scenario\./, ""), `scenario-${scenarioIndex + 1}`)}-${ruleIndex + 1}`;
|
|
53
|
+
statementToId.set(statement, ruleId);
|
|
54
|
+
rules.push({ rule_id: ruleId, statement, responsible_context: scenario.responsible_context, status: "confirmed", evidence_refs: [...evidence] });
|
|
55
|
+
}
|
|
56
|
+
scenario.rule_refs.push(ruleId);
|
|
57
|
+
}
|
|
58
|
+
scenario.critical = false;
|
|
59
|
+
scenario.success_results = Array.isArray(scenario.events) && scenario.events.length ? [...scenario.events] : ["migration-required: 补充成功结果"];
|
|
60
|
+
scenario.evidence_refs = [...evidence];
|
|
61
|
+
}
|
|
62
|
+
for (const [index, invariant] of (output.invariants ?? []).entries()) {
|
|
63
|
+
let ruleId = statementToId.get(invariant.statement);
|
|
64
|
+
if (!ruleId) {
|
|
65
|
+
ruleId = `rule.${token(invariant.invariant_id?.replace(/^invariant\./, ""), `invariant-${index + 1}`)}`;
|
|
66
|
+
statementToId.set(invariant.statement, ruleId);
|
|
67
|
+
rules.push({ rule_id: ruleId, statement: invariant.statement, responsible_context: invariant.responsible_context, status: "confirmed", evidence_refs: [...evidence] });
|
|
68
|
+
}
|
|
69
|
+
invariant.rule_ref = ruleId;
|
|
70
|
+
invariant.evidence_refs = [...evidence];
|
|
71
|
+
}
|
|
72
|
+
const sourceRefs = [...(output.scenarios ?? []).map((item) => item.scenario_id), ...(output.invariants ?? []).map((item) => item.invariant_id)].filter(Boolean);
|
|
73
|
+
output.downstream_mapping = (output.downstream_mapping ?? []).map((mapping, index) => {
|
|
74
|
+
const impacts = Array.isArray(mapping.impacts) ? mapping.impacts : ["migration-required"];
|
|
75
|
+
const isFrontend = impacts.some((item) => /frontend|ui|visual/i.test(item));
|
|
76
|
+
return {
|
|
77
|
+
mapping_id: `mapping.${token(mapping.domain_change, `migrated-${index + 1}`)}`,
|
|
78
|
+
source_refs: sourceRefs.length ? sourceRefs : [rules[0]?.rule_id].filter(Boolean),
|
|
79
|
+
consumer_capability: isFrontend ? "frontend-engineering-design" : "backend-technical-design",
|
|
80
|
+
impacts,
|
|
81
|
+
propagation: mapping.propagation,
|
|
82
|
+
reapproval_condition: mapping.reapproval_condition,
|
|
83
|
+
evidence_refs: [...evidence]
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
output.schema_version = 3;
|
|
87
|
+
output.traceability_version = 1;
|
|
88
|
+
output.rule_catalog = rules;
|
|
89
|
+
output.domain_version = nextVersion(output.domain_version);
|
|
90
|
+
resetApproval(output, output.domain_version);
|
|
91
|
+
return output;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function migrateStage(input, root) {
|
|
95
|
+
const output = structuredClone(input);
|
|
96
|
+
if (output.schema_version !== 2) throw new TypeError("Stage Decision 迁移仅支持 schema_version: 2");
|
|
97
|
+
const evidence = Array.isArray(output.evidence_refs) && output.evidence_refs.length ? output.evidence_refs : ["migration-required:evidence"];
|
|
98
|
+
let sourceRefs = [];
|
|
99
|
+
try {
|
|
100
|
+
const domainSource = await readFile(resolve(root, output.domain_strategy_ref.persisted_ref), "utf8");
|
|
101
|
+
const domain = parse(domainSource, "Domain Strategy");
|
|
102
|
+
sourceRefs = [...(domain.rule_catalog ?? []).map((item) => item.rule_id), ...(domain.scenarios ?? []).map((item) => item.scenario_id), ...(domain.invariants ?? []).map((item) => item.invariant_id)].filter(Boolean);
|
|
103
|
+
} catch {
|
|
104
|
+
sourceRefs = [];
|
|
105
|
+
}
|
|
106
|
+
const prefixes = { success_criteria: "success-criterion", test_seams: "test-seam", confirmed_decisions: "decision", assumptions: "assumption", constraints: "constraint" };
|
|
107
|
+
for (const [field, prefix] of Object.entries(prefixes)) {
|
|
108
|
+
output[field] = (output[field] ?? []).map((statement, index) => ({
|
|
109
|
+
id: `${prefix}.${token(statement, `migrated-${index + 1}`)}`,
|
|
110
|
+
statement,
|
|
111
|
+
source_refs: sourceRefs.slice(0, 1),
|
|
112
|
+
evidence_refs: [...evidence],
|
|
113
|
+
status: "candidate"
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
output.downstream_mapping = (output.downstream_mapping ?? []).map((mapping, index) => ({
|
|
117
|
+
mapping_id: `mapping.${token(mapping.domain_change, `migrated-${index + 1}`)}`,
|
|
118
|
+
source_refs: sourceRefs.slice(0, 1),
|
|
119
|
+
consumer_capability: /frontend|ui/i.test(mapping.consumer ?? "") ? "frontend-engineering-design" : /coord/i.test(mapping.consumer ?? "") ? "delivery-coordination" : "backend-technical-design",
|
|
120
|
+
propagation: mapping.propagation,
|
|
121
|
+
reapproval_condition: mapping.reapproval_condition,
|
|
122
|
+
evidence_refs: [...evidence]
|
|
123
|
+
}));
|
|
124
|
+
output.schema_version = 3;
|
|
125
|
+
output.package_version = nextVersion(output.package_version);
|
|
126
|
+
resetApproval(output, output.package_version);
|
|
127
|
+
return output;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
const { values, positionals } = parseArgs({
|
|
132
|
+
options: { kind: { type: "string" }, root: { type: "string", default: process.cwd() } },
|
|
133
|
+
allowPositionals: true,
|
|
134
|
+
strict: true
|
|
135
|
+
});
|
|
136
|
+
const file = positionals[0];
|
|
137
|
+
if (!file || !["domain-strategy", "stage-decision"].includes(values.kind)) throw new TypeError("用法: migrate-contract-v3.mjs <contract.yaml> --kind <domain-strategy|stage-decision> [--root <project-root>]");
|
|
138
|
+
const value = parse(await readFile(file, "utf8"), "合同");
|
|
139
|
+
const migrated = values.kind === "domain-strategy" ? migrateDomain(value) : await migrateStage(value, values.root);
|
|
140
|
+
process.stdout.write(`${JSON.stringify(migrated, null, 2)}\n`);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
blocked(error.message);
|
|
143
|
+
}
|