@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/index.js 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
  *
@@ -14,19 +14,34 @@
14
14
  */
15
15
  import { homedir } from 'node:os';
16
16
  import { rename } from 'node:fs/promises';
17
- import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
18
17
  import z from '@deepseek-ai/schemastery';
19
18
  import { childProcessExec } from './git.js';
20
- import { handleCreateBranch, handleCreateWorktree, handleEnsureDirectory, handleFetch, handleGroupWorktrees, handleInspectWorktree, handlePathExists, handleRemoveWorktree, handleStatus, handleSwitch, handleUpdate, } from './routes.js';
19
+ import { handleCreateBranch, handleCreateWorktree, handleDeleteBranch, handleEnsureDirectory, handleFetch, handleGroupWorktrees, handleInspectWorktree, handlePathExists, handlePurgeDirectory, handleRemoveWorktree, handleRenameBranch, handleStatus, handleSwitch, handleUpdate, handleWorktreesAll, } from './routes.js';
21
20
  import { loadLegacySettings, migratedFileOf, planLegacyMigration, settingsFileOf, validateRootDir, } from './settings.js';
22
- import { ROUTE_BRANCH, ROUTE_ENSURE_DIRECTORY, ROUTE_EXISTS, ROUTE_FETCH, ROUTE_GROUP, ROUTE_INSPECT, ROUTE_REMOVE, ROUTE_STATUS, ROUTE_SWITCH, ROUTE_UPDATE, ROUTE_WORKTREE } from './wire.js';
21
+ import { ROUTE_BRANCH, ROUTE_BRANCH_DELETE, ROUTE_BRANCH_RENAME, ROUTE_ENSURE_DIRECTORY, ROUTE_EXISTS, ROUTE_FETCH, ROUTE_GROUP, ROUTE_INSPECT, ROUTE_PURGE, ROUTE_REMOVE, ROUTE_STATUS, ROUTE_SWITCH, ROUTE_UPDATE, ROUTE_WORKTREE, ROUTE_WORKTREES_ALL } from './wire.js';
23
22
  export const name = 'dsh-git-worktree';
24
23
  export const inject = [];
25
24
  /** Largest accepted request body (bytes) — these payloads are a few strings. */
26
25
  const BODY_LIMIT = 64 * 1024;
26
+ /**
27
+ * Cordis resolves the composition entry's config through this schema before
28
+ * `apply` runs (official plugin-config convention: export the `Config` type
29
+ * and a same-named Schemastery schema). It fills the `groupSidebar` default;
30
+ * `rootDir` passes through untouched — its absence stays observable so the
31
+ * settings section keeps spelling the resolved default. Constraints the
32
+ * schema cannot express still fail loudly in validateConfig below (absolute
33
+ * path; unknown keys — schemastery keeps extras instead of rejecting them).
34
+ */
35
+ export const Config = z.object({
36
+ rootDir: z.string(),
37
+ groupSidebar: z.boolean().default(true),
38
+ fetchBeforeCreate: z.boolean().default(false),
39
+ autoPruneWorktrees: z.boolean().default(false),
40
+ keepWorktrees: z.number(),
41
+ });
27
42
  /** Reject stale or misspelled config keys before defaults can hide them. */
28
43
  export function validateConfig(config) {
29
- const unknown = Object.keys(config).find(key => key !== 'rootDir' && key !== 'groupSidebar');
44
+ const unknown = Object.keys(config).find(key => key !== 'rootDir' && key !== 'groupSidebar' && key !== 'fetchBeforeCreate' && key !== 'autoPruneWorktrees' && key !== 'keepWorktrees');
30
45
  if (unknown !== undefined) {
31
46
  throw new Error(`GitWorktreeConfig: unknown key "${unknown}"`);
32
47
  }
@@ -36,22 +51,52 @@ export function validateConfig(config) {
36
51
  if (config.groupSidebar !== undefined && typeof config.groupSidebar !== 'boolean') {
37
52
  throw new Error('GitWorktreeConfig: "groupSidebar" must be a boolean');
38
53
  }
54
+ if (config.fetchBeforeCreate !== undefined && typeof config.fetchBeforeCreate !== 'boolean') {
55
+ throw new Error('GitWorktreeConfig: "fetchBeforeCreate" must be a boolean');
56
+ }
57
+ if (config.autoPruneWorktrees !== undefined && typeof config.autoPruneWorktrees !== 'boolean') {
58
+ throw new Error('GitWorktreeConfig: "autoPruneWorktrees" must be a boolean');
59
+ }
60
+ validateKeepWorktrees(config.keepWorktrees);
39
61
  validateRootDir(config.rootDir);
40
62
  }
63
+ /**
64
+ * The prune cap must be an integer >= 1: 0 would read as "create then
65
+ * immediately self-delete" (the fresh worktree is excluded, but every other
66
+ * one dies on the next creation), a fraction cannot count directories.
67
+ * Absent = the shipped default, which passes.
68
+ */
69
+ export function validateKeepWorktrees(value) {
70
+ if (value === undefined)
71
+ return;
72
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < 1) {
73
+ throw new Error('GitWorktreeConfig: "keepWorktrees" must be an integer >= 1');
74
+ }
75
+ }
41
76
  /** The settings namespace this plugin serves; its browser card spells the same string. */
42
- export const GIT_WORKTREE_NS = settingsNamespace('git-worktree');
77
+ export const GIT_WORKTREE_NS = 'git-worktree';
43
78
  /** Schema resolving the `git-worktree` settings section. */
44
79
  export const sectionSchema = z.object({
45
80
  rootDir: z.string(),
46
81
  groupSidebar: z.boolean(),
82
+ fetchBeforeCreate: z.boolean(),
83
+ autoPruneWorktrees: z.boolean(),
84
+ keepWorktrees: z.number(),
47
85
  });
48
- /** The section-shaped view of a config: absent keys stay absent (`exactOptionalPropertyTypes`). */
86
+ /** The shipped prune cap (whole storage root, valid git worktrees only). */
87
+ export const KEEP_WORKTREES_DEFAULT = 30;
88
+ /** The section-shaped view of a config: absent keys stay absent
89
+ * (`exactOptionalPropertyTypes`) except the switches, which spell their
90
+ * shipped defaults so a user-layer unset can always fall back to them. */
49
91
  export function sectionOf(config) {
50
92
  return {
51
93
  ...(config.rootDir === undefined ? {} : { rootDir: config.rootDir }),
52
- // The composition layer spells the shipped default (grouping ON) so a
53
- // user-layer unset can always fall back to it.
94
+ // The composition layer spells the shipped defaults so a user-layer
95
+ // unset can always fall back to them.
54
96
  groupSidebar: config.groupSidebar ?? true,
97
+ fetchBeforeCreate: config.fetchBeforeCreate ?? false,
98
+ autoPruneWorktrees: config.autoPruneWorktrees ?? false,
99
+ keepWorktrees: config.keepWorktrees ?? KEEP_WORKTREES_DEFAULT,
55
100
  };
56
101
  }
57
102
  /**
@@ -70,24 +115,39 @@ export function apply(ctx, config = {}) {
70
115
  const deps = () => ({
71
116
  exec: childProcessExec,
72
117
  sectionRootDir: () => sectionSource().rootDir,
118
+ sectionFetchBeforeCreate: () => sectionSource().fetchBeforeCreate,
73
119
  home: () => homedir(),
74
120
  envHome: () => process.env.DSH_HOME,
75
121
  });
76
- installSettingsSection(ctx, GIT_WORKTREE_NS, sectionSchema, sectionOf(config), {
77
- validate: value => {
78
- validateRootDir(value.rootDir);
79
- if (value.groupSidebar !== undefined && typeof value.groupSidebar !== 'boolean') {
80
- throw new Error('groupSidebar must be a boolean');
81
- }
82
- },
83
- setSource: (source) => { sectionSource = source; },
84
- onChange: () => {
85
- // The storage root takes effect live: the routes read the section
86
- // source per request, so a committed edit needs no action here.
87
- },
122
+ // Host 0.1.2 hosts section installation on the provider itself: the same
123
+ // composition-entry base, validate, setSource, and onChange hooks ride
124
+ // `SettingsProvider.installSection`, reached through a settings injection.
125
+ // The registration is an effect on this plugin's fiber either way, so a
126
+ // late-attaching settings service is handled by the injection itself.
127
+ ctx.inject(['settings'], (settingsCtx) => {
128
+ settingsCtx.settings.installSection(ctx, GIT_WORKTREE_NS, sectionSchema, sectionOf(config), {
129
+ validate: value => {
130
+ validateRootDir(value.rootDir);
131
+ if (value.groupSidebar !== undefined && typeof value.groupSidebar !== 'boolean') {
132
+ throw new Error('groupSidebar must be a boolean');
133
+ }
134
+ if (value.fetchBeforeCreate !== undefined && typeof value.fetchBeforeCreate !== 'boolean') {
135
+ throw new Error('fetchBeforeCreate must be a boolean');
136
+ }
137
+ if (value.autoPruneWorktrees !== undefined && typeof value.autoPruneWorktrees !== 'boolean') {
138
+ throw new Error('autoPruneWorktrees must be a boolean');
139
+ }
140
+ validateKeepWorktrees(value.keepWorktrees);
141
+ },
142
+ setSource: (source) => { sectionSource = source; },
143
+ onChange: () => {
144
+ // The storage root takes effect live: the routes read the section
145
+ // source per request, so a committed edit needs no action here.
146
+ },
147
+ });
88
148
  });
89
149
  // One-shot legacy migration: the pre-0.3 plugin persisted its own
90
- // ~/.dsh/git-work-tree/settings.json. Registered after installSettingsSection
150
+ // ~/.dsh/git-work-tree/settings.json. Registered after installSection
91
151
  // so the namespace is on the ledger by the time this fiber runs; a failure
92
152
  // (or a user layer that already chose) leaves both documents exactly as
93
153
  // they are, and the next startup retries.
@@ -146,90 +206,38 @@ export function apply(ctx, config = {}) {
146
206
  });
147
207
  req.on('error', rejectPromise);
148
208
  });
209
+ /** One exact POST route: bounded JSON body in, one RouteOutcome out. A
210
+ * body-level failure (too large, invalid JSON) answers 400 and leaves
211
+ * the server alive; handler outcomes carry their own status codes. */
212
+ const postRoute = (path, label, handle) => {
213
+ webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path, handler: async (req, res) => {
214
+ try {
215
+ send(res, await handle(deps(), await readJson(req)));
216
+ }
217
+ catch (error) {
218
+ send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
219
+ }
220
+ } }), `git-worktree: ${label} route`);
221
+ };
222
+ // The one query-driven route; every mutation is a POST body.
149
223
  webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_STATUS, handler: async (req, res) => {
150
224
  /* v8 ignore next -- node:http always sets url on server requests. */
151
225
  const query = new URL(req.url ?? '/', 'http://x').searchParams;
152
226
  send(res, await handleStatus(deps(), query.get('path') ?? undefined));
153
227
  } }), 'git-worktree: status route');
154
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_WORKTREE, handler: async (req, res) => {
155
- try {
156
- send(res, await handleCreateWorktree(deps(), await readJson(req)));
157
- }
158
- catch (error) {
159
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
160
- }
161
- } }), 'git-worktree: worktree route');
162
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_SWITCH, handler: async (req, res) => {
163
- try {
164
- send(res, await handleSwitch(deps(), await readJson(req)));
165
- }
166
- catch (error) {
167
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
168
- }
169
- } }), 'git-worktree: switch route');
170
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_BRANCH, handler: async (req, res) => {
171
- try {
172
- send(res, await handleCreateBranch(deps(), await readJson(req)));
173
- }
174
- catch (error) {
175
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
176
- }
177
- } }), 'git-worktree: branch route');
178
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_FETCH, handler: async (req, res) => {
179
- try {
180
- send(res, await handleFetch(deps(), await readJson(req)));
181
- }
182
- catch (error) {
183
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
184
- }
185
- } }), 'git-worktree: fetch route');
186
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_GROUP, handler: async (req, res) => {
187
- try {
188
- send(res, await handleGroupWorktrees(deps(), await readJson(req)));
189
- }
190
- catch (error) {
191
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
192
- }
193
- } }), 'git-worktree: group route');
194
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_UPDATE, handler: async (req, res) => {
195
- try {
196
- send(res, await handleUpdate(deps(), await readJson(req)));
197
- }
198
- catch (error) {
199
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
200
- }
201
- } }), 'git-worktree: update route');
202
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_INSPECT, handler: async (req, res) => {
203
- try {
204
- send(res, await handleInspectWorktree(deps(), await readJson(req)));
205
- }
206
- catch (error) {
207
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
208
- }
209
- } }), 'git-worktree: inspect route');
210
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_REMOVE, handler: async (req, res) => {
211
- try {
212
- send(res, await handleRemoveWorktree(deps(), await readJson(req)));
213
- }
214
- catch (error) {
215
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
216
- }
217
- } }), 'git-worktree: remove route');
218
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_EXISTS, handler: async (req, res) => {
219
- try {
220
- send(res, await handlePathExists(deps(), await readJson(req)));
221
- }
222
- catch (error) {
223
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
224
- }
225
- } }), 'git-worktree: exists route');
226
- webCtx.effect(() => webCtx.webServer.register({ kind: 'exact', path: ROUTE_ENSURE_DIRECTORY, handler: async (req, res) => {
227
- try {
228
- send(res, await handleEnsureDirectory(deps(), await readJson(req)));
229
- }
230
- catch (error) {
231
- send(res, { status: 400, body: { error: error instanceof Error ? error.message : String(error) } });
232
- }
233
- } }), 'git-worktree: ensure-directory route');
228
+ postRoute(ROUTE_WORKTREE, 'worktree', handleCreateWorktree);
229
+ postRoute(ROUTE_SWITCH, 'switch', handleSwitch);
230
+ postRoute(ROUTE_BRANCH, 'branch', handleCreateBranch);
231
+ postRoute(ROUTE_BRANCH_RENAME, 'branch-rename', handleRenameBranch);
232
+ postRoute(ROUTE_BRANCH_DELETE, 'branch-delete', handleDeleteBranch);
233
+ postRoute(ROUTE_FETCH, 'fetch', handleFetch);
234
+ postRoute(ROUTE_GROUP, 'group', handleGroupWorktrees);
235
+ postRoute(ROUTE_UPDATE, 'update', handleUpdate);
236
+ postRoute(ROUTE_INSPECT, 'inspect', handleInspectWorktree);
237
+ postRoute(ROUTE_REMOVE, 'remove', handleRemoveWorktree);
238
+ postRoute(ROUTE_EXISTS, 'exists', handlePathExists);
239
+ postRoute(ROUTE_ENSURE_DIRECTORY, 'ensure-directory', handleEnsureDirectory);
240
+ postRoute(ROUTE_WORKTREES_ALL, 'worktrees-all', handleWorktreesAll);
241
+ postRoute(ROUTE_PURGE, 'purge', handlePurgeDirectory);
234
242
  });
235
243
  }
package/lib/routes.d.ts CHANGED
@@ -3,12 +3,14 @@
3
3
  * shell (index.ts) owns req/res mechanics; everything testable lives here.
4
4
  */
5
5
  import { type DirExists, type Exec } from './git.js';
6
- import type { CreateBranchResult, CreateWorktreeResult, EnsureDirectoryResult, FetchResult, GroupWorkspacesResult, InspectWorktreeResult, PathExistsResult, RemoveWorktreeResult, RepoStatus, RouteError, SwitchResult, UpdateResult } from './wire.js';
6
+ import type { CreateBranchResult, CreateWorktreeResult, EnsureDirectoryResult, FetchResult, GroupWorkspacesResult, InspectWorktreeResult, PathExistsResult, PurgeDirectoryResult, RemoveWorktreeResult, RepoStatus, RouteError, SwitchResult, UpdateResult, WorktreesAllResult } from './wire.js';
7
7
  /** Everything the handlers need from the host half. */
8
8
  export interface RouteDeps {
9
9
  exec: Exec;
10
10
  /** The settings-resolved rootDir (absent/blank = the default location). */
11
11
  sectionRootDir: () => string | undefined;
12
+ /** Whether a worktree creation syncs the remotes first (absent = off). */
13
+ sectionFetchBeforeCreate: () => boolean | undefined;
12
14
  /** User home directory seam. */
13
15
  home: () => string;
14
16
  /** `$DSH_HOME` environment value seam. */
@@ -20,7 +22,16 @@ export interface RouteDeps {
20
22
  statDirectory?: (path: string) => Promise<boolean>;
21
23
  /** Recursive mkdir seam (fs.mkdir recursive); tests substitute. */
22
24
  mkdirRecursive?: (path: string) => Promise<void>;
25
+ /** One-level directory listing seam (fs.readdir with dirents); tests
26
+ * substitute. */
27
+ listDir?: (path: string) => Promise<string[]>;
28
+ /** Recursive force rm seam (fs.rm with retries); tests substitute. */
29
+ rmRecursive?: (path: string) => Promise<void>;
23
30
  }
31
+ /** Real fs-backed one-level directory listing (names only). Plain FILES are
32
+ * filtered out — the storage root can carry strays (a legacy settings.json
33
+ * was seen in the wild), and the scan lists worktree SLOTS, not entries. */
34
+ export declare function fsListDir(path: string): Promise<string[]>;
24
35
  /** Real fs-backed directory probe: exists and is a directory. */
25
36
  export declare function fsStatDirectory(path: string): Promise<boolean>;
26
37
  /** Real fs-backed recursive mkdir. */
@@ -28,7 +39,7 @@ export declare function fsMkdirRecursive(path: string): Promise<void>;
28
39
  /** One route outcome: HTTP status plus the JSON body. */
29
40
  export interface RouteOutcome {
30
41
  status: number;
31
- body: RepoStatus | CreateWorktreeResult | SwitchResult | CreateBranchResult | FetchResult | UpdateResult | GroupWorkspacesResult | InspectWorktreeResult | RemoveWorktreeResult | PathExistsResult | EnsureDirectoryResult | RouteError;
42
+ body: RepoStatus | CreateWorktreeResult | SwitchResult | CreateBranchResult | FetchResult | UpdateResult | GroupWorkspacesResult | InspectWorktreeResult | RemoveWorktreeResult | PathExistsResult | EnsureDirectoryResult | WorktreesAllResult | PurgeDirectoryResult | RouteError;
32
43
  }
33
44
  /**
34
45
  * POST /group — git belonging facts for a batch of workspace directories.
@@ -40,6 +51,36 @@ export interface RouteOutcome {
40
51
  * @param body - parsed request body: `{ paths }`.
41
52
  */
42
53
  export declare function handleGroupWorktrees(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
54
+ /**
55
+ * POST /worktrees-all — git facts for every DIRECT child directory of the
56
+ * resolved worktree storage root (the slots this plugin plans as
57
+ * `<repoName>-<branch>`). The management dialog's data source: one scan
58
+ * answers for all repositories at once, orphan directories included (a
59
+ * child that probes as no git repository comes back with null facts rather
60
+ * than being dropped — the dialog shows it as unrecognized). A missing
61
+ * storage root answers an empty list; per-child probe failures degrade to
62
+ * null facts, never a 500 — the dialog must render, not error out. A root
63
+ * holding more than {@link SCAN_CHILDREN_LIMIT} children answers its first
64
+ * slice plus `truncated`, so a misconfigured rootDir cannot turn one dialog
65
+ * open into thousands of git spawns.
66
+ * @param deps - host dependencies.
67
+ */
68
+ export declare function handleWorktreesAll(deps: RouteDeps): Promise<RouteOutcome>;
69
+ /** Real fs-backed recursive force rm (Windows file-lock retries included). */
70
+ export declare function fsRmRecursive(path: string): Promise<void>;
71
+ /**
72
+ * POST /purge — delete a NON-git directory sitting DIRECTLY inside the
73
+ * resolved worktree storage root: the orphaned leftover a half-failed
74
+ * `worktree remove` can leave behind (git registration and the .git file
75
+ * already gone, contents stranded on disk). Triple-gated: one level below
76
+ * the root (resolved forms, same slot boundary as /ensure-directory), a
77
+ * real directory, and NOT a git repository — anything git still recognizes
78
+ * must go through /remove, where the removal carries the session-archive
79
+ * and unregistration half. Deletion is a plain recursive force rm.
80
+ * @param deps - host dependencies.
81
+ * @param body - parsed request body: `{ path }`.
82
+ */
83
+ export declare function handlePurgeDirectory(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
43
84
  /**
44
85
  * GET /status 鈥?repository facts for one directory.
45
86
  * @param deps - host dependencies.
@@ -63,14 +104,38 @@ export declare function handleCreateWorktree(deps: RouteDeps, body: unknown): Pr
63
104
  */
64
105
  export declare function handleSwitch(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
65
106
  /**
66
- * POST /branch 鈥?create a NEW branch from the queried directory's current
67
- * checkout (whatever its HEAD points at, detached included) and check it out
68
- * in place. Git validates the name; the client pre-flights the same rules
107
+ * POST /branch — create a NEW branch. Without `from`, from the queried
108
+ * directory's current checkout (whatever its HEAD points at, detached
109
+ * included), checked out in place. With `from` (a local branch or a remote
110
+ * tracking ref): checked out here too when `checkout` is set
111
+ * (`git switch -c <name> <from>`), created with no checkout touched
112
+ * otherwise (`git branch`) — a create aimed at another branch must not
113
+ * silently move the session's HEAD unless the caller asked for exactly
114
+ * that. Git validates both names; the client pre-flights the same rules
69
115
  * and only sends names it already accepts.
70
116
  * @param deps - host dependencies.
71
117
  * @param body - parsed request body.
72
118
  */
73
119
  export declare function handleCreateBranch(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
120
+ /**
121
+ * POST /branch-rename — rename a LOCAL branch (`git branch -m`). Runs at the
122
+ * repository root: branch refs are repository-wide and worktree HEADs
123
+ * pointing at the old name follow the ref. Git validates the new name and
124
+ * refuses a target that already exists; both map to 400 through
125
+ * {@link gitFailure}.
126
+ * @param deps - host dependencies.
127
+ * @param body - parsed request body.
128
+ */
129
+ export declare function handleRenameBranch(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
130
+ /**
131
+ * POST /branch-delete — delete a LOCAL branch with the SAFE form
132
+ * (`git branch -d`): git refuses unmerged commits and branches checked out
133
+ * in any worktree, both mapping to 400 through {@link gitFailure}. No
134
+ * force variant — a menu click must never discard commits.
135
+ * @param deps - host dependencies.
136
+ * @param body - parsed request body.
137
+ */
138
+ export declare function handleDeleteBranch(deps: RouteDeps, body: unknown): Promise<RouteOutcome>;
74
139
  /**
75
140
  * POST /fetch 鈥?sync remote-tracking refs for the repository: fetch every
76
141
  * remote and prune tracking branches the remotes no longer carry. Pure