[FEATURE]: Plugin-Provided Autocomplete #3552

Open
opened 2026-02-16 17:40:37 -05:00 by yindo · 3 comments
Owner

Originally created by @V1RE on GitHub (Dec 15, 2025).

Originally assigned to: @thdxr on GitHub.

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

Describe the enhancement you want to request

Problem

Currently, the TUI autocomplete only supports built-in triggers:

  • @ for files and agents
  • / for slash commands

There's no way for plugins to contribute completion items. This limits plugins that could benefit from autocomplete, such as:

  • Issue trackers (beads, linear, jira) - completing issue IDs
  • Database tools - completing table/column names
  • Project-specific references - completing custom identifiers

Proposed Solution

Add a new plugin hook "autocomplete.provide" that allows plugins to:

  1. Register custom trigger characters (e.g., # for issues)
  2. Provide completion items when their trigger is activated
  3. Optionally handle their own filtering (vs. default fuzzysort)

API Design

// Provider configuration
interface AutocompleteProvider {
  trigger: string      // "@", "#", or prefix like "bd-"
  fuzzy?: boolean      // Use fuzzysort (default: true)
}

// Completion item
interface AutocompleteItem {
  display: string      // Dropdown text
  value?: string       // Text to insert
  description?: string // Secondary text
}

// Hook signature
interface Hooks {
  "autocomplete.provide"?: (
    input: { trigger: string; query: string },
    output: { provider?: AutocompleteProvider; items: AutocompleteItem[] }
  ) => Promise<void>
}

Example Usage

// Beads issue tracker plugin
export const BeadsPlugin: Plugin = async (ctx) => ({
  "autocomplete.provide": async (input, output) => {
    output.provider = { trigger: "#", fuzzy: true }
    if (input.trigger !== "#") return
    
    const issues = await fetchIssues(ctx)
    for (const issue of issues) {
      output.items.push({
        display: `${issue.id}: ${issue.title}`,
        value: issue.id,
        description: issue.status,
      })
    }
  },
})

User types #bd- → sees dropdown with matching issues → selects → bd-a1b2 inserted.

Behavior

  • Trigger conflict: First plugin to register a trigger wins
  • Prefix triggers: Support both single-char (#) and prefix (bd-) triggers
  • Filtering: OpenCode applies fuzzysort by default; plugins can disable and filter themselves
  • Insertion: Selected item's value (or display) is inserted at cursor

Implementation Scope

Package Changes
@opencode-ai/plugin Add hook types
packages/opencode/src/server/server.ts Add /autocomplete/* endpoints
packages/opencode/src/cli/cmd/tui/context/sync.tsx Store providers
packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx Handle custom triggers
SDK Regenerate from OpenAPI

Benefits

  1. Extensibility: Plugins can provide contextual completions
  2. Better UX: Users get autocomplete for plugin-specific identifiers
  3. Consistent patterns: Uses existing hook/trigger architecture
  4. Non-breaking: Existing @ and / behavior unchanged

Use Cases

  • Issue trackers: beads, Linear, Jira, GitHub Issues
  • Documentation: Notion pages, Confluence docs
  • Databases: Table/column names for SQL tools
  • Custom references: Project-specific IDs, ticket numbers

Happy to implement this if the design looks good. Let me know if you'd prefer different trigger behavior or API shape.

Originally created by @V1RE on GitHub (Dec 15, 2025). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## Describe the enhancement you want to request ### Problem Currently, the TUI autocomplete only supports built-in triggers: - `@` for files and agents - `/` for slash commands There's no way for plugins to contribute completion items. This limits plugins that could benefit from autocomplete, such as: - Issue trackers (beads, linear, jira) - completing issue IDs - Database tools - completing table/column names - Project-specific references - completing custom identifiers ### Proposed Solution Add a new plugin hook `"autocomplete.provide"` that allows plugins to: 1. Register custom trigger characters (e.g., `#` for issues) 2. Provide completion items when their trigger is activated 3. Optionally handle their own filtering (vs. default fuzzysort) ### API Design ```typescript // Provider configuration interface AutocompleteProvider { trigger: string // "@", "#", or prefix like "bd-" fuzzy?: boolean // Use fuzzysort (default: true) } // Completion item interface AutocompleteItem { display: string // Dropdown text value?: string // Text to insert description?: string // Secondary text } // Hook signature interface Hooks { "autocomplete.provide"?: ( input: { trigger: string; query: string }, output: { provider?: AutocompleteProvider; items: AutocompleteItem[] } ) => Promise<void> } ``` ### Example Usage ```typescript // Beads issue tracker plugin export const BeadsPlugin: Plugin = async (ctx) => ({ "autocomplete.provide": async (input, output) => { output.provider = { trigger: "#", fuzzy: true } if (input.trigger !== "#") return const issues = await fetchIssues(ctx) for (const issue of issues) { output.items.push({ display: `${issue.id}: ${issue.title}`, value: issue.id, description: issue.status, }) } }, }) ``` User types `#bd-` → sees dropdown with matching issues → selects → `bd-a1b2` inserted. ### Behavior - **Trigger conflict**: First plugin to register a trigger wins - **Prefix triggers**: Support both single-char (`#`) and prefix (`bd-`) triggers - **Filtering**: OpenCode applies fuzzysort by default; plugins can disable and filter themselves - **Insertion**: Selected item's `value` (or `display`) is inserted at cursor ### Implementation Scope | Package | Changes | |---------|---------| | `@opencode-ai/plugin` | Add hook types | | `packages/opencode/src/server/server.ts` | Add `/autocomplete/*` endpoints | | `packages/opencode/src/cli/cmd/tui/context/sync.tsx` | Store providers | | `packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx` | Handle custom triggers | | SDK | Regenerate from OpenAPI | ### Benefits 1. **Extensibility**: Plugins can provide contextual completions 2. **Better UX**: Users get autocomplete for plugin-specific identifiers 3. **Consistent patterns**: Uses existing hook/trigger architecture 4. **Non-breaking**: Existing `@` and `/` behavior unchanged ### Use Cases - **Issue trackers**: beads, Linear, Jira, GitHub Issues - **Documentation**: Notion pages, Confluence docs - **Databases**: Table/column names for SQL tools - **Custom references**: Project-specific IDs, ticket numbers --- Happy to implement this if the design looks good. Let me know if you'd prefer different trigger behavior or API shape.
yindo added the discussion label 2026-02-16 17:40:37 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 15, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5305: [FEATURE]: Plugin Hook for Instant TUI Commands - Similar plugin extensibility request for command/trigger registration
  • #2185: Hooks for commands (Plugin Commands) - Earlier feature request for plugin command hooks
  • #5148: [FEATURE]: Comprehensive Plugin Pipeline - Middleware-Style Data Flow Control - Broader plugin system extensibility request that would enable custom autocomplete

All these requests aim to extend the plugin system to support new types of plugin-provided functionality beyond current event hooks. The autocomplete feature request may benefit from insights in these related discussions.

Feel free to ignore if your specific autocomplete use case addresses unique requirements not covered in these issues.

@github-actions[bot] commented on GitHub (Dec 15, 2025): This issue might be a duplicate of existing issues. Please check: - #5305: [FEATURE]: Plugin Hook for Instant TUI Commands - Similar plugin extensibility request for command/trigger registration - #2185: Hooks for commands (Plugin Commands) - Earlier feature request for plugin command hooks - #5148: [FEATURE]: Comprehensive Plugin Pipeline - Middleware-Style Data Flow Control - Broader plugin system extensibility request that would enable custom autocomplete All these requests aim to extend the plugin system to support new types of plugin-provided functionality beyond current event hooks. The autocomplete feature request may benefit from insights in these related discussions. Feel free to ignore if your specific autocomplete use case addresses unique requirements not covered in these issues.
Author
Owner

@rekram1-node commented on GitHub (Dec 15, 2025):

I think @thdxr had some ideas but this is definitely something we want

@rekram1-node commented on GitHub (Dec 15, 2025): I think @thdxr had some ideas but this is definitely something we want
Author
Owner

@antonio-ivanovski commented on GitHub (Feb 12, 2026):

I think @thdxr had some ideas but this is definitely something we want

This is something i want too :) I was using the desktop opencode for a bit and got fooled by the spellcheck and dumb next word suggestion. Would not make it as aggressive as in Cursor as this is when the AI can influence our thinking and steer us in an undesired direction.

@rekram1-node @thdxr

@antonio-ivanovski commented on GitHub (Feb 12, 2026): > I think [@thdxr](https://github.com/thdxr) had some ideas but this is definitely something we want This is something i want too :) I was using the desktop opencode for a bit and got fooled by the spellcheck and dumb next word suggestion. Would not make it as aggressive as in Cursor as this is when the AI can influence our thinking and steer us in an undesired direction. @rekram1-node @thdxr
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3552