@polymorphism-tech/morph-spec 8.38.0 → 8.40.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/CLAUDE.md +19 -8
- package/README.md +2 -2
- package/bin/morph-spec.js +60 -43
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +3 -2
- package/framework/MORPH.md +1 -1
- package/framework/agents.json +36 -25
- package/framework/docs/CLI.md +2 -2
- package/framework/evals/rubrics/code-quality.md +4 -4
- package/framework/evals/rubrics/condensed.md +2 -2
- package/framework/mcp/registry.json +33 -2
- package/framework/rules/infrastructure-standards.md +0 -1
- package/framework/rules/morph-workflow.md +9 -4
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +5 -1
- package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
- package/framework/skills/core/morph-eval/SKILL.md +1 -1
- package/framework/skills/core/morph-hotfix/SKILL.md +1 -1
- package/framework/skills/core/morph-implement/SKILL.md +6 -1
- package/framework/skills/core/morph-media/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +4 -3
- package/framework/skills/core/morph-proposal/SKILL.md +1 -1
- package/framework/skills/core/morph-review/SKILL.md +1 -1
- package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
- package/framework/skills/core/morph-standards/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +6 -5
- package/framework/standards/STANDARDS.json +3 -3
- package/framework/standards/ai-agents/context-providers.md +16 -26
- package/framework/standards/ai-agents/durable-workflows-hitl.md +15 -21
- package/framework/standards/ai-agents/modalities-image-gen.md +21 -25
- package/framework/standards/ai-agents/modalities-speech-to-text.md +4 -15
- package/framework/standards/ai-agents/modalities-text-to-speech.md +2 -11
- package/framework/standards/ai-agents/modalities-vision.md +1 -18
- package/framework/standards/ai-agents/prompt-sources.md +0 -4
- package/framework/standards/architecture/code-comments.md +52 -16
- package/framework/standards/backend/integrations/neon-auth/neon-auth.md +63 -50
- package/framework/standards/frontend/design-system/ai-image-generation.md +5 -5
- package/framework/standards/integration/mcp/mcp-tools.md +48 -117
- package/framework/templates/code/dotnet/abstractions/result.cs +0 -2
- package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +26 -39
- package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +28 -68
- package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +99 -117
- package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +2 -44
- package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +40 -61
- package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +54 -107
- package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +53 -58
- package/framework/templates/code/dotnet/contracts/contracts-vsa.cs +192 -281
- package/framework/templates/code/dotnet/database/migration.cs +49 -83
- package/framework/templates/code/dotnet/database/vector-entity.cs +2 -46
- package/framework/templates/code/dotnet/extensions/result-extensions.cs +0 -2
- package/framework/templates/code/dotnet/feature/validator.cs.hbs +11 -15
- package/framework/templates/code/dotnet/jobs/agent.cs +3 -51
- package/framework/templates/code/dotnet/jobs/job.cs +2 -97
- package/framework/templates/code/dotnet/test.cs +2 -87
- package/framework/templates/code/typescript/contracts.ts +140 -167
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentApi.cs +1 -48
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactory.cs +3 -79
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactoryOptions.cs +1 -70
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpec.cs +1 -47
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpecOptions.cs +2 -99
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/AiKitAssemblyMarker.cs +0 -6
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/ConversationStore.cs +3 -88
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/IConversationStore.cs +1 -41
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/InMemoryConversationStore.cs +0 -21
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/CountingChatClient.cs +1 -25
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalAssertion.cs +2 -63
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +0 -30
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheOptions.cs +1 -52
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheStamp.cs +3 -78
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +4 -109
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalMode.cs +0 -22
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalQualityEvaluators.cs +1 -36
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalScenario.cs +2 -57
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalSummary.cs +0 -75
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/OfflineChatClient.cs +2 -59
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/ShortPathResponseCache.cs +4 -111
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaGenerator.cs +0 -34
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaProvider.cs +1 -57
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaArtifact.cs +0 -19
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaDisclosure.cs +2 -74
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaGenerator.cs +2 -33
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaIdempotencyKey.cs +1 -43
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJob.cs +1 -96
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobId.cs +0 -13
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobState.cs +0 -27
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaPricing.cs +0 -33
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaProvenance.cs +0 -31
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaRequest.cs +3 -75
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaResult.cs +0 -42
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaReview.cs +0 -39
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaSeams.cs +1 -55
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaStore.cs +3 -59
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MorphMedia.cs +0 -46
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/GoogleImageProvider.cs +3 -28
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/OpenAIImageProvider.cs +7 -61
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/VeoVideoProvider.cs +2 -37
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/IUsageCostSink.cs +1 -23
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostMiddleware.cs +2 -82
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostRecord.cs +1 -68
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphOpenTelemetryExtensions.cs +1 -62
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphTelemetryOptions.cs +2 -62
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/IProviderClientFactory.cs +1 -25
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelAlias.cs +0 -124
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelRegistry.cs +1 -73
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaIngest.cs +1 -66
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaPlan.cs +0 -41
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentFactoryTests.cs +2 -112
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentSpecTests.cs +2 -43
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ConversationStoreTests.cs +5 -110
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/DeltaIngestTests.cs +7 -103
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalAssertionTests.cs +1 -42
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheMissTests.cs +1 -30
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheStampTests.cs +1 -19
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFailuresTests.cs +0 -48
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFixtureTests.cs +1 -29
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalRefreshTests.cs +2 -38
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalWorkspace.cs +1 -14
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/KitEvals.cs +4 -69
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/OfflineChatClientTests.cs +1 -10
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClient.cs +1 -57
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClientTests.cs +0 -26
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeClock.cs +1 -19
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeMediaProvider.cs +0 -32
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeProviderClientFactory.cs +0 -14
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeUsageCostSink.cs +0 -24
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/InMemoryMediaStore.cs +0 -32
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAccessibilityTests.cs +0 -37
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAliasIsNotAnAgentTests.cs +0 -24
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +0 -78
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaGeneratorTests.cs +0 -53
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaIdempotencyKeyTests.cs +0 -44
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaJobStateTests.cs +0 -44
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaReviewTests.cs +0 -19
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaStoreTests.cs +0 -24
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ModelRegistryTests.cs +6 -48
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/SkeletonSmokeTests.cs +1 -13
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/TelemetryTests.cs +2 -71
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/UsageCostMiddlewareTests.cs +5 -100
- package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +39 -43
- package/framework/templates/frontend/nextjs/env.mjs.hbs +29 -32
- package/framework/templates/frontend/nextjs/page.tsx.hbs +21 -22
- package/framework/templates/frontend/nextjs/use-feature.ts.hbs +42 -54
- package/framework/templates/integrations/asaas-client.cs +332 -387
- package/framework/templates/integrations/asaas-webhook.cs +290 -351
- package/framework/templates/integrations/neon-auth-config.cs +9 -105
- package/framework/templates/project/validate.js +97 -120
- package/package.json +2 -2
- package/src/commands/dashboard/dashboard.js +80 -53
- package/src/commands/mcp/mcp-setup.js +37 -9
- package/src/commands/project/doctor.js +3 -5
- package/src/commands/project/init.js +6 -3
- package/src/commands/project/install-plugin-cmd.js +1 -1
- package/src/commands/project/update.js +5 -0
- package/src/dashboard/app/App.jsx +80 -16
- package/src/dashboard/app/components/ActivityFeed.jsx +172 -0
- package/src/dashboard/app/components/CommandPalette.jsx +155 -0
- package/src/dashboard/app/components/DetailPanel.jsx +47 -11
- package/src/dashboard/app/components/EntityLink.jsx +55 -0
- package/src/dashboard/app/components/ErrorBoundary.jsx +54 -0
- package/src/dashboard/app/components/FlowGraph.jsx +19 -17
- package/src/dashboard/app/components/KnowledgeMarkdown.jsx +53 -0
- package/src/dashboard/app/components/Markdown.jsx +47 -0
- package/src/dashboard/app/components/PhaseRail.jsx +111 -0
- package/src/dashboard/app/components/SearchFilter.jsx +40 -22
- package/src/dashboard/app/components/Sidebar.jsx +146 -37
- package/src/dashboard/app/hooks/useMorphQuery.js +54 -0
- package/src/dashboard/app/hooks/usePref.js +38 -0
- package/src/dashboard/app/lib/format.js +69 -0
- package/src/dashboard/app/lib/phases.js +56 -0
- package/src/dashboard/app/lib/project.js +50 -0
- package/src/dashboard/app/pages/Activity.jsx +24 -0
- package/src/dashboard/app/pages/AgentMap.jsx +371 -370
- package/src/dashboard/app/pages/FeatureDetail.jsx +604 -0
- package/src/dashboard/app/pages/Features.jsx +400 -0
- package/src/dashboard/app/pages/Guide.jsx +146 -0
- package/src/dashboard/app/pages/HookInspector.jsx +357 -322
- package/src/dashboard/app/pages/PhasePipeline.jsx +277 -408
- package/src/dashboard/app/pages/Portfolio.jsx +156 -0
- package/src/dashboard/app/pages/Rubrics.jsx +101 -0
- package/src/dashboard/app/pages/RulesMap.jsx +300 -273
- package/src/dashboard/app/pages/SkillsLibrary.jsx +483 -366
- package/src/dashboard/app/pages/Standards.jsx +407 -332
- package/src/dashboard/app/styles/index.css +187 -47
- package/src/dashboard/index.html +14 -12
- package/src/dashboard/package.json +32 -24
- package/src/dashboard/scanner/activity-scanner.js +351 -0
- package/src/dashboard/scanner/agents-scanner.js +59 -1
- package/src/dashboard/scanner/docs-scanner.js +59 -0
- package/src/dashboard/scanner/feature-status.js +10 -0
- package/src/dashboard/scanner/features-scanner.js +360 -0
- package/src/dashboard/scanner/index.js +14 -7
- package/src/dashboard/scanner/phases-scanner.js +14 -15
- package/src/dashboard/scanner/portfolio.js +153 -0
- package/src/dashboard/scanner/project-api.js +195 -0
- package/src/dashboard/scanner/rules-scanner.js +42 -37
- package/src/dashboard/scanner/skills-scanner.js +105 -43
- package/src/dashboard/scanner/standards-scanner.js +2 -0
- package/src/dashboard/vite-plugin-morph-data.js +134 -17
- package/src/lib/detectors/claude-config-detector.js +2 -7
- package/src/lib/detectors/index.js +5 -1
- package/src/lib/evaluator-report.js +22 -0
- package/src/lib/generators/settings-generator.js +208 -209
- package/src/lib/installers/mcp-installer.js +724 -719
- package/src/lib/installers/memory-installer.js +1 -2
- package/src/lib/projects/registry.js +154 -0
- package/src/lib/validators/code-budget/code-budget-validator.js +32 -4
- package/src/scripts/install-plugin.js +1 -1
- package/src/scripts/setup-infra.js +2 -4
- package/src/utils/agents-installer.js +57 -12
- package/src/utils/banner.js +1 -1
- package/src/commands/index.js +0 -13
- package/src/commands/project/checkpoint.js +0 -209
- package/src/core/state/phase-state-machine.js +0 -197
- package/src/dashboard/app/hooks/useDetailPanel.js +0 -15
- package/src/dashboard/app/pages/LiveState.jsx +0 -206
- package/src/dashboard/scanner/squads-scanner.js +0 -13
- package/src/dashboard/scanner/state-scanner.js +0 -85
- package/src/lib/generators/index.js +0 -10
- package/src/lib/hooks/hook-executor.js +0 -167
- package/src/lib/validators/checkpoint-persistence.js +0 -39
- package/src/lib/validators/shared/emit-validator-dispatch.js +0 -14
- package/src/lib/validators/shared/index.js +0 -12
- package/src/lib/validators/shared/issue-counter.js +0 -14
- package/src/lib/validators/shared/result-formatter.js +0 -124
|
@@ -1,366 +1,483 @@
|
|
|
1
|
-
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
<
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
<
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
1
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { Handle, Position } from '@xyflow/react';
|
|
4
|
+
import { Terminal, Robot, UsersThree } from '@phosphor-icons/react';
|
|
5
|
+
import morphData from 'virtual:morph-data';
|
|
6
|
+
import FlowGraph from '../components/FlowGraph.jsx';
|
|
7
|
+
import DetailPanel from '../components/DetailPanel.jsx';
|
|
8
|
+
import SearchFilter from '../components/SearchFilter.jsx';
|
|
9
|
+
import Markdown from '../components/Markdown.jsx';
|
|
10
|
+
import EntityLink, { useSelection, entityHref } from '../components/EntityLink.jsx';
|
|
11
|
+
import { phaseMeta } from '../lib/phases.js';
|
|
12
|
+
import { splitFrontmatter } from '../lib/format.js';
|
|
13
|
+
|
|
14
|
+
const SUPPORT_LABEL = 'Skills de apoio';
|
|
15
|
+
const GENERIC_ID = 'persona:*';
|
|
16
|
+
const GENERIC_LABEL = 'implementadores (morph-{id})';
|
|
17
|
+
const SUPPORT_COLOR = 'var(--color-dim)';
|
|
18
|
+
const PERSONA_COLOR = 'var(--color-ok)';
|
|
19
|
+
|
|
20
|
+
const INVOKE_YES = 'invocável por você';
|
|
21
|
+
const INVOKE_NO = 'só interna';
|
|
22
|
+
|
|
23
|
+
const tint = (color, pct = 14) => `color-mix(in srgb, ${color} ${pct}%, var(--color-core))`;
|
|
24
|
+
|
|
25
|
+
// ─── Nodes ────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
const HANDLE = { width: 7, height: 7, border: 0 };
|
|
28
|
+
|
|
29
|
+
function PhaseNode({ data }) {
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className="w-[220px] cursor-pointer select-none rounded-xl px-4 py-2.5"
|
|
33
|
+
style={{ background: tint(data.color, 18), boxShadow: `inset 0 0 0 1.5px ${data.color}` }}
|
|
34
|
+
>
|
|
35
|
+
<div className="text-[13px] font-semibold leading-tight text-[var(--color-fg)]">{data.label}</div>
|
|
36
|
+
<div className="mt-0.5 text-xs" style={{ color: data.color }}>
|
|
37
|
+
fase{data.optional ? ' opcional' : ''}
|
|
38
|
+
</div>
|
|
39
|
+
<Handle type="source" position={Position.Bottom} style={{ ...HANDLE, background: data.color }} />
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function SkillNode({ data }) {
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
className="w-[220px] cursor-pointer select-none rounded-xl px-3.5 py-2 transition-opacity"
|
|
48
|
+
style={{
|
|
49
|
+
background: tint(data.color, 12),
|
|
50
|
+
boxShadow: `inset 0 0 0 1.5px ${data.color}`,
|
|
51
|
+
opacity: data.dimmed ? 0.2 : 1,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<Handle type="target" position={Position.Top} id="top-in" style={{ ...HANDLE, background: data.color }} />
|
|
55
|
+
<div className="flex items-center gap-1.5">
|
|
56
|
+
<span className="truncate font-mono text-[13px] font-medium text-[var(--color-fg)]" title={data.label}>{data.label}</span>
|
|
57
|
+
{data.userInvocable && <Terminal weight="light" size={13} className="shrink-0 text-[var(--color-dim)]" aria-label="invocável por você" />}
|
|
58
|
+
</div>
|
|
59
|
+
<div className="mt-0.5 text-xs text-[var(--color-dim)]">
|
|
60
|
+
{data.dispatchCount > 0 ? `${data.dispatchCount} prompt${data.dispatchCount > 1 ? 's' : ''} a sub-agents` : data.sub}
|
|
61
|
+
</div>
|
|
62
|
+
<Handle type="source" position={Position.Bottom} id="bottom-out" style={{ ...HANDLE, background: data.color }} />
|
|
63
|
+
<Handle type="source" position={Position.Top} id="top-out" style={{ ...HANDLE, background: data.color, left: '70%' }} />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function PersonaNode({ data }) {
|
|
69
|
+
const Icon = data.generic ? UsersThree : Robot;
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
className="w-[220px] cursor-pointer select-none rounded-full px-4 py-2 transition-opacity"
|
|
73
|
+
style={{
|
|
74
|
+
background: tint(PERSONA_COLOR, 10),
|
|
75
|
+
boxShadow: `inset 0 0 0 1.5px ${PERSONA_COLOR}`,
|
|
76
|
+
opacity: data.dimmed ? 0.25 : 1,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Handle type="target" position={Position.Top} id="top-in" style={{ ...HANDLE, background: PERSONA_COLOR }} />
|
|
80
|
+
<div className="flex items-center gap-2">
|
|
81
|
+
<Icon weight="light" size={15} className="shrink-0 text-[var(--color-ok)]" />
|
|
82
|
+
<span className="truncate font-mono text-[13px] text-[var(--color-fg)]" title={data.label}>{data.label}</span>
|
|
83
|
+
</div>
|
|
84
|
+
<Handle type="target" position={Position.Bottom} id="bottom-in" style={{ ...HANDLE, background: PERSONA_COLOR }} />
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function GroupNode({ data }) {
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
className="pointer-events-none rounded-2xl"
|
|
93
|
+
style={{ width: data.width, height: data.height, boxShadow: 'inset 0 0 0 1px var(--color-hair-strong)', background: 'rgb(255 255 255 / 0.015)' }}
|
|
94
|
+
>
|
|
95
|
+
<div className="px-4 pt-3 text-[13px] font-medium text-[var(--color-dim)]">{data.label}</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const nodeTypes = { phaseNode: PhaseNode, skillNode: SkillNode, personaNode: PersonaNode, groupNode: GroupNode };
|
|
101
|
+
|
|
102
|
+
// ─── Graph model ──────────────────────────────────────────────────────────────
|
|
103
|
+
|
|
104
|
+
/** The phase a skill belongs to: its own `phase`, or the phase whose `skill` it is. */
|
|
105
|
+
function skillPhaseOf(skill, phases) {
|
|
106
|
+
if (skill.phase) return skill.phase;
|
|
107
|
+
return phases.find((p) => p.skill === skill.id)?.id || null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The persona targets of a skill's dispatches: generic ones go to the one "implementadores" node. */
|
|
111
|
+
function dispatchTargets(skill) {
|
|
112
|
+
const out = new Set();
|
|
113
|
+
for (const d of skill.dispatches || []) {
|
|
114
|
+
if (d.generic) out.add(GENERIC_ID);
|
|
115
|
+
else for (const p of d.personas || []) out.add(p);
|
|
116
|
+
}
|
|
117
|
+
return [...out];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const COL = 250;
|
|
121
|
+
const ROW_PHASE = 0;
|
|
122
|
+
const ROW_SKILL = 120;
|
|
123
|
+
const ROW_PERSONA = 290;
|
|
124
|
+
const ROW_SUPPORT = 440;
|
|
125
|
+
const SUPPORT_PER_ROW = 5;
|
|
126
|
+
|
|
127
|
+
function buildGraph({ skills, phases, agents, isMatch, hasFilter }) {
|
|
128
|
+
const nodes = [];
|
|
129
|
+
const edges = [];
|
|
130
|
+
const phaseSkills = new Map(); // phaseId → skill[]
|
|
131
|
+
const support = [];
|
|
132
|
+
for (const s of skills) {
|
|
133
|
+
const ph = skillPhaseOf(s, phases);
|
|
134
|
+
if (ph && phases.some((p) => p.id === ph)) {
|
|
135
|
+
if (!phaseSkills.has(ph)) phaseSkills.set(ph, []);
|
|
136
|
+
phaseSkills.get(ph).push(s);
|
|
137
|
+
} else support.push(s);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Row 0 + 1: one column per phase, its skill(s) below it.
|
|
141
|
+
phases.forEach((p, i) => {
|
|
142
|
+
const meta = phaseMeta(p.id);
|
|
143
|
+
const x = i * COL;
|
|
144
|
+
nodes.push({
|
|
145
|
+
id: `phase:${p.id}`, type: 'phaseNode', position: { x, y: ROW_PHASE },
|
|
146
|
+
data: { label: meta.label, color: meta.color, optional: p.optional, phaseId: p.id },
|
|
147
|
+
});
|
|
148
|
+
(phaseSkills.get(p.id) || []).forEach((s, j) => {
|
|
149
|
+
nodes.push(skillNode(s, x, ROW_SKILL + j * 70, meta.color, meta.label));
|
|
150
|
+
edges.push({
|
|
151
|
+
id: `e:phase:${p.id}->${s.id}`, source: `phase:${p.id}`, target: s.id, targetHandle: 'top-in',
|
|
152
|
+
style: { stroke: meta.color, strokeWidth: 1.5, opacity: hasFilter && !isMatch(s) ? 0.12 : 0.8 },
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Row 3+: the support skills, in a labelled group under the personas.
|
|
158
|
+
const supportCols = Math.min(SUPPORT_PER_ROW, Math.max(1, support.length));
|
|
159
|
+
const supportRows = Math.ceil(support.length / supportCols);
|
|
160
|
+
const supportWidth = supportCols * COL;
|
|
161
|
+
const gridWidth = Math.max(phases.length * COL, supportWidth);
|
|
162
|
+
const supportX0 = (gridWidth - supportWidth) / 2;
|
|
163
|
+
if (support.length) {
|
|
164
|
+
nodes.push({
|
|
165
|
+
id: 'group:support', type: 'groupNode', position: { x: supportX0 - 15, y: ROW_SUPPORT - 45 },
|
|
166
|
+
data: { label: `${SUPPORT_LABEL} (fora do pipeline de fases)`, width: supportWidth, height: supportRows * 80 + 45 },
|
|
167
|
+
selectable: false, draggable: false, focusable: false, zIndex: -1,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
support.forEach((s, i) => {
|
|
171
|
+
const x = supportX0 + (i % supportCols) * COL;
|
|
172
|
+
const y = ROW_SUPPORT + Math.floor(i / supportCols) * 80;
|
|
173
|
+
nodes.push(skillNode(s, x, y, SUPPORT_COLOR, SUPPORT_LABEL));
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Row 2: the personas the skills dispatch prompts to.
|
|
177
|
+
const personaIds = new Set();
|
|
178
|
+
for (const s of skills) for (const t of dispatchTargets(s)) personaIds.add(t);
|
|
179
|
+
const agentOrder = agents.map((a) => a.id);
|
|
180
|
+
const personas = [...personaIds].sort((a, b) => {
|
|
181
|
+
if (a === GENERIC_ID) return 1;
|
|
182
|
+
if (b === GENERIC_ID) return -1;
|
|
183
|
+
return (agentOrder.indexOf(a) + 1 || 99) - (agentOrder.indexOf(b) + 1 || 99);
|
|
184
|
+
});
|
|
185
|
+
const personaX0 = (gridWidth - personas.length * COL) / 2;
|
|
186
|
+
personas.forEach((pid, i) => {
|
|
187
|
+
const touched = skills.filter((s) => dispatchTargets(s).includes(pid));
|
|
188
|
+
nodes.push({
|
|
189
|
+
id: `persona:${pid}`, type: 'personaNode', position: { x: personaX0 + i * COL, y: ROW_PERSONA },
|
|
190
|
+
data: {
|
|
191
|
+
label: pid === GENERIC_ID ? GENERIC_LABEL : `morph-${pid}`,
|
|
192
|
+
personaId: pid === GENERIC_ID ? null : pid,
|
|
193
|
+
generic: pid === GENERIC_ID,
|
|
194
|
+
color: PERSONA_COLOR,
|
|
195
|
+
dimmed: hasFilter && !touched.some(isMatch),
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// skill → persona, from the dispatch prompts.
|
|
201
|
+
const supportIds = new Set(support.map((s) => s.id));
|
|
202
|
+
for (const s of skills) {
|
|
203
|
+
const fromSupport = supportIds.has(s.id);
|
|
204
|
+
for (const pid of dispatchTargets(s)) {
|
|
205
|
+
edges.push({
|
|
206
|
+
id: `e:${s.id}->persona:${pid}`,
|
|
207
|
+
source: s.id, sourceHandle: fromSupport ? 'top-out' : 'bottom-out',
|
|
208
|
+
target: `persona:${pid}`, targetHandle: fromSupport ? 'bottom-in' : 'top-in',
|
|
209
|
+
style: { stroke: PERSONA_COLOR, strokeWidth: 1.25, strokeDasharray: '5 4', opacity: hasFilter && !isMatch(s) ? 0.1 : 0.6 },
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return { nodes, edges, supportCount: support.length, linkedCount: skills.length - support.length };
|
|
215
|
+
|
|
216
|
+
function skillNode(s, x, y, color, sub) {
|
|
217
|
+
return {
|
|
218
|
+
id: s.id, type: 'skillNode', position: { x, y },
|
|
219
|
+
data: {
|
|
220
|
+
label: s.id, sub, color, skillId: s.id,
|
|
221
|
+
userInvocable: Boolean(s.userInvocable),
|
|
222
|
+
dispatchCount: (s.dispatches || []).length,
|
|
223
|
+
dimmed: hasFilter && !isMatch(s),
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ─── Detail ───────────────────────────────────────────────────────────────────
|
|
230
|
+
|
|
231
|
+
function Section({ title, children }) {
|
|
232
|
+
return (
|
|
233
|
+
<section className="space-y-2">
|
|
234
|
+
<h3 className="text-xs font-medium text-[var(--color-faint)]">{title}</h3>
|
|
235
|
+
{children}
|
|
236
|
+
</section>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function PromptBlock({ text, label = 'Prompt enviado ao sub-agent' }) {
|
|
241
|
+
return (
|
|
242
|
+
<div
|
|
243
|
+
className="overflow-hidden rounded-xl"
|
|
244
|
+
style={{ background: tint('var(--color-phase-implement)', 8), boxShadow: 'inset 0 0 0 1px color-mix(in srgb, var(--color-phase-implement) 45%, transparent)' }}
|
|
245
|
+
>
|
|
246
|
+
<div className="flex items-center gap-1.5 border-b border-[var(--color-hair)] px-3 py-1.5 text-xs text-[var(--color-phase-implement)]">
|
|
247
|
+
<Robot weight="light" size={14} />
|
|
248
|
+
{label}
|
|
249
|
+
</div>
|
|
250
|
+
<pre className="m-0 overflow-x-auto whitespace-pre-wrap px-3 py-2.5 font-mono text-xs leading-relaxed text-[var(--color-fg)]">{text}</pre>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Plain text of a hast node (the `node` react-markdown hands to overrides). */
|
|
256
|
+
function hastText(node) {
|
|
257
|
+
if (!node) return '';
|
|
258
|
+
if (node.type === 'text') return node.value || '';
|
|
259
|
+
return (node.children || []).map(hastText).join('');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function isDispatchBlock(text) {
|
|
263
|
+
const t = text.trimStart();
|
|
264
|
+
return t.startsWith('dispatch Agent') || t.includes('subagent_type');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const SKILL_MD_COMPONENTS = {
|
|
268
|
+
pre({ node, ...rest }) {
|
|
269
|
+
const text = hastText(node);
|
|
270
|
+
if (isDispatchBlock(text)) return <PromptBlock text={text.replace(/\n$/, '')} />;
|
|
271
|
+
return <pre {...rest} />;
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
function DispatchItem({ d }) {
|
|
276
|
+
const personas = d.personas || [];
|
|
277
|
+
return (
|
|
278
|
+
<li className="space-y-2 rounded-xl bg-white/[0.02] p-3 shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
279
|
+
<div className="flex flex-wrap items-center gap-1.5 text-xs text-[var(--color-dim)]">
|
|
280
|
+
<span>Para</span>
|
|
281
|
+
{d.generic ? (
|
|
282
|
+
<span className="rounded-full px-2 py-0.5 font-mono text-xs text-[var(--color-fg)] shadow-[inset_0_0_0_1px_var(--color-hair-strong)]">
|
|
283
|
+
qualquer implementador (morph-{'{id}'})
|
|
284
|
+
</span>
|
|
285
|
+
) : personas.length ? (
|
|
286
|
+
personas.map((p) => <EntityLink key={p} kind="persona" id={p} chip>{`morph-${p}`}</EntityLink>)
|
|
287
|
+
) : d.builtin?.length ? (
|
|
288
|
+
d.builtin.map((b) => (
|
|
289
|
+
<span key={b} className="rounded-full px-2 py-0.5 font-mono text-xs text-[var(--color-fg)] shadow-[inset_0_0_0_1px_var(--color-hair-strong)]" title="sub-agent nativo do Claude Code, não uma persona do morph-spec">
|
|
290
|
+
{b}
|
|
291
|
+
</span>
|
|
292
|
+
))
|
|
293
|
+
) : (
|
|
294
|
+
<span>sub-agent não identificado</span>
|
|
295
|
+
)}
|
|
296
|
+
</div>
|
|
297
|
+
{d.context && (
|
|
298
|
+
<div className="text-sm text-[var(--color-dim)]">
|
|
299
|
+
<Markdown text={d.context} size="sm" />
|
|
300
|
+
</div>
|
|
301
|
+
)}
|
|
302
|
+
{d.text && <PromptBlock text={d.text} />}
|
|
303
|
+
</li>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function SkillDetail({ skill, phases = morphData.phases?.list || [] }) {
|
|
308
|
+
const phaseId = skillPhaseOf(skill, phases);
|
|
309
|
+
const dispatches = skill.dispatches || [];
|
|
310
|
+
const stacks = skill.stacks || [];
|
|
311
|
+
const body = useMemo(() => splitFrontmatter(skill.content || '').body, [skill.content]);
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<div className="space-y-6 text-sm text-[var(--color-dim)]">
|
|
315
|
+
{skill.description && <p className="leading-relaxed text-[var(--color-fg)]">{skill.description}</p>}
|
|
316
|
+
|
|
317
|
+
<dl className="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-2 rounded-xl bg-white/[0.03] px-4 py-3 shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
318
|
+
{skill.whenToInvoke && (
|
|
319
|
+
<>
|
|
320
|
+
<dt className="text-xs leading-6 text-[var(--color-faint)]">Quando usar</dt>
|
|
321
|
+
<dd className="leading-6">{skill.whenToInvoke}</dd>
|
|
322
|
+
</>
|
|
323
|
+
)}
|
|
324
|
+
<dt className="text-xs leading-6 text-[var(--color-faint)]">Fase</dt>
|
|
325
|
+
<dd className="leading-6">
|
|
326
|
+
{phaseId
|
|
327
|
+
? <EntityLink kind="phase" id={phaseId}>{phaseMeta(phaseId).label}</EntityLink>
|
|
328
|
+
: <span>Skill de apoio (não pertence a uma fase)</span>}
|
|
329
|
+
</dd>
|
|
330
|
+
<dt className="text-xs leading-6 text-[var(--color-faint)]">Invocação</dt>
|
|
331
|
+
<dd className="leading-6">
|
|
332
|
+
{skill.userInvocable
|
|
333
|
+
? <>você pode rodar <code className="rounded bg-white/[0.06] px-1.5 py-0.5 font-mono text-xs text-[var(--color-fg)]">/{skill.id}</code></>
|
|
334
|
+
: 'interna: o orquestrador a carrega, você não a chama direto'}
|
|
335
|
+
</dd>
|
|
336
|
+
{stacks.length > 0 && (
|
|
337
|
+
<>
|
|
338
|
+
<dt className="text-xs leading-6 text-[var(--color-faint)]">Stacks</dt>
|
|
339
|
+
<dd className="flex flex-wrap gap-1.5 py-0.5">
|
|
340
|
+
{stacks.map((s) => (
|
|
341
|
+
<span key={s} className="rounded-full px-2 py-0.5 font-mono text-xs shadow-[inset_0_0_0_1px_var(--color-hair)]">{s}</span>
|
|
342
|
+
))}
|
|
343
|
+
</dd>
|
|
344
|
+
</>
|
|
345
|
+
)}
|
|
346
|
+
{skill.allowedTools?.length > 0 && (
|
|
347
|
+
<>
|
|
348
|
+
<dt className="text-xs leading-6 text-[var(--color-faint)]">Ferramentas</dt>
|
|
349
|
+
<dd className="flex flex-wrap gap-1.5 py-0.5">
|
|
350
|
+
{skill.allowedTools.map((t) => (
|
|
351
|
+
<span key={t} className="rounded-full px-2 py-0.5 font-mono text-xs shadow-[inset_0_0_0_1px_var(--color-hair)]">{t}</span>
|
|
352
|
+
))}
|
|
353
|
+
</dd>
|
|
354
|
+
</>
|
|
355
|
+
)}
|
|
356
|
+
</dl>
|
|
357
|
+
|
|
358
|
+
{dispatches.length > 0 && (
|
|
359
|
+
<Section title={`Prompts enviados a sub-agents (${dispatches.length})`}>
|
|
360
|
+
<ul className="space-y-3">
|
|
361
|
+
{dispatches.map((d) => <DispatchItem key={d.index} d={d} />)}
|
|
362
|
+
</ul>
|
|
363
|
+
</Section>
|
|
364
|
+
)}
|
|
365
|
+
|
|
366
|
+
{body.trim() && (
|
|
367
|
+
<Section title="SKILL.md completo">
|
|
368
|
+
<Markdown text={body} size="sm" components={SKILL_MD_COMPONENTS} />
|
|
369
|
+
</Section>
|
|
370
|
+
)}
|
|
371
|
+
</div>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ─── Page ─────────────────────────────────────────────────────────────────────
|
|
376
|
+
|
|
377
|
+
export default function SkillsLibrary() {
|
|
378
|
+
const skills = morphData.skills || [];
|
|
379
|
+
const phases = morphData.phases?.list || [];
|
|
380
|
+
const agents = morphData.agents?.list || [];
|
|
381
|
+
const navigate = useNavigate();
|
|
382
|
+
const [sel, setSel] = useSelection();
|
|
383
|
+
const [search, setSearch] = useState('');
|
|
384
|
+
const [phaseFilter, setPhaseFilter] = useState('');
|
|
385
|
+
const [invokeFilter, setInvokeFilter] = useState('');
|
|
386
|
+
|
|
387
|
+
const phaseOptions = useMemo(() => [...phases.map((p) => phaseMeta(p.id).label), SUPPORT_LABEL], [phases]);
|
|
388
|
+
|
|
389
|
+
const isMatch = useCallback((s) => {
|
|
390
|
+
const q = search.trim().toLowerCase();
|
|
391
|
+
if (q) {
|
|
392
|
+
const hay = [s.id, s.name, s.description, s.whenToInvoke].filter(Boolean).join(' ').toLowerCase();
|
|
393
|
+
if (!hay.includes(q)) return false;
|
|
394
|
+
}
|
|
395
|
+
if (phaseFilter) {
|
|
396
|
+
const ph = skillPhaseOf(s, phases);
|
|
397
|
+
const label = ph ? phaseMeta(ph).label : SUPPORT_LABEL;
|
|
398
|
+
if (label !== phaseFilter) return false;
|
|
399
|
+
}
|
|
400
|
+
if (invokeFilter === INVOKE_YES && !s.userInvocable) return false;
|
|
401
|
+
if (invokeFilter === INVOKE_NO && s.userInvocable) return false;
|
|
402
|
+
return true;
|
|
403
|
+
}, [search, phaseFilter, invokeFilter, phases]);
|
|
404
|
+
|
|
405
|
+
const hasFilter = Boolean(search.trim() || phaseFilter || invokeFilter);
|
|
406
|
+
const matchCount = useMemo(() => skills.filter(isMatch).length, [skills, isMatch]);
|
|
407
|
+
|
|
408
|
+
const graph = useMemo(
|
|
409
|
+
() => buildGraph({ skills, phases, agents, isMatch, hasFilter }),
|
|
410
|
+
[skills, phases, agents, isMatch, hasFilter],
|
|
411
|
+
);
|
|
412
|
+
const dispatchingCount = skills.filter((s) => (s.dispatches || []).length > 0).length;
|
|
413
|
+
|
|
414
|
+
const selected = sel ? skills.find((s) => s.id === sel) : null;
|
|
415
|
+
const selectedPhase = selected ? skillPhaseOf(selected, phases) : null;
|
|
416
|
+
const close = useCallback(() => setSel(null), [setSel]);
|
|
417
|
+
|
|
418
|
+
const onNodeClick = useCallback((_e, node) => {
|
|
419
|
+
if (node.type === 'skillNode') setSel(node.data.skillId);
|
|
420
|
+
else if (node.type === 'phaseNode') navigate(entityHref('phase', node.data.phaseId));
|
|
421
|
+
else if (node.type === 'personaNode' && node.data.personaId) navigate(entityHref('persona', node.data.personaId));
|
|
422
|
+
}, [setSel, navigate]);
|
|
423
|
+
|
|
424
|
+
const filters = [
|
|
425
|
+
{ name: 'phase', label: 'Fase', options: phaseOptions, value: phaseFilter },
|
|
426
|
+
{ name: 'invoke', label: 'Invocação', options: [INVOKE_YES, INVOKE_NO], value: invokeFilter },
|
|
427
|
+
];
|
|
428
|
+
|
|
429
|
+
return (
|
|
430
|
+
<div className="flex h-full flex-col">
|
|
431
|
+
<SearchFilter
|
|
432
|
+
placeholder="Buscar skill por nome, descrição ou quando usar"
|
|
433
|
+
filters={filters}
|
|
434
|
+
onSearchChange={setSearch}
|
|
435
|
+
onFilterChange={(name, value) => {
|
|
436
|
+
if (name === 'phase') setPhaseFilter(value);
|
|
437
|
+
if (name === 'invoke') setInvokeFilter(value);
|
|
438
|
+
}}
|
|
439
|
+
/>
|
|
440
|
+
|
|
441
|
+
<div className="relative flex-1">
|
|
442
|
+
<FlowGraph nodes={graph.nodes} edges={graph.edges} nodeTypes={nodeTypes} onNodeClick={onNodeClick} fitView />
|
|
443
|
+
|
|
444
|
+
<div className="absolute left-3 top-3 z-10 space-y-2 rounded-xl bg-[var(--color-ink)]/85 p-3 text-xs text-[var(--color-dim)] shadow-[inset_0_0_0_1px_var(--color-hair)] backdrop-blur">
|
|
445
|
+
<p className="text-[13px] font-medium text-[var(--color-fg)]">Legenda</p>
|
|
446
|
+
<div className="flex items-center gap-2">
|
|
447
|
+
<span className="inline-block h-3 w-8 rounded" style={{ boxShadow: 'inset 0 0 0 1.5px var(--color-phase-plan)' }} />
|
|
448
|
+
fase → skill que a conduz
|
|
449
|
+
</div>
|
|
450
|
+
<div className="flex items-center gap-2">
|
|
451
|
+
<span className="inline-block h-3 w-8 rounded" style={{ boxShadow: `inset 0 0 0 1.5px ${SUPPORT_COLOR}` }} />
|
|
452
|
+
skill de apoio (sem fase)
|
|
453
|
+
</div>
|
|
454
|
+
<div className="flex items-center gap-2">
|
|
455
|
+
<span className="inline-block w-8 border-t-2 border-dashed" style={{ borderColor: PERSONA_COLOR }} />
|
|
456
|
+
skill → sub-agent que ela despacha
|
|
457
|
+
</div>
|
|
458
|
+
<div className="flex items-center gap-2">
|
|
459
|
+
<Terminal weight="light" size={13} className="ml-2.5 mr-2.5" />
|
|
460
|
+
você pode rodar com /nome
|
|
461
|
+
</div>
|
|
462
|
+
</div>
|
|
463
|
+
|
|
464
|
+
<div className="absolute right-3 top-3 z-10 space-y-0.5 rounded-xl bg-[var(--color-ink)]/85 px-3 py-2 text-xs text-[var(--color-dim)] shadow-[inset_0_0_0_1px_var(--color-hair)] backdrop-blur">
|
|
465
|
+
<div className="text-[13px] text-[var(--color-fg)]">
|
|
466
|
+
{hasFilter ? `${matchCount} de ${skills.length} skills` : `${skills.length} skills`}
|
|
467
|
+
</div>
|
|
468
|
+
<div>{graph.linkedCount} conduzem uma fase · {graph.supportCount} de apoio</div>
|
|
469
|
+
<div>{dispatchingCount} despacham sub-agents</div>
|
|
470
|
+
</div>
|
|
471
|
+
</div>
|
|
472
|
+
|
|
473
|
+
<DetailPanel
|
|
474
|
+
open={Boolean(selected)}
|
|
475
|
+
title={selected?.name || ''}
|
|
476
|
+
subtitle={selected ? (selectedPhase ? `Skill da fase ${phaseMeta(selectedPhase).label}` : 'Skill de apoio') : ''}
|
|
477
|
+
onClose={close}
|
|
478
|
+
>
|
|
479
|
+
{selected && <SkillDetail skill={selected} phases={phases} />}
|
|
480
|
+
</DetailPanel>
|
|
481
|
+
</div>
|
|
482
|
+
);
|
|
483
|
+
}
|