@ducci/jarvis 1.0.48 → 1.0.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducci/jarvis",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -3,9 +3,25 @@
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import os from 'os';
6
+ import { spawnSync } from 'child_process';
7
+ import { createRequire } from 'module';
6
8
  import inquirer from 'inquirer';
7
9
  import chalk from 'chalk';
8
10
 
11
+ // Resolve pm2 CLI from local node_modules so it works even when pm2 is not in PATH
12
+ // (e.g. when Node is managed by NVM and the shell is not initialised with it).
13
+ const _require = createRequire(import.meta.url);
14
+ let PM2_BIN;
15
+ try {
16
+ PM2_BIN = _require.resolve('pm2/bin/pm2');
17
+ } catch {
18
+ PM2_BIN = null; // will fall back gracefully
19
+ }
20
+ function pm2(...args) {
21
+ if (!PM2_BIN) return { status: 1, error: new Error('pm2 binary not found') };
22
+ return spawnSync(process.execPath, [PM2_BIN, ...args], { stdio: 'inherit' });
23
+ }
24
+
9
25
  const jarvisDir = path.join(os.homedir(), '.jarvis');
10
26
  const envFile = path.join(jarvisDir, '.env');
11
27
  const configDir = path.join(jarvisDir, 'data', 'config');
@@ -420,6 +436,37 @@ async function run() {
420
436
  }
421
437
  }
422
438
 
439
+ // --- LOG ROTATION STEP ---
440
+ const logrotateModuleDir = path.join(os.homedir(), '.pm2', 'modules', 'pm2-logrotate');
441
+ const logrotateInstalled = fs.existsSync(logrotateModuleDir);
442
+
443
+ if (logrotateInstalled) {
444
+ console.log(chalk.green('pm2-logrotate is already installed — server.log will be rotated automatically.'));
445
+ } else {
446
+ const { setupLogrotate } = await inquirer.prompt([
447
+ {
448
+ type: 'confirm',
449
+ name: 'setupLogrotate',
450
+ message: 'Install pm2-logrotate to prevent server.log from growing indefinitely?',
451
+ default: true,
452
+ }
453
+ ]);
454
+
455
+ if (setupLogrotate) {
456
+ console.log(chalk.blue('Installing pm2-logrotate...'));
457
+ const install = pm2('install', 'pm2-logrotate');
458
+ if (install.status !== 0) {
459
+ console.log(chalk.yellow('Installation failed — try running `pm2 install pm2-logrotate` manually.'));
460
+ } else {
461
+ pm2('set', 'pm2-logrotate:max_size', '10M');
462
+ pm2('set', 'pm2-logrotate:retain', '5');
463
+ pm2('set', 'pm2-logrotate:compress', 'true');
464
+ pm2('set', 'pm2-logrotate:rotateInterval', '0 0 * * *');
465
+ console.log(chalk.green('pm2-logrotate installed: 10 MB max, 5 rotated files kept, daily rotation.'));
466
+ }
467
+ }
468
+ }
469
+
423
470
  console.log(chalk.green.bold('\nSetup complete!'));
424
471
  }
425
472