[PR #3409] [CLOSED] fix(cli)!: rename the Cutter command JSON option to --command-json #5724

Closed
opened 2026-10-31 01:08:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3409
Author: @Anurag-5ingh
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/cutter-command-json-flag


📝 Commits (1)

  • f8cd294 fix(cli)!: rename the Cutter command JSON option to --command-json

📊 Changes

3 files changed (+184 additions, -124 deletions)

View changed files

📝 src/cli/cutterCommands.ts (+7 -3)
📝 tests/boundary/cli/cliOptionAliases.test.ts (+52 -0)
📝 tests/boundary/cli/cutterCommands.test.ts (+125 -121)

📄 Description

Summary

Fixes #3182.

cutter-command --help advertises --json as the switch for command-specific JSON, but a bare --json never reached the command. Incur treats --json anywhere in argv as its builtin result-format flag and strips it before command options are parsed. So --json only switched the CLI output to JSON and sent json: false to the bridge, and Rizin output was never parsed with cmdj. Only the undocumented --json=true spelling enabled it.

This PR renames the command-specific control to --command-json, so it reaches the bridge independently of the global output flags.

Problem and expected behavior

Smallest trigger: rea cutter-command <session> <generation> pdi --json sends json: false to the selected bridge.

Expected:

  • The documented command option enables parsed command JSON (cmdj).
  • --json and --format json select only the CLI result representation and do not enable command-specific JSON by themselves.

Change and scope

  • The handler cannot recover the bare --json token: Incur's extractBuiltinFlags consumes it, and the run context only exposes format/formatExplicit, which --format json also sets. So no option named json can ever receive the documented spelling. The owning fix is to stop declaring an option that collides with a builtin.
  • src/cli/cutterCommands.ts: the option is now commandJson (--command-json) and forwards to the existing json field of the shared input contract. The help text now says what it does: parse the Rizin command's JSON output with cmdj.
  • The MCP cutter_command input is unchanged and keeps json, since MCP has no builtin flag collision.
  • tests/boundary/cli/cliOptionAliases.test.ts: a new guard rejects any registered command option whose long spelling matches an Incur builtin flag, so the collision cannot recur elsewhere. cutter-command was the only offender; the format in inspect-web-network-capture is a positional argument.

Not included: changes to Incur, to MCP contracts, or to the bridge.

Follow the contribution scope: this is an ordinary CLI parsing fix within existing boundaries, so a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the cutter-command CLI option declaration in src/cli/cutterCommands.ts.
  • Contribution scope fit and linked maintainer decision: in scope; not applicable.
  • CLI and MCP/tool-catalog contract:
    • CLI: cutter-command --json=true is replaced by --command-json (breaking, see below).
    • MCP: unchanged.
  • Provider, bridge, target-format, or platform compatibility: none; the bridge request still carries json.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged; same selected session and generation checks.
  • Generated metadata, package, or installation impact: the generated CLI catalog reflects the renamed option; no tracked generated files change.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

No new effect is introduced. The existing cutter-command behavior (running one Rizin command in an already-running Cutter over the authenticated loopback bridge) is unchanged.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/cli/cutterCommands.test.ts: the Evidence test now runs through the real CLI parser (serveCli) instead of calling the command handler directly with pre-parsed options. A shared authenticated loopback bridge fixture records the transmitted JSON mode. For each spelling, the test expects JSON CLI output carrying the command observation and the recorded mode:

      Flags Bridge receives
      --command-json --json json: true
      --json json: false
      --format json json: false
    • tests/boundary/cli/cliOptionAliases.test.ts: no registered command option may share a spelling with an Incur builtin flag. On the base revision this test fails with cutter-command --json.

  • Base reproduction (source-derived): the previous direct-handler test passed options: { json: false } and could not observe the parser collision; the issue's reproduction shows the bare --json result.
  • User-visible CLI/MCP output: rea cutter-command <session> <generation> <command> --command-json --json now sends json: true and returns parsed command output.
  • Remaining proof gaps: no real Cutter/Rizin session was exercised; coverage uses the synthetic authenticated bridge fixture.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • oxfmt on the changed files — formatted, with no other changes
  • Full validation relies on this PR's CI. A local npm ci is not available in my environment because the registry it uses blocks some of the locked package versions.

Compatibility, safety, and release

  • Breaking changes or migration steps:
    • Previously valid: rea cutter-command <session> <generation> pdi --json=true requested parsed command JSON.
    • Now: --json=true is no longer a cutter-command option. Use --command-json.
    • --json and --format json keep selecting the CLI result format.
    • Why compatibility cannot be preserved: keeping an option named json would keep advertising a bare --json that Incur never delivers to the command.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no real Cutter session exercised.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change to bridge authentication, session selection, or command execution.

Author readiness

Human owner: @Anurag-5ingh

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3409 **Author:** [@Anurag-5ingh](https://github.com/Anurag-5ingh) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/cutter-command-json-flag` --- ### 📝 Commits (1) - [`f8cd294`](https://github.com/morluto/rea/commit/f8cd29424697bfd88ffb3bd658d69a4c8a630658) fix(cli)!: rename the Cutter command JSON option to --command-json ### 📊 Changes **3 files changed** (+184 additions, -124 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/cutterCommands.ts` (+7 -3) 📝 `tests/boundary/cli/cliOptionAliases.test.ts` (+52 -0) 📝 `tests/boundary/cli/cutterCommands.test.ts` (+125 -121) </details> ### 📄 Description ## Summary Fixes #3182. `cutter-command --help` advertises `--json` as the switch for command-specific JSON, but a bare `--json` never reached the command. Incur treats `--json` anywhere in argv as its builtin result-format flag and strips it before command options are parsed. So `--json` only switched the CLI output to JSON and sent `json: false` to the bridge, and Rizin output was never parsed with `cmdj`. Only the undocumented `--json=true` spelling enabled it. This PR renames the command-specific control to `--command-json`, so it reaches the bridge independently of the global output flags. ## Problem and expected behavior Smallest trigger: `rea cutter-command <session> <generation> pdi --json` sends `json: false` to the selected bridge. Expected: - The documented command option enables parsed command JSON (`cmdj`). - `--json` and `--format json` select only the CLI result representation and do not enable command-specific JSON by themselves. ## Change and scope - The handler cannot recover the bare `--json` token: Incur's `extractBuiltinFlags` consumes it, and the run context only exposes `format`/`formatExplicit`, which `--format json` also sets. So no option named `json` can ever receive the documented spelling. The owning fix is to stop declaring an option that collides with a builtin. - `src/cli/cutterCommands.ts`: the option is now `commandJson` (`--command-json`) and forwards to the existing `json` field of the shared input contract. The help text now says what it does: parse the Rizin command's JSON output with `cmdj`. - The MCP `cutter_command` input is unchanged and keeps `json`, since MCP has no builtin flag collision. - `tests/boundary/cli/cliOptionAliases.test.ts`: a new guard rejects any registered command option whose long spelling matches an Incur builtin flag, so the collision cannot recur elsewhere. `cutter-command` was the only offender; the `format` in `inspect-web-network-capture` is a positional argument. Not included: changes to Incur, to MCP contracts, or to the bridge. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope): this is an ordinary CLI parsing fix within existing boundaries, so a maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: the `cutter-command` CLI option declaration in `src/cli/cutterCommands.ts`. - Contribution scope fit and linked maintainer decision: in scope; not applicable. - CLI and MCP/tool-catalog contract: - CLI: `cutter-command --json=true` is replaced by `--command-json` (breaking, see below). - MCP: unchanged. - Provider, bridge, target-format, or platform compatibility: none; the bridge request still carries `json`. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: unchanged; same selected session and generation checks. - Generated metadata, package, or installation impact: the generated CLI catalog reflects the renamed option; no tracked generated files change. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. No new effect is introduced. The existing `cutter-command` behavior (running one Rizin command in an already-running Cutter over the authenticated loopback bridge) is unchanged. ## Evidence and regression coverage - Tests added or updated: - `tests/boundary/cli/cutterCommands.test.ts`: the Evidence test now runs through the real CLI parser (`serveCli`) instead of calling the command handler directly with pre-parsed options. A shared authenticated loopback bridge fixture records the transmitted JSON mode. For each spelling, the test expects JSON CLI output carrying the command observation and the recorded mode: | Flags | Bridge receives | | --- | --- | | `--command-json --json` | `json: true` | | `--json` | `json: false` | | `--format json` | `json: false` | - `tests/boundary/cli/cliOptionAliases.test.ts`: no registered command option may share a spelling with an Incur builtin flag. On the base revision this test fails with `cutter-command --json`. - Base reproduction (source-derived): the previous direct-handler test passed `options: { json: false }` and could not observe the parser collision; the issue's reproduction shows the bare `--json` result. - User-visible CLI/MCP output: `rea cutter-command <session> <generation> <command> --command-json --json` now sends `json: true` and returns parsed command output. - Remaining proof gaps: no real Cutter/Rizin session was exercised; coverage uses the synthetic authenticated bridge fixture. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `oxfmt` on the changed files — formatted, with no other changes - Full validation relies on this PR's CI. A local `npm ci` is not available in my environment because the registry it uses blocks some of the locked package versions. ## Compatibility, safety, and release - Breaking changes or migration steps: - Previously valid: `rea cutter-command <session> <generation> pdi --json=true` requested parsed command JSON. - Now: `--json=true` is no longer a `cutter-command` option. Use `--command-json`. - `--json` and `--format json` keep selecting the CLI result format. - Why compatibility cannot be preserved: keeping an option named `json` would keep advertising a bare `--json` that Incur never delivers to the command. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; no real Cutter session exercised. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no change to bridge authentication, session selection, or command execution. ## Author readiness Human owner: @Anurag-5ingh - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:08:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5724
No description provided.