Skip to content

Commit d90e7cb

Browse files
committed
docs(openspec): add harden-opencode-runtime-integration proposal.md
1 parent 544bb25 commit d90e7cb

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

  • openspec/changes/harden-opencode-runtime-integration
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Why
2+
3+
The SDK already exposes broad OpenCode HTTP, SSE and CLI coverage, but several integration contracts are incomplete or inconsistent with OpenCode v1.17.18. The most important gaps are no longer missing command wrappers: they are incorrect CLI option modeling, fragile streaming semantics, lack of bounded and isolated CLI execution, and treating long-running Web/Serve/ACP processes as ordinary blocking commands.
4+
5+
This change hardens the SDK so Java applications can embed OpenCode reliably rather than only invoke it as a thin command wrapper.
6+
7+
## What Changes
8+
9+
- Correct the `opencode run --share` model from a string-valued option to a boolean switch.
10+
- Add typed support for currently unmodeled documented execution flags needed by programmatic integrations, including `run --auto` and `run --interactive`.
11+
- Make CLI execution honor `maxConcurrentExecutions`.
12+
- Add per-execution environment overrides and explicit environment inheritance semantics.
13+
- Add bounded stdout/stderr capture so an untrusted or long-running child process cannot grow memory without limit.
14+
- Preserve captured stdout/stderr and distinguish timeout, cancellation, spawn failure, and non-zero exit outcomes.
15+
- Add a streaming CLI execution API that delivers stdout/stderr incrementally before process exit.
16+
- Add a managed long-running process abstraction for `serve`, `web`, and ACP launch use cases with start, readiness, stop, exit, and log-tail semantics.
17+
- Correct HTTP/SSE chat streaming to consume canonical delta events without appending full part snapshots as text deltas.
18+
- Add SSE readiness and failure propagation so a prompt is not submitted until the event stream is connected and transport failure completes the chat stream exceptionally.
19+
- Keep “unsubscribe from events” separate from “abort server-side session execution”; abort remains explicit.
20+
- Add a typed `server` configuration model and real unknown-field preservation for OpenCode configuration round-trips.
21+
- Add real OpenCode contract tests in addition to existing `echo`-based argument-construction tests.
22+
- Apply behavioral changes first to `feature/3.0.x`, then port equivalent behavior to `feature/2.0.x` and `feature/1.0.x` while preserving each line's Java/Jackson compatibility.
23+
24+
## Capabilities
25+
26+
### New Capabilities
27+
28+
- `cli-runtime`: bounded, cancellable, concurrent, environment-isolated CLI process execution with streaming and managed-process modes.
29+
- `server-lifecycle`: managed lifecycle for long-running OpenCode `serve` / `web` / ACP launcher processes.
30+
- `contract-verification`: version-pinned OpenCode CLI and SSE contract tests beyond command-string construction.
31+
32+
### Modified Capabilities
33+
34+
- `cli-contract`: typed OpenCode CLI flags MUST match upstream option arity and semantics.
35+
- `chat-streaming`: SSE chat streaming MUST use canonical delta events, wait for subscription readiness, and propagate transport failures.
36+
- `configuration-model`: OpenCode configuration MUST model server settings and preserve unknown fields across read/modify/write operations.
37+
38+
## Impact
39+
40+
- Public API: `OpenCodeRunOptions.share(String)` is an incorrect API and requires a compatibility migration to `share(boolean)`. The string overload may be temporarily deprecated if source compatibility is required.
41+
- Runtime behavior: CLI commands become concurrency-controlled and output-bounded; long-running commands gain a separate lifecycle API instead of relying on the ordinary synchronous timeout path.
42+
- Tests: contract tests require a pinned OpenCode test binary or explicitly enabled integration-test profile.
43+
- Branching: implementation starts on the Java 21 / Jackson 3 line, then is backported with compatibility-specific code for the older branches.

0 commit comments

Comments
 (0)