tokenzero 0.1.1__tar.gz → 0.1.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenzero
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Zero Token Waste - AST Code Skeletonizer & Live AI Monitor for Coding Agents
5
5
  License-Expression: MIT
6
6
  Keywords: tokenzero,tokens,ai-agents,ast,antigravity,claude,cursor,optimization,mcp
@@ -11,7 +11,7 @@ from scanner import scan_project, generate_markdown_map
11
11
 
12
12
  INTERNAL_PATTERNS = (
13
13
  ".tokenzero",
14
- ".tokensqueeze",
14
+
15
15
  "repo_map.md",
16
16
  "audit.jsonl",
17
17
  "hooks.json",
@@ -48,9 +48,6 @@ def get_repo_map_path(target_dir: Path) -> Path:
48
48
  local_map = target_dir / ".tokenzero" / "REPO_MAP.md"
49
49
  if local_map.exists():
50
50
  return local_map
51
- local_ts = target_dir / ".tokensqueeze" / "REPO_MAP.md"
52
- if local_ts.exists():
53
- return local_ts
54
51
  return get_project_cache_dir(target_dir) / "REPO_MAP.md"
55
52
 
56
53
  def record_activity(target_dir: Path, action: str, file: str, function: str, lines_used: int, total_lines: int):
@@ -222,7 +219,7 @@ def handle_get_stats(args: dict) -> str:
222
219
  pass
223
220
 
224
221
  # 2. Local fallback
225
- for folder in (".tokenzero", ".tokensqueeze"):
222
+ for folder in (".tokenzero",):
226
223
  local_audit = target_dir / folder / "audit.jsonl"
227
224
  if local_audit.exists():
228
225
  for line in local_audit.read_text(encoding="utf-8").splitlines():
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tokenzero"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Zero Token Waste - AST Code Skeletonizer & Live AI Monitor for Coding Agents"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -11,7 +11,7 @@ from typing import Dict, Any, List
11
11
 
12
12
  IGNORE_DIRS = {
13
13
  ".git", ".venv", "venv", "__pycache__", "node_modules",
14
- ".pytest_cache", ".tokenzero", ".tokensqueeze", "dist", "build", ".egg-info",
14
+ ".pytest_cache", ".tokenzero", ".tokenzero", "dist", "build", ".egg-info",
15
15
  ".next", ".turbo", "coverage", ".cache"
16
16
  }
17
17
 
@@ -377,8 +377,8 @@ def scan_project(root_dir: Path) -> List[Dict[str, Any]]:
377
377
  def generate_markdown_map(scan_data: List[Dict[str, Any]]) -> str:
378
378
  """Converts the parsed AST data into an ultra-clean, dense markdown map."""
379
379
  md = [
380
- "# 🗺️ Project Architecture & Symbol Map",
381
- "> Auto-generated by **TokenSqueeze**. Consult this map for line ranges before reading full files.",
380
+ "# Project Architecture & Symbol Map",
381
+ "> Auto-generated by **TokenZero**. Consult this map for line ranges before reading full files.",
382
382
  ""
383
383
  ]
384
384
 
@@ -26,9 +26,9 @@ AGENT_CONFIGS = [
26
26
  "file": "GEMINI.md",
27
27
  "name": "Google Antigravity",
28
28
  "rule": """<!-- BEGIN_TOKENZERO_RULE -->
29
- # ⚡ TokenZero Optimization Guide (Active)
29
+ # TokenZero Optimization Guide (Active)
30
30
 
31
- 1. **Check the Map First**: Before reading full source files, consult `.tokenzero/REPO_MAP.md` (or `.tokensqueeze/REPO_MAP.md`) to see the project structure, function signatures, and exact line ranges.
31
+ 1. **Check the Map First**: Before reading full source files, consult `.tokenzero/REPO_MAP.md` (or `.tokenzero/REPO_MAP.md`) to see the project structure, function signatures, and exact line ranges.
32
32
  2. **Partial File Reads**: Do NOT read whole files (>100 lines) if you only need one class or function. Always use line-range reading (`StartLine` and `EndLine`) based on the line numbers in `REPO_MAP.md`.
33
33
  3. **Targeted Edits**: Only inspect the exact function or block being edited to preserve context window and reduce token consumption.
34
34
  4. **Do NOT Edit audit.jsonl**: The TokenZero background hook manages audit logging automatically. Never propose edits to `audit.jsonl`.
@@ -40,7 +40,7 @@ AGENT_CONFIGS = [
40
40
  "file": "CLAUDE.md",
41
41
  "name": "Claude Code",
42
42
  "rule": """<!-- BEGIN_TOKENZERO_RULE -->
43
- # ⚡ TokenZero Optimization Guide (Active)
43
+ # TokenZero Optimization Guide (Active)
44
44
 
45
45
  1. **Check the Map First**: Before reading full source files, consult `.tokenzero/REPO_MAP.md` to see the project structure, function signatures, and exact line ranges.
46
46
  2. **Partial File Reads**: Do NOT read whole files (>100 lines) if you only need one class or function. Always use line-range reading based on the line numbers in `REPO_MAP.md`.
@@ -52,7 +52,7 @@ AGENT_CONFIGS = [
52
52
  "file": ".cursorrules",
53
53
  "name": "Cursor IDE",
54
54
  "rule": """<!-- BEGIN_TOKENZERO_RULE -->
55
- # ⚡ TokenZero Optimization Guide (Active)
55
+ # TokenZero Optimization Guide (Active)
56
56
 
57
57
  1. **Check the Map First**: Before reading full source files, consult `.tokenzero/REPO_MAP.md` to see the project structure, function signatures, and exact line ranges.
58
58
  2. **Partial File Reads**: Do NOT read whole files (>100 lines) if you only need one class or function. Always use line-range reading based on the line numbers in `REPO_MAP.md`.
@@ -63,7 +63,7 @@ AGENT_CONFIGS = [
63
63
  "file": ".windsurfrules",
64
64
  "name": "Windsurf IDE",
65
65
  "rule": """<!-- BEGIN_TOKENZERO_RULE -->
66
- # ⚡ TokenZero Optimization Guide (Active)
66
+ # TokenZero Optimization Guide (Active)
67
67
 
68
68
  1. **Check the Map First**: Before reading full source files, consult `.tokenzero/REPO_MAP.md` to see the project structure, function signatures, and exact line ranges.
69
69
  2. **Partial File Reads**: Do NOT read whole files (>100 lines) if you only need one class or function. Always use line-range reading based on the line numbers in `REPO_MAP.md`.
@@ -74,7 +74,7 @@ AGENT_CONFIGS = [
74
74
  "file": ".github/copilot-instructions.md",
75
75
  "name": "GitHub Copilot",
76
76
  "rule": """<!-- BEGIN_TOKENZERO_RULE -->
77
- # ⚡ TokenZero Optimization Guide (Active)
77
+ # TokenZero Optimization Guide (Active)
78
78
 
79
79
  1. **Check the Map First**: Before reading full source files, consult `.tokenzero/REPO_MAP.md` to see the project structure, function signatures, and exact line ranges.
80
80
  2. **Partial File Reads**: Do NOT read whole files (>100 lines) if you only need one class or function. Always use line-range reading based on the line numbers in `REPO_MAP.md`.
@@ -90,7 +90,7 @@ HOOK_CONFIG = {
90
90
  "hooks": [
91
91
  {
92
92
  "type": "command",
93
- "command": "PATH=\"$HOME/.local/bin:$PATH\" tokenzero hook",
93
+ "command": "PATH=\"$HOME/.local/bin:$PATH\" tokenzero hook || exit 0",
94
94
  "timeout": 5
95
95
  }
96
96
  ]
@@ -101,7 +101,7 @@ HOOK_CONFIG = {
101
101
 
102
102
  INTERNAL_PATTERNS = (
103
103
  ".tokenzero",
104
- ".tokensqueeze",
104
+ ".tokenzero",
105
105
  "repo_map.md",
106
106
  "audit.jsonl",
107
107
  "hooks.json",
@@ -142,7 +142,7 @@ def get_repo_map_path(target_dir: Path) -> Path:
142
142
  local_map = target_dir / ".tokenzero" / "REPO_MAP.md"
143
143
  if local_map.exists():
144
144
  return local_map
145
- local_ts = target_dir / ".tokensqueeze" / "REPO_MAP.md"
145
+ local_ts = target_dir / ".tokenzero" / "REPO_MAP.md"
146
146
  if local_ts.exists():
147
147
  return local_ts
148
148
  return get_project_cache_dir(target_dir) / "REPO_MAP.md"
@@ -150,7 +150,7 @@ def get_repo_map_path(target_dir: Path) -> Path:
150
150
  def get_config_dir(target_dir: Path) -> Path:
151
151
  """Returns local .tokenzero dir if exists, else global cache."""
152
152
  tz = target_dir / ".tokenzero"
153
- ts = target_dir / ".tokensqueeze"
153
+ ts = target_dir / ".tokenzero"
154
154
  if tz.exists():
155
155
  return tz
156
156
  if ts.exists():
@@ -283,7 +283,7 @@ def get_audit_entries(target_dir: Path):
283
283
  pass
284
284
 
285
285
  # 2. Local fallback if legacy audit exists
286
- for folder in (".tokenzero", ".tokensqueeze"):
286
+ for folder in (".tokenzero", ".tokenzero"):
287
287
  local_audit = target_dir / folder / "audit.jsonl"
288
288
  if local_audit.exists():
289
289
  try:
@@ -338,7 +338,7 @@ def render_dashboard_layout(target_dir: Path, spinner_frame: str) -> Layout:
338
338
  table.add_row(
339
339
  datetime.now().strftime("%H:%M:%S"),
340
340
  "[dim]WAIT[/dim]",
341
- "[dim]Waiting for Antigravity to inspect or edit code...[/dim]",
341
+ "[dim]Listening for AI agent tool calls...[/dim]",
342
342
  "-",
343
343
  "-"
344
344
  )
@@ -389,14 +389,14 @@ def render_dashboard_layout(target_dir: Path, spinner_frame: str) -> Layout:
389
389
 
390
390
  summary_table.add_row(
391
391
  f"[dim]Activity:[/dim] [bold white]{len(entries)} events[/bold white] across [bold white]{len(files_touched)} files[/bold white] | "
392
- f"🔴 [red]Actual Cost (Without TokenZero):[/red] [bold white]{without_tokens:,}[/bold white] tokens (${dollars_without:.4f}) ➜ "
393
- f"🟢 [green]Used (With TokenZero):[/green] [bold yellow]{total_tokens_used:,}[/bold yellow] tokens (${dollars_with:.4f})"
392
+ f"[dim]Unoptimized:[/dim] [white]{without_tokens:,}[/white] tokens (${dollars_without:.4f}) ➜ "
393
+ f"[dim]Optimized:[/dim] [green]{total_tokens_used:,}[/green] tokens (${dollars_with:.4f})"
394
394
  )
395
395
  summary_table.add_row(
396
- f"💰 [bold green]Net Impact: Saved +{total_tokens_saved:,} tokens ({pct_saved:.1f}% reduction) • You Saved ${dollars_saved:.4f} USD![/bold green]"
396
+ f"[bold green]Net Savings: {total_tokens_saved:,} tokens ({pct_saved:.1f}% reduction) | Cost Saved: ${dollars_saved:.4f} USD[/bold green]"
397
397
  )
398
398
 
399
- layout["footer"].update(Panel(summary_table, title="📊 TokenZero ROI & Savings Comparison", border_style="cyan"))
399
+ layout["footer"].update(Panel(summary_table, title="TokenZero Metrics & Savings", border_style="cyan"))
400
400
 
401
401
  return layout
402
402
 
@@ -405,7 +405,7 @@ def watch_dashboard(target_dir: Path):
405
405
  setup_tokenzero(silent=True)
406
406
  map_file = get_repo_map_path(target_dir)
407
407
  if not map_file.exists():
408
- console.print(f"[yellow]⚠️ TokenZero cache not found for {target_dir.name}. Initializing in Zero-File mode...[/yellow]")
408
+ console.print(f"[dim]TokenZero cache not found for {target_dir.name}. Initializing stealth mode...[/dim]")
409
409
  init_tokenzero(target_dir, local=False)
410
410
 
411
411
  console.clear()
@@ -419,19 +419,19 @@ def watch_dashboard(target_dir: Path):
419
419
  idx = (idx + 1) % len(spinner_chars)
420
420
  live.update(render_dashboard_layout(target_dir, spinner_chars[idx]))
421
421
  except KeyboardInterrupt:
422
- console.print("\n[yellow]👋 TokenZero Live Monitor stopped.[/yellow]")
422
+ console.print("\n[dim]TokenZero live monitor stopped.[/dim]")
423
423
 
424
424
  def show_stats_once(target_dir: Path):
425
425
  """Static one-time stats print."""
426
426
  console.print(render_dashboard_layout(target_dir, "●"))
427
427
 
428
428
  def init_tokenzero(target_dir: Path, local: bool = False):
429
- console.print(f"\n[bold cyan]🔍 Activating TokenZero in:[/bold cyan] {target_dir}")
429
+ console.print(f"\n[bold]TokenZero[/bold] initializing in: {target_dir}")
430
430
 
431
431
  # 1. Scan codebase (Python, JavaScript, TypeScript, Go)
432
432
  scan_results = scan_project(target_dir)
433
433
  if not scan_results:
434
- console.print("[yellow]⚠️ No supported source files (.py, .js, .ts, .jsx, .tsx, .go) with functions/classes found.[/yellow]")
434
+ console.print("[yellow]Warning: No supported source files (.py, .js, .ts, .jsx, .tsx, .go) found.[/yellow]")
435
435
  return
436
436
 
437
437
  map_content = generate_markdown_map(scan_results)
@@ -449,7 +449,7 @@ def init_tokenzero(target_dir: Path, local: bool = False):
449
449
  with open(gitignore_path, "a", encoding="utf-8") as f:
450
450
  if existing_gi and not existing_gi.endswith("\n"):
451
451
  f.write("\n")
452
- f.write("\n# TokenZero (Auto-ignored)\n.tokenzero/\n.tokensqueeze/\n")
452
+ f.write("\n# TokenZero (Auto-ignored)\n.tokenzero/\n.tokenzero/\n")
453
453
 
454
454
  # Inject Rules into supported agent files
455
455
  for cfg in AGENT_CONFIGS:
@@ -503,7 +503,7 @@ def init_tokenzero(target_dir: Path, local: bool = False):
503
503
 
504
504
  mode_label = "Local (Auto-.gitignore)" if local else "[bold green]Zero-File Stealth Mode (0 files in project)[/bold green]"
505
505
 
506
- table = Table(title="⚡ [bold green]TokenZero Optimization Engine Activated[/bold green]", header_style="bold magenta")
506
+ table = Table(title="TokenZero Configuration", header_style="bold")
507
507
  table.add_column("Component", style="cyan")
508
508
  table.add_column("Status / Impact", style="bold white")
509
509
 
@@ -516,7 +516,7 @@ def init_tokenzero(target_dir: Path, local: bool = False):
516
516
 
517
517
  console.print()
518
518
  console.print(table)
519
- console.print("\n[bold green]🚀 Zero token waste active![/bold green] Run '[cyan]tokenzero watch[/cyan]' to monitor live AI tool calls!")
519
+ console.print("\n[dim]Ready. Run '[cyan]tokenzero watch[/cyan]' to monitor live tool calls.[/dim]")
520
520
 
521
521
  def ensure_antigravity_plugin() -> tuple:
522
522
  """Installs or updates the global Antigravity plugin in ~/.gemini/config/plugins/tokenzero/"""
@@ -535,7 +535,7 @@ def ensure_antigravity_plugin() -> tuple:
535
535
  rules_dir = plugin_dir / "rules"
536
536
  rules_dir.mkdir(exist_ok=True)
537
537
  (rules_dir / "AGENTS.md").write_text("""<!-- BEGIN_TOKENZERO_RULE -->
538
- # ⚡ TokenZero Optimization Guide (Active)
538
+ # TokenZero Optimization Guide (Active)
539
539
 
540
540
  1. **Check the Map First**: Before reading full source files, consult TokenZero REPO_MAP to see the project structure, function signatures, and exact line ranges.
541
541
  2. **Partial File Reads**: Do NOT read whole files (>100 lines) if you only need one class or function. Always use line-range reading (`StartLine` and `EndLine`).
@@ -553,7 +553,7 @@ def setup_tokenzero(silent: bool = False) -> list:
553
553
  Configures Claude Desktop, Claude Code, Cursor IDE, etc.
554
554
  """
555
555
  if not silent:
556
- console.print("\n[bold cyan]🔧 Setting up TokenZero Universal MCP Integration...[/bold cyan]\n")
556
+ console.print("\n[bold]TokenZero Universal Integration[/bold]\n")
557
557
  results = []
558
558
 
559
559
  mcp_config_entry = {
@@ -617,7 +617,7 @@ def setup_tokenzero(silent: bool = False) -> list:
617
617
  results.append(("Google Antigravity", "~/.gemini/config/plugins/", f"[yellow]Skipped ({path_or_err})[/yellow]"))
618
618
 
619
619
  if not silent:
620
- table = Table(title="⚡ [bold green]TokenZero Universal Integration Status[/bold green]", header_style="bold magenta")
620
+ table = Table(title="Integration Status", header_style="bold")
621
621
  table.add_column("AI Agent / IDE", style="cyan")
622
622
  table.add_column("Configuration Target", style="dim")
623
623
  table.add_column("Status", style="bold white")
@@ -626,18 +626,18 @@ def setup_tokenzero(silent: bool = False) -> list:
626
626
  table.add_row(agent, path, status)
627
627
 
628
628
  console.print(table)
629
- console.print("\n[bold green]✨ All configured AI coding assistants now use TokenZero automatically![/bold green]")
629
+ console.print("\n[dim]All configured AI coding assistants now route tool calls through TokenZero.[/dim]")
630
630
  console.print("[dim]Project repositories remain 100% clean with 0 files added.[/dim]\n")
631
631
 
632
632
  return results
633
633
 
634
634
  def remove_tokenzero(target_dir: Path):
635
635
  """Completely removes TokenZero config, maps, rules, and hooks from a project."""
636
- console.print(f"\n[bold yellow]🧹 Deactivating TokenZero from:[/bold yellow] {target_dir}")
636
+ console.print(f"\n[bold]TokenZero:[/bold] Deactivating from {target_dir}")
637
637
  removed_items = []
638
638
 
639
639
  # 1. Remove directories
640
- for d in (".tokenzero", ".tokensqueeze"):
640
+ for d in (".tokenzero", ".tokenzero"):
641
641
  folder = target_dir / d
642
642
  if folder.exists():
643
643
  shutil.rmtree(folder)
@@ -686,7 +686,7 @@ def remove_tokenzero(target_dir: Path):
686
686
  try:
687
687
  data = json.loads(hooks_file.read_text(encoding="utf-8"))
688
688
  data.pop("tokenzero-live", None)
689
- data.pop("tokensqueeze-live", None)
689
+
690
690
  if data:
691
691
  hooks_file.write_text(json.dumps(data, indent=2), encoding="utf-8")
692
692
  removed_items.append(".agents/hooks.json")
@@ -704,7 +704,7 @@ def remove_tokenzero(target_dir: Path):
704
704
  if gitignore_path.exists():
705
705
  try:
706
706
  gi_content = gitignore_path.read_text(encoding="utf-8")
707
- cleaned_gi = re.sub(r"\n*# TokenZero \(Auto-ignored\)\n\.tokenzero/\n\.tokensqueeze/\n*", "\n", gi_content).strip()
707
+ cleaned_gi = re.sub(r"\n*# TokenZero \(Auto-ignored\)\n\.tokenzero/\n\.tokenzero/\n*", "\n", gi_content).strip()
708
708
  if cleaned_gi != gi_content.strip():
709
709
  if cleaned_gi:
710
710
  gitignore_path.write_text(cleaned_gi + "\n", encoding="utf-8")
@@ -715,14 +715,14 @@ def remove_tokenzero(target_dir: Path):
715
715
  pass
716
716
 
717
717
  if removed_items:
718
- console.print(f"\n[bold green]✅ TokenZero optimizations deactivated successfully.[/bold green]")
718
+ console.print(f"\n[green]TokenZero optimizations deactivated successfully.[/green]")
719
719
  console.print(f"[dim]Codebase restored to original state ({len(removed_items)} components cleaned).[/dim]\n")
720
720
  else:
721
- console.print(f"[cyan]ℹ️ No TokenZero configurations were found in {target_dir.name}.[/cyan]\n")
721
+ console.print(f"[dim]No TokenZero configurations found in {target_dir.name}.[/dim]\n")
722
722
 
723
723
  def remove_global_configs() -> list:
724
724
  """Completely uninstalls TokenZero from all global AI editors, plugins, and cache."""
725
- console.print("\n[bold yellow]🧹 Cleaning TokenZero Global AI Integrations & Cache...[/bold yellow]\n")
725
+ console.print("\n[bold]TokenZero Global Cleanup[/bold]\n")
726
726
  cleaned = []
727
727
 
728
728
  # 1. Remove Google Antigravity Global Plugin
@@ -786,7 +786,7 @@ def remove_global_configs() -> list:
786
786
  except Exception as e:
787
787
  cleaned.append(("Global Cache & Telemetry", str(GLOBAL_DIR), f"[yellow]Error ({e})[/yellow]"))
788
788
 
789
- table = Table(title="🧹 [bold yellow]TokenZero Global Cleanup Status[/bold yellow]", header_style="bold magenta")
789
+ table = Table(title="Global Cleanup Status", header_style="bold")
790
790
  table.add_column("AI Agent / Resource", style="cyan")
791
791
  table.add_column("Location", style="dim")
792
792
  table.add_column("Result", style="bold white")
@@ -795,12 +795,12 @@ def remove_global_configs() -> list:
795
795
  table.add_row(agent, path, status)
796
796
 
797
797
  console.print(table)
798
- console.print("\n[bold green]✨ All TokenZero global integrations and caches completely cleaned![/bold green]\n")
798
+ console.print("\n[green]All TokenZero global integrations and local caches have been removed.[/green]\n")
799
799
  return cleaned
800
800
 
801
801
  def main():
802
802
  import argparse
803
- parser = argparse.ArgumentParser(description="⚡ TokenZero - Zero Token Waste for AI Coding Agents")
803
+ parser = argparse.ArgumentParser(description="TokenZero - AST Code Skeletonizer & Token Optimizer for AI Coding Agents")
804
804
  subparsers = parser.add_subparsers(dest="command", help="Available commands")
805
805
 
806
806
  # init command
@@ -865,7 +865,7 @@ def main():
865
865
  elif args.command == "proxy":
866
866
  import uvicorn
867
867
  from proxy import app
868
- console.print("[bold green]🚀 Starting TokenZero Proxy on http://127.0.0.1:8080[/bold green]")
868
+ console.print("TokenZero Proxy listening on http://127.0.0.1:8080")
869
869
  uvicorn.run(app, host="127.0.0.1", port=8080, log_level="warning")
870
870
  elif args.command == "watch":
871
871
  target_path = Path(getattr(args, "path", ".")).resolve()
@@ -107,7 +107,7 @@ class TestTokenZeroScanner(unittest.TestCase):
107
107
  py_file.write_text("def helper(): pass\n")
108
108
  results = scan_project(Path(self.test_dir))
109
109
  md = generate_markdown_map(results)
110
- self.assertIn("# 🗺️ Project Architecture & Symbol Map", md)
110
+ self.assertIn("# Project Architecture & Symbol Map", md)
111
111
  self.assertIn("utils.py", md)
112
112
  self.assertIn("helper", md)
113
113
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenzero
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Zero Token Waste - AST Code Skeletonizer & Live AI Monitor for Coding Agents
5
5
  License-Expression: MIT
6
6
  Keywords: tokenzero,tokens,ai-agents,ast,antigravity,claude,cursor,optimization,mcp
File without changes
File without changes
File without changes
File without changes