Skip to content

feat: add --file flag and better errors to crit comment --json#480

Merged
tomasz-tomczyk merged 2 commits intomainfrom
crit-comment-json-file-flag
May 7, 2026
Merged

feat: add --file flag and better errors to crit comment --json#480
tomasz-tomczyk merged 2 commits intomainfrom
crit-comment-json-file-flag

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • New --file <path> flag (alias -f, with - for stdin) on crit comment --json so callers can hand JSON over via a file path instead of shell-quoted stdin. Multi-paragraph "body" strings are exactly the case where shell quoting silently corrupts JSON; pointing at a file written by the agent's normal write tooling sidesteps the whole class.
  • Parse errors now include byte offset, line/column, and a snippet of the input around the offending position with control characters rendered visibly (e.g. >>>HERE<<< next to the literal \n that broke things). Replaces the opaque invalid character '\n' in string literal with a locatable diagnostic.
  • Documented the new flag and "prefer --file for multi-paragraph bodies" guidance across AGENTS.md and all 8 integration prompts (claude-code, codex, cursor, github-copilot, cline, windsurf, opencode, aider). Bumped plugin.json to 1.5.1 so claude-code users pick up the updated SKILL.

Review

  • Code review: passed (intent clean, no blockers)
  • Parity audit: N/A (no review-page files)

Test plan

  • New tests in comment_json_input_test.go: --file <path> happy path, --file - reads stdin, --file <missing> errors with path in message, default stdin still works, malformed JSON parse-error formatting (offset/line/col/snippet/visible-control), flag parsing for --file and -f.
  • gofmt -l, go vet, golangci-lint run, go test -race ./... all clean.

🤖 Generated with Claude Code

Pass --file <path> instead of piping JSON through stdin to avoid
shell-quoting hazards with multi-paragraph bodies. --file - keeps
stdin behavior explicit. Stdin remains the default when --file is
omitted.

Parse errors now include byte offset, line/column, and a snippet
around the offending position with control characters rendered
visibly, so a stray newline inside a "body" string is immediately
locatable instead of opaque.

Documented across AGENTS.md and all 8 agent integration prompts;
plugin manifest bumped to 1.5.1 so users pick up the updated guidance.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 82.22222% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.33%. Comparing base (25f6d64) to head (2f91bd8).

Files with missing lines Patch % Lines
main.go 82.22% 8 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #480      +/-   ##
==========================================
+ Coverage   69.06%   69.33%   +0.26%     
==========================================
  Files          43       43              
  Lines       10733    10817      +84     
==========================================
+ Hits         7413     7500      +87     
+ Misses       2759     2751       -8     
- Partials      561      566       +5     
Flag Coverage Δ
e2e 32.16% <0.00%> (-0.28%) ⬇️
unit 67.19% <82.22%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Adds helper-subprocess tests around runCommentJSONScoped (success,
parse-error exit, missing-file exit) and table-driven coverage for
jsonErrorOffset (SyntaxError / UnmarshalTypeError / generic / nil)
and visibleControl (LF / CR / TAB / mixed / empty).
@tomasz-tomczyk tomasz-tomczyk merged commit 294208c into main May 7, 2026
8 of 10 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the crit-comment-json-file-flag branch May 7, 2026 11:17
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