@polymorphism-tech/morph-spec 10.11.1 → 10.12.1

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 (77) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +2 -0
  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 +21 -6
  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 +7 -6
  19. package/framework/hooks/claude-code/core/worktree-context.js +48 -44
  20. package/framework/hooks/shared/gate-question.js +8 -0
  21. package/framework/hooks/shared/next-step.js +54 -23
  22. package/framework/hooks/shared/owner-words.js +146 -0
  23. package/framework/hooks/shared/report-progress.js +84 -10
  24. package/framework/phases.json +7 -7
  25. package/framework/rules/implement-report.md +8 -7
  26. package/framework/rules/plan-grammar.md +4 -1
  27. package/framework/schemas/feature.schema.json +3 -2
  28. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  29. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  30. package/framework/skills/core/morph-apply/SKILL.md +6 -5
  31. package/framework/skills/core/morph-apply/references/hotfix.md +6 -2
  32. package/framework/skills/core/morph-apply/references/review.md +9 -5
  33. package/framework/skills/core/morph-plan/SKILL.md +5 -5
  34. package/framework/skills/core/morph-plan/references/interview.md +1 -1
  35. package/framework/skills/core/morph-uiux/SKILL.md +10 -6
  36. package/framework/templates/docs/plan.md +1 -1
  37. package/package.json +1 -1
  38. package/src/commands/e2e/e2e.js +31 -29
  39. package/src/commands/project/status.js +28 -184
  40. package/src/commands/state/advance.js +44 -20
  41. package/src/commands/state/approve.js +70 -59
  42. package/src/commands/state/archive.js +20 -15
  43. package/src/commands/state/auto-approval.js +25 -23
  44. package/src/commands/state/create.js +35 -32
  45. package/src/commands/state/finish.js +179 -58
  46. package/src/commands/state/gate-check.js +43 -31
  47. package/src/commands/state/gate-decision.js +18 -14
  48. package/src/commands/state/list.js +23 -14
  49. package/src/commands/state/next.js +4 -5
  50. package/src/commands/state/report-check.js +47 -23
  51. package/src/commands/validation/plan-check.js +30 -14
  52. package/src/commands/validation/verify.js +39 -18
  53. package/src/dashboard/app/components/ActivityFeed.jsx +8 -8
  54. package/src/dashboard/app/components/CommandPalette.jsx +1 -1
  55. package/src/dashboard/app/components/GatePauses.jsx +8 -8
  56. package/src/dashboard/app/components/PhaseRail.jsx +6 -6
  57. package/src/dashboard/app/components/SessionMap.jsx +7 -7
  58. package/src/dashboard/app/lib/format.js +6 -2
  59. package/src/dashboard/app/lib/phases.js +48 -16
  60. package/src/dashboard/app/pages/FeatureDetail.jsx +87 -59
  61. package/src/dashboard/app/pages/Features.jsx +18 -18
  62. package/src/dashboard/app/pages/Guide.jsx +4 -4
  63. package/src/dashboard/app/pages/PhasePipeline.jsx +7 -7
  64. package/src/dashboard/app/pages/Portfolio.jsx +3 -3
  65. package/src/dashboard/scanner/activity-scanner.js +20 -6
  66. package/src/dashboard/scanner/features-scanner.js +43 -8
  67. package/src/dashboard/scanner/project-api.js +2 -0
  68. package/src/dashboard/vite.config.js +2 -0
  69. package/src/lib/next-step.js +3 -2
  70. package/src/lib/plan/checks.js +30 -15
  71. package/src/lib/plan/critique.js +6 -4
  72. package/src/lib/recap/recap.js +46 -20
  73. package/src/lib/risk-detector.js +260 -98
  74. package/src/lib/view/feature-html.js +19 -25
  75. package/src/lib/view/feature-view.js +6 -6
  76. package/src/utils/audience.js +27 -0
  77. package/src/utils/refusal-line.js +2 -2
@@ -4,7 +4,9 @@ import { execFileSync } from 'child_process';
4
4
  import { getFeature, setApprovalGate, getApprovalGate } from '../../core/state/state-manager.js';
5
5
  import { unmetPrereqs } from '../../core/state/gate-order.js';
6
6
  import { reviewReports, reviewFileName, REVIEW_ROLES, VERDICT_TOKEN, REVIEWED_SHA_TOKEN } from '../../lib/review-reports.js';
7
- import { shouldPauseGate } from '../../lib/risk-detector.js';
7
+ import { shouldPauseGate, fillTodo } from '../../lib/risk-detector.js';
8
+ import { GATE_NAME, PHASE_NAME, approvedBySay, ROLE_NAME, VERDICT_SAY } from '../../../framework/hooks/shared/owner-words.js';
9
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
8
10
  import { collectSignals, collectReviewRequirement } from './gate-check.js';
9
11
  import { autoApprovalRefusal, printRefusal } from './auto-approval.js';
10
12
  import { readTrustFromConfig } from './gate-decision.js';
@@ -12,6 +14,7 @@ import { assertOwnerTree, ownerTreeRefusalLines } from '../../lib/worktree/featu
12
14
  import { reviewConfirmation } from '../../lib/review-confirmation.js';
13
15
  import { seedDotnetBuildIgnores } from '../../lib/stack/dotnet-build-ignores.js';
14
16
  import { reportDotnetIgnores } from './advance.js';
17
+ import { ownerRef } from '../../../framework/hooks/shared/report-progress.js';
15
18
 
16
19
  export { REVIEWED_SHA_TOKEN };
17
20
 
@@ -46,7 +49,7 @@ function reviewStaleness(reports) {
46
49
  reviewed = null;
47
50
  }
48
51
  if (!reviewed) {
49
- unstamped ??= { status: 'unstamped', file, head };
52
+ unstamped ??= { status: 'unstamped', file, role, head };
50
53
  continue;
51
54
  }
52
55
  if (!staleRoles.has(role)) continue;
@@ -54,24 +57,17 @@ function reviewStaleness(reports) {
54
57
  try {
55
58
  ahead = Number(execFileSync('git', ['rev-list', '--count', `${reviewed}..${head}`], { cwd, stdio: 'pipe' }).toString().trim()) || 0;
56
59
  } catch { ahead = 0; }
57
- return { status: 'stale', file, reviewed, head, ahead };
60
+ return { status: 'stale', file, role, reviewed, head, ahead };
58
61
  }
59
62
  return unstamped ?? { status: 'ok', head };
60
63
  }
61
64
 
62
65
  export async function unapproveCommand(featureName, gateName, options = {}) {
63
66
  try {
64
- if (!VALID_GATES.includes(gateName)) {
65
- console.error(chalk.red(`\n❌ Invalid gate: ${gateName}`));
66
- console.log(chalk.gray(`Valid gates: ${VALID_GATES.join(', ')}\n`));
67
- process.exit(1);
68
- }
67
+ if (!VALID_GATES.includes(gateName)) refuseGate(gateName);
69
68
 
70
69
  const feature = getFeature(featureName);
71
- if (!feature) {
72
- console.error(chalk.red(`\n❌ Feature not found: ${featureName}\n`));
73
- process.exit(1);
74
- }
70
+ if (!feature) refuseFeature(featureName);
75
71
 
76
72
  const owner = assertOwnerTree(featureName, process.cwd());
77
73
  if (owner.blocked) {
@@ -81,9 +77,10 @@ export async function unapproveCommand(featureName, gateName, options = {}) {
81
77
  process.exit(1);
82
78
  }
83
79
 
80
+ const who = gateOf(gateName, featureName, feature);
84
81
  const currentStatus = getApprovalGate(featureName, gateName);
85
82
  if (!currentStatus?.approved) {
86
- console.log(chalk.yellow(`\n⚠️ Gate "${gateName}" is not currently approved — nothing to revoke\n`));
83
+ console.log(chalk.yellow(`\n⚠ ${who} não está aprovada: nada a revogar.\n`));
87
84
  return;
88
85
  }
89
86
 
@@ -105,11 +102,11 @@ export async function unapproveCommand(featureName, gateName, options = {}) {
105
102
  reason: options.reason
106
103
  });
107
104
 
108
- console.log(chalk.yellow(`\n↩️ Gate "${gateName}" approval revoked for feature: ${featureName}`));
109
- console.log(chalk.gray(`A fase voltou a ${gateName}: emende, \`plan-check ${featureName}\`, \`gate-check ${featureName} ${gateName}\` e \`advance ${featureName}\` reaprovam pelo fluxo normal\n`));
105
+ console.log(chalk.yellow(`\n↩ Aprovação revogada: ${who}. O trabalho volta para a etapa ${PHASE_NAME[gateName] ?? gateName}.`));
106
+ console.log(chalk.gray(` ${SESSION_MARK} emende, \`plan-check ${featureName}\`, \`gate-check ${featureName} ${gateName}\` e \`advance ${featureName}\` reaprovam pelo fluxo normal\n`));
110
107
 
111
108
  } catch (error) {
112
- console.error(chalk.red(`\n❌ Error revoking gate: ${error.message}\n`));
109
+ console.error(chalk.red(`\n✗ Não deu para revogar a aprovação: ${error.message}\n`));
113
110
  process.exit(1);
114
111
  }
115
112
  }
@@ -118,19 +115,30 @@ const program = new Command();
118
115
 
119
116
  const VALID_GATES = ['plan', 'uiux', 'review'];
120
117
 
118
+ const gateOf = (gate, featureName, feature) => `${GATE_NAME[gate] ?? gate} de ${ownerRef(process.cwd(), featureName, feature)}`;
119
+
120
+ function refuseGate(gateName) {
121
+ console.error(chalk.red(`\n✗ Etapa de aprovação desconhecida: ${gateName}.`));
122
+ console.error(chalk.gray(` ${SESSION_MARK} use uma destas: ${VALID_GATES.join(', ')}\n`));
123
+ process.exit(1);
124
+ }
125
+
126
+ function refuseFeature(featureName) {
127
+ console.error(chalk.red(`\n✗ Funcionalidade não encontrada: ${featureName}.\n`));
128
+ process.exit(1);
129
+ }
130
+
131
+ const REPORT_STATUS_SAY = {
132
+ missing: 'o relatório não existe',
133
+ partial: 'o relatório ficou pela metade',
134
+ };
135
+
121
136
  export async function approveCommand(featureName, gateName, options = {}) {
122
137
  try {
123
- if (!VALID_GATES.includes(gateName)) {
124
- console.error(chalk.red(`\n❌ Invalid gate: ${gateName}`));
125
- console.log(chalk.gray(`Valid gates: ${VALID_GATES.join(', ')}\n`));
126
- process.exit(1);
127
- }
138
+ if (!VALID_GATES.includes(gateName)) refuseGate(gateName);
128
139
 
129
140
  const feature = getFeature(featureName);
130
- if (!feature) {
131
- console.error(chalk.red(`\n❌ Feature not found: ${featureName}\n`));
132
- process.exit(1);
133
- }
141
+ if (!feature) refuseFeature(featureName);
134
142
 
135
143
  // A live worktree elsewhere owns the state: never stamp a gate onto the root skeleton.
136
144
  const owner = assertOwnerTree(featureName, process.cwd());
@@ -141,13 +149,12 @@ export async function approveCommand(featureName, gateName, options = {}) {
141
149
  process.exit(1);
142
150
  }
143
151
 
152
+ const who = gateOf(gateName, featureName, feature);
144
153
  const currentStatus = getApprovalGate(featureName, gateName);
145
154
  if (currentStatus?.approved) {
146
- console.log(chalk.yellow(`\n⚠️ Gate "${gateName}" is already approved`));
147
- console.log(chalk.gray(`Approved at: ${currentStatus.timestamp}`));
148
- console.log(chalk.gray(`Approved by: ${currentStatus.approvedBy || 'Unknown'}`));
155
+ console.log(chalk.yellow(`\n⚠ ${who} já está aprovada (por ${currentStatus.approvedBy || 'alguém sem nome'}, em ${currentStatus.timestamp}).`));
149
156
  // `--force` does not cover this no-op (it only covers gate ORDER), so name the way out.
150
- console.log(chalk.gray(`To approve it again, revoke it first: morph-spec unapprove ${featureName} ${gateName}\n`));
157
+ console.log(chalk.gray(` ${SESSION_MARK} para aprovar de novo, revogue antes: morph-spec unapprove ${featureName} ${gateName}\n`));
151
158
  if (gateName === 'plan') reportDotnetIgnores(seedDotnetBuildIgnores(process.cwd(), { featureName }));
152
159
  return;
153
160
  }
@@ -155,8 +162,8 @@ export async function approveCommand(featureName, gateName, options = {}) {
155
162
  // Gate monotonicity: predecessors first; policy stamps count (`--force` to recover).
156
163
  const unmet = unmetPrereqs(gateName, feature.approvalGates);
157
164
  if (unmet.length && !options.force) {
158
- console.error(chalk.red(`\n❌ Cannot approve "${gateName}" — prerequisite gate(s) not approved: ${unmet.join(', ')}.`));
159
- console.log(chalk.gray(` Gates must be approved in order (${unmet.map((u) => u).join(' → ')} → ${gateName}). Approve them first, or pass --force.\n`));
165
+ console.error(chalk.red(`\n✗ ${who} ainda não pode ser aprovada: antes vem ${unmet.map((u) => GATE_NAME[u] ?? u).join(', ')}.`));
166
+ console.error(chalk.gray(` ${SESSION_MARK} aprove na ordem (${unmet.join(' → ')} → ${gateName}), ou passe --force\n`));
160
167
  process.exit(1);
161
168
  }
162
169
 
@@ -185,16 +192,15 @@ export async function approveCommand(featureName, gateName, options = {}) {
185
192
  if (gateName === 'review') {
186
193
  const stale = reviewStaleness(reports);
187
194
  if (stale.status === 'stale') {
188
- console.error(chalk.red(`\n❌ O \`4-review/${stale.file}\` está desatualizado em relação ao código.`));
189
- console.error(chalk.gray(` Revisado em: ${stale.reviewed.slice(0, 8)}`));
190
- console.error(chalk.gray(` HEAD atual: ${stale.head.slice(0, 8)}${stale.ahead ? ` (${stale.ahead} commit(s) depois da revisão)` : ''}`));
191
- console.error(chalk.gray(' Um review revisa uma ÁRVORE, e a árvore andou. Re-rode a `morph-review`'));
192
- console.error(chalk.gray(` e atualize o \`${REVIEWED_SHA_TOKEN}\` de cada relatório.\n`));
195
+ console.error(chalk.red(`\n✗ O código mudou depois da ${ROLE_NAME[stale.role] ?? stale.role}: ela olhou uma versão anterior.`));
196
+ if (stale.ahead) console.error(` ${stale.ahead} mudança(s) gravada(s) depois da revisão.`);
197
+ console.error(chalk.gray(` ${SESSION_MARK} \`4-review/${stale.file}\` revisado em ${stale.reviewed.slice(0, 8)}, HEAD atual ${stale.head.slice(0, 8)}:`
198
+ + ` re-rode a \`morph-review\` e atualize o \`${REVIEWED_SHA_TOKEN}\` de cada relatório\n`));
193
199
  process.exit(1);
194
200
  }
195
201
  if (stale.status === 'unstamped') {
196
- console.log(chalk.yellow(`\n⚠️ O \`${stale.file}\` não carrega \`${REVIEWED_SHA_TOKEN}\` — impossível saber se ele revisa o código atual.`));
197
- console.log(chalk.gray(` Adicione a linha \`${REVIEWED_SHA_TOKEN} ${stale.head}\` ao relatório para que o Gate 3 possa verificar.`));
202
+ console.log(chalk.yellow(`\n⚠ Não dá para saber se a ${ROLE_NAME[stale.role] ?? stale.role} olhou o código atual.`));
203
+ console.log(chalk.gray(` ${SESSION_MARK} \`${stale.file}\` sem \`${REVIEWED_SHA_TOKEN}\`: adicione a linha \`${REVIEWED_SHA_TOKEN} ${stale.head}\``));
198
204
  }
199
205
  }
200
206
 
@@ -204,10 +210,9 @@ export async function approveCommand(featureName, gateName, options = {}) {
204
210
  // Hotfix never dispatches: the orchestrator writes `verifier.md` itself
205
211
  // (diff + real verify evidence); the human signature above decides.
206
212
  if (reports.verifier.status === 'missing') {
207
- console.error(chalk.red('\n❌ Gate 3 de hotfix exige `4-review/verifier.md` — não existe.'));
208
- console.error(chalk.gray(' No hotfix o orquestrador o escreve (diff do fix + evidência real do'));
209
- console.error(chalk.gray(' `morph-spec verify`) sem despachar ninguém. Escreva o relatório antes'));
210
- console.error(chalk.gray(' de aprovar; a assinatura humana já é exigida pelo backstop acima.\n'));
213
+ console.error(chalk.red('\n✗ A correção urgente precisa do relatório da Conferência das entregas antes da aprovação.'));
214
+ console.error(chalk.gray(` ${SESSION_MARK} no hotfix a sessão escreve \`4-review/verifier.md\` (diff do fix + evidência real do`
215
+ + ' `morph-spec verify`) sem despachar ninguém; a assinatura humana já é exigida\n'));
211
216
  process.exit(1);
212
217
  }
213
218
  } else {
@@ -215,17 +220,21 @@ export async function approveCommand(featureName, gateName, options = {}) {
215
220
  const unusable = required.filter((role) => reports[role].status !== 'ok');
216
221
  if (unusable.length) {
217
222
  if (!options.selfAssessed) {
218
- console.error(chalk.red(`\n❌ Gate 3 exige ${required.map((r) => `\`4-review/${reviewFileName(r)}\``).join(', ')}.`));
223
+ console.error(chalk.red('\n✗ A entrega não pode ser aprovada: falta a Revisão independente.'));
219
224
  for (const role of unusable) {
225
+ const { status } = reports[role];
226
+ console.error(` ${ROLE_NAME[role]}: ${REPORT_STATUS_SAY[status] ?? 'o relatório não diz se aprovou ou pediu correção'}.`);
227
+ }
228
+ const tokens = unusable.map((role) => {
220
229
  const { status } = reports[role];
221
230
  const what = status === 'missing' ? 'não existe'
222
- : status === 'partial' ? 'está PARCIAL — despache o mesmo papel de novo dizendo o que já está no relatório'
231
+ : status === 'partial' ? 'está PARCIAL (despache o mesmo papel de novo dizendo o que já está no relatório)'
223
232
  : `não tem \`${VERDICT_TOKEN} SHIP|FIX\``;
224
- console.error(chalk.gray(` ${reviewFileName(role)} ${what}.`));
225
- }
226
- console.error(chalk.gray(` Os relatórios vêm de ${unusable.map((r) => `\`${REVIEW_ROLES[r].persona}\``).join(', ')} em contexto fresco, nunca de quem implementou.`));
227
- console.error(chalk.gray(' Se o dispatch for impossível nesta sessão, aprove com --self-assessed —'));
228
- console.error(chalk.gray(' a degradação fica registrada no feature.json e aparece no `list`/`fleet`.\n'));
233
+ return `${reviewFileName(role)} ${what}`;
234
+ });
235
+ console.error(chalk.gray(` ${SESSION_MARK} exige ${required.map((r) => `\`4-review/${reviewFileName(r)}\``).join(', ')}. ${tokens.join('; ')}.`
236
+ + ` Despache ${unusable.map((r) => `\`${REVIEW_ROLES[r].persona}\``).join(', ')} em contexto fresco, nunca quem implementou.`
237
+ + ' Se o dispatch for impossível nesta sessão, aprove com --self-assessed (a degradação fica registrada no feature.json e aparece no `list`/`fleet`)\n'));
229
238
  process.exit(1);
230
239
  }
231
240
  selfAssessed = true;
@@ -236,10 +245,12 @@ export async function approveCommand(featureName, gateName, options = {}) {
236
245
  if (approvedBy === 'auto') {
237
246
  const signals = collectSignals(featureName, feature, process.cwd(), 'review');
238
247
  if (selfAssessed) signals.reviewReports = SIGNED_OFF;
239
- const { pause, reason } = shouldPauseGate({ trust: readTrustFromConfig() }, signals);
248
+ const { pause, reason, todo } = shouldPauseGate({ trust: readTrustFromConfig() }, signals);
240
249
  if (pause) {
241
- console.error(chalk.red(`\n❌ Gate 3 não pode ser auto-aprovado — ${reason}.`));
242
- console.error(chalk.gray(' Corrija e rode de novo, ou leve a decisão ao humano (--approver <nome>).\n'));
250
+ console.error(chalk.red('\n✗ A entrega não pode ser aprovada sozinha.'));
251
+ console.error(` Motivo: ${reason}`);
252
+ const action = fillTodo(todo, featureName, 'review');
253
+ console.error(chalk.gray(` ${SESSION_MARK} ${action ? `${action}; ou ` : ''}leve a decisão ao humano (--approver <nome>)\n`));
243
254
  process.exit(1);
244
255
  }
245
256
  }
@@ -247,8 +258,8 @@ export async function approveCommand(featureName, gateName, options = {}) {
247
258
  for (const role of required) {
248
259
  const r = reports[role];
249
260
  if (r.status === 'ok' && r.superseded.length > 0) {
250
- console.log(chalk.yellow(`\n⚠️ ${reviewFileName(role)} tem ${r.superseded.length + 1} vereditos (append-only).`));
251
- console.log(chalk.gray(` Vigente: ${r.verdict}, ${r.blockers.length} bloqueador(es). Superados: ${r.superseded.join(', ')}\n`));
261
+ console.log(chalk.yellow(`\n⚠ O relatório da ${ROLE_NAME[role]} tem ${r.superseded.length + 1} vereditos; vale o último: ${VERDICT_SAY[r.verdict] ?? r.verdict}, ${r.blockers.length} problema(s).`));
262
+ console.log(chalk.gray(` ${SESSION_MARK} ${reviewFileName(role)} tem ${r.superseded.length + 1} vereditos (append-only). Vigente: ${r.verdict}. Superados: ${r.superseded.join(', ')}\n`));
252
263
  }
253
264
  }
254
265
  }
@@ -262,16 +273,16 @@ export async function approveCommand(featureName, gateName, options = {}) {
262
273
  });
263
274
 
264
275
  if (selfAssessed) {
265
- console.log(chalk.yellow('\n⚠️ Gate 3 aprovado SEM os relatórios de review independentes (--self-assessed).'));
266
- console.log(chalk.gray(' Registrado em feature.json → approvalGates.review.selfAssessed.'));
276
+ console.log(chalk.yellow('\n⚠ Entrega aprovada SEM a Revisão independente.'));
277
+ console.log(chalk.gray(` ${SESSION_MARK} --self-assessed registrado em feature.json → approvalGates.review.selfAssessed`));
267
278
  }
268
279
 
269
- console.log(chalk.green(`\n✅ Gate "${gateName}" approved for feature: ${featureName}`));
280
+ console.log(chalk.green(`\n✓ ${who}: ${approvedBySay(approvedBy)}. O trabalho pode seguir.`));
270
281
  if (gateName === 'plan') reportDotnetIgnores(seedDotnetBuildIgnores(process.cwd(), { featureName }));
271
- console.log(chalk.gray(`Workflow can now proceed past ${gateName} phase\n`));
282
+ console.log('');
272
283
 
273
284
  } catch (error) {
274
- console.error(chalk.red(`\n❌ Error approving gate: ${error.message}\n`));
285
+ console.error(chalk.red(`\n✗ Não deu para aprovar: ${error.message}\n`));
275
286
  process.exit(1);
276
287
  }
277
288
  }
@@ -5,6 +5,9 @@ import { execFileSync } from 'child_process';
5
5
  import { ADR_INDEX_PATHSPEC, updateAdrIndex } from '../../lib/specs/adr-index.js';
6
6
  import { isValidFeatureName } from '../project/worktree.js';
7
7
  import { RECAP_FILES, writeRecap } from './recap.js';
8
+ import { GATE_NAME, featureRef } from '../../../framework/hooks/shared/owner-words.js';
9
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
10
+ import { featureSummary } from '../../../framework/hooks/shared/report-progress.js';
8
11
 
9
12
  function assertContained(scopeDir, name, target) {
10
13
  const scopeAbs = resolve(scopeDir) + sep;
@@ -185,42 +188,44 @@ export async function archiveCommand(featureName, options = {}) {
185
188
 
186
189
  if (!result.ok) {
187
190
  if (result.error === 'invalid-feature-name') {
188
- console.error(chalk.red(`\n❌ Invalid feature name: "${featureName}"`));
189
- console.error(chalk.gray('Use kebab-case: lowercase letters, digits and hyphens (e.g. "user-onboarding")\n'));
191
+ console.error(chalk.red(`\n❌ Identificador da feature inválido: "${featureName}"`));
192
+ console.error(chalk.gray('Use kebab-case: letras minúsculas, números e hífens (ex.: "cadastro-de-cliente")\n'));
190
193
  } else if (result.error === 'feature-folder-not-found') {
191
- console.error(chalk.red(`\n❌ Feature folder not found: .morph/features/${featureName}\n`));
194
+ console.error(chalk.red(`\n❌ Não achei a feature ${featureName} neste projeto (.morph/features/${featureName}).\n`));
192
195
  } else if (result.error === 'review-not-approved') {
193
- console.error(chalk.red(`\n❌ Gate 3 (review) is not approved for "${featureName}".`));
194
- console.log(chalk.gray(`Approve it first (morph-spec approve ${featureName} review) or pass --force.\n`));
196
+ console.error(chalk.red(`\n❌ A entrega de ${featureName} ainda não passou pela ${GATE_NAME.review}.`));
197
+ console.error(chalk.gray(' Só se arquiva o que foi aprovado.'));
198
+ console.log(chalk.gray(` ${SESSION_MARK} morph-spec approve ${featureName} review, ou --force.\n`));
195
199
  } else {
196
- console.error(chalk.red(`\n❌ Error archiving feature: ${result.error}\n`));
200
+ console.error(chalk.red(`\n❌ Não deu para arquivar a feature: ${result.error}\n`));
197
201
  }
198
202
  process.exit(1);
199
203
  }
200
204
 
201
205
  if (result.alreadyArchived) {
202
- console.error(chalk.red(`\n❌ Already archived: .morph/archive/${featureName}\n`));
206
+ console.error(chalk.red(`\n❌ A feature ${featureName} já está arquivada (.morph/archive/${featureName}).\n`));
203
207
  process.exit(1);
204
208
  }
205
209
 
206
- console.log(chalk.green(`\n📦 Archived "${featureName}" → .morph/archive/${featureName}/`));
207
- console.log(chalk.gray(` status: completed, archivedAt stamped in feature.json.`));
208
- if (result.recap) console.log(chalk.gray(` recap: ${result.recap} (morph-spec recap ${featureName} --piper narra com o Piper)`));
210
+ let ref = featureName;
211
+ try { ref = featureRef(featureName, JSON.parse(readFileSync(join(result.archivePath, 'feature.json'), 'utf8')), featureSummary(result.archivePath)); } catch { /* the slug still names it */ }
212
+ console.log(chalk.green(`\n📦 Feature ${ref} arquivada: marcada como concluída e guardada em .morph/archive/${featureName}/`));
213
+ if (result.recap) console.log(chalk.gray(` Resumo animado da entrega: ${result.recap} (com narração: morph-spec recap ${featureName} --piper)`));
209
214
  if (result.adrIndex) {
210
215
  const { added, revoked, narrowed } = result.adrIndex;
211
- console.log(chalk.gray(` ADR index (.morph/specs/adrs/): +${added.length} −${revoked.length} ~${narrowed.length}.`));
216
+ console.log(chalk.gray(` Decisões do projeto (.morph/specs/adrs/): ${added.length} nova(s), ${revoked.length} revogada(s), ${narrowed.length} com alcance reduzido.`));
212
217
  }
213
218
  if (result.revocationProblems?.length) {
214
- console.log(chalk.yellow(`\n⚠️ ${result.revocationProblems.length} revogação(ões) do plan.md NÃO aplicada(s):`));
219
+ console.log(chalk.yellow(`\n⚠️ ${result.revocationProblems.length} revogação(ões) de decisão pedida(s) no plano NÃO foi(ram) aplicada(s):`));
215
220
  for (const p of result.revocationProblems) {
216
221
  console.log(chalk.yellow(` ${p.message}`));
217
222
  }
218
223
  }
219
- if (result.committed) console.log(chalk.gray(` Move committed on the current branch.\n`));
220
- else if (result.staged) console.log(chalk.gray(` Move staged in git; commit it when ready.\n`));
224
+ if (result.committed) console.log(chalk.gray(' A mudança já está em commit na branch atual.\n'));
225
+ else if (result.staged) console.log(chalk.gray(' A mudança está pronta no git, falta o commit.\n'));
221
226
  else console.log('');
222
227
  } catch (error) {
223
- console.error(chalk.red(`\n❌ Error archiving feature: ${error.message}\n`));
228
+ console.error(chalk.red(`\n❌ Não deu para arquivar a feature: ${error.message}\n`));
224
229
  process.exit(1);
225
230
  }
226
231
  }
@@ -1,31 +1,34 @@
1
1
  import { planAutoApprovalBlock } from './gate-check.js';
2
2
  import { uiuxAutoApprovalBlock } from '../../lib/specs/screen-checklist.js';
3
+ import { GATE_NAME } from '../../../framework/hooks/shared/owner-words.js';
4
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
5
+ import { ASK_OWNER } from '../../lib/risk-detector.js';
6
+
7
+ const HUMAN_SIGN = `${ASK_OWNER}; a resposta "aprovado" do dono grava a aprovação (state-sync), ou ele mesmo aprova num terminal com --approver <nome>`;
3
8
 
4
9
  /**
5
10
  * Why an "auto" signature may not stamp `gate`, or null when it may. The one rule
6
11
  * `approve` and `advance` share: they write the same `approvalGates` entry.
12
+ * `title` and `hints` are for the owner; `todo` is the exact action for the session.
7
13
  */
8
14
  export function autoApprovalRefusal({ cwd, featureName, feature, gate, approvedBy }) {
9
15
  if (approvedBy !== 'auto' || !gate) return null;
10
16
 
11
17
  if (gate === 'review' && feature.workType === 'hotfix') {
12
18
  return {
13
- title: 'Hotfix exige aprovação humana no Gate 3 — trust:auto não se aplica.',
14
- hints: ['Aprove com --approver <nome>, num terminal interativo, ou pela resposta humana "aprovado" (state-sync) via AskUserQuestion.'],
19
+ title: 'Correção urgente: a entrega precisa da sua aprovação. Ela não é aprovada sozinha.',
20
+ hints: ['Hotfix exige aprovação humana na Revisão independente.'],
21
+ todo: HUMAN_SIGN,
15
22
  };
16
23
  }
17
24
 
18
25
  const decision = feature.gateDecisions?.[gate];
19
26
  if (decision?.pause === true) {
20
27
  return {
21
- title: `O Gate "${gate}" registrou pause:true — auto-aprovação não se aplica.`,
22
- hints: [
23
- `Sinal: ${decision.reason || 'risco detectado'}`,
24
- 'A decisão gravada exigia pausa humana. Aprove com --approver <nome>, num',
25
- 'terminal interativo, ou pela resposta humana via AskUserQuestion (state-sync).',
26
- 'Se o sinal de risco já não vale, regrave a decisão:',
27
- `morph-spec gate-decision ${featureName} ${gate} --pause false --reason "<motivo>"`,
28
- ],
28
+ title: `A ${GATE_NAME[gate] ?? gate} parou e espera você. Ela não é aprovada sozinha.`,
29
+ hints: [`Motivo: ${decision.reason || 'risco detectado'}`],
30
+ todo: `a decisão gravada (gateDecisions.${gate}) é pause:true: ${HUMAN_SIGN}. `
31
+ + `Se o dono disser que o motivo já não vale, grave: \`morph-spec gate-decision ${featureName} ${gate} --pause false --reason "<motivo do dono>"\``,
29
32
  };
30
33
  }
31
34
 
@@ -33,8 +36,9 @@ export function autoApprovalRefusal({ cwd, featureName, feature, gate, approvedB
33
36
  const block = planAutoApprovalBlock(cwd, featureName, feature);
34
37
  if (block) {
35
38
  return {
36
- title: `O gate "plan" não pode ser auto-aprovado — ${block}.`,
37
- hints: ['Sem checks.json fresco: plan-check verde e rode de novo. Com degrau: aprove com --approver <nome> ou pela resposta humana. O --force não dispensa nenhum dos dois.'],
39
+ title: 'O plano não pode ser aprovado sozinho.',
40
+ hints: [`Motivo: ${block.reason}`],
41
+ todo: `${block.todo ?? HUMAN_SIGN}. O --force não dispensa`,
38
42
  };
39
43
  }
40
44
  }
@@ -43,13 +47,11 @@ export function autoApprovalRefusal({ cwd, featureName, feature, gate, approvedB
43
47
  const block = uiuxAutoApprovalBlock(cwd, featureName, feature);
44
48
  if (block) {
45
49
  return {
46
- title: `O Gate "uiux" não pode ser auto-aprovado — ${block}.`,
47
- hints: [
48
- 'Complete o checklist (ver a skill morph-uiux) e rode de novo, aprove com',
49
- '--approver <nome>, ou, se a pausa já foi decidida, grave a decisão:',
50
- `morph-spec gate-decision ${featureName} uiux --pause false --reason "<motivo>"`,
51
- 'O --force não dispensa o checklist.',
52
- ],
50
+ title: 'As telas não podem ser aprovadas sozinhas.',
51
+ hints: [`Motivo: ${block}`],
52
+ todo: 'complete o checklist (skill morph-uiux) e rode de novo. Sem como completar: '
53
+ + `${HUMAN_SIGN}; se o dono já decidiu a pausa, grave: \`morph-spec gate-decision ${featureName} uiux --pause false --reason "<motivo do dono>"\`. `
54
+ + 'O --force não dispensa o checklist',
53
55
  };
54
56
  }
55
57
  }
@@ -58,8 +60,8 @@ export function autoApprovalRefusal({ cwd, featureName, feature, gate, approvedB
58
60
  }
59
61
 
60
62
  export function printRefusal(chalk, refusal) {
61
- console.error(chalk.red(`\n❌ ${refusal.title}`));
62
- refusal.hints.forEach((line, i) => {
63
- console.error(chalk.gray(` ${line}${i === refusal.hints.length - 1 ? '\n' : ''}`));
64
- });
63
+ console.error(chalk.red(`\n✗ ${refusal.title}`));
64
+ for (const line of refusal.hints) console.error(` ${line}`);
65
+ if (refusal.todo) console.error(chalk.gray(` ${SESSION_MARK} ${refusal.todo}`));
66
+ console.error('');
65
67
  }
@@ -10,6 +10,8 @@ import { detectDefaultBranch, freshDefaultRef } from '../../lib/git/default-bran
10
10
  import { writePlanSkeleton } from '../../lib/plan/plan-template.js';
11
11
  import { seedDotnetBuildIgnores } from '../../lib/stack/dotnet-build-ignores.js';
12
12
  import { reportDotnetIgnores } from './advance.js';
13
+ import { GATE_NAME, WORK_NAME, featureRef } from '../../../framework/hooks/shared/owner-words.js';
14
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
13
15
 
14
16
  // Branches from the DEFAULT branch, never HEAD, so it never inherits another feature's commits.
15
17
  // `checkout: false` still CREATES the branch, which `finish` depends on. Fail-open: any git error
@@ -37,11 +39,11 @@ function branchCommonFlow(featureName, { checkout = true } = {}) {
37
39
  // One builder for stdout and (under --json) stderr, so the two surfaces never drift.
38
40
  function branchMoveWarning({ branch, movedFrom }) {
39
41
  return [
40
- `⚠️ Working tree MOVED: ${movedFrom} → ${branch}`,
41
- ` This checkout is now ON the feature branch — uncommitted work came along,`,
42
- ` and anything committed here from now on lands on ${branch}, not ${movedFrom}.`,
43
- ` Use --no-checkout to create the branch without moving the tree, or --worktree`,
44
- ` (the recommended route for parallel work) to isolate the feature in its own tree.`,
42
+ `⚠️ Esta pasta MUDOU de branch: ${movedFrom} → ${branch}`,
43
+ ` O que ainda não estava em commit veio junto.`,
44
+ ` Todo commit feito aqui daqui em diante vai para ${branch}, não para ${movedFrom}.`,
45
+ ` Para criar a branch sem mudar esta pasta: --no-checkout.`,
46
+ ` Para trabalhar em paralelo, com a feature numa pasta só dela: --worktree (o caminho recomendado).`,
45
47
  ];
46
48
  }
47
49
 
@@ -54,13 +56,13 @@ const VALID_DETECT_SOURCES = ['deterministic', 'llm', 'user'];
54
56
  function resolveWorkType(options, now) {
55
57
  if (options.type !== undefined) {
56
58
  if (!isValidWorkType(options.type)) {
57
- console.error(chalk.red(`\n❌ Invalid --type: "${options.type}"`));
58
- console.error(chalk.gray(`Valid types: ${Object.keys(WORK_TYPES).join(', ')}\n`));
59
+ console.error(chalk.red(`\n❌ --type não reconhecido: "${options.type}"`));
60
+ console.error(chalk.gray(`Tipos aceitos: ${Object.keys(WORK_TYPES).join(', ')}\n`));
59
61
  process.exit(1);
60
62
  }
61
63
  if (options.detectSource !== undefined && !VALID_DETECT_SOURCES.includes(options.detectSource)) {
62
- console.error(chalk.red(`\n❌ Invalid --detect-source: "${options.detectSource}"`));
63
- console.error(chalk.gray(`Valid sources: ${VALID_DETECT_SOURCES.join(', ')}\n`));
64
+ console.error(chalk.red(`\n❌ --detect-source não reconhecido: "${options.detectSource}"`));
65
+ console.error(chalk.gray(`Valores aceitos: ${VALID_DETECT_SOURCES.join(', ')}\n`));
64
66
  process.exit(1);
65
67
  }
66
68
  return {
@@ -100,14 +102,14 @@ function resolveWorkType(options, now) {
100
102
  export async function createCommand(featureName, options = {}) {
101
103
  try {
102
104
  if (!FEATURE_NAME_RE.test(featureName)) {
103
- console.error(chalk.red(`\n❌ Invalid feature name: "${featureName}"`));
104
- console.error(chalk.gray('Use kebab-case: lowercase letters, digits and hyphens (e.g. "user-onboarding")\n'));
105
+ console.error(chalk.red(`\n❌ Identificador da feature inválido: "${featureName}"`));
106
+ console.error(chalk.gray('Use kebab-case: letras minúsculas, números e hífens (ex.: "cadastro-de-cliente")\n'));
105
107
  process.exit(1);
106
108
  }
107
109
 
108
110
  if (options.status !== undefined && !VALID_STATUSES.includes(options.status)) {
109
- console.error(chalk.red(`\n❌ Invalid --status: "${options.status}"`));
110
- console.error(chalk.gray(`Valid statuses: ${VALID_STATUSES.join(', ')}\n`));
111
+ console.error(chalk.red(`\n❌ --status não reconhecido: "${options.status}"`));
112
+ console.error(chalk.gray(`Valores aceitos: ${VALID_STATUSES.join(', ')}\n`));
111
113
  process.exit(1);
112
114
  }
113
115
 
@@ -131,9 +133,9 @@ export async function createCommand(featureName, options = {}) {
131
133
  // Filesystem, not loadState: loadState throws when no state exists yet (birth from nothing).
132
134
  const alreadyExists = existsSync(join(process.cwd(), '.morph', 'features', featureName, 'feature.json'));
133
135
  if (!alreadyExists && (description === null || String(description).trim() === '')) {
134
- console.error(chalk.red(`\n❌ A feature needs a description at birth: "${featureName}"`));
135
- console.error(chalk.gray(' Pass --description "<what/why>" (or --request '<pedido>', which seeds it).'));
136
- console.error(chalk.gray(' This keeps features identifiable — no more anonymous scaffolds.\n'));
136
+ console.error(chalk.red(`\n❌ A feature "${featureName}" precisa nascer com uma descrição.`));
137
+ console.error(chalk.gray(' Passe --description "<o quê e por quê>" (ou --request \'<pedido>\', que vira a descrição).'));
138
+ console.error(chalk.gray(' É pela descrição que a feature aparece com nome nas listas e no status.\n'));
137
139
  process.exit(1);
138
140
  }
139
141
 
@@ -226,46 +228,47 @@ export async function createCommand(featureName, options = {}) {
226
228
  return;
227
229
  }
228
230
 
231
+ const ref = featureRef(featureName, finalFeature);
229
232
  if (created) {
230
- console.log(chalk.green(`\n✅ Feature created: ${featureName} (type: ${finalFeature.workType})`));
231
- console.log(chalk.gray(` .morph/features/${featureName}/feature.json (canonical shape)`));
232
- console.log(chalk.gray(` status: ${finalFeature.status} | createdAt: ${finalFeature.createdAt}`));
233
- console.log(chalk.gray(` scaffolded: ${wt.scaffold.join(', ')}`));
233
+ console.log(chalk.green(`\n✅ Feature criada: ${ref}`));
234
+ console.log(chalk.gray(` Tipo: ${WORK_NAME[finalFeature.workType] ?? finalFeature.workType} (${finalFeature.workType})`));
234
235
  reportDotnetIgnores(gitignoreAdded);
235
236
  if (planSkeleton?.written) {
236
- console.log(chalk.gray(` 2-plan/plan.md: esqueleto escrito (gramática: morph-spec plan-check --help)`));
237
+ console.log(chalk.gray(' O plano começa de um modelo em branco, pronto para preencher.'));
237
238
  }
238
239
  if (wt.skippedGates.length) {
239
- console.log(chalk.yellow(` gates skipped by policy:${finalFeature.workType}: ${wt.skippedGates.join(', ')}`));
240
+ const skipped = wt.skippedGates.map((g) => GATE_NAME[g] ?? g).join(', ');
241
+ console.log(chalk.yellow(` Este tipo de trabalho dispensa: ${skipped}.`));
240
242
  }
241
- console.log(chalk.cyan(` next: ${wt.entrySkill}\n`));
243
+ console.log(chalk.gray(` ${SESSION_MARK} ${wt.entrySkill}; pastas criadas em .morph/features/${featureName}/: ${wt.scaffold.join(', ')}\n`));
242
244
 
243
245
  if (worktreeResult) {
244
246
  if (worktreeResult.created) {
245
- console.log(chalk.green(` worktree: ${worktreeResult.path} (branch ${worktreeResult.branch})`));
247
+ console.log(chalk.green(' A feature ganhou uma pasta própria, separada da principal.'));
248
+ console.log(chalk.gray(` ${SESSION_MARK} pasta ${worktreeResult.path} (branch ${worktreeResult.branch})`));
246
249
  console.log(chalk.gray(` ${worktreeResult.nextStep}\n`));
247
250
  } else {
248
- const why = worktreeResult.error || (worktreeResult.alreadyExists ? 'already exists' : 'unknown');
249
- console.log(chalk.yellow(` ⚠️ worktree setup skipped (${why}) — feature stays in the root worktree\n`));
251
+ const why = worktreeResult.error || (worktreeResult.alreadyExists ? 'a pasta já existe' : 'motivo desconhecido');
252
+ console.log(chalk.yellow(` ⚠️ Não deu para criar a pasta separada (${why}). A feature fica na pasta principal.\n`));
250
253
  }
251
254
  } else if (branchResult?.branched) {
252
- console.log(chalk.green(` branch: ${branchResult.branch} (from ${branchResult.from})`));
253
- console.log(chalk.gray(` close it with: morph-spec finish ${featureName} --pr | --merge`));
255
+ console.log(chalk.green(` O trabalho fica numa branch própria, separado de ${branchResult.from} até a entrega.`));
256
+ console.log(chalk.gray(` ${SESSION_MARK} branch ${branchResult.branch}; para entregar: morph-spec finish ${featureName} --pr | --merge`));
254
257
  if (branchResult.movedFrom) {
255
258
  // Alert, not one more success line: the tree the dev is standing in moved.
256
259
  console.log('');
257
260
  for (const line of branchMoveWarning(branchResult)) console.log(chalk.yellow(` ${line}`));
258
261
  } else if (branchResult.checkedOut === false) {
259
- console.log(chalk.gray(` working tree left on ${branchResult.stayedOn} (--no-checkout)`));
262
+ console.log(chalk.gray(` Esta pasta continua na branch ${branchResult.stayedOn} (--no-checkout).`));
260
263
  }
261
264
  console.log('');
262
265
  }
263
266
  } else {
264
- console.log(chalk.yellow(`\n⚠️ Feature "${featureName}" already exists — left untouched`));
265
- console.log(chalk.gray(` status: ${finalFeature.status} | workType: ${finalFeature.workType || 'feature'} | createdAt: ${finalFeature.createdAt || 'unknown'}\n`));
267
+ console.log(chalk.yellow(`\n⚠️ A feature ${ref} já existe. Nada foi mudado.`));
268
+ console.log(chalk.gray(` Tipo: ${WORK_NAME[finalFeature.workType || 'feature'] ?? finalFeature.workType}. Criada em ${finalFeature.createdAt || 'data desconhecida'}.\n`));
266
269
  }
267
270
  } catch (error) {
268
- console.error(chalk.red(`\n❌ Error creating feature: ${error.message}\n`));
271
+ console.error(chalk.red(`\n❌ Não deu para criar a feature: ${error.message}\n`));
269
272
  process.exit(1);
270
273
  }
271
274
  }