@polymorphism-tech/morph-spec 8.2.1 → 8.4.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 (55) hide show
  1. package/README.md +73 -102
  2. package/bin/morph-spec.js +36 -1
  3. package/claude-plugin.json +1 -1
  4. package/docs/CHEATSHEET.md +77 -134
  5. package/docs/QUICKSTART.md +47 -57
  6. package/framework/CLAUDE.md +6 -3
  7. package/framework/MORPH.md +2 -2
  8. package/framework/agents.json +3 -1
  9. package/framework/commands/morph-hotfix.md +1 -1
  10. package/framework/hooks/README.md +3 -0
  11. package/framework/hooks/claude-code/core/state-sync.js +41 -9
  12. package/framework/hooks/claude-code/core/telemetry-log.js +102 -0
  13. package/framework/hooks/shared/state-writer.js +14 -3
  14. package/framework/hooks/shared/telemetry-logger.js +75 -0
  15. package/framework/rules/ai-agents-standards.md +1 -0
  16. package/framework/schemas/feature.schema.json +15 -7
  17. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  18. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  19. package/framework/skills/core/morph-apply/SKILL.md +1 -1
  20. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  21. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  22. package/framework/skills/core/morph-hotfix/SKILL.md +3 -3
  23. package/framework/skills/core/morph-implement/SKILL.md +1 -1
  24. package/framework/skills/core/morph-plan/SKILL.md +1 -1
  25. package/framework/skills/core/morph-proposal/SKILL.md +4 -4
  26. package/framework/skills/core/morph-review/SKILL.md +1 -1
  27. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  28. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  29. package/framework/standards/STANDARDS.json +43 -1
  30. package/framework/standards/ai-agents/observability-patterns.md +156 -0
  31. package/framework/standards/ai-agents/production.md +3 -47
  32. package/framework/templates/REGISTRY.json +0 -93
  33. package/package.json +1 -1
  34. package/src/commands/observability/telemetry.js +75 -0
  35. package/src/commands/project/doctor.js +28 -0
  36. package/src/commands/state/advance.js +17 -0
  37. package/src/commands/state/approve.js +13 -0
  38. package/src/commands/state/create.js +21 -1
  39. package/src/commands/state/delete.js +143 -0
  40. package/src/commands/state/list.js +110 -0
  41. package/src/core/state/feature-identity.js +36 -0
  42. package/src/core/state/gate-order.js +51 -0
  43. package/src/core/state/lifecycle-audit.js +79 -0
  44. package/src/core/state/state-manager.js +47 -140
  45. package/src/dashboard/app/pages/LiveState.jsx +0 -43
  46. package/src/lib/detectors/design-system-detector.js +0 -43
  47. package/src/lib/generators/index.js +0 -1
  48. package/src/lib/telemetry/telemetry-reader.js +103 -0
  49. package/src/lib/validators/validation-runner.js +9 -73
  50. package/src/utils/hooks-installer.js +27 -3
  51. package/framework/templates/context/CONTEXT-FEATURE.md +0 -269
  52. package/framework/templates/context/CONTEXT.md +0 -181
  53. package/src/lib/agents/metrics-aggregator.js +0 -56
  54. package/src/lib/agents/metrics-calculator.js +0 -125
  55. package/src/lib/generators/metadata-extractor.js +0 -385
@@ -5,10 +5,12 @@
5
5
  ```bash
6
6
  npm install -g @polymorphism-tech/morph-spec@latest --prefer-online # install/upgrade globally
7
7
  morph-spec init # initialize project
8
- morph-spec init --wizard # interactive wizard
9
- morph-spec init --force # overwrite existing
10
- morph-spec update # sync framework files
11
- morph-spec doctor # health check
8
+ morph-spec init --force # overwrite existing install
9
+ morph-spec init --skip-mcp # skip interactive MCP setup
10
+ morph-spec setup-infra # headless install, no prompts (used by init internally)
11
+ morph-spec setup-infra --reinstall # re-install only stack-aware assets (rules/skills/agents)
12
+ morph-spec update # sync framework templates/standards to the installed version
13
+ morph-spec doctor # health check (agents/rules drift, hook config, etc.)
12
14
  morph-spec --version
13
15
  ```
14
16
 
@@ -21,96 +23,78 @@ morph-spec --version
21
23
  ## Phase workflow
22
24
 
23
25
  ```
24
- proposal → [uiux] → design → plan → tasks → implement → [sync]
26
+ proposal → [uiux] → plan → implement → review
25
27
  ```
26
28
 
27
- Phases in brackets are optional.
29
+ `uiux` is optional. Which of the 5 phases actually run for a given feature is also shaped by its **work type** (see below) — a `chore` skips straight to implement, a `hotfix` runs a different pipeline entirely.
28
30
 
29
- | Phase | Directory | Output files | Gate |
30
- |-------|-----------|--------------|------|
31
- | proposal | `0-proposal/` | `proposal.md` | ✅ Approval |
32
- | uiux *(optional)* | `1-design/` | `design-system.md`, `mockups.md`, `components.md`, `flows.md` | ✅ Approval |
33
- | design | `2-design/` | `spec.md`, `contracts.cs`, `decisions.md` | ✅ Approval |
34
- | plan | `3-plan/` | `plan.md` | ✅ Approval |
35
- | tasks | `4-tasks/` | `tasks.md` | ✅ Approval |
36
- | implement | `3-implement/` | code + `recap.md` | — |
37
- | sync *(optional)* | — | standards updated | — |
31
+ | Phase | Folder | Gate |
32
+ |-------|--------|------|
33
+ | proposal | `0-proposal/` | ✅ Gate 1 |
34
+ | uiux *(optional)* | `1-design/` | ✅ |
35
+ | plan | `2-plan/` | ✅ Gate 2 |
36
+ | implement | `3-implement/` | — (auto-advance between tasks) |
37
+ | review | `4-review/` | ✅ Gate 3 |
38
38
 
39
39
  ---
40
40
 
41
41
  ## Slash commands (Claude Code)
42
42
 
43
- | Command | Description |
44
- |---------|-------------|
45
- | `/morph-proposal {feature}` | Full spec pipeline — phases 0–4 with approval gates |
46
- | `/morph-apply {feature}` | Implement approved feature — phase 5 |
47
- | `/morph-hotfix {feature}` | Surgical hotfix ADW — scout → fix → human Gate 3 → ship |
48
- | `/morph-status` | Project-wide feature status dashboard |
49
- | `/morph-preflight` | Pre-implementation validation (7 checks) |
43
+ | Command | Purpose |
44
+ |---------|---------|
45
+ | `/morph-proposal {feature}` | Business understanding + plan (Gates 1 and 2). Step 0 routes by work type (`feature`/`bug`/`chore`/`hotfix`) |
46
+ | `/morph-hotfix {feature}` | Surgical hotfix ADW (scout → fix → human gate → ship) |
47
+ | `/morph-apply {feature}` | Autonomous execution + review (Gate 3) |
48
+ | `/morph-status [feature]` | Status of the active (or specified) feature |
49
+ | `/morph-archive {feature}` | Archive a completed feature (after Gate 3) |
50
+ | `/morph-preflight` | Pre-deploy validation (specs, contracts, tests, infra) |
51
+ | `/morph-troubleshoot [error]` | Root-cause diagnosis for .NET/Next.js errors |
50
52
 
51
53
  ---
52
54
 
53
- ## CLI — project management
55
+ ## CLI — approvals & phase advance
54
56
 
55
57
  ```bash
56
- morph-spec init [--force] [--skip-mcp]
57
- morph-spec update [--templates] [--standards]
58
- morph-spec doctor
58
+ morph-spec approve {feature} {gate} [--mode auto] [--approver name] [--notes text]
59
+ morph-spec advance {feature} [--design] # approve current gate + scaffold next phase folder in one step
60
+ morph-spec approval-status {feature} [--json]
61
+ morph-spec unapprove {feature} {gate} [--reason text] # recovery only
62
+ morph-spec archive {feature} [--force] [--no-git]
59
63
  ```
60
64
 
61
65
  ---
62
66
 
63
- ## CLI — feature workflow
67
+ ## CLI — feature birth & work-type routing
64
68
 
65
- ```bash
66
- morph-spec state list # all features
67
- morph-spec state get {feature} [--json] # feature detail
68
- morph-spec state set {feature} {key} {value} # update property
69
- morph-spec phase advance {feature} # advance to next phase
70
- morph-spec status {feature} [--json] [--verbose]
71
- morph-spec task done {feature} {task-id} # mark task complete
72
- morph-spec task start {feature} {task-id} # start a task (dispatch gate)
73
- ```
74
-
75
- ---
69
+ Every feature is born with a **work type** that dimensions its pipeline: `feature` (full proposal → [uiux] → plan → implement → review), `bug` (lean), `chore` (fast-track straight to implement), `hotfix` (scout → surgical fix → human Gate 3 always, even under `trust: auto`).
76
70
 
77
- ## CLI — validation
71
+ Every feature is also born with an **identity**: `--description` is required (`create` refuses a nameless scaffold without it), `name` defaults to the slug.
78
72
 
79
73
  ```bash
80
- morph-spec validate # all validators
81
- morph-spec validate architecture
82
- morph-spec validate packages
83
- morph-spec validate contrast [--wcag-aaa]
84
- morph-spec validate-feature {feature} [--phase {phase}] [--json]
85
- morph-spec verify {feature} [task] [--json] # deterministic build+tests+validators chain, before the LLM judge
74
+ morph-spec create {feature} --type feature|bug|chore|hotfix --description "<what/why>"
75
+ morph-spec create {feature} --request "<free text>" # detector classifies the type AND seeds the description
76
+ morph-spec retype {feature} {newType} # change type mid-flight (blocked after Gate 3)
86
77
  ```
87
78
 
88
79
  ---
89
80
 
90
- ## CLI — work-type routing
91
-
92
- Every feature is born with a **work type** that dimensions its pipeline: `feature` (full proposal → [uiux] → plan → implement → review), `bug` (lean), `chore` (fast-track straight to implement), `hotfix` (scout → surgical fix → human Gate 3 always, even under `trust: auto`).
81
+ ## CLI — state (server-side, timestamped)
93
82
 
94
83
  ```bash
95
- morph-spec create {feature} --type feature|bug|chore|hotfix
96
- morph-spec create {feature} --request "<free text>" # deterministic detector classifies the type
97
- morph-spec retype {feature} {newType} # change type mid-flight (blocked after Gate 3)
84
+ morph-spec score {feature} {task} {score} [--dims "9.5,9,9,9"] # writes taskScores
85
+ morph-spec gate-decision {feature} {gate} --pause <bool> [--reason] [--signals json] # writes gateDecisions
98
86
  ```
99
87
 
100
- ---
88
+ Never hand-edit `taskScores`/`gateDecisions`/`approvalGates` in `feature.json` — always go through these commands (they collide with the `state-sync` hook otherwise).
101
89
 
102
- ## CLI — worktrees (parallel development / fleet)
90
+ ---
103
91
 
104
- One feature = one git worktree = one Claude Code instance. Independent features run side by side without stepping on each other's state; a SessionStart hook injects each worktree's feature identity, allocated ports and handoff pointer into context. Each worktree gets a deterministic port block (`.morph/worktree.env`) and a regenerable handoff document.
92
+ ## CLI — validation
105
93
 
106
94
  ```bash
107
- morph-spec create {feature} --worktree # birth the feature already isolated in its own worktree
108
- morph-spec worktree setup {feature} # create .worktrees/{feature}/ on branch morph/{feature}
109
- morph-spec worktree link [--all] # relink shared infra (node_modules, .claude, .morph/framework)
110
- morph-spec worktree finish {feature} # merge --no-ff back to the primary root, clean up + release ports (requires Gate 3)
111
- morph-spec worktree list [--json] # active feature worktrees with phase/gate status
112
- morph-spec handoff {feature} [--json] # regenerate the compressed session-handoff doc (pointers, not copies)
113
- morph-spec fleet [--json] # fleet view: every active feature (root + worktrees) with phase/gates/ports/handoff/activity
95
+ morph-spec validate [architecture|packages|contrast] [--wcag-aaa]
96
+ morph-spec validate-feature {feature} [--phase {phase}] [--json] # alias: vf
97
+ morph-spec verify {feature} [task] [--json] [--skip-tests] [--skip-build] # deterministic build+test+validator chain, before the LLM judge
114
98
  ```
115
99
 
116
100
  ---
@@ -124,59 +108,30 @@ morph-spec dag {feature} --mermaid # emit the tasks.json DAG as a Mermai
124
108
 
125
109
  ---
126
110
 
127
- ## CLI — utilities
128
-
129
- ```bash
130
- morph-spec generate recap {feature} # auto-generate recap.md
131
- morph-spec template render {id} {output} {vars-json}
132
- morph-spec trust status [feature]
133
- morph-spec trust set {feature} {level} [reason] # level: manual|high|auto
134
- morph-spec mcp setup [name] [--list] [--auto]
135
- ```
136
-
137
- ---
138
-
139
- ## State — mark-output
140
-
141
- ```bash
142
- morph-spec state mark-output {feature} proposal
143
- morph-spec state mark-output {feature} spec
144
- morph-spec state mark-output {feature} contracts
145
- morph-spec state mark-output {feature} decisions
146
- morph-spec state mark-output {feature} tasks
147
- morph-spec state mark-output {feature} recap
148
-
149
- # UI outputs (camelCase or kebab-case both work)
150
- morph-spec state mark-output {feature} uiDesignSystem
151
- morph-spec state mark-output {feature} uiMockups
152
- morph-spec state mark-output {feature} uiComponents
153
- morph-spec state mark-output {feature} uiFlows
154
- ```
155
-
156
- ---
157
-
158
- ## State — agents
159
-
160
- ```bash
161
- morph-spec state add-agent {feature} {agent-id}
162
- morph-spec state remove-agent {feature} {agent-id}
163
- ```
164
-
165
- ---
111
+ ## CLI — worktrees (parallel development / fleet)
166
112
 
167
- ## Checkpoints
113
+ One feature = one git worktree = one Claude Code instance. Each worktree gets its own deterministic port block (`.morph/worktree.env`) and a regenerable handoff document.
168
114
 
169
115
  ```bash
170
- morph-spec checkpoint-save {feature}
116
+ morph-spec create {feature} --description "<what/why>" --worktree # birth the feature already isolated in its own worktree
117
+ morph-spec worktree setup {feature} # create .worktrees/{feature}/ on branch morph/{feature}
118
+ morph-spec worktree link [--all] # relink shared infra (node_modules[, .claude, .morph/framework])
119
+ morph-spec worktree finish {feature} # merge --no-ff back to the primary root, clean up + release ports (requires Gate 3)
120
+ morph-spec worktree list [--json] # active feature worktrees with phase/gate status
121
+ morph-spec handoff {feature} [--json] # regenerate the compressed session-handoff doc (pointers, not copies)
122
+ morph-spec fleet [--json] # every active feature (root + worktrees) with phase/gates/ports/handoff/activity
171
123
  ```
172
124
 
173
125
  ---
174
126
 
175
- ## Approvals
127
+ ## CLI — scaffolding & misc
176
128
 
177
129
  ```bash
178
- morph-spec approve {feature} {gate} # approve a gate
179
- morph-spec approval-status {feature} # show gate status
130
+ morph-spec scaffold dotnet {feature} {slice-name} [--dry-run] # generate a VSA feature slice
131
+ morph-spec scaffold nextjs {feature} [--dry-run] # generate a feature page + components
132
+ morph-spec context refresh # rescan project, regenerate .morph/context/README.md
133
+ morph-spec mcp setup [name] [--list] [--auto]
134
+ morph-spec dashboard [--port 3200] # open the inspector dashboard
180
135
  ```
181
136
 
182
137
  ---
@@ -185,47 +140,35 @@ morph-spec approval-status {feature} # show gate status
185
140
 
186
141
  ```
187
142
  .morph/
188
- ├── config/
189
- │ └── config.json # project config (editable)
143
+ ├── config/config.json # project config (editable)
190
144
  ├── framework/ # READ-ONLY
191
- │ ├── agents.json # 22 agents, 4 tiers
192
- │ ├── standards/ # 82 standards across 11 categories
193
- │ └── templates/ # code and IaC templates
194
- ├── context/ # project context (editable)
195
- │ ├── README.md
196
- │ └── standards.md
197
- ├── features/
198
- │ └── {feature}/
199
- │ ├── 0-proposal/proposal.md
200
- │ ├── 1-design/design-system.md, mockups.md, components.md, flows.md
201
- │ ├── 2-design/spec.md, contracts.cs, decisions.md
202
- │ ├── 3-tasks/tasks.md
203
- │ └── 4-implement/recap.md
204
- ├── checkpoints/
205
- ├── logs/
206
- └── state.json # READ-ONLY — CLI managed
145
+ │ ├── agents.json # 8 domain personas
146
+ │ ├── standards/ # standards registry
147
+ │ └── templates/ # code, IaC, and context templates
148
+ ├── context/ # project context (editable)
149
+ ├── features/{feature}/
150
+ │ ├── feature.json # authoritative, committed
151
+ │ ├── handoff.md
152
+ │ └── 0-proposal/ 1-design/ 2-plan/ 3-implement/ 4-review/
153
+ └── state.json # gitignored, derived index — never hand-edited
207
154
 
208
155
  .claude/
209
- ├── commands/ # slash commands
156
+ ├── commands/ # slash commands
210
157
  ├── skills/ # framework skills (SKILL.md per dir)
211
- ├── agents/ # native subagents (22)
212
- │ ├── morph-{id}.md # tier 1-2 agents
213
- │ └── morph-domain-{name}.md # tier 3 domain agents
214
- ├── rules/ # path-scoped rules (6 files)
215
- └── settings.local.json # hooks (10)
158
+ ├── agents/morph-{id}.md # generated subagents (one per persona, no tiers)
159
+ └── settings.local.json # hooks + permissions.deny
216
160
  ```
217
161
 
218
162
  ---
219
163
 
220
164
  ## Protected files
221
165
 
222
- These files are never edited directly. Use CLI commands or `morph-spec update` instead:
166
+ Never edited directly — go through CLI commands or `morph-spec update` instead:
223
167
 
224
168
  | Path | Protected by |
225
169
  |------|-------------|
226
- | `.morph/state.json` | `permissions.deny` |
227
- | `.morph/framework/**` | `permissions.deny` |
228
- | Approved spec/contracts | `protect-spec-files.js` hook |
170
+ | `.morph/state.json`, `.morph/framework/**` | `permissions.deny` |
171
+ | `tasks.json` plan contract (`title`/`description`/`dependencies`/`effort`/`doneCriteria`/`group`) after Gate 2 | `protect-spec-files` hook (semantic diff) |
229
172
 
230
173
  ---
231
174
 
@@ -239,4 +182,4 @@ These files are never edited directly. Use CLI commands or `morph-spec update` i
239
182
 
240
183
  ---
241
184
 
242
- *morph-spec v8.2.1 by Polymorphism Tech*
185
+ *morph-spec v8.4.0 by Polymorphism Tech*
@@ -19,11 +19,11 @@ morph-spec init
19
19
  ```
20
20
 
21
21
  `init` does the following:
22
- - Auto-detects your stack (Blazor, Next.js, Node.js, monorepo)
22
+ - Auto-detects your stack (.NET, Next.js, Node.js, monorepo)
23
23
  - Creates `.morph/` with framework files, standards, and templates
24
24
  - Creates `.morph/context/` with inferred project context
25
25
  - Installs `.claude/skills/`, `.claude/agents/`, `.claude/rules/`
26
- - Writes `.claude/settings.local.json` with 10 Claude Code hooks
26
+ - Writes `.claude/settings.local.json` with the fail-open Claude Code hooks (see `docs/ARCHITECTURE.md`)
27
27
  - Copies `CLAUDE.md` with runtime instructions
28
28
 
29
29
  Verify the installation:
@@ -44,42 +44,31 @@ Open your project in Claude Code and run:
44
44
 
45
45
  Replace `my-feature` with a short kebab-case name for your feature (e.g., `user-notifications`, `payment-flow`).
46
46
 
47
- The proposal pipeline runs phases 0–6 with three approval gates:
47
+ The proposal pipeline runs the `proposal` and `plan` phases (plus the optional `uiux` phase), with an approval gate at each:
48
48
 
49
- ### Phase 0 — Proposal
49
+ ### Proposal (Gate 1)
50
50
 
51
- Claude analyzes your request, detects which agents are relevant, and produces `0-proposal/proposal.md`. You review it and approve (or request changes).
51
+ Claude analyzes your request, detects the relevant stack and standards, and produces `0-proposal/proposal.md`. You review it and approve (or request changes).
52
52
 
53
- ### Phase 1 — Setup
53
+ ### UI/UX — optional (Gate)
54
54
 
55
- Loads project context from `.morph/context/`, confirms stack and active agents. No approval needed.
55
+ Only runs for UI-heavy features. Claude generates, under `1-design/`:
56
+ - `design-system.md` — colors, typography, spacing
57
+ - `mockups.md` — ASCII wireframes
58
+ - `components.md` — component specs
59
+ - `flows.md` — user flows and edge cases
56
60
 
57
- ### Phase 2 — UI/UX (conditional)
61
+ You approve the UI design before moving on.
58
62
 
59
- Only runs if frontend agents are active. Claude generates:
60
- - `1-design/design-system.md` — colors, typography, spacing
61
- - `1-design/mockups.md` — ASCII wireframes
62
- - `1-design/components.md` — component specs
63
- - `1-design/flows.md` — user flows and edge cases
63
+ ### Plan (Gate 2)
64
64
 
65
- You approve the UI design before design phase begins.
65
+ Claude produces, under `2-plan/`:
66
+ - `spec.md` — full requirements, use cases, validations
67
+ - `mandate.md` — the implementation contract (stack defaults, forbidden patterns)
68
+ - `tasks.json` — ordered task breakdown (`T001`, `T002`, …)
69
+ - `decisions.md` — architectural decision records (optional)
66
70
 
67
- ### Phase 3 — Design
68
-
69
- Claude produces the technical specification:
70
- - `2-design/spec.md` — full requirements, use cases, validations
71
- - `2-design/contracts.cs` — C# interfaces, DTOs, enums
72
- - `2-design/decisions.md` — architectural decision records (ADRs)
73
-
74
- You review and approve the design.
75
-
76
- ### Phase 4 — Clarify
77
-
78
- Claude identifies 3–7 ambiguities in the spec, asks you to resolve them, then updates the spec. No gate.
79
-
80
- ### Phase 6 — Tasks
81
-
82
- Claude breaks the spec into atomic tasks (`T001`, `T002`, …) saved to `3-tasks/tasks.md`. You approve the task list.
71
+ Claude identifies ambiguities in the spec and resolves them with you before finalizing. You review and approve the spec + mandate + task list together.
83
72
 
84
73
  At this point, planning is complete:
85
74
 
@@ -95,11 +84,11 @@ At this point, planning is complete:
95
84
  /morph-apply my-feature
96
85
  ```
97
86
 
98
- Claude reads `spec.md`, `contracts.cs`, and `tasks.md`, then implements task by task:
99
- - Starts each task, writes the code, marks it done
100
- - Runs 5 validators automatically after each task: security, architecture, packages, design system, Blazor concurrency
101
- - Auto-checkpoints every 3 tasks (validates, saves state)
102
- - Generates `4-implement/recap.md` on completion
87
+ Claude reads `spec.md`, `mandate.md`, and `tasks.json`, then implements task by task with auto-advance (no pause between tasks unless there's a blocking ambiguity):
88
+ - Tracks task progress with the native `TaskCreate`/`TaskUpdate` tools, persisted to `tasks.json`
89
+ - Runs the validators relevant to your stack after each task (e.g. `architecture`/`packages`/`contract-compliance` for .NET, `nextjs-component`/`css`/`design-system` for Next.js) via `morph-spec verify`
90
+ - Applies `morph-eval` after each task — a score below 9 triggers an autonomous correction loop, not a pause
91
+ - Generates `3-implement/recap.md` on completion, then Gate 3 review (`4-review/`)
103
92
 
104
93
  ---
105
94
 
@@ -108,21 +97,16 @@ Claude reads `spec.md`, `contracts.cs`, and `tasks.md`, then implements task by
108
97
  Check feature state:
109
98
 
110
99
  ```bash
111
- morph-spec state get my-feature
112
100
  morph-spec status my-feature
113
101
  ```
114
102
 
115
- Advance to the next phase manually (when needed):
103
+ Approve the current gate and scaffold the next phase folder in one step:
116
104
 
117
105
  ```bash
118
- morph-spec phase advance my-feature
106
+ morph-spec advance my-feature
119
107
  ```
120
108
 
121
- Mark a task complete:
122
-
123
- ```bash
124
- morph-spec task done my-feature T001
125
- ```
109
+ Task progress is tracked with the native `TaskCreate`/`TaskUpdate` tools and persisted to `tasks.json` — there is no separate CLI command for marking a task done.
126
110
 
127
111
  Run validators at any time:
128
112
 
@@ -145,14 +129,20 @@ morph-spec verify my-feature T001 # scoped to one task
145
129
 
146
130
  Not every change needs the full pipeline walked above. Every feature is born with a **work type** that dimensions its pipeline:
147
131
 
132
+ Every feature is also born with an **identity** — a `--description` (the one field a human must supply; `create` refuses a nameless scaffold without it) and a `name` (defaults to the slug):
133
+
148
134
  ```bash
149
- morph-spec create my-feature --type feature # default: full proposal → [uiux] → plan → implement → review
150
- morph-spec create my-fix --type bug # lean proposal/plan
151
- morph-spec create my-chore --type chore # skips straight to implement (Gates 1/2 stamped by policy)
152
- morph-spec create my-hotfix --type hotfix # scout → surgical fix → test loop; Gate 3 always pauses for a human
135
+ # full: proposal → [uiux] → plan → implement → review
136
+ morph-spec create my-feature --type feature --description "what & why"
137
+ # bug: lean proposal/plan
138
+ morph-spec create my-fix --type bug --description "what broke"
139
+ # chore: skips straight to implement (Gates 1/2 stamped by policy)
140
+ morph-spec create my-chore --type chore --description "the tidy-up"
141
+ # hotfix: scout → surgical fix → test loop; Gate 3 always pauses for a human
142
+ morph-spec create my-hotfix --type hotfix --description "the incident"
153
143
  ```
154
144
 
155
- You can also let the deterministic detector classify a free-text request instead of picking a type by hand:
145
+ You can also let the deterministic detector classify a free-text request instead of picking a type by hand (`--request` doubles as the description):
156
146
 
157
147
  ```bash
158
148
  morph-spec create my-feature --request "produção caiu, corrigir urgente"
@@ -173,7 +163,7 @@ Production incidents run through the dedicated `/morph-hotfix my-feature` slash
173
163
  Independent features can be developed in parallel, each isolated in its own git worktree — one feature, one worktree, one Claude Code instance:
174
164
 
175
165
  ```bash
176
- morph-spec create my-feature --worktree # birth the feature already isolated
166
+ morph-spec create my-feature --description "what & why" --worktree # birth the feature already isolated
177
167
  # or, for an existing feature:
178
168
  morph-spec worktree setup my-feature # creates .worktrees/my-feature/ on branch morph/my-feature
179
169
  ```
@@ -195,23 +185,23 @@ morph-spec worktree list
195
185
 
196
186
  ## Multiple features
197
187
 
198
- You can have multiple features in progress simultaneously. Each has its own directory under `.morph/features/`:
188
+ You can have multiple features in progress simultaneously. Each has its own directory under `.morph/features/`, with its own committed `feature.json`:
199
189
 
200
190
  ```
201
191
  .morph/features/
202
192
  ├── user-notifications/
193
+ │ ├── feature.json
203
194
  │ ├── 0-proposal/
204
- │ ├── 2-design/
205
- │ └── 3-tasks/
195
+ │ └── 2-plan/
206
196
  └── payment-flow/
207
- ├── 0-proposal/
208
- └── 2-design/
197
+ ├── feature.json
198
+ └── 0-proposal/
209
199
  ```
210
200
 
211
- See all feature states:
201
+ See every active feature — root and worktrees — with phase, gates, and activity:
212
202
 
213
203
  ```bash
214
- morph-spec state list
204
+ morph-spec fleet
215
205
  ```
216
206
 
217
207
  ---
@@ -256,4 +246,4 @@ morph-spec doctor
256
246
 
257
247
  ---
258
248
 
259
- *morph-spec v8.2.1 by Polymorphism Tech*
249
+ *morph-spec v8.4.0 by Polymorphism Tech*
@@ -47,12 +47,15 @@ Se não houver feature ativa, pergunte ao usuário qual feature trabalhar.
47
47
  - `morph-spec dag <feature>` — análise do DAG de tasks.json com decisão sequencial vs paralelo **ponderada por effort** (raízes S vão inline, nunca ganham agente próprio).
48
48
  - `morph-spec score <feature> <task> <score> [--dims a,c,q,t]` — grava `taskScores` no feature.json com timestamp server-side; **nunca edite taskScores à mão**. Em PowerShell, cite o valor de `--dims` entre aspas (`--dims "9.5,9,9,9"`) — sem aspas, a lista pode chegar como tokens separados; o parser aceita ambas as formas, mas citar evita qualquer ambiguidade.
49
49
  - `morph-spec gate-decision <feature> <gate> --pause <bool> [--reason <txt>] [--signals <json>]` — grava `gateDecisions` no feature.json com timestamp server-side (shape em `framework/schemas/feature.schema.json`); **nunca edite gateDecisions à mão** — o Edit manual colide com o hook state-sync.
50
- - `morph-spec create <feature> --type <feature|bug|chore|hotfix> [--request "<txt>"] [--worktree]` — cria a estrutura da feature + `feature.json` canônico explicitamente (nascimento explícito no início da proposal; o hook state-sync continua cobrindo o caminho implícito como fallback). `--type` classifica direto; `--request "<pedido>"` roda o detector determinístico (empate/sem sinal sai com exit 2 e candidatos — a LLM decide e re-roda com `--type`); `--worktree` já nasce a feature no seu worktree próprio.
50
+ - `morph-spec create <feature> --description "<o quê/porquê>" --type <feature|bug|chore|hotfix> [--request "<txt>"] [--name "<nome>"] [--worktree]` — cria a estrutura da feature + `feature.json` canônico explicitamente (nascimento explícito no início da proposal; o hook state-sync continua cobrindo o caminho implícito como fallback). **Identidade no nascimento:** `name` (default = slug) e `description` são carimbados; a `--description` é **obrigatória** numa feature nova (ou `--request`, que a semeia) — sem nenhuma das duas o `create` recusa (fim dos scaffolds anônimos). `--type` classifica direto; `--request "<pedido>"` roda o detector determinístico (empate/sem sinal sai com exit 2 e candidatos — a LLM decide e re-roda com `--type` + `--request`/`--description`); `--worktree` já nasce a feature no seu worktree próprio.
51
+ - `morph-spec list [--all] [--json]` — o quadro de auditoria: uma linha por feature × workType × status × fase × gates G1/G2/G3 × descrição, com `⚠` para inconsistências (sem descrição, ordem de gate). `--all` inclui as arquivadas; `--json` para scripting. É o complemento do `delete` (enxergar o que está morto antes de remover).
52
+ - `morph-spec delete <feature> [--archive] [--force]` — remove uma feature. Hard por padrão (pasta apagada, git-aware, + entrada podada do índice raiz para não ressuscitar); `--archive` move para `.morph/archive` com status `abandoned` em vez de apagar. Recusa se algum gate estiver aprovado, a menos que `--force`. Use para faxina de scaffolds mortos e drafts abandonados (`archive` é para trabalho concluído; `delete` é para trabalho morto).
51
53
  - `morph-spec retype <feature> <newType>` — muda o tipo de trabalho mid-flight; desfaz só os gates carimbados por política, preserva aprovações humanas; bloqueado após o Gate 3.
52
54
  - `morph-spec verify <feature> [task] [--json]` — cadeia determinística build+testes+validadores (código antes do juiz LLM); escopo de task quando informado, senão a feature inteira.
53
55
  - `morph-spec worktree setup|link|finish|list` — gerencia o ciclo do worktree por feature (`setup` cria `.worktrees/{f}/` na branch `morph/{f}`, aloca o bloco de portas e escreve `.morph/worktree.env`; `link` religa infra compartilhada; `finish` faz merge `--no-ff`, limpa e libera o bloco; `list` mostra fase/gate de cada worktree ativo).
54
56
  - `morph-spec handoff <feature>` — regenera o documento de retomada (`.morph/features/{f}/handoff.md`): comprimido, derivado, aponta para os artefatos em vez de copiá-los. Gerado automaticamente em `setup`/`create --worktree`/`advance`.
55
57
  - `morph-spec fleet` — visão da frota: toda feature ativa (raiz + worktrees) com fase, gates pendentes, tasks, portas, handoff e atividade. Use entre sessões para decidir onde atuar.
58
+ - `morph-spec telemetry [--json] [--feature <f>] [--limit <n>]` — reconstrói o caminho de execução da sessão a partir de `.morph/logs/events.jsonl` (skills invocadas, personas despachadas + prompts, standards/base de conhecimento lidos, mix de tools, prompts do usuário). Capturado silenciosamente pelo hook `telemetry-log` em todo tool call e todo UserPromptSubmit.
56
59
 
57
60
  ## Skills core (em `.claude/skills/`)
58
61
 
@@ -69,9 +72,9 @@ Se não houver feature ativa, pergunte ao usuário qual feature trabalhar.
69
72
 
70
73
  ## Roteamento por tipo de trabalho
71
74
 
72
- Toda feature nasce com um `workType` (`morph-spec create <f> --type <tipo>` ou classificado de `--request "<pedido>"`) que dimensiona o pipeline: `feature` roda o fluxo completo (proposal → [uiux] → plan → implement → review); `bug` roda uma versão enxuta (proposal/plan lean); `chore` pula direto para implement (Gates 1/2 carimbados por política no nascimento); `hotfix` roda scout → fix cirúrgico → test loop → ship. O Gate 3 do `hotfix` **pausa sempre para um humano**, mesmo em `trust: auto` — o CLI recusa `morph-spec approve <f> review --mode auto` nesse tipo. Detalhes em `.morph/framework/MORPH.md` §2.1 e §5.
75
+ Toda feature nasce com um `workType` (`morph-spec create <f> --description "<o quê/porquê>" --type <tipo>` ou classificado de `--request "<pedido>"`, que também semeia a descrição obrigatória) que dimensiona o pipeline: `feature` roda o fluxo completo (proposal → [uiux] → plan → implement → review); `bug` roda uma versão enxuta (proposal/plan lean); `chore` pula direto para implement (Gates 1/2 carimbados por política no nascimento); `hotfix` roda scout → fix cirúrgico → test loop → ship. O Gate 3 do `hotfix` **pausa sempre para um humano**, mesmo em `trust: auto` — o CLI recusa `morph-spec approve <f> review --mode auto` nesse tipo. Detalhes em `.morph/framework/MORPH.md` §2.1 e §5.
73
76
 
74
- Features independentes podem rodar em paralelo, cada uma isolada num git worktree (`morph-spec create <f> --worktree` ou `morph-spec worktree setup <f>`) — uma feature por worktree, uma instância de Claude Code por worktree. Cada worktree tem seu **bloco de portas** próprio (`.morph/worktree.env` — suba dev servers SEMPRE nelas, nunca nas portas padrão) e seu **handoff.md** de retomada. `feature.json` viaja commitado na branch `morph/{f}`; ao fechar, aprove o Gate 3 dentro do worktree e rode `morph-spec worktree finish <f>` seguido de `morph-spec archive <f>` na raiz. Visão agregada: `morph-spec fleet`. Detalhes em `.morph/framework/MORPH.md` §2.2.
77
+ Features independentes podem rodar em paralelo, cada uma isolada num git worktree (`morph-spec create <f> --description "<o quê/porquê>" --worktree` ou `morph-spec worktree setup <f>`) — uma feature por worktree, uma instância de Claude Code por worktree. Cada worktree tem seu **bloco de portas** próprio (`.morph/worktree.env` — suba dev servers SEMPRE nelas, nunca nas portas padrão) e seu **handoff.md** de retomada. `feature.json` viaja commitado na branch `morph/{f}`; ao fechar, aprove o Gate 3 dentro do worktree e rode `morph-spec worktree finish <f>` seguido de `morph-spec archive <f>` na raiz. Visão agregada: `morph-spec fleet`. Detalhes em `.morph/framework/MORPH.md` §2.2.
75
78
 
76
79
  ## Personas (em `.claude/agents/`)
77
80
 
@@ -97,7 +97,7 @@ Não avance de fase sem o gate correspondente ter sido confirmado.
97
97
 
98
98
  ### 2.1 Roteamento por tipo de trabalho
99
99
 
100
- Nem todo trabalho merece o pipeline completo. Cada feature nasce com um **workType** (`morph-spec create <f> --type <tipo>` ou classificado de `--request "<pedido>"`), e o tipo dimensiona o pipeline:
100
+ Nem todo trabalho merece o pipeline completo. Cada feature nasce com **identidade** (`name` = slug por padrão + `description` obrigatória) e um **workType** (`morph-spec create <f> --description "<o quê/porquê>" --type <tipo>`, ou classificado de `--request "<pedido>"` — que também semeia a descrição), e o tipo dimensiona o pipeline:
101
101
 
102
102
  | Tipo | Pipeline | Gates |
103
103
  |------|----------|-------|
@@ -114,7 +114,7 @@ Nem todo trabalho merece o pipeline completo. Cada feature nasce com um **workTy
114
114
 
115
115
  ### 2.2 Desenvolvimento paralelo por worktree (frota)
116
116
 
117
- Features independentes podem ser desenvolvidas **em paralelo, cada uma no seu git worktree**, com uma instância de Claude Code por worktree. `morph-spec create <f> --worktree` (ou `morph-spec worktree setup <f>`) cria `.worktrees/{f}/` na branch `morph/{f}`. Contrato:
117
+ Features independentes podem ser desenvolvidas **em paralelo, cada uma no seu git worktree**, com uma instância de Claude Code por worktree. `morph-spec create <f> --description "<o quê/porquê>" --worktree` (ou `morph-spec worktree setup <f>`) cria `.worktrees/{f}/` na branch `morph/{f}`. Contrato:
118
118
 
119
119
  - **Uma feature = um worktree = uma instância.** Nunca abra duas instâncias na mesma feature (o setup recusa com exit 3).
120
120
  - O estado autoritativo (`feature.json`) viaja **commitado na branch** `morph/{f}`. O `state.json` local do worktree é um índice derivável — materializado por self-heal, nunca sincronizado à mão.
@@ -64,6 +64,7 @@
64
64
  "ai-agents-prompts-in-db",
65
65
  "ai-agents-rag-custom-pgvector",
66
66
  "ai-agents-middleware-patterns",
67
+ "ai-agents-observability-patterns",
67
68
  "ai-agents-multi-agent-patterns"
68
69
  ],
69
70
  "mcp": ["context7"],
@@ -125,7 +126,8 @@
125
126
  "standards": [
126
127
  "backend-integrations-hangfire-hangfire-jobs",
127
128
  "infrastructure-docker-coolify-deploy",
128
- "backend-dotnet-scrutor"
129
+ "backend-dotnet-scrutor",
130
+ "ai-agents-observability-patterns"
129
131
  ],
130
132
  "mcp": ["context7"],
131
133
  "model": "sonnet",
@@ -16,7 +16,7 @@ Resolve uma queda ou bug crítico de produção com prioridade máxima em veloci
16
16
 
17
17
  ## Fluxo
18
18
 
19
- 1. **Nascimento:** `morph-spec create {feature-name} --type hotfix` — carimba os gates `proposal`/`plan` por política e cria `0-proposal/`, `2-plan/`, `3-implement/` num passo só.
19
+ 1. **Nascimento:** `morph-spec create {feature-name} --type hotfix --description "<incidente>"` — carimba `name`+`description` (obrigatória) e os gates `proposal`/`plan` por política e cria `0-proposal/`, `2-plan/`, `3-implement/` num passo só.
20
20
  2. **Scout obrigatório:** despacha `subagent_type: "morph-scout"` (fallback `general-purpose` + persona colada) para localizar root cause e blast radius antes de qualquer fix.
21
21
  3. **Hotfix brief:** escreve `0-proposal/proposal.md` curto (sintoma/root cause/blast radius/plano do fix) e `2-plan/tasks.json` mínimo (T1 fix, T2 verify/regressão).
22
22
  4. **Fix cirúrgico:** implementa a mudança mínima que resolve o sintoma — sem refatoração, sem hardening fora de escopo.
@@ -51,7 +51,9 @@ framework/hooks/
51
51
  | **PostToolUse** (Write\|Edit) | trace-autogen.js | State sync | Auto-generates `.morph/traces/YYYY-MM-DD-{feature}-implement.json` from tasks.json + recap.md + taskScores on every tasks.json write — the skills never write traces by hand |
52
52
  | **PostToolUse** (Write\|Edit\|AskUserQuestion) | state-sync.js | State sync | Autonomous state updates (feature register, output tracking, gate approval) |
53
53
  | **PostToolUse** (Write\|Edit\|AskUserQuestion) | gate-guard.js | Advisory | Warns (never blocks) when a gate action disagrees with the persisted gateDecisions; logs one `coherent`/`divergent` line per check in `.morph/logs/activity.json` (issue #63) |
54
+ | **PostToolUse** (all tools) | telemetry-log.js | Telemetry | Appends every tool call (skill, sub-agent dispatch + prompt, knowledge-base read, bash/edit) to `.morph/logs/events.jsonl`; silent, fail-open — the NLH execution-path capture read back by `morph-spec telemetry` |
54
55
  | **PostToolUse** (all tools) | loop-detect.js | Advisory | Warns when the last 8 actions collapse to ≤2 unique signatures |
56
+ | **UserPromptSubmit** | telemetry-log.js | Telemetry | Appends the user's prompt to the same `events.jsonl` stream; silent, fail-open |
55
57
  | **Stop** | validate-completion.js | Advisory | Warns about incomplete tasks/missing outputs/recap drift; build check; session snapshot |
56
58
 
57
59
  ## Design Principles
@@ -112,6 +114,7 @@ All Claude Code hooks import from `framework/hooks/shared/`:
112
114
  | `phase-utils.js` | Phase constants, path extraction, file classification |
113
115
  | `hook-response.js` | `block(reason)`, `approve(context)`, `injectContext(text)`, `pass()` |
114
116
  | `stdin-reader.js` | `readStdin()` — Promise-based stdin JSON reader |
117
+ | `telemetry-logger.js` | `appendTelemetryEvent()`, `readTelemetryEvents()` — append-only JSONL event stream (`.morph/logs/events.jsonl`) |
115
118
 
116
119
  `injectContext(text)` is how `worktree-context.js` (and any other SessionStart hook) delivers context: it emits `{ "hookSpecificOutput": { "hookEventName": "SessionStart", "additionalContext": text } }` on stdout. Claude Code only honors additional context nested under `hookSpecificOutput` — a bare top-level field is ignored.
117
120