@polymorphism-tech/morph-spec 7.4.0 → 7.6.0

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 (66) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +18 -0
  3. package/claude-plugin.json +1 -1
  4. package/docs/CHEATSHEET.md +1 -1
  5. package/docs/QUICKSTART.md +1 -1
  6. package/framework/CLAUDE.md +9 -4
  7. package/framework/MORPH.md +4 -4
  8. package/framework/agents.json +1 -1
  9. package/framework/commands/create-umbraco-lp.md +35 -0
  10. package/framework/commands/migrate-lp-to-umbraco.md +33 -0
  11. package/framework/commands/morph-archive.md +17 -27
  12. package/framework/commands/morph-preflight.md +10 -5
  13. package/framework/hooks/claude-code/core/enforce-phase-writes.js +115 -90
  14. package/framework/hooks/claude-code/core/protect-spec-files.js +32 -30
  15. package/framework/hooks/claude-code/core/state-sync.js +16 -48
  16. package/framework/hooks/shared/state-reader.js +74 -8
  17. package/framework/hooks/shared/state-writer.js +124 -0
  18. package/framework/rules/infrastructure-standards.md +4 -4
  19. package/framework/rules/morph-task-tracking.md +69 -49
  20. package/framework/rules/morph-workflow.md +192 -191
  21. package/framework/skills/core/create-umbraco-lp/SKILL.md +272 -0
  22. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +531 -0
  23. package/framework/skills/core/morph-apply/SKILL.md +15 -15
  24. package/framework/skills/core/morph-brainstorming/SKILL.md +5 -5
  25. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  26. package/framework/skills/core/morph-implement/SKILL.md +5 -4
  27. package/framework/skills/core/morph-plan/SKILL.md +6 -6
  28. package/framework/skills/core/morph-proposal/SKILL.md +8 -7
  29. package/framework/skills/core/morph-review/SKILL.md +3 -3
  30. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  31. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  32. package/framework/standards/STANDARDS.json +80 -8
  33. package/framework/standards/ai-agents/durable-workflows-hitl.md +191 -0
  34. package/framework/standards/ai-agents/rag-custom-pgvector.md +246 -243
  35. package/framework/standards/ai-agents/setup.md +3 -0
  36. package/framework/standards/ai-agents/vector-data-extensions.md +170 -0
  37. package/framework/standards/ai-agents/workflows.md +190 -187
  38. package/framework/standards/infrastructure/docker/{easypanel-deploy.md → coolify-deploy.md} +49 -20
  39. package/framework/templates/README.md +7 -7
  40. package/framework/templates/REGISTRY.json +15 -17
  41. package/framework/templates/context/CONTEXT-FEATURE.md +10 -17
  42. package/framework/templates/context/CONTEXT.md +181 -180
  43. package/framework/templates/docs/onboarding.md +122 -118
  44. package/framework/templates/docs/proposal.md +12 -2
  45. package/framework/templates/docs/spec.md +228 -228
  46. package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +1 -1
  47. package/framework/templates/infrastructure/docker/coolify.template.json +49 -0
  48. package/framework/templates/infrastructure/github/README.md +6 -6
  49. package/framework/templates/infrastructure/github/workflows/deploy-coolify.yml.hbs +33 -0
  50. package/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +80 -80
  51. package/framework/templates/meta-prompts/squad-leaders/backend-squad.md +90 -89
  52. package/framework/templates/meta-prompts/squad-leaders/frontend-squad.md +2 -1
  53. package/framework/templates/meta-prompts/squad-leaders/squad-leader.md +44 -43
  54. package/framework/templates/meta-prompts/validators/checkpoint-validator.md +107 -107
  55. package/package.json +1 -1
  56. package/src/commands/project/update.js +415 -368
  57. package/src/commands/project/worktree.js +212 -210
  58. package/src/commands/state/advance.js +82 -0
  59. package/src/commands/state/archive.js +111 -0
  60. package/src/commands/validation/validate-feature.js +229 -105
  61. package/src/core/state/state-manager.js +238 -66
  62. package/src/dashboard/scanner/state-scanner.js +35 -8
  63. package/src/lib/generators/context-generator.js +12 -8
  64. package/src/utils/file-copier.js +7 -0
  65. package/framework/templates/infrastructure/docker/easypanel.template.json +0 -46
  66. package/framework/templates/infrastructure/github/workflows/deploy-easypanel.yml.hbs +0 -31
@@ -1,191 +1,192 @@
1
- ---
2
- stacks:
3
- - "*"
4
- ---
5
-
6
- # MORPH-SPEC Workflow Rules
7
-
8
- > Always-active rules for all MORPH-SPEC managed projects.
9
-
10
- ---
11
-
12
- ## Spec-First Mandate
13
-
14
- **NEVER skip to code without a specification.** Every feature must progress through phases:
15
-
16
- 1. **Proposal** — Problem statement + acceptance criteria (`0-proposal/proposal.md`)
17
- 2. **Design** (optional, UI-heavy) — Design system + mockups + flows (`1-design/`)
18
- 3. **Plan** — Technical spec + mandate + tasks (`2-plan/spec.md`, `mandate.md`, `tasks.json`)
19
- 4. **Implement** — Code + recap (`3-implement/recap.md`)
20
- 5. **Review** — Review report + Gate 3 (`4-review/review-report.md`)
21
-
22
- ---
23
-
24
- ## Phase Sequence
25
-
26
- ```
27
- proposal → [design] → plan → implement → review
28
- ```
29
-
30
- Use `morph-spec status {feature}` to see current phase and pending approval gates.
31
-
32
- ---
33
-
34
- ## Phase Commands
35
-
36
- | Command | Purpose |
37
- |---------|---------|
38
- | `/morph-proposal {feature}` | Full spec pipeline (phases 1-4, pauses for approval) |
39
- | `/morph-apply {feature}` | Implement feature (phase 5) |
40
- | `/morph-status` | Feature dashboard |
41
-
42
- ---
43
-
44
- ## State & Outputs
45
-
46
- | Path | Notes |
47
- |------|-------|
48
- | `.morph/state.json` | **READ-ONLY** — use `morph-spec` CLI to update |
49
- | `.morph/features/{feature}/{phase}/` | Feature outputs organized by phase |
50
- | `.morph/framework/` | **READ-ONLY** — framework files managed by morph-spec |
51
- | `.morph/config/config.json` | Project configuration (editable) |
52
-
53
- ### output types
54
-
55
- Output types are defined in `src/core/paths/output-schema.js`. State sync is
56
- handled automatically by the `state-sync.js` PostToolUse hook — the agent
57
- does not need to call mark-output explicitly.
58
-
59
- ---
60
-
61
- ## Output Paths
62
-
63
- All outputs go in `.morph/features/{feature}/`:
64
-
65
- | Phase | Path |
66
- |-------|------|
67
- | Proposal | `0-proposal/proposal.md`, `stack-scan.md`, `migration-plan.md` (optional) |
68
- | Design (optional) | `1-design/design-system.md`, `mockups.md`, `components.md`, `flows.md` |
69
- | Plan | `2-plan/spec.md`, `mandate.md`, `tasks.json`, `decisions.md` |
70
- | Implement | `3-implement/recap.md` + source code |
71
- | Review | `4-review/review-report.md` |
72
-
73
- ---
74
-
75
- ## Checkpoints
76
-
77
- Run a checkpoint every 3 completed tasks:
78
- - Validate architecture compliance
79
- - Check package versions
80
- - Scan for security issues
81
- - Verify design system adherence (UI features)
82
-
83
- ---
84
-
85
- ## Approval Gates
86
-
87
- Before completing any phase, verify pending approval gates:
88
- - `morph-spec approval-status <feature>` — check which gates are pending
89
- - `morph-spec approve <feature> <gate>` — approve a gate (design, plan, tasks, uiux)
90
- - Gates must be approved before advancing to the next phase
91
-
92
- ---
93
-
94
- ## Protected Files
95
-
96
- **NEVER directly edit:**
97
- - `.morph/state.json` — Managed by CLI only
98
- - `.morph/framework/**` — Read-only framework content
99
-
100
- ---
101
-
102
- ## Test File Policy
103
-
104
- When a test fails, always follow this order:
105
-
106
- 1. **Analyze first** — determine if the IMPLEMENTATION is wrong or the TEST SPEC is wrong
107
- 2. **Fix implementation first** — the test is the spec; trust it by default
108
- 3. **Only modify a test file if the test expectation itself is incorrect** — wrong expected value, wrong behavior modeled
109
- 4. **Before modifying any test file, explain WHY the test spec is wrong** — what the correct behavior is and why the test doesn't model it
110
-
111
- Do not modify test files to make a failing test pass when the implementation is the actual problem.
112
-
113
- ---
114
-
115
- ## Context Maintenance
116
-
117
- After making structural changes (new packages, dependencies, project config changes), update the project context:
118
- - Edit `.morph/context/README.md` — update Tech Stack, Architecture, Key Integrations sections
119
- - Update `.morph/config/config.json` — update stack, architecture, integrations, paths
120
- - Structural changes include: package.json, .csproj, next.config.*, tsconfig.json, docker-compose.yml
121
-
122
- ---
123
-
124
- ## Spec-Driven Task Execution (implement phase)
125
-
126
- BEFORE implementing ANY task during the implement phase:
127
-
128
- 1. **Read tasks.json** → identify the current task object (`id`, `description`, `doneCriteria`, `dependencies`)
129
- 2. **Read spec.md** → the FR sections that the task `description` references
130
- 3. **Read the contracts** → the DTOs/interfaces are defined inside `spec.md` (v5 keeps contracts in the spec, not separate files)
131
- 4. Only then begin implementation
132
-
133
- This is **NON-NEGOTIABLE**. The spec is the source of truth. Code that doesn't match the spec is a bug.
134
-
135
- Every task in `tasks.json` MUST reference its FR(s) in the `description` field so the link to the spec is explicit:
136
- ```json
137
- {
138
- "id": "T1",
139
- "title": "Create user endpoint",
140
- "description": "Implement user CRUD (FR001) and input validation (FR003). Contracts: CreateUserRequest, CreateUserResponse, UserErrors.",
141
- "dependencies": [],
142
- "effort": "M",
143
- "doneCriteria": "POST /users creates a user and rejects invalid input",
144
- "status": "pending",
145
- "outputs": ["Features/UserFeature/Create/Handler.cs", "Validator.cs", "Endpoint.cs"],
146
- "group": "backend"
147
- }
148
- ```
149
-
150
- ---
151
-
152
- ## Mandatory Skills per Phase
153
-
154
- During implementation, these skills MUST be invoked at the specified triggers:
155
-
156
- ### Implement Phase
157
- | Trigger | Skill | When |
158
- |---------|-------|------|
159
- | Before each task | `superpowers:test-driven-development` | Invoke BEFORE writing any code for a task |
160
- | Before task done | `morph-verification-before-completion` | Invoke BEFORE running `morph-spec task done` |
161
- | On bug/unexpected | `superpowers:systematic-debugging` | Invoke IF a bug or unexpected behavior is encountered |
162
- | After all tasks | `morph-post-implementation` | Invoke AFTER all tasks completed |
163
- | Before PR | `morph-checklist` | Invoke BEFORE creating pull request |
164
-
165
- ### Tasks Phase
166
- | Trigger | Skill | When |
167
- |---------|-------|------|
168
- | On parallel tasks | `superpowers:dispatching-parallel-agents` | When parallel task groups are identified |
169
- | Before completion | `morph-verification-before-completion` | Before completing the tasks phase |
170
-
171
- These are MANDATORY. Use the `Skill()` tool. Do NOT skip.
172
-
173
- ---
174
-
175
- ## Scope Escalation
176
-
177
- If during implementation a task reveals significantly more complexity than estimated:
178
- - **Low impact:** `morph-spec task expand <feature> <task-id> --into "T00Xa: Sub" "T00Xb: Sub"`
179
- - **Medium/High impact:** `/morph-scope-escalation <feature>`
180
- - **Never** implement extra functionality within a task without registering it as a subtask
181
-
182
- ---
183
-
184
- ## Context Window Tip
185
-
186
- When using 3+ MCPs, add `"experimental": { "mcpCliMode": true }` to `.claude/settings.json`.
187
- MCP tools load on-demand instead of all at startup — keeps context clean for actual work.
188
-
189
- ---
190
-
191
- *MORPH-SPEC by Polymorphism Tech*
1
+ ---
2
+ stacks:
3
+ - "*"
4
+ ---
5
+
6
+ # MORPH-SPEC Workflow Rules
7
+
8
+ > Always-active rules for all MORPH-SPEC managed projects.
9
+
10
+ ---
11
+
12
+ ## Spec-First Mandate
13
+
14
+ **NEVER skip to code without a specification.** Every feature must progress through phases:
15
+
16
+ 1. **Proposal** — Problem statement + acceptance criteria (`0-proposal/proposal.md`)
17
+ 2. **Design** (optional, UI-heavy) — Design system + mockups + flows (`1-design/`)
18
+ 3. **Plan** — Technical spec + mandate + tasks (`2-plan/spec.md`, `mandate.md`, `tasks.json`)
19
+ 4. **Implement** — Code + recap (`3-implement/recap.md`)
20
+ 5. **Review** — Review report + Gate 3 (`4-review/review-report.md`)
21
+
22
+ ---
23
+
24
+ ## Phase Sequence
25
+
26
+ ```
27
+ proposal → [design] → plan → implement → review
28
+ ```
29
+
30
+ Use `morph-spec status {feature}` to see current phase and pending approval gates.
31
+
32
+ ---
33
+
34
+ ## Phase Commands
35
+
36
+ | Command | Purpose |
37
+ |---------|---------|
38
+ | `/morph-proposal {feature}` | Full spec pipeline (phases 1-4, pauses for approval) |
39
+ | `/morph-apply {feature}` | Implement feature (phase 5) |
40
+ | `/morph-status` | Feature dashboard |
41
+
42
+ ---
43
+
44
+ ## State & Outputs
45
+
46
+ | Path | Notes |
47
+ |------|-------|
48
+ | `.morph/state.json` | **READ-ONLY** — updated automatically by the `state-sync` hook |
49
+ | `.morph/features/{feature}/{phase}/` | Feature outputs organized by phase |
50
+ | `.morph/framework/` | **READ-ONLY** — framework files managed by morph-spec |
51
+ | `.morph/config/config.json` | Project configuration (editable) |
52
+
53
+ ### output types
54
+
55
+ Output types are defined in `src/core/paths/output-schema.js`. State sync is
56
+ handled automatically by the `state-sync.js` PostToolUse hook — the agent
57
+ does not need to record outputs through any CLI call.
58
+
59
+ ---
60
+
61
+ ## Output Paths
62
+
63
+ All outputs go in `.morph/features/{feature}/`:
64
+
65
+ | Phase | Path |
66
+ |-------|------|
67
+ | Proposal | `0-proposal/proposal.md`, `stack-scan.md`, `migration-plan.md` (optional) |
68
+ | Design (optional) | `1-design/design-system.md`, `mockups.md`, `components.md`, `flows.md` |
69
+ | Plan | `2-plan/spec.md`, `mandate.md`, `tasks.json`, `decisions.md` |
70
+ | Implement | `3-implement/recap.md` + source code |
71
+ | Review | `4-review/review-report.md` |
72
+
73
+ ---
74
+
75
+ ## Checkpoints
76
+
77
+ Run a checkpoint every 3 completed tasks:
78
+ - Validate architecture compliance
79
+ - Check package versions
80
+ - Scan for security issues
81
+ - Verify design system adherence (UI features)
82
+
83
+ ---
84
+
85
+ ## Approval Gates
86
+
87
+ Before completing any phase, verify pending approval gates:
88
+ - `morph-spec approval-status <feature>` — check which gates are pending
89
+ - `morph-spec approve <feature> <gate>` — approve a gate (`proposal`, `plan`, `review`; `uiux` if applicable)
90
+ - `morph-spec advance <feature>` — approve the current gate AND scaffold the next phase folder in one step
91
+ - Gates must be approved before advancing to the next phase
92
+
93
+ ---
94
+
95
+ ## Protected Files
96
+
97
+ **NEVER directly edit:**
98
+ - `.morph/state.json` — Managed by CLI only
99
+ - `.morph/framework/**` — Read-only framework content
100
+
101
+ ---
102
+
103
+ ## Test File Policy
104
+
105
+ When a test fails, always follow this order:
106
+
107
+ 1. **Analyze first** — determine if the IMPLEMENTATION is wrong or the TEST SPEC is wrong
108
+ 2. **Fix implementation first** — the test is the spec; trust it by default
109
+ 3. **Only modify a test file if the test expectation itself is incorrect** — wrong expected value, wrong behavior modeled
110
+ 4. **Before modifying any test file, explain WHY the test spec is wrong** — what the correct behavior is and why the test doesn't model it
111
+
112
+ Do not modify test files to make a failing test pass when the implementation is the actual problem.
113
+
114
+ ---
115
+
116
+ ## Context Maintenance
117
+
118
+ After making structural changes (new packages, dependencies, project config changes), update the project context:
119
+ - Edit `.morph/context/README.md` — update Tech Stack, Architecture, Key Integrations sections
120
+ - Update `.morph/config/config.json` — update stack, architecture, integrations, paths
121
+ - Structural changes include: package.json, .csproj, next.config.*, tsconfig.json, docker-compose.yml
122
+
123
+ ---
124
+
125
+ ## Spec-Driven Task Execution (implement phase)
126
+
127
+ BEFORE implementing ANY task during the implement phase:
128
+
129
+ 1. **Read tasks.json** → identify the current task object (`id`, `description`, `doneCriteria`, `dependencies`)
130
+ 2. **Read spec.md** → the FR sections that the task `description` references
131
+ 3. **Read the contracts** → the DTOs/interfaces are defined inside `spec.md` (v5 keeps contracts in the spec, not separate files)
132
+ 4. Only then begin implementation
133
+
134
+ This is **NON-NEGOTIABLE**. The spec is the source of truth. Code that doesn't match the spec is a bug.
135
+
136
+ Every task in `tasks.json` MUST reference its FR(s) in the `description` field so the link to the spec is explicit:
137
+ ```json
138
+ {
139
+ "id": "T1",
140
+ "title": "Create user endpoint",
141
+ "description": "Implement user CRUD (FR001) and input validation (FR003). Contracts: CreateUserRequest, CreateUserResponse, UserErrors.",
142
+ "dependencies": [],
143
+ "effort": "M",
144
+ "doneCriteria": "POST /users creates a user and rejects invalid input",
145
+ "status": "pending",
146
+ "outputs": ["Features/UserFeature/Create/Handler.cs", "Validator.cs", "Endpoint.cs"],
147
+ "group": "backend"
148
+ }
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Mandatory Skills per Phase
154
+
155
+ During implementation, these skills MUST be invoked at the specified triggers:
156
+
157
+ ### Implement Phase
158
+ | Trigger | Skill | When |
159
+ |---------|-------|------|
160
+ | Before each task | `superpowers:test-driven-development` | Invoke BEFORE writing any code for a task |
161
+ | Before marking a task complete | `morph-verification-before-completion` | Invoke BEFORE setting a task's `status` to `completed` in `tasks.json` |
162
+ | On bug/unexpected | `superpowers:systematic-debugging` | Invoke IF a bug or unexpected behavior is encountered |
163
+ | After all tasks | `morph-post-implementation` | Invoke AFTER all tasks completed |
164
+ | Before PR | `morph-checklist` | Invoke BEFORE creating pull request |
165
+
166
+ ### Tasks Phase
167
+ | Trigger | Skill | When |
168
+ |---------|-------|------|
169
+ | On parallel tasks | `superpowers:dispatching-parallel-agents` | When parallel task groups are identified |
170
+ | Before completion | `morph-verification-before-completion` | Before completing the tasks phase |
171
+
172
+ These are MANDATORY. Use the `Skill()` tool. Do NOT skip.
173
+
174
+ ---
175
+
176
+ ## Scope Escalation
177
+
178
+ If during implementation a task reveals significantly more complexity than estimated:
179
+ - **Low impact:** record the added scope in the task's `notes` field (in `tasks.json`) and track the sub-steps with native `TaskCreate`/`TaskUpdate` for the current session
180
+ - **Medium/High impact:** `/morph-scope-escalation <feature>` — re-opens the plan so the frozen contract (`title`/`description`/`dependencies`/`doneCriteria`) can be amended through the gate
181
+ - **Never** implement extra functionality within a task without registering it — in `notes` for small additions, or via scope escalation for anything that changes the plan contract
182
+
183
+ ---
184
+
185
+ ## Context Window Tip
186
+
187
+ When using 3+ MCPs, add `"experimental": { "mcpCliMode": true }` to `.claude/settings.json`.
188
+ MCP tools load on-demand instead of all at startup — keeps context clean for actual work.
189
+
190
+ ---
191
+
192
+ *MORPH-SPEC by Polymorphism Tech*