Repository navigation
feat(clients): native DSH bundle install for DeepSeek Harness (builds on #1453) #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sobhanb-eth
wants to merge
11
commits into
CoplayDev:beta
Choose a base branch
from
sobhanb-eth:feat/dsh-native-bundle
base: beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3ee15a1
feat(clients): auto-configure DeepSeek Harness
VortDyn 4c7e533
fix(tests): pass unescaped API key in DshConfiguratorTests round-trip
VortDyn 42c4e2b
feat(clients): install DeepSeek Harness config as a native DSH bundle
sobhanb-eth d5296f7
fix(clients): resolve dsh.cmd launcher, guard missing DSH profile, do…
sobhanb-eth bf2fde1
fix(clients): emit failOnStartupError in the unityMCP row
sobhanb-eth 9fca4a2
fix(clients): compare uvx package sources as text, not file paths
sobhanb-eth 163edd2
fix(clients): address CodeRabbit review — process deadlock, per-profi…
sobhanb-eth adfbbc8
fix(clients): keep bundle on failed removal, quote args against cmd.e…
sobhanb-eth 4503ddb
fix(clients): remove disabled-but-installed bundles through the CLI
sobhanb-eth 27f6aa1
refactor(clients): trim DeepSeek Harness to a manual configurator
sobhanb-eth c7f62e4
docs(clients): note DSH desktop profile handling in the manual snippet
sobhanb-eth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
190 changes: 190 additions & 0 deletions
190
MCPForUnity/Editor/Clients/Configurators/DeepSeekHarnessConfigurator.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Text; | ||
| using MCPForUnity.Editor.Constants; | ||
| using MCPForUnity.Editor.Helpers; | ||
| using MCPForUnity.Editor.Models; | ||
| using MCPForUnity.Editor.Services; | ||
| using UnityEditor; | ||
|
|
||
| namespace MCPForUnity.Editor.Clients.Configurators | ||
| { | ||
| /// <summary> | ||
| /// DeepSeek Harness (<c>dsh</c>) has no client config file. MCP servers are mounted | ||
| /// through its plugin manager as a configuration-only bundle (a manifest plus a | ||
| /// <c>cordis.patch.yml</c> row for <c>@deepseek-ai/dsh-mcp-client</c>), so setup is | ||
| /// manual like the other UI-driven clients: the snippet below holds the two bundle | ||
| /// files and the <c>dsh plugin add</c> command that installs them. After a DSH | ||
| /// reload the tools surface as <c>mcp__unityMCP__<tool></c>. From there DSH's | ||
| /// own plugin manager owns enable/disable and removal. | ||
| /// </summary> | ||
| public class DeepSeekHarnessConfigurator : McpClientConfiguratorBase | ||
| { | ||
| public const string ClientName = "DeepSeek Harness"; | ||
|
|
||
| private const string ServerName = "unityMCP"; | ||
| private const string BundleName = "@local/unity-mcp-dsh"; | ||
|
|
||
| public DeepSeekHarnessConfigurator() : base(new McpClient | ||
| { | ||
| name = ClientName, | ||
| windowsConfigPath = BundlePatchPath(), | ||
| macConfigPath = BundlePatchPath(), | ||
| linuxConfigPath = BundlePatchPath() | ||
| }) | ||
| { } | ||
|
|
||
| public override bool SupportsAutoConfigure => false; | ||
|
|
||
| /// <summary>DSH is installed once it has run at least once (its home directory exists).</summary> | ||
| public override bool IsInstalled => Directory.Exists(DshHome()); | ||
|
|
||
| public override string GetConfigPath() => BundlePatchPath(); | ||
|
|
||
| public override McpStatus CheckStatus(bool attemptAutoRewrite = true) | ||
| { | ||
| client.SetStatus(McpStatus.NotConfigured, "DeepSeek Harness setup is manual; DSH's plugin manager owns the bundle."); | ||
| return client.status; | ||
| } | ||
|
|
||
| public override void Configure() | ||
| { | ||
| throw new InvalidOperationException( | ||
| "DeepSeek Harness setup is manual. Use the Manual Configuration snippet below: " + | ||
| "it holds the two bundle files and the 'dsh plugin add' command to run."); | ||
| } | ||
|
|
||
| public override IList<string> GetInstallationSteps() => new List<string> | ||
| { | ||
| "Install DeepSeek Harness and run any 'dsh' command once (creates ~/.dsh)", | ||
| "Create the two files shown in the Manual Configuration snippet below", | ||
| "Quit DeepSeek Harness, run the 'dsh plugin add' command from the snippet, then reopen it", | ||
| "Restart DeepSeek Harness; Unity tools appear as mcp__unityMCP__<tool>", | ||
| "DSH's plugin manager can enable/disable or remove the bundle afterwards" | ||
| }; | ||
|
|
||
| public override string GetManualSnippet() | ||
| { | ||
| try | ||
| { | ||
| string bundleDir = BundleDir(); | ||
| string profile = ProfileName(); | ||
| var sb = new StringBuilder(); | ||
| sb.AppendLine("# DeepSeek Harness setup. $DSH_HOME defaults to ~/.dsh."); | ||
| sb.AppendLine("# 'desktop' is the Desktop app's own profile: quit DeepSeek Harness, run the"); | ||
| sb.AppendLine("# commands below, then reopen it. With a standalone dsh (npm install), pick"); | ||
| sb.AppendLine("# another profile name instead; 'desktop' is reserved for the Desktop app."); | ||
| sb.AppendLine(); | ||
| sb.AppendLine("# --- " + bundleDir + "/package.json ---"); | ||
| sb.AppendLine("{"); | ||
| sb.AppendLine(" \"name\": \"@local/unity-mcp-dsh\","); | ||
| sb.AppendLine(" \"version\": \"1.0.0\","); | ||
| sb.AppendLine(" \"private\": true,"); | ||
| sb.AppendLine(" \"type\": \"module\","); | ||
| sb.AppendLine(" \"dsh\": { \"bundle\": { \"patch\": \"./cordis.patch.yml\" } }"); | ||
| sb.AppendLine("}"); | ||
| sb.AppendLine(); | ||
| sb.AppendLine("# --- " + bundleDir + "/cordis.patch.yml ---"); | ||
| sb.Append(Row()); | ||
| sb.AppendLine(); | ||
| sb.AppendLine("# Install:"); | ||
| sb.AppendLine("# dsh plugin --profile " + ShellQuote(profile) + " add " + ShellQuote(bundleDir)); | ||
| sb.AppendLine("# Remove:"); | ||
| sb.AppendLine("# dsh plugin --profile " + ShellQuote(profile) + " remove " + ShellQuote(BundleName)); | ||
| return sb.ToString(); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| return "# error: " + ex.Message; | ||
| } | ||
| } | ||
|
|
||
| /// <summary>Renders the patch row for the transport currently selected in Unity.</summary> | ||
| private static string Row() | ||
| { | ||
| bool useHttp = EditorConfigurationCache.Instance.UseHttpTransport; | ||
| var sb = new StringBuilder(); | ||
| sb.AppendLine("# >>> MCP for Unity (unityMCP) managed block >>>"); | ||
| sb.AppendLine("- insert:"); | ||
| sb.AppendLine(" - id: unitymcp"); | ||
| sb.AppendLine(" name: '@deepseek-ai/dsh-mcp-client'"); | ||
| sb.AppendLine(" config:"); | ||
| sb.AppendLine(" serverName: " + ServerName); | ||
|
|
||
| if (useHttp) | ||
| { | ||
| sb.AppendLine(" transport: streamable-http"); | ||
| sb.AppendLine(" url: " + YamlQuote(HttpEndpointUtility.GetMcpRpcUrl())); | ||
| if (HttpEndpointUtility.IsRemoteScope()) | ||
| { | ||
| string apiKey = EditorPrefs.GetString(EditorPrefKeys.ApiKey, string.Empty); | ||
| if (!string.IsNullOrEmpty(apiKey)) | ||
| { | ||
| sb.AppendLine(" headers:"); | ||
| sb.AppendLine(" " + AuthConstants.ApiKeyHeader + ": " + YamlQuote(apiKey)); | ||
| } | ||
| } | ||
| } | ||
| else | ||
| { | ||
| var (uvxPath, _, packageName) = AssetPathUtility.GetUvxCommandParts(); | ||
| if (string.IsNullOrWhiteSpace(uvxPath)) | ||
| { | ||
| throw new InvalidOperationException("uvx not found. Install uv/uvx or set the override in Advanced Settings."); | ||
| } | ||
|
|
||
| sb.AppendLine(" transport: stdio"); | ||
| sb.AppendLine(" command: " + YamlQuote(uvxPath)); | ||
| sb.AppendLine(" args:"); | ||
| foreach (string flag in AssetPathUtility.GetUvxDevFlagsList()) | ||
| { | ||
| sb.AppendLine(" - " + YamlQuote(flag)); | ||
| } | ||
| foreach (string arg in AssetPathUtility.GetBetaServerFromArgsList()) | ||
| { | ||
| sb.AppendLine(" - " + YamlQuote(arg)); | ||
| } | ||
| sb.AppendLine(" - " + YamlQuote(packageName)); | ||
| sb.AppendLine(" - " + YamlQuote("--transport")); | ||
| sb.AppendLine(" - " + YamlQuote("stdio")); | ||
| if (MCPServiceLocator.Platform.IsWindows()) | ||
| { | ||
| sb.AppendLine(" env:"); | ||
| sb.AppendLine(" SystemRoot: " + YamlQuote(MCPServiceLocator.Platform.GetSystemRoot())); | ||
| } | ||
| } | ||
|
|
||
| sb.AppendLine(" failOnStartupError: true"); | ||
| sb.AppendLine("# <<< MCP for Unity (unityMCP) <<<"); | ||
| return sb.ToString(); | ||
| } | ||
|
|
||
| /// <summary>DSH home: <c>$DSH_HOME</c> when set, else <c>~/.dsh</c>.</summary> | ||
| private static string DshHome() | ||
| { | ||
| string envHome = Environment.GetEnvironmentVariable("DSH_HOME"); | ||
| if (!string.IsNullOrEmpty(envHome)) return envHome; | ||
|
|
||
| string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
| return string.IsNullOrEmpty(home) ? string.Empty : Path.Combine(home, ".dsh"); | ||
| } | ||
|
|
||
| /// <summary>Target profile: <c>DSH_PROFILE</c> when set, else <c>desktop</c>.</summary> | ||
| private static string ProfileName() | ||
| { | ||
| string envProfile = Environment.GetEnvironmentVariable("DSH_PROFILE"); | ||
| return string.IsNullOrEmpty(envProfile) ? "desktop" : envProfile; | ||
| } | ||
|
|
||
| private static string BundleDir() => Path.Combine(DshHome(), "bundles", ProfileName(), "unity-mcp"); | ||
|
|
||
| private static string BundlePatchPath() => Path.Combine(BundleDir(), "cordis.patch.yml"); | ||
|
|
||
| /// <summary>Single-quotes a YAML scalar; embedded single quotes are doubled.</summary> | ||
| private static string YamlQuote(string value) => "'" + (value ?? string.Empty).Replace("'", "''") + "'"; | ||
|
|
||
| /// <summary>Double-quotes a shell argument so cmd.exe metacharacters stay literal.</summary> | ||
| private static string ShellQuote(string value) => "\"" + (value ?? string.Empty).Replace("\"", "\\\"") + "\""; | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
MCPForUnity/Editor/Clients/Configurators/DeepSeekHarnessConfigurator.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n -i 'desktop|DSH_PROFILE' MCPForUnity/Editor/Clients/Configurators/DeepSeekHarnessConfigurator.cs website/docsRepository: CoplayDev/unity-mcp
Length of output: 4590
🌐 Web query:
deepseek-harness dsh CLI plugin --profile desktop reserved Electron profile README💡 Result:
🏁 Script executed:
Repository: CoplayDev/unity-mcp
Length of output: 23869
🌐 Web query:
official DeepSeek Harness CLI README DSH_PROFILE desktop Electron plugin management profile💡 Result:
🏁 Script executed:
Repository: CoplayDev/unity-mcp
Length of output: 23869
Do not use
desktopas the ordinary CLI default.When
DSH_PROFILEis unset,ProfileName()selectsdesktop. The generateddsh plugin --profile desktop add ...command then targets the Electron-owned profile, which the regular npm-installed DSH CLI cannot modify.The current default appears intentional for Desktop, but the snippet must either require a documented CLI profile or explain that
desktoprequires the Desktop-installeddshcommand after Desktop is closed.🤖 Prompt for AI Agents