@xbzbing/dsh-git-panel 0.1.0 → 0.2.0
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 +7 -5
- package/README_EN.md +7 -5
- package/cordis.patch.yml +1 -1
- package/lib/client.js +37 -27
- package/lib/host/actions.d.ts +2 -3
- package/lib/host/core.d.ts +20 -1
- package/lib/host/git.d.ts +2 -0
- package/lib/host/index.js +319 -139
- package/lib/host/parser.d.ts +8 -1
- package/lib/host/types.d.ts +24 -4
- package/lib/host/validate.d.ts +10 -0
- package/lib/host/version.d.ts +6 -4
- package/package.json +4 -3
package/lib/host/parser.d.ts
CHANGED
|
@@ -19,7 +19,14 @@ export declare function parseGraphLog(stdout: string): GraphCommit[];
|
|
|
19
19
|
export declare function parseRefs(decoration: string): GitRef[];
|
|
20
20
|
/** Parse `git for-each-ref` local/remote branch lines: `name\0shortHash\0track`. */
|
|
21
21
|
export declare function parseBranches(stdout: string): GitBranch[];
|
|
22
|
-
/** Parse `git
|
|
22
|
+
/** Parse `git for-each-ref` tag lines: `name\0shortHash` per line. */
|
|
23
|
+
export declare function parseTags(stdout: string): GitBranch[];
|
|
24
|
+
/**
|
|
25
|
+
* Parse `git show --name-status -z` into stats with an explicit state machine:
|
|
26
|
+
* read a status token, then consume exactly the paths it owns (2 for R/C, 1
|
|
27
|
+
* otherwise). A malformed token stops the scan rather than silently shifting
|
|
28
|
+
* every later field, so one bad entry can't corrupt the whole list.
|
|
29
|
+
*/
|
|
23
30
|
export declare function parseNameStatus(stdout: string): GitFileStat[];
|
|
24
31
|
/** Sum `git diff --numstat` output: { insertions, deletions }. Binary rows ("-") skipped. */
|
|
25
32
|
export declare function sumNumstat(stdout: string): {
|
package/lib/host/types.d.ts
CHANGED
|
@@ -15,9 +15,6 @@ export type GitSnapshotResult = {
|
|
|
15
15
|
readonly error: GitFailure;
|
|
16
16
|
};
|
|
17
17
|
export type GitFailure = {
|
|
18
|
-
readonly code: 'session-not-found';
|
|
19
|
-
readonly sessionId: string;
|
|
20
|
-
} | {
|
|
21
18
|
readonly code: 'cwd-unavailable';
|
|
22
19
|
readonly sessionId: string;
|
|
23
20
|
} | {
|
|
@@ -29,6 +26,8 @@ export type GitFailure = {
|
|
|
29
26
|
readonly detail: string;
|
|
30
27
|
} | {
|
|
31
28
|
readonly code: 'timeout';
|
|
29
|
+
} | {
|
|
30
|
+
readonly code: 'cancelled';
|
|
32
31
|
};
|
|
33
32
|
/** Immutable snapshot of one repository's status at `checkedAt`. */
|
|
34
33
|
export interface GitSnapshot {
|
|
@@ -49,6 +48,8 @@ export interface GitSnapshot {
|
|
|
49
48
|
readonly behind: number;
|
|
50
49
|
readonly lastCommit: GitCommit | null;
|
|
51
50
|
readonly changes: readonly GitChange[];
|
|
51
|
+
/** Working-tree statistics for the changes-page header (single source). */
|
|
52
|
+
readonly stats: WorktreeStats;
|
|
52
53
|
/** True when the change list was capped at maxChanges. */
|
|
53
54
|
readonly truncated: boolean;
|
|
54
55
|
/** Polling interval the client should use after this snapshot (0 = off). */
|
|
@@ -114,7 +115,7 @@ export type GitAction = {
|
|
|
114
115
|
} | {
|
|
115
116
|
readonly kind: 'fetch';
|
|
116
117
|
};
|
|
117
|
-
export type GitErrorCode = '
|
|
118
|
+
export type GitErrorCode = 'cwd-unavailable' | 'not-a-git-repo' | 'git-unavailable' | 'invalid-path' | 'invalid-name' | 'git-error' | 'timeout' | 'cancelled' | 'empty-message' | 'local-changes-block';
|
|
118
119
|
export type GitActionResult = {
|
|
119
120
|
readonly ok: true;
|
|
120
121
|
readonly snapshot: GitSnapshot;
|
|
@@ -153,6 +154,19 @@ export type GitQuery = {
|
|
|
153
154
|
readonly base: 'commit';
|
|
154
155
|
readonly commit: string;
|
|
155
156
|
readonly context?: number;
|
|
157
|
+
} | {
|
|
158
|
+
readonly kind: 'file-lines';
|
|
159
|
+
readonly path: string;
|
|
160
|
+
readonly base: 'worktree' | 'staged';
|
|
161
|
+
readonly start: number;
|
|
162
|
+
readonly end: number;
|
|
163
|
+
} | {
|
|
164
|
+
readonly kind: 'file-lines';
|
|
165
|
+
readonly path: string;
|
|
166
|
+
readonly base: 'commit';
|
|
167
|
+
readonly commit: string;
|
|
168
|
+
readonly start: number;
|
|
169
|
+
readonly end: number;
|
|
156
170
|
} | {
|
|
157
171
|
readonly kind: 'image-diff';
|
|
158
172
|
readonly path: string;
|
|
@@ -211,6 +225,12 @@ export type GitQueryResult = {
|
|
|
211
225
|
readonly kind: 'diff';
|
|
212
226
|
readonly path: string;
|
|
213
227
|
readonly text: string;
|
|
228
|
+
} | {
|
|
229
|
+
readonly kind: 'file-lines';
|
|
230
|
+
readonly path: string;
|
|
231
|
+
readonly start: number;
|
|
232
|
+
readonly lines: readonly string[];
|
|
233
|
+
readonly eof: boolean;
|
|
214
234
|
} | {
|
|
215
235
|
/**
|
|
216
236
|
* Old/new images for a binary image diff, as data URLs. The sides mirror
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A repository-relative path is safe when it stays inside the work tree. */
|
|
2
|
+
export declare function isSafePath(path: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* A ref (branch / tag / commit-ish) is safe as a bare argv element: no leading
|
|
5
|
+
* `-` (would be parsed as a git option — the `--output=` file-write vector),
|
|
6
|
+
* no whitespace/control chars, no glob or rev-range metacharacters.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSafeRev(input: string): boolean;
|
|
9
|
+
/** A branch name for `git checkout`: the ref rules plus no leading slash. */
|
|
10
|
+
export declare function isSafeBranchName(name: string): boolean;
|
package/lib/host/version.d.ts
CHANGED
|
@@ -21,9 +21,10 @@ export declare function parseRepository(repository: unknown): {
|
|
|
21
21
|
repo: string;
|
|
22
22
|
} | undefined;
|
|
23
23
|
/**
|
|
24
|
-
* Compare dotted
|
|
25
|
-
* when a
|
|
26
|
-
*
|
|
24
|
+
* Compare dotted versions with prerelease handling; returns 1 when a > b, -1
|
|
25
|
+
* when a < b, 0 when equal. A release outranks a prerelease sharing the same
|
|
26
|
+
* core (0.2.0 > 0.2.0-beta.1); prerelease identifiers compare dot-segment by
|
|
27
|
+
* segment, numeric parts numerically (beta.2 > beta.1, 0.2.0-rc.10 > rc.2).
|
|
27
28
|
*/
|
|
28
29
|
export declare function compareVersions(a: string, b: string): number;
|
|
29
30
|
/** Local-only view: current version + repository URL, no network access. */
|
|
@@ -32,7 +33,8 @@ export declare function readVersionInfo(options?: {
|
|
|
32
33
|
}): Promise<VersionInfo>;
|
|
33
34
|
/**
|
|
34
35
|
* Query the GitHub releases API for the latest tag and compare it to the
|
|
35
|
-
* bundled version. Failures are reported through `error` instead of throwing
|
|
36
|
+
* bundled version. Failures are reported through `error` instead of throwing;
|
|
37
|
+
* a 5s timeout bounds the call and a 10-minute memo bounds the request rate.
|
|
36
38
|
*/
|
|
37
39
|
export declare function checkLatestVersion(options?: {
|
|
38
40
|
manifestPath?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbzbing/dsh-git-panel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "DeepSeek Harness (dsh) plugin: an IDE-style Git panel in the Web GUI — branch/history overview, uncommitted changes with commit & amend, diff stats, and a zsh-style branch marker in the input bar.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"test:unit": "node build.mjs && node --test --test-force-exit test/unit/*.test.mjs",
|
|
45
45
|
"test:e2e": "node build.mjs && node test/e2e/setup.mjs && node test/e2e/run.mjs && node test/e2e/run2.mjs",
|
|
46
46
|
"test": "npm run test:unit && npm run test:e2e",
|
|
47
|
-
"check": "npm run typecheck && npm run test"
|
|
47
|
+
"check": "npm run typecheck && npm run test && git diff --exit-code -- lib/",
|
|
48
|
+
"prepare": "node build.mjs"
|
|
48
49
|
},
|
|
49
50
|
"dsh": {
|
|
50
51
|
"bundle": {
|
|
@@ -88,4 +89,4 @@
|
|
|
88
89
|
"react-dom": "18.3.1",
|
|
89
90
|
"typescript": "5.7.3"
|
|
90
91
|
}
|
|
91
|
-
}
|
|
92
|
+
}
|