mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
feat: handle multiple dynamic context filenames in system prompt (#18598)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
} from '../tools/tool-names.js';
|
||||
import { resolveModel, isPreviewModel } from '../config/models.js';
|
||||
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
||||
import { getAllGeminiMdFilenames } from '../tools/memoryTool.js';
|
||||
|
||||
/**
|
||||
* Orchestrates prompt generation by gathering context and building options.
|
||||
@@ -56,6 +57,7 @@ export class PromptProvider {
|
||||
const desiredModel = resolveModel(config.getActiveModel());
|
||||
const isGemini3 = isPreviewModel(desiredModel);
|
||||
const activeSnippets = isGemini3 ? snippets : legacySnippets;
|
||||
const contextFilenames = getAllGeminiMdFilenames();
|
||||
|
||||
// --- Context Gathering ---
|
||||
let planModeToolsList = PLAN_MODE_TOOLS.filter((t) =>
|
||||
@@ -114,6 +116,7 @@ export class PromptProvider {
|
||||
interactive: interactiveMode,
|
||||
isGemini3,
|
||||
hasSkills: skills.length > 0,
|
||||
contextFilenames,
|
||||
})),
|
||||
subAgents: this.withSection('agentContexts', () =>
|
||||
config
|
||||
@@ -191,7 +194,11 @@ export class PromptProvider {
|
||||
}
|
||||
|
||||
// --- Finalization (Shell) ---
|
||||
const finalPrompt = activeSnippets.renderFinalShell(basePrompt, userMemory);
|
||||
const finalPrompt = activeSnippets.renderFinalShell(
|
||||
basePrompt,
|
||||
userMemory,
|
||||
contextFilenames,
|
||||
);
|
||||
|
||||
// Sanitize erratic newlines from composition
|
||||
const sanitizedPrompt = finalPrompt.replace(/\n{3,}/g, '\n\n');
|
||||
|
||||
Reference in New Issue
Block a user