Skip to content

Plugin System Overview

tokentop is built on a plugin architecture with four distinct plugin types. Everything from provider integrations to color themes is a plugin, making the system highly extensible.

TypePurposeExamples
ProviderFetch usage data from AI model APIsAnthropic, OpenAI, Google
AgentParse coding agent sessionsClaude Code, Cursor, OpenCode
ThemeVisual color schemes for the TUITokyo Night, Dracula, Nord
NotificationAlert delivery mechanismsTerminal bell, visual flash

Plugins are loaded from three sources, in order:

  1. Built-in plugins — Shipped with tokentop in the core package
  2. Local plugins — Discovered from ~/.config/tokentop/plugins/ and paths specified via --plugin flag or config.plugins.local
  3. npm plugins — Packages listed in config.plugins.npm

Plugins listed in config.plugins.disabled are removed after loading.

tokentop discovers local plugins from several sources:

  • Default directory: ~/.config/tokentop/plugins/ (files and directories)
  • CLI flag: ttop --plugin <path> loads a plugin for that run (repeatable)
  • Config file: plugins.local array in ~/.config/tokentop/config.json

See Local Development for a detailed guide on all three methods, entry point resolution, and a recommended development workflow.

All plugins must declare their required permissions:

permissions: {
network?: { enabled: boolean; allowedDomains?: string[] };
filesystem?: { read?: boolean; write?: boolean; paths?: string[] };
env?: { read?: boolean; vars?: string[] };
system?: { notifications?: boolean; clipboard?: boolean };
}

tokentop enforces these permissions at runtime, preventing plugins from accessing resources they haven’t declared.

TierPatternExample
Official@tokentop/{type}-<name>@tokentop/agent-opencode
Communitytokentop-{type}-<name>tokentop-provider-replicate
Scoped@scope/tokentop-{type}-<name>@myname/tokentop-theme-catppuccin

The @tokentop/* scope is reserved for official plugins.