Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Adopt Printing Press agent-native CLI conventions#10

Open
zgalant wants to merge 3 commits into
maincodehs/bool-cli:mainfrom
claude/align-cli-standards-3VTBycodehs/bool-cli:claude/align-cli-standards-3VTByCopy head branch name to clipboard
Open

Adopt Printing Press agent-native CLI conventions#10
zgalant wants to merge 3 commits into
maincodehs/bool-cli:mainfrom
claude/align-cli-standards-3VTBycodehs/bool-cli:claude/align-cli-standards-3VTByCopy head branch name to clipboard

Conversation

@zgalant

@zgalant zgalant commented May 8, 2026

Copy link
Copy Markdown
Member

This PR refactors the bool-cli to follow Printing Press agent-native CLI conventions, enabling better integration with AI agents and programmatic tooling while maintaining a great human experience.

Summary

The CLI now supports structured output (JSON/CSV) by default when piped, typed exit codes for machine-readable error handling, and standard flags on every command. Status messages are written to stderr, structured data to stdout, allowing clean piping without losing log output.

Key Changes

Output & Formatting

  • Refactored src/utils/output.js to support multiple output modes: human (default), JSON, CSV, and auto-detection when stdout is piped
  • Added --json, --csv, --select, and --compact flags to all commands for structured output control
  • Status messages (✔ ✖ ℹ ⚠) now write to stderr; structured data to stdout
  • Implemented data() function that returns shaped data for human rendering or emits JSON/CSV automatically

Error Handling & Exit Codes

  • Created src/utils/exit.js with typed exit codes (USAGE=2, NOT_FOUND=3, AUTH=4, API=5, RATE_LIMITED=7)
  • Introduced CliError class to carry exit codes and contextual hints
  • Errors now include indented hints pointing to the flag, value, or remediation step

Command Wrapper & Global Flags

  • Created src/utils/action.js with action() wrapper that:
    • Configures output mode once per command from global flags
    • Catches thrown errors and converts them to typed exit codes
    • Merges global options so all handlers see --json, --dry-run, etc.
  • Added global flags to bin/bool.js: --json, --csv, --select, --compact, --quiet, --no-color, --no-input, --dry-run

Command Refactoring

  • Wrapped all command actions with action() to enable error handling and output configuration
  • Replaced error() + process.exit(1) patterns with usage() or CliError throws
  • Inlined helper functions (listBools, createBool, etc.) into command actions for clarity
  • Added --dry-run support to create, update, delete, deploy, shipit, claim, and skill commands
  • Updated confirm() to throw CliError when --no-input is set instead of prompting
  • Added --no-input support to auth login and auth status commands
  • Implemented auth doctor command for diagnosing auth + API connectivity

API Error Handling

  • Enhanced src/utils/api.js to throw CliError with appropriate exit codes based on HTTP status
  • Network errors now throw with EXIT.API code
  • 401/403 → EXIT.AUTH, 404 → EXIT.NOT_FOUND, 429 → EXIT.RATE_LIMITED

Documentation

  • Updated README with Printing Press conventions, agent-native flags, exit codes, and examples
  • Added examples showing piping JSON output and using --select for field filtering

Notable Implementation Details

  • Output mode resolution order: --csv--json → piped stdout → human (table/text)
  • data() returns undefined when structured output is active (caller skips human rendering), or returns shaped data for human rendering
  • listFooter() prints "Showing N of M results" hint only in human mode
  • --select and --compact work with any structured output format
  • Errors preserve context through CliError.hint for agent self-correction
  • All status messages respect --quiet flag
  • Colors respect --no-color and NO_COLOR environment variable

https://claude.ai/code/session_012nFFfAmPiCZBm8zJRoKrru


Open in Devin Review

claude added 2 commits May 8, 2026 02:56
Adopt the standard agent-native flag set, typed exit codes, and
auto-JSON-on-pipe behavior described at https://printingpress.dev/.

- Global flags on every command: --json, --csv, --select, --compact,
  --quiet, --no-color, --no-input, --dry-run.
- Auto-emit JSON when stdout is piped (no flag needed).
- Typed exit codes: 0 success, 2 usage, 3 not found, 4 auth, 5 API,
  7 rate limited. API client maps HTTP status accordingly.
- Errors include a hint pointing at the offending flag/value or the
  remediation step so agents can self-correct in one retry.
- New 'auth doctor' subcommand reports key presence, reachability,
  and authenticated-call validity as a structured check list.
- Shared action wrapper (src/utils/action.js) plumbs global flags
  into every handler and turns CliError into the right exit code.
- Status messages route to stderr; structured data to stdout, so
  pipelines like `bool list | jq` work without losing logs.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread src/commands/auth.js Outdated
healthy,
...(healthy ? {} : { error: healthError }),
});
if (shaped === undefined) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 auth status silently exits 0 in structured output mode when API health check fails

When structured output is active (piped stdout, --json, or --csv), printData() returns undefined and auth status returns early at line 78 with exit code 0 — even when the health check has failed (healthy === false). The JSON payload contains "healthy": false and the error message, but the process exit code is 0 (success). This is inconsistent with auth doctor (src/commands/auth.js:128-130) which correctly sets process.exitCode = EXIT.AUTH in the same situation. An agent relying on exit codes (the core Printing Press convention this PR introduces) cannot detect the failure.

Suggested change
if (shaped === undefined) return;
if (shaped === undefined) {
if (!healthy) process.exitCode = EXIT.API;
return;
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

In JSON/CSV/piped mode auth status returned early after printing the
payload, leaving exit code 0 even when the health check had failed.
Set EXIT.API before returning, matching how auth doctor already
handles the same case.

Reported by Devin Review on PR #10.
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.