@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.
- package/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/hooks/dev/guard-version-numbers.js +1 -1
- package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-design/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-implement/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-setup/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +1 -1
- package/package.json +4 -4
- package/.morph/analytics/threads-log.jsonl +0 -54
- package/.morph/state.json +0 -198
- package/docs/ARCHITECTURE.md +0 -328
- package/docs/COMMAND-FLOWS.md +0 -398
- package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +0 -514
- package/docs/plans/2026-02-22-claude-settings.md +0 -517
- package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +0 -730
- package/docs/plans/2026-02-22-morph-spec-next.md +0 -480
- package/docs/plans/2026-02-22-native-alignment-design.md +0 -201
- package/docs/plans/2026-02-22-native-alignment-impl.md +0 -927
- package/docs/plans/2026-02-22-native-enrichment-design.md +0 -246
- package/docs/plans/2026-02-22-native-enrichment.md +0 -737
- package/docs/plans/2026-02-23-ddd-architecture-refactor.md +0 -1155
- package/docs/plans/2026-02-23-ddd-nextsteps.md +0 -684
- package/docs/plans/2026-02-23-infra-architect-refactor.md +0 -439
- package/docs/plans/2026-02-23-nextjs-code-review-design.md +0 -157
- package/docs/plans/2026-02-23-nextjs-code-review-impl.md +0 -1256
- package/docs/plans/2026-02-23-nextjs-standards-design.md +0 -150
- package/docs/plans/2026-02-23-nextjs-standards-impl.md +0 -1848
- package/docs/plans/2026-02-24-cli-radical-simplification.md +0 -592
- package/docs/plans/2026-02-24-framework-failure-points.md +0 -125
- package/docs/plans/2026-02-24-morph-init-design.md +0 -337
- package/docs/plans/2026-02-24-morph-init-impl.md +0 -1269
- package/docs/plans/2026-02-24-tutorial-command-design.md +0 -71
- package/docs/plans/2026-02-24-tutorial-command.md +0 -298
- package/scripts/bump-version.js +0 -248
- package/scripts/generate-refs.js +0 -336
- package/scripts/generate-standards-registry.js +0 -44
- package/scripts/install-dev-hooks.js +0 -138
- package/scripts/scan-nextjs.mjs +0 -169
- package/scripts/validate-real.mjs +0 -255
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
# Claude Code Native Enrichment — Design Document
|
|
2
|
-
|
|
3
|
-
**Status:** COMPLETE (see implementation plan)
|
|
4
|
-
|
|
5
|
-
> **Session:** 2026-02-22
|
|
6
|
-
> **Approach:** Targeted native enrichment (Approach A)
|
|
7
|
-
> **Output:** Design doc + implementation plan
|
|
8
|
-
> **Docs reviewed:** permissions, sub-agents, hooks-guide, memory, settings
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Background
|
|
13
|
-
|
|
14
|
-
This analysis was driven by the prompt at `.wiki/prompts/claude_code_docs_to_morph.md`:
|
|
15
|
-
read the official Claude Code documentation, analyze morph-spec, compare philosophies,
|
|
16
|
-
and produce concrete architectural improvements.
|
|
17
|
-
|
|
18
|
-
The prior alignment work (plan `2026-02-22-claude-settings.md`) brought morph-spec into
|
|
19
|
-
good native alignment. This document identifies the **next layer** of improvements
|
|
20
|
-
that the docs reveal but morph-spec hasn't yet leveraged.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## What Is Already Well-Aligned
|
|
25
|
-
|
|
26
|
-
| Native primitive | morph state |
|
|
27
|
-
|---|---|
|
|
28
|
-
| `permissions.deny` — file protection | ✓ protects `state.json` + `framework/**` |
|
|
29
|
-
| `.claude/agents/` subagent discovery | ✓ tier-1 + tier-2 installed via agents-installer |
|
|
30
|
-
| `.claude/skills/` flat install | ✓ level-0 + level-1 installed |
|
|
31
|
-
| `.claude/rules/` path-scoped rules | ✓ 5 rules files (morph-workflow, csharp, frontend, testing, infra) |
|
|
32
|
-
| `$schema`, `env`, `attribution`, `plansDirectory` | ✓ written by hooks-installer |
|
|
33
|
-
| Global `statusLine` at `~/.claude/` | ✓ Python + shell scripts |
|
|
34
|
-
| `.claude/CLAUDE.md` runtime instructions | ✓ `framework/CLAUDE_runtime.md` |
|
|
35
|
-
| `SessionStart compact` hook for context re-injection | ✓ `inject-morph-context.js` |
|
|
36
|
-
| `@.morph/context/README.md` import in CLAUDE.md | ✓ |
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## Gaps Identified
|
|
41
|
-
|
|
42
|
-
### G1: Agent frontmatter is bare minimum
|
|
43
|
-
|
|
44
|
-
Current `morph-{id}.md` files in `.claude/agents/` have only `name` + `description`.
|
|
45
|
-
|
|
46
|
-
The Claude Code subagent spec supports:
|
|
47
|
-
- `model` — assign optimal model per tier (opus for orchestrators)
|
|
48
|
-
- `tools` — restrict tool access per role
|
|
49
|
-
- `maxTurns` — prevent runaway execution
|
|
50
|
-
- `skills` — preload relevant framework skills into agent context
|
|
51
|
-
- `memory` — persistent project memory across sessions
|
|
52
|
-
- `hooks` — agent-scoped lifecycle hooks
|
|
53
|
-
|
|
54
|
-
None are used. Tier-1 orchestrators could use `memory: project` to accumulate
|
|
55
|
-
project patterns. All agents could have `skills: [morph-workflow]` preloaded.
|
|
56
|
-
|
|
57
|
-
### G2: All hooks use `type: "command"` (Node.js scripts)
|
|
58
|
-
|
|
59
|
-
The docs add two higher-level hook types:
|
|
60
|
-
- `type: "prompt"` — single LLM call evaluates a condition
|
|
61
|
-
- `type: "agent"` — spawns an agent with tools for multi-turn verification
|
|
62
|
-
|
|
63
|
-
The `Stop` hook (`validate-completion.js`) reads `state.json` and checks JSON flags.
|
|
64
|
-
A `type: "agent"` hook could read actual output files and verify they are non-empty
|
|
65
|
-
and semantically valid — without Node.js and with Claude's reasoning.
|
|
66
|
-
|
|
67
|
-
### G3: Skills levels 2–4 not installed as native skills
|
|
68
|
-
|
|
69
|
-
`skills-installer.js` installs only `level-0-meta` and `level-1-workflows`.
|
|
70
|
-
|
|
71
|
-
Users cannot invoke `/blazor`, `/ef-core`, `/authentication`, etc. natively.
|
|
72
|
-
Levels 2–4 exist in `framework/skills/` and should be installed to `.claude/skills/`.
|
|
73
|
-
|
|
74
|
-
### G4: SubagentStart/SubagentStop hooks unused
|
|
75
|
-
|
|
76
|
-
The `SubagentStart` event fires when a morph native agent is activated.
|
|
77
|
-
A lightweight log hook on matcher `morph-.*` would capture agent usage
|
|
78
|
-
to `.morph/logs/agents.log` — useful for debugging and analytics.
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## What Is NOT Changing (Justified Architecture)
|
|
83
|
-
|
|
84
|
-
| Component | Reason to keep |
|
|
85
|
-
|---|---|
|
|
86
|
-
| `agents.json` as CLI source of truth | Needed for keyword matching, workflow detection, spawn-team |
|
|
87
|
-
| `.morph/state.json` state machine | Claude Code has no native phase concept |
|
|
88
|
-
| `.morph/memory/` | Stores structured morph outputs, distinct from Claude auto-memory |
|
|
89
|
-
| 7-phase workflow system | Core framework differentiator |
|
|
90
|
-
| All 12 existing hooks | Each serves a specific validated purpose |
|
|
91
|
-
| `agents.json` dual-format (JSON + compiled .md) | JSON needed for CLI logic; .md for native discovery |
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## Improvements
|
|
96
|
-
|
|
97
|
-
### Improvement 1: Richer agent frontmatter
|
|
98
|
-
|
|
99
|
-
**File:** `src/utils/agents-installer.js`
|
|
100
|
-
**Change:** Expand `buildBody()` and the YAML header to emit `model`, `tools`,
|
|
101
|
-
`maxTurns`, `skills`, and `memory` fields based on agent tier.
|
|
102
|
-
|
|
103
|
-
**Tier mapping:**
|
|
104
|
-
|
|
105
|
-
| Tier | model | tools | maxTurns | skills | memory |
|
|
106
|
-
|------|-------|-------|----------|--------|--------|
|
|
107
|
-
| 1 — Orchestrators | `inherit` | `Read, Grep, Glob, Bash, Task` | 30 | `morph-workflow` | `project` |
|
|
108
|
-
| 2 — Domain Leaders | `inherit` | `Read, Grep, Glob, Bash` | 20 | `morph-workflow` | `local` |
|
|
109
|
-
|
|
110
|
-
`morph-workflow` refers to the skill at `.claude/skills/morph-workflow.md`
|
|
111
|
-
(copied from `framework/rules/morph-workflow.md` — note: skill vs. rules are
|
|
112
|
-
separate directories; a `morph-workflow` skill should be added to `framework/skills/level-0-meta/`
|
|
113
|
-
or the rules file referenced directly).
|
|
114
|
-
|
|
115
|
-
**Expected output per agent:**
|
|
116
|
-
```markdown
|
|
117
|
-
---
|
|
118
|
-
name: Chief Architect
|
|
119
|
-
description: Team Lead (Delegate Mode). Coordinate Domain Leaders...
|
|
120
|
-
model: inherit
|
|
121
|
-
tools: Read, Grep, Glob, Bash, Task
|
|
122
|
-
maxTurns: 30
|
|
123
|
-
skills:
|
|
124
|
-
- morph-workflow
|
|
125
|
-
memory: project
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
You are the Chief Architect and Team Lead...
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
**Tests:** Update `test/utils/agents-installer.test.js` to assert
|
|
132
|
-
`model:`, `tools:`, `maxTurns:`, `memory:` appear in generated files.
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
### Improvement 2: Upgrade Stop hook to `type: "agent"`
|
|
137
|
-
|
|
138
|
-
**File:** `src/utils/hooks-installer.js`
|
|
139
|
-
**Change:** Replace the `Stop` hook entry from `type: "command"` (Node.js script)
|
|
140
|
-
to `type: "agent"` with an inline prompt.
|
|
141
|
-
|
|
142
|
-
```js
|
|
143
|
-
{
|
|
144
|
-
event: 'Stop',
|
|
145
|
-
matcher: null,
|
|
146
|
-
hooks: [{
|
|
147
|
-
type: 'agent',
|
|
148
|
-
prompt: `Check if the active morph-spec feature phase is complete.
|
|
149
|
-
1. Read .morph/state.json to find features with status "in_progress".
|
|
150
|
-
2. For the active feature+phase, check that required output files exist and are non-empty.
|
|
151
|
-
3. If all outputs exist, return {"ok": true}.
|
|
152
|
-
4. If any required output is missing or empty, return {"ok": false, "reason": "Missing: <path>"}.
|
|
153
|
-
Do NOT modify any files.`,
|
|
154
|
-
timeout: 60
|
|
155
|
-
}]
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
**Migration:** Remove `framework/hooks/claude-code/stop/validate-completion.js`
|
|
160
|
-
or keep it as fallback for environments where agent hooks aren't supported.
|
|
161
|
-
Update hook pattern detection in `removeMorphHooks()` to handle `type: "agent"` entries.
|
|
162
|
-
|
|
163
|
-
**Tests:** Update `test/hooks/hooks-installer.test.js` to assert the Stop hook
|
|
164
|
-
uses `type: "agent"` and has the expected prompt fields.
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
### Improvement 3: Install all skill levels
|
|
169
|
-
|
|
170
|
-
**File:** `src/utils/skills-installer.js`
|
|
171
|
-
**Change:** Expand `SKILL_LEVELS_TO_INSTALL` to include all 5 levels.
|
|
172
|
-
|
|
173
|
-
```js
|
|
174
|
-
const SKILL_LEVELS_TO_INSTALL = [
|
|
175
|
-
'level-0-meta',
|
|
176
|
-
'level-1-workflows',
|
|
177
|
-
'level-2-domains',
|
|
178
|
-
'level-3-technologies',
|
|
179
|
-
'level-4-patterns'
|
|
180
|
-
];
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Expected native invocations after change:**
|
|
184
|
-
- `/blazor`, `/nextjs`, `/ef-core`, `/azure-devops` (level-3)
|
|
185
|
-
- `/authentication`, `/caching`, `/validation` (level-4)
|
|
186
|
-
- `/frontend`, `/backend`, `/devops` (level-2)
|
|
187
|
-
|
|
188
|
-
**Tests:** Update `test/utils/skills-installer.test.js` to assert
|
|
189
|
-
level-2, level-3, level-4 skill files are installed.
|
|
190
|
-
|
|
191
|
-
---
|
|
192
|
-
|
|
193
|
-
### Improvement 4: SubagentStart logging hook
|
|
194
|
-
|
|
195
|
-
**New file:** `framework/hooks/claude-code/subagent/log-agent-start.js`
|
|
196
|
-
**Change:** Add a new hook entry in `MORPH_HOOKS` for `SubagentStart`.
|
|
197
|
-
|
|
198
|
-
Hook logic (log-agent-start.js):
|
|
199
|
-
- Read JSON from stdin (contains `agent_type`)
|
|
200
|
-
- Append `{timestamp, agentType}` to `.morph/logs/agents.log`
|
|
201
|
-
- Exit 0 (always non-blocking)
|
|
202
|
-
|
|
203
|
-
Hook definition:
|
|
204
|
-
```js
|
|
205
|
-
{
|
|
206
|
-
event: 'SubagentStart',
|
|
207
|
-
matcher: 'morph-.*',
|
|
208
|
-
hooks: [{
|
|
209
|
-
type: 'command',
|
|
210
|
-
command: 'node "$CLAUDE_PROJECT_DIR/framework/hooks/claude-code/subagent/log-agent-start.js"'
|
|
211
|
-
}]
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
**Tests:** Add to `test/hooks/` for the new hook script.
|
|
216
|
-
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
## Success Criteria
|
|
220
|
-
|
|
221
|
-
1. `morph-spec init` produces `.claude/agents/` files with `model`, `tools`,
|
|
222
|
-
`maxTurns`, `memory`, `skills` frontmatter fields
|
|
223
|
-
2. `.claude/settings.local.json` Stop hook uses `type: "agent"` not `type: "command"`
|
|
224
|
-
3. `.claude/skills/` contains files from all 5 skill levels (not just 0 + 1)
|
|
225
|
-
4. `SubagentStart` hook entry present in settings with `morph-.*` matcher
|
|
226
|
-
5. All existing tests pass (no regressions)
|
|
227
|
-
6. New tests added for all 4 improvements
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## Files to Modify
|
|
232
|
-
|
|
233
|
-
| File | Change |
|
|
234
|
-
|------|--------|
|
|
235
|
-
| `src/utils/agents-installer.js` | Add tier-based `model`, `tools`, `maxTurns`, `skills`, `memory` to frontmatter |
|
|
236
|
-
| `src/utils/skills-installer.js` | Add levels 2–4 to `SKILL_LEVELS_TO_INSTALL` |
|
|
237
|
-
| `src/utils/hooks-installer.js` | Upgrade Stop hook to `type: "agent"`; add SubagentStart hook |
|
|
238
|
-
| `framework/hooks/claude-code/subagent/log-agent-start.js` | **NEW** — agent activation logger |
|
|
239
|
-
| `test/utils/agents-installer.test.js` | Assert new frontmatter fields |
|
|
240
|
-
| `test/utils/skills-installer.test.js` | Assert levels 2–4 installed |
|
|
241
|
-
| `test/hooks/hooks-installer.test.js` | Assert Stop hook type and SubagentStart entry |
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
*Design approved: 2026-02-22*
|
|
246
|
-
*Next step: writing-plans skill to create step-by-step implementation plan*
|