dsh-git-ui 0.0.2 → 0.1.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/README.md +55 -20
- package/README.zh.md +55 -21
- package/cordis.patch.yml +1 -1
- package/lib/client.js +36 -35
- package/lib/client.js.map +4 -4
- package/lib/contracts/host-endpoints.d.ts +27 -0
- package/lib/host/actions.d.ts +22 -2
- package/lib/host/core.d.ts +7 -1
- package/lib/host/index.d.ts +25 -15
- package/lib/host/index.js +419 -53
- package/lib/host/index.js.map +4 -4
- package/lib/host/parser.d.ts +37 -1
- package/lib/host/queries.d.ts +17 -0
- package/lib/host/types.d.ts +131 -1
- package/package.json +1 -1
- package/src/adapters/dsh/client-adapter.ts +120 -0
- package/src/adapters/dsh/types/cordis.d.ts +48 -0
- package/src/adapters/dsh/types/typert-protocol.d.ts +81 -0
- package/src/adapters/dsh/types/ui-primitives.d.ts +45 -0
- package/src/adapters/dsh/ui-primitives.ts +16 -0
- package/src/client/GitCenter.tsx +1414 -149
- package/src/client/GitPill.tsx +282 -67
- package/src/client/changes-diff.ts +63 -0
- package/src/client/controller.ts +34 -31
- package/src/client/error-text.ts +21 -0
- package/src/client/file-tree.ts +101 -0
- package/src/client/git-graph.ts +188 -0
- package/src/client/icons.tsx +292 -0
- package/src/client/index.ts +38 -134
- package/src/client/locales.ts +124 -0
- package/src/client/popup-close.ts +19 -0
- package/src/client/remote.ts +85 -3
- package/src/client/select-menu.tsx +113 -0
- package/src/client/side-by-side.ts +150 -0
- package/src/client/styles.ts +1375 -86
- package/src/client/time-format.ts +32 -0
- package/src/contracts/client-platform.ts +147 -0
- package/src/contracts/host-endpoints.ts +58 -0
- package/src/contracts/plugin-activation.ts +129 -0
- package/src/contracts/ui-context.tsx +28 -0
- package/src/contracts/ui-primitives.ts +48 -0
- package/src/host/actions.ts +66 -15
- package/src/host/core.ts +9 -2
- package/src/host/index.ts +60 -54
- package/src/host/parser.ts +155 -12
- package/src/host/queries.ts +289 -0
- package/src/host/types.ts +104 -0
package/src/host/types.ts
CHANGED
|
@@ -58,10 +58,40 @@ export interface GitCommit {
|
|
|
58
58
|
readonly dateIso: string
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* 带父引用的提交(图渲染用)。
|
|
63
|
+
* `parents` 为完整 SHA(线上格式以空格分隔);根提交为空数组。
|
|
64
|
+
* `refs` 为 `%D` 装饰(分支 / 远程 / 标签)。
|
|
65
|
+
*/
|
|
66
|
+
export interface GraphCommit extends GitCommit {
|
|
67
|
+
readonly parents: readonly string[]
|
|
68
|
+
readonly refs: readonly GitRef[]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 提交上挂载的一个 ref 装饰(分支 / 远程 / 标签)。 */
|
|
72
|
+
export interface GitRef {
|
|
73
|
+
readonly kind: 'branch' | 'remote' | 'tag'
|
|
74
|
+
readonly name: string
|
|
75
|
+
/** `HEAD -> name` 的当前分支为 true。 */
|
|
76
|
+
readonly head: boolean
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 一条变更文件条目。混合状态(porcelain XY 双列均非空,如 MM/AM)会被
|
|
81
|
+
* 拆为两条:`staged: true` 一侧(状态取 X 列)与 `staged: false` 一侧
|
|
82
|
+
* (状态取 Y 列),UI 据此分列「已暂存更改 / 更改」两组(IDEA 式)。
|
|
83
|
+
* 真实冲突(UU/AA/DD 等)保持单条 `conflicted`。
|
|
84
|
+
*/
|
|
61
85
|
export interface GitChange {
|
|
62
86
|
readonly path: string
|
|
63
87
|
readonly status: GitChangeStatus
|
|
64
88
|
readonly staged: boolean
|
|
89
|
+
/**
|
|
90
|
+
* 目录条目(git status 对未跟踪目录输出 `dir/`,host 解析时权威标记)。
|
|
91
|
+
* 展示层必须以此字段判断目录而非字符串派生——任何路径规范化剥离尾斜杠
|
|
92
|
+
* 都不会丢失目录性(`.agent/` 曾被当文件展示的根因防护)。
|
|
93
|
+
*/
|
|
94
|
+
readonly isDirectory: boolean
|
|
65
95
|
}
|
|
66
96
|
|
|
67
97
|
export type GitChangeStatus =
|
|
@@ -92,6 +122,10 @@ export type GitAction =
|
|
|
92
122
|
* empty commits everything already staged. */
|
|
93
123
|
readonly paths?: readonly string[]
|
|
94
124
|
}
|
|
125
|
+
| { readonly kind: 'branch-create'; readonly name: string; readonly from?: string }
|
|
126
|
+
| { readonly kind: 'branch-checkout'; readonly name: string }
|
|
127
|
+
| { readonly kind: 'branch-delete'; readonly name: string; readonly force?: boolean }
|
|
128
|
+
| { readonly kind: 'fetch' }
|
|
95
129
|
|
|
96
130
|
export type GitOperationErrorCode =
|
|
97
131
|
| 'session-not-found'
|
|
@@ -99,8 +133,13 @@ export type GitOperationErrorCode =
|
|
|
99
133
|
| 'path-not-found'
|
|
100
134
|
| 'not-a-git-repo'
|
|
101
135
|
| 'invalid-path'
|
|
136
|
+
| 'invalid-name'
|
|
102
137
|
| 'git-error'
|
|
103
138
|
| 'timeout'
|
|
139
|
+
/** 切分支被工作区未提交变更阻止(git: "would be overwritten by checkout")。
|
|
140
|
+
* host 归一化为业务错误:client 用友好文案 +「处理变更」引导,不再直接
|
|
141
|
+
* 抛原始多行 git stderr。原始信息保留在 message。 */
|
|
142
|
+
| 'local-changes-block'
|
|
104
143
|
|
|
105
144
|
export type GitActionResult =
|
|
106
145
|
| { readonly ok: true; readonly snapshot: GitSnapshot; readonly output?: string }
|
|
@@ -111,3 +150,68 @@ export interface GitActionRequest {
|
|
|
111
150
|
readonly sessionId: string
|
|
112
151
|
readonly action: GitAction
|
|
113
152
|
}
|
|
153
|
+
|
|
154
|
+
// ── Query endpoint (read-only inspections: history / diff / show / branches) ──
|
|
155
|
+
|
|
156
|
+
/** 一条只读查询,对应 `gitInfo/query` 端点。 */
|
|
157
|
+
export type GitQuery =
|
|
158
|
+
| {
|
|
159
|
+
readonly kind: 'history'
|
|
160
|
+
readonly limit: number
|
|
161
|
+
readonly skip: number
|
|
162
|
+
/** 可选 ref 过滤(分支/远程/标签);缺省为 --all 全分支。 */
|
|
163
|
+
readonly ref?: string
|
|
164
|
+
/** 文本搜索:7+ 位十六进制视为哈希前缀跳转;否则提交信息正则搜索(-i -E)。 */
|
|
165
|
+
readonly search?: string
|
|
166
|
+
/** 作者过滤(--author)。 */
|
|
167
|
+
readonly author?: string
|
|
168
|
+
/** 日期下限(--since,如 '7 days ago')。 */
|
|
169
|
+
readonly since?: string
|
|
170
|
+
}
|
|
171
|
+
| { readonly kind: 'diff'; readonly path: string; readonly base: 'worktree' | 'staged' }
|
|
172
|
+
| { readonly kind: 'show'; readonly ref: string }
|
|
173
|
+
| { readonly kind: 'branches' }
|
|
174
|
+
| { readonly kind: 'tags' }
|
|
175
|
+
| { readonly kind: 'authors' }
|
|
176
|
+
|
|
177
|
+
/** 提交变更文件行(`--name-status` 源:状态 + 路径,不再携带 +/- 行数)。 */
|
|
178
|
+
export interface GitFileStat {
|
|
179
|
+
readonly path: string
|
|
180
|
+
readonly status: GitChangeStatus
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** One branch row from `git branch --format`. Local branches may carry
|
|
184
|
+
* ahead/behind counts relative to their upstream (from `%(upstream:track)`). */
|
|
185
|
+
export interface GitBranch {
|
|
186
|
+
readonly name: string
|
|
187
|
+
readonly shortHash: string | null
|
|
188
|
+
/** 本地分支领先上游的提交数(仅本地有上游时存在)。 */
|
|
189
|
+
readonly ahead?: number
|
|
190
|
+
/** 本地分支落后上游的提交数(仅本地有上游时存在)。 */
|
|
191
|
+
readonly behind?: number
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type GitQueryResult =
|
|
195
|
+
| { readonly kind: 'history'; readonly commits: readonly GraphCommit[]; readonly total: number }
|
|
196
|
+
| { readonly kind: 'diff'; readonly path: string; readonly text: string }
|
|
197
|
+
| {
|
|
198
|
+
readonly kind: 'show'
|
|
199
|
+
readonly ref: string
|
|
200
|
+
readonly commit: GitCommit | null
|
|
201
|
+
/** 提交完整正文(不含 subject 行);IDEA 式右栏展示用。 */
|
|
202
|
+
readonly body: string
|
|
203
|
+
readonly stats: readonly GitFileStat[]
|
|
204
|
+
}
|
|
205
|
+
| { readonly kind: 'branches'; readonly current: string | null; readonly defaultBranch: string | null; readonly local: readonly GitBranch[]; readonly remote: readonly GitBranch[] }
|
|
206
|
+
| { readonly kind: 'tags'; readonly tags: readonly GitBranch[] }
|
|
207
|
+
| { readonly kind: 'authors'; readonly authors: readonly string[] }
|
|
208
|
+
|
|
209
|
+
export type GitQueryResponse =
|
|
210
|
+
| { readonly ok: true; readonly value: GitQueryResult }
|
|
211
|
+
| { readonly ok: false; readonly error: { readonly code: GitOperationErrorCode; readonly message?: string } }
|
|
212
|
+
|
|
213
|
+
/** Wire request of the `query` endpoint. */
|
|
214
|
+
export interface GitQueryRequest {
|
|
215
|
+
readonly sessionId: string
|
|
216
|
+
readonly query: GitQuery
|
|
217
|
+
}
|