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

@serkanalgur/opencode-slim

v1.4.0

Published

Smart context management plugin for OpenCode - semantic compression, cost-aware pruning, adaptive thresholds

Readme

opencode-slim

npm version License: MIT

Smart context management plugin for OpenCode. Optimizes token usage through semantic compression, cost-aware pruning, and adaptive thresholds.

Features

  • TUI Panel - Rich context usage visualization with status indicators
  • Enhanced Compress - Auto/range/topic modes for flexible compression
  • Semantic Compression - Groups related tool calls and compresses them intelligently
  • Cost-Aware Pruning - Considers token pricing when deciding what to compress
  • Adaptive Thresholds - Learns from compression history to optimize timing
  • Session Persistence - Saves state across restarts
  • Deduplication - Removes repeated tool calls automatically
  • Error Purging - Cleans up failed tool call outputs after configurable turns
  • Topic Extraction - Identifies and tracks conversation topics
  • Smart Recommendations - Provides actionable suggestions for context optimization

Installation

opencode plugin @serkanalgur/opencode-slim@latest --global

This installs the plugin globally. The TUI features (panel, slash commands) are automatically loaded when OpenCode starts.

Manual Installation

If the CLI command doesn't work, add to your ~/.config/opencode/opencode.json:

{
  "plugins": ["@serkanalgur/opencode-slim"]
}

Usage

Slash Commands

After installation, these slash commands are available in the TUI:

  • /panel — Opens the rich TUI panel with context usage, stats, and help
  • /compress — Shows instructions for using the compress tool

TUI Panel

The panel provides a real-time overview of your context usage, including:

  • Token usage vs model limit with visual progress bar
  • Message breakdown by role (user/assistant/tools)
  • Compression history and savings
  • Cost estimation based on your model
  • Smart recommendations for optimization

Compress Tool

The enhanced compress tool supports multiple modes:

// Auto mode (default) - intelligently selects what to compress
compress({ focus: "old exploration" })

// Range mode - compress specific message range
compress({ focus: "completed tasks", mode: "range", start: 0, end: 50 })

// Topic mode - compress messages matching a topic
compress({ focus: "database work", mode: "topic", topic: "database" })

Configuration

Create ~/.config/opencode/slim.jsonc:

{
    "enabled": true,
    "compress": {
        "enabled": true,
        "permission": "allow",
        "maxContextLimit": "80%",
        "minContextLimit": "40%",
        "nudgeFrequency": 5,
        "protectUserMessages": false,
        "protectedTools": ["task", "skill", "todowrite", "todoread"]
    },
    "strategies": {
        "deduplication": {
            "enabled": true,
            "protectedTools": []
        },
        "purgeErrors": {
            "enabled": true,
            "turns": 4,
            "protectedTools": []
        }
    },
    "adaptive": {
        "enabled": true,
        "learningRate": 0.1,
        "minCompressionRatio": 0.3
    },
    "costAware": {
        "enabled": true,
        "cacheBoostFactor": 0.5
    },
    "persistence": {
        "enabled": true,
        "directory": "~/.config/opencode/slim"
    }
}

How It Works

TUI Panel

The panel provides a real-time overview of your context usage, including:

  • Token usage vs model limit with visual progress bar
  • Message breakdown by role (user/assistant/tools)
  • Compression history and savings
  • Cost estimation based on your model
  • Topic distribution across the conversation
  • Smart recommendations for optimization

Semantic Compression

Unlike simple text truncation, slim analyzes the semantic content of messages and groups related tool calls together. This preserves context while removing redundancy.

Cost-Aware Pruning

Slim considers the cost of tokens when deciding what to compress. It prioritizes compressing expensive operations (like large file reads) while preserving cheap but important context.

Adaptive Thresholds

The plugin learns from your compression patterns and adjusts thresholds over time. If you tend to need more context, it will compress less aggressively. If you're efficient, it will compress more.

Session Persistence

State is saved to disk, so compression history and learning persist across restarts.

Commands

| Command | Description | |---------|-------------| | /panel | Open the Slim TUI panel with context usage, stats, and help | | /compress | Show instructions for using the compress tool |

Note: Compression is performed by the AI assistant using the compress tool. The slash command provides guidance on usage.

Comparison with DCP

| Feature | slim | DCP | |---------|------|-----| | TUI Panel | ✅ | ✅ | | Slash Commands | ✅ /panel /compress | ✅ /dcp /dcp-compress | | Manual Compress | ✅ | ✅ | | Semantic grouping | ✅ | ❌ | | Cost awareness | ✅ | ❌ | | Adaptive thresholds | ✅ | ❌ | | Session persistence | ✅ | ❌ | | Topic extraction | ✅ | ❌ | | File count | ~10 | ~150 | | License | MIT | AGPL-3.0 | | Config complexity | Low | High |

License

MIT