@@ -9,69 +9,63 @@ import { formatPatch, structuredPatch } from "diff"
99import fuzzysort from "fuzzysort"
1010import ignore from "ignore"
1111import path from "path"
12- import z from "zod"
1312import { Global } from "../global"
1413import { Instance } from "../project/instance"
1514import { Log } from "../util"
1615import { Protected } from "./protected"
1716import { Ripgrep } from "./ripgrep"
18-
19- export const Info = z
20- . object ( {
21- path : z . string ( ) ,
22- added : z . number ( ) . int ( ) ,
23- removed : z . number ( ) . int ( ) ,
24- status : z . enum ( [ "added" , "deleted" , "modified" ] ) ,
25- } )
26- . meta ( {
27- ref : "File" ,
28- } )
29-
30- export type Info = z . infer < typeof Info >
31-
32- export const Node = z
33- . object ( {
34- name : z . string ( ) ,
35- path : z . string ( ) ,
36- absolute : z . string ( ) ,
37- type : z . enum ( [ "file" , "directory" ] ) ,
38- ignored : z . boolean ( ) ,
39- } )
40- . meta ( {
41- ref : "FileNode" ,
42- } )
43- export type Node = z . infer < typeof Node >
44-
45- export const Content = z
46- . object ( {
47- type : z . enum ( [ "text" , "binary" ] ) ,
48- content : z . string ( ) ,
49- diff : z . string ( ) . optional ( ) ,
50- patch : z
51- . object ( {
52- oldFileName : z . string ( ) ,
53- newFileName : z . string ( ) ,
54- oldHeader : z . string ( ) . optional ( ) ,
55- newHeader : z . string ( ) . optional ( ) ,
56- hunks : z . array (
57- z . object ( {
58- oldStart : z . number ( ) ,
59- oldLines : z . number ( ) ,
60- newStart : z . number ( ) ,
61- newLines : z . number ( ) ,
62- lines : z . array ( z . string ( ) ) ,
63- } ) ,
64- ) ,
65- index : z . string ( ) . optional ( ) ,
66- } )
67- . optional ( ) ,
68- encoding : z . literal ( "base64" ) . optional ( ) ,
69- mimeType : z . string ( ) . optional ( ) ,
70- } )
71- . meta ( {
72- ref : "FileContent" ,
73- } )
74- export type Content = z . infer < typeof Content >
17+ import { zod } from "@/util/effect-zod"
18+ import { type DeepMutable , withStatics } from "@/util/schema"
19+
20+ export const Info = Schema . Struct ( {
21+ path : Schema . String ,
22+ added : Schema . Int ,
23+ removed : Schema . Int ,
24+ status : Schema . Literals ( [ "added" , "deleted" , "modified" ] ) ,
25+ } )
26+ . annotate ( { identifier : "File" } )
27+ . pipe ( withStatics ( ( s ) => ( { zod : zod ( s ) } ) ) )
28+ export type Info = DeepMutable < Schema . Schema . Type < typeof Info > >
29+
30+ export const Node = Schema . Struct ( {
31+ name : Schema . String ,
32+ path : Schema . String ,
33+ absolute : Schema . String ,
34+ type : Schema . Literals ( [ "file" , "directory" ] ) ,
35+ ignored : Schema . Boolean ,
36+ } )
37+ . annotate ( { identifier : "FileNode" } )
38+ . pipe ( withStatics ( ( s ) => ( { zod : zod ( s ) } ) ) )
39+ export type Node = DeepMutable < Schema . Schema . Type < typeof Node > >
40+
41+ const Hunk = Schema . Struct ( {
42+ oldStart : Schema . Number ,
43+ oldLines : Schema . Number ,
44+ newStart : Schema . Number ,
45+ newLines : Schema . Number ,
46+ lines : Schema . Array ( Schema . String ) ,
47+ } )
48+
49+ const Patch = Schema . Struct ( {
50+ oldFileName : Schema . String ,
51+ newFileName : Schema . String ,
52+ oldHeader : Schema . optional ( Schema . String ) ,
53+ newHeader : Schema . optional ( Schema . String ) ,
54+ hunks : Schema . Array ( Hunk ) ,
55+ index : Schema . optional ( Schema . String ) ,
56+ } )
57+
58+ export const Content = Schema . Struct ( {
59+ type : Schema . Literals ( [ "text" , "binary" ] ) ,
60+ content : Schema . String ,
61+ diff : Schema . optional ( Schema . String ) ,
62+ patch : Schema . optional ( Patch ) ,
63+ encoding : Schema . optional ( Schema . Literal ( "base64" ) ) ,
64+ mimeType : Schema . optional ( Schema . String ) ,
65+ } )
66+ . annotate ( { identifier : "FileContent" } )
67+ . pipe ( withStatics ( ( s ) => ( { zod : zod ( s ) } ) ) )
68+ export type Content = DeepMutable < Schema . Schema . Type < typeof Content > >
7569
7670export const Event = {
7771 Edited : BusEvent . define (
0 commit comments