ktg-plugin-marketplace/plugins/ultraplan-local/tests/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
..
agent-frontmatter.test.mjs test(ultraplan-local): pin agent frontmatter contract (model + tools) 2026-05-04 06:26:08 +02:00
arg-parser.test.mjs test(ultraplan-local): add ultracontinue to FLAG_SCHEMA + tests 2026-05-04 16:34:55 +02:00
atomic-write.test.mjs refactor(ultraplan-local): extract atomicWriteJson to lib/util 2026-05-01 20:21:15 +02:00
autonomy-gate.test.mjs feat(ultraplan-local): add autonomy-gate state machine + manifest schema extensions for skip_commit_check + memory_write 2026-05-04 06:28:47 +02:00
bash-normalize.test.mjs feat(ultraplan-local): Spor 1 wave 1 — lib/parsers + 66 tests grønn 2026-05-01 05:35:28 +02:00
cleanup.test.mjs feat(ultraplan-local): cleanup util (Bug 4 dry-run/confirm/idempotent) [skip-docs] 2026-05-04 17:41:06 +02:00
doc-consistency.test.mjs feat(ultraplan-local): mirror Phase 2.6 hardenings in headless-launch-template 2026-05-04 07:51:50 +02:00
finding-id.test.mjs feat(ultraplan-local): add lib/parsers/finding-id.mjs (stable SHA1) 2026-05-01 13:28:05 +02:00
frontmatter.test.mjs feat(ultraplan-local): Spor 1 wave 1 — lib/parsers + 66 tests grønn 2026-05-01 05:35:28 +02:00
gates-flag-coverage.test.mjs feat(ultraplan-local): add --gates autonomy-control flag to all four pipeline commands 2026-05-04 07:54:30 +02:00
jaccard.test.mjs feat(ultraplan-local): add lib/parsers/jaccard.mjs 2026-05-01 13:28:44 +02:00
main-merge-gate.test.mjs feat(ultraplan-local): emit main-merge-gate stats event from Phase 8 2026-05-04 07:55:41 +02:00
manifest-schema-extensions.test.mjs feat(ultraplan-local): add autonomy-gate state machine + manifest schema extensions for skip_commit_check + memory_write 2026-05-04 06:28:47 +02:00
manifest-yaml.test.mjs feat(graceful-handoff): 2.0 — migrate to skills/ with disable-model-invocation [skip-docs] 2026-05-01 05:45:26 +02:00
plan-review-dedup.test.mjs feat(ultraplan-local): add plan-review-dedup helper for Phase 9 finding dedup 2026-05-04 06:30:28 +02:00
plan-schema.test.mjs feat(ultraplan-local): Spor 1 wave 1 — lib/parsers + 66 tests grønn 2026-05-01 05:35:28 +02:00
project-discovery.test.mjs feat(ultraplan-local): extend project-discovery with review.md 2026-05-01 16:43:08 +02:00
review-determinism.test.mjs test(ultraplan-local): add review determinism integration test 2026-05-01 17:21:42 +02:00
rule-catalogue.test.mjs feat(ultraplan-local): add lib/review/rule-catalogue.mjs (12 rule keys) 2026-05-01 13:27:29 +02:00
source-findings.test.mjs test(ultraplan-local): add SC3(b) source_findings structural test 2026-05-01 17:23:30 +02:00
stats-event-emit.test.mjs feat(ultraplan-local): add stats event-emit for autonomy lifecycle events 2026-05-04 06:31:52 +02:00