From 9ca994201a340ed83172d71b42187e81e195f75c Mon Sep 17 00:00:00 2001 From: yexi Date: Tue, 22 Sep 2026 19:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=20DSH=200.1.7=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8E=E4=BC=9A=E8=AF=9D=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 ++++--- lib/client.js | 7 ++-- lib/client.js.map | 2 +- locale/en.json | 6 +++ locale/zh.json | 6 +++ package.json | 8 ++-- src/client/UnrestrictedCard.tsx | 2 +- src/client/controller.ts | 8 ++-- src/client/index.tsx | 2 +- src/node.js | 41 +++++++++++-------- src/rules.js | 3 +- tests/fixtures/meta.json | 20 ++++----- tests/fixtures/original-cordis-plan.md | 28 ++----------- tests/fixtures/original-cordis.md | 28 ++----------- tests/fixtures/original-ptc-plan.md | 26 +++++++----- tests/fixtures/original-ptc.md | 26 +++++++----- tests/fixtures/original-standard-plan.md | 4 +- tests/fixtures/original-standard.md | 4 +- tests/fixtures/original-subagent-standard.md | 4 +- tests/fixtures/sections-cordis-plan.json | 10 ++--- tests/fixtures/sections-cordis.json | 10 ++--- tests/fixtures/sections-ptc-plan.json | 6 +-- tests/fixtures/sections-ptc.json | 6 +-- tests/fixtures/sections-standard-plan.json | 4 +- tests/fixtures/sections-standard.json | 4 +- .../fixtures/sections-subagent-standard.json | 4 +- tests/fixtures/tools-cordis-plan.json | 26 ++++++++---- tests/fixtures/tools-cordis.json | 26 ++++++++---- tests/fixtures/tools-standard-plan.json | 20 +++++---- tests/fixtures/tools-standard.json | 20 +++++---- tests/fixtures/tools-subagent-standard.json | 20 +++++---- tools/dump-prompts.mjs | 19 ++++----- tools/verify-live.mjs | 35 ++++++++-------- 33 files changed, 228 insertions(+), 221 deletions(-) create mode 100644 locale/en.json create mode 100644 locale/zh.json diff --git a/README.md b/README.md index 1209a01..bd7e2a0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # dsh-unrestricted +当前版本 0.1.9 适配 DSH 0.1.7-alpha.1(`c36a83ff6b`)。在侧栏「插件 → 破限模式」打开配置。配置通过本体 ConfigEditor 保存到当前 profile 的 `cordis.patch.yml`,由 volatile Config 热更新;旧 `settings.yaml` 由本体首次启动时导入。 + 为 DeepSeek Harness(DSH)Web 提供可随时开关的破限提示词。它把一份**交付契约** 融合进 Standard、PTC、Cordis、Minimal 及其子代理的当前原版系统提示词;关闭后恢复 DSH 原版提示词。开启前可以在设置卡片里预览即将写入的完整提示词。 @@ -9,12 +11,12 @@ DSH 原版提示词。开启前可以在设置卡片里预览即将写入的完 下面的命令把当前稳定版本安装到 DSH 的 `web` profile: ```sh -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.1.8 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.1.9 ``` 安装后重启 `dsh web`,然后进入 -侧栏 `插件 → unrestricted` 打开开关。开关状态保存在 -`~/.dsh/settings.yaml` 的 `unrestricted.enabled` 中,重启后仍然有效。 +侧栏 `插件 → 破限模式` 打开开关。开关状态保存在 +`~/.dsh/profiles/web/cordis.patch.yml` 的 `id: unrestricted` 条目的 `config.enabled` 中,重启后仍然有效。 如需安装仓库中的最新代码,可以省略版本号: @@ -61,7 +63,7 @@ DSH 的原版系统提示词规定 agent 身份、计划模式和工具调用方 - 预览:优先返回真实 agent 刚组装的字节;还没有 agent 组装过该模式时退回 preset standing scope,此时 `{{model}}`、`{{cwd}}` 显示为字面占位符。 -插件直接面向 DSH `0.1.6-alpha.2` 的 master `ddefc45fbc`,使用当前的 `ptc` preset、`tools:ptc-only` 段和 +插件直接面向 DSH `0.1.7-alpha.1` 的 master `c36a83ff6b`,使用当前的 `ptc` preset、`tools:ptc-only` 段和 字符串 settings namespace。设置页已接入官方 `plugins.bundle.config`,Cordis persona 锚点与 fixtures 同步新版的 `plugin_manager` 和 Creator 工作流,既有契约正文保持原样。完整改写清单见 [当前 master 提示词融合说明](docs/prompt-fusion.md),本次重构吸收上游哪些实测结论见 @@ -76,7 +78,7 @@ DSH 的原版系统提示词规定 agent 身份、计划模式和工具调用方 dsh plugin --profile web remove dsh-unrestricted ``` -卸载插件不会删除 `~/.dsh/settings.yaml` 中已经保存的开关值。 +卸载插件不会删除 `~/.dsh/profiles/web/cordis.patch.yml` 中已经保存的开关值。 ## 来源、版权与许可证 @@ -136,4 +138,4 @@ tools/ 原版提示词抓取和集成验证脚本 docs/ 原版与融合版的逐项差异、上游吸收说明 ``` -Web bundle 为官方 `connection` 条目声明 `webServer` 依赖,并保留 `webRuntime`;私有 RPC 因而可以在 DSH `0.1.5-rc.2` 上注册,浏览器认证继续由 Connection 处理。 +Web bundle 为官方 `connection` 条目声明 `webServer` 依赖,并保留 `webRuntime`;私有 RPC 因而可以在 DSH `0.1.7-alpha.1` 上注册,浏览器认证继续由 Connection 处理。 diff --git a/lib/client.js b/lib/client.js index 858ec53..91b8708 100644 --- a/lib/client.js +++ b/lib/client.js @@ -15,12 +15,12 @@ window.__ModuleLoader__.load({ } /** * Create the card controller bound to the calling plugin's context. - * @param ctx - the browser plugin context (connection + remote + settingsScope injected). + * @param ctx - the browser plugin context (connection + remote + configForms injected). * @returns the controller whose face() feeds the slot inject share. */ function createUnrestrictedController(ctx) { const connection = ctx.get("connection"); - const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NS }); + const settings = ctx.configForms.get(SETTINGS_NS); let snapshot = { enabled: false, writable: false, @@ -605,6 +605,7 @@ window.__ModuleLoader__.load({ if (entry === void 0 || entry.status === "failed") props.loadPreview(presetId); } return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", { + open: true, className: "dsh-unrestricted-card", children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { className: "dsh-unrestricted-summary", @@ -773,7 +774,7 @@ window.__ModuleLoader__.load({ "locale", "connection", "remote", - "settingsScope" + "configForms" ]; /** 注册本插件的配置页面。 */ function apply(ctx) { diff --git a/lib/client.js.map b/lib/client.js.map index 01774d0..3408b94 100644 --- a/lib/client.js.map +++ b/lib/client.js.map @@ -1 +1 @@ -{"version":3,"file":"client.js","names":["useState"],"sources":["../src/client/controller.ts","../src/client/locales.ts","../src/client/styles.ts","../src/client/UnrestrictedCard.tsx","../src/client/index.tsx"],"sourcesContent":["/**\n * Browser-half controller for the unrestricted card: binds the `unrestricted`\n * settings namespace (the toggle) and polls the host half's private RPC for\n * per-preset fusion state. Mirrors the card-controller pattern: the apply\n * closure owns the controller, the slot inject face hands hooks and callbacks\n * to the component.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: the ctx.remote Context merge and the forwarded-event key face.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.settingsScope Context merge.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n\n/** The toggle section stored in the `unrestricted` settings namespace. */\nexport interface UnrestrictedSettings {\n enabled?: boolean\n}\n\n/** Per-preset fusion state reported by the host half. */\nexport interface UnrestrictedModeState {\n state: 'off' | 'checking' | 'active' | 'failed'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n /** Fingerprint of the contract bytes the host half deploys. */\n contract: string\n modes: Record\n}\n\n/** Deploy preview for one preset: what switching on would actually assemble. */\nexport interface UnrestrictedPreview {\n presetId: string\n contract: string\n available: boolean\n /** `live` = bytes a live agent received; `standing` = preset scope, no agent bound. */\n source?: 'live' | 'standing'\n /** Fused prompt text; present when available. */\n text?: string\n bytes?: number\n lines?: number\n /** Why no preview could be built; present when unavailable. */\n reason?: string\n}\n\n/** One fetched preview, keyed by preset, plus its in-flight/error state. */\nexport interface UnrestrictedPreviewEntry {\n status: 'loading' | 'ready' | 'failed'\n preview?: UnrestrictedPreview\n message?: string\n}\n\n/** Full view snapshot the card subscribes to. */\nexport interface UnrestrictedViewSnapshot {\n /** Persisted toggle; undefined until the settings scope first syncs. */\n enabled: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Settings scope sync state. */\n settingsStatus: 'loading' | 'ready' | 'unavailable'\n /** Live host status; null until the first RPC answer. */\n status: UnrestrictedStatus | null\n /** presetId -> fetched deploy preview. */\n previews: Record\n /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\n\n/** Minimal observable contract consumed by the slot renderer's hook binding. */\nexport interface UnrestrictedViewSource {\n getSnapshot(): UnrestrictedViewSnapshot\n subscribe(listener: () => void): () => void\n}\n\n/** Inject face handed to the card at registration. */\nexport interface UnrestrictedCardInjected {\n hooks: {\n /** Reactive card view. */\n view: UnrestrictedViewSource\n }\n /** Persist the toggle. */\n setEnabled: (enabled: boolean) => Promise\n /** Re-run the host-side anchor checks and refresh. */\n recheck: () => Promise\n /** Re-read host status. */\n refresh: () => Promise\n /** Fetch the exact fused prompt this preset would deploy. */\n loadPreview: (presetId: string) => Promise\n}\n\nconst RPC_CHANNEL = '/dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\n\n/** Human-readable error text for the banner. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * Create the card controller bound to the calling plugin's context.\n * @param ctx - the browser plugin context (connection + remote + settingsScope injected).\n * @returns the controller whose face() feeds the slot inject share.\n */\nexport function createUnrestrictedController(ctx: Context) {\n const connection = ctx.get('connection') as ConnectionHandle\n const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NS })\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\n previews: {},\n }\n const listeners = new Set<() => void>()\n\n const view: UnrestrictedViewSource = {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n\n function publish(): void {\n const settingsSnapshot = settings.getSnapshot()\n snapshot = {\n enabled: settingsSnapshot.value?.enabled === true,\n writable: settingsSnapshot.writable,\n settingsStatus: settingsSnapshot.status,\n status: snapshot.status,\n previews: snapshot.previews,\n message: snapshot.message,\n }\n for (const listener of listeners) listener()\n }\n\n async function call(endpoint: string, payload: unknown): Promise {\n const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload) as RpcResult\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n }\n\n async function refresh(): Promise {\n try {\n const status = await call('status', {})\n snapshot = { ...snapshot, status, message: undefined }\n publish()\n } catch (error) {\n snapshot = { ...snapshot, message: messageOf(error) }\n publish()\n }\n }\n\n async function setEnabled(enabled: boolean): Promise {\n await settings.set('enabled', enabled)\n publish()\n // Give the host settings watcher one turn before reading its derived state.\n setTimeout(() => void refresh(), 300)\n }\n\n async function recheck(): Promise {\n try {\n const status = await call('recheck', {})\n // The recheck invalidates every cached preview: the deployed bytes may\n // have changed under a new master.\n snapshot = { ...snapshot, status, previews: {}, message: undefined }\n publish()\n } catch (error) {\n snapshot = { ...snapshot, message: messageOf(error) }\n publish()\n }\n }\n\n /**\n * Fetch one preset's deploy preview. The card renders the raw fused prompt,\n * so the user reads the exact bytes before switching the mode on.\n * @param presetId - preset id from the card's row.\n */\n async function loadPreview(presetId: string): Promise {\n snapshot = {\n ...snapshot,\n previews: { ...snapshot.previews, [presetId]: { status: 'loading' } },\n }\n publish()\n try {\n const preview = await call('preview', { presetId })\n snapshot = {\n ...snapshot,\n previews: { ...snapshot.previews, [presetId]: { status: 'ready', preview } },\n }\n } catch (error) {\n snapshot = {\n ...snapshot,\n previews: { ...snapshot.previews, [presetId]: { status: 'failed', message: messageOf(error) } },\n }\n }\n publish()\n }\n\n ctx.effect(\n () => settings.subscribe(publish),\n 'dsh-unrestricted: settings mirror',\n )\n // External settings.yaml edits commit through the settings service, which\n // forwards one document event per commit regardless of namespace.\n ctx.effect(\n () => ctx.remote.$on('settings/document-updated', (namespace?: string) => {\n if (namespace === undefined || namespace === SETTINGS_NS) void refresh()\n }),\n 'dsh-unrestricted: settings invalidations',\n )\n\n publish()\n void refresh()\n return {\n face: (): UnrestrictedCardInjected => ({\n hooks: { view }, setEnabled, recheck, refresh, loadPreview,\n }),\n }\n}\n","/** Copy dictionaries for the unrestricted settings card. */\n\n/** Simplified Chinese dictionary and key source of truth. */\nexport const zh = {\n title: '破限模式',\n summaryEnabled: '已开启',\n summaryDisabled: '已关闭',\n summaryLoading: '读取中',\n summaryUnavailable: '设置不可用',\n summaryValidationFailed: '部分模式校验未通过',\n description: '开启后,各模式的系统提示词整体替换为以当前原版为底稿、融合破限规则的完整版本;关闭即恢复 DSH 原版提示词。从下一次请求和新建子代理开始生效,不改动正在执行的请求、工具定义、权限配置与会话历史。',\n toggle: '启用破限',\n scopeNote: '提示词仅由 DSH 生成时才受本插件控制;模型平台或宿主环境中更高优先级的规则不在覆盖范围内。',\n statusTitle: '各模式状态',\n modeStandard: 'Standard 标准模式',\n modePtc: 'PTC 模式',\n modeCordis: 'Cordis 创造模式',\n modeMinimal: 'Minimal 极简模式',\n subagentNote: '子代理随所属模式一并生效。',\n stateActive: '已生效',\n stateOff: '已关闭',\n stateChecking: '校验中',\n stateValidationFailed: '校验未通过,已保持原版',\n recheck: '重新校验',\n refresh: '刷新',\n preflightTitle: '本次即将写入的内容',\n fingerprint: '契约指纹',\n fingerprintNote: '与当前提示词一一对应。各模式实际部署的就是下面这段文本。',\n preset: '预设',\n presetStandard: 'standard',\n presetPtc: 'ptc',\n presetCordis: 'cordis',\n presetMinimal: 'minimal',\n showPreview: '查看预览',\n hidePreview: '收起预览',\n previewLoading: '正在组装当前提示词…',\n previewUnavailable: '暂不可预览:',\n previewSize: '行',\n settingsUnavailable: '当前连接不可写设置(远程浏览器只读)。',\n settingsLoading: '正在读取设置…',\n operationFailed: '操作失败:',\n} satisfies Record\n\n/** Unrestricted card locale key union. */\nexport type UnrestrictedLocaleKey = keyof typeof zh\n\n/** English dictionary checked against the Chinese key set. */\nexport const en = {\n title: 'Unrestricted mode',\n summaryEnabled: 'Enabled',\n summaryDisabled: 'Disabled',\n summaryLoading: 'Loading',\n summaryUnavailable: 'Settings unavailable',\n summaryValidationFailed: 'Some mode checks failed',\n description: 'When enabled, each mode\\'s system prompt is replaced wholesale by a fused prompt built on its current original; disabling restores the stock DSH prompt. Applies from the next request and new subagents; in-flight requests, tool definitions, permissions, and session history are never touched.',\n toggle: 'Enable unrestricted mode',\n scopeNote: 'This plugin can only rewrite prompts DSH generates itself; higher-priority rules from the model platform or host environment are out of scope.',\n statusTitle: 'Per-mode status',\n modeStandard: 'Standard',\n modePtc: 'PTC',\n modeCordis: 'Cordis',\n modeMinimal: 'Minimal',\n subagentNote: 'Subagents follow their parent\\'s mode.',\n stateActive: 'Active',\n stateOff: 'Off',\n stateChecking: 'Checking',\n stateValidationFailed: 'Check failed — stock prompt kept',\n recheck: 'Re-check',\n refresh: 'Refresh',\n preflightTitle: 'What this deployment would write',\n fingerprint: 'Contract fingerprint',\n fingerprintNote: 'One-to-one with the current prompt: the text below is exactly what each mode deploys.',\n preset: 'Preset',\n presetStandard: 'standard',\n presetPtc: 'ptc',\n presetCordis: 'cordis',\n presetMinimal: 'minimal',\n showPreview: 'Show preview',\n hidePreview: 'Hide preview',\n previewLoading: 'Assembling the current prompt…',\n previewUnavailable: 'No preview available: ',\n previewSize: 'lines',\n settingsUnavailable: 'This connection cannot write settings (remote browser is read-only).',\n settingsLoading: 'Reading settings…',\n operationFailed: 'Operation failed: ',\n} satisfies Record\n\n/** Dictionary namespace owned by this plugin. */\nexport const NS = 'settings.unrestricted'\n","/**\n * Stylesheet for the unrestricted settings card. One hand-written stylesheet\n * injected as a single