@lukstei/dsh-client-review-git 0.0.0-stage → 0.2.2-rc.5.4

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/package.json CHANGED
@@ -1,6 +1,159 @@
1
1
  {
2
2
  "name": "@lukstei/dsh-client-review-git",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.2-rc.5.4",
4
+ "description": "Git diff and GitButler change view client plugin for DeepSeek Harness",
5
+ "type": "module",
6
+ "main": "./dist/host.js",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.ts",
11
+ "default": "./dist/host.js"
12
+ },
13
+ "./client": "./dist/client.js",
14
+ "./client-contract": {
15
+ "types": "./src/client/contract.ts"
16
+ },
17
+ "./typert": {
18
+ "types": "./lib/typert.host.d.ts",
19
+ "default": "./lib/typert.host.js"
20
+ },
21
+ "./remote": {
22
+ "types": "./lib/typert.remote-client.d.ts",
23
+ "default": "./lib/typert.remote-client.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "src",
29
+ "dist",
30
+ "lib/typert.host.js",
31
+ "lib/typert.host.d.ts",
32
+ "lib/typert.remote-client.js",
33
+ "lib/typert.remote-client.d.ts",
34
+ "lib/typert.remote-client.d.ts.map",
35
+ "README.md",
36
+ "cordis.patch.yml",
37
+ "!src/**/*.spec.*",
38
+ "!src/**/*.test.*",
39
+ "!src/**/*.stories.*",
40
+ "!src/**/stories",
41
+ "!src/**/*.e2e.*",
42
+ "!src/**/__snapshots__",
43
+ "!src/**/fixtures"
44
+ ],
45
+ "dsh": {
46
+ "bundle": {
47
+ "patch": "./cordis.patch.yml"
48
+ },
49
+ "client": {
50
+ "platform": "web",
51
+ "immediately": true,
52
+ "inject": [
53
+ "@deepseek-ai/dsh-client-ui-chat",
54
+ "@deepseek-ai/dsh-client-ui-conversation",
55
+ "@deepseek-ai/dsh-client-ui-slots",
56
+ "@deepseek-ai/dsh-client-ui-sidebar-right",
57
+ "@deepseek-ai/dsh-api-gateway"
58
+ ]
59
+ }
60
+ },
61
+ "dependencies": {
62
+ "@lukstei/util-review-ui": "0.2.2-rc.5.4",
63
+ "zod": "4.6.6"
64
+ },
65
+ "devDependencies": {
66
+ "@deepseek-ai/cordis": "4.1.0",
67
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.5",
68
+ "@deepseek-ai/dsh-api-gateway": "0.2.2-rc.5",
69
+ "@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.5",
70
+ "@deepseek-ai/dsh-api-workspace-files": "0.2.2-rc.5",
71
+ "@deepseek-ai/dsh-client-store": "0.2.2-rc.5",
72
+ "@deepseek-ai/dsh-client-ui-chat": "0.2.2-rc.5",
73
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.5",
74
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.5",
75
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.5",
76
+ "@deepseek-ai/dsh-client-ui-session": "0.2.2-rc.5",
77
+ "@deepseek-ai/dsh-client-ui-sidebar-documentpreview": "0.2.2-rc.5",
78
+ "@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.5",
79
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.5",
80
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.5",
81
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
82
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5",
83
+ "@deepseek-ai/dsh-session-persistence": "0.2.2-rc.5",
84
+ "@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-rc.5",
85
+ "@deepseek-ai/dsh-tool-present": "0.2.2-rc.5",
86
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.5",
87
+ "@deepseek-ai/dsh-typert-generator": "0.2.2-rc.5",
88
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
89
+ "@deepseek-ai/dsh-util-code-language": "0.2.2-rc.5",
90
+ "@deepseek-ai/dsh-util-workspace-path": "0.2.2-rc.5",
91
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.5",
92
+ "@ladle/react": "^5.1.1",
93
+ "@lukstei/dsh-client-split-view": "0.2.2-rc.5.4",
94
+ "@types/node": "^26.0.0",
95
+ "@types/react": "^19.3.0",
96
+ "@types/react-dom": "^19.3.0",
97
+ "@vitest/coverage-v8": "5.0.5",
98
+ "anser": "^2.3.5",
99
+ "happy-dom": "^21.0.4",
100
+ "immer": "^10.2.0",
101
+ "katex": "^0.16.47",
102
+ "lightningcss": "^1.33.0",
103
+ "mdast-util-math": "^3.0.0",
104
+ "micromark-extension-math": "^3.1.0",
105
+ "react": "^19.3.1",
106
+ "react-dom": "^19.3.1",
107
+ "simple-icons": "16.31.0",
108
+ "tsdown": "^0.23.0",
109
+ "typescript": "^7.0.2",
110
+ "typescript-transpile": "npm:typescript@6.0.3",
111
+ "vitest": "5.0.5",
112
+ "zustand": "^4.5.7"
113
+ },
114
+ "peerDependencies": {
115
+ "@deepseek-ai/cordis": "*",
116
+ "@deepseek-ai/dsh-agent": "*",
117
+ "@deepseek-ai/dsh-api-gateway": "*",
118
+ "@deepseek-ai/dsh-api-session-controller": "*",
119
+ "@deepseek-ai/dsh-client-ui-chat": "*",
120
+ "@deepseek-ai/dsh-client-ui-conversation": "*",
121
+ "@deepseek-ai/dsh-client-ui-primitives": "*",
122
+ "@deepseek-ai/dsh-client-ui-renderer": "*",
123
+ "@deepseek-ai/dsh-client-ui-sidebar-right": "*",
124
+ "@deepseek-ai/dsh-client-ui-slots": "*",
125
+ "@deepseek-ai/dsh-commands": "*",
126
+ "@deepseek-ai/dsh-session": "*",
127
+ "@deepseek-ai/dsh-session-persistence": "*",
128
+ "@deepseek-ai/dsh-tool-executor-ptc": "*",
129
+ "@deepseek-ai/dsh-tool-present": "*",
130
+ "@deepseek-ai/dsh-tools": "*",
131
+ "@deepseek-ai/dsh-typert-protocol": "*",
132
+ "@deepseek-ai/dsh-util-workspace-path": "*",
133
+ "@deepseek-ai/dsh-working-directory": "*",
134
+ "react": "*"
135
+ },
136
+ "license": "MIT",
137
+ "repository": {
138
+ "type": "git",
139
+ "url": "git+https://github.com/lukstei/dsh-plugins.git",
140
+ "directory": "packages/dsh-client-review-git"
141
+ },
142
+ "publishConfig": {
143
+ "access": "public"
144
+ },
145
+ "scripts": {
146
+ "gen:typert": "node scripts/gen-typert.ts",
147
+ "build": "pnpm --silent run gen:typert && tsdown --config tsdown.config.ts --logLevel error",
148
+ "dev": "pnpm run gen:typert && tsdown --config tsdown.config.ts --watch",
149
+ "check": "biome check --reporter=concise .",
150
+ "typecheck": "pnpm --silent run gen:typert && tsc --noEmit",
151
+ "test": "vitest run --reporter=minimal",
152
+ "test:integration": "vitest run --config vitest.integration.config.ts --reporter=minimal",
153
+ "test:watch": "vitest",
154
+ "test:update": "vitest run -u",
155
+ "verify": "pnpm --silent run check && pnpm --silent run build && pnpm --silent run typecheck && pnpm --silent run test && pnpm --silent run test:integration",
156
+ "ladle": "ladle serve",
157
+ "ladle:build": "ladle build"
158
+ }
6
159
  }
@@ -0,0 +1,162 @@
1
+ import type { InputActions } from "@deepseek-ai/dsh-client-ui-conversation/client";
2
+ import {
3
+ Button,
4
+ IconNewChatOutlineRegular,
5
+ Tooltip,
6
+ } from "@deepseek-ai/dsh-client-ui-primitives";
7
+ import type { TypertRemoteNamespace } from "@deepseek-ai/dsh-typert-protocol";
8
+ import {
9
+ CodeFileView,
10
+ type CodeQuotePayload,
11
+ } from "@lukstei/util-review-ui/client/CodeFileView.tsx";
12
+ import { createUnifiedDiff } from "@lukstei/util-review-ui/client/diff.ts";
13
+ import { FileList } from "@lukstei/util-review-ui/client/FileList.tsx";
14
+ import { FileReview } from "@lukstei/util-review-ui/client/FileReview.tsx";
15
+ import styles from "@lukstei/util-review-ui/client/GitDiffPane.module.css";
16
+ import { quoteToComposer } from "@lukstei/util-review-ui/client/quote.ts";
17
+ import { useLazyFile } from "@lukstei/util-review-ui/client/useLazyFile.ts";
18
+ import type { GitDiffView, GitFileDiff } from "@lukstei/util-review-ui/types";
19
+ import { type ReactNode, useCallback, useMemo } from "react";
20
+
21
+ export function FileInspector(props: {
22
+ view: GitDiffView;
23
+ revision: number;
24
+ api: TypertRemoteNamespace<"workspaceReview">;
25
+ sessionId: string;
26
+ inputActions?: Pick<
27
+ InputActions,
28
+ "insertQuote" | "insertText" | "captureInsertion" | "persistDraft"
29
+ >;
30
+ isExpanded?: (path: string) => boolean;
31
+ onToggleExpanded?: (path: string, expanded: boolean) => void;
32
+ initialScrollTop?: number;
33
+ onScroll?: (scrollTop: number) => void;
34
+ wrapped: boolean;
35
+ toggleWrap: () => void;
36
+ }): ReactNode {
37
+ const { wrapped, toggleWrap } = props;
38
+
39
+ const onQuote = useCallback(
40
+ (quote: CodeQuotePayload) => {
41
+ quoteToComposer(quote, props.inputActions);
42
+ },
43
+ [props.inputActions],
44
+ );
45
+
46
+ return (
47
+ <FileList
48
+ label="Changed file list"
49
+ files={props.view.diffs.map((file) => ({ kind: "diff", ...file }))}
50
+ isExpanded={props.isExpanded}
51
+ onToggleExpanded={props.onToggleExpanded}
52
+ initialScrollTop={props.initialScrollTop}
53
+ onScroll={props.onScroll}
54
+ renderFile={(file, heading, expanded, contentId) => {
55
+ if (file.kind !== "diff")
56
+ throw new Error("Git files require diff metadata");
57
+ return (
58
+ <GitFile
59
+ {...props}
60
+ file={file}
61
+ heading={heading}
62
+ contentId={contentId}
63
+ expanded={expanded}
64
+ wrapped={wrapped}
65
+ toggleWrap={toggleWrap}
66
+ onQuote={onQuote}
67
+ />
68
+ );
69
+ }}
70
+ />
71
+ );
72
+ }
73
+
74
+ function GitFile({
75
+ view,
76
+ revision,
77
+ api,
78
+ sessionId,
79
+ file,
80
+ heading,
81
+ contentId,
82
+ expanded,
83
+ wrapped,
84
+ toggleWrap,
85
+ onQuote,
86
+ }: Parameters<typeof FileInspector>[0] & {
87
+ file: GitFileDiff;
88
+ heading: ReactNode;
89
+ contentId: string;
90
+ expanded: boolean;
91
+ wrapped: boolean;
92
+ toggleWrap: () => void;
93
+ onQuote: (quote: CodeQuotePayload) => void;
94
+ }) {
95
+ const load = useCallback(
96
+ (signal: AbortSignal) => {
97
+ void revision;
98
+ return api.file(sessionId, view.snapshot, file.path, signal);
99
+ },
100
+ [api, sessionId, view.snapshot, file.path, revision],
101
+ );
102
+ const { result, retry } = useLazyFile(load, expanded);
103
+ const contents = result.value;
104
+
105
+ const patch = useMemo(() => {
106
+ if (contents === null || contents.kind !== "text") return null;
107
+ return createUnifiedDiff(file.path, contents.before, contents.after);
108
+ }, [contents, file.path]);
109
+
110
+ return (
111
+ <>
112
+ <FileReview
113
+ heading={heading}
114
+ expanded={expanded}
115
+ wrapped={wrapped}
116
+ toggleWrap={toggleWrap}
117
+ actions={
118
+ <Tooltip label="Quote diff to chat" portal>
119
+ <Button
120
+ size="sm"
121
+ variant="ghost"
122
+ aria-label={`Quote diff ${file.path}`}
123
+ onClick={() => {
124
+ if (patch !== null) {
125
+ onQuote({ text: patch, path: file.path });
126
+ } else {
127
+ onQuote({ text: file.path, path: file.path });
128
+ }
129
+ }}
130
+ icon={<IconNewChatOutlineRegular className={styles.icon} />}
131
+ />
132
+ </Tooltip>
133
+ }
134
+ />
135
+ <section
136
+ id={contentId}
137
+ className={styles.fileBody}
138
+ aria-label={`File diff ${file.path}`}
139
+ hidden={!expanded}
140
+ >
141
+ {expanded && (
142
+ <CodeFileView
143
+ path={file.path}
144
+ code={patch}
145
+ diff={true}
146
+ wrapped={wrapped}
147
+ result={result}
148
+ onRetry={retry}
149
+ onQuote={onQuote}
150
+ extra={
151
+ contents !== null && contents.kind === "unavailable" ? (
152
+ <p className={styles.note}>
153
+ {file.path}: {contents.message}
154
+ </p>
155
+ ) : null
156
+ }
157
+ />
158
+ )}
159
+ </section>
160
+ </>
161
+ );
162
+ }
@@ -0,0 +1,252 @@
1
+ import type { ScopeStandardProps } from "@deepseek-ai/dsh-client-ui-slots";
2
+ import type { TypertRemoteNamespace } from "@deepseek-ai/dsh-typert-protocol";
3
+ import styles, {
4
+ cssText,
5
+ } from "@lukstei/util-review-ui/client/GitDiffPane.module.css";
6
+ import type {
7
+ BranchReviewScope,
8
+ ReviewSelection,
9
+ } from "@lukstei/util-review-ui/types";
10
+ import {
11
+ type ReactNode,
12
+ useCallback,
13
+ useEffect,
14
+ useMemo,
15
+ useState,
16
+ } from "react";
17
+ import type {} from "../../lib/typert.remote-client.js";
18
+ import { FileInspector } from "./FileInspector.tsx";
19
+ import { ReviewToolbar } from "./ReviewToolbar.tsx";
20
+ import { resolveReviewBaseline } from "./reviewSelection.ts";
21
+ import { useLoad } from "./useLoad.ts";
22
+ import { useReviewViewState } from "./useReviewViewState.ts";
23
+
24
+ type Api = TypertRemoteNamespace<"workspaceReview">;
25
+
26
+ export function GitDiffPane(
27
+ props: Pick<ScopeStandardProps<"session">, "sessionId"> &
28
+ Partial<Pick<ScopeStandardProps<"session">, "inputActions">> & {
29
+ api: Api;
30
+ scope?: BranchReviewScope;
31
+ },
32
+ ): ReactNode {
33
+ return <ReviewPane key={props.sessionId} {...props} />;
34
+ }
35
+
36
+ function ReviewPane({
37
+ sessionId,
38
+ api,
39
+ inputActions,
40
+ scope: initialScope,
41
+ }: Parameters<typeof GitDiffPane>[0]) {
42
+ const [revision, setRevision] = useState(0);
43
+ const reviewState = useReviewViewState(sessionId, initialScope);
44
+ const {
45
+ selectedRepoCwd,
46
+ setSelectedRepoCwd,
47
+ scope,
48
+ setScope: select,
49
+ } = reviewState;
50
+
51
+ const load = useCallback(
52
+ (signal: AbortSignal) => {
53
+ // smell: loader identity carries refresh invalidation when request arguments stay unchanged.
54
+ void revision;
55
+ return api.catalog(sessionId, signal);
56
+ },
57
+ [api, sessionId, revision],
58
+ );
59
+ const catalogResult = useLoad(load);
60
+ const [previousCatalog, setPreviousCatalog] = useState<Extract<
61
+ typeof catalogResult,
62
+ { status: "ready" }
63
+ > | null>(null);
64
+ useEffect(() => {
65
+ if (catalogResult.status === "ready") setPreviousCatalog(catalogResult);
66
+ }, [catalogResult]);
67
+ const catalog =
68
+ catalogResult.status === "ready" || previousCatalog === null
69
+ ? catalogResult
70
+ : previousCatalog;
71
+ const activeRepository =
72
+ catalog.status === "ready" && catalog.value.kind === "git"
73
+ ? (catalog.value.repositories.find((r) => r.cwd === selectedRepoCwd) ??
74
+ catalog.value.repository)
75
+ : null;
76
+ const onSelectRepository = (cwd: string) => {
77
+ setSelectedRepoCwd(cwd);
78
+ if (scope !== null) {
79
+ select(null);
80
+ }
81
+ };
82
+ const base = resolveReviewBaseline(
83
+ scope,
84
+ catalog.status === "ready" ? catalog.value : null,
85
+ );
86
+ const selection = useMemo<ReviewSelection | null>(
87
+ () =>
88
+ scope === null || scope.kind !== "branch" ? scope : { ...scope, base },
89
+ [scope, base],
90
+ );
91
+ const refresh = () => setRevision((value) => value + 1);
92
+
93
+ return (
94
+ <div className={styles.root}>
95
+ <style>{cssText}</style>
96
+ <ReviewToolbar
97
+ catalog={catalog.status === "ready" ? catalog.value : null}
98
+ activeRepository={activeRepository}
99
+ onSelectRepository={onSelectRepository}
100
+ selection={scope}
101
+ base={base}
102
+ revision={revision}
103
+ select={select}
104
+ api={api}
105
+ sessionId={sessionId}
106
+ refresh={refresh}
107
+ />
108
+ <div className={styles.body}>
109
+ {catalogResult.status === "failed" && previousCatalog !== null && (
110
+ <p className={styles.error} role="alert">
111
+ {catalogResult.message}
112
+ </p>
113
+ )}
114
+ {catalog.status === "loading" ? (
115
+ <p className={styles.note} role="status">
116
+ Loading repository…
117
+ </p>
118
+ ) : catalog.status === "failed" ? (
119
+ <p className={styles.error} role="alert">
120
+ {catalog.message}
121
+ </p>
122
+ ) : catalog.value.kind === "unavailable" ? (
123
+ <p className={styles.note}>
124
+ Git unavailable: {catalog.value.message}.
125
+ </p>
126
+ ) : (
127
+ <>
128
+ {activeRepository !== null &&
129
+ activeRepository.gitbutlerError !== null && (
130
+ <p className={styles.note}>
131
+ GitButler metadata unavailable:{" "}
132
+ {activeRepository.gitbutlerError}
133
+ </p>
134
+ )}
135
+ {activeRepository !== null &&
136
+ activeRepository.branches.length === 0 && (
137
+ <p className={styles.note}>No branches found.</p>
138
+ )}
139
+ {selection === null ? (
140
+ <p className={styles.note}>Choose a review scope.</p>
141
+ ) : selection.kind === "branch" && selection.base === "" ? (
142
+ <p className={styles.note}>
143
+ Choose the repository's default branch to compare.
144
+ </p>
145
+ ) : (
146
+ <Comparison
147
+ key={JSON.stringify(selection)}
148
+ revision={revision}
149
+ api={api}
150
+ sessionId={sessionId}
151
+ selection={selection}
152
+ inputActions={inputActions}
153
+ isExpanded={reviewState.isPathExpanded}
154
+ onToggleExpanded={reviewState.setPathExpanded}
155
+ initialScrollTop={reviewState.scrollTop}
156
+ onScroll={reviewState.setScrollTop}
157
+ wrapped={reviewState.wrapped}
158
+ toggleWrap={reviewState.toggleWrapped}
159
+ />
160
+ )}
161
+ </>
162
+ )}
163
+ </div>
164
+ </div>
165
+ );
166
+ }
167
+
168
+ function Comparison({
169
+ revision,
170
+ api,
171
+ sessionId,
172
+ selection,
173
+ inputActions,
174
+ isExpanded,
175
+ onToggleExpanded,
176
+ initialScrollTop,
177
+ onScroll,
178
+ wrapped,
179
+ toggleWrap,
180
+ }: {
181
+ api: Api;
182
+ revision: number;
183
+ sessionId: string;
184
+ selection: ReviewSelection;
185
+ inputActions?: Parameters<typeof GitDiffPane>[0]["inputActions"];
186
+ isExpanded?: (path: string) => boolean;
187
+ onToggleExpanded?: (path: string, expanded: boolean) => void;
188
+ initialScrollTop?: number;
189
+ onScroll?: (scrollTop: number) => void;
190
+ wrapped: boolean;
191
+ toggleWrap: () => void;
192
+ }) {
193
+ const load = useCallback(
194
+ async (signal: AbortSignal) => {
195
+ const result = await api.view(sessionId, selection, signal);
196
+ return result.ok
197
+ ? { ok: true as const, value: { revision, result: result.value } }
198
+ : result;
199
+ },
200
+ [api, sessionId, selection, revision],
201
+ );
202
+ const current = useLoad(load);
203
+ const [previous, setPrevious] = useState<Extract<
204
+ typeof current,
205
+ { status: "ready" }
206
+ > | null>(null);
207
+ useEffect(() => {
208
+ if (current.status === "ready") setPrevious(current);
209
+ }, [current]);
210
+ const result =
211
+ current.status === "ready" || previous === null ? current : previous;
212
+ if (result.status === "loading")
213
+ return (
214
+ <p className={styles.note} role="status">
215
+ Loading diff…
216
+ </p>
217
+ );
218
+ if (result.status === "failed")
219
+ return (
220
+ <p className={styles.error} role="alert">
221
+ {result.message}
222
+ </p>
223
+ );
224
+ if (result.value.result.kind !== "diff")
225
+ throw new Error("Git scopes must produce a diff");
226
+ return (
227
+ <>
228
+ {current.status === "failed" && (
229
+ <p className={styles.error} role="alert">
230
+ {current.message}
231
+ </p>
232
+ )}
233
+ {result.value.result.view.diffs.length === 0 ? (
234
+ <p className={styles.note}>No file differences found.</p>
235
+ ) : (
236
+ <FileInspector
237
+ revision={result.value.revision}
238
+ view={result.value.result.view}
239
+ api={api}
240
+ sessionId={sessionId}
241
+ inputActions={inputActions}
242
+ isExpanded={isExpanded}
243
+ onToggleExpanded={onToggleExpanded}
244
+ initialScrollTop={initialScrollTop}
245
+ onScroll={onScroll}
246
+ wrapped={wrapped}
247
+ toggleWrap={toggleWrap}
248
+ />
249
+ )}
250
+ </>
251
+ );
252
+ }