fix(plugin-sdk): stabilize surface report after builds

This commit is contained in:
Vincent Koc
2026-06-21 21:06:01 +02:00
parent 2e7c3ace9c
commit 86fea26797
2 changed files with 25 additions and 0 deletions

View File

@@ -203,9 +203,25 @@ function hasDeprecatedTag(symbol) {
return symbol.getJsDocTags().some((tag) => tag.name === "deprecated");
}
const generatedLlmCoreValidatorExports = new Set(["validateToolArguments", "validateToolCall"]);
function isGeneratedLlmCoreValidatorDeclaration(exportName, declaration) {
if (!generatedLlmCoreValidatorExports.has(exportName)) {
return false;
}
const relative = path.relative(repoRoot, declaration.getSourceFile().fileName);
const relativePath = relative.split(path.sep).join(path.posix.sep);
// Build artifacts can make agent-core's package-name validator reexports look
// newly callable. Keep this source report independent of generated dist state.
return relativePath.includes("llm-core/dist/validation.d.");
}
function isCallableExport(checker, symbol, sourceFile) {
const target = unwrapAlias(checker, symbol);
const declaration = target.valueDeclaration ?? target.declarations?.[0] ?? sourceFile;
if (isGeneratedLlmCoreValidatorDeclaration(symbol.getName(), declaration)) {
return false;
}
const type = checker.getTypeOfSymbolAtLocation(target, declaration);
return checker.getSignaturesOfType(type, ts.SignatureKind.Call).length > 0;
}

View File

@@ -49,6 +49,15 @@ describe("plugin SDK surface report", () => {
expect(result.stderr).toBe("");
});
it("keeps generated package declarations out of source surface counts", () => {
const result = runSurfaceReport({
OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS: "5186",
});
expect(result.status).toBe(1);
expect(result.stderr).toContain("public callable exports 5187 > 5186");
});
it("rejects deprecated export growth by public entrypoint", () => {
const result = runSurfaceReport({
OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_DEPRECATED_EXPORTS_BY_ENTRYPOINT: JSON.stringify({ core: 1 }),