Skip to content

Prune stale cache copies when installing #12

Description

@diegohb

What to build

Running the suite's CLI install (either scope, including a no-op) must also clear this package's non-pinned copies from OpenCode's package cache, so OpenCode re-fetches the just-installed version on next start instead of reusing a stale or partial cached extraction indefinitely.

The cache location mirrors OpenCode's own resolution: join(XDG_CACHE_HOME || join(homedir(), ".cache"), "opencode", "packages"). This holds across platforms (it is XDG-shaped even on macOS/Windows; only homedir() is OS-specific).

On install:

  • remove opencode-architect, opencode-architect@latest, and opencode-architect@<running version>
  • keep other pinned versions (opencode-architect@0.6.0, etc.) and every other package's cache dir
  • perform this on every install invocation, including when the install is a no-op
  • treat deletion as best-effort: a removal failure warns but does not fail the install
  • report the paths cleared to the user

Acceptance criteria

  • install removes opencode-architect, opencode-architect@latest, and opencode-architect@<running version> from the resolved cache packages directory
  • Older pinned versions and other packages' cache dirs are left untouched
  • Pruning runs even when install is a no-op (scope already at the running version)
  • Cache deletion failures warn and exit 0; the install still reports success
  • Cache root honors XDG_CACHE_HOME, falling back to ~/.cache
  • Unit tests cover removal targets, preserved dirs, no-op pruning, and the failure path using a temporary XDG_CACHE_HOME
  • README and CHANGELOG describe the behavior

Blocked by

  • None (can start immediately).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions