dsh-date-wrapper
Compresses DSH time-context from ~280 chars to 46 chars by injecting a compact date line into the runtime-context snapshot; zero runtime dependencies.
Install
dsh plugin --profile web add dsh-date-wrapper
Sandbox test results
| Stage | Result |
|---|---|
| 1 install | ✗ |
| 2 list | — |
| 3 mount | — |
| 4 boot | — |
dsh: initialized profile web at /home/node/.dsh/profiles/webFour stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).
README
dsh-date-wrapper
- [English README](./README.md)
- [中文 README](./README.zh.md)
- [日本語 README](./README.ja.md)
- [한국어 README](./README.ko.md)
- [Français README](./README.fr.md)
- [Deutsch README](./README.de.md)
- [Italiano README](./README.it.md)
- [Русский README](./README.ru.md)
- [Español README](./README.es.md)
- [Installation guide](./INSTALL.md)
- [中文安装指南](./INSTALL.zh.md)
- [日本語インストールガイド](./INSTALL.ja.md)
- [한국어 설치 안내](./INSTALL.ko.md)
- [Guide d'installation](./INSTALL.fr.md)
- [Installationsanleitung](./INSTALL.de.md)
- [Guida all'installazione](./INSTALL.it.md)
- [Руководство по установке](./INSTALL.ru.md)
- [Guía de instalación](./INSTALL.es.md)
- [Changelog](./CHANGELOG.md)
- [日本語 changelog](./CHANGELOG.ja.md)
- [한국어 changelog](./CHANGELOG.ko.md)
- [Français changelog](./CHANGELOG.fr.md)
- [Deutsch changelog](./CHANGELOG.de.md)
- [Italiano changelog](./CHANGELOG.it.md)
- [Русский changelog](./CHANGELOG.ru.md)
- [Español changelog](./CHANGELOG.es.md)
▼ DSH 版本适配
支持的 DSH 版本清单是脚本下发、禁止手改的 —— 见下方自动生成的管理块
(单一事实源:scripts/hosts.mjs;由scripts/sync-hosts.mjs下发到
package.jsonpeerDependencies + engines.dsh、dsh.plugin.json与九语 README)。
插件唯一宿主契约是 systemPrompt.context({ name, order, text }):不注册设置
命名空间、不读会话数据、不发 RPC,宿主侧客户端/会话/持久化重写都与它无关。
精简版时间注入:把 Current date: 2026-09-08 Asia/Shanghai Tuesday(46 字符 ≈ 12 token)挂进 DSH 自带的运行上下文快照。
不加载 @deepseek-ai/dsh-time-context,不产生额外会话消息,不改 DSH 源码,不提 PR。
- [机制详解:DSH 会话、JSONL 与请求组装](./docs/dsh-session-and-context-mechanics.md)(中文)
- [交接文档 HANDOVER.md](./HANDOVER.md)(中文)
<!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->
- 支持的 DSH 宿主:
0.1.0-rc.20.1.0-rc.30.1.0-rc.60.1.0-rc.70.1.0-rc.80.1.1-rc.10.1.1-rc.20.1.2-rc.10.1.5-rc.10.1.5-rc.20.1.5-rc.30.1.7-rc.10.1.7-rc.20.2.0-rc.10.2.0-rc.20.2.1-rc.10.2.1-rc.20.2.1-rc.30.2.1-rc.40.2.1-rc.50.2.2-rc.1(覆盖 0.1.0 / 0.1.1 / 0.1.2 / 0.1.5 / 0.1.7 / 0.2.0 / 0.2.1 七条线共 21 个 rc) - 运行时已验证:
0.1.0-rc.2,0.1.0-rc.3,0.1.0-rc.6,0.1.0-rc.7,0.1.0-rc.8,0.1.1-rc.1,0.1.1-rc.2,0.1.2-rc.1,0.1.5-rc.1,0.1.5-rc.2,0.1.5-rc.3,0.1.7-rc.1,0.1.7-rc.2,0.2.0-rc.1,0.2.0-rc.2(证据见.compat-results/)
<!-- host-compat:end -->
这个插件解决什么
DSH 自带的 @deepseek-ai/dsh-time-context 每次请求注入约 280 字符的元数据:
Time sampled while preparing turn 3, step 2: 2026-09-08T16:05:36+08:00[Asia/Shanghai] Browser time zone for this request: Asia/Shanghai. Interpret otherwise-unqualified dates and times in this zone. Elapsed since the preceding model-visible message: 2m 34s.
本插件把同样的信息压成一行 46 字符,并且换了一个落点 —— 不再往消息流里塞:
Current date: 2026-09-08 Asia/Shanghai Tuesday
维度 · dsh-time-context · dsh-date-wrapper
注入文本 · ~280 字符 · 46 字符(↓84%),约 12 token
落点 · 每条 pre-step 消息(user/message) · 平台运行上下文快照(systemPrompt.context)
频率 · 每个 eligible step 一条 · 文本变化时随快照重发(同一天内 0 条)
依赖 · agents 服务 · systemPrompt 服务
运行时依赖 · — · 零
版本适配与兼容性
项 · 结论
目标 DSH 版本 · 脚本管理枚举 —— scripts/hosts.mjs(0.1.0 → 0.2.1 七条线共 16 个 rc);运行时已验证清单见文首自动生成块
settings API · 不适用:本插件不注册 settings,也不导出 schemastery Config
使用的契约点 · 只有一个 —— systemPrompt.context()
与原生功能冲突 · @deepseek-ai/dsh-time-context 功能重叠,不要同时使用。本插件默认不安装 = 默认关闭
client 半 · 无:不涉及 slot / DOM / CSS 语义 token
DSH 包 import · 零:不 import 任何 @deepseek-ai/*,比「运行时检测 + 双 API 回退」更保守
历史静态审计(npm-pack 类型比对,留档用;版本支持声明现以枚举 + 运行时矩阵为准,不再以本表为准):
契约点 · 0.1.0-rc.7 · 0.1.1-rc.2 · 0.1.2-rc.1 · 0.1.3-alpha.2 · 0.1.7-rc.2 · 0.2.0-rc.1
systemPrompt.context(ctx): () => void · ✅ · ✅(本机实装验证) · ✅ · ✅ · ✅ · ✅(相对 0.1.7-rc.2 diff 仅版本号)
PromptContext = { name, order, text },无 complete 字段 · ✅ · ✅ · ✅ · ✅ · ✅ · ✅
includeRuntimeContext / suppressRuntimeContext · ✅ · ✅ · ✅ · ✅ · ✅ · ✅
agent-loop project() 按文本去重、surfaceOp: "append" · ✅ · ✅ · ✅ · 未比对 · ✅ · ✅
order: 116 无碰撞(110 / 115 / 120 已占用) · ✅ · ✅ · ✅ · ✅ · ✅ · ✅
验证方式:npm pack @deepseek-ai/dsh-system-prompt@<版本>解包后比对lib/types/index.d.ts与lib/index.js;@deepseek-ai/dsh-agent-loop同法。
dsh-v0.1.7-rc.2与dsh-v0.2.0-rc.1之间,packages/core/system-prompt的 diff 仅版本号一行,110/115/120 的systemPrompt.context调用点原位未动,插件迁移指南无任何systemPrompt条目。
运行时验证现按宿主 rc 逐格在本地隔离矩阵进行(scripts/test-host-compat.mjs,证据在.compat-results/);绿名单即文首自动生成块。HANDOVER.md§7 的 0.1.1-rc.2 记录先于矩阵,属历史。
为什么用运行上下文快照,而不是消息
最初的做法是学 dsh-time-context,在 agent/pre-step 里追加一条 user/message。实测下来太贵:每条 JSONL 事件 339 字节(文本只占 46 字节,content 与 sections 各存一份),而它每轮都会写一条。
改成注册运行上下文后,日期并入平台本来就有的那条快照消息:
- 平台对快照按文本去重(
dsh-agent-loop的RuntimeContextProjection.project():if (this.retained?.text === snapshot) return),所以日期不变时一条事件都不多; - 快照是追加新消息(
surfaceOp: 'append'),不是原地改写,请求序列只增长 → 不破坏前缀缓存; - 我们的边际成本只有那 46 字节,且只在快照因文本变化而重发时才被带上。
本机实测(一个 10 轮 / 231 步的真实会话):
项 · 实测
平台运行上下文快照 · 2 条,1133 B/条,共 2.3 KB
真实用户消息 · 10 条,396 B/条
旧做法(每轮一条消息) · 10 条 × 339 B ≈ 3.4 KB
本做法增量 · 0 条额外事件,日期约 46 B 并入已有快照
配置
cordis.patch.yml 里随行下发,改完需重启:
- insert:
- id: date-wrapper
name: dsh-date-wrapper
config:
timeZone: Asia/Shanghai # IANA 时区;缺省用进程时区
timeZone非法会在启动时直接抛错(不静默降级成 UTC)。- 文本里的时区名就是解析后的 IANA 名(
timeZone缺省时取进程时区名)。 - 运行上下文条目的名字是
date-wrapper:date,排序位116(已占用:110 sandbox、115 approval、120 subagent)。 - 本插件不导出 schemastery
Config,所以配置不走宿主的 schema 校验,校验全部在validateConfig()里手写(这也是「设置 → 插件」页没有本插件配置表单的原因)。
开关:靠插件激活,没有面板开关
本插件不提供设置面板开关,也没有 enabled 之类的 config 字段。原因:
- 功能开关 = 插件行是否激活。插件未激活 →
apply()不跑 → 运行上下文条目不存在 → 一个字都不会注入。 - 本插件没有 client 半(无
dsh.client),界面上没有任何属于它的控件。 - DSH 自带的 设置 → 插件 页面已经会显示每个条目的
已启用 / 已停用(只读,不能点)。
怎么关
在你自己的 profile patch 层里按 id 覆盖即可 —— `C:\Users\<你>\.dsh\
…(truncated)
Rendered from the README published on npm. Formatted only, not edited.
Versions
Published on npm::15,最后更新 2026-11-06