|
@@ -29,7 +29,7 @@ type Command struct {
|
|
|
Name CommandName
|
|
Name CommandName
|
|
|
Description string
|
|
Description string
|
|
|
Keybindings []Keybinding
|
|
Keybindings []Keybinding
|
|
|
- Trigger string
|
|
|
|
|
|
|
+ Trigger []string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (c Command) Keys() []string {
|
|
func (c Command) Keys() []string {
|
|
@@ -40,6 +40,21 @@ func (c Command) Keys() []string {
|
|
|
return keys
|
|
return keys
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (c Command) HasTrigger() bool {
|
|
|
|
|
+ return len(c.Trigger) > 0
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (c Command) PrimaryTrigger() string {
|
|
|
|
|
+ if len(c.Trigger) > 0 {
|
|
|
|
|
+ return c.Trigger[0]
|
|
|
|
|
+ }
|
|
|
|
|
+ return ""
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (c Command) MatchesTrigger(trigger string) bool {
|
|
|
|
|
+ return slices.Contains(c.Trigger, trigger)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
type CommandRegistry map[CommandName]Command
|
|
type CommandRegistry map[CommandName]Command
|
|
|
|
|
|
|
|
func (r CommandRegistry) Sorted() []Command {
|
|
func (r CommandRegistry) Sorted() []Command {
|
|
@@ -135,37 +150,37 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
|
|
|
Name: AppHelpCommand,
|
|
Name: AppHelpCommand,
|
|
|
Description: "show help",
|
|
Description: "show help",
|
|
|
Keybindings: parseBindings("<leader>h"),
|
|
Keybindings: parseBindings("<leader>h"),
|
|
|
- Trigger: "help",
|
|
|
|
|
|
|
+ Trigger: []string{"help"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: EditorOpenCommand,
|
|
Name: EditorOpenCommand,
|
|
|
Description: "open editor",
|
|
Description: "open editor",
|
|
|
Keybindings: parseBindings("<leader>e"),
|
|
Keybindings: parseBindings("<leader>e"),
|
|
|
- Trigger: "editor",
|
|
|
|
|
|
|
+ Trigger: []string{"editor"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: SessionNewCommand,
|
|
Name: SessionNewCommand,
|
|
|
Description: "new session",
|
|
Description: "new session",
|
|
|
Keybindings: parseBindings("<leader>n"),
|
|
Keybindings: parseBindings("<leader>n"),
|
|
|
- Trigger: "new",
|
|
|
|
|
|
|
+ Trigger: []string{"new", "clear"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: SessionListCommand,
|
|
Name: SessionListCommand,
|
|
|
Description: "list sessions",
|
|
Description: "list sessions",
|
|
|
Keybindings: parseBindings("<leader>l"),
|
|
Keybindings: parseBindings("<leader>l"),
|
|
|
- Trigger: "sessions",
|
|
|
|
|
|
|
+ Trigger: []string{"sessions", "resume", "continue"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: SessionShareCommand,
|
|
Name: SessionShareCommand,
|
|
|
Description: "share session",
|
|
Description: "share session",
|
|
|
Keybindings: parseBindings("<leader>s"),
|
|
Keybindings: parseBindings("<leader>s"),
|
|
|
- Trigger: "share",
|
|
|
|
|
|
|
+ Trigger: []string{"share"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: SessionUnshareCommand,
|
|
Name: SessionUnshareCommand,
|
|
|
Description: "unshare session",
|
|
Description: "unshare session",
|
|
|
Keybindings: parseBindings("<leader>u"),
|
|
Keybindings: parseBindings("<leader>u"),
|
|
|
- Trigger: "unshare",
|
|
|
|
|
|
|
+ Trigger: []string{"unshare"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: SessionInterruptCommand,
|
|
Name: SessionInterruptCommand,
|
|
@@ -176,31 +191,31 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
|
|
|
Name: SessionCompactCommand,
|
|
Name: SessionCompactCommand,
|
|
|
Description: "compact the session",
|
|
Description: "compact the session",
|
|
|
Keybindings: parseBindings("<leader>c"),
|
|
Keybindings: parseBindings("<leader>c"),
|
|
|
- Trigger: "compact",
|
|
|
|
|
|
|
+ Trigger: []string{"compact", "summarize"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: ToolDetailsCommand,
|
|
Name: ToolDetailsCommand,
|
|
|
Description: "toggle tool details",
|
|
Description: "toggle tool details",
|
|
|
Keybindings: parseBindings("<leader>d"),
|
|
Keybindings: parseBindings("<leader>d"),
|
|
|
- Trigger: "details",
|
|
|
|
|
|
|
+ Trigger: []string{"details"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: ModelListCommand,
|
|
Name: ModelListCommand,
|
|
|
Description: "list models",
|
|
Description: "list models",
|
|
|
Keybindings: parseBindings("<leader>m"),
|
|
Keybindings: parseBindings("<leader>m"),
|
|
|
- Trigger: "models",
|
|
|
|
|
|
|
+ Trigger: []string{"models"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: ThemeListCommand,
|
|
Name: ThemeListCommand,
|
|
|
Description: "list themes",
|
|
Description: "list themes",
|
|
|
Keybindings: parseBindings("<leader>t"),
|
|
Keybindings: parseBindings("<leader>t"),
|
|
|
- Trigger: "themes",
|
|
|
|
|
|
|
+ Trigger: []string{"themes"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: FileListCommand,
|
|
Name: FileListCommand,
|
|
|
Description: "list files",
|
|
Description: "list files",
|
|
|
Keybindings: parseBindings("<leader>f"),
|
|
Keybindings: parseBindings("<leader>f"),
|
|
|
- Trigger: "files",
|
|
|
|
|
|
|
+ Trigger: []string{"files"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: FileCloseCommand,
|
|
Name: FileCloseCommand,
|
|
@@ -221,7 +236,7 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
|
|
|
Name: ProjectInitCommand,
|
|
Name: ProjectInitCommand,
|
|
|
Description: "create/update AGENTS.md",
|
|
Description: "create/update AGENTS.md",
|
|
|
Keybindings: parseBindings("<leader>i"),
|
|
Keybindings: parseBindings("<leader>i"),
|
|
|
- Trigger: "init",
|
|
|
|
|
|
|
+ Trigger: []string{"init"},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
Name: InputClearCommand,
|
|
Name: InputClearCommand,
|
|
@@ -302,7 +317,7 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
|
|
|
Name: AppExitCommand,
|
|
Name: AppExitCommand,
|
|
|
Description: "exit the app",
|
|
Description: "exit the app",
|
|
|
Keybindings: parseBindings("ctrl+c", "<leader>q"),
|
|
Keybindings: parseBindings("ctrl+c", "<leader>q"),
|
|
|
- Trigger: "exit",
|
|
|
|
|
|
|
+ Trigger: []string{"exit", "quit"},
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
registry := make(CommandRegistry)
|
|
registry := make(CommandRegistry)
|