feat(core): improve DeepSeek Harness usage collection - #42
Open
yudaxia1 wants to merge 2 commits 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>
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.
🏷️ 变动类型
🖥️ 影响范围
Desktop 和 CLI 通过同一个 core parser 采集 DSH 用量;本次不涉及 Dashboard UI。
🔗 关联 Issue
基于 #39 继续完善,可作为 #39 的后续替代 PR(supersedes #39)。
本 PR 完整保留了 @cyhano 在 #39 中的原始提交和贡献记录;新增改动单独放在后续 commit 中。
💡 改动说明
#39 已经完成 DeepSeek Harness(DSH)数据源的主体接入。本 PR 在此基础上补充实际 DSH 日志场景,并修复增量扫描时可能重复累计 token 的问题:
session.jsonl.zstd和关闭压缩后的session.jsonlrequest/header.data.header.config.model回退获取cacheWriteTokens计入cache_creation_input_tokens和总 token未改动面板 UI。
验证结果:
pnpm build通过git diff --check通过📝 Changelog
@juejin-opensource/jusage(CLI)~/.dsh/sessions/**/session.jsonl(.zstd),按消息增量去重统计 input/output/cache-read/cache-write token、模型与项目,支持多帧 zstd、明文日志与模型回退。@juejin-opensource/jusage-core~/.dsh/sessions/**/session.jsonl(.zstd),按消息增量去重统计 input/output/cache-read/cache-write token、模型与项目,支持多帧 zstd、明文日志与模型回退。@juejin-opensource/jusage-desktop~/.dsh/sessions/**/session.jsonl(.zstd),按消息增量去重统计 input/output/cache-read/cache-write token、模型与项目,支持多帧 zstd、明文日志与模型回退。☑️ 自查清单
<type>/<end>/<short-desc>pnpm build通过