fix: enforce plugin config schemas (#1272) (thanks @thewilloftheshadow)
Co-authored-by: thewilloftheshadow <thewilloftheshadow@users.noreply.github.com>
This commit is contained in:
committed by
Peter Steinberger
parent
48f733e4b3
commit
2f6d5805de
@@ -1,8 +1,6 @@
|
||||
import { readConfigFileSnapshot } from "../../config/config.js";
|
||||
import { colorize, isRich, theme } from "../../terminal/theme.js";
|
||||
import { loadAndMaybeMigrateDoctorConfig } from "../../commands/doctor-config-flow.js";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { loadClawdbotPlugins } from "../../plugins/loader.js";
|
||||
import { colorize, isRich, theme } from "../../terminal/theme.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import { formatCliCommand } from "../command-format.js";
|
||||
|
||||
@@ -30,26 +28,7 @@ export async function ensureConfigReady(params: {
|
||||
? snapshot.legacyIssues.map((issue) => `- ${issue.path}: ${issue.message}`)
|
||||
: [];
|
||||
|
||||
const pluginIssues: string[] = [];
|
||||
if (snapshot.valid) {
|
||||
const workspaceDir = resolveAgentWorkspaceDir(
|
||||
snapshot.config,
|
||||
resolveDefaultAgentId(snapshot.config),
|
||||
);
|
||||
const registry = loadClawdbotPlugins({
|
||||
config: snapshot.config,
|
||||
workspaceDir: workspaceDir ?? undefined,
|
||||
cache: false,
|
||||
mode: "validate",
|
||||
});
|
||||
for (const diag of registry.diagnostics) {
|
||||
if (diag.level !== "error") continue;
|
||||
const id = diag.pluginId ? ` ${diag.pluginId}` : "";
|
||||
pluginIssues.push(`- plugin${id}: ${diag.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const invalid = snapshot.exists && (!snapshot.valid || pluginIssues.length > 0);
|
||||
const invalid = snapshot.exists && !snapshot.valid;
|
||||
if (!invalid) return;
|
||||
|
||||
const rich = isRich();
|
||||
@@ -68,10 +47,6 @@ export async function ensureConfigReady(params: {
|
||||
params.runtime.error(muted("Legacy config keys detected:"));
|
||||
params.runtime.error(legacyIssues.map((issue) => ` ${error(issue)}`).join("\n"));
|
||||
}
|
||||
if (pluginIssues.length > 0) {
|
||||
params.runtime.error(muted("Plugin config errors:"));
|
||||
params.runtime.error(pluginIssues.map((issue) => ` ${error(issue)}`).join("\n"));
|
||||
}
|
||||
params.runtime.error("");
|
||||
params.runtime.error(
|
||||
`${muted("Run:")} ${commandText(formatCliCommand("clawdbot doctor --fix"))}`,
|
||||
|
||||
Reference in New Issue
Block a user