Files
magpie/internal/sessions/testdata
yetone f5553d7103 sessions: a Pi subagent's calls are its lead session's, on its own model (nzvzbmz78932 on X)
nzvzbmz78932 on X: "在pi子代理中使用了deepseek 但是不显示用量". pi-subagents
(npm 0.88.1) runs each subagent as a Pi of its own, its session in
<lead file's folder>/<run id>/run-<n>/session.jsonl (async and parallel
runs a level deeper), or under extensions/subagent/config.json's
defaultSessionDir, its header's parentSession naming the lead's file.
magpie read only sessions/*/*.jsonl, so those files were never read. The
lead's `subagent` tool result carries the subagents' usage summed, and
piParse counted it on the lead's model and provider: a lead on magpie's
entry made it the gateway's (piGateway), so DeepSeek's calls were on no
page, Usage or Sessions.

- piFilesIn reads every session file under a lead's folder as the
  lead's (non-main, like omp's), and the defaultSessionDir ones through
  their headers' parentSession, up to 8 levels.
- piSubagentsRead: a tool result whose every sessionFile is one of those
  counts nothing, in piParse and piCall; one naming a file not read
  still counts as before.
- The scout's header id is in Session.Subs (pi is idInFile), so a
  subagent on magpie's entry is the lead's row to the gateway too.
- state.codexPath is parsePath, the file read, for piLeadID: a new field
  took state past its 416-byte class (TestStateFitsItsSizeClass).
- parseVersions and callParseVersions pi/raft/cindy raised.

The fixture is a real run: Pi 1.4.0 with pi-subagents 0.88.1 in a
sandbox PI_CODING_AGENT_DIR, a lead and one scout on a relay's
deepseek/deepseek-flash; system prompts dropped, paths rewritten.

Run (mica, at this head):
- go test ./internal/sessions: ok (119s)
- GOOS=linux and GOOS=windows go vet ./internal/sessions: ok; gofmt clean.
- Linux (wsl-run, magpie-desktop): TestPi*, TestOmp*, TestCodex*,
  TestStateFits*: ok
TestPiSubagentCalls: beside the lead and in defaultSessionDir, each with
the lead on the relay and on magpie's entry (the reporter's case).
Broken by hand: without the walk, 3 of 5 calls and 0 of 2 with the lead
on magpie (red); without the tool-result skip, 6 calls, the sum counted
again (red); the Subs check was red while it named the run id.
Not tried: the reporter's own files; a subagent nesting subagents; a
subagent run on magpie's entry against a live gateway.

With f0fb22c6b and 5bc816c1a below it, at this head (mica): go test
./internal/sessions ./internal/agent ./internal/claudecode ok,
./internal/gateway -run TestClaude ok, GOOS=linux and windows go vet of
the four ok, gofmt clean.
2026-11-13 19:07:34 +08:00
..
sessions: ZCode, DeepSeek Harness, Cline and Qoder's sessions are listed too (lml: 希望会话里也能看到 ZCode、Qoder CN、Cline、DeepSeek Harness 的) — ZCode's are OpenCode's tables in ~/.zcode/cli/db/db.sqlite, read as OpenCode's database is (opened read-only), its tokens the AI SDK's (input less the cache, output as it is), its model modelId, a title_source of default no title, a prompt typed a real_user's; dsh's are ~/.dsh/sessions ($DSH_HOME), a folder a session, the latest format's session[.vN].jsonl[.zstd] read whole, zstd frames and all, a subagent's (parentSession) in its parent's, a fork's seeded events (seedLength, or up to an inherited session/end-seed) counted where they were first written; Cline's are ~/.cline/data/sessions ($CLINE_SESSION_DATA_DIR, $CLINE_DATA_DIR, $CLINE_DIR), <id>.messages.json with its manifest <id>.json for the cwd, the prompt and the title, a subagent's other messages file beside it, a fork's messages before its forkedAt not counted, cline --id <id> to pick it up; Qoder's and Qoder CN's are Claude Code's lines in ~/.qoder/projects and ~/.qoder-cn/projects ($QODER_CONFIG_DIR, $QODERCN_CONFIG_DIR), qodercli --resume / qoderclicn --resume. Each folder is watched when it's there (Dirs). Tests keep HOME in their sandbox now. Tested with made-up fixtures for each (a ZCode database made in the test, dsh plain and zstd, forks of both formats, a Cline fork and subagent, both Qoder builds), and read-only against copies of this machine's ZCode database and dsh sessions: 2 and 13 sessions, their token totals the same as a separate tally of the raw rows
2026-09-28 22:45:50 +08:00
sessions: ZCode, DeepSeek Harness, Cline and Qoder's sessions are listed too (lml: 希望会话里也能看到 ZCode、Qoder CN、Cline、DeepSeek Harness 的) — ZCode's are OpenCode's tables in ~/.zcode/cli/db/db.sqlite, read as OpenCode's database is (opened read-only), its tokens the AI SDK's (input less the cache, output as it is), its model modelId, a title_source of default no title, a prompt typed a real_user's; dsh's are ~/.dsh/sessions ($DSH_HOME), a folder a session, the latest format's session[.vN].jsonl[.zstd] read whole, zstd frames and all, a subagent's (parentSession) in its parent's, a fork's seeded events (seedLength, or up to an inherited session/end-seed) counted where they were first written; Cline's are ~/.cline/data/sessions ($CLINE_SESSION_DATA_DIR, $CLINE_DATA_DIR, $CLINE_DIR), <id>.messages.json with its manifest <id>.json for the cwd, the prompt and the title, a subagent's other messages file beside it, a fork's messages before its forkedAt not counted, cline --id <id> to pick it up; Qoder's and Qoder CN's are Claude Code's lines in ~/.qoder/projects and ~/.qoder-cn/projects ($QODER_CONFIG_DIR, $QODERCN_CONFIG_DIR), qodercli --resume / qoderclicn --resume. Each folder is watched when it's there (Dirs). Tests keep HOME in their sandbox now. Tested with made-up fixtures for each (a ZCode database made in the test, dsh plain and zstd, forks of both formats, a Cline fork and subagent, both Qoder builds), and read-only against copies of this machine's ZCode database and dsh sessions: 2 and 13 sessions, their token totals the same as a separate tally of the raw rows
2026-09-28 22:45:50 +08:00
sessions: ZCode, DeepSeek Harness, Cline and Qoder's sessions are listed too (lml: 希望会话里也能看到 ZCode、Qoder CN、Cline、DeepSeek Harness 的) — ZCode's are OpenCode's tables in ~/.zcode/cli/db/db.sqlite, read as OpenCode's database is (opened read-only), its tokens the AI SDK's (input less the cache, output as it is), its model modelId, a title_source of default no title, a prompt typed a real_user's; dsh's are ~/.dsh/sessions ($DSH_HOME), a folder a session, the latest format's session[.vN].jsonl[.zstd] read whole, zstd frames and all, a subagent's (parentSession) in its parent's, a fork's seeded events (seedLength, or up to an inherited session/end-seed) counted where they were first written; Cline's are ~/.cline/data/sessions ($CLINE_SESSION_DATA_DIR, $CLINE_DATA_DIR, $CLINE_DIR), <id>.messages.json with its manifest <id>.json for the cwd, the prompt and the title, a subagent's other messages file beside it, a fork's messages before its forkedAt not counted, cline --id <id> to pick it up; Qoder's and Qoder CN's are Claude Code's lines in ~/.qoder/projects and ~/.qoder-cn/projects ($QODER_CONFIG_DIR, $QODERCN_CONFIG_DIR), qodercli --resume / qoderclicn --resume. Each folder is watched when it's there (Dirs). Tests keep HOME in their sandbox now. Tested with made-up fixtures for each (a ZCode database made in the test, dsh plain and zstd, forks of both formats, a Cline fork and subagent, both Qoder builds), and read-only against copies of this machine's ZCode database and dsh sessions: 2 and 13 sessions, their token totals the same as a separate tally of the raw rows
2026-09-28 22:45:50 +08:00