feat: add default injection toggle and managed fallback plugin discovery#2122
feat: add default injection toggle and managed fallback plugin discovery#2122SupenBysz wants to merge 7 commits intocode-yeongyu:devfrom
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
|
Milestone alignment update (issue/work-order):
M2 gate checklist:
Plan source: |
There was a problem hiding this comment.
1 issue found across 13 files
Confidence score: 3/5
- Potential memory leak in
src/plugin/hooks/create-transform-hooks.ts: whendefault_injection_toggleis disabled, producer hooks may still register without the consumer injector, risking uncollected resources. - This carries some runtime risk despite being a single issue, so merge confidence is moderate rather than high.
- Pay close attention to
src/plugin/hooks/create-transform-hooks.ts- ensure hooks are created/cleaned consistently when the injection toggle is off.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/plugin/hooks/create-transform-hooks.ts">
<violation number="1" location="src/plugin/hooks/create-transform-hooks.ts:58">
P1: Potential memory leak: when `default_injection_toggle` is disabled, the context injector transform hook (consumer) is not created, but other hooks like `claudeCodeHooks` and `keywordDetector` (producers) may still register context data to the shared `contextCollector` singleton. Without the consumer to call `consume()` and clear the sessions Map, state will accumulate unbounded over time.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| const contextInjectorMessagesTransform = | ||
| createContextInjectorMessagesTransformHook(contextCollector) | ||
| const contextInjectorMessagesTransform = isContextInjectionEnabled |
There was a problem hiding this comment.
P1: Potential memory leak: when default_injection_toggle is disabled, the context injector transform hook (consumer) is not created, but other hooks like claudeCodeHooks and keywordDetector (producers) may still register context data to the shared contextCollector singleton. Without the consumer to call consume() and clear the sessions Map, state will accumulate unbounded over time.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/plugin/hooks/create-transform-hooks.ts, line 58:
<comment>Potential memory leak: when `default_injection_toggle` is disabled, the context injector transform hook (consumer) is not created, but other hooks like `claudeCodeHooks` and `keywordDetector` (producers) may still register context data to the shared `contextCollector` singleton. Without the consumer to call `consume()` and clear the sessions Map, state will accumulate unbounded over time.</comment>
<file context>
@@ -52,8 +55,13 @@ export function createTransformHooks(args: {
- const contextInjectorMessagesTransform =
- createContextInjectorMessagesTransformHook(contextCollector)
+ const contextInjectorMessagesTransform = isContextInjectionEnabled
+ ? safeCreateHook(
+ "context-injector",
</file context>
|
Milestone execution note:\n\n- M2 target: merge after M1 (#2119) is merged.\n- This PR is intentionally stacked on top of the M1 baseline.\n- I cannot request reviewers or merge from this account due repository permission limits.\n\nMaintainer action needed:\n1) Merge #2119\n2) Re-check #2122 diff on latest dev\n3) Merge #2122\n\nCurrent local verification for this PR scope is complete (tests/typecheck/build). |
|
Milestone source-of-truth synced from GitLab :\n\n- M0-Architecture-and-UX-Freeze (2026-02-26 -> 2026-03-04)\n- M1-Desktop-OEM-Alpha (2026-03-05 -> 2026-03-19)\n- M2-Mobile-Realtime-MVP (2026-03-20 -> 2026-04-02)\n- M3-Security-and-Beta (2026-04-03 -> 2026-04-16)\n\nThis PR is aligned to M1 and keeps stack dependency order: #2119 -> #2122. |
|
Milestone source-of-truth synced from GitLab group ktai:
This PR is aligned to desktop M1 issue #5 (OEM default integration + disable strategy) and keeps stack dependency order: #2119 -> #2122. |
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
|
Execution-ready milestone gate status:
Maintainer runbook:
I can execute step 4 immediately after the merges are done. |
Summary
default_injection_toggleconfig field and wire it into transform hook creationcontextInjectorMessagesTransformby config while preserving default-enabled behaviorinstalled_plugins.jsonis missingDependency Note
This branch is stacked on top of #2119 because it depends on its regression baseline.
While #2119 is open, this PR includes those base commits in GitHub history view.
Review focus for this PR:
325e0016,01c79e3e,c9af780b.Validation
bun test src/shared/model-error-classifier.test.ts src/hooks/model-fallback/hook.test.ts src/plugin/event.model-fallback.test.ts src/cli/model-fallback.test.ts src/hooks/session-notification.test.ts src/hooks/session-notification-input-needed.test.ts src/plugin/tool-execute-before-session-notification.test.ts src/cli/mcp-oauth/login.test.ts src/plugin-config.test.ts src/plugin/hooks/create-transform-hooks.test.ts src/features/claude-code-plugin-loader/discovery.test.tsbun run typecheckbun run buildResult:
Risk
Rollback
Revert PR-scoped files and rerun the same validation chain.
Summary by cubic
Adds a toggle to enable/disable default context injection and injects a managed default plugin when no plugin database is found, improving first-run reliability and control over message transforms. Stabilizes fallback provider selection, fixes session-notification state leakage, and syncs GitLab-style delivery docs to the ktai roadmap milestones.
New Features
Bug Fixes
Written for commit 0286a78. Summary will update on new commits.