Skip to content

feat: consistency pass for --json across tw react/unreact, comment view, conversation with#176

Merged
scottlovegrove merged 4 commits intomainfrom
scottl/json-consistency-pass
Apr 16, 2026
Merged

feat: consistency pass for --json across tw react/unreact, comment view, conversation with#176
scottlovegrove merged 4 commits intomainfrom
scottl/json-consistency-pass

Conversation

@scottlovegrove
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #175 — audits every command for missing --json / --ndjson support and closes three gaps:

  • tw react / tw unreact — emitted plain text only; the only mutating commands without --json. Adds --json that outputs { targetType, targetId, emoji, action } (and dryRun: true for dry-run).
  • tw comment view — declared --json but not --ndjson, even though tw thread view and tw msg view both do. Adds --ndjson matching the single-item-wrapped-in-array pattern those siblings use.
  • tw conversation with — declared --json / --ndjson but the not-found branch fell back to a plain-English message, breaking JSON consumers. Routes the empty case through listConversationsWithUser so --json emits [] and --ndjson emits nothing.

Each gap is its own commit so they can be reviewed independently. A final commit regenerates skills/twist-cli/SKILL.md.

Test plan

  • npm test passes (448 tests, +5 new)
  • npm run type-check, npm run lint:check, pre-push test hook all clean
  • npm run sync:skill clean; SKILL.md regenerated
  • Manual smoke: tw react thread <id> +1 --json | jq . returns { action: "added", ... }
  • Manual smoke: tw unreact thread <id> +1 --json --dry-run | jq .dryRun returns true and the API is not called
  • Manual smoke: tw comment view <id> --ndjson emits a single NDJSON line
  • Manual smoke: tw conversation with <user> --json when no DM exists returns []

🤖 Generated with Claude Code

scottlovegrove and others added 4 commits April 16, 2026 17:20
All other mutating commands (thread/conversation/comment/msg/away) already
emit JSON on --json; react and unreact were the only outliers. Useful for
scripting flows like "react on thread when CI passes."

Output is a minimal status object ({ targetType, targetId, emoji, action })
since the API returns void, matching the pattern in thread/delete.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Matches the behavior of tw thread view and tw msg view, both of which
support --ndjson on single-item views by wrapping the item in a
1-element array.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tw conversation with declared --json and --ndjson but fell back to a
plain-text "No 1:1 conversation found" message when no match existed,
breaking JSON consumers. Route the empty case through the shared helper
so --json emits [] and --ndjson emits nothing, matching how the helper
already handles non-empty results.

Also hardens listConversationsWithUser so other callers benefit if they
pass an empty array with --json.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Picks up the react/unreact --json and comment view --ndjson entries
added in the preceding commits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@doistbot doistbot requested a review from nvignola April 16, 2026 16:23
@scottlovegrove scottlovegrove self-assigned this Apr 16, 2026
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label Apr 16, 2026
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

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

This PR does a great job completing a consistency pass across the CLI by adding missing --json and --ndjson support to the react, unreact, comment view, and conversation with commands. These additions ensure structured output behaves predictably across the tool, making it much more robust for automated scripting. No issues were flagged during the review.

Share FeedbackReview Logs

@scottlovegrove scottlovegrove merged commit 5db95cc into main Apr 16, 2026
5 checks passed
@scottlovegrove scottlovegrove deleted the scottl/json-consistency-pass branch April 16, 2026 16:27
doist-release-bot bot added a commit that referenced this pull request Apr 16, 2026
## [2.31.0](v2.30.0...v2.31.0) (2026-04-16)

### Features

* consistency pass for --json across tw react/unreact, comment view, conversation with ([#176](#176)) ([5db95cc](5db95cc))
@doist-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.31.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants