@polymorphism-tech/morph-spec 4.8.1 → 4.8.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 (44) hide show
  1. package/README.md +2 -2
  2. package/claude-plugin.json +1 -1
  3. package/docs/CHEATSHEET.md +1 -1
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/hooks/dev/guard-version-numbers.js +1 -1
  6. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +1 -1
  7. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +1 -1
  8. package/framework/skills/level-1-workflows/phase-design/SKILL.md +1 -1
  9. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +1 -1
  10. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +1 -1
  11. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +1 -1
  12. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +1 -1
  13. package/package.json +4 -4
  14. package/.morph/analytics/threads-log.jsonl +0 -54
  15. package/.morph/state.json +0 -198
  16. package/docs/ARCHITECTURE.md +0 -328
  17. package/docs/COMMAND-FLOWS.md +0 -398
  18. package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +0 -514
  19. package/docs/plans/2026-02-22-claude-settings.md +0 -517
  20. package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +0 -730
  21. package/docs/plans/2026-02-22-morph-spec-next.md +0 -480
  22. package/docs/plans/2026-02-22-native-alignment-design.md +0 -201
  23. package/docs/plans/2026-02-22-native-alignment-impl.md +0 -927
  24. package/docs/plans/2026-02-22-native-enrichment-design.md +0 -246
  25. package/docs/plans/2026-02-22-native-enrichment.md +0 -737
  26. package/docs/plans/2026-02-23-ddd-architecture-refactor.md +0 -1155
  27. package/docs/plans/2026-02-23-ddd-nextsteps.md +0 -684
  28. package/docs/plans/2026-02-23-infra-architect-refactor.md +0 -439
  29. package/docs/plans/2026-02-23-nextjs-code-review-design.md +0 -157
  30. package/docs/plans/2026-02-23-nextjs-code-review-impl.md +0 -1256
  31. package/docs/plans/2026-02-23-nextjs-standards-design.md +0 -150
  32. package/docs/plans/2026-02-23-nextjs-standards-impl.md +0 -1848
  33. package/docs/plans/2026-02-24-cli-radical-simplification.md +0 -592
  34. package/docs/plans/2026-02-24-framework-failure-points.md +0 -125
  35. package/docs/plans/2026-02-24-morph-init-design.md +0 -337
  36. package/docs/plans/2026-02-24-morph-init-impl.md +0 -1269
  37. package/docs/plans/2026-02-24-tutorial-command-design.md +0 -71
  38. package/docs/plans/2026-02-24-tutorial-command.md +0 -298
  39. package/scripts/bump-version.js +0 -248
  40. package/scripts/generate-refs.js +0 -336
  41. package/scripts/generate-standards-registry.js +0 -44
  42. package/scripts/install-dev-hooks.js +0 -138
  43. package/scripts/scan-nextjs.mjs +0 -169
  44. package/scripts/validate-real.mjs +0 -255
@@ -1,125 +0,0 @@
1
- # Framework Failure Points — Implementation Plan
2
-
3
- **Status:** COMPLETE
4
-
5
- > Created: 2026-02-24
6
- > Status: In progress (detect-agents fix already merged)
7
-
8
- ---
9
-
10
- ## Already Done
11
-
12
- - **#1 detect-agents ghost command** — Fixed in commit `9a90f31`. All 5 skill files updated to use `Read agents.json + morph-spec state add-agent` flow.
13
- - **#2 validate-css in morph-replicate** — Fixed in same commit.
14
-
15
- ---
16
-
17
- ## Remaining Issues — Prioritized
18
-
19
- ### Task 1 — Fix ARCHITECTURE.md hooks table (documentation, low risk)
20
-
21
- The hooks table in `docs/ARCHITECTURE.md` has wrong hook names. Verified against actual files in `framework/hooks/claude-code/`:
22
-
23
- | What doc says | What actually exists |
24
- |---|---|
25
- | UserPromptSubmit: `protect-spec-files.js` | UserPromptSubmit: `enrich-prompt.js` |
26
- | PreToolUse: `validate-feature-phase.js` | PreToolUse: `enforce-phase-writes.js` + `protect-readonly-files.js` + `protect-spec-files.js` (3 hooks) |
27
-
28
- **Fix:** Rewrite hooks table in `ARCHITECTURE.md` with correct names and descriptions. Also fix COMMAND-FLOWS.md Section 9 hook chain (same error — hook names partially wrong).
29
-
30
- Files: `docs/ARCHITECTURE.md`, `docs/COMMAND-FLOWS.md`
31
-
32
- ---
33
-
34
- ### Task 2 — Add `morph-spec unapprove` command (gate revocation)
35
-
36
- `approve` was kept in the CLI, but `reject` was removed in the simplification. Users who approve a gate and then realize the spec needs rework are blocked — no supported path to undo an approval.
37
-
38
- **Fix:** Add `unapprove` command that sets `approvals[gate] = false` and removes the approval from history.
39
-
40
- Files:
41
- - `src/commands/state/approve.js` — add `unapproveCommand()`
42
- - `bin/morph-spec.js` — register `morph-spec unapprove <feature> <gate>`
43
- - `test/commands/approve.test.js` — add tests
44
-
45
- ---
46
-
47
- ### Task 3 — Make spec injection limit configurable
48
-
49
- `inject-morph-context.js` hardcodes `3000` chars. Real specs exceed this; Claude starts sessions with truncated context and makes decisions based on partial information.
50
-
51
- **Fix:** Read limit from `.morph/config/config.json` → `hooks.specInjectionLimit` (default: 3000). Add `specInjectionLimit` to the config schema.
52
-
53
- Files:
54
- - `framework/hooks/claude-code/session-start/inject-morph-context.js`
55
- - `src/lib/config/config-schema.js` (or wherever defaults live)
56
- - `test/hooks/hooks-e2e.test.js` — add test for custom limit
57
-
58
- ---
59
-
60
- ### Task 4 — Add hook health summary to `morph-spec doctor`
61
-
62
- `doctor` checks for the existence of `.claude/skills/`, `.claude/agents/`, `.claude/rules/` but doesn't validate hook configuration. A broken hook (wrong path, deleted file) passes doctor with no warning.
63
-
64
- **Fix:** Add a `hooks` health check section to `doctorCommand()`:
65
- 1. Read `.claude/settings.local.json`
66
- 2. For each configured hook, verify the hook script file exists at the referenced path
67
- 3. Report any missing or misconfigured hooks
68
-
69
- Files:
70
- - `src/commands/project/doctor.js`
71
- - `test/commands/doctor.test.js`
72
-
73
- ---
74
-
75
- ### Task 5 — Skills-CLI compatibility: add `cliVersion` to SKILL.md frontmatter + doctor check
76
-
77
- After the radical simplification, skill files drifted from the CLI. There's no mechanism to detect this drift.
78
-
79
- **Fix:**
80
- 1. Add `cliVersion: "4.7.2"` to the frontmatter of all workflow skill files (`level-1-workflows/**`)
81
- 2. `morph-spec doctor` reads each installed `.claude/skills/*/SKILL.md`, extracts `cliVersion`, and warns if it doesn't match the running CLI version
82
-
83
- This gives future maintainers a clear signal when a skill update is needed.
84
-
85
- Files:
86
- - `framework/skills/level-1-workflows/*/SKILL.md` (8 files) — add `cliVersion: "4.7.2"` to frontmatter
87
- - `src/commands/project/doctor.js` — add skills version check
88
- - `test/commands/doctor.test.js` — add tests
89
-
90
- ---
91
-
92
- ### Task 6 — Atomic state.json writes (prevent corruption on concurrent hook + CLI)
93
-
94
- `state-manager.js` does direct `writeFileSync`. If `track-output-creation.js` hook fires while a CLI command is mid-write, the state file can be corrupted or half-written.
95
-
96
- **Fix:** Use write-then-rename pattern in `saveState()`:
97
- 1. Write to `state.json.tmp`
98
- 2. `fs.renameSync('state.json.tmp', 'state.json')`
99
-
100
- `renameSync` is atomic on the same filesystem (POSIX guarantee; on Windows, Node ≥ 14 uses `MoveFileExW` which is also atomic for same-volume).
101
-
102
- Files:
103
- - `src/core/state/state-manager.js` — update `saveState()`
104
- - `test/core/state-manager.test.js` — add concurrent write test
105
-
106
- ---
107
-
108
- ## Intentionally Deferred
109
-
110
- **Phase numbering refactor** (issue #11): Renaming phase IDs and output directories (0-proposal → proposal/, 1-design → design/, etc.) is a breaking change that affects state.json migration, all skill files, all hook paths, and user documentation simultaneously. High value, high risk — scope for a dedicated major version bump.
111
-
112
- ---
113
-
114
- ## Execution Order
115
-
116
- ```
117
- Task 1 (docs fix) → low risk, do first, no tests needed
118
- Task 2 (unapprove) → small new command, fully testable
119
- Task 3 (spec limit) → single hook + config schema
120
- Task 4 (doctor) → extends existing doctor checks
121
- Task 5 (cliVersion) → frontmatter + doctor extension
122
- Task 6 (atomic) → state-manager internals
123
- ```
124
-
125
- Tasks 1–3 are independent and can be done in any order. Tasks 4–5 both extend doctor.js; do sequentially. Task 6 is self-contained.
@@ -1,337 +0,0 @@
1
- # morph-init: LLM-Powered Project Initialization
2
-
3
- **Status:** COMPLETE (see implementation plan)
4
-
5
- **Date:** 2026-02-24
6
- **Replaces:** `morph-spec init` as user-facing entry point
7
-
8
- ---
9
-
10
- ## Problem
11
-
12
- `morph-spec init` relies on deterministic file-based detection that fails in three common scenarios:
13
-
14
- 1. **Monorepos** — Next.js in `src/frontend/`, .NET in `src/backend/`; patterns look for config at project root only
15
- 2. **Empty/new projects** — no files yet to detect
16
- 3. **Non-standard layouts** — any structure outside expected conventions
17
-
18
- When detection fails, it writes `architecture: "unknown"`, `stack: "dotnet"` (false positive), and a placeholder `context/README.md` with `(To be detected)`. MCP recommendations are also wrong because they depend on the detected stack.
19
-
20
- Additionally, skills throughout the framework reference `superpowers:brainstorming`, `superpowers:writing-plans`, etc. — but nothing in init ensures those plugins are installed.
21
-
22
- ---
23
-
24
- ## Decision
25
-
26
- Split init into two layers with clear responsibilities:
27
-
28
- | Layer | Entry Point | Mechanism | Responsibility |
29
- |-------|-------------|-----------|----------------|
30
- | Infrastructure | `morph-spec setup-infra` (internal) | CLI, deterministic | Dirs, framework files, hooks, agents, rules, skills |
31
- | Context + Config | `/morph-init` (skill) | LLM-powered | Stack detection, README.md, config.json, MCPs, plugins |
32
-
33
- **User-facing flow:**
34
- ```
35
- npm install -g @polymorphism-tech/morph-spec
36
- ↓ (postinstall copies morph-init.md → ~/.claude/skills/)
37
-
38
- Open project in Claude Code
39
- /morph-init ← single entry point for all users
40
- ```
41
-
42
- `morph-spec init` CLI remains for CI/CD and non-Claude-Code environments but is no longer the documented primary path.
43
-
44
- ---
45
-
46
- ## Architecture
47
-
48
- ```
49
- npm package (@polymorphism-tech/morph-spec)
50
- ├── bin/morph-spec.js CLI — retains: status, update, doctor, mcp, etc.
51
- │ init kept for headless/CI use only
52
- ├── src/scripts/
53
- │ ├── setup-infra.js NEW — headless infrastructure setup (no prompts)
54
- │ ├── install-plugin.js NEW — auto-installs Claude Code plugins
55
- │ └── global-install.js NEW — postinstall: copies morph-init.md globally
56
- └── framework/skills/
57
- └── level-0-meta/morph-init/
58
- └── SKILL.md NEW — primary user entry point
59
- ```
60
-
61
- ---
62
-
63
- ## Skill Design: `/morph-init`
64
-
65
- ### Frontmatter
66
-
67
- ```yaml
68
- ---
69
- name: morph-init
70
- description: >
71
- LLM-powered project initialization. Installs morph-spec infrastructure,
72
- analyzes any project structure intelligently, generates rich context/README.md
73
- and config.json, and configures MCPs. Use once per project after installing
74
- @polymorphism-tech/morph-spec. Re-run with /morph-init refresh to update
75
- context as project evolves.
76
- argument-hint: "[refresh]"
77
- user-invocable: true
78
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep
79
- ---
80
- ```
81
-
82
- ---
83
-
84
- ### Step 0 — Plugin Prerequisites
85
-
86
- Check and auto-install `superpowers` and `context7` Claude Code plugins.
87
-
88
- **Detection:**
89
- ```bash
90
- # Read ~/.claude/plugins/installed_plugins.json
91
- # Check for keys: "superpowers@claude-plugins-official", "context7@claude-plugins-official"
92
- ```
93
-
94
- **Auto-install flow (for each missing plugin):**
95
- ```
96
- [Bash] node {morphSpecRoot}/scripts/install-plugin.js {plugin}
97
- 1. GET github.com/anthropics/claude-plugins-official — resolve latest SHA/version
98
- 2. Download plugin files recursively to:
99
- ~/.claude/plugins/cache/claude-plugins-official/{plugin}/{version}/
100
- 3. Register in installed_plugins.json:
101
- { scope: "user", installPath: "...", version: "...",
102
- installedAt: now, lastUpdated: now, gitCommitSha: "..." }
103
- 4. SUCCESS → "✓ {plugin} installed."
104
- 5. FAIL → show manual guide (see below) → STOP
105
- ```
106
-
107
- **Manual fallback (on auto-install failure):**
108
- ```
109
- ┌─────────────────────────────────────────────────────────────┐
110
- │ Plugin {plugin} requires manual installation: │
111
- │ │
112
- │ 1. Claude Code → Settings (Cmd/Ctrl+,) → Extensions │
113
- │ 2. Browse → search "{plugin}" → Install │
114
- │ 3. Restart Claude Code │
115
- │ 4. Re-run /morph-init │
116
- └─────────────────────────────────────────────────────────────┘
117
- → STOP — do not continue without required plugins
118
- ```
119
-
120
- Both `superpowers` and `context7` are required. Execution halts if either cannot be installed.
121
-
122
- ---
123
-
124
- ### Step 1 — Infrastructure
125
-
126
- ```
127
- Check if .morph/ exists:
128
-
129
- MISSING → [Bash] npx morph-spec setup-infra
130
- Creates: .morph/{config,framework,context,features,checkpoints,memory,archive}
131
- Copies: framework files (templates, standards, rules, agents, skills, hooks)
132
- Installs: .claude/agents/, .claude/rules/, .claude/skills/
133
- Creates: config.json (minimal), context/README.md (placeholder)
134
- Updates: .gitignore
135
- → "✓ Infrastructure installed"
136
-
137
- EXISTS + argument "refresh" → continue (will overwrite context/config)
138
-
139
- EXISTS + no argument →
140
- "MORPH already initialized. Refresh context and config? (y/n)"
141
- n → STOP
142
- ```
143
-
144
- ---
145
-
146
- ### Step 2 — LLM Project Analysis
147
-
148
- Run in parallel to build an evidence map:
149
-
150
- | Tool | Pattern | Signal |
151
- |------|---------|--------|
152
- | Glob | `**/package.json` | All package.json — detect next, supabase, clerk, stripe, etc. |
153
- | Glob | `**/*.csproj` | .NET projects (any depth) |
154
- | Glob | `**/next.config.{js,ts,mjs}` | Next.js in any subdirectory |
155
- | Glob | `**/components.json` | shadcn/ui |
156
- | Glob | `**/docker-compose*.yml` | Services in use |
157
- | Glob | `database/migrations/**` | Supabase local dev |
158
- | Glob | `supabase/**` | Supabase project config |
159
- | Glob | `**/*.razor` | Blazor |
160
- | Read | `.env.example` | Env vars reveal integrations |
161
- | Read | `README.md` | Existing developer context |
162
- | Grep | `@supabase/supabase-js` | Supabase dep in any package.json |
163
- | Grep | `clerk\|auth0\|nextauth` | Authentication provider |
164
- | Grep | `stripe\|asaas` | Payment provider |
165
-
166
- **Output: evidence map**
167
- ```json
168
- {
169
- "stack": ["nextjs", "dotnet"],
170
- "integrations": ["supabase", "docker", "clerk"],
171
- "uiLibrary": "shadcn",
172
- "monorepo": true,
173
- "frontendPath": "src/frontend",
174
- "backendPath": "src/backend",
175
- "confidence": { "stack": 0.98, "integrations": 0.91 }
176
- }
177
- ```
178
-
179
- ---
180
-
181
- ### Step 3 — Targeted Questions (max 3)
182
-
183
- **Rule: only ask what cannot be inferred with ≥90% confidence.**
184
-
185
- | Question | Condition | Purpose |
186
- |----------|-----------|---------|
187
- | "Em uma frase: qual é o objetivo principal do [ProjectName]?" | Always | Generate Overview in README.md |
188
- | "Confirmo: frontend em `{frontendPath}`, backend em `{backendPath}`. Correto?" | Monorepo detected | Validate before persisting paths |
189
- | "Supabase Cloud (managed) ou self-hosted?" | Supabase detected | Determines MCP URL configuration |
190
-
191
- Do not ask about technology already confirmed by file evidence.
192
-
193
- ---
194
-
195
- ### Step 4 — Generate `context/README.md`
196
-
197
- ```markdown
198
- # [ProjectName] — Project Context
199
-
200
- ## Overview
201
- [Answer from question 1]
202
-
203
- ## Tech Stack
204
- | Layer | Technology | Location |
205
- |------------|-------------------------|------------------|
206
- | Frontend | Next.js 14 (App Router) | src/frontend/ |
207
- | Backend | .NET 8 (Clean Arch.) | src/backend/ |
208
- | Database | Supabase (PostgreSQL) | database/ |
209
- | UI Library | shadcn/ui + Tailwind | components.json |
210
- | Auth | Clerk | — |
211
-
212
- ## Architecture
213
- [Inferred + confirmed: monorepo / single-stack / etc.]
214
- [Description of layers and responsibilities]
215
-
216
- ## Key Integrations
217
- [Per integration: service → purpose → detection evidence]
218
-
219
- ## Agent Notes
220
- [Conventions detected from eslint/tsconfig/.editorconfig,
221
- important paths, project-specific patterns for MORPH agents]
222
- ```
223
-
224
- ---
225
-
226
- ### Step 5 — Update `config.json`
227
-
228
- ```json
229
- {
230
- "framework": "global",
231
- "frameworkVersion": "4.x.x",
232
- "project": {
233
- "name": "ProspectPRO",
234
- "description": "One-sentence objective from question 1",
235
- "stack": "nextjs+dotnet",
236
- "architecture": "monorepo",
237
- "uiLibrary": "shadcn",
238
- "integrations": ["supabase", "docker", "clerk"],
239
- "frontendPath": "src/frontend",
240
- "backendPath": "src/backend"
241
- }
242
- }
243
- ```
244
-
245
- ---
246
-
247
- ### Step 6 — Configure MCPs
248
-
249
- For each detected integration with an available MCP:
250
-
251
- ```
252
- supabase detected:
253
- "Configure Supabase MCP now? (needs SUPABASE_URL + SERVICE_ROLE_KEY)"
254
- YES → collect credentials → Write .claude/settings.local.json
255
- NO → show config snippet + "morph-spec mcp setup supabase"
256
-
257
- github:
258
- "Configure GitHub MCP? (needs GITHUB_PERSONAL_ACCESS_TOKEN)"
259
- YES/NO → same pattern
260
-
261
- Others (Figma, Docker, Azure): only if explicitly detected in .env.example or mentioned
262
- ```
263
-
264
- ---
265
-
266
- ### Step 7 — Final Output
267
-
268
- ```
269
- ✓ Plugins: superpowers v4.3.1 ✓ context7 ✓
270
- ✓ Infrastructure: .morph/ structure, hooks, agents, rules, skills
271
- ✓ context/README.md generated
272
- ✓ config.json updated
273
- Stack: nextjs+dotnet | Architecture: monorepo
274
- Integrations: supabase, docker, clerk
275
- ✓ MCPs: supabase configured
276
- ○ Restart Claude Code to activate newly installed plugins
277
-
278
- Next: /morph-proposal [feature-name]
279
- ```
280
-
281
- ---
282
-
283
- ## CLI Changes
284
-
285
- ### `morph-spec setup-infra` (new command)
286
-
287
- Headless infrastructure-only setup. Called internally by the skill.
288
- Same logic as current `morph-spec init` but:
289
- - No interactive prompts
290
- - No stack detection (that's the skill's job)
291
- - No MCP setup (that's the skill's job)
292
- - Writes minimal `config.json` (name + version only)
293
- - Writes placeholder `context/README.md`
294
-
295
- ### `morph-spec init` (modified)
296
-
297
- Remains for CI/CD and non-Claude-Code environments.
298
- Internally delegates to `setup-infra.js` for infrastructure,
299
- then runs a best-effort detection pass.
300
- No longer documented as primary user path.
301
-
302
- ### `morph-spec doctor` (modified)
303
-
304
- Add plugin checks:
305
- ```
306
- ✓ superpowers@claude-plugins-official installed?
307
- ✓ context7@claude-plugins-official installed?
308
- ```
309
-
310
- ---
311
-
312
- ## New Files
313
-
314
- | File | Description |
315
- |------|-------------|
316
- | `framework/skills/level-0-meta/morph-init/SKILL.md` | Primary skill |
317
- | `src/scripts/setup-infra.js` | Headless infrastructure setup |
318
- | `src/scripts/install-plugin.js` | Auto-install CC plugins from GitHub |
319
- | `src/scripts/global-install.js` | postinstall: copy skill to ~/.claude/skills/ |
320
-
321
- ## Modified Files
322
-
323
- | File | Change |
324
- |------|--------|
325
- | `package.json` | Add `"postinstall": "node scripts/global-install.js"` |
326
- | `src/commands/project/init.js` | Delegate to setup-infra.js; remove context/MCP logic |
327
- | `src/commands/project/doctor.js` | Add plugin presence checks |
328
- | `src/lib/detectors/structure-detector.js` | Fix nextjs patterns for subdirectories (best-effort) |
329
-
330
- ---
331
-
332
- ## Out of Scope
333
-
334
- - Removing `morph-spec init` entirely (kept for CI/CD)
335
- - Plugin auto-update (only install if missing)
336
- - Interactive stack selector fallback in CLI (skill handles this)
337
- - shadcn MCP (no official MCP available)