Skip to content

feat: import Anthropic Console/Workbench session exports#46

Open
jakduch wants to merge 5 commits into
josepe98:mainfrom
jakduch:feat/workbench-import
Open

feat: import Anthropic Console/Workbench session exports#46
jakduch wants to merge 5 commits into
josepe98:mainfrom
jakduch:feat/workbench-import

Conversation

@jakduch
Copy link
Copy Markdown
Collaborator

@jakduch jakduch commented May 23, 2026

What does this add and why do you believe it belongs in this dashboard?

Adds a python3 cli.py import-workbench <PATH> command that imports an Anthropic Console / Workbench session export (the JSON you can download from console.anthropic.com after experimenting in the Workbench) into the same SQLite store the CLI scanner writes to. Imported turns land under a synthetic Workbench project so they appear in the dashboard alongside Claude Code CLI usage.

Most users who run this dashboard also iterate on prompts in the Console — model picks, cache strategies, and one-off experiments. Today that spend is invisible here, which makes the "personal Claude usage" picture incomplete and skews per-model totals. Pulling those exports in keeps the dashboard promise (one place to see your Claude usage) without coupling to any Anthropic API: it is a local, opt-in file import. Re-importing the same file is a no-op thanks to a deterministic message_id and the existing unique index on turns.message_id, so it is safe to run repeatedly.

Checklist

Code correctness

  • All calcCost() calls pass 6 arguments: (model, inp, out, cache_read, cache_creation, cache_1h)
  • JavaScript template literals use bare backticks (`), not escaped ones (\`)
  • No JS variables referenced before they are defined
  • No new third-party dependencies introduced

Tests

  • python3 -m unittest discover -s tests -v — all passing
  • python3 -m unittest tests.test_browser -v — all passing
  • New behaviour is covered by at least one test

Scope

  • This is a single concern — one feature or fix per PR
  • Only touches existing files (dashboard.py, scanner.py, cli.py, pricing.py, cowork.py, tests/) — or I have explained below why a new file is needed

jakduch added 2 commits May 23, 2026 20:46
Adds 'python3 cli.py import-workbench <PATH>' which ingests JSON dumps
exported from the Anthropic Console/Workbench so prompt-engineering work
shows up alongside Claude Code sessions in the dashboard.

- Graceful parser: accepts top-level arrays, {runs|messages|data:[...]}
  wrappers, snake_case and camelCase token field names, ISO 8601 and
  unix-epoch timestamps. Malformed records are skipped with a count.
- Imported entries are assigned project_name='Workbench',
  session_id='wb-<sha1(file)[:12]>', git_branch='', and
  message_id='wb-<file>-<line>' so re-importing the same file is a no-op
  (deduped via the existing unique partial index on turns.message_id).
- Reuses scanner.upsert_sessions / scanner.insert_turns so totals,
  pricing, and dashboard queries work without further changes.
- Prints a summary: imported, already-present, skipped, total tokens.

The Console export format isn't officially documented; the parser is
intentionally lenient so it can adapt if Anthropic tweaks the shape.

Tests (9) cover empty input, valid records, malformed entries skipped,
object/camelCase variants, idempotency, summary output, missing file
and invalid JSON error paths.
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants