fix: use stable yaml parser for aipod specs

This commit is contained in:
Codex
2026-06-10 18:31:02 +08:00
parent fee4001e3b
commit 391a4ce68f
5 changed files with 24 additions and 6 deletions
+16 -1
View File
@@ -12,6 +12,10 @@ const selfTest: SelfTestCase = async (context) => {
const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore(), aipodSpecDir: path.join(context.root, "config", "aipods") });
try {
const client = new ManagerClient(server.baseUrl);
const parsedWithoutBunGlobal = await runNodeParserCompat(context);
assert.equal(parsedWithoutBunGlobal.name, "Artificer");
assert.equal(parsedWithoutBunGlobal.hasBunGlobal, false);
const listed = await client.get("/api/v1/aipod-specs") as JsonRecord;
assert.equal(listed.action, "aipod-spec-list");
assert.equal((listed.items as JsonRecord[]).some((item) => item.name === "Artificer"), true);
@@ -68,7 +72,7 @@ const selfTest: SelfTestCase = async (context) => {
assert.equal(commands.some((item) => item.includes("aipod-specs render <name>")), true);
assert.equal(commands.some((item) => item.includes("queue submit --aipod <name>")), true);
assertNoSecretLeak(submitPlan);
return { name: "aipod-spec", tests: ["aipod-spec-artificer-yaml-render", "aipod-spec-git-mirror-url", "queue-submit-aipod-dry-run", "aipod-cli-help"] };
return { name: "aipod-spec", tests: ["aipod-spec-yaml-parser-runtime-compatible", "aipod-spec-artificer-yaml-render", "aipod-spec-git-mirror-url", "queue-submit-aipod-dry-run", "aipod-cli-help"] };
} finally {
await new Promise<void>((resolve) => server.server.close(() => resolve()));
}
@@ -76,6 +80,17 @@ const selfTest: SelfTestCase = async (context) => {
export default selfTest;
async function runNodeParserCompat(context: { root: string }): Promise<JsonRecord> {
const script = `import { readFileSync } from "node:fs";
import { parseAipodSpecYaml } from "./src/common/aipod-specs.ts";
const spec = parseAipodSpecYaml(readFileSync("config/aipods/artificer.yaml", "utf8"), "selftest-no-bun-yaml");
console.log(JSON.stringify({ name: spec.metadata.name, hasBunGlobal: typeof globalThis.Bun !== "undefined" }));`;
const proc = spawn("node", ["--import", "tsx", "--eval", script], { cwd: context.root, stdio: ["ignore", "pipe", "pipe"] });
const [stdout, stderr, code] = await Promise.all([readStream(proc.stdout), readStream(proc.stderr), new Promise<number | null>((resolve) => proc.on("close", resolve))]);
assert.equal(code, 0, stderr || stdout);
return JSON.parse(stdout) as JsonRecord;
}
async function runCliJson(context: { root: string }, managerUrl: string, args: string[]): Promise<JsonRecord> {
const proc = spawn(process.execPath, [`${context.root}/scripts/agentrun-cli.ts`, "--manager-url", managerUrl, ...args], { stdio: ["ignore", "pipe", "pipe"] });
const [stdout, stderr, code] = await Promise.all([readStream(proc.stdout), readStream(proc.stderr), new Promise<number | null>((resolve) => proc.on("close", resolve))]);