dsh-volcano-git-plugin 0.0.0-stage → 1.7.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.
- package/LICENSE +21 -0
- package/README.md +184 -2
- package/client.js +4331 -0
- package/cordis.patch.yml +4 -0
- package/git-core.mjs +2755 -0
- package/git-graph.mjs +77 -0
- package/icon.svg +19 -0
- package/index.js +712 -0
- package/package.json +66 -4
- package/typert.host.js +601 -0
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-volcano-git-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.7.2",
|
|
4
|
+
"description": "Git 分支徽标跟随会话实时工作目录(DSH 插件,fork 自 @duke-dsh-plugins/dsh-git-manager)。DSH 正式 bundle 插件:在 DSH Web UI 里管理 Git 工作区——入口在输入框「模式」选择器旁(仅 git 仓库显示),进入与设置同规格的居中面板:变更暂存(hunk 级/行级/stash)、分支与 tag、交互式 rebase、提交历史(分支线图形/过滤/范围对比/revert/reset/fixup/undo)、合并冲突解决、blame/reflog、worktree 管理、remote/config 设置,以及子仓库支持(git submodule + 嵌套独立仓库)。",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://gitcode.com/davew/dsh-volcano-git-plugin.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://gitcode.com/davew/dsh-volcano-git-plugin",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://gitcode.com/davew/dsh-volcano-git-plugin/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dsh",
|
|
18
|
+
"deepseek-harness",
|
|
19
|
+
"plugin",
|
|
20
|
+
"git",
|
|
21
|
+
"worktree"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "index.js",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./index.js",
|
|
27
|
+
"./client": "./client.js",
|
|
28
|
+
"./typert": "./typert.host.js",
|
|
29
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
30
|
+
"./icon": "./icon.svg",
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"index.js",
|
|
35
|
+
"client.js",
|
|
36
|
+
"typert.host.js",
|
|
37
|
+
"git-core.mjs",
|
|
38
|
+
"git-graph.mjs",
|
|
39
|
+
"cordis.patch.yml",
|
|
40
|
+
"icon.svg"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"engines": {
|
|
44
|
+
"dsh": "^0.1.0-rc.7 || ^0.1.1-rc.0 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
45
|
+
},
|
|
46
|
+
"dsh": {
|
|
47
|
+
"bundle": {
|
|
48
|
+
"patch": "./cordis.patch.yml"
|
|
49
|
+
},
|
|
50
|
+
"client": {
|
|
51
|
+
"platform": "web"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"dsh": "^0.1.0-rc.7 || ^0.1.1-rc.0 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
59
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.7 || ^0.1.1-rc.0 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"zod": "^4.4.3"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"check": "node --check index.js && node --check client.js && node --check typert.host.js && node --check git-core.mjs && node --check git-graph.mjs"
|
|
66
|
+
},
|
|
67
|
+
"forkedFrom": "@duke-dsh-plugins/dsh-git-manager@1.7.1"
|
|
68
|
+
}
|
package/typert.host.js
ADDED
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-volcano-git-plugin — Typert Host manifest.
|
|
3
|
+
*
|
|
4
|
+
* 手写 TYPERT manifest(dsh-typert-loader 从包的 `./typert` 导出加载)。
|
|
5
|
+
* 必须导出名为 `TYPERT` 的 manifest 对象(loader 的 validateTypertManifest 校验),
|
|
6
|
+
* 形状与 memory-manager / archive-manager 的手写 manifest 一致:
|
|
7
|
+
* { package, face: "host", schemas: [], invocations: [...], model: {services:[...]}, events: [], objects: [] }
|
|
8
|
+
*
|
|
9
|
+
* 每个 invocation:{ id, service, namespace, method, invocation:{kind:"direct"},
|
|
10
|
+
* parameters:[{name, wire, source, codec:{mode:"strict", typeSymbol, schema}}],
|
|
11
|
+
* result:{mode:"strict", typeSymbol, schema} }
|
|
12
|
+
*
|
|
13
|
+
* 与 index.js (GitManagerService) 和 client.js 的关键名字一致:
|
|
14
|
+
* - 服务键 / 类名:gitManager / GitManagerService
|
|
15
|
+
* - invocation id:dsh-volcano-git-plugin#gitManager/<method>
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
|
|
20
|
+
// ---- shared schemas -------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
const errorSchema = z.object({
|
|
23
|
+
code: z.string().readonly(),
|
|
24
|
+
message: z.string().readonly(),
|
|
25
|
+
}).readonly();
|
|
26
|
+
|
|
27
|
+
// status 的文件条目:子仓库支持 P0 新增两个可选字段(有值才挂 key,
|
|
28
|
+
// 否则网关 assertJsonValue 拒绝显式 undefined 的 own key——见 AGENTS.md)
|
|
29
|
+
// subState —— porcelain v2 <sub> 原样字符串("SC.." 等,仅非 "N" 时存在)
|
|
30
|
+
// gitlink —— staged 的 gitlink 指针变更:hH/hI 均为 40 位 sha 且不相等
|
|
31
|
+
const gitlinkSchema = z.object({
|
|
32
|
+
fromSha: z.string().readonly(),
|
|
33
|
+
toSha: z.string().readonly(),
|
|
34
|
+
}).readonly();
|
|
35
|
+
|
|
36
|
+
const fileEntrySchema = z.object({
|
|
37
|
+
path: z.string().readonly(),
|
|
38
|
+
oldPath: z.string().readonly().optional(),
|
|
39
|
+
x: z.string().readonly().optional(),
|
|
40
|
+
y: z.string().readonly().optional(),
|
|
41
|
+
kind: z.string().readonly(),
|
|
42
|
+
subState: z.string().readonly().optional(),
|
|
43
|
+
gitlink: gitlinkSchema.optional(),
|
|
44
|
+
}).readonly();
|
|
45
|
+
|
|
46
|
+
const conflictEntrySchema = z.object({
|
|
47
|
+
path: z.string().readonly(),
|
|
48
|
+
xy: z.string().readonly(),
|
|
49
|
+
}).readonly();
|
|
50
|
+
|
|
51
|
+
const branchInfoSchema = z.object({
|
|
52
|
+
name: z.string().readonly(),
|
|
53
|
+
refname: z.string().readonly(),
|
|
54
|
+
shortSha: z.string().readonly(),
|
|
55
|
+
at: z.number().readonly(),
|
|
56
|
+
upstream: z.string().readonly().nullable(),
|
|
57
|
+
ahead: z.number().readonly().nullable(),
|
|
58
|
+
behind: z.number().readonly().nullable(),
|
|
59
|
+
upstreamGone: z.boolean().readonly(),
|
|
60
|
+
subject: z.string().readonly(),
|
|
61
|
+
current: z.boolean().readonly(),
|
|
62
|
+
}).readonly();
|
|
63
|
+
|
|
64
|
+
const commitSchema = z.object({
|
|
65
|
+
sha: z.string().readonly(),
|
|
66
|
+
short: z.string().readonly(),
|
|
67
|
+
parents: z.array(z.string().readonly()).readonly(),
|
|
68
|
+
author: z.string().readonly(),
|
|
69
|
+
email: z.string().readonly(),
|
|
70
|
+
at: z.number().readonly(),
|
|
71
|
+
refs: z.string().readonly(),
|
|
72
|
+
subject: z.string().readonly(),
|
|
73
|
+
// v2 §6:subject 之后的多行正文(amend 预填用);无正文挂 ""(字段稳定)
|
|
74
|
+
body: z.string().readonly().optional(),
|
|
75
|
+
}).readonly();
|
|
76
|
+
|
|
77
|
+
const graphSchema = z.object({
|
|
78
|
+
nodes: z.array(z.object({ col: z.number().readonly(), color: z.number().readonly() }).readonly()).readonly(),
|
|
79
|
+
links: z.array(z.object({
|
|
80
|
+
fromRow: z.number().readonly(),
|
|
81
|
+
fromCol: z.number().readonly(),
|
|
82
|
+
toRow: z.number().readonly().nullable(),
|
|
83
|
+
toCol: z.number().readonly(),
|
|
84
|
+
color: z.number().readonly(),
|
|
85
|
+
kind: z.string().readonly(),
|
|
86
|
+
}).readonly()).readonly(),
|
|
87
|
+
laneCount: z.number().readonly(),
|
|
88
|
+
}).readonly();
|
|
89
|
+
|
|
90
|
+
const probeSchema = z.object({
|
|
91
|
+
isRepo: z.boolean().readonly(),
|
|
92
|
+
toplevel: z.string().readonly().optional(),
|
|
93
|
+
gitDir: z.string().readonly().optional(),
|
|
94
|
+
commonDir: z.string().readonly().optional(),
|
|
95
|
+
bare: z.boolean().readonly().optional(),
|
|
96
|
+
branch: z.string().readonly().nullable().optional(),
|
|
97
|
+
detached: z.boolean().readonly().optional(),
|
|
98
|
+
headShort: z.string().readonly().nullable().optional(),
|
|
99
|
+
unborn: z.boolean().readonly().optional(),
|
|
100
|
+
merging: z.boolean().readonly().optional(),
|
|
101
|
+
rebasing: z.boolean().readonly().optional(),
|
|
102
|
+
isLinkedWorktree: z.boolean().readonly().optional(),
|
|
103
|
+
mainWorktreePath: z.string().readonly().optional(),
|
|
104
|
+
}).readonly();
|
|
105
|
+
|
|
106
|
+
const statusSchema = z.object({
|
|
107
|
+
branch: z.string().readonly().nullable(),
|
|
108
|
+
detached: z.boolean().readonly(),
|
|
109
|
+
headSha: z.string().readonly().nullable(),
|
|
110
|
+
upstream: z.string().readonly().nullable(),
|
|
111
|
+
ahead: z.number().readonly(),
|
|
112
|
+
behind: z.number().readonly(),
|
|
113
|
+
unborn: z.boolean().readonly(),
|
|
114
|
+
staged: z.array(fileEntrySchema).readonly(),
|
|
115
|
+
unstaged: z.array(fileEntrySchema).readonly(),
|
|
116
|
+
untracked: z.array(z.string().readonly()).readonly(),
|
|
117
|
+
conflicted: z.array(conflictEntrySchema).readonly(),
|
|
118
|
+
merging: z.boolean().readonly(),
|
|
119
|
+
rebasing: z.boolean().readonly(),
|
|
120
|
+
}).readonly();
|
|
121
|
+
|
|
122
|
+
const worktreeSchema = z.object({
|
|
123
|
+
path: z.string().readonly(),
|
|
124
|
+
headSha: z.string().readonly().nullable(),
|
|
125
|
+
branch: z.string().readonly().nullable(),
|
|
126
|
+
detached: z.boolean().readonly(),
|
|
127
|
+
bare: z.boolean().readonly(),
|
|
128
|
+
locked: z.union([z.boolean().readonly(), z.string().readonly()]).readonly().optional(),
|
|
129
|
+
prunable: z.union([z.boolean().readonly(), z.string().readonly()]).readonly().optional(),
|
|
130
|
+
current: z.boolean().readonly().optional(),
|
|
131
|
+
// 行内状态富化(getWorktrees:非 bare worktree 才有;可选字段有值才挂 key)
|
|
132
|
+
headShort: z.string().readonly().optional(),
|
|
133
|
+
dirty: z.object({
|
|
134
|
+
staged: z.number().readonly(),
|
|
135
|
+
unstaged: z.number().readonly(),
|
|
136
|
+
untracked: z.number().readonly(),
|
|
137
|
+
conflicted: z.number().readonly(),
|
|
138
|
+
}).readonly().optional(),
|
|
139
|
+
ahead: z.number().readonly().optional(),
|
|
140
|
+
behind: z.number().readonly().optional(),
|
|
141
|
+
error: z.string().readonly().optional(),
|
|
142
|
+
}).readonly();
|
|
143
|
+
|
|
144
|
+
const remoteSchema = z.object({
|
|
145
|
+
name: z.string().readonly(),
|
|
146
|
+
fetchUrl: z.string().readonly().nullable(),
|
|
147
|
+
pushUrl: z.string().readonly().nullable(),
|
|
148
|
+
}).readonly();
|
|
149
|
+
|
|
150
|
+
// ---- v2 §2.2 新增数据形状(strict、readonly;可选字段有值才挂) ----
|
|
151
|
+
|
|
152
|
+
const stashEntrySchema = z.object({
|
|
153
|
+
index: z.number().readonly(),
|
|
154
|
+
ref: z.string().readonly(),
|
|
155
|
+
subject: z.string().readonly(),
|
|
156
|
+
at: z.number().readonly(),
|
|
157
|
+
}).readonly();
|
|
158
|
+
|
|
159
|
+
const tagInfoSchema = z.object({
|
|
160
|
+
name: z.string().readonly(),
|
|
161
|
+
sha: z.string().readonly(),
|
|
162
|
+
short: z.string().readonly(),
|
|
163
|
+
subject: z.string().readonly(),
|
|
164
|
+
at: z.number().readonly(),
|
|
165
|
+
annotated: z.boolean().readonly(),
|
|
166
|
+
message: z.string().readonly().optional(),
|
|
167
|
+
}).readonly();
|
|
168
|
+
|
|
169
|
+
const blameLineSchema = z.object({
|
|
170
|
+
sha: z.string().readonly(),
|
|
171
|
+
short: z.string().readonly(),
|
|
172
|
+
author: z.string().readonly(),
|
|
173
|
+
at: z.number().readonly(),
|
|
174
|
+
line: z.number().readonly(),
|
|
175
|
+
text: z.string().readonly(),
|
|
176
|
+
}).readonly();
|
|
177
|
+
|
|
178
|
+
const reflogEntrySchema = z.object({
|
|
179
|
+
sha: z.string().readonly(),
|
|
180
|
+
short: z.string().readonly(),
|
|
181
|
+
selector: z.string().readonly(),
|
|
182
|
+
message: z.string().readonly(),
|
|
183
|
+
at: z.number().readonly(),
|
|
184
|
+
}).readonly();
|
|
185
|
+
|
|
186
|
+
const configEntrySchema = z.object({
|
|
187
|
+
key: z.string().readonly(),
|
|
188
|
+
value: z.string().readonly(),
|
|
189
|
+
}).readonly();
|
|
190
|
+
|
|
191
|
+
// ---- 子仓库支持 P0(2026-10-13):仓库树 RepoNode ----
|
|
192
|
+
// 可选字段一律 .optional() 且 Host 侧「有值才挂 key」;字符串无值用 ""、
|
|
193
|
+
// 计数恒为数字(不挂 null/undefined)。
|
|
194
|
+
|
|
195
|
+
const repoDirtySchema = z.object({
|
|
196
|
+
staged: z.number().readonly(),
|
|
197
|
+
unstaged: z.number().readonly(),
|
|
198
|
+
untracked: z.number().readonly(),
|
|
199
|
+
conflicted: z.number().readonly(),
|
|
200
|
+
}).readonly();
|
|
201
|
+
|
|
202
|
+
// 只在 kind==="submodule" 且 initialized=true 时存在(未初始化节点不挂 key)
|
|
203
|
+
const repoSubmoduleSchema = z.object({
|
|
204
|
+
state: z.enum(["ok", "pointer-mismatch", "conflict"]).readonly(),
|
|
205
|
+
sha: z.string().readonly(),
|
|
206
|
+
recordedSha: z.string().readonly(),
|
|
207
|
+
url: z.string().readonly(),
|
|
208
|
+
}).readonly();
|
|
209
|
+
|
|
210
|
+
const repoNodeSchema = z.object({
|
|
211
|
+
id: z.string().readonly(),
|
|
212
|
+
path: z.string().readonly(),
|
|
213
|
+
relPath: z.string().readonly(),
|
|
214
|
+
name: z.string().readonly(),
|
|
215
|
+
kind: z.enum(["root", "submodule", "nested"]).readonly(),
|
|
216
|
+
depth: z.number().readonly(),
|
|
217
|
+
initialized: z.boolean().readonly(),
|
|
218
|
+
branch: z.string().readonly(),
|
|
219
|
+
detached: z.boolean().readonly(),
|
|
220
|
+
unborn: z.boolean().readonly(),
|
|
221
|
+
headShort: z.string().readonly(),
|
|
222
|
+
dirty: repoDirtySchema,
|
|
223
|
+
// 仅当该节点 probe/status 查询失败时挂(节点仍返回,dirty 全 0)
|
|
224
|
+
error: z.string().readonly().optional(),
|
|
225
|
+
// 仅 kind==="nested" 且该仓库有 origin remote 时挂(P2:供客户端「注册为
|
|
226
|
+
// submodule」转换用)。submodule/root 不挂——submodule 的 url 在 submodule.url。
|
|
227
|
+
originUrl: z.string().readonly().optional(),
|
|
228
|
+
submodule: repoSubmoduleSchema.optional(),
|
|
229
|
+
}).readonly();
|
|
230
|
+
|
|
231
|
+
const repoTreeValueSchema = z.object({
|
|
232
|
+
repos: z.array(repoNodeSchema).readonly(),
|
|
233
|
+
}).readonly();
|
|
234
|
+
|
|
235
|
+
// P3-A §8.1:rebase todo 条目(action ∈ pick|squash|fixup|drop|edit,Host 枚举校验;
|
|
236
|
+
// message 仅 squash 有值才挂)
|
|
237
|
+
const rebaseTodoSchema = z.object({
|
|
238
|
+
sha: z.string().readonly(),
|
|
239
|
+
short: z.string().readonly(),
|
|
240
|
+
subject: z.string().readonly(),
|
|
241
|
+
action: z.string().readonly(),
|
|
242
|
+
message: z.string().readonly().optional(),
|
|
243
|
+
}).readonly();
|
|
244
|
+
|
|
245
|
+
const branchesValueSchema = z.object({
|
|
246
|
+
current: z.string().readonly().nullable(),
|
|
247
|
+
locals: z.array(branchInfoSchema).readonly(),
|
|
248
|
+
remotes: z.array(branchInfoSchema).readonly(),
|
|
249
|
+
}).readonly();
|
|
250
|
+
|
|
251
|
+
const logValueSchema = z.object({
|
|
252
|
+
commits: z.array(commitSchema).readonly(),
|
|
253
|
+
graph: graphSchema,
|
|
254
|
+
hasMore: z.boolean().readonly(),
|
|
255
|
+
}).readonly();
|
|
256
|
+
|
|
257
|
+
const worktreesValueSchema = z.object({
|
|
258
|
+
worktrees: z.array(worktreeSchema).readonly(),
|
|
259
|
+
}).readonly();
|
|
260
|
+
|
|
261
|
+
const conflictContentValueSchema = z.object({
|
|
262
|
+
ours: z.string().readonly().optional(),
|
|
263
|
+
theirs: z.string().readonly().optional(),
|
|
264
|
+
base: z.string().readonly().optional(),
|
|
265
|
+
worktree: z.string().readonly().optional(),
|
|
266
|
+
}).readonly();
|
|
267
|
+
|
|
268
|
+
const diffValueSchema = z.object({
|
|
269
|
+
text: z.string().readonly(),
|
|
270
|
+
truncated: z.boolean().readonly(),
|
|
271
|
+
}).readonly();
|
|
272
|
+
|
|
273
|
+
const statusOnlySchema = z.object({ status: statusSchema }).readonly();
|
|
274
|
+
const commitValueSchema = z.object({
|
|
275
|
+
commit: z.string().readonly(),
|
|
276
|
+
status: statusSchema,
|
|
277
|
+
}).readonly();
|
|
278
|
+
const mergeValueSchema = z.object({
|
|
279
|
+
merged: z.boolean().readonly(),
|
|
280
|
+
status: statusSchema,
|
|
281
|
+
}).readonly();
|
|
282
|
+
// cherry-pick 与 merge 同款契约:冲突时 picked=false 不抛错,
|
|
283
|
+
// 仓库进 CHERRY_PICK_HEAD 态,交冲突页解决后 mergeContinue 完成 pick
|
|
284
|
+
const cherryPickValueSchema = z.object({
|
|
285
|
+
picked: z.boolean().readonly(),
|
|
286
|
+
status: statusSchema,
|
|
287
|
+
}).readonly();
|
|
288
|
+
const fetchValueSchema = z.object({
|
|
289
|
+
output: z.string().readonly(),
|
|
290
|
+
status: statusSchema,
|
|
291
|
+
}).readonly();
|
|
292
|
+
|
|
293
|
+
function result(valueSchema) {
|
|
294
|
+
return z.union([
|
|
295
|
+
z.object({ ok: z.literal(true).readonly(), value: valueSchema }).readonly(),
|
|
296
|
+
z.object({ ok: z.literal(false).readonly(), error: errorSchema }).readonly(),
|
|
297
|
+
]).readonly();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function netResult(valueSchema) {
|
|
301
|
+
return z.union([
|
|
302
|
+
z.object({ ok: z.literal(true).readonly(), value: valueSchema }).readonly(),
|
|
303
|
+
z.object({
|
|
304
|
+
ok: z.literal(false).readonly(),
|
|
305
|
+
error: errorSchema,
|
|
306
|
+
output: z.string().readonly().optional(),
|
|
307
|
+
status: statusSchema.optional(),
|
|
308
|
+
}).readonly(),
|
|
309
|
+
]).readonly();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ---- per-method result schemas ------------------------------------------
|
|
313
|
+
|
|
314
|
+
const probeResult = result(probeSchema);
|
|
315
|
+
const overviewResult = result(z.object({
|
|
316
|
+
probe: probeSchema,
|
|
317
|
+
status: statusSchema.nullable(),
|
|
318
|
+
remotes: z.array(remoteSchema).readonly(),
|
|
319
|
+
}).readonly());
|
|
320
|
+
const statusResult = result(statusSchema);
|
|
321
|
+
const diffResult = result(diffValueSchema);
|
|
322
|
+
const logResult = result(logValueSchema);
|
|
323
|
+
const branchesResult = result(branchesValueSchema);
|
|
324
|
+
const remotesResult = result(z.array(remoteSchema).readonly());
|
|
325
|
+
const worktreesResult = result(worktreesValueSchema);
|
|
326
|
+
const conflictContentResult = result(conflictContentValueSchema);
|
|
327
|
+
const mutationResult = result(statusOnlySchema);
|
|
328
|
+
const commitResult = result(commitValueSchema);
|
|
329
|
+
const mergeResult = result(mergeValueSchema);
|
|
330
|
+
const cherryPickResult = result(cherryPickValueSchema);
|
|
331
|
+
const fetchResult = netResult(fetchValueSchema);
|
|
332
|
+
const worktreeMutResult = result(worktreesValueSchema);
|
|
333
|
+
const initResult = result(z.object({ probe: probeSchema }).readonly());
|
|
334
|
+
// discard 与其它变更方法不同款:除 status 外还可能带 skipped(未跟踪清理时
|
|
335
|
+
// 含 .git 的嵌套仓库路径被跳过不删;有值才挂 key)
|
|
336
|
+
const discardValueSchema = z.object({
|
|
337
|
+
status: statusSchema,
|
|
338
|
+
skipped: z.array(z.string().readonly()).readonly().optional(),
|
|
339
|
+
}).readonly();
|
|
340
|
+
const discardResult = result(discardValueSchema);
|
|
341
|
+
|
|
342
|
+
// ---- v2 §2.2/§2.3 新增 result schemas -----------------------------------
|
|
343
|
+
|
|
344
|
+
const stashesValueSchema = z.object({
|
|
345
|
+
stashes: z.array(stashEntrySchema).readonly(),
|
|
346
|
+
}).readonly();
|
|
347
|
+
const tagsValueSchema = z.object({
|
|
348
|
+
tags: z.array(tagInfoSchema).readonly(),
|
|
349
|
+
}).readonly();
|
|
350
|
+
const blameValueSchema = z.object({
|
|
351
|
+
lines: z.array(blameLineSchema).readonly(),
|
|
352
|
+
truncated: z.boolean().readonly(),
|
|
353
|
+
}).readonly();
|
|
354
|
+
const reflogValueSchema = z.object({
|
|
355
|
+
entries: z.array(reflogEntrySchema).readonly(),
|
|
356
|
+
}).readonly();
|
|
357
|
+
const configValueSchema = z.object({
|
|
358
|
+
entries: z.array(configEntrySchema).readonly(),
|
|
359
|
+
}).readonly();
|
|
360
|
+
const remotesValueSchema = z.object({
|
|
361
|
+
remotes: z.array(remoteSchema).readonly(),
|
|
362
|
+
}).readonly();
|
|
363
|
+
// revert 与 cherry-pick 同款契约:冲突 reverted=false 不抛错,进 REVERT_HEAD 态
|
|
364
|
+
const revertValueSchema = z.object({
|
|
365
|
+
reverted: z.boolean().readonly(),
|
|
366
|
+
status: statusSchema,
|
|
367
|
+
}).readonly();
|
|
368
|
+
|
|
369
|
+
const stashesResult = result(stashesValueSchema);
|
|
370
|
+
const tagsResult = result(tagsValueSchema);
|
|
371
|
+
const blameResult = result(blameValueSchema);
|
|
372
|
+
const reflogResult = result(reflogValueSchema);
|
|
373
|
+
const configResult = result(configValueSchema);
|
|
374
|
+
const remoteListResult = result(remotesValueSchema); // v2 remoteAdd/Remove/Rename 返回 { remotes }
|
|
375
|
+
const revertResult = result(revertValueSchema);
|
|
376
|
+
|
|
377
|
+
// ---- P3-A(§8.1/§8.3)result schemas -----------------------------------
|
|
378
|
+
|
|
379
|
+
// rebasePlan:todo 候选(base..HEAD 不含 base,最旧在前)
|
|
380
|
+
const rebasePlanResult = result(z.object({
|
|
381
|
+
entries: z.array(rebaseTodoSchema).readonly(),
|
|
382
|
+
}).readonly());
|
|
383
|
+
// rebaseRun / fixupCommit / rebaseBranch 共款:done=false = 冲突或 edit 停驻进行中
|
|
384
|
+
const rebaseDoneValueSchema = z.object({
|
|
385
|
+
done: z.boolean().readonly(),
|
|
386
|
+
status: statusSchema,
|
|
387
|
+
}).readonly();
|
|
388
|
+
const rebaseRunResult = result(rebaseDoneValueSchema);
|
|
389
|
+
const fixupResult = result(rebaseDoneValueSchema);
|
|
390
|
+
const rebaseBranchResult = result(rebaseDoneValueSchema);
|
|
391
|
+
|
|
392
|
+
// ---- 子仓库支持 P0(2026-10-13):repoTree ----
|
|
393
|
+
const repoTreeResult = result(repoTreeValueSchema);
|
|
394
|
+
|
|
395
|
+
// ---- 子仓库支持 P1:revExists(sha 存在性门控)----
|
|
396
|
+
// 恒为数组(空数组合法);ok:false = 该 sha 不在这个仓库的对象库里(跳转禁用),
|
|
397
|
+
// 非法 sha 由 git-core 抛错走错误信封,不会混进 checks 里。
|
|
398
|
+
const revExistsValueSchema = z.object({
|
|
399
|
+
checks: z.array(z.object({
|
|
400
|
+
rev: z.string().readonly(),
|
|
401
|
+
ok: z.boolean().readonly(),
|
|
402
|
+
}).readonly()).readonly(),
|
|
403
|
+
}).readonly();
|
|
404
|
+
const revExistsResult = result(revExistsValueSchema);
|
|
405
|
+
|
|
406
|
+
// ---- 子仓库支持 P2(2026-10-13):submodule 管理五方法 ----
|
|
407
|
+
// 前四个与其它变更方法同款:{ status };submoduleAdd 额外带新子仓库 probe,
|
|
408
|
+
// 客户端可直接把新节点插进仓库树。
|
|
409
|
+
const submoduleAddValueSchema = z.object({
|
|
410
|
+
status: statusSchema,
|
|
411
|
+
probe: probeSchema,
|
|
412
|
+
}).readonly();
|
|
413
|
+
const submoduleAddResult = result(submoduleAddValueSchema);
|
|
414
|
+
|
|
415
|
+
// per-method 请求补充字段(基础形态是 passthrough 的 z.object({}),这里给个别方法
|
|
416
|
+
// 显式声明新增的可选入参;其余键仍由 passthrough 放行)
|
|
417
|
+
const REQUEST_SHAPES = {
|
|
418
|
+
// stage {all:true} 时排除嵌套独立仓库目录(方案 §5.1:暂存它会变成意外 gitlink);
|
|
419
|
+
// files 模式忽略该参数
|
|
420
|
+
stage: {
|
|
421
|
+
exclude: z.array(z.string().readonly()).readonly().optional(),
|
|
422
|
+
},
|
|
423
|
+
// path 由 passthrough 放行;revs 只接受字符串数组(元素级 sha 白名单在 git-core)
|
|
424
|
+
revExists: {
|
|
425
|
+
revs: z.array(z.string().readonly()).readonly(),
|
|
426
|
+
},
|
|
427
|
+
// submodule 管理五方法(子仓库支持 P2)。位置参数是「仓库内路径」(相对
|
|
428
|
+
// toplevel,git submodule 子命令收路径而非注册名),越界防护在 git-core 的
|
|
429
|
+
// safeJoin;deinit 必填(缺省会清空全部子模块)。
|
|
430
|
+
submoduleInit: {
|
|
431
|
+
subPath: z.string().readonly().optional(),
|
|
432
|
+
},
|
|
433
|
+
submoduleUpdate: {
|
|
434
|
+
subPath: z.string().readonly().optional(),
|
|
435
|
+
init: z.boolean().readonly().optional(),
|
|
436
|
+
recursive: z.boolean().readonly().optional(),
|
|
437
|
+
},
|
|
438
|
+
submoduleSync: {
|
|
439
|
+
subPath: z.string().readonly().optional(),
|
|
440
|
+
},
|
|
441
|
+
submoduleDeinit: {
|
|
442
|
+
subPath: z.string().readonly(),
|
|
443
|
+
},
|
|
444
|
+
submoduleAdd: {
|
|
445
|
+
url: z.string().readonly(),
|
|
446
|
+
subPath: z.string().readonly(),
|
|
447
|
+
name: z.string().readonly().optional(),
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
function requestSchemaOf(method) {
|
|
452
|
+
const shape = REQUEST_SHAPES[method];
|
|
453
|
+
return shape ? z.object(shape).passthrough() : z.object({}).passthrough();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// ---- manifest ------------------------------------------------------------
|
|
457
|
+
|
|
458
|
+
const METHODS = [
|
|
459
|
+
["probe", probeResult],
|
|
460
|
+
["overview", overviewResult],
|
|
461
|
+
["status", statusResult],
|
|
462
|
+
["diff", diffResult],
|
|
463
|
+
["log", logResult],
|
|
464
|
+
["branches", branchesResult],
|
|
465
|
+
["remotes", remotesResult],
|
|
466
|
+
["worktrees", worktreesResult],
|
|
467
|
+
["conflictContent", conflictContentResult],
|
|
468
|
+
["stage", mutationResult],
|
|
469
|
+
["unstage", mutationResult],
|
|
470
|
+
["discard", discardResult],
|
|
471
|
+
["hunkApply", mutationResult],
|
|
472
|
+
["commit", commitResult],
|
|
473
|
+
["branchCreate", mutationResult],
|
|
474
|
+
["checkout", mutationResult],
|
|
475
|
+
["branchDelete", mutationResult],
|
|
476
|
+
["branchRename", mutationResult],
|
|
477
|
+
["merge", mergeResult],
|
|
478
|
+
["mergeAbort", mutationResult],
|
|
479
|
+
["mergeContinue", mutationResult],
|
|
480
|
+
["cherryPick", cherryPickResult],
|
|
481
|
+
["resolveConflict", mutationResult],
|
|
482
|
+
["fetch", fetchResult],
|
|
483
|
+
["pull", fetchResult],
|
|
484
|
+
["push", fetchResult],
|
|
485
|
+
["worktreeAdd", worktreeMutResult],
|
|
486
|
+
["worktreeRemove", worktreeMutResult],
|
|
487
|
+
["worktreePrune", worktreeMutResult],
|
|
488
|
+
["init", initResult],
|
|
489
|
+
// ---- v2 §2.1 stageHunk + §2.2 P1 ----
|
|
490
|
+
["stageHunk", mutationResult],
|
|
491
|
+
["stashList", stashesResult],
|
|
492
|
+
["stashPush", stashesResult],
|
|
493
|
+
["stashPop", mutationResult],
|
|
494
|
+
["stashApply", mutationResult],
|
|
495
|
+
["stashDrop", stashesResult],
|
|
496
|
+
["stashClear", stashesResult],
|
|
497
|
+
["tags", tagsResult],
|
|
498
|
+
["tagCreate", tagsResult],
|
|
499
|
+
["tagDelete", tagsResult],
|
|
500
|
+
["reset", mutationResult],
|
|
501
|
+
["revert", revertResult],
|
|
502
|
+
["blame", blameResult],
|
|
503
|
+
["diffRange", diffResult],
|
|
504
|
+
["reflog", reflogResult],
|
|
505
|
+
// ---- v2 §2.3 P2 ----
|
|
506
|
+
["remoteAdd", remoteListResult],
|
|
507
|
+
["remoteRemove", remoteListResult],
|
|
508
|
+
["remoteRename", remoteListResult],
|
|
509
|
+
["configList", configResult],
|
|
510
|
+
["configSet", configResult],
|
|
511
|
+
["configUnset", configResult],
|
|
512
|
+
// ---- P3-A §8.1/§8.3(51 → 56)----
|
|
513
|
+
["rebasePlan", rebasePlanResult],
|
|
514
|
+
["rebaseRun", rebaseRunResult],
|
|
515
|
+
["fixupCommit", fixupResult],
|
|
516
|
+
["rebaseBranch", rebaseBranchResult],
|
|
517
|
+
["lineApply", mutationResult],
|
|
518
|
+
// ---- 子仓库支持 P0(56 → 57):repoTree(仓库树发现)----
|
|
519
|
+
["repoTree", repoTreeResult],
|
|
520
|
+
// ---- 子仓库支持 P1(57 → 58):revExists(sha 存在性门控)----
|
|
521
|
+
["revExists", revExistsResult],
|
|
522
|
+
// ---- 子仓库支持 P2(58 → 63):submodule 管理五方法 ----
|
|
523
|
+
["submoduleInit", mutationResult],
|
|
524
|
+
["submoduleUpdate", mutationResult],
|
|
525
|
+
["submoduleSync", mutationResult],
|
|
526
|
+
["submoduleDeinit", mutationResult],
|
|
527
|
+
["submoduleAdd", submoduleAddResult],
|
|
528
|
+
];
|
|
529
|
+
|
|
530
|
+
function invocationOf(method, resultSchema) {
|
|
531
|
+
// strict codec 必须「双形态」(实测 21 个 typert-loader 版本的矩阵结论):
|
|
532
|
+
// - ≤0.1.6-alpha.1:loader/registry/gateway 校验并使用 `schema`(zod 实例,`.parse`)
|
|
533
|
+
// - ≥0.1.6-alpha.2(含 0.1.7-rc.x):校验 `create()` 工厂,gateway 解码走 `codec.create().parse(...)`
|
|
534
|
+
// 两代校验各看一个键、互不检查对方,所以两个键并存才能同时通过新旧两端;
|
|
535
|
+
// 只写 schema 会在 0.1.7 的客户端 $mount 注册时抛 "strict codec has no create() factory",
|
|
536
|
+
// 导致插件槽位注册失败、入口按钮不出现(表现为"插件加载不上")。
|
|
537
|
+
const requestSchema = requestSchemaOf(method);
|
|
538
|
+
return {
|
|
539
|
+
id: "dsh-volcano-git-plugin#gitManager/" + method,
|
|
540
|
+
service: "gitManager",
|
|
541
|
+
namespace: "gitManager",
|
|
542
|
+
method,
|
|
543
|
+
invocation: { kind: "direct" },
|
|
544
|
+
parameters: [
|
|
545
|
+
{
|
|
546
|
+
name: "request",
|
|
547
|
+
wire: "request",
|
|
548
|
+
source: "json",
|
|
549
|
+
codec: {
|
|
550
|
+
mode: "strict",
|
|
551
|
+
typeSymbol: "dsh-volcano-git-plugin#GitManager" + method + "Request",
|
|
552
|
+
schema: requestSchema,
|
|
553
|
+
create: () => requestSchema,
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
],
|
|
557
|
+
result: {
|
|
558
|
+
mode: "strict",
|
|
559
|
+
typeSymbol: "dsh-volcano-git-plugin#GitManager" + method + "Result",
|
|
560
|
+
schema: resultSchema,
|
|
561
|
+
create: () => resultSchema,
|
|
562
|
+
},
|
|
563
|
+
sourceLocation: { file: "index.js", line: 1, column: 1 },
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// service members(Remote 方法)与 types 用生成器构造,与 invocations 同源
|
|
568
|
+
function serviceMemberOf(method) {
|
|
569
|
+
return {
|
|
570
|
+
kind: "method",
|
|
571
|
+
name: method,
|
|
572
|
+
signature: "@Remote('" + method + "') async " + method + "(request: GitManager" + method + "Request): Promise<GitManager" + method + "Result>",
|
|
573
|
+
summary: "gitManager." + method + "() — see index.js.",
|
|
574
|
+
jsDoc: "/**\n * gitManager." + method + "()\n * @param request - the request payload.\n * @returns the result envelope.\n */",
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export const TYPERT = {
|
|
579
|
+
package: "dsh-volcano-git-plugin",
|
|
580
|
+
face: "host",
|
|
581
|
+
schemas: [],
|
|
582
|
+
invocations: METHODS.map(([m, r]) => invocationOf(m, r)),
|
|
583
|
+
model: {
|
|
584
|
+
services: [
|
|
585
|
+
{
|
|
586
|
+
description: "Git workspace management service: probe, status, diff, branches, log (with branch graph), conflicts, worktrees, and commit/fetch/pull/push.",
|
|
587
|
+
summary: "Git workspace management service.",
|
|
588
|
+
tags: [],
|
|
589
|
+
jsDoc: "/**\n * Git workspace management service.\n */",
|
|
590
|
+
key: "gitManager",
|
|
591
|
+
exportName: "GitManagerService",
|
|
592
|
+
members: METHODS.map(([m]) => serviceMemberOf(m)),
|
|
593
|
+
types: [],
|
|
594
|
+
},
|
|
595
|
+
],
|
|
596
|
+
events: [],
|
|
597
|
+
objects: [],
|
|
598
|
+
},
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
export default TYPERT;
|