Skip to content

Fix client filter flag for tokscale v4 compatibility - #3

Merged
stevejkang merged 2 commits into
mainfrom
fix/tokscale-v4-client-flag
Jun 29, 2026
Merged

Fix client filter flag for tokscale v4 compatibility#3
stevejkang merged 2 commits into
mainfrom
fix/tokscale-v4-client-flag

Conversation

@stevejkang

Copy link
Copy Markdown
Owner

Summary

tokscale v4.0.0 (PR #465) removed deprecated per-client boolean flags (--opencode, --claude, --cursor, etc.) in favor of the unified -c/--client flag.

Since this plugin defaults showOpenCodeOnly to true, every CLI call included --opencode, which v4+ rejects as an unexpected argument:

error: unexpected argument '--opencode' found

All three period stats (today, week, month) failed and rendered err in the sidebar.

Changes

  • src/tokscale.ts — Replace --opencode with -c opencode
  • src/__tests__/tokscale.test.ts — Update test assertion to match

Testing

  • npx vitest run — 30/30 tests passing
  • npx tsc --noEmit — clean
  • Manual CLI verification: tokscale models --json --today --no-spinner -c opencode returns valid JSON

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.
@stevejkang
stevejkang merged commit 0ab4bfd into main Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant