@mintlify/cli 4.0.1108 → 4.0.1110

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/bin/cli.js CHANGED
@@ -29,6 +29,7 @@ import { logout } from './logout.js';
29
29
  import { mdxLinter } from './mdxLinter.js';
30
30
  import { createTelemetryMiddleware } from './middlewares/telemetryMiddleware.js';
31
31
  import { checkOpenApiFile, getOpenApiFilenamesFromDocsConfig } from './openApiCheck.js';
32
+ import { scoreHandler } from './score/index.js';
32
33
  import { status, getCliSubdomains } from './status.js';
33
34
  import { trackTelemetryPreferenceChange } from './telemetry/track.js';
34
35
  import { update } from './update.js';
@@ -411,6 +412,18 @@ export const cli = ({ packageName = 'mint' }) => {
411
412
  }
412
413
  }))
413
414
  .command('analytics', 'View analytics for your documentation', analyticsBuilder)
415
+ .command('score <url>', 'Run agent readiness checks on a docs site', (yargs) => yargs
416
+ .positional('url', {
417
+ type: 'string',
418
+ demandOption: true,
419
+ description: 'URL of the docs site to check',
420
+ })
421
+ .option('format', {
422
+ type: 'string',
423
+ choices: ['table', 'plain', 'json'],
424
+ description: 'Output format',
425
+ })
426
+ .example('mint score docs.example.com', 'Run agent readiness checks'), scoreHandler)
414
427
  // Coming soon commands — visible in help, tracked via telemetry to gauge interest.
415
428
  .command('ai', '[Coming soon] AI-powered documentation (run mint ai to vote)', () => undefined, comingSoon('ai', packageName))
416
429
  .command('test', '[Coming soon] Test your documentation (run mint test to vote)', () => undefined, comingSoon('test', packageName))
@@ -0,0 +1,25 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { authenticatedFetch } from '../authenticatedFetch.js';
11
+ import { API_URL } from '../constants.js';
12
+ export function getScore(url) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const endpoint = new URL(`${API_URL}/api/cli/score`);
15
+ endpoint.searchParams.set('url', url);
16
+ const res = yield authenticatedFetch(endpoint.toString(), {
17
+ headers: { Accept: 'application/json' },
18
+ });
19
+ if (!res.ok) {
20
+ const body = yield res.text().catch(() => '');
21
+ throw new Error(`API error (${res.status}): ${body || res.statusText}`);
22
+ }
23
+ return res.json();
24
+ });
25
+ }
@@ -0,0 +1,98 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { addLog, ErrorLog, SpinnerLog, removeLastLog } from '@mintlify/previewing';
12
+ import chalk from 'chalk';
13
+ import { Text } from 'ink';
14
+ import { terminate } from '../helpers.js';
15
+ import { getScore } from './client.js';
16
+ function resolveFormat(argv) {
17
+ if (argv.format === 'table' || argv.format === 'plain' || argv.format === 'json')
18
+ return argv.format;
19
+ return 'table';
20
+ }
21
+ function statusIcon(pass) {
22
+ return pass ? chalk.green('✓') : chalk.red('✗');
23
+ }
24
+ function formatCheckName(name) {
25
+ return name
26
+ .replace(/([A-Z])/g, ' $1')
27
+ .replace(/^./, (c) => c.toUpperCase())
28
+ .trim();
29
+ }
30
+ function renderChecks(checks, indent = 0) {
31
+ const lines = [];
32
+ const pad = ' '.repeat(indent + 1);
33
+ for (const check of checks) {
34
+ lines.push(`${pad}${statusIcon(check.pass)} ${formatCheckName(check.name)}`);
35
+ if (check.children && check.children.length > 0) {
36
+ lines.push(...renderChecks(check.children, indent + 1));
37
+ }
38
+ }
39
+ return lines;
40
+ }
41
+ function renderPlain(checks, prefix = '') {
42
+ const lines = [];
43
+ for (const check of checks) {
44
+ lines.push(`${prefix}${check.pass ? 'PASS' : 'FAIL'}\t${check.name}`);
45
+ if (check.children && check.children.length > 0) {
46
+ lines.push(...renderPlain(check.children, prefix + ' '));
47
+ }
48
+ }
49
+ return lines;
50
+ }
51
+ function output(format, text) {
52
+ if (format === 'table') {
53
+ addLog(_jsx(Text, { children: text }));
54
+ }
55
+ else {
56
+ process.stdout.write(text + '\n');
57
+ }
58
+ }
59
+ export const scoreHandler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
60
+ const format = resolveFormat(argv);
61
+ try {
62
+ if (format === 'table')
63
+ addLog(_jsx(SpinnerLog, { message: "Running agent readiness checks..." }));
64
+ const data = yield getScore(argv.url);
65
+ if (format === 'table')
66
+ removeLastLog();
67
+ if (format === 'json') {
68
+ output(format, JSON.stringify(data, null, 2));
69
+ yield terminate(0);
70
+ return;
71
+ }
72
+ if (format === 'plain') {
73
+ const lines = [`SCORE\t${data.overallScore}`, ...renderPlain(data.checks)];
74
+ output(format, lines.join('\n'));
75
+ yield terminate(0);
76
+ return;
77
+ }
78
+ const scoreColor = data.overallScore >= 70 ? 'green' : data.overallScore >= 40 ? 'yellow' : 'red';
79
+ const lines = [];
80
+ lines.push(chalk.bold(`\nAgent Readiness Score — ${data.url}\n`));
81
+ lines.push(` Score: ${chalk[scoreColor].bold(`${data.overallScore}%`)}\n`);
82
+ lines.push(chalk.bold(' Checks'));
83
+ lines.push(...renderChecks(data.checks));
84
+ output(format, lines.join('\n'));
85
+ yield terminate(0);
86
+ }
87
+ catch (err) {
88
+ const message = err instanceof Error ? err.message : 'unknown error';
89
+ if (format === 'table') {
90
+ removeLastLog();
91
+ addLog(_jsx(ErrorLog, { message: message }));
92
+ }
93
+ else {
94
+ process.stderr.write(`Error: ${message}\n`);
95
+ }
96
+ yield terminate(1);
97
+ }
98
+ });
@@ -0,0 +1 @@
1
+ export {};