MCPcopy Create free account
hub / github.com/compozy/agh / newSessionPromptCommand

Function newSessionPromptCommand

internal/cli/session.go:482–557  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

480}
481
482func newSessionPromptCommand(deps commandDeps) *cobra.Command {
483 var (
484 queue bool
485 interrupt bool
486 steer bool
487 cancelEntry string
488 )
489
490 cmd := &cobra.Command{
491 Use: "prompt <id> <message>",
492 Short: "Send a prompt to a session",
493 Example: ` # Send a follow-up prompt to an active session
494 agh session prompt sess_1234 "Summarize the current changes."
495
496 # Queue input while the session is busy
497 agh session prompt sess_1234 "Run the next check." --queue
498
499 # Steer the current turn after the next tool result
500 agh session prompt sess_1234 "Prefer the smaller patch." --steer
501
502 # Cancel queued input by entry id
503 agh session prompt sess_1234 --cancel queue_entry_1234`,
504 Args: func(cmd *cobra.Command, args []string) error {
505 cancelChanged := cmd.Flags().Changed("cancel")
506 modeCount := 0
507 for _, enabled := range []bool{queue, interrupt, steer, cancelChanged} {
508 if enabled {
509 modeCount++
510 }
511 }
512 if modeCount > 1 {
513 return errors.New("cli: choose only one of --queue, --interrupt, --steer, or --cancel")
514 }
515 if cancelChanged {
516 if strings.TrimSpace(cancelEntry) == "" {
517 return errors.New("cli: --cancel requires a queue entry id")
518 }
519 if len(args) != 1 {
520 return fmt.Errorf("cli: session prompt --cancel accepts 1 arg, received %d", len(args))
521 }
522 return nil
523 }
524 if len(args) != 2 {
525 return fmt.Errorf("cli: session prompt accepts 2 args, received %d", len(args))
526 }
527 return nil
528 },
529 RunE: func(cmd *cobra.Command, args []string) error {
530 mode, err := resolveOutputFormat(cmd)
531 if err != nil {
532 return err
533 }
534 client, err := clientFromDeps(deps)
535 if err != nil {
536 return err
537 }
538 if mode == OutputJSONL {
539 if queue || interrupt || steer || cmd.Flags().Changed("cancel") {

Callers 1

newSessionCommandFunction · 0.85

Calls 6

resolveOutputFormatFunction · 0.85
clientFromDepsFunction · 0.85
streamPromptEventsJSONLFunction · 0.85
runSessionPromptActionFunction · 0.85
writeCommandOutputFunction · 0.85
sessionPromptBundleFunction · 0.85

Tested by

no test coverage detected