Repository navigation
Harden the companion Claude Code plugin and how it is installed - #4289
Merged
Merged
Conversation
Every step of the hook runs inside one try. It first asks the main plugin's action with no call in it, which answers nothing; with no such action that throws before $.session.id() or anything else runs, and the call is passed on untouched. next is called once, outside the try.
…removed companion out, skip a disabled plugin - claude --version counts only when its first line is "<x.y.z> (Claude Code)", as the daily check reads it; a wrapper's own line before it, or anything else, is an unknown version and the companion is left alone. - The installers consult the daily check's record (claude-run-companion.json, companionSeen, in the data dir): absent and installed before means the person removed it, so it is not installed again. An install that succeeds, or a companion found there, is recorded. An unreadable record reads as never installed. - No companion step when enabledPlugins in Claude Code's user settings turns plannotator@plannotator off. - Windows: the silent companion step runs before the plugin's result line instead of after it; what prints is unchanged.
…ce retry, a reason in the log, small fixes - readPluginList requires the main plugin enabled: a row with enabled false (what plugin list --json prints after plugin disable on 2.1.287 to 2.1.330) is main-plugin-disabled, nothing is installed and companionSeen is kept. - The marketplace update and retry run when the install's output says the plugin is not found, does not exist, no such or unknown in the marketplace, the pattern the installers use. - A failure logs one sanitized line of why (the output's last non-empty line, control characters stripped, at most 120 characters) to the same update.log line. - forgetRunCompanion (plannotator uninstall) also clears checkedAt, so an install right after is picked up without waiting a day. - The marker is written to a temp file in the data dir and renamed. - On Windows CLAUDECODE is cleared whatever its case.
A test fails when the marketplace no longer offers an id the daily check or the installers install (plannotator-run@plannotator), and the guide says the entry stays while installs exist; plannotator uninstall retires it.
The companion is installed once per Claude Code config folder, but the "companion seen" flag was kept once per data dir, so a second profile (another CLAUDE_CONFIG_DIR) or a restored data dir never got it. The marker now keeps companionSeenIn: one entry per config folder (its real path, lower case on Windows) with the main plugin's installedAt when the companion was seen. Removed means: this folder's entry, the same installedAt now (Claude Code keeps it through an update and sets it anew on a reinstall), and no companion. Anything else, an older marker's single flag included, installs. Also: the Claude Code version is the first line of `claude --version` that reads "x.y.z (Claude Code)" (a wrapper may print its own line first), and the update.log reason drops colour sequences, also the "[31m" left when the ESC was already stripped.
…on line anywhere The three installers apply the daily check's rule: a missing companion is installed unless the shared marker has this config folder's entry with the main plugin's installedAt now; they write this folder's entry and keep the others. An older marker's single companionSeen flag reads as no entry. - install.sh: the disabled main plugin is read only inside enabledPlugins (a false under another key no longer means disabled); a file whose enabledPlugins cannot be told apart reads as enabled. The checkedAt read cannot fail the function (|| true). - All three: the first `claude --version` line that reads "x.y.z (Claude Code)" is the version, not only the first line. - install.ps1 / install.cmd: a temp marker left by a failed move is removed; the companion step has its own try, so the result line always prints; the marker is written with ConvertTo-Json -InputObject (the attestation guard bans a piped ConvertTo-Json in these files, which failed CI's unit-3 lane). Under PowerShell 7 an installedAt read as a [datetime] is written back in Claude Code's form, so it compares equal. install.cmd's PowerShell line is 8151 characters (cmd.exe's limit is 8191).
…ep text like [5m]; tests use a temp home
backnotprop
marked this pull request as ready for review
November 30, 2026 19:19
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.
Hardening of the second Claude Code plugin (
plannotator-run) and of the code that installs it. Nothing a person sees changes: no new words, steps or settings.Changes:
tool.runhook (runs on every Bash call) can no longer throw into Claude Code: the whole body sits in one try. First it calls the main plugin's action with nothing to open. With no action there, that call throws before$.session.id()or anything else runs, and the call is passed on untouched.nextis called once, outside the try. Why:$.session.id()used to run before the try. Claude Code refusestypeof $.plannotatorRun("used as a value"), so a first call that does nothing is how the hook checks for the action.<x.y.z> (Claude Code), the same rule as the daily check. Why: before, they took any x.y.z, so a wrapper printing "Using node 22.14.0" first was read as Claude Code 22.companionSeeninclaude-run-companion.jsonin the data dir). If the companion was installed before and is now gone, it is not installed again. A successful install, or a companion already there, is recorded. A record that cannot be read counts as "never installed". Why: someone who removed it got it back on the next update.enabledPluginsin Claude Code's user settings; the daily check checksenabled: falseinplugin list --json. Why: the companion was added next to a disabled plugin.plannotator uninstallalso clears the daily check's date (checkedAt), so a reinstall right after is picked up without waiting a day. The record is written to a temp file and renamed into place. On Windows,CLAUDECODEis removed from the environment whatever its letter case.plannotator-run@plannotator). Why: a removed or renamed entry would leave installed users with "Plugin plannotator-run not found in marketplace plannotator" and a failing update. The guide now says the entry stays while installs exist, and thatplannotator uninstallis how it is retired.Run locally against real Claude Code (sandboxed HOME, no login):
plugin validateon the companion: passes on 2.1.329 and 2.1.330.plugin test(the main plugin's suite with the companion): 93 pass, 0 fail on 2.1.287, 2.1.325, 2.1.329 and 2.1.330.plugin disable plannotator@plannotator,plugin list --jsonshows"enabled": falseon 2.1.287, 2.1.329 and 2.1.330.Tests run locally:
Not in this round: what happens after
/reload-pluginsif Claude Code does not re-runengine.create, and Windows.cmdshims.