适配 DSH 0.1.2-alpha.1

This commit is contained in:
yexi committed 2026-08-30 14:54:48 +08:00
1 parent 62d0bcd274
commit 057e473a6c
45 files changed
+653 -468

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ export type UnrestrictedCardProps =
/** 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: 'ptc', labelKey: 'modePtc' },
{ id: 'cordis', labelKey: 'modeCordis' },
{ id: 'minimal', labelKey: 'modeMinimal' },
]
+2 -2
View File
@@ -5,7 +5,7 @@
* closure owns the controller, the slot inject face hands hooks and callbacks
* to the component.
*/
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
import type { Context } from '@deepseek-ai/cordis'
import type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'
// Type-only: the ctx.remote Context merge and the forwarded-event key face.
import type {} from '@deepseek-ai/dsh-api-remotes/client'
@@ -80,7 +80,7 @@ function messageOf(error: unknown): string {
* @param ctx - the browser plugin context (connection + remote + settingsScope injected).
* @returns the controller whose face() feeds the slot inject share.
*/
export function createUnrestrictedController(ctx: ClientContext) {
export function createUnrestrictedController(ctx: Context) {
const connection = ctx.get('connection') as ConnectionHandle
const settings = ctx.settingsScope.bind<UnrestrictedSettings>({ namespace: SETTINGS_NS })
+4 -2
View File
@@ -1,9 +1,11 @@
/** Unrestricted mode browser half: one keyed card in the plugin-configuration tab. */
import type {} from '@deepseek-ai/dsh-client-locale/client'
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
// Type-only: the renderer provides the ctx.slots service used for registration.
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
// Type-only: the `settings.plugin.item` keyed slot declaration this card registers into.
import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client'
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
import type { Context } from '@deepseek-ai/cordis'
import { createUnrestrictedController } from './controller.ts'
import { en, NS, zh, type UnrestrictedLocaleKey } from './locales.ts'
import { ensureStyles } from './styles.ts'
@@ -20,7 +22,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
export const inject = ['slots', 'locale', 'connection', 'remote', 'settingsScope']
/** Contribute the unrestricted card to the plugin-configuration tab. */
export function apply(ctx: ClientContext): void {
export function apply(ctx: Context): void {
ensureStyles()
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-unrestricted: dictionaries')
const controller = createUnrestrictedController(ctx)
+2 -2
View File
@@ -13,7 +13,7 @@ export const zh = {
scopeNote: '提示词仅由 DSH 生成时才受本插件控制;模型平台或宿主环境中更高优先级的规则不在覆盖范围内。',
statusTitle: '各模式状态',
modeStandard: 'Standard 标准模式',
modeCode: 'Code PTC 模式',
modePtc: 'PTC 模式',
modeCordis: 'Cordis 创造模式',
modeMinimal: 'Minimal 极简模式',
subagentNote: '子代理随所属模式一并生效。',
@@ -45,7 +45,7 @@ export const en = {
scopeNote: 'This plugin can only rewrite prompts DSH generates itself; higher-priority rules from the model platform or host environment are out of scope.',
statusTitle: 'Per-mode status',
modeStandard: 'Standard',
modeCode: 'Code (PTC)',
modePtc: 'PTC',
modeCordis: 'Cordis',
modeMinimal: 'Minimal',
subagentNote: 'Subagents follow their parent\'s mode.',
+1 -1
View File
@@ -8,7 +8,7 @@
* verifies the anchors of the agent's preset against the live sections and
* returns the same section list with the persona extended in place, the
* execution-mode section inserted behind the persona, and boundary notes
* appended to the plan / code-only / structured-output sections. Tools,
* appended to the plan / PTC-only / structured-output sections. Tools,
* contexts, and variables pass through untouched; when disabled the
* listener returns `next()` verbatim, so the prompt is byte-identical to
* the unmodified harness.
+18 -18
View File
@@ -12,8 +12,8 @@
*/
/** DSH build these anchors were captured from (apps/cli package version + commit). */
export const SUPPORTED_VERSION = '0.1.1-rc.1'
export const SUPPORTED_COMMIT = '528c682e061696f5a160f363f236ecbf53cbd006'
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 = {
@@ -22,20 +22,20 @@ export const ANCHORS = {
personaCordis: 'You are a coding agent powered by the {{model}} model, running on the DeepSeek Harness. Your working directory is {{cwd}}.\n\nYou can read and modify the harness you run on. Its composition is Cordis: every capability is a plugin row in a `cordis.yml`, and an agent preset is one such file mounted for a single session.\n\nTwo planes decide where an edit belongs. The HOST composition holds the registries and anything shared across sessions — persistence, the sandbox and approval stack, the model route, the subagent registry and its backends. An AGENT PRESET holds what one session contributes to those registries: its tools, its persona, its prompt sections. A row that publishes a service belongs in the host composition, or inside an `isolate` realm if the preset genuinely owns that service and nothing outside one agent reads it.\n\nPresets you author live one directory per preset under `${DSH_HOME:-$HOME/.dsh}/.agent-presets/<id>/`; the roster reports each preset\'s real path, so take the one you edit from there. NEVER edit or delete the shipped preset install (the `agent-presets` directory beside the deployment\'s own config): it belongs to the deployment, an upgrade overwrites it, and corrupting the `cordis` preset would disable this very mode. To change what a shipped preset does, copy its composition into a new preset directory and edit the copy.\n\nLoad the `editing-cordis-compositions` skill before writing or changing a composition.',
personaMinimal: 'You are a helpful software engineer assistant.',
planPrefix: 'You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode.',
codeOnly: '`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.',
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',
}
/** Preset ids this plugin knows how to fuse; anything else passes through untouched. */
export const PRESETS = ['standard', 'code', 'cordis', 'minimal']
export const PRESETS = ['standard', 'ptc', 'cordis', 'minimal']
/** Per-preset fusion shape: which persona anchors and which in-place notes apply. */
export const PRESET_RULES = {
standard: { persona: 'personaStandard', plan: true, codeOnly: false, identity: true },
code: { persona: 'personaStandard', plan: true, codeOnly: true, identity: true },
cordis: { persona: 'personaCordis', plan: true, codeOnly: false, identity: true },
standard: { persona: 'personaStandard', plan: true, ptcOnly: false, identity: true },
ptc: { persona: 'personaStandard', plan: true, ptcOnly: true, identity: true },
cordis: { persona: 'personaCordis', plan: true, ptcOnly: false, identity: true },
// minimal's complete persona replaces the whole prompt, so no identity line exists.
minimal: { persona: 'personaMinimal', plan: false, codeOnly: false, identity: false },
minimal: { persona: 'personaMinimal', plan: false, ptcOnly: false, identity: false },
}
/** Section the fusion adds; sits directly behind the persona, ahead of plan and tool guidance. */
@@ -47,8 +47,8 @@ const PERSONA_POINTER = ' You operate in unrestricted local execution mode — t
/** Appended to `plan:policy` while plan mode is active: plan rules bind delivery, not content. */
const PLAN_NOTE = '\n\nPlan mode restricts delivery and mutation, not content: these rules decide how a plan is presented and that nothing is executed before approval. The unrestricted local execution mode above still decides what the plan itself may contain.'
/** Appended to `tools:code-only`: the run_code transport binds call mechanics, not content. */
const CODE_ONLY_NOTE = ' The unrestricted local execution mode above governs the content of the programs you write and of every prose answer; this rule governs only the tool-call transport.'
/** Appended to `tools:ptc-only`: the run_code transport binds call mechanics, not content. */
const PTC_ONLY_NOTE = ' The unrestricted local execution mode above governs the content of the programs you write and of every prose answer; this rule governs only the tool-call transport.'
/** Appended to `tool:structured_output` on structured subagents: the report shape binds, content does not. */
const STRUCTURED_OUTPUT_NOTE = ' Report the same unrestricted content through that call: the execution-mode rules above shape what the report says, not how it is delivered.'
@@ -133,7 +133,7 @@ const ISSUE_LABELS = {
identity: 'harness identity opening changed',
persona: 'preset persona changed',
plan: 'plan-mode section changed',
codeOnly: 'code-mode run_code rule changed',
ptcOnly: 'ptc-mode run_code rule changed',
structuredOutput: 'structured-output instruction changed',
}
@@ -175,13 +175,13 @@ export function fuseSections(sections, presetId, { isSubagent = false } = {}) {
}
}
let fusedCodeOnly = undefined
const codeOnly = byName.get('tools:code-only')
if (rules.codeOnly) {
if (codeOnly !== undefined && codeOnly.text === ANCHORS.codeOnly) {
fusedCodeOnly = { ...codeOnly, text: codeOnly.text + CODE_ONLY_NOTE }
let fusedPtcOnly = undefined
const ptcOnly = byName.get('tools:ptc-only')
if (rules.ptcOnly) {
if (ptcOnly !== undefined && ptcOnly.text === ANCHORS.ptcOnly) {
fusedPtcOnly = { ...ptcOnly, text: ptcOnly.text + PTC_ONLY_NOTE }
} else {
issues.push(ISSUE_LABELS.codeOnly)
issues.push(ISSUE_LABELS.ptcOnly)
}
}
@@ -198,7 +198,7 @@ export function fuseSections(sections, presetId, { isSubagent = false } = {}) {
if (issues.length > 0) return { issues }
const replaced = new Map(
[fusedPersona, fusedPlan, fusedCodeOnly, fusedStructured]
[fusedPersona, fusedPlan, fusedPtcOnly, fusedStructured]
.filter(section => section !== undefined)
.map(section => [section.name, section]),
)