Introduction¶
A DeepSeek Harness (DSH) workspace requires a local directory to exist first. To get started with a GitHub/GitLab repository, the standard workflow is: manually git clone → add the directory in Settings → create a new session. This plugin collapses that into a single step.
Plugin Overview¶
wuqiyang312/dsh-git-workspace is a DSH workflow plugin. Maintained by Wuqiyang312 and categorized under Workflow. The plugin lets you paste a Git URL to have the Host side clone the repository, register it as a workspace, and automatically enter a new session. It has no npm runtime dependency and is licensed under MIT.
Core Features¶
On the DSH “New Session” screen, click “Add Git Workspace” (located to the right of “Select Workspace”), paste the repository URL, and the clone and registration are handled automatically. The plugin parses branch information from the URL (/tree/<branch>, /blob/<ref>/<path>, GitLab’s /-/tree/<branch>), auto-fills the “Branch” and “Folder Name” fields, and allows manual editing.
Installation & Activation¶
DSH’s built-in plugin manager has a GUI and is recommended for use.
- Open the Plugins page in the left sidebar.
- Click Add Plugin in the upper-right corner.
- In the package name field, type
@wuqiyang312/dsh-git-workspace(with a version, e.g.@0.1.0), then press Enter or click Install.
- The same field also accepts a Git URL (https://github.com/Wuqiyang312/dsh-git-workspace) and an absolute path to a local directory. All three sources install the same plugin.
- If your connection is slow, expand Install Source and select “China Mirror”. - After installation, click Enable Now — installation only places the package into the profile; without this step the plugin remains disabled.
- Refresh the page (Ctrl+R) to reload the Client half. If the Host half prompts for a restart, restart the desktop app once more.
Once installed, go back to “New Session” and you’ll see Add Git Workspace appear to the right of “Select Workspace”.
Configuration¶
cordis.patch.yml provides the defaults. After installation, you can override them in the profile’s patch layer using id: git-workspace.
| Key | Default | Description |
|---|---|---|
cloneRoot |
'' |
Clone root directory. An empty string means auto-inference: <dirname(workingDirectory.defaultDirectory)>/repos. If non-empty, it must be an absolute path; relative paths are ignored with a warning logged. |
gitCommand |
'git' |
The git executable. Invoked via argv only; values containing whitespace are rejected. |
timeoutMs |
600000 |
Wall-clock upper limit for a single clone. On timeout, a stop is requested (on Windows via taskkill /T /F, falling back to child.kill('SIGKILL') if denied), and the process waits for exit confirmation; if exit isn’t confirmed within 5 seconds, it reports truthfully that “stop was requested, process may still be running”. Upper limit: 1 hour. |
maxOutputBytes |
65536 |
Byte limit for retaining the tail of git stdout/stderr. Error messages include this tail; excess is marked with … (output truncated). Upper limit: 4 MiB. |
shallow |
false |
Initial value of the shallow-clone toggle in the dialog. |
depth |
1 |
Depth for shallow clones. |
maxBodyBytes |
65536 |
Request body limit for POST /api/git-workspace/*; exceeding it returns 413. |
Configuration undergoes runtime validation at apply() time. Invalid values don’t cause the plugin to fail to load; instead, a [git-workspace] … warning is logged and the default value is used.
Supported Git URLs¶
| Form | Example |
|---|---|
| HTTPS | https://github.com/o/r, https://github.com/o/r.git |
| HTTPS with branch/file path | https://github.com/o/r/tree/dev, https://github.com/o/r/tree/main/firmware/esp32, https://github.com/o/r/blob/main/a/b.ts |
GitLab copy-link (/-/ separator) |
https://gitlab.com/group/sub/repo/-/tree/main, https://gitlab.com/group/sub/repo/-/blob/main/a.ts |
| SSH (URL) | ssh://git@example.com:2222/team/sub/repo.git |
| SSH (scp-style) | git@github.com:o/r.git |
file:// |
file:///C:/mirrors/repo.git (offline mirror) |
| Shorthand | o/r → https://github.com/o/r |
/tree/<ref> and /blob/<ref>/<path> only extract branch information: the workspace always points to the repository root; subdirectories are not used as workspace roots. If the branch name itself contains /, it is truncated to the first segment — in that case, enter the full name directly in the “Branch” field.
Host API¶
Prefix: /api/git-workspace, registered via ctx.connection.fetch.register (same-origin, subject to Connection’s Host/Origin and browser auth checks). It does not use the plugin’s own web server.
| Endpoint | Description |
|---|---|
GET /defaults (also accepts HEAD) |
{ ok: true, value: { parentDirectory, separator, platform, shallow, configured } }, performs mkdir -p as needed. |
POST /parse |
body { url } → { ok: true, value: parseGitUrl(url) }. |
POST /clone |
body { url, branch?, parentDirectory?, folderName?, depth?, shallow? } → on success { ok: true, value: { workspace: { workspaceId, path, title }, branch, folderName, clonedPath } }; on failure { ok: false, error: { code, message } }. |
All failures carry a stable code, localized by the frontend (error.<code>, with both en/zh locales complete):
git-workspace/invalid-url, unsafe-url, url-too-long, invalid-branch, invalid-folder-name, invalid-parent-directory, invalid-json, body-too-large, missing-url, target-exists, target-check-failed, clone-busy, clone-timeout, clone-failed, spawn-failed, move-failed, register-failed, no-workspace-registry, no-clone-root, clone-root-failed, network (frontend-only).
Security & Robustness¶
- No shell interpolation: only
spawn(gitCommand, argv)withshell: false; the URL and target path are each a single argv element, with--terminated option parsing. - The
gitprocess runs withGIT_TERMINAL_PROMPT=0,GIT_ASKPASS=echo,GCM_INTERACTIVE=never, andwindowsHide: true; no terminal is available, so credential prompts fail immediately rather than hanging. - Parameter injection surface: URLs must not start with
-, must not contain NUL, and must be ≤ 2048 characters; protocol whitelist ishttp/https/ssh/git/file; branch names must not start with-, contain whitespace, or ref metacharacters. Local bare paths (C:\x,/x,./x,~/x) are rejected — only an explicitfile://URL qualifies as a URL. - Target directory:
parentDirectorymust be an absolute path (auto-created);folderNamemust be a single path segment (no/or\, not./.., must not start with., must not be a Windows reserved name), with a secondary check thatpath.dirname(dest) === parent. - Target already exists → error. Never overwrites, never deletes.
- Staging + rename: the repository is first cloned to
.git-workspace-<uuid>under the parent directory; only after success is itrenamed to the target. On failure/timeout/move-failure, the staging directory is removed. A failed deletion is written intomessage(and a[git-workspace] staging cleanup failedwarning is logged), because the leftover directory is part of the outcome and cannot be confined to logs alone. - Timeout: upon expiry, a stop is first requested (on Windows via
taskkill /pid <pid> /T /F; if denied or if spawn fails, it falls back tochild.kill('SIGKILL')), then it waits for proof of exit (the child’sexit/closeevent), up to an additional 5 seconds. A stop is merely a “request”: in practice on Windows,taskkill /T /Fagainst child processes may exit with code 1 (Access denied) while the child process continues running, so the command’s exit code is observed and triggers the fallback signal. If exit is not observed, it does not claim the process has stopped — in that case the error message reads “A stop was requested … may still be running”, and it still attempts to remove the staging directory (a failed deletion is likewise written intomessage). Timeout durations are displayed in seconds with one decimal place (timeoutMs: 1200→within 1.2s; 60 seconds and above display as integers).
Typical Workflow¶
- Open DSH and navigate to “New Session”.
- Click “Add Git Workspace” to the right of “Select Workspace”.
- Paste the repository URL, e.g.
https://github.com/octocat/Spoon-Knife/tree/main. - The plugin automatically parses the branch
mainand pre-fills the “Branch” field; the folder name defaults to the repository name. - Click “Clone & Open”. The Host side executes
git clone, registers the repository as a workspace, and automatically switches to a new session for that repository.
Use Cases & Notes¶
Ideal for developers who need to quickly pull remote repositories and start a session in DSH. The plugin runs with the current dsh process permissions; the Host half does exactly three things: parse the URL, git clone, and register the workspace.
It is recommended to review the source code and license before installing. This package is open-source under the MIT license, with code publicly available on the GitHub repository.
Closing¶
This plugin compresses the three-step process of “clone repository + add workspace + create session” into a single step, making it well-suited for developers who frequently work across different Git repositories. Related documentation and source code are available on the directory page and GitHub.