Repository navigation
Detect the official DeepSeek Harness dsh.cmd launcher on Windows - #17
Conversation
The CLI installer writes dsh.cmd, but discovery only looked for dsh.exe. Normalize the official batch shim into the executable, argument prefix and environment the launcher declares, keeping the argument-array spawn sites unchanged. The parser accepts only the official layout, binds the Electron entry to the owning installation, checks both files on disk, and leaves other shims to the node_modules fallback.
|
Mention Blocks like a regular teammate with your question or request: @blocks review this pull request Run |
There was a problem hiding this comment.
🟡 Changes recommended
A critical issue in runtime/commands.ts routes extensionless Linux PATH executables into the Windows batch-shim branch, skipping installed harnesses and potentially resolving tools such as gh to null.
1 open issue
What changed in this PR
This PR adds detection of the official Windows DeepSeek Harness launcher, converting it into an executable command compatible with MemCode’s existing shell-free worker spawning.
Changes:
- Parse and validate
dsh.cmd, returning the executable, arguments, environment, and approval identity. - Add Windows
.cmddiscovery while preserving same-directory.exeprecedence and PATH ordering. - Add 11 Windows tests covering launcher parsing, validation, fallback behavior, and precedence.
| File | Description |
|---|---|
tests/windows-command-discovery.test.ts |
Adds Windows launcher discovery and validation tests. |
runtime/commands.ts |
Normalizes official DSH shims and extends command discovery. |
Review effort: Balanced
Shim normalization ran for every extension other than .exe. On Linux the extension list is [""], so each PATH executable entered that branch and was skipped unless a node_modules fallback existed; git, gh and shell lookups could return null. Normalize only .cmd files so native executables reach the direct return.
|
Follow-up on the extension-normalization comment: fixed in 98fa754.
Added Verification on 98fa754: |
There was a problem hiding this comment.
🟡 Changes recommended
Saved harness entries inside app.asar fail the configured-path existence check when a later GUI launch lacks the installer directory in PATH, making an approved, still-installed harness unavailable.
1 open issue
1 resolved since last review
Review effort: Balanced
A GUI launch without the installer's launcher directory on PATH could not reuse an approved dsh runtime: its saved identity points inside app.asar, which ordinary filesystem access cannot read. Reconstruct the Electron command from the owning executable and archive before the configured-path existence check, sharing the validation used for the .cmd shim. Reject non-canonical paths so an identity cannot traverse into another installation.
|
Follow-up to the saved-runtime comment: fixed in 3b78207.
Added regressions for rediscovery without the launcher directory, missing executable/archive, another harness, a normal configured executable, and |
…setup branch The Desktop CLI helper installs the official dsh.cmd launcher on Windows; without syncable-dev#17's shim normalization the installed CLI stays undiscoverable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Promotes MemCode 0.4.0-beta.21 from dev: shared projects, private worker conversations on shared projects, deleting a project from the project switcher, the WebKit Browser tab on Mac, and DeepSeek Harness setup fixes. Integrates PRs #17 to #22. The tree is dev at b5c2158 plus the Windows test fixes in PR #22. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

What problem does this solve?
On Windows, the official DeepSeek Harness CLI installer writes a
dsh.cmdbatch launcher (resources/runtime/cli/bin/dsh.cmd) and puts that directory at the front of the user's PATH. MemCode'sfindCommand()only looked for<PATH dir>\dsh.exe, so a correctly installed CLI was reported as "Not installed" in the worker/harness list.There is a second constraint: the worker session code spawns harness commands with
spawn(..., { shell: false })(runtime/agents/standard-acp.ts). Windows cannot launch a.cmd/.batfile directly throughCreateProcess, so simply adding.cmdto the discovery candidates would turn a detection bug into a spawn failure.This PR teaches discovery to recognise the official launcher and normalise it into the same
{ command, prefix, env, identity }shape already used by the existingnode_modulesfallback. No spawn call site changes.What changed
runtime/commands.tsNew
WINDOWS_DSH_SHIMregex. A single anchored expression matches the whole launcher line:Both paths must be quoted,
%~dp0is expanded relative to the shim, an optional\right after%~dp0is accepted, and no unexpanded%VAR%is allowed. Lines that merely mention--expose-internals(rem,echo,@rem, etc.) cannot shadow the real line: the code now scans for the first line that fully matches, not the first line containing the flag.New
windowsShimCommand()helper. It resolves the executable and Electron entry from the shim, then applies four guards before accepting it:DeepSeek Harness.exe;<install dir>\resources\app.asar\;app.asarfile exists on disk.The name +
app.asarchecks bind the entry to the installation that owns the executable. Without them, a modified shim could point at a different.exewhile keeping the same entry path — and becauseworkerApprovalMatches()comparesruntimeIdentitywhen present, a previously saved approval would still match. With them, a different executable or a different installation produces a different identity and requires a fresh approval.The file checks prevent a leftover shim from an incomplete uninstall from being displayed as "Installed", and let discovery fall through to the working
node_modulesfallback in the same directory.Returned
Commandobject. The helper returns:prefixis prepended before transport arguments by every spawn site andenvis applied on top ofchildEnv(), so the existing argument-array spawning is preserved. An explicitidentityis needed becausecommandIdentity()would otherwise read--expose-internalsasprefix[0].Discovery extensions. On Windows,
dshis tried as.exeand then.cmd;.batis not used. Other harness names keep the previous.exe-only probing, so there is no extraaccess()call for them..exestill wins inside a directory; between directories, normal PATH order wins. That matchescmd.exeresolution and the installer, which prepends its own directory. Invalid shims fall through to the existingnode_modules/@deepseek-ai/dsh/lib/bin.jscheck.tests/windows-command-discovery.test.ts(new, 11 tests)dsh.exein the same directory wins overdsh.cmd;.cmdis ignored, never handed toshell: false;remline containing the flag cannot spoof the launcher;echoline mentioning the flag cannot shadow the real line;resources\app.asaris rejected;app.asaris missing is ignored;node_modulesfallback;process.env.PATHis restored witht.after()andnode --testruns each file in its own process.Verification
Run locally on Windows, at commit
cd86870:The 7 failing tests are pre-existing environment/timing failures also present on the base commit (
context-preparationslow-helper timeouts,fleettiming, and twoterminalscases that hitEACCESonWindowsApps\pwsh.exe). A clean worktree at the same base commit failed 7 tests too; no new failure was introduced. Tests that varied between runs passed when executed in isolation twice.Real launcher check. With PATH pointing only at
...\DeepSeek Harness\resources\runtime\cli\bin,findCommand("dsh")resolved:Argument-array spawn proof. The exact shape MemCode uses was exercised manually:
Result:
status: 0, stdout0.2.2-rc.5. This is the check the Tauri smoke cannot isolate, because this machine also has a localdsh.exeshim earlier in PATH.The Tauri smoke passed and listed DeepSeek Harness as available, but it detected the CLI through that local
dsh.exe, so it is not used as evidence for the.cmdpath.Review history
Two adversarial review rounds were run against the patch. Round 1 found one high issue (approval inheritance through an arbitrary exe), plus missing file checks, an over-permissive parser, a precedence ambiguity,
.batsurface and weak tests — all addressed here. Round 2 returned APPROVE with three low findings; those are also addressed (dedicated regression tests for the three guards, first-full-match parsing, and removal of a tautological assertion).Notes for reviewers / release notes
dsh.exein a later PATH directory will need to approve again once the official installer puts itsdsh.cmddirectory first, because the provider identity changes. This is the intended consequence of following PATH order; the alternate behaviour (prefer any.exein the whole PATH) was considered and rejected.node_modules, not break spawning.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.