@mintlify/cli 4.0.1813 → 4.1.1

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.
Files changed (274) hide show
  1. package/dist/assets/export-scripts/README.classic.md +15 -0
  2. package/dist/assets/export-scripts/README.md +14 -0
  3. package/dist/assets/export-scripts/serve.js +114 -0
  4. package/dist/assets/export-scripts/start-docs.bat +10 -0
  5. package/dist/assets/export-scripts/start-docs.sh +9 -0
  6. package/dist/assets/og/Inter-Bold.ttf +0 -0
  7. package/dist/assets/og/Inter-Medium.ttf +0 -0
  8. package/dist/assets/og/Inter-Regular.ttf +0 -0
  9. package/dist/assets/og/Inter-SemiBold.ttf +0 -0
  10. package/dist/assets/og/PaperMono-Regular.ttf +0 -0
  11. package/dist/assets/og/index_bg.wasm +0 -0
  12. package/dist/assets/openChrome.applescript +94 -0
  13. package/dist/assets/socket.io/socket.io.esm.min.js +7 -0
  14. package/dist/assets/socket.io/socket.io.esm.min.js.map +1 -0
  15. package/dist/assets/socket.io/socket.io.js +4907 -0
  16. package/dist/assets/socket.io/socket.io.js.map +1 -0
  17. package/dist/assets/socket.io/socket.io.min.js +7 -0
  18. package/dist/assets/socket.io/socket.io.min.js.map +1 -0
  19. package/dist/assets/socket.io/socket.io.msgpack.min.js +7 -0
  20. package/dist/assets/socket.io/socket.io.msgpack.min.js.map +1 -0
  21. package/dist/assets/xdg-open +1066 -0
  22. package/dist/assets/yargs-locales/be.json +46 -0
  23. package/dist/assets/yargs-locales/cs.json +51 -0
  24. package/dist/assets/yargs-locales/de.json +46 -0
  25. package/dist/assets/yargs-locales/en.json +55 -0
  26. package/dist/assets/yargs-locales/es.json +46 -0
  27. package/dist/assets/yargs-locales/fi.json +49 -0
  28. package/dist/assets/yargs-locales/fr.json +53 -0
  29. package/dist/assets/yargs-locales/hi.json +49 -0
  30. package/dist/assets/yargs-locales/hu.json +46 -0
  31. package/dist/assets/yargs-locales/id.json +50 -0
  32. package/dist/assets/yargs-locales/it.json +46 -0
  33. package/dist/assets/yargs-locales/ja.json +51 -0
  34. package/dist/assets/yargs-locales/ko.json +49 -0
  35. package/dist/assets/yargs-locales/nb.json +44 -0
  36. package/dist/assets/yargs-locales/nl.json +49 -0
  37. package/dist/assets/yargs-locales/nn.json +44 -0
  38. package/dist/assets/yargs-locales/pirate.json +13 -0
  39. package/dist/assets/yargs-locales/pl.json +49 -0
  40. package/dist/assets/yargs-locales/pt.json +45 -0
  41. package/dist/assets/yargs-locales/pt_BR.json +48 -0
  42. package/dist/assets/yargs-locales/ru.json +51 -0
  43. package/dist/assets/yargs-locales/th.json +46 -0
  44. package/dist/assets/yargs-locales/tr.json +48 -0
  45. package/dist/assets/yargs-locales/uk_UA.json +51 -0
  46. package/dist/assets/yargs-locales/uz.json +52 -0
  47. package/dist/assets/yargs-locales/zh_CN.json +48 -0
  48. package/dist/assets/yargs-locales/zh_TW.json +51 -0
  49. package/dist/converter-d8O3xkdU.js +102 -0
  50. package/dist/devtools-CGNZQKFV.js +24 -0
  51. package/dist/index.js +8 -0
  52. package/dist/rolldown-runtime-CEAe2Uac.js +7 -0
  53. package/dist/schemas-CBsmCNpK.js +372 -0
  54. package/dist/start.js +2310 -0
  55. package/package.json +38 -31
  56. package/.oxlintrc.json +0 -5
  57. package/.prettierignore +0 -2
  58. package/.turbo/turbo-build.log +0 -1
  59. package/CONTRIBUTING.md +0 -45
  60. package/__test__/agent-auth.test.ts +0 -114
  61. package/__test__/agent-claim.test.ts +0 -164
  62. package/__test__/agent-credentials.test.ts +0 -149
  63. package/__test__/agent-deployment.test.ts +0 -106
  64. package/__test__/agent-setup-config.test.ts +0 -324
  65. package/__test__/agent-setup.test.ts +0 -207
  66. package/__test__/agent.test.ts +0 -64
  67. package/__test__/analytics/client.test.ts +0 -180
  68. package/__test__/analytics/dates.test.ts +0 -12
  69. package/__test__/analytics/filters.test.ts +0 -116
  70. package/__test__/analytics/format.test.ts +0 -137
  71. package/__test__/authenticatedFetch.test.ts +0 -182
  72. package/__test__/brokenLinks.test.ts +0 -283
  73. package/__test__/checkPort.test.ts +0 -92
  74. package/__test__/deploy-github-actions.test.ts +0 -202
  75. package/__test__/deploy-github-setup.test.ts +0 -240
  76. package/__test__/deploy-instructions.test.ts +0 -155
  77. package/__test__/deploy.test.ts +0 -202
  78. package/__test__/feedback.test.ts +0 -34
  79. package/__test__/foreignSyntax.test.ts +0 -73
  80. package/__test__/format.test.ts +0 -72
  81. package/__test__/helpers.test.ts +0 -52
  82. package/__test__/init.test.ts +0 -119
  83. package/__test__/instructions.test.ts +0 -53
  84. package/__test__/keyring.test.ts +0 -82
  85. package/__test__/mdxAccessibility.test.ts +0 -81
  86. package/__test__/migrate.test.ts +0 -186
  87. package/__test__/openApiCheck.test.ts +0 -185
  88. package/__test__/pathValidation.test.ts +0 -25
  89. package/__test__/resolveFiles.test.ts +0 -70
  90. package/__test__/sessionId.test.ts +0 -46
  91. package/__test__/signup.test.ts +0 -36
  92. package/__test__/update.test.ts +0 -117
  93. package/__test__/utils.ts +0 -25
  94. package/__test__/validateCommand.test.ts +0 -647
  95. package/__test__/validateEngine.test.ts +0 -245
  96. package/__test__/validateRules.test.ts +0 -1275
  97. package/__test__/welcome.test.ts +0 -15
  98. package/__test__/workflows/client.test.ts +0 -126
  99. package/bin/accessibility.js +0 -111
  100. package/bin/accessibilityCheck.js +0 -82
  101. package/bin/addDomain.js +0 -130
  102. package/bin/agent-auth.js +0 -104
  103. package/bin/agent-claim.js +0 -97
  104. package/bin/agent-credentials.js +0 -124
  105. package/bin/agent-deployment.js +0 -96
  106. package/bin/agent-http.js +0 -45
  107. package/bin/agent-setup-config.js +0 -141
  108. package/bin/agent-setup.js +0 -146
  109. package/bin/agent.js +0 -42
  110. package/bin/analytics/client.js +0 -60
  111. package/bin/analytics/dates.js +0 -6
  112. package/bin/analytics/filters.js +0 -27
  113. package/bin/analytics/format.js +0 -13
  114. package/bin/analytics/index.js +0 -496
  115. package/bin/analytics/output.js +0 -75
  116. package/bin/analytics/types.js +0 -1
  117. package/bin/authenticatedFetch.js +0 -46
  118. package/bin/brokenLinks.js +0 -122
  119. package/bin/callbackServer.js +0 -65
  120. package/bin/cli.js +0 -813
  121. package/bin/comingSoon.js +0 -26
  122. package/bin/config.js +0 -78
  123. package/bin/constants.js +0 -16
  124. package/bin/deploy-base.js +0 -20
  125. package/bin/deploy-github-actions.js +0 -102
  126. package/bin/deploy-github-setup.js +0 -165
  127. package/bin/deploy-instructions.js +0 -71
  128. package/bin/deploy.js +0 -123
  129. package/bin/feedback.js +0 -36
  130. package/bin/format.js +0 -121
  131. package/bin/helpers.js +0 -238
  132. package/bin/idToken.js +0 -14
  133. package/bin/index.js +0 -102
  134. package/bin/init.js +0 -182
  135. package/bin/instructions.js +0 -101
  136. package/bin/keyring.js +0 -78
  137. package/bin/login.js +0 -123
  138. package/bin/logout.js +0 -18
  139. package/bin/mdxAccessibility.js +0 -113
  140. package/bin/mdxLinter.js +0 -55
  141. package/bin/middlewares/subdomainMiddleware.js +0 -28
  142. package/bin/middlewares/telemetryMiddleware.js +0 -61
  143. package/bin/migrate.js +0 -54
  144. package/bin/og.js +0 -145
  145. package/bin/openApiCheck.js +0 -99
  146. package/bin/resolveFiles.js +0 -114
  147. package/bin/score/client.js +0 -40
  148. package/bin/score/index.js +0 -211
  149. package/bin/score/types.js +0 -1
  150. package/bin/signup.js +0 -118
  151. package/bin/start.js +0 -36
  152. package/bin/status.js +0 -106
  153. package/bin/telemetry/client.js +0 -53
  154. package/bin/telemetry/distinctId.js +0 -68
  155. package/bin/telemetry/sessionId.js +0 -36
  156. package/bin/telemetry/track.js +0 -149
  157. package/bin/templates.js +0 -127
  158. package/bin/tokenRefresh.js +0 -50
  159. package/bin/tsconfig.build.tsbuildinfo +0 -1
  160. package/bin/update.js +0 -65
  161. package/bin/validate/command.js +0 -127
  162. package/bin/validate/engine.js +0 -154
  163. package/bin/validate/files.js +0 -163
  164. package/bin/validate/mdx.js +0 -238
  165. package/bin/validate/output.js +0 -44
  166. package/bin/validate/report.js +0 -11
  167. package/bin/validate/rules/build.js +0 -102
  168. package/bin/validate/rules/content/duplicateH1.js +0 -57
  169. package/bin/validate/rules/content/foreignSyntax.js +0 -120
  170. package/bin/validate/rules/content/katex.js +0 -34
  171. package/bin/validate/rules/content/missingSnippet.js +0 -34
  172. package/bin/validate/rules/content/undefinedVariable.js +0 -13
  173. package/bin/validate/rules/content/unknownComponent.js +0 -121
  174. package/bin/validate/rules/content/voidTags.js +0 -38
  175. package/bin/validate/rules/index.js +0 -21
  176. package/bin/validate/rules/openapi.js +0 -50
  177. package/bin/validate/rules/parseError.js +0 -7
  178. package/bin/validate/site.js +0 -57
  179. package/bin/validate/types.js +0 -1
  180. package/bin/vendor/converter.js +0 -30882
  181. package/bin/welcome.js +0 -108
  182. package/bin/workflows/client.js +0 -34
  183. package/bin/workflows/index.js +0 -269
  184. package/bin/workflows/types.js +0 -11
  185. package/scripts/bundle-converter.mjs +0 -26
  186. package/scripts/generate-logo.mjs +0 -79
  187. package/src/accessibility.ts +0 -180
  188. package/src/accessibilityCheck.tsx +0 -150
  189. package/src/addDomain.tsx +0 -206
  190. package/src/agent-auth.ts +0 -119
  191. package/src/agent-claim.ts +0 -124
  192. package/src/agent-credentials.ts +0 -104
  193. package/src/agent-deployment.ts +0 -116
  194. package/src/agent-http.ts +0 -34
  195. package/src/agent-setup-config.ts +0 -144
  196. package/src/agent-setup.ts +0 -165
  197. package/src/agent.ts +0 -56
  198. package/src/analytics/client.ts +0 -153
  199. package/src/analytics/dates.ts +0 -6
  200. package/src/analytics/filters.ts +0 -50
  201. package/src/analytics/format.ts +0 -13
  202. package/src/analytics/index.tsx +0 -599
  203. package/src/analytics/output.ts +0 -99
  204. package/src/analytics/types.ts +0 -145
  205. package/src/authenticatedFetch.ts +0 -42
  206. package/src/brokenLinks.tsx +0 -152
  207. package/src/callbackServer.ts +0 -64
  208. package/src/cli.tsx +0 -1105
  209. package/src/comingSoon.tsx +0 -29
  210. package/src/config.ts +0 -75
  211. package/src/constants.ts +0 -28
  212. package/src/deploy-base.ts +0 -18
  213. package/src/deploy-github-actions.ts +0 -139
  214. package/src/deploy-github-setup.ts +0 -189
  215. package/src/deploy-instructions.ts +0 -76
  216. package/src/deploy.ts +0 -165
  217. package/src/feedback.tsx +0 -31
  218. package/src/format.tsx +0 -82
  219. package/src/helpers.tsx +0 -279
  220. package/src/idToken.ts +0 -17
  221. package/src/index.ts +0 -109
  222. package/src/init.tsx +0 -237
  223. package/src/instructions.ts +0 -99
  224. package/src/keyring.ts +0 -65
  225. package/src/login.tsx +0 -166
  226. package/src/logout.tsx +0 -8
  227. package/src/mdxAccessibility.ts +0 -134
  228. package/src/mdxLinter.tsx +0 -88
  229. package/src/middlewares/subdomainMiddleware.ts +0 -20
  230. package/src/middlewares/telemetryMiddleware.ts +0 -55
  231. package/src/migrate.ts +0 -76
  232. package/src/og.tsx +0 -185
  233. package/src/openApiCheck.tsx +0 -125
  234. package/src/resolveFiles.ts +0 -101
  235. package/src/score/client.ts +0 -36
  236. package/src/score/index.tsx +0 -205
  237. package/src/score/types.ts +0 -15
  238. package/src/signup.tsx +0 -172
  239. package/src/start.ts +0 -27
  240. package/src/status.tsx +0 -129
  241. package/src/telemetry/client.ts +0 -46
  242. package/src/telemetry/distinctId.ts +0 -70
  243. package/src/telemetry/sessionId.ts +0 -40
  244. package/src/telemetry/track.ts +0 -163
  245. package/src/templates.tsx +0 -143
  246. package/src/tokenRefresh.ts +0 -53
  247. package/src/update.tsx +0 -89
  248. package/src/validate/command.tsx +0 -135
  249. package/src/validate/engine.ts +0 -210
  250. package/src/validate/files.ts +0 -249
  251. package/src/validate/mdx.ts +0 -290
  252. package/src/validate/output.tsx +0 -76
  253. package/src/validate/report.ts +0 -40
  254. package/src/validate/rules/build.ts +0 -146
  255. package/src/validate/rules/content/duplicateH1.ts +0 -78
  256. package/src/validate/rules/content/foreignSyntax.ts +0 -144
  257. package/src/validate/rules/content/katex.ts +0 -33
  258. package/src/validate/rules/content/missingSnippet.ts +0 -36
  259. package/src/validate/rules/content/undefinedVariable.ts +0 -20
  260. package/src/validate/rules/content/unknownComponent.ts +0 -130
  261. package/src/validate/rules/content/voidTags.ts +0 -43
  262. package/src/validate/rules/index.ts +0 -23
  263. package/src/validate/rules/openapi.ts +0 -59
  264. package/src/validate/rules/parseError.ts +0 -9
  265. package/src/validate/site.ts +0 -53
  266. package/src/validate/types.ts +0 -102
  267. package/src/vendor/converter.ts +0 -1
  268. package/src/welcome.ts +0 -154
  269. package/src/workflows/client.ts +0 -39
  270. package/src/workflows/index.tsx +0 -287
  271. package/src/workflows/types.ts +0 -73
  272. package/tsconfig.build.json +0 -4
  273. package/tsconfig.json +0 -10
  274. package/vitest.config.ts +0 -9
@@ -1,101 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
-
4
- const GLOB_CHARS = /[*?]/;
5
- const DOCS_FILE = /\.mdx?$/i;
6
- const REGEX_SPECIAL = /[.+^${}()|\\[\]]/;
7
- const SKIPPED_DIRS = new Set(['.git', 'node_modules']);
8
-
9
- function toPosix(filePath: string): string {
10
- return filePath.split(path.sep).join('/');
11
- }
12
-
13
- function normalizeArg(arg: string): string {
14
- return toPosix(arg).replace(/^\.\//, '');
15
- }
16
-
17
- function globToRegExp(pattern: string): RegExp {
18
- let source = '';
19
- let i = 0;
20
- while (i < pattern.length) {
21
- const char = pattern[i]!;
22
- if (char === '*') {
23
- if (pattern[i + 1] === '*') {
24
- if (pattern[i + 2] === '/') {
25
- source += '(?:[^/]+/)*';
26
- i += 3;
27
- } else {
28
- source += '.*';
29
- i += 2;
30
- }
31
- } else {
32
- source += '[^/]*';
33
- i += 1;
34
- }
35
- } else if (char === '?') {
36
- source += '[^/]';
37
- i += 1;
38
- } else {
39
- source += REGEX_SPECIAL.test(char) ? `\\${char}` : char;
40
- i += 1;
41
- }
42
- }
43
- return new RegExp(`^${source}$`);
44
- }
45
-
46
- async function isFile(filePath: string): Promise<boolean> {
47
- try {
48
- return (await fs.stat(filePath)).isFile();
49
- } catch {
50
- return false;
51
- }
52
- }
53
-
54
- async function walk(baseDir: string, dir = ''): Promise<string[]> {
55
- const entries = await fs.readdir(path.join(baseDir, dir), { withFileTypes: true });
56
- const files: string[] = [];
57
- for (const entry of entries) {
58
- if (SKIPPED_DIRS.has(entry.name)) continue;
59
- const rel = dir ? `${dir}/${entry.name}` : entry.name;
60
- if (entry.isDirectory()) {
61
- files.push(...(await walk(baseDir, rel)));
62
- } else {
63
- files.push(rel);
64
- }
65
- }
66
- return files;
67
- }
68
-
69
- export class NoMatchingFilesError extends Error {}
70
-
71
- export async function resolveExplicitFiles(baseDir: string, args: string[]): Promise<string[]> {
72
- let allFiles: string[] | null = null;
73
- const matched: string[] = [];
74
- const unmatched: string[] = [];
75
-
76
- for (const arg of args) {
77
- const pattern = normalizeArg(arg);
78
- if (GLOB_CHARS.test(pattern)) {
79
- allFiles = allFiles ?? (await walk(baseDir));
80
- const regex = globToRegExp(pattern);
81
- const hits = allFiles.filter((file) => DOCS_FILE.test(file) && regex.test(file)).sort();
82
- if (hits.length === 0) {
83
- unmatched.push(arg);
84
- } else {
85
- matched.push(...hits);
86
- }
87
- } else if (await isFile(path.join(baseDir, pattern))) {
88
- matched.push(pattern);
89
- } else {
90
- unmatched.push(arg);
91
- }
92
- }
93
-
94
- if (unmatched.length > 0) {
95
- throw new NoMatchingFilesError(
96
- `No matching files for: ${unmatched.join(', ')} (globs match .md and .mdx files)`
97
- );
98
- }
99
-
100
- return [...new Set(matched)];
101
- }
@@ -1,36 +0,0 @@
1
- import { authenticatedFetch } from '../authenticatedFetch.js';
2
- import { API_URL } from '../constants.js';
3
- import type { ResolveResult, ScoreResponse } from './types.js';
4
-
5
- export async function resolveScoreForUrl(url: string): Promise<ResolveResult> {
6
- const endpoint = new URL(`${API_URL}/api/cli/score`);
7
- endpoint.searchParams.set('url', url);
8
-
9
- const res = await authenticatedFetch(endpoint.toString(), {
10
- headers: { Accept: 'application/json' },
11
- });
12
-
13
- if (res.status !== 200 && res.status !== 202) {
14
- const body = await res.text().catch(() => '');
15
- throw new Error(`API error (${res.status}): ${body || res.statusText}`);
16
- }
17
-
18
- return res.json() as Promise<ResolveResult>;
19
- }
20
-
21
- export async function fetchScoreBySlug(slug: string): Promise<ScoreResponse | null> {
22
- const endpoint = new URL(`${API_URL}/api/cli/score/${encodeURIComponent(slug)}`);
23
-
24
- const res = await authenticatedFetch(endpoint.toString(), {
25
- headers: { Accept: 'application/json' },
26
- });
27
-
28
- if (res.status === 202) return null;
29
-
30
- if (!res.ok) {
31
- const body = await res.text().catch(() => '');
32
- throw new Error(`API error (${res.status}): ${body || res.statusText}`);
33
- }
34
-
35
- return res.json() as Promise<ScoreResponse>;
36
- }
@@ -1,205 +0,0 @@
1
- import { addLog, ErrorLog, SpinnerLog, removeLastLog } from '@mintlify/previewing';
2
- import chalk from 'chalk';
3
- import { Text } from 'ink';
4
-
5
- import { getConfigValue } from '../config.js';
6
- import { terminate } from '../helpers.js';
7
- import { getAccessToken } from '../keyring.js';
8
- import { getCliSubdomains } from '../status.js';
9
- import { trackEvent } from '../telemetry/track.js';
10
- import { fetchScoreBySlug, resolveScoreForUrl } from './client.js';
11
- import type { Check, CliCheckStatus, ScoreResponse } from './types.js';
12
-
13
- type OutputFormat = 'table' | 'plain' | 'json';
14
-
15
- const POLL_INTERVAL_MS = 3_000;
16
- const POLL_TIMEOUT_MS = 120_000;
17
-
18
- function resolveFormat(argv: { format?: string }): OutputFormat {
19
- if (argv.format === 'table' || argv.format === 'plain' || argv.format === 'json')
20
- return argv.format;
21
- return 'table';
22
- }
23
-
24
- function statusIcon(status: CliCheckStatus): string {
25
- switch (status) {
26
- case 'pass':
27
- return chalk.green('✓');
28
- case 'warn':
29
- return chalk.yellow('⚠');
30
- case 'skip':
31
- return chalk.dim('○');
32
- case 'fail':
33
- case 'error':
34
- return chalk.red('✗');
35
- default: {
36
- const _exhaustive: never = status;
37
- void _exhaustive;
38
- return chalk.dim('?');
39
- }
40
- }
41
- }
42
-
43
- function plainStatusLabel(status: CliCheckStatus): string {
44
- return status.toUpperCase();
45
- }
46
-
47
- function formatCheckName(name: string): string {
48
- return name
49
- .replace(/[-_]+/g, ' ')
50
- .replace(/([a-z])([A-Z])/g, '$1 $2')
51
- .replace(/^./, (c) => c.toUpperCase())
52
- .trim();
53
- }
54
-
55
- function renderChecks(checks: Check[], indent = 0): string[] {
56
- const lines: string[] = [];
57
- const pad = ' '.repeat(indent + 1);
58
- for (const check of checks) {
59
- lines.push(`${pad}${statusIcon(check.status)} ${formatCheckName(check.name)}`);
60
- if (check.children && check.children.length > 0) {
61
- lines.push(...renderChecks(check.children, indent + 1));
62
- }
63
- }
64
- return lines;
65
- }
66
-
67
- function renderPlain(checks: Check[], prefix = ''): string[] {
68
- const lines: string[] = [];
69
- for (const check of checks) {
70
- lines.push(`${prefix}${plainStatusLabel(check.status)}\t${check.name}`);
71
- if (check.children && check.children.length > 0) {
72
- lines.push(...renderPlain(check.children, prefix + ' '));
73
- }
74
- }
75
- return lines;
76
- }
77
-
78
- function renderTable(score: ScoreResponse, opts?: { stale?: boolean }): string {
79
- const scoreColor =
80
- score.overallScore >= 70 ? 'green' : score.overallScore >= 40 ? 'yellow' : 'red';
81
- const header = opts?.stale
82
- ? chalk.bold(`\nAgent Readiness Score — ${score.canonicalUrl}`) +
83
- chalk.dim(` (last run ${new Date(score.computedAt).toLocaleString()})\n`)
84
- : chalk.bold(`\nAgent Readiness Score — ${score.canonicalUrl}\n`);
85
-
86
- const lines: string[] = [header];
87
- lines.push(` Score: ${chalk[scoreColor].bold(`${score.overallScore}%`)}\n`);
88
- lines.push(chalk.bold(' Checks'));
89
- lines.push(...renderChecks(score.checks));
90
- return lines.join('\n');
91
- }
92
-
93
- function output(format: OutputFormat, text: string) {
94
- if (format === 'table') {
95
- addLog(<Text>{text}</Text>);
96
- } else {
97
- process.stdout.write(text + '\n');
98
- }
99
- }
100
-
101
- async function sleep(ms: number): Promise<void> {
102
- return new Promise((resolve) => setTimeout(resolve, ms));
103
- }
104
-
105
- async function pollForScore(
106
- slug: string,
107
- afterIso: string | null,
108
- onAttempt?: () => void
109
- ): Promise<ScoreResponse> {
110
- const deadline = Date.now() + POLL_TIMEOUT_MS;
111
- while (Date.now() < deadline) {
112
- await sleep(POLL_INTERVAL_MS);
113
- onAttempt?.();
114
- const score = await fetchScoreBySlug(slug);
115
- if (!score) continue;
116
- if (afterIso === null) return score;
117
- if (new Date(score.computedAt).getTime() > new Date(afterIso).getTime()) return score;
118
- }
119
- throw new Error(`Score did not complete within ${POLL_TIMEOUT_MS / 1000}s`);
120
- }
121
-
122
- async function resolveDefaultSubdomain(): Promise<string | undefined> {
123
- const fromConfig = getConfigValue('subdomain');
124
- if (fromConfig) return fromConfig;
125
- const accessToken = await getAccessToken();
126
- if (!accessToken) return undefined;
127
- const subdomains = await getCliSubdomains(accessToken);
128
- return subdomains[0];
129
- }
130
-
131
- export const scoreHandler = async (argv: { url?: string; format?: string }) => {
132
- const format = resolveFormat(argv);
133
- try {
134
- let url = argv.url;
135
- if (!url) {
136
- const subdomain = await resolveDefaultSubdomain();
137
- if (!subdomain) {
138
- throw new Error(
139
- 'No URL provided and no default subdomain set. Run `mint login` to set one, or pass a URL: `mint score <url>`.'
140
- );
141
- }
142
- url = `${subdomain}.mintlify.site`;
143
- }
144
- if (format === 'table') addLog(<SpinnerLog message="Checking agent readiness..." />);
145
- const resolved = await resolveScoreForUrl(url);
146
-
147
- let final: ScoreResponse;
148
-
149
- if (resolved.status === 'ready') {
150
- const score = await fetchScoreBySlug(resolved.slug);
151
- if (format === 'table') removeLastLog();
152
- if (!score) throw new Error('Score was unexpectedly unavailable');
153
- final = score;
154
- } else if (resolved.status === 'stale_refresh_queued') {
155
- const stale = await fetchScoreBySlug(resolved.slug);
156
- if (format === 'table') removeLastLog();
157
- if (!stale) throw new Error('Stale score was unexpectedly unavailable');
158
-
159
- if (format === 'table') {
160
- output('table', renderTable(stale, { stale: true }));
161
- addLog(<SpinnerLog message="Refreshing score in the background..." />);
162
- } else {
163
- process.stderr.write('Refreshing score in the background...\n');
164
- }
165
- final = await pollForScore(resolved.slug, stale.computedAt);
166
- if (format === 'table') removeLastLog();
167
- } else {
168
- if (format === 'table') {
169
- removeLastLog();
170
- addLog(<SpinnerLog message="Queued a new scoring run. Waiting for first result..." />);
171
- } else {
172
- process.stderr.write('Queued a new scoring run. Waiting for first result...\n');
173
- }
174
- final = await pollForScore(resolved.slug, null);
175
- if (format === 'table') removeLastLog();
176
- }
177
-
178
- void trackEvent('cli.score.executed', {
179
- url,
180
- score: final.overallScore,
181
- format,
182
- status: resolved.status,
183
- });
184
-
185
- if (format === 'json') {
186
- output(format, JSON.stringify(final, null, 2));
187
- } else if (format === 'plain') {
188
- const lines = [`SCORE\t${final.overallScore}`, ...renderPlain(final.checks)];
189
- output(format, lines.join('\n'));
190
- } else {
191
- output(format, renderTable(final));
192
- }
193
-
194
- await terminate(0);
195
- } catch (err) {
196
- const message = err instanceof Error ? err.message : 'unknown error';
197
- if (format === 'table') {
198
- removeLastLog();
199
- addLog(<ErrorLog message={message} />);
200
- } else {
201
- process.stderr.write(`Error: ${message}\n`);
202
- }
203
- await terminate(1);
204
- }
205
- };
@@ -1,15 +0,0 @@
1
- // These types are defined in `@mintlify/models/src/types/cliScoreResponse.ts`.
2
- // The server (mintlify/server) is the source of truth for this contract — it
3
- // implements the response shape in `agentReadinessScore.controller.ts` →
4
- // `getCliSiteScore`. Do not redefine the shape locally; update the shared
5
- // package (and bump the dependency in both repos) if you need to change it.
6
- export type {
7
- CliCheckStatus,
8
- CliGrade,
9
- CliScoreCheck as Check,
10
- CliScorePendingResponse,
11
- CliScoreResolveResponse as ResolveResult,
12
- CliScoreResolveStatus as ResolveStatus,
13
- CliScoreResponse as ScoreResponse,
14
- CliScoreResponseStatus,
15
- } from '@mintlify/models';
package/src/signup.tsx DELETED
@@ -1,172 +0,0 @@
1
- import { input } from '@inquirer/prompts';
2
- import { addLog, addLogs, ErrorLog, SuccessLog } from '@mintlify/previewing';
3
- import { Box, Text } from 'ink';
4
- import {
5
- calculatePKCECodeChallenge,
6
- randomNonce,
7
- randomPKCECodeVerifier,
8
- randomState,
9
- } from 'openid-client';
10
-
11
- import { isCI } from './agent.js';
12
- import { startCallbackServer } from './callbackServer.js';
13
- import { clearConfigValue, hasShownPublishPrompt, markPublishPromptShown } from './config.js';
14
- import { API_URL, TOKEN_ENDPOINT } from './constants.js';
15
- import { CMD_EXEC_PATH, isAI } from './helpers.js';
16
- import { getEmailFromIdToken } from './idToken.js';
17
- import { getAccessToken, storeCredentials } from './keyring.js';
18
- import type { TokenResponse } from './login.js';
19
-
20
- export interface SignupOptions {
21
- firstName?: string;
22
- lastName?: string;
23
- company?: string;
24
- email?: string;
25
- }
26
-
27
- export const AUTH_MD_URL = 'https://mintlify.com/auth.md';
28
-
29
- const sendAIUsageMessage = () => {
30
- addLogs(
31
- <Text>Agent Detected - sending AI friendly prompt</Text>,
32
- <Text>{'<mint-cli-instructions>'}</Text>,
33
- <Text>
34
- Could not fetch the agent signup guide. Read {AUTH_MD_URL} directly, or create a site without
35
- an account by running `mint deploy --subdomain [subdomain]` from the documentation directory
36
- and following the instructions it prints.
37
- </Text>,
38
- <Text>
39
- To hand the site to the user, ask for their email (never invent one) and run `mint claim
40
- --email [email]`.
41
- </Text>,
42
- <Text>{'</mint-cli-instructions>'}</Text>
43
- );
44
- };
45
-
46
- export const sendPublishPrompt = async () => {
47
- if (
48
- !isAI() ||
49
- isCI() ||
50
- process.env.MINTLIFY_SESSION_TOKEN ||
51
- (await getAccessToken().catch(() => undefined))
52
- ) {
53
- return;
54
- }
55
- if (hasShownPublishPrompt(CMD_EXEC_PATH)) {
56
- addLog(<Text>Not published yet. Run `mint signup` or `mint login` to publish.</Text>);
57
- return;
58
- }
59
- addLogs(
60
- <Text>{'<mint-cli-instructions>'}</Text>,
61
- <Text>Ready to publish? The Starter plan is free, no credit card needed.</Text>,
62
- <Text>
63
- Offer to create the user's Mintlify account: run `mint signup` and follow the instructions it
64
- prints.
65
- </Text>,
66
- <Text>Have an account: `mint login`.</Text>,
67
- <Text>
68
- Your site will then be live at https://[subdomain].mintlify.site (`mint status` shows the
69
- exact URL).
70
- </Text>,
71
- <Text>{'</mint-cli-instructions>'}</Text>
72
- );
73
- await markPublishPromptShown(CMD_EXEC_PATH).catch(() => undefined);
74
- };
75
-
76
- // Agents sign up through auth.md, so give them that guide instead of the email flow.
77
- const sendAuthMd = async () => {
78
- try {
79
- const res = await fetch(AUTH_MD_URL, { signal: AbortSignal.timeout(30_000) });
80
- if (!res.ok) throw new Error(`auth.md returned ${res.status}`);
81
- process.stdout.write(`${await res.text()}\n`);
82
- } catch {
83
- sendAIUsageMessage();
84
- }
85
- };
86
-
87
- export async function signup(options: SignupOptions = {}): Promise<void> {
88
- if (isAI()) {
89
- await sendAuthMd();
90
- return;
91
- }
92
-
93
- const firstName = options.firstName ?? (await input({ message: 'First name' }));
94
- const lastName = options.lastName ?? (await input({ message: 'Last name' }));
95
- const company = options.company ?? (await input({ message: 'Company name' }));
96
- const email = options.email ?? (await input({ message: 'Email' }));
97
-
98
- const codeVerifier = randomPKCECodeVerifier();
99
- const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
100
- const nonce = randomNonce();
101
- const clientState = randomState();
102
- const state = Buffer.from(JSON.stringify({ nonce, clientState })).toString('base64url');
103
-
104
- const { codePromise, close: closeServer } = await startCallbackServer();
105
- codePromise.catch(() => {});
106
-
107
- try {
108
- const res = await fetch(`${API_URL}/api/cli-onboarding/signup`, {
109
- method: 'POST',
110
- headers: { 'Content-Type': 'application/json' },
111
- body: JSON.stringify({ firstName, lastName, company, email, state, codeChallenge }),
112
- });
113
-
114
- if (!res.ok) {
115
- const body = await res.json().catch(() => ({}));
116
- closeServer();
117
- addLog(<ErrorLog message={`signup failed: ${body.error ?? 'unknown error'}`} />);
118
- return;
119
- }
120
- } catch {
121
- closeServer();
122
- addLog(<ErrorLog message="signup failed: could not reach the server" />);
123
- return;
124
- }
125
-
126
- addLog(
127
- <Box flexDirection="column" gap={1} paddingY={1}>
128
- <Text bold>
129
- <Text color="green">◆ </Text>Check your email to verify your account
130
- </Text>
131
- <Box flexDirection="column" paddingLeft={3} gap={1}>
132
- <Text dimColor>We sent a verification link to {email}. Click it to continue.</Text>
133
- </Box>
134
- </Box>
135
- );
136
-
137
- let code: string;
138
- try {
139
- code = await codePromise;
140
- } catch {
141
- addLog(<ErrorLog message="signup cancelled" />);
142
- return;
143
- }
144
-
145
- const res = await fetch(TOKEN_ENDPOINT, {
146
- method: 'POST',
147
- headers: { 'Content-Type': 'application/json' },
148
- body: JSON.stringify({
149
- grant_type: 'authorization_code',
150
- code,
151
- code_verifier: codeVerifier,
152
- }),
153
- });
154
-
155
- const body = await res.json().catch(() => ({}));
156
-
157
- if (!res.ok) {
158
- const reason = body.error_message ?? body.error ?? 'unknown error';
159
- addLog(<ErrorLog message={`signup failed: ${reason}`} />);
160
- return;
161
- }
162
-
163
- const token = body as TokenResponse;
164
- await storeCredentials(
165
- token.access_token,
166
- token.refresh_token,
167
- getEmailFromIdToken(token.id_token) ?? email
168
- );
169
- await clearConfigValue('subdomain').catch(() => undefined);
170
- addLog(<SuccessLog message="account created and logged in successfully" />);
171
- addLog(<Text>Continue in the browser tab where you verified your email to connect GitHub.</Text>);
172
- }
package/src/start.ts DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import { cli } from './cli.js';
3
- import { shutdownPostHog } from './telemetry/client.js';
4
-
5
- const packageName = process.env.MINTLIFY_PACKAGE_NAME ?? 'mint';
6
-
7
- cli({ packageName }).catch((err: unknown) => {
8
- console.error(err instanceof Error ? err.message : err);
9
- process.exit(1);
10
- });
11
-
12
- async function shutdown(exitCode: number): Promise<never> {
13
- await shutdownPostHog();
14
- process.exit(exitCode);
15
- }
16
-
17
- process.once('beforeExit', async () => {
18
- try {
19
- await shutdownPostHog();
20
- } catch {}
21
- });
22
- process.on('SIGINT', () => {
23
- void shutdown(130);
24
- });
25
- process.on('SIGTERM', () => {
26
- void shutdown(143);
27
- });
package/src/status.tsx DELETED
@@ -1,129 +0,0 @@
1
- import { addLog, ErrorLog } from '@mintlify/previewing';
2
- import { Box, Text } from 'ink';
3
- import { z } from 'zod';
4
-
5
- import { authenticatedFetch } from './authenticatedFetch.js';
6
- import { getConfigValue, setConfigValue } from './config.js';
7
- import { API_URL } from './constants.js';
8
- import { getCliVersion } from './helpers.js';
9
- import { getAccessToken } from './keyring.js';
10
-
11
- const StatusResponseSchema = z.object({
12
- user: z.object({ email: z.string() }),
13
- org: z.object({ name: z.string() }),
14
- subdomains: z.array(z.string()).default([]),
15
- });
16
-
17
- export async function getCliStatus(
18
- accessToken: string
19
- ): Promise<z.infer<typeof StatusResponseSchema> | null> {
20
- try {
21
- const res = await fetch(`${API_URL}/api/cli/status`, {
22
- headers: { Authorization: `Bearer ${accessToken}` },
23
- });
24
- if (!res.ok) return null;
25
- const json = await res.json().catch(() => null);
26
- const parsed = StatusResponseSchema.safeParse(json);
27
- return parsed.success ? parsed.data : null;
28
- } catch {
29
- return null;
30
- }
31
- }
32
-
33
- export type CliStatusResult =
34
- | { ok: true; status: z.infer<typeof StatusResponseSchema> }
35
- | { ok: false; reason: 'unauthenticated' | 'unreachable' | 'invalid'; detail?: string };
36
-
37
- /**
38
- * Like getCliStatus, but refreshes an expired session and says why it failed, so commands can
39
- * tell "log in again" apart from "the server is down" and from "not allowed".
40
- */
41
- export async function fetchCliStatus(signal?: AbortSignal): Promise<CliStatusResult> {
42
- let res: Response;
43
- try {
44
- res = await authenticatedFetch(`${API_URL}/api/cli/status`, { signal });
45
- } catch (error) {
46
- const detail = error instanceof Error ? error.message : String(error);
47
- if (/not authenticated/i.test(detail)) return { ok: false, reason: 'unauthenticated' };
48
- return { ok: false, reason: 'unreachable', detail };
49
- }
50
- if (res.status === 401 || res.status === 403) return { ok: false, reason: 'unauthenticated' };
51
- if (!res.ok) return { ok: false, reason: 'unreachable', detail: `HTTP ${res.status}` };
52
- const parsed = StatusResponseSchema.safeParse(await res.json().catch(() => null));
53
- if (!parsed.success) return { ok: false, reason: 'invalid' };
54
- return { ok: true, status: parsed.data };
55
- }
56
-
57
- export async function getCliSubdomains(accessToken: string): Promise<string[]> {
58
- const status = await getCliStatus(accessToken);
59
- return status?.subdomains ?? [];
60
- }
61
-
62
- export async function status(): Promise<void> {
63
- const accessToken =
64
- (await getAccessToken().catch(() => null)) ?? process.env.MINTLIFY_SESSION_TOKEN;
65
-
66
- if (!accessToken) {
67
- addLog(<ErrorLog message="not logged in. Run `mint login` to authenticate." />);
68
- return;
69
- }
70
-
71
- try {
72
- const res = await authenticatedFetch(`${API_URL}/api/cli/status`);
73
-
74
- if (!res.ok) {
75
- addLog(<ErrorLog message="not logged in. Run `mint login` to authenticate." />);
76
- return;
77
- }
78
-
79
- const json = await res.json().catch(() => null);
80
- const parsed = StatusResponseSchema.safeParse(json);
81
-
82
- if (!parsed.success) {
83
- addLog(<ErrorLog message="unexpected response from server. please try again." />);
84
- return;
85
- }
86
-
87
- const { user, org, subdomains } = parsed.data;
88
- const version = getCliVersion();
89
-
90
- const cached = getConfigValue('subdomain');
91
- const subdomain = (cached && subdomains.includes(cached) ? cached : subdomains[0]) ?? null;
92
- if (subdomain && subdomain !== cached)
93
- await setConfigValue('subdomain', subdomain).catch(() => undefined);
94
- addLog(
95
- <Box flexDirection="column" paddingY={1}>
96
- {version && (
97
- <Box>
98
- <Box minWidth={16}>
99
- <Text dimColor>Version</Text>
100
- </Box>
101
- <Text>{version}</Text>
102
- </Box>
103
- )}
104
- <Box>
105
- <Box minWidth={16}>
106
- <Text dimColor>Email</Text>
107
- </Box>
108
- <Text>{user.email}</Text>
109
- </Box>
110
- <Box>
111
- <Box minWidth={16}>
112
- <Text dimColor>Organization</Text>
113
- </Box>
114
- <Text>{org.name}</Text>
115
- </Box>
116
- {subdomain && (
117
- <Box>
118
- <Box minWidth={16}>
119
- <Text dimColor>Subdomain</Text>
120
- </Box>
121
- <Text>{subdomain}</Text>
122
- </Box>
123
- )}
124
- </Box>
125
- );
126
- } catch (e) {
127
- addLog(<ErrorLog message="unexpected response from server. please try again." />);
128
- }
129
- }