Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CLI_REFERENCE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions docs/MCP_TOOLS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions docs/commands/gh.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions docs/commands/pr.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-25
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Design

## Decisions

- **Extend `pr_view_args`/`plan_pr_view` and `pr_list_args`/`plan_pr_list` and add `pr_status_args`/`plan_pr_status` in `src/devops_cli/github/pr_plans.py`.**: Both execution and `--dry-run` request plans share one argument builder per verb (`src/devops_cli/github/pr_plans.py:23-85`), preventing plan-vs-runtime drift (`tests/commands/test_pr_dry_run.py:176`).
- **Use caller-supplied `--json` in `pr_list_args` instead of the fixed table field list when provided.**: `gh pr list` takes one `--json` flag (`src/devops_cli/github/pr_plans.py:37`); keeping default table fields only when `--json` is omitted preserves existing table output for `devops pr list --search ... --base ...` while producing requested fields when `--json` is given.
- **Branch to raw stdout and non-fallback error handling when `--json` or `--jq` is passed.**: `list_prs` and `view_pr` currently render tables and invoke REST fallbacks (`src/devops_cli/commands/pr.py:259-272, 423-430`); emitting masked stdout directly on success and masked `gh` error without fallback on failure preserves the requested JSON/jq output contract.
- **Keep option short flags `-q` (`--jq`), `-c` (`--comments`), `-S` (`--search`), `-H` (`--head`), `-B` (`--base`) matching `gh`.**: Avoids colliding with existing `-s` (`--state`), `-n` (`--limit`), and `-R` (`--repo`) in `src/devops_cli/commands/pr.py:234-245`.

## Rejected alternatives

- **Add a separate wrapper in `src/devops_cli/commands/gh.py`.**: `src/devops_cli/commands/gh.py:143` already mounts `pr_app` directly at `devops gh pr`; duplicating handlers in `gh.py` would drift.
- **Validate `--json` field names locally.**: `gh` already validates PR JSON fields and reports invalid field errors directly (`src/devops_cli/commands/pr.py:423`); a local allowlist would go stale on `gh` updates.
- **Modify `devops pr checks` and `devops pr diff` in this change.**: Issue `#4842` targets only `pr view`, `pr list`, and `pr status`; `pr checks` already powers readiness tables and `pr diff` passes `--color`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Proposal: #4842

## Why

`devops pr view` exposes only `--repo` and `--dry-run`, `devops pr list` exposes only `--state`, `--limit`, `--repo`, and `--dry-run`, and `devops pr status` does not exist. Agents and developers routinely need `--json`, `--jq`, `--comments`, `--search`, `--head`, and `--base`, and `devops gh pr` shares the same application. #4842 forwards those `gh` options from `devops pr` and `devops gh pr`, adds `devops pr status` / `devops gh pr status`, prints raw `gh` output (and `gh` errors without a fallback table) when `--json` or `--jq` is requested, and includes every option in `--dry-run` plans.

## What Changes

- Extend `pr_view_args` and `plan_pr_view` in `src/devops_cli/github/pr_plans.py` with `comments`, `json_fields`, and `jq_expr`; extend `pr_list_args` and `plan_pr_list` with `search`, `head`, `base`, `json_fields`, and `jq_expr`; and add `pr_status_args` and `plan_pr_status`.
- Update `view_pr` (`--json`, `--jq`/`-q`, `--comments`/`-c`) and `list_prs` (`--json`, `--jq`/`-q`, `--search`/`-S`, `--head`/`-H`, `--base`/`-B`) and add `status_pr` (`devops pr status` / `devops gh pr status` with `--json`, `--jq`/`-q`, `--repo`/`-R`, `--dry-run`) in `src/devops_cli/commands/pr.py`.
- Return raw masked stdout (and masked `gh` stderr on non-zero exit without table fallback) when `--json` or `--jq` is passed to `pr view`, `pr list`, or `pr status`.
- Add help strings in `src/devops_cli/lang/en/help.py` and regenerate documentation (`docs/commands/pr.md`, `docs/commands/gh.md`, `docs/CLI_REFERENCE.md`).
- Add comprehensive unit and dry-run tests across `tests/commands/test_pr_dry_run.py` and `tests/commands/test_pr_cmd.py`.
- Fits in one pull request.

## Capabilities

### New Capabilities

- `pr-passthrough`: Forward `gh` JSON, jq, comments, search, head, and base options on `pr view`, `pr list`, and `pr status` under both `devops pr` and `devops gh pr` with raw-output mode and zero-execution `--dry-run` plans.

### Modified Capabilities

None.

## Impact

- Code: `src/devops_cli/github/pr_plans.py`, `src/devops_cli/commands/pr.py`, `src/devops_cli/lang/en/help.py`
- Documents: `docs/commands/pr.md`, `docs/commands/gh.md`, `docs/CLI_REFERENCE.md`
- Tests: `tests/commands/test_pr_dry_run.py`, `tests/commands/test_pr_cmd.py`

## Feasibility

- Verified `src/devops_cli/commands/gh.py:143` mounts `pr_app` directly as `devops gh pr`, so commands and flags on `src/devops_cli/commands/pr.py` are exposed at both `devops pr` and `devops gh pr`.
- Verified `src/devops_cli/github/pr_plans.py:23-85` already drives `pr_list_args`/`plan_pr_list` and `pr_view_args`/`plan_pr_view` through `run_gh` and `PlannedRequest`.
- Verified `openspec list --specs` shows no conflicting active change modifying `pr-passthrough` or `gh-command-names`.

## Existing Tool Considered

Uses `cli/cli` (`gh`), already installed and invoked through `run_gh` in `src/devops_cli/github/rate_limiter.py`. Only missing wrapper options, raw-output branching, `pr status` wiring, dry-run plans, and tests are added (~60 lines of wrapper code plus tests, zero new external dependencies, zero code deleted).
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Purpose

Forward `gh` pass-through flags (`--json`, `--jq`, `--comments`, `--search`, `--head`, `--base`) and `pr status` across `devops pr` and `devops gh pr` with raw-output mode and dry-run request plans.

## ADDED Requirements

### Requirement: PR view forwards JSON, jq, and comments options
`devops pr view` and `devops gh pr view` SHALL forward `--json <fields>`, `--jq`/`-q <expr>`, `--comments`/`-c`, and `--repo`/`-R` to `gh pr view`. When `--json` or `--jq` is set and `gh` exits non-zero, the command SHALL print the error and exit with `gh`'s exit code without invoking REST fallback rendering.

#### Scenario: PR view forwards JSON, jq, and comments
- **WHEN** a test invokes `devops pr view 12 --json number,title --jq .title --comments` with a `gh` process stub
- **THEN** the stub receives `gh pr view 12 --comments --json number,title --jq .title` and stdout prints the stub output

#### Scenario: GH path forwards PR view JSON
- **WHEN** a test invokes `devops gh pr view 12 --json title` with a `gh` process stub
- **THEN** the stub receives `gh pr view 12 --json title` and prints its output

### Requirement: PR list forwards JSON, jq, search, head, and base options
`devops pr list` and `devops gh pr list` SHALL forward `--search`/`-S`, `--head`/`-H`, `--base`/`-B`, `--json`, and `--jq`/`-q` to `gh pr list`. When `--json` or `--jq` is omitted, the command SHALL render the PR table; when `--json` or `--jq` is set, the command SHALL print raw `gh` stdout on success and print `gh` error with `gh`'s exit code and no table on failure.

#### Scenario: PR list forwards head and JSON raw output
- **WHEN** a test invokes `devops pr list --head feature --json number` with a `gh` stub returning a JSON array
- **THEN** the stub receives `--head feature` and `--json number`, and stdout prints the raw JSON array without table formatting

#### Scenario: PR list forwards search and base in table mode
- **WHEN** a test invokes `devops pr list --search is:draft --base main` with a `gh` stub returning PR JSON
- **THEN** the stub receives `--search is:draft` and `--base main` alongside default JSON fields and renders the formatted PR table

#### Scenario: Raw output failure prints gh error and no table
- **WHEN** a test invokes `devops pr list --json number` and `gh` exits 1 with a rate-limit error
- **THEN** the command prints `gh`'s error, exits 1, and invokes no table fallback

### Requirement: PR status command runs gh pr status
`devops pr status` and `devops gh pr status` SHALL invoke `gh pr status` forwarding optional `--json`, `--jq`/`-q`, and `--repo`/`-R`, and declare `@dry_run_class("request-plan")`.

#### Scenario: PR status forwards JSON and repo
- **WHEN** a test invokes `devops pr status --json number --repo owner/repo` with a `gh` stub
- **THEN** the stub receives `gh pr status --json number --repo owner/repo` and prints the output with exit code 0

### Requirement: Dry run prints planned gh arguments
`devops pr view`, `devops pr list`, and `devops pr status` under `--dry-run` SHALL include all forwarded options in the planned `gh` argv and execute zero subprocesses.

#### Scenario: Dry run prints planned argv for new flags and status
- **WHEN** tests run `devops pr view 12 --json title --dry-run`, `devops pr list --head feat --search is:draft --dry-run`, and `devops pr status --json number --dry-run`
- **THEN** each output prints the planned `gh` argv holding those flags and executes zero external processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Tasks

## 1. Extend PR plan builders and command options

Kind: behavior. Reads: `src/devops_cli/github/pr_plans.py`, `src/devops_cli/commands/pr.py`, `src/devops_cli/lang/en/help.py`, `tests/commands/test_pr_dry_run.py`, `tests/commands/test_pr_cmd.py`. Changes: `src/devops_cli/github/pr_plans.py`, `src/devops_cli/commands/pr.py`, `src/devops_cli/lang/en/help.py`, `tests/commands/test_pr_dry_run.py`, `tests/commands/test_pr_cmd.py`.

- [x] 1.1 Add failing tests in `tests/commands/test_pr_dry_run.py` and `tests/commands/test_pr_cmd.py` covering `pr view` (`--json`, `--jq`/`-q`, `--comments`/`-c`), `pr list` (`--json`, `--jq`/`-q`, `--search`/`-S`, `--head`/`-H`, `--base`/`-B`, raw-output failure without fallback), `pr status` (`--json`, `--jq`/`-q`, `--repo`/`-R`), `--dry-run` plans for all flags and `pr status`, and `devops gh pr view` / `list` / `status`
- Verification: `$ uv run devops ci test tests/commands/test_pr_dry_run.py tests/commands/test_pr_cmd.py`
- [x] 1.2 Implement `pr_view_args`/`plan_pr_view`, `pr_list_args`/`plan_pr_list`, `pr_status_args`/`plan_pr_status` in `src/devops_cli/github/pr_plans.py`, wire options and `status_pr` in `src/devops_cli/commands/pr.py`, and add help strings in `src/devops_cli/lang/en/help.py`
- Verification: `$ uv run devops ci test tests/commands/test_pr_dry_run.py tests/commands/test_pr_cmd.py`

## 2. Regenerate CLI documentation

Kind: other. Reads: `docs/commands/pr.md`, `docs/commands/gh.md`, `docs/CLI_REFERENCE.md`. Changes: `docs/commands/pr.md`, `docs/commands/gh.md`, `docs/CLI_REFERENCE.md`.

- [x] 2.1 Regenerate documentation with `uv run devops docs generate` and verify with `uv run devops docs check`
- Verification: `$ uv run devops ci docs`

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
47 changes: 47 additions & 0 deletions openspec/specs/pr-passthrough/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# pr-passthrough Specification

## Purpose

Forward `gh` pass-through flags (`--json`, `--jq`, `--comments`, `--search`, `--head`, `--base`) and `pr status` across `devops pr` and `devops gh pr` with raw-output mode and dry-run request plans.

## Requirements

### Requirement: PR view forwards JSON, jq, and comments options
`devops pr view` and `devops gh pr view` SHALL forward `--json <fields>`, `--jq`/`-q <expr>`, `--comments`/`-c`, and `--repo`/`-R` to `gh pr view`. When `--json` or `--jq` is set and `gh` exits non-zero, the command SHALL print the error and exit with `gh`'s exit code without invoking REST fallback rendering.

#### Scenario: PR view forwards JSON, jq, and comments
- **WHEN** a test invokes `devops pr view 12 --json number,title --jq .title --comments` with a `gh` process stub
- **THEN** the stub receives `gh pr view 12 --comments --json number,title --jq .title` and stdout prints the stub output

#### Scenario: GH path forwards PR view JSON
- **WHEN** a test invokes `devops gh pr view 12 --json title` with a `gh` process stub
- **THEN** the stub receives `gh pr view 12 --json title` and prints its output

### Requirement: PR list forwards JSON, jq, search, head, and base options
`devops pr list` and `devops gh pr list` SHALL forward `--search`/`-S`, `--head`/`-H`, `--base`/`-B`, `--json`, and `--jq`/`-q` to `gh pr list`. When `--json` or `--jq` is omitted, the command SHALL render the PR table; when `--json` or `--jq` is set, the command SHALL print raw `gh` stdout on success and print `gh` error with `gh`'s exit code and no table on failure.

#### Scenario: PR list forwards head and JSON raw output
- **WHEN** a test invokes `devops pr list --head feature --json number` with a `gh` stub returning a JSON array
- **THEN** the stub receives `--head feature` and `--json number`, and stdout prints the raw JSON array without table formatting

#### Scenario: PR list forwards search and base in table mode
- **WHEN** a test invokes `devops pr list --search is:draft --base main` with a `gh` stub returning PR JSON
- **THEN** the stub receives `--search is:draft` and `--base main` alongside default JSON fields and renders the formatted PR table

#### Scenario: Raw output failure prints gh error and no table
- **WHEN** a test invokes `devops pr list --json number` and `gh` exits 1 with a rate-limit error
- **THEN** the command prints `gh`'s error, exits 1, and invokes no table fallback

### Requirement: PR status command runs gh pr status
`devops pr status` and `devops gh pr status` SHALL invoke `gh pr status` forwarding optional `--json`, `--jq`/`-q`, and `--repo`/`-R`, and declare `@dry_run_class("request-plan")`.

#### Scenario: PR status forwards JSON and repo
- **WHEN** a test invokes `devops pr status --json number --repo owner/repo` with a `gh` stub
- **THEN** the stub receives `gh pr status --json number --repo owner/repo` and prints the output with exit code 0

### Requirement: Dry run prints planned gh arguments
`devops pr view`, `devops pr list`, and `devops pr status` under `--dry-run` SHALL include all forwarded options in the planned `gh` argv and execute zero subprocesses.

#### Scenario: Dry run prints planned argv for new flags and status
- **WHEN** tests run `devops pr view 12 --json title --dry-run`, `devops pr list --head feat --search is:draft --dry-run`, and `devops pr status --json number --dry-run`
- **THEN** each output prints the planned `gh` argv holding those flags and executes zero external processes
Loading