@polymorphism-tech/morph-spec 10.11.0 → 10.12.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/README.md +2 -2
- package/bin/morph-spec.js +3 -1
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +4 -3
- package/framework/MORPH.md +14 -12
- package/framework/commands/morph-review.md +1 -1
- package/framework/commands/morph-status.md +2 -6
- package/framework/docs/CLI.md +22 -7
- package/framework/hooks/claude-code/core/enforce-phase-writes.js +12 -11
- package/framework/hooks/claude-code/core/gate-guard.js +19 -14
- package/framework/hooks/claude-code/core/heavy-gate.js +4 -1
- package/framework/hooks/claude-code/core/loop-detect.js +8 -7
- package/framework/hooks/claude-code/core/masked-exit.js +5 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +13 -11
- package/framework/hooks/claude-code/core/state-sync.js +20 -12
- package/framework/hooks/claude-code/core/validate-completion.js +6 -5
- package/framework/hooks/claude-code/core/worktree-context.js +47 -43
- package/framework/hooks/shared/e2e-check.js +49 -9
- package/framework/hooks/shared/gate-question.js +8 -0
- package/framework/hooks/shared/host-services.js +7 -3
- package/framework/hooks/shared/next-step.js +54 -23
- package/framework/hooks/shared/owner-words.js +146 -0
- package/framework/hooks/shared/report-progress.js +84 -10
- package/framework/phases.json +7 -7
- package/framework/rules/implement-report.md +8 -7
- package/framework/rules/plan-grammar.md +4 -1
- package/framework/schemas/feature.schema.json +3 -2
- 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 +6 -5
- package/framework/skills/core/morph-apply/references/hotfix.md +6 -2
- package/framework/skills/core/morph-apply/references/review.md +9 -5
- package/framework/skills/core/morph-plan/SKILL.md +5 -5
- package/framework/skills/core/morph-plan/references/interview.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +10 -6
- package/framework/templates/docs/plan.md +1 -1
- package/package.json +1 -1
- package/src/commands/e2e/e2e.js +37 -29
- package/src/commands/project/status.js +28 -184
- package/src/commands/state/advance.js +44 -20
- package/src/commands/state/approve.js +70 -59
- package/src/commands/state/archive.js +20 -15
- package/src/commands/state/auto-approval.js +25 -23
- package/src/commands/state/create.js +35 -32
- package/src/commands/state/finish.js +179 -58
- package/src/commands/state/gate-check.js +43 -31
- package/src/commands/state/gate-decision.js +18 -14
- package/src/commands/state/list.js +23 -14
- package/src/commands/state/next.js +4 -5
- package/src/commands/state/report-check.js +47 -23
- package/src/commands/validation/plan-check.js +30 -14
- package/src/commands/validation/verify.js +39 -18
- package/src/dashboard/app/components/ActivityFeed.jsx +8 -8
- package/src/dashboard/app/components/CommandPalette.jsx +1 -1
- package/src/dashboard/app/components/GatePauses.jsx +8 -8
- package/src/dashboard/app/components/PhaseRail.jsx +6 -6
- package/src/dashboard/app/components/SessionMap.jsx +7 -7
- package/src/dashboard/app/lib/format.js +6 -2
- package/src/dashboard/app/lib/phases.js +48 -16
- package/src/dashboard/app/pages/FeatureDetail.jsx +87 -59
- package/src/dashboard/app/pages/Features.jsx +18 -18
- package/src/dashboard/app/pages/Guide.jsx +4 -4
- package/src/dashboard/app/pages/PhasePipeline.jsx +7 -7
- package/src/dashboard/app/pages/Portfolio.jsx +3 -3
- package/src/dashboard/scanner/activity-scanner.js +20 -6
- package/src/dashboard/scanner/features-scanner.js +43 -8
- package/src/dashboard/scanner/project-api.js +2 -0
- package/src/dashboard/vite.config.js +2 -0
- package/src/lib/next-step.js +3 -2
- package/src/lib/plan/checks.js +30 -15
- package/src/lib/plan/critique.js +6 -4
- package/src/lib/recap/recap.js +46 -20
- package/src/lib/risk-detector.js +260 -98
- package/src/lib/view/feature-html.js +19 -25
- package/src/lib/view/feature-view.js +6 -6
- package/src/utils/audience.js +27 -0
- package/src/utils/refusal-line.js +2 -2
|
@@ -3,6 +3,9 @@ import { renderRecapHtml } from '../recap/recap.js';
|
|
|
3
3
|
import { ADR_PLAIN_LABELS } from '../plan/plan-parser.js';
|
|
4
4
|
import { stateMachineSvg } from './flow-svg.js';
|
|
5
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';
|
|
6
9
|
|
|
7
10
|
export const TOKENS_CSS = readFileSync(new URL('./tokens.css', import.meta.url), 'utf8');
|
|
8
11
|
const PAGE_CSS = readFileSync(new URL('./feature-page.css', import.meta.url), 'utf8');
|
|
@@ -14,30 +17,21 @@ const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
|
14
17
|
const clean = (text) => String(text ?? '').replace(/<!--[\s\S]*?-->/g, '').trim();
|
|
15
18
|
const NONE_RE = /^(nenhum|nenhuma)\.?$/i;
|
|
16
19
|
|
|
17
|
-
const WORK_LABEL = { feature: 'Funcionalidade nova', bug: 'Correção de bug', chore: 'Manutenção', hotfix: 'Correção urgente' };
|
|
18
|
-
const PROOF_LABEL = {
|
|
19
|
-
teste: 'teste automático', e2e: 'teste do fluxo completo, como um usuário', eval: 'avaliação da resposta da IA',
|
|
20
|
-
manual: 'conferência manual', leitura: 'leitura do código',
|
|
21
|
-
};
|
|
22
|
-
const RISK_LABEL = {
|
|
23
|
-
regra: 'regra de negócio', dinheiro: 'dinheiro', contrato: 'integração com outro sistema',
|
|
24
|
-
'concorrência': 'duas coisas ao mesmo tempo', dado: 'integridade dos dados', 'regressão': 'bug que já aconteceu',
|
|
25
|
-
};
|
|
26
20
|
const RUNG = {
|
|
27
21
|
desfazer: { label: 'Dá trabalho para desfazer', why: 'Dá para voltar atrás, mas não só desfazendo o código.', tone: 'warn' },
|
|
28
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' },
|
|
29
23
|
'irreversível': { label: 'Não tem volta', why: 'Depois que rodar, o que mudou não se recupera.', tone: 'bad' },
|
|
30
24
|
};
|
|
31
25
|
const rungOf = (c) => RUNG[String(c.rung ?? '').toLowerCase().replace('irreversivel', 'irreversível')] ?? null;
|
|
32
|
-
const
|
|
33
|
-
const
|
|
26
|
+
const scenarioName = (id) => `Cenário ${String(id).replace(/^C/i, '')}`;
|
|
27
|
+
const refName = (id) => (/^C\d+$/.test(id) ? scenarioName(id) : id);
|
|
34
28
|
|
|
35
29
|
function linkifier(plan) {
|
|
36
30
|
const known = new Set([...plan.scenarios.map((c) => c.id), ...plan.adrs.map((a) => a.id)]);
|
|
37
31
|
const defaults = new Set(plan.defaults.items.map((d) => d.n));
|
|
38
32
|
const ref = (id, label) => `<a href="#${id}" data-ref="${id}">${label}</a>`;
|
|
39
33
|
return (escaped) => escaped
|
|
40
|
-
.replace(/\b(C\d+|ADR-\d+)\b/g, (m, id) => (known.has(id) ? ref(id, m) : m))
|
|
34
|
+
.replace(/\b(C\d+|ADR-\d+)\b/g, (m, id) => (known.has(id) ? ref(id, refName(m)) : m))
|
|
41
35
|
.replace(/\b([Pp]adrão) (\d+)\b/g, (m, word, n) => (defaults.has(Number(n)) ? ref(`P${n}`, `${word} ${n}`) : m));
|
|
42
36
|
}
|
|
43
37
|
|
|
@@ -168,7 +162,7 @@ export function attentionPoints(view) {
|
|
|
168
162
|
}
|
|
169
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.' });
|
|
170
164
|
for (const [role, r] of Object.entries(reviews ?? {})) {
|
|
171
|
-
for (const b of r.blockers ?? []) points.push({ kind: 'review', tone: 'bad', glyph: '✕', tag: `${
|
|
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 });
|
|
172
166
|
}
|
|
173
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' });
|
|
174
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}` }));
|
|
@@ -190,7 +184,7 @@ function pointGroups(points, link) {
|
|
|
190
184
|
}
|
|
191
185
|
const item = (p) => {
|
|
192
186
|
const ask = p.ask ? ` data-ask="${esc(p.ask)}" data-verb="${esc(p.verb)}"` : '';
|
|
193
|
-
const where = p.ref ? `<a class="id" href="#${esc(p.ref)}" data-ref="${esc(p.ref)}">${esc(p.ref)}</a>` : p.href ? `<a class="id" href="${esc(p.href)}">ver</a>` : '';
|
|
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>` : '';
|
|
194
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>`;
|
|
195
189
|
};
|
|
196
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>`;
|
|
@@ -231,7 +225,7 @@ function stopsLine(scenarios) {
|
|
|
231
225
|
return `<nav class="stops" aria-label="As ${scenarios.length} entregas">${scenarios.map((c, i) => {
|
|
232
226
|
const state = scenarioState(c);
|
|
233
227
|
const rung = rungOf(c);
|
|
234
|
-
return `<a class="stop ${state.tone}${rung ? ' rung' : ''}" style="--i:${i}" href="#${esc(c.id)}" data-ref="${esc(c.id)}" aria-label="${esc(`${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>`;
|
|
235
229
|
}).join('')}</nav>`;
|
|
236
230
|
}
|
|
237
231
|
|
|
@@ -297,13 +291,13 @@ function progressBlock(view, link) {
|
|
|
297
291
|
for (const [role, r] of Object.entries(reviews)) {
|
|
298
292
|
if (r.status === 'missing') continue;
|
|
299
293
|
const tone = r.verdict === 'SHIP' ? 'ok' : r.verdict === 'FIX' ? 'bad' : 'todo';
|
|
300
|
-
const word = r.verdict
|
|
301
|
-
rows.push(row(tone, tone === 'ok' ? '✓' : tone === 'bad' ? '✕' : '',
|
|
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') : ''));
|
|
302
296
|
}
|
|
303
297
|
const blockers = Object.values(reviews).flatMap((r) => r.blockers ?? []);
|
|
304
298
|
return `<div id="andamento"><h2>Como está andando</h2>
|
|
305
299
|
${rows.length ? `<ul class="timeline">${rows.join('')}</ul>` : ''}
|
|
306
|
-
${blockers.length ? `<h3>O que a revisão apontou</h3><div class="prose"><ul>${blockers.map((b) => `<li>${inline(`${b.
|
|
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>` : ''}
|
|
307
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>` : ''}
|
|
308
302
|
</div>`;
|
|
309
303
|
}
|
|
@@ -347,17 +341,17 @@ function scenarioRow(c, cites, link) {
|
|
|
347
341
|
const steps = parts
|
|
348
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>`
|
|
349
343
|
: `<div class="prose"><p>${inline(c.text, link)}</p></div>`;
|
|
350
|
-
const proof = c.proof ?
|
|
351
|
-
const risk = c.risk ?
|
|
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;
|
|
352
346
|
const meta = [
|
|
353
347
|
proof && `<li><b>Como se confere</b>${esc(proof)}</li>`,
|
|
354
348
|
risk && `<li><b>O que protege</b>${esc(risk)}</li>`,
|
|
355
349
|
rung && `<li><b>Cuidado</b>${esc(rung.why)}</li>`,
|
|
356
|
-
cites.length && `<li><b>Decisão por trás</b>${cites.map((id) => `<a href="#${id}" data-ref="${id}">${id}</a>`).join(', ')}</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>`,
|
|
357
351
|
].filter(Boolean).join('');
|
|
358
352
|
const evidence = c.proof_note || c.evidence;
|
|
359
353
|
// The title is the author's paraphrase and nothing checks it: what has no way back shows its real text unasked.
|
|
360
|
-
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(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>`;
|
|
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>`;
|
|
361
355
|
}
|
|
362
356
|
|
|
363
357
|
function deliveriesPanel(view, citesOf, link) {
|
|
@@ -379,7 +373,7 @@ const adrBody = (a) => a.body
|
|
|
379
373
|
|
|
380
374
|
function decisionCard(a, holds, link) {
|
|
381
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>' : ''}`;
|
|
382
|
-
const sustains = holds.length ? `<p class="holds">Sustenta ${holds.map((id) => `<a href="#${id}" data-ref="${id}">${id}</a>`).join(', ')}</p>` : '';
|
|
376
|
+
const sustains = holds.length ? `<p class="holds">Sustenta ${holds.map((id) => `<a href="#${id}" data-ref="${id}">${scenarioName(id)}</a>`).join(', ')}</p>` : '';
|
|
383
377
|
const body = adrBody(a);
|
|
384
378
|
const lines = Object.entries(ADR_PLAIN_LABELS).filter(([key]) => a.plain?.[key]);
|
|
385
379
|
if (!lines.length) return `<details class="adr" id="${esc(a.id)}"><summary>${head}</summary><div class="prose">${blocks(body, link)}</div>${sustains}</details>`;
|
|
@@ -401,7 +395,7 @@ function insidePanel(view, link) {
|
|
|
401
395
|
const { plan } = view;
|
|
402
396
|
const flow = plan.flow?.transitions ?? [];
|
|
403
397
|
const states = plan.states?.transitions ?? [];
|
|
404
|
-
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(
|
|
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>` : '';
|
|
405
399
|
const choices = plan.defaults.items.length
|
|
406
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>`
|
|
407
401
|
: '';
|
|
@@ -461,7 +455,7 @@ ${TOKENS_CSS}${PAGE_CSS}</style>
|
|
|
461
455
|
</head>
|
|
462
456
|
<body data-key="${esc(key)}" data-feature="${esc(view.feature)}"${settled(view) ? ' class="settled"' : ''}>
|
|
463
457
|
<header class="top">
|
|
464
|
-
<p class="kind">${esc(
|
|
458
|
+
<p class="kind">${esc(WORK_NAME[view.workType] ?? 'Funcionalidade nova')}${name ? ` <code>${esc(view.feature)}</code>` : ''}</p>
|
|
465
459
|
<h1>${esc(name ?? view.feature)}</h1>
|
|
466
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>
|
|
467
461
|
${originStrip(view)}
|
|
@@ -7,12 +7,12 @@ import { reviewReportsFromDir } from '../review-reports.js';
|
|
|
7
7
|
import { implementProgressFrom } from '../../../framework/hooks/shared/report-progress.js';
|
|
8
8
|
import { changeSummary } from '../recap/recap.js';
|
|
9
9
|
import { renderFeatureHtml } from './feature-html.js';
|
|
10
|
+
import { GATE_NAME, PHASE_NAME } from '../../../framework/hooks/shared/owner-words.js';
|
|
10
11
|
|
|
11
12
|
const readText = (path) => { try { return readFileSync(path, 'utf8'); } catch { return null; } };
|
|
12
13
|
const readJson = (path) => { try { return JSON.parse(readFileSync(path, 'utf8')); } catch { return null; } };
|
|
13
14
|
const listDir = (path) => { try { return readdirSync(path); } catch { return []; } };
|
|
14
15
|
|
|
15
|
-
const GATE_ASK = { plan: 'Plano', uiux: 'Design', review: 'Revisão' };
|
|
16
16
|
|
|
17
17
|
function collectDesign(featureDir) {
|
|
18
18
|
const screens = (sub) => listDir(join(featureDir, '1-design', sub))
|
|
@@ -30,10 +30,10 @@ function stations({ gates, design, progress, reviews, archived }) {
|
|
|
30
30
|
const hasReview = Object.values(reviews).some((r) => r.status !== 'missing');
|
|
31
31
|
const built = hasReview || (progress?.total > 0 && progress.done === progress.total);
|
|
32
32
|
const reached = [
|
|
33
|
-
{ id: 'plan', label:
|
|
34
|
-
...(design ? [{ id: 'uiux', label:
|
|
35
|
-
{ id: 'implement', label:
|
|
36
|
-
{ id: 'review', label:
|
|
33
|
+
{ id: 'plan', label: PHASE_NAME.plan, done: approved('plan') },
|
|
34
|
+
...(design ? [{ id: 'uiux', label: PHASE_NAME.uiux, done: approved('uiux') }] : []),
|
|
35
|
+
{ id: 'implement', label: PHASE_NAME.implement, done: built, note: progress?.total ? `${progress.done} de ${progress.total}` : null },
|
|
36
|
+
{ id: 'review', label: PHASE_NAME.review, done: approved('review') },
|
|
37
37
|
{ id: 'ship', label: 'Entrega', done: archived },
|
|
38
38
|
];
|
|
39
39
|
// The archive keeps neither the report nor the reviews: a later station done proves the earlier ones.
|
|
@@ -46,7 +46,7 @@ function currentGate(fj) {
|
|
|
46
46
|
const pending = ['plan', 'uiux', 'review'].find((g) => fj.gateDecisions?.[g] && !(fj.approvalGates?.[g]?.approved === true));
|
|
47
47
|
if (!pending) return null;
|
|
48
48
|
const d = fj.gateDecisions[pending];
|
|
49
|
-
return { gate: pending, label:
|
|
49
|
+
return { gate: pending, label: GATE_NAME[pending], pause: d.pause === true, resolver: d.resolver ?? null, reason: d.reason ?? null };
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** Everything the page shows, read from the feature folder; a missing file only drops its part. */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// eslint-disable-next-line no-control-regex
|
|
2
|
+
const SESSION_LINE = /^\s*(?:\x1b\[[\d;]*m)*\s*para a sessão:/;
|
|
3
|
+
|
|
4
|
+
/** Who reads the terminal: Claude Code marks its shell with CLAUDECODE; MORPH_AUDIENCE overrides. */
|
|
5
|
+
export function audience(env = process.env) {
|
|
6
|
+
if (env.MORPH_AUDIENCE === 'owner' || env.MORPH_AUDIENCE === 'session') return env.MORPH_AUDIENCE;
|
|
7
|
+
return env.CLAUDECODE ? 'session' : 'owner';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function dropSessionLines(text) {
|
|
11
|
+
return String(text).split('\n').filter((line) => !SESSION_LINE.test(line)).join('\n');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** In the owner's terminal the `para a sessão:` lines go away; the session still reads them, and `--json` is untouched. */
|
|
15
|
+
export function installOwnerView(env = process.env) {
|
|
16
|
+
if (audience(env) !== 'owner') return;
|
|
17
|
+
for (const method of ['log', 'error']) {
|
|
18
|
+
const original = console[method];
|
|
19
|
+
console[method] = (...args) => {
|
|
20
|
+
if (!args.length || !args.every((a) => typeof a === 'string')) return original(...args);
|
|
21
|
+
const joined = args.join(' ');
|
|
22
|
+
if (!SESSION_LINE.test(joined) && !joined.includes('\n')) return original(joined);
|
|
23
|
+
const kept = dropSessionLines(joined);
|
|
24
|
+
if (kept.trim() || !joined.trim()) original(kept);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -7,7 +7,7 @@ function reasonFromJson(text) {
|
|
|
7
7
|
try {
|
|
8
8
|
const obj = JSON.parse(text);
|
|
9
9
|
if (!obj || typeof obj !== 'object' || !obj.error) return null;
|
|
10
|
-
return obj.hint
|
|
10
|
+
return clean(obj.hint ?? '') || clean(obj.reason ?? '') || String(obj.error);
|
|
11
11
|
} catch {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
@@ -27,7 +27,7 @@ export function installRefusalLine(command) {
|
|
|
27
27
|
};
|
|
28
28
|
console.error = (...args) => {
|
|
29
29
|
const text = args.map(String).join(' ');
|
|
30
|
-
if (!reason &&
|
|
30
|
+
if (!reason && /❌|^\s*(?:\x1b\[[\d;]*m)?\s*✗/u.test(text)) reason = clean(text);
|
|
31
31
|
error(...args);
|
|
32
32
|
};
|
|
33
33
|
process.on('exit', (code) => {
|