juno-code 1.0.20 → 1.0.23

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
@@ -401,7 +401,31 @@ var init_service_installer = __esm({
401
401
  if (!exists) {
402
402
  return true;
403
403
  }
404
- return semver__default.default.gt(packageVersion, installedVersion);
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;
405
429
  } catch {
406
430
  return true;
407
431
  }
@@ -455,13 +479,28 @@ var init_service_installer = __esm({
455
479
  */
456
480
  static async autoUpdate() {
457
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
+ }
458
488
  const needsUpdate = await this.needsUpdate();
489
+ if (debug) {
490
+ console.error(`[DEBUG] Needs update: ${needsUpdate}`);
491
+ }
459
492
  if (needsUpdate) {
460
493
  await this.install(true);
494
+ if (debug) {
495
+ console.error(`[DEBUG] Service scripts updated successfully`);
496
+ }
461
497
  return true;
462
498
  }
463
499
  return false;
464
- } catch {
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
+ }
465
504
  return false;
466
505
  }
467
506
  }
@@ -6457,6 +6496,8 @@ var init_shell_backend = __esm({
6457
6496
  eventCounter = 0;
6458
6497
  jsonBuffer = "";
6459
6498
  // Buffer for handling partial JSON objects
6499
+ logFilePath = null;
6500
+ // Path to current log file
6460
6501
  /**
6461
6502
  * Configure the shell backend
6462
6503
  */
@@ -6488,6 +6529,15 @@ var init_shell_backend = __esm({
6488
6529
  }
6489
6530
  const startTime = Date.now();
6490
6531
  const toolId = `shell_${request.toolName}_${startTime}`;
6532
+ const subagentType = this.extractSubagentFromToolName(request.toolName);
6533
+ try {
6534
+ this.logFilePath = await this.createLogFile(subagentType);
6535
+ } catch (error) {
6536
+ if (this.config.debug) {
6537
+ engineLogger.warn(`Failed to create log file, continuing without file logging: ${error instanceof Error ? error.message : String(error)}`);
6538
+ }
6539
+ this.logFilePath = null;
6540
+ }
6491
6541
  await this.emitProgressEvent({
6492
6542
  sessionId: request.metadata?.sessionId || "unknown",
6493
6543
  timestamp: /* @__PURE__ */ new Date(),
@@ -6503,7 +6553,6 @@ var init_shell_backend = __esm({
6503
6553
  }
6504
6554
  });
6505
6555
  try {
6506
- const subagentType = this.extractSubagentFromToolName(request.toolName);
6507
6556
  const scriptPath = await this.findScriptForSubagent(subagentType);
6508
6557
  const result = await this.executeScript(scriptPath, request, toolId);
6509
6558
  const duration = Date.now() - startTime;
@@ -6593,6 +6642,46 @@ var init_shell_backend = __esm({
6593
6642
  // =============================================================================
6594
6643
  // Private Implementation Methods
6595
6644
  // =============================================================================
6645
+ /**
6646
+ * Create log file path and ensure log directory exists
6647
+ */
6648
+ async createLogFile(subagentName) {
6649
+ const now = /* @__PURE__ */ new Date();
6650
+ const timestamp = now.getFullYear().toString() + (now.getMonth() + 1).toString().padStart(2, "0") + now.getDate().toString().padStart(2, "0") + "_" + now.getHours().toString().padStart(2, "0") + now.getMinutes().toString().padStart(2, "0") + now.getSeconds().toString().padStart(2, "0");
6651
+ const logDir = path3__namespace.join(this.config.workingDirectory, ".juno_task", "logs");
6652
+ try {
6653
+ await fs3__default.default.ensureDir(logDir);
6654
+ } catch (error) {
6655
+ if (this.config?.debug) {
6656
+ engineLogger.warn(`Failed to create log directory: ${error instanceof Error ? error.message : String(error)}`);
6657
+ }
6658
+ throw new Error(`Failed to create log directory: ${logDir}`);
6659
+ }
6660
+ const logFileName = `${subagentName}_shell_${timestamp}.log`;
6661
+ const logFilePath = path3__namespace.join(logDir, logFileName);
6662
+ if (this.config?.debug) {
6663
+ engineLogger.debug(`Created log file path: ${logFilePath}`);
6664
+ }
6665
+ return logFilePath;
6666
+ }
6667
+ /**
6668
+ * Write log entry to file
6669
+ */
6670
+ async writeToLogFile(message) {
6671
+ if (!this.logFilePath) {
6672
+ return;
6673
+ }
6674
+ try {
6675
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
6676
+ const logEntry = `[${timestamp}] ${message}
6677
+ `;
6678
+ await fs3__default.default.appendFile(this.logFilePath, logEntry, "utf-8");
6679
+ } catch (error) {
6680
+ if (this.config?.debug) {
6681
+ engineLogger.warn(`Failed to write to log file: ${error instanceof Error ? error.message : String(error)}`);
6682
+ }
6683
+ }
6684
+ }
6596
6685
  /**
6597
6686
  * Extract subagent type from tool name
6598
6687
  */
@@ -7003,6 +7092,10 @@ var init_shell_backend = __esm({
7003
7092
  * Emit progress event to all callbacks
7004
7093
  */
7005
7094
  async emitProgressEvent(event) {
7095
+ if (this.logFilePath) {
7096
+ const logMessage = `[${event.type}] ${event.content}${event.metadata ? " | metadata: " + JSON.stringify(event.metadata) : ""}`;
7097
+ await this.writeToLogFile(logMessage);
7098
+ }
7006
7099
  for (const callback of this.progressCallbacks) {
7007
7100
  try {
7008
7101
  await callback(event);
@@ -12788,8 +12881,10 @@ var init_main = __esm({
12788
12881
  }
12789
12882
  onProgress(event) {
12790
12883
  const timestamp = event.timestamp.toLocaleTimeString();
12791
- if (event.metadata?.rawJsonOutput) {
12884
+ if (event.metadata?.rawJsonOutput || event.metadata?.format === "text" && event.metadata?.raw === true) {
12792
12885
  this.hasStreamedJsonOutput = true;
12886
+ }
12887
+ if (event.metadata?.rawJsonOutput) {
12793
12888
  try {
12794
12889
  const jsonObj = JSON.parse(event.content);
12795
12890
  const formattedJson = this.colorizeJson(jsonObj);
@@ -12806,11 +12901,23 @@ var init_main = __esm({
12806
12901
  return;
12807
12902
  }
12808
12903
  }
12809
- const content = event.content.length > 100 ? event.content.substring(0, 100) + "..." : event.content;
12810
- if (this.verbose) {
12811
- console.error(chalk12__default.default.gray(`[${timestamp}] ${event.type}: ${content}`));
12812
- } else {
12813
- console.error(chalk12__default.default.blue(`\u{1F4E1} ${event.type}: ${content}`));
12904
+ try {
12905
+ const jsonObj = JSON.parse(event.content);
12906
+ const formattedJson = this.colorizeJson(jsonObj);
12907
+ const backend = event.backend ? chalk12__default.default.cyan(`[${event.backend}]`) : "";
12908
+ if (this.verbose) {
12909
+ console.error(`${chalk12__default.default.gray(timestamp)} ${backend} ${formattedJson}`);
12910
+ } else {
12911
+ console.error(`${backend} ${formattedJson}`);
12912
+ }
12913
+ return;
12914
+ } catch (error) {
12915
+ const backend = event.backend ? `[${event.backend}]` : "";
12916
+ if (this.verbose) {
12917
+ console.error(chalk12__default.default.gray(`[${timestamp}] ${backend} ${event.type}: ${event.content}`));
12918
+ } else {
12919
+ console.error(`${backend} ${chalk12__default.default.blue(`${event.type}:`)} ${event.content}`);
12920
+ }
12814
12921
  }
12815
12922
  }
12816
12923
  /**
@@ -17856,6 +17963,19 @@ var ProgressDisplay = class {
17856
17963
  return;
17857
17964
  }
17858
17965
  }
17966
+ if (event.metadata?.format === "text") {
17967
+ try {
17968
+ const jsonObj = JSON.parse(event.content);
17969
+ const formattedJson = this.colorizeJson(jsonObj);
17970
+ writeTerminalProgress(`${chalk12__default.default.gray(timestamp)} ${chalk12__default.default.cyan(backend)} ${formattedJson}
17971
+ `);
17972
+ return;
17973
+ } catch (error) {
17974
+ writeTerminalProgress(chalk12__default.default.gray(`[${timestamp}] ${backend} ${event.type}: ${event.content}
17975
+ `));
17976
+ return;
17977
+ }
17978
+ }
17859
17979
  const toolName = event.metadata?.toolName || "unknown";
17860
17980
  const phase = event.metadata?.phase || "";
17861
17981
  const duration = event.metadata?.duration;
@@ -25149,8 +25269,14 @@ async function main() {
25149
25269
  configureEnvironment();
25150
25270
  try {
25151
25271
  const { ServiceInstaller: ServiceInstaller2 } = await Promise.resolve().then(() => (init_service_installer(), service_installer_exports));
25152
- await ServiceInstaller2.autoUpdate();
25153
- } catch {
25272
+ const updated = await ServiceInstaller2.autoUpdate();
25273
+ if (updated && (process.argv.includes("--verbose") || process.argv.includes("-v") || process.env.JUNO_CODE_DEBUG === "1")) {
25274
+ console.error("[DEBUG] Service scripts auto-updated to latest version");
25275
+ }
25276
+ } catch (error) {
25277
+ if (process.env.JUNO_CODE_DEBUG === "1") {
25278
+ console.error("[DEBUG] Service auto-update failed:", error instanceof Error ? error.message : String(error));
25279
+ }
25154
25280
  }
25155
25281
  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");
25156
25282
  setupGlobalOptions(program);