import * as Schema from "effect/Schema";import { TrimmedNonEmptyString } from "./baseSchemas.ts"; export const VcsDriverKind = Schema.Literals(["git", "jj", "unknown"]);export type VcsDriverKind = typeof VcsDriverKind.Type; export const VcsFreshnessSource = Schema.Literals([ "live-local", "cached-local", "cached-remote", "explicit-remote",]);export type VcsFreshnessSource = typeof VcsFreshnessSource.Type; export const VcsFreshness = Schema.Struct({ source: VcsFreshnessSource, observedAt: Schema.DateTimeUtc, expiresAt: Schema.Option(Schema.DateTimeUtc),});export type VcsFreshness = typeof VcsFreshness.Type; export const VcsDriverCapabilities = Schema.Struct({ kind: VcsDriverKind, supportsWorktrees: Schema.Boolean, supportsBookmarks: Schema.Boolean, supportsAtomicSnapshot: Schema.Boolean, supportsPushDefaultRemote: Schema.Boolean, ignoreClassifier: Schema.Literals(["native", "git-compatible-fallback"]),});export type VcsDriverCapabilities = typeof VcsDriverCapabilities.Type; export const VcsRepositoryIdentity = Schema.Struct({ kind: VcsDriverKind, rootPath: TrimmedNonEmptyString, metadataPath: Schema.NullOr(TrimmedNonEmptyString), freshness: VcsFreshness,});export type VcsRepositoryIdentity = typeof VcsRepositoryIdentity.Type; export const VcsListWorkspaceFilesResult = Schema.Struct({ paths: Schema.Array(TrimmedNonEmptyString), truncated: Schema.Boolean, freshness: VcsFreshness,});export type VcsListWorkspaceFilesResult = typeof VcsListWorkspaceFilesResult.Type; export const VcsRemote = Schema.Struct({ name: TrimmedNonEmptyString, url: TrimmedNonEmptyString, pushUrl: Schema.Option(TrimmedNonEmptyString), isPrimary: Schema.Boolean,});export type VcsRemote = typeof VcsRemote.Type; export const VcsListRemotesResult = Schema.Struct({ remotes: Schema.Array(VcsRemote), freshness: VcsFreshness,});export type VcsListRemotesResult = typeof VcsListRemotesResult.Type; export class VcsProcessSpawnError extends Schema.TaggedErrorClass<VcsProcessSpawnError>()( "VcsProcessSpawnError", { operation: Schema.String, command: Schema.String, cwd: Schema.String, cause: Schema.Defect, },) { override get message(): string { return `VCS process failed to spawn in ${this.operation}: ${this.command} (${this.cwd})`; }} export class VcsProcessExitError extends Schema.TaggedErrorClass<VcsProcessExitError>()( "VcsProcessExitError", { operation: Schema.String, command: Schema.String, cwd: Schema.String, exitCode: Schema.Number, detail: Schema.String, },) { override get message(): string { return `VCS process failed in ${this.operation}: ${this.command} (${this.cwd}) exited with ${this.exitCode} - ${this.detail}`; }} export class VcsProcessTimeoutError extends Schema.TaggedErrorClass<VcsProcessTimeoutError>()( "VcsProcessTimeoutError", { operation: Schema.String, command: Schema.String, cwd: Schema.String, timeoutMs: Schema.Number, },) { override get message(): string { return `VCS process timed out in ${this.operation}: ${this.command} (${this.cwd}) after ${this.timeoutMs}ms`; }} export class VcsOutputDecodeError extends Schema.TaggedErrorClass<VcsOutputDecodeError>()( "VcsOutputDecodeError", { operation: Schema.String, command: Schema.String, cwd: Schema.String, detail: Schema.String, cause: Schema.optional(Schema.Defect), },) { override get message(): string { return `VCS output decode failed in ${this.operation}: ${this.command} (${this.cwd}) - ${this.detail}`; }} export class VcsRepositoryDetectionError extends Schema.TaggedErrorClass<VcsRepositoryDetectionError>()( "VcsRepositoryDetectionError", { operation: Schema.String, cwd: Schema.String, detail: Schema.String, cause: Schema.optional(Schema.Defect), },) { override get message(): string { return `VCS repository detection failed in ${this.operation}: ${this.cwd} - ${this.detail}`; }} export class VcsUnsupportedOperationError extends Schema.TaggedErrorClass<VcsUnsupportedOperationError>()( "VcsUnsupportedOperationError", { operation: Schema.String, kind: VcsDriverKind, detail: Schema.String, },) { override get message(): string { return `VCS operation is unsupported for ${this.kind} in ${this.operation}: ${this.detail}`; }} export const VcsError = Schema.Union([ VcsProcessSpawnError, VcsProcessExitError, VcsProcessTimeoutError, VcsOutputDecodeError, VcsRepositoryDetectionError, VcsUnsupportedOperationError,]);export type VcsError = typeof VcsError.Type;
import * as Schema from "effect/Schema";
import { TrimmedNonEmptyString } from "./baseSchemas.ts";
export const VcsDriverKind = Schema.Literals(["git", "jj", "unknown"]);
export type VcsDriverKind = typeof VcsDriverKind.Type;
export const VcsFreshnessSource = Schema.Literals([
"live-local",
"cached-local",
"cached-remote",
"explicit-remote",
]);
export type VcsFreshnessSource = typeof VcsFreshnessSource.Type;
export const VcsFreshness = Schema.Struct({
source: VcsFreshnessSource,
observedAt: Schema.DateTimeUtc,
expiresAt: Schema.Option(Schema.DateTimeUtc),
});
export type VcsFreshness = typeof VcsFreshness.Type;
export const VcsDriverCapabilities = Schema.Struct({
kind: VcsDriverKind,
supportsWorktrees: Schema.Boolean,
supportsBookmarks: Schema.Boolean,
supportsAtomicSnapshot: Schema.Boolean,
supportsPushDefaultRemote: Schema.Boolean,
ignoreClassifier: Schema.Literals(["native", "git-compatible-fallback"]),
});
export type VcsDriverCapabilities = typeof VcsDriverCapabilities.Type;
export const VcsRepositoryIdentity = Schema.Struct({
kind: VcsDriverKind,
rootPath: TrimmedNonEmptyString,
metadataPath: Schema.NullOr(TrimmedNonEmptyString),
freshness: VcsFreshness,
});
export type VcsRepositoryIdentity = typeof VcsRepositoryIdentity.Type;
export const VcsListWorkspaceFilesResult = Schema.Struct({
paths: Schema.Array(TrimmedNonEmptyString),
truncated: Schema.Boolean,
freshness: VcsFreshness,
});
export type VcsListWorkspaceFilesResult = typeof VcsListWorkspaceFilesResult.Type;
export const VcsRemote = Schema.Struct({
name: TrimmedNonEmptyString,
url: TrimmedNonEmptyString,
pushUrl: Schema.Option(TrimmedNonEmptyString),
isPrimary: Schema.Boolean,
});
export type VcsRemote = typeof VcsRemote.Type;
export const VcsListRemotesResult = Schema.Struct({
remotes: Schema.Array(VcsRemote),
freshness: VcsFreshness,
});
export type VcsListRemotesResult = typeof VcsListRemotesResult.Type;
export class VcsProcessSpawnError extends Schema.TaggedErrorClass<VcsProcessSpawnError>()(
"VcsProcessSpawnError",
{
operation: Schema.String,
command: Schema.String,
cwd: Schema.String,
cause: Schema.Defect,
},
) {
override get message(): string {
return `VCS process failed to spawn in ${this.operation}: ${this.command} (${this.cwd})`;
}
}
export class VcsProcessExitError extends Schema.TaggedErrorClass<VcsProcessExitError>()(
"VcsProcessExitError",
{
operation: Schema.String,
command: Schema.String,
cwd: Schema.String,
exitCode: Schema.Number,
detail: Schema.String,
},
) {
override get message(): string {
return `VCS process failed in ${this.operation}: ${this.command} (${this.cwd}) exited with ${this.exitCode} - ${this.detail}`;
}
}
export class VcsProcessTimeoutError extends Schema.TaggedErrorClass<VcsProcessTimeoutError>()(
"VcsProcessTimeoutError",
{
operation: Schema.String,
command: Schema.String,
cwd: Schema.String,
timeoutMs: Schema.Number,
},
) {
override get message(): string {
return `VCS process timed out in ${this.operation}: ${this.command} (${this.cwd}) after ${this.timeoutMs}ms`;
}
}
export class VcsOutputDecodeError extends Schema.TaggedErrorClass<VcsOutputDecodeError>()(
"VcsOutputDecodeError",
{
operation: Schema.String,
command: Schema.String,
cwd: Schema.String,
detail: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `VCS output decode failed in ${this.operation}: ${this.command} (${this.cwd}) - ${this.detail}`;
}
}
export class VcsRepositoryDetectionError extends Schema.TaggedErrorClass<VcsRepositoryDetectionError>()(
"VcsRepositoryDetectionError",
{
operation: Schema.String,
cwd: Schema.String,
detail: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `VCS repository detection failed in ${this.operation}: ${this.cwd} - ${this.detail}`;
}
}
export class VcsUnsupportedOperationError extends Schema.TaggedErrorClass<VcsUnsupportedOperationError>()(
"VcsUnsupportedOperationError",
{
operation: Schema.String,
kind: VcsDriverKind,
detail: Schema.String,
},
) {
override get message(): string {
return `VCS operation is unsupported for ${this.kind} in ${this.operation}: ${this.detail}`;
}
}
export const VcsError = Schema.Union([
VcsProcessSpawnError,
VcsProcessExitError,
VcsProcessTimeoutError,
VcsOutputDecodeError,
VcsRepositoryDetectionError,
VcsUnsupportedOperationError,
]);
export type VcsError = typeof VcsError.Type;