Skip to content

feat: add --merge flag to combine JSON exports - #10

Open
pasrom wants to merge 1 commit into
JeanMeijer:mainfrom
pasrom:feat/merge-json-exports
Open

feat: add --merge flag to combine JSON exports#10
pasrom wants to merge 1 commit into
JeanMeijer:mainfrom
pasrom:feat/merge-json-exports

Conversation

@pasrom

@pasrom pasrom commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds --merge CLI flag to combine multiple JSON exports into a single heatmap
  • Enables merging usage data from different machines (e.g. work laptop + home desktop)
  • Handles sparse JSON exports where daily entries only contain displayValue without full token breakdowns

Usage

# Export on each machine
slopmeter --claude -f json -o machine-a.json
slopmeter --claude -f json -o machine-b.json

# Merge into one heatmap
slopmeter --merge machine-a.json --merge machine-b.json -o combined.png

# Or merge to JSON for further processing
slopmeter --merge machine-a.json --merge machine-b.json -f json -o combined.json

Test plan

  • Merge two JSON exports and verify tokens are correctly summed per day
  • Merge exports with different providers (e.g. claude + opencode) and verify separate heatmaps render
  • Merge sparse exports (only displayValue, no token fields) without errors
  • Verify --merge with --dark, --format, and --output flags

Summary by cubic

Adds a new --merge flag to the slopmeter CLI to combine multiple JSON exports from different machines into one output. Merges per provider into a single heatmap or a merged JSON export.

  • New Features
    • --merge <files...> reads JSON exports, groups by provider, and merges daily totals across files (sparse entries supported; missing token fields default to 0).
    • Supports PNG/SVG/JSON outputs and respects --dark, -f/--format, and -o/--output.
    • Validates inputs and errors when no provider data is found.

Written for commit 17a996c. Summary will update on new commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/cli.ts">

<violation number="1" location="packages/cli/src/cli.ts:311">
P1: `--merge` is documented as single-flag variadic (`<files...>`), but `parseArgs` is configured in a way that rejects the second bare filename, causing documented usage to fail at parse time.</violation>

<violation number="2" location="packages/cli/src/cli.ts:356">
P2: Single-summary providers skip merge normalization/recomputation, causing inconsistent derived values versus providers that go through `mergeUsageSummaries`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/cli/src/cli.ts
Comment thread packages/cli/src/cli.ts
Allows merging slopmeter JSON exports from different computers into a
single heatmap. Usage:

  slopmeter --merge machine-a.json --merge machine-b.json -o merged.png

Also handles sparse JSON exports where daily entries only contain
displayValue without full token breakdowns.
@pasrom
pasrom force-pushed the feat/merge-json-exports branch from 53da926 to 17a996c Compare March 12, 2026 06:40
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.

1 participant