Skip to content

feat: support cc-mirror — auto-discover isolated Claude Code variants under ~/.cc-mirror/ #610

@sultanfariz

Description

@sultanfariz

Summary

cc-mirror creates isolated Claude Code instances with custom providers (Z.ai, Kimi, OpenRouter, etc.), each storing session data under its own config dir — completely separate from ~/.claude/. All cc-mirror usage is currently invisible to Tokscale.

What exists locally

~/.cc-mirror/
├── <variant>/
│   ├── variant.json          ← name, provider, baseUrl, configDir
│   └── config/
│       └── projects/         ← session .jsonl files
└── .cache/

variant.json example:

{
  "name": "zaicc",
  "provider": "zai",
  "baseUrl": "https://api.z.ai/api/anthropic",
  "configDir": "/Users/.../.cc-mirror/zaicc/config"
}

Session .jsonl files under <configDir>/projects/ are identical in schema to ~/.claude/projects/ — full token fields present and verified:

"usage":{"input_tokens":15945,"cache_creation_input_tokens":0,"cache_read_input_tokens":11584,"output_tokens":84,...}

Why it's straightforward

Discovery is deterministic:

  1. Glob ~/.cc-mirror/*/variant.json
  2. Read configDir from each
  3. Run the existing Claude Code JSONL parser on <configDir>/projects/
  4. Tag usage with provider + name from variant.json

No new parser needed — just path remapping with provider attribution.

Proposed v1 scope

  • Auto-discover variants via ~/.cc-mirror/*/variant.json on startup
  • Reuse Claude Code parser on each variant's configDir
  • Report each variant as a distinct row (e.g. cc-mirror/zaicc) since providers have different pricing
  • Show discovered variants in tokscale clients diagnostics

Complication: model name aliasing

cc-mirror sessions use provider-specific model aliases ("glm-5.1", "opus", "sonnet") rather than canonical Claude model IDs. Cost attribution via LiteLLM/OpenRouter may need the provider + baseUrl from variant.json to resolve pricing correctly, especially for non-Anthropic providers like Z.ai.

Non-goals for v1

  • No deduplication with ~/.claude/ (no overlap — fully isolated config dirs)
  • No parsing of cc-mirror theme/prompt-pack config
  • No support for arbitrary CLAUDE_CONFIG_DIR overrides outside ~/.cc-mirror/

Open questions

  • Should each variant be a distinct client or sub-rows under a cc-mirror parent?
  • When baseUrl is OpenRouter-compatible, can the existing OpenRouter pricing fallback apply?

Context

Verified on macOS against an active zaicc (Z.ai) variant. cc-mirror is commonly used by developers running alternative providers alongside their primary ~/.claude/ setup — a non-trivial slice of Claude Code users whose usage Tokscale currently cannot see at all.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions