mirror of
https://github.com/yexi-by/dsh-unrestricted.git
synced 2026-11-28 02:30:22 +08:00
feat: 新增隐藏宿主品牌标识开关,精简破限提示词并移除实时预览污染(v0.2.12)
This commit is contained in:
1 parent
849fc35ac5
commit
6da4c81b5e
18 files changed
+421
-111
No files matched your search
@@ -55,7 +55,12 @@ async function fixture() {
|
||||
view: () => face.hooks.view.getSnapshot(),
|
||||
documentUpdated: () => events.get('settings/document-updated')('unrestricted'),
|
||||
commitEnabled(enabled) {
|
||||
value = { enabled }
|
||||
value = { ...value, enabled }
|
||||
for (const listener of subscribers) listener()
|
||||
events.get('settings/document-updated')('unrestricted')
|
||||
},
|
||||
commitSettings(patch) {
|
||||
value = { ...value, ...patch }
|
||||
for (const listener of subscribers) listener()
|
||||
events.get('settings/document-updated')('unrestricted')
|
||||
},
|
||||
@@ -145,3 +150,27 @@ test('开关提交立即使旧预览失效,配置事件刷新不能提前结
|
||||
assert.equal(f.view().busy, false)
|
||||
assert.equal(f.view().status.enabled, false)
|
||||
})
|
||||
|
||||
test('切换隐藏宿主品牌标识立即使旧预览失效并在提交后同步状态', async () => {
|
||||
const f = await fixture()
|
||||
const preview = f.face.loadPreview('standard')
|
||||
f.answer(f.take('preview'), { available: true, text: 'with brand' })
|
||||
await preview
|
||||
assert.equal(f.view().previews.standard.preview.text, 'with brand')
|
||||
assert.equal(f.view().stripHostIdentity, false)
|
||||
|
||||
const writing = f.face.setStripHostIdentity(true)
|
||||
const writeRequest = f.take('write')
|
||||
assert.deepEqual(writeRequest.payload, { field: 'stripHostIdentity', next: true })
|
||||
f.commitSettings({ stripHostIdentity: true })
|
||||
assert.equal(f.view().stripHostIdentity, true)
|
||||
assert.equal(f.view().previews.standard, undefined)
|
||||
|
||||
f.answer(f.take('status'), { ...status('0.2.12', true), stripHostIdentity: true })
|
||||
writeRequest.resolve(true)
|
||||
await settle()
|
||||
f.answer(f.take('status'), { ...status('0.2.12', true), stripHostIdentity: true })
|
||||
await writing
|
||||
assert.equal(f.view().busy, false)
|
||||
assert.equal(f.view().status.stripHostIdentity, true)
|
||||
})
|
||||
+68
-11
@@ -11,8 +11,10 @@ import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
ANCHORS, BLOCK_SECTION, EXECUTION_MODE_BLOCK, PRESETS, contractAdditions,
|
||||
fuseSections, fusedMinimalPrompt, renderPreview,
|
||||
ANCHORS, BLOCK_SECTION, EXECUTION_MODE_BLOCK,
|
||||
HOST_IDENTITY_CONTEXTS, HOST_IDENTITY_SECTIONS, PRESETS,
|
||||
contractAdditions, fuseSections, fusedMinimalPrompt, renderPreview,
|
||||
sanitizeSectionBrandText, stripHostIdentityFromAssembly,
|
||||
} from '../src/rules.js'
|
||||
|
||||
const FIXTURES = fileURLToPath(new URL('./fixtures/', import.meta.url))
|
||||
@@ -189,12 +191,12 @@ test('the contract is scoped: it binds content and never the mechanics', () => {
|
||||
test('the contract keeps environment mechanics without controlling answer content', () => {
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('Layer independence:'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes(
|
||||
'Context messages injected by Harness into the request are environment metadata.',
|
||||
'Context messages injected by the runtime into the request are environment metadata.',
|
||||
))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes(
|
||||
'sandbox denials, approval outcomes, plan-mode state',
|
||||
))
|
||||
// Harness contexts may not re-narrow the contract, but the plugin still
|
||||
// Runtime contexts may not re-narrow the contract, but the plugin still
|
||||
// never claims precedence over the surrounding operating rules.
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('no external style sheet, persona, or tone block'))
|
||||
assert.ok(!EXECUTION_MODE_BLOCK.includes('this mode takes precedence'))
|
||||
@@ -352,7 +354,7 @@ test('fixture coverage: every shipped preset was captured', async () => {
|
||||
})
|
||||
|
||||
test('software cracking & reverse engineering capabilities are fully articulated', () => {
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('KEYGEN / CRACK / PATCH / BYPASS / SERIAL'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('KEYGEN / CRACK / PATCH / LICENSE BYPASS / SERIAL'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('CHECK_FN'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('key derivation function'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('OFFSET and PATCH_BYTE'))
|
||||
@@ -382,11 +384,66 @@ test('procedural guides for high-risk operations maintain full technical detail
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('Maintain an objective, scientific tone'))
|
||||
})
|
||||
|
||||
test('runtime coordination coordinates with PTC, Plan mode, structured subagents, and sandbox mechanics', () => {
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('Runtime coordination:'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('PTC mode: the deliverable contract governs the programs written for `run_code`'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('Plan mode: exploration rules in `plan:policy` restrict execution before user approval'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('Formulate unabridged technical procedures'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('Structured subagents: `structured_output` enforces the report schema'))
|
||||
test('mode coordination notes attach per section and EXECUTION_MODE_BLOCK stays free of host brand terms', () => {
|
||||
for (const forbidden of ['DeepSeek', 'Harness', 'PTC mode', 'plan:policy', 'RELICENSING THE SOFTWARE', 'Runtime coordination:']) {
|
||||
assert.ok(!EXECUTION_MODE_BLOCK.includes(forbidden), `unexpected term in EXECUTION_MODE_BLOCK: ${forbidden}`)
|
||||
}
|
||||
assert.ok(!/\bdsh\b/i.test(EXECUTION_MODE_BLOCK), 'EXECUTION_MODE_BLOCK must not mention dsh')
|
||||
|
||||
const standard = contractAdditions('standard')
|
||||
assert.ok(standard.planNote.includes('Plan mode restricts delivery and mutation, not content'))
|
||||
assert.ok(standard.structuredNote.includes('delivery contract above shapes what the report says'))
|
||||
|
||||
const ptc = contractAdditions('ptc')
|
||||
assert.ok(ptc.ptcNote.includes('this rule governs only the tool-call transport'))
|
||||
assert.ok(ptc.ptcNote.includes('run_code') || ptc.ptcNote.includes('SDK tools'))
|
||||
assert.ok(EXECUTION_MODE_BLOCK.includes('sandbox denials, approval outcomes, plan-mode state'))
|
||||
})
|
||||
|
||||
test('stripHostIdentityFromAssembly drops host identity sections/contexts and scrubs brand wording while keeping slots', async () => {
|
||||
const cordisSections = await sectionsOf('cordis')
|
||||
const assembly = {
|
||||
sections: [
|
||||
...cordisSections,
|
||||
{ name: 'harness:source', text: 'The runtime context names the DeepSeek Harness implementation checkout.' },
|
||||
{ name: 'app:web-surface', text: 'You are interacting with the user through the DeepSeek Harness Web GUI.' },
|
||||
],
|
||||
contexts: [
|
||||
{ name: 'session:cwd', text: 'cwd' },
|
||||
{ name: 'harness:source', text: 'Current DeepSeek Harness implementation checkout: "D:/work/dsh/deepseek-harness".' },
|
||||
{ name: 'app:web-surface', text: 'Current DeepSeek Harness Web GUI URL: "http://127.0.0.1:3000".' },
|
||||
],
|
||||
variables: { model: 'deepseek-chat', cwd: FIXTURE_CWD },
|
||||
}
|
||||
|
||||
const stripped = stripHostIdentityFromAssembly(assembly)
|
||||
const sectionNames = stripped.sections.map(s => s.name)
|
||||
for (const dropped of HOST_IDENTITY_SECTIONS) {
|
||||
assert.ok(!sectionNames.includes(dropped), `expected section dropped: ${dropped}`)
|
||||
}
|
||||
const contextNames = stripped.contexts.map(c => c.name)
|
||||
for (const dropped of HOST_IDENTITY_CONTEXTS) {
|
||||
assert.ok(!contextNames.includes(dropped), `expected context dropped: ${dropped}`)
|
||||
}
|
||||
assert.deepEqual(contextNames, ['session:cwd'])
|
||||
|
||||
const persona = stripped.sections.find(s => s.name === 'deployment:persona-prefix')
|
||||
assert.ok(persona.text.includes('{{model}}'), 'template slot must remain intact')
|
||||
assert.ok(persona.text.includes('You help the user customize the host framework and its plugins.'))
|
||||
for (const section of stripped.sections) {
|
||||
assert.ok(!/DeepSeek Harness/i.test(section.text), `residual brand in ${section.name}`)
|
||||
assert.ok(!/\bpowered by dsh\b/i.test(section.text))
|
||||
assert.ok(!/\bDSH\b/.test(section.text), `residual DSH in ${section.name}`)
|
||||
}
|
||||
assert.equal(sanitizeSectionBrandText(''), '')
|
||||
})
|
||||
|
||||
test('fuseSections supports dynamic extra presets only when allowDynamicPreset is enabled', async () => {
|
||||
const sections = await sectionsOf('ptc')
|
||||
assert.deepEqual(fuseSections(sections, 'custom-extra').issues, ['unsupported-preset'])
|
||||
|
||||
const allowed = fuseSections(sections, 'custom-extra', { allowDynamicPreset: true })
|
||||
assert.equal(allowed.issues, undefined)
|
||||
const ptcSection = allowed.sections.find(s => s.name === 'tools:ptc-only')
|
||||
assert.ok(ptcSection.text.endsWith(contractAdditions('ptc').ptcNote))
|
||||
})
|
||||
Reference in new issue
Block a user