@polymorphism-tech/morph-spec 10.11.1 → 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 +2 -0
- 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 +21 -6
- 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/gate-question.js +8 -0
- 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 +31 -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
|
@@ -10,14 +10,14 @@ import { contextResult, runStandalone } from '../../shared/hook-response.js';
|
|
|
10
10
|
import { appendTelemetryEvent } from '../../shared/telemetry-logger.js';
|
|
11
11
|
import { readTranscriptUsage, usageDelta } from '../../shared/transcript-usage.js';
|
|
12
12
|
import { implementProgress } from '../../shared/report-progress.js';
|
|
13
|
+
import { scenarioLabel } from '../../shared/owner-words.js';
|
|
14
|
+
import { SESSION_MARK } from '../../shared/next-step.js';
|
|
13
15
|
|
|
14
16
|
function auditReport(featurePath) {
|
|
15
17
|
const progress = implementProgress(featurePath);
|
|
16
18
|
if (!progress || progress.legacy) return [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
? [`report.md: ${bare.join(', ')} feito sem evidência — o teste, a linha de código ou o passo que prova (morph-spec report-check)`]
|
|
20
|
-
: [];
|
|
19
|
+
return progress.checks.filter((c) => c.status === 'feito' && !c.evidence.trim())
|
|
20
|
+
.map((c) => `${scenarioLabel(c)} está marcado feito sem prova (o teste, a linha de código ou o passo que mostra que funciona).`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export async function run(payload) {
|
|
@@ -52,8 +52,9 @@ export async function run(payload) {
|
|
|
52
52
|
if (reportWarnings.length > 0) {
|
|
53
53
|
const hash = createHash('sha1').update(reportWarnings.join('\n')).digest('hex');
|
|
54
54
|
if (warnedHashes[name]?.reports !== hash) {
|
|
55
|
-
warnings.push('📋
|
|
55
|
+
warnings.push('📋 Relatório da construção:');
|
|
56
56
|
for (const w of reportWarnings) warnings.push(` • ${w}`);
|
|
57
|
+
warnings.push(`${SESSION_MARK} preencha a coluna evidência em 3-implement/report.md (morph-spec report-check ${name})`);
|
|
57
58
|
warnedHashes[name] = { ...warnedHashes[name], reports: hash };
|
|
58
59
|
try { writeFileSync(warnedHashesPath, JSON.stringify(warnedHashes, null, 2), 'utf-8'); } catch {}
|
|
59
60
|
}
|
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
4
4
|
import { dirname, join, resolve } from 'path';
|
|
5
5
|
import { execSync } from 'child_process';
|
|
6
|
-
import {
|
|
7
|
-
stateExists,
|
|
8
|
-
getActiveFeature,
|
|
9
|
-
getFeaturePhase,
|
|
10
|
-
getPendingGates,
|
|
11
|
-
} from '../../shared/state-reader.js';
|
|
6
|
+
import { stateExists, getActiveFeature, getFeaturePhase } from '../../shared/state-reader.js';
|
|
12
7
|
import { implementProgress } from '../../shared/report-progress.js';
|
|
13
|
-
import { collectNextSignals, decideNext,
|
|
8
|
+
import { collectNextSignals, decideNext, retratoOf, sessionLine, SESSION_MARK } from '../../shared/next-step.js';
|
|
9
|
+
import { featureRef, TESTS } from '../../shared/owner-words.js';
|
|
14
10
|
import { contextResult, runStandalone } from '../../shared/hook-response.js';
|
|
15
11
|
import { acquireClaim, foreignClaim, claimAge } from '../../shared/claim-registry.js';
|
|
16
12
|
import { rotateEventsLogIfLarge } from '../../shared/telemetry-logger.js';
|
|
@@ -120,30 +116,48 @@ function buildEnvLine(dir) {
|
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
|
|
119
|
+
function signalsFor(dir, slug, fallbackFeature) {
|
|
120
|
+
let signals = null;
|
|
121
|
+
try { signals = collectNextSignals(slug, dir); } catch {}
|
|
122
|
+
if (signals) return { signals, ownSignals: true };
|
|
123
|
+
const featureDir = join(dir, '.morph', 'features', slug);
|
|
124
|
+
return {
|
|
125
|
+
ownSignals: false,
|
|
126
|
+
signals: {
|
|
127
|
+
feature: slug, featureJson: fallbackFeature ?? null, progress: implementProgress(featureDir),
|
|
128
|
+
phase: getFeaturePhase(slug, dir), hasDesign: existsSync(join(featureDir, '1-design')),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
123
133
|
// No git here, so verify staleness is unknown: an escalation the tree already moved past, or the
|
|
124
134
|
// root skeleton of a feature living in a worktree, would be an order read from stale facts.
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return null;
|
|
135
|
+
function featureBlock(dir, slug, fallbackFeature) {
|
|
136
|
+
const { signals, ownSignals } = signalsFor(dir, slug, fallbackFeature);
|
|
137
|
+
const ref = featureRef(slug, signals.featureJson, signals.progress?.summary);
|
|
138
|
+
if (signals.worktreePath && !samePath(resolve(signals.worktreePath), resolve(dir))) {
|
|
139
|
+
return {
|
|
140
|
+
ref,
|
|
141
|
+
lines: [
|
|
142
|
+
`Esta funcionalidade está sendo construída em outro worktree (${signals.worktreePath}): abra a sessão lá; `
|
|
143
|
+
+ 'aqui é só o esqueleto de quando ela nasceu.',
|
|
144
|
+
],
|
|
145
|
+
};
|
|
137
146
|
}
|
|
147
|
+
let next = null;
|
|
148
|
+
try { next = ownSignals ? decideNext(signals) : null; } catch {}
|
|
149
|
+
const escalate = next?.action === 'escalate';
|
|
150
|
+
const lines = retratoOf(signals, escalate ? null : next).slice(1);
|
|
151
|
+
if (escalate) lines.push(`${SESSION_MARK} ${TESTS} falharam de novo: rode \`morph-spec next ${slug} --json\` antes de agir.`);
|
|
152
|
+
else if (next) lines.push(`${sessionLine(next)} (confirme com \`morph-spec next ${slug} --json\` depois de mudar a árvore)`);
|
|
153
|
+
return { ref, lines };
|
|
138
154
|
}
|
|
139
155
|
|
|
140
156
|
function buildWorktreeContext(dir, feature) {
|
|
141
|
-
const
|
|
142
|
-
let text = `🌳 Worktree desta
|
|
143
|
-
`Trabalhe
|
|
144
|
-
|
|
145
|
-
const nextLine = buildNextLine(dir, feature);
|
|
146
|
-
if (nextLine) text += `\n${nextLine}`;
|
|
157
|
+
const { ref, lines } = featureBlock(dir, feature);
|
|
158
|
+
let text = `🌳 Worktree desta funcionalidade: ${ref} (branch morph/${feature}). ` +
|
|
159
|
+
`Trabalhe só nela nesta sessão; o estado vive no .morph/ deste worktree.`;
|
|
160
|
+
if (lines.length) text += `\n${lines.join('\n')}`;
|
|
147
161
|
|
|
148
162
|
const envLine = buildEnvLine(dir);
|
|
149
163
|
if (envLine) text += `\n${envLine}`;
|
|
@@ -172,18 +186,8 @@ function buildActiveFeatureSummary(dir) {
|
|
|
172
186
|
const active = getActiveFeature(dir);
|
|
173
187
|
if (!active) return null;
|
|
174
188
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const pending = getPendingGates(active.name, dir);
|
|
178
|
-
|
|
179
|
-
let text = `MORPH-SPEC: feature ativa ${active.name} (fase ${phase})`;
|
|
180
|
-
if (progress) text += ` · cenários ${progress.done}/${progress.total}`;
|
|
181
|
-
if (pending.length) {
|
|
182
|
-
text += ` · gates pendentes: ${pending.join(', ')}`;
|
|
183
|
-
}
|
|
184
|
-
const nextLine = buildNextLine(dir, active.name);
|
|
185
|
-
if (nextLine) text += `\n${nextLine}`;
|
|
186
|
-
return text;
|
|
189
|
+
const { ref, lines } = featureBlock(dir, active.name, active.feature);
|
|
190
|
+
return [`MORPH-SPEC: em andamento — ${ref}`, ...lines].join('\n');
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
// Advisory: the claim is taken even on collision; it warns, never locks.
|
|
@@ -193,12 +197,12 @@ function claimBlock(dir, feature, sessionId) {
|
|
|
193
197
|
const other = foreignClaim(feature, { gitCommonDir, sessionId });
|
|
194
198
|
acquireClaim(feature, { gitCommonDir, sessionId, pid: process.pid, path: dir });
|
|
195
199
|
if (!other) return '';
|
|
196
|
-
return `\n⚠️ ATENÇÃO
|
|
197
|
-
+ `\n
|
|
198
|
-
+ '\n Duas sessões na mesma
|
|
199
|
-
+ '\n Confirme com
|
|
200
|
-
+
|
|
201
|
-
+
|
|
200
|
+
return `\n⚠️ ATENÇÃO: outra sessão está trabalhando agora nesta mesma funcionalidade (${feature})`
|
|
201
|
+
+ `\n processo ${other.pid}${other.path ? ` · ${other.path}` : ''} · visto há ${claimAge(other)}`
|
|
202
|
+
+ '\n Duas sessões na mesma funcionalidade apagam o trabalho uma da outra.'
|
|
203
|
+
+ '\n Confirme com quem está na outra sessão antes de continuar, principalmente antes de entregar, arquivar ou apagar.'
|
|
204
|
+
+ `\n${SESSION_MARK} claim vivo de outra sessão; confirme antes de \`finish\`, \`archive\` ou \`delete\`. `
|
|
205
|
+
+ `Se aquela sessão morreu: morph-spec claim ${feature} --release`;
|
|
202
206
|
} catch {
|
|
203
207
|
return '';
|
|
204
208
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
const OWNER_FORM = [
|
|
2
|
+
[/\baprovar\s+o\s+plano\s+d[eoa]\b/i, 'plan'],
|
|
3
|
+
[/\baprovar\s+as\s+telas\s+d[eoa]\b/i, 'uiux'],
|
|
4
|
+
[/\baprovar\s+a\s+entrega\s+d[eoa]\b/i, 'review'],
|
|
5
|
+
];
|
|
6
|
+
|
|
1
7
|
/** Explicit gate names win over words a feature slug may also carry ("plan", "design", "review"). */
|
|
2
8
|
export function gateFromQuestion(question) {
|
|
3
9
|
if (typeof question !== 'string') return null;
|
|
10
|
+
const head = question.split(/\r?\n/).find((l) => l.trim()) ?? '';
|
|
11
|
+
for (const [re, gate] of OWNER_FORM) if (re.test(head)) return gate;
|
|
4
12
|
if (/gate\s+uiux/i.test(question)) return 'uiux';
|
|
5
13
|
if (/gate\s+3\b/i.test(question)) return 'review';
|
|
6
14
|
if (/gate\s+(?:[12]\b|d[oe]\s+plano|plan\b)/i.test(question)) return 'plan';
|
|
@@ -5,21 +5,27 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { derivePhaseForFeature } from './state-reader.js';
|
|
7
7
|
import { implementProgress } from './report-progress.js';
|
|
8
|
+
import { gateQuestion, retrato, scenarioLabel, TESTS } from './owner-words.js';
|
|
8
9
|
|
|
9
10
|
export const FIX_ATTEMPTS = 3;
|
|
10
11
|
|
|
11
|
-
const step = (action, command, reason, extra = {}) => ({ action, command, reason, ...extra });
|
|
12
|
+
const step = (action, command, reason, say, extra = {}) => ({ action, command, reason, say, ...extra });
|
|
13
|
+
|
|
14
|
+
function firstAndMore(checks) {
|
|
15
|
+
const [first, ...rest] = checks;
|
|
16
|
+
return rest.length ? `${scenarioLabel(first)} e mais ${rest.length}` : scenarioLabel(first);
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
const HOW = {
|
|
14
20
|
plan: (f) => [
|
|
15
21
|
`Rode \`/morph-plan ${f}\`: escreva 2-plan/plan.md e rode \`morph-spec plan-check ${f}\` até zero erro.`,
|
|
16
22
|
],
|
|
17
|
-
gate: (f) => [
|
|
18
|
-
`Rode \`morph-spec gate-check ${f} plan\`; se pausar, AskUserQuestion "
|
|
23
|
+
gate: (f, q) => [
|
|
24
|
+
`Rode \`morph-spec gate-check ${f} plan\`; se pausar, AskUserQuestion "${q('plan')}".`,
|
|
19
25
|
],
|
|
20
|
-
design: (f) => [
|
|
26
|
+
design: (f, q) => [
|
|
21
27
|
`Rode \`/morph-uiux ${f}\` (opções em 1-design/opcoes/, protótipo e prints); depois \`morph-spec gate-check ${f} uiux\`.`,
|
|
22
|
-
`Se pausar, AskUserQuestion "
|
|
28
|
+
`Se pausar, AskUserQuestion "${q('uiux')}".`,
|
|
23
29
|
],
|
|
24
30
|
implement: (f) => [
|
|
25
31
|
'Implemente os Cn pendentes em sequência; ao fechar cada um, marque `feito` + evidência (teste ou arquivo:linha) '
|
|
@@ -56,7 +62,8 @@ const HOW = {
|
|
|
56
62
|
*/
|
|
57
63
|
export function decideNext(s) {
|
|
58
64
|
const n = decide(s);
|
|
59
|
-
const
|
|
65
|
+
const q = (gate) => gateQuestion(gate, s.feature, s.featureJson, s.progress?.summary);
|
|
66
|
+
const how = (HOW[n.action] ?? HOW.status)(s.feature, q);
|
|
60
67
|
const hotfix = s.workType === 'hotfix' && n.command.startsWith('/morph-hotfix');
|
|
61
68
|
return { ...n, how: hotfix ? ['Fluxo de hotfix: siga .claude/skills/morph-apply/references/hotfix.md.', ...how] : how };
|
|
62
69
|
}
|
|
@@ -69,30 +76,35 @@ function decide(s) {
|
|
|
69
76
|
switch (s.phase) {
|
|
70
77
|
case 'plan':
|
|
71
78
|
return s.progress
|
|
72
|
-
? step('gate', `morph-spec gate-check ${f} plan`, 'plano extraído: o gate do plano decide a pausa'
|
|
73
|
-
|
|
79
|
+
? step('gate', `morph-spec gate-check ${f} plan`, 'plano extraído: o gate do plano decide a pausa',
|
|
80
|
+
'a sessão confere o plano e, se houver risco, pede a sua aprovação.')
|
|
81
|
+
: step('plan', `/morph-plan ${f}`, 'sem checks.json: escreva o plan.md e rode plan-check até zero erro', 'a sessão escreve o plano.');
|
|
74
82
|
|
|
75
83
|
case 'uiux':
|
|
76
|
-
return step('design', `morph-spec gate-check ${f} uiux`, 'complete 1-design/ (morph-uiux) e passe o gate de uiux'
|
|
84
|
+
return step('design', `morph-spec gate-check ${f} uiux`, 'complete 1-design/ (morph-uiux) e passe o gate de uiux',
|
|
85
|
+
'a sessão desenha as telas para você aprovar.');
|
|
77
86
|
|
|
78
87
|
case 'implement': {
|
|
79
88
|
const p = s.progress;
|
|
80
|
-
if (!p) return step('plan', skill('morph-plan'), 'sem checks.json: plan.md curto e plan-check até zero erro');
|
|
81
|
-
const blocked = p.checks.filter((c) => c.status === 'bloqueado')
|
|
89
|
+
if (!p) return step('plan', skill('morph-plan'), 'sem checks.json: plan.md curto e plan-check até zero erro', 'a sessão escreve o plano.');
|
|
90
|
+
const blocked = p.checks.filter((c) => c.status === 'bloqueado');
|
|
82
91
|
if (blocked.length) {
|
|
83
92
|
return step('decide', 'AskUserQuestion (decisão do cenário)',
|
|
84
|
-
'Cn bloqueado no report.md: decida pelo plano/ADR ou pergunte, e siga implementando',
|
|
93
|
+
'Cn bloqueado no report.md: decida pelo plano/ADR ou pergunte, e siga implementando',
|
|
94
|
+
`decidir o ${firstAndMore(blocked)}, que está travado.`, { checks: blocked.map((c) => c.id) });
|
|
85
95
|
}
|
|
86
|
-
const pending = p.checks.filter((c) => c.status === 'pendente')
|
|
96
|
+
const pending = p.checks.filter((c) => c.status === 'pendente');
|
|
87
97
|
if (pending.length) {
|
|
88
|
-
return step('implement', skill('morph-apply'), 'implemente nesta sessão e marque cada Cn feito no report.md',
|
|
98
|
+
return step('implement', skill('morph-apply'), 'implemente nesta sessão e marque cada Cn feito no report.md',
|
|
99
|
+
`a sessão constrói o ${firstAndMore(pending)}.`, { checks: pending.map((c) => c.id) });
|
|
89
100
|
}
|
|
90
101
|
const fullFresh = s.verification?.status && s.verificationStale !== true;
|
|
91
102
|
const affectedFresh = s.affected?.status && s.affectedStale !== true;
|
|
92
103
|
const v = fullFresh ? s.verification : affectedFresh ? s.affected : null;
|
|
93
104
|
if (!v) {
|
|
94
105
|
const ran = s.verification?.status || s.affected?.status;
|
|
95
|
-
return step('verify', `morph-spec verify ${f} --affected`, ran ? 'a árvore andou desde o último verify' : 'todo Cn feito, sem verify'
|
|
106
|
+
return step('verify', `morph-spec verify ${f} --affected`, ran ? 'a árvore andou desde o último verify' : 'todo Cn feito, sem verify',
|
|
107
|
+
`rodar ${TESTS}.`);
|
|
96
108
|
}
|
|
97
109
|
if (v.status === 'fail') {
|
|
98
110
|
const streak = (fullFresh ? s.failStreak : s.affected.failStreak) ?? 0;
|
|
@@ -100,27 +112,44 @@ function decide(s) {
|
|
|
100
112
|
return step('escalate', 'AskUserQuestion (aceitar/continuar/parar)',
|
|
101
113
|
`${streak} verifies vermelhos seguidos, nunca uma tentativa a mais por conta própria. `
|
|
102
114
|
+ `aceitar → ${skill('morph-review')} (o verify vermelho pausa o gate: o humano assina lá); `
|
|
103
|
-
+ 'continuar → corrija e rode o verify de novo; parar → encerre aqui. Segue `escalate` até a árvore andar'
|
|
115
|
+
+ 'continuar → corrija e rode o verify de novo; parar → encerre aqui. Segue `escalate` até a árvore andar',
|
|
116
|
+
'esperar a sua decisão sobre os testes automáticos.',
|
|
117
|
+
{ ask: `${TESTS} falharam ${streak} vezes seguidas. Você decide: aceitar assim, tentar de novo ou parar.` });
|
|
104
118
|
}
|
|
105
119
|
return step('fix', `morph-spec verify ${f}${fullFresh ? '' : ' --affected'}`,
|
|
106
|
-
`corrija pelo feedback do verify e rode de novo (${FIX_ATTEMPTS - (streak % FIX_ATTEMPTS)} tentativa(s) antes de perguntar)
|
|
120
|
+
`corrija pelo feedback do verify e rode de novo (${FIX_ATTEMPTS - (streak % FIX_ATTEMPTS)} tentativa(s) antes de perguntar)`,
|
|
121
|
+
`a sessão corrige o que ${TESTS} apontaram (${FIX_ATTEMPTS - (streak % FIX_ATTEMPTS)} tentativa(s) antes de perguntar a você).`);
|
|
107
122
|
}
|
|
108
|
-
return step('review', skill('morph-review'), 'verify verde: Gate 3');
|
|
123
|
+
return step('review', skill('morph-review'), 'verify verde: Gate 3', 'a revisão independente roda sozinha.');
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
case 'review':
|
|
112
127
|
return approved('review')
|
|
113
|
-
? step('finish', `morph-spec finish ${f} --pr|--merge`, 'Gate 3 aprovado: arquiva e integra num passo')
|
|
114
|
-
: step('review', skill('morph-review'), 'relatórios do Gate 3 e gate-check review');
|
|
128
|
+
? step('finish', `morph-spec finish ${f} --pr|--merge`, 'Gate 3 aprovado: arquiva e integra num passo', 'a sessão abre o PR e entrega.')
|
|
129
|
+
: step('review', skill('morph-review'), 'relatórios do Gate 3 e gate-check review', 'a revisão independente roda sozinha.');
|
|
115
130
|
|
|
116
131
|
default:
|
|
117
|
-
return step('status', `morph-spec status ${f}`, `fase desconhecida: ${s.phase ?? '—'}
|
|
132
|
+
return step('status', `morph-spec status ${f}`, `fase desconhecida: ${s.phase ?? '—'}`, 'conferir o estado da feature.');
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
|
|
121
|
-
export
|
|
136
|
+
export const SESSION_MARK = 'para a sessão:';
|
|
137
|
+
|
|
138
|
+
export function sessionLine(n) {
|
|
122
139
|
const ids = n.checks?.length ? ` [${n.checks.join(', ')}]` : '';
|
|
123
|
-
return
|
|
140
|
+
return `${SESSION_MARK} ${n.action}${ids} → ${n.command} — ${n.reason}`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Owner line first; the second line is the exact instruction the session runs.
|
|
144
|
+
export function formatNext(n) {
|
|
145
|
+
return `Próximo: ${n.say}\n ${sessionLine(n)}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function retratoOf(signals, next) {
|
|
149
|
+
return retrato({
|
|
150
|
+
slug: signals.feature, feature: signals.featureJson, progress: signals.progress,
|
|
151
|
+
phase: signals.phase, next, hasDesign: signals.hasDesign,
|
|
152
|
+
});
|
|
124
153
|
}
|
|
125
154
|
|
|
126
155
|
/** Facts readable from `hooks/shared`; the CLI adds `verificationStale` (git) on top. Null without feature.json. */
|
|
@@ -139,9 +168,11 @@ export function collectNextSignals(featureName, cwd) {
|
|
|
139
168
|
return {
|
|
140
169
|
feature: featureName,
|
|
141
170
|
workType: feature.workType ?? 'feature',
|
|
171
|
+
featureJson: feature,
|
|
142
172
|
worktreePath: feature.worktree?.path ?? null,
|
|
143
173
|
phase,
|
|
144
174
|
progress: implementProgress(featureDir),
|
|
175
|
+
hasDesign: existsSync(join(featureDir, '1-design')),
|
|
145
176
|
gates: feature.approvals || feature.approvalGates || {},
|
|
146
177
|
verification: feature.verification ?? null,
|
|
147
178
|
failStreak: feature.verifications?.feature?.failStreak ?? 0,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
export const PHASE_NAME = {
|
|
2
|
+
plan: 'Plano', uiux: 'Telas', implement: 'Construção', review: 'Revisão', 'aguardando-merge': 'Esperando o merge do PR',
|
|
3
|
+
};
|
|
4
|
+
export const GATE_NAME = { plan: 'Aprovação do plano', uiux: 'Aprovação das telas', review: 'Revisão independente' };
|
|
5
|
+
export const GATE_ASK = { plan: 'aprovar o plano', uiux: 'aprovar as telas', review: 'aprovar a entrega' };
|
|
6
|
+
export const RUNG_SAY = {
|
|
7
|
+
refazer: 'dá trabalho para refazer',
|
|
8
|
+
desfazer: 'dá trabalho para desfazer',
|
|
9
|
+
migrar: 'mexe na estrutura do banco; reverter o código não desfaz',
|
|
10
|
+
'irreversível': 'não tem volta',
|
|
11
|
+
};
|
|
12
|
+
export const VERDICT_SAY = { SHIP: 'aprovou', FIX: 'pediu correção' };
|
|
13
|
+
export const ROLE_NAME = { verifier: 'Conferência das entregas', reviewer: 'Revisão do código', security: 'Revisão de segurança' };
|
|
14
|
+
export const STATUS_SAY = { feito: 'feito', pendente: 'falta', bloqueado: 'travado' };
|
|
15
|
+
export const TESTS = 'os testes automáticos';
|
|
16
|
+
export const WORK_NAME = { feature: 'Funcionalidade nova', bug: 'Correção de bug', chore: 'Manutenção', hotfix: 'Correção urgente' };
|
|
17
|
+
export const PROOF_SAY = {
|
|
18
|
+
teste: 'teste automático', e2e: 'teste do fluxo completo, como um usuário', eval: 'avaliação da resposta da IA',
|
|
19
|
+
manual: 'conferência manual', leitura: 'leitura do código',
|
|
20
|
+
};
|
|
21
|
+
export const RISK_SAY = {
|
|
22
|
+
regra: 'regra de negócio', dinheiro: 'dinheiro', contrato: 'integração com outro sistema',
|
|
23
|
+
'concorrência': 'duas coisas ao mesmo tempo', dado: 'integridade dos dados', 'regressão': 'bug que já aconteceu',
|
|
24
|
+
};
|
|
25
|
+
export const REUSE_SAY = { REUSAR: 'usa o que já existe', ESTENDER: 'amplia o que já existe', CRIAR: 'novo' };
|
|
26
|
+
export const CHECK_RESULT_SAY = { PROVADO: 'conferido', 'NÃO PROVADO': 'não conferido', FALHA: 'falhou na conferência' };
|
|
27
|
+
export const BLOCKER_SAY = {
|
|
28
|
+
check: 'cenário não cumprido', teste: 'teste faltando ou fraco', regressao: 'quebrou algo que funcionava',
|
|
29
|
+
seguranca: 'falha de segurança', escopo: 'fora do combinado', arquitetura: 'desenho do código',
|
|
30
|
+
performance: 'lentidão', irreversivel: 'passo sem volta',
|
|
31
|
+
};
|
|
32
|
+
export const VERIFY_STEP_SAY = {
|
|
33
|
+
build: 'compilação', tests: 'testes', validators: 'regras do projeto', e2e: 'teste do fluxo completo', evals: 'avaliação da IA',
|
|
34
|
+
};
|
|
35
|
+
export const RESULT_SAY = { pass: 'passou', fail: 'falhou', skip: 'não rodou' };
|
|
36
|
+
|
|
37
|
+
export function approvedBySay(by) {
|
|
38
|
+
if (by === 'auto') return 'aprovada sozinha, sem sinal de risco';
|
|
39
|
+
if (!by || by === 'manual') return 'aprovada por você';
|
|
40
|
+
return `aprovada por ${by}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const MAX_TITLE_WORDS = 10;
|
|
44
|
+
|
|
45
|
+
function clip(text) {
|
|
46
|
+
const words = String(text ?? '').trim().replace(/[.;:,]+$/, '').split(/\s+/).filter(Boolean);
|
|
47
|
+
if (!words.length) return '';
|
|
48
|
+
const out = words.slice(0, MAX_TITLE_WORDS).join(' ');
|
|
49
|
+
return words.length > MAX_TITLE_WORDS ? `${out}…` : out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function titleFromText(text) {
|
|
53
|
+
const s = String(text ?? '');
|
|
54
|
+
const then = /\bent[aã]o,?\s+(.+)/i.exec(s);
|
|
55
|
+
const clause = (then ? then[1] : s).split(/[.;]\s/)[0];
|
|
56
|
+
const t = clip(clause);
|
|
57
|
+
return t ? t[0].toUpperCase() + t.slice(1) : '';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const scenarioTitle = (c) => (c?.title ? String(c.title).trim() : titleFromText(c?.text));
|
|
61
|
+
|
|
62
|
+
export function scenarioLabel(c) {
|
|
63
|
+
const n = String(c?.id ?? '').replace(/^C/i, '');
|
|
64
|
+
const title = scenarioTitle(c);
|
|
65
|
+
return title ? `Cenário ${n}: ${title}` : `Cenário ${n}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function labelFor(checks, id) {
|
|
69
|
+
return scenarioLabel((checks ?? []).find((c) => c.id === id) ?? { id });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function featureName(slug, feature, summary) {
|
|
73
|
+
if (summary?.name) return summary.name;
|
|
74
|
+
const first = String(feature?.description ?? '').split(/\r?\n/).map((l) => l.replace(/^#+\s*/, '').trim()).find(Boolean);
|
|
75
|
+
return first ? clip(first) : slug;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** How a feature is named where a hook or a gate answer must still find the slug. */
|
|
79
|
+
export const featureRef = (slug, feature, summary) => {
|
|
80
|
+
const name = featureName(slug, feature, summary);
|
|
81
|
+
return name === slug ? slug : `${name} (${slug})`;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export function gateQuestion(gate, slug, feature, summary) {
|
|
85
|
+
const what = { plan: 'o plano', uiux: 'as telas', review: 'a entrega' }[gate] ?? gate;
|
|
86
|
+
return `Aprovar ${what} de ${featureRef(slug, feature, summary)}?`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const LIST_MAX = 3;
|
|
90
|
+
|
|
91
|
+
function stationsLine(phase, hasDesign, reviewApproved) {
|
|
92
|
+
const ids = ['plan', ...(hasDesign || phase === 'uiux' ? ['uiux'] : []), 'implement', 'review'];
|
|
93
|
+
const at = phase === 'aguardando-merge' || reviewApproved ? ids.length : ids.indexOf(phase);
|
|
94
|
+
if (at < 0) return `Passo: ${PHASE_NAME[phase] ?? phase}`;
|
|
95
|
+
const marks = ids.map((id, i) => `${PHASE_NAME[id]}${i < at ? ' ✓' : i === at ? ' ◀' : ''}`).join(' · ');
|
|
96
|
+
const now = at >= ids.length ? (phase === 'aguardando-merge' ? PHASE_NAME[phase] : 'Entrega') : PHASE_NAME[ids[at]];
|
|
97
|
+
return `Passo: ${now} (${marks})`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function scenarioLines(progress, phase) {
|
|
101
|
+
if (!progress) return ['Cenários: ainda não definidos (o plano está sendo escrito).'];
|
|
102
|
+
if (phase === 'plan') return [`Cenários: ${progress.total} no plano, nenhum construído ainda.`];
|
|
103
|
+
const open = progress.checks.filter((c) => c.status === 'pendente');
|
|
104
|
+
const head = `Cenários: ${progress.done} de ${progress.total} feitos.`;
|
|
105
|
+
if (!open.length) return [head];
|
|
106
|
+
const lines = [`${head} Faltam:`, ...open.slice(0, LIST_MAX).map((c) => ` ${scenarioLabel(c)}`)];
|
|
107
|
+
if (open.length > LIST_MAX) lines.push(` +${open.length - LIST_MAX}`);
|
|
108
|
+
return lines;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function waitingOnOwner({ feature, progress, next, phase }) {
|
|
112
|
+
const out = [];
|
|
113
|
+
const gates = feature?.approvalGates ?? feature?.approvals ?? {};
|
|
114
|
+
for (const [gate, d] of Object.entries(feature?.gateDecisions ?? {})) {
|
|
115
|
+
// A decision taken in an earlier phase is stale until gate-check runs again in this one.
|
|
116
|
+
if (gate !== phase || gates[gate]?.approved || !d?.pause || d.resolver === 'session') continue;
|
|
117
|
+
out.push(`${GATE_ASK[gate] ?? gate}. ${d.reason ?? ''}`.trim());
|
|
118
|
+
}
|
|
119
|
+
for (const c of progress?.checks ?? []) {
|
|
120
|
+
if (c.status !== 'bloqueado') continue;
|
|
121
|
+
out.push(c.question ? `responder o ${scenarioLabel(c)}. ${c.question}` : `decidir o ${scenarioLabel(c)}.`);
|
|
122
|
+
}
|
|
123
|
+
if (next?.ask) out.push(next.ask);
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The glance view: what it delivers, which step, how many scenarios, what is stuck, what waits on the owner.
|
|
129
|
+
* @param {{ slug: string, feature: object, progress: object|null, phase: string, next?: object|null, hasDesign?: boolean }} s
|
|
130
|
+
*/
|
|
131
|
+
export function retrato({ slug, feature, progress, phase, next = null, hasDesign = false }) {
|
|
132
|
+
const summary = progress?.summary ?? null;
|
|
133
|
+
const lines = [featureName(slug, feature, summary)];
|
|
134
|
+
if (summary?.after) lines.push(`Entrega: ${summary.after}`);
|
|
135
|
+
lines.push(stationsLine(phase, hasDesign, feature?.approvalGates?.review?.approved === true));
|
|
136
|
+
lines.push(...scenarioLines(progress, phase));
|
|
137
|
+
const blocked = (progress?.checks ?? []).filter((c) => c.status === 'bloqueado').map(scenarioLabel);
|
|
138
|
+
const red = feature?.verification?.status === 'fail' && phase === 'implement';
|
|
139
|
+
const stuck = [...blocked, ...(red ? [`${TESTS} estão falhando`] : [])];
|
|
140
|
+
lines.push(`Travado: ${stuck.length ? stuck.join('; ') : 'nada'}.`.replace(/\.\.$/, '.'));
|
|
141
|
+
const wait = waitingOnOwner({ feature, progress, next, phase });
|
|
142
|
+
if (wait.length) lines.push(`Espera você: ${wait[0]}`, ...wait.slice(1).map((w) => ` ${w}`));
|
|
143
|
+
else lines.push('Espera você: nada agora.');
|
|
144
|
+
if (next?.say) lines.push(`Próximo: ${next.say}`);
|
|
145
|
+
return lines;
|
|
146
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { featureRef, scenarioTitle } from './owner-words.js';
|
|
3
4
|
|
|
4
5
|
/** `PARCIAL` on the report's first non-blank line, tolerating heading/bold/quote typography. */
|
|
5
6
|
export const PARTIAL_MARKER = /^[\s#>*_]*PARCIAL\b/;
|
|
@@ -14,7 +15,15 @@ export function reportPath(featureDir) {
|
|
|
14
15
|
return join(featureDir, '3-implement', 'report.md');
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const ROW = /^\|\s*(C\d+)\s
|
|
18
|
+
const ROW = /^\|\s*(C\d+)\s*\|(.*)$/;
|
|
19
|
+
const NOTE = /^\s*[-*]\s+(?:.*?[—–-]\s+)?(C\d+)\s*:\s*(.+?)\s*$/;
|
|
20
|
+
|
|
21
|
+
// Two shapes: `| Cn | status | evidência |` and `| Cn | cenário | status | evidência |`.
|
|
22
|
+
function rowCells(rest) {
|
|
23
|
+
const cells = rest.replace(/\|\s*$/, '').split('|').map((c) => c.trim());
|
|
24
|
+
const at = STATUSES.includes(cells[0]?.toLowerCase()) || !STATUSES.includes(cells[1]?.toLowerCase()) ? 0 : 1;
|
|
25
|
+
return { status: cells[at]?.toLowerCase() ?? '', evidence: cells.slice(at + 1).join(' | ').trim() };
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
/** Status per Cn from the report's table; an unknown status reads as `pendente`. */
|
|
20
29
|
export function parseReport(text) {
|
|
@@ -22,12 +31,24 @@ export function parseReport(text) {
|
|
|
22
31
|
for (const line of String(text ?? '').split(/\r?\n/)) {
|
|
23
32
|
const m = ROW.exec(line);
|
|
24
33
|
if (!m) continue;
|
|
25
|
-
const status = m[2]
|
|
26
|
-
rows.set(m[1], { status: STATUSES.includes(status) ? status : 'pendente', evidence
|
|
34
|
+
const { status, evidence } = rowCells(m[2]);
|
|
35
|
+
rows.set(m[1], { status: STATUSES.includes(status) ? status : 'pendente', evidence });
|
|
27
36
|
}
|
|
28
37
|
return rows;
|
|
29
38
|
}
|
|
30
39
|
|
|
40
|
+
/** The last note per Cn under `## Notas`: the question a blocked scenario waits on. */
|
|
41
|
+
export function parseNotes(text) {
|
|
42
|
+
const notes = new Map();
|
|
43
|
+
let inNotes = false;
|
|
44
|
+
for (const line of String(text ?? '').split(/\r?\n/)) {
|
|
45
|
+
if (/^##\s/.test(line)) { inNotes = /^##\s+notas\b/i.test(line); continue; }
|
|
46
|
+
const m = inNotes && NOTE.exec(line);
|
|
47
|
+
if (m) notes.set(m[1], m[2]);
|
|
48
|
+
}
|
|
49
|
+
return notes;
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
// Features started before 10.0 have per-slice reports and no report.md: a Cn counts as done when a
|
|
32
53
|
// slice that covers it has a final report, so an in-flight feature keeps moving after the upgrade.
|
|
33
54
|
function legacyRows(checks, readSliceReport) {
|
|
@@ -44,8 +65,35 @@ function legacyRows(checks, readSliceReport) {
|
|
|
44
65
|
return rows;
|
|
45
66
|
}
|
|
46
67
|
|
|
68
|
+
const SCENARIO_LINE = /^[-*]\s+\*\*(C\d+)\*\*/;
|
|
69
|
+
const TITLE_LINE = /^\s*t[ií]tulo\s*:\s*(.+?)\s*$/i;
|
|
70
|
+
const SUMMARY_LINE = /^\s*[-*]\s+\**\s*(nome|depois)\s*\**\s*:\s*\**\s*(.+?)\s*$/i;
|
|
71
|
+
|
|
72
|
+
// A checks.json extracted before titles existed: the names come from its plan.md, read only.
|
|
73
|
+
export function planNames(planText) {
|
|
74
|
+
const titles = new Map();
|
|
75
|
+
const summary = { name: null, after: null };
|
|
76
|
+
let current = null;
|
|
77
|
+
for (const line of String(planText ?? '').split(/\r?\n/)) {
|
|
78
|
+
const scenario = SCENARIO_LINE.exec(line);
|
|
79
|
+
if (scenario) { current = scenario[1]; continue; }
|
|
80
|
+
const title = current && TITLE_LINE.exec(line);
|
|
81
|
+
if (title && !titles.has(current)) { titles.set(current, title[1]); continue; }
|
|
82
|
+
const sum = SUMMARY_LINE.exec(line);
|
|
83
|
+
if (sum) {
|
|
84
|
+
const key = sum[1].toLowerCase() === 'nome' ? 'name' : 'after';
|
|
85
|
+
summary[key] ??= sum[2];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return { titles, summary: summary.name || summary.after ? summary : null };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function needsPlan(checks) {
|
|
92
|
+
return !checks?.summary || !(checks.checks ?? []).every((c) => c?.title);
|
|
93
|
+
}
|
|
94
|
+
|
|
47
95
|
/** @returns {{ total, done, blocked, pending, checks: Array<{id, status, evidence}>, legacy: boolean } | null} */
|
|
48
|
-
export function implementProgressFrom(checksText, reportText, readSliceReport = () => null) {
|
|
96
|
+
export function implementProgressFrom(checksText, reportText, readSliceReport = () => null, readPlan = () => null) {
|
|
49
97
|
let checks;
|
|
50
98
|
try {
|
|
51
99
|
checks = JSON.parse(checksText ?? '');
|
|
@@ -55,11 +103,22 @@ export function implementProgressFrom(checksText, reportText, readSliceReport =
|
|
|
55
103
|
if (!Array.isArray(checks?.checks)) return null;
|
|
56
104
|
const legacy = reportText == null && Array.isArray(checks.slices);
|
|
57
105
|
const rows = legacy ? legacyRows(checks, readSliceReport) : parseReport(reportText);
|
|
106
|
+
const notes = legacy ? new Map() : parseNotes(reportText);
|
|
107
|
+
const plan = needsPlan(checks) ? planNames(readPlan()) : null;
|
|
58
108
|
const out = checks.checks
|
|
59
109
|
.filter((c) => c && typeof c.id === 'string')
|
|
60
|
-
.map((c) =>
|
|
110
|
+
.map((c) => {
|
|
111
|
+
const status = rows.get(c.id)?.status ?? 'pendente';
|
|
112
|
+
return {
|
|
113
|
+
id: c.id, title: scenarioTitle(c.title ? c : { ...c, title: plan?.titles.get(c.id) }), status, evidence: rows.get(c.id)?.evidence ?? '',
|
|
114
|
+
...(status === 'bloqueado' && notes.has(c.id) ? { question: notes.get(c.id) } : {}),
|
|
115
|
+
};
|
|
116
|
+
});
|
|
61
117
|
const count = (status) => out.filter((c) => c.status === status).length;
|
|
62
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
total: out.length, done: count('feito'), blocked: count('bloqueado'), pending: count('pendente'), checks: out, legacy,
|
|
120
|
+
summary: checks.summary ?? plan?.summary ?? null,
|
|
121
|
+
};
|
|
63
122
|
}
|
|
64
123
|
|
|
65
124
|
function readOrNull(path) {
|
|
@@ -70,17 +129,32 @@ function readOrNull(path) {
|
|
|
70
129
|
}
|
|
71
130
|
}
|
|
72
131
|
|
|
132
|
+
const planPath = (featureDir) => join(featureDir, '2-plan', 'plan.md');
|
|
133
|
+
|
|
134
|
+
export function featureSummary(featureDir) {
|
|
135
|
+
let checks = null;
|
|
136
|
+
try { checks = JSON.parse(readOrNull(checksPath(featureDir)) ?? 'null'); } catch { /* the plan still names it */ }
|
|
137
|
+
return checks?.summary ?? planNames(readOrNull(planPath(featureDir))).summary;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** `Nome (slug)` with the plan's name, from the project root that holds `.morph/`. */
|
|
141
|
+
export function ownerRef(root, slug, feature) {
|
|
142
|
+
return featureRef(slug, feature, featureSummary(join(root, '.morph', 'features', slug)));
|
|
143
|
+
}
|
|
144
|
+
|
|
73
145
|
export function implementProgress(featureDir) {
|
|
74
146
|
const sliceDir = join(featureDir, '3-implement', 'reports');
|
|
75
147
|
return implementProgressFrom(
|
|
76
148
|
readOrNull(checksPath(featureDir)),
|
|
77
149
|
readOrNull(reportPath(featureDir)),
|
|
78
150
|
(id) => (existsSync(sliceDir) ? readOrNull(join(sliceDir, `${id}.md`)) : null),
|
|
151
|
+
() => readOrNull(planPath(featureDir)),
|
|
79
152
|
);
|
|
80
153
|
}
|
|
81
154
|
|
|
82
|
-
/** The report template body for a feature's checks: every Cn starts `pendente`. */
|
|
83
|
-
export function reportSkeleton(featureName,
|
|
84
|
-
const rows =
|
|
85
|
-
|
|
155
|
+
/** The report template body for a feature's checks (ids or `{ id, title }`): every Cn starts `pendente`. */
|
|
156
|
+
export function reportSkeleton(featureName, checks) {
|
|
157
|
+
const rows = checks.map((c) => (typeof c === 'string' ? { id: c } : c))
|
|
158
|
+
.map((c) => `| ${c.id} | ${scenarioTitle(c).replaceAll('|', '/')} | pendente | |`).join('\n');
|
|
159
|
+
return `# ${featureName}\n\n| Cn | cenário | status | evidência |\n|----|---------|--------|-----------|\n${rows}\n\n## Notas\n\n`;
|
|
86
160
|
}
|