@xbzbing/dsh-git-panel 1.2.0 → 1.4.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 +9 -2
- package/README_EN.md +9 -2
- package/lib/client.js +164 -15
- package/lib/host/actions.d.ts +19 -0
- package/lib/host/core.d.ts +24 -1
- package/lib/host/index.d.ts +10 -4
- package/lib/host/index.js +393 -27
- package/lib/host/llm-face.d.ts +27 -0
- package/lib/host/parser.d.ts +9 -1
- package/lib/host/suggest.d.ts +4 -0
- package/lib/host/types.d.ts +95 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,11 +26,17 @@ dsh plugin --profile web add github:xbzbing/dsh-git-panel
|
|
|
26
26
|
|
|
27
27
|
- **Git 总览**:三栏布局。左栏是分支 / 标签列表,点击某个引用即按它过滤历史;中栏是提交历史图,支持按提交信息、commit 哈希、作者、日期搜索,悬停某条提交弹出卡片显示完整提交信息(comment);右栏是选中提交的变更文件树与提交信息,点击文件在弹出的 modal 里查看该文件在此提交中的差异。
|
|
28
28
|
- **变更记录**:面向本地工作区。左栏是统计条(文件数 / 增删行数 / 最近变更时间)、带复选框的未提交变更列表、以及含 **Amend** 复选框的提交框,支持逐文件暂存 / 取消暂存 / 丢弃与手动提交;右栏是选中文件的差异对照。
|
|
29
|
+
- **AI 生成提交信息**:提交框旁的「AI 生成」按钮根据当前未提交变更(勾选了文件则只看这些文件)与最近一次提交的风格,调用你在 DSH 中配置的模型生成提交信息,填入提交框后可编辑再提交;没有可生成的变更、模型服务不可用或生成失败都会给出明确提示。**隐私提示:生成请求会把 diff 内容发送给你在 DSH 中所配置模型的供应商。** 可在插件详情页关闭该按钮。
|
|
30
|
+
- **标签管理**:在「Git 总览」右栏的提交详情顶部可为选中的提交创建标签(轻量标签,或带说明的附注标签);该提交上已有的标签以可删除的标签片呈现,删除走二次确认。创建与删除标签都只作用于本地仓库,不会推送到远程,如需同步需自行 `git push <remote> <tagname>`(或 `--tags`)。
|
|
31
|
+
- **提交回撤**:同一处提交操作区可「还原此提交」(revert,追加一个反向提交、不动工作区)或「重置到此」(reset,软 / 混合 / 硬三挡)。硬重置会列出将被永久丢弃的未提交改动并要求额外勾选确认,始终不作为默认方式;检测到未提交改动时提示这些改动可能是 dsh AI 正在进行的工作。还原与重置都只改写本地仓库,不会推送到远程,远端分支需你自行推送同步。
|
|
32
|
+
- **贮藏(stash)**:「变更记录」页可将当前未提交更改贮藏起来(可填说明),下方的贮藏列表支持应用 / 弹出 / 丢弃;弹出或应用遇到冲突时保留贮藏条目并提示,不会半途丢失。丢弃走二次确认。
|
|
33
|
+
- **共享工作区护栏**:标签 / 贮藏 / 还原 / 重置等写操作与 dsh 的 AI 共用同一仓库,弹窗底部统一提示「可直接让 AI 执行 Git 操作」;撞上 `.git/index.lock`(另一进程正在操作)会自动重试一次并给出「Git 正忙」提示而非原始报错。
|
|
29
34
|
- **文件浏览**:直接打开工作区「Git」标签时,非 Git 目录默认进入文件浏览;Git 仓库中无未提交变更则进入「Git 总览」,有未提交变更则进入「变更记录」。非 Git 目录也能浏览,以当前工作目录为根。左栏目录树按需加载(点开才读取下一层,不显示 `.git`),按文件类型显示 dsh 官方图标,被 `.gitignore` 忽略的条目半透明呈现,宽度可拖动;右栏可预览代码、文本和图片,顶部可复制文件相对路径,过大文件或其他二进制文件显示提示。Markdown 默认显示源码,可点击「渲染」切换到 dsh 自带的 Markdown 视图;HTML 默认显示源码,可点击「渲染」在隔离沙箱(`allow-scripts`、无同源权限)中预览页面,不会自动执行。大文件的源码视图按行虚拟化(只渲染视口内的行),超大文件关闭语法高亮、超长行截断,保证流畅。
|
|
30
35
|
- **代码内查找**:文件浏览的源码视图与差异对照都支持 <kbd>Ctrl</kbd>/<kbd>⌘</kbd>+<kbd>F</kbd> 就地查找——高亮全部命中并保留语法着色,显示「当前 / 总数」,<kbd>Enter</kbd> / <kbd>Shift</kbd>+<kbd>Enter</kbd> 或 `‹` `›` 在命中间跳转,可切换区分大小写(默认不敏感),<kbd>Esc</kbd> 关闭。命中统计覆盖整份内容,视口外的命中同样计入并可跳转。
|
|
31
36
|
- **语法高亮差异**:总览弹窗、变更记录和文件浏览共用 dsh 官方语法高亮,按文件扩展名选择语言,语法资源按需加载;差异视图的改动词级强调保留原有交互。
|
|
32
37
|
- **对照模式**:差异支持「统一 / 对照 / 变更前 / 变更后」四种视图切换。统一视图为单栏行内对比(改动行前后紧邻,省横向空间),对照视图为左右并排;两种视图都带块间隐藏上下文的按需展开与改动行的词级高亮。默认视图可在插件详情页选择(统一 / 并排),也可在每个差异视图工具栏临时切换。
|
|
33
|
-
-
|
|
38
|
+
- **移动端 / 窄面板自适应**:面板宽度收窄到 620px 及以下(手机竖屏,或右侧栏挤压面板)时自动切换为单栏「钻取」布局——三栏折叠为一栏,列表与详情 / 差异 / 预览之间点击进入、带「返回」按钮退出;Git 总览的分支筛选改为从底部升起的面板(bottom sheet),提交行改为两行式更易点按,顶栏控件换行到第二行而非隐藏,差异对比在窄屏隐藏「对照」(并排)模式。面板变宽后自动恢复三栏布局,桌面体验不变。触控设备(如平板)上逐文件操作按钮常驻显示、点按区域放大。
|
|
39
|
+
- **显示输入框标记开关**:插件详情页可切换输入框标记;关闭后输入框不再显示分支标记,改为在「Git」标签旁显示状态圆点(绿=已同步、橙色=有变更),两者互斥,保存后立即生效。同一处配置区还可设置差异对比的默认视图(统一 / 并排)、提交历史图的线条样式(平行线 VSCode 风格 / 紧凑 git log 风格,默认平行线)以及是否在提交框显示「AI 生成」按钮。
|
|
34
40
|
- **输入框 Git 标记**:一个 zsh 主题风格的 `<仓库名> (<分支>)` 标记,仓库名青色,`(分支)` 在已同步时为绿色、有未提交变更时为橙色;悬停显示完整仓库路径,点击跳转面板(有未提交变更进入变更记录,否则进入 Git 总览);非 Git 目录不显示输入框标记,可通过工作区的「Git」标签进入文件浏览。
|
|
35
41
|
- UI 跟随 DSH 系统语言设置,支持简体中文和英文。
|
|
36
42
|
|
|
@@ -46,7 +52,7 @@ dsh plugin --profile web add github:xbzbing/dsh-git-panel
|
|
|
46
52
|
|
|
47
53
|
插件分 host / client 两半,通过 typert Remote 网关通信。
|
|
48
54
|
|
|
49
|
-
- **Host**(`lib/host/`):`gitPanel` 命名空间上的 Cordis + typert `GitPanelService`,暴露 `snapshot` / `run` / `query` / `version`
|
|
55
|
+
- **Host**(`lib/host/`):`gitPanel` 命名空间上的 Cordis + typert `GitPanelService`,暴露 `snapshot` / `run` / `query` / `suggest` / `version` 五个端点,仅做端点委托与生命周期接线;git 命令经宿主 `subprocess` 服务执行(argv 数组、无 shell、cwd 锁仓库根、超时 + 输出上限);`suggest` 端点经宿主 `llm` 服务用你已配置的模型一次性生成提交信息。
|
|
50
56
|
- **Client**(`lib/client.js`):一个 React 包,注册 `conversation.view` 面板和 `conversation.input.left` 标记。每会话一个快照控制器(轮询 + turn 完成后刷新 + 连接重置重拉),标记、变更记录页和统计条共用同一份快照,避免重复 git 命令。
|
|
51
57
|
|
|
52
58
|
## 开发
|
|
@@ -72,6 +78,7 @@ src/
|
|
|
72
78
|
core.ts workspace 解析 + snapshotForSession
|
|
73
79
|
actions.ts GitAction → git 命令序列(commit / amend / stage 等)
|
|
74
80
|
queries.ts history / diff / file-lines / image-diff / dir-list / file-content / show / branches / tags / worktree-stats
|
|
81
|
+
suggest.ts AI 生成提交信息(diff 收集 + ctx.llm 一次性调用)
|
|
75
82
|
parser.ts git 输出解析为结构化数据
|
|
76
83
|
version.ts 本包版本 + GitHub release 更新检查
|
|
77
84
|
client/
|
package/README_EN.md
CHANGED
|
@@ -26,11 +26,17 @@ After installing or updating, restart the `dsh web` service and refresh the page
|
|
|
26
26
|
|
|
27
27
|
- **Overview** — three columns. The left column is the branch / tag list; clicking a ref filters history by it. The middle column is the commit history graph, searchable by commit message, commit hash, author, or date; hovering a commit shows a card with its full commit message (comment). The right column is the selected commit's changed-file tree and commit message; click a file to see its diff within that commit in a modal.
|
|
28
28
|
- **Changes** — the local working tree. The left column has a statistics bar (file count / added·deleted lines / last-change time), the uncommitted change list with per-file checkboxes, and a commit box with an **Amend** checkbox; per-file stage / unstage / discard and manual commit are supported. The right column is the selected file's diff.
|
|
29
|
+
- **AI commit-message suggestion** — the "AI suggest" button beside the commit box writes a commit message from the current uncommitted changes (restricted to your checked files when any are selected) in the style of the latest commit, using the model you have configured in DSH; the result lands in the commit box for you to edit before committing. No changes to summarize, a missing model service, and generation failures all report a clear message. **Privacy note: the generation request sends your diff content to the provider of the model you configured in DSH.** The button can be turned off on the plugin detail page.
|
|
30
|
+
- **Tag management** — the commit-detail header in the Overview right column creates a tag at the selected commit (lightweight, or annotated with a message); tags already on that commit show as deletable chips, and deletion asks for confirmation. Creating and deleting tags only affects the local repository and is never pushed to the remote; run `git push <remote> <tagname>` (or `--tags`) yourself to sync.
|
|
31
|
+
- **Stash** — the Changes page stashes the current uncommitted changes (with an optional message); the stash list below supports apply / pop / drop. A pop or apply that conflicts keeps the stash entry and reports it, so nothing is lost halfway. Drop asks for confirmation.
|
|
32
|
+
- **Commit undo** — the same commit-action area can "Revert this commit" (appends a reverse commit, leaving the work tree untouched) or "Reset to here" (reset in soft / mixed / hard modes). Hard reset lists the uncommitted changes it will permanently discard and requires an extra acknowledgement; it is never the default, and whenever uncommitted changes are present a note warns they may be work the dsh AI is doing. Both revert and reset only rewrite the local repository and are never pushed to the remote; sync the remote branch yourself.
|
|
33
|
+
- **Shared-worktree guards** — tag / stash / revert / reset and other write actions share the repository with the dsh AI, so every dialog footer suggests letting the AI run Git for you; a `.git/index.lock` clash (another process is working) retries once and surfaces a friendly "Git is busy" message instead of the raw error.
|
|
29
34
|
- **File browser** — opening the workspace Git tab selects Files outside a Git repository, Overview in a clean repository, or Changes when there are uncommitted changes. Non-Git directories use the current directory as the browse root. The resizable tree loads one directory at a time and hides `.git`, shows dsh's official type icons per file, and dims entries excluded by `.gitignore`; the preview shows code/text or images, with a button to copy the file's relative path and placeholders for oversized or binary files. Markdown defaults to source; choose Rendered to use dsh's built-in Markdown view. HTML also defaults to source; choose Rendered to preview the page inside a locked-down sandbox (`allow-scripts`, no same-origin) — it never auto-runs. The source view is row-virtualized for large files (only the visible rows render); very large files disable highlighting and over-long lines are truncated, keeping it responsive.
|
|
30
35
|
- **In-code find** — the file source preview and the diff views support <kbd>Ctrl</kbd>/<kbd>⌘</kbd>+<kbd>F</kbd> to find in place: every match is highlighted preserving syntax colors, with an active/total count, <kbd>Enter</kbd> / <kbd>Shift</kbd>+<kbd>Enter</kbd> or `‹` `›` to walk matches, a case-sensitivity toggle (insensitive by default), and <kbd>Esc</kbd> to close. Match counting scans the whole content, so matches outside the viewport are counted and reachable too.
|
|
31
36
|
- **Syntax-highlighted diffs** — the overview modal, changes page, and file browser share dsh's built-in highlighter. Languages are selected by file extension and grammars load on demand; word-level change emphasis remains available in the diff views.
|
|
32
37
|
- **Diff modes** — unified / split / before / after views. Unified is a single inline column (each change shown as adjacent `-`/`+` lines, saving horizontal space); split is side-by-side. Both carry on-demand expansion of hidden between-hunk context and word-level emphasis on changed lines. The default view is selectable on the plugin detail page (unified / split) and can be switched per diff from the toolbar.
|
|
33
|
-
- **
|
|
38
|
+
- **Mobile / narrow-panel layout** — at 620px wide or below (a phone in portrait, or a sidebar squeezing the panel) the UI switches to a single-column drill-in: the three columns collapse to one, and you tap from a list into its detail / diff / preview and come back with a Back button. The Overview branch filter becomes a bottom sheet, commit rows go two-line for easier tapping, the tab-bar controls wrap onto a second row instead of hiding, and the side-by-side diff mode is dropped on narrow screens. Widening the panel restores the three-column layout, so the desktop experience is unchanged. On touch devices (e.g. tablets) the per-file row actions stay visible and hit targets grow.
|
|
39
|
+
- **Show input-bar marker toggle** — the plugin detail page can toggle the input-bar marker; when off, the input bar stays clean and the Git tab shows a status dot instead (green = synced, orange = dirty). The two are mutually exclusive and changes apply immediately. The same config section also sets the default diff view (unified / split), the commit-graph line style (parallel VSCode style / compact git-log style, parallel by default), and whether the commit box shows the "AI suggest" button.
|
|
34
40
|
- **Input-bar Git marker** — a zsh-theme `<repo> (<branch>)` marker: the repo name is cyan, `(branch)` is green when in sync and orange when there are uncommitted changes; hover shows the full repository path, and clicking jumps to the panel (to Changes when dirty, otherwise to Overview); in non-Git directories the input-bar marker is hidden, while the workspace Git tab still opens the file browser.
|
|
35
41
|
- The UI follows the DSH system language, in Simplified Chinese and English.
|
|
36
42
|
|
|
@@ -46,7 +52,7 @@ After installing or updating, restart the `dsh web` service and refresh the page
|
|
|
46
52
|
|
|
47
53
|
Two halves communicating over the typert Remote gateway.
|
|
48
54
|
|
|
49
|
-
- **Host** (`lib/host/`) — a Cordis + typert `GitPanelService` on the `gitPanel` namespace, exposing `snapshot` / `run` / `query` / `version` and doing only endpoint delegation and lifecycle wiring; git runs through the host `subprocess` service (argv arrays, no shell, cwd locked to the repository root, timeout + output caps).
|
|
55
|
+
- **Host** (`lib/host/`) — a Cordis + typert `GitPanelService` on the `gitPanel` namespace, exposing `snapshot` / `run` / `query` / `suggest` / `version` and doing only endpoint delegation and lifecycle wiring; git runs through the host `subprocess` service (argv arrays, no shell, cwd locked to the repository root, timeout + output caps); the `suggest` endpoint makes a one-shot commit-message call through the host `llm` service with your configured model.
|
|
50
56
|
- **Client** (`lib/client.js`) — a React bundle that registers the `conversation.view` panel and the `conversation.input.left` marker. One snapshot controller per session (polling + a refresh after each turn + a reload on connection reset) feeds the marker, the changes page, and the stats bar from a single snapshot, avoiding duplicate git commands.
|
|
51
57
|
|
|
52
58
|
## Development
|
|
@@ -72,6 +78,7 @@ src/
|
|
|
72
78
|
core.ts workspace resolution + snapshotForSession
|
|
73
79
|
actions.ts GitAction → git command sequences (commit / amend / stage …)
|
|
74
80
|
queries.ts history / diff / file-lines / image-diff / dir-list / file-content / show / branches / tags / worktree-stats
|
|
81
|
+
suggest.ts AI commit-message suggestion (diff collection + one ctx.llm call)
|
|
75
82
|
parser.ts git output parsed into structured data
|
|
76
83
|
version.ts package version + GitHub release update check
|
|
77
84
|
client/
|