Trace collection
hevd and hev index capture sessions from Claude Code, Codex, Antigravity,
OpenCode, Pi and dot into one normalized archive, with secret redaction before
any write. This page documents harness-specific capture details, skill-load
detection, and factory cost attribution.
OpenCode
Kit reads OpenCode’s SQLite session database (opencode.db and channel builds
opencode-<channel>.db) with harness=opencode — no export, plugin or OpenCode
config change is needed. Both OpenCode 2.x (session_v2, session_message,
session_part) and OpenCode 1.2–1.19.x (session, message, part)
layouts are supported.
| OS | Default data directory |
|---|---|
| Linux / macOS | $XDG_DATA_HOME/opencode or ~/.local/share/opencode |
| Windows | %USERPROFILE%\.local\share\opencode |
Root precedence: HEV_OPENCODE_DATA_DIR, then [capture] opencode_data_dir,
then the default above.
hev index --read-side --tier all
hev traces search --harness opencode 'distinctive phrase'
hev traces show <session id>
- Safe concurrent reads: When OpenCode is running (
-walpresent), kit opens withmode=roandquery_onlyfor one session per read transaction. When OpenCode is closed, kit opens withimmutable=1and verifies the file did not change mid-read. - Complete turns only: Kit captures up to the first assistant message
without
time.completed(or after an hour idle if OpenCode was killed mid-reply), so truncated turns or half-streamed secrets are never archived. - 1.x -> 2.x upgrades: Existing 1.x turns keep their original IDs and only new 2.x messages written after the upgrade are appended.
- Captured: user prompts,
@agentmentions,!shell commands, assistant text/reasoning/tool calls, model/effort/usage/cost, session titles, subagent side-chains, and skill loads. Omitted: step/compaction/retry markers, MCP resource bodies, credentials, and pre-1.2 JSON file stores.
Pi
Kit reads Pi 1.2.0’s native JSONL v3 sessions with harness=pi. Discovery
scans .jsonl files recursively and never reads Pi auth or settings stores.
Root precedence:
HEV_PI_SESSIONS_DIR[capture] pi_sessions_dir~/.pi/agent/sessions
HEV_PI_SESSIONS_DIR=/path/to/pi-sessions hev index --read-side --tier all
hev traces search --harness pi --json 'query'
- Immutable history: Sessions are archived in file order with original entry IDs, timestamps, working directories and tree parents. Model/thinking changes follow entry ancestry; compaction and branch summaries are recorded without erasing prior history.
- Validation: Malformed JSON, incomplete trailing lines, duplicate IDs, or records over 16 MiB reject the unit for that scan and retry once the file changes.
Skill capture
Every harness parser attaches skill_loads to normalized blocks and records a
distinct skills list on each session row (via: tool, read or command):
- Tool / command loads: Claude Code’s
Skilltool and/commandinvocations, OpenCode’sskilltool (name/id), and Pi’sskilltool. - File / shell reads: Reads of
.../skills/<name>/SKILL.mdvia read tools or shell read commands (cat,sed,head,tail,less,bat,rg,grep, etc., parsed with a shell syntax parser so comments, echoes and dynamic expressions are not miscounted). - Normalization: Surrounding quotes/punctuation, JSON wrappers and plugin
prefixes (
kit:hev-traces->hev-traces) are stripped so tool calls andSKILL.mdreads count as the same skill.
Preview skill capture locally without writing to any backend:
hev skills-preview --out /tmp/skills-plan.json
Pass --existing-sessions FILE to compare against existing rows, or override
roots with --claude-root, --codex-root, --pi-root, --opencode-root,
and --dot-root.
Cost attribution
hev serve --factory-dir DIR and hev cost-price price captured sessions
against prices.toml (USD per million tokens, exact model match, reasoning
included in output tokens, 5m/1h cache tiers and long-context thresholds) and
allocate flat-rate plans from subscriptions.toml across each plan’s billing
week (reset_day, reset_hour).
hev cost-price --dir "$HOME/.factory/costs" --output "$HOME/.factory/costs/priced.jsonl"
hev serve --factory-dir "$HOME/.factory/costs" --factory-team example --factory-repos example/api,example/web
- Unknown models or omitted
monthly_usdfields remain unpriced / unavailable rather than guessed as zero. - Weekly subscription spend (
monthly_usd * 12 / 365.2425 * 7) is allocated proportionally by tokens before window/filter selection.