|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Cause, Duration, Effect, Layer, Schedule, Semaphore, Context, Stream } from "effect"
|
|
|
+import { Cause, Duration, Effect, Layer, Schedule, Schema, Semaphore, Context, Stream } from "effect"
|
|
|
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
|
|
|
import { formatPatch, structuredPatch } from "diff"
|
|
|
import path from "path"
|
|
|
@@ -10,25 +10,25 @@ import { Hash } from "@opencode-ai/shared/util/hash"
|
|
|
import { Config } from "../config"
|
|
|
import { Global } from "../global"
|
|
|
import { Log } from "../util"
|
|
|
-
|
|
|
-export const Patch = z.object({
|
|
|
- hash: z.string(),
|
|
|
- files: z.string().array(),
|
|
|
+import { withStatics } from "@/util/schema"
|
|
|
+import { zod } from "@/util/effect-zod"
|
|
|
+
|
|
|
+export const Patch = Schema.Struct({
|
|
|
+ hash: Schema.String,
|
|
|
+ files: Schema.mutable(Schema.Array(Schema.String)),
|
|
|
+}).pipe(withStatics((s) => ({ zod: zod(s) })))
|
|
|
+export type Patch = typeof Patch.Type
|
|
|
+
|
|
|
+export const FileDiff = Schema.Struct({
|
|
|
+ file: Schema.String,
|
|
|
+ patch: Schema.String,
|
|
|
+ additions: Schema.Number,
|
|
|
+ deletions: Schema.Number,
|
|
|
+ status: Schema.optional(Schema.Literals(["added", "deleted", "modified"])),
|
|
|
})
|
|
|
-export type Patch = z.infer<typeof Patch>
|
|
|
-
|
|
|
-export const FileDiff = z
|
|
|
- .object({
|
|
|
- file: z.string(),
|
|
|
- patch: z.string(),
|
|
|
- additions: z.number(),
|
|
|
- deletions: z.number(),
|
|
|
- status: z.enum(["added", "deleted", "modified"]).optional(),
|
|
|
- })
|
|
|
- .meta({
|
|
|
- ref: "SnapshotFileDiff",
|
|
|
- })
|
|
|
-export type FileDiff = z.infer<typeof FileDiff>
|
|
|
+ .annotate({ identifier: "SnapshotFileDiff" })
|
|
|
+ .pipe(withStatics((s) => ({ zod: zod(s) })))
|
|
|
+export type FileDiff = typeof FileDiff.Type
|
|
|
|
|
|
const log = Log.create({ service: "snapshot" })
|
|
|
const prune = "7.days"
|