refactor: rename clawdbot to moltbot with legacy compat

This commit is contained in:
Peter Steinberger
2026-01-27 12:19:58 +00:00
parent 83460df96f
commit 6d16a658e5
1839 changed files with 11250 additions and 11199 deletions

View File

@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import type { ClawdbotConfig, SkillConfig } from "../../config/config.js";
import type { MoltbotConfig, SkillConfig } from "../../config/config.js";
import { resolveSkillKey } from "./frontmatter.js";
import type { SkillEligibilityContext, SkillEntry } from "./types.js";
@@ -17,7 +17,7 @@ function isTruthy(value: unknown): boolean {
return true;
}
export function resolveConfigPath(config: ClawdbotConfig | undefined, pathStr: string) {
export function resolveConfigPath(config: MoltbotConfig | undefined, pathStr: string) {
const parts = pathStr.split(".").filter(Boolean);
let current: unknown = config;
for (const part of parts) {
@@ -27,7 +27,7 @@ export function resolveConfigPath(config: ClawdbotConfig | undefined, pathStr: s
return current;
}
export function isConfigPathTruthy(config: ClawdbotConfig | undefined, pathStr: string): boolean {
export function isConfigPathTruthy(config: MoltbotConfig | undefined, pathStr: string): boolean {
const value = resolveConfigPath(config, pathStr);
if (value === undefined && pathStr in DEFAULT_CONFIG_VALUES) {
return DEFAULT_CONFIG_VALUES[pathStr] === true;
@@ -36,7 +36,7 @@ export function isConfigPathTruthy(config: ClawdbotConfig | undefined, pathStr:
}
export function resolveSkillConfig(
config: ClawdbotConfig | undefined,
config: MoltbotConfig | undefined,
skillKey: string,
): SkillConfig | undefined {
const skills = config?.skills?.entries;
@@ -58,10 +58,10 @@ function normalizeAllowlist(input: unknown): string[] | undefined {
}
function isBundledSkill(entry: SkillEntry): boolean {
return entry.skill.source === "clawdbot-bundled";
return entry.skill.source === "moltbot-bundled";
}
export function resolveBundledAllowlist(config?: ClawdbotConfig): string[] | undefined {
export function resolveBundledAllowlist(config?: MoltbotConfig): string[] | undefined {
return normalizeAllowlist(config?.skills?.allowBundled);
}
@@ -89,14 +89,14 @@ export function hasBinary(bin: string): boolean {
export function shouldIncludeSkill(params: {
entry: SkillEntry;
config?: ClawdbotConfig;
config?: MoltbotConfig;
eligibility?: SkillEligibilityContext;
}): boolean {
const { entry, config, eligibility } = params;
const skillKey = resolveSkillKey(entry.skill, entry);
const skillConfig = resolveSkillConfig(config, skillKey);
const allowBundled = normalizeAllowlist(config?.skills?.allowBundled);
const osList = entry.clawdbot?.os ?? [];
const osList = entry.metadata?.os ?? [];
const remotePlatforms = eligibility?.remote?.platforms ?? [];
if (skillConfig?.enabled === false) return false;
@@ -108,11 +108,11 @@ export function shouldIncludeSkill(params: {
) {
return false;
}
if (entry.clawdbot?.always === true) {
if (entry.metadata?.always === true) {
return true;
}
const requiredBins = entry.clawdbot?.requires?.bins ?? [];
const requiredBins = entry.metadata?.requires?.bins ?? [];
if (requiredBins.length > 0) {
for (const bin of requiredBins) {
if (hasBinary(bin)) continue;
@@ -120,7 +120,7 @@ export function shouldIncludeSkill(params: {
return false;
}
}
const requiredAnyBins = entry.clawdbot?.requires?.anyBins ?? [];
const requiredAnyBins = entry.metadata?.requires?.anyBins ?? [];
if (requiredAnyBins.length > 0) {
const anyFound =
requiredAnyBins.some((bin) => hasBinary(bin)) ||
@@ -128,19 +128,19 @@ export function shouldIncludeSkill(params: {
if (!anyFound) return false;
}
const requiredEnv = entry.clawdbot?.requires?.env ?? [];
const requiredEnv = entry.metadata?.requires?.env ?? [];
if (requiredEnv.length > 0) {
for (const envName of requiredEnv) {
if (process.env[envName]) continue;
if (skillConfig?.env?.[envName]) continue;
if (skillConfig?.apiKey && entry.clawdbot?.primaryEnv === envName) {
if (skillConfig?.apiKey && entry.metadata?.primaryEnv === envName) {
continue;
}
return false;
}
}
const requiredConfig = entry.clawdbot?.requires?.config ?? [];
const requiredConfig = entry.metadata?.requires?.config ?? [];
if (requiredConfig.length > 0) {
for (const configPath of requiredConfig) {
if (!isConfigPathTruthy(config, configPath)) return false;

View File

@@ -1,9 +1,9 @@
import type { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } from "../../config/config.js";
import { resolveSkillConfig } from "./config.js";
import { resolveSkillKey } from "./frontmatter.js";
import type { SkillEntry, SkillSnapshot } from "./types.js";
export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?: ClawdbotConfig }) {
export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?: MoltbotConfig }) {
const { skills, config } = params;
const updates: Array<{ key: string; prev: string | undefined }> = [];
@@ -20,7 +20,7 @@ export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?:
}
}
const primaryEnv = entry.clawdbot?.primaryEnv;
const primaryEnv = entry.metadata?.primaryEnv;
if (primaryEnv && skillConfig.apiKey && !process.env[primaryEnv]) {
updates.push({ key: primaryEnv, prev: process.env[primaryEnv] });
process.env[primaryEnv] = skillConfig.apiKey;
@@ -37,7 +37,7 @@ export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?:
export function applySkillEnvOverridesFromSnapshot(params: {
snapshot?: SkillSnapshot;
config?: ClawdbotConfig;
config?: MoltbotConfig;
}) {
const { snapshot, config } = params;
if (!snapshot) return () => {};

View File

@@ -1,10 +1,11 @@
import JSON5 from "json5";
import type { Skill } from "@mariozechner/pi-coding-agent";
import { LEGACY_MANIFEST_KEY } from "../../compat/legacy-names.js";
import { parseFrontmatterBlock } from "../../markdown/frontmatter.js";
import { parseBooleanValue } from "../../utils/boolean.js";
import type {
ClawdbotSkillMetadata,
MoltbotSkillMetadata,
ParsedSkillFrontmatter,
SkillEntry,
SkillInstallSpec,
@@ -71,32 +72,34 @@ function parseFrontmatterBool(value: string | undefined, fallback: boolean): boo
return parsed === undefined ? fallback : parsed;
}
export function resolveClawdbotMetadata(
export function resolveMoltbotMetadata(
frontmatter: ParsedSkillFrontmatter,
): ClawdbotSkillMetadata | undefined {
): MoltbotSkillMetadata | undefined {
const raw = getFrontmatterValue(frontmatter, "metadata");
if (!raw) return undefined;
try {
const parsed = JSON5.parse(raw) as { clawdbot?: unknown };
const parsed = JSON5.parse(raw) as { moltbot?: unknown } & Partial<
Record<typeof LEGACY_MANIFEST_KEY, unknown>
>;
if (!parsed || typeof parsed !== "object") return undefined;
const clawdbot = (parsed as { clawdbot?: unknown }).clawdbot;
if (!clawdbot || typeof clawdbot !== "object") return undefined;
const clawdbotObj = clawdbot as Record<string, unknown>;
const metadataRaw = parsed.moltbot ?? parsed[LEGACY_MANIFEST_KEY];
if (!metadataRaw || typeof metadataRaw !== "object") return undefined;
const metadataObj = metadataRaw as Record<string, unknown>;
const requiresRaw =
typeof clawdbotObj.requires === "object" && clawdbotObj.requires !== null
? (clawdbotObj.requires as Record<string, unknown>)
typeof metadataObj.requires === "object" && metadataObj.requires !== null
? (metadataObj.requires as Record<string, unknown>)
: undefined;
const installRaw = Array.isArray(clawdbotObj.install) ? (clawdbotObj.install as unknown[]) : [];
const installRaw = Array.isArray(metadataObj.install) ? (metadataObj.install as unknown[]) : [];
const install = installRaw
.map((entry) => parseInstallSpec(entry))
.filter((entry): entry is SkillInstallSpec => Boolean(entry));
const osRaw = normalizeStringList(clawdbotObj.os);
const osRaw = normalizeStringList(metadataObj.os);
return {
always: typeof clawdbotObj.always === "boolean" ? clawdbotObj.always : undefined,
emoji: typeof clawdbotObj.emoji === "string" ? clawdbotObj.emoji : undefined,
homepage: typeof clawdbotObj.homepage === "string" ? clawdbotObj.homepage : undefined,
skillKey: typeof clawdbotObj.skillKey === "string" ? clawdbotObj.skillKey : undefined,
primaryEnv: typeof clawdbotObj.primaryEnv === "string" ? clawdbotObj.primaryEnv : undefined,
always: typeof metadataObj.always === "boolean" ? metadataObj.always : undefined,
emoji: typeof metadataObj.emoji === "string" ? metadataObj.emoji : undefined,
homepage: typeof metadataObj.homepage === "string" ? metadataObj.homepage : undefined,
skillKey: typeof metadataObj.skillKey === "string" ? metadataObj.skillKey : undefined,
primaryEnv: typeof metadataObj.primaryEnv === "string" ? metadataObj.primaryEnv : undefined,
os: osRaw.length > 0 ? osRaw : undefined,
requires: requiresRaw
? {
@@ -126,5 +129,5 @@ export function resolveSkillInvocationPolicy(
}
export function resolveSkillKey(skill: Skill, entry?: SkillEntry): string {
return entry?.clawdbot?.skillKey ?? skill.name;
return entry?.metadata?.skillKey ?? skill.name;
}

View File

@@ -1,7 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import type { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } from "../../config/config.js";
import { createSubsystemLogger } from "../../logging/subsystem.js";
import {
normalizePluginsConfig,
@@ -14,7 +14,7 @@ const log = createSubsystemLogger("skills");
export function resolvePluginSkillDirs(params: {
workspaceDir: string;
config?: ClawdbotConfig;
config?: MoltbotConfig;
}): string[] {
const workspaceDir = params.workspaceDir.trim();
if (!workspaceDir) return [];

View File

@@ -2,7 +2,7 @@ import path from "node:path";
import chokidar, { type FSWatcher } from "chokidar";
import type { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } from "../../config/config.js";
import { createSubsystemLogger } from "../../logging/subsystem.js";
import { CONFIG_DIR, resolveUserPath } from "../../utils.js";
import { resolvePluginSkillDirs } from "./plugin-skills.js";
@@ -48,7 +48,7 @@ function emit(event: SkillsChangeEvent) {
}
}
function resolveWatchPaths(workspaceDir: string, config?: ClawdbotConfig): string[] {
function resolveWatchPaths(workspaceDir: string, config?: MoltbotConfig): string[] {
const paths: string[] = [];
if (workspaceDir.trim()) {
paths.push(path.join(workspaceDir, "skills"));
@@ -97,7 +97,7 @@ export function getSkillsSnapshotVersion(workspaceDir?: string): number {
return Math.max(globalVersion, local);
}
export function ensureSkillsWatcher(params: { workspaceDir: string; config?: ClawdbotConfig }) {
export function ensureSkillsWatcher(params: { workspaceDir: string; config?: MoltbotConfig }) {
const workspaceDir = params.workspaceDir.trim();
if (!workspaceDir) return;
const watchEnabled = params.config?.skills?.load?.watch !== false;

View File

@@ -16,7 +16,7 @@ export type SkillInstallSpec = {
targetDir?: string;
};
export type ClawdbotSkillMetadata = {
export type MoltbotSkillMetadata = {
always?: boolean;
skillKey?: string;
primaryEnv?: string;
@@ -66,7 +66,7 @@ export type ParsedSkillFrontmatter = Record<string, string>;
export type SkillEntry = {
skill: Skill;
frontmatter: ParsedSkillFrontmatter;
clawdbot?: ClawdbotSkillMetadata;
metadata?: MoltbotSkillMetadata;
invocation?: SkillInvocationPolicy;
};

View File

@@ -7,14 +7,14 @@ import {
type Skill,
} from "@mariozechner/pi-coding-agent";
import type { ClawdbotConfig } from "../../config/config.js";
import type { MoltbotConfig } from "../../config/config.js";
import { createSubsystemLogger } from "../../logging/subsystem.js";
import { CONFIG_DIR, resolveUserPath } from "../../utils.js";
import { resolveBundledSkillsDir } from "./bundled-dir.js";
import { shouldIncludeSkill } from "./config.js";
import {
parseFrontmatter,
resolveClawdbotMetadata,
resolveMoltbotMetadata,
resolveSkillInvocationPolicy,
} from "./frontmatter.js";
import { resolvePluginSkillDirs } from "./plugin-skills.js";
@@ -43,7 +43,7 @@ function debugSkillCommandOnce(
function filterSkillEntries(
entries: SkillEntry[],
config?: ClawdbotConfig,
config?: MoltbotConfig,
skillFilter?: string[],
eligibility?: SkillEligibilityContext,
): SkillEntry[] {
@@ -95,7 +95,7 @@ function resolveUniqueSkillCommandName(base: string, used: Set<string>): string
function loadSkillEntries(
workspaceDir: string,
opts?: {
config?: ClawdbotConfig;
config?: MoltbotConfig;
managedSkillsDir?: string;
bundledSkillsDir?: string;
},
@@ -130,23 +130,23 @@ function loadSkillEntries(
const bundledSkills = bundledSkillsDir
? loadSkills({
dir: bundledSkillsDir,
source: "clawdbot-bundled",
source: "moltbot-bundled",
})
: [];
const extraSkills = mergedExtraDirs.flatMap((dir) => {
const resolved = resolveUserPath(dir);
return loadSkills({
dir: resolved,
source: "clawdbot-extra",
source: "moltbot-extra",
});
});
const managedSkills = loadSkills({
dir: managedSkillsDir,
source: "clawdbot-managed",
source: "moltbot-managed",
});
const workspaceSkills = loadSkills({
dir: workspaceSkillsDir,
source: "clawdbot-workspace",
source: "moltbot-workspace",
});
const merged = new Map<string, Skill>();
@@ -167,7 +167,7 @@ function loadSkillEntries(
return {
skill,
frontmatter,
clawdbot: resolveClawdbotMetadata(frontmatter),
metadata: resolveMoltbotMetadata(frontmatter),
invocation: resolveSkillInvocationPolicy(frontmatter),
};
});
@@ -177,7 +177,7 @@ function loadSkillEntries(
export function buildWorkspaceSkillSnapshot(
workspaceDir: string,
opts?: {
config?: ClawdbotConfig;
config?: MoltbotConfig;
managedSkillsDir?: string;
bundledSkillsDir?: string;
entries?: SkillEntry[];
@@ -204,7 +204,7 @@ export function buildWorkspaceSkillSnapshot(
prompt,
skills: eligible.map((entry) => ({
name: entry.skill.name,
primaryEnv: entry.clawdbot?.primaryEnv,
primaryEnv: entry.metadata?.primaryEnv,
})),
resolvedSkills,
version: opts?.snapshotVersion,
@@ -214,7 +214,7 @@ export function buildWorkspaceSkillSnapshot(
export function buildWorkspaceSkillsPrompt(
workspaceDir: string,
opts?: {
config?: ClawdbotConfig;
config?: MoltbotConfig;
managedSkillsDir?: string;
bundledSkillsDir?: string;
entries?: SkillEntry[];
@@ -242,7 +242,7 @@ export function buildWorkspaceSkillsPrompt(
export function resolveSkillsPromptForRun(params: {
skillsSnapshot?: SkillSnapshot;
entries?: SkillEntry[];
config?: ClawdbotConfig;
config?: MoltbotConfig;
workspaceDir: string;
}): string {
const snapshotPrompt = params.skillsSnapshot?.prompt?.trim();
@@ -260,7 +260,7 @@ export function resolveSkillsPromptForRun(params: {
export function loadWorkspaceSkillEntries(
workspaceDir: string,
opts?: {
config?: ClawdbotConfig;
config?: MoltbotConfig;
managedSkillsDir?: string;
bundledSkillsDir?: string;
},
@@ -271,7 +271,7 @@ export function loadWorkspaceSkillEntries(
export async function syncSkillsToWorkspace(params: {
sourceWorkspaceDir: string;
targetWorkspaceDir: string;
config?: ClawdbotConfig;
config?: MoltbotConfig;
managedSkillsDir?: string;
bundledSkillsDir?: string;
}) {
@@ -308,7 +308,7 @@ export async function syncSkillsToWorkspace(params: {
export function filterWorkspaceSkillEntries(
entries: SkillEntry[],
config?: ClawdbotConfig,
config?: MoltbotConfig,
): SkillEntry[] {
return filterSkillEntries(entries, config);
}
@@ -316,7 +316,7 @@ export function filterWorkspaceSkillEntries(
export function buildWorkspaceSkillCommandSpecs(
workspaceDir: string,
opts?: {
config?: ClawdbotConfig;
config?: MoltbotConfig;
managedSkillsDir?: string;
bundledSkillsDir?: string;
entries?: SkillEntry[];