@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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +3 -1
  3. package/claude-plugin.json +1 -1
  4. package/docs/CHEATSHEET.md +1 -1
  5. package/docs/QUICKSTART.md +1 -1
  6. package/framework/CLAUDE.md +4 -3
  7. package/framework/MORPH.md +14 -12
  8. package/framework/commands/morph-review.md +1 -1
  9. package/framework/commands/morph-status.md +2 -6
  10. package/framework/docs/CLI.md +22 -7
  11. package/framework/hooks/claude-code/core/enforce-phase-writes.js +12 -11
  12. package/framework/hooks/claude-code/core/gate-guard.js +19 -14
  13. package/framework/hooks/claude-code/core/heavy-gate.js +4 -1
  14. package/framework/hooks/claude-code/core/loop-detect.js +8 -7
  15. package/framework/hooks/claude-code/core/masked-exit.js +5 -2
  16. package/framework/hooks/claude-code/core/protect-spec-files.js +13 -11
  17. package/framework/hooks/claude-code/core/state-sync.js +20 -12
  18. package/framework/hooks/claude-code/core/validate-completion.js +6 -5
  19. package/framework/hooks/claude-code/core/worktree-context.js +47 -43
  20. package/framework/hooks/shared/e2e-check.js +49 -9
  21. package/framework/hooks/shared/gate-question.js +8 -0
  22. package/framework/hooks/shared/host-services.js +7 -3
  23. package/framework/hooks/shared/next-step.js +54 -23
  24. package/framework/hooks/shared/owner-words.js +146 -0
  25. package/framework/hooks/shared/report-progress.js +84 -10
  26. package/framework/phases.json +7 -7
  27. package/framework/rules/implement-report.md +8 -7
  28. package/framework/rules/plan-grammar.md +4 -1
  29. package/framework/schemas/feature.schema.json +3 -2
  30. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  31. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  32. package/framework/skills/core/morph-apply/SKILL.md +6 -5
  33. package/framework/skills/core/morph-apply/references/hotfix.md +6 -2
  34. package/framework/skills/core/morph-apply/references/review.md +9 -5
  35. package/framework/skills/core/morph-plan/SKILL.md +5 -5
  36. package/framework/skills/core/morph-plan/references/interview.md +1 -1
  37. package/framework/skills/core/morph-uiux/SKILL.md +10 -6
  38. package/framework/templates/docs/plan.md +1 -1
  39. package/package.json +1 -1
  40. package/src/commands/e2e/e2e.js +37 -29
  41. package/src/commands/project/status.js +28 -184
  42. package/src/commands/state/advance.js +44 -20
  43. package/src/commands/state/approve.js +70 -59
  44. package/src/commands/state/archive.js +20 -15
  45. package/src/commands/state/auto-approval.js +25 -23
  46. package/src/commands/state/create.js +35 -32
  47. package/src/commands/state/finish.js +179 -58
  48. package/src/commands/state/gate-check.js +43 -31
  49. package/src/commands/state/gate-decision.js +18 -14
  50. package/src/commands/state/list.js +23 -14
  51. package/src/commands/state/next.js +4 -5
  52. package/src/commands/state/report-check.js +47 -23
  53. package/src/commands/validation/plan-check.js +30 -14
  54. package/src/commands/validation/verify.js +39 -18
  55. package/src/dashboard/app/components/ActivityFeed.jsx +8 -8
  56. package/src/dashboard/app/components/CommandPalette.jsx +1 -1
  57. package/src/dashboard/app/components/GatePauses.jsx +8 -8
  58. package/src/dashboard/app/components/PhaseRail.jsx +6 -6
  59. package/src/dashboard/app/components/SessionMap.jsx +7 -7
  60. package/src/dashboard/app/lib/format.js +6 -2
  61. package/src/dashboard/app/lib/phases.js +48 -16
  62. package/src/dashboard/app/pages/FeatureDetail.jsx +87 -59
  63. package/src/dashboard/app/pages/Features.jsx +18 -18
  64. package/src/dashboard/app/pages/Guide.jsx +4 -4
  65. package/src/dashboard/app/pages/PhasePipeline.jsx +7 -7
  66. package/src/dashboard/app/pages/Portfolio.jsx +3 -3
  67. package/src/dashboard/scanner/activity-scanner.js +20 -6
  68. package/src/dashboard/scanner/features-scanner.js +43 -8
  69. package/src/dashboard/scanner/project-api.js +2 -0
  70. package/src/dashboard/vite.config.js +2 -0
  71. package/src/lib/next-step.js +3 -2
  72. package/src/lib/plan/checks.js +30 -15
  73. package/src/lib/plan/critique.js +6 -4
  74. package/src/lib/recap/recap.js +46 -20
  75. package/src/lib/risk-detector.js +260 -98
  76. package/src/lib/view/feature-html.js +19 -25
  77. package/src/lib/view/feature-view.js +6 -6
  78. package/src/utils/audience.js +27 -0
  79. package/src/utils/refusal-line.js +2 -2
@@ -4,7 +4,7 @@ description: Conduz a fase de UI/UX de uma feature com plano aprovado — render
4
4
  version: core
5
5
  when_to_use: Use quando o ramo de design for tomado (morph-spec advance {feature} --design), antes de /morph-apply
6
6
  user-invocable: true
7
- cliVersion: "10.11.0"
7
+ cliVersion: "10.12.0"
8
8
  ---
9
9
 
10
10
  # morph-uiux
@@ -15,7 +15,7 @@ A régua de sistema e de estética chega sozinha: a rule `ui-design` carrega qua
15
15
 
16
16
  ## 1. Insumos
17
17
 
18
- - `2-plan/plan.md` — problema e cenários de tela, referidos pelo id (`C3`). Esta fase **nunca** edita `plan.md` nem `checks.json`.
18
+ - `2-plan/plan.md` — problema e cenários de tela, referidos pelo id (`C3`); ao dono, pelo nome (`Cenário 3: <título>`). Esta fase **nunca** edita `plan.md` nem `checks.json`.
19
19
  - `.morph/context/design-system.md` — o design system vivo; toda decisão de token ou componente parte dele e dos tokens reais do CSS do projeto.
20
20
  - `config.json` → `project.stack` decide a tecnologia (`nextjs` → Tailwind + shadcn + Motion). Nunca suponha Next.js.
21
21
  - O catálogo, antes de desenhar: o que o projeto já tem (`npx shadcn@latest info --json`, na pasta do `components.json`) e o que os registries oferecem para cada tela (`npx shadcn@latest search @shadcn <os do components.json> -q "<termo>"`, ou `search_items_in_registries` do MCP `shadcn`; o `@shadcn` embutido só entra na busca se nomeado). Uma direção parte do bloco que existe; o standard `frontend-nextjs-components` ("Catalog First") diz quais registries valem. Sem shadcn no projeto, a busca é no código e no design system.
@@ -74,15 +74,19 @@ Cada ocorrência vai para o `Cn` do plano que já a cobre, para uma exclusão re
74
74
 
75
75
  Apresente aberto, não descrito: abra cada protótipo no navegador e cite a direção de cada tela em uma frase. Divergência de design system vista aqui: `--signals '{"designSystemDivergence":true}'`.
76
76
 
77
- Pausa com `resolver: "session"` não é pergunta: faça o que a `reason` diz e rode o `gate-check` de novo. Checklist ou protótipo incompleto → complete-o. Sem como completar (sem navegador para os prints): `morph-spec gate-decision {feature} uiux --pause true --reason "<o que falta>"`, pausa manual, que é do usuário.
77
+ Pausa com `resolver: "session"` não é pergunta: faça o que o `todo` diz e rode o `gate-check` de novo. Checklist ou protótipo incompleto → complete-o. Sem como completar (sem navegador para os prints): `morph-spec gate-decision {feature} uiux --pause true --reason "<o que falta>"`, pausa manual, que é do usuário.
78
78
 
79
- `resolver === "human"` → `AskUserQuestion`, header "Gate uiux":
79
+ `resolver === "human"` → `AskUserQuestion`, header "Telas". A primeira linha leva o nome (`- Nome:` do `## Resumo`) e o slug, que é o que o `state-sync` lê; as outras, uma frase curta cada:
80
80
 
81
81
  ```
82
- question: "Gate uiux — Design de {feature} aprovado?{ reason ? ' Sinal: ' + reason : '' }"
82
+ question: "Aprovar as telas de {nome} ({feature})?
83
+ Você aprova: <cada tela e a direção escolhida, numa frase>
84
+ Se aprovar: as telas travam e a construção segue por elas
85
+ Provado: <checklist de tela completo, prints em computador e celular>
86
+ Não provado: <a reason do gate-check, ou o que só a construção mostra; ou nada>"
83
87
  options: "aprovado, prosseguir" | "preciso ajustar" | "cancelar feature"
84
88
  ```
85
89
 
86
90
  O hook `state-sync` grava a aprovação pela feature nomeada. Headless: `morph-spec advance {feature} --approver <quem>` — sem `--approver`, um terminal não interativo grava `approvedBy: "auto"` num gate que um humano devia assinar. `pause === false` → uma linha e `morph-spec advance {feature}`.
87
91
 
88
- Aprovado, `1-design/` trava: retrabalho passa pelo gate de novo. Diga que `/morph-apply {feature}` está pronto.
92
+ Aprovado, `1-design/` trava: retrabalho passa pelo gate de novo. Mostre ao dono o bloco que o `morph-spec next {feature}` imprime, tal qual, e diga que `/morph-apply {feature}` está pronto.
@@ -43,7 +43,7 @@ Resultado buscado: <o estado depois: o que muda, para quem, como se percebe.>
43
43
  `prova: teste` exige `risco:` regra | dinheiro | contrato | concorrência | dado | regressão; sem risco, `leitura`.
44
44
  `degrau:` migrar | irreversível quando um revert não desfaz (toda migration é migrar); sem a linha, refazer.
45
45
  Cenário que fala de arquivo, grep ou texto exige a linha "> Por que artefato:" logo abaixo.
46
- `título:` é o nome do cenário na página: até dez palavras, linguagem de quem usa, sem identificador de código. -->
46
+ `título:` é o nome do cenário para o dono (página, next, gate, report): até dez palavras, linguagem de quem usa, sem identificador de código. -->
47
47
 
48
48
  - **C1** — Dado <estado>, quando <ação>, então <resultado observável>.
49
49
  título: <o que passa a funcionar>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymorphism-tech/morph-spec",
3
- "version": "10.11.0",
3
+ "version": "10.12.0",
4
4
  "description": "MORPH-SPEC: NLH (Natural Language Harness) for spec-driven development with Claude Code",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -32,6 +32,7 @@ import { createHeavyGate, HeavyBusyError } from '../../lib/heavy/gate.js';
32
32
  import { afterHeavyRun } from '../../lib/heavy/cleanup.js';
33
33
  import { memoryBusyHint } from '../../lib/heavy/live-stacks.js';
34
34
  import { readHeavyConfig } from '../../../framework/hooks/shared/heavy-config.js';
35
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
35
36
 
36
37
  const EXIT_USAGE = 2;
37
38
  const EXIT_BUSY = 3;
@@ -112,7 +113,7 @@ export async function e2eUpCommand(featureName, options = {}) {
112
113
 
113
114
  const exec = options._exec ?? defaultExec;
114
115
  if (ctx.composeFile && !isDockerAvailable(ctx.cwd, exec)) {
115
- console.error(chalk.red('\n❌ Docker is not available in this environment.\n'));
116
+ console.error(chalk.red('\n❌ O Docker não está disponível nesta máquina, então o ambiente de teste não sobe.\n'));
116
117
  process.exit(EXIT_USAGE);
117
118
  }
118
119
 
@@ -133,7 +134,8 @@ export async function e2eUpCommand(featureName, options = {}) {
133
134
  if (options.json) {
134
135
  console.log(JSON.stringify({ status: 'busy', feature: featureName, busy: { reason: err.reason, waitedMs: err.waitedMs } }, null, 2));
135
136
  }
136
- console.error(chalk.yellow(`\n⏳ e2e up não rodou: ${err.message}. Não é vermelho — a fila já esperou o prazo dela: não repita em laço — siga sem esta rodada e avise o usuário (\`morph-spec heavy status\`).\n`));
137
+ console.error(chalk.yellow(`\n⏳ O ambiente de teste não subiu: ${err.message}. Isso não é falha: a máquina estava ocupada e a fila já esperou o prazo dela.`));
138
+ console.error(chalk.gray(` ${SESSION_MARK} não repita em laço; siga sem esta rodada e avise o usuário (\`morph-spec heavy status\`).\n`));
137
139
  const hint = memoryBusyHint(err, ctx.cwd);
138
140
  if (hint) console.error(chalk.yellow(`${hint}\n`));
139
141
  process.exit(EXIT_BUSY);
@@ -171,13 +173,13 @@ export async function e2eUpCommand(featureName, options = {}) {
171
173
  } else {
172
174
  const how = !ctx.composeFile
173
175
  ? chalk.gray(`(${result.stack.reason})`)
174
- : result.stack.reused ? chalk.gray(`(${result.stack.reason})`) : chalk.gray('(built)');
175
- console.log(chalk.green(`\n✓ Stack up — ${ctx.projectName} ${how}`));
176
- console.log(chalk.gray(` tree: ${ctx.tree}`));
176
+ : result.stack.reused ? chalk.gray(`(${result.stack.reason})`) : chalk.gray('(montado agora)');
177
+ console.log(chalk.green(`\n✓ Ambiente de teste no ar — ${ctx.projectName} ${how}`));
178
+ console.log(chalk.gray(` Pasta: ${ctx.tree}`));
177
179
  for (const s of hostServices.services) {
178
- console.log(chalk.gray(` host: ${s.name} pid ${s.pid} (${s.reused ? 'reused' : 'started'}) — log ${s.log}`));
180
+ console.log(chalk.gray(` Serviço ${s.name}: pid ${s.pid} (${s.reused ? 'já estava rodando' : 'iniciado agora'}) — log ${s.log}`));
179
181
  }
180
- if (auth.reason) console.log(chalk.gray(` auth: ${auth.reason}`));
182
+ if (auth.reason) console.log(chalk.gray(` Login de teste: ${auth.reason}`));
181
183
  for (const w of result.warnings) console.log(chalk.yellow(`⚠️ ${w}`));
182
184
  console.log('');
183
185
  }
@@ -213,6 +215,9 @@ export async function e2eStatusCommand(featureName, options = {}) {
213
215
  const stamp = computeSourceStamp(ctx.cwd, exec);
214
216
  const previous = ctx.gitCommonDir ? readStamp(ctx.gitCommonDir, ctx.projectName) : null;
215
217
  const fresh = Boolean(stamp && previous?.stamp === stamp);
218
+ // Live processes say nothing about the schema: a reset that died after wiping the data left this mark.
219
+ const dataBroken = Boolean(previous?.dataBroken);
220
+ const healthy = status.healthy && !dataBroken;
216
221
 
217
222
  const spec = resolveSpecCommand(ctx.cwd, ctx.config, ctx.config?.project?.frontendPath);
218
223
 
@@ -222,7 +227,8 @@ export async function e2eStatusCommand(featureName, options = {}) {
222
227
  tree: ctx.tree,
223
228
  composeFile: ctx.composeFile,
224
229
  up: status.up,
225
- healthy: status.healthy,
230
+ healthy,
231
+ ...(dataBroken ? { dataBroken: true } : {}),
226
232
  fresh,
227
233
  baseUrl: resolveBaseUrl(ctx.env),
228
234
  builtAt: previous?.builtAt ?? null,
@@ -239,28 +245,30 @@ export async function e2eStatusCommand(featureName, options = {}) {
239
245
  console.log(JSON.stringify(payload, null, 2));
240
246
  } else {
241
247
  console.log('');
242
- console.log(chalk.bold(`E2E stack — ${ctx.projectName}`));
243
- console.log(chalk.gray(`tree: ${ctx.tree}`));
244
- console.log(chalk.gray(`compose: ${ctx.composeFile ?? 'none (host services only)'}`));
245
- console.log(chalk.gray(`url: ${payload.baseUrl}`));
248
+ console.log(chalk.bold(`Ambiente de teste — ${ctx.projectName}`));
249
+ console.log(chalk.gray(`Pasta: ${ctx.tree}`));
250
+ console.log(chalk.gray(`Compose: ${ctx.composeFile ?? 'nenhum (só serviços locais)'}`));
251
+ console.log(chalk.gray(`Endereço: ${payload.baseUrl}`));
246
252
  console.log('');
247
- console.log(` up ${status.up ? chalk.green('yes') : chalk.gray('no')}`);
248
- console.log(` healthy ${status.healthy ? chalk.green('yes') : chalk.gray('no')}`);
253
+ console.log(` No ar ${status.up ? chalk.green('sim') : chalk.gray('não')}`);
254
+ console.log(` Funcionando ${healthy ? chalk.green('sim') : dataBroken
255
+ ? chalk.red(`não — o último reset deixou os dados inutilizáveis: rode \`morph-spec e2e up ${featureName} --fresh\``)
256
+ : chalk.gray('não')}`);
249
257
  console.log(
250
- ` fresh ${fresh ? chalk.green('yes') : chalk.yellow('no — source changed since build')}`
258
+ ` Código em dia ${fresh ? chalk.green('sim') : chalk.yellow('não — o código mudou depois que o ambiente subiu')}`
251
259
  );
252
- console.log(` specs ${spec ? payload.specs : chalk.gray('none (smoke only)')}`);
260
+ console.log(` Testes do fluxo ${spec ? payload.specs : chalk.gray('nenhum (só o teste de fumaça)')}`);
253
261
  for (const s of payload.services) {
254
262
  console.log(chalk.gray(` · ${s.name}: ${s.state}${s.health ? ` / ${s.health}` : ''}`));
255
263
  }
256
264
  for (const h of hostServices) {
257
- const health = h.health === null ? 'no health check' : h.health ? 'healthy' : 'unhealthy';
258
- console.log(chalk.gray(` · host ${h.name}: pid ${h.pid} ${h.alive ? 'alive' : 'dead'} / ${health}`));
265
+ const health = h.health === null ? 'sem checagem de saúde' : h.health ? 'funcionando' : 'com problema';
266
+ console.log(chalk.gray(` · serviço ${h.name}: pid ${h.pid} ${h.alive ? 'rodando' : 'parado'} / ${health}`));
259
267
  }
260
268
  console.log('');
261
269
  }
262
270
 
263
- process.exit(status.up && status.healthy && fresh ? 0 : 1);
271
+ process.exit(status.up && healthy && fresh ? 0 : 1);
264
272
  }
265
273
 
266
274
  // Best-effort: a stack that will not come down must never block `finish`. The freshness stamp
@@ -291,12 +299,12 @@ export async function e2eDownCommand(featureName, options = {}) {
291
299
  ));
292
300
  } else {
293
301
  if (result.status === 'pass') {
294
- console.log(chalk.green(`\n✓ Stack down — ${ctx.projectName}`));
295
- console.log(chalk.gray(` tree: ${ctx.tree}\n`));
302
+ console.log(chalk.green(`\n✓ Ambiente de teste desligado — ${ctx.projectName}`));
303
+ console.log(chalk.gray(` Pasta: ${ctx.tree}\n`));
296
304
  } else {
297
- console.log(chalk.yellow(`\n⚠️ Teardown reported a problem (not fatal):\n${result.output}\n`));
305
+ console.log(chalk.yellow(`\n⚠️ O desligamento avisou um problema (não impede de seguir):\n${result.output}\n`));
298
306
  }
299
- if (hostServices.killed.length) console.log(chalk.gray(` host services stopped: ${hostServices.killed.join(', ')}`));
307
+ if (hostServices.killed.length) console.log(chalk.gray(` Serviços locais parados: ${hostServices.killed.join(', ')}`));
300
308
  for (const w of hostServices.warnings) console.log(chalk.yellow(`⚠️ ${w}`));
301
309
  }
302
310
 
@@ -313,15 +321,15 @@ export async function e2eResetCommand(featureName, options = {}) {
313
321
  console.error(chalk.red(`\n✗ ${payload.reason}\n`));
314
322
  if (payload.output) console.error(payload.output);
315
323
  } else if (payload.status === 'skip') {
316
- console.log(chalk.gray(`\n○ e2e reset: ${payload.reason}\n`));
324
+ console.log(chalk.gray(`\n○ Dados de teste não foram zerados: ${payload.reason}\n`));
317
325
  } else {
318
326
  const what = payload.reset.mode === 'command'
319
- ? `e2e.resetCommand (${payload.reset.command})`
327
+ ? `pelo e2e.resetCommand (${payload.reset.command})`
320
328
  : payload.reset.mode === 'volumes'
321
- ? `recreated ${payload.reset.services.join(', ')} (volumes ${payload.reset.volumes.join(', ')})`
322
- : 'no data reset';
323
- console.log(chalk.green(`\n✓ e2e reset — ${what}`));
324
- if (payload.auth.reason) console.log(chalk.gray(` auth: ${payload.auth.reason}`));
329
+ ? `recriando ${payload.reset.services.join(', ')} (volumes ${payload.reset.volumes.join(', ')})`
330
+ : 'sem apagar dados';
331
+ console.log(chalk.green(`\n✓ Dados de teste zerados ${what}`));
332
+ if (payload.auth.reason) console.log(chalk.gray(` Login de teste: ${payload.auth.reason}`));
325
333
  console.log('');
326
334
  }
327
335
  process.exit(payload.status === 'fail' ? 1 : 0);
@@ -1,98 +1,13 @@
1
1
  import chalk from 'chalk';
2
- import { loadState, getFeature, derivePhase, deriveOutputs } from '../../core/state/state-manager.js';
2
+ import { join } from 'path';
3
+ import { getFeature, derivePhase, deriveOutputs } from '../../core/state/state-manager.js';
3
4
  import { implementProgress } from '../../../framework/hooks/shared/report-progress.js';
4
- import { formatNext } from '../../../framework/hooks/shared/next-step.js';
5
+ import { PHASE_NAME, retrato } from '../../../framework/hooks/shared/owner-words.js';
5
6
  import { nextStepFor } from '../../lib/next-step.js';
6
7
 
7
- const PHASE_SYMBOLS = {
8
- completed: '✅',
9
- current: '⏸️',
10
- pending: '⬜',
11
- skipped: '⊘'
12
- };
13
-
14
- const PHASE_ORDER = [
15
- { key: 'plan', name: 'FASE 1: PLAN', order: 0 },
16
- { key: 'uiux', name: 'FASE 2: UI/UX', order: 1, optional: true },
17
- { key: 'implement', name: 'FASE 3: IMPLEMENT', order: 2 },
18
- { key: 'review', name: 'FASE 4: REVIEW', order: 3 }
19
- ];
20
-
21
- const PHASE_OUTPUTS = {
22
- plan: ['plan', 'checks'],
23
- uiux: ['uiMockups'],
24
- implement: ['implementReport'],
25
- review: ['verifierReport', 'reviewerReport']
26
- };
27
-
28
- function getPhaseStatus(phaseKey, currentPhase, feature) {
29
- const phase = PHASE_ORDER.find(p => p.key === phaseKey);
30
- const current = PHASE_ORDER.find(p => p.key === currentPhase);
31
-
32
- if (!phase || !current) return 'pending';
33
-
34
- if (phase.optional && phase.order < current.order) {
35
- const hasOutputs = checkPhaseOutputs(phaseKey, feature);
36
- if (!hasOutputs) return 'skipped';
37
- }
38
-
39
- if (phase.order < current.order) return 'completed';
40
- if (phase.order === current.order) return 'current';
41
- return 'pending';
42
- }
43
-
44
- function checkPhaseOutputs(phaseKey, feature) {
45
- const outputs = PHASE_OUTPUTS[phaseKey] || [];
46
- return outputs.some(output => feature.outputs[output]?.created);
47
- }
48
-
49
- function formatPhase(phaseKey, currentPhase, feature, options = {}) {
50
- const phase = PHASE_ORDER.find(p => p.key === phaseKey);
51
- const status = getPhaseStatus(phaseKey, currentPhase, feature);
52
- const symbol = PHASE_SYMBOLS[status];
53
-
54
- let display = `${symbol} ${phase.name}`;
55
-
56
- if (phase.optional) {
57
- display += ` ${chalk.gray('(optional)')}`;
58
- }
59
-
60
- if (status === 'current') {
61
- display = chalk.cyan(display) + chalk.cyan(' ← CURRENT');
62
- } else if (status === 'completed') {
63
- display = chalk.green(display);
64
- } else if (status === 'skipped') {
65
- display = chalk.gray(display + ' (skipped)');
66
- } else {
67
- display = chalk.gray(display);
68
- }
69
-
70
- if (options.verbose && status !== 'pending' && status !== 'skipped') {
71
- const outputs = PHASE_OUTPUTS[phaseKey] || [];
72
- const created = outputs.filter(o => feature.outputs[o]?.created);
73
- if (created.length > 0) {
74
- display += chalk.gray(`\n Files: ${created.length}/${outputs.length}`);
75
- }
76
- }
77
-
78
- return display;
79
- }
80
-
81
- function calculateCompletionPercentage(feature) {
82
- const totalPhases = PHASE_ORDER.filter(p => !p.optional).length;
83
- const completedPhases = PHASE_ORDER.filter(p => {
84
- if (p.optional) return false;
85
- const status = getPhaseStatus(p.key, feature.phase, feature);
86
- return status === 'completed';
87
- }).length;
88
-
89
- return Math.round((completedPhases / totalPhases) * 100);
90
- }
91
-
92
8
  export async function statusCommand(featureName, options = {}) {
93
9
  if (!featureName) {
94
- console.error(chalk.red('✗ Error: Feature name required'));
95
- console.error(chalk.gray('Usage: morph-spec status <feature-name>'));
10
+ console.error(chalk.red('✗ Diga qual feature: morph-spec status <feature>'));
96
11
  process.exit(1);
97
12
  }
98
13
 
@@ -100,118 +15,47 @@ export async function statusCommand(featureName, options = {}) {
100
15
  try {
101
16
  feature = getFeature(featureName);
102
17
  } catch (err) {
103
- console.error(chalk.red(`✗ Error: ${err.message}`));
104
- console.error(chalk.gray('Run \'morph-spec doctor\' to diagnose or fix your state.json'));
18
+ console.error(chalk.red(`✗ Não consegui ler o estado do projeto: ${err.message}`));
19
+ console.error(chalk.gray('Para diagnosticar: morph-spec doctor'));
105
20
  process.exit(1);
106
21
  }
107
22
  if (!feature) {
108
- console.error(chalk.red(`✗ Error: Feature '${featureName}' not found`));
109
- console.error(chalk.gray(`Run 'morph-spec status' to list known features`));
23
+ console.error(chalk.red(`✗ Não achei a feature ${featureName} neste projeto.`));
110
24
  process.exit(1);
111
25
  }
112
26
 
113
- const { join } = await import('path');
114
27
  const featurePath = join(process.cwd(), '.morph', 'features', featureName);
115
- if (!feature.phase) {
116
- feature.phase = derivePhase(featurePath);
117
- }
118
- if (!feature.outputs) {
119
- feature.outputs = deriveOutputs(featureName, process.cwd());
120
- }
121
- const scenarios = implementProgress(featurePath);
28
+ const phase = feature.phase || derivePhase(featurePath);
29
+ const next = nextStepFor(featureName, process.cwd());
122
30
 
123
31
  if (options.json) {
124
- const status = {
32
+ const order = ['plan', 'uiux', 'implement', 'review'];
33
+ const at = order.indexOf(phase);
34
+ const phases = order.map((key, i) => ({
35
+ key, name: PHASE_NAME[key], optional: key === 'uiux',
36
+ status: i < at ? 'completed' : i === at ? 'current' : 'pending',
37
+ }));
38
+ const required = phases.filter((p) => !p.optional);
39
+ console.log(JSON.stringify({
125
40
  feature: featureName,
126
- phase: feature.phase,
41
+ phase,
42
+ phaseName: PHASE_NAME[phase] ?? phase,
127
43
  status: feature.status,
128
- completion: calculateCompletionPercentage(feature),
129
- phases: PHASE_ORDER.map(p => ({
130
- key: p.key,
131
- name: p.name,
132
- status: getPhaseStatus(p.key, feature.phase, feature),
133
- optional: p.optional || false
134
- })),
135
- outputs: Object.entries(feature.outputs).map(([key, output]) => ({
136
- type: key,
137
- created: output.created,
138
- path: output.path
139
- })),
140
- scenarios,
44
+ completion: Math.round((required.filter((p) => p.status === 'completed').length / required.length) * 100),
45
+ phases,
46
+ outputs: Object.entries(feature.outputs || deriveOutputs(featureName, process.cwd())).map(([type, o]) => ({ type, created: o.created, path: o.path })),
47
+ scenarios: implementProgress(featurePath),
141
48
  approvals: feature.approvalGates || {},
142
- next: nextStepFor(featureName, process.cwd())
143
- };
144
-
145
- console.log(JSON.stringify(status, null, 2));
49
+ next,
50
+ }, null, 2));
146
51
  return;
147
52
  }
148
53
 
149
- console.log(chalk.cyan('\n┌────────────────────────────────────────────────────────────┐'));
150
- console.log(chalk.cyan('│ MORPH-SPEC STATUS │'));
151
- console.log(chalk.cyan('└────────────────────────────────────────────────────────────┘\n'));
152
-
153
- console.log(chalk.white.bold(`Feature: ${featureName}`));
154
- console.log(chalk.gray(`Status: ${feature.status || 'unknown'}`));
155
- console.log(chalk.gray(`Completion: ${calculateCompletionPercentage(feature)}%`));
54
+ const lines = next?.retrato
55
+ ?? retrato({ slug: featureName, feature, progress: implementProgress(featurePath), phase });
156
56
  console.log('');
157
-
158
- console.log(chalk.white.bold('Phases:'));
159
- console.log(chalk.cyan('├─────────────────────────────────────────────────────────────┤'));
160
- PHASE_ORDER.forEach(phase => {
161
- console.log(`│ ${formatPhase(phase.key, feature.phase, feature, options)}`);
162
- });
163
- console.log(chalk.cyan('└─────────────────────────────────────────────────────────────┘'));
57
+ for (const line of lines) console.log(line);
164
58
  console.log('');
165
-
166
- const totalOutputs = Object.keys(feature.outputs).length;
167
- const createdOutputs = Object.values(feature.outputs).filter(o => o.created).length;
168
- console.log(chalk.white.bold(`Outputs: ${createdOutputs}/${totalOutputs} complete`));
169
-
170
- if (options.verbose) {
171
- console.log(chalk.gray('Output files:'));
172
- Object.entries(feature.outputs).forEach(([key, output]) => {
173
- const symbol = output.created ? '✅' : '⬜';
174
- const display = output.created ? chalk.green(key) : chalk.gray(key);
175
- console.log(` ${symbol} ${display}`);
176
- });
177
- }
178
- console.log('');
179
-
180
- if (scenarios && scenarios.total > 0) {
181
- console.log(chalk.white.bold('Cenários (3-implement/report.md):'));
182
- const percentage = Math.round((scenarios.done / scenarios.total) * 100);
183
- console.log(` Total: ${scenarios.total}`);
184
- console.log(chalk.green(` ✓ Feitos: ${scenarios.done} (${percentage}%)`));
185
- if (scenarios.blocked > 0) console.log(chalk.yellow(` ⏸ Bloqueados (esperam decisão): ${scenarios.blocked}`));
186
- if (scenarios.pending > 0) console.log(chalk.gray(` ⬜ Pendentes: ${scenarios.pending}`));
187
- console.log('');
188
- }
189
-
190
- if (feature.approvalGates) {
191
- const gates = Object.entries(feature.approvalGates);
192
- const approved = gates.filter(([_, g]) => g.approved).length;
193
- console.log(chalk.white.bold(`Approval Gates: ${approved}/${gates.length} approved`));
194
-
195
- if (options.verbose) {
196
- gates.forEach(([gate, info]) => {
197
- const symbol = info.approved ? '✅' : '⬜';
198
- const display = info.approved ? chalk.green(gate) : chalk.gray(gate);
199
- let extra = '';
200
- if (info.approved && info.approvedBy) {
201
- extra = chalk.gray(` (by ${info.approvedBy})`);
202
- }
203
- console.log(` ${symbol} ${display}${extra}`);
204
- });
205
- }
206
- console.log('');
207
- }
208
-
209
- const next = nextStepFor(featureName, process.cwd());
210
- if (next) console.log(chalk.yellow(`${formatNext(next)}\n`));
211
-
212
- console.log(chalk.gray('─'.repeat(60)));
213
- console.log(chalk.gray('Run with --verbose for detailed output'));
214
- console.log(chalk.gray('Run with --json for JSON output\n'));
215
59
  }
216
60
 
217
61
  export default statusCommand;
@@ -8,9 +8,27 @@ import { OUTPUT_SCHEMA } from '../../core/paths/output-schema.js';
8
8
  import { assertOwnerTree, ownerTreeRefusalLines } from '../../lib/worktree/feature-truth.js';
9
9
  import { uiuxAutoApprovalBlock } from '../../lib/specs/screen-checklist.js';
10
10
  import { seedDesignArtifacts } from '../../lib/specs/design-seed.js';
11
- import { implementProgress, reportPath, reportSkeleton } from '../../../framework/hooks/shared/report-progress.js';
11
+ import { implementProgress, ownerRef, reportPath, reportSkeleton } from '../../../framework/hooks/shared/report-progress.js';
12
12
  import { autoApprovalRefusal, printRefusal } from './auto-approval.js';
13
13
  import { seedDotnetBuildIgnores } from '../../lib/stack/dotnet-build-ignores.js';
14
+ import { GATE_NAME, PHASE_NAME, approvedBySay, STATUS_SAY, scenarioLabel } from '../../../framework/hooks/shared/owner-words.js';
15
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
16
+
17
+ const ARTIFACT_SAY = {
18
+ 'plan.md': 'o plano',
19
+ 'checks.json': 'a lista de cenários do plano (gerada pela validação do plano)',
20
+ 'report.md': 'o progresso da construção',
21
+ };
22
+
23
+ function missingLines(missing, featurePath) {
24
+ const lines = missing.filter((rel) => !rel.startsWith('3-implement/report.md ('))
25
+ .map((rel) => `Falta ${ARTIFACT_SAY[rel.split('/').pop()] ?? rel}.`);
26
+ const progress = missing.some((rel) => rel.startsWith('3-implement/report.md (')) ? implementProgress(featurePath) : null;
27
+ for (const c of progress?.checks ?? []) {
28
+ if (c.status !== 'feito') lines.push(`${scenarioLabel(c)}: ${STATUS_SAY[c.status] ?? c.status}.`);
29
+ }
30
+ return lines;
31
+ }
14
32
 
15
33
  const FRAMEWORK_DIR = fileURLToPath(new URL('../../../framework/', import.meta.url));
16
34
 
@@ -99,9 +117,10 @@ export async function advanceCommand(featureName, options = {}) {
99
117
  try {
100
118
  const feature = getFeature(featureName);
101
119
  if (!feature) {
102
- console.error(chalk.red(`\n❌ Feature not found: ${featureName}\n`));
120
+ console.error(chalk.red(`\n✗ Funcionalidade não encontrada: ${featureName}.\n`));
103
121
  process.exit(1);
104
122
  }
123
+ const ref = ownerRef(process.cwd(), featureName, feature);
105
124
 
106
125
  // A live worktree elsewhere owns the state: never stamp a gate onto the root skeleton.
107
126
  const owner = assertOwnerTree(featureName, process.cwd());
@@ -122,16 +141,17 @@ export async function advanceCommand(featureName, options = {}) {
122
141
  mkdirSync(join(featurePath, '1-design'), { recursive: true });
123
142
  reportDesignSeed(seedDesignArtifacts(featureName, process.cwd()));
124
143
  reportDotnetIgnores(seedDotnetBuildIgnores(process.cwd(), { featureName }));
125
- console.log(chalk.green(`\n✅ "${featureName}": gate plan já aprovado — ramo de design aberto (1-design/).\n`));
144
+ console.log(chalk.green(`\n✓ ${ref}: o plano já estava aprovado. O desenho das telas começa agora.`));
145
+ console.log(chalk.gray(` ${SESSION_MARK} ramo de design aberto em 1-design/\n`));
126
146
  return;
127
147
  }
128
148
 
129
149
  if (phase === 'review') {
130
- console.log(chalk.yellow(`\n⚠️ Feature "${featureName}" is already at the final phase (review).`));
131
- console.log(chalk.gray(`Approve Gate 3 with: morph-spec approve ${featureName} review`));
132
- console.log(chalk.gray(`Then archive with: morph-spec archive ${featureName}\n`));
150
+ console.log(chalk.yellow(`\n⚠ ${ref} já está na última etapa (${PHASE_NAME.review}).`));
151
+ console.log(chalk.gray(` ${SESSION_MARK} aprove a entrega com \`morph-spec approve ${featureName} review\` e arquive com \`morph-spec archive ${featureName}\`\n`));
133
152
  return;
134
153
  }
154
+ const stage = PHASE_NAME[phase] ?? phase;
135
155
 
136
156
  // `implement` has no gate, so this is what keeps unfinished scenarios out of review.
137
157
  // `--force` bypasses it but still names what was skipped.
@@ -139,8 +159,8 @@ export async function advanceCommand(featureName, options = {}) {
139
159
  if (missingArtifacts.length && !options.force) {
140
160
  const elsewhere = await artifactsLiveInWorktree(featureName, missingArtifacts);
141
161
  if (elsewhere) {
142
- console.error(chalk.red(`\n❌ A fase "${phase}" de "${featureName}" não pode ser encerrada A PARTIR DESTA ÁRVORE.`));
143
- console.error(chalk.gray(' Os artefatos não estão ausentes — eles vivem no worktree dono desta feature:'));
162
+ console.error(chalk.red(`\n✗ A etapa ${stage} de ${ref} não pode ser encerrada a partir desta pasta.`));
163
+ console.error(chalk.gray(' Nada está faltando: os arquivos vivem no worktree dono desta funcionalidade:'));
144
164
  for (const rel of elsewhere.present) console.error(chalk.gray(` • ${rel}`));
145
165
  console.error(chalk.gray(`\n Worktree: ${elsewhere.path}${elsewhere.branch ? ` (branch ${elsewhere.branch})` : ''}`));
146
166
  console.error(chalk.gray(' Rode o comando LÁ — o gate é gravado no feature.json daquela árvore:'));
@@ -150,9 +170,10 @@ export async function advanceCommand(featureName, options = {}) {
150
170
  process.exit(1);
151
171
  }
152
172
 
153
- console.error(chalk.red(`\n❌ A fase "${phase}" não pode ser encerrada — artefato(s) obrigatório(s) ausente(s), PARCIAL ou BLOQUEADO:`));
154
- for (const rel of missingArtifacts) console.error(chalk.gray(` • ${rel}`));
155
- console.error(chalk.gray('\n Produza o artefato e rode de novo, ou passe --force para avançar assim mesmo.\n'));
173
+ console.error(chalk.red(`\n✗ A etapa ${stage} de ${ref} ainda não pode ser encerrada:`));
174
+ for (const line of missingLines(missingArtifacts, featurePath)) console.error(` ${line}`);
175
+ console.error(chalk.gray(` ${SESSION_MARK} ausente(s), PARCIAL ou BLOQUEADO: ${missingArtifacts.join('; ')}.`
176
+ + ' Produza o artefato e rode de novo, ou passe --force para avançar assim mesmo.\n'));
156
177
  process.exit(1);
157
178
  }
158
179
 
@@ -163,8 +184,8 @@ export async function advanceCommand(featureName, options = {}) {
163
184
  if (gate) {
164
185
  const unmet = unmetPrereqs(gate, feature.approvalGates);
165
186
  if (unmet.length && !options.force) {
166
- console.error(chalk.red(`\n❌ Cannot advance past the ${phase} phase — prerequisite gate(s) not approved: ${unmet.join(', ')}.`));
167
- console.error(chalk.gray(` Gates must be approved in order (${unmet.join(' → ')} → ${gate}). Approve them first, or pass --force.\n`));
187
+ console.error(chalk.red(`\n✗ A etapa ${stage} de ${ref} ainda não pode ser encerrada: antes vem ${unmet.map((u) => GATE_NAME[u] ?? u).join(', ')}.`));
188
+ console.error(chalk.gray(` ${SESSION_MARK} prerequisite gate(s) não aprovado(s): aprove na ordem (${unmet.join(' → ')} → ${gate}), ou passe --force\n`));
168
189
  process.exit(1);
169
190
  }
170
191
  }
@@ -201,24 +222,27 @@ export async function advanceCommand(featureName, options = {}) {
201
222
  if (phase === 'plan') reportDotnetIgnores(seedDotnetBuildIgnores(process.cwd(), { featureName }));
202
223
 
203
224
 
204
- console.log(chalk.green(`\n✅ Advanced "${featureName}" past the ${phase} phase.`));
225
+ console.log(chalk.green(`\n✓ ${ref}: etapa ${stage} encerrada.`));
205
226
  if (missingArtifacts.length) {
206
- console.log(chalk.yellow(` ⚠️ --force: avançou SEM ${missingArtifacts.join(', ')}.`));
227
+ console.log(chalk.yellow(' ⚠ Avançou sem terminar tudo:'));
228
+ for (const line of missingLines(missingArtifacts, featurePath)) console.log(chalk.yellow(` ${line}`));
229
+ console.log(chalk.gray(` ${SESSION_MARK} --force: avançou SEM ${missingArtifacts.join(', ')}`));
207
230
  }
208
231
  if (checklistBlock) {
209
232
  const by = options.force ? '--force' : `aprovado por ${approvedBy}`;
210
- console.log(chalk.yellow(` ⚠️ ${by}: avançou com o ${checklistBlock}.`));
233
+ console.log(chalk.yellow(` ⚠ ${by}: avançou com o desenho das telas incompleto.`));
234
+ console.log(chalk.yellow(` ${checklistBlock}`));
211
235
  }
212
236
  // Never claim "approved (auto)" when nothing was written.
213
237
  if (gate && alreadyApproved) {
214
- console.log(chalk.gray(` Gate "${gate}" was already approved (${priorGate.approvedBy || 'unknown'}) — approval preserved, nothing re-written.`));
238
+ console.log(` ${GATE_NAME[gate]} já estava aprovada (por ${priorGate.approvedBy || 'alguém sem nome'}): nada foi regravado.`);
215
239
  } else if (gate) {
216
- console.log(chalk.gray(` Gate "${gate}" approved (${approvedBy}).`));
240
+ console.log(` ${GATE_NAME[gate]}: ${approvedBySay(approvedBy)}.`);
217
241
  }
218
- if (nextDir) console.log(chalk.gray(` Scaffolded ${nextDir}/ — ready for the next phase's first artifact.\n`));
242
+ if (nextDir) console.log(chalk.gray(` ${SESSION_MARK} pasta ${nextDir}/ criada para a próxima etapa\n`));
219
243
  else console.log('');
220
244
  } catch (error) {
221
- console.error(chalk.red(`\n❌ Error advancing feature: ${error.message}\n`));
245
+ console.error(chalk.red(`\n✗ Não deu para avançar: ${error.message}\n`));
222
246
  process.exit(1);
223
247
  }
224
248
  }