You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix DeepSeek Harness profile discovery, Desktop setup, and grouped model picker - #18
Fixes why MemCode's DeepSeek Harness (dsh) model picker only exposed 3 base models and adds guided setup and Desktop provider sync across Windows and macOS (target dev):
Preserve grouped ACP catalogs and full JSON.stringify provider IDs (runtime/agents/acp-models.ts, runtime/agents/standard-acp.ts, src/components/ModelSelect.tsx, src/components/Select.tsx)
Avoids flattening grouped ACP configOptions into an ungrouped list, preserving provider group headings in the Worker Assignment model picker.
Keeps structured ["provider", "model"] IDs intact so all provider models advertised by dsh ACP sessions can be selected and labeled cleanly.
Inspects $DSH_HOME/profiles/* for @deepseek-ai/dsh-acp-app / @deepseek-ai/dsh-acp (excluding conflicting non-ACP @deepseek-ai/dsh-web-app bundles, desktop, node_modules, and memcode-dryrun-* staging dirs).
Auto-selects a customized ACP profile when settings.dshProfile is unset, forwards --profile <name> across discovery, connection probes, worker launches, and read-only reviews, and guides users with non-ACP profiles through creating or switching to an ACP profile.
Guided CLI installation for Desktop-only users (runtime/dsh-desktop.ts, runtime/commands.ts, runtime/mac-commands.ts, src/components/DshSetupFlow.tsx)
Detects installed DeepSeek Harness Desktop apps (findDesktopApp("dsh")) when no dsh CLI is available yet, inspects the bundled command-manager.js helper via its bundled Node runtime, and installs/registers the CLI using the helper's fingerprint check (with Windows user PATH refresh and non-elevated macOS EACCES/EPERM guidance pointing to Manage dsh Command… in DeepSeek Harness Desktop).
Compares Desktop llm-pi-ai providers (cordis.patch.yml) and @deepseek-ai/dsh-llmregisterAdapter plugins against the active ACP profile, skipping inline API secrets and unsafe YAML tags and leaving link: local plugins unchecked by default.
Displays a tick/untick provider checklist, dry-runs checked providers first in an isolated memcode-dryrun-* staging profile with strictStdout validation, isolates failing providers with Retry without broken providers, and applies verified changes with snapshot rollback.
Complementary to open #17 (fix-dsh-cmd-discovery — Windows dsh.cmd launcher discovery, currently approved by 1 of 2 approvers and awaiting final approval). Rather than duplicating #17's launcher-normalization diff here, this branch will be rebased cleanly onto dev once #17 lands.
Validation
Branch: magalz:fix/deepseek-integration-and-setup at commit 44c1752998dc3636a5d4b95dbdf976e8812b6e06 (no GitHub Actions dispatched).
Local Windows checks (after final edit on 44c1752998dc3636a5d4b95dbdf976e8812b6e06)
Full npm test: 1186/1188 passed, 2 failed (both pre-existing Windows Store App Execution Alias EACCES: permission denied, stat '...\Microsoft\WindowsApps\pwsh.exe' in tests/terminals.test.ts; 0 skipped)
npm run build: passed (exit 0)
Live end-to-end UI/runtime verification (browser preview against built dist/ + runtime/app.ts Tauri shim on Windows, run at 5853e83 prior to Copilot hardening):
Real Windows dsh setup (CLI + Desktop llm-pi-ai + registry plugins + local link: plugin): switched to a custom ACP profile, kept the Local link plugin unchecked, ran live dry-run + import (65 verified models across 6 provider groups in the Worker Assignment model picker).
Fixture runs verified: non-ACP profiles only -> guided ACP creation & sync; broken plugin stdout pollution caught by isolated dry-run + Retry without broken providers; Desktop-only user (no CLI on PATH) -> Install dsh CLI -> ACP creation -> sync; custom ACP profile auto-detected when settings.dshProfile is unset.
Native Windows Tauri smoke (npm run test:smoke against a temporary Podman cargo-xwinx86_64-pc-windows-msvc debug memcode.exe build, run at 5853e83, src-tauri/ unchanged):
Stopped at scripts/tauri-smoke.mjs:291 (preview:action"capture"): returned Bring MemCode to the foreground before capturing its visible preview (src-tauri/src/native.rsGetForegroundWindow() != hwnd) because the background-spawned smoke process (windowsHide: true) did not hold Win32 foreground focus in the interactive session.
Checkout 44c1752998dc3636a5d4b95dbdf976e8812b6e06, install dependencies cleanly (npm ci), and run npm run typecheck && npm test && npm run build && npm run test:smoke.
Test Desktop-only setup on macOS: ensure DeepSeek Harness.app is installed in /Applications and remove /usr/local/bin/dsh (and any dsh on PATH), open MemCode -> Workers, confirm Desktop app installed, click Install dsh CLI, and verify Contents/Resources/runtime/cli/command-manager.js either installs cleanly or, on EACCES/EPERM for /usr/local/bin/dsh, directs the user to Manage dsh Command… in DeepSeek Harness Desktop without osascript elevation prompts.
Test custom ACP profile discovery & sync: create/use a non-default ACP profile under ~/.dsh/profiles/<custom>, verify auto-detection / switching, import Desktop providers via the dry-run checklist, and confirm grouped provider models appear in Worker Assignment -> Model.
User impact
Existing dsh approvals and saved workspace settings remain intact (settings.dshProfile is optional; users without it automatically get their customized ACP profile).
Desktop-to-ACP provider sync is strictly opt-in, dry-runs in a temporary profile before modifying the target profile, excludes inline API secrets and unsafe YAML tags, and leaves link: local plugins unchecked by default.
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.
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.
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.
Mention Blocks like a regular teammate with your question or request:
@blocks review this pull request @blocks make the following changes ... @blocks create an issue from what was mentioned in the following comment ... @blocks explain the following code ... @blocks are there any security or performance concerns?
Follow-up on Copilot's review: 17 of 18 findings have been fixed in commit 44c1752 (44c1752998dc3636a5d4b95dbdf976e8812b6e06), and the remaining Windows .cmd discovery item points to open #17.
Resolved in 44c1752
High severity
Block overlapping setup mutations and worker launches (runtime/app.ts, runtime/workers.ts) — Added withDshSetupLock / dshSetupInFlight serialization across dsh:install-cli, dsh:create-profile, dsh:select-profile, dsh:dry-run-migrate, dsh:apply-migrate, and settings:save, and blocked dsh worker starts (including resolved auto-routed dsh starts before spawn) until active setup settles.
Preserve or reject tagged expressions in target patches (runtime/dsh-migration.ts) — Switched target patch writes to strict parsing (readPatchStrict) and abort before modifying anything when cordis.patch.yml contains !!js expressions.
Mark owned staging directories and reserve their names (runtime/dsh-migration.ts, runtime/dsh-profiles.ts, runtime/agents/standard-acp.ts) — Staged directories write .memcode-dryrun, stale cleanup deletes only marked directories, and normalizeDshProfile() rejects memcode-dryrun-* names (scoped allowStaging: true only for internal dry-run probes).
Abort migration when existing snapshots cannot be read (runtime/dsh-migration.ts) — Records null only on ENOENT; aborts cleanly before mutation on any other snapshot read error.
Report incomplete rollback and retain recovery backups (runtime/dsh-migration.ts) — Collects every restore/cleanup failure, persists recovery snapshots under $DSH_HOME/memcode-recovery/, and returns an explicit error with the recovery backup path.
Exclude providers containing credentials and authorization headers (runtime/dsh-yaml.ts) — Expanded hasInlineSecret() to match Authorization, cookie, credentials?, arrays/nested objects, and Bearer / Basic values.
Parse quoted-key colons in YAML flow mappings (runtime/dsh-yaml.ts) — Updated findUnquotedColon() (allowTightQuotedColon) for JSON-style flow mappings ({"id":"ui-theme","config":{"fontSize":14}}) and reject malformed flow entries cleanly.
Propagate tagged-scalar flags through flow collections (runtime/dsh-yaml.ts) — Preserves taggedJs || scalar.taggedJs when returning flow scalars so flow-embedded !!js is detected by hasJsTag().
Require a successful combined dry run before applying providers (src/components/DshSetupFlow.tsx, runtime/dsh-migration.ts) — Gates apply on dryRun.ok && dryRun.failed.length === 0 and surfaces combination-level errors (dryRun.error) instead of proceeding when failed is empty.
Medium severity
11. Reject empty model catalogs during strict validation (runtime/agents/cursor.ts) — Rejects models.length === 0 under strictStdout: true.
12. Refresh Windows user PATH before checking for the CLI (runtime/app.ts) — dshSetupStatus and connection:refresh-catalog refresh HKCU user PATH via refreshWindowsUserPath() when dsh is not found in inherited PATH.
13. Skip catalog probes for profiles classified as non-ACP (runtime/catalog.ts) — Skips launching dsh catalog probes during discovery when activeProfileIssue === "non-acp" (or "missing" for a non-default profile).
14. Validate the baseline profile before testing providers (runtime/dsh-migration.ts) — On combined dry-run failure, validates runStaging([]) first and returns a single profile:<name> failure instead of blaming every selected provider.
15. Clear refreshed models when the profile or catalog changes (src/components/WorkerAssignment.tsx) — Updated useEffect dependencies to [task.harness, dshRuntime?.activeProfile, currentHarness?.models].
16. Keep connection-failure guidance and retry controls visible (src/components/WorkerConnections.tsx) — Suppressed the fallback section only while !dshReady so failed connection probes still show selected.note and Check again.
17. Default fixture layout to the host platform (tests/dsh-desktop.test.ts) — Defaults options.mac to process.platform === "darwin" so Windows/macOS test layouts match the host platform when omitted.
Full npm test: 1186/1188 passed, 2 failed (both pre-existing Windows Store App Execution Alias EACCES: permission denied, stat '...\Microsoft\WindowsApps\pwsh.exe' in tests/terminals.test.ts; 0 skipped)
Strict mode detects JSON parse failures but accepts logs such as {"message":"starting"}, which incoming() ignores without emitting an error. A stdout-polluting provider can therefore pass the strict dry-run without producing a clean ACP stream. Validate each parsed line as an ACP/JSON-RPC message before dispatching it in strict mode.
Resolve relative plugin specs against the Desktop profile
runtime/dsh-migration.ts:185
Relative link: and file: specs are copied verbatim from Desktop into another profile, so link:./plugins/provider resolves to a different directory or fails. The CLI runs plugin commands inside the selected profile directory (upstream default branch at 4b399c3). Resolve local specs against the Desktop profile before using them in staging or the target, preserving already-absolute paths.
Validate all selected IDs against fresh candidates
runtime/dsh-migration.ts:496
Only plugin IDs are validated, so stale pi-ai selections and unknown ID prefixes are silently skipped yet returned in passedIds or appliedIds. This can happen when Desktop removes a provider or adds an inline secret after the checklist loads. Validate every selected ID against the fresh candidate list before installing plugins or writing the patch.
Stage the target dependency tree before probing
runtime/dsh-migration.ts:605
Staging copies manifests and patches but not the target's installed dependencies, so a pi-ai-only import can fail to load existing third-party bundles from a healthy customized profile. DSH resolves bundles through the installation and selected profile (upstream default branch at 4b399c3). Reproduce the target's dependency tree in independent staging storage before probing, without sharing writable files with the target.
Do not attribute combined-probe failures to the last plugin
runtime/dsh-migration.ts:751
A post-apply probe failure is attributed to the last installed plugin, although the probe validates the combined profile rather than that provider alone. The UI then unchecks that provider and offers “Retry without broken providers” without evidence it caused the failure. Reset attribution to a profile: ID before the combined probe, and use that default before installation begins.
Flag a non-ACP default profile directory
runtime/dsh-profiles.ts:209
When settings.dshProfile is unset and an existing directory named acp is non-ACP, this fallback selects it without activeProfileIssue. Catalog discovery and connection checks then launch the incompatible profile instead of showing setup guidance. Preserve the default directory's non-ACP classification in this fallback.
Refresh or clear model overrides when the draft profile changes
src/components/Dialogs.tsx:910
Changing the draft profile leaves the model picker on the saved profile's catalog and retains its override, so Settings can save a model the new profile does not offer. Profile switches from Workers also retain that override (runtime/app.ts:971), causing later dsh tasks to fail model selection. Load the draft profile's catalog or require saving first, and clear or revalidate dsh overrides whenever profiles change.
Avoid claiming the profile is unchanged after apply failure
src/components/DshSetupFlow.tsx:640
Apply failures are stored in dryRunResult too, including failures where rollback could not restore all files. This heading then says the profile was not modified even though recovery may be required. Use a neutral failure heading, or distinguish the operation and rollback outcome before promising an unchanged profile.
Show comparison failure instead of an empty diff
src/components/DshSetupFlow.tsx:697
When loadDiff() fails, it sets diff to null, which falls through to this “already present” message. A failed comparison does not establish that Desktop providers are synchronized. Render an unavailable-comparison state with a retry instead of treating null as a successful empty diff.
Focus the Close button while setup controls are loading
src/components/WorkerConnections.tsx:145
When the dsh dialog opens, setup initially renders only a spinner and hides the approval input, so the focus query can find nothing. The effect does not rerun when setup finishes loading, leaving keyboard focus behind the modal. Fall back to the always-rendered Close button when no preferred setup control exists.
…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>
…mport
Migration
- Apply runs only the plan a successful dry-run verified. The plan is bound
to the Desktop sources, the home patch and the target files; any change
in between refuses the import before the profile is touched.
- The unchanged profile is probed first. Each selected pi-ai provider must
then list its models and each plugin must add a new provider, in staging
and again after apply, instead of "some catalog came back".
- A home cordis.patch.yml that sets llm-pi-ai replaces every profile's
providers (dsh composes it last); such imports are refused with a reason.
- Staging installs the target's own dependency tree before probing.
- Rollback restores pnpm-workspace.yaml too, reinstalls the restored
lockfile after `plugin add`, and reports whether it completed.
- Stale or unknown selected ids are refused; relative link:/file: specs are
resolved against the Desktop profile; probe failures after install are
attributed to the profile, not the last plugin.
- Providers under an explicitly !!js-tagged entry/config/providers container
are refused while untagged siblings stay importable.
YAML
- Decode every YAML double-quoted escape and reject unknown ones; escape
non-printable characters on output.
- Keep line breaks around more-indented lines in folded scalars.
- Resolve plain scalars and keys like dsh's core schema and quote any string
that would load back as another type; refuse forms (timestamps, underscore
numbers, malformed quotes) that cannot round-trip.
- Credential detection uses the key's head noun (privateKey, x-api-key,
password: 123456) without flagging maxTokens or apiKeyEnv.
Runtime and UI
- One gate coordinates setup with dsh workers, reviewers and goal planners
in both directions; shutdown waits for a running import.
- Strict probes reject JSON lines that are not JSON-RPC messages.
- Profile scans skip names dsh cannot be given; a non-ACP "acp" directory
is flagged; probeStandardCatalog rejects instead of throwing.
- Profile changes drop dsh model overrides the new catalog does not offer;
Settings stops offering the old profile's models for a new draft profile.
- Setup shows a failed Desktop comparison with Retry, a neutral or
recovery heading after a failed import, and focuses Close while loading.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Fixes why MemCode's DeepSeek Harness (
dsh) model picker only exposed 3 base models and adds guided setup and Desktop provider sync across Windows and macOS (targetdev):Preserve grouped ACP catalogs and full
JSON.stringifyprovider IDs (runtime/agents/acp-models.ts,runtime/agents/standard-acp.ts,src/components/ModelSelect.tsx,src/components/Select.tsx)configOptionsinto an ungrouped list, preserving provider group headings in the Worker Assignment model picker.["provider", "model"]IDs intact so all provider models advertised bydshACP sessions can be selected and labeled cleanly.Detect arbitrary ACP profiles without hardcoding
"acp"(runtime/dsh-profiles.ts,runtime/agents/standard-acp.ts,runtime/worker-connections.ts,runtime/workers.ts,runtime/review-agent.ts,runtime/catalog.ts)$DSH_HOME/profiles/*for@deepseek-ai/dsh-acp-app/@deepseek-ai/dsh-acp(excluding conflicting non-ACP@deepseek-ai/dsh-web-appbundles,desktop,node_modules, andmemcode-dryrun-*staging dirs).settings.dshProfileis unset, forwards--profile <name>across discovery, connection probes, worker launches, and read-only reviews, and guides users with non-ACP profiles through creating or switching to an ACP profile.Guided CLI installation for Desktop-only users (
runtime/dsh-desktop.ts,runtime/commands.ts,runtime/mac-commands.ts,src/components/DshSetupFlow.tsx)DeepSeek HarnessDesktop apps (findDesktopApp("dsh")) when nodshCLI is available yet, inspects the bundledcommand-manager.jshelper via its bundled Node runtime, and installs/registers the CLI using the helper's fingerprint check (with Windows userPATHrefresh and non-elevated macOSEACCES/EPERMguidance pointing toManage dsh Command…in DeepSeek Harness Desktop).Opt-in Desktop provider sync with isolated dry-run & rollback (
runtime/dsh-migration.ts,runtime/dsh-yaml.ts,src/components/DshSetupFlow.tsx,src/components/WorkerConnections.tsx)llm-pi-aiproviders (cordis.patch.yml) and@deepseek-ai/dsh-llmregisterAdapterplugins against the active ACP profile, skipping inline API secrets and unsafe YAML tags and leavinglink:local plugins unchecked by default.memcode-dryrun-*staging profile withstrictStdoutvalidation, isolates failing providers withRetry without broken providers, and applies verified changes with snapshot rollback.Documentation (
docs/account-and-workers.md)command-manager.jsand macOSManage dsh Command…),$DSH_HOME/profiles/*ACP discovery rules, and Desktop-to-ACP provider dry-run/sync behavior.Validation
Branch:
magalz:fix/deepseek-integration-and-setupat commit44c1752998dc3636a5d4b95dbdf976e8812b6e06(no GitHub Actions dispatched).Local Windows checks (after final edit on
44c1752998dc3636a5d4b95dbdf976e8812b6e06)npm run typecheck: passed (exit0)node scripts/verify-third-party-notices.mjs: passed (849packages,dependencyLocksMatch: true,fontSourceVerified: true)node --import tsx --test tests/dsh-profiles.test.ts tests/dsh-desktop.test.ts tests/dsh-migration.test.ts tests/standard-acp.test.ts tests/review-agent.test.ts tests/connections.test.ts tests/commands.test.ts tests/mac-command-discovery.test.ts): 65/65 passed (0failed,0skipped)npm test: 1186/1188 passed, 2 failed (both pre-existing Windows Store App Execution AliasEACCES: permission denied, stat '...\Microsoft\WindowsApps\pwsh.exe'intests/terminals.test.ts;0skipped)npm run build: passed (exit0)dist/+runtime/app.tsTauri shim on Windows, run at5853e83prior to Copilot hardening):dshsetup (CLI + Desktopllm-pi-ai+ registry plugins + locallink:plugin): switched to a custom ACP profile, kept theLocal linkplugin unchecked, ran live dry-run + import (65verified models across6provider groups in the Worker Assignment model picker).Retry without broken providers; Desktop-only user (no CLI onPATH) ->Install dsh CLI-> ACP creation -> sync; custom ACP profile auto-detected whensettings.dshProfileis unset.npm run test:smokeagainst a temporary Podmancargo-xwinx86_64-pc-windows-msvcdebugmemcode.exebuild, run at5853e83,src-tauri/unchanged):scripts/tauri-smoke.mjs:290: native WebView2 launch,workspace:load, updater/dev checks,.app-shell, Docs product tour, Settings -> Updates, full planning smoke (cycles, carryover, frozen history, bulk validation, saved views, card styles, independent lanes and insights), state/preview event subscriptions, isolated preview guest WebView (window.memcode/requireundefined, guestrpcdenied), andwindow:action"maximize".scripts/tauri-smoke.mjs:291(preview:action"capture"): returnedBring MemCode to the foreground before capturing its visible preview(src-tauri/src/native.rsGetForegroundWindow() != hwnd) because the background-spawned smoke process (windowsHide: true) did not hold Win32 foreground focus in the interactive session.Pending platform checks (macOS verification requested)
magalz:fix/deepseek-integration-and-setup(44c1752998dc3636a5d4b95dbdf976e8812b6e06)44c1752998dc3636a5d4b95dbdf976e8812b6e06, install dependencies cleanly (npm ci), and runnpm run typecheck && npm test && npm run build && npm run test:smoke.DeepSeek Harness.appis installed in/Applicationsand remove/usr/local/bin/dsh(and anydshonPATH), open MemCode -> Workers, confirm Desktop app installed, click Install dsh CLI, and verifyContents/Resources/runtime/cli/command-manager.jseither installs cleanly or, onEACCES/EPERMfor/usr/local/bin/dsh, directs the user toManage dsh Command…in DeepSeek Harness Desktop withoutosascriptelevation prompts.~/.dsh/profiles/<custom>, verify auto-detection / switching, import Desktop providers via the dry-run checklist, and confirm grouped provider models appear in Worker Assignment -> Model.User impact
dshapprovals and saved workspace settings remain intact (settings.dshProfileis optional; users without it automatically get their customized ACP profile).link:local plugins unchecked by default.