autoclaw 1.0.30 → 1.0.32

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8,8 +8,6 @@ import * as fs from 'fs';
8
8
  import * as path from 'path';
9
9
  import * as os from 'os';
10
10
  import { fileURLToPath } from 'url';
11
- import { createInterface } from 'node:readline/promises';
12
- import { stdin as input, stdout as output } from 'node:process';
13
11
  // Handle Ctrl+C gracefully
14
12
  function handleExit() {
15
13
  console.log(chalk.cyan("\n\nGoodbye! (Interrupted)"));
@@ -59,8 +57,9 @@ program
59
57
  program
60
58
  .command('setup')
61
59
  .description('Run the interactive setup wizard to configure API keys')
62
- .action(async () => {
63
- await runSetup();
60
+ .option('-p, --project', 'Save configuration to project-level (.autoclaw/setting.json)')
61
+ .action(async (options) => {
62
+ await runSetup(options);
64
63
  });
65
64
  program
66
65
  .command('chat [query...]', { isDefault: true })
@@ -70,10 +69,16 @@ program
70
69
  await runChat(queryParts, options);
71
70
  });
72
71
  program.parse(process.argv);
73
- async function runSetup() {
72
+ async function runSetup(options = {}) {
73
+ const isProject = options.project;
74
+ const targetFile = isProject ? LOCAL_CONFIG_FILE : GLOBAL_CONFIG_FILE;
75
+ const targetDir = isProject ? path.join(process.cwd(), '.autoclaw') : GLOBAL_CONFIG_DIR;
74
76
  console.log(chalk.bold.cyan("AutoClaw Setup Wizard šŸ¦ž\n"));
75
- console.log(chalk.dim(`Config will be saved to: ${GLOBAL_CONFIG_FILE}`));
76
- const currentConfig = loadJsonConfig(GLOBAL_CONFIG_FILE);
77
+ console.log(chalk.dim(`Config will be saved to: ${targetFile}`));
78
+ // Load both to show current effective values as defaults
79
+ const globalConfig = loadJsonConfig(GLOBAL_CONFIG_FILE);
80
+ const localConfig = loadJsonConfig(LOCAL_CONFIG_FILE);
81
+ const currentConfig = { ...globalConfig, ...localConfig };
77
82
  function maskSecret(secret) {
78
83
  if (!secret || secret.length < 8)
79
84
  return '******';
@@ -248,11 +253,11 @@ async function runSetup() {
248
253
  ...notifyConfig
249
254
  };
250
255
  try {
251
- if (!fs.existsSync(GLOBAL_CONFIG_DIR)) {
252
- fs.mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true });
256
+ if (!fs.existsSync(targetDir)) {
257
+ fs.mkdirSync(targetDir, { recursive: true });
253
258
  }
254
- fs.writeFileSync(GLOBAL_CONFIG_FILE, JSON.stringify(newConfig, null, 2), { mode: 0o600 });
255
- console.log(chalk.green(`\nāœ… Configuration saved to ${GLOBAL_CONFIG_FILE}`));
259
+ fs.writeFileSync(targetFile, JSON.stringify(newConfig, null, 2), { mode: 0o600 });
260
+ console.log(chalk.green(`\nāœ… Configuration saved to ${targetFile}`));
256
261
  console.log(chalk.cyan("You can now run 'autoclaw' to start using the agent."));
257
262
  }
258
263
  catch (error) {
@@ -347,20 +352,16 @@ async function runChat(queryParts, options) {
347
352
  }
348
353
  }
349
354
  // Main chat loop
350
- const rl = createInterface({ input, output });
351
355
  try {
352
356
  while (true) {
353
- let userInput;
354
- try {
355
- userInput = await rl.question(chalk.green('? ') + 'You > ');
356
- }
357
- catch (err) {
358
- if (err.code === 'ABORT_ERR') {
359
- console.log(chalk.cyan("\nGoodbye!"));
360
- break;
357
+ const { userInput } = await inquirer.prompt([
358
+ {
359
+ type: 'input',
360
+ name: 'userInput',
361
+ message: 'You >',
362
+ prefix: chalk.green('?')
361
363
  }
362
- throw err;
363
- }
364
+ ]);
364
365
  if (userInput.toLowerCase() === 'exit' || userInput.toLowerCase() === 'quit') {
365
366
  console.log(chalk.cyan("Goodbye!"));
366
367
  break;
@@ -371,17 +372,13 @@ async function runChat(queryParts, options) {
371
372
  }
372
373
  }
373
374
  catch (err) {
374
- if (err.name === 'AbortError' || err.code === 'ABORT_ERR') {
375
- // Handled inside loop mostly, but just in case
375
+ if (err.message && (err.message.includes('User force closed') || err.message.includes('Prompt was canceled'))) {
376
376
  console.log(chalk.cyan("\nGoodbye!"));
377
377
  }
378
378
  else {
379
379
  console.error(chalk.red("Error in chat loop:"), err);
380
380
  }
381
381
  }
382
- finally {
383
- rl.close();
384
- }
385
382
  }
386
383
  // Global error handler
387
384
  main().catch(err => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoclaw",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {