@deepseek-ai/dsh-experimental-client-ui-forge 0.0.0-stage → 0.2.2-alpha.2
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/LICENSE +21 -0
- package/README.i18n.yaml +37 -0
- package/README.md +134 -2
- package/README.zh.md +135 -0
- package/lib/client.js +8745 -0
- package/lib/index.js +3131 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +2222 -0
- package/lib/typert.remote-client.d.ts +79 -0
- package/lib/typert.remote-client.js +1284 -0
- package/lib/types/client/ActionToast.d.ts +14 -0
- package/lib/types/client/ChangeRequestCard.d.ts +54 -0
- package/lib/types/client/ChangesTab.d.ts +49 -0
- package/lib/types/client/ChangesTabTitle.d.ts +13 -0
- package/lib/types/client/DiffFile.d.ts +75 -0
- package/lib/types/client/FileLabel.d.ts +20 -0
- package/lib/types/client/ForgeTab.d.ts +54 -0
- package/lib/types/client/ForgeTabTitle.d.ts +11 -0
- package/lib/types/client/HeaderButton.d.ts +27 -0
- package/lib/types/client/LocalChangesCard.d.ts +29 -0
- package/lib/types/client/RefreshGlyph.d.ts +18 -0
- package/lib/types/client/SessionHoverForge.d.ts +20 -0
- package/lib/types/client/SessionRowForge.d.ts +39 -0
- package/lib/types/client/WorktreeProgress.d.ts +44 -0
- package/lib/types/client/WorktreeToggle.d.ts +42 -0
- package/lib/types/client/changes-address.d.ts +70 -0
- package/lib/types/client/changes-store.d.ts +39 -0
- package/lib/types/client/checkout.d.ts +34 -0
- package/lib/types/client/diff-rows.d.ts +96 -0
- package/lib/types/client/format.d.ts +21 -0
- package/lib/types/client/glyphs.d.ts +33 -0
- package/lib/types/client/index.d.ts +25 -0
- package/lib/types/client/locales.d.ts +228 -0
- package/lib/types/client/mount.d.ts +17 -0
- package/lib/types/client/session-list.d.ts +46 -0
- package/lib/types/client/source.d.ts +146 -0
- package/lib/types/client/status.d.ts +95 -0
- package/lib/types/diff.d.ts +32 -0
- package/lib/types/git.d.ts +93 -0
- package/lib/types/index.d.ts +275 -0
- package/lib/types/local-diff.d.ts +93 -0
- package/lib/types/panel.d.ts +135 -0
- package/lib/types/parse.d.ts +57 -0
- package/lib/types/patch-cache.d.ts +33 -0
- package/lib/types/states.d.ts +89 -0
- package/lib/types/types.d.ts +395 -0
- package/lib/types/worktree.d.ts +225 -0
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +123 -3
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/** Browser-safe panel state, the worktree request record, Remote error codes, and Host configuration of the forge panel. */
|
|
2
|
+
import type { ChangeRequestSnapshot, ForgeReadiness, ForgeRepository } from '@deepseek-ai/dsh-experimental-forge/types';
|
|
3
|
+
import type { SessionChangeRequest } from '@deepseek-ai/dsh-experimental-forge-session/types';
|
|
4
|
+
/** Git facts for the checkout that contains the Session's current directory. */
|
|
5
|
+
export interface ForgeCheckout {
|
|
6
|
+
/** Top-level directory of the checkout. */
|
|
7
|
+
readonly root: string;
|
|
8
|
+
/** Checked-out branch, or null when HEAD is detached. */
|
|
9
|
+
readonly branch: string | null;
|
|
10
|
+
/** Whether the checkout is a linked worktree of another checkout's repository. */
|
|
11
|
+
readonly linked: boolean;
|
|
12
|
+
/** Abbreviated commit HEAD names, or null while the checked-out branch has no commit. */
|
|
13
|
+
readonly commit: string | null;
|
|
14
|
+
}
|
|
15
|
+
/** Inspection result for the Session's current directory. */
|
|
16
|
+
export type ForgeCheckoutState =
|
|
17
|
+
/** The first inspection has not finished. */
|
|
18
|
+
{
|
|
19
|
+
readonly state: 'pending';
|
|
20
|
+
}
|
|
21
|
+
/** The current directory is not inside a Git checkout. */
|
|
22
|
+
| {
|
|
23
|
+
readonly state: 'none';
|
|
24
|
+
}
|
|
25
|
+
/** Git could not run or reported an error. */
|
|
26
|
+
| {
|
|
27
|
+
readonly state: 'failed';
|
|
28
|
+
readonly message: string;
|
|
29
|
+
}
|
|
30
|
+
/** The checkout facts. */
|
|
31
|
+
| {
|
|
32
|
+
readonly state: 'ready';
|
|
33
|
+
readonly checkout: ForgeCheckout;
|
|
34
|
+
};
|
|
35
|
+
/** The worktree the panel created and entered for a Session before its first step. */
|
|
36
|
+
export interface ForgeSessionWorktree {
|
|
37
|
+
/** Canonical checkout directory. */
|
|
38
|
+
readonly path: string;
|
|
39
|
+
/** Branch created for the checkout. */
|
|
40
|
+
readonly branch: string;
|
|
41
|
+
/** Requested base branch, or null when the checkout started from HEAD of the source checkout. */
|
|
42
|
+
readonly from: string | null;
|
|
43
|
+
/** Commit object name the branch started from. */
|
|
44
|
+
readonly baseCommit: string;
|
|
45
|
+
/** Canonical root of the source checkout. */
|
|
46
|
+
readonly repositoryRoot: string;
|
|
47
|
+
}
|
|
48
|
+
/** Payload of the `plugin:client-ui-forge/worktree` record. */
|
|
49
|
+
export type WorktreeRecord =
|
|
50
|
+
/** Create a worktree before the Session's first step, starting from `from`, or from HEAD when it is null. */
|
|
51
|
+
{
|
|
52
|
+
readonly action: 'request';
|
|
53
|
+
readonly from: string | null;
|
|
54
|
+
}
|
|
55
|
+
/** Withdraw the open request. */
|
|
56
|
+
| {
|
|
57
|
+
readonly action: 'cancel';
|
|
58
|
+
}
|
|
59
|
+
/** The requested worktree was created and became the Session's working directory. */
|
|
60
|
+
| {
|
|
61
|
+
readonly action: 'created';
|
|
62
|
+
readonly worktree: ForgeSessionWorktree;
|
|
63
|
+
}
|
|
64
|
+
/** Restoration started; the checkout stays unavailable until restoration completes. */
|
|
65
|
+
| {
|
|
66
|
+
readonly action: 'restoring';
|
|
67
|
+
}
|
|
68
|
+
/** The recorded worktree was completely restored. */
|
|
69
|
+
| {
|
|
70
|
+
readonly action: 'restored';
|
|
71
|
+
};
|
|
72
|
+
/** One open worktree request. */
|
|
73
|
+
export interface ForgeWorktreeRequest {
|
|
74
|
+
/** Base branch, or null for HEAD of the source checkout. */
|
|
75
|
+
readonly from: string | null;
|
|
76
|
+
}
|
|
77
|
+
/** Host-only state of the `forgeWorktree` projection. */
|
|
78
|
+
export interface ForgeWorktreeState {
|
|
79
|
+
/** Open request, or null without one. */
|
|
80
|
+
readonly request: ForgeWorktreeRequest | null;
|
|
81
|
+
/** Created worktree, or null before creation. */
|
|
82
|
+
readonly created: ForgeSessionWorktree | null;
|
|
83
|
+
/** Whether a turn has started; requests and withdrawals recorded afterwards are ignored. */
|
|
84
|
+
readonly locked: boolean;
|
|
85
|
+
/** Whether a step has started; no worktree is created afterwards. */
|
|
86
|
+
readonly stepped: boolean;
|
|
87
|
+
/** The Session's working directory as its log last recorded it, or null when none is recorded. */
|
|
88
|
+
readonly cwd: string | null;
|
|
89
|
+
/** Whether a restoration started without a successful completion, including across reloads. */
|
|
90
|
+
readonly restoring: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** Why the Session's checkout cannot host a new worktree. */
|
|
93
|
+
export type ForgeWorktreeBlocker =
|
|
94
|
+
/** The current directory is not inside a Git checkout. */
|
|
95
|
+
'not-git'
|
|
96
|
+
/** The Session's sandbox cannot write the checkout or its Git directory, as for a linked worktree outside the writable root. */
|
|
97
|
+
| 'outside-writable-root'
|
|
98
|
+
/** The Session runs read-only. */
|
|
99
|
+
| 'read-only';
|
|
100
|
+
/** One running worktree creation. */
|
|
101
|
+
export interface ForgeWorktreeCreation {
|
|
102
|
+
/** Running step: `prepare` validates and creates the branch, then `checkout` writes the files. */
|
|
103
|
+
readonly phase: 'prepare' | 'checkout';
|
|
104
|
+
/** Branch the attempt creates. */
|
|
105
|
+
readonly branch: string;
|
|
106
|
+
/** Base branch, or null for HEAD. */
|
|
107
|
+
readonly from: string | null;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a message waits for the creation before its turn starts. Only
|
|
110
|
+
* such a creation can be stopped, after which the message keeps waiting; a
|
|
111
|
+
* creation at the first step serves a message the Session already holds.
|
|
112
|
+
*/
|
|
113
|
+
readonly held: boolean;
|
|
114
|
+
}
|
|
115
|
+
/** One running restoration of the removed worktree a Session works in. */
|
|
116
|
+
export interface ForgeWorktreeRestoration {
|
|
117
|
+
/** Running step: `prepare` registers the checkout again, creating a missing branch, then `checkout` writes the files. */
|
|
118
|
+
readonly phase: 'prepare' | 'checkout';
|
|
119
|
+
}
|
|
120
|
+
/** The last attempt to create the requested worktree for a message, which failed. */
|
|
121
|
+
export interface ForgeWorktreeFailure {
|
|
122
|
+
/** Branch the attempt created, or null when it failed before naming one. */
|
|
123
|
+
readonly branch: string | null;
|
|
124
|
+
/** Base branch of the attempt, or null for HEAD. */
|
|
125
|
+
readonly from: string | null;
|
|
126
|
+
/** Step that failed. */
|
|
127
|
+
readonly phase: 'prepare' | 'checkout';
|
|
128
|
+
/** Failure text. */
|
|
129
|
+
readonly message: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* What a message waits for before its turn starts: the creation of the
|
|
133
|
+
* requested worktree, or the restoration or leaving of the removed worktree
|
|
134
|
+
* the Session works in.
|
|
135
|
+
*/
|
|
136
|
+
export type ForgeWorktreeWaiting = 'creation' | 'restoration';
|
|
137
|
+
/** The recorded worktree whose directory is missing, invalid, or incompletely restored. */
|
|
138
|
+
export interface ForgeMissingWorktree {
|
|
139
|
+
/** Whether its branch exists, or null when an incomplete restoration cannot inspect it. */
|
|
140
|
+
readonly branchExists: boolean | null;
|
|
141
|
+
}
|
|
142
|
+
/** Worktree facts of one Session in the panel state. */
|
|
143
|
+
export interface ForgePanelWorktree {
|
|
144
|
+
/**
|
|
145
|
+
* Whether the Session can still request or withdraw a worktree: a worktree
|
|
146
|
+
* service is mounted, no turn has started, and none was created.
|
|
147
|
+
*/
|
|
148
|
+
readonly editable: boolean;
|
|
149
|
+
/** Why the checkout cannot host a worktree, or null when it can, before the first inspection, and after a failed one. */
|
|
150
|
+
readonly blocker: ForgeWorktreeBlocker | null;
|
|
151
|
+
/** Open request, or null without one. */
|
|
152
|
+
readonly request: ForgeWorktreeRequest | null;
|
|
153
|
+
/** Created worktree, or null before creation. */
|
|
154
|
+
readonly created: ForgeSessionWorktree | null;
|
|
155
|
+
/** Running creation, or null. */
|
|
156
|
+
readonly creation: ForgeWorktreeCreation | null;
|
|
157
|
+
/**
|
|
158
|
+
* The last failed attempt of the creation a message waits for, or null. It
|
|
159
|
+
* clears when another attempt starts, when the request changes or is
|
|
160
|
+
* withdrawn, and when the wait ends.
|
|
161
|
+
*/
|
|
162
|
+
readonly failure: ForgeWorktreeFailure | null;
|
|
163
|
+
/** The created worktree the Session works in when its directory is gone, or null. */
|
|
164
|
+
readonly missing: ForgeMissingWorktree | null;
|
|
165
|
+
/** Running restoration of the removed worktree, or null. */
|
|
166
|
+
readonly restoration: ForgeWorktreeRestoration | null;
|
|
167
|
+
/** What a message of the Session waits for before its turn starts, or null while none waits. */
|
|
168
|
+
readonly waiting: ForgeWorktreeWaiting | null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The last polled state of one change request that a listed Session binds, as
|
|
172
|
+
* the Session list shows it.
|
|
173
|
+
*/
|
|
174
|
+
export type ForgeChangeRequestListState = Pick<ChangeRequestSnapshot, 'url' | 'title' | 'state' | 'draft' | 'checksRollup' | 'reviewDecision' | 'mergeability'> & {
|
|
175
|
+
/** Change request number on its code host. */
|
|
176
|
+
readonly number: number;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* One frame of `forgePanel.changeRequestStates`: the known state of every
|
|
180
|
+
* change request the reader may see first, then the states that changed or
|
|
181
|
+
* became visible since the previous frame.
|
|
182
|
+
*/
|
|
183
|
+
export type ForgeChangeRequestStatesFrame = {
|
|
184
|
+
readonly type: 'baseline';
|
|
185
|
+
readonly states: readonly ForgeChangeRequestListState[];
|
|
186
|
+
} | {
|
|
187
|
+
readonly type: 'changed';
|
|
188
|
+
readonly states: readonly ForgeChangeRequestListState[];
|
|
189
|
+
};
|
|
190
|
+
/** One bound change request in the panel state. */
|
|
191
|
+
export interface ForgePanelChangeRequest extends SessionChangeRequest {
|
|
192
|
+
/** Latest snapshot a poll returned, kept while later polls fail, or null before the first successful poll. */
|
|
193
|
+
readonly snapshot: ChangeRequestSnapshot | null;
|
|
194
|
+
}
|
|
195
|
+
/** Everything the panel shows for one Session. */
|
|
196
|
+
export interface ForgePanelState {
|
|
197
|
+
/** Current working directory of the Session. */
|
|
198
|
+
readonly directory: string;
|
|
199
|
+
/** Inspection result for `directory`. */
|
|
200
|
+
readonly checkout: ForgeCheckoutState;
|
|
201
|
+
/** Code host repository of the checkout's upstream remote or `origin`, or null when no provider serves them. */
|
|
202
|
+
readonly repository: ForgeRepository | null;
|
|
203
|
+
/** Sign-in state for the repository's host, or null before the first probe and without a repository. */
|
|
204
|
+
readonly readiness: ForgeReadiness | null;
|
|
205
|
+
/** Visible change request bindings with their latest polling results, in first-recorded order. */
|
|
206
|
+
readonly changeRequests: readonly ForgePanelChangeRequest[];
|
|
207
|
+
/** Worktree request and creation state. */
|
|
208
|
+
readonly worktree: ForgePanelWorktree;
|
|
209
|
+
/**
|
|
210
|
+
* Files the `branch` scope changes, or null before the first inspection,
|
|
211
|
+
* outside a checkout, and without a fork point.
|
|
212
|
+
*/
|
|
213
|
+
readonly local: ForgeLocalChanges | null;
|
|
214
|
+
}
|
|
215
|
+
/** Local branches offered as the base of a new worktree. */
|
|
216
|
+
export interface ForgeBranches {
|
|
217
|
+
/** Checked-out branch, or null when HEAD is detached. */
|
|
218
|
+
readonly current: string | null;
|
|
219
|
+
/** Local branch names, `current` first and then most recently committed first, at most `maxBranches`. */
|
|
220
|
+
readonly branches: readonly string[];
|
|
221
|
+
}
|
|
222
|
+
/** Which local changes a diff covers; each reads the Session's checkout through Git. */
|
|
223
|
+
export type ForgeLocalScope =
|
|
224
|
+
/**
|
|
225
|
+
* The working tree and untracked files against the fork point: the base commit of the worktree the
|
|
226
|
+
* Session created, else the merge base of HEAD with the default branch of the code host remote.
|
|
227
|
+
*/
|
|
228
|
+
{
|
|
229
|
+
readonly kind: 'branch';
|
|
230
|
+
}
|
|
231
|
+
/** The working tree and untracked files against HEAD. */
|
|
232
|
+
| {
|
|
233
|
+
readonly kind: 'uncommitted';
|
|
234
|
+
}
|
|
235
|
+
/** The working tree and untracked files against the index. */
|
|
236
|
+
| {
|
|
237
|
+
readonly kind: 'unstaged';
|
|
238
|
+
}
|
|
239
|
+
/** The index against HEAD. */
|
|
240
|
+
| {
|
|
241
|
+
readonly kind: 'staged';
|
|
242
|
+
};
|
|
243
|
+
/** One hunk of a file diff. */
|
|
244
|
+
export interface ForgeDiffHunk {
|
|
245
|
+
/** First old line the hunk covers, or the old line it comes before when it covers none. */
|
|
246
|
+
readonly oldStart: number;
|
|
247
|
+
/** Old lines the hunk covers. */
|
|
248
|
+
readonly oldLines: number;
|
|
249
|
+
/** First new line the hunk covers, or the new line it comes before when it covers none. */
|
|
250
|
+
readonly newStart: number;
|
|
251
|
+
/** New lines the hunk covers. */
|
|
252
|
+
readonly newLines: number;
|
|
253
|
+
/** Lines in patch form: a leading space for context, `+` for added, `-` for deleted, and `\` for a missing final newline. */
|
|
254
|
+
readonly lines: readonly string[];
|
|
255
|
+
}
|
|
256
|
+
/** How one file changed. */
|
|
257
|
+
export type ForgeDiffStatus = 'added' | 'deleted' | 'modified' | 'renamed';
|
|
258
|
+
/** One changed file of a diff. */
|
|
259
|
+
export interface ForgeDiffFile {
|
|
260
|
+
/** Path relative to the repository root after the change, or before it for a deleted file. */
|
|
261
|
+
readonly path: string;
|
|
262
|
+
/** Path before a rename, else null. */
|
|
263
|
+
readonly previousPath: string | null;
|
|
264
|
+
/** How the file changed. */
|
|
265
|
+
readonly status: ForgeDiffStatus;
|
|
266
|
+
/** Whether the content is binary, which carries no hunks. */
|
|
267
|
+
readonly binary: boolean;
|
|
268
|
+
/** Whether an untracked file exceeds `maxDiffBytes`, so it carries no hunks. */
|
|
269
|
+
readonly oversized: boolean;
|
|
270
|
+
/** Whether Git does not track the file yet; only local diffs list such files. */
|
|
271
|
+
readonly untracked: boolean;
|
|
272
|
+
/** Lines added. */
|
|
273
|
+
readonly additions: number;
|
|
274
|
+
/** Lines deleted. */
|
|
275
|
+
readonly deletions: number;
|
|
276
|
+
/** Hunks in file order; none for a binary file or a change of mode or name only. */
|
|
277
|
+
readonly hunks: readonly ForgeDiffHunk[];
|
|
278
|
+
}
|
|
279
|
+
/** Local changes of the Session's checkout in one scope. */
|
|
280
|
+
export interface ForgeLocalDiff {
|
|
281
|
+
/** Ref or abbreviated commit the `branch` scope compares with, such as `origin/master`; null for other scopes. */
|
|
282
|
+
readonly base: string | null;
|
|
283
|
+
/** Changed files in Git's path order, untracked files last. */
|
|
284
|
+
readonly files: readonly ForgeDiffFile[];
|
|
285
|
+
/** Untracked files left out beyond `maxUntrackedFiles`. */
|
|
286
|
+
readonly omitted: number;
|
|
287
|
+
}
|
|
288
|
+
/** Changes of a change request as its code host computes them. */
|
|
289
|
+
export interface ForgeChangeRequestDiff {
|
|
290
|
+
/** Head commit the diff describes. */
|
|
291
|
+
readonly headSha: string;
|
|
292
|
+
/** Changed files in the host's order. */
|
|
293
|
+
readonly files: readonly ForgeDiffFile[];
|
|
294
|
+
/**
|
|
295
|
+
* Commits the checkout's branch has beyond the head when that branch is the change request's head
|
|
296
|
+
* branch and the head commit is present locally; null otherwise.
|
|
297
|
+
*/
|
|
298
|
+
readonly localAhead: number | null;
|
|
299
|
+
/** Web page of each changed file at the head commit, by path. */
|
|
300
|
+
readonly fileUrls: Readonly<Record<string, string>>;
|
|
301
|
+
}
|
|
302
|
+
/** One file the `branch` scope changes, without its hunks. */
|
|
303
|
+
export interface ForgeChangedFile {
|
|
304
|
+
/** Path relative to the repository root after the change. */
|
|
305
|
+
readonly path: string;
|
|
306
|
+
/** Lines added, or 0 for a binary file. */
|
|
307
|
+
readonly additions: number;
|
|
308
|
+
/** Lines deleted, or 0 for a binary file. */
|
|
309
|
+
readonly deletions: number;
|
|
310
|
+
/** Whether the content is binary. */
|
|
311
|
+
readonly binary: boolean;
|
|
312
|
+
}
|
|
313
|
+
/** Size of the `branch` scope, which the panel's local changes card shows. */
|
|
314
|
+
export interface ForgeLocalChanges {
|
|
315
|
+
/** Ref or abbreviated commit the scope compares with. */
|
|
316
|
+
readonly base: string;
|
|
317
|
+
/** Changed files in Git's path order, untracked files last, at most `maxUntrackedFiles` of those. */
|
|
318
|
+
readonly files: readonly ForgeChangedFile[];
|
|
319
|
+
}
|
|
320
|
+
/** Host settings of the forge panel Remote. */
|
|
321
|
+
export interface Config {
|
|
322
|
+
/** Git executable name or absolute path in the Session's execution world. */
|
|
323
|
+
gitCommand?: string;
|
|
324
|
+
/** Deadline in milliseconds for one Git command, including confinement. */
|
|
325
|
+
gitTimeoutMs?: number;
|
|
326
|
+
/** Termination grace period in milliseconds for each Git process. */
|
|
327
|
+
graceMs?: number;
|
|
328
|
+
/** Maximum captured bytes per Git output stream. */
|
|
329
|
+
maxOutputBytes?: number;
|
|
330
|
+
/** Deadline in milliseconds for one provider sign-in probe. */
|
|
331
|
+
readinessTimeoutMs?: number;
|
|
332
|
+
/** Most local branches listed as worktree bases. */
|
|
333
|
+
maxBranches?: number;
|
|
334
|
+
/**
|
|
335
|
+
* Prefix of the branch and checkout directory created for a Session worktree; the first eight
|
|
336
|
+
* hexadecimal digits of the Session id's UUID, a hyphen, and four random hexadecimal digits follow it.
|
|
337
|
+
*/
|
|
338
|
+
worktreePrefix?: string;
|
|
339
|
+
/** Largest diff, or file read to show unchanged lines, in bytes. */
|
|
340
|
+
maxDiffBytes?: number;
|
|
341
|
+
/** Most untracked files a local diff or the local changes card includes. */
|
|
342
|
+
maxUntrackedFiles?: number;
|
|
343
|
+
/** Most UTF-8 bytes of change request diffs kept in memory for later reads at the same head commit and base branch. */
|
|
344
|
+
maxCachedDiffBytes?: number;
|
|
345
|
+
}
|
|
346
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
347
|
+
interface RemoteErrorDetailsMap {
|
|
348
|
+
/** No registered provider serves the change request URL. */
|
|
349
|
+
'forgePanel/unrecognized-url': Record<string, never>;
|
|
350
|
+
/** A turn of the Session has started, or its worktree was created, so its worktree request can no longer change. */
|
|
351
|
+
'forgePanel/session-started': Record<string, never>;
|
|
352
|
+
/** No worktree service is mounted. */
|
|
353
|
+
'forgePanel/worktrees-unavailable': Record<string, never>;
|
|
354
|
+
/** The requested base branch name is empty. */
|
|
355
|
+
'forgePanel/invalid-branch': Record<string, never>;
|
|
356
|
+
/** The Session has no created worktree to restore or leave. */
|
|
357
|
+
'forgePanel/no-worktree': Record<string, never>;
|
|
358
|
+
/** The Session's Agent is not loaded or has other work, so its checkout cannot change now. */
|
|
359
|
+
'forgePanel/session-busy': Record<string, never>;
|
|
360
|
+
/** No message of the Session waits after a failed or stopped attempt to create its worktree. */
|
|
361
|
+
'forgePanel/not-waiting': Record<string, never>;
|
|
362
|
+
/** The removed worktree could not be checked out again; the message gives the reason. */
|
|
363
|
+
'forgePanel/restore-failed': Record<string, never>;
|
|
364
|
+
/** The URL is not a visible binding of the Session that a provider serves, so the panel does not act on it. */
|
|
365
|
+
'forgePanel/not-bound': Record<string, never>;
|
|
366
|
+
/** The change request has new commits since the head the user confirmed, so it was not merged. */
|
|
367
|
+
'forgePanel/stale-head': Record<string, never>;
|
|
368
|
+
/** The code host refused the change or could not be reached; the message gives the host's reason. */
|
|
369
|
+
'forgePanel/action-failed': Record<string, never>;
|
|
370
|
+
/** The Session's directory is not inside a Git checkout, so it has no local changes. */
|
|
371
|
+
'forgePanel/not-a-checkout': Record<string, never>;
|
|
372
|
+
/** No remote names a default branch that HEAD shares history with, and the checkout is not a worktree the Session created. */
|
|
373
|
+
'forgePanel/no-fork-point': Record<string, never>;
|
|
374
|
+
/**
|
|
375
|
+
* The patch, the untracked file list, or the file exceeds `maxDiffBytes`, or the code host
|
|
376
|
+
* or its provider refuses a change request's diff or file over a size limit.
|
|
377
|
+
*/
|
|
378
|
+
'forgePanel/diff-too-large': Record<string, never>;
|
|
379
|
+
/** The code host did not provide the change request's diff or file, or its status has not been read yet; the message says why. */
|
|
380
|
+
'forgePanel/diff-failed': Record<string, never>;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
384
|
+
interface PluginRecordMap {
|
|
385
|
+
/** A request, withdrawal, or creation of the worktree a Session starts in. */
|
|
386
|
+
'plugin:client-ui-forge/worktree': WorktreeRecord;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
390
|
+
interface SessionProjectionMap {
|
|
391
|
+
/** The worktree the panel created for the Session while the Session works in it, else null. */
|
|
392
|
+
forgeWorktree: ForgeSessionWorktree | null;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/** The worktree a Session requests before it starts: its record, its projection, and its creation. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
4
|
+
import type { CreatedWorktree, CreateWorktreePhase } from '@deepseek-ai/dsh-experimental-worktree';
|
|
5
|
+
import type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
|
|
6
|
+
import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import type { ForgeMissingWorktree, ForgeSessionWorktree, ForgeWorktreeCreation, ForgeWorktreeFailure, ForgeWorktreeRestoration, ForgeWorktreeState, ForgeWorktreeWaiting } from './types.ts';
|
|
9
|
+
/** Plugin record type of worktree requests, withdrawals, and creations. */
|
|
10
|
+
export declare const WORKTREE_RECORD = "plugin:client-ui-forge/worktree";
|
|
11
|
+
/**
|
|
12
|
+
* The `forgeWorktree` unit. `request` and `cancel` records change the request
|
|
13
|
+
* until the first `turn/start` or creation; the first `created` record of an
|
|
14
|
+
* open request applies until the first `step/start`. Records outside those
|
|
15
|
+
* periods leave the state unchanged. The unit also follows the Session's
|
|
16
|
+
* working directory, so clients, including the Session summary, see the
|
|
17
|
+
* created worktree only while that directory is the worktree or lies below it.
|
|
18
|
+
* Restoration records retain incomplete checkout recovery across reloads.
|
|
19
|
+
*/
|
|
20
|
+
export declare const forgeWorktreeProjection: {
|
|
21
|
+
key: "forgeWorktree";
|
|
22
|
+
stateVersion: number;
|
|
23
|
+
stateSchema: z.ZodType<ForgeWorktreeState, unknown, z.core.$ZodTypeInternals<ForgeWorktreeState, unknown>>;
|
|
24
|
+
init: (header: import("@deepseek-ai/dsh-session").SessionHeader) => {
|
|
25
|
+
cwd: string | null;
|
|
26
|
+
request: import("./types.ts").ForgeWorktreeRequest | null;
|
|
27
|
+
created: ForgeSessionWorktree | null;
|
|
28
|
+
restoring: boolean;
|
|
29
|
+
locked: boolean;
|
|
30
|
+
stepped: boolean;
|
|
31
|
+
};
|
|
32
|
+
apply: typeof apply;
|
|
33
|
+
wire: {
|
|
34
|
+
viewSchema: z.ZodNullable<z.ZodType<ForgeSessionWorktree, unknown, z.core.$ZodTypeInternals<ForgeSessionWorktree, unknown>>>;
|
|
35
|
+
view: (state: NoInfer<ForgeWorktreeState>) => ForgeSessionWorktree | null;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether `path` is `root` or lies below it.
|
|
40
|
+
* @param root - absolute directory.
|
|
41
|
+
* @param path - absolute path.
|
|
42
|
+
* @returns whether `root` contains `path`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function within(root: string, path: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The text of a failure: an Error's message, or else the thrown value as a string.
|
|
47
|
+
* @param error - what was thrown.
|
|
48
|
+
* @returns the text.
|
|
49
|
+
*/
|
|
50
|
+
export declare function messageOf(error: unknown): string;
|
|
51
|
+
declare function apply(state: ForgeWorktreeState, event: SessionEvent): ForgeWorktreeState;
|
|
52
|
+
/** A failed attempt to create a requested worktree; `cause` holds the worktree service's error. */
|
|
53
|
+
export declare class CreationFailure extends Error {
|
|
54
|
+
readonly branch: string;
|
|
55
|
+
readonly phase: CreateWorktreePhase;
|
|
56
|
+
readonly reason: string;
|
|
57
|
+
/**
|
|
58
|
+
* @param branch - branch the attempt created.
|
|
59
|
+
* @param phase - step that failed.
|
|
60
|
+
* @param reason - the worktree service's failure text.
|
|
61
|
+
* @param cause - the worktree service's error.
|
|
62
|
+
*/
|
|
63
|
+
constructor(branch: string, phase: CreateWorktreePhase, reason: string, cause: unknown);
|
|
64
|
+
}
|
|
65
|
+
/** Work on a Session's checkout that runs as maintenance of its Agent. */
|
|
66
|
+
export type HeldWork = (agent: Agent, signal: AbortSignal) => Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Creates requested worktrees, one attempt with a new branch name per call,
|
|
69
|
+
* and holds the turn of a message while the Session's worktree is not ready.
|
|
70
|
+
* A hold is maintenance of the Session's Agent that starts while the message
|
|
71
|
+
* enters the inbox, before the delivery wakes the Agent, so the Agent starts
|
|
72
|
+
* the message's turn once the hold ends. A creation hold makes an attempt
|
|
73
|
+
* and, after a failed or stopped one, waits for another attempt or for the
|
|
74
|
+
* request to be withdrawn; a restoration hold checks the worktree the Session
|
|
75
|
+
* works in and, when it is gone, waits until it is restored or left. The
|
|
76
|
+
* Agent's cancellation and the panel's stop end a hold. The first step
|
|
77
|
+
* proposal of a Session whose request is still open also creates the
|
|
78
|
+
* worktree, which covers a message no hold took. The worktree service enters
|
|
79
|
+
* the created checkout and queues its directory notice; at a step proposal
|
|
80
|
+
* the notice joins the proposed messages so the first request already names
|
|
81
|
+
* the new directory, a proposal without messages leaves it queued, and a
|
|
82
|
+
* failure ends the turn with the request still open. A failed attempt may
|
|
83
|
+
* leave its branch or checkout behind.
|
|
84
|
+
*/
|
|
85
|
+
export declare class WorktreeCreations {
|
|
86
|
+
private readonly ctx;
|
|
87
|
+
private readonly states;
|
|
88
|
+
private readonly prefix;
|
|
89
|
+
private readonly changed;
|
|
90
|
+
private readonly live;
|
|
91
|
+
private readonly restorations;
|
|
92
|
+
private readonly failures;
|
|
93
|
+
private readonly holds;
|
|
94
|
+
private readonly lifetime;
|
|
95
|
+
private readonly pending;
|
|
96
|
+
/** Stop admission, cancel operations, and wait for their final callbacks. */
|
|
97
|
+
readonly dispose: () => Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* @param ctx - context that optionally provides `worktrees`.
|
|
100
|
+
* @param states - reads the `forgeWorktree` projection of a Session.
|
|
101
|
+
* @param prefix - branch name prefix that `generatedWorktreeName` combines with the Session id and random digits.
|
|
102
|
+
* @param changed - called after the creation or restoration of a Session starts, changes phase, or ends, after its
|
|
103
|
+
* failure changes, and after a wait starts or ends.
|
|
104
|
+
*/
|
|
105
|
+
constructor(ctx: Context, states: ProjectionHandle<ForgeWorktreeState>, prefix: string, changed: (session: Session) => void);
|
|
106
|
+
/**
|
|
107
|
+
* Read the running creation of a Session.
|
|
108
|
+
* @param session - Session to read.
|
|
109
|
+
* @returns the running creation, or null.
|
|
110
|
+
*/
|
|
111
|
+
of(session: Session): ForgeWorktreeCreation | null;
|
|
112
|
+
/**
|
|
113
|
+
* Read the running restoration of a Session.
|
|
114
|
+
* @param session - Session to read.
|
|
115
|
+
* @returns the running restoration, or null.
|
|
116
|
+
*/
|
|
117
|
+
restorationOf(session: Session): ForgeWorktreeRestoration | null;
|
|
118
|
+
/**
|
|
119
|
+
* Read the failed attempt that a waiting message saw last.
|
|
120
|
+
* @param session - Session to read.
|
|
121
|
+
* @returns the failure, or null.
|
|
122
|
+
*/
|
|
123
|
+
failureOf(session: Session): ForgeWorktreeFailure | null;
|
|
124
|
+
/**
|
|
125
|
+
* Read what a message of a Session waits for before its turn starts.
|
|
126
|
+
* @param session - Session to read.
|
|
127
|
+
* @returns the creation or restoration the message waits for, or null while none waits.
|
|
128
|
+
*/
|
|
129
|
+
waitingOf(session: Session): ForgeWorktreeWaiting | null;
|
|
130
|
+
/**
|
|
131
|
+
* Forget the failure of a Session whose request changes or is withdrawn; the record of that change republishes the panel.
|
|
132
|
+
* @param session - Session whose failure no longer applies.
|
|
133
|
+
*/
|
|
134
|
+
forget(session: Session): void;
|
|
135
|
+
/**
|
|
136
|
+
* Hold the turn of a message entering the inbox of a Session whose
|
|
137
|
+
* requested worktree does not exist yet, and create the worktree. Call it
|
|
138
|
+
* while the message enters, before the delivery wakes the Agent. A Session
|
|
139
|
+
* already held, or an Agent with other work, gets no new hold.
|
|
140
|
+
* @param agent - Agent of the Session.
|
|
141
|
+
*/
|
|
142
|
+
holdCreation(agent: Agent): void;
|
|
143
|
+
/**
|
|
144
|
+
* Hold the turn of a message entering the inbox of a Session that works in
|
|
145
|
+
* its created worktree while `check` decides whether that worktree is gone,
|
|
146
|
+
* and until it is restored or left when it is. Call it while the message
|
|
147
|
+
* enters, before the delivery wakes the Agent. A Session already held, or an
|
|
148
|
+
* Agent with other work, gets no new hold.
|
|
149
|
+
* @param agent - Agent of the Session.
|
|
150
|
+
* @param check - answers whether the worktree is gone; a rejection lets the message go on.
|
|
151
|
+
*/
|
|
152
|
+
holdRestoration(agent: Agent, check: (signal: AbortSignal) => Promise<ForgeMissingWorktree | null>): void;
|
|
153
|
+
/**
|
|
154
|
+
* Make another attempt for the message that waits after a failed or stopped one.
|
|
155
|
+
* @param session - Session whose message waits.
|
|
156
|
+
* @returns whether a waiting message without a running attempt took the decision.
|
|
157
|
+
*/
|
|
158
|
+
retry(session: Session): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Read the request again after it changed; a withdrawn request lets the waiting message go on.
|
|
161
|
+
* @param session - Session whose request changed.
|
|
162
|
+
*/
|
|
163
|
+
recheck(session: Session): void;
|
|
164
|
+
/**
|
|
165
|
+
* Run work on the removed worktree a message waits for, inside the wait; its success lets the message go on.
|
|
166
|
+
* @param session - Session whose message waits.
|
|
167
|
+
* @param work - restores or leaves the worktree.
|
|
168
|
+
* @returns the work's outcome, or undefined when no message waits for the removed worktree.
|
|
169
|
+
*/
|
|
170
|
+
within(session: Session, work: HeldWork): Promise<void> | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Stop the running attempt a message waits for; the message keeps waiting
|
|
173
|
+
* with the request still open. Without such an attempt the Session is unchanged.
|
|
174
|
+
* @param session - Session whose attempt stops.
|
|
175
|
+
*/
|
|
176
|
+
stop(session: Session): void;
|
|
177
|
+
/**
|
|
178
|
+
* Check the removed worktree of a Session out again through the worktree
|
|
179
|
+
* service; the running restoration is readable through
|
|
180
|
+
* {@link WorktreeCreations.restorationOf} until it ends.
|
|
181
|
+
* @param agent - Agent of the Session.
|
|
182
|
+
* @param worktrees - the worktree service.
|
|
183
|
+
* @param created - the worktree the Session created.
|
|
184
|
+
* @param signal - cancellation of the restoration.
|
|
185
|
+
* @param restored - runs once the checkout is back, before the restoration ends, so both changes publish together.
|
|
186
|
+
* @param available - checks whether the recorded checkout is already usable, within this operation's lifetime.
|
|
187
|
+
* @throws the worktree service's error when the restoration fails; the cancellation reason once `signal` aborts.
|
|
188
|
+
*/
|
|
189
|
+
restore(agent: Agent, worktrees: Context['worktrees'], created: ForgeSessionWorktree, signal: AbortSignal, restored: () => void, available: (signal: AbortSignal) => Promise<boolean>): Promise<void>;
|
|
190
|
+
private restoreCheckout;
|
|
191
|
+
/**
|
|
192
|
+
* Create a Session's requested worktree with a new branch name, enter it, and
|
|
193
|
+
* record it on the Session. The running creation is readable through
|
|
194
|
+
* {@link WorktreeCreations.of} until the record exists or the attempt fails.
|
|
195
|
+
* @param agent - Agent of the Session.
|
|
196
|
+
* @param from - base branch, or null for HEAD of the current checkout.
|
|
197
|
+
* @param signal - cancellation of the attempt.
|
|
198
|
+
* @param held - whether a message waits for the creation before its turn starts.
|
|
199
|
+
* @returns the created worktree.
|
|
200
|
+
* @throws {@link CreationFailure} when the attempt fails; the cancellation reason once `signal` aborts.
|
|
201
|
+
*/
|
|
202
|
+
create(agent: Agent, from: string | null, signal: AbortSignal, held: boolean): Promise<CreatedWorktree>;
|
|
203
|
+
private createCheckout;
|
|
204
|
+
/**
|
|
205
|
+
* Run a hold as maintenance of the Agent, which latches the delivery's wake until the hold ends.
|
|
206
|
+
* @param agent - Agent of the Session.
|
|
207
|
+
* @param hold - the hold's state.
|
|
208
|
+
* @param body - waits for the worktree; settles once the message may go on.
|
|
209
|
+
*/
|
|
210
|
+
private hold;
|
|
211
|
+
private run;
|
|
212
|
+
private join;
|
|
213
|
+
/**
|
|
214
|
+
* Make attempts until one creates the worktree or the request no longer asks
|
|
215
|
+
* for one, waiting for a decision after each failed or stopped attempt.
|
|
216
|
+
*/
|
|
217
|
+
private runCreation;
|
|
218
|
+
/** Check the worktree the Session works in and, when it is gone, run the work that restores or leaves it until one succeeds. */
|
|
219
|
+
private runRestoration;
|
|
220
|
+
/** Wait for the next decision on a hold; rejects with the abort reason once `signal` aborts. */
|
|
221
|
+
private wait;
|
|
222
|
+
private preStep;
|
|
223
|
+
}
|
|
224
|
+
export {};
|
|
225
|
+
//# sourceMappingURL=worktree.d.ts.map
|
package/locale/de.json
ADDED
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED