@atlaskit/ads-cli 0.5.0 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @atlaskit/ads-cli
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`70516acb1b138`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/70516acb1b138) -
8
+ Support complete-string child requests in `ads-cli batch` while preserving the canonical tokenized
9
+ form.
10
+
11
+ ```sh
12
+ # Canonical tokenized form
13
+ npx @atlaskit/ads-cli batch --command component "Inline Dialog"
14
+
15
+ # Complete-string compatibility form
16
+ npx @atlaskit/ads-cli batch --command 'component "Inline Dialog"'
17
+ ```
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
23
+ ## 0.6.0
24
+
25
+ ### Minor Changes
26
+
27
+ - [`23b45bcd71b5d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/23b45bcd71b5d) -
28
+ Add an in-process batch command for running multiple ADS CLI queries with independent results,
29
+ using a repeated `--command` flag to introduce each child request.
30
+
31
+ For example:
32
+
33
+ ```sh
34
+ npx @atlaskit/ads-cli batch --command search button --type icon --command token space.200
35
+ ```
36
+
37
+ For readability, put each `--command` group on its own line — the two forms are equivalent:
38
+
39
+ ```sh
40
+ npx @atlaskit/ads-cli batch \
41
+ --command search button --type icon \
42
+ --command token space.200
43
+ ```
44
+
3
45
  ## 0.5.0
4
46
 
5
47
  ### Minor Changes
package/README.md CHANGED
@@ -21,15 +21,16 @@ default; `--json` emits a stable, self-describing envelope for machine consumers
21
21
 
22
22
  The CLI has these commands:
23
23
 
24
- | Command | Description |
25
- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
- | `search <query...>` | **Unified** fuzzy-search across components, tokens, icons, and foundations docs at once. Narrow results with `--type component\|token\|icon\|docs`; limit with `--limit N`. |
27
- | `component <name>` | Detail for a single component. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every component. |
28
- | `token <name>` | Detail for a single token. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every token. |
29
- | `icon <name>` | Detail for a single icon (with a copy-paste import). Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every icon. |
30
- | `lint-rules [term...]` | ADS ESLint rules. A term that matches one rule (exactly or uniquely) prints its docs; several matches show a "did you mean?" list. Bare `lint-rules` prints every rule; `--limit N` caps the candidate list. |
31
- | `docs <topic...>` | Read ADS reference docs. Three forms:<br>• `docs <term...>` — foundations guidelines (spacing, color, …)<br>• `docs a11y [topic]` — accessibility guidance (optional topic e.g. `buttons`, `forms`, `colors`)<br>• `docs migration <id>` — a structured migration guide |
32
- | `manifest` | Describe every command, argument, flag, and JSON response type. Use `--json` for the machine-readable contract. |
24
+ | Command | Description |
25
+ | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
+ | `search <query...>` | **Unified** fuzzy-search across components, tokens, icons, and foundations docs at once. Narrow results with `--type component\|token\|icon\|docs`; limit with `--limit N`. |
27
+ | `batch --command <command> [args...]...` | Run multiple ADS CLI queries, including different command types, in one process. Repeat `--command` once per child; each keeps its normal arguments, flags, and response envelope. Tokenized requests are canonical; complete quoted requests are also accepted. |
28
+ | `component <name>` | Detail for a single component. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every component. |
29
+ | `token <name>` | Detail for a single token. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every token. |
30
+ | `icon <name>` | Detail for a single icon (with a copy-paste import). Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every icon. |
31
+ | `lint-rules [term...]` | ADS ESLint rules. A term that matches one rule (exactly or uniquely) prints its docs; several matches show a "did you mean?" list. Bare `lint-rules` prints every rule; `--limit N` caps the candidate list. |
32
+ | `docs <topic...>` | Read ADS reference docs. Three forms:<br>• `docs <term...>` — foundations guidelines (spacing, color, …)<br>• `docs a11y [topic]` — accessibility guidance (optional topic e.g. `buttons`, `forms`, `colors`)<br>• `docs migration <id>` — a structured migration guide |
33
+ | `manifest` | Describe every command, argument, flag, and JSON response type. Use `--json` for the machine-readable contract. |
33
34
 
34
35
  ### Global flags
35
36
 
@@ -47,6 +48,18 @@ npx @atlaskit/ads-cli search contrast
47
48
  npx @atlaskit/ads-cli search space color --type token
48
49
  npx @atlaskit/ads-cli search contrast --type docs
49
50
 
51
+ # Run multiple queries, including different command types, in one process
52
+ npx @atlaskit/ads-cli batch \
53
+ --command component Button \
54
+ --command component Modal \
55
+ --command docs spacing \
56
+ --command search contrast --type docs
57
+
58
+ # Complete-string compatibility form (tokenized input above remains canonical)
59
+ npx @atlaskit/ads-cli batch \
60
+ --command 'component "Inline Dialog"' \
61
+ --command "search contrast" --type docs
62
+
50
63
  # Detail for a single component, token, or icon
51
64
  npx @atlaskit/ads-cli component Avatar
52
65
  npx @atlaskit/ads-cli token space.100
@@ -84,8 +97,20 @@ npx @atlaskit/ads-cli manifest --json
84
97
  is no exact match but several candidates, they print a `Did you mean?` list (each with a
85
98
  `→ ads-cli <command>` follow-up) and exit `0` — under `--json` this is
86
99
  `{ "ambiguous": true, "query", "noun", "candidates": [...] }`.
100
+ - **Batch commands are independent.** Each repeated `--command` starts a child request. Passing its
101
+ command and arguments as separate, tokenized argv is the canonical form. A complete quoted request
102
+ is also accepted, including inner quoting and already-tokenized trailing flags; it is normalized
103
+ to argv without invoking a shell. Shell operators, pipes, redirects, environment expansion, and
104
+ command substitution are rejected with a usage error. `batch` runs valid commands concurrently
105
+ through the existing command registry in one CLI process. Each item includes its normalized
106
+ tokenized `request`, a `status` (`success`, `ambiguous`, or `failure`), and the child command's
107
+ unchanged success or error `response` envelope. A failed or ambiguous child does not discard
108
+ successful sibling results. A syntactically valid batch exits `0`; inspect each item's status or
109
+ nested envelope.
87
110
  - **Data is written to stdout only.** Logs, hints, and errors go to **stderr**. This keeps `--json`
88
- output clean for piping.
111
+ output clean for piping. `batch` is the one deliberate exception: a child's failure is part of the
112
+ aggregate result rather than a failure of the batch itself, so per-child errors stay inline on
113
+ stdout beside their `Request:` heading instead of being split onto stderr.
89
114
  - **The manifest is derived from the live command registry.** `manifest --json` lists every command,
90
115
  positional argument, flag, example, and success response type without maintaining a separate copy
91
116
  of the CLI surface.
@@ -122,6 +147,42 @@ npx @atlaskit/ads-cli manifest --json
122
147
  "meta": { "terms": ["avatar"], "limit": 5, "count": 2 }
123
148
  }
124
149
 
150
+ // success — batch preserves each child command's existing envelope
151
+ {
152
+ "type": "ads-cli/batch",
153
+ "command": "batch",
154
+ "ok": true,
155
+ "data": [
156
+ {
157
+ "request": ["component", "Button"],
158
+ "status": "success",
159
+ "response": {
160
+ "type": "ads-cli/component",
161
+ "command": "component",
162
+ "ok": true,
163
+ "data": { /* full Button data */ },
164
+ "meta": { "name": "Button" }
165
+ }
166
+ },
167
+ {
168
+ "request": ["docs", "missing-topic"],
169
+ "status": "failure",
170
+ "response": {
171
+ "type": "ads-cli/error",
172
+ "command": "docs",
173
+ "ok": false,
174
+ "error": { "code": "NOT_FOUND", "message": "No guidelines found for missing-topic." }
175
+ }
176
+ }
177
+ ],
178
+ "meta": {
179
+ "succeeded": 1,
180
+ "ambiguous": 0,
181
+ "failed": 1,
182
+ "count": 2
183
+ }
184
+ }
185
+
125
186
  // failure
126
187
  {
127
188
  "type": "ads-cli/error",
package/dist/cjs/cli.js CHANGED
@@ -6,6 +6,7 @@ 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"));
11
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -18,7 +19,9 @@ var _runTool = require("./commands/run-tool");
18
19
  var _createErrorEnvelope = require("./envelope/create-error-envelope");
19
20
  var _createSuccessEnvelope = require("./envelope/create-success-envelope");
20
21
  var _createDocSearchResults = require("./output/create-doc-search-results");
22
+ var _disambiguation = require("./output/disambiguation");
21
23
  var _formatGroupedResults = require("./output/format-grouped-results");
24
+ var _formatHumanResult = require("./output/format-human-result");
22
25
  var _formatResults = require("./output/format-results");
23
26
  var _writeHumanError = require("./output/write-human-error");
24
27
  var _writeHumanResult = require("./output/write-human-result");
@@ -67,6 +70,12 @@ var buildHelpText = function buildHelpText(invocation) {
67
70
  var examples = [{
68
71
  command: 'search contrast',
69
72
  comment: 'unified: components, tokens, icons & docs'
73
+ }, {
74
+ command: 'batch --command search button --type icon --command token space.200',
75
+ comment: 'canonical tokenized batch form'
76
+ }, {
77
+ command: 'batch --command "search button" --type icon --command "token space.200"',
78
+ comment: 'complete-string compatibility form'
70
79
  }, {
71
80
  command: 'search button --type component'
72
81
  }, {
@@ -159,7 +168,19 @@ var runRegistryCommand = /*#__PURE__*/function () {
159
168
  invocation: invocation
160
169
  }));
161
170
  case 2:
162
- _context2.next = 3;
171
+ if (!resolved.batch) {
172
+ _context2.next = 3;
173
+ break;
174
+ }
175
+ return _context2.abrupt("return", runBatchRequests({
176
+ command: command,
177
+ requests: resolved.batch,
178
+ json: json,
179
+ writer: writer,
180
+ invocation: invocation
181
+ }));
182
+ case 3:
183
+ _context2.next = 4;
163
184
  return Promise.all(resolved.tools.map( /*#__PURE__*/function () {
164
185
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(tool) {
165
186
  var handler, _t, _t2;
@@ -194,10 +215,10 @@ var runRegistryCommand = /*#__PURE__*/function () {
194
215
  return _ref5.apply(this, arguments);
195
216
  };
196
217
  }()));
197
- case 3:
218
+ case 4:
198
219
  results = _context2.sent;
199
220
  if (!resolved.grouped) {
200
- _context2.next = 4;
221
+ _context2.next = 5;
201
222
  break;
202
223
  }
203
224
  return _context2.abrupt("return", renderGroupedResult({
@@ -209,7 +230,7 @@ var runRegistryCommand = /*#__PURE__*/function () {
209
230
  writer: writer,
210
231
  invocation: invocation
211
232
  }));
212
- case 4:
233
+ case 5:
213
234
  return _context2.abrupt("return", renderSingleResult({
214
235
  command: command,
215
236
  input: input,
@@ -219,7 +240,7 @@ var runRegistryCommand = /*#__PURE__*/function () {
219
240
  writer: writer,
220
241
  invocation: invocation
221
242
  }));
222
- case 5:
243
+ case 6:
223
244
  case "end":
224
245
  return _context2.stop();
225
246
  }
@@ -231,17 +252,45 @@ var runRegistryCommand = /*#__PURE__*/function () {
231
252
  }();
232
253
 
233
254
  /**
234
- * Render a single-tool command result (the common case).
255
+ * Render a command's already-transformed payload as human-readable text.
256
+ *
257
+ * Tried in order:
258
+ * 1. Compact per-row view when the command declares a result kind (search/list).
259
+ * 2. The command's own `formatHuman` renderer for rich single-object payloads
260
+ * (component docs, a11y/migration guides, lint-rule markdown).
261
+ *
262
+ * Returns `null` when neither step applies, leaving the caller to choose its own last-resort
263
+ * fallback. Shared by the single-command path and `batch` so the two cannot drift apart.
235
264
  */
236
- var renderSingleResult = function renderSingleResult(_ref6) {
265
+ var formatCommandHuman = function formatCommandHuman(_ref6) {
237
266
  var _command$resultKind, _ref7, _command$formatHuman;
238
267
  var command = _ref6.command,
239
268
  input = _ref6.input,
240
- result = _ref6.result,
241
- meta = _ref6.meta,
242
- json = _ref6.json,
243
- writer = _ref6.writer,
269
+ data = _ref6.data,
244
270
  invocation = _ref6.invocation;
271
+ var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
272
+ var compact = resultKind ? (0, _formatResults.formatCompactResults)({
273
+ kind: resultKind,
274
+ data: data,
275
+ showFollowUp: command.name === 'search',
276
+ invocation: invocation
277
+ }) : null;
278
+ return (_ref7 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data, {
279
+ invocation: invocation
280
+ })) !== null && _ref7 !== void 0 ? _ref7 : null;
281
+ };
282
+
283
+ /**
284
+ * Render a single-tool command result (the common case).
285
+ */
286
+ var renderSingleResult = function renderSingleResult(_ref8) {
287
+ var command = _ref8.command,
288
+ input = _ref8.input,
289
+ result = _ref8.result,
290
+ meta = _ref8.meta,
291
+ json = _ref8.json,
292
+ writer = _ref8.writer,
293
+ invocation = _ref8.invocation;
245
294
  var isError = result.isError;
246
295
 
247
296
  // The ADS search tools return an `Error: No … found` text block when nothing matches.
@@ -307,22 +356,14 @@ var renderSingleResult = function renderSingleResult(_ref6) {
307
356
  return _types.ExitCode.Ok;
308
357
  }
309
358
 
310
- // Default (human) output, tried in order:
311
- // 1. Compact per-row view when the command declares a result kind (search/list).
312
- // 2. The command's own `formatHuman` renderer for rich single-object payloads
313
- // (component docs, a11y/migration guides, lint-rule markdown).
314
- // 3. The generic fallback: verbatim strings (e.g. foundations markdown) or pretty JSON.
315
- // Each step returns `null` to defer to the next, so a raw JSON dump is only ever a last resort.
316
- var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
317
- var compact = resultKind ? (0, _formatResults.formatCompactResults)({
318
- kind: resultKind,
359
+ // Default (human) output: the shared renderer, falling back to verbatim strings (e.g.
360
+ // foundations markdown) or pretty JSON so a raw dump is only ever a last resort.
361
+ var human = formatCommandHuman({
362
+ command: command,
363
+ input: input,
319
364
  data: data,
320
- showFollowUp: command.name === 'search',
321
- invocation: invocation
322
- }) : null;
323
- var human = (_ref7 = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data, {
324
365
  invocation: invocation
325
- })) !== null && _ref7 !== void 0 ? _ref7 : null;
366
+ });
326
367
  if (human !== null) {
327
368
  writer.out(human);
328
369
  } else {
@@ -333,6 +374,209 @@ var renderSingleResult = function renderSingleResult(_ref6) {
333
374
  }
334
375
  return _types.ExitCode.Ok;
335
376
  };
377
+ var classifyBatchResponse = function classifyBatchResponse(response) {
378
+ if (!response.ok) {
379
+ return 'failure';
380
+ }
381
+ return (0, _disambiguation.isDisambiguation)(response.data) ? 'ambiguous' : 'success';
382
+ };
383
+ var createCapturedWriter = function createCapturedWriter() {
384
+ var stdout = [];
385
+ var stderr = [];
386
+ return {
387
+ stdout: stdout,
388
+ stderr: stderr,
389
+ out: function out(line) {
390
+ return stdout.push(line);
391
+ },
392
+ err: function err(line) {
393
+ return stderr.push(line);
394
+ }
395
+ };
396
+ };
397
+
398
+ /**
399
+ * Execute one child argv through the normal CLI pipeline, forcing JSON so the parent can preserve
400
+ * the child's stable envelope without scraping human-readable output.
401
+ *
402
+ * There is deliberately no `--help`/`--version` guard here. Every child token is also a top-level
403
+ * token, so {@link run} already short-circuits the whole invocation to help/version text before a
404
+ * batch is ever resolved — a guard at this level would be unreachable.
405
+ */
406
+ var runBatchChild = /*#__PURE__*/function () {
407
+ var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref9) {
408
+ var request, invocation, parsed, response, captured;
409
+ return _regenerator.default.wrap(function (_context3) {
410
+ while (1) switch (_context3.prev = _context3.next) {
411
+ case 0:
412
+ request = _ref9.request, invocation = _ref9.invocation;
413
+ parsed = (0, _parseArgs2.parseArgs)(request.argv);
414
+ if (parsed.command) {
415
+ _context3.next = 1;
416
+ break;
417
+ }
418
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
419
+ command: 'batch',
420
+ code: 'USAGE_ERROR',
421
+ message: 'A batch request must start with a command name.'
422
+ });
423
+ _context3.next = 4;
424
+ break;
425
+ case 1:
426
+ if (!(parsed.command === 'batch')) {
427
+ _context3.next = 2;
428
+ break;
429
+ }
430
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
431
+ command: 'batch',
432
+ code: 'USAGE_ERROR',
433
+ message: 'Nested batch requests are not supported.'
434
+ });
435
+ _context3.next = 4;
436
+ break;
437
+ case 2:
438
+ captured = createCapturedWriter();
439
+ _context3.next = 3;
440
+ return run([].concat((0, _toConsumableArray2.default)(request.argv), ['--json']), captured, {
441
+ invocation: invocation
442
+ });
443
+ case 3:
444
+ try {
445
+ response = JSON.parse(captured.stdout.join('\n'));
446
+ } catch (_unused) {
447
+ response = (0, _createErrorEnvelope.createErrorEnvelope)({
448
+ command: parsed.command,
449
+ code: 'RUNTIME_ERROR',
450
+ message: 'The child command did not produce a valid JSON envelope.'
451
+ });
452
+ }
453
+ case 4:
454
+ return _context3.abrupt("return", {
455
+ request: request.argv,
456
+ status: classifyBatchResponse(response),
457
+ response: response
458
+ });
459
+ case 5:
460
+ case "end":
461
+ return _context3.stop();
462
+ }
463
+ }, _callee3);
464
+ }));
465
+ return function runBatchChild(_x3) {
466
+ return _ref0.apply(this, arguments);
467
+ };
468
+ }();
469
+
470
+ /**
471
+ * Render an already-transformed child success envelope with the same human format as its command.
472
+ */
473
+ var formatBatchChildHuman = function formatBatchChildHuman(_ref1) {
474
+ var item = _ref1.item,
475
+ invocation = _ref1.invocation;
476
+ if (!item.response.ok) {
477
+ return "Error: ".concat(item.response.error.message);
478
+ }
479
+ var parsed = (0, _parseArgs2.parseArgs)(item.request);
480
+ var definition = parsed.command ? (0, _getCommand.getCommand)(parsed.command) : undefined;
481
+ if (!definition) {
482
+ return (0, _formatHumanResult.formatHumanResult)({
483
+ data: item.response.data
484
+ });
485
+ }
486
+
487
+ // A unified search spans every kind, so it has no single result kind and needs the grouped
488
+ // formatter instead. This is the same condition `search`'s own resolver uses to choose the
489
+ // grouped path, so the two cannot disagree.
490
+ if (definition.name === 'search' && parsed.flags.type === undefined && (0, _typeof2.default)(item.response.data) === 'object' && item.response.data !== null) {
491
+ var _item$response$meta$c;
492
+ return (0, _formatGroupedResults.formatGroupedResults)({
493
+ groups: item.response.data,
494
+ totalCount: Number((_item$response$meta$c = item.response.meta.count) !== null && _item$response$meta$c !== void 0 ? _item$response$meta$c : 0),
495
+ invocation: invocation
496
+ });
497
+ }
498
+ var human = formatCommandHuman({
499
+ command: definition,
500
+ input: {
501
+ positionals: parsed.positionals,
502
+ flags: parsed.flags
503
+ },
504
+ data: item.response.data,
505
+ invocation: invocation
506
+ });
507
+ return human !== null && human !== void 0 ? human : (0, _formatHumanResult.formatHumanResult)({
508
+ data: item.response.data
509
+ });
510
+ };
511
+
512
+ /**
513
+ * Execute heterogeneous registered commands concurrently in the current process and aggregate
514
+ * their existing envelopes. A valid batch exits zero even when individual child commands fail.
515
+ */
516
+ var runBatchRequests = /*#__PURE__*/function () {
517
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref10) {
518
+ var command, requests, json, writer, invocation, items, succeeded, ambiguous, failed, summary, sections;
519
+ return _regenerator.default.wrap(function (_context4) {
520
+ while (1) switch (_context4.prev = _context4.next) {
521
+ case 0:
522
+ command = _ref10.command, requests = _ref10.requests, json = _ref10.json, writer = _ref10.writer, invocation = _ref10.invocation;
523
+ _context4.next = 1;
524
+ return Promise.all(requests.map(function (request) {
525
+ return runBatchChild({
526
+ request: request,
527
+ invocation: invocation
528
+ });
529
+ }));
530
+ case 1:
531
+ items = _context4.sent;
532
+ succeeded = items.filter(function (item) {
533
+ return item.status === 'success';
534
+ }).length;
535
+ ambiguous = items.filter(function (item) {
536
+ return item.status === 'ambiguous';
537
+ }).length;
538
+ failed = items.length - succeeded - ambiguous;
539
+ if (!json) {
540
+ _context4.next = 2;
541
+ break;
542
+ }
543
+ (0, _writeJsonEnvelope.writeJsonEnvelope)({
544
+ envelope: (0, _createSuccessEnvelope.createSuccessEnvelope)({
545
+ envelopeType: command.envelopeType({
546
+ positionals: [],
547
+ flags: {}
548
+ }),
549
+ command: command.name,
550
+ data: items,
551
+ meta: {
552
+ succeeded: succeeded,
553
+ ambiguous: ambiguous,
554
+ failed: failed
555
+ }
556
+ }),
557
+ writer: writer
558
+ });
559
+ return _context4.abrupt("return", _types.ExitCode.Ok);
560
+ case 2:
561
+ summary = "Batch results: ".concat(succeeded, " succeeded, ").concat(ambiguous, " ambiguous, ").concat(failed, " failed");
562
+ sections = items.map(function (item) {
563
+ return "Request: ".concat(item.request.join(' '), "\n").concat(formatBatchChildHuman({
564
+ item: item,
565
+ invocation: invocation
566
+ }));
567
+ });
568
+ writer.out([summary].concat((0, _toConsumableArray2.default)(sections)).join('\n\n'));
569
+ return _context4.abrupt("return", _types.ExitCode.Ok);
570
+ case 3:
571
+ case "end":
572
+ return _context4.stop();
573
+ }
574
+ }, _callee4);
575
+ }));
576
+ return function runBatchRequests(_x4) {
577
+ return _ref11.apply(this, arguments);
578
+ };
579
+ }();
336
580
 
337
581
  /**
338
582
  * Render a grouped (multi-tool) command result, e.g. unified `search`.
@@ -340,14 +584,14 @@ var renderSingleResult = function renderSingleResult(_ref6) {
340
584
  * Each sub-result is keyed by its {@link ToolCall.key}. A sub-search that finds nothing simply
341
585
  * contributes an empty array; the command is only treated as NOT_FOUND when every group is empty.
342
586
  */
343
- var renderGroupedResult = function renderGroupedResult(_ref8) {
344
- var command = _ref8.command,
345
- input = _ref8.input,
346
- results = _ref8.results,
347
- meta = _ref8.meta,
348
- json = _ref8.json,
349
- writer = _ref8.writer,
350
- invocation = _ref8.invocation;
587
+ var renderGroupedResult = function renderGroupedResult(_ref12) {
588
+ var command = _ref12.command,
589
+ input = _ref12.input,
590
+ results = _ref12.results,
591
+ meta = _ref12.meta,
592
+ json = _ref12.json,
593
+ writer = _ref12.writer,
594
+ invocation = _ref12.invocation;
351
595
  // Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
352
596
  // empty domain does not blank out the others. The guidelines tool returns full Markdown, so
353
597
  // summarize its highest-ranked match for search; `docs <query>` remains the detail view.
@@ -428,11 +672,11 @@ var renderGroupedResult = function renderGroupedResult(_ref8) {
428
672
  * @returns The process exit code. The bin wrapper maps this onto `process.exit`.
429
673
  */
430
674
  var run = exports.run = /*#__PURE__*/function () {
431
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
675
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
432
676
  var argv,
433
677
  writer,
434
- _ref0,
435
- _ref0$invocation,
678
+ _ref14,
679
+ _ref14$invocation,
436
680
  invocation,
437
681
  _parseArgs,
438
682
  command,
@@ -442,33 +686,33 @@ var run = exports.run = /*#__PURE__*/function () {
442
686
  definition,
443
687
  message,
444
688
  _message2,
445
- _args3 = arguments,
689
+ _args5 = arguments,
446
690
  _t3;
447
- return _regenerator.default.wrap(function (_context3) {
448
- while (1) switch (_context3.prev = _context3.next) {
691
+ return _regenerator.default.wrap(function (_context5) {
692
+ while (1) switch (_context5.prev = _context5.next) {
449
693
  case 0:
450
- argv = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : process.argv.slice(2);
451
- writer = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : _writer.defaultWriter;
452
- _ref0 = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, _ref0$invocation = _ref0.invocation, invocation = _ref0$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref0$invocation;
694
+ argv = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : process.argv.slice(2);
695
+ writer = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : _writer.defaultWriter;
696
+ _ref14 = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {}, _ref14$invocation = _ref14.invocation, invocation = _ref14$invocation === void 0 ? _cliMetadata.CLI_BIN_NAME : _ref14$invocation;
453
697
  _parseArgs = (0, _parseArgs2.parseArgs)(argv), command = _parseArgs.command, positionals = _parseArgs.positionals, flags = _parseArgs.flags;
454
698
  json = flags.json === true; // `--version` / `-v` takes precedence and short-circuits.
455
699
  if (!(flags.version === true)) {
456
- _context3.next = 1;
700
+ _context5.next = 1;
457
701
  break;
458
702
  }
459
703
  writer.out((0, _getVersion.getVersion)());
460
- return _context3.abrupt("return", _types.ExitCode.Ok);
704
+ return _context5.abrupt("return", _types.ExitCode.Ok);
461
705
  case 1:
462
706
  if (!(flags.help === true || command === undefined)) {
463
- _context3.next = 2;
707
+ _context5.next = 2;
464
708
  break;
465
709
  }
466
710
  writer.out(buildHelpText(invocation));
467
- return _context3.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
711
+ return _context5.abrupt("return", command === undefined && flags.help !== true ? _types.ExitCode.UsageError : _types.ExitCode.Ok);
468
712
  case 2:
469
713
  definition = (0, _getCommand.getCommand)(command);
470
714
  if (definition) {
471
- _context3.next = 3;
715
+ _context5.next = 3;
472
716
  break;
473
717
  }
474
718
  message = "Unknown command \"".concat(command, "\".");
@@ -488,25 +732,26 @@ var run = exports.run = /*#__PURE__*/function () {
488
732
  });
489
733
  writer.err("Run `".concat(invocation, " --help` to see available commands."));
490
734
  }
491
- return _context3.abrupt("return", _types.ExitCode.UsageError);
735
+ return _context5.abrupt("return", _types.ExitCode.UsageError);
492
736
  case 3:
493
- _context3.prev = 3;
494
- _context3.next = 4;
737
+ _context5.prev = 3;
738
+ _context5.next = 4;
495
739
  return runRegistryCommand({
496
740
  command: definition,
497
741
  input: {
498
742
  positionals: positionals,
499
- flags: flags
743
+ flags: flags,
744
+ rawArgs: argv
500
745
  },
501
746
  json: json,
502
747
  writer: writer,
503
748
  invocation: invocation
504
749
  });
505
750
  case 4:
506
- return _context3.abrupt("return", _context3.sent);
751
+ return _context5.abrupt("return", _context5.sent);
507
752
  case 5:
508
- _context3.prev = 5;
509
- _t3 = _context3["catch"](3);
753
+ _context5.prev = 5;
754
+ _t3 = _context5["catch"](3);
510
755
  _message2 = _t3 instanceof Error ? _t3.message : String(_t3);
511
756
  if (json) {
512
757
  (0, _writeJsonEnvelope.writeJsonEnvelope)({
@@ -523,14 +768,14 @@ var run = exports.run = /*#__PURE__*/function () {
523
768
  writer: writer
524
769
  });
525
770
  }
526
- return _context3.abrupt("return", _types.ExitCode.RuntimeError);
771
+ return _context5.abrupt("return", _types.ExitCode.RuntimeError);
527
772
  case 6:
528
773
  case "end":
529
- return _context3.stop();
774
+ return _context5.stop();
530
775
  }
531
- }, _callee3, null, [[3, 5]]);
776
+ }, _callee5, null, [[3, 5]]);
532
777
  }));
533
778
  return function run() {
534
- return _ref9.apply(this, arguments);
779
+ return _ref13.apply(this, arguments);
535
780
  };
536
781
  }();