@rosenfan/matrix 0.1.4 → 0.1.5

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 (48) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +29 -29
  3. package/README.zh-CN.md +27 -27
  4. package/{.claude → assets}/skills/matrix/SKILL.md +78 -78
  5. package/{.claude → assets}/skills/matrix/agents/openai.yaml +4 -4
  6. package/{.claude → assets}/skills/matrix/scripts/matrix_claude.py +11 -11
  7. package/{.claude → assets}/skills/matrix/scripts/matrix_state.py +49 -49
  8. package/assets/skills/matrix/scripts/test_matrix_claude.py +69 -0
  9. package/assets/skills/matrix/scripts/test_matrix_state.py +69 -0
  10. package/{.claude → assets}/skills/matrix-archive/SKILL.md +36 -36
  11. package/{.claude/skills/matrix-hotfix → assets/skills/matrix-archive}/agents/openai.yaml +4 -4
  12. package/{.claude → assets}/skills/matrix-build/SKILL.md +41 -41
  13. package/{.claude/skills/matrix-archive → assets/skills/matrix-build}/agents/openai.yaml +4 -4
  14. package/{.claude → assets}/skills/matrix-claude/SKILL.md +98 -98
  15. package/{.claude → assets}/skills/matrix-claude/agents/openai.yaml +4 -4
  16. package/{.claude → assets}/skills/matrix-design/SKILL.md +65 -65
  17. package/{.claude → assets}/skills/matrix-design/agents/openai.yaml +4 -4
  18. package/{.claude → assets}/skills/matrix-hotfix/SKILL.md +8 -8
  19. package/{.claude/skills/matrix-build → assets/skills/matrix-hotfix}/agents/openai.yaml +4 -4
  20. package/{.claude → assets}/skills/matrix-open/SKILL.md +39 -39
  21. package/assets/skills/matrix-open/agents/openai.yaml +4 -0
  22. package/{.claude → assets}/skills/matrix-status/SKILL.md +15 -15
  23. package/{.claude → assets}/skills/matrix-status/agents/openai.yaml +4 -4
  24. package/{.claude → assets}/skills/matrix-tweak/SKILL.md +8 -8
  25. package/assets/skills/matrix-tweak/agents/openai.yaml +4 -0
  26. package/{.claude → assets}/skills/matrix-verify/SKILL.md +62 -62
  27. package/assets/skills/matrix-verify/agents/openai.yaml +4 -0
  28. package/assets/skills-zh-CN/matrix/SKILL.md +14 -14
  29. package/assets/skills-zh-CN/matrix-build/SKILL.md +4 -4
  30. package/assets/skills-zh-CN/matrix-design/SKILL.md +4 -4
  31. package/assets/skills-zh-CN/matrix-open/SKILL.md +3 -3
  32. package/assets/skills-zh-CN/matrix-verify/SKILL.md +19 -19
  33. package/bin/matrix.js +15 -15
  34. package/package.json +4 -13
  35. package/src/catalog.js +79 -72
  36. package/src/cli.js +100 -100
  37. package/src/distribution.js +181 -178
  38. package/src/installer.js +10 -10
  39. package/src/matt-catalog.mjs +1 -1
  40. package/src/matt.js +115 -115
  41. package/src/messages.js +14 -14
  42. package/src/runtime-resolver.js +76 -76
  43. package/src/self-update.js +81 -81
  44. package/src/workflow-transaction.js +13 -13
  45. package/src/workflow.js +711 -705
  46. package/.claude/skills/matrix-open/agents/openai.yaml +0 -4
  47. package/.claude/skills/matrix-tweak/agents/openai.yaml +0 -4
  48. package/.claude/skills/matrix-verify/agents/openai.yaml +0 -4
@@ -0,0 +1,69 @@
1
+ import json
2
+ import os
3
+ import shutil
4
+ import subprocess
5
+ import sys
6
+ import tempfile
7
+ import unittest
8
+ from pathlib import Path
9
+
10
+ STATE = Path(__file__).with_name("matrix_state.py")
11
+ CLAUDE = Path(__file__).with_name("matrix_claude.py")
12
+ RUNTIME = Path(__file__).resolve().parents[4] / "src" / "workflow.js"
13
+ NODE_DIRECTORY = str(Path(shutil.which("node") or "").parent)
14
+
15
+
16
+ class MatrixClaudeTests(unittest.TestCase):
17
+ def invoke(self, script, *args, cwd):
18
+ env = {**os.environ, "PATH": NODE_DIRECTORY, "MATRIX_DEVELOPMENT_RUNTIME": str(RUNTIME)}
19
+ return subprocess.run([sys.executable, str(script), *args], cwd=cwd, env=env, text=True, capture_output=True)
20
+
21
+ def inspect(self, cwd):
22
+ return json.loads(self.invoke(STATE, "inspect", cwd=cwd).stdout)
23
+
24
+ def make_design_change(self, cwd):
25
+ self.assertEqual(self.invoke(STATE, "init", "bridge", "--title", "Bridge", cwd=cwd).returncode, 0)
26
+ artifacts = cwd / ".matrix/changes/bridge/artifacts"
27
+ (artifacts / "proposal.md").write_text("## Goal\nBuild a bounded feature.\n\n## Scope\nOne module only.\n\n## Non-goals\nNo extra work.\n\n## Acceptance\nA focused test passes.\n\n## Risks\nKnown risk.\n")
28
+ self.assertEqual(self.invoke(STATE, "transition", "design", cwd=cwd).returncode, 0)
29
+ (artifacts / "design.md").write_text("## Decisions\nKeep one public seam.\n\n## Boundaries\nOne public seam only.\n\n## Test seams\nUse the public interface.\n\n## Risks\nKnown risk.\n")
30
+ (artifacts / "plan.md").write_text("## Steps\n1. Add a failing test.\n\n## Validation\nRun the focused test.\n\n## Stop conditions\nStop on scope change.\n")
31
+ self.assertEqual(self.invoke(STATE, "transition", "build", cwd=cwd).returncode, 0)
32
+
33
+ def test_generic_export_does_not_change_matrix_state(self):
34
+ with tempfile.TemporaryDirectory() as temp:
35
+ cwd = Path(temp)
36
+ self.make_design_change(cwd)
37
+ result = self.invoke(CLAUDE, "export", "--task-id", "GEN-001", cwd=cwd)
38
+ self.assertEqual(result.returncode, 0, result.stderr)
39
+ task = cwd / ".matrix/changes/bridge/artifacts/claude-task.md"
40
+ self.assertIn("## Prohibited work", task.read_text(encoding="utf-8"))
41
+ self.assertEqual(self.inspect(cwd)["phase"], "build")
42
+
43
+ def test_fnsec_board_refuses_existing_objective(self):
44
+ with tempfile.TemporaryDirectory() as temp:
45
+ cwd = Path(temp)
46
+ self.make_design_change(cwd)
47
+ tasks = cwd / "docs/tasks"
48
+ tasks.mkdir(parents=True)
49
+ (tasks / "active.md").write_text("# Active task\n", encoding="utf-8")
50
+ result = self.invoke(CLAUDE, "export", "--task-id", "FNSEC-X", "--target", "fnsec", "--apply-fnsec-board", cwd=cwd)
51
+ self.assertNotEqual(result.returncode, 0)
52
+ self.assertFalse((tasks / "claude-task-FNSEC-X.md").exists(), result.stdout + result.stderr)
53
+
54
+ def test_fnsec_export_updates_empty_board_only(self):
55
+ with tempfile.TemporaryDirectory() as temp:
56
+ cwd = Path(temp)
57
+ self.make_design_change(cwd)
58
+ tasks = cwd / "docs/tasks"
59
+ tasks.mkdir(parents=True)
60
+ (tasks / "active.md").write_text("# NO_ACTIVE_OBJECTIVE\n", encoding="utf-8")
61
+ result = self.invoke(CLAUDE, "export", "--task-id", "FNSEC-Y", "--target", "fnsec", "--apply-fnsec-board", cwd=cwd)
62
+ self.assertEqual(result.returncode, 0, result.stderr)
63
+ self.assertIn("## Prohibited work", (tasks / "claude-task-FNSEC-Y.md").read_text(encoding="utf-8"))
64
+ self.assertIn("CLAUDE_QUEUED", (tasks / "active.md").read_text(encoding="utf-8"))
65
+ self.assertEqual(self.inspect(cwd)["phase"], "build")
66
+
67
+
68
+ if __name__ == "__main__":
69
+ unittest.main()
@@ -0,0 +1,69 @@
1
+ import json
2
+ import importlib.util
3
+ import os
4
+ import shutil
5
+ import subprocess
6
+ import sys
7
+ import tempfile
8
+ import unittest
9
+ from unittest import mock
10
+ from pathlib import Path
11
+
12
+ SCRIPT = Path(__file__).with_name("matrix_state.py")
13
+ RUNTIME = Path(__file__).resolve().parents[4] / "src" / "workflow.js"
14
+ NODE_DIRECTORY = str(Path(shutil.which("node") or "").parent)
15
+ class MatrixStateTests(unittest.TestCase):
16
+ def invoke(self, *args, cwd):
17
+ env = {**os.environ, "PATH": NODE_DIRECTORY, "MATRIX_DEVELOPMENT_RUNTIME": str(RUNTIME)}
18
+ return subprocess.run([sys.executable, str(SCRIPT), *args], cwd=cwd, env=env, text=True, capture_output=True)
19
+ def load_adapter(self, directory):
20
+ script = directory / "matrix_state.py"
21
+ shutil.copyfile(SCRIPT, script)
22
+ spec = importlib.util.spec_from_file_location(f"matrix_state_{directory.name}", script)
23
+ module = importlib.util.module_from_spec(spec)
24
+ spec.loader.exec_module(module)
25
+ return module
26
+ def test_runtime_precedence_is_bundled_then_global(self):
27
+ with tempfile.TemporaryDirectory() as temp:
28
+ directory = Path(temp)
29
+ adapter = self.load_adapter(directory)
30
+ bundled = directory / "matrix-runtime.mjs"
31
+ bundled.write_text("// project runtime\n", encoding="utf-8")
32
+ with mock.patch.object(adapter, "development_runtime", return_value=None), mock.patch.object(adapter, "primary_runtime", return_value="global-matrix"):
33
+ command = adapter.runtime_command(["inspect"])
34
+ self.assertEqual(Path(command[1]), bundled)
35
+ bundled.unlink()
36
+ with mock.patch.object(adapter, "development_runtime", return_value=None), mock.patch.object(adapter, "primary_runtime", return_value="global-matrix"):
37
+ self.assertEqual(adapter.runtime_command(["inspect"]), ["global-matrix", "workflow", "inspect", "--json"])
38
+ def test_phase_guard_and_recovery(self):
39
+ with tempfile.TemporaryDirectory() as temp:
40
+ cwd = Path(temp); result = self.invoke("init", "sample", "--title", "Sample", cwd=cwd); self.assertEqual(result.returncode, 0)
41
+ self.assertTrue((cwd / ".matrix" / "active.json").exists())
42
+ self.assertFalse((cwd / ".codex").exists())
43
+ self.assertNotEqual(self.invoke("transition", "design", cwd=cwd).returncode, 0)
44
+ p = cwd / ".matrix/changes/sample/artifacts"
45
+ (p / "proposal.md").write_text("## Goal\nBuild a bounded feature.\n\n## Scope\nOne module only.\n\n## Non-goals\nNo extra work.\n\n## Acceptance\nA focused test passes.\n\n## Risks\nKnown risk.\n")
46
+ self.assertEqual(self.invoke("transition", "design", cwd=cwd).returncode, 0)
47
+ self.assertEqual(json.loads(self.invoke("inspect", cwd=cwd).stdout)["phase"], "design")
48
+
49
+ def test_full_lifecycle_requires_evidence(self):
50
+ with tempfile.TemporaryDirectory() as temp:
51
+ cwd = Path(temp); self.assertEqual(self.invoke("init", "full", "--title", "Full", cwd=cwd).returncode, 0)
52
+ p = cwd / ".matrix/changes/full/artifacts"
53
+ (p / "proposal.md").write_text("## Goal\nBuild a bounded feature.\n\n## Scope\nOne module only.\n\n## Non-goals\nNo extra work.\n\n## Acceptance\nA focused test passes.\n\n## Risks\nKnown risk.\n")
54
+ self.assertEqual(self.invoke("transition", "design", cwd=cwd).returncode, 0)
55
+ self.assertNotEqual(self.invoke("transition", "build", cwd=cwd).returncode, 0)
56
+ (p / "design.md").write_text("## Decisions\nKeep one public seam.\n\n## Boundaries\nOne public seam only.\n\n## Test seams\nUse the public interface.\n\n## Risks\nKnown risk.\n")
57
+ (p / "plan.md").write_text("## Steps\n1. Add a failing test.\n\n## Validation\nRun the focused test.\n\n## Stop conditions\nStop on scope change.\n")
58
+ self.assertEqual(self.invoke("transition", "build", cwd=cwd).returncode, 0)
59
+ (p / "verification.md").write_text("## Build evidence\nThe focused implementation test command completed successfully with an expected result.\n")
60
+ self.assertEqual(self.invoke("transition", "verify", cwd=cwd).returncode, 0)
61
+ self.assertNotEqual(self.invoke("transition", "archive", cwd=cwd).returncode, 0)
62
+ (p / "verification.md").write_text("## Build evidence\nThe focused implementation test command completed successfully with an expected result.\n\n## Test evidence\nThe acceptance command passed and its output was reviewed for the requested behavior.\n\n## Review evidence\nThe fixed-baseline standards and specification review found no blocking issue.\n")
63
+ self.assertEqual(self.invoke("transition", "archive", cwd=cwd).returncode, 0)
64
+ preflight = self.invoke("archive", "--dry-run", cwd=cwd)
65
+ self.assertEqual(preflight.returncode, 0)
66
+ token = json.loads(preflight.stdout)["preflight_hash"]
67
+ self.assertEqual(self.invoke("archive", "--expect-preflight", token, cwd=cwd).returncode, 0)
68
+ self.assertTrue((cwd / ".matrix/archive/full/matrix.yaml").exists())
69
+ if __name__ == "__main__": unittest.main()
@@ -1,36 +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
- 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.
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.
@@ -1,4 +1,4 @@
1
- interface:
2
- display_name: "Matrix Workflow"
3
- short_description: "Persistent development workflow stage"
4
- default_prompt: "Use $name to continue a Matrix development workflow."
1
+ interface:
2
+ display_name: "Matrix Workflow"
3
+ short_description: "Persistent development workflow stage"
4
+ default_prompt: "Use $name to continue a Matrix development workflow."
@@ -1,47 +1,47 @@
1
- ---
2
- name: matrix-build
3
- description: Implement the frozen active Matrix plan with test-first vertical slices. Use when the active Matrix phase is build.
4
- ---
5
-
6
- # Matrix Build
7
-
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
-
1
+ ---
2
+ name: matrix-build
3
+ description: Implement the frozen active Matrix plan with test-first vertical slices. Use when the active Matrix phase is build.
4
+ ---
5
+
6
+ # Matrix Build
7
+
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
+
18
18
  - invoke `tdd` when the change modifies observable behavior at a testable seam;
19
19
  - invoke `diagnosing-bugs` only when an actual failure exists and root cause is not established;
20
20
  - invoke `writing-for-agents` when the approved Contract changes agent-facing instructions;
21
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.
22
22
 
23
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.
26
-
27
- ## Scope Discipline
28
-
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.
36
-
37
- ## Process
38
-
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`.
43
-
44
- ```powershell
45
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
46
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
47
- ```
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.
26
+
27
+ ## Scope Discipline
28
+
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.
36
+
37
+ ## Process
38
+
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`.
43
+
44
+ ```powershell
45
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
46
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
47
+ ```
@@ -1,4 +1,4 @@
1
- interface:
2
- display_name: "Matrix Workflow"
3
- short_description: "Persistent development workflow stage"
4
- default_prompt: "Use $name to continue a Matrix development workflow."
1
+ interface:
2
+ display_name: "Matrix Workflow"
3
+ short_description: "Persistent development workflow stage"
4
+ default_prompt: "Use $name to continue a Matrix development workflow."
@@ -1,98 +1,98 @@
1
- ---
2
- name: matrix-claude
3
- description: Export a frozen Matrix design as a bounded Claude Code task package without changing Matrix workflow state. Use when Codex should design and Claude Code should implement.
4
- ---
5
-
6
- # Matrix Claude Handoff
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`. 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.
11
-
12
- ## When to Use
13
-
14
- Use `$matrix-claude` when:
15
- - The active change is in Build and the Design -> Build transition has approved the contract
16
- - You want Claude Code (instead of Codex) to implement the design
17
- - You need a bounded task package with all implementation details
18
-
19
- ## Preconditions
20
-
21
- The exporter performs this read-only check before writing anything:
22
-
23
- ```powershell
24
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
25
- ```
26
-
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.
28
-
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.
30
-
31
- ## Export
32
-
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.
34
-
35
- ```powershell
36
- # Generic project: only exports a Matrix artifact.
37
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs export --task-id <ID> --target generic
38
-
39
- # FnSec: exports its formal task package. Add --apply-fnsec-board only when
40
- # active.md is NO_ACTIVE_OBJECTIVE; an existing task is never overwritten.
41
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs export --task-id <ID> --target fnsec --apply-fnsec-board
42
- ```
43
-
44
- ## Task Package Contents
45
-
46
- The exported package (`artifacts/claude-task.md`) contains everything Claude Code needs to implement and produce evidence for `$matrix-verify`:
47
-
48
- 1. **Task ID, execution actor, and approved contract hash**: Claude Code and the exact approved snapshot
49
- 2. **Objective and acceptance criteria** — copied from `proposal.md`
50
- 3. **In-scope and out-of-scope boundaries** — from `proposal.md`
51
- 4. **Frozen design decisions** — from `design.md` (Decisions, Boundaries, Test seams)
52
- 5. **Ordered implementation plan** — from `plan.md` (Steps, Validation)
53
- 6. **Allowed and prohibited files/actions** — to prevent scope creep
54
- 7. **Required commands** — test, lint, typecheck, build commands to run
55
- 8. **Stop conditions** — ambiguity, scope expansion, failing acceptance, design conflict
56
- 9. **Required evidence for verify**:
57
- - Changed files list
58
- - Commands and their outputs
59
- - Test results (pass/fail)
60
- - Build evidence
61
- - Residual risks
62
- - `NEEDS_DECISION` items (if any)
63
-
64
- ## After Claude Code Completes
65
-
66
- When Claude Code returns results, verify that the following evidence is present before proceeding to `$matrix-verify`:
67
-
68
- - [ ] `artifacts/verification.md` exists with `## Build evidence` section
69
- - [ ] Build evidence includes concrete commands and outcomes
70
- - [ ] All tests in the plan's validation section have been run
71
- - [ ] Any `NEEDS_DECISION` items have been resolved or documented
72
-
73
- If evidence is missing, ask Claude Code to补充 before proceeding.
74
-
75
- ## Resuming Matrix Workflow
76
-
77
- After Claude Code completes and evidence is present:
78
-
79
- 1. Run build guard to verify evidence:
80
- ```powershell
81
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
82
- ```
83
-
84
- 2. If guard passes, transition to verify:
85
- ```powershell
86
- node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
87
- ```
88
-
89
- 3. Enter `$matrix-verify` to继续验证流程
90
-
91
- If the build guard fails, return to Claude Code to补充 missing evidence.
92
-
93
- ## Important Notes
94
-
95
- - This sidecar does NOT change Matrix phase, workflow, or guard result
96
- - The Matrix state remains in `build` phase; export itself does not advance it
97
- - Claude Code must produce evidence that satisfies the build guard conditions
98
- - After successful transition to verify, the normal verify流程 continues
1
+ ---
2
+ name: matrix-claude
3
+ description: Export a frozen Matrix design as a bounded Claude Code task package without changing Matrix workflow state. Use when Codex should design and Claude Code should implement.
4
+ ---
5
+
6
+ # Matrix Claude Handoff
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`. 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.
11
+
12
+ ## When to Use
13
+
14
+ Use `$matrix-claude` when:
15
+ - The active change is in Build and the Design -> Build transition has approved the contract
16
+ - You want Claude Code (instead of Codex) to implement the design
17
+ - You need a bounded task package with all implementation details
18
+
19
+ ## Preconditions
20
+
21
+ The exporter performs this read-only check before writing anything:
22
+
23
+ ```powershell
24
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
25
+ ```
26
+
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.
28
+
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.
30
+
31
+ ## Export
32
+
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.
34
+
35
+ ```powershell
36
+ # Generic project: only exports a Matrix artifact.
37
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs export --task-id <ID> --target generic
38
+
39
+ # FnSec: exports its formal task package. Add --apply-fnsec-board only when
40
+ # active.md is NO_ACTIVE_OBJECTIVE; an existing task is never overwritten.
41
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs export --task-id <ID> --target fnsec --apply-fnsec-board
42
+ ```
43
+
44
+ ## Task Package Contents
45
+
46
+ The exported package (`artifacts/claude-task.md`) contains everything Claude Code needs to implement and produce evidence for `$matrix-verify`:
47
+
48
+ 1. **Task ID, execution actor, and approved contract hash**: Claude Code and the exact approved snapshot
49
+ 2. **Objective and acceptance criteria** — copied from `proposal.md`
50
+ 3. **In-scope and out-of-scope boundaries** — from `proposal.md`
51
+ 4. **Frozen design decisions** — from `design.md` (Decisions, Boundaries, Test seams)
52
+ 5. **Ordered implementation plan** — from `plan.md` (Steps, Validation)
53
+ 6. **Allowed and prohibited files/actions** — to prevent scope creep
54
+ 7. **Required commands** — test, lint, typecheck, build commands to run
55
+ 8. **Stop conditions** — ambiguity, scope expansion, failing acceptance, design conflict
56
+ 9. **Required evidence for verify**:
57
+ - Changed files list
58
+ - Commands and their outputs
59
+ - Test results (pass/fail)
60
+ - Build evidence
61
+ - Residual risks
62
+ - `NEEDS_DECISION` items (if any)
63
+
64
+ ## After Claude Code Completes
65
+
66
+ When Claude Code returns results, verify that the following evidence is present before proceeding to `$matrix-verify`:
67
+
68
+ - [ ] `artifacts/verification.md` exists with `## Build evidence` section
69
+ - [ ] Build evidence includes concrete commands and outcomes
70
+ - [ ] All tests in the plan's validation section have been run
71
+ - [ ] Any `NEEDS_DECISION` items have been resolved or documented
72
+
73
+ If evidence is missing, ask Claude Code to补充 before proceeding.
74
+
75
+ ## Resuming Matrix Workflow
76
+
77
+ After Claude Code completes and evidence is present:
78
+
79
+ 1. Run build guard to verify evidence:
80
+ ```powershell
81
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs guard build
82
+ ```
83
+
84
+ 2. If guard passes, transition to verify:
85
+ ```powershell
86
+ node <matrix-skill-directory>/scripts/matrix-runtime.mjs transition verify
87
+ ```
88
+
89
+ 3. Enter `$matrix-verify` to继续验证流程
90
+
91
+ If the build guard fails, return to Claude Code to补充 missing evidence.
92
+
93
+ ## Important Notes
94
+
95
+ - This sidecar does NOT change Matrix phase, workflow, or guard result
96
+ - The Matrix state remains in `build` phase; export itself does not advance it
97
+ - Claude Code must produce evidence that satisfies the build guard conditions
98
+ - After successful transition to verify, the normal verify流程 continues
@@ -1,4 +1,4 @@
1
- interface:
2
- display_name: "Matrix Claude Handoff"
3
- short_description: "Export frozen Matrix design as a Claude Code task"
4
- default_prompt: "Use $matrix-claude to prepare a Claude Code task package."
1
+ interface:
2
+ display_name: "Matrix Claude Handoff"
3
+ short_description: "Export frozen Matrix design as a Claude Code task"
4
+ default_prompt: "Use $matrix-claude to prepare a Claude Code task package."