feat: add DeepSeek Harness (dsh) provider - #1001
Open
MiloMMIN wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new dsh provider to CodeBurn to ingest DeepSeek Harness session logs (including multi-frame zstd JSONL), enabling cost/token attribution by model/project/turn and integrating the provider into discovery, caching, docs, and the macOS menubar change guard.
Changes:
- Implement
src/providers/dsh.tswith multi-frame zstd frame scanning + per-(turn,step) usage projection semantics and tool/skill/bash extraction. - Register
dshacross the provider registry, env var declarations, and session-cache parse-versioning. - Add provider documentation and a comprehensive
vitestsuite for discovery/parsing/display-name behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/providers/dsh.test.ts | New test suite covering DSH discovery/parsing semantics (zstd + plain JSONL) and display-name normalization. |
| tests/provider-registry.test.ts | Updates expected core provider registration list to include dsh. |
| tests/provider-env-declarations.test.ts | Declares dsh.ts as a provider that reads env vars. |
| src/session-cache.ts | Adds DSH_HOME invalidation and a dsh parse-version key. |
| src/providers/index.ts | Eagerly registers the new dsh provider. |
| src/providers/dsh.ts | New DSH provider implementation (discovery + parsing + zstd frame handling). |
| README.md | Updates supported-tool count and adds DSH to the supported tools section. |
| mac/Sources/CodeBurnMenubar/Data/UsageDataChangeGuard.swift | Adds DSH sessions directory to the menubar refresh change-detection roots. |
| docs/providers/README.md | Adds DSH to the provider docs index table. |
| docs/providers/dsh.md | New DSH provider documentation (paths, format, deduping, quirks). |
| docs/architecture.md | Updates provider registration tier list to include eager dsh. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+17
| const zstdCompress = (zlib as { zstdCompressSync?: (buf: Buffer) => Buffer }).zstdCompressSync | ||
|
|
Comment on lines
+189
to
+196
| // Cheap discovery probe: decompress ONLY the first frame (the session header | ||
| // batch) instead of the whole log. The header frame is tiny, so a bounded head | ||
| // read almost always contains it; fall back to a full read when it does not. | ||
| async function readSessionHeader(filePath: string): Promise<DshEvent | null> { | ||
| const firstLine = async (): Promise<string | null> => { | ||
| if (filePath.endsWith('.zstd')) { | ||
| if (!zstdDecompress) return null | ||
| let head: Buffer |
Reads DSH sessions from $DSH_HOME/sessions (default ~/.dsh/sessions): one directory per session holding session.jsonl.zstd (or an uncompressed session.jsonl when compression=none). The .zstd log is a concatenation of independent zstd frames (one per appended event batch), which node:zlib's one-shot API cannot decode whole; the provider ports the frame-boundary scan from the official @deepseek-ai/dsh-session-persistence-jsonl package and decompresses frame by frame. zstd needs Node >= 22.15; older runtimes get a notice and DSH data is skipped. Usage follows dsh-token-meter semantics: an assistant/message usage report is the final value for its (turn, step) and replaces the earlier assistant/chunk sample instead of double counting. Models come from the most recent request/header config; reasoning tokens are billed at the output rate. One parsed call per (turn, step), dedup key dsh:<sessionId>:<turn>:<step>.
MiloMMIN
force-pushed
the
feat/dsh-provider
branch
from
August 16, 2026 08:10
58d5d42 to
0b61419
Compare
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.
Summary
dsh): reads sessions from$DSH_HOME/sessions/<encoded-cwd>/session-<uuid>/session.jsonl.zstd(default~/.dsh, plus the uncompressedsession.jsonlvariant).node:zlib's one-shot API cannot decode as a whole. The provider ports the frame-boundary scan (scanZstdFrames) from the official@deepseek-ai/dsh-session-persistence-jsonlpackage and decompresses frame by frame using only public APIs. zstd requires Node >= 22.15; older runtimes get a stderr notice and DSH data is skipped (same pattern as the Zed provider).dsh-token-meter's projection semantics: anassistant/messageusage report is the final value for its(turn, step)and replaces the earlierassistant/chunksample (adjacent reports of the same API call), never double counting. Model attribution comes from the most recentrequest/headerconfig; reasoning tokens are billed at the output rate (same as Hermes/Gemini). One parsed call per(turn, step), dedup keydsh:<sessionId>:<turn>:<step>.Testing
npm testpasses — the new suite (tests/providers/dsh.test.ts, 22 tests) plus registry/env/probe-roots/session-cache suites are green. Fulltests/providerson this Windows machine shows 45 failures that exist identically on the unmodified baseline (home-dir-related: claude-config-dirs, copilot, devin, ...); none are dsh-related.npm run buildsucceeds —build:cli(tsup) andtsc --noEmitare clean. Note: the fullbuildscript's first step (bundle-litellm, re-fetching the upstream pricing snapshot) fails on this machine withECONNRESETdue to local network restrictions; that fetch is unrelated to this change, which does not touch pricing data.For new providers only:
npm run dev -- todayshows correct costs and session counts for this providernpm run dev -- models --provider dshshows correct model names and pricingreport --provider dsh -p all --format jsonagainst a real~/.dsh(25 sessions):Cross-check: token totals summed independently from the raw session logs (frame-by-frame decode + the replace-on-final usage rule) match the report exactly (sessions=25, calls=1027, input/output/cacheRead/cacheWrite identical).
Dashboard (
npm run dev) with DSH included in theallview:Provider cycling (
p) detectsdshand the TUI shows it asDeepSeek Harness;codeburn doctorprobes$DSH_HOME/sessions.