Skip to content

Commit 6bbe69a

Browse files
committed
fix(skill-loader): implement eager loading to resolve empty slash commands
1 parent f9dca8d commit 6bbe69a

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/features/opencode-skill-loader/loader.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function loadSkillFromPath(
6363
): Promise<LoadedSkill | null> {
6464
try {
6565
const content = await fs.readFile(skillPath, "utf-8")
66-
const { data } = parseFrontmatter<SkillMetadata>(content)
66+
const { data, body } = parseFrontmatter<SkillMetadata>(content)
6767
const frontmatterMcp = parseSkillMcpConfigFromFrontmatter(content)
6868
const mcpJsonMcp = await loadMcpJsonFromDir(resolvedPath)
6969
const mcpConfig = mcpJsonMcp || frontmatterMcp
@@ -73,14 +73,7 @@ async function loadSkillFromPath(
7373
const isOpencodeSource = scope === "opencode" || scope === "opencode-project"
7474
const formattedDescription = `(${scope} - Skill) ${originalDescription}`
7575

76-
const lazyContent: LazyContentLoader = {
77-
loaded: false,
78-
content: undefined,
79-
load: async () => {
80-
if (!lazyContent.loaded) {
81-
const fileContent = await fs.readFile(skillPath, "utf-8")
82-
const { body } = parseFrontmatter<SkillMetadata>(fileContent)
83-
lazyContent.content = `<skill-instruction>
76+
const templateContent = `<skill-instruction>
8477
Base directory for this skill: ${resolvedPath}/
8578
File references (@path) in this skill are relative to this directory.
8679
@@ -90,16 +83,17 @@ ${body.trim()}
9083
<user-request>
9184
$ARGUMENTS
9285
</user-request>`
93-
lazyContent.loaded = true
94-
}
95-
return lazyContent.content!
96-
},
86+
87+
const lazyContent: LazyContentLoader = {
88+
loaded: true,
89+
content: templateContent,
90+
load: async () => templateContent,
9791
}
9892

9993
const definition: CommandDefinition = {
10094
name: skillName,
10195
description: formattedDescription,
102-
template: "",
96+
template: templateContent,
10397
model: sanitizeModelField(data.model, isOpencodeSource ? "opencode" : "claude-code"),
10498
agent: data.agent,
10599
subtask: data.subtask,

0 commit comments

Comments
 (0)