fix(slashcommand): deduplicate opencode command aliases
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -76,6 +76,22 @@ function discoverPluginCommands(options?: CommandDiscoveryOptions): CommandInfo[
|
||||
}))
|
||||
}
|
||||
|
||||
function deduplicateCommandInfosByName(commands: CommandInfo[]): CommandInfo[] {
|
||||
const seen = new Set<string>()
|
||||
const deduplicatedCommands: CommandInfo[] = []
|
||||
|
||||
for (const command of commands) {
|
||||
if (seen.has(command.name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
seen.add(command.name)
|
||||
deduplicatedCommands.push(command)
|
||||
}
|
||||
|
||||
return deduplicatedCommands
|
||||
}
|
||||
|
||||
export function discoverCommandsSync(
|
||||
directory?: string,
|
||||
options?: CommandDiscoveryOptions,
|
||||
@@ -110,12 +126,12 @@ export function discoverCommandsSync(
|
||||
scope: "builtin",
|
||||
}))
|
||||
|
||||
return [
|
||||
return deduplicateCommandInfosByName([
|
||||
...projectCommands,
|
||||
...userCommands,
|
||||
...opencodeProjectCommands,
|
||||
...opencodeGlobalCommands,
|
||||
...builtinCommands,
|
||||
...pluginCommands,
|
||||
]
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user