autoclaw 1.0.30 → 1.0.31

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 +16 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -59,8 +59,9 @@ program
59
59
  program
60
60
  .command('setup')
61
61
  .description('Run the interactive setup wizard to configure API keys')
62
- .action(async () => {
63
- await runSetup();
62
+ .option('-p, --project', 'Save configuration to project-level (.autoclaw/setting.json)')
63
+ .action(async (options) => {
64
+ await runSetup(options);
64
65
  });
65
66
  program
66
67
  .command('chat [query...]', { isDefault: true })
@@ -70,10 +71,16 @@ program
70
71
  await runChat(queryParts, options);
71
72
  });
72
73
  program.parse(process.argv);
73
- async function runSetup() {
74
+ async function runSetup(options = {}) {
75
+ const isProject = options.project;
76
+ const targetFile = isProject ? LOCAL_CONFIG_FILE : GLOBAL_CONFIG_FILE;
77
+ const targetDir = isProject ? path.join(process.cwd(), '.autoclaw') : GLOBAL_CONFIG_DIR;
74
78
  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);
79
+ console.log(chalk.dim(`Config will be saved to: ${targetFile}`));
80
+ // Load both to show current effective values as defaults
81
+ const globalConfig = loadJsonConfig(GLOBAL_CONFIG_FILE);
82
+ const localConfig = loadJsonConfig(LOCAL_CONFIG_FILE);
83
+ const currentConfig = { ...globalConfig, ...localConfig };
77
84
  function maskSecret(secret) {
78
85
  if (!secret || secret.length < 8)
79
86
  return '******';
@@ -248,11 +255,11 @@ async function runSetup() {
248
255
  ...notifyConfig
249
256
  };
250
257
  try {
251
- if (!fs.existsSync(GLOBAL_CONFIG_DIR)) {
252
- fs.mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true });
258
+ if (!fs.existsSync(targetDir)) {
259
+ fs.mkdirSync(targetDir, { recursive: true });
253
260
  }
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}`));
261
+ fs.writeFileSync(targetFile, JSON.stringify(newConfig, null, 2), { mode: 0o600 });
262
+ console.log(chalk.green(`\nāœ… Configuration saved to ${targetFile}`));
256
263
  console.log(chalk.cyan("You can now run 'autoclaw' to start using the agent."));
257
264
  }
258
265
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoclaw",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {