- Imported and injected `zod/v4` under `zod` in runtime environments for custom commands, custom tools, extensions, and hooks. - Added corresponding Type definitions to `CustomCommandAPI`, `CustomToolAPI`, `ExtensionAPI`, and `HookAPI` interfaces. - Re-exported Zod and its alias from the main package entry point to expand the public API surface. - Refactored the internal Typebox validation shim to support parsing via standard `.safeParse()` and `.toJSON()` methods. - Advanced Typebox shim utility capabilities with support for dual-key record validation and enhanced schema structure handling.
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "bun:test";
|
|
import * as piCodingAgent from "@oh-my-pi/pi-coding-agent";
|
|
import { GreenCommand } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/bundled/ci-green";
|
|
import type { CustomCommandAPI } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/types";
|
|
import type { HookCommandContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types";
|
|
import type * as TypeBox from "@oh-my-pi/pi-coding-agent/extensibility/typebox";
|
|
import * as git from "@oh-my-pi/pi-coding-agent/utils/git";
|
|
import * as arktype from "arktype";
|
|
import * as zod from "zod/v4";
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
function createApi(): CustomCommandAPI {
|
|
return {
|
|
cwd: "/tmp/test",
|
|
exec: async () => ({
|
|
stdout: "",
|
|
stderr: "",
|
|
code: 0,
|
|
killed: false,
|
|
}),
|
|
typebox: {} as unknown as typeof TypeBox,
|
|
arktype,
|
|
zod,
|
|
pi: piCodingAgent,
|
|
};
|
|
}
|
|
|
|
describe("GreenCommand", () => {
|
|
it("includes tag instructions when HEAD has a tag", async () => {
|
|
vi.spyOn(git.ref, "tags").mockResolvedValue(["v0.1.0-alpha2"]);
|
|
const command = new GreenCommand(createApi());
|
|
|
|
const result = await command.execute([], {} as HookCommandContext);
|
|
|
|
expect(result).toContain("v0.1.0-alpha2");
|
|
expect(result).not.toContain("timeouts due to the harnesses");
|
|
});
|
|
|
|
it("omits tag instructions when HEAD is not tagged", async () => {
|
|
vi.spyOn(git.ref, "tags").mockResolvedValue([]);
|
|
const command = new GreenCommand(createApi());
|
|
|
|
const result = await command.execute([], {} as HookCommandContext);
|
|
|
|
expect(result).not.toContain("v0.1.0-alpha2");
|
|
});
|
|
});
|