setup-agent 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A coding agent a person can hand a setup to. `launch` is set when the
3
+ * agent has a terminal command that opens an interactive session with a
4
+ * first prompt; the others are handed the prompt to paste.
5
+ */
6
+ export type CodingAgent = {
7
+ kind: string;
8
+ name: string;
9
+ launch?: {
10
+ /** Command names to try in order; the first one on PATH runs. */
11
+ commands: readonly string[];
12
+ args: (prompt: string) => string[];
13
+ install: string;
14
+ };
15
+ };
16
+ /** The coding agents people use most, in the order the picker lists them. */
17
+ export declare const CODING_AGENTS: readonly CodingAgent[];
18
+ /** The coding agent this process runs under, from the variables each one exports to its shell. */
19
+ export declare const detectAgentKind: (env?: NodeJS.ProcessEnv) => string | undefined;
20
+ /** True when a person typed the command into a terminal rather than an agent running it from its shell. */
21
+ export declare const isDirectInvocation: (env?: NodeJS.ProcessEnv, stdin?: {
22
+ isTTY?: boolean | undefined;
23
+ }, stdout?: {
24
+ isTTY?: boolean | undefined;
25
+ }) => boolean;
26
+ /** The first of `commands` found on PATH, or `undefined`. */
27
+ export declare const findCommand: (commands: readonly string[], env?: NodeJS.ProcessEnv) => string | undefined;
28
+ /**
29
+ * Starts `agent` in this terminal with `prompt` as its first message and
30
+ * resolves with its exit code; `undefined` when its command is not installed.
31
+ */
32
+ export declare const runCodingAgent: (agent: CodingAgent, prompt: string) => Promise<number | undefined>;
33
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QACP,iEAAiE;QACjE,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;QAC5B,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAqG/C,CAAC;AA2CF,kGAAkG;AAClG,eAAO,MAAM,eAAe,GAC1B,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAM,GAAG,SAaX,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,GAC7B,MAAK,MAAM,CAAC,UAAwB,EACpC,QAAO;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAkB,EACtD,SAAQ;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAmB,YAInC,CAAC;AAExB,6DAA6D;AAC7D,eAAO,MAAM,WAAW,GACtB,UAAU,SAAS,MAAM,EAAE,EAC3B,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAM,GAAG,SAoBX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,WAAW,EAClB,QAAQ,MAAM,KACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAgB5B,CAAC"}
package/dist/agents.js ADDED
@@ -0,0 +1,221 @@
1
+ import spawn from "cross-spawn";
2
+ import { accessSync, constants } from "node:fs";
3
+ import { delimiter, join } from "node:path";
4
+ // src/agents.ts
5
+ /** The coding agents people use most, in the order the picker lists them. */
6
+ const CODING_AGENTS = [
7
+ {
8
+ kind: "claude",
9
+ name: "Claude Code",
10
+ launch: {
11
+ commands: ["claude"],
12
+ args: (prompt) => [prompt],
13
+ install: "npm install -g @anthropic-ai/claude-code"
14
+ }
15
+ },
16
+ {
17
+ kind: "codex",
18
+ name: "Codex",
19
+ launch: {
20
+ commands: ["codex"],
21
+ args: (prompt) => [prompt],
22
+ install: "npm install -g @openai/codex"
23
+ }
24
+ },
25
+ {
26
+ kind: "cursor",
27
+ name: "Cursor",
28
+ launch: {
29
+ commands: ["cursor-agent", "agent"],
30
+ args: (prompt) => [prompt],
31
+ install: "curl https://cursor.com/install -fsS | bash"
32
+ }
33
+ },
34
+ {
35
+ kind: "gemini",
36
+ name: "Gemini CLI",
37
+ launch: {
38
+ commands: ["gemini"],
39
+ args: (prompt) => ["-i", prompt],
40
+ install: "npm install -g @google/gemini-cli"
41
+ }
42
+ },
43
+ {
44
+ kind: "copilot",
45
+ name: "Copilot CLI",
46
+ launch: {
47
+ commands: ["copilot"],
48
+ args: (prompt) => ["-i", prompt],
49
+ install: "npm install -g @github/copilot"
50
+ }
51
+ },
52
+ {
53
+ kind: "amp",
54
+ name: "Amp"
55
+ },
56
+ {
57
+ kind: "opencode",
58
+ name: "OpenCode",
59
+ launch: {
60
+ commands: ["opencode"],
61
+ args: (prompt) => ["--prompt", prompt],
62
+ install: "npm install -g opencode-ai"
63
+ }
64
+ },
65
+ {
66
+ kind: "cline",
67
+ name: "Cline"
68
+ },
69
+ {
70
+ kind: "aider",
71
+ name: "Aider"
72
+ },
73
+ {
74
+ kind: "goose",
75
+ name: "Goose"
76
+ },
77
+ {
78
+ kind: "warp",
79
+ name: "Warp"
80
+ },
81
+ {
82
+ kind: "windsurf",
83
+ name: "Windsurf"
84
+ },
85
+ {
86
+ kind: "kiro",
87
+ name: "Kiro",
88
+ launch: {
89
+ commands: ["kiro-cli"],
90
+ args: (prompt) => ["chat", prompt],
91
+ install: "curl -fsSL https://cli.kiro.dev/install | bash"
92
+ }
93
+ },
94
+ {
95
+ kind: "junie",
96
+ name: "Junie"
97
+ },
98
+ {
99
+ kind: "qwen",
100
+ name: "Qwen Code",
101
+ launch: {
102
+ commands: ["qwen"],
103
+ args: (prompt) => ["-i", prompt],
104
+ install: "npm install -g @qwen-code/qwen-code"
105
+ }
106
+ },
107
+ {
108
+ kind: "roo",
109
+ name: "Roo Code"
110
+ },
111
+ {
112
+ kind: "zed",
113
+ name: "Zed"
114
+ },
115
+ {
116
+ kind: "augment",
117
+ name: "Augment",
118
+ launch: {
119
+ commands: ["auggie"],
120
+ args: (prompt) => [prompt],
121
+ install: "npm install -g @augmentcode/auggie"
122
+ }
123
+ },
124
+ {
125
+ kind: "droid",
126
+ name: "Factory Droid",
127
+ launch: {
128
+ commands: ["droid"],
129
+ args: (prompt) => [prompt],
130
+ install: "curl -fsSL https://app.factory.ai/cli | sh"
131
+ }
132
+ },
133
+ {
134
+ kind: "crush",
135
+ name: "Crush"
136
+ }
137
+ ];
138
+ /** The variables each agent exports to the shells it runs commands in. */
139
+ const AGENT_ENV = [
140
+ ["claude", "CLAUDECODE"],
141
+ ["claude", "CLAUDE_CODE"],
142
+ ["codex", "CODEX_SANDBOX"],
143
+ ["codex", "CODEX_SANDBOX_NETWORK_DISABLED"],
144
+ ["codex", "CODEX_CI"],
145
+ ["codex", "CODEX_THREAD_ID"],
146
+ ["cursor", "CURSOR_AGENT"],
147
+ ["gemini", "GEMINI_CLI"],
148
+ ["qwen", "QWEN_CODE"],
149
+ ["copilot", "COPILOT_AGENT"],
150
+ ["copilot", "COPILOT_CLI"],
151
+ ["opencode", "OPENCODE_CLIENT"],
152
+ ["augment", "AUGMENT_AGENT"],
153
+ ["junie", "JUNIE_DATA"]
154
+ ];
155
+ /** `AI_AGENT` values name the agent first, such as `claude-code_2-1-3_agent` or `github-copilot`. */
156
+ const AI_AGENT_PREFIXES = [
157
+ ["claude", "claude"],
158
+ ["codex", "codex"],
159
+ ["cursor", "cursor"],
160
+ ["gemini", "gemini"],
161
+ ["github-copilot", "copilot"],
162
+ ["github_copilot", "copilot"],
163
+ ["copilot", "copilot"],
164
+ ["opencode", "opencode"],
165
+ ["augment", "augment"],
166
+ ["auggie", "augment"],
167
+ ["qwen", "qwen"],
168
+ ["amp", "amp"],
169
+ ["goose", "goose"],
170
+ ["junie", "junie"],
171
+ ["droid", "droid"],
172
+ ["factory", "droid"],
173
+ ["kiro", "kiro"],
174
+ ["cline", "cline"],
175
+ ["crush", "crush"]
176
+ ];
177
+ /** The coding agent this process runs under, from the variables each one exports to its shell. */
178
+ const detectAgentKind = (env = process.env) => {
179
+ const named = env.AI_AGENT?.trim().toLowerCase();
180
+ if (named) return AI_AGENT_PREFIXES.find(([prefix]) => named.startsWith(prefix) && (named.length === prefix.length || /[-_ ./0-9]/.test(named[prefix.length])))?.[1] ?? "other";
181
+ return AGENT_ENV.find(([, variable]) => env[variable])?.[0];
182
+ };
183
+ /** True when a person typed the command into a terminal rather than an agent running it from its shell. */
184
+ const isDirectInvocation = (env = process.env, stdin = process.stdin, stdout = process.stdout) => detectAgentKind(env) === void 0 && stdin.isTTY === true && stdout.isTTY === true;
185
+ /** The first of `commands` found on PATH, or `undefined`. */
186
+ const findCommand = (commands, env = process.env) => {
187
+ const directories = (env.PATH ?? "").split(delimiter).filter(Boolean);
188
+ const extensions = process.platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
189
+ return commands.find((command) => directories.some((directory) => extensions.some((extension) => {
190
+ try {
191
+ accessSync(join(directory, command + extension), constants.X_OK);
192
+ return true;
193
+ } catch {
194
+ return false;
195
+ }
196
+ })));
197
+ };
198
+ /**
199
+ * Starts `agent` in this terminal with `prompt` as its first message and
200
+ * resolves with its exit code; `undefined` when its command is not installed.
201
+ */
202
+ const runCodingAgent = (agent, prompt) => {
203
+ const launch = agent.launch;
204
+ if (!launch) return Promise.resolve(void 0);
205
+ const command = findCommand(launch.commands);
206
+ if (command === void 0) return Promise.resolve(void 0);
207
+ const child = spawn(command, launch.args(prompt), { stdio: "inherit" });
208
+ return new Promise((resolve) => {
209
+ child.on("error", (error) => {
210
+ if (error.code === "ENOENT") resolve(void 0);
211
+ else {
212
+ process.stderr.write(`${error.message}\n`);
213
+ resolve(1);
214
+ }
215
+ });
216
+ child.on("exit", (status) => resolve(status ?? 1));
217
+ });
218
+ };
219
+ export { CODING_AGENTS, detectAgentKind, findCommand, isDirectInvocation, runCodingAgent };
220
+
221
+ //# sourceMappingURL=agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.js","names":[],"sources":["../src/agents.ts"],"sourcesContent":["import spawn from \"cross-spawn\";\nimport { accessSync, constants } from \"node:fs\";\nimport { delimiter, join } from \"node:path\";\n\n/**\n * A coding agent a person can hand a setup to. `launch` is set when the\n * agent has a terminal command that opens an interactive session with a\n * first prompt; the others are handed the prompt to paste.\n */\nexport type CodingAgent = {\n kind: string;\n name: string;\n launch?: {\n /** Command names to try in order; the first one on PATH runs. */\n commands: readonly string[];\n args: (prompt: string) => string[];\n install: string;\n };\n};\n\n/** The coding agents people use most, in the order the picker lists them. */\nexport const CODING_AGENTS: readonly CodingAgent[] = [\n {\n kind: \"claude\",\n name: \"Claude Code\",\n launch: {\n commands: [\"claude\"],\n args: (prompt) => [prompt],\n install: \"npm install -g @anthropic-ai/claude-code\",\n },\n },\n {\n kind: \"codex\",\n name: \"Codex\",\n launch: {\n commands: [\"codex\"],\n args: (prompt) => [prompt],\n install: \"npm install -g @openai/codex\",\n },\n },\n {\n kind: \"cursor\",\n name: \"Cursor\",\n launch: {\n commands: [\"cursor-agent\", \"agent\"],\n args: (prompt) => [prompt],\n install: \"curl https://cursor.com/install -fsS | bash\",\n },\n },\n {\n kind: \"gemini\",\n name: \"Gemini CLI\",\n launch: {\n commands: [\"gemini\"],\n args: (prompt) => [\"-i\", prompt],\n install: \"npm install -g @google/gemini-cli\",\n },\n },\n {\n kind: \"copilot\",\n name: \"Copilot CLI\",\n launch: {\n commands: [\"copilot\"],\n args: (prompt) => [\"-i\", prompt],\n install: \"npm install -g @github/copilot\",\n },\n },\n { kind: \"amp\", name: \"Amp\" },\n {\n kind: \"opencode\",\n name: \"OpenCode\",\n launch: {\n commands: [\"opencode\"],\n args: (prompt) => [\"--prompt\", prompt],\n install: \"npm install -g opencode-ai\",\n },\n },\n { kind: \"cline\", name: \"Cline\" },\n { kind: \"aider\", name: \"Aider\" },\n { kind: \"goose\", name: \"Goose\" },\n { kind: \"warp\", name: \"Warp\" },\n { kind: \"windsurf\", name: \"Windsurf\" },\n {\n kind: \"kiro\",\n name: \"Kiro\",\n launch: {\n commands: [\"kiro-cli\"],\n args: (prompt) => [\"chat\", prompt],\n install: \"curl -fsSL https://cli.kiro.dev/install | bash\",\n },\n },\n { kind: \"junie\", name: \"Junie\" },\n {\n kind: \"qwen\",\n name: \"Qwen Code\",\n launch: {\n commands: [\"qwen\"],\n args: (prompt) => [\"-i\", prompt],\n install: \"npm install -g @qwen-code/qwen-code\",\n },\n },\n { kind: \"roo\", name: \"Roo Code\" },\n { kind: \"zed\", name: \"Zed\" },\n {\n kind: \"augment\",\n name: \"Augment\",\n launch: {\n commands: [\"auggie\"],\n args: (prompt) => [prompt],\n install: \"npm install -g @augmentcode/auggie\",\n },\n },\n {\n kind: \"droid\",\n name: \"Factory Droid\",\n launch: {\n commands: [\"droid\"],\n args: (prompt) => [prompt],\n install: \"curl -fsSL https://app.factory.ai/cli | sh\",\n },\n },\n { kind: \"crush\", name: \"Crush\" },\n];\n\n/** The variables each agent exports to the shells it runs commands in. */\nconst AGENT_ENV: readonly [kind: string, variable: string][] = [\n [\"claude\", \"CLAUDECODE\"],\n [\"claude\", \"CLAUDE_CODE\"],\n [\"codex\", \"CODEX_SANDBOX\"],\n [\"codex\", \"CODEX_SANDBOX_NETWORK_DISABLED\"],\n [\"codex\", \"CODEX_CI\"],\n [\"codex\", \"CODEX_THREAD_ID\"],\n [\"cursor\", \"CURSOR_AGENT\"],\n [\"gemini\", \"GEMINI_CLI\"],\n [\"qwen\", \"QWEN_CODE\"],\n [\"copilot\", \"COPILOT_AGENT\"],\n [\"copilot\", \"COPILOT_CLI\"],\n [\"opencode\", \"OPENCODE_CLIENT\"],\n [\"augment\", \"AUGMENT_AGENT\"],\n [\"junie\", \"JUNIE_DATA\"],\n];\n\n/** `AI_AGENT` values name the agent first, such as `claude-code_2-1-3_agent` or `github-copilot`. */\nconst AI_AGENT_PREFIXES: readonly [prefix: string, kind: string][] = [\n [\"claude\", \"claude\"],\n [\"codex\", \"codex\"],\n [\"cursor\", \"cursor\"],\n [\"gemini\", \"gemini\"],\n [\"github-copilot\", \"copilot\"],\n [\"github_copilot\", \"copilot\"],\n [\"copilot\", \"copilot\"],\n [\"opencode\", \"opencode\"],\n [\"augment\", \"augment\"],\n [\"auggie\", \"augment\"],\n [\"qwen\", \"qwen\"],\n [\"amp\", \"amp\"],\n [\"goose\", \"goose\"],\n [\"junie\", \"junie\"],\n [\"droid\", \"droid\"],\n [\"factory\", \"droid\"],\n [\"kiro\", \"kiro\"],\n [\"cline\", \"cline\"],\n [\"crush\", \"crush\"],\n];\n\n/** The coding agent this process runs under, from the variables each one exports to its shell. */\nexport const detectAgentKind = (\n env: NodeJS.ProcessEnv = process.env,\n): string | undefined => {\n const named = env.AI_AGENT?.trim().toLowerCase();\n if (named) {\n // The name, or the name followed by a separator and a version or role.\n const match = AI_AGENT_PREFIXES.find(\n ([prefix]) =>\n named.startsWith(prefix) &&\n (named.length === prefix.length ||\n /[-_ ./0-9]/.test(named[prefix.length]!)),\n );\n return match?.[1] ?? \"other\";\n }\n return AGENT_ENV.find(([, variable]) => env[variable])?.[0];\n};\n\n/** True when a person typed the command into a terminal rather than an agent running it from its shell. */\nexport const isDirectInvocation = (\n env: NodeJS.ProcessEnv = process.env,\n stdin: { isTTY?: boolean | undefined } = process.stdin,\n stdout: { isTTY?: boolean | undefined } = process.stdout,\n) =>\n detectAgentKind(env) === undefined &&\n stdin.isTTY === true &&\n stdout.isTTY === true;\n\n/** The first of `commands` found on PATH, or `undefined`. */\nexport const findCommand = (\n commands: readonly string[],\n env: NodeJS.ProcessEnv = process.env,\n): string | undefined => {\n // Empty entries (the working directory) are skipped on purpose: a project\n // must not be able to plant its own `claude` next to the user.\n const directories = (env.PATH ?? \"\").split(delimiter).filter(Boolean);\n const extensions =\n process.platform === \"win32\"\n ? (env.PATHEXT ?? \".EXE;.CMD;.BAT\").split(\";\")\n : [\"\"];\n return commands.find((command) =>\n directories.some((directory) =>\n extensions.some((extension) => {\n try {\n accessSync(join(directory, command + extension), constants.X_OK);\n return true;\n } catch {\n return false;\n }\n }),\n ),\n );\n};\n\n/**\n * Starts `agent` in this terminal with `prompt` as its first message and\n * resolves with its exit code; `undefined` when its command is not installed.\n */\nexport const runCodingAgent = (\n agent: CodingAgent,\n prompt: string,\n): Promise<number | undefined> => {\n const launch = agent.launch;\n if (!launch) return Promise.resolve(undefined);\n const command = findCommand(launch.commands);\n if (command === undefined) return Promise.resolve(undefined);\n const child = spawn(command, launch.args(prompt), { stdio: \"inherit\" });\n return new Promise((resolve) => {\n child.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") resolve(undefined);\n else {\n process.stderr.write(`${error.message}\\n`);\n resolve(1);\n }\n });\n child.on(\"exit\", (status) => resolve(status ?? 1));\n });\n};\n"],"mappings":";;;;;AAqBA,MAAa,gBAAwC;CACnD;EACE,MAAM;EACN,MAAM;EACN,QAAQ;GACN,UAAU,CAAC,QAAQ;GACnB,OAAO,WAAW,CAAC,MAAM;GACzB,SAAS;EACX;CACF;CACA;EACE,MAAM;EACN,MAAM;EACN,QAAQ;GACN,UAAU,CAAC,OAAO;GAClB,OAAO,WAAW,CAAC,MAAM;GACzB,SAAS;EACX;CACF;CACA;EACE,MAAM;EACN,MAAM;EACN,QAAQ;GACN,UAAU,CAAC,gBAAgB,OAAO;GAClC,OAAO,WAAW,CAAC,MAAM;GACzB,SAAS;EACX;CACF;CACA;EACE,MAAM;EACN,MAAM;EACN,QAAQ;GACN,UAAU,CAAC,QAAQ;GACnB,OAAO,WAAW,CAAC,MAAM,MAAM;GAC/B,SAAS;EACX;CACF;CACA;EACE,MAAM;EACN,MAAM;EACN,QAAQ;GACN,UAAU,CAAC,SAAS;GACpB,OAAO,WAAW,CAAC,MAAM,MAAM;GAC/B,SAAS;EACX;CACF;CACA;EAAE,MAAM;EAAO,MAAM;CAAM;CAC3B;EACE,MAAM;EACN,MAAM;EACN,QAA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,MAAM,YACpB,YAAY,MAAM,cAChB,WAAW,MAAM,cAAc;EAC7B,IAAI;GACF,WAAW,KAAK,WAAW,UAAU,SAAS,GAAG,UAAU,IAAI;GAC/D,OAAO;EACT,QAAQ;GACN,OAAO;EACT;CACF,CAAC,CACH,CACF;AACF;;;;;AAMA,MAAa,kBACX,OACA,WACgC;CAChC,MAAM,SAAS,MAAM;CACrB,IAAI,CAAC,QAAQ,OAAO,QAAQ,QAAQ,KAAA,CAAS;CAC7C,MAAM,UAAU,YAAY,OAAO,QAAQ;CAC3C,IAAI,YAAY,KAAA,GAAW,OAAO,QAAQ,QAAQ,KAAA,CAAS;CAC3D,MAAM,QAAQ,MAAM,SAAS,OAAO,KAAK,MAAM,GAAG,EAAE,OAAO,UAAU,CAAC;CACtE,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,GAAG,UAAU,UAAiC;GAClD,IAAI,MAAM,SAAS,UAAU,QAAQ,KAAA,CAAS;QACzC;IACH,QAAQ,OAAO,MAAM,GAAG,MAAM,QAAQ,GAAG;IACzC,QAAQ,CAAC;GACX;EACF,CAAC;EACD,MAAM,GAAG,SAAS,WAAW,QAAQ,UAAU,CAAC,CAAC;CACnD,CAAC;AACH"}
package/dist/cli.d.ts CHANGED
@@ -8,20 +8,26 @@ export declare const HELP: string;
8
8
  * no credentials, query or fragment, and hold only address characters.
9
9
  */
10
10
  export declare const parseSetupUrl: (value: string) => string;
11
- export declare const agentInstructions: (setupUrl: string) => string;
12
- export declare const INSTRUCTIONS: (setupUrl: string) => string;
11
+ export type AgentInstructionsOptions = {
12
+ /**
13
+ * The agent started this setup with `assistant-ui setup`, which already
14
+ * began planning and opened the setup page in the user's browser; there is
15
+ * no Begin plan click to wait for.
16
+ */
17
+ startedByAgent?: {
18
+ browserUrl: string;
19
+ /** False when the browser was not opened for the user; the agent then hands them the link. */
20
+ opened?: boolean;
21
+ };
22
+ };
23
+ export declare const agentInstructions: (setupUrl: string, options?: AgentInstructionsOptions) => string;
24
+ export declare const INSTRUCTIONS: (setupUrl: string, options?: AgentInstructionsOptions) => string;
13
25
  type Parsed = {
14
26
  positional: string[];
15
27
  flags: Map<string, string | true>;
16
28
  };
17
- /** The coding agent this process runs under, from the variables each one exports to its shell. */
18
- export declare const detectAgentKind: (env?: NodeJS.ProcessEnv) => string | undefined;
19
- /** True when a person typed the command into a terminal rather than an agent running it from its shell. */
20
- export declare const isDirectInvocation: (env?: NodeJS.ProcessEnv, stdin?: {
21
- isTTY?: boolean | undefined;
22
- }, stdout?: {
23
- isTTY?: boolean | undefined;
24
- }) => boolean;
29
+ export { CODING_AGENTS, detectAgentKind, findCommand, isDirectInvocation, runCodingAgent, } from "./agents.js";
30
+ export type { CodingAgent } from "./agents.js";
25
31
  type StreamEvent = {
26
32
  event: "planning.started";
27
33
  } | {
@@ -73,6 +79,5 @@ export declare const upsertEnvLine: (content: string, key: string, value: string
73
79
  * still deposited; it is read after, so lines written meanwhile survive.
74
80
  */
75
81
  export declare const writeEnvSecret: (file: string, key: string, take: () => Promise<string>, projectRoot?: string) => Promise<void>;
76
- export declare const main: (argv: readonly string[]) => Promise<undefined>;
77
- export {};
82
+ export declare const main: (argv: readonly string[]) => Promise<void>;
78
83
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAiB;AA+B/C,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAmB;AAE3C,eAAO,MAAM,IAAI,QAgChB,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MA6B7C,CAAC;AAQF,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,WA6CjD,CAAC;AAEF,eAAO,MAAM,YAAY,aA/CmB,MAAM,WA+CL,CAAC;AAE9C,KAAK,MAAM,GAAG;IAAE,UA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UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAKnD,eAAO,MAAM,UAAU,GACrB,QAAQ,QAAQ,CAAC,KAAK,EACtB,OAAO,QAAQ,CAAC,KAAK,KACpB,WAAW,EAqEb,CAAC;AA4CF,2LAA2L;AAC3L,eAAO,MAAM,YAAY,GACvB,QAAQ,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,WAAW,CAAC,6BAiBjD,CAAC;AAwDL,eAAO,MAAM,OAAO,GAClB,MAAM,SAAS,MAAM,EAAE,EACvB,OAAO,MAAM,CAAC,OAAO,CAAC,KACrB,QAAQ,CAAC,SAAS,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CA+HxC,CAAC;AAQF,+EAA+E;AAC/E,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,OAAO,MAAM,WAqBxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,MAAM,MAAM,OAAO,CAAC,MAAM,CAAC,EAC3B,oBAA2B,kBAsD5B,CAAC;AAyHF,eAAO,MAAM,IAAI,GAAU,MAAM,SAAS,MAAM,EAAE,kBAoQjD,CAAC"}
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
+ import { CODING_AGENTS, detectAgentKind, findCommand, isDirectInvocation, runCodingAgent } from "./agents.js";
1
2
  import { connectCheckout } from "./client.js";
2
3
  import { INPUT_PRESETS, isPresetId, presetInput } from "./presets.js";
3
4
  import { AGENT_HEARTBEAT_MS, OPTION_ICONS, classifyChoiceAnswer, currentPlan, isAgentPresent, isClosed, isLoopbackHostname, isOptionIcon, isValidModelAnswer, parseEntryPointOptions, parseMultipleAnswer, stepProgress } from "./protocol.js";
4
- import { spawn } from "node:child_process";
5
- import { createHash, randomBytes } from "node:crypto";
6
5
  import { constants } from "node:fs";
6
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
+ import { createHash, randomBytes } from "node:crypto";
7
8
  import { chmod, lstat, mkdir, open, readFile, realpath, unlink } from "node:fs/promises";
8
9
  import { homedir, tmpdir, userInfo } from "node:os";
9
10
  import { createInterface } from "node:readline/promises";
10
- import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
11
11
  // src/cli.ts
12
12
  const HELP = `setup-agent <url> [command]
13
13
 
@@ -66,9 +66,14 @@ const parseSetupUrl = (value) => {
66
66
  };
67
67
  /** `value` as one shell word, quoted only when it holds more than plain URL characters. */
68
68
  const shellWord = (value) => /^[A-Za-z0-9._~%/:@=+,-]+$/.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
69
- const agentInstructions = (setupUrl) => {
69
+ const beginPlanHandoff = (url) => `Before planning, check the current setup status. If it is "waiting", tell the user in your own conversation: "I'm connected. Go back to your browser and click Begin plan. You can watch my progress, answer questions, and steer me there." Then run:
70
+ npx setup-agent ${url} wait start
71
+ Keep the stream running while you wait. Do not inspect the project, fetch guides, ask setup questions, or propose a plan until this command returns {"ok":true}. If it returns {"ok":false,"status":"cancelled"}, the user ended this setup before planning: do not plan, tell the user you are connected and waiting for their next setup, and run "wait start" again. Only the user in the browser should start planning; never invoke the browser's start command yourself. "planning.started" also arrives on the stream. If the status is already "planning" or "installing", resume that phase without asking the user to begin again. If it is "done" or "cancelled", that setup is over: tell the user you are connected and waiting for their next setup, and run "wait start", which returns once the next one begins.`;
72
+ const agentStartedHandoff = ({ browserUrl, opened = true }) => `You started this setup, and it is already planning: there is no Begin plan click to wait for. The browser asks the user to connect to you first; it shows your working directory once your stream is running. Check "status" before planning: if it is "planning" or "installing", go on with that phase. Tell the user in your own conversation, once: ${opened ? `"I opened the assistant-ui setup in your browser. I'll ask my questions there, and you can watch my progress and steer me from that page. If it didn't open, go to ${browserUrl} ."` : `"Open ${browserUrl} to follow the assistant-ui setup. I'll ask my questions there, and you can watch my progress and steer me from that page."`} If the status is "done" or "cancelled", that setup is over: tell the user you are connected and waiting for their next setup, and run "wait start", which returns once the next one begins.`;
73
+ const agentInstructions = (setupUrl, options = {}) => {
70
74
  const url = shellWord(setupUrl);
71
- return `You are the coding agent for a setup the user opened in their browser. The browser shows this setup live; every command below updates it. The user watches the browser, not this terminal: once setup begins, send questions through "ask" so the user can answer in their browser.
75
+ const started = options.startedByAgent;
76
+ return `You are the coding agent for a setup ${started ? "you opened in the user's browser" : "the user opened in their browser"}. The browser shows this setup live; every command below updates it. The user watches the browser, not this terminal: once setup begins, send questions through "ask" so the user can answer in their browser.
72
77
 
73
78
  First, start a persistent Monitor on
74
79
  npx setup-agent ${url} stream
@@ -78,9 +83,7 @@ The user can message you at any time, including while a question is waiting. Rea
78
83
 
79
84
  "log" is a message to the user, and the user reads every one: send it only to reply to their message, to tell them something no question or step conveys (a blocker, a deviation from the plan, a decision you made for them), or once as a wrap-up when the install is finished. Findings go in the plan, progress in step notes, questions in "ask"; do not narrate.
80
85
 
81
- Before planning, check the current setup status. If it is "waiting", tell the user in your own conversation: "I'm connected. Go back to your browser and click Begin plan. You can watch my progress, answer questions, and steer me there." Then run:
82
- npx setup-agent ${url} wait start
83
- Keep the stream running while you wait. Do not inspect the project, fetch guides, ask setup questions, or propose a plan until this command returns {"ok":true}. Only the user in the browser should start planning; never invoke the browser's start command yourself. "planning.started" also arrives on the stream. If the status is already "planning" or "installing", resume that phase without asking the user to begin again. If it is "done" or "cancelled", that setup is over: tell the user you are connected and waiting for their next setup, and run "wait start", which returns once the next one begins.
86
+ ${started ? agentStartedHandoff(started) : beginPlanHandoff(url)}
84
87
 
85
88
  The remaining phases are plan, then install.
86
89
 
@@ -89,7 +92,7 @@ The remaining phases are plan, then install.
89
92
  Read the project: its app framework and package manager, the agent framework and model provider it already uses, where components live, any existing chat route. Fetch each product's "guide" URL from the setup below; it is the install reference. Ask for what the project does not decide, using the standard questions so the browser can render them well:
90
93
  npx setup-agent ${url} ask --preset framework
91
94
  npx setup-agent ${url} ask --preset llm-provider
92
- The setup's products are starting names and guide references. Explore each product's setup instructions, then discover and plan any other relevant products or dependencies the app needs. Read /catalog.md on the guide URL’s origin to find related products and fetch their setup guides. The starting list does not restrict the implementation or require adding another product to the list. Include relevant additions in the plan for approval.
95
+ The setup's products are starting names and guide references. If the setup lists no products, first ask the user what to set up with a choice question whose options are slugs from https://www.assistant-ui.com/catalog.md, then fetch https://www.assistant-ui.com/install.md?items=<slugs> as the guide. Explore each product's setup instructions, then discover and plan any other relevant products or dependencies the app needs. Read /catalog.md on the guide URL’s origin to find related products and fetch their setup guides. The starting list does not restrict the implementation or require adding another product to the list. Include relevant additions in the plan for approval.
93
96
  When the setup puts an assistant in the app, ask how users should access it after discovering the actual app and before proposing the plan. Skip this question when no product's guide installs an assistant (a standalone library or service setup, for example). Use an entry-point question with only 1–3 sensible alternatives. Describe the actual app's pages, workflow and component placement, not generic placeholder copy. Recommend one clear fit when there is one; two options may use the same form factor in different places. Each option needs a stable id, label, contextual description and entryPoint {"formFactor":"modal"|"sidebar"|"full-page","placement":"where it appears","trigger":"how users open it or navigate to it","recommended":true?}. Write the JSON array for this app and send it with:
94
97
  npx setup-agent ${url} ask "Where should users access the assistant?" --entry-points '<JSON array>' --wait
95
98
  Mark a clear fit with "recommended":true rather than --default, so the user makes the pick. When you ask it, do not submit the plan before the user picks an entry point. Respect the selected placement and trigger in the plan and implementation. Do not ask for a new-versus-existing app setting; discover the app from its files and ask only for an install path when needed.
@@ -145,47 +148,8 @@ const fail = (message) => {
145
148
  const print = (value) => {
146
149
  process.stdout.write(`${JSON.stringify(value)}\n`);
147
150
  };
148
- const AGENT_ENV = [
149
- ["claude", "CLAUDECODE"],
150
- ["codex", "CODEX_SANDBOX"],
151
- ["codex", "CODEX_SANDBOX_NETWORK_DISABLED"],
152
- ["cursor", "CURSOR_AGENT"],
153
- ["gemini", "GEMINI_CLI"]
154
- ];
155
- /** The coding agent this process runs under, from the variables each one exports to its shell. */
156
- const detectAgentKind = (env = process.env) => AGENT_ENV.find(([, variable]) => env[variable])?.[0];
157
- const LAUNCHERS = [
158
- {
159
- kind: "claude",
160
- name: "Claude Code",
161
- command: "claude",
162
- args: (prompt) => [prompt],
163
- install: "npm install -g @anthropic-ai/claude-code"
164
- },
165
- {
166
- kind: "codex",
167
- name: "Codex",
168
- command: "codex",
169
- args: (prompt) => [prompt],
170
- install: "npm install -g @openai/codex"
171
- },
172
- {
173
- kind: "cursor",
174
- name: "Cursor",
175
- command: "agent",
176
- args: (prompt) => [prompt],
177
- install: "curl https://cursor.com/install -fsS | bash"
178
- },
179
- {
180
- kind: "gemini",
181
- name: "Gemini CLI",
182
- command: "gemini",
183
- args: (prompt) => ["-i", prompt],
184
- install: "npm install -g @google/gemini-cli"
185
- }
186
- ];
187
- /** True when a person typed the command into a terminal rather than an agent running it from its shell. */
188
- const isDirectInvocation = (env = process.env, stdin = process.stdin, stdout = process.stdout) => detectAgentKind(env) === void 0 && stdin.isTTY === true && stdout.isTTY === true;
151
+ /** The agents `setup-agent <url>` can start itself, for a person who ran it in a terminal. */
152
+ const LAUNCHERS = CODING_AGENTS.filter((agent) => agent.launch !== void 0);
189
153
  const chooseLauncher = async () => {
190
154
  const rl = createInterface({
191
155
  input: process.stdin,
@@ -213,16 +177,9 @@ const launchAgent = async (url) => {
213
177
  const launcher = await chooseLauncher();
214
178
  const prompt = `Run \`npx setup-agent ${shellWord(url)}\` and follow the instructions it prints.`;
215
179
  process.stdout.write(`\nStarting ${launcher.name}...\n\n`);
216
- const child = spawn(launcher.command, launcher.args(prompt), { stdio: "inherit" });
217
- const code = await new Promise((resolve) => {
218
- child.on("error", (error) => {
219
- if (error.code === "ENOENT") process.stderr.write(`${launcher.name} is not installed. Install it with:\n ${launcher.install}\nthen run this command again.\n`);
220
- else process.stderr.write(`${error.message}\n`);
221
- resolve(1);
222
- });
223
- child.on("exit", (status) => resolve(status ?? 1));
224
- });
225
- process.exit(code);
180
+ const code = await runCodingAgent(launcher, prompt);
181
+ if (code === void 0) process.stderr.write(`${launcher.name} is not installed. Install it with:\n ${launcher.launch.install}\nthen run this command again.\n`);
182
+ process.exitCode = code ?? 1;
226
183
  };
227
184
  const requireState = (client) => client.state ?? fail("the setup has no state");
228
185
  const summary = (state) => {
@@ -828,6 +785,6 @@ const main = async (argv) => {
828
785
  client.dispose();
829
786
  }
830
787
  };
831
- export { HELP, INSTRUCTIONS, agentInstructions, askSeed, detectAgentKind, diffEvents, isDirectInvocation, main, parseSetupUrl, upsertEnvLine, waitForStart, writeEnvSecret };
788
+ export { CODING_AGENTS, HELP, INSTRUCTIONS, agentInstructions, askSeed, detectAgentKind, diffEvents, findCommand, isDirectInvocation, main, parseSetupUrl, runCodingAgent, upsertEnvLine, waitForStart, writeEnvSecret };
832
789
 
833
790
  //# sourceMappingURL=cli.js.map