Skip to content

feat: archive beans for project memory instead of deleting#30

Merged
hmans merged 11 commits intomainfrom
feat/archived-beans
Dec 27, 2025
Merged

feat: archive beans for project memory instead of deleting#30
hmans merged 11 commits intomainfrom
feat/archived-beans

Conversation

@hmans
Copy link
Copy Markdown
Owner

@hmans hmans commented Dec 27, 2025

Summary

This PR replaces the destructive beans archive command with a non-destructive archiving system that preserves beans as project memory.

Key Changes

  • Archive directory: Completed/scrapped beans are now moved to .beans/archive/ instead of being deleted
  • --with-archived global flag: Include archived beans in any query (works with beans list, beans query, etc.)
  • Auto-unarchive on update: Running beans update <archived-id> automatically unarchives the bean
  • Simplified archive command: Removed confirmation prompts since archiving is now reversible
  • Updated agent prompt: Added guidance on using archived beans for context and project memory

Implementation Details

  • Core.Archive() / Core.Unarchive() methods to move beans between main and archive directories
  • Core.SetWithArchived(bool) controls whether archived beans are loaded
  • Core.LoadAndUnarchive() for the update command's auto-unarchive behavior
  • Core.GetFromArchive() to check archive without loading all archived beans
  • Thread-safe implementation with proper locking to prevent race conditions
  • normalizeID helper to deduplicate ID prefix-handling logic
  • Comprehensive test coverage for all archive operations (330+ lines of tests)

Agent Prompt Updates

Updated cmd/prompt.tmpl with:

  • Guidance on using --with-archived to access project memory
  • Instructions for searching archived beans for context before starting new work
  • Reminder to add notes when scrapping beans to help future agents understand past decisions

Why This Matters

Archived beans serve as project memory for AI agents, helping them:

  • Understand past decisions and why certain approaches were chosen
  • See why previous attempts were scrapped (to avoid repeating mistakes)
  • Find implementation patterns used in completed work

Test plan

  • beans archive moves beans to .beans/archive/ instead of deleting
  • beans list excludes archived beans by default
  • beans list --with-archived includes archived beans
  • beans query --with-archived includes archived beans
  • beans update <archived-id> --status todo unarchives the bean
  • Archive/unarchive operations are idempotent
  • Race condition fixes verified with concurrent access patterns
  • All existing tests pass
  • New archive tests added and passing

hmans added 11 commits December 27, 2025 19:10
- Add `.beans/archive/` directory for storing completed/scrapped beans
- `beans archive` now moves beans instead of deleting them
- Add `--with-archived` global flag to include archived beans in queries
- Automatically unarchive beans when updating them via `beans update`
- Update file watcher to conditionally watch archive directory
- Update agent prompt with guidance on using archived beans for context
- Add comprehensive tests for archive functionality

Archived beans serve as project memory, preserving past decisions and
completed work that agents can reference for context.
Since archiving now moves files instead of deleting them, the operation
is reversible and doesn't need confirmation. Remove:
- The --force flag
- The confirmation prompt
- The printBeanList helper function
* origin/main:
  refactor(prompt): simplify agent instructions template (#31)
- Add `normalizeID` helper to deduplicate prefix-handling logic
- Refactor `findBeanLocked` and `GetFromArchive` to use the new helper
- Fix race condition in `LoadAndUnarchive` by holding lock throughout
- Add early-return for already-loaded beans (idempotency)
Since archiving is now non-destructive (beans moved to .beans/archive/
instead of deleted), we no longer need to remove incoming links when
archiving. Relationships are preserved and accessible via --with-archived.

- Remove RemoveLinksTo call from archive command
- Update help text to reflect that relationships are preserved
- Add follow-up bean for fixing broken links (beans-3kd3)

Refs: beans-3kd3
@hmans hmans merged commit 284bf3b into main Dec 27, 2025
1 check passed
@hmans hmans deleted the feat/archived-beans branch December 27, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant