nuwa-skill
alchaincyf
你想蒸馏的下一个员工,何必是同事。蒸馏任何人的思维方式——心智模型、决策启发式、表达DNA。Distill how anyone thinks.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Tom-l-j-h/dsh-ctx-log
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DeepSeek Harness 插件:把会话事件逐条落盘为按日 JSONL,并在系统提示里注入轨迹位置、最近摘要与当前时间 —— 上下文被自动压缩后,细节还能捞回来。
DSH 的上下文会自动压缩。压缩之后,早期的对话原文、工具调用的参数与结果会从模型视野里消失,于是开始出现:
Claude Code / Codex 有会话钩子可以把原始轨迹落盘;DSH 没有内置钩子,但它的 Host Event 足够做等价的事。本插件订阅 session/event,把 5 类事件逐条追加到按日 JSONL,并在每一轮的系统提示里告诉模型"轨迹文件在哪、最近发生了什么、现在几点"。
| # | 功能 | 说明 |
|---|---|---|
| 1 | 全量记录(核心) | session/event → user/message / assistant/message / tool/call / tool/result / turn/end 五类逐条落盘,单条截断(默认 4000 字 / 1500 字)控制体积 |
| 2 | 轨迹注入 | 每轮系统提示注入:轨迹文件绝对路径、本会话记录条数、最近 N 条(默认 6)用户/助手消息摘要(跨天自动回看上一天) |
| 3 | 时间与新鲜度 | 每轮注入准确当前时间(避免一轮跑到一半不知道几点);watchFiles 可监控关键文件 mtime,超 3 天标 ⏳、超 7 天标 ⚠️ 并提示"引用前先核实" |
| 4 | 会话开始行 | agent/created → 记 session/start 一行(含来源与 cwd),便于事后按会话聚合 |
落盘格式(每行一条,JSONL):
{"ts":"2026-11-06T07:31:22.123Z","sess":"session-…","seq":42,"type":"user/message","role":"user","text":"…"}
{"ts":"2026-11-06T07:31:25.456Z","sess":"session-…","seq":44,"type":"tool/call","tool":"pwsh","args":"…"}
{"ts":"2026-11-06T07:31:26.789Z","sess":"session-…","seq":45,"type":"tool/result","isError":false,"result":"…"}
默认目录:~/.dsh/ctx-log/ctx_YYYY-MM-DD.jsonl(Windows:C:\Users\<你>\.dsh\ctx-log\)。
DSH 桌面端的 profile 由 Electron 独占管理,命令行装不了,请走插件页。
git clone https://github.com/Tom-l-j-h/dsh-ctx-log.git(或下载 zip 解压);【上下文轨迹】… 行;同时 ~/.dsh/ctx-log/ 下出现当天的 ctx_*.jsonl。本插件是 Host 插件,装进 profile 后对所有会话生效。改配置后:插件管理器里 disable → enable(热重载),或重启应用。
插件通过 cordis.patch.yml 传配置(装好后也可在 profile 对应条目里改):
- insert:
- id: dsh-ctx-log
name: 'dsh-ctx-log'
config:
logDir: '' # 留空 = ~/.dsh/ctx-log
maxTextChars: 4000 # 用户/助手消息单条上限
maxToolChars: 1500 # 工具参数/结果单条上限
injectTrail: true # 是否注入轨迹路径与摘要
trailRecentLines: 6 # 摘要条数
skipTypes: [] # 例:['tool/call','tool/result'] 可显著降低落盘敏感度
watchFiles: [] # 例:[{ path: 'D:/notes/TODO.md', label: '笔记' }]
| 字段 | 默认 | 说明 |
|---|---|---|
logDir |
~/.dsh/ctx-log |
落盘目录,不存在会自动创建 |
maxTextChars |
4000 |
用户/助手消息截断长度 |
maxToolChars |
1500 |
工具参数/结果截断长度 |
injectTrail |
true |
关闭则只记录、不注入(系统提示保持干净) |
trailRecentLines |
6 |
注入的最近消息条数 |
skipTypes |
[] |
跳过的 session 事件类型(如只记对话不记工具) |
watchFiles |
[] |
信息新鲜度监控:[{ path, label }],按 mtime 提示多久没更新 |
每轮系统提示固定注入两段上下文:轨迹路径(+已记条数)与当前时间(+可选文件新鲜度),以及 trailRecentLines 条摘要。
按 evals/RESULTS.md 的实测(chars÷1.6 代理估算):常规规模每轮约 400 token;100 轮会话约 40,000 token。
不需要注入时设 injectTrail: false,只落盘不占上下文。
实测口径:
trailRecentLines默认 6、watchFiles为空。0 行日志(无摘要)约 186 token/轮,即固定开销;摘要固定取尾部 6 条,所以成本随trailRecentLines变化,不随日志体积线性增长。
scrub() 只是兜底:覆盖常见 password=…、api_key=…、Bearer …、URL 里 //user:pass@ 的密码段,不保证覆盖所有敏感信息。logDir 指到本机专用目录,不要放进云同步盘 / 共享目录;skipTypes: ['tool/call','tool/result'] 只留对话;Get-ChildItem $env:USERPROFILE\.dsh\ctx-log\*.jsonl | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-7) } | Remove-Itemfind ~/.dsh/ctx-log -name 'ctx_*.jsonl' -mtime +7 -deletenode:fs / node:path / node:os),无第三方依赖;@deepseek-ai/* 的 peerDependencies → 不会触发 DSH 的插件版本闸门;这四条是开发本插件时真实踩过的坑,做 DSH 插件可直接参考:
Config 为纯 JSON Schema:Cordis 期待的是 schemastery Schema(带 .validate()),否则激活时报 Cannot read properties of undefined (reading 'validate')。最省事:不导出 Config,cordis.patch.yml 里的 config 会直接作为 apply(ctx, config) 第二参传入。apply() 里用 ctx.inject(['systemPrompt'], (sctx) => { … }) 延迟注册。若直接 ctx.get('systemPrompt') 判空后 return,冷启动会记录正常、注入全无(半瘫,极难察觉)。ctx_.jsonl 垃圾文件。每次写入时重算日期即可,顺便天然处理跨天翻转。Current runtime context… 是 user 角色但非真人消息,需要过滤。plugin_manager 里 disable → enable 会重新 apply 新代码,不用重启整个应用。session/event 是 fire-and-forget;另外不要 append 新的事件类型(会让 Session 无法重开)。session/event ──(5 类过滤)──> appendFileSync ──> ~/.dsh/ctx-log/ctx_YYYY-MM-DD.jsonl
│
systemPrompt.context() ──每轮──> 读尾部 400 行 ──> 最近 6 条摘要 + 轨迹路径 + 当前时间/新鲜度
dsh-ctx-log is a DeepSeek Harness plugin that records every session event (user/assistant messages, tool calls/results, turn ends) into daily JSONL files and injects the log path, a short recent-message summary, and the current time into the system prompt — so details survive automatic context compaction. Built with Node built-ins only, no peer dependencies. Privacy: it stores conversation content by default; scrubbing is best-effort — use a local-only logDir, skipTypes for tool events, and retention cleanup. MIT licensed.
MIT © 2026 Tom-l-j-h
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: context。