@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 109 lines 3.78 KB
Raw
1 import * as Schema from "effect/Schema";
2 import { TrimmedNonEmptyString } from "./baseSchemas.ts";
3 import { GitCommandError } from "./git.ts";
4 import { VcsError } from "./vcs.ts";
5
6 export const ReviewDiffPreviewInput = Schema.Struct({
7 cwd: TrimmedNonEmptyString,
8 baseRef: Schema.optional(TrimmedNonEmptyString),
9 commitSha: Schema.optional(TrimmedNonEmptyString),
10 ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
11 sourceKind: Schema.optionalKey(Schema.Literals(["working-tree", "branch-range"])),
12 trackedOnly: Schema.optionalKey(Schema.Boolean),
13 metadataOnly: Schema.optionalKey(Schema.Boolean),
14 file: Schema.optionalKey(
15 Schema.Struct({
16 path: Schema.NonEmptyString,
17 previousPath: Schema.NullOr(Schema.NonEmptyString),
18 sourceKind: Schema.Literals(["working-tree", "branch-range", "commit"]),
19 }),
20 ),
21 });
22 export type ReviewDiffPreviewInput = typeof ReviewDiffPreviewInput.Type;
23
24 export const ReviewBranchCommitsInput = Schema.Struct({
25 cwd: TrimmedNonEmptyString,
26 baseRef: Schema.optional(TrimmedNonEmptyString),
27 });
28 export type ReviewBranchCommitsInput = typeof ReviewBranchCommitsInput.Type;
29
30 export const ReviewBranchCommitsResult = Schema.Struct({
31 commits: Schema.Array(
32 Schema.Struct({
33 sha: Schema.String,
34 subject: Schema.String,
35 committedAt: Schema.String,
36 }),
37 ),
38 truncated: Schema.Boolean,
39 });
40 export type ReviewBranchCommitsResult = typeof ReviewBranchCommitsResult.Type;
41
42 export const ReviewDiffPreviewSourceKind = Schema.Literals([
43 "working-tree",
44 "branch-range",
45 "commit",
46 ]);
47 export type ReviewDiffPreviewSourceKind = typeof ReviewDiffPreviewSourceKind.Type;
48
49 export const ReviewDiffChangeType = Schema.Literals([
50 "change",
51 "rename-pure",
52 "rename-changed",
53 "new",
54 "deleted",
55 ]);
56 export type ReviewDiffChangeType = typeof ReviewDiffChangeType.Type;
57
58 export const ReviewDiffFileStat = Schema.Struct({
59 path: Schema.String,
60 previousPath: Schema.NullOr(Schema.String),
61 // Older servers omit it.
62 changeType: Schema.optionalKey(ReviewDiffChangeType),
63 additions: Schema.Number,
64 deletions: Schema.Number,
65 });
66 export type ReviewDiffFileStat = typeof ReviewDiffFileStat.Type;
67
68 export const ReviewDiffPreviewSource = Schema.Struct({
69 id: TrimmedNonEmptyString,
70 kind: ReviewDiffPreviewSourceKind,
71 title: TrimmedNonEmptyString,
72 commitSubject: Schema.optionalKey(TrimmedNonEmptyString),
73 baseRef: Schema.NullOr(TrimmedNonEmptyString),
74 headRef: Schema.NullOr(TrimmedNonEmptyString),
75 diff: Schema.String,
76 diffHash: TrimmedNonEmptyString,
77 truncated: Schema.Boolean,
78 patchesDeferred: Schema.optionalKey(Schema.Boolean),
79 files: Schema.optionalKey(Schema.Array(ReviewDiffFileStat)),
80 });
81 export type ReviewDiffPreviewSource = typeof ReviewDiffPreviewSource.Type;
82
83 export const ReviewDiffFileContentsInput = Schema.Struct({
84 cwd: TrimmedNonEmptyString,
85 sourceKind: ReviewDiffPreviewSourceKind,
86 changeType: ReviewDiffChangeType,
87 baseRef: Schema.NullOr(TrimmedNonEmptyString),
88 headRef: Schema.NullOr(TrimmedNonEmptyString),
89 oldPath: Schema.NonEmptyString,
90 newPath: Schema.NonEmptyString,
91 });
92 export type ReviewDiffFileContentsInput = typeof ReviewDiffFileContentsInput.Type;
93
94 export const ReviewDiffFileContentsResult = Schema.Struct({
95 oldContents: Schema.String,
96 newContents: Schema.String,
97 });
98 export type ReviewDiffFileContentsResult = typeof ReviewDiffFileContentsResult.Type;
99
100 export const ReviewDiffPreviewResult = Schema.Struct({
101 cwd: TrimmedNonEmptyString,
102 generatedAt: Schema.DateTimeUtc,
103 sources: Schema.Array(ReviewDiffPreviewSource),
104 incomplete: Schema.optionalKey(Schema.Boolean),
105 });
106 export type ReviewDiffPreviewResult = typeof ReviewDiffPreviewResult.Type;
107
108 export const ReviewDiffPreviewError = Schema.Union([VcsError, GitCommandError]);
109 export type ReviewDiffPreviewError = typeof ReviewDiffPreviewError.Type;