@nmakarov/cli-toolkit 0.14.0 → 0.16.0

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.
Files changed (49) hide show
  1. package/dist/args.cjs +49 -9
  2. package/dist/args.cjs.map +1 -1
  3. package/dist/args.js +49 -9
  4. package/dist/args.js.map +1 -1
  5. package/dist/db.cjs +9 -2
  6. package/dist/db.cjs.map +1 -1
  7. package/dist/db.js +9 -2
  8. package/dist/db.js.map +1 -1
  9. package/dist/errors.cjs +17 -0
  10. package/dist/errors.cjs.map +1 -1
  11. package/dist/errors.js +15 -0
  12. package/dist/errors.js.map +1 -1
  13. package/dist/filedatabase.cjs +16 -24
  14. package/dist/filedatabase.cjs.map +1 -1
  15. package/dist/filedatabase.js +16 -23
  16. package/dist/filedatabase.js.map +1 -1
  17. package/dist/http-client.cjs +44 -34
  18. package/dist/http-client.cjs.map +1 -1
  19. package/dist/http-client.js +44 -34
  20. package/dist/http-client.js.map +1 -1
  21. package/dist/http-client2.cjs +368 -0
  22. package/dist/http-client2.cjs.map +1 -0
  23. package/dist/http-client2.js +340 -0
  24. package/dist/http-client2.js.map +1 -0
  25. package/dist/index.cjs +214 -91
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +214 -90
  28. package/dist/index.js.map +1 -1
  29. package/dist/init.cjs +192 -76
  30. package/dist/init.cjs.map +1 -1
  31. package/dist/init.js +192 -76
  32. package/dist/init.js.map +1 -1
  33. package/dist/logger.cjs +19 -36
  34. package/dist/logger.cjs.map +1 -1
  35. package/dist/logger.js +19 -36
  36. package/dist/logger.js.map +1 -1
  37. package/dist/mock-server.cjs +13 -16
  38. package/dist/mock-server.cjs.map +1 -1
  39. package/dist/mock-server.js +13 -16
  40. package/dist/mock-server.js.map +1 -1
  41. package/dist/params.cjs +114 -15
  42. package/dist/params.cjs.map +1 -1
  43. package/dist/params.js +114 -15
  44. package/dist/params.js.map +1 -1
  45. package/dist/screen.cjs +2 -0
  46. package/dist/screen.cjs.map +1 -1
  47. package/dist/screen.js +2 -0
  48. package/dist/screen.js.map +1 -1
  49. package/package.json +9 -2
package/dist/index.cjs CHANGED
@@ -684,6 +684,8 @@ async function showScreen(config2) {
684
684
  keyMatches = true;
685
685
  } else if (input === binding.key) {
686
686
  keyMatches = true;
687
+ } else if (key?.name === binding.key) {
688
+ keyMatches = true;
687
689
  }
688
690
  if (keyMatches) {
689
691
  if (binding.enabled === false) {
@@ -1115,7 +1117,6 @@ __export(src_exports, {
1115
1117
  dbInit: () => dbInit,
1116
1118
  defaultFileSynopsisFunction: () => defaultFileSynopsisFunction,
1117
1119
  defaultVersionSynopsisFunction: () => defaultVersionSynopsisFunction,
1118
- fileDatabaseInit: () => fileDatabaseInit,
1119
1120
  getArgsInstance: () => getArgsInstance,
1120
1121
  h: () => import_react5.createElement,
1121
1122
  joiEdateType: () => joiEdateType,
@@ -1158,20 +1159,31 @@ var Args = class _Args {
1158
1159
  configValues = {};
1159
1160
  configsLoaded = [];
1160
1161
  env = "local";
1161
- constructor(config2 = {}) {
1162
+ constructor(contextOrConfig = {}, config2) {
1163
+ const hasContext = config2 !== void 0;
1164
+ const configToUse = hasContext ? config2 ?? {} : contextOrConfig ?? {};
1165
+ const context = hasContext ? contextOrConfig : void 0;
1162
1166
  this.aliases = {};
1163
1167
  this.overrides = {};
1164
1168
  this.defaults = {};
1165
1169
  this.prefixes = ["not", "no"];
1166
- if (Object.keys(config2).length > 0) {
1167
- this.configure(config2);
1170
+ if (Object.keys(configToUse).length > 0) {
1171
+ this.configure(configToUse);
1168
1172
  }
1169
- const args = config2.args || process.argv.slice(2);
1173
+ const args = configToUse.args || process.argv.slice(2);
1170
1174
  this.parseArgs(args);
1171
1175
  this.env = this.get("env")?.toLowerCase() || "local";
1172
1176
  this.loadDotEnv();
1173
1177
  this.loadConfigFiles();
1174
1178
  this.checkConflicts();
1179
+ if (context && typeof context.registerCleanup === "function") {
1180
+ context.registerCleanup((ctx) => {
1181
+ const unusedArgs = ctx.args.getUnused();
1182
+ if (unusedArgs.length > 0) {
1183
+ ctx.logger.warn("Unused CLI args:", unusedArgs.join(", "));
1184
+ }
1185
+ });
1186
+ }
1175
1187
  }
1176
1188
  /**
1177
1189
  * Configure Args options
@@ -1193,12 +1205,15 @@ var Args = class _Args {
1193
1205
  }
1194
1206
  }
1195
1207
  /**
1196
- * Initialize Args instance
1197
- * Note: Args is special - it's initialized first, so it can't take context
1198
- * This static method is for consistency with other components
1208
+ * Initialize Args instance.
1209
+ * Args.init(context, config) when used from init/setup: context has registerCleanup, Args registers unused-args cleanup.
1210
+ * Args.init(config) for standalone use (no cleanup).
1199
1211
  */
1200
- static init(config2 = {}) {
1201
- return new _Args(config2);
1212
+ static init(contextOrConfig, config2) {
1213
+ if (config2 !== void 0) {
1214
+ return new _Args(contextOrConfig, config2);
1215
+ }
1216
+ return new _Args(contextOrConfig ?? {});
1202
1217
  }
1203
1218
  /**
1204
1219
  * Parse command line arguments
@@ -1378,6 +1393,32 @@ var Args = class _Args {
1378
1393
  }
1379
1394
  return void 0;
1380
1395
  }
1396
+ /**
1397
+ * Return which layer provided the value for get(key): overrides, cli, config, env, or default.
1398
+ * Does not add key to usedKeys. Use after get(key) when you need the origin.
1399
+ */
1400
+ getSource(key) {
1401
+ const resolvedKey = this.aliases[key] || key;
1402
+ const lcKey = resolvedKey.toLowerCase();
1403
+ const overrideKey = Object.keys(this.overrides).find((k) => k.toLowerCase() === lcKey);
1404
+ if (overrideKey !== void 0) return "overrides";
1405
+ const lcKeyWithEnv = `${lcKey}${this.env ? `_${this.env.toLowerCase()}` : ""}`;
1406
+ if (this.env && this.args[lcKeyWithEnv] !== void 0) return "cli";
1407
+ if (this.args[lcKey] !== void 0) return "cli";
1408
+ const configKey = Object.keys(this.configValues).find((k) => k.toLowerCase() === lcKey);
1409
+ if (configKey !== void 0) return "config";
1410
+ const envKey = this.toEnvKey(resolvedKey);
1411
+ const envKeyWithEnv = `${envKey}${this.env ? `_${this.env.toUpperCase()}` : ""}`;
1412
+ const envSpecificKey = Object.keys(process.env).find((k) => this.env && k.toUpperCase() === envKeyWithEnv);
1413
+ const envKeyFound = Object.keys(process.env).find((k) => k.toUpperCase() === envKey);
1414
+ const envKeyAlt = envKey.replace(/_([0-9])/g, "$1");
1415
+ const envKeyAltFound = !envKeyFound ? Object.keys(process.env).find((k) => k.toUpperCase() === envKeyAlt) : null;
1416
+ if (envSpecificKey || envKeyFound || envKeyAltFound) return "env";
1417
+ const defaultKey = Object.keys(this.defaults).find((k) => k.toLowerCase() === lcKey);
1418
+ if (defaultKey !== void 0) return "default";
1419
+ if (lcKey === "env" && process.env.NODE_ENV !== void 0) return "env";
1420
+ return void 0;
1421
+ }
1381
1422
  /**
1382
1423
  * Set a value (for testing/internal use)
1383
1424
  */
@@ -1603,6 +1644,12 @@ var ParamError = class extends FrameworkError {
1603
1644
  this.name = "ParamError";
1604
1645
  }
1605
1646
  };
1647
+ var FileDatabaseError = class extends FrameworkError {
1648
+ constructor(message) {
1649
+ super(message);
1650
+ this.name = "FileDatabaseError";
1651
+ }
1652
+ };
1606
1653
 
1607
1654
  // src/params/custom-types.ts
1608
1655
  var joiEdateType = (value, helpers) => {
@@ -1728,17 +1775,53 @@ var Params = class _Params {
1728
1775
  context;
1729
1776
  // Partial context during initialization
1730
1777
  params = {};
1778
+ paramSources = {};
1731
1779
  definitions = {};
1732
1780
  args;
1733
1781
  paramSetters = [];
1734
1782
  paramGetters = [];
1735
1783
  trackedParams = [];
1784
+ _currentModule = "script";
1785
+ /** Resolved early in constructor so cleanup does not read params lazily */
1786
+ _showUsedParams = false;
1736
1787
  constructor(context, options = {}) {
1737
1788
  this.context = context;
1738
1789
  this.args = context.args;
1739
1790
  if (Object.keys(options).length > 0) {
1740
1791
  this.configure(options);
1741
1792
  }
1793
+ this._showUsedParams = this.get("showUsedParams", "boolean default false");
1794
+ if (context && typeof context.registerCleanup === "function") {
1795
+ context.registerCleanup((ctx) => {
1796
+ if (!ctx.params.getShowUsedParams()) return;
1797
+ const byModule = ctx.params.getFiguredByModule();
1798
+ const modules = Object.keys(byModule).sort();
1799
+ if (modules.length === 0) return;
1800
+ const logger = ctx.logger;
1801
+ logger.debug("[Params]: list of used params:");
1802
+ if (typeof logger.highlight !== "function") {
1803
+ for (const mod of modules) {
1804
+ logger.debug(` [${mod}]`);
1805
+ for (const [key, entry] of Object.entries(byModule[mod])) {
1806
+ logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);
1807
+ }
1808
+ }
1809
+ return;
1810
+ }
1811
+ for (const mod of modules) {
1812
+ logger.debug(` [${mod}]`);
1813
+ for (const [key, entry] of Object.entries(byModule[mod])) {
1814
+ const valueStr = JSON.stringify(entry.value);
1815
+ const display = entry.source === "default" ? valueStr : logger.highlight(valueStr);
1816
+ logger.debug(` ${key}: ${display} (${entry.source})`);
1817
+ }
1818
+ }
1819
+ });
1820
+ }
1821
+ }
1822
+ /** Whether --showUsedParams was requested (resolved in constructor). */
1823
+ getShowUsedParams() {
1824
+ return this._showUsedParams;
1742
1825
  }
1743
1826
  /**
1744
1827
  * Configure parameters
@@ -1757,14 +1840,15 @@ var Params = class _Params {
1757
1840
  return new _Params(context, options || {});
1758
1841
  }
1759
1842
  /**
1760
- * Track a parameter request for --stopAfter=init feature
1843
+ * Track a parameter request for --stopAfter=init and --showUsedParams
1761
1844
  */
1762
- trackParam(key, definition, value, source) {
1845
+ trackParam(key, definition, value, source, moduleName) {
1763
1846
  this.trackedParams.push({
1764
1847
  key,
1765
1848
  definition,
1766
1849
  value,
1767
- source
1850
+ source,
1851
+ module: moduleName ?? this._currentModule
1768
1852
  });
1769
1853
  }
1770
1854
  /**
@@ -1774,7 +1858,7 @@ var Params = class _Params {
1774
1858
  return [...this.trackedParams];
1775
1859
  }
1776
1860
  /**
1777
- * Get all figured parameters as a record
1861
+ * Get all figured parameters as a record (flat, last occurrence per key)
1778
1862
  * Returns all parameters that were collected during initialization,
1779
1863
  * whether from CLI args, options, or defaults
1780
1864
  */
@@ -1788,6 +1872,19 @@ var Params = class _Params {
1788
1872
  }
1789
1873
  return result;
1790
1874
  }
1875
+ /**
1876
+ * Get figured parameters grouped by module name.
1877
+ * Same param can appear in multiple modules (e.g. source, resource).
1878
+ */
1879
+ getFiguredByModule() {
1880
+ const byModule = {};
1881
+ for (const param of this.trackedParams) {
1882
+ const mod = param.module;
1883
+ if (!byModule[mod]) byModule[mod] = {};
1884
+ byModule[mod][param.key] = { value: param.value, source: param.source };
1885
+ }
1886
+ return byModule;
1887
+ }
1791
1888
  /**
1792
1889
  * Clear tracked parameters
1793
1890
  */
@@ -1906,14 +2003,19 @@ var Params = class _Params {
1906
2003
  source = "options";
1907
2004
  } else if (valFromArgs !== void 0 && valFromArgs !== null) {
1908
2005
  value = this.validate(key, valFromArgs, def);
1909
- source = "cli";
2006
+ const argsSource = this.args.getSource?.(key);
2007
+ if (argsSource === "overrides") source = "options";
2008
+ else if (argsSource === "cli" || argsSource === "env" || argsSource === "config") source = argsSource;
2009
+ else if (argsSource === "default") source = "default";
2010
+ else source = "cli";
1910
2011
  } else if (valFromParams !== void 0 && valFromParams !== null) {
1911
2012
  value = this.validate(key, valFromParams, def);
1912
- source = "options";
2013
+ source = this.paramSources[key] ?? "options";
1913
2014
  } else {
1914
2015
  value = this.validate(key, void 0, def);
1915
2016
  source = "default";
1916
2017
  }
2018
+ this.paramSources[key] = source;
1917
2019
  this.trackParam(key, definition || "string", value, source);
1918
2020
  if (value !== void 0 && def.values && !def.values.includes(value)) {
1919
2021
  throw new ParamError(`key ${key} should be one of ${def.values}`);
@@ -1934,19 +2036,63 @@ var Params = class _Params {
1934
2036
  }
1935
2037
  }
1936
2038
  /**
1937
- * Get all parameters from definitions
1938
- * Processes parameters left-to-right to support cross-parameter references
2039
+ * Get all parameters from definitions (main script).
2040
+ * Same as getAllForModule("script", defs). Processes left-to-right for cross-parameter references.
1939
2041
  */
1940
2042
  getAll(defs) {
1941
- const res = {};
1942
- for (const [k, def] of Object.entries(defs)) {
1943
- const value = this.get(k, def);
1944
- res[k] = value;
1945
- if (value !== void 0) {
1946
- this.params[k] = value;
2043
+ return this.getAllForModule("script", defs);
2044
+ }
2045
+ /**
2046
+ * Get all parameters from definitions for a given module name.
2047
+ * Figured params are grouped by module when using --showUsedParams.
2048
+ * Processes parameters left-to-right to support cross-parameter references.
2049
+ * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).
2050
+ */
2051
+ getAllForModule(moduleNameOrDefs, defs) {
2052
+ let moduleName;
2053
+ let definitions;
2054
+ if (defs !== void 0) {
2055
+ moduleName = moduleNameOrDefs;
2056
+ definitions = defs;
2057
+ } else {
2058
+ definitions = moduleNameOrDefs;
2059
+ moduleName = this._inferModuleNameFromStack();
2060
+ }
2061
+ const prev = this._currentModule;
2062
+ this._currentModule = moduleName;
2063
+ try {
2064
+ const res = {};
2065
+ for (const [k, def] of Object.entries(definitions)) {
2066
+ const value = this.get(k, def);
2067
+ res[k] = value;
2068
+ if (value !== void 0) {
2069
+ this.params[k] = value;
2070
+ }
1947
2071
  }
2072
+ return res;
2073
+ } finally {
2074
+ this._currentModule = prev;
1948
2075
  }
1949
- return res;
2076
+ }
2077
+ /**
2078
+ * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...
2079
+ */
2080
+ _inferModuleNameFromStack() {
2081
+ const stack = new Error().stack;
2082
+ if (!stack) return "script";
2083
+ const lines = stack.split("\n");
2084
+ const paramsIndexPath = "params" + (typeof process !== "undefined" && process.platform === "win32" ? "\\" : "/") + "index.";
2085
+ for (const line of lines) {
2086
+ const parenMatch = line.match(/\(([^)]+)\)/);
2087
+ if (!parenMatch) continue;
2088
+ const parts = parenMatch[1].split(":");
2089
+ if (parts.length < 3) continue;
2090
+ const path4 = parts.slice(0, -2).join(":").replace(/^file:\/\//, "");
2091
+ if (!path4 || path4.includes(paramsIndexPath)) continue;
2092
+ const srcMatch = path4.match(/[/\\]src[/\\]([^/\\]+)(?:[/\\]|$)/);
2093
+ if (srcMatch) return srcMatch[1];
2094
+ }
2095
+ return "script";
1950
2096
  }
1951
2097
  /**
1952
2098
  * Run all registered getters for a key
@@ -2168,13 +2314,7 @@ function defaultVersionSynopsisFunction(metadata) {
2168
2314
  }
2169
2315
 
2170
2316
  // src/filedatabase/index.ts
2171
- var FileDatabaseError = class extends Error {
2172
- constructor(message) {
2173
- super(message);
2174
- this.name = "FileDatabaseError";
2175
- }
2176
- };
2177
- var FileDatabase = class {
2317
+ var FileDatabase = class _FileDatabase {
2178
2318
  basePath;
2179
2319
  namespace;
2180
2320
  tableName = null;
@@ -2211,18 +2351,8 @@ var FileDatabase = class {
2211
2351
  maxVersions: "number default 5",
2212
2352
  pageSize: "number default 5000"
2213
2353
  };
2214
- const paramsConfig = context.params.getAll(defs);
2215
- config2 = {
2216
- basePath: opts.basePath ?? paramsConfig.basePath,
2217
- namespace: opts.namespace ?? paramsConfig.namespace,
2218
- tableName: opts.tableName ?? paramsConfig.tableName ?? null,
2219
- versioned: opts.versioned ?? true,
2220
- maxVersions: opts.maxVersions ?? paramsConfig.maxVersions,
2221
- pageSize: opts.pageSize ?? paramsConfig.pageSize,
2222
- useMetadata: opts.useMetadata ?? true,
2223
- freeSpaceThreshold: opts.freeSpaceThreshold ?? 100 * 1024 * 1024,
2224
- logger: context.logger
2225
- };
2354
+ const discovered = context.params.getAllForModule(defs);
2355
+ config2 = { ...discovered, ...opts, logger: context.logger };
2226
2356
  } else {
2227
2357
  config2 = contextOrConfig;
2228
2358
  }
@@ -2240,6 +2370,13 @@ var FileDatabase = class {
2240
2370
  this.logger = config2.logger || console;
2241
2371
  this.metadata = this.getDefaultMetadata();
2242
2372
  }
2373
+ /**
2374
+ * Initialize FileDatabase from context and options.
2375
+ * Params are read via getAllForModule("filedatabase", defs) for --showUsedParams grouping.
2376
+ */
2377
+ static init(context, options) {
2378
+ return new _FileDatabase(context, options ?? {});
2379
+ }
2243
2380
  /**
2244
2381
  * Get default metadata structure
2245
2382
  */
@@ -3105,9 +3242,6 @@ function listSources(basePath) {
3105
3242
  return [];
3106
3243
  }
3107
3244
  }
3108
- function fileDatabaseInit(context, options = {}) {
3109
- return new FileDatabase(context, options);
3110
- }
3111
3245
 
3112
3246
  // src/db/index.ts
3113
3247
  var import_knex = __toESM(require("knex"), 1);
@@ -3406,6 +3540,13 @@ var Db = class {
3406
3540
  isConnectedToDb() {
3407
3541
  return this.isConnected && this.knexInstance !== null;
3408
3542
  }
3543
+ /**
3544
+ * Initialize Db with context (connects and registers disconnect cleanup).
3545
+ * Params are read via getAllForModule("db", defs). Same as dbInit(context, dbNameOrConnectionString).
3546
+ */
3547
+ static async init(context, dbNameOrConnectionString) {
3548
+ return dbFindAndConnect(context, dbNameOrConnectionString);
3549
+ }
3409
3550
  };
3410
3551
  function capitalizeFirstLetter(str) {
3411
3552
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -3419,7 +3560,7 @@ async function dbConnect(context, connectionString, name, dbProfile) {
3419
3560
  acquireConnectionTimeout: "number default 10000",
3420
3561
  sslRejectUnauthorized: "boolean default false"
3421
3562
  };
3422
- const paramsConfig = context.params.getAll(defs);
3563
+ const paramsConfig = context.params.getAllForModule(defs);
3423
3564
  const config2 = {
3424
3565
  connectionString,
3425
3566
  name: paramsConfig.name || name || "default",
@@ -3469,7 +3610,7 @@ async function dbFindAndConnect(context, dbNameOrConnectionString) {
3469
3610
  dbConnectionString: "string",
3470
3611
  dbProfile: "boolean default false"
3471
3612
  };
3472
- const paramsConfig = context.params.getAll(defs);
3613
+ const paramsConfig = context.params.getAllForModule(defs);
3473
3614
  dbName = paramsConfig.dbName;
3474
3615
  dbConnectionString = paramsConfig.dbConnectionString;
3475
3616
  dbProfile = paramsConfig.dbProfile;
@@ -3561,8 +3702,7 @@ var Logger = class _Logger {
3561
3702
  this.updateTransport();
3562
3703
  }
3563
3704
  /**
3564
- * Configure logger options
3565
- * Only parameters present in options are updated
3705
+ * Configure logger options. Accepts both LoggerOptions shape and flat param names (levels string, progressWithTimes, progressThrottleMs).
3566
3706
  */
3567
3707
  configure(options) {
3568
3708
  if (options.mode !== void 0) {
@@ -3572,32 +3712,24 @@ var Logger = class _Logger {
3572
3712
  this.options.route = options.route;
3573
3713
  this.updateTransport();
3574
3714
  }
3575
- if (options.prefix !== void 0) {
3576
- this.options.prefix = options.prefix;
3577
- }
3578
- if (options.silent !== void 0) {
3579
- this.options.silent = options.silent;
3580
- }
3581
- if (options.showLevel !== void 0) {
3582
- this.options.showLevel = options.showLevel;
3583
- }
3584
- if (options.timestamp !== void 0) {
3585
- this.options.timestamp = options.timestamp;
3586
- }
3715
+ if (options.prefix !== void 0) this.options.prefix = options.prefix;
3716
+ if (options.silent !== void 0) this.options.silent = options.silent;
3717
+ if (options.showLevel !== void 0) this.options.showLevel = options.showLevel;
3718
+ if (options.timestamp !== void 0) this.options.timestamp = options.timestamp;
3587
3719
  if (options.levels !== void 0) {
3588
- this.options.levels = this.normalizeLevels(options.levels);
3720
+ const levels = typeof options.levels === "string" ? options.levels.split(",") : options.levels;
3721
+ this.options.levels = this.normalizeLevels(levels);
3589
3722
  }
3590
3723
  if (options.progress !== void 0) {
3591
- if (options.progress.withTimes !== void 0) {
3592
- this.options.progressTimes = options.progress.withTimes;
3593
- }
3594
- if (options.progress.throttleMs !== void 0) {
3595
- this.options.progressThrottle = options.progress.throttleMs;
3596
- }
3724
+ if (options.progress.withTimes !== void 0) this.options.progressTimes = options.progress.withTimes;
3725
+ if (options.progress.throttleMs !== void 0) this.options.progressThrottle = options.progress.throttleMs;
3597
3726
  }
3727
+ const flat = options;
3728
+ if (flat.progressWithTimes !== void 0) this.options.progressTimes = flat.progressWithTimes;
3729
+ if (flat.progressThrottleMs !== void 0) this.options.progressThrottle = flat.progressThrottleMs;
3598
3730
  }
3599
3731
  /**
3600
- * Initialize logger from context and CLI parameters
3732
+ * Initialize logger from context and CLI parameters. Whatever is in options goes (after discovered params).
3601
3733
  */
3602
3734
  static init(context, options) {
3603
3735
  const paramDefs = {
@@ -3611,20 +3743,8 @@ var Logger = class _Logger {
3611
3743
  progressWithTimes: "boolean default false",
3612
3744
  progressThrottleMs: "number"
3613
3745
  };
3614
- const cliParams = context.params.getAll(paramDefs);
3615
- const config2 = {
3616
- mode: options?.mode ?? cliParams.mode,
3617
- route: options?.route ?? cliParams.route,
3618
- prefix: options?.prefix ?? cliParams.prefix,
3619
- silent: options?.silent ?? cliParams.silent,
3620
- showLevel: options?.showLevel ?? cliParams.showLevel,
3621
- timestamp: options?.timestamp ?? cliParams.timestamp,
3622
- levels: options?.levels ?? (cliParams.levels ? cliParams.levels.split(",") : void 0),
3623
- progress: options?.progress ?? {
3624
- withTimes: cliParams.progressWithTimes,
3625
- throttleMs: cliParams.progressThrottleMs
3626
- }
3627
- };
3746
+ const discovered = context.params.getAllForModule(paramDefs);
3747
+ const config2 = { ...discovered, ...options };
3628
3748
  const logger = new _Logger(context, config2);
3629
3749
  context.logger = logger;
3630
3750
  return logger;
@@ -3651,6 +3771,10 @@ var Logger = class _Logger {
3651
3771
  }
3652
3772
  this.options.mode = mode;
3653
3773
  }
3774
+ /** Returns a styled string (bright white) for highlighting; keeps chalk inside logger. */
3775
+ highlight(text) {
3776
+ return import_chalk.default.whiteBright(text);
3777
+ }
3654
3778
  debug(message, ...chunks) {
3655
3779
  this.out({ level: "debug", message, chunks });
3656
3780
  }
@@ -3826,12 +3950,7 @@ function extractComponentOptions(opts, componentName) {
3826
3950
  return componentOptions;
3827
3951
  }
3828
3952
  function setup(opts = {}) {
3829
- const args = Args.init({
3830
- overrides: opts.overrides || {},
3831
- defaults: opts.defaults || {}
3832
- });
3833
3953
  const partialContext = {
3834
- args,
3835
3954
  emitter: new import_events.EventEmitter(),
3836
3955
  isStop: () => false,
3837
3956
  cleanupFunctions: [],
@@ -3839,6 +3958,11 @@ function setup(opts = {}) {
3839
3958
  partialContext.cleanupFunctions.push(fn);
3840
3959
  }
3841
3960
  };
3961
+ const args = Args.init(partialContext, {
3962
+ overrides: opts.overrides || {},
3963
+ defaults: opts.defaults || {}
3964
+ });
3965
+ partialContext.args = args;
3842
3966
  const params = Params.init(partialContext, opts.overrides || {});
3843
3967
  partialContext.params = params;
3844
3968
  const loggerOptions = extractComponentOptions(opts, "logger");
@@ -3892,7 +4016,6 @@ function setupContext(opts = {}) {
3892
4016
  dbInit,
3893
4017
  defaultFileSynopsisFunction,
3894
4018
  defaultVersionSynopsisFunction,
3895
- fileDatabaseInit,
3896
4019
  getArgsInstance,
3897
4020
  h,
3898
4021
  joiEdateType,