Skip to content

Commit 5bab9f0

Browse files
committed
Make filePath option of read_file optional again
1 parent 49b1c3e commit 5bab9f0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/read_files.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const readFileActions = {
2828
filePath: z.string().meta({
2929
description: 'The relative path to the file. If omitted, reads the currently open file.',
3030
examples: ['./index.html', 'style.css', 'src/main.js'],
31-
}),
31+
}).optional(),
3232
}),
3333
handler(context) {
3434
const { data: actionData } = context;
@@ -86,14 +86,17 @@ export const readFileActions = {
8686
actionData.params.filePath = vscode.workspace.asRelativePath(normalizedUri, false);
8787
}
8888

89+
// Assert to the type checker that filePath is definitely defined
90+
const contextCopyWithFilePathDefined = contextCopy as RCEContext<{filePath: string}>;
91+
8992
// Run all validators with the resolved filePath
9093
const neuroSafeResult = await neuroSafeValidation(true)(context);
9194
if (!neuroSafeResult.success) return neuroSafeResult;
9295

93-
const binaryResult = await binaryFileValidation(contextCopy);
96+
const binaryResult = await binaryFileValidation(contextCopyWithFilePathDefined);
9497
if (!binaryResult.success) return binaryResult;
9598

96-
const fileResult = await validateIsAFile(contextCopy);
99+
const fileResult = await validateIsAFile(contextCopyWithFilePathDefined);
97100
if (!fileResult.success) return fileResult;
98101

99102
return actionValidationAccept();

0 commit comments

Comments
 (0)