Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"dependencies": {
"@agentclientprotocol/sdk": "^1.4.0",
"@openai/codex": "^0.155.0",
"@openai/codex": "^0.155.1",
"diff": "^9.0.0",
"open": "^11.0.1",
"vscode-jsonrpc": "^9.0.1",
Expand Down
23 changes: 22 additions & 1 deletion src/__tests__/AgentFileChangeReport.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import {describe, expect, it} from "vitest";
import {describe, expect, it, vi} from "vitest";
import {
AGENT_FILE_CHANGE_REPORT_MAX_DIFF_BYTES,
AGENT_FILE_CHANGE_REPORT_MAX_PATH_LENGTH,
Expand All @@ -20,6 +20,23 @@ function capturedWorkspace(cwd: string, additionalDirectories: string[] = []) {
return captureAgentFileChangeWorkspace(cwd, additionalDirectories);
}

function hideTemporaryDirectoryAncestorGitMarkers() {
const markers = new Set<string>();
let directory = path.resolve(os.tmpdir());
while (true) {
markers.add(path.join(directory, ".git"));
const parent = path.dirname(directory);
if (parent === directory) break;
directory = parent;
}
const existsSync = fs.existsSync;
// These fixtures need lexical ancestor discovery to stop without finding a
// repository outside the fixture, even when the host temp directory has one.
return vi.spyOn(fs, "existsSync").mockImplementation(filename =>
typeof filename === "string" && markers.has(filename) ? false : existsSync(filename),
);
}

describe("agent file-change report", () => {
it("accepts only a versioned request with a bounded opaque id", () => {
expect(parseAgentFileChangeReportRequest({
Expand Down Expand Up @@ -228,6 +245,7 @@ describe("agent file-change report", () => {
const realRoot = fs.mkdtempSync(path.join(os.tmpdir(), "file-report-real-"));
const linkedRoot = `${realRoot}-link`;
fs.symlinkSync(realRoot, linkedRoot, "dir");
const ancestorMarkers = hideTemporaryDirectoryAncestorGitMarkers();
try {
const report = createReportedAgentFileChangeReport(
"request-symlink-root",
Expand All @@ -236,6 +254,7 @@ describe("agent file-change report", () => {
);
expect(report.paths).toEqual([path.join(fs.realpathSync.native(realRoot), "generated.ts")]);
} finally {
ancestorMarkers.mockRestore();
fs.unlinkSync(linkedRoot);
fs.rmSync(realRoot, {recursive: true, force: true});
}
Expand All @@ -250,6 +269,7 @@ describe("agent file-change report", () => {
fs.mkdirSync(path.join(repository, ".git"));
fs.mkdirSync(realCwd, {recursive: true});
fs.symlinkSync(realCwd, linkedCwd, "dir");
const ancestorMarkers = hideTemporaryDirectoryAncestorGitMarkers();
try {
const report = createReportedAgentFileChangeReport(
"request-symlink-nested-cwd",
Expand All @@ -259,6 +279,7 @@ describe("agent file-change report", () => {

expect(report.paths).toEqual([path.join(fs.realpathSync.native(realCwd), "src", "Main.ts")]);
} finally {
ancestorMarkers.mockRestore();
fs.unlinkSync(linkedCwd);
fs.rmSync(repository, {recursive: true, force: true});
}
Expand Down
Loading