@polymorphism-tech/morph-spec 10.12.1 → 11.1.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 +27 -57
- package/README.md +53 -338
- package/bin/morph-spec.js +22 -373
- package/docs/CHEATSHEET.md +37 -166
- package/docs/QUICKSTART.md +14 -74
- package/framework/CLAUDE.md +15 -26
- package/framework/MORPH.md +34 -101
- package/framework/agents.json +12 -9
- package/framework/commands/morph-apply.md +5 -5
- package/framework/commands/morph-infra.md +1 -1
- package/framework/docs/CLI.md +74 -886
- package/framework/evals/review-checklist.md +14 -14
- package/framework/hooks/README.md +21 -189
- package/framework/hooks/claude-code/core/README.md +2 -5
- package/framework/hooks/claude-code/core/conventional-commit.js +2 -2
- package/framework/hooks/claude-code/core/denylist.json +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/hooks/claude-code/core/masked-exit.js +6 -6
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +17 -61
- package/framework/hooks/claude-code/core/stack-changed.js +35 -0
- package/framework/hooks/claude-code/core/validate-completion.js +32 -87
- package/framework/hooks/shared/{heavy-command.js → command-kind.js} +6 -79
- package/framework/hooks/shared/command-tokens.js +0 -139
- package/framework/hooks/shared/contract.js +14 -0
- package/framework/hooks/shared/feature-slug.js +21 -0
- package/framework/hooks/shared/frontend-locations.js +0 -1
- package/framework/hooks/shared/git-paths.js +0 -15
- package/framework/hooks/shared/graph-freshness.js +0 -19
- package/framework/hooks/shared/hook-response.js +0 -7
- package/framework/hooks/shared/morph-cli.js +2 -81
- package/framework/hooks/shared/owner-words.js +2 -120
- package/framework/hooks/shared/payload-utils.js +0 -39
- package/framework/hooks/shared/report-progress.js +7 -101
- package/framework/hooks/statusline.js +16 -60
- package/framework/mcp/registry.json +2 -2
- package/framework/rules/ai-agents-standards.md +1 -1
- package/framework/rules/asaas-standards.md +1 -1
- package/framework/rules/ef-standards.md +1 -1
- package/framework/rules/gsap-standards.md +1 -1
- package/framework/rules/hangfire-standards.md +1 -1
- package/framework/rules/implement-report.md +3 -3
- package/framework/rules/neon-auth-standards.md +1 -1
- package/framework/rules/nextjs-standards.md +1 -1
- package/framework/rules/plan-grammar.md +15 -13
- package/framework/rules/resend-standards.md +1 -1
- package/framework/rules/ui-design.md +5 -1
- package/framework/schemas/config.schema.json +95 -310
- package/framework/skills/README.md +12 -32
- 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 +21 -46
- package/framework/skills/core/morph-plan/SKILL.md +28 -63
- package/framework/skills/core/morph-uiux/SKILL.md +23 -25
- package/framework/{templates/docs/ui-mockups.md → skills/core/morph-uiux/references/mockups.md} +4 -4
- package/framework/standards/STANDARDS.json +10 -11
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/evals-with-cache.md +18 -32
- package/framework/standards/ai-agents/observability-patterns.md +2 -2
- package/framework/standards/architecture/code-comments.md +2 -5
- package/framework/standards/architecture/engineering-lens.md +1 -1
- package/framework/standards/backend/dotnet/testing.md +4 -4
- package/framework/standards/frontend/nextjs/lint.md +24 -10
- package/framework/standards/frontend/nextjs/testing.md +2 -2
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +14 -30
- package/framework/templates/CLAUDE.md.core.guide.md +2 -2
- package/framework/templates/README.md +1 -1
- package/framework/templates/REGISTRY.json +3 -33
- package/framework/templates/docs/plan.md +3 -2
- package/framework/templates/dotnet/ai-kit/README.md +2 -4
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +1 -1
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +1 -1
- package/package.json +1 -2
- package/src/commands/graph/explain.js +2 -1
- package/src/commands/graph/status.js +2 -1
- package/src/commands/mcp/mcp-setup.js +1 -2
- package/src/commands/project/doctor.js +13 -342
- package/src/commands/project/env.js +21 -52
- package/src/commands/project/init-contract.js +47 -0
- package/src/commands/project/init.js +36 -66
- package/src/commands/project/stack-scan.js +1 -1
- package/src/commands/project/update.js +16 -53
- package/src/commands/validation/check.js +128 -0
- package/src/commands/validation/plan-check.js +41 -64
- package/src/commands/validation/prove-red.js +1 -1
- package/src/core/paths/output-schema.js +0 -22
- package/src/core/templates/template-renderer.js +0 -14
- package/src/lib/ai/ai-project-scan.js +1 -6
- package/src/lib/check/attempts.js +38 -0
- package/src/lib/check/signals.js +145 -0
- package/src/lib/config/project-config.js +13 -0
- package/src/lib/contract/apply.js +62 -0
- package/src/lib/contract/defaults.js +96 -0
- package/src/lib/contract/merge.js +79 -0
- package/src/lib/contract/ports.js +43 -0
- package/src/lib/contract/scan.js +102 -0
- package/src/lib/detectors/claude-config-detector.js +7 -0
- package/src/lib/{procs → detectors}/mcp-config.js +1 -37
- package/src/lib/diff/diff-lines.js +64 -0
- package/src/lib/generators/architecture-scanner.js +1 -1
- package/src/lib/generators/scaffold-generator.js +0 -7
- package/src/lib/git/default-branch.js +0 -122
- package/src/lib/graph/diff-tree.js +2 -1
- package/src/lib/graph/god-nodes.js +2 -1
- package/src/lib/graph/graphify-runtime.js +0 -1
- package/src/lib/graph/graphifyignore.js +1 -1
- package/src/lib/graph/sanitize.js +2 -8
- package/src/lib/installers/memory-installer.js +15 -30
- package/src/lib/installers/stack-sync.js +16 -9
- package/src/lib/plan/checks.js +20 -64
- package/src/lib/plan/media.js +1 -1
- package/src/lib/plan/plan-parser.js +5 -5
- package/src/lib/review-reports.js +3 -77
- package/src/lib/scan/worktree-dirs.js +3 -0
- package/src/lib/specs/adr-index.js +2 -2
- package/src/lib/stack/dotnet-build-ignores.js +10 -2
- package/src/lib/stack/stack-scan.js +2 -2
- package/src/lib/stack-filter.js +3 -2
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/scripts/setup-infra.js +6 -59
- package/src/utils/agents-installer.js +13 -37
- package/src/utils/atomic-json.js +27 -0
- package/src/utils/file-copier.js +24 -24
- package/src/utils/hooks-installer.js +9 -107
- package/claude-plugin.json +0 -14
- package/framework/commands/morph-archive.md +0 -46
- package/framework/commands/morph-hotfix.md +0 -17
- package/framework/commands/morph-preflight.md +0 -180
- package/framework/commands/morph-review.md +0 -15
- package/framework/commands/morph-status.md +0 -37
- package/framework/hooks/claude-code/core/block-destructive-worktree-removal.js +0 -80
- package/framework/hooks/claude-code/core/block-raw-worktree-add.js +0 -72
- package/framework/hooks/claude-code/core/enforce-phase-writes.js +0 -100
- package/framework/hooks/claude-code/core/gate-guard.js +0 -148
- package/framework/hooks/claude-code/core/heavy-gate.js +0 -78
- package/framework/hooks/claude-code/core/heavy-release.js +0 -23
- package/framework/hooks/claude-code/core/loop-detect.js +0 -79
- package/framework/hooks/claude-code/core/state-sync.js +0 -214
- package/framework/hooks/claude-code/core/telemetry-log.js +0 -259
- package/framework/hooks/claude-code/core/test-budget.js +0 -29
- package/framework/hooks/claude-code/core/worktree-context.js +0 -249
- package/framework/hooks/claude-code/core/worktree-create.js +0 -119
- package/framework/hooks/claude-code/core/worktree-env-inject.js +0 -68
- package/framework/hooks/claude-code/core/worktree-remove.js +0 -55
- package/framework/hooks/shared/build-check.js +0 -120
- package/framework/hooks/shared/claim-registry.js +0 -125
- package/framework/hooks/shared/e2e-check.js +0 -1022
- package/framework/hooks/shared/feature-locator.js +0 -82
- package/framework/hooks/shared/gate-event.js +0 -18
- package/framework/hooks/shared/gate-question.js +0 -20
- package/framework/hooks/shared/heavy-config.js +0 -113
- package/framework/hooks/shared/heavy-holders.js +0 -85
- package/framework/hooks/shared/heavy-slots.js +0 -280
- package/framework/hooks/shared/host-services.js +0 -440
- package/framework/hooks/shared/next-step.js +0 -181
- package/framework/hooks/shared/redact-secrets.js +0 -44
- package/framework/hooks/shared/reparse-scan.js +0 -40
- package/framework/hooks/shared/state-reader.js +0 -220
- package/framework/hooks/shared/state-writer.js +0 -112
- package/framework/hooks/shared/telemetry-logger.js +0 -101
- package/framework/hooks/shared/transcript-usage.js +0 -58
- package/framework/hooks/shared/worktree-root.js +0 -71
- package/framework/phases.json +0 -92
- package/framework/schemas/feature.schema.json +0 -242
- package/framework/skills/core/morph-apply/references/hotfix.md +0 -46
- package/framework/skills/core/morph-apply/references/machine.md +0 -30
- package/framework/skills/core/morph-apply/references/review.md +0 -77
- package/framework/skills/core/morph-plan/references/critique.md +0 -51
- package/framework/skills/core/morph-plan/references/interview.md +0 -37
- package/framework/templates/state.template.json +0 -17
- package/src/commands/dashboard/dashboard.js +0 -74
- package/src/commands/e2e/e2e.js +0 -400
- package/src/commands/observability/cost.js +0 -283
- package/src/commands/project/branch.js +0 -129
- package/src/commands/project/claim.js +0 -132
- package/src/commands/project/doctor-procs.js +0 -162
- package/src/commands/project/fleet.js +0 -66
- package/src/commands/project/heavy.js +0 -81
- package/src/commands/project/install-plugin-cmd.js +0 -27
- package/src/commands/project/status.js +0 -61
- package/src/commands/project/worktree.js +0 -1234
- package/src/commands/state/advance.js +0 -248
- package/src/commands/state/approve.js +0 -303
- package/src/commands/state/archive.js +0 -231
- package/src/commands/state/auto-approval.js +0 -67
- package/src/commands/state/create.js +0 -274
- package/src/commands/state/delete.js +0 -192
- package/src/commands/state/finish.js +0 -1247
- package/src/commands/state/gate-check.js +0 -244
- package/src/commands/state/gate-decision.js +0 -122
- package/src/commands/state/list.js +0 -244
- package/src/commands/state/next.js +0 -24
- package/src/commands/state/recap.js +0 -80
- package/src/commands/state/report-check.js +0 -244
- package/src/commands/state/retype.js +0 -110
- package/src/commands/validation/verify.js +0 -421
- package/src/core/state/feature-identity.js +0 -10
- package/src/core/state/gate-order.js +0 -23
- package/src/core/state/lifecycle-audit.js +0 -171
- package/src/core/state/state-manager.js +0 -523
- package/src/core/templates/template-seed.js +0 -21
- package/src/core/work-types.js +0 -44
- package/src/dashboard/app/App.jsx +0 -84
- package/src/dashboard/app/components/ActivityFeed.jsx +0 -166
- package/src/dashboard/app/components/CommandPalette.jsx +0 -144
- package/src/dashboard/app/components/DetailPanel.jsx +0 -43
- package/src/dashboard/app/components/EntityLink.jsx +0 -42
- package/src/dashboard/app/components/ErrorBoundary.jsx +0 -47
- package/src/dashboard/app/components/FlowGraph.jsx +0 -19
- package/src/dashboard/app/components/GatePauses.jsx +0 -116
- package/src/dashboard/app/components/KnowledgeMarkdown.jsx +0 -42
- package/src/dashboard/app/components/Markdown.jsx +0 -38
- package/src/dashboard/app/components/PhaseRail.jsx +0 -100
- package/src/dashboard/app/components/SearchFilter.jsx +0 -36
- package/src/dashboard/app/components/SessionMap.jsx +0 -77
- package/src/dashboard/app/components/Sidebar.jsx +0 -147
- package/src/dashboard/app/hooks/useMorphQuery.js +0 -44
- package/src/dashboard/app/hooks/usePref.js +0 -34
- package/src/dashboard/app/lib/format.js +0 -69
- package/src/dashboard/app/lib/phases.js +0 -75
- package/src/dashboard/app/lib/project.js +0 -38
- package/src/dashboard/app/main.jsx +0 -13
- package/src/dashboard/app/pages/Activity.jsx +0 -28
- package/src/dashboard/app/pages/AgentMap.jsx +0 -363
- package/src/dashboard/app/pages/FeatureDetail.jsx +0 -579
- package/src/dashboard/app/pages/Features.jsx +0 -393
- package/src/dashboard/app/pages/Guide.jsx +0 -145
- package/src/dashboard/app/pages/HookInspector.jsx +0 -444
- package/src/dashboard/app/pages/PhasePipeline.jsx +0 -273
- package/src/dashboard/app/pages/Portfolio.jsx +0 -190
- package/src/dashboard/app/pages/RulesMap.jsx +0 -285
- package/src/dashboard/app/pages/SkillsLibrary.jsx +0 -468
- package/src/dashboard/app/pages/Standards.jsx +0 -392
- package/src/dashboard/app/styles/index.css +0 -187
- package/src/dashboard/index.html +0 -14
- package/src/dashboard/package.json +0 -32
- package/src/dashboard/scanner/activity-scanner.js +0 -321
- package/src/dashboard/scanner/agents-scanner.js +0 -67
- package/src/dashboard/scanner/docs-scanner.js +0 -34
- package/src/dashboard/scanner/feature-status.js +0 -7
- package/src/dashboard/scanner/features-scanner.js +0 -397
- package/src/dashboard/scanner/hooks-scanner.js +0 -96
- package/src/dashboard/scanner/index.js +0 -21
- package/src/dashboard/scanner/phases-scanner.js +0 -14
- package/src/dashboard/scanner/portfolio.js +0 -129
- package/src/dashboard/scanner/project-api.js +0 -160
- package/src/dashboard/scanner/rules-scanner.js +0 -46
- package/src/dashboard/scanner/skills-scanner.js +0 -104
- package/src/dashboard/scanner/standards-scanner.js +0 -38
- package/src/dashboard/vite-plugin-morph-data.js +0 -120
- package/src/dashboard/vite.config.js +0 -26
- package/src/lib/ci/ci-verify.js +0 -30
- package/src/lib/ci/github-ci.js +0 -52
- package/src/lib/ci/pr-checks.js +0 -76
- package/src/lib/e2e/applicability.js +0 -39
- package/src/lib/e2e/compose-env.js +0 -80
- package/src/lib/e2e/stack-teardown.js +0 -96
- package/src/lib/git/branch-classifier.js +0 -104
- package/src/lib/git/evidence-staleness.js +0 -40
- package/src/lib/git/gh.js +0 -15
- package/src/lib/git/pending-prs.js +0 -58
- package/src/lib/git/pr-files.js +0 -31
- package/src/lib/git/pr-index.js +0 -39
- package/src/lib/git/tree-fingerprint.js +0 -58
- package/src/lib/git/tree-state.js +0 -125
- package/src/lib/heavy/cleanup.js +0 -72
- package/src/lib/heavy/gate.js +0 -168
- package/src/lib/heavy/live-stacks.js +0 -64
- package/src/lib/heavy/reclaim.js +0 -107
- package/src/lib/heavy/watchdog.js +0 -46
- package/src/lib/next-step.js +0 -12
- package/src/lib/plan/critique.js +0 -67
- package/src/lib/plan/plan-template.js +0 -18
- package/src/lib/procs/classify.js +0 -91
- package/src/lib/procs/list.js +0 -124
- package/src/lib/procs/prune.js +0 -47
- package/src/lib/procs/wslconfig.js +0 -70
- package/src/lib/projects/registry.js +0 -121
- package/src/lib/recap/piper.js +0 -36
- package/src/lib/recap/recap.js +0 -259
- package/src/lib/review-confirmation.js +0 -66
- package/src/lib/risk/diff-risk.js +0 -137
- package/src/lib/risk-detector.js +0 -638
- package/src/lib/specs/design-seed.js +0 -18
- package/src/lib/specs/screen-checklist.js +0 -315
- package/src/lib/stack/stack-profile.js +0 -69
- package/src/lib/tasks/eval-node.js +0 -293
- package/src/lib/tasks/linux-runner.js +0 -200
- package/src/lib/tasks/test-nodes.js +0 -414
- package/src/lib/tasks/test-runner.js +0 -569
- package/src/lib/telemetry/metrics.js +0 -384
- package/src/lib/telemetry/telemetry-reader.js +0 -276
- package/src/lib/telemetry/verify-event.js +0 -57
- package/src/lib/validators/code-budget/code-budget-validator.js +0 -170
- package/src/lib/validators/contracts/contract-compliance-validator.js +0 -219
- package/src/lib/validators/nextjs/next-component-validator.js +0 -142
- package/src/lib/validators/packages/package-validator.js +0 -310
- package/src/lib/validators/reuse/reuse-validator.js +0 -202
- package/src/lib/validators/reuse/symbol-scanner.js +0 -64
- package/src/lib/validators/validation-runner.js +0 -188
- package/src/lib/validators/verify-cache.js +0 -63
- package/src/lib/validators/verify-runner.js +0 -971
- package/src/lib/verify/affected.js +0 -143
- package/src/lib/verify/detached.js +0 -159
- package/src/lib/view/feature-html.js +0 -480
- package/src/lib/view/feature-page.client.js +0 -109
- package/src/lib/view/feature-page.css +0 -278
- package/src/lib/view/feature-view.js +0 -113
- package/src/lib/view/flow-layers.js +0 -79
- package/src/lib/view/flow-svg.js +0 -63
- package/src/lib/view/tokens.css +0 -18
- package/src/lib/work-type-detector.js +0 -81
- package/src/lib/worktree/dirs.js +0 -3
- package/src/lib/worktree/docker-audit.js +0 -175
- package/src/lib/worktree/env-allocator.js +0 -177
- package/src/lib/worktree/feature-truth.js +0 -145
- package/src/lib/worktree/finish-backup.js +0 -529
- package/src/lib/worktree/fleet-scanner.js +0 -223
- package/src/lib/worktree/ignored-triage.js +0 -136
- package/src/lib/worktree/vscode-settings.js +0 -112
- package/src/lib/worktree/worktree-audit.js +0 -323
- package/src/lib/worktree/worktree-include.js +0 -44
- package/src/scripts/install-plugin.js +0 -114
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { Handle, Position } from '@xyflow/react';
|
|
3
|
-
import { SealCheck, Pause } 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 EntityLink, { useSelection } from '../components/EntityLink.jsx';
|
|
8
|
-
import { phaseMeta, GATE_LABEL } from '../lib/phases.js';
|
|
9
|
-
|
|
10
|
-
const phaseColor = (id) => `var(--color-phase-${id})`;
|
|
11
|
-
|
|
12
|
-
const GATE_CHECKS = {
|
|
13
|
-
plan: 'Confere o plano: o problema, o que fica de fora, os cenários com a forma de conferir cada um, o que se reaproveita e as decisões. Depois dele o plano congela (só a errata cresce).',
|
|
14
|
-
uiux: 'Confere o desenho das telas (protótipos e a conferência de cada tela). É opcional: só existe quando a feature passa pela etapa de telas, depois do plano.',
|
|
15
|
-
review: 'Revisão independente, feita do zero: a conferência das entregas e a revisão do código (e a de segurança, quando a mudança toca login, segredo ou dado pessoal), cada uma aprova ou pede correção sobre a mesma versão. Só barra com evidência; passa com os testes automáticos verdes e todo cenário conferido.',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const GATE_PREFIX = 'gate-';
|
|
19
|
-
const gateId = (phaseId) => `${GATE_PREFIX}${phaseId}`;
|
|
20
|
-
const hasGate = (phaseId) => Object.prototype.hasOwnProperty.call(GATE_LABEL, phaseId);
|
|
21
|
-
|
|
22
|
-
function GateNode({ data }) {
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
title={data.label}
|
|
26
|
-
className="fluid flex cursor-pointer select-none items-center gap-1.5 rounded-full bg-[var(--color-raised)] px-3 py-1.5 text-[12px] font-medium text-[var(--color-warn)] transition-shadow"
|
|
27
|
-
style={{ boxShadow: data.selected ? '0 0 0 2px var(--color-warn)' : 'inset 0 0 0 1px var(--color-warn)' }}
|
|
28
|
-
>
|
|
29
|
-
<Handle type="target" position={Position.Left} style={{ background: 'var(--color-warn)', width: 6, height: 6, border: 0 }} />
|
|
30
|
-
<SealCheck weight="light" size={15} />
|
|
31
|
-
{data.label}
|
|
32
|
-
<Handle type="source" position={Position.Right} style={{ background: 'var(--color-warn)', width: 6, height: 6, border: 0 }} />
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function PhaseNode({ data }) {
|
|
38
|
-
const color = phaseColor(data.phaseId);
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
className="fluid cursor-pointer select-none rounded-xl bg-[var(--color-raised)] px-4 py-3 transition-shadow"
|
|
42
|
-
style={{
|
|
43
|
-
width: PHASE_W,
|
|
44
|
-
border: `1.5px ${data.optional ? 'dashed' : 'solid'} ${color}`,
|
|
45
|
-
boxShadow: data.selected ? `0 0 0 2px ${color}` : 'none',
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<Handle type="target" position={Position.Left} style={{ background: color, width: 7, height: 7, border: 0 }} />
|
|
49
|
-
<div className="text-[14px] font-semibold leading-tight text-[var(--color-fg)]">{data.label}</div>
|
|
50
|
-
<div className="mt-1 text-[12px] text-[var(--color-dim)]">
|
|
51
|
-
{data.optional ? 'opcional' : `fase ${data.position}`}
|
|
52
|
-
{data.skill ? ` · ${data.skill}` : ''}
|
|
53
|
-
</div>
|
|
54
|
-
<Handle type="source" position={Position.Right} style={{ background: color, width: 7, height: 7, border: 0 }} />
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const nodeTypes = { phaseNode: PhaseNode, gateNode: GateNode };
|
|
60
|
-
|
|
61
|
-
const PHASE_W = 200;
|
|
62
|
-
const PHASE_H = 64;
|
|
63
|
-
const GATE_W = 150;
|
|
64
|
-
const GATE_H = 32;
|
|
65
|
-
const GAP = 48;
|
|
66
|
-
|
|
67
|
-
function buildPipelineGraph(phases, sel) {
|
|
68
|
-
const nodes = [];
|
|
69
|
-
const edges = [];
|
|
70
|
-
const edge = (source, target) => edges.push({
|
|
71
|
-
id: `e-${source}-${target}`, source, target, type: 'smoothstep',
|
|
72
|
-
style: { stroke: 'var(--color-hair-strong)', strokeWidth: 1.5 },
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
let x = 0;
|
|
76
|
-
let prev = null;
|
|
77
|
-
phases.forEach((phase, i) => {
|
|
78
|
-
nodes.push({
|
|
79
|
-
id: phase.id,
|
|
80
|
-
type: 'phaseNode',
|
|
81
|
-
data: {
|
|
82
|
-
label: phaseMeta(phase.id).label,
|
|
83
|
-
phaseId: phase.id,
|
|
84
|
-
optional: phase.optional,
|
|
85
|
-
position: i + 1,
|
|
86
|
-
skill: phase.skill || null,
|
|
87
|
-
color: phaseColor(phase.id),
|
|
88
|
-
selected: sel === phase.id,
|
|
89
|
-
},
|
|
90
|
-
position: { x, y: 0 },
|
|
91
|
-
});
|
|
92
|
-
if (prev) edge(prev, phase.id);
|
|
93
|
-
prev = phase.id;
|
|
94
|
-
x += PHASE_W + GAP;
|
|
95
|
-
|
|
96
|
-
if (hasGate(phase.id)) {
|
|
97
|
-
const id = gateId(phase.id);
|
|
98
|
-
nodes.push({
|
|
99
|
-
id,
|
|
100
|
-
type: 'gateNode',
|
|
101
|
-
data: { label: GATE_LABEL[phase.id], color: 'var(--color-warn)', selected: sel === id },
|
|
102
|
-
position: { x, y: (PHASE_H - GATE_H) / 2 },
|
|
103
|
-
});
|
|
104
|
-
edge(prev, id);
|
|
105
|
-
prev = id;
|
|
106
|
-
x += GATE_W + GAP;
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return { nodes, edges };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function Section({ title, children }) {
|
|
113
|
-
return (
|
|
114
|
-
<section>
|
|
115
|
-
<h3 className="mb-2 text-xs font-medium text-[var(--color-faint)]">{title}</h3>
|
|
116
|
-
{children}
|
|
117
|
-
</section>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function Chip({ children }) {
|
|
122
|
-
return (
|
|
123
|
-
<span className="inline-flex items-center rounded-full px-2 py-0.5 font-mono text-[12px] text-[var(--color-dim)] shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
124
|
-
{children}
|
|
125
|
-
</span>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Exported for the render smoke test: no page state, only the phase and the personas.
|
|
130
|
-
export function PhaseDetail({ phase, agents }) {
|
|
131
|
-
const color = phaseColor(phase.id);
|
|
132
|
-
const activeAgents = agents.filter((a) => a.activePhases?.includes(phase.id));
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<div className="space-y-6 text-sm text-[var(--color-fg)]">
|
|
136
|
-
<div className="flex flex-wrap items-center gap-2">
|
|
137
|
-
<span className="inline-block h-2.5 w-2.5 rounded-full" style={{ background: color }} />
|
|
138
|
-
{phase.optional && <Chip>opcional</Chip>}
|
|
139
|
-
{hasGate(phase.id) && <EntityLink kind="phase" id={gateId(phase.id)} chip>{GATE_LABEL[phase.id]}</EntityLink>}
|
|
140
|
-
{phase.folder && <Chip>{phase.folder}/</Chip>}
|
|
141
|
-
</div>
|
|
142
|
-
|
|
143
|
-
{phase.skill && (
|
|
144
|
-
<Section title="Skill que conduz a fase">
|
|
145
|
-
<EntityLink kind="skill" id={phase.skill} chip>{phase.skill}</EntityLink>
|
|
146
|
-
</Section>
|
|
147
|
-
)}
|
|
148
|
-
|
|
149
|
-
{phase.goals?.length > 0 && (
|
|
150
|
-
<Section title="Objetivos">
|
|
151
|
-
<ul className="list-disc space-y-1.5 pl-5 text-[var(--color-dim)]">
|
|
152
|
-
{phase.goals.map((g, i) => <li key={i}>{g}</li>)}
|
|
153
|
-
</ul>
|
|
154
|
-
</Section>
|
|
155
|
-
)}
|
|
156
|
-
|
|
157
|
-
{(phase.requiredOutputs?.length > 0 || phase.optionalOutputs?.length > 0) && (
|
|
158
|
-
<Section title="Artefatos que a fase produz">
|
|
159
|
-
<div className="space-y-2">
|
|
160
|
-
{phase.requiredOutputs?.length > 0 && (
|
|
161
|
-
<div className="flex flex-wrap items-center gap-1.5">
|
|
162
|
-
<span className="mr-1 text-[12px] text-[var(--color-dim)]">Obrigatórios:</span>
|
|
163
|
-
{phase.requiredOutputs.map((o) => <Chip key={o}>{o}</Chip>)}
|
|
164
|
-
</div>
|
|
165
|
-
)}
|
|
166
|
-
{phase.optionalOutputs?.length > 0 && (
|
|
167
|
-
<div className="flex flex-wrap items-center gap-1.5">
|
|
168
|
-
<span className="mr-1 text-[12px] text-[var(--color-dim)]">Opcionais:</span>
|
|
169
|
-
{phase.optionalOutputs.map((o) => <Chip key={o}>{o}</Chip>)}
|
|
170
|
-
</div>
|
|
171
|
-
)}
|
|
172
|
-
</div>
|
|
173
|
-
</Section>
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
<Section title={`Personas despachadas (${activeAgents.length})`}>
|
|
177
|
-
{activeAgents.length > 0 ? (
|
|
178
|
-
<ul className="space-y-1">
|
|
179
|
-
{activeAgents.map((a) => (
|
|
180
|
-
<li key={a.id} className="flex items-center justify-between gap-3 rounded-lg bg-white/[0.03] px-3 py-1.5">
|
|
181
|
-
<EntityLink kind="persona" id={a.id}>{a.title}</EntityLink>
|
|
182
|
-
<span className="shrink-0 font-mono text-[12px] text-[var(--color-faint)]">morph-{a.id}</span>
|
|
183
|
-
</li>
|
|
184
|
-
))}
|
|
185
|
-
</ul>
|
|
186
|
-
) : (
|
|
187
|
-
<p className="text-[var(--color-dim)]">A thread principal conduz esta fase sem despachar persona.</p>
|
|
188
|
-
)}
|
|
189
|
-
</Section>
|
|
190
|
-
|
|
191
|
-
{phase.pausePoints?.length > 0 && (
|
|
192
|
-
<Section title="Pontos de pausa">
|
|
193
|
-
<ul className="space-y-1">
|
|
194
|
-
{phase.pausePoints.map((pp) => (
|
|
195
|
-
<li key={pp.id} className="flex items-center gap-2 rounded-lg bg-white/[0.03] px-3 py-1.5 text-[var(--color-dim)]">
|
|
196
|
-
<Pause weight="light" size={14} className="shrink-0 text-[var(--color-warn)]" />
|
|
197
|
-
{pp.label}
|
|
198
|
-
</li>
|
|
199
|
-
))}
|
|
200
|
-
</ul>
|
|
201
|
-
</Section>
|
|
202
|
-
)}
|
|
203
|
-
|
|
204
|
-
{phase.recommendedMCPs?.length > 0 && (
|
|
205
|
-
<Section title="Servidores MCP recomendados">
|
|
206
|
-
<div className="flex flex-wrap gap-1.5">
|
|
207
|
-
{phase.recommendedMCPs.map((m) => <Chip key={m}>{m}</Chip>)}
|
|
208
|
-
</div>
|
|
209
|
-
</Section>
|
|
210
|
-
)}
|
|
211
|
-
</div>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function GateDetail({ phase }) {
|
|
216
|
-
return (
|
|
217
|
-
<div className="space-y-5 text-sm text-[var(--color-dim)]">
|
|
218
|
-
<p>{GATE_CHECKS[phase.id] || 'Ponto de aprovação ao fim desta etapa.'}</p>
|
|
219
|
-
<p>
|
|
220
|
-
Fica ao fim da etapa <EntityLink kind="phase" id={phase.id}>{phaseMeta(phase.id).label}</EntityLink>.
|
|
221
|
-
No modo padrão (aprova sozinho quando não há risco) a aprovação passa sozinha,
|
|
222
|
-
a menos que apareça algo arriscado; aí a decisão volta para você. No modo em que você aprova tudo ela
|
|
223
|
-
sempre espera a sua aprovação.
|
|
224
|
-
</p>
|
|
225
|
-
</div>
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export default function PhasePipeline() {
|
|
230
|
-
const { phases, agents } = morphData;
|
|
231
|
-
const [sel, setSel] = useSelection();
|
|
232
|
-
|
|
233
|
-
const { nodes, edges } = useMemo(() => buildPipelineGraph(phases.list, sel), [phases.list, sel]);
|
|
234
|
-
const gateCount = phases.list.filter((p) => hasGate(p.id)).length;
|
|
235
|
-
|
|
236
|
-
const handleNodeClick = useCallback((_event, node) => setSel(node.id), [setSel]);
|
|
237
|
-
const close = useCallback(() => setSel(null), [setSel]);
|
|
238
|
-
|
|
239
|
-
const gatePhase = sel?.startsWith(GATE_PREFIX)
|
|
240
|
-
? phases.list.find((p) => gateId(p.id) === sel && hasGate(p.id)) || null
|
|
241
|
-
: null;
|
|
242
|
-
const phase = gatePhase ? null : phases.list.find((p) => p.id === sel) || null;
|
|
243
|
-
|
|
244
|
-
let title = '';
|
|
245
|
-
let subtitle;
|
|
246
|
-
if (phase) { title = phaseMeta(phase.id).label; subtitle = phase.optional ? 'Fase opcional' : 'Fase'; }
|
|
247
|
-
if (gatePhase) { title = GATE_LABEL[gatePhase.id]; subtitle = 'Ponto de aprovação'; }
|
|
248
|
-
|
|
249
|
-
return (
|
|
250
|
-
<div className="flex h-full flex-col">
|
|
251
|
-
<div className="shrink-0 border-b border-[var(--color-hair)] px-6 py-4">
|
|
252
|
-
<h1 className="text-xl font-semibold tracking-tight text-[var(--color-fg)]">Fases</h1>
|
|
253
|
-
<p className="mt-0.5 text-sm text-[var(--color-dim)]">
|
|
254
|
-
O caminho de uma feature: {phases.list.length} fases, com {gateCount} pontos de aprovação.
|
|
255
|
-
Borda tracejada marca fase opcional. Clique numa fase ou num gate para ver os detalhes.
|
|
256
|
-
</p>
|
|
257
|
-
</div>
|
|
258
|
-
|
|
259
|
-
<div className="relative flex-1">
|
|
260
|
-
<FlowGraph nodes={nodes} edges={edges} nodeTypes={nodeTypes} onNodeClick={handleNodeClick} fitView />
|
|
261
|
-
|
|
262
|
-
<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)]">
|
|
263
|
-
{phases.list.length} fases · {gateCount} gates
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
|
|
267
|
-
<DetailPanel open={Boolean(phase || gatePhase)} title={title} subtitle={subtitle} onClose={close}>
|
|
268
|
-
{phase && <PhaseDetail key={phase.id} phase={phase} agents={agents.list} />}
|
|
269
|
-
{gatePhase && <GateDetail phase={gatePhase} />}
|
|
270
|
-
</DetailPanel>
|
|
271
|
-
</div>
|
|
272
|
-
);
|
|
273
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
3
|
-
import { FolderSimplePlus, X, ArrowRight } from '@phosphor-icons/react';
|
|
4
|
-
import { FeatureRow, isWorking } from './Features.jsx';
|
|
5
|
-
import { useProjects, projectHref, featureHref, announceProjectsChanged } from '../lib/project.js';
|
|
6
|
-
import { useNow } from '../hooks/usePref.js';
|
|
7
|
-
import { timeAgo } from '../lib/format.js';
|
|
8
|
-
import { GATE_LABEL, featureTitle } from '../lib/phases.js';
|
|
9
|
-
|
|
10
|
-
const ACTIVE_SHOWN = 4;
|
|
11
|
-
const GATE_COLOR = { plan: 'var(--color-phase-plan)', uiux: 'var(--color-phase-uiux)', review: 'var(--color-phase-review)' };
|
|
12
|
-
|
|
13
|
-
// One row per gate that waits for the human, oldest first: the longest wait is the next decision.
|
|
14
|
-
export function decisionQueue(projects = []) {
|
|
15
|
-
return projects
|
|
16
|
-
.filter((p) => p.summary)
|
|
17
|
-
.flatMap((p) => p.summary.activeFeatures.flatMap((f) => (f.gates || [])
|
|
18
|
-
.filter((g) => g.paused)
|
|
19
|
-
.map((g) => ({ project: p, feature: f, gate: g.gate, reason: g.reason, since: g.since }))))
|
|
20
|
-
.sort((a, b) => (a.since || '').localeCompare(b.since || ''));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function DecisionRow({ item, now }) {
|
|
24
|
-
const { project, feature, gate, reason, since } = item;
|
|
25
|
-
return (
|
|
26
|
-
<li>
|
|
27
|
-
<Link to={featureHref(project.id, feature.name)}
|
|
28
|
-
className="fluid grid grid-cols-[8.5rem_minmax(0,1fr)] items-start gap-x-4 gap-y-1 px-5 py-3.5 transition-colors hover:bg-white/[0.025] md:grid-cols-[8.5rem_minmax(0,1fr)_auto]">
|
|
29
|
-
<span className="mt-0.5 rounded-full px-2 py-px text-center text-[11px] font-medium shadow-[inset_0_0_0_1px_var(--color-hair-strong)]"
|
|
30
|
-
style={{ color: GATE_COLOR[gate] }}>{GATE_LABEL[gate] ?? gate}</span>
|
|
31
|
-
<div className="min-w-0">
|
|
32
|
-
<div className="flex items-baseline gap-2">
|
|
33
|
-
<span className="truncate font-medium text-[var(--color-fg)]" title={feature.name}>{featureTitle(feature)}</span>
|
|
34
|
-
<span className="shrink-0 text-xs text-[var(--color-faint)]">{project.name}</span>
|
|
35
|
-
</div>
|
|
36
|
-
{reason && <p className="mt-0.5 line-clamp-2 text-sm text-[var(--color-dim)]">{reason}</p>}
|
|
37
|
-
</div>
|
|
38
|
-
<span className="col-start-2 whitespace-nowrap text-xs text-[var(--color-faint)] md:col-start-auto md:text-right" title={since || undefined}>
|
|
39
|
-
{since ? `esperando ${timeAgo(since, now)}` : 'sem horário'}
|
|
40
|
-
</span>
|
|
41
|
-
</Link>
|
|
42
|
-
</li>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function send(method, url, body) {
|
|
47
|
-
const res = await fetch(url, {
|
|
48
|
-
method,
|
|
49
|
-
headers: body ? { 'Content-Type': 'application/json' } : undefined,
|
|
50
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
51
|
-
});
|
|
52
|
-
const out = await res.json().catch(() => ({}));
|
|
53
|
-
if (!res.ok) throw new Error(out.error || `HTTP ${res.status}`);
|
|
54
|
-
return out;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function ProjectBlock({ p, now, onRemove }) {
|
|
58
|
-
const s = p.summary;
|
|
59
|
-
const working = s ? s.activeFeatures.filter((f) => isWorking(f, now)).length : 0;
|
|
60
|
-
const rest = s ? s.activeFeatures.filter((f) => !f.awaiting) : [];
|
|
61
|
-
const shown = [...rest].sort((a, b) => (b.lastActivity?.ts || '').localeCompare(a.lastActivity?.ts || '')).slice(0, ACTIVE_SHOWN);
|
|
62
|
-
return (
|
|
63
|
-
<section className="bezel" aria-label={p.name}>
|
|
64
|
-
<div className="bezel-core overflow-hidden">
|
|
65
|
-
<header className="flex flex-col gap-3 px-5 py-4 md:flex-row md:items-center md:justify-between">
|
|
66
|
-
<div className="min-w-0">
|
|
67
|
-
<Link to={projectHref(p.id)} className="text-lg font-semibold tracking-tight hover:underline underline-offset-4">{p.name}</Link>
|
|
68
|
-
<p className="mt-0.5 truncate font-mono text-xs text-[var(--color-faint)]" title={p.dir}>{p.dir}</p>
|
|
69
|
-
</div>
|
|
70
|
-
<div className="flex flex-wrap items-center gap-x-5 gap-y-1 whitespace-nowrap text-sm md:shrink-0">
|
|
71
|
-
{!s && <span className="text-[var(--color-faint)]">lendo…</span>}
|
|
72
|
-
{s && (
|
|
73
|
-
<>
|
|
74
|
-
<span className="text-[var(--color-dim)]"><span className="font-mono text-[var(--color-fg)]">{s.active}</span> ativas</span>
|
|
75
|
-
{s.awaiting > 0 && <span className="text-[var(--color-warn)]"><span className="font-mono">{s.awaiting}</span> esperando você</span>}
|
|
76
|
-
{working > 0 && <span className="text-[var(--color-phase-implement)]">agente trabalhando</span>}
|
|
77
|
-
<span className="text-xs text-[var(--color-faint)]">{s.lastActivityTs ? `atividade ${timeAgo(s.lastActivityTs, now)}` : `${s.total} features`}</span>
|
|
78
|
-
</>
|
|
79
|
-
)}
|
|
80
|
-
<Link to={projectHref(p.id)} aria-label={`Abrir ${p.name}`}
|
|
81
|
-
className="fluid flex h-8 w-8 items-center justify-center rounded-full bg-white/[0.05] text-[var(--color-dim)] transition-transform hover:translate-x-0.5 hover:text-[var(--color-fg)]">
|
|
82
|
-
<ArrowRight weight="light" size={15} />
|
|
83
|
-
</Link>
|
|
84
|
-
{!p.launch && (
|
|
85
|
-
<button type="button" onClick={() => onRemove(p)} aria-label={`Remover ${p.name} do portfólio`} title="Remover do portfólio (não apaga nada)"
|
|
86
|
-
className="fluid flex h-8 w-8 items-center justify-center rounded-full text-[var(--color-faint)] transition-colors hover:bg-white/[0.05] hover:text-[var(--color-dim)]">
|
|
87
|
-
<X weight="light" size={14} />
|
|
88
|
-
</button>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
</header>
|
|
92
|
-
{s && shown.length > 0 && (
|
|
93
|
-
<ul className="divide-y divide-[var(--color-hair)] border-t border-[var(--color-hair)]">
|
|
94
|
-
{shown.map((f) => <FeatureRow key={f.name} f={f} now={now} project={p.id} />)}
|
|
95
|
-
</ul>
|
|
96
|
-
)}
|
|
97
|
-
{s && rest.length > ACTIVE_SHOWN && (
|
|
98
|
-
<Link to={projectHref(p.id)} className="block border-t border-[var(--color-hair)] px-5 py-2.5 text-sm text-[var(--color-dim)] hover:text-[var(--color-fg)]">
|
|
99
|
-
Ver as {s.active} features ativas
|
|
100
|
-
</Link>
|
|
101
|
-
)}
|
|
102
|
-
{s && s.active === 0 && (
|
|
103
|
-
<p className="border-t border-[var(--color-hair)] px-5 py-3 text-sm text-[var(--color-faint)]">
|
|
104
|
-
{s.legacyStateOnly ? 'Projeto no modelo de estado antigo: rode morph-spec update nele.' : 'Nada em andamento.'}
|
|
105
|
-
</p>
|
|
106
|
-
)}
|
|
107
|
-
</div>
|
|
108
|
-
</section>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function PortfolioView({ data, now = Date.now(), onAdd = () => {}, onRemove = () => {}, busy = null, error = null }) {
|
|
113
|
-
const projects = data.projects || [];
|
|
114
|
-
const ready = projects.filter((p) => p.summary);
|
|
115
|
-
const totalActive = ready.reduce((n, p) => n + p.summary.active, 0);
|
|
116
|
-
const totalAwaiting = ready.reduce((n, p) => n + p.summary.awaiting, 0);
|
|
117
|
-
const queue = decisionQueue(projects);
|
|
118
|
-
const ordered = [...projects].sort((a, b) => (b.summary?.lastActivityTs || '').localeCompare(a.summary?.lastActivityTs || ''));
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<div className="mx-auto max-w-6xl px-4 pb-24 pt-10 md:px-10 md:pt-14">
|
|
122
|
-
<header className="rise mb-10">
|
|
123
|
-
<h1 className="text-4xl font-semibold tracking-tight md:text-5xl">Portfólio</h1>
|
|
124
|
-
<p className="mt-3 text-sm text-[var(--color-dim)]">
|
|
125
|
-
{projects.length} {projects.length === 1 ? 'projeto' : 'projetos'}, {totalActive} features ativas
|
|
126
|
-
{totalAwaiting > 0 && <span className="text-[var(--color-warn)]">, {totalAwaiting} esperando você</span>}
|
|
127
|
-
</p>
|
|
128
|
-
</header>
|
|
129
|
-
|
|
130
|
-
{queue.length > 0 && (
|
|
131
|
-
<section className="rise-2 mb-10">
|
|
132
|
-
<h2 className="mb-3 px-1 text-sm font-medium">Esperando você <span className="text-[var(--color-faint)]">· a mais antiga primeiro</span></h2>
|
|
133
|
-
<div className="bezel">
|
|
134
|
-
<ul className="bezel-core divide-y divide-[var(--color-hair)] overflow-hidden">
|
|
135
|
-
{queue.map((item) => <DecisionRow key={`${item.project.id}:${item.feature.name}:${item.gate}`} item={item} now={now} />)}
|
|
136
|
-
</ul>
|
|
137
|
-
</div>
|
|
138
|
-
</section>
|
|
139
|
-
)}
|
|
140
|
-
|
|
141
|
-
<div className="rise-3 space-y-6">
|
|
142
|
-
{ordered.map((p) => <ProjectBlock key={p.id} p={p} now={now} onRemove={onRemove} />)}
|
|
143
|
-
</div>
|
|
144
|
-
|
|
145
|
-
<section className="mt-14" aria-labelledby="found">
|
|
146
|
-
<h2 id="found" className="px-1 text-sm font-medium">Outros projetos com morph-spec</h2>
|
|
147
|
-
<p className="mb-4 mt-1 px-1 text-sm text-[var(--color-dim)]">
|
|
148
|
-
Encontrados nas pastas vizinhas dos projetos acima. Projetos também entram sozinhos quando você roda
|
|
149
|
-
<code className="mx-1 font-mono text-[var(--color-fg)]">morph-spec init</code>,
|
|
150
|
-
<code className="mx-1 font-mono text-[var(--color-fg)]">update</code> ou
|
|
151
|
-
<code className="mx-1 font-mono text-[var(--color-fg)]">dashboard</code> neles.
|
|
152
|
-
</p>
|
|
153
|
-
{error && <p className="mb-3 px-1 text-sm text-[var(--color-bad)]">{error}</p>}
|
|
154
|
-
{(data.suggestions || []).length === 0 && <p className="px-1 text-sm text-[var(--color-faint)]">Nenhum outro encontrado.</p>}
|
|
155
|
-
<ul className="grid grid-cols-1 gap-2 md:grid-cols-2">
|
|
156
|
-
{(data.suggestions || []).map((s) => (
|
|
157
|
-
<li key={s.dir} className="flex min-w-0 items-center justify-between gap-3 rounded-xl px-4 py-3 shadow-[inset_0_0_0_1px_var(--color-hair)]">
|
|
158
|
-
<div className="min-w-0">
|
|
159
|
-
<p className="truncate text-sm text-[var(--color-fg)]">{s.name}</p>
|
|
160
|
-
<p className="truncate font-mono text-xs text-[var(--color-faint)]" title={s.dir}>{s.dir}</p>
|
|
161
|
-
</div>
|
|
162
|
-
<button type="button" onClick={() => onAdd(s.dir)} disabled={busy === s.dir}
|
|
163
|
-
className="fluid inline-flex shrink-0 items-center gap-1.5 rounded-full bg-white/[0.06] px-3 py-1.5 text-sm text-[var(--color-fg)] transition-colors hover:bg-white/[0.1] active:scale-[0.98] disabled:opacity-50">
|
|
164
|
-
<FolderSimplePlus weight="light" size={15} /> {busy === s.dir ? 'Adicionando…' : 'Adicionar'}
|
|
165
|
-
</button>
|
|
166
|
-
</li>
|
|
167
|
-
))}
|
|
168
|
-
</ul>
|
|
169
|
-
</section>
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export default function Portfolio() {
|
|
175
|
-
const { data, error } = useProjects();
|
|
176
|
-
const now = useNow();
|
|
177
|
-
const [busy, setBusy] = useState(null);
|
|
178
|
-
const [actionError, setActionError] = useState(null);
|
|
179
|
-
const run = async (dir, fn) => {
|
|
180
|
-
setBusy(dir); setActionError(null);
|
|
181
|
-
// The server also pushes the change; reading again here does not depend on it.
|
|
182
|
-
try { await fn(); announceProjectsChanged(); } catch (err) { setActionError(err.message); } finally { setBusy(null); }
|
|
183
|
-
};
|
|
184
|
-
const onAdd = (dir) => run(dir, () => send('POST', '/api/morph/projects', { dir }));
|
|
185
|
-
const onRemove = (p) => run(p.dir, () => send('DELETE', `/api/morph/projects?dir=${encodeURIComponent(p.dir)}`));
|
|
186
|
-
|
|
187
|
-
if (error) return <p className="px-10 pt-16 text-sm text-[var(--color-bad)]">Não consegui ler o portfólio: {error}</p>;
|
|
188
|
-
if (!data) return <p className="px-10 pt-16 text-sm text-[var(--color-faint)]">Lendo os projetos…</p>;
|
|
189
|
-
return <PortfolioView data={data} now={now} onAdd={onAdd} onRemove={onRemove} busy={busy} error={actionError} />;
|
|
190
|
-
}
|