Skip to content

setup: auto-detect plugin installation scope when --scope is omitted - #67

Open
Milofax wants to merge 1 commit into
rse:masterfrom
Milofax:fix-setup-scope-autodetect
Open

setup: auto-detect plugin installation scope when --scope is omitted#67
Milofax wants to merge 1 commit into
rse:masterfrom
Milofax:fix-setup-scope-autodetect

Conversation

@Milofax

@Milofax Milofax commented Jul 8, 2026

Copy link
Copy Markdown

Symptom

With the ASE plugin installed only in the Claude Code project or local scope (e.g. ase setup install --scope project), running a plain ase setup update from within the project reports an error and exits non-zero — although the update itself effectively succeeds:

  • npm update -g @rse/ase updates the ASE CLI tool just fine, but
  • the subsequent claude plugin update ase@ase is executed without --scope (the hard-coded option default is user), and fails because the plugin is not registered in the per-user scope.

Root cause

tool/src/ase-setup.ts registers -s, --scope with a hard-coded default of "user" for all setup sub-commands. For update, uninstall, enable, and disable this default is an assumption about where the plugin is already installed — and it is wrong whenever the installation lives in the project or local scope.

Fix

  • New private method detectScope(tool): when --scope is omitted, probe the Claude Code settings files from the strongest to the weakest scope (localprojectuser, resolved via the existing statuslineSettingsFile() helper) for a registered enabledPlugins entry "ase@ase" (its true/false value does not matter — even a disabled plugin is registered in that scope). The first match wins and is logged; no match falls back to user, i.e. the previous behavior.
  • Wired into the update, uninstall, enable, and disable actions. An explicitly given --scope always wins. install keeps its user default (there is no existing installation to detect), mcp/statusline are untouched. For --tool copilot|codex detection immediately resolves to user, so requireClaudeScope() semantics are preserved.
  • docs/usage-tool.md updated accordingly.

Testing

  • npm start build (lint + tsc + plugin copy) passes cleanly.
  • Functional tests with claude/npm shims and a fake $HOME:
    • project-scope-only installation, ase setup update --forcesetup: detected ASE plugin installation in scope "project", runs claude plugin update ase@ase --scope project, exit 0;
    • explicit --scope user → no detection, no --scope argument (unchanged behavior);
    • no ASE registration anywhere → falls back to user (unchanged behavior);
    • ase setup enable with a settings.local.json registration ("ase@ase": false) → claude plugin enable ase@ase --scope local;
    • precedence with registrations in both local and projectlocal wins; a malformed settings file is skipped gracefully.

🤖 Generated with Claude Code

When the ASE plugin is installed only in the Claude Code "project" or
"local" scope, "ase setup update" (and "uninstall", "enable",
"disable") so far always targeted the hard-coded default scope "user":
the ASE CLI tool itself was updated fine via npm, but the subsequent
"claude plugin update ase@ase" ran without "--scope" and failed with
an error, although the update itself had succeeded.

Now, when --scope is not given explicitly, the scope is auto-detected
from the existing installation by probing the Claude Code settings files
(local -> project -> user) for a registered "enabledPlugins" entry
"ase@ase", falling back to "user" when no installation is found.
An explicitly given --scope always wins, and "ase setup install"
keeps its "user" default.

Co-Authored-By: Claude Fable 5 <[email protected]>
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