@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,439 +0,0 @@
1
- # infra-architect Refactor Implementation Plan
2
-
3
- **Status:** COMPLETE
4
-
5
- > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
6
-
7
- **Goal:** Introduce a cloud-agnostic `infra-architect` tier-2 squad leader, demote `azure-architect` to tier-3 specialist, and update all references so non-Azure projects aren't burdened with an always-active Azure agent.
8
-
9
- **Architecture:** Add a new `infra-architect` agent (tier 2, always_active: true) that owns infrastructure coordination regardless of cloud provider. `azure-architect` becomes a tier-3 specialist under it (always_active: false), activated only when Azure infra work is needed. `bicep-architect` stays tier-3 (already always_active: false... wait, it IS true — fix that too).
10
-
11
- **Tech Stack:** Node.js/ESM, `framework/agents.json`, `.claude/agents/`, `src/lib/standards/standards-context-injector.js`, `test/utils/agents-installer.test.js`
12
-
13
- ---
14
-
15
- ## Scope Summary
16
-
17
- | File | Action |
18
- |------|--------|
19
- | `framework/agents.json` | Add `infra-architect` (tier-2), demote `azure-architect` (tier-3), fix `bicep-architect` always_active, update refs, update counts |
20
- | `framework/agents/infrastructure/infra-architect.md` | CREATE cloud-agnostic squad leader spec |
21
- | `framework/agents/infrastructure/azure-architect.md` | Remove "always active Core Agent" trigger text |
22
- | `framework/agents/README.md` | Update squad leader reference |
23
- | `.claude/agents/morph-azure-architect.md` | DELETE (no longer tier-2, installAgents won't generate it) |
24
- | `.claude/agents/morph-infra-architect.md` | CREATE new squad leader agent file |
25
- | `src/lib/standards/standards-context-injector.js` | Add `infra-architect` entry, keep `azure-architect` entry |
26
- | `test/utils/agents-installer.test.js` | Replace `morph-azure-architect.md` check → `morph-infra-architect.md` |
27
-
28
- ---
29
-
30
- ### Task 1: Update `framework/agents.json` — add infra-architect, demote azure-architect
31
-
32
- **Files:**
33
- - Modify: `framework/agents.json`
34
-
35
- **Step 1: Add the `infra-architect` agent entry in the tier-2 section (after `dotnet-senior`, before `azure-architect` current slot)**
36
-
37
- Insert before the `"azure-architect"` key:
38
-
39
- ```json
40
- "infra-architect": {
41
- "tier": 2,
42
- "role": "domain-leader",
43
- "title": "Infrastructure Squad Leader",
44
- "domains": ["infrastructure"],
45
- "keywords": ["infrastructure", "infra", "cloud", "deployment", "hosting", "ci/cd", "container", "iac", "pipeline"],
46
- "always_active": true,
47
- "validators": ["architecture"],
48
- "relationships": {
49
- "reports_to": "standards-architect",
50
- "coordinates": ["azure-architect", "bicep-architect", "devops-engineer", "container-specialist", "observability-expert", "azure-identity"],
51
- "escalates_to": "standards-architect",
52
- "collaborates_with": ["dotnet-senior", "ui-designer"],
53
- "team_role": "domain_leader"
54
- },
55
- "standards": ["core/coding.md", "core/architecture.md"],
56
- "teammate": {
57
- "role": "Infrastructure Squad Leader",
58
- "icon": "🏗️",
59
- "spawn_prompt": "You are the Infrastructure Squad Leader. Coordinate infra specialists regardless of cloud provider (azure-architect, devops-engineer, container-specialist, observability-expert). Focus on IaC, CI/CD, containerization, cost optimization. Delegate to azure-architect for Azure-specific work. Escalate to standards-architect on conflicts."
60
- }
61
- },
62
- ```
63
-
64
- **Step 2: Demote `azure-architect` from tier-2 to tier-3**
65
-
66
- In the `azure-architect` entry change:
67
- - `"tier": 2` → `"tier": 3`
68
- - `"role": "domain-leader"` → `"role": "specialist"`
69
- - `"always_active": true` → `"always_active": false`
70
- - `"relationships.reports_to": "standards-architect"` → `"infra-architect"`
71
- - `"relationships.escalates_to": "standards-architect"` → `"infra-architect"`
72
- - Remove `"collaborates_with": ["dotnet-senior", "blazor-builder", "nextjs-expert"]` (now a specialist, not a leader)
73
- - Remove `"team_role": "domain_leader"` → `"team_role": "specialist"`
74
- - Add `"collaborates_with": ["bicep-architect", "devops-engineer", "container-specialist"]`
75
-
76
- **Step 3: Fix `bicep-architect` — set `always_active: false`**
77
-
78
- `bicep-architect` is currently `always_active: true`, which is wrong (it's Azure Bicep-specific). Change to `false`.
79
-
80
- **Step 4: Update tier counts and cross-references**
81
-
82
- - `"total_agents": 37` → `38` (infra-architect is new)
83
- - `"tier_2_leaders": 3` stays at `3` (azure-architect leaves, infra-architect joins — net zero)
84
- - `"tier_3_specialists": 26` → `27` (azure-architect joins tier-3)
85
- - `standards-architect.relationships.coordinates`: replace `"azure-architect"` → `"infra-architect"`
86
- - `dotnet-senior.relationships.collaborates_with`: replace `"azure-architect"` → `"infra-architect"`
87
- - `event-architect.relationships.collaborates_with`: replace `"azure-architect"` → `"infra-architect"`
88
- - `nosql-cache-expert.relationships.collaborates_with`: check and replace `"azure-architect"` → `"infra-architect"` if present
89
- - `blazor-builder.relationships.collaborates_with`: replace `"azure-architect"` → `"infra-architect"` if present
90
- - `nextjs-expert.relationships.collaborates_with`: replace `"azure-architect"` → `"infra-architect"` if present
91
- - `hangfire-orchestrator.relationships.collaborates_with`: replace `"azure-architect"` → `"infra-architect"` if present
92
- - `devops-engineer`, `container-specialist`, `observability-expert`, `azure-identity`: change `reports_to`/`escalates_to` from `"azure-architect"` → stays as `"azure-architect"` IF they are Azure-specific; OR change to `"infra-architect"` since the squad leader is now `infra-architect`
93
- - Decision: `devops-engineer`, `container-specialist`, `observability-expert`, `azure-identity` are still sub-specialties that `azure-architect` may coordinate. But the squad leader is `infra-architect`. Change their `reports_to`/`escalates_to` → `"infra-architect"`.
94
- - `bicep-architect` stays `reports_to: "azure-architect"` (Bicep is Azure-specific, azure-architect coordinates it)
95
-
96
- **Step 5: Validate JSON is well-formed**
97
-
98
- Run: `node -e "JSON.parse(require('fs').readFileSync('framework/agents.json','utf8')); console.log('OK')"`
99
- Expected: `OK`
100
-
101
- **Step 6: Verify counts**
102
-
103
- Run: `node -e "const d=JSON.parse(require('fs').readFileSync('framework/agents.json','utf8')); const agents=Object.entries(d.agents).filter(([k])=>!k.startsWith('_comment')); const t2=agents.filter(([,v])=>v.tier===2); const t3=agents.filter(([,v])=>v.tier===3); console.log('total',agents.length,'t2',t2.length,'t3',t3.length,'always_active',agents.filter(([,v])=>v.always_active).map(([k])=>k).join(','));"`
104
-
105
- Expected: `total 38 t2 3 t3 27 always_active standards-architect,dotnet-senior,infra-architect,...` (azure-architect and bicep-architect should NOT be in the always_active list)
106
-
107
- **Step 7: Commit**
108
-
109
- ```bash
110
- git add framework/agents.json
111
- git commit -m "refactor(agents): introduce infra-architect tier-2 squad leader, demote azure-architect to tier-3 specialist"
112
- ```
113
-
114
- ---
115
-
116
- ### Task 2: Create `framework/agents/infrastructure/infra-architect.md`
117
-
118
- **Files:**
119
- - Create: `framework/agents/infrastructure/infra-architect.md`
120
-
121
- **Step 1: Write the new agent spec file**
122
-
123
- ```markdown
124
- ---
125
- name: infra-architect
126
- description: Infrastructure Squad Leader for cloud-agnostic infrastructure coordination. Use when planning deployments, provisioning any cloud resources, setting up CI/CD pipelines, containerizing applications, or designing infrastructure architecture regardless of cloud provider.
127
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep
128
- ---
129
-
130
- # Infrastructure Squad Leader
131
-
132
- Cloud-agnostic infrastructure coordinator. Delegates to cloud-specific specialists.
133
-
134
- ## Responsabilidades
135
-
136
- 1. **Coordenar especialistas de infra** (azure-architect, devops-engineer, container-specialist, observability-expert)
137
- 2. **Decidir stack de infra** com base no config do projeto (cloud: azure | aws | gcp | self-hosted)
138
- 3. **Garantir IaC** — tudo via código, nada manual
139
- 4. **CI/CD** — pipelines para todos os ambientes
140
-
141
- ## Quando ativar sub-especialistas
142
-
143
- | Cenário | Especialista |
144
- |---------|-------------|
145
- | Deploy em Azure | azure-architect |
146
- | Templates Bicep | bicep-architect (via azure-architect) |
147
- | Pipelines CI/CD | devops-engineer |
148
- | Docker / containers | container-specialist |
149
- | Logs / métricas | observability-expert |
150
- | Auth Microsoft/Entra | azure-identity |
151
-
152
- ## Princípio: Infrastructure as Code
153
-
154
- > Nunca criar recursos de infra manualmente. Toda infra via código (Bicep, Terraform, Pulumi, Compose).
155
-
156
- ## Checklist de Infra
157
-
158
- - [ ] Cloud provider definido em config.json
159
- - [ ] IaC templates criados e validados
160
- - [ ] Ambientes dev/staging/prod separados
161
- - [ ] Secrets nunca hardcoded
162
- - [ ] CI/CD pipeline configurado
163
- - [ ] Observability básica (logs + métricas)
164
- - [ ] Estimativa de custos documentada
165
-
166
- ---
167
-
168
- *MORPH-SPEC by Polymorphism Tech*
169
- ```
170
-
171
- **Step 2: Commit**
172
-
173
- ```bash
174
- git add framework/agents/infrastructure/infra-architect.md
175
- git commit -m "feat(agents): add infra-architect cloud-agnostic squad leader spec"
176
- ```
177
-
178
- ---
179
-
180
- ### Task 3: Update `framework/agents/infrastructure/azure-architect.md`
181
-
182
- **Files:**
183
- - Modify: `framework/agents/infrastructure/azure-architect.md`
184
-
185
- **Step 1: Remove "always active" claim from Triggers section**
186
-
187
- Find and replace:
188
- ```
189
- ## Triggers
190
-
191
- Ativado automaticamente em todo projeto MORPH-SPEC (Core Agent).
192
- ```
193
-
194
- ```
195
- ## Triggers
196
-
197
- Ativado quando o projeto usa Azure como provedor de cloud. Coordenado pelo `infra-architect`.
198
- ```
199
-
200
- **Step 2: Verify the file looks correct**
201
-
202
- Read the file and confirm the Triggers section no longer claims it's always-on.
203
-
204
- **Step 3: Commit**
205
-
206
- ```bash
207
- git add framework/agents/infrastructure/azure-architect.md
208
- git commit -m "fix(agents): azure-architect is no longer always-active, ativado apenas em projetos Azure"
209
- ```
210
-
211
- ---
212
-
213
- ### Task 4: Update `framework/agents/README.md`
214
-
215
- **Files:**
216
- - Modify: `framework/agents/README.md`
217
-
218
- **Step 1: Update squad leader reference**
219
-
220
- Change:
221
- ```
222
- - infrastructure/ - Infrastructure Squad (led by azure-architect)
223
- ```
224
-
225
- ```
226
- - infrastructure/ - Infrastructure Squad (led by infra-architect)
227
- ```
228
-
229
- **Step 2: Commit**
230
-
231
- ```bash
232
- git add framework/agents/README.md
233
- git commit -m "docs(agents): update infra squad leader reference to infra-architect"
234
- ```
235
-
236
- ---
237
-
238
- ### Task 5: Update `.claude/agents/` installed agent files
239
-
240
- **Files:**
241
- - Delete: `.claude/agents/morph-azure-architect.md`
242
- - Create: `.claude/agents/morph-infra-architect.md`
243
-
244
- **Step 1: Delete the old tier-2 azure-architect agent file**
245
-
246
- `azure-architect` is no longer tier-2, so `installAgents()` won't generate `morph-azure-architect.md`. Delete the stale file.
247
-
248
- ```bash
249
- rm ".claude/agents/morph-azure-architect.md"
250
- ```
251
-
252
- **Step 2: Create the new infra-architect agent file**
253
-
254
- ```markdown
255
- ---
256
- name: Infrastructure Squad Leader
257
- description: Infrastructure Squad Leader
258
- model: inherit
259
- tools: Read, Grep, Glob, Bash
260
- maxTurns: 20
261
- skills:
262
- - morph-checklist
263
- memory: local
264
- ---
265
-
266
- You are the Infrastructure Squad Leader. Coordinate infra specialists regardless of cloud provider (azure-architect, devops-engineer, container-specialist, observability-expert). Focus on IaC, CI/CD, containerization, and cost optimization. Delegate to azure-architect for Azure-specific work. Escalate to standards-architect on conflicts.
267
-
268
- ## Standards to Reference
269
- - core/coding.md
270
- - core/architecture.md
271
- ```
272
-
273
- **Step 3: Verify the correct files exist**
274
-
275
- Run: `ls ".claude/agents/" | grep -E "morph-(infra|azure)" `
276
- Expected: `morph-domain-azure-architect.md`, `morph-infra-architect.md` — no `morph-azure-architect.md`
277
-
278
- **Step 4: Commit**
279
-
280
- ```bash
281
- git add ".claude/agents/morph-infra-architect.md"
282
- git rm ".claude/agents/morph-azure-architect.md"
283
- git commit -m "fix(agents): replace morph-azure-architect with morph-infra-architect as tier-2 squad leader"
284
- ```
285
-
286
- ---
287
-
288
- ### Task 6: Update `src/lib/standards/standards-context-injector.js`
289
-
290
- **Files:**
291
- - Modify: `src/lib/standards/standards-context-injector.js:47`
292
-
293
- **Step 1: Add `infra-architect` entry and rename existing entry**
294
-
295
- The current entry at line 47:
296
- ```js
297
- 'azure-architect': [
298
- 'infrastructure/azure/azure', // Stack-specific
299
- 'core/architecture',
300
- 'backend/dotnet/core'
301
- ],
302
- ```
303
-
304
- **After** the `ui-designer` entry (end of tier-2 section), add:
305
- ```js
306
- 'infra-architect': [
307
- 'core/architecture',
308
- 'core/coding'
309
- ],
310
- ```
311
-
312
- Keep the existing `'azure-architect'` entry as-is (it's now a tier-3 specialist entry, still valid).
313
-
314
- **Step 2: Add a comment clarifying the section**
315
-
316
- Above `'azure-architect'`: add `// Tier 3: Specialists - Infrastructure Squad`
317
-
318
- **Step 3: Verify no syntax errors**
319
-
320
- Run: `node -e "require('./src/lib/standards/standards-context-injector.js'); console.log('OK')"`
321
- Expected: `OK`
322
-
323
- **Step 4: Commit**
324
-
325
- ```bash
326
- git add src/lib/standards/standards-context-injector.js
327
- git commit -m "feat(standards): add infra-architect to standards context injector"
328
- ```
329
-
330
- ---
331
-
332
- ### Task 7: Update `test/utils/agents-installer.test.js`
333
-
334
- **Files:**
335
- - Modify: `test/utils/agents-installer.test.js`
336
-
337
- **Step 1: Find and update the tier-2 file check**
338
-
339
- Current (around line 101-105):
340
- ```js
341
- // Find a tier-2 file (dotnet-senior, azure-architect, or ui-designer)
342
- ...
343
- f === 'morph-azure-architect.md' ||
344
- ```
345
-
346
- Change `morph-azure-architect.md` → `morph-infra-architect.md`
347
-
348
- **Step 2: Run the test suite to verify**
349
-
350
- Run: `node --test test/utils/agents-installer.test.js`
351
- Expected: All tests pass (no failures)
352
-
353
- **Step 3: Run the full test suite**
354
-
355
- Run: `npm test`
356
- Expected: Same pass count as before (or +0 failures)
357
-
358
- **Step 4: Commit**
359
-
360
- ```bash
361
- git add test/utils/agents-installer.test.js
362
- git commit -m "test(agents-installer): update tier-2 file check to morph-infra-architect"
363
- ```
364
-
365
- ---
366
-
367
- ### Task 8: Update agents-installer.js to regenerate correctly
368
-
369
- **Files:**
370
- - Modify: `src/utils/agents-installer.js` (only if the installer hardcodes azure-architect anywhere)
371
-
372
- **Step 1: Check for hardcoded references**
373
-
374
- Run: `grep -n "azure-architect\|infra-architect" src/utils/agents-installer.js`
375
-
376
- If only data-driven (reads from agents.json) — no changes needed.
377
- If hardcoded references exist — update them to use `infra-architect`.
378
-
379
- **Step 2: Verify installAgents() generates the right files by dry-running**
380
-
381
- Run: `node -e "
382
- const {installAgents} = require('./src/utils/agents-installer.js');
383
- const path = require('path');
384
- const os = require('os');
385
- const tmp = require('fs').mkdtempSync(path.join(os.tmpdir(), 'morph-test-'));
386
- installAgents(process.cwd(), tmp).then(r => { console.log(r.installed); require('fs').rmdirSync(tmp, {recursive:true}); });
387
- "`
388
- Expected: Output includes `morph-infra-architect` but NOT `morph-azure-architect` in the tier-1/2 installed list.
389
-
390
- **Step 3: Commit if changes were needed**
391
-
392
- ```bash
393
- git add src/utils/agents-installer.js
394
- git commit -m "fix(agents-installer): update hardcoded azure-architect references if present"
395
- ```
396
-
397
- ---
398
-
399
- ### Task 9: Final verification
400
-
401
- **Step 1: Run the full test suite**
402
-
403
- Run: `npm test`
404
- Expected: All previously passing tests still pass. No new failures.
405
-
406
- **Step 2: Verify always_active agents are correct**
407
-
408
- Run: `node -e "
409
- const d = JSON.parse(require('fs').readFileSync('framework/agents.json', 'utf8'));
410
- const always = Object.entries(d.agents)
411
- .filter(([k, v]) => !k.startsWith('_comment') && v.always_active)
412
- .map(([k, v]) => k + ' (tier ' + v.tier + ')');
413
- console.log('Always active:', always.join(', '));
414
- "`
415
- Expected: `infra-architect` is listed, `azure-architect` and `bicep-architect` are NOT listed.
416
-
417
- **Step 3: Final commit (version bump if needed)**
418
-
419
- The change is a `refactor` — no version bump required unless maintainer decides otherwise.
420
-
421
- ```bash
422
- git log --oneline -8
423
- ```
424
-
425
- ---
426
-
427
- ## Files Changed Summary
428
-
429
- | File | Type |
430
- |------|------|
431
- | `framework/agents.json` | Modified |
432
- | `framework/agents/infrastructure/infra-architect.md` | Created |
433
- | `framework/agents/infrastructure/azure-architect.md` | Modified |
434
- | `framework/agents/README.md` | Modified |
435
- | `.claude/agents/morph-azure-architect.md` | Deleted |
436
- | `.claude/agents/morph-infra-architect.md` | Created |
437
- | `src/lib/standards/standards-context-injector.js` | Modified |
438
- | `test/utils/agents-installer.test.js` | Modified |
439
- | `src/utils/agents-installer.js` | Modified only if hardcoded refs found |
@@ -1,157 +0,0 @@
1
- # Next.js Code Review & Scan — Design Doc
2
-
3
- **Status:** COMPLETE (see implementation plan)
4
-
5
- > **Date:** 2026-02-23
6
- > **Approach:** Approach 1 — Trio completo (wire + scan script + skill)
7
-
8
- ---
9
-
10
- ## Problem
11
-
12
- The MORPH-SPEC framework has a two-layer validation architecture for .NET/Blazor (programmatic validators + `code-review` skill) but Next.js is severely under-covered:
13
-
14
- - `nextjs-expert.validators = ["packages"]` — only 1 validator; blazor-builder has 6
15
- - `next-component-validator.js` was created but **never wired** into agents.json
16
- - No `code-review-nextjs` skill exists
17
- - `scripts/scan-csharp.mjs` referenced in `code-review` skill but doesn't exist
18
- - The `scan-nextjs.mjs` would be the **first scan script** in the framework
19
-
20
- ## Design
21
-
22
- ### Three layers (full parity with intended .NET design)
23
-
24
- ```
25
- Layer 1 (auto) agents.json → validation-runner.js → validators/*.js
26
- Layer 2 (CLI) scripts/scan-nextjs.mjs → validateNextComponent() + additional checks
27
- Layer 3 (LLM) code-review-nextjs skill → scan script first, then manual checklist
28
- ```
29
-
30
- ---
31
-
32
- ## Layer 1: Wire `nextjs-component` validator
33
-
34
- **Change:** `agents.json` — `nextjs-expert.validators`
35
-
36
- ```json
37
- // Before
38
- "validators": ["packages"]
39
-
40
- // After
41
- "validators": ["packages", "nextjs-component"]
42
- ```
43
-
44
- **Also register** the validator key in `validation-runner.js`'s validator registry so `nextjs-component` maps to `next-component-validator.js`.
45
-
46
- ---
47
-
48
- ## Layer 2: `scripts/scan-nextjs.mjs`
49
-
50
- CLI scan script for CRITICAL/HIGH violation detection before manual review.
51
-
52
- **Interface:**
53
- ```bash
54
- node scripts/scan-nextjs.mjs [path] # defaults to src/
55
- node scripts/scan-nextjs.mjs src/features/ # specific dir
56
- node scripts/scan-nextjs.mjs --json # JSON output for CI
57
- ```
58
-
59
- **What it checks (delegates to `validateNextComponent` + adds):**
60
- 1. `'use client'` without interactivity (warning → HIGH)
61
- 2. React hooks without `'use client'` (error → CRITICAL)
62
- 3. PascalCase `.tsx` file names (warning → HIGH)
63
- 4. `useEffect` used for data fetching (`useEffect(() => { fetch(...)` pattern) → CRITICAL
64
- 5. Default exports on non-special files (should use named exports) → MEDIUM
65
- 6. Deep path imports instead of feature index (`from '@/features/users/components/x'` instead of `from '@/features/users'`) → MEDIUM
66
-
67
- **Output format** (mirrors intended `scan-csharp.mjs` style):
68
- ```
69
- 🔍 Scanning src/ (42 files)...
70
-
71
- CRITICAL (1)
72
- components/UserCard.tsx:1 — React hooks used (useState) without 'use client'
73
-
74
- HIGH (2)
75
- components/UserList.tsx — 'use client' with no interactivity detected
76
- components/UserCard.tsx — PascalCase filename (should be user-card.tsx)
77
-
78
- ✅ No issues found in 39 files
79
-
80
- Summary: 42 files scanned | 3 issues (1 critical, 2 high, 0 medium)
81
- Exit code: 1 (errors found)
82
- ```
83
-
84
- **Exit codes:** `0` = clean, `1` = errors, `2` = scan failed
85
-
86
- ---
87
-
88
- ## Layer 3: `code-review-nextjs` skill
89
-
90
- Skill file: `framework/skills/level-0-meta/code-review-nextjs/SKILL.md`
91
- Reference: `framework/skills/level-0-meta/code-review-nextjs/references/review-example-nextjs.md`
92
-
93
- **Structure mirrors `code-review.md`:**
94
-
95
- 1. Run scan script first (automated CRITICAL/HIGH)
96
- 2. Naming & Style checklist (8 standards ref)
97
- 3. Component Architecture checklist (tier violations, use client discipline)
98
- 4. Data Fetching checklist (TanStack Query v5, no useEffect fetch)
99
- 5. Forms checklist (zodResolver, schema-first, shadcn Form)
100
- 6. State Management checklist (no unnecessary Zustand/Context for server state)
101
- 7. TypeScript checklist (no `any`, z.infer<> usage)
102
- 8. Structure checklist (feature boundary rules, index imports)
103
- 9. Testing checklist (userEvent over fireEvent, MSW over mock fetch)
104
- 10. Quick Pre-Merge Checklist
105
-
106
- **Severity levels:**
107
- - `[CRITICAL]` — breaks app or violates core Next.js rules
108
- - `[HIGH]` — significant pattern violation, reviewer must fix before merge
109
- - `[MEDIUM]` — best practice violation, should fix
110
- - `[LOW]` — style/consistency, nice to fix
111
-
112
- ---
113
-
114
- ## Testing Strategy
115
-
116
- **End-to-end tests using real temp directory user cases** (not mocks):
117
-
118
- ### Test cases for `scan-nextjs.mjs`:
119
- 1. **Clean project** — a `src/` with properly written components → 0 issues, exit 0
120
- 2. **Component with `useState` but no `'use client'`** → CRITICAL finding
121
- 3. **Unnecessary `'use client'`** on static component → HIGH finding
122
- 4. **PascalCase filename** `UserCard.tsx` → HIGH finding
123
- 5. **`useEffect` for fetch** → CRITICAL finding
124
- 6. **Mixed project** — some clean, some violations → correct counts, exit 1
125
- 7. **`--json` flag** → valid JSON output with `{ files, issues, exitCode }`
126
- 8. **Empty directory** → 0 files, exit 0
127
- 9. **Non-existent path** → graceful error, exit 2
128
-
129
- ### Test cases for validation-runner wiring:
130
- 10. **Feature with `nextjs-expert` active** → `nextjs-component` validator runs
131
- 11. **Feature without `nextjs-expert` active** → `nextjs-component` validator doesn't run
132
-
133
- ---
134
-
135
- ## Artifacts
136
-
137
- | File | Type | Notes |
138
- |------|------|-------|
139
- | `framework/agents.json` | Modified | Add `nextjs-component` to validators |
140
- | `src/lib/validators/validation-runner.js` | Modified | Register `nextjs-component` key |
141
- | `scripts/scan-nextjs.mjs` | New | CLI scan script |
142
- | `test/scripts/scan-nextjs.test.mjs` | New | E2E tests with real temp dirs |
143
- | `framework/skills/level-0-meta/code-review-nextjs/SKILL.md` | New | Code review skill |
144
- | `framework/skills/level-0-meta/code-review-nextjs/references/review-example-nextjs.md` | New | Filled review example |
145
- | `.claude/skills/code-review-nextjs.md` | Installed | Via installSkills() |
146
-
147
- ---
148
-
149
- ## Out of Scope
150
-
151
- - `scan-csharp.mjs` — exists conceptually, not implemented. Follow-up task.
152
- - AST-based analysis — regex is sufficient for the current check set
153
- - IDE integration — out of scope for this iteration
154
-
155
- ---
156
-
157
- *MORPH-SPEC by Polymorphism Tech*