fix: make agent snapshots writable

This commit is contained in:
lezi-fun committed 2026-08-14 11:15:56 +08:00
1 parent 087b19e705
commit b6239fc458
4 files changed
+30

No files matched your search

+6
View File
@@ -81,6 +81,7 @@ test("PR chat snapshot excludes repository instructions, secrets, git data, and
await fs.mkdir(path.join(source, ".agents"));
await fs.mkdir(path.join(source, ".ghbot"));
await fs.mkdir(path.join(source, "src"));
await fs.mkdir(path.join(source, "scripts"));
await Promise.all([
fs.writeFile(path.join(source, ".git", "config"), "credential data"),
fs.writeFile(path.join(source, ".goose", "config.yaml"), "untrusted goose config"),
@@ -93,11 +94,16 @@ test("PR chat snapshot excludes repository instructions, secrets, git data, and
fs.writeFile(path.join(source, "opencode.json"), "{}"),
fs.writeFile(path.join(source, ".goosehints"), "untrusted hints"),
fs.writeFile(path.join(source, "src", "index.ts"), "export const safe = true;\n"),
fs.writeFile(path.join(source, "scripts", "check.sh"), "#!/bin/sh\nexit 0\n", { mode: 0o755 }),
fs.symlink(path.join(source, ".env"), path.join(source, "secret-link"))
]);
snapshot = await createRepositorySnapshot(source);
assert.equal(await fs.readFile(path.join(snapshot, "src", "index.ts"), "utf8"), "export const safe = true;\n");
assert.equal((await fs.stat(snapshot)).mode & 0o777, 0o777);
assert.equal((await fs.stat(path.join(snapshot, "src"))).mode & 0o777, 0o777);
assert.equal((await fs.stat(path.join(snapshot, "src", "index.ts"))).mode & 0o777, 0o666);
assert.equal((await fs.stat(path.join(snapshot, "scripts", "check.sh"))).mode & 0o777, 0o777);
for (const excluded of [
".git",
".goose",
+5
View File
@@ -16,6 +16,11 @@ test("repository knowledge round trips through the agent scratch file", async ()
try {
await writeKnowledgeScratch(root, "# Architecture\n\nUse npm test.\n");
assert.equal(await readKnowledgeScratch(root), "# Architecture\n\nUse npm test.\n");
assert.equal((await fs.stat(path.join(root, ".ghbot"))).mode & 0o777, 0o777);
assert.equal(
(await fs.stat(path.join(root, ".ghbot", "repository-knowledge.md"))).mode & 0o777,
0o666
);
} finally {
await fs.rm(root, { recursive: true, force: true });
}