refactor: extract @uncaged/workflow-util-agent + smart prompt
- New package: spawn-cli + build-agent-prompt shared utils - Smart prompt: start + meta summaries for middle steps + last step full - Cursor/Hermes adapters now import from util-agent (no duplicate code) - 109 tests pass, biome clean Closes #14 小橘 <xiaoju@shazhou.work>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import { spawnCli } from "../src/index.js";
|
||||
|
||||
const noTimeout = { cwd: null, timeoutMs: null } as const;
|
||||
|
||||
describe("spawnCli", () => {
|
||||
test("resolves ok stdout on zero exit", async () => {
|
||||
const run = await spawnCli("echo", ["spawn-cli-ok"], { ...noTimeout });
|
||||
expect(run.ok).toBe(true);
|
||||
if (run.ok) {
|
||||
expect(run.value.trim()).toBe("spawn-cli-ok");
|
||||
}
|
||||
});
|
||||
|
||||
test("resolves err on non-zero exit", async () => {
|
||||
const run = await spawnCli("false", [], { ...noTimeout });
|
||||
expect(run.ok).toBe(false);
|
||||
if (!run.ok) {
|
||||
expect(run.error.kind).toBe("non_zero_exit");
|
||||
}
|
||||
});
|
||||
|
||||
test("resolves err on timeout", async () => {
|
||||
const run = await spawnCli("sleep", ["10"], { cwd: null, timeoutMs: 80 });
|
||||
expect(run.ok).toBe(false);
|
||||
if (!run.ok) {
|
||||
expect(run.error.kind).toBe("timeout");
|
||||
}
|
||||
});
|
||||
|
||||
test("resolves err when spawn fails", async () => {
|
||||
const run = await spawnCli("definitely-missing-executable-7f2a9c1b", [], { ...noTimeout });
|
||||
expect(run.ok).toBe(false);
|
||||
if (!run.ok) {
|
||||
expect(run.error.kind).toBe("spawn_failed");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user