Skip to content

feat(plugin): improve OpenCode plugin robustness with availability checks#58

Merged
hmans merged 2 commits intohmans:mainfrom
matleh:feature/opencode-plugin
Jan 16, 2026
Merged

feat(plugin): improve OpenCode plugin robustness with availability checks#58
hmans merged 2 commits intohmans:mainfrom
matleh:feature/opencode-plugin

Conversation

@matleh
Copy link
Copy Markdown
Contributor

@matleh matleh commented Jan 16, 2026

Summary

Improves the OpenCode Beans Prime plugin to gracefully handle cases where the beans CLI is not installed or the current project is not configured to use beans.

Changes

  • Availability checks: Verifies both that the beans CLI exists (which beans) and that the project has beans configured (beans check) before attempting to load prime content
  • Error handling: Wraps all beans commands in try-catch to prevent plugin failures
  • Correct working directory: Uses the directory parameter to run beans commands in the correct project context
  • Graceful degradation: When beans is unavailable or not configured, the plugin silently skips adding prime content rather than crashing
  • Code style: Switches to single quotes for consistency with TypeScript conventions

Why

Previously, the plugin would fail if:

  • The beans CLI was not installed on the system
  • The project opened in OpenCode didn't have beans configured
  • Beans commands were run from the wrong directory

This made the plugin unreliable for general use. With these changes, the plugin now works seamlessly across all projects, only injecting beans prime content when it's actually available and appropriate.

Testing

To test this PR:

  1. Open a project without beans configured → plugin should work without errors
  2. Open a project with beans configured → prime content should be injected
  3. Test with beans CLI not installed → plugin should work without errors

…ecks

- Check if beans CLI is installed before attempting to run commands
- Verify project has beans configuration before loading prime
- Handle errors gracefully when beans is unavailable
- Use correct working directory for beans commands
- Switch to single quotes for consistency

This prevents the plugin from failing in projects without beans or
when the beans CLI is not installed.
@hmans
Copy link
Copy Markdown
Owner

hmans commented Jan 16, 2026

Hi, this is a useful change, thanks!

@hmans hmans merged commit 3d3f841 into hmans:main Jan 16, 2026
1 check passed
hmans added a commit to divaltor/beans that referenced this pull request Jan 17, 2026
* origin/main:
  feat(tui): Two-column layout with detail preview (hmans#42)
  feat: add ETag support for optimistic concurrency control (hmans#59)
  feat(plugin): improve OpenCode plugin robustness with availability checks (hmans#58)
  feat(cli): Add --prefix flag to create command (hmans#56)
  chore: clean up README.md
  docs: only push prime if it exists (hmans#52)
  fix: normalise short IDs when storing relationship links (hmans#50)
@matleh matleh deleted the feature/opencode-plugin branch January 22, 2026 09:32
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