Skip to content

perf: optimize plugin loading with better caching#15106

Closed
sureshsankaran wants to merge 31 commits intoanomalyco:devfrom
sureshsankaran:perf/faster-plugin-loading
Closed

perf: optimize plugin loading with better caching#15106
sureshsankaran wants to merge 31 commits intoanomalyco:devfrom
sureshsankaran:perf/faster-plugin-loading

Conversation

@sureshsankaran
Copy link

Summary

  • Remove --force flag from bun add to leverage Bun package cache
  • Move lock acquisition AFTER fast-path checks to reduce contention
  • Add double-check locking pattern after acquiring lock
  • Perform fast-path checks without holding lock for better concurrency

Benefits

This significantly speeds up plugin loading on subsequent runs by:

  1. Skipping npm registry checks when packages are already cached
  2. Avoiding unnecessary lock contention on read-only checks
  3. Preventing duplicate installs when multiple processes race

Testing

  • Ran existing bun tests - all pass
  • Manual testing confirms faster plugin loading on warm starts

suresh sankaran and others added 30 commits January 3, 2026 15:34
- Add dag-orchestrator.md agent for DAG-based task execution
- Add dag-analyzer.ts custom tool for dependency analysis
- Configure as default agent with Hivemind MCP integration
- Non-blocking parallel execution with progress updates
- Tables and ASCII art formatting (no bullet lists)
Implements the Ralph Wiggum technique for self-referential AI loops:
- Add session.stop hook to plugin system for loop control
- Add ralph-loop command to start iterative loops
- Add cancel-ralph and ralph-status commands/tools
- Add state file verification at ~/.config/opencode/state/ralph-wiggum.json
- Support --max, --promise, --state-file, --no-state options
- Proper quoted string parsing for multi-word prompts
- Remove console.log to fix TUI overlay issues

Based on: https://github.com/anthropics/claude-code/tree/main/plugins/ralph-wiggum
Enable proactive context management via SQLite-backed summaries and allow plugins to perform async work during session stop.
Remove custom DAG orchestrator agent, tool, and provider configs.
Add dedicated ralph-wiggum package for iterative development loops.
…system

- Add context-drain plugin to opencode config with intelligent context management
- Add packages/context-drain workspace for token budget management
- Update ralph-wiggum with review phase system (working -> review -> fix cycle)
- Add REVIEW_SYSTEM_PROMPT and FIX_SYSTEM_PROMPT for code review automation
- Default max iterations changed from 10 to 8
Removed the context-drain plugin reference from config after the plugin
file was deleted, which was causing OpenCode to crash with SIGTRAP on
startup.
… plugin

- Replace standalone plugin with symlink to packages/ralph-wiggum/src/index.ts
- Add environment variable check to skip local plugin when global is preferred
- Add README documenting usage, review system, and env var
- Changed ralph-wiggum plugin path from absolute file:// URL to relative path
- Fixes plugin loading on Linux ARM64 systems
- Path now resolves correctly from config file location
- Works across Mac, Linux, and Windows environments
- Fixes TypeScript compilation errors in ralph-wiggum package
- Adds proper Bun type definitions for development
- Resolves pre-push typecheck failures
Gracefully handle missing Instance context to avoid cryptic native binding
errors when tools are executed outside normal server flow (e.g., MCP, plugins).

Related upstream PR: anomalyco#8302
- Add URL param persistence to localStorage for project context
- Fix session loading with proper SDK client initialization
- Add CORS support and launcher routes to server
- Add 0.0.0.0 to localhost hosts for dev connectivity
- Add SPA fallback configuration for vite
- Add parallel plugin loading and bootstrap initialization
- Add bun package install fast path
- Fix prompt input ref assignment
- Add floating button group with 4 navigation buttons
- Go to top/bottom buttons for quick scroll
- Previous/next message buttons for message navigation
- Add keyboard shortcuts: home for first, end for last message
- Add data-session-scroll attribute for scroll targeting
- Buttons only appear when viewing a session with messages
…ge previews

- Add MIME type detection for code files, documents, and images
- Replace createFocusSignal with custom focus handling for late-bound refs
- Fix duplicate attachment rendering in share view
- Add image preview support for shared sessions
- Use h-dvh for better mobile viewport handling
- Bump bun to 1.3.6
…uncher

- Add empathy listener agent and plugin for conversation memory
- Add custom commands: helpme, listen, tweets
- Add e2e tests for app switching, file picker, image attachments, nav buttons, session list
- Add launcher HTML page and test
- Add server start script
Use Visual Viewport API to detect keyboard open/close and adjust
prompt input and navigation buttons position. Force repaint when
keyboard closes to eliminate leftover gap.
Merged upstream changes while preserving fork's unique features:
- Ralph Wiggum plugin (iterative development loops)
- Context-drain plugin
- Empathy listener plugin
- Navigation buttons for mobile
- File attachment improvements (broader MIME types, image previews)
- Virtual keyboard handling (createVisualViewport hook)
- Portal-based header (renders to titlebar slots)
- IME composition handling
- Persisted caching with runWithOwner in global-sync
- Message pagination/history loading in sync.tsx

Added upstream features:
- CORS support for 0.0.0.0 and dev ports (3000, 5173)
- /launcher and /launcher/browse routes for directory browsing
- DEV_APP environment variable for local development proxy
- launcher.html static file
The DialogSelectDirectory component was using file.list which is sandboxed
to the current project directory. This prevented browsing to select a new
project from outside the current directory.

- Add global.browse endpoint that can browse any directory on the filesystem
- Update DialogSelectDirectory to use global.browse instead of file.list
- Fix CORS to allow requests from any origin on dev ports (3000/5173)
- Add e2e test for directory dialog functionality
- Add screen-analyzer.md: Custom subagent for AI-powered screen monitoring
- Add tdd-loop.ts: Custom plugin for TDD workflow automation
- Add design.md: Design documentation and notes
- Update server.ts: Add executable option for customizing opencode binary path
- Update bun.lock: Dependency lock file updates
- Add @sureshsankaran/opencode-destructive-check npm package
- Plugin asks for permission before executing destructive commands
- Detects 52 patterns across 8 categories (rm, git, database, system, sudo, container, packages, network)
- Protects 28 dangerous file paths
- Auto-loads for all sessions and agents via opencode.jsonc config
… fallbacks

- Update destructive-check plugin to support both old (type/pattern) and new (permission/patterns) permission APIs
- Integrate plugin hooks into prompt.ts to intercept permission requests and force 'ask' when needed
- Add clipboard fallback using execCommand for environments where navigator.clipboard fails
- Fix Shift+Enter to properly insert newline instead of submitting form
- Change screen-analyzer agent to primary mode
…r input

- Add new Chime module (util/chime.ts) with configurable audio notifications
- Play chime when session status becomes idle (status.ts)
- Play chime in run command when waiting for input (run.ts)
- Add chime configuration options to config schema (config.ts)
- Support custom sound file path via config
- Only plays on macOS where afplay is available
- Gracefully handles errors and missing contexts
- Add SessionRawContextTab component with sub-tabs for system prompts and LLM messages
- Add Raw Context tab to desktop right panel and mobile dialog
- Add i18n translations for all 14 languages
- Fix mobile button to use valid 'code' icon
- Import Dialog component for mobile modal
- Add raw context button to mobile navigation
- Improve destructive command check with enhanced warnings and metadata
- Update session list to use projectID for worktree support
- Remove --force flag from bun add to leverage Bun's package cache
- Move lock acquisition AFTER fast-path checks to reduce contention
- Add double-check locking pattern after acquiring lock
- Perform fast-path checks without holding lock for better concurrency

This significantly speeds up plugin loading on subsequent runs by:
1. Skipping npm registry checks when packages are already cached
2. Avoiding unnecessary lock contention on read-only checks
3. Preventing duplicate installs when multiple processes race
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 25, 2026
@github-actions
Copy link
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Contributor

Hey! Your PR title perf: optimize plugin loading with better caching doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 25, 2026
@github-actions github-actions bot closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant