@atlaskit/ads-cli 0.4.2 → 0.6.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 (48) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +62 -10
  3. package/bin/ads-cli.js +5 -1
  4. package/dist/cjs/atlas-cli.js +4 -1
  5. package/dist/cjs/cli.js +368 -70
  6. package/dist/cjs/commands/build-manifest.js +1 -2
  7. package/dist/cjs/commands/cli-metadata.js +2 -1
  8. package/dist/cjs/commands/definitions.js +100 -16
  9. package/dist/cjs/output/format-disambiguation.js +3 -1
  10. package/dist/cjs/output/format-grouped-results.js +6 -2
  11. package/dist/cjs/output/format-human-result.js +33 -0
  12. package/dist/cjs/output/format-manifest.js +5 -3
  13. package/dist/cjs/output/format-results.js +25 -18
  14. package/dist/cjs/output/write-human-result.js +8 -10
  15. package/dist/es2019/atlas-cli.js +4 -1
  16. package/dist/es2019/cli.js +273 -29
  17. package/dist/es2019/commands/build-manifest.js +1 -2
  18. package/dist/es2019/commands/cli-metadata.js +1 -0
  19. package/dist/es2019/commands/definitions.js +77 -6
  20. package/dist/es2019/output/format-disambiguation.js +3 -2
  21. package/dist/es2019/output/format-grouped-results.js +5 -2
  22. package/dist/es2019/output/format-human-result.js +28 -0
  23. package/dist/es2019/output/format-manifest.js +6 -3
  24. package/dist/es2019/output/format-results.js +25 -18
  25. package/dist/es2019/output/write-human-result.js +8 -9
  26. package/dist/esm/atlas-cli.js +4 -1
  27. package/dist/esm/cli.js +369 -71
  28. package/dist/esm/commands/build-manifest.js +1 -2
  29. package/dist/esm/commands/cli-metadata.js +1 -0
  30. package/dist/esm/commands/definitions.js +100 -16
  31. package/dist/esm/output/format-disambiguation.js +3 -1
  32. package/dist/esm/output/format-grouped-results.js +6 -2
  33. package/dist/esm/output/format-human-result.js +27 -0
  34. package/dist/esm/output/format-manifest.js +5 -3
  35. package/dist/esm/output/format-results.js +26 -18
  36. package/dist/esm/output/write-human-result.js +8 -9
  37. package/dist/types/cli.d.ts +10 -1
  38. package/dist/types/commands/build-manifest.d.ts +1 -2
  39. package/dist/types/commands/cli-metadata.d.ts +1 -0
  40. package/dist/types/commands/types.d.ts +28 -1
  41. package/dist/types/output/format-disambiguation.d.ts +1 -1
  42. package/dist/types/output/format-grouped-results.d.ts +2 -1
  43. package/dist/types/output/format-human-result.d.ts +17 -0
  44. package/dist/types/output/format-manifest.d.ts +2 -1
  45. package/dist/types/output/format-results.d.ts +4 -3
  46. package/dist/types/output/write-human-result.d.ts +2 -2
  47. package/dist/types/parse-args.d.ts +1 -1
  48. package/package.json +1 -1
package/dist/cjs/cli.js CHANGED
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.run = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
13
  var _cliMetadata = require("./commands/cli-metadata");
12
14
  var _definitions = require("./commands/definitions");
13
15
  var _getCommand = require("./commands/get-command");
@@ -17,7 +19,9 @@ var _runTool = require("./commands/run-tool");
17
19
  var _createErrorEnvelope = require("./envelope/create-error-envelope");
18
20
  var _createSuccessEnvelope = require("./envelope/create-success-envelope");
19
21
  var _createDocSearchResults = require("./output/create-doc-search-results");
22
+ var _disambiguation = require("./output/disambiguation");
20
23
  var _formatGroupedResults = require("./output/format-grouped-results");
24
+ var _formatHumanResult = require("./output/format-human-result");
21
25
  var _formatResults = require("./output/format-results");
22
26
  var _writeHumanError = require("./output/write-human-error");
23
27
  var _writeHumanResult = require("./output/write-human-result");
@@ -43,7 +47,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
43
47
  * Build the top-level help text from the command registry so it can never drift from the
44
48
  * runnable surface.
45
49
  */
46
- var buildHelpText = function buildHelpText() {
50
+ var buildHelpText = function buildHelpText(invocation) {
47
51
  // Width of the usage "gutter"; descriptions align to this column. Usages longer than the
48
52
  // gutter wrap onto their own line with the description indented beneath, so a long usage
49
53
  // (e.g. `docs`, which lists every topic) never produces a single 130-column line.
@@ -63,20 +67,64 @@ var buildHelpText = function buildHelpText() {
63
67
  var aliases = flag.alias ? ", -".concat(flag.alias) : '';
64
68
  return " --".concat(flag.name).concat(aliases).padEnd(18) + flag.description;
65
69
  }).join('\n');
66
- return [_cliMetadata.CLI_DESCRIPTION, '', 'Usage', ' $ npx @atlaskit/ads-cli <command> [options]', '', 'Commands', commandLines, '', 'Global options', globalFlagLines, '', 'Examples', ' $ npx @atlaskit/ads-cli search contrast # unified: components, tokens, icons & docs', ' $ npx @atlaskit/ads-cli search button --type component', ' $ npx @atlaskit/ads-cli search contrast --type docs', ' $ npx @atlaskit/ads-cli component Button # detail for one component', ' $ npx @atlaskit/ads-cli token space.100 # detail for one token', ' $ npx @atlaskit/ads-cli icon --all # list every icon', ' $ npx @atlaskit/ads-cli docs spacing # foundations docs', ' $ npx @atlaskit/ads-cli docs a11y buttons # accessibility guidance', ' $ npx @atlaskit/ads-cli docs migration motion # migration guide', ' $ npx @atlaskit/ads-cli manifest --json # machine-readable CLI contract'].join('\n');
70
+ var examples = [{
71
+ command: 'search contrast',
72
+ comment: 'unified: components, tokens, icons & docs'
73
+ }, {
74
+ command: 'batch --command search button --type icon --command token space.200',
75
+ comment: 'independent commands in one process'
76
+ }, {
77
+ command: 'search button --type component'
78
+ }, {
79
+ command: 'search contrast --type docs'
80
+ }, {
81
+ command: 'component Button',
82
+ comment: 'detail for one component'
83
+ }, {
84
+ command: 'token space.100',
85
+ comment: 'detail for one token'
86
+ }, {
87
+ command: 'icon --all',
88
+ comment: 'list every icon'
89
+ }, {
90
+ command: 'docs spacing',
91
+ comment: 'foundations docs'
92
+ }, {
93
+ command: 'docs a11y buttons',
94
+ comment: 'accessibility guidance'
95
+ }, {
96
+ command: 'docs migration motion',
97
+ comment: 'migration guide'
98
+ }, {
99
+ command: 'manifest --json',
100
+ comment: 'machine-readable CLI contract'
101
+ }];
102
+ var exampleCommands = examples.map(function (_ref) {
103
+ var command = _ref.command;
104
+ return "$ ".concat(invocation, " ").concat(command);
105
+ });
106
+ var exampleWidth = Math.max.apply(Math, (0, _toConsumableArray2.default)(exampleCommands.map(function (command) {
107
+ return command.length;
108
+ })));
109
+ var exampleLines = examples.map(function (_ref2, index) {
110
+ var comment = _ref2.comment;
111
+ var command = exampleCommands[index];
112
+ return " ".concat(comment ? "".concat(command.padEnd(exampleWidth), " # ").concat(comment) : command);
113
+ }).join('\n');
114
+ return [_cliMetadata.CLI_DESCRIPTION, '', 'Usage', " $ ".concat(invocation, " <command> [options]"), '', 'Commands', commandLines, '', 'Global options', globalFlagLines, '', 'Examples', exampleLines].join('\n');
67
115
  };
68
116
 
69
117
  /**
70
118
  * Execute a registry-backed command: resolve its tool + args, dispatch, and format output.
71
119
  */
72
120
  var runRegistryCommand = /*#__PURE__*/function () {
73
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref) {
121
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
74
122
  var _resolved$meta3;
75
- var command, input, json, writer, resolved, _resolved$meta, results, _resolved$meta2;
123
+ var command, input, json, writer, invocation, resolved, _resolved$meta, results, _resolved$meta2;
76
124
  return _regenerator.default.wrap(function (_context2) {
77
125
  while (1) switch (_context2.prev = _context2.next) {
78
126
  case 0:
79
- command = _ref.command, input = _ref.input, json = _ref.json, writer = _ref.writer;
127
+ command = _ref3.command, input = _ref3.input, json = _ref3.json, writer = _ref3.writer, invocation = _ref3.invocation;
80
128
  resolved = command.resolve(input); // A resolver returning `{ error }` indicates invalid input (a usage error).
81
129
  if (!('error' in resolved)) {
82
130
  _context2.next = 1;
@@ -113,12 +161,25 @@ var runRegistryCommand = /*#__PURE__*/function () {
113
161
  },
114
162
  meta: (_resolved$meta = resolved.meta) !== null && _resolved$meta !== void 0 ? _resolved$meta : {},
115
163
  json: json,
116
- writer: writer
164
+ writer: writer,
165
+ invocation: invocation
117
166
  }));
118
167
  case 2:
119
- _context2.next = 3;
168
+ if (!resolved.batch) {
169
+ _context2.next = 3;
170
+ break;
171
+ }
172
+ return _context2.abrupt("return", runBatchRequests({
173
+ command: command,
174
+ requests: resolved.batch,
175
+ json: json,
176
+ writer: writer,
177
+ invocation: invocation
178
+ }));
179
+ case 3:
180
+ _context2.next = 4;
120
181
  return Promise.all(resolved.tools.map( /*#__PURE__*/function () {
121
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tool) {
182
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tool) {
122
183
  var handler, _t, _t2;
123
184
  return _regenerator.default.wrap(function (_context) {
124
185
  while (1) switch (_context.prev = _context.next) {
@@ -148,13 +209,13 @@ var runRegistryCommand = /*#__PURE__*/function () {
148
209
  }, _callee);
149
210
  }));
150
211
  return function (_x2) {
151
- return _ref3.apply(this, arguments);
212
+ return _ref5.apply(this, arguments);
152
213
  };
153
214
  }()));
154
- case 3:
215
+ case 4:
155
216
  results = _context2.sent;
156
217
  if (!resolved.grouped) {
157
- _context2.next = 4;
218
+ _context2.next = 5;
158
219
  break;
159
220
  }
160
221
  return _context2.abrupt("return", renderGroupedResult({
@@ -163,39 +224,70 @@ var runRegistryCommand = /*#__PURE__*/function () {
163
224
  results: results,
164
225
  meta: (_resolved$meta2 = resolved.meta) !== null && _resolved$meta2 !== void 0 ? _resolved$meta2 : {},
165
226
  json: json,
166
- writer: writer
227
+ writer: writer,
228
+ invocation: invocation
167
229
  }));
168
- case 4:
230
+ case 5:
169
231
  return _context2.abrupt("return", renderSingleResult({
170
232
  command: command,
171
233
  input: input,
172
234
  result: results[0],
173
235
  meta: (_resolved$meta3 = resolved.meta) !== null && _resolved$meta3 !== void 0 ? _resolved$meta3 : {},
174
236
  json: json,
175
- writer: writer
237
+ writer: writer,
238
+ invocation: invocation
176
239
  }));
177
- case 5:
240
+ case 6:
178
241
  case "end":
179
242
  return _context2.stop();
180
243
  }
181
244
  }, _callee2);
182
245
  }));
183
246
  return function runRegistryCommand(_x) {
184
- return _ref2.apply(this, arguments);
247
+ return _ref4.apply(this, arguments);
185
248
  };
186
249
  }();
187
250
 
251
+ /**
252
+ * Render a command's already-transformed payload as human-readable text.
253
+ *
254
+ * Tried in order:
255
+ * 1. Compact per-row view when the command declares a result kind (search/list).
256
+ * 2. The command's own `formatHuman` renderer for rich single-object payloads
257
+ * (component docs, a11y/migration guides, lint-rule markdown).
258
+ *
259
+ * Returns `null` when neither step applies, leaving the caller to choose its own last-resort
260
+ * fallback. Shared by the single-command path and `batch` so the two cannot drift apart.
261
+ */
262
+ var formatCommandHuman = function formatCommandHuman(_ref6) {
263
+ var _command$resultKind, _ref7, _command$formatHuman;
264
+ var command = _ref6.command,
265
+ input = _ref6.input,
266
+ data = _ref6.data,
267
+ invocation = _ref6.invocation;
268
+ var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
269
+ var compact = resultKind ? (0, _formatResults.formatCompactResults)({
270
+ kind: resultKind,
271
+ data: data,
272
+ showFollowUp: command.name === 'search',
273
+ invocation: invocation
274
+ }) : null;
275
+ return (_ref7 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data, {
276
+ invocation: invocation
277
+ })) !== null && _ref7 !== void 0 ? _ref7 : null;
278
+ };
279
+
188
280
  /**
189
281
  * Render a single-tool command result (the common case).
190
282
  */
191
- var renderSingleResult = function renderSingleResult(_ref4) {
192
- var _command$resultKind, _ref5, _command$formatHuman;
193
- var command = _ref4.command,
194
- input = _ref4.input,
195
- result = _ref4.result,
196
- meta = _ref4.meta,
197
- json = _ref4.json,
198
- writer = _ref4.writer;
283
+ var renderSingleResult = function renderSingleResult(_ref8) {
284
+ var command = _ref8.command,
285
+ input = _ref8.input,
286
+ result = _ref8.result,
287
+ meta = _ref8.meta,
288
+ json = _ref8.json,
289
+ writer = _ref8.writer,
290
+ invocation = _ref8.invocation;
199
291
  var isError = result.isError;
200
292
 
201
293
  // The ADS search tools return an `Error: No … found` text block when nothing matches.
@@ -261,19 +353,14 @@ var renderSingleResult = function renderSingleResult(_ref4) {
261
353
  return _types.ExitCode.Ok;
262
354
  }
263
355
 
264
- // Default (human) output, tried in order:
265
- // 1. Compact per-row view when the command declares a result kind (search/list).
266
- // 2. The command's own `formatHuman` renderer for rich single-object payloads
267
- // (component docs, a11y/migration guides, lint-rule markdown).
268
- // 3. The generic fallback: verbatim strings (e.g. foundations markdown) or pretty JSON.
269
- // Each step returns `null` to defer to the next, so a raw JSON dump is only ever a last resort.
270
- var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
271
- var compact = resultKind ? (0, _formatResults.formatCompactResults)({
272
- kind: resultKind,
356
+ // Default (human) output: the shared renderer, falling back to verbatim strings (e.g.
357
+ // foundations markdown) or pretty JSON so a raw dump is only ever a last resort.
358
+ var human = formatCommandHuman({
359
+ command: command,
360
+ input: input,
273
361
  data: data,
274
- showFollowUp: command.name === 'search'
275
- }) : null;
276
- var human = (_ref5 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data)) !== null && _ref5 !== void 0 ? _ref5 : null;
362
+ invocation: invocation
363
+ });
277
364
  if (human !== null) {
278
365
  writer.out(human);
279
366
  } else {
@@ -284,6 +371,209 @@ var renderSingleResult = function renderSingleResult(_ref4) {
284
371
  }
285
372
  return _types.ExitCode.Ok;
286
373
  };
374
+ var classifyBatchResponse = function classifyBatchResponse(response) {
375
+ if (!response.ok) {
376
+ return 'failure';
377
+ }
378
+ return (0, _disambiguation.isDisambiguation)(response.data) ? 'ambiguous' : 'success';
379
+ };
380
+ var createCapturedWriter = function createCapturedWriter() {
381
+ var stdout = [];
382
+ var stderr = [];
383
+ return {
384
+ stdout: stdout,
385
+ stderr: stderr,
386
+ out: function out(line) {
387
+ return stdout.push(line);
388
+ },
389
+ err: function err(line) {
390
+ return stderr.push(line);
391
+ }
392
+ };
393
+ };
394
+
395
+ /**
396
+ * Execute one child argv through the normal CLI pipeline, forcing JSON so the parent can preserve
397
+ * the child's stable envelope without scraping human-readable output.
398
+ *
399
+ * There is deliberately no `--help`/`--version` guard here. Every child token is also a top-level
400
+ * token, so {@link run} already short-circuits the whole invocation to help/version text before a
401
+ * batch is ever resolved — a guard at this level would be unreachable.
402
+ */
403
+ var runBatchChild = /*#__PURE__*/function () {
404
+ var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref9) {
405
+ var request, invocation, parsed, response, captured;
406
+ return _regenerator.default.wrap(function (_context3) {
407
+ while (1) switch (_context3.prev = _context3.next) {
408
+ case 0:
409
+ request = _ref9.request, invocation = _ref9.invocation;
410
+ parsed = (0, _parseArgs2.parseArgs)(request.argv);
411
+ if (parsed.command) {
412
+ _context3.next = 1;
413
+ break;
414
+ }
415
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
416
+ command: 'batch',
417
+ code: 'USAGE_ERROR',
418
+ message: 'A batch request must start with a command name.'
419
+ });
420
+ _context3.next = 4;
421
+ break;
422
+ case 1:
423
+ if (!(parsed.command === 'batch')) {
424
+ _context3.next = 2;
425
+ break;
426
+ }
427
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
428
+ command: 'batch',
429
+ code: 'USAGE_ERROR',
430
+ message: 'Nested batch requests are not supported.'
431
+ });
432
+ _context3.next = 4;
433
+ break;
434
+ case 2:
435
+ captured = createCapturedWriter();
436
+ _context3.next = 3;
437
+ return run([].concat((0, _toConsumableArray2.default)(request.argv), ['--json']), captured, {
438
+ invocation: invocation
439
+ });
440
+ case 3:
441
+ try {
442
+ response = JSON.parse(captured.stdout.join('\n'));
443
+ } catch (_unused) {
444
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
445
+ command: parsed.command,
446
+ code: 'RUNTIME_ERROR',
447
+ message: 'The child command did not produce a valid JSON envelope.'
448
+ });
449
+ }
450
+ case 4:
451
+ return _context3.abrupt("return", {
452
+ request: request.argv,
453
+ status: classifyBatchResponse(response),
454
+ response: response
455
+ });
456
+ case 5:
457
+ case "end":
458
+ return _context3.stop();
459
+ }
460
+ }, _callee3);
461
+ }));
462
+ return function runBatchChild(_x3) {
463
+ return _ref0.apply(this, arguments);
464
+ };
465
+ }();
466
+
467
+ /**
468
+ * Render an already-transformed child success envelope with the same human format as its command.
469
+ */
470
+ var formatBatchChildHuman = function formatBatchChildHuman(_ref1) {
471
+ var item = _ref1.item,
472
+ invocation = _ref1.invocation;
473
+ if (!item.response.ok) {
474
+ return "Error: ".concat(item.response.error.message);
475
+ }
476
+ var parsed = (0, _parseArgs2.parseArgs)(item.request);
477
+ var definition = parsed.command ? (0, _getCommand.getCommand)(parsed.command) : undefined;
478
+ if (!definition) {
479
+ return (0, _formatHumanResult.formatHumanResult)({
480
+ data: item.response.data
481
+ });
482
+ }
483
+
484
+ // A unified search spans every kind, so it has no single result kind and needs the grouped
485
+ // formatter instead. This is the same condition `search`'s own resolver uses to choose the
486
+ // grouped path, so the two cannot disagree.
487
+ if (definition.name === 'search' && parsed.flags.type === undefined && (0, _typeof2.default)(item.response.data) === 'object' && item.response.data !== null) {
488
+ var _item$response$meta$c;
489
+ return (0, _formatGroupedResults.formatGroupedResults)({
490
+ groups: item.response.data,
491
+ totalCount: Number((_item$response$meta$c = item.response.meta.count) !== null && _item$response$meta$c !== void 0 ? _item$response$meta$c : 0),
492
+ invocation: invocation
493
+ });
494
+ }
495
+ var human = formatCommandHuman({
496
+ command: definition,
497
+ input: {
498
+ positionals: parsed.positionals,
499
+ flags: parsed.flags
500
+ },
501
+ data: item.response.data,
502
+ invocation: invocation
503
+ });
504
+ return human !== null && human !== void 0 ? human : (0, _formatHumanResult.formatHumanResult)({
505
+ data: item.response.data
506
+ });
507
+ };
508
+
509
+ /**
510
+ * Execute heterogeneous registered commands concurrently in the current process and aggregate
511
+ * their existing envelopes. A valid batch exits zero even when individual child commands fail.
512
+ */
513
+ var runBatchRequests = /*#__PURE__*/function () {
514
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref10) {
515
+ var command, requests, json, writer, invocation, items, succeeded, ambiguous, failed, summary, sections;
516
+ return _regenerator.default.wrap(function (_context4) {
517
+ while (1) switch (_context4.prev = _context4.next) {
518
+ case 0:
519
+ command = _ref10.command, requests = _ref10.requests, json = _ref10.json, writer = _ref10.writer, invocation = _ref10.invocation;
520
+ _context4.next = 1;
521
+ return Promise.all(requests.map(function (request) {
522
+ return runBatchChild({
523
+ request: request,
524
+ invocation: invocation
525
+ });
526
+ }));
527
+ case 1:
528
+ items = _context4.sent;
529
+ succeeded = items.filter(function (item) {
530
+ return item.status === 'success';
531
+ }).length;
532
+ ambiguous = items.filter(function (item) {
533
+ return item.status === 'ambiguous';
534
+ }).length;
535
+ failed = items.length - succeeded - ambiguous;
536
+ if (!json) {
537
+ _context4.next = 2;
538
+ break;
539
+ }
540
+ (0, _writeJsonEnvelope.writeJsonEnvelope)({
541
+ envelope: (0, _createSuccessEnvelope.createSuccessEnvelope)({
542
+ envelopeType: command.envelopeType({
543
+ positionals: [],
544
+ flags: {}
545
+ }),
546
+ command: command.name,
547
+ data: items,
548
+ meta: {
549
+ succeeded: succeeded,
550
+ ambiguous: ambiguous,
551
+ failed: failed
552
+ }
553
+ }),
554
+ writer: writer
555
+ });
556
+ return _context4.abrupt("return", _types.ExitCode.Ok);
557
+ case 2:
558
+ summary = "Batch results: ".concat(succeeded, " succeeded, ").concat(ambiguous, " ambiguous, ").concat(failed, " failed");
559
+ sections = items.map(function (item) {
560
+ return "Request: ".concat(item.request.join(' '), "\n").concat(formatBatchChildHuman({
561
+ item: item,
562
+ invocation: invocation
563
+ }));
564
+ });
565
+ writer.out([summary].concat((0, _toConsumableArray2.default)(sections)).join('\n\n'));
566
+ return _context4.abrupt("return", _types.ExitCode.Ok);
567
+ case 3:
568
+ case "end":
569
+ return _context4.stop();
570
+ }
571
+ }, _callee4);
572
+ }));
573
+ return function runBatchRequests(_x4) {
574
+ return _ref11.apply(this, arguments);
575
+ };
576
+ }();
287
577
 
288
578
  /**
289
579
  * Render a grouped (multi-tool) command result, e.g. unified `search`.
@@ -291,13 +581,14 @@ var renderSingleResult = function renderSingleResult(_ref4) {
291
581
  * Each sub-result is keyed by its {@link ToolCall.key}. A sub-search that finds nothing simply
292
582
  * contributes an empty array; the command is only treated as NOT_FOUND when every group is empty.
293
583
  */
294
- var renderGroupedResult = function renderGroupedResult(_ref6) {
295
- var command = _ref6.command,
296
- input = _ref6.input,
297
- results = _ref6.results,
298
- meta = _ref6.meta,
299
- json = _ref6.json,
300
- writer = _ref6.writer;
584
+ var renderGroupedResult = function renderGroupedResult(_ref12) {
585
+ var command = _ref12.command,
586
+ input = _ref12.input,
587
+ results = _ref12.results,
588
+ meta = _ref12.meta,
589
+ json = _ref12.json,
590
+ writer = _ref12.writer,
591
+ invocation = _ref12.invocation;
301
592
  // Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
302
593
  // empty domain does not blank out the others. The guidelines tool returns full Markdown, so
303
594
  // summarize its highest-ranked match for search; `docs <query>` remains the detail view.
@@ -364,22 +655,26 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
364
655
  }
365
656
  writer.out((0, _formatGroupedResults.formatGroupedResults)({
366
657
  groups: grouped,
367
- totalCount: totalCount
658
+ totalCount: totalCount,
659
+ invocation: invocation
368
660
  }));
369
661
  return _types.ExitCode.Ok;
370
662
  };
371
-
372
663
  /**
373
664
  * Parse and execute a single CLI invocation.
374
665
  *
375
666
  * @param argv - Arguments after `node <script>` (i.e. `process.argv.slice(2)`).
376
667
  * @param writer - Injectable output sink; defaults to console-backed stdout/stderr.
668
+ * @param options - Distribution-specific rendering options.
377
669
  * @returns The process exit code. The bin wrapper maps this onto `process.exit`.
378
670
  */
379
671
  var run = exports.run = /*#__PURE__*/function () {
380
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
672
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
381
673
  var argv,
382
674
  writer,
675
+ _ref14,
676
+ _ref14$invocation,
677
+ invocation,
383
678
  _parseArgs,
384
679
  command,
385
680
  positionals,
@@ -388,32 +683,33 @@ var run = exports.run = /*#__PURE__*/function () {
388
683
  definition,
389
684
  message,
390
685
  _message2,
391
- _args3 = arguments,
686
+ _args5 = arguments,
392
687
  _t3;
393
- return _regenerator.default.wrap(function (_context3) {
394
- while (1) switch (_context3.prev = _context3.next) {
688
+ return _regenerator.default.wrap(function (_context5) {
689
+ while (1) switch (_context5.prev = _context5.next) {
395
690
  case 0:
396
- argv = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.argv.slice(2);
397
- writer = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : _writer.defaultWriter;
691
+ argv = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : process.argv.slice(2);
692
+ writer = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : _writer.defaultWriter;
693
+ _ref14 = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {}, _ref14$invocation = _ref14.invocation, invocation = _ref14$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref14$invocation;
398
694
  _parseArgs = (0, _parseArgs2.parseArgs)(argv), command = _parseArgs.command, positionals = _parseArgs.positionals, flags = _parseArgs.flags;
399
695
  json = flags.json === true; // `--version` / `-v` takes precedence and short-circuits.
400
696
  if (!(flags.version === true)) {
401
- _context3.next = 1;
697
+ _context5.next = 1;
402
698
  break;
403
699
  }
404
700
  writer.out((0, _getVersion.getVersion)());
405
- return _context3.abrupt("return", _types.ExitCode.Ok);
701
+ return _context5.abrupt("return", _types.ExitCode.Ok);
406
702
  case 1:
407
703
  if (!(flags.help === true || command === undefined)) {
408
- _context3.next = 2;
704
+ _context5.next = 2;
409
705
  break;
410
706
  }
411
- writer.out(buildHelpText());
412
- return _context3.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
707
+ writer.out(buildHelpText(invocation));
708
+ return _context5.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
413
709
  case 2:
414
710
  definition = (0, _getCommand.getCommand)(command);
415
711
  if (definition) {
416
- _context3.next = 3;
712
+ _context5.next = 3;
417
713
  break;
418
714
  }
419
715
  message = "Unknown command \"".concat(command, "\".");
@@ -431,26 +727,28 @@ var run = exports.run = /*#__PURE__*/function () {
431
727
  message: message,
432
728
  writer: writer
433
729
  });
434
- writer.err('Run `ads-cli --help` to see available commands.');
730
+ writer.err("Run `".concat(invocation, " --help` to see available commands."));
435
731
  }
436
- return _context3.abrupt("return", _types.ExitCode.UsageError);
732
+ return _context5.abrupt("return", _types.ExitCode.UsageError);
437
733
  case 3:
438
- _context3.prev = 3;
439
- _context3.next = 4;
734
+ _context5.prev = 3;
735
+ _context5.next = 4;
440
736
  return runRegistryCommand({
441
737
  command: definition,
442
738
  input: {
443
739
  positionals: positionals,
444
- flags: flags
740
+ flags: flags,
741
+ rawArgs: argv
445
742
  },
446
743
  json: json,
447
- writer: writer
744
+ writer: writer,
745
+ invocation: invocation
448
746
  });
449
747
  case 4:
450
- return _context3.abrupt("return", _context3.sent);
748
+ return _context5.abrupt("return", _context5.sent);
451
749
  case 5:
452
- _context3.prev = 5;
453
- _t3 = _context3["catch"](3);
750
+ _context5.prev = 5;
751
+ _t3 = _context5["catch"](3);
454
752
  _message2 = _t3 instanceof Error ? _t3.message : String(_t3);
455
753
  if (json) {
456
754
  (0, _writeJsonEnvelope.writeJsonEnvelope)({
@@ -467,14 +765,14 @@ var run = exports.run = /*#__PURE__*/function () {
467
765
  writer: writer
468
766
  });
469
767
  }
470
- return _context3.abrupt("return", _types.ExitCode.RuntimeError);
768
+ return _context5.abrupt("return", _types.ExitCode.RuntimeError);
471
769
  case 6:
472
770
  case "end":
473
- return _context3.stop();
771
+ return _context5.stop();
474
772
  }
475
- }, _callee3, null, [[3, 5]]);
773
+ }, _callee5, null, [[3, 5]]);
476
774
  }));
477
775
  return function run() {
478
- return _ref7.apply(this, arguments);
776
+ return _ref13.apply(this, arguments);
479
777
  };
480
778
  }();
@@ -17,12 +17,11 @@ var _cliMetadata = require("./cli-metadata");
17
17
  */
18
18
  var buildManifest = exports.buildManifest = function buildManifest(commands, version) {
19
19
  return {
20
- schemaVersion: 1,
20
+ schemaVersion: 2,
21
21
  name: _cliMetadata.CLI_NAME,
22
22
  bin: _cliMetadata.CLI_BIN_NAME,
23
23
  version: version,
24
24
  description: _cliMetadata.CLI_DESCRIPTION,
25
- invocation: "npx ".concat(_cliMetadata.CLI_NAME),
26
25
  commands: commands.map(function (_ref) {
27
26
  var name = _ref.name,
28
27
  description = _ref.description,
@@ -3,13 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.globalFlags = exports.CLI_NAME = exports.CLI_DESCRIPTION = exports.CLI_BIN_NAME = void 0;
6
+ exports.globalFlags = exports.CLI_NAME = exports.CLI_DESCRIPTION = exports.CLI_BIN_NAME = exports.CLI_ATLAS_INVOCATION = void 0;
7
7
  /**
8
8
  * Shared top-level ADS CLI metadata used by help and the capability manifest.
9
9
  */
10
10
 
11
11
  var CLI_NAME = exports.CLI_NAME = '@atlaskit/ads-cli';
12
12
  var CLI_BIN_NAME = exports.CLI_BIN_NAME = 'ads-cli';
13
+ var CLI_ATLAS_INVOCATION = exports.CLI_ATLAS_INVOCATION = 'atlas ads';
13
14
  var CLI_DESCRIPTION = exports.CLI_DESCRIPTION = 'Query Atlassian Design System (ADS) structured content — components, tokens, icons, and guidelines — from the terminal.';
14
15
  var globalFlags = exports.globalFlags = [{
15
16
  name: 'json',