适配 master 当前提示词组合

This commit is contained in:
yexi committed 2026-08-31 07:52:34 +08:00
1 parent 057e473a6c
commit fdfecb09fc
18 files changed
+104 -143

No files matched your search

+6 -12
View File
@@ -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>
+2 -3
View File
@@ -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)
}
+4 -6
View File
@@ -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).',
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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.',