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.mjs CHANGED
@@ -5,6 +5,8 @@ import path3__default, { dirname, join } from 'path';
5
5
  import * as os2 from 'os';
6
6
  import os2__default, { homedir, EOL } from 'os';
7
7
  import { fileURLToPath } from 'url';
8
+ import { createRequire } from 'module';
9
+ import semver from 'semver';
8
10
  import { z } from 'zod';
9
11
  import * as nodeFs from 'fs';
10
12
  import { promises } from 'fs';
@@ -30,7 +32,6 @@ import { v4 } from 'uuid';
30
32
  import whichPkg from 'which';
31
33
  import { glob } from 'glob';
32
34
  import fastGlob from 'fast-glob';
33
- import { createRequire } from 'module';
34
35
 
35
36
  var __defProp = Object.defineProperty;
36
37
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -306,6 +307,70 @@ var init_service_installer = __esm({
306
307
  init_version();
307
308
  ServiceInstaller = class {
308
309
  static SERVICES_DIR = path3.join(homedir(), ".juno_code", "services");
310
+ static VERSION_FILE = path3.join(homedir(), ".juno_code", "services", ".version");
311
+ /**
312
+ * Get the current package version
313
+ */
314
+ static getPackageVersion() {
315
+ try {
316
+ const __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
317
+ const require3 = createRequire(import.meta.url);
318
+ let packageJsonPath = path3.join(__dirname2, "..", "..", "package.json");
319
+ if (fs3.existsSync(packageJsonPath)) {
320
+ const packageJson2 = require3(packageJsonPath);
321
+ return packageJson2.version;
322
+ }
323
+ packageJsonPath = path3.join(__dirname2, "..", "..", "..", "package.json");
324
+ if (fs3.existsSync(packageJsonPath)) {
325
+ const packageJson2 = require3(packageJsonPath);
326
+ return packageJson2.version;
327
+ }
328
+ return "0.0.0";
329
+ } catch {
330
+ return "0.0.0";
331
+ }
332
+ }
333
+ /**
334
+ * Get the installed services version
335
+ */
336
+ static async getInstalledVersion() {
337
+ try {
338
+ const exists = await fs3.pathExists(this.VERSION_FILE);
339
+ if (!exists) {
340
+ return null;
341
+ }
342
+ const version3 = await fs3.readFile(this.VERSION_FILE, "utf-8");
343
+ return version3.trim();
344
+ } catch {
345
+ return null;
346
+ }
347
+ }
348
+ /**
349
+ * Save the current package version to the version file
350
+ */
351
+ static async saveVersion() {
352
+ const version3 = this.getPackageVersion();
353
+ await fs3.writeFile(this.VERSION_FILE, version3, "utf-8");
354
+ }
355
+ /**
356
+ * Check if services need to be updated based on version
357
+ */
358
+ static async needsUpdate() {
359
+ try {
360
+ const packageVersion = this.getPackageVersion();
361
+ const installedVersion = await this.getInstalledVersion();
362
+ if (!installedVersion) {
363
+ return true;
364
+ }
365
+ const exists = await fs3.pathExists(this.SERVICES_DIR);
366
+ if (!exists) {
367
+ return true;
368
+ }
369
+ return semver.gt(packageVersion, installedVersion);
370
+ } catch {
371
+ return true;
372
+ }
373
+ }
309
374
  /**
310
375
  * Get the path to the services directory in the package
311
376
  */
@@ -323,8 +388,9 @@ var init_service_installer = __esm({
323
388
  }
324
389
  /**
325
390
  * Install all service scripts to ~/.juno_code/services/
391
+ * @param silent - If true, suppresses console output
326
392
  */
327
- static async install() {
393
+ static async install(silent = false) {
328
394
  try {
329
395
  await fs3.ensureDir(this.SERVICES_DIR);
330
396
  const packageServicesDir = this.getPackageServicesDir();
@@ -340,11 +406,30 @@ var init_service_installer = __esm({
340
406
  await fs3.chmod(filePath, 493);
341
407
  }
342
408
  }
343
- console.log(`\u2713 Services installed to: ${this.SERVICES_DIR}`);
409
+ await this.saveVersion();
410
+ if (!silent) {
411
+ console.log(`\u2713 Services installed to: ${this.SERVICES_DIR}`);
412
+ }
344
413
  } catch (error) {
345
414
  throw new Error(`Failed to install services: ${error instanceof Error ? error.message : String(error)}`);
346
415
  }
347
416
  }
417
+ /**
418
+ * Automatically update services if needed (silent operation)
419
+ * This should be called on every CLI run to ensure services are up-to-date
420
+ */
421
+ static async autoUpdate() {
422
+ try {
423
+ const needsUpdate = await this.needsUpdate();
424
+ if (needsUpdate) {
425
+ await this.install(true);
426
+ return true;
427
+ }
428
+ return false;
429
+ } catch {
430
+ return false;
431
+ }
432
+ }
348
433
  /**
349
434
  * Check if services are installed
350
435
  */
@@ -25027,6 +25112,11 @@ function configureEnvironment() {
25027
25112
  async function main() {
25028
25113
  const program = new Command();
25029
25114
  configureEnvironment();
25115
+ try {
25116
+ const { ServiceInstaller: ServiceInstaller2 } = await Promise.resolve().then(() => (init_service_installer(), service_installer_exports));
25117
+ await ServiceInstaller2.autoUpdate();
25118
+ } catch {
25119
+ }
25030
25120
  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");
25031
25121
  setupGlobalOptions(program);
25032
25122
  const isVerbose = process.argv.includes("--verbose") || process.argv.includes("-v");