-
Notifications
You must be signed in to change notification settings - Fork 42
🤖 feat: add custom executable slash commands (.mux/commands/) #1523
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
base: main
Are you sure you want to change the base?
Conversation
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8152aa515
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review Addressed the P1 and P2 review comments:
Also added:
|
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccbeaea806
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review Addressed additional review comments:
|
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04ddac9a3d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11cc4f1b8e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
11cc4f1 to
825fabf
Compare
Adds support for custom slash commands that run executables in the workspace. ## Features - **Discovery**: Executables at `.mux/commands/<name>` are discovered and appear in slash command autocomplete. - **Execution**: `/<name> [args...]` runs the command with: - First line tokens become argv - Lines after the first become stdin - Stdout streams in real-time via init events - Stdout becomes the user message on success - **Environment**: Commands receive MUX_* env vars (project path, runtime, workspace name, workspace path). ## Implementation - Backend: SlashCommandService for discovery and execution with streaming - Frontend: Parser extended with rawInput for unknown commands - Frontend: ChatInput wired to execute custom commands and show autocomplete - Docs: New page at docs/hooks/slash-commands.mdx ## Example ```bash #!/bin/bash # .mux/commands/refinement echo "Refine this:" cat ``` Then use with: `/refinement\n<text to refine>`
- Quote command path before exec to handle spaces in workspace paths (P1) - Preserve stdin whitespace - don't trim multiline input (P2) - Add exit code 2 handling: show output but don't send to model - Update docs with progressive examples (static msg, args, stdin) - Add comprehensive UI integration tests for custom slash commands - Add unit tests for custom command suggestions
- Remove UI integration tests that were timing out in CI - Add backend integration tests for slash command functionality: - Command discovery (list) - Command execution (run) - Exit code handling (0, 2, others) - Argument and stdin passing
- P2: Preserve blank lines in command stdout by accumulating raw bytes instead of using LineBuffer (which drops empty lines) - P3: Restore input when command produces no output (consistent error handling)
0eb1c76 to
2941d90
Compare
7fdb7f8 to
13e6ee3
Compare
13e6ee3 to
a684aae
Compare
Static files are read verbatim (no execution required): - .mux/commands/<name>.txt - .mux/commands/<name>.md This is simpler than writing an executable script for static prompts. Static files are preferred over executables with the same base name (.txt checked first, then .md, then bare executable).
a684aae to
ab2bb5d
Compare
- Add 'custom' badge to distinguish custom commands from built-in ones - Add 'Add custom commands' docs link in autocomplete footer - Add isCustom property to SlashSuggestion type - Add slashCommands mock support for storybook - Create App.slashCommands.stories.tsx with: - BuiltInCommands: shows standard slash commands - WithCustomCommands: shows custom commands with badge - FilteredCommands: shows filtering behavior
23be909 to
66b2949
Compare
Reduces duplication between static file and executable command paths by: - Adding withCommandLifecycle() to handle init-start/end lifecycle and error handling - Adding emitOutput() helper for streaming lines - Both runStaticFile() and runExecutable() now use these helpers Net reduction: ~50 lines (~15% less code)
- Badge now appears before command name to reduce visual scanning - Custom command text uses plan-mode-light color for visual distinction
- Drop .txt support, only .md files for static commands - Parse YAML frontmatter from .md files for description field - Parse magic comment '# mux: <description>' from executables - API returns skippedInvalidNames to help users debug invalid command names - Badge now appears after command name for consistent vertical alignment - Descriptions shown in autocomplete suggestions New shared utility: src/node/utils/markdown.ts (simple frontmatter parsing)
- Frontmatter field changed from 'description' to 'usage' - Executable comment changed from '# mux: ...' to '# usage: ...' - Updated all docs examples to show usage comments - Pattern is case-insensitive for flexibility The 'usage:' pattern is more conventional and self-documenting.
Replace generic /context example with /todo - finds TODO/FIXME comments and asks the model to help address them. More practical demonstration of dynamic content.
6083c12 to
bf0777d
Compare
Adds a deterministic streaming test that uses file-based synchronization to prove output accumulates progressively during slash command execution. The test creates an executable command that signals via temp files between steps, allowing the test to verify streaming works without timing-based flakiness.
When switching between storybook stories, the MemoryRouter was not
re-reading initialEntries from localStorage because it wasn't being
remounted. This caused custom slash commands to not appear because
the router stayed on the previous story's workspace.
Adding key={storyId} forces AppLoader (and its child MemoryRouter)
to remount when the story changes, ensuring the router reads the
correct workspace selection from localStorage.
Summary
Adds support for custom slash commands that run executables in the workspace.
Features
.mux/commands/<name>are discovered and appear in slash command autocomplete/<name> [args...]runs the command with:Example
Then use with:
/refinement\n<text to refine>Implementation
SlashCommandServicefor discovery and execution with streamingrawInputfor unknown commandsTesting
Generated with
mux• Model:anthropic:claude-opus-4-5• Thinking:high• Cost:$11.85