@polymorphism-tech/morph-spec 8.37.1 → 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 +37 -13
- package/README.md +2 -2
- package/bin/morph-spec.js +75 -49
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +6 -5
- package/framework/MORPH.md +25 -22
- package/framework/agents.json +96 -36
- package/framework/docs/CLI.md +54 -17
- package/framework/evals/rubrics/code-quality.md +5 -0
- package/framework/evals/rubrics/condensed.md +6 -2
- package/framework/evals/rubrics/contracts.md +20 -0
- package/framework/evals/rubrics/test-coverage.md +17 -6
- package/framework/hooks/README.md +9 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +52 -0
- package/framework/hooks/claude-code/core/telemetry-log.js +172 -87
- package/framework/hooks/claude-code/core/validate-completion.js +16 -90
- package/framework/hooks/claude-code/core/worktree-context.js +10 -0
- package/framework/hooks/shared/command-tokens.js +96 -0
- package/framework/hooks/shared/git-exclude.js +44 -0
- package/framework/hooks/shared/git-paths.js +52 -0
- package/framework/hooks/shared/graph-freshness.js +380 -0
- package/framework/hooks/shared/graph-refresh.js +416 -0
- package/framework/hooks/shared/morph-cli.js +17 -5
- package/framework/hooks/shared/redact-secrets.js +55 -0
- package/framework/hooks/shared/telemetry-logger.js +25 -2
- package/framework/hooks/shared/transcript-usage.js +80 -0
- package/framework/mcp/registry.json +33 -2
- package/framework/rubrics/backend.json +2 -2
- package/framework/rubrics/default.json +2 -2
- package/framework/rubrics/frontend.json +2 -2
- package/framework/rules/csharp-standards.md +1 -0
- package/framework/rules/infrastructure-standards.md +0 -1
- package/framework/rules/morph-workflow.md +10 -4
- package/framework/rules/nextjs-standards.md +1 -0
- package/framework/schemas/config.schema.json +41 -1
- package/framework/schemas/feature.schema.json +5 -1
- 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 +40 -11
- package/framework/skills/core/morph-brainstorming/SKILL.md +16 -7
- 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 +44 -10
- package/framework/skills/core/morph-media/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +73 -15
- package/framework/skills/core/morph-proposal/SKILL.md +1 -1
- package/framework/skills/core/morph-review/SKILL.md +51 -13
- 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 +39 -13
- package/framework/standards/STANDARDS.json +189 -14
- 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/ai-agents/testing-ai.md +2 -1
- package/framework/standards/architecture/code-comments.md +100 -0
- package/framework/standards/backend/dotnet/testing.md +22 -0
- package/framework/standards/backend/integrations/neon-auth/neon-auth.md +63 -50
- package/framework/standards/frontend/admin-app/data-table.md +562 -0
- package/framework/standards/frontend/admin-app/feedback.md +236 -0
- package/framework/standards/frontend/admin-app/forms.md +232 -0
- package/framework/standards/frontend/admin-app/page-structure.md +203 -0
- package/framework/standards/frontend/design-system/ai-image-generation.md +5 -5
- package/framework/standards/frontend/nextjs/components.md +37 -58
- package/framework/standards/frontend/nextjs/data-fetching.md +1 -0
- package/framework/standards/frontend/nextjs/forms.md +31 -30
- package/framework/standards/frontend/nextjs/state-management.md +2 -1
- package/framework/standards/frontend/nextjs/testing.md +18 -0
- 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/context/design-system.md +3 -3
- package/framework/templates/docs/proposal.md +11 -0
- package/framework/templates/docs/spec.md +15 -0
- package/framework/templates/docs/ui-mockups.md +115 -98
- 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/feature/decisions.md +124 -122
- 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/graph/affected.js +4 -3
- package/src/commands/graph/build.js +109 -18
- package/src/commands/graph/explain.js +8 -5
- package/src/commands/graph/status.js +14 -8
- package/src/commands/mcp/mcp-setup.js +37 -9
- package/src/commands/observability/cost.js +148 -18
- package/src/commands/project/doctor.js +85 -15
- package/src/commands/project/init.js +6 -3
- package/src/commands/project/install-plugin-cmd.js +1 -1
- package/src/commands/project/update.js +30 -0
- package/src/commands/project/worktree.js +73 -90
- package/src/commands/state/advance.js +18 -0
- package/src/commands/state/approve.js +15 -0
- package/src/commands/state/archive.js +62 -9
- package/src/commands/state/finish.js +62 -14
- package/src/commands/state/gate-check.js +8 -1
- package/src/commands/state/gate-decision.js +8 -4
- package/src/commands/state/report-check.js +90 -9
- package/src/commands/state/usecase.js +66 -0
- package/src/commands/tasks/dag.js +17 -2
- package/src/commands/validation/validate-feature.js +6 -1
- package/src/commands/validation/verify.js +20 -1
- 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 +63 -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/hooks-scanner.js +8 -1
- 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 +4 -1
- package/src/dashboard/vite-plugin-morph-data.js +134 -17
- package/src/lib/ai/comment-stripper.js +101 -4
- package/src/lib/detectors/claude-config-detector.js +2 -7
- package/src/lib/detectors/index.js +5 -1
- package/src/lib/evaluator-report.js +47 -0
- package/src/lib/generators/handoff-generator.js +4 -18
- package/src/lib/generators/settings-generator.js +208 -209
- package/src/lib/git/default-branch.js +52 -0
- package/src/lib/git/tree-fingerprint.js +58 -0
- package/src/lib/git/tree-state.js +167 -0
- package/src/lib/graph/god-nodes.js +12 -3
- package/src/lib/graph/graph-health.js +48 -2
- package/src/lib/graph/graph-loader.js +99 -25
- package/src/lib/graph/graphifyignore.js +145 -28
- package/src/lib/graph/sanitize.js +117 -11
- 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/risk-detector.js +90 -0
- package/src/lib/specs/acervo-format.js +70 -0
- package/src/lib/specs/acervo-lifecycle.js +264 -0
- package/src/lib/specs/adr-index.js +169 -0
- package/src/lib/specs/revocations.js +156 -0
- package/src/lib/specs/screen-checklist.js +357 -0
- package/src/lib/specs/usecase-check.js +20 -16
- package/src/lib/specs/usecase-promoter.js +103 -38
- package/src/lib/specs/usecase-registry.js +7 -7
- package/src/lib/tasks/tasks-json-parser.js +2 -3
- package/src/lib/telemetry/metrics.js +386 -0
- package/src/lib/telemetry/telemetry-reader.js +161 -51
- package/src/lib/telemetry/verify-event.js +79 -0
- package/src/lib/validators/code-budget/code-budget-validator.js +200 -0
- package/src/lib/validators/code-budget/comment-scanner.js +75 -0
- package/src/lib/validators/code-budget/index.js +9 -0
- package/src/lib/validators/reuse/reuse-validator.js +4 -2
- package/src/lib/validators/reuse/symbol-scanner.js +27 -22
- package/src/lib/validators/validation-runner.js +21 -5
- package/src/lib/validators/verify-runner.js +11 -0
- package/src/lib/worktree/finish-backup.js +739 -0
- package/src/lib/worktree/ignored-triage.js +15 -8
- package/src/lib/worktree/worktree-audit.js +5 -0
- package/src/scripts/install-plugin.js +1 -1
- package/src/scripts/setup-infra.js +31 -22
- package/src/utils/agents-installer.js +338 -24
- package/src/utils/banner.js +1 -1
- package/src/utils/hooks-installer.js +75 -15
- 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,370 +1,371 @@
|
|
|
1
|
-
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
-
import { Handle, Position } from '@xyflow/react';
|
|
3
|
-
import dagre from '@dagrejs/dagre';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
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
|
-
const
|
|
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
|
-
</div>
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
{
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
1
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { Handle, Position } from '@xyflow/react';
|
|
3
|
+
import dagre from '@dagrejs/dagre';
|
|
4
|
+
import { UserCircle, Robot } 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 } from '../components/EntityLink.jsx';
|
|
11
|
+
import { phaseMeta } from '../lib/phases.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `agents.json → color` is a color NAME (blue, cyan…), the one Claude Code
|
|
15
|
+
* paints the sub-agent with. The map reads the same name, so a persona looks
|
|
16
|
+
* the same here and in the terminal.
|
|
17
|
+
*/
|
|
18
|
+
const COLOR_HEX = {
|
|
19
|
+
blue: '#60a5fa',
|
|
20
|
+
cyan: '#22d3ee',
|
|
21
|
+
purple: '#a78bfa',
|
|
22
|
+
green: '#34d399',
|
|
23
|
+
magenta: '#f472b6',
|
|
24
|
+
yellow: '#fbbf24',
|
|
25
|
+
red: '#f87171',
|
|
26
|
+
gray: '#9ca3af',
|
|
27
|
+
orange: '#fb923c',
|
|
28
|
+
pink: '#f472b6',
|
|
29
|
+
};
|
|
30
|
+
const FALLBACK_HEX = '#9ca3af';
|
|
31
|
+
|
|
32
|
+
/** The ONE color lookup: nodes, edges, detail badge and legend all read it. */
|
|
33
|
+
const personaColor = (agent) => COLOR_HEX[agent?.color] || FALLBACK_HEX;
|
|
34
|
+
|
|
35
|
+
/** `'*'` in a persona's `stack` means "every stack" — it is not a stack of its own. */
|
|
36
|
+
const UNIVERSAL_STACK = '*';
|
|
37
|
+
|
|
38
|
+
/** The node of the human + main thread. Never a persona id. */
|
|
39
|
+
const PRINCIPAL_ID = 'principal';
|
|
40
|
+
|
|
41
|
+
const NODE_W = 220;
|
|
42
|
+
const NODE_H = 64;
|
|
43
|
+
|
|
44
|
+
function AgentNode({ data }) {
|
|
45
|
+
const color = data.color;
|
|
46
|
+
const Icon = data.isUser ? UserCircle : Robot;
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
className="fluid flex cursor-pointer select-none items-start gap-2.5 rounded-xl bg-[var(--color-raised)] px-3.5 py-2.5 transition-shadow hover:shadow-[0_0_0_1px_var(--color-hair-strong)]"
|
|
50
|
+
style={{
|
|
51
|
+
width: NODE_W,
|
|
52
|
+
boxShadow: data.selected ? `0 0 0 2px ${color}` : `inset 0 0 0 1px var(--color-hair)`,
|
|
53
|
+
borderLeft: `3px solid ${color}`,
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Handle type="target" position={Position.Top} style={{ background: color, width: 7, height: 7, border: 0 }} />
|
|
57
|
+
<Icon weight="light" size={18} className="mt-0.5 shrink-0" style={{ color }} />
|
|
58
|
+
<div className="min-w-0">
|
|
59
|
+
<div className="text-[13px] font-semibold leading-snug text-[var(--color-fg)]" title={data.label}>
|
|
60
|
+
{data.label}
|
|
61
|
+
</div>
|
|
62
|
+
<div className="mt-0.5 truncate text-[12px] text-[var(--color-dim)]">{data.sub}</div>
|
|
63
|
+
</div>
|
|
64
|
+
<Handle type="source" position={Position.Bottom} style={{ background: color, width: 7, height: 7, border: 0 }} />
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const nodeTypes = { agentNode: AgentNode };
|
|
70
|
+
|
|
71
|
+
function buildLayout(nodes, edges) {
|
|
72
|
+
const g = new dagre.graphlib.Graph();
|
|
73
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
74
|
+
g.setGraph({ rankdir: 'TB', nodesep: 28, ranksep: 80, marginx: 20, marginy: 20 });
|
|
75
|
+
nodes.forEach((n) => g.setNode(n.id, { width: NODE_W, height: NODE_H }));
|
|
76
|
+
edges.forEach((e) => g.setEdge(e.source, e.target));
|
|
77
|
+
dagre.layout(g);
|
|
78
|
+
return nodes.map((n) => {
|
|
79
|
+
const pos = g.node(n.id);
|
|
80
|
+
return { ...n, position: { x: pos.x - NODE_W / 2, y: pos.y - NODE_H / 2 } };
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Skills whose dispatch lines name this persona, or dispatch any implementer. */
|
|
85
|
+
function dispatchingSkills(agent) {
|
|
86
|
+
const implementer = (agent.activePhases || []).includes('implement');
|
|
87
|
+
return (morphData.skills || []).filter((s) => (s.dispatches || []).some(
|
|
88
|
+
(d) => (d.personas || []).includes(agent.id) || (d.generic && implementer),
|
|
89
|
+
));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function toolsText(tools) {
|
|
93
|
+
if (!tools || (Array.isArray(tools) && tools.length === 0)) return 'todas as da sessão (herda)';
|
|
94
|
+
return Array.isArray(tools) ? tools.join(', ') : String(tools);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function Section({ title, children }) {
|
|
98
|
+
return (
|
|
99
|
+
<section>
|
|
100
|
+
<h3 className="mb-2 text-xs font-medium text-[var(--color-faint)]">{title}</h3>
|
|
101
|
+
{children}
|
|
102
|
+
</section>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function Chip({ children, mono = false }) {
|
|
107
|
+
return (
|
|
108
|
+
<span className={`inline-flex items-center rounded-full px-2 py-0.5 text-[12px] text-[var(--color-dim)] shadow-[inset_0_0_0_1px_var(--color-hair)] ${mono ? 'font-mono' : ''}`}>
|
|
109
|
+
{children}
|
|
110
|
+
</span>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Exported for the render smoke test: no page state, only the persona.
|
|
115
|
+
export function AgentDetail({ agent }) {
|
|
116
|
+
const [tab, setTab] = useState('persona');
|
|
117
|
+
const color = personaColor(agent);
|
|
118
|
+
const stack = agent.stack || [];
|
|
119
|
+
const universal = stack.includes(UNIVERSAL_STACK);
|
|
120
|
+
const skills = dispatchingSkills(agent);
|
|
121
|
+
const standardName = (id) => (morphData.standards?.list || []).find((s) => s.id === id)?.name;
|
|
122
|
+
|
|
123
|
+
const facts = [
|
|
124
|
+
['Modelo', agent.model || 'herda da sessão'],
|
|
125
|
+
['Limite de turnos', agent.maxTurns != null ? String(agent.maxTurns) : 'sem limite declarado'],
|
|
126
|
+
['Ferramentas', toolsText(agent.tools)],
|
|
127
|
+
['Stack', universal ? 'universal (todas as stacks)' : (stack.join(', ') || '—')],
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<div className="space-y-6 text-sm text-[var(--color-fg)]">
|
|
132
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
133
|
+
<span className="inline-block h-2.5 w-2.5 rounded-full" style={{ background: color }} />
|
|
134
|
+
<span className="font-mono text-[12px] text-[var(--color-dim)]">morph-{agent.id}</span>
|
|
135
|
+
{(agent.domains || []).map((d) => <Chip key={d}>{d}</Chip>)}
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<dl className="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1.5 rounded-xl bg-white/[0.03] px-4 py-3 shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
139
|
+
{facts.map(([k, v]) => (
|
|
140
|
+
<div key={k} className="contents">
|
|
141
|
+
<dt className="text-xs leading-6 text-[var(--color-faint)]">{k}</dt>
|
|
142
|
+
<dd className="leading-6 text-[var(--color-dim)]">{v}</dd>
|
|
143
|
+
</div>
|
|
144
|
+
))}
|
|
145
|
+
</dl>
|
|
146
|
+
|
|
147
|
+
<Section title="Fases em que trabalha">
|
|
148
|
+
{agent.activePhases?.length > 0 ? (
|
|
149
|
+
<div className="flex flex-wrap gap-2">
|
|
150
|
+
{agent.activePhases.map((p) => (
|
|
151
|
+
<EntityLink key={p} kind="phase" id={p} chip>{phaseMeta(p).label}</EntityLink>
|
|
152
|
+
))}
|
|
153
|
+
</div>
|
|
154
|
+
) : (
|
|
155
|
+
<p className="text-[var(--color-dim)]">Nenhuma skill de fase despacha esta persona.</p>
|
|
156
|
+
)}
|
|
157
|
+
</Section>
|
|
158
|
+
|
|
159
|
+
<Section title="Despachada por">
|
|
160
|
+
{skills.length > 0 ? (
|
|
161
|
+
<div className="flex flex-wrap gap-2">
|
|
162
|
+
{skills.map((s) => <EntityLink key={s.id} kind="skill" id={s.id} chip>{s.id}</EntityLink>)}
|
|
163
|
+
</div>
|
|
164
|
+
) : (
|
|
165
|
+
<p className="text-[var(--color-dim)]">Nenhuma skill a despacha pelo nome.</p>
|
|
166
|
+
)}
|
|
167
|
+
</Section>
|
|
168
|
+
|
|
169
|
+
{agent.mcp?.length > 0 && (
|
|
170
|
+
<Section title="Servidores MCP">
|
|
171
|
+
<div className="flex flex-wrap gap-2">
|
|
172
|
+
{agent.mcp.map((m) => <Chip key={String(m)} mono>{String(m)}</Chip>)}
|
|
173
|
+
</div>
|
|
174
|
+
</Section>
|
|
175
|
+
)}
|
|
176
|
+
|
|
177
|
+
{agent.standards?.length > 0 && (
|
|
178
|
+
<Section title={`Standards que segue (${agent.standards.length})`}>
|
|
179
|
+
<div className="flex flex-wrap gap-2">
|
|
180
|
+
{agent.standards.map((id) => (
|
|
181
|
+
<EntityLink key={id} kind="standard" id={id} chip title={standardName(id)}>{id}</EntityLink>
|
|
182
|
+
))}
|
|
183
|
+
</div>
|
|
184
|
+
</Section>
|
|
185
|
+
)}
|
|
186
|
+
|
|
187
|
+
{agent.keywords?.length > 0 && (
|
|
188
|
+
<Section title="Palavras-chave">
|
|
189
|
+
<div className="flex flex-wrap gap-1.5">
|
|
190
|
+
{agent.keywords.map((k) => <Chip key={k}>{k}</Chip>)}
|
|
191
|
+
</div>
|
|
192
|
+
</Section>
|
|
193
|
+
)}
|
|
194
|
+
|
|
195
|
+
<section>
|
|
196
|
+
<div role="tablist" className="mb-3 inline-flex rounded-full bg-white/[0.04] p-1 shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
197
|
+
{[['persona', 'Persona'], ['prompt', 'Prompt gerado']].map(([id, label]) => (
|
|
198
|
+
<button
|
|
199
|
+
key={id}
|
|
200
|
+
type="button"
|
|
201
|
+
role="tab"
|
|
202
|
+
aria-selected={tab === id}
|
|
203
|
+
onClick={() => setTab(id)}
|
|
204
|
+
className={`fluid rounded-full px-3 py-1 text-[13px] transition-colors ${tab === id ? 'bg-white/[0.1] text-[var(--color-fg)]' : 'text-[var(--color-dim)] hover:text-[var(--color-fg)]'}`}
|
|
205
|
+
>
|
|
206
|
+
{label}
|
|
207
|
+
</button>
|
|
208
|
+
))}
|
|
209
|
+
</div>
|
|
210
|
+
{tab === 'persona' ? (
|
|
211
|
+
agent.persona
|
|
212
|
+
? <Markdown text={agent.persona} size="sm" />
|
|
213
|
+
: <p className="text-[var(--color-dim)]">Esta persona não tem texto de persona.</p>
|
|
214
|
+
) : (
|
|
215
|
+
<>
|
|
216
|
+
<p className="mb-3 text-[13px] text-[var(--color-dim)]">
|
|
217
|
+
É o arquivo <code className="font-mono">.claude/agents/morph-{agent.id}.md</code> exatamente como o sub-agent o recebe.
|
|
218
|
+
</p>
|
|
219
|
+
{agent.prompt
|
|
220
|
+
? <Markdown text={agent.prompt} size="sm" />
|
|
221
|
+
: <p className="text-[var(--color-dim)]">O prompt não foi gerado.</p>}
|
|
222
|
+
</>
|
|
223
|
+
)}
|
|
224
|
+
</section>
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function PrincipalDetail() {
|
|
230
|
+
return (
|
|
231
|
+
<div className="space-y-3 text-sm text-[var(--color-dim)]">
|
|
232
|
+
<p>
|
|
233
|
+
Você conversa com a thread principal do Claude Code, que faz o papel de orquestrador. É ela que
|
|
234
|
+
despacha cada persona como sub-agent, com o prompt gerado de cada uma.
|
|
235
|
+
</p>
|
|
236
|
+
<p>As personas são planas: nenhuma manda na outra, e todas respondem à thread principal.</p>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export default function AgentMap() {
|
|
242
|
+
const { agents } = morphData;
|
|
243
|
+
const [search, setSearch] = useState('');
|
|
244
|
+
const [domainFilter, setDomainFilter] = useState('');
|
|
245
|
+
const [phaseFilter, setPhaseFilter] = useState('');
|
|
246
|
+
const [stackFilter, setStackFilter] = useState('');
|
|
247
|
+
const [sel, setSel] = useSelection();
|
|
248
|
+
|
|
249
|
+
const allDomains = useMemo(() => [...new Set(agents.list.flatMap((a) => a.domains || []))].sort(), [agents.list]);
|
|
250
|
+
const allPhases = useMemo(() => {
|
|
251
|
+
const phases = new Set(agents.list.flatMap((a) => a.activePhases || []));
|
|
252
|
+
// Pipeline order, not alphabetical.
|
|
253
|
+
return morphData.phases.list.map((p) => p.id).filter((id) => phases.has(id));
|
|
254
|
+
}, [agents.list]);
|
|
255
|
+
const allStacks = useMemo(() => {
|
|
256
|
+
const stacks = new Set(agents.list.flatMap((a) => a.stack || []));
|
|
257
|
+
stacks.delete(UNIVERSAL_STACK);
|
|
258
|
+
return [...stacks].sort();
|
|
259
|
+
}, [agents.list]);
|
|
260
|
+
|
|
261
|
+
const matchedIds = useMemo(() => {
|
|
262
|
+
const q = search.toLowerCase();
|
|
263
|
+
return new Set(agents.list.filter((a) => {
|
|
264
|
+
const matchesSearch = !q || a.title.toLowerCase().includes(q) || a.id.toLowerCase().includes(q) || a.keywords?.some((k) => k.toLowerCase().includes(q));
|
|
265
|
+
const matchesDomain = !domainFilter || (a.domains || []).includes(domainFilter);
|
|
266
|
+
const matchesPhase = !phaseFilter || (a.activePhases || []).includes(phaseFilter);
|
|
267
|
+
const matchesStack = !stackFilter || (a.stack || []).includes(UNIVERSAL_STACK) || (a.stack || []).includes(stackFilter);
|
|
268
|
+
return matchesSearch && matchesDomain && matchesPhase && matchesStack;
|
|
269
|
+
}).map((a) => a.id));
|
|
270
|
+
}, [agents.list, search, domainFilter, phaseFilter, stackFilter]);
|
|
271
|
+
|
|
272
|
+
const hasFilter = Boolean(search || domainFilter || phaseFilter || stackFilter);
|
|
273
|
+
|
|
274
|
+
const { nodes, edges } = useMemo(() => {
|
|
275
|
+
const rawNodes = [{
|
|
276
|
+
id: PRINCIPAL_ID,
|
|
277
|
+
type: 'agentNode',
|
|
278
|
+
data: { label: 'Você e a thread principal', sub: 'orquestra e despacha', isUser: true, color: 'var(--color-phase-proposal)', selected: sel === PRINCIPAL_ID },
|
|
279
|
+
position: { x: 0, y: 0 },
|
|
280
|
+
}];
|
|
281
|
+
const rawEdges = [];
|
|
282
|
+
for (const agent of agents.list) {
|
|
283
|
+
const dimmed = hasFilter && !matchedIds.has(agent.id);
|
|
284
|
+
const color = personaColor(agent);
|
|
285
|
+
rawNodes.push({
|
|
286
|
+
id: agent.id,
|
|
287
|
+
type: 'agentNode',
|
|
288
|
+
data: {
|
|
289
|
+
label: agent.title,
|
|
290
|
+
sub: [agent.domains?.[0], agent.model].filter(Boolean).join(' · '),
|
|
291
|
+
color,
|
|
292
|
+
selected: sel === agent.id,
|
|
293
|
+
},
|
|
294
|
+
style: dimmed ? { opacity: 0.25 } : {},
|
|
295
|
+
position: { x: 0, y: 0 },
|
|
296
|
+
});
|
|
297
|
+
rawEdges.push({
|
|
298
|
+
id: `rt-${agent.id}`,
|
|
299
|
+
source: PRINCIPAL_ID,
|
|
300
|
+
target: agent.id,
|
|
301
|
+
type: 'smoothstep',
|
|
302
|
+
style: { stroke: color, strokeWidth: 1.5, opacity: dimmed ? 0.25 : 0.7 },
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return { nodes: buildLayout(rawNodes, rawEdges), edges: rawEdges };
|
|
306
|
+
}, [agents.list, matchedIds, hasFilter, sel]);
|
|
307
|
+
|
|
308
|
+
const handleNodeClick = useCallback((_event, node) => setSel(node.id), [setSel]);
|
|
309
|
+
const close = useCallback(() => setSel(null), [setSel]);
|
|
310
|
+
|
|
311
|
+
const selected = agents.list.find((a) => a.id === sel) || null;
|
|
312
|
+
const isPrincipal = sel === PRINCIPAL_ID;
|
|
313
|
+
const panelOpen = Boolean(selected || isPrincipal);
|
|
314
|
+
|
|
315
|
+
const filterConfig = [
|
|
316
|
+
{ name: 'domain', label: 'Domínio', options: allDomains, value: domainFilter },
|
|
317
|
+
{ name: 'phase', label: 'Fase', options: allPhases, value: phaseFilter },
|
|
318
|
+
{ name: 'stack', label: 'Stack', options: allStacks, value: stackFilter },
|
|
319
|
+
];
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<div className="flex h-full flex-col">
|
|
323
|
+
<SearchFilter
|
|
324
|
+
placeholder="Buscar persona por nome ou palavra-chave"
|
|
325
|
+
filters={filterConfig}
|
|
326
|
+
onSearchChange={setSearch}
|
|
327
|
+
onFilterChange={(name, value) => {
|
|
328
|
+
if (name === 'domain') setDomainFilter(value);
|
|
329
|
+
if (name === 'phase') setPhaseFilter(value);
|
|
330
|
+
if (name === 'stack') setStackFilter(value);
|
|
331
|
+
}}
|
|
332
|
+
/>
|
|
333
|
+
|
|
334
|
+
<div className="relative flex-1">
|
|
335
|
+
<FlowGraph nodes={nodes} edges={edges} nodeTypes={nodeTypes} onNodeClick={handleNodeClick} fitView />
|
|
336
|
+
|
|
337
|
+
<div className="bezel absolute left-3 top-3 z-10 max-w-[18rem]">
|
|
338
|
+
<div className="bezel-core space-y-1.5 px-3.5 py-3 text-[12px]">
|
|
339
|
+
<p className="mb-1 font-medium text-[var(--color-faint)]">Personas</p>
|
|
340
|
+
{agents.list.map((a) => (
|
|
341
|
+
<button
|
|
342
|
+
key={a.id}
|
|
343
|
+
type="button"
|
|
344
|
+
onClick={() => setSel(a.id)}
|
|
345
|
+
className="fluid flex w-full items-center gap-2 text-left text-[var(--color-dim)] transition-colors hover:text-[var(--color-fg)]"
|
|
346
|
+
>
|
|
347
|
+
<span className="inline-block h-2.5 w-2.5 shrink-0 rounded-full" style={{ background: personaColor(a) }} />
|
|
348
|
+
<span className="truncate">{a.title}</span>
|
|
349
|
+
</button>
|
|
350
|
+
))}
|
|
351
|
+
<p className="mt-2 border-t border-[var(--color-hair)] pt-2 text-[var(--color-faint)]">A linha liga quem despacha a quem é despachado.</p>
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
|
|
355
|
+
<div className="absolute right-3 top-3 z-10 rounded-full bg-[var(--color-ink)]/80 px-3 py-1.5 text-[12px] text-[var(--color-dim)] shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
356
|
+
{hasFilter ? `${matchedIds.size} de ${agents.list.length}` : agents.list.length} personas
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<DetailPanel
|
|
361
|
+
open={panelOpen}
|
|
362
|
+
title={selected ? selected.title : isPrincipal ? 'Você e a thread principal' : ''}
|
|
363
|
+
subtitle={selected ? `morph-${selected.id}` : isPrincipal ? 'Orquestrador' : undefined}
|
|
364
|
+
onClose={close}
|
|
365
|
+
>
|
|
366
|
+
{selected && <AgentDetail key={selected.id} agent={selected} />}
|
|
367
|
+
{isPrincipal && <PrincipalDetail />}
|
|
368
|
+
</DetailPanel>
|
|
369
|
+
</div>
|
|
370
|
+
);
|
|
371
|
+
}
|