gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

[JITContext] Implement ContextManager and Feature Flag

Open abhipatel12 opened this issue 2 months ago • 0 comments

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.jitContext is available in Settings, defaulting to false.
  • [ ] The Config class has an experimentalJitContext property initialized from settings.
  • [ ] A new ContextManager class is created in packages/core/src/services/contextManager.ts.
  • [ ] ContextManager can track loaded file paths to avoid duplicate loading.
  • [ ] ContextManager implements a discoverContext(accessedPath: string) method that traverses upwards from the accessed path to the project root, finding relevant GEMINI.md files.
  • [ ] The Config class initializes ContextManager only when the experiment flag is enabled.
  • [ ] The Config class is updated to support separated memory tiers: globalMemory (Tier 1) and environmentMemory (Tier 2), while maintaining userMemory for legacy compatibility.

Technical Details

  • Modify packages/cli/src/config/settingsSchema.ts: Add the new experimental setting jitContext.
  • Create packages/core/src/services/contextManager.ts:
    • Implement ContextManager with a Set<string> for loadedPaths.
    • Implement discoverContext logic: upward traversal, file existence check, read file, process imports, return formatted string.
  • Modify packages/core/src/config/config.ts:
    • Add experimentalJitContext to ConfigParameters and Config.
    • Add globalMemory and environmentMemory strings to Config.
    • Initialize this.contextManager in Config.initialize() if the flag is true.

abhipatel12 avatar Oct 24 '25 20:10 abhipatel12