JSPM

@drfok/opencode-ttc-plugin

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 291
  • Score
    100M100P100Q79810F
  • License ISC

OpenCode plugin that allows input compression via The Token Company API

Package Exports

  • @drfok/opencode-ttc-plugin
  • @drfok/opencode-ttc-plugin/plugin
  • @drfok/opencode-ttc-plugin/plugin-core

Readme

Opencode The Token Company Plugin

OpenCode message transform plugin with The Token Company (TTC) API.

The Token Company (YC W26) builds models that process tokens based on context and semantic intent. With this plugin, you can remove context bloat from your prompts to Opencode before they hit the LLM provider.

npm version License: ISC X (Twitter)

1) Setup

Option A: Let an LLM do it

Paste this into your coding agent:

Install @drfok/opencode-ttc-plugin, run opencode auth login, choose provider the-token-company-plugin, and set the TTC API key. If the key is missing, get one from https://thetokencompany.com/.

Option B: Manual setup

  1. Install and register plugin:
npm install -g @drfok/opencode-ttc-plugin
opencode-ttc-plugin install
  1. Configure auth in OpenCode:
opencode auth login
  1. In the auth flow choose:
  • provider: the-token-company-plugin
  • method: Set TTC API Key
  • paste key from https://thetokencompany.com/
  1. Verify:
opencode-ttc-plugin doctor --verbose

Option C: For LLM agents (step-by-step)

  1. npm install -g @drfok/opencode-ttc-plugin
  2. opencode-ttc-plugin install
  3. opencode auth login
  4. Select provider the-token-company-plugin
  5. Select method Set TTC API Key
  6. Paste API key from https://thetokencompany.com/
  7. opencode-ttc-plugin doctor --verbose

2) Configure compression aggressiveness

Primary control is aggressiveness. You can set it by named level (recommended) or exact numeric value.

Set by level:

opencode-ttc-plugin config set level balanced

Set exact value:

opencode-ttc-plugin config set aggressiveness 0.25

Inspect active config:

opencode-ttc-plugin config get
opencode-ttc-plugin doctor --verbose

Compression levels:

Level Aggressiveness Typical tradeoff
low 0.05 Minimal changes, conservative compression
balanced 0.10 Default; good savings with stable quality
high 0.20 Stronger compression, better token reduction
max 0.30 Most aggressive preset in this plugin

Why these values exist:

  • TTC API exposes aggressiveness on a 0.0-1.0 range in their docs: https://thetokencompany.com/docs
  • TTC benchmark data shows quality/token tradeoffs vary by aggressiveness: https://www.thetokencompany.com/benchmarks/accuracy

Runtime resolution order for aggressiveness:

  1. TTC_AGGRESSIVENESS env var (override)
  2. plugin config file ~/.config/opencode/ttc-plugin.json
  3. built-in default (balanced = 0.1)

3) CLI commands

Command What it does
opencode-ttc-plugin install Installs plugin file into ~/.config/opencode/plugins
opencode-ttc-plugin doctor Runs setup/auth checks
opencode-ttc-plugin doctor --verbose Shows effective config sources and resolution order
opencode-ttc-plugin uninstall Removes installed plugin file
opencode-ttc-plugin config get Prints plugin config and effective aggressiveness
opencode-ttc-plugin config set level <low|balanced|high|max> Sets named aggressiveness level
opencode-ttc-plugin config set aggressiveness <0..1> Sets numeric aggressiveness
opencode-ttc-plugin config set <setting> <value> Sets behavior settings (see table below)
opencode-ttc-plugin config reset Removes plugin config file

Behavior settings

Use CLI config for normal setup. Env vars are advanced overrides.

Setting Default CLI command
enabled true opencode-ttc-plugin config set enabled true
model bear-1.2 opencode-ttc-plugin config set model bear-1.2
minChars 400 opencode-ttc-plugin config set min-chars 400
timeoutMs 2000 opencode-ttc-plugin config set timeout-ms 2000
maxRetries 1 opencode-ttc-plugin config set max-retries 1
retryBackoffMs 100 opencode-ttc-plugin config set retry-backoff-ms 100
useGzip true opencode-ttc-plugin config set use-gzip true
compressSystem false opencode-ttc-plugin config set compress-system false
compressHistory false opencode-ttc-plugin config set compress-history false
debug false opencode-ttc-plugin config set debug false
cacheMaxEntries 1000 opencode-ttc-plugin config set cache-max-entries 1000
toastOnActive true opencode-ttc-plugin config set toast-on-active true
toastOnIdleSummary true opencode-ttc-plugin config set toast-on-idle-summary true

Advanced overrides (optional):

  • TTC_AGGRESSIVENESS, TTC_MIN_CHARS, TTC_TIMEOUT_MS, TTC_MAX_RETRIES, TTC_RETRY_BACKOFF_MS
  • TTC_USE_GZIP, TTC_COMPRESS_SYSTEM, TTC_COMPRESS_HISTORY, TTC_DEBUG
  • TTC_CACHE_MAX_ENTRIES, TTC_TOAST_ON_ACTIVE, TTC_TOAST_ON_IDLE_SUMMARY, TTC_MODEL, TTC_ENABLED

Security and network policy

  • Compression egress is pinned to https://api.thetokencompany.com.
  • Custom/invalid TTC_BASE_URL is ignored and safely falls back to pinned host.
  • If your firewall prompts about outbound socket traffic, that is expected on first compression request.