@laoyuehanni/dsh-git-worktree 0.4.12 → 0.4.14

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.
Files changed (71) hide show
  1. package/README.md +123 -49
  2. package/README.zh.md +123 -49
  3. package/docs/DETAIL.md +16 -0
  4. package/docs/DETAIL.zh.md +16 -0
  5. package/icon.svg +22 -0
  6. package/lib/client.js +727 -448
  7. package/lib/git.d.ts +7 -4
  8. package/lib/git.js +25 -6
  9. package/locale/en.json +5 -1
  10. package/locale/zh.json +2 -1
  11. package/package.json +8 -3
  12. package/lib/graph-preview/asciidoc-xKuVlNk6.js +0 -5
  13. package/lib/graph-preview/bat-Dx8nnxXE.js +0 -5
  14. package/lib/graph-preview/bibtex-BzgdqG3s.js +0 -5
  15. package/lib/graph-preview/c-BGpbtv2-.js +0 -8
  16. package/lib/graph-preview/clojure-DDsQ0FaV.js +0 -5
  17. package/lib/graph-preview/cmake-DPsCB_V6.js +0 -5
  18. package/lib/graph-preview/cpp-CBYrHpV9.js +0 -27
  19. package/lib/graph-preview/csharp-CFKaLbHg.js +0 -5
  20. package/lib/graph-preview/css-C6zsnaz5.js +0 -8
  21. package/lib/graph-preview/csv-DqIVFkK7.js +0 -5
  22. package/lib/graph-preview/dart-C6DUdjib.js +0 -5
  23. package/lib/graph-preview/diff-Blb4MjsC.js +0 -5
  24. package/lib/graph-preview/dotenv-Dkdv7Sm2.js +0 -5
  25. package/lib/graph-preview/elixir-D0Gskj1z.js +0 -8
  26. package/lib/graph-preview/erlang-BJwlUj8s.js +0 -8
  27. package/lib/graph-preview/fish-D7qAeWQz.js +0 -5
  28. package/lib/graph-preview/fsharp-MCvH12ek.js +0 -8
  29. package/lib/graph-preview/go-aXtTCanQ.js +0 -5
  30. package/lib/graph-preview/graphql-DBbDUzBC.js +0 -19
  31. package/lib/graph-preview/groovy-Bw2Ku4bU.js +0 -5
  32. package/lib/graph-preview/haskell-CfGsE1Cf.js +0 -5
  33. package/lib/graph-preview/hcl-DHg_Osgo.js +0 -5
  34. package/lib/graph-preview/html-DwZ-9Aol.js +0 -15
  35. package/lib/graph-preview/html-derivative-CdrGiVx_.js +0 -8
  36. package/lib/graph-preview/http-B769neBI.js +0 -16
  37. package/lib/graph-preview/ini-C24lZfdM.js +0 -5
  38. package/lib/graph-preview/java-B6HH4GJL.js +0 -8
  39. package/lib/graph-preview/javascript-BXA9Hfas.js +0 -5
  40. package/lib/graph-preview/julia--d6L9eAJ.js +0 -19
  41. package/lib/graph-preview/kotlin-BHE8CoV9.js +0 -5
  42. package/lib/graph-preview/latex-BsyjE6iS.js +0 -12
  43. package/lib/graph-preview/less-BzbdhFUi.js +0 -5
  44. package/lib/graph-preview/log-Dad54gsi.js +0 -5
  45. package/lib/graph-preview/lua-DL6V31K-.js +0 -10
  46. package/lib/graph-preview/make-B2ukzWs3.js +0 -5
  47. package/lib/graph-preview/markdown-CkmxmzqY.js +0 -5
  48. package/lib/graph-preview/mdx-BK9ZufRc.js +0 -5
  49. package/lib/graph-preview/nix-BRl3YduB.js +0 -9
  50. package/lib/graph-preview/perl-DJHPR3L5.js +0 -19
  51. package/lib/graph-preview/php-B74oGaLi.js +0 -21
  52. package/lib/graph-preview/powershell-DvOBVZPr.js +0 -5
  53. package/lib/graph-preview/preview.js +0 -79431
  54. package/lib/graph-preview/proto-ClkOcAW0.js +0 -5
  55. package/lib/graph-preview/python-BjnOIxPe.js +0 -5
  56. package/lib/graph-preview/r-BSNufAtJ.js +0 -8
  57. package/lib/graph-preview/rst-CDCHc-qO.js +0 -25
  58. package/lib/graph-preview/ruby-Dx4dTqam.js +0 -40
  59. package/lib/graph-preview/rust-COBzcmTx.js +0 -5
  60. package/lib/graph-preview/scala-pMGZAs9j.js +0 -5
  61. package/lib/graph-preview/scss-D2N2uO1z.js +0 -8
  62. package/lib/graph-preview/sql-DBa5L-Wg.js +0 -8
  63. package/lib/graph-preview/svelte-DQXUqa3J.js +0 -18
  64. package/lib/graph-preview/swift-DWmMn3lF.js +0 -5
  65. package/lib/graph-preview/system-verilog-DW0KSMVO.js +0 -5
  66. package/lib/graph-preview/toml-B7BHZIqX.js +0 -5
  67. package/lib/graph-preview/vb-eGVhCUXq.js +0 -5
  68. package/lib/graph-preview/verilog-Ma7yBE30.js +0 -5
  69. package/lib/graph-preview/vue-k6e1qQTO.js +0 -32
  70. package/lib/graph-preview/xml-DUa-g8pJ.js +0 -10
  71. package/lib/graph-preview/yaml-B81N8prR.js +0 -5
package/lib/git.d.ts CHANGED
@@ -73,12 +73,15 @@ export type DirExists = (path: string) => boolean;
73
73
  export declare const fsDirExists: DirExists;
74
74
  /**
75
75
  * Leftover-directory sweeper after `git worktree remove` unregisters but
76
- * fails the final rmdir (Windows EPERM when a process still has the folder
77
- * as cwd). `gone` = deleted; `empty` = still there but vacant (cwd hold);
78
- * `occupied` = still has files — the caller must not pretend removal finished.
76
+ * fails partway through deleting the tree — a Windows hold (EPERM when a
77
+ * process still has the folder as cwd) or a deep path beyond the 260-char
78
+ * limit (`Filename too long`, node_modules chains). `gone` = deleted;
79
+ * `empty` = still there but vacant (cwd hold); `occupied` = still has
80
+ * files — the caller must not pretend removal finished.
79
81
  */
80
82
  export type SweepDir = (path: string) => Promise<'gone' | 'empty' | 'occupied'>;
81
- /** Real leftover sweep: `fs.rm` with Windows EPERM retries, then classify. */
83
+ /** Real leftover sweep: `fs.rm` (extended-length on Windows) with EPERM
84
+ * retries, then classify. */
82
85
  export declare function fsSweepDir(path: string): Promise<'gone' | 'empty' | 'occupied'>;
83
86
  export declare function probeRepo(exec: Exec, path: string, dirExists?: DirExists): Promise<RepoFacts | undefined>;
84
87
  /**
package/lib/git.js CHANGED
@@ -146,12 +146,27 @@ async function gitMaybe(exec, cwd, args) {
146
146
  }
147
147
  /** Real existence check. */
148
148
  export const fsDirExists = path => existsSync(path);
149
- /** Real leftover sweep: `fs.rm` with Windows EPERM retries, then classify. */
149
+ /**
150
+ * Windows extended-length form (`\\?\…`) of a path: the prefix skips the
151
+ * 260-char normalization that makes deep node_modules chains unlink-fail —
152
+ * exactly the shape `git worktree remove` gave up on. POSIX paths and
153
+ * already extended paths pass through.
154
+ */
155
+ function asExtendedLengthPath(path) {
156
+ if (process.platform !== 'win32')
157
+ return path;
158
+ const abs = resolve(path);
159
+ if (abs.startsWith('\\\\?\\'))
160
+ return abs;
161
+ return abs.startsWith('\\\\') ? `\\\\?\\UNC${abs.slice(1)}` : `\\\\?\\${abs}`;
162
+ }
163
+ /** Real leftover sweep: `fs.rm` (extended-length on Windows) with EPERM
164
+ * retries, then classify. */
150
165
  export async function fsSweepDir(path) {
151
166
  if (!existsSync(path))
152
167
  return 'gone';
153
168
  try {
154
- await rm(path, { recursive: true, force: true, maxRetries: 8, retryDelay: 100 });
169
+ await rm(asExtendedLengthPath(path), { recursive: true, force: true, maxRetries: 8, retryDelay: 100 });
155
170
  }
156
171
  catch {
157
172
  // Retries exhausted; classify whatever is still on disk.
@@ -165,13 +180,15 @@ export async function fsSweepDir(path) {
165
180
  return 'occupied';
166
181
  }
167
182
  }
168
- /** stderr of a git rmdir that lost to an OS file lock (not git's dirty check). */
183
+ /** stderr of a git rmdir that lost to the OS (not git's dirty check): an
184
+ * open handle on the tree, or a deep path past the 260-char limit. */
169
185
  function isDirBusyGitError(error) {
170
186
  const text = error.stderr;
171
187
  return /permission denied/i.test(text)
172
188
  || /\bEPERM\b/i.test(text)
173
189
  || /\bEACCES\b/i.test(text)
174
- || /\bEBUSY\b/i.test(text);
190
+ || /\bEBUSY\b/i.test(text)
191
+ || /filename too long/i.test(text);
175
192
  }
176
193
  /**
177
194
  * Whether a directory IS the main worktree of its repository: exactly when
@@ -735,8 +752,10 @@ export async function removeWorktree(exec, repoRoot, worktreePath, force, dirExi
735
752
  }
736
753
  catch (error) {
737
754
  // Windows: git often unregisters the worktree and empties the tree,
738
- // then fails the last rmdir (`Permission denied`) because some process
739
- // still has the folder as cwd. `--force` does not help — that flag only
755
+ // then fails a deletion — the last rmdir lost to an open handle
756
+ // (`Permission denied`, a process holding the folder as cwd), or an
757
+ // unlink hit a deep path past the 260-char limit (`Filename too long`,
758
+ // node_modules chains). `--force` does not help — that flag only
740
759
  // bypasses dirty/lock checks, not OS handles. Relist from `repoRoot`
741
760
  // (the main checkout, which still has `.git`); listing from the target
742
761
  // path would throw "not a git repository" once git has stripped its
package/locale/en.json CHANGED
@@ -1,3 +1,7 @@
1
1
  {
2
- "meta": {}
2
+ "meta": {
3
+ "title": "Git worktree",
4
+ "description": "A branch menu in the composer tool row: inspect and switch branches in place, right-click to create, rename, delete, or push, and browse history in the commit graph; tick Worktree on a blank session to start it inside its own Git worktree in the repository.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
3
7
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh git 工作树",
4
- "description": "支持分支操作与工作树功能的dsh插件"
4
+ "description": "输入框工具行的分支菜单:查看并原地切换分支,右键新建、重命名、删除或推送,在提交图谱里浏览历史;空白会话勾选「工作树」,新会话就在仓库内的独立 Git 工作树中开始。",
5
+ "detail": "docs/DETAIL.zh.md"
5
6
  }
6
7
  }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@laoyuehanni/dsh-git-worktree",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "description": "DSH plugin: branch visibility and git worktree isolation for Web UI sessions",
5
+ "icon": "./icon.svg",
5
6
  "keywords": [
6
7
  "dsh",
7
8
  "deepseek",
@@ -42,10 +43,13 @@
42
43
  "files": [
43
44
  "lib",
44
45
  "locale",
46
+ "icon.svg",
45
47
  "!lib/**/*.map",
46
48
  "cordis.patch.yml",
47
49
  "README.md",
48
- "README.zh.md"
50
+ "README.zh.md",
51
+ "docs/DETAIL.md",
52
+ "docs/DETAIL.zh.md"
49
53
  ],
50
54
  "publishConfig": {
51
55
  "registry": "https://registry.npmjs.org/",
@@ -136,7 +140,8 @@
136
140
  "zustand": "~4.4.7"
137
141
  },
138
142
  "engines": {
139
- "node": ">=22.19"
143
+ "node": ">=22.19",
144
+ "dsh": ">=0.2.0-rc.1"
140
145
  },
141
146
  "packageManager": "pnpm@11.8.0"
142
147
  }