Skip to content

Conversation

@shuv1337
Copy link
Collaborator

@shuv1337 shuv1337 commented Jan 7, 2026

Summary

This PR completes the v1.1.6 integration by fixing plugin command execution that was lost during the merge.

Changes from v1.1.6 Upstream Sync

Features

  • Truncation system: New configurable limits (2000 lines, 50KB bytes) with head/tail direction support for all tool outputs
  • Permission enhancements: PermissionNext with wildcard pattern matching
  • Console billing: Stripe webhook handlers for checkout, subscriptions, payments, and refunds
  • Desktop Tauri: Enhanced entitlements and lib.rs improvements
  • Zed extension: Updated to match upstream v1.1.6

Fixes

  • fix(grep): Stream ripgrep output line-by-line to prevent memory exhaustion on large codebases (PR fix(grep): stream ripgrep output to prevent memory exhaustion anomalyco/opencode#5432)
  • fix: Show spinner indicator for running tool calls and subagent tasks
  • fix(pwa): Lock viewport on iOS to prevent overscroll bounce in PWA standalone mode
  • fix(bedrock): Handle bundled AWS SDK export shapes from Bun with robust coalescing logic
  • fix: Resolve TypeScript errors in theme.tsx and prompt.ts
  • fix: Restore plugin command execution and sessionOnly guard (lost during merge)

Plugin Command Fix Details

Restored two critical pieces of code lost during v1.1.6 merge:

  1. sessionOnly guard - Checks if command requires existing session, throws appropriate error if missing
  2. Plugin command execution - Direct execution via plugin hooks instead of treating as templates

Files Modified

  • packages/opencode/src/session/prompt.ts - Restored sessionOnly and plugin execution code
  • script/sync/fork-features.json - Documented feature to prevent future merge regressions

Testing

All tests pass including:

  • Bedrock bundled module export tests
  • Truncation tests
  • Permission task tests
  • Plugin command tests (4 tests):
    • Command.get resolves plugin aliases
    • SessionPrompt.command executes plugin command
    • SessionPrompt.command publishes error on plugin failure
    • SessionPrompt.command blocks session-only commands for missing sessions

Breaking Changes

None

Greptile Summary

Restores two critical plugin command features that were lost during the v1.1.6 upstream merge:

  • sessionOnly guard: Validates that session-only commands have an existing session before execution, throwing appropriate errors if missing
  • Plugin command execution: Executes plugin commands directly via plugin hooks instead of treating them as templates

The implementation follows existing patterns with proper error handling, logging, and event publishing. The fork-features.json documentation prevents future merge regressions by documenting the code markers to preserve.

Confidence Score: 5/5

  • This PR is safe to merge - it restores previously working code with comprehensive test coverage
  • The changes are well-tested (4 dedicated tests in plugin-commands.test.ts), follow existing code patterns, include proper error handling and logging, and restore functionality that was previously working before being lost in a merge
  • No files require special attention

Important Files Changed

Filename Overview
packages/opencode/src/session/prompt.ts Restores plugin command execution and sessionOnly guard that was lost during v1.1.6 merge. Clean implementation with proper error handling and logging.
script/sync/fork-features.json Documents the restored fork-specific feature to prevent future merge regressions. Well-documented with file markers and descriptions.

Sequence Diagram

sequenceDiagram
    participant User
    participant SessionPrompt
    participant Command
    participant Session
    participant Plugin
    participant Bus

    User->>SessionPrompt: command(input)
    SessionPrompt->>Command: get(command)
    Command-->>SessionPrompt: command info

    alt command.sessionOnly is true
        SessionPrompt->>Session: get(sessionID)
        alt Session not found
            Session-->>SessionPrompt: error
            SessionPrompt->>Bus: publish(Session.Event.Error)
            SessionPrompt-->>User: throw Error
        else Session found
            Session-->>SessionPrompt: session
        end
    end

    alt command.type === "plugin"
        SessionPrompt->>Plugin: list()
        Plugin-->>SessionPrompt: plugins[]
        loop for each plugin
            SessionPrompt->>Plugin: client()
            Plugin-->>SessionPrompt: client
            SessionPrompt->>Plugin: pluginCommand.execute()
            alt execution fails
                Plugin-->>SessionPrompt: error
                SessionPrompt->>Bus: publish(Session.Event.Error)
                SessionPrompt-->>User: throw error
            else execution succeeds
                SessionPrompt->>Session: messages({limit: 1})
                Session-->>SessionPrompt: messages[]
                alt messages exist
                    SessionPrompt->>Bus: publish(Command.Event.Executed)
                    SessionPrompt-->>User: return last message
                else no messages
                    SessionPrompt-->>User: return undefined
                end
            end
        end
    else command.type === "template"
        SessionPrompt->>SessionPrompt: process template
        SessionPrompt-->>User: return result
    end
Loading

Code was lost during v1.1.6 upstream merge. This restores:
- sessionOnly guard to block commands that require an existing session
- Plugin command execution via plugin hooks with error handling
- Tests in test/command/plugin-commands.test.ts verified passing

Documented in fork-features.json for future merge protection.
@shuv1337 shuv1337 merged commit d0ffbac into integration Jan 7, 2026
1 of 2 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