{"_id":"@artem-kuprin/opencode-toolcost","_rev":"2-f7e93581ad60ea2fd8e2956988b244bc","name":"@artem-kuprin/opencode-toolcost","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@artem-kuprin/opencode-toolcost","version":"1.0.0","keywords":["opencode","opencode-plugin","plugin","token-usage","cost-tracking","tool-cost","sidebar","cost"],"author":{"url":"https://github.com/ArtemKx1","name":"Artem K.","email":"artem.kx@proton.me"},"license":"MIT","_id":"@artem-kuprin/opencode-toolcost@1.0.0","maintainers":[{"name":"artem_kuprin","email":"artem.kx@proton.me"}],"homepage":"https://github.com/ArtemKx1/opencode-toolcost#readme","bugs":{"url":"https://github.com/ArtemKx1/opencode-toolcost/issues"},"dist":{"shasum":"3107eaae9f23461898ccf69e4fa326013c35cc59","tarball":"https://registry.npmjs.org/@artem-kuprin/opencode-toolcost/-/opencode-toolcost-1.0.0.tgz","fileCount":24,"integrity":"sha512-MZJFRy+nH6jwRvUUd+QoogmQFRcKrklhQAnzo1NEMf5EJOr/Z0Fe8zNHShQJKck0OyafG1vEwKkEIrSio8ORiA==","signatures":[{"sig":"MEYCIQDtqJDrybRQqbkXBrJPjSNTfB/bL3hQiKQdAthAXK1FHwIhALvH9yFspdflLDvjs4l5omppR5kO62HHD/G8VXhmyztR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45087},"main":"./dist/toolcost.js","type":"module","types":"./dist/toolcost.d.ts","$schema":"https://json.schemastore.org/package.json","exports":{".":{"types":"./dist/toolcost.d.ts","default":"./dist/toolcost.js"},"./tui":{"types":"./dist/tui.d.ts","default":"./dist/tui.tsx"},"./server":{"types":"./dist/toolcost.d.ts","default":"./dist/toolcost.js"}},"gitHead":"0e58b8c9e4dcb29f5a294e322ba44755a11edaf6","scripts":{"build":"npm run clean && tsc && node scripts/copy-tui.mjs","clean":"rm -rf dist","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"artem_kuprin","email":"artem.kx@proton.me"},"oc-plugin":["server","tui"],"repository":{"url":"git+https://github.com/ArtemKx1/opencode-toolcost.git","type":"git"},"_npmVersion":"11.5.1","description":"OpenCode plugin — real-time per-tool token cost breakdown in TUI sidebar","directories":{},"_nodeVersion":"24.6.0","dependencies":{"solid-js":"^1.9.10","@opentui/core":"^0.1.92","@opentui/solid":"^0.1.92"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.2.0","typescript":"^5.7.0","@types/node":"^22.0.0","@opencode-ai/sdk":"^1.4.7","@opencode-ai/plugin":"^1.4.7"},"peerDependencies":{"@opencode-ai/sdk":"^1.3.5","@opencode-ai/plugin":"^1.3.5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-toolcost_1.0.0_1778753899700_0.9802444409525783","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"$schema":"https://json.schemastore.org/package.json","name":"@artem-kuprin/opencode-toolcost","version":"1.0.1","description":"See exactly how much each tool (read, edit, bash, grep, task) is costing you — live per-tool breakdown in the OpenCode TUI sidebar","type":"module","main":"./dist/toolcost.js","types":"./dist/toolcost.d.ts","exports":{".":{"types":"./dist/toolcost.d.ts","default":"./dist/toolcost.js"},"./server":{"types":"./dist/toolcost.d.ts","default":"./dist/toolcost.js"},"./tui":{"types":"./dist/tui.d.ts","default":"./dist/tui.tsx"}},"oc-plugin":["server","tui"],"scripts":{"clean":"rm -rf dist","build":"npm run clean && tsc && node scripts/copy-tui.mjs","prepublishOnly":"npm run build","typecheck":"tsc --noEmit"},"keywords":["opencode","opencode-plugin","plugin","token-usage","cost-tracking","tool-cost","sidebar","cost"],"homepage":"https://github.com/ArtemKx1/opencode-toolcost#readme","bugs":{"url":"https://github.com/ArtemKx1/opencode-toolcost/issues"},"repository":{"type":"git","url":"git+https://github.com/ArtemKx1/opencode-toolcost.git"},"author":{"name":"Artem K.","email":"artem.kx@proton.me","url":"https://github.com/ArtemKx1"},"license":"MIT","publishConfig":{"access":"public"},"peerDependencies":{"@opencode-ai/plugin":"^1.3.5","@opencode-ai/sdk":"^1.3.5","@opentui/core":"^0.3.2","@opentui/solid":"^0.3.2","solid-js":"^1.9.10"},"dependencies":{},"devDependencies":{"@opencode-ai/plugin":"^1.16.2","@opencode-ai/sdk":"^1.16.2","@opentui/core":"^0.3.4","@opentui/solid":"^0.3.4","solid-js":"^1.9.10","@types/bun":"^1.2.0","@types/node":"^22.0.0","typescript":"^5.7.0"},"gitHead":"20db6c5dbd6a3c5c94784acf2a7bcb8b0d39fb33","_id":"@artem-kuprin/opencode-toolcost@1.0.1","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-MFd5QkVxPe3GSaO709zFsju6C/WJvnQotZbySPhUNwpfRM+dTWNLWC6NRqu35mg/nraam1iFlbq0zM5zTNWy0g==","shasum":"fbd78cb0bcd3fecaac7a2c32e7efa93dfd126b28","tarball":"https://registry.npmjs.org/@artem-kuprin/opencode-toolcost/-/opencode-toolcost-1.0.1.tgz","fileCount":24,"unpackedSize":46173,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAHtb9X8KLaQobDJwGpy5OQecRCtnR25hmQvItRVrd5eAiEAiZuxTL55XbQM9ExbSkxjsmKyjULem3joEnarbQzMgC0="}]},"_npmUser":{"name":"artem_kuprin","email":"artem.kx@proton.me"},"directories":{},"maintainers":[{"name":"artem_kuprin","email":"artem.kx@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/opencode-toolcost_1.0.1_1780989910700_0.3978982316038937"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T10:18:19.592Z","modified":"2026-06-09T07:25:11.009Z","1.0.0":"2026-05-14T10:18:19.886Z","1.0.1":"2026-06-09T07:25:10.837Z"},"bugs":{"url":"https://github.com/ArtemKx1/opencode-toolcost/issues"},"author":{"name":"Artem K.","email":"artem.kx@proton.me","url":"https://github.com/ArtemKx1"},"license":"MIT","homepage":"https://github.com/ArtemKx1/opencode-toolcost#readme","keywords":["opencode","opencode-plugin","plugin","token-usage","cost-tracking","tool-cost","sidebar","cost"],"repository":{"type":"git","url":"git+https://github.com/ArtemKx1/opencode-toolcost.git"},"description":"See exactly how much each tool (read, edit, bash, grep, task) is costing you — live per-tool breakdown in the OpenCode TUI sidebar","maintainers":[{"name":"artem_kuprin","email":"artem.kx@proton.me"}],"readme":"<div align=\"center\">\n\n# 💰 opencode-toolcost\n\n### See exactly how much each tool is costing you — live in the OpenCode TUI sidebar\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![npm version](https://img.shields.io/npm/v/@artem-kuprin/opencode-toolcost)](https://www.npmjs.com/package/@artem-kuprin/opencode-toolcost)\n[![OpenCode plugin](https://img.shields.io/badge/OpenCode-plugin-blue)](https://opencode.ai)\n\n</div>\n\n---\n\n## ⚡ Quick Start\n\n```bash\nnpm install -g @artem-kuprin/opencode-toolcost\n```\n\nThen add `\"@artem-kuprin/opencode-toolcost\"` to the `plugin` array in your `opencode.json` and `tui.json`, then restart OpenCode.\n\n---\n\n## ✨ Why opencode-toolcost?\n\nOther cost trackers show you the **total bill**. This one tells you **what exactly you're paying for**:\n\n> Is `read` eating your budget? Is `edit` more expensive than `bash`? Is `task` running away with your tokens?\n\n**opencode-toolcost** breaks down every dollar by tool — live, in your sidebar, while you work. No guesswork, no math.\n\n| Compared to | opencode-toolcost |\n|---|---|\n| Generic cost dashboards | ❌ Show total only | ✅ **Per-tool breakdown** |\n| Manual log analysis | ❌ Retrospective | ✅ **Live in TUI sidebar** |\n| Built-in OpenCode stats | ❌ No per-tool view | ✅ **Granular attribution** |\n\n---\n\n## 🚀 Features\n\n- **📊 Live TUI sidebar** — top 5 costliest tools with visual bars, updated automatically\n- **🎯 Per-tool attribution** — knows exactly which tool caused each step's cost\n- **💬 `/toolcost` command** — saves a detailed text report to `toolcost-output.txt`\n- **🔄 Auto-refresh** — panel updates as new messages arrive, no manual reload\n- **🆓 Works with any model/provider** — reads cost from API metadata, falls back to built-in pricing table\n\n---\n\n## 📦 Install\n\n### Prerequisites\n\n- **Node.js** >= 18\n- **npm** (comes with Node.js)\n- **OpenCode** >= 1.2.15\n\n### Step 1 — Install the package\n\n```bash\nnpm install -g @artem-kuprin/opencode-toolcost\n```\n\n> Or install locally in your project: `npm install @artem-kuprin/opencode-toolcost`\n\n### Step 2 — Configure\n\nAdd the plugin to OpenCode config files. Server plugins go in `opencode.json`, TUI plugins in `tui.json`:\n\n**`opencode.json`** (server plugin — enables `/toolcost` command & cost tracking):\n```json\n{\n  \"plugin\": [\"@artem-kuprin/opencode-toolcost\"]\n}\n```\n\n**`tui.json`** (TUI plugin — enables the live sidebar panel):\n```json\n{\n  \"plugin\": [\"@artem-kuprin/opencode-toolcost\"]\n}\n```\n\n### Step 3 — Restart\n\nRestart OpenCode. You should see the `TOOL COST` block in the sidebar and be able to use `/toolcost` in chat.\n\n### Verify it works\n\nIn any conversation, run `/toolcost`. If the plugin is loaded, a detailed report will be saved to `toolcost-output.txt`. You'll also see the `TOOL COST` sidebar panel during active LLM sessions.\n\n---\n\n## 🎮 Usage\n\nThe TUI sidebar will show a `TOOL COST` block during active sessions. Before any tool calls, it shows:\n\n```\nTOOL COST\n  waiting for tool calls...\n```\n\nOnce the LLM starts calling tools, it switches to the live breakdown:\n\n```\nTOOL COST\n  edit     ████████████ $0.0123\n  read     ████████     $0.0081\n  bash     ██████       $0.0060\n  grep     ████         $0.0042\n  task     ██           $0.0021\n  ────────────────────\n  Total                $0.0327\n  12 steps\n```\n\nFor a detailed report, run `/toolcost` in chat. The report is saved to `toolcost-output.txt`.\n\n---\n\n## ⚙️ How It Works\n\n1. Each LLM step emits a `step-finish` part with `tokens` and `cost` metadata\n2. All tool calls in that message are collected\n3. Output tokens are **split equally** across the tools called in that step\n4. Cost is attributed using the same split\n5. Results accumulate across the entire session\n\n---\n\n## 📐 What The Sidebar Shows\n\n| Block | Description |\n|---|---|\n| **Top 5 tools** | Costliest tools ranked, others grouped as \"other\" |\n| **Visual bar** | Proportional to tool's cost share |\n| **Total cost** | Cumulative session cost |\n| **Step count** | Number of LLM steps processed |\n\n---\n\n<div align=\"center\">\n\nCreated with ❤️ by [Artem K.](https://github.com/ArtemKx1)\n\n**Feedback? Ideas?** [Open an issue](https://github.com/ArtemKx1/opencode-toolcost/issues)\n\n</div>\n\n## License\n\nMIT\n","readmeFilename":"README.md"}