cloudaxe-opencode/packages/opencode/src/cli/cmd/debug/snapshot.ts

54 lines
1.5 KiB
TypeScript
Raw Normal View History

import { AppRuntime } from "@/effect/app-runtime"
2025-07-01 16:06:38 +00:00
import { Snapshot } from "../../../snapshot"
import { bootstrap } from "../../bootstrap"
import { cmd } from "../cmd"
export const SnapshotCommand = cmd({
command: "snapshot",
describe: "snapshot debugging utilities",
2025-07-28 17:00:09 +00:00
builder: (yargs) => yargs.command(TrackCommand).command(PatchCommand).command(DiffCommand).demandCommand(),
2025-07-01 16:06:38 +00:00
async handler() {},
})
2025-07-24 21:34:15 +00:00
const TrackCommand = cmd({
command: "track",
describe: "track current snapshot state",
2025-07-01 16:06:38 +00:00
async handler() {
await bootstrap(process.cwd(), async () => {
console.log(await AppRuntime.runPromise(Snapshot.Service.use((svc) => svc.track())))
2025-07-01 16:06:38 +00:00
})
},
})
2025-07-14 18:44:47 +00:00
2025-07-24 21:34:15 +00:00
const PatchCommand = cmd({
command: "patch <hash>",
describe: "show patch for a snapshot hash",
2025-07-14 18:44:47 +00:00
builder: (yargs) =>
2025-07-24 21:34:15 +00:00
yargs.positional("hash", {
2025-07-14 18:44:47 +00:00
type: "string",
2025-07-24 21:34:15 +00:00
description: "hash",
2025-07-14 18:44:47 +00:00
demandOption: true,
}),
async handler(args) {
await bootstrap(process.cwd(), async () => {
console.log(await AppRuntime.runPromise(Snapshot.Service.use((svc) => svc.patch(args.hash))))
})
},
})
2025-07-28 17:00:09 +00:00
const DiffCommand = cmd({
command: "diff <hash>",
describe: "show diff for a snapshot hash",
2025-07-28 17:00:09 +00:00
builder: (yargs) =>
yargs.positional("hash", {
type: "string",
description: "hash",
demandOption: true,
}),
async handler(args) {
await bootstrap(process.cwd(), async () => {
console.log(await AppRuntime.runPromise(Snapshot.Service.use((svc) => svc.diff(args.hash))))
2025-07-28 17:00:09 +00:00
})
},
})