@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
|
@@ -64,21 +64,49 @@ export async function detectStack(targetPath) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Detect the project's integrations (`neon`, `stripe`...), same sources and
|
|
69
|
+
* order as detectStack. The detectors never fold them into the stack string, so
|
|
70
|
+
* without this an MCP scoped to an integration (neon, asaas) is never offered.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} targetPath
|
|
73
|
+
* @returns {Promise<string[]>}
|
|
74
|
+
*/
|
|
75
|
+
export async function detectIntegrations(targetPath) {
|
|
76
|
+
try {
|
|
77
|
+
const configPath = join(targetPath, '.morph', 'config', 'config.json');
|
|
78
|
+
if (existsSync(configPath)) {
|
|
79
|
+
const integrations = JSON.parse(readFileSync(configPath, 'utf-8')).project?.integrations;
|
|
80
|
+
if (Array.isArray(integrations)) return integrations;
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
// Fall through to filesystem detection
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const results = await detectProject(targetPath, { conversation: false, generateStandards: false });
|
|
88
|
+
return results.structure?.integrations ?? [];
|
|
89
|
+
} catch {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
67
94
|
export async function mcpSetupCommand(name, options) {
|
|
68
95
|
const targetPath = process.cwd();
|
|
69
96
|
|
|
70
97
|
try {
|
|
71
98
|
// Detect current environment
|
|
72
99
|
const stack = await detectStack(targetPath);
|
|
100
|
+
const integrations = await detectIntegrations(targetPath);
|
|
73
101
|
const claudeConfig = await detectClaudeConfig(targetPath);
|
|
74
102
|
const existingMcps = claudeConfig.mcpServers || [];
|
|
75
103
|
|
|
76
104
|
if (options.list) {
|
|
77
|
-
return showStatusList(targetPath, stack, existingMcps);
|
|
105
|
+
return showStatusList(targetPath, stack, existingMcps, integrations);
|
|
78
106
|
}
|
|
79
107
|
|
|
80
108
|
if (options.auto) {
|
|
81
|
-
return autoInstall(targetPath, stack, existingMcps);
|
|
109
|
+
return autoInstall(targetPath, stack, existingMcps, integrations);
|
|
82
110
|
}
|
|
83
111
|
|
|
84
112
|
if (name) {
|
|
@@ -86,7 +114,7 @@ export async function mcpSetupCommand(name, options) {
|
|
|
86
114
|
}
|
|
87
115
|
|
|
88
116
|
// Interactive wizard
|
|
89
|
-
return interactiveWizard(targetPath, stack, existingMcps);
|
|
117
|
+
return interactiveWizard(targetPath, stack, existingMcps, integrations);
|
|
90
118
|
} catch (err) {
|
|
91
119
|
console.error(chalk.red(`Error: ${err.message}`));
|
|
92
120
|
process.exit(1);
|
|
@@ -96,8 +124,8 @@ export async function mcpSetupCommand(name, options) {
|
|
|
96
124
|
/**
|
|
97
125
|
* Show MCP status list (--list)
|
|
98
126
|
*/
|
|
99
|
-
async function showStatusList(targetPath, stack, existingMcps) {
|
|
100
|
-
const orchestration = orchestrateMcpSetup(targetPath, stack, existingMcps);
|
|
127
|
+
async function showStatusList(targetPath, stack, existingMcps, integrations) {
|
|
128
|
+
const orchestration = orchestrateMcpSetup(targetPath, stack, existingMcps, { integrations });
|
|
101
129
|
const statusRows = formatMcpStatusTable(orchestration, {});
|
|
102
130
|
|
|
103
131
|
console.log(chalk.cyan('\n MCP Server Status\n'));
|
|
@@ -130,8 +158,8 @@ async function showStatusList(targetPath, stack, existingMcps) {
|
|
|
130
158
|
/**
|
|
131
159
|
* Auto-install credential-free MCPs (--auto)
|
|
132
160
|
*/
|
|
133
|
-
async function autoInstall(targetPath, stack, existingMcps) {
|
|
134
|
-
const orchestration = orchestrateMcpSetup(targetPath, stack, existingMcps, { autoOnly: true });
|
|
161
|
+
async function autoInstall(targetPath, stack, existingMcps, integrations) {
|
|
162
|
+
const orchestration = orchestrateMcpSetup(targetPath, stack, existingMcps, { autoOnly: true, integrations });
|
|
135
163
|
const autoNames = Object.keys(orchestration.autoInstallable);
|
|
136
164
|
|
|
137
165
|
if (autoNames.length === 0) {
|
|
@@ -391,8 +419,8 @@ async function setupSpecificMcp(targetPath, name, stack, existingMcps) {
|
|
|
391
419
|
/**
|
|
392
420
|
* Interactive wizard showing all MCPs
|
|
393
421
|
*/
|
|
394
|
-
async function interactiveWizard(targetPath, stack, existingMcps) {
|
|
395
|
-
const orchestration = orchestrateMcpSetup(targetPath, stack, existingMcps);
|
|
422
|
+
async function interactiveWizard(targetPath, stack, existingMcps, integrations) {
|
|
423
|
+
const orchestration = orchestrateMcpSetup(targetPath, stack, existingMcps, { integrations });
|
|
396
424
|
|
|
397
425
|
console.log(chalk.cyan('\n MCP Setup Wizard'));
|
|
398
426
|
console.log(chalk.gray(` Stack: ${stack}`));
|
|
@@ -44,10 +44,10 @@ function normCwd(root, cwd) {
|
|
|
44
44
|
/**
|
|
45
45
|
* Check which required Claude Code plugins are installed.
|
|
46
46
|
* @param {Object} pluginsData - The `plugins` object from installed_plugins.json
|
|
47
|
-
* @returns {{
|
|
47
|
+
* @returns {{ context7: boolean }}
|
|
48
48
|
*/
|
|
49
49
|
export function checkInstalledPlugins(pluginsData) {
|
|
50
|
-
const REQUIRED = ['
|
|
50
|
+
const REQUIRED = ['context7'];
|
|
51
51
|
return Object.fromEntries(
|
|
52
52
|
REQUIRED.map(name => [name, `${name}@claude-plugins-official` in (pluginsData || {})])
|
|
53
53
|
);
|
|
@@ -1330,15 +1330,13 @@ export async function doctorCommand(options = {}) {
|
|
|
1330
1330
|
} catch { /* non-fatal */ }
|
|
1331
1331
|
|
|
1332
1332
|
// ── Claude Code Plugins ──────────────────────────────────────────────────
|
|
1333
|
-
console.log(chalk.cyan('\n Claude Code Plugins (required
|
|
1333
|
+
console.log(chalk.cyan('\n Claude Code Plugins (required by morph-spec init)'));
|
|
1334
1334
|
const pluginsFile = join(homedir(), '.claude', 'plugins', 'installed_plugins.json');
|
|
1335
1335
|
let pluginData = { plugins: {} };
|
|
1336
1336
|
try {
|
|
1337
1337
|
pluginData = JSON.parse(await fs.readFile(pluginsFile, 'utf8'));
|
|
1338
1338
|
} catch { /* file may not exist */ }
|
|
1339
1339
|
const pluginStatus = checkInstalledPlugins(pluginData.plugins || {});
|
|
1340
|
-
check('superpowers plugin', pluginStatus.superpowers, false,
|
|
1341
|
-
'Run: morph-spec install-plugin superpowers');
|
|
1342
1340
|
check('context7 plugin', pluginStatus.context7, false,
|
|
1343
1341
|
'Run: morph-spec install-plugin context7');
|
|
1344
1342
|
} else {
|
|
@@ -34,6 +34,7 @@ import { installAgents, installDomainAgents } from '../../utils/agents-installer
|
|
|
34
34
|
import { getProjectTags } from '../../lib/stack-filter.js';
|
|
35
35
|
import { updateCommand } from './update.js';
|
|
36
36
|
import { resolvePrimaryRoot } from './worktree.js';
|
|
37
|
+
import { registerProject } from '../../lib/projects/registry.js';
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Guard against running a full `init` install from inside a secondary
|
|
@@ -135,8 +136,7 @@ export async function initCommand(options) {
|
|
|
135
136
|
try {
|
|
136
137
|
claudeConfigDetected = await detectClaudeConfig(targetPath);
|
|
137
138
|
const hasIntegrations = claudeConfigDetected.plugins.length > 0
|
|
138
|
-
|| claudeConfigDetected.mcpServers.length > 0
|
|
139
|
-
|| claudeConfigDetected.superpowers.installed;
|
|
139
|
+
|| claudeConfigDetected.mcpServers.length > 0;
|
|
140
140
|
|
|
141
141
|
if (hasIntegrations) {
|
|
142
142
|
spinner.stop();
|
|
@@ -287,7 +287,8 @@ export async function initCommand(options) {
|
|
|
287
287
|
try {
|
|
288
288
|
spinner.stop();
|
|
289
289
|
const existingMcps = claudeConfigDetected?.mcpServers || [];
|
|
290
|
-
const orchestration = orchestrateMcpSetup(targetPath, detectedStack, existingMcps
|
|
290
|
+
const orchestration = orchestrateMcpSetup(targetPath, detectedStack, existingMcps,
|
|
291
|
+
{ integrations: config.project?.integrations ?? [] });
|
|
291
292
|
|
|
292
293
|
const autoNames = Object.keys(orchestration.autoInstallable);
|
|
293
294
|
const manualNames = Object.keys(orchestration.needsManualSetup);
|
|
@@ -467,6 +468,8 @@ export async function initCommand(options) {
|
|
|
467
468
|
}
|
|
468
469
|
|
|
469
470
|
spinner.succeed('MORPH-SPEC installed successfully!');
|
|
471
|
+
// The dashboard's portfolio learns about the project here (fail-open).
|
|
472
|
+
registerProject(targetPath, 'init');
|
|
470
473
|
|
|
471
474
|
// Show next steps
|
|
472
475
|
logger.blank();
|
|
@@ -5,7 +5,7 @@ import { logger } from '../../utils/logger.js';
|
|
|
5
5
|
export async function installPluginCommand(pluginName, _options) {
|
|
6
6
|
if (!pluginName) {
|
|
7
7
|
logger.error('Plugin name required. Usage: morph-spec install-plugin <name>');
|
|
8
|
-
logger.dim(' Available:
|
|
8
|
+
logger.dim(' Available: context7');
|
|
9
9
|
process.exit(1);
|
|
10
10
|
}
|
|
11
11
|
try {
|
|
@@ -33,6 +33,7 @@ import { getProjectTags } from '../../lib/stack-filter.js';
|
|
|
33
33
|
import { updateClaudeMdAgentsBlock, installRulesForStack } from '../../scripts/setup-infra.js';
|
|
34
34
|
import { reconcileLegacyTemplatesCopy } from '../../lib/installers/templates-reconcile.js';
|
|
35
35
|
import { createEffects } from '../../lib/installers/effects.js';
|
|
36
|
+
import { registerProject } from '../../lib/projects/registry.js';
|
|
36
37
|
import {
|
|
37
38
|
writeGraphifyignore, describeOutdatedIgnore, graphifyignoreTracked,
|
|
38
39
|
} from '../../lib/graph/graphifyignore.js';
|
|
@@ -758,6 +759,10 @@ export async function updateCommand(options = {}) {
|
|
|
758
759
|
logger.blank();
|
|
759
760
|
|
|
760
761
|
if (!dryRun) {
|
|
762
|
+
// The dashboard's portfolio learns about the project here (fail-open;
|
|
763
|
+
// outside the project, so not an effect of the update itself).
|
|
764
|
+
registerProject(targetPath, 'update');
|
|
765
|
+
|
|
761
766
|
// Show version change
|
|
762
767
|
if (projectCheck.current && projectCheck.current !== cliCheck.current) {
|
|
763
768
|
logger.success(`Updated: ${projectCheck.current} → ${cliCheck.current}`);
|
|
@@ -1,28 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Routes, Route, Navigate, useLocation, useParams } from 'react-router-dom';
|
|
3
|
+
import Sidebar, { MobileNav } from './components/Sidebar.jsx';
|
|
4
|
+
import ErrorBoundary from './components/ErrorBoundary.jsx';
|
|
5
|
+
import CommandPalette from './components/CommandPalette.jsx';
|
|
6
|
+
import Portfolio from './pages/Portfolio.jsx';
|
|
7
|
+
import Features, { isWorking } from './pages/Features.jsx';
|
|
8
|
+
import FeatureDetail from './pages/FeatureDetail.jsx';
|
|
9
|
+
import Activity from './pages/Activity.jsx';
|
|
3
10
|
import AgentMap from './pages/AgentMap.jsx';
|
|
4
11
|
import PhasePipeline from './pages/PhasePipeline.jsx';
|
|
5
12
|
import HookInspector from './pages/HookInspector.jsx';
|
|
6
13
|
import SkillsLibrary from './pages/SkillsLibrary.jsx';
|
|
7
14
|
import RulesMap from './pages/RulesMap.jsx';
|
|
8
15
|
import Standards from './pages/Standards.jsx';
|
|
9
|
-
import
|
|
16
|
+
import Guide from './pages/Guide.jsx';
|
|
17
|
+
import Rubrics from './pages/Rubrics.jsx';
|
|
18
|
+
import { useNow } from './hooks/usePref.js';
|
|
19
|
+
import { useProjects, useCurrentProject, projectHref } from './lib/project.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* What the sidebar and the tab title say at a glance, from the portfolio:
|
|
23
|
+
* per project, how many features are active, waiting on you and being worked
|
|
24
|
+
* on right now.
|
|
25
|
+
*/
|
|
26
|
+
function usePulse(portfolio) {
|
|
27
|
+
const now = useNow();
|
|
28
|
+
const byProject = {};
|
|
29
|
+
for (const p of portfolio?.projects || []) {
|
|
30
|
+
const s = p.summary;
|
|
31
|
+
byProject[p.id] = s
|
|
32
|
+
? { active: s.active, awaiting: s.awaiting, working: s.activeFeatures.filter((f) => isWorking(f, now)).length }
|
|
33
|
+
: null;
|
|
34
|
+
}
|
|
35
|
+
const awaiting = Object.values(byProject).reduce((n, x) => n + (x?.awaiting || 0), 0);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
document.title = awaiting ? `(${awaiting}) morph-spec` : 'morph-spec';
|
|
38
|
+
}, [awaiting]);
|
|
39
|
+
return { byProject, awaiting };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function ProjectIndex() {
|
|
43
|
+
const { project } = useParams();
|
|
44
|
+
return <Navigate to={projectHref(project)} replace />;
|
|
45
|
+
}
|
|
10
46
|
|
|
11
47
|
export default function App() {
|
|
48
|
+
const { pathname } = useLocation();
|
|
49
|
+
const { data: portfolio } = useProjects();
|
|
50
|
+
const current = useCurrentProject(portfolio);
|
|
51
|
+
const pulse = usePulse(portfolio);
|
|
52
|
+
const [palette, setPalette] = useState(false);
|
|
53
|
+
// Ctrl+K / Cmd+K opens the search from anywhere.
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const onKey = (e) => {
|
|
56
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); setPalette((o) => !o); }
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener('keydown', onKey);
|
|
59
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
60
|
+
}, []);
|
|
61
|
+
const nav = { portfolio, current: current.id, pulse, onSearch: () => setPalette(true) };
|
|
12
62
|
return (
|
|
13
|
-
<div className="flex h-
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
63
|
+
<div className="flex h-full overflow-hidden">
|
|
64
|
+
<div className="ambient" aria-hidden="true" />
|
|
65
|
+
<Sidebar {...nav} />
|
|
66
|
+
<CommandPalette open={palette} onClose={() => setPalette(false)} portfolio={portfolio} project={current.id} />
|
|
67
|
+
<main className="relative z-10 flex-1 overflow-auto">
|
|
68
|
+
<MobileNav {...nav} />
|
|
69
|
+
{/* Inside <main>, keyed by route: a page that throws leaves the
|
|
70
|
+
sidebar alive, and navigating away remounts a clean boundary. */}
|
|
71
|
+
<ErrorBoundary key={pathname} page={pathname}>
|
|
72
|
+
<Routes>
|
|
73
|
+
<Route path="/" element={<Portfolio />} />
|
|
74
|
+
<Route path="/p/:project" element={<ProjectIndex />} />
|
|
75
|
+
<Route path="/p/:project/features" element={<Features />} />
|
|
76
|
+
<Route path="/p/:project/features/:name" element={<FeatureDetail />} />
|
|
77
|
+
<Route path="/p/:project/activity" element={<Activity />} />
|
|
78
|
+
<Route path="/guide" element={<Guide />} />
|
|
79
|
+
<Route path="/guide/:doc" element={<Guide />} />
|
|
80
|
+
<Route path="/rubrics" element={<Rubrics />} />
|
|
81
|
+
<Route path="/agents" element={<AgentMap />} />
|
|
82
|
+
<Route path="/phases" element={<PhasePipeline />} />
|
|
83
|
+
<Route path="/hooks" element={<HookInspector />} />
|
|
84
|
+
<Route path="/skills" element={<SkillsLibrary />} />
|
|
85
|
+
<Route path="/rules" element={<RulesMap />} />
|
|
86
|
+
<Route path="/standards" element={<Standards />} />
|
|
87
|
+
<Route path="*" element={<Navigate to="/" replace />} />
|
|
88
|
+
</Routes>
|
|
89
|
+
</ErrorBoundary>
|
|
26
90
|
</main>
|
|
27
91
|
</div>
|
|
28
92
|
);
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import {
|
|
4
|
+
ChatCircleText, Question, BookOpenText, PaperPlaneTilt, ArrowBendDownLeft, CheckSquare, ShieldCheck, Flag, WarningOctagon,
|
|
5
|
+
PencilSimpleLine, Eye, TerminalWindow, Wrench,
|
|
6
|
+
} from '@phosphor-icons/react';
|
|
7
|
+
import { useMorphQuery } from '../hooks/useMorphQuery.js';
|
|
8
|
+
import EntityLink from './EntityLink.jsx';
|
|
9
|
+
import { apiBase, featureHref } from '../lib/project.js';
|
|
10
|
+
import { clock, dayLabel } from '../lib/format.js';
|
|
11
|
+
import { phaseMeta } from '../lib/phases.js';
|
|
12
|
+
|
|
13
|
+
export const KIND_META = {
|
|
14
|
+
prompt: { label: 'Você', icon: ChatCircleText },
|
|
15
|
+
question: { label: 'Perguntas', icon: Question },
|
|
16
|
+
skill: { label: 'Skills', icon: BookOpenText },
|
|
17
|
+
dispatch: { label: 'Despachos', icon: PaperPlaneTilt },
|
|
18
|
+
handback: { label: 'Retornos', icon: ArrowBendDownLeft },
|
|
19
|
+
task: { label: 'Tasks', icon: CheckSquare },
|
|
20
|
+
verify: { label: 'Verify', icon: ShieldCheck },
|
|
21
|
+
gate: { label: 'Gates', icon: Flag },
|
|
22
|
+
failure: { label: 'Falhas', icon: WarningOctagon },
|
|
23
|
+
write: { label: 'Escritas', icon: PencilSimpleLine },
|
|
24
|
+
read: { label: 'Leituras', icon: Eye },
|
|
25
|
+
command: { label: 'Comandos', icon: TerminalWindow },
|
|
26
|
+
tool: { label: 'Outras tools', icon: Wrench },
|
|
27
|
+
};
|
|
28
|
+
const DEFAULT = ['prompt', 'question', 'skill', 'dispatch', 'handback', 'task', 'verify', 'gate', 'failure'];
|
|
29
|
+
|
|
30
|
+
const NODE_TONE = { pass: 'text-[var(--color-ok)]', fail: 'text-[var(--color-bad)]', skip: 'text-[var(--color-faint)]' };
|
|
31
|
+
|
|
32
|
+
function Line({ item, showFeature, project }) {
|
|
33
|
+
const Icon = KIND_META[item.kind]?.icon || Wrench;
|
|
34
|
+
const tone = item.status === 'fail' ? 'text-[var(--color-bad)]' : item.status === 'ok' ? 'text-[var(--color-ok)]' : 'text-[var(--color-dim)]';
|
|
35
|
+
return (
|
|
36
|
+
<li className="grid grid-cols-[3rem_1.25rem_minmax(0,1fr)] gap-3 py-2.5">
|
|
37
|
+
<time className="pt-px font-mono text-xs tabular-nums text-[var(--color-faint)]" dateTime={item.ts}>{clock(item.ts)}</time>
|
|
38
|
+
<Icon weight="light" size={17} className={tone} aria-hidden="true" />
|
|
39
|
+
<div className="min-w-0">
|
|
40
|
+
<p className="text-sm text-[var(--color-fg)]">
|
|
41
|
+
{item.refs?.persona ? (
|
|
42
|
+
<>{item.title.replace(`morph-${item.refs.persona}`, '')}<EntityLink kind="persona" id={item.refs.persona}>morph-{item.refs.persona}</EntityLink></>
|
|
43
|
+
) : item.refs?.skill ? (
|
|
44
|
+
<>Carregou a skill <EntityLink kind="skill" id={item.refs.skill} /></>
|
|
45
|
+
) : item.title}
|
|
46
|
+
{showFeature && item.feature && (
|
|
47
|
+
<Link to={featureHref(project, item.feature)} className="ml-2 text-xs text-[var(--color-faint)] hover:text-[var(--color-dim)]">{item.feature}</Link>
|
|
48
|
+
)}
|
|
49
|
+
{item.phase && (
|
|
50
|
+
<span className="ml-2 text-xs" style={{ color: phaseMeta(item.phase).color }}>{phaseMeta(item.phase).label.toLowerCase()}</span>
|
|
51
|
+
)}
|
|
52
|
+
{item.agent && item.kind !== 'handback' && (
|
|
53
|
+
<span className="ml-2 text-xs text-[var(--color-faint)]">por {item.agent}</span>
|
|
54
|
+
)}
|
|
55
|
+
</p>
|
|
56
|
+
{item.detail && <p className="mt-0.5 line-clamp-2 break-words text-sm text-[var(--color-dim)]">{item.detail}</p>}
|
|
57
|
+
{item.nodes?.length > 0 && (
|
|
58
|
+
<p className="mt-1 flex flex-wrap gap-x-3 gap-y-1 font-mono text-xs">
|
|
59
|
+
{item.nodes.map((n) => (
|
|
60
|
+
<span key={n.name} className={NODE_TONE[n.status] || 'text-[var(--color-dim)]'}>{n.name} {n.status}</span>
|
|
61
|
+
))}
|
|
62
|
+
</p>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
</li>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Group consecutive items by calendar day, newest day first. */
|
|
70
|
+
function byDay(items) {
|
|
71
|
+
const groups = [];
|
|
72
|
+
for (const it of items) {
|
|
73
|
+
const key = (it.ts || '').slice(0, 10);
|
|
74
|
+
const last = groups[groups.length - 1];
|
|
75
|
+
if (last && last.key === key) last.items.push(it);
|
|
76
|
+
else groups.push({ key, ts: it.ts, items: [it] });
|
|
77
|
+
}
|
|
78
|
+
return groups;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function FeedView({ items, kinds, onToggleKind, showFeature, onMore, hasMore, total, project }) {
|
|
82
|
+
return (
|
|
83
|
+
<div>
|
|
84
|
+
<div className="mb-5 flex flex-wrap gap-2" role="group" aria-label="Tipos de evento">
|
|
85
|
+
{Object.entries(KIND_META).map(([kind, meta]) => {
|
|
86
|
+
const on = kinds.includes(kind);
|
|
87
|
+
return (
|
|
88
|
+
<button
|
|
89
|
+
key={kind}
|
|
90
|
+
type="button"
|
|
91
|
+
aria-pressed={on}
|
|
92
|
+
onClick={() => onToggleKind(kind)}
|
|
93
|
+
className={[
|
|
94
|
+
'fluid rounded-full px-3 py-1 text-xs transition-colors active:scale-[0.98]',
|
|
95
|
+
on ? 'bg-white/[0.09] text-[var(--color-fg)] shadow-[inset_0_0_0_1px_var(--color-hair-strong)]' : 'text-[var(--color-faint)] shadow-[inset_0_0_0_1px_var(--color-hair)] hover:text-[var(--color-dim)]',
|
|
96
|
+
].join(' ')}
|
|
97
|
+
>
|
|
98
|
+
{meta.label}
|
|
99
|
+
</button>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</div>
|
|
103
|
+
{items.length === 0 && (
|
|
104
|
+
<p className="text-sm text-[var(--color-dim)]">
|
|
105
|
+
Nada registrado com esses filtros. A telemetria vem de <code className="font-mono">.morph/logs/events.jsonl</code>, gravada pelos hooks enquanto o Claude trabalha.
|
|
106
|
+
</p>
|
|
107
|
+
)}
|
|
108
|
+
{byDay(items).map((g) => (
|
|
109
|
+
<section key={g.key} className="mb-6">
|
|
110
|
+
<h3 className="sticky top-0 z-10 -mx-1 bg-[var(--color-core)] px-1 py-1.5 text-xs font-medium text-[var(--color-dim)] first-letter:uppercase">{dayLabel(g.ts)}</h3>
|
|
111
|
+
<ul className="divide-y divide-[var(--color-hair)]">
|
|
112
|
+
{g.items.map((it) => <Line key={it.id} item={it} showFeature={showFeature} project={project} />)}
|
|
113
|
+
</ul>
|
|
114
|
+
</section>
|
|
115
|
+
))}
|
|
116
|
+
{hasMore && (
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
onClick={onMore}
|
|
120
|
+
className="fluid rounded-full px-4 py-2 text-sm text-[var(--color-dim)] shadow-[inset_0_0_0_1px_var(--color-hair)] transition-colors hover:text-[var(--color-fg)] active:scale-[0.98]"
|
|
121
|
+
>
|
|
122
|
+
Carregar anteriores
|
|
123
|
+
</button>
|
|
124
|
+
)}
|
|
125
|
+
{typeof total === 'number' && items.length > 0 && (
|
|
126
|
+
<p className="mt-3 text-xs text-[var(--color-faint)]">{items.length} de {total} eventos</p>
|
|
127
|
+
)}
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Live activity feed. The first page follows the server's `morph:changed`
|
|
134
|
+
* pushes; older pages are fetched on demand and appended.
|
|
135
|
+
*/
|
|
136
|
+
export default function ActivityFeed({ project, feature, showFeature = false }) {
|
|
137
|
+
const [kinds, setKinds] = useState(DEFAULT);
|
|
138
|
+
const [older, setOlder] = useState([]);
|
|
139
|
+
const [cursor, setCursor] = useState(null);
|
|
140
|
+
const params = new URLSearchParams({ kinds: kinds.join(','), limit: '80' });
|
|
141
|
+
if (feature) params.set('feature', feature);
|
|
142
|
+
const { data, error } = useMorphQuery(`${apiBase(project)}/activity?${params}`, { scope: 'activity', project });
|
|
143
|
+
|
|
144
|
+
useEffect(() => { setOlder([]); setCursor(null); }, [feature, kinds.join(',')]);
|
|
145
|
+
|
|
146
|
+
const next = cursor === null ? data?.next : cursor;
|
|
147
|
+
const loadMore = async () => {
|
|
148
|
+
if (!next) return;
|
|
149
|
+
const p = new URLSearchParams(params);
|
|
150
|
+
p.set('before', next);
|
|
151
|
+
const res = await fetch(`${apiBase(project)}/activity?${p}`);
|
|
152
|
+
const page = await res.json();
|
|
153
|
+
setOlder((o) => [...o, ...page.items]);
|
|
154
|
+
setCursor(page.next || '');
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
if (error) return <p className="text-sm text-[var(--color-bad)]">Não consegui ler a atividade: {error}</p>;
|
|
158
|
+
if (!data) return <p className="text-sm text-[var(--color-faint)]">Lendo a telemetria…</p>;
|
|
159
|
+
const toggle = (k) => setKinds((ks) => (ks.includes(k) ? ks.filter((x) => x !== k) : [...ks, k]));
|
|
160
|
+
return (
|
|
161
|
+
<FeedView
|
|
162
|
+
items={[...data.items, ...older]}
|
|
163
|
+
kinds={kinds}
|
|
164
|
+
onToggleKind={toggle}
|
|
165
|
+
showFeature={showFeature}
|
|
166
|
+
onMore={loadMore}
|
|
167
|
+
hasMore={Boolean(next)}
|
|
168
|
+
total={data.total}
|
|
169
|
+
project={project}
|
|
170
|
+
/>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import morphData from 'virtual:morph-data';
|
|
4
|
+
import { MagnifyingGlass } from '@phosphor-icons/react';
|
|
5
|
+
import { entityHref } from './EntityLink.jsx';
|
|
6
|
+
import { tocOf } from '../pages/Guide.jsx';
|
|
7
|
+
import { useMorphQuery } from '../hooks/useMorphQuery.js';
|
|
8
|
+
import { apiBase, projectHref, featureHref } from '../lib/project.js';
|
|
9
|
+
|
|
10
|
+
const KIND_LABEL = {
|
|
11
|
+
page: 'Página', project: 'Projeto', feature: 'Feature', task: 'Task', skill: 'Skill', persona: 'Persona',
|
|
12
|
+
standard: 'Standard', rule: 'Rule', hook: 'Hook', guide: 'Guia', rubric: 'Rubrica',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const PAGES = [
|
|
16
|
+
['Portfólio', '/'], ['Guia', '/guide'], ['Fases', '/phases'], ['Skills', '/skills'],
|
|
17
|
+
['Personas', '/agents'], ['Standards', '/standards'], ['Rules', '/rules'], ['Hooks', '/hooks'], ['Rubricas', '/rubrics'],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** Everything the framework knows that has a page — built once. */
|
|
21
|
+
function knowledgeIndex() {
|
|
22
|
+
const out = PAGES.map(([title, to]) => ({ kind: 'page', title, to, hay: title }));
|
|
23
|
+
for (const s of morphData.skills || []) out.push({ kind: 'skill', title: s.id, hint: s.description, to: entityHref('skill', s.id), hay: `${s.id} ${s.description}` });
|
|
24
|
+
for (const a of morphData.agents?.list || []) out.push({ kind: 'persona', title: `morph-${a.id}`, hint: a.title, to: entityHref('persona', a.id), hay: `${a.id} ${a.title} ${(a.keywords || []).join(' ')}` });
|
|
25
|
+
for (const s of morphData.standards?.list || []) out.push({ kind: 'standard', title: s.name, hint: s.id, to: entityHref('standard', s.id), hay: `${s.name} ${s.id} ${(s.aliases || []).join(' ')} ${(s.tags || []).join(' ')}` });
|
|
26
|
+
for (const r of morphData.rules || []) out.push({ kind: 'rule', title: r.name, hint: (r.paths || []).join(', '), to: entityHref('rule', r.name), hay: `${r.name} ${(r.paths || []).join(' ')}` });
|
|
27
|
+
const hooks = new Set();
|
|
28
|
+
for (const h of morphData.hooks || []) {
|
|
29
|
+
if (hooks.has(h.name)) continue;
|
|
30
|
+
hooks.add(h.name);
|
|
31
|
+
out.push({ kind: 'hook', title: h.name, hint: h.description, to: entityHref('hook', h.name), hay: `${h.name} ${h.description || ''}` });
|
|
32
|
+
}
|
|
33
|
+
for (const d of morphData.docs?.guide || []) {
|
|
34
|
+
for (const h of tocOf(d).filter((x) => x.depth >= 2)) {
|
|
35
|
+
out.push({ kind: 'guide', title: h.text, hint: d.title, to: `/guide/${d.id}#${h.slug}`, hay: `${h.text} ${d.title}` });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const r of morphData.docs?.rubrics || []) out.push({ kind: 'rubric', title: r.title, to: `/rubrics?sel=${encodeURIComponent(`dim:${r.id}`)}`, hay: r.title });
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function projectIndex(portfolio) {
|
|
43
|
+
return (portfolio?.projects || []).map((p) => ({ kind: 'project', title: p.name, hint: p.dir, to: projectHref(p.id), hay: `${p.name} ${p.dir}` }));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Features and their tasks. `projectName` is set for another project's
|
|
48
|
+
* features, so a hit says where it lives.
|
|
49
|
+
*/
|
|
50
|
+
function featureIndex(project, features, projectName = null) {
|
|
51
|
+
const out = [];
|
|
52
|
+
const where = (text) => (projectName ? (text ? `${projectName}: ${text}` : projectName) : text);
|
|
53
|
+
for (const f of features || []) {
|
|
54
|
+
out.push({ kind: 'feature', title: f.name, hint: where(f.description), to: featureHref(project, f.name), hay: `${f.name} ${f.description || ''} ${projectName || ''}` });
|
|
55
|
+
for (const t of f.taskIndex || []) {
|
|
56
|
+
out.push({ kind: 'task', title: `${t.id} ${t.title}`, hint: where(f.name), to: featureHref(project, f.name, '?tab=tasks'), hay: `${t.id} ${t.title} ${f.name} ${projectName || ''}` });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The active features of the other projects, from the portfolio's summaries. */
|
|
63
|
+
function otherProjectsIndex(portfolio, project) {
|
|
64
|
+
return (portfolio?.projects || [])
|
|
65
|
+
.filter((p) => p.id !== project && p.summary)
|
|
66
|
+
.flatMap((p) => featureIndex(p.id, p.summary.activeFeatures, p.name));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Every query word must appear; a title that starts with the query ranks first. */
|
|
70
|
+
export function searchIndex(index, query, limit = 40) {
|
|
71
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
72
|
+
if (!words.length) return [];
|
|
73
|
+
const scored = [];
|
|
74
|
+
for (const item of index) {
|
|
75
|
+
const hay = item.hay.toLowerCase();
|
|
76
|
+
if (!words.every((w) => hay.includes(w))) continue;
|
|
77
|
+
const title = item.title.toLowerCase();
|
|
78
|
+
const score = (title.startsWith(words[0]) ? 0 : title.includes(words[0]) ? 1 : 2) + (item.kind === 'page' ? -1 : 0);
|
|
79
|
+
scored.push({ item, score });
|
|
80
|
+
}
|
|
81
|
+
return scored.sort((a, b) => a.score - b.score || a.item.title.length - b.item.title.length).slice(0, limit).map((s) => s.item);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function CommandPalette({ open, onClose, portfolio, project }) {
|
|
85
|
+
const navigate = useNavigate();
|
|
86
|
+
const [query, setQuery] = useState('');
|
|
87
|
+
const [active, setActive] = useState(0);
|
|
88
|
+
const inputRef = useRef(null);
|
|
89
|
+
const knowledge = useMemo(knowledgeIndex, []);
|
|
90
|
+
const { data } = useMorphQuery(open && project ? `${apiBase(project)}/features` : null, { project });
|
|
91
|
+
const index = useMemo(
|
|
92
|
+
() => [...featureIndex(project, data?.features), ...otherProjectsIndex(portfolio, project), ...projectIndex(portfolio), ...knowledge],
|
|
93
|
+
[data, knowledge, portfolio, project],
|
|
94
|
+
);
|
|
95
|
+
const results = useMemo(() => searchIndex(index, query), [index, query]);
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (open) { setQuery(''); setActive(0); setTimeout(() => inputRef.current?.focus(), 0); }
|
|
99
|
+
}, [open]);
|
|
100
|
+
useEffect(() => { setActive(0); }, [query]);
|
|
101
|
+
|
|
102
|
+
if (!open) return null;
|
|
103
|
+
const go = (item) => { onClose(); navigate(item.to); };
|
|
104
|
+
const onKey = (e) => {
|
|
105
|
+
if (e.key === 'Escape') onClose();
|
|
106
|
+
else if (e.key === 'ArrowDown') { e.preventDefault(); setActive((i) => Math.min(i + 1, results.length - 1)); }
|
|
107
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); setActive((i) => Math.max(i - 1, 0)); }
|
|
108
|
+
else if (e.key === 'Enter' && results[active]) go(results[active]);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className="fixed inset-0 z-50 flex items-start justify-center bg-black/60 px-4 pt-[12vh] backdrop-blur-sm" onMouseDown={onClose} role="presentation">
|
|
113
|
+
<div role="dialog" aria-modal="true" aria-label="Busca" className="bezel w-full max-w-2xl" onMouseDown={(e) => e.stopPropagation()}>
|
|
114
|
+
<div className="bezel-core overflow-hidden">
|
|
115
|
+
<label className="flex items-center gap-3 border-b border-[var(--color-hair)] px-5 py-4">
|
|
116
|
+
<MagnifyingGlass weight="light" size={18} className="text-[var(--color-faint)]" />
|
|
117
|
+
<span className="sr-only">Buscar em tudo</span>
|
|
118
|
+
<input
|
|
119
|
+
ref={inputRef}
|
|
120
|
+
value={query}
|
|
121
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
122
|
+
onKeyDown={onKey}
|
|
123
|
+
placeholder="Buscar features, tasks, skills, personas, standards, seções do guia…"
|
|
124
|
+
className="w-full bg-transparent text-base text-[var(--color-fg)] outline-none focus-visible:outline-none placeholder:text-[var(--color-faint)]"
|
|
125
|
+
aria-controls="palette-results"
|
|
126
|
+
aria-activedescendant={results[active] ? `palette-${active}` : undefined}
|
|
127
|
+
/>
|
|
128
|
+
<kbd className="rounded-md px-1.5 font-mono text-[11px] text-[var(--color-faint)] shadow-[inset_0_0_0_1px_var(--color-hair)]">Esc</kbd>
|
|
129
|
+
</label>
|
|
130
|
+
<ul id="palette-results" role="listbox" className="max-h-[55vh] overflow-y-auto p-2">
|
|
131
|
+
{query && results.length === 0 && <li className="px-3 py-6 text-center text-sm text-[var(--color-dim)]">Nada encontrado para “{query}”.</li>}
|
|
132
|
+
{!query && <li className="px-3 py-6 text-center text-sm text-[var(--color-faint)]">Digite para buscar. Setas navegam, Enter abre.</li>}
|
|
133
|
+
{results.map((r, i) => (
|
|
134
|
+
<li
|
|
135
|
+
key={`${r.kind}:${r.to}:${r.title}`}
|
|
136
|
+
id={`palette-${i}`}
|
|
137
|
+
role="option"
|
|
138
|
+
aria-selected={i === active}
|
|
139
|
+
onMouseEnter={() => setActive(i)}
|
|
140
|
+
onClick={() => go(r)}
|
|
141
|
+
className={['flex cursor-pointer items-baseline gap-3 rounded-lg px-3 py-2', i === active ? 'bg-white/[0.07]' : ''].join(' ')}
|
|
142
|
+
>
|
|
143
|
+
<span className="w-16 shrink-0 text-xs text-[var(--color-faint)]">{KIND_LABEL[r.kind]}</span>
|
|
144
|
+
<span className="min-w-0 flex-1">
|
|
145
|
+
<span className="block truncate text-sm text-[var(--color-fg)]">{r.title}</span>
|
|
146
|
+
{r.hint && <span className="block truncate text-xs text-[var(--color-dim)]">{r.hint}</span>}
|
|
147
|
+
</span>
|
|
148
|
+
</li>
|
|
149
|
+
))}
|
|
150
|
+
</ul>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|