artificial-intelligence-usage 0.0.1__tar.gz → 0.0.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,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artificial-intelligence-usage
3
- Version: 0.0.1
4
- Summary: Analyze recent Codex sessions and report usage information.
3
+ Version: 0.0.2
4
+ Summary: Analyze usage of artificial intelligence tool.
5
5
  Author: Kaizten Analytics
6
6
  License-Expression: LicenseRef-Proprietary
7
7
  Classifier: Programming Language :: Python :: 3
@@ -17,6 +17,7 @@ latest session followed by daily session, turn, token, and rate-limit usage.
17
17
  ## Behavior
18
18
 
19
19
  - Reads rollout files below `~/.codex/sessions`.
20
+ - Reports when the Codex or Claude CLI is not available on `PATH`.
20
21
  - Shows status details from the most recently modified session.
21
22
  - Reports sessions from the last 14 calendar days by default, including today.
22
23
  - Counts user turns and cumulative tokens for each session.
@@ -6,6 +6,7 @@ latest session followed by daily session, turn, token, and rate-limit usage.
6
6
  ## Behavior
7
7
 
8
8
  - Reads rollout files below `~/.codex/sessions`.
9
+ - Reports when the Codex or Claude CLI is not available on `PATH`.
9
10
  - Shows status details from the most recently modified session.
10
11
  - Reports sessions from the last 14 calendar days by default, including today.
11
12
  - Counts user turns and cumulative tokens for each session.
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "artificial-intelligence-usage"
7
- version = "0.0.1"
8
- description = "Analyze recent Codex sessions and report usage information."
7
+ version = "0.0.2"
8
+ description = "Analyze usage of artificial intelligence tool."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = "LicenseRef-Proprietary"
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artificial-intelligence-usage
3
- Version: 0.0.1
4
- Summary: Analyze recent Codex sessions and report usage information.
3
+ Version: 0.0.2
4
+ Summary: Analyze usage of artificial intelligence tool.
5
5
  Author: Kaizten Analytics
6
6
  License-Expression: LicenseRef-Proprietary
7
7
  Classifier: Programming Language :: Python :: 3
@@ -17,6 +17,7 @@ latest session followed by daily session, turn, token, and rate-limit usage.
17
17
  ## Behavior
18
18
 
19
19
  - Reads rollout files below `~/.codex/sessions`.
20
+ - Reports when the Codex or Claude CLI is not available on `PATH`.
20
21
  - Shows status details from the most recently modified session.
21
22
  - Reports sessions from the last 14 calendar days by default, including today.
22
23
  - Counts user turns and cumulative tokens for each session.
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
 
6
6
  import argparse
7
7
  import json
8
+ import shutil
8
9
  from collections import Counter, defaultdict
9
10
  from datetime import date, datetime, timedelta
10
11
  from pathlib import Path
@@ -14,6 +15,13 @@ from typing import Any
14
15
  DEFAULT_DAYS = 14
15
16
 
16
17
 
18
+ def print_unavailable_tools() -> None:
19
+ """Print a message for each supported AI CLI that is not on PATH."""
20
+ for command, name in (("codex", "Codex"), ("claude", "Claude")):
21
+ if shutil.which(command) is None:
22
+ print(f"{name} is not available.")
23
+
24
+
17
25
  def positive_int(value: str) -> int:
18
26
  """Return value as a positive integer for command-line arguments."""
19
27
  try:
@@ -352,6 +360,7 @@ def run_report(sessions_dir: Path, days: int, today: date | None = None) -> int:
352
360
  def main(argv: list[str] | None = None) -> int:
353
361
  """Run the artificial-intelligence-usage command."""
354
362
  args = build_parser().parse_args(argv)
363
+ print_unavailable_tools()
355
364
  return run_report(Path.home() / ".codex" / "sessions", args.days)
356
365
 
357
366
 
@@ -184,14 +184,40 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
184
184
  def test_main_can_be_called_repeatedly(self):
185
185
  with patch.object(
186
186
  artificial_intelligence_usage, "run_report", return_value=0
187
- ) as run_report:
187
+ ) as run_report, patch.object(
188
+ artificial_intelligence_usage, "print_unavailable_tools"
189
+ ) as print_unavailable_tools:
188
190
  self.assertEqual(artificial_intelligence_usage.main(["--days", "3"]), 0)
189
191
  self.assertEqual(artificial_intelligence_usage.main(["--days", "5"]), 0)
190
192
 
191
193
  self.assertEqual(run_report.call_count, 2)
194
+ self.assertEqual(print_unavailable_tools.call_count, 2)
192
195
  self.assertEqual(run_report.call_args_list[0].args[1], 3)
193
196
  self.assertEqual(run_report.call_args_list[1].args[1], 5)
194
197
 
198
+ def test_unavailable_tools_prints_a_message_for_codex_and_claude(self):
199
+ output = io.StringIO()
200
+ with patch.object(
201
+ artificial_intelligence_usage.shutil, "which", return_value=None
202
+ ), contextlib.redirect_stdout(output):
203
+ artificial_intelligence_usage.print_unavailable_tools()
204
+
205
+ self.assertEqual(
206
+ output.getvalue(),
207
+ "Codex is not available.\nClaude is not available.\n",
208
+ )
209
+
210
+ def test_unavailable_tools_does_not_print_for_installed_commands(self):
211
+ output = io.StringIO()
212
+ with patch.object(
213
+ artificial_intelligence_usage.shutil,
214
+ "which",
215
+ side_effect=lambda command: f"/usr/bin/{command}",
216
+ ), contextlib.redirect_stdout(output):
217
+ artificial_intelligence_usage.print_unavailable_tools()
218
+
219
+ self.assertEqual(output.getvalue(), "")
220
+
195
221
 
196
222
  if __name__ == "__main__":
197
223
  unittest.main()