@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.
@@ -55,9 +55,8 @@ var truncate = function truncate(text) {
55
55
  /**
56
56
  * Append a `→ ads-cli <command> <name>` drill-in hint beneath a row.
57
57
  *
58
- * Only used in unified `search`, where a row is one of many mixed results and the natural next
59
- * step is to view that one in full. Single-kind listings (`--all`, `--type`) omit it — you asked
60
- * for the whole list, so echoing each row's own name back would just be noise.
58
+ * Used for every `search` result, where the natural next step is to view that match in full.
59
+ * `--all` listings omit it because echoing every row's own name would just be noise.
61
60
  */
62
61
  var withFollowUp = function withFollowUp(_ref) {
63
62
  var line = _ref.line,
@@ -122,13 +121,21 @@ var formatIconLine = function formatIconLine(iconResult, showFollowUp) {
122
121
  });
123
122
  };
124
123
 
124
+ /**
125
+ * Render one foundations-document match without dumping its full Markdown body.
126
+ */
127
+ var formatDocLine = function formatDocLine(doc, showFollowUp) {
128
+ var summary = doc.summary ? " \u2014 ".concat(doc.summary) : '';
129
+ var line = "".concat(doc.title).concat(summary);
130
+ return showFollowUp ? "".concat(line, "\n \u2192 ads-cli ").concat(doc.followUp) : line;
131
+ };
132
+
125
133
  /**
126
134
  * Render an array of results as compact lines for the given kind. Returns `null` when the data
127
135
  * is not an array (so the caller can fall back to generic JSON rendering).
128
136
  *
129
137
  * `showFollowUp` (default `false`) adds a `→ ads-cli <command> <name>` drill-in hint beneath each
130
- * row. It is enabled only by unified `search`; single-kind listings (`--all`, `--type`) leave it
131
- * off so the output stays terse.
138
+ * row. Search enables it for both grouped and `--type` output; `--all` listings leave it off.
132
139
  */
133
140
  var formatCompactResults = exports.formatCompactResults = function formatCompactResults(_ref2) {
134
141
  var kind = _ref2.kind,
@@ -149,6 +156,8 @@ var formatCompactResults = exports.formatCompactResults = function formatCompact
149
156
  return formatTokenLine(entry, showFollowUp);
150
157
  case 'icons':
151
158
  return formatIconLine(entry, showFollowUp);
159
+ case 'docs':
160
+ return formatDocLine(entry, showFollowUp);
152
161
  default:
153
162
  return JSON.stringify(entry);
154
163
  }
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import { run } from './cli';
3
+
4
+ /**
5
+ * Process entrypoint for the `atlas ads` distribution.
6
+ *
7
+ * Atlas forwards everything after `atlas ads` as process arguments. The shared CLI owns parsing,
8
+ * output, and its stable exit-code contract; this entrypoint only maps that result onto the plugin
9
+ * process.
10
+ */
11
+ export const main = async (argv = process.argv.slice(2)) => {
12
+ try {
13
+ const exitCode = await run(argv);
14
+ process.exitCode = exitCode;
15
+ } catch (error) {
16
+ var _error$stack;
17
+ if (typeof error === 'number') {
18
+ process.exitCode = error;
19
+ return;
20
+ }
21
+ process.stderr.write(`${error instanceof Error ? (_error$stack = error.stack) !== null && _error$stack !== void 0 ? _error$stack : error.message : String(error)}\n`);
22
+ process.exitCode = 1;
23
+ }
24
+ };
25
+ if (require.main === module) {
26
+ void main();
27
+ }
@@ -17,6 +17,7 @@ import { importToolHandler } from './commands/import-tool-handler';
17
17
  import { runTool } from './commands/run-tool';
18
18
  import { createErrorEnvelope } from './envelope/create-error-envelope';
19
19
  import { createSuccessEnvelope } from './envelope/create-success-envelope';
20
+ import { createDocSearchResults } from './output/create-doc-search-results';
20
21
  import { formatGroupedResults } from './output/format-grouped-results';
21
22
  import { formatCompactResults } from './output/format-results';
22
23
  import { writeHumanError } from './output/write-human-error';
@@ -48,7 +49,7 @@ const buildHelpText = () => {
48
49
  const aliases = flag.alias ? `, -${flag.alias}` : '';
49
50
  return ` --${flag.name}${aliases}`.padEnd(18) + flag.description;
50
51
  }).join('\n');
51
- return [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');
52
+ 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');
52
53
  };
53
54
 
54
55
  /**
@@ -226,7 +227,8 @@ const renderSingleResult = ({
226
227
  const resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
227
228
  const compact = resultKind ? formatCompactResults({
228
229
  kind: resultKind,
229
- data
230
+ data,
231
+ showFollowUp: command.name === 'search'
230
232
  }) : null;
231
233
  const human = (_ref = compact !== null && compact !== void 0 ? compact : (_command$formatHuman = command.formatHuman) === null || _command$formatHuman === void 0 ? void 0 : _command$formatHuman.call(command, data)) !== null && _ref !== void 0 ? _ref : null;
232
234
  if (human !== null) {
@@ -255,18 +257,26 @@ const renderGroupedResult = ({
255
257
  writer
256
258
  }) => {
257
259
  // Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
258
- // empty domain does not blank out the others.
260
+ // empty domain does not blank out the others. The guidelines tool returns full Markdown, so
261
+ // summarize its highest-ranked match for search; `docs <query>` remains the detail view.
259
262
  const grouped = {};
260
263
  for (const {
261
264
  key,
262
265
  data,
263
266
  isError
264
267
  } of results) {
265
- grouped[key] = isError || !Array.isArray(data) ? [] : data;
268
+ if (key === 'docs' && !isError && typeof data === 'string' && data.trim() !== '') {
269
+ grouped[key] = createDocSearchResults({
270
+ data,
271
+ query: input.positionals.join(' ')
272
+ });
273
+ } else {
274
+ grouped[key] = isError || !Array.isArray(data) ? [] : data;
275
+ }
266
276
  }
267
277
  const totalCount = Object.values(grouped).reduce((sum, arr) => sum + arr.length, 0);
268
278
  if (totalCount === 0) {
269
- const message = 'No components, tokens, or icons found.';
279
+ const message = `No components, tokens, icons, or docs found for "${input.positionals.join(' ')}".`;
270
280
  if (json) {
271
281
  writeJsonEnvelope({
272
282
  envelope: createErrorEnvelope({
@@ -289,8 +299,8 @@ const renderGroupedResult = ({
289
299
  envelope: createSuccessEnvelope({
290
300
  envelopeType: command.envelopeType(input),
291
301
  command: command.name,
292
- // `data` for grouped commands is `{ components, tokens, icons }` (already counted
293
- // per group), so `count` is the combined total across groups.
302
+ // `data` for grouped commands is `{ components, tokens, icons, docs }` (already
303
+ // counted per group), so `count` is the combined total across groups.
294
304
  data: grouped,
295
305
  meta: {
296
306
  ...meta,
@@ -16,6 +16,7 @@
16
16
 
17
17
  import { accessibilityGuidelines } from '@atlaskit/ads-mcp/a11y-guidelines';
18
18
  import { migrationRegistry } from '@atlaskit/ads-mcp/migration-registry';
19
+ import { createDocSearchResults } from '../output/create-doc-search-results';
19
20
  import { isDisambiguation } from '../output/disambiguation';
20
21
  import { formatComponent } from '../output/format-component';
21
22
  import { formatDisambiguation } from '../output/format-disambiguation';
@@ -56,7 +57,7 @@ const parseLimit = flags => {
56
57
  };
57
58
 
58
59
  /**
59
- * Map of the three `search --type` variants to their ADS MCP tool exports.
60
+ * Map of the `search --type` variants to their ADS MCP tool exports.
60
61
  */
61
62
  const searchKindTools = {
62
63
  components: {
@@ -73,17 +74,22 @@ const searchKindTools = {
73
74
  importPath: '@atlaskit/ads-mcp/tools/search-icons',
74
75
  handlerName: 'searchIconsTool',
75
76
  envelopeType: 'search-icons'
77
+ },
78
+ docs: {
79
+ importPath: '@atlaskit/ads-mcp/tools/get-guidelines',
80
+ handlerName: 'getGuidelinesTool',
81
+ envelopeType: 'search-docs'
76
82
  }
77
83
  };
78
84
  /**
79
- * Accepted `--type` values (singular, matching the item command names) → the internal (plural)
80
- * {@link SearchKind}. Everything downstream keys off the plural `SearchKind` (envelope types,
81
- * grouped JSON keys), so the singular input normalises to it here.
85
+ * Accepted `--type` values → the internal {@link SearchKind}. Entity inputs are singular to match
86
+ * their item commands; `docs` matches the dedicated documentation command.
82
87
  */
83
88
  const SEARCH_TYPE_VALUES = {
84
89
  component: 'components',
85
90
  token: 'tokens',
86
- icon: 'icons'
91
+ icon: 'icons',
92
+ docs: 'docs'
87
93
  };
88
94
  const isSearchTypeValue = value => value in SEARCH_TYPE_VALUES;
89
95
 
@@ -391,10 +397,11 @@ const makeItemCommand = ({
391
397
  };
392
398
 
393
399
  /**
394
- * Resolver for the unified `search` (no `--type`): fan out to all three search tools in one
395
- * command. The results are grouped by kind (components/tokens/icons) rather than merged into a
396
- * single ranked list — each tool ranks its own domain, and re-ranking across domains would
397
- * mean duplicating ranking logic here (breaking the zero-drift contract with `@atlaskit/ads-mcp`).
400
+ * Resolver for the unified `search` (no `--type`): fan out to the three entity search tools and
401
+ * foundations documentation search in one command. The results are grouped by kind
402
+ * (components/tokens/icons/docs) rather than merged into a single ranked list — each tool ranks its
403
+ * own domain, and re-ranking across domains would mean duplicating ranking logic here (breaking the
404
+ * zero-drift contract with `@atlaskit/ads-mcp`).
398
405
  */
399
406
  const resolveUnifiedSearch = input => {
400
407
  const terms = input.positionals;
@@ -427,6 +434,10 @@ const resolveUnifiedSearch = input => {
427
434
  key: 'icons',
428
435
  ...searchKindTools.icons,
429
436
  args
437
+ }, {
438
+ key: 'docs',
439
+ ...searchKindTools.docs,
440
+ args
430
441
  }],
431
442
  meta: args
432
443
  };
@@ -437,7 +448,7 @@ const resolveUnifiedSearch = input => {
437
448
  */
438
449
  export const commands = [{
439
450
  name: 'search',
440
- description: 'Fuzzy-search ADS components, tokens, and icons together (or narrow with --type).',
451
+ description: 'Fuzzy-search ADS components, tokens, icons, and docs together (or narrow results with --type).',
441
452
  usage: `search <query...> [--type ${Object.keys(SEARCH_TYPE_VALUES).join('|')}] [--limit N]`,
442
453
  arguments: [{
443
454
  name: 'query',
@@ -453,7 +464,7 @@ export const commands = [{
453
464
  choices: Object.keys(SEARCH_TYPE_VALUES),
454
465
  description: `Narrow the search to a single kind: ${Object.keys(SEARCH_TYPE_VALUES).join(', ')}.`
455
466
  }, limitFlag],
456
- examples: ['search button', 'search space color --type token', 'search add --type icon --limit 5'],
467
+ examples: ['search button', 'search space color --type token', 'search add --type icon --limit 5', 'search contrast --type docs'],
457
468
  responseTypes: ['ads-cli/search', ...Object.values(searchKindTools).map(tool => `ads-cli/${tool.envelopeType}`)],
458
469
  // With `--type`, the result is a single kind (compact per-row rendering). Without it, the
459
470
  // result is grouped across all kinds, so there is no single result kind — the grouped
@@ -462,12 +473,19 @@ export const commands = [{
462
473
  var _resolveSearchType;
463
474
  return (_resolveSearchType = resolveSearchType(input.flags)) !== null && _resolveSearchType !== void 0 ? _resolveSearchType : undefined;
464
475
  },
476
+ transform: ({
477
+ data,
478
+ input
479
+ }) => resolveSearchType(input.flags) === 'docs' ? createDocSearchResults({
480
+ data,
481
+ query: input.positionals.join(' ')
482
+ }) : data,
465
483
  envelopeType: input => {
466
484
  const searchType = resolveSearchType(input.flags);
467
485
  return searchType ? searchKindTools[searchType].envelopeType : 'search';
468
486
  },
469
487
  resolve: input => {
470
- // No `--type`: unified search across all three kinds.
488
+ // No `--type`: unified search across all three entity kinds and foundations docs.
471
489
  if (input.flags.type === undefined) {
472
490
  return resolveUnifiedSearch(input);
473
491
  }
@@ -1,8 +1,38 @@
1
- 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; }
2
1
  /**
3
2
  * Dynamic-import indirection used to load an ADS MCP tool handler by subpath.
4
3
  */
5
4
 
5
+ /**
6
+ * Every ADS MCP tool that the CLI can dispatch to.
7
+ *
8
+ * Literal import paths let bundlers discover and embed every tool while preserving lazy loading
9
+ * for the npm CLI. An unconstrained `import(importPath)` cannot produce a self-contained Atlas
10
+ * executable.
11
+ */
12
+ const toolImporters = {
13
+ '@atlaskit/ads-mcp/tools/get-a11y-guidelines': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-a11y-guidelines" */
14
+ '@atlaskit/ads-mcp/tools/get-a11y-guidelines'),
15
+ '@atlaskit/ads-mcp/tools/get-all-components': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-all-components" */
16
+ '@atlaskit/ads-mcp/tools/get-all-components'),
17
+ '@atlaskit/ads-mcp/tools/get-all-icons': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-all-icons" */
18
+ '@atlaskit/ads-mcp/tools/get-all-icons'),
19
+ '@atlaskit/ads-mcp/tools/get-all-tokens': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-all-tokens" */
20
+ '@atlaskit/ads-mcp/tools/get-all-tokens'),
21
+ '@atlaskit/ads-mcp/tools/get-guidelines': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-guidelines" */
22
+ '@atlaskit/ads-mcp/tools/get-guidelines'),
23
+ '@atlaskit/ads-mcp/tools/get-lint-rules': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-get-lint-rules" */
24
+ '@atlaskit/ads-mcp/tools/get-lint-rules'),
25
+ '@atlaskit/ads-mcp/tools/migration-guides': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-migration-guides" */
26
+ '@atlaskit/ads-mcp/tools/migration-guides'),
27
+ '@atlaskit/ads-mcp/tools/search-components': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-search-components" */
28
+ '@atlaskit/ads-mcp/tools/search-components'),
29
+ '@atlaskit/ads-mcp/tools/search-icons': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-search-icons" */
30
+ '@atlaskit/ads-mcp/tools/search-icons'),
31
+ '@atlaskit/ads-mcp/tools/search-tokens': () => import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool-search-tokens" */
32
+ '@atlaskit/ads-mcp/tools/search-tokens')
33
+ };
34
+ const isToolImportPath = importPath => importPath in toolImporters;
35
+
6
36
  /**
7
37
  * Load an ADS MCP tool handler by subpath.
8
38
  *
@@ -13,7 +43,10 @@ export const importToolHandler = async ({
13
43
  importPath,
14
44
  handlerName
15
45
  }) => {
16
- const mod = await import( /* webpackChunkName: "@atlaskit-internal_ads-cli-tool" */_tsRewriteRelativeImportExtensions(importPath));
46
+ if (!isToolImportPath(importPath)) {
47
+ throw new Error(`Unknown ADS MCP tool import path "${importPath}".`);
48
+ }
49
+ const mod = await toolImporters[importPath]();
17
50
  const handler = mod[handlerName];
18
51
  if (typeof handler !== 'function') {
19
52
  throw new Error(`Tool handler "${handlerName}" not found in "${importPath}".`);
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A concise documentation match derived from the Markdown returned by `getGuidelinesTool`.
3
+ *
4
+ * Search only surfaces this summary. The `docs` command remains the detail view for the full
5
+ * Markdown content.
6
+ */
7
+
8
+ /**
9
+ * Truncate a one-line description so compact rows stay on a single line.
10
+ */
11
+ const truncate = (text, max) => text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
12
+
13
+ /**
14
+ * Remove common Markdown formatting before showing documentation content in one row.
15
+ */
16
+ const toPlainText = text => text.replace(/!\[[^\]]*]\([^)]*\)/g, '').replace(/\[([^\]]+)]\([^)]*\)/g, '$1').replace(/^\s{0,3}#{1,6}\s+/gm, '').replace(/<[^>]+>/g, ' ').replace(/[*_`~]/g, '').replace(/\s+/g, ' ').trim();
17
+
18
+ /**
19
+ * Turn a full foundations-doc Markdown match into the concise record used by `search`.
20
+ *
21
+ * `getGuidelinesTool` currently returns Markdown rather than structured search metadata. Its
22
+ * highest-ranked match is represented by the query and a preview of its leading textual content;
23
+ * the full payload remains available through the follow-up `docs <query>` command.
24
+ */
25
+ export const createDocSearchResults = ({
26
+ data,
27
+ query
28
+ }) => {
29
+ if (typeof data !== 'string' || data.trim() === '') {
30
+ return [];
31
+ }
32
+ const normalizedQuery = query.replace(/\s+/g, ' ').trim();
33
+ const title = normalizedQuery ? `${normalizedQuery.charAt(0).toUpperCase()}${normalizedQuery.slice(1)}` : 'Documentation';
34
+ const preview = toPlainText(data);
35
+ return [{
36
+ title: truncate(title, 80),
37
+ ...(preview ? {
38
+ summary: truncate(preview, 100)
39
+ } : {}),
40
+ followUp: `docs ${query}`
41
+ }];
42
+ };
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Sectioned compact renderer for grouped (multi-kind) results, e.g. unified `search`.
3
3
  *
4
- * Prints a Components section, then Tokens, then Icons — reusing the per-kind compact renderer
5
- * for each. Empty groups are skipped, so one command surfaces whatever kinds match, grouped by
6
- * kind.
4
+ * Prints Components, Tokens, Icons, and Docs sections using the per-kind compact renderer. Empty
5
+ * groups are skipped, so one command surfaces whatever kinds match, grouped by kind.
7
6
  */
8
7
 
9
8
  import { formatCompactResults } from './format-results';
@@ -25,6 +24,9 @@ export const formatGroupedResults = ({
25
24
  }, {
26
25
  kind: 'icons',
27
26
  title: 'Icons'
27
+ }, {
28
+ kind: 'docs',
29
+ title: 'Docs'
28
30
  }];
29
31
  const blocks = [`Results (${totalCount}):`];
30
32
  for (const {
@@ -40,9 +40,8 @@ const truncate = (text, max = 80) => text.length > max ? `${text.slice(0, max -
40
40
  /**
41
41
  * Append a `→ ads-cli <command> <name>` drill-in hint beneath a row.
42
42
  *
43
- * Only used in unified `search`, where a row is one of many mixed results and the natural next
44
- * step is to view that one in full. Single-kind listings (`--all`, `--type`) omit it — you asked
45
- * for the whole list, so echoing each row's own name back would just be noise.
43
+ * Used for every `search` result, where the natural next step is to view that match in full.
44
+ * `--all` listings omit it because echoing every row's own name would just be noise.
46
45
  */
47
46
  const withFollowUp = ({
48
47
  line,
@@ -106,13 +105,21 @@ const formatIconLine = (iconResult, showFollowUp) => {
106
105
  });
107
106
  };
108
107
 
108
+ /**
109
+ * Render one foundations-document match without dumping its full Markdown body.
110
+ */
111
+ const formatDocLine = (doc, showFollowUp) => {
112
+ const summary = doc.summary ? ` — ${doc.summary}` : '';
113
+ const line = `${doc.title}${summary}`;
114
+ return showFollowUp ? `${line}\n → ads-cli ${doc.followUp}` : line;
115
+ };
116
+
109
117
  /**
110
118
  * Render an array of results as compact lines for the given kind. Returns `null` when the data
111
119
  * is not an array (so the caller can fall back to generic JSON rendering).
112
120
  *
113
121
  * `showFollowUp` (default `false`) adds a `→ ads-cli <command> <name>` drill-in hint beneath each
114
- * row. It is enabled only by unified `search`; single-kind listings (`--all`, `--type`) leave it
115
- * off so the output stays terse.
122
+ * row. Search enables it for both grouped and `--type` output; `--all` listings leave it off.
116
123
  */
117
124
  export const formatCompactResults = ({
118
125
  kind,
@@ -133,6 +140,8 @@ export const formatCompactResults = ({
133
140
  return formatTokenLine(entry, showFollowUp);
134
141
  case 'icons':
135
142
  return formatIconLine(entry, showFollowUp);
143
+ case 'docs':
144
+ return formatDocLine(entry, showFollowUp);
136
145
  default:
137
146
  return JSON.stringify(entry);
138
147
  }
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { run } from './cli';
5
+
6
+ /**
7
+ * Process entrypoint for the `atlas ads` distribution.
8
+ *
9
+ * Atlas forwards everything after `atlas ads` as process arguments. The shared CLI owns parsing,
10
+ * output, and its stable exit-code contract; this entrypoint only maps that result onto the plugin
11
+ * process.
12
+ */
13
+ export var main = /*#__PURE__*/function () {
14
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
15
+ var argv,
16
+ exitCode,
17
+ _error$stack,
18
+ _args = arguments,
19
+ _t;
20
+ return _regeneratorRuntime.wrap(function (_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ argv = _args.length > 0 && _args[0] !== undefined ? _args[0] : process.argv.slice(2);
24
+ _context.prev = 1;
25
+ _context.next = 2;
26
+ return run(argv);
27
+ case 2:
28
+ exitCode = _context.sent;
29
+ process.exitCode = exitCode;
30
+ _context.next = 5;
31
+ break;
32
+ case 3:
33
+ _context.prev = 3;
34
+ _t = _context["catch"](1);
35
+ if (!(typeof _t === 'number')) {
36
+ _context.next = 4;
37
+ break;
38
+ }
39
+ process.exitCode = _t;
40
+ return _context.abrupt("return");
41
+ case 4:
42
+ process.stderr.write("".concat(_t instanceof Error ? (_error$stack = _t.stack) !== null && _error$stack !== void 0 ? _error$stack : _t.message : String(_t), "\n"));
43
+ process.exitCode = 1;
44
+ case 5:
45
+ case "end":
46
+ return _context.stop();
47
+ }
48
+ }, _callee, null, [[1, 3]]);
49
+ }));
50
+ return function main() {
51
+ return _ref.apply(this, arguments);
52
+ };
53
+ }();
54
+ if (require.main === module) {
55
+ void main();
56
+ }
package/dist/esm/cli.js CHANGED
@@ -25,6 +25,7 @@ import { importToolHandler } from './commands/import-tool-handler';
25
25
  import { runTool } from './commands/run-tool';
26
26
  import { createErrorEnvelope } from './envelope/create-error-envelope';
27
27
  import { createSuccessEnvelope } from './envelope/create-success-envelope';
28
+ import { createDocSearchResults } from './output/create-doc-search-results';
28
29
  import { formatGroupedResults } from './output/format-grouped-results';
29
30
  import { formatCompactResults } from './output/format-results';
30
31
  import { writeHumanError } from './output/write-human-error';
@@ -58,7 +59,7 @@ var buildHelpText = function buildHelpText() {
58
59
  var aliases = flag.alias ? ", -".concat(flag.alias) : '';
59
60
  return " --".concat(flag.name).concat(aliases).padEnd(18) + flag.description;
60
61
  }).join('\n');
61
- return [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');
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');
62
63
  };
63
64
 
64
65
  /**
@@ -265,7 +266,8 @@ var renderSingleResult = function renderSingleResult(_ref4) {
265
266
  var resultKind = (_command$resultKind = command.resultKind) === null || _command$resultKind === void 0 ? void 0 : _command$resultKind.call(command, input);
266
267
  var compact = resultKind ? formatCompactResults({
267
268
  kind: resultKind,
268
- data: data
269
+ data: data,
270
+ showFollowUp: command.name === 'search'
269
271
  }) : null;
270
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;
271
273
  if (human !== null) {
@@ -293,7 +295,8 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
293
295
  json = _ref6.json,
294
296
  writer = _ref6.writer;
295
297
  // Assemble `{ [key]: results }`, coercing "no matches" sub-results to empty arrays so one
296
- // empty domain does not blank out the others.
298
+ // empty domain does not blank out the others. The guidelines tool returns full Markdown, so
299
+ // summarize its highest-ranked match for search; `docs <query>` remains the detail view.
297
300
  var grouped = {};
298
301
  var _iterator = _createForOfIteratorHelper(results),
299
302
  _step;
@@ -303,7 +306,14 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
303
306
  key = _step$value.key,
304
307
  data = _step$value.data,
305
308
  isError = _step$value.isError;
306
- grouped[key] = isError || !Array.isArray(data) ? [] : data;
309
+ if (key === 'docs' && !isError && typeof data === 'string' && data.trim() !== '') {
310
+ grouped[key] = createDocSearchResults({
311
+ data: data,
312
+ query: input.positionals.join(' ')
313
+ });
314
+ } else {
315
+ grouped[key] = isError || !Array.isArray(data) ? [] : data;
316
+ }
307
317
  }
308
318
  } catch (err) {
309
319
  _iterator.e(err);
@@ -314,7 +324,7 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
314
324
  return sum + arr.length;
315
325
  }, 0);
316
326
  if (totalCount === 0) {
317
- var message = 'No components, tokens, or icons found.';
327
+ var message = "No components, tokens, icons, or docs found for \"".concat(input.positionals.join(' '), "\".");
318
328
  if (json) {
319
329
  writeJsonEnvelope({
320
330
  envelope: createErrorEnvelope({
@@ -337,8 +347,8 @@ var renderGroupedResult = function renderGroupedResult(_ref6) {
337
347
  envelope: createSuccessEnvelope({
338
348
  envelopeType: command.envelopeType(input),
339
349
  command: command.name,
340
- // `data` for grouped commands is `{ components, tokens, icons }` (already counted
341
- // per group), so `count` is the combined total across groups.
350
+ // `data` for grouped commands is `{ components, tokens, icons, docs }` (already
351
+ // counted per group), so `count` is the combined total across groups.
342
352
  data: grouped,
343
353
  meta: _objectSpread(_objectSpread({}, meta), {}, {
344
354
  count: totalCount