From 6bbe69a72a7c06537fa20368380c379484f292a5 Mon Sep 17 00:00:00 2001 From: Momentum96 Date: Mon, 12 Jan 2026 17:27:54 +0900 Subject: [PATCH] fix(skill-loader): implement eager loading to resolve empty slash commands --- src/features/opencode-skill-loader/loader.ts | 22 +++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/features/opencode-skill-loader/loader.ts b/src/features/opencode-skill-loader/loader.ts index 2d59f1477..5d6561da6 100644 --- a/src/features/opencode-skill-loader/loader.ts +++ b/src/features/opencode-skill-loader/loader.ts @@ -63,7 +63,7 @@ async function loadSkillFromPath( ): Promise { try { const content = await fs.readFile(skillPath, "utf-8") - const { data } = parseFrontmatter(content) + const { data, body } = parseFrontmatter(content) const frontmatterMcp = parseSkillMcpConfigFromFrontmatter(content) const mcpJsonMcp = await loadMcpJsonFromDir(resolvedPath) const mcpConfig = mcpJsonMcp || frontmatterMcp @@ -73,14 +73,7 @@ async function loadSkillFromPath( const isOpencodeSource = scope === "opencode" || scope === "opencode-project" const formattedDescription = `(${scope} - Skill) ${originalDescription}` - const lazyContent: LazyContentLoader = { - loaded: false, - content: undefined, - load: async () => { - if (!lazyContent.loaded) { - const fileContent = await fs.readFile(skillPath, "utf-8") - const { body } = parseFrontmatter(fileContent) - lazyContent.content = ` + const templateContent = ` Base directory for this skill: ${resolvedPath}/ File references (@path) in this skill are relative to this directory. @@ -90,16 +83,17 @@ ${body.trim()} $ARGUMENTS ` - lazyContent.loaded = true - } - return lazyContent.content! - }, + + const lazyContent: LazyContentLoader = { + loaded: true, + content: templateContent, + load: async () => templateContent, } const definition: CommandDefinition = { name: skillName, description: formattedDescription, - template: "", + template: templateContent, model: sanitizeModelField(data.model, isOpencodeSource ? "opencode" : "claude-code"), agent: data.agent, subtask: data.subtask,