refactor(cli): extract hook pack update flow

This commit is contained in:
Peter Steinberger
2026-03-22 11:46:22 -07:00
parent 5696e24c3f
commit e3151af6bc
6 changed files with 300 additions and 255 deletions

View File

@@ -1,5 +1,3 @@
import fs from "node:fs";
import path from "node:path";
import type { OpenClawConfig } from "../config/config.js";
import type { HookInstallRecord } from "../config/types.hooks.js";
import type { PluginInstallRecord } from "../config/types.plugins.js";
@@ -138,16 +136,6 @@ export function logHookPackRestartHint() {
defaultRuntime.log("Restart the gateway to load hooks.");
}
export async function readInstalledPackageVersion(dir: string): Promise<string | undefined> {
try {
const raw = fs.readFileSync(path.join(dir, "package.json"), "utf-8");
const parsed = JSON.parse(raw) as { version?: unknown };
return typeof parsed.version === "string" ? parsed.version : undefined;
} catch {
return undefined;
}
}
export function logSlotWarnings(warnings: string[]) {
if (warnings.length === 0) {
return;