feat(plan): add core logic and exit_plan_mode tool definition (#18110)

This commit is contained in:
Jerop Kipruto
2026-02-02 22:30:03 -05:00
committed by GitHub
parent 01e33465bd
commit ed26ea49e9
13 changed files with 981 additions and 2 deletions

View File

@@ -34,6 +34,8 @@ import {
readWasmBinaryFromDisk,
saveTruncatedToolOutput,
formatTruncatedToolOutput,
getRealPath,
isEmpty,
} from './fileUtils.js';
import { StandardFileSystemService } from '../services/fileSystemService.js';
@@ -172,6 +174,47 @@ describe('fileUtils', () => {
);
});
describe('getRealPath', () => {
it('should resolve a real path for an existing file', () => {
const testFile = path.join(tempRootDir, 'real.txt');
actualNodeFs.writeFileSync(testFile, 'content');
expect(getRealPath(testFile)).toBe(actualNodeFs.realpathSync(testFile));
});
it('should return absolute resolved path for a non-existent file', () => {
const ghostFile = path.join(tempRootDir, 'ghost.txt');
expect(getRealPath(ghostFile)).toBe(path.resolve(ghostFile));
});
it('should resolve symbolic links', () => {
const targetFile = path.join(tempRootDir, 'target.txt');
const linkFile = path.join(tempRootDir, 'link.txt');
actualNodeFs.writeFileSync(targetFile, 'content');
actualNodeFs.symlinkSync(targetFile, linkFile);
expect(getRealPath(linkFile)).toBe(actualNodeFs.realpathSync(targetFile));
});
});
describe('isEmpty', () => {
it('should return false for a non-empty file', async () => {
const testFile = path.join(tempRootDir, 'full.txt');
actualNodeFs.writeFileSync(testFile, 'some content');
expect(await isEmpty(testFile)).toBe(false);
});
it('should return true for an empty file', async () => {
const testFile = path.join(tempRootDir, 'empty.txt');
actualNodeFs.writeFileSync(testFile, ' ');
expect(await isEmpty(testFile)).toBe(true);
});
it('should return true for a non-existent file (defensive)', async () => {
const testFile = path.join(tempRootDir, 'ghost.txt');
expect(await isEmpty(testFile)).toBe(true);
});
});
describe('fileExists', () => {
it('should return true if the file exists', async () => {
const testFile = path.join(tempRootDir, 'exists.txt');