Skip to content

feat(harness-ops): add operator-run plugins refresh and preview script, user scope - #11202

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-9702-41020057633-1
Oct 30, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-9702-41020057633-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #9702

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Adds plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh with two modes. preview prints the count and size of the marketplace clones and cache/ (including temp_git_*) without changing anything. refresh snapshots marketplaces (name, source, autoUpdate), user-scope installs (id, scope) and user enabledPlugins. It then moves the clones and cache/ into a run directory outside ~/.claude/plugins, re-fetches them serially through claude plugin marketplace update and claude plugin install --scope user, re-applies enable/disable where an install flipped a value, and exits non-zero on any CLI failure or snapshot difference. It copies itself out of the cache before acting, refuses under CLAUDE_CODE_REMOTE or a running claude process, leaves builtin and project/local records alone, and deletes nothing. A black-box test, fixtures, a context page with the isolated-HOME probe record, a SKILL.md section and a changelog fragment come with it.

Not verified

  • bash plugins/harness-ops/skills/plugins/scripts/reset-refresh.test.sh was not executed: this lane's Bash runs only the named wrappers, and check-affected --uncommitted does not run test suites. It was hand-traced by a fresh-context reviewer. Left to the PR's CI test lanes.
  • git diff --exit-code on the fixture settings files after a test run was not run here: the test only copies the committed fixtures into a temp HOME and never writes them, and it asserts the copied settings.json is byte-identical after refresh. Left to the PR's CI.
  • Tidy (code-tidying:tidy-diff) skipped: the change is over the 300 changed-line cutoff (the new script, test and context page together run past 300 lines).
  • The live-CLI behavior was not re-probed in this run; the context page's probe record comes from the 2026-10-30 host-run comment on the issue (Claude Code 2.1.314). The test uses stubs modelled on it.
  • The running-session check uses pgrep -x claude, so a session whose process is not named claude (for example an npm/node install) is not detected. This is documented in context/refresh.md; no sourced way to match other process names was available.
  • git status lists untracked sandbox entries at the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) that this run did not create and that the file tools cannot see. They are not part of this change.
  • CI-only gates the lane cannot run here (typos, validate-plugins steps, changed-skills, shell-portability whole-repo scanners, silent-skips, orphaned-fixtures and the others check-affected lists as CI only) are left to the PR's CI.

Fix

  • plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh: new operator-run script with preview and refresh modes. Refuses under CLAUDE_CODE_REMOTE, a running claude process, a pgrep error, invalid state JSON, or a journal root inside ~/.claude/plugins. Copies itself to the run directory and
  • plugins/harness-ops/skills/plugins/scripts/reset-refresh.test.sh: new black-box test using a throwaway HOME and stub claude/pgrep. Cases: preview changes nothing; refresh leaves marketplaces, installs and enabledPlugins identical and settings.json byte-identical; a forced autoUpdate mismatch exi
  • plugins/harness-ops/skills/plugins/scripts/fixtures/reset-refresh/settings.json: fixture user settings (one disabled id), in jq's output format so a stub rewrite round-trips byte-identically.
  • plugins/harness-ops/skills/plugins/scripts/fixtures/reset-refresh/installed_plugins.json: fixture install records covering user, project, local and builtin.
  • plugins/harness-ops/skills/plugins/scripts/fixtures/reset-refresh/known_marketplaces.json: fixture with one marketplace with autoUpdate set and one without.
  • plugins/harness-ops/skills/plugins/context/refresh.md: new context page covering both modes, the safeguards, enable-state repair, what the snapshots leave out, the probe answers (install on a recorded disabled id flips it to true; install refills a cleared cache; marketplace update re-clones a missi
  • plugins/harness-ops/skills/plugins/SKILL.md: new 'Operator script: refresh' section (the model gives the two commands and does not run them) and a Reference-index row for context/refresh.md.
  • .changes/harness-ops/feat-9702-plugins-reset-refresh-3f8a6c21.md: minor changelog fragment for the new script.

Verification

The runner ran each check from the base copy against 9a36c2e:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: All 6 changelog fragment(s) under .changes/ are valid.
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected (scripts/check-affected.sh --uncommitted): first run failed shellcheck (SC2016 on jq programs); fixed with per-site disable directives. Final run: 12 passed, 6 skipped over 8 changed files.
  • cant-fail-scan --file plugins/harness-ops/skills/plugins/scripts/reset-refresh.test.sh --check: PASS, no gating findings, 1 test file fully read.
  • Fresh-context review subagent hand-traced every assertion of reset-refresh.test.sh against the script and stubs (bash 5/GNU and bash 3.2/BSD) and found none failing. I applied its confirmed findings: marketplace snapshot sorted by name; state JSON validated and snapshot failures stop the run; pgrep
  • read https: //code.claude.com/docs/en/plugins/cli-reference.md: plugin install takes -s, --scope (default user), and an already-installed id prints already installed and exits 0. plugin enable/disable on a plugin already in that state exit 1 (already enabled/already disabled). `plugin
  • read https: //code.claude.com/docs/en/plugins-reference (redirected to the plugin manifest reference): the CLAUDE_PLUGIN_DATA location ~/.claude/plugins/data/<id>/ and the CLAUDE_PLUGIN_ROOT substitution in skill content. Used only to confirm the SKILL.md command form.
  • read https: //github.com/melodic-software/claude-code-plugins/issues /6185: the parent's recorded recommendations. The refresh level discards marketplace clones and cache/ (including temp_git_*) and keeps data/; scope is user only; records whose project path is gone are not dropped; backup deletio
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41020057633

Left out: the items under Not verified.

Related

#9702

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 9a36c2e9477de0ff06ac3058b5605cf4b8f0a718: 0 finding(s), 0 as inline comments.

No security issues found in this pull request.

I read the full diff and the PR context. The change adds an operator-run script (reset-refresh.sh) and its test, fixtures, context page, SKILL.md section and changelog fragment, all under plugins/harness-ops/skills/plugins/ and .changes/. It touches no trusted path and none of the trust controls: no trusted-actor list, token scope, kill switch, merge hold, workflow or plugin manifest.

  • Manifests: the diff changes no plugin.json or marketplace.json, so there is no manifest <field> line to report.
  • Model access: SKILL.md tells the model to give the user the two commands and not run them. The script also refuses to run under CLAUDE_CODE_REMOTE or while a claude process is running, so a lane or session can't reach it.
  • Input sources: the script reads only the operator's own ~/.claude state files and runs only the claude CLI against them. It makes no network calls and handles no tokens or secrets. No pull-request author or other untrusted text reaches it.
  • Environment override: RESET_REFRESH_RUN_DIR skips the journal-root check only on the copied re-exec. The environment is the operator's, and the CLAUDE_CODE_REMOTE and pgrep refusals still run before it.
  • Run directory: it is created with mktemp -d (mode 0700) and sits outside ~/.claude/plugins.
  • Moves: the script deletes nothing and only moves directories into the run directory.
  • Marketplace names: names from known_marketplaces.json go into mv paths without a check for .. or /. That file is operator-owned and the CLI writes the names. I did not verify whether the CLI validates a name that comes from a third-party marketplace.json, so this is not a finding. Rejecting any name containing / or equal to .. would remove the question.
  • Spend: the change spends nothing on a billed resource.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 9a36c2e9477de0ff06ac3058b5605cf4b8f0a718: 1 finding(s), 0 as inline comments.

I read the full diff and the closing issue #9702, and traced the script and test by hand. I did not run anything. The PR description's verification claims are the author's and I have not confirmed them.

Acceptance criteria in #9702

  • The script, SKILL.md section, context page and changelog fragment are all there.
  • Preview changes nothing.
  • A refresh leaves the three snapshots identical.
  • A forced autoUpdate drop exits 1.
  • CLAUDE_CODE_REMOTE=1 refuses with exit 2.
  • The script copies itself out of the cache before acting, leaves @builtin out, and treats "already enabled/disabled" as success.
  • Each of those has an assertion that fails if it breaks.

Finding

  • Failed clone move leaves the plugin tree half-moved with no way back. reset-refresh.sh moves cache/ first and then each clone. If a later clone move fails, the script exits 2 with "nothing was fetched". The cache and the earlier clones are already in <run_dir>/moved/. The message gives neither the run directory nor the go-back steps that the exit-1 path prints. The inline comment has the detail.

Trusted paths: the diff matches none of the TRUSTED PATHS globs, so I applied no extra security scrutiny. The script writes only under the run directory and ~/.claude/plugins (by moving), and it refuses a journal root inside the plugins tree.

Spend: none. This is an operator-run local script, so there is no billed resource and no hold.

critical-findings: 1

Findings not posted inline (their lines are not in the diff):

  • plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh:509 (RIGHT): If a clone move fails here, the cache and every clone moved before it are already in $moved. The script then exits 2 with "nothing was fetched". That message is wrong about the state: ~/.claude/plugins/cache is gone, and the exit-1 go-back instructions (lines 550-551) and the run directory path are never printed on this path.

To reproduce: make marketplaces/market2 unmovable, for example a read-only parent or a different-filesystem mv that fails midway. cache/ and marketplaces/market1 are then gone and the operator is left with a broken tree and no path to moved/.

On a failed move, print $moved and the same restore instructions the exit-1 path prints. Better still, move the items back in reverse order before exiting 2. The same applies to the mkdir -p "$moved/..." and cache-move failures, though no state has changed by then.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 7539ff9 Oct 30, 2026
48 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-9702-41020057633-1 branch October 30, 2026 09:06
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 4, survived 3, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 57%; mutation score 57%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh 4 3 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh:138 AOR productive no-assertion
plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh:226 SBR productive input-gap
plugins/harness-ops/skills/plugins/scripts/reset-refresh.sh:284 AOR productive input-gap

The run's summary has the full report.

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.

feat(harness-ops): plugins refresh and preview as an operator-run script, user scope

1 participant