feat(a2a): Introduce /memory command for a2a server
This pull request introduces a new /memory command to the a2a-server and refactors the existing memory commands in the CLI. The core logic for memory management has been centralized in the @google/gemini-cli-core package.
Here's a summary of the changes:
New /memory command for a2a-server
A new top-level /memory command has been added to the a2a-server, which includes the following sub-commands:
- memory show: Displays the current memory contents.
- memory refresh: Refreshes the memory from the source GEMINI.md files.
- memory list: Lists the paths of the GEMINI.md files currently in use.
- memory add: Adds content to the memory.
These commands are registered in the CommandRegistry of the a2a-server.
Refactoring of Memory Commands
The logic for the memory commands, which was previously in the packages/cli/src/ui/commands/memoryCommand.ts file, has been moved to the packages/core/src/commands/memory.ts file. This centralizes the memory management logic, allowing it to be shared between the CLI and the a2a-server.
The following functions have been added to @google/gemini-cli-core and are now used by both the CLI and a2a-server:
- showMemory
- addMemory
- refreshMemory
- listMemoryFiles
The CLI's memoryCommand.ts has been updated to use these new functions from the core package.
Configuration Changes
The loadConfig function in packages/a2a-server/src/config/config.ts has been updated to load the file paths of GEMINI.md files into the configuration. This allows the listMemoryFiles command to access the paths.
Testing
Unit tests have been added for the new memory commands in both the a2a-server and core packages to ensure they function correctly.
/gemini review
Code Review
This pull request refactors memory management logic into the
@google/gemini-cli-corepackage, introducing a new/memorycommand for the a2a-server and updating CLI commands to use new core functions. However, a security audit identified two high-severity Cross-Site Scripting (XSS) vulnerabilities. These stem from echoing raw user input from the 'memory add' command back in responses, which could be exploited if client UIs render this input without proper escaping. Additionally, there are areas for improvement related to error handling robustness and code duplication.
These are original /memory behaviors in cli UI. Please let me know if they should be changed to improve security.