Skip to content

Feat/buddy-profiles#17

Merged
cpaczek merged 16 commits into
cpaczek:mainfrom
Ahmad8864:feat/buddy-profiles
Apr 2, 2026
Merged

Feat/buddy-profiles#17
cpaczek merged 16 commits into
cpaczek:mainfrom
Ahmad8864:feat/buddy-profiles

Conversation

@Ahmad8864

@Ahmad8864 Ahmad8864 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Buddy Profiles: save, switch, and manage multiple companions - now with animated sprites

Summary

Adds a profile system that lets users save multiple buddy configurations and switch between them without re-rolling. Sprites are now animated throughout the UI (idle frame sequences play in both the builder preview and the gallery). Each profile persists the full buddy identity - species, rarity, cosmetics, stats, companion name, and personality - so switching feels like reuniting with an old friend, not starting over.

  • any-buddy buddies -- new command to browse saved buddies in an interactive gallery (OpenTUI) or sequential fallback prompt
  • Profile persistence -- V2 config schema (PetConfigV2) with transparent V1 migration; profiles stored in ~/.claude-code-any-buddy.json
  • Binary-aware switching -- patches the Claude Code binary salt in-place when switching, with rollback support via previousSalt
  • Companion identity preservation -- snapshots the outgoing buddy's name and personality before switching, restores the incoming buddy's identity after
  • Animated sprite preview -- shared animation clock (createAnimator) drives idle sprite frames in both the builder (main creation screen) and gallery panels
  • Active buddy tracking -- resolved by comparing the current binary salt rather than relying on a stored profile name, so state stays consistent even after manual restores

New files

Area Files What they do
Gallery TUI src/tui/gallery/ (5 files) OpenTUI-based profile browser with scrollable list + animated preview panel
Buddies command src/tui/commands/buddies.ts Orchestrates profile selection, binary patching, and identity swap
Animator src/tui/animator.ts Lazy animation clock that auto-starts/stops based on subscriber count
Config V2 src/config/pet-config.ts (extended) Profile CRUD, V1 migration, active profile management
Types src/types.ts (extended) ProfileData and PetConfigV2 interfaces

Tests added

  • pet-config-v2.test.ts -- V1-to-V2 migration, profile CRUD, edge cases (delete active buddy, empty state)
  • render-animated.test.ts -- animated sprite rendering with IDLE_SEQUENCE
  • animator.test.ts -- subscription lifecycle, cleanup, lazy start/stop
  • stat-bars-from-stats.test.ts -- stat bar rendering from profile stats
  • gallery/state.test.ts -- gallery entry building, active entry detection

How it works

any-buddy          # build a new buddy (unchanged)
any-buddy buddies  # browse & switch between saved buddies

When a buddy is built, it's automatically saved as a named profile. The gallery shows all profiles with a live animated preview. On selection, the buddies command:

  1. Snapshots the outgoing buddy's companion name/personality into its profile
  2. Locates the current salt in the Claude Code binary
  3. Patches in the new buddy's salt
  4. Updates the config's active profile and salt tracking
  5. Restores the incoming buddy's companion identity

Notes

  • Backwards-compatible: existing V1 configs are silently migrated on first load
  • The animator is unref'd so it never blocks process exit
  • Gallery gracefully falls back to @inquirer/prompts select if OpenTUI is unavailable

@Ahmad8864

Copy link
Copy Markdown
Contributor Author

Not ready for review sry, making some adjustments, will comment when ready

@cpaczek

cpaczek commented Apr 2, 2026

Copy link
Copy Markdown
Owner

No worries looks like a great feature add lmk when done and I'll review and merge

@Ahmad8864

Copy link
Copy Markdown
Contributor Author

@cpaczek PR is ready for review

@cpaczek cpaczek merged commit 8e50b5a into cpaczek:main Apr 2, 2026
7 checks passed
@cpaczek

cpaczek commented Apr 2, 2026

Copy link
Copy Markdown
Owner

@Ahmad8864 Merged ty for the PR just doing some code quality checks and fixes before I release

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.

2 participants