@polymorphism-tech/morph-spec 8.38.0 → 8.41.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 +20 -9
- 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 +4 -3
- package/framework/MORPH.md +10 -9
- package/framework/agents.json +43 -26
- package/framework/docs/CLI.md +7 -5
- package/framework/evals/rubrics/code-quality.md +4 -4
- package/framework/evals/rubrics/condensed.md +2 -2
- package/framework/hooks/README.md +1 -1
- package/framework/hooks/claude-code/core/telemetry-log.js +39 -8
- package/framework/hooks/claude-code/core/worktree-create.js +22 -6
- package/framework/hooks/shared/git-paths.js +38 -5
- package/framework/mcp/registry.json +58 -66
- 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 +59 -25
- 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 +2 -2
- package/framework/skills/core/morph-implement/SKILL.md +48 -24
- package/framework/skills/core/morph-media/SKILL.md +2 -2
- package/framework/skills/core/morph-plan/SKILL.md +10 -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 +7 -6
- package/framework/standards/PROVENANCE.json +4 -4
- package/framework/standards/STANDARDS.json +9 -9
- 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/dotnet/testing.md +4 -2
- package/framework/standards/backend/integrations/neon-auth/neon-auth.md +63 -50
- package/framework/standards/frontend/design-system/ai-image-generation.md +42 -28
- package/framework/standards/frontend/design-system/ai-video-generation.md +24 -9
- package/framework/standards/frontend/nextjs/testing.md +4 -2
- package/framework/standards/integration/mcp/mcp-tools.md +64 -126
- 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 +12 -6
- 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/commands/project/worktree.js +60 -4
- package/src/commands/state/gate-check.js +5 -0
- package/src/commands/tasks/dag.js +27 -4
- package/src/commands/validation/verify.js +22 -38
- 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/risk-detector.js +13 -0
- package/src/lib/tasks/tasks-json-parser.js +21 -0
- package/src/lib/validators/code-budget/code-budget-validator.js +32 -4
- package/src/lib/worktree/env-allocator.js +9 -3
- package/src/scripts/install-plugin.js +1 -1
- package/src/scripts/setup-infra.js +2 -4
- package/src/utils/agents-installer.js +108 -13
- 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,332 +1,407 @@
|
|
|
1
|
-
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
-
import { Handle, Position } from '@xyflow/react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
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
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
</div>
|
|
58
|
-
<div className="
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</div>
|
|
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
|
-
const
|
|
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
|
-
const
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
1
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { Handle, Position } from '@xyflow/react';
|
|
3
|
+
import { Robot } from '@phosphor-icons/react';
|
|
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 Markdown from '../components/Markdown.jsx';
|
|
9
|
+
import EntityLink, { useSelection, standardKey } from '../components/EntityLink.jsx';
|
|
10
|
+
|
|
11
|
+
// ─── Colors ───────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
/** Token palette the categories draw from, in order; the categories come from the data. */
|
|
14
|
+
const PALETTE = [
|
|
15
|
+
'var(--color-phase-implement)',
|
|
16
|
+
'var(--color-phase-uiux)',
|
|
17
|
+
'var(--color-phase-proposal)',
|
|
18
|
+
'var(--color-phase-plan)',
|
|
19
|
+
'var(--color-ok)',
|
|
20
|
+
'var(--color-warn)',
|
|
21
|
+
'var(--color-phase-review)',
|
|
22
|
+
'var(--color-dim)',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const tint = (color, pct = 14) => `color-mix(in srgb, ${color} ${pct}%, var(--color-core))`;
|
|
26
|
+
|
|
27
|
+
/** category → color, stable by category name so a color never jumps between renders. */
|
|
28
|
+
function categoryColors(standards) {
|
|
29
|
+
const cats = [...new Set(standards.map((s) => s.category || 'outros'))].sort();
|
|
30
|
+
return Object.fromEntries(cats.map((c, i) => [c, PALETTE[i % PALETTE.length]]));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Resolve `?sel=` to a standard: by id first, then by the path a task cites. */
|
|
34
|
+
export function findStandard(list, sel) {
|
|
35
|
+
if (!sel) return null;
|
|
36
|
+
return list.find((s) => s.id === sel) || list.find((s) => s.path === standardKey(sel)) || null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ─── Nodes ────────────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
const HANDLE = { width: 7, height: 7, border: 0 };
|
|
42
|
+
const NODE_W = 230;
|
|
43
|
+
const NODE_H = 52;
|
|
44
|
+
|
|
45
|
+
function StandardNode({ data }) {
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className="cursor-pointer select-none rounded-xl px-3 py-1.5 transition-opacity"
|
|
49
|
+
style={{
|
|
50
|
+
width: NODE_W, height: NODE_H,
|
|
51
|
+
background: tint(data.color, data.selected ? 30 : 12),
|
|
52
|
+
boxShadow: `inset 0 0 0 ${data.selected ? 2 : 1.25}px ${data.color}`,
|
|
53
|
+
opacity: data.dimmed ? 0.18 : 1,
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Handle type="target" position={Position.Top} style={{ ...HANDLE, background: data.color }} />
|
|
57
|
+
<div className="truncate text-[13px] font-medium leading-tight text-[var(--color-fg)]" title={data.label}>{data.label}</div>
|
|
58
|
+
<div className="mt-0.5 truncate text-xs text-[var(--color-dim)]" title={data.sub}>{data.sub}</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function AgentNode({ data }) {
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className="flex cursor-pointer select-none items-center gap-2 rounded-full px-4 py-2 transition-opacity"
|
|
67
|
+
style={{
|
|
68
|
+
width: NODE_W,
|
|
69
|
+
background: data.active ? tint('var(--color-fg)', 16) : 'var(--color-raised)',
|
|
70
|
+
boxShadow: `inset 0 0 0 ${data.active ? 2 : 1}px ${data.active ? 'var(--color-fg)' : 'var(--color-hair-strong)'}`,
|
|
71
|
+
opacity: data.dimmed ? 0.3 : 1,
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<Robot weight="light" size={16} className="shrink-0 text-[var(--color-dim)]" />
|
|
75
|
+
<div className="min-w-0">
|
|
76
|
+
<div className="truncate font-mono text-[13px] text-[var(--color-fg)]" title={data.title}>morph-{data.agentId}</div>
|
|
77
|
+
<div className="text-xs text-[var(--color-dim)]">{data.count} standards</div>
|
|
78
|
+
</div>
|
|
79
|
+
<Handle type="source" position={Position.Bottom} style={{ ...HANDLE, background: 'var(--color-dim)' }} />
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function CategoryNode({ data }) {
|
|
85
|
+
return (
|
|
86
|
+
<div
|
|
87
|
+
className="pointer-events-none rounded-2xl"
|
|
88
|
+
style={{ width: data.width, height: data.height, background: tint(data.color, 5), boxShadow: `inset 0 0 0 1px color-mix(in srgb, ${data.color} 40%, transparent)` }}
|
|
89
|
+
>
|
|
90
|
+
<div className="flex items-baseline gap-2 px-4 pt-3">
|
|
91
|
+
<span className="text-sm font-semibold" style={{ color: data.color }}>{data.label}</span>
|
|
92
|
+
<span className="text-xs text-[var(--color-dim)]">{data.count}</span>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const nodeTypes = { standardNode: StandardNode, agentNode: AgentNode, categoryNode: CategoryNode };
|
|
99
|
+
|
|
100
|
+
// ─── Layout ───────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
const CELL_W = NODE_W + 14;
|
|
103
|
+
const CELL_H = NODE_H + 12;
|
|
104
|
+
const PAD = 16;
|
|
105
|
+
const HEADER = 40;
|
|
106
|
+
const BLOCK_GAP = 36;
|
|
107
|
+
const MAX_ROW_W = 1700;
|
|
108
|
+
|
|
109
|
+
/** How many columns a category block gets: tall categories spread sideways. */
|
|
110
|
+
function colsFor(n) {
|
|
111
|
+
if (n > 12) return 3;
|
|
112
|
+
if (n > 5) return 2;
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function buildGraph({ standards, agents, colors, isMatch, hasFilter, persona, selectedId }) {
|
|
117
|
+
const nodes = [];
|
|
118
|
+
const edges = [];
|
|
119
|
+
|
|
120
|
+
const byCat = new Map();
|
|
121
|
+
for (const s of standards) {
|
|
122
|
+
const c = s.category || 'outros';
|
|
123
|
+
if (!byCat.has(c)) byCat.set(c, []);
|
|
124
|
+
byCat.get(c).push(s);
|
|
125
|
+
}
|
|
126
|
+
const cats = [...byCat.entries()]
|
|
127
|
+
.map(([cat, list]) => [cat, [...list].sort((a, b) => (a.subcategory || '').localeCompare(b.subcategory || '') || a.name.localeCompare(b.name))])
|
|
128
|
+
.sort((a, b) => b[1].length - a[1].length || a[0].localeCompare(b[0]));
|
|
129
|
+
|
|
130
|
+
// Pack the category blocks into rows no wider than MAX_ROW_W.
|
|
131
|
+
const blocks = cats.map(([cat, list]) => {
|
|
132
|
+
const cols = colsFor(list.length);
|
|
133
|
+
const rows = Math.ceil(list.length / cols);
|
|
134
|
+
return { cat, list, cols, w: cols * CELL_W + PAD * 2 - 14, h: HEADER + rows * CELL_H + PAD - 12 };
|
|
135
|
+
});
|
|
136
|
+
const rows = [];
|
|
137
|
+
for (const b of blocks) {
|
|
138
|
+
const row = rows[rows.length - 1];
|
|
139
|
+
if (row && row.w + BLOCK_GAP + b.w <= MAX_ROW_W) { row.items.push(b); row.w += BLOCK_GAP + b.w; row.h = Math.max(row.h, b.h); }
|
|
140
|
+
else rows.push({ items: [b], w: b.w, h: b.h });
|
|
141
|
+
}
|
|
142
|
+
const totalW = Math.max(...rows.map((r) => r.w), 0);
|
|
143
|
+
|
|
144
|
+
const std = new Set(); // node ids present
|
|
145
|
+
let y = 180;
|
|
146
|
+
for (const row of rows) {
|
|
147
|
+
let x = (totalW - row.w) / 2;
|
|
148
|
+
for (const b of row.items) {
|
|
149
|
+
const color = colors[b.cat];
|
|
150
|
+
nodes.push({
|
|
151
|
+
id: `cat:${b.cat}`, type: 'categoryNode', position: { x, y },
|
|
152
|
+
data: { label: b.cat, count: b.list.length, color, width: b.w, height: b.h },
|
|
153
|
+
selectable: false, draggable: false, focusable: false, zIndex: -1,
|
|
154
|
+
});
|
|
155
|
+
b.list.forEach((s, i) => {
|
|
156
|
+
const col = i % b.cols;
|
|
157
|
+
const r = Math.floor(i / b.cols);
|
|
158
|
+
nodes.push({
|
|
159
|
+
id: `std:${s.id}`, type: 'standardNode',
|
|
160
|
+
position: { x: x + PAD + col * CELL_W, y: y + HEADER + r * CELL_H },
|
|
161
|
+
data: {
|
|
162
|
+
label: s.name, sub: s.subcategory || s.path, color, stdId: s.id,
|
|
163
|
+
dimmed: hasFilter && !isMatch(s), selected: s.id === selectedId,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
std.add(s.id);
|
|
167
|
+
});
|
|
168
|
+
x += b.w + BLOCK_GAP;
|
|
169
|
+
}
|
|
170
|
+
y += row.h + BLOCK_GAP;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The personas on top, each with an edge to every standard it consults.
|
|
174
|
+
const withStandards = agents.filter((a) => (a.standards || []).some((id) => std.has(id)));
|
|
175
|
+
const agentX0 = (totalW - withStandards.length * (NODE_W + 24)) / 2;
|
|
176
|
+
const byId = new Map(standards.map((s) => [s.id, s]));
|
|
177
|
+
withStandards.forEach((a, i) => {
|
|
178
|
+
const ids = (a.standards || []).filter((id) => std.has(id));
|
|
179
|
+
const active = persona === a.id;
|
|
180
|
+
nodes.push({
|
|
181
|
+
id: `agent:${a.id}`, type: 'agentNode', position: { x: agentX0 + i * (NODE_W + 24), y: 0 },
|
|
182
|
+
data: { agentId: a.id, title: a.title, count: ids.length, active, dimmed: Boolean(persona) && !active },
|
|
183
|
+
});
|
|
184
|
+
for (const id of ids) {
|
|
185
|
+
const s = byId.get(id);
|
|
186
|
+
const lit = persona ? active : !hasFilter || isMatch(s);
|
|
187
|
+
edges.push({
|
|
188
|
+
id: `e:${a.id}->${id}`, source: `agent:${a.id}`, target: `std:${id}`, type: 'default',
|
|
189
|
+
style: { stroke: colors[s.category || 'outros'], strokeWidth: lit && persona ? 1.5 : 1, opacity: lit ? (persona ? 0.85 : 0.22) : 0.04 },
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return { nodes, edges, categories: cats.map(([c, l]) => [c, l.length]) };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ─── Detail ───────────────────────────────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
function Section({ title, children }) {
|
|
200
|
+
return (
|
|
201
|
+
<section className="space-y-2">
|
|
202
|
+
<h3 className="text-xs font-medium text-[var(--color-faint)]">{title}</h3>
|
|
203
|
+
{children}
|
|
204
|
+
</section>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function jumpTo(anchor) {
|
|
209
|
+
if (typeof document === 'undefined') return;
|
|
210
|
+
const id = decodeURIComponent(String(anchor).replace(/^#/, ''));
|
|
211
|
+
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function StandardDetail({ std, color = 'var(--color-dim)' }) {
|
|
215
|
+
const aliases = std.aliases || [];
|
|
216
|
+
const anchors = Object.entries(std.anchors || {});
|
|
217
|
+
const refs = std.referencedBy || [];
|
|
218
|
+
const provedBy = std.provedBy || [];
|
|
219
|
+
const stacks = std.stacks || [];
|
|
220
|
+
const verified = typeof std.verifiedAgainst === 'string' ? std.verifiedAgainst.trim() : '';
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div className="space-y-6 text-sm text-[var(--color-dim)]">
|
|
224
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
225
|
+
<span className="rounded-full px-2.5 py-0.5 text-xs font-medium" style={{ color, background: tint(color, 18), boxShadow: `inset 0 0 0 1px ${color}` }}>
|
|
226
|
+
{std.category}
|
|
227
|
+
</span>
|
|
228
|
+
{std.subcategory && (
|
|
229
|
+
<span className="rounded-full px-2.5 py-0.5 text-xs shadow-[inset_0_0_0_1px_var(--color-hair-strong)]">{std.subcategory}</span>
|
|
230
|
+
)}
|
|
231
|
+
{stacks.map((s) => (
|
|
232
|
+
<span key={s} className="rounded-full px-2 py-0.5 font-mono text-xs shadow-[inset_0_0_0_1px_var(--color-hair)]">stack {s}</span>
|
|
233
|
+
))}
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<div className="font-mono text-xs text-[var(--color-faint)]">
|
|
237
|
+
<div>id <span className="text-[var(--color-dim)]">{std.id}</span></div>
|
|
238
|
+
{std.path && <div>arquivo <span className="text-[var(--color-dim)]">standards/{std.path}</span></div>}
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
{std.digest && (
|
|
242
|
+
<Section title="Resumo">
|
|
243
|
+
<p className="leading-relaxed text-[var(--color-fg)]">{std.digest}</p>
|
|
244
|
+
</Section>
|
|
245
|
+
)}
|
|
246
|
+
|
|
247
|
+
{aliases.length > 0 && (
|
|
248
|
+
<Section title="Também encontrado por">
|
|
249
|
+
<div className="flex flex-wrap gap-1.5">
|
|
250
|
+
{aliases.map((a, i) => (
|
|
251
|
+
<span key={`${a}-${i}`} className="rounded-full px-2 py-0.5 text-xs shadow-[inset_0_0_0_1px_var(--color-hair)]">{a}</span>
|
|
252
|
+
))}
|
|
253
|
+
</div>
|
|
254
|
+
</Section>
|
|
255
|
+
)}
|
|
256
|
+
|
|
257
|
+
{anchors.length > 0 && (
|
|
258
|
+
<Section title="Seções">
|
|
259
|
+
<ul className="grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1">
|
|
260
|
+
{anchors.map(([name, href]) => (
|
|
261
|
+
<li key={name} className="contents">
|
|
262
|
+
<span className="font-mono text-xs leading-6 text-[var(--color-faint)]">{name}</span>
|
|
263
|
+
<button
|
|
264
|
+
type="button" onClick={() => jumpTo(href)}
|
|
265
|
+
className="truncate text-left font-mono text-xs leading-6 text-[var(--color-phase-proposal)] hover:underline"
|
|
266
|
+
>
|
|
267
|
+
{href}
|
|
268
|
+
</button>
|
|
269
|
+
</li>
|
|
270
|
+
))}
|
|
271
|
+
</ul>
|
|
272
|
+
</Section>
|
|
273
|
+
)}
|
|
274
|
+
|
|
275
|
+
<Section title={refs.length ? `Consultado por (${refs.length})` : 'Consultado por'}>
|
|
276
|
+
{refs.length ? (
|
|
277
|
+
<div className="flex flex-wrap gap-1.5">
|
|
278
|
+
{refs.map((r, i) => <EntityLink key={`${r.agentId}-${i}`} kind="persona" id={r.agentId} chip>{`morph-${r.agentId}`}</EntityLink>)}
|
|
279
|
+
</div>
|
|
280
|
+
) : (
|
|
281
|
+
<p>Nenhuma persona lista este standard; ele é achado por busca (<code className="font-mono text-xs">morph-spec standards --find</code>).</p>
|
|
282
|
+
)}
|
|
283
|
+
</Section>
|
|
284
|
+
|
|
285
|
+
{provedBy.length > 0 && (
|
|
286
|
+
<Section title="Provado por">
|
|
287
|
+
<ul className="space-y-1">
|
|
288
|
+
{provedBy.map((p, i) => (
|
|
289
|
+
<li key={`${p}-${i}`} className="break-all font-mono text-xs text-[var(--color-fg)]">{p}</li>
|
|
290
|
+
))}
|
|
291
|
+
</ul>
|
|
292
|
+
</Section>
|
|
293
|
+
)}
|
|
294
|
+
|
|
295
|
+
{verified && (
|
|
296
|
+
<Section title="Verificado contra">
|
|
297
|
+
<Markdown text={verified} size="sm" />
|
|
298
|
+
</Section>
|
|
299
|
+
)}
|
|
300
|
+
|
|
301
|
+
{std.content && (
|
|
302
|
+
<Section title="Conteúdo completo">
|
|
303
|
+
<Markdown text={std.content} size="sm" />
|
|
304
|
+
</Section>
|
|
305
|
+
)}
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ─── Page ─────────────────────────────────────────────────────────────────────
|
|
311
|
+
|
|
312
|
+
export default function Standards() {
|
|
313
|
+
const standards = morphData.standards?.list || [];
|
|
314
|
+
const version = morphData.standards?.version;
|
|
315
|
+
const agents = morphData.agents?.list || [];
|
|
316
|
+
const [sel, setSel] = useSelection();
|
|
317
|
+
const [search, setSearch] = useState('');
|
|
318
|
+
const [categoryFilter, setCategoryFilter] = useState('');
|
|
319
|
+
const [persona, setPersona] = useState('');
|
|
320
|
+
|
|
321
|
+
const colors = useMemo(() => categoryColors(standards), [standards]);
|
|
322
|
+
const selected = useMemo(() => findStandard(standards, sel), [standards, sel]);
|
|
323
|
+
|
|
324
|
+
const isMatch = useCallback((s) => {
|
|
325
|
+
const q = search.trim().toLowerCase();
|
|
326
|
+
if (q) {
|
|
327
|
+
const hay = [s.id, s.name, s.path, s.digest, s.category, s.subcategory, ...(s.aliases || []), ...(s.tags || [])]
|
|
328
|
+
.filter(Boolean).join(' ').toLowerCase();
|
|
329
|
+
if (!hay.includes(q)) return false;
|
|
330
|
+
}
|
|
331
|
+
if (categoryFilter && s.category !== categoryFilter) return false;
|
|
332
|
+
if (persona && !(s.referencedBy || []).some((r) => r.agentId === persona)) return false;
|
|
333
|
+
return true;
|
|
334
|
+
}, [search, categoryFilter, persona]);
|
|
335
|
+
|
|
336
|
+
const hasFilter = Boolean(search.trim() || categoryFilter || persona);
|
|
337
|
+
const matchCount = useMemo(() => standards.filter(isMatch).length, [standards, isMatch]);
|
|
338
|
+
const orphanCount = standards.filter((s) => !(s.referencedBy || []).length).length;
|
|
339
|
+
|
|
340
|
+
const graph = useMemo(
|
|
341
|
+
() => buildGraph({ standards, agents, colors, isMatch, hasFilter, persona, selectedId: selected?.id }),
|
|
342
|
+
[standards, agents, colors, isMatch, hasFilter, persona, selected?.id],
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
const personaOptions = useMemo(
|
|
346
|
+
() => agents.filter((a) => (a.standards || []).length).map((a) => a.id),
|
|
347
|
+
[agents],
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const close = useCallback(() => setSel(null), [setSel]);
|
|
351
|
+
const onNodeClick = useCallback((_e, node) => {
|
|
352
|
+
if (node.type === 'standardNode') setSel(node.data.stdId);
|
|
353
|
+
else if (node.type === 'agentNode') setPersona((p) => (p === node.data.agentId ? '' : node.data.agentId));
|
|
354
|
+
}, [setSel]);
|
|
355
|
+
|
|
356
|
+
const filters = [
|
|
357
|
+
{ name: 'category', label: 'Categoria', options: graph.categories.map(([c]) => c), value: categoryFilter },
|
|
358
|
+
{ name: 'persona', label: 'Persona', options: personaOptions, value: persona },
|
|
359
|
+
];
|
|
360
|
+
|
|
361
|
+
return (
|
|
362
|
+
<div className="flex h-full flex-col">
|
|
363
|
+
<SearchFilter
|
|
364
|
+
placeholder="Buscar standard por nome, id, caminho, resumo ou apelido"
|
|
365
|
+
filters={filters}
|
|
366
|
+
onSearchChange={setSearch}
|
|
367
|
+
onFilterChange={(name, value) => {
|
|
368
|
+
if (name === 'category') setCategoryFilter(value);
|
|
369
|
+
if (name === 'persona') setPersona(value);
|
|
370
|
+
}}
|
|
371
|
+
/>
|
|
372
|
+
|
|
373
|
+
<div className="relative flex-1">
|
|
374
|
+
<FlowGraph nodes={graph.nodes} edges={graph.edges} nodeTypes={nodeTypes} onNodeClick={onNodeClick} fitView />
|
|
375
|
+
|
|
376
|
+
<div className="absolute left-3 top-3 z-10 space-y-1.5 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">
|
|
377
|
+
<p className="mb-1 text-[13px] font-medium text-[var(--color-fg)]">Categorias</p>
|
|
378
|
+
{graph.categories.map(([cat, n]) => (
|
|
379
|
+
<button
|
|
380
|
+
key={cat} type="button"
|
|
381
|
+
onClick={() => setCategoryFilter((c) => (c === cat ? '' : cat))}
|
|
382
|
+
className="flex w-full items-center gap-2 text-left hover:text-[var(--color-fg)]"
|
|
383
|
+
style={{ opacity: categoryFilter && categoryFilter !== cat ? 0.45 : 1 }}
|
|
384
|
+
>
|
|
385
|
+
<span className="inline-block h-3 w-3 shrink-0 rounded" style={{ background: tint(colors[cat], 30), boxShadow: `inset 0 0 0 1px ${colors[cat]}` }} />
|
|
386
|
+
<span>{cat}</span>
|
|
387
|
+
<span className="ml-auto pl-3 text-[var(--color-faint)]">{n}</span>
|
|
388
|
+
</button>
|
|
389
|
+
))}
|
|
390
|
+
<p className="border-t border-[var(--color-hair)] pt-2 text-[var(--color-faint)]">clique numa persona para ver os standards dela</p>
|
|
391
|
+
</div>
|
|
392
|
+
|
|
393
|
+
<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">
|
|
394
|
+
<div className="text-[13px] text-[var(--color-fg)]">
|
|
395
|
+
{hasFilter ? `${matchCount} de ${standards.length} standards` : `${standards.length} standards`}
|
|
396
|
+
</div>
|
|
397
|
+
<div>{graph.categories.length} categorias{version ? ` · registro v${version}` : ''}</div>
|
|
398
|
+
<div>{orphanCount} sem persona (achados por busca)</div>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
|
|
402
|
+
<DetailPanel open={Boolean(selected)} title={selected?.name || ''} subtitle={selected?.id || ''} onClose={close}>
|
|
403
|
+
{selected && <StandardDetail std={selected} color={colors[selected.category || 'outros']} />}
|
|
404
|
+
</DetailPanel>
|
|
405
|
+
</div>
|
|
406
|
+
);
|
|
407
|
+
}
|