Repository navigation
Conversation
Standard plugin (no UI surfaces). Unifies billion-context's incremental reversible compression with dsh-token-optimizer's output triage, dedup and monitoring into one layered plugin: automatic ledger via PostToolUse hooks, reversible /digest vault, /compress summaries anchoring built-in compaction, /context-search recovery, /token-status statistics with GLM-aware (CJK) token estimation and flash/balanced/max profiles. v0.2.2, MIT, zero-dependency Node. Includes original generated icon (assets/tokencare) with provenance record.
Collaborator
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin type
ui.surfacesor_meta.ui.resourceUri)Affected plugins:
tokencareProblem solved
Long ZCode sessions accumulate huge tool outputs, re-read unchanged files, and overflow context — inflating cost and degrading quality. TokenCare applies layered, reversible compression: nothing is lost, everything is recoverable from an on-disk vault.
It unifies the ideas of two prior projects with their overlapping parts merged (one ledger, one status surface, one compaction driver) instead of duplicated:
Behavior and components
PostToolUsehook records size/hash/path per tool result to a per-session JSONL ledger; outputs >30k chars get a one-line/digestnudge;SessionStart(compact)hook points at the vault after built-in compaction/digestspills originals verbatim to<project>/.zcode/tokencare/vault/and emits structure-aware digests (error → 300-char excerpt, JSON → shape summary, CSV → header+rows, text → head/tail); ledger detects unchanged duplicate reads/compresswrites a structured summary into the vault and anchors ZCode's built-in/compact(cooperates with, not replaces, host compaction)/context-searchgreps the vault;/token-statusreports per-tool token estimates, largest outputs, duplicate-read waste, vault totals, MCP-trim adviceGLM-aware token estimation (CJK ≈ 1 token/char, ASCII ≈ 4 chars/token) and tiered profiles (
TOKENCARE_PROFILE=flash|balanced|max, auto-detected fromTOKENCARE_MODEL/ZCODE_MODEL/ANTHROPIC_MODELor the hook payload): flash nudges at 20k chars / ~35–40% pressure, balanced 30k / ~45%, max 40k / ~55%.Testing
python scripts/validate.py: OK: 52 plugin(s) validated (includes tokencare).zcode commands list), hooks registered (hookCount: 2at startup), hook executed against the installed cache path with real Node and verified writing the ledger + nudge. No hook/plugin errors in logs.pnpm build/scripts/build_dist.pyfull pass on Windows — they fail pre-existing onexcalidraw(its bundler emits a Windows-invalid pathdist\ui\C:\...); verified identical failure on a pristine checkout. tokencare is not a compiled plugin (nopackage.json, skipped bybuild-plugins.mjs).Version
New plugin, first publication: 0.2.1 (manifest and marketplace entry match).
Dependencies, permissions, side effects
<project>/.zcode/tokencare/(ledger + vault, self-gitignored). No network access, no secrets, no machine-specific paths, no prebuilt artifacts.Licensing / provenance
MIT (LICENSE included). Original code, no third-party code copied. Design inspired by and credited to billion-context (MIT + attribution term — credited with link in README) and dsh-token-optimizer (MIT); both linked in README.md / README_CN.md. Bilingual READMEs included.