Skip to content

feat: json flag#112

Merged
Kikobeats merged 7 commits into
masterfrom
next
May 2, 2026
Merged

feat: json flag#112
Kikobeats merged 7 commits into
masterfrom
next

Conversation

@Kikobeats
Copy link
Copy Markdown
Member

@Kikobeats Kikobeats commented May 2, 2026

Note

Medium Risk
Changes the CLI’s primary request/response and rendering flow (spinner, output formatting, clipboard behavior), which may affect existing scripts and terminal output expectations. Adds optional JSON serialization that includes request metadata and can expose full API keys when --json-full is used.

Overview
Adds --json and --json-full flags to emit a serialized request + response JSON payload (with API key masked by default) and updates help/examples accordingly.

Refactors src/api.js output flow to choose between buffered rendering vs JSON mode, measures duration explicitly, normalizes header handling, and centralizes clipboard/header/pretty-print helpers in new src/util.js and src/print-json.js.

Updates defaults to auto-detect colorized output (removing the explicit --colors flag), switches error printing to print-text, pins ava to v7, and adds comprehensive AVA test coverage for the new flags and refactors.

Reviewed by Cursor Bugbot for commit 3e95b41. Bugbot is set up for automated code reviews on this repo. Configure here.

@Kikobeats Kikobeats changed the title fix: don’t check timings feat: json flag May 2, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented May 2, 2026

Coverage Report for CI Build 25250232678

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Warning

No base build found for commit ca35902 on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 98.211%

Details

  • Patch coverage: 210 of 210 lines across 7 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 501
Covered Lines: 501
Line Coverage: 100.0%
Relevant Branches: 114
Covered Branches: 103
Branch Coverage: 90.35%
Branches in Coverage %: Yes
Coverage Strength: 4.3 hits per line

💛 - Coveralls

@Kikobeats
Copy link
Copy Markdown
Member Author

Kikobeats commented May 2, 2026

@cursor review

Copy link
Copy Markdown

Copilot AI commented May 2, 2026

@cursor review

Found and fixed one issue during review: src/index.js still referenced ./print (the old filename) after the rename to ./print-text, causing a runtime MODULE_NOT_FOUND error. Fixed in 4828439 — also updated the corresponding test mock.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because on-demand usage is turned off. To enable Bugbot Autofix, turn on on-demand usage and set a spend limit in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a2ac8f5. Configure here.

Comment thread src/api.js
copiedValue = body
}
clipboardy.writeSync(JSON.stringify(copiedValue, null, 2))
toClipboard(JSON.parse(bodyText), flags)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy with non-JSON body crashes without try-catch

Medium Severity

toClipboard(JSON.parse(bodyText), flags) will throw when bodyText isn't valid JSON (e.g., data URIs, image buffers, or text/plain responses) and --copy is used. The previous implementation wrapped JSON.parse(body) in a try-catch, falling back to the raw body on parse failure. That safety net was removed in this rewrite.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a2ac8f5. Configure here.

@Kikobeats Kikobeats merged commit bfb3b3d into master May 2, 2026
2 checks passed
@Kikobeats Kikobeats deleted the next branch May 2, 2026 10:50
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 3e95b41. Configure here.

Comment thread src/api.js
copiedValue = body
}
clipboardy.writeSync(JSON.stringify(copiedValue, null, 2))
toClipboard(JSON.parse(bodyText), flags)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing try-catch crashes copy for non-JSON responses

High Severity

JSON.parse(bodyText) in the flags.copy path will throw a SyntaxError when the response body is not valid JSON. This applies to base64 data URIs, images, text/plain, and text/html responses — all of which reach this line in the pretty-mode flow. The old code had a try-catch that gracefully fell back to the raw body when parsing failed; that guard was removed in this refactor.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3e95b41. Configure here.

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.

3 participants