add absolute file path description for windows (#12007)

This commit is contained in:
Gaurav Sehgal
2025-10-27 09:47:13 +05:30
committed by GitHub
parent ee66732ad2
commit 2fa13420ae
4 changed files with 88 additions and 2 deletions

View File

@@ -36,6 +36,14 @@ vi.mock('../telemetry/loggers.js', () => ({
logFileOperation: vi.fn(),
}));
interface EditFileParameterSchema {
properties: {
file_path: {
description: string;
};
};
}
import type { Mock } from 'vitest';
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import type { EditToolParams } from './edit.js';
@@ -1025,6 +1033,38 @@ describe('EditTool', () => {
});
});
describe('constructor', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('should use windows-style path examples on windows', () => {
vi.spyOn(process, 'platform', 'get').mockReturnValue('win32');
const tool = new EditTool({} as unknown as Config);
const schema = tool.schema;
expect(
(schema.parametersJsonSchema as EditFileParameterSchema).properties
.file_path.description,
).toBe(
"The absolute path to the file to modify (e.g., 'C:\\Users\\project\\file.txt'). Must be an absolute path.",
);
});
it('should use unix-style path examples on non-windows platforms', () => {
vi.spyOn(process, 'platform', 'get').mockReturnValue('linux');
const tool = new EditTool({} as unknown as Config);
const schema = tool.schema;
expect(
(schema.parametersJsonSchema as EditFileParameterSchema).properties
.file_path.description,
).toBe(
"The absolute path to the file to modify (e.g., '/home/user/project/file.txt'). Must start with '/'.",
);
});
});
describe('IDE mode', () => {
const testFile = 'edit_me.txt';
let filePath: string;