morphisms 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/LICENSE +45 -0
  2. package/bin/mor-workbench.js +3 -0
  3. package/bin/mor.js +3 -0
  4. package/bin/morphisms.js +9 -0
  5. package/lib/cli.js +28 -0
  6. package/lib/files.js +49 -0
  7. package/lib/forward.js +45 -0
  8. package/lib/init.js +190 -0
  9. package/lib/platform.js +40 -0
  10. package/lib/update.js +45 -0
  11. package/lib/workbench.js +120 -0
  12. package/package.json +24 -0
  13. package/templates/README.md +21 -0
  14. package/templates/agent/.gitkeep +0 -0
  15. package/templates/agent/skills/morphisms/SKILL.md +86 -0
  16. package/templates/claude/.gitkeep +0 -0
  17. package/templates/claude/skills/morphisms/SKILL.md +86 -0
  18. package/templates/contract/README.md +57 -0
  19. package/templates/contract/contract.mor +247 -0
  20. package/templates/contract/personas/investigator.md +20 -0
  21. package/templates/contract/personas/operator-facing-intake.md +16 -0
  22. package/templates/contract/personas/plan-reviewer.md +20 -0
  23. package/templates/contract/personas/scoper.md +23 -0
  24. package/templates/contract/personas/triager.md +22 -0
  25. package/templates/contract/schemas/investigation-report.schema.json +28 -0
  26. package/templates/contract/schemas/operator-decision.schema.json +13 -0
  27. package/templates/contract/schemas/plan-review.schema.json +26 -0
  28. package/templates/contract/schemas/scoped-plan.schema.json +25 -0
  29. package/templates/contract/schemas/triage-decision.schema.json +25 -0
  30. package/templates/instructions/starter-issues-agent-manual.md +232 -0
  31. package/templates/instructions/workspace-agent-manual.md +22 -0
  32. package/templates/manifest.json +22 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "description": "Rigorous-lane plan review. PASS is the closing artifact for ready rigorous plans; REVISE loops to scoping.",
5
+ "required": ["review_round", "reviewed_plan_round", "gate", "review_summary"],
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "review_round": {"type": "integer", "minimum": 1, "description": "Monotone review attempt number for this rigorous issue."},
9
+ "reviewed_plan_round": {"type": "integer", "minimum": 1, "description": "The scoped_plan.plan_round this review evaluates."},
10
+ "gate": {"type": "string", "enum": ["PASS", "REVISE"]},
11
+ "review_summary": {"type": "string", "minLength": 1},
12
+ "review_outcome": {"type": "string", "enum": ["ready_for_execution"]},
13
+ "required_changes": {"type": "array", "items": {"type": "string", "minLength": 1}, "default": []},
14
+ "risk_notes": {"type": "array", "items": {"type": "string", "minLength": 1}, "default": []}
15
+ },
16
+ "allOf": [
17
+ {
18
+ "if": {"properties": {"gate": {"const": "PASS"}}, "required": ["gate"]},
19
+ "then": {"required": ["review_outcome"], "properties": {"review_outcome": {"const": "ready_for_execution"}}}
20
+ },
21
+ {
22
+ "if": {"properties": {"gate": {"const": "REVISE"}}, "required": ["gate"]},
23
+ "then": {"required": ["required_changes"], "properties": {"required_changes": {"minItems": 1}}}
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "description": "Scoped front-half plan and handoff prompt, or a blocked outcome with explanation.",
5
+ "required": ["plan_round", "plan_outcome", "problem", "evidence", "approach", "acceptance_criteria", "handoff_prompt"],
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "plan_round": {"type": "integer", "minimum": 1, "description": "Monotone review-loop round for rigorous lane; increment after each REVISE."},
9
+ "based_on_review_round": {"type": "integer", "minimum": 1, "description": "Prior REVISE review_round this plan answers, when applicable."},
10
+ "plan_outcome": {"type": "string", "enum": ["ready_for_execution", "blocked"]},
11
+ "problem": {"type": "string", "minLength": 1},
12
+ "evidence": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
13
+ "approach": {"type": "string", "minLength": 1},
14
+ "acceptance_criteria": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
15
+ "handoff_prompt": {"type": "string", "minLength": 1},
16
+ "blocker": {"type": "string", "minLength": 1},
17
+ "non_goals": {"type": "array", "items": {"type": "string", "minLength": 1}, "default": []}
18
+ },
19
+ "allOf": [
20
+ {
21
+ "if": {"properties": {"plan_outcome": {"const": "blocked"}}, "required": ["plan_outcome"]},
22
+ "then": {"required": ["blocker"]}
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "description": "Triage evidence choosing the issue lane or closing as discarded/duplicate.",
5
+ "required": ["decision", "rationale"],
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "decision": {"type": "string", "enum": ["quick", "standard", "rigorous", "discard", "duplicate"]},
9
+ "rationale": {"type": "string", "minLength": 1},
10
+ "signals": {"type": "array", "items": {"type": "string", "minLength": 1}, "default": []},
11
+ "closing_outcome": {"type": "string", "enum": ["discarded", "duplicate"]},
12
+ "duplicate_of": {"type": "string", "minLength": 1},
13
+ "operator_question": {"type": "string", "minLength": 1}
14
+ },
15
+ "allOf": [
16
+ {
17
+ "if": {"properties": {"decision": {"const": "discard"}}, "required": ["decision"]},
18
+ "then": {"required": ["closing_outcome"], "properties": {"closing_outcome": {"const": "discarded"}}}
19
+ },
20
+ {
21
+ "if": {"properties": {"decision": {"const": "duplicate"}}, "required": ["decision"]},
22
+ "then": {"required": ["closing_outcome", "duplicate_of"], "properties": {"closing_outcome": {"const": "duplicate"}}}
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,232 @@
1
+ # Starter issues distro instructions
2
+
3
+ This is the S3 distro layer for `starter_issues_front_half/v1`.
4
+
5
+ ## Contract map
6
+
7
+ - Store: `issues`; CLI alias: `issue`; ids: `ISS0001`, `ISS0002`, ...
8
+ - Fields accepted at add time: `title`, `kind`, `summary`. `kind` is `bug | idea | feature`. `priority`, `reporter_context`, and `source_anchor` default at add time.
9
+ - Dimensions:
10
+ - `journey`: `triage` initial; `investigating`; `scoping`; `plan_review`; `done` terminal.
11
+ - `attention`: `autonomous_entry` initial; `autonomous`; `awaiting_operator`.
12
+ - Personas:
13
+ - `journey.triage` -> `triager`
14
+ - `journey.investigating` -> `investigator`
15
+ - `journey.scoping` -> `scoper`
16
+ - `journey.plan_review` -> `plan-reviewer`
17
+ - `attention.awaiting_operator` -> `operator-facing-intake`
18
+
19
+ ## Actionability
20
+
21
+ - Human-only: `attention.awaiting_operator`. Stop, summarize the ambiguity, and wait for `operator_decision`.
22
+ - Agent-actionable: `journey.triage`, `journey.investigating`, `journey.scoping`, `journey.plan_review`, `attention.autonomous_entry`, `attention.autonomous`.
23
+ - Terminal: `journey.done` means this record's front-half journey is complete. Read the typed outcome evidence to know whether it was ready, blocked, duplicate, or discarded.
24
+ - No automatic task materialization. This front half ends at `journey.done` with a typed outcome artifact and, for ready work, a `scoped_plan.handoff_prompt`.
25
+
26
+ ## Artifacts
27
+
28
+ - `triage_decision`: `decision` is `quick | standard | rigorous | discard | duplicate`; include `rationale`, `signals[]` when useful, and `operator_question` only if human ambiguity must route through attention; use `closing_outcome` for discard/duplicate and `duplicate_of` for duplicate.
29
+ - `investigation_report`: `finding` is `confirmed | not_reproduced | needs_scope | blocked`; include `summary`; `citations` must be non-empty with `{file,line,excerpt,why_it_matters}`; include `reproduction_steps[]` and `open_questions[]` as applicable.
30
+ - `scoped_plan`: include `plan_round`, optional `based_on_review_round`, `plan_outcome` (`ready_for_execution | blocked`), `problem`, `evidence`, `approach`, `acceptance_criteria`, `handoff_prompt`; include `blocker` when blocked and `non_goals[]` when useful.
31
+ - `plan_review`: rigorous lane only; include `review_round`, `reviewed_plan_round`, `gate` (`PASS | REVISE`), `review_summary`, and `risk_notes[]` (`[]` is acceptable); include `review_outcome=ready_for_execution` for PASS or `required_changes[]` for REVISE.
32
+ - `operator_decision`: human answer for attention; `decision` is `resume | revise_scope`; include `rationale`, optional `instructions`, and `answered_questions[]`.
33
+
34
+ Rigorous PASS example: `{"review_round":1,"reviewed_plan_round":1,"gate":"PASS","review_summary":"Ready with manageable risk.","review_outcome":"ready_for_execution","risk_notes":[]}`. Rigorous REVISE example: `{"review_round":1,"reviewed_plan_round":1,"gate":"REVISE","review_summary":"Needs narrower scope.","required_changes":["Split risky migration out."],"risk_notes":["Migration touches auth flow."]}`.
35
+
36
+ ## Edges
37
+
38
+ Journey:
39
+
40
+ - `journey.choose_quick_scope`: `triage` -> `scoping`, requires latest `triage_decision.decision=quick`.
41
+ - `journey.choose_standard_investigation`: `triage` -> `investigating`, requires latest `triage_decision.decision=standard`.
42
+ - `journey.choose_rigorous_investigation`: `triage` -> `investigating`, requires latest `triage_decision.decision=rigorous`.
43
+ - `journey.close_discarded_from_triage`: `triage` -> `done`, requires `decision=discard` and `closing_outcome=discarded`.
44
+ - `journey.close_duplicate_from_triage`: `triage` -> `done`, requires `decision=duplicate`, `closing_outcome=duplicate`, and `duplicate_of`.
45
+ - `journey.submit_standard_investigation`: `investigating` -> `scoping`, requires standard `triage_decision` and latest `investigation_report`.
46
+ - `journey.submit_rigorous_investigation`: `investigating` -> `scoping`, requires rigorous `triage_decision` and latest `investigation_report`.
47
+ - `journey.complete_scoped_plan`: `scoping` -> `done`, requires `scoped_plan.plan_outcome=ready_for_execution` and quick or standard triage.
48
+ - `journey.close_blocked_from_scoping`: `scoping` -> `done`, requires `scoped_plan.plan_outcome=blocked`.
49
+ - `journey.submit_rigorous_plan_review`: `scoping` -> `plan_review`, requires rigorous triage, investigation, ready scoped plan, and a scoped plan fresh after the latest revise loop.
50
+ - `journey.revise_rigorous_plan`: `plan_review` -> `scoping`, requires fresh `plan_review.gate=REVISE`.
51
+ - `journey.approve_rigorous_plan`: `plan_review` -> `done`, requires fresh `plan_review.gate=PASS` and `review_outcome=ready_for_execution`.
52
+
53
+ Attention:
54
+
55
+ - `attention.start_autonomous`: `autonomous_entry` -> `autonomous`.
56
+ - `attention.request_operator_from_entry`: `autonomous_entry` -> `awaiting_operator`.
57
+ - `attention.request_operator`: `autonomous` -> `awaiting_operator`.
58
+ - `attention.return_to_autonomous`: `awaiting_operator` -> `autonomous`, requires latest `operator_decision`.
59
+
60
+ ## Normal loop
61
+
62
+ 1. List frontier: `mor issue ls`.
63
+ 2. Hydrate current node: `mor issue hydrate <id> <dimension.state>`.
64
+ 3. Use the persona/context packet. Produce only the artifact this node is authorized to produce.
65
+ 4. Attach evidence: `mor issue enrich <id> <artifact_kind> --role <role> --payload <file>`.
66
+ 5. Walk one edge: `mor issue walk <id> <dimension.edge>`.
67
+ 6. Verify with `mor issue inspect <id>` or by hydrating the new node.
68
+
69
+ ## Concierge onboarding
70
+
71
+ If `.mor/onboarding-complete` does **not** exist, you are in concierge mode. Do this before normal orchestration.
72
+
73
+ ### 1. Ask for one real annoyance
74
+
75
+ Say:
76
+
77
+ > Let's make this real. Give me one bug, annoyance, or confusing behavior in this repo. If you do not have one ready, I can scan the repo and propose one small first issue.
78
+
79
+ If the human gives an issue, file it. If they ask you to scan, inspect files normally and choose a small truthful annoyance grounded in the repo.
80
+
81
+ Create the first issue with only add-accepted fields:
82
+
83
+ ```json
84
+ {"title":"<short title>","kind":"bug","summary":"<human words plus any repo clue>"}
85
+ ```
86
+
87
+ ```bash
88
+ mor issue add --payload /tmp/morphisms-first-issue.json
89
+ ```
90
+
91
+ Narrate: "I filed the first `issue` record. The graph should now show it at `journey.triage` and `attention.autonomous_entry` in Workbench: http://localhost:4400/#workbench."
92
+
93
+ ### 2. Hydrate and explain the packet
94
+
95
+ Run:
96
+
97
+ ```bash
98
+ mor issue hydrate <id> journey.triage
99
+ ```
100
+
101
+ Narrate the first occurrence: "Hydration is the handoff packet: record fields, persona, context, legal edges, and missing witnesses. I follow this packet instead of guessing."
102
+
103
+ ### 3. Show one deliberate refusal
104
+
105
+ Before attaching `triage_decision`, intentionally attempt the standard lane once:
106
+
107
+ ```bash
108
+ mor issue walk <id> journey.choose_standard_investigation
109
+ ```
110
+
111
+ Expect a blocked/refused result such as a missing `triage_decision` witness. Narrate: "This refusal is the safety rail. MOR will not let me move the graph until the typed evidence exists."
112
+
113
+ ### 4. Triage into a real investigation lane
114
+
115
+ Attach a standard triage decision unless the issue truly needs rigorous review:
116
+
117
+ ```json
118
+ {"decision":"standard","rationale":"Needs one file/line investigation before scoping.","signals":["<signal>"]}
119
+ ```
120
+
121
+ ```bash
122
+ mor issue enrich <id> triage_decision --role triage_decision --payload /tmp/triage.json
123
+ mor issue walk <id> journey.choose_standard_investigation
124
+ mor issue hydrate <id> journey.investigating
125
+ ```
126
+
127
+ Narrate the graph movement in Workbench.
128
+
129
+ ### 5. Investigate with citations
130
+
131
+ Do a real repo read. The `investigation_report.citations` array must be non-empty and cite real file lines:
132
+
133
+ ```json
134
+ {
135
+ "finding":"confirmed",
136
+ "summary":"<what the code showed>",
137
+ "citations":[{"file":"path/to/file","line":123,"excerpt":"<exact excerpt>","why_it_matters":"<why>"}],
138
+ "reproduction_steps":["<step>"],
139
+ "open_questions":[]
140
+ }
141
+ ```
142
+
143
+ ```bash
144
+ mor issue enrich <id> investigation_report --role investigation_report --payload /tmp/investigation.json
145
+ mor issue walk <id> journey.submit_standard_investigation
146
+ mor issue hydrate <id> journey.scoping
147
+ ```
148
+
149
+ ### 6. Scope to a typed front-half outcome
150
+
151
+ Attach a scoped plan with a handoff prompt:
152
+
153
+ ```json
154
+ {
155
+ "plan_round":1,
156
+ "plan_outcome":"ready_for_execution",
157
+ "problem":"<problem>",
158
+ "evidence":["path/to/file:123 <fact>"],
159
+ "approach":"<approach>",
160
+ "acceptance_criteria":["<criterion>"],
161
+ "handoff_prompt":"<prompt another agent can execute>",
162
+ "non_goals":[]
163
+ }
164
+ ```
165
+
166
+ ```bash
167
+ mor issue enrich <id> scoped_plan --role scoped_plan --payload /tmp/scoped-plan.json
168
+ mor issue inspect <id>
169
+ ```
170
+
171
+ If the honest outcome is blocked, set `plan_outcome=blocked` and include `blocker`; do not close the journey until after the human-collab step below.
172
+
173
+ ### 7. Route one real human-collab moment
174
+
175
+ After the scoped plan is attached and before closing the journey, route the record to the human in the `attention` dimension. First inspect the current attention state:
176
+
177
+ ```bash
178
+ mor issue inspect <id>
179
+ ```
180
+
181
+ If `attention=autonomous_entry`, run:
182
+
183
+ ```bash
184
+ mor issue walk <id> attention.request_operator_from_entry
185
+ ```
186
+
187
+ If `attention=autonomous`, run:
188
+
189
+ ```bash
190
+ mor issue walk <id> attention.request_operator
191
+ ```
192
+
193
+ Tell the human: "The record is now waiting for YOU at `attention.awaiting_operator`. In an armed Workbench thread, this is the `Review now` moment; otherwise use the record card in Workbench: http://localhost:4400/#workbench. Please answer whether I should resume and close this scoped plan, or revise scope."
194
+
195
+ Use the human's actual answer as the `operator_decision`; do not fabricate it. For a resume answer, attach:
196
+
197
+ ```json
198
+ {"decision":"resume","rationale":"<human's answer>","instructions":"Proceed with the scoped plan outcome.","answered_questions":["Resume and close this scoped plan?"]}
199
+ ```
200
+
201
+ ```bash
202
+ mor issue enrich <id> operator_decision --role operator_decision --payload /tmp/operator-decision.json
203
+ mor issue walk <id> attention.return_to_autonomous
204
+ ```
205
+
206
+ Narrate: "This is how future work pauses only when it needs you, then resumes after your typed decision."
207
+
208
+ ### 8. Close the journey
209
+
210
+ For a ready quick/standard scoped plan, close with:
211
+
212
+ ```bash
213
+ mor issue walk <id> journey.complete_scoped_plan
214
+ mor issue inspect <id>
215
+ ```
216
+
217
+ For a blocked scoped plan, close with:
218
+
219
+ ```bash
220
+ mor issue walk <id> journey.close_blocked_from_scoping
221
+ mor issue inspect <id>
222
+ ```
223
+
224
+ ### 9. Complete onboarding
225
+
226
+ When the first record reaches `journey.done`, write the sentinel:
227
+
228
+ ```bash
229
+ printf '%s %s\n' "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" "<id>" > .mor/onboarding-complete
230
+ ```
231
+
232
+ Tell the human: "Onboarding is complete. Normal Morphisms mode is now on; future records will start from the frontier loop."
@@ -0,0 +1,22 @@
1
+ # Morphisms workspace instructions
2
+
3
+ This is the S2 workspace layer for a repo initialized by `morphisms init`. It applies across local distros in this repo.
4
+
5
+ ## Startup
6
+
7
+ - Run `mor agent instructions` before orchestrating. Read the reported S1/S2/S3 files; use `mor agent instructions preview` only when you need the rendered stack.
8
+ - Workbench is the lens: `http://localhost:4400/#workbench` unless `.morphisms-contract/config.json` says a different `workbench_port`.
9
+ - Keep runtime state under `.mor/`. Do not edit SQLite files or registry material by hand.
10
+ - Do not create `.mor/onboarding-complete`; the onboarding agent writes it only after the first real issue reaches `journey.done`.
11
+
12
+ ## Thread narration
13
+
14
+ - If this session is inside a MOR Workbench thread capsule, reply in the thread with `mor-thread reply` and use `mor-thread suggest` for consent-gated viewer movement.
15
+ - If this is a normal terminal agent session, narrate progress in the current conversation and include the Workbench deep-link.
16
+ - Keep narration short: what node was hydrated, what evidence was attached, what edge was walked or refused, and where the record is now.
17
+
18
+ ## Local command posture
19
+
20
+ - Prefer compact human output while narrating. Add `--json` only when you need machine parsing.
21
+ - Use `mor --help` when syntax is uncertain. Do not guess command forms.
22
+ - Treat MOR refusals as evidence gates working correctly. Never bypass with direct DB edits.
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "src": "claude/skills/morphisms/SKILL.md",
4
+ "dest": "{repo}/.claude/skills/morphisms/SKILL.md",
5
+ "when": "claude"
6
+ },
7
+ {
8
+ "src": "agent/skills/morphisms/SKILL.md",
9
+ "dest": "{repo}/.agent/skills/morphisms/SKILL.md",
10
+ "when": "agent"
11
+ },
12
+ {
13
+ "src": "instructions/workspace-agent-manual.md",
14
+ "dest": "{repo}/.mor/agent-manual.md",
15
+ "when": "always"
16
+ },
17
+ {
18
+ "src": "instructions/starter-issues-agent-manual.md",
19
+ "dest": "{repo}/.morphisms-contract/issues_front_half/agent-manual.md",
20
+ "when": "always"
21
+ }
22
+ ]