Skip to content

Add a clear-cache CLI subcommand #13

Description

@diegohb

What to build

A new manual-only clear-cache subcommand that removes cached copies from OpenCode's package cache. Default targets this package; destructive broad modes require explicit confirmation.

Cache root: join(XDG_CACHE_HOME || join(homedir(), ".cache"), "opencode", "packages").

Modes:

  • default (no flags): remove opencode-architect and every opencode-architect@*
  • --package <name>: remove <name> and every <name>@*; requires --yes, otherwise exit 1 with a usage message
  • --all: remove the entire OpenCode cache directory (the opencode directory under the cache root, not just packages/); requires --yes
  • --package and --all are mutually exclusive
  • reject --package values containing path separators or ..

The command is idempotent: no cached copies is a success. Deletion failures warn and continue; exit 0 unless the cache location cannot be read at all. It is never invoked automatically by any load-time hook.

Acceptance criteria

  • Default clear-cache removes only this package's cache dirs
  • --package <name> removes only that package's cache dirs and requires --yes
  • --all removes the whole OpenCode cache dir and requires --yes
  • Omitting --yes for a broad mode exits 1 without deleting anything
  • --package + --all together exits 1
  • Traversal-y --package values exit 1
  • Running with nothing cached exits 0
  • Per-mode removal failures warn and exit 0
  • --help and README list the command; CHANGELOG notes it
  • Unit tests cover each mode, the confirmation gate, mutual exclusion, unsafe names, and the empty-cache case

Blocked by

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