npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-devcontainers

v0.3.2

Published

OpenCode plugin for isolated branch workspaces using devcontainers or git worktrees

Readme

opencode-devcontainers

OpenCode plugin for isolated branch workspaces using devcontainers or git worktrees.

Note: This is a community project and is not built by or affiliated with the OpenCode team.

Version 0.x - Pre-1.0 software. Minor versions may contain breaking changes.

Why?

When working on multiple branches, you need isolated development environments:

  • Devcontainers provide full container isolation (different dependencies, databases, etc.)
  • Worktrees provide lightweight filesystem isolation (same dependencies, just different code)

This plugin provides both options with:

  • Session state management (the agent remembers your workspace)
  • Auto-assigned ports from a configurable range (13000-13099)
  • Automatic copying of gitignored secrets (.env, credentials, etc.)
  • Unified workspace management and cleanup

Installation

Add to your ~/.config/opencode/opencode.json:

{
  "plugin": ["opencode-devcontainers"]
}

OpenCode automatically installs npm plugins on startup.

Dependencies

  • For devcontainers: devcontainer CLI - Install with: npm install -g @devcontainers/cli
  • For worktrees: Just git (no additional dependencies)

Usage

Devcontainers (Full Container Isolation)

/devcontainer feature-x    # Start/target a devcontainer for this branch
/devcontainer myapp/main   # Target specific repo/branch
/devcontainer              # Show current status
/devcontainer off          # Disable, run commands on host

When a devcontainer is targeted:

  • Most commands run inside the container automatically
  • Git operations and file reading run on host
  • Prefix with HOST: to force host execution

Worktrees (Lightweight Filesystem Isolation)

/worktree feature-x        # Create/target a worktree for this branch
/worktree myapp/main       # Target specific repo/branch
/worktree                  # Show current status
/worktree off              # Disable, run commands in original directory

When a worktree is targeted:

  • Bash commands run in the worktree directory
  • Same HOST: prefix for escaping
  • Gitignored files are automatically copied from main repo

Workspace Management

/workspaces                # List all workspaces (clones + worktrees)
/workspaces cleanup        # Find stale workspaces (not used in 7+ days)

When to Use What

| Use Case | Recommendation | |----------|----------------| | Project has devcontainer.json | /devcontainer | | Different dependencies per branch | /devcontainer | | Quick branch work, same deps | /worktree | | No Docker available | /worktree | | Testing migrations/databases | /devcontainer |

Configuration

~/.config/opencode/devcontainers/config.json:

{
  "portRangeStart": 13000,
  "portRangeEnd": 13099
}

How It Works

Devcontainers

  1. Creates clone in ~/.local/share/opencode/clone/<repo>/<branch>/
  2. Copies gitignored secrets from main repo
  3. Generates ephemeral override config with unique port
  4. Starts container via devcontainer up

Worktrees

  1. Creates worktree in ~/.local/share/opencode/worktree/<repo>/<branch>/
  2. Copies gitignored secrets from main repo
  3. Runs direnv allow if .envrc exists
  4. Sets bash workdir to the worktree path

Port/Database Isolation (Worktrees)

For worktrees, you can configure your .envrc to derive PORT and database settings from the worktree name to avoid conflicts:

# .envrc
export BRANCH_NAME=$(basename $(pwd))
export PORT=$((3000 + $(echo "$BRANCH_NAME" | cksum | cut -d' ' -f1) % 1000))
export DATABASE_URL="postgres://localhost/${BRANCH_NAME//-/_}_development"

Integration with opencode-pilot

When using opencode-pilot for automated issue processing, configure your repos.yaml:

repos:
  myorg/myrepo:
    session:
      prompt_template: |
        /devcontainer issue-{number}

        {title}

        {body}

This starts an isolated devcontainer for each issue automatically.

Known Issues

OpenCode Desktop shows changes from wrong directory

When switching workspaces with /devcontainer or /worktree, OpenCode's internal directory context doesn't update. The "Session changes" panel continues showing diffs from the original directory.

Workaround: Start OpenCode directly in the target directory, or use separate terminal sessions per workspace.

Upstream issue: anomalyco/opencode#6697

Environment Variables

Override default paths:

  • OCDC_CONFIG_DIR - Config directory (default: ~/.config/opencode/devcontainers)
  • OCDC_CACHE_DIR - Cache directory (default: ~/.cache/opencode-devcontainers)
  • OCDC_CLONES_DIR - Clones directory (default: ~/.local/share/opencode/clone)
  • OCDC_WORKTREES_DIR - Worktrees directory (default: ~/.local/share/opencode/worktree)
  • OCDC_SESSIONS_DIR - Sessions directory (default: <cache>/opencode-sessions)

Related

  • opencode-pilot - Automation layer for OpenCode (notifications, mobile UI, polling)

License

MIT