claudeshift-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claudeshift/__init__.py +3 -0
- claudeshift/cli.py +634 -0
- claudeshift/config/__init__.py +0 -0
- claudeshift/config/paths.py +73 -0
- claudeshift/core/__init__.py +0 -0
- claudeshift/core/inspector.py +113 -0
- claudeshift/core/models.py +98 -0
- claudeshift/core/vault.py +723 -0
- claudeshift/licensing/__init__.py +0 -0
- claudeshift/licensing/entitlements.py +60 -0
- claudeshift/licensing/gumroad.py +291 -0
- claudeshift/providers/__init__.py +0 -0
- claudeshift/providers/base.py +136 -0
- claudeshift/providers/plan_detector.py +249 -0
- claudeshift/telemetry/__init__.py +0 -0
- claudeshift/telemetry/analytics.py +200 -0
- claudeshift/telemetry/dashboard.py +157 -0
- claudeshift/telemetry/exporter.py +93 -0
- claudeshift/telemetry/parser.py +400 -0
- claudeshift/telemetry/pricing.py +362 -0
- claudeshift_cli-0.1.0.dist-info/METADATA +38 -0
- claudeshift_cli-0.1.0.dist-info/RECORD +26 -0
- claudeshift_cli-0.1.0.dist-info/WHEEL +5 -0
- claudeshift_cli-0.1.0.dist-info/entry_points.txt +3 -0
- claudeshift_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
- claudeshift_cli-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import math
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import urllib.error
|
|
8
|
+
import urllib.request
|
|
9
|
+
import uuid
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from datetime import datetime, timezone
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
LITELLM_PRICING_URL = (
|
|
15
|
+
"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True)
|
|
20
|
+
class ModelRate:
|
|
21
|
+
"""USD per 1,000,000 tokens."""
|
|
22
|
+
|
|
23
|
+
input_per_m: float
|
|
24
|
+
output_per_m: float
|
|
25
|
+
cache_write_per_m: float
|
|
26
|
+
cache_read_per_m: float
|
|
27
|
+
estimated: bool = False
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True)
|
|
31
|
+
class PlanQuota:
|
|
32
|
+
id: str
|
|
33
|
+
label: str
|
|
34
|
+
window_hours: int
|
|
35
|
+
window_cost_budget_usd: float
|
|
36
|
+
window_token_budget: int
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Ordered version-agnostic family + tier rules (most specific first).
|
|
40
|
+
# Handles minor/point releases automatically (e.g. gemini-3.1-pro, gemini-3.8-flash, claude-opus-5.5, gpt-6.2-mini).
|
|
41
|
+
MODEL_PATTERNS: tuple[tuple[re.Pattern[str], ModelRate], ...] = (
|
|
42
|
+
# --- Google Gemini 3.x family (3.0, 3.1, 3.5, 3.8, previews, etc.) ---
|
|
43
|
+
(re.compile(r"gemini-3(?:\.\d+)?(?:[-_.].*)?flash[-_.]?lite"), ModelRate(0.10, 0.40, 0.10, 0.025)),
|
|
44
|
+
(re.compile(r"gemini-3(?:\.\d+)?(?:[-_.].*)?flash"), ModelRate(0.30, 1.20, 0.30, 0.075)),
|
|
45
|
+
(re.compile(r"gemini-3(?:\.\d+)?(?:[-_.].*)?ultra"), ModelRate(5.00, 25.00, 5.00, 1.25)),
|
|
46
|
+
(re.compile(r"gemini-3(?:\.\d+)?(?:[-_.].*)?pro"), ModelRate(2.50, 15.00, 2.50, 0.625)),
|
|
47
|
+
(re.compile(r"gemini-3(?:\.\d+)?\b"), ModelRate(1.50, 10.00, 1.50, 0.375)),
|
|
48
|
+
# --- Google Gemini 2.5 family ---
|
|
49
|
+
(re.compile(r"gemini-2\.5(?:[-_.].*)?flash[-_.]?lite"), ModelRate(0.075, 0.30, 0.075, 0.02)),
|
|
50
|
+
(re.compile(r"gemini-2\.5(?:[-_.].*)?flash"), ModelRate(0.15, 0.60, 0.15, 0.0375)),
|
|
51
|
+
(re.compile(r"gemini-2\.5(?:[-_.].*)?pro"), ModelRate(1.25, 10.00, 1.25, 0.31)),
|
|
52
|
+
# --- Anthropic Claude (5.x, 4.x, 3.x & Fable) ---
|
|
53
|
+
(re.compile(r"claude.*fable|\bfable(?:[-_.]\d+(?:\.\d+)?)?"), ModelRate(5.00, 25.00, 6.25, 0.50)),
|
|
54
|
+
(re.compile(r"claude.*opus"), ModelRate(15.00, 75.00, 18.75, 1.50)),
|
|
55
|
+
(re.compile(r"claude.*sonnet"), ModelRate(3.00, 15.00, 3.75, 0.30)),
|
|
56
|
+
(re.compile(r"claude.*haiku"), ModelRate(0.80, 4.00, 1.00, 0.08)),
|
|
57
|
+
# --- OpenAI GPT-6.x / Astra / Luna ---
|
|
58
|
+
(re.compile(r"gpt-6(?:\.\d+)?.*astra|\bastra\b"), ModelRate(5.00, 20.00, 5.00, 1.25)),
|
|
59
|
+
(re.compile(r"gpt-6(?:\.\d+)?.*luna|\bluna\b"), ModelRate(1.50, 6.00, 1.50, 0.375)),
|
|
60
|
+
(re.compile(r"gpt-6(?:\.\d+)?.*nano"), ModelRate(0.15, 0.60, 0.15, 0.0375)),
|
|
61
|
+
(re.compile(r"gpt-6(?:\.\d+)?.*mini"), ModelRate(0.60, 2.40, 0.60, 0.15)),
|
|
62
|
+
(re.compile(r"gpt-6(?:\.\d+)?.*pro"), ModelRate(10.00, 40.00, 10.00, 2.50)),
|
|
63
|
+
(re.compile(r"gpt-6(?:\.\d+)?"), ModelRate(3.00, 12.00, 3.00, 0.75)),
|
|
64
|
+
# --- OpenAI GPT-5.x / Codex / o-series / GPT-4.1 ---
|
|
65
|
+
(re.compile(r"gpt-5(?:\.\d+)?.*nano"), ModelRate(0.05, 0.40, 0.05, 0.005)),
|
|
66
|
+
(re.compile(r"gpt-5(?:\.\d+)?.*mini"), ModelRate(0.25, 2.00, 0.25, 0.025)),
|
|
67
|
+
(re.compile(r"gpt-5(?:\.\d+)?.*codex"), ModelRate(1.50, 10.00, 1.50, 0.15)),
|
|
68
|
+
(re.compile(r"gpt-5\.4"), ModelRate(2.50, 10.00, 2.50, 0.25)),
|
|
69
|
+
(re.compile(r"gpt-5\.3"), ModelRate(2.00, 10.00, 2.00, 0.20)),
|
|
70
|
+
(re.compile(r"gpt-5\.2"), ModelRate(1.75, 10.00, 1.75, 0.175)),
|
|
71
|
+
(re.compile(r"gpt-5\.1"), ModelRate(1.50, 10.00, 1.50, 0.15)),
|
|
72
|
+
(re.compile(r"gpt-5\b"), ModelRate(1.25, 10.00, 1.25, 0.125)),
|
|
73
|
+
(re.compile(r"codex-mini"), ModelRate(1.50, 6.00, 1.50, 0.375)),
|
|
74
|
+
(re.compile(r"\bo4-mini\b"), ModelRate(1.10, 4.40, 1.10, 0.275)),
|
|
75
|
+
(re.compile(r"\bo3-pro\b"), ModelRate(20.00, 80.00, 20.00, 5.00)),
|
|
76
|
+
(re.compile(r"\bo3-mini\b"), ModelRate(1.10, 4.40, 1.10, 0.55)),
|
|
77
|
+
(re.compile(r"\bo3\b"), ModelRate(2.00, 8.00, 2.00, 0.50)),
|
|
78
|
+
(re.compile(r"gpt-4\.1.*mini"), ModelRate(0.40, 1.60, 0.40, 0.10)),
|
|
79
|
+
(re.compile(r"gpt-4\.1"), ModelRate(2.00, 8.00, 2.00, 0.50)),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Plan quotas across Claude Code, OpenAI Codex, and Gemini CLI
|
|
83
|
+
PLAN_QUOTAS: dict[str, PlanQuota] = {
|
|
84
|
+
"claude_free": PlanQuota(
|
|
85
|
+
id="claude_free",
|
|
86
|
+
label="Claude Free / Unverified",
|
|
87
|
+
window_hours=5,
|
|
88
|
+
window_cost_budget_usd=5.0,
|
|
89
|
+
window_token_budget=5_000_000,
|
|
90
|
+
),
|
|
91
|
+
"pro": PlanQuota(
|
|
92
|
+
id="pro",
|
|
93
|
+
label="Claude Pro ($20/mo)",
|
|
94
|
+
window_hours=5,
|
|
95
|
+
window_cost_budget_usd=18.0,
|
|
96
|
+
window_token_budget=19_000_000,
|
|
97
|
+
),
|
|
98
|
+
"max5": PlanQuota(
|
|
99
|
+
id="max5",
|
|
100
|
+
label="Claude Max 5x ($100/mo)",
|
|
101
|
+
window_hours=5,
|
|
102
|
+
window_cost_budget_usd=35.0,
|
|
103
|
+
window_token_budget=88_000_000,
|
|
104
|
+
),
|
|
105
|
+
"max20": PlanQuota(
|
|
106
|
+
id="max20",
|
|
107
|
+
label="Claude Max 20x ($200/mo)",
|
|
108
|
+
window_hours=5,
|
|
109
|
+
window_cost_budget_usd=140.0,
|
|
110
|
+
window_token_budget=220_000_000,
|
|
111
|
+
),
|
|
112
|
+
"claude_team": PlanQuota(
|
|
113
|
+
id="claude_team",
|
|
114
|
+
label="Claude Team",
|
|
115
|
+
window_hours=5,
|
|
116
|
+
window_cost_budget_usd=40.0,
|
|
117
|
+
window_token_budget=95_000_000,
|
|
118
|
+
),
|
|
119
|
+
"claude_enterprise": PlanQuota(
|
|
120
|
+
id="claude_enterprise",
|
|
121
|
+
label="Claude Enterprise",
|
|
122
|
+
window_hours=5,
|
|
123
|
+
window_cost_budget_usd=100.0,
|
|
124
|
+
window_token_budget=180_000_000,
|
|
125
|
+
),
|
|
126
|
+
"codex_free": PlanQuota(
|
|
127
|
+
id="codex_free",
|
|
128
|
+
label="ChatGPT Free / Unverified",
|
|
129
|
+
window_hours=5,
|
|
130
|
+
window_cost_budget_usd=5.0,
|
|
131
|
+
window_token_budget=5_000_000,
|
|
132
|
+
),
|
|
133
|
+
"codex_go": PlanQuota(
|
|
134
|
+
id="codex_go",
|
|
135
|
+
label="ChatGPT Go / Codex",
|
|
136
|
+
window_hours=5,
|
|
137
|
+
window_cost_budget_usd=10.0,
|
|
138
|
+
window_token_budget=12_000_000,
|
|
139
|
+
),
|
|
140
|
+
"codex_plus": PlanQuota(
|
|
141
|
+
id="codex_plus",
|
|
142
|
+
label="ChatGPT Plus / Codex ($20/mo)",
|
|
143
|
+
window_hours=5,
|
|
144
|
+
window_cost_budget_usd=20.0,
|
|
145
|
+
window_token_budget=25_000_000,
|
|
146
|
+
),
|
|
147
|
+
"codex_pro": PlanQuota(
|
|
148
|
+
id="codex_pro",
|
|
149
|
+
label="ChatGPT Pro / Codex ($200/mo)",
|
|
150
|
+
window_hours=5,
|
|
151
|
+
window_cost_budget_usd=140.0,
|
|
152
|
+
window_token_budget=220_000_000,
|
|
153
|
+
),
|
|
154
|
+
"codex_team": PlanQuota(
|
|
155
|
+
id="codex_team",
|
|
156
|
+
label="ChatGPT Team / Codex",
|
|
157
|
+
window_hours=5,
|
|
158
|
+
window_cost_budget_usd=50.0,
|
|
159
|
+
window_token_budget=90_000_000,
|
|
160
|
+
),
|
|
161
|
+
"codex_enterprise": PlanQuota(
|
|
162
|
+
id="codex_enterprise",
|
|
163
|
+
label="ChatGPT Enterprise / Codex",
|
|
164
|
+
window_hours=5,
|
|
165
|
+
window_cost_budget_usd=120.0,
|
|
166
|
+
window_token_budget=200_000_000,
|
|
167
|
+
),
|
|
168
|
+
"gemini_free": PlanQuota(
|
|
169
|
+
id="gemini_free",
|
|
170
|
+
label="Gemini Personal (Free OAuth)",
|
|
171
|
+
window_hours=5,
|
|
172
|
+
window_cost_budget_usd=5.0,
|
|
173
|
+
window_token_budget=10_000_000,
|
|
174
|
+
),
|
|
175
|
+
"api": PlanQuota(
|
|
176
|
+
id="api",
|
|
177
|
+
label="API Key (Pay-as-you-go)",
|
|
178
|
+
window_hours=5,
|
|
179
|
+
window_cost_budget_usd=50.0,
|
|
180
|
+
window_token_budget=100_000_000,
|
|
181
|
+
),
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_CUSTOM_RATES: dict[str, ModelRate] = {}
|
|
185
|
+
_SYNCED_RATES: dict[str, ModelRate] = {}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _safe_non_negative_rate(val: object, default: float) -> float | None:
|
|
189
|
+
try:
|
|
190
|
+
num = float(val if val is not None else default)
|
|
191
|
+
except (TypeError, ValueError):
|
|
192
|
+
return None
|
|
193
|
+
if not math.isfinite(num) or num < 0.0 or num > 10_000.0:
|
|
194
|
+
return None
|
|
195
|
+
return num
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _load_rate_map_file(path: Path, target_dict: dict[str, ModelRate]) -> None:
|
|
199
|
+
if not path.is_file():
|
|
200
|
+
return
|
|
201
|
+
try:
|
|
202
|
+
raw = json.loads(path.read_text(encoding="utf-8"))
|
|
203
|
+
entries = raw.get("models", raw) if isinstance(raw, dict) else {}
|
|
204
|
+
if isinstance(entries, dict):
|
|
205
|
+
for prefix, vals in entries.items():
|
|
206
|
+
if not isinstance(prefix, str) or not prefix.strip() or not isinstance(vals, dict):
|
|
207
|
+
continue
|
|
208
|
+
in_m = _safe_non_negative_rate(vals.get("input_per_m"), 3.0)
|
|
209
|
+
out_m = _safe_non_negative_rate(vals.get("output_per_m"), 15.0)
|
|
210
|
+
cw_m = _safe_non_negative_rate(vals.get("cache_write_per_m"), 3.75)
|
|
211
|
+
cr_m = _safe_non_negative_rate(vals.get("cache_read_per_m"), 0.30)
|
|
212
|
+
if None in (in_m, out_m, cw_m, cr_m):
|
|
213
|
+
continue
|
|
214
|
+
target_dict[prefix.strip().lower()] = ModelRate(
|
|
215
|
+
input_per_m=in_m, # type: ignore[arg-type]
|
|
216
|
+
output_per_m=out_m, # type: ignore[arg-type]
|
|
217
|
+
cache_write_per_m=cw_m, # type: ignore[arg-type]
|
|
218
|
+
cache_read_per_m=cr_m, # type: ignore[arg-type]
|
|
219
|
+
estimated=False,
|
|
220
|
+
)
|
|
221
|
+
except Exception:
|
|
222
|
+
pass
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def load_pricing_overrides(config_dir: Path) -> None:
|
|
226
|
+
"""Load synced pricing cache + user pricing_overrides.json (overrides win)."""
|
|
227
|
+
_SYNCED_RATES.clear()
|
|
228
|
+
_CUSTOM_RATES.clear()
|
|
229
|
+
_load_rate_map_file(config_dir / "pricing_cache.json", _SYNCED_RATES)
|
|
230
|
+
_load_rate_map_file(config_dir / "pricing_overrides.json", _CUSTOM_RATES)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def sync_live_pricing_catalog(
|
|
234
|
+
config_dir: Path,
|
|
235
|
+
source_url: str = LITELLM_PRICING_URL,
|
|
236
|
+
timeout_sec: float = 15.0,
|
|
237
|
+
) -> tuple[int, Path]:
|
|
238
|
+
"""Fetch latest community model pricing catalog so brand-new models get exact prices."""
|
|
239
|
+
req = urllib.request.Request(source_url, headers={"User-Agent": "claudeshift-cli/0.1.0"})
|
|
240
|
+
try:
|
|
241
|
+
with urllib.request.urlopen(req, timeout=timeout_sec) as resp:
|
|
242
|
+
raw = json.loads(resp.read().decode("utf-8"))
|
|
243
|
+
except (urllib.error.URLError, urllib.error.HTTPError, json.JSONDecodeError) as exc:
|
|
244
|
+
raise RuntimeError(f"Failed to sync live pricing catalog: {exc}") from exc
|
|
245
|
+
|
|
246
|
+
if not isinstance(raw, dict):
|
|
247
|
+
raise RuntimeError("Unexpected pricing catalog format.")
|
|
248
|
+
|
|
249
|
+
extracted: dict[str, dict[str, float]] = {}
|
|
250
|
+
relevant_prefixes = ("claude", "gpt-", "o1", "o3", "o4", "codex", "gemini", "fable", "astra", "luna")
|
|
251
|
+
|
|
252
|
+
for raw_name, meta in raw.items():
|
|
253
|
+
if not isinstance(meta, dict):
|
|
254
|
+
continue
|
|
255
|
+
clean_name = raw_name.split("/")[-1].lower().strip()
|
|
256
|
+
if not clean_name.startswith(relevant_prefixes):
|
|
257
|
+
continue
|
|
258
|
+
in_tok = meta.get("input_cost_per_token")
|
|
259
|
+
out_tok = meta.get("output_cost_per_token")
|
|
260
|
+
if not isinstance(in_tok, int | float) or not isinstance(out_tok, int | float):
|
|
261
|
+
continue
|
|
262
|
+
if not (math.isfinite(in_tok) and math.isfinite(out_tok)) or in_tok < 0 or out_tok < 0:
|
|
263
|
+
continue
|
|
264
|
+
if in_tok == 0 and out_tok == 0:
|
|
265
|
+
continue
|
|
266
|
+
|
|
267
|
+
cw_tok = meta.get("cache_creation_input_token_cost")
|
|
268
|
+
cr_tok = meta.get("cache_read_input_token_cost")
|
|
269
|
+
|
|
270
|
+
in_m = round(float(in_tok) * 1_000_000.0, 4)
|
|
271
|
+
out_m = round(float(out_tok) * 1_000_000.0, 4)
|
|
272
|
+
cw_m = (
|
|
273
|
+
round(float(cw_tok) * 1_000_000.0, 4)
|
|
274
|
+
if isinstance(cw_tok, int | float) and math.isfinite(cw_tok) and cw_tok >= 0
|
|
275
|
+
else in_m
|
|
276
|
+
)
|
|
277
|
+
cr_m = (
|
|
278
|
+
round(float(cr_tok) * 1_000_000.0, 4)
|
|
279
|
+
if isinstance(cr_tok, int | float) and math.isfinite(cr_tok) and cr_tok >= 0
|
|
280
|
+
else round(in_m * 0.25, 4)
|
|
281
|
+
)
|
|
282
|
+
extracted[clean_name] = {
|
|
283
|
+
"input_per_m": in_m,
|
|
284
|
+
"output_per_m": out_m,
|
|
285
|
+
"cache_write_per_m": cw_m,
|
|
286
|
+
"cache_read_per_m": cr_m,
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
290
|
+
target = config_dir / "pricing_cache.json"
|
|
291
|
+
tmp = target.with_suffix(f".{uuid.uuid4().hex[:6]}.tmp")
|
|
292
|
+
payload = {
|
|
293
|
+
"synced_at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
|
294
|
+
"source": source_url,
|
|
295
|
+
"count": len(extracted),
|
|
296
|
+
"models": extracted,
|
|
297
|
+
}
|
|
298
|
+
tmp.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
299
|
+
os.replace(tmp, target)
|
|
300
|
+
return len(extracted), target
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def _infer_heuristic_rate(low_model: str) -> ModelRate:
|
|
304
|
+
"""Smart tier fallback when encountering a brand-new unseen model."""
|
|
305
|
+
if any(k in low_model for k in ("nano", "lite")):
|
|
306
|
+
return ModelRate(0.10, 0.40, 0.10, 0.025, estimated=True)
|
|
307
|
+
if any(k in low_model for k in ("mini", "flash", "haiku", "fast")):
|
|
308
|
+
return ModelRate(0.60, 2.40, 0.60, 0.15, estimated=True)
|
|
309
|
+
if any(k in low_model for k in ("opus", "ultra", "pro-max")):
|
|
310
|
+
return ModelRate(15.0, 75.0, 18.75, 1.50, estimated=True)
|
|
311
|
+
if any(k in low_model for k in ("astra", "fable", "max")):
|
|
312
|
+
return ModelRate(5.0, 20.0, 5.0, 1.00, estimated=True)
|
|
313
|
+
return ModelRate(3.0, 12.0, 3.0, 0.50, estimated=True)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def resolve_model_rate(model_name: str) -> ModelRate:
|
|
317
|
+
low = (model_name or "").strip().lower()
|
|
318
|
+
if not low:
|
|
319
|
+
return _infer_heuristic_rate("")
|
|
320
|
+
|
|
321
|
+
# 1. User custom overrides (exact or longest substring)
|
|
322
|
+
if low in _CUSTOM_RATES:
|
|
323
|
+
return _CUSTOM_RATES[low]
|
|
324
|
+
for prefix in sorted(_CUSTOM_RATES, key=len, reverse=True):
|
|
325
|
+
if prefix in low:
|
|
326
|
+
return _CUSTOM_RATES[prefix]
|
|
327
|
+
|
|
328
|
+
# 2. Live synced catalog (exact match first, then longest prefix)
|
|
329
|
+
if low in _SYNCED_RATES:
|
|
330
|
+
return _SYNCED_RATES[low]
|
|
331
|
+
for prefix in sorted(_SYNCED_RATES, key=len, reverse=True):
|
|
332
|
+
if low.startswith(prefix):
|
|
333
|
+
return _SYNCED_RATES[prefix]
|
|
334
|
+
|
|
335
|
+
# 3. Version-agnostic 2026+ regex table
|
|
336
|
+
for pattern, rate in MODEL_PATTERNS:
|
|
337
|
+
if pattern.search(low):
|
|
338
|
+
return rate
|
|
339
|
+
|
|
340
|
+
# 4. Heuristic tier fallback for brand-new unseen models
|
|
341
|
+
return _infer_heuristic_rate(low)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def estimate_event_cost_usd(
|
|
345
|
+
model_name: str,
|
|
346
|
+
input_tokens: int,
|
|
347
|
+
output_tokens: int,
|
|
348
|
+
cache_write_tokens: int,
|
|
349
|
+
cache_read_tokens: int,
|
|
350
|
+
) -> float:
|
|
351
|
+
rate = resolve_model_rate(model_name)
|
|
352
|
+
in_t = max(0, int(input_tokens))
|
|
353
|
+
out_t = max(0, int(output_tokens))
|
|
354
|
+
cw_t = max(0, int(cache_write_tokens))
|
|
355
|
+
cr_t = max(0, int(cache_read_tokens))
|
|
356
|
+
cost = (
|
|
357
|
+
(in_t / 1_000_000.0) * rate.input_per_m
|
|
358
|
+
+ (out_t / 1_000_000.0) * rate.output_per_m
|
|
359
|
+
+ (cw_t / 1_000_000.0) * rate.cache_write_per_m
|
|
360
|
+
+ (cr_t / 1_000_000.0) * rate.cache_read_per_m
|
|
361
|
+
)
|
|
362
|
+
return round(cost, 6)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claudeshift-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast local-first profile switcher, MCP vault, and real-time quota radar for Claude Code, OpenAI Codex CLI, Gemini CLI, and Cursor.
|
|
5
|
+
Author: Mohamed Aboelmaged
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/mohamed2003-mgd/claudeshift-cli
|
|
8
|
+
Project-URL: Repository, https://github.com/mohamed2003-mgd/claudeshift-cli
|
|
9
|
+
Project-URL: Issues, https://github.com/mohamed2003-mgd/claudeshift-cli/issues
|
|
10
|
+
Keywords: claude,claude-code,codex,gemini-cli,cursor,mcp,cli,profile-switcher,quota-monitor,ai-tools
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: typer>=0.12.0
|
|
27
|
+
Requires-Dist: rich>=13.7.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.6.0; extra == "dev"
|
|
31
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
32
|
+
Requires-Dist: twine>=5.1.0; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# claudeshift
|
|
36
|
+
|
|
37
|
+
Local-first profile switcher, MCP vault, and usage monitor for AI CLIs.
|
|
38
|
+
**[Get claudeshift-cli Pro ($19 One-Time) on Gumroad →](https://mgm15.gumroad.com/l/claudeshift-cli)**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
claudeshift/__init__.py,sha256=m5oqJPZu_mBkKIZMeWh-sqS3BKKaKILf-fo-EDbb5V8,91
|
|
2
|
+
claudeshift/cli.py,sha256=XUtEFbsihzpTNZRpeLEFMf5bnYV4jY_wwjlq6vMktu0,24736
|
|
3
|
+
claudeshift/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
claudeshift/config/paths.py,sha256=nFXvvWovE-euws7YFcCf7XIXhGq6pF3NWjocEi2Da9A,2393
|
|
5
|
+
claudeshift/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
claudeshift/core/inspector.py,sha256=ljHn0Q1DgaHVP2ywERnhEWgmtnfXutM2BuvXxE2rUrc,4405
|
|
7
|
+
claudeshift/core/models.py,sha256=hfRqm_6XFirXT_Mep8xJlRBLPlkmTASoXnX4nKSKSbQ,2721
|
|
8
|
+
claudeshift/core/vault.py,sha256=iIiWHQBL3Gb5gFehCd6uH2n2JCQAFO6xMJhWtWMyDeA,28448
|
|
9
|
+
claudeshift/licensing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
claudeshift/licensing/entitlements.py,sha256=lnxQQW6sIjQFG9ytTrpfJgfVMboAIagWE73oNcmxM5A,1750
|
|
11
|
+
claudeshift/licensing/gumroad.py,sha256=WTs7G1ra4AcKEjMJX6h6qmSK5RW_JJMPi13QNI-c1ys,10175
|
|
12
|
+
claudeshift/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
claudeshift/providers/base.py,sha256=UmhetFLz7zeNVPcj6ZJ-PDKrP1S-WjrxvJvajyxD30Y,4491
|
|
14
|
+
claudeshift/providers/plan_detector.py,sha256=GPgj-zbggnyq0GNDVARD458ZuMIkV72TmvieNcyCz6A,10624
|
|
15
|
+
claudeshift/telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
claudeshift/telemetry/analytics.py,sha256=d5RdS5MzQTsQ_P9A6VSqLXXroeaFYHLysSlKjUM2VIk,6941
|
|
17
|
+
claudeshift/telemetry/dashboard.py,sha256=PHR7101BSMhc8QxMQBSZ6TkznqsCn9hV5qOecNxtDn4,6036
|
|
18
|
+
claudeshift/telemetry/exporter.py,sha256=ENXe6psMAG4NV_Jq68RFoCXk9PLIb1gbQG2iJl47SWQ,3482
|
|
19
|
+
claudeshift/telemetry/parser.py,sha256=t0rqQ3n2mMFYdbf28SZYPChWhLJwDjp9rIgxH5ExxZ0,15436
|
|
20
|
+
claudeshift/telemetry/pricing.py,sha256=ZATTJT3BP7QsLABqVgcQi12KxS7TH_OPF_KS6w3Ca0s,14264
|
|
21
|
+
claudeshift_cli-0.1.0.dist-info/licenses/LICENSE,sha256=XDoNXetyyJhoXgzl_bPLJZfIq8B4aUBDk9qscHAi4J0,1094
|
|
22
|
+
claudeshift_cli-0.1.0.dist-info/METADATA,sha256=1KRPnJoYTTg4BZZE0DWyQxfkEdwg8mTd5iT_iNSN3gU,1724
|
|
23
|
+
claudeshift_cli-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
24
|
+
claudeshift_cli-0.1.0.dist-info/entry_points.txt,sha256=7261rTJXgl-tGTN_f_TQODRz6t6v6WjdxcSSxJ2Ts4U,90
|
|
25
|
+
claudeshift_cli-0.1.0.dist-info/top_level.txt,sha256=Pg99uV6WwLQ68l0dDX1ZlTEuRmqncBuPv1dnHP7tjAI,12
|
|
26
|
+
claudeshift_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohamed Aboelmaged
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
claudeshift
|