@atlaskit/ads-cli 0.2.0 → 0.4.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,32 @@
1
1
  # @atlaskit/ads-cli
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ccba0c0605171`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ccba0c0605171) -
8
+ Add an Atlas CLI distribution (internal to Atlassian) with bundle-safe ADS MCP loading and Statlas
9
+ release packaging.
10
+
11
+ After the plugin is published, internal staff can run the ADS CLI with `atlas ads` instead of
12
+ `npx @atlaskit/ads-cli`. For example:
13
+
14
+ ```sh
15
+ atlas ads search avatar
16
+ ```
17
+
18
+ ## 0.3.0
19
+
20
+ ### Minor Changes
21
+
22
+ - [`d678f1fec09ca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d678f1fec09ca) -
23
+ Include concise, query-labelled foundations docs in unified search results, with leading-text
24
+ previews, docs filtering, and detail commands. For example:
25
+
26
+ ```sh
27
+ npx @atlaskit/ads-cli search contrast --type docs
28
+ ```
29
+
3
30
  ## 0.2.0
4
31
 
5
32
  ### Minor Changes
package/README.md CHANGED
@@ -23,7 +23,7 @@ The CLI has these commands:
23
23
 
24
24
  | Command | Description |
25
25
  | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
- | `search <query...>` | **Unified** fuzzy-search across components, tokens, and icons at once. Narrow with `--type component\|token\|icon`; limit with `--limit N`. |
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
27
  | `component <name>` | Detail for a single component. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every component. |
28
28
  | `token <name>` | Detail for a single token. Exact name → detail; ambiguous → a "did you mean?" list. `--all` lists every token. |
29
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. |
@@ -40,11 +40,12 @@ The CLI has these commands:
40
40
  ## Examples
41
41
 
42
42
  ```sh
43
- # Unified human-readable search — components, tokens, and icons grouped together
44
- npx @atlaskit/ads-cli search button
43
+ # Unified human-readable search — components, tokens, icons, and docs grouped together
44
+ npx @atlaskit/ads-cli search contrast
45
45
 
46
46
  # Narrow to a single kind
47
47
  npx @atlaskit/ads-cli search space color --type token
48
+ npx @atlaskit/ads-cli search contrast --type docs
48
49
 
49
50
  # Detail for a single component, token, or icon
50
51
  npx @atlaskit/ads-cli component Avatar
@@ -71,11 +72,13 @@ npx @atlaskit/ads-cli manifest --json
71
72
  - **Every command is human-readable by default; `--json` is the only path to structured output.**
72
73
  `search` and the `--all` listings print one compact line per result (e.g.
73
74
  `Avatar @atlaskit/avatar (42 props, 1 example)`), and unified `search` groups results into
74
- `Components` / `Tokens` / `Icons` sections with a `→ ads-cli component Avatar` follow-up hint per
75
- row. `component`/`token`/`icon` print a readable detail view (the icon view includes a copy-paste
76
- `import` line); `docs` (foundations, `a11y`, and `migration`) and `lint-rules` print
77
- prose/Markdown. A raw JSON dump is only ever a last-resort fallback for an unrecognised shape. For
78
- the **full structured payload**, use `--json`.
75
+ `Components` / `Tokens` / `Icons` / `Docs` sections. Every `search` row includes a follow-up
76
+ command, such as `→ ads-cli component Avatar` or `→ ads-cli docs contrast`; this also applies to
77
+ narrowed `search --type` output. Documentation search results stay concise, while `docs <query>`
78
+ prints the full matched Markdown. `component`/`token`/`icon` print a readable detail view (the
79
+ icon view includes a copy-paste `import` line); `docs` (`foundations`, `a11y`, and `migration`)
80
+ and `lint-rules` print prose/Markdown. A raw JSON dump is only ever a last-resort fallback for an
81
+ unrecognised shape. For the **full structured payload**, use `--json`.
79
82
  - **Lookups never silently guess.** `component`/`token`/`icon <name>` — and a fuzzy
80
83
  `lint-rules <term>` — render the entry whose name matches exactly (case-insensitively). If there
81
84
  is no exact match but several candidates, they print a `Did you mean?` list (each with a
@@ -95,7 +98,18 @@ npx @atlaskit/ads-cli manifest --json
95
98
  "type": "ads-cli/search",
96
99
  "command": "search",
97
100
  "ok": true,
98
- "data": { "components": [ /* … */ ], "tokens": [ /* … */ ], "icons": [ /* … */ ] },
101
+ "data": {
102
+ "components": [ /* … */ ],
103
+ "tokens": [ /* … */ ],
104
+ "icons": [ /* … */ ],
105
+ "docs": [
106
+ {
107
+ "title": "Button",
108
+ "summary": "A concise preview of the leading textual content.",
109
+ "followUp": "docs button"
110
+ }
111
+ ]
112
+ },
99
113
  "meta": { "terms": ["button"], "count": 12 }
100
114
  }
101
115
 
@@ -136,6 +150,45 @@ skill are all thin surfaces over the **same** `@atlaskit/ads-mcp/tools/*` query
136
150
  `ComponentMcpPayload[]` dataset. Adding or improving a tool in `ads-mcp` is automatically reflected
137
151
  here.
138
152
 
139
- > **Note:** An `atlas ads` plugin (for the Atlas CLI) is a separate future distribution path. The
140
- > `--json` envelope here is intentionally structured so it can be wrapped by that plugin later
141
- > without changes to this package.
153
+ The `--json` envelope is shared unchanged by the npm and Atlas distributions.
154
+
155
+ ## Atlas CLI distribution
156
+
157
+ The same command surface is available as `atlas ads`. Its entrypoint delegates directly to `run()`,
158
+ so npm and Atlas share command parsing, output, and exit codes.
159
+
160
+ Build the self-contained JavaScript bundle from the `platform/` directory:
161
+
162
+ ```sh
163
+ afm workspace @atlaskit/ads-cli build:atlas
164
+ node packages/design-system/ads-cli/build/atlas/ads-cli.js search button
165
+ ```
166
+
167
+ The `.atlas-plugin` descriptor declares the `ads` plugin and the `atlas-cli-plugin-ads` Statlas
168
+ namespace. The checked-in `manifest.toml` is a seed for the first release. After the first release,
169
+ every upload fetches the remote Statlas manifest so its release history remains canonical.
170
+
171
+ Prepare an Atlas-shaped release locally:
172
+
173
+ ```sh
174
+ VERSION=local-$(git rev-parse --short HEAD) \
175
+ afm workspace @atlaskit/ads-cli release:atlas:prepare
176
+ ```
177
+
178
+ This builds 5 variants under `build/releases/$VERSION`, creates each archive and checksum,
179
+ smoke-tests the Linux AMD64 executable when running on Linux AMD64, and adds the release to the
180
+ `alpha` channel in the working manifest.
181
+
182
+ The `ads-cli-build-and-upload-to-statlas` custom pipeline runs the tests and typecheck, prepares the
183
+ release, uploads all artifacts, then publishes the manifest. Run it from `master`. Set
184
+ `ALLOW_MISSING_REMOTE_MANIFEST` to `true` only for the first release; later runs must fetch the
185
+ remote release history successfully.
186
+
187
+ After validating an alpha release, run the `ads-cli-promote-stable-version` custom pipeline from
188
+ `master` with `VERSION_TO_PROMOTE` set to its exact version. Promotion updates the canonical remote
189
+ manifest without rebuilding or uploading artifacts.
190
+
191
+ The Statlas namespace authorization and Atlas plugin registry entry are one-time external
192
+ prerequisites. Until the registry entry is available, use `atlas atlasdev exec` to exercise a
193
+ packaged binary in the Atlas runtime. The AFM package scripts own the Node.js executable build; the
194
+ generic `atlas atlasdev plugin build` command doesn't drive this package.
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.main = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _cli = require("./cli");
12
+ /**
13
+ * Process entrypoint for the `atlas ads` distribution.
14
+ *
15
+ * Atlas forwards everything after `atlas ads` as process arguments. The shared CLI owns parsing,
16
+ * output, and its stable exit-code contract; this entrypoint only maps that result onto the plugin
17
+ * process.
18
+ */
19
+ var main = exports.main = /*#__PURE__*/function () {
20
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
21
+ var argv,
22
+ exitCode,
23
+ _error$stack,
24
+ _args = arguments,
25
+ _t;
26
+ return _regenerator.default.wrap(function (_context) {
27
+ while (1) switch (_context.prev = _context.next) {
28
+ case 0:
29
+ argv = _args.length > 0 && _args[0] !== undefined ? _args[0] : process.argv.slice(2);
30
+ _context.prev = 1;
31
+ _context.next = 2;
32
+ return (0, _cli.run)(argv);
33
+ case 2:
34
+ exitCode = _context.sent;
35
+ process.exitCode = exitCode;
36
+ _context.next = 5;
37
+ break;
38
+ case 3:
39
+ _context.prev = 3;
40
+ _t = _context["catch"](1);
41
+ if (!(typeof _t === 'number')) {
42
+ _context.next = 4;
43
+ break;
44
+ }
45
+ process.exitCode = _t;
46
+ return _context.abrupt("return");
47
+ case 4:
48
+ process.stderr.write("".concat(_t instanceof Error ? (_error$stack = _t.stack) !== null && _error$stack !== void 0 ? _error$stack : _t.message : String(_t), "\n"));
49
+ process.exitCode = 1;
50
+ case 5:
51
+ case "end":
52
+ return _context.stop();
53
+ }
54
+ }, _callee, null, [[1, 3]]);
55
+ }));
56
+ return function main() {
57
+ return _ref.apply(this, arguments);
58
+ };
59
+ }();
60
+ if (require.main === module) {
61
+ void main();
62
+ }
package/dist/cjs/cli.js CHANGED
@@ -16,6 +16,7 @@ var _importToolHandler = require("./commands/import-tool-handler");
16
16
  var _runTool = require("./commands/run-tool");
17
17
  var _createErrorEnvelope = require("./envelope/create-error-envelope");
18
18
  var _createSuccessEnvelope = require("./envelope/create-success-envelope");
19
+ var _createDocSearchResults = require("./output/create-doc-search-results");
19
20
  var _formatGroupedResults = require("./output/format-grouped-results");
20
21
  var _formatResults = require("./output/format-results");
21
22
  var _writeHumanError = require("./output/write-human-error");
@@ -62,7 +63,7 @@ var buildHelpText = function buildHelpText() {
62
63
  var aliases = flag.alias ? ", -".concat(flag.alias) : '';
63
64
  return " --".concat(flag.name).concat(aliases).padEnd(18) + flag.description;
64
65
  }).join('\n');
65
- return [_cliMetadata.CLI_DESCRIPTION, '', 'Usage', ' $ npx @atlaskit/ads-cli <command> [options]', '', 'Commands', commandLines, '', 'Global options', globalFlagLines, '', 'Examples', ' $ npx @atlaskit/ads-cli search button # unified: components, tokens & icons', ' $ npx @atlaskit/ads-cli search button --type component', ' $ 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
+ 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');
66
67
  };
67
68
 
68
69
  /**
@@ -269,7 +270,8 @@ var renderSingleResult = function renderSingleResult(_ref4) {
269
270
  var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
270
271
  var compact = resultKind ? (0, _formatResults.formatCompactResults)({
271
272
  kind: resultKind,
272
- data: data
273
+ data: data,
274
+ showFollowUp: command.name === 'search'
273
275
  }) : null;
274
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;
275
277
  if (human !== null) {
@@ -297,7 +299,8 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
297
299
  json = _ref6.json,
298
300
  writer = _ref6.writer;
299
301
  // Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
300
- // empty domain does not blank out the others.
302
+ // empty domain does not blank out the others. The guidelines tool returns full Markdown, so
303
+ // summarize its highest-ranked match for search; `docs <query>` remains the detail view.
301
304
  var grouped = {};
302
305
  var _iterator = _createForOfIteratorHelper(results),
303
306
  _step;
@@ -307,7 +310,14 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
307
310
  key = _step$value.key,
308
311
  data = _step$value.data,
309
312
  isError = _step$value.isError;
310
- grouped[key] = isError || !Array.isArray(data) ? [] : data;
313
+ if (key === 'docs' && !isError && typeof data === 'string' && data.trim() !== '') {
314
+ grouped[key] = (0, _createDocSearchResults.createDocSearchResults)({
315
+ data: data,
316
+ query: input.positionals.join(' ')
317
+ });
318
+ } else {
319
+ grouped[key] = isError || !Array.isArray(data) ? [] : data;
320
+ }
311
321
  }
312
322
  } catch (err) {
313
323
  _iterator.e(err);
@@ -318,7 +328,7 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
318
328
  return sum + arr.length;
319
329
  }, 0);
320
330
  if (totalCount === 0) {
321
- var message = 'No components, tokens, or icons found.';
331
+ var message = "No components, tokens, icons, or docs found for \"".concat(input.positionals.join(' '), "\".");
322
332
  if (json) {
323
333
  (0, _writeJsonEnvelope.writeJsonEnvelope)({
324
334
  envelope: (0, _createErrorEnvelope.createErrorEnvelope)({
@@ -341,8 +351,8 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
341
351
  envelope: (0, _createSuccessEnvelope.createSuccessEnvelope)({
342
352
  envelopeType: command.envelopeType(input),
343
353
  command: command.name,
344
- // `data` for grouped commands is `{ components, tokens, icons }` (already counted
345
- // per group), so `count` is the combined total across groups.
354
+ // `data` for grouped commands is `{ components, tokens, icons, docs }` (already
355
+ // counted per group), so `count` is the combined total across groups.
346
356
  data: grouped,
347
357
  meta: _objectSpread(_objectSpread({}, meta), {}, {
348
358
  count: totalCount
@@ -11,6 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _a11yGuidelines = require("@atlaskit/ads-mcp/a11y-guidelines");
13
13
  var _migrationRegistry = require("@atlaskit/ads-mcp/migration-registry");
14
+ var _createDocSearchResults = require("../output/create-doc-search-results");
14
15
  var _disambiguation = require("../output/disambiguation");
15
16
  var _formatComponent = require("../output/format-component");
16
17
  var _formatDisambiguation = require("../output/format-disambiguation");
@@ -68,7 +69,7 @@ var parseLimit = function parseLimit(flags) {
68
69
  };
69
70
 
70
71
  /**
71
- * Map of the three `search --type` variants to their ADS MCP tool exports.
72
+ * Map of the `search --type` variants to their ADS MCP tool exports.
72
73
  */
73
74
  var searchKindTools = {
74
75
  components: {
@@ -85,17 +86,22 @@ var searchKindTools = {
85
86
  importPath: '@atlaskit/ads-mcp/tools/search-icons',
86
87
  handlerName: 'searchIconsTool',
87
88
  envelopeType: 'search-icons'
89
+ },
90
+ docs: {
91
+ importPath: '@atlaskit/ads-mcp/tools/get-guidelines',
92
+ handlerName: 'getGuidelinesTool',
93
+ envelopeType: 'search-docs'
88
94
  }
89
95
  };
90
96
  /**
91
- * Accepted `--type` values (singular, matching the item command names) → the internal (plural)
92
- * {@link SearchKind}. Everything downstream keys off the plural `SearchKind` (envelope types,
93
- * grouped JSON keys), so the singular input normalises to it here.
97
+ * Accepted `--type` values → the internal {@link SearchKind}. Entity inputs are singular to match
98
+ * their item commands; `docs` matches the dedicated documentation command.
94
99
  */
95
100
  var SEARCH_TYPE_VALUES = {
96
101
  component: 'components',
97
102
  token: 'tokens',
98
- icon: 'icons'
103
+ icon: 'icons',
104
+ docs: 'docs'
99
105
  };
100
106
  var isSearchTypeValue = function isSearchTypeValue(value) {
101
107
  return value in SEARCH_TYPE_VALUES;
@@ -416,10 +422,11 @@ var makeItemCommand = function makeItemCommand(_ref3) {
416
422
  };
417
423
 
418
424
  /**
419
- * Resolver for the unified `search` (no `--type`): fan out to all three search tools in one
420
- * command. The results are grouped by kind (components/tokens/icons) rather than merged into a
421
- * single ranked list — each tool ranks its own domain, and re-ranking across domains would
422
- * mean duplicating ranking logic here (breaking the zero-drift contract with `@atlaskit/ads-mcp`).
425
+ * Resolver for the unified `search` (no `--type`): fan out to the three entity search tools and
426
+ * foundations documentation search in one command. The results are grouped by kind
427
+ * (components/tokens/icons/docs) rather than merged into a single ranked list — each tool ranks its
428
+ * own domain, and re-ranking across domains would mean duplicating ranking logic here (breaking the
429
+ * zero-drift contract with `@atlaskit/ads-mcp`).
423
430
  */
424
431
  var resolveUnifiedSearch = function resolveUnifiedSearch(input) {
425
432
  var terms = input.positionals;
@@ -451,6 +458,10 @@ var resolveUnifiedSearch = function resolveUnifiedSearch(input) {
451
458
  key: 'icons'
452
459
  }, searchKindTools.icons), {}, {
453
460
  args: args
461
+ }), _objectSpread(_objectSpread({
462
+ key: 'docs'
463
+ }, searchKindTools.docs), {}, {
464
+ args: args
454
465
  })],
455
466
  meta: args
456
467
  };
@@ -461,7 +472,7 @@ var resolveUnifiedSearch = function resolveUnifiedSearch(input) {
461
472
  */
462
473
  var commands = exports.commands = [{
463
474
  name: 'search',
464
- description: 'Fuzzy-search ADS components, tokens, and icons together (or narrow with --type).',
475
+ description: 'Fuzzy-search ADS components, tokens, icons, and docs together (or narrow results with --type).',
465
476
  usage: "search <query...> [--type ".concat(Object.keys(SEARCH_TYPE_VALUES).join('|'), "] [--limit N]"),
466
477
  arguments: [{
467
478
  name: 'query',
@@ -477,7 +488,7 @@ var commands = exports.commands = [{
477
488
  choices: Object.keys(SEARCH_TYPE_VALUES),
478
489
  description: "Narrow the search to a single kind: ".concat(Object.keys(SEARCH_TYPE_VALUES).join(', '), ".")
479
490
  }, limitFlag],
480
- examples: ['search button', 'search space color --type token', 'search add --type icon --limit 5'],
491
+ examples: ['search button', 'search space color --type token', 'search add --type icon --limit 5', 'search contrast --type docs'],
481
492
  responseTypes: ['ads-cli/search'].concat((0, _toConsumableArray2.default)(Object.values(searchKindTools).map(function (tool) {
482
493
  return "ads-cli/".concat(tool.envelopeType);
483
494
  }))),
@@ -488,12 +499,20 @@ var commands = exports.commands = [{
488
499
  var _resolveSearchType;
489
500
  return (_resolveSearchType = resolveSearchType(input.flags)) !== null && _resolveSearchType !== void 0 ? _resolveSearchType : undefined;
490
501
  },
502
+ transform: function transform(_ref5) {
503
+ var data = _ref5.data,
504
+ input = _ref5.input;
505
+ return resolveSearchType(input.flags) === 'docs' ? (0, _createDocSearchResults.createDocSearchResults)({
506
+ data: data,
507
+ query: input.positionals.join(' ')
508
+ }) : data;
509
+ },
491
510
  envelopeType: function envelopeType(input) {
492
511
  var searchType = resolveSearchType(input.flags);
493
512
  return searchType ? searchKindTools[searchType].envelopeType : 'search';
494
513
  },
495
514
  resolve: function resolve(input) {
496
- // No `--type`: unified search across all three kinds.
515
+ // No `--type`: unified search across all three entity kinds and foundations docs.
497
516
  if (input.flags.type === undefined) {
498
517
  return resolveUnifiedSearch(input);
499
518
  }
@@ -549,9 +568,9 @@ var commands = exports.commands = [{
549
568
  // shows that rule's docs, but several matches with no exact name surface a disambiguation
550
569
  // list instead of dumping every rule's full Markdown. Skipped for bare `lint-rules` (which
551
570
  // intentionally returns every rule's content).
552
- transform: function transform(_ref5) {
553
- var data = _ref5.data,
554
- input = _ref5.input;
571
+ transform: function transform(_ref6) {
572
+ var data = _ref6.data,
573
+ input = _ref6.input;
555
574
  var terms = input.positionals;
556
575
  if (terms.length === 0) {
557
576
  return data;
@@ -1,19 +1,91 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.importToolHandler = void 0;
9
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
12
- function _tsRewriteRelativeImportExtensions(t, e) { return "string" == typeof t && /^\.\.?\//.test(t) ? t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+)?)\.([cm]?)ts$/i, function (t, s, r, n, o) { return s ? e ? ".jsx" : ".js" : !r || n && o ? r + n + "." + o.toLowerCase() + "js" : t; }) : t; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
13
12
  /**
14
13
  * Dynamic-import indirection used to load an ADS MCP tool handler by subpath.
15
14
  */
16
15
 
16
+ /**
17
+ * Every ADS MCP tool that the CLI can dispatch to.
18
+ *
19
+ * Literal import paths let bundlers discover and embed every tool while preserving lazy loading
20
+ * for the npm CLI. An unconstrained `import(importPath)` cannot produce a self-contained Atlas
21
+ * executable.
22
+ */
23
+ var toolImporters = {
24
+ '@atlaskit/ads-mcp/tools/get-a11y-guidelines': function atlaskit_adsMcp_tools_getA11yGuidelines() {
25
+ return Promise.resolve().then(function () {
26
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-a11y-guidelines" */
27
+ '@atlaskit/ads-mcp/tools/get-a11y-guidelines'));
28
+ });
29
+ },
30
+ '@atlaskit/ads-mcp/tools/get-all-components': function atlaskit_adsMcp_tools_getAllComponents() {
31
+ return Promise.resolve().then(function () {
32
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-all-components" */
33
+ '@atlaskit/ads-mcp/tools/get-all-components'));
34
+ });
35
+ },
36
+ '@atlaskit/ads-mcp/tools/get-all-icons': function atlaskit_adsMcp_tools_getAllIcons() {
37
+ return Promise.resolve().then(function () {
38
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-all-icons" */
39
+ '@atlaskit/ads-mcp/tools/get-all-icons'));
40
+ });
41
+ },
42
+ '@atlaskit/ads-mcp/tools/get-all-tokens': function atlaskit_adsMcp_tools_getAllTokens() {
43
+ return Promise.resolve().then(function () {
44
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-all-tokens" */
45
+ '@atlaskit/ads-mcp/tools/get-all-tokens'));
46
+ });
47
+ },
48
+ '@atlaskit/ads-mcp/tools/get-guidelines': function atlaskit_adsMcp_tools_getGuidelines() {
49
+ return Promise.resolve().then(function () {
50
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-guidelines" */
51
+ '@atlaskit/ads-mcp/tools/get-guidelines'));
52
+ });
53
+ },
54
+ '@atlaskit/ads-mcp/tools/get-lint-rules': function atlaskit_adsMcp_tools_getLintRules() {
55
+ return Promise.resolve().then(function () {
56
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-lint-rules" */
57
+ '@atlaskit/ads-mcp/tools/get-lint-rules'));
58
+ });
59
+ },
60
+ '@atlaskit/ads-mcp/tools/migration-guides': function atlaskit_adsMcp_tools_migrationGuides() {
61
+ return Promise.resolve().then(function () {
62
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-migration-guides" */
63
+ '@atlaskit/ads-mcp/tools/migration-guides'));
64
+ });
65
+ },
66
+ '@atlaskit/ads-mcp/tools/search-components': function atlaskit_adsMcp_tools_searchComponents() {
67
+ return Promise.resolve().then(function () {
68
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-search-components" */
69
+ '@atlaskit/ads-mcp/tools/search-components'));
70
+ });
71
+ },
72
+ '@atlaskit/ads-mcp/tools/search-icons': function atlaskit_adsMcp_tools_searchIcons() {
73
+ return Promise.resolve().then(function () {
74
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-search-icons" */
75
+ '@atlaskit/ads-mcp/tools/search-icons'));
76
+ });
77
+ },
78
+ '@atlaskit/ads-mcp/tools/search-tokens': function atlaskit_adsMcp_tools_searchTokens() {
79
+ return Promise.resolve().then(function () {
80
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-search-tokens" */
81
+ '@atlaskit/ads-mcp/tools/search-tokens'));
82
+ });
83
+ }
84
+ };
85
+ var isToolImportPath = function isToolImportPath(importPath) {
86
+ return importPath in toolImporters;
87
+ };
88
+
17
89
  /**
18
90
  * Load an ADS MCP tool handler by subpath.
19
91
  *
@@ -27,25 +99,25 @@ var importToolHandler = exports.importToolHandler = /*#__PURE__*/function () {
27
99
  while (1) switch (_context.prev = _context.next) {
28
100
  case 0:
29
101
  importPath = _ref.importPath, handlerName = _ref.handlerName;
30
- _context.next = 1;
31
- return function (specifier) {
32
- return new Promise(function (r) {
33
- return r("".concat(specifier));
34
- }).then(function (s) {
35
- return _interopRequireWildcard(require(s));
36
- });
37
- }( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool" */_tsRewriteRelativeImportExtensions(importPath));
102
+ if (isToolImportPath(importPath)) {
103
+ _context.next = 1;
104
+ break;
105
+ }
106
+ throw new Error("Unknown ADS MCP tool import path \"".concat(importPath, "\"."));
38
107
  case 1:
108
+ _context.next = 2;
109
+ return toolImporters[importPath]();
110
+ case 2:
39
111
  mod = _context.sent;
40
112
  handler = mod[handlerName];
41
113
  if (!(typeof handler !== 'function')) {
42
- _context.next = 2;
114
+ _context.next = 3;
43
115
  break;
44
116
  }
45
117
  throw new Error("Tool handler \"".concat(handlerName, "\" not found in \"").concat(importPath, "\"."));
46
- case 2:
47
- return _context.abrupt("return", handler);
48
118
  case 3:
119
+ return _context.abrupt("return", handler);
120
+ case 4:
49
121
  case "end":
50
122
  return _context.stop();
51
123
  }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createDocSearchResults = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ /**
12
+ * A concise documentation match derived from the Markdown returned by `getGuidelinesTool`.
13
+ *
14
+ * Search only surfaces this summary. The `docs` command remains the detail view for the full
15
+ * Markdown content.
16
+ */
17
+
18
+ /**
19
+ * Truncate a one-line description so compact rows stay on a single line.
20
+ */
21
+ var truncate = function truncate(text, max) {
22
+ return text.length > max ? "".concat(text.slice(0, max - 1).trimEnd(), "\u2026") : text;
23
+ };
24
+
25
+ /**
26
+ * Remove common Markdown formatting before showing documentation content in one row.
27
+ */
28
+ var toPlainText = function toPlainText(text) {
29
+ return text.replace(/!\[[^\]]*]\([^)]*\)/g, '').replace(/\[([^\]]+)]\([^)]*\)/g, '$1').replace(/^\s{0,3}#{1,6}\s+/gm, '').replace(/<[^>]+>/g, ' ').replace(/[*_`~]/g, '').replace(/\s+/g, ' ').trim();
30
+ };
31
+
32
+ /**
33
+ * Turn a full foundations-doc Markdown match into the concise record used by `search`.
34
+ *
35
+ * `getGuidelinesTool` currently returns Markdown rather than structured search metadata. Its
36
+ * highest-ranked match is represented by the query and a preview of its leading textual content;
37
+ * the full payload remains available through the follow-up `docs <query>` command.
38
+ */
39
+ var createDocSearchResults = exports.createDocSearchResults = function createDocSearchResults(_ref) {
40
+ var data = _ref.data,
41
+ query = _ref.query;
42
+ if (typeof data !== 'string' || data.trim() === '') {
43
+ return [];
44
+ }
45
+ var normalizedQuery = query.replace(/\s+/g, ' ').trim();
46
+ var title = normalizedQuery ? "".concat(normalizedQuery.charAt(0).toUpperCase()).concat(normalizedQuery.slice(1)) : 'Documentation';
47
+ var preview = toPlainText(data);
48
+ return [_objectSpread(_objectSpread({
49
+ title: truncate(title, 80)
50
+ }, preview ? {
51
+ summary: truncate(preview, 100)
52
+ } : {}), {}, {
53
+ followUp: "docs ".concat(query)
54
+ })];
55
+ };
@@ -8,9 +8,8 @@ var _formatResults = require("./format-results");
8
8
  /**
9
9
  * Sectioned compact renderer for grouped (multi-kind) results, e.g. unified `search`.
10
10
  *
11
- * Prints a Components section, then Tokens, then Icons — reusing the per-kind compact renderer
12
- * for each. Empty groups are skipped, so one command surfaces whatever kinds match, grouped by
13
- * kind.
11
+ * Prints Components, Tokens, Icons, and Docs sections using the per-kind compact renderer. Empty
12
+ * groups are skipped, so one command surfaces whatever kinds match, grouped by kind.
14
13
  */
15
14
 
16
15
  /**
@@ -29,6 +28,9 @@ var formatGroupedResults = exports.formatGroupedResults = function formatGrouped
29
28
  }, {
30
29
  kind: 'icons',
31
30
  title: 'Icons'
31
+ }, {
32
+ kind: 'docs',
33
+ title: 'Docs'
32
34
  }];
33
35
  var blocks = ["Results (".concat(totalCount, "):")];
34
36
  for (var _i = 0, _sections = sections; _i < _sections.length; _i++) {