Z ZPI 文档 v0.3.8
介绍页

源码

packages/builtin-plugins/test/subagent-protocol.test.ts

typescript17 行查看原文
import { readFileSync } from "node:fs";
import * as protocol from "@zpi-dev/builtin-plugins/collaboration/protocol";
import { expect, test } from "vitest";

// Evaluated from the checked-out ZCode implementations, including the runner's
// SendMessage success objects. Tests need no access to that checkout.
const reference = JSON.parse(
  readFileSync(new URL("./fixtures/zcode-subagent-results.json", import.meta.url), "utf8"),
) as { revision: string; cases: { name: string; args: unknown[]; expected: unknown }[] };
const formatters = protocol as unknown as Record<string, (...args: unknown[]) => unknown>;
test.each(reference.cases.map((item, index) => ({ ...item, index })))(
  "ZCode result $index: $name",
  ({ name, args, expected }) => {
    expect(formatters[name](...args)).toEqual(expected);
  },
);