feat(core): 新增 DeepSeek Harness (dsh) 用量采集 - #39
Open
cyhano wants to merge 1 commit into
Open
Conversation
读取 ~/.dsh/sessions/**/session.jsonl.zstd,把 dsh 的 token 用量计入面板与排行榜。 - 新增 parser:解析官方会话文件(zstd 压缩 JSONL),只采 assistant/message 的 data.usage,按消息去重、支持增量重扫,避免重复计数 - 多帧 zstd:dsh 会话是流式追加写入的多帧文件,Node 内置解压只处理第一帧, 这里按帧循环解压并拼接(靠 engine.bytesWritten 推进) - 字段映射:inputTokens→input,outputTokens→output,cacheReadTokens→cached_input, model 取 message.source.model,项目取 session 首行 cwd - 接入 sync 调度、source 探测、tool catalog、上传事件映射与前端 label/颜色/图标 Co-Authored-By: ZCode <noreply@z.ai>
cyhano
force-pushed
the
feat/dsh-harness-source
branch
from
August 31, 2026 10:34
cc940da to
99e7171
Compare
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
让 juejin-usage 能读取本机 DeepSeek Harness(dsh) 的官方会话存储,把 token 用量计入面板与排行榜。
数据源
DSH 官方会话文件:
~/.dsh/sessions/<workspace>/<sessionId>/session.jsonl.zstd(zstd 压缩的 JSONL,逐行一个事件)。assistant/message事件的data.usage(inputTokens/outputTokens/cacheReadTokens,每个消息的最终值)。data.message.source(如api/deepseek-v4-pro)。cwd。字段映射
inputTokensinput_tokensoutputTokensoutput_tokenscacheReadTokenscached_input_tokenscache_creation_input_tokens = 0reasoning_output_tokens = 0message.source.modelmodelcwd→resolveProjectNameproject关键实现点
zstdDecompressSync只解压第一帧。parser 按帧循环解压并拼接(靠{ info: true }返回的engine.bytesWritten推进偏移)。sessionId|messageId去重,避免重复计数。parsers/dsh.ts)→ sync 调度(syncDsh+SYNC_SOURCE_IDS)→ source 探测(source-presence.ts)→ tool catalog → 上传事件映射(upload/events.ts)→ 前端 label/颜色/图标/关于页。测试
packages/core/test/dsh.test.ts新增 5 个用例(覆盖:环境变量、文件发现、基础解析、幂等、多帧 zstd),全量 core 测试 246 个通过,无回归。Co-Authored-By: ZCode noreply@z.ai