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-janus

v1.3.0

Published

Directory-based OpenCode configuration switching tool. Automatically switch between different OpenCode configurations based on your current working directory.

Readme

🔀 Janus

Directory-aware OpenCode configuration switcher

Named after the Roman god of transitions—seamlessly transform your configuration as you navigate between projects

npm version npm downloads License Node.js Version

FeaturesQuick StartConfigurationHow It Works


✨ Features

🎯 Smart Path Matching

Automatically detects your working directory and applies the right configuration

⚡ Zero Overhead

Lightweight shell integration with instant switching

🔒 Process Isolation

Each OpenCode instance runs with its own isolated configuration

🎨 Flexible Patterns

Full glob pattern support with longest-prefix priority

🚀 Quick Start

Installation

npm install -g opencode-janus
git clone https://github.com/kuitos/janus.git
cd janus
bun install && bun run build
npm install -g .

Setup in 3 steps

# 1. Create your configuration file
mkdir -p ~/.config/janus
nano ~/.config/janus/config.json

# 2. Install shell hook (auto-detects zsh/bash)
janus install

# 3. Reload your shell
source ~/.zshrc  # or ~/.bashrc

That's it! 🎉 Your opencode command now adapts to each directory.

⚙️ Configuration

Create ~/.config/janus/config.json with your mapping rules:

{
  "defaultConfigDir": "/Users/yourname/.config/opencode-default", // Optional: Fallback config for unmatched paths
  "mappings": [
    {
      "match": ["/Users/yourname/work/**"],        // Company projects
      "configDir": "/Users/yourname/.config/opencode-work"
    },
    {
      "match": ["/Users/yourname/projects/oss/**"], // Open source
      "configDir": "/Users/yourname/.config/opencode-oss"
    },
    {
      "match": ["/Users/yourname/personal/**"],     // Personal projects
      "configDir": "/Users/yourname/.config/opencode-personal"
    }
  ]
}

Configuration Structure

Each configDir should contain:

~/.config/opencode-work/
├── opencode.json           # OpenCode settings
└── oh-my-opencode.json     # oh-my-opencode plugins

| Field | Type | Required | Description | |-------|------|----------|-------------| | defaultConfigDir | string | No | Fallback configuration directory when no mappings match | | mappings | Array | Yes | List of directory-to-config mapping rules | | match | string[] | Yes | Path patterns to match (supports ** glob) | | configDir | string | Yes | Absolute path to configuration directory |

Pattern Matching:

  • Supports glob patterns: **, *, ?
  • Supports tilde (~) expansion for home directory
  • Multiple patterns per mapping
  • Longest (most specific) match wins
  • Falls back to defaultConfigDir if configured and no match found

Path Examples:

{
  "defaultConfigDir": "~/.config/opencode-default",  // ✅ Optional fallback
  "mappings": [
    {
      "match": ["~/work/**"],           // ✅ Tilde expanded to home directory
      "configDir": "~/.config/work"     // ✅ Also supports tilde
    },
    {
      "match": ["/absolute/path/**"],   // ✅ Absolute path
      "configDir": "/absolute/config"
    }
  ]
}

Default Configuration Behavior:

  • When a directory doesn't match any pattern in mappings, defaultConfigDir is used (if configured)
  • If defaultConfigDir is not set, unmatched directories will not use any configuration (backward compatible)
  • Useful for providing a general-purpose configuration for casual projects

💡 How It Works

graph LR
    A[cd ~/work/project] --> B{janus hook}
    B --> C[Match path patterns]
    C --> D[Find longest match]
    D --> E[Set OPENCODE_CONFIG_DIR]
    E --> F[opencode uses custom config]
  1. Shell Integration – Hook runs on directory change
  2. Path Resolution – Matches current path against patterns
  3. Priority Selection – Longest (most specific) pattern wins
  4. Environment Setup – Sets OPENCODE_CONFIG_DIR for the session
  5. Isolated Execution – Each process gets the right configuration

🛠️ Commands

janus install    # Install shell hook (auto-detects shell)
janus uninstall  # Remove shell hook
janus --version  # Show version
janus --help     # Show help

🧪 Development

# Run tests
bun test

# Coverage report
bun test --coverage

# Type checking
bun run typecheck

# Build for production
bun run build

📦 Project Structure

src/
├── cli.ts              # CLI entry point
├── config.ts           # Configuration loading & validation
├── resolver.ts         # Path matching engine
├── install.ts          # Shell hook installer
├── shell-hook.ts       # Hook generation logic
├── types.ts            # TypeScript definitions
└── *.test.ts           # Comprehensive test suite

🤝 Contributing

Contributions are welcome! Feel free to:

📄 License

MIT © kuitos

🙏 Acknowledgments

Built with ❤️ using:

  • Bun – Fast all-in-one JavaScript runtime
  • Zod – TypeScript-first schema validation

Inspired by:

  • direnv – Environment switcher for the shell
  • projj – Project management tool