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