From e80e0ebc4079df21fbfadbde355330dcdd30f895 Mon Sep 17 00:00:00 2001 From: celestial-vault <58194240+celestial-vault@users.noreply.github.com> Date: Tue, 7 Oct 2025 22:45:28 -0700 Subject: [PATCH] add oneshot command (#6695) --- cli/pkg/cli/task.go | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/cli/pkg/cli/task.go b/cli/pkg/cli/task.go index ce91ce45..7748634a 100644 --- a/cli/pkg/cli/task.go +++ b/cli/pkg/cli/task.go @@ -23,6 +23,7 @@ func NewTaskCommand() *cobra.Command { } cmd.AddCommand(newTaskNewCommand()) + cmd.AddCommand(newTaskOneshotCommand()) cmd.AddCommand(newTaskCancelCommand()) cmd.AddCommand(newTaskFollowCommand()) cmd.AddCommand(NewTaskSendCommand()) @@ -165,6 +166,71 @@ func newTaskNewCommand() *cobra.Command { return cmd } +func newTaskOneshotCommand() *cobra.Command { + var ( + images []string + files []string + workspaces []string + address string + settings []string + ) + + cmd := &cobra.Command{ + Use: "oneshot ", + Aliases: []string{"o"}, + Short: "Create a task in yolo+plan mode and view until completion", + Long: `Creates a new task in yolo mode (non-interactive) and plan mode, then streams the conversation until completion.`, + Args: cobra.MinimumNArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + + // Get prompt from args/stdin + prompt, err := getContentFromStdinAndArgs(args) + if err != nil { + return fmt.Errorf("failed to read prompt: %w", err) + } + + if prompt == "" { + return fmt.Errorf("prompt required: provide as argument or pipe via stdin") + } + + // Ensure task manager + if err := ensureTaskManager(ctx, address); err != nil { + return err + } + + // Set mode to plan + if err := taskManager.SetMode(ctx, "plan", nil, nil, nil); err != nil { + return fmt.Errorf("failed to set plan mode: %w", err) + } + fmt.Println("Mode set to: plan") + + // Inject yolo mode into settings + settings = append(settings, "yolo_mode_toggled=true") + + // Create task + taskID, err := taskManager.CreateTask(ctx, prompt, images, files, workspaces, settings) + if err != nil { + return fmt.Errorf("failed to create task: %w", err) + } + + fmt.Printf("Task created in yolo+plan mode (ID: %s)\n", taskID) + fmt.Printf("Using instance: %s\n", taskManager.GetCurrentInstance()) + + // Follow until completion + return taskManager.FollowConversationUntilCompletion(ctx) + }, + } + + cmd.Flags().StringSliceVarP(&images, "image", "i", nil, "attach image files") + cmd.Flags().StringSliceVarP(&files, "file", "f", nil, "attach files") + cmd.Flags().StringSliceVarP(&workspaces, "workdir", "w", nil, "workdir directory paths") + cmd.Flags().StringVar(&address, "address", "", "specific Cline instance address to use") + cmd.Flags().StringSliceVarP(&settings, "setting", "s", nil, "task settings (key=value format, e.g., -s model=claude)") + + return cmd +} + func newTaskCancelCommand() *cobra.Command { var address string