| 49 | describe: `comma-separated list of tools to enable (default: all). Available: "${AVAILABLE_TOOLS.join(", ")}"`, |
| 50 | }), |
| 51 | async handler(args) { |
| 52 | await Instance.provide({ |
| 53 | directory: process.cwd(), |
| 54 | async fn() { |
| 55 | const cliPath = args.path |
| 56 | const cliDescription = args.description |
| 57 | const cliMode = args.mode as AgentMode | undefined |
| 58 | const cliTools = args.tools |
| 59 | |
| 60 | const isFullyNonInteractive = cliPath && cliDescription && cliMode && cliTools !== undefined |
| 61 | |
| 62 | if (!isFullyNonInteractive) { |
| 63 | UI.empty() |
| 64 | prompts.intro("Create agent") |
| 65 | } |
| 66 | |
| 67 | const project = Instance.project |
| 68 | |
| 69 | // Determine scope/path |
| 70 | let targetPath: string |
| 71 | if (cliPath) { |
| 72 | targetPath = path.join(cliPath, "agent") |
| 73 | } else { |
| 74 | let scope: "global" | "project" = "global" |
| 75 | if (project.vcs === "git") { |
| 76 | const scopeResult = await prompts.select({ |
| 77 | message: "Location", |
| 78 | options: [ |
| 79 | { |
| 80 | label: "Current project", |
| 81 | value: "project" as const, |
| 82 | hint: Instance.worktree, |
| 83 | }, |
| 84 | { |
| 85 | label: "Global", |
| 86 | value: "global" as const, |
| 87 | hint: Global.Path.config, |
| 88 | }, |
| 89 | ], |
| 90 | }) |
| 91 | if (prompts.isCancel(scopeResult)) throw new UI.CancelledError() |
| 92 | scope = scopeResult |
| 93 | } |
| 94 | targetPath = path.join( |
| 95 | scope === "global" ? Global.Path.config : path.join(Instance.worktree, ".arctic"), |
| 96 | "agent", |
| 97 | ) |
| 98 | } |
| 99 | |
| 100 | // Get description |
| 101 | let description: string |
| 102 | if (cliDescription) { |
| 103 | description = cliDescription |
| 104 | } else { |
| 105 | const query = await prompts.text({ |
| 106 | message: "Description", |
| 107 | placeholder: "What should this agent do?", |
| 108 | validate: (x) => (x && x.length > 0 ? undefined : "Required"), |