@qodalis/cli-core 2.0.0-beta.1 → 2.0.0-beta.11

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
@@ -1909,11 +1909,7 @@ var require_semver2 = __commonJS({
1909
1909
  }
1910
1910
  });
1911
1911
 
1912
- // src/lib/models/permissions.ts
1913
- var DEFAULT_FILE_PERMISSIONS = "rw-r--r--";
1914
- var DEFAULT_DIR_PERMISSIONS = "rwxr-xr-x";
1915
-
1916
- // src/lib/models/index.ts
1912
+ // src/lib/models/colors.ts
1917
1913
  var CliForegroundColor = /* @__PURE__ */ ((CliForegroundColor2) => {
1918
1914
  CliForegroundColor2["Black"] = "\x1B[30m";
1919
1915
  CliForegroundColor2["Red"] = "\x1B[31m";
@@ -1937,6 +1933,8 @@ var CliBackgroundColor = /* @__PURE__ */ ((CliBackgroundColor2) => {
1937
1933
  CliBackgroundColor2["White"] = "\x1B[47m";
1938
1934
  return CliBackgroundColor2;
1939
1935
  })(CliBackgroundColor || {});
1936
+
1937
+ // src/lib/models/icons.ts
1940
1938
  var CliIcon = /* @__PURE__ */ ((CliIcon2) => {
1941
1939
  CliIcon2["CheckIcon"] = "\u2714";
1942
1940
  CliIcon2["CrossIcon"] = "\u2718";
@@ -2006,7 +2004,7 @@ var CliIcon = /* @__PURE__ */ ((CliIcon2) => {
2006
2004
  CliIcon2["Server"] = "\u{1F5A5}";
2007
2005
  CliIcon2["Cloud"] = "\u2601";
2008
2006
  CliIcon2["Network"] = "\u{1F310}";
2009
- CliIcon2["Monitor"] = "\u{1F5A5}";
2007
+ CliIcon2["Monitor"] = "\u{1F4FA}";
2010
2008
  CliIcon2["Printer"] = "\u{1F5A8}";
2011
2009
  CliIcon2["USB"] = "\u{1F50C}";
2012
2010
  CliIcon2["Speaker"] = "\u{1F50A}";
@@ -2016,14 +2014,14 @@ var CliIcon = /* @__PURE__ */ ((CliIcon2) => {
2016
2014
  CliIcon2["Music"] = "\u{1F3B5}";
2017
2015
  CliIcon2["Phone"] = "\u{1F4DE}";
2018
2016
  CliIcon2["Package"] = "\u{1F4E6}";
2019
- CliIcon2["Plugin"] = "\u{1F50C}";
2020
- CliIcon2["Extension"] = "\u{1F9E9}";
2021
- CliIcon2["Module"] = "\u{1F4E6}";
2017
+ CliIcon2["Plugin"] = "\u{1F9E9}";
2018
+ CliIcon2["Extension"] = "\u{1F50C}";
2019
+ CliIcon2["Module"] = "\u{1F9F1}";
2022
2020
  CliIcon2["Evaluate"] = "\u{1F50D}";
2023
- CliIcon2["Variable"] = "\u{1F527}";
2021
+ CliIcon2["Variable"] = "\u{1D465}";
2024
2022
  CliIcon2["Script"] = "\u{1F4DC}";
2025
- CliIcon2["Code"] = "\u{1F4BE}";
2026
- CliIcon2["Logs"] = "\u{1F4DC}";
2023
+ CliIcon2["Code"] = "\u{1F4DD}";
2024
+ CliIcon2["Logs"] = "\u{1F4CB}";
2027
2025
  CliIcon2["Power"] = "\u23FB";
2028
2026
  CliIcon2["Heart"] = "\u2764";
2029
2027
  CliIcon2["Flame"] = "\u{1F525}";
@@ -2054,6 +2052,8 @@ var CliIcon = /* @__PURE__ */ ((CliIcon2) => {
2054
2052
  CliIcon2["Gift"] = "\u{1F381}";
2055
2053
  return CliIcon2;
2056
2054
  })(CliIcon || {});
2055
+
2056
+ // src/lib/models/options.ts
2057
2057
  var CliLogLevel = /* @__PURE__ */ ((CliLogLevel2) => {
2058
2058
  CliLogLevel2[CliLogLevel2["None"] = 0] = "None";
2059
2059
  CliLogLevel2[CliLogLevel2["DEBUG"] = 1] = "DEBUG";
@@ -2063,6 +2063,12 @@ var CliLogLevel = /* @__PURE__ */ ((CliLogLevel2) => {
2063
2063
  CliLogLevel2[CliLogLevel2["ERROR"] = 5] = "ERROR";
2064
2064
  return CliLogLevel2;
2065
2065
  })(CliLogLevel || {});
2066
+
2067
+ // src/lib/models/permissions.ts
2068
+ var DEFAULT_FILE_PERMISSIONS = "rw-r--r--";
2069
+ var DEFAULT_DIR_PERMISSIONS = "rwxr-xr-x";
2070
+
2071
+ // src/lib/models/index.ts
2066
2072
  var enums = {
2067
2073
  CliForegroundColor,
2068
2074
  CliBackgroundColor,
@@ -2070,18 +2076,17 @@ var enums = {
2070
2076
  CliLogLevel
2071
2077
  };
2072
2078
 
2073
- // src/lib/interfaces/completion.ts
2079
+ // src/lib/tokens.ts
2080
+ var ICliUserSessionService_TOKEN = "cli-user-session-service";
2081
+ var ICliUsersStoreService_TOKEN = "cli-users-store-service";
2082
+ var ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
2083
+ var ICliAuthService_TOKEN = "cli-auth-service";
2074
2084
  var ICliCompletionProvider_TOKEN = "cli-completion-provider";
2075
-
2076
- // src/lib/interfaces/file-transfer.ts
2077
- var ICliFileTransferService_TOKEN = "cli-file-transfer-service";
2078
-
2079
- // src/lib/interfaces/drag-drop.ts
2080
2085
  var ICliDragDropService_TOKEN = "cli-drag-drop-service";
2081
-
2082
- // src/lib/interfaces/index.ts
2086
+ var ICliFileTransferService_TOKEN = "cli-file-transfer-service";
2083
2087
  var ICliTranslationService_TOKEN = "cli-translation-service";
2084
2088
  var ICliPermissionService_TOKEN = "cli-permission-service";
2089
+ var ICliFilePickerProvider_TOKEN = "cli-file-picker-provider";
2085
2090
 
2086
2091
  // src/lib/constants/index.ts
2087
2092
  var DefaultLibraryAuthor = {
@@ -2243,6 +2248,19 @@ function getConfigValue(state, category, key, defaultValue) {
2243
2248
  }
2244
2249
  return defaultValue;
2245
2250
  }
2251
+ function getPluginConfigValue(context, category, key, defaultValue) {
2252
+ try {
2253
+ const storeManager = context.services.get(
2254
+ "cli-state-store-manager"
2255
+ );
2256
+ if (!storeManager) return defaultValue;
2257
+ const store = storeManager.getStateStore(CLI_CONFIGURE_STORE_NAME);
2258
+ if (!store) return defaultValue;
2259
+ return getConfigValue(store, category, key, defaultValue);
2260
+ } catch {
2261
+ return defaultValue;
2262
+ }
2263
+ }
2246
2264
  function resolveConfigurationCategories(registry) {
2247
2265
  const categories = /* @__PURE__ */ new Map();
2248
2266
  for (const processor of registry.processors) {
@@ -2264,7 +2282,8 @@ function resolveConfigurationCategories(registry) {
2264
2282
 
2265
2283
  // src/lib/utils/terminal-utils.ts
2266
2284
  var clearTerminalLine = (terminal, contentLength) => {
2267
- const lines = Math.max(1, Math.ceil(contentLength / terminal.cols));
2285
+ if (contentLength <= 0) return;
2286
+ const lines = Math.ceil(contentLength / terminal.cols);
2268
2287
  for (let i = 0; i < lines; i++) {
2269
2288
  terminal.write("\x1B[2K");
2270
2289
  if (i < lines - 1) {
@@ -2295,10 +2314,15 @@ function satisfiesVersionRange(installed, range) {
2295
2314
  return semver.satisfies(coerced, range);
2296
2315
  }
2297
2316
 
2317
+ // src/lib/version.ts
2318
+ var LIBRARY_VERSION = "2.0.0-beta.11";
2319
+ var API_VERSION = 2;
2320
+
2298
2321
  // src/lib/utils/server-version-negotiator.ts
2322
+ var VERSIONS_ENDPOINT = "/api/qcli/versions";
2299
2323
  var ServerVersionNegotiator = class {
2300
2324
  static {
2301
- this.CLIENT_SUPPORTED_VERSIONS = [2];
2325
+ this.CLIENT_SUPPORTED_VERSIONS = [API_VERSION];
2302
2326
  }
2303
2327
  /**
2304
2328
  * Given a server's version info, pick the highest mutually compatible version.
@@ -2317,14 +2341,14 @@ var ServerVersionNegotiator = class {
2317
2341
  */
2318
2342
  static async discover(baseUrl) {
2319
2343
  try {
2320
- const response = await fetch(`${baseUrl}/api/cli/versions`);
2344
+ const response = await fetch(`${baseUrl}${VERSIONS_ENDPOINT}`);
2321
2345
  if (!response.ok) return null;
2322
2346
  const info = await response.json();
2323
2347
  const version = this.negotiate(info);
2324
2348
  if (version === null) return null;
2325
2349
  return {
2326
2350
  apiVersion: version,
2327
- basePath: `${baseUrl}/api/v${version}/cli`
2351
+ basePath: `${baseUrl}/api/v${version}/qcli`
2328
2352
  };
2329
2353
  } catch {
2330
2354
  return null;
@@ -2334,7 +2358,7 @@ var ServerVersionNegotiator = class {
2334
2358
 
2335
2359
  // src/lib/utils/panel-theme-sync.ts
2336
2360
  function hexToRgb(hex) {
2337
- const m = /^#?([0-9A-Fa-f]{6})$/.exec(hex);
2361
+ const m = /^#?([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/.exec(hex);
2338
2362
  if (!m) return null;
2339
2363
  const n = parseInt(m[1], 16);
2340
2364
  return { r: n >> 16 & 255, g: n >> 8 & 255, b: n & 255 };
@@ -2352,10 +2376,13 @@ function hexToRgba(hex, alpha) {
2352
2376
  if (!rgb) return hex;
2353
2377
  return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
2354
2378
  }
2379
+ var DEFAULT_BG = "#111827";
2380
+ var DEFAULT_FG = "#ffffff";
2381
+ var DEFAULT_ACCENT = "#818cf8";
2355
2382
  function derivePanelThemeStyles(theme) {
2356
- const bg = theme.background || "#111827";
2357
- const fg = theme.foreground || "#ffffff";
2358
- const accent = theme.cyan || theme.blue || theme.magenta || "#818cf8";
2383
+ const bg = theme.background || DEFAULT_BG;
2384
+ const fg = theme.foreground || DEFAULT_FG;
2385
+ const accent = theme.cyan || theme.blue || theme.magenta || DEFAULT_ACCENT;
2359
2386
  return {
2360
2387
  "--cli-panel-bg": bg,
2361
2388
  "--cli-panel-header-bg": shiftColor(bg, 12),
@@ -2389,9 +2416,21 @@ function savePanelPosition(position) {
2389
2416
  }
2390
2417
  function nextPanelPosition(current) {
2391
2418
  const index = POSITION_CYCLE.indexOf(current);
2419
+ if (index === -1) {
2420
+ return POSITION_CYCLE[0];
2421
+ }
2392
2422
  return POSITION_CYCLE[(index + 1) % POSITION_CYCLE.length];
2393
2423
  }
2394
2424
 
2425
+ // src/lib/utils/ansi-utils.ts
2426
+ var ANSI_RE = /\x1b\[[0-9;]*m/g;
2427
+ function stripAnsi(text) {
2428
+ return text.replace(ANSI_RE, "");
2429
+ }
2430
+ function visibleLength(text) {
2431
+ return stripAnsi(text).length;
2432
+ }
2433
+
2395
2434
  // src/lib/utils/index.ts
2396
2435
  var getParameterValue = (p, args) => {
2397
2436
  if (args[p.name] !== void 0) {
@@ -2405,18 +2444,46 @@ var formatJson = (json) => {
2405
2444
  return colorizeJson(identedJson.split("\n").join("\r\n"));
2406
2445
  };
2407
2446
  var colorizeJson = (jsonString) => {
2408
- return jsonString.replace(/"([^"]+)":/g, '\x1B[33m"$1":\x1B[0m').replace(/: "([^"]*)"/g, ': \x1B[32m"$1"\x1B[0m').replace(/: (\d+)/g, ": \x1B[34m$1\x1B[0m").replace(/: (true|false)/g, ": \x1B[35m$1\x1B[0m").replace(/: (null)/g, ": \x1B[36m$1\x1B[0m");
2447
+ const RST = "\x1B[0m";
2448
+ const CYN = "\x1B[36m";
2449
+ const GRN = "\x1B[32m";
2450
+ const YLW = "\x1B[33m";
2451
+ const GRY = "\x1B[90m";
2452
+ const tokenRe = /("(?:[^"\\]|\\.)*"?)(\s*:)?|(\btrue\b|\bfalse\b|\bnull\b)|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([{}[\],])/g;
2453
+ let result = "";
2454
+ let lastIndex = 0;
2455
+ let m;
2456
+ while ((m = tokenRe.exec(jsonString)) !== null) {
2457
+ if (m.index > lastIndex) {
2458
+ result += jsonString.slice(lastIndex, m.index);
2459
+ }
2460
+ if (m[1] !== void 0) {
2461
+ if (m[2] !== void 0) {
2462
+ result += CYN + m[1] + RST + m[2];
2463
+ } else {
2464
+ result += GRN + m[1] + RST;
2465
+ }
2466
+ } else if (m[3] !== void 0) {
2467
+ result += YLW + m[3] + RST;
2468
+ } else if (m[4] !== void 0) {
2469
+ result += YLW + m[4] + RST;
2470
+ } else if (m[5] !== void 0) {
2471
+ result += GRY + m[5] + RST;
2472
+ }
2473
+ lastIndex = m.index + m[0].length;
2474
+ }
2475
+ if (lastIndex < jsonString.length) {
2476
+ result += jsonString.slice(lastIndex);
2477
+ }
2478
+ return result;
2409
2479
  };
2410
2480
  var toQueryString = (params) => {
2411
2481
  const searchParams = new URLSearchParams();
2412
- for (const key in params) {
2413
- if (params.hasOwnProperty(key)) {
2414
- const value = params[key];
2415
- if (Array.isArray(value)) {
2416
- value.forEach((v) => searchParams.append(key, v.toString()));
2417
- } else if (value !== null && value !== void 0) {
2418
- searchParams.append(key, value.toString());
2419
- }
2482
+ for (const [key, value] of Object.entries(params)) {
2483
+ if (Array.isArray(value)) {
2484
+ value.forEach((v) => searchParams.append(key, v.toString()));
2485
+ } else if (value !== null && value !== void 0) {
2486
+ searchParams.append(key, value.toString());
2420
2487
  }
2421
2488
  }
2422
2489
  return searchParams.toString();
@@ -2453,14 +2520,11 @@ var utils = {
2453
2520
  ObjectDescriber,
2454
2521
  delay,
2455
2522
  getConfigValue,
2523
+ getPluginConfigValue,
2456
2524
  resolveConfigurationCategories,
2457
2525
  CLI_CONFIGURE_STORE_NAME
2458
2526
  };
2459
2527
 
2460
- // src/lib/version.ts
2461
- var LIBRARY_VERSION = "2.0.0-beta.1";
2462
- var API_VERSION = 2;
2463
-
2464
2528
  // src/lib/modules/cli-module-registry.ts
2465
2529
  var CliModuleRegistry = class {
2466
2530
  constructor() {
@@ -2474,20 +2538,33 @@ var CliModuleRegistry = class {
2474
2538
  this.bootHandlers.push(handler);
2475
2539
  }
2476
2540
  /**
2477
- * Register a module and notify all boot handlers.
2478
- * Modules that do not meet the required API version are silently skipped.
2541
+ * Register a web plugin module and notify all boot handlers.
2542
+ * Modules whose `apiVersion` is below the runtime's `API_VERSION` are
2543
+ * skipped with a warning — this ensures only compatible frontend plugins load.
2479
2544
  */
2480
2545
  async register(module) {
2481
2546
  const modApiVersion = module.apiVersion;
2482
2547
  if (typeof modApiVersion !== "number" || modApiVersion < API_VERSION) {
2483
- console.warn(
2484
- `[CLI] Plugin "${module.name}" targets API version ${modApiVersion ?? "unknown"}, but this runtime requires API version ${API_VERSION}. Skipping.`
2485
- );
2548
+ const msg = `[CLI] Plugin "${module.name}" targets API version ${modApiVersion ?? "unknown"}, but this runtime requires API version ${API_VERSION}. Skipping.`;
2549
+ if (this.onWarn) {
2550
+ this.onWarn(msg);
2551
+ } else {
2552
+ console.warn(msg);
2553
+ }
2486
2554
  return;
2487
2555
  }
2488
2556
  this.modules.set(module.name, module);
2489
2557
  for (const handler of this.bootHandlers) {
2490
- await handler(module);
2558
+ try {
2559
+ await handler(module);
2560
+ } catch (e) {
2561
+ const msg = `[CLI] Boot handler failed for module "${module.name}": ${e instanceof Error ? e.message : e}`;
2562
+ if (this.onWarn) {
2563
+ this.onWarn(msg);
2564
+ } else {
2565
+ console.warn(msg);
2566
+ }
2567
+ }
2491
2568
  }
2492
2569
  }
2493
2570
  /**
@@ -2552,16 +2629,21 @@ var bootUmdModule = async (module) => {
2552
2629
  };
2553
2630
 
2554
2631
  // src/lib/types/CancellablePromise.ts
2632
+ var CANCELLATION_ERROR_MESSAGE = "Promise cancelled";
2555
2633
  var CancellablePromise = class {
2556
2634
  constructor(executor) {
2557
2635
  this.executor = executor;
2558
2636
  this.hasCancelled = false;
2559
2637
  this.abortController = new AbortController();
2560
2638
  }
2639
+ /**
2640
+ * Run the executor and return a promise for its result.
2641
+ * If `cancel()` has been called, the promise rejects immediately.
2642
+ */
2561
2643
  execute() {
2562
2644
  return new Promise((resolve, reject) => {
2563
2645
  this.abortController.signal.onabort = () => {
2564
- reject(new Error("Promise cancelled"));
2646
+ reject(new Error(CANCELLATION_ERROR_MESSAGE));
2565
2647
  };
2566
2648
  this.executor(
2567
2649
  (value) => {
@@ -2577,13 +2659,17 @@ var CancellablePromise = class {
2577
2659
  );
2578
2660
  });
2579
2661
  }
2662
+ /**
2663
+ * Cancel the promise. The executing promise rejects with
2664
+ * `Error('Promise cancelled')` and subsequent resolve/reject calls are ignored.
2665
+ */
2580
2666
  cancel() {
2581
2667
  this.hasCancelled = true;
2582
2668
  this.abortController.abort();
2583
2669
  }
2584
2670
  };
2585
2671
 
2586
- // src/lib/themes/index.ts
2672
+ // src/lib/themes/default-themes.ts
2587
2673
  var DefaultThemes = {
2588
2674
  default: {
2589
2675
  background: "#070b14",
@@ -3219,6 +3305,8 @@ var DefaultThemes = {
3219
3305
  }
3220
3306
  };
3221
3307
  DefaultThemes.yellow = DefaultThemes.highContrastLight;
3308
+
3309
+ // src/lib/themes/default-theme-infos.ts
3222
3310
  var DefaultThemeInfos = {
3223
3311
  default: {
3224
3312
  theme: DefaultThemes.default,
@@ -3396,12 +3484,6 @@ var DefaultThemeInfos = {
3396
3484
  }
3397
3485
  };
3398
3486
 
3399
- // src/lib/tokens.ts
3400
- var ICliUserSessionService_TOKEN = "cli-user-session-service";
3401
- var ICliUsersStoreService_TOKEN = "cli-users-store-service";
3402
- var ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
3403
- var ICliAuthService_TOKEN = "cli-auth-service";
3404
-
3405
3487
  // src/lib/worker/create-worker-service.ts
3406
3488
  function createWorkerService(handlers) {
3407
3489
  const abortController = new AbortController();
@@ -3494,9 +3576,17 @@ var BrowserFileTransferService = class {
3494
3576
  const filename = path.split("/").pop() || "download";
3495
3577
  this.downloadToBrowser(filename, content);
3496
3578
  }
3579
+ /**
3580
+ * Not supported in browser — always returns an empty array.
3581
+ * Use `@qodalis/cli-files` for directory listing.
3582
+ */
3497
3583
  async listFiles(_path) {
3498
3584
  return [];
3499
3585
  }
3586
+ /**
3587
+ * Not supported in browser — always returns `false`.
3588
+ * Use `@qodalis/cli-files` for file existence checks.
3589
+ */
3500
3590
  async exists(_path) {
3501
3591
  return false;
3502
3592
  }
@@ -3540,6 +3630,6 @@ var BrowserFileTransferService = class {
3540
3630
  }
3541
3631
  };
3542
3632
 
3543
- export { API_VERSION, BrowserFileTransferService, CLI_CONFIGURE_STORE_NAME, CancellablePromise, CliBackgroundColor, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, ICliAuthService_TOKEN, ICliCompletionProvider_TOKEN, ICliDragDropService_TOKEN, ICliFileTransferService_TOKEN, ICliGroupsStoreService_TOKEN, ICliPermissionService_TOKEN, ICliTranslationService_TOKEN, ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, ServerVersionNegotiator, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, toQueryString, utils };
3633
+ export { API_VERSION, BrowserFileTransferService, CANCELLATION_ERROR_MESSAGE, CLI_CONFIGURE_STORE_NAME, CancellablePromise, CliBackgroundColor, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, ICliAuthService_TOKEN, ICliCompletionProvider_TOKEN, ICliDragDropService_TOKEN, ICliFilePickerProvider_TOKEN, ICliFileTransferService_TOKEN, ICliGroupsStoreService_TOKEN, ICliPermissionService_TOKEN, ICliTranslationService_TOKEN, ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, ServerVersionNegotiator, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getPluginConfigValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, stripAnsi, toQueryString, utils, visibleLength };
3544
3634
  //# sourceMappingURL=public-api.mjs.map
3545
3635
  //# sourceMappingURL=public-api.mjs.map