feat(tools): refactor slashcommand to support options and caching
- Extract createSlashcommandTool factory with SlashcommandToolOptions - Export discoverCommandsSync for external use - Move description building to lazy evaluation with caching - Support pre-warming cache with provided commands and skills - Simplify tool initialization in plugin with new factory approach This allows the slashcommand tool to be instantiated with custom options while maintaining backward compatibility through lazy loading. 🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
11
src/index.ts
11
src/index.ts
@@ -53,6 +53,8 @@ import {
|
||||
createLookAt,
|
||||
createSkillTool,
|
||||
createSkillMcpTool,
|
||||
createSlashcommandTool,
|
||||
discoverCommandsSync,
|
||||
sessionExists,
|
||||
interactive_bash,
|
||||
startTmuxCheck,
|
||||
@@ -231,6 +233,12 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
getSessionID: getSessionIDForMcp,
|
||||
});
|
||||
|
||||
const commands = discoverCommandsSync();
|
||||
const slashcommandTool = createSlashcommandTool({
|
||||
commands,
|
||||
skills: mergedSkills,
|
||||
});
|
||||
|
||||
const googleAuthHooks = pluginConfig.google_auth !== false
|
||||
? await createGoogleAntigravityAuthPlugin(ctx)
|
||||
: null;
|
||||
@@ -251,7 +259,8 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
look_at: lookAt,
|
||||
skill: skillTool,
|
||||
skill_mcp: skillMcpTool,
|
||||
interactive_bash, // Always included, handles missing tmux gracefully via getCachedTmuxPath() ?? "tmux"
|
||||
slashcommand: slashcommandTool,
|
||||
interactive_bash,
|
||||
},
|
||||
|
||||
"chat.message": async (input, output) => {
|
||||
|
||||
Reference in New Issue
Block a user