ktg-plugin-marketplace/plugins/ultraplan-local/lib
Kjell Tore Guttormsen 3c0f0a0bab feat(ultraplan-local): cleanup util (Bug 4 dry-run/confirm/idempotent) [skip-docs]
Step 9 of v3.4.1 plan.

lib/util/cleanup.mjs (new):
- cleanupProject(projectDir, {dryRun, confirm}) reads
  .session-state.local.json via validateSessionState; refuses unless the
  parsed status is strictly equal to 'completed' (per risk-assessor
  Critical 2 — no soft-match on similar statuses).
- Default dryRun: true; refuses dryRun: false without explicit
  confirm: true (CLEANUP_REQUIRES_CONFIRM).
- Removes .session-state.local.json + NEXT-SESSION-PROMPT.local.md
  candidates; ENOENT counts as "already absent" so the function is
  idempotent.
- No CLI shim — invoked from /ultracontinue --cleanup via inline ESM
  (Step 10 wires this in).

tests/lib/cleanup.test.mjs (new):
- 7 cases: dry-run lists candidates without deleting; confirm-mode
  deletes both files; idempotent re-run signals CLEANUP_NO_STATE_FILE
  after fully cleaned; refuses on status: in_progress
  (CLEANUP_NOT_COMPLETED); refuses dryRun: false without confirm
  (CLEANUP_REQUIRES_CONFIRM); defaults to dry-run; missing state file
  returns CLEANUP_NO_STATE_FILE.

Internal scaffolding consumed by Step 10 (Phase 0.5 wire-up). User-facing
docs land with Step 14.

Tests 348 -> 355 (+7).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-04 17:41:06 +02:00
..
parsers test(ultraplan-local): add ultracontinue to FLAG_SCHEMA + tests 2026-05-04 16:34:55 +02:00
review feat(ultraplan-local): add plan-review-dedup helper for Phase 9 finding dedup 2026-05-04 06:30:28 +02:00
stats feat(ultraplan-local): add stats event-emit for autonomy lifecycle events 2026-05-04 06:31:52 +02:00
util feat(ultraplan-local): cleanup util (Bug 4 dry-run/confirm/idempotent) [skip-docs] 2026-05-04 17:41:06 +02:00
validators fix(ultraplan-local): Bug 3 — wire frontmatter consistency check into /ultracontinue Phase 1.5 2026-05-04 17:39:42 +02:00