1- import { Cause , Duration , Effect , Layer , Schedule , Semaphore , Context , Stream } from "effect"
1+ import { Cause , Duration , Effect , Layer , Schedule , Schema , Semaphore , Context , Stream } from "effect"
22import { ChildProcess , ChildProcessSpawner } from "effect/unstable/process"
33import { formatPatch , structuredPatch } from "diff"
44import path from "path"
@@ -10,25 +10,25 @@ import { Hash } from "@opencode-ai/shared/util/hash"
1010import { Config } from "../config"
1111import { Global } from "../global"
1212import { Log } from "../util"
13-
14- export const Patch = z . object ( {
15- hash : z . string ( ) ,
16- files : z . string ( ) . array ( ) ,
13+ import { withStatics } from "@/util/schema"
14+ import { zod } from "@/util/effect-zod"
15+
16+ export const Patch = Schema . Struct ( {
17+ hash : Schema . String ,
18+ files : Schema . mutable ( Schema . Array ( Schema . String ) ) ,
19+ } ) . pipe ( withStatics ( ( s ) => ( { zod : zod ( s ) } ) ) )
20+ export type Patch = typeof Patch . Type
21+
22+ export const FileDiff = Schema . Struct ( {
23+ file : Schema . String ,
24+ patch : Schema . String ,
25+ additions : Schema . Number ,
26+ deletions : Schema . Number ,
27+ status : Schema . optional ( Schema . Literals ( [ "added" , "deleted" , "modified" ] ) ) ,
1728} )
18- export type Patch = z . infer < typeof Patch >
19-
20- export const FileDiff = z
21- . object ( {
22- file : z . string ( ) ,
23- patch : z . string ( ) ,
24- additions : z . number ( ) ,
25- deletions : z . number ( ) ,
26- status : z . enum ( [ "added" , "deleted" , "modified" ] ) . optional ( ) ,
27- } )
28- . meta ( {
29- ref : "SnapshotFileDiff" ,
30- } )
31- export type FileDiff = z . infer < typeof FileDiff >
29+ . annotate ( { identifier : "SnapshotFileDiff" } )
30+ . pipe ( withStatics ( ( s ) => ( { zod : zod ( s ) } ) ) )
31+ export type FileDiff = typeof FileDiff . Type
3232
3333const log = Log . create ( { service : "snapshot" } )
3434const prune = "7.days"
0 commit comments