@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,192 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { existsSync, rmSync, renameSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
-
import { join, resolve, sep } from 'path';
|
|
4
|
-
import { execSync } from 'child_process';
|
|
5
|
-
import { isValidFeatureName, cwdIsInsideWorktree, teardownWorktree, resolvePrimaryRoot } from '../project/worktree.js';
|
|
6
|
-
import { resolveFeatureTree } from '../../lib/worktree/feature-truth.js';
|
|
7
|
-
import { tearDownFeatureStack } from '../../lib/e2e/stack-teardown.js';
|
|
8
|
-
|
|
9
|
-
// `featureName` flows into a recursive rmSync and `../../.claude` would resolve to the shared
|
|
10
|
-
// install: the name is validated AND the resolved path must stay contained. Dropping the root
|
|
11
|
-
// index entry matters too, or the next loadState resurrects the folder.
|
|
12
|
-
|
|
13
|
-
function assertContained(scopeDir, name, target) {
|
|
14
|
-
const scopeAbs = resolve(scopeDir) + sep;
|
|
15
|
-
const targetAbs = resolve(target);
|
|
16
|
-
if (targetAbs !== resolve(scopeDir) && !(targetAbs + sep).startsWith(scopeAbs)) {
|
|
17
|
-
throw new Error(`recusado: "${name}" resolve para fora de ${scopeDir}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function isGitRepo(cwd) {
|
|
22
|
-
try {
|
|
23
|
-
execSync('git rev-parse --is-inside-work-tree', { cwd, stdio: 'pipe' });
|
|
24
|
-
return true;
|
|
25
|
-
} catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function approvedGates(feature) {
|
|
31
|
-
const gates = feature?.approvalGates || {};
|
|
32
|
-
return Object.entries(gates)
|
|
33
|
-
.filter(([, g]) => g?.approved === true)
|
|
34
|
-
.map(([name]) => name);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function dropFromIndex(cwd, featureName) {
|
|
38
|
-
const rootPath = join(cwd, '.morph', 'state.json');
|
|
39
|
-
if (!existsSync(rootPath)) return;
|
|
40
|
-
try {
|
|
41
|
-
const root = JSON.parse(readFileSync(rootPath, 'utf8'));
|
|
42
|
-
if (root.features && root.features[featureName]) {
|
|
43
|
-
delete root.features[featureName];
|
|
44
|
-
root.metadata = root.metadata || {};
|
|
45
|
-
root.metadata.totalFeatures = Object.keys(root.features).length;
|
|
46
|
-
writeFileSync(rootPath, JSON.stringify(root, null, 2), 'utf8');
|
|
47
|
-
}
|
|
48
|
-
} catch { /* index is derivable — non-fatal */ }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function deleteCommand(featureName, options = {}) {
|
|
52
|
-
try {
|
|
53
|
-
const cwd = options.cwd || process.cwd();
|
|
54
|
-
|
|
55
|
-
// Validated BEFORE any path is built: delete takes a fresh argument on every invocation.
|
|
56
|
-
if (!isValidFeatureName(featureName)) {
|
|
57
|
-
console.error(chalk.red(`\n❌ Invalid feature name: "${featureName}"`));
|
|
58
|
-
console.error(chalk.gray('Use kebab-case: lowercase letters, digits and hyphens (e.g. "user-onboarding")\n'));
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const featuresDir = join(cwd, '.morph', 'features');
|
|
63
|
-
const featuresPath = join(featuresDir, featureName);
|
|
64
|
-
assertContained(featuresDir, featureName, featuresPath);
|
|
65
|
-
const fjPath = join(featuresPath, 'feature.json');
|
|
66
|
-
|
|
67
|
-
if (!existsSync(featuresPath)) {
|
|
68
|
-
console.error(chalk.red(`\n❌ Feature not found: .morph/features/${featureName}\n`));
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Not loadState: a read that mutates state has no place inside a delete.
|
|
73
|
-
let feature = {};
|
|
74
|
-
if (existsSync(fjPath)) {
|
|
75
|
-
try { feature = JSON.parse(readFileSync(fjPath, 'utf8')); } catch { feature = {}; }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const approved = approvedGates(feature);
|
|
79
|
-
if (approved.length && !options.force) {
|
|
80
|
-
console.error(chalk.red(`\n❌ "${featureName}" has approved gate(s): ${approved.join(', ')}.`));
|
|
81
|
-
console.log(chalk.gray(` Deleting approved work is unusual — pass --force to override,`));
|
|
82
|
-
console.log(chalk.gray(` or 'morph-spec archive ${featureName}' if it's actually complete.\n`));
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// A live worktree owns the real state; deleting the root registration would orphan it. A distinct
|
|
87
|
-
// consent from --force on purpose: --force answers a state risk, this one is a filesystem risk.
|
|
88
|
-
const owner = resolveFeatureTree(featureName, cwd);
|
|
89
|
-
const liveElsewhere = (owner.source === 'registry' || owner.source === 'pointer') && owner.tree;
|
|
90
|
-
if (liveElsewhere) {
|
|
91
|
-
if (!options.withWorktree) {
|
|
92
|
-
const payload = { error: 'feature-has-worktree', feature: featureName, worktree: { path: owner.tree, branch: owner.branch } };
|
|
93
|
-
if (options.json) { console.log(JSON.stringify(payload)); process.exit(1); }
|
|
94
|
-
console.error(chalk.red(`\n❌ "${featureName}" tem um worktree vivo em ${owner.tree}.`));
|
|
95
|
-
console.error(chalk.gray(' Feche com `morph-spec finish <feature> --pr|--merge` se o trabalho vale,'));
|
|
96
|
-
console.error(chalk.gray(` ou \`morph-spec worktree remove ${featureName}\` e rode o delete de novo,`));
|
|
97
|
-
console.error(chalk.gray(` ou \`morph-spec delete ${featureName} --with-worktree\` para fazer os dois num passo.\n`));
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (cwdIsInsideWorktree(cwd, owner.tree)) {
|
|
102
|
-
const payload = { error: 'cwd-inside-worktree', feature: featureName, path: owner.tree };
|
|
103
|
-
if (options.json) { console.log(JSON.stringify(payload)); process.exit(1); }
|
|
104
|
-
console.error(chalk.red(`\n❌ Rode fora do worktree antes de removê-lo: ${owner.tree}\n`));
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// PROVE-or-DECLINE: a refusal here must leave everything untouched.
|
|
109
|
-
const root = resolvePrimaryRoot(cwd);
|
|
110
|
-
// The stack comes down BEFORE the worktree, where its compose file and bind mount live. Fail-open.
|
|
111
|
-
try {
|
|
112
|
-
tearDownFeatureStack(featureName, { root, worktreePath: owner.tree, volumes: true, images: 'local', _exec: options._exec });
|
|
113
|
-
} catch { /* fail-open */ }
|
|
114
|
-
const teardown = await teardownWorktree(owner.tree, {
|
|
115
|
-
root,
|
|
116
|
-
feature: featureName,
|
|
117
|
-
branch: owner.branch,
|
|
118
|
-
options: { discardIgnored: options.discardIgnored === true },
|
|
119
|
-
deleteBranch: options.deleteBranch === true, // kept by default — it is the work
|
|
120
|
-
});
|
|
121
|
-
if (!teardown.worktreeRemoved) {
|
|
122
|
-
const payload = { error: 'worktree-removal-failed', feature: featureName, declineReason: teardown.declineReason };
|
|
123
|
-
if (options.json) { console.log(JSON.stringify(payload)); process.exit(1); }
|
|
124
|
-
console.error(chalk.red(`\n❌ Não foi possível remover o worktree — nada foi apagado.`));
|
|
125
|
-
console.error(chalk.gray(` ${teardown.declineReason || 'motivo desconhecido'}\n`));
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const useGit = isGitRepo(cwd) && options.git !== false;
|
|
131
|
-
|
|
132
|
-
if (options.archive) {
|
|
133
|
-
const archiveDir = join(cwd, '.morph', 'archive');
|
|
134
|
-
const archivePath = join(archiveDir, featureName);
|
|
135
|
-
if (existsSync(archivePath)) {
|
|
136
|
-
console.error(chalk.red(`\n❌ Already present in archive: .morph/archive/${featureName}\n`));
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
if (existsSync(fjPath)) {
|
|
140
|
-
feature.status = 'abandoned';
|
|
141
|
-
feature.abandonedAt = new Date().toISOString();
|
|
142
|
-
feature.updatedAt = feature.abandonedAt;
|
|
143
|
-
writeFileSync(fjPath, JSON.stringify(feature, null, 2), 'utf8');
|
|
144
|
-
}
|
|
145
|
-
mkdirSync(archiveDir, { recursive: true });
|
|
146
|
-
let staged = false;
|
|
147
|
-
if (useGit) {
|
|
148
|
-
try {
|
|
149
|
-
execSync(`git mv "${featuresPath}" "${archivePath}"`, { cwd, stdio: 'pipe' });
|
|
150
|
-
staged = true;
|
|
151
|
-
} catch {
|
|
152
|
-
renameSync(featuresPath, archivePath);
|
|
153
|
-
try { execSync(`git add -A "${featuresPath}" "${archivePath}"`, { cwd, stdio: 'pipe' }); staged = true; } catch { /* not fatal */ }
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
renameSync(featuresPath, archivePath);
|
|
157
|
-
}
|
|
158
|
-
dropFromIndex(cwd, featureName);
|
|
159
|
-
|
|
160
|
-
if (options.json) { console.log(JSON.stringify({ deleted: featureName, mode: 'archive', status: 'abandoned', staged })); process.exit(0); }
|
|
161
|
-
console.log(chalk.yellow(`\n🗃 Abandoned "${featureName}" → .morph/archive/${featureName}/`));
|
|
162
|
-
console.log(chalk.gray(` status: abandoned, abandonedAt stamped; dropped from index.`));
|
|
163
|
-
console.log(staged ? chalk.gray(' Move staged in git.\n') : '');
|
|
164
|
-
process.exit(0);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let staged = false;
|
|
168
|
-
if (useGit) {
|
|
169
|
-
try {
|
|
170
|
-
execSync(`git rm -r -f --quiet "${featuresPath}"`, { cwd, stdio: 'pipe' });
|
|
171
|
-
staged = true;
|
|
172
|
-
} catch {
|
|
173
|
-
// Untracked (never committed) — nothing for git rm to act on.
|
|
174
|
-
}
|
|
175
|
-
// `git rm` only removes tracked files: scaffolded empty phase folders survive it.
|
|
176
|
-
if (existsSync(featuresPath)) rmSync(featuresPath, { recursive: true, force: true });
|
|
177
|
-
try { execSync(`git add -A "${featuresPath}"`, { cwd, stdio: 'pipe' }); staged = true; } catch { /* not fatal */ }
|
|
178
|
-
} else {
|
|
179
|
-
rmSync(featuresPath, { recursive: true, force: true });
|
|
180
|
-
}
|
|
181
|
-
dropFromIndex(cwd, featureName);
|
|
182
|
-
|
|
183
|
-
if (options.json) { console.log(JSON.stringify({ deleted: featureName, mode: 'hard', staged })); process.exit(0); }
|
|
184
|
-
console.log(chalk.green(`\n🗑 Deleted "${featureName}" (.morph/features/${featureName}/ removed, dropped from index).`));
|
|
185
|
-
if (approved.length) console.log(chalk.gray(` (had approved gate(s): ${approved.join(', ')} — removed via --force)`));
|
|
186
|
-
console.log(staged ? chalk.gray(' Removal staged in git.\n') : '');
|
|
187
|
-
process.exit(0);
|
|
188
|
-
} catch (error) {
|
|
189
|
-
console.error(chalk.red(`\n❌ Error deleting feature: ${error.message}\n`));
|
|
190
|
-
process.exit(1);
|
|
191
|
-
}
|
|
192
|
-
}
|