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.
- package/dist/index.js +16 -9
- 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
|
-
.
|
|
63
|
-
|
|
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: ${
|
|
76
|
-
|
|
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(
|
|
252
|
-
fs.mkdirSync(
|
|
258
|
+
if (!fs.existsSync(targetDir)) {
|
|
259
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
253
260
|
}
|
|
254
|
-
fs.writeFileSync(
|
|
255
|
-
console.log(chalk.green(`\nā
Configuration saved to ${
|
|
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) {
|