@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/LICENSE.md +7 -0
- package/README.md +175 -0
- package/dist/cli.cjs +378 -214
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +440 -216
- package/dist/cli.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -8
package/dist/cli.cjs
CHANGED
|
@@ -25,193 +25,159 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
|
|
26
26
|
// src/cli.ts
|
|
27
27
|
var import_extra_typings = require("@commander-js/extra-typings");
|
|
28
|
+
var import_cli_utils7 = require("@felixarntz/cli-utils");
|
|
28
29
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
29
30
|
|
|
30
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
debug(text) {
|
|
61
|
-
this.log(text, 0 /* DEBUG */);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Logs an info message.
|
|
65
|
-
*
|
|
66
|
-
* @param text - The message to log.
|
|
67
|
-
*/
|
|
68
|
-
info(text) {
|
|
69
|
-
this.log(text, 1 /* INFO */);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Logs a success message.
|
|
73
|
-
*
|
|
74
|
-
* @param text - The message to log.
|
|
75
|
-
*/
|
|
76
|
-
success(text) {
|
|
77
|
-
this.log(text, 2 /* SUCCESS */);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Logs a warning message.
|
|
81
|
-
*
|
|
82
|
-
* @param text - The message to log.
|
|
83
|
-
*/
|
|
84
|
-
warn(text) {
|
|
85
|
-
this.log(text, 3 /* WARN */);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Logs an error message.
|
|
89
|
-
*
|
|
90
|
-
* @param text - The message to log.
|
|
91
|
-
*/
|
|
92
|
-
error(text) {
|
|
93
|
-
this.log(text, 4 /* ERROR */);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Logs a message with a log level.
|
|
97
|
-
*
|
|
98
|
-
* @param text - The message to log.
|
|
99
|
-
* @param level - The log level. Defaults to LogLevel.INFO.
|
|
100
|
-
*/
|
|
101
|
-
log(text, level = 1 /* INFO */) {
|
|
102
|
-
if (level < CURRENT_LOG_LEVEL) {
|
|
103
|
-
return;
|
|
31
|
+
// src/commands/docker-code-agent.ts
|
|
32
|
+
var import_ai_code_agents2 = require("ai-code-agents");
|
|
33
|
+
var import_cli_utils2 = require("@felixarntz/cli-utils");
|
|
34
|
+
|
|
35
|
+
// src/util/create-and-run-code-agent.ts
|
|
36
|
+
var import_ai_code_agents = require("ai-code-agents");
|
|
37
|
+
var import_cli_utils = require("@felixarntz/cli-utils");
|
|
38
|
+
var createAndRunCodeAgent = async (options6) => {
|
|
39
|
+
const {
|
|
40
|
+
environment,
|
|
41
|
+
environmentToolsDefinition,
|
|
42
|
+
model,
|
|
43
|
+
prompt,
|
|
44
|
+
system,
|
|
45
|
+
maxSteps = 10,
|
|
46
|
+
directory
|
|
47
|
+
} = options6;
|
|
48
|
+
const modelSuffix = model ? ` (using model ${model})` : "";
|
|
49
|
+
import_cli_utils.logger.debug(
|
|
50
|
+
`Running task prompt in ${environment.name} about code in ${directory}${modelSuffix}...`
|
|
51
|
+
);
|
|
52
|
+
const agent = (0, import_ai_code_agents.createCodeAgent)({
|
|
53
|
+
model,
|
|
54
|
+
environment,
|
|
55
|
+
environmentToolsDefinition,
|
|
56
|
+
maxSteps,
|
|
57
|
+
instructions: system,
|
|
58
|
+
logStep: (log) => {
|
|
59
|
+
import_cli_utils.logger.debug("\n" + log);
|
|
104
60
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
61
|
+
});
|
|
62
|
+
const result = await agent.generate({ prompt });
|
|
63
|
+
const { text } = result;
|
|
64
|
+
(0, import_cli_utils.output)(text);
|
|
108
65
|
};
|
|
109
|
-
var logger = new Logger();
|
|
110
66
|
|
|
111
|
-
// src/
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
67
|
+
// src/commands/docker-code-agent.ts
|
|
68
|
+
var name = "docker-code-agent";
|
|
69
|
+
var description = "Runs a code agent in a Docker container to perform a specified task.";
|
|
70
|
+
var actualOptions = [
|
|
71
|
+
{
|
|
72
|
+
argname: "-p, --prompt <prompt>",
|
|
73
|
+
description: "Task prompt for the agent",
|
|
74
|
+
required: true
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
argname: "-m, --model <model>",
|
|
78
|
+
description: "Model to use for the agent",
|
|
79
|
+
required: true
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
argname: "-d, --directory <directory>",
|
|
83
|
+
description: "Directory with the project to work on",
|
|
84
|
+
parse: (value) => (0, import_cli_utils2.normalizeAbsolutePath)(value),
|
|
85
|
+
required: true
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
argname: "-t, --tools <tools>",
|
|
89
|
+
description: "Tools to allow the agent to use in the environment",
|
|
90
|
+
choices: import_ai_code_agents2.EnvironmentToolSafetyLevels,
|
|
91
|
+
defaults: "readonly"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
argname: "-i, --container-id <container-id>",
|
|
95
|
+
description: "ID of the Docker container",
|
|
96
|
+
required: true
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
argname: "-s, --system <system>",
|
|
100
|
+
description: "System instruction to guide the agent"
|
|
115
101
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
102
|
+
];
|
|
103
|
+
var options = (0, import_cli_utils2.injectFileOptionsForCommander)(actualOptions, [
|
|
104
|
+
"prompt",
|
|
105
|
+
"system"
|
|
106
|
+
]).map((option) => (0, import_cli_utils2.stripOptionFieldsForCommander)(option));
|
|
107
|
+
var parseOptions = (opt) => {
|
|
108
|
+
const config = {
|
|
109
|
+
prompt: String(opt["prompt"]),
|
|
110
|
+
model: opt["model"] ? String(opt["model"]) : "",
|
|
111
|
+
containerId: String(opt["container-id"]),
|
|
112
|
+
directory: opt["directory"] ? String(opt["directory"]) : "",
|
|
113
|
+
tools: opt["tools"] ? opt["tools"] : "readonly"
|
|
114
|
+
};
|
|
115
|
+
if (opt["system"]) {
|
|
116
|
+
config.system = String(opt["system"]);
|
|
121
117
|
}
|
|
122
|
-
return
|
|
118
|
+
return config;
|
|
123
119
|
};
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
required,
|
|
131
|
-
defaults,
|
|
132
|
-
choices,
|
|
133
|
-
parse,
|
|
134
|
-
variadic
|
|
135
|
-
}) => {
|
|
136
|
-
if (positional) {
|
|
137
|
-
const variadicSuffix = variadic ? "..." : "";
|
|
138
|
-
const argument = command.createArgument(
|
|
139
|
-
required ? `<${argname}${variadicSuffix}>` : `[${argname}${variadicSuffix}]`,
|
|
140
|
-
description2
|
|
141
|
-
);
|
|
142
|
-
if (defaults) {
|
|
143
|
-
argument.default(defaults);
|
|
144
|
-
}
|
|
145
|
-
if (typeof parse === "function") {
|
|
146
|
-
argument.argParser(parse);
|
|
147
|
-
}
|
|
148
|
-
if (choices) {
|
|
149
|
-
argument.choices(choices);
|
|
150
|
-
}
|
|
151
|
-
command.addArgument(argument);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const option = command.createOption(argname, description2);
|
|
155
|
-
if (required) {
|
|
156
|
-
option.makeOptionMandatory(true);
|
|
157
|
-
}
|
|
158
|
-
if (defaults) {
|
|
159
|
-
option.default(defaults);
|
|
160
|
-
}
|
|
161
|
-
if (typeof parse === "function") {
|
|
162
|
-
option.argParser(parse);
|
|
163
|
-
}
|
|
164
|
-
if (choices) {
|
|
165
|
-
option.choices(choices);
|
|
166
|
-
}
|
|
167
|
-
command.addOption(option);
|
|
168
|
-
}
|
|
120
|
+
var handler = async (...handlerArgs) => {
|
|
121
|
+
const { prompt, model, directory, tools, containerId, system } = parseOptions(
|
|
122
|
+
await (0, import_cli_utils2.promptMissingOptions)(
|
|
123
|
+
actualOptions,
|
|
124
|
+
await (0, import_cli_utils2.parseFileOptions)((0, import_cli_utils2.getOpt)(handlerArgs), ["prompt", "system"])
|
|
125
|
+
)
|
|
169
126
|
);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
process.exitCode = 1;
|
|
183
|
-
}
|
|
127
|
+
await createAndRunCodeAgent({
|
|
128
|
+
environment: (0, import_ai_code_agents2.createEnvironment)("docker", {
|
|
129
|
+
directoryPath: directory,
|
|
130
|
+
containerId
|
|
131
|
+
}),
|
|
132
|
+
environmentToolsDefinition: tools,
|
|
133
|
+
model,
|
|
134
|
+
prompt,
|
|
135
|
+
system,
|
|
136
|
+
directory
|
|
137
|
+
});
|
|
184
138
|
};
|
|
185
139
|
|
|
186
|
-
// src/commands/code-agent.ts
|
|
187
|
-
var
|
|
140
|
+
// src/commands/just-bash-code-agent.ts
|
|
141
|
+
var import_ai_code_agents4 = require("ai-code-agents");
|
|
142
|
+
var import_just_bash = require("@ai-code-agents/just-bash");
|
|
143
|
+
var import_cli_utils3 = require("@felixarntz/cli-utils");
|
|
188
144
|
|
|
189
|
-
// src/util/
|
|
145
|
+
// src/util/read-local-directory-files.ts
|
|
190
146
|
var import_node_path = __toESM(require("path"), 1);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
147
|
+
var import_ai_code_agents3 = require("ai-code-agents");
|
|
148
|
+
var readLocalDirectoryFiles = async (directoryPath) => {
|
|
149
|
+
const env = new import_ai_code_agents3.UnsafeLocalEnvironment({ directoryPath });
|
|
150
|
+
const getProjectFileStructureTool = new import_ai_code_agents3.GetProjectFileStructureTool(env);
|
|
151
|
+
const readManyFilesTool = new import_ai_code_agents3.ReadManyFilesTool(env);
|
|
152
|
+
const { files } = await getProjectFileStructureTool.execute(
|
|
153
|
+
{ excludeGitIgnored: true },
|
|
154
|
+
{}
|
|
155
|
+
);
|
|
156
|
+
if (files.length === 0) {
|
|
157
|
+
return {};
|
|
194
158
|
}
|
|
195
|
-
|
|
196
|
-
|
|
159
|
+
const readResult = await readManyFilesTool.execute(
|
|
160
|
+
{ paths: files },
|
|
161
|
+
{}
|
|
162
|
+
);
|
|
163
|
+
const result = {};
|
|
164
|
+
for (const [, fileResult] of Object.entries(readResult)) {
|
|
165
|
+
const relativePath = import_node_path.default.relative(
|
|
166
|
+
directoryPath,
|
|
167
|
+
import_node_path.default.resolve(directoryPath, fileResult.path)
|
|
168
|
+
);
|
|
169
|
+
result[relativePath] = fileResult.content;
|
|
197
170
|
}
|
|
198
|
-
return
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// src/util/output.ts
|
|
202
|
-
function output(text) {
|
|
203
|
-
process.stdout.write(`${text}
|
|
204
|
-
`);
|
|
205
|
-
}
|
|
171
|
+
return result;
|
|
172
|
+
};
|
|
206
173
|
|
|
207
|
-
// src/commands/code-agent.ts
|
|
208
|
-
var
|
|
209
|
-
var
|
|
210
|
-
var
|
|
174
|
+
// src/commands/just-bash-code-agent.ts
|
|
175
|
+
var name2 = "just-bash-code-agent";
|
|
176
|
+
var description2 = "Runs a code agent using a simulated bash environment to perform a specified task.";
|
|
177
|
+
var actualOptions2 = [
|
|
211
178
|
{
|
|
212
|
-
argname: "
|
|
213
|
-
description: "Task for the agent",
|
|
214
|
-
positional: true,
|
|
179
|
+
argname: "-p, --prompt <prompt>",
|
|
180
|
+
description: "Task prompt for the agent",
|
|
215
181
|
required: true
|
|
216
182
|
},
|
|
217
183
|
{
|
|
@@ -219,91 +185,289 @@ var options = [
|
|
|
219
185
|
description: "Model to use for the agent",
|
|
220
186
|
required: true
|
|
221
187
|
},
|
|
222
|
-
{
|
|
223
|
-
argname: "-e, --environment <environment>",
|
|
224
|
-
description: "Environment type to use",
|
|
225
|
-
choices: import_ai_code_agents.EnvironmentNames,
|
|
226
|
-
required: true
|
|
227
|
-
},
|
|
228
188
|
{
|
|
229
189
|
argname: "-d, --directory <directory>",
|
|
230
190
|
description: "Directory with the project to work on",
|
|
231
|
-
parse: (value) => normalizeAbsolutePath(value),
|
|
191
|
+
parse: (value) => (0, import_cli_utils3.normalizeAbsolutePath)(value),
|
|
232
192
|
required: true
|
|
233
193
|
},
|
|
234
194
|
{
|
|
235
195
|
argname: "-t, --tools <tools>",
|
|
236
|
-
description: "
|
|
237
|
-
choices:
|
|
238
|
-
|
|
196
|
+
description: "Tools to allow the agent to use in the environment",
|
|
197
|
+
choices: import_ai_code_agents4.EnvironmentToolSafetyLevels,
|
|
198
|
+
defaults: "readonly"
|
|
239
199
|
},
|
|
240
200
|
{
|
|
241
|
-
argname: "-
|
|
242
|
-
description: "
|
|
201
|
+
argname: "-l, --local-directory <local-directory>",
|
|
202
|
+
description: "Local directory to mount into the simulated environment (reads all files excluding gitignored)",
|
|
203
|
+
parse: (value) => (0, import_cli_utils3.normalizeAbsolutePath)(value)
|
|
243
204
|
},
|
|
244
205
|
{
|
|
245
206
|
argname: "-s, --system <system>",
|
|
246
207
|
description: "System instruction to guide the agent"
|
|
247
208
|
}
|
|
248
209
|
];
|
|
249
|
-
var
|
|
210
|
+
var options2 = (0, import_cli_utils3.injectFileOptionsForCommander)(actualOptions2, [
|
|
211
|
+
"prompt",
|
|
212
|
+
"system"
|
|
213
|
+
]).map((option) => (0, import_cli_utils3.stripOptionFieldsForCommander)(option));
|
|
214
|
+
var parseOptions2 = (opt) => {
|
|
250
215
|
const config = {
|
|
216
|
+
prompt: String(opt["prompt"]),
|
|
251
217
|
model: opt["model"] ? String(opt["model"]) : "",
|
|
252
|
-
environment: opt["environment"],
|
|
253
218
|
directory: opt["directory"] ? String(opt["directory"]) : "",
|
|
254
219
|
tools: opt["tools"] ? opt["tools"] : "readonly"
|
|
255
220
|
};
|
|
256
|
-
if (opt["
|
|
257
|
-
config.
|
|
221
|
+
if (opt["local-directory"]) {
|
|
222
|
+
config.localDirectory = String(opt["local-directory"]);
|
|
258
223
|
}
|
|
259
224
|
if (opt["system"]) {
|
|
260
225
|
config.system = String(opt["system"]);
|
|
261
226
|
}
|
|
262
227
|
return config;
|
|
263
228
|
};
|
|
264
|
-
var
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
229
|
+
var handler2 = async (...handlerArgs) => {
|
|
230
|
+
const { prompt, model, directory, tools, localDirectory, system } = parseOptions2(
|
|
231
|
+
await (0, import_cli_utils3.promptMissingOptions)(
|
|
232
|
+
actualOptions2,
|
|
233
|
+
await (0, import_cli_utils3.parseFileOptions)((0, import_cli_utils3.getOpt)(handlerArgs), ["prompt", "system"])
|
|
234
|
+
)
|
|
270
235
|
);
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
236
|
+
const files = localDirectory ? await readLocalDirectoryFiles(localDirectory) : void 0;
|
|
237
|
+
await createAndRunCodeAgent({
|
|
238
|
+
environment: import_just_bash.JustBashEnvironment.create({
|
|
239
|
+
directoryPath: directory,
|
|
240
|
+
bashOptions: files ? { files } : void 0
|
|
241
|
+
}),
|
|
242
|
+
environmentToolsDefinition: tools,
|
|
243
|
+
model,
|
|
244
|
+
prompt,
|
|
245
|
+
system,
|
|
246
|
+
directory
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// src/commands/mock-filesystem-code-agent.ts
|
|
251
|
+
var import_ai_code_agents5 = require("ai-code-agents");
|
|
252
|
+
var import_cli_utils4 = require("@felixarntz/cli-utils");
|
|
253
|
+
var name3 = "mock-filesystem-code-agent";
|
|
254
|
+
var description3 = "Runs a code agent on a mock filesystem to perform a specified task.";
|
|
255
|
+
var actualOptions3 = [
|
|
256
|
+
{
|
|
257
|
+
argname: "-p, --prompt <prompt>",
|
|
258
|
+
description: "Task prompt for the agent",
|
|
259
|
+
required: true
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
argname: "-m, --model <model>",
|
|
263
|
+
description: "Model to use for the agent",
|
|
264
|
+
required: true
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
argname: "-d, --directory <directory>",
|
|
268
|
+
description: "Directory with the project to work on",
|
|
269
|
+
parse: (value) => (0, import_cli_utils4.normalizeAbsolutePath)(value),
|
|
270
|
+
required: true
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
argname: "-t, --tools <tools>",
|
|
274
|
+
description: "Tools to allow the agent to use in the environment",
|
|
275
|
+
choices: import_ai_code_agents5.EnvironmentToolSafetyLevels,
|
|
276
|
+
defaults: "readonly"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
argname: "-s, --system <system>",
|
|
280
|
+
description: "System instruction to guide the agent"
|
|
281
|
+
}
|
|
282
|
+
];
|
|
283
|
+
var options3 = (0, import_cli_utils4.injectFileOptionsForCommander)(actualOptions3, [
|
|
284
|
+
"prompt",
|
|
285
|
+
"system"
|
|
286
|
+
]).map((option) => (0, import_cli_utils4.stripOptionFieldsForCommander)(option));
|
|
287
|
+
var parseOptions3 = (opt) => {
|
|
288
|
+
const config = {
|
|
289
|
+
prompt: String(opt["prompt"]),
|
|
290
|
+
model: opt["model"] ? String(opt["model"]) : "",
|
|
291
|
+
directory: opt["directory"] ? String(opt["directory"]) : "",
|
|
292
|
+
tools: opt["tools"] ? opt["tools"] : "readonly"
|
|
293
|
+
};
|
|
294
|
+
if (opt["system"]) {
|
|
295
|
+
config.system = String(opt["system"]);
|
|
296
|
+
}
|
|
297
|
+
return config;
|
|
298
|
+
};
|
|
299
|
+
var handler3 = async (...handlerArgs) => {
|
|
300
|
+
const { prompt, model, directory, tools, system } = parseOptions3(
|
|
301
|
+
await (0, import_cli_utils4.promptMissingOptions)(
|
|
302
|
+
actualOptions3,
|
|
303
|
+
await (0, import_cli_utils4.parseFileOptions)((0, import_cli_utils4.getOpt)(handlerArgs), ["prompt", "system"])
|
|
304
|
+
)
|
|
275
305
|
);
|
|
276
|
-
|
|
306
|
+
await createAndRunCodeAgent({
|
|
307
|
+
environment: (0, import_ai_code_agents5.createEnvironment)("mock-filesystem", {
|
|
308
|
+
directoryPath: directory
|
|
309
|
+
}),
|
|
310
|
+
environmentToolsDefinition: tools,
|
|
277
311
|
model,
|
|
278
|
-
|
|
312
|
+
prompt,
|
|
313
|
+
system,
|
|
314
|
+
directory
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
// src/commands/node-filesystem-code-agent.ts
|
|
319
|
+
var import_ai_code_agents6 = require("ai-code-agents");
|
|
320
|
+
var import_cli_utils5 = require("@felixarntz/cli-utils");
|
|
321
|
+
var name4 = "node-filesystem-code-agent";
|
|
322
|
+
var description4 = "Runs a code agent locally using Node to perform a specified task.";
|
|
323
|
+
var actualOptions4 = [
|
|
324
|
+
{
|
|
325
|
+
argname: "-p, --prompt <prompt>",
|
|
326
|
+
description: "Task prompt for the agent",
|
|
327
|
+
required: true
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
argname: "-m, --model <model>",
|
|
331
|
+
description: "Model to use for the agent",
|
|
332
|
+
required: true
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
argname: "-d, --directory <directory>",
|
|
336
|
+
description: "Directory with the project to work on",
|
|
337
|
+
parse: (value) => (0, import_cli_utils5.normalizeAbsolutePath)(value),
|
|
338
|
+
required: true
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
argname: "-t, --tools <tools>",
|
|
342
|
+
description: "Tools to allow the agent to use in the environment",
|
|
343
|
+
choices: import_ai_code_agents6.EnvironmentToolSafetyLevels,
|
|
344
|
+
defaults: "readonly"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
argname: "-s, --system <system>",
|
|
348
|
+
description: "System instruction to guide the agent"
|
|
349
|
+
}
|
|
350
|
+
];
|
|
351
|
+
var options4 = (0, import_cli_utils5.injectFileOptionsForCommander)(actualOptions4, [
|
|
352
|
+
"prompt",
|
|
353
|
+
"system"
|
|
354
|
+
]).map((option) => (0, import_cli_utils5.stripOptionFieldsForCommander)(option));
|
|
355
|
+
var parseOptions4 = (opt) => {
|
|
356
|
+
const config = {
|
|
357
|
+
prompt: String(opt["prompt"]),
|
|
358
|
+
model: opt["model"] ? String(opt["model"]) : "",
|
|
359
|
+
directory: opt["directory"] ? String(opt["directory"]) : "",
|
|
360
|
+
tools: opt["tools"] ? opt["tools"] : "readonly"
|
|
361
|
+
};
|
|
362
|
+
if (opt["system"]) {
|
|
363
|
+
config.system = String(opt["system"]);
|
|
364
|
+
}
|
|
365
|
+
return config;
|
|
366
|
+
};
|
|
367
|
+
var handler4 = async (...handlerArgs) => {
|
|
368
|
+
const { prompt, model, directory, tools, system } = parseOptions4(
|
|
369
|
+
await (0, import_cli_utils5.promptMissingOptions)(
|
|
370
|
+
actualOptions4,
|
|
371
|
+
await (0, import_cli_utils5.parseFileOptions)((0, import_cli_utils5.getOpt)(handlerArgs), ["prompt", "system"])
|
|
372
|
+
)
|
|
373
|
+
);
|
|
374
|
+
await createAndRunCodeAgent({
|
|
375
|
+
environment: (0, import_ai_code_agents6.createEnvironment)("node-filesystem", {
|
|
376
|
+
directoryPath: directory
|
|
377
|
+
}),
|
|
279
378
|
environmentToolsDefinition: tools,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
system
|
|
379
|
+
model,
|
|
380
|
+
prompt,
|
|
381
|
+
system,
|
|
382
|
+
directory
|
|
285
383
|
});
|
|
286
|
-
const result = await agent.generate({ prompt: task });
|
|
287
|
-
const { text } = result;
|
|
288
|
-
output(text);
|
|
289
384
|
};
|
|
290
|
-
|
|
385
|
+
|
|
386
|
+
// src/commands/unsafe-local-code-agent.ts
|
|
387
|
+
var import_ai_code_agents7 = require("ai-code-agents");
|
|
388
|
+
var import_cli_utils6 = require("@felixarntz/cli-utils");
|
|
389
|
+
var name5 = "unsafe-local-code-agent";
|
|
390
|
+
var description5 = "Runs a code agent locally to perform a specified task.";
|
|
391
|
+
var actualOptions5 = [
|
|
392
|
+
{
|
|
393
|
+
argname: "-p, --prompt <prompt>",
|
|
394
|
+
description: "Task prompt for the agent",
|
|
395
|
+
required: true
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
argname: "-m, --model <model>",
|
|
399
|
+
description: "Model to use for the agent",
|
|
400
|
+
required: true
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
argname: "-d, --directory <directory>",
|
|
404
|
+
description: "Directory with the project to work on",
|
|
405
|
+
parse: (value) => (0, import_cli_utils6.normalizeAbsolutePath)(value),
|
|
406
|
+
required: true
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
argname: "-t, --tools <tools>",
|
|
410
|
+
description: "Tools to allow the agent to use in the environment",
|
|
411
|
+
choices: import_ai_code_agents7.EnvironmentToolSafetyLevels,
|
|
412
|
+
defaults: "readonly"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
argname: "-s, --system <system>",
|
|
416
|
+
description: "System instruction to guide the agent"
|
|
417
|
+
}
|
|
418
|
+
];
|
|
419
|
+
var options5 = (0, import_cli_utils6.injectFileOptionsForCommander)(actualOptions5, [
|
|
420
|
+
"prompt",
|
|
421
|
+
"system"
|
|
422
|
+
]).map((option) => (0, import_cli_utils6.stripOptionFieldsForCommander)(option));
|
|
423
|
+
var parseOptions5 = (opt) => {
|
|
291
424
|
const config = {
|
|
292
|
-
|
|
425
|
+
prompt: String(opt["prompt"]),
|
|
426
|
+
model: opt["model"] ? String(opt["model"]) : "",
|
|
427
|
+
directory: opt["directory"] ? String(opt["directory"]) : "",
|
|
428
|
+
tools: opt["tools"] ? opt["tools"] : "readonly"
|
|
293
429
|
};
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
...config,
|
|
297
|
-
containerId: environmentId
|
|
298
|
-
};
|
|
430
|
+
if (opt["system"]) {
|
|
431
|
+
config.system = String(opt["system"]);
|
|
299
432
|
}
|
|
300
433
|
return config;
|
|
301
434
|
};
|
|
435
|
+
var handler5 = async (...handlerArgs) => {
|
|
436
|
+
const { prompt, model, directory, tools, system } = parseOptions5(
|
|
437
|
+
await (0, import_cli_utils6.promptMissingOptions)(
|
|
438
|
+
actualOptions5,
|
|
439
|
+
await (0, import_cli_utils6.parseFileOptions)((0, import_cli_utils6.getOpt)(handlerArgs), ["prompt", "system"])
|
|
440
|
+
)
|
|
441
|
+
);
|
|
442
|
+
await createAndRunCodeAgent({
|
|
443
|
+
environment: (0, import_ai_code_agents7.createEnvironment)("unsafe-local", {
|
|
444
|
+
directoryPath: directory
|
|
445
|
+
}),
|
|
446
|
+
environmentToolsDefinition: tools,
|
|
447
|
+
model,
|
|
448
|
+
prompt,
|
|
449
|
+
system,
|
|
450
|
+
directory
|
|
451
|
+
});
|
|
452
|
+
};
|
|
302
453
|
|
|
303
454
|
// src/cli.ts
|
|
304
455
|
function initialize() {
|
|
305
456
|
import_dotenv.default.config();
|
|
306
|
-
withOptions(import_extra_typings.program.command(name), options).description(description).action(withErrorHandling(handler));
|
|
457
|
+
(0, import_cli_utils7.withOptions)(import_extra_typings.program.command(name), options).description(description).action((0, import_cli_utils7.withErrorHandling)(handler));
|
|
458
|
+
(0, import_cli_utils7.withOptions)(import_extra_typings.program.command(name2), options2).description(description2).action((0, import_cli_utils7.withErrorHandling)(handler2));
|
|
459
|
+
(0, import_cli_utils7.withOptions)(
|
|
460
|
+
import_extra_typings.program.command(name3),
|
|
461
|
+
options3
|
|
462
|
+
).description(description3).action((0, import_cli_utils7.withErrorHandling)(handler3));
|
|
463
|
+
(0, import_cli_utils7.withOptions)(
|
|
464
|
+
import_extra_typings.program.command(name4),
|
|
465
|
+
options4
|
|
466
|
+
).description(description4).action((0, import_cli_utils7.withErrorHandling)(handler4));
|
|
467
|
+
(0, import_cli_utils7.withOptions)(
|
|
468
|
+
import_extra_typings.program.command(name5),
|
|
469
|
+
options5
|
|
470
|
+
).description(description5).action((0, import_cli_utils7.withErrorHandling)(handler5));
|
|
307
471
|
}
|
|
308
472
|
function run() {
|
|
309
473
|
import_extra_typings.program.parse();
|