@mintlify/cli 4.0.1130 → 4.0.1132

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
@@ -423,18 +423,18 @@ export const cli = ({ packageName = 'mint' }) => {
423
423
  }
424
424
  }))
425
425
  .command('analytics', 'View analytics for your documentation', analyticsBuilder)
426
- .command('score <url>', 'Run agent readiness checks on a docs site', (yargs) => yargs
426
+ .command('score [url]', 'Run agent readiness checks on a docs site', (yargs) => yargs
427
427
  .positional('url', {
428
428
  type: 'string',
429
- demandOption: true,
430
- description: 'URL of the docs site to check',
429
+ description: 'URL of the docs site to check (defaults to your configured subdomain)',
431
430
  })
432
431
  .option('format', {
433
432
  type: 'string',
434
433
  choices: ['table', 'plain', 'json'],
435
434
  description: 'Output format',
436
435
  })
437
- .example('mint score docs.example.com', 'Run agent readiness checks'), scoreHandler)
436
+ .example('mint score', 'Run agent readiness checks on your default subdomain')
437
+ .example('mint score docs.example.com', 'Run agent readiness checks on a URL'), scoreHandler)
438
438
  // Coming soon commands — visible in help, tracked via telemetry to gauge interest.
439
439
  .command('ai', '[Coming soon] AI-powered documentation (run mint ai to vote)', () => undefined, comingSoon('ai', packageName))
440
440
  .command('test', '[Coming soon] Test your documentation (run mint test to vote)', () => undefined, comingSoon('test', packageName))
@@ -11,7 +11,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { addLog, ErrorLog, SpinnerLog, removeLastLog } from '@mintlify/previewing';
12
12
  import chalk from 'chalk';
13
13
  import { Text } from 'ink';
14
+ import { getConfigValue } from '../config.js';
14
15
  import { terminate } from '../helpers.js';
16
+ import { getAccessToken } from '../keyring.js';
17
+ import { getCliSubdomains } from '../status.js';
15
18
  import { trackEvent } from '../telemetry/track.js';
16
19
  import { fetchScoreBySlug, resolveScoreForUrl } from './client.js';
17
20
  const POLL_INTERVAL_MS = 3000;
@@ -93,12 +96,32 @@ function pollForScore(slug, afterIso, onAttempt) {
93
96
  throw new Error(`Score did not complete within ${POLL_TIMEOUT_MS / 1000}s`);
94
97
  });
95
98
  }
99
+ function resolveDefaultSubdomain() {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ const fromConfig = getConfigValue('subdomain');
102
+ if (fromConfig)
103
+ return fromConfig;
104
+ const accessToken = yield getAccessToken();
105
+ if (!accessToken)
106
+ return undefined;
107
+ const subdomains = yield getCliSubdomains(accessToken);
108
+ return subdomains[0];
109
+ });
110
+ }
96
111
  export const scoreHandler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
97
112
  const format = resolveFormat(argv);
98
113
  try {
114
+ let url = argv.url;
115
+ if (!url) {
116
+ const subdomain = yield resolveDefaultSubdomain();
117
+ if (!subdomain) {
118
+ throw new Error('No URL provided and no default subdomain set. Run `mint login` to set one, or pass a URL: `mint score <url>`.');
119
+ }
120
+ url = `${subdomain}.mintlify.app`;
121
+ }
99
122
  if (format === 'table')
100
123
  addLog(_jsx(SpinnerLog, { message: "Checking agent readiness..." }));
101
- const resolved = yield resolveScoreForUrl(argv.url);
124
+ const resolved = yield resolveScoreForUrl(url);
102
125
  let final;
103
126
  if (resolved.status === 'ready') {
104
127
  const score = yield fetchScoreBySlug(resolved.slug);
@@ -138,7 +161,7 @@ export const scoreHandler = (argv) => __awaiter(void 0, void 0, void 0, function
138
161
  removeLastLog();
139
162
  }
140
163
  void trackEvent('cli.score.executed', {
141
- url: argv.url,
164
+ url,
142
165
  score: final.overallScore,
143
166
  format,
144
167
  status: resolved.status,