-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(cli): add custom commands support #5183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): add custom commands support #5183
Conversation
🦋 Changeset detectedLatest commit: 01e9014 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
65cffcc to
d084421
Compare
| }) | ||
|
|
||
| describe("getCustomCommands", () => { | ||
| const mockCwd = "/mock/project" |
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.
These tests might fail on Windows
|
Cool feature @alexandrevilain! We just need to get those edge cases right. |
d084421 to
42fb14f
Compare
|
Thanks for the review @marius-kilocode ! I've addressed all your comments except for the failing tests on Windows. Since I don't have a Windows development environment, I can't confirm whether these tests are actually failing or not. However, given that the tests use mocked implementations for Feel free to let me know what kind of issues you're anticipating on Windows with this approach, and I'll be happy to adjust accordingly! |
Implement custom commands feature allowing users to create reusable slash commands from markdown files stored in global (~/.kilocode/commands/) or project-specific (.kilocode/commands/) directories. Commands support argument substitution, automatic mode/model switching, and YAML frontmatter configuration. - Add documentation for custom commands in CLI docs - Implement custom command loading, parsing, and execution logic - Add comprehensive test suite for custom commands functionality - Integrate custom commands initialization into the UI startup process
42fb14f to
8450f6d
Compare
| const entries = await fs.readdir(dirPath, { withFileTypes: true }) | ||
|
|
||
| for (const entry of entries) { | ||
| if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue |
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.
@alexandrevilain I think you misunderstood me here. The .md file was just an example. We need to validate here if the format for a custom slash command is correct. Maybe a regex would make sense.
Good:
/review
/review-this
Bad:
/this.is.bad
/file.txt
/$#()%$#)
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.
@marius-kilocode this was the purpose of isValidCommandName. Isn't it sufficient ?
Maybe I can rework it to become isValidCommandFilename and validate against ^[a-zA-Z0-9][a-zA-Z0-9-]*\.md$. WDYT ?
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 think I misread the regex. I also tested it one more time. The change looks good to go. Thanks a lot!
|
Thanks for the contribution @alexandrevilain! |
Context
Implement custom commands feature allowing users to create reusable slash commands from markdown files stored in global (~/.kilocode/commands/) or project-specific (.kilocode/commands/) directories. Commands support argument substitution, automatic mode/model switching, and YAML frontmatter configuration.
Implementation
Users drop markdown files in ~/.kilocode/commands/ or .kilocode/commands/, and those become slash commands. That's it.
Commands loading steps:
The markdown format:
When you run the command:
Decisions
Mardown: Same as opencode, claude code, simple to write.
Directories: We already have this pattern for skills (~/.kilocode/skills/ and .kilocode/skills/), so just reused the same convention. Users already understand it.
Arguments substitution: Tried to keep it dumb - just replace $1 with the first arg, $ARGUMENTS with all args. No fancy templating engine needed.
Error handling: If a directory doesn't exist, fine. If model switching fails, warn but keep going. Don't break the whole feature because of one bad file.
Screenshots
Here is an example with the following custom command:
custom-commands-light.mp4
How to Test
Create custom commands in
~/.kilocode/commands/or.kilocode/commands/and runkilo.You can use them and show commands help
Get in Touch
Discord:
alexandrevilain.