Fix client filter flag for tokscale v4 compatibility - #3
Merged
Conversation
tokscale v4.0.0 removed deprecated per-client boolean flags (--opencode, --claude, etc.) in favor of the unified -c/--client flag (PR #465). Since this plugin defaults showOpenCodeOnly to true, every CLI call included --opencode, which v4+ rejects as an unexpected argument. All three period stats (today, week, month) failed silently and rendered "err" in the sidebar. Replace --opencode with -c opencode and update the corresponding test assertion.
tokscale v4.0.0 replaced per-client boolean flags (--opencode) with the unified -c/--client flag. Since opencode auto-updates this plugin faster than users update the tokscale binary, both flag styles need to work. detectTokscale() now runs tokscale --version after the install check and caches the parsed semver. fetchPeriodStats() uses -c opencode on v4.0.0+ and falls back to --opencode on older versions or when the version is unknown. parseVersion() and versionAtLeast() are exported as general utilities for any future version-gated behavior.
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.
Summary
tokscale v4.0.0 (PR #465) removed deprecated per-client boolean flags (
--opencode,--claude,--cursor, etc.) in favor of the unified-c/--clientflag.Since this plugin defaults
showOpenCodeOnlytotrue, every CLI call included--opencode, which v4+ rejects as an unexpected argument:All three period stats (today, week, month) failed and rendered
errin the sidebar.Changes
src/tokscale.ts— Replace--opencodewith-c opencodesrc/__tests__/tokscale.test.ts— Update test assertion to matchTesting
npx vitest run— 30/30 tests passingnpx tsc --noEmit— cleantokscale models --json --today --no-spinner -c opencodereturns valid JSON