test(cli): subprocess integration tests for opencode acp#28265
Open
kitlangton wants to merge 2 commits into
Open
test(cli): subprocess integration tests for opencode acp#28265kitlangton wants to merge 2 commits into
kitlangton wants to merge 2 commits into
Conversation
4 tasks
Adds the second long-lived-command builder to the cli-process harness: `opencode.acp(opts)` spawns the real CLI in JSON-RPC-over-stdio mode and returns a duplex handle (`send`/`receive`/`close`/`exited`) scoped to the test's lifetime. Stdin EOF triggers a clean shutdown; the scope finalizer also falls back to SIGTERM after 2s for a hung child. ACP frames each JSON-RPC message as one ndjson line on stdout. The builder forks a scope-bound `Stream.fromReadableStream` + `splitLines` pipeline that feeds parsed responses into a `Queue.unbounded`, so tests can `yield* acp.receive` without worrying about backpressure or framing. Two smoke tests: - `initialize` round-trip — sends the protocol handshake from the ACP README and asserts the response advertises the same protocolVersion and a non-empty agentCapabilities block. - Clean shutdown on stdin EOF — proves the scope finalizer's stdin.end() triggers a graceful exit, not a SIGTERM-fallback exit.
Replaces raw Promise.race + setTimeout in the acp builder's release finalizer with an Effect.gen that expresses the graceful-then-SIGTERM race using Effect.timeoutOrElse(Duration.seconds(2)). Same behavior, no leaked timer, consistent with the serve builder.
e38f49f to
8513472
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the second long-lived-command builder to the
cli-processharness:opencode.acp(opts)spawns the real CLI in JSON-RPC-over-stdio mode andreturns a duplex handle (
send/receive/close/exited) scoped to thetest's lifetime. Stdin EOF triggers a clean shutdown; the scope finalizer
falls back to SIGTERM after 2s for a hung child.
ACP frames each JSON-RPC message as one ndjson line on stdout. The builder
forks a scope-bound
Stream.fromReadableStream+splitLinespipeline thatfeeds parsed responses into a
Queue.unbounded, so tests canyield* acp.receivewithout worrying about backpressure or framing.
Two smoke tests:
Why this matters
Nothing currently exercises the ACP stdin/stdout protocol end-to-end. A regression that broke the framing, the handshake, the agent capabilities block, or the stdin-EOF clean-shutdown path would slip through every other test tier. The handshake test alone catches a huge class of "ACP doesn't even start" regressions that today only manifest when a user wires up an editor integration and it fails silently.
Stacked on #28263
This branches off the serve-builder branch since auto-merge on #28263 is still waiting on Windows checks. Once #28263 merges, the diff here shrinks to just the acp changes (the serve changes will already be in dev).
Test plan
Stack