-
Notifications
You must be signed in to change notification settings - Fork 731
feat: custom commands #133
feat: custom commands #133
Conversation
@@ -56,6 +57,12 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | |||
if cmd != nil { | |||
return p, cmd | |||
} | |||
case dialog.CommandRunCustomMsg: | |||
// Handle custom command execution | |||
cmd := p.sendMessage(msg.Content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to check if the agent is busy here before we send the message.
p.app.CoderAgent.IsBusy()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's busy what should the behavior be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess just returning a warning should be fine right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you already did what I wanted to suggest 😂 awesome.
@ezynda3 do you mind adding a section for this in the readme? |
Done! |
README.md
Outdated
|
||
Global | ||
``` | ||
$HOME/.opencode/commands/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the code is actually looking for this global dir? maybe I am missing something but I think this is a good idea to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@kujtimiihoxha So it now looks in the global opencode config dir as well as the project level data dir and prefixes with either |
checking this now.. sorry it took so long. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awesome addition 🙌 just a couple of small things.
Maybe later we could make it possible to have multiple inputs and anything that starts with $ and is all upper case could be considered a variable... this way we could add many variables and not be limited to one.
var commands []Command | ||
|
||
// Load user commands from XDG_CONFIG_HOME/opencode/commands | ||
xdgConfigHome := os.Getenv("XDG_CONFIG_HOME") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also make it possible to add commands in $HOME/.opencode/commands
this way this behaves similar to the config path defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kujtimiihoxha updated
Co-authored-by: Kujtim Hoxha <kujtimii.h@gmail.com>
Users can create custom commands by adding .md files to their configured
<data_dir>/commands
dir (default is.opencode/commands
). They can then open the command dialog as normal withcttrl+k
and select one of the custom commands.Custom commands are simply prompts and work similar to custom slash commands in Claude Code
ref: https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#create-custom-slash-commands
Addresses: #132