coder-agent 2.6.0 → 2.6.1

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/agent.js CHANGED
@@ -331,11 +331,13 @@ export class Agent {
331
331
  memory;
332
332
  model;
333
333
  memoryScope;
334
- constructor(apiKey, model = "gemini-2.5-flash", memoryScope = "project") {
334
+ confirmHandler;
335
+ constructor(apiKey, model = "gemini-2.5-flash", memoryScope = "project", confirmHandler) {
335
336
  this.apiKey = apiKey;
336
337
  this.memory = new Memory();
337
338
  this.model = model;
338
339
  this.memoryScope = memoryScope;
340
+ this.confirmHandler = confirmHandler;
339
341
  }
340
342
  clearMemory() {
341
343
  this.memory.clear();
@@ -516,7 +518,7 @@ export class Agent {
516
518
  modifiedFiles.add(path.normalize(args.file_path));
517
519
  }
518
520
  }
519
- const result = await dispatchTool(name, args, signal);
521
+ const result = await dispatchTool(name, args, this.confirmHandler, signal);
520
522
  if (signal?.aborted) {
521
523
  const abortErr = new Error("The user aborted a request.");
522
524
  abortErr.name = "AbortError";
package/dist/index.js CHANGED
@@ -114,6 +114,7 @@ async function promptApiKey() {
114
114
  }
115
115
  // ─── Main Execution ───────────────────────────────────────────────────────────
116
116
  async function main() {
117
+ let rl;
117
118
  const args = process.argv.slice(2);
118
119
  let tempModel;
119
120
  let tempMemoryScope;
@@ -182,7 +183,28 @@ async function main() {
182
183
  if (!apiKey) {
183
184
  apiKey = await promptApiKey();
184
185
  }
185
- const agent = new Agent(apiKey, modelToUse, tempMemoryScope);
186
+ const confirmHandler = async (question) => {
187
+ if (rl) {
188
+ return new Promise((resolve) => {
189
+ rl.question(question, (answer) => {
190
+ resolve(answer.trim().toLowerCase().startsWith("y"));
191
+ });
192
+ });
193
+ }
194
+ else {
195
+ const rlConfirm = readline.createInterface({
196
+ input: process.stdin,
197
+ output: process.stdout,
198
+ });
199
+ return new Promise((resolve) => {
200
+ rlConfirm.question(question, (answer) => {
201
+ rlConfirm.close();
202
+ resolve(answer.trim().toLowerCase().startsWith("y"));
203
+ });
204
+ });
205
+ }
206
+ };
207
+ const agent = new Agent(apiKey, modelToUse, tempMemoryScope, confirmHandler);
186
208
  // Single-Shot Mode
187
209
  if (queryArgs.length > 0) {
188
210
  const singleShotPrompt = queryArgs.join(" ").trim();
@@ -206,7 +228,7 @@ async function main() {
206
228
  }
207
229
  // Interactive REPL Mode
208
230
  printBanner(modelToUse);
209
- const rl = readline.createInterface({
231
+ rl = readline.createInterface({
210
232
  input: process.stdin,
211
233
  output: process.stdout,
212
234
  terminal: true,
package/dist/tools.js CHANGED
@@ -212,7 +212,7 @@ export async function list_directory({ dir_path = "." }) {
212
212
  return `ERROR: ${e.message}`;
213
213
  }
214
214
  }
215
- export async function run_shell({ command, cwd }, signal) {
215
+ export async function run_shell({ command, cwd }, confirmHandler, signal) {
216
216
  try {
217
217
  let targetCwd = process.cwd();
218
218
  if (cwd) {
@@ -234,7 +234,22 @@ export async function run_shell({ command, cwd }, signal) {
234
234
  if (cwd) {
235
235
  console.log(` in directory: ${chalk.gray(cwd)}`);
236
236
  }
237
- const allowed = await askConfirmation(` Allow execution? (y/N): `);
237
+ let allowed = false;
238
+ if (confirmHandler) {
239
+ allowed = await confirmHandler(` Allow execution? (y/N): `);
240
+ }
241
+ else {
242
+ const rlConfirm = readline.createInterface({
243
+ input: process.stdin,
244
+ output: process.stdout,
245
+ });
246
+ allowed = await new Promise((resolve) => {
247
+ rlConfirm.question(` Allow execution? (y/N): `, (answer) => {
248
+ rlConfirm.close();
249
+ resolve(answer.trim().toLowerCase().startsWith("y"));
250
+ });
251
+ });
252
+ }
238
253
  if (!allowed) {
239
254
  return "ERROR: Command execution denied by user.";
240
255
  }
@@ -392,12 +407,12 @@ export async function patch_file({ file_path, target_code, replacement_code }) {
392
407
  }
393
408
  }
394
409
  // ─── Dispatcher ──────────────────────────────────────────────────────────────
395
- export async function dispatchTool(name, args, signal) {
410
+ export async function dispatchTool(name, args, confirmHandler, signal) {
396
411
  switch (name) {
397
412
  case "read_file": return read_file(args);
398
413
  case "write_file": return write_file(args);
399
414
  case "list_directory": return list_directory(args);
400
- case "run_shell": return run_shell(args, signal);
415
+ case "run_shell": return run_shell(args, confirmHandler, signal);
401
416
  case "web_search": return web_search(args, signal);
402
417
  case "find_files": return find_files(args);
403
418
  case "read_file_lines": return read_file_lines(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder-agent",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "CLI coding agent powered by Google Gemini",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",