Help us shape the future of Go! Take the 2026 Go Developer Survey

mockpeer

command
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package main builds mockpeer: a small, real ACP agent used as a scriptable test peer. It is spawned as a subprocess (over acp/transport/stdio) by acp/client's tests and by mockpeer_test.go here; it is never imported as a library.

mockpeer speaks the agent role of the Agent Client Protocol directly on protocol.Conn (via Conn.Handle/HandleNotify with the generated method-name constants and request/response types) rather than through a typed "server-side AgentConn" wrapper, because no such wrapper exists yet — that lands in Phase 2 as the real agent facade.

Behavior is scripted entirely through environment variables, read once at startup and validated defensively (see envBool and envExitCode): garbage values fail closed with exitInvalidEnv rather than being silently ignored or causing a panic.

  • ACP_MOCK_EXIT_CODE=n: exit immediately with code n, before any protocol activity.
  • ACP_MOCK_MALFORMED_OUTPUT=1: write one non-JSON line to stdout before starting the connection, then continue serving normally.
  • ACP_MOCK_DIE_AFTER_INIT=1: behave normally through the "initialize" response, then exit the instant that response has been flushed to stdout — simulating a peer that crashes right after the handshake.
  • Default (none set): answer "initialize", "session/new", and "session/prompt"; a prompt streams a fixed "session/update" sequence (an agent message chunk, an agent thought chunk, a tool call, a tool call update, and a plan) and issues one "session/request_permission" call back to the peer.

Note on elicitation: the task this package implements (docs/plans/2026-07-23-acp-bridge-implementation.md, Task 1.8) also calls for mockpeer to "issue ... one elicitation when told to." The pinned v1.20.0 ACP schema this module generates from (see protocol/methods_gen.go) has no elicitation method at all — it was already confirmed absent during Task 1.7 (protocol/acp.go has no ClientConn.Elicit either, for the same reason). Per the plan's own precedence rule ("when a generated-schema detail conflicts with this plan's exact constant names, the pinned artifact wins"), elicitation is omitted here rather than invented.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL