@laoyuehanni/dsh-git-worktree 0.4.14 → 0.4.16
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 +9 -3
- package/README.zh.md +9 -3
- package/docs/DETAIL.md +5 -2
- package/docs/DETAIL.zh.md +5 -2
- package/lib/client.js +4253 -620
- package/lib/deferred-worktree.d.ts +105 -0
- package/lib/deferred-worktree.js +293 -0
- package/lib/git.d.ts +95 -0
- package/lib/git.js +384 -4
- package/lib/index.d.ts +13 -0
- package/lib/index.js +204 -4
- package/lib/normalize.d.ts +13 -0
- package/lib/normalize.js +51 -0
- package/lib/pr.d.ts +177 -0
- package/lib/pr.js +672 -0
- package/lib/routes.d.ts +61 -3
- package/lib/routes.js +639 -80
- package/lib/wire.d.ts +235 -3
- package/lib/wire.js +17 -0
- package/package.json +1 -1
package/lib/routes.d.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type CopyFilesSeams } from './copy-files.js';
|
|
6
6
|
import { type DirExists, type ExcludeSeams, type Exec } from './git.js';
|
|
7
|
-
import
|
|
8
|
-
import type {
|
|
7
|
+
import { type ForgeServiceLike } from './pr.js';
|
|
8
|
+
import type { AuthorList, CommitHistory, CommitDetail, PrCheckoutResult, PrContextResult, PrResolveResult } from './wire.js';
|
|
9
|
+
import type { CreateBranchResult, CreateWorktreeResult, DeferredWorktreePhase, DeferredWorktreeSnapshot, DeferredWorktreeSpec, EnsureDirectoryResult, FetchResult, GroupWorkspacesResult, HeadStatus, InspectWorktreeResult, PathExistsResult, PushPlan, PushPreview, PushResult, PurgeDirectoryResult, RemoveWorktreeResult, RepoStatus, RouteError, SetSessionDirectoryResult, SwitchResult, SyncEvent, UpdateResult, WorktreesAllResult } from './wire.js';
|
|
10
|
+
import type { DeferredCreateOutcome, DeferredWorktreeCoordinator } from './deferred-worktree.js';
|
|
9
11
|
/** Everything the handlers need from the host half. */
|
|
10
12
|
export interface RouteDeps {
|
|
11
13
|
exec: Exec;
|
|
@@ -15,6 +17,10 @@ export interface RouteDeps {
|
|
|
15
17
|
sectionFetchBeforeCreate: () => boolean | undefined;
|
|
16
18
|
/** Post-create configuration files to copy when .worktreeinclude is absent. */
|
|
17
19
|
sectionPostCreateCopyFiles?: () => string[] | undefined;
|
|
20
|
+
/** Whether `/worktrees-all` and `/purge` also cover official `<repo>/.agents/worktrees`. */
|
|
21
|
+
sectionManageOfficialWorktrees?: () => boolean | undefined;
|
|
22
|
+
/** Optional host `ctx.forge` service bridge when forge-bundle is enabled. */
|
|
23
|
+
forge?: () => ForgeServiceLike | undefined;
|
|
18
24
|
/** User home directory seam. */
|
|
19
25
|
home: () => string;
|
|
20
26
|
/** `$DSH_HOME` environment value seam. */
|
|
@@ -35,6 +41,12 @@ export interface RouteDeps {
|
|
|
35
41
|
listDir?: (path: string) => Promise<string[]>;
|
|
36
42
|
/** Recursive force rm seam (fs.rm with retries); tests substitute. */
|
|
37
43
|
rmRecursive?: (path: string) => Promise<void>;
|
|
44
|
+
/** Move a live session's working directory via host `agents` + `workingDirectory` services. */
|
|
45
|
+
setSessionDirectory?: (sessionId: string, path: string) => Promise<string>;
|
|
46
|
+
/** Deferred worktree creation coordinator (available when host supports workingDirectory). */
|
|
47
|
+
deferredWorktrees?: DeferredWorktreeCoordinator;
|
|
48
|
+
/** Deterministic 4-hex generator seam for random cutout branch tests. */
|
|
49
|
+
randomHex?: () => string;
|
|
38
50
|
}
|
|
39
51
|
/** Real fs-backed one-level directory listing (names only). Plain FILES are
|
|
40
52
|
* filtered out — the storage root can carry strays (a legacy settings.json
|
|
@@ -47,7 +59,9 @@ export declare function fsMkdirRecursive(path: string): Promise<void>;
|
|
|
47
59
|
/** One route outcome: HTTP status plus the JSON body. */
|
|
48
60
|
export interface RouteOutcome {
|
|
49
61
|
status: number;
|
|
50
|
-
body: AuthorList | CommitHistory | CommitDetail | PushPlan | PushPreview | PushResult | RepoStatus | HeadStatus | CreateWorktreeResult | SwitchResult | CreateBranchResult | FetchResult | UpdateResult | GroupWorkspacesResult | InspectWorktreeResult | RemoveWorktreeResult | PathExistsResult | EnsureDirectoryResult | WorktreesAllResult | PurgeDirectoryResult |
|
|
62
|
+
body: AuthorList | CommitHistory | CommitDetail | PushPlan | PushPreview | PushResult | RepoStatus | HeadStatus | CreateWorktreeResult | SwitchResult | CreateBranchResult | FetchResult | UpdateResult | GroupWorkspacesResult | InspectWorktreeResult | RemoveWorktreeResult | PathExistsResult | EnsureDirectoryResult | WorktreesAllResult | PurgeDirectoryResult | SetSessionDirectoryResult | DeferredWorktreeSnapshot | PrContextResult | PrResolveResult | PrCheckoutResult | {
|
|
63
|
+
ok: true;
|
|
64
|
+
} | RouteError;
|
|
51
65
|
}
|
|
52
66
|
/**
|
|
53
67
|
* POST /group — git belonging facts for a batch of workspace directories.
|
|
@@ -128,6 +142,11 @@ export declare function handleCommit(deps: RouteDeps, body: unknown): Promise<Ro
|
|
|
128
142
|
* @param deps - host dependencies.
|
|
129
143
|
* @param body - parsed request body.
|
|
130
144
|
*/
|
|
145
|
+
/**
|
|
146
|
+
* Shared worktree creation execution pipeline used by both immediate
|
|
147
|
+
* `POST /worktree` and deferred first-turn creation.
|
|
148
|
+
*/
|
|
149
|
+
export declare function executeCreateWorktree(deps: RouteDeps, spec: DeferredWorktreeSpec, onPhase?: (phase: Exclude<DeferredWorktreePhase, 'switch'>, resolvedBranch?: string) => void, signal?: AbortSignal): Promise<DeferredCreateOutcome>;
|
|
131
150
|
export declare function handleCreateWorktree(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
|
|
132
151
|
/**
|
|
133
152
|
* POST /switch 鈥?in-place branch switch of the main checkout.
|
|
@@ -270,3 +289,42 @@ export declare function handlePathExists(deps: RouteDeps, body: unknown): Promis
|
|
|
270
289
|
* @param body - parsed request body: `{ path }`.
|
|
271
290
|
*/
|
|
272
291
|
export declare function handleEnsureDirectory(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
|
|
292
|
+
/**
|
|
293
|
+
* POST /session-cwd — move a session's working directory to an existing
|
|
294
|
+
* directory via the host `workingDirectory` service. Used by the shared
|
|
295
|
+
* workspace mode (`switchSessionDirectory`) so a blank session stays under
|
|
296
|
+
* its parent repository workspace while working inside a linked worktree.
|
|
297
|
+
* @param deps - host dependencies.
|
|
298
|
+
* @param body - parsed request body: `{ sessionId, path }`.
|
|
299
|
+
*/
|
|
300
|
+
export declare function handleSetSessionDirectory(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
|
|
301
|
+
/** GET /deferred?sessionId=<id> — read a session's current deferred worktree state. */
|
|
302
|
+
export declare function handleGetDeferredWorktree(deps: RouteDeps, sessionId: string | undefined): Promise<RouteOutcome>;
|
|
303
|
+
/** POST /deferred/arm — arm a deferred worktree creation for a blank session. */
|
|
304
|
+
export declare function handleArmDeferredWorktree(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
|
|
305
|
+
/** POST /deferred/action — cancel, retry, or withdraw a deferred worktree. */
|
|
306
|
+
export declare function handleDeferredWorktreeAction(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
|
|
307
|
+
/**
|
|
308
|
+
* POST /pr-context — remotes, optional `ctx.forge` readiness, and open PR/MR candidates.
|
|
309
|
+
* @param deps - host dependencies.
|
|
310
|
+
* @param body - parsed request body: `{ repoPath, remote? }`.
|
|
311
|
+
* @param signal - optional cancellation signal aborted when the HTTP client disconnects.
|
|
312
|
+
*/
|
|
313
|
+
export declare function handlePrContext(deps: RouteDeps, body: unknown, signal?: AbortSignal): Promise<RouteOutcome>;
|
|
314
|
+
/**
|
|
315
|
+
* POST /pr-resolve — parse and validate a PR/MR ID or URL against repository remotes,
|
|
316
|
+
* verifying remote ref existence via lightweight `git ls-remote` unless skipped for live
|
|
317
|
+
* candidates or an already-existing local worktree.
|
|
318
|
+
* @param deps - host dependencies.
|
|
319
|
+
* @param body - parsed request body.
|
|
320
|
+
* @param signal - optional cancellation signal aborted when the HTTP client disconnects.
|
|
321
|
+
*/
|
|
322
|
+
export declare function handlePrResolve(deps: RouteDeps, body: unknown, signal?: AbortSignal): Promise<RouteOutcome>;
|
|
323
|
+
/**
|
|
324
|
+
* POST /pr-checkout — stream native `git fetch refs/pull|merge-requests` + isolated worktree
|
|
325
|
+
* creation (or safe reuse/update/reset when the worktree already exists).
|
|
326
|
+
* @param deps - host dependencies.
|
|
327
|
+
* @param body - parsed request body.
|
|
328
|
+
* @param live - optional streaming channel for NDJSON progress events.
|
|
329
|
+
*/
|
|
330
|
+
export declare function handlePrCheckout(deps: RouteDeps, body: unknown, live?: RouteLive): Promise<RouteOutcome>;
|