@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
@@ -7,84 +7,81 @@ description: Route, initialize, resume, and govern a persistent Matrix developme
7
7
 
8
8
  Use Matrix as the development-workflow entrypoint. Its source of truth is the current repository's `.matrix/`; never infer a phase from chat history.
9
9
 
10
+ Read `artifact_language` from `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect`. Keep required Markdown heading tokens unchanged, but write every user-facing artifact body, explanation, and handoff in that language: English for `en`, Chinese for `zh-CN`.
11
+
10
12
  ## Route
11
13
 
12
- First run:
14
+ For every workflow command, run the Runtime bundled with this project Skill so the project compatibility authority wins over a different global launcher:
15
+
16
+ ```powershell
17
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect
18
+ ```
19
+
20
+ Use the global `matrix` command for `init`, `update`, and bootstrap only. A trusted 0.1.4 launcher auto-delegates only to an exact, hash-verified 0.1.4 project Runtime. A different or unidentified project release remains authoritative but must be invoked through the exact direct command returned by the launcher. Older launchers cannot provide this cross-release check and must not be used as the project workflow entrypoint.
21
+
22
+ - If an active change exists, show its phase and frozen `orchestration`, report any Arch installation-integrity failure, and enter the returned `next_skill` only when the Runtime permits continuation.
23
+ - If no active change exists, classify the request: reproducible small bug → `$matrix-hotfix` with workflow `hotfix`; bounded small change with no public API/schema/architecture impact → `$matrix-tweak` with workflow `tweak`; otherwise full Matrix with workflow `full`.
24
+ - Do not create Matrix state for questions, read-only investigation, or requests outside software development.
25
+ - Before `init`, derive a short kebab-case change id and an accurate title. Start with `full` unless a shortcut clearly applies.
13
26
 
14
27
  ```powershell
15
- matrix workflow inspect
28
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs init <change-id> --workflow <full|hotfix|tweak> --orchestration <prim|arch> --title "<title>"
16
29
  ```
17
30
 
18
- If and only if the `matrix` executable is reported as absent, run the bundled fallback from this Skill directory instead:
31
+ An explicit mode wins; otherwise Runtime uses the project `default_orchestration`. The resolved value is immutable for the change and is shown in init, inspect, and the initialized Event. Then enter `$matrix-open`.
32
+
33
+ ## Orchestration
34
+
35
+ - **Prim** uses Matrix's own capability in every phase and never requires Matt Skills.
36
+ - **Arch** conditionally invokes the ten reviewed automatic capabilities frozen by the active Change. Matrix 0.1.4 reviews all 25 official Matt Skills v1.2.3 roles and installs only the 23 compatible Skills project-locally; `implement` and raw `resolving-merge-conflicts` are excluded.
37
+
38
+ Both orchestration modes use the same selected workflow profile. `full` uses `open → design → build → verify → archive`; `hotfix` and `tweak` share one internal `lightweight` profile, `open → build → verify → archive`, with different evidence policies. Companion Skills never write Matrix state, transition, commit, archive, or create competing workflow artifacts.
39
+
40
+ A correctly installed Arch capability that fails gets at most one Matrix-owned fallback for the same bounded capability, with failure and evidence recorded. A missing, modified, or incomplete Arch installation must be repaired with `matrix init --with-mattpocock`; never switch the active change to Prim.
41
+
42
+ ## Recovery
43
+
44
+ Use Runtime commands instead of editing Matrix state:
19
45
 
20
46
  ```powershell
21
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect
47
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason design-gap
48
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return build --reason verification-failed
49
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason acceptance-or-design-gap
50
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason acceptance-or-design-gap # from Archive, before terminal archive
51
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs abort --reason <requirement-cancelled|superseded|no-longer-valuable|blocked|other>
22
52
  ```
23
53
 
24
- - If an active change exists, show its phase and frozen `orchestration`, report any Arch installation-integrity failure, and enter the returned `next_skill` only when the Runtime permits continuation.
25
- - If no active change exists, classify the request: reproducible small bug → `$matrix-hotfix` with workflow `hotfix`; bounded small change with no public API/schema/architecture impact → `$matrix-tweak` with workflow `tweak`; otherwise full Matrix with workflow `full`.
26
- - Do not create Matrix state for questions, read-only investigation, or requests outside software development.
27
- - Before `init`, derive a short kebab-case change id and an accurate title. Start with `full` unless a shortcut clearly applies.
54
+ Return preserves the change but moves the current `verification.md` into revisioned evidence history, so the returned phase must produce fresh current evidence. Abort preserves the last phase and moves the terminal change into `.matrix/archive/`; it never undoes worktree changes.
55
+
56
+ If any mutation reports `WORKFLOW_RECOVERY_REQUIRED`, stop normal phase work and run the read-only diagnosis:
28
57
 
29
58
  ```powershell
30
- matrix workflow init <change-id> --workflow <full|hotfix|tweak> --orchestration <prim|arch> --title "<title>"
31
- ```
32
-
33
- An explicit mode wins; otherwise Runtime uses the project `default_orchestration`. The resolved value is immutable for the change and is shown in init, inspect, and the initialized Event. Then enter `$matrix-open`.
34
-
35
- ## Orchestration
36
-
37
- - **Prim** uses Matrix's own capability in every phase and never requires Matt Skills.
38
- - **Arch** conditionally invokes the initialization-verified ten-Skill cohort when documented task-fact triggers are present.
39
-
40
- Both modes share the same Matrix phase graph, artifacts, guards, Return/Abort, Contract, transactions, and Archive protocol. Companion Skills never write Matrix state, transition, commit, archive, or create competing workflow artifacts. Announce each Arch capability and trigger before invoking it; do not ask for redundant per-Skill permission.
41
-
42
- A correctly installed Arch capability that fails gets at most one Matrix-owned fallback for the same bounded capability, with failure and evidence recorded. A missing, modified, or incomplete Arch installation must be repaired with `matrix init --with-mattpocock`; never switch the active change to Prim.
43
-
44
- ## Recovery
45
-
46
- Use Runtime commands instead of editing Matrix state:
47
-
48
- ```powershell
49
- matrix workflow return design --reason design-gap
50
- matrix workflow return build --reason verification-failed
51
- matrix workflow return design --reason acceptance-or-design-gap
52
- matrix workflow return design --reason acceptance-or-design-gap # from Archive, before terminal archive
53
- matrix workflow abort --reason <requirement-cancelled|superseded|no-longer-valuable|blocked|other>
54
- ```
55
-
56
- Return preserves the change but moves the current `verification.md` into revisioned evidence history, so the returned phase must produce fresh current evidence. Abort preserves the last phase and moves the terminal change into `.matrix/archive/`; it never undoes worktree changes.
57
-
58
- If any mutation reports `WORKFLOW_RECOVERY_REQUIRED`, stop normal phase work and run the read-only diagnosis:
59
-
60
- ```powershell
61
- matrix workflow doctor
62
- ```
63
-
64
- Never infer a repair target or strategy. Use only the exact command returned by doctor:
65
-
66
- ```powershell
67
- matrix workflow doctor --repair --transaction <id> --strategy <continue|rollback>
68
- matrix workflow doctor --repair --lock <id>
69
- ```
70
-
71
- ## Optional Claude handoff
59
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor
60
+ ```
61
+
62
+ Never infer a repair target or strategy. Use only the exact command returned by doctor:
63
+
64
+ ```powershell
65
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor --repair --transaction <id> --strategy <continue|rollback>
66
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor --repair --lock <id>
67
+ ```
68
+
69
+ ## Optional Claude handoff
72
70
 
73
- `$matrix-claude` is an optional sidecar command used after the approved Design -> Build transition. It exports the matching approved contract to a Claude Code task package. It never changes the Matrix phase, workflow, guard result, or runtime state.
74
- Use it only when the user explicitly chooses Codex design with Claude Code implementation; never inject it into the standard path.
71
+ `$matrix-claude` is an optional sidecar command used after the approved Design -> Build transition. It exports the matching approved contract to a Claude Code task package. It never changes the Matrix phase, workflow, guard result, or runtime state.
72
+ Use it only when the user explicitly chooses Codex design with Claude Code implementation; never inject it into the standard path.
75
73
 
76
74
  ## Cross-Cutting Skills
77
75
 
78
- ### Handoff (`handoff`)
79
- When context is running low and work needs to continue in a fresh session, use `handoff` at any stage boundary. It compacts the conversation into a handoff document with suggested skills for the next agent. Save to the OS temp directory, not the workspace.
76
+ Matrix never nests user-invoked Matt Skills. When relevant, explain the reason and ask the user to invoke one explicitly: `setup-matt-pocock-skills` for one-time setup, `improve-codebase-architecture` for an out-of-band scan, `wayfinder` for generating a separate large-effort candidate, `handoff` at a context boundary, or `to-questionnaire` when another person owns blocking facts. `ask-matt`, `grill-with-docs`, `triage`, `to-spec`, `to-tickets`, `grill-me`, `teach`, and `wait-what` remain standalone. Matrix does not install or manage `implement` or raw `resolving-merge-conflicts`; preserve pre-existing copies as unmanaged extras and never suggest them inside an active Change.
80
77
 
81
78
  ## Rules
82
79
 
83
- - A phase can advance only through `matrix workflow transition`; run its guard first.
84
- - A phase can move backward only through one of the documented `matrix workflow return` intents.
85
- - The Build transition approves the exact bytes of proposal, design, and plan. Any later byte change blocks Build, Verify, Archive, and Claude export until a controlled Return to Design and a new Build approval.
86
- - A successful Archive is always a two-step optimistic commit: run `matrix workflow archive --dry-run`, then pass its exact hash to `matrix workflow archive --expect-preflight <sha256>`. Never bypass the preflight.
87
- - `matrix workflow doctor` is read-only. Every transaction or stale-lock repair must explicitly bind the identity reported by doctor; do not edit or delete `.matrix/transactions/` or `.matrix/workflow.lock`.
88
- - Do not replace required evidence with an assertion that work is complete.
89
- - Pause for user confirmation at material architecture/scope decisions and before archive/commit.
90
- - On scope expansion, run `matrix workflow return design --reason design-gap` and enter `$matrix-design`; never silently continue the old plan.
80
+ - A phase can advance only through `node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition`; run its guard first.
81
+ - A phase can move backward only through one of the documented `node <matrix-skill-directory>/scripts/matrix-runtime.mjs return` intents.
82
+ - Full Build approval binds proposal, design, and plan. Lightweight Build approval binds its compact proposal, requires `transition build --confirmed`, and rejects project implementation changes made after initialization but before approval.
83
+ - A successful Archive is always a two-step optimistic commit: run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs archive --dry-run`, then pass its exact hash to `node <matrix-skill-directory>/scripts/matrix-runtime.mjs archive --expect-preflight <sha256>`. Never bypass the preflight.
84
+ - `node <matrix-skill-directory>/scripts/matrix-runtime.mjs doctor` is read-only. Every transaction or stale-lock repair must explicitly bind the identity reported by doctor; do not edit or delete `.matrix/transactions/` or `.matrix/workflow.lock`.
85
+ - Do not replace required evidence with an assertion that work is complete.
86
+ - Pause for user confirmation at material architecture/scope decisions and before archive/commit.
87
+ - On shortcut scope expansion, run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason design-gap`; Runtime upgrades the change to `full`. Never silently continue the old contract.
@@ -1,11 +1,11 @@
1
- #!/usr/bin/env python3
2
- """Compatibility adapter for the authoritative Node workflow exporter."""
3
- from __future__ import annotations
4
-
5
- import sys
6
-
7
- from matrix_state import run_runtime
8
-
9
-
10
- if __name__ == "__main__":
11
- raise SystemExit(run_runtime(sys.argv[1:]))
1
+ #!/usr/bin/env python3
2
+ """Compatibility adapter for the authoritative Node workflow exporter."""
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+
7
+ from matrix_state import run_runtime
8
+
9
+
10
+ if __name__ == "__main__":
11
+ raise SystemExit(run_runtime(sys.argv[1:]))
@@ -1,60 +1,60 @@
1
- #!/usr/bin/env python3
2
- """Compatibility adapter for the authoritative Node Workflow Runtime."""
3
- from __future__ import annotations
4
-
5
- import os
6
- import shutil
7
- import subprocess
8
- import sys
9
- from pathlib import Path
10
-
11
-
12
- def development_runtime() -> Path | None:
13
- """Return an explicitly selected source runtime for repository tests only."""
14
- configured = os.environ.get("MATRIX_DEVELOPMENT_RUNTIME")
15
- return Path(configured).resolve() if configured else None
16
-
17
-
18
- def primary_runtime() -> str | None:
19
- if os.name == "nt":
20
- return shutil.which("matrix.cmd") or shutil.which("matrix.exe")
21
- return shutil.which("matrix")
22
-
23
-
1
+ #!/usr/bin/env python3
2
+ """Compatibility adapter for the authoritative Node Workflow Runtime."""
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ from pathlib import Path
10
+
11
+
12
+ def development_runtime() -> Path | None:
13
+ """Return an explicitly selected source runtime for repository tests only."""
14
+ configured = os.environ.get("MATRIX_DEVELOPMENT_RUNTIME")
15
+ return Path(configured).resolve() if configured else None
16
+
17
+
18
+ def primary_runtime() -> str | None:
19
+ if os.name == "nt":
20
+ return shutil.which("matrix.cmd") or shutil.which("matrix.exe")
21
+ return shutil.which("matrix")
22
+
23
+
24
24
  def runtime_command(args: list[str]) -> list[str]:
25
- primary = primary_runtime()
26
- if primary is not None:
27
- return [primary, "workflow", *args, "--json"]
28
-
29
25
  development = development_runtime()
30
26
  if development is not None:
31
- if not development.is_file():
32
- raise RuntimeError(f"Configured Matrix development runtime was not found: {development}")
33
- node = shutil.which("node")
34
- if node is None:
35
- raise RuntimeError("Node.js is required to run the Matrix workflow.")
36
- return [node, str(development), *args]
37
-
38
- bundled = Path(__file__).with_name("matrix-runtime.mjs")
39
- node = shutil.which("node")
27
+ if not development.is_file():
28
+ raise RuntimeError(f"Configured Matrix development runtime was not found: {development}")
29
+ node = shutil.which("node")
30
+ if node is None:
31
+ raise RuntimeError("Node.js is required to run the Matrix workflow.")
32
+ return [node, str(development), *args]
33
+
34
+ bundled = Path(__file__).with_name("matrix-runtime.mjs")
35
+ node = shutil.which("node")
40
36
  if node is not None and bundled.exists():
41
37
  return [node, str(bundled), *args]
42
38
 
43
- raise RuntimeError("Matrix CLI is absent and the bundled workflow runtime was not found.")
44
-
45
-
46
- def run_runtime(args: list[str]) -> int:
47
- try:
48
- completed = subprocess.run(runtime_command(args), cwd=Path.cwd(), check=False)
49
- except (OSError, RuntimeError) as error:
50
- print(f"MATRIX ERROR [RUNTIME_UNAVAILABLE]: {error}", file=sys.stderr)
51
- return 2
52
- return completed.returncode
53
-
54
-
55
- def main() -> int:
56
- return run_runtime(sys.argv[1:])
57
-
39
+ primary = primary_runtime()
40
+ if primary is not None:
41
+ return [primary, "workflow", *args, "--json"]
58
42
 
59
- if __name__ == "__main__":
60
- raise SystemExit(main())
43
+ raise RuntimeError("Matrix CLI is absent and the bundled workflow runtime was not found.")
44
+
45
+
46
+ def run_runtime(args: list[str]) -> int:
47
+ try:
48
+ completed = subprocess.run(runtime_command(args), cwd=Path.cwd(), check=False)
49
+ except (OSError, RuntimeError) as error:
50
+ print(f"MATRIX ERROR [RUNTIME_UNAVAILABLE]: {error}", file=sys.stderr)
51
+ return 2
52
+ return completed.returncode
53
+
54
+
55
+ def main() -> int:
56
+ return run_runtime(sys.argv[1:])
57
+
58
+
59
+ if __name__ == "__main__":
60
+ raise SystemExit(main())
@@ -1,33 +1,36 @@
1
- ---
2
- name: matrix-archive
3
- description: Close and archive a verified Matrix change. Use when the active Matrix phase is archive.
4
- ---
5
-
6
- # Matrix Archive
7
-
8
- This is the final Matrix phase. Read the proposal, plan, and verification evidence; summarize changed behavior, verification, residual risks, and follow-up work. Ask for explicit confirmation before committing or archiving.
9
-
10
- Archive is Matrix-owned in both Prim and Arch. Do not invoke companion implementation, review, or architecture capabilities here.
11
-
12
- ## Mandatory two-step Archive
13
-
14
- Run the read-only preflight and review its bounded effect summary. Then submit exactly the hash returned by that preflight:
15
-
16
- ```powershell
17
- matrix workflow archive --dry-run
18
- matrix workflow archive --expect-preflight <sha256-returned-by-dry-run>
19
- ```
20
-
21
- Bare Archive is rejected. Runtime reacquires the project Archive boundary and recomputes the entire protected change-directory manifest before committing.
22
-
23
- - `ARCHIVE_PREFLIGHT_CHANGED`: run dry-run again and review the new summary.
24
- - `ARCHIVE_BUSY`: retry later. Do not remove or take over the lock; stale-lock recovery belongs to the later doctor/repair change.
25
- - Guard or Contract failure: use the returned recovery command and do not submit.
26
-
27
- If acceptance criteria or design must change while awaiting confirmation, use the sole Archive recovery path:
28
-
29
- ```powershell
30
- matrix workflow return design --reason acceptance-or-design-gap
31
- ```
32
-
33
- After successful commit, the change is under `.matrix/archive/` and the workflow is complete.
1
+ ---
2
+ name: matrix-archive
3
+ description: Close and archive a verified Matrix change. Use when the active Matrix phase is archive.
4
+ ---
5
+
6
+ # Matrix Archive
7
+
8
+ This is the final Matrix phase. Read the proposal, plan, and verification evidence; summarize changed behavior, verification, residual risks, and follow-up work. Ask for explicit confirmation before committing or archiving.
9
+
10
+ Write archive summaries and handoff prose in `artifact_language`; keep Runtime-required English heading tokens unchanged.
11
+
12
+ Archive is Matrix-owned in both Prim and Arch. Do not invoke companion implementation, review, or architecture capabilities here.
13
+
14
+ ## Mandatory two-step Archive
15
+
16
+ Run the read-only preflight and review its bounded effect summary. Then submit exactly the hash returned by that preflight:
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 <sha256-returned-by-dry-run>
21
+ ```
22
+
23
+ Bare Archive is rejected. Runtime reacquires the project Archive boundary and recomputes the entire protected change-directory manifest before committing.
24
+ For hotfix/tweak, ask for explicit confirmation after reviewing the preflight, then use the returned command with `--confirmed`. Runtime rejects a shortcut Archive without it.
25
+
26
+ - `ARCHIVE_PREFLIGHT_CHANGED`: run dry-run again and review the new summary.
27
+ - `ARCHIVE_BUSY`: retry later. Do not remove or take over the lock; stale-lock recovery belongs to the later doctor/repair change.
28
+ - Guard or Contract failure: use the returned recovery command and do not submit.
29
+
30
+ If acceptance criteria or design must change while awaiting confirmation, use the sole Archive recovery path:
31
+
32
+ ```powershell
33
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason acceptance-or-design-gap
34
+ ```
35
+
36
+ After successful commit, the change is under `.matrix/archive/` and the workflow is complete.
@@ -5,38 +5,43 @@ description: Implement the frozen active Matrix plan with test-first vertical sl
5
5
 
6
6
  # Matrix Build
7
7
 
8
- Run `matrix workflow inspect`. Read `plan.md`, `design.md`, the approved Contract, and repository instructions. Implement only the frozen scope.
9
-
10
- ## Prim
11
-
12
- Use Matrix's own implementation and test discipline.
13
-
14
- ## Arch
15
-
8
+ Run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect` and implement only its approved Contract. Full and `legacy-full` read proposal/design/plan. `lightweight` reads the approved compact proposal and must not backfill Design artifacts.
9
+
10
+ Write build evidence and user-facing explanations in `artifact_language`; preserve any Runtime-required English heading tokens.
11
+
12
+ ## Prim
13
+
14
+ Use Matrix's own implementation and test discipline.
15
+
16
+ ## Arch
17
+
16
18
  - invoke `tdd` when the change modifies observable behavior at a testable seam;
17
19
  - invoke `diagnosing-bugs` only when an actual failure exists and root cause is not established;
18
- - invoke `resolving-merge-conflicts` only for an in-progress merge or rebase conflict.
20
+ - invoke `writing-for-agents` when the approved Contract changes agent-facing instructions;
21
+ - invoke `wizard` only to generate and statically verify human-run shell steps required by the Contract; never execute the wizard end-to-end or collect secrets.
19
22
 
20
- Announce each triggered capability and reason. No companion may commit, review, transition, archive, or broaden scope. A correctly installed capability gets at most one Matrix-owned fallback for that same capability; record the Skill, failure, fallback, and evidence. Installation-integrity failure stops the phase.
23
+ Resolve an in-progress merge/rebase through Matrix-owned conflict handling. Do not invoke raw `resolving-merge-conflicts`, because it can stage, continue, and commit outside Matrix lifecycle ownership. Never invoke `implement` inside an active Change.
24
+
25
+ Announce each triggered capability and reason. No companion may commit, review, transition, archive, or broaden scope. A correctly installed capability gets at most one Matrix-owned fallback for that same capability; record the Skill, failure, fallback, and evidence. Installation-integrity failure stops the phase.
21
26
 
22
27
  ## Scope Discipline
23
28
 
24
- If implementation exposes a scope or design change, **stop and run**:
25
-
26
- ```powershell
27
- matrix workflow return design --reason design-gap
28
- ```
29
-
30
- Then enter `$matrix-design`; do not amend the plan silently. The Runtime preserves old verification evidence in revision history and requires fresh evidence after the redesigned plan returns to Build.
29
+ If implementation exposes a scope or design change, **stop and run**; a lightweight change is upgraded to full by this Return:
30
+
31
+ ```powershell
32
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs return design --reason design-gap
33
+ ```
34
+
35
+ Then enter `$matrix-design`; do not amend the plan silently. The Runtime preserves old verification evidence in revision history and requires fresh evidence after the redesigned plan returns to Build.
31
36
 
32
37
  ## Process
33
38
 
34
- 1. Implement the approved plan in bounded vertical slices.
35
- 2. Use only triggered Arch capabilities.
36
- 3. Record commands, outcomes, capability invocations and fallbacks under `## Build evidence`.
37
- 4. Run the guard and transition, then enter `$matrix-verify`.
39
+ 1. Implement the approved plan in bounded vertical slices.
40
+ 2. Use only triggered Arch capabilities.
41
+ 3. Record common facts under `## Build evidence`. Hotfix also requires `## Reproduction evidence` and `## Root cause`; tweak also requires `## Scope evidence`.
42
+ 4. Run the guard and transition, then enter `$matrix-verify`.
38
43
 
39
44
  ```powershell
40
- matrix workflow guard build
41
- matrix workflow transition verify
45
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
46
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
42
47
  ```
@@ -5,12 +5,14 @@ description: Export a frozen Matrix design as a bounded Claude Code task package
5
5
 
6
6
  # Matrix Claude Handoff
7
7
 
8
- This is an optional Matrix sidecar, not a Matrix phase. It must not call `transition`, `archive`, or write `matrix.yaml` or `events.jsonl`.
8
+ This is an optional Matrix sidecar, not a Matrix phase. It must not call `transition`, `archive`, or write `matrix.yaml` or `events.jsonl`. It supports only a matching full or legacy-full three-artifact Contract; new lightweight hotfix/tweak changes are intentionally unsupported.
9
+
10
+ Use `artifact_language` from inspect for human-readable handoff text while retaining the stable machine-readable headings and metadata keys.
9
11
 
10
12
  ## When to Use
11
13
 
12
14
  Use `$matrix-claude` when:
13
- - The active change is in Build and the Design -> Build transition has approved the contract
15
+ - The active change is in Build and the Design -> Build transition has approved the contract
14
16
  - You want Claude Code (instead of Codex) to implement the design
15
17
  - You need a bounded task package with all implementation details
16
18
 
@@ -19,31 +21,31 @@ Use `$matrix-claude` when:
19
21
  The exporter performs this read-only check before writing anything:
20
22
 
21
23
  ```powershell
22
- matrix workflow guard build
24
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
23
25
  ```
24
26
 
25
27
  If `matrix` is genuinely absent from PATH, use the bundled runtime from the installed root Matrix Skill. Do not fall back when the primary command starts and returns an error.
26
28
 
27
- If the build guard reports `CONTRACT_CHANGED` or `CONTRACT_UNAPPROVED`, return to `$matrix-design` and approve a new contract through Build. The exporter reads the approved bytes of `proposal.md`, `design.md`, and `plan.md`; it does not invent missing facts.
29
+ If the build guard reports `CONTRACT_CHANGED` or `CONTRACT_UNAPPROVED`, return to `$matrix-design` and approve a new contract through Build. The exporter reads the approved bytes of `proposal.md`, `design.md`, and `plan.md`; it does not invent missing facts.
28
30
 
29
31
  ## Export
30
32
 
31
- Treat explicit invocation of `$matrix-claude` as the user's choice of Claude Code as the implementation actor. Generate the package with the deterministic exporter; it refuses a non-matching approved contract and does not alter Matrix state.
33
+ Treat explicit invocation of `$matrix-claude` as the user's choice of Claude Code as the implementation actor. Generate the package with the deterministic exporter; it refuses a non-matching approved contract and does not alter Matrix state.
32
34
 
33
35
  ```powershell
34
36
  # Generic project: only exports a Matrix artifact.
35
- matrix workflow export --task-id <ID> --target generic
37
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs export --task-id <ID> --target generic
36
38
 
37
39
  # FnSec: exports its formal task package. Add --apply-fnsec-board only when
38
40
  # active.md is NO_ACTIVE_OBJECTIVE; an existing task is never overwritten.
39
- matrix workflow export --task-id <ID> --target fnsec --apply-fnsec-board
41
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs export --task-id <ID> --target fnsec --apply-fnsec-board
40
42
  ```
41
43
 
42
44
  ## Task Package Contents
43
45
 
44
46
  The exported package (`artifacts/claude-task.md`) contains everything Claude Code needs to implement and produce evidence for `$matrix-verify`:
45
47
 
46
- 1. **Task ID, execution actor, and approved contract hash**: Claude Code and the exact approved snapshot
48
+ 1. **Task ID, execution actor, and approved contract hash**: Claude Code and the exact approved snapshot
47
49
  2. **Objective and acceptance criteria** — copied from `proposal.md`
48
50
  3. **In-scope and out-of-scope boundaries** — from `proposal.md`
49
51
  4. **Frozen design decisions** — from `design.md` (Decisions, Boundaries, Test seams)
@@ -76,12 +78,12 @@ After Claude Code completes and evidence is present:
76
78
 
77
79
  1. Run build guard to verify evidence:
78
80
  ```powershell
79
- matrix workflow guard build
81
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
80
82
  ```
81
83
 
82
84
  2. If guard passes, transition to verify:
83
85
  ```powershell
84
- matrix workflow transition verify
86
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
85
87
  ```
86
88
 
87
89
  3. Enter `$matrix-verify` to继续验证流程
@@ -91,6 +93,6 @@ If the build guard fails, return to Claude Code to补充 missing evidence.
91
93
  ## Important Notes
92
94
 
93
95
  - This sidecar does NOT change Matrix phase, workflow, or guard result
94
- - The Matrix state remains in `build` phase; export itself does not advance it
96
+ - The Matrix state remains in `build` phase; export itself does not advance it
95
97
  - Claude Code must produce evidence that satisfies the build guard conditions
96
98
  - After successful transition to verify, the normal verify流程 continues
@@ -5,35 +5,41 @@ description: Design and freeze the active Matrix change before implementation. U
5
5
 
6
6
  # Matrix Design
7
7
 
8
- Run `matrix workflow inspect`, read the active proposal and frozen `orchestration`, then write `artifacts/design.md` with `## Decisions`, `## Boundaries`, `## Test seams`, and `## Risks`; write `artifacts/plan.md` with `## Steps`, `## Validation`, and `## Stop conditions`.
9
-
10
- ## Prim
11
-
12
- Use Matrix's own capability to investigate the repository and design the change.
13
-
14
- ## Arch
15
-
16
- Invoke only capabilities whose task-fact trigger is proven:
17
-
8
+ Design is used by `full` and resumable legacy shortcut changes only. A new lightweight hotfix/tweak moves directly from Open to Build and must not create Design artifacts merely to satisfy the full guard.
9
+
10
+ Use `artifact_language` from `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect` for all design and plan prose. Keep Runtime-required English heading tokens unchanged.
11
+
12
+ Run `node <matrix-skill-directory>/scripts/matrix-runtime.mjs inspect`, read the active proposal and frozen `orchestration`, then write `artifacts/design.md` with `## Decisions`, `## Boundaries`, `## Test seams`, and `## Risks`; write `artifacts/plan.md` with `## Steps`, `## Validation`, and `## Stop conditions`.
13
+
14
+ ## Prim
15
+
16
+ Use Matrix's own capability to investigate the repository and design the change.
17
+
18
+ ## Arch
19
+
20
+ Invoke only capabilities whose task-fact trigger is proven:
21
+
18
22
  - `domain-modeling` for unclear vocabulary, invariants, or architectural decisions;
19
23
  - `research` when required external facts cannot be established from the repository;
20
- - `wayfinder` when module ownership or dependency seams are unknown;
21
24
  - `prototype` when a material design decision needs disposable empirical evidence;
22
- - `codebase-design` when a deep-module, interface, or test-seam decision remains.
23
-
24
- Order follows actual dependencies; never run a fixed companion sequence. Announce each invocation and reason. A correctly installed capability gets at most one same-capability Matrix fallback; installation-integrity failure stops the phase.
25
-
25
+ - `codebase-design` when a deep-module, interface, or test-seam decision remains;
26
+ - `writing-for-agents` when the Contract creates or changes Skills, `AGENTS.md`, `CLAUDE.md`, or documents reached through agent pointers.
27
+
28
+ Order follows actual dependencies; never run a fixed companion sequence. Announce each invocation and reason. A correctly installed capability gets at most one same-capability Matrix fallback; installation-integrity failure stops the phase.
29
+
26
30
  Long-lived domain, ADR, or research artifacts follow repository conventions, and material conclusions must be synchronized into the canonical design or plan. Prototypes default to an OS temporary directory unless the approved design promotes a project path. Companion output cannot own Matrix state or create a competing plan.
31
+
32
+ `wayfinder` and `improve-codebase-architecture` are explicit handoffs outside the active Design. Recommend one only when its purpose fits, then let the user invoke it; a selected result may enter a separate governed Change.
27
33
 
28
34
  ## Process
29
35
 
30
- 1. Establish repository facts and resolve only triggered design questions.
31
- 2. Write and synchronize the canonical Matrix design and plan.
32
- 3. Confirm material architecture choices with the user before freezing.
33
- 4. Run the guard, then choose the implementation actor.
36
+ 1. Establish repository facts and resolve only triggered design questions.
37
+ 2. Write and synchronize the canonical Matrix design and plan.
38
+ 3. Confirm material architecture choices with the user before freezing.
39
+ 4. Run the guard, then choose the implementation actor.
34
40
 
35
41
  ```powershell
36
- matrix workflow guard design
42
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard design
37
43
  ```
38
44
 
39
45
  ## Implementation Decision Point
@@ -45,23 +51,23 @@ After the design guard passes, the user chooses:
45
51
  Run transition and enter `$matrix-build`:
46
52
 
47
53
  ```powershell
48
- matrix workflow transition build
54
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition build
49
55
  ```
50
56
 
51
57
  Then enter `$matrix-build` to implement directly in this session.
52
58
 
53
59
  ### Option B: Use Claude Code for implementation
54
60
 
55
- First approve the frozen contract by transitioning to Build, then run `$matrix-claude` to export a bounded task package. This:
56
- - Does not change the Build phase or state beyond the preceding transition
61
+ First approve the frozen contract by transitioning to Build, then run `$matrix-claude` to export a bounded task package. This:
62
+ - Does not change the Build phase or state beyond the preceding transition
57
63
  - Creates `artifacts/claude-task.md` with all implementation details
58
64
  - Includes acceptance criteria, test seams, and required commands
59
65
 
60
- After Claude Code completes and returns results, run the Build guard and enter `$matrix-verify`:
66
+ After Claude Code completes and returns results, run the Build guard and enter `$matrix-verify`:
61
67
 
62
68
  ```powershell
63
- matrix workflow guard build
64
- matrix workflow transition verify
69
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
70
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
65
71
  ```
66
72
 
67
73
  Then enter `$matrix-verify` to verify the implementation.
@@ -5,4 +5,4 @@ description: Run a constrained Matrix workflow for a reproducible small bug. Use
5
5
 
6
6
  # Matrix Hotfix
7
7
 
8
- Start through `$matrix` with workflow `hotfix` and preserve its frozen Prim or Arch orchestration. Prim diagnoses directly. Arch invokes `diagnosing-bugs` only when an actual failure exists and root cause is not established. Write the compact proposal, continue through the normal Matrix gates, and keep all companion output subordinate to Matrix artifacts and state. If the bug requires architecture change, a new public API, schema work, or broad coordination, use controlled Return and upgrade the work to a full Matrix change.
8
+ Start through `$matrix` with workflow `hotfix`. It uses the shared lightweight lifecycle `open → build → verify → archive`; there is no separate hotfix state machine. Before Build, record expected/actual behavior and a reproducible failure signal, present the compact Contract, and wait for confirmation. Build records reproduction and root-cause evidence; Verify records regression evidence. If the bug requires architecture, public API, schema, or broad coordination, use controlled Return to upgrade the change to full.