{"_id":"@descope-int/claude-code-plugin-detoken","_rev":"5-5177660922c90f361661284369f77145","name":"@descope-int/claude-code-plugin-detoken","dist-tags":{"latest":"0.12.1"},"versions":{"0.9.2":{"name":"@descope-int/claude-code-plugin-detoken","version":"0.9.2","keywords":["claude-code","claude-code-plugin","analytics","observability","token-optimization"],"author":{"name":"Descope Engineering"},"license":"MIT","_id":"@descope-int/claude-code-plugin-detoken@0.9.2","maintainers":[{"name":"tom-descope","email":"tom@descope.com"},{"name":"omercnet","email":"npm@omerc.dev"},{"name":"nirgur","email":"nir@descope.com"}],"homepage":"https://github.com/descope/claude-config/tree/main/plugins/detoken","bugs":{"url":"https://github.com/descope/claude-config/issues"},"dist":{"shasum":"c5d610ca594a2207baad119942a322d2f555d43a","tarball":"https://registry.npmjs.org/@descope-int/claude-code-plugin-detoken/-/claude-code-plugin-detoken-0.9.2.tgz","fileCount":10,"integrity":"sha512-RBROkrPGtzU8sSw/203icEF2HrcVw3m4yVhtmx/dSKjc4rtYX80SgPBP181oTGTE7vQMrxgX230XPEdl2F1Prg==","signatures":[{"sig":"MEUCIFpAJ2/kqSwL8R0SHDHR13be3m26Op5gr9t4nTcnvEHbAiEApC1jSun8CopoLROEtLAqsRLgkHxFW2Gna9O25lujfaM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69034},"private":false,"scripts":{"prepublishOnly":"node ../../scripts/check-plugin-release.mjs detoken"},"_npmUser":{"name":"omercnet","email":"npm@omerc.dev"},"repository":{"url":"git+https://github.com/descope/claude-config.git","type":"git","directory":"plugins/detoken"},"_npmVersion":"11.16.0","description":"Privacy-safe Claude Code usage analytics and token-cost optimization.","directories":{},"_nodeVersion":"24.18.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/claude-code-plugin-detoken_0.9.2_1784036967049_0.9249684325159198","host":"s3://npm-registry-packages-npm-production"}},"0.10.0":{"name":"@descope-int/claude-code-plugin-detoken","version":"0.10.0","keywords":["claude-code","claude-code-plugin","analytics","observability","token-optimization"],"author":{"name":"Descope Engineering"},"license":"MIT","_id":"@descope-int/claude-code-plugin-detoken@0.10.0","maintainers":[{"name":"tom-descope","email":"tom@descope.com"},{"name":"omercnet","email":"npm@omerc.dev"},{"name":"nirgur","email":"nir@descope.com"}],"homepage":"https://github.com/descope/claude-config/tree/main/plugins/detoken","bugs":{"url":"https://github.com/descope/claude-config/issues"},"dist":{"shasum":"63ecc4e55e45821d3904a4c422dc2e24b5cbcc3f","tarball":"https://registry.npmjs.org/@descope-int/claude-code-plugin-detoken/-/claude-code-plugin-detoken-0.10.0.tgz","fileCount":10,"integrity":"sha512-Oz+PTp2+CUEjUsNuiPfYL7QE/nSu70wrpuHjOK3wcWKaJB2L7F5fsIkNbJ83MrR2t0bwaHIk6S6pswPNUO/30Q==","signatures":[{"sig":"MEUCIQCEn7vx1zV/U6vaKfYYcqaxY90vxbMghzXaEeXc9GyiJwIgBSvlgKYPB1M7llg7G/pnKH1JRbA4jYDferOeCveQ1Go=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69036},"_from":"file:npm-packages/descope-int-claude-code-plugin-detoken-0.10.0.tgz","private":false,"scripts":{"prepublishOnly":"node ../../scripts/check-plugin-release.mjs detoken"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c1a0468a-74df-44c3-95c7-75e44db24ff3"}},"_resolved":"/home/runner/work/claude-config/claude-config/npm-packages/descope-int-claude-code-plugin-detoken-0.10.0.tgz","_integrity":"sha512-Oz+PTp2+CUEjUsNuiPfYL7QE/nSu70wrpuHjOK3wcWKaJB2L7F5fsIkNbJ83MrR2t0bwaHIk6S6pswPNUO/30Q==","repository":{"url":"git+https://github.com/descope/claude-config.git","type":"git","directory":"plugins/detoken"},"_npmVersion":"11.16.0","description":"Privacy-safe Claude Code usage analytics and token-cost optimization.","directories":{},"_nodeVersion":"24.18.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/claude-code-plugin-detoken_0.10.0_1785150245337_0.4466418228667477","host":"s3://npm-registry-packages-npm-production"}},"0.11.0":{"name":"@descope-int/claude-code-plugin-detoken","version":"0.11.0","keywords":["claude-code","claude-code-plugin","analytics","observability","token-optimization"],"author":{"name":"Descope Engineering"},"license":"MIT","_id":"@descope-int/claude-code-plugin-detoken@0.11.0","maintainers":[{"name":"tom-descope","email":"tom@descope.com"},{"name":"omercnet","email":"npm@omerc.dev"},{"name":"nirgur","email":"nir@descope.com"}],"homepage":"https://github.com/descope/claude-config/tree/main/plugins/detoken","bugs":{"url":"https://github.com/descope/claude-config/issues"},"dist":{"shasum":"b2ed88c28acd06d5a2b80c6d221239a0fc722f7a","tarball":"https://registry.npmjs.org/@descope-int/claude-code-plugin-detoken/-/claude-code-plugin-detoken-0.11.0.tgz","fileCount":10,"integrity":"sha512-NXIQtUAwYSELgRihVlw12sSvjK2zL5Zrt19oCgPag3xF9MTmdnQQyXfysyNqLESJCkVrtGnWG9ObDkEueRT68A==","signatures":[{"sig":"MEYCIQCCV2CIyxiZ1HP0eI84Gb/5nL42QsBNkfozkVnu7lA8LQIhAMhSUrsS7AViaF53nD4sfLNxUGxrZFH6H3/BI77ZR351","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69735},"_from":"file:npm-packages/descope-int-claude-code-plugin-detoken-0.11.0.tgz","private":false,"scripts":{"prepublishOnly":"node ../../scripts/check-plugin-release.mjs detoken"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c1a0468a-74df-44c3-95c7-75e44db24ff3"}},"_resolved":"/home/runner/work/claude-config/claude-config/npm-packages/descope-int-claude-code-plugin-detoken-0.11.0.tgz","_integrity":"sha512-NXIQtUAwYSELgRihVlw12sSvjK2zL5Zrt19oCgPag3xF9MTmdnQQyXfysyNqLESJCkVrtGnWG9ObDkEueRT68A==","repository":{"url":"git+https://github.com/descope/claude-config.git","type":"git","directory":"plugins/detoken"},"_npmVersion":"11.17.0","description":"Privacy-safe Claude Code usage analytics and token-cost optimization.","directories":{},"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/claude-code-plugin-detoken_0.11.0_1786711492144_0.5089222575894383","host":"s3://npm-registry-packages-npm-production"}},"0.12.0":{"name":"@descope-int/claude-code-plugin-detoken","version":"0.12.0","keywords":["claude-code","claude-code-plugin","analytics","observability","token-optimization"],"author":{"name":"Descope Engineering"},"license":"MIT","_id":"@descope-int/claude-code-plugin-detoken@0.12.0","maintainers":[{"name":"tom-descope","email":"tom@descope.com"},{"name":"omercnet","email":"npm@omerc.dev"},{"name":"nirgur","email":"nir@descope.com"}],"homepage":"https://github.com/descope/claude-config/tree/main/plugins/detoken","bugs":{"url":"https://github.com/descope/claude-config/issues"},"omp":{"extensions":["./extensions/omp.mjs"]},"dist":{"shasum":"e8528906cdb37da5436e6df1aaa9e506ae248b8f","tarball":"https://registry.npmjs.org/@descope-int/claude-code-plugin-detoken/-/claude-code-plugin-detoken-0.12.0.tgz","fileCount":11,"integrity":"sha512-pWvNmz3LQbIHbQAMuz7m+KC81NWLdSzOqOEJ4Dc2ggn1LosW1zH1a3wfGWQe32I8wEtYfddNeP+OMFo3VJu7pg==","signatures":[{"sig":"MEQCIGi2fUbNrDFZ2+nTJnQ2SLxPCI9fn+Y6AMZzQ5eCgYdzAiBlC2/06XpxO6XU5OTHF3V5F06xyu49kxTExN7htfAJvw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":75626},"_from":"file:npm-packages/descope-int-claude-code-plugin-detoken-0.12.0.tgz","private":false,"scripts":{"prepublishOnly":"node ../../scripts/check-plugin-release.mjs detoken"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c1a0468a-74df-44c3-95c7-75e44db24ff3"}},"_resolved":"/home/runner/work/claude-config/claude-config/npm-packages/descope-int-claude-code-plugin-detoken-0.12.0.tgz","_integrity":"sha512-pWvNmz3LQbIHbQAMuz7m+KC81NWLdSzOqOEJ4Dc2ggn1LosW1zH1a3wfGWQe32I8wEtYfddNeP+OMFo3VJu7pg==","repository":{"url":"git+https://github.com/descope/claude-config.git","type":"git","directory":"plugins/detoken"},"_npmVersion":"11.17.0","description":"Privacy-safe Claude Code usage analytics and token-cost optimization.","directories":{},"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/claude-code-plugin-detoken_0.12.0_1788183513870_0.41613531520810176","host":"s3://npm-registry-packages-npm-production"}},"0.12.1":{"name":"@descope-int/claude-code-plugin-detoken","version":"0.12.1","description":"Privacy-safe Claude Code usage analytics and token-cost optimization.","private":false,"license":"MIT","author":{"name":"Descope Engineering"},"homepage":"https://github.com/descope/claude-config/tree/main/plugins/detoken","repository":{"type":"git","url":"git+https://github.com/descope/claude-config.git","directory":"plugins/detoken"},"bugs":{"url":"https://github.com/descope/claude-config/issues"},"keywords":["claude-code","claude-code-plugin","analytics","observability","token-optimization"],"omp":{"extensions":["./extensions/omp.mjs"]},"scripts":{"prepublishOnly":"node ../../scripts/check-plugin-release.mjs detoken"},"publishConfig":{"access":"public"},"_id":"@descope-int/claude-code-plugin-detoken@0.12.1","_integrity":"sha512-1fGDHwuCpKaSS4fzm1gRa/8RbGDcliCQ0h6HgVV4vQtmzdFyl0gXfxW7afhcQZN3862aGHgDRH0Rk/JMdippcQ==","_resolved":"/home/runner/work/claude-config/claude-config/npm-packages/descope-int-claude-code-plugin-detoken-0.12.1.tgz","_from":"file:npm-packages/descope-int-claude-code-plugin-detoken-0.12.1.tgz","_nodeVersion":"24.20.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-1fGDHwuCpKaSS4fzm1gRa/8RbGDcliCQ0h6HgVV4vQtmzdFyl0gXfxW7afhcQZN3862aGHgDRH0Rk/JMdippcQ==","shasum":"a1fb52960c386f0fbca4a3a953b7db4ad7f6907e","tarball":"https://registry.npmjs.org/@descope-int/claude-code-plugin-detoken/-/claude-code-plugin-detoken-0.12.1.tgz","fileCount":11,"unpackedSize":75626,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDqiEYwA/6r4zjDakmgZbDqjp3mLlMYyX4FG99sy6epeAIgG1hD/rwArb5jLN+2ysWWTXVIZxpGckmhVdnku1XlQ0Y="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c1a0468a-74df-44c3-95c7-75e44db24ff3"}},"directories":{},"maintainers":[{"name":"tom-descope","email":"tom@descope.com"},{"name":"omercnet","email":"npm@omerc.dev"},{"name":"nirgur","email":"nir@descope.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/claude-code-plugin-detoken_0.12.1_1788900120446_0.1970250615389193"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-14T13:49:26.892Z","modified":"2026-09-08T20:42:00.712Z","0.9.2":"2026-07-14T13:49:27.185Z","0.10.0":"2026-07-27T11:04:05.479Z","0.11.0":"2026-08-14T12:44:52.282Z","0.12.0":"2026-08-31T13:38:34.084Z","0.12.1":"2026-09-08T20:42:00.567Z"},"bugs":{"url":"https://github.com/descope/claude-config/issues"},"author":{"name":"Descope Engineering"},"license":"MIT","homepage":"https://github.com/descope/claude-config/tree/main/plugins/detoken","keywords":["claude-code","claude-code-plugin","analytics","observability","token-optimization"],"repository":{"type":"git","url":"git+https://github.com/descope/claude-config.git","directory":"plugins/detoken"},"description":"Privacy-safe Claude Code usage analytics and token-cost optimization.","maintainers":[{"name":"tom-descope","email":"tom@descope.com"},{"name":"omercnet","email":"npm@omerc.dev"},{"name":"nirgur","email":"nir@descope.com"}],"readme":"# detoken\n\n**See where your Claude Code tokens go.** A Claude Code plugin + backend that\nanalyzes how your team uses Claude Code — all from local session transcripts,\nwith only aggregate metrics ever leaving the machine.\n\n```\nplugins/detoken/\n├── (plugin)    # hooks, the usage-analysis skill, the usage-analyst agent, and the uo.py engine\n└── backend/    # Node/TypeScript ingest + dashboard service (Hono, Descope auth)\n```\n\n## The idea\n\n1. **Measure** — the plugin parses local session transcripts into privacy-safe\n   metrics (tokens, cost, tool/model mix, cache efficiency) and classifies each\n   session: `feature-dev`, `debugging`, `troubleshooting`, `wasting-tokens`,\n   `exploration`. Classification happens **client-side**; only the label + numbers\n   leave the machine.\n2. **Report** — on each turn end (throttled) and session end, a hook POSTs the\n   report to the backend, which stores per-session rows and serves a dashboard of\n   cost by user and by classification.\n\n## What it does\n\n**Analysis & reporting (no commands — just ask)**\n- Ask in plain language — \"how much have I spent on Claude Code this week?\",\n  \"which sessions wasted tokens?\" — and the `usage-analyst` agent parses your\n  local transcripts off to the side and returns cost/token/tool/model breakdowns\n  with a classification per session.\n\n**Hooks (automatic)**\n\n| Hook | Event | Behavior |\n|------|-------|----------|\n| `session-greeting` | SessionStart | Surfaces the previous session's spend for visibility. |\n| `report` | Stop / SessionEnd | Flushes privacy-safe metrics + classification to the backend (throttled). |\n\n## Install\n\n```bash\nclaude plugin marketplace add descope/claude-config\nclaude plugin install detoken@descope-dev-internal\n```\n\nFor local iteration: `claude --plugin-dir /path/to/plugins/detoken`.\n\nFor Oh My Pi, install the npm package directly and restart OMP so its extension\nand bundled capabilities are discovered:\n\n```bash\nomp plugin install @descope-int/claude-code-plugin-detoken\n```\n\nOMP uses the same `usage-analysis` skill and `usage-analyst` agent. Automatic\nreporting is wired through the package's OMP extension rather than Claude's\n`hooks/hooks.json`.\n\n## Configure (optional)\n\nLocal analysis works out of the box. Backend reporting is enabled only for approved\ninstalls that receive `DETOKEN_INGEST_SECRET` through their managed environment;\nthe token is never shipped in this open-source plugin. Create a config file only\nto override another default (point at a different backend or turn something off):\n\n```bash\ncp detoken.local.md.example ~/.claude/detoken.local.md\n# e.g. change backend_url or set enabled: false\n```\n\nConfig is read from `<project>/.claude/detoken.local.md` then\n`~/.claude/detoken.local.md` (project overrides global). `backend_url` can also\ncome from `DETOKEN_BACKEND_URL`. Distributors should inject the required bearer\ntoken as `DETOKEN_INGEST_SECRET`, never commit it to a config file.\n\n> Hooks load at session start — restart Claude Code after changing config.\n\n## The engine\n\nAll logic lives in `scripts/uo.py` (Python stdlib only — no pip installs). Useful directly:\n\n```bash\npython3 scripts/uo.py metrics  <transcript.jsonl>   # privacy-safe usage metrics\npython3 scripts/uo.py classify <transcript.jsonl>   # session classification\npython3 scripts/uo.py config   [key]                # resolved configuration\n```\n\n## Backend\n\nThe ingest + dashboard service lives in `backend/` (Hono + libSQL/Turso, deploys\nto Vercel). See `backend/README.md`. For local dev:\n\n```bash\ncd backend && npm install\nINGEST_SHARED_SECRET=local-dev-token AUTH_DISABLED=true npm run dev\n```\n\nTo see your data locally instead of the team backend, point the plugin at the\nlocal server — set `backend_url: \"http://localhost:8787\"` in\n`~/.claude/detoken.local.md` (or `DETOKEN_BACKEND_URL=http://localhost:8787`) and\nset `DETOKEN_INGEST_SECRET=local-dev-token` for the plugin process.\n\n## RTK integration\n\n[RTK (Rust Token Killer)](https://github.com/mksglu/rtk) is a separately-installed\nCLI that compresses prompts before they reach Claude. detoken is the **measurement\nlayer** on top of it: it detects whether RTK is active, can optionally wire it into\nyour global config, and reports RTK's token-savings to the backend so the dashboard\nshows fleet-wide savings and rollout coverage. detoken does not install or duplicate\nRTK.\n\n**What detoken does with RTK**\n\n- Checks whether RTK is installed and wired (`rtk init -g` has been run).\n- On each Stop/SessionEnd report, sends a privacy-safe `rtk` block: saved-token\n  totals, command count, active flag, and RTK version. No command text or project\n  paths leave the machine.\n- The backend aggregates these into fleet-wide totals visible on the dashboard\n  (an \"RTK savings\" card and a coverage indicator showing what fraction of sessions\n  have RTK active).\n\n**Privacy guarantee**\n\nOnly aggregates leave the machine: saved-token totals, command counts, the active\nflag, and the RTK version string. The gain DB is read **read-only**. No command\ntext, no project paths, no file contents.\n\n**Config keys**\n\n| Key | Default | What it does |\n|-----|---------|--------------|\n| `rtk_enabled` | `true` | Master toggle for the RTK health-check and gain reporting. Set `false` to skip RTK entirely. |\n| `rtk_db_path` | `\"\"` | Override the path to RTK's `history.db`. Empty = auto-detect: config value, then `RTK_DB_PATH` env, then the macOS default `~/Library/Application Support/rtk/history.db`. |\n| `rtk_auto_init` | `true` | Run `rtk init -g` at SessionStart when RTK is installed but not yet wired. No-op when RTK is already active (no duplicate init). Set `false` to only surface a hint instead. |\n\n**Consent and the next-session caveat**\n\n`rtk_auto_init` defaults to `true`. detoken runs `rtk init -g` at SessionStart only\nwhen RTK is installed but not yet wired; it is a no-op when RTK is already active\n(so it never double-inits), and `rtk init -g` is itself idempotent. The wiring takes\neffect the **next** session (Claude Code reads the wired config at startup). Set\n`rtk_auto_init: false` to suppress auto-init and only show a one-line hint.\n\n## context-mode integration\n\n[context-mode](https://github.com/mksglu/context-mode) keeps large tool outputs,\nlogs, files, and docs out of Claude's active context while preserving searchable\nrecall. detoken reports context-mode savings the same way it reports RTK savings:\non each Stop/SessionEnd report it reads the current project's context-mode SQLite\nsession DB **read-only**, sends only aggregate deltas, and advances a local\nper-project watermark only after a confirmed backend accept.\n\n**What detoken reports**\n\n- A privacy-safe `context_mode` block with active flag, version string, raw\n  `bytes_avoided` totals, and command/event count.\n- The **active flag is a deployment signal** — the analog of RTK's \"wired\" — true\n  when context-mode is installed on the machine **or** has recorded activity (which\n  proves it's present even when install-detection misses an editor-plugin install).\n  This keeps the dashboard's context-mode rollout coverage comparable to RTK's, so a\n  fresh project on a context-mode machine is not under-counted. Actual impact is the\n  saved-tokens / operations cards, not this flag.\n- The plugin sends raw `bytes_avoided`; the **backend** converts it to tokens\n  (`bytes_avoided // 4`), so the conversion constant lives in one auditable place.\n- No project paths, event payloads, file contents, prompts, or raw command data\n  leave the machine.\n\n**Config keys**\n\n| Key | Default | What it does |\n|-----|---------|--------------|\n| `ctx_enabled` | `true` | Master toggle for context-mode health-check and savings reporting. Set `false` to skip context-mode entirely. |\n| `ctx_db_path` | `\"\"` | Override context-mode's sessions directory or a specific project `.db`. Empty = auto-detect: `DETOKEN_CTX_DB_PATH`, `CONTEXT_MODE_DIR/sessions`, `~/.config/opencode/context-mode/sessions`, then `~/.claude/context-mode/sessions`. |\n\n## Design notes\n\n- **Privacy first.** No prompt/response text is ever stored or transmitted — only\n  counts, token totals, tool/model names, timestamps, a classification label, the\n  plugin's own version (`client_version`, for upgrade-rollout monitoring), and\n  a `user_label` (Claude account email / git / OS user, configurable) for per-user\n  attribution. Reports carry a hashed cwd, never the path.\n- **Never breaks a session.** Every hook is a silent no-op when the plugin is\n  disabled, misconfigured, or missing `python3`, and always exits 0.\n- **Dependency-free engine.** All client logic lives in `scripts/uo.py` (Python\n  stdlib only — no pip installs).\n\n## Requirements\n\n- `python3` (stdlib only).\n\n## Acknowledgements\n\nThe privacy-safe, low-overhead usage-analytics approach is informed by\n[mksglu/context-mode](https://github.com/mksglu/context-mode).\n","readmeFilename":"README.md"}