gemini-cli
gemini-cli copied to clipboard
feat(core): Implement JIT context memory loading and UI sync
TLDR
Refactors memory loading to support the Experimental JIT Context feature. It introduces a unified refresh() method in ContextManager for JIT mode, ensures the UI receives updates via events, and properly includes environment memory (and MCP instructions) in the system context.
Dive Deeper
- ContextManager Refactor: Introduced a
refresh()method to unify memory reloading (Global + Environment) and event emission. Removed legacyloadGlobalMemorycalls from Config initialization. - Config Delegation:
Configdelegates memory state retrieval (file count, paths) toContextManagerwhen JIT is enabled. - Event Optimization: Simplified
MemoryChangedevent to only emitfileCount, as content and paths are pulled from Config on demand or not required for simple UI updates. - Memory Refresh: Updated
/memory refreshcommand to useContextManager.refresh()when JIT is enabled. - System Context:
getEnvironmentContextnow includes the content of loaded environment memory files. MCP instructions are appended to environment memory in JIT mode.
Reviewer Test Plan
- Enable JIT: Set
experimental.jitContext: truein settings. - Startup: Launch the CLI. Verify that the "Using: X GEMINI.md files" indicator appears and shows the correct count.
- Context: Run
/resetand start a chat. Verify (via debug logs or model response) that the system instruction includes content from yourGEMINI.mdfiles AND any active MCP server instructions. - Refresh: Modify a
GEMINI.mdfile and run/memory refresh. Verify the count updates and the model sees the new content. - Legacy: Disable JIT. Verify that memory loading works as before (using the CLI-side loader).
Testing Matrix
| 🍏 | 🪟 | 🐧 | |
|---|---|---|---|
| npm run | ✅ | ❓ | ❓ |
| npx | ✅ | ❓ | ❓ |
| Docker | ❓ | ❓ | ❓ |
| Podman | ❓ | - | - |
| Seatbelt | ❓ | - | - |