Expand description
Mock opencode binary logic (Task 12). tests/bin/mock_opencode.rs is a shim over main.
Test infrastructure only: it reads keyed fixtures from MOCK_OPENCODE_FIXTURES, keeps
counters and an argv log in MOCK_OPENCODE_STATE_DIR, and never touches the real home, the
network or a real opencode.
StructsΒ§
EnumsΒ§
- Outcome π
ConstantsΒ§
- DEFAULT_
BIG π - DEFAULT_
URL π - PIPE_
CAP π - UNREACHABLE_
STDERR - The captured real stderr of
opencode api server.info --server http://127.0.0.1:1(opencode v2.0.32; the raised error isserver-connection.ts:96).
FunctionsΒ§
- append_
log π - big_
array π - count_
poll π - Count one poll of
key(append one byte; the file length is the count). - env_
presence_ line - One argv-log line (no trailing newline):
{argv, env:{<name>:{present,len,sha8}}, stdout_kind}forOPENCODE_PASSWORD,OPENCODE_SERVER_PASSWORDand everyOPENCODE_CTL_*; never a value. - expand_
now π - Expand whole-string
"{{now}}","{{now-N}}","{{now+N}}"to numbers. - finish π
- fixture_
key <op>__<k>=<v>&...: pairs sorted by name, values (not names) percent-encoded. With no params the key is the bare operation id.- is_
stdout_ pipe - Whether fd 1 is a pipe (the mock truncates
bigoutput only then). - main
- next_
seq π - Claim the next 1-based sequence number for
key: the first free<key>.<n>.seenmarker. - now_ms π
- parse_
api π - Parse
apiarguments after the subcommand: the first positional(s),--param k=v,-d <json>,--server <url>. - parse_
mode MOCK_OPENCODE_MODE=<key>:<mode>[,...].- pending_
row π - A non-empty permission or form list row for the polling modes.
- percent_
encode - Percent-encode every byte outside
[A-Za-z0-9_.-]as uppercase%XX. - reply_
from_ πfixture - select_
fixture - Pick the fixture file under
<fixtures>/mock/, most specific first:<op>__<params>__<n>,<op>__<params>,<op>__<n>,<op>. A numbered family past its last file repeats that last file. - spawn_
grandchild π - tagged π
- unknown_
error_ πstack - validate_
body - The first
requiredproperty of the operationβs JSON body thatbodylacks. - write_
stdout π