Merge develop into feature/users-and-media
This commit is contained in:
commit
f34e3d312e
3 files changed
+39
-20
No files matched your search
@@ -10,7 +10,7 @@ between lil-koneko.com, CarsHub, iriks-it.nl and bouwbedrijf.iriks-it.nl, as one
|
|||||||
- Nothing site-specific in the package. A site's own part is its own module class.
|
- Nothing site-specific in the package. A site's own part is its own module class.
|
||||||
- Tests: `composer test` (Pest + Testbench); style: `composer lint` (Pint).
|
- Tests: `composer test` (Pest + Testbench); style: `composer lint` (Pint).
|
||||||
- Branches: `production` is main, work on `feature/…` from `develop`; I never merge to `production`.
|
- Branches: `production` is main, work on `feature/…` from `develop`; I never merge to `production`.
|
||||||
- No mention of an AI in commits or PRs. Keep a row per piece of work in `TOKENS.md` (`dev/token-usage.py`).
|
- No mention of an AI in commits or PRs. Keep a row per piece of work in `TOKENS.md` (`dev/token-usage.py`; helper agents are counted in the row, one row per model).
|
||||||
|
|
||||||
## Open decisions
|
## Open decisions
|
||||||
|
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ Per stuk werk een rij; zie `dev/token-usage.py`.
|
|||||||
|---|---|---|---|---:|---:|---:|---:|---:|---:|
|
|---|---|---|---|---:|---:|---:|---:|---:|---:|
|
||||||
| 2026-12-04 | Eerste opzet van het pakket: modules, schakelaars, rechten. Gebruikers en media uit bouwbedrijf overgezet | - | claude-sonnet-5-5 | 34 | 57.433 | 76 | 131.194 | 3.225.205 | 0,18 |
|
| 2026-12-04 | Eerste opzet van het pakket: modules, schakelaars, rechten. Gebruikers en media uit bouwbedrijf overgezet | - | claude-sonnet-5-5 | 34 | 57.433 | 76 | 131.194 | 3.225.205 | 0,18 |
|
||||||
| 2026-12-04 | Posts overgezet: berichten met concepten, inplannen, categorieën en tags | - | claude-sonnet-5-5 | 9 | 19.897 | 20 | 35.420 | 1.584.858 | 0,03 |
|
| 2026-12-04 | Posts overgezet: berichten met concepten, inplannen, categorieën en tags | - | claude-sonnet-5-5 | 9 | 19.897 | 20 | 35.420 | 1.584.858 | 0,03 |
|
||||||
|
| 2026-12-04 | Token-script telt de tokens van helper-agents mee in de rij, per model | - | claude-sonnet-5-5 | 16 | 27.013 | 36 | 45.155 | 2.982.056 | 0,06 |
|
||||||
+37
-19
@@ -4,14 +4,18 @@
|
|||||||
Usage: dev/token-usage.py LOG.jsonl [--since 2026-12-02T07:00] [--until 2026-12-02T12:00]
|
Usage: dev/token-usage.py LOG.jsonl [--since 2026-12-02T07:00] [--until 2026-12-02T12:00]
|
||||||
[--row "Wat er is gemaakt" [--version v0.2.0]]
|
[--row "Wat er is gemaakt" [--version v0.2.0]]
|
||||||
|
|
||||||
With --row it also prints the line for the table of TOKENS.md, with the hours as its last cell.
|
With --row it also prints the line(s) for the table of TOKENS.md, with the hours as the last cell.
|
||||||
|
|
||||||
|
Helper agents (subagents) are part of the work: their tokens are added to the row. The row is made
|
||||||
|
per model, because the price differs per model: when helper agents ran on another model than the
|
||||||
|
session, there is one row for each, and the hours are on the first row only.
|
||||||
|
|
||||||
The hours are the time that was worked in the period: from one entry of the log to the next,
|
The hours are the time that was worked in the period: from one entry of the log to the next,
|
||||||
the time between an answer and the next request included, pauses of more than half an hour
|
the time between an answer and the next request included, pauses of more than half an hour
|
||||||
left out.
|
left out.
|
||||||
|
|
||||||
LOG.jsonl is the log of the session (~/.claude/projects/<folder>/<session>.jsonl); the logs of
|
LOG.jsonl is the log of the session (~/.claude/projects/<folder>/<session>.jsonl); the logs of
|
||||||
helper agents in the folder `<session>/subagents` next to it are counted separately. The moments
|
helper agents in the folder `<session>/subagents` next to it are shown separately and also counted in the row. The moments
|
||||||
are UTC, as in the log. An answer of the model can be in the log more than once; it is counted
|
are UTC, as in the log. An answer of the model can be in the log more than once; it is counted
|
||||||
once, by its message id.
|
once, by its message id.
|
||||||
|
|
||||||
@@ -70,20 +74,28 @@ def hours(path, since, until):
|
|||||||
|
|
||||||
|
|
||||||
def total(found, since, until):
|
def total(found, since, until):
|
||||||
"""Steps, output, input, written to the cache, read from the cache; and the models seen."""
|
"""Steps, output, input, written to the cache, read from the cache; and the same per model."""
|
||||||
row = [0, 0, 0, 0, 0]
|
row = [0, 0, 0, 0, 0]
|
||||||
models = {}
|
per_model = {}
|
||||||
for usage, moment, model in found.values():
|
for usage, moment, model in found.values():
|
||||||
if (since and moment[:16] < since) or (until and moment[:16] >= until):
|
if (since and moment[:16] < since) or (until and moment[:16] >= until):
|
||||||
continue
|
continue
|
||||||
row[0] += 1
|
# Entries the client made itself (model "<synthetic>") hold no tokens and no work.
|
||||||
row[1] += usage.get("output_tokens", 0)
|
if model and model.startswith("<"):
|
||||||
row[2] += usage.get("input_tokens", 0)
|
continue
|
||||||
row[3] += usage.get("cache_creation_input_tokens", 0)
|
add = [
|
||||||
row[4] += usage.get("cache_read_input_tokens", 0)
|
1,
|
||||||
if model and not model.startswith("<"):
|
usage.get("output_tokens", 0),
|
||||||
models[model] = models.get(model, 0) + 1
|
usage.get("input_tokens", 0),
|
||||||
return row, models
|
usage.get("cache_creation_input_tokens", 0),
|
||||||
|
usage.get("cache_read_input_tokens", 0),
|
||||||
|
]
|
||||||
|
model = model or "?"
|
||||||
|
mine = per_model.setdefault(model, [0, 0, 0, 0, 0])
|
||||||
|
for index, value in enumerate(add):
|
||||||
|
row[index] += value
|
||||||
|
mine[index] += value
|
||||||
|
return row, per_model
|
||||||
|
|
||||||
|
|
||||||
def number(value):
|
def number(value):
|
||||||
@@ -105,9 +117,11 @@ def main():
|
|||||||
if len(paths) != 1:
|
if len(paths) != 1:
|
||||||
sys.exit(__doc__)
|
sys.exit(__doc__)
|
||||||
|
|
||||||
row, models = total(answers(paths[0]), since, until)
|
session = answers(paths[0])
|
||||||
|
row, _ = total(session, since, until)
|
||||||
show("session", row)
|
show("session", row)
|
||||||
print(f"hours worked: {hours(paths[0], since, until):.2f}")
|
worked_hours = hours(paths[0], since, until)
|
||||||
|
print(f"hours worked: {worked_hours:.2f}")
|
||||||
|
|
||||||
helpers = {}
|
helpers = {}
|
||||||
for path in glob.glob(os.path.join(os.path.splitext(paths[0])[0], "subagents", "*.jsonl")):
|
for path in glob.glob(os.path.join(os.path.splitext(paths[0])[0], "subagents", "*.jsonl")):
|
||||||
@@ -116,12 +130,16 @@ def main():
|
|||||||
show("helper agents", total(helpers, since, until)[0])
|
show("helper agents", total(helpers, since, until)[0])
|
||||||
|
|
||||||
if option("--row"):
|
if option("--row"):
|
||||||
if len(models) > 1:
|
# Session and helper agents together, one row per model.
|
||||||
print("More than one model in this period: make a row per model (--since/--until).", file=sys.stderr)
|
everything = {**session, **{"helper:" + key: value for key, value in helpers.items()}}
|
||||||
model = max(models, key=models.get) if models else "?"
|
_, per_model = total(everything, since, until)
|
||||||
|
if not per_model:
|
||||||
|
per_model = {"?": [0, 0, 0, 0, 0]}
|
||||||
day = (since or "")[:10] or "JJJJ-MM-DD"
|
day = (since or "")[:10] or "JJJJ-MM-DD"
|
||||||
worked = f"{hours(paths[0], since, until):.2f}".replace(".", ",")
|
# The model with the most steps first; the hours go on that row only.
|
||||||
cells = [day, option("--row"), option("--version") or "", model] + [number(value) for value in row] + [worked]
|
for position, model in enumerate(sorted(per_model, key=lambda name: -per_model[name][0])):
|
||||||
|
worked = f"{worked_hours:.2f}" if position == 0 else "0.00"
|
||||||
|
cells = [day, option("--row"), option("--version") or "", model] + [number(value) for value in per_model[model]] + [worked.replace(".", ",")]
|
||||||
print("| " + " | ".join(cells) + " |")
|
print("| " + " | ".join(cells) + " |")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user