@intentic/sandbox-contract 1.377.0 → 1.378.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/contracts/diff.contract.d.ts +9 -0
- package/dist/contracts/diff.contract.d.ts.map +1 -1
- package/dist/contracts/git.contract.d.ts +362 -1
- package/dist/contracts/git.contract.d.ts.map +1 -1
- package/dist/contracts/git.contract.js +37 -16
- package/dist/contracts/git.contract.js.map +1 -1
- package/dist/contracts/system.contract.d.ts +30 -30
- package/dist/contracts/workspace.contract.d.ts +30 -0
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.js +2 -2
- package/dist/contracts/workspace.contract.js.map +1 -1
- package/dist/index.d.ts +431 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/schemas/diff.d.ts +9 -0
- package/dist/schemas/diff.d.ts.map +1 -1
- package/dist/schemas/diff.js +2 -0
- package/dist/schemas/diff.js.map +1 -1
- package/dist/schemas/git/branch-landings.d.ts +27 -0
- package/dist/schemas/git/branch-landings.d.ts.map +1 -0
- package/dist/schemas/git/branch-landings.js +20 -0
- package/dist/schemas/git/branch-landings.js.map +1 -0
- package/dist/schemas/git/git-history.d.ts +80 -0
- package/dist/schemas/git/git-history.d.ts.map +1 -1
- package/dist/schemas/git/git-history.js +17 -17
- package/dist/schemas/git/git-history.js.map +1 -1
- package/dist/schemas/git/git-view.d.ts +32 -0
- package/dist/schemas/git/git-view.d.ts.map +1 -0
- package/dist/schemas/git/git-view.js +19 -0
- package/dist/schemas/git/git-view.js.map +1 -0
- package/dist/schemas/git/git.d.ts +45 -0
- package/dist/schemas/git/git.d.ts.map +1 -1
- package/dist/schemas/git/git.js +11 -10
- package/dist/schemas/git/git.js.map +1 -1
- package/dist/schemas/git/index-run.d.ts +5 -0
- package/dist/schemas/git/index-run.d.ts.map +1 -1
- package/dist/schemas/git/index-run.js +2 -2
- package/dist/schemas/git/index-run.js.map +1 -1
- package/dist/schemas/workspace/workspace-tree.d.ts +15 -0
- package/dist/schemas/workspace/workspace-tree.d.ts.map +1 -1
- package/dist/schemas/workspace/workspace-tree.js +3 -3
- package/dist/schemas/workspace/workspace-tree.js.map +1 -1
- package/package.json +5 -5
- package/src/contracts/git.contract.ts +39 -16
- package/src/contracts/workspace.contract.ts +2 -2
- package/src/schemas/diff.ts +2 -0
- package/src/schemas/git/branch-landings.ts +25 -0
- package/src/schemas/git/git-history.ts +17 -17
- package/src/schemas/git/git-view.ts +22 -0
- package/src/schemas/git/git.ts +12 -12
- package/src/schemas/git/index-run.ts +2 -2
- package/src/schemas/workspace/workspace-tree.ts +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GitViewQuerySchema,GitRepoParamSchema } from "../schemas/git/git-view.js";
|
|
1
2
|
import { procedure } from "../protocol/route-meta.js";
|
|
2
3
|
import {
|
|
3
4
|
CommitResultSchema,
|
|
@@ -47,12 +48,23 @@ import {
|
|
|
47
48
|
} from "../schemas/git/git-history.js";
|
|
48
49
|
import { IndexRunSchema, IndexRunStartSchema } from "../schemas/git/index-run.js";
|
|
49
50
|
import { FileDiffSchema } from "../schemas/history.js";
|
|
50
|
-
import { OkSchema
|
|
51
|
+
import { OkSchema } from "../schemas/shared.js";
|
|
52
|
+
import { BranchLandingsQuerySchema, BranchLandingsSchema } from "../schemas/git/branch-landings.js";
|
|
51
53
|
|
|
52
54
|
// Per-repo git ops over the workspace repos; `root` is /work, others are discovered under it, and {repo} is the
|
|
53
55
|
// root-relative dir, URL-encoded. Unknown {repo} throws NOT_FOUND, an escaping path throws BAD_REQUEST. `changes` is
|
|
54
56
|
// the workspace-wide review set; commit/discard take optional `paths`.
|
|
55
57
|
export const gitContract = {
|
|
58
|
+
branchLandings: procedure
|
|
59
|
+
.route({
|
|
60
|
+
method: "GET",
|
|
61
|
+
path: "/git/{repo}/branch-landings",
|
|
62
|
+
summary: "Session work landed onto a branch",
|
|
63
|
+
description:
|
|
64
|
+
"Session commits unique to the selected branch, newest first. Each commit compares the branch before that landing with the result, independently of later edits or session worktree cleanup. Continue with the returned next cursor.",
|
|
65
|
+
})
|
|
66
|
+
.input(BranchLandingsQuerySchema)
|
|
67
|
+
.output(BranchLandingsSchema),
|
|
56
68
|
changes: procedure
|
|
57
69
|
.route({
|
|
58
70
|
method: "GET",
|
|
@@ -61,6 +73,17 @@ export const gitContract = {
|
|
|
61
73
|
description:
|
|
62
74
|
"The workspace's whole review set in one answer: every repo that has something uncommitted, and within it every changed file with its status and line counts. This is what the Changes panel draws, and it is the call to make when you want to know whether a workspace is clean without walking the repos yourself.",
|
|
63
75
|
})
|
|
76
|
+
.input(GitViewQuerySchema.optional())
|
|
77
|
+
.output(GitChangesSchema),
|
|
78
|
+
viewChanges: procedure
|
|
79
|
+
.route({
|
|
80
|
+
method: "GET",
|
|
81
|
+
path: "/git/view/changes",
|
|
82
|
+
summary: "Uncommitted work across every repo",
|
|
83
|
+
description:
|
|
84
|
+
"The workspace's whole review set in one answer: every repo that has something uncommitted, and within it every changed file with its status and line counts. This is what the Changes panel draws, and it is the call to make when you want to know whether a workspace is clean without walking the repos yourself.",
|
|
85
|
+
})
|
|
86
|
+
.input(GitViewQuerySchema)
|
|
64
87
|
.output(GitChangesSchema),
|
|
65
88
|
// Read-only: repo list, commit log, lazy per-commit diff; commit/discard on the tree are a separate write path.
|
|
66
89
|
repos: procedure
|
|
@@ -122,7 +145,7 @@ export const gitContract = {
|
|
|
122
145
|
description:
|
|
123
146
|
"Names the git operation the worktree is stuck inside, if any: a conflicted merge, an interrupted rebase, a half-applied cherry-pick. Check this first when another call refuses, because a halted worktree is the usual reason and the abort call is the way out.",
|
|
124
147
|
})
|
|
125
|
-
.input(
|
|
148
|
+
.input(GitRepoParamSchema)
|
|
126
149
|
.output(GitOperationStateSchema),
|
|
127
150
|
abort: procedure
|
|
128
151
|
.route({
|
|
@@ -132,7 +155,7 @@ export const gitContract = {
|
|
|
132
155
|
description:
|
|
133
156
|
"Runs git's own abort for whichever operation has the worktree halted, putting the repo back where it stood before the operation started. Nothing else clears that state.",
|
|
134
157
|
})
|
|
135
|
-
.input(
|
|
158
|
+
.input(GitRepoParamSchema)
|
|
136
159
|
.output(GitActionResultSchema),
|
|
137
160
|
// Moves the branch ref via reflog; requires `previousSha` from the matching read as a concurrency token.
|
|
138
161
|
undoable: procedure
|
|
@@ -143,7 +166,7 @@ export const gitContract = {
|
|
|
143
166
|
description:
|
|
144
167
|
"Reads the branch's reflog to describe the move that undo would reverse, and hands back the commit it would land on. Pass that commit to the undo call as proof you looked, and an undo prepared against a view that has since moved is refused rather than landing somewhere unexamined.",
|
|
145
168
|
})
|
|
146
|
-
.input(
|
|
169
|
+
.input(GitRepoParamSchema)
|
|
147
170
|
.output(GitUndoStateSchema),
|
|
148
171
|
undo: procedure
|
|
149
172
|
.route({
|
|
@@ -164,7 +187,7 @@ export const gitContract = {
|
|
|
164
187
|
description:
|
|
165
188
|
"The repo's stash entries, newest first, each with the message and the commit behind it. A stash entry is a commit, so it reads the same way a log entry does and its contents come back from the stash diff call.",
|
|
166
189
|
})
|
|
167
|
-
.input(
|
|
190
|
+
.input(GitRepoParamSchema)
|
|
168
191
|
.output(StashListSchema),
|
|
169
192
|
stashDiff: procedure
|
|
170
193
|
.route({
|
|
@@ -261,7 +284,7 @@ export const gitContract = {
|
|
|
261
284
|
description:
|
|
262
285
|
"Switches a shared checkout that something moved off its main line back onto it, which is the only switch the shared workspace takes. Uncommitted work that would be overwritten is reported instead of being trampled, and nothing happens when it is already there.",
|
|
263
286
|
})
|
|
264
|
-
.input(
|
|
287
|
+
.input(GitRepoParamSchema)
|
|
265
288
|
.output(GitActionResultSchema),
|
|
266
289
|
cherryPick: procedure
|
|
267
290
|
.route({
|
|
@@ -341,7 +364,7 @@ export const gitContract = {
|
|
|
341
364
|
description:
|
|
342
365
|
"The current branch, its sync position against the remote, and every staged, unstaged and untracked path. The single-repo counterpart to the workspace-wide changes call.",
|
|
343
366
|
})
|
|
344
|
-
.input(
|
|
367
|
+
.input(GitRepoParamSchema)
|
|
345
368
|
.output(GitStatusSchema),
|
|
346
369
|
commit: procedure
|
|
347
370
|
.route({
|
|
@@ -393,7 +416,7 @@ export const gitContract = {
|
|
|
393
416
|
description:
|
|
394
417
|
"Every local branch with how many commits it sits ahead of and behind its remote counterpart, so a branch switcher can show sync state without a call per branch.",
|
|
395
418
|
})
|
|
396
|
-
.input(
|
|
419
|
+
.input(GitRepoParamSchema)
|
|
397
420
|
.output(GitBranchesSchema),
|
|
398
421
|
createBranchAt: procedure
|
|
399
422
|
.route({
|
|
@@ -424,7 +447,7 @@ export const gitContract = {
|
|
|
424
447
|
description:
|
|
425
448
|
"How far the current branch sits ahead of and behind its remote, as of the last fetch, plus whether a remote and working credentials exist at all. This is a read of what the daemon already knows, not a network call, which is why fetching is a separate button.",
|
|
426
449
|
})
|
|
427
|
-
.input(
|
|
450
|
+
.input(GitRepoParamSchema)
|
|
428
451
|
.output(GitRemoteStateSchema),
|
|
429
452
|
fetch: procedure
|
|
430
453
|
.route({
|
|
@@ -434,7 +457,7 @@ export const gitContract = {
|
|
|
434
457
|
description:
|
|
435
458
|
"Contacts the remote and updates the daemon's picture of it without touching your branch. Run this before trusting the sync position.",
|
|
436
459
|
})
|
|
437
|
-
.input(
|
|
460
|
+
.input(GitRepoParamSchema)
|
|
438
461
|
.output(GitActionResultSchema),
|
|
439
462
|
pull: procedure
|
|
440
463
|
.route({
|
|
@@ -444,7 +467,7 @@ export const gitContract = {
|
|
|
444
467
|
description:
|
|
445
468
|
"Fetches and integrates the remote's commits into the current branch. A pull that cannot fast-forward is reported in the answer rather than raised, because that is an ordinary thing to be told.",
|
|
446
469
|
})
|
|
447
|
-
.input(
|
|
470
|
+
.input(GitRepoParamSchema)
|
|
448
471
|
.output(GitActionResultSchema),
|
|
449
472
|
// Starts the push and returns at once; poll `pushState` for the verdict, since it runs the pre-push hook.
|
|
450
473
|
push: procedure
|
|
@@ -465,7 +488,7 @@ export const gitContract = {
|
|
|
465
488
|
description:
|
|
466
489
|
"The verdict, or the progress so far: where it is, the terminal it runs in, and for a push that did not go, git's last words and who refused it, the repository's own pre-push hook, the remote, or the transport. Idle when nothing has been started for this repository.",
|
|
467
490
|
})
|
|
468
|
-
.input(
|
|
491
|
+
.input(GitRepoParamSchema)
|
|
469
492
|
.output(PushRunSchema),
|
|
470
493
|
pushCancel: procedure
|
|
471
494
|
.route({
|
|
@@ -474,7 +497,7 @@ export const gitContract = {
|
|
|
474
497
|
summary: "Stop the push",
|
|
475
498
|
description: "Kills the run. It settles as cancelled; nothing that git had not already sent reaches the remote.",
|
|
476
499
|
})
|
|
477
|
-
.input(
|
|
500
|
+
.input(GitRepoParamSchema)
|
|
478
501
|
.output(OkSchema),
|
|
479
502
|
// Stage-all and commit-all as runs (index-run.ts): a stage over tens of thousands of files outlives the browser's
|
|
480
503
|
// header deadline, so it starts, answers at once and is polled, like a push.
|
|
@@ -496,7 +519,7 @@ export const gitContract = {
|
|
|
496
519
|
description:
|
|
497
520
|
"The repository's latest stage or commit run: its phase and file counts while it runs, then its verdict, the commit's answer, or what held it at the guardrail. Idle when none has been started since the sandbox last started.",
|
|
498
521
|
})
|
|
499
|
-
.input(
|
|
522
|
+
.input(GitRepoParamSchema)
|
|
500
523
|
.output(IndexRunSchema),
|
|
501
524
|
indexRunCancel: procedure
|
|
502
525
|
.route({
|
|
@@ -506,7 +529,7 @@ export const gitContract = {
|
|
|
506
529
|
description:
|
|
507
530
|
"Kills the git the run is waiting on. It settles as cancelled; a stage stopped part way leaves the index as git last wrote it, which unstaging takes back, and a commit stopped before git recorded it records nothing.",
|
|
508
531
|
})
|
|
509
|
-
.input(
|
|
532
|
+
.input(GitRepoParamSchema)
|
|
510
533
|
.output(OkSchema),
|
|
511
534
|
files: procedure
|
|
512
535
|
.route({
|
|
@@ -516,7 +539,7 @@ export const gitContract = {
|
|
|
516
539
|
description:
|
|
517
540
|
"The flat list of files git tracks, which is what a file picker or a search box wants. Ignored and untracked files are not in it.",
|
|
518
541
|
})
|
|
519
|
-
.input(
|
|
542
|
+
.input(GitRepoParamSchema)
|
|
520
543
|
.output(GitFilesSchema),
|
|
521
544
|
readFile: procedure
|
|
522
545
|
.route({
|
|
@@ -245,7 +245,7 @@ export const workspaceContract = {
|
|
|
245
245
|
"Removes one entry and everything under it. It goes to the trash rather than being erased, and the answer carries the id that brings it back through the restore call for a day. The path travels in the body rather than the address, the same as every other write in this group.",
|
|
246
246
|
})
|
|
247
247
|
.meta({ floor: "writer" })
|
|
248
|
-
.input(WorkspaceFileQuerySchema)
|
|
248
|
+
.input(WorkspaceFileQuerySchema.extend({ view: WorkspaceScopeSchema.optional() }))
|
|
249
249
|
.output(WorkspaceDeletedSchema),
|
|
250
250
|
restore: procedure
|
|
251
251
|
.route({
|
|
@@ -287,7 +287,7 @@ export const workspaceContract = {
|
|
|
287
287
|
"Unpacks a zip or tar already in the workspace into a new folder beside it, named after the archive. An archive that is one folder of its own name lands as that folder rather than as it twice, and a .gz, .bz2, .xz or .zst holding a single file lands as that file. Nothing is ever written over: the answer says where it landed. Formats with no tool here, such as .7z and .rar, are refused.",
|
|
288
288
|
})
|
|
289
289
|
.meta({ floor: "writer" })
|
|
290
|
-
.input(WorkspaceFileQuerySchema)
|
|
290
|
+
.input(WorkspaceFileQuerySchema.extend({ view: WorkspaceScopeSchema.optional() }))
|
|
291
291
|
.output(WorkspaceExtractSchema),
|
|
292
292
|
// An imported project lacks node_modules/.venv; until this says ready, its type checks and tests can mislead.
|
|
293
293
|
setup: procedure
|
package/src/schemas/diff.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EncodedGitViewSchema } from "./git/git-view.js";
|
|
1
2
|
// diff: one side of a file diff named by its source, for the routes that answer with something other than the text
|
|
2
3
|
// diff itself (bytes on /diff/raw, derived text on /diff/derived).
|
|
3
4
|
import { z } from "zod";
|
|
@@ -12,6 +13,7 @@ export const DiffSourceQuerySchema = z.discriminatedUnion("source", [
|
|
|
12
13
|
z
|
|
13
14
|
.object({
|
|
14
15
|
source: z.literal("working"),
|
|
16
|
+
view: EncodedGitViewSchema.optional(),
|
|
15
17
|
repo,
|
|
16
18
|
side: GitDiffSideSchema.describe("Which git side the row came from; a half-staged file is two different diffs."),
|
|
17
19
|
path,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ConversationIdSchema } from "../agent.js";
|
|
3
|
+
import { RepoBranchSchema } from "../shared.js";
|
|
4
|
+
|
|
5
|
+
const CommitShaSchema = z.string().regex(/^[0-9a-f]{40,64}$/);
|
|
6
|
+
|
|
7
|
+
export const BranchLandingsQuerySchema = RepoBranchSchema.extend({
|
|
8
|
+
before: CommitShaSchema.optional().describe("Continue before this landing from the previous page."),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const BranchLandingSchema = z.object({
|
|
12
|
+
sha: CommitShaSchema.describe("The landing commit, whose first parent is the state before this landing."),
|
|
13
|
+
short: z.string().describe("Its abbreviated hash."),
|
|
14
|
+
subject: z.string().describe("What the landing did."),
|
|
15
|
+
at: z.number().describe("When it was committed, in milliseconds."),
|
|
16
|
+
agent: ConversationIdSchema.describe("The session named by the commit's Conversation-Id trailer."),
|
|
17
|
+
});
|
|
18
|
+
export type BranchLanding = z.infer<typeof BranchLandingSchema>;
|
|
19
|
+
|
|
20
|
+
export const BranchLandingsSchema = z.object({
|
|
21
|
+
mainBranch: z.string().describe("The main line excluded from this branch's landings."),
|
|
22
|
+
commits: z.array(BranchLandingSchema).describe("Session commits on this branch's first-parent history, newest first, excluding the main line."),
|
|
23
|
+
next: CommitShaSchema.optional().describe("Continue before this commit. Absent on the last page."),
|
|
24
|
+
});
|
|
25
|
+
export type BranchLandings = z.infer<typeof BranchLandingsSchema>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { GitRepoParamSchema } from "./git-view.js";
|
|
1
2
|
// The Git Graph view over a repo's real commits.
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { RefNameSchema } from "../internal.js";
|
|
4
|
-
import { RepoParamSchema } from "../shared.js";
|
|
5
5
|
import { GitChangeSchema } from "./git.js";
|
|
6
6
|
// A hex sha, full or abbreviated; commit routes accept only this, never an arbitrary git revision expression.
|
|
7
7
|
const ShaSchema = z.string().regex(/^[0-9a-f]{4,64}$/);
|
|
@@ -38,7 +38,7 @@ export const GitLogSchema = z.object({
|
|
|
38
38
|
),
|
|
39
39
|
});
|
|
40
40
|
export type GitLog = z.infer<typeof GitLogSchema>;
|
|
41
|
-
export const GitLogQuerySchema =
|
|
41
|
+
export const GitLogQuerySchema = GitRepoParamSchema.extend({
|
|
42
42
|
limit: z.coerce.number().int().positive().max(2000).optional().describe("How many commits to return."),
|
|
43
43
|
// Page cursor: how many newer commits to skip before returning results.
|
|
44
44
|
skip: z.coerce
|
|
@@ -70,7 +70,7 @@ export const GitRemoteReposSchema = z.object({
|
|
|
70
70
|
export type GitRemoteRepos = z.infer<typeof GitRemoteReposSchema>;
|
|
71
71
|
// Writes one file to the default branch and publishes it: write, commit that path alone, push, in one call. `message`
|
|
72
72
|
// is the caller's, since it lands in the user's own commit history.
|
|
73
|
-
export const GitPublishFileSchema =
|
|
73
|
+
export const GitPublishFileSchema = GitRepoParamSchema.extend({
|
|
74
74
|
path: z.string().min(1).describe("Which file, relative to the repository."),
|
|
75
75
|
content: z.string().describe("Its whole new contents."),
|
|
76
76
|
message: z.string().min(1).describe("The commit message."),
|
|
@@ -92,7 +92,7 @@ export const GitPublishFileResultSchema = z.object({
|
|
|
92
92
|
),
|
|
93
93
|
});
|
|
94
94
|
export type GitPublishFileResult = z.infer<typeof GitPublishFileResultSchema>;
|
|
95
|
-
export const GitCommitDiffQuerySchema =
|
|
95
|
+
export const GitCommitDiffQuerySchema = GitRepoParamSchema.extend({ sha: ShaSchema.describe("Which commit.") });
|
|
96
96
|
// A commit's changed files, diffed against its first parent (a root commit against the empty tree); reuses `GitChange`
|
|
97
97
|
// so working-tree and commit diffs share one shape.
|
|
98
98
|
export const GitCommitDiffSchema = z.object({
|
|
@@ -103,32 +103,32 @@ export const GitCommitDiffSchema = z.object({
|
|
|
103
103
|
),
|
|
104
104
|
});
|
|
105
105
|
export type GitCommitDiff = z.infer<typeof GitCommitDiffSchema>;
|
|
106
|
-
export const GitCommitFileDiffQuerySchema =
|
|
106
|
+
export const GitCommitFileDiffQuerySchema = GitRepoParamSchema.extend({
|
|
107
107
|
sha: ShaSchema.describe("Which commit."),
|
|
108
108
|
path: z.string().min(1).describe("Which file in it."),
|
|
109
109
|
});
|
|
110
110
|
// Git write actions from the graph's context menu. Branch/tag only add a ref (no checkpoint); sequence ops, checkout,
|
|
111
111
|
// and reset are auto-checkpointed, and a conflict returns `ok:false` instead of throwing.
|
|
112
|
-
export const GitBranchCreateSchema =
|
|
112
|
+
export const GitBranchCreateSchema = GitRepoParamSchema.extend({
|
|
113
113
|
sha: ShaSchema.describe("Which commit to start it at."),
|
|
114
114
|
name: RefNameSchema.describe("The new branch's name."),
|
|
115
115
|
});
|
|
116
|
-
export const GitTagCreateSchema =
|
|
116
|
+
export const GitTagCreateSchema = GitRepoParamSchema.extend({
|
|
117
117
|
sha: ShaSchema.describe("Which commit to tag."),
|
|
118
118
|
name: RefNameSchema.describe("The tag's name."),
|
|
119
119
|
});
|
|
120
|
-
export const GitCheckoutSchema =
|
|
120
|
+
export const GitCheckoutSchema = GitRepoParamSchema.extend({ ref: RefNameSchema.describe("Where to switch to: a branch, a tag, or a commit.") });
|
|
121
121
|
// Deletes a tag locally, and on the named remote too; a tag never pushed there does not fail the local delete.
|
|
122
|
-
export const GitTagDeleteSchema =
|
|
122
|
+
export const GitTagDeleteSchema = GitRepoParamSchema.extend({
|
|
123
123
|
name: RefNameSchema.describe("Which tag."),
|
|
124
124
|
remote: RefNameSchema.optional().describe("Also delete it there. Leave it out to remove it locally only."),
|
|
125
125
|
});
|
|
126
126
|
// Pushes only the named tag, never every unpushed tag.
|
|
127
|
-
export const GitTagPushSchema =
|
|
127
|
+
export const GitTagPushSchema = GitRepoParamSchema.extend({
|
|
128
128
|
name: RefNameSchema.describe("Which tag."),
|
|
129
129
|
remote: RefNameSchema.describe("Which remote to send it to."),
|
|
130
130
|
});
|
|
131
|
-
export const GitResetSchema =
|
|
131
|
+
export const GitResetSchema = GitRepoParamSchema.extend({
|
|
132
132
|
sha: ShaSchema.describe("Which commit to move the branch to."),
|
|
133
133
|
mode: z
|
|
134
134
|
.enum(["soft", "mixed", "hard"])
|
|
@@ -136,7 +136,7 @@ export const GitResetSchema = RepoParamSchema.extend({
|
|
|
136
136
|
"How much to take with it: move the branch alone, also unstage, or also throw away what is on disk. The last one takes a checkpoint first.",
|
|
137
137
|
),
|
|
138
138
|
});
|
|
139
|
-
export const GitCommitActionSchema =
|
|
139
|
+
export const GitCommitActionSchema = GitRepoParamSchema.extend({ sha: ShaSchema.describe("Which commit to act on.") });
|
|
140
140
|
export const GitActionResultSchema = z.object({
|
|
141
141
|
ok: z.boolean().describe("Whether it worked."),
|
|
142
142
|
reason: z
|
|
@@ -166,17 +166,17 @@ export const StashListSchema = z.object({
|
|
|
166
166
|
});
|
|
167
167
|
// A stash ref as git numbers it (`stash@{0}`); constrained because it reaches a shell argument.
|
|
168
168
|
const StashRefSchema = z.string().regex(/^stash@\{\d{1,4}\}$/);
|
|
169
|
-
export const StashPushSchema =
|
|
169
|
+
export const StashPushSchema = GitRepoParamSchema.extend({
|
|
170
170
|
message: z.string().max(500).optional().describe("What to call it, so you know what it was later."),
|
|
171
171
|
includeUntracked: z.boolean().optional().describe("Also set aside files git is not yet tracking, which are otherwise left where they are."),
|
|
172
172
|
});
|
|
173
173
|
// `pop` drops the entry after a clean apply; `apply` keeps it, git's own resume-vs-try-again distinction.
|
|
174
|
-
export const StashApplySchema =
|
|
174
|
+
export const StashApplySchema = GitRepoParamSchema.extend({
|
|
175
175
|
ref: StashRefSchema.describe("Which entry."),
|
|
176
176
|
pop: z.boolean().optional().describe("Remove it from the stash once it has been applied cleanly."),
|
|
177
177
|
});
|
|
178
|
-
export const StashRefParamSchema =
|
|
179
|
-
export const StashDiffQuerySchema =
|
|
178
|
+
export const StashRefParamSchema = GitRepoParamSchema.extend({ ref: StashRefSchema.describe("Which entry.") });
|
|
179
|
+
export const StashDiffQuerySchema = GitRepoParamSchema.extend({ ref: StashRefSchema.describe("Which entry.") });
|
|
180
180
|
// The last ref move on this branch, and whether it can be undone; complements Checkpoints, which restores the working
|
|
181
181
|
// tree instead. `previousSha` doubles as a concurrency token: refused if the branch moved since it was read.
|
|
182
182
|
export const UndoKindSchema = z.enum(["commit", "amend", "merge", "rebase", "cherry-pick", "revert", "reset", "pull", "other"]);
|
|
@@ -203,7 +203,7 @@ export const GitUndoStateSchema = z.object({
|
|
|
203
203
|
});
|
|
204
204
|
export type GitUndoState = z.infer<typeof GitUndoStateSchema>;
|
|
205
205
|
// `previousSha` must match what the caller was shown; `discardChanges` picks a hard reset over a soft one.
|
|
206
|
-
export const GitUndoSchema =
|
|
206
|
+
export const GitUndoSchema = GitRepoParamSchema.extend({
|
|
207
207
|
previousSha: ShaSchema.describe(
|
|
208
208
|
"Where to go back to, from the matching read. It is also proof you looked: one prepared against a stale view is refused.",
|
|
209
209
|
),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { RepoParamSchema } from "../shared.js";
|
|
3
|
+
import { WorkspaceScopeSchema } from "../workspace/workspace-tree.js";
|
|
4
|
+
|
|
5
|
+
export const GitViewSchema = WorkspaceScopeSchema.refine(
|
|
6
|
+
(view) => !(view.agent !== undefined && (view.branch !== undefined || view.repo !== undefined)) && (view.repo === undefined || view.branch !== undefined),
|
|
7
|
+
{ message: "Choose one checkout: a conversation, a branch, or the shared workspace." },
|
|
8
|
+
);
|
|
9
|
+
export type GitView = z.infer<typeof GitViewSchema>;
|
|
10
|
+
|
|
11
|
+
export const GitViewQuerySchema = z.object({ view: GitViewSchema.optional() });
|
|
12
|
+
export const GitRepoParamSchema = RepoParamSchema.extend({ view: GitViewSchema.optional() });
|
|
13
|
+
|
|
14
|
+
export const EncodedGitViewSchema = z.union([
|
|
15
|
+
GitViewSchema,
|
|
16
|
+
z.string().transform((value, ctx) => {
|
|
17
|
+
try { return JSON.parse(value); } catch {
|
|
18
|
+
ctx.addIssue({ code: "custom", message: "Invalid checkout selection." });
|
|
19
|
+
return z.NEVER;
|
|
20
|
+
}
|
|
21
|
+
}).pipe(GitViewSchema),
|
|
22
|
+
]);
|
package/src/schemas/git/git.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { GitRepoParamSchema } from "./git-view.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { AgentProviderSchema } from "../agent.js";
|
|
3
4
|
import { LandConflictSchema, LandedMessageSchema } from "../agents.js";
|
|
4
5
|
import { CommandRunSchema } from "../ci.js";
|
|
5
6
|
import { RefNameSchema } from "../internal.js";
|
|
6
|
-
import { MainBranchSchema
|
|
7
|
+
import { MainBranchSchema } from "../shared.js";
|
|
7
8
|
|
|
8
|
-
// Which
|
|
9
|
-
// defaulted.
|
|
9
|
+
// Which working-tree diff a row names: a path can be both staged and edited again, so side is required.
|
|
10
10
|
// staged: index vs HEAD.
|
|
11
11
|
// unstaged: worktree vs index (untracked ⇒ no before side).
|
|
12
12
|
// conflicted: HEAD vs worktree, markers included (no stage 0 to diff against).
|
|
@@ -65,7 +65,7 @@ const oneTarget = (target: GitTarget): boolean => target.paths === undefined ||
|
|
|
65
65
|
// { paths }: stage exactly those paths, then commit.
|
|
66
66
|
// Never `commit --only`: a partial commit over a half-staged file would record the worktree while the row showed the
|
|
67
67
|
// index.
|
|
68
|
-
export const CommitSchema =
|
|
68
|
+
export const CommitSchema = GitRepoParamSchema.extend({
|
|
69
69
|
message: z.string().min(1).describe("The commit message."),
|
|
70
70
|
stage: GitTargetSchema.refine(oneTarget, ONE_TARGET)
|
|
71
71
|
.optional()
|
|
@@ -73,7 +73,7 @@ export const CommitSchema = RepoParamSchema.extend({
|
|
|
73
73
|
"What to stage before committing. Leave it out to record the index exactly as it stands; give it an empty object to stage everything first.",
|
|
74
74
|
),
|
|
75
75
|
});
|
|
76
|
-
export const DiscardSchema =
|
|
76
|
+
export const DiscardSchema = GitRepoParamSchema.extend(GitTargetSchema.shape)
|
|
77
77
|
.describe("What to throw away. Neither paths nor a scope discards every uncommitted change in the repository.")
|
|
78
78
|
.refine(oneTarget, ONE_TARGET);
|
|
79
79
|
// Index-only moves; nothing on disk changes, so neither needs a checkpoint. An empty target means the whole repository
|
|
@@ -83,7 +83,7 @@ export const DiscardSchema = RepoParamSchema.extend(GitTargetSchema.shape)
|
|
|
83
83
|
// merge's clean result survives one on/off. It names its own target, so it goes alone.
|
|
84
84
|
const oneIndexMove = (move: GitTarget & { readonly chip?: string | undefined }): boolean =>
|
|
85
85
|
oneTarget(move) && (move.chip === undefined || (move.paths === undefined && move.scope === undefined));
|
|
86
|
-
export const GitIndexMoveSchema =
|
|
86
|
+
export const GitIndexMoveSchema = GitRepoParamSchema.extend(GitTargetSchema.shape)
|
|
87
87
|
.extend({
|
|
88
88
|
chip: z
|
|
89
89
|
.string()
|
|
@@ -97,7 +97,7 @@ export const GitIndexMoveSchema = RepoParamSchema.extend(GitTargetSchema.shape)
|
|
|
97
97
|
.refine(oneIndexMove, { message: "name paths, a scope or a chip, not more than one" });
|
|
98
98
|
// No separate "set upstream" flag: the daemon runs `push -u` exactly when the branch has none yet, which is never
|
|
99
99
|
// destructive.
|
|
100
|
-
export const PushSchema =
|
|
100
|
+
export const PushSchema = GitRepoParamSchema.extend({
|
|
101
101
|
branch: z
|
|
102
102
|
.string()
|
|
103
103
|
.min(1)
|
|
@@ -124,12 +124,12 @@ export const PushRunSchema = CommandRunSchema.extend({
|
|
|
124
124
|
),
|
|
125
125
|
});
|
|
126
126
|
export type PushRun = z.infer<typeof PushRunSchema>;
|
|
127
|
-
export const GitFileQuerySchema =
|
|
128
|
-
export const GitFileWriteSchema =
|
|
127
|
+
export const GitFileQuerySchema = GitRepoParamSchema.extend({ path: z.string().min(1).describe("The file to read, relative to the repository root.") });
|
|
128
|
+
export const GitFileWriteSchema = GitRepoParamSchema.extend({
|
|
129
129
|
path: z.string().min(1).describe("Where to write, relative to the repository root. Missing folders are created."),
|
|
130
130
|
content: z.string().describe("The file's whole new contents."),
|
|
131
131
|
});
|
|
132
|
-
export const GitFileDiffQuerySchema =
|
|
132
|
+
export const GitFileDiffQuerySchema = GitRepoParamSchema.extend({
|
|
133
133
|
path: z.string().min(1).describe("The file, relative to the repository root."),
|
|
134
134
|
side: GitDiffSideSchema.describe(
|
|
135
135
|
"Which comparison you want. A file that is staged and then edited again has genuinely different answers for each, which is why this is required rather than assumed.",
|
|
@@ -234,13 +234,13 @@ export const GitBranchesSchema = z.object({
|
|
|
234
234
|
});
|
|
235
235
|
export type GitBranches = z.infer<typeof GitBranchesSchema>;
|
|
236
236
|
// Creates at `start` (sha or ref; absent means HEAD); `checkout` switches to it immediately.
|
|
237
|
-
export const GitBranchCreateAtSchema =
|
|
237
|
+
export const GitBranchCreateAtSchema = GitRepoParamSchema.extend({
|
|
238
238
|
name: RefNameSchema.describe("The new branch's name."),
|
|
239
239
|
start: z.string().min(1).optional().describe("Where to start it: a commit or another branch. Leave it out to start from where you are."),
|
|
240
240
|
checkout: z.boolean().optional().describe("Switch to it as well as creating it."),
|
|
241
241
|
});
|
|
242
242
|
// `force` is the deliberate retry after git refuses to drop an unmerged branch.
|
|
243
|
-
export const GitBranchDeleteSchema =
|
|
243
|
+
export const GitBranchDeleteSchema = GitRepoParamSchema.extend({
|
|
244
244
|
name: RefNameSchema.describe("The branch to delete."),
|
|
245
245
|
force: z
|
|
246
246
|
.boolean()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { GitRepoParamSchema } from "./git-view.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { CommandRunSchema } from "../ci.js";
|
|
3
|
-
import { RepoParamSchema } from "../shared.js";
|
|
4
4
|
import { CommitResultSchema, GitTargetSchema } from "./git.js";
|
|
5
5
|
|
|
6
6
|
// Stage-all and commit-all as runs the daemon keeps, not requests held open: over a tree of tens of thousands of
|
|
@@ -40,7 +40,7 @@ export type IndexRunHold = z.infer<typeof IndexRunHoldSchema>;
|
|
|
40
40
|
|
|
41
41
|
// Flat rather than a union on `op`: the route's path parameter merges into the input, which a discriminated union cannot
|
|
42
42
|
// take, and the one cross-field rule (a commit needs a message) is a refine.
|
|
43
|
-
export const IndexRunStartSchema =
|
|
43
|
+
export const IndexRunStartSchema = GitRepoParamSchema.extend({
|
|
44
44
|
op: IndexRunOpSchema.describe("Stage, or commit (staging `target` first when given)."),
|
|
45
45
|
target: GitTargetSchema.optional().describe(
|
|
46
46
|
"What to stage. For a stage, leave it out for the whole repository. For a commit, leave it out to record the index exactly as it stands, or give an empty object to stage everything first.",
|
|
@@ -9,7 +9,7 @@ export const WorkspaceScopeSchema = z.object({
|
|
|
9
9
|
"Read a conversation's own private copy of the workspace rather than the shared tree. Leave it out for the shared tree. A conversation that is not working privately resolves back to the shared tree rather than failing, so a link need not know which mode it runs in.",
|
|
10
10
|
),
|
|
11
11
|
// A branch the shared checkout is not on (it stays on its main line): read from a checkout the daemon keeps of it,
|
|
12
|
-
//
|
|
12
|
+
// inside `repo` from the branch, everywhere else from the shared tree. Never together with `agent`.
|
|
13
13
|
branch: BranchNameSchema.optional()
|
|
14
14
|
.describe(
|
|
15
15
|
"Read a branch of one repository as it stands, without the shared workspace leaving its main line: files inside that repository come from the branch, everything else from the shared tree. Never together with `agent`.",
|
|
@@ -385,11 +385,11 @@ export const WorkspaceResolveSchema = z.object({
|
|
|
385
385
|
export type WorkspaceResolve = z.infer<typeof WorkspaceResolveSchema>;
|
|
386
386
|
// Direct file management (delete, new folder, rename/move, copy). Byte writes and editor saves go through POST
|
|
387
387
|
// /workspace/upload instead, since oRPC can't carry a body.
|
|
388
|
-
export const WorkspaceDirSchema = z.object({ path: z.string().min(1).describe("The folder to create. Missing folders above it are created too.") });
|
|
388
|
+
export const WorkspaceDirSchema = z.object({ path: z.string().min(1).describe("The folder to create. Missing folders above it are created too.") }).extend({ view: WorkspaceScopeSchema.optional() });
|
|
389
389
|
export const WorkspaceMoveSchema = z.object({
|
|
390
390
|
from: z.string().min(1).describe("What to move or copy, as a workspace path."),
|
|
391
391
|
to: z.string().min(1).describe("Where it should end up. Changing only the last part is how you rename something."),
|
|
392
|
-
});
|
|
392
|
+
}).extend({ view: WorkspaceScopeSchema.optional() });
|
|
393
393
|
// Unpacking an archive already in the workspace. Nothing is overwritten, so the answer is where it actually landed,
|
|
394
394
|
// which is not always the name the caller would have guessed.
|
|
395
395
|
export const WorkspaceExtractSchema = z.object({
|
|
@@ -411,7 +411,7 @@ export const WorkspaceDeletedSchema = z.object({
|
|
|
411
411
|
export type WorkspaceDeleted = z.infer<typeof WorkspaceDeletedSchema>;
|
|
412
412
|
export const WorkspaceRestoreSchema = z.object({
|
|
413
413
|
trashed: z.string().min(1).describe("The trash id a delete answered with."),
|
|
414
|
-
});
|
|
414
|
+
}).extend({ view: WorkspaceScopeSchema.optional() });
|
|
415
415
|
export const WorkspaceRestoredSchema = z.object({
|
|
416
416
|
path: z
|
|
417
417
|
.string()
|