Files
codex/codex-cli/src/utils/singlepass/file_ops.ts
Ilan Bigio 59a180ddec Initial commit
Signed-off-by: Ilan Bigio <ilan@openai.com>
2025-04-16 12:56:08 -04:00

48 lines
1.2 KiB
TypeScript

import { z } from "zod";
/**
* Represents a file operation, including modifications, deletes, and moves.
*/
export const FileOperationSchema = z.object({
/**
* Absolute path to the file.
*/
path: z.string(),
/**
* FULL CONTENT of the file after modification. Provides the FULL AND FINAL content of
* the file after modification WITHOUT OMITTING OR TRUNCATING ANY PART OF THE FILE.
*
* Mutually exclusive with 'delete' and 'move_to'.
*/
updated_full_content: z.string().nullable().optional(),
/**
* Set to true if the file is to be deleted.
*
* Mutually exclusive with 'updated_full_content' and 'move_to'.
*/
delete: z.boolean().nullable().optional(),
/**
* New path of the file if it is to be moved.
*
* Mutually exclusive with 'updated_full_content' and 'delete'.
*/
move_to: z.string().nullable().optional(),
});
export type FileOperation = z.infer<typeof FileOperationSchema>;
/**
* Container for one or more FileOperation objects.
*/
export const EditedFilesSchema = z.object({
/**
* A list of file operations that are applied in order.
*/
ops: z.array(FileOperationSchema),
});
export type EditedFiles = z.infer<typeof EditedFilesSchema>;