artificial-intelligence-usage 0.0.8__tar.gz → 0.0.9__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.
Files changed (13) hide show
  1. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/PKG-INFO +1 -1
  2. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/pyproject.toml +1 -1
  3. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.egg-info/PKG-INFO +1 -1
  4. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.py +27 -1
  5. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/tests/test_artificial_intelligence_usage.py +25 -4
  6. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/README.md +0 -0
  7. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/setup.cfg +0 -0
  8. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.egg-info/SOURCES.txt +0 -0
  9. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.egg-info/dependency_links.txt +0 -0
  10. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.egg-info/entry_points.txt +0 -0
  11. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.egg-info/requires.txt +0 -0
  12. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/src/artificial_intelligence_usage.egg-info/top_level.txt +0 -0
  13. {artificial_intelligence_usage-0.0.8 → artificial_intelligence_usage-0.0.9}/tests/test_publish_pypi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artificial-intelligence-usage
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: Analyze usage of artificial intelligence tool.
5
5
  Author: Kaizten Analytics
6
6
  License-Expression: LicenseRef-Proprietary
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "artificial-intelligence-usage"
7
- version = "0.0.8"
7
+ version = "0.0.9"
8
8
  description = "Analyze usage of artificial intelligence tool."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artificial-intelligence-usage
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: Analyze usage of artificial intelligence tool.
5
5
  Author: Kaizten Analytics
6
6
  License-Expression: LicenseRef-Proprietary
@@ -128,6 +128,24 @@ def detect_latest_tool_versions(installed_versions: dict[str, str]) -> dict[str,
128
128
  }
129
129
 
130
130
 
131
+ def version_key(output: str) -> tuple | None:
132
+ """Extract a semantic version and return its precedence key, if available."""
133
+ for token in output.split():
134
+ match = re.fullmatch(
135
+ r"v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?"
136
+ r"(?:\+[0-9A-Za-z.-]+)?",
137
+ token,
138
+ )
139
+ if match:
140
+ major, minor, patch, prerelease = match.groups()
141
+ identifiers = tuple(
142
+ (0, int(part)) if part.isdigit() else (1, part)
143
+ for part in prerelease.split(".")
144
+ ) if prerelease else ()
145
+ return (int(major), int(minor), int(patch), bool(not prerelease), identifiers)
146
+ return None
147
+
148
+
131
149
  def print_installed_tool_versions(
132
150
  versions: dict[str, str], latest_versions: dict[str, str] | None = None
133
151
  ) -> None:
@@ -139,8 +157,16 @@ def print_installed_tool_versions(
139
157
  print("-" * 57)
140
158
  for name, _command in SUPPORTED_TOOLS:
141
159
  if name in versions:
142
- print(f"{name + ':':<16} {versions[name]}")
143
160
  latest_version = (latest_versions or {}).get(name, "UNKNOWN")
161
+ installed_key = version_key(versions[name])
162
+ latest_key = version_key(latest_version)
163
+ upgrade = (
164
+ " It must be upgraded"
165
+ if installed_key is not None and latest_key is not None
166
+ and latest_key > installed_key
167
+ else ""
168
+ )
169
+ print(f"{name + ':':<16} {versions[name]}{upgrade}")
144
170
  print(f"{name + ' latest version:':<26} {latest_version}")
145
171
  print()
146
172
 
@@ -188,10 +188,31 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
188
188
 
189
189
  report = output.getvalue()
190
190
  self.assertIn("Installed AI tools", report)
191
- self.assertIn("Codex: codex-cli 1.2.3", report)
192
- self.assertIn("Codex latest version: 1.3.0", report)
193
- self.assertIn("Claude: 2.0.1 (Claude Code)", report)
194
- self.assertIn("Claude latest version: 2.1.0", report)
191
+ self.assertIn("Codex: codex-cli 1.2.3 It must be upgraded", report)
192
+ self.assertIn("Codex latest version: 1.3.0", report)
193
+ self.assertIn("Claude: 2.0.1 (Claude Code) It must be upgraded", report)
194
+ self.assertIn("Claude latest version: 2.1.0", report)
195
+
196
+ def test_upgrade_message_requires_a_newer_known_version(self):
197
+ cases = (
198
+ ("codex-cli 0.170.0", "0.172.0", True),
199
+ ("codex-cli 0.9.0", "0.10.0", True),
200
+ ("codex-cli 1.0.0-rc.2", "1.0.0-rc.10", True),
201
+ ("codex-cli 1.0.0-rc.1", "1.0.0", True),
202
+ ("codex-cli 1.0.0", "1.0.0-rc.1", False),
203
+ ("codex-cli 1.0.0", "1.0.0", False),
204
+ ("codex-cli 2.0.0", "1.9.0", False),
205
+ ("unknown", "1.0.0", False),
206
+ ("codex-cli 1.0.0", "UNKNOWN", False),
207
+ )
208
+ for installed, latest, expected in cases:
209
+ with self.subTest(installed=installed, latest=latest):
210
+ output = io.StringIO()
211
+ with contextlib.redirect_stdout(output):
212
+ artificial_intelligence_usage.print_installed_tool_versions(
213
+ {"Codex": installed}, {"Codex": latest}
214
+ )
215
+ self.assertEqual("It must be upgraded" in output.getvalue(), expected)
195
216
 
196
217
  def test_analyze_session_ignores_malformed_lines_and_uses_maximum_tokens(self):
197
218
  with tempfile.TemporaryDirectory() as directory: