You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 07ecf87
Browse filesBrowse the repository at this point in the historyBrowse files
v2 wrap-up actions, bridge toasts, and extraction-child cleanup
The opencode v2 adapter now carries the wrap-up completion actions, TUI
toasts, and extraction-child cleanup that v1 reached through its TUI
client routes.
Wrap-ups: /thatch/compact calls session.compact on the promise domain
(upstream #52385, in v2.0.22+; runtime-guarded because the pinned dev
types predate the surface, so an older host degrades to a logged no-op).
/thatch/exit records the session's watcher deaths synchronously BEFORE
the chat unregister - onSessionDeath places the death row via the
session's chat row, so the order is load-bearing - then emits the
session-tab bridge's exit-tab-closed event, a TUI-only close of the
session's own tab (the anomalyco/opencode#50984 ask; the v2 daemon hosts
every tab, so app.exit would take down unrelated sessions). The exit
template leaves the chat directory via the plugin-side unregister only:
a model-side thatch_chat_unregister mid-turn would delete the chat row
before the death placement can use it.
Toasts: every runtime toast call site (alerts, extraction metrics, chat
registration, blocked wrap-ups, watcher rearm notices) rides the
bridge's new toast event to the TUI plugin's ui.toast.show. The pump
never translates it; a TUI-less environment (headless run) shows
nothing - best-effort by contract.
Extraction-child cleanup: sessionDelete calls session.remove (upstream
#52387, in v2.0.22+; same runtime guard), so fact-extractor child
sessions are deleted when they finish - the session picker stays clean
and -c resume cannot land in one. Older 2.x hosts keep the documented
gap, degrading silently.
Also: empty-targets watcher deaths write no death row (the
runtime_state upsert would erase an earlier placed row for the same
session); the wrap-up resolution and the death-notice delivery check
disposed before journal writes; the QA v2-adapter harness lives in
tests/mocks/v2-harness.ts; UC-103 gains the v2 leg (compact greenlight,
exit greenlight, SDK floors, blocked toast) and UC-120 pins the child
cleanup; docs updated across both tiers (opencode-plugin capability
table, session-lifecycle, session-tabs, cross-session-chat, mcp-parity,
READMEs).
|`index.ts`| Dual-shape OpenCode plugin entry: the merged default export (`{ id, setup, server }`) loads on opencode v1 (reads `default.server`) and v2 (reads `default.setup`, strips excess keys). Lazy-imports the host adapter so each host's SDK resolves only under its own runtime. |
92
92
|`opencode/v1.ts` + `opencode/v2.ts`| Host adapters. v1 builds HostCapabilities from the PluginInput client and returns the hooks object; v2 registers through the promise-context domains (ToolEditor, session.hook, event.subscribe) and degrades the surfaces v2 lacks. v2 also wires the session-tab host flow (create -> move -> chat-register -> rpc emit -> prompt) through the `CoreContext.sessionTabHost` seam. |
93
93
|`opencode/tui-plugin.ts`| The v2 TUI CLI plugin (the package's `./tui` entrypoint): listens for `rpc.thatch-tabs.tab-opened` and `rpc.thatch-tabs.tab-closed` events and opens/closes the subordinate session's tab via `ui.tabs.open`/`ui.tabs.close`. See [features/session-tabs.md](features/session-tabs.md). |
94
-
|`capabilities.ts`| The `HostCapabilities` seam: the host operations the shared runtime needs (session create/prompt/get/list/messages/delete, toast, compaction trigger, app exit). `capabilitiesFromClient` bridges the v1 SDK client. |
94
+
|`capabilities.ts`| The `HostCapabilities` seam: the host operations the shared runtime needs (session create/prompt/get/list/messages/delete, toast, compaction trigger, session close-out - app exit on v1, the session's own tab on v2). `capabilitiesFromClient` bridges the v1 SDK client. |
95
95
|`runtime.ts`| Shared plugin runtime: wires DB, model, extraction; the nudge tiers, system prompt injection, session event handling, child-session bookkeeping, wrap-up resolution. Host-agnostic: consumed by both adapters. |
96
96
|`os-args.ts`| Pure argv / OS-command-line helpers for startup session resolution (`-s`/`-c`). SDK-free. |
|`experimental.chat.system.transform`| Appends the thatch system prompt (store names, usage rules). |
131
131
|`experimental.session.compacting`| Marks the session as compacting and appends re-familiarization context so a compacted session still knows thatch exists. |
132
-
|`command.execute.before`| Arms the wrap-up greenlight check: `/thatch/compact` and `/thatch/exit` mark their session in `pendingWrapUp`. The next `session.status` idle resolves it by inspecting the final assistant message for the greenlight token and, when present, triggering the TUI action (`session_compact` via `executeCommand`, `app.exit` via `publish`; the exit path unregisters the session from the chat directory first). See [features/session-lifecycle.md](features/session-lifecycle.md). |
132
+
|`command.execute.before`| Arms the wrap-up greenlight check: `/thatch/compact` and `/thatch/exit` mark their session in `pendingWrapUp`. The next `session.status` idle resolves it by inspecting the final assistant message for the greenlight token and, when present, triggering the host action (compact: v1 `session_compact` via `executeCommand`, v2 `session.compact` on the promise domain; exit: record the session's watcher deaths, unregister it from chat, then v1 `app.exit` via `publish` or v2 the exit-tab-closed rpc event closing the session's own tab). See [features/session-lifecycle.md](features/session-lifecycle.md). |
133
133
|`experimental.compaction.autocontinue`| Clears the compacting flag so `chat.message` nudges resume. Without this, nudges that instruct tool calls would fire during summary generation where tools are blocked. The `chat.message` hook also clears the flag if it fires for a session still in the compacting set but the incoming message has no compaction-type part — this handles compaction failure, where the session would otherwise be stuck with nudges off forever. |
134
134
|`tool.execute.after`| Buffers every non-`thatch_*`, non-`skill`, non-`task` tool call into the session's extraction buffer. (Skill/task are excluded — buffering them creates a feedback loop where the nudge triggers a skill load, which gets buffered, which triggers another nudge.) Memory writes (`thatch_memory_remember`) and `thatch_extraction_done` drain the buffer and reset the missed-nudge counter. For child sessions (`childToParent.has(sessionID)`), also tracks metrics: `remember` with `overwrite:false` → new++, `overwrite:true` → updated++, `forget` → deleted++. For `thatch_chat_*` tool calls, builds the transcript echo (`chatEchoText`) and posts it as a visible non-synthetic `noReply` part. This is a plugin hook, NOT a bus event — do not move it into the `event` handler; the event bus has no such event and it will silently never fire. |
135
135
| `chat.message` | Recall nudge: embeds the user's prompt text with the in-process warm model, searches `db.search()` across repo + global, and pushes a recall nudge if matches exceed the threshold (default 0.55). The same embedding also feeds the prediction auto-fire (`db.scorePredictionNudge`, injects `[thatch] User decision model`) and the behavior auto-fire (`db.scoreBehaviorNudge`, injects `[thatch] Situational behaviors`). All three nudges fire independently in separate try/catch blocks with separate synthetic parts. There is deliberately NO extraction nudge here - extraction is plugin-driven at session idle (see the extraction feature doc); the old model-driven handshake raced its own state machine and was removed. Chat transcript echoes (non-synthetic `noReply` parts whose text is entirely `[chat]`-prefixed bubbles) are skipped before any tier — no model turn reads them, so nudging them wastes an embedding. Skipped entirely while the session is compacting (tool calls are blocked during summary generation), and for task-dispatched sub-agent sessions (`childToParent` without `extractionChildren`) - their tool lists may exclude the thatch tools and their work is driven by the dispatch prompt. |
@@ -268,14 +268,16 @@ extraction cycle
268
268
→ MCP path (Claude Code/Cursor): unchanged — no SDK client, no child
269
269
sessions; extract-queue.ts + flush-tools drives the nudge via hooks
270
270
271
-
toast notifications (opencode-only, TUI-rendered)
271
+
toast notifications (opencode-only, TUI-rendered; the bridge's toast
272
+
event -> the TUI plugin's ui.toast.show on v2)
272
273
→ client.tui.showToast — best-effort, silently ignored if TUI not
273
274
connected (headless mode); model-invisible (goes to the user only,
274
275
not the conversation history — the inverse of synthetic nudge parts,
275
276
which are model-visible but TUI-hidden)
276
277
→ extraction metrics: `[thatch] new: N, updated: M, deleted: K` (success
277
-
variant, 4s) — fires when an extraction child goes idle; no-save runs
278
-
show `[thatch] extraction complete — nothing to save` (info variant)
278
+
variant, 4s) — fires when an extraction child goes idle, but ONLY when
279
+
memories were actually written; no-save runs show nothing (no
0 commit comments