spec-wave 2.1.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.
Files changed (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +327 -0
  3. package/README.zh-CN.md +327 -0
  4. package/RELEASING.md +52 -0
  5. package/assets/README.md +30 -0
  6. package/assets/ci/samples/README.md +76 -0
  7. package/assets/ci/samples/hgm-ingest.yml.example +42 -0
  8. package/assets/ci/samples/lint-wiki-delta.pin.yml.example +47 -0
  9. package/assets/ci/samples/lint-wiki-delta.yml.example +49 -0
  10. package/assets/ci/samples/pytest.yml.example +49 -0
  11. package/assets/ci/samples/quality.yml.example +56 -0
  12. package/assets/ci/samples/skills-validate.yml.example +38 -0
  13. package/assets/ci/samples/tech-graph.yml.example +55 -0
  14. package/assets/coding_wiki/templates/README.md +115 -0
  15. package/assets/coding_wiki/templates/_index.md +19 -0
  16. package/assets/coding_wiki/templates/context.md +18 -0
  17. package/assets/coding_wiki/templates/stable.md +26 -0
  18. package/assets/coding_wiki/templates/topics/wiki_layout.md +13 -0
  19. package/assets/coding_wiki/templates/topics/wikilinks_export.md +13 -0
  20. package/assets/coding_wiki/templates/volatile.md +25 -0
  21. package/assets/docs/POINTER_ONBOARDING.md +9 -0
  22. package/assets/docs/POINTER_RUNBOOK_wiki_delta.md +18 -0
  23. package/assets/docs/POINTER_SDD_HAT_FLOW.md +8 -0
  24. package/assets/docs/POINTER_USER_GUIDE.md +8 -0
  25. package/assets/graph/stubs/README.md +6 -0
  26. package/assets/graph/templates/00_main.graph.yaml +72 -0
  27. package/assets/graph/templates/00_main.md +85 -0
  28. package/assets/graph/templates/01_struct.md +38 -0
  29. package/assets/graph/templates/02_version.md +7 -0
  30. package/assets/graph/templates/10_flow_MAIN.graph.yaml +105 -0
  31. package/assets/graph/templates/10_flow_MAIN.md +103 -0
  32. package/assets/graph/templates/99_mermaid_protocol.md +156 -0
  33. package/assets/graph/templates/README.md +66 -0
  34. package/assets/harness/README.md +18 -0
  35. package/assets/harness/discipline-coverage.yaml +320 -0
  36. package/assets/harness/invokes/README.md +22 -0
  37. package/assets/harness/invokes/TEMPLATE_invoke.md +61 -0
  38. package/assets/harness/lifecycle.yaml +127 -0
  39. package/assets/harness/prompts/00-orchestrator.md +91 -0
  40. package/assets/harness/prompts/10-spec-requirements.md +63 -0
  41. package/assets/harness/prompts/10-task-requirements.md +70 -0
  42. package/assets/harness/prompts/20-spec-audit.md +50 -0
  43. package/assets/harness/prompts/20-task-audit.md +90 -0
  44. package/assets/harness/prompts/30-execute-code.md +64 -0
  45. package/assets/harness/prompts/40-self-check.md +65 -0
  46. package/assets/harness/prompts/FRAGMENT_00_delegate_only_v1_zh.md +19 -0
  47. package/assets/harness/prompts/FRAGMENT_30_gate_verify_v1_zh.md +34 -0
  48. package/assets/harness/prompts/FRAGMENT_30_invoke_block_v1_zh.md +28 -0
  49. package/assets/harness/prompts/FRAGMENT_hat_reanchor_v1_zh.md +19 -0
  50. package/assets/harness/prompts/README.md +67 -0
  51. package/assets/harness/prompts/TEMPLATE_30_gate_stop.md +36 -0
  52. package/assets/harness/templates/FRAGMENT_task_domain_infer_v1_zh.md +16 -0
  53. package/assets/harness/templates/ONTOLOGY_consumer_slice_v1.md +41 -0
  54. package/assets/harness/templates/QUICKREF_v1_zh.md +35 -0
  55. package/assets/harness/templates/README.md +50 -0
  56. package/assets/harness/templates/TASK_TEMPLATE.md +133 -0
  57. package/assets/harness/templates/TASK_done_README.md +76 -0
  58. package/assets/harness/templates/TASK_epic.md +103 -0
  59. package/assets/harness/templates/TASK_graph_bootstrap.md +115 -0
  60. package/assets/harness/templates/VIEW_done_by_domain.md +66 -0
  61. package/assets/harness/templates/VIEW_done_thin_pointer.md +16 -0
  62. package/assets/ide/adapters/AGENTS.md.fragment.example +33 -0
  63. package/assets/ide/adapters/CLAUDE.md.fragment.example +32 -0
  64. package/assets/ide/adapters/README.md +57 -0
  65. package/assets/ide/adapters/cursor-harness-starter.mdc.example +39 -0
  66. package/assets/ide/commands/claude/kit/apply-standards.md +10 -0
  67. package/assets/ide/commands/claude/kit/gate-status.md +10 -0
  68. package/assets/ide/commands/claude/kit/graph-check.md +8 -0
  69. package/assets/ide/commands/claude/kit/hat-00-delegate.md +9 -0
  70. package/assets/ide/commands/claude/kit/hat-10-spec.md +9 -0
  71. package/assets/ide/commands/claude/kit/hat-10-task.md +9 -0
  72. package/assets/ide/commands/claude/kit/hat-20-spec-audit.md +9 -0
  73. package/assets/ide/commands/claude/kit/hat-20-task-audit.md +9 -0
  74. package/assets/ide/commands/claude/kit/hat-reanchor.md +8 -0
  75. package/assets/ide/commands/claude/kit/init-guide.md +16 -0
  76. package/assets/ide/commands/claude/kit/sync-prompts-guide.md +9 -0
  77. package/assets/ide/commands/claude/kit/verify.md +16 -0
  78. package/assets/ide/commands/cursor/kit-apply-standards.md +12 -0
  79. package/assets/ide/commands/cursor/kit-gate-status.md +12 -0
  80. package/assets/ide/commands/cursor/kit-graph-check.md +10 -0
  81. package/assets/ide/commands/cursor/kit-hat-00-delegate.md +11 -0
  82. package/assets/ide/commands/cursor/kit-hat-10-spec.md +11 -0
  83. package/assets/ide/commands/cursor/kit-hat-10-task.md +11 -0
  84. package/assets/ide/commands/cursor/kit-hat-20-spec-audit.md +11 -0
  85. package/assets/ide/commands/cursor/kit-hat-20-task-audit.md +11 -0
  86. package/assets/ide/commands/cursor/kit-hat-reanchor.md +10 -0
  87. package/assets/ide/commands/cursor/kit-init-guide.md +18 -0
  88. package/assets/ide/commands/cursor/kit-sync-prompts-guide.md +11 -0
  89. package/assets/ide/commands/cursor/kit-verify.md +18 -0
  90. package/assets/ide/host-adapt/README.md +113 -0
  91. package/assets/ide/host-adapt/examples/mvp-hosts.yaml +78 -0
  92. package/assets/ide/host-adapt/host-adapt.schema.json +97 -0
  93. package/assets/ide/skills-orch/README.md +16 -0
  94. package/assets/ide/skills-orch/kit-apply-standards/SKILL.md +17 -0
  95. package/assets/ide/skills-orch/kit-gate-status/SKILL.md +17 -0
  96. package/assets/ide/skills-orch/kit-hat-reanchor/SKILL.md +15 -0
  97. package/assets/ide/skills-orch/kit-init-guide/SKILL.md +23 -0
  98. package/assets/ide/skills-orch/kit-verify/SKILL.md +23 -0
  99. package/assets/ontology.yaml +113 -0
  100. package/assets/skills/README.md +37 -0
  101. package/assets/skills/harness-00-delegate-only/SKILL.md +19 -0
  102. package/assets/skills/harness-10-spec/SKILL.md +63 -0
  103. package/assets/skills/harness-10-task/SKILL.md +70 -0
  104. package/assets/skills/harness-20-spec-audit/SKILL.md +50 -0
  105. package/assets/skills/harness-20-task-audit/SKILL.md +90 -0
  106. package/assets/skills/harness-20-task-audit/references/TEMPLATE_30_gate_stop.md +36 -0
  107. package/assets/skills/harness-hat-reanchor/SKILL.md +19 -0
  108. package/assets/standards/POINTER_workspace_truth_v1_zh.md +42 -0
  109. package/assets/standards/README.md +35 -0
  110. package/assets/standards/SOURCES_v1_zh.md +49 -0
  111. package/assets/standards/TEMPLATE_CODING_BASELINE_L1_v1_zh.md +88 -0
  112. package/assets/standards/TEMPLATE_CODING_BASELINE_L2_backend_v1_zh.md +75 -0
  113. package/assets/standards/TEMPLATE_CODING_BASELINE_L2_frontend_v1_zh.md +76 -0
  114. package/bin/dsh-coding-kit.js +7 -0
  115. package/bin/specgate.js +7 -0
  116. package/bin/validate_template_compliance.py +470 -0
  117. package/cordis.patch.yml +5 -0
  118. package/lib/cli-checks.d.ts +68 -0
  119. package/lib/cli-checks.js +812 -0
  120. package/lib/cli-checks.js.map +1 -0
  121. package/lib/cli-graph-hgm.d.ts +74 -0
  122. package/lib/cli-graph-hgm.js +416 -0
  123. package/lib/cli-graph-hgm.js.map +1 -0
  124. package/lib/cli-graph-yaml.d.ts +79 -0
  125. package/lib/cli-graph-yaml.js +602 -0
  126. package/lib/cli-graph-yaml.js.map +1 -0
  127. package/lib/cli-graph.d.ts +1 -0
  128. package/lib/cli-graph.js +199 -0
  129. package/lib/cli-graph.js.map +1 -0
  130. package/lib/cli-host.d.ts +24 -0
  131. package/lib/cli-host.js +1197 -0
  132. package/lib/cli-host.js.map +1 -0
  133. package/lib/cli-lifecycle.d.ts +2 -0
  134. package/lib/cli-lifecycle.js +401 -0
  135. package/lib/cli-lifecycle.js.map +1 -0
  136. package/lib/cli-refresh-ide-blocks.d.ts +66 -0
  137. package/lib/cli-refresh-ide-blocks.js +484 -0
  138. package/lib/cli-refresh-ide-blocks.js.map +1 -0
  139. package/lib/cli-shared.d.ts +74 -0
  140. package/lib/cli-shared.js +281 -0
  141. package/lib/cli-shared.js.map +1 -0
  142. package/lib/cli-skills.d.ts +52 -0
  143. package/lib/cli-skills.js +363 -0
  144. package/lib/cli-skills.js.map +1 -0
  145. package/lib/cli-status.d.ts +2 -0
  146. package/lib/cli-status.js +251 -0
  147. package/lib/cli-status.js.map +1 -0
  148. package/lib/cli-sync-prompts.d.ts +25 -0
  149. package/lib/cli-sync-prompts.js +158 -0
  150. package/lib/cli-sync-prompts.js.map +1 -0
  151. package/lib/cli-sync.d.ts +2 -0
  152. package/lib/cli-sync.js +124 -0
  153. package/lib/cli-sync.js.map +1 -0
  154. package/lib/cli-task-extra.d.ts +53 -0
  155. package/lib/cli-task-extra.js +408 -0
  156. package/lib/cli-task-extra.js.map +1 -0
  157. package/lib/cli-timeline.d.ts +28 -0
  158. package/lib/cli-timeline.js +68 -0
  159. package/lib/cli-timeline.js.map +1 -0
  160. package/lib/cli-wiki.d.ts +21 -0
  161. package/lib/cli-wiki.js +189 -0
  162. package/lib/cli-wiki.js.map +1 -0
  163. package/lib/cli.d.ts +22 -0
  164. package/lib/cli.js +1034 -0
  165. package/lib/cli.js.map +1 -0
  166. package/lib/host-contract.d.ts +23 -0
  167. package/lib/host-contract.js +143 -0
  168. package/lib/host-contract.js.map +1 -0
  169. package/lib/index.d.ts +18 -0
  170. package/lib/index.js +290 -0
  171. package/lib/index.js.map +1 -0
  172. package/lib/yaml.d.ts +4 -0
  173. package/lib/yaml.js +10 -0
  174. package/lib/yaml.js.map +1 -0
  175. package/package.json +87 -0
@@ -0,0 +1,38 @@
1
+ # 模块边界登记表(L0-b · D4-a 人签真值)
2
+
3
+ > **用途**:`docs/_tech_graph/01_struct.md` — **一级模块** 边界;**HG-GRAPH-MODULES** approved 后方可 **30 执行改码**。
4
+ > **不是**:全仓 flow 一次画完;flow 按 task **增量** 维护。
5
+ > **嵌入后**:删除示例行,填真实模块;维护者人签后更新 task 内 `HG-GRAPH-MODULES` → `approved`。
6
+
7
+ ## 模块表(必填)
8
+
9
+ | module_id | 名称 | 路径 glob | 依赖方向(仅指向谁) | 负责人/备注 |
10
+ |-----------|------|-----------|----------------------|-------------|
11
+ | `core` | 核心业务 | `src/core/**` 或 `app/**` | → `infra` | 示例 · **替换** |
12
+ | `api` | HTTP / RPC 入口 | `src/api/**` 或 `routes/**` | → `core` | 示例 · **替换** |
13
+ | `infra` | DB / 缓存 / 外部 SDK | `src/infra/**` | —(被依赖) | 示例 · **替换** |
14
+ | `_TODO_` | (待填) | `(glob)` | → | 新增行 |
15
+
16
+ ### 填写规则
17
+
18
+ 1. **module_id**:小写 snake_case;全仓唯一。
19
+ 2. **路径 glob**:能覆盖该模块源码根; monorepo 按 **子包** 分行。
20
+ 3. **依赖方向**:只写 **出边**(本模块允许 import / 调用谁);禁止循环 unless 文档化。
21
+ 4. **一级模块**:通常 3~12 行;更细粒度放 Wiki 或子 task,不膨胀本表。
22
+
23
+ ## 跨模块契约(可选)
24
+
25
+ | 契约 | 提供方 module_id | 消费方 | 说明 |
26
+ |------|------------------|--------|------|
27
+ | `(例:UserDTO)` | `core` | `api` | 共享类型 / OpenAPI schema |
28
+
29
+ ## 人签记录(嵌入后填写)
30
+
31
+ | human_gate_id | status | 签核人 | 日期 | 说明 |
32
+ |---------------|--------|--------|------|------|
33
+ | HG-GRAPH-MODULES | pending | | | `01_struct` 模块表覆盖一级模块 |
34
+
35
+ ## 关联
36
+
37
+ - 顶层图:[`00_main.md`](./00_main.md) · [`00_main.ai.md`](./00_main.ai.md)
38
+ - 主 flow 示例:[`10_flow_MAIN.md`](./10_flow_MAIN.md)
@@ -0,0 +1,7 @@
1
+ # 图谱版本时间线
2
+
3
+ | 日期 | 版本 | 事件 |
4
+ |------|------|------|
5
+ | YYYY-MM-DD | v0.1 | 首次嵌入用户仓(请替换为真实日期) |
6
+ | 2026-06-30 | v0.2 | 模板包迁移至 YAML-first:`00_main.graph.yaml`、`10_flow_MAIN.graph.yaml` 成为唯一编辑源;`.ai.md` 双轨文件弃用并删除;旧包脚本编译/校验流程上线 |
7
+ | 2026-08-24 | v1.2.4 | DEF-006:编译/校验命令面迁移至本包 `npx spec-wave graph yaml compile|export|check`;生成物 md 以本包编译器重生成 |
@@ -0,0 +1,105 @@
1
+ graph_id: "10_flow_MAIN"
2
+ title: "主路径 Flow 示例"
3
+ description: "典型 HTTP 请求从入口到响应的主干流程"
4
+ version: "2026-06-30"
5
+
6
+ nodes:
7
+ - id: "IN"
8
+ label: "HTTP 请求"
9
+ - id: "AUTH"
10
+ label: "鉴权 / 会话校验"
11
+ - id: "VAL"
12
+ label: "参数校验"
13
+ - id: "SVC"
14
+ label: "业务服务层"
15
+ - id: "ERR_AUTH"
16
+ label: "Auth Failed"
17
+ - id: "ERR_VAL"
18
+ label: "Validation Failed"
19
+ - id: "REPO"
20
+ label: "仓储 / ORM"
21
+ - id: "DB"
22
+ label: "数据库 / 存储"
23
+ - id: "HIT"
24
+ label: "record exists?"
25
+ - id: "NOTFOUND"
26
+ label: "404 / 空结果"
27
+ - id: "BIZERR"
28
+ label: "4xx 业务错误"
29
+ - id: "RESP"
30
+ label: "组装响应 DTO"
31
+ - id: "OUT"
32
+ label: "返回 JSON / 页面"
33
+ - id: "LOG"
34
+ label: "结构化日志"
35
+ - id: "MAIN_DOC"
36
+ label: ">00_main.md"
37
+
38
+ edges:
39
+ - from: "IN"
40
+ to: "AUTH"
41
+ label: "->"
42
+ anchors:
43
+ - path: "middleware/auth.py"
44
+ symbol: "require_user"
45
+ - from: "AUTH"
46
+ to: "VAL"
47
+ label: "[ok]"
48
+ - from: "AUTH"
49
+ to: "ERR_AUTH"
50
+ label: "[err]"
51
+ anchors:
52
+ - path: "middleware/auth.py"
53
+ line: 42
54
+ - from: "VAL"
55
+ to: "SVC"
56
+ label: "[ok]"
57
+ anchors:
58
+ - path: "services/resource_service.py"
59
+ symbol: "handle"
60
+ - from: "VAL"
61
+ to: "ERR_VAL"
62
+ label: "[err]"
63
+ - from: "SVC"
64
+ to: "REPO"
65
+ label: "->"
66
+ anchors:
67
+ - path: "repositories/resource_repo.py"
68
+ symbol: "find_by_id"
69
+ - from: "REPO"
70
+ to: "DB"
71
+ label: "->"
72
+ anchors:
73
+ - path: "db/session.py"
74
+ - from: "REPO"
75
+ to: "HIT"
76
+ label: "?>"
77
+ - from: "HIT"
78
+ to: "NOTFOUND"
79
+ label: "[no]"
80
+ - from: "HIT"
81
+ to: "SVC"
82
+ label: "[yes]"
83
+ - from: "SVC"
84
+ to: "BIZERR"
85
+ label: "[err]"
86
+ anchors:
87
+ - path: "services/resource_service.py"
88
+ - from: "SVC"
89
+ to: "RESP"
90
+ label: "->"
91
+ - from: "RESP"
92
+ to: "OUT"
93
+ label: "->"
94
+ anchors:
95
+ - path: "handlers/resource.py"
96
+ symbol: "to_response"
97
+ - from: "OUT"
98
+ to: "LOG"
99
+ mark: "::archives"
100
+ type: "archives"
101
+ anchors:
102
+ - path: "observability/logger.py"
103
+ - from: "IN"
104
+ to: "MAIN_DOC"
105
+ label: "加载"
@@ -0,0 +1,103 @@
1
+ ---
2
+ graph_id: 10_flow_MAIN
3
+ version: 2026-06-30
4
+ generated_at: sha256-eb7519dfb81b42a1
5
+ source: 10_flow_MAIN.graph.yaml
6
+ ---
7
+
8
+ # 主路径 Flow 示例
9
+
10
+ 典型 HTTP 请求从入口到响应的主干流程
11
+
12
+ ## Mermaid
13
+
14
+ ```mermaid
15
+ flowchart TD
16
+ IN["HTTP 请求"]
17
+ AUTH["鉴权 / 会话校验"]
18
+ VAL["参数校验"]
19
+ SVC["业务服务层"]
20
+ ERR_AUTH["Auth Failed"]
21
+ ERR_VAL["Validation Failed"]
22
+ REPO["仓储 / ORM"]
23
+ DB["数据库 / 存储"]
24
+ HIT["record exists?"]
25
+ NOTFOUND["404 / 空结果"]
26
+ BIZERR["4xx 业务错误"]
27
+ RESP["组装响应 DTO"]
28
+ OUT["返回 JSON / 页面"]
29
+ LOG["结构化日志"]
30
+ MAIN_DOC[">00_main.md"]
31
+
32
+ IN --> AUTH
33
+ %% → middleware/auth.py::require_user
34
+ AUTH -->|"[ok]"| VAL
35
+ AUTH -->|"[err]"| ERR_AUTH
36
+ %% → middleware/auth.py#L42
37
+ VAL -->|"[ok]"| SVC
38
+ %% → services/resource_service.py::handle
39
+ VAL -->|"[err]"| ERR_VAL
40
+ SVC --> REPO
41
+ %% → repositories/resource_repo.py::find_by_id
42
+ REPO --> DB
43
+ %% → db/session.py
44
+ REPO -->|"?>"| HIT
45
+ HIT -->|"[no]"| NOTFOUND
46
+ HIT -->|"[yes]"| SVC
47
+ SVC -->|"[err]"| BIZERR
48
+ %% → services/resource_service.py
49
+ SVC --> RESP
50
+ RESP --> OUT
51
+ %% → handlers/resource.py::to_response
52
+ OUT -->|"::archives"| LOG
53
+ %% → observability/logger.py
54
+ IN -->|"加载"| MAIN_DOC
55
+
56
+ classDef phase fill:#e1f5fe,stroke:#01579b,stroke-width:2px
57
+ classDef doc fill:#fff8e1,stroke:#ff6f00,stroke-width:1px
58
+ classDef infra fill:#e8f5e9,stroke:#2e7d32,stroke-width:1px
59
+ class MAIN_DOC doc
60
+ class AUTH infra
61
+ ```
62
+
63
+ ## Structured Data
64
+
65
+ ### Nodes
66
+
67
+ | ID | Label | Kind |
68
+ |----|-------|------|
69
+ | IN | HTTP 请求 | |
70
+ | AUTH | 鉴权 / 会话校验 | |
71
+ | VAL | 参数校验 | |
72
+ | SVC | 业务服务层 | |
73
+ | ERR_AUTH | Auth Failed | |
74
+ | ERR_VAL | Validation Failed | |
75
+ | REPO | 仓储 / ORM | |
76
+ | DB | 数据库 / 存储 | |
77
+ | HIT | record exists? | |
78
+ | NOTFOUND | 404 / 空结果 | |
79
+ | BIZERR | 4xx 业务错误 | |
80
+ | RESP | 组装响应 DTO | |
81
+ | OUT | 返回 JSON / 页面 | |
82
+ | LOG | 结构化日志 | |
83
+ | MAIN_DOC | >00_main.md | |
84
+
85
+ ### Edges
86
+
87
+ | From | To | Mark | Type | Label | Anchors |
88
+ |------|----|------|------|-------|---------|
89
+ | IN | AUTH | -> | depends_on | -> | 1 anchor(s) |
90
+ | AUTH | VAL | -> | depends_on | [ok] | |
91
+ | AUTH | ERR_AUTH | -> | depends_on | [err] | 1 anchor(s) |
92
+ | VAL | SVC | -> | depends_on | [ok] | 1 anchor(s) |
93
+ | VAL | ERR_VAL | -> | depends_on | [err] | |
94
+ | SVC | REPO | -> | depends_on | -> | 1 anchor(s) |
95
+ | REPO | DB | -> | depends_on | -> | 1 anchor(s) |
96
+ | REPO | HIT | ?> | condition | ?> | |
97
+ | HIT | NOTFOUND | -> | depends_on | [no] | |
98
+ | HIT | SVC | -> | depends_on | [yes] | |
99
+ | SVC | BIZERR | -> | depends_on | [err] | 1 anchor(s) |
100
+ | SVC | RESP | -> | depends_on | -> | |
101
+ | RESP | OUT | -> | depends_on | -> | 1 anchor(s) |
102
+ | OUT | LOG | ::archives | archives | | 1 anchor(s) |
103
+ | IN | MAIN_DOC | -> | depends_on | 加载 | |
@@ -0,0 +1,156 @@
1
+ # Mermaid 拓扑协议(通用 · v3)
2
+
3
+ > **用途**:`docs/_tech_graph/99_mermaid_protocol.md` — flowchart 边标记、节点形状与 YAML-first 生成真值。
4
+
5
+ ## 0. YAML-first 工作流
6
+
7
+ - **唯一人工编辑源**:`*.graph.yaml`(本目录下如 `00_main.graph.yaml`、`10_flow_MAIN.graph.yaml`)。
8
+ - **生成物**:同名 `*.md` 由本包 CLI `npx spec-wave graph yaml compile`(`--graph-id ID` 或 `--all`)自动生成,包含 YAML frontmatter、Mermaid flowchart、Nodes/Edges 表。frontmatter / `graph.json` 的 `generated_at` 为 yaml 源内容戳 `sha256-<16hex>`(同字节重编译 / export 幂等),不是 wall-clock。
9
+ - **禁止手写 `.md`**:如需改图,改 YAML 源后重新运行 `graph yaml compile`;手改生成物会被下次编译覆盖。
10
+ - **一致性校验**:`graph yaml check` 比对的是 YAML 源与 `graph.json` 切片(按 graph_id 过滤节点/边),需先 `graph yaml export` 生成 `shared/graph.json`;本包不校验 `.md` 与 `.graph.yaml` 的同步(md 由编译单一来源生成,见 §7)。
11
+ - **历史 `.ai.md` 双轨已弃用**:Post-G0 后不再维护 `.md` + `.ai.md` 两份文件;所有结构化信息(锚点、边类型)集中在 YAML 源中。
12
+
13
+ ---
14
+
15
+ ## 1. 边标记
16
+
17
+ ### 1.1 执行流
18
+
19
+ | 标记 | 语义 | 何时用 |
20
+ |------|------|--------|
21
+ | `->` | 同步顺序执行 | 普通调用 |
22
+ | `~>` | 异步 / await | 非阻塞 I/O |
23
+ | `=>` | 赋值 / 映射 | 数据转换 |
24
+ | `?>` | 条件分支 | if / switch / 路由 |
25
+
26
+ ### 1.2 状态与可靠性
27
+
28
+ | 标记 | 语义 | 示例 |
29
+ |------|------|------|
30
+ | `[ok]` | 成功路径 | `validate() -->|"[ok]"| save()` |
31
+ | `[err]` | 失败 / 异常 | `parse() -->|"[err]"| fallback()` |
32
+ | `[retry=N]` | 重试 | `call_api() -->|"[retry=3]"| call_api()` |
33
+ | `[timeout]` | 超时降级 | `fetch() -->|"[timeout]"| cache_get()` |
34
+
35
+ > 示例采用官方边上文字形态 `A-->|text|B`(见 §7 输出契约);旧形态 `--"[ok]"-->` 已弃用,IDE 预览不保证可渲染。
36
+
37
+ ### 1.3 元关系(`::` 命名空间)
38
+
39
+ | 标记 | 语义 |
40
+ |------|------|
41
+ | `::yields` | 流式 / 生成器产出 |
42
+ | `::triggers` | 触发子流程或后台任务 |
43
+ | `::gates` | 门禁 / 鉴权 / 依赖注入 |
44
+ | `::branches` | 并行分支 |
45
+ | `::merges` | 多路归并 |
46
+ | `::signoff` | 持久化确认 / 事务提交 |
47
+ | `::archives` | 日志 / 审计归档 |
48
+
49
+ ---
50
+
51
+ ## 2. 节点形状(flowchart)
52
+
53
+ | 形状 | 含义 | 示例 |
54
+ |------|------|------|
55
+ | `[["..."]]` | 阶段 / 流程块 | `Q[["Query Phase"]]` |
56
+ | `["..."]` | 函数 / 操作(编译器默认,文本一律加引号) | `step["process_request"]` |
57
+ | `[">..."]` | 文档指针(`>` 前缀保留在引号文本内) | `FLOW_DOC[">10_flow_MAIN.md"]` |
58
+ | `[(...)]` | 数据 / 模型(手写图可用) | `db[(UserRecord)]` |
59
+ | `{...}` | 判断 / 路由(手写图可用) | `gw{authorized?}` |
60
+ | `((...))` | 循环 / 归档(手写图可用) | `log((write_log))` |
61
+
62
+ ---
63
+
64
+ ## 3. 锚点规则(YAML 源强制)
65
+
66
+ 每条 **硬边** 须可追溯到代码或文档,写在 YAML `edges[].anchors` 中:
67
+
68
+ ```yaml
69
+ edges:
70
+ - from: "Q"
71
+ to: "E"
72
+ anchors:
73
+ - path: "src/main.py"
74
+ line: 1
75
+ - path: "app/router/index.ts"
76
+ symbol: "Router"
77
+ ```
78
+
79
+ - 跨模块调用:使用 `::triggers` 或虚线,**不**展开对方内部。
80
+ - 未知锚点:保留 `path: TBD` 并开 task 补全。
81
+
82
+ ---
83
+
84
+ ## 4. 分层与折叠
85
+
86
+ | 条件 | 操作 |
87
+ |------|------|
88
+ | 子图节点 ≤ 7 | 可在主图展开 |
89
+ | 子图节点 > 7 | 折叠为 `[[Phase]]`,链独立 `10_flow_*.md` |
90
+ | 异常分支 | 挂侧链;Happy Path 走主干 |
91
+
92
+ ---
93
+
94
+ ## 5. 禁止项
95
+
96
+ - **禁止**维护 `.ai.md` 双轨文件。
97
+ - **禁止**在生成的 `.md` 中直接手写 flowchart(会被下次编译覆盖)。
98
+ - 禁止虚构文件路径;未知处用 `path: TBD` 并开 task 补锚点。
99
+ - **禁止** onboarding 默认「全仓扫描生图」。
100
+
101
+ ---
102
+
103
+ ## 6. YAML 字段到 Mermaid 映射
104
+
105
+ | YAML 字段 | Mermaid 输出 | 说明 |
106
+ |-----------|--------------|------|
107
+ | `nodes[].id` | 节点 ID | 必须唯一 |
108
+ | `nodes[].label` | 节点显示文本 | 决定节点形状 |
109
+ | `edges[].from` / `to` | 边两端 | 必须引用存在的节点 |
110
+ | `edges[].label` | 边标签 | `"->"` 表示裸执行边 |
111
+ | `edges[].mark` | 元关系标记 | 如 `::triggers`、`::branches` |
112
+ | `edges[].type` | 边类型 | 与 `mark` 命名空间对应 |
113
+ | `edges[].anchors` | `%% → path[#Ln|::symbol]` 独立注释行;Edges 表 Anchors 列渲染为 `N anchor(s)` 摘要 | 代码追溯 |
114
+
115
+ > 编译器 Edges 表列序固定为 `From | To | Mark | Type | Label | Anchors`(与 §7 输出契约同源)。
116
+
117
+ ---
118
+
119
+ ## 7. IDE 预览兼容 · 编译器输出契约
120
+
121
+ > 语法真值(改编译器 emit 前必读,禁止凭记忆):
122
+ > 官网 [Diagram Syntax](https://mermaid.js.org/intro/syntax-reference.html)(注释只认 `%%`)·
123
+ > [Flowchart](https://mermaid.js.org/syntax/flowchart.html);
124
+ > 本地对照 `mermaid/packages/mermaid/src/docs/syntax/flowchart.md`
125
+ >(§ Links between nodes · § Text on links · § A link with arrow head and text · § Special characters that break syntax · § Comments)。
126
+
127
+ `graph yaml compile` 生成物 **默认 emit 形态**(Cursor / IDE Markdown 预览与 mermaid-cli 均可渲染):
128
+
129
+ | 元素 | 默认输出 | 依据 |
130
+ |------|----------|------|
131
+ | 锚点注释 | `%% → path#Ln`(独立行) | flowchart.md § Comments:注释仅 `%%` 前缀 |
132
+ | 带标签边 | `src -->|"label"| dst` | flowchart.md § A link with arrow head and text:`A-->|text|B` |
133
+ | 裸边 | `src --> dst`(yaml `label: "->"` 或无 label) | flowchart.md § A link with arrow head |
134
+ | 节点 | `id["label"]`(文本一律双引号包裹) | flowchart.md § Special characters that break syntax |
135
+ | 子流程节点 | `id[["label"]]`(文本同样加引号) | 同上 |
136
+ | label 转义 | `"` → `#quot;` · `|` → `#124;` · `#` → `#35;` | flowchart.md § Entity codes to escape characters |
137
+
138
+ **禁止作为编译器默认输出**(IDE 预览会静默解析失败:节点横排一行、边丢失):
139
+
140
+ - `--"label"-->`(旧边形态,非官方推荐)
141
+ - `//` 行注释(非 Mermaid 语法)
142
+ - 含空格 / `()` / `/` / `+` / `>` 等字符却未加引号的节点标签
143
+
144
+ **消费者升级指引**:升级 dsh-coding-kit 后须重跑 `graph yaml compile`(或 `graph yaml compile --all`)重新生成 `*.md`;手改生成物会被下次编译覆盖。
145
+
146
+ ---
147
+
148
+ ## 8. 修订记录
149
+
150
+ | 日期 | 说明 |
151
+ |------|------|
152
+ | 2026-06-30 | v3:YAML-first,删除 `.ai.md` 双轨,新增 YAML → Mermaid 映射 |
153
+ | 2026-08-24 | DEF-023:新增 §7 IDE 预览兼容输出契约;§1.2/§2 示例改官方 `-->|"…"|` 与引号节点形态;锚点注释改 `%%` |
154
+ | 2026-08-24 | DEF-006:§0 编译器名改本包 `npx spec-wave graph yaml compile`;`check` 语义如实改写为 YAML↔graph.json 切片比对(需先 `export`);§6 补 Edges 表列序与锚点摘要化说明 |
155
+ | 2026-08-28 | §0:`generated_at` 改为 yaml 源内容戳(幂等),不是 wall-clock |
156
+ | YYYY-MM-DD | 嵌入用户仓时填写首次版本 |
@@ -0,0 +1,66 @@
1
+ # graph/templates
2
+
3
+ 复制到用户仓 **`docs/_tech_graph/`**。
4
+
5
+ ## v0.2 已交付模板(T2 · YAML-first)
6
+
7
+ | 文件 | 状态 | 说明 |
8
+ |------|------|------|
9
+ | [`00_main.graph.yaml`](./00_main.graph.yaml) | ✅ | 顶层流程(唯一编辑源) |
10
+ | [`00_main.md`](./00_main.md) | ✅ | 顶层流程(编译生成物) |
11
+ | [`01_struct.md`](./01_struct.md) | ✅ | **模块边界表**(D4-a · **HG-GRAPH-MODULES** 人签真值) |
12
+ | [`10_flow_MAIN.graph.yaml`](./10_flow_MAIN.graph.yaml) | ✅ | 主路径 flow 示例(唯一编辑源) |
13
+ | [`10_flow_MAIN.md`](./10_flow_MAIN.md) | ✅ | 主路径 flow 示例(编译生成物) |
14
+ | [`99_mermaid_protocol.md`](./99_mermaid_protocol.md) | ✅ | Mermaid 拓扑协议(YAML-first) |
15
+
16
+ ## 仍可选补(非 T1 硬门槛)
17
+
18
+ | 文件 | 说明 |
19
+ |------|------|
20
+ | `02_version.md` | 版本时间线;新仓建议嵌入后首周补 |
21
+
22
+ ## 编辑与复制流程
23
+
24
+ 1. **改图**:只改 `.graph.yaml`,不要手写 `.md`。
25
+ 2. **编译**(业务仓根,本包作为依赖安装后):
26
+ ```bash
27
+ npx spec-wave graph yaml compile --all --input docs/_tech_graph
28
+ ```
29
+ 3. **校验**(两步:先 `export` 生成 `shared/graph.json`,再 `check` 做 YAML ↔ graph.json 切片比对):
30
+ ```bash
31
+ npx spec-wave graph yaml export --input docs/_tech_graph
32
+ npx spec-wave graph yaml check --all --input docs/_tech_graph
33
+ ```
34
+ 4. **复制到业务仓**(模板源在本包 assets 内):
35
+ ```bash
36
+ mkdir -p docs/_tech_graph
37
+ cp -R node_modules/spec-wave/assets/graph/templates/* docs/_tech_graph/
38
+ # 按需删除 README 或本说明段
39
+ ```
40
+
41
+ ## 业务仓专属产物
42
+
43
+ 以下文件是业务仓运行时 artifact,**不在模板包中生成空壳**:
44
+
45
+ - `_manifest.json`
46
+ - `_contract_manifest.json`
47
+ - `_test_manifest.json`
48
+
49
+ 业务仓应基于真实 endpoint / RPC / 表 / 事件契约,通过自身 CI(如 `tech-graph.yml`、`tech-graph-contract.yml`)生成并校验这些 manifest。模板包仅提供 `.graph.yaml` → `.md` 的简化编译流。
50
+
51
+ ## 嵌入后
52
+
53
+ - **新仓**:骨架 + 模块表人签 + 至少 1 主 flow(见薄指针页 [`POINTER_ONBOARDING.md`](../../docs/POINTER_ONBOARDING.md) · 原文 §3)
54
+ - **存量**:按 ONBOARDING 档位 S0~S3;**禁止**首次全 flow 构图
55
+ - **人签**:`01_struct` 模块表 → **HG-GRAPH-MODULES** approved → 允许 30 改码
56
+
57
+ ## 本包 dogfood
58
+
59
+ kit **源码仓**自图在 `docs/_tech_graph/`(L0 `00_main` · L1 `01_struct` · L2 四条 `10_flow_*`);CI 为 `.github/workflows/tech-graph.yml`(本仓 bin compile/check)。
60
+ **`docs/` 不随 npm 包发布**;请到源码仓查看:https://github.com/Cyning12/SpecGate/tree/main/docs/_tech_graph
61
+
62
+ ## 历史说明
63
+
64
+ - v0.1 使用 `.md` + `.ai.md` 双轨;v0.2 起改为 YAML-first,`.ai.md` 已弃用。
65
+ - 复杂业务仓应采用 `.graph.yaml` 源 + manifest/contract CI;本模板包(dsh-coding-kit)维持简化编译流。
66
+ - v1.2.4(DEF-006):编译/校验命令面迁移至本包 `npx spec-wave graph yaml compile|export|check`;`00_main.md`/`10_flow_MAIN.md` 以本包编译器重生成(输出契约见 `99_mermaid_protocol.md` §7)。
@@ -0,0 +1,18 @@
1
+ # harness · 过程轨
2
+
3
+ | 子目录 | 内容 | T3 状态 |
4
+ |--------|------|---------|
5
+ | [`templates/`](templates/) | task、Epic、graph_bootstrap | ✅ v0.1 |
6
+ | [`prompts/`](prompts/) | 10/22/30 Starter 子集 | ✅ v0.1 |
7
+ | [`invokes/`](invokes/) | invoke 落盘约定 + TEMPLATE | ✅ v0.1 |
8
+
9
+ 用户仓对应路径建议:`docs/tasks/`、`docs/harness/prompts/`、`docs/harness/invokes/`。
10
+
11
+ ## 嵌入一键清单
12
+
13
+ ```bash
14
+ mkdir -p docs/tasks/active docs/harness/prompts docs/harness/invokes/by-task docs/harness/reviews
15
+ cp -R harness/templates/* docs/tasks/ # 或按需单文件复制并重命名
16
+ cp harness/prompts/*.md docs/harness/prompts/
17
+ cp harness/invokes/TEMPLATE_invoke.md docs/harness/invokes/
18
+ ```