dsh-unrestricted: toggleable unrestricted-mode prompt fusion plugin

Fuses the unrestricted execution mode into each preset's original system
prompt at assembly time (standard/code/cordis via the system-prompt/assemble
waterfall, minimal via an agent-scoped complete persona shadow), covering
subagents, plan state, code-mode transport and structured-output delivery.
Anchored rewrites verify the installed DSH prompts before every fusion;
mismatches fall back to the stock prompt per mode and surface in the
settings card. Toggle persists in the unrestricted settings namespace.

Baseline: DSH 0.1.1-rc.1 (528c682e). docs/diff-rc.1.md itemizes every
kept/extended/inserted rule; tests replay fixtures captured from the
installed harness (tools/dump-prompts.mjs); tools/verify-live.mjs and
tools/verify-server.mjs carry the acceptance runs.
This commit is contained in:
yexi committed 2026-08-22 14:55:29 +08:00
commit aceb93ccd4
48 files changed
+9847

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
/**
* The unrestricted settings card: one persisted toggle plus the per-preset
* fusion state reported by the host half. All data arrives through the four
* props shares; the component holds no state of its own.
*/
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
// Type-only: the `settings.plugin.item` keyed slot declaration.
import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client'
import type { UnrestrictedCardInjected, UnrestrictedModeState } from './controller.ts'
import type { UnrestrictedLocaleKey } from './locales.ts'
/** Full component props assembled by the Settings slot renderer. */
export type UnrestrictedCardProps =
PropsRuntime<'settings.plugin.item'>
& PropsLocale<'settings.unrestricted'>
& InjectFace<UnrestrictedCardInjected>
/** Mode rows in display order, with their locale label keys. */
const MODE_ROWS: ReadonlyArray<{ id: string; labelKey: UnrestrictedLocaleKey }> = [
{ id: 'standard', labelKey: 'modeStandard' },
{ id: 'code', labelKey: 'modeCode' },
{ id: 'cordis', labelKey: 'modeCordis' },
{ id: 'minimal', labelKey: 'modeMinimal' },
]
/** Locale key for one mode state. */
function stateKey(mode: UnrestrictedModeState | undefined): UnrestrictedLocaleKey {
switch (mode?.state) {
case 'active': return 'stateActive'
case 'checking': return 'stateChecking'
case 'incompatible': return 'stateIncompatible'
default: return 'stateOff'
}
}
/**
* Render the unrestricted card.
* @param props - locale copy, the card snapshot, and its actions.
* @returns the card.
*/
export function UnrestrictedCard(props: UnrestrictedCardProps) {
const { t } = props
const view = props.useView(snapshot => snapshot)
const status = view.status
return (
<section className="dsh-unrestricted-card">
<h3 className="dsh-unrestricted-title">{t('title')}</h3>
<p className="dsh-unrestricted-description">{t('description')}</p>
<label className="dsh-unrestricted-toggle">
<input
type="checkbox"
checked={view.enabled}
disabled={!view.writable || view.settingsStatus !== 'ready'}
onChange={(event) => { void props.setEnabled(event.target.checked) }}
/>
<span>{t('toggle')}</span>
</label>
{view.settingsStatus === 'unavailable' && (
<p className="dsh-unrestricted-note">{t('settingsUnavailable')}</p>
)}
{view.message !== undefined && (
<p className="dsh-unrestricted-error">{t('operationFailed')}{view.message}</p>
)}
<h4 className="dsh-unrestricted-statusTitle">{t('statusTitle')}</h4>
<ul className="dsh-unrestricted-modes">
{MODE_ROWS.map((row) => {
const mode = status?.modes[row.id]
return (
<li key={row.id} className="dsh-unrestricted-mode">
<span className="dsh-unrestricted-dot" data-state={mode?.state ?? 'off'} />
<span className="dsh-unrestricted-modeName">{t(row.labelKey)}</span>
<span className="dsh-unrestricted-modeState">{t(stateKey(mode))}</span>
{mode !== undefined && mode.issues.length > 0 && (
<span className="dsh-unrestricted-issues">{mode.issues.join('; ')}</span>
)}
</li>
)
})}
</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>
<button type="button" onClick={() => { void props.refresh() }}>{t('refresh')}</button>
</div>
</section>
)
}