Migrate automation from OpenCode to goose

This commit is contained in:
lezi-fun committed 2026-08-13 14:24:16 +08:00
1 parent adf6c60a70
commit 8c4e866765
15 files changed
+820 -743

No files matched your search

+5
View File
@@ -35,17 +35,20 @@ test("PR chat snapshot excludes repository instructions, secrets, git data, and
try {
await fs.mkdir(path.join(source, ".git"));
await fs.mkdir(path.join(source, ".goose"));
await fs.mkdir(path.join(source, ".opencode"));
await fs.mkdir(path.join(source, ".agents"));
await fs.mkdir(path.join(source, "src"));
await Promise.all([
fs.writeFile(path.join(source, ".git", "config"), "credential data"),
fs.writeFile(path.join(source, ".goose", "config.yaml"), "untrusted goose config"),
fs.writeFile(path.join(source, ".opencode", "plugin.ts"), "untrusted plugin"),
fs.writeFile(path.join(source, ".agents", "SKILL.md"), "untrusted skill"),
fs.writeFile(path.join(source, ".env"), "TOKEN=secret"),
fs.writeFile(path.join(source, ".env.local"), "TOKEN=local-secret"),
fs.writeFile(path.join(source, "AGENTS.md"), "untrusted instructions"),
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.symlink(path.join(source, ".env"), path.join(source, "secret-link"))
]);
@@ -54,12 +57,14 @@ test("PR chat snapshot excludes repository instructions, secrets, git data, and
assert.equal(await fs.readFile(path.join(snapshot, "src", "index.ts"), "utf8"), "export const safe = true;\n");
for (const excluded of [
".git",
".goose",
".opencode",
".agents",
".env",
".env.local",
"AGENTS.md",
"opencode.json",
".goosehints",
"secret-link"
]) {
await assert.rejects(fs.lstat(path.join(snapshot, excluded)), { code: "ENOENT" });
+43
View File
@@ -0,0 +1,43 @@
import assert from "node:assert/strict";
import test from "node:test";
import { extractGooseFinalText } from "../src/ai/gooseCli.js";
test("goose output extracts the latest assistant text", () => {
const output = JSON.stringify({
messages: [
{ role: "user", content: [{ type: "text", text: "review this" }] },
{ role: "assistant", content: [{ type: "text", text: "first response" }] },
{
role: "assistant",
content: [
{ type: "thinking", thinking: "hidden" },
{ type: "text", text: "final " },
{ type: "text", text: "response" }
]
}
],
metadata: { status: "completed" }
});
assert.equal(extractGooseFinalText(output), "final response");
});
test("goose output strips a surrounding JSON markdown fence", () => {
const output = JSON.stringify({
messages: [
{
role: "assistant",
content: [{ type: "text", text: "```json\n{\"ok\":true}\n```" }]
}
]
});
assert.equal(extractGooseFinalText(output), '{"ok":true}');
});
test("goose output rejects a response without assistant text", () => {
assert.throws(
() => extractGooseFinalText(JSON.stringify({ messages: [{ role: "user", content: [] }] })),
/final assistant text/
);
});