Skip to content

Add support for Kimi Code, ZCode/GLM, Pi/SPI, and Reasonix/DeepSeek#1

Open
Theoz001 wants to merge 1 commit into
Backtthefuture:mainfrom
Theoz001:add-more-agents
Open

Add support for Kimi Code, ZCode/GLM, Pi/SPI, and Reasonix/DeepSeek#1
Theoz001 wants to merge 1 commit into
Backtthefuture:mainfrom
Theoz001:add-more-agents

Conversation

@Theoz001

Copy link
Copy Markdown

Summary

This PR adds local token usage tracking for four additional AI coding agents that write usage metadata to local files:

  • Kimi Code — reads "usage.record" events from the Daimon runtime wire logs.
  • ZCode / GLM — reads the "model_usage" table in the local SQLite database.
  • Pi / SPI — reads usage fields from assistant messages in session JSONL files.
  • Reasonix / DeepSeek — reads usage from "model.final" events in events JSONL files.

Data sources

Agent Local source
Kimi Code "~/Library/Application Support/kimi-desktop/daimon-share/daimon/runtime/kimi-code/home/sessions/**/agents/main/wire.jsonl"
ZCode / GLM "~/.zcode/cli/db/db.sqlite" (model_usage table)
Pi / SPI "~/.pi/agent/sessions/**/*.jsonl"
Reasonix / DeepSeek "/.reasonix/sessions/*.events.jsonl" and "/.reasonix/projects/**/*.events.jsonl"

All new collectors only read numeric usage metadata. They do not read prompts, code, tool outputs, or conversation text.

Changes

  • "token_usage_monitor.py": adds "collect_kimi_code()", "collect_zcode()", "collect_pi()", "collect_reasonix()"; updates "collect_all()" and the dashboard HTML rendering to be tool-agnostic.
  • "TokenStepSwift/Sources/TokenStepSwift/Services/UsageCollector.swift": adds native Swift equivalents of the four collectors.
  • "TokenStepSwift/Sources/TokenStepSwift/Views/Components.swift": adds tool colors and ordering for the new agents.
  • "config/pricing.json": adds rough local cost estimates for the new tools and models.
  • "docs/AGENT_SUPPORT.md": updates the supported-agent table.

Privacy

The new collectors follow the existing local-first principle: they read only timestamp/model/usage fields from local logs and do not upload anything.

Testing

  • Built and ran the Swift app successfully on macOS 14+.
  • Verified that the Python collector generates "dashboard.html" with all six tools.
  • Verified that the native Swift collector writes "~/Library/Application Support/TokenStep/data/usage.json" with entries for the new agents.

Notes

  • Field-name aliases in both Python and Swift normalizers were extended so the new usage formats map cleanly to the canonical token counts.
  • ZCode logs contain usage fields but the values are redacted as "[Redacted]"; this PR reads the SQLite table instead, which contains the real numbers.

@Backtthefuture

Copy link
Copy Markdown
Owner

Thanks for the PR. The direction is useful, especially adding more local collectors for Kimi Code, ZCode/GLM, Pi/SPI, and Reasonix/DeepSeek.

I reviewed the branch locally. I don’t think this is ready to merge yet because there are a few blocking regressions:

  1. The PR changes PopoverQuotaCard from the existing Agent quota card into a “today model usage” card. This is outside the scope of adding collectors, and it removes the current Codex / Claude quota display behind the showCodexQuota setting. Please either revert this UI change or move model usage into a separate card/setting.

  2. token_usage_monitor.py still scans .codex/archived_sessions. We recently fixed a serious over-counting issue caused by archived Codex sessions being re-counted as today’s usage, so this path should also exclude archived sessions.

  3. WorkBuddy is now collected by default in Swift, but the docs still list it as “待确认 / not confirmed”. Since we only want stable, verified local token sources in the main total, please either remove WorkBuddy from the default collector for now or add real validation samples/tests and update the docs.

  4. The fixture check currently fails on this branch:
    script/test_ccswitch_proxy_collector.sh
    It fails because the fixture still expects gpt-5.4, while the PR now canonicalizes it to GPT-5.4.

What I verified locally:

  • Python syntax check passed.
  • SwiftUI source compile passed, with one warning in PopoverQuotaCard.
  • script/test_ccswitch_proxy_collector.sh fails on this branch.
  • The same fixture passes on current main.

I’d be happy to review again after the quota-card change is split/reverted, archived Codex sessions are excluded from the Python collector, WorkBuddy’s status is resolved, and the fixture is fixed.

…Seek

Core changes:
- Swift UsageCollector now reads Kimi Code, ZCode, Pi, and Reasonix/DeepSeek
  native logs.
- canonicalModelName() normalizes model aliases (e.g. daimon-kimi-code ->
  Kimi 2.6, deepseek-v4-pro -> DeepSeek V4 Pro, gpt-5.4 -> GPT-5.4).
- Falls back to session_meta.model_provider when Codex JSONL turn_context
  lacks a model name, reducing unknown-model entries.
- Aggregates usage per canonical model across clients in StatsView and keeps
  a per-tool/per-model breakdown in DailyUsage.toolModels for deep dives.
- Adds UI colors and ordering for the new agents.
- Updates pricing.json with new model tiers.
- Python token_usage_monitor.py now supports the same agents and excludes
  archived Codex sessions from scanning.
- Fixes CCSwitchProxy fixture assertion for canonicalized GPT-5.4 model name.

WorkBuddy and the popover daily-model card are left out of this branch;
they remain in add-more-agents-ui for separate review.
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.

2 participants