@qodalis/cli 2.0.1 → 2.1.1

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/public-api.mjs CHANGED
@@ -518,7 +518,7 @@ var CliKeyValueStore_TOKEN = createCliToken("cli-key-value-store");
518
518
  var SyntaxHighlighterRegistry_TOKEN = createCliToken("syntax-highlighter-registry");
519
519
 
520
520
  // src/lib/version.ts
521
- var LIBRARY_VERSION = "2.0.1";
521
+ var LIBRARY_VERSION = "2.1.1";
522
522
  var API_VERSION = 2;
523
523
  var ANONYMOUS = "\0anonymous";
524
524
  function aliasOwner(context2) {
@@ -5397,6 +5397,7 @@ var CliServerConnection = class _CliServerConnection {
5397
5397
  this._eventServiceRegistered = false;
5398
5398
  this._healthCheckTimer = null;
5399
5399
  this._healthCheckAttempts = 0;
5400
+ this._needsSignIn = false;
5400
5401
  }
5401
5402
  static {
5402
5403
  this.WS_MAX_RECONNECT_ATTEMPTS = 5;
@@ -5413,6 +5414,13 @@ var CliServerConnection = class _CliServerConnection {
5413
5414
  get config() {
5414
5415
  return this._config;
5415
5416
  }
5417
+ /**
5418
+ * The last connect was refused for want of a sign-in (401 or 403 on the
5419
+ * command list): the server is up, and a sign-in reconnects it.
5420
+ */
5421
+ get needsSignIn() {
5422
+ return this._needsSignIn;
5423
+ }
5416
5424
  get connected() {
5417
5425
  return this._connected;
5418
5426
  }
@@ -5452,6 +5460,7 @@ var CliServerConnection = class _CliServerConnection {
5452
5460
  });
5453
5461
  }
5454
5462
  async connect() {
5463
+ this._needsSignIn = false;
5455
5464
  try {
5456
5465
  const baseUrl = this.normalizeUrl(this._config.url);
5457
5466
  const negotiated = await ServerVersionNegotiator.discover(
@@ -5534,6 +5543,7 @@ var CliServerConnection = class _CliServerConnection {
5534
5543
  const url = `${this._basePath}/commands`;
5535
5544
  const response = await this.httpFetch(url);
5536
5545
  if (!response.ok) {
5546
+ if (response.status === 401 || response.status === 403) this._needsSignIn = true;
5537
5547
  throw new Error(
5538
5548
  `Server ${this._config.name} returned ${response.status}`
5539
5549
  );
@@ -6224,6 +6234,10 @@ var CliServerManager = class {
6224
6234
  );
6225
6235
  this.registerProxyProcessors(connection, config.name);
6226
6236
  this.emitConnected(connection, false);
6237
+ } else if (connection.needsSignIn) {
6238
+ logger?.info(
6239
+ `Server '${config.name}' needs a sign-in; its commands load once you are signed in.`
6240
+ );
6227
6241
  } else {
6228
6242
  logger?.warn(
6229
6243
  `Could not connect to server '${config.name}' at ${config.url}. Commands from this server will not be available.`
@@ -6706,6 +6720,20 @@ var getCliNameArt = (cols) => {
6706
6720
  }
6707
6721
  return "\n Qodalis CLI\n";
6708
6722
  };
6723
+ var DEFAULT_CLI_NAME = "Web CLI";
6724
+ var resolveCliBranding = (branding) => {
6725
+ const custom = branding?.name?.trim() || void 0;
6726
+ const name = custom ?? DEFAULT_CLI_NAME;
6727
+ const icon = branding?.icon?.trim() || void 0;
6728
+ return {
6729
+ name,
6730
+ custom: !!custom,
6731
+ icon,
6732
+ art: (cols) => custom ? `
6733
+ ${custom}
6734
+ ` : getCliNameArt(cols)
6735
+ };
6736
+ };
6709
6737
  var hotkeysInfo = [
6710
6738
  {
6711
6739
  key: "Ctrl + C",
@@ -6783,7 +6811,9 @@ var CliVersionCommandProcessor = class {
6783
6811
  writer.wrapInColor(getCliNameArt(context2.terminal.cols), CliForegroundColor.Cyan)
6784
6812
  );
6785
6813
  const framework = context2.services.get("cli-framework") ?? "vanilla";
6814
+ const branding = resolveCliBranding(context2.options?.branding);
6786
6815
  writer.writeBox([
6816
+ ...branding.custom ? [`${DIM2}App${RESET2} ${writer.wrapInColor(branding.name, CliForegroundColor.Cyan)}`] : [],
6787
6817
  `${DIM2}CLI${RESET2} ${writer.wrapInColor(`v${LIBRARY_VERSION}`, CliForegroundColor.Green)}`,
6788
6818
  `${DIM2}Core${RESET2} ${writer.wrapInColor(`v${LIBRARY_VERSION$1}`, CliForegroundColor.Green)}`,
6789
6819
  `${DIM2}Framework${RESET2} ${writer.wrapInColor(framework, CliForegroundColor.Cyan)}`,
@@ -19277,8 +19307,9 @@ var welcomeModule = {
19277
19307
  );
19278
19308
  await configureStore.initialize();
19279
19309
  const state = configureStore.getState();
19280
- if (state?.["system"]?.["welcomeMessage"]) {
19281
- showOption = state["system"]["welcomeMessage"];
19310
+ const stored = state?.["system"]?.["welcomeMessage"];
19311
+ if (stored && stored !== "always") {
19312
+ showOption = stored;
19282
19313
  }
19283
19314
  }
19284
19315
  if (showOption) {
@@ -19290,10 +19321,12 @@ var welcomeModule = {
19290
19321
  if (config.message) {
19291
19322
  context2.terminal.writeln(config.message);
19292
19323
  } else {
19324
+ const branding = resolveCliBranding(context2.options?.branding);
19325
+ const art = branding.art(context2.terminal.cols);
19293
19326
  const lines = [
19294
- `\u{1F680} Welcome to Web CLI [Version ${context2.writer.wrapInColor(LIBRARY_VERSION, CliForegroundColor.Green)}]`,
19327
+ `\u{1F680} Welcome to ${branding.name} [Version ${context2.writer.wrapInColor(LIBRARY_VERSION, CliForegroundColor.Green)}]`,
19295
19328
  `(c) ${(/* @__PURE__ */ new Date()).getFullYear()} Qodalis Solutions. All rights reserved.`,
19296
- getCliNameArt(context2.terminal.cols),
19329
+ art,
19297
19330
  "",
19298
19331
  `\u{1F4D6} ${context2.writer.wrapInColor("Documentation:", CliForegroundColor.Green)} https://cli.qodalis.com/docs/`,
19299
19332
  "",
@@ -19301,7 +19334,10 @@ var welcomeModule = {
19301
19334
  ""
19302
19335
  ];
19303
19336
  lines.forEach((line2) => {
19304
- context2.terminal.write(line2 + "\r\n");
19337
+ const wrapped = line2 === art ? [line2] : wrapWelcomeLine(line2, context2.terminal.cols);
19338
+ wrapped.forEach(
19339
+ (part) => context2.terminal.write(part + "\r\n")
19340
+ );
19305
19341
  });
19306
19342
  }
19307
19343
  recordWelcomeMessageDisplay();
@@ -19333,12 +19369,51 @@ var greetingModule = {
19333
19369
  if (host.typedDuringBoot || host.isReadingInput || context2.currentLine) {
19334
19370
  return;
19335
19371
  }
19336
- await context2.textAnimator?.showText(getGreetingBasedOnTime(), {
19372
+ const buffer = context2.terminal.buffer?.active;
19373
+ const room = context2.terminal.cols - (buffer?.cursorX ?? 0) - 1;
19374
+ const greeting = fitGreeting(getGreetingBasedOnTime(), room);
19375
+ if (!greeting) return;
19376
+ await context2.textAnimator?.showText(greeting, {
19337
19377
  speed: 60,
19338
19378
  removeAfterTyping: true
19339
19379
  });
19340
19380
  }
19341
19381
  };
19382
+ function fitGreeting(text, room) {
19383
+ const width = (value) => Array.from(value).reduce(
19384
+ (sum, ch) => sum + (ch.codePointAt(0) > 65535 || /\p{Extended_Pictographic}/u.test(ch) ? 2 : ch === "\uFE0F" ? 0 : 1),
19385
+ 0
19386
+ );
19387
+ if (width(text) <= room) return text;
19388
+ const words = text.split(" ");
19389
+ let fitted = "";
19390
+ for (const word of words) {
19391
+ const next = fitted ? `${fitted} ${word}` : word;
19392
+ if (width(next) > room) break;
19393
+ fitted = next;
19394
+ }
19395
+ return fitted.split(" ").length >= 3 ? fitted.replace(/[,;:]$/, "") : null;
19396
+ }
19397
+ function wrapWelcomeLine(line2, cols) {
19398
+ const width = Math.max(20, cols - 1);
19399
+ const visible = (value) => Array.from(value.replace(/\x1b\[[0-9;]*m/g, "")).reduce(
19400
+ (sum, ch) => sum + (ch.codePointAt(0) > 65535 ? 2 : ch === "\uFE0F" ? 0 : 1),
19401
+ 0
19402
+ );
19403
+ if (visible(line2) <= width) return [line2];
19404
+ const lines = [];
19405
+ let current = "";
19406
+ for (const word of line2.split(" ")) {
19407
+ if (current && visible(current) + 1 + visible(word) > width) {
19408
+ lines.push(current);
19409
+ current = word;
19410
+ } else {
19411
+ current = current ? `${current} ${word}` : word;
19412
+ }
19413
+ }
19414
+ if (current) lines.push(current);
19415
+ return lines;
19416
+ }
19342
19417
  function shouldDisplayWelcomeMessage(showOption) {
19343
19418
  const lastDisplayed = localStorage.getItem(
19344
19419
  "cliWelcomeMessageLastDisplayed"
@@ -22858,7 +22933,7 @@ var CliEngine = class {
22858
22933
  (s) => s.enabled !== false
22859
22934
  ).length;
22860
22935
  bootLog.addSteps(1 + serverCount);
22861
- bootLog.info(`Starting Web CLI ${LIBRARY_VERSION}`);
22936
+ bootLog.info(`Starting ${resolveCliBranding(this.options?.branding).name} ${LIBRARY_VERSION}`);
22862
22937
  bootLog.ok(
22863
22938
  `Terminal and services ready \xB7 ${this.terminal.cols}\xD7${this.terminal.rows}`,
22864
22939
  bootLog.elapsedMs
@@ -24070,7 +24145,9 @@ var CliPanelController = class {
24070
24145
  unhide() {
24071
24146
  if (!this.snapshot.hidden) return;
24072
24147
  this.updateHidden(false);
24073
- if (this.snapshot.collapsed !== this.preHideCollapsed) this.updateCollapsed(this.preHideCollapsed);
24148
+ const collapsed = this.snapshot.initialized ? this.preHideCollapsed : false;
24149
+ if (this.snapshot.collapsed !== collapsed) this.updateCollapsed(collapsed);
24150
+ if (!collapsed) this.ensureInitialized();
24074
24151
  }
24075
24152
  toggleHide() {
24076
24153
  if (this.snapshot.hidden) this.unhide();
@@ -24681,6 +24758,11 @@ var PANEL_LABELS = {
24681
24758
  serversHeader: "Server Connections",
24682
24759
  serversEmpty: "No servers configured"
24683
24760
  };
24761
+ function panelBranding(options) {
24762
+ const name = options?.branding?.name?.trim();
24763
+ const icon = options?.branding?.icon?.trim();
24764
+ return { title: name || PANEL_LABELS.title, iconUrl: icon || void 0 };
24765
+ }
24684
24766
  var SERVICES_ICON = "\u2699";
24685
24767
  var UPTIME_ICON = "\u2191";
24686
24768
  var SUCCESS_ICON = "\u2713";
@@ -24874,6 +24956,6 @@ function openStatusDropdown(s) {
24874
24956
  return null;
24875
24957
  }
24876
24958
 
24877
- export { API_VERSION, CLI_ENV_GLOBAL_PERMISSION, CLI_FRAMEWORK_SERVICE, CLOSE_GLYPH, CLOSE_ICON, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliBootLog, CliBootLog_TOKEN, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliEventsCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFalseCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliHttpClient, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKeyValueStore_TOKEN, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliNotifier, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPanelController, CliPanelStatusTracker, CliPermissionRegistry, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliScriptSyntaxError, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestCommandProcessor, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliTrueCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, DEFAULT_GLOBAL_STATUS, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH, DEFAULT_TAB_STATUS, ERROR_ICON, EXEC_POLL_MS, GLOBAL_POLL_MS, HIDE_ICON, HIDE_TAB_TERMINAL_ICON, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, ICliScriptRunner_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, MAXIMIZE_ICON, MIN_PANEL_SIZE, MIN_PANE_WIDTH_PERCENT, OverlayAddon, PANEL_LABELS, PANEL_POSITIONS, ProcessExitedError, RESTORE_ICON, SERVICES_ICON, SUCCESS_ICON, SVG_COMMON_ATTRS, SVG_VIEW_BOX, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, TERMINAL_ICON, UPTIME_ICON, appendOutputToFile, appendStderrToFile, applyEnvironmentChange, builtinProcessors, capitalize, clampPanelSize, cliScriptRunner, collapseChevronIcon, computeDiff, computeGlobalStatus, computeTabStatus, contextGlobalParameter, contextMenuItems, contextMenuStyle, createCliEngine, createServerModule, defaultFontSize, describeShellClose, distributePaneWidths, dropdownAnchorStyle, executeOnServer, expandBraces, expandEnvironmentVars, expandGlobs, formatDiff, formatUptime2 as formatUptime, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, glowLineClass, greetingModule, groupBy, handleRenameKey, helpGlobalParameter, hideTabChevronIcon, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isHorizontalPosition, isWasmAccelerated, joinClasses, matchGlob, mergeCliOptions, miscProcessors, nextRowsCommand, normalizePaneWidths, openLink, openStatusDropdown, paneClass, paneStyle, panelTabClass, panelTabDotClass, panelWrapperClass, panelWrapperStyle, panesContainerClass, panesContainerWidth, parseAssignments, parseScript, positionDropdownItemClass, positionIcon, positionOptions, reconcileArgs, renderServerResponse, renderSingleOutput, resizePaneWidths, resizedPanelSize, resolveCliHostConfig, runContextMenuAction, runScript, splitWords, statusIndicators, substituteCommands, substituteVars, svgAttrs, systemProcessors, tabDotClass, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
24959
+ export { API_VERSION, CLI_ENV_GLOBAL_PERMISSION, CLI_FRAMEWORK_SERVICE, CLOSE_GLYPH, CLOSE_ICON, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliBootLog, CliBootLog_TOKEN, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliEventsCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFalseCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliHttpClient, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKeyValueStore_TOKEN, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliNotifier, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPanelController, CliPanelStatusTracker, CliPermissionRegistry, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliScriptSyntaxError, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestCommandProcessor, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliTrueCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, DEFAULT_CLI_NAME, DEFAULT_GLOBAL_STATUS, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH, DEFAULT_TAB_STATUS, ERROR_ICON, EXEC_POLL_MS, GLOBAL_POLL_MS, HIDE_ICON, HIDE_TAB_TERMINAL_ICON, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, ICliScriptRunner_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, MAXIMIZE_ICON, MIN_PANEL_SIZE, MIN_PANE_WIDTH_PERCENT, OverlayAddon, PANEL_LABELS, PANEL_POSITIONS, ProcessExitedError, RESTORE_ICON, SERVICES_ICON, SUCCESS_ICON, SVG_COMMON_ATTRS, SVG_VIEW_BOX, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, TERMINAL_ICON, UPTIME_ICON, appendOutputToFile, appendStderrToFile, applyEnvironmentChange, builtinProcessors, capitalize, clampPanelSize, cliScriptRunner, collapseChevronIcon, computeDiff, computeGlobalStatus, computeTabStatus, contextGlobalParameter, contextMenuItems, contextMenuStyle, createCliEngine, createServerModule, defaultFontSize, describeShellClose, distributePaneWidths, dropdownAnchorStyle, executeOnServer, expandBraces, expandEnvironmentVars, expandGlobs, formatDiff, formatUptime2 as formatUptime, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, glowLineClass, greetingModule, groupBy, handleRenameKey, helpGlobalParameter, hideTabChevronIcon, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isHorizontalPosition, isWasmAccelerated, joinClasses, matchGlob, mergeCliOptions, miscProcessors, nextRowsCommand, normalizePaneWidths, openLink, openStatusDropdown, paneClass, paneStyle, panelBranding, panelTabClass, panelTabDotClass, panelWrapperClass, panelWrapperStyle, panesContainerClass, panesContainerWidth, parseAssignments, parseScript, positionDropdownItemClass, positionIcon, positionOptions, reconcileArgs, renderServerResponse, renderSingleOutput, resizePaneWidths, resizedPanelSize, resolveCliBranding, resolveCliHostConfig, runContextMenuAction, runScript, splitWords, statusIndicators, substituteCommands, substituteVars, svgAttrs, systemProcessors, tabDotClass, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
24878
24960
  //# sourceMappingURL=public-api.mjs.map
24879
24961
  //# sourceMappingURL=public-api.mjs.map