mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 08:24:10 -07:00
fix(core): resolve nested plan directory duplication and relative path policies (#25138)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { PromptProvider } from './promptProvider.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
import { makeRelative } from '../utils/paths.js';
|
||||
import {
|
||||
getAllGeminiMdFilenames,
|
||||
DEFAULT_CONTEXT_FILENAME,
|
||||
@@ -58,6 +59,7 @@ describe('PromptProvider', () => {
|
||||
).getToolRegistry?.() as unknown as ToolRegistry;
|
||||
},
|
||||
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
||||
getProjectRoot: vi.fn().mockReturnValue('/tmp/project-temp'),
|
||||
topicState: new TopicState(),
|
||||
getEnableShellOutputEfficiency: vi.fn().mockReturnValue(true),
|
||||
getSandboxEnabled: vi.fn().mockReturnValue(false),
|
||||
@@ -236,7 +238,14 @@ describe('PromptProvider', () => {
|
||||
expect(prompt).toContain(
|
||||
'`write_file` and `replace` may ONLY be used to write .md plan files',
|
||||
);
|
||||
expect(prompt).toContain('/tmp/project-temp/plans/');
|
||||
|
||||
const expectedRelativePath = makeRelative(
|
||||
mockConfig.storage.getPlansDir(),
|
||||
mockConfig.getProjectRoot(),
|
||||
).replaceAll('\\', '/');
|
||||
expect(prompt).toContain(
|
||||
`write .md plan files to \`${expectedRelativePath}/\``,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import type { HierarchicalMemory } from '../config/memory.js';
|
||||
import { GEMINI_DIR } from '../utils/paths.js';
|
||||
import { GEMINI_DIR, makeRelative } from '../utils/paths.js';
|
||||
import { ApprovalMode } from '../policy/types.js';
|
||||
import * as snippets from './snippets.js';
|
||||
import * as legacySnippets from './snippets.legacy.js';
|
||||
@@ -199,8 +199,19 @@ export class PromptProvider {
|
||||
() => ({
|
||||
interactive: interactiveMode,
|
||||
planModeToolsList,
|
||||
plansDir: context.config.storage.getPlansDir(),
|
||||
approvedPlanPath: context.config.getApprovedPlanPath(),
|
||||
plansDir: makeRelative(
|
||||
context.config.storage.getPlansDir(),
|
||||
context.config.getProjectRoot(),
|
||||
).replaceAll('\\', '/'),
|
||||
approvedPlanPath: (() => {
|
||||
const approvedPath = context.config.getApprovedPlanPath();
|
||||
return approvedPath
|
||||
? makeRelative(
|
||||
approvedPath,
|
||||
context.config.getProjectRoot(),
|
||||
).replaceAll('\\', '/')
|
||||
: undefined;
|
||||
})(),
|
||||
}),
|
||||
isPlanMode,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user