@rosenfan/matrix 0.1.2 → 0.1.4

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 (37) hide show
  1. package/.claude/skills/matrix/SKILL.md +59 -62
  2. package/.claude/skills/matrix/scripts/matrix_claude.py +11 -11
  3. package/.claude/skills/matrix/scripts/matrix_state.py +53 -53
  4. package/.claude/skills/matrix-archive/SKILL.md +36 -33
  5. package/.claude/skills/matrix-build/SKILL.md +28 -23
  6. package/.claude/skills/matrix-claude/SKILL.md +13 -11
  7. package/.claude/skills/matrix-design/SKILL.md +32 -26
  8. package/.claude/skills/matrix-hotfix/SKILL.md +1 -1
  9. package/.claude/skills/matrix-open/SKILL.md +27 -15
  10. package/.claude/skills/matrix-status/SKILL.md +5 -5
  11. package/.claude/skills/matrix-tweak/SKILL.md +1 -1
  12. package/.claude/skills/matrix-verify/SKILL.md +35 -17
  13. package/README.md +131 -96
  14. package/README.zh-CN.md +127 -92
  15. package/assets/skills-zh-CN/matrix/SKILL.md +75 -72
  16. package/assets/skills-zh-CN/matrix-archive/SKILL.md +36 -33
  17. package/assets/skills-zh-CN/matrix-build/SKILL.md +41 -37
  18. package/assets/skills-zh-CN/matrix-claude/SKILL.md +33 -31
  19. package/assets/skills-zh-CN/matrix-design/SKILL.md +13 -7
  20. package/assets/skills-zh-CN/matrix-hotfix/SKILL.md +1 -1
  21. package/assets/skills-zh-CN/matrix-open/SKILL.md +18 -6
  22. package/assets/skills-zh-CN/matrix-status/SKILL.md +5 -5
  23. package/assets/skills-zh-CN/matrix-tweak/SKILL.md +1 -1
  24. package/assets/skills-zh-CN/matrix-verify/SKILL.md +27 -9
  25. package/package.json +2 -2
  26. package/src/catalog.js +29 -18
  27. package/src/cli.js +150 -39
  28. package/src/distribution.js +268 -114
  29. package/src/installer.js +10 -10
  30. package/src/matt-catalog.mjs +67 -0
  31. package/src/matt.js +115 -33
  32. package/src/messages.js +18 -14
  33. package/src/runtime-resolver.js +76 -0
  34. package/src/self-update.js +81 -0
  35. package/src/ui.js +1 -1
  36. package/src/workflow-transaction.js +622 -618
  37. package/src/workflow.js +949 -464
package/README.zh-CN.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Matrix Workflow
2
2
 
3
- 一个提供 Prim 与 Arch 编排的证据驱动开发工作流,灵感来自 [Comet](https://github.com/rpamis/comet)。Matrix 可以使用自身能力,也可以按事实调用已验证的 [Matt Pocock agent skills](https://github.com/mattpocock/skills),但生命周期所有权始终由 Matrix 保持。
3
+ 一个提供 Prim 与 Arch 编排的证据驱动开发工作流,灵感来自 [Comet](https://github.com/rpamis/comet)。Matrix 可以使用自身能力,也可以按事实调用已验证的 [Matt Pocock agent skills](https://github.com/mattpocock/skills),但生命周期所有权始终由 Matrix 保持。
4
4
 
5
5
  **[English](./README.md)** | 中文
6
6
 
@@ -27,38 +27,39 @@
27
27
 
28
28
  ## 为什么需要 Matrix
29
29
 
30
- [Matt Pocock 的 skills](https://github.com/mattpocock/skills) 提供 `/grilling`、`/tdd`、`/code-review` 等聚焦能力。但缺少统一生命周期所有者时会导致常见问题:
30
+ [Matt Pocock 的 skills](https://github.com/mattpocock/skills) 提供 `/grilling`、`/tdd`、`/code-review` 等聚焦能力。但缺少统一生命周期所有者时会导致常见问题:
31
31
 
32
32
  - **无流程记忆**:你进行了 grilling,然后实现,但没有记录决策过程
33
33
  - **阶段混乱**:设计完成了吗?我们在构建阶段吗?上下文丢失后很难判断
34
34
  - **静默范围蔓延**:需求在构建过程中变更,却没有返回设计阶段
35
35
  - **缺少证据**:"看起来完成了"却没有验证证明
36
36
 
37
- Matrix 通过唯一的确定性状态机解决这些问题 —— 包含明确的阶段、守卫条件和产物追踪。Skill 可以协助阶段,但生命周期始终由 Matrix 拥有。
37
+ Matrix 通过唯一的确定性状态机解决这些问题 —— 包含明确的阶段、守卫条件和产物追踪。Skill 可以协助阶段,但生命周期始终由 Matrix 拥有。
38
38
 
39
39
  ---
40
40
 
41
41
  ## 它做了什么
42
42
 
43
- Matrix 在同一条工作流上提供两种能力编排:
43
+ Matrix 在集中定义的两种 workflow profile 上提供两种能力编排:
44
44
 
45
45
  ```
46
- open → design → build → verify → archive
47
-
48
- Prim:Matrix 使用自身能力
49
- Arch:仅在任务事实满足触发条件时调用已验证的原子 Skill
50
- ```
51
-
52
- 恢复路径由 Runtime 受控执行:
53
-
54
- ```text
55
- build --design-gap--------------------> design
56
- verify --verification-failed-----------> build
57
- verify --acceptance-or-design-gap------> design
58
- 任意活动阶段 --abort-------------------> aborted
59
- ```
60
-
61
- 每个阶段:
46
+ full: open → design → build → verify → archive
47
+ hotfix/tweak lightweight:open ─────────→ build → verify → archive
48
+
49
+ Prim:Matrix 使用自身能力
50
+ Arch:仅在任务事实满足触发条件时调用已验证的原子 Skill
51
+ ```
52
+
53
+ 恢复路径由 Runtime 受控执行:
54
+
55
+ ```text
56
+ build --design-gap--------------------> design
57
+ verify --verification-failed-----------> build
58
+ verify --acceptance-or-design-gap------> design
59
+ 任意活动阶段 --abort-------------------> aborted
60
+ ```
61
+
62
+ 每个阶段:
62
63
  - 有特定的交付物(产物)
63
64
  - 有必须通过的守卫条件
64
65
  - 记录所有转换
@@ -68,9 +69,10 @@ verify --acceptance-or-design-gap------> design
68
69
 
69
70
  ## 前置条件
70
71
 
71
- - 已安装 [Claude Code](https://docs.anthropic.com/claude-code)
72
- - Node.js 18+(用于运行安装器)
73
- - Python 3.8+ 已添加到 PATH
72
+ - 已安装 [Claude Code](https://docs.anthropic.com/claude-code) 和/或 Codex,作为 Skill 宿主
73
+ - Node.js 18+,且 `npm` 已加入 PATH(用于 Matrix CLI)
74
+ - Python 仅在兼容窗口内的旧适配器路径使用;新安装使用内置 Node workflow runtime
75
+ - Git 仅在从 GitHub 安装或参与 Matrix 开发时需要
74
76
 
75
77
  ---
76
78
 
@@ -91,26 +93,48 @@ matrix init
91
93
 
92
94
  交互式初始化支持:
93
95
 
94
- - 选择安装到当前项目或全局
96
+ - 选择 Matrix Skill 发现入口安装到当前项目或全局
95
97
  - 复制 skills(推荐)或为本地开发创建符号链接
96
- - 更新已有安装,并自动备份被替换的 Matrix 文件
97
- - 在同一流程中安装 Matt Pocock 的配套 skills
98
- - 选择 Prim 或 Arch 作为项目默认值,且不禁用另一种可用模式
98
+ - 安全地重新配置已有安装,并自动备份被替换的 Matrix 文件
99
+ - 审查 Matt Skills v1.2.3 官方 25 项角色,并在目标项目安装其中 23 项兼容 Skill
100
+ - 选择 Prim 或 Arch 作为项目默认值,且不禁用另一种可用模式
99
101
 
100
102
  自动化或 CI 环境可以使用:
101
103
 
102
104
  ```bash
103
105
  # 使用推荐的项目级默认值,不显示交互问题
104
- matrix init --yes --with-mattpocock
105
-
106
+ matrix init --yes --with-mattpocock
107
+
106
108
  # 显式选择项目默认编排
107
109
  matrix init --yes --with-mattpocock --default-orchestration arch
110
+
111
+ # 只有明确授权备份后才替换被本地修改的 Matt Skills
112
+ matrix init --yes --with-mattpocock --force-matt
108
113
 
109
114
  # 检查安装完整性和运行环境
110
115
  matrix doctor
111
116
  ```
112
117
 
113
- npm 包正式发布前,也可以直接从 GitHub 安装:
118
+ 更新已经初始化的项目:
119
+
120
+ ```bash
121
+ # 检查新版 Matrix CLI,确认计划后更新 CLI 并同步当前项目资产
122
+ matrix update
123
+
124
+ # 离线或本地开发:不访问 npm registry,只用当前 CLI 同步资产
125
+ matrix update --skip-self-update
126
+
127
+ # 已在自动化中明确授权写入
128
+ matrix update --yes
129
+ ```
130
+
131
+ `matrix update` 会保留既有安装的 scope、平台、语言、mode 与 orchestration。它先隔离验证 npm 新包,再由新 CLI 同步 Matrix 资产;它绝不下载、安装、修复或删除 Matt Skills。Matrix 更新完成后只读报告项目 Matt 兼容状态,必要时提示 `matrix init . --with-mattpocock`。npm 与项目资产是两个事务:若 CLI 已更新但资产同步失败,可运行 `matrix update --skip-self-update` 重试。
132
+
133
+ Matrix 0.1.4 固定对应 Matt Skills v1.2.3,commit 为 `6acc160e4e0cd062dbbbd7a1b26ae92855edf07e`。即使上游已有新版,`matrix init --with-mattpocock` 仍使用该确切 archive 与经过审查的 23 项兼容 manifest。官方角色中的 `implement` 与 raw `resolving-merge-conflicts` 不兼容,因此 Matrix 不安装也不管理它们。Matrix scope 只控制 Matrix Skill 的发现位置;Matt Skills 与 `.matrix/matt-installation.json` 始终属于目标项目。全局 Matt 副本会保留,但绝不用于补齐项目 readiness。
134
+
135
+ `matrix init` 选择的语言决定新 Matrix 产物的正文语言:`zh-CN` 使用中文、`en` 使用英文。Runtime 守卫依赖的 Markdown 英文标题 token 保持不变;每个 change 在创建时冻结该语言。
136
+
137
+ 也可以直接从 GitHub 安装,而不是 npm:
114
138
 
115
139
  ```bash
116
140
  npm install --global github:Rosenfan/Matrix
@@ -118,10 +142,10 @@ npm install --global github:Rosenfan/Matrix
118
142
 
119
143
  Matrix 将安装:
120
144
  - `matrix/` — 入口点和状态管理
121
- - `matrix-open/` — Open 阶段与 canonical proposal
122
- - `matrix-design/` — Design、plan 与 Contract 批准
123
- - `matrix-build/` — 有界实现与构建证据
124
- - `matrix-verify/` — 测试和双轴审查证据
145
+ - `matrix-open/` — Open 阶段与 canonical proposal
146
+ - `matrix-design/` — Design、plan 与 Contract 批准
147
+ - `matrix-build/` — 有界实现与构建证据
148
+ - `matrix-verify/` — 测试和双轴审查证据
125
149
  - `matrix-archive/` — 归档阶段
126
150
  - `matrix-hotfix/` — 小型 Bug 快捷方式
127
151
  - `matrix-tweak/` — 有界变更快捷方式
@@ -139,8 +163,8 @@ $matrix 我想给 API 添加用户认证
139
163
  ```
140
164
 
141
165
  Matrix 将会:
142
- 1. 用工作流类型 `full` 和冻结的 `prim|arch` 编排初始化变更
143
- 2. 进入 `open`;Prim 直接处理,Arch 只调用已证明的需求触发能力
166
+ 1. 用工作流类型 `full` 和冻结的 `prim|arch` 编排初始化变更
167
+ 2. 进入 `open`;Prim 直接处理,Arch 只调用已证明的需求触发能力
144
168
  3. 创建 `proposal.md`,包含目标、范围、验收标准、风险
145
169
  4. 守卫检查:所有章节是否内容充实?
146
170
  5. 如果通过 → 转换到 `design`
@@ -149,13 +173,13 @@ Matrix 将会:
149
173
 
150
174
  ## 工作流阶段
151
175
 
152
- | 阶段 | Arch 能力(按事实触发,不是固定序列) | 交付物 | 守卫条件 |
153
- |------|----------------------------------------|--------|----------|
154
- | **open** | `/grilling`、`/domain-modeling` | `proposal.md`;可选仓库约定的 context/ADR 证据 | 目标、范围、验收标准、风险存在 |
155
- | **design** | `/domain-modeling`、`/research`、`/wayfinder`、`/prototype`、`/codebase-design` | `design.md`、`plan.md` | 决策、测试点、步骤已记录 |
156
- | **build** | `/tdd`、`/diagnosing-bugs`、`/resolving-merge-conflicts` | 代码、`verification.md` | 已批准的精确 Contract 匹配,且已记录构建证据 |
157
- | **verify** | `/code-review` | 测试和审查证据 | 测试和审查证据存在 |
158
- | **archive** | 无;两种模式均由 Matrix 拥有 | 归档记录 | 验证守卫通过 |
176
+ | 阶段 | Arch 能力(按事实触发,不是固定序列) | 交付物 | 守卫条件 |
177
+ |------|----------------------------------------|--------|----------|
178
+ | **open** | `/grilling`、`/domain-modeling` | `proposal.md`;可选仓库约定的 context/ADR 证据 | 目标、范围、验收标准、风险存在 |
179
+ | **design** | `/domain-modeling`、`/research`、`/prototype`、`/codebase-design`、条件触发的 `/writing-for-agents` | `design.md`、`plan.md` | 决策、测试点、步骤已记录 |
180
+ | **build** | `/tdd`、`/diagnosing-bugs`、条件触发的 `/writing-for-agents` 与仅生成的 `/wizard` | 代码、`verification.md` | 已批准的精确 Contract 匹配,且已记录构建证据 |
181
+ | **verify** | `/code-review` | 测试证据、双轴审查、Arch 回执 | 证据内容充分;Arch 回执匹配当前 Contract、审查正文和工作区 |
182
+ | **archive** | 无;两种模式均由 Matrix 拥有 | 归档记录 | 验证守卫通过 |
159
183
 
160
184
  ---
161
185
 
@@ -169,45 +193,50 @@ Matrix 将会:
169
193
  ├── config.yaml
170
194
  ├── changes/
171
195
  │ └── <change-id>/
172
- │ ├── matrix.yaml # 唯一 workflow、orchestration、阶段、状态与 revision 事实
173
- │ ├── events.jsonl
174
- │ └── artifacts/
175
- │ ├── proposal.md
176
- │ ├── design.md
177
- │ ├── plan.md
178
- │ ├── verification.md
179
- │ └── evidence-history/
180
- └── archive/
181
- ```
196
+ │ ├── matrix.yaml # 唯一 workflow、orchestration、阶段、状态与 revision 事实
197
+ │ ├── workspace-baseline.json # lightweight 的实施顺序边界
198
+ │ ├── events.jsonl
199
+ │ └── artifacts/
200
+ │ ├── proposal.md
201
+ │ ├── design.md
202
+ │ ├── plan.md
203
+ │ ├── verification.md
204
+ │ └── evidence-history/
205
+ └── archive/
206
+ ```
182
207
 
183
208
  状态机强制执行转换:
184
209
 
185
210
  ```bash
186
- # 检查守卫
187
- matrix workflow guard open
188
-
189
- # 推进(仅在守卫通过时)
190
- matrix workflow transition design
191
-
192
- # 验证失败时返回 Build;旧证据保留在历史目录
193
- matrix workflow return build --reason verification-failed
194
-
195
- # 终止变更但保留产物,不撤销工作区代码
196
- matrix workflow abort --reason requirement-cancelled
197
-
198
- # 最终归档强制使用两步乐观提交
199
- matrix workflow archive --dry-run
200
- matrix workflow archive --expect-preflight <dry-run-返回的-sha256>
201
-
202
- # 只读诊断中断的 Workflow
203
- matrix workflow doctor
204
-
205
- # 只恢复 doctor 明确报告的 transaction 或陈旧锁
206
- matrix workflow doctor --repair --transaction <id> --strategy <continue|rollback>
207
- matrix workflow doctor --repair --lock <id>
208
- ```
209
-
210
- `matrix.yaml` 是 workflow、orchestration、阶段、状态与 revision 的唯一事实来源,schema 为 `matrix/change/v2`;初始化解析出的 `prim|arch` 在整个 change 中冻结。旧 schema 会被拒绝且不会发生写入。`design -> build` 会记录 `proposal.md`、`design.md`、`plan.md` 精确字节的 SHA-256 身份;任一字节改动都会阻断 Build、Verify、Archive 和 Claude 导出,必须受控 Return 到 Design 后重新批准。最终 Archive 必须先只读 dry-run,再携带该 hash 提交;Runtime 在 Archive 事务边界内重算整个受保护 change 目录 manifest,发生漂移即拒绝。所有多文件 Workflow mutation 都由 `.matrix/transactions/` 下的持久 journal 保护;`matrix workflow doctor` 始终只读,恢复必须显式绑定其报告的 transaction/strategy 或 lock identity。终态 journal 会收缩为有界审计 receipt,未完成或冲突 journal 永不自动删除。
211
+ # 检查守卫
212
+ matrix workflow guard open
213
+
214
+ # 推进(仅在守卫通过时)
215
+ matrix workflow transition design
216
+
217
+ # lightweight:确认紧凑 proposal 后进入 Build
218
+ matrix workflow transition build --confirmed
219
+
220
+ # 验证失败时返回 Build;旧证据保留在历史目录
221
+ matrix workflow return build --reason verification-failed
222
+
223
+ # 终止变更但保留产物,不撤销工作区代码
224
+ matrix workflow abort --reason requirement-cancelled
225
+
226
+ # 最终归档强制使用两步乐观提交
227
+ matrix workflow archive --dry-run
228
+ matrix workflow archive --expect-preflight <dry-run-返回的-sha256>
229
+ # hotfix/tweak 的提交命令还必须带 --confirmed
230
+
231
+ # 只读诊断中断的 Workflow
232
+ matrix workflow doctor
233
+
234
+ # 只恢复 doctor 明确报告的 transaction 或陈旧锁
235
+ matrix workflow doctor --repair --transaction <id> --strategy <continue|rollback>
236
+ matrix workflow doctor --repair --lock <id>
237
+ ```
238
+
239
+ `matrix.yaml` 仍是 workflow、orchestration、阶段、状态与 revision 的唯一事实来源。full 批准 proposal/design/plan 的精确字节;lightweight 批准紧凑 proposal,要求明确确认,并与初始化工作区基线比较,阻止先实现后补方案。Contract 漂移会阻断后续阶段。最终 Archive 仍使用只读 dry-run 与 hash-bound commit,shortcut 还要求明确确认;所有多文件 mutation 继续受持久 journal 保护。
211
240
 
212
241
  ---
213
242
 
@@ -219,6 +248,8 @@ matrix workflow doctor --repair --lock <id>
219
248
  | **hotfix** | 可复现的小型 Bug | 简化:open → build → verify → archive |
220
249
  | **tweak** | 有界变更,无 API/架构影响 | 简化:open → build → verify → archive |
221
250
 
251
+ hotfix 与 tweak 引用同一个内部 `lightweight` 迁移 profile,只在入口和证据上区分:hotfix 要求复现、根因、回归证据;tweak 要求行为边界、diff 与范围审查证据。
252
+
222
253
  ---
223
254
 
224
255
  ## 特别功能:matrix-claude
@@ -235,7 +266,7 @@ $matrix → open → design → build → verify → archive
235
266
  |------|------|
236
267
  | 一个工具完成所有工作(默认) | 直接用 `$matrix`,无需额外步骤 |
237
268
  | Codex 设计 + Codex 实现 | 标准流程:design → build → verify |
238
- | Codex 设计 + Claude Code 实现 | design → build(批准 Contract)→ `$matrix-claude` → Claude Code → verify |
269
+ | Codex 设计 + Claude Code 实现 | design → build(批准 Contract)→ `$matrix-claude` → Claude Code → verify |
239
270
 
240
271
  ### matrix-claude 工作原理
241
272
 
@@ -249,30 +280,34 @@ $matrix → open → design → build → verify → archive
249
280
 
250
281
  ---
251
282
 
252
- ## 与 Matt Pocock Skills 的集成
253
-
254
- Prim 使用 Matrix 自身能力。Arch 使用初始化时验证的十项原子能力:
255
-
256
- | 阶段 | 能力 | 触发条件 |
257
- |---|---|---|
258
- | open | `/grilling` | 存在重大歧义或用户明确要求压力测试 |
259
- | open/design | `/domain-modeling` | 词汇、不变量或架构决定不清晰 |
260
- | design | `/research` | 仓库内无法获得必需的外部事实 |
261
- | design | `/wayfinder` | 模块归属或依赖接缝未知 |
283
+ ## 与 Matt Pocock Skills 的集成
284
+
285
+ Prim 使用 Matrix 自身能力。Matrix 会审查 Matt v1.2.3 官方 25 项角色,安装其中 23 项兼容 Skill,但 Arch 只自动调用以下十项经过审查的能力:
286
+
287
+ | 阶段 | 能力 | 触发条件 |
288
+ |---|---|---|
289
+ | open | `/grilling` | 存在重大歧义或用户明确要求压力测试 |
290
+ | open/design | `/domain-modeling` | 词汇、不变量或架构决定不清晰 |
291
+ | design | `/research` | 仓库内无法获得必需的外部事实 |
262
292
  | design | `/prototype` | 重大设计问题需要一次性实验证据 |
263
293
  | design | `/codebase-design` | 深模块、接口或测试接缝决定尚未完成 |
294
+ | design/build | `/writing-for-agents` | Contract 修改 agent-facing 指令或指针可达文档 |
264
295
  | build | `/tdd` | 可测试接缝上的可观察行为发生变化 |
265
296
  | build | `/diagnosing-bugs` | 存在真实失败且根因未知 |
266
- | build | `/resolving-merge-conflicts` | 正在发生 merge/rebase 冲突 |
297
+ | build | `/wizard` | Contract 需要生成人工执行的 shell 步骤;Matrix 不端到端运行 |
267
298
  | verify | `/code-review` | 需要 Standards 与 Spec 双轴证据 |
268
299
 
269
- `grill-with-docs`、`implement`、`improve-codebase-architecture` 不受 Matrix 管理,也不会自动调用。用户已安装的副本会作为非受管额外 Skill 保留。companion 不得推进、提交、归档或写 Matrix 状态。
300
+ Matrix 可以推荐但绝不嵌套以下 user-invoked handoff:`setup-matt-pocock-skills`、`improve-codebase-architecture`、`wayfinder`、`handoff`、`to-questionnaire`。它们由用户在活动阶段外显式运行,选中的结果可以再进入受治理 Change。
301
+
302
+ Arch 在 `code-review` 后记录由 Runtime 管理的审查回执,把 fixed point 与已提交的 HEAD diff 绑定到当前 Contract、审查正文和工作区。正常的 `code-review` 回执要求 Matrix 管理资产之外的候选工作区是干净的。无可用 Git 基线、已提交 diff 为空、仍存在 staged/unstaged/untracked 候选,或正确安装的 capability 真实失败时,Matrix 可为该 revision 执行一次明确标记的同能力 fallback;其中 `uncommitted-worktree` 会同时绑定 fixed point 与完整工作区候选的内容 hash。安装完整性失败不得 fallback。只有标题或自述、但没有匹配回执时,Verify 不能推进。
303
+
304
+ 安装但保持 standalone 的 Skill 是 `ask-matt`、`grill-with-docs`、`triage`、`to-spec`、`to-tickets`、`grill-me`、`teach`、`wait-what`。`implement` 与 raw `resolving-merge-conflicts` 可能接管 Matrix 所有的 TDD、review、stage 或 commit 副作用,因此 0.1.4 不安装也不管理它们;已有副本会被保留并报告为未管理额外项。安装不代表自动调用;任何 companion 都不得推进、提交、归档、恢复或写 Matrix 状态。
270
305
 
271
306
  ---
272
307
 
273
308
  **关键区别**:Matt Pocock 的 skills 是独立工具。Matrix 增加了:
274
309
  - **状态持久化**:可承受上下文丢失
275
- - **阶段强制**:不能跳过设计直接进入构建
310
+ - **阶段强制**:full 不能跳过 Design;lightweight 不能在确认 Open Contract 前修改实现
276
311
  - **证据要求**:守卫检查产物,而非断言
277
312
  - **转换日志**:完整的阶段变更审计记录
278
313
 
@@ -1,80 +1,83 @@
1
- ---
2
- name: matrix
3
- description: 启动、恢复并治理持久化的 Matrix 开发工作流。
4
- ---
5
-
6
- # Matrix
7
-
8
- 以当前仓库的 `.matrix/` 为唯一状态来源;不得从聊天记录推断阶段。
9
-
10
- 先执行:
11
-
12
- ```powershell
13
- matrix workflow inspect
14
- ```
15
-
16
- 只有系统明确报告 `matrix` 命令不存在时,才使用当前 Matrix Skill 目录中的 bundled runtime:
1
+ ---
2
+ name: matrix
3
+ description: 启动、恢复并治理持久化的 Matrix 开发工作流。
4
+ ---
5
+
6
+ # Matrix
7
+
8
+ 以当前仓库的 `.matrix/` 为唯一状态来源;不得从聊天记录推断阶段。
9
+
10
+ 读取 `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect` 的 `artifact_language`。规范 Markdown 标题 token 必须保持不变;面向用户的产物正文、说明和 handoff 在 `zh-CN` 时写中文,在 `en` 时写英文。
11
+
12
+ 所有 workflow 命令都先执行当前项目 Matrix Skill 自带的 Runtime,使项目兼容性权威优先于不同版本的全局启动器:
17
13
 
18
14
  ```powershell
19
15
  node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect
20
16
  ```
21
17
 
22
- 有活动变更时,报告其 phase、冻结的 `orchestration` 以及 Arch 安装完整性,再按 Runtime 结果进入 `next_skill`。没有活动变更时,为开发请求创建简短 kebab-case ID:
23
-
24
- ```powershell
25
- matrix workflow init <change-id> --workflow <full|hotfix|tweak> --orchestration <prim|arch> --title "<title>"
26
- ```
27
-
28
- 显式模式优先,否则使用项目 `default_orchestration`。解析后的模式在整个 change 生命周期中不可切换。
29
-
30
- ## 编排模式
31
-
32
- - **Prim**:各阶段使用 Matrix 自身能力,不依赖 Matt Skills。
33
- - **Arch**:仅在任务事实满足触发条件时,调用初始化阶段已验证的十项原子能力。
34
-
35
- 两种模式共用同一套 Matrix phase graph、产物、守卫、Return/Abort、Contract、事务与归档协议。Arch 能力不得写 Matrix 状态、推进阶段、提交、归档或创建竞争工作流。调用前说明能力与触发原因,无需重复请求 Skill 权限。
36
-
37
- 正确安装的 Arch 能力执行失败时,最多允许一次同能力的 Matrix fallback,并记录失败与证据。缺失、修改或不完整的 Arch 安装必须通过 `matrix init --with-mattpocock` 修复,不得切换活动 change 到 Prim。
38
-
39
- ## 恢复
40
-
41
- 只能通过 Runtime 恢复,不得手工修改状态:
42
-
43
- ```powershell
44
- matrix workflow return design --reason design-gap
45
- matrix workflow return build --reason verification-failed
46
- matrix workflow return design --reason acceptance-or-design-gap
47
- matrix workflow abort --reason <requirement-cancelled|superseded|no-longer-valuable|blocked|other>
48
- ```
49
-
50
- Return 会把当前 `verification.md` 轮换至按 revision 编号的证据历史。Archive 等待确认期间若验收或设计改变,只能使用 `archive -> design` 的 `acceptance-or-design-gap` Return。Abort 将终态变更移入 `.matrix/archive/`,但不会撤销工作区代码。
51
-
52
- 任何 mutation 返回 `WORKFLOW_RECOVERY_REQUIRED` 时,停止正常阶段操作并先执行只读诊断:
53
-
54
- ```powershell
55
- matrix workflow doctor
56
- ```
57
-
58
- 不得推断恢复目标或策略,只能执行 doctor 返回的精确命令:
59
-
60
- ```powershell
61
- matrix workflow doctor --repair --transaction <id> --strategy <continue|rollback>
62
- matrix workflow doctor --repair --lock <id>
63
- ```
64
-
65
- ## 精确 Contract
66
-
67
- `design -> build` 会批准 `proposal.md`、`design.md`、`plan.md` 的精确字节 SHA-256 身份。任何后续字节变动都会阻断 Build、Verify、Archive 和 Claude 导出;必须受控 Return 至 Design 后重新批准。旧 schema 会被拒绝且不发生写入。
68
-
18
+ 全局 `matrix` 命令只负责 init、update 和 bootstrap。受信任的 0.1.4 启动器只会自动委派给版本与 hash 都精确匹配的 0.1.4 项目 Runtime。项目 Runtime 属于不同版本或无法识别版本时仍是项目权威,但必须执行启动器返回的精确直连命令;旧版启动器不具备这项跨版本检查,不能作为项目 workflow 入口。
19
+
20
+ 有活动变更时,报告其 phase、冻结的 `orchestration` 以及 Arch 安装完整性,再按 Runtime 结果进入 `next_skill`。没有活动变更时,为开发请求创建简短 kebab-case ID:
21
+
22
+ ```powershell
23
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs init <change-id> --workflow <full|hotfix|tweak> --orchestration <prim|arch> --title "<title>"
24
+ ```
25
+
26
+ 显式模式优先,否则使用项目 `default_orchestration`。解析后的模式在整个 change 生命周期中不可切换。
27
+
28
+ ## 编排模式
29
+
30
+ - **Prim**:各阶段使用 Matrix 自身能力,不依赖 Matt Skills。
31
+ - **Arch**:仅在任务事实满足触发条件时,调用活动 Change 冻结的十项自动能力。Matrix 0.1.4 审查 Matt Skills v1.2.3 官方 25 项角色,只把其中 23 项兼容 Skill 安装在项目本地;排除 `implement` 与 raw `resolving-merge-conflicts`。
32
+
33
+ 两种编排模式使用已选定的 workflow profile:`full` 走 `open → design → build → verify → archive`;`hotfix` 与 `tweak` 共用内部 `lightweight` profile,走 `open → build → verify → archive`,仅证据策略不同。Arch 能力不得写 Matrix 状态、推进阶段、提交、归档或创建竞争工作流。
34
+
35
+ 正确安装的 Arch 能力执行失败时,最多允许一次同能力的 Matrix fallback,并记录失败与证据。缺失、修改或不完整的 Arch 安装必须通过 `matrix init --with-mattpocock` 修复,不得切换活动 change 到 Prim。
36
+
37
+ ## 恢复
38
+
39
+ 只能通过 Runtime 恢复,不得手工修改状态:
40
+
41
+ ```powershell
42
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason design-gap
43
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return build --reason verification-failed
44
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason acceptance-or-design-gap
45
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs abort --reason <requirement-cancelled|superseded|no-longer-valuable|blocked|other>
46
+ ```
47
+
48
+ Return 会把当前 `verification.md` 轮换至按 revision 编号的证据历史。Archive 等待确认期间若验收或设计改变,只能使用 `archive -> design` 的 `acceptance-or-design-gap` Return。Abort 将终态变更移入 `.matrix/archive/`,但不会撤销工作区代码。
49
+
50
+ 任何 mutation 返回 `WORKFLOW_RECOVERY_REQUIRED` 时,停止正常阶段操作并先执行只读诊断:
51
+
52
+ ```powershell
53
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor
54
+ ```
55
+
56
+ 不得推断恢复目标或策略,只能执行 doctor 返回的精确命令:
57
+
58
+ ```powershell
59
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor --repair --transaction <id> --strategy <continue|rollback>
60
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor --repair --lock <id>
61
+ ```
62
+
63
+ ## 精确 Contract
64
+
65
+ full 的 `design -> build` 会批准 proposal/design/plan;lightweight 的 `open -> build --confirmed` 只批准紧凑 proposal,并拒绝初始化后、批准前发生的项目实现改动。Contract 后续漂移都会阻断推进。
66
+
69
67
  ## 可选 Claude 交接
70
-
71
- `$matrix-claude` 只在已批准的 Build 中使用,导出同一 Contract 快照给 Claude Code。它不拥有阶段推进或验收;直接由 Codex 实现仍使用原有 Matrix 主流程。
68
+
69
+ `$matrix-claude` 只在已批准的 Build 中使用,导出同一 Contract 快照给 Claude Code。它不拥有阶段推进或验收;直接由 Codex 实现仍使用原有 Matrix 主流程。
72
70
  只有用户明确选择“Codex 设计、Claude Code 实现”时才使用,不得自动插入标准流程。
73
71
 
74
- ## 规则
75
-
76
- - 阶段只能经 `matrix workflow transition` 正向推进。
77
- - 只能经上述明确的 `matrix workflow return` 反向推进。
78
- - 成功 Archive 必须使用两步乐观提交:先运行 `matrix workflow archive --dry-run`,再将其精确 hash 传给 `matrix workflow archive --expect-preflight <sha256>`;不得绕过预演。
79
- - `matrix workflow doctor` 始终只读;transaction 与陈旧锁 repair 必须显式绑定 doctor 报告的 identity,不得手工编辑或删除 `.matrix/transactions/`、`.matrix/workflow.lock`。
80
- - 重大架构/范围决定和 archive/commit 前应暂停等待用户确认。
72
+ ## 显式 Matt handoff
73
+
74
+ Matrix 不嵌套 user-invoked Skill。适用时只解释原因,并让用户显式调用:一次性配置使用 `setup-matt-pocock-skills`,工作流外架构扫描使用 `improve-codebase-architecture`,独立大型候选生成使用 `wayfinder`,上下文边界使用 `handoff`,他人掌握阻塞事实时使用 `to-questionnaire`。`ask-matt`、`grill-with-docs`、`triage`、`to-spec`、`to-tickets`、`grill-me`、`teach`、`wait-what` 保持 standalone。Matrix 不安装也不管理 `implement` 或 raw `resolving-merge-conflicts`;已有副本保留为未管理额外项,活动 Change 内不得建议使用。
75
+
76
+ ## 规则
77
+
78
+ - 阶段只能经 `node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition` 正向推进。
79
+ - 只能经上述明确的 `node <matrix-skill-directory>/scripts/matrix-runtime.mjs return` 反向推进。
80
+ - 成功 Archive 必须使用两步乐观提交:先运行 `node <matrix-skill-directory>/scripts/matrix-runtime.mjs archive --dry-run`,再将其精确 hash 传给 `node <matrix-skill-directory>/scripts/matrix-runtime.mjs archive --expect-preflight <sha256>`;不得绕过预演。
81
+ - `node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor` 始终只读;transaction 与陈旧锁 repair 必须显式绑定 doctor 报告的 identity,不得手工编辑或删除 `.matrix/transactions/`、`.matrix/workflow.lock`。
82
+ - 重大架构/范围决定和 archive/commit 前应暂停等待用户确认。
83
+ - shortcut 范围扩大时执行 `node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason design-gap`;Runtime 将其升级为 full。
@@ -1,33 +1,36 @@
1
- ---
2
- name: matrix-archive
3
- description: 关闭并归档已经验证的 Matrix 变更。
4
- ---
5
-
6
- # Matrix Archive
7
-
8
- 这是 Matrix 最终阶段。读取 proposal、plan 与验证证据,汇总行为变化、验证结果、残留风险和后续工作;提交归档前必须取得用户明确确认。
9
-
10
- Prim 与 Arch 的 Archive 均完全由 Matrix 拥有;本阶段不调用 companion 实现、审查或架构能力。
11
-
12
- ## 强制两步归档
13
-
14
- 先运行只读预演并复核影响摘要,再原样提交该次预演返回的 hash:
15
-
16
- ```powershell
17
- matrix workflow archive --dry-run
18
- matrix workflow archive --expect-preflight <dry-run-返回的-sha256>
19
- ```
20
-
21
- 裸 Archive 会被拒绝。Runtime 会重新取得项目 Archive 互斥权,并在提交前重算整个受保护 change 目录 manifest。
22
-
23
- - `ARCHIVE_PREFLIGHT_CHANGED`:重新 dry-run 并复核新摘要。
24
- - `ARCHIVE_BUSY`:稍后重试;不得移除或接管锁,陈旧锁恢复属于后续 doctor/repair change。
25
- - Guard 或 Contract 失败:使用 Runtime 返回的恢复命令,不得提交。
26
-
27
- 若最终确认前发现验收或设计需要调整,使用唯一 Archive 回退路径:
28
-
29
- ```powershell
30
- matrix workflow return design --reason acceptance-or-design-gap
31
- ```
32
-
33
- 提交成功后,变更位于 `.matrix/archive/`,工作流完成。
1
+ ---
2
+ name: matrix-archive
3
+ description: 关闭并归档已经验证的 Matrix 变更。
4
+ ---
5
+
6
+ # Matrix Archive
7
+
8
+ 这是 Matrix 最终阶段。读取 proposal、plan 与验证证据,汇总行为变化、验证结果、残留风险和后续工作;提交归档前必须取得用户明确确认。
9
+
10
+ 归档摘要和 handoff 正文使用 `artifact_language`;Runtime 所需英文标题 token 保持不变。
11
+
12
+ Prim 与 Arch 的 Archive 均完全由 Matrix 拥有;本阶段不调用 companion 实现、审查或架构能力。
13
+
14
+ ## 强制两步归档
15
+
16
+ 先运行只读预演并复核影响摘要,再原样提交该次预演返回的 hash:
17
+
18
+ ```powershell
19
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs archive --dry-run
20
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs archive --expect-preflight <dry-run-返回的-sha256>
21
+ ```
22
+
23
+ 裸 Archive 会被拒绝。Runtime 会重新取得项目 Archive 互斥权,并在提交前重算整个受保护 change 目录 manifest。
24
+ hotfix/tweak 在复核 preflight 后必须再次取得用户明确确认,并执行 Runtime 返回的带 `--confirmed` 命令;缺少确认会被拒绝。
25
+
26
+ - `ARCHIVE_PREFLIGHT_CHANGED`:重新 dry-run 并复核新摘要。
27
+ - `ARCHIVE_BUSY`:稍后重试;不得移除或接管锁,陈旧锁恢复属于后续 doctor/repair change。
28
+ - Guard 或 Contract 失败:使用 Runtime 返回的恢复命令,不得提交。
29
+
30
+ 若最终确认前发现验收或设计需要调整,使用唯一 Archive 回退路径:
31
+
32
+ ```powershell
33
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason acceptance-or-design-gap
34
+ ```
35
+
36
+ 提交成功后,变更位于 `.matrix/archive/`,工作流完成。