MCPcopy Create free account
hub / github.com/arctic-cli/interface / fn

Function fn

packages/arctic/src/cli/cmd/agent.ts:54–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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"),
109 })
110 if (prompts.isCancel(query)) throw new UI.CancelledError()
111 description = query

Callers

nothing calls this directly

Calls 6

stopMethod · 0.80
textMethod · 0.65
startMethod · 0.45
existsMethod · 0.45
logMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected