@laoyuehanni/dsh-git-worktree 0.4.3 → 0.4.5

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/lib/git.d.ts CHANGED
@@ -26,10 +26,23 @@ export declare class GitError extends Error {
26
26
  }
27
27
  /** Facts the status route assembles: branches, worktrees, repo identity. */
28
28
  export interface RepoFacts {
29
- /** Absolute main worktree path (`rev-parse --show-toplevel` of the main dir). */
29
+ /** Absolute main worktree path (`dirname` of `--git-common-dir`, not the
30
+ * queried directory's `--show-toplevel` — a linked worktree's toplevel
31
+ * dies during `worktree remove`). */
30
32
  repoRoot: string;
31
33
  /** Main repository directory basename. */
32
34
  repoName: string;
35
+ /** The QUERIED directory's own toplevel — the worktree the session
36
+ * actually sits in. Repository-wide commands (branch refs, fetch,
37
+ * worktree registration) run at {@link RepoFacts.repoRoot}; commands that
38
+ * act on the session's own checkout (switch/update/create-and-check-out)
39
+ * run HERE, or a linked-worktree session would silently operate on the
40
+ * main checkout instead. */
41
+ toplevel: string;
42
+ /** Whether the QUERIED directory is the main worktree — see
43
+ * {@link isMainWorktree}. `repoRoot` cannot answer this: it names the main
44
+ * checkout from every worktree by construction. */
45
+ main: boolean;
33
46
  /** Branch checked out by the queried directory. */
34
47
  currentBranch: string;
35
48
  branches: BranchEntry[];
@@ -43,6 +56,15 @@ export declare function childProcessExec(file: string, args: readonly string[],
43
56
  export type DirExists = (path: string) => boolean;
44
57
  /** Real existence check. */
45
58
  export declare const fsDirExists: DirExists;
59
+ /**
60
+ * Leftover-directory sweeper after `git worktree remove` unregisters but
61
+ * fails the final rmdir (Windows EPERM when a process still has the folder
62
+ * as cwd). `gone` = deleted; `empty` = still there but vacant (cwd hold);
63
+ * `occupied` = still has files — the caller must not pretend removal finished.
64
+ */
65
+ export type SweepDir = (path: string) => Promise<'gone' | 'empty' | 'occupied'>;
66
+ /** Real leftover sweep: `fs.rm` with Windows EPERM retries, then classify. */
67
+ export declare function fsSweepDir(path: string): Promise<'gone' | 'empty' | 'occupied'>;
46
68
  /**
47
69
  * Resolve a directory to repository facts, or undefined outside any git
48
70
  * repository (including the `git` binary missing: ENOENT surfaces as a
@@ -52,6 +74,18 @@ export declare const fsDirExists: DirExists;
52
74
  * @param dirExists - existence seam for stale-registration filtering.
53
75
  */
54
76
  export declare function probeRepo(exec: Exec, path: string, dirExists?: DirExists): Promise<RepoFacts | undefined>;
77
+ /**
78
+ * Resolve a branch display name against the authoritative branch list of the
79
+ * repository. Exported for the /worktree route's fetch gate: the pre-create
80
+ * remote sync only earns its round trip when the display name is REMOTE-only
81
+ * (a local branch's worktree never consumes fetched refs).
82
+ * @returns the local name plus the tracking remote when the display name is
83
+ * remote-only, or undefined when neither shape exists.
84
+ */
85
+ export declare function resolveBranch(exec: Exec, repoRoot: string, branch: string): Promise<{
86
+ local: string;
87
+ remote: string | undefined;
88
+ } | undefined>;
55
89
  /**
56
90
  * Create (or reuse) the worktree for one branch.
57
91
  *
@@ -108,18 +142,53 @@ export declare function addWorktreeCutout(exec: Exec, repoRoot: string, base: st
108
142
  */
109
143
  export declare function switchBranch(exec: Exec, repoRoot: string, branch: string): Promise<string>;
110
144
  /**
111
- * Create a NEW branch from the current checkout and check it out in place
112
- * (`git switch -c`): the cut point is whatever the queried directory's HEAD
113
- * points at, so a detached or unborn checkout cuts from the current commit
114
- * too. Runs at the queried directory's own toplevel — a session inside a
115
- * linked worktree creates and checks out within that worktree, never the
116
- * main checkout (the same semantics as {@link switchBranch}).
145
+ * Create a NEW branch. Three shapes:
146
+ *
147
+ * - no `from`: cut from the current checkout and check it out in place
148
+ * (`git switch -c`) — the cut point is whatever the queried directory's
149
+ * HEAD points at, so a detached or unborn checkout cuts from the current
150
+ * commit too. Runs at the queried directory's own toplevel — a session
151
+ * inside a linked worktree creates and checks out within that worktree,
152
+ * never the main checkout (the same semantics as {@link switchBranch}).
153
+ * - `from` without `checkout`: create AT that start point WITHOUT touching
154
+ * any checkout (`git branch`) — a create aimed at another branch must
155
+ * not move this session's HEAD.
156
+ * - `from` with `checkout`: create at the start point AND check it out
157
+ * here in one stroke (`git switch -c <name> <from>`).
117
158
  * @param exec - executor seam.
118
159
  * @param cwd - directory whose HEAD the branch is cut from (worktree toplevel).
119
160
  * @param name - new branch name (git validates; failures raise GitError).
120
- * @returns the branch name now created and checked out.
161
+ * @param from - optional start point; absent keeps the in-place semantics.
162
+ * @param checkout - with `from`, also check the new branch out here.
163
+ * @returns the branch name now created (checked out unless created at a
164
+ * start point with `checkout` false).
165
+ */
166
+ export declare function createBranch(exec: Exec, cwd: string, name: string, from?: string, checkout?: boolean): Promise<string>;
167
+ /**
168
+ * Rename a LOCAL branch (`git branch -m`): branch refs are repository-wide,
169
+ * so the command runs at the repository root and every worktree HEAD pointing
170
+ * at the old name follows the ref. Git validates the new name and refuses a
171
+ * target that already exists; remote branches are not renameable (not ours).
172
+ * @param exec - executor seam.
173
+ * @param repoRoot - main worktree directory.
174
+ * @param name - branch to rename.
175
+ * @param newName - the new local name.
176
+ * @returns the new name.
177
+ */
178
+ export declare function renameBranch(exec: Exec, repoRoot: string, name: string, newName: string): Promise<string>;
179
+ /**
180
+ * Delete a LOCAL branch (`git branch -d`, the SAFE form): git refuses a
181
+ * branch with unmerged commits ("not fully merged") and one checked out in
182
+ * any worktree — both caller-side state, mapped to 400 by the route. No
183
+ * `-D` force variant on purpose: a menu click must never discard commits
184
+ * (the terminal is the place for deliberate force-deletes). Runs at the
185
+ * repository root; remote branches are not ours to delete.
186
+ * @param exec - executor seam.
187
+ * @param repoRoot - main worktree directory.
188
+ * @param name - branch to delete.
189
+ * @returns the name of the branch that was deleted.
121
190
  */
122
- export declare function createBranch(exec: Exec, cwd: string, name: string): Promise<string>;
191
+ export declare function deleteBranch(exec: Exec, repoRoot: string, name: string): Promise<string>;
123
192
  /**
124
193
  * Sync remote-tracking refs: fetch every remote and prune tracking branches
125
194
  * the remotes no longer carry (the CLI equivalent of IDEA's "synchronize
@@ -178,11 +247,13 @@ export declare function inspectWorktree(exec: Exec, worktreePath: string): Promi
178
247
  * @param worktreePath - the linked worktree directory to delete (absolute).
179
248
  * @param force - pass `--force` past uncommitted changes.
180
249
  * @param dirExists - existence seam for the stale-registration branch.
250
+ * @param sweepDir - leftover rmdir after git unregisters but the OS holds the
251
+ * folder (Windows Permission denied on the empty directory).
181
252
  * @returns the path plus whether only a stale registration was pruned.
182
253
  * @throws GitError for the main worktree, an unregistered path, or a refused
183
254
  * removal (git's own stderr verbatim).
184
255
  */
185
- export declare function removeWorktree(exec: Exec, repoRoot: string, worktreePath: string, force: boolean, dirExists?: DirExists): Promise<{
256
+ export declare function removeWorktree(exec: Exec, repoRoot: string, worktreePath: string, force: boolean, dirExists?: DirExists, sweepDir?: SweepDir): Promise<{
186
257
  path: string;
187
258
  pruned: boolean;
188
259
  }>;
package/lib/git.js CHANGED
@@ -4,7 +4,8 @@
4
4
  * argument assembly plus porcelain parsing, no ambient state.
5
5
  */
6
6
  import { execFile } from 'node:child_process';
7
- import { existsSync } from 'node:fs';
7
+ import { existsSync, readdirSync } from 'node:fs';
8
+ import { rm } from 'node:fs/promises';
8
9
  import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';
9
10
  import { localBranchName } from './normalize.js';
10
11
  /** Failure of one git invocation: non-zero exit with the stderr text. */
@@ -45,6 +46,54 @@ async function gitMaybe(exec, cwd, args) {
45
46
  }
46
47
  /** Real existence check. */
47
48
  export const fsDirExists = path => existsSync(path);
49
+ /** Real leftover sweep: `fs.rm` with Windows EPERM retries, then classify. */
50
+ export async function fsSweepDir(path) {
51
+ if (!existsSync(path))
52
+ return 'gone';
53
+ try {
54
+ await rm(path, { recursive: true, force: true, maxRetries: 8, retryDelay: 100 });
55
+ }
56
+ catch {
57
+ // Retries exhausted; classify whatever is still on disk.
58
+ }
59
+ if (!existsSync(path))
60
+ return 'gone';
61
+ try {
62
+ return readdirSync(path).length === 0 ? 'empty' : 'occupied';
63
+ }
64
+ catch {
65
+ return 'occupied';
66
+ }
67
+ }
68
+ /** stderr of a git rmdir that lost to an OS file lock (not git's dirty check). */
69
+ function isDirBusyGitError(error) {
70
+ const text = error.stderr;
71
+ return /permission denied/i.test(text)
72
+ || /\bEPERM\b/i.test(text)
73
+ || /\bEACCES\b/i.test(text)
74
+ || /\bEBUSY\b/i.test(text);
75
+ }
76
+ /**
77
+ * Whether a directory IS the main worktree of its repository: exactly when
78
+ * its own toplevel holds the SHARED `.git` that `--git-common-dir` names.
79
+ * From a linked worktree that path resolves to the shared `<repo>/.git` too,
80
+ * but its toplevel is the linked folder — so the two differ and the answer
81
+ * is false.
82
+ *
83
+ * Deliberately NOT "is the first entry of `worktree list`": that list is
84
+ * filtered by directory existence downstream (a stale main registration
85
+ * would flip the answer), it costs a second git spawn, and its `main` flag
86
+ * describes a different question — which entry git considers main, not
87
+ * which directory was asked about. Same rule as {@link probeWorkspaceGit}
88
+ * applies for the sidebar's grouping, extracted here so both answers are the
89
+ * same answer.
90
+ * @param toplevel - the queried directory's own `--show-toplevel`.
91
+ * @param gitDir - the SHARED git dir (`--git-common-dir`) every worktree
92
+ * resolves back to.
93
+ */
94
+ function isMainWorktree(toplevel, gitDir) {
95
+ return normalize(resolve(toplevel, '.git')) === gitDir;
96
+ }
48
97
  /**
49
98
  * Resolve a directory to repository facts, or undefined outside any git
50
99
  * repository (including the `git` binary missing: ENOENT surfaces as a
@@ -61,13 +110,21 @@ export async function probeRepo(exec, path, dirExists = fsDirExists) {
61
110
  // repoName comes from the shared .git location: a linked worktree's own
62
111
  // toplevel would name the branch folder, not the repository. Both git
63
112
  // outputs carry forward slashes on Windows — normalize every derived path.
64
- const repoRoot = normalize(top.trim());
113
+ const toplevel = normalize(top.trim());
65
114
  const gitDir = commonDir !== undefined && commonDir.trim() !== ''
66
115
  ? normalize(resolve(path, commonDir.trim()))
67
- : resolve(repoRoot, '.git');
116
+ : resolve(toplevel, '.git');
117
+ // Main worktree, not the queried directory: a linked worktree's
118
+ // `--show-toplevel` is its own folder, which `git worktree remove` then
119
+ // destroys (including `.git`). Later `worktree list` / `worktree prune`
120
+ // must still run in a living git dir — the shared checkout
121
+ // (`dirname(--git-common-dir)`), same grouping key as probeWorkspaceGit.
122
+ const repoRoot = dirname(gitDir);
68
123
  return {
69
124
  repoRoot,
70
125
  repoName: basename(dirname(gitDir)),
126
+ toplevel,
127
+ main: isMainWorktree(toplevel, gitDir),
71
128
  currentBranch: await currentBranch(exec, path),
72
129
  branches: await listBranches(exec, repoRoot),
73
130
  // A stale registration (directory removed behind git's back) must not
@@ -173,11 +230,13 @@ async function listWorktrees(exec, repoRoot) {
173
230
  }
174
231
  /**
175
232
  * Resolve a branch display name against the authoritative branch list of the
176
- * repository.
233
+ * repository. Exported for the /worktree route's fetch gate: the pre-create
234
+ * remote sync only earns its round trip when the display name is REMOTE-only
235
+ * (a local branch's worktree never consumes fetched refs).
177
236
  * @returns the local name plus the tracking remote when the display name is
178
237
  * remote-only, or undefined when neither shape exists.
179
238
  */
180
- async function resolveBranch(exec, repoRoot, branch) {
239
+ export async function resolveBranch(exec, repoRoot, branch) {
181
240
  const localsOut = await git(exec, repoRoot, ['for-each-ref', 'refs/heads', '--format=%(refname:short)']);
182
241
  const locals = localsOut.split('\n').map(l => l.trim()).filter(l => l !== '');
183
242
  if (locals.includes(branch))
@@ -307,19 +366,65 @@ export async function switchBranch(exec, repoRoot, branch) {
307
366
  return resolved.local;
308
367
  }
309
368
  /**
310
- * Create a NEW branch from the current checkout and check it out in place
311
- * (`git switch -c`): the cut point is whatever the queried directory's HEAD
312
- * points at, so a detached or unborn checkout cuts from the current commit
313
- * too. Runs at the queried directory's own toplevel — a session inside a
314
- * linked worktree creates and checks out within that worktree, never the
315
- * main checkout (the same semantics as {@link switchBranch}).
369
+ * Create a NEW branch. Three shapes:
370
+ *
371
+ * - no `from`: cut from the current checkout and check it out in place
372
+ * (`git switch -c`) — the cut point is whatever the queried directory's
373
+ * HEAD points at, so a detached or unborn checkout cuts from the current
374
+ * commit too. Runs at the queried directory's own toplevel — a session
375
+ * inside a linked worktree creates and checks out within that worktree,
376
+ * never the main checkout (the same semantics as {@link switchBranch}).
377
+ * - `from` without `checkout`: create AT that start point WITHOUT touching
378
+ * any checkout (`git branch`) — a create aimed at another branch must
379
+ * not move this session's HEAD.
380
+ * - `from` with `checkout`: create at the start point AND check it out
381
+ * here in one stroke (`git switch -c <name> <from>`).
316
382
  * @param exec - executor seam.
317
383
  * @param cwd - directory whose HEAD the branch is cut from (worktree toplevel).
318
384
  * @param name - new branch name (git validates; failures raise GitError).
319
- * @returns the branch name now created and checked out.
385
+ * @param from - optional start point; absent keeps the in-place semantics.
386
+ * @param checkout - with `from`, also check the new branch out here.
387
+ * @returns the branch name now created (checked out unless created at a
388
+ * start point with `checkout` false).
389
+ */
390
+ export async function createBranch(exec, cwd, name, from, checkout = false) {
391
+ if (from === undefined || checkout) {
392
+ const startPoint = from === undefined ? [] : [from];
393
+ await git(exec, cwd, ['switch', '-c', name, ...startPoint]);
394
+ return name;
395
+ }
396
+ await git(exec, cwd, ['branch', name, from]);
397
+ return name;
398
+ }
399
+ /**
400
+ * Rename a LOCAL branch (`git branch -m`): branch refs are repository-wide,
401
+ * so the command runs at the repository root and every worktree HEAD pointing
402
+ * at the old name follows the ref. Git validates the new name and refuses a
403
+ * target that already exists; remote branches are not renameable (not ours).
404
+ * @param exec - executor seam.
405
+ * @param repoRoot - main worktree directory.
406
+ * @param name - branch to rename.
407
+ * @param newName - the new local name.
408
+ * @returns the new name.
409
+ */
410
+ export async function renameBranch(exec, repoRoot, name, newName) {
411
+ await git(exec, repoRoot, ['branch', '-m', name, newName]);
412
+ return newName;
413
+ }
414
+ /**
415
+ * Delete a LOCAL branch (`git branch -d`, the SAFE form): git refuses a
416
+ * branch with unmerged commits ("not fully merged") and one checked out in
417
+ * any worktree — both caller-side state, mapped to 400 by the route. No
418
+ * `-D` force variant on purpose: a menu click must never discard commits
419
+ * (the terminal is the place for deliberate force-deletes). Runs at the
420
+ * repository root; remote branches are not ours to delete.
421
+ * @param exec - executor seam.
422
+ * @param repoRoot - main worktree directory.
423
+ * @param name - branch to delete.
424
+ * @returns the name of the branch that was deleted.
320
425
  */
321
- export async function createBranch(exec, cwd, name) {
322
- await git(exec, cwd, ['switch', '-c', name]);
426
+ export async function deleteBranch(exec, repoRoot, name) {
427
+ await git(exec, repoRoot, ['branch', '-d', name]);
323
428
  return name;
324
429
  }
325
430
  /**
@@ -387,11 +492,13 @@ export async function inspectWorktree(exec, worktreePath) {
387
492
  * @param worktreePath - the linked worktree directory to delete (absolute).
388
493
  * @param force - pass `--force` past uncommitted changes.
389
494
  * @param dirExists - existence seam for the stale-registration branch.
495
+ * @param sweepDir - leftover rmdir after git unregisters but the OS holds the
496
+ * folder (Windows Permission denied on the empty directory).
390
497
  * @returns the path plus whether only a stale registration was pruned.
391
498
  * @throws GitError for the main worktree, an unregistered path, or a refused
392
499
  * removal (git's own stderr verbatim).
393
500
  */
394
- export async function removeWorktree(exec, repoRoot, worktreePath, force, dirExists = fsDirExists) {
501
+ export async function removeWorktree(exec, repoRoot, worktreePath, force, dirExists = fsDirExists, sweepDir = fsSweepDir) {
395
502
  const target = normalize(worktreePath);
396
503
  const worktrees = await listWorktrees(exec, repoRoot);
397
504
  const registered = worktrees.find(w => w.path === target);
@@ -407,8 +514,32 @@ export async function removeWorktree(exec, repoRoot, worktreePath, force, dirExi
407
514
  await git(exec, repoRoot, ['worktree', 'prune']);
408
515
  return { path: target, pruned: true };
409
516
  }
410
- await git(exec, repoRoot, force ? ['worktree', 'remove', '--force', target] : ['worktree', 'remove', target]);
411
- return { path: target, pruned: false };
517
+ try {
518
+ await git(exec, repoRoot, force ? ['worktree', 'remove', '--force', target] : ['worktree', 'remove', target]);
519
+ return { path: target, pruned: false };
520
+ }
521
+ catch (error) {
522
+ // Windows: git often unregisters the worktree and empties the tree,
523
+ // then fails the last rmdir (`Permission denied`) because some process
524
+ // still has the folder as cwd. `--force` does not help — that flag only
525
+ // bypasses dirty/lock checks, not OS handles. Relist from `repoRoot`
526
+ // (the main checkout, which still has `.git`); listing from the target
527
+ // path would throw "not a git repository" once git has stripped its
528
+ // `.git`. If the registration is already gone, the git side is done;
529
+ // sweep the leftover and succeed so the DSH archive+unregister half
530
+ // can run. A still-occupied leftover (files remain) is a real refusal.
531
+ if (!(error instanceof GitError) || !isDirBusyGitError(error))
532
+ throw error;
533
+ const remaining = (await listWorktrees(exec, repoRoot)).find(w => w.path === target);
534
+ if (remaining !== undefined)
535
+ throw error;
536
+ if (!dirExists(target))
537
+ return { path: target, pruned: false };
538
+ const leftover = await sweepDir(target);
539
+ if (leftover === 'occupied')
540
+ throw error;
541
+ return { path: target, pruned: false };
542
+ }
412
543
  }
413
544
  /**
414
545
  * Lightweight git belonging probe for ONE workspace directory: the three
@@ -457,6 +588,6 @@ export async function probeWorkspaceGit(exec, path) {
457
588
  repoRoot: dirname(gitDir),
458
589
  repoName: basename(dirname(gitDir)),
459
590
  branch: branchName === '' || branchName === 'HEAD' ? null : branchName,
460
- main: normalize(resolve(toplevel, '.git')) === gitDir,
591
+ main: isMainWorktree(toplevel, gitDir),
461
592
  };
462
593
  }
package/lib/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * dsh-git-worktree host half. Owns the worktree storage-root settings section
3
3
  * (the `git-worktree` namespace in the dsh settings document, registered
4
- * through installSettingsSection with the composition entry as its base
5
- * layer) and — while a webServer service exists — the HTTP routes the browser
4
+ * through SettingsProvider.installSection with the composition entry as its
5
+ * base layer) and — while a webServer service exists — the HTTP routes the browser
6
6
  * half fetches. A stored root edit takes effect live: the routes read the
7
7
  * section source per request, so no restart and no route re-registration.
8
8
  *
@@ -21,21 +21,57 @@ export interface Config {
21
21
  rootDir?: string;
22
22
  /** Sidebar git grouping on/off; absent = on (the composition-entry layer's default). */
23
23
  groupSidebar?: boolean;
24
+ /** Fetch every remote before creating a worktree; absent = off. A failed
25
+ * fetch never blocks the creation (see the /worktree route). */
26
+ fetchBeforeCreate?: boolean;
27
+ /** Prune stale worktrees lazily after each creation; absent = off. */
28
+ autoPruneWorktrees?: boolean;
29
+ /** Global cap the lazy prune trims down to (valid git worktrees only);
30
+ * absent = 30. */
31
+ keepWorktrees?: number;
24
32
  }
33
+ /**
34
+ * Cordis resolves the composition entry's config through this schema before
35
+ * `apply` runs (official plugin-config convention: export the `Config` type
36
+ * and a same-named Schemastery schema). It fills the `groupSidebar` default;
37
+ * `rootDir` passes through untouched — its absence stays observable so the
38
+ * settings section keeps spelling the resolved default. Constraints the
39
+ * schema cannot express still fail loudly in validateConfig below (absolute
40
+ * path; unknown keys — schemastery keeps extras instead of rejecting them).
41
+ */
42
+ export declare const Config: z<Config>;
25
43
  /** Reject stale or misspelled config keys before defaults can hide them. */
26
44
  export declare function validateConfig(config: Config): void;
45
+ /**
46
+ * The prune cap must be an integer >= 1: 0 would read as "create then
47
+ * immediately self-delete" (the fresh worktree is excluded, but every other
48
+ * one dies on the next creation), a fraction cannot count directories.
49
+ * Absent = the shipped default, which passes.
50
+ */
51
+ export declare function validateKeepWorktrees(value: number | undefined): void;
27
52
  /** The settings namespace this plugin serves; its browser card spells the same string. */
28
- export declare const GIT_WORKTREE_NS: import("@deepseek-ai/dsh-settings").SettingsNamespace;
29
- /** The settings-facing subset of the config: the worktree storage root and the sidebar grouping switch. */
53
+ export declare const GIT_WORKTREE_NS = "git-worktree";
54
+ /** The settings-facing subset of the config: the worktree storage root, the
55
+ * sidebar grouping switch, and the create/prune behavior switches. */
30
56
  export interface SectionConfig {
31
57
  /** Worktree storage root; absent/blank selects `$DSH_HOME/gitworktree`. */
32
58
  rootDir?: string;
33
59
  /** Whether the sidebar groups same-repository workspaces; absent = on. */
34
60
  groupSidebar?: boolean;
61
+ /** Fetch every remote before creating a worktree; absent = off. */
62
+ fetchBeforeCreate?: boolean;
63
+ /** Prune stale worktrees lazily after each creation; absent = off. */
64
+ autoPruneWorktrees?: boolean;
65
+ /** Global cap the lazy prune trims down to; absent = 30. */
66
+ keepWorktrees?: number;
35
67
  }
36
68
  /** Schema resolving the `git-worktree` settings section. */
37
69
  export declare const sectionSchema: z<SectionConfig>;
38
- /** The section-shaped view of a config: absent keys stay absent (`exactOptionalPropertyTypes`). */
70
+ /** The shipped prune cap (whole storage root, valid git worktrees only). */
71
+ export declare const KEEP_WORKTREES_DEFAULT = 30;
72
+ /** The section-shaped view of a config: absent keys stay absent
73
+ * (`exactOptionalPropertyTypes`) except the switches, which spell their
74
+ * shipped defaults so a user-layer unset can always fall back to them. */
39
75
  export declare function sectionOf(config: Config): SectionConfig;
40
76
  /**
41
77
  * Plugin apply: install the settings section, migrate any legacy stored root