mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-23 10:45:33 -04:00
29 lines
889 B
TypeScript
29 lines
889 B
TypeScript
export * as Location from "./location"
|
|
|
|
import { Effect, Schema } from "effect"
|
|
import { AbsolutePath, optional } from "./schema"
|
|
import { ProjectID } from "./project-id"
|
|
import { WorkspaceID } from "./workspace-id"
|
|
|
|
export interface Ref extends Schema.Schema.Type<typeof Ref> {}
|
|
export const Ref = Schema.Struct({
|
|
directory: AbsolutePath,
|
|
workspaceID: Schema.optional(WorkspaceID).pipe(
|
|
Schema.withDecodingDefault(Effect.succeed(undefined)),
|
|
Schema.withConstructorDefault(Effect.succeed(undefined)),
|
|
),
|
|
}).annotate({ identifier: "Location.Ref" })
|
|
|
|
export class Info extends Schema.Class<Info>("Location.Info")({
|
|
directory: AbsolutePath,
|
|
workspaceID: optional(WorkspaceID),
|
|
project: Schema.Struct({
|
|
id: ProjectID,
|
|
directory: AbsolutePath,
|
|
}),
|
|
}) {}
|
|
|
|
export function response<S extends Schema.Top>(data: S) {
|
|
return Schema.Struct({ location: Info, data })
|
|
}
|