Skip to content

Commit f6a3f55

Browse files
authored
fix(drive): repair compaction and open-picker probes for current V2 (#78)
* fix(drive): repair compaction and open-picker probes for current V2 compact-admission replied to compaction requests by matching the old "anchored summary" prompt, which OpenCode PR #46751 replaced with a structured template whose `##` headings the server now requires. The fake model routes on the stable prompt frame and returns a template-shaped summary, so expected compactions settle as completed again. open-picker read the default model and build agent from a cold location before plugins had activated, which returns empty data since OpenCode PR #46639. Bump the pinned client to 0.0.0-dev-18911 for plugin.awaitActivation and call it for both fixture locations first. Closes #74 * docs(drive): link the multi-tool probe failure to the upstream issue
1 parent 44df5e9 commit f6a3f55

6 files changed

Lines changed: 53 additions & 11 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"opencode-drive": patch
3+
---
4+
5+
Bump the pinned `@opencode-ai/client` to `0.0.0-dev-18911` so the generated SDK exposes `plugin.awaitActivation`, which scripts need before reading agents or models from a cold location on current V2 servers.

‎bun.lock‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/drive/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@effect/platform-node": "4.0.0-rc.112",
6262
"@effect/platform-node-shared": "4.0.0-rc.112",
6363
"@napi-rs/canvas": "1.0.2",
64-
"@opencode-ai/client": "0.0.0-dev-18862",
64+
"@opencode-ai/client": "0.0.0-dev-18911",
6565
"@opentui/core": "0.4.5",
6666
"@types/bun": "1.3.13",
6767
"@typescript/native-preview": "7.0.0-dev.20251207.1",

‎packages/drive/test/manual/tui-regressions/README.md‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@ and terminal frame in `state-machine-failure.json`.
306306
| `cancelled` | Cancellation removes the known pending item while setup is blocked. The client still proposes a fresh compaction ID and completes it after healing; cancellation itself does not permanently reserve the old ID. |
307307
| `rollback` | Killing connections before admission removes the unacknowledged row and displays the transport error. After healing, retry compaction and submit a recovery prompt successfully. |
308308

309+
The simulated compaction reply is a structured summary with the `##` section
310+
headings that OpenCode requires since PR #46751; a plain sentence now settles as
311+
`compaction.failed` ("did not match the required template") instead of
312+
`completed`. The fake model routes compaction requests on the stable prompt
313+
frame ("Summarize only the history shown"), not on template wording, which has
314+
already changed once since.
315+
309316
The simulated model paces a busy-step checkpoint before holding the response
310317
open; this isolates admission behavior from stream-publication behavior. The
311318
bounded-flush tests separately verify complete single bursts without a later
@@ -364,7 +371,10 @@ Drive writes current V2 `cli.json` under its isolated `OPENCODE_CONFIG_DIR`.
364371
The probe expresses `session.new_location: "inherit"` and a `Ctrl-N` binding
365372
through `tuiConfig`, making the movement check an explicit fixture contract
366373
without a manual config-file workaround or installed-client changes. Fixture
367-
sessions also select the simulation model and build agent explicitly.
374+
sessions also select the simulation model and build agent explicitly. Since
375+
OpenCode PR #46639 plugins load after config, so a cold location answers
376+
`agent.list` and `model.default` with empty data until activation; the fixture
377+
calls `plugin.awaitActivation` for both project locations before reading them.
368378

369379
Successful runs write `open-picker-report.json` and print `passed: true`.
370380
Failures retain the case, viewport, marker seed, checkpoint trace, server
@@ -413,6 +423,19 @@ bun run --cwd packages/drive drive start --name tui-multi-tool-interleavings \
413423
--dev "$OPENCODE_DEV"
414424
```
415425

426+
This probe currently fails on V2 at or after OpenCode PR #46724
427+
([`anomalyco/opencode#37650`](https://github.com/anomalyco/opencode/issues/37650)) with
428+
`InvalidRequestError: Expected JSON value at ["data"][2]["metadata"]["hidden"]`
429+
from `GET /api/session/:id/permission`. That is a server defect, not probe
430+
drift: the glob tool copies every optional input into its permission
431+
`metadata` (`path`, `limit`, and now `hidden`), so an omitted input leaves an
432+
`undefined` value that the response encoder for `Record(String, Unknown)`
433+
rejects, and the endpoint answers 400 while that permission is pending. Any
434+
model call that omits `hidden` (or `path`, or `limit`) trips it. The probe
435+
deliberately keeps its realistic `{ pattern, path, limit }` input rather than
436+
adding `hidden: false` to dodge the bug; expect it to pass again once the
437+
server drops or defaults undefined permission metadata.
438+
416439
## Plugin registry
417440

418441
`plugin-registry.ts` checks that plugin registrations reach both the frontend and the model without a server restart. A discovered local plugin registers a command and a tool; the probe asserts the command through `command.list`, the tool through the captured provider request body, and the slash menu through the TUI. It then writes a second plugin into `.opencode/plugins/` at runtime, asserts both appear, removes it, and asserts it disappears. Activation is observed through `plugin.list`.

‎packages/drive/test/manual/tui-regressions/compact-admission.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { saveFailure } from "./state-machine.js"
77
// Run each scenario independently so a failed checkpoint cannot mask later cases.
88
const scenario = process.env.OPENCODE_DRIVE_COMPACT_CASE ?? "ordered"
99
const cols = Number(process.env.OPENCODE_DRIVE_COLS ?? 100)
10+
const compactionSummary = [
11+
"## Objective",
12+
"- Inspect the admission fixture README.",
13+
"",
14+
"## Work State",
15+
"### Completed",
16+
"- The fixture README was inspected.",
17+
].join("\n")
1018

1119
export default defineScript({
1220
network: true,
@@ -55,8 +63,10 @@ export default defineScript({
5563
yield* llm.serve((request) => {
5664
const body = JSON.stringify(request.body)
5765
if (body.includes("title generator")) return Stream.make(Llm.text("Admission fixture"))
58-
if (body.includes("Create a new anchored summary") || body.includes("Update the anchored summary below"))
59-
return Stream.make(Llm.text("The fixture README was inspected."))
66+
// Compaction (OpenCode PR #46751) asks for a structured summary and
67+
// rejects a reply without one of its `##` section headings as
68+
// `compaction.failed`. Match the prompt frame, not the template text.
69+
if (body.includes("Summarize only the history shown")) return Stream.make(Llm.text(compactionSummary))
6070
// History includes previous markers. Only the newest prompt selects a reply.
6171
const marker = ["CA_WARM", "CA_HOLD", "CA_NEXT"].reduce((latest, candidate) =>
6272
body.lastIndexOf(candidate) > body.lastIndexOf(latest) ? candidate : latest,

‎packages/drive/test/manual/tui-regressions/open-picker.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ export default defineScript({
5959
const location = yield* opencode.location.get({ location: { directory: `${artifacts}/files` } })
6060
const archive = yield* opencode.location.get({ location: { directory: `${artifacts}/files/archive` } })
6161
assert.notEqual(archive.project.id, location.project.id, "archive must be a distinct Git project")
62+
// Plugins load after config (OpenCode PR #46639), so a cold location
63+
// answers agent and model reads with empty data until activation.
64+
yield* opencode.plugin.awaitActivation({ location })
65+
yield* opencode.plugin.awaitActivation({ location: archive })
6266
const model = (yield* opencode.model.default({ location })).data
6367
const agent = (yield* opencode.agent.list({ location })).data.find((agent) => agent.id === "build")
64-
assert(model)
65-
assert(agent)
68+
assert(model, "no default model after plugin activation")
69+
assert(agent, "no build agent after plugin activation")
6670
// Created before frontend launch: these are neither open tabs nor event-
6771
// hydrated sessions. Distinct titles fit the 44-column picker as well.
6872
const older = yield* opencode.session

0 commit comments

Comments
 (0)