Repository navigation
Expand file tree
/
Copy pathschemas.ts
More file actions
217 lines (187 loc) · 7.02 KB
/
Copy pathschemas.ts
File metadata and controls
217 lines (187 loc) · 7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import { z } from "zod";
// Config tools schemas
export const GetConfigArgsSchema = z.object({});
export const SetConfigValueArgsSchema = z.object({
key: z.string(),
value: z.union([
z.string(),
z.number(),
z.boolean(),
z.array(z.string()),
z.null(),
]),
});
// Empty schemas
export const ListProcessesArgsSchema = z.object({});
// Terminal tools schemas
export const StartProcessArgsSchema = z.object({
command: z.string(),
timeout_ms: z.number(),
shell: z.string().optional(),
verbose_timing: z.boolean().optional(),
});
export const ReadProcessOutputArgsSchema = z.object({
pid: z.number(),
timeout_ms: z.number().optional(),
offset: z.number().optional(), // Line offset: 0=from last read, positive=absolute, negative=tail
length: z.number().optional(), // Max lines to return (default from config.fileReadLineLimit)
verbose_timing: z.boolean().optional(),
});
export const ForceTerminateArgsSchema = z.object({
pid: z.number(),
});
export const ListSessionsArgsSchema = z.object({});
export const KillProcessArgsSchema = z.object({
pid: z.number(),
});
// Filesystem tools schemas
export const ReadFileArgsSchema = z.object({
path: z.string(),
isUrl: z.boolean().optional().default(false),
offset: z.number().optional().default(0),
length: z.number().optional().default(1000),
sheet: z.string().optional(), // String only for MCP client compatibility (Cursor doesn't support union types in JSON Schema)
range: z.string().optional(),
options: z.record(z.any()).optional()
});
export const ReadMultipleFilesArgsSchema = z.object({
paths: z.array(z.string()),
});
export const WriteFileArgsSchema = z.object({
path: z.string(),
content: z.string(),
mode: z.enum(['rewrite', 'append']).default('rewrite'),
});
// PDF modification schemas - exported for reuse
export const PdfInsertOperationSchema = z.object({
type: z.literal('insert'),
pageIndex: z.number(),
markdown: z.string().optional(),
sourcePdfPath: z.string().optional(),
pdfOptions: z.object({}).passthrough().optional(),
});
export const PdfDeleteOperationSchema = z.object({
type: z.literal('delete'),
pageIndexes: z.array(z.number()),
});
export const PdfOperationSchema = z.union([PdfInsertOperationSchema, PdfDeleteOperationSchema]);
export const WritePdfArgsSchema = z.object({
path: z.string(),
// Preprocess content to handle JSON strings that should be parsed as arrays
content: z.preprocess(
(val) => {
// If it's a string that looks like JSON array, parse it
if (typeof val === 'string' && val.trim().startsWith('[')) {
try {
return JSON.parse(val);
} catch {
// If parsing fails, return as-is (might be markdown content)
return val;
}
}
// Otherwise return as-is
return val;
},
z.union([z.string(), z.array(PdfOperationSchema)])
),
outputPath: z.string().optional(),
options: z.object({}).passthrough().optional(), // Allow passing options to md-to-pdf
});
export const CreateDirectoryArgsSchema = z.object({
path: z.string(),
});
export const ListDirectoryArgsSchema = z.object({
path: z.string(),
depth: z.number().optional().default(2),
});
export const MoveFileArgsSchema = z.object({
source: z.string(),
destination: z.string(),
});
export const GetFileInfoArgsSchema = z.object({
path: z.string(),
});
// Edit tools schema - SIMPLIFIED from three modes to two
// Previously supported: text replacement, location-based edits (edits array), and range rewrites
// Now supports only: text replacement and range rewrites
// Removed 'edits' array parameter - location-based surgical edits were complex and unnecessary
// Range rewrites are more powerful and cover all structured file editing needs
export const EditBlockArgsSchema = z.object({
file_path: z.string(),
// Text file string replacement
old_string: z.string().optional(),
new_string: z.string().optional(),
expected_replacements: z.number().optional().default(1),
// Structured file range rewrite (Excel, etc.)
range: z.string().optional(),
content: z.any().optional(),
options: z.record(z.any()).optional()
}).refine(
data => {
// Helper to check if value is actually provided (not undefined, not empty string)
const hasValue = (v: unknown) => v !== undefined && v !== '';
return (hasValue(data.old_string) && data.new_string !== undefined) ||
(hasValue(data.range) && hasValue(data.content));
},
{ message: "Must provide either (old_string + new_string) or (range + content)" }
);
// Send input to process schema
export const InteractWithProcessArgsSchema = z.object({
pid: z.number(),
input: z.string(),
timeout_ms: z.number().optional(),
wait_for_prompt: z.boolean().optional(),
verbose_timing: z.boolean().optional(),
});
// Usage stats schema
export const GetUsageStatsArgsSchema = z.object({});
// Feedback tool schema - no pre-filled parameters, all user input
export const GiveFeedbackArgsSchema = z.object({
// No parameters needed - form will be filled manually by user
// Only auto-filled hidden fields remain:
// - tool_call_count (auto)
// - days_using (auto)
// - platform (auto)
// - client_id (auto)
});
// Search schemas (renamed for natural language)
export const StartSearchArgsSchema = z.object({
path: z.string(),
pattern: z.string(),
searchType: z.enum(['files', 'content']).default('files'),
filePattern: z.string().optional(),
ignoreCase: z.boolean().optional().default(true),
maxResults: z.number().optional(),
includeHidden: z.boolean().optional().default(false),
contextLines: z.number().optional().default(5),
timeout_ms: z.number().optional(), // Match process naming convention
earlyTermination: z.boolean().optional(), // Stop search early when exact filename match is found (default: true for files, false for content)
literalSearch: z.boolean().optional().default(false), // Force literal string matching (-F flag) instead of regex
});
export const GetMoreSearchResultsArgsSchema = z.object({
sessionId: z.string(),
offset: z.number().optional().default(0), // Same as file reading
length: z.number().optional().default(100), // Same as file reading (but smaller default)
});
export const StopSearchArgsSchema = z.object({
sessionId: z.string(),
});
export const ListSearchesArgsSchema = z.object({});
// Prompts tool schema - SIMPLIFIED (only get_prompt action)
export const GetPromptsArgsSchema = z.object({
action: z.enum(['get_prompt']),
promptId: z.string(),
// Disabled to check if it makes sense or should be removed or changed
// anonymous_user_use_case: z.string().optional(),
});
// Tool history schema
export const GetRecentToolCallsArgsSchema = z.object({
maxResults: z.number().min(1).max(1000).optional().default(50),
toolName: z.string().optional(),
since: z.string().datetime().optional(),
});
export const TrackUiEventArgsSchema = z.object({
event: z.string().min(1).max(80),
component: z.string().optional().default('file_preview'),
params: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional().default({}),
});