@dereekb/dbx-cli 13.11.1 → 13.11.2

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/index.esm.js CHANGED
@@ -1658,7 +1658,7 @@ function mergeOutputCommandsConfig(existing, updates) {
1658
1658
  * The `model.*` write scopes filtered out by {@link filterReadOnlyModelScopes}.
1659
1659
  *
1660
1660
  * Mirrors the write half of the dbx-components callModel CRUD scope set
1661
- * (`CALL_MODEL_OIDC_SCOPES` in `@dereekb/firebase-server/oidc`) — duplicated here so the
1661
+ * (`CALL_MODEL_OIDC_SCOPES` in `@dereekb/firebase`) — duplicated here so the
1662
1662
  * CLI doesn't take a server-side dependency just to know the names.
1663
1663
  */ var MODEL_WRITE_OIDC_SCOPES = [
1664
1664
  'model.create',
@@ -7091,6 +7091,15 @@ var SKIPPED_VERBS = new Set([
7091
7091
  'standalone'
7092
7092
  ]);
7093
7093
  var ALL_HELP_FLAG = '--all-help';
7094
+ var HELP_MODE_FLAG = '--help-mode';
7095
+ /**
7096
+ * Default help mode when no override is supplied.
7097
+ */ var DEFAULT_MANIFEST_HELP_MODE = 'both';
7098
+ var MANIFEST_HELP_MODES = new Set([
7099
+ 'action',
7100
+ 'params',
7101
+ 'both'
7102
+ ]);
7094
7103
  /**
7095
7104
  * Default schema format when no override is supplied.
7096
7105
  */ var DEFAULT_MANIFEST_HELP_DATA_FORMAT = 'jsonschema';
@@ -7123,7 +7132,7 @@ var DATA_HELP_FLAG = '--data-help';
7123
7132
  * @returns The yargs `CommandModule[]` ready to be passed to `runCli({ apiCommands })`. Empty
7124
7133
  * when the manifest has no callable entries.
7125
7134
  */ function buildManifestCommands(manifest, options) {
7126
- var _ref, _ref1, _ref2, _ref3, _ref4;
7135
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
7127
7136
  var callable = manifest.filter(function(e) {
7128
7137
  return !SKIPPED_VERBS.has(e.verb);
7129
7138
  });
@@ -7160,15 +7169,17 @@ var DATA_HELP_FLAG = '--data-help';
7160
7169
  }
7161
7170
  var argv = (_ref = options === null || options === void 0 ? void 0 : options.argv) !== null && _ref !== void 0 ? _ref : process.argv;
7162
7171
  var dataHelpFormat = (_ref1 = options === null || options === void 0 ? void 0 : options.dataHelpFormat) !== null && _ref1 !== void 0 ? _ref1 : detectDataHelpFormat(argv);
7163
- var focusHelp = ((_ref2 = options === null || options === void 0 ? void 0 : options.focusHelpOnDataHelp) !== null && _ref2 !== void 0 ? _ref2 : true) && hasDataHelpFlag(argv) && !hasAllHelpFlag(argv);
7164
- var hideOnFocus = focusHelp ? (_ref3 = options === null || options === void 0 ? void 0 : options.hiddenWhenFocused) !== null && _ref3 !== void 0 ? _ref3 : STANDARD_GLOBAL_OPTION_NAMES : [];
7165
- var modelCommandName = (_ref4 = options === null || options === void 0 ? void 0 : options.modelCommandName) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_MANIFEST_MODEL_COMMAND_NAME;
7172
+ var helpMode = (_ref2 = options === null || options === void 0 ? void 0 : options.helpMode) !== null && _ref2 !== void 0 ? _ref2 : detectHelpMode(argv);
7173
+ var focusHelp = ((_ref3 = options === null || options === void 0 ? void 0 : options.focusHelpOnDataHelp) !== null && _ref3 !== void 0 ? _ref3 : true) && hasDataHelpFlag(argv) && !hasAllHelpFlag(argv);
7174
+ var hideOnFocus = focusHelp ? (_ref4 = options === null || options === void 0 ? void 0 : options.hiddenWhenFocused) !== null && _ref4 !== void 0 ? _ref4 : STANDARD_GLOBAL_OPTION_NAMES : [];
7175
+ var modelCommandName = (_ref5 = options === null || options === void 0 ? void 0 : options.modelCommandName) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_MANIFEST_MODEL_COMMAND_NAME;
7166
7176
  var sortedModels = _to_consumable_array(byModel.entries()).sort(function(param, param1) {
7167
7177
  var _param = _sliced_to_array(param, 1), a = _param[0], _param1 = _sliced_to_array(param1, 1), b = _param1[0];
7168
7178
  return a.localeCompare(b);
7169
7179
  });
7170
7180
  var context = {
7171
7181
  dataHelpFormat: dataHelpFormat,
7182
+ helpMode: helpMode,
7172
7183
  hideOnFocus: hideOnFocus
7173
7184
  };
7174
7185
  return [
@@ -7261,6 +7272,38 @@ var DATA_HELP_FLAG = '--data-help';
7261
7272
  function parseDataHelpFormat(value) {
7262
7273
  return MANIFEST_HELP_DATA_FORMATS.has(value) ? value : undefined;
7263
7274
  }
7275
+ /**
7276
+ * Inspects an argv array for `--help-mode=<mode>` or `--help-mode <mode>` and
7277
+ * returns the requested {@link ManifestHelpMode}. Unrecognized values fall
7278
+ * back to {@link DEFAULT_MANIFEST_HELP_MODE}.
7279
+ *
7280
+ * Implemented as a raw argv scan (rather than going through yargs) because the
7281
+ * value is needed when each command's builder runs — which is before yargs
7282
+ * parses argv.
7283
+ *
7284
+ * @param argv - argv to inspect (defaults to `process.argv`).
7285
+ * @returns The detected mode, or {@link DEFAULT_MANIFEST_HELP_MODE}.
7286
+ */ function detectHelpMode() {
7287
+ var argv = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.argv;
7288
+ var result = DEFAULT_MANIFEST_HELP_MODE;
7289
+ for(var i = 0; i < argv.length; i++){
7290
+ var arg = argv[i];
7291
+ if (arg.startsWith("".concat(HELP_MODE_FLAG, "="))) {
7292
+ var _parseHelpMode;
7293
+ result = (_parseHelpMode = parseHelpMode(arg.slice(HELP_MODE_FLAG.length + 1))) !== null && _parseHelpMode !== void 0 ? _parseHelpMode : result;
7294
+ break;
7295
+ }
7296
+ if (arg === HELP_MODE_FLAG && i + 1 < argv.length) {
7297
+ var _parseHelpMode1;
7298
+ result = (_parseHelpMode1 = parseHelpMode(argv[i + 1])) !== null && _parseHelpMode1 !== void 0 ? _parseHelpMode1 : result;
7299
+ break;
7300
+ }
7301
+ }
7302
+ return result;
7303
+ }
7304
+ function parseHelpMode(value) {
7305
+ return MANIFEST_HELP_MODES.has(value) ? value : undefined;
7306
+ }
7264
7307
  function buildModelCommand(model, entries, context) {
7265
7308
  return {
7266
7309
  command: "".concat(model, " <action>"),
@@ -7295,14 +7338,15 @@ function buildModelCommand(model, entries, context) {
7295
7338
  };
7296
7339
  }
7297
7340
  function buildEntryCommand(entry, context) {
7298
- var _entry_description;
7341
+ var _oneLineDescription;
7299
7342
  var action = entry.specifier && entry.specifier !== '_' ? "".concat(entry.verb, "-").concat(entry.specifier) : entry.verb;
7300
7343
  var specPart = entry.specifier && entry.specifier !== '_' ? ' ' + entry.specifier : '';
7301
- var describe = (_entry_description = entry.description) !== null && _entry_description !== void 0 ? _entry_description : "".concat(entry.verb).concat(specPart, " on ").concat(entry.model);
7302
- var epilogue = buildEntryEpilogue(entry, context.dataHelpFormat);
7344
+ var fallbackDescribe = "".concat(entry.verb).concat(specPart, " on ").concat(entry.model);
7345
+ var describeOneLine = (_oneLineDescription = oneLineDescription(entry.description)) !== null && _oneLineDescription !== void 0 ? _oneLineDescription : fallbackDescribe;
7346
+ var epilogue = buildEntryEpilogue(entry, context);
7303
7347
  return {
7304
7348
  command: action,
7305
- describe: describe,
7349
+ describe: describeOneLine,
7306
7350
  builder: function builder(yargs) {
7307
7351
  var y = yargs.option('data', {
7308
7352
  type: 'string',
@@ -7351,6 +7395,12 @@ function buildEntryCommand(entry, context) {
7351
7395
  }
7352
7396
  };
7353
7397
  }
7398
+ function oneLineDescription(description) {
7399
+ var _description_split_;
7400
+ if (!description) return undefined;
7401
+ var firstLine = (_description_split_ = description.split('\n', 1)[0]) === null || _description_split_ === void 0 ? void 0 : _description_split_.trim();
7402
+ return firstLine && firstLine.length > 0 ? firstLine : undefined;
7403
+ }
7354
7404
  function hideGlobalOptions(yargs, names) {
7355
7405
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7356
7406
  try {
@@ -7374,37 +7424,145 @@ function hideGlobalOptions(yargs, names) {
7374
7424
  }
7375
7425
  }
7376
7426
  /**
7377
- * Builds the help epilogue for a manifest-driven command. Surfaces the params
7378
- * arktype validator (as JSON Schema and/or the arktype expression — see
7379
- * {@link ManifestHelpDataFormat}) along with the params/result type names and
7380
- * the source `.api.ts` path for traceability. Designed to give both humans
7381
- * and LLM agents enough information from `--help` alone to construct a valid
7382
- * `--data` payload.
7427
+ * Builds the help epilogue for a manifest-driven command. Surfaces the action
7428
+ * description JSDoc, the params interface description and per-field
7429
+ * descriptions, the params arktype validator (as JSON Schema and/or arktype
7430
+ * expression — see {@link ManifestHelpDataFormat}), and the source `.api.ts`
7431
+ * path for traceability. Designed to give both humans and LLM agents enough
7432
+ * information from `--help` alone to understand a command and construct a
7433
+ * valid `--data` payload.
7383
7434
  *
7384
7435
  * @param entry - Manifest entry whose metadata becomes the help epilogue.
7385
- * @param dataHelpFormat - Format used for the `Params Schema` section.
7436
+ * @param context - Builder context controlling schema format and which sections
7437
+ * to render (see {@link ManifestHelpMode}).
7386
7438
  * @returns Multi-section epilogue string, or `undefined` when the entry has no
7387
7439
  * metadata worth surfacing.
7388
- */ function buildEntryEpilogue(entry, dataHelpFormat) {
7389
- var _sections;
7440
+ */ function buildEntryEpilogue(entry, context) {
7441
+ var dataHelpFormat = context.dataHelpFormat, helpMode = context.helpMode;
7442
+ var showAction = helpMode === 'action' || helpMode === 'both';
7443
+ var showParams = helpMode === 'params' || helpMode === 'both';
7390
7444
  var sections = [];
7391
- if (entry.paramsTypeName) {
7392
- sections.push("Params: ".concat(entry.paramsTypeName));
7393
- }
7394
- var schemaSections = renderParamsSchemaSections(entry, dataHelpFormat);
7395
- (_sections = sections).push.apply(_sections, _to_consumable_array(schemaSections));
7396
- if (entry.resultTypeName) {
7397
- sections.push("Result: ".concat(entry.resultTypeName));
7445
+ if (showAction) {
7446
+ var actionSection = buildActionSection(entry);
7447
+ if (actionSection) sections.push(actionSection);
7448
+ }
7449
+ var schemaSections = [];
7450
+ if (showParams) {
7451
+ var _sections;
7452
+ var paramsSection = buildParamsSection(entry);
7453
+ if (paramsSection) sections.push(paramsSection);
7454
+ schemaSections = renderParamsSchemaSections(entry, dataHelpFormat);
7455
+ (_sections = sections).push.apply(_sections, _to_consumable_array(schemaSections));
7456
+ var resultSection = buildResultSection(entry);
7457
+ if (resultSection) {
7458
+ sections.push(resultSection);
7459
+ } else if (entry.resultTypeName) {
7460
+ sections.push("Result: ".concat(entry.resultTypeName));
7461
+ }
7398
7462
  }
7399
7463
  if (entry.sourceFile) {
7400
7464
  sections.push("Source: ".concat(entry.sourceFile));
7401
7465
  }
7402
- if (schemaSections.length > 0 && dataHelpFormat !== 'both') {
7466
+ if (showParams && schemaSections.length > 0 && dataHelpFormat !== 'both') {
7403
7467
  var other = dataHelpFormat === 'jsonschema' ? 'arktype' : 'jsonschema';
7404
7468
  sections.push("(Pass --data-help=".concat(other, " or --data-help=both to switch the schema format above.)"));
7405
7469
  }
7470
+ if (helpMode === 'both' && (entry.description || entry.paramsTypeDescription || entry.paramsFields && entry.paramsFields.length > 0)) {
7471
+ sections.push("(Pass --help-mode=action or --help-mode=params to focus this help on a single section.)");
7472
+ }
7406
7473
  return sections.length > 0 ? sections.join('\n\n') : undefined;
7407
7474
  }
7475
+ function buildActionSection(entry) {
7476
+ if (!entry.description) return undefined;
7477
+ return "About:\n".concat(indentLines(entry.description, ' '));
7478
+ }
7479
+ function buildParamsSection(entry) {
7480
+ if (!entry.paramsTypeName && !entry.paramsTypeDescription && !(entry.paramsFields && entry.paramsFields.length > 0)) {
7481
+ return undefined;
7482
+ }
7483
+ var lines = [];
7484
+ if (entry.paramsTypeName) {
7485
+ lines.push("Params: ".concat(entry.paramsTypeName));
7486
+ }
7487
+ if (entry.paramsTypeDescription) {
7488
+ lines.push(indentLines(entry.paramsTypeDescription, ' '));
7489
+ }
7490
+ if (entry.paramsFields && entry.paramsFields.length > 0) {
7491
+ lines.push('');
7492
+ lines.push('Fields:');
7493
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7494
+ try {
7495
+ for(var _iterator = entry.paramsFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7496
+ var field = _step.value;
7497
+ var header = " - ".concat(field.name, ": ").concat(field.typeText);
7498
+ lines.push(header);
7499
+ if (field.description) {
7500
+ lines.push(indentLines(field.description, ' '));
7501
+ }
7502
+ }
7503
+ } catch (err) {
7504
+ _didIteratorError = true;
7505
+ _iteratorError = err;
7506
+ } finally{
7507
+ try {
7508
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7509
+ _iterator.return();
7510
+ }
7511
+ } finally{
7512
+ if (_didIteratorError) {
7513
+ throw _iteratorError;
7514
+ }
7515
+ }
7516
+ }
7517
+ }
7518
+ return lines.join('\n');
7519
+ }
7520
+ function buildResultSection(entry) {
7521
+ if (!entry.resultTypeDescription && !(entry.resultFields && entry.resultFields.length > 0)) {
7522
+ return undefined;
7523
+ }
7524
+ var lines = [];
7525
+ if (entry.resultTypeName) {
7526
+ lines.push("Result: ".concat(entry.resultTypeName));
7527
+ }
7528
+ if (entry.resultTypeDescription) {
7529
+ lines.push(indentLines(entry.resultTypeDescription, ' '));
7530
+ }
7531
+ if (entry.resultFields && entry.resultFields.length > 0) {
7532
+ lines.push('');
7533
+ lines.push('Fields:');
7534
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7535
+ try {
7536
+ for(var _iterator = entry.resultFields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7537
+ var field = _step.value;
7538
+ var header = " - ".concat(field.name, ": ").concat(field.typeText);
7539
+ lines.push(header);
7540
+ if (field.description) {
7541
+ lines.push(indentLines(field.description, ' '));
7542
+ }
7543
+ }
7544
+ } catch (err) {
7545
+ _didIteratorError = true;
7546
+ _iteratorError = err;
7547
+ } finally{
7548
+ try {
7549
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7550
+ _iterator.return();
7551
+ }
7552
+ } finally{
7553
+ if (_didIteratorError) {
7554
+ throw _iteratorError;
7555
+ }
7556
+ }
7557
+ }
7558
+ }
7559
+ return lines.join('\n');
7560
+ }
7561
+ function indentLines(text, indent) {
7562
+ return text.split('\n').map(function(line) {
7563
+ return "".concat(indent).concat(line);
7564
+ }).join('\n');
7565
+ }
7408
7566
  function renderParamsSchemaSections(entry, dataHelpFormat) {
7409
7567
  var sections = [];
7410
7568
  if (!entry.paramsValidator) {
@@ -8108,4 +8266,4 @@ function printPaginatedOutput(input) {
8108
8266
  })();
8109
8267
  }
8110
8268
 
8111
- export { CALL_MODEL_API_PATH, CliError, DEFAULT_CLI_OIDC_SCOPES, DEFAULT_CLI_SECRET_PATTERNS, DEFAULT_MANIFEST_HELP_DATA_FORMAT, DEFAULT_MANIFEST_MODEL_COMMAND_NAME, DUMP_MERGE_MODES, DUMP_OUTPUT_MODES, MODEL_WRITE_OIDC_SCOPES, MULTIPLE_PAGES_OUTPUT_MODES, PROMPT_CANCELLED_ERROR_CODE, STANDARD_GLOBAL_OPTION_NAMES, applyEnvVarOverrides, buildAuthorizationUrl, buildCliPaths, buildDumpFilePath, buildErrorOutput, buildManifestCommands, callModelOverHttp, callPassthroughCommand, configureCliErrorMapper, configureCliSecretPatterns, configureOutputOptions, createAuthCommand, createAuthMiddleware, createCallModelCommand, createCli, createCliContext, createCliTokenCacheStore, createContextSlot, createDoctorCommand, createEnvCommand, createOutputCommand, createOutputMiddleware, defaultDoctorChecks, detectDataHelpFormat, discoverOidcMetadata, dumpTimestamp, exchangeAuthorizationCode, fetchUserInfo, filterReadOnlyModelScopes, findCliEnvDefault, generateOAuthState, generatePkceMaterial, getCliContext, getOutputOptions, isCliEnvConfigComplete, isTokenExpired, loadCliConfig, maskSecret, mergeCliConfig, mergeCliEnvWithDefault, mergeOutputConfig, openStreamingDump, outputError, outputResult, parsePastedRedirect, pickFields, promptLine, refreshAccessToken, requireCliContext, resolveActiveEnvName, resolveOutputConfig, revokeToken, runCli, runPaginatedList, sanitizeString, saveCliConfig, setCliContext, withCallModelArgs, withEnv, withMultiplePages, withOutput, wrapCommandHandler };
8269
+ export { CALL_MODEL_API_PATH, CliError, DEFAULT_CLI_OIDC_SCOPES, DEFAULT_CLI_SECRET_PATTERNS, DEFAULT_MANIFEST_HELP_DATA_FORMAT, DEFAULT_MANIFEST_HELP_MODE, DEFAULT_MANIFEST_MODEL_COMMAND_NAME, DUMP_MERGE_MODES, DUMP_OUTPUT_MODES, MODEL_WRITE_OIDC_SCOPES, MULTIPLE_PAGES_OUTPUT_MODES, PROMPT_CANCELLED_ERROR_CODE, STANDARD_GLOBAL_OPTION_NAMES, applyEnvVarOverrides, buildAuthorizationUrl, buildCliPaths, buildDumpFilePath, buildErrorOutput, buildManifestCommands, callModelOverHttp, callPassthroughCommand, configureCliErrorMapper, configureCliSecretPatterns, configureOutputOptions, createAuthCommand, createAuthMiddleware, createCallModelCommand, createCli, createCliContext, createCliTokenCacheStore, createContextSlot, createDoctorCommand, createEnvCommand, createOutputCommand, createOutputMiddleware, defaultDoctorChecks, detectDataHelpFormat, detectHelpMode, discoverOidcMetadata, dumpTimestamp, exchangeAuthorizationCode, fetchUserInfo, filterReadOnlyModelScopes, findCliEnvDefault, generateOAuthState, generatePkceMaterial, getCliContext, getOutputOptions, isCliEnvConfigComplete, isTokenExpired, loadCliConfig, maskSecret, mergeCliConfig, mergeCliEnvWithDefault, mergeOutputConfig, openStreamingDump, outputError, outputResult, parsePastedRedirect, pickFields, promptLine, refreshAccessToken, requireCliContext, resolveActiveEnvName, resolveOutputConfig, revokeToken, runCli, runPaginatedList, sanitizeString, saveCliConfig, setCliContext, withCallModelArgs, withEnv, withMultiplePages, withOutput, wrapCommandHandler };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hapier Creative LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ exports._default = require('./index.cjs.js').default;