gemini-cli
gemini-cli copied to clipboard
[JITContext] Implement ContextManager and Feature Flag
Description
Establish the core infrastructure for JIT context loading by introducing a feature flag and a new service to manage dynamic context state.
Acceptance Criteria
- [ ] A new boolean setting
experimental.jitContextis available inSettings, defaulting tofalse. - [ ] The
Configclass has anexperimentalJitContextproperty initialized from settings. - [ ] A new
ContextManagerclass is created inpackages/core/src/services/contextManager.ts. - [ ]
ContextManagercan track loaded file paths to avoid duplicate loading. - [ ]
ContextManagerimplements adiscoverContext(accessedPath: string)method that traverses upwards from the accessed path to the project root, finding relevantGEMINI.mdfiles. - [ ] The
Configclass initializesContextManageronly when the experiment flag is enabled. - [ ] The
Configclass is updated to support separated memory tiers:globalMemory(Tier 1) andenvironmentMemory(Tier 2), while maintaininguserMemoryfor legacy compatibility.
Technical Details
- Modify
packages/cli/src/config/settingsSchema.ts: Add the new experimental settingjitContext. - Create
packages/core/src/services/contextManager.ts:- Implement
ContextManagerwith aSet<string>forloadedPaths. - Implement
discoverContextlogic: upward traversal, file existence check, read file, process imports, return formatted string.
- Implement
- Modify
packages/core/src/config/config.ts:- Add
experimentalJitContexttoConfigParametersandConfig. - Add
globalMemoryandenvironmentMemorystrings toConfig. - Initialize
this.contextManagerinConfig.initialize()if the flag is true.
- Add