@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.
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 +6 -5
  19. package/framework/hooks/claude-code/core/worktree-context.js +47 -43
  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
@@ -1,6 +1,8 @@
1
1
  import chalk from 'chalk';
2
2
  import { getFeature } from '../../core/state/state-manager.js';
3
- import { shouldPauseGate, getRiskSignals, classifyE2eSkip, planChecksPause, securityReviewFor, pausingRungs, migrationsTouched, contractsTouched, humanApprover, rungPause, planCritiquePause } from '../../lib/risk-detector.js';
3
+ import { shouldPauseGate, getRiskSignals, classifyE2eSkip, planChecksPause, securityReviewFor, pausingRungs, migrationsTouched, contractsTouched, humanApprover, rungPause, planCritiquePause, planAutoApprovalTodo, scenarioTitles, fillTodo, ASK_OWNER } from '../../lib/risk-detector.js';
4
+ import { GATE_NAME, featureRef } from '../../../framework/hooks/shared/owner-words.js';
5
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
4
6
  import { readPlanCritique } from '../../lib/plan/critique.js';
5
7
  import { reviewReports, reviewSignal, requiredReviewRoles, verifierMediaSection } from '../../lib/review-reports.js';
6
8
  import { featureDiffRisk } from '../../lib/risk/diff-risk.js';
@@ -63,14 +65,19 @@ export function collectReviewSignal(cwd, featureName, feature, planChecks = read
63
65
  return reviewSignal(reviewReports(cwd, featureName), { required, checkIds });
64
66
  }
65
67
 
66
- /** Why an automatic signature may not close the plan gate: the rule that makes gate-check pause it. */
68
+ /**
69
+ * Why an automatic signature may not close the plan gate: the rule that makes gate-check pause it.
70
+ * @returns {{ reason: string, todo: string|null }|null}
71
+ */
67
72
  export function planAutoApprovalBlock(cwd, featureName, feature) {
68
73
  const planChecks = readPlanChecks(cwd, featureName);
69
74
  const workType = feature?.workType || 'feature';
75
+ const planCritique = readPlanCritique(cwd, featureName, { workType, planChecks });
70
76
  const reason = planChecksPause(planChecks.status)
71
- ?? planCritiquePause(readPlanCritique(cwd, featureName, { workType, planChecks }))
77
+ ?? planCritiquePause(planCritique)
72
78
  ?? rungPause({ gate: 'plan', rungs: pausingRungs(planChecks.checks) })?.reason;
73
- return reason ? reason.replace('{feature}', featureName) : null;
79
+ if (!reason) return null;
80
+ return { reason, todo: fillTodo(planAutoApprovalTodo({ planChecks: planChecks.status, planCritique }), featureName, 'plan') ?? null };
74
81
  }
75
82
 
76
83
  // Collects only; risk-detector.js decides. `e2eStatus`/`e2eReason` exist because a skipped e2e
@@ -94,7 +101,10 @@ export function collectSignals(featureName, feature, cwd, gateName) {
94
101
  signals.planChecks = planChecks.status;
95
102
  signals.planCritique = readPlanCritique(cwd, featureName, { workType: signals.workType, planChecks });
96
103
  }
97
- if (gateName === 'plan' || gateName === 'review') signals.rungs = pausingRungs(planChecks.checks);
104
+ if (gateName === 'plan' || gateName === 'review') {
105
+ signals.rungs = pausingRungs(planChecks.checks);
106
+ signals.scenarios = scenarioTitles(planChecks.checks);
107
+ }
98
108
 
99
109
  // Só onde o checklist decide algo: no fecho do design e no ship.
100
110
  if (gateName === 'uiux' || gateName === 'review') {
@@ -142,14 +152,14 @@ export function collectSignals(featureName, feature, cwd, gateName) {
142
152
  export async function gateCheckCommand(featureName, gateName, options = {}) {
143
153
  try {
144
154
  if (!VALID_GATES.includes(gateName)) {
145
- console.error(chalk.red(`\n❌ Invalid gate: ${gateName}`));
146
- console.error(chalk.gray(`Valid gates: ${VALID_GATES.join(', ')}\n`));
155
+ console.error(chalk.red(`\n✗ Etapa de aprovação desconhecida: ${gateName}.`));
156
+ console.error(chalk.gray(` ${SESSION_MARK} use uma destas: ${VALID_GATES.join(', ')}\n`));
147
157
  process.exit(1);
148
158
  }
149
159
 
150
160
  const feature = getFeature(featureName);
151
161
  if (!feature) {
152
- console.error(chalk.red(`\n❌ Feature not found: ${featureName}\n`));
162
+ console.error(chalk.red(`\n✗ Funcionalidade não encontrada: ${featureName}.\n`));
153
163
  process.exit(1);
154
164
  }
155
165
 
@@ -168,20 +178,20 @@ export async function gateCheckCommand(featureName, gateName, options = {}) {
168
178
  try {
169
179
  parsed = JSON.parse(options.signals);
170
180
  } catch (err) {
171
- console.error(chalk.red(`\n❌ Invalid --signals: not valid JSON (${err.message})\n`));
181
+ console.error(chalk.red(`\n✗ --signals inválido: não é JSON (${err.message})\n`));
172
182
  process.exit(1);
173
183
  }
174
184
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
175
- console.error(chalk.red('\n❌ Invalid --signals: expected a JSON object, e.g. \'{"standardsViolations":[]}\'\n'));
185
+ console.error(chalk.red('\n✗ --signals inválido: precisa ser um objeto JSON, por exemplo \'{"standardsViolations":[]}\'\n'));
176
186
  process.exit(1);
177
187
  }
178
188
 
179
189
  const rejected = Object.keys(parsed).filter((k) => !OVERRIDABLE_SIGNAL_KEYS.includes(k));
180
190
  if (rejected.length > 0) {
181
191
  console.error(chalk.yellow(
182
- `\n⚠️ --signals ignored for keys not derived from disk-facts you may safely override: ${rejected.join(', ')}\n` +
183
- ` Only ${OVERRIDABLE_SIGNAL_KEYS.join(', ')} may be overridden here — everything else is read from feature.json/checks.json/git.\n` +
184
- ` Use \`morph-spec gate-decision\` directly for a fully manual decision.\n`
192
+ `\n⚠ --signals ignorado para: ${rejected.join(', ')}\n` +
193
+ ` ${SESSION_MARK} só ${OVERRIDABLE_SIGNAL_KEYS.join(', ')} entram por aqui; o resto é lido de feature.json/checks.json/git.` +
194
+ ' Para uma decisão toda manual, use `morph-spec gate-decision`.\n'
185
195
  ));
186
196
  }
187
197
  for (const key of OVERRIDABLE_SIGNAL_KEYS) {
@@ -197,36 +207,38 @@ export async function gateCheckCommand(featureName, gateName, options = {}) {
197
207
  const computed = shouldPauseGate({ trust }, signals);
198
208
  const manual = feature.gateDecisions?.[gateName];
199
209
  const manualPause = manual?.source === 'manual' && manual.pause === true;
200
- const { pause, reason, signal, resolver } = manualPause
201
- ? { pause: true, reason: manual.reason, signal: 'manual', resolver: 'human' }
202
- : computed;
210
+ const { pause, reason, signal, resolver, todo } = manualPause
211
+ ? { pause: true, reason: manual.reason, signal: 'manual', resolver: 'human',
212
+ todo: `${ASK_OWNER}; pausa manual: só depois que o dono liberar, grave \`morph-spec gate-decision ${featureName} ${gateName} --pause false\`` }
213
+ : { ...computed, todo: fillTodo(computed.todo, featureName, gateName) };
203
214
 
204
215
  const entry = await persistGateDecision(featureName, gateName, {
205
- pause, reason, signal, resolver, signals, trust, cwd, source: manualPause ? 'manual' : 'gate-check',
216
+ pause, reason, signal, resolver, todo, signals, trust, cwd, source: manualPause ? 'manual' : 'gate-check',
206
217
  });
207
218
 
219
+ const riskSignals = getRiskSignals(signals);
208
220
  if (options.json) {
209
- console.log(JSON.stringify({ feature: featureName, gate: gateName, ...entry }, null, 2));
221
+ console.log(JSON.stringify({ feature: featureName, gate: gateName, ...entry, riskSignals }, null, 2));
210
222
  return;
211
223
  }
212
224
 
213
- const allSignals = getRiskSignals(signals);
214
- console.log(!entry.pause
215
- ? chalk.green(`\n▶️ Gate "${gateName}" — auto-pass (${featureName})`)
216
- : entry.resolver === 'session'
217
- ? chalk.yellow(`\n🔧 Gate "${gateName}" — PAUSE, resolver: session (${featureName}): do what the reason says and run gate-check again`)
218
- : chalk.yellow(`\n⏸️ Gate "${gateName}" — PAUSE, resolver: human (${featureName})`));
219
- console.log(chalk.gray(` reason: ${entry.reason} | trust: ${entry.trust} | decidedAt: ${entry.decidedAt}`));
220
- if (manualPause) {
221
- console.log(chalk.gray(` pausa manual mantida (sinais calculados: ${computed.reason}); só \`morph-spec gate-decision ${featureName} ${gateName} --pause false\` a libera`));
225
+ const who = `${GATE_NAME[gateName]} de ${featureRef(featureName, feature, readPlanChecks(cwd, featureName).checks?.summary)}`;
226
+ if (!entry.pause) {
227
+ console.log(chalk.green(`\n✓ ${who}: segue sem parar.\n`));
228
+ return;
222
229
  }
223
- if (allSignals.length > 0) {
224
- console.log(chalk.gray(` risk signals present: ${allSignals.join('; ')}`));
230
+ console.log(entry.resolver === 'session'
231
+ ? chalk.yellow(`\n↻ ${who} parou: a sessão resolve e segue.`)
232
+ : chalk.yellow(`\n⏸ ${who} parou: espera você.`));
233
+ console.log(` Motivo: ${entry.reason}`);
234
+ if (manualPause) {
235
+ console.log(' A pausa foi registrada à mão e continua até alguém liberar.');
236
+ if (computed.pause) console.log(` Além disso: ${computed.reason}`);
225
237
  }
226
- console.log(chalk.gray(` signals: ${JSON.stringify(entry.signals)}`));
238
+ if (entry.todo) console.log(chalk.gray(` ${SESSION_MARK} ${entry.todo}`));
227
239
  console.log('');
228
240
  } catch (error) {
229
- console.error(chalk.red(`\n❌ Error running gate check: ${error.message}\n`));
241
+ console.error(chalk.red(`\n✗ Não deu para decidir a etapa: ${error.message}\n`));
230
242
  process.exit(1);
231
243
  }
232
244
  }
@@ -5,6 +5,9 @@ import { getFeature, updateFeature } from '../../core/state/state-manager.js';
5
5
  import { assertOwnerTree, ownerTreeRefusalLines } from '../../lib/worktree/feature-truth.js';
6
6
  import { mockupsHash } from '../../lib/specs/screen-checklist.js';
7
7
  import { recordGateEvent } from '../../../framework/hooks/shared/gate-event.js';
8
+ import { GATE_NAME } from '../../../framework/hooks/shared/owner-words.js';
9
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
10
+ import { ownerRef } from '../../../framework/hooks/shared/report-progress.js';
8
11
 
9
12
  export const VALID_GATES = ['plan', 'uiux', 'review'];
10
13
 
@@ -12,7 +15,7 @@ function parsePauseValue(raw) {
12
15
  const v = String(raw).toLowerCase();
13
16
  if (v === 'true') return true;
14
17
  if (v === 'false') return false;
15
- console.error(chalk.red(`\n❌ Invalid --pause: "${raw}" — expected true or false\n`));
18
+ console.error(chalk.red(`\n✗ --pause inválido: "${raw}" (use true ou false)\n`));
16
19
  process.exit(1);
17
20
  }
18
21
 
@@ -32,11 +35,12 @@ export function readTrustFromConfig() {
32
35
  * The ONE write path of `gateDecisions.{gate}`, shared by `gate-decision` and `gate-check`.
33
36
  * Does not validate `gateName`. A uiux decision records the `mockupsHash` it saw.
34
37
  */
35
- export async function persistGateDecision(featureName, gateName, { pause, reason, signal, resolver, signals = {}, trust, cwd = process.cwd(), source } = {}) {
38
+ export async function persistGateDecision(featureName, gateName, { pause, reason, signal, resolver, todo, signals = {}, trust, cwd = process.cwd(), source } = {}) {
36
39
  const entry = {
37
40
  pause,
38
41
  resolver: pause ? resolver ?? 'human' : null,
39
42
  reason: reason || (pause ? 'risco detectado' : 'nenhum sinal de risco'),
43
+ todo: pause && todo ? todo : null,
40
44
  signals,
41
45
  trust: trust || readTrustFromConfig(),
42
46
  decidedAt: new Date().toISOString(),
@@ -52,20 +56,20 @@ export async function persistGateDecision(featureName, gateName, { pause, reason
52
56
  export async function gateDecisionCommand(featureName, gateName, options = {}) {
53
57
  try {
54
58
  if (!VALID_GATES.includes(gateName)) {
55
- console.error(chalk.red(`\n❌ Invalid gate: ${gateName}`));
56
- console.error(chalk.gray(`Valid gates: ${VALID_GATES.join(', ')}\n`));
59
+ console.error(chalk.red(`\n✗ Etapa de aprovação desconhecida: ${gateName}.`));
60
+ console.error(chalk.gray(` ${SESSION_MARK} use uma destas: ${VALID_GATES.join(', ')}\n`));
57
61
  process.exit(1);
58
62
  }
59
63
 
60
64
  if (options.pause === undefined) {
61
- console.error(chalk.red('\n❌ --pause is required (true or false)\n'));
65
+ console.error(chalk.red('\n✗ Falta o --pause (true ou false)\n'));
62
66
  process.exit(1);
63
67
  }
64
68
  const pause = parsePauseValue(options.pause);
65
69
 
66
70
  const feature = getFeature(featureName);
67
71
  if (!feature) {
68
- console.error(chalk.red(`\n❌ Feature not found: ${featureName}\n`));
72
+ console.error(chalk.red(`\n✗ Funcionalidade não encontrada: ${featureName}.\n`));
69
73
  process.exit(1);
70
74
  }
71
75
 
@@ -82,11 +86,11 @@ export async function gateDecisionCommand(featureName, gateName, options = {}) {
82
86
  try {
83
87
  signals = JSON.parse(options.signals);
84
88
  } catch (err) {
85
- console.error(chalk.red(`\n❌ Invalid --signals: not valid JSON (${err.message})\n`));
89
+ console.error(chalk.red(`\n✗ --signals inválido: não é JSON (${err.message})\n`));
86
90
  process.exit(1);
87
91
  }
88
92
  if (!signals || typeof signals !== 'object' || Array.isArray(signals)) {
89
- console.error(chalk.red('\n❌ Invalid --signals: expected a JSON object, e.g. \'{"standardsViolations":[]}\'\n'));
93
+ console.error(chalk.red('\n✗ --signals inválido: precisa ser um objeto JSON, por exemplo \'{"standardsViolations":[]}\'\n'));
90
94
  process.exit(1);
91
95
  }
92
96
  }
@@ -105,14 +109,14 @@ export async function gateDecisionCommand(featureName, gateName, options = {}) {
105
109
  return;
106
110
  }
107
111
 
108
- console.log(chalk.green(`\n✅ Gate decision recorded: ${featureName}/${gateName} → pause: ${entry.pause}`));
109
- console.log(chalk.gray(` reason: ${entry.reason} | trust: ${entry.trust} | decidedAt: ${entry.decidedAt}`));
110
- if (Object.keys(entry.signals).length > 0) {
111
- console.log(chalk.gray(` signals: ${JSON.stringify(entry.signals)}`));
112
- }
112
+ const who = `${GATE_NAME[gateName]} de ${ownerRef(process.cwd(), featureName, feature)}`;
113
+ console.log(chalk.green(entry.pause
114
+ ? `\n⏸ Decisão registrada: ${who} para e espera você.`
115
+ : `\n✓ Decisão registrada: ${who} segue sem parar.`));
116
+ console.log(` Motivo: ${entry.reason}`);
113
117
  console.log('');
114
118
  } catch (error) {
115
- console.error(chalk.red(`\n❌ Error recording gate decision: ${error.message}\n`));
119
+ console.error(chalk.red(`\n✗ Não deu para registrar a decisão: ${error.message}\n`));
116
120
  process.exit(1);
117
121
  }
118
122
  }
@@ -9,6 +9,8 @@ import { isGitRepo } from '../project/worktree.js';
9
9
  import { morphBranches, currentBranch, branchView } from '../../lib/worktree/feature-truth.js';
10
10
  import { buildPrIndex } from '../../lib/git/pr-index.js';
11
11
  import { pendingPrFeatures, prForFeature } from '../../lib/git/pending-prs.js';
12
+ import { PHASE_NAME, WORK_NAME, featureName } from '../../../framework/hooks/shared/owner-words.js';
13
+ import { featureSummary } from '../../../framework/hooks/shared/report-progress.js';
12
14
 
13
15
  // Read-only: feature.json straight off disk, never `loadState` (which mutates). By default the
14
16
  // branch `morph/{f}` wins over a stale root copy; `--no-branch` reads only the disk.
@@ -42,7 +44,7 @@ function readWorktreePointer(fj) {
42
44
  }
43
45
 
44
46
  // Shared by the disk and branch reads so the two never drift on what counts as an anomaly.
45
- function shapeRow(name, fj, location, phase, { corruptDisk = false, worktree = null, source = 'disk', branch = null } = {}) {
47
+ function shapeRow(name, fj, location, phase, { corruptDisk = false, worktree = null, source = 'disk', branch = null, planName = null } = {}) {
46
48
  const gates = {};
47
49
  for (const g of G) gates[g] = fj.approvalGates?.[g]?.approved === true;
48
50
 
@@ -59,6 +61,7 @@ function shapeRow(name, fj, location, phase, { corruptDisk = false, worktree = n
59
61
  return {
60
62
  feature: name,
61
63
  name: fj.name || null,
64
+ planName,
62
65
  description: fj.description || null,
63
66
  workType: fj.workType || 'feature',
64
67
  status: fj.status || 'unknown',
@@ -83,6 +86,7 @@ function buildRow(name, fj, fdir, location) {
83
86
  worktree: readWorktreePointer(fj),
84
87
  source: 'disk',
85
88
  branch: null,
89
+ planName: featureSummary(fdir)?.name ?? null,
86
90
  });
87
91
  }
88
92
 
@@ -109,6 +113,7 @@ function resolveBranchTruth(cwd, rows) {
109
113
  rows[i] = shapeRow(row.feature, view.fj, row.location, phase, {
110
114
  corruptDisk: row.flags.includes('corrupt'),
111
115
  worktree: row.worktree, // root-owned — never trust the branch copy for this
116
+ planName: row.planName,
112
117
  source: 'branch',
113
118
  branch: featureBranch,
114
119
  });
@@ -160,10 +165,13 @@ function whereLabel(row) {
160
165
  return 'raiz';
161
166
  }
162
167
 
168
+ const PR_STATE = { open: 'aberto', merged: 'mergeado', closed: 'fechado' };
169
+ const STATUS_NAME = { draft: 'rascunho', in_progress: 'em andamento', completed: 'concluída', unknown: 'ilegível' };
170
+
163
171
  const prCell = (pr) => {
164
172
  if (!pr) return '-';
165
173
  const state = String(pr.state || '').toLowerCase();
166
- return `#${pr.number} ${state}`;
174
+ return `#${pr.number} ${PR_STATE[state] ?? state}`;
167
175
  };
168
176
 
169
177
  export function listCommand(options = {}) {
@@ -201,7 +209,7 @@ export function listCommand(options = {}) {
201
209
  }
202
210
 
203
211
  if (!rows.length) {
204
- console.log(chalk.gray('Nenhuma feature — .morph/features está vazio.'));
212
+ console.log(chalk.gray('Nenhuma funcionalidade neste projeto ainda.'));
205
213
  process.exit(0);
206
214
  }
207
215
 
@@ -210,26 +218,27 @@ export function listCommand(options = {}) {
210
218
  // `pr-pending` é trabalho em voo, não anomalia: segue em `flags` no `--json`, sem `⚠`.
211
219
  const warnFlags = (r) => r.flags.filter((f) => f !== 'pr-pending');
212
220
  console.log(chalk.white.bold(
213
- col('FEATURE', 22) + col('TYPE', 9) + col('STATUS', 13) + col('PHASE', 17) + col('WHERE', 22) + (showPr ? col('PR', 12) : '')
214
- + col('G1', 4) + col('Gd', 4) + col('G3', 4) + col('', 3) + 'DESCRIPTION',
221
+ col('FUNCIONALIDADE', 34) + col('TIPO', 20) + col('SITUAÇÃO', 14) + col('PASSO', 24) + col('ONDE', 22) + (showPr ? col('PR', 12) : '')
222
+ + col('Plano', 7) + col('Telas', 7) + col('Revisão', 9) + col('', 2) + 'ID',
215
223
  ));
216
224
  for (const r of rows) {
217
225
  const flag = warnFlags(r).length ? chalk.yellow('⚠') : ' ';
218
- const desc = r.location === 'pr-pending'
219
- ? chalk.yellow(`aguardando merge${r.pr?.ageDays != null ? ` há ${r.pr.ageDays}d` : ''} — sem cópia local`)
220
- : (r.selfAssessed ? chalk.yellow('[G3 self-assessed] ') : '')
221
- + (r.description ? truncate(r.description, 34) : chalk.yellow('(sem descrição)'));
226
+ const name = r.location === 'pr-pending'
227
+ ? `esperando o merge${r.pr?.ageDays != null ? ` há ${r.pr.ageDays}d` : ''}, sem cópia local`
228
+ : featureName(r.feature, { description: r.description }, r.planName ? { name: r.planName } : r.name && r.name !== r.feature ? { name: r.name } : null);
229
+ const note = r.selfAssessed ? chalk.yellow(' (revisão feita pela própria sessão)') : '';
222
230
  // padEnd counts the invisible color codes; pad the plain marks manually.
223
231
  console.log(
224
- col(r.feature, 22) + col(r.workType, 9) + col(r.status, 13) + col(r.phase, 17) + col(whereLabel(r), 22) + (showPr ? col(prCell(r.pr), 12) : '')
225
- + mark(r.gates.plan) + ' ' + mark(r.gates.uiux) + ' ' + mark(r.gates.review) + ' '
226
- + flag + ' ' + desc,
232
+ col(truncate(name, 33), 34) + col(WORK_NAME[r.workType] ?? r.workType, 20) + col(STATUS_NAME[r.status] ?? r.status, 14)
233
+ + col(r.phase === 'archived' ? 'Arquivada' : PHASE_NAME[r.phase] ?? r.phase, 24) + col(whereLabel(r), 22) + (showPr ? col(prCell(r.pr), 12) : '')
234
+ + mark(r.gates.plan) + ' ' + mark(r.gates.uiux) + ' ' + mark(r.gates.review) + ' '
235
+ + flag + ' ' + r.feature + note,
227
236
  );
228
237
  }
229
238
  const flagged = rows.filter((r) => warnFlags(r).length);
230
239
  if (flagged.length) {
231
- console.log(chalk.gray(`\n⚠ ${flagged.length} com inconsistência — rode 'morph-spec doctor' para detalhes.`));
240
+ console.log(chalk.gray(`\n⚠ ${flagged.length} com inconsistência. Para ver o que é: morph-spec doctor`));
232
241
  }
233
- console.log(chalk.gray(`\nG1=plan · Gd=uiux (design) · G3=review${options.all || options.archived ? ' · inclui arquivadas' : ''}`));
242
+ console.log(chalk.gray(`\nPlano, Telas e Revisão: ✓ aprovado · ainda não${options.all || options.archived ? '. Inclui as arquivadas.' : ''}`));
234
243
  process.exit(0);
235
244
  }
@@ -1,5 +1,4 @@
1
1
  import chalk from 'chalk';
2
- import { formatNext } from '../../../framework/hooks/shared/next-step.js';
3
2
  import { nextStepFor } from '../../lib/next-step.js';
4
3
  import { resolveFeatureTree } from '../../lib/worktree/feature-truth.js';
5
4
 
@@ -11,7 +10,8 @@ export function nextCommand(featureName, options = {}) {
11
10
  if (!next) {
12
11
  const error = owner.source === 'branch-only' ? 'feature-not-in-tree' : 'feature-not-found';
13
12
  if (options.json) console.log(JSON.stringify({ error, feature: featureName, branch: owner.branch ?? null }));
14
- else console.error(chalk.red(`\n❌ ${error}: ${featureName}${owner.branch ? ` (morph-spec worktree setup ${featureName})` : ''}\n`));
13
+ else if (owner.branch) console.error(chalk.red(`\n❌ A feature ${featureName} existe só na branch ${owner.branch}. Para trazê-la: morph-spec worktree setup ${featureName}\n`));
14
+ else console.error(chalk.red(`\n❌ Não achei a feature ${featureName} neste projeto.\n`));
15
15
  process.exit(1);
16
16
  }
17
17
 
@@ -19,7 +19,6 @@ export function nextCommand(featureName, options = {}) {
19
19
  console.log(JSON.stringify({ ...next, feature: featureName, tree: owner.tree }));
20
20
  return;
21
21
  }
22
- console.log(formatNext(next));
23
- for (const line of next.how ?? []) console.log(` ${line}`);
24
- if (owner.tree !== process.cwd()) console.log(chalk.gray(` árvore dona: ${owner.tree}`));
22
+ for (const line of next.retrato) console.log(line);
23
+ if (owner.tree !== process.cwd()) console.log(chalk.gray(`Pasta da feature: ${owner.tree}`));
25
24
  }
@@ -17,6 +17,9 @@ import { collectReviewRequirement } from './gate-check.js';
17
17
  import { featureGeneratesMedia } from '../../lib/plan/media.js';
18
18
  import { resolveBaseRef } from '../../lib/git/branch-classifier.js';
19
19
  import { reviewConfirmation } from '../../lib/review-confirmation.js';
20
+ import { nextStepFor } from '../../lib/next-step.js';
21
+ import { GATE_NAME, ROLE_NAME, VERDICT_SAY, labelFor } from '../../../framework/hooks/shared/owner-words.js';
22
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
20
23
 
21
24
  /** Each review report: complete when it carries a readable verdict and is not partial. */
22
25
  export function inspectReviewReports(cwd, feature) {
@@ -133,7 +136,7 @@ function commitLooseReports(cwd, feature) {
133
136
  const paths = loose.split('\n').map((line) => line.slice(3).trim()).filter(Boolean);
134
137
  try {
135
138
  execFileSync('git', ['add', '--', ...paths], { cwd, stdio: 'pipe' });
136
- execFileSync('git', ['commit', '-q', '-m', `chore(${feature}): relatórios do Gate 3`, '--', ...paths], { cwd, stdio: 'pipe' });
139
+ execFileSync('git', ['commit', '-q', '-m', `chore(${feature}): relatórios da revisão independente`, '--', ...paths], { cwd, stdio: 'pipe' });
137
140
  return paths;
138
141
  } catch {
139
142
  return [];
@@ -142,9 +145,11 @@ function commitLooseReports(cwd, feature) {
142
145
 
143
146
  export function reportCheckCommand(feature, options = {}) {
144
147
  const cwd = options.cwd || process.cwd();
148
+ const featureDir = join(cwd, '.morph', 'features', feature);
149
+ let progress = null;
145
150
  const emit = (obj, code) => {
146
151
  if (options.json) console.log(JSON.stringify(obj, null, 2));
147
- else printHuman(obj);
152
+ else printHuman(obj, { cwd, progress, planStatus: status });
148
153
  process.exit(code);
149
154
  };
150
155
 
@@ -152,8 +157,7 @@ export function reportCheckCommand(feature, options = {}) {
152
157
  if (!checks) {
153
158
  emit({ error: `feature "${feature}" sem 2-plan/checks.json legível (${status}) — rode morph-spec plan-check ${feature}`, feature }, 1);
154
159
  }
155
- const featureDir = join(cwd, '.morph', 'features', feature);
156
- const progress = implementProgress(featureDir);
160
+ progress = implementProgress(featureDir);
157
161
  const warnings = checksSpread(readOrEmpty(reportPath(featureDir))).map(({ id, files }) =>
158
162
  `${id} cita testes em ${files.length} arquivos (${files.join(', ')}): um teste por Cn, na camada mais baixa que o prova`);
159
163
  const implement = progress
@@ -168,53 +172,73 @@ export function reportCheckCommand(feature, options = {}) {
168
172
  }, 0);
169
173
  }
170
174
 
171
- function printHuman(obj) {
175
+ function reviewSay(r) {
176
+ if (!r.exists) return 'ainda não escrita';
177
+ if (r.complete) return VERDICT_SAY[r.verdict] ?? `sem veredito claro (${r.verdict ?? '-'})`;
178
+ return r.partial ? 'incompleto: o relatório diz que faltou parte' : 'incompleto: sem veredito';
179
+ }
180
+
181
+ function printHuman(obj, { cwd, progress, planStatus }) {
172
182
  if (obj.error) {
173
- console.error(chalk.red(`\n❌ ${obj.error}\n`));
183
+ console.error(chalk.red(`\n❌ O plano de ${obj.feature} ainda não foi conferido (${planStatus}).`));
184
+ console.error(chalk.gray(` ${SESSION_MARK} rode morph-spec plan-check ${obj.feature}\n`));
174
185
  return;
175
186
  }
176
- console.log(chalk.bold(`\n📄 report-check ${obj.feature}`));
187
+ console.log('');
188
+ let lines = null;
189
+ try { lines = nextStepFor(obj.feature, cwd)?.retrato ?? null; } catch { lines = null; }
177
190
  const impl = obj.implement;
191
+ if (lines) {
192
+ for (const line of lines) console.log(line);
193
+ } else if (impl) {
194
+ console.log(chalk.bold(obj.feature));
195
+ console.log(`Cenários: ${impl.done} de ${impl.total} feitos.`);
196
+ for (const id of impl.pending) console.log(` falta ${labelFor(progress?.checks, id)}`);
197
+ for (const id of impl.blocked) console.log(` travado ${labelFor(progress?.checks, id)}`);
198
+ }
178
199
  if (impl) {
179
- const open = [...impl.pending, ...impl.blocked];
180
- console.log(` ${open.length ? chalk.yellow('⚠') : chalk.green('✓')} report.md ${impl.done}/${impl.total} cenários feitos`
181
- + `${impl.pending.length ? ` · pendentes: ${impl.pending.join(', ')}` : ''}${impl.blocked.length ? ` · bloqueados: ${impl.blocked.join(', ')}` : ''}`);
182
- for (const w of impl.warnings) console.log(chalk.yellow(` ⚠ ${w}`));
200
+ for (const { id, files } of checksSpread(readOrEmpty(reportPath(join(cwd, '.morph', 'features', obj.feature))))) {
201
+ console.log(chalk.yellow(` ⚠ ${labelFor(progress?.checks, id)}: a prova cita testes em ${files.length} arquivos (${files.join(', ')}). Um teste por cenário basta.`));
202
+ }
183
203
  }
204
+
205
+ console.log('');
206
+ console.log(chalk.bold(`${GATE_NAME.review}:`));
184
207
  for (const [role, r] of Object.entries(obj.reviews ?? {})) {
185
208
  if (!r.exists && role === 'security') continue;
186
- console.log(
187
- ` ${r.complete ? chalk.green('✓') : chalk.yellow('⚠')} ${'Gate 3'.padEnd(6)} `
188
- + `${reviewFileName(role)} ${r.exists ? (r.complete ? `íntegro (${r.verdict})` : r.partial ? 'PARCIAL' : 'incompleto') : 'ausente'}`,
189
- );
209
+ const ok = r.complete && r.verdict === 'SHIP';
210
+ console.log(` ${ok ? chalk.green('✓') : chalk.yellow('⚠')} ${ROLE_NAME[role] ?? role}: ${reviewSay(r)}`);
190
211
  }
191
212
  if (obj.reviewModels) {
192
213
  const m = obj.reviewModels;
193
- console.log(chalk.gray(` dispatch: verifier ${m.verifier.model}, reviewer ${m.reviewer.model}${m.security.required ? `, security ${m.security.model}` : ''}`));
214
+ console.log(chalk.gray(` ${SESSION_MARK} dispatch verifier ${m.verifier.model}, reviewer ${m.reviewer.model}${m.security.required ? `, security ${m.security.model}` : ''}`));
194
215
  }
195
216
  if (obj.gate3) {
196
217
  const g = obj.gate3;
197
- console.log(chalk.gray(` gate 3: base ${g.base?.slice(0, 8) ?? '-'}, sha ${g.sha?.slice(0, 8) ?? '-'}`
218
+ console.log(chalk.gray(` ${SESSION_MARK} gate 3 base ${g.base?.slice(0, 8) ?? '-'}, sha ${g.sha?.slice(0, 8) ?? '-'}`
198
219
  + `${g.redispatch ? `, voltam: ${g.redispatch.join(', ') || 'nenhum'}` : ''}${g.flaky.length ? `, instáveis: ${g.flaky.join(', ')}` : ''}`));
199
220
  }
221
+ console.log('');
200
222
  printTree(obj.tree);
201
223
  console.log('');
202
224
  }
203
225
 
204
226
  function printTree(tree) {
205
227
  if (!tree) {
206
- console.log(chalk.gray(' árvore: fora de um repositório git — não conferida'));
228
+ console.log(chalk.gray('Código: a pasta não é um repositório git, então não deu para conferir.'));
207
229
  return;
208
230
  }
209
- const stat = tree.diffstat ? ` (+${tree.diffstat.insertions} −${tree.diffstat.deletions})` : '';
210
- console.log(` árvore ${tree.branch ?? '-'}@${tree.head ?? '-'}: ${tree.dirtyCount} arquivo(s) não commitado(s) fora de .morph/${stat}`);
231
+ const stat = tree.diffstat ? ` (+${tree.diffstat.insertions} −${tree.diffstat.deletions} linhas)` : '';
232
+ console.log(tree.dirtyCount
233
+ ? `Código: ${tree.dirtyCount} arquivo(s) mudaram e ainda não estão em commit${stat}. Branch ${tree.branch ?? '-'}, commit ${tree.head ?? '-'}.`
234
+ : `Código: tudo em commit. Branch ${tree.branch ?? '-'}, commit ${tree.head ?? '-'}.`);
211
235
  for (const d of tree.dirty.slice(0, 10)) console.log(chalk.gray(` ${d.status.padEnd(2)} ${d.path}`));
212
236
  if (tree.dirtyCount > 10) console.log(chalk.gray(` … e mais ${tree.dirtyCount - 10}`));
213
- if (tree.commits?.length) console.log(chalk.gray(` commits sobre a default: ${tree.commits.join(' · ')}`));
237
+ if (tree.commits?.length) console.log(chalk.gray(` Commits desta entrega: ${tree.commits.join(' · ')}`));
214
238
  const since = tree.sinceBeforeEval;
215
239
  if (since) {
216
240
  console.log(since.changedCount
217
- ? chalk.yellow(` ⚠ desde a foto de ${since.at}: ${since.changedCount} arquivo(s) mudaram — ${since.changed.join(', ')}`)
218
- : chalk.green(` ✓ nada mudou fora de .morph/ desde a foto de ${since.at}`));
241
+ ? chalk.yellow(` ⚠ Desde a foto tirada antes da revisão (${since.at}), ${since.changedCount} arquivo(s) mudaram: ${since.changed.join(', ')}`)
242
+ : chalk.green(` ✓ Nada mudou no código desde a foto tirada antes da revisão (${since.at}).`));
219
243
  }
220
244
  }
@@ -2,7 +2,8 @@ import chalk from 'chalk';
2
2
  import { existsSync, readFileSync } from 'fs';
3
3
  import { join } from 'path';
4
4
  import { atomicWriteJson } from '../../core/state/state-manager.js';
5
- import { isGateApproved } from '../../../framework/hooks/shared/state-reader.js';
5
+ import { getFeature, isGateApproved } from '../../../framework/hooks/shared/state-reader.js';
6
+ import { SESSION_MARK } from '../../../framework/hooks/shared/next-step.js';
6
7
  import { FEATURE_VIEW_FILE, getAbsoluteOutputPath } from '../../core/paths/output-schema.js';
7
8
  import { parsePlan } from '../../lib/plan/plan-parser.js';
8
9
  import { buildChecks, planHash, planRuleOptions, validatePlan } from '../../lib/plan/checks.js';
@@ -12,6 +13,11 @@ import { assertOwnerTree, ownerTreeRefusalLines } from '../../lib/worktree/featu
12
13
  import { seedDotnetBuildIgnores } from '../../lib/stack/dotnet-build-ignores.js';
13
14
  import { reportDotnetIgnores } from '../state/advance.js';
14
15
  import { syncStackRules } from '../../lib/installers/stack-sync.js';
16
+ import { ownerRef } from '../../../framework/hooks/shared/report-progress.js';
17
+
18
+ function nameOf(featureName) {
19
+ try { return ownerRef(process.cwd(), featureName, getFeature(featureName, process.cwd())); } catch { return featureName; }
20
+ }
15
21
 
16
22
  function readJson(path) {
17
23
  try { return JSON.parse(readFileSync(path, 'utf8')); } catch { return null; }
@@ -42,7 +48,7 @@ export function runPlanCheck(featureName, cwd = process.cwd()) {
42
48
  atomicWriteJson(checksPath, checks);
43
49
  const critique = critiqueByAgent(checks, text);
44
50
  return {
45
- ...result, ok: true, exit: 0, written: true, viewPath: join(cwd, '.morph', 'features', featureName, FEATURE_VIEW_FILE),
51
+ ...result, ok: true, exit: 0, written: true, scenarios: checks.checks.length, viewPath: join(cwd, '.morph', 'features', featureName, FEATURE_VIEW_FILE),
46
52
  critique: { by: critique.agent ? 'agent' : 'session', reasons: critique.reasons },
47
53
  };
48
54
  }
@@ -70,26 +76,36 @@ export function planCheckCommand(featureName, options = {}) {
70
76
  process.exit(result.exit);
71
77
  }
72
78
 
79
+ const ref = nameOf(featureName);
73
80
  if (result.error === 'plan-not-found') {
74
- console.error(chalk.red(`plan-check: ${result.plan} não existe — o create escreve o esqueleto em 2-plan/plan.md (chore/hotfix: você o cria); gramática completa: morph-spec plan-check --help`));
81
+ console.error(chalk.red(`O plano de ${ref} ainda não existe (${result.plan}).`));
82
+ console.error(chalk.gray(` ${SESSION_MARK} o create escreve o esqueleto em 2-plan/plan.md (chore/hotfix: você o cria); gramática completa: morph-spec plan-check --help`));
75
83
  process.exit(2);
76
84
  }
77
- for (const e of result.errors) console.log(chalk.red(` ✗ ${e}`));
78
- for (const w of result.warnings) console.log(chalk.yellow(` ⚠ ${w}`));
79
85
 
80
86
  if (result.error === 'frozen') {
81
- console.log(chalk.red(`✗ plan-check: o gate plan de ${featureName} está aprovado e o plan.md mudou fora da errata — checks.json congelado.`));
82
- console.log(chalk.gray(' Fato errado sobre o código: acrescente em ## Errata (não muda o planHash).'));
83
- console.log(chalk.gray(` Mudança real de escopo: morph-spec unapprove ${featureName} plan, rode plan-check e re-apresente o gate.`));
87
+ console.log(chalk.red(`✗ O plano de ${ref} já foi aprovado e o texto mudou depois.`));
88
+ console.log(chalk.red(' A versão aprovada continua valendo: ela fica congelada.'));
89
+ console.log(chalk.gray(' Se era um fato errado sobre o código, a correção vai em ## Errata, no fim do plano.'));
90
+ console.log(chalk.gray(' Se o que vai ser feito mudou, o plano volta para a sua aprovação.'));
91
+ console.log(chalk.gray(` ${SESSION_MARK} errata não muda o planHash; escopo novo → morph-spec unapprove ${featureName} plan, rode plan-check e reapresente o gate.`));
84
92
  } else if (!result.ok) {
85
- console.log(chalk.red(`✗ plan-check: ${result.errors.length} erro(s) em ${result.plan} — checks.json não foi gravado`));
86
- } else {
87
- console.log(chalk.green(`✓ plan-check: ${join('2-plan', 'checks.json')} gravado (${result.planHash.slice(0, 12)})`));
88
- console.log(chalk.gray(` página da feature: ${result.viewPath}`));
93
+ console.log(chalk.red(`✗ O plano de ${ref} tem ${result.errors.length} problema(s) para corrigir antes de seguir:`));
94
+ }
95
+ for (const e of result.errors) console.log(chalk.red(` ✗ ${e}`));
96
+ if (result.warnings.length) console.log(chalk.yellow(result.ok ? 'Pontos de atenção:' : 'Também vale olhar:'));
97
+ for (const w of result.warnings) console.log(chalk.yellow(` ⚠ ${w}`));
98
+
99
+ if (result.ok) {
100
+ console.log(chalk.green(`✓ Plano de ${ref} conferido: ${result.scenarios} cenário(s), pronto para aprovação.`));
101
+ console.log(chalk.gray(` Página da feature: ${result.viewPath}`));
89
102
  console.log(chalk.gray(result.critique.by === 'agent'
90
- ? ` crítica do plano: sub-agent em contexto fresco (${result.critique.reasons.join('; ')})`
91
- : ' crítica do plano: a própria sessão, com o checklist de grep (sem sinal de risco)'));
103
+ ? ` Quem revisa o plano: um revisor separado, que não viu a conversa (${result.critique.reasons.join('; ')}).`
104
+ : ' Quem revisa o plano: a própria sessão, com a lista de conferência (o plano não tem sinal de risco).'));
105
+ console.log(chalk.gray(` ${SESSION_MARK} ${join('2-plan', 'checks.json')} gravado (${result.planHash.slice(0, 12)})`));
92
106
  reportDotnetIgnores(gitignoreAdded);
107
+ } else if (!result.error) {
108
+ console.log(chalk.gray(` ${SESSION_MARK} corrija ${result.plan} e rode morph-spec plan-check ${featureName} de novo; checks.json não foi gravado.`));
93
109
  }
94
110
  process.exit(result.exit);
95
111
  }