Repository navigation
fix(wizard): offer the plugins that are actually active - #132604
HuzaifaChaudary wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 27, 2026, 1:25 AM ET / 05:25 UTC (Revision 12). ClawSweeper reviewWhat this changesThe CLI plugin wizard selects configurable plugins using effective activation, and wizard and toggle saves fold legacy plugin IDs into canonical config entries. Merge readiness⛔ Blocked before merge - 6 items remain The wizard defect remains on current main, and this PR addresses the earlier finding about partial policy objects. A separate compatibility question remains: saving a wizard answer can make previously ignored legacy-plugin settings active. The branch also expands an unrelated assertion baseline. Priority: P1 Review scores
Verification
How this fits togetherOnboarding and flowchart LR
A[Plugin manifests] --> C[Wizard inventory]
B[User plugin config] --> D[Activation decision]
D --> C
C --> E[Settings prompt]
B --> F[Legacy entry fold]
E --> F
F --> G[Saved plugin config]
Decision needed
Why: The branch deliberately preserves both payloads, but that changes effective settings in existing installations; source and contributor tests establish the behavior without establishing that it is the intended upgrade contract. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +176, Tests +435, Other +1. Total +612 across 6 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use canonical activation for the wizard inventory, then make legacy-entry saves preserve the previously effective plugin settings unless an explicit, reviewed migration resolves conflicting dormant values. Do we have a high-confidence way to reproduce the issue? Yes for the original inventory defect: current main still uses the manifest-default shortcut, and the supplied real wizard trace shows disabled xai being offered before the fix. The reviewer did not execute contributor code. Is this the best way to solve the issue? Unclear for the full patch: reusing canonical activation is the right inventory boundary, but combining previously ignored saved settings needs an agreed upgrade contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 13829435c8a8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
|
ran it through the real wizard step rather than a mocked one, and it turned up a second thing worth having. no vitest, no module mocks. real bundled plugin registry, real metadata snapshot, real activation resolver, real config shape. the only substitution is the human at the keyboard, and before after so the part i did not expect. diffing the two lists:
the script is nine lines of prompter plus two calls, so rather than carry it in the branch: import { setupPluginConfig } from "./src/wizard/setup.plugin-config.js";
const offered: string[] = [];
const prompter = { /* ...noop, multiselect records opts.options and returns ["__skip__"] */ };
await setupPluginConfig({ config: { plugins: { entries: { xai: { enabled: false } } } }, prompter });
console.log(offered.includes("xai"));run with happy to add the |
f76485f to
f656a0e
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
the wizard decided which plugins to offer from the manifest default , so a plugin config explicitly disabled was still offered , and a plugin turned on through an alias or auto enable was not . it now resolves activation the way runtime does . settings saved under a legacy plugin id are folded onto the canonical id before the wizard reads or writes . enabled , hooks , subagent and llm fold in file order and a policy object is taken whole , the way runtime reads it , so a save never writes back a grant runtime is not applying . config and keys runtime does not read fold with the canonical entry last.
5642d49 to
251040b
Compare
|
the review was right , fixed in 251040b and rebased on main .
the toggle path goes through the same merger , so enable and disable get it too . on main the toggle writer had its own canonical-last fold for everything , which had the same grant problem , so it now calls the merger too . main had also made new tests cover a partial @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
Closing due to inactivity. |
Closes #127578
What Problem This Solves
Fixes an issue where the CLI plugin wizard, during onboarding and
configure, offers plugins that are switched off and skips plugins that are actually running.Both directions are user visible. A plugin explicitly disabled in config is still offered, so the wizard solicits settings for it and then warns that config is present while the plugin is disabled. A plugin activated through slot selection, auto-enable, workspace policy or a platform default is left out, so the wizard never asks about something that does run.
Why This Change Was Made
The inventory decided activation itself:
An explicit
enabled: falseis not=== true, so that arm falls through to the manifest default and the plugin stays in the list. The same shortcut ignores a globalplugins.enabled: false, deny and allow policy, workspace policy, selected slots and context engines, auto-enable reasons, bundled channel configuration, and platform-specific default enablement.It now asks
resolveEffectivePluginActivationState, which is what config validation and gateway startup already use, withisPluginEnabledByDefaultForPlatformfor the default, matchingvalidation-plugin-config.ts. One source of truth for what is active rather than a second, weaker one in the wizard.It is loaded through
createLazyRuntimeModulealongside the existing metadata snapshot import, so the wizard still does not pull the plugin graph in eagerly.User Impact
The wizard offers the plugins that are actually active. It no longer asks for settings for a disabled plugin and then complains about the config it just wrote, and it no longer skips a plugin enabled by policy rather than by an explicit entry.
Evidence
The reported shape, a bundled default-on manifest with
enabled: falsein config, as a test:On the old filter, everything else identical:
The test asserts the multiselect is never reached, so it fails on the wizard offering the plugin at all rather than on a later prompt detail.
vitest run src/wizard src/plugins/config-state.test.tstsc --noEmit -p tsconfig.core.jsonoxfmt --checkon both changed filesNode 24.20.0 and pnpm 12.0.0, matching the engine floor in
package.json.disclaimer: this contribution was prepared with the assistance of an ai agent. i read the wizard inventory, the canonical resolver and the existing validation caller before changing anything, and ran the tests, typecheck and formatter locally.
Real-run evidence
Added after review. Not a mocked test: real bundled plugin registry, real metadata snapshot, real activation resolver, real config. The only substitution is the person at the keyboard, and
WizardPrompteris an injected dependency ofsetupPluginConfig, so supplying one uses the entrypoint rather than bypassing it. The prompter records what the multiselect is offered, then skips.before
after
Diffing the two offered sets shows both directions of the defect, including one I had not written a test for:
memory-coreis activated through canonical slot policy rather than an explicit entry, so the oldenabledByDefault || entry.enabled === truehad no way to see it. The wizard was not asking about a plugin that runs.Reproduce with
node --import ./scripts/tsx.mjs <file>.mtson Node 24.20.0, pnpm 12.0.0:Follow-up: both parity gaps were real
Review found the resolver call still ignored legacy plugin-ID normalization and runtime auto-enable materialization. Both correct, fixed in
e7d17c10.Legacy ids. I normalized with
normalizePluginsConfigWithResolver, whose default isidentityNormalizePluginId. The canonical one is not identity:So a legacy plugin id used as an entry key never lined up with the manifest id, and that entry was silently ignored, which is the same class of bug this PR is about.
Auto-enable. I resolved against the raw config. Runtime materializes auto-enables before it judges activation, so a plugin that is only on because auto-enable turned it on still looked off.
Both come from routing through
resolvePluginActivationInputs, which applies auto-enable, normalizes with the alias-aware resolver, and returns the activation source and reasons. That is the same input the gateway startup path uses:One thing this surfaced in the tests
Turning auto-enable on made an unrelated existing test fail:
makeManifestPlugininsetup.plugin-config.test.tsomitsrootDir, whichPluginManifestRecorddeclares as required and which auto-enable detection resolves. The fixture only survived because the old filter never reached that code. I addedrootDirandoriginrather than switch auto-enable off to keep a mock that cannot survive the real path.Verification after the change
vitest run src/wizard src/plugins/config-state.test.tsxai offered : falsexai offered : truetsc --noEmit -p tsconfig.core.jsonoxfmt --checkFollow-up: carrying legacy entry config through the wizard
The [P1] finding on
setup.plugin-config.ts:228-240is right and it is worth more than the alias read it points at. Fixed in the latest commit.getExistingPluginConfiglooked the entry up by raw key:pluginIdis the manifest id, which is canonical.google-gemini-cli,minimax-portalandminimax-portal-authare real aliases inBUILT_IN_PLUGIN_ALIAS_LOOKUP, so an entry saved under one of those is on a different key and this lookup reads back nothing. Two things follow, not one:[plugin.id], so it lands a second entry on the canonical key and leaves the old one sitting there with the previous valuesSecond point is the data loss. The wizard does not merge, it writes beside.
Fixed with
normalizePluginTargetConfig, the targeted normalizer you pointed to, applied before the read and used as the base for the write so the fold and the write are the same object:One deliberate detail:
if (!changed)now returnsparams.configrather than the folded one. If the user answered nothing, rewriting their entry keys is not something the wizard was asked to do.The legacy-ID regression test you asked for
Uses a real alias rather than an invented one. Config holds
apiKeyundergoogle-gemini-cli, the manifest offersgooglewithapiKeyandregion:With the change: one prompt, for
Regiononly, and one entry afterwards.Without the source change, tests untouched:
It re-asks for the key it already holds. That is the first half of the defect showing up directly, and the entry assertions cover the second.
checks
vitest run src/wizardvitest run src/plugins/config-state.test.tspnpm tsgo:corepnpm tsgo:test:srcoxfmt --checkrun-oxlint.mjs src/wizardOn the earlier question about pinning the
memory-coredirection: this test pins the alias direction against a real alias constant rather than against whichever plugins happen to be bundled, so it does not have the fragility I was worried about there. Happy to add the slot-activated one against a synthetic manifest as well if you want it.Follow-up 2: both findings were right, and one of them was mine to cause
[P2] the lazy boundary i broke
Correct, and the repo says so itself. My static import at line 4 sat above a
createLazyRuntimeModulethat dynamically imports the same module, which makes the lazy one do nothing.pnpm lint:tmp:dynamic-import-wartsnames it:That is a CI failure I introduced and did not run the guard for. Fixed by dropping the static import and taking the normalizer from the lazy module that was already there.
Rather than thread it through every call site, the fold now happens once at the two async entrypoints, so everything below already works on canonical ids and
getExistingPluginConfiggoes back to being a plain lookup:This is better than what I had.
discoverUnconfiguredPluginsis sync and on the real onboard path, and my previous version only folded insidepromptPluginFields, so the plugin list was still built from unfolded config. Both entrypoints keep returningparams.configuntouched when nothing was answered.Guard is clean now:
[P1] discovery
Also correct.
resolvePluginActivationInputstakesdiscoveryand hands it to auto-enable atactivation-context.ts:139, and the snapshot carries one atplugin-metadata-snapshot.ts:649. I forwarded onlymanifestRegistry, so auto-enable re-derived a default scope discovery and a workspace scoped run judged activation against a different generation than the inventory came from. One line:the wiring is tested this time, not the decision
You have twice caught me testing a decision function rather than the wiring around it, so this one watches the real call. The mock wraps the actual resolver instead of replacing it, so every other test in the file keeps running against real activation behaviour:
Remove the
discovery:line and it fails:Worth saying how it failed first: with a sentinel of the wrong shape it got a
TypeErrorfromchannel-catalog-registry.ts:53readingcandidates, which is itself proof the value now travels into the channel auto-enable path instead of being ignored. I gave the sentinel the shape the repo's own tests use,{ candidates: [], diagnostics: [] }.The legacy-id test still discriminates against the real baseline. I checked it against
HEAD~1rather thanHEAD, sinceHEADalready carries the first fold and reverting to it proves nothing:checks
vitest run src/wizardlint:tmp:dynamic-import-wartspnpm tsgo:corepnpm tsgo:test:srcoxfmt --checkFollow-up 3: the fold was unsafe when both keys exist
Right again, and the confidence of 0.99 is deserved. I checked it rather than taking it, and it is worse than one side losing: which side survives depends on the order the keys sit in the file.
Same two entries, same plugin, only the write order differs:
normalizePluginTargetConfigrebuilds the entry from the normalized one, whoseconfigis whichever raw key was applied last. So the settings that disappear are decided by JSON key order. My fold put that on the wizard path for every plugin, so this was mine to cause.the answer was already in the repo
setPluginEnabledInConfighad solved it, comment and all:Copying that into the wizard would have left two implementations of one rule, so it moved to a shared helper in
config-state.tsand both callers use it. The toggle writer's inline block is now one line and its behaviour is unchanged.The wizard fold writes the merged entry back over the one the normalizer kept, reading the merge off the pre-fold config since that is what still holds both keys.
both key orders, as asked
Alias holds
apiKey, canonical holdsregion, and the wizard is answered for a third field. Both orders must land on all three. With the merge reverted both fail, and the two failures are mirror images of each other, which is the order dependence stated in the output:also fixed: the type check i had red
check-test-types-core-1was failing on my previous push and that was mine too:I had reset a capture variable to
undefined, which narrows it, so the optional chain read offnever. It collects into an array now. I had checked types withpnpm tsgo:test:srcbefore pushing, which passes; the shard CI runs ispnpm tsgo:core:test, which fails. I reproduced the failure locally with the right command before fixing it, so I know the gate I am now trusting is the real one.checks
vitest run src/wizard src/plugins/config-state.test.ts src/plugins/toggle-config.test.tspnpm tsgo:corepnpm tsgo:core:testpnpm check:import-cycleslint:tmp:dynamic-import-wartsoxfmt --checksrc/plugins/clawhub.test.tsfails in my checkout, identically with my changes stashed. It asserts that output carries no ansi escape sequences and my terminal forces colour, so I have left it alone.Follow-up 4: the fold could switch a plugin off
Right again, and this was the worst one I have shipped on this PR. I checked it rather than taking it, both directions:
Raw entries are applied in file order, so a later alias beats the canonical entry and that is what the runtime resolves. My fold always sorted canonical last, which is correct for config payload precedence and exactly wrong for policy. Answering any wizard prompt would have written the inverted state back.
Policy now comes from the normalizer, which is the same thing the runtime reads, and only the config payload is merged:
Both directions now agree with the runtime, and the payload merge from the previous round is unaffected:
the conflicting-enable regression test you asked for
Canonical
enabled: false, aliasenabled: truewritten after it, wizard answers a field. Revert the fix and it fails:checks
vitest run src/wizard src/plugins/config-state.test.ts src/plugins/toggle-config.test.tspnpm tsgo:core:testpnpm check:import-cyclesrun-oxlint.mjs src/wizard src/pluginsoxfmt --checkOne note for the record:
pnpm tsgo:corepassed on my first attempt at this andpnpm tsgo:core:testcaught a realTS2322in it, because the normalized entry typesconfigasunknown. I only saw it because I now run the command CI runs rather than the one next to it.Commits were also reauthored to my own address; the content is unchanged and the tree hashes matched before and after.
Follow-up 5: the fold was writing fields the schema forbids
Correct, and it is worse than the finding states. I probed it rather than taking it:
Two problems in one line. It adds
hasAllowedModelsConfig, which the strict persisted schema forbids, and it loses theallowedModelslist that flag was derived from. So a valid entry with an empty allowlist comes back both invalid and missing a real user setting.The mistake was mine and it was structural: in the previous round I moved the base of the fold from the raw entries to the normalized entry, to fix the enablement inversion. The normalized entry is runtime policy, not persisted config, so everything derived came along with it.
The repo already had the right shape.
setPluginEnabledInConfigalways folded the raw entries, which are in persisted form by construction, and then setenableditself. The fold does the same again, and reads onlyenabledoff the normalizer, because that is the single field that has to agree with what the runtime resolves:All four properties hold together now, which is what the last three rounds have each broken one of:
regression test
Revert to the normalized base and it fails with the defect stated plainly:
checks
vitest run src/wizard src/plugins/config-state.test.ts src/plugins/toggle-config.test.tspnpm tsgo:core:testrun-oxlint.mjs src/wizard src/pluginsoxfmt --check