Skip to content

Pass wrapped OpenCode run prompts as positional messages - #25001

Merged
nwparker merged 124 commits into
mainfrom
nwparker/OpenCode-Run-Positional-Prompt
Oct 4, 2026
Merged

nwparker merged 124 commits into
mainfrom
nwparker/OpenCode-Run-Positional-Prompt

Conversation

@nwparker

@nwparker nwparker commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​106 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​105
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47

ELI5

Wrapped opencode run commands received a TUI-only --prompt flag and could exit before sending the task. They now keep their run options and receive the task as a positional message.

What Changed

Use the existing command parser to recognize supported environment prefixes, PowerShell call syntax, and an existing -- separator. Reuse shell quoting and the existing startup environment when building the launch command.

Why

OpenCode's run command accepts a positional message. Handling this in the launch builder preserves the user's command and literal task text without requiring a separate prompt submission.

Linked Issue

Focused follow-up for #17551; credit @coelho-doti (#13065).

Visual Proof

N/A — command argument handling adds no rendered controls. Recorded actual before/after evidence remains pinned to its tested source.

Testing

  • Manually tested with installed OpenCode in the retained macOS before/after runs.
  • Automated tests added for wrapped commands, flags, separators, and literal task text.

The current source passes 248 tests across 17 files, all three desktop typechecks, lint and format for all four changed files, and changed code-quality checks. The tests also cover startup intent and configuration cleanup together. Public CI will cover the published merge.

Review

The normal merge preserves current main's configuration cleanup and all previous PR history. Only four launch files differ from main. Earlier app builds and actual OpenCode runs remain evidence for their recorded commits.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material is copied.

Notes

Shell argument tests cover POSIX, PowerShell, and CMD. Actual CLI turns used controlled model responses on macOS. Windows, SSH, and paid-model entitlement are not established by those runs.

Checklist

  • This PR is small and focused.
  • Explained the user-facing change, mechanism, and approach.
  • Visual evidence identified above, or N/A with reason.
  • Self-reviewed for correctness, security, and performance.
  • Cross-platform, folder workspace, and SSH boundaries considered.
  • Relevant tests, typechecks, formatting, and changed-line checks pass; CI covers the published merge.

nwparker and others added 30 commits October 2, 2026 00:46
Reuse captured composer readiness on local and paired execution hosts and revoke launching-shell paste anchors.

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
Co-authored-by: Adnan Khan <adnank11427@gmail.com>
Reuse captured composer readiness on local and paired execution hosts and revoke launching-shell paste anchors.

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
@nwparker
nwparker requested a review from Jinwoo-H as a code owner October 4, 2026 00:40

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

The commits since the prior pullfrog review (b78c1aa) extract the OpenCode plugin-config writer into its own module and re-apply the four OpenCode layers on current main; the run core is byte-identical to the prior review.

  • Extracted writeOpenCodePluginConfig into src/main/opencode/opencode-plugin-config-writer.ts — writePluginIntoOverlay/writePluginToConfigDir now delegate to a pure function that owns the mkdir/source/tui-only/atomic-write sequence, selecting isOverlay…/isInstalled… and the matching atomic writer from the ownership argument. Verified against the removed inline bodies: the installsTuiPlugin guard and tuiOnlyDirectory early return are preserved exactly, so this is behavior-preserving. hook-service.ts is the only importer.
  • Re-applied the caps/intent/overlay/run layers on current main (a77cea7f81, b43c77d7f5, f45ae0bf1d, 7a24ede575) with the rest of the 216-file diff being merged main (#25059, #25107, #24644, and others), not authored here.
  • Ran the three hook-service suites — 41 passed — and pnpm tc:node (clean) at 7a24ede575.

The sole prior inline thread (env-wrapper options) is resolved. Prior body-only nits (runIndex unused; the "Mirrors" comment) are unchanged and not re-raised.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

The commits since the prior pullfrog review (7a24ede) advance the layered base branch and re-apply the run layer on top; this PR's net diff (d12f6b5..9a90462) is byte-identical to the version approved at 7a24ede.

  • Rebased the run layer onto the advanced base — 9a90462 re-applies flag-prompt-startup.ts, opencode-startup-prompt.ts, tui-agent-startup.ts, and the prompt test onto nwparker/OpenCode-Overlay-Cleanup-Guard (d12f6b5), which now carries the sibling intent/overlay layers. git diff 7a24ede 9a90462 shows no change to any of these four files, so the approved positional-run behavior is unchanged.
  • Folded the location-hydration wait into the shared prompt plugin — the only content differing between 7a24ede and 9a90462 is src/main/opencode/opencode-startup-prompt-source.ts (+ its test): submitStartupPrompt now gates claiming and dispatch on ctx.data.location.sync(ctx.location) resolving, and fails closed when sync is missing or rejects. That file lives on the base branch (85efe85/d12f6b5), so it is not part of this PR's diff; I reviewed it as the delta since the last run and found no correctness issue.
  • Retired prior feedback — the sole open pullfrog thread (env options in opencode-headless-command.ts) is resolved; the two prior body-only nits remain unaddressed and are not re-raised.

The env-option handling and wrapper detection in src/shared/opencode-headless-command.ts are not in the current PR diff (already on the base branch); grep confirmed the shell-aware signatures match this PR's call sites.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

The two commits since the prior pullfrog review (9a90462) bind OpenCode startup-prompt hydration to the current home location. This PR's own run-positional diff is unchanged.

  • Bound hydration to the current location — the injected plugin replaces the one-shot locationReady flag with a [directory, workspaceID] key; it syncs the location it is about to read, ignores stale completions, re-syncs when the home location changes, and fails closed when sync is missing or rejects.
  • Re-checked the location around delivery — a granted claim is refused, and the prompt is not inserted, when the location key changed while the claim was in flight.
  • Added transition controls — four tests cover a startup-directory change mid-hydration, an unset location, a workspace change under the same directory, and a granted claim after the composer moves; each asserts exact sync call counts and that no claim or insert happens for a stale location.
  • This PR's authored diff is unchanged — git diff 9a90462 HEAD over src/shared/{flag-prompt-startup,opencode-startup-prompt,tui-agent-startup}.ts and opencode-startup-prompt.test.ts is empty, and the delta file src/main/opencode/opencode-startup-prompt-source.ts is byte-identical to the advanced base branch (git diff 0dd7371 HEAD -- <file> is empty), so it is not authored by this PR.

I reran src/main/opencode/opencode-startup-prompt-source.test.ts — 54 passed.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Preserve OpenCode launch ownership and location-bound startup claims while inheriting current terminal observations and installer corrections.
Preserve OpenCode launch ownership and location-bound startup claims while inheriting current terminal observations and installer corrections.
Preserve OpenCode launch ownership and location-bound startup claims while inheriting current terminal observations and installer corrections.
Preserve OpenCode launch ownership and location-bound startup claims while inheriting current terminal observations and installer corrections.
@nwparker

nwparker commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Fresh and nested startup now pass with genuine installed OpenCode 2.0.16 on exact combined commit c8fdfdbee9160cf8d4c9251fb1b467c63ede34a8 (main 2b1acd0 with the reviewed launch, catalog, model and execution-host CLI fixes).

Each launch submitted exactly one Unicode user prompt, received one granted and transmitted startup claim, used the unchanged configured model A and completed in SQLite and the authoritative status store. The nested launch followed positive closure of the fresh app/TUIs/service and used the same healthy private profile. Its real TUI and service selected one combined overlay, retained the original user-plugin source pointer and left all seven inherited overlay members byte-for-byte unchanged.

Root and an independent reviewer inspected the raw provider, PTY, claim, process-environment and copied SQLite evidence, plus these hidden-renderer images. All 319 recorded test process incarnations exited and four private ports closed; a reused unrelated PID was untouched. These are macOS tests with a controlled loopback provider. The newer-main source composition and its CI remain separately qualified; no paid-provider, Windows, SSH or IME result is claimed. Earlier failed attempts remain preserved.

Fresh startup completed on model A

Nested startup completed on model A

Preserve current overlay cleanup and restore the qualified run prompt contract.
@nwparker
nwparker changed the base branch from nwparker/OpenCode-Overlay-Cleanup-Guard to main October 4, 2026 13:07
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83d81efe-bac1-4ed1-b909-f51543b9ac0f
📥 Commits

Reviewing files that changed from the base of the PR and between 5389925 and a6f8bb9.

📒 Files selected for processing (4)
  • src/shared/flag-prompt-startup.ts
  • src/shared/opencode-startup-prompt.test.ts
  • src/shared/opencode-startup-prompt.ts
  • src/shared/tui-agent-startup.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Flag-prompt startup planning now uses a shared plan builder. For OpenCode run commands, it places the quoted prompt after an existing message separator or adds -- before the prompt. Other commands receive --prompt. The updated tests cover OpenCode command forms across POSIX, PowerShell, and cmd shells, including wrapped commands.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to a6f8b

OpenCode run commands now receive the task as a positional message, and other agents keep --prompt. No merge-blocking risk was found in the supplied changes.

Architecture Summary

Architecture risk: 🟡 Medium · up to a6f8b

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 4 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/shared/flag-prompt-startup.ts: Adds appliedSessionOptionProps, returning a copied sessionOptions object when values has keys and an empty object otherwise.
  • observed — Modified behavior in src/shared/flag-prompt-startup.ts: Adds startup-plan construction that tokenizes the launch command and checks for an OpenCode run command only for opencode or opencode2 when tokenization succeeds. A detected run receives the quoted prompt positionally, after an existing message separator or after -- when absent; other commands receive --prompt. The plan also sets the configured expected process, a null follow-up prompt, launch configuration, optional session options, and startup-prompt environment properties.
  • observed — Modified behavior in src/shared/opencode-startup-prompt.test.ts: The test file imports tokenizeStartupCommand for parsing generated launch commands.
  • observed — Modified behavior in src/shared/opencode-startup-prompt.test.ts: The explicit-run test now expects a positional message after run -- instead of a --prompt option.

Reliability and maintainability

  • inferred — Risk-relevant change factors for src: blast_radius_1; blast_radius_2; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: passing prompts to wrapped OpenCode run commands as positional messages.
Description check ✅ Passed The description covers the user-facing change, rationale, linked issue, visual-proof status, testing, review, scope boundary, and checklist. It notes platform limitations and provides a reason for mar…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit ea6a6d6 into main Oct 4, 2026
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants