NewAddWizardCommand creates the add-wizard command, which is always interactive.
(validateEngine func(string) error)
| 14 | |
| 15 | // NewAddWizardCommand creates the add-wizard command, which is always interactive. |
| 16 | func NewAddWizardCommand(validateEngine func(string) error) *cobra.Command { |
| 17 | cmd := &cobra.Command{ |
| 18 | Use: "add-wizard <workflow>...", |
| 19 | Short: "Interactively add one or more agentic workflows with guided setup", |
| 20 | Long: `Interactively add one or more agentic workflows with guided setup. |
| 21 | |
| 22 | This command walks you through: |
| 23 | - Selecting an AI engine (Copilot, Claude, Codex, Gemini, or Crush) |
| 24 | - Configuring API keys and secrets |
| 25 | - Creating a pull request with the workflow |
| 26 | - Optionally running the workflow immediately |
| 27 | |
| 28 | Use 'add' for non-interactive workflow addition. |
| 29 | |
| 30 | Workflow specifications: |
| 31 | - Two parts: "owner/repo[@version]" (loads repository-root aw.yml package) |
| 32 | - Three+ parts without .md: "owner/repo/folder[@version]" (loads nested aw.yml package when present) |
| 33 | - Three parts: "owner/repo/workflow-name[@version]" (implicitly looks in workflows/ directory) |
| 34 | - Four+ parts: "owner/repo/workflows/workflow-name.md[@version]" (requires explicit .md extension) |
| 35 | - GitHub URL: "https://github.com/owner/repo/blob/branch/path/to/workflow.md" |
| 36 | - Arbitrary URL: "https://example.com/workflow.md" (fetches and dispatches on Content-Type) |
| 37 | - text/markdown → treated as a gh-aw workflow markdown file |
| 38 | - application/json → converted from a JSON workflow definition |
| 39 | - Local file: "./path/to/workflow.md" |
| 40 | - Version can be tag, branch, or SHA (for remote workflows) |
| 41 | |
| 42 | Note: Requires an interactive terminal. Use 'add' for CI/automation environments. |
| 43 | Note: In GitHub Enterprise repos, shorthand source specs resolve on your enterprise host by default. |
| 44 | For github/*, githubnext/*, and microsoft/* sources, shorthand resolves on github.com. |
| 45 | Use full https://github.com/... source URLs for other public github.com workflows. |
| 46 | Note: To create a new workflow from scratch, use the 'new' command instead.`, |
| 47 | Example: ` ` + string(constants.CLIExtensionPrefix) + ` add-wizard githubnext/agentics # Guided setup for repository-root aw.yml package |
| 48 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard githubnext/agentics/packages/repo-assist # Guided setup for nested aw.yml package |
| 49 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard githubnext/agentics/daily-repo-status # Guided setup |
| 50 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard githubnext/agentics/ci-doctor@v1.0.0 # Guided setup with version |
| 51 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard ./my-workflow.md # Guided setup for local workflow |
| 52 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard https://example.com/my-workflow.md # Guided setup from any HTTPS URL |
| 53 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard https://example.com/workflow.json # Import JSON workflow definition with guided setup |
| 54 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard githubnext/agentics/ci-doctor --engine copilot # Pre-select engine |
| 55 | ` + string(constants.CLIExtensionPrefix) + ` add-wizard githubnext/agentics/ci-doctor --no-secret # Skip secret prompt |
| 56 | `, |
| 57 | Args: func(cmd *cobra.Command, args []string) error { |
| 58 | if len(args) < 1 { |
| 59 | return errors.New("missing workflow specification\n\nRun 'gh aw add-wizard --help' for usage information") |
| 60 | } |
| 61 | return nil |
| 62 | }, |
| 63 | RunE: func(cmd *cobra.Command, args []string) error { |
| 64 | workflows := args |
| 65 | engineOverride, _ := cmd.Flags().GetString("engine") |
| 66 | verbose, _ := cmd.Flags().GetBool("verbose") |
| 67 | noGitattributes, _ := cmd.Flags().GetBool("no-gitattributes") |
| 68 | workflowDir, _ := cmd.Flags().GetString("dir") |
| 69 | noStopAfter, _ := cmd.Flags().GetBool("no-stop-after") |
| 70 | stopAfter, _ := cmd.Flags().GetString("stop-after") |
| 71 | noSecret, _ := cmd.Flags().GetBool("no-secret") |
| 72 | skipSecretLegacy, _ := cmd.Flags().GetBool("skip-secret") |
| 73 | skipSecret := noSecret || skipSecretLegacy |