tunacode-cli 0.0.46__py3-none-any.whl → 0.0.47__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.

Potentially problematic release.


This version of tunacode-cli might be problematic. Click here for more details.

tunacode/constants.py CHANGED
@@ -7,7 +7,7 @@ Centralizes all magic strings, UI text, error messages, and application constant
7
7
 
8
8
  # Application info
9
9
  APP_NAME = "TunaCode"
10
- APP_VERSION = "0.0.46"
10
+ APP_VERSION = "0.0.47"
11
11
 
12
12
  # File patterns
13
13
  GUIDE_FILE_PATTERN = "{name}.md"
@@ -49,6 +49,14 @@ class CostCalculator:
49
49
 
50
50
  pricing = model_config.pricing
51
51
 
52
+ # Safety check for None pricing
53
+ if not pricing:
54
+ return 0.0
55
+
56
+ # Safety check for None pricing attributes
57
+ if pricing.input is None or pricing.output is None:
58
+ return 0.0
59
+
52
60
  input_cost = (prompt_tokens / TOKENS_PER_MILLION) * pricing.input
53
61
 
54
62
  output_cost = (completion_tokens / TOKENS_PER_MILLION) * pricing.output
@@ -60,18 +60,27 @@ class UsageTracker(UsageTrackerProtocol):
60
60
  if not api_model_name.startswith(provider_prefix + ":"):
61
61
  final_model_name = f"{provider_prefix}:{api_model_name}"
62
62
 
63
- return self.calculator.calculate_cost(
63
+ cost = self.calculator.calculate_cost(
64
64
  prompt_tokens=parsed_data.get("prompt_tokens", 0),
65
65
  completion_tokens=parsed_data.get("completion_tokens", 0),
66
66
  model_name=final_model_name,
67
67
  )
68
68
 
69
+ # Ensure cost is never None
70
+ return cost if cost is not None else 0.0
71
+
69
72
  def _update_state(self, parsed_data: dict, cost: float):
70
73
  """Updates the last_call and session_total usage in the state."""
71
74
  session = self.state_manager.session
72
75
  prompt_tokens = parsed_data.get("prompt_tokens", 0)
73
76
  completion_tokens = parsed_data.get("completion_tokens", 0)
74
77
 
78
+ # Initialize usage dicts if they're None
79
+ if session.last_call_usage is None:
80
+ session.last_call_usage = {"prompt_tokens": 0, "completion_tokens": 0, "cost": 0.0}
81
+ if session.session_total_usage is None:
82
+ session.session_total_usage = {"prompt_tokens": 0, "completion_tokens": 0, "cost": 0.0}
83
+
75
84
  # Update last call usage
76
85
  session.last_call_usage["prompt_tokens"] = prompt_tokens
77
86
  session.last_call_usage["completion_tokens"] = completion_tokens
@@ -85,6 +94,13 @@ class UsageTracker(UsageTrackerProtocol):
85
94
  async def _display_summary(self):
86
95
  """Formats and prints the usage summary to the console."""
87
96
  session = self.state_manager.session
97
+
98
+ # Initialize usage dicts if they're None
99
+ if session.last_call_usage is None:
100
+ session.last_call_usage = {"prompt_tokens": 0, "completion_tokens": 0, "cost": 0.0}
101
+ if session.session_total_usage is None:
102
+ session.session_total_usage = {"prompt_tokens": 0, "completion_tokens": 0, "cost": 0.0}
103
+
88
104
  prompt = session.last_call_usage["prompt_tokens"]
89
105
  completion = session.last_call_usage["completion_tokens"]
90
106
  last_cost = session.last_call_usage["cost"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tunacode-cli
3
- Version: 0.0.46
3
+ Version: 0.0.47
4
4
  Summary: Your agentic CLI developer.
5
5
  Author-email: larock22 <noreply@github.com>
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  tunacode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- tunacode/constants.py,sha256=o1NSdboUcXjPgeYQJ7sCC7HtStJP2e8fE9lo0Jio0N4,5168
2
+ tunacode/constants.py,sha256=833fgfAmkcJmU1RmSYDhGCOzoU-eUMdgbcfBBwUQOZ4,5168
3
3
  tunacode/context.py,sha256=_gXVCyjU052jlyRAl9tklZSwl5U_zI_EIX8XN87VVWE,2786
4
4
  tunacode/exceptions.py,sha256=oDO1SVKOgjcKIylwqdbqh_g5my4roU5mB9Nv4n_Vb0s,3877
5
5
  tunacode/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -46,8 +46,8 @@ tunacode/core/setup/coordinator.py,sha256=oVTN2xIeJERXitVJpkIk9tDGLs1D1bxIRmaogJ
46
46
  tunacode/core/setup/environment_setup.py,sha256=n3IrObKEynHZSwtUJ1FddMg2C4sHz7ca42awemImV8s,2225
47
47
  tunacode/core/setup/git_safety_setup.py,sha256=CRIqrQt0QUJQRS344njty_iCqTorrDhHlXRuET7w0Tk,6714
48
48
  tunacode/core/token_usage/api_response_parser.py,sha256=CTtqGaFaxpkzkW3TEbe00QJzyRULpWN1EQxIYMleseg,1622
49
- tunacode/core/token_usage/cost_calculator.py,sha256=oQPMphGhqIt7NKdOg1o5Zbo59_nwFWmRJMQ30ViiCWs,1835
50
- tunacode/core/token_usage/usage_tracker.py,sha256=uKCpdZgmDfLauwsawSCifMu0kJE3lAnK7Sjd-0KYUgA,3894
49
+ tunacode/core/token_usage/cost_calculator.py,sha256=RjO-O0JENBuGOrWP7QgBZlZxeXC-PAIr8tj_9p_BxOU,2058
50
+ tunacode/core/token_usage/usage_tracker.py,sha256=kuAjUCyQkFykPy5mqsLRbKhZW298pyiCuFGn-ptBpy4,4657
51
51
  tunacode/prompts/system.md,sha256=hXpjZ8Yiv2Acr2_6EmC2uOklP8FbmvyYR9oais-1KLk,16290
52
52
  tunacode/services/__init__.py,sha256=w_E8QK6RnvKSvU866eDe8BCRV26rAm4d3R-Yg06OWCU,19
53
53
  tunacode/services/mcp.py,sha256=R48X73KQjQ9vwhBrtbWHSBl-4K99QXmbIhh5J_1Gezo,3046
@@ -91,9 +91,9 @@ tunacode/utils/system.py,sha256=FSoibTIH0eybs4oNzbYyufIiV6gb77QaeY2yGqW39AY,1138
91
91
  tunacode/utils/text_utils.py,sha256=6YBD9QfkDO44-6jxnwRWIpmfIifPG-NqMzy_O2NAouc,7277
92
92
  tunacode/utils/token_counter.py,sha256=lLbkrNUraRQn5RMhwnGurqq1RHFDyn4AaFhruONWIxo,2690
93
93
  tunacode/utils/user_configuration.py,sha256=Ilz8dpGVJDBE2iLWHAPT0xR8D51VRKV3kIbsAz8Bboc,3275
94
- tunacode_cli-0.0.46.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
95
- tunacode_cli-0.0.46.dist-info/METADATA,sha256=kO5Xol8ooArWqyfluRNjVq9t3MmZh9J02-ySYlpW_WA,5902
96
- tunacode_cli-0.0.46.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
- tunacode_cli-0.0.46.dist-info/entry_points.txt,sha256=hbkytikj4dGu6rizPuAd_DGUPBGF191RTnhr9wdhORY,51
98
- tunacode_cli-0.0.46.dist-info/top_level.txt,sha256=lKy2P6BWNi5XSA4DHFvyjQ14V26lDZctwdmhEJrxQbU,9
99
- tunacode_cli-0.0.46.dist-info/RECORD,,
94
+ tunacode_cli-0.0.47.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
95
+ tunacode_cli-0.0.47.dist-info/METADATA,sha256=oHfTMPtEUgbgVd7Nm0bb39wAKAuPKRHskBpZmDnBxMM,5902
96
+ tunacode_cli-0.0.47.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
+ tunacode_cli-0.0.47.dist-info/entry_points.txt,sha256=hbkytikj4dGu6rizPuAd_DGUPBGF191RTnhr9wdhORY,51
98
+ tunacode_cli-0.0.47.dist-info/top_level.txt,sha256=lKy2P6BWNi5XSA4DHFvyjQ14V26lDZctwdmhEJrxQbU,9
99
+ tunacode_cli-0.0.47.dist-info/RECORD,,