Skip to content

feat(acp): add acq acp to the Python implementation - #700

Closed
JJediny wants to merge 1 commit into
migration/python-cross-platformfrom
feat/acp-python-port
Closed

JJediny wants to merge 1 commit into
migration/python-cross-platformfrom
feat/acp-python-port

Conversation

@JJediny

@JJediny JJediny commented Nov 13, 2026

Copy link
Copy Markdown
Member

AI-assisted: written with OpenCode (claude-sonnet-5.5) under the direction of the responsible human, who has not yet reviewed it. Needs human review before merge.

Context

acq acp runs a sandboxed agent's Agent Client Protocol (ACP) server over raw stdin/stdout so an IDE such as Zed can use acq as its agent command. It was first proposed for the Bash acq in #696. The maintainers asked for it to wait for the Python rewrite, so this is the port onto migration/python-cross-platform (#697). The base branch is not main, on purpose.

Plan

  • commands/acp.py (new): CleanStdio sends fd 1 to fd 2 and fd 0 to the null device for the prologue, then restores both before the launch. ACQ_NO_PROMPT=1 and ACQ_UPDATE_CHECK=0 are set for the prologue only. shell and --json are refused.
  • msb.py / sbx.py: new stream_command (msb exec --stream, sbx exec -i, never -t).
  • lifecycle.py: run_run takes an optional launch argument (default None), so acp reuses the create-or-re-attach, heal and key-check path instead of copying it.
  • cli.py: known commands, parser, dispatch, mutating set, -- split.
  • ADR-0053m (status proposed), a how-to section, 29 Tier-2 tests, 3 Tier-1 vectors.

Binding stdin to the null device is what protects the client's pipe. The provider-credential prompt only checks that stdin is a terminal, not ACQ_NO_PROMPT.

Verification

  • tests/test_acp.py: 29 passed. Four deliberate breakages (stdin not bound, fd 1 not redirected, prompts not disabled, --stream dropped) each fail a named test.
  • ruff, mypy (46 files) and bandit: no findings, using the hash-locked requirements-quality.txt.
  • Full py-acq suite: 3448 passed, 101 skipped, 59 failed. All 59 also fail on an unmodified checkout of the base branch: 52 run git commit where signing is mandatory and no key is loaded (51 of them pass with signing off), 5 need a short directory with 6 GB free under /tmp, and 2 are in test_create_config_settings.py and test_provider_input.py. I did not diagnose those last two or the one signing-off failure.

Not verified

  • The real msb exec --stream and sbx exec -i were not run; the tests use the stubs. A live ACP exchange (Tier 3) has not been done.
  • Docs were not linted (markdownlint is not installed where this was written).
  • scripts/run-vectors was not run; only the pytest runner was.
  • No KNOWN_FAILURE_MODES.md entry: the Bash change's entry number does not map onto this branch.

Rollback

Revert this commit. run_run's new parameter defaults to None, so no other caller changes.

Security impact

Adds a verb that launches an agent with stdio attached. It adds no credential handling and no new network path. It lowers prompt exposure by refusing to prompt. Merging touches py-acq/src/acq_py/, which is on the Tier-3 surface, so it expires the live qualification transcripts (ADR-0044m) and needs a re-qualification run.

Notes for review

  • The commit is unsigned: no signing key was available in the sandbox. Re-sign or squash on merge if the base requires signatures.
  • The commit trailer follows the upstream AGENTS.md form. AGENTS.fork.md asks for "AI-assisted" only on the fork; adjust if that applies here.

Port the acq acp subcommand (ADR-0040, first proposed as a Bash patch in
#696) onto the Python implementation, as the
maintainers asked. It runs a sandboxed agent's Agent Client Protocol server over
raw stdin/stdout so an IDE such as Zed can use acq as its agent command.

- add commands/acp.py: CleanStdio sends fd 1 to fd 2 and binds fd 0 to the null
  device for the prologue, then restores both before the launch; the prologue
  runs with ACQ_NO_PROMPT=1 and ACQ_UPDATE_CHECK=0; shell and --json are refused
- add stream_command to the msb (exec --stream) and sbx (exec -i) adapters; never -t
- give lifecycle.run_run an optional launch argument so acp reuses the
  create-or-reattach, heal and key-check path instead of copying it
- wire the verb into cli: known commands, parser, dispatch, mutating set, -- split
- add ADR-0053m (proposed), the how-to section, 29 tier-2 tests and 3 tier-1 vectors

Binding stdin to the null device is what protects the client's pipe: the
provider-credential prompt only checks that stdin is a terminal, not ACQ_NO_PROMPT.

Merging touches the Tier-3 surface, so it needs live re-qualification (ADR-0044m).
The real msb --stream and sbx -i have not been exercised; the tests use the stubs.

Co-authored-by: OpenCode [claude-sonnet-5.5] <John.Jediny@gsa.gov>
@JJediny

JJediny commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Closing without merging: the base branch (#697) is not merged yet. The branch feat/acp-python-port is kept. Re-open or re-base onto main once the Python implementation lands. Remaining work is listed in #701.

AI-assisted.

@JJediny JJediny closed this Nov 13, 2026
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.

1 participant