Repository navigation
Description
Update 2026-11-26 (infra move): gh comes from the devtools image, and tools.lock is gone.
The devcontainer and the Service image take gh from the same devtools image, so step 9 needs no pin and no feature option. src/devops_cli/tools_lock/ and its runbook no longer exist: keep the recorded flag files next to the registry code.
Problem or Motivation
The owner asked on 2026-11-12: "I'd prefer if devops subcommands that run other cli tools match the command names and parameters and pass them through when possible, api based tools should use the api route naming for consistency. This should reduce agent confusion."
Today each wrapper builds a fixed argv from its own Typer options. So each new tool flag needs code, and an agent that types a real tool flag gets a usage error. Loki holds 159 cli_usage_error records in the 7 days to 2026-11-12, and agents made all of them. 149 of them (94 %) are gh flags on view and list commands: --json 127, --comments 10, --search 9, --head 2, --jq 1. Only four commands pass arguments through today: devops gh api, devops uv run, devops valkey cli and devops k8s run-job.
Examples:
devops gh run listuses-nfor gh's-L, and-f/--format table|jsonfor gh's--json <fields>.devops gh run viewhas no--json,--jq,--attemptor--exit-status.- In devops,
gh api --cacheis a boolean flag. In gh,--cachetakes a duration. So withdevops gh api <route> --cache 1h, gh gets1has a second endpoint. devops gh apichanges each byte that is not UTF-8 to U+FFFD, anddevops ghhas norun download. So an agent cannot read a run artifact (fix(gh): devops gh api breaks a binary response #5015).- The devcontainer installs gh with the feature
github-cli:1and no version (.devcontainer/image/devcontainer.json:27). The Service image pins gh 2.103.3 (Dockerfile:40-43). So the gh of an agent can differ from the gh of the Service, and no recorded flag list can match both.
Proposed Solution & Architectural Design
- Documents. Write ADR
docs/adr/0026-a-command-that-runs-a-tool-takes-its-names-and-passes-its-arguments-through.md, the naming rows ofCONTRIBUTING.md, a 'Tool pass-through' bullet in section 7.3 ofARCHITECTURE.md, and the MCP and egress rules inSECURITY.md. The spectool-command-namesreplacesgh-command-names.
Follow the ADR rules of the ADR modernization tracker (MADR front matter, 1,000 words or fewer) if its first item has merged; else write the record in the current form. - Registry. Add
src/devops_cli/core/passthrough.py. The key of an entry is the tool path (gh run list). An entry holds:- the devops paths (a
gh prentry namesdevops gh pr <verb>anddevops pr <verb>) - the runner (
run_gh, orrun_subprocesswith the isolated environment of the tool) - read or write
- the owned options and the refused options, with the tool's names
- the MCP allowlist: each option that an MCP caller can give, with its arity and its caps
- the cost of one run, and the page rule of
-L/--limit - the timeout
The registry also lists the gh verbs that devops never wraps:pr merge,auth,secret set,repo deleteandrelease.
- the devops paths (a
- Command shape. One Typer argument
argswithclick.UNPROCESSED, the context settingsignore_unknown_optionsandhelp_option_names=[], the option--dry-run, and the owned and refused options of the entry as Typer options with the tool's names. Click parses each form of a declared option (--opt=value,-Ovalue,-dO value), so the command reads or refuses the parsed value, not a token. The runner gives each owned value to the tool unchanged, andargsin the typed order. - Options that each gh entry owns or refuses:
-R/--repo: a value that is notOWNER/REPO(a host or a URL) exits 2. The child getsGH_HOST=github.com. So no gh entry sends a request to another host.-L/--limiton a list entry: the runner charges one unit for each 100 items.gh apiowns--paginateand--cache <duration>, and refuses--hostname.--cache-ttlgoes.
- Runner.
- A read keeps backoff and retry. A write runs once (
max_retries=0). gh can send two mutations in one run, andrun_ghruns the whole argv again after rate-limit text today (github/rate_limiter.py:1824-1869), so a second run can write twice. - On a rate-limit refusal, the command prints gh's error, then one line with the reset time and the note that REST reads go through
devops gh api(ADR 0026). The line holds no filled route, because the runner does not read the number. - Output: the runner decodes stdout and stderr with
surrogateescape, masks them withmask_secretsand writes the same bytes back. The command exits with the exit code of the tool. When the timeout of the entry stops the tool, it exits 124 and prints the masked partial output.
- A read keeps backoff and retry. A write runs once (
- Help. When
argsholds-hor--helpbefore a--, the runner runs the tool as a local command: no token, no pin and no rate-limit read (is_local_gh_commandchecks onlyargs[0]today,core/process.py:407). First it prints one devops line from the entry: the devops paths, the owned and refused options, the forced options and the devops meaning of--dry-run.main._delegatereturns the exit code of a help query on a pass-through path (src/devops_cli/main.py:105-130drops it today). - Dry run.
--dry-run,devops --dry-runandDEVOPS_CLI_DRY_RUNprint the masked tool argv and its rate-limit resource (detect_resource), and send 0 requests. The tool never gets--dry-run. - MCP.
- The generator publishes
args: list[str]for a pass-through row and puts the devops options beforeargs(ai/mcp/generator.py:466-484puts them after today). - The MCP layer parses
argswith a strict Click parser built from the MCP allowlist of the entry. It refuses an option that is not on the list, in any form, and a bare--, before a request. - No allowlist holds
-F/--body-file,--input,--recover,-w/--webor-e/--editor.-L/--limitis at most 100. - A row can be read-only only for a read entry.
- Each MCP tool description starts with its exact CLI path. A test checks each row (
ai_cost_reportisdevops ai cost report, feat(cli): usage errors show a hint for known wrong commands #4860).
- The generator publishes
- Recorded flags. The devcontainer and the Service image take gh from the devtools image. Record the flags of each registry path from the cobra completion command of the pinned gh (
gh __complete <path> -, with the values of enum flags), and the help of the pinned openspec (tests/support/openspec_recording.py). Keep the files next to the registry code. - Resolver.
core/command_resolver.pyaccepts a token after a pass-through path only when its option name is in the recorded flags of the tool, and only with a listed value where the flag has an enum. Sodevops docs checkstill finds a stale flag. A hint of feat(cli): usage errors show a hint for known wrong commands #4860 never covers a token after a pass-through path. - Commands. Change
devops gh run list,gh run viewandgh api, and adddevops gh run download.run viewandrun downloadget the timeoutDEFAULT_GH_RUN_LOG_TIMEOUT_SECONDS(120 s).run downloadwrites local files, so it is not an MCP tool. - Premise check, recorded in the proposal:
- Run each changed verb with
GH_DEBUG=apiand record its API. A GraphQL verb goes intoCONST_GH_GRAPHQL_PORCELAIN_COMMANDS(config/constants.py:2855). - Typer 0.28 gives
-htoargswhenhelp_option_namesis empty. gh __completelists the flags and the enum values with no request and no token.- Which identity runs each path: the CLI runs as the login of the person; the MCP rows and the Service tools run as the GitHub App installation.
Target Subsystem
CLI core (core/passthrough.py, core/command_resolver.py, core/process.py, ai/mcp/generator.py, main.py), devops gh api, devops gh run and the devcontainer gh pin.
Existing Tool Considered
- The Click pattern that forwards unknown options (
ignore_unknown_options,nargs=-1,click.UNPROCESSED), and Click's own parser for the MCP allowlist. No new parser. - The cobra completion command of gh for the recorded flags. gh parses and documents its own flags,
--jsonfields,--jqand--template, so devops keeps no full flag table. - The
surrogateescapeerror handler of Python.
Built: the registry and one runner of about 200 lines. Estimate: about 0.80 USD on the DeepSeek implement path and 2 days elapsed.
Acceptance Criteria
devops gh run list -L 5 --json databaseId,status --jq '.[0].status'prints what gh prints and exits with the exit code of gh.devops gh run view 1 --log-failed --dry-runanddevops --dry-run gh run view 1 --log-failedprintgh run view 1 --log-failedand send 0 requests (process-stub test).devops gh run download 43191263934 -n coverage-shard-1 -D <dir>writes a zip of 2,420,029 bytes.devops gh api <artifact zip route> > f.zipwrites the same bytes (fix(gh): devops gh api breaks a binary response #5015).- A second
devops gh api <route> --cache 1hin the same hour sends 0 requests. devops gh run list -R evil.example.com/o/rand-R https://evil.example.com/o/rexit 2 before a request.devops gh api --hostname example.com userexits 2.- Process-stub tests: a write entry whose gh run fails with
secondary rate limitruns gh once. A read entry that times out exits 124 and prints the partial output. - With sockets blocked and no token,
devops gh run view --helpprints the devops line and the help of gh, and exits with the exit code of gh. - MCP: on a read entry,
args["--json", "databaseId"]runs. On a test write entry,["5", "-F/etc/hostname"],["5", "--body-file=/etc/hostname"],["5", "-dF", "/etc/hostname"]and["5", "--", "--dry-run"]are refused before a request.["-L", "500"]is refused. - A test: each MCP tool description starts with its CLI path.
uv run devops gh --versionin the devcontainer prints the gh version of the Service image.tests/commands/test_tool_command_names.pyfails when a registry path differs from the tool prefix, when a pass-through command declares an option that the entry does not own or refuse, and when a project verb in a tool group is a verb of the tool.- A fixture document with
devops gh run list --no-such-flagfailsdevops docs check.devops docs checkpasses on the repository.
Dependencies
Merge first: a private security fix (owner) and #4860. Do not open its pull request while a pull request of #4862 is open, because both change core/command_resolver.py. #5015 is closed as superseded by this item.
Source: #4833
Alternatives check of 2026-11-29: in-use.
The repository already uses this tool.
Tool: pallets/click (https://github.com/pallets/click), BSD-3-Clause, last activity 2026-11-16, maintained.
Reason: Searches surfaced only Click, the parser the project already builds on: it gives unknown-option forwarding, ordered UNPROCESSED tokens and a strict parser, but no registry, rate-limit cost, timeout, dry-run, help delegation or MCP schema.
Covers:
- Forwards unknown options through ignore_unknown_options with nargs=-1
- Keeps typed order and option forms via click.UNPROCESSED
- Strict parser refuses undeclared options for the MCP allowlist
- Parses each declared form such as --opt=value and -Ovalue
Lacks:
- No registry of tool paths, owned or refused options
- No rate-limit cost, retry, timeout or dry-run rules
- No help delegation or MCP tool description generation
- No recorded per-tool flags for resolver validation
Activity
dan-petty commentedon Nov 12, 2026
Both items change devops gh CLI command behaviour, but #181 adds specific native subcommands while the candidate adds a general pass-through of unknown flags to the tool.dan-petty commentedon Nov 13, 2026
Order 9 of tracker #5311 (#5323) builds on the registry of this item. #5323 adds
devops gh repo,gh ruleset,gh variableandgh org listas registry entries with no new logic, so it starts after this item merges. With the registry it costs about 250k tokens and 0.5 day; without it, about 400k tokens. The owner approved the plan in #5311 on 2026-11-13.dan-petty commentedon Nov 13, 2026
New evidence of 2026-11-13 (review of failing CLI calls). This item is the largest single cause of
devopsusage errors.Counts
--json299 (23 sessions, 256 agents),--comments51,--search48,--body-file42,--head9.gh issue view --json173,gh issue list --search47,gh pr view --json43,gh issue view --comments11,gh pr list --json5,pr view --json3. The--jsonshare stays between 71% and 87% on every release from 0.118.0 to 0.129.1.cli_usage_errorrecords.devops gh api:issues/{n}6,133 calls,issues/{n}/commentsabout 3,000,search/issues2,022.Two points for the scope
No such option: --jsongives no next step, so each agent finds thedevops gh apifallback again. I ask feat(cli): usage errors show a hint for known wrong commands #4860 to add hint rows for--json,--jq,--commentsand--searchon the mirror paths, each with the exact fallback (for exampledevops gh api repos/{owner}/{repo}/issues/<n> --jq .title). A hint is output, not an alias. This item deletes those rows when the pass-through merges, as feat(cli): usage errors show a hint for known wrong commands #4860 already plans ("no hint covers a token after a pass-through path").--jsonin one group.devops gh status,gh metrics,gh project workflows listandgh branch-protection audithave a true/false--json(src/devops_cli/commands/gh.py, lines 738, 1635, 1856 and 2199). After the pass-through,--json <fields>on the mirror commands and a bare--jsonon these commands mean different things in thedevops ghgroup. feat(gh): gh status, label list and secret list run gh #5228 makesgh statusa pass-through. For the other 3, I propose--format jsonin the pull request that changes them, and a test that walks theghandprgroups and fails on a true/false--json. This changes the feat(cli): track gh-parity names and usage-error capture #4833 decision ("the boolean--jsonof the other 118 commands does not change") for theghgroup only.Measure:
cli_usage_errorrecords with the names--json,--jq,--comments,--search,--heador--body-filego to 0 in the 7 days after the release.devops gh apicalls toissues/{n}andsearch/issuesper session go down.devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
fix(roadmap): Keep blockers that a sentence opens with other words (#…
fix(roadmap): an open tracker holds back no item (#6548)
feat(cli): add the tool pass-through registry and its ADR (#7047)