适配 DSH 0.2.2-alpha.2 并移除旧版兼容

This commit is contained in:
yexi committed 2026-10-28 15:53:51 +08:00
1 parent ab63f682d8
commit 13b6772f16
8 files changed
+15 -370

No files matched your search

+2 -70
View File
@@ -6,7 +6,7 @@
The plugin stays lightweight: the existing switches enable or disable the rules as a whole, preserving DSH's interface layout, tool-calling protocols, Plan Mode, code execution (PTC), and subagent mechanics.
`0.2.4` fixes prompt registration conflicts in Minimal subagents with custom personas, missing native structured-output instructions, and overlapping settings requests that could overwrite a newer preview or clear the busy state too early. The prompt rules and existing switches remain unchanged. It supports DSH `0.2.1-rc.2` (`687f282e86`) with `engines.dsh` set to `>=0.2.0-rc.2 <0.2.2-0`, retaining installation support for desktop `0.2.0-rc.2`. The desktop app is supported on Windows and macOS.
`0.2.5` fixes prompt registration conflicts in Minimal subagents with custom personas, missing native structured-output instructions, and overlapping settings requests that could overwrite a newer preview or clear the busy state too early. The prompt rules and existing switches remain unchanged. It supports DSH `0.2.2-alpha.2` (`f3803c9697`) with `engines.dsh` set to `>=0.2.2-alpha.2 <0.2.3-0`. Only the current DSH version is supported; legacy compatibility is removed.
The native model reasoning settings and plugin index do not replace this plugin's per-mode prompt assembly. Reasoning levels remain managed by the native model settings.
@@ -22,7 +22,6 @@ The native model reasoning settings and plugin index do not replace this plugin'
- [Hot-Switching & Zero-Trace Reversion](#hot-switching--zero-trace-reversion)
- [Installation & Updates](#installation--updates)
- [Web Mode](#web-mode)
- [Desktop App](#desktop-app)
- [Local Source Install](#local-source-install)
- [Usage (Double-Switch Activation)](#usage-double-switch-activation)
- [Operational Boundaries](#operational-boundaries)
@@ -111,7 +110,7 @@ For CLI and server setups running `dsh web`.
#### Install
```sh
# Install specific tag
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.4
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.5
# Or track master
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
@@ -132,71 +131,6 @@ dsh plugin --profile web remove dsh-unrestricted
---
### Desktop App
For users running the official DeepSeek Harness desktop application on Windows or macOS.
> **Note**: The desktop app runs on an isolated `desktop` profile. Use the desktop app's bundled CLI binary rather than a global `dsh` command.
#### 1. Desktop CLI Path
On Windows, the default path is:
```text
%LOCALAPPDATA%\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd
```
On macOS, the default path is:
```text
/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh
```
If the app is installed elsewhere, replace the application path in the commands with its actual location.
#### 2. Install
1. Completely exit the desktop app.
2. Run the command for your operating system in a terminal.
**Windows (PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.4
```
**macOS (Terminal):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add "github:yexi-by/dsh-unrestricted#v0.2.4"
```
3. Launch the desktop app and follow the activation steps below.
#### 3. Update
1. Completely exit the desktop app.
2. Reinstall with the new version:
**Windows (PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop remove dsh-unrestricted
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#<new-version>
```
**macOS (Terminal):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop remove dsh-unrestricted
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add "github:yexi-by/dsh-unrestricted#<new-version>"
```
3. Restart the desktop app.
#### 4. Uninstall
**Windows (PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop remove dsh-unrestricted
```
**macOS (Terminal):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop remove dsh-unrestricted
```
---
### Local Source Install
For developers linking a local workspace:
@@ -205,8 +139,6 @@ For developers linking a local workspace:
# Web profile
dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted
# Desktop profile
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add file:D:/work/dsh/plugin/unrestricted
```
---
+2 -70
View File
@@ -6,7 +6,7 @@
プラグインは軽量な構成を維持し、既存のスイッチでルール全体を有効・無効にします。DSH 本来の画面レイアウト、ツール呼び出しプロトコル、計画モード(Plan Mode)、コード実行(PTC)、サブエージェントの実行ロジックを維持します。
`0.2.4` は、カスタムペルソナを持つ Minimal サブエージェントのプロンプト登録競合、公式の構造化出力指示の欠落、設定画面の並行リクエストによる古いプレビューの上書きや処理中状態の早期解除を修正します。既存のプロンプトルールとスイッチは変更しません。DSH `0.2.1-rc.2`(`687f282e86`)に対応し、`engines.dsh` は `>=0.2.0-rc.2 <0.2.2-0` です。デスクトップ版 `0.2.0-rc.2` へのインストールも引き続きサポートします。デスクトップ版は Windows と macOS に対応しています。
`0.2.5` は、カスタムペルソナを持つ Minimal サブエージェントのプロンプト登録競合、公式の構造化出力指示の欠落、設定画面の並行リクエストによる古いプレビューの上書きや処理中状態の早期解除を修正します。既存のプロンプトルールとスイッチは変更しません。DSH `0.2.2-alpha.2`(`f3803c9697`)に対応し、`engines.dsh` は `>=0.2.2-alpha.2 <0.2.3-0` です。旧バージョン向けの互換処理は削除しました。
公式の推論レベル設定とプラグイン索引は、本プラグインのモード別プロンプト組み立てを代替しません。推論レベルは公式のモデル設定で管理します。
@@ -22,7 +22,6 @@
- [即時適用と痕跡ゼロのロールバック](#即時適用と痕跡ゼロのロールバック)
- [インストール・更新](#インストール更新)
- [Web 版](#web-版)
- [デスクトップ版](#デスクトップ版)
- [ローカルソースインストール](#ローカルソースインストール)
- [使用方法(二重スイッチの確認)](#使用方法二重スイッチの確認)
- [動作境界と注意事項](#動作境界と注意事項)
@@ -109,7 +108,7 @@ CLI またはサーバー環境で `dsh web` を実行している場合。
#### インストール
```sh
# 指定バージョンのインストール
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.4
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.5
# または master 最新コードのインストール
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
@@ -130,71 +129,6 @@ dsh plugin --profile web remove dsh-unrestricted
---
### デスクトップ版
Windows または macOS の DeepSeek Harness 公式デスクトップアプリ環境。
> **注意**:デスクトップ版は独立した `desktop` プロファイルを使用します。グローバルの `dsh` コマンドではなく、アプリ付属の CLI を指定して実行する必要があります。
#### 1. デスクトップ版 CLI のパス
Windows の標準パス:
```text
%LOCALAPPDATA%\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd
```
macOS の標準パス:
```text
/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh
```
アプリを別の場所にインストールした場合は、コマンド内のアプリのパスを実際の場所に置き換えてください。
#### 2. インストール手順
1. デスクトップアプリを完全に終了します。
2. お使いの OS に対応するコマンドをターミナルで実行します。
**Windows(PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.4
```
**macOS(ターミナル):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add "github:yexi-by/dsh-unrestricted#v0.2.4"
```
3. デスクトップアプリを起動し、下記の使用方法に従って設定を完了します。
#### 3. アップデート手順
1. デスクトップアプリを完全に終了します。
2. アンインストールと再インストールを実行します:
**Windows(PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop remove dsh-unrestricted
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#新バージョン
```
**macOS(ターミナル):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop remove dsh-unrestricted
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add "github:yexi-by/dsh-unrestricted#新バージョン"
```
3. デスクトップアプリを再起動します。
#### 4. アンインストール
**Windows(PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop remove dsh-unrestricted
```
**macOS(ターミナル):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop remove dsh-unrestricted
```
---
### ローカルソースインストール
開発・デバッグ用:
@@ -203,8 +137,6 @@ macOS の標準パス:
# Web 版
dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted
# デスクトップ版
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add file:D:/work/dsh/plugin/unrestricted
```
---
+2 -70
View File
@@ -6,7 +6,7 @@
插件保持轻量:通过现有开关整体启停破限规则,保留 DSH 原有的界面布局、工具调用协议、计划模式(Plan Mode)、代码执行(PTC)以及子代理运行逻辑。
`0.2.4` 修复 Minimal 自定义角色子代理的提示词注册冲突、结构化子代理遗漏官方输出指引,以及设置页并发请求导致的旧预览覆盖和忙碌状态提前解除。现有提示词规则与开关保持不变。支持 DSH `0.2.1-rc.3`(`22ddee3792`),`engines.dsh` 为 `>=0.2.0-rc.2 <0.2.2-0`;保留桌面版 `0.2.0-rc.2` 的安装支持。桌面端支持 Windows 与 macOS。
`0.2.5` 修复 Minimal 自定义角色子代理的提示词注册冲突、结构化子代理遗漏官方输出指引,以及设置页并发请求导致的旧预览覆盖和忙碌状态提前解除。现有提示词规则与开关保持不变。支持 DSH `0.2.2-alpha.2`(`f3803c9697`),`engines.dsh` 为 `>=0.2.2-alpha.2 <0.2.3-0`。仅适配上述最新 DSH,不保留旧版兼容。
官方新增的自定义模型推理等级与插件索引不替代本插件的按模式提示词组装功能;本轮保留插件。模型推理等级统一由官方模型设置管理。
@@ -22,7 +22,6 @@
- [动态开关与无痕回滚](#动态开关与无痕回滚)
- [安装与更新](#安装与更新)
- [Web 端](#web-端)
- [桌面端(Desktop App)](#桌面端desktop-app)
- [本地源码安装](#本地源码安装)
- [使用说明(双重开关确认)](#使用说明双重开关确认)
- [使用边界与说明](#使用边界与说明)
@@ -111,7 +110,7 @@
#### 安装
```sh
# 安装指定版本
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.4
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.5
# 或安装 master 最新代码
dsh plugin --profile web add github:yexi-by/dsh-unrestricted
@@ -132,71 +131,6 @@ dsh plugin --profile web remove dsh-unrestricted
---
### 桌面端(Desktop App)
适用于 Windows 与 macOS 上的 DeepSeek Harness 官方桌面客户端。
> **注意**:桌面端使用独立的 `desktop` profile,不能使用全局 `dsh` 命令,必须调用桌面端自带的 CLI 工具执行配置。
#### 1. 桌面端 CLI 路径
Windows 默认路径:
```text
%LOCALAPPDATA%\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd
```
macOS 默认路径:
```text
/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh
```
如果应用安装在其他位置,请将命令中的应用路径替换为实际路径。
#### 2. 安装步骤
1. 完全退出正在运行的桌面客户端。
2. 根据系统在终端执行安装命令。
**Windows(PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.4
```
**macOS(终端):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add "github:yexi-by/dsh-unrestricted#v0.2.4"
```
3. 启动桌面客户端,按下方说明启用插件与功能开关。
#### 3. 更新步骤
1. 完全退出桌面客户端。
2. 执行重新安装命令:
**Windows(PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop remove dsh-unrestricted
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#目标版本号
```
**macOS(终端):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop remove dsh-unrestricted
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add "github:yexi-by/dsh-unrestricted#目标版本号"
```
3. 重新打开桌面客户端。
#### 4. 卸载步骤
**Windows(PowerShell):**
```powershell
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop remove dsh-unrestricted
```
**macOS(终端):**
```sh
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop remove dsh-unrestricted
```
---
### 本地源码安装
面向二次开发调试,使用 `file:` 协议安装本地源码目录:
@@ -205,8 +139,6 @@ macOS 默认路径:
# Web 端
dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted
# 桌面端
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add file:D:/work/dsh/plugin/unrestricted
```
---
-40
View File
@@ -1,40 +0,0 @@
# Desktop 0.2.0-rc.2 的预设加载失败恢复
适用于 [issue #7](https://github.com/yexi-by/dsh-unrestricted/issues/7):为处理插件导入错误,手工安装了 `@deepseek-ai/dsh-system-prompt`、`@deepseek-ai/dsh-scope`、`@deepseek-ai/cordis` 等宿主包,随后四个预设加载失败,并提示:
```text
persona (@deepseek-ai/dsh-persona): prompt section "deployment:persona-prefix" is already registered (for a per-agent override, register through that agent's `agent.ctx` instead)
```
这些宿主包应由桌面版运行时提供。额外安装的副本可能让预设注册与提示词服务使用不同的作用域标记,即使版本号相同也会产生该错误。
报告者同时安装的 `dsh-openwrite@0.2.12` 依赖旧版 `@deepseek-ai/schemastery@3.18.2`。默认平铺布局会把该包放在其他插件的查找路径中,破限插件随后会出现 `.volatile is not a function`。恢复流程同时改用隔离布局,保留 OpenWrite 自己的旧依赖,让破限插件继续使用宿主提供的版本。
## 恢复步骤
1. 完全退出 DeepSeek Harness Desktop,包括托盘中的进程。
2. 下载与本文一起提供的 `repair-desktop-profile.ps1`,在文件所在目录打开 PowerShell,运行:
```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\repair-desktop-profile.ps1
```
3. 重新启动桌面版。在插件页面启用 `dsh-unrestricted`,再打开破限功能开关,确认四种模式通过校验并新建会话。
脚本先备份 profile 的配置、依赖清单和锁文件,再把包管理设置改为 `nodeLinker: isolated`、`hoist: false`、`autoInstallPeers: false`,将旧 `node_modules` 移入同一备份目录。随后使用桌面版自带 CLI 移除破限插件及直接声明的六个相关宿主包,重新安装官方 `v0.2.2` 和其余已有依赖。其他插件的依赖声明、会话和自定义预设保留;不会自动退出或启动桌面应用。备份位置会打印在命令输出中。
如果桌面版安装在其他目录,使用 `-DesktopCliPath '实际路径\resources\runtime\cli\bin\dsh.cmd'`。如果设置了不同的 DSH 数据目录,使用 `-DshHomePath '实际的 DSH_HOME 目录'`。脚本默认继承 `DSH_HOME`,未设置时使用用户目录下的 `.dsh`。
执行失败时保留完整输出并反馈。若再次出现 `ERR_MODULE_NOT_FOUND`,不要继续手工补装宿主包,应检查桌面版 CLI 路径及 profile 的安装布局。
## 实测范围
使用 Windows 上桌面版自带 `0.2.0-rc.2` 运行时及临时 profile 验证,未启动桌面界面,也未调用模型 API:
- 全新安装官方 `v0.2.2` 后,standard、ptc、cordis、minimal 均可创建 Agent。
- 开启破限后四种模式均完成注入,工具列表不变;关闭后提示词恢复。
- 按报告补装五个宿主依赖后,复现同一条全局 persona 重复注册异常。
- 保留报告中的自定义小说预设、`dsh-novel-craft@0.3.0` 和 `dsh-openwrite@0.2.12`,复现旧 schemastery 的导入冲突;隔离依赖后四种模式及小说预设重新可加载。
- 最终恢复脚本在含以上插件和手工宿主依赖的 profile 上执行后,再次完成加载、开关与回滚验证;恢复过程保持 `cordis.patch.yml` 字节不变,并保留另外两个插件的依赖声明和 bundle。
该流程针对报告中的安装状态;尚未在报告者电脑上执行。
+2 -2
View File
@@ -1,8 +1,8 @@
{
"name": "dsh-unrestricted",
"version": "0.2.4",
"version": "0.2.5",
"engines": {
"dsh": ">=0.2.0-rc.2 <0.2.2-0"
"dsh": ">=0.2.2-alpha.2 <0.2.3-0"
},
"private": true,
"description": "Toggleable unrestricted mode for DeepSeek Harness: fuses execution rules into the active standard, ptc, cordis, minimal, and subagent prompts",
+5 -16
View File
@@ -32,7 +32,6 @@
*/
import z from '@deepseek-ai/schemastery'
import { renderPrompt } from '@deepseek-ai/dsh-system-prompt'
import { createScope } from '@deepseek-ai/dsh-scope'
import {
ANCHORS, PRESETS, PRESET_RULES, contractFingerprint, fuseSections, fusedMinimalPrompt, renderPreview,
} from './rules.js'
@@ -90,8 +89,8 @@ export function apply(ctx, config) {
}
/**
* Read the standing assembly of a preset using the registry's scope lease
* (or a temporary mounted scope fallback). In rosterless profiles, assemble
* Read the standing assembly of a preset using the registry's scope lease.
* In rosterless profiles, assemble
* the global host layer directly.
*/
async function presetAssembly(presetId) {
@@ -101,21 +100,11 @@ export function apply(ctx, config) {
if (presets === undefined) {
return await ctx.systemPrompt.assemble({})
}
if (typeof presets.acquireScope === 'function') {
const lease = await presets.acquireScope(presetId)
try {
return await ctx.systemPrompt.assemble({ scope: lease.key })
} finally {
await lease[Symbol.asyncDispose]()
}
}
const key = {}
const scope = createScope(ctx, key)
const lease = await presets.acquireScope(presetId)
try {
await presets.mount(scope.ctx, presetId)
return await ctx.systemPrompt.assemble({ scope: key })
return await ctx.systemPrompt.assemble({ scope: lease.key })
} finally {
await scope.dispose()
await lease[Symbol.asyncDispose]()
}
}
+2 -2
View File
@@ -16,8 +16,8 @@ export const ANCHORS = {
identity: 'You are an AI agent powered by DeepSeek Harness.',
personaStandard: 'You are a coding agent powered by the {{model}} model.',
personaMinimal: 'You are a helpful software engineer assistant.',
// 只识别原生计划模式段;审批条件和完整正文保持官方内容,兼容本机 Desktop 的旧文案。
planPrefix: 'You are in plan mode. Stay in plan mode until ',
// 匹配当前官方计划模式首句;旧版本提示词不在适配范围内。
planPrefix: 'You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode.',
ptcOnly: '`run_code` is the only tool you can call directly — a tool call naming any other tool fails. Reach every tool the SDK declares below from inside the program.',
structuredOutputPrefix: 'When you have your final answer, you MUST report it by calling the `structured_output` tool',
structuredOutputFull: 'When you have your final answer, you MUST report it by calling the `structured_output` tool with arguments matching its parameter schema exactly. Do not finish with a plain text answer: only the tool call counts as your result.',
-100
View File
@@ -1,100 +0,0 @@
#requires -Version 5.1
<#
.SYNOPSIS
修复 issue #7 中手工补装宿主依赖后,桌面版预设全部加载失败的问题。
.DESCRIPTION
先备份 profile 配置和依赖清单,再通过桌面版自带 CLI 隔离第三方依赖,
移除手工宿主依赖,并重新安装已验证的官方插件 v0.2.2。
运行前请完全退出 DSH Desktop;脚本不会退出或启动桌面应用。
#>
[CmdletBinding()]
param(
[string]$DesktopCliPath = (Join-Path $env:LOCALAPPDATA 'Programs/DeepSeek Harness/resources/runtime/cli/bin/dsh.cmd'),
[string]$DshHomePath = $(if ([string]::IsNullOrWhiteSpace($env:DSH_HOME)) { Join-Path $env:USERPROFILE '.dsh' } else { $env:DSH_HOME }),
[string]$ProfileName = 'desktop'
)
$ErrorActionPreference = 'Stop'
if (-not (Test-Path -LiteralPath $DesktopCliPath -PathType Leaf)) {
throw "找不到桌面版 CLI:$DesktopCliPath。请用 -DesktopCliPath 指定实际安装目录内的 dsh.cmd。"
}
if ($ProfileName -notmatch '^[a-zA-Z0-9][a-zA-Z0-9_-]*$') {
throw 'ProfileName 必须是 profile 名称,不能是路径。'
}
$DshHomePath = [System.IO.Path]::GetFullPath($DshHomePath)
$profileDirectory = Join-Path (Join-Path $DshHomePath 'profiles') $ProfileName
$manifestPath = Join-Path $profileDirectory 'package.json'
if (-not (Test-Path -LiteralPath $manifestPath -PathType Leaf)) {
throw "找不到现有 profile:$manifestPath。请确认 DSH_HOME 或用 -DshHomePath 指定实际目录。"
}
$manifest = Get-Content -LiteralPath $manifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
$sharedPackageNames = @(
'@deepseek-ai/cordis',
'@deepseek-ai/schemastery',
'@deepseek-ai/dsh-system-prompt',
'@deepseek-ai/dsh-scope',
'@deepseek-ai/dsh-invariants',
'@deepseek-ai/dsh-llm'
)
$declaredNames = @(
foreach ($section in @('dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies')) {
$dependencies = $manifest.$section
if ($null -ne $dependencies) { $dependencies.PSObject.Properties.Name }
}
)
$removeNames = @(
@('dsh-unrestricted') + $sharedPackageNames |
Where-Object { $declaredNames -contains $_ } |
Select-Object -Unique
)
$backupDirectory = Join-Path $profileDirectory ('.plugin-manager/backups/unrestricted-issue7-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0, 6))
New-Item -ItemType Directory -Path $backupDirectory -Force | Out-Null
foreach ($filename in @('package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml', 'cordis.yml', 'cordis.patch.yml')) {
$sourcePath = Join-Path $profileDirectory $filename
if (Test-Path -LiteralPath $sourcePath -PathType Leaf) {
Copy-Item -LiteralPath $sourcePath -Destination (Join-Path $backupDirectory $filename)
}
}
Write-Host "配置和依赖清单已备份到:$backupDirectory"
function Invoke-DesktopDsh {
param([string[]]$DshArguments)
& $DesktopCliPath @DshArguments
if ($LASTEXITCODE -ne 0) {
throw "桌面版 CLI 执行失败(退出码 $LASTEXITCODE)。请保留上面的错误和备份目录;不要手工安装 @deepseek-ai 宿主包。"
}
}
$previousDshHome = $env:DSH_HOME
try {
$env:DSH_HOME = $DshHomePath
Invoke-DesktopDsh -DshArguments @('--version')
# OpenWrite 的旧 schemastery 仅供它自身使用,不能提升到其他插件的查找路径。
Invoke-DesktopDsh -DshArguments @('plugin', '--profile', $ProfileName, 'config', 'set', 'nodeLinker', 'isolated', '--location', 'project')
Invoke-DesktopDsh -DshArguments @('plugin', '--profile', $ProfileName, 'config', 'set', 'hoist', 'false', '--location', 'project')
Invoke-DesktopDsh -DshArguments @('plugin', '--profile', $ProfileName, 'config', 'set', 'autoInstallPeers', 'false', '--location', 'project')
# 更换安装布局前保留旧目录;不删除插件源码、会话或 profile 配置。
$moduleDirectory = [System.IO.Path]::GetFullPath((Join-Path $profileDirectory 'node_modules'))
$moduleBackup = [System.IO.Path]::GetFullPath((Join-Path $backupDirectory 'node_modules'))
$profilePrefix = [System.IO.Path]::GetFullPath($profileDirectory).TrimEnd('\', '/') + [System.IO.Path]::DirectorySeparatorChar
if (-not $moduleDirectory.StartsWith($profilePrefix, [System.StringComparison]::OrdinalIgnoreCase) -or
-not $moduleBackup.StartsWith($profilePrefix, [System.StringComparison]::OrdinalIgnoreCase)) {
throw '依赖目录或备份目录不在指定 profile 内,已停止。'
}
if (Test-Path -LiteralPath $moduleDirectory) {
Move-Item -LiteralPath $moduleDirectory -Destination $moduleBackup
}
if ($removeNames.Count -gt 0) {
Invoke-DesktopDsh -DshArguments (@('plugin', '--profile', $ProfileName, 'remove') + $removeNames)
}
Invoke-DesktopDsh -DshArguments @('plugin', '--profile', $ProfileName, 'add', 'github:yexi-by/dsh-unrestricted#v0.2.2')
$installedManifestPath = Join-Path $profileDirectory 'node_modules/dsh-unrestricted/package.json'
$installed = Get-Content -LiteralPath $installedManifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
if ($installed.version -ne '0.2.2') {
throw "安装包版本应为 0.2.2,实际为 $($installed.version)。请保留命令输出。"
}
Write-Host '官方 dsh-unrestricted v0.2.2 已重新安装,第三方依赖已隔离。请启动 DSH Desktop,开启插件及破限功能开关,再新建会话验证。'
} finally {
$env:DSH_HOME = $previousDshHome
}