juno-code 1.0.19 → 1.0.20

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/bin/cli.js CHANGED
@@ -5,6 +5,8 @@ var fs3 = require('fs-extra');
5
5
  var path3 = require('path');
6
6
  var os2 = require('os');
7
7
  var url = require('url');
8
+ var module$1 = require('module');
9
+ var semver = require('semver');
8
10
  var zod = require('zod');
9
11
  var nodeFs = require('fs');
10
12
  var yaml = require('js-yaml');
@@ -28,7 +30,6 @@ var uuid = require('uuid');
28
30
  var whichPkg = require('which');
29
31
  var glob = require('glob');
30
32
  var fastGlob = require('fast-glob');
31
- var module$1 = require('module');
32
33
 
33
34
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
34
35
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -54,6 +55,7 @@ function _interopNamespace(e) {
54
55
  var fs3__default = /*#__PURE__*/_interopDefault(fs3);
55
56
  var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
56
57
  var os2__namespace = /*#__PURE__*/_interopNamespace(os2);
58
+ var semver__default = /*#__PURE__*/_interopDefault(semver);
57
59
  var nodeFs__namespace = /*#__PURE__*/_interopNamespace(nodeFs);
58
60
  var yaml__namespace = /*#__PURE__*/_interopNamespace(yaml);
59
61
  var Table__default = /*#__PURE__*/_interopDefault(Table);
@@ -340,6 +342,70 @@ var init_service_installer = __esm({
340
342
  init_version();
341
343
  ServiceInstaller = class {
342
344
  static SERVICES_DIR = path3__namespace.join(os2.homedir(), ".juno_code", "services");
345
+ static VERSION_FILE = path3__namespace.join(os2.homedir(), ".juno_code", "services", ".version");
346
+ /**
347
+ * Get the current package version
348
+ */
349
+ static getPackageVersion() {
350
+ try {
351
+ const __dirname2 = path3__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href))));
352
+ const require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
353
+ let packageJsonPath = path3__namespace.join(__dirname2, "..", "..", "package.json");
354
+ if (fs3__default.default.existsSync(packageJsonPath)) {
355
+ const packageJson2 = require3(packageJsonPath);
356
+ return packageJson2.version;
357
+ }
358
+ packageJsonPath = path3__namespace.join(__dirname2, "..", "..", "..", "package.json");
359
+ if (fs3__default.default.existsSync(packageJsonPath)) {
360
+ const packageJson2 = require3(packageJsonPath);
361
+ return packageJson2.version;
362
+ }
363
+ return "0.0.0";
364
+ } catch {
365
+ return "0.0.0";
366
+ }
367
+ }
368
+ /**
369
+ * Get the installed services version
370
+ */
371
+ static async getInstalledVersion() {
372
+ try {
373
+ const exists = await fs3__default.default.pathExists(this.VERSION_FILE);
374
+ if (!exists) {
375
+ return null;
376
+ }
377
+ const version3 = await fs3__default.default.readFile(this.VERSION_FILE, "utf-8");
378
+ return version3.trim();
379
+ } catch {
380
+ return null;
381
+ }
382
+ }
383
+ /**
384
+ * Save the current package version to the version file
385
+ */
386
+ static async saveVersion() {
387
+ const version3 = this.getPackageVersion();
388
+ await fs3__default.default.writeFile(this.VERSION_FILE, version3, "utf-8");
389
+ }
390
+ /**
391
+ * Check if services need to be updated based on version
392
+ */
393
+ static async needsUpdate() {
394
+ try {
395
+ const packageVersion = this.getPackageVersion();
396
+ const installedVersion = await this.getInstalledVersion();
397
+ if (!installedVersion) {
398
+ return true;
399
+ }
400
+ const exists = await fs3__default.default.pathExists(this.SERVICES_DIR);
401
+ if (!exists) {
402
+ return true;
403
+ }
404
+ return semver__default.default.gt(packageVersion, installedVersion);
405
+ } catch {
406
+ return true;
407
+ }
408
+ }
343
409
  /**
344
410
  * Get the path to the services directory in the package
345
411
  */
@@ -357,8 +423,9 @@ var init_service_installer = __esm({
357
423
  }
358
424
  /**
359
425
  * Install all service scripts to ~/.juno_code/services/
426
+ * @param silent - If true, suppresses console output
360
427
  */
361
- static async install() {
428
+ static async install(silent = false) {
362
429
  try {
363
430
  await fs3__default.default.ensureDir(this.SERVICES_DIR);
364
431
  const packageServicesDir = this.getPackageServicesDir();
@@ -374,11 +441,30 @@ var init_service_installer = __esm({
374
441
  await fs3__default.default.chmod(filePath, 493);
375
442
  }
376
443
  }
377
- console.log(`\u2713 Services installed to: ${this.SERVICES_DIR}`);
444
+ await this.saveVersion();
445
+ if (!silent) {
446
+ console.log(`\u2713 Services installed to: ${this.SERVICES_DIR}`);
447
+ }
378
448
  } catch (error) {
379
449
  throw new Error(`Failed to install services: ${error instanceof Error ? error.message : String(error)}`);
380
450
  }
381
451
  }
452
+ /**
453
+ * Automatically update services if needed (silent operation)
454
+ * This should be called on every CLI run to ensure services are up-to-date
455
+ */
456
+ static async autoUpdate() {
457
+ try {
458
+ const needsUpdate = await this.needsUpdate();
459
+ if (needsUpdate) {
460
+ await this.install(true);
461
+ return true;
462
+ }
463
+ return false;
464
+ } catch {
465
+ return false;
466
+ }
467
+ }
382
468
  /**
383
469
  * Check if services are installed
384
470
  */
@@ -25061,6 +25147,11 @@ function configureEnvironment() {
25061
25147
  async function main() {
25062
25148
  const program = new commander.Command();
25063
25149
  configureEnvironment();
25150
+ try {
25151
+ const { ServiceInstaller: ServiceInstaller2 } = await Promise.resolve().then(() => (init_service_installer(), service_installer_exports));
25152
+ await ServiceInstaller2.autoUpdate();
25153
+ } catch {
25154
+ }
25064
25155
  program.name("juno-code").description("TypeScript implementation of juno-code CLI tool for AI subagent orchestration").version(VERSION, "-V, --version", "Display version information").helpOption("-h, --help", "Display help information");
25065
25156
  setupGlobalOptions(program);
25066
25157
  const isVerbose = process.argv.includes("--verbose") || process.argv.includes("-v");