


















11// Plugin Sdk Surface Report tests cover plugin sdk surface report script behavior.
22import { spawnSync } from "node:child_process";
3+import { readFileSync } from "node:fs";
34import { describe, expect, it } from "vitest";
4556function runSurfaceReport(env: Record<string, string>) {
@@ -13,6 +14,18 @@ function runSurfaceReport(env: Record<string, string>) {
1314});
1415}
151617+function readDefaultPublicFunctionExportBudget() {
18+const source = readFileSync("scripts/plugin-sdk-surface-report.mjs", "utf8");
19+const match =
20+/publicFunctionExports:\s*readBudgetEnv\("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS",\s*(\d+)\)/u.exec(
21+source,
22+);
23+if (match === null || match[1] === undefined) {
24+throw new Error("failed to read default public function export budget");
25+}
26+return Number(match[1]);
27+}
28+1629describe("plugin SDK surface report", () => {
1730it("rejects loose numeric budget env vars before collecting SDK stats", () => {
1831const result = runSurfaceReport({
@@ -50,12 +63,13 @@ describe("plugin SDK surface report", () => {
5063});
51645265it("keeps generated package declarations out of source surface counts", () => {
66+const budget = readDefaultPublicFunctionExportBudget();
5367const result = runSurfaceReport({
54-OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS: "5183",
68+OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS: String(budget - 1),
5569});
56705771expect(result.status).toBe(1);
58-expect(result.stderr).toContain("public callable exports 5184 > 5183");
72+expect(result.stderr).toContain(`public callable exports ${budget} > ${budget - 1}`);
5973});
60746175it("rejects deprecated export growth by public entrypoint", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。