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