Files
moltbot/src/cli/command-bootstrap.ts
Peter Steinberger 250376f885 fix: simplify bundled runtime dependency repair (#75183)
Summary:
- Merged fix: simplify bundled runtime dependency repair after ClawSweeper review.

ClawSweeper fixups:
- Included follow-up commit: fix: verify cached bundled runtime roots
- Included follow-up commit: refactor: simplify plugin runtime startup paths
- Included follow-up commit: refactor: trim plugin startup policy helpers
- Included follow-up commit: refactor: trust package manager runtime deps materialization
- Included follow-up commit: fix: narrow channel runtime deps skip policy
- Included follow-up commit: refactor: defer startup plugin runtime deps
- Ran the ClawSweeper repair loop before final review.

Validation:
- ClawSweeper review passed for head 04dc566534.
- Required merge gates passed before the squash merge.

Prepared head SHA: 04dc566534
Review: https://github.com/openclaw/openclaw/pull/75183#issuecomment-4358383786

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Co-authored-by: Shakker <shakkerdroid@gmail.com>
Co-authored-by: clawsweeper-repair <clawsweeper-repair@users.noreply.github.com>
2026-05-01 07:49:02 +00:00

46 lines
1.6 KiB
TypeScript

import type { RuntimeEnv } from "../runtime.js";
import type { CliPluginRegistryPolicy } from "./command-catalog.js";
import { resolveCliCommandPathPolicy } from "./command-path-policy.js";
import { ensureCliPluginRegistryLoaded } from "./plugin-registry-loader.js";
let configGuardModulePromise: Promise<typeof import("./program/config-guard.js")> | undefined;
function loadConfigGuardModule() {
configGuardModulePromise ??= import("./program/config-guard.js");
return configGuardModulePromise;
}
export async function ensureCliCommandBootstrap(params: {
runtime: RuntimeEnv;
commandPath: string[];
suppressDoctorStdout?: boolean;
skipConfigGuard?: boolean;
allowInvalid?: boolean;
loadPlugins?: boolean;
pluginRegistry?: CliPluginRegistryPolicy;
}) {
if (!params.skipConfigGuard) {
const { ensureConfigReady } = await loadConfigGuardModule();
await ensureConfigReady({
runtime: params.runtime,
commandPath: params.commandPath,
...(params.allowInvalid ? { allowInvalid: true } : {}),
...(params.suppressDoctorStdout ? { suppressDoctorStdout: true } : {}),
});
}
if (!params.loadPlugins) {
return;
}
const pluginRegistryLoadPolicy =
params.pluginRegistry ?? resolveCliCommandPathPolicy(params.commandPath).pluginRegistry;
await ensureCliPluginRegistryLoaded({
scope: pluginRegistryLoadPolicy.scope,
routeLogsToStderr: params.suppressDoctorStdout,
...(pluginRegistryLoadPolicy.installBundledRuntimeDeps !== undefined
? {
installBundledRuntimeDeps: pluginRegistryLoadPolicy.installBundledRuntimeDeps,
}
: {}),
});
}