mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:07:40 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -36,7 +36,9 @@ function debugSkillCommandOnce(
|
||||
message: string,
|
||||
meta?: Record<string, unknown>,
|
||||
) {
|
||||
if (skillCommandDebugOnce.has(messageKey)) return;
|
||||
if (skillCommandDebugOnce.has(messageKey)) {
|
||||
return;
|
||||
}
|
||||
skillCommandDebugOnce.add(messageKey);
|
||||
skillsLogger.debug(message, meta);
|
||||
}
|
||||
@@ -79,14 +81,18 @@ function sanitizeSkillCommandName(raw: string): string {
|
||||
|
||||
function resolveUniqueSkillCommandName(base: string, used: Set<string>): string {
|
||||
const normalizedBase = base.toLowerCase();
|
||||
if (!used.has(normalizedBase)) return base;
|
||||
if (!used.has(normalizedBase)) {
|
||||
return base;
|
||||
}
|
||||
for (let index = 2; index < 1000; index += 1) {
|
||||
const suffix = `_${index}`;
|
||||
const maxBaseLength = Math.max(1, SKILL_COMMAND_MAX_LENGTH - suffix.length);
|
||||
const trimmedBase = base.slice(0, maxBaseLength);
|
||||
const candidate = `${trimmedBase}${suffix}`;
|
||||
const candidateKey = candidate.toLowerCase();
|
||||
if (!used.has(candidateKey)) return candidate;
|
||||
if (!used.has(candidateKey)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
const fallback = `${base.slice(0, Math.max(1, SKILL_COMMAND_MAX_LENGTH - 2))}_x`;
|
||||
return fallback;
|
||||
@@ -102,7 +108,9 @@ function loadSkillEntries(
|
||||
): SkillEntry[] {
|
||||
const loadSkills = (params: { dir: string; source: string }): Skill[] => {
|
||||
const loaded = loadSkillsFromDir(params);
|
||||
if (Array.isArray(loaded)) return loaded;
|
||||
if (Array.isArray(loaded)) {
|
||||
return loaded;
|
||||
}
|
||||
if (
|
||||
loaded &&
|
||||
typeof loaded === "object" &&
|
||||
@@ -151,10 +159,18 @@ function loadSkillEntries(
|
||||
|
||||
const merged = new Map<string, Skill>();
|
||||
// Precedence: extra < bundled < managed < workspace
|
||||
for (const skill of extraSkills) merged.set(skill.name, skill);
|
||||
for (const skill of bundledSkills) merged.set(skill.name, skill);
|
||||
for (const skill of managedSkills) merged.set(skill.name, skill);
|
||||
for (const skill of workspaceSkills) merged.set(skill.name, skill);
|
||||
for (const skill of extraSkills) {
|
||||
merged.set(skill.name, skill);
|
||||
}
|
||||
for (const skill of bundledSkills) {
|
||||
merged.set(skill.name, skill);
|
||||
}
|
||||
for (const skill of managedSkills) {
|
||||
merged.set(skill.name, skill);
|
||||
}
|
||||
for (const skill of workspaceSkills) {
|
||||
merged.set(skill.name, skill);
|
||||
}
|
||||
|
||||
const skillEntries: SkillEntry[] = Array.from(merged.values()).map((skill) => {
|
||||
let frontmatter: ParsedSkillFrontmatter = {};
|
||||
@@ -246,7 +262,9 @@ export function resolveSkillsPromptForRun(params: {
|
||||
workspaceDir: string;
|
||||
}): string {
|
||||
const snapshotPrompt = params.skillsSnapshot?.prompt?.trim();
|
||||
if (snapshotPrompt) return snapshotPrompt;
|
||||
if (snapshotPrompt) {
|
||||
return snapshotPrompt;
|
||||
}
|
||||
if (params.entries && params.entries.length > 0) {
|
||||
const prompt = buildWorkspaceSkillsPrompt(params.workspaceDir, {
|
||||
entries: params.entries,
|
||||
@@ -277,7 +295,9 @@ export async function syncSkillsToWorkspace(params: {
|
||||
}) {
|
||||
const sourceDir = resolveUserPath(params.sourceWorkspaceDir);
|
||||
const targetDir = resolveUserPath(params.targetWorkspaceDir);
|
||||
if (sourceDir === targetDir) return;
|
||||
if (sourceDir === targetDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
await serializeByKey(`syncSkills:${targetDir}`, async () => {
|
||||
const targetSkillsDir = path.join(targetDir, "skills");
|
||||
@@ -371,8 +391,12 @@ export function buildWorkspaceSkillCommandSpecs(
|
||||
)
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
if (!kindRaw) return undefined;
|
||||
if (kindRaw !== "tool") return undefined;
|
||||
if (!kindRaw) {
|
||||
return undefined;
|
||||
}
|
||||
if (kindRaw !== "tool") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const toolName = (
|
||||
entry.frontmatter?.["command-tool"] ??
|
||||
|
||||
Reference in New Issue
Block a user