@polymorphism-tech/morph-spec 4.19.0 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +11 -0
  3. package/bin/task-manager.js +35 -10
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/agents/architecture/architecture-expert.md +12 -0
  8. package/framework/agents/architecture/packages-validator.md +12 -0
  9. package/framework/agents/architecture/security-expert.md +12 -0
  10. package/framework/agents/frontend/design-system-validator.md +12 -0
  11. package/framework/agents/frontend/nextjs-component-validator.md +12 -0
  12. package/framework/hooks/claude-code/post-tool-use/dispatch.js +20 -3
  13. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +60 -11
  14. package/framework/rubrics/backend.json +36 -0
  15. package/framework/rubrics/default.json +36 -0
  16. package/framework/rubrics/frontend.json +36 -0
  17. package/framework/skills/level-0-meta/mcp-registry.json +21 -8
  18. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +1 -1
  19. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
  20. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +1 -1
  21. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +1 -1
  22. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
  23. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
  24. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +1 -1
  25. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  26. package/package.json +1 -1
  27. package/src/commands/dashboard/dashboard.js +53 -0
  28. package/src/commands/mcp/mcp-setup.js +99 -2
  29. package/src/dashboard/app/App.jsx +31 -0
  30. package/src/dashboard/app/components/DetailPanel.jsx +11 -0
  31. package/src/dashboard/app/components/FlowGraph.jsx +17 -0
  32. package/src/dashboard/app/components/SearchFilter.jsx +22 -0
  33. package/src/dashboard/app/components/Sidebar.jsx +45 -0
  34. package/src/dashboard/app/hooks/useDetailPanel.js +15 -0
  35. package/src/dashboard/app/main.jsx +13 -0
  36. package/src/dashboard/app/pages/AgentMap.jsx +371 -0
  37. package/src/dashboard/app/pages/HookInspector.jsx +418 -0
  38. package/src/dashboard/app/pages/LiveState.jsx +239 -0
  39. package/src/dashboard/app/pages/PhasePipeline.jsx +410 -0
  40. package/src/dashboard/app/pages/RulesMap.jsx +273 -0
  41. package/src/dashboard/app/pages/SkillsLibrary.jsx +367 -0
  42. package/src/dashboard/app/pages/Standards.jsx +332 -0
  43. package/src/dashboard/app/pages/Workflows.jsx +346 -0
  44. package/src/dashboard/app/styles/index.css +47 -0
  45. package/src/dashboard/index.html +12 -0
  46. package/src/dashboard/package.json +24 -0
  47. package/src/dashboard/scanner/agents-scanner.js +35 -0
  48. package/src/dashboard/scanner/hooks-scanner.js +41 -0
  49. package/src/dashboard/scanner/index.js +21 -0
  50. package/src/dashboard/scanner/phases-scanner.js +15 -0
  51. package/src/dashboard/scanner/rubrics-scanner.js +12 -0
  52. package/src/dashboard/scanner/rules-scanner.js +37 -0
  53. package/src/dashboard/scanner/skills-scanner.js +43 -0
  54. package/src/dashboard/scanner/squads-scanner.js +13 -0
  55. package/src/dashboard/scanner/standards-scanner.js +26 -0
  56. package/src/dashboard/scanner/state-scanner.js +8 -0
  57. package/src/dashboard/scanner/workflows-scanner.js +18 -0
  58. package/src/dashboard/vite-plugin-morph-data.js +17 -0
  59. package/src/dashboard/vite.config.js +24 -0
  60. package/src/lib/checkpoints/checkpoint-hooks.js +2 -1
  61. package/src/lib/detectors/index.js +1 -1
  62. package/src/lib/generators/recap-generator.js +15 -0
  63. package/src/lib/installers/mcp-installer.js +140 -1
  64. package/src/lib/validators/score-aggregator.js +244 -0
  65. package/src/lib/validators/validation-runner.js +44 -0
  66. package/src/scripts/setup-infra.js +8 -0
@@ -0,0 +1,371 @@
1
+ import { useState, useMemo, useCallback } from 'react';
2
+ import { Handle, Position } from '@xyflow/react';
3
+ import dagre from '@dagrejs/dagre';
4
+ import morphData from 'virtual:morph-data';
5
+ import FlowGraph from '../components/FlowGraph.jsx';
6
+ import DetailPanel from '../components/DetailPanel.jsx';
7
+ import SearchFilter from '../components/SearchFilter.jsx';
8
+ import { useDetailPanel } from '../hooks/useDetailPanel.js';
9
+
10
+ // Tier color palette: bg color, border color
11
+ const TIER_COLORS = {
12
+ user: { bg: '#78350f', border: '#f59e0b', label: 'User' },
13
+ 1: { bg: '#991b1b', border: '#ef4444', label: 'T1' },
14
+ 2: { bg: '#9a3412', border: '#f97316', label: 'T2' },
15
+ 3: { bg: '#1e40af', border: '#3b82f6', label: 'T3' },
16
+ 4: { bg: '#6d28d9', border: '#8b5cf6', label: 'T4' },
17
+ };
18
+
19
+ // Custom AgentNode component
20
+ function AgentNode({ data }) {
21
+ const colors = data.isUser ? TIER_COLORS.user : (TIER_COLORS[data.tier] || TIER_COLORS[4]);
22
+ return (
23
+ <div
24
+ className="rounded-lg px-3 py-2 min-w-[130px] max-w-[160px] cursor-pointer select-none"
25
+ style={{ background: colors.bg, border: `1.5px solid ${colors.border}`, boxShadow: `0 0 8px ${colors.border}22` }}
26
+ >
27
+ <Handle type="target" position={Position.Top} style={{ background: colors.border, width: 8, height: 8 }} />
28
+ <div className="text-white text-xs font-semibold leading-tight truncate" title={data.label}>
29
+ {data.label}
30
+ </div>
31
+ <div className="text-gray-300 text-[10px] mt-0.5 truncate">
32
+ {data.isUser ? 'Principal' : `${colors.label} · ${data.group || ''}`}
33
+ </div>
34
+ <Handle type="source" position={Position.Bottom} style={{ background: colors.border, width: 8, height: 8 }} />
35
+ </div>
36
+ );
37
+ }
38
+
39
+ const nodeTypes = { agentNode: AgentNode };
40
+
41
+ // Dagre layout helpers
42
+ function buildLayout(nodes, edges) {
43
+ const g = new dagre.graphlib.Graph();
44
+ g.setDefaultEdgeLabel(() => ({}));
45
+ g.setGraph({ rankdir: 'TB', nodesep: 40, ranksep: 60, marginx: 20, marginy: 20 });
46
+
47
+ nodes.forEach((n) => g.setNode(n.id, { width: 160, height: 60 }));
48
+ edges.forEach((e) => g.setEdge(e.source, e.target));
49
+
50
+ dagre.layout(g);
51
+
52
+ return nodes.map((n) => {
53
+ const pos = g.node(n.id);
54
+ return { ...n, position: { x: pos.x - 80, y: pos.y - 30 } };
55
+ });
56
+ }
57
+
58
+ // AgentDetail shown inside the panel
59
+ function AgentDetail({ agent }) {
60
+ const [showPrompt, setShowPrompt] = useState(false);
61
+ const tierColors = TIER_COLORS[agent.tier] || TIER_COLORS[4];
62
+
63
+ return (
64
+ <div className="text-sm text-gray-200 space-y-4">
65
+ {/* Header */}
66
+ <div>
67
+ <div className="flex items-center gap-2 mb-1">
68
+ <span className="px-2 py-0.5 rounded text-xs font-bold" style={{ background: tierColors.bg, color: tierColors.border, border: `1px solid ${tierColors.border}` }}>
69
+ Tier {agent.tier}
70
+ </span>
71
+ <span className="text-gray-400 text-xs">{agent.group}</span>
72
+ </div>
73
+ <p className="text-gray-400 text-xs">ID: <span className="text-gray-300 font-mono">{agent.id}</span></p>
74
+ {agent.reportsTo && (
75
+ <p className="text-gray-400 text-xs mt-0.5">Reports to: <span className="text-blue-300 font-mono">{agent.reportsTo}</span></p>
76
+ )}
77
+ </div>
78
+
79
+ {/* Active Phases */}
80
+ {agent.activePhases?.length > 0 && (
81
+ <div>
82
+ <p className="text-gray-500 text-xs uppercase tracking-wide mb-1.5">Active Phases</p>
83
+ <div className="flex flex-wrap gap-1">
84
+ {agent.activePhases.map((p) => (
85
+ <span key={p} className="px-2 py-0.5 bg-blue-900/50 border border-blue-700 rounded text-xs text-blue-300">{p}</span>
86
+ ))}
87
+ </div>
88
+ </div>
89
+ )}
90
+
91
+ {/* Validators */}
92
+ {agent.validators?.length > 0 && (
93
+ <div>
94
+ <p className="text-gray-500 text-xs uppercase tracking-wide mb-1.5">Validators</p>
95
+ <div className="flex flex-wrap gap-1">
96
+ {agent.validators.map((v) => (
97
+ <span key={v} className="px-2 py-0.5 bg-purple-900/50 border border-purple-700 rounded text-xs text-purple-300">{v}</span>
98
+ ))}
99
+ </div>
100
+ </div>
101
+ )}
102
+
103
+ {/* Standards */}
104
+ {agent.standards?.length > 0 && (
105
+ <div>
106
+ <p className="text-gray-500 text-xs uppercase tracking-wide mb-1.5">Standards</p>
107
+ <ul className="space-y-1">
108
+ {agent.standards.map((s) => (
109
+ <li key={s.id} className="flex items-center justify-between text-xs">
110
+ <span className="font-mono text-gray-300">{s.id}</span>
111
+ <div className="flex gap-1">
112
+ {s.scope && <span className="px-1.5 py-0.5 bg-gray-800 rounded text-gray-400">{s.scope}</span>}
113
+ {s.priority && <span className="px-1.5 py-0.5 bg-gray-800 rounded text-gray-400">{s.priority}</span>}
114
+ </div>
115
+ </li>
116
+ ))}
117
+ </ul>
118
+ </div>
119
+ )}
120
+
121
+ {/* Domains */}
122
+ {agent.domains?.length > 0 && (
123
+ <div>
124
+ <p className="text-gray-500 text-xs uppercase tracking-wide mb-1.5">Domains</p>
125
+ <p className="text-gray-300 text-xs">{agent.domains.join(', ')}</p>
126
+ </div>
127
+ )}
128
+
129
+ {/* Keywords */}
130
+ {agent.keywords?.length > 0 && (
131
+ <div>
132
+ <p className="text-gray-500 text-xs uppercase tracking-wide mb-1.5">Keywords</p>
133
+ <div className="flex flex-wrap gap-1">
134
+ {agent.keywords.map((k) => (
135
+ <span key={k} className="px-1.5 py-0.5 bg-gray-800 border border-gray-700 rounded text-xs text-gray-400">{k}</span>
136
+ ))}
137
+ </div>
138
+ </div>
139
+ )}
140
+
141
+ {/* Stacks */}
142
+ {agent.stacks?.length > 0 && (
143
+ <div>
144
+ <p className="text-gray-500 text-xs uppercase tracking-wide mb-1.5">Stacks</p>
145
+ <div className="flex flex-wrap gap-1">
146
+ {agent.stacks.map((s) => (
147
+ <span key={s} className="px-1.5 py-0.5 bg-green-900/50 border border-green-700 rounded text-xs text-green-300">{s}</span>
148
+ ))}
149
+ </div>
150
+ </div>
151
+ )}
152
+
153
+ {/* Full Prompt toggle */}
154
+ {agent.prompt && (
155
+ <div>
156
+ <button
157
+ onClick={() => setShowPrompt((v) => !v)}
158
+ className="w-full text-left px-3 py-1.5 bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded text-xs text-gray-300 transition-colors"
159
+ >
160
+ {showPrompt ? 'Hide Full Prompt' : 'Show Full Prompt'}
161
+ </button>
162
+ {showPrompt && (
163
+ <pre className="mt-2 p-3 bg-gray-950 border border-gray-800 rounded text-[10px] text-gray-400 overflow-x-auto whitespace-pre-wrap font-mono leading-relaxed max-h-64 overflow-y-auto">
164
+ {agent.prompt}
165
+ </pre>
166
+ )}
167
+ </div>
168
+ )}
169
+ </div>
170
+ );
171
+ }
172
+
173
+ export default function AgentMap() {
174
+ const { agents } = morphData;
175
+ const [search, setSearch] = useState('');
176
+ const [tierFilter, setTierFilter] = useState('');
177
+ const [groupFilter, setGroupFilter] = useState('');
178
+ const [phaseFilter, setPhaseFilter] = useState('');
179
+ const [stackFilter, setStackFilter] = useState('');
180
+ const { panel, openPanel, closePanel } = useDetailPanel();
181
+
182
+ // Derive unique groups, tiers, phases, and stacks for filters
183
+ const allGroups = useMemo(() => [...new Set(agents.list.map((a) => a.group).filter(Boolean))].sort(), [agents.list]);
184
+ const allTiers = useMemo(() => [...new Set(agents.list.map((a) => String(a.tier)))].sort(), [agents.list]);
185
+ const allPhases = useMemo(() => {
186
+ const phases = new Set();
187
+ for (const a of agents.list) {
188
+ for (const p of a.activePhases || []) {
189
+ if (p !== '*') phases.add(p);
190
+ }
191
+ }
192
+ return [...phases].sort();
193
+ }, [agents.list]);
194
+ const allStacks = useMemo(() => {
195
+ const stacks = new Set();
196
+ for (const a of agents.list) {
197
+ for (const s of a.stacks || []) {
198
+ stacks.add(s);
199
+ }
200
+ }
201
+ return [...stacks].sort();
202
+ }, [agents.list]);
203
+
204
+ // Filtered agent ids (for highlight — we always show all nodes but dim non-matching)
205
+ const matchedIds = useMemo(() => {
206
+ const q = search.toLowerCase();
207
+ return new Set(
208
+ agents.list
209
+ .filter((a) => {
210
+ const matchesSearch = !q || a.title.toLowerCase().includes(q) || a.id.toLowerCase().includes(q) || a.keywords?.some((k) => k.toLowerCase().includes(q));
211
+ const matchesTier = !tierFilter || String(a.tier) === tierFilter;
212
+ const matchesGroup = !groupFilter || a.group === groupFilter;
213
+ const matchesPhase = !phaseFilter || (a.activePhases || []).includes('*') || (a.activePhases || []).includes(phaseFilter);
214
+ const matchesStack = !stackFilter || (a.stacks || []).includes(stackFilter);
215
+ return matchesSearch && matchesTier && matchesGroup && matchesPhase && matchesStack;
216
+ })
217
+ .map((a) => a.id)
218
+ );
219
+ }, [agents.list, search, tierFilter, groupFilter, phaseFilter, stackFilter]);
220
+
221
+ const hasFilter = search || tierFilter || groupFilter || phaseFilter || stackFilter;
222
+
223
+ // Build React Flow nodes and edges
224
+ const { nodes: layoutNodes, edges } = useMemo(() => {
225
+ const rawNodes = [];
226
+ const rawEdges = [];
227
+
228
+ // User node at top
229
+ rawNodes.push({
230
+ id: '__user__',
231
+ type: 'agentNode',
232
+ data: { label: 'User', isUser: true, color: '#78350f' },
233
+ position: { x: 0, y: 0 },
234
+ });
235
+
236
+ // Agent nodes
237
+ for (const agent of agents.list) {
238
+ const dimmed = hasFilter && !matchedIds.has(agent.id);
239
+ const tierColors = TIER_COLORS[agent.tier] || TIER_COLORS[4];
240
+ rawNodes.push({
241
+ id: agent.id,
242
+ type: 'agentNode',
243
+ data: {
244
+ label: agent.title,
245
+ tier: agent.tier,
246
+ group: agent.group,
247
+ color: tierColors.border,
248
+ agentRef: agent,
249
+ },
250
+ style: dimmed ? { opacity: 0.2 } : {},
251
+ position: { x: 0, y: 0 },
252
+ });
253
+ }
254
+
255
+ // reports_to edges (solid, tier-colored)
256
+ for (const agent of agents.list) {
257
+ const source = agent.reportsTo === 'user' ? '__user__' : agent.reportsTo;
258
+ if (!source) continue;
259
+ const tierColors = TIER_COLORS[agent.tier] || TIER_COLORS[4];
260
+ rawEdges.push({
261
+ id: `rt-${agent.id}`,
262
+ source,
263
+ target: agent.id,
264
+ type: 'smoothstep',
265
+ style: { stroke: tierColors.border, strokeWidth: 1.5 },
266
+ animated: false,
267
+ });
268
+ }
269
+
270
+ // validators edges (dashed purple) — Tier 4 validator agent → validated agent
271
+ // agent.validators contains runner names like "architecture", "design-system", "nextjs-component"
272
+ // which map to Tier 4 agent IDs like "architecture-expert", "design-system-validator", etc.
273
+ // Match by finding the Tier 4 agent whose ID contains the validator runner name.
274
+ const tier4Agents = agents.list.filter((a) => a.tier === 4);
275
+ for (const agent of agents.list) {
276
+ for (const v of agent.validators || []) {
277
+ const validatorAgent = tier4Agents.find((a) => a.id.includes(v));
278
+ if (validatorAgent) {
279
+ rawEdges.push({
280
+ id: `val-${validatorAgent.id}-${agent.id}`,
281
+ source: validatorAgent.id,
282
+ target: agent.id,
283
+ type: 'smoothstep',
284
+ style: { stroke: '#8b5cf6', strokeWidth: 1, strokeDasharray: '4 3' },
285
+ animated: false,
286
+ });
287
+ }
288
+ }
289
+ }
290
+
291
+ const layouted = buildLayout(rawNodes, rawEdges);
292
+ return { nodes: layouted, edges: rawEdges };
293
+ }, [agents.list, matchedIds, hasFilter]);
294
+
295
+ const handleNodeClick = useCallback(
296
+ (_event, node) => {
297
+ if (node.id === '__user__') {
298
+ openPanel('User (Principal)', <div className="text-gray-400 text-sm">The human operator. All Tier 1 orchestrators report to this node.</div>);
299
+ return;
300
+ }
301
+ const agent = node.data.agentRef;
302
+ if (agent) {
303
+ openPanel(agent.title, <AgentDetail agent={agent} />);
304
+ }
305
+ },
306
+ [openPanel]
307
+ );
308
+
309
+ const filterConfig = [
310
+ { name: 'tier', label: 'Tier', options: allTiers, value: tierFilter },
311
+ { name: 'group', label: 'Group', options: allGroups, value: groupFilter },
312
+ { name: 'phase', label: 'Phase', options: allPhases, value: phaseFilter },
313
+ { name: 'stack', label: 'Stack', options: allStacks, value: stackFilter },
314
+ ];
315
+
316
+ return (
317
+ <div className="flex flex-col h-full">
318
+ <SearchFilter
319
+ placeholder="Search agents by name or keyword..."
320
+ filters={filterConfig}
321
+ onSearchChange={setSearch}
322
+ onFilterChange={(name, value) => {
323
+ if (name === 'tier') setTierFilter(value);
324
+ if (name === 'group') setGroupFilter(value);
325
+ if (name === 'phase') setPhaseFilter(value);
326
+ if (name === 'stack') setStackFilter(value);
327
+ }}
328
+ />
329
+
330
+ <div className="flex-1 relative">
331
+ <FlowGraph
332
+ nodes={layoutNodes}
333
+ edges={edges}
334
+ nodeTypes={nodeTypes}
335
+ onNodeClick={handleNodeClick}
336
+ fitView
337
+ />
338
+
339
+ {/* Legend */}
340
+ <div className="absolute top-3 left-3 bg-gray-900/90 border border-gray-700 rounded-lg p-3 text-xs space-y-1.5 z-10">
341
+ <p className="text-gray-400 font-semibold uppercase tracking-wide text-[10px] mb-2">Legend</p>
342
+ {Object.entries(TIER_COLORS).map(([key, c]) => (
343
+ <div key={key} className="flex items-center gap-2">
344
+ <span className="inline-block w-3 h-3 rounded-sm flex-shrink-0" style={{ background: c.bg, border: `1px solid ${c.border}` }} />
345
+ <span className="text-gray-300">{key === 'user' ? 'User' : `Tier ${key} — ${c.label}`}</span>
346
+ </div>
347
+ ))}
348
+ <div className="border-t border-gray-700 mt-2 pt-2 space-y-1">
349
+ <div className="flex items-center gap-2">
350
+ <span className="inline-block w-6 border-t-2 border-blue-400" />
351
+ <span className="text-gray-400">reports_to</span>
352
+ </div>
353
+ <div className="flex items-center gap-2">
354
+ <span className="inline-block w-6 border-t-2 border-purple-400 border-dashed" />
355
+ <span className="text-gray-400">validates</span>
356
+ </div>
357
+ </div>
358
+ </div>
359
+
360
+ {/* Agent count badge */}
361
+ <div className="absolute top-3 right-3 bg-gray-900/90 border border-gray-700 rounded-lg px-3 py-1.5 text-xs text-gray-400 z-10">
362
+ {hasFilter ? `${matchedIds.size} / ${agents.list.length}` : agents.list.length} agents
363
+ </div>
364
+ </div>
365
+
366
+ <DetailPanel open={panel.open} title={panel.title} onClose={closePanel}>
367
+ {panel.content}
368
+ </DetailPanel>
369
+ </div>
370
+ );
371
+ }