GeezerVison is showing github.com — Workflows rolling follow-up: dev sync, audit round 2, Deep Research example by mguttmann · Pull Request #2 · VasyaYovbak/opencode
Conversation
mguttmann
commented
Jun 6, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Hi @VasyaYovbak — following up on #1 (thanks for the quick merge! 🎉).
This rolling PR delivers a dev sync + a full second-round audit of the merged workflow feature. Every box below is green on the full gates (typechecks for opencode/core/plugin/sdk, the complete packages/opencode suite, and the httpapi exercise gate in all three modes).
Roadmap
- dev sync — merged the latest commits from anomalyco
dev twice (incl. the core protocol refactors and the fff search tools), conflict-free / reconciled.
- Adversarial audit, round 2 — fresh full audit of the merged state (engine, tool, HTTP, TUI dashboard, tests, docs). Confirmed findings fixed below.
- Built-in "Deep Research" example workflow — your suggestion; shipped in round 3 below.
- pause/resume — shipped in round 3 below (per-agent journal replay; per-agent re-run covers the retry case).
What the round-2 audit fixed
Correctness / safety
- Discovery no longer executes module code — workflow listing/autocomplete now extracts
meta via a static AST reader instead of importing each file. Removes arbitrary code execution at discovery time (and a 1s-dashboard re-import loop).
- Hardened discovery — symlink boundary, temp-file cleanup, project-over-global precedence, workflow-name sanitization (no permission-pattern injection).
- Cancel is correct —
cancel/remove are race-free across detached agent fibers; cancel no longer returns 404 when it loses the race against a run's own natural completion; foreground tool honors ctx.abort.
- Terminal-state integrity — terminal runs close every agent node (no zombie
running agents), orphan sweep normalizes zombie nodes, null results survive persistence distinctly, and snapshot() is a total defensive projection (JSON-normalized results, severed agent-token aliasing — can't crash finish or leak live engine state).
- Workspace scoping — runs are scoped to their workspace directory (no cross-directory read/cancel/delete).
Security
create honors the workflow permission (was only asking edit); denial blocks the file write; validation is static (no import of the just-written module).
- Workflow subagents inherit parent permissions — deny + external_directory rules and Plan-Mode edit restriction now propagate to
ctx.agent child sessions (regression of Subagents Bypass Plan Mode READ-ONLY Restrictions anomalyco/opencode#26514). (behavior change)
- TUI starts route permission prompts to the active session.
Contracts
- HTTP 404 convention —
get/cancel/start return 404 for unknown runs/workflows (was 200+null / 400); SDK + OpenAPI regenerated. (behavior change)
- Declared argument types & defaults enforced at the engine boundary —
"42"→42, "true"→true, empty/non-finite/unconvertible → error, declared defaults coerced; applies uniformly to HTTP/Tool/TUI. (behavior change)
- Budget counts all subagent turns — per-agent cost/tokens (and budget enforcement) sum every assistant turn, not just the last message. (behavior change)
- Finite time fields (no NaN-string variants) in the SDK for log/agent timestamps.
TUI dashboard
- Stable selection by run id, delete confirmation, cancelled status glyph, honest inline widget for failed/cancelled/interrupted, rendered log section, deep-link without discovered definitions, linear (ReDoS-free) arg tokenizer, status-column width fix. (behavior change: delete asks for confirmation)
Tool
- Robustness: malformed run-ids fail cleanly (no defect), timeout schema bounds, honest failure reporting (failed/cancelled/interrupted surface as tool errors on every path), XML-escaping of all interpolated untrusted fields, all inspect views covered.
Tests & docs
- Engine/tool/TUI suites grew substantially (deterministic concurrency/budget/wait coverage, real multi-turn cost fakes persisting through the message table, cancel/orphan/roundtrip). Docs aligned with the audited behavior.
Every behavior-changing fix to your original code is flagged above with (behavior change) — happy to adjust or drop any of it.
Round 3: Claude Code parity (ultracode, pause/resume, deep-research, approval)
-
ultracode keyword + /ultracode session mode — the keyword anywhere in a prompt (highlighted in the input, configurable via workflows.ultracode_keyword) opts that turn into workflow orchestration: the agent authors and starts a workflow instead of working turn by turn. /ultracode toggles a session mode that plans workflows for every substantial task (understand → change → verify chains) and best-effort bumps the model to its strongest reasoning variant (restored on toggle-off/session change).
- Run caps + pause/resume — run-wide agent concurrency cap
min(16, max(2, cpus−2)) on top of per-call limits, 1,000-agent lifetime limit per run; new non-terminal paused status with p (pause/resume) and r (re-run one agent) in the dashboard, POST /workflow/run/{id}/pause, and resume via the persisted agent journal — completed agents replay from cache (cached: true, costs still charged against the budget). Because the journal lives in SQLite, resume works across app restarts. Resume sources are status-guarded (only paused/interrupted), and schema/journal drift falls back to a live run instead of defecting.
- Bundled
deep-research + direct slash commands — a built-in workflow (plan → research → verify → synthesize with adversarial claim voting and cited output; fails clearly when agents have no web tools) shipped via a new builtin discovery root (project > global > builtin). Discovered workflows now appear as direct /<name> commands, and s in the dashboard saves any run's script as a command (project or global). The builtin module loads through the global workflows dir, so it works in the compiled binary (import.meta.dir is read-only /$bunfs there — caught in review with an empirical probe).
- Per-run approval for interactive starts — name/description/phases/args preview with Yes / Yes-always (persisted in
workflows.approved) / View script / No, configurable via workflows.approval (always/first-run/never, default first-run). Tool-initiated starts keep the existing workflow permission gate.
All gates green after the round: 4 package typechecks, full packages/opencode suite (3271 pass / 0 fail), httpapi exercise 181/181 in all three modes, SDK/OpenAPI regen idempotent.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
VasyaYovbak reacted with eyes emoji
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
The deep-research builtin imported `@opencode-ai/plugin`. Its source is
materialized as a temp module under the global workflows directory, so that
bare specifier resolved through `<config>/node_modules` — the PUBLISHED plugin
package that config.ts installs there, never a dev workspace checkout. In local
development the builtin would only load after manually linking the workspace
plugin into the global config dir (reported on PR anomalyco#2).
Ship the source in the wrapper-free `export default { meta, run }` shape
instead — exactly what the plugin's workflow() helper returns at runtime, and a
form the static MetaReader reads natively. The materialized temp module now
resolves nothing at all and loads identically in dev, in tests, and in the
compiled binary. The wrapper only ever added editor types, which a string
constant cannot benefit from anyway.
Documented as an INVARIANT in builtin.ts, enforced by a regression test (the
builtin source must not contain imports), and the test's plugin-symlink
workaround is gone. loadModule keeps writing to the global workflows dir — in a
compiled binary import.meta.dir is /$bunfs/root and read-only — but no longer
depends on any node_modules above it.
131/131 workflow/meta-reader/tool tests, typecheck clean. Import-smoke-verified
from a bare directory with no node_modules in scope.
Reported by @VasyaYovbak on PR anomalyco#2.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Glad it boots now — thanks for confirming, and great catch on the builtin materialization nuance!
You diagnosed it exactly right: the deep-research builtin is materialized as a temp module under the global config dir, so its import { workflow } from "@opencode-ai/plugin" resolved through <config>/node_modules — the published plugin package that config.ts installs there, never your dev workspace. Hence the manual link you needed.
Fixed properly in 559402e — builtin workflow sources are now self-contained (no imports):
- the deep-research source ships in the wrapper-free
export default { meta, run } shape — exactly what workflow() returns at runtime, and a form the static meta reader supports natively
- the materialized temp module therefore resolves nothing at all and loads identically in a dev workspace, in tests, and in the compiled binary (smoke-verified by importing it from a bare directory with no
node_modules in scope)
- documented as an invariant in
builtin.ts and enforced by a regression test (a builtin source containing an import now fails the suite); the test's plugin-symlink workaround is gone too
So after pulling 559402e you can remove your manual @opencode-ai/plugin link — it's no longer needed. User-authored workflows in the project/global dirs are unaffected: those still resolve imports from their own location, which is the expected behavior there.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…packages/tui
Sync onto upstream dev (2006259). The dominant upstream change is the TUI
extraction into the new packages/tui package; the workflow feature surface
moved with it:
- dialog-workflow(+helpers), dialog-workflow-approval(+helpers), ultracode,
and workflow-autocomplete now live in packages/tui/src/component (relative
imports, no aliases; Clipboard.copy -> clipboard write API)
- session route: WorkflowCall adapted to the untyped ToolProps + display()
dispatch ("workflow" added to toolDisplays); workflowMetadata kept
- prompt: ultracode submit path keeps RAW-input keyword strip with sentinel-
protected paste spans (restored named pastedRanges; upstream part shape
without client part ids; tui.prompt.append event API)
- app: DialogWorkflow wiring carried into the Effect-based Tui.run bootstrap
- httpapi: WorkflowApi kept alongside the renamed server Api export
- our five workflow/ultracode TUI test files moved to packages/tui/test
- SDK regenerated: openapi.json carries the 6 /workflow routes
Verified: typecheck clean (opencode + tui); 131/131 workflow/meta-reader/tool,
287 pass / 1 skip tui (incl. the 5 migrated suites), 280 pass / 2 skip server;
TUI boots under a PTY and renders the home route.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Synced this branch onto the latest upstream dev (bddf3fe00, upstream dev @ 2006259).
The main thing the sync involved was the TUI package extraction migration — reconciling our changes against the moved/extracted TUI package so the workflow autocomplete, dashboard, and approval-dialog components line up with the new layout.
All suites are green. Ready to merge into feat/workflows.
Numbers after the sync: typecheck clean for both packages/opencode and packages/tui; 131/131 workflow/meta-reader/tool, 287 pass / 1 skip tui (incl. the five migrated workflow/ultracode suites, now under packages/tui/test), 280 pass / 2 skip server; TUI boots under a PTY and renders the home route.
|
VasyaYovbak reacted with hooray emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mguttmann
added a commit
that referenced
this pull request
Jun 14, 2026
…putation
The home route's Suspense fallback renders the Prompt eagerly, exposing three
ordering bugs that crashed boot with a fatal-error screen:
- autocomplete: the `options` memo could be read before its first computation
("undefined is not an object (evaluating 'options().length')"). Give it an
initial value of [] and return [] while the menu is hidden so it never pulls
commands()/slashes()/files() during the fallback render.
- autocomplete: `commands` referenced the `slashCommandWorkflowInfos` resource
declared after it — a temporal-dead-zone forward reference ("Cannot access
'slashCommandWorkflowInfos' before initialization") whenever the memo
computes eagerly. Declare both workflow-info resources before the memo and
gate it on visibility.
- prompt: the `ultracodeKeyword` memo read `store` declared ~50 lines later
(same TDZ class, "Cannot access 'store' before initialization"). Declare it
after the store.
Verified by booting the TUI under a PTY (previously: fatal-error screen; now:
the home route renders). 163/163 TUI tests pass, typecheck clean.
Reported by @VasyaYovbak on PR #2.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mguttmann
added a commit
that referenced
this pull request
Jun 14, 2026
The deep-research builtin imported `@opencode-ai/plugin`. Its source is
materialized as a temp module under the global workflows directory, so that
bare specifier resolved through `<config>/node_modules` — the PUBLISHED plugin
package that config.ts installs there, never a dev workspace checkout. In local
development the builtin would only load after manually linking the workspace
plugin into the global config dir (reported on PR #2).
Ship the source in the wrapper-free `export default { meta, run }` shape
instead — exactly what the plugin's workflow() helper returns at runtime, and a
form the static MetaReader reads natively. The materialized temp module now
resolves nothing at all and loads identically in dev, in tests, and in the
compiled binary. The wrapper only ever added editor types, which a string
constant cannot benefit from anyway.
Documented as an INVARIANT in builtin.ts, enforced by a regression test (the
builtin source must not contain imports), and the test's plugin-symlink
workaround is gone. loadModule keeps writing to the global workflows dir — in a
compiled binary import.meta.dir is /$bunfs/root and read-only — but no longer
depends on any node_modules above it.
131/131 workflow/meta-reader/tool tests, typecheck clean. Import-smoke-verified
from a bare directory with no node_modules in scope.
Reported by @VasyaYovbak on PR #2.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mguttmann
pushed a commit
that referenced
this pull request
Jun 14, 2026
Workflows rolling follow-up: dev sync, audit round 2, Deep Research implemetnation
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|