@deepseek-ai/dsh-experimental-client-ui-forge 0.2.2-alpha.3 → 0.2.2-rc.2

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 (272) hide show
  1. package/README.i18n.yaml +8 -8
  2. package/README.md +41 -14
  3. package/README.zh.md +40 -13
  4. package/lib/client.js +13 -11800
  5. package/lib/client.js.map +1 -0
  6. package/lib/index.js +1340 -115
  7. package/lib/typert.host.js +1715 -212
  8. package/lib/typert.remote-client.d.ts +42 -5
  9. package/lib/typert.remote-client.d.ts.map +1 -0
  10. package/lib/typert.remote-client.js +1523 -244
  11. package/lib/types/client/ActionToast.d.ts.map +1 -0
  12. package/lib/types/client/ActionToast.js.map +1 -0
  13. package/lib/types/client/BaseMenu.d.ts +30 -0
  14. package/lib/types/client/BaseMenu.d.ts.map +1 -0
  15. package/lib/types/client/BaseMenu.js.map +1 -0
  16. package/lib/types/client/ChangeRequestCard.d.ts +9 -5
  17. package/lib/types/client/ChangeRequestCard.d.ts.map +1 -0
  18. package/lib/types/client/ChangeRequestCard.js.map +1 -0
  19. package/lib/types/client/ChangeRequestOverview.d.ts +124 -0
  20. package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -0
  21. package/lib/types/client/ChangeRequestOverview.js.map +1 -0
  22. package/lib/types/client/ChangedFiles.d.ts +2 -0
  23. package/lib/types/client/ChangedFiles.d.ts.map +1 -0
  24. package/lib/types/client/ChangedFiles.js.map +1 -0
  25. package/lib/types/client/ChangesTab.d.ts +30 -5
  26. package/lib/types/client/ChangesTab.d.ts.map +1 -0
  27. package/lib/types/client/ChangesTab.js.map +1 -0
  28. package/lib/types/client/ChangesTabTitle.d.ts.map +1 -0
  29. package/lib/types/client/ChangesTabTitle.js.map +1 -0
  30. package/lib/types/client/CommitMenu.d.ts +41 -0
  31. package/lib/types/client/CommitMenu.d.ts.map +1 -0
  32. package/lib/types/client/CommitMenu.js.map +1 -0
  33. package/lib/types/client/DiffFile.d.ts +47 -15
  34. package/lib/types/client/DiffFile.d.ts.map +1 -0
  35. package/lib/types/client/DiffFile.js.map +1 -0
  36. package/lib/types/client/FileLabel.d.ts.map +1 -0
  37. package/lib/types/client/FileLabel.js.map +1 -0
  38. package/lib/types/client/FileTreePane.d.ts +4 -2
  39. package/lib/types/client/FileTreePane.d.ts.map +1 -0
  40. package/lib/types/client/FileTreePane.js.map +1 -0
  41. package/lib/types/client/ForgeTab.d.ts +9 -1
  42. package/lib/types/client/ForgeTab.d.ts.map +1 -0
  43. package/lib/types/client/ForgeTab.js.map +1 -0
  44. package/lib/types/client/ForgeTabTitle.d.ts.map +1 -0
  45. package/lib/types/client/ForgeTabTitle.js.map +1 -0
  46. package/lib/types/client/HeaderButton.d.ts.map +1 -0
  47. package/lib/types/client/HeaderButton.js.map +1 -0
  48. package/lib/types/client/LocalChangesCard.d.ts.map +1 -0
  49. package/lib/types/client/LocalChangesCard.js.map +1 -0
  50. package/lib/types/client/RefreshGlyph.d.ts.map +1 -0
  51. package/lib/types/client/RefreshGlyph.js.map +1 -0
  52. package/lib/types/client/ReviewComposer.d.ts +20 -6
  53. package/lib/types/client/ReviewComposer.d.ts.map +1 -0
  54. package/lib/types/client/ReviewComposer.js.map +1 -0
  55. package/lib/types/client/ReviewControls.d.ts +79 -0
  56. package/lib/types/client/ReviewControls.d.ts.map +1 -0
  57. package/lib/types/client/ReviewControls.js.map +1 -0
  58. package/lib/types/client/ReviewThread.d.ts +4 -4
  59. package/lib/types/client/ReviewThread.d.ts.map +1 -0
  60. package/lib/types/client/ReviewThread.js.map +1 -0
  61. package/lib/types/client/ReviewThreads.d.ts +108 -0
  62. package/lib/types/client/ReviewThreads.d.ts.map +1 -0
  63. package/lib/types/client/ReviewThreads.js.map +1 -0
  64. package/lib/types/client/SessionHoverForge.d.ts.map +1 -0
  65. package/lib/types/client/SessionHoverForge.js.map +1 -0
  66. package/lib/types/client/SessionRowForge.d.ts +1 -1
  67. package/lib/types/client/SessionRowForge.d.ts.map +1 -0
  68. package/lib/types/client/SessionRowForge.js.map +1 -0
  69. package/lib/types/client/SubmitReview.d.ts +12 -4
  70. package/lib/types/client/SubmitReview.d.ts.map +1 -0
  71. package/lib/types/client/SubmitReview.js.map +1 -0
  72. package/lib/types/client/ThreadList.d.ts +43 -0
  73. package/lib/types/client/ThreadList.d.ts.map +1 -0
  74. package/lib/types/client/ThreadList.js.map +1 -0
  75. package/lib/types/client/ViewOptionsMenu.d.ts +31 -0
  76. package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -0
  77. package/lib/types/client/ViewOptionsMenu.js.map +1 -0
  78. package/lib/types/client/WorktreeProgress.d.ts.map +1 -0
  79. package/lib/types/client/WorktreeProgress.js.map +1 -0
  80. package/lib/types/client/WorktreeSettings.d.ts +12 -0
  81. package/lib/types/client/WorktreeSettings.d.ts.map +1 -0
  82. package/lib/types/client/WorktreeSettings.js.map +1 -0
  83. package/lib/types/client/WorktreeToggle.d.ts.map +1 -0
  84. package/lib/types/client/WorktreeToggle.js.map +1 -0
  85. package/lib/types/client/changes-address.d.ts.map +1 -0
  86. package/lib/types/client/changes-address.js.map +1 -0
  87. package/lib/types/client/changes-store.d.ts +20 -5
  88. package/lib/types/client/changes-store.d.ts.map +1 -0
  89. package/lib/types/client/changes-store.js.map +1 -0
  90. package/lib/types/client/checkout.d.ts.map +1 -0
  91. package/lib/types/client/checkout.js.map +1 -0
  92. package/lib/types/client/code-selection.d.ts.map +1 -0
  93. package/lib/types/client/code-selection.js.map +1 -0
  94. package/lib/types/client/diff-rows.d.ts.map +1 -0
  95. package/lib/types/client/diff-rows.js.map +1 -0
  96. package/lib/types/client/file-tree.d.ts.map +1 -0
  97. package/lib/types/client/file-tree.js.map +1 -0
  98. package/lib/types/client/format.d.ts.map +1 -0
  99. package/lib/types/client/format.js.map +1 -0
  100. package/lib/types/client/glyphs.d.ts +4 -2
  101. package/lib/types/client/glyphs.d.ts.map +1 -0
  102. package/lib/types/client/glyphs.js.map +1 -0
  103. package/lib/types/client/host-viewed.d.ts +84 -0
  104. package/lib/types/client/host-viewed.d.ts.map +1 -0
  105. package/lib/types/client/host-viewed.js.map +1 -0
  106. package/lib/types/client/index.d.ts.map +1 -0
  107. package/lib/types/client/index.js.map +1 -0
  108. package/lib/types/client/locales.d.ts +175 -3
  109. package/lib/types/client/locales.d.ts.map +1 -0
  110. package/lib/types/client/locales.js.map +1 -0
  111. package/lib/types/client/menu-search.d.ts +10 -0
  112. package/lib/types/client/menu-search.d.ts.map +1 -0
  113. package/lib/types/client/menu-search.js.map +1 -0
  114. package/lib/types/client/mount.d.ts +4 -0
  115. package/lib/types/client/mount.d.ts.map +1 -0
  116. package/lib/types/client/mount.js.map +1 -0
  117. package/lib/types/client/review-queue.d.ts +5 -8
  118. package/lib/types/client/review-queue.d.ts.map +1 -0
  119. package/lib/types/client/review-queue.js.map +1 -0
  120. package/lib/types/client/review-threads.d.ts +108 -0
  121. package/lib/types/client/review-threads.d.ts.map +1 -0
  122. package/lib/types/client/review-threads.js.map +1 -0
  123. package/lib/types/client/review.d.ts +31 -4
  124. package/lib/types/client/review.d.ts.map +1 -0
  125. package/lib/types/client/review.js.map +1 -0
  126. package/lib/types/client/section-reach.d.ts +26 -0
  127. package/lib/types/client/section-reach.d.ts.map +1 -0
  128. package/lib/types/client/section-reach.js.map +1 -0
  129. package/lib/types/client/session-list.d.ts.map +1 -0
  130. package/lib/types/client/session-list.js.map +1 -0
  131. package/lib/types/client/source.d.ts.map +1 -0
  132. package/lib/types/client/source.js.map +1 -0
  133. package/lib/types/client/status.d.ts.map +1 -0
  134. package/lib/types/client/status.js.map +1 -0
  135. package/lib/types/client/thread-state.d.ts +68 -0
  136. package/lib/types/client/thread-state.d.ts.map +1 -0
  137. package/lib/types/client/thread-state.js.map +1 -0
  138. package/lib/types/client/toolbar-fold.d.ts +19 -0
  139. package/lib/types/client/toolbar-fold.d.ts.map +1 -0
  140. package/lib/types/client/toolbar-fold.js.map +1 -0
  141. package/lib/types/client/viewed-files.d.ts +70 -0
  142. package/lib/types/client/viewed-files.d.ts.map +1 -0
  143. package/lib/types/client/viewed-files.js.map +1 -0
  144. package/lib/types/client/worktree-settings-form.d.ts +32 -0
  145. package/lib/types/client/worktree-settings-form.d.ts.map +1 -0
  146. package/lib/types/client/worktree-settings-form.js.map +1 -0
  147. package/lib/types/commit-range.d.ts +17 -0
  148. package/lib/types/commit-range.d.ts.map +1 -0
  149. package/lib/types/commit-range.js.map +1 -0
  150. package/lib/types/diff.d.ts +10 -2
  151. package/lib/types/diff.d.ts.map +1 -0
  152. package/lib/types/diff.js.map +1 -0
  153. package/lib/types/git.d.ts.map +1 -0
  154. package/lib/types/git.js.map +1 -0
  155. package/lib/types/index.d.ts +194 -14
  156. package/lib/types/index.d.ts.map +1 -0
  157. package/lib/types/index.js.map +1 -0
  158. package/lib/types/layers.d.ts +66 -0
  159. package/lib/types/layers.d.ts.map +1 -0
  160. package/lib/types/layers.js.map +1 -0
  161. package/lib/types/local-diff.d.ts +54 -6
  162. package/lib/types/local-diff.d.ts.map +1 -0
  163. package/lib/types/local-diff.js.map +1 -0
  164. package/lib/types/panel.d.ts.map +1 -0
  165. package/lib/types/panel.js.map +1 -0
  166. package/lib/types/parse.d.ts +16 -0
  167. package/lib/types/parse.d.ts.map +1 -0
  168. package/lib/types/parse.js.map +1 -0
  169. package/lib/types/patch-cache.d.ts +12 -7
  170. package/lib/types/patch-cache.d.ts.map +1 -0
  171. package/lib/types/patch-cache.js.map +1 -0
  172. package/lib/types/review-cache.d.ts +54 -0
  173. package/lib/types/review-cache.d.ts.map +1 -0
  174. package/lib/types/review-cache.js.map +1 -0
  175. package/lib/types/states.d.ts.map +1 -0
  176. package/lib/types/states.js.map +1 -0
  177. package/lib/types/types.d.ts +113 -11
  178. package/lib/types/types.d.ts.map +1 -0
  179. package/lib/types/types.js.map +1 -0
  180. package/lib/types/wildmatch.d.ts +14 -0
  181. package/lib/types/wildmatch.d.ts.map +1 -0
  182. package/lib/types/wildmatch.js.map +1 -0
  183. package/lib/types/worktree.d.ts +8 -6
  184. package/lib/types/worktree.d.ts.map +1 -0
  185. package/lib/types/worktree.js.map +1 -0
  186. package/package.json +59 -49
  187. package/src/client/ActionToast.tsx +38 -0
  188. package/src/client/BaseMenu.module.css +153 -0
  189. package/src/client/BaseMenu.tsx +180 -0
  190. package/src/client/ChangeRequestCard.tsx +439 -0
  191. package/src/client/ChangeRequestOverview.module.css +196 -0
  192. package/src/client/ChangeRequestOverview.tsx +620 -0
  193. package/src/client/ChangedFiles.module.css +26 -0
  194. package/src/client/ChangedFiles.tsx +144 -0
  195. package/src/client/ChangesTab.module.css +984 -0
  196. package/src/client/ChangesTab.tsx +1288 -0
  197. package/src/client/ChangesTabTitle.tsx +28 -0
  198. package/src/client/CommitMenu.module.css +139 -0
  199. package/src/client/CommitMenu.tsx +186 -0
  200. package/src/client/DiffFile.tsx +621 -0
  201. package/src/client/FileLabel.module.css +53 -0
  202. package/src/client/FileLabel.tsx +66 -0
  203. package/src/client/FileTreePane.module.css +10 -0
  204. package/src/client/FileTreePane.tsx +79 -0
  205. package/src/client/ForgeTab.module.css +627 -0
  206. package/src/client/ForgeTab.tsx +263 -0
  207. package/src/client/ForgeTabTitle.tsx +21 -0
  208. package/src/client/HeaderButton.module.css +29 -0
  209. package/src/client/HeaderButton.tsx +68 -0
  210. package/src/client/LocalChangesCard.tsx +83 -0
  211. package/src/client/RefreshGlyph.module.css +22 -0
  212. package/src/client/RefreshGlyph.tsx +35 -0
  213. package/src/client/ReviewComposer.module.css +37 -0
  214. package/src/client/ReviewComposer.tsx +128 -0
  215. package/src/client/ReviewControls.module.css +162 -0
  216. package/src/client/ReviewControls.tsx +191 -0
  217. package/src/client/ReviewThread.tsx +96 -0
  218. package/src/client/ReviewThreads.module.css +326 -0
  219. package/src/client/ReviewThreads.tsx +443 -0
  220. package/src/client/SessionHoverForge.tsx +72 -0
  221. package/src/client/SessionList.module.css +85 -0
  222. package/src/client/SessionRowForge.tsx +86 -0
  223. package/src/client/SubmitReview.module.css +26 -0
  224. package/src/client/SubmitReview.tsx +95 -0
  225. package/src/client/ThreadList.module.css +218 -0
  226. package/src/client/ThreadList.tsx +165 -0
  227. package/src/client/ViewOptionsMenu.tsx +79 -0
  228. package/src/client/WorktreeProgress.module.css +226 -0
  229. package/src/client/WorktreeProgress.tsx +280 -0
  230. package/src/client/WorktreeSettings.module.css +29 -0
  231. package/src/client/WorktreeSettings.tsx +42 -0
  232. package/src/client/WorktreeToggle.module.css +132 -0
  233. package/src/client/WorktreeToggle.tsx +165 -0
  234. package/src/client/changes-address.ts +110 -0
  235. package/src/client/changes-store.ts +155 -0
  236. package/src/client/checkout.ts +75 -0
  237. package/src/client/code-selection.ts +53 -0
  238. package/src/client/diff-rows.ts +199 -0
  239. package/src/client/file-tree.ts +86 -0
  240. package/src/client/format.ts +37 -0
  241. package/src/client/glyphs.tsx +151 -0
  242. package/src/client/host-viewed.ts +195 -0
  243. package/src/client/index.ts +31 -0
  244. package/src/client/locales.ts +3446 -0
  245. package/src/client/menu-search.ts +16 -0
  246. package/src/client/mount.ts +439 -0
  247. package/src/client/review-queue.ts +256 -0
  248. package/src/client/review-threads.ts +204 -0
  249. package/src/client/review.ts +120 -0
  250. package/src/client/section-reach.ts +61 -0
  251. package/src/client/session-list.ts +79 -0
  252. package/src/client/source.ts +274 -0
  253. package/src/client/status.ts +171 -0
  254. package/src/client/thread-state.ts +127 -0
  255. package/src/client/toolbar-fold.ts +70 -0
  256. package/src/client/viewed-files.ts +178 -0
  257. package/src/client/worktree-settings-form.ts +43 -0
  258. package/src/commit-range.ts +27 -0
  259. package/src/css-modules.d.ts +5 -0
  260. package/src/diff.ts +162 -0
  261. package/src/git.ts +293 -0
  262. package/src/index.ts +1162 -0
  263. package/src/layers.ts +163 -0
  264. package/src/local-diff.ts +438 -0
  265. package/src/panel.ts +422 -0
  266. package/src/parse.ts +137 -0
  267. package/src/patch-cache.ts +73 -0
  268. package/src/review-cache.ts +98 -0
  269. package/src/states.ts +350 -0
  270. package/src/types.ts +504 -0
  271. package/src/wildmatch.ts +121 -0
  272. package/src/worktree.ts +576 -0
package/src/types.ts ADDED
@@ -0,0 +1,504 @@
1
+ /** Browser-safe panel state, the worktree request record, Remote error codes, and Host configuration of the forge panel. */
2
+
3
+ import type {} from '@deepseek-ai/dsh-typert-protocol'
4
+ import type { ChangeRequestSnapshot, ForgeCommit, ForgeReadiness, ForgeRepository } from '@deepseek-ai/dsh-experimental-forge/types'
5
+ import type { SessionChangeRequest } from '@deepseek-ai/dsh-experimental-forge-session/types'
6
+
7
+ /** Git facts for the checkout that contains the Session's current directory. */
8
+ export interface ForgeCheckout {
9
+ /** Top-level directory of the checkout. */
10
+ readonly root: string
11
+ /** Checked-out branch, or null when HEAD is detached. */
12
+ readonly branch: string | null
13
+ /** Whether the checkout is a linked worktree of another checkout's repository. */
14
+ readonly linked: boolean
15
+ /** Abbreviated commit HEAD names, or null while the checked-out branch has no commit. */
16
+ readonly commit: string | null
17
+ }
18
+
19
+ /** Inspection result for the Session's current directory. */
20
+ export type ForgeCheckoutState =
21
+ /** The first inspection has not finished. */
22
+ | { readonly state: 'pending' }
23
+ /** The current directory is not inside a Git checkout. */
24
+ | { readonly state: 'none' }
25
+ /** Git could not run or reported an error. */
26
+ | { readonly state: 'failed'; readonly message: string }
27
+ /** The checkout facts. */
28
+ | { readonly state: 'ready'; readonly checkout: ForgeCheckout }
29
+
30
+ /** The worktree the panel created and entered for a Session before its first step. */
31
+ export interface ForgeSessionWorktree {
32
+ /** Canonical checkout directory. */
33
+ readonly path: string
34
+ /** Branch created for the checkout. */
35
+ readonly branch: string
36
+ /** Requested base branch, or null when the checkout started from HEAD of the source checkout. */
37
+ readonly from: string | null
38
+ /** Commit object name the branch started from. */
39
+ readonly baseCommit: string
40
+ /** Canonical root of the source checkout. */
41
+ readonly repositoryRoot: string
42
+ }
43
+
44
+ /** Payload of the `plugin:client-ui-forge/worktree` record. */
45
+ export type WorktreeRecord =
46
+ /** Create a worktree before the Session's first step, starting from `from`, or from HEAD when it is null. */
47
+ | { readonly action: 'request'; readonly from: string | null }
48
+ /** Withdraw the open request. */
49
+ | { readonly action: 'cancel' }
50
+ /** The requested worktree was created and became the Session's working directory. */
51
+ | { readonly action: 'created'; readonly worktree: ForgeSessionWorktree }
52
+ /** Restoration started; the checkout stays unavailable until restoration completes. */
53
+ | { readonly action: 'restoring' }
54
+ /** The recorded worktree was completely restored. */
55
+ | { readonly action: 'restored' }
56
+
57
+ /** One open worktree request. */
58
+ export interface ForgeWorktreeRequest {
59
+ /** Base branch, or null for HEAD of the source checkout. */
60
+ readonly from: string | null
61
+ }
62
+
63
+ /** Host-only state of the `forgeWorktree` projection. */
64
+ export interface ForgeWorktreeState {
65
+ /** Open request, or null without one. */
66
+ readonly request: ForgeWorktreeRequest | null
67
+ /** Created worktree, or null before creation. */
68
+ readonly created: ForgeSessionWorktree | null
69
+ /** Whether a turn has started; requests and withdrawals recorded afterwards are ignored. */
70
+ readonly locked: boolean
71
+ /** Whether a step has started; no worktree is created afterwards. */
72
+ readonly stepped: boolean
73
+ /** The Session's working directory as its log last recorded it, or null when none is recorded. */
74
+ readonly cwd: string | null
75
+ /** Whether a restoration started without a successful completion, including across reloads. */
76
+ readonly restoring: boolean
77
+ }
78
+
79
+ /** Why the Session's checkout cannot host a new worktree. */
80
+ export type ForgeWorktreeBlocker =
81
+ /** The current directory is not inside a Git checkout. */
82
+ | 'not-git'
83
+ /** The Session's sandbox cannot write the checkout or its Git directory, as for a linked worktree outside the writable root. */
84
+ | 'outside-writable-root'
85
+ /** The Session runs read-only. */
86
+ | 'read-only'
87
+
88
+ /** One running worktree creation. */
89
+ export interface ForgeWorktreeCreation {
90
+ /** Running step: `prepare` validates and creates the branch, then `checkout` writes the files. */
91
+ readonly phase: 'prepare' | 'checkout'
92
+ /** Branch the attempt creates. */
93
+ readonly branch: string
94
+ /** Base branch, or null for HEAD. */
95
+ readonly from: string | null
96
+ /**
97
+ * Whether a message waits for the creation before its turn starts. Only
98
+ * such a creation can be stopped, after which the message keeps waiting; a
99
+ * creation at the first step serves a message the Session already holds.
100
+ */
101
+ readonly held: boolean
102
+ }
103
+
104
+ /** One running restoration of the removed worktree a Session works in. */
105
+ export interface ForgeWorktreeRestoration {
106
+ /** Running step: `prepare` registers the checkout again, creating a missing branch, then `checkout` writes the files. */
107
+ readonly phase: 'prepare' | 'checkout'
108
+ }
109
+
110
+ /** The last attempt to create the requested worktree for a message, which failed. */
111
+ export interface ForgeWorktreeFailure {
112
+ /** Branch the attempt created, or null when it failed before naming one. */
113
+ readonly branch: string | null
114
+ /** Base branch of the attempt, or null for HEAD. */
115
+ readonly from: string | null
116
+ /** Step that failed. */
117
+ readonly phase: 'prepare' | 'checkout'
118
+ /** Failure text. */
119
+ readonly message: string
120
+ }
121
+
122
+ /**
123
+ * What a message waits for before its turn starts: the creation of the
124
+ * requested worktree, or the restoration or leaving of the removed worktree
125
+ * the Session works in.
126
+ */
127
+ export type ForgeWorktreeWaiting = 'creation' | 'restoration'
128
+
129
+ /** The recorded worktree whose directory is missing, invalid, or incompletely restored. */
130
+ export interface ForgeMissingWorktree {
131
+ /** Whether its branch exists, or null when an incomplete restoration cannot inspect it. */
132
+ readonly branchExists: boolean | null
133
+ }
134
+
135
+ /** Worktree facts of one Session in the panel state. */
136
+ export interface ForgePanelWorktree {
137
+ /**
138
+ * Whether the Session can still request or withdraw a worktree: a worktree
139
+ * service is mounted, no turn has started, and none was created.
140
+ */
141
+ readonly editable: boolean
142
+ /** Why the checkout cannot host a worktree, or null when it can, before the first inspection, and after a failed one. */
143
+ readonly blocker: ForgeWorktreeBlocker | null
144
+ /** Open request, or null without one. */
145
+ readonly request: ForgeWorktreeRequest | null
146
+ /** Created worktree, or null before creation. */
147
+ readonly created: ForgeSessionWorktree | null
148
+ /** Running creation, or null. */
149
+ readonly creation: ForgeWorktreeCreation | null
150
+ /**
151
+ * The last failed attempt of the creation a message waits for, or null. It
152
+ * clears when another attempt starts, when the request changes or is
153
+ * withdrawn, and when the wait ends.
154
+ */
155
+ readonly failure: ForgeWorktreeFailure | null
156
+ /** The created worktree the Session works in when its directory is gone, or null. */
157
+ readonly missing: ForgeMissingWorktree | null
158
+ /** Running restoration of the removed worktree, or null. */
159
+ readonly restoration: ForgeWorktreeRestoration | null
160
+ /** What a message of the Session waits for before its turn starts, or null while none waits. */
161
+ readonly waiting: ForgeWorktreeWaiting | null
162
+ }
163
+
164
+ /**
165
+ * The last polled state of one change request that a listed Session binds, as
166
+ * the Session list shows it.
167
+ */
168
+ export type ForgeChangeRequestListState = Pick<
169
+ ChangeRequestSnapshot, 'url' | 'title' | 'state' | 'draft' | 'checksRollup' | 'reviewDecision' | 'mergeability'
170
+ > & {
171
+ /** Change request number on its code host. */
172
+ readonly number: number
173
+ }
174
+
175
+ /**
176
+ * One frame of `forgePanel.changeRequestStates`: the known state of every
177
+ * change request the reader may see first, then the states that changed or
178
+ * became visible since the previous frame.
179
+ */
180
+ export type ForgeChangeRequestStatesFrame =
181
+ | { readonly type: 'baseline'; readonly states: readonly ForgeChangeRequestListState[] }
182
+ | { readonly type: 'changed'; readonly states: readonly ForgeChangeRequestListState[] }
183
+
184
+ /** One bound change request in the panel state. */
185
+ export interface ForgePanelChangeRequest extends SessionChangeRequest {
186
+ /** Latest snapshot a poll returned, kept while later polls fail, or null before the first successful poll. */
187
+ readonly snapshot: ChangeRequestSnapshot | null
188
+ }
189
+
190
+ /** Everything the panel shows for one Session. */
191
+ export interface ForgePanelState {
192
+ /** Current working directory of the Session. */
193
+ readonly directory: string
194
+ /** Inspection result for `directory`. */
195
+ readonly checkout: ForgeCheckoutState
196
+ /** Code host repository of the checkout's upstream remote or `origin`, or null when no provider serves them. */
197
+ readonly repository: ForgeRepository | null
198
+ /** Sign-in state for the repository's host, or null before the first probe and without a repository. */
199
+ readonly readiness: ForgeReadiness | null
200
+ /** Visible change request bindings with their latest polling results, in first-recorded order. */
201
+ readonly changeRequests: readonly ForgePanelChangeRequest[]
202
+ /** Worktree request and creation state. */
203
+ readonly worktree: ForgePanelWorktree
204
+ /**
205
+ * Files the `branch` scope changes, or null before the first inspection,
206
+ * outside a checkout, and without a fork point.
207
+ */
208
+ readonly local: ForgeLocalChanges | null
209
+ }
210
+
211
+ /** Local branches offered as the base of a new worktree. */
212
+ export interface ForgeBranches {
213
+ /** Checked-out branch, or null when HEAD is detached. */
214
+ readonly current: string | null
215
+ /** Local branch names, `current` first and then most recently committed first, at most `maxBranches`. */
216
+ readonly branches: readonly string[]
217
+ }
218
+
219
+ /** A branch the `branch` scope can compare with. */
220
+ export interface ForgeBaseBranch {
221
+ /** Full ref name: `refs/heads/<branch>` or `refs/remotes/<remote>/<branch>`. */
222
+ readonly ref: string
223
+ /** The ref without `refs/heads/` or `refs/remotes/`, such as `master` or `origin/master`. */
224
+ readonly name: string
225
+ }
226
+
227
+ /** What the `branch` scope compares with while no base branch is chosen. */
228
+ export interface ForgeAutomaticBase {
229
+ /** The created worktree's base branch or abbreviated base commit, or the default branch of the code host remote. */
230
+ readonly name: string
231
+ /** Whether the fork point is the base commit of the worktree the Session created rather than a merge base. */
232
+ readonly worktree: boolean
233
+ }
234
+
235
+ /** Branches the `branch` scope can compare with, whose names contain a query. */
236
+ export interface ForgeBaseBranches {
237
+ /** The fork point used while no base branch is chosen, whatever the query; null without one. */
238
+ readonly automatic: ForgeAutomaticBase | null
239
+ /** Remote-tracking branches without symbolic refs such as `origin/HEAD`, most recently committed first, at most `maxBranches`. */
240
+ readonly remote: readonly ForgeBaseBranch[]
241
+ /** Local branches other than the checked-out one, most recently committed first, at most `maxBranches`. */
242
+ readonly local: readonly ForgeBaseBranch[]
243
+ }
244
+
245
+ /**
246
+ * Consecutive commits a changes view shows instead of its whole comparison, named by full object names in the order
247
+ * the commit list shows them, oldest first; the view shows the changes from the first commit's first parent to the last.
248
+ */
249
+ export interface ForgeCommitRange {
250
+ /** First, oldest commit shown. */
251
+ readonly from: string
252
+ /** Last, newest commit shown; equal to `from` for one commit. */
253
+ readonly to: string
254
+ }
255
+
256
+ /** Which local changes a diff covers; each reads the Session's checkout through Git. */
257
+ export type ForgeLocalScope =
258
+ /**
259
+ * The working tree and untracked files against a fork point: the merge base of HEAD with the
260
+ * `base` ref, or while `base` is null, the base commit of the worktree the Session created,
261
+ * else the merge base of HEAD with the default branch of the code host remote. With `commits`, only the changes
262
+ * of those commits between the fork point and HEAD, without uncommitted or untracked files.
263
+ */
264
+ | { readonly kind: 'branch'; readonly base: string | null; readonly commits: ForgeCommitRange | null }
265
+ /** The working tree and untracked files against HEAD. */
266
+ | { readonly kind: 'uncommitted' }
267
+ /** The working tree and untracked files against the index. */
268
+ | { readonly kind: 'unstaged' }
269
+ /** The index against HEAD. */
270
+ | { readonly kind: 'staged' }
271
+
272
+ /** One hunk of a file diff. */
273
+ export interface ForgeDiffHunk {
274
+ /** First old line the hunk covers, or the old line it comes before when it covers none. */
275
+ readonly oldStart: number
276
+ /** Old lines the hunk covers. */
277
+ readonly oldLines: number
278
+ /** First new line the hunk covers, or the new line it comes before when it covers none. */
279
+ readonly newStart: number
280
+ /** New lines the hunk covers. */
281
+ readonly newLines: number
282
+ /** Lines in patch form: a leading space for context, `+` for added, `-` for deleted, and `\` for a missing final newline. */
283
+ readonly lines: readonly string[]
284
+ }
285
+
286
+ /** How one file changed. */
287
+ export type ForgeDiffStatus = 'added' | 'deleted' | 'modified' | 'renamed'
288
+
289
+ /**
290
+ * Review layer of a changed file: the layer the repository's root `.gitattributes` names with `dsh-review-layer`, else
291
+ * `test` for a file it marks `linguist-generated`, else the first of `testPaths`, `interfacePaths`, and the built-in
292
+ * test and interface rules that the path matches, else `implementation`.
293
+ */
294
+ export type ForgeFileLayer = 'interface' | 'implementation' | 'test'
295
+
296
+ /** One changed file of a diff. */
297
+ export interface ForgeDiffFile {
298
+ /** Path relative to the repository root after the change, or before it for a deleted file. */
299
+ readonly path: string
300
+ /** Path before a rename, else null. */
301
+ readonly previousPath: string | null
302
+ /** How the file changed. */
303
+ readonly status: ForgeDiffStatus
304
+ /** Whether the content is binary, which carries no hunks. */
305
+ readonly binary: boolean
306
+ /** Whether an untracked file exceeds `maxDiffBytes`, so it carries no hunks. */
307
+ readonly oversized: boolean
308
+ /** Whether Git does not track the file yet; only local diffs list such files. */
309
+ readonly untracked: boolean
310
+ /** Lines added. */
311
+ readonly additions: number
312
+ /** Lines deleted. */
313
+ readonly deletions: number
314
+ /** Hunks in file order; none for a binary file or a change of mode or name only. */
315
+ readonly hunks: readonly ForgeDiffHunk[]
316
+ /** Review layer the path falls in. */
317
+ readonly layer: ForgeFileLayer
318
+ /**
319
+ * Digest of the file's change: its paths, status, and hunks, plus the blob names of a binary change, or the content
320
+ * of an untracked binary file. Equal digests describe the same change; reading the same comparison again keeps it.
321
+ */
322
+ readonly digest: string
323
+ }
324
+
325
+ /** Local changes of the Session's checkout in one scope. */
326
+ export interface ForgeLocalDiff {
327
+ /** Ref or abbreviated commit the `branch` scope compares with, such as `origin/master`; null for other scopes. */
328
+ readonly base: string | null
329
+ /** Changed files in Git's path order, untracked files last. */
330
+ readonly files: readonly ForgeDiffFile[]
331
+ /** Untracked files left out beyond `maxUntrackedFiles`. */
332
+ readonly omitted: number
333
+ }
334
+
335
+ /** Changes of a change request, or of consecutive commits of it, as its code host computes them. */
336
+ export interface ForgeChangeRequestDiff {
337
+ /** Commit whose new side the diff describes: the head, or the last chosen commit. */
338
+ readonly headSha: string
339
+ /** Changed files in the host's order. */
340
+ readonly files: readonly ForgeDiffFile[]
341
+ /**
342
+ * Commits the checkout's branch has beyond the head when that branch is the change request's head
343
+ * branch and the head commit is present locally; null otherwise and for chosen commits.
344
+ */
345
+ readonly localAhead: number | null
346
+ /** Web page of each changed file at `headSha`, by path. */
347
+ readonly fileUrls: Readonly<Record<string, string>>
348
+ }
349
+
350
+ /** Commits of the `branch` scope at one HEAD commit, which the changes view can show one or several of. */
351
+ export interface ForgeLocalCommits {
352
+ /** HEAD commit the list was read at. */
353
+ readonly headSha: string
354
+ /** Commits oldest first, ending with HEAD's commit. */
355
+ readonly commits: readonly ForgeCommit[]
356
+ /** Whether the branch has more commits than `maxCommits`; the listed ones are the newest. */
357
+ readonly truncated: boolean
358
+ }
359
+
360
+ /** One file the `branch` scope changes, without its hunks. */
361
+ export interface ForgeChangedFile {
362
+ /** Path relative to the repository root after the change. */
363
+ readonly path: string
364
+ /** Lines added, or 0 for a binary file. */
365
+ readonly additions: number
366
+ /** Lines deleted, or 0 for a binary file. */
367
+ readonly deletions: number
368
+ /** Whether the content is binary. */
369
+ readonly binary: boolean
370
+ }
371
+
372
+ /** Size of the `branch` scope, which the panel's local changes card shows. */
373
+ export interface ForgeLocalChanges {
374
+ /** Ref or abbreviated commit the scope compares with. */
375
+ readonly base: string
376
+ /** Changed files in Git's path order, untracked files last, at most `maxUntrackedFiles` of those. */
377
+ readonly files: readonly ForgeChangedFile[]
378
+ }
379
+
380
+ /** Host settings of the forge panel Remote. */
381
+ export interface Config {
382
+ /** Git executable name or absolute path in the Session's execution world. */
383
+ gitCommand?: string
384
+ /** Deadline in milliseconds for one Git command, including confinement. */
385
+ gitTimeoutMs?: number
386
+ /** Termination grace period in milliseconds for each Git process. */
387
+ graceMs?: number
388
+ /** Maximum captured bytes per Git output stream. */
389
+ maxOutputBytes?: number
390
+ /** Deadline in milliseconds for one provider sign-in probe. */
391
+ readinessTimeoutMs?: number
392
+ /** Most local branches listed as worktree bases, and most branches in each group of base branches listed for the `branch` scope. */
393
+ maxBranches?: number
394
+ /**
395
+ * Prefix of the branch and checkout directory created for a Session worktree; the first eight
396
+ * hexadecimal digits of the Session id's UUID, a hyphen, and four random hexadecimal digits follow it.
397
+ */
398
+ worktreePrefix?: string
399
+ /** Largest diff, file read to show unchanged lines, or list of base branch refs, in bytes. */
400
+ maxDiffBytes?: number
401
+ /** Most untracked files a local diff or the local changes card includes. */
402
+ maxUntrackedFiles?: number
403
+ /** Most UTF-8 bytes of change request diffs kept in memory for later reads at the same head commit and base branch. */
404
+ maxCachedDiffBytes?: number
405
+ /** Most commits of the `branch` scope listed; a longer branch lists its newest ones. */
406
+ maxCommits?: number
407
+ /**
408
+ * Globs of files in the `test` layer, which the changes view can hide, beside the built-in rules and checked before
409
+ * them; matched against repository-relative paths with dot files included. A repository's `.gitattributes` overrides both.
410
+ */
411
+ testPaths?: string[]
412
+ /**
413
+ * Globs of files in the `interface` layer beside the built-in rules, matched like `testPaths`; checked after
414
+ * `testPaths` and before the built-in rules.
415
+ */
416
+ interfacePaths?: string[]
417
+ /** Most UTF-8 bytes, as JSON, of change request review threads kept in memory for later reads at the same head commit and update time. */
418
+ maxCachedReviewBytes?: number
419
+ /**
420
+ * Age in milliseconds at which review threads kept in memory are read from the code host again; a GitHub pull
421
+ * request's update time does not change when a thread is resolved.
422
+ */
423
+ reviewRefreshMs?: number
424
+ }
425
+
426
+ declare module '@deepseek-ai/dsh-typert-protocol' {
427
+ interface RemoteErrorDetailsMap {
428
+ /** No registered provider serves the change request URL. */
429
+ 'forgePanel/unrecognized-url': Record<string, never>
430
+ /** A turn of the Session has started, or its worktree was created, so its worktree request can no longer change. */
431
+ 'forgePanel/session-started': Record<string, never>
432
+ /** No worktree service is mounted. */
433
+ 'forgePanel/worktrees-unavailable': Record<string, never>
434
+ /** The requested base branch name is empty. */
435
+ 'forgePanel/invalid-branch': Record<string, never>
436
+ /** The Session has no created worktree to restore or leave. */
437
+ 'forgePanel/no-worktree': Record<string, never>
438
+ /** The Session's Agent is not loaded or has other work, so its checkout cannot change now. */
439
+ 'forgePanel/session-busy': Record<string, never>
440
+ /** No message of the Session waits after a failed or stopped attempt to create its worktree. */
441
+ 'forgePanel/not-waiting': Record<string, never>
442
+ /** The removed worktree could not be checked out again; the message gives the reason. */
443
+ 'forgePanel/restore-failed': Record<string, never>
444
+ /** The URL is not a visible binding of the Session that a provider serves, so the panel does not act on it. */
445
+ 'forgePanel/not-bound': Record<string, never>
446
+ /**
447
+ * The change request's head is no longer the commit the request named: the head the user confirmed for a merge,
448
+ * the head displayed for complete checks, the head of the latest status for a diff, or the head of the displayed
449
+ * diff for review threads and viewed marks. A diff, review, or viewed mark read the host refuses polls the change
450
+ * request again at once, so a later status names the current head.
451
+ */
452
+ 'forgePanel/stale-head': Record<string, never>
453
+ /** The code host refused the change or could not be reached; the message gives the host's reason. */
454
+ 'forgePanel/action-failed': Record<string, never>
455
+ /** The code host did not confirm whether it applied the change, which must be checked there before trying again. */
456
+ 'forgePanel/action-unknown': Record<string, never>
457
+ /** The Session's directory is not inside a Git checkout, so it has no local changes. */
458
+ 'forgePanel/not-a-checkout': Record<string, never>
459
+ /**
460
+ * HEAD shares no history with the base branch chosen for the `branch` scope, or with none chosen, no remote names a
461
+ * default branch that HEAD shares history with and the checkout is not a worktree the Session created.
462
+ */
463
+ 'forgePanel/no-fork-point': Record<string, never>
464
+ /** The base branch chosen for the `branch` scope does not exist, as after the branch was deleted. */
465
+ 'forgePanel/base-missing': Record<string, never>
466
+ /** Filter configuration could not be read completely; no comparison ran. Correct Git settings or the output limit before retrying. */
467
+ 'forgePanel/filter-config-failed': Record<string, never>
468
+ /**
469
+ * The patch, the untracked file list, or the file exceeds `maxDiffBytes`, or the code host
470
+ * or its provider refuses a change request's diff or file over a size limit.
471
+ */
472
+ 'forgePanel/diff-too-large': Record<string, never>
473
+ /** Complete checks could not be loaded; the polling preview remains available. */
474
+ 'forgePanel/checks-failed': Record<string, never>
475
+ /** The code host did not provide the change request's diff or file, or its status has not been read yet; the message says why. */
476
+ 'forgePanel/diff-failed': Record<string, never>
477
+ /** A chosen commit is no longer among the listed commits of the branch or change request, or the commits are out of order. */
478
+ 'forgePanel/commits-missing': Record<string, never>
479
+ /** A chosen commit after the first lacks the commit listed before it as its first parent, so two ends cannot name the run. */
480
+ 'forgePanel/commits-not-linear': Record<string, never>
481
+ /** The code host did not provide the signed-in user's viewed marks on the change request's files; the message says why. */
482
+ 'forgePanel/viewed-failed': Record<string, never>
483
+ /** The code host did not list the accounts a review can be requested from; the message says why. */
484
+ 'forgePanel/reviewers-failed': Record<string, never>
485
+ /** The code host's provider cannot read review threads, so the changes view shows none. */
486
+ 'forgePanel/review-unsupported': Record<string, never>
487
+ /** The code host did not provide the change request's review threads, or its status has not been read yet; the message says why. */
488
+ 'forgePanel/review-failed': Record<string, never>
489
+ }
490
+ }
491
+
492
+ declare module '@deepseek-ai/dsh-session/types' {
493
+ interface PluginRecordMap {
494
+ /** A request, withdrawal, or creation of the worktree a Session starts in. */
495
+ 'plugin:client-ui-forge/worktree': WorktreeRecord
496
+ }
497
+ }
498
+
499
+ declare module '@deepseek-ai/dsh-session-projection/types' {
500
+ interface SessionProjectionMap {
501
+ /** The worktree the panel created for the Session while the Session works in it, else null. */
502
+ forgeWorktree: ForgeSessionWorktree | null
503
+ }
504
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Patterns of `.gitattributes` lines, matched as Git's wildmatch matches them: `*` and `?` stay within one path
3
+ * segment, `**` between slashes or at either end crosses segments, `[...]` sets take `!` or `^` for negation, ranges,
4
+ * and POSIX classes, `\` makes the next character literal, and every other character, including `(`, `{`, and `+`,
5
+ * is literal. Matching is case-sensitive, as in Git unless `core.ignoreCase` is set, and compares characters where Git
6
+ * compares UTF-8 bytes, so `?` and ranges differ from Git only for characters outside ASCII.
7
+ */
8
+
9
+ /** ASCII members of each POSIX class wildmatch accepts, written as regular expression class ranges. */
10
+ const CLASSES: Readonly<Record<string, string>> = {
11
+ alnum: 'a-zA-Z0-9',
12
+ alpha: 'a-zA-Z',
13
+ blank: ' \\t',
14
+ cntrl: '\\x00-\\x1f\\x7f',
15
+ digit: '0-9',
16
+ graph: '\\x21-\\x7e',
17
+ lower: 'a-z',
18
+ print: '\\x20-\\x7e',
19
+ punct: '\\x21-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7e',
20
+ space: '\\t-\\r ',
21
+ upper: 'A-Z',
22
+ xdigit: '0-9a-fA-F',
23
+ }
24
+
25
+ /** Write one character literally in a regular expression, inside or outside a class. */
26
+ function literal(char: string): string {
27
+ return /[\\^$.*+?()[\]{}|/-]/.test(char) ? `\\${char}` : char
28
+ }
29
+
30
+ /**
31
+ * Translate a bracket expression that starts at `pattern[start]`, which is `[`.
32
+ * @returns the regular expression class and the index of the closing `]`, or undefined for an unterminated set or an
33
+ * unknown class, which wildmatch treats as matching nothing.
34
+ */
35
+ function bracket(pattern: string, start: number): { readonly source: string; readonly end: number } | undefined {
36
+ let index = start + 1
37
+ const negated = pattern[index] === '!' || pattern[index] === '^'
38
+ if (negated) index += 1
39
+ const members: string[] = []
40
+ // The first character, even `]`, is a member, so the set closes at a later `]`.
41
+ for (let first = true; first || pattern[index] !== ']'; first = false, index += 1) {
42
+ let char = pattern[index]
43
+ if (char === undefined) return undefined
44
+ if (char === '[' && pattern[index + 1] === ':') {
45
+ // A class runs to the next `]`, which must follow `:`; otherwise the `[` is a member.
46
+ const close = pattern.indexOf(']', index + 2)
47
+ if (close === -1) return undefined
48
+ if (close > index + 2 && pattern[close - 1] === ':') {
49
+ const range = CLASSES[pattern.slice(index + 2, close - 1)]
50
+ if (range === undefined) return undefined
51
+ members.push(range)
52
+ index = close
53
+ continue
54
+ }
55
+ }
56
+ if (char === '\\') {
57
+ index += 1
58
+ char = pattern[index]
59
+ if (char === undefined) return undefined
60
+ }
61
+ const to = pattern[index + 2]
62
+ if (pattern[index + 1] === '-' && to !== undefined && to !== ']') {
63
+ index += 2
64
+ let end = to
65
+ if (end === '\\') {
66
+ index += 1
67
+ end = pattern[index] ?? ''
68
+ if (end === '') return undefined
69
+ }
70
+ // A range whose end precedes its start matches only its start.
71
+ members.push(char <= end ? `${literal(char)}-${literal(end)}` : literal(char))
72
+ continue
73
+ }
74
+ members.push(literal(char))
75
+ }
76
+ const set = members.join('')
77
+ // A set never matches `/`.
78
+ return { source: negated ? `[^/${set}]` : `(?!/)[${set}]`, end: index }
79
+ }
80
+
81
+ /**
82
+ * Compile one `.gitattributes` pattern, without the leading `/` that anchors it, into a test of a path.
83
+ * @param pattern - the pattern as written, which the caller has checked is not quoted, negated, or a directory.
84
+ * @returns a test of the text the pattern applies to, or undefined for a pattern that can match nothing.
85
+ */
86
+ export function wildmatch(pattern: string): ((text: string) => boolean) | undefined {
87
+ let source = ''
88
+ for (let index = 0; index < pattern.length; index += 1) {
89
+ const char = pattern.charAt(index)
90
+ if (char === '\\') {
91
+ const next = pattern[index + 1]
92
+ if (next === undefined) return undefined
93
+ source += literal(next)
94
+ index += 1
95
+ } else if (char === '?') {
96
+ source += '[^/]'
97
+ } else if (char === '*') {
98
+ let last = index
99
+ while (pattern[last + 1] === '*') last += 1
100
+ const after = pattern[last + 1]
101
+ const crossing = last > index && (index === 0 || pattern[index - 1] === '/') && (after === undefined || after === '/')
102
+ if (crossing && after === '/') {
103
+ // `**/` also matches no directory at all.
104
+ source += '(?:.*/)?'
105
+ index = last + 1
106
+ } else {
107
+ source += crossing ? '.*' : '[^/]*'
108
+ index = last
109
+ }
110
+ } else if (char === '[') {
111
+ const set = bracket(pattern, index)
112
+ if (set === undefined) return undefined
113
+ source += set.source
114
+ index = set.end
115
+ } else {
116
+ source += literal(char)
117
+ }
118
+ }
119
+ const expression = new RegExp(`^${source}$`, 's')
120
+ return text => expression.test(text)
121
+ }