@ai-code-agents/cli 0.1.0-beta.1 → 0.1.0

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.
package/dist/cli.js CHANGED
@@ -2,198 +2,185 @@
2
2
 
3
3
  // src/cli.ts
4
4
  import { program } from "@commander-js/extra-typings";
5
+ import { withOptions, withErrorHandling } from "@felixarntz/cli-utils";
5
6
  import dotenv from "dotenv";
6
7
 
7
- // src/util/logger.ts
8
- import { styleText } from "util";
9
- var createStyledText = (style) => (text) => styleText(style, text);
10
- var formatBold = createStyledText("bold");
11
- var colorError = createStyledText("red");
12
- var colorWarning = createStyledText("yellowBright");
13
- var colorSuccess = createStyledText("green");
14
- var colorDebug = createStyledText("cyan");
15
- var formatLogMessage = (text, level) => {
16
- switch (level) {
17
- case 0 /* DEBUG */:
18
- return colorDebug(text);
19
- case 2 /* SUCCESS */:
20
- return formatBold(colorSuccess(`\u2705 ${text}`));
21
- case 3 /* WARN */:
22
- return formatBold(colorWarning(`\u26A0\uFE0F ${text}`));
23
- case 4 /* ERROR */:
24
- return formatBold(colorError(`\u274C ${text}`));
25
- default:
26
- return text;
27
- }
28
- };
29
- var DEFAULT_LOG_LEVEL = 1 /* INFO */;
30
- var CURRENT_LOG_LEVEL = process.env["NODE_ENV"] === "development" || process.env["DEBUG"] === "true" ? 0 /* DEBUG */ : process.env["SILENT"] === "true" ? 5 /* SILENT */ : DEFAULT_LOG_LEVEL;
31
- var Logger = class {
32
- /**
33
- * Logs a debug message.
34
- *
35
- * @param text - The message to log.
36
- */
37
- debug(text) {
38
- this.log(text, 0 /* DEBUG */);
39
- }
40
- /**
41
- * Logs an info message.
42
- *
43
- * @param text - The message to log.
44
- */
45
- info(text) {
46
- this.log(text, 1 /* INFO */);
47
- }
48
- /**
49
- * Logs a success message.
50
- *
51
- * @param text - The message to log.
52
- */
53
- success(text) {
54
- this.log(text, 2 /* SUCCESS */);
55
- }
56
- /**
57
- * Logs a warning message.
58
- *
59
- * @param text - The message to log.
60
- */
61
- warn(text) {
62
- this.log(text, 3 /* WARN */);
63
- }
64
- /**
65
- * Logs an error message.
66
- *
67
- * @param text - The message to log.
68
- */
69
- error(text) {
70
- this.log(text, 4 /* ERROR */);
71
- }
72
- /**
73
- * Logs a message with a log level.
74
- *
75
- * @param text - The message to log.
76
- * @param level - The log level. Defaults to LogLevel.INFO.
77
- */
78
- log(text, level = 1 /* INFO */) {
79
- if (level < CURRENT_LOG_LEVEL) {
80
- return;
8
+ // src/commands/docker-code-agent.ts
9
+ import {
10
+ createEnvironment,
11
+ EnvironmentToolSafetyLevels
12
+ } from "ai-code-agents";
13
+ import {
14
+ getOpt,
15
+ parseFileOptions,
16
+ injectFileOptionsForCommander,
17
+ promptMissingOptions,
18
+ stripOptionFieldsForCommander,
19
+ normalizeAbsolutePath
20
+ } from "@felixarntz/cli-utils";
21
+
22
+ // src/util/create-and-run-code-agent.ts
23
+ import {
24
+ createCodeAgent
25
+ } from "ai-code-agents";
26
+ import { output, logger } from "@felixarntz/cli-utils";
27
+ var createAndRunCodeAgent = async (options6) => {
28
+ const {
29
+ environment,
30
+ environmentToolsDefinition,
31
+ model,
32
+ prompt,
33
+ system,
34
+ maxSteps = 10,
35
+ directory
36
+ } = options6;
37
+ const modelSuffix = model ? ` (using model ${model})` : "";
38
+ logger.debug(
39
+ `Running task prompt in ${environment.name} about code in ${directory}${modelSuffix}...`
40
+ );
41
+ const agent = createCodeAgent({
42
+ model,
43
+ environment,
44
+ environmentToolsDefinition,
45
+ maxSteps,
46
+ instructions: system,
47
+ logStep: (log) => {
48
+ logger.debug("\n" + log);
81
49
  }
82
- process.stderr.write(`${formatLogMessage(text, level)}
83
- `);
84
- }
50
+ });
51
+ const result = await agent.generate({ prompt });
52
+ const { text } = result;
53
+ output(text);
85
54
  };
86
- var logger = new Logger();
87
55
 
88
- // src/util/commander.ts
89
- var getArgs = (handlerArgs) => {
90
- if (handlerArgs.length <= 2) {
91
- return [];
56
+ // src/commands/docker-code-agent.ts
57
+ var name = "docker-code-agent";
58
+ var description = "Runs a code agent in a Docker container to perform a specified task.";
59
+ var actualOptions = [
60
+ {
61
+ argname: "-p, --prompt <prompt>",
62
+ description: "Task prompt for the agent",
63
+ required: true
64
+ },
65
+ {
66
+ argname: "-m, --model <model>",
67
+ description: "Model to use for the agent",
68
+ required: true
69
+ },
70
+ {
71
+ argname: "-d, --directory <directory>",
72
+ description: "Directory with the project to work on",
73
+ parse: (value) => normalizeAbsolutePath(value),
74
+ required: true
75
+ },
76
+ {
77
+ argname: "-t, --tools <tools>",
78
+ description: "Tools to allow the agent to use in the environment",
79
+ choices: EnvironmentToolSafetyLevels,
80
+ defaults: "readonly"
81
+ },
82
+ {
83
+ argname: "-i, --container-id <container-id>",
84
+ description: "ID of the Docker container",
85
+ required: true
86
+ },
87
+ {
88
+ argname: "-s, --system <system>",
89
+ description: "System instruction to guide the agent"
92
90
  }
93
- return handlerArgs.slice(0, -2).map(String);
94
- };
95
- var getOpt = (handlerArgs) => {
96
- if (handlerArgs.length <= 1) {
97
- return {};
91
+ ];
92
+ var options = injectFileOptionsForCommander(actualOptions, [
93
+ "prompt",
94
+ "system"
95
+ ]).map((option) => stripOptionFieldsForCommander(option));
96
+ var parseOptions = (opt) => {
97
+ const config = {
98
+ prompt: String(opt["prompt"]),
99
+ model: opt["model"] ? String(opt["model"]) : "",
100
+ containerId: String(opt["container-id"]),
101
+ directory: opt["directory"] ? String(opt["directory"]) : "",
102
+ tools: opt["tools"] ? opt["tools"] : "readonly"
103
+ };
104
+ if (opt["system"]) {
105
+ config.system = String(opt["system"]);
98
106
  }
99
- return handlerArgs[handlerArgs.length - 2];
107
+ return config;
100
108
  };
101
- var withOptions = (command, options2) => {
102
- options2.forEach(
103
- ({
104
- description: description2,
105
- argname,
106
- positional,
107
- required,
108
- defaults,
109
- choices,
110
- parse,
111
- variadic
112
- }) => {
113
- if (positional) {
114
- const variadicSuffix = variadic ? "..." : "";
115
- const argument = command.createArgument(
116
- required ? `<${argname}${variadicSuffix}>` : `[${argname}${variadicSuffix}]`,
117
- description2
118
- );
119
- if (defaults) {
120
- argument.default(defaults);
121
- }
122
- if (typeof parse === "function") {
123
- argument.argParser(parse);
124
- }
125
- if (choices) {
126
- argument.choices(choices);
127
- }
128
- command.addArgument(argument);
129
- return;
130
- }
131
- const option = command.createOption(argname, description2);
132
- if (required) {
133
- option.makeOptionMandatory(true);
134
- }
135
- if (defaults) {
136
- option.default(defaults);
137
- }
138
- if (typeof parse === "function") {
139
- option.argParser(parse);
140
- }
141
- if (choices) {
142
- option.choices(choices);
143
- }
144
- command.addOption(option);
145
- }
109
+ var handler = async (...handlerArgs) => {
110
+ const { prompt, model, directory, tools, containerId, system } = parseOptions(
111
+ await promptMissingOptions(
112
+ actualOptions,
113
+ await parseFileOptions(getOpt(handlerArgs), ["prompt", "system"])
114
+ )
146
115
  );
147
- return command;
148
- };
149
- var withErrorHandling = (handler2) => async (...handlerArgs) => {
150
- try {
151
- const result = handler2(...handlerArgs);
152
- if (result instanceof Promise) {
153
- await result;
154
- }
155
- } catch (error) {
156
- if (error instanceof Error) {
157
- logger.error(error.message);
158
- }
159
- process.exitCode = 1;
160
- }
116
+ await createAndRunCodeAgent({
117
+ environment: createEnvironment("docker", {
118
+ directoryPath: directory,
119
+ containerId
120
+ }),
121
+ environmentToolsDefinition: tools,
122
+ model,
123
+ prompt,
124
+ system,
125
+ directory
126
+ });
161
127
  };
162
128
 
163
- // src/commands/code-agent.ts
129
+ // src/commands/just-bash-code-agent.ts
164
130
  import {
165
- createCodeAgent,
166
- createEnvironment,
167
- EnvironmentNames,
168
- EnvironmentToolSafetyLevels
131
+ EnvironmentToolSafetyLevels as EnvironmentToolSafetyLevels2
169
132
  } from "ai-code-agents";
133
+ import { JustBashEnvironment } from "@ai-code-agents/just-bash";
134
+ import {
135
+ getOpt as getOpt2,
136
+ parseFileOptions as parseFileOptions2,
137
+ injectFileOptionsForCommander as injectFileOptionsForCommander2,
138
+ promptMissingOptions as promptMissingOptions2,
139
+ stripOptionFieldsForCommander as stripOptionFieldsForCommander2,
140
+ logger as logger2,
141
+ normalizeAbsolutePath as normalizeAbsolutePath2
142
+ } from "@felixarntz/cli-utils";
170
143
 
171
- // src/util/paths.ts
144
+ // src/util/read-local-directory-files.ts
172
145
  import path from "path";
173
- function normalizeAbsolutePath(filePath, rootDir = void 0) {
174
- if (!rootDir) {
175
- rootDir = process.cwd();
146
+ import {
147
+ UnsafeLocalEnvironment,
148
+ GetProjectFileStructureTool,
149
+ ReadManyFilesTool
150
+ } from "ai-code-agents";
151
+ var readLocalDirectoryFiles = async (directoryPath) => {
152
+ const env = new UnsafeLocalEnvironment({ directoryPath });
153
+ const getProjectFileStructureTool = new GetProjectFileStructureTool(env);
154
+ const readManyFilesTool = new ReadManyFilesTool(env);
155
+ const { files } = await getProjectFileStructureTool.execute(
156
+ { excludeGitIgnored: true },
157
+ {}
158
+ );
159
+ if (files.length === 0) {
160
+ return {};
176
161
  }
177
- if (path.isAbsolute(filePath)) {
178
- return filePath;
162
+ const readResult = await readManyFilesTool.execute(
163
+ { paths: files },
164
+ {}
165
+ );
166
+ const result = {};
167
+ for (const [, fileResult] of Object.entries(readResult)) {
168
+ const relativePath = path.relative(
169
+ directoryPath,
170
+ path.resolve(directoryPath, fileResult.path)
171
+ );
172
+ result[relativePath] = fileResult.content;
179
173
  }
180
- return path.join(rootDir, filePath);
181
- }
182
-
183
- // src/util/output.ts
184
- function output(text) {
185
- process.stdout.write(`${text}
186
- `);
187
- }
174
+ return result;
175
+ };
188
176
 
189
- // src/commands/code-agent.ts
190
- var name = "code-agent";
191
- var description = "Runs a code agent to perform a specified task.";
192
- var options = [
177
+ // src/commands/just-bash-code-agent.ts
178
+ var name2 = "just-bash-code-agent";
179
+ var description2 = "Runs a code agent using a simulated bash environment to perform a specified task.";
180
+ var actualOptions2 = [
193
181
  {
194
- argname: "task",
195
- description: "Task for the agent",
196
- positional: true,
182
+ argname: "-p, --prompt <prompt>",
183
+ description: "Task prompt for the agent",
197
184
  required: true
198
185
  },
199
186
  {
@@ -202,90 +189,327 @@ var options = [
202
189
  required: true
203
190
  },
204
191
  {
205
- argname: "-e, --environment <environment>",
206
- description: "Environment type to use",
207
- choices: EnvironmentNames,
192
+ argname: "-d, --directory <directory>",
193
+ description: "Working directory in the simulated bash environment",
194
+ parse: (value) => normalizeAbsolutePath2(value)
195
+ },
196
+ {
197
+ argname: "-t, --tools <tools>",
198
+ description: "Tools to allow the agent to use in the environment",
199
+ choices: EnvironmentToolSafetyLevels2,
200
+ defaults: "readonly"
201
+ },
202
+ {
203
+ argname: "-l, --local-directory <local-directory>",
204
+ description: "Local directory to mount into the simulated environment (reads all files excluding gitignored)",
205
+ parse: (value) => normalizeAbsolutePath2(value)
206
+ },
207
+ {
208
+ argname: "-s, --system <system>",
209
+ description: "System instruction to guide the agent"
210
+ }
211
+ ];
212
+ var options2 = injectFileOptionsForCommander2(actualOptions2, [
213
+ "prompt",
214
+ "system"
215
+ ]).map((option) => stripOptionFieldsForCommander2(option));
216
+ var parseOptions2 = (opt) => {
217
+ const config = {
218
+ prompt: String(opt["prompt"]),
219
+ model: opt["model"] ? String(opt["model"]) : "",
220
+ tools: opt["tools"] ? opt["tools"] : "readonly"
221
+ };
222
+ if (opt["directory"]) {
223
+ config.directory = String(opt["directory"]);
224
+ }
225
+ if (opt["local-directory"]) {
226
+ config.localDirectory = String(opt["local-directory"]);
227
+ }
228
+ if (opt["system"]) {
229
+ config.system = String(opt["system"]);
230
+ }
231
+ return config;
232
+ };
233
+ var handler2 = async (...handlerArgs) => {
234
+ const { prompt, model, directory, tools, localDirectory, system } = parseOptions2(
235
+ await promptMissingOptions2(
236
+ actualOptions2,
237
+ await parseFileOptions2(getOpt2(handlerArgs), ["prompt", "system"])
238
+ )
239
+ );
240
+ let files = void 0;
241
+ if (localDirectory) {
242
+ logger2.debug(`Reading files from local directory at ${localDirectory}...`);
243
+ files = await readLocalDirectoryFiles(localDirectory);
244
+ logger2.debug(
245
+ `Mounting ${Object.keys(files).length} files into the simulated bash environment...`
246
+ );
247
+ }
248
+ await createAndRunCodeAgent({
249
+ environment: JustBashEnvironment.create({
250
+ directoryPath: directory,
251
+ bashOptions: files ? { files } : void 0
252
+ }),
253
+ environmentToolsDefinition: tools,
254
+ model,
255
+ prompt,
256
+ system,
257
+ directory: directory || "/home/user"
258
+ // Default 'just-bash' working directory.
259
+ });
260
+ };
261
+
262
+ // src/commands/mock-filesystem-code-agent.ts
263
+ import {
264
+ createEnvironment as createEnvironment2,
265
+ EnvironmentToolSafetyLevels as EnvironmentToolSafetyLevels3
266
+ } from "ai-code-agents";
267
+ import {
268
+ getOpt as getOpt3,
269
+ parseFileOptions as parseFileOptions3,
270
+ injectFileOptionsForCommander as injectFileOptionsForCommander3,
271
+ promptMissingOptions as promptMissingOptions3,
272
+ stripOptionFieldsForCommander as stripOptionFieldsForCommander3,
273
+ normalizeAbsolutePath as normalizeAbsolutePath3
274
+ } from "@felixarntz/cli-utils";
275
+ var name3 = "mock-filesystem-code-agent";
276
+ var description3 = "Runs a code agent on a mock filesystem to perform a specified task.";
277
+ var actualOptions3 = [
278
+ {
279
+ argname: "-p, --prompt <prompt>",
280
+ description: "Task prompt for the agent",
281
+ required: true
282
+ },
283
+ {
284
+ argname: "-m, --model <model>",
285
+ description: "Model to use for the agent",
208
286
  required: true
209
287
  },
210
288
  {
211
289
  argname: "-d, --directory <directory>",
212
290
  description: "Directory with the project to work on",
213
- parse: (value) => normalizeAbsolutePath(value),
291
+ parse: (value) => normalizeAbsolutePath3(value),
214
292
  required: true
215
293
  },
216
294
  {
217
295
  argname: "-t, --tools <tools>",
218
- description: "ID of the environment, if relevant (e.g. Docker container ID)",
219
- choices: EnvironmentToolSafetyLevels,
220
- default: "readonly"
296
+ description: "Tools to allow the agent to use in the environment",
297
+ choices: EnvironmentToolSafetyLevels3,
298
+ defaults: "readonly"
299
+ },
300
+ {
301
+ argname: "-s, --system <system>",
302
+ description: "System instruction to guide the agent"
303
+ }
304
+ ];
305
+ var options3 = injectFileOptionsForCommander3(actualOptions3, [
306
+ "prompt",
307
+ "system"
308
+ ]).map((option) => stripOptionFieldsForCommander3(option));
309
+ var parseOptions3 = (opt) => {
310
+ const config = {
311
+ prompt: String(opt["prompt"]),
312
+ model: opt["model"] ? String(opt["model"]) : "",
313
+ directory: opt["directory"] ? String(opt["directory"]) : "",
314
+ tools: opt["tools"] ? opt["tools"] : "readonly"
315
+ };
316
+ if (opt["system"]) {
317
+ config.system = String(opt["system"]);
318
+ }
319
+ return config;
320
+ };
321
+ var handler3 = async (...handlerArgs) => {
322
+ const { prompt, model, directory, tools, system } = parseOptions3(
323
+ await promptMissingOptions3(
324
+ actualOptions3,
325
+ await parseFileOptions3(getOpt3(handlerArgs), ["prompt", "system"])
326
+ )
327
+ );
328
+ await createAndRunCodeAgent({
329
+ environment: createEnvironment2("mock-filesystem", {
330
+ directoryPath: directory
331
+ }),
332
+ environmentToolsDefinition: tools,
333
+ model,
334
+ prompt,
335
+ system,
336
+ directory
337
+ });
338
+ };
339
+
340
+ // src/commands/node-filesystem-code-agent.ts
341
+ import {
342
+ createEnvironment as createEnvironment3,
343
+ EnvironmentToolSafetyLevels as EnvironmentToolSafetyLevels4
344
+ } from "ai-code-agents";
345
+ import {
346
+ getOpt as getOpt4,
347
+ parseFileOptions as parseFileOptions4,
348
+ injectFileOptionsForCommander as injectFileOptionsForCommander4,
349
+ promptMissingOptions as promptMissingOptions4,
350
+ stripOptionFieldsForCommander as stripOptionFieldsForCommander4,
351
+ normalizeAbsolutePath as normalizeAbsolutePath4
352
+ } from "@felixarntz/cli-utils";
353
+ var name4 = "node-filesystem-code-agent";
354
+ var description4 = "Runs a code agent locally using Node to perform a specified task.";
355
+ var actualOptions4 = [
356
+ {
357
+ argname: "-p, --prompt <prompt>",
358
+ description: "Task prompt for the agent",
359
+ required: true
221
360
  },
222
361
  {
223
- argname: "-i, --environment-id <environment-id>",
224
- description: "ID of the environment, if relevant (e.g. Docker container ID)"
362
+ argname: "-m, --model <model>",
363
+ description: "Model to use for the agent",
364
+ required: true
365
+ },
366
+ {
367
+ argname: "-d, --directory <directory>",
368
+ description: "Directory with the project to work on",
369
+ parse: (value) => normalizeAbsolutePath4(value),
370
+ required: true
371
+ },
372
+ {
373
+ argname: "-t, --tools <tools>",
374
+ description: "Tools to allow the agent to use in the environment",
375
+ choices: EnvironmentToolSafetyLevels4,
376
+ defaults: "readonly"
225
377
  },
226
378
  {
227
379
  argname: "-s, --system <system>",
228
380
  description: "System instruction to guide the agent"
229
381
  }
230
382
  ];
231
- var parseOptions = (opt) => {
383
+ var options4 = injectFileOptionsForCommander4(actualOptions4, [
384
+ "prompt",
385
+ "system"
386
+ ]).map((option) => stripOptionFieldsForCommander4(option));
387
+ var parseOptions4 = (opt) => {
232
388
  const config = {
389
+ prompt: String(opt["prompt"]),
233
390
  model: opt["model"] ? String(opt["model"]) : "",
234
- environment: opt["environment"],
235
391
  directory: opt["directory"] ? String(opt["directory"]) : "",
236
392
  tools: opt["tools"] ? opt["tools"] : "readonly"
237
393
  };
238
- if (opt["environment-id"]) {
239
- config.environmentId = String(opt["environment-id"]);
240
- }
241
394
  if (opt["system"]) {
242
395
  config.system = String(opt["system"]);
243
396
  }
244
397
  return config;
245
398
  };
246
- var handler = async (...handlerArgs) => {
247
- const [task] = getArgs(handlerArgs);
248
- const { model, environment, directory, tools, environmentId, system } = parseOptions(getOpt(handlerArgs));
249
- const modelSuffix = model ? ` (using model ${model})` : "";
250
- logger.debug(
251
- `Running task "${task}" in ${environment} about code in ${directory}${modelSuffix}...`
252
- );
253
- const environmentConfig = createEnvironmentConfig(
254
- environment,
255
- directory,
256
- environmentId
399
+ var handler4 = async (...handlerArgs) => {
400
+ const { prompt, model, directory, tools, system } = parseOptions4(
401
+ await promptMissingOptions4(
402
+ actualOptions4,
403
+ await parseFileOptions4(getOpt4(handlerArgs), ["prompt", "system"])
404
+ )
257
405
  );
258
- const agent = createCodeAgent({
259
- model,
260
- environment: createEnvironment(environment, environmentConfig),
406
+ await createAndRunCodeAgent({
407
+ environment: createEnvironment3("node-filesystem", {
408
+ directoryPath: directory
409
+ }),
261
410
  environmentToolsDefinition: tools,
262
- maxSteps: 10,
263
- logStep: (log) => {
264
- logger.debug("\n" + log);
265
- },
266
- system
411
+ model,
412
+ prompt,
413
+ system,
414
+ directory
267
415
  });
268
- const result = await agent.generate({ prompt: task });
269
- const { text } = result;
270
- output(text);
271
416
  };
272
- var createEnvironmentConfig = (environment, directory, environmentId) => {
417
+
418
+ // src/commands/unsafe-local-code-agent.ts
419
+ import {
420
+ createEnvironment as createEnvironment4,
421
+ EnvironmentToolSafetyLevels as EnvironmentToolSafetyLevels5
422
+ } from "ai-code-agents";
423
+ import {
424
+ getOpt as getOpt5,
425
+ parseFileOptions as parseFileOptions5,
426
+ injectFileOptionsForCommander as injectFileOptionsForCommander5,
427
+ promptMissingOptions as promptMissingOptions5,
428
+ stripOptionFieldsForCommander as stripOptionFieldsForCommander5,
429
+ normalizeAbsolutePath as normalizeAbsolutePath5
430
+ } from "@felixarntz/cli-utils";
431
+ var name5 = "unsafe-local-code-agent";
432
+ var description5 = "Runs a code agent locally to perform a specified task.";
433
+ var actualOptions5 = [
434
+ {
435
+ argname: "-p, --prompt <prompt>",
436
+ description: "Task prompt for the agent",
437
+ required: true
438
+ },
439
+ {
440
+ argname: "-m, --model <model>",
441
+ description: "Model to use for the agent",
442
+ required: true
443
+ },
444
+ {
445
+ argname: "-d, --directory <directory>",
446
+ description: "Directory with the project to work on",
447
+ parse: (value) => normalizeAbsolutePath5(value),
448
+ required: true
449
+ },
450
+ {
451
+ argname: "-t, --tools <tools>",
452
+ description: "Tools to allow the agent to use in the environment",
453
+ choices: EnvironmentToolSafetyLevels5,
454
+ defaults: "readonly"
455
+ },
456
+ {
457
+ argname: "-s, --system <system>",
458
+ description: "System instruction to guide the agent"
459
+ }
460
+ ];
461
+ var options5 = injectFileOptionsForCommander5(actualOptions5, [
462
+ "prompt",
463
+ "system"
464
+ ]).map((option) => stripOptionFieldsForCommander5(option));
465
+ var parseOptions5 = (opt) => {
273
466
  const config = {
274
- directoryPath: directory
467
+ prompt: String(opt["prompt"]),
468
+ model: opt["model"] ? String(opt["model"]) : "",
469
+ directory: opt["directory"] ? String(opt["directory"]) : "",
470
+ tools: opt["tools"] ? opt["tools"] : "readonly"
275
471
  };
276
- if (environment === "docker" && environmentId) {
277
- return {
278
- ...config,
279
- containerId: environmentId
280
- };
472
+ if (opt["system"]) {
473
+ config.system = String(opt["system"]);
281
474
  }
282
475
  return config;
283
476
  };
477
+ var handler5 = async (...handlerArgs) => {
478
+ const { prompt, model, directory, tools, system } = parseOptions5(
479
+ await promptMissingOptions5(
480
+ actualOptions5,
481
+ await parseFileOptions5(getOpt5(handlerArgs), ["prompt", "system"])
482
+ )
483
+ );
484
+ await createAndRunCodeAgent({
485
+ environment: createEnvironment4("unsafe-local", {
486
+ directoryPath: directory
487
+ }),
488
+ environmentToolsDefinition: tools,
489
+ model,
490
+ prompt,
491
+ system,
492
+ directory
493
+ });
494
+ };
284
495
 
285
496
  // src/cli.ts
286
497
  function initialize() {
287
498
  dotenv.config();
288
499
  withOptions(program.command(name), options).description(description).action(withErrorHandling(handler));
500
+ withOptions(program.command(name2), options2).description(description2).action(withErrorHandling(handler2));
501
+ withOptions(
502
+ program.command(name3),
503
+ options3
504
+ ).description(description3).action(withErrorHandling(handler3));
505
+ withOptions(
506
+ program.command(name4),
507
+ options4
508
+ ).description(description4).action(withErrorHandling(handler4));
509
+ withOptions(
510
+ program.command(name5),
511
+ options5
512
+ ).description(description5).action(withErrorHandling(handler5));
289
513
  }
290
514
  function run() {
291
515
  program.parse();