@johngaynor/ocnus 2.0.1-next.78 → 2.0.1-next.86
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.
- package/README.md +35 -14
- package/cli/lib/asks.sh +33 -10
- package/cli/lib/handoff.sh +2 -1
- package/cli/lib/host.sh +140 -104
- package/cli/ocnus +13 -9
- package/herdr/README.md +135 -45
- package/herdr/layouts/showcase.json +11 -0
- package/herdr/layouts/vibe.json +7 -2
- package/herdr/mods/needs-you/main.js +526 -0
- package/herdr/mods/needs-you/mod.json +1 -0
- package/package.json +1 -1
- package/skills/sdlc-build/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -102,8 +102,10 @@ what to put in a layout of your own. `vibe` is three columns for steering
|
|
|
102
102
|
every agent without reading code, with no files, diffs or split terminals,
|
|
103
103
|
and the dropdown again, to come back to `default`. Its middle column starts
|
|
104
104
|
with the card list, the cards that are running and every open card of the
|
|
105
|
-
space that is showing
|
|
106
|
-
|
|
105
|
+
space that is showing, and its right column is Needs you, every question
|
|
106
|
+
that waits on you in the space, each answered with a click. The
|
|
107
|
+
`layouts/vibe.json` row in [herdr/README.md](herdr/README.md#whats-here)
|
|
108
|
+
says what each column holds.
|
|
107
109
|
|
|
108
110
|
In a terminal, `ocnus install` and `ocnus help`, which `ocnus` with no
|
|
109
111
|
command is too, open with a banner: OCNUS in block letters beside Ocnus on
|
|
@@ -703,7 +705,9 @@ The first three are a card's latest hand-off, while that is `needs-human`,
|
|
|
703
705
|
and the id is its number in the store. A permission prompt's id starts with
|
|
704
706
|
`p`. `--json` prints the same as one line, for a program:
|
|
705
707
|
`{"space": …, "questions": […]}`, the list empty when none waits. Each
|
|
706
|
-
question has its `id`, `card`, `kind`, `
|
|
708
|
+
question has its `id`, `card`, `kind`, `step` (the step its agent is at:
|
|
709
|
+
its hand-off's, or for a permission prompt the step its card stands on, or
|
|
710
|
+
`null` for a card with no hand-off), `text`, `options` (a list), `at` (when
|
|
707
711
|
it was asked, in UTC), `seconds` (how long ago), `summary` (or `null`),
|
|
708
712
|
`words` (whether it can be answered in your own words) and `running`
|
|
709
713
|
(whether its agent is running, to take an answer). A merge also has `pulls`,
|
|
@@ -760,6 +764,18 @@ Only you answer. Run from inside the session of an agent ocnus started,
|
|
|
760
764
|
`task answer` sends nothing and merges nothing, and says so; `task asks`
|
|
761
765
|
lists there as anywhere.
|
|
762
766
|
|
|
767
|
+
On the `vibe` layout, Needs you does both with a click. It lists what
|
|
768
|
+
`task asks` lists for the space that is showing, the merges after the rest,
|
|
769
|
+
and keeps up on its own. A permission prompt, an approval and a merge have
|
|
770
|
+
their options as buttons, such as Yes and No, Approve, or Merge and Ask for
|
|
771
|
+
changes, and a merge an Open button for each pull request, which opens it in
|
|
772
|
+
your browser. An agent's own options are numbered rows. A click runs
|
|
773
|
+
`task answer` with that option, then shows `✓ Sent`, or what ocnus said
|
|
774
|
+
when it refused, with the buttons back. The last row, Something else,
|
|
775
|
+
answers nothing: it opens the agent, for you to answer in your own words,
|
|
776
|
+
once the opened agent (LAB-239) is there to show it. See
|
|
777
|
+
[herdr/README.md](herdr/README.md#needs-you).
|
|
778
|
+
|
|
763
779
|
A permission prompt is seen through a Claude Code hook, which `task new` and
|
|
764
780
|
`task build` give every `claude` they start: `ocnus task hold <space>
|
|
765
781
|
<card>`. Claude Code runs it beside the prompt. It writes the question to
|
|
@@ -1336,7 +1352,7 @@ read afterwards. It is off until you turn it on, and works on macOS only.
|
|
|
1336
1352
|
|
|
1337
1353
|
```sh
|
|
1338
1354
|
ocnus host on # turn recording on
|
|
1339
|
-
ocnus host report [<period>] # the host's numbers
|
|
1355
|
+
ocnus host report [<period>] # the host's numbers and the work summed up, and where the steps' time went
|
|
1340
1356
|
ocnus host report --card <space> <card> --json # what the host recorded while each of a card's steps ran, as JSON for programs
|
|
1341
1357
|
ocnus host off # turn it off, and delete every reading
|
|
1342
1358
|
ocnus host # whether recording is on, and what it has
|
|
@@ -1415,16 +1431,21 @@ of memory pressure. An average weighs each reading by its seconds in the
|
|
|
1415
1431
|
period. One of the levels is how much of the CPU recording used, its
|
|
1416
1432
|
average with watching the test runs included. A number that no reading in
|
|
1417
1433
|
the period holds, as on a Mac without it or in readings from before it was
|
|
1418
|
-
recorded, is shown as not read, never as 0. Then it
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1434
|
+
recorded, is shown as not read, never as 0. Then it sums up the work in
|
|
1435
|
+
the period by kind, never card by card, and ranks none of it. For each
|
|
1436
|
+
step, in their order from `define` to `pr`, and each phase, `write-up` then
|
|
1437
|
+
`build`: how many cards were in it, how long their agents were open in all,
|
|
1438
|
+
on average and at the longest, the CPU time they used, and the most memory
|
|
1439
|
+
one card held at once. A tab that holds its shell alone counts for none of
|
|
1440
|
+
it. For each repo's test runs that started in the period, the repos in the
|
|
1441
|
+
order of their names: how many there were, how long those that ended took
|
|
1442
|
+
in all, on average and at the longest, the CPU time they used, the most
|
|
1443
|
+
memory one held, and how many were cut short or are still going. A figure
|
|
1444
|
+
that was not read, such as the CPU time in readings from before the cores
|
|
1445
|
+
were counted, is shown as not read, and a list with none says
|
|
1446
|
+
`none recorded`. Then it says where the steps' time went: the agents' time
|
|
1447
|
+
in all on the host, waiting on the model and the rest, then the same for
|
|
1448
|
+
each step, every card's in it together, and how many steps had no split.
|
|
1428
1449
|
|
|
1429
1450
|
`ocnus host report --card <space> <card> --json` gives a program what
|
|
1430
1451
|
the host recorded while each of a card's steps ran, as one line of JSON, so
|
package/cli/lib/asks.sh
CHANGED
|
@@ -313,14 +313,35 @@ ask_pulls() {
|
|
|
313
313
|
done
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
# The step each card of a space stands on, as one JSON object by card, for
|
|
317
|
+
# the permission prompts: the step that comes next when the card's latest
|
|
318
|
+
# hand-off is done, and that hand-off's own step otherwise, as the Step
|
|
319
|
+
# counts section places a card (stand_sql, in handoff.sh). A card with no
|
|
320
|
+
# hand-off is not in it.
|
|
321
|
+
# asks_stands <space>
|
|
322
|
+
asks_stands() {
|
|
323
|
+
local out=''
|
|
324
|
+
if [ -e "$STORE" ]; then
|
|
325
|
+
out=$(store "$STORE" "select json_group_object(card, stand) from (
|
|
326
|
+
select card, $(stand_sql) as stand
|
|
327
|
+
from (select *, row_number() over (partition by card order by id desc) as nth
|
|
328
|
+
from handoffs where space = $(sql_str "$1"))
|
|
329
|
+
where nth = 1);") ||
|
|
330
|
+
die "could not read the hand-offs in $STORE. It may not be ocnus's store."
|
|
331
|
+
fi
|
|
332
|
+
[ -n "$out" ] || out='{}'
|
|
333
|
+
printf '%s\n' "$out"
|
|
334
|
+
}
|
|
335
|
+
|
|
316
336
|
# Every question that waits on the human in a space, a line of JSON each, as
|
|
317
337
|
# `task asks --json` gives one, and with it what `task answer` needs: asked,
|
|
318
|
-
# the time it was asked in seconds since 1970, its
|
|
319
|
-
#
|
|
320
|
-
#
|
|
321
|
-
#
|
|
322
|
-
#
|
|
323
|
-
#
|
|
338
|
+
# the time it was asked in seconds since 1970, and its terminal and pid for
|
|
339
|
+
# a permission prompt. Each has its step: the step of its hand-off, or for a
|
|
340
|
+
# permission prompt the step its card stands on (asks_stands), null for a
|
|
341
|
+
# card with no hand-off. It reads the store, the watch's files, the hooks'
|
|
342
|
+
# files and hc, and changes nothing. The space's tabs are read only when a
|
|
343
|
+
# hand-off waits, and a hand-off's agent counts as not running when its tab
|
|
344
|
+
# is closed or holds its own shell alone, as it is with no tab to look in.
|
|
324
345
|
# asks_collect <space> <the space's folder>
|
|
325
346
|
asks_collect() {
|
|
326
347
|
local space=$1 dir=$2 sep=$'\x1f' rows='' tabs=0 now
|
|
@@ -357,7 +378,7 @@ asks_collect() {
|
|
|
357
378
|
die "could not put $card's question together with jq."
|
|
358
379
|
done <<< "$rows"
|
|
359
380
|
|
|
360
|
-
local f q pid term
|
|
381
|
+
local f q pid term stands=''
|
|
361
382
|
now=$(date +%s)
|
|
362
383
|
for f in "$ASKS_DIR/$space"/*/p*.json; do
|
|
363
384
|
[ -f "$f" ] || continue
|
|
@@ -365,20 +386,22 @@ asks_collect() {
|
|
|
365
386
|
[ -n "$q" ] || continue
|
|
366
387
|
pid=$(printf '%s' "$q" | jq -r '.pid // empty') term=$(printf '%s' "$q" | jq -r '.terminal // empty')
|
|
367
388
|
ask_alive "$pid" && [ -n "$term" ] && [ "$(terminal_doing "$term")" = blocked ] || continue
|
|
389
|
+
[ -n "$stands" ] || stands=$(asks_stands "$space") || exit 1
|
|
368
390
|
printf '%s' "$q" | jq -c --argjson now "$now" --arg allow "$ASK_ALLOW" --arg refuse "$ASK_REFUSE" \
|
|
369
|
-
--arg always "$ASK_ALWAYS" '
|
|
391
|
+
--arg always "$ASK_ALWAYS" --argjson stands "$stands" '
|
|
370
392
|
(.asked | if type == "number" then . else $now end) as $asked
|
|
371
393
|
| {id, card, kind: "permission", text: (.text | if type == "string" then . else "" end),
|
|
372
394
|
options: ([$allow, $refuse] + (if .always == true then [$always] else [] end)),
|
|
373
395
|
at: (.at | if type == "string" then . else ($asked | todate) end),
|
|
374
396
|
seconds: ([$now - $asked, 0] | max), summary: null, words: false, running: true,
|
|
375
|
-
tool: (.tool | if type == "string" then . else null end),
|
|
397
|
+
tool: (.tool | if type == "string" then . else null end), step: ($stands[.card] // null),
|
|
398
|
+
asked: $asked, terminal, pid}' || true
|
|
376
399
|
done
|
|
377
400
|
}
|
|
378
401
|
|
|
379
402
|
# jq: a question as `task asks --json` gives it, without what only `task
|
|
380
403
|
# answer` reads.
|
|
381
|
-
ASK_PUBLIC='del(.asked, .
|
|
404
|
+
ASK_PUBLIC='del(.asked, .terminal, .pid)'
|
|
382
405
|
|
|
383
406
|
# List the questions that wait on the human in a space, oldest first: each
|
|
384
407
|
# with its card, its kind, its id, when it was asked, its text, any summary,
|
package/cli/lib/handoff.sh
CHANGED
|
@@ -454,7 +454,8 @@ COUNT_STEPS='define plan breakdown start build review pr'
|
|
|
454
454
|
# stands on no step, and this is null for it. The counts and the card list
|
|
455
455
|
# both place a card by it, as the column stand of the table latest
|
|
456
456
|
# (log_cards), so a card's dot in the Step counts section and its row in the
|
|
457
|
-
# card list are on the same step.
|
|
457
|
+
# card list are on the same step. `task asks` gives a permission prompt
|
|
458
|
+
# the step its card stands on by it too (asks_stands, in asks.sh).
|
|
458
459
|
stand_sql() {
|
|
459
460
|
printf '%s' "case when status = 'done'
|
|
460
461
|
then case next when 'setup' then 'start' when 'merged' then null else next end
|
package/cli/lib/host.sh
CHANGED
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
# so that no process counts toward two, and the shares add up to the agents'
|
|
28
28
|
# totals. A share names its terminal's work by the card its labels give, the
|
|
29
29
|
# phase its tab gives, and the step that card is in, from the hand-off store,
|
|
30
|
-
# which the recorder only ever reads. `host report`
|
|
31
|
-
#
|
|
30
|
+
# which the recorder only ever reads. `host report` sums them up by step and
|
|
31
|
+
# by phase, never card by card.
|
|
32
32
|
#
|
|
33
33
|
# Each reading also counts the agents open as working or waiting, and each
|
|
34
34
|
# share says which its agent was. An agent is working while it takes its
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
# memory it held at once. A test run is named by its card and repo alone.
|
|
44
44
|
# Its command is kept only as a fingerprint, a number the same for the same
|
|
45
45
|
# command and from which its text cannot be read back, and nothing else of
|
|
46
|
-
# its command line is kept. `host report`
|
|
46
|
+
# its command line is kept. `host report` sums the test runs up by repo.
|
|
47
47
|
#
|
|
48
48
|
# With each reading go the shares of the test runs going then, too, each
|
|
49
49
|
# worked out as a terminal's is, from the processes under the run's job,
|
|
@@ -1214,11 +1214,11 @@ host_day() {
|
|
|
1214
1214
|
# How the host worked over a period, in its numbers alone: how much of the
|
|
1215
1215
|
# period was recorded, in all and on each day, with time with no reading
|
|
1216
1216
|
# shown as missing, never as idle (host_report_sql). Then the host's numbers
|
|
1217
|
-
# summed up (host_numbers_sql), the
|
|
1218
|
-
#
|
|
1219
|
-
# (host_split_sql).
|
|
1217
|
+
# summed up (host_numbers_sql), the work summed up by step, by phase and by
|
|
1218
|
+
# repo (host_work_sql), and it ends with where the steps' time went, by step
|
|
1219
|
+
# (host_split_sql). It ranks nothing, and names no card.
|
|
1220
1220
|
host_report() {
|
|
1221
|
-
local period=${1:-7d} now start end n first last row have
|
|
1221
|
+
local period=${1:-7d} now start end n first last row have
|
|
1222
1222
|
# A card's readings, as JSON, are a form of their own.
|
|
1223
1223
|
for n in "$@"; do
|
|
1224
1224
|
case $n in --card | --json) host_card "$@"; return ;; esac
|
|
@@ -1264,23 +1264,13 @@ host_report() {
|
|
|
1264
1264
|
fi
|
|
1265
1265
|
# A store the recorder has not opened since a table or a column came has
|
|
1266
1266
|
# none of it, and the report only reads the store, so it never adds them.
|
|
1267
|
-
# A
|
|
1268
|
-
#
|
|
1269
|
-
# and where the steps' time went needs the shares, and the splits to split
|
|
1270
|
-
# it.
|
|
1267
|
+
# A column the store lacks is read as null, so that its number is not
|
|
1268
|
+
# read, and a table it lacks as one with no rows (host_select).
|
|
1271
1269
|
have=$(host_columns) || have=' '
|
|
1272
|
-
case $have in *' shares.'*) works=1 ;; esac
|
|
1273
|
-
case $have in *' splits.'*) splits=$works ;; esac
|
|
1274
|
-
case $have in *' readings.cores '*) case $have in *' test_runs.'*) ranks=$works ;; esac ;; esac
|
|
1275
1270
|
store "$HOST_DB" "$(host_report_sql "$start" "$end" "$period")" || die "could not read $HOST_DB"
|
|
1276
1271
|
store "$HOST_DB" "$(host_numbers_sql "$start" "$end" "$have")" || die "could not read $HOST_DB"
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
else
|
|
1280
|
-
say ''
|
|
1281
|
-
say 'No step, phase or test run was recorded in this period.'
|
|
1282
|
-
fi
|
|
1283
|
-
store "$HOST_DB" "$(host_split_sql "$start" "$end" "$works" "$splits")" || die "could not read $HOST_DB"
|
|
1272
|
+
store "$HOST_DB" "$(host_work_sql "$start" "$end" "$have")" || die "could not read $HOST_DB"
|
|
1273
|
+
store "$HOST_DB" "$(host_split_sql "$start" "$end" "$have")" || die "could not read $HOST_DB"
|
|
1284
1274
|
}
|
|
1285
1275
|
|
|
1286
1276
|
# The tables and the columns the readings' store has, each column as its
|
|
@@ -1290,6 +1280,33 @@ host_columns() {
|
|
|
1290
1280
|
from sqlite_master m join pragma_table_info(m.name) p where m.type = 'table';"
|
|
1291
1281
|
}
|
|
1292
1282
|
|
|
1283
|
+
# SQL that selects the columns $3 onward of the table $2, from a store whose
|
|
1284
|
+
# tables and columns $1 lists, as host_columns gives them: a column the
|
|
1285
|
+
# store lacks as null, and no row at all when it lacks the table.
|
|
1286
|
+
host_select() {
|
|
1287
|
+
local have=$1 table=$2 c cols=''
|
|
1288
|
+
shift 2
|
|
1289
|
+
for c in "$@"; do
|
|
1290
|
+
case $have in *" $table.$c "*) cols="$cols, $c" ;; *) cols="$cols, null as $c" ;; esac
|
|
1291
|
+
done
|
|
1292
|
+
case $have in
|
|
1293
|
+
*" $table."*) printf 'select %s from %s' "${cols#, }" "$table" ;;
|
|
1294
|
+
*) printf 'select %s where 0' "${cols#, }" ;;
|
|
1295
|
+
esac
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
# SQL for the place of the value of the column $1 among the names $2 onward,
|
|
1299
|
+
# from 1 in their order; a value that is none of them comes after them all.
|
|
1300
|
+
host_order() {
|
|
1301
|
+
local col=$1 name sql='' n=0
|
|
1302
|
+
shift
|
|
1303
|
+
for name in "$@"; do
|
|
1304
|
+
n=$((n + 1))
|
|
1305
|
+
sql="$sql when '$name' then $n"
|
|
1306
|
+
done
|
|
1307
|
+
printf 'case %s%s else %s end' "$col" "$sql" $((n + 1))
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1293
1310
|
# The top of the report, for the period from $1 to $2, named $3: how much of
|
|
1294
1311
|
# it was recorded and how much is missing, then the same for each day. A
|
|
1295
1312
|
# reading covers the secs before its at, so each one counts for the part of
|
|
@@ -1459,128 +1476,147 @@ host_state() {
|
|
|
1459
1476
|
else $shown || case when $left > 0 then ', $none ' || $(sql_took "($left)") else '' end end"
|
|
1460
1477
|
}
|
|
1461
1478
|
|
|
1462
|
-
# The
|
|
1463
|
-
#
|
|
1464
|
-
#
|
|
1465
|
-
#
|
|
1466
|
-
#
|
|
1467
|
-
#
|
|
1479
|
+
# The work from $1 to $2, summed up by kind, never card by card: each step,
|
|
1480
|
+
# each phase, and each repo's test runs. $3 lists the store's tables and
|
|
1481
|
+
# columns, as host_columns gives them: a column the store lacks is read as
|
|
1482
|
+
# null, and a table it lacks as one with no rows (host_select).
|
|
1483
|
+
#
|
|
1484
|
+
# A step or a phase counts each card's shares while its agent was open, for
|
|
1485
|
+
# the part of their reading in the period, as the report counts a reading,
|
|
1486
|
+
# and once a reading however many of the card's tabs were in it: so a
|
|
1487
|
+
# step's time in all is the time its agents were open, which where the
|
|
1488
|
+
# steps' time went splits. A card's CPU time in it is its shares' share of
|
|
1489
|
+
# all cores, over that part, on the reading's cores, and its memory the most
|
|
1490
|
+
# its shares held in one reading. Its line gives how many cards were in it,
|
|
1491
|
+
# their time in all, on average and at the longest, their CPU time added up,
|
|
1492
|
+
# and the most memory one of them held.
|
|
1493
|
+
#
|
|
1494
|
+
# A repo's line counts its test runs that started in the period: how many,
|
|
1495
|
+
# the time in all, on average and at the longest of those that ended, their
|
|
1496
|
+
# CPU time added up, and the most memory one held. When any were cut short,
|
|
1497
|
+
# ended by the recorder as their process had gone, or are still going, it
|
|
1498
|
+
# ends with how many of each.
|
|
1468
1499
|
#
|
|
1469
|
-
#
|
|
1470
|
-
#
|
|
1471
|
-
#
|
|
1472
|
-
#
|
|
1473
|
-
#
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1500
|
+
# The order is fixed, never by size: the steps from define to pr, write-up
|
|
1501
|
+
# before build, the repos by name. A list with none says none recorded, and
|
|
1502
|
+
# with no step, phase or test run at all, it says so in place of the lists.
|
|
1503
|
+
# A figure no row holds says not read, as SQLite's printf would print a null
|
|
1504
|
+
# as 0, and sql_took of a null is null.
|
|
1505
|
+
host_work_sql() {
|
|
1506
|
+
local s=$1 e=$2 have=$3 line
|
|
1507
|
+
line="' ' || printf('%-18s ', name) || many || noun || ', '
|
|
1508
|
+
|| case when ran is null then 'time not read'
|
|
1509
|
+
else $(sql_took ran) || ' in all, ' || $(sql_took mean) || ' on average, ' || $(sql_took longest) || ' at the longest' end
|
|
1510
|
+
|| '; CPU time ' || case when cpu is null then 'not read' else $(sql_took cpu) end
|
|
1511
|
+
|| '; memory ' || case when mem is null then 'not read' else mem || ' MB at most' end || tail"
|
|
1481
1512
|
cat <<EOF
|
|
1482
1513
|
with
|
|
1483
|
-
|
|
1484
|
-
select card, repo, started, ended, secs, cpu_secs, mem_mb, cut from test_runs where started >= $s and started < $e),
|
|
1514
|
+
r(at, secs, cores) as ($(host_select "$have" readings at secs cores)),
|
|
1485
1515
|
parts(at, d, cores) as (
|
|
1486
|
-
select at, max(0, min(at, $e) - max(at - secs, $s)), cores from
|
|
1516
|
+
select at, max(0, min(at, $e) - max(at - secs, $s)), cores from r
|
|
1487
1517
|
where at > $s and at < $e + $HOST_GAP and at - secs < $e),
|
|
1518
|
+
sh(at, card, phase, step, open, cpu, mem) as ($(host_select "$have" shares at card phase step open cpu mem_mb)),
|
|
1488
1519
|
owned(kind, card, what, at, d, cpu, mem) as (
|
|
1489
|
-
select 'step', s.card, s.step, p.at, p.d, s.cpu * p.d * p.cores / 100.0, s.
|
|
1490
|
-
from parts p join
|
|
1520
|
+
select 'step', s.card, s.step, p.at, p.d, s.cpu * p.d * p.cores / 100.0, s.mem
|
|
1521
|
+
from parts p join sh s on s.at = p.at where s.open = 1 and s.card is not null and s.step is not null
|
|
1491
1522
|
union all
|
|
1492
|
-
select 'phase', s.card, s.phase, p.at, p.d, s.cpu * p.d * p.cores / 100.0, s.
|
|
1493
|
-
from parts p join
|
|
1523
|
+
select 'phase', s.card, s.phase, p.at, p.d, s.cpu * p.d * p.cores / 100.0, s.mem
|
|
1524
|
+
from parts p join sh s on s.at = p.at where s.open = 1 and s.card is not null and s.phase is not null),
|
|
1494
1525
|
once(kind, card, what, d, cpu, mem) as (
|
|
1495
1526
|
select kind, card, what, max(d), sum(cpu), sum(mem) from owned group by kind, card, what, at),
|
|
1496
1527
|
totals(kind, card, what, ran, cpu, mem) as (
|
|
1497
|
-
select kind, card, what, sum(d),
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1528
|
+
select kind, card, what, sum(d), sum(cpu), max(mem) from once group by kind, card, what),
|
|
1529
|
+
t(repo, started, ended, secs, cpu, mem, cut) as ($(host_select "$have" test_runs repo started ended secs cpu_secs mem_mb cut)),
|
|
1530
|
+
runs(repo, many, ran, mean, longest, cpu, mem, cut, going) as (
|
|
1531
|
+
select repo, count(*), sum(took), avg(took), max(took), sum(cpu), max(mem),
|
|
1532
|
+
sum(case when cut = 1 then 1 else 0 end), sum(case when ended is null then 1 else 0 end)
|
|
1533
|
+
from (select repo, case when ended is not null then secs end as took, ended, cpu, mem, cut from t
|
|
1534
|
+
where started >= $s and started < $e)
|
|
1535
|
+
group by repo),
|
|
1536
|
+
sums(n, o, name, many, noun, ran, mean, longest, cpu, mem, tail) as (
|
|
1537
|
+
select case kind when 'step' then 1 else 2 end,
|
|
1538
|
+
case kind when 'step' then $(host_order what $HOST_WRITE_UP_STEPS $HOST_BUILD_STEPS) else $(host_order what write-up build) end,
|
|
1539
|
+
what, count(*), case when count(*) = 1 then ' card' else ' cards' end,
|
|
1540
|
+
sum(ran), avg(ran), max(ran), sum(cpu), max(mem), ''
|
|
1541
|
+
from totals group by kind, what
|
|
1502
1542
|
union all
|
|
1503
|
-
select
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
select
|
|
1520
|
-
|
|
1521
|
-
union all select n,
|
|
1522
|
-
|
|
1523
|
-
where yes and not exists (select 1 from ranked r where r.n = h.n)
|
|
1524
|
-
union all select n, k, line from ranked where k <= 10)
|
|
1525
|
-
select line from lines order by n, k;
|
|
1543
|
+
select 3, 1, repo, many, case when many = 1 then ' run' else ' runs' end, ran, mean, longest, cpu, mem,
|
|
1544
|
+
case when cut > 0 then '; ' || cut || ' cut short' else '' end
|
|
1545
|
+
|| case when going > 0 then case when cut > 0 then ', ' else '; ' end || going || ' still going' else '' end
|
|
1546
|
+
from runs),
|
|
1547
|
+
shown(n, o, name, line) as (
|
|
1548
|
+
select n, o, name, $line from (
|
|
1549
|
+
select n, o, name, many, noun, cast(round(ran) as integer) as ran, cast(round(mean) as integer) as mean,
|
|
1550
|
+
cast(round(longest) as integer) as longest, cast(round(cpu) as integer) as cpu,
|
|
1551
|
+
cast(round(mem) as integer) as mem, tail
|
|
1552
|
+
from sums)),
|
|
1553
|
+
heads(n, head) as (values (1, 'Steps:'), (2, 'Phases:'), (3, 'Test runs:')),
|
|
1554
|
+
found(yes) as (select exists (select 1 from sums)),
|
|
1555
|
+
lines(n, o, name, line) as (
|
|
1556
|
+
select 0, 0, '', ''
|
|
1557
|
+
union all select 0, 1, '', 'No step, phase or test run was recorded in this period.' from found where not yes
|
|
1558
|
+
union all select n, 0, '', head from heads, found where yes
|
|
1559
|
+
union all select n, 1, '', ' none recorded' from heads h, found
|
|
1560
|
+
where yes and not exists (select 1 from sums s where s.n = h.n)
|
|
1561
|
+
union all select n, o, name, line from shown)
|
|
1562
|
+
select line from lines order by n, o, name;
|
|
1526
1563
|
EOF
|
|
1527
1564
|
}
|
|
1528
1565
|
|
|
1529
|
-
# Where the steps' time went from $1 to $2, from the
|
|
1530
|
-
#
|
|
1531
|
-
#
|
|
1532
|
-
#
|
|
1533
|
-
#
|
|
1534
|
-
#
|
|
1535
|
-
#
|
|
1536
|
-
#
|
|
1537
|
-
#
|
|
1538
|
-
# split,
|
|
1566
|
+
# Where the steps' time went from $1 to $2, from the splits: first the
|
|
1567
|
+
# agents' time in all on the host, waiting on the model and the rest, then
|
|
1568
|
+
# the same for each step, every card's splits in it added up, in the order
|
|
1569
|
+
# the steps go, from define to pr. Each split counts for the part of its
|
|
1570
|
+
# reading in the period, as the report counts a reading: its seconds on the
|
|
1571
|
+
# host and on the model in that proportion, and the rest is that part less
|
|
1572
|
+
# the two. Each line says how long it was open, and its three parts, to the
|
|
1573
|
+
# second, which add up to that. Then how many steps were open in the period
|
|
1574
|
+
# with no split, each card's step counted once. With no split, it says no
|
|
1575
|
+
# step was split, and why. $3 lists the store's tables and columns, as
|
|
1576
|
+
# host_columns gives them: a store with no table of shares or of splits is
|
|
1577
|
+
# read as one with none of them (host_select).
|
|
1539
1578
|
HOST_NO_SPLIT="an agent's time is split only when it starts in Claude Code while recording is on"
|
|
1540
1579
|
host_split_sql() {
|
|
1541
|
-
local s=$1 e=$2
|
|
1580
|
+
local s=$1 e=$2 have=$3 line why
|
|
1542
1581
|
why=$(sql_str "$HOST_NO_SPLIT")
|
|
1543
|
-
|
|
1544
|
-
[ "${3:-0}" = 1 ] || shares='select null, null, null, null where 0'
|
|
1545
|
-
splits='select at, card, step, host_secs, model_secs from splits'
|
|
1546
|
-
[ "${4:-0}" = 1 ] || splits='select null, null, null, null, null where 0'
|
|
1547
|
-
line="' ' || printf('%-24s', name) || ' open ' || $(sql_took d) || ': on the host ' || $(sql_took h)
|
|
1582
|
+
line="' ' || printf('%-18s ', name) || 'open ' || $(sql_took d) || ': on the host ' || $(sql_took h)
|
|
1548
1583
|
|| ', waiting on the model ' || $(sql_took m) || ', the rest ' || $(sql_took r)"
|
|
1549
1584
|
cat <<EOF
|
|
1550
1585
|
with
|
|
1551
1586
|
parts(at, secs, d) as (
|
|
1552
1587
|
select at, secs, max(0, min(at, $e) - max(at - secs, $s)) from readings
|
|
1553
1588
|
where at > $s and at < $e + $HOST_GAP and at - secs < $e and secs > 0),
|
|
1554
|
-
sh(at, card, step, open) as ($shares),
|
|
1555
|
-
x(at, card, step, host, model) as ($splits),
|
|
1589
|
+
sh(at, card, step, open) as ($(host_select "$have" shares at card step open)),
|
|
1590
|
+
x(at, card, step, host, model) as ($(host_select "$have" splits at card step host_secs model_secs)),
|
|
1556
1591
|
sp(card, step, d, host, model) as (
|
|
1557
1592
|
select x.card, x.step, p.d, 1.0 * x.host * p.d / p.secs, 1.0 * x.model * p.d / p.secs
|
|
1558
1593
|
from parts p join x on x.at = p.at),
|
|
1559
1594
|
steps(card, step, d, host, model) as (
|
|
1560
1595
|
select card, step, sum(d), sum(host), sum(model) from sp
|
|
1561
1596
|
where card is not null and step is not null group by card, step),
|
|
1562
|
-
shown(k, name, d, host, model) as (
|
|
1563
|
-
select 0, 'all agents', d, host, model from (select count(*) n, sum(d) d, sum(host) host, sum(model) model from sp) where n > 0
|
|
1597
|
+
shown(k, o, name, d, host, model) as (
|
|
1598
|
+
select 0, 0, 'all agents', d, host, model from (select count(*) n, sum(d) d, sum(host) host, sum(model) model from sp) where n > 0
|
|
1564
1599
|
union all
|
|
1565
|
-
select
|
|
1566
|
-
|
|
1567
|
-
|
|
1600
|
+
select 1, $(host_order step $HOST_WRITE_UP_STEPS $HOST_BUILD_STEPS), step, sum(d), sum(host), sum(model)
|
|
1601
|
+
from steps group by step),
|
|
1602
|
+
timed(k, o, name, d, h, m, r) as (
|
|
1603
|
+
select k, o, name, d, cast(round(host) as integer),
|
|
1568
1604
|
cast(round(host + model) as integer) - cast(round(host) as integer),
|
|
1569
1605
|
max(0, d - cast(round(host + model) as integer))
|
|
1570
|
-
from shown
|
|
1606
|
+
from shown),
|
|
1571
1607
|
unsplit(n) as (
|
|
1572
1608
|
select count(*) from (
|
|
1573
1609
|
select distinct sh.card, sh.step from parts p join sh on sh.at = p.at
|
|
1574
1610
|
where sh.open = 1 and sh.card is not null and sh.step is not null
|
|
1575
1611
|
except select card, step from steps)),
|
|
1576
|
-
lines(k, line) as (
|
|
1577
|
-
select -2, '' union all select -1, 'Where the steps'' time went:'
|
|
1578
|
-
union all select k, $line from timed
|
|
1579
|
-
union all select
|
|
1612
|
+
lines(k, o, name, line) as (
|
|
1613
|
+
select -2, 0, '', '' union all select -1, 0, '', 'Where the steps'' time went:'
|
|
1614
|
+
union all select k, o, name, $line from timed
|
|
1615
|
+
union all select 2, 0, '', ' ' || n || case when n = 1 then ' step' else ' steps' end
|
|
1580
1616
|
|| ' had no split, as ' || $why from unsplit
|
|
1581
1617
|
where n > 0 and exists (select 1 from sp)
|
|
1582
|
-
union all select 0, ' no step was split, as ' || $why where not exists (select 1 from sp))
|
|
1583
|
-
select line from lines order by k;
|
|
1618
|
+
union all select 0, 0, '', ' no step was split, as ' || $why where not exists (select 1 from sp))
|
|
1619
|
+
select line from lines order by k, o, name;
|
|
1584
1620
|
EOF
|
|
1585
1621
|
}
|
|
1586
1622
|
|
package/cli/ocnus
CHANGED
|
@@ -127,10 +127,9 @@ Usage:
|
|
|
127
127
|
ocnus host on record it every 10 seconds while an agent is open
|
|
128
128
|
ocnus host off stop recording, and delete every reading
|
|
129
129
|
ocnus host report [<period>] the host's CPU, memory, disk, network, and power and heat,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
YYYY-MM-DD, or <day>..<day>
|
|
130
|
+
and the work by step, phase and repo, summed up, and where
|
|
131
|
+
the steps' time went: <n>d or <n>h back from now (7d when
|
|
132
|
+
none is given), a day YYYY-MM-DD, or <day>..<day>
|
|
134
133
|
ocnus host report --card <space> <card> --json
|
|
135
134
|
what the host recorded while each of a card's steps ran, as
|
|
136
135
|
one line of JSON for programs: each step's start and end,
|
|
@@ -415,9 +414,13 @@ reading by its seconds in the period. One of the levels is how much of the
|
|
|
415
414
|
CPU recording used, its average with watching the test runs included. A
|
|
416
415
|
number that no reading in the period holds, as on a Mac without it or in
|
|
417
416
|
readings from before it was recorded, is shown as not read, never as 0.
|
|
418
|
-
Then it
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
Then it sums up the work by kind, never card by card, and ranks none of
|
|
418
|
+
it: for each step from define to pr, and each phase, how many cards were in
|
|
419
|
+
it, how long their agents were open in all, on average and at the longest,
|
|
420
|
+
the CPU time they used and the most memory one held at once; and for each
|
|
421
|
+
repo's test runs, how many there were, how long they took in all, on
|
|
422
|
+
average and at the longest, the CPU time they used, the most memory one
|
|
423
|
+
held, and how many were cut short or are still going.
|
|
421
424
|
|
|
422
425
|
While the host is recorded, `task new` and `task build` also start claude
|
|
423
426
|
with hooks that mark when its agent starts and stops, is given a prompt,
|
|
@@ -427,8 +430,9 @@ or did. From them each reading splits each agent's time into time on the
|
|
|
427
430
|
host, while its tools run, waiting on the model, and the rest, such as
|
|
428
431
|
waiting on you. Then `host report` says where the steps' time went: the
|
|
429
432
|
agents' time in all on the host, waiting on the model and the rest, the
|
|
430
|
-
same for
|
|
431
|
-
agent started in another harness or while recording was off
|
|
433
|
+
same for each step, every card's in it together, and how many steps had no
|
|
434
|
+
split, as an agent started in another harness or while recording was off
|
|
435
|
+
has none.
|
|
432
436
|
|
|
433
437
|
Each wait on the model is kept too, as its start and end alone, for 90
|
|
434
438
|
days.
|