mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Add file virtualization and patch editing for large files
This commit is contained in:
1 parent
16767a2a77
commit
12b7ab54b2
9 files changed
+760
-31
No files matched your search
@@ -9,6 +9,7 @@ export const FileInfoSchema: z.ZodType<{
|
||||
content?: string
|
||||
children?: Array<any>
|
||||
lastModified: Date
|
||||
totalLines?: number
|
||||
}> = z.object({
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
@@ -18,6 +19,7 @@ export const FileInfoSchema: z.ZodType<{
|
||||
content: z.string().optional(),
|
||||
children: z.lazy(() => z.array(FileInfoSchema)).optional(),
|
||||
lastModified: z.date(),
|
||||
totalLines: z.number().optional(),
|
||||
})
|
||||
|
||||
export const CreateFileRequestSchema = z.object({
|
||||
@@ -35,3 +37,35 @@ export const FileUploadResponseSchema = z.object({
|
||||
size: z.number(),
|
||||
mimeType: z.string(),
|
||||
})
|
||||
|
||||
export const ChunkedFileInfoSchema = z.object({
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
isDirectory: z.literal(false),
|
||||
size: z.number(),
|
||||
mimeType: z.string().optional(),
|
||||
lines: z.array(z.string()),
|
||||
totalLines: z.number(),
|
||||
startLine: z.number(),
|
||||
endLine: z.number(),
|
||||
hasMore: z.boolean(),
|
||||
lastModified: z.date(),
|
||||
})
|
||||
|
||||
export const FileRangeRequestSchema = z.object({
|
||||
startLine: z.number().int().min(0),
|
||||
endLine: z.number().int().min(0),
|
||||
})
|
||||
|
||||
export const PatchOperationSchema = z.object({
|
||||
type: z.enum(['replace', 'insert', 'delete']),
|
||||
startLine: z.number().int().min(0),
|
||||
endLine: z.number().int().min(0).optional(),
|
||||
content: z.string().optional(),
|
||||
})
|
||||
|
||||
export const FilePatchRequestSchema = z.object({
|
||||
patches: z.array(PatchOperationSchema),
|
||||
})
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ import {
|
||||
CreateFileRequestSchema,
|
||||
RenameFileRequestSchema,
|
||||
FileUploadResponseSchema,
|
||||
ChunkedFileInfoSchema,
|
||||
FileRangeRequestSchema,
|
||||
PatchOperationSchema,
|
||||
FilePatchRequestSchema,
|
||||
} from '../schemas/files'
|
||||
import {
|
||||
SessionSchema,
|
||||
@@ -46,6 +50,10 @@ export type FileInfo = z.infer<typeof FileInfoSchema>
|
||||
export type CreateFileRequest = z.infer<typeof CreateFileRequestSchema>
|
||||
export type RenameFileRequest = z.infer<typeof RenameFileRequestSchema>
|
||||
export type FileUploadResponse = z.infer<typeof FileUploadResponseSchema>
|
||||
export type ChunkedFileInfo = z.infer<typeof ChunkedFileInfoSchema>
|
||||
export type FileRangeRequest = z.infer<typeof FileRangeRequestSchema>
|
||||
export type PatchOperation = z.infer<typeof PatchOperationSchema>
|
||||
export type FilePatchRequest = z.infer<typeof FilePatchRequestSchema>
|
||||
|
||||
export type Session = z.infer<typeof SessionSchema>
|
||||
export type Message = z.infer<typeof MessageSchema>
|
||||
|
||||
Reference in new issue
Block a user