Skip to content

fix(cli): exit non-zero when rig ask names an unknown rig - #1202

Open
Coder8124 wants to merge 1 commit into
mvschwarz:mainfrom
Coder8124:fix/ask-unknown-rig-exit-code
Open

Coder8124 wants to merge 1 commit into
mvschwarz:mainfrom
Coder8124:fix/ask-unknown-rig-exit-code

Conversation

@Coder8124

@Coder8124 Coder8124 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

rig ask <rig> "<question>" exits 0 when the rig doesn't exist. The daemon answers with rig: null and guidance (ask-service.ts:80), and the CLI prints Rig: nosuchrig [not found], or the JSON in --json mode, but the exit status is 0. A script or agent therefore can't tell a mistyped or ambiguous rig name from a real answer that found nothing. rig send, rig transcript and rig release already exit 1 when their target is missing.

$ rig ask nosuchrig hi; echo $?
Rig: nosuchrig  [not found]
...
0

Fix

When the daemon returns rig: null, set process.exitCode = 1. This applies in both human and --json mode. The output itself doesn't change. When the rig is found but the evidence is insufficient (for example, no useful keywords), the command still exits 0.

Tests

packages/cli/test/ask.test.ts:

  • The existing unknown-rig test now also asserts exit code 1.
  • New: with --json, an unknown rig still prints parseable JSON with rig: null and exits 1.
  • The insufficient-keywords test now asserts that no exit code is set.

Without the fix, both unknown-rig assertions fail. npx vitest run test/ask passes (32 tests) and tsc --noEmit is clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • The ask command now exits with status 1 when a rig name matches no rig or matches multiple rigs. It continues to display the existing human-readable or JSON result, including rig: null in JSON output for an unknown rig.

rig ask <rig> prints "[not found]" (or the JSON with rig: null) but exits
0, so a script or agent cannot tell a mistyped or ambiguous rig name from
an answer with no matches. rig send, transcript and release already exit
1 for a missing target.

Set process.exitCode = 1 when the daemon returns rig: null, in both human
and --json modes. Output is unchanged, and a found rig with insufficient
evidence still exits 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: acead549-706d-4c11-b879-1ab395fc4e81
📥 Commits

Reviewing files that changed from the base of the PR and between 39565e7 and d5c2558.

📒 Files selected for processing (2)
  • packages/cli/src/commands/ask.ts
  • packages/cli/test/ask.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The ask command now sets exit code 1 when the result has no rig. Tests cover unknown-rig responses in human-readable and JSON output, and confirm that insufficient keywords leave the exit code undefined.

Changes: Ask command exit status

Layer / File(s) Summary
Null-rig exit status and test coverage
packages/cli/src/commands/ask.ts, packages/cli/test/ask.test.ts
The command sets exit code 1 when result.rig is null. Tests check the human-readable and JSON responses and confirm that insufficient keywords leave the exit code undefined.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d5c25

Unknown or ambiguous rig selections now return a failing CLI status while retaining existing output; insufficient evidence for a found rig remains successful. No merge-blocking risk is evident.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: rig ask now exits with a non-zero status when the requested rig is unknown.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks, @Coder8124. It's in review, and we'll reply here.

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks, @Coder8124, for #1202. We'd like this change: rig ask exits 1 for an unknown or ambiguous rig. One small change first: rig ask --help still lists exit 1 only as "Daemon not running", so please add that it also means an unknown or ambiguous rig. We'll do a short read of that change.

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.

2 participants