Skip to content

feat(boulder-state): add plan auto-archive functionality#2186

Open
imwxc wants to merge 4 commits intocode-yeongyu:devfrom
imwxc:feat/plan-archive-to-upstream
Open

feat(boulder-state): add plan auto-archive functionality#2186
imwxc wants to merge 4 commits intocode-yeongyu:devfrom
imwxc:feat/plan-archive-to-upstream

Conversation

@imwxc
Copy link

@imwxc imwxc commented Feb 27, 2026

Summary

  • Add automatic archiving of completed plans to .sisyphus/plans/completed/
  • Archive associated notepad directory when plan completes
  • Handle filename conflicts with auto-renaming (-2.md, -3.md, etc.)
  • Integrate with Atlas hook for automatic archival on plan completion
  • Add comprehensive test coverage (6 test cases)

Implementation

Core Functions (src/features/boulder-state/storage.ts)

  • archivePlan(directory, planName): Archive completed plan
  • findCompletedPlans(directory): List archived plans

Atlas Hook Integration (src/hooks/atlas/index.ts)

  • Auto-trigger archive when all checkboxes are marked complete
  • Clear boulder.json state after successful archival

Test Coverage

  • archive.test.ts: 6 test cases covering:
    • Basic archive functionality
    • Name conflict resolution (-2 suffix)
    • Notepad archival
    • Missing plan handling
    • Completed plans listing

Files Changed

File Purpose
constants.ts Add completed directory constants
types.ts Add ArchiveResult interface
storage.ts Core archive functions
index.ts (atlas hook) Auto-archive integration
archive.test.ts Test cases

Test Plan

  • bun run typecheck passes
  • bun run build succeeds
  • All 6 archive tests pass

Summary by cubic

Automatically archive completed plans and their notepads when Atlas marks all tasks done. Archives to .sisyphus/plans/completed and .sisyphus/notepads/completed, resolves name conflicts, and clears boulder state; also speeds up plan discovery with a shared sorter.

  • New Features

    • archivePlan(directory, planName) moves the plan; auto-renames with -2/-3 on conflict.
    • Moves matching notepad (if present) to .sisyphus/notepads/completed.
    • findCompletedPlans(directory) lists archived plans (newest first).
    • Atlas event-handler auto-archives on completion and clears boulder state; 6 tests cover archiving, conflicts, notepad move, missing plan, and listing.
  • Refactors

    • Extracted findMdFilesSortedByMtime() and reused in findPrometheusPlans and findCompletedPlans.
    • One stat per file for faster, DRY sorting.

Written for commit a77693b. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Confidence score: 4/5

  • This PR seems safe to merge; the only noted issue is medium severity and not a clear user-facing regression risk.
  • findCompletedPlans in src/features/boulder-state/storage.ts has duplicate logic and inefficient sorting, which could add avoidable overhead or maintenance cost but isn’t likely to break behavior.
  • Pay close attention to src/features/boulder-state/storage.ts - duplicate logic and inefficient sorting in findCompletedPlans.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/features/boulder-state/storage.ts">

<violation number="1" location="src/features/boulder-state/storage.ts:259">
P2: Duplicate logic and inefficient sorting in `findCompletedPlans`</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

imwxc added a commit to imwxc/oh-my-opencode that referenced this pull request Feb 28, 2026
- Extract findMdFilesSortedByMtime() helper function
- Both findPrometheusPlans and findCompletedPlans now use shared helper
- Optimize sorting: O(n) stat calls instead of O(n log n)

Addresses AI review feedback on PR code-yeongyu#2186:
- Fixed P2: Duplicate logic and inefficient sorting in findCompletedPlans
- Add archivePlan() and findCompletedPlans() functions
- Auto-archive completed plans to .sisyphus/plans/completed/
- Handle name conflicts with -2, -3 suffix
- Integrate with Atlas hook for automatic archival on completion
- Add comprehensive test coverage
- Extract findMdFilesSortedByMtime() helper function
- Both findPrometheusPlans and findCompletedPlans now use shared helper
- Optimize sorting: O(n) stat calls instead of O(n log n)

Addresses AI review feedback on PR code-yeongyu#2186:
- Fixed P2: Duplicate logic and inefficient sorting in findCompletedPlans
- Move archive functionality to event-handler.ts (upstream's new module)
- Reset index.ts to upstream's re-export only pattern
- Archive auto-triggers when plan is complete in atlas hook
@imwxc imwxc force-pushed the feat/plan-archive-to-upstream branch from 87afe9d to a77693b Compare February 28, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant