Repository navigation
feat(plugins): narrow CLI loading via activation planning - #65120
Conversation
|
Found 1 test failure on Blacksmith runners: Failure
|
Greptile SummaryThis PR introduces
Confidence Score: 4/5Safe to merge after resolving the null/undefined type mismatch in cli.ts; runtime behavior is correct but pnpm tsgo will reject the current types. One P1 TypeScript strict-mode type error (null vs undefined for primaryCommand) needs fixing before the full type-check gate passes. All other findings are P2 (dead code style). The activation logic, fallback behavior, loader wiring, and tests are solid. src/plugins/cli.ts — the primaryCommand: primary assignment needs Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/plugins/cli.ts
Line: 51-56
Comment:
**`null` assigned to `string | undefined` — strict TypeScript type error**
`primary` is `string | null` (because `RegisterPluginCliOptions.primary?: string | null` combined with `?? null`), but `PluginCliPublicLoadParams.primaryCommand` is typed `primaryCommand?: string` (i.e., `string | undefined`). With `strict: true` in `tsconfig.json`, `null` is not assignable to `string | undefined`, so `pnpm tsgo` will reject this.
Functionally, the runtime is safe (`null?.trim()` → `undefined`, and `!undefined` → early return in `resolvePrimaryCommandPluginIds`), but the type violation needs fixing:
```suggestion
await registerPluginCliCommandGroups(
program,
await loadPluginCliRegistrationEntriesWithDefaults({
cfg,
env,
loaderOptions,
primaryCommand: primary ?? undefined,
}),
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/plugins/activation-planner.ts
Line: 59-62
Comment:
**Unreachable `return false` after exhaustive switch**
The switch covers all five variants of `PluginActivationPlannerTrigger` (every `case` returns), so the `return false` on line 62 is dead code. The same pattern appears at the end of `hasActivationCapability` (line 111). Consider removing both, or replacing them with a `satisfies never` exhaustiveness check — that would turn future union extensions into a compile-time error rather than silently falling through.
```suggestion
case "capability":
return hasActivationCapability(plugin, trigger.capability);
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into feat/ocplugins-..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78dcf29704
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
…5120) * feat(plugins): narrow cli loading via activation planning * fix(plugins): normalize primary CLI command nullability * fix(plugins): enforce activation planner exhaustiveness
Summary
Describe the problem and fix in 2–5 bullets:
registerPluginCliCommands(..., { primary })knew the requested command root, but the plugin CLI loaders still loaded every CLI-capable plugin before registration.src/plugins/activation-planner.ts, taught it to resolve manifest-driven command/provider/channel/route/capability matches, and used command planning to passonlyPluginIdsinto CLI runtime/metadata loaders when a primary command is known.activationis now a real narrowing hint and that command planning still falls back to legacycommandAliasesmetadata for older plugins.AI-assisted: yes. Fully tested on the touched surface listed below.
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.activation.onCommands; older plugins still benefit fromcommandAliasesfallback.Diagram (if applicable)
For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write
N/A.Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation:Repro + Verification
Environment
Steps
registerPluginCliCommands(..., { mode: "lazy", primary: "memory" }).Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm test:serial src/plugins/activation-planner.test.tspnpm test:serial src/plugins/cli.test.ts -t 'registers a selected plugin primary eagerly during lazy startup|keeps full CLI loading when primary command planning finds no plugin match'pnpm lint -- src/plugins/activation-planner.ts src/plugins/activation-planner.test.ts src/plugins/cli-registry-loader.ts src/plugins/cli.ts src/plugins/cli.test.tspnpm buildcommandAliases[].cliCommandfallbackcommandAliases[].nameonlyPluginIdsoverride when planning finds no matchReview Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.onlyPluginIdswhen planning returns a non-empty set; otherwise it falls back to the previous full-load behavior.activation.onCommandsremains the preferred path and docs now say that clearly.