Skip to content

Add gh-style --json CLI mode for LLM agents - #28

Closed
rafaeelricco wants to merge 1 commit into
mainfrom
rafaeelricco/llm-friendly-cli-e6a8
Closed

Add gh-style --json CLI mode for LLM agents#28
rafaeelricco wants to merge 1 commit into
mainfrom
rafaeelricco/llm-friendly-cli-e6a8

Conversation

@rafaeelricco

Copy link
Copy Markdown
Owner

Summary

Adds machine-readable --json output for commit generate and commit doctor, following the same pattern as gh. When --json is set, the CLI skips Clack prompts and writes structured JSON to stdout; errors go to stderr as JSON.

Automation flags (require --json):

  • --adjust <text> — refine the message once
  • --dry-run — generate only, no git writes
  • --commit — commit with the generated message
  • --push — push after commit
  • --yes — publish branch or force-with-lease without confirm

Interactive commit / commit generate behavior is unchanged.

Changes

  • New src/cli/json-io.ts — JSON schemas, CliError codes, stdout/stderr writers
  • New src/cli/generate-flags.tsGenerateRunMode union and flag parsing
  • Updated src/cli/parser.ts — flag-aware command parsing and help text
  • Updated src/cli/commit.tsrun(mode) with runJson / pushJson paths
  • Updated src/cli/doctor.tsdoctor --json with checks array
  • Updated index.ts — passes command.mode / command.json (thin switch unchanged)
  • DocsAGENTS.md + README agent section
  • Tests — parser, generate-json, doctor-json coverage

Example usage

commit generate --json | jq -r '.message'
commit generate --json --commit
commit generate --json --commit --push
commit doctor --json | jq '.ready'

Verification

  • pnpm run typecheck
  • pnpm run lint:ci
  • pnpm test (78 passed)
  • pnpm run build
Open in Web Open in Cursor 

Introduce machine-readable output for generate and doctor commands with
explicit action flags (--commit, --push, --adjust, --dry-run, --yes).
Interactive Clack flow remains the default when --json is not set.

Co-authored-by: Rafael Ricco <rafaeelricco@users.noreply.github.com>
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