artificial-intelligence-usage 0.0.5__tar.gz → 0.0.6__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.
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/PKG-INFO +5 -3
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/README.md +4 -2
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/pyproject.toml +1 -1
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.egg-info/PKG-INFO +5 -3
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.py +30 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/tests/test_artificial_intelligence_usage.py +53 -3
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/setup.cfg +0 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.egg-info/SOURCES.txt +0 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.egg-info/dependency_links.txt +0 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.egg-info/entry_points.txt +0 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.egg-info/requires.txt +0 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/src/artificial_intelligence_usage.egg-info/top_level.txt +0 -0
- {artificial_intelligence_usage-0.0.5 → artificial_intelligence_usage-0.0.6}/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.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Analyze usage of artificial intelligence tool.
|
|
5
5
|
Author: Kaizten Analytics
|
|
6
6
|
License-Expression: LicenseRef-Proprietary
|
|
@@ -27,8 +27,10 @@ latest session followed by daily and per-session prompt, token, and rate-limit u
|
|
|
27
27
|
include automatic goal continuations, while background tasks such as guardian
|
|
28
28
|
reviews are excluded.
|
|
29
29
|
- Shows a second table with one row per session, including its start time,
|
|
30
|
-
session name (up to 10 characters), first-prompt preview (up to
|
|
31
|
-
characters), GitHub repository, usage, and language.
|
|
30
|
+
finish time, session name (up to 10 characters), first-prompt preview (up to
|
|
31
|
+
20 characters), GitHub repository, usage, and language. A session is finished
|
|
32
|
+
when its final rollout event is `task_complete`; otherwise its finish value is
|
|
33
|
+
`In progress`.
|
|
32
34
|
- Reads session names from `~/.codex/session_index.jsonl`. Missing names and
|
|
33
35
|
prompts display as `Unknown`.
|
|
34
36
|
- For goal-only sessions, reads the goal objective from
|
|
@@ -15,8 +15,10 @@ latest session followed by daily and per-session prompt, token, and rate-limit u
|
|
|
15
15
|
include automatic goal continuations, while background tasks such as guardian
|
|
16
16
|
reviews are excluded.
|
|
17
17
|
- Shows a second table with one row per session, including its start time,
|
|
18
|
-
session name (up to 10 characters), first-prompt preview (up to
|
|
19
|
-
characters), GitHub repository, usage, and language.
|
|
18
|
+
finish time, session name (up to 10 characters), first-prompt preview (up to
|
|
19
|
+
20 characters), GitHub repository, usage, and language. A session is finished
|
|
20
|
+
when its final rollout event is `task_complete`; otherwise its finish value is
|
|
21
|
+
`In progress`.
|
|
20
22
|
- Reads session names from `~/.codex/session_index.jsonl`. Missing names and
|
|
21
23
|
prompts display as `Unknown`.
|
|
22
24
|
- For goal-only sessions, reads the goal objective from
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: artificial-intelligence-usage
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Analyze usage of artificial intelligence tool.
|
|
5
5
|
Author: Kaizten Analytics
|
|
6
6
|
License-Expression: LicenseRef-Proprietary
|
|
@@ -27,8 +27,10 @@ latest session followed by daily and per-session prompt, token, and rate-limit u
|
|
|
27
27
|
include automatic goal continuations, while background tasks such as guardian
|
|
28
28
|
reviews are excluded.
|
|
29
29
|
- Shows a second table with one row per session, including its start time,
|
|
30
|
-
session name (up to 10 characters), first-prompt preview (up to
|
|
31
|
-
characters), GitHub repository, usage, and language.
|
|
30
|
+
finish time, session name (up to 10 characters), first-prompt preview (up to
|
|
31
|
+
20 characters), GitHub repository, usage, and language. A session is finished
|
|
32
|
+
when its final rollout event is `task_complete`; otherwise its finish value is
|
|
33
|
+
`In progress`.
|
|
32
34
|
- Reads session names from `~/.codex/session_index.jsonl`. Missing names and
|
|
33
35
|
prompts display as `Unknown`.
|
|
34
36
|
- For goal-only sessions, reads the goal objective from
|
|
@@ -45,6 +45,7 @@ class SessionAnalysis:
|
|
|
45
45
|
language: str
|
|
46
46
|
session_id: str | None
|
|
47
47
|
first_prompt: str | None
|
|
48
|
+
finish: str
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
def positive_int(value: str) -> int:
|
|
@@ -122,6 +123,21 @@ def format_timestamp(value: str | int | float | None) -> str:
|
|
|
122
123
|
return "unknown"
|
|
123
124
|
|
|
124
125
|
|
|
126
|
+
def format_time(value: str | int | float | None) -> str:
|
|
127
|
+
"""Format an ISO or Unix timestamp as a local time."""
|
|
128
|
+
try:
|
|
129
|
+
if isinstance(value, str):
|
|
130
|
+
timestamp = datetime.fromisoformat(value.replace("Z", "+00:00"))
|
|
131
|
+
elif isinstance(value, (int, float)):
|
|
132
|
+
timestamp = datetime.fromtimestamp(value).astimezone()
|
|
133
|
+
else:
|
|
134
|
+
return "Unknown"
|
|
135
|
+
|
|
136
|
+
return timestamp.astimezone().strftime("%H:%M:%S")
|
|
137
|
+
except (OverflowError, OSError, ValueError):
|
|
138
|
+
return "Unknown"
|
|
139
|
+
|
|
140
|
+
|
|
125
141
|
def format_window(minutes: Any) -> str:
|
|
126
142
|
"""Return a compact label for a rate-limit window."""
|
|
127
143
|
if not isinstance(minutes, (int, float)):
|
|
@@ -457,6 +473,8 @@ def analyze_session(session_file: Path) -> SessionAnalysis:
|
|
|
457
473
|
repository = "Unknown"
|
|
458
474
|
session_id = None
|
|
459
475
|
first_prompt = None
|
|
476
|
+
last_event_is_task_complete = False
|
|
477
|
+
last_event_timestamp = None
|
|
460
478
|
|
|
461
479
|
with session_file.open("r", encoding="utf-8") as file_handle:
|
|
462
480
|
for line in file_handle:
|
|
@@ -466,6 +484,11 @@ def analyze_session(session_file: Path) -> SessionAnalysis:
|
|
|
466
484
|
continue
|
|
467
485
|
|
|
468
486
|
payload = event.get("payload") or {}
|
|
487
|
+
last_event_is_task_complete = (
|
|
488
|
+
event.get("type") == "event_msg"
|
|
489
|
+
and payload.get("type") == "task_complete"
|
|
490
|
+
)
|
|
491
|
+
last_event_timestamp = event.get("timestamp")
|
|
469
492
|
|
|
470
493
|
if event.get("type") == "session_meta":
|
|
471
494
|
candidate_session_id = payload.get("id") or payload.get("session_id")
|
|
@@ -512,6 +535,11 @@ def analyze_session(session_file: Path) -> SessionAnalysis:
|
|
|
512
535
|
language=detect_language(first_prompt),
|
|
513
536
|
session_id=session_id,
|
|
514
537
|
first_prompt=first_prompt,
|
|
538
|
+
finish=(
|
|
539
|
+
format_time(last_event_timestamp)
|
|
540
|
+
if last_event_is_task_complete
|
|
541
|
+
else "In progress"
|
|
542
|
+
),
|
|
515
543
|
)
|
|
516
544
|
|
|
517
545
|
|
|
@@ -663,6 +691,7 @@ def run_report(
|
|
|
663
691
|
session_header = (
|
|
664
692
|
f"{'Date':<12} "
|
|
665
693
|
f"{'Start':<8} "
|
|
694
|
+
f"{'Finish':<11} "
|
|
666
695
|
f"{'Repository':<{repository_width}} "
|
|
667
696
|
f"{'Name':<10} "
|
|
668
697
|
f"{'First prompt':<20} "
|
|
@@ -690,6 +719,7 @@ def run_report(
|
|
|
690
719
|
print(
|
|
691
720
|
f"{date_label:<12} "
|
|
692
721
|
f"{session_start_time(session_file):<8} "
|
|
722
|
+
f"{analysis.finish:<11} "
|
|
693
723
|
f"{analysis.repository:<{repository_width}} "
|
|
694
724
|
f"{session_name:<10} "
|
|
695
725
|
f"{prompt_preview:<20} "
|
|
@@ -65,6 +65,13 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
65
65
|
},
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
def task_complete_event(self, timestamp: str = "2026-10-04T10:05:06") -> dict:
|
|
69
|
+
return {
|
|
70
|
+
"timestamp": timestamp,
|
|
71
|
+
"type": "event_msg",
|
|
72
|
+
"payload": {"type": "task_complete"},
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
def test_positive_int_accepts_positive_values(self):
|
|
69
76
|
self.assertEqual(artificial_intelligence_usage.positive_int("7"), 7)
|
|
70
77
|
|
|
@@ -162,6 +169,7 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
162
169
|
language="Unknown",
|
|
163
170
|
session_id=None,
|
|
164
171
|
first_prompt=None,
|
|
172
|
+
finish="In progress",
|
|
165
173
|
),
|
|
166
174
|
)
|
|
167
175
|
|
|
@@ -218,6 +226,7 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
218
226
|
language="Unknown",
|
|
219
227
|
session_id=None,
|
|
220
228
|
first_prompt=None,
|
|
229
|
+
finish="In progress",
|
|
221
230
|
),
|
|
222
231
|
)
|
|
223
232
|
|
|
@@ -297,6 +306,45 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
297
306
|
"09:08:07",
|
|
298
307
|
)
|
|
299
308
|
|
|
309
|
+
def test_analyze_session_uses_only_a_terminal_task_completion_as_finish(self):
|
|
310
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
311
|
+
root = Path(directory)
|
|
312
|
+
completed_session = root / "rollout-completed.jsonl"
|
|
313
|
+
completed_session.write_text(
|
|
314
|
+
json.dumps(self.task_complete_event("2026-10-04T12:34:56"))
|
|
315
|
+
+ "\nnot-json\n",
|
|
316
|
+
encoding="utf-8",
|
|
317
|
+
)
|
|
318
|
+
active_session = root / "rollout-active.jsonl"
|
|
319
|
+
active_session.write_text(
|
|
320
|
+
json.dumps(self.task_complete_event())
|
|
321
|
+
+ "\n"
|
|
322
|
+
+ json.dumps(
|
|
323
|
+
{
|
|
324
|
+
"timestamp": "2026-10-04T10:06:00",
|
|
325
|
+
"type": "event_msg",
|
|
326
|
+
"payload": {"type": "task_started"},
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
+ "\n",
|
|
330
|
+
encoding="utf-8",
|
|
331
|
+
)
|
|
332
|
+
invalid_session = root / "rollout-invalid.jsonl"
|
|
333
|
+
invalid_session.write_text(
|
|
334
|
+
json.dumps(self.task_complete_event("not-a-timestamp")) + "\n",
|
|
335
|
+
encoding="utf-8",
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
completed = artificial_intelligence_usage.analyze_session(
|
|
339
|
+
completed_session
|
|
340
|
+
)
|
|
341
|
+
active = artificial_intelligence_usage.analyze_session(active_session)
|
|
342
|
+
invalid = artificial_intelligence_usage.analyze_session(invalid_session)
|
|
343
|
+
|
|
344
|
+
self.assertEqual(completed.finish, "12:34:56")
|
|
345
|
+
self.assertEqual(active.finish, "In progress")
|
|
346
|
+
self.assertEqual(invalid.finish, "Unknown")
|
|
347
|
+
|
|
300
348
|
def test_github_repository_supports_https_and_rejects_other_hosts(self):
|
|
301
349
|
self.assertEqual(
|
|
302
350
|
artificial_intelligence_usage.github_repository(
|
|
@@ -480,6 +528,7 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
480
528
|
plan_prompt,
|
|
481
529
|
goal_prompt,
|
|
482
530
|
self.token_event(100),
|
|
531
|
+
self.task_complete_event(),
|
|
483
532
|
],
|
|
484
533
|
)
|
|
485
534
|
self.write_session(
|
|
@@ -524,16 +573,17 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
524
573
|
self.assertIn("70% remaining", report)
|
|
525
574
|
self.assertIn("55% remaining", report)
|
|
526
575
|
self.assertIn("Sessions", report)
|
|
576
|
+
self.assertRegex(report, r"Start\s+Finish\s+Repository")
|
|
527
577
|
self.assertIn("Name", report)
|
|
528
578
|
self.assertIn("First prompt", report)
|
|
529
579
|
self.assertIn("Repository", report)
|
|
530
580
|
self.assertRegex(
|
|
531
581
|
report,
|
|
532
|
-
r"2026-10-04\s+09:00:00\s+kaizten/example\s+Updated se\s+Please update the us\s+1\s+1\s+1\s+1\s+English\s+100",
|
|
582
|
+
r"2026-10-04\s+09:00:00\s+10:05:06\s+kaizten/example\s+Updated se\s+Please update the us\s+1\s+1\s+1\s+1\s+English\s+100",
|
|
533
583
|
)
|
|
534
584
|
self.assertRegex(
|
|
535
585
|
report,
|
|
536
|
-
r"2026-10-04\s+10:00:00\s+Unknown\s+Unknown\s+Please update the us\s+2\s+1\s+0\s+0\s+English\s+250",
|
|
586
|
+
r"2026-10-04\s+10:00:00\s+In progress\s+Unknown\s+Unknown\s+Please update the us\s+2\s+1\s+0\s+0\s+English\s+250",
|
|
537
587
|
)
|
|
538
588
|
self.assertLess(report.index("09:00:00"), report.index("10:00:00"))
|
|
539
589
|
daily_report = report[report.index("Date") :]
|
|
@@ -589,7 +639,7 @@ class ArtificialIntelligenceUsageTests(unittest.TestCase):
|
|
|
589
639
|
session_table = output.getvalue()[output.getvalue().index("Sessions") :]
|
|
590
640
|
self.assertRegex(
|
|
591
641
|
session_table,
|
|
592
|
-
r"11:00:00\s+Unknown\s+Unknown\s+Run the existing tes\s+0\s+0\s+0\s+1\s+Unknown\s+75",
|
|
642
|
+
r"11:00:00\s+In progress\s+Unknown\s+Unknown\s+Run the existing tes\s+0\s+0\s+0\s+1\s+Unknown\s+75",
|
|
593
643
|
)
|
|
594
644
|
|
|
595
645
|
def test_main_can_be_called_repeatedly(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|