The !cmd shell syntax was ALREADY IMPLEMENTED in kuuzuki but had a critical missing piece!
- Input Detection -
!cmdsyntax detected in editor.go:558 - Shell Execution - ExecuteShellCommand message sent to app
- Server Endpoint -
/session/:id/shellendpoint exists - Real-time Streaming - Server streams output via updatePart()
- TUI Streaming - EventListResponseEventMessagePartUpdated handled
Shell Output Display - No case "shell" in tool rendering logic!
Added missing case "shell" in /packages/tui/internal/components/chat/message.go to properly render shell command output with:
- Real-time streaming output display
- Status indicators (Running/Completed/Error)
- Exit code display
- ANSI-stripped clean output
- Cursor indicator for active streaming
// Check for !shell command
if strings.HasPrefix(value, "!") && len(value) > 1 {
command := strings.TrimSpace(value[1:]) // Remove the ! prefix
if command != "" {
// Execute shell command
cmds = append(cmds, util.CmdHandler(app.ExecuteShellCommand{
SessionID: m.app.Session.ID,
Command: command,
}))
return m, tea.Batch(cmds...)
}
}case app.ExecuteShellCommand:
a.showCompletionDialog = false
// Execute shell command asynchronously
cmds = append(cmds, func() tea.Msg {
_, err := a.app.ExecuteShellCommand(context.Background(), msg.SessionID, msg.Command)
if err != nil {
return toast.NewErrorToast(fmt.Sprintf("Shell command failed: %v", err))
}
return nil
})// Run a shell command
func (r *SessionService) Shell(ctx context.Context, id string, body SessionShellParams, opts ...option.RequestOption) (res *AssistantMessage, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("session/%s/shell", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}✅ Input Detection: Detects commands starting with ! in TUI editor
✅ Command Parsing: Strips ! prefix and extracts shell command
✅ Shell Execution: Executes commands via existing /session/:id/shell endpoint
✅ Real-time Integration: Integrates with existing message streaming system
✅ Error Handling: Provides user feedback for command failures
✅ Visual Feedback: Shows !cmd shell hint in editor status bar
✅ Async Execution: Commands execute asynchronously without blocking UI
- Existing Shell Endpoint: Uses the already implemented
/session/:id/shellendpoint - Message System: Integrates with existing message streaming and display
- Error Handling: Uses existing toast notification system
- UI Patterns: Follows existing TUI patterns and styling
- SDK Consistency: Go SDK methods follow existing patterns
To test the implementation:
- Start the TUI:
kuuzuki tui - Type a shell command with
!prefix:!ls -la - Press Enter to execute
- The command will be sent to the shell endpoint and output displayed in real-time
- Error messages will appear as toast notifications if commands fail
- Invalid commands show error toasts
- Empty commands after
!are ignored - Network errors are handled gracefully
- Shell command failures are reported to the user
- Uses existing shell endpoint security measures
- Commands execute in the same security context as the bash tool
- No additional privilege escalation
- Follows existing permission patterns
This implementation provides a seamless inline shell execution experience that matches the OpenCode feature while maintaining kuuzuki's architecture and security model.