@mintlify/cli 4.0.1434 → 4.0.1438

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 (39) hide show
  1. package/bin/agent-harness/buildTaskPrompt.js +76 -0
  2. package/bin/agent-harness/discoverCodeBlocks.js +101 -0
  3. package/bin/agent-harness/executeCodeBlocks.js +220 -0
  4. package/bin/agent-harness/filterSelectedPages.js +10 -0
  5. package/bin/agent-harness/generateTestCode.js +293 -0
  6. package/bin/agent-harness/index.js +85 -0
  7. package/bin/agent-harness/loadAgentSdk.js +46 -0
  8. package/bin/agent-harness/mapWithConcurrency.js +26 -0
  9. package/bin/agent-harness/runSave.js +47 -0
  10. package/bin/agent-harness/setupFolders.js +59 -0
  11. package/bin/agent-harness/tasks/checkTestability.js +226 -0
  12. package/bin/agent-harness/types.js +35 -0
  13. package/bin/cli.js +10 -4
  14. package/bin/mintTest.js +96 -0
  15. package/bin/mintTestNav.js +35 -0
  16. package/bin/mintTestTree.js +94 -0
  17. package/bin/mintTestUi.js +610 -0
  18. package/bin/status.js +11 -4
  19. package/bin/tsconfig.build.tsbuildinfo +1 -1
  20. package/package.json +13 -9
  21. package/src/agent-harness/MINT_TEST_SYSTEM_DESIGN.md +58 -0
  22. package/src/agent-harness/buildTaskPrompt.ts +82 -0
  23. package/src/agent-harness/discoverCodeBlocks.ts +90 -0
  24. package/src/agent-harness/executeCodeBlocks.ts +285 -0
  25. package/src/agent-harness/filterSelectedPages.ts +14 -0
  26. package/src/agent-harness/generateTestCode.ts +332 -0
  27. package/src/agent-harness/index.ts +109 -0
  28. package/src/agent-harness/loadAgentSdk.ts +35 -0
  29. package/src/agent-harness/mapWithConcurrency.ts +21 -0
  30. package/src/agent-harness/runSave.ts +38 -0
  31. package/src/agent-harness/setupFolders.ts +73 -0
  32. package/src/agent-harness/tasks/checkTestability.ts +247 -0
  33. package/src/agent-harness/types.ts +152 -0
  34. package/src/cli.tsx +15 -9
  35. package/src/mintTest.tsx +102 -0
  36. package/src/mintTestNav.ts +31 -0
  37. package/src/mintTestTree.ts +134 -0
  38. package/src/mintTestUi.tsx +988 -0
  39. package/src/status.tsx +11 -4
@@ -0,0 +1,134 @@
1
+ import type { DocsPage } from './agent-harness/index.js';
2
+
3
+ export type ScopeSelectionState = 'all' | 'some' | 'none';
4
+
5
+ export interface ScopeTreeRow {
6
+ id: string;
7
+ kind: 'directory' | 'file';
8
+ label: string;
9
+ depth: number;
10
+ file?: string;
11
+ blockCount: number;
12
+ selectableFiles: string[];
13
+ selection: ScopeSelectionState;
14
+ expanded?: boolean;
15
+ }
16
+
17
+ interface TreeNode {
18
+ id: string;
19
+ kind: 'directory' | 'file';
20
+ label: string;
21
+ file?: string;
22
+ blockCount: number;
23
+ children: TreeNode[];
24
+ }
25
+
26
+ function buildTree(pages: DocsPage[]): TreeNode {
27
+ const root: TreeNode = { id: 'dir:', kind: 'directory', label: '.', blockCount: 0, children: [] };
28
+ const directories = new Map<string, TreeNode>([['', root]]);
29
+
30
+ for (const page of pages) {
31
+ const parts = page.file.split('/');
32
+ let parent = root;
33
+ let directoryPath = '';
34
+ for (const part of parts.slice(0, -1)) {
35
+ directoryPath = directoryPath ? `${directoryPath}/${part}` : part;
36
+ let directory = directories.get(directoryPath);
37
+ if (!directory) {
38
+ directory = {
39
+ id: `dir:${directoryPath}`,
40
+ kind: 'directory',
41
+ label: part,
42
+ blockCount: 0,
43
+ children: [],
44
+ };
45
+ directories.set(directoryPath, directory);
46
+ parent.children.push(directory);
47
+ }
48
+ parent = directory;
49
+ }
50
+
51
+ parent.children.push({
52
+ id: `file:${page.file}`,
53
+ kind: 'file',
54
+ label: parts[parts.length - 1] ?? page.file,
55
+ file: page.file,
56
+ blockCount: page.blockCount,
57
+ children: [],
58
+ });
59
+ }
60
+
61
+ const sumBlocks = (node: TreeNode): number => {
62
+ if (node.kind === 'file') return node.blockCount;
63
+ node.blockCount = node.children.reduce((total, child) => total + sumBlocks(child), 0);
64
+ return node.blockCount;
65
+ };
66
+ sumBlocks(root);
67
+
68
+ const sortChildren = (node: TreeNode): void => {
69
+ node.children.sort((left, right) => {
70
+ if (left.kind !== right.kind) return left.kind === 'directory' ? -1 : 1;
71
+ return left.label.localeCompare(right.label);
72
+ });
73
+ for (const child of node.children) sortChildren(child);
74
+ };
75
+ sortChildren(root);
76
+ return root;
77
+ }
78
+
79
+ function descendantFiles(node: TreeNode): string[] {
80
+ if (node.kind === 'file') return node.file ? [node.file] : [];
81
+ return node.children.flatMap(descendantFiles);
82
+ }
83
+
84
+ function selectionState(files: string[], selectedFiles: ReadonlySet<string>): ScopeSelectionState {
85
+ if (files.length === 0) return 'none';
86
+ const selectedCount = files.filter((file) => selectedFiles.has(file)).length;
87
+ if (selectedCount === 0) return 'none';
88
+ return selectedCount === files.length ? 'all' : 'some';
89
+ }
90
+
91
+ export function visibleScopeRows(
92
+ pages: DocsPage[],
93
+ expandedDirectories: ReadonlySet<string>,
94
+ selectedFiles: ReadonlySet<string>
95
+ ): ScopeTreeRow[] {
96
+ const root = buildTree(pages);
97
+ const rows: ScopeTreeRow[] = [];
98
+
99
+ const visit = (node: TreeNode, depth: number) => {
100
+ const files = descendantFiles(node);
101
+ const expanded = node.kind === 'directory' ? expandedDirectories.has(node.id) : undefined;
102
+ rows.push({
103
+ id: node.id,
104
+ kind: node.kind,
105
+ label: node.label,
106
+ depth,
107
+ ...(node.file ? { file: node.file } : {}),
108
+ blockCount: node.blockCount,
109
+ selectableFiles: files,
110
+ selection: selectionState(files, selectedFiles),
111
+ ...(expanded !== undefined ? { expanded } : {}),
112
+ });
113
+ if (node.kind === 'directory' && expanded) {
114
+ for (const child of node.children) visit(child, depth + 1);
115
+ }
116
+ };
117
+
118
+ for (const child of root.children) visit(child, 0);
119
+ return rows;
120
+ }
121
+
122
+ export function toggleScopeSelection(
123
+ selectedFiles: ReadonlySet<string>,
124
+ row: ScopeTreeRow
125
+ ): Set<string> {
126
+ const next = new Set(selectedFiles);
127
+ if (row.selectableFiles.length === 0) return next;
128
+ const shouldSelect = row.selectableFiles.some((file) => !next.has(file));
129
+ for (const file of row.selectableFiles) {
130
+ if (shouldSelect) next.add(file);
131
+ else next.delete(file);
132
+ }
133
+ return next;
134
+ }