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
9 changes: 9 additions & 0 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7227,6 +7227,7 @@ devops gh project link [OPTIONS] <project_number>
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh project list`

Expand All @@ -7241,6 +7242,7 @@ devops gh project list [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--owner`, `-o` | `string` | - | Target user or organization |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh project audit`

Expand All @@ -7256,6 +7258,7 @@ devops gh project audit [OPTIONS]
|---|---|---|---|
| `--template`, `-t` | `path` | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh project template`

Expand Down Expand Up @@ -7293,6 +7296,7 @@ devops gh project workflows list [OPTIONS]
| `--repo`, `-R` | `string` | - | Target repository |
| `--format`, `-f` | `string` | `table` | Output format type (table, json, yaml, markdown). |
| `--json` | `boolean` | - | Output findings or metrics as JSON. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh views`

Expand Down Expand Up @@ -7342,6 +7346,7 @@ devops gh views sync [OPTIONS]
|---|---|---|---|
| `--template`, `-t` | `path` | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh views audit`

Expand All @@ -7357,6 +7362,7 @@ devops gh views audit [OPTIONS]
|---|---|---|---|
| `--template`, `-t` | `path` | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh pages`

Expand All @@ -7377,6 +7383,7 @@ devops gh pages status [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh pages builds`

Expand All @@ -7392,6 +7399,7 @@ devops gh pages builds [OPTIONS]
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--limit`, `-l` | `integer` | `5` | Number of builds to retrieve |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh pages build`

Expand All @@ -7406,6 +7414,7 @@ devops gh pages build [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

#### `devops gh pages verify`

Expand Down
6 changes: 6 additions & 0 deletions docs/MCP_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ Trigger a new deployment build for GitHub Pages.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `repo` | `string` | No | - | Target repository |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `gh_pages_status`

Expand All @@ -975,6 +976,7 @@ Inspect GitHub Pages deployment status, URL, branch, and HTTPS enforcement.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `repo` | `string` | No | - | Target repository |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `gh_pages_verify`

Expand All @@ -1000,6 +1002,7 @@ Audit the project board's views against the template.
|---|---|---|---|---|
| `template_file` | `string` | No | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `repo` | `string` | No | - | Target repository |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `gh_project_list`

Expand All @@ -1012,6 +1015,7 @@ List available GitHub Projects v2 boards for user or organization.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `owner` | `string` | No | - | Target user or organization |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `gh_project_reconcile`

Expand Down Expand Up @@ -1111,6 +1115,7 @@ Audit remote project views against standardized template specifications.
|---|---|---|---|---|
| `template_file` | `string` | No | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `repo` | `string` | No | - | Target repository |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `gh_views_spec`

Expand All @@ -1136,6 +1141,7 @@ Synchronize standardized views with the remote GitHub Projects v2 board.
|---|---|---|---|---|
| `template_file` | `string` | No | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `repo` | `string` | No | - | Target repository |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `grafana_dashboards_list`

Expand Down
9 changes: 9 additions & 0 deletions docs/commands/gh.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ devops gh project link [OPTIONS] <project_number>
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh project list`

Expand All @@ -314,6 +315,7 @@ devops gh project list [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--owner`, `-o` | `string` | - | Target user or organization |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh project audit`

Expand All @@ -329,6 +331,7 @@ devops gh project audit [OPTIONS]
|---|---|---|---|
| `--template`, `-t` | `path` | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh project template`

Expand Down Expand Up @@ -366,6 +369,7 @@ devops gh project workflows list [OPTIONS]
| `--repo`, `-R` | `string` | - | Target repository |
| `--format`, `-f` | `string` | `table` | Output format type (table, json, yaml, markdown). |
| `--json` | `boolean` | - | Output findings or metrics as JSON. |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

---

Expand Down Expand Up @@ -417,6 +421,7 @@ devops gh views sync [OPTIONS]
|---|---|---|---|
| `--template`, `-t` | `path` | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh views audit`

Expand All @@ -432,6 +437,7 @@ devops gh views audit [OPTIONS]
|---|---|---|---|
| `--template`, `-t` | `path` | - | Path to the project template JSON; defaults to .github/project-template.json at the repository root. |
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

---

Expand All @@ -454,6 +460,7 @@ devops gh pages status [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh pages builds`

Expand All @@ -469,6 +476,7 @@ devops gh pages builds [OPTIONS]
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--limit`, `-l` | `integer` | `5` | Number of builds to retrieve |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh pages build`

Expand All @@ -483,6 +491,7 @@ devops gh pages build [OPTIONS]
| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--repo`, `-R` | `string` | - | Target repository |
| `--dry-run` | `boolean` | - | Preview execution plan without mutating external state. |

### `devops gh pages verify`

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Design

## Architecture

This change implements request plans and dry-run classifications across 15 GitHub CLI commands in `src/devops_cli/commands/gh.py`, backed by request-plan generator functions in `src/devops_cli/github/projects.py` and `src/devops_cli/github/pages.py`.

### 1. Classification Overview

| Command | Classification | Subsystem Module | Request Plan Details |
| :--- | :--- | :--- | :--- |
| `gh pages build` | `request-plan` | `github.pages` | POST `repos/{repo}/pages/builds` |
| `gh pages builds` | `request-plan` | `github.pages` | GET `repos/{repo}/pages/builds?per_page={limit}` |
| `gh pages status` | `request-plan` | `github.pages` | GET `repos/{repo}/pages` |
| `gh pages verify` | `no-external-request` | `github.pages` | Local file checks only |
| `gh project audit` | `request-plan` | `github.projects` | Board discovery, fields query, view query |
| `gh project link` | `request-plan` | `github.projects` | User login lookup, repo link mutation |
| `gh project list` | `request-plan` | `github.projects` | User login lookup, board listing queries |
| `gh project status` | `no-external-request` | `github.projects` | Template load and panel render only |
| `gh project sync` | `request-plan` | `github.projects` | Board creation / lookup, field provisioning, view sync |
| `gh project template` | `no-external-request` | `github.projects` | Local template file read only |
| `gh project workflows list`| `request-plan` | `github.projects` | Workflow GraphQL query for project |
| `gh views audit` | `request-plan` | `github.projects` | View GraphQL query and layout inspection |
| `gh views list` | `no-external-request` | `github.projects` | Template view table render only |
| `gh views spec` | `no-external-request` | `github.projects` | Template view JSON schema dump only |
| `gh views sync` | `request-plan` | `github.projects` | View creation and rename GraphQL mutations |

### 2. Request Plan Builders

Each request-plan command uses a helper function (e.g. `pages_status_requests`, `pages_builds_requests`, `pages_build_requests`, `project_audit_requests`, `project_link_requests`, `project_list_requests`, `project_sync_requests`, `project_workflows_requests`, `views_audit_requests`, `views_sync_requests`) returning `list[PlannedRequest]`.
Each `PlannedRequest` provides:
- `method`: Subprocess or HTTP action (e.g. `gh`, `gh api`).
- `target`: Human-readable description of the operation.
- `argv`: The exact command-line arguments that `run_gh` or `subprocess.run` executes.
- `condition`: Any prerequisite or condition.

### 3. Dry-Run Option and Output

Each command callback in `src/devops_cli/commands/gh.py` accepts `dry_run: Annotated[bool, typer.Option("--dry-run", ...)] = False`.
When `dry_run or is_dry_run()` is true:
- It calls the corresponding request plan builder without performing external calls.
- If JSON format is requested, outputs a JSON-compatible dictionary with `dry_run: True` and `requests`.
- Otherwise, calls `render_request_plan` to render the numbered list of planned requests.
- Returns early without running external requests.

### 4. Gaps and Ratchet

All 15 command paths are removed from `tests/fixtures/dry_run_gaps.json`, reducing the gap count from 438 to 423. The ratchet test `tests/test_dry_run_class_ratchet.py` enforces that every classified command is removed from the fixture.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Proposal

## Why

Issue #2236: The owner dry-run rule states that a dry run makes no external request. External requests include GitHub, Kubernetes clusters, AI models, network endpoints, and child processes that access them. A dry run returns planned requests and the real result type. Commands without external requests can run normally in dry-run mode. Currently, 15 `gh project`, `gh views`, and `gh pages` commands do not obey this rule: 10 commands make external requests with no request plan, and 5 commands make no external request but are blocked by the lazy proxy.

## What Changes

- Add `@dry_run_class("no-external-request")` to the 5 local-only commands: `gh pages verify`, `gh project status`, `gh project template`, `gh views list`, `gh views spec`.
- Add `--dry-run` option and `@dry_run_class("request-plan")` to the 10 request-making commands:
- `gh pages build`
- `gh pages builds`
- `gh pages status`
- `gh project audit`
- `gh project link`
- `gh project list`
- `gh project sync`
- `gh project workflows list`
- `gh views audit`
- `gh views sync`
- Implement dry-run request builders for these 10 commands returning ordered `PlannedRequest` sequences without making external network or child-process calls.
- Render request plans via `render_request_plan` in CLI output, or return structured dry-run dictionaries when format is JSON.
- Remove all 15 commands from `tests/fixtures/dry_run_gaps.json`.
- Add comprehensive test coverage in `tests/test_gh_project_views_pages_dry_run.py` verifying request-plan accuracy, absence of external requests, and normal execution for `no-external-request` commands.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `command-dry-run-class`: add dry-run request plans and classifications for 15 `gh project`, `gh views`, and `gh pages` commands.

## Impact

- Users and agents running `devops <command> --dry-run` or `devops --dry-run <command>` on these 10 commands inspect planned requests safely.
- Users and agents running `devops --dry-run <command>` on the 5 local commands execute them safely and receive normal output.
- All 15 commands pass the ratchet test.

## Feasibility

- Premise confirmed: all 15 commands exist in `src/devops_cli/commands/gh.py` and are listed in `tests/fixtures/dry_run_gaps.json`.
- `reconcile_project_cmd` provides a verified reference implementation for `gh project` request planning.
- `PlannedRequest` and `render_request_plan` exist and handle formatting and structured output.
- All tests obey the test floor with no real subprocess or network access.

## Existing Tool Considered

Reuses existing `PlannedRequest` and `render_request_plan` primitives from `devops_cli.dry_run.requests` and `devops_cli.roadmap.request_plan`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Spec Delta

## ADDED Requirements

### Requirement: gh-project-views-pages-request-plans
The ten external-request commands in `gh project`, `gh views`, and `gh pages` SHALL carry the `request-plan` dry-run class. Each command SHALL expose `--dry-run`, make zero external requests during a dry run, and output its planned requests.

#### Scenario: Dry run on gh pages build
- **WHEN** user executes `devops gh pages build --dry-run`
- **THEN** no external request is made and the planned build request is printed

#### Scenario: Dry run on gh project sync
- **WHEN** user executes `devops gh project sync --dry-run`
- **THEN** no external request is made and the planned board, field, and view requests are printed

### Requirement: gh-project-views-pages-no-external-request
The five local commands in `gh project`, `gh views`, and `gh pages` SHALL carry the `no-external-request` dry-run class, allowing execution under `devops --dry-run <command>` without external requests.

#### Scenario: Dry run on local command gh views list
- **WHEN** user executes `devops --dry-run gh views list`
- **THEN** the command executes locally and renders the standardized views table
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Tasks

## 1. Gh project, views and pages dry-run plans

Reads: `src/devops_cli/commands/gh.py`, `src/devops_cli/github/projects.py`, `src/devops_cli/github/pages.py`, `tests/fixtures/dry_run_gaps.json`.. Changes: `src/devops_cli/commands/gh.py`, `src/devops_cli/github/projects.py`, `src/devops_cli/github/pages.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_gh_project_views_pages_dry_run.py`..

- [x] 1.1 Write failing unit tests in `tests/test_gh_project_views_pages_dry_run.py` validating that the 10 request-making commands have request plans and make no external calls under `--dry-run`, and that the 5 local commands execute safely under `devops --dry-run <command>`.
- [x] 1.2 Implement request builders in `src/devops_cli/github/pages.py` for `gh pages status`, `gh pages builds`, and `gh pages build`.
- [x] 1.3 Implement request builders in `src/devops_cli/github/projects.py` for `gh project audit`, `gh project link`, `gh project list`, `gh project sync`, `gh project workflows list`, `gh views audit`, and `gh views sync`.
- [x] 1.4 Update callbacks in `src/devops_cli/commands/gh.py`: apply `@dry_run_class("no-external-request")` to the 5 local commands; add `--dry-run` and `@dry_run_class("request-plan")` to the 10 commands with request plans.
- [x] 1.5 Remove all 15 commands from `tests/fixtures/dry_run_gaps.json`.
- [x] 1.6 Verify that all tests pass, docs are up to date (`uv run devops docs generate --sync-readme`), and `uv run devops ci` passes.

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
18 changes: 18 additions & 0 deletions openspec/specs/command-dry-run-class/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,21 @@ An MCP tool entry in `CONST_MCP_EXPOSURE_TABLE` that delegates to a command mark
#### Scenario: mcp tool wraps no-external-request command
- **WHEN** an MCP tool definition in `CONST_MCP_EXPOSURE_TABLE` maps to a command path with `no-external-request`
- **THEN** the third element of the table entry is `True`

### Requirement: gh-project-views-pages-request-plans
The ten external-request commands in `gh project`, `gh views`, and `gh pages` SHALL carry the `request-plan` dry-run class. Each command SHALL expose `--dry-run`, make zero external requests during a dry run, and output its planned requests.

#### Scenario: Dry run on gh pages build
- **WHEN** user executes `devops gh pages build --dry-run`
- **THEN** no external request is made and the planned build request is printed

#### Scenario: Dry run on gh project sync
- **WHEN** user executes `devops gh project sync --dry-run`
- **THEN** no external request is made and the planned board, field, and view requests are printed

### Requirement: gh-project-views-pages-no-external-request
The five local commands in `gh project`, `gh views`, and `gh pages` SHALL carry the `no-external-request` dry-run class, allowing execution under `devops --dry-run <command>` without external requests.

#### Scenario: Dry run on local command gh views list
- **WHEN** user executes `devops --dry-run gh views list`
- **THEN** the command executes locally and renders the standardized views table
Loading
Loading