@laoyuehanni/dsh-git-worktree 0.4.4 → 0.4.6-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/wire.d.ts CHANGED
@@ -12,8 +12,15 @@ export declare const ROUTE_STATUS = "/plugin/git-worktree/status";
12
12
  export declare const ROUTE_WORKTREE = "/plugin/git-worktree/worktree";
13
13
  /** POST ROUTE_PREFIX/switch — in-place branch switch of the main checkout. */
14
14
  export declare const ROUTE_SWITCH = "/plugin/git-worktree/switch";
15
- /** POST ROUTE_PREFIX/branch — create a NEW branch from the current checkout and switch to it. */
15
+ /** POST ROUTE_PREFIX/branch — create a NEW branch (at the current checkout
16
+ * or an explicit start point, with or without checking it out). */
16
17
  export declare const ROUTE_BRANCH = "/plugin/git-worktree/branch";
18
+ /** POST ROUTE_PREFIX/branch-rename — rename a LOCAL branch (refs are
19
+ * repository-wide; worktree HEADs pointing at it follow). */
20
+ export declare const ROUTE_BRANCH_RENAME = "/plugin/git-worktree/branch-rename";
21
+ /** POST ROUTE_PREFIX/branch-delete — delete a LOCAL branch (`-d`, merged
22
+ * only; git refuses the rest). */
23
+ export declare const ROUTE_BRANCH_DELETE = "/plugin/git-worktree/branch-delete";
17
24
  /** POST ROUTE_PREFIX/fetch — sync remote-tracking refs (fetch every remote + prune). */
18
25
  export declare const ROUTE_FETCH = "/plugin/git-worktree/fetch";
19
26
  /** POST ROUTE_PREFIX/update — fast-forward the current branch to its upstream. */
@@ -28,6 +35,12 @@ export declare const ROUTE_REMOVE = "/plugin/git-worktree/remove";
28
35
  export declare const ROUTE_EXISTS = "/plugin/git-worktree/exists";
29
36
  /** POST ROUTE_PREFIX/ensure-directory — mkdir -p a missing worktree storage slot. */
30
37
  export declare const ROUTE_ENSURE_DIRECTORY = "/plugin/git-worktree/ensure-directory";
38
+ /** POST ROUTE_PREFIX/worktrees-all — scan the storage root: git facts for
39
+ * every direct child directory (the plugin-planned worktree slots). */
40
+ export declare const ROUTE_WORKTREES_ALL = "/plugin/git-worktree/worktrees-all";
41
+ /** POST ROUTE_PREFIX/purge — delete a NON-git directory sitting DIRECTLY in
42
+ * the storage root (an orphaned leftover whose .git is already gone). */
43
+ export declare const ROUTE_PURGE = "/plugin/git-worktree/purge";
31
44
  /** One selectable branch row. */
32
45
  export interface BranchEntry {
33
46
  /** Display name: a bare local name (`main`) or `<remote>/<name>`. */
@@ -57,6 +70,11 @@ export type RepoStatus = {
57
70
  repoName: string;
58
71
  /** Absolute path of the main worktree directory. */
59
72
  repoRoot: string;
73
+ /** True when the queried directory IS the main worktree (its own
74
+ * toplevel holds the shared `.git`). The client's "session sits in a
75
+ * linked worktree" trigger — `repoRoot` cannot answer it, since it
76
+ * names the main checkout from every worktree by construction. */
77
+ main: boolean;
60
78
  /** Branch checked out by the directory the client asked about. */
61
79
  currentBranch: string;
62
80
  /** Local branches plus every remote's remote-only branches (those
@@ -87,6 +105,21 @@ export interface CreateWorktreeResult {
87
105
  path: string;
88
106
  /** False when an existing worktree for the branch was reused. */
89
107
  created: boolean;
108
+ /** Present only when the pre-create remote sync (`fetchBeforeCreate`) was
109
+ * enabled AND failed: the creation went ahead anyway (a local worktree
110
+ * never consumes the fetch), this carries git's stderr summary for the
111
+ * client to toast. */
112
+ fetchWarning?: string;
113
+ /** Present only when the idempotent write of `/.dsh/gitworktree/` into
114
+ * `<repo>/.git/info/exclude` failed: the worktree was created anyway (it
115
+ * cannot be rolled back), so the SOURCE REPOSITORY now shows an untracked
116
+ * `.dsh/` directory — the client must toast this or the user's next
117
+ * `git status` reads as a mystery. */
118
+ excludeWarning?: string;
119
+ /** Present only when copying declared configuration files into the new
120
+ * worktree failed for one or more files: the worktree was created anyway,
121
+ * this carries a summary of the failed copies for the client to toast. */
122
+ copyWarning?: string;
90
123
  }
91
124
  /** POST switch request body. */
92
125
  export interface SwitchBody {
@@ -102,15 +135,52 @@ export interface SwitchResult {
102
135
  }
103
136
  /** POST branch request body. */
104
137
  export interface CreateBranchBody {
105
- /** Any directory inside the repository (workspace cwd) — the new branch is
106
- * cut from whatever this directory's HEAD points at and checked out HERE. */
138
+ /** Any directory inside the repository (workspace cwd). Without `from` the
139
+ * new branch is cut from whatever this directory's HEAD points at and
140
+ * checked out HERE. */
107
141
  repoPath: string;
108
142
  /** User-typed name of the branch to create (a local name, verbatim). */
109
143
  name: string;
144
+ /** Optional start point (a local branch or a remote-tracking ref like
145
+ * `origin/feat-x`). Absent keeps the original in-place semantics: create
146
+ * AND check out here. */
147
+ from?: string;
148
+ /** With `from`, ALSO check the new branch out in the queried directory
149
+ * (`git switch -c <name> <from>`) instead of leaving every checkout
150
+ * untouched (`git branch <name> <from>`). Ignored without `from` —
151
+ * the no-`from` shape always checks out. */
152
+ checkout?: boolean;
110
153
  }
111
154
  /** POST branch response body. */
112
155
  export interface CreateBranchResult {
113
- /** The branch created and now checked out. */
156
+ /** The branch created; checked out in the queried directory unless
157
+ * created at a start point with `checkout` left false. */
158
+ branch: string;
159
+ }
160
+ /** POST branch-rename request body. */
161
+ export interface RenameBranchBody {
162
+ /** Any directory inside the repository (branch refs are repository-wide). */
163
+ repoPath: string;
164
+ /** The branch to rename (a LOCAL name; remote branches are not ours). */
165
+ name: string;
166
+ /** User-typed new name (a local name, verbatim). */
167
+ newName: string;
168
+ }
169
+ /** POST branch-rename response body. */
170
+ export interface RenameBranchResult {
171
+ /** The branch's new name. */
172
+ branch: string;
173
+ }
174
+ /** POST branch-delete request body. */
175
+ export interface DeleteBranchBody {
176
+ /** Any directory inside the repository (branch refs are repository-wide). */
177
+ repoPath: string;
178
+ /** The branch to delete (a LOCAL name; remote branches are not ours). */
179
+ name: string;
180
+ }
181
+ /** POST branch-delete response body. */
182
+ export interface DeleteBranchResult {
183
+ /** The branch that was deleted. */
114
184
  branch: string;
115
185
  }
116
186
  /** POST fetch request body. */
@@ -215,7 +285,7 @@ export interface PathExistsResult {
215
285
  /** POST ensure-directory request body. */
216
286
  export interface EnsureDirectoryBody {
217
287
  /** The missing directory to create (absolute; must sit directly inside the
218
- * worktree storage root). */
288
+ * legacy storage root or a repository's `.dsh/gitworktree`). */
219
289
  path: string;
220
290
  }
221
291
  /** POST ensure-directory response body. */
@@ -224,3 +294,57 @@ export interface EnsureDirectoryResult {
224
294
  * present as a directory). */
225
295
  created: boolean;
226
296
  }
297
+ /** POST worktrees-all request body (all-optional for shape compatibility). */
298
+ export interface WorktreesAllBody {
299
+ /** Absolute directories of the REGISTERED workspaces, from which the host
300
+ * derives the repository-root set to scan `<repo>/.dsh/gitworktree` under
301
+ * (each probed once, deduplicated). Absent/empty scans only the legacy
302
+ * storage root. */
303
+ workspaces?: string[];
304
+ }
305
+ /** One direct child directory of a worktree storage location. */
306
+ export interface WorktreeScanEntry {
307
+ /** Absolute directory path. */
308
+ path: string;
309
+ /** Main repository directory basename; null = the directory is not inside
310
+ * a git repository (an orphan or foreign folder — shown as unrecognized,
311
+ * never deleted, never counted against the prune cap). */
312
+ repoName: string | null;
313
+ /** Branch checked out by the directory; null = unrecognized, detached, or
314
+ * unborn HEAD. */
315
+ branch: string | null;
316
+ /** Where the directory lives: `project` = inside `<repo>/.dsh/gitworktree`
317
+ * (the current layout, auto-nested under its repository by the workspace
318
+ * tree), `legacy` = inside the historical central storage root. */
319
+ source: 'legacy' | 'project';
320
+ }
321
+ /** POST worktrees-all response body — one entry per DIRECT child of each
322
+ * scanned storage location; a missing location answers its half as an empty
323
+ * list. */
324
+ export interface WorktreesAllResult {
325
+ worktrees: WorktreeScanEntry[];
326
+ /** The resolved LEGACY storage root (historical central location): kept
327
+ * read-only in the settings card so existing users can still find where
328
+ * their old worktrees live. */
329
+ legacyRoot: string;
330
+ /** False when the legacy root does not exist on disk — "未使用" rather
331
+ * than hiding the field. */
332
+ legacyRootExists: boolean;
333
+ /** Present and true when either scanned location held more children than
334
+ * the scan probes: the list is the first slice, and the client says so
335
+ * rather than presenting a truncated scan as the whole picture. */
336
+ truncated?: boolean;
337
+ }
338
+ /** POST purge request body. */
339
+ export interface PurgeDirectoryBody {
340
+ /** The leftover directory to delete (absolute; must sit directly inside
341
+ * the legacy storage root or a repository's `.dsh/gitworktree`, AND have
342
+ * no git identity). */
343
+ path: string;
344
+ }
345
+ /** POST purge response body. */
346
+ export interface PurgeDirectoryResult {
347
+ /** Always true on 200 — the directory (contents included) is gone. */
348
+ path: string;
349
+ removed: boolean;
350
+ }
package/lib/wire.js CHANGED
@@ -12,8 +12,15 @@ export const ROUTE_STATUS = `${ROUTE_PREFIX}/status`;
12
12
  export const ROUTE_WORKTREE = `${ROUTE_PREFIX}/worktree`;
13
13
  /** POST ROUTE_PREFIX/switch — in-place branch switch of the main checkout. */
14
14
  export const ROUTE_SWITCH = `${ROUTE_PREFIX}/switch`;
15
- /** POST ROUTE_PREFIX/branch — create a NEW branch from the current checkout and switch to it. */
15
+ /** POST ROUTE_PREFIX/branch — create a NEW branch (at the current checkout
16
+ * or an explicit start point, with or without checking it out). */
16
17
  export const ROUTE_BRANCH = `${ROUTE_PREFIX}/branch`;
18
+ /** POST ROUTE_PREFIX/branch-rename — rename a LOCAL branch (refs are
19
+ * repository-wide; worktree HEADs pointing at it follow). */
20
+ export const ROUTE_BRANCH_RENAME = `${ROUTE_PREFIX}/branch-rename`;
21
+ /** POST ROUTE_PREFIX/branch-delete — delete a LOCAL branch (`-d`, merged
22
+ * only; git refuses the rest). */
23
+ export const ROUTE_BRANCH_DELETE = `${ROUTE_PREFIX}/branch-delete`;
17
24
  /** POST ROUTE_PREFIX/fetch — sync remote-tracking refs (fetch every remote + prune). */
18
25
  export const ROUTE_FETCH = `${ROUTE_PREFIX}/fetch`;
19
26
  /** POST ROUTE_PREFIX/update — fast-forward the current branch to its upstream. */
@@ -28,3 +35,9 @@ export const ROUTE_REMOVE = `${ROUTE_PREFIX}/remove`;
28
35
  export const ROUTE_EXISTS = `${ROUTE_PREFIX}/exists`;
29
36
  /** POST ROUTE_PREFIX/ensure-directory — mkdir -p a missing worktree storage slot. */
30
37
  export const ROUTE_ENSURE_DIRECTORY = `${ROUTE_PREFIX}/ensure-directory`;
38
+ /** POST ROUTE_PREFIX/worktrees-all — scan the storage root: git facts for
39
+ * every direct child directory (the plugin-planned worktree slots). */
40
+ export const ROUTE_WORKTREES_ALL = `${ROUTE_PREFIX}/worktrees-all`;
41
+ /** POST ROUTE_PREFIX/purge — delete a NON-git directory sitting DIRECTLY in
42
+ * the storage root (an orphaned leftover whose .git is already gone). */
43
+ export const ROUTE_PURGE = `${ROUTE_PREFIX}/purge`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laoyuehanni/dsh-git-worktree",
3
- "version": "0.4.4",
3
+ "version": "0.4.6-rc.1",
4
4
  "description": "DSH plugin: branch visibility and git worktree isolation for Web UI sessions",
5
5
  "keywords": [
6
6
  "dsh",
@@ -57,63 +57,81 @@
57
57
  "platform": "web",
58
58
  "inject": [
59
59
  "@deepseek-ai/dsh-client-ui-conversation",
60
- "@deepseek-ai/dsh-client-ui-sidebar",
61
60
  "@deepseek-ai/dsh-client-ui-settings",
62
- "@deepseek-ai/dsh-client-ui-settings-plugins",
61
+ "@deepseek-ai/dsh-client-ui-plugin-manager",
63
62
  "@deepseek-ai/dsh-client-ui-workspace"
64
63
  ]
65
64
  }
66
65
  },
67
- "scripts": {
68
- "build": "tsc -p tsconfig.json",
69
- "build:client": "tsdown",
70
- "build:all": "npm run build && npm run build:client",
71
- "watch:client": "tsdown --watch",
72
- "test": "vitest run",
73
- "typecheck": "tsc -p tsconfig.client.json --noEmit",
74
- "prepublishOnly": "npm run typecheck && npm test && npm run build && npm run build:client"
75
- },
76
66
  "peerDependencies": {
77
- "@deepseek-ai/cordis": "^4.0.1",
78
- "@deepseek-ai/dsh-host-webserver": "^0.1.2-rc.1",
79
- "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
80
- "@deepseek-ai/schemastery": "^3.18.1"
67
+ "@deepseek-ai/cordis": "^4.0.3",
68
+ "@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.1",
69
+ "@deepseek-ai/dsh-settings": "^0.1.7-rc.1",
70
+ "@deepseek-ai/schemastery": "^3.18.3"
81
71
  },
82
72
  "devDependencies": {
83
- "@deepseek-ai/cordis": "^4.0.2",
84
- "@deepseek-ai/dsh-api-gateway": "^0.1.2-rc.1",
85
- "@deepseek-ai/dsh-api-remotes": "^0.1.2-rc.1",
86
- "@deepseek-ai/dsh-api-session-controller": "^0.1.2-rc.1",
87
- "@deepseek-ai/dsh-api-workspace-controller": "^0.1.2-rc.1",
88
- "@deepseek-ai/dsh-client-locale": "^0.1.2-rc.1",
89
- "@deepseek-ai/dsh-client-connection": "^0.1.2-rc.1",
90
- "@deepseek-ai/dsh-client-store": "^0.1.2-rc.1",
91
- "@deepseek-ai/dsh-client-ui-conversation": "^0.1.2-rc.1",
92
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.2-rc.1",
93
- "@deepseek-ai/dsh-client-ui-renderer": "^0.1.2-rc.1",
94
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.2-rc.1",
95
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.2-rc.1",
96
- "@deepseek-ai/dsh-client-ui-session": "^0.1.2-rc.1",
97
- "@deepseek-ai/dsh-client-ui-sidebar": "^0.1.2-rc.1",
98
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.2-rc.1",
99
- "@deepseek-ai/dsh-client-ui-workspace": "^0.1.2-rc.1",
100
- "@deepseek-ai/dsh-host-webserver": "^0.1.2-rc.1",
101
- "@deepseek-ai/dsh-session": "^0.1.2-rc.1",
102
- "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
103
- "@deepseek-ai/dsh-util-workspace-path": "^0.1.2-rc.1",
104
- "@deepseek-ai/dsh-workspace": "^0.1.2-rc.1",
105
- "@deepseek-ai/schemastery": "^3.18.1",
73
+ "@deepseek-ai/cordis": "^4.0.3",
74
+ "@deepseek-ai/dsh-api-gateway": "^0.1.7-rc.1",
75
+ "@deepseek-ai/dsh-api-remotes": "^0.1.7-rc.1",
76
+ "@deepseek-ai/dsh-api-session-controller": "^0.1.7-rc.1",
77
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.1.7-rc.1",
78
+ "@deepseek-ai/dsh-client-locale": "^0.1.7-rc.1",
79
+ "@deepseek-ai/dsh-client-connection": "^0.1.7-rc.1",
80
+ "@deepseek-ai/dsh-client-store": "^0.1.7-rc.1",
81
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.7-rc.1",
82
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "^0.1.7-rc.1",
83
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.7-rc.1",
84
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.7-rc.1",
85
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.7-rc.1",
86
+ "@deepseek-ai/dsh-client-ui-session": "^0.1.7-rc.1",
87
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.7-rc.1",
88
+ "@deepseek-ai/dsh-client-ui-workspace": "^0.1.7-rc.1",
89
+ "@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.1",
90
+ "@deepseek-ai/dsh-session": "^0.1.7-rc.1",
91
+ "@deepseek-ai/dsh-settings": "^0.1.7-rc.1",
92
+ "@deepseek-ai/dsh-util-workspace-path": "^0.1.7-rc.1",
93
+ "@deepseek-ai/schemastery": "^3.18.3",
94
+ "@shikijs/langs": "^4.3.1",
95
+ "@types/mdast": "^4.0.4",
106
96
  "@types/node": "^24.13.3",
107
97
  "@types/react": "~18.3.1",
108
98
  "@types/react-dom": "~18.3.1",
99
+ "anser": "^2.3.5",
100
+ "clsx": "^2.1.1",
101
+ "diff": "^9.0.0",
102
+ "immer": "^10.1.1",
103
+ "katex": "^0.16.47",
104
+ "mdast-util-from-markdown": "^2.0.3",
105
+ "mdast-util-gfm": "^3.1.0",
106
+ "mdast-util-math": "^3.0.0",
107
+ "micromark-core-commonmark": "^2.0.3",
108
+ "micromark-extension-gfm": "^3.0.0",
109
+ "micromark-extension-math": "^3.1.0",
110
+ "micromark-factory-space": "^2.0.1",
111
+ "micromark-util-character": "^2.1.1",
112
+ "micromark-util-classify-character": "^2.0.1",
113
+ "micromark-util-sanitize-uri": "^2.0.1",
114
+ "micromark-util-symbol": "^2.0.1",
115
+ "micromark-util-types": "^2.0.2",
109
116
  "playwright-core": "^1.55.1",
110
117
  "react": "^18.2.0",
111
118
  "react-dom": "^18.2.0",
119
+ "shiki": "^4.3.1",
120
+ "simple-icons": "16.31.0",
112
121
  "tsdown": "^0.14.0",
113
122
  "typescript": "^5.9.3",
114
- "vitest": "^3.2.4"
123
+ "vitest": "^3.2.4",
124
+ "zustand": "~4.4.7"
115
125
  },
116
126
  "engines": {
117
127
  "node": ">=22.19"
128
+ },
129
+ "scripts": {
130
+ "build": "tsc -p tsconfig.json",
131
+ "build:client": "tsdown",
132
+ "build:all": "pnpm run build && pnpm run build:client",
133
+ "watch:client": "tsdown --watch",
134
+ "test": "vitest run",
135
+ "typecheck": "tsc -p tsconfig.client.json --noEmit"
118
136
  }
119
- }
137
+ }