mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:31:25 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -3,7 +3,7 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export function resolveBundledSkillsDir(): string | undefined {
|
||||
const override = process.env.CLAWDBOT_BUNDLED_SKILLS_DIR?.trim();
|
||||
const override = process.env.OPENCLAW_BUNDLED_SKILLS_DIR?.trim();
|
||||
if (override) return override;
|
||||
|
||||
// bun --compile: ship a sibling `skills/` next to the executable.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import type { MoltbotConfig, SkillConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig, 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: MoltbotConfig | undefined, pathStr: string) {
|
||||
export function resolveConfigPath(config: OpenClawConfig | 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: MoltbotConfig | undefined, pathStr: st
|
||||
return current;
|
||||
}
|
||||
|
||||
export function isConfigPathTruthy(config: MoltbotConfig | undefined, pathStr: string): boolean {
|
||||
export function isConfigPathTruthy(config: OpenClawConfig | 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: MoltbotConfig | undefined, pathStr: s
|
||||
}
|
||||
|
||||
export function resolveSkillConfig(
|
||||
config: MoltbotConfig | undefined,
|
||||
config: OpenClawConfig | undefined,
|
||||
skillKey: string,
|
||||
): SkillConfig | undefined {
|
||||
const skills = config?.skills?.entries;
|
||||
@@ -57,11 +57,13 @@ function normalizeAllowlist(input: unknown): string[] | undefined {
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
}
|
||||
|
||||
const BUNDLED_SOURCES = new Set(["openclaw-bundled"]);
|
||||
|
||||
function isBundledSkill(entry: SkillEntry): boolean {
|
||||
return entry.skill.source === "moltbot-bundled";
|
||||
return BUNDLED_SOURCES.has(entry.skill.source);
|
||||
}
|
||||
|
||||
export function resolveBundledAllowlist(config?: MoltbotConfig): string[] | undefined {
|
||||
export function resolveBundledAllowlist(config?: OpenClawConfig): string[] | undefined {
|
||||
return normalizeAllowlist(config?.skills?.allowBundled);
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ export function hasBinary(bin: string): boolean {
|
||||
|
||||
export function shouldIncludeSkill(params: {
|
||||
entry: SkillEntry;
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
eligibility?: SkillEligibilityContext;
|
||||
}): boolean {
|
||||
const { entry, config, eligibility } = params;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } 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?: MoltbotConfig }) {
|
||||
export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?: OpenClawConfig }) {
|
||||
const { skills, config } = params;
|
||||
const updates: Array<{ key: string; prev: string | undefined }> = [];
|
||||
|
||||
@@ -37,7 +37,7 @@ export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?:
|
||||
|
||||
export function applySkillEnvOverridesFromSnapshot(params: {
|
||||
snapshot?: SkillSnapshot;
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
}) {
|
||||
const { snapshot, config } = params;
|
||||
if (!snapshot) return () => {};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import JSON5 from "json5";
|
||||
import type { Skill } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
import { LEGACY_MANIFEST_KEY } from "../../compat/legacy-names.js";
|
||||
import { LEGACY_MANIFEST_KEYS, MANIFEST_KEY } from "../../compat/legacy-names.js";
|
||||
import { parseFrontmatterBlock } from "../../markdown/frontmatter.js";
|
||||
import { parseBooleanValue } from "../../utils/boolean.js";
|
||||
import type {
|
||||
MoltbotSkillMetadata,
|
||||
OpenClawSkillMetadata,
|
||||
ParsedSkillFrontmatter,
|
||||
SkillEntry,
|
||||
SkillInstallSpec,
|
||||
@@ -72,17 +72,23 @@ function parseFrontmatterBool(value: string | undefined, fallback: boolean): boo
|
||||
return parsed === undefined ? fallback : parsed;
|
||||
}
|
||||
|
||||
export function resolveMoltbotMetadata(
|
||||
export function resolveOpenClawMetadata(
|
||||
frontmatter: ParsedSkillFrontmatter,
|
||||
): MoltbotSkillMetadata | undefined {
|
||||
): OpenClawSkillMetadata | undefined {
|
||||
const raw = getFrontmatterValue(frontmatter, "metadata");
|
||||
if (!raw) return undefined;
|
||||
try {
|
||||
const parsed = JSON5.parse(raw) as { moltbot?: unknown } & Partial<
|
||||
Record<typeof LEGACY_MANIFEST_KEY, unknown>
|
||||
>;
|
||||
const parsed = JSON5.parse(raw) as Record<string, unknown>;
|
||||
if (!parsed || typeof parsed !== "object") return undefined;
|
||||
const metadataRaw = parsed.moltbot ?? parsed[LEGACY_MANIFEST_KEY];
|
||||
const metadataRawCandidates = [MANIFEST_KEY, ...LEGACY_MANIFEST_KEYS];
|
||||
let metadataRaw: unknown;
|
||||
for (const key of metadataRawCandidates) {
|
||||
const candidate = parsed[key];
|
||||
if (candidate && typeof candidate === "object") {
|
||||
metadataRaw = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!metadataRaw || typeof metadataRaw !== "object") return undefined;
|
||||
const metadataObj = metadataRaw as Record<string, unknown>;
|
||||
const requiresRaw =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } 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?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
}): string[] {
|
||||
const workspaceDir = params.workspaceDir.trim();
|
||||
if (!workspaceDir) return [];
|
||||
|
||||
@@ -2,7 +2,7 @@ import path from "node:path";
|
||||
|
||||
import chokidar, { type FSWatcher } from "chokidar";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } 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?: MoltbotConfig): string[] {
|
||||
function resolveWatchPaths(workspaceDir: string, config?: OpenClawConfig): 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?: MoltbotConfig }) {
|
||||
export function ensureSkillsWatcher(params: { workspaceDir: string; config?: OpenClawConfig }) {
|
||||
const workspaceDir = params.workspaceDir.trim();
|
||||
if (!workspaceDir) return;
|
||||
const watchEnabled = params.config?.skills?.load?.watch !== false;
|
||||
|
||||
@@ -16,7 +16,7 @@ export type SkillInstallSpec = {
|
||||
targetDir?: string;
|
||||
};
|
||||
|
||||
export type MoltbotSkillMetadata = {
|
||||
export type OpenClawSkillMetadata = {
|
||||
always?: boolean;
|
||||
skillKey?: string;
|
||||
primaryEnv?: string;
|
||||
@@ -66,7 +66,7 @@ export type ParsedSkillFrontmatter = Record<string, string>;
|
||||
export type SkillEntry = {
|
||||
skill: Skill;
|
||||
frontmatter: ParsedSkillFrontmatter;
|
||||
metadata?: MoltbotSkillMetadata;
|
||||
metadata?: OpenClawSkillMetadata;
|
||||
invocation?: SkillInvocationPolicy;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ import {
|
||||
type Skill,
|
||||
} from "@mariozechner/pi-coding-agent";
|
||||
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import type { OpenClawConfig } 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,
|
||||
resolveMoltbotMetadata,
|
||||
resolveOpenClawMetadata,
|
||||
resolveSkillInvocationPolicy,
|
||||
} from "./frontmatter.js";
|
||||
import { resolvePluginSkillDirs } from "./plugin-skills.js";
|
||||
@@ -43,7 +43,7 @@ function debugSkillCommandOnce(
|
||||
|
||||
function filterSkillEntries(
|
||||
entries: SkillEntry[],
|
||||
config?: MoltbotConfig,
|
||||
config?: OpenClawConfig,
|
||||
skillFilter?: string[],
|
||||
eligibility?: SkillEligibilityContext,
|
||||
): SkillEntry[] {
|
||||
@@ -95,7 +95,7 @@ function resolveUniqueSkillCommandName(base: string, used: Set<string>): string
|
||||
function loadSkillEntries(
|
||||
workspaceDir: string,
|
||||
opts?: {
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
managedSkillsDir?: string;
|
||||
bundledSkillsDir?: string;
|
||||
},
|
||||
@@ -130,23 +130,23 @@ function loadSkillEntries(
|
||||
const bundledSkills = bundledSkillsDir
|
||||
? loadSkills({
|
||||
dir: bundledSkillsDir,
|
||||
source: "moltbot-bundled",
|
||||
source: "openclaw-bundled",
|
||||
})
|
||||
: [];
|
||||
const extraSkills = mergedExtraDirs.flatMap((dir) => {
|
||||
const resolved = resolveUserPath(dir);
|
||||
return loadSkills({
|
||||
dir: resolved,
|
||||
source: "moltbot-extra",
|
||||
source: "openclaw-extra",
|
||||
});
|
||||
});
|
||||
const managedSkills = loadSkills({
|
||||
dir: managedSkillsDir,
|
||||
source: "moltbot-managed",
|
||||
source: "openclaw-managed",
|
||||
});
|
||||
const workspaceSkills = loadSkills({
|
||||
dir: workspaceSkillsDir,
|
||||
source: "moltbot-workspace",
|
||||
source: "openclaw-workspace",
|
||||
});
|
||||
|
||||
const merged = new Map<string, Skill>();
|
||||
@@ -167,7 +167,7 @@ function loadSkillEntries(
|
||||
return {
|
||||
skill,
|
||||
frontmatter,
|
||||
metadata: resolveMoltbotMetadata(frontmatter),
|
||||
metadata: resolveOpenClawMetadata(frontmatter),
|
||||
invocation: resolveSkillInvocationPolicy(frontmatter),
|
||||
};
|
||||
});
|
||||
@@ -177,7 +177,7 @@ function loadSkillEntries(
|
||||
export function buildWorkspaceSkillSnapshot(
|
||||
workspaceDir: string,
|
||||
opts?: {
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
managedSkillsDir?: string;
|
||||
bundledSkillsDir?: string;
|
||||
entries?: SkillEntry[];
|
||||
@@ -214,7 +214,7 @@ export function buildWorkspaceSkillSnapshot(
|
||||
export function buildWorkspaceSkillsPrompt(
|
||||
workspaceDir: string,
|
||||
opts?: {
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
managedSkillsDir?: string;
|
||||
bundledSkillsDir?: string;
|
||||
entries?: SkillEntry[];
|
||||
@@ -242,7 +242,7 @@ export function buildWorkspaceSkillsPrompt(
|
||||
export function resolveSkillsPromptForRun(params: {
|
||||
skillsSnapshot?: SkillSnapshot;
|
||||
entries?: SkillEntry[];
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir: string;
|
||||
}): string {
|
||||
const snapshotPrompt = params.skillsSnapshot?.prompt?.trim();
|
||||
@@ -260,7 +260,7 @@ export function resolveSkillsPromptForRun(params: {
|
||||
export function loadWorkspaceSkillEntries(
|
||||
workspaceDir: string,
|
||||
opts?: {
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
managedSkillsDir?: string;
|
||||
bundledSkillsDir?: string;
|
||||
},
|
||||
@@ -271,7 +271,7 @@ export function loadWorkspaceSkillEntries(
|
||||
export async function syncSkillsToWorkspace(params: {
|
||||
sourceWorkspaceDir: string;
|
||||
targetWorkspaceDir: string;
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
managedSkillsDir?: string;
|
||||
bundledSkillsDir?: string;
|
||||
}) {
|
||||
@@ -308,7 +308,7 @@ export async function syncSkillsToWorkspace(params: {
|
||||
|
||||
export function filterWorkspaceSkillEntries(
|
||||
entries: SkillEntry[],
|
||||
config?: MoltbotConfig,
|
||||
config?: OpenClawConfig,
|
||||
): SkillEntry[] {
|
||||
return filterSkillEntries(entries, config);
|
||||
}
|
||||
@@ -316,7 +316,7 @@ export function filterWorkspaceSkillEntries(
|
||||
export function buildWorkspaceSkillCommandSpecs(
|
||||
workspaceDir: string,
|
||||
opts?: {
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
managedSkillsDir?: string;
|
||||
bundledSkillsDir?: string;
|
||||
entries?: SkillEntry[];
|
||||
|
||||
Reference in New Issue
Block a user