Skip to content

fix: keep the inventory outside the version-pinned plugin directory (0.3.3) - #2

Merged
CallMeTechie merged 2 commits into
mainfrom
fix/context-dir-outside-plugin
Aug 3, 2026
Merged

fix: keep the inventory outside the version-pinned plugin directory (0.3.3)#2
CallMeTechie merged 2 commits into
mainfrom
fix/context-dir-outside-plugin

Conversation

@CallMeTechie

Copy link
Copy Markdown
Owner

The bug

_fleet-lib.sh derived FM_CONTEXT from its own location:

_fm_lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FM_CONTEXT="$(cd "$_fm_lib_dir/.." && pwd)/context"

Claude Code installs plugins into a version-pinned cache path, so on a real install that resolves to:

~/.claude/plugins/cache/fleet-manager/fleet-manager/0.3.2/context

Every claude plugin update creates a new directory. The updated plugin starts with an empty inventory, and the previous version's server profiles, active-server and inventory.md are stranded where nothing reads them. Both directories are already sitting side by side on a machine that has only ever run 0.3.1 → 0.3.2:

.../cache/fleet-manager/fleet-manager/0.3.1/context/
.../cache/fleet-manager/fleet-manager/0.3.2/context/

Silent data loss on a routine update, and the failure mode is confusing: /list-servers reports an empty fleet with no error.

README.md and .gitignore both claimed this layout "survives claude plugin update". It never did.

The fix

Default is now ${XDG_CONFIG_HOME:-~/.config}/fleet-manager. FM_CONTEXT_DIR still overrides, so all 19 existing test call sites are unaffected.

A guarded one-time migration copies a pre-0.3.3 inventory forward. It fires only when the legacy directory holds real profiles and the new one holds none, so it cannot clobber a live inventory, and it copies rather than moves — the originals stay in the old cache directory until the next update discards it.

Verification

tests/unit/test-context-dir.sh, 11 assertions, all passing. It stages a fake version-pinned tree (.../0.3.2/commands/_fleet-lib.sh) and sources the real library from it:

  • override precedence, XDG default, $HOME/.config fallback
  • the default never resolves back into the plugin directory — this is the regression guard
  • migration copies profiles and active-server, skips *.md.template, keeps originals
  • migration refuses a populated target, and is a no-op under FM_CONTEXT_DIR

Rest of the suite unchanged: test-fleet-lib 51/51, test-transfer-lib 14/14, test-health-line 3/3, static checks OK, claude plugin validate passes. test-compose-lib shows its usual 2 failures locally for want of docker/jq; they pass in CI.

Note

The /first-run intake agent declares AskUserQuestion in its frontmatter but was dispatched without it, so it cannot ask its intake questions and aborts at the first prompt. Out of scope here — filing separately.

_fleet-lib.sh derived FM_CONTEXT from its own location. Claude Code installs
the plugin into a version-pinned cache path, so that resolved to something
like .../cache/fleet-manager/fleet-manager/0.3.2/context. Every plugin update
creates a fresh directory: the new version starts with an empty inventory and
the previous server profiles, active-server and inventory.md are stranded
where nothing reads them.

The default is now ${XDG_CONFIG_HOME:-~/.config}/fleet-manager. FM_CONTEXT_DIR
keeps working as the override, so every existing test is unaffected.

A guarded one-time migration copies a pre-0.3.3 in-plugin inventory forward.
It requires real profiles in the legacy directory and none in the new one, so
it cannot clobber a live inventory, and it copies rather than moves.

README and .gitignore claimed the old layout "survives plugin update"; both
now describe where state actually lives.
shellcheck SC2015 flagged six occurrences: with `A && B || C` the C branch
also runs when A is true but B fails, so a single check could report both a
pass and a fail. assert_exists/assert_absent spell out the if-then-else.
@CallMeTechie
CallMeTechie merged commit af185cc into main Aug 3, 2026
4 checks passed
@CallMeTechie
CallMeTechie deleted the fix/context-dir-outside-plugin branch August 3, 2026 20:05
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