@polymorphism-tech/morph-spec 10.12.0 → 11.0.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 +51 -340
- 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 +8 -8
- 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 +31 -86
- 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 +13 -11
- package/framework/rules/resend-standards.md +1 -1
- package/framework/rules/ui-design.md +4 -0
- 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 +5 -341
- 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 +15 -50
- 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 +1 -34
- package/src/utils/atomic-json.js +27 -0
- package/src/utils/file-copier.js +4 -12
- 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,480 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
|
-
import { renderRecapHtml } from '../recap/recap.js';
|
|
3
|
-
import { ADR_PLAIN_LABELS } from '../plan/plan-parser.js';
|
|
4
|
-
import { stateMachineSvg } from './flow-svg.js';
|
|
5
|
-
import { layeredFlowSvg } from './flow-layers.js';
|
|
6
|
-
import {
|
|
7
|
-
BLOCKER_SAY, PROOF_SAY, REUSE_SAY, RISK_SAY, ROLE_NAME, VERDICT_SAY, WORK_NAME, scenarioLabel,
|
|
8
|
-
} from '../../../framework/hooks/shared/owner-words.js';
|
|
9
|
-
|
|
10
|
-
export const TOKENS_CSS = readFileSync(new URL('./tokens.css', import.meta.url), 'utf8');
|
|
11
|
-
const PAGE_CSS = readFileSync(new URL('./feature-page.css', import.meta.url), 'utf8');
|
|
12
|
-
const CLIENT_JS = readFileSync(new URL('./feature-page.client.js', import.meta.url), 'utf8');
|
|
13
|
-
|
|
14
|
-
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
15
|
-
const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
16
|
-
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
17
|
-
const clean = (text) => String(text ?? '').replace(/<!--[\s\S]*?-->/g, '').trim();
|
|
18
|
-
const NONE_RE = /^(nenhum|nenhuma)\.?$/i;
|
|
19
|
-
|
|
20
|
-
const RUNG = {
|
|
21
|
-
desfazer: { label: 'Dá trabalho para desfazer', why: 'Dá para voltar atrás, mas não só desfazendo o código.', tone: 'warn' },
|
|
22
|
-
migrar: { label: 'Mexe na estrutura do banco', why: 'Voltar atrás exige outra migração; desfazer o código não basta.', tone: 'warn' },
|
|
23
|
-
'irreversível': { label: 'Não tem volta', why: 'Depois que rodar, o que mudou não se recupera.', tone: 'bad' },
|
|
24
|
-
};
|
|
25
|
-
const rungOf = (c) => RUNG[String(c.rung ?? '').toLowerCase().replace('irreversivel', 'irreversível')] ?? null;
|
|
26
|
-
const scenarioName = (id) => `Cenário ${String(id).replace(/^C/i, '')}`;
|
|
27
|
-
const refName = (id) => (/^C\d+$/.test(id) ? scenarioName(id) : id);
|
|
28
|
-
|
|
29
|
-
function linkifier(plan) {
|
|
30
|
-
const known = new Set([...plan.scenarios.map((c) => c.id), ...plan.adrs.map((a) => a.id)]);
|
|
31
|
-
const defaults = new Set(plan.defaults.items.map((d) => d.n));
|
|
32
|
-
const ref = (id, label) => `<a href="#${id}" data-ref="${id}">${label}</a>`;
|
|
33
|
-
return (escaped) => escaped
|
|
34
|
-
.replace(/\b(C\d+|ADR-\d+)\b/g, (m, id) => (known.has(id) ? ref(id, refName(m)) : m))
|
|
35
|
-
.replace(/\b([Pp]adrão) (\d+)\b/g, (m, word, n) => (defaults.has(Number(n)) ? ref(`P${n}`, `${word} ${n}`) : m));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function inline(text, link) {
|
|
39
|
-
return String(text).split(/(`[^`]+`)/).map((part) => {
|
|
40
|
-
if (/^`[^`]+`$/.test(part)) return `<code>${esc(part.slice(1, -1))}</code>`;
|
|
41
|
-
return link(esc(part)).replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
|
|
42
|
-
}).join('');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const LONG_PARAGRAPH = 320;
|
|
46
|
-
|
|
47
|
-
/** Sentences of a paragraph, never cut inside a code span. */
|
|
48
|
-
export function sentences(text) {
|
|
49
|
-
const out = [''];
|
|
50
|
-
const parts = String(text).split(/(`[^`]+`)/);
|
|
51
|
-
parts.forEach((part, i) => {
|
|
52
|
-
if (i % 2) { out[out.length - 1] += part; return; }
|
|
53
|
-
part.split(/(?<=[.!?])\s+(?=[A-ZÀ-Ý"(])/).forEach((piece, k) => {
|
|
54
|
-
if (k) out.push('');
|
|
55
|
-
out[out.length - 1] += piece;
|
|
56
|
-
});
|
|
57
|
-
if (/[.!?]\s+$/.test(part) && i < parts.length - 1) out.push('');
|
|
58
|
-
});
|
|
59
|
-
return out.map((s) => s.trim()).filter(Boolean);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// A wall of text reads as one sentence per line; a short paragraph stays a paragraph.
|
|
63
|
-
function paragraph(text, link) {
|
|
64
|
-
const parts = text.length > LONG_PARAGRAPH ? sentences(text) : [];
|
|
65
|
-
return parts.length >= 3 ? `<ul class="sentences">${parts.map((s) => `<li>${inline(s, link)}</li>`).join('')}</ul>` : `<p>${inline(text, link)}</p>`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function blocks(markdown, link) {
|
|
69
|
-
const text = String(markdown ?? '').replace(/<!--[\s\S]*?-->/g, '');
|
|
70
|
-
const out = [];
|
|
71
|
-
let para = [];
|
|
72
|
-
let list = null;
|
|
73
|
-
let table = null;
|
|
74
|
-
let fence = null;
|
|
75
|
-
const closePara = () => { if (para.length) out.push(paragraph(para.join(' '), link)); para = []; };
|
|
76
|
-
const closeList = () => { if (list) out.push(`<ul>${list.map((i) => `<li>${inline(i, link)}</li>`).join('')}</ul>`); list = null; };
|
|
77
|
-
const closeTable = () => {
|
|
78
|
-
if (!table) return;
|
|
79
|
-
const [head, ...rows] = table;
|
|
80
|
-
const cells = (row, tag) => row.map((c) => `<${tag}>${inline(c, link)}</${tag}>`).join('');
|
|
81
|
-
out.push(`<div class="scroll-x"><table><thead><tr>${cells(head, 'th')}</tr></thead><tbody>${rows.map((r) => `<tr>${cells(r, 'td')}</tr>`).join('')}</tbody></table></div>`);
|
|
82
|
-
table = null;
|
|
83
|
-
};
|
|
84
|
-
const closeAll = () => { closePara(); closeList(); closeTable(); };
|
|
85
|
-
for (const line of text.split(/\r?\n/)) {
|
|
86
|
-
if (fence) {
|
|
87
|
-
if (/^\s*```/.test(line)) { out.push(`<pre><code>${esc(fence.join('\n'))}</code></pre>`); fence = null; } else fence.push(line);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (/^\s*```/.test(line)) { closeAll(); fence = []; continue; }
|
|
91
|
-
if (!line.trim()) { closeAll(); continue; }
|
|
92
|
-
if (/^\s*\|/.test(line)) {
|
|
93
|
-
closePara(); closeList();
|
|
94
|
-
if (/^\s*\|[\s:|-]+\|?\s*$/.test(line)) continue;
|
|
95
|
-
(table ??= []).push(line.trim().replace(/^\||\|$/g, '').split('|').map((c) => c.trim()));
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
closeTable();
|
|
99
|
-
const bullet = /^\s*[-*]\s+(.*)$/.exec(line);
|
|
100
|
-
if (bullet) { closePara(); (list ??= []).push(bullet[1]); continue; }
|
|
101
|
-
if (list && /^\s+\S/.test(line)) { list[list.length - 1] += ` ${line.trim()}`; continue; }
|
|
102
|
-
closeList();
|
|
103
|
-
const heading = /^#{1,6}\s+(.*)$/.exec(line);
|
|
104
|
-
if (heading) { closePara(); out.push(`<h4>${inline(heading[1], link)}</h4>`); continue; }
|
|
105
|
-
para.push(line.trim());
|
|
106
|
-
}
|
|
107
|
-
if (fence) out.push(`<pre><code>${esc(fence.join('\n'))}</code></pre>`);
|
|
108
|
-
closeAll();
|
|
109
|
-
return out.join('');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function splitProblem(text) {
|
|
113
|
-
const m = /^\s*\**\s*Resultado buscado\s*:\s*\**\s*(.+(?:\r?\n(?!\s*$).+)*)/im.exec(text ?? '');
|
|
114
|
-
const outcome = m ? m[1].replace(/\*\*/g, '').replace(/\s*\r?\n\s*/g, ' ').trim() : null;
|
|
115
|
-
return { outcome, problem: m ? text.replace(m[0], '').trim() : text ?? '' };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** "Dado X, quando Y, então Z" in its three parts; null when the scenario is not written that way. */
|
|
119
|
-
export function splitScenario(text) {
|
|
120
|
-
const m = /^Dad[oa]s?\s+(.+?),\s+quando\s+(.+?),\s+então\s+(.+)$/is.exec(String(text ?? '').trim());
|
|
121
|
-
return m ? { given: m[1], when: m[2], then: m[3] } : null;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const bulletsOf = (text) => clean(text).split(/\r?\n/).reduce((items, line) => {
|
|
125
|
-
const bullet = /^\s*[-*]\s+(.+)$/.exec(line);
|
|
126
|
-
if (bullet) items.push(bullet[1]);
|
|
127
|
-
else if (items.length && /^\s+\S/.test(line)) items[items.length - 1] += ` ${line.trim()}`;
|
|
128
|
-
return items;
|
|
129
|
-
}, []).filter((item) => !NONE_RE.test(item.trim()));
|
|
130
|
-
|
|
131
|
-
const conflictsOf = (plan) => {
|
|
132
|
-
const text = clean(plan.conflicts?.text);
|
|
133
|
-
return text && !NONE_RE.test(text) ? text : null;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
export function firstSentence(text) {
|
|
138
|
-
const flat = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
139
|
-
return /^(.+?[.!?])\s+(?=[A-ZÀ-Ý"`(])/.exec(flat)?.[1] ?? flat;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const titleOf = (c) => c.title || firstSentence(cap(splitScenario(c.text)?.then ?? c.text));
|
|
143
|
-
|
|
144
|
-
/** The before and after the page opens with: the plan's own plain lines, else its technical text cut short. */
|
|
145
|
-
export function story(plan) {
|
|
146
|
-
const { outcome, problem } = splitProblem(plan.text.problem);
|
|
147
|
-
const s = plan.summary ?? {};
|
|
148
|
-
return { today: s.today ?? (firstSentence(clean(problem)) || null), after: s.after ?? outcome, plain: Boolean(s.today && s.after), outcome, problem, rest: clean(s.rest) };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/** What deserves a careful look, heaviest first: the plan's own warnings, no way back, stuck, failed, flagged, assumed. */
|
|
152
|
-
export function attentionPoints(view) {
|
|
153
|
-
const { plan, reviews, verification } = view;
|
|
154
|
-
const points = [];
|
|
155
|
-
for (const text of plan.summary?.watch ?? []) points.push({ kind: 'note', tone: 'warn', glyph: '!', tag: 'Aviso do plano', text: cap(text) });
|
|
156
|
-
for (const c of plan.scenarios) {
|
|
157
|
-
const rung = rungOf(c);
|
|
158
|
-
if (rung) points.push({ kind: 'rung', tone: rung.tone, glyph: '!', tag: rung.label, why: rung.why, text: titleOf(c), ref: c.id, ask: c.id, verb: 'Rever', anchor: `ponto-${c.id}` });
|
|
159
|
-
}
|
|
160
|
-
for (const c of plan.scenarios) {
|
|
161
|
-
if (c.status === 'bloqueado') points.push({ kind: 'blocked', tone: 'bad', glyph: '✕', tag: 'Travado na construção', why: 'Precisa de uma decisão para continuar.', text: c.evidence || titleOf(c), ref: c.id, ask: `${c.id} (travado)`, verb: 'Decidir', anchor: `ponto-${c.id}-travado` });
|
|
162
|
-
}
|
|
163
|
-
if (verification && verification.status !== 'pass') points.push({ kind: 'verify', tone: 'bad', glyph: '✕', tag: 'Checagem automática falhou', text: 'O build ou os testes não passaram na última rodada.' });
|
|
164
|
-
for (const [role, r] of Object.entries(reviews ?? {})) {
|
|
165
|
-
for (const b of r.blockers ?? []) points.push({ kind: 'review', tone: 'bad', glyph: '✕', tag: `${ROLE_NAME[role] ?? 'Revisão'} apontou`, text: b.evidence || b.where || b.id });
|
|
166
|
-
}
|
|
167
|
-
if (conflictsOf(plan)) points.push({ kind: 'conflict', tone: 'warn', glyph: '!', tag: 'Contraria uma decisão anterior', text: 'Este plano muda algo que já tinha sido decidido no projeto.', href: '#conflitos' });
|
|
168
|
-
bulletsOf(plan.text.assumptions).forEach((text, i) => points.push({ kind: 'assumption', tone: 'warn', glyph: '?', tag: 'Suposição não confirmada', why: 'Foi assumido sem prova. Se estiver errado, o plano muda.', text, ask: `suposição ${i + 1}`, verb: 'Corrigir', anchor: `S${i + 1}` }));
|
|
169
|
-
return points;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const approved = (g) => g === true || g?.approved === true;
|
|
173
|
-
// After the plan gate there is nothing left to veto: the points stay as a record, and only what is stuck still asks.
|
|
174
|
-
const settled = (view) => approved(view.gates?.plan);
|
|
175
|
-
const LIVE_KINDS = ['blocked', 'verify', 'review'];
|
|
176
|
-
|
|
177
|
-
const toggle = (label = 'Quero mudar') => `<button type="button" class="toggle" aria-pressed="false">${esc(label)}</button>`;
|
|
178
|
-
|
|
179
|
-
function pointGroups(points, link) {
|
|
180
|
-
const groups = [];
|
|
181
|
-
for (const p of points) {
|
|
182
|
-
const last = groups[groups.length - 1];
|
|
183
|
-
if (last?.tag === p.tag) last.items.push(p); else groups.push({ ...p, items: [p] });
|
|
184
|
-
}
|
|
185
|
-
const item = (p) => {
|
|
186
|
-
const ask = p.ask ? ` data-ask="${esc(p.ask)}" data-verb="${esc(p.verb)}"` : '';
|
|
187
|
-
const where = p.ref ? `<a class="id" href="#${esc(p.ref)}" data-ref="${esc(p.ref)}">${esc(refName(p.ref))}</a>` : p.href ? `<a class="id" href="${esc(p.href)}">ver</a>` : '';
|
|
188
|
-
return `<li${p.anchor ? ` id="${esc(p.anchor)}"` : ''}${LIVE_KINDS.includes(p.kind) ? ' class="live"' : ''}${ask}>${where}<p>${inline(p.text, link)}</p>${p.ask ? toggle(p.kind === 'blocked' ? 'Decidir' : 'Quero mudar') : ''}</li>`;
|
|
189
|
-
};
|
|
190
|
-
return `<ul class="groups plain">${groups.map((g) => `<li class="group ${g.tone}"><div class="group-head"><i class="ico ${g.tone}" aria-hidden="true">${g.glyph}</i><div><h3>${esc(g.tag)}${g.items.length > 1 ? `<span class="n">${g.items.length}</span>` : ''}</h3>${g.why ? `<p class="why">${esc(g.why)}</p>` : ''}</div></div><ul class="items">${g.items.map(item).join('')}</ul></li>`).join('')}</ul>`;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// The hook that records an approval reads an answer that starts with this word.
|
|
194
|
-
const APPROVAL_ANSWER = 'Aprovado.';
|
|
195
|
-
|
|
196
|
-
export function headline(view) {
|
|
197
|
-
const g = view.gate;
|
|
198
|
-
if (g?.pause && g.resolver !== 'session') {
|
|
199
|
-
return { tone: 'wait', title: 'Esperando a sua decisão', text: g.reason ?? `A etapa "${g.label}" só segue com o seu ok.`, hint: 'Para seguir como está, cole a resposta no terminal. Para mudar algo, marque "Quero mudar" nos itens abaixo e cole a resposta do rodapé.', answer: APPROVAL_ANSWER };
|
|
200
|
-
}
|
|
201
|
-
const now = view.stations.find((s) => s.state === 'now');
|
|
202
|
-
const p = view.progress;
|
|
203
|
-
if (!now) return { tone: 'ok', title: 'Entregue', text: 'Tudo o que foi prometido foi construído, conferido e entregue.' };
|
|
204
|
-
if (now.id === 'plan') return { tone: 'info', title: 'Plano escrito, nada construído ainda', text: 'A construção começa quando o plano for aprovado.' };
|
|
205
|
-
if (now.id === 'uiux') return { tone: 'info', title: 'Desenhando as telas', text: 'Plano aprovado. As telas vêm antes da construção.' };
|
|
206
|
-
if (now.id === 'implement') {
|
|
207
|
-
const stuck = p?.blocked ? ` ${plural(p.blocked, 'está travada', 'estão travadas')}.` : '';
|
|
208
|
-
return { tone: p?.blocked ? 'wait' : 'info', title: 'Em construção', text: p?.total ? `${p.done} de ${plural(p.total, 'entrega pronta', 'entregas prontas')}.${stuck}` : 'A construção começou.' };
|
|
209
|
-
}
|
|
210
|
-
if (now.id === 'review') return { tone: 'info', title: 'Construído, em conferência', text: 'Cada entrega é conferida antes de ir para o ar.' };
|
|
211
|
-
return { tone: 'ok', title: 'Conferido, falta entregar', text: 'A revisão aprovou. Falta só integrar ao projeto.' };
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function scenarioState(c) {
|
|
215
|
-
if (c.proved === 'PROVADO') return { tone: 'ok', glyph: '✓', label: 'Conferido', done: true };
|
|
216
|
-
if (c.proved === 'FALHA') return { tone: 'bad', glyph: '✕', label: 'Falhou na conferência' };
|
|
217
|
-
if (c.status === 'bloqueado') return { tone: 'bad', glyph: '✕', label: 'Travado' };
|
|
218
|
-
if (c.proved) return { tone: 'warn', glyph: '!', label: 'Ainda não conferido' };
|
|
219
|
-
if (c.status === 'feito') return { tone: 'ok', glyph: '✓', label: 'Construído', done: true };
|
|
220
|
-
return { tone: 'todo', glyph: '', label: 'A fazer' };
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/** One stop per delivery, in plan order, painted by its state; a diamond marks what has no way back. */
|
|
224
|
-
function stopsLine(scenarios) {
|
|
225
|
-
return `<nav class="stops" aria-label="As ${scenarios.length} entregas">${scenarios.map((c, i) => {
|
|
226
|
-
const state = scenarioState(c);
|
|
227
|
-
const rung = rungOf(c);
|
|
228
|
-
return `<a class="stop ${state.tone}${rung ? ' rung' : ''}" style="--i:${i}" href="#${esc(c.id)}" data-ref="${esc(c.id)}" aria-label="${esc(`${scenarioLabel(c)}: ${state.label}${rung ? `, ${rung.label.toLowerCase()}` : ''}`)}"><i aria-hidden="true"></i><span>${esc(String(c.id).replace(/^C/i, ''))}</span></a>`;
|
|
229
|
-
}).join('')}</nav>`;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const fold = (title, body) => (body ? `<details class="fold"><summary>${title}</summary><div class="prose">${body}</div></details>` : '');
|
|
233
|
-
|
|
234
|
-
const number = (n) => n.toLocaleString('pt-BR');
|
|
235
|
-
|
|
236
|
-
export function span(startedAt, endedAt) {
|
|
237
|
-
const ms = Date.parse(endedAt ?? '') - Date.parse(startedAt ?? '');
|
|
238
|
-
if (!Number.isFinite(ms) || ms < 0) return null;
|
|
239
|
-
const minutes = Math.round(ms / 60000);
|
|
240
|
-
if (minutes < 90) return `${Math.max(1, minutes)} min`;
|
|
241
|
-
const hours = Math.round(minutes / 60);
|
|
242
|
-
return hours < 48 ? `${hours} h` : `${Math.round(hours / 24)} dias`;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const tokenCount = (n) => (n >= 1e6 ? `${(n / 1e6).toFixed(1).replace('.', ',')} mi` : n >= 1e3 ? `${Math.round(n / 1e3)} mil` : String(n));
|
|
246
|
-
const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso ?? ''); return m ? `${m[3]}/${m[2]}/${m[1]}` : null; };
|
|
247
|
-
|
|
248
|
-
function linkLabel(url) {
|
|
249
|
-
const gh = /github\.com\/[^/]+\/[^/]+\/(issues|pull)\/(\d+)/.exec(url);
|
|
250
|
-
if (gh) return `${gh[1] === 'pull' ? 'PR' : 'Issue'} #${gh[2]}`;
|
|
251
|
-
try { return new URL(url).hostname; } catch { return 'link do pedido'; }
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function originStrip(view) {
|
|
255
|
-
const o = view.origin ?? {};
|
|
256
|
-
const items = [
|
|
257
|
-
o.link && `<li>Pedido: <a href="${esc(o.link)}" rel="noreferrer">${esc(linkLabel(o.link))}</a></li>`,
|
|
258
|
-
dayOf(o.startedAt) && `<li>Começou em ${dayOf(o.startedAt)}</li>`,
|
|
259
|
-
dayOf(o.endedAt) && `<li>Entregue em ${dayOf(o.endedAt)}</li>`,
|
|
260
|
-
o.branch && `<li>Branch <code>${esc(o.branch)}</code></li>`,
|
|
261
|
-
].filter(Boolean);
|
|
262
|
-
return items.length ? `<ul class="origin">${items.join('')}</ul>` : '';
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function sizeFacts(view) {
|
|
266
|
-
const stat = view.changes?.stat;
|
|
267
|
-
const took = span(view.origin?.startedAt, view.origin?.endedAt);
|
|
268
|
-
const facts = [
|
|
269
|
-
stat && `<li><b>${number(stat.files)}</b> ${stat.files === 1 ? 'arquivo alterado' : 'arquivos alterados'}</li>`,
|
|
270
|
-
stat && `<li><b>+${number(stat.added)}</b> linhas, <b>−${number(stat.removed)}</b></li>`,
|
|
271
|
-
took && `<li><b>${took}</b> do início à entrega</li>`,
|
|
272
|
-
view.tokens && `<li><b>${tokenCount(view.tokens)}</b> de tokens</li>`,
|
|
273
|
-
].filter(Boolean);
|
|
274
|
-
return facts.length ? `<ul class="legend facts">${facts.join('')}</ul>` : '';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function progressBlock(view, link) {
|
|
278
|
-
const { progress, verification, reviews, design } = view;
|
|
279
|
-
const started = progress?.done > 0 || progress?.blocked > 0 || verification || Object.values(reviews).some((r) => r.status !== 'missing');
|
|
280
|
-
if (!started && !design.length) return '';
|
|
281
|
-
const row = (tone, glyph, title, text, extra = '') => `<li><i class="ico ${tone}" aria-hidden="true">${glyph}</i><div><b>${title}</b><span>${text}</span>${extra ? `<small>${extra}</small>` : ''}</div></li>`;
|
|
282
|
-
const rows = [];
|
|
283
|
-
if (progress?.total) {
|
|
284
|
-
const all = progress.done === progress.total;
|
|
285
|
-
rows.push(row(progress.blocked ? 'bad' : all ? 'ok' : 'todo', progress.blocked ? '✕' : all ? '✓' : '', 'Construção', `${progress.done} de ${plural(progress.total, 'entrega pronta', 'entregas prontas')}${progress.blocked ? `, ${plural(progress.blocked, 'travada', 'travadas')}` : ''}`));
|
|
286
|
-
}
|
|
287
|
-
if (verification) {
|
|
288
|
-
const ok = verification.status === 'pass';
|
|
289
|
-
rows.push(row(ok ? 'ok' : 'bad', ok ? '✓' : '✕', 'Checagem automática', ok ? 'build e testes passaram' : 'build ou testes falharam', verification.sha ? `versão <code>${esc(String(verification.sha).slice(0, 8))}</code>` : ''));
|
|
290
|
-
}
|
|
291
|
-
for (const [role, r] of Object.entries(reviews)) {
|
|
292
|
-
if (r.status === 'missing') continue;
|
|
293
|
-
const tone = r.verdict === 'SHIP' ? 'ok' : r.verdict === 'FIX' ? 'bad' : 'todo';
|
|
294
|
-
const word = VERDICT_SAY[r.verdict] ?? 'em andamento';
|
|
295
|
-
rows.push(row(tone, tone === 'ok' ? '✓' : tone === 'bad' ? '✕' : '', ROLE_NAME[role] ?? esc(role), word, r.blockers?.length ? plural(r.blockers.length, 'problema apontado', 'problemas apontados') : ''));
|
|
296
|
-
}
|
|
297
|
-
const blockers = Object.values(reviews).flatMap((r) => r.blockers ?? []);
|
|
298
|
-
return `<div id="andamento"><h2>Como está andando</h2>
|
|
299
|
-
${rows.length ? `<ul class="timeline">${rows.join('')}</ul>` : ''}
|
|
300
|
-
${blockers.length ? `<h3>O que a revisão apontou</h3><div class="prose"><ul>${blockers.map((b) => `<li>${inline(`${cap(BLOCKER_SAY[b.type] ?? 'problema')}: ${b.evidence || b.where}`, link)}</li>`).join('')}</ul></div>` : ''}
|
|
301
|
-
${design.length ? `<h3>Telas</h3><ul class="shots">${design.map((d) => `<li><a href="${esc(d.href)}">${d.shot ? `<img src="${esc(d.shot)}" alt="" loading="lazy">` : ''}${esc(d.name)}${d.kind === 'opcoes' ? ' (opções)' : ''}</a></li>`).join('')}</ul>` : ''}
|
|
302
|
-
</div>`;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function summaryPanel(view, points, link) {
|
|
306
|
-
const { plan } = view;
|
|
307
|
-
const st = story(plan);
|
|
308
|
-
const h = headline(view);
|
|
309
|
-
const out = bulletsOf(plan.text.outOfScope);
|
|
310
|
-
const done = plan.scenarios.filter((c) => scenarioState(c).done).length;
|
|
311
|
-
const total = plan.scenarios.length;
|
|
312
|
-
const noReturn = plan.scenarios.filter(rungOf).length;
|
|
313
|
-
const choices = plan.defaults.items.length;
|
|
314
|
-
const live = points.some((p) => LIVE_KINDS.includes(p.kind));
|
|
315
|
-
const beforeAfter = st.today || st.after ? `<div class="shift${st.plain ? ' plain' : ''}">
|
|
316
|
-
<div class="before"><span class="tag">Hoje</span><p>${st.today ? inline(cap(st.today), link) : '—'}</p></div>
|
|
317
|
-
<div class="after"><span class="tag">Depois</span><p>${st.after ? inline(cap(st.after), link) : '—'}</p></div>
|
|
318
|
-
</div>` : '';
|
|
319
|
-
return `<section class="panel on" id="resumo">
|
|
320
|
-
${beforeAfter}
|
|
321
|
-
<div class="status ${h.tone}"><div><h2>${esc(h.title)}</h2><p>${inline(h.text, link)}</p>${h.hint ? `<p class="hint">${esc(h.hint)}</p>` : ''}</div>${h.answer ? `<button type="button" class="act" data-copy="${esc(h.answer)}">Copiar "${esc(h.answer)}"</button>` : ''}</div>
|
|
322
|
-
${total ? `<div class="board">${stopsLine(plan.scenarios)}
|
|
323
|
-
<ul class="legend"><li><b>${done} de ${total}</b> ${total === 1 ? 'entrega pronta' : 'entregas prontas'}</li>${noReturn ? `<li class="rung"><i aria-hidden="true"></i><b>${noReturn}</b> sem volta fácil</li>` : ''}<li><a href="#decisoes"><b>${plan.adrs.length}</b> ${plan.adrs.length === 1 ? 'decisão de projeto' : 'decisões de projeto'}</a></li>${choices ? `<li><a href="#escolhas"><b>${choices}</b> ${choices === 1 ? 'escolha técnica' : 'escolhas técnicas'}</a></li>` : ''}</ul>
|
|
324
|
-
${sizeFacts(view)}</div>` : ''}
|
|
325
|
-
<h2 id="atencao">${settled(view) && !live ? 'O risco que este plano carrega' : 'Olhe com carinho'}</h2>
|
|
326
|
-
${points.length ? `${pointGroups(points, link)}<p class="tip">"Quero mudar" monta a resposta no rodapé, pronta para colar no terminal.</p>` : '<p class="calm"><i class="ico ok" aria-hidden="true">✓</i>Nada fora do comum: nenhuma mudança sem volta, nada travado, nenhuma suposição em aberto.</p>'}
|
|
327
|
-
${progressBlock(view, link)}
|
|
328
|
-
${out.length ? `<h2>Fica de fora</h2><ul class="out">${out.map((o) => `<li><p>${inline(o, link)}</p></li>`).join('')}</ul>` : ''}
|
|
329
|
-
<h2>Quer o contexto inteiro?</h2>
|
|
330
|
-
${fold('O problema, em detalhe', blocks(st.problem, link))}
|
|
331
|
-
${fold('O que mais o resumo diz', st.rest ? blocks(st.rest, link) : '')}
|
|
332
|
-
${st.plain && st.outcome ? fold('Como saber que deu certo', `<p>${inline(st.outcome, link)}</p>`) : ''}
|
|
333
|
-
${fold('O pedido original', view.description ? `<p>${esc(view.description)}</p>` : '')}
|
|
334
|
-
</section>`;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function scenarioRow(c, cites, link) {
|
|
338
|
-
const state = scenarioState(c);
|
|
339
|
-
const parts = splitScenario(c.text);
|
|
340
|
-
const rung = rungOf(c);
|
|
341
|
-
const steps = parts
|
|
342
|
-
? `<div class="steps"><div><b>Situação</b><p>${inline(cap(parts.given), link)}</p></div><i aria-hidden="true">→</i><div><b>Ação</b><p>${inline(cap(parts.when), link)}</p></div><i aria-hidden="true">→</i><div class="res"><b>Resultado</b><p>${inline(cap(parts.then), link)}</p></div></div>`
|
|
343
|
-
: `<div class="prose"><p>${inline(c.text, link)}</p></div>`;
|
|
344
|
-
const proof = c.proof ? PROOF_SAY[c.proof.toLowerCase()] ?? c.proof : null;
|
|
345
|
-
const risk = c.risk ? RISK_SAY[c.risk.toLowerCase()] ?? c.risk : null;
|
|
346
|
-
const meta = [
|
|
347
|
-
proof && `<li><b>Como se confere</b>${esc(proof)}</li>`,
|
|
348
|
-
risk && `<li><b>O que protege</b>${esc(risk)}</li>`,
|
|
349
|
-
rung && `<li><b>Cuidado</b>${esc(rung.why)}</li>`,
|
|
350
|
-
cites.length && `<li><b>Decisão por trás</b>${cites.map((id) => `<a href="#${id}" data-ref="${id}">${refName(id)}</a>`).join(', ')}</li>`,
|
|
351
|
-
].filter(Boolean).join('');
|
|
352
|
-
const evidence = c.proof_note || c.evidence;
|
|
353
|
-
// The title is the author's paraphrase and nothing checks it: what has no way back shows its real text unasked.
|
|
354
|
-
return `<li><details class="row ${state.tone}" id="${esc(c.id)}"${rung ? ' open' : ''}><summary><i class="ico ${state.tone}" title="${esc(state.label)}" aria-hidden="true">${state.glyph}</i><span class="id">${esc(scenarioName(c.id))}</span><span class="t plain">${inline(titleOf(c), link)}</span>${rung ? `<span class="pill ${rung.tone}">${esc(rung.label)}</span>` : ''}<span class="pill ${state.tone}">${esc(state.label)}</span></summary><div class="row-body">${steps}${meta ? `<ul class="meta">${meta}</ul>` : ''}${evidence ? fold('A prova, para quem quer conferir', `<p>${inline(evidence, link)}</p>`) : ''}</div></details></li>`;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function deliveriesPanel(view, citesOf, link) {
|
|
358
|
-
const { scenarios } = view.plan;
|
|
359
|
-
const states = scenarios.map(scenarioState);
|
|
360
|
-
const tally = [...new Set(states.map((s) => s.label))].map((label) => {
|
|
361
|
-
const s = states.find((x) => x.label === label);
|
|
362
|
-
return `<li><i class="ico ${s.tone}" aria-hidden="true">${s.glyph}</i>${states.filter((x) => x.label === label).length} ${esc(label.toLowerCase())}</li>`;
|
|
363
|
-
}).join('');
|
|
364
|
-
return `<section class="panel" id="entregas"><h2>O que será entregue</h2><p class="sub">Cada linha é algo que precisa funcionar para a feature estar pronta. Clique para ver em que situação.</p>
|
|
365
|
-
${scenarios.length ? `<ul class="tally">${tally}</ul><ol class="line">${scenarios.map((c) => scenarioRow(c, citesOf(c.id), link)).join('')}</ol>` : '<p class="calm">O plano ainda não lista entregas.</p>'}</section>`;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// The page shows the plain lines and what a decision holds up by itself; the body keeps only the technical rest.
|
|
369
|
-
const adrBody = (a) => a.body
|
|
370
|
-
.replace(/^\s*\*\*(?:Alcance|Decidimos|Por qu[eê]|O que custa):\*\*.*$/gim, '')
|
|
371
|
-
.replace(/\s*Sustenta\s+(?:C\d+(?:,\s*|\s+e\s+)?)+\.?\s*$/i, '')
|
|
372
|
-
.trim();
|
|
373
|
-
|
|
374
|
-
function decisionCard(a, holds, link) {
|
|
375
|
-
const head = `<span class="id">${esc(a.id)}</span><span class="t plain">${inline(a.title, link)}</span>${a.scope === 'projeto' ? '<span class="pill">vale para o projeto todo</span>' : ''}`;
|
|
376
|
-
const sustains = holds.length ? `<p class="holds">Sustenta ${holds.map((id) => `<a href="#${id}" data-ref="${id}">${scenarioName(id)}</a>`).join(', ')}</p>` : '';
|
|
377
|
-
const body = adrBody(a);
|
|
378
|
-
const lines = Object.entries(ADR_PLAIN_LABELS).filter(([key]) => a.plain?.[key]);
|
|
379
|
-
if (!lines.length) return `<details class="adr" id="${esc(a.id)}"><summary>${head}</summary><div class="prose">${blocks(body, link)}</div>${sustains}</details>`;
|
|
380
|
-
return `<article class="adr said" id="${esc(a.id)}"><h3>${head}</h3><dl class="plain">${lines.map(([key, label]) => `<dt>${label}</dt><dd>${inline(cap(a.plain[key]), link)}</dd>`).join('')}</dl>${sustains}${fold('O detalhe técnico', body ? blocks(body, link) : '')}</article>`;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function decisionsPanel(view, cited, link) {
|
|
384
|
-
const { adrs } = view.plan;
|
|
385
|
-
const conflicts = conflictsOf(view.plan);
|
|
386
|
-
return `<section class="panel" id="decisoes">
|
|
387
|
-
<h2>Decisões de projeto</h2><p class="sub">O caminho escolhido, o motivo e o que ele custa.</p>
|
|
388
|
-
${adrs.length ? adrs.map((a) => decisionCard(a, cited.get(a.id), link)).join('') : '<p class="calm">Este plano não precisou de decisão de arquitetura.</p>'}
|
|
389
|
-
${conflicts ? `<h2 id="conflitos">Mudanças em decisões anteriores</h2><div class="prose">${blocks(conflicts, link)}</div>` : ''}
|
|
390
|
-
${fold('Segunda opinião sobre o plano', view.critique ? blocks(view.critique, link) : '')}
|
|
391
|
-
</section>`;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function insidePanel(view, link) {
|
|
395
|
-
const { plan } = view;
|
|
396
|
-
const flow = plan.flow?.transitions ?? [];
|
|
397
|
-
const states = plan.states?.transitions ?? [];
|
|
398
|
-
const reuse = plan.reuse.length ? `<h2>O que aproveita e o que é novo</h2><div class="scroll-x"><table><thead><tr><th>Peça</th><th>Situação</th><th>Onde</th></tr></thead><tbody>${plan.reuse.map((r) => `<tr><td>${inline(r.concept, link)}</td><td><span class="pill ${r.verdict === 'CRIAR' ? 'warn' : 'ok'}">${esc(REUSE_SAY[r.verdict] ?? r.verdict.toLowerCase())}</span></td><td>${inline(r.target, link)}${r.why ? `<br><small>${inline(r.why, link)}</small>` : ''}</td></tr>`).join('')}</tbody></table></div>` : '';
|
|
399
|
-
const choices = plan.defaults.items.length
|
|
400
|
-
? `<h2 id="escolhas">Escolhas técnicas feitas sem perguntar</h2><p class="sub">Valores de baixo risco, decididos para não parar o trabalho. Sem marca = aceito.</p><ul class="choices">${plan.defaults.items.map((d) => `<li id="P${d.n}" data-ask="padrão ${d.n}" data-verb="Vetar"><span class="n">${d.n}</span><p>${inline(d.text, link)}</p>${toggle()}</li>`).join('')}</ul>`
|
|
401
|
-
: '';
|
|
402
|
-
const parts = [
|
|
403
|
-
flow.length ? `<h2>O caminho pelo sistema</h2><div class="diagram">${layeredFlowSvg(flow, 'Fluxo', 'flow')}</div>` : '',
|
|
404
|
-
states.length ? `<h2>Estados</h2><div class="diagram">${stateMachineSvg(states, 'Máquina de estados', 'states')}</div>` : '',
|
|
405
|
-
plan.text.architecture ? `<h2>Onde o código entra</h2><div class="prose">${blocks(plan.text.architecture, link)}</div>` : '',
|
|
406
|
-
reuse,
|
|
407
|
-
choices,
|
|
408
|
-
clean(plan.errata) ? `<h2>Correções feitas depois da aprovação</h2><div class="prose">${blocks(plan.errata, link)}</div>` : '',
|
|
409
|
-
].filter(Boolean);
|
|
410
|
-
if (!parts.length) return '';
|
|
411
|
-
return `<section class="panel" id="por-dentro"><p class="calm">A parte técnica, para quem vai abrir o código. Dá para aprovar o plano sem ler esta aba.</p>
|
|
412
|
-
${parts.join('\n')}
|
|
413
|
-
</section>`;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function recapPanel(view) {
|
|
417
|
-
if (!view.recap) return '';
|
|
418
|
-
return `<section class="panel" id="recap"><h2>A história da feature</h2><p class="sub">Toque para ouvir o que foi feito, cena por cena.</p><iframe class="recap" title="Recap narrado" loading="lazy" srcdoc="${esc(renderRecapHtml(view.recap))}"></iframe></section>`;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
function refsOf(plan) {
|
|
422
|
-
const refs = {};
|
|
423
|
-
for (const c of plan.scenarios) refs[c.id] = (c.title || c.text).replace(/`/g, '');
|
|
424
|
-
for (const a of plan.adrs) refs[a.id] = a.title;
|
|
425
|
-
for (const d of plan.defaults.items) refs[`P${d.n}`] = d.text.replace(/`/g, '');
|
|
426
|
-
return JSON.stringify(refs).replace(/</g, '\\u003c');
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
export function renderFeatureHtml(view) {
|
|
430
|
-
const { plan } = view;
|
|
431
|
-
const link = linkifier(plan);
|
|
432
|
-
const points = attentionPoints(view);
|
|
433
|
-
const ids = plan.scenarios.map((c) => c.id);
|
|
434
|
-
const cited = new Map(plan.adrs.map((a) => [a.id, ids.filter((id) => new RegExp(`\\b${id}\\b`).test(a.body))]));
|
|
435
|
-
const citesOf = (id) => plan.adrs.filter((a) => cited.get(a.id).includes(id)).map((a) => a.id);
|
|
436
|
-
const inside = insidePanel(view, link);
|
|
437
|
-
const recap = recapPanel(view);
|
|
438
|
-
const tabs = [
|
|
439
|
-
['resumo', 'Resumo', settled(view) ? points.filter((p) => LIVE_KINDS.includes(p.kind)).length : points.length],
|
|
440
|
-
['entregas', 'Entregas'],
|
|
441
|
-
['decisoes', 'Decisões'],
|
|
442
|
-
...(inside ? [['por-dentro', 'Por dentro']] : []),
|
|
443
|
-
...(recap ? [['recap', 'Recap']] : []),
|
|
444
|
-
];
|
|
445
|
-
const key = `${view.feature}:${(view.planHash ?? '').slice(0, 12)}`;
|
|
446
|
-
const name = plan.summary?.name;
|
|
447
|
-
return `<!doctype html>
|
|
448
|
-
<html lang="pt-BR">
|
|
449
|
-
<head>
|
|
450
|
-
<meta charset="utf-8">
|
|
451
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
452
|
-
<title>${esc(name ?? view.feature)}</title>
|
|
453
|
-
<style>
|
|
454
|
-
${TOKENS_CSS}${PAGE_CSS}</style>
|
|
455
|
-
</head>
|
|
456
|
-
<body data-key="${esc(key)}" data-feature="${esc(view.feature)}"${settled(view) ? ' class="settled"' : ''}>
|
|
457
|
-
<header class="top">
|
|
458
|
-
<p class="kind">${esc(WORK_NAME[view.workType] ?? 'Funcionalidade nova')}${name ? ` <code>${esc(view.feature)}</code>` : ''}</p>
|
|
459
|
-
<h1>${esc(name ?? view.feature)}</h1>
|
|
460
|
-
<ol class="route">${view.stations.map((s) => `<li class="${s.state}"${s.state === 'now' ? ' aria-current="step"' : ''}><i aria-hidden="true"></i><span>${esc(s.label)}${s.note ? `<small>${esc(s.note)}</small>` : ''}</span></li>`).join('')}</ol>
|
|
461
|
-
${originStrip(view)}
|
|
462
|
-
</header>
|
|
463
|
-
<nav class="tabs" aria-label="Partes da página"><div>${tabs.map(([id, label, badge], i) => `<a href="#${id}"${i === 0 ? ' class="on"' : ''}>${esc(label)}${badge ? `<b>${badge}</b>` : ''}</a>`).join('')}</div></nav>
|
|
464
|
-
<main>
|
|
465
|
-
${summaryPanel(view, points, link)}
|
|
466
|
-
${deliveriesPanel(view, citesOf, link)}
|
|
467
|
-
${decisionsPanel(view, cited, link)}
|
|
468
|
-
${inside}
|
|
469
|
-
${recap}
|
|
470
|
-
<p class="source">Página gerada pelo morph-spec a partir do plano${view.planHash ? ` (${esc(view.planHash.slice(0, 12))})` : ''} e dos relatórios da feature. Recarregue para ver o estado mais recente.</p>
|
|
471
|
-
</main>
|
|
472
|
-
<div id="peek" role="tooltip"></div>
|
|
473
|
-
<div id="tray" role="region" aria-label="Sua resposta"><span class="count"></span><button type="button" class="copy">Copiar resposta</button><button type="button" class="clear">Limpar</button></div>
|
|
474
|
-
<script type="application/json" id="refs">${refsOf(plan)}</script>
|
|
475
|
-
<script>
|
|
476
|
-
${CLIENT_JS}</script>
|
|
477
|
-
</body>
|
|
478
|
-
</html>
|
|
479
|
-
`;
|
|
480
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
document.documentElement.classList.add('js');
|
|
2
|
-
const REFS = JSON.parse(document.getElementById('refs').textContent);
|
|
3
|
-
const STORE = `morph-view:${document.body.dataset.key}`;
|
|
4
|
-
const load = () => { try { return JSON.parse(localStorage.getItem(STORE)) ?? {}; } catch { return {}; } };
|
|
5
|
-
const save = (v) => { try { localStorage.setItem(STORE, JSON.stringify(v)); } catch { /* the page works without it */ } };
|
|
6
|
-
|
|
7
|
-
const panels = [...document.querySelectorAll('.panel')];
|
|
8
|
-
const tabs = [...document.querySelectorAll('.tabs a')];
|
|
9
|
-
function openPanel(id) {
|
|
10
|
-
panels.forEach((p) => p.classList.toggle('on', p.id === id));
|
|
11
|
-
tabs.forEach((a) => {
|
|
12
|
-
const on = a.getAttribute('href') === `#${id}`;
|
|
13
|
-
a.classList.toggle('on', on);
|
|
14
|
-
if (on) a.setAttribute('aria-current', 'page'); else a.removeAttribute('aria-current');
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function jump() {
|
|
18
|
-
const id = decodeURIComponent(location.hash.slice(1));
|
|
19
|
-
const el = id ? document.getElementById(id) : null;
|
|
20
|
-
const panel = el?.closest('.panel') ?? panels[0];
|
|
21
|
-
openPanel(panel.id);
|
|
22
|
-
if (!el) return;
|
|
23
|
-
if (el === panel) { document.querySelector('.tabs').scrollIntoView(); return; }
|
|
24
|
-
if (el.tagName === 'DETAILS') el.open = true;
|
|
25
|
-
el.closest('details')?.setAttribute('open', '');
|
|
26
|
-
el.scrollIntoView({ block: 'start' });
|
|
27
|
-
el.classList.remove('flash');
|
|
28
|
-
void el.offsetWidth;
|
|
29
|
-
el.classList.add('flash');
|
|
30
|
-
}
|
|
31
|
-
addEventListener('hashchange', jump);
|
|
32
|
-
|
|
33
|
-
const peek = document.getElementById('peek');
|
|
34
|
-
function showPeek(a) {
|
|
35
|
-
const text = REFS[a.dataset.ref];
|
|
36
|
-
if (!text) return;
|
|
37
|
-
peek.textContent = text;
|
|
38
|
-
const r = a.getBoundingClientRect();
|
|
39
|
-
peek.style.left = `${Math.max(8, Math.min(r.left, innerWidth - 350))}px`;
|
|
40
|
-
peek.style.top = `${r.bottom + 6 + 90 > innerHeight ? r.top - 96 : r.bottom + 6}px`;
|
|
41
|
-
peek.classList.add('on');
|
|
42
|
-
}
|
|
43
|
-
const hidePeek = () => peek.classList.remove('on');
|
|
44
|
-
document.querySelectorAll('a[data-ref]').forEach((a) => {
|
|
45
|
-
a.addEventListener('mouseenter', () => showPeek(a));
|
|
46
|
-
a.addEventListener('focus', () => showPeek(a));
|
|
47
|
-
a.addEventListener('mouseleave', hidePeek);
|
|
48
|
-
a.addEventListener('blur', hidePeek);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const state = load();
|
|
52
|
-
const tray = document.getElementById('tray');
|
|
53
|
-
const asks = [...document.querySelectorAll('[data-ask]')];
|
|
54
|
-
function answer() {
|
|
55
|
-
const lines = [];
|
|
56
|
-
for (const li of asks) {
|
|
57
|
-
const id = li.dataset.ask;
|
|
58
|
-
const pressed = li.querySelector('.toggle')?.getAttribute('aria-pressed') === 'true';
|
|
59
|
-
const note = li.querySelector('.note')?.value.trim();
|
|
60
|
-
if (pressed || note) lines.push(`- ${li.dataset.verb} ${id}${note ? `: ${note}` : ''}`);
|
|
61
|
-
}
|
|
62
|
-
return lines;
|
|
63
|
-
}
|
|
64
|
-
function sync() {
|
|
65
|
-
const n = answer().length;
|
|
66
|
-
tray.classList.toggle('on', n > 0);
|
|
67
|
-
tray.querySelector('.count').textContent = `${n} ${n === 1 ? 'ajuste marcado' : 'ajustes marcados'}`;
|
|
68
|
-
save(state);
|
|
69
|
-
}
|
|
70
|
-
for (const li of asks) {
|
|
71
|
-
const id = li.dataset.ask;
|
|
72
|
-
const toggle = li.querySelector('.toggle');
|
|
73
|
-
const open = (on) => {
|
|
74
|
-
toggle.setAttribute('aria-pressed', String(on));
|
|
75
|
-
let note = li.querySelector('.note');
|
|
76
|
-
if (on && !note) {
|
|
77
|
-
note = document.createElement('textarea');
|
|
78
|
-
note.className = 'note';
|
|
79
|
-
note.setAttribute('aria-label', `O que mudar em ${id}`);
|
|
80
|
-
note.placeholder = 'O que você quer no lugar? Opcional.';
|
|
81
|
-
note.value = state[id]?.note ?? '';
|
|
82
|
-
note.addEventListener('input', () => { state[id] = { note: note.value }; sync(); });
|
|
83
|
-
li.append(note);
|
|
84
|
-
} else if (!on && note) note.remove();
|
|
85
|
-
};
|
|
86
|
-
toggle.addEventListener('click', () => {
|
|
87
|
-
const on = toggle.getAttribute('aria-pressed') !== 'true';
|
|
88
|
-
open(on);
|
|
89
|
-
if (on) { state[id] = { note: state[id]?.note ?? '' }; li.querySelector('.note').focus(); } else delete state[id];
|
|
90
|
-
sync();
|
|
91
|
-
});
|
|
92
|
-
if (state[id]) open(true);
|
|
93
|
-
}
|
|
94
|
-
tray.querySelector('.copy').addEventListener('click', async (e) => {
|
|
95
|
-
const text = `Ajustes em ${document.body.dataset.feature}:\n${answer().join('\n')}`;
|
|
96
|
-
try { await navigator.clipboard.writeText(text); e.target.textContent = 'Copiado'; } catch { prompt('Copie o texto', text); }
|
|
97
|
-
setTimeout(() => { e.target.textContent = 'Copiar resposta'; }, 1800);
|
|
98
|
-
});
|
|
99
|
-
document.querySelectorAll('[data-copy]').forEach((b) => b.addEventListener('click', async () => {
|
|
100
|
-
const label = b.textContent;
|
|
101
|
-
try { await navigator.clipboard.writeText(b.dataset.copy); b.textContent = 'Copiado'; } catch { prompt('Copie o texto', b.dataset.copy); }
|
|
102
|
-
setTimeout(() => { b.textContent = label; }, 1800);
|
|
103
|
-
}));
|
|
104
|
-
tray.querySelector('.clear').addEventListener('click', () => {
|
|
105
|
-
for (const li of asks) if (li.querySelector('.toggle').getAttribute('aria-pressed') === 'true') li.querySelector('.toggle').click();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
sync();
|
|
109
|
-
jump();
|