refactor(core): dedupe shared config and runtime helpers

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:03 +00:00
parent 544ffbcf7b
commit 04892ee230
68 changed files with 1966 additions and 2018 deletions

View File

@@ -9,6 +9,7 @@ import { parseFrontmatterBlock } from "../markdown/frontmatter.js";
import {
getFrontmatterString,
normalizeStringList,
parseOpenClawManifestInstallBase,
parseFrontmatterBool,
resolveOpenClawManifestBlock,
resolveOpenClawManifestInstall,
@@ -21,30 +22,23 @@ export function parseFrontmatter(content: string): ParsedHookFrontmatter {
}
function parseInstallSpec(input: unknown): HookInstallSpec | undefined {
if (!input || typeof input !== "object") {
const parsed = parseOpenClawManifestInstallBase(input, ["bundled", "npm", "git"]);
if (!parsed) {
return undefined;
}
const raw = input as Record<string, unknown>;
const kindRaw =
typeof raw.kind === "string" ? raw.kind : typeof raw.type === "string" ? raw.type : "";
const kind = kindRaw.trim().toLowerCase();
if (kind !== "bundled" && kind !== "npm" && kind !== "git") {
return undefined;
}
const { raw } = parsed;
const spec: HookInstallSpec = {
kind: kind,
kind: parsed.kind as HookInstallSpec["kind"],
};
if (typeof raw.id === "string") {
spec.id = raw.id;
if (parsed.id) {
spec.id = parsed.id;
}
if (typeof raw.label === "string") {
spec.label = raw.label;
if (parsed.label) {
spec.label = parsed.label;
}
const bins = normalizeStringList(raw.bins);
if (bins.length > 0) {
spec.bins = bins;
if (parsed.bins) {
spec.bins = parsed.bins;
}
if (typeof raw.package === "string") {
spec.package = raw.package;