olly-molly 0.3.66 → 0.3.68
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/README.md +1 -1
- package/bin/cli.js +71 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/cli.js
CHANGED
|
@@ -21,6 +21,8 @@ const CLI_OPTIONS = {
|
|
|
21
21
|
// Data/path settings
|
|
22
22
|
'data-dir': { type: 'string', short: 'd' },
|
|
23
23
|
'db-path': { type: 'string' },
|
|
24
|
+
// API key
|
|
25
|
+
'api-key': { type: 'string' },
|
|
24
26
|
// Development/debugging
|
|
25
27
|
dev: { type: 'boolean', default: false },
|
|
26
28
|
verbose: { type: 'boolean', short: 'v', default: false },
|
|
@@ -70,6 +72,9 @@ DATA/PATH SETTINGS
|
|
|
70
72
|
-d, --data-dir <path> App data directory (default: ~/.olly-molly)
|
|
71
73
|
--db-path <path> Database path (default: <data-dir>/db)
|
|
72
74
|
|
|
75
|
+
API SETTINGS
|
|
76
|
+
--api-key <key> Anthropic API key (saved to ~/.olly-molly/.env)
|
|
77
|
+
|
|
73
78
|
DEVELOPMENT
|
|
74
79
|
--dev Run in development mode (next dev)
|
|
75
80
|
-v, --verbose Enable verbose logging
|
|
@@ -90,7 +95,10 @@ ENVIRONMENT VARIABLES
|
|
|
90
95
|
OLLY_MOLLY_DATA_DIR App data directory (fallback)
|
|
91
96
|
OLLY_MOLLY_DB_PATH Database path (fallback)
|
|
92
97
|
|
|
98
|
+
ANTHROPIC_API_KEY Anthropic API key (required for AI agents)
|
|
99
|
+
|
|
93
100
|
You can also create ~/.olly-molly/.env file:
|
|
101
|
+
ANTHROPIC_API_KEY=sk-ant-api03-xxxxx
|
|
94
102
|
AWS_REGION=ap-northeast-2
|
|
95
103
|
AWS_ACCESS_KEY_ID=your-key
|
|
96
104
|
AWS_SECRET_ACCESS_KEY=your-secret
|
|
@@ -254,7 +262,8 @@ async function handleExportDb(exportPath, config) {
|
|
|
254
262
|
}
|
|
255
263
|
|
|
256
264
|
// Create tar.gz
|
|
257
|
-
|
|
265
|
+
const forceLocal = process.platform === 'win32' ? ' --force-local' : '';
|
|
266
|
+
execSync(`tar -czf "${absPath}" -C "${tmpDir}" .${forceLocal}`, { stdio: 'pipe' });
|
|
258
267
|
console.log(`✅ Database exported to: ${absPath}`);
|
|
259
268
|
} finally {
|
|
260
269
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
@@ -293,7 +302,8 @@ async function handleImportDb(importPath, config) {
|
|
|
293
302
|
// Extract to temp dir first to validate
|
|
294
303
|
const tmpDir = path.join(os.tmpdir(), `olly-molly-import-${Date.now()}`);
|
|
295
304
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
296
|
-
|
|
305
|
+
const forceLocal2 = process.platform === 'win32' ? ' --force-local' : '';
|
|
306
|
+
execSync(`tar -xzf "${absPath}" -C "${tmpDir}"${forceLocal2}`, { stdio: 'pipe' });
|
|
297
307
|
|
|
298
308
|
// Check if valid export
|
|
299
309
|
const hasDb = fs.existsSync(path.join(tmpDir, 'db'));
|
|
@@ -454,7 +464,8 @@ function download(url, destDir, { allowNotFound = false, stripComponents = 1 } =
|
|
|
454
464
|
file.close();
|
|
455
465
|
fs.mkdirSync(destDir, { recursive: true });
|
|
456
466
|
const stripArg = stripComponents > 0 ? ` --strip-components=${stripComponents}` : '';
|
|
457
|
-
|
|
467
|
+
const forceLocal = process.platform === 'win32' ? ' --force-local' : '';
|
|
468
|
+
execSync(`tar -xzf "${tmp}" -C "${destDir}"${stripArg}${forceLocal}`, { stdio: 'pipe' });
|
|
458
469
|
fs.unlinkSync(tmp);
|
|
459
470
|
resolve(true);
|
|
460
471
|
});
|
|
@@ -555,6 +566,60 @@ function restoreUserData(backupDir, config) {
|
|
|
555
566
|
fs.rmSync(backupDir, { recursive: true, force: true });
|
|
556
567
|
}
|
|
557
568
|
|
|
569
|
+
// Ensure ANTHROPIC_API_KEY exists: CLI arg → env → .env file → prompt user
|
|
570
|
+
async function ensureApiKey(config) {
|
|
571
|
+
// 1. --api-key flag: save to .env and set in process.env
|
|
572
|
+
if (args['api-key']) {
|
|
573
|
+
saveApiKeyToEnv(config.APP_DIR, args['api-key']);
|
|
574
|
+
process.env.ANTHROPIC_API_KEY = args['api-key'];
|
|
575
|
+
console.log('✅ API key saved to ~/.olly-molly/.env\n');
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// 2. Already available via env or .env file
|
|
580
|
+
if (process.env.ANTHROPIC_API_KEY) return;
|
|
581
|
+
|
|
582
|
+
// 3. Prompt user
|
|
583
|
+
const readline = require('readline');
|
|
584
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
585
|
+
|
|
586
|
+
console.log('🔑 Anthropic API key is required to run AI agents.');
|
|
587
|
+
console.log(' Get one at: https://console.anthropic.com/settings/keys\n');
|
|
588
|
+
|
|
589
|
+
const key = await new Promise((resolve) => {
|
|
590
|
+
rl.question('Enter your API key (sk-ant-...): ', (answer) => {
|
|
591
|
+
rl.close();
|
|
592
|
+
resolve(answer.trim());
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
if (!key) {
|
|
597
|
+
console.error('❌ No API key provided. Exiting.');
|
|
598
|
+
process.exit(1);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
saveApiKeyToEnv(config.APP_DIR, key);
|
|
602
|
+
process.env.ANTHROPIC_API_KEY = key;
|
|
603
|
+
console.log('\n✅ API key saved to ~/.olly-molly/.env\n');
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function saveApiKeyToEnv(appDir, apiKey) {
|
|
607
|
+
fs.mkdirSync(appDir, { recursive: true });
|
|
608
|
+
const envPath = path.join(appDir, '.env');
|
|
609
|
+
|
|
610
|
+
if (fs.existsSync(envPath)) {
|
|
611
|
+
let content = fs.readFileSync(envPath, 'utf8');
|
|
612
|
+
if (/^ANTHROPIC_API_KEY=.*/m.test(content)) {
|
|
613
|
+
content = content.replace(/^ANTHROPIC_API_KEY=.*/m, `ANTHROPIC_API_KEY=${apiKey}`);
|
|
614
|
+
} else {
|
|
615
|
+
content = `ANTHROPIC_API_KEY=${apiKey}\n${content}`;
|
|
616
|
+
}
|
|
617
|
+
fs.writeFileSync(envPath, content);
|
|
618
|
+
} else {
|
|
619
|
+
fs.writeFileSync(envPath, `ANTHROPIC_API_KEY=${apiKey}\n`);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
558
623
|
async function main() {
|
|
559
624
|
console.log('\n🐙 Olly Molly\n');
|
|
560
625
|
|
|
@@ -582,6 +647,9 @@ async function main() {
|
|
|
582
647
|
process.exit(0);
|
|
583
648
|
}
|
|
584
649
|
|
|
650
|
+
// Ensure API key is configured
|
|
651
|
+
await ensureApiKey(config);
|
|
652
|
+
|
|
585
653
|
// Handle dev mode
|
|
586
654
|
if (config.DEV_MODE) {
|
|
587
655
|
await handleDevMode(config);
|