add oneshot command (#6695)
This commit is contained in:
1 parent
d14d05547d
commit
e80e0ebc40
1 file changed
+66
@@ -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 <prompt>",
|
||||
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
|
||||
|
||||
|
||||
Reference in new issue
Block a user