@linxin666/dsh-liangshen 0.3.20 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +69 -39
  3. package/README.zh.md +70 -40
  4. package/lib/client.js +640 -0
  5. package/lib/client.js.map +1 -0
  6. package/lib/index.js +11 -6
  7. package/lib/types/announce.test.d.ts +1 -0
  8. package/lib/types/client/LiangShenLever.d.ts +17 -0
  9. package/lib/types/client/index.d.ts +45 -0
  10. package/lib/types/client/lever-controller.d.ts +133 -0
  11. package/lib/types/client/locales.d.ts +27 -0
  12. package/lib/types/core/lever.d.ts +50 -0
  13. package/lib/types/index.d.ts +11 -6
  14. package/lib/types/index.test.d.ts +1 -0
  15. package/lib/types/schema.test.d.ts +1 -0
  16. package/lib/types/sync.test.d.ts +1 -0
  17. package/package.json +29 -2
  18. package/presets/liangshen/NOTICE +4 -3
  19. package/presets/liangshen/agent.cordis.yml +129 -86
  20. package/presets/liangshen/custom-bash.mjs +4 -4
  21. package/presets/liangshen/minimal-prompt.mjs +835 -0
  22. package/presets/liangshen/tool-catalog.mjs +631 -0
  23. package/src/client/LiangShenLever.module.css +314 -0
  24. package/src/client/LiangShenLever.tsx +176 -0
  25. package/src/client/css-modules.d.ts +5 -0
  26. package/src/client/index.ts +89 -0
  27. package/src/client/lever-controller.ts +331 -0
  28. package/src/client/locales.ts +46 -0
  29. package/src/core/lever.ts +68 -0
  30. package/src/index.ts +11 -6
  31. package/src/schema.test.ts +1 -1
  32. package/src/sync.test.ts +4 -4
  33. package/tools/analyze-session.mjs +25 -5
  34. package/tools/benchmark-driver.mjs +124 -0
  35. package/tools/benchmark-live-run.mjs +771 -0
  36. package/tools/benchmark-report.mjs +354 -0
  37. package/tools/tasks/liangshen-v41-flash.json +127 -0
  38. package/presets/liangshen/tool-bootstrap.mjs +0 -601
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":["css"],"sources":["../../../packages/dsh-liangshen/src/client/LiangShenLever.tsx","../../../packages/dsh-liangshen/src/core/lever.ts","../../../packages/dsh-liangshen/src/client/lever-controller.ts","../../../packages/dsh-liangshen/src/client/locales.ts","../../../packages/dsh-liangshen/src/client/index.ts"],"sourcesContent":["/**\n * The homepage lever: a slot-machine arm beside the model selector.\n *\n * Pull it down and the session about to start becomes LiangShen mode; push it\n * up and the preset the user was on comes back. The arm tracks the real preset\n * (never a local guess), and the theatrical part — flash, shockwave, sparks,\n * and the three-language jackpot banner — plays only once the switch actually\n * landed, so a refused switch never celebrates.\n *\n * The component is pure: every fact and verb arrives through the injected face.\n * A pointer drag past {@link DRAG_THRESHOLD_PX} counts as a pull or a push; a\n * plain click or a keyboard activation toggles instead.\n */\n\nimport { useEffect, useRef, useState, useSyncExternalStore, type PointerEvent as ReactPointerEvent, type ReactElement } from 'react'\nimport type { LeverFace } from './lever-controller.ts'\nimport css from './LiangShenLever.module.css'\n\n/** Vertical travel that separates a pull or push from a plain click. */\nconst DRAG_THRESHOLD_PX = 14\n\n/** How long the burst overlay stays mounted, matching its CSS duration. */\nconst BURST_MS = 2200\n\n/** Jackpot lines that read the same in every language. */\nconst BINARY = '01001100 01001001 01000001 01001110 01000111'\nconst MORSE = '-.. . . .--. ... . . -.- / .... .- .-. -. . ... ...'\n\n/** One spark per spoke of the burst. */\nconst SPARKS = Array.from({ length: 14 }, (_, index) => index)\n\n/** Slot entry for `conversation.input.right` (left of the model selector). */\nexport function LiangShenLever(face: LeverFace): ReactElement | null {\n const snapshot = useSyncExternalStore(face.store.subscribe, face.store.getSnapshot)\n const { state, restoreLabel, busy, error, burst } = snapshot\n const [burstKey, setBurstKey] = useState(0)\n const seen = useRef(burst)\n const drag = useRef<{ y: number, fired: boolean } | undefined>(undefined)\n const actionable = !busy && (state === 'on' || state === 'off')\n const on = state === 'on'\n const errorText = error === undefined\n ? undefined\n : error.kind === 'locked'\n ? face.t('lever.failed.locked')\n : error.kind === 'missing'\n ? face.t('lever.failed.missing')\n : error.kind === 'timeout'\n ? face.t('lever.failed.timeout')\n : face.t('lever.failed.failed', { reason: error.reason })\n\n // The burst is driven by the controller's counter, so a reload or a refresh\n // can never replay it and a refused switch can never start it.\n useEffect(() => {\n if (burst > seen.current) setBurstKey(burst)\n seen.current = burst\n }, [burst])\n\n useEffect(() => {\n if (burstKey === 0) return\n const timer = setTimeout(() => { setBurstKey(0) }, BURST_MS)\n return () => { clearTimeout(timer) }\n }, [burstKey])\n\n // The lever exists only while the preset can still change, which is the\n // blank-session window: a started session reports `locked`, a deployment\n // without the preset reports `missing`, and both mean the row renders\n // nothing instead of a dead control in the composer of a running session.\n if (state === 'locked' || state === 'missing') return null\n\n const toggle = (): void => {\n if (!actionable) return\n if (on) face.push()\n else face.pull()\n }\n\n const onPointerDown = (event: ReactPointerEvent<HTMLButtonElement>): void => {\n if (!actionable) return\n drag.current = { y: event.clientY, fired: false }\n event.currentTarget.setPointerCapture?.(event.pointerId)\n }\n\n const onPointerMove = (event: ReactPointerEvent<HTMLButtonElement>): void => {\n const pending = drag.current\n if (pending === undefined || pending.fired) return\n const travel = event.clientY - pending.y\n if (travel >= DRAG_THRESHOLD_PX) {\n pending.fired = true\n face.pull()\n } else if (travel <= -DRAG_THRESHOLD_PX) {\n pending.fired = true\n face.push()\n }\n }\n\n const onPointerUp = (): void => {\n const pending = drag.current\n drag.current = undefined\n // A drag already fired its verb; a click without travel still toggles.\n if (pending === undefined || pending.fired) return\n toggle()\n }\n\n return (\n <span\n className={css.lever}\n data-dsh-plugin=\"liangshen\"\n data-dsh-part=\"lever\"\n data-state={state}\n data-busy={busy ? 'true' : undefined}\n >\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={on}\n aria-label={face.t('lever.a11y')}\n aria-busy={busy}\n title={hint(face, state, restoreLabel)}\n className={css.control}\n disabled={!actionable}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n // Keyboard and assistive activation arrives as a detail-less click;\n // pointer activation is already handled on pointerup.\n onClick={(event) => { if (event.detail === 0) toggle() }}\n >\n <span className={css.track} data-dsh-part=\"lever-track\" aria-hidden=\"true\">\n <svg className={css.arm} data-dsh-part=\"lever-arm\" viewBox=\"0 0 16 26\" aria-hidden=\"true\">\n <rect className={css.rod} x=\"6.5\" y=\"3.5\" width=\"3\" height=\"21\" rx=\"1.5\" />\n <circle className={css.knob} cx=\"8\" cy=\"4\" r=\"3.4\" />\n </svg>\n </span>\n <span className={css.readout}>{busy ? face.t('lever.busy') : on ? face.t('lever.state.on') : face.t('lever.state.off')}</span>\n </button>\n {errorText !== undefined && (\n <span className={css.error} role=\"status\" title={errorText}>{errorText}</span>\n )}\n {burstKey !== 0 && <Burst key={burstKey} face={face} />}\n </span>\n )\n}\n\n/** The hover hint: what this gesture would do right now. */\nfunction hint(face: LeverFace, state: string, restoreLabel: string): string {\n if (state === 'locked') return face.t('lever.hint.locked')\n if (state === 'missing') return face.t('lever.hint.missing')\n if (state === 'on') return face.t('lever.hint.push', { preset: restoreLabel === '' ? face.t('lever.state.off') : restoreLabel })\n return face.t('lever.hint.pull')\n}\n\n/** The jackpot overlay: flash, shockwave rings, sparks, and the banner. */\nfunction Burst({ face }: { face: LeverFace }): ReactElement {\n return (\n <span className={css.burst} data-dsh-part=\"lever-burst\" aria-hidden=\"true\">\n <span className={css.flash} />\n <span className={css.ring} />\n <span className={css.ring} />\n <span className={css.ring} />\n <span className={css.banner} data-dsh-part=\"lever-banner\">\n <span className={css.bannerName}>{face.t('lever.name')}</span>\n <span className={css.line}>{face.t('burst.line1')}</span>\n <span className={css.line}>{face.t('burst.line2')}</span>\n <span className={css.code}>{BINARY}</span>\n <span className={css.code}>{MORSE}</span>\n </span>\n <span className={css.sparks}>\n {SPARKS.map(spoke => (\n // `rotate` is its own property so the keyframes' translate runs along\n // the spoke after the rotation composes with it.\n <i key={spoke} className={css.spark} style={{ rotate: `${spoke * (360 / SPARKS.length)}deg` }} />\n ))}\n </span>\n </span>\n )\n}\n","/**\n * LiangShen lever logic — framework-free, no DOM, compiled by both programs.\n *\n * The lever is a homepage control beside the model selector: pulling it down\n * turns the current session's preset into LiangShen mode, pushing it up\n * restores the preset the user was on before. The facts it needs are the\n * current session's preset, whether that session may still change preset at\n * all, and the preset roster; the decisions are pure so they can be tested\n * without the browser runtime.\n *\n * A preset is fixed once a session starts (the host refuses the switch with\n * `agent-preset/locked`), so the lever is only meaningful while the session is\n * blank — which is exactly the new-session screen it renders on.\n */\n\n/** The preset id this lever turns on; also the preset directory name. */\nexport const LIANGSHEN_PRESET_ID = 'liangshen'\n\n/** What the lever currently reports. */\nexport type LeverState =\n /** LiangShen mode is the current preset. */\n | 'on'\n /** Another preset is current and the session may still switch. */\n | 'off'\n /** The session has started; the preset can no longer change. */\n | 'locked'\n /** The deployment does not supply the LiangShen preset. */\n | 'missing'\n\n/** The facts one lever decision reads. */\nexport interface LeverFacts {\n /** Whether the current session may still change preset (blank). */\n blank: boolean\n /** The preset the current session runs, when the session reports one. */\n agentPreset?: string\n /** Ids every usable roster row supplies, in roster order. */\n available: readonly string[]\n /** The deployment default preset id, when the roster names one. */\n fallback?: string\n /** The preset the user ran before the last pull-down, remembered by the client. */\n previous?: string\n}\n\n/** Resolve what the lever shows for one set of facts. */\nexport function leverState(facts: LeverFacts): LeverState {\n if (!facts.available.includes(LIANGSHEN_PRESET_ID)) return 'missing'\n if (!facts.blank) return 'locked'\n return facts.agentPreset === LIANGSHEN_PRESET_ID ? 'on' : 'off'\n}\n\n/**\n * The preset a push-up restores: the preset the user was on before pulling the\n * lever, else the deployment default. A candidate is skipped when it is the\n * LiangShen preset itself (restoring it would be a no-op) or when the roster\n * no longer supplies it.\n */\nexport function restoreTarget(facts: LeverFacts): string | undefined {\n for (const candidate of [facts.previous, facts.fallback]) {\n if (candidate === undefined || candidate === LIANGSHEN_PRESET_ID) continue\n if (facts.available.includes(candidate)) return candidate\n }\n return undefined\n}\n\n/** Whether the lever can act at all in its current state. */\nexport function isActionable(state: LeverState): boolean {\n return state === 'on' || state === 'off'\n}\n","/**\n * Lever controller: the business face behind the homepage lever.\n *\n * The view stays pure; every fact and verb comes from here. The roster arrives\n * over the agent-preset Remote namespace (the same one the official surfaces\n * read), the current session comes from the browser sessions service, and the\n * switch goes through `agentPresets.select`, which the host accepts only while\n * the session is still blank.\n *\n * Nothing is cached across reloads except in memory: the lever reads the\n * session's `agentPreset` projection, so a page reload still shows the true\n * state, while `previous` (the preset a push-up restores) is remembered for\n * the length of the page visit and otherwise falls back to the deployment\n * default.\n */\n\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-presets/types'\nimport type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'\nimport type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'\nimport { LIANGSHEN_PRESET_ID, isActionable, leverState, restoreTarget, type LeverFacts, type LeverState } from '../core/lever.ts'\nimport type { LiangShenKey } from './locales.ts'\n\n/**\n * Why the last switch was refused, mapped from the Remote failure code so the\n * view can render localized copy instead of a host message.\n */\nexport type LeverError =\n /** The session already started; its composition is fixed. */\n | { kind: 'locked' }\n /** The deployment supplies no such preset. */\n | { kind: 'missing' }\n /**\n * The switch outlived its ceiling. A Remote answer can be lost on the way\n * back even though the host committed the change, so the lever must stop\n * claiming to be busy and let the next session read report the truth.\n */\n | { kind: 'timeout' }\n /** Anything else, carrying the host's own reason. */\n | { kind: 'failed'; reason: string }\n\n/** How long one preset switch may stay in flight before it is reported as timed out. */\nexport const SELECT_TIMEOUT_MS = 10_000\n\n/** What the lever view renders. */\nexport interface LeverSnapshot {\n /** Resolved lever state. */\n state: LeverState\n /** Display name of the preset a push-up restores; empty when there is none. */\n restoreLabel: string\n /** A switch is in flight. */\n busy: boolean\n /** The last refusal, cleared by the next attempt. */\n error?: LeverError\n /** Increments when a pull-down landed, so the view replays the burst once. */\n burst: number\n}\n\n/**\n * The two agent-preset Remote calls this plugin makes. Spelled locally: the\n * generated namespace merge belongs to the SDK's own client packages, and this\n * browser bundle only needs the two members it calls.\n */\nexport interface AgentPresetRemote {\n list(): Promise<RemoteResult<AgentPresetRoster>>\n select(sessionId: string, agentPreset: string): Promise<RemoteResult<string>>\n}\n\n/** The injected face the lever view consumes. */\nexport interface LeverFace {\n /** The snapshot store the view subscribes to. */\n store: SnapshotStore<LeverSnapshot>\n /** Pull the lever down: turn LiangShen mode on. */\n pull: () => void\n /** Push the lever up: restore the previous preset. */\n push: () => void\n /** Translate one lever key. */\n t: (key: LiangShenKey, vars?: Record<string, string | number>) => string\n}\n\n/** Read the preset a session summary reports, when it reports one. */\nfunction presetOf(session: { projectionValues?: Record<string, unknown> } | undefined): string | undefined {\n const value = session?.projectionValues?.['agentPreset']\n return typeof value === 'string' ? value : undefined\n}\n\n/** The lever controller: roster read, session facts, and the preset switch. */\nexport class LeverController {\n private readonly store: SnapshotStore<LeverSnapshot>\n\n /**\n * The browser services this controller reads, resolved defensively: the\n * context proxy throws on any service the fiber did not inject, so a\n * deployment that cannot answer one of them must leave the lever inert\n * rather than take the plugin (and the composer row) down with it.\n */\n private readonly sessions: ISessions | undefined\n\n private readonly remote: AgentPresetRemote | undefined\n\n /** Roster rows as last read; empty until the first read lands. */\n private rows: AgentPresetRoster['presets'] = []\n\n /** The preset the user was on before the last pull-down. */\n private previous: string | undefined\n\n private loading = false\n\n /** Ceiling on one in-flight switch, so a lost Remote answer cannot hang the row. */\n private readonly selectTimeoutMs: number\n\n private readonly disposers: (() => void)[] = []\n\n constructor(private readonly ctx: ClientContext, options: LeverControllerOptions = {}) {\n this.selectTimeoutMs = options.selectTimeoutMs ?? SELECT_TIMEOUT_MS\n this.sessions = readService<ISessions>(() => (ctx as unknown as { sessions: ISessions }).sessions)\n this.remote = readService<AgentPresetRemote>(\n () => (ctx as unknown as { remote: { agentPresets: AgentPresetRemote } }).remote.agentPresets,\n )\n this.store = createSnapshotStore<LeverSnapshot>({\n state: 'off',\n restoreLabel: '',\n busy: false,\n burst: 0,\n })\n }\n\n /** The snapshot store the view subscribes to. */\n snapshot(): SnapshotStore<LeverSnapshot> {\n return this.store\n }\n\n /** Follow the roster and the current session, then read the roster once. */\n start(): void {\n const list = this.sessions?.list\n if (list !== undefined) {\n this.disposers.push(list.subscribe(() => { this.refresh() }))\n }\n const remote = readService<{ $on?: (event: string, listener: (ns: string) => void) => () => void }>(\n () => (this.ctx as unknown as { remote: { $on: (event: string, listener: (ns: string) => void) => () => void } }).remote,\n )\n if (typeof remote?.$on === 'function') {\n this.disposers.push(remote.$on('settings/document-updated', (ns: string) => {\n if (ns === 'agent-presets') void this.load()\n }))\n }\n this.refresh()\n if (this.remote !== undefined) void this.load()\n }\n\n /** Release every subscription. Idempotent. */\n dispose(): void {\n for (const dispose of this.disposers.splice(0)) dispose()\n }\n\n /** The inject face handed to the slot entry. */\n face(): LeverFace {\n return {\n store: this.store,\n pull: () => { void this.toggle('down') },\n push: () => { void this.toggle('up') },\n t: (key, vars) => {\n const translate = readService<(key: LiangShenKey, vars?: Record<string, string | number>) => string>(\n () => this.ctx.locale.bind('liangshen'),\n )\n return translate === undefined ? key : translate(key, vars)\n },\n }\n }\n\n /** Read the roster; a refusal leaves the lever as it was. */\n async load(): Promise<void> {\n if (this.loading) return\n const remote = this.remote\n if (remote === undefined) return\n this.loading = true\n try {\n const result = await remote.list()\n if (result.ok) this.rows = result.value.presets\n } catch {\n // A carrier failure leaves the roster empty; the view reports `missing`.\n } finally {\n this.loading = false\n this.refresh()\n }\n }\n\n /**\n * Recompute the snapshot from the current session and the last roster read.\n * Only the derived fields are written: an in-flight switch, the last refusal,\n * and the burst counter belong to the gesture, not to a session refresh.\n */\n refresh(): void {\n const facts = this.facts()\n const snapshot = this.store.getSnapshot()\n const state = leverState(facts)\n const target = restoreTarget(facts)\n const restoreLabel = target === undefined ? '' : this.labelOf(target)\n if (snapshot.state === state && snapshot.restoreLabel === restoreLabel) return\n this.store.set({ ...snapshot, state, restoreLabel })\n }\n\n /** The verb behind one gesture direction. */\n private async toggle(direction: 'down' | 'up'): Promise<void> {\n const snapshot = this.store.getSnapshot()\n if (snapshot.busy) return\n const remote = this.remote\n if (remote === undefined) return\n const facts = this.facts()\n if (!isActionable(leverState(facts))) return\n const target = direction === 'down' ? LIANGSHEN_PRESET_ID : restoreTarget(facts)\n const sessionId = this.currentSessionId()\n if (target === undefined || sessionId === undefined) return\n if (facts.agentPreset === target) {\n // Already there: a gesture on the current state is a no-op, not a switch.\n this.refresh()\n return\n }\n this.store.set({ ...snapshot, busy: true, error: undefined })\n let result: RemoteResult<string>\n try {\n result = await withTimeout(remote.select(sessionId, target), this.selectTimeoutMs)\n } catch (error) {\n // A timeout is its own copy: the host may well have committed the change\n // even though its answer never arrived, so this reports the wait, and the\n // next session read (or the next gesture) shows what actually happened.\n const mapped: LeverError = error instanceof SwitchTimeout\n ? { kind: 'timeout' }\n : { kind: 'failed', reason: message(error) }\n this.store.set({ ...this.store.getSnapshot(), busy: false, error: mapped })\n this.refresh()\n return\n }\n if (!result.ok) {\n this.store.set({ ...this.store.getSnapshot(), busy: false, error: refusal(result.error) })\n this.refresh()\n return\n }\n // The switch landed: remember where to return, then celebrate only the\n // pull that turned the mode on.\n this.previous = direction === 'down' ? facts.agentPreset : undefined\n const next = this.store.getSnapshot()\n this.store.set({ ...next, busy: false, error: undefined, burst: direction === 'down' ? next.burst + 1 : next.burst })\n this.refresh()\n }\n\n /** The facts one decision reads, from the live session and the roster. */\n private facts(): LeverFacts {\n const summary = this.currentSession()\n const available = this.rows.filter(row => row.broken === undefined).map(row => row.id)\n const fallback = this.rows.find(row => row.isDefault)?.id\n return {\n blank: summary?.blank === true,\n agentPreset: presetOf(summary),\n available,\n fallback,\n previous: this.previous,\n }\n }\n\n private currentSessionId(): string | undefined {\n const current = this.sessions?.list.getSnapshot().current\n return current === undefined ? undefined : String(current)\n }\n\n private currentSession(): { blank?: boolean, projectionValues?: Record<string, unknown> } | undefined {\n const state = this.sessions?.list.getSnapshot()\n const current = state?.current\n if (state === undefined || current === undefined) return undefined\n return state.byId[current] as unknown as { blank?: boolean, projectionValues?: Record<string, unknown> } | undefined\n }\n\n /** Display name of one preset id, falling back to the id itself. */\n private labelOf(id: string): string {\n const row = this.rows.find(candidate => candidate.id === id)\n return row?.name ?? id\n }\n}\n\n/** The face constructor options; tests narrow the switch ceiling. */\nexport interface LeverControllerOptions {\n /** Override {@link SELECT_TIMEOUT_MS}. */\n selectTimeoutMs?: number\n}\n\n/** Raised when one switch outlives {@link SELECT_TIMEOUT_MS}. */\nclass SwitchTimeout extends Error {\n constructor() {\n super('the preset switch did not answer in time')\n this.name = 'SwitchTimeout'\n }\n}\n\n/** Resolve with `work`, or reject with a {@link SwitchTimeout} after `ms`. */\nfunction withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => { reject(new SwitchTimeout()) }, ms)\n work.then(\n (value) => { clearTimeout(timer); resolve(value) },\n (error: unknown) => { clearTimeout(timer); reject(error instanceof Error ? error : new Error(String(error))) },\n )\n })\n}\n\n/**\n * Read one context service, treating the proxy's \"without inject\" refusal (and\n * any other resolution fault) as the service being absent.\n */\nfunction readService<T>(read: () => T): T | undefined {\n try {\n return read()\n } catch {\n return undefined\n }\n}\n\n/** The host's own reason for a refusal, mapped to lever copy. */\nfunction refusal(error: { code?: string, message?: string, details?: unknown }): LeverError {\n if (error.code === 'agent-preset/locked') return { kind: 'locked' }\n if (error.code === 'agent-preset/not-found') return { kind: 'missing' }\n const details = error.details\n if (typeof details === 'object' && details !== null && typeof (details as { reason?: unknown }).reason === 'string') {\n return { kind: 'failed', reason: (details as { reason: string }).reason }\n }\n return { kind: 'failed', reason: error.message ?? error.code ?? 'unknown' }\n}\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n","/**\n * Lever copy: zh-first dictionary with an English counterpart. The zh side is\n * the key-set source of truth; `packages/dsh-i18n` mirrors the keys into the\n * centralized ru dictionary and `pnpm i18n:check` enforces the parity.\n */\n\n/** Lever copy, key source of truth. */\nexport const zh = {\n 'lever.a11y': '梁神模式拨杆',\n 'lever.name': '梁神模式',\n 'lever.hint.pull': '拨下拨杆:开启「梁神模式」',\n 'lever.hint.push': '上拨拨杆:返回「{preset}」',\n 'lever.hint.locked': '会话已开始,模式不可再更改',\n 'lever.hint.missing': '未找到「梁神模式」预设,请先启用该插件行',\n 'lever.state.on': '梁神模式',\n 'lever.state.off': '普通模式',\n 'lever.busy': '正在切换…',\n 'lever.failed.locked': '会话已经开始,模式已锁定',\n 'lever.failed.missing': '没有找到「梁神模式」预设',\n 'lever.failed.timeout': '切换超时,请重试',\n 'lever.failed.failed': '切换失败:{reason}',\n 'burst.line1': '三秒,三辈子的代码',\n 'burst.line2': '文言文 · 二进制 · 摩斯电码',\n}\n\n/** English counterpart; the key set mirrors {@link zh} exactly. */\nexport const en: Record<keyof typeof zh, string> = {\n 'lever.a11y': 'LiangShen mode lever',\n 'lever.name': 'LiangShen mode',\n 'lever.hint.pull': 'Pull the lever down to turn on LiangShen mode',\n 'lever.hint.push': 'Push the lever up to return to \"{preset}\"',\n 'lever.hint.locked': 'The session has started, so its mode can no longer change',\n 'lever.hint.missing': 'The LiangShen preset is not installed; enable that plugin row first',\n 'lever.state.on': 'LiangShen',\n 'lever.state.off': 'Standard',\n 'lever.busy': 'Switching…',\n 'lever.failed.locked': 'The session already started, so the mode is locked',\n 'lever.failed.missing': 'The LiangShen preset was not found',\n 'lever.failed.timeout': 'The switch timed out; try again',\n 'lever.failed.failed': 'Switch failed: {reason}',\n 'burst.line1': 'Three seconds, three lifetimes of code',\n 'burst.line2': 'Classical Chinese · Binary · Morse code',\n}\n\n/** One lever copy key. */\nexport type LiangShenKey = keyof typeof zh\n","/**\n * dsh-liangshen browser half: the LiangShen lever in the composer tool row.\n *\n * The slot is `conversation.input.right` — \"compact controls before the\n * composer submit action\", which renders immediately left of the model\n * selector (`conversation.input.model`) inside the same composer card, on the\n * homepage's new-session hero as well as in a session. The lever lives only\n * while the session is still blank, because that is the only window in which a\n * preset can change at all: `agentPresets.select` refuses an already-started\n * session, and the arm would have nothing to do in one.\n *\n * This half talks to the host over the agent-preset Remote namespace rather\n * than through the official preset package's browser module: cross-plugin\n * collaboration here goes through cordis services and Remote surfaces, not\n * value imports.\n *\n * Failure policy: a missing slot or a refused Remote call is handled, never\n * thrown — one external plugin must not take the GUI boot down.\n */\n\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the ui-conversation SlotMap merge (the composer tool row).\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-slots'\nimport { LiangShenLever } from './LiangShenLever.tsx'\nimport { LeverController } from './lever-controller.ts'\nimport { en, zh, type LiangShenKey } from './locales.ts'\n\n/** Locale namespace this half owns. */\nexport const NS = 'liangshen'\n\n/**\n * Required client services: the slot registry, locale, sessions, and the roster\n * Remote. Both `remote` and `remote.agentPresets` are declared: the context\n * proxy refuses an uninjected service, and a nested service name does not imply\n * its parent, so reading `ctx.remote.agentPresets` needs `remote` as well.\n */\nexport const inject = ['slots', 'locale', 'sessions', 'remote', 'remote.agentPresets']\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** The LiangShen lever copy. */\n 'liangshen': LiangShenKey\n }\n}\n\nexport { LiangShenLever } from './LiangShenLever.tsx'\nexport { LeverController, type LeverFace, type LeverSnapshot } from './lever-controller.ts'\nexport { LIANGSHEN_PRESET_ID, leverState, restoreTarget, type LeverFacts, type LeverState } from '../core/lever.ts'\n\n/**\n * Mount the lever: register the copy, follow the roster and the current\n * session, and claim the composer tool row.\n * @param ctx - the browser plugin context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => {\n try {\n return ctx.locale.register(NS, { zh, en })\n } catch {\n return () => {}\n }\n }, 'liangshen: lever dictionaries')\n\n const controller = new LeverController(ctx)\n ctx.effect(() => () => controller.dispose(), 'liangshen: lever controller')\n try {\n controller.start()\n } catch {\n // An unavailable sessions or Remote service leaves the lever inert; the\n // view still renders and reports what it knows.\n }\n\n ctx.slots.inject('conversation.input.right', () => {\n try {\n const unregister = ctx.slots.register({\n name: 'conversation.input.right',\n id: 'liangshen-lever',\n order: 20,\n inject: () => controller.face(),\n }, LiangShenLever)\n return () => { unregister() }\n } catch {\n return () => {}\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBA,MAAM,oBAAoB;;EAG1B,MAAM,WAAW;;EAGjB,MAAM,SAAS;EACf,MAAM,QAAQ;;EAGd,MAAM,SAAS,MAAM,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,KAAK;;EAG7D,SAAgB,eAAe,MAAsC;GAEnE,MAAM,EAAE,OAAO,cAAc,MAAM,OAAO,WAAA,GAAA,MAAA,qBAAA,CADJ,KAAK,MAAM,WAAW,KAAK,MAAM,WACZ;GAC3D,MAAM,CAAC,UAAU,gBAAA,GAAA,MAAA,SAAA,CAAwB,CAAC;GAC1C,MAAM,QAAA,GAAA,MAAA,OAAA,CAAc,KAAK;GACzB,MAAM,QAAA,GAAA,MAAA,OAAA,CAAyD,KAAA,CAAS;GACxE,MAAM,aAAa,CAAC,SAAS,UAAU,QAAQ,UAAU;GACzD,MAAM,KAAK,UAAU;GACrB,MAAM,YAAY,UAAU,KAAA,IACxB,KAAA,IACA,MAAM,SAAS,WACb,KAAK,EAAE,qBAAqB,IAC5B,MAAM,SAAS,YACb,KAAK,EAAE,sBAAsB,IAC7B,MAAM,SAAS,YACb,KAAK,EAAE,sBAAsB,IAC7B,KAAK,EAAE,uBAAuB,EAAE,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,IAAI,aAAa;IACf,IAAI;KACF,OAAO,IAAI,OAAO,SAAS,IAAI;MAAE;MAAI;KAAG,CAAC;IAC3C,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,GAAG,+BAA+B;GAElC,MAAM,aAAa,IAAI,gBAAgB,GAAG;GAC1C,IAAI,mBAAmB,WAAW,QAAQ,GAAG,6BAA6B;GAC1E,IAAI;IACF,WAAW,MAAM;GACnB,QAAQ,CAGR;GAEA,IAAI,MAAM,OAAO,kCAAkC;IACjD,IAAI;KACF,MAAM,aAAa,IAAI,MAAM,SAAS;MACpC,MAAM;MACN,IAAI;MACJ,OAAO;MACP,cAAc,WAAW,KAAK;KAChC,GAAG,cAAc;KACjB,aAAa;MAAE,WAAW;KAAE;IAC9B,QAAQ;KACN,aAAa,CAAC;IAChB;GACF,CAAC;EACH"}
package/lib/index.js CHANGED
@@ -387,11 +387,16 @@ function mountOnce(packageName, fn) {
387
387
  * surface (plugin config) or the profile patch. No browser half, no routes,
388
388
  * no agent tools — the preset itself provides the tools.
389
389
  *
390
- * The preset is the "anchored-standard" idea shipped as a named mode: the
391
- * first model request sees only the builtin Minimal preset's exact two tools
392
- * (persistent `bash` plus `str_replace_editor`), and after the anchor the
393
- * wire switches to PTC Mode. Derived from
394
- * https://github.com/xiaobright/dsh-anchored-standard (MIT).
390
+ * The preset combines a minimal persona with a staged, promoted tool surface:
391
+ * the system prompt keeps a minimal persona with standing working discipline
392
+ * and workspace instructions, the session's entire first user turn runs a native
393
+ * foundational tool surface ([bash, str_replace_editor, exit_plan_mode, skill],
394
+ * with bash-only preserved as a configuration experiment), and from the second
395
+ * turn this session presents its tools in PTC mode upon successful activation,
396
+ * so the wire carries the single `run_code` transport while the generated SDK
397
+ * bindings and collapse rule travel in the tool list injected as a durable
398
+ * message after the user's message, preserving full input and output key
399
+ * parameter semantics.
395
400
  */
396
401
  /** Stable cordis plugin name. */
397
402
  const name = "liangshen";
@@ -408,7 +413,7 @@ const DEFAULT_ANNOUNCE = false;
408
413
  /** Order of the announcement section within the tool-guidance band. */
409
414
  const SECTION_ORDER = 150;
410
415
  /** Model-facing announcement: plugin presence, principle, and limits. */
411
- const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:两阶段锚定——首轮模型请求仅暴露官方 Minimal 精确双工具(持久 bash 与 str_replace_editor,文件工具继承宿主沙箱),只保留一行 persona,清空运行时上下文并只放行白名单消息(用户直接消息与 /goal 自动轮次),锚定 Minimal 推理轨迹;晋升受首块锚定门控(首块包含 we 且无 let me,四步兜底),无工具首轮会在响应后自动晋升,晋升后 wire 切换为 PTC Mode(单一 run_code)并在 persona 追加所选工作区路径,workspace 指令与 skill 目录在晋升后再延迟一步注入。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
416
+ const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(思维循环即断、先理解需求与方案再实现验证、YAGNI/PDCA、代码不加冗余注释),并在组装时追加工作区目录 Your working directory is <cwd>. 与 AGENTS.md 工作区指令(workspace-instructions 段,65536 字节预算,每次组装重读);工具清单由 tool-catalog 从第一条用户消息起以 user 消息注入在用户消息之后,形如 skill catalog,仅当工具集变化或该消息离开可见面(压缩、恢复)时重发;wire 上的 schema 按回合分层:首轮整个 user turn 原生呈现基础锚定工具集(默认 [bash, str_replace_editor, exit_plan_mode, skill],且保留 bash-only 配置实验),第二个回合起在 PTC 成功激活后切换为 PTC 呈现(wire 上只有 run_code,其余工具在程序里以 await tools.<name>({...}) 调用,保留完整输入输出关键参数语义而非 200 字唯一契约;缺失 code runtime 时优雅回退至原生呈现);注入消息承载 SDK 绑定、程序契约(一段程序编排多步:独立只读调用用 Promise.all 并发、ToolCallError 处理、输出自选)与「激活后只有 run_code 可直接调用」的规则。工作区子目录动态指令支持注册文件工具含 str_replace_editor 及 PTC 内子调用触达的目录(不解析任意 bash/program 代码)。文件操作受宿主沙箱约束,Windows 下 bash 为 Git Bash 子进程且状态不跨调用保留。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。preset 文件由插件维护于 ~/.dsh/.agent-presets,升级插件时自动更新;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
412
417
  /** Absolute path of the bundled preset tree inside this package. */
413
418
  function bundledPresetsRoot() {
414
419
  return fileURLToPath(new URL("../presets/", import.meta.url));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The homepage lever: a slot-machine arm beside the model selector.
3
+ *
4
+ * Pull it down and the session about to start becomes LiangShen mode; push it
5
+ * up and the preset the user was on comes back. The arm tracks the real preset
6
+ * (never a local guess), and the theatrical part — flash, shockwave, sparks,
7
+ * and the three-language jackpot banner — plays only once the switch actually
8
+ * landed, so a refused switch never celebrates.
9
+ *
10
+ * The component is pure: every fact and verb arrives through the injected face.
11
+ * A pointer drag past {@link DRAG_THRESHOLD_PX} counts as a pull or a push; a
12
+ * plain click or a keyboard activation toggles instead.
13
+ */
14
+ import { type ReactElement } from 'react';
15
+ import type { LeverFace } from './lever-controller.ts';
16
+ /** Slot entry for `conversation.input.right` (left of the model selector). */
17
+ export declare function LiangShenLever(face: LeverFace): ReactElement | null;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * dsh-liangshen browser half: the LiangShen lever in the composer tool row.
3
+ *
4
+ * The slot is `conversation.input.right` — "compact controls before the
5
+ * composer submit action", which renders immediately left of the model
6
+ * selector (`conversation.input.model`) inside the same composer card, on the
7
+ * homepage's new-session hero as well as in a session. The lever lives only
8
+ * while the session is still blank, because that is the only window in which a
9
+ * preset can change at all: `agentPresets.select` refuses an already-started
10
+ * session, and the arm would have nothing to do in one.
11
+ *
12
+ * This half talks to the host over the agent-preset Remote namespace rather
13
+ * than through the official preset package's browser module: cross-plugin
14
+ * collaboration here goes through cordis services and Remote surfaces, not
15
+ * value imports.
16
+ *
17
+ * Failure policy: a missing slot or a refused Remote call is handled, never
18
+ * thrown — one external plugin must not take the GUI boot down.
19
+ */
20
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
21
+ import { type LiangShenKey } from './locales.ts';
22
+ /** Locale namespace this half owns. */
23
+ export declare const NS = "liangshen";
24
+ /**
25
+ * Required client services: the slot registry, locale, sessions, and the roster
26
+ * Remote. Both `remote` and `remote.agentPresets` are declared: the context
27
+ * proxy refuses an uninjected service, and a nested service name does not imply
28
+ * its parent, so reading `ctx.remote.agentPresets` needs `remote` as well.
29
+ */
30
+ export declare const inject: string[];
31
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
32
+ interface LocaleNamespaceMap {
33
+ /** The LiangShen lever copy. */
34
+ 'liangshen': LiangShenKey;
35
+ }
36
+ }
37
+ export { LiangShenLever } from './LiangShenLever.tsx';
38
+ export { LeverController, type LeverFace, type LeverSnapshot } from './lever-controller.ts';
39
+ export { LIANGSHEN_PRESET_ID, leverState, restoreTarget, type LeverFacts, type LeverState } from '../core/lever.ts';
40
+ /**
41
+ * Mount the lever: register the copy, follow the roster and the current
42
+ * session, and claim the composer tool row.
43
+ * @param ctx - the browser plugin context.
44
+ */
45
+ export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Lever controller: the business face behind the homepage lever.
3
+ *
4
+ * The view stays pure; every fact and verb comes from here. The roster arrives
5
+ * over the agent-preset Remote namespace (the same one the official surfaces
6
+ * read), the current session comes from the browser sessions service, and the
7
+ * switch goes through `agentPresets.select`, which the host accepts only while
8
+ * the session is still blank.
9
+ *
10
+ * Nothing is cached across reloads except in memory: the lever reads the
11
+ * session's `agentPreset` projection, so a page reload still shows the true
12
+ * state, while `previous` (the preset a push-up restores) is remembered for
13
+ * the length of the page visit and otherwise falls back to the deployment
14
+ * default.
15
+ */
16
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
17
+ import type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-presets/types';
18
+ import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client';
19
+ import { type SnapshotStore } from '@deepseek-ai/dsh-client-store';
20
+ import { type LeverState } from '../core/lever.ts';
21
+ import type { LiangShenKey } from './locales.ts';
22
+ /**
23
+ * Why the last switch was refused, mapped from the Remote failure code so the
24
+ * view can render localized copy instead of a host message.
25
+ */
26
+ export type LeverError =
27
+ /** The session already started; its composition is fixed. */
28
+ {
29
+ kind: 'locked';
30
+ }
31
+ /** The deployment supplies no such preset. */
32
+ | {
33
+ kind: 'missing';
34
+ }
35
+ /**
36
+ * The switch outlived its ceiling. A Remote answer can be lost on the way
37
+ * back even though the host committed the change, so the lever must stop
38
+ * claiming to be busy and let the next session read report the truth.
39
+ */
40
+ | {
41
+ kind: 'timeout';
42
+ }
43
+ /** Anything else, carrying the host's own reason. */
44
+ | {
45
+ kind: 'failed';
46
+ reason: string;
47
+ };
48
+ /** How long one preset switch may stay in flight before it is reported as timed out. */
49
+ export declare const SELECT_TIMEOUT_MS = 10000;
50
+ /** What the lever view renders. */
51
+ export interface LeverSnapshot {
52
+ /** Resolved lever state. */
53
+ state: LeverState;
54
+ /** Display name of the preset a push-up restores; empty when there is none. */
55
+ restoreLabel: string;
56
+ /** A switch is in flight. */
57
+ busy: boolean;
58
+ /** The last refusal, cleared by the next attempt. */
59
+ error?: LeverError;
60
+ /** Increments when a pull-down landed, so the view replays the burst once. */
61
+ burst: number;
62
+ }
63
+ /**
64
+ * The two agent-preset Remote calls this plugin makes. Spelled locally: the
65
+ * generated namespace merge belongs to the SDK's own client packages, and this
66
+ * browser bundle only needs the two members it calls.
67
+ */
68
+ export interface AgentPresetRemote {
69
+ list(): Promise<RemoteResult<AgentPresetRoster>>;
70
+ select(sessionId: string, agentPreset: string): Promise<RemoteResult<string>>;
71
+ }
72
+ /** The injected face the lever view consumes. */
73
+ export interface LeverFace {
74
+ /** The snapshot store the view subscribes to. */
75
+ store: SnapshotStore<LeverSnapshot>;
76
+ /** Pull the lever down: turn LiangShen mode on. */
77
+ pull: () => void;
78
+ /** Push the lever up: restore the previous preset. */
79
+ push: () => void;
80
+ /** Translate one lever key. */
81
+ t: (key: LiangShenKey, vars?: Record<string, string | number>) => string;
82
+ }
83
+ /** The lever controller: roster read, session facts, and the preset switch. */
84
+ export declare class LeverController {
85
+ private readonly ctx;
86
+ private readonly store;
87
+ /**
88
+ * The browser services this controller reads, resolved defensively: the
89
+ * context proxy throws on any service the fiber did not inject, so a
90
+ * deployment that cannot answer one of them must leave the lever inert
91
+ * rather than take the plugin (and the composer row) down with it.
92
+ */
93
+ private readonly sessions;
94
+ private readonly remote;
95
+ /** Roster rows as last read; empty until the first read lands. */
96
+ private rows;
97
+ /** The preset the user was on before the last pull-down. */
98
+ private previous;
99
+ private loading;
100
+ /** Ceiling on one in-flight switch, so a lost Remote answer cannot hang the row. */
101
+ private readonly selectTimeoutMs;
102
+ private readonly disposers;
103
+ constructor(ctx: ClientContext, options?: LeverControllerOptions);
104
+ /** The snapshot store the view subscribes to. */
105
+ snapshot(): SnapshotStore<LeverSnapshot>;
106
+ /** Follow the roster and the current session, then read the roster once. */
107
+ start(): void;
108
+ /** Release every subscription. Idempotent. */
109
+ dispose(): void;
110
+ /** The inject face handed to the slot entry. */
111
+ face(): LeverFace;
112
+ /** Read the roster; a refusal leaves the lever as it was. */
113
+ load(): Promise<void>;
114
+ /**
115
+ * Recompute the snapshot from the current session and the last roster read.
116
+ * Only the derived fields are written: an in-flight switch, the last refusal,
117
+ * and the burst counter belong to the gesture, not to a session refresh.
118
+ */
119
+ refresh(): void;
120
+ /** The verb behind one gesture direction. */
121
+ private toggle;
122
+ /** The facts one decision reads, from the live session and the roster. */
123
+ private facts;
124
+ private currentSessionId;
125
+ private currentSession;
126
+ /** Display name of one preset id, falling back to the id itself. */
127
+ private labelOf;
128
+ }
129
+ /** The face constructor options; tests narrow the switch ceiling. */
130
+ export interface LeverControllerOptions {
131
+ /** Override {@link SELECT_TIMEOUT_MS}. */
132
+ selectTimeoutMs?: number;
133
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Lever copy: zh-first dictionary with an English counterpart. The zh side is
3
+ * the key-set source of truth; `packages/dsh-i18n` mirrors the keys into the
4
+ * centralized ru dictionary and `pnpm i18n:check` enforces the parity.
5
+ */
6
+ /** Lever copy, key source of truth. */
7
+ export declare const zh: {
8
+ 'lever.a11y': string;
9
+ 'lever.name': string;
10
+ 'lever.hint.pull': string;
11
+ 'lever.hint.push': string;
12
+ 'lever.hint.locked': string;
13
+ 'lever.hint.missing': string;
14
+ 'lever.state.on': string;
15
+ 'lever.state.off': string;
16
+ 'lever.busy': string;
17
+ 'lever.failed.locked': string;
18
+ 'lever.failed.missing': string;
19
+ 'lever.failed.timeout': string;
20
+ 'lever.failed.failed': string;
21
+ 'burst.line1': string;
22
+ 'burst.line2': string;
23
+ };
24
+ /** English counterpart; the key set mirrors {@link zh} exactly. */
25
+ export declare const en: Record<keyof typeof zh, string>;
26
+ /** One lever copy key. */
27
+ export type LiangShenKey = keyof typeof zh;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * LiangShen lever logic — framework-free, no DOM, compiled by both programs.
3
+ *
4
+ * The lever is a homepage control beside the model selector: pulling it down
5
+ * turns the current session's preset into LiangShen mode, pushing it up
6
+ * restores the preset the user was on before. The facts it needs are the
7
+ * current session's preset, whether that session may still change preset at
8
+ * all, and the preset roster; the decisions are pure so they can be tested
9
+ * without the browser runtime.
10
+ *
11
+ * A preset is fixed once a session starts (the host refuses the switch with
12
+ * `agent-preset/locked`), so the lever is only meaningful while the session is
13
+ * blank — which is exactly the new-session screen it renders on.
14
+ */
15
+ /** The preset id this lever turns on; also the preset directory name. */
16
+ export declare const LIANGSHEN_PRESET_ID = "liangshen";
17
+ /** What the lever currently reports. */
18
+ export type LeverState =
19
+ /** LiangShen mode is the current preset. */
20
+ 'on'
21
+ /** Another preset is current and the session may still switch. */
22
+ | 'off'
23
+ /** The session has started; the preset can no longer change. */
24
+ | 'locked'
25
+ /** The deployment does not supply the LiangShen preset. */
26
+ | 'missing';
27
+ /** The facts one lever decision reads. */
28
+ export interface LeverFacts {
29
+ /** Whether the current session may still change preset (blank). */
30
+ blank: boolean;
31
+ /** The preset the current session runs, when the session reports one. */
32
+ agentPreset?: string;
33
+ /** Ids every usable roster row supplies, in roster order. */
34
+ available: readonly string[];
35
+ /** The deployment default preset id, when the roster names one. */
36
+ fallback?: string;
37
+ /** The preset the user ran before the last pull-down, remembered by the client. */
38
+ previous?: string;
39
+ }
40
+ /** Resolve what the lever shows for one set of facts. */
41
+ export declare function leverState(facts: LeverFacts): LeverState;
42
+ /**
43
+ * The preset a push-up restores: the preset the user was on before pulling the
44
+ * lever, else the deployment default. A candidate is skipped when it is the
45
+ * LiangShen preset itself (restoring it would be a no-op) or when the roster
46
+ * no longer supplies it.
47
+ */
48
+ export declare function restoreTarget(facts: LeverFacts): string | undefined;
49
+ /** Whether the lever can act at all in its current state. */
50
+ export declare function isActionable(state: LeverState): boolean;
@@ -9,11 +9,16 @@
9
9
  * surface (plugin config) or the profile patch. No browser half, no routes,
10
10
  * no agent tools — the preset itself provides the tools.
11
11
  *
12
- * The preset is the "anchored-standard" idea shipped as a named mode: the
13
- * first model request sees only the builtin Minimal preset's exact two tools
14
- * (persistent `bash` plus `str_replace_editor`), and after the anchor the
15
- * wire switches to PTC Mode. Derived from
16
- * https://github.com/xiaobright/dsh-anchored-standard (MIT).
12
+ * The preset combines a minimal persona with a staged, promoted tool surface:
13
+ * the system prompt keeps a minimal persona with standing working discipline
14
+ * and workspace instructions, the session's entire first user turn runs a native
15
+ * foundational tool surface ([bash, str_replace_editor, exit_plan_mode, skill],
16
+ * with bash-only preserved as a configuration experiment), and from the second
17
+ * turn this session presents its tools in PTC mode upon successful activation,
18
+ * so the wire carries the single `run_code` transport while the generated SDK
19
+ * bindings and collapse rule travel in the tool list injected as a durable
20
+ * message after the user's message, preserving full input and output key
21
+ * parameter semantics.
17
22
  */
18
23
  import type { Context } from '@deepseek-ai/cordis';
19
24
  import type { SettingsNamespace } from '@deepseek-ai/dsh-settings';
@@ -33,7 +38,7 @@ export interface Config {
33
38
  }
34
39
  export declare const Config: z<Config>;
35
40
  /** Model-facing announcement: plugin presence, principle, and limits. */
36
- export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u3002\u539F\u7406\uFF1A\u4E24\u9636\u6BB5\u951A\u5B9A\u2014\u2014\u9996\u8F6E\u6A21\u578B\u8BF7\u6C42\u4EC5\u66B4\u9732\u5B98\u65B9 Minimal \u7CBE\u786E\u53CC\u5DE5\u5177\uFF08\u6301\u4E45 bash \u4E0E str_replace_editor\uFF0C\u6587\u4EF6\u5DE5\u5177\u7EE7\u627F\u5BBF\u4E3B\u6C99\u7BB1\uFF09\uFF0C\u53EA\u4FDD\u7559\u4E00\u884C persona\uFF0C\u6E05\u7A7A\u8FD0\u884C\u65F6\u4E0A\u4E0B\u6587\u5E76\u53EA\u653E\u884C\u767D\u540D\u5355\u6D88\u606F\uFF08\u7528\u6237\u76F4\u63A5\u6D88\u606F\u4E0E /goal \u81EA\u52A8\u8F6E\u6B21\uFF09\uFF0C\u951A\u5B9A Minimal \u63A8\u7406\u8F68\u8FF9\uFF1B\u664B\u5347\u53D7\u9996\u5757\u951A\u5B9A\u95E8\u63A7\uFF08\u9996\u5757\u5305\u542B we \u4E14\u65E0 let me\uFF0C\u56DB\u6B65\u515C\u5E95\uFF09\uFF0C\u65E0\u5DE5\u5177\u9996\u8F6E\u4F1A\u5728\u54CD\u5E94\u540E\u81EA\u52A8\u664B\u5347\uFF0C\u664B\u5347\u540E wire \u5207\u6362\u4E3A PTC Mode\uFF08\u5355\u4E00 run_code\uFF09\u5E76\u5728 persona \u8FFD\u52A0\u6240\u9009\u5DE5\u4F5C\u533A\u8DEF\u5F84\uFF0Cworkspace \u6307\u4EE4\u4E0E skill \u76EE\u5F55\u5728\u664B\u5347\u540E\u518D\u5EF6\u8FDF\u4E00\u6B65\u6CE8\u5165\u3002preset \u6587\u4EF6\u7531\u63D2\u4EF6\u7EF4\u62A4\u4E8E ~/.dsh/.agent-presets\uFF0C\u5347\u7EA7\u63D2\u4EF6\u65F6\u81EA\u52A8\u66F4\u65B0\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
41
+ export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u3002\u539F\u7406\uFF1A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u6781\u7B80 persona\uFF08minimal-prompt \u653E\u884C\u8BE5\u6BB5\u4E0E plan \u6A21\u5F0F\u7684 plan:policy\uFF09\uFF0Cpersona \u5185\u7F6E\u672C\u6A21\u5F0F\u5DE5\u4F5C\u7EAA\u5F8B\uFF08\u601D\u7EF4\u5FAA\u73AF\u5373\u65AD\u3001\u5148\u7406\u89E3\u9700\u6C42\u4E0E\u65B9\u6848\u518D\u5B9E\u73B0\u9A8C\u8BC1\u3001YAGNI/PDCA\u3001\u4EE3\u7801\u4E0D\u52A0\u5197\u4F59\u6CE8\u91CA\uFF09\uFF0C\u5E76\u5728\u7EC4\u88C5\u65F6\u8FFD\u52A0\u5DE5\u4F5C\u533A\u76EE\u5F55 Your working directory is <cwd>. \u4E0E AGENTS.md \u5DE5\u4F5C\u533A\u6307\u4EE4\uFF08workspace-instructions \u6BB5\uFF0C65536 \u5B57\u8282\u9884\u7B97\uFF0C\u6BCF\u6B21\u7EC4\u88C5\u91CD\u8BFB\uFF09\uFF1B\u5DE5\u5177\u6E05\u5355\u7531 tool-catalog \u4ECE\u7B2C\u4E00\u6761\u7528\u6237\u6D88\u606F\u8D77\u4EE5 user \u6D88\u606F\u6CE8\u5165\u5728\u7528\u6237\u6D88\u606F\u4E4B\u540E\uFF0C\u5F62\u5982 skill catalog\uFF0C\u4EC5\u5F53\u5DE5\u5177\u96C6\u53D8\u5316\u6216\u8BE5\u6D88\u606F\u79BB\u5F00\u53EF\u89C1\u9762\uFF08\u538B\u7F29\u3001\u6062\u590D\uFF09\u65F6\u91CD\u53D1\uFF1Bwire \u4E0A\u7684 schema \u6309\u56DE\u5408\u5206\u5C42\uFF1A\u9996\u8F6E\u6574\u4E2A user turn \u539F\u751F\u5448\u73B0\u57FA\u7840\u951A\u5B9A\u5DE5\u5177\u96C6\uFF08\u9ED8\u8BA4 [bash, str_replace_editor, exit_plan_mode, skill]\uFF0C\u4E14\u4FDD\u7559 bash-only \u914D\u7F6E\u5B9E\u9A8C\uFF09\uFF0C\u7B2C\u4E8C\u4E2A\u56DE\u5408\u8D77\u5728 PTC \u6210\u529F\u6FC0\u6D3B\u540E\u5207\u6362\u4E3A PTC \u5448\u73B0\uFF08wire \u4E0A\u53EA\u6709 run_code\uFF0C\u5176\u4F59\u5DE5\u5177\u5728\u7A0B\u5E8F\u91CC\u4EE5 await tools.<name>({...}) \u8C03\u7528\uFF0C\u4FDD\u7559\u5B8C\u6574\u8F93\u5165\u8F93\u51FA\u5173\u952E\u53C2\u6570\u8BED\u4E49\u800C\u975E 200 \u5B57\u552F\u4E00\u5951\u7EA6\uFF1B\u7F3A\u5931 code runtime \u65F6\u4F18\u96C5\u56DE\u9000\u81F3\u539F\u751F\u5448\u73B0\uFF09\uFF1B\u6CE8\u5165\u6D88\u606F\u627F\u8F7D SDK \u7ED1\u5B9A\u3001\u7A0B\u5E8F\u5951\u7EA6\uFF08\u4E00\u6BB5\u7A0B\u5E8F\u7F16\u6392\u591A\u6B65\uFF1A\u72EC\u7ACB\u53EA\u8BFB\u8C03\u7528\u7528 Promise.all \u5E76\u53D1\u3001ToolCallError \u5904\u7406\u3001\u8F93\u51FA\u81EA\u9009\uFF09\u4E0E\u300C\u6FC0\u6D3B\u540E\u53EA\u6709 run_code \u53EF\u76F4\u63A5\u8C03\u7528\u300D\u7684\u89C4\u5219\u3002\u5DE5\u4F5C\u533A\u5B50\u76EE\u5F55\u52A8\u6001\u6307\u4EE4\u652F\u6301\u6CE8\u518C\u6587\u4EF6\u5DE5\u5177\u542B str_replace_editor \u53CA PTC \u5185\u5B50\u8C03\u7528\u89E6\u8FBE\u7684\u76EE\u5F55\uFF08\u4E0D\u89E3\u6790\u4EFB\u610F bash/program \u4EE3\u7801\uFF09\u3002\u6587\u4EF6\u64CD\u4F5C\u53D7\u5BBF\u4E3B\u6C99\u7BB1\u7EA6\u675F\uFF0CWindows \u4E0B bash \u4E3A Git Bash \u5B50\u8FDB\u7A0B\u4E14\u72B6\u6001\u4E0D\u8DE8\u8C03\u7528\u4FDD\u7559\u3002\u771F\u5B9E\u63A8\u7406\u63A2\u9488\u901A\u8FC7\u4E0D\u7B49\u4E8E\u6A21\u5F0F\u96C6\u6210\u901A\u8FC7\uFF0C\u66F4\u4E0D\u7B49\u4E8E\u7EDF\u8BA1\u6548\u679C\u63D0\u5347\u3002preset \u6587\u4EF6\u7531\u63D2\u4EF6\u7EF4\u62A4\u4E8E ~/.dsh/.agent-presets\uFF0C\u5347\u7EA7\u63D2\u4EF6\u65F6\u81EA\u52A8\u66F4\u65B0\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
37
42
  export { dshHome } from './dsh-home.ts';
38
43
  /** Absolute path of the bundled preset tree inside this package. */
39
44
  export declare function bundledPresetsRoot(): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-liangshen",
3
- "description": "LiangShen (梁神) agent preset for the dsh web GUI: a two-phase anchored-standard preset — the first model request exposes only the builtin Minimal exact two-tool surface (persistent bash plus str_replace_editor) with no runtime contexts or injected instructions (Minimal-aligned trajectory anchor), promotion is gated on the first minimal-like reasoning block with a fallback, and the wire then switches to PTC Mode (a single run_code tool over the full registry) with the ordinary injections returning afterwards. The preset files are synced into ~/.dsh/.agent-presets on host startup. Hot-pluggable — mounted via cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "0.3.20",
3
+ "description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The preset keeps a minimal persona with standing working discipline and workspace instructions in the system prompt, anchors the entire first user turn on a native foundational tool surface ([bash, str_replace_editor, exit_plan_mode, skill], with bash-only supported as a configuration experiment), and from the second turn presents tools in PTC mode upon successful activation: the wire carries the single `run_code` transport and other tools are reached via the generated SDK preserving full input/output key parameter semantics. The tool catalog, SDK bindings, program contract (one program per intent, overlapping independent reads under `Promise.all`, `ToolCallError` handling, curated output), and collapse rule are injected as a durable user message after the user's message the way the skill catalog is. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Preset files sync to ~/.dsh/.agent-presets on startup. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
4
+ "version": "0.3.22",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^22.19.0 || >=24.0.0"
@@ -13,6 +13,10 @@
13
13
  "types": "./lib/types/index.d.ts",
14
14
  "default": "./lib/index.js"
15
15
  },
16
+ "./client": {
17
+ "types": "./lib/types/client/index.d.ts",
18
+ "default": "./lib/client.js"
19
+ },
16
20
  "./package.json": "./package.json",
17
21
  "./presets/*": "./presets/*"
18
22
  },
@@ -22,6 +26,15 @@
22
26
  },
23
27
  "bundle": {
24
28
  "patch": "./cordis.patch.yml"
29
+ },
30
+ "client": {
31
+ "inject": [
32
+ "@deepseek-ai/dsh-client-connection",
33
+ "@deepseek-ai/dsh-client-ui-renderer",
34
+ "@deepseek-ai/dsh-api-remotes",
35
+ "@deepseek-ai/dsh-api-session-controller"
36
+ ],
37
+ "platform": "web"
25
38
  }
26
39
  },
27
40
  "dependencies": {
@@ -29,9 +42,23 @@
29
42
  },
30
43
  "devDependencies": {
31
44
  "@deepseek-ai/cordis": "^4.0.2",
45
+ "@deepseek-ai/dsh-agent-presets": "^0.1.5-rc.1",
46
+ "@deepseek-ai/dsh-api-remotes": "^0.1.5-rc.1",
47
+ "@deepseek-ai/dsh-api-session-controller": "^0.1.5-rc.1",
48
+ "@deepseek-ai/dsh-client-connection": "^0.1.5-rc.1",
49
+ "@deepseek-ai/dsh-client-locale": "^0.1.5-rc.1",
50
+ "@deepseek-ai/dsh-client-store": "^0.1.5-rc.1",
51
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.1",
52
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-rc.1",
53
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.5-rc.1",
32
54
  "@deepseek-ai/dsh-settings": "^0.1.5-rc.1",
33
55
  "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.1",
34
56
  "@types/node": "^22.20.0",
57
+ "@types/react": "~18.3.1",
58
+ "@types/react-dom": "~18.3.1",
59
+ "jsdom": "^25.0.0",
60
+ "react": "^18.3.1",
61
+ "react-dom": "^18.3.1",
35
62
  "tsdown": "0.22.2",
36
63
  "typescript": "~5.7.2",
37
64
  "vitest": "^3.0.0"
@@ -1,6 +1,7 @@
1
- agent.cordis.yml 改编自 DeepSeek Harness 内置 Minimal 与 Standard preset(MIT)。
2
- tool-bootstrap.mjs 来自 https://github.com/xiaobright/dsh-anchored-standard(MIT),
3
- 并包含 dsh-liangshen 的两阶段隔离扩展。
1
+ agent.cordis.yml 改编自 DeepSeek Harness 内置 Minimal、Standard 与 PTC preset(MIT)。
2
+ minimal-prompt.mjs 与 tool-catalog.mjs 为 dsh-liangshen 自有实现;其中的
3
+ agent-instructions 引用提示沿用 https://github.com/xiaobright/dsh-anchored-standard
4
+ (MIT)的实验结论,消息注入形状参照 DeepSeek Harness 的 skill catalog。
4
5
  custom-bash.mjs 移植自同一上游(xiaobright/dsh-anchored-standard,MIT)的
5
6
  combo-anchored/custom-bash.mjs,用于 win32 上以跨平台子进程通道提供同名
6
7
  `bash` 工具(Git Bash)。