fix(command-loader): strip incompatible fields before registering with OpenCode
Slash commands with arguments were silently failing in OpenCode TUI because command definitions included 'name' and 'argumentHint' fields that don't exist in OpenCode's Command schema. Strip these fields before registration across all command/skill loaders to ensure compatibility. Affected loaders: - builtin commands - claude-code command loader - opencode skill loader - claude-code plugin loader 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -42,10 +42,8 @@ export function loadBuiltinCommands(
|
|||||||
|
|
||||||
for (const [name, definition] of Object.entries(BUILTIN_COMMAND_DEFINITIONS)) {
|
for (const [name, definition] of Object.entries(BUILTIN_COMMAND_DEFINITIONS)) {
|
||||||
if (!disabled.has(name as BuiltinCommandName)) {
|
if (!disabled.has(name as BuiltinCommandName)) {
|
||||||
commands[name] = {
|
const { argumentHint: _argumentHint, ...openCodeCompatible } = definition
|
||||||
name,
|
commands[name] = openCodeCompatible as CommandDefinition
|
||||||
...definition,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ $ARGUMENTS
|
|||||||
function commandsToRecord(commands: LoadedCommand[]): Record<string, CommandDefinition> {
|
function commandsToRecord(commands: LoadedCommand[]): Record<string, CommandDefinition> {
|
||||||
const result: Record<string, CommandDefinition> = {}
|
const result: Record<string, CommandDefinition> = {}
|
||||||
for (const cmd of commands) {
|
for (const cmd of commands) {
|
||||||
result[cmd.name] = cmd.definition
|
const { name: _name, argumentHint: _argumentHint, ...openCodeCompatible } = cmd.definition
|
||||||
|
result[cmd.name] = openCodeCompatible as CommandDefinition
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ $ARGUMENTS
|
|||||||
|
|
||||||
const formattedDescription = `(plugin: ${plugin.name}) ${data.description || ""}`
|
const formattedDescription = `(plugin: ${plugin.name}) ${data.description || ""}`
|
||||||
|
|
||||||
commands[namespacedName] = {
|
const definition = {
|
||||||
name: namespacedName,
|
name: namespacedName,
|
||||||
description: formattedDescription,
|
description: formattedDescription,
|
||||||
template: wrappedTemplate,
|
template: wrappedTemplate,
|
||||||
@@ -255,6 +255,8 @@ $ARGUMENTS
|
|||||||
subtask: data.subtask,
|
subtask: data.subtask,
|
||||||
argumentHint: data["argument-hint"],
|
argumentHint: data["argument-hint"],
|
||||||
}
|
}
|
||||||
|
const { name: _name, argumentHint: _argumentHint, ...openCodeCompatible } = definition
|
||||||
|
commands[namespacedName] = openCodeCompatible as CommandDefinition
|
||||||
|
|
||||||
log(`Loaded plugin command: ${namespacedName}`, { path: commandPath })
|
log(`Loaded plugin command: ${namespacedName}`, { path: commandPath })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -306,12 +308,14 @@ ${body.trim()}
|
|||||||
$ARGUMENTS
|
$ARGUMENTS
|
||||||
</user-request>`
|
</user-request>`
|
||||||
|
|
||||||
skills[namespacedName] = {
|
const definition = {
|
||||||
name: namespacedName,
|
name: namespacedName,
|
||||||
description: formattedDescription,
|
description: formattedDescription,
|
||||||
template: wrappedTemplate,
|
template: wrappedTemplate,
|
||||||
model: sanitizeModelField(data.model),
|
model: sanitizeModelField(data.model),
|
||||||
}
|
}
|
||||||
|
const { name: _name, ...openCodeCompatible } = definition
|
||||||
|
skills[namespacedName] = openCodeCompatible as CommandDefinition
|
||||||
|
|
||||||
log(`Loaded plugin skill: ${namespacedName}`, { path: resolvedPath })
|
log(`Loaded plugin skill: ${namespacedName}`, { path: resolvedPath })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ function loadSkillsFromDir(skillsDir: string, scope: SkillScope): LoadedSkill[]
|
|||||||
function skillsToRecord(skills: LoadedSkill[]): Record<string, CommandDefinition> {
|
function skillsToRecord(skills: LoadedSkill[]): Record<string, CommandDefinition> {
|
||||||
const result: Record<string, CommandDefinition> = {}
|
const result: Record<string, CommandDefinition> = {}
|
||||||
for (const skill of skills) {
|
for (const skill of skills) {
|
||||||
result[skill.name] = skill.definition
|
const { name: _name, argumentHint: _argumentHint, ...openCodeCompatible } = skill.definition
|
||||||
|
result[skill.name] = openCodeCompatible as CommandDefinition
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user