chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -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"] ??