fix(core): resolve nested plan directory duplication and relative path policies (#25138)

This commit is contained in:
Mahima Shanware
2026-04-21 14:20:57 -04:00
committed by GitHub
parent c260550146
commit a4e98c0a4c
17 changed files with 283 additions and 76 deletions
@@ -76,6 +76,7 @@ vi.mocked(IdeClient.getInstance).mockResolvedValue(
const fsService = new StandardFileSystemService();
const mockConfigInternal = {
getTargetDir: () => rootDir,
getProjectRoot: () => rootDir,
getApprovalMode: vi.fn(() => ApprovalMode.DEFAULT),
setApprovalMode: vi.fn(),
getGeminiClient: vi.fn(), // Initialize as a plain mock function
@@ -1113,4 +1114,26 @@ describe('WriteFileTool', () => {
);
});
});
describe('plan mode path handling', () => {
const abortSignal = new AbortController().signal;
it('should correctly resolve nested paths in plan mode', async () => {
vi.mocked(mockConfig.isPlanMode).mockReturnValue(true);
// Extend storage mock with getPlansDir
mockConfig.storage.getPlansDir = vi.fn().mockReturnValue(plansDir);
const nestedFilePath = 'conductor/tracks/test.md';
const invocation = tool.build({
file_path: nestedFilePath,
content: 'nested content',
});
await invocation.execute({ abortSignal });
const expectedWritePath = path.join(plansDir, 'conductor/tracks/test.md');
expect(fs.existsSync(expectedWritePath)).toBe(true);
expect(fs.readFileSync(expectedWritePath, 'utf8')).toBe('nested content');
});
});
});