@polymorphism-tech/morph-spec 4.18.0 → 4.19.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.
- package/README.md +2 -2
- package/bin/task-manager.js +12 -0
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/agents/architecture/architecture-expert.md +86 -0
- package/framework/agents/architecture/morph-spec-architect.md +66 -0
- package/framework/agents/architecture/packages-validator.md +77 -0
- package/framework/agents/architecture/security-expert.md +67 -0
- package/framework/agents/backend/ms-agent-expert.md +1 -1
- package/framework/agents/frontend/design-system-validator.md +88 -0
- package/framework/agents/frontend/nextjs-component-validator.md +85 -0
- package/framework/agents/frontend/{ui-ux-designer.md → ui-designer.md} +31 -0
- package/framework/agents.json +1 -1
- package/framework/hooks/claude-code/post-tool-use/dispatch.js +39 -0
- package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +78 -44
- package/framework/hooks/claude-code/post-tool-use/loop-detect.js +103 -0
- package/framework/hooks/claude-code/session-start/inject-morph-context.js +21 -2
- package/framework/hooks/claude-code/stop/validate-completion.js +48 -1
- package/framework/hooks/shared/activity-logger.js +56 -1
- package/framework/hooks/shared/build-check.js +79 -0
- package/framework/hooks/shared/payload-utils.js +39 -0
- package/framework/hooks/shared/session-snapshot.js +105 -0
- package/framework/phases.json +1 -1
- package/framework/skills/level-0-meta/mcp-registry.json +34 -1
- package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +11 -1
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +12 -1
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +119 -11
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
- package/framework/standards/ai-agents/production.md +5 -2
- package/framework/standards/ai-agents/setup.md +13 -14
- package/framework/standards/ai-agents/workflows.md +8 -6
- package/framework/standards/backend/database/vector-search-rag.md +1 -1
- package/framework/templates/code/dotnet/jobs/agent.cs +0 -1
- package/package.json +1 -1
- package/src/commands/mcp/mcp-setup.js +21 -0
- package/src/commands/project/init.js +11 -0
- package/src/lib/contracts/sprint-contract-generator.js +137 -0
- package/src/lib/installers/mcp-installer.js +25 -0
- package/src/utils/hooks-installer.js +12 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
|
|
4
4
|
|
|
5
5
|
**Package:** `@polymorphism-tech/morph-spec`
|
|
6
|
-
**Version:** 4.
|
|
6
|
+
**Version:** 4.19.0
|
|
7
7
|
**Requires:** Node.js 18+, Claude Code
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -364,4 +364,4 @@ Code generated by morph-spec (contracts, templates, implementation output) belon
|
|
|
364
364
|
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
-
*morph-spec v4.
|
|
367
|
+
*morph-spec v4.19.0 by [Polymorphism Tech](https://polymorphism.tech)*
|
package/bin/task-manager.js
CHANGED
|
@@ -877,6 +877,18 @@ async function main() {
|
|
|
877
877
|
}
|
|
878
878
|
|
|
879
879
|
await withStateLock(() => manager.startTask(featureName, taskId));
|
|
880
|
+
|
|
881
|
+
// Generate sprint contract for evaluator
|
|
882
|
+
try {
|
|
883
|
+
const { generateSprintContract } = await import('../src/lib/contracts/sprint-contract-generator.js');
|
|
884
|
+
const contract = generateSprintContract(process.cwd(), featureName, taskId);
|
|
885
|
+
if (contract) {
|
|
886
|
+
console.log(chalk.gray(` Sprint contract: .morph/features/${featureName}/5-implement/contracts/${taskId}-contract.yaml`));
|
|
887
|
+
}
|
|
888
|
+
} catch {
|
|
889
|
+
// Non-blocking — contract generation is optional
|
|
890
|
+
}
|
|
891
|
+
|
|
880
892
|
break;
|
|
881
893
|
}
|
|
882
894
|
|
package/claude-plugin.json
CHANGED
package/docs/CHEATSHEET.md
CHANGED
package/docs/QUICKSTART.md
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-expert
|
|
3
|
+
description: Architecture Validator (READ-ONLY Tier 4) that scans .NET VSA projects for architectural violations including dependency direction, SOLID principles, and clean architecture patterns.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
color: gray
|
|
6
|
+
effort: medium
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Architecture Validator
|
|
10
|
+
|
|
11
|
+
READ-ONLY scanner for architectural violations in .NET VSA projects.
|
|
12
|
+
|
|
13
|
+
## Responsibilities
|
|
14
|
+
|
|
15
|
+
1. **Scan all .cs files and Program.cs** for architectural violations
|
|
16
|
+
2. **Validate dependency direction** — Domain must not reference Infrastructure
|
|
17
|
+
3. **Check SOLID compliance** — SRP, DI usage, interface segregation
|
|
18
|
+
4. **Report findings** with severity and location
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Scan Categories
|
|
23
|
+
|
|
24
|
+
### Critical (Severity: Error)
|
|
25
|
+
|
|
26
|
+
| Violation | Signal | Pattern |
|
|
27
|
+
|-----------|--------|---------|
|
|
28
|
+
| Wrong dependency direction | Domain references Infrastructure | `using *.Infrastructure` in Domain/ |
|
|
29
|
+
| Feature cross-references | Feature A imports Feature B directly | `using *.Features.Orders` in Features/Users/ |
|
|
30
|
+
| Missing DI registration | Service instantiated with `new` | `new OrderService()` instead of DI |
|
|
31
|
+
| DbContext in background | Scoped context in Task.Run/Hangfire | `_dbContext` captured in closure |
|
|
32
|
+
|
|
33
|
+
### Warning (Severity: Warning)
|
|
34
|
+
|
|
35
|
+
| Violation | Signal |
|
|
36
|
+
|-----------|--------|
|
|
37
|
+
| Class > 300 lines | SRP violation, needs splitting |
|
|
38
|
+
| Method > 30 lines | Needs extraction |
|
|
39
|
+
| > 4 constructor params | Consider grouping dependencies |
|
|
40
|
+
| Mixed responsibilities | Handler doing validation + persistence + notification |
|
|
41
|
+
| Missing `sealed` | Non-abstract class without `sealed` modifier |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## VSA Structure Validation
|
|
46
|
+
|
|
47
|
+
Expected project structure:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
src/
|
|
51
|
+
├── Features/ # Vertical slices (one folder per use case)
|
|
52
|
+
│ └── {Feature}/
|
|
53
|
+
│ └── {UseCase}/
|
|
54
|
+
│ ├── Endpoint.cs
|
|
55
|
+
│ ├── Handler.cs
|
|
56
|
+
│ ├── Request.cs
|
|
57
|
+
│ └── Response.cs
|
|
58
|
+
├── Infrastructure/ # EF Core, external services
|
|
59
|
+
├── Domain/ # Entities, value objects (no dependencies)
|
|
60
|
+
└── Extensions/ # DI registration, middleware
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Scan Procedure
|
|
66
|
+
|
|
67
|
+
1. **Glob** all `.cs` files
|
|
68
|
+
2. **Grep** for dependency violations (`using` statements)
|
|
69
|
+
3. **Read** Program.cs for DI registration patterns
|
|
70
|
+
4. **Validate** folder structure against VSA conventions
|
|
71
|
+
5. **Report** violations with file, line, type, severity
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Checklist
|
|
76
|
+
|
|
77
|
+
- [ ] Domain project has zero infrastructure references
|
|
78
|
+
- [ ] Features are self-contained vertical slices
|
|
79
|
+
- [ ] All services registered via DI (no `new Service()`)
|
|
80
|
+
- [ ] DbContext not captured in background threads
|
|
81
|
+
- [ ] Classes are `sealed` by default
|
|
82
|
+
- [ ] No circular dependencies between features
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: morph-spec-architect
|
|
3
|
+
description: Morph-Spec Architect that designs new features for the morph-spec-framework CLI tool itself. Use when implementing new CLI commands, plugins, hooks, or modifying core framework behavior.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
5
|
+
color: cyan
|
|
6
|
+
effort: medium
|
|
7
|
+
permissionMode: acceptEdits
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Morph-Spec Architect
|
|
11
|
+
|
|
12
|
+
Designs new features for the morph-spec-framework CLI tool. Understands the full module layout, Commander.js commands, and the dual-layer phase tracking architecture.
|
|
13
|
+
|
|
14
|
+
## Responsibilities
|
|
15
|
+
|
|
16
|
+
1. **Design new CLI commands** — analyze existing commands in `bin/morph-spec.js` and `src/commands/`
|
|
17
|
+
2. **Identify reusable modules** — leverage `src/core/`, `src/lib/`, `src/utils/` before writing new code
|
|
18
|
+
3. **Maintain architectural consistency** — ESM modules, atomic state writes, data-driven validation
|
|
19
|
+
4. **Hook design** — fail-open hooks in `framework/hooks/claude-code/`
|
|
20
|
+
5. **Output schema evolution** — extend `src/core/paths/output-schema.js` when adding new output types
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Key Architecture
|
|
25
|
+
|
|
26
|
+
### Module Layout
|
|
27
|
+
|
|
28
|
+
| Layer | Path | Purpose |
|
|
29
|
+
|-------|------|---------|
|
|
30
|
+
| CLI entry | `bin/morph-spec.js` | Commander.js command registration |
|
|
31
|
+
| Commands | `src/commands/` | Thin CLI wrappers (delegate to core/lib) |
|
|
32
|
+
| Core | `src/core/` | Domain logic (state, paths, templates, workflows) |
|
|
33
|
+
| Libraries | `src/lib/` | Subsystems (validators, generators, trust, hooks) |
|
|
34
|
+
| Utilities | `src/utils/` | Shared helpers (logger, banner, file-copier) |
|
|
35
|
+
| Framework | `framework/` | Metadata installed into target projects |
|
|
36
|
+
|
|
37
|
+
### Key Patterns
|
|
38
|
+
|
|
39
|
+
- **Dual-layer phase tracking:** Phase derived from filesystem (`derivePhase()`), state.json only for lightweight phases
|
|
40
|
+
- **Output schema as SSOT:** `output-schema.js` defines all 15 output types. Run `npm run generate` after changes
|
|
41
|
+
- **Data-driven validation:** `agents.json` lists validators per agent
|
|
42
|
+
- **Fail-open hooks:** Check `stateExists()` first, return `{}` if missing
|
|
43
|
+
- **Atomic state writes:** Write to PID temp file, then rename
|
|
44
|
+
|
|
45
|
+
### Testing
|
|
46
|
+
|
|
47
|
+
- Framework: `node:test` (native), always sequential (`--test-concurrency=1`)
|
|
48
|
+
- Every `src/**/*.js` should have `test/**/*.test.js`
|
|
49
|
+
- Use `createTempDir()` / `cleanupTempDir()` from `test/helpers/test-utils.js`
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Checklist
|
|
54
|
+
|
|
55
|
+
- [ ] New command registered in `bin/morph-spec.js`
|
|
56
|
+
- [ ] Command handler delegates to `src/core/` or `src/lib/` (not inline logic)
|
|
57
|
+
- [ ] ESM imports/exports only
|
|
58
|
+
- [ ] State mutations use `state-manager.js` (atomic writes)
|
|
59
|
+
- [ ] If new output type: added to `output-schema.js` + ran `npm run generate`
|
|
60
|
+
- [ ] If new hook: follows fail-open pattern + added to `MORPH_HOOKS` in hooks-installer.js
|
|
61
|
+
- [ ] Test file created with `node:test`
|
|
62
|
+
- [ ] All existing tests pass (`npm test`)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: packages-validator
|
|
3
|
+
description: Packages Validator (READ-ONLY Tier 4) that scans NuGet and npm packages for version conflicts, deprecated dependencies, security advisories, and configuration issues.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
color: gray
|
|
6
|
+
effort: medium
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Packages Validator
|
|
10
|
+
|
|
11
|
+
READ-ONLY scanner for NuGet and npm package issues.
|
|
12
|
+
|
|
13
|
+
## Responsibilities
|
|
14
|
+
|
|
15
|
+
1. **Scan all .csproj and package.json files** for package issues
|
|
16
|
+
2. **Detect version conflicts** between projects
|
|
17
|
+
3. **Flag deprecated or vulnerable packages**
|
|
18
|
+
4. **Report findings** with severity and location
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Scan Categories
|
|
23
|
+
|
|
24
|
+
### NuGet (.csproj)
|
|
25
|
+
|
|
26
|
+
| Issue | Signal | Severity |
|
|
27
|
+
|-------|--------|----------|
|
|
28
|
+
| Version conflict | Same package, different versions across projects | Error |
|
|
29
|
+
| Floating version | `Version="*"` or `Version="1.*"` in production | Warning |
|
|
30
|
+
| Deprecated package | Known deprecated packages (e.g., `Newtonsoft.Json` when `System.Text.Json` suffices) | Warning |
|
|
31
|
+
| Missing version | `<PackageReference>` without explicit version | Warning |
|
|
32
|
+
| Preview in production | `-preview` or `-rc` packages in release config | Warning |
|
|
33
|
+
|
|
34
|
+
### npm (package.json)
|
|
35
|
+
|
|
36
|
+
| Issue | Signal | Severity |
|
|
37
|
+
|-------|--------|----------|
|
|
38
|
+
| Version conflict | Mismatched versions in monorepo workspaces | Error |
|
|
39
|
+
| Exact versions missing | No lockfile or `^` ranges without lockfile | Warning |
|
|
40
|
+
| Deprecated package | Known deprecated (e.g., `request`, `moment`) | Warning |
|
|
41
|
+
| Missing peer deps | Peer dependency warnings | Warning |
|
|
42
|
+
| Duplicate functionality | Multiple packages for same purpose | Info |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Scan Procedure
|
|
47
|
+
|
|
48
|
+
1. **Glob** all `*.csproj` and `package.json` files
|
|
49
|
+
2. **Read** each file to extract package references and versions
|
|
50
|
+
3. **Cross-reference** versions across all project files
|
|
51
|
+
4. **Grep** for known problematic patterns
|
|
52
|
+
5. **Report** issues with file, package name, versions, severity
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Known Package Mappings
|
|
57
|
+
|
|
58
|
+
| Deprecated / Redundant | Recommended |
|
|
59
|
+
|------------------------|-------------|
|
|
60
|
+
| `Newtonsoft.Json` (new projects) | `System.Text.Json` |
|
|
61
|
+
| `AutoMapper` | Manual mapping or Mapster |
|
|
62
|
+
| `MediatR` (in VSA) | Direct handler injection |
|
|
63
|
+
| `FluentValidation` (simple cases) | Data annotations or minimal API filters |
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Checklist
|
|
68
|
+
|
|
69
|
+
- [ ] No version conflicts between projects
|
|
70
|
+
- [ ] No floating versions in production
|
|
71
|
+
- [ ] No deprecated packages without justification
|
|
72
|
+
- [ ] Lockfiles present (packages.lock.json / pnpm-lock.yaml)
|
|
73
|
+
- [ ] Preview packages documented with rationale
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-expert
|
|
3
|
+
description: Security Validator (READ-ONLY Tier 4) that scans source files for security vulnerabilities including SQL injection, XSS, hardcoded secrets, CSRF, and insecure deserialization.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
color: gray
|
|
6
|
+
effort: medium
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Security Validator
|
|
10
|
+
|
|
11
|
+
READ-ONLY scanner for security vulnerabilities across all source files.
|
|
12
|
+
|
|
13
|
+
## Responsibilities
|
|
14
|
+
|
|
15
|
+
1. **Scan all .cs, .tsx, .ts, .js files** for security issues
|
|
16
|
+
2. **Report findings** with severity, file path, and line number
|
|
17
|
+
3. **Never modify code** — report only
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Scan Categories
|
|
22
|
+
|
|
23
|
+
### Critical (Severity: Error)
|
|
24
|
+
|
|
25
|
+
| Vulnerability | Signal | Pattern |
|
|
26
|
+
|---------------|--------|---------|
|
|
27
|
+
| SQL Injection | String concatenation in queries | `$"SELECT ... {variable}"`, `string.Format` in SQL |
|
|
28
|
+
| Hardcoded Secrets | API keys, connection strings in code | `"sk-"`, `"Bearer "`, passwords in literals |
|
|
29
|
+
| XSS | Unescaped user input in HTML | `dangerouslySetInnerHTML`, raw HTML injection |
|
|
30
|
+
| Insecure Deserialization | Untrusted data deserialization | `JsonSerializer.Deserialize` from user input without validation |
|
|
31
|
+
| CSRF | Missing anti-forgery tokens | POST endpoints without `[ValidateAntiForgeryToken]` |
|
|
32
|
+
| Path Traversal | User input in file paths | `Path.Combine(basePath, userInput)` without sanitization |
|
|
33
|
+
|
|
34
|
+
### High (Severity: Warning)
|
|
35
|
+
|
|
36
|
+
| Vulnerability | Signal |
|
|
37
|
+
|---------------|--------|
|
|
38
|
+
| Missing auth on endpoints | Public endpoints without `[Authorize]` |
|
|
39
|
+
| Weak crypto | MD5, SHA1 for security purposes |
|
|
40
|
+
| Information disclosure | Stack traces in production responses |
|
|
41
|
+
| Missing HTTPS redirect | No `UseHttpsRedirection()` in pipeline |
|
|
42
|
+
| Overly permissive CORS | `AllowAnyOrigin()` with `AllowCredentials()` |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Scan Procedure
|
|
47
|
+
|
|
48
|
+
1. **Glob** all source files: `**/*.cs`, `**/*.tsx`, `**/*.ts`, `**/*.js`
|
|
49
|
+
2. **Grep** for each vulnerability pattern
|
|
50
|
+
3. **Read** flagged files to verify (reduce false positives)
|
|
51
|
+
4. **Report** with: file, line, vulnerability type, severity, recommendation
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Checklist
|
|
56
|
+
|
|
57
|
+
- [ ] No hardcoded secrets in source code
|
|
58
|
+
- [ ] No SQL string concatenation
|
|
59
|
+
- [ ] No `dangerouslySetInnerHTML` with user input
|
|
60
|
+
- [ ] All POST/PUT/DELETE endpoints have authorization
|
|
61
|
+
- [ ] HTTPS enforced in production
|
|
62
|
+
- [ ] CORS policy is restrictive
|
|
63
|
+
- [ ] No weak cryptographic algorithms
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -35,7 +35,7 @@ When working on AI agent tasks:
|
|
|
35
35
|
1. Consult `setup.md` for agent configuration, tools, and DI registration
|
|
36
36
|
2. Follow `workflows.md` for orchestration (sequential, parallel, conditional)
|
|
37
37
|
3. Apply `production.md` for middleware, observability, and production patterns
|
|
38
|
-
4.
|
|
38
|
+
4. Use Microsoft.Extensions.AI for IChatClient/IEmbeddingGenerator abstractions (stable). MAF packages (`Microsoft.Agents.AI.*`) are not yet published on NuGet — use `IChatClient` directly until MAF reaches GA.
|
|
39
39
|
|
|
40
40
|
## When to Use
|
|
41
41
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-system-validator
|
|
3
|
+
description: Design System Validator (READ-ONLY Tier 4) that scans CSS and component files for design token compliance including color palette, spacing, motion tokens, and naming conventions.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
color: gray
|
|
6
|
+
effort: medium
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Design System Validator
|
|
10
|
+
|
|
11
|
+
READ-ONLY scanner for design token compliance across CSS and component files.
|
|
12
|
+
|
|
13
|
+
## Standards
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
.morph/framework/standards/frontend/design-system-naming.md
|
|
17
|
+
.morph/framework/standards/frontend/design-system-animations.md
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Responsibilities
|
|
23
|
+
|
|
24
|
+
1. **Read project design tokens** from `.morph/context/design-system.md`
|
|
25
|
+
2. **Scan all .css, .scss, .tsx, .ts files** for design token violations
|
|
26
|
+
3. **Validate naming conventions** for CSS custom properties
|
|
27
|
+
4. **Check animation compliance** against motion token standards
|
|
28
|
+
5. **Report findings** with severity and location
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Scan Categories
|
|
33
|
+
|
|
34
|
+
### Colors
|
|
35
|
+
|
|
36
|
+
| Issue | Signal | Severity |
|
|
37
|
+
|-------|--------|----------|
|
|
38
|
+
| Hardcoded color | `#fff`, `rgb(...)`, `hsl(...)` instead of token | Error |
|
|
39
|
+
| Wrong token namespace | `--color-*` instead of `--ds-color-*` | Warning |
|
|
40
|
+
| Missing opacity token | Inline `opacity: 0.5` instead of token | Warning |
|
|
41
|
+
|
|
42
|
+
### Spacing
|
|
43
|
+
|
|
44
|
+
| Issue | Signal | Severity |
|
|
45
|
+
|-------|--------|----------|
|
|
46
|
+
| Hardcoded spacing | `padding: 16px` instead of token | Error |
|
|
47
|
+
| Magic numbers | Arbitrary values not in spacing scale | Warning |
|
|
48
|
+
| Inconsistent units | Mixed `rem`/`px`/`em` without system | Warning |
|
|
49
|
+
|
|
50
|
+
### Typography
|
|
51
|
+
|
|
52
|
+
| Issue | Signal | Severity |
|
|
53
|
+
|-------|--------|----------|
|
|
54
|
+
| Hardcoded font-size | `font-size: 14px` instead of token | Error |
|
|
55
|
+
| Missing font stack | Custom `font-family` instead of token | Warning |
|
|
56
|
+
|
|
57
|
+
### Motion / Animation
|
|
58
|
+
|
|
59
|
+
| Issue | Signal | Severity |
|
|
60
|
+
|-------|--------|----------|
|
|
61
|
+
| Hardcoded duration | `transition: 0.3s` instead of motion token | Warning |
|
|
62
|
+
| Missing `prefers-reduced-motion` | Animation without reduced-motion media query | Error |
|
|
63
|
+
| Excessive animation | Duration > 500ms without justification | Warning |
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Scan Procedure
|
|
68
|
+
|
|
69
|
+
1. **Read** `.morph/context/design-system.md` for project-specific tokens
|
|
70
|
+
2. **Glob** all `.css`, `.scss`, `.tsx`, `.ts` files under `src/`
|
|
71
|
+
3. **Grep** for hardcoded values (hex colors, px values, raw durations)
|
|
72
|
+
4. **Validate** against design token naming conventions
|
|
73
|
+
5. **Report** violations with file, line, severity, expected token
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Checklist
|
|
78
|
+
|
|
79
|
+
- [ ] No hardcoded colors — all via CSS custom properties
|
|
80
|
+
- [ ] No hardcoded spacing — all via spacing scale tokens
|
|
81
|
+
- [ ] No hardcoded font sizes — all via typography tokens
|
|
82
|
+
- [ ] Animations use motion tokens for duration/easing
|
|
83
|
+
- [ ] `prefers-reduced-motion` respected for all animations
|
|
84
|
+
- [ ] CSS custom properties follow `--ds-*` namespace
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nextjs-component-validator
|
|
3
|
+
description: Next.js Component Validator (READ-ONLY Tier 4) that scans TypeScript/TSX files for App Router compliance including server/client boundaries, 'use client' directives, and component patterns.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
stacks:
|
|
6
|
+
- nextjs
|
|
7
|
+
color: gray
|
|
8
|
+
effort: medium
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Next.js Component Validator
|
|
12
|
+
|
|
13
|
+
READ-ONLY scanner for App Router compliance in Next.js projects.
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Scan all .tsx/.ts files** under `src/` for App Router violations
|
|
18
|
+
2. **Validate server/client boundaries** — correct `'use client'` placement
|
|
19
|
+
3. **Check component patterns** — data fetching, metadata, layouts
|
|
20
|
+
4. **Report findings** with severity and location
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Scan Categories
|
|
25
|
+
|
|
26
|
+
### Server/Client Boundaries
|
|
27
|
+
|
|
28
|
+
| Issue | Signal | Severity |
|
|
29
|
+
|-------|--------|----------|
|
|
30
|
+
| Missing `'use client'` | Component uses hooks (`useState`, `useEffect`) without directive | Error |
|
|
31
|
+
| Unnecessary `'use client'` | Server component marked as client without reason | Warning |
|
|
32
|
+
| Client importing server | Client component importing server-only module | Error |
|
|
33
|
+
| Hooks in server component | React hooks in file without `'use client'` | Error |
|
|
34
|
+
|
|
35
|
+
### Data Fetching
|
|
36
|
+
|
|
37
|
+
| Issue | Signal | Severity |
|
|
38
|
+
|-------|--------|----------|
|
|
39
|
+
| `useEffect` for data | Using `useEffect` + `fetch` instead of server component | Warning |
|
|
40
|
+
| Missing `Suspense` | Async server component without Suspense boundary | Warning |
|
|
41
|
+
| Client-side fetch in page | `fetch` in client component that could be server | Info |
|
|
42
|
+
|
|
43
|
+
### Routing & Metadata
|
|
44
|
+
|
|
45
|
+
| Issue | Signal | Severity |
|
|
46
|
+
|-------|--------|----------|
|
|
47
|
+
| Missing `metadata` export | Page without `export const metadata` or `generateMetadata` | Warning |
|
|
48
|
+
| Wrong file convention | `page.tsx` missing in route folder | Error |
|
|
49
|
+
| Layout without children | `layout.tsx` not rendering `{children}` | Error |
|
|
50
|
+
|
|
51
|
+
### Performance
|
|
52
|
+
|
|
53
|
+
| Issue | Signal | Severity |
|
|
54
|
+
|-------|--------|----------|
|
|
55
|
+
| Large client bundle | `'use client'` at page level (should be leaf components) | Warning |
|
|
56
|
+
| Missing `loading.tsx` | Route without loading state | Info |
|
|
57
|
+
| Unoptimized images | `<img>` instead of `next/image` | Warning |
|
|
58
|
+
| Missing `dynamic` import | Heavy component not lazy-loaded | Info |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Scan Procedure
|
|
63
|
+
|
|
64
|
+
1. **Glob** all `.tsx`, `.ts` files under `src/`
|
|
65
|
+
2. **Grep** for `'use client'` directives and React hooks
|
|
66
|
+
3. **Read** files with hooks to verify `'use client'` presence
|
|
67
|
+
4. **Validate** page/layout conventions in `app/` directory
|
|
68
|
+
5. **Report** violations with file, line, severity, fix suggestion
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Checklist
|
|
73
|
+
|
|
74
|
+
- [ ] All components with hooks have `'use client'`
|
|
75
|
+
- [ ] Server components fetch data directly (no `useEffect`)
|
|
76
|
+
- [ ] Pages export `metadata` or `generateMetadata`
|
|
77
|
+
- [ ] Layouts render `{children}`
|
|
78
|
+
- [ ] Images use `next/image`
|
|
79
|
+
- [ ] Heavy components use `dynamic()` import
|
|
80
|
+
- [ ] `Suspense` boundaries around async components
|
|
81
|
+
- [ ] `'use client'` at leaf level, not page level
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -55,6 +55,31 @@ Linear (linear.app), Vercel (vercel.com), Stripe (stripe.com), Dribbble dashboar
|
|
|
55
55
|
|
|
56
56
|
---
|
|
57
57
|
|
|
58
|
+
### Stitch MCP (Optional)
|
|
59
|
+
|
|
60
|
+
When Stitch MCP is available, use AI-generated screen designs instead of manual wireframes:
|
|
61
|
+
|
|
62
|
+
| Tool | Purpose |
|
|
63
|
+
|------|---------|
|
|
64
|
+
| `generate_screen_from_text` | Generate screen design from text prompt |
|
|
65
|
+
| `fetch_screen_image` | Export screen as image for review |
|
|
66
|
+
| `fetch_screen_code` | Export design.md with tokens |
|
|
67
|
+
| `list_projects` / `list_screens` | Navigate existing projects |
|
|
68
|
+
|
|
69
|
+
**Companion skills** (auto-installed with Stitch MCP):
|
|
70
|
+
- `stitch-design` — entry point for design generation via Claude Code
|
|
71
|
+
- `stitch-loop` — multi-page website generation
|
|
72
|
+
- `design-md` — generate design.md from existing designs
|
|
73
|
+
- `prompt-enhance` — improve design prompts automatically
|
|
74
|
+
- `react-components` — convert Stitch HTML to React components
|
|
75
|
+
- `shadcn-ui` — guide conversion to ShadCN components (recommended for Next.js projects)
|
|
76
|
+
|
|
77
|
+
**Key:** Stitch MCP transmits real HTML/CSS code (not screenshots), producing dramatically better results.
|
|
78
|
+
|
|
79
|
+
**Rule:** Stitch design.md is NOT a separate deliverable. Extract tokens into `design-system.md`.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
58
83
|
## Design Brief Protocol (MANDATORY)
|
|
59
84
|
|
|
60
85
|
> **This protocol runs BEFORE any wireframe, mockup, or visual decision.**
|
|
@@ -74,6 +99,11 @@ Read: .morph/context/design-system.md
|
|
|
74
99
|
- Fill in the missing sections using the Design Thinking questions (Step 1 below)
|
|
75
100
|
- This file is the persistent record — update it, don't just keep it in memory
|
|
76
101
|
|
|
102
|
+
**If Stitch MCP is available:**
|
|
103
|
+
- Check `list_projects` — if a project exists for this feature, its design.md can seed the design system
|
|
104
|
+
- Stitch tokens map INTO `design-system.md` — never a separate file
|
|
105
|
+
- Validate Stitch-exported colors against WCAG AA before adopting
|
|
106
|
+
|
|
77
107
|
**When taking any design decision not covered by the file:**
|
|
78
108
|
1. Add the token/decision to `design-system.md` in the correct section
|
|
79
109
|
2. Register in the Changelog: `- YYYY-MM-DD [ui-ux-designer] Description`
|
|
@@ -208,6 +238,7 @@ Per flow: Trigger, steps, happy path, edge cases, ASCII flowchart diagram.
|
|
|
208
238
|
- [ ] `design-system.md` read (project-level at `.morph/context/`) OR created with real tokens
|
|
209
239
|
- [ ] Design Brief declared before any visual output (direction, palette, motion)
|
|
210
240
|
- [ ] All color values in deliverables use CSS tokens (`--color-accent: #FF4D1C`) not generic names
|
|
241
|
+
- [ ] If Stitch was used: tokens extracted and mapped to `design-system.md` (no separate design.md output)
|
|
211
242
|
- [ ] `mockups.md`: Wireframes for ALL screens + states (loading, error, empty) + responsiveness
|
|
212
243
|
- [ ] `components.md`: shadcn components mapped with props/events/states
|
|
213
244
|
- [ ] `flows.md`: Happy paths + edge cases + ASCII diagrams
|
package/framework/agents.json
CHANGED
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
"role": "UI/UX Squad Leader",
|
|
262
262
|
"icon": "🎨",
|
|
263
263
|
"triggers": "UI/UX design, wireframes, user flows, design system, shadcn/ui component selection",
|
|
264
|
-
"spawn_prompt": "You are the UI/UX Squad Leader. Create wireframes, design system, and user flows during the UI/UX phase.\n\nWorkflow:\n1. Read `.morph/context/design-system.md` FIRST — use only defined tokens\n2. Read spec.md for UI requirements\n3. Generate deliverables: design-system.md, mockups.md, components.md, flows.md\
|
|
264
|
+
"spawn_prompt": "You are the UI/UX Squad Leader. Create wireframes, design system, and user flows during the UI/UX phase.\n\nWorkflow:\n1. Read `.morph/context/design-system.md` FIRST — use only defined tokens\n2. Read spec.md for UI requirements\n3. If Stitch MCP available, offer AI-generated screen designs. Use companion skills (stitch-design, design-md) for workflow. Extract Stitch design.md tokens into design-system.md — no separate output.\n4. Generate deliverables: design-system.md, mockups.md, components.md, flows.md\n5. Coordinate squad: nextjs-expert, css-specialist, seo-growth-hacker\n\nWork is UI/UX phase ONLY — no implementation code. Refer to the Domain Knowledge section below for design brief protocol, shadcn/ui reference, and accessibility rules."
|
|
265
265
|
}
|
|
266
266
|
},
|
|
267
267
|
"ef-modeler": {
|
|
@@ -69,6 +69,45 @@ async function dispatch(command, payload) {
|
|
|
69
69
|
// Non-blocking
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// Evaluator dispatch: if sprint contract exists, instruct Claude to dispatch evaluator
|
|
73
|
+
try {
|
|
74
|
+
const taskId = taskDoneParsed.taskId;
|
|
75
|
+
if (taskId && !command.includes('--skip-eval')) {
|
|
76
|
+
const contractPath = join(process.cwd(), '.morph', 'features', featureName, '5-implement', 'contracts', `${taskId}-contract.yaml`);
|
|
77
|
+
if (existsSync(contractPath)) {
|
|
78
|
+
const contractContent = readFileSync(contractPath, 'utf-8');
|
|
79
|
+
let changedFiles = '';
|
|
80
|
+
try {
|
|
81
|
+
changedFiles = execSync('git diff --name-only HEAD~1 2>/dev/null | head -10', {
|
|
82
|
+
cwd: process.cwd(), encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe']
|
|
83
|
+
}).trim();
|
|
84
|
+
} catch { /* no git */ }
|
|
85
|
+
|
|
86
|
+
contextParts.push(
|
|
87
|
+
`🔍 EVALUATOR DISPATCH\n` +
|
|
88
|
+
`════════════════════════════════════════\n` +
|
|
89
|
+
`Sprint contract exists for ${taskId}. Dispatch an evaluator sub-agent:\n\n` +
|
|
90
|
+
`Use the Agent tool with:\n` +
|
|
91
|
+
` subagent_type: "general-purpose"\n` +
|
|
92
|
+
` model: "sonnet"\n` +
|
|
93
|
+
` prompt: (see below)\n\n` +
|
|
94
|
+
`--- EVALUATOR PROMPT ---\n` +
|
|
95
|
+
`You are an independent evaluator. Validate this implementation against the sprint contract.\n\n` +
|
|
96
|
+
`## Contract\n${contractContent}\n\n` +
|
|
97
|
+
`## Changed Files\n${changedFiles || '(unable to determine)'}\n\n` +
|
|
98
|
+
`## Instructions\n` +
|
|
99
|
+
`1. Read each changed file\n` +
|
|
100
|
+
`2. Run the verification commands from the contract\n` +
|
|
101
|
+
`3. Evaluate each definitionOfDone item: PASS or FAIL with evidence\n` +
|
|
102
|
+
`4. Return a structured result with overall PASS/FAIL\n` +
|
|
103
|
+
`--- END EVALUATOR PROMPT ---`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch {
|
|
108
|
+
// Non-blocking — evaluator is optional
|
|
109
|
+
}
|
|
110
|
+
|
|
72
111
|
// Always inject validator dispatch — deferred if --skip-validation
|
|
73
112
|
const validatorText = await buildValidatorDispatchContext(featureName, payload);
|
|
74
113
|
if (validatorText) {
|