@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,27 +0,0 @@
1
- export function filterSearchResponse(data, filters) {
2
- let searches = data.searches;
3
- if (filters.query) {
4
- const query = filters.query.toLowerCase();
5
- searches = searches.filter((row) => row.searchQuery.toLowerCase().includes(query));
6
- }
7
- const page = filters.page;
8
- if (page) {
9
- searches = searches.filter((row) => { var _a; return (_a = row.topClickedPage) === null || _a === void 0 ? void 0 : _a.includes(page); });
10
- }
11
- return Object.assign(Object.assign({}, data), { searches });
12
- }
13
- export function filterFeedbackByPageResponse(data, page) {
14
- if (!page)
15
- return data;
16
- return Object.assign(Object.assign({}, data), { feedback: data.feedback.filter((row) => row.path.includes(page)) });
17
- }
18
- export function filterFeedbackResponse(data, page) {
19
- if (!page)
20
- return data;
21
- return Object.assign(Object.assign({}, data), { feedback: data.feedback.filter((row) => row.path.includes(page)) });
22
- }
23
- export function filterConversationResponse(data, page) {
24
- if (!page)
25
- return data;
26
- return Object.assign(Object.assign({}, data), { conversations: data.conversations.filter((conversation) => conversation.sources.some((source) => source.url.includes(page))) });
27
- }
@@ -1,13 +0,0 @@
1
- export function num(n) {
2
- return n.toLocaleString('en-US');
3
- }
4
- export function pct(n, total) {
5
- if (total === 0)
6
- return '\u2014';
7
- return ((n / total) * 100).toFixed(1) + '%';
8
- }
9
- export function truncate(s, max) {
10
- if (s.length <= max)
11
- return s;
12
- return s.slice(0, max - 1) + '\u2026';
13
- }
@@ -1,496 +0,0 @@
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 { getConfigValue } from '../config.js';
15
- import { terminate } from '../helpers.js';
16
- import { subdomainMiddleware } from '../middlewares/subdomainMiddleware.js';
17
- import { getAssistantThread, getBucketThreads, getBuckets, getConversations, getFeedback, getFeedbackByPage, getKpi, getSearches, } from './client.js';
18
- import { formatLocalDate } from './dates.js';
19
- import { filterConversationResponse, filterFeedbackByPageResponse, filterFeedbackResponse, filterSearchResponse, } from './filters.js';
20
- import { num, truncate } from './format.js';
21
- import { formatBarChart, formatOutput, resolveFormat } from './output.js';
22
- const withSubdomain = (yargs) => yargs.option('subdomain', {
23
- type: 'string',
24
- description: 'Documentation subdomain (default: mint config set subdomain)',
25
- });
26
- function defaultFrom() {
27
- const configured = getConfigValue('dateFrom');
28
- if (configured)
29
- return configured;
30
- const d = new Date();
31
- d.setDate(d.getDate() - 7);
32
- return formatLocalDate(d);
33
- }
34
- function defaultTo() {
35
- var _a;
36
- return (_a = getConfigValue('dateTo')) !== null && _a !== void 0 ? _a : formatLocalDate(new Date());
37
- }
38
- const withDates = (yargs) => yargs
39
- .option('from', {
40
- type: 'string',
41
- default: defaultFrom(),
42
- description: 'Start date (YYYY-MM-DD)',
43
- })
44
- .option('to', {
45
- type: 'string',
46
- default: defaultTo(),
47
- description: 'End date (YYYY-MM-DD)',
48
- });
49
- const withFormat = (yargs) => yargs.option('format', {
50
- type: 'string',
51
- choices: ['table', 'plain', 'json', 'graph'],
52
- description: 'Output format (table=pretty, plain=pipeable, json=raw)',
53
- });
54
- const withAll = (yargs) => withFormat(withDates(withSubdomain(yargs)));
55
- function output(format, text) {
56
- if (format === 'table') {
57
- addLog(_jsx(Text, { children: text }));
58
- }
59
- else {
60
- process.stdout.write(text + '\n');
61
- }
62
- }
63
- export const analyticsBuilder = (yargs) => yargs
64
- .middleware(subdomainMiddleware)
65
- .command('stats', 'display KPI numbers (views, visitors, searches)', (yargs) => withAll(yargs).option('page', {
66
- type: 'string',
67
- description: 'Filter to a specific page path',
68
- }), (argv) => __awaiter(void 0, void 0, void 0, function* () {
69
- var _a, _b;
70
- const format = resolveFormat(argv);
71
- try {
72
- if (format === 'table')
73
- addLog(_jsx(SpinnerLog, { message: "Fetching analytics..." }));
74
- const kpi = yield getKpi({ dateFrom: argv.from, dateTo: argv.to, page: argv.page }, argv.subdomain);
75
- if (format === 'table')
76
- removeLastLog();
77
- if (format === 'json') {
78
- output(format, JSON.stringify(kpi, null, 2));
79
- yield terminate(0);
80
- return;
81
- }
82
- if (format === 'plain') {
83
- const lines = [
84
- ['METRIC', 'HUMAN', 'AGENT', 'TOTAL'].join('\t'),
85
- ['Views', kpi.humanViews, kpi.agentViews, kpi.humanViews + kpi.agentViews].join('\t'),
86
- [
87
- 'Visitors',
88
- kpi.humanVisitors,
89
- kpi.agentVisitors,
90
- kpi.humanVisitors + kpi.agentVisitors,
91
- ].join('\t'),
92
- ['Searches', kpi.humanSearches, '', kpi.humanSearches].join('\t'),
93
- ['Feedback', kpi.humanFeedback, '', kpi.humanFeedback].join('\t'),
94
- [
95
- 'Assistant',
96
- kpi.humanAssistant,
97
- kpi.agentMcpSearches,
98
- kpi.humanAssistant + kpi.agentMcpSearches,
99
- ].join('\t'),
100
- ];
101
- output(format, lines.join('\n'));
102
- yield terminate(0);
103
- return;
104
- }
105
- if (format === 'graph') {
106
- const label = (_a = argv.subdomain) !== null && _a !== void 0 ? _a : '';
107
- const lines = [];
108
- lines.push(chalk.bold(`\nAnalytics \u2014 ${label} (${argv.from} to ${argv.to})\n`));
109
- lines.push(chalk.bold(' Human vs Agent\n'));
110
- lines.push(formatBarChart([
111
- { label: 'Human Views', value: kpi.humanViews, color: 'cyan' },
112
- { label: 'Agent Views', value: kpi.agentViews, color: 'magenta' },
113
- { label: 'Human Visitors', value: kpi.humanVisitors, color: 'cyan' },
114
- { label: 'Agent Visitors', value: kpi.agentVisitors, color: 'magenta' },
115
- ]));
116
- lines.push(chalk.bold('\n\n Engagement\n'));
117
- lines.push(formatBarChart([
118
- { label: 'Searches', value: kpi.humanSearches, color: 'yellow' },
119
- { label: 'Feedback', value: kpi.humanFeedback, color: 'green' },
120
- { label: 'Assistant (web)', value: kpi.humanAssistant, color: 'blue' },
121
- { label: 'Assistant (API)', value: kpi.agentMcpSearches, color: 'magenta' },
122
- ]));
123
- output('table', lines.join('\n'));
124
- yield terminate(0);
125
- return;
126
- }
127
- const lines = [];
128
- const label = (_b = argv.subdomain) !== null && _b !== void 0 ? _b : '';
129
- lines.push(chalk.bold(`\nAnalytics \u2014 ${label} (${argv.from} to ${argv.to})\n`));
130
- if (argv.page) {
131
- lines.push(` Page: ${argv.page}\n`);
132
- }
133
- lines.push(chalk.bold(' Views'));
134
- lines.push(` Human: ${chalk.cyan(num(kpi.humanViews).padStart(8))}`);
135
- lines.push(` Agent: ${chalk.magenta(num(kpi.agentViews).padStart(8))}`);
136
- lines.push(` Total: ${num(kpi.humanViews + kpi.agentViews).padStart(8)}`);
137
- lines.push(chalk.bold('\n Visitors'));
138
- lines.push(` Human: ${chalk.cyan(num(kpi.humanVisitors).padStart(8))}`);
139
- lines.push(` Agent: ${chalk.magenta(num(kpi.agentVisitors).padStart(8))}`);
140
- lines.push(` Total: ${num(kpi.humanVisitors + kpi.agentVisitors).padStart(8)}`);
141
- lines.push(`\n Searches: ${chalk.bold(num(kpi.humanSearches))}`);
142
- lines.push(` Feedback: ${chalk.bold(num(kpi.humanFeedback))}`);
143
- lines.push(` Assistant: ${chalk.bold(num(kpi.humanAssistant))} web, ${chalk.bold(num(kpi.agentMcpSearches))} API`);
144
- output(format, lines.join('\n'));
145
- yield terminate(0);
146
- }
147
- catch (err) {
148
- if (format === 'table')
149
- removeLastLog();
150
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
151
- yield terminate(1);
152
- }
153
- }))
154
- .command('search', 'display search analytics', (yargs) => withAll(yargs)
155
- .option('query', { type: 'string', description: 'Filter by search query substring' })
156
- .option('page', { type: 'string', description: 'Filter by top clicked page' }), (argv) => __awaiter(void 0, void 0, void 0, function* () {
157
- var _a, _b;
158
- const format = resolveFormat(argv);
159
- try {
160
- if (format === 'table')
161
- addLog(_jsx(SpinnerLog, { message: "Fetching search analytics..." }));
162
- const data = yield getSearches({ dateFrom: argv.from, dateTo: argv.to }, argv.subdomain);
163
- if (format === 'table')
164
- removeLastLog();
165
- const filteredData = filterSearchResponse(data, {
166
- query: argv.query,
167
- page: argv.page,
168
- });
169
- const rows = filteredData.searches;
170
- const headers = ['Query', 'Hits', 'CTR', 'Top Clicked Page', 'Last Searched'];
171
- const tableRows = rows.map((r) => [
172
- truncate(r.searchQuery, 30),
173
- num(r.hits),
174
- r.ctr.toFixed(1) + '%',
175
- truncate(r.topClickedPage || '\u2014', 30),
176
- r.lastSearchedAt.slice(0, 10),
177
- ]);
178
- if (format === 'json') {
179
- output(format, JSON.stringify(filteredData, null, 2));
180
- }
181
- else if (format === 'graph') {
182
- const label = (_a = argv.subdomain) !== null && _a !== void 0 ? _a : '';
183
- const lines = [];
184
- lines.push(chalk.bold(`\nSearch Queries \u2014 ${label} (${argv.from} to ${argv.to})\n`));
185
- lines.push(formatBarChart(rows.slice(0, 20).map((r) => ({
186
- label: truncate(r.searchQuery, 25),
187
- value: r.hits,
188
- color: 'yellow',
189
- }))));
190
- output('table', lines.join('\n'));
191
- }
192
- else if (format === 'plain') {
193
- output(format, formatOutput(format, headers, tableRows, filteredData));
194
- }
195
- else {
196
- const label = (_b = argv.subdomain) !== null && _b !== void 0 ? _b : '';
197
- const lines = [];
198
- lines.push(chalk.bold(`\nSearch Analytics \u2014 ${label} (${argv.from} to ${argv.to})`));
199
- lines.push(`Total Searches: ${chalk.bold(num(data.totalSearches))}\n`);
200
- lines.push(formatOutput(format, headers, tableRows, filteredData));
201
- output(format, lines.join('\n'));
202
- }
203
- yield terminate(0);
204
- }
205
- catch (err) {
206
- if (format === 'table')
207
- removeLastLog();
208
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
209
- yield terminate(1);
210
- }
211
- }))
212
- .command('feedback', 'display feedback analytics', (yargs) => withAll(yargs)
213
- .option('type', {
214
- type: 'string',
215
- choices: ['code', 'page'],
216
- description: 'Feedback type: code snippets or page-level aggregation',
217
- })
218
- .option('page', { type: 'string', description: 'Filter to a specific page path' }), (argv) => __awaiter(void 0, void 0, void 0, function* () {
219
- var _a, _b, _c;
220
- const format = resolveFormat(argv);
221
- try {
222
- if (format === 'table')
223
- addLog(_jsx(SpinnerLog, { message: "Fetching feedback..." }));
224
- if (argv.type === 'page') {
225
- const data = yield getFeedbackByPage({ dateFrom: argv.from, dateTo: argv.to }, argv.subdomain);
226
- if (format === 'table')
227
- removeLastLog();
228
- const filteredData = filterFeedbackByPageResponse(data, argv.page);
229
- const rows = filteredData.feedback;
230
- const headers = ['Path', 'Thumbs Up', 'Thumbs Down', 'Code', 'Total'];
231
- const tableRows = rows.map((r) => [
232
- truncate(r.path, 40),
233
- num(r.thumbsUp),
234
- num(r.thumbsDown),
235
- num(r.code),
236
- num(r.total),
237
- ]);
238
- if (format === 'json') {
239
- output(format, JSON.stringify(filteredData, null, 2));
240
- }
241
- else if (format === 'graph') {
242
- const label = (_a = argv.subdomain) !== null && _a !== void 0 ? _a : '';
243
- const lines = [];
244
- lines.push(chalk.bold(`\nFeedback by Page \u2014 ${label} (${argv.from} to ${argv.to})\n`));
245
- lines.push(formatBarChart(rows.slice(0, 20).map((r) => ({
246
- label: truncate(r.path, 25),
247
- value: r.total,
248
- color: 'green',
249
- }))));
250
- output('table', lines.join('\n'));
251
- }
252
- else {
253
- const label = (_b = argv.subdomain) !== null && _b !== void 0 ? _b : '';
254
- const lines = [];
255
- if (format === 'table')
256
- lines.push(chalk.bold(`\nFeedback \u2014 ${label} (${argv.from} to ${argv.to})\n`));
257
- lines.push(formatOutput(format, headers, tableRows, filteredData));
258
- if (format === 'table' && data.hasMore)
259
- lines.push(chalk.dim('\n (more results available)'));
260
- output(format, lines.join('\n'));
261
- }
262
- }
263
- else {
264
- const source = argv.type === 'code' ? 'code_snippet' : undefined;
265
- const data = yield getFeedback({ dateFrom: argv.from, dateTo: argv.to, source }, argv.subdomain);
266
- if (format === 'table')
267
- removeLastLog();
268
- const filteredData = filterFeedbackResponse(data, argv.page);
269
- const rows = filteredData.feedback;
270
- const headers = ['ID', 'Path', 'Status', 'Source', 'Comment', 'Created'];
271
- const tableRows = rows.map((r) => {
272
- var _a, _b, _c;
273
- return [
274
- r.id.slice(0, 8),
275
- truncate(r.path, 30),
276
- r.status,
277
- r.source,
278
- truncate((_a = r.comment) !== null && _a !== void 0 ? _a : '\u2014', 30),
279
- (_c = (_b = r.createdAt) === null || _b === void 0 ? void 0 : _b.slice(0, 10)) !== null && _c !== void 0 ? _c : '\u2014',
280
- ];
281
- });
282
- if (format === 'json') {
283
- output(format, JSON.stringify(filteredData, null, 2));
284
- }
285
- else {
286
- const label = (_c = argv.subdomain) !== null && _c !== void 0 ? _c : '';
287
- const lines = [];
288
- if (format === 'table')
289
- lines.push(chalk.bold(`\nFeedback \u2014 ${label} (${argv.from} to ${argv.to})\n`));
290
- lines.push(formatOutput(format, headers, tableRows, filteredData));
291
- if (format === 'table' && data.hasMore)
292
- lines.push(chalk.dim('\n (more results available)'));
293
- output(format, lines.join('\n'));
294
- }
295
- }
296
- yield terminate(0);
297
- }
298
- catch (err) {
299
- if (format === 'table')
300
- removeLastLog();
301
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
302
- yield terminate(1);
303
- }
304
- }))
305
- .command('conversation', 'view assistant conversation analytics', (yargs) => yargs
306
- .command('list', 'list assistant conversations', (yargs) => withAll(yargs).option('page', {
307
- type: 'string',
308
- description: 'Filter conversations mentioning this page in sources',
309
- }), (argv) => __awaiter(void 0, void 0, void 0, function* () {
310
- var _a;
311
- const format = resolveFormat(argv);
312
- try {
313
- if (format === 'table')
314
- addLog(_jsx(SpinnerLog, { message: "Fetching conversations..." }));
315
- const data = yield getConversations({ dateFrom: argv.from, dateTo: argv.to }, argv.subdomain);
316
- if (format === 'table')
317
- removeLastLog();
318
- const filteredData = filterConversationResponse(data, argv.page);
319
- const conversations = filteredData.conversations;
320
- const headers = ['ID', 'Timestamp', 'Query', 'Category'];
321
- const tableRows = conversations.map((c) => [
322
- c.id,
323
- c.timestamp.slice(0, 19).replace('T', ' '),
324
- truncate(c.query, 40),
325
- c.queryCategory || '\u2014',
326
- ]);
327
- if (format === 'json') {
328
- output(format, JSON.stringify(filteredData, null, 2));
329
- }
330
- else {
331
- const label = (_a = argv.subdomain) !== null && _a !== void 0 ? _a : '';
332
- const lines = [];
333
- if (format === 'table')
334
- lines.push(chalk.bold(`\nConversations \u2014 ${label} (${argv.from} to ${argv.to})\n`));
335
- lines.push(formatOutput(format, headers, tableRows, filteredData));
336
- if (format === 'table' && data.hasMore)
337
- lines.push(chalk.dim('\n (more results available)'));
338
- output(format, lines.join('\n'));
339
- }
340
- yield terminate(0);
341
- }
342
- catch (err) {
343
- if (format === 'table')
344
- removeLastLog();
345
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
346
- yield terminate(1);
347
- }
348
- }))
349
- .command('view <id>', 'view a single conversation', (yargs) => withFormat(withSubdomain(yargs)).positional('id', {
350
- type: 'string',
351
- demandOption: true,
352
- description: 'Conversation ID',
353
- }), (argv) => __awaiter(void 0, void 0, void 0, function* () {
354
- const format = resolveFormat(argv);
355
- try {
356
- if (format === 'table')
357
- addLog(_jsx(SpinnerLog, { message: "Fetching conversation..." }));
358
- const thread = yield getAssistantThread(argv.id, argv.subdomain);
359
- if (format === 'table')
360
- removeLastLog();
361
- if (format === 'json' || format === 'plain') {
362
- output(format, JSON.stringify(thread, null, 2));
363
- }
364
- else {
365
- const lines = [];
366
- lines.push(chalk.bold(`\nConversation ${thread.threadId}\n`));
367
- lines.push(` Created: ${thread.createdAt}`);
368
- for (const message of thread.messages) {
369
- const label = message.role === 'user' ? 'User' : 'Assistant';
370
- lines.push(chalk.bold(`\n ${label}:`));
371
- for (const line of message.content.split('\n')) {
372
- lines.push(` ${line}`);
373
- }
374
- }
375
- output(format, lines.join('\n'));
376
- }
377
- yield terminate(0);
378
- }
379
- catch (err) {
380
- if (format === 'table')
381
- removeLastLog();
382
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
383
- yield terminate(1);
384
- }
385
- }))
386
- .command('buckets', 'view conversation category buckets', (yargs) => yargs
387
- .command('list', 'list conversation buckets', (yargs) => withAll(yargs), (argv) => __awaiter(void 0, void 0, void 0, function* () {
388
- var _a, _b;
389
- const format = resolveFormat(argv);
390
- try {
391
- if (format === 'table')
392
- addLog(_jsx(SpinnerLog, { message: "Fetching conversation buckets..." }));
393
- const data = yield getBuckets({ dateFrom: argv.from, dateTo: argv.to }, argv.subdomain);
394
- if (format === 'table')
395
- removeLastLog();
396
- const headers = ['ID', 'Label', 'Count', 'Last Asked'];
397
- const tableRows = data.data.map((b) => [
398
- b.id.slice(0, 12),
399
- truncate(b.questionSummary, 50),
400
- num(b.size),
401
- b.lastAsked ? b.lastAsked.slice(0, 10) : '\u2014',
402
- ]);
403
- if (format === 'json') {
404
- output(format, JSON.stringify(data, null, 2));
405
- }
406
- else if (format === 'graph') {
407
- const label = (_a = argv.subdomain) !== null && _a !== void 0 ? _a : '';
408
- const lines = [];
409
- lines.push(chalk.bold(`\nConversation Buckets \u2014 ${label} (${argv.from} to ${argv.to})\n`));
410
- lines.push(formatBarChart(data.data.slice(0, 20).map((b) => ({
411
- label: truncate(b.questionSummary, 30),
412
- value: b.size,
413
- color: 'blue',
414
- }))));
415
- output('table', lines.join('\n'));
416
- }
417
- else {
418
- const label = (_b = argv.subdomain) !== null && _b !== void 0 ? _b : '';
419
- const lines = [];
420
- if (format === 'table')
421
- lines.push(chalk.bold(`\nConversation Buckets \u2014 ${label} (${argv.from} to ${argv.to})\n`));
422
- lines.push(formatOutput(format, headers, tableRows, data));
423
- if (format === 'table')
424
- lines.push(chalk.dim(`\n Total: ${data.pagination.total}`));
425
- output(format, lines.join('\n'));
426
- }
427
- yield terminate(0);
428
- }
429
- catch (err) {
430
- if (format === 'table')
431
- removeLastLog();
432
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
433
- yield terminate(1);
434
- }
435
- }))
436
- .command('view <id>', 'view conversations in a bucket', (yargs) => withAll(yargs)
437
- .option('limit', {
438
- type: 'number',
439
- description: 'Maximum threads to return (1-100)',
440
- })
441
- .option('cursor', {
442
- type: 'string',
443
- description: 'Pagination cursor from a previous response',
444
- })
445
- .positional('id', {
446
- type: 'string',
447
- demandOption: true,
448
- description: 'Bucket ID',
449
- }), (argv) => __awaiter(void 0, void 0, void 0, function* () {
450
- const format = resolveFormat(argv);
451
- try {
452
- if (format === 'table')
453
- addLog(_jsx(SpinnerLog, { message: "Fetching bucket conversations..." }));
454
- const data = yield getBucketThreads(argv.id, {
455
- dateFrom: argv.from,
456
- dateTo: argv.to,
457
- limit: argv.limit,
458
- cursor: argv.cursor,
459
- }, argv.subdomain);
460
- if (format === 'table')
461
- removeLastLog();
462
- if (format === 'json') {
463
- output(format, JSON.stringify(data, null, 2));
464
- }
465
- else {
466
- const headers = ['Thread ID', 'Query', 'Length', 'Feedback', 'Created'];
467
- const tableRows = data.data.map((t) => [
468
- t.id.slice(0, 12),
469
- truncate(t.firstUserMessage || '\u2014', 40),
470
- num(t.length),
471
- `+${t.feedback.up} -${t.feedback.down}`,
472
- t.createdAt.slice(0, 10),
473
- ]);
474
- const lines = [];
475
- if (format === 'table')
476
- lines.push(chalk.bold(`\nBucket ${argv.id}\n`));
477
- lines.push(formatOutput(format, headers, tableRows, data));
478
- if (format === 'table' &&
479
- data.pagination.hasMore &&
480
- data.pagination.nextCursor) {
481
- lines.push(chalk.dim(`\n More results available. Run again with --cursor ${data.pagination.nextCursor}`));
482
- }
483
- output(format, lines.join('\n'));
484
- }
485
- yield terminate(0);
486
- }
487
- catch (err) {
488
- if (format === 'table')
489
- removeLastLog();
490
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'unknown error' }));
491
- yield terminate(1);
492
- }
493
- }))
494
- .demandCommand(1, 'specify a subcommand: list or view'))
495
- .demandCommand(1, 'specify a subcommand: list, view, or buckets'))
496
- .demandCommand(1, 'specify a subcommand: stats, search, feedback, or conversation');
@@ -1,75 +0,0 @@
1
- import chalk from 'chalk';
2
- import { isAI } from '../helpers.js';
3
- export function resolveFormat(argv) {
4
- if (argv.format === 'table' ||
5
- argv.format === 'plain' ||
6
- argv.format === 'json' ||
7
- argv.format === 'graph')
8
- return argv.format;
9
- if (isAI())
10
- return 'json';
11
- return 'plain';
12
- }
13
- export function formatPlainTable(headers, rows) {
14
- if (rows.length === 0)
15
- return '';
16
- const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => { var _a; return ((_a = r[i]) !== null && _a !== void 0 ? _a : '').length; })));
17
- const headerLine = headers.map((h, i) => h.toUpperCase().padEnd(colWidths[i])).join('\t');
18
- const bodyLines = rows.map((row) => row.map((cell, i) => cell.padEnd(colWidths[i])).join('\t'));
19
- return [headerLine, ...bodyLines].join('\n');
20
- }
21
- export function formatPrettyTable(headers, rows) {
22
- if (rows.length === 0)
23
- return chalk.dim(' No data found.');
24
- const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => { var _a; return ((_a = r[i]) !== null && _a !== void 0 ? _a : '').length; })));
25
- const headerLine = headers.map((h, i) => chalk.bold(h.padEnd(colWidths[i]))).join(' ');
26
- const separator = chalk.dim(colWidths.map((w) => '\u2500'.repeat(w)).join('\u2500\u2500'));
27
- const bodyLines = rows.map((row) => row.map((cell, i) => cell.padEnd(colWidths[i])).join(' '));
28
- return [headerLine, separator, ...bodyLines].join('\n');
29
- }
30
- function gradientBar(len, rgb) {
31
- let result = '';
32
- for (let i = 0; i < len; i++) {
33
- const t = len === 1 ? 1 : i / (len - 1);
34
- const dim = 0.3 + t * 0.7;
35
- const r = Math.round(rgb[0] * dim);
36
- const g = Math.round(rgb[1] * dim);
37
- const b = Math.round(rgb[2] * dim);
38
- result += chalk.rgb(r, g, b)('\u2588');
39
- }
40
- return result;
41
- }
42
- const COLOR_MAP = {
43
- cyan: [0, 255, 255],
44
- magenta: [255, 0, 255],
45
- yellow: [255, 255, 0],
46
- green: [0, 255, 100],
47
- blue: [80, 140, 255],
48
- red: [255, 80, 80],
49
- };
50
- export function formatBarChart(items, opts = {}) {
51
- var _a;
52
- if (items.length === 0)
53
- return chalk.dim(' No data found.');
54
- const maxWidth = (_a = opts.maxWidth) !== null && _a !== void 0 ? _a : 40;
55
- const maxVal = Math.max(...items.map((i) => i.value), 1);
56
- const maxLabel = Math.max(...items.map((i) => i.label.length));
57
- const maxValStr = Math.max(...items.map((i) => i.value.toLocaleString('en-US').length));
58
- return items
59
- .map((item) => {
60
- var _a, _b;
61
- const barLen = Math.round((item.value / maxVal) * maxWidth);
62
- const rgb = (_b = COLOR_MAP[(_a = item.color) !== null && _a !== void 0 ? _a : 'cyan']) !== null && _b !== void 0 ? _b : COLOR_MAP.cyan;
63
- const bar = barLen > 0 ? gradientBar(barLen, rgb) : '';
64
- const pad = ' '.repeat(maxWidth - barLen);
65
- return ` ${item.label.padEnd(maxLabel)} ${bar}${pad} ${item.value.toLocaleString('en-US').padStart(maxValStr)}`;
66
- })
67
- .join('\n');
68
- }
69
- export function formatOutput(format, headers, rows, jsonData) {
70
- if (format === 'json')
71
- return JSON.stringify(jsonData, null, 2);
72
- if (format === 'plain')
73
- return formatPlainTable(headers, rows);
74
- return formatPrettyTable(headers, rows);
75
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,46 +0,0 @@
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 { getAccessToken } from './keyring.js';
11
- import { refreshAccessToken } from './tokenRefresh.js';
12
- function getKeyringToken() {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- try {
15
- return yield getAccessToken();
16
- }
17
- catch (_a) {
18
- return null;
19
- }
20
- });
21
- }
22
- export function authenticatedFetch(url, init) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const keyringToken = yield getKeyringToken();
25
- const envToken = process.env.MINTLIFY_SESSION_TOKEN;
26
- const token = keyringToken !== null && keyringToken !== void 0 ? keyringToken : envToken;
27
- if (!token) {
28
- throw new Error('Not authenticated. Run `mint login` to authenticate.');
29
- }
30
- const makeRequest = (t) => fetch(url, Object.assign(Object.assign({}, init), { headers: Object.assign(Object.assign({}, init === null || init === void 0 ? void 0 : init.headers), { Authorization: `Bearer ${t}` }) }));
31
- const res = yield makeRequest(token);
32
- if (res.status !== 401)
33
- return res;
34
- // If the keyring token expired, try refreshing it
35
- if (keyringToken) {
36
- const refreshed = yield refreshAccessToken();
37
- if (refreshed)
38
- return makeRequest(refreshed);
39
- }
40
- // Fall back to the env session token if it wasn't already used
41
- if (envToken && token !== envToken) {
42
- return makeRequest(envToken);
43
- }
44
- return res;
45
- });
46
- }