mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-08-08 16:11:58 -07:00
7504259d72
Co-authored-by: Jenna Inouye <jinouye@google.com>
75 lines
1.8 KiB
TypeScript
75 lines
1.8 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {
|
|
listMemoryFiles,
|
|
refreshMemory,
|
|
showMemory,
|
|
} from '@google/gemini-cli-core';
|
|
import type {
|
|
Command,
|
|
CommandContext,
|
|
CommandExecutionResponse,
|
|
} from './types.js';
|
|
|
|
export class MemoryCommand implements Command {
|
|
readonly name = 'memory';
|
|
readonly description = 'Manage memory.';
|
|
readonly subCommands = [
|
|
new ShowMemoryCommand(),
|
|
new RefreshMemoryCommand(),
|
|
new ListMemoryCommand(),
|
|
];
|
|
readonly topLevel = true;
|
|
readonly requiresWorkspace = true;
|
|
|
|
async execute(
|
|
context: CommandContext,
|
|
_: string[],
|
|
): Promise<CommandExecutionResponse> {
|
|
return new ShowMemoryCommand().execute(context, _);
|
|
}
|
|
}
|
|
|
|
export class ShowMemoryCommand implements Command {
|
|
readonly name = 'memory show';
|
|
readonly description = 'Shows the current memory contents.';
|
|
|
|
async execute(
|
|
context: CommandContext,
|
|
_: string[],
|
|
): Promise<CommandExecutionResponse> {
|
|
const result = showMemory(context.config);
|
|
return { name: this.name, data: result.content };
|
|
}
|
|
}
|
|
|
|
export class RefreshMemoryCommand implements Command {
|
|
readonly name = 'memory refresh';
|
|
readonly description = 'Refreshes the memory from the source.';
|
|
|
|
async execute(
|
|
context: CommandContext,
|
|
_: string[],
|
|
): Promise<CommandExecutionResponse> {
|
|
const result = await refreshMemory(context.config);
|
|
return { name: this.name, data: result.content };
|
|
}
|
|
}
|
|
|
|
export class ListMemoryCommand implements Command {
|
|
readonly name = 'memory list';
|
|
readonly description = 'Lists the paths of the GEMINI.md files in use.';
|
|
|
|
async execute(
|
|
context: CommandContext,
|
|
_: string[],
|
|
): Promise<CommandExecutionResponse> {
|
|
const result = listMemoryFiles(context.config);
|
|
return { name: this.name, data: result.content };
|
|
}
|
|
}
|