@polymorphism-tech/morph-spec 4.9.0 → 4.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +30 -0
  3. package/bin/task-manager.js +34 -22
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +35 -98
  8. package/framework/agents/backend/api-designer.md +3 -0
  9. package/framework/agents/backend/dotnet-senior.md +3 -0
  10. package/framework/agents/backend/ef-modeler.md +2 -0
  11. package/framework/agents/backend/hangfire-orchestrator.md +2 -0
  12. package/framework/agents/backend/ms-agent-expert.md +2 -0
  13. package/framework/agents/frontend/blazor-builder.md +2 -0
  14. package/framework/agents/frontend/nextjs-expert.md +2 -0
  15. package/framework/agents/infrastructure/azure-architect.md +2 -0
  16. package/framework/agents/infrastructure/azure-deploy-specialist.md +2 -0
  17. package/framework/agents/infrastructure/bicep-architect.md +2 -0
  18. package/framework/agents/infrastructure/container-specialist.md +2 -0
  19. package/framework/agents/infrastructure/devops-engineer.md +3 -0
  20. package/framework/agents/infrastructure/infra-architect.md +3 -0
  21. package/framework/agents/integrations/asaas-financial.md +2 -0
  22. package/framework/agents/integrations/azure-identity.md +2 -0
  23. package/framework/agents/integrations/clerk-auth.md +3 -0
  24. package/framework/agents/integrations/hangfire-integration.md +2 -0
  25. package/framework/agents/integrations/resend-email.md +2 -0
  26. package/framework/agents.json +37 -7
  27. package/framework/commands/commit.md +166 -0
  28. package/framework/commands/morph-apply.md +156 -155
  29. package/framework/commands/morph-archive.md +33 -27
  30. package/framework/commands/morph-infra.md +83 -77
  31. package/framework/commands/morph-preflight.md +97 -55
  32. package/framework/commands/morph-proposal.md +131 -58
  33. package/framework/commands/morph-status.md +36 -30
  34. package/framework/commands/morph-troubleshoot.md +68 -59
  35. package/framework/hooks/claude-code/notification/approval-reminder.js +3 -2
  36. package/framework/hooks/claude-code/post-tool-use/dispatch.js +154 -31
  37. package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +7 -84
  38. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +8 -17
  39. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +16 -3
  40. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +4 -3
  41. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +3 -2
  42. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +60 -0
  43. package/framework/hooks/claude-code/session-start/inject-morph-context.js +55 -2
  44. package/framework/hooks/claude-code/session-start/post-compact-restore.js +41 -0
  45. package/framework/hooks/claude-code/stop/validate-completion.js +2 -15
  46. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +23 -5
  47. package/framework/hooks/shared/compact-restore.js +100 -0
  48. package/framework/hooks/shared/dispatch-helpers.js +116 -0
  49. package/framework/hooks/shared/phase-utils.js +9 -5
  50. package/framework/hooks/shared/state-reader.js +27 -3
  51. package/framework/phases.json +30 -7
  52. package/framework/rules/csharp-standards.md +3 -0
  53. package/framework/rules/frontend-standards.md +2 -0
  54. package/framework/rules/infrastructure-standards.md +3 -0
  55. package/framework/rules/morph-workflow.md +143 -86
  56. package/framework/rules/nextjs-standards.md +2 -0
  57. package/framework/rules/testing-standards.md +3 -0
  58. package/framework/skills/level-0-meta/mcp-registry.json +86 -51
  59. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +139 -0
  60. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +42 -19
  61. package/framework/skills/level-0-meta/{code-review → morph-code-review}/SKILL.md +8 -5
  62. package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/SKILL.md +8 -6
  63. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +362 -0
  64. package/framework/skills/level-0-meta/morph-init/SKILL.md +114 -20
  65. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +362 -0
  66. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +95 -87
  67. package/framework/skills/level-0-meta/{simulation-checklist → morph-simulation-checklist}/SKILL.md +24 -0
  68. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/SKILL.md +43 -43
  69. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/references/tools-per-phase.md +1 -2
  70. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/SKILL.md +23 -12
  71. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/scripts/check-phase-outputs.mjs +2 -2
  72. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +247 -0
  73. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +270 -0
  74. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +499 -0
  75. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +38 -0
  76. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +472 -0
  77. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +50 -0
  78. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +45 -0
  79. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +47 -0
  80. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +246 -0
  81. package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +238 -0
  82. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +14 -0
  83. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +312 -0
  84. package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/scripts/validate-tasks.mjs +3 -3
  85. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +324 -0
  86. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +146 -0
  87. package/framework/standards/integration/mcp/mcp-tools.md +25 -7
  88. package/framework/templates/docs/onboarding.md +2 -2
  89. package/package.json +3 -4
  90. package/src/commands/agents/dispatch-agents.js +50 -3
  91. package/src/commands/mcp/mcp-setup.js +39 -2
  92. package/src/commands/phase/phase-reset.js +74 -0
  93. package/src/commands/project/doctor.js +26 -7
  94. package/src/commands/project/update.js +4 -4
  95. package/src/commands/scope/escalate.js +215 -0
  96. package/src/commands/state/advance-phase.js +27 -53
  97. package/src/commands/state/state.js +1 -1
  98. package/src/commands/task/expand.js +100 -0
  99. package/src/core/paths/output-schema.js +4 -3
  100. package/src/core/state/phase-state-machine.js +7 -4
  101. package/src/core/state/state-manager.js +4 -3
  102. package/src/lib/detectors/claude-config-detector.js +93 -347
  103. package/src/lib/detectors/design-system-detector.js +189 -189
  104. package/src/lib/detectors/index.js +155 -57
  105. package/src/lib/generators/context-generator.js +2 -2
  106. package/src/lib/installers/mcp-installer.js +37 -5
  107. package/src/lib/phase-chain/phase-validator.js +22 -16
  108. package/src/lib/scope/impact-analyzer.js +106 -0
  109. package/src/lib/stack-filter.js +58 -0
  110. package/src/lib/tasks/task-parser.js +1 -1
  111. package/src/lib/validators/shared/emit-validator-dispatch.js +64 -0
  112. package/src/scripts/setup-infra.js +68 -18
  113. package/src/utils/agents-installer.js +51 -17
  114. package/src/utils/claude-md-injector.js +90 -0
  115. package/src/utils/file-copier.js +0 -1
  116. package/src/utils/hooks-installer.js +16 -5
  117. package/src/utils/skills-installer.js +67 -7
  118. package/CLAUDE.md +0 -98
  119. package/framework/memory/patterns-learned.md +0 -766
  120. package/framework/skills/level-0-meta/brainstorming/SKILL.md +0 -137
  121. package/framework/skills/level-0-meta/frontend-review/SKILL.md +0 -359
  122. package/framework/skills/level-0-meta/post-implementation/SKILL.md +0 -362
  123. package/framework/skills/level-0-meta/terminal-title/SKILL.md +0 -61
  124. package/framework/skills/level-0-meta/terminal-title/scripts/set_title.sh +0 -65
  125. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +0 -216
  126. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +0 -252
  127. package/framework/skills/level-1-workflows/phase-design/SKILL.md +0 -383
  128. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +0 -492
  129. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +0 -195
  130. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +0 -271
  131. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +0 -286
  132. package/src/commands/project/index.js +0 -8
  133. package/src/core/index.js +0 -10
  134. package/src/core/state/index.js +0 -8
  135. package/src/core/templates/index.js +0 -9
  136. package/src/core/templates/template-data-sources.js +0 -325
  137. package/src/core/workflows/index.js +0 -7
  138. package/src/lib/detectors/config-detector.js +0 -223
  139. package/src/lib/detectors/standards-generator.js +0 -335
  140. package/src/lib/detectors/structure-detector.js +0 -275
  141. package/src/lib/monitor/agent-resolver.js +0 -144
  142. package/src/lib/monitor/renderer.js +0 -230
  143. package/src/lib/orchestration/index.js +0 -7
  144. package/src/lib/orchestration/team-orchestrator.js +0 -404
  145. package/src/sanitizer/context-sanitizer.js +0 -221
  146. package/src/sanitizer/patterns.js +0 -163
  147. package/src/writer/file-writer.js +0 -86
  148. /package/framework/skills/level-0-meta/{brainstorming → morph-brainstorming}/references/proposal-example.md +0 -0
  149. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-example.md +0 -0
  150. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-guidelines.md +0 -0
  151. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/scripts/scan-csharp.mjs +0 -0
  152. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/references/review-example-nextjs.md +0 -0
  153. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/scripts/scan-nextjs.mjs +0 -0
  154. /package/framework/skills/level-0-meta/{frontend-review → morph-frontend-review}/scripts/scan-accessibility.mjs +0 -0
  155. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-dev-server.mjs +0 -0
  156. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-stack.mjs +0 -0
  157. /package/framework/skills/level-1-workflows/{phase-clarify → morph-phase-clarify}/references/clarifications-example.md +0 -0
  158. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/architecture-analysis-guide.md +0 -0
  159. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-authoring-guide.md +0 -0
  160. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-example.md +0 -0
  161. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/recap-example.md +0 -0
  162. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/vsa-implementation-guide.md +0 -0
  163. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/task-planning-patterns.md +0 -0
  164. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/tasks-example.md +0 -0
@@ -125,13 +125,13 @@ uiLibrary: shadcn | fluent-ui | mudblazor | null
125
125
  monorepo: true | false
126
126
  frontendPath: src/frontend (if monorepo)
127
127
  backendPath: src/backend (if monorepo)
128
- architectureStyle: vertical-slice | null ← novo
128
+ architectureStyle: vertical-slice | null ← new
129
129
  ```
130
130
 
131
- **VSA detection:** `architectureStyle: "vertical-slice"` se qualquer um destes existir:
132
- - `Abstractions/IHandler.cs` encontrado pelo Glob
133
- - `Pipelines/ValidationDecorator.cs` encontrado pelo Glob
134
- - 2+ pastas com sufixo `Feature` em `Features/` (ex: `BookFeature`, `OrderFeature`)
131
+ **VSA detection:** `architectureStyle: "vertical-slice"` if any of these exist:
132
+ - `Abstractions/IHandler.cs` found by Glob
133
+ - `Pipelines/ValidationDecorator.cs` found by Glob
134
+ - 2+ folders with `Feature` suffix in `Features/` (e.g., `BookFeature`, `OrderFeature`)
135
135
 
136
136
  ---
137
137
 
@@ -143,9 +143,9 @@ Ask at most 3 questions, only those that apply:
143
143
 
144
144
  | # | Question | Condition | Purpose |
145
145
  |---|----------|-----------|---------|
146
- | 1 | *"Em uma frase: qual é o objetivo principal do **[ProjectName]**?"* | Always | README.md Overview |
147
- | 2 | *"Confirmo: frontend em `{frontendPath}`, backend em `{backendPath}`. Correto?"* | Monorepo detected | Validate paths before persisting |
148
- | 3 | *"Supabase Cloud (managed) ou self-hosted?"* | Supabase detected | MCP URL configuration |
146
+ | 1 | *"In one sentence: what is the main purpose of **[ProjectName]**?"* | Always | README.md Overview |
147
+ | 2 | *"Confirmed: frontend at `{frontendPath}`, backend at `{backendPath}`. Correct?"* | Monorepo detected | Validate paths before persisting |
148
+ | 3 | *"Supabase Cloud (managed) or self-hosted?"* | Supabase detected | MCP URL configuration |
149
149
 
150
150
  Do **not** ask about technology already confirmed by file evidence.
151
151
 
@@ -200,7 +200,7 @@ Read `.morph/config/config.json` and merge into `project`:
200
200
  }
201
201
  ```
202
202
 
203
- **Se `architectureStyle: "vertical-slice"` foi detectado no Step 3**, adicione também:
203
+ **If `architectureStyle: "vertical-slice"` was detected in Step 3**, also add:
204
204
 
205
205
  ```json
206
206
  {
@@ -210,7 +210,7 @@ Read `.morph/config/config.json` and merge into `project`:
210
210
  }
211
211
  ```
212
212
 
213
- E informe o usuário:
213
+ And inform the user:
214
214
 
215
215
  ```
216
216
  ✓ Detected: Vertical Slice Architecture (IHandler.cs / *Feature folders)
@@ -218,12 +218,12 @@ E informe o usuário:
218
218
  → morph-spec will use vsa-architect + contracts-vsa.cs for features
219
219
  ```
220
220
 
221
- > Esta key é o que ativa o `vsa-architect` em vez do `domain-architect` durante `/morph-proposal`.
221
+ > This key is what activates `vsa-architect` instead of `domain-architect` during `/morph-proposal`.
222
222
 
223
- **Se o projeto ainda não existe (novo projeto VSA do zero)**, informe também:
223
+ **If the project doesn't exist yet (new VSA project from scratch)**, also inform:
224
224
 
225
225
  ```
226
- Para criar um novo projeto VSA:
226
+ To create a new VSA project:
227
227
  dotnet new install https://github.com/polymorphism-tech/Morph_Template_VerticalSliceArchitecture
228
228
  dotnet new vsa -n MyProject
229
229
  cd MyProject && npx morph-spec init
@@ -236,17 +236,43 @@ Para criar um novo projeto VSA:
236
236
  For each detected integration with an available MCP:
237
237
 
238
238
  **Supabase detected:**
239
- > *"Configure Supabase MCP now? I'll need `SUPABASE_URL` and `SERVICE_ROLE_KEY`."*
240
- - YES → collect credentials add to `.claude/settings.local.json` under `mcpServers`
239
+ > *"Configure Supabase MCP? Uses OAuth no credentials needed."*
240
+ - YES → write remote config to `.claude/settings.local.json`:
241
+ ```json
242
+ "supabase": { "type": "http", "url": "https://mcp.supabase.com/mcp" }
243
+ ```
241
244
  - NO → show snippet + `npx morph-spec mcp setup supabase`
242
245
 
243
246
  **GitHub:**
244
- > *"Configure GitHub MCP? I'll need a `GITHUB_PERSONAL_ACCESS_TOKEN`."*
245
- - YES/NOsame pattern
247
+ > *"Configure GitHub MCP? Requires Docker + a `GITHUB_PERSONAL_ACCESS_TOKEN`."*
248
+ - YES → collect token → write Docker config:
249
+ ```json
250
+ "github": {
251
+ "command": "docker",
252
+ "args": ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
253
+ "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "<token>" }
254
+ }
255
+ ```
256
+ - NO → show snippet + `npx morph-spec mcp setup github`
257
+
258
+ **Vercel detected** (vercel.json exists OR stack is nextjs):
259
+ > *"Configure Vercel MCP? Uses OAuth — no credentials needed."*
260
+ - YES → write remote config:
261
+ ```json
262
+ "vercel": { "type": "http", "url": "https://mcp.vercel.com" }
263
+ ```
264
+ - NO → show snippet + `npx morph-spec mcp setup vercel`
246
265
 
247
- Only offer Figma, Docker, Azure if explicitly detected in `.env.example`.
266
+ Only offer Docker, Azure if explicitly detected in `.env.example`.
248
267
 
249
- > **Format rule:** Always write MCP entries with `"command": "cmd"` and `"/c"` as the **first element of `"args"`**:
268
+ > **Format rules for MCP configs:**
269
+ >
270
+ > **Remote MCPs** (Supabase, Vercel) — no credentials, OAuth-based:
271
+ > ```json
272
+ > "mcp-name": { "type": "http", "url": "https://mcp.example.com" }
273
+ > ```
274
+ >
275
+ > **Stdio MCPs** (Context7, Playwright) — local process with `cmd /c` on Windows:
250
276
  > ```json
251
277
  > "mcp-name": {
252
278
  > "command": "cmd",
@@ -254,11 +280,79 @@ Only offer Figma, Docker, Azure if explicitly detected in `.env.example`.
254
280
  > "env": { "KEY": "VALUE" }
255
281
  > }
256
282
  > ```
283
+ >
284
+ > **Docker MCPs** (GitHub) — Docker container:
285
+ > ```json
286
+ > "mcp-name": {
287
+ > "command": "docker",
288
+ > "args": ["run", "-i", "--rm", "-e", "TOKEN_VAR", "ghcr.io/org/image"],
289
+ > "env": { "TOKEN_VAR": "<value>" }
290
+ > }
291
+ > ```
292
+ >
257
293
  > **Never** use `"command": "cmd /c"` (space-separated string) — that is invalid and will fail.
258
294
  > **Never** use `"command": "npx"` directly — it also fails on Windows without `cmd`.
259
295
 
260
296
  ---
261
297
 
298
+ ## Step 7.5 — Validate MCP Connections
299
+
300
+ For each MCP configured in Step 7, run a health check to verify it actually works.
301
+
302
+ **Read the registry:** `framework/skills/level-0-meta/mcp-registry.json` → for each configured MCP, get its `healthCheck` object.
303
+
304
+ **For each configured MCP:**
305
+
306
+ 1. **Find available tool:** Search your available tools for one matching `healthCheck.toolPattern` (substring match — e.g., tool name contains "context7")
307
+ 2. **If tool found → execute the test call:** Follow `healthCheck.testCall` using `healthCheck.testParams`
308
+ 3. **Evaluate result:**
309
+
310
+ | Result | Action |
311
+ |--------|--------|
312
+ | **Success** (matches `healthCheck.successIndicator`) | Print `✓ {MCP} — connection verified` |
313
+ | **Tool not found** (no tool matching `toolPattern`) | Print `○ {MCP} — needs restart to activate` (MCP configured but tools not yet loaded) |
314
+ | **Error** (tool found but call fails) | → **AskUserQuestion** (see below) |
315
+
316
+ **On error — ask user with 3 options:**
317
+
318
+ Use `AskUserQuestion` with header `"{MCP} failed"` and these options:
319
+ - **Reconfigure credentials** — Loop back to Step 7 for this specific MCP. Maximum 2 retries per MCP. After 2 failures, force option 2.
320
+ - **Continue without {MCP}** — Show the `fallback` field from the registry (e.g., "WebSearch + WebFetch for library documentation") and proceed.
321
+ - **Stop init** — Abort initialization. User must fix MCP configuration manually and re-run `/morph:init`.
322
+
323
+ **Retry tracking:** Keep a counter per MCP. On the 2nd failure for the same MCP, skip the "Reconfigure" option and only offer "Continue without" or "Stop".
324
+
325
+ ---
326
+
327
+ ## Step 7.7 — Run Doctor
328
+
329
+ After all configuration is complete, run the health check to verify everything is properly installed:
330
+
331
+ ```bash
332
+ npx morph-spec doctor
333
+ ```
334
+
335
+ This validates: config.json integrity, agents.json presence, hooks installation, skills distribution, required command files, and state.json schema version. Fix any reported issues before proceeding.
336
+
337
+ ---
338
+
339
+ ## Step 7.8 — Workflow Selection
340
+
341
+ If the project stack suggests a non-standard workflow, ask the user:
342
+
343
+ | Stack | Default Workflow | Alternative |
344
+ |-------|-----------------|-------------|
345
+ | Node.js CLI (no UI) | `nodejs-cli` (skips uiux/clarify/sync) | `standard` |
346
+ | .NET + Blazor | `standard` (all phases) | — |
347
+ | Next.js | `standard` (all phases) | — |
348
+
349
+ For Node.js CLI projects, update config:
350
+ ```json
351
+ { "workflow": "nodejs-cli" }
352
+ ```
353
+
354
+ ---
355
+
262
356
  ## Step 8 — Final Output
263
357
 
264
358
  Before printing the summary, check `~/.claude/settings.local.json` for `env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`. If set to `"1"`, mark Agent Teams as enabled; otherwise show the warning.
@@ -271,7 +365,7 @@ Before printing the summary, check `~/.claude/settings.local.json` for `env.CLAU
271
365
  ✓ config.json updated
272
366
  Stack: [stack] | Architecture: [architecture]
273
367
  Integrations: [list]
274
- ✓ MCPs: [configured list]
368
+ ✓ MCPs: [configured list] ([N verified] / [M needs restart] / [K failed])
275
369
 
276
370
  [If CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = "1":]
277
371
  ✓ Agent Teams: enabled
@@ -0,0 +1,362 @@
1
+ ---
2
+ name: morph:post-implementation
3
+ description: Orchestrates the complete post-implementation flow: stack detection,
4
+ automated scans (C#/Next.js), tests, validate-feature, smoke test via Playwright
5
+ (mandatory if dev server active), code review checklist by stack, checkpoint, and
6
+ recap generation. Use after completing all tasks.
7
+ argument-hint: "[feature-name]"
8
+ user-invocable: true
9
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Task, AskUserQuestion,
10
+ mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot,
11
+ mcp__playwright__browser_take_screenshot, mcp__playwright__browser_console_messages
12
+ ---
13
+
14
+ # Post-Implementation Review
15
+
16
+ > Post-implementation orchestrator: runs all checks in logical sequence and blocks on failure.
17
+ > Use after completing all implementation tasks, before creating the PR.
18
+
19
+ ---
20
+
21
+ ## Prerequisites
22
+
23
+ - All tasks marked as done (`morph-spec task done`)
24
+ - Project build compiling without errors
25
+
26
+ ---
27
+
28
+ ## Step 1 — Detect Stack
29
+
30
+ ```bash
31
+ node .claude/skills/morph-post-implementation/scripts/detect-stack.mjs
32
+ ```
33
+
34
+ Output JSON: `{ stack: "DOTNET" | "NEXTJS" | "FULLSTACK" | "UNKNOWN", frontendPath, backendPath, startCommand }`
35
+
36
+ Priority order (most reliable first):
37
+ 1. `.morph/config/config.json` → `config.project.stack` + `frontendPath`/`backendPath`
38
+ 2. `.morph/context/README.md` → section `## Tech Stack`
39
+ 3. Fallback: Glob for `*.csproj` and `package.json` with dep `"next"`
40
+
41
+ Store the result — all following steps depend on the detected `stack`.
42
+
43
+ ---
44
+
45
+ ## Step 2 — Automated Scans
46
+
47
+ Run automated scans based on detected stack.
48
+
49
+ ### If DOTNET or FULLSTACK:
50
+
51
+ ```bash
52
+ node .claude/skills/morph-code-review/scripts/scan-csharp.mjs --diff
53
+ ```
54
+
55
+ ### If NEXTJS or FULLSTACK:
56
+
57
+ ```bash
58
+ node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff
59
+ ```
60
+
61
+ **🚫 BLOCK if any CRITICAL finding found.**
62
+
63
+ Fix all CRITICALs before continuing. To review the full checklist:
64
+ - .NET: `/morph:code-review`
65
+ - Next.js: `/morph:code-review-nextjs`
66
+
67
+ ---
68
+
69
+ ## Step 3 — Test Suite
70
+
71
+ Run tests based on stack.
72
+
73
+ ### DOTNET:
74
+
75
+ ```bash
76
+ dotnet test --verbosity minimal
77
+ ```
78
+
79
+ ### NEXTJS:
80
+
81
+ ```bash
82
+ npm test -- --watchAll=false
83
+ ```
84
+
85
+ ### FULLSTACK:
86
+
87
+ Run both in parallel (use Task tool with two independent subagents).
88
+
89
+ **🚫 BLOCK if tests fail.**
90
+
91
+ Do not proceed while tests are failing. Fix failures and re-run before continuing.
92
+
93
+ ---
94
+
95
+ ## Step 4 — Framework Validation
96
+
97
+ ```bash
98
+ npx morph-spec validate-feature $ARGUMENTS
99
+ ```
100
+
101
+ **🚫 BLOCK if it fails.**
102
+
103
+ Read validation output, fix reported issues, and re-run until it passes.
104
+
105
+ ---
106
+
107
+ ## Step 5 — Smoke Test (Playwright MCP)
108
+
109
+ ### 5a. Detect Dev Server
110
+
111
+ ```bash
112
+ node .claude/skills/morph-post-implementation/scripts/detect-dev-server.mjs "<startCommand>"
113
+ ```
114
+
115
+ Pass the `startCommand` returned by detect-stack in Step 1.
116
+
117
+ The script:
118
+ 1. Scans ports `[3000, 3001, 4200, 5000, 5001, 7000, 8000, 8080]` with `fetch()` timeout 500ms
119
+ 2. If it finds an active server → returns `{ found: true, url }`
120
+ 3. If not found and `startCommand` provided → tries to start automatically and waits 30s
121
+ 4. Returns exit code 0 (server available) or 1 (not available after attempt)
122
+
123
+ ### 5b. If dev server available (exit 0):
124
+
125
+ **Smoke test is MANDATORY.**
126
+
127
+ 1. Read feature `spec.md` to identify critical happy paths (maximum 3 flows, section Functional Requirements)
128
+ 2. Run the smoke test via Playwright MCP:
129
+
130
+ ```javascript
131
+ // Navigate to the feature
132
+ await mcp__playwright__browser_navigate({ url: '<detected-url>' });
133
+
134
+ // Capture page state
135
+ await mcp__playwright__browser_snapshot();
136
+
137
+ // Check for critical console errors
138
+ await mcp__playwright__browser_console_messages({ level: 'error' });
139
+
140
+ // Screenshot for documentation
141
+ await mcp__playwright__browser_take_screenshot({
142
+ type: 'png',
143
+ filename: '.morph/features/$ARGUMENTS/5-implement/smoke-screenshots/smoke-<timestamp>.png'
144
+ });
145
+ ```
146
+
147
+ For each critical happy path from the spec:
148
+ - Navigate to the flow
149
+ - Verify key elements are visible (`browser_snapshot`)
150
+ - Confirm absence of critical console errors
151
+ - Capture screenshot of final state
152
+
153
+ **Mandatory checks:**
154
+ - [ ] Page loads without 404/500 error
155
+ - [ ] Main feature elements visible (per spec)
156
+ - [ ] Console without critical errors (level: error)
157
+ - [ ] Main happy path functional
158
+
159
+ **🚫 BLOCK if any check fails.** Do not create PR with failing smoke test.
160
+
161
+ ### 5c. If dev server NOT available (exit 1):
162
+
163
+ **⚠️ WARNING: Dev server not found after attempt to start.**
164
+
165
+ Request explicit user confirmation before skipping smoke test:
166
+
167
+ ```
168
+ Dev server not detected on expected port. Smoke test via Playwright is mandatory
169
+ to ensure the code works in the browser before creating the PR.
170
+
171
+ Options:
172
+ 1. Start the server manually (`npm run dev` / `dotnet run`) and re-run /post-implementation
173
+ 2. Explicitly confirm you want to skip the smoke test and why
174
+
175
+ Cannot proceed to PR creation without smoke test or explicit confirmation.
176
+ ```
177
+
178
+ **Wait for response before continuing.**
179
+
180
+ ---
181
+
182
+ ## Step 6 — Code Review Checklist (CRITICAL + HIGH)
183
+
184
+ > Before reviewing, read: `.claude/skills/morph-code-review/references/review-guidelines.md` — apply confidence ≥ 75, ignore pre-existing violations, include file:line in each finding.
185
+
186
+ Review the most important items by stack. For complete review, use the dedicated skills.
187
+
188
+ ### If FULLSTACK:
189
+
190
+ Dispatch two subagents in parallel (Task tool):
191
+
192
+ **Subagent 1 — Backend Review:**
193
+ > .NET focused reviewer. Scope: ONLY changed .cs files (git diff main...HEAD).
194
+ > Run: `node .claude/skills/morph-code-review/scripts/scan-csharp.mjs --diff`
195
+ > Then manually review CRITICAL+HIGH checklist items for .NET.
196
+ > Apply review-guidelines.md: confidence ≥ 75, skip pre-existing.
197
+ > Output: findings with file:line, or "✅ No CRITICAL/HIGH in changed backend."
198
+
199
+ **Subagent 2 — Frontend Review:**
200
+ > Next.js focused reviewer. Scope: ONLY changed .tsx/.ts files (git diff main...HEAD).
201
+ > Run: `node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff`
202
+ > Then manually review CRITICAL+HIGH checklist items for Next.js.
203
+ > Apply review-guidelines.md: confidence ≥ 75, skip pre-existing.
204
+ > Output: findings with file:line, or "✅ No CRITICAL/HIGH in changed frontend."
205
+
206
+ Wait for both. **🚫 BLOCK if either returns unresolved CRITICAL.**
207
+
208
+ ### If DOTNET:
209
+
210
+ **CRITICAL and HIGH items — .NET:**
211
+
212
+ ```
213
+ [ ] CancellationToken propagated through the entire async chain
214
+ [ ] No .Result / .Wait() (deadlock risk)
215
+ [ ] Domain has zero refs to Infrastructure or Web
216
+ [ ] No circular dependencies
217
+ [ ] No empty catch blocks
218
+ [ ] Background ops use IDbContextFactory + await using
219
+ [ ] Async methods have Async suffix
220
+ [ ] Interfaces prefixed with I
221
+ [ ] No classes > 300 lines
222
+ [ ] DTOs with descriptive names + correct types
223
+ ```
224
+
225
+ > For full list: `/morph:code-review`
226
+
227
+ ### If NEXTJS:
228
+
229
+ **CRITICAL and HIGH items — Next.js:**
230
+
231
+ ```
232
+ [ ] node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs --diff → 0 CRITICAL
233
+ [ ] File names in kebab-case (user-card.tsx, not UserCard.tsx)
234
+ [ ] 'use client' only in components with hooks/event handlers
235
+ [ ] No useEffect for data fetching → Server Component or useQuery
236
+ [ ] Zod schema defined first, type derived with z.infer<>
237
+ [ ] zodResolver connected to useForm, useMutation for submit
238
+ [ ] Query key factory used (userKeys.lists(), not ['users'])
239
+ [ ] Feature public API via features/{name}/index.ts
240
+ [ ] components/ui/ untouched (shadcn CLI only)
241
+ [ ] No any type annotation
242
+ ```
243
+
244
+ > For full list: `/morph:code-review-nextjs`
245
+
246
+ **🚫 BLOCK if any CRITICAL item is unresolved.**
247
+
248
+ ---
249
+
250
+ ## Step 7 — Checkpoint + Recap
251
+
252
+ ```bash
253
+ # Save post-review checkpoint
254
+ npx morph-spec checkpoint-save $ARGUMENTS --note "post-implementation review"
255
+
256
+ # Generate final recap
257
+ npx morph-spec generate recap $ARGUMENTS
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Step 8 — Finish Worktree
263
+
264
+ Implementation is complete. If the feature was developed in a morph worktree, finalize it now.
265
+
266
+ **Check if a worktree exists:**
267
+ ```bash
268
+ git worktree list | grep morph/
269
+ ```
270
+
271
+ **If a `morph/{feature}` worktree exists:**
272
+
273
+ Invoke the finishing-a-development-branch skill:
274
+ ```
275
+ Skill(superpowers:finishing-a-development-branch)
276
+ ```
277
+
278
+ This skill will:
279
+ 1. Verify tests pass
280
+ 2. Present 4 options:
281
+ - **Merge locally** → merge into base branch + delete worktree
282
+ - **Push and create PR** → push branch + create GitHub PR (keeps worktree)
283
+ - **Keep as-is** → no action (worktree preserved for later)
284
+ - **Discard** → delete branch + worktree (requires typed confirmation)
285
+ 3. Clean up worktree for options 1 and 4
286
+
287
+ **If NOT in a worktree** (legacy mode): skip this step and proceed to Step 9.
288
+
289
+ > **Note:** If the `superpowers` plugin is not installed, create the PR manually:
290
+ > `gh pr create --title "feat({feature}): <description>" --body "..."`
291
+
292
+ ---
293
+
294
+ ## Step 9 — Pre-PR Compliance Checklist
295
+
296
+ Before creating the PR, invoke the compliance checklist:
297
+
298
+ ```
299
+ Skill(morph:checklist)
300
+ ```
301
+
302
+ This skill checks: security, SEO, performance, accessibility, and LGPD compliance.
303
+ **🚫 BLOCK if any CRITICAL item is unresolved.**
304
+
305
+ ---
306
+
307
+ ## Step 10 — PR Suggestion
308
+
309
+ When all steps pass, suggest the PR:
310
+
311
+ ```bash
312
+ gh pr create \
313
+ --title "feat($ARGUMENTS): <concise feature description>" \
314
+ --body "$(cat <<'EOF'
315
+ ## Summary
316
+
317
+ - <main implemented changes>
318
+ - <completed tasks>
319
+
320
+ ## Test Results
321
+
322
+ - Build: ✅ passed
323
+ - Tests: ✅ X tests passing
324
+ - Smoke Test: ✅ happy path verified via Playwright
325
+
326
+ ## Screenshots
327
+
328
+ <!-- Paste screenshot paths saved in smoke-screenshots/ -->
329
+
330
+ ## Checklist
331
+
332
+ - [ ] Automated scans: 0 CRITICAL findings
333
+ - [ ] All tests passing
334
+ - [ ] Smoke test via Playwright: ✅
335
+ - [ ] Code review checklist: CRITICAL + HIGH items verified
336
+ - [ ] validate-feature: ✅ passed
337
+ - [ ] Checkpoint saved
338
+ - [ ] recap.md generated
339
+ EOF
340
+ )"
341
+ ```
342
+
343
+ ---
344
+
345
+ ## Block Summary
346
+
347
+ | Step | Block Condition |
348
+ |------|-----------------|
349
+ | Step 2 | Any CRITICAL finding in automated scans |
350
+ | Step 3 | Any test failing |
351
+ | Step 4 | `validate-feature` failing |
352
+ | Step 5 | Dev server active + smoke test failing |
353
+ | Step 5 | Dev server not detected without explicit user confirmation |
354
+ | Step 6 | Any unresolved CRITICAL item in manual checklist |
355
+ | Step 8 | Tests failing in worktree before merge/PR |
356
+ | Step 9 | Unresolved CRITICAL item in `morph:checklist` |
357
+
358
+ **All BLOCKs must be resolved before creating the PR.**
359
+
360
+ ---
361
+
362
+ *MORPH-SPEC by Polymorphism Tech*