@polymorphism-tech/morph-spec 10.12.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +27 -57
- package/README.md +51 -340
- package/bin/morph-spec.js +22 -373
- package/docs/CHEATSHEET.md +37 -166
- package/docs/QUICKSTART.md +14 -74
- package/framework/CLAUDE.md +15 -26
- package/framework/MORPH.md +34 -101
- package/framework/agents.json +8 -8
- package/framework/commands/morph-apply.md +5 -5
- package/framework/commands/morph-infra.md +1 -1
- package/framework/docs/CLI.md +74 -886
- package/framework/evals/review-checklist.md +14 -14
- package/framework/hooks/README.md +21 -189
- package/framework/hooks/claude-code/core/README.md +2 -5
- package/framework/hooks/claude-code/core/conventional-commit.js +2 -2
- package/framework/hooks/claude-code/core/denylist.json +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/hooks/claude-code/core/masked-exit.js +6 -6
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +17 -61
- package/framework/hooks/claude-code/core/stack-changed.js +35 -0
- package/framework/hooks/claude-code/core/validate-completion.js +31 -86
- package/framework/hooks/shared/{heavy-command.js → command-kind.js} +6 -79
- package/framework/hooks/shared/command-tokens.js +0 -139
- package/framework/hooks/shared/contract.js +14 -0
- package/framework/hooks/shared/feature-slug.js +21 -0
- package/framework/hooks/shared/frontend-locations.js +0 -1
- package/framework/hooks/shared/git-paths.js +0 -15
- package/framework/hooks/shared/graph-freshness.js +0 -19
- package/framework/hooks/shared/hook-response.js +0 -7
- package/framework/hooks/shared/morph-cli.js +2 -81
- package/framework/hooks/shared/owner-words.js +2 -120
- package/framework/hooks/shared/payload-utils.js +0 -39
- package/framework/hooks/shared/report-progress.js +7 -101
- package/framework/hooks/statusline.js +16 -60
- package/framework/mcp/registry.json +2 -2
- package/framework/rules/ai-agents-standards.md +1 -1
- package/framework/rules/asaas-standards.md +1 -1
- package/framework/rules/ef-standards.md +1 -1
- package/framework/rules/gsap-standards.md +1 -1
- package/framework/rules/hangfire-standards.md +1 -1
- package/framework/rules/implement-report.md +3 -3
- package/framework/rules/neon-auth-standards.md +1 -1
- package/framework/rules/nextjs-standards.md +1 -1
- package/framework/rules/plan-grammar.md +13 -11
- package/framework/rules/resend-standards.md +1 -1
- package/framework/rules/ui-design.md +4 -0
- package/framework/schemas/config.schema.json +95 -310
- package/framework/skills/README.md +12 -32
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +21 -46
- package/framework/skills/core/morph-plan/SKILL.md +28 -63
- package/framework/skills/core/morph-uiux/SKILL.md +23 -25
- package/framework/{templates/docs/ui-mockups.md → skills/core/morph-uiux/references/mockups.md} +4 -4
- package/framework/standards/STANDARDS.json +10 -11
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/evals-with-cache.md +18 -32
- package/framework/standards/ai-agents/observability-patterns.md +2 -2
- package/framework/standards/architecture/code-comments.md +2 -5
- package/framework/standards/architecture/engineering-lens.md +1 -1
- package/framework/standards/backend/dotnet/testing.md +4 -4
- package/framework/standards/frontend/nextjs/lint.md +24 -10
- package/framework/standards/frontend/nextjs/testing.md +2 -2
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +14 -30
- package/framework/templates/CLAUDE.md.core.guide.md +2 -2
- package/framework/templates/README.md +1 -1
- package/framework/templates/REGISTRY.json +3 -33
- package/framework/templates/docs/plan.md +3 -2
- package/framework/templates/dotnet/ai-kit/README.md +2 -4
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +1 -1
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +1 -1
- package/package.json +1 -2
- package/src/commands/graph/explain.js +2 -1
- package/src/commands/graph/status.js +2 -1
- package/src/commands/mcp/mcp-setup.js +1 -2
- package/src/commands/project/doctor.js +5 -341
- package/src/commands/project/env.js +21 -52
- package/src/commands/project/init-contract.js +47 -0
- package/src/commands/project/init.js +36 -66
- package/src/commands/project/stack-scan.js +1 -1
- package/src/commands/project/update.js +15 -50
- package/src/commands/validation/check.js +128 -0
- package/src/commands/validation/plan-check.js +41 -64
- package/src/commands/validation/prove-red.js +1 -1
- package/src/core/paths/output-schema.js +0 -22
- package/src/core/templates/template-renderer.js +0 -14
- package/src/lib/ai/ai-project-scan.js +1 -6
- package/src/lib/check/attempts.js +38 -0
- package/src/lib/check/signals.js +145 -0
- package/src/lib/config/project-config.js +13 -0
- package/src/lib/contract/apply.js +62 -0
- package/src/lib/contract/defaults.js +96 -0
- package/src/lib/contract/merge.js +79 -0
- package/src/lib/contract/ports.js +43 -0
- package/src/lib/contract/scan.js +102 -0
- package/src/lib/detectors/claude-config-detector.js +7 -0
- package/src/lib/{procs → detectors}/mcp-config.js +1 -37
- package/src/lib/diff/diff-lines.js +64 -0
- package/src/lib/generators/architecture-scanner.js +1 -1
- package/src/lib/generators/scaffold-generator.js +0 -7
- package/src/lib/git/default-branch.js +0 -122
- package/src/lib/graph/diff-tree.js +2 -1
- package/src/lib/graph/god-nodes.js +2 -1
- package/src/lib/graph/graphify-runtime.js +0 -1
- package/src/lib/graph/graphifyignore.js +1 -1
- package/src/lib/graph/sanitize.js +2 -8
- package/src/lib/installers/memory-installer.js +15 -30
- package/src/lib/installers/stack-sync.js +16 -9
- package/src/lib/plan/checks.js +20 -64
- package/src/lib/plan/media.js +1 -1
- package/src/lib/plan/plan-parser.js +5 -5
- package/src/lib/review-reports.js +3 -77
- package/src/lib/scan/worktree-dirs.js +3 -0
- package/src/lib/specs/adr-index.js +2 -2
- package/src/lib/stack/dotnet-build-ignores.js +10 -2
- package/src/lib/stack/stack-scan.js +2 -2
- package/src/lib/stack-filter.js +3 -2
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/scripts/setup-infra.js +6 -59
- package/src/utils/agents-installer.js +1 -34
- package/src/utils/atomic-json.js +27 -0
- package/src/utils/file-copier.js +4 -12
- package/src/utils/hooks-installer.js +9 -107
- package/claude-plugin.json +0 -14
- package/framework/commands/morph-archive.md +0 -46
- package/framework/commands/morph-hotfix.md +0 -17
- package/framework/commands/morph-preflight.md +0 -180
- package/framework/commands/morph-review.md +0 -15
- package/framework/commands/morph-status.md +0 -37
- package/framework/hooks/claude-code/core/block-destructive-worktree-removal.js +0 -80
- package/framework/hooks/claude-code/core/block-raw-worktree-add.js +0 -72
- package/framework/hooks/claude-code/core/enforce-phase-writes.js +0 -100
- package/framework/hooks/claude-code/core/gate-guard.js +0 -148
- package/framework/hooks/claude-code/core/heavy-gate.js +0 -78
- package/framework/hooks/claude-code/core/heavy-release.js +0 -23
- package/framework/hooks/claude-code/core/loop-detect.js +0 -79
- package/framework/hooks/claude-code/core/state-sync.js +0 -214
- package/framework/hooks/claude-code/core/telemetry-log.js +0 -259
- package/framework/hooks/claude-code/core/test-budget.js +0 -29
- package/framework/hooks/claude-code/core/worktree-context.js +0 -249
- package/framework/hooks/claude-code/core/worktree-create.js +0 -119
- package/framework/hooks/claude-code/core/worktree-env-inject.js +0 -68
- package/framework/hooks/claude-code/core/worktree-remove.js +0 -55
- package/framework/hooks/shared/build-check.js +0 -120
- package/framework/hooks/shared/claim-registry.js +0 -125
- package/framework/hooks/shared/e2e-check.js +0 -1022
- package/framework/hooks/shared/feature-locator.js +0 -82
- package/framework/hooks/shared/gate-event.js +0 -18
- package/framework/hooks/shared/gate-question.js +0 -20
- package/framework/hooks/shared/heavy-config.js +0 -113
- package/framework/hooks/shared/heavy-holders.js +0 -85
- package/framework/hooks/shared/heavy-slots.js +0 -280
- package/framework/hooks/shared/host-services.js +0 -440
- package/framework/hooks/shared/next-step.js +0 -181
- package/framework/hooks/shared/redact-secrets.js +0 -44
- package/framework/hooks/shared/reparse-scan.js +0 -40
- package/framework/hooks/shared/state-reader.js +0 -220
- package/framework/hooks/shared/state-writer.js +0 -112
- package/framework/hooks/shared/telemetry-logger.js +0 -101
- package/framework/hooks/shared/transcript-usage.js +0 -58
- package/framework/hooks/shared/worktree-root.js +0 -71
- package/framework/phases.json +0 -92
- package/framework/schemas/feature.schema.json +0 -242
- package/framework/skills/core/morph-apply/references/hotfix.md +0 -46
- package/framework/skills/core/morph-apply/references/machine.md +0 -30
- package/framework/skills/core/morph-apply/references/review.md +0 -77
- package/framework/skills/core/morph-plan/references/critique.md +0 -51
- package/framework/skills/core/morph-plan/references/interview.md +0 -37
- package/framework/templates/state.template.json +0 -17
- package/src/commands/dashboard/dashboard.js +0 -74
- package/src/commands/e2e/e2e.js +0 -400
- package/src/commands/observability/cost.js +0 -283
- package/src/commands/project/branch.js +0 -129
- package/src/commands/project/claim.js +0 -132
- package/src/commands/project/doctor-procs.js +0 -162
- package/src/commands/project/fleet.js +0 -66
- package/src/commands/project/heavy.js +0 -81
- package/src/commands/project/install-plugin-cmd.js +0 -27
- package/src/commands/project/status.js +0 -61
- package/src/commands/project/worktree.js +0 -1234
- package/src/commands/state/advance.js +0 -248
- package/src/commands/state/approve.js +0 -303
- package/src/commands/state/archive.js +0 -231
- package/src/commands/state/auto-approval.js +0 -67
- package/src/commands/state/create.js +0 -274
- package/src/commands/state/delete.js +0 -192
- package/src/commands/state/finish.js +0 -1247
- package/src/commands/state/gate-check.js +0 -244
- package/src/commands/state/gate-decision.js +0 -122
- package/src/commands/state/list.js +0 -244
- package/src/commands/state/next.js +0 -24
- package/src/commands/state/recap.js +0 -80
- package/src/commands/state/report-check.js +0 -244
- package/src/commands/state/retype.js +0 -110
- package/src/commands/validation/verify.js +0 -421
- package/src/core/state/feature-identity.js +0 -10
- package/src/core/state/gate-order.js +0 -23
- package/src/core/state/lifecycle-audit.js +0 -171
- package/src/core/state/state-manager.js +0 -523
- package/src/core/templates/template-seed.js +0 -21
- package/src/core/work-types.js +0 -44
- package/src/dashboard/app/App.jsx +0 -84
- package/src/dashboard/app/components/ActivityFeed.jsx +0 -166
- package/src/dashboard/app/components/CommandPalette.jsx +0 -144
- package/src/dashboard/app/components/DetailPanel.jsx +0 -43
- package/src/dashboard/app/components/EntityLink.jsx +0 -42
- package/src/dashboard/app/components/ErrorBoundary.jsx +0 -47
- package/src/dashboard/app/components/FlowGraph.jsx +0 -19
- package/src/dashboard/app/components/GatePauses.jsx +0 -116
- package/src/dashboard/app/components/KnowledgeMarkdown.jsx +0 -42
- package/src/dashboard/app/components/Markdown.jsx +0 -38
- package/src/dashboard/app/components/PhaseRail.jsx +0 -100
- package/src/dashboard/app/components/SearchFilter.jsx +0 -36
- package/src/dashboard/app/components/SessionMap.jsx +0 -77
- package/src/dashboard/app/components/Sidebar.jsx +0 -147
- package/src/dashboard/app/hooks/useMorphQuery.js +0 -44
- package/src/dashboard/app/hooks/usePref.js +0 -34
- package/src/dashboard/app/lib/format.js +0 -69
- package/src/dashboard/app/lib/phases.js +0 -75
- package/src/dashboard/app/lib/project.js +0 -38
- package/src/dashboard/app/main.jsx +0 -13
- package/src/dashboard/app/pages/Activity.jsx +0 -28
- package/src/dashboard/app/pages/AgentMap.jsx +0 -363
- package/src/dashboard/app/pages/FeatureDetail.jsx +0 -579
- package/src/dashboard/app/pages/Features.jsx +0 -393
- package/src/dashboard/app/pages/Guide.jsx +0 -145
- package/src/dashboard/app/pages/HookInspector.jsx +0 -444
- package/src/dashboard/app/pages/PhasePipeline.jsx +0 -273
- package/src/dashboard/app/pages/Portfolio.jsx +0 -190
- package/src/dashboard/app/pages/RulesMap.jsx +0 -285
- package/src/dashboard/app/pages/SkillsLibrary.jsx +0 -468
- package/src/dashboard/app/pages/Standards.jsx +0 -392
- package/src/dashboard/app/styles/index.css +0 -187
- package/src/dashboard/index.html +0 -14
- package/src/dashboard/package.json +0 -32
- package/src/dashboard/scanner/activity-scanner.js +0 -321
- package/src/dashboard/scanner/agents-scanner.js +0 -67
- package/src/dashboard/scanner/docs-scanner.js +0 -34
- package/src/dashboard/scanner/feature-status.js +0 -7
- package/src/dashboard/scanner/features-scanner.js +0 -397
- package/src/dashboard/scanner/hooks-scanner.js +0 -96
- package/src/dashboard/scanner/index.js +0 -21
- package/src/dashboard/scanner/phases-scanner.js +0 -14
- package/src/dashboard/scanner/portfolio.js +0 -129
- package/src/dashboard/scanner/project-api.js +0 -160
- package/src/dashboard/scanner/rules-scanner.js +0 -46
- package/src/dashboard/scanner/skills-scanner.js +0 -104
- package/src/dashboard/scanner/standards-scanner.js +0 -38
- package/src/dashboard/vite-plugin-morph-data.js +0 -120
- package/src/dashboard/vite.config.js +0 -26
- package/src/lib/ci/ci-verify.js +0 -30
- package/src/lib/ci/github-ci.js +0 -52
- package/src/lib/ci/pr-checks.js +0 -76
- package/src/lib/e2e/applicability.js +0 -39
- package/src/lib/e2e/compose-env.js +0 -80
- package/src/lib/e2e/stack-teardown.js +0 -96
- package/src/lib/git/branch-classifier.js +0 -104
- package/src/lib/git/evidence-staleness.js +0 -40
- package/src/lib/git/gh.js +0 -15
- package/src/lib/git/pending-prs.js +0 -58
- package/src/lib/git/pr-files.js +0 -31
- package/src/lib/git/pr-index.js +0 -39
- package/src/lib/git/tree-fingerprint.js +0 -58
- package/src/lib/git/tree-state.js +0 -125
- package/src/lib/heavy/cleanup.js +0 -72
- package/src/lib/heavy/gate.js +0 -168
- package/src/lib/heavy/live-stacks.js +0 -64
- package/src/lib/heavy/reclaim.js +0 -107
- package/src/lib/heavy/watchdog.js +0 -46
- package/src/lib/next-step.js +0 -12
- package/src/lib/plan/critique.js +0 -67
- package/src/lib/plan/plan-template.js +0 -18
- package/src/lib/procs/classify.js +0 -91
- package/src/lib/procs/list.js +0 -124
- package/src/lib/procs/prune.js +0 -47
- package/src/lib/procs/wslconfig.js +0 -70
- package/src/lib/projects/registry.js +0 -121
- package/src/lib/recap/piper.js +0 -36
- package/src/lib/recap/recap.js +0 -259
- package/src/lib/review-confirmation.js +0 -66
- package/src/lib/risk/diff-risk.js +0 -137
- package/src/lib/risk-detector.js +0 -638
- package/src/lib/specs/design-seed.js +0 -18
- package/src/lib/specs/screen-checklist.js +0 -315
- package/src/lib/stack/stack-profile.js +0 -69
- package/src/lib/tasks/eval-node.js +0 -293
- package/src/lib/tasks/linux-runner.js +0 -200
- package/src/lib/tasks/test-nodes.js +0 -414
- package/src/lib/tasks/test-runner.js +0 -569
- package/src/lib/telemetry/metrics.js +0 -384
- package/src/lib/telemetry/telemetry-reader.js +0 -276
- package/src/lib/telemetry/verify-event.js +0 -57
- package/src/lib/validators/code-budget/code-budget-validator.js +0 -170
- package/src/lib/validators/contracts/contract-compliance-validator.js +0 -219
- package/src/lib/validators/nextjs/next-component-validator.js +0 -142
- package/src/lib/validators/packages/package-validator.js +0 -310
- package/src/lib/validators/reuse/reuse-validator.js +0 -202
- package/src/lib/validators/reuse/symbol-scanner.js +0 -64
- package/src/lib/validators/validation-runner.js +0 -188
- package/src/lib/validators/verify-cache.js +0 -63
- package/src/lib/validators/verify-runner.js +0 -971
- package/src/lib/verify/affected.js +0 -143
- package/src/lib/verify/detached.js +0 -159
- package/src/lib/view/feature-html.js +0 -480
- package/src/lib/view/feature-page.client.js +0 -109
- package/src/lib/view/feature-page.css +0 -278
- package/src/lib/view/feature-view.js +0 -113
- package/src/lib/view/flow-layers.js +0 -79
- package/src/lib/view/flow-svg.js +0 -63
- package/src/lib/view/tokens.css +0 -18
- package/src/lib/work-type-detector.js +0 -81
- package/src/lib/worktree/dirs.js +0 -3
- package/src/lib/worktree/docker-audit.js +0 -175
- package/src/lib/worktree/env-allocator.js +0 -177
- package/src/lib/worktree/feature-truth.js +0 -145
- package/src/lib/worktree/finish-backup.js +0 -529
- package/src/lib/worktree/fleet-scanner.js +0 -223
- package/src/lib/worktree/ignored-triage.js +0 -136
- package/src/lib/worktree/vscode-settings.js +0 -112
- package/src/lib/worktree/worktree-audit.js +0 -323
- package/src/lib/worktree/worktree-include.js +0 -44
- package/src/scripts/install-plugin.js +0 -114
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
-
import { tmpdir } from 'os';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import { buildRecap, changeSummary, recapScenes, renderRecapHtml } from '../../lib/recap/recap.js';
|
|
6
|
-
import { writeFeatureView } from '../../lib/view/feature-view.js';
|
|
7
|
-
import { FEATURE_VIEW_FILE } from '../../core/paths/output-schema.js';
|
|
8
|
-
import { narrateWithPiper, resolvePiper } from '../../lib/recap/piper.js';
|
|
9
|
-
import { aggregateCost, loadTelemetry } from '../../lib/telemetry/telemetry-reader.js';
|
|
10
|
-
|
|
11
|
-
export const RECAP_FILES = { html: FEATURE_VIEW_FILE, data: 'recap.json' };
|
|
12
|
-
|
|
13
|
-
/** Every token the feature's sessions and agents spent, from the telemetry of this tree; null when none was logged. */
|
|
14
|
-
export function tokensSpent(cwd, feature) {
|
|
15
|
-
try {
|
|
16
|
-
const cost = aggregateCost(loadTelemetry(cwd), { feature });
|
|
17
|
-
const sum = (u) => (u ? u.inputTokens + u.outputTokens + u.cacheReadTokens + u.cacheCreationTokens : 0);
|
|
18
|
-
return sum(cost.sessionUsage) + sum(cost.agentUsage) || null;
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Writes `recap.json` and the page with the recap inside into `targetDir`, from the live feature folder. Never throws. */
|
|
25
|
-
export function writeRecap(featureDir, targetDir, feature, { cwd }) {
|
|
26
|
-
try {
|
|
27
|
-
const data = { ...buildRecap(featureDir, feature, { changes: changeSummary(cwd) }), tokens: tokensSpent(cwd, feature) };
|
|
28
|
-
writeFileSync(join(targetDir, RECAP_FILES.data), JSON.stringify(data, null, 2));
|
|
29
|
-
return writeFeatureView(targetDir, feature, { changes: data.changes, archived: true });
|
|
30
|
-
} catch (err) {
|
|
31
|
-
return { ok: false, reason: err.message };
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Active feature: rebuilt from its folder and the branch diff. Archived: the data the finish froze,
|
|
36
|
-
// since the archive keeps neither the reports nor the branch.
|
|
37
|
-
export function recapCommand(feature, options = {}) {
|
|
38
|
-
const cwd = options.path || process.cwd();
|
|
39
|
-
const active = join(cwd, '.morph', 'features', feature);
|
|
40
|
-
const archived = join(cwd, '.morph', 'archive', feature);
|
|
41
|
-
let data;
|
|
42
|
-
let dir;
|
|
43
|
-
if (existsSync(active)) {
|
|
44
|
-
dir = active;
|
|
45
|
-
data = { ...buildRecap(active, feature, { changes: changeSummary(cwd) }), tokens: tokensSpent(cwd, feature) };
|
|
46
|
-
writeFileSync(join(dir, RECAP_FILES.data), JSON.stringify(data, null, 2));
|
|
47
|
-
} else if (existsSync(join(archived, RECAP_FILES.data))) {
|
|
48
|
-
dir = archived;
|
|
49
|
-
data = JSON.parse(readFileSync(join(archived, RECAP_FILES.data), 'utf8'));
|
|
50
|
-
} else {
|
|
51
|
-
const payload = { ok: false, reason: existsSync(archived) ? 'archived-without-recap' : 'feature-not-found' };
|
|
52
|
-
if (options.json) console.log(JSON.stringify(payload));
|
|
53
|
-
else console.error(chalk.yellow(`\n○ ${payload.reason === 'feature-not-found' ? `Feature "${feature}" não existe.` : `"${feature}" foi arquivada antes do recap existir.`}\n`));
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let narration = 'sistema';
|
|
58
|
-
let path = join(dir, RECAP_FILES.html);
|
|
59
|
-
let note = null;
|
|
60
|
-
if (options.piper) {
|
|
61
|
-
const piper = resolvePiper();
|
|
62
|
-
const audio = piper.ok ? narrateWithPiper(recapScenes(data), piper) : null;
|
|
63
|
-
if (audio) {
|
|
64
|
-
// Audio is megabytes: it goes to a temp file, never into the committed archive.
|
|
65
|
-
path = join(tmpdir(), `morph-recap-${feature}.html`);
|
|
66
|
-
writeFileSync(path, renderRecapHtml(data, { audio }));
|
|
67
|
-
narration = 'piper';
|
|
68
|
-
} else {
|
|
69
|
-
note = piper.ok ? 'o piper falhou numa cena — ficou a voz do sistema' : piper.reason;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (narration === 'sistema') writeFeatureView(dir, feature, { changes: data.changes ?? null, archived: dir === archived });
|
|
73
|
-
|
|
74
|
-
if (options.json) {
|
|
75
|
-
console.log(JSON.stringify({ ok: true, path, narration, note }));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
console.log(chalk.green(`\n✅ Recap de ${feature}: ${path}`));
|
|
79
|
-
console.log(chalk.gray(` narração: ${narration === 'piper' ? 'Piper (áudio embutido)' : 'voz do sistema, pelo navegador'}${note ? ` — ${note}` : ''}\n`));
|
|
80
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { execFileSync } from 'child_process';
|
|
3
|
-
import { existsSync, readFileSync } from 'fs';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import { implementProgress, parseReport, reportPath } from '../../../framework/hooks/shared/report-progress.js';
|
|
6
|
-
import { treeState, snapshotTree } from '../../lib/git/tree-state.js';
|
|
7
|
-
import { atomicWriteJson } from '../../core/state/state-manager.js';
|
|
8
|
-
import { minimatch } from 'minimatch';
|
|
9
|
-
import { reviewReports, reviewFileName } from '../../lib/review-reports.js';
|
|
10
|
-
import { verifierModelFor } from '../../lib/risk-detector.js';
|
|
11
|
-
import { changedPathsAgainst, detectDefaultBranch } from '../../lib/git/default-branch.js';
|
|
12
|
-
import { readMorphConfig } from '../../lib/tasks/test-runner.js';
|
|
13
|
-
import { readPlanChecks } from '../../lib/plan/checks.js';
|
|
14
|
-
import { isTestPath } from '../../lib/graph/sanitize.js';
|
|
15
|
-
import { getAbsoluteOutputPath } from '../../core/paths/output-schema.js';
|
|
16
|
-
import { collectReviewRequirement } from './gate-check.js';
|
|
17
|
-
import { featureGeneratesMedia } from '../../lib/plan/media.js';
|
|
18
|
-
import { resolveBaseRef } from '../../lib/git/branch-classifier.js';
|
|
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';
|
|
23
|
-
|
|
24
|
-
/** Each review report: complete when it carries a readable verdict and is not partial. */
|
|
25
|
-
export function inspectReviewReports(cwd, feature) {
|
|
26
|
-
const out = {};
|
|
27
|
-
for (const [role, r] of Object.entries(reviewReports(cwd, feature))) {
|
|
28
|
-
out[role] = r.status === 'missing'
|
|
29
|
-
? { exists: false, complete: false, partial: false, verdict: null }
|
|
30
|
-
: { exists: true, complete: r.status === 'ok', partial: r.status === 'partial', verdict: r.verdict ?? null };
|
|
31
|
-
}
|
|
32
|
-
return out;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function readOrEmpty(path) {
|
|
36
|
-
try { return existsSync(path) ? readFileSync(path, 'utf8') : ''; } catch { return ''; }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// The verifier routes to opus on prompt/model or media; security is dispatched only when required.
|
|
40
|
-
function reviewDispatch(cwd, feature) {
|
|
41
|
-
let changedFiles = [];
|
|
42
|
-
try { changedFiles = changedPathsAgainst(detectDefaultBranch(cwd), cwd); } catch { changedFiles = []; }
|
|
43
|
-
const watch = readMorphConfig(cwd)?.project?.evals?.watch;
|
|
44
|
-
const globs = Array.isArray(watch) ? watch.filter((g) => typeof g === 'string' && g.trim()) : [];
|
|
45
|
-
let workType;
|
|
46
|
-
try { workType = JSON.parse(readFileSync(join(cwd, '.morph', 'features', feature, 'feature.json'), 'utf8')).workType; } catch { workType = undefined; }
|
|
47
|
-
const { required, security, risk } = collectReviewRequirement(cwd, { workType });
|
|
48
|
-
// A confirmation re-judges a delta against scenarios already proven: never the expensive model.
|
|
49
|
-
const confirming = Object.values(reviewReports(cwd, feature)).some((r) => r.status !== 'missing');
|
|
50
|
-
return {
|
|
51
|
-
required,
|
|
52
|
-
risk,
|
|
53
|
-
selfReview: ['low', 'none'].includes(risk?.level) && workType !== 'hotfix',
|
|
54
|
-
verifier: confirming
|
|
55
|
-
? { model: 'sonnet', reasons: ['confirmação de delta'] }
|
|
56
|
-
: verifierModelFor({
|
|
57
|
-
promptModelTouched: changedFiles.some((f) => globs.some((g) => minimatch(f, g))),
|
|
58
|
-
generatesMedia: featureGeneratesMedia(readOrEmpty(getAbsoluteOutputPath(cwd, feature, 'plan'))),
|
|
59
|
-
}),
|
|
60
|
-
reviewer: { model: 'sonnet', reasons: [] },
|
|
61
|
-
security: { required: security.required, model: 'opus', reasons: security.reasons },
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const slash = (p) => String(p || '').replace(/\\/g, '/');
|
|
66
|
-
const isTestRef = (p) => isTestPath(p) || /\.(test|spec)\.[a-z]+$|Tests?\.cs$/i.test(p);
|
|
67
|
-
|
|
68
|
-
/** Cn whose evidence in the report cites tests in more than one file, as `{ id, files }`. */
|
|
69
|
-
export function checksSpread(reportText) {
|
|
70
|
-
const spread = [];
|
|
71
|
-
for (const [id, { evidence }] of parseReport(reportText)) {
|
|
72
|
-
const files = [...new Set((evidence.match(/[\w@./\\-]+\.[A-Za-z]+/g) ?? []).map(slash).filter(isTestRef))];
|
|
73
|
-
if (files.length > 1) spread.push({ id, files });
|
|
74
|
-
}
|
|
75
|
-
return spread;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function snapshotPath(cwd, feature) {
|
|
79
|
-
return join(cwd, '.morph', 'features', feature, '4-review', 'tree-before-eval.json');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// `beforeEval` snapshots after comparing, so the output still shows what changed since the last one.
|
|
83
|
-
function treeFor(cwd, feature, beforeEval) {
|
|
84
|
-
const path = snapshotPath(cwd, feature);
|
|
85
|
-
let snapshot = null;
|
|
86
|
-
try { if (existsSync(path)) snapshot = JSON.parse(readFileSync(path, 'utf8')); } catch { snapshot = null; }
|
|
87
|
-
const tree = treeState(cwd, { snapshot });
|
|
88
|
-
if (!beforeEval) return { tree };
|
|
89
|
-
const reviewModels = reviewDispatch(cwd, feature);
|
|
90
|
-
const gate3 = gate3Briefing(cwd, feature);
|
|
91
|
-
const next = snapshotTree(cwd);
|
|
92
|
-
if (!next) return { tree, beforeEval: null, reviewModels, gate3 };
|
|
93
|
-
atomicWriteJson(path, next);
|
|
94
|
-
return { tree, beforeEval: { at: next.at, files: Object.keys(next.files).length }, reviewModels, gate3 };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function gitLine(cwd, args) {
|
|
98
|
-
try {
|
|
99
|
-
return execFileSync('git', args, { cwd, stdio: 'pipe' }).toString().trim() || null;
|
|
100
|
-
} catch {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function readVerification(cwd, feature) {
|
|
106
|
-
try {
|
|
107
|
-
return JSON.parse(readFileSync(join(cwd, '.morph', 'features', feature, 'feature.json'), 'utf8')).verification ?? null;
|
|
108
|
-
} catch {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// What every dispatch needs, in one read. `redispatch: null` = no report yet, every required role goes.
|
|
114
|
-
function gate3Briefing(cwd, feature) {
|
|
115
|
-
const sha = gitLine(cwd, ['rev-parse', 'HEAD']);
|
|
116
|
-
const defaultRef = resolveBaseRef(detectDefaultBranch(cwd), cwd);
|
|
117
|
-
const reports = reviewReports(cwd, feature);
|
|
118
|
-
const anyReport = Object.values(reports).some((report) => report.status !== 'missing');
|
|
119
|
-
const moved = anyReport && sha ? reviewConfirmation(cwd, reports, sha).moved : [];
|
|
120
|
-
const { checks } = readPlanChecks(cwd, feature);
|
|
121
|
-
return {
|
|
122
|
-
base: defaultRef ? gitLine(cwd, ['merge-base', defaultRef, 'HEAD']) : null,
|
|
123
|
-
sha,
|
|
124
|
-
flaky: readVerification(cwd, feature)?.flaky ?? [],
|
|
125
|
-
e2eChecks: (checks?.checks ?? []).filter((check) => check.proof === 'e2e').map((check) => check.id),
|
|
126
|
-
redispatch: anyReport ? moved.filter((role) => !role.skippable).map((role) => role.role) : null,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// An agent writes its report and never commits: left loose it rides into whatever commit comes next, and
|
|
131
|
-
// a revert of that commit takes the report with it. Only these files, in a commit of their own.
|
|
132
|
-
function commitLooseReports(cwd, feature) {
|
|
133
|
-
const rels = Object.keys(reviewReports(cwd, feature)).map((role) => `.morph/features/${feature}/4-review/${reviewFileName(role)}`);
|
|
134
|
-
const loose = gitLine(cwd, ['status', '--porcelain', '--untracked-files=all', '--', ...rels]);
|
|
135
|
-
if (!loose) return [];
|
|
136
|
-
const paths = loose.split('\n').map((line) => line.slice(3).trim()).filter(Boolean);
|
|
137
|
-
try {
|
|
138
|
-
execFileSync('git', ['add', '--', ...paths], { cwd, stdio: 'pipe' });
|
|
139
|
-
execFileSync('git', ['commit', '-q', '-m', `chore(${feature}): relatórios da revisão independente`, '--', ...paths], { cwd, stdio: 'pipe' });
|
|
140
|
-
return paths;
|
|
141
|
-
} catch {
|
|
142
|
-
return [];
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function reportCheckCommand(feature, options = {}) {
|
|
147
|
-
const cwd = options.cwd || process.cwd();
|
|
148
|
-
const featureDir = join(cwd, '.morph', 'features', feature);
|
|
149
|
-
let progress = null;
|
|
150
|
-
const emit = (obj, code) => {
|
|
151
|
-
if (options.json) console.log(JSON.stringify(obj, null, 2));
|
|
152
|
-
else printHuman(obj, { cwd, progress, planStatus: status });
|
|
153
|
-
process.exit(code);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const { status, checks } = readPlanChecks(cwd, feature);
|
|
157
|
-
if (!checks) {
|
|
158
|
-
emit({ error: `feature "${feature}" sem 2-plan/checks.json legível (${status}) — rode morph-spec plan-check ${feature}`, feature }, 1);
|
|
159
|
-
}
|
|
160
|
-
progress = implementProgress(featureDir);
|
|
161
|
-
const warnings = checksSpread(readOrEmpty(reportPath(featureDir))).map(({ id, files }) =>
|
|
162
|
-
`${id} cita testes em ${files.length} arquivos (${files.join(', ')}): um teste por Cn, na camada mais baixa que o prova`);
|
|
163
|
-
const implement = progress
|
|
164
|
-
? { total: progress.total, done: progress.done, pending: progress.checks.filter((c) => c.status === 'pendente').map((c) => c.id),
|
|
165
|
-
blocked: progress.checks.filter((c) => c.status === 'bloqueado').map((c) => c.id), legacy: progress.legacy, warnings }
|
|
166
|
-
: null;
|
|
167
|
-
const committedReports = commitLooseReports(cwd, feature);
|
|
168
|
-
emit({
|
|
169
|
-
feature, implement, reviews: inspectReviewReports(cwd, feature),
|
|
170
|
-
...(committedReports.length ? { committedReports } : {}),
|
|
171
|
-
...treeFor(cwd, feature, options.beforeEval),
|
|
172
|
-
}, 0);
|
|
173
|
-
}
|
|
174
|
-
|
|
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 }) {
|
|
182
|
-
if (obj.error) {
|
|
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`));
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
console.log('');
|
|
188
|
-
let lines = null;
|
|
189
|
-
try { lines = nextStepFor(obj.feature, cwd)?.retrato ?? null; } catch { lines = null; }
|
|
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
|
-
}
|
|
199
|
-
if (impl) {
|
|
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
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
console.log('');
|
|
206
|
-
console.log(chalk.bold(`${GATE_NAME.review}:`));
|
|
207
|
-
for (const [role, r] of Object.entries(obj.reviews ?? {})) {
|
|
208
|
-
if (!r.exists && role === 'security') continue;
|
|
209
|
-
const ok = r.complete && r.verdict === 'SHIP';
|
|
210
|
-
console.log(` ${ok ? chalk.green('✓') : chalk.yellow('⚠')} ${ROLE_NAME[role] ?? role}: ${reviewSay(r)}`);
|
|
211
|
-
}
|
|
212
|
-
if (obj.reviewModels) {
|
|
213
|
-
const m = obj.reviewModels;
|
|
214
|
-
console.log(chalk.gray(` ${SESSION_MARK} dispatch verifier ${m.verifier.model}, reviewer ${m.reviewer.model}${m.security.required ? `, security ${m.security.model}` : ''}`));
|
|
215
|
-
}
|
|
216
|
-
if (obj.gate3) {
|
|
217
|
-
const g = obj.gate3;
|
|
218
|
-
console.log(chalk.gray(` ${SESSION_MARK} gate 3 base ${g.base?.slice(0, 8) ?? '-'}, sha ${g.sha?.slice(0, 8) ?? '-'}`
|
|
219
|
-
+ `${g.redispatch ? `, voltam: ${g.redispatch.join(', ') || 'nenhum'}` : ''}${g.flaky.length ? `, instáveis: ${g.flaky.join(', ')}` : ''}`));
|
|
220
|
-
}
|
|
221
|
-
console.log('');
|
|
222
|
-
printTree(obj.tree);
|
|
223
|
-
console.log('');
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function printTree(tree) {
|
|
227
|
-
if (!tree) {
|
|
228
|
-
console.log(chalk.gray('Código: a pasta não é um repositório git, então não deu para conferir.'));
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
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 ?? '-'}.`);
|
|
235
|
-
for (const d of tree.dirty.slice(0, 10)) console.log(chalk.gray(` ${d.status.padEnd(2)} ${d.path}`));
|
|
236
|
-
if (tree.dirtyCount > 10) console.log(chalk.gray(` … e mais ${tree.dirtyCount - 10}`));
|
|
237
|
-
if (tree.commits?.length) console.log(chalk.gray(` Commits desta entrega: ${tree.commits.join(' · ')}`));
|
|
238
|
-
const since = tree.sinceBeforeEval;
|
|
239
|
-
if (since) {
|
|
240
|
-
console.log(since.changedCount
|
|
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}).`));
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, unlinkSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { getFeature, setApprovalGate, updateFeature } from '../../core/state/state-manager.js';
|
|
5
|
-
import { WORK_TYPES, isValidWorkType, POLICY_APPROVER_PREFIX } from '../../core/work-types.js';
|
|
6
|
-
import { renderPlanSkeleton } from '../../lib/plan/plan-template.js';
|
|
7
|
-
|
|
8
|
-
// Retype only ever undoes `policy:` stamps: blocked once review is approved; a downgrade
|
|
9
|
-
// is blocked once the plan carries a genuine approval; an upgrade only adds scrutiny.
|
|
10
|
-
export async function retypeCommand(featureName, newType, options = {}) {
|
|
11
|
-
try {
|
|
12
|
-
if (!isValidWorkType(newType)) {
|
|
13
|
-
console.error(chalk.red(`\n❌ Invalid work type: "${newType}"`));
|
|
14
|
-
console.error(chalk.gray(`Valid types: ${Object.keys(WORK_TYPES).join(', ')}\n`));
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const feature = getFeature(featureName);
|
|
19
|
-
if (!feature) {
|
|
20
|
-
console.error(chalk.red(`\n❌ Feature not found: ${featureName}\n`));
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const oldType = feature.workType || 'feature';
|
|
25
|
-
|
|
26
|
-
if (oldType === newType) {
|
|
27
|
-
console.log(chalk.yellow(`\n⚠️ Feature "${featureName}" already is type "${newType}" — no-op\n`));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (feature.approvalGates?.review?.approved === true) {
|
|
32
|
-
console.error(chalk.red(`\n❌ Feature "${featureName}" já passou pelo Gate 3 (review); retype bloqueado\n`));
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const oldWorkType = WORK_TYPES[oldType] || WORK_TYPES.feature;
|
|
37
|
-
const newWorkType = WORK_TYPES[newType];
|
|
38
|
-
const isDowngrade = newWorkType.skippedGates.length > oldWorkType.skippedGates.length;
|
|
39
|
-
|
|
40
|
-
if (isDowngrade) {
|
|
41
|
-
const planGate = feature.approvalGates?.plan;
|
|
42
|
-
const genuinelyApproved = planGate?.approved === true
|
|
43
|
-
&& !String(planGate.approvedBy || '').startsWith(POLICY_APPROVER_PREFIX);
|
|
44
|
-
if (genuinelyApproved) {
|
|
45
|
-
console.error(chalk.red(`\n❌ Gate do plano já aprovado por "${planGate.approvedBy}"; downgrade bloqueado — o plano já foi aceito\n`));
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const now = new Date().toISOString();
|
|
51
|
-
|
|
52
|
-
// A genuine (non-policy) approval is never reset.
|
|
53
|
-
const resetGates = [];
|
|
54
|
-
for (const [gate, data] of Object.entries(feature.approvalGates || {})) {
|
|
55
|
-
const isPolicyStamped = String(data?.approvedBy || '').startsWith(POLICY_APPROVER_PREFIX);
|
|
56
|
-
if (isPolicyStamped && !newWorkType.skippedGates.includes(gate)) {
|
|
57
|
-
await setApprovalGate(featureName, gate, false, { approvedBy: null, approvedAt: null });
|
|
58
|
-
resetGates.push(gate);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// A gate already approved keeps its genuine approval.
|
|
63
|
-
const stampedGates = [];
|
|
64
|
-
for (const gate of newWorkType.skippedGates) {
|
|
65
|
-
if (!feature.approvalGates?.[gate]?.approved) {
|
|
66
|
-
await setApprovalGate(featureName, gate, true, {
|
|
67
|
-
approvedBy: `${POLICY_APPROVER_PREFIX}${newType}`,
|
|
68
|
-
approvedAt: now,
|
|
69
|
-
});
|
|
70
|
-
stampedGates.push(gate);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const featureDir = join(process.cwd(), '.morph', 'features', featureName);
|
|
75
|
-
const planPath = join(featureDir, '2-plan', 'plan.md');
|
|
76
|
-
if (stampedGates.includes('plan') && existsSync(planPath)
|
|
77
|
-
&& readFileSync(planPath, 'utf8') === renderPlanSkeleton(featureName)) {
|
|
78
|
-
unlinkSync(planPath);
|
|
79
|
-
}
|
|
80
|
-
for (const folder of newWorkType.scaffold) {
|
|
81
|
-
mkdirSync(join(featureDir, folder), { recursive: true });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
await updateFeature(featureName, 'workType', newType);
|
|
85
|
-
await updateFeature(featureName, 'workTypeHistory', [
|
|
86
|
-
...(feature.workTypeHistory || []),
|
|
87
|
-
{ from: oldType, to: newType, reason: options.reason || null, at: now },
|
|
88
|
-
]);
|
|
89
|
-
|
|
90
|
-
const finalFeature = getFeature(featureName);
|
|
91
|
-
|
|
92
|
-
if (options.json) {
|
|
93
|
-
console.log(JSON.stringify({ feature: featureName, from: oldType, to: newType, resetGates, stampedGates, ...finalFeature }, null, 2));
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
console.log(chalk.green(`\n✅ Feature retyped: ${featureName} (${oldType} → ${newType})`));
|
|
98
|
-
if (resetGates.length) {
|
|
99
|
-
console.log(chalk.yellow(` gates reset (were policy-stamped, no longer skipped): ${resetGates.join(', ')}`));
|
|
100
|
-
}
|
|
101
|
-
if (stampedGates.length) {
|
|
102
|
-
console.log(chalk.yellow(` gates stamped policy:${newType}: ${stampedGates.join(', ')}`));
|
|
103
|
-
}
|
|
104
|
-
console.log(chalk.gray(` scaffolded: ${newWorkType.scaffold.join(', ')}`));
|
|
105
|
-
console.log('');
|
|
106
|
-
} catch (error) {
|
|
107
|
-
console.error(chalk.red(`\n❌ Error retyping feature: ${error.message}\n`));
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
}
|