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

+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/
);
});