mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-15 06:12:50 -07:00
refactor: Remove deprecated --all-files flag (#11228)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
+9
-10
@@ -296,16 +296,15 @@ gemini -p "List programming languages" | grep -i "python"
|
|||||||
|
|
||||||
Key command-line options for headless usage:
|
Key command-line options for headless usage:
|
||||||
|
|
||||||
| Option | Description | Example |
|
| Option | Description | Example |
|
||||||
| ----------------------- | ----------------------------------------------- | -------------------------------------------------- |
|
| ----------------------- | ---------------------------------- | -------------------------------------------------- |
|
||||||
| `--prompt`, `-p` | Run in headless mode | `gemini -p "query"` |
|
| `--prompt`, `-p` | Run in headless mode | `gemini -p "query"` |
|
||||||
| `--output-format` | Specify output format (text, json, stream-json) | `gemini -p "query" --output-format stream-json` |
|
| `--output-format` | Specify output format (text, json) | `gemini -p "query" --output-format json` |
|
||||||
| `--model`, `-m` | Specify the Gemini model | `gemini -p "query" -m gemini-2.5-flash` |
|
| `--model`, `-m` | Specify the Gemini model | `gemini -p "query" -m gemini-2.5-flash` |
|
||||||
| `--debug`, `-d` | Enable debug mode | `gemini -p "query" --debug` |
|
| `--debug`, `-d` | Enable debug mode | `gemini -p "query" --debug` |
|
||||||
| `--all-files`, `-a` | Include all files in context | `gemini -p "query" --all-files` |
|
| `--include-directories` | Include additional directories | `gemini -p "query" --include-directories src,docs` |
|
||||||
| `--include-directories` | Include additional directories | `gemini -p "query" --include-directories src,docs` |
|
| `--yolo`, `-y` | Auto-approve all actions | `gemini -p "query" --yolo` |
|
||||||
| `--yolo`, `-y` | Auto-approve all actions | `gemini -p "query" --yolo` |
|
| `--approval-mode` | Set approval mode | `gemini -p "query" --approval-mode auto_edit` |
|
||||||
| `--approval-mode` | Set approval mode | `gemini -p "query" --approval-mode auto_edit` |
|
|
||||||
|
|
||||||
For complete details on all available configuration options, settings files, and
|
For complete details on all available configuration options, settings files, and
|
||||||
environment variables, see the
|
environment variables, see the
|
||||||
|
|||||||
@@ -673,9 +673,7 @@ for that specific session.
|
|||||||
- Sets the sandbox image URI.
|
- Sets the sandbox image URI.
|
||||||
- **`--debug`** (**`-d`**):
|
- **`--debug`** (**`-d`**):
|
||||||
- Enables debug mode for this session, providing more verbose output.
|
- Enables debug mode for this session, providing more verbose output.
|
||||||
- **`--all-files`** (**`-a`**):
|
|
||||||
- If set, recursively includes all files within the current directory as
|
|
||||||
context for the prompt.
|
|
||||||
- **`--help`** (or **`-h`**):
|
- **`--help`** (or **`-h`**):
|
||||||
- Displays help information about command-line arguments.
|
- Displays help information about command-line arguments.
|
||||||
- **`--show-memory-usage`**:
|
- **`--show-memory-usage`**:
|
||||||
|
|||||||
@@ -727,9 +727,7 @@ for that specific session.
|
|||||||
- Sets the sandbox image URI.
|
- Sets the sandbox image URI.
|
||||||
- **`--debug`** (**`-d`**):
|
- **`--debug`** (**`-d`**):
|
||||||
- Enables debug mode for this session, providing more verbose output.
|
- Enables debug mode for this session, providing more verbose output.
|
||||||
- **`--all-files`** (**`-a`**):
|
|
||||||
- If set, recursively includes all files within the current directory as
|
|
||||||
context for the prompt.
|
|
||||||
- **`--help`** (or **`-h`**):
|
- **`--help`** (or **`-h`**):
|
||||||
- Displays help information about command-line arguments.
|
- Displays help information about command-line arguments.
|
||||||
- **`--show-memory-usage`**:
|
- **`--show-memory-usage`**:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export async function loadConfig(
|
|||||||
targetDir: workspaceDir, // Or a specific directory the agent operates on
|
targetDir: workspaceDir, // Or a specific directory the agent operates on
|
||||||
debugMode: process.env['DEBUG'] === 'true' || false,
|
debugMode: process.env['DEBUG'] === 'true' || false,
|
||||||
question: '', // Not used in server mode directly like CLI
|
question: '', // Not used in server mode directly like CLI
|
||||||
fullContext: false, // Server might have different context needs
|
|
||||||
coreTools: settings.coreTools || undefined,
|
coreTools: settings.coreTools || undefined,
|
||||||
excludeTools: settings.excludeTools || undefined,
|
excludeTools: settings.excludeTools || undefined,
|
||||||
showMemoryUsage: settings.showMemoryUsage || false,
|
showMemoryUsage: settings.showMemoryUsage || false,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export interface CliArgs {
|
|||||||
debug: boolean | undefined;
|
debug: boolean | undefined;
|
||||||
prompt: string | undefined;
|
prompt: string | undefined;
|
||||||
promptInteractive: string | undefined;
|
promptInteractive: string | undefined;
|
||||||
allFiles: boolean | undefined;
|
|
||||||
showMemoryUsage: boolean | undefined;
|
showMemoryUsage: boolean | undefined;
|
||||||
yolo: boolean | undefined;
|
yolo: boolean | undefined;
|
||||||
approvalMode: string | undefined;
|
approvalMode: string | undefined;
|
||||||
@@ -208,12 +208,7 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
|
|||||||
nargs: 1,
|
nargs: 1,
|
||||||
description: 'Sandbox image URI.',
|
description: 'Sandbox image URI.',
|
||||||
})
|
})
|
||||||
.option('all-files', {
|
|
||||||
alias: ['a'],
|
|
||||||
type: 'boolean',
|
|
||||||
description: 'Include ALL files in context?',
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
.option('show-memory-usage', {
|
.option('show-memory-usage', {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Show memory usage in status bar',
|
description: 'Show memory usage in status bar',
|
||||||
@@ -314,10 +309,7 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
|
|||||||
'checkpointing',
|
'checkpointing',
|
||||||
'Use the "general.checkpointing.enabled" setting in settings.json instead. This flag will be removed in a future version.',
|
'Use the "general.checkpointing.enabled" setting in settings.json instead. This flag will be removed in a future version.',
|
||||||
)
|
)
|
||||||
.deprecateOption(
|
|
||||||
'all-files',
|
|
||||||
'Use @ includes in the application instead. This flag will be removed in a future version.',
|
|
||||||
)
|
|
||||||
.deprecateOption(
|
.deprecateOption(
|
||||||
'prompt',
|
'prompt',
|
||||||
'Use the positional prompt instead. This flag will be removed in a future version.',
|
'Use the positional prompt instead. This flag will be removed in a future version.',
|
||||||
@@ -708,7 +700,7 @@ export async function loadCliConfig(
|
|||||||
settings.context?.loadMemoryFromIncludeDirectories || false,
|
settings.context?.loadMemoryFromIncludeDirectories || false,
|
||||||
debugMode,
|
debugMode,
|
||||||
question,
|
question,
|
||||||
fullContext: argv.allFiles || false,
|
|
||||||
coreTools: settings.tools?.core || undefined,
|
coreTools: settings.tools?.core || undefined,
|
||||||
allowedTools: allowedTools.length > 0 ? allowedTools : undefined,
|
allowedTools: allowedTools.length > 0 ? allowedTools : undefined,
|
||||||
policyEngineConfig,
|
policyEngineConfig,
|
||||||
|
|||||||
@@ -320,7 +320,6 @@ describe('gemini.tsx main function kitty protocol', () => {
|
|||||||
prompt: undefined,
|
prompt: undefined,
|
||||||
promptInteractive: undefined,
|
promptInteractive: undefined,
|
||||||
query: undefined,
|
query: undefined,
|
||||||
allFiles: undefined,
|
|
||||||
showMemoryUsage: undefined,
|
showMemoryUsage: undefined,
|
||||||
yolo: undefined,
|
yolo: undefined,
|
||||||
approvalMode: undefined,
|
approvalMode: undefined,
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ describe('runNonInteractive', () => {
|
|||||||
getProjectTempDir: vi.fn().mockReturnValue('/test/project/.gemini/tmp'),
|
getProjectTempDir: vi.fn().mockReturnValue('/test/project/.gemini/tmp'),
|
||||||
},
|
},
|
||||||
getIdeMode: vi.fn().mockReturnValue(false),
|
getIdeMode: vi.fn().mockReturnValue(false),
|
||||||
getFullContext: vi.fn().mockReturnValue(false),
|
|
||||||
getContentGeneratorConfig: vi.fn().mockReturnValue({}),
|
getContentGeneratorConfig: vi.fn().mockReturnValue({}),
|
||||||
getDebugMode: vi.fn().mockReturnValue(false),
|
getDebugMode: vi.fn().mockReturnValue(false),
|
||||||
getOutputFormat: vi.fn().mockReturnValue('text'),
|
getOutputFormat: vi.fn().mockReturnValue('text'),
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ interface MockConfigInstanceShape {
|
|||||||
getSandbox: Mock<() => boolean | string>;
|
getSandbox: Mock<() => boolean | string>;
|
||||||
getDebugMode: Mock<() => boolean>;
|
getDebugMode: Mock<() => boolean>;
|
||||||
getQuestion: Mock<() => string | undefined>;
|
getQuestion: Mock<() => string | undefined>;
|
||||||
getFullContext: Mock<() => boolean>;
|
|
||||||
getUserAgent: Mock<() => string>;
|
getUserAgent: Mock<() => string>;
|
||||||
getUserMemory: Mock<() => string>;
|
getUserMemory: Mock<() => string>;
|
||||||
getGeminiMdFileCount: Mock<() => number>;
|
getGeminiMdFileCount: Mock<() => number>;
|
||||||
@@ -93,7 +93,7 @@ describe('useAutoAcceptIndicator', () => {
|
|||||||
getQuestion: vi.fn().mockReturnValue(undefined) as Mock<
|
getQuestion: vi.fn().mockReturnValue(undefined) as Mock<
|
||||||
() => string | undefined
|
() => string | undefined
|
||||||
>,
|
>,
|
||||||
getFullContext: vi.fn().mockReturnValue(false) as Mock<() => boolean>,
|
|
||||||
getUserAgent: vi.fn().mockReturnValue('test-user-agent') as Mock<
|
getUserAgent: vi.fn().mockReturnValue('test-user-agent') as Mock<
|
||||||
() => string
|
() => string
|
||||||
>,
|
>,
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ describe('useGeminiStream', () => {
|
|||||||
targetDir: '/test/dir',
|
targetDir: '/test/dir',
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
question: undefined,
|
question: undefined,
|
||||||
fullContext: false,
|
|
||||||
coreTools: [],
|
coreTools: [],
|
||||||
toolDiscoveryCommand: undefined,
|
toolDiscoveryCommand: undefined,
|
||||||
toolCallCommand: undefined,
|
toolCallCommand: undefined,
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ describe('Server Config (config.ts)', () => {
|
|||||||
const TARGET_DIR = '/path/to/target';
|
const TARGET_DIR = '/path/to/target';
|
||||||
const DEBUG_MODE = false;
|
const DEBUG_MODE = false;
|
||||||
const QUESTION = 'test question';
|
const QUESTION = 'test question';
|
||||||
const FULL_CONTEXT = false;
|
|
||||||
const USER_MEMORY = 'Test User Memory';
|
const USER_MEMORY = 'Test User Memory';
|
||||||
const TELEMETRY_SETTINGS = { enabled: false };
|
const TELEMETRY_SETTINGS = { enabled: false };
|
||||||
const EMBEDDING_MODEL = 'gemini-embedding';
|
const EMBEDDING_MODEL = 'gemini-embedding';
|
||||||
@@ -171,7 +170,6 @@ describe('Server Config (config.ts)', () => {
|
|||||||
targetDir: TARGET_DIR,
|
targetDir: TARGET_DIR,
|
||||||
debugMode: DEBUG_MODE,
|
debugMode: DEBUG_MODE,
|
||||||
question: QUESTION,
|
question: QUESTION,
|
||||||
fullContext: FULL_CONTEXT,
|
|
||||||
userMemory: USER_MEMORY,
|
userMemory: USER_MEMORY,
|
||||||
telemetry: TELEMETRY_SETTINGS,
|
telemetry: TELEMETRY_SETTINGS,
|
||||||
sessionId: SESSION_ID,
|
sessionId: SESSION_ID,
|
||||||
@@ -1006,7 +1004,6 @@ describe('BaseLlmClient Lifecycle', () => {
|
|||||||
const TARGET_DIR = '/path/to/target';
|
const TARGET_DIR = '/path/to/target';
|
||||||
const DEBUG_MODE = false;
|
const DEBUG_MODE = false;
|
||||||
const QUESTION = 'test question';
|
const QUESTION = 'test question';
|
||||||
const FULL_CONTEXT = false;
|
|
||||||
const USER_MEMORY = 'Test User Memory';
|
const USER_MEMORY = 'Test User Memory';
|
||||||
const TELEMETRY_SETTINGS = { enabled: false };
|
const TELEMETRY_SETTINGS = { enabled: false };
|
||||||
const EMBEDDING_MODEL = 'gemini-embedding';
|
const EMBEDDING_MODEL = 'gemini-embedding';
|
||||||
@@ -1018,7 +1015,6 @@ describe('BaseLlmClient Lifecycle', () => {
|
|||||||
targetDir: TARGET_DIR,
|
targetDir: TARGET_DIR,
|
||||||
debugMode: DEBUG_MODE,
|
debugMode: DEBUG_MODE,
|
||||||
question: QUESTION,
|
question: QUESTION,
|
||||||
fullContext: FULL_CONTEXT,
|
|
||||||
userMemory: USER_MEMORY,
|
userMemory: USER_MEMORY,
|
||||||
telemetry: TELEMETRY_SETTINGS,
|
telemetry: TELEMETRY_SETTINGS,
|
||||||
sessionId: SESSION_ID,
|
sessionId: SESSION_ID,
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ export interface ConfigParameters {
|
|||||||
targetDir: string;
|
targetDir: string;
|
||||||
debugMode: boolean;
|
debugMode: boolean;
|
||||||
question?: string;
|
question?: string;
|
||||||
fullContext?: boolean;
|
|
||||||
coreTools?: string[];
|
coreTools?: string[];
|
||||||
allowedTools?: string[];
|
allowedTools?: string[];
|
||||||
excludeTools?: string[];
|
excludeTools?: string[];
|
||||||
@@ -298,7 +298,7 @@ export class Config {
|
|||||||
private workspaceContext: WorkspaceContext;
|
private workspaceContext: WorkspaceContext;
|
||||||
private readonly debugMode: boolean;
|
private readonly debugMode: boolean;
|
||||||
private readonly question: string | undefined;
|
private readonly question: string | undefined;
|
||||||
private readonly fullContext: boolean;
|
|
||||||
private readonly coreTools: string[] | undefined;
|
private readonly coreTools: string[] | undefined;
|
||||||
private readonly allowedTools: string[] | undefined;
|
private readonly allowedTools: string[] | undefined;
|
||||||
private readonly excludeTools: string[] | undefined;
|
private readonly excludeTools: string[] | undefined;
|
||||||
@@ -391,7 +391,7 @@ export class Config {
|
|||||||
);
|
);
|
||||||
this.debugMode = params.debugMode;
|
this.debugMode = params.debugMode;
|
||||||
this.question = params.question;
|
this.question = params.question;
|
||||||
this.fullContext = params.fullContext ?? false;
|
|
||||||
this.coreTools = params.coreTools;
|
this.coreTools = params.coreTools;
|
||||||
this.allowedTools = params.allowedTools;
|
this.allowedTools = params.allowedTools;
|
||||||
this.excludeTools = params.excludeTools;
|
this.excludeTools = params.excludeTools;
|
||||||
@@ -692,10 +692,6 @@ export class Config {
|
|||||||
return this.question;
|
return this.question;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFullContext(): boolean {
|
|
||||||
return this.fullContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
getCoreTools(): string[] | undefined {
|
getCoreTools(): string[] | undefined {
|
||||||
return this.coreTools;
|
return this.coreTools;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ describe('Gemini Client (client.ts)', () => {
|
|||||||
getVertexAI: vi.fn().mockReturnValue(false),
|
getVertexAI: vi.fn().mockReturnValue(false),
|
||||||
getUserAgent: vi.fn().mockReturnValue('test-agent'),
|
getUserAgent: vi.fn().mockReturnValue('test-agent'),
|
||||||
getUserMemory: vi.fn().mockReturnValue(''),
|
getUserMemory: vi.fn().mockReturnValue(''),
|
||||||
getFullContext: vi.fn().mockReturnValue(false),
|
|
||||||
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
||||||
getProxy: vi.fn().mockReturnValue(undefined),
|
getProxy: vi.fn().mockReturnValue(undefined),
|
||||||
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ describe('loggers', () => {
|
|||||||
}),
|
}),
|
||||||
getQuestion: () => 'test-question',
|
getQuestion: () => 'test-question',
|
||||||
getToolRegistry: () => new ToolRegistry(cfg1),
|
getToolRegistry: () => new ToolRegistry(cfg1),
|
||||||
getFullContext: () => false,
|
|
||||||
getUserMemory: () => 'user-memory',
|
getUserMemory: () => 'user-memory',
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ describe('EditTool', () => {
|
|||||||
getSandbox: () => false,
|
getSandbox: () => false,
|
||||||
getDebugMode: () => false,
|
getDebugMode: () => false,
|
||||||
getQuestion: () => undefined,
|
getQuestion: () => undefined,
|
||||||
getFullContext: () => false,
|
|
||||||
getToolDiscoveryCommand: () => undefined,
|
getToolDiscoveryCommand: () => undefined,
|
||||||
getToolCallCommand: () => undefined,
|
getToolCallCommand: () => undefined,
|
||||||
getMcpServerCommand: () => undefined,
|
getMcpServerCommand: () => undefined,
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ describe('SmartEditTool', () => {
|
|||||||
getSandbox: () => false,
|
getSandbox: () => false,
|
||||||
getDebugMode: () => false,
|
getDebugMode: () => false,
|
||||||
getQuestion: () => undefined,
|
getQuestion: () => undefined,
|
||||||
getFullContext: () => false,
|
|
||||||
getToolDiscoveryCommand: () => undefined,
|
getToolDiscoveryCommand: () => undefined,
|
||||||
getToolCallCommand: () => undefined,
|
getToolCallCommand: () => undefined,
|
||||||
getMcpServerCommand: () => undefined,
|
getMcpServerCommand: () => undefined,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ const mockConfigInternal = {
|
|||||||
getSandbox: () => false,
|
getSandbox: () => false,
|
||||||
getDebugMode: () => false,
|
getDebugMode: () => false,
|
||||||
getQuestion: () => undefined,
|
getQuestion: () => undefined,
|
||||||
getFullContext: () => false,
|
|
||||||
getToolDiscoveryCommand: () => undefined,
|
getToolDiscoveryCommand: () => undefined,
|
||||||
getToolCallCommand: () => undefined,
|
getToolCallCommand: () => undefined,
|
||||||
getMcpServerCommand: () => undefined,
|
getMcpServerCommand: () => undefined,
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ describe('editCorrector', () => {
|
|||||||
targetDir: '/test',
|
targetDir: '/test',
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
question: undefined as string | undefined,
|
question: undefined as string | undefined,
|
||||||
fullContext: false,
|
|
||||||
coreTools: undefined as string[] | undefined,
|
coreTools: undefined as string[] | undefined,
|
||||||
toolDiscoveryCommand: undefined as string | undefined,
|
toolDiscoveryCommand: undefined as string | undefined,
|
||||||
toolCallCommand: undefined as string | undefined,
|
toolCallCommand: undefined as string | undefined,
|
||||||
@@ -188,7 +188,7 @@ describe('editCorrector', () => {
|
|||||||
getToolRegistry: vi.fn(() => mockToolRegistry),
|
getToolRegistry: vi.fn(() => mockToolRegistry),
|
||||||
getDebugMode: vi.fn(() => configParams.debugMode),
|
getDebugMode: vi.fn(() => configParams.debugMode),
|
||||||
getQuestion: vi.fn(() => configParams.question),
|
getQuestion: vi.fn(() => configParams.question),
|
||||||
getFullContext: vi.fn(() => configParams.fullContext),
|
|
||||||
getCoreTools: vi.fn(() => configParams.coreTools),
|
getCoreTools: vi.fn(() => configParams.coreTools),
|
||||||
getToolDiscoveryCommand: vi.fn(() => configParams.toolDiscoveryCommand),
|
getToolDiscoveryCommand: vi.fn(() => configParams.toolDiscoveryCommand),
|
||||||
getToolCallCommand: vi.fn(() => configParams.toolCallCommand),
|
getToolCallCommand: vi.fn(() => configParams.toolCallCommand),
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ describe('getEnvironmentContext', () => {
|
|||||||
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
||||||
}),
|
}),
|
||||||
getFileService: vi.fn(),
|
getFileService: vi.fn(),
|
||||||
getFullContext: vi.fn().mockReturnValue(false),
|
|
||||||
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -142,32 +142,7 @@ describe('getEnvironmentContext', () => {
|
|||||||
expect(getFolderStructure).toHaveBeenCalledTimes(2);
|
expect(getFolderStructure).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include full file context when getFullContext is true', async () => {
|
|
||||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
|
||||||
const mockReadManyFilesTool = {
|
|
||||||
build: vi.fn().mockReturnValue({
|
|
||||||
execute: vi
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue({ llmContent: 'Full file content here' }),
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
mockToolRegistry.getTool.mockReturnValue(mockReadManyFilesTool);
|
|
||||||
|
|
||||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
|
||||||
|
|
||||||
expect(parts.length).toBe(2);
|
|
||||||
expect(parts[1].text).toBe(
|
|
||||||
'\n--- Full File Context ---\nFull file content here',
|
|
||||||
);
|
|
||||||
expect(mockToolRegistry.getTool).toHaveBeenCalledWith('read_many_files');
|
|
||||||
expect(mockReadManyFilesTool.build).toHaveBeenCalledWith({
|
|
||||||
paths: ['**/*'],
|
|
||||||
useDefaultExcludes: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle read_many_files returning no content', async () => {
|
it('should handle read_many_files returning no content', async () => {
|
||||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
|
||||||
const mockReadManyFilesTool = {
|
const mockReadManyFilesTool = {
|
||||||
build: vi.fn().mockReturnValue({
|
build: vi.fn().mockReturnValue({
|
||||||
execute: vi.fn().mockResolvedValue({ llmContent: '' }),
|
execute: vi.fn().mockResolvedValue({ llmContent: '' }),
|
||||||
@@ -181,26 +156,10 @@ describe('getEnvironmentContext', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle read_many_files tool not being found', async () => {
|
it('should handle read_many_files tool not being found', async () => {
|
||||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
|
||||||
mockToolRegistry.getTool.mockReturnValue(null);
|
mockToolRegistry.getTool.mockReturnValue(null);
|
||||||
|
|
||||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||||
|
|
||||||
expect(parts.length).toBe(1); // No extra part added
|
expect(parts.length).toBe(1); // No extra part added
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle errors when reading full file context', async () => {
|
|
||||||
mockConfig.getFullContext = vi.fn().mockReturnValue(true);
|
|
||||||
const mockReadManyFilesTool = {
|
|
||||||
build: vi.fn().mockReturnValue({
|
|
||||||
execute: vi.fn().mockRejectedValue(new Error('Read error')),
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
mockToolRegistry.getTool.mockReturnValue(mockReadManyFilesTool);
|
|
||||||
|
|
||||||
const parts = await getEnvironmentContext(mockConfig as Config);
|
|
||||||
|
|
||||||
expect(parts.length).toBe(2);
|
|
||||||
expect(parts[1].text).toBe('\n--- Error reading full file context ---');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -68,42 +68,6 @@ ${directoryContext}
|
|||||||
`.trim();
|
`.trim();
|
||||||
|
|
||||||
const initialParts: Part[] = [{ text: context }];
|
const initialParts: Part[] = [{ text: context }];
|
||||||
const toolRegistry = config.getToolRegistry();
|
|
||||||
|
|
||||||
// Add full file context if the flag is set
|
|
||||||
if (config.getFullContext()) {
|
|
||||||
try {
|
|
||||||
const readManyFilesTool = toolRegistry.getTool('read_many_files');
|
|
||||||
if (readManyFilesTool) {
|
|
||||||
const invocation = readManyFilesTool.build({
|
|
||||||
paths: ['**/*'], // Read everything recursively
|
|
||||||
useDefaultExcludes: true, // Use default excludes
|
|
||||||
});
|
|
||||||
|
|
||||||
// Read all files in the target directory
|
|
||||||
const result = await invocation.execute(AbortSignal.timeout(30000));
|
|
||||||
if (result.llmContent) {
|
|
||||||
initialParts.push({
|
|
||||||
text: `\n--- Full File Context ---\n${result.llmContent}`,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.warn(
|
|
||||||
'Full context requested, but read_many_files returned no content.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn(
|
|
||||||
'Full context requested, but read_many_files tool not found.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// Not using reportError here as it's a startup/config phase, not a chat/generation phase error.
|
|
||||||
console.error('Error reading full file context:', error);
|
|
||||||
initialParts.push({
|
|
||||||
text: '\n--- Error reading full file context ---',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return initialParts;
|
return initialParts;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user