(deps commandDeps)
| 79 | } |
| 80 | |
| 81 | func newAgentCreateCommand(deps commandDeps) *cobra.Command { |
| 82 | var flags agentCreateFlags |
| 83 | cmd := &cobra.Command{ |
| 84 | Use: "create <name>", |
| 85 | Short: "Create a global or workspace-local AGENT.md definition", |
| 86 | Example: ` # Create a workspace-local agent definition |
| 87 | agh agent create pricing_strategist \ |
| 88 | --workspace ~/dev/ad8 \ |
| 89 | --provider claude \ |
| 90 | --model claude-sonnet-4-6 \ |
| 91 | --prompt "You own pricing strategy." \ |
| 92 | -o json`, |
| 93 | Args: exactOneNonBlankArg(), |
| 94 | RunE: func(cmd *cobra.Command, args []string) error { |
| 95 | workspace, err := commandWorkspaceFlag(cmd) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | flags.workspace = workspace |
| 100 | agent, err := createAgentDefinition(cmd, deps, args[0], flags) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | return writeCommandOutput(cmd, agentBundle(agentRecordFromDefinition(agent))) |
| 105 | }, |
| 106 | } |
| 107 | cmd.Flags().String("workspace", "", "Workspace id, name, or path to create the agent under") |
| 108 | cmd.Flags().StringVar(&flags.provider, cliProviderKey, "", "Provider name for sessions using this agent") |
| 109 | cmd.Flags().StringVar(&flags.command, agentCommandKey, "", "Optional provider command override") |
| 110 | cmd.Flags().StringVar(&flags.model, agentModelKey, "", "Optional provider model") |
| 111 | cmd.Flags().StringVar(&flags.prompt, "prompt", "", "Agent system prompt body") |
| 112 | cmd.Flags().StringVar(&flags.promptFile, "prompt-file", "", "Read the agent system prompt body from a file") |
| 113 | cmd.Flags().StringArrayVar(&flags.tools, "tool", nil, "Allowed tool pattern (repeatable)") |
| 114 | cmd.Flags().StringArrayVar(&flags.toolsets, "toolset", nil, "Allowed toolset reference (repeatable)") |
| 115 | cmd.Flags().StringArrayVar(&flags.denyTools, "deny-tool", nil, "Denied tool pattern (repeatable)") |
| 116 | cmd.Flags().StringVar(&flags.permissions, configPermissionsKey, "", "Optional permission mode") |
| 117 | cmd.Flags().StringArrayVar(&flags.categoryPath, agentCategoryKey, nil, "Agent category path segment (repeatable)") |
| 118 | cmd.Flags().BoolVar(&flags.force, "force", false, "Overwrite an existing AGENT.md definition") |
| 119 | return cmd |
| 120 | } |
| 121 | |
| 122 | func createAgentDefinition( |
| 123 | cmd *cobra.Command, |
no test coverage detected