mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-12 20:37:08 -07:00
refactor: apply architectural refinements for token efficiency and prompt spacing
This commit is contained in:
@@ -572,20 +572,20 @@ function workflowStepResearch(options: PrimaryWorkflowsOptions): string {
|
||||
}
|
||||
|
||||
const validationClause = options.enableGrep
|
||||
? ` Use ${grepName} with context or ${readFileName} with precise ranges to validate all assumptions.`
|
||||
: ` Use ${readFileName} to validate all assumptions.`;
|
||||
? `Use ${grepName} with context or ${readFileName} with precise ranges to validate all assumptions.`
|
||||
: `Use ${readFileName} to validate all assumptions.`;
|
||||
|
||||
if (options.enableCodebaseInvestigator) {
|
||||
let subAgentSearch = '';
|
||||
if (searchTools.length > 0) {
|
||||
const toolsStr = searchTools.join(' or ');
|
||||
subAgentSearch = ` For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), use ${toolsStr} directly in parallel.`;
|
||||
subAgentSearch = `For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), use ${toolsStr} directly in parallel. `;
|
||||
}
|
||||
|
||||
return `1. **Research:** Systematically map the codebase and validate assumptions. Utilize specialized sub-agents (e.g., \`codebase_investigator\`) as the primary mechanism for initial discovery when the task involves **complex refactoring, codebase exploration or system-wide analysis**.${subAgentSearch}${validationClause} **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
|
||||
return `1. **Research:** Systematically map the codebase and validate assumptions. Utilize specialized sub-agents (e.g., \`codebase_investigator\`) as the primary mechanism for initial discovery when the task involves **complex refactoring, codebase exploration or system-wide analysis**. ${subAgentSearch}${validationClause} **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
|
||||
}
|
||||
|
||||
return `1. **Research:** Systematically map the codebase and validate assumptions.${searchSentence}${validationClause} **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
|
||||
return `1. **Research:** Systematically map the codebase and validate assumptions.${searchSentence} ${validationClause} **Prioritize empirical reproduction of reported issues to confirm the failure state.**${suggestion}`;
|
||||
}
|
||||
|
||||
function workflowStepStrategy(options: PrimaryWorkflowsOptions): string {
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { FunctionDeclaration, PartUnion } from '@google/genai';
|
||||
import {
|
||||
processSingleFileContent,
|
||||
getSpecificMimeType,
|
||||
DEFAULT_MAX_LINES_TEXT_FILE,
|
||||
} from '../utils/fileUtils.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
import { FileOperation } from '../telemetry/metrics.js';
|
||||
@@ -264,7 +265,7 @@ export class ReadFileTool extends BaseDeclarativeTool<
|
||||
return {
|
||||
name: this.name,
|
||||
description: isGemini3
|
||||
? `Reads a specific range of a file (up to 2,000 lines). **Important:** For high token efficiency, avoid reading large files in their entirety. Use 'grep_search' to find symbols or 'run_shell_command' with 'sed' for surgical block extraction instead of broad file reads. Handles text, images, audio, and PDF files.`
|
||||
? `Reads a specific range of a file (up to ${DEFAULT_MAX_LINES_TEXT_FILE} lines). **Important:** For high token efficiency, avoid reading large files in their entirety. Use 'grep_search' to find symbols or 'run_shell_command' with 'sed' for surgical block extraction instead of broad file reads. Handles text, images, audio, and PDF files.`
|
||||
: `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images, audio, and PDF files. For text files, it can read specific line ranges.`,
|
||||
parametersJsonSchema: {
|
||||
properties,
|
||||
|
||||
@@ -18,6 +18,7 @@ import type { Config } from '../config/config.js';
|
||||
import { fileExists } from '../utils/fileUtils.js';
|
||||
import { Storage } from '../config/storage.js';
|
||||
import { GREP_TOOL_NAME } from './tool-names.js';
|
||||
import { GREP_DEFINITION } from './definitions/coreTools.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
import {
|
||||
FileExclusions,
|
||||
@@ -559,7 +560,7 @@ export class RipGrepTool extends BaseDeclarativeTool<
|
||||
super(
|
||||
RipGrepTool.Name,
|
||||
'SearchText',
|
||||
'FAST regular expression search. This is the **primary discovery tool** for locating code. Use context parameters (`context`, `after`, `before`) to read code surrounding matches in a single turn, often eliminating the need for a separate `read_file` call. (max 100 matches).',
|
||||
GREP_DEFINITION.base.description,
|
||||
Kind.Search,
|
||||
{
|
||||
properties: {
|
||||
|
||||
Reference in New Issue
Block a user