refactor(plugin-sdk): narrow config runtime imports

This commit is contained in:
Peter Steinberger
2026-04-27 14:57:48 +01:00
parent f3e8a8a319
commit 4336a7f3a9
573 changed files with 1066 additions and 860 deletions

View File

@@ -66,6 +66,7 @@ function isProductionExtensionFile(relPath) {
relPath.includes(".test-d.") ||
relPath.includes(".test-harness.") ||
relPath.includes(".test-shared.") ||
relPath.endsWith(".test-support.ts") ||
relPath.endsWith("-test-helpers.ts") ||
relPath.endsWith("-test-support.ts")
) {
@@ -155,6 +156,26 @@ function pushDeprecatedRuntimeApiViolations(violations, files) {
}
}
function pushBroadConfigRuntimeBarrelViolations(violations, files) {
const staticImportPattern =
/\b(?:import|export)\s+(?:type\s+)?\{[\s\S]*?\}\s+from\s+["']openclaw\/plugin-sdk\/config-runtime["']/g;
const dynamicImportPattern =
/\b(?:const|let|var)\s+\{[\s\S]*?\}\s*=\s*(?:await\s+)?import\(["']openclaw\/plugin-sdk\/config-runtime["']\)/g;
const typeQueryPattern =
/\b(?:typeof\s+)?import\(["']openclaw\/plugin-sdk\/config-runtime["']\)\.[A-Za-z_$][\w$]*/g;
for (const { filePath, relPath } of files) {
const source = readFileSync(filePath, "utf8");
for (const pattern of [staticImportPattern, dynamicImportPattern, typeQueryPattern]) {
for (const line of findMatchLineNumbers(source, pattern)) {
violations.push(
`${relPath}:${line} use narrow plugin-sdk config subpaths instead of openclaw/plugin-sdk/config-runtime`,
);
}
}
}
}
export function collectDeprecatedInternalConfigApiViolations({
repoRoot = DEFAULT_REPO_ROOT,
} = {}) {
@@ -177,6 +198,7 @@ export function collectDeprecatedInternalConfigApiViolations({
.map((filePath) => ({ filePath, relPath: repoRelative(repoRoot, filePath) }))
.filter(({ relPath }) => isProductionExtensionFile(relPath));
pushDeprecatedRuntimeApiViolations(violations, productionExtensionFiles);
pushBroadConfigRuntimeBarrelViolations(violations, productionExtensionFiles);
for (const { filePath, relPath } of productionExtensionFiles) {
const source = readFileSync(filePath, "utf8");
@@ -215,6 +237,15 @@ export function collectDeprecatedInternalConfigApiViolations({
violations,
repoFiles.filter(({ relPath }) => !isCompatConfigApiFile(relPath)),
);
pushBroadConfigRuntimeBarrelViolations(
violations,
repoFiles.filter(
({ relPath }) =>
!isTestOrHarnessFile(relPath) &&
!isCompatConfigApiFile(relPath) &&
!relPath.startsWith("test/"),
),
);
for (const { filePath, relPath } of repoFiles.filter(
({ relPath }) => !isCompatConfigApiFile(relPath),

View File

@@ -30,6 +30,10 @@
"approval-reply-runtime",
"approval-runtime",
"config-runtime",
"config-types",
"plugin-config-runtime",
"config-mutation",
"cron-store-runtime",
"config-schema",
"reply-runtime",
"reply-dedupe",
@@ -51,6 +55,8 @@
"infra-runtime",
"runtime-config-snapshot",
"runtime-group-policy",
"model-session-runtime",
"talk-config-runtime",
"ssrf-policy",
"ssrf-runtime",
"media-runtime",