[FEATURE]: TUI plugin API for inline prompt suggestions

未关闭
#65,338 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
15/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

Start from the plugin host's context.ui.prompt surface and the existing prompt/textarea renderer that the external opencode-autosuggestions plugin currently patches through renderer internals; read the prior art in #51209 (draft and cursor access) and #54197 (empty-composer suggestions) before designing the API. The proposal spans keybind handling (Tab, Ctrl+Right, Escape), trimming on typed prefix, and suppression rules for shell mode, open autocomplete/dialogs and non-end cursors, so it needs agreement on the contract first and tests against opencode-autosuggestions to be considered done. The author has stated they intend to implement it in a single PR, so coordinate before starting.

由索引模型根据 Issue 内容生成。

描述

area/plugins type/feature version/v2
Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request

TUI plugins have no supported way to show an inline suggestion in the prompt. opencode-autosuggestions already completes drafts while typing and suggests follow-ups after each turn, but it finds the prompt textarea through renderer internals and draws the ghost text in an absolutely positioned overlay at the cursor's screen coordinates. Its source notes that an OpenCode update can break this.

Proposal: add a suggestion API to context.ui.prompt, next to the draft access requested in #51209.

context.ui.prompt.suggest({ sessionID, text }): () => void
  • The host draws text as muted ghost text right after the cursor, in an empty or non-empty draft, and handles wrapping.
  • Tab accepts the whole suggestion, Ctrl+Right accepts the next word, and Escape dismisses it. All three are configurable keybinds. Accepting inserts text into the draft and never submits.
  • When the user types characters that match the start of the suggestion, the host trims it. Any other edit, cursor move or session switch clears it.
  • Suggestions are ignored in shell mode, while autocomplete or a dialog is open, and when the cursor is not at the end of the draft.
  • Plugins also need to read the draft and cursor (#51209) and get a change event, so they can debounce their own requests.

This covers what #54197 did for the empty composer and extends it to drafts in progress. Model calls stay in plugins, so core sends no extra model requests.

I plan to implement this in a single PR and test it against opencode-autosuggestions.

主要语言
TypeScript
星标
227k
派生
30.7k
平均合并
3 小时 57 分钟
30 天内合并 PR
484

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。