2025-10-01 16:56:50 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { expect, describe, it, beforeEach, afterEach } from 'vitest';
|
2025-10-11 08:33:01 -07:00
|
|
|
import { TestRig, printDebugInfo } from './test-helper.js';
|
2025-10-01 16:56:50 +00:00
|
|
|
|
|
|
|
|
describe('Interactive file system', () => {
|
|
|
|
|
let rig: TestRig;
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
rig = new TestRig();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
|
await rig.cleanup();
|
|
|
|
|
});
|
|
|
|
|
|
2025-10-10 11:02:36 -07:00
|
|
|
it.skip('should perform a read-then-write sequence', async () => {
|
|
|
|
|
const fileName = 'version.txt';
|
|
|
|
|
rig.setup('interactive-read-then-write');
|
|
|
|
|
rig.createFile(fileName, '1.0.0');
|
|
|
|
|
|
2025-10-11 08:33:01 -07:00
|
|
|
const run = await rig.runInteractive();
|
2025-10-10 11:02:36 -07:00
|
|
|
|
|
|
|
|
// Step 1: Read the file
|
|
|
|
|
const readPrompt = `Read the version from ${fileName}`;
|
2025-10-11 08:33:01 -07:00
|
|
|
await run.type(readPrompt);
|
|
|
|
|
await run.type('\r');
|
2025-10-10 11:02:36 -07:00
|
|
|
|
|
|
|
|
const readCall = await rig.waitForToolCall('read_file', 30000);
|
|
|
|
|
expect(readCall, 'Expected to find a read_file tool call').toBe(true);
|
|
|
|
|
|
2025-10-11 08:33:01 -07:00
|
|
|
await run.waitForText('1.0.0', 30000);
|
2025-10-10 11:02:36 -07:00
|
|
|
|
|
|
|
|
// Step 2: Write the file
|
|
|
|
|
const writePrompt = `now change the version to 1.0.1 in the file`;
|
2025-10-11 08:33:01 -07:00
|
|
|
await run.type(writePrompt);
|
|
|
|
|
await run.type('\r');
|
2025-10-10 11:02:36 -07:00
|
|
|
|
|
|
|
|
const toolCall = await rig.waitForAnyToolCall(
|
|
|
|
|
['write_file', 'replace'],
|
|
|
|
|
30000,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!toolCall) {
|
2025-10-11 08:33:01 -07:00
|
|
|
printDebugInfo(rig, run.output, { toolCall });
|
2025-10-10 11:02:36 -07:00
|
|
|
}
|
2025-10-01 16:56:50 +00:00
|
|
|
|
2025-10-10 11:02:36 -07:00
|
|
|
expect(toolCall, 'Expected to find a write_file or replace tool call').toBe(
|
|
|
|
|
true,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const newFileContent = rig.readFile(fileName);
|
|
|
|
|
expect(newFileContent).toBe('1.0.1');
|
|
|
|
|
});
|
2025-10-01 16:56:50 +00:00
|
|
|
});
|