token-cut-cli 0.1.6__tar.gz → 0.1.7__tar.gz
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.
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/PKG-INFO +10 -3
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/README.md +9 -2
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/pyproject.toml +1 -1
- token_cut_cli-0.1.7/src/token_cut_cli/__init__.py +1 -0
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/src/token_cut_cli/client.py +7 -0
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/src/token_cut_cli/verify.py +37 -0
- token_cut_cli-0.1.6/src/token_cut_cli/__init__.py +0 -1
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/.gitignore +0 -0
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/src/token_cut_cli/__main__.py +0 -0
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/src/token_cut_cli/main.py +0 -0
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/src/token_cut_cli/mcp_server.py +0 -0
- {token_cut_cli-0.1.6 → token_cut_cli-0.1.7}/src/token_cut_cli/workspace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: token-cut-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Verify Token-Cut API integration from the terminal (no repo clone required)
|
|
5
5
|
Project-URL: Homepage, https://www.token-cut.com
|
|
6
6
|
Project-URL: Documentation, https://www.token-cut.com
|
|
@@ -48,16 +48,23 @@ cd cli && pip install .
|
|
|
48
48
|
## Verify integration (~1 min)
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
export
|
|
51
|
+
export TOKEN_CUT_API_URL='https://www.token-cut.com'
|
|
52
|
+
export TOKEN_CUT_API_KEY='cc_live_…' # full key from Connect — not the prefix
|
|
52
53
|
token-cut verify
|
|
53
54
|
```
|
|
54
55
|
|
|
56
|
+
Shows token count and **estimated cost** before vs after for:
|
|
57
|
+
|
|
58
|
+
1. A short auth/optimize check (no repo graph)
|
|
59
|
+
2. A repo-graph optimize on a small public sample repo
|
|
60
|
+
|
|
55
61
|
Calls `https://www.token-cut.com` (override with `TOKEN_CUT_API_URL`).
|
|
56
62
|
|
|
57
63
|
## IDE setup (Cursor · Claude · Copilot)
|
|
58
64
|
|
|
59
65
|
```bash
|
|
60
|
-
export
|
|
66
|
+
export TOKEN_CUT_API_URL='https://www.token-cut.com'
|
|
67
|
+
export TOKEN_CUT_API_KEY='cc_live_…'
|
|
61
68
|
token-cut mcp-config > ~/.cursor/mcp.json
|
|
62
69
|
# merge if file already exists — restart IDE
|
|
63
70
|
```
|
|
@@ -28,16 +28,23 @@ cd cli && pip install .
|
|
|
28
28
|
## Verify integration (~1 min)
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
export
|
|
31
|
+
export TOKEN_CUT_API_URL='https://www.token-cut.com'
|
|
32
|
+
export TOKEN_CUT_API_KEY='cc_live_…' # full key from Connect — not the prefix
|
|
32
33
|
token-cut verify
|
|
33
34
|
```
|
|
34
35
|
|
|
36
|
+
Shows token count and **estimated cost** before vs after for:
|
|
37
|
+
|
|
38
|
+
1. A short auth/optimize check (no repo graph)
|
|
39
|
+
2. A repo-graph optimize on a small public sample repo
|
|
40
|
+
|
|
35
41
|
Calls `https://www.token-cut.com` (override with `TOKEN_CUT_API_URL`).
|
|
36
42
|
|
|
37
43
|
## IDE setup (Cursor · Claude · Copilot)
|
|
38
44
|
|
|
39
45
|
```bash
|
|
40
|
-
export
|
|
46
|
+
export TOKEN_CUT_API_URL='https://www.token-cut.com'
|
|
47
|
+
export TOKEN_CUT_API_KEY='cc_live_…'
|
|
41
48
|
token-cut mcp-config > ~/.cursor/mcp.json
|
|
42
49
|
# merge if file already exists — restart IDE
|
|
43
50
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.7"
|
|
@@ -118,6 +118,13 @@ class TokenCutClient:
|
|
|
118
118
|
if r.status_code == 401:
|
|
119
119
|
detail = parse_api_error(r)
|
|
120
120
|
raise PermissionError(f"API key rejected (401): {detail}")
|
|
121
|
+
if r.status_code == 403:
|
|
122
|
+
detail = parse_api_error(r)
|
|
123
|
+
raise PermissionError(
|
|
124
|
+
f"Access denied (403): {detail}. "
|
|
125
|
+
"Confirm your email from the signup message, or sign in at "
|
|
126
|
+
"https://www.token-cut.com/connect and resend verification."
|
|
127
|
+
)
|
|
121
128
|
if r.status_code == 429:
|
|
122
129
|
detail = parse_api_error(r)
|
|
123
130
|
raise PermissionError(f"Plan limit reached (429): {detail}")
|
|
@@ -27,6 +27,34 @@ def _fail(msg: str) -> None:
|
|
|
27
27
|
print(f" ✗ {msg}", file=sys.stderr)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def _pct_saved(original: int, optimized: int) -> float:
|
|
31
|
+
if original <= 0:
|
|
32
|
+
return 0.0
|
|
33
|
+
return max(0.0, (1 - optimized / original) * 100.0)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _print_savings(label: str, data: dict[str, Any], *, quiet: bool) -> None:
|
|
37
|
+
if quiet:
|
|
38
|
+
return
|
|
39
|
+
original = int(data.get("original_tokens") or 0)
|
|
40
|
+
optimized = int(data.get("optimized_tokens") or 0)
|
|
41
|
+
saved_tokens = max(0, original - optimized)
|
|
42
|
+
pct = _pct_saved(original, optimized)
|
|
43
|
+
before = float(data.get("estimated_cost_before_usd") or 0)
|
|
44
|
+
after = float(data.get("estimated_cost_after_usd") or 0)
|
|
45
|
+
cost_saved = float(
|
|
46
|
+
data.get("cost_saved_usd") or max(0.0, before - after)
|
|
47
|
+
)
|
|
48
|
+
factor = float(data.get("reduction_factor") or 1.0)
|
|
49
|
+
if original > 0 and optimized > 0 and factor <= 1.0:
|
|
50
|
+
factor = original / optimized
|
|
51
|
+
|
|
52
|
+
print(f"\n ── {label} ──")
|
|
53
|
+
print(f" Tokens: {original:,} → {optimized:,} ({saved_tokens:,} saved, {pct:.1f}% less)")
|
|
54
|
+
print(f" Factor: {factor:.2f}× smaller payload")
|
|
55
|
+
print(f" Est cost: ${before:.6f} → ${after:.6f} (${cost_saved:.6f} saved on this call)")
|
|
56
|
+
|
|
57
|
+
|
|
30
58
|
def run_verify(
|
|
31
59
|
client: TokenCutClient,
|
|
32
60
|
*,
|
|
@@ -84,6 +112,7 @@ def run_verify(
|
|
|
84
112
|
return 3
|
|
85
113
|
|
|
86
114
|
_ok("API key accepted")
|
|
115
|
+
_print_savings("Optimize (no repo graph)", auth_data, quiet=quiet)
|
|
87
116
|
o1 = int(auth_data.get("original_tokens") or 0)
|
|
88
117
|
o2 = int(auth_data.get("optimized_tokens") or 0)
|
|
89
118
|
_ok(f"Optimize (no graph): {o1} → {o2} tokens")
|
|
@@ -119,6 +148,14 @@ def run_verify(
|
|
|
119
148
|
if graph_ready:
|
|
120
149
|
cache = "built now" if graph_built else "cached"
|
|
121
150
|
_ok(f"Repo graph: {nodes:,} nodes ({cache})")
|
|
151
|
+
_print_savings("Optimize (with repo graph)", data, quiet=quiet)
|
|
152
|
+
if not quiet and o1 > 0 and o2 > 0:
|
|
153
|
+
g_orig = int(data.get("original_tokens") or 0)
|
|
154
|
+
g_opt = int(data.get("optimized_tokens") or 0)
|
|
155
|
+
print(
|
|
156
|
+
f"\n Compare: graph run used {g_orig:,} input tokens vs {o1:,} without graph "
|
|
157
|
+
f"({max(0, g_orig - o1):,} more context injected from repo index)."
|
|
158
|
+
)
|
|
122
159
|
elif "background" in msg.lower():
|
|
123
160
|
_ok("Repo index queued on server (background — avoids OOM)")
|
|
124
161
|
if not quiet:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.6"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|