跪拜 Guibai
← All articles
Frontend

Building a full Git panel inside an AI chat: a DeepSeek Harness plugin

By 叫个啥呢 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

For developers living inside AI chat tools, this shows a practical pattern for extending DSH without leaving the conversation context, and it documents the exact host/client split and security guardrails that make such plugins viable.

Summary

DeepSeek Harness (DSH) now has a plugin that puts a full Git panel inside the AI conversation UI. @wagq/dsh-git adds a Git icon to the session title bar; clicking it opens a three-tab modal with staged changes, a commit graph with swim lanes, and a terminal rooted at the repo. The developer wrote it after finding existing options not to their taste, and the project doubles as a reference for how DSH plugins actually work.

DSH plugins split into a host side (Node.js, runs in DSH's process) and a client side (React, injected into the browser). They communicate over a local HTTP API. The host registers routes under /wagq-git, using execFile with argument arrays for all git operations, never shell strings, and sets a 64MB maxBuffer to handle large repos. Security checks block DNS rebinding and cross-site POSTs, and realpath validation keeps file APIs inside the repo.

The client injects a button into the conversation slot, resolves the working directory from sessionId, and renders the panel. A standout feature: a "Generate commit message" button sends the staged diff to the same model the current session uses, with a 12,000-character patch limit, and falls back to the deployment's default model. The author also documents pitfalls, like needing the package name rather than a local path in the Cordis patch, and system messages being a top-level option rather than part of the messages array.

Takeaways
— DSH plugins are dual-ended: a Node.js host side and a browser React client side, communicating over a local HTTP API.
— UI injection happens via slots.inject, targeting a conversation title bar utilities slot.
— All git commands run through execFile with argument arrays, never shell string concatenation, to avoid escaping bugs from filenames and branches.
— The environment sets GIT_TERMINAL_PROMPT=0, GIT_OPTIONAL_LOCKS=0, GIT_PAGER=cat, and core.quotepath=false to handle non-interactive and non-ASCII paths.
— maxBuffer is raised to 64MB because git log --all in large repos can output multiple MB.
— Commit graph lanes are not compressed; each branch keeps its column across the window to prevent horizontal jumps.
— Host routes are prefixed with /wagq-git and check loopback origin and Origin/Sec-Fetch-Site for state-changing POSTs.
— File APIs realpath and verify the result stays within the repo root to block .. traversal.
— The client uses git diff --no-index for untracked files to get the same hunk shape, and truncates patches over 600,000 characters to avoid freezing the browser.
— AI commit messages use the current session's model, falling back to the deployment default; only the diff is sent, capped at 12,000 characters.
— The system prompt must be passed as a top-level option, not inside messages, or the model produces no output.
— The Cordis bundle patch requires the package name, not a local path, for DSH to resolve the plugin.
Conclusions

The dual-host/client architecture with local HTTP is a clean separation: host side owns the file system and git, client side owns the DOM, and security is enforced at the HTTP boundary.

Reusing the current conversation's model for commit message generation ties tool behavior to the user's style, a small touch that makes the feature feel native to the chat context.

The commit graph lane compression avoidance is a deliberate UX choice; most graph renderers collapse lanes, but stable columns reduce visual jumps when scrolling through long histories.

The author's decision to write local context types instead of augmenting Cordis types keeps the plugin compile-clean but sacrifices some type safety at the boundary.

The plugin only transmits diffs, not full files, which is both a performance and a privacy decision; 12,000 characters is a tight limit but keeps generation fast.

Concepts & terms
DeepSeek Harness (DSH)
An AI conversation tool where users interact with models; it supports plugins that extend the UI and backend capabilities through a dual host/client architecture.
slots.inject
DSH's mechanism for injecting UI components into reserved 'slots' in the conversation interface, similar to VSCode contribution points but for a web-based chat UI.
Cordis patch
A YAML configuration file (cordis.patch.yml) that inserts a host module into DSH's dependency injection container; the `name` field must be the package name, not a path.
Swim lane layout
In a commit graph, each branch gets a vertical column (lane); the algorithm assigns the first free lane and does not compress lanes, so branch lines stay stable horizontally.
From the discussion
Featured comments
组合搭配函数

Splitting host and client into two halves is a sound approach; the plugin's structure becomes clear right away. And only sending the diff rather than the full text for commit messages is considerate.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗