Self-update the plugin from its own SessionStart hook (PRDE-1161) - #10
Merged
Merged
Conversation
A stale install now converges to the latest published version within a day plus one session restart, with no user or CLI involvement: at most once per 24h (state file ~/.composio/plugin-cc-self-update.json), a fully detached background job runs `claude plugin marketplace update composio` then `claude plugin update composio@composio`; the new version activates at the next session launch. The job is detached (never waited on, all fds redirected) because SessionStart has an 8s timeout and its stdout is parsed as JSON. `claude plugin ...` subcommands don't fire hooks, so no recursion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A stale install of this plugin now converges to the latest published version within a day plus one session restart, with zero user or CLI involvement — the Claude Code/Codex "relaunch to update" model. The plugin owns its own freshness; the composio CLI is not involved (cross-artifact repair proposals were explicitly rejected on the ticket).
Linear: PRDE-1161
How
In
session-start.sh, at most once per 24h (throttle state in~/.composio/plugin-cc-self-update.json, stamped before running so it doubles as a poor-man's lock), a fully detached background job runs:claude plugin marketplace update composio— git-refreshes the marketplace checkoutclaude plugin update composio@composio— stages the newest cached version; active at next session launchConstraints honored:
( … ) >/dev/null 2>&1 </dev/null &). Hook latency is unchanged (~1.4s, dominated by the pre-existing auth/cache work).claude plugin …subcommands don't fire hooks (verified with an instrumented hook) → no recursion.claudebinary, no network, read-only/corrupt/absent state file, unsetHOMEall degrade to "do nothing" without touching the hook's JSON output.plugin.jsonbumped 0.2.3 → 0.2.4 (release-discipline CI from Enforce plugin version bumps in CI + tag releases on bump (PRDE-1152) #9).One deviation from the plan: instead of comparing the marketplace checkout's
plugin.jsonagainst the running version (the checkout's path differs between directory-source and git-source marketplaces), the job always runsclaude plugin update, which does that comparison itself and no-ops locally with "already at the latest version" when current. Fewer failure modes, same behavior.Verification (isolated home —
CLAUDE_CONFIG_DIR=<scratch>, real~/.claudeuntouched)Premise checks:
marketplace add,plugin install,marketplace update,plugin update→ marker never appeared (no hook recursion).End-to-end convergence ladder (scratch git clone as marketplace source):
claude -p) → hook fired, emitted valid JSON, exited fast; the detached job survived the session process exiting (the session actually died immediately on a login error — the job still completed) and wrote{"lastAttempt":…,"lastResult":"updated"};claude plugin listshowed 0.2.5 staged.Adversarial battery (all emit valid hook JSON, all failure-silent):
claudeon PATH → no state file, nothing attempted.~/.composio→ silent no-op.HOME→ skipped.lastResult:"error", installed version untouched, retry naturally throttled to 24h.shellcheckclean (it caught a real missing-argument bug in the state-write during development);make testgreen (49 unit tests +claude plugin validateon marketplace and plugin).Bootstrap caveat (accepted on ticket): installs older than this release never gain self-update — one manual
composio setuprerun; current pre-self-update base ≈ KJ.🤖 Generated with Claude Code