mirror of
https://github.com/yexi-by/dsh-unrestricted.git
synced 2026-11-28 02:30:22 +08:00
适配 master 当前提示词组合
This commit is contained in:
1 parent
057e473a6c
commit
d3b490a915
18 files changed
+104
-143
No files matched your search
@@ -9,7 +9,7 @@ DSH 原版提示词。
|
||||
下面的命令把当前稳定版本安装到 DSH 的 `web` profile:
|
||||
|
||||
```sh
|
||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.1.3
|
||||
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.1.4
|
||||
```
|
||||
|
||||
安装后重启 `dsh web`,然后进入
|
||||
@@ -42,21 +42,20 @@ DSH 的原版系统提示词主要规定 agent 身份、计划模式和工具调
|
||||
优先级规则。开关只影响下一次请求和之后新建的子代理,不会改写正在执行的请求、工具
|
||||
定义、权限配置或既有会话历史。
|
||||
|
||||
## 工作方式与兼容性
|
||||
## 工作方式
|
||||
|
||||
- Standard / PTC / Cordis:在运行时通过 `system-prompt/assemble` waterfall 读取当前
|
||||
模式的完整原版提示词,校验关键锚点后插入破限规则。
|
||||
- Minimal:由于原版 persona 使用 `complete: true`,插件用 agent 作用域的同名 persona
|
||||
覆盖,并保留原 persona 作为开头。
|
||||
- 子代理和 plan 状态:沿用父模式的融合结果,同时保留结构化输出与 plan 协议。
|
||||
- 兼容检查:每次融合前核对 harness 身份、各模式 persona、plan 段首句、`run_code`
|
||||
规则和 structured-output 首句。任一锚点不匹配时,该模式保持原版提示词,并在设置卡片
|
||||
中显示不兼容项,不会静默套用旧版规则。
|
||||
- 当前提示词校验:每次融合前核对 harness 身份、各模式 persona、plan 段首句、`run_code`
|
||||
规则和 structured-output 首句。校验未通过时,该模式保持原版提示词,并在设置卡片中显示
|
||||
具体问题。
|
||||
|
||||
当前支持基线为 DSH `0.1.2-alpha.1`,commit
|
||||
`cd5ef8148158c3a752a658978873241fdf8e2bbc`。该版本把原 `code` preset 定名为
|
||||
`ptc`,对应提示词段为 `tools:ptc-only`;插件、状态卡、测试 fixture 和验收工具均按
|
||||
当前名称工作。完整改写清单见[原版与融合版差异说明](docs/diff-alpha.1.md)。
|
||||
插件直接面向 DSH 当前 `master`,使用当前的 `ptc` preset、`tools:ptc-only` 段和
|
||||
字符串 settings namespace。完整改写清单见
|
||||
[当前 master 提示词融合说明](docs/prompt-fusion.md)。
|
||||
|
||||
## 更新与卸载
|
||||
|
||||
@@ -82,7 +81,7 @@ codex-keysmith 由 Jia-Ethan 以 MIT License 发布。原作者版权和许可
|
||||
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。本项目自身同样使用
|
||||
[MIT License](LICENSE)。
|
||||
|
||||
仓库中的版本锚点和测试 fixtures 还包含 DeepSeek Harness 的原版提示词片段;对应的
|
||||
仓库中的当前提示词锚点和测试 fixtures 还包含 DeepSeek Harness 的原版提示词片段;对应的
|
||||
DeepSeek 版权与 MIT 许可也保留在 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
|
||||
|
||||
## 从源码开发
|
||||
@@ -119,7 +118,7 @@ node tools/verify-server.mjs --base http://127.0.0.1:5199
|
||||
|
||||
```text
|
||||
src/rules.js 锚点、破限提示词和融合纯函数
|
||||
src/node.js host 端:提示词改写、设置开关和兼容状态
|
||||
src/node.js host 端:提示词改写、设置开关和当前提示词校验状态
|
||||
src/client/ Web 端:设置卡片、开关和各模式状态
|
||||
lib/client.js 随仓库提交的 Web 构建产物
|
||||
tests/ 规则测试与 DSH 原版提示词 fixtures
|
||||
|
||||
@@ -35,9 +35,9 @@ SOFTWARE.
|
||||
|
||||
## DeepSeek Harness
|
||||
|
||||
`src/rules.js` 中的兼容锚点和 `tests/fixtures/` 中的原版提示词来自
|
||||
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness/tree/cd5ef8148158c3a752a658978873241fdf8e2bbc)
|
||||
`0.1.2-alpha.1`。
|
||||
`src/rules.js` 中的当前提示词锚点和 `tests/fixtures/` 中的原版提示词来自
|
||||
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness/tree/0a53fb55bea101816fa226bb964ae2bed71c343b)
|
||||
`0.1.2-alpha.2`。
|
||||
|
||||
原项目使用以下许可证:
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
# 原版与融合版差异说明(DSH 0.1.2-alpha.1)
|
||||
|
||||
本文记录 dsh-unrestricted 在 DSH commit
|
||||
`cd5ef8148158c3a752a658978873241fdf8e2bbc` 上的提示词融合行为。原版提示词由
|
||||
`tools/dump-prompts.mjs` 从真实 Web composition 组装并保存到 `tests/fixtures/`。
|
||||
|
||||
## 融合规则
|
||||
|
||||
插件保留原版全部提示词段、动态上下文、工具 schema 与变量,并做四项定向追加:
|
||||
|
||||
1. 在 `deployment:persona` 末尾加入执行模式指针。
|
||||
2. 在 persona 后插入 `unrestricted:execution-mode` 段。
|
||||
3. plan 激活时,在 `plan:policy` 末尾说明 plan 负责交付与变更边界,执行模式负责内容尺度。
|
||||
4. PTC 与结构化子代理分别在 `tools:ptc-only`、`tool:structured_output` 末尾保留其交付协议。
|
||||
|
||||
融合段只决定回答内容与表达尺度。工具目录、调用协议、plan、审批、沙箱、结构化输出和
|
||||
模式边界继续由 DSH 原版规则决定。
|
||||
|
||||
## 各 preset
|
||||
|
||||
### Standard
|
||||
|
||||
原版由 `harness:identity`、`deployment:persona`、`plan:policy`、文件引用上下文、工具指导和
|
||||
交付文件引用共 19 段组成。插件追加 persona 指针和执行模式段;plan 激活时再追加 plan
|
||||
边界说明。原段内容与工具目录保持不变。
|
||||
|
||||
### PTC
|
||||
|
||||
PTC 使用官方 `ptc` preset,并在 Standard 的基础上带有 `tools:ptc-only` 和 `tools:sdk`。
|
||||
插件保留 `run_code` 唯一直接工具规则与完整 SDK,在 `tools:ptc-only` 末尾加入内容尺度
|
||||
说明。官方 `0.1.2-alpha.1` 已使用 `ptc` 和 `tools:ptc-only` 作为当前名称。
|
||||
|
||||
### Cordis
|
||||
|
||||
Cordis 保留完整的两平面 persona、动态 Cordis 工具说明和其余工具指导。插件在 persona
|
||||
后加入执行模式段;plan 激活时追加同一边界说明。
|
||||
|
||||
### Minimal
|
||||
|
||||
Minimal 的 `deployment:persona` 使用 `complete: true`。插件在 agent 作用域注册同名完整
|
||||
persona,使其成为“原单句 persona + 指针 + 执行模式段”;关闭开关时移除该作用域覆盖。
|
||||
|
||||
### 子代理
|
||||
|
||||
进程内子代理沿用父 agent 的 preset 作用域,因此自动获得对应融合结果。带结构化输出的
|
||||
子代理继续通过 `structured_output` 提交结果,插件只在该段末尾补充内容尺度说明。
|
||||
|
||||
## 兼容校验
|
||||
|
||||
每个 preset 在启用时接受 standing-scope 校验,并在每次实际组装时再次校验。校验对象为
|
||||
harness 身份、persona、plan 首句、PTC 的 `run_code` 规则和结构化输出首句。任一锚点变化
|
||||
时,该 preset 直接使用当次 DSH 原版提示词,设置卡显示具体不兼容项。
|
||||
|
||||
更新 DSH 后执行以下命令刷新事实基线并验证:
|
||||
|
||||
```sh
|
||||
node tools/dump-prompts.mjs --repo <deepseek-harness-path> --out tests/fixtures
|
||||
pnpm test
|
||||
node tools/verify-live.mjs --repo <deepseek-harness-path>
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
# 当前 master 提示词融合说明
|
||||
|
||||
本文记录 dsh-unrestricted 在当前 DSH `master` 上的提示词融合行为。`tools/dump-prompts.mjs` 从真实 Web composition 组装原版提示词并保存到 `tests/fixtures/`。
|
||||
|
||||
## 融合规则
|
||||
|
||||
插件保留原版全部提示词段、动态上下文、工具 schema 与变量,并做四项定向追加:
|
||||
|
||||
1. 在 `deployment:persona` 末尾加入执行模式指针。
|
||||
2. 在 persona 后插入 `unrestricted:execution-mode` 段。
|
||||
3. plan 激活时,在 `plan:policy` 末尾说明 plan 负责交付与变更范围,执行模式负责内容尺度。
|
||||
4. PTC 与结构化子代理分别在 `tools:ptc-only`、`tool:structured_output` 末尾保留其交付协议。
|
||||
|
||||
融合段决定回答内容与表达尺度。工具目录、调用协议、plan、审批、沙箱、结构化输出和模式范围继续由 DSH 原版规则决定。
|
||||
|
||||
## 各 preset
|
||||
|
||||
### Standard
|
||||
|
||||
插件在 persona 后加入执行模式段;plan 激活时再追加 plan 说明。原段内容与工具目录保持不变。
|
||||
|
||||
### PTC
|
||||
|
||||
PTC 使用当前 `ptc` preset,并在 Standard 的基础上带有 `tools:ptc-only` 和 `tools:sdk`。插件保留 `run_code` 唯一直接工具规则与完整 SDK,在 `tools:ptc-only` 末尾加入内容尺度说明。
|
||||
|
||||
### Cordis
|
||||
|
||||
Cordis 保留完整的两平面 persona、动态 Cordis 工具说明和其余工具指导。插件在 persona 后加入执行模式段;plan 激活时追加同一说明。
|
||||
|
||||
### Minimal
|
||||
|
||||
Minimal 的 `deployment:persona` 使用 `complete: true`。插件在 agent 作用域注册同名完整 persona,使其成为“原单句 persona + 指针 + 执行模式段”;关闭开关时移除该作用域覆盖。完整 persona 最终成为唯一提示词段,因此插件使用自身的有限顺序值,不依赖仓内 section 顺序名称。
|
||||
|
||||
### 子代理
|
||||
|
||||
进程内子代理沿用父 agent 的 preset 作用域,因此获得对应融合结果。带结构化输出的子代理继续通过 `structured_output` 提交结果,插件只在该段末尾补充内容尺度说明。
|
||||
|
||||
## 当前提示词校验
|
||||
|
||||
每个 preset 在启用时接受 standing-scope 校验,并在每次实际组装时再次校验。校验对象为 harness 身份、persona、plan 首句、PTC 的 `run_code` 规则和结构化输出首句。锚点变化或探测失败时,该 preset 直接使用当次 DSH 原版提示词,设置卡显示具体问题。
|
||||
|
||||
更新 DSH master 后执行以下命令刷新事实基线并验证:
|
||||
|
||||
```sh
|
||||
node tools/dump-prompts.mjs --repo <deepseek-harness-path> --out tests/fixtures
|
||||
pnpm test
|
||||
node tools/verify-live.mjs --repo <deepseek-harness-path>
|
||||
```
|
||||
+9
-15
@@ -112,7 +112,7 @@ window.__ModuleLoader__.load({
|
||||
summaryDisabled: "已关闭",
|
||||
summaryLoading: "读取中",
|
||||
summaryUnavailable: "设置不可用",
|
||||
summaryIncompatible: "部分模式不兼容",
|
||||
summaryValidationFailed: "部分模式校验未通过",
|
||||
description: "开启后,各模式的系统提示词整体替换为以当前原版为底稿、融合破限规则的完整版本;关闭即恢复 DSH 原版提示词。从下一次请求和新建子代理开始生效,不改动正在执行的请求、工具定义、权限配置与会话历史。",
|
||||
toggle: "启用破限",
|
||||
scopeNote: "提示词仅由 DSH 生成时才受本插件控制;模型平台或宿主环境中更高优先级的规则不在覆盖范围内。",
|
||||
@@ -125,8 +125,7 @@ window.__ModuleLoader__.load({
|
||||
stateActive: "已生效",
|
||||
stateOff: "已关闭",
|
||||
stateChecking: "校验中",
|
||||
stateIncompatible: "版本不兼容,已保持原版",
|
||||
supported: "锚点校验基线(DSH 更新导致原版提示词变化时,对应模式自动回退原版并在此提示):",
|
||||
stateValidationFailed: "校验未通过,已保持原版",
|
||||
recheck: "重新校验",
|
||||
refresh: "刷新",
|
||||
settingsUnavailable: "当前连接不可写设置(远程浏览器只读)。",
|
||||
@@ -140,7 +139,7 @@ window.__ModuleLoader__.load({
|
||||
summaryDisabled: "Disabled",
|
||||
summaryLoading: "Loading",
|
||||
summaryUnavailable: "Settings unavailable",
|
||||
summaryIncompatible: "Some modes incompatible",
|
||||
summaryValidationFailed: "Some mode checks failed",
|
||||
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.",
|
||||
toggle: "Enable unrestricted mode",
|
||||
scopeNote: "This plugin can only rewrite prompts DSH generates itself; higher-priority rules from the model platform or host environment are out of scope.",
|
||||
@@ -153,8 +152,7 @@ window.__ModuleLoader__.load({
|
||||
stateActive: "Active",
|
||||
stateOff: "Off",
|
||||
stateChecking: "Checking",
|
||||
stateIncompatible: "Incompatible — stock prompt kept",
|
||||
supported: "Anchor-check baseline (when a DSH update changes an original prompt, that mode falls back to the stock prompt and reports here):",
|
||||
stateValidationFailed: "Check failed — stock prompt kept",
|
||||
recheck: "Re-check",
|
||||
refresh: "Refresh",
|
||||
settingsUnavailable: "This connection cannot write settings (remote browser is read-only).",
|
||||
@@ -349,7 +347,7 @@ window.__ModuleLoader__.load({
|
||||
background: var(--dsw-alias-state-business-primary);
|
||||
}
|
||||
|
||||
.dsh-unrestricted-dot[data-state='incompatible'] {
|
||||
.dsh-unrestricted-dot[data-state='failed'] {
|
||||
background: var(--dsw-alias-state-error-primary);
|
||||
}
|
||||
|
||||
@@ -435,7 +433,7 @@ window.__ModuleLoader__.load({
|
||||
switch (mode?.state) {
|
||||
case "active": return "stateActive";
|
||||
case "checking": return "stateChecking";
|
||||
case "incompatible": return "stateIncompatible";
|
||||
case "failed": return "stateValidationFailed";
|
||||
default: return "stateOff";
|
||||
}
|
||||
}
|
||||
@@ -448,9 +446,9 @@ window.__ModuleLoader__.load({
|
||||
const { t } = props;
|
||||
const view = props.useView((snapshot) => snapshot);
|
||||
const status = view.status;
|
||||
const hasIncompatibleMode = status !== null && Object.values(status.modes).some((mode) => mode.state === "incompatible");
|
||||
const summaryKey = view.settingsStatus === "loading" ? "summaryLoading" : view.settingsStatus === "unavailable" ? "summaryUnavailable" : hasIncompatibleMode ? "summaryIncompatible" : view.enabled ? "summaryEnabled" : "summaryDisabled";
|
||||
const summaryState = view.settingsStatus === "ready" ? hasIncompatibleMode ? "error" : view.enabled ? "active" : "off" : "pending";
|
||||
const hasFailedMode = status !== null && Object.values(status.modes).some((mode) => mode.state === "failed");
|
||||
const summaryKey = view.settingsStatus === "loading" ? "summaryLoading" : view.settingsStatus === "unavailable" ? "summaryUnavailable" : hasFailedMode ? "summaryValidationFailed" : view.enabled ? "summaryEnabled" : "summaryDisabled";
|
||||
const summaryState = view.settingsStatus === "ready" ? hasFailedMode ? "error" : view.enabled ? "active" : "off" : "pending";
|
||||
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
||||
className: "dsh-unrestricted-card",
|
||||
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
||||
@@ -529,10 +527,6 @@ window.__ModuleLoader__.load({
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("subagentNote")
|
||||
}),
|
||||
status !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: [t("supported"), ` DSH ${status.supported.version}(${status.supported.commit.slice(0, 7)})。`]
|
||||
}),
|
||||
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
||||
className: "dsh-unrestricted-note",
|
||||
children: t("scopeNote")
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"client.js","names":[],"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' | 'incompatible'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n modes: Record<string, UnrestrictedModeState>\n supported: { version: string; commit: 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 /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult<T> = { 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<void>\n /** Re-run the host-side anchor checks and refresh. */\n recheck: () => Promise<void>\n /** Re-read host status. */\n refresh: () => Promise<void>\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<UnrestrictedSettings>({ namespace: SETTINGS_NS })\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\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 message: snapshot.message,\n }\n for (const listener of listeners) listener()\n }\n\n async function call<T>(endpoint: string, payload: unknown): Promise<T> {\n const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload) as RpcResult<T>\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n }\n\n async function refresh(): Promise<void> {\n try {\n const status = await call<UnrestrictedStatus>('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<void> {\n await settings.set('enabled', enabled)\Line truncated
|
||||
{"version":3,"file":"client.js","names":[],"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 modes: Record<string, UnrestrictedModeState>\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 /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult<T> = { 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<void>\n /** Re-run the host-side anchor checks and refresh. */\n recheck: () => Promise<void>\n /** Re-read host status. */\n refresh: () => Promise<void>\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<UnrestrictedSettings>({ namespace: SETTINGS_NS })\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\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 message: snapshot.message,\n }\n for (const listener of listeners) listener()\n }\n\n async function call<T>(endpoint: string, payload: unknown): Promise<T> {\n const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload) as RpcResult<T>\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n }\n\n async function refresh(): Promise<void> {\n try {\n const status = await call<UnrestrictedStatus>('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<void> {\n await settings.set('enabled', enabled)\n publish()\n // Give the host settings watcher onLine truncated
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "dsh-unrestricted",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"description": "Toggleable unrestricted mode for DSH Web: fuses the unrestricted execution mode into each preset's original system prompt (standard/ptc/cordis/minimal + subagents), with per-mode anchor verification and automatic fallback to the stock prompt",
|
||||
"description": "Toggleable unrestricted mode for the current DSH master: fuses execution rules into the active standard, ptc, cordis, minimal, and subagent prompts",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -28,7 +28,7 @@ function stateKey(mode: UnrestrictedModeState | undefined): UnrestrictedLocaleKe
|
||||
switch (mode?.state) {
|
||||
case 'active': return 'stateActive'
|
||||
case 'checking': return 'stateChecking'
|
||||
case 'incompatible': return 'stateIncompatible'
|
||||
case 'failed': return 'stateValidationFailed'
|
||||
default: return 'stateOff'
|
||||
}
|
||||
}
|
||||
@@ -42,17 +42,17 @@ export function UnrestrictedCard(props: UnrestrictedCardProps) {
|
||||
const { t } = props
|
||||
const view = props.useView(snapshot => snapshot)
|
||||
const status = view.status
|
||||
const hasIncompatibleMode = status !== null
|
||||
&& Object.values(status.modes).some(mode => mode.state === 'incompatible')
|
||||
const hasFailedMode = status !== null
|
||||
&& Object.values(status.modes).some(mode => mode.state === 'failed')
|
||||
const summaryKey: UnrestrictedLocaleKey = view.settingsStatus === 'loading'
|
||||
? 'summaryLoading'
|
||||
: view.settingsStatus === 'unavailable'
|
||||
? 'summaryUnavailable'
|
||||
: hasIncompatibleMode
|
||||
? 'summaryIncompatible'
|
||||
: hasFailedMode
|
||||
? 'summaryValidationFailed'
|
||||
: view.enabled ? 'summaryEnabled' : 'summaryDisabled'
|
||||
const summaryState = view.settingsStatus === 'ready'
|
||||
? hasIncompatibleMode ? 'error' : view.enabled ? 'active' : 'off'
|
||||
? hasFailedMode ? 'error' : view.enabled ? 'active' : 'off'
|
||||
: 'pending'
|
||||
return (
|
||||
<details className="dsh-unrestricted-card">
|
||||
@@ -96,12 +96,6 @@ export function UnrestrictedCard(props: UnrestrictedCardProps) {
|
||||
})}
|
||||
</ul>
|
||||
<p className="dsh-unrestricted-note">{t('subagentNote')}</p>
|
||||
{status !== null && (
|
||||
<p className="dsh-unrestricted-note">
|
||||
{t('supported')}
|
||||
{` DSH ${status.supported.version}(${status.supported.commit.slice(0, 7)})。`}
|
||||
</p>
|
||||
)}
|
||||
<p className="dsh-unrestricted-note">{t('scopeNote')}</p>
|
||||
<div className="dsh-unrestricted-actions">
|
||||
<button type="button" onClick={() => { void props.recheck() }}>{t('recheck')}</button>
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface UnrestrictedSettings {
|
||||
|
||||
/** Per-preset fusion state reported by the host half. */
|
||||
export interface UnrestrictedModeState {
|
||||
state: 'off' | 'checking' | 'active' | 'incompatible'
|
||||
state: 'off' | 'checking' | 'active' | 'failed'
|
||||
issues: string[]
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ export interface UnrestrictedModeState {
|
||||
export interface UnrestrictedStatus {
|
||||
enabled: boolean
|
||||
modes: Record<string, UnrestrictedModeState>
|
||||
supported: { version: string; commit: string }
|
||||
}
|
||||
|
||||
/** Full view snapshot the card subscribes to. */
|
||||
@@ -132,7 +131,7 @@ export function createUnrestrictedController(ctx: Context) {
|
||||
async function setEnabled(enabled: boolean): Promise<void> {
|
||||
await settings.set('enabled', enabled)
|
||||
publish()
|
||||
// The host applies the toggle on the same commit; give it one turn first.
|
||||
// Give the host settings watcher one turn before reading its derived state.
|
||||
setTimeout(() => void refresh(), 300)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export const zh = {
|
||||
summaryDisabled: '已关闭',
|
||||
summaryLoading: '读取中',
|
||||
summaryUnavailable: '设置不可用',
|
||||
summaryIncompatible: '部分模式不兼容',
|
||||
summaryValidationFailed: '部分模式校验未通过',
|
||||
description: '开启后,各模式的系统提示词整体替换为以当前原版为底稿、融合破限规则的完整版本;关闭即恢复 DSH 原版提示词。从下一次请求和新建子代理开始生效,不改动正在执行的请求、工具定义、权限配置与会话历史。',
|
||||
toggle: '启用破限',
|
||||
scopeNote: '提示词仅由 DSH 生成时才受本插件控制;模型平台或宿主环境中更高优先级的规则不在覆盖范围内。',
|
||||
@@ -20,8 +20,7 @@ export const zh = {
|
||||
stateActive: '已生效',
|
||||
stateOff: '已关闭',
|
||||
stateChecking: '校验中',
|
||||
stateIncompatible: '版本不兼容,已保持原版',
|
||||
supported: '锚点校验基线(DSH 更新导致原版提示词变化时,对应模式自动回退原版并在此提示):',
|
||||
stateValidationFailed: '校验未通过,已保持原版',
|
||||
recheck: '重新校验',
|
||||
refresh: '刷新',
|
||||
settingsUnavailable: '当前连接不可写设置(远程浏览器只读)。',
|
||||
@@ -39,7 +38,7 @@ export const en = {
|
||||
summaryDisabled: 'Disabled',
|
||||
summaryLoading: 'Loading',
|
||||
summaryUnavailable: 'Settings unavailable',
|
||||
summaryIncompatible: 'Some modes incompatible',
|
||||
summaryValidationFailed: 'Some mode checks failed',
|
||||
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.',
|
||||
toggle: 'Enable unrestricted mode',
|
||||
scopeNote: 'This plugin can only rewrite prompts DSH generates itself; higher-priority rules from the model platform or host environment are out of scope.',
|
||||
@@ -52,8 +51,7 @@ export const en = {
|
||||
stateActive: 'Active',
|
||||
stateOff: 'Off',
|
||||
stateChecking: 'Checking',
|
||||
stateIncompatible: 'Incompatible — stock prompt kept',
|
||||
supported: 'Anchor-check baseline (when a DSH update changes an original prompt, that mode falls back to the stock prompt and reports here):',
|
||||
stateValidationFailed: 'Check failed — stock prompt kept',
|
||||
recheck: 'Re-check',
|
||||
refresh: 'Refresh',
|
||||
settingsUnavailable: 'This connection cannot write settings (remote browser is read-only).',
|
||||
|
||||
@@ -183,7 +183,7 @@ const CSS = `
|
||||
background: var(--dsw-alias-state-business-primary);
|
||||
}
|
||||
|
||||
.dsh-unrestricted-dot[data-state='incompatible'] {
|
||||
.dsh-unrestricted-dot[data-state='failed'] {
|
||||
background: var(--dsw-alias-state-error-primary);
|
||||
}
|
||||
|
||||
|
||||
+7
-12
@@ -17,9 +17,9 @@
|
||||
* minimal agents (joined or later created) the plugin shadows
|
||||
* `deployment:persona` at agent scope with a complete section carrying the
|
||||
* fused minimal prompt.
|
||||
* - Anchor failures (startup standing-scope check or any live assembly) mark
|
||||
* the preset incompatible: its prompt passes through unchanged and the
|
||||
* settings card shows the failure. Nothing stale is ever delivered.
|
||||
* - Anchor failures (startup standing-scope check or any live assembly) leave
|
||||
* that prompt unchanged and show the failed current-master invariant in the
|
||||
* settings card.
|
||||
*
|
||||
* The toggle lives in the `unrestricted` settings namespace (persisted to
|
||||
* $DSH_HOME/settings.yaml). Switching affects the NEXT assembly of any live
|
||||
@@ -27,8 +27,7 @@
|
||||
*/
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import {
|
||||
ANCHORS, PRESETS, PRESET_RULES, SUPPORTED_COMMIT, SUPPORTED_VERSION,
|
||||
fuseSections, fusedMinimalPrompt,
|
||||
ANCHORS, PRESETS, PRESET_RULES, fuseSections, fusedMinimalPrompt,
|
||||
} from './rules.js'
|
||||
|
||||
/** Cordis plugin name used by Loader diagnostics. */
|
||||
@@ -169,7 +168,7 @@ export function apply(ctx) {
|
||||
clearShadows()
|
||||
}
|
||||
|
||||
/** Current card view: toggle, per-preset state, and the build this plugin supports. */
|
||||
/** Current card view: toggle and per-preset state. */
|
||||
function statusPayload() {
|
||||
const modes = {}
|
||||
for (const presetId of PRESETS) {
|
||||
@@ -179,15 +178,11 @@ export function apply(ctx) {
|
||||
? 'off'
|
||||
: !state.startup.has(presetId)
|
||||
? 'checking'
|
||||
: issues.length > 0 ? 'incompatible' : 'active',
|
||||
: issues.length > 0 ? 'failed' : 'active',
|
||||
issues,
|
||||
}
|
||||
}
|
||||
return {
|
||||
enabled: state.enabled,
|
||||
modes,
|
||||
supported: { version: SUPPORTED_VERSION, commit: SUPPORTED_COMMIT },
|
||||
}
|
||||
return { enabled: state.enabled, modes }
|
||||
}
|
||||
|
||||
/** RPC endpoint handler for the settings card. */
|
||||
|
||||
+5
-10
@@ -1,20 +1,15 @@
|
||||
/**
|
||||
* dsh-unrestricted fusion rules: verbatim anchors for the shipped DSH prompts
|
||||
* dsh-unrestricted fusion rules: verbatim anchors for the current master prompts
|
||||
* and the pure functions that fuse the unrestricted execution mode into them.
|
||||
*
|
||||
* Every rewrite is anchored on exact original text captured from the installed
|
||||
* harness (see tools/dump-prompts.mjs and tests/fixtures/). An anchor that no
|
||||
* longer matches means the harness changed underneath us: callers must then
|
||||
* leave the original prompt untouched and surface the incompatibility instead
|
||||
* of silently shipping a stale prompt.
|
||||
* Every rewrite is anchored on exact original text captured from master (see
|
||||
* tools/dump-prompts.mjs and tests/fixtures/). When an anchor no longer
|
||||
* matches, callers leave the current prompt untouched and surface the failed
|
||||
* invariant.
|
||||
*
|
||||
* @module dsh-unrestricted/rules
|
||||
*/
|
||||
|
||||
/** DSH build these anchors were captured from (apps/cli package version + commit). */
|
||||
export const SUPPORTED_VERSION = '0.1.2-alpha.1'
|
||||
export const SUPPORTED_COMMIT = 'cd5ef8148158c3a752a658978873241fdf8e2bbc'
|
||||
|
||||
/** Exact original section texts / prefixes, verified per assembly before any rewrite. */
|
||||
export const ANCHORS = {
|
||||
identity: 'You are an AI agent powered by DeepSeek Harness.',
|
||||
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"fixtureCwd": "/workspace/dsh-unrestricted",
|
||||
"commit": "cd5ef8148158c3a752a658978873241fdf8e2bbc",
|
||||
"capturedAt": "2026-08-30T06:45:38.696Z",
|
||||
"commit": "0a53fb55bea101816fa226bb964ae2bed71c343b",
|
||||
"capturedAt": "2026-08-30T22:38:26.758Z",
|
||||
"dumps": {
|
||||
"standard": {
|
||||
"sections": [
|
||||
|
||||
@@ -4,7 +4,7 @@ import { test } from 'node:test'
|
||||
|
||||
const manifest = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))
|
||||
|
||||
test('declares the alpha.1 client renderer and settings dependencies', () => {
|
||||
test('declares the current master client renderer and settings dependencies', () => {
|
||||
assert.deepEqual(manifest.dsh.client.inject, [
|
||||
'@deepseek-ai/dsh-client-connection',
|
||||
'@deepseek-ai/dsh-client-locale',
|
||||
|
||||
@@ -148,7 +148,7 @@ test('plan-mode tampering is detected only when the section is active', async ()
|
||||
assert.equal(fuseSections(onExtended, 'standard').issues, undefined)
|
||||
})
|
||||
|
||||
test('ptc mode loses its run_code anchor -> incompatible', async () => {
|
||||
test('ptc mode reports a changed run_code anchor', async () => {
|
||||
const sections = await sectionsOf('ptc')
|
||||
const tampered = sections.map(section =>
|
||||
section.name === 'tools:ptc-only' ? { ...section, text: 'call whatever' } : section)
|
||||
|
||||
@@ -43,7 +43,6 @@ const appBoot = await importPackage('packages/boot/app-boot')
|
||||
const cmdline = await importPackage('packages/boot/cmdline')
|
||||
const { SessionId } = await importPackage('packages/core/session')
|
||||
const { renderPrompt } = await importPackage('packages/core/system-prompt')
|
||||
const { settingsNamespace } = await importPackage('packages/settings/settings')
|
||||
const { applyChildComposition, childSessionMeta } = await importPackage('packages/subagent/subagent')
|
||||
const rules = await import(pathToFileURL(join(pluginDir, 'src/rules.js')).href)
|
||||
|
||||
@@ -141,7 +140,7 @@ async function assemblePrompt(agent) {
|
||||
}
|
||||
|
||||
async function setEnabled(enabled) {
|
||||
await ctx.settings.update(settingsNamespace('unrestricted'), { enabled })
|
||||
await ctx.settings.update('unrestricted', { enabled })
|
||||
}
|
||||
|
||||
/** Poll until the predicate holds or the deadline passes. */
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import { defineConfig } from 'tsdown'
|
||||
|
||||
const ID = 'dsh-unrestricted'
|
||||
|
||||
/** Implicit baseline answered by the alpha.1 Web shell's frozen module table. */
|
||||
/** Platform modules supplied by the current Web shell. */
|
||||
const EXTERNALS: readonly string[] = [
|
||||
'react',
|
||||
'react/jsx-runtime',
|
||||
|
||||
Reference in new issue
Block a user