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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host 端点契约:纯业务逻辑,零框架依赖。
|
|
3
|
+
*
|
|
4
|
+
* 将 `snapshotForSession` / `runAction` / `runQuery` 聚合为统一的
|
|
5
|
+
* `HostEndpoints` 接口——宿主适配层(Cordis/typert 或其他框架)只需调用
|
|
6
|
+
* `createHostEndpoints(deps, config)` 即可获得全部端点方法,再以任何
|
|
7
|
+
* RPC 机制暴露。业务层对此一无所知。
|
|
8
|
+
*/
|
|
9
|
+
import { type GitStatusConfig, type SnapshotDeps } from '../host/core.ts';
|
|
10
|
+
import type { GitActionRequest, GitActionResult, GitQueryRequest, GitQueryResponse, GitSnapshotRequest, GitSnapshotResult } from '../host/types.ts';
|
|
11
|
+
/**
|
|
12
|
+
* 业务端点集合:三个 RPC 方法的纯函数实现。
|
|
13
|
+
* 每个方法接收 wire 请求、可选取消信号,返回 wire 响应。
|
|
14
|
+
*/
|
|
15
|
+
export interface HostEndpoints {
|
|
16
|
+
snapshot(request: GitSnapshotRequest, signal?: AbortSignal): Promise<GitSnapshotResult>;
|
|
17
|
+
run(request: GitActionRequest, signal?: AbortSignal): Promise<GitActionResult>;
|
|
18
|
+
query(request: GitQueryRequest, signal?: AbortSignal): Promise<GitQueryResponse>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 构造业务端点实例。
|
|
22
|
+
*
|
|
23
|
+
* `deps` 携带全部宿主能力(子进程、会话查找、文件系统);`config` 携带
|
|
24
|
+
* 运行参数。两者均为结构化接口,与任何框架无关。返回的端点对象可直接
|
|
25
|
+
* 绑定到 RPC 装饰器、HTTP 路由、或测试桩。
|
|
26
|
+
*/
|
|
27
|
+
export declare function createHostEndpoints(deps: SnapshotDeps, config: GitStatusConfig): HostEndpoints;
|
package/lib/host/actions.d.ts
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import { type GitStatusConfig, type SnapshotDeps } from './core.ts';
|
|
2
|
-
import type { GitActionResult, GitActionRequest } from './types.ts';
|
|
1
|
+
import { resolveWorkspace, type GitStatusConfig, type SnapshotDeps } from './core.ts';
|
|
2
|
+
import type { GitAction, GitActionResult, GitActionRequest, GitOperationErrorCode } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A branch name is valid when it matches git's ref-name grammar at the level
|
|
5
|
+
* we care about: non-empty, ASCII ref chars only, no leading `-` (option
|
|
6
|
+
* injection guard, though argv never shells out), no `..` (path traversal of
|
|
7
|
+
* refs), no trailing `/`, and no double slashes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidBranchName(name: string): boolean;
|
|
3
10
|
/**
|
|
4
11
|
* A path is safe when it is repo-relative and stays inside the work tree:
|
|
5
12
|
* reject absolute paths, drive letters / backslashes, and `..` escapes
|
|
6
13
|
* (checked via path resolution against the realpath'd root).
|
|
7
14
|
*/
|
|
8
15
|
export declare function isSafePath(path: string, root: string): boolean;
|
|
16
|
+
/** Map a snapshot-flow failure (which may carry git-unavailable) onto the operation error shape. */
|
|
17
|
+
export declare function operationError(failure: Extract<Awaited<ReturnType<typeof resolveWorkspace>>, {
|
|
18
|
+
ok: false;
|
|
19
|
+
}>['error']): GitActionResult & {
|
|
20
|
+
ok: false;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 把 git 命令失败归类为可预期的业务错误(其余保持 git-error)。
|
|
24
|
+
* 切分支被工作区未提交变更阻止是最常见的可预期失败:git 输出
|
|
25
|
+
* "would be overwritten by checkout"(或中文本地化 "将被 checkout 覆盖"),
|
|
26
|
+
* 归一化为 local-changes-block,client 据此给友好提示 + 处理变更引导。
|
|
27
|
+
*/
|
|
28
|
+
export declare function classifyOperationError(kind: GitAction['kind'], message: string): GitOperationErrorCode;
|
|
9
29
|
/**
|
|
10
30
|
* Execute one management action against the session's repository and return
|
|
11
31
|
* the refreshed snapshot on success (the caller re-renders from it, so the
|
package/lib/host/core.d.ts
CHANGED
|
@@ -71,7 +71,13 @@ export declare function resolveWorkspace(deps: SnapshotDeps, sessionId: string):
|
|
|
71
71
|
* 1. `git rev-parse --show-toplevel` — repo detection (exit 128 → not-a-git-repo)
|
|
72
72
|
* 2. `git branch --show-current` — null when detached
|
|
73
73
|
* 3. `git rev-parse --short HEAD` — null + unborn when the repo has no commits
|
|
74
|
-
* 4. `git status --porcelain=v1 -z --branch`
|
|
74
|
+
* 4. `git status --porcelain=v1 -z --branch --untracked-files=all`
|
|
75
75
|
* 5. `git log -n 5 --format=%H%x1f%h%x1f%s%x1f%an%x1f%aI`
|
|
76
|
+
*
|
|
77
|
+
* --untracked-files=all:git 默认 normal 模式会把整目录未跟踪折叠为单条
|
|
78
|
+
* `?? dir/`(尾斜杠)且不枚举其内部文件——隐藏目录(.agent/.tianqi 等)的
|
|
79
|
+
* 变更因此从不进入变更清单。`all` 强制逐文件枚举(与 IDEA / VSCode 一致),
|
|
80
|
+
* 内部文件得以展示;maxChanges 截断列表、maxStatusBytes spill 保计数精确,
|
|
81
|
+
* 超大未跟踪树(如未 gitignore 的构建产物)经此路径优雅降级。
|
|
76
82
|
*/
|
|
77
83
|
export declare function snapshotForSession(deps: SnapshotDeps, config: GitStatusConfig, sessionId: string): Promise<GitSnapshotResult>;
|
package/lib/host/index.d.ts
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-git-ui host
|
|
2
|
+
* dsh-git-ui host 适配层:Cordis/typert 壳。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* 本文件是 host 端**唯一** import `@deepseek-ai/*` 的地方。职责:
|
|
5
|
+
* 1. 将 Cordis 服务(subprocess / sessions / sessionPersistence)适配为
|
|
6
|
+
* 结构化 `SnapshotDeps` 接口;
|
|
7
|
+
* 2. 调用 `createHostEndpoints(deps, config)` 获得纯业务端点;
|
|
8
|
+
* 3. 以 `@Remote` 装饰器将端点暴露给 typert Gateway。
|
|
9
|
+
*
|
|
10
|
+
* 业务逻辑全部在 `contracts/host-endpoints.ts` → `host/core.ts` /
|
|
11
|
+
* `host/actions.ts` / `host/queries.ts`,与框架无关。
|
|
10
12
|
*/
|
|
11
13
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
12
14
|
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
-
import type { GitActionResult,
|
|
14
|
-
export type { GitSnapshot, GitSnapshotResult, GitSnapshotFailure, GitSnapshotRequest, GitCommit, GitChange, GitAction, GitActionResult, GitActionRequest } from './types.ts';
|
|
15
|
+
import type { GitActionRequest, GitActionResult, GitQueryRequest, GitQueryResponse, GitSnapshotRequest, GitSnapshotResult } from './types.ts';
|
|
16
|
+
export type { GitSnapshot, GitSnapshotResult, GitSnapshotFailure, GitSnapshotRequest, GitCommit, GitChange, GitAction, GitActionResult, GitActionRequest, GitQuery, GitQueryResult, GitQueryRequest, GitQueryResponse, GitBranch, GitFileStat, GitRef } from './types.ts';
|
|
15
17
|
export { normalizeConfig, DEFAULT_CONFIG } from './core.ts';
|
|
16
|
-
export { parseStatusOutput, parseLogOutput, parseBranchOutput } from './parser.ts';
|
|
17
|
-
export { isSafePath, runAction } from './actions.ts';
|
|
18
|
-
|
|
18
|
+
export { parseStatusOutput, parseLogOutput, parseBranchOutput, parseNameStatusOutput } from './parser.ts';
|
|
19
|
+
export { isSafePath, isValidBranchName, runAction } from './actions.ts';
|
|
20
|
+
export { runQuery } from './queries.ts';
|
|
21
|
+
export { createHostEndpoints, type HostEndpoints } from '../contracts/host-endpoints.ts';
|
|
22
|
+
/**
|
|
23
|
+
* gitInfo Remote 服务:Cordis 壳。
|
|
24
|
+
*
|
|
25
|
+
* 构造时从 Cordis Context 取出宿主服务,适配为 `SnapshotDeps`,再调用
|
|
26
|
+
* `createHostEndpoints` 获得纯业务端点。三个 `@Remote` 方法仅做委托。
|
|
27
|
+
*/
|
|
19
28
|
export declare class GitStatusService extends TypertRemoteService {
|
|
20
29
|
static inject: string[];
|
|
21
|
-
private readonly
|
|
30
|
+
private readonly endpoints;
|
|
22
31
|
constructor(ctx: Context, config: unknown);
|
|
23
|
-
/**
|
|
24
|
-
private
|
|
32
|
+
/** 将 Cordis 服务适配为结构化 SnapshotDeps。 */
|
|
33
|
+
private buildDeps;
|
|
25
34
|
snapshot(request: GitSnapshotRequest, signal?: AbortSignal): Promise<GitSnapshotResult>;
|
|
26
35
|
run(request: GitActionRequest, signal?: AbortSignal): Promise<GitActionResult>;
|
|
36
|
+
query(request: GitQueryRequest, signal?: AbortSignal): Promise<GitQueryResponse>;
|
|
27
37
|
}
|
|
28
38
|
export default GitStatusService;
|