@mintlify/cli 4.0.1314 → 4.0.1316

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.
@@ -0,0 +1,39 @@
1
+ export type PredictionShort = 'AI' | 'AI-Assisted' | 'Human' | 'Mixed';
2
+
3
+ export interface Rewrite {
4
+ text: string;
5
+ rationale: string;
6
+ }
7
+
8
+ export interface DeslopWindow {
9
+ text: string;
10
+ label: string;
11
+ aiAssistanceScore: number;
12
+ confidence: string | number;
13
+ startLine: number;
14
+ endLine: number;
15
+ rewrites?: Rewrite[];
16
+ }
17
+
18
+ export interface DeslopCheckedResponse {
19
+ path: string;
20
+ skipped: null;
21
+ predictionShort: PredictionShort;
22
+ fractionAi: number;
23
+ fractionAiAssisted: number;
24
+ fractionHuman: number;
25
+ windows: DeslopWindow[];
26
+ creditsCharged: number;
27
+ }
28
+
29
+ export interface DeslopSkippedResponse {
30
+ path: string;
31
+ skipped: string;
32
+ creditsCharged: number;
33
+ }
34
+
35
+ export type DeslopResponse = DeslopCheckedResponse | DeslopSkippedResponse;
36
+
37
+ export type DeslopFileResult =
38
+ | { file: string; response: DeslopResponse }
39
+ | { file: string; error: string };
@@ -0,0 +1,155 @@
1
+ export interface WhitespaceReport {
2
+ fixed: string;
3
+ changed: boolean;
4
+ counts: {
5
+ trailing: number;
6
+ blankRuns: number;
7
+ unicodeSpaces: number;
8
+ zeroWidth: number;
9
+ spaces: number;
10
+ finalNewline: boolean;
11
+ };
12
+ }
13
+
14
+ // Unusual space characters that should read as a normal space.
15
+ const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
16
+ // Zero-width and BOM characters that should be removed outright.
17
+ const ZERO_WIDTH = /[\u200B-\u200D\u2060\uFEFF]/g;
18
+
19
+ const FENCE = /^(\s*)(`{3,}|~{3,})/;
20
+ // Splits a line so odd indices are inline-code spans (left untouched).
21
+ const INLINE_CODE = /(`+[^`]*`+)/;
22
+
23
+ function isFrontmatterFence(line: string, index: number): boolean {
24
+ return index === 0 && line.trim() === '---';
25
+ }
26
+
27
+ /**
28
+ * Normalize prose whitespace in an MDX document without touching the bytes of
29
+ * fenced code blocks or YAML frontmatter, where spacing is significant.
30
+ */
31
+ export function normalizeWhitespace(content: string): WhitespaceReport {
32
+ const counts = {
33
+ trailing: 0,
34
+ blankRuns: 0,
35
+ unicodeSpaces: 0,
36
+ zeroWidth: 0,
37
+ spaces: 0,
38
+ finalNewline: false,
39
+ };
40
+
41
+ const lines = content.split('\n');
42
+ const out: string[] = [];
43
+ const isProtected: boolean[] = [];
44
+ let inFence = false;
45
+ let fenceMarker = '';
46
+ let inFrontmatter = false;
47
+
48
+ const pushProtected = (line: string) => {
49
+ out.push(line);
50
+ isProtected.push(true);
51
+ };
52
+
53
+ for (const [index, rawLine] of lines.entries()) {
54
+ if (isFrontmatterFence(rawLine, index)) {
55
+ inFrontmatter = true;
56
+ pushProtected(rawLine);
57
+ continue;
58
+ }
59
+ if (inFrontmatter) {
60
+ pushProtected(rawLine);
61
+ if (rawLine.trim() === '---') inFrontmatter = false;
62
+ continue;
63
+ }
64
+
65
+ const fence = rawLine.match(FENCE);
66
+ if (fence) {
67
+ const marker = fence[2] ?? '';
68
+ if (!inFence) {
69
+ inFence = true;
70
+ fenceMarker = marker;
71
+ } else if (marker[0] === fenceMarker[0] && marker.length >= fenceMarker.length) {
72
+ inFence = false;
73
+ }
74
+ pushProtected(rawLine);
75
+ continue;
76
+ }
77
+ if (inFence) {
78
+ pushProtected(rawLine);
79
+ continue;
80
+ }
81
+
82
+ let line = rawLine;
83
+ // Separate a trailing CR so CRLF files still get their trailing whitespace
84
+ // stripped (and keep the CR so line endings are preserved).
85
+ const cr = line.endsWith('\r') ? '\r' : '';
86
+ if (cr) line = line.slice(0, -1);
87
+
88
+ // Apply substitutions only outside inline-code spans (odd split indices),
89
+ // so backticked code keeps its exact spacing.
90
+ line = line
91
+ .split(INLINE_CODE)
92
+ .map((seg, i) => {
93
+ if (i % 2 === 1) return seg;
94
+ const uni = seg.match(UNICODE_SPACES);
95
+ if (uni) counts.unicodeSpaces += uni.length;
96
+ seg = seg.replace(UNICODE_SPACES, ' ');
97
+ const zw = seg.match(ZERO_WIDTH);
98
+ if (zw) counts.zeroWidth += zw.length;
99
+ return seg.replace(ZERO_WIDTH, '');
100
+ })
101
+ .join('');
102
+
103
+ const trimmed = line.replace(/[ \t]+$/, '');
104
+ if (trimmed !== line) counts.trailing += 1;
105
+ line = trimmed;
106
+
107
+ // Collapse runs of internal spaces (outside inline code), preserving leading indentation.
108
+ const leading = line.match(/^[ \t]*/)?.[0] ?? '';
109
+ const body = line.slice(leading.length);
110
+ const collapsed = body
111
+ .split(INLINE_CODE)
112
+ .map((seg, i) => (i % 2 === 1 ? seg : seg.replace(/ {2,}/g, ' ')))
113
+ .join('');
114
+ if (collapsed !== body) counts.spaces += 1;
115
+ line = leading + collapsed + cr;
116
+
117
+ out.push(line);
118
+ isProtected.push(false);
119
+ }
120
+
121
+ // Collapse runs of 2 or more consecutive blank lines down to a single blank
122
+ // line, but never inside protected regions (code fences, frontmatter).
123
+ const collapsed: string[] = [];
124
+ let blankRun = 0;
125
+ for (const [index, line] of out.entries()) {
126
+ if (!isProtected[index] && line.trim() === '') {
127
+ blankRun += 1;
128
+ if (blankRun <= 1) collapsed.push(line);
129
+ continue;
130
+ }
131
+ if (blankRun > 1) counts.blankRuns += 1;
132
+ blankRun = 0;
133
+ collapsed.push(line);
134
+ }
135
+ if (blankRun > 1) counts.blankRuns += 1;
136
+
137
+ let fixed = collapsed.join('\n').replace(/\n+$/, '');
138
+ if (content.length > 0) {
139
+ counts.finalNewline = !content.endsWith('\n') || content.endsWith('\n\n');
140
+ fixed += '\n';
141
+ }
142
+
143
+ return { fixed, changed: fixed !== content, counts };
144
+ }
145
+
146
+ export function summarizeWhitespace(counts: WhitespaceReport['counts']): string | null {
147
+ const parts: string[] = [];
148
+ if (counts.trailing) parts.push(`${counts.trailing} trailing`);
149
+ if (counts.blankRuns) parts.push(`${counts.blankRuns} blank-line runs`);
150
+ if (counts.unicodeSpaces) parts.push(`${counts.unicodeSpaces} unicode spaces`);
151
+ if (counts.zeroWidth) parts.push(`${counts.zeroWidth} zero-width chars`);
152
+ if (counts.spaces) parts.push(`${counts.spaces} collapsed spaces`);
153
+ if (counts.finalNewline) parts.push('final newline');
154
+ return parts.length ? parts.join(', ') : null;
155
+ }
package/src/signup.tsx CHANGED
@@ -21,7 +21,7 @@ export interface SignupOptions {
21
21
  email?: string;
22
22
  }
23
23
 
24
- const sendAIUsageMessage = () => {
24
+ export const sendAIUsageMessage = () => {
25
25
  addLogs(
26
26
  <Text>Agent Detected - sending AI friendly prompt</Text>,
27
27
  <Text>{'<system-message>'}</Text>,