Skip to content

feat(hooks): nudge CLI upgrade when a newer stable release is cached - #8

Merged
Kshitij Jhunjhunwala (KJ-11) merged 2 commits into
masterfrom
kj/plugin-upgrade-nudge
Jul 27, 2026
Merged

Kshitij Jhunjhunwala (KJ-11) merged 2 commits into
masterfrom
kj/plugin-upgrade-nudge

Conversation

@KJ-11

Copy link
Copy Markdown
Contributor

Implements the composio-plugin-cc slice of PRDE-1144.

What

The SessionStart hook already offers to install the CLI when it is missing; now it also nudges when the installed CLI is outdated. In the CLI-present branch it compares composio version against the CLI's own 24h-throttled release cache (~/.composio/update-check.json, shape {"lastChecked", "latestVersion"}) and appends to the context line:

A newer Composio CLI (X.Y.Z) is available — run composio upgrade.

Why the cache file and not composio version --check

ComposioHQ/composio#3944 adds version --check as the first-class machine-readable source, but (a) it is still unmerged/unreleased so the installed base doesn't have it, and (b) its contract does a synchronous GitHub fetch (10s timeout) when the cache is stale with no cache-only flag — which can blow the hook's 8s budget and would break the plugin's no-network-in-hooks convention. #3944's own PR body designates the unchanged cache file as what PRDE-1144 reads, so the hook reads it directly: a pure local file read on every path.

Degradation matrix (all silent, hook always exits 0)

  • prerelease installed (e.g. 0.2.32-beta.289) — the plugin adds no beta policy of its own
  • prerelease latestVersion in the cache (the anchored-quote sed rejects it rather than truncating 0.3.0-beta.1 to 0.3.0)
  • up-to-date or newer-than-cache install; unparseable composio version output
  • cache missing or malformed; CLI absent (install line wins)

Comparison is numeric per field (sort -t. -kN,Nn), so 0.2.9 < 0.2.10 is handled correctly.

Verification

  • python3 -m pytest tests/unit -q — 49 passed (11 new nudge cases; test env now pins HOME so the cache read is hermetic).
  • Manual: fake $HOME with cache 0.2.32 + fake CLI 0.2.30 → nudge emitted verbatim; this machine's real beta install (0.2.32-beta.289) → silent.
  • Plugin version bumped 0.2.1 → 0.2.2; README's upgrade mention (line ~100) still accurate.

🤖 Generated with Claude Code

SessionStart now compares `composio version` against the CLI's own
24h-throttled release cache (~/.composio/update-check.json) and appends
"A newer Composio CLI (X.Y.Z) is available — run `composio upgrade`."
to the auth line. Local file read only — never the network (PRDE-1144;
`composio version --check` from ComposioHQ/composio#3944 was ruled out
for the hook because it can do a synchronous fetch on a stale cache,
which could blow the 8s hook budget).

Only a plain X.Y.Z install strictly older than a plain X.Y.Z
latestVersion nudges; prereleases on either side, a missing or
malformed cache, or an unparseable version all degrade to silence.
Tests pin HOME so the cache read stays hermetic.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@KJ-11
Kshitij Jhunjhunwala (KJ-11) merged commit 07061a1 into master Jul 27, 2026
6 checks passed
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