feat: add --format json option to canonical command - #117
Merged
ErikBjare merged 2 commits intoAug 23, 2026
Conversation
Add JSON output support to the 'canonical' subcommand to enable machine-readable access to canonical events. This supports the ActivityWatch × AI agent enablement workflow, allowing agents to consume categorized activity data without reimplementing the canonical query. - Add --format option with 'table' (default) and 'json' choices - JSON output emits event array with ISO-8601 timestamps - Preserves existing table format behavior (human-readable) Closes: ActivityWatch/aw-client contribution for agent enablement. Reference: https://github.com/ActivityWatch/aw-client/issues (agent enablement docs)
Greptile SummaryThe canonical command now supports machine-readable JSON output while retaining table output as the default.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported duration serialization issue is fixed by converting each event duration to seconds before JSON encoding. Important Files Changed
Reviews (2): Last reviewed commit: "fix(cli): serialize canonical durations ..." | Re-trigger Greptile |
| json_events = [ | ||
| { | ||
| "timestamp": e.timestamp.isoformat(), | ||
| "duration": e.duration, |
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
Fixed in fb7cee7: canonical JSON now serializes Event.duration via total_seconds(). I also formatted the option declaration so Black passes. Verified the JSON path with a non-empty event (numeric 1.5 seconds), plus 7 unit tests, mypy, and Black locally.
Contributor
Author
|
@greptileai review |
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
Add JSON output support to the 'canonical' subcommand to enable machine-readable access to canonical events.
Motivation
This addresses the ActivityWatch × AI agent enablement workflow, allowing AI agents to consume categorized activity data without reimplementing the canonical query. The feature was documented in the agent enablement docs but the CLI flag implementation was missing.
Changes
--formatoption to canonical command with choices: 'table' (default, preserving existing behavior) and 'json'Usage
Testing
The change is backward compatible:
aw-coremodels