juno-code 1.0.19 → 1.0.22

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,94 @@ 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
+ if (semver__default.default.gt(packageVersion, installedVersion)) {
405
+ return true;
406
+ }
407
+ if (semver__default.default.eq(packageVersion, installedVersion)) {
408
+ const codexExists = await fs3__default.default.pathExists(path3__namespace.join(this.SERVICES_DIR, "codex.py"));
409
+ const claudeExists = await fs3__default.default.pathExists(path3__namespace.join(this.SERVICES_DIR, "claude.py"));
410
+ if (!codexExists || !claudeExists) {
411
+ return true;
412
+ }
413
+ try {
414
+ const packageServicesDir = this.getPackageServicesDir();
415
+ const packageCodex = path3__namespace.join(packageServicesDir, "codex.py");
416
+ const packageClaude = path3__namespace.join(packageServicesDir, "claude.py");
417
+ const packageCodexExists = await fs3__default.default.pathExists(packageCodex);
418
+ const packageClaudeExists = await fs3__default.default.pathExists(packageClaude);
419
+ if (packageCodexExists || packageClaudeExists) {
420
+ const isDevelopment2 = packageServicesDir.includes("/src/");
421
+ if (isDevelopment2) {
422
+ return true;
423
+ }
424
+ }
425
+ } catch {
426
+ }
427
+ }
428
+ return false;
429
+ } catch {
430
+ return true;
431
+ }
432
+ }
343
433
  /**
344
434
  * Get the path to the services directory in the package
345
435
  */
@@ -357,8 +447,9 @@ var init_service_installer = __esm({
357
447
  }
358
448
  /**
359
449
  * Install all service scripts to ~/.juno_code/services/
450
+ * @param silent - If true, suppresses console output
360
451
  */
361
- static async install() {
452
+ static async install(silent = false) {
362
453
  try {
363
454
  await fs3__default.default.ensureDir(this.SERVICES_DIR);
364
455
  const packageServicesDir = this.getPackageServicesDir();
@@ -374,11 +465,45 @@ var init_service_installer = __esm({
374
465
  await fs3__default.default.chmod(filePath, 493);
375
466
  }
376
467
  }
377
- console.log(`\u2713 Services installed to: ${this.SERVICES_DIR}`);
468
+ await this.saveVersion();
469
+ if (!silent) {
470
+ console.log(`\u2713 Services installed to: ${this.SERVICES_DIR}`);
471
+ }
378
472
  } catch (error) {
379
473
  throw new Error(`Failed to install services: ${error instanceof Error ? error.message : String(error)}`);
380
474
  }
381
475
  }
476
+ /**
477
+ * Automatically update services if needed (silent operation)
478
+ * This should be called on every CLI run to ensure services are up-to-date
479
+ */
480
+ static async autoUpdate() {
481
+ try {
482
+ const debug = process.env.JUNO_CODE_DEBUG === "1";
483
+ if (debug) {
484
+ const packageVersion = this.getPackageVersion();
485
+ const installedVersion = await this.getInstalledVersion();
486
+ console.error(`[DEBUG] Package version: ${packageVersion}, Installed version: ${installedVersion || "not found"}`);
487
+ }
488
+ const needsUpdate = await this.needsUpdate();
489
+ if (debug) {
490
+ console.error(`[DEBUG] Needs update: ${needsUpdate}`);
491
+ }
492
+ if (needsUpdate) {
493
+ await this.install(true);
494
+ if (debug) {
495
+ console.error(`[DEBUG] Service scripts updated successfully`);
496
+ }
497
+ return true;
498
+ }
499
+ return false;
500
+ } catch (error) {
501
+ if (process.env.JUNO_CODE_DEBUG === "1") {
502
+ console.error("[DEBUG] autoUpdate error:", error instanceof Error ? error.message : String(error));
503
+ }
504
+ return false;
505
+ }
506
+ }
382
507
  /**
383
508
  * Check if services are installed
384
509
  */
@@ -12720,11 +12845,23 @@ var init_main = __esm({
12720
12845
  return;
12721
12846
  }
12722
12847
  }
12723
- const content = event.content.length > 100 ? event.content.substring(0, 100) + "..." : event.content;
12724
- if (this.verbose) {
12725
- console.error(chalk12__default.default.gray(`[${timestamp}] ${event.type}: ${content}`));
12726
- } else {
12727
- console.error(chalk12__default.default.blue(`\u{1F4E1} ${event.type}: ${content}`));
12848
+ try {
12849
+ const jsonObj = JSON.parse(event.content);
12850
+ const formattedJson = this.colorizeJson(jsonObj);
12851
+ const backend = event.backend ? chalk12__default.default.cyan(`[${event.backend}]`) : "";
12852
+ if (this.verbose) {
12853
+ console.error(`${chalk12__default.default.gray(timestamp)} ${backend} ${formattedJson}`);
12854
+ } else {
12855
+ console.error(`${backend} ${formattedJson}`);
12856
+ }
12857
+ return;
12858
+ } catch (error) {
12859
+ const backend = event.backend ? `[${event.backend}]` : "";
12860
+ if (this.verbose) {
12861
+ console.error(chalk12__default.default.gray(`[${timestamp}] ${backend} ${event.type}: ${event.content}`));
12862
+ } else {
12863
+ console.error(`${backend} ${chalk12__default.default.blue(`${event.type}:`)} ${event.content}`);
12864
+ }
12728
12865
  }
12729
12866
  }
12730
12867
  /**
@@ -25061,6 +25198,17 @@ function configureEnvironment() {
25061
25198
  async function main() {
25062
25199
  const program = new commander.Command();
25063
25200
  configureEnvironment();
25201
+ try {
25202
+ const { ServiceInstaller: ServiceInstaller2 } = await Promise.resolve().then(() => (init_service_installer(), service_installer_exports));
25203
+ const updated = await ServiceInstaller2.autoUpdate();
25204
+ if (updated && (process.argv.includes("--verbose") || process.argv.includes("-v") || process.env.JUNO_CODE_DEBUG === "1")) {
25205
+ console.error("[DEBUG] Service scripts auto-updated to latest version");
25206
+ }
25207
+ } catch (error) {
25208
+ if (process.env.JUNO_CODE_DEBUG === "1") {
25209
+ console.error("[DEBUG] Service auto-update failed:", error instanceof Error ? error.message : String(error));
25210
+ }
25211
+ }
25064
25212
  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
25213
  setupGlobalOptions(program);
25066
25214
  const isVerbose = process.argv.includes("--verbose") || process.argv.includes("-v");