@johngaynor/ocnus 2.0.1-next.24 → 2.0.1-next.69
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 +459 -42
- package/cli/lib/agents.sh +32 -16
- package/cli/lib/asks.sh +762 -0
- package/cli/lib/banner.sh +181 -0
- package/cli/lib/brief.sh +375 -0
- package/cli/lib/chain.sh +363 -0
- package/cli/lib/close.sh +5 -3
- package/cli/lib/cost.sh +500 -0
- package/cli/lib/github.sh +106 -26
- package/cli/lib/guard.sh +38 -11
- package/cli/lib/handoff.sh +196 -31
- package/cli/lib/host.sh +172 -1
- package/cli/lib/linear.sh +198 -1
- package/cli/lib/links.sh +6 -3
- package/cli/lib/merges.sh +126 -27
- package/cli/lib/sessions.sh +132 -0
- package/cli/lib/settings.sh +31 -15
- package/cli/lib/task.sh +159 -64
- package/cli/lib/tests.sh +300 -4
- package/cli/lib/usage.sh +70 -25
- package/cli/ocnus +234 -37
- package/herdr/README.md +756 -79
- package/herdr/layouts/default.json +10 -0
- package/herdr/layouts/showcase.json +291 -0
- package/herdr/layouts/vibe.json +162 -0
- package/herdr/layouts/vibe.svg +41 -0
- package/herdr/mods/agent-settings/main.js +19 -7
- package/herdr/mods/names/main.js +22 -4
- package/herdr/mods/step-counts/main.js +281 -0
- package/herdr/mods/step-counts/mod.json +1 -0
- package/package.json +1 -1
- package/prompts/task-new.md +1 -1
- package/skills/brief/SKILL.md +8 -0
- package/skills/sdlc-breakdown/SKILL.md +5 -5
package/cli/lib/host.sh
CHANGED
|
@@ -63,6 +63,11 @@
|
|
|
63
63
|
# From the same marks, each wait on the model is kept too, as its start and
|
|
64
64
|
# end alone, by the reading it ended in.
|
|
65
65
|
#
|
|
66
|
+
# `host report --card <space> <card> --json` gives a program the readings
|
|
67
|
+
# taken while each of a card's steps ran, as one line of JSON (host_card):
|
|
68
|
+
# the whole host's CPU and memory, with each step's start and end from the
|
|
69
|
+
# hand-off store, which it only reads.
|
|
70
|
+
#
|
|
66
71
|
# A share's card, phase and step, a split's, a wait's, and a test run's card
|
|
67
72
|
# and repo, are the only text the readings hold, and only the values
|
|
68
73
|
# ocnus gives them: a card ID, a phase, a step of it, and the name of
|
|
@@ -203,7 +208,7 @@ host_table() {
|
|
|
203
208
|
[ -z "$sql" ] || store "$HOST_DB" "begin; ${sql}commit;"
|
|
204
209
|
}
|
|
205
210
|
|
|
206
|
-
HOST_USAGE='usage: ocnus host [on|off|report [<period>]] (see: ocnus help)'
|
|
211
|
+
HOST_USAGE='usage: ocnus host [on|off|report [<period>]|report --card <space> <card> --json] (see: ocnus help)'
|
|
207
212
|
HOST_PERIODS='a period is <n>d or <n>h back from now, like 7d or 12h; a day, like 2026-11-29; or two days and every day between, like 2026-11-01..2026-11-29'
|
|
208
213
|
|
|
209
214
|
# --- on and off -------------------------------------------------------------
|
|
@@ -1211,6 +1216,10 @@ host_day() {
|
|
|
1211
1216
|
# the steps' time went (host_split_sql).
|
|
1212
1217
|
host_report() {
|
|
1213
1218
|
local period=${1:-7d} now start end n first last row works splits
|
|
1219
|
+
# A card's readings, as JSON, are a form of their own.
|
|
1220
|
+
for n in "$@"; do
|
|
1221
|
+
case $n in --card | --json) host_card "$@"; return ;; esac
|
|
1222
|
+
done
|
|
1214
1223
|
[ "$#" -le 1 ] || die "$HOST_USAGE"
|
|
1215
1224
|
now=$(date +%s)
|
|
1216
1225
|
case $period in
|
|
@@ -1460,6 +1469,168 @@ select line from lines order by k;
|
|
|
1460
1469
|
EOF
|
|
1461
1470
|
}
|
|
1462
1471
|
|
|
1472
|
+
# The readings taken while each of a card's steps ran, as one line of JSON:
|
|
1473
|
+
# `host report --card <space> <card> --json`. Anything else it is asked is
|
|
1474
|
+
# refused on stderr, with nothing on stdout, so that a program never reads
|
|
1475
|
+
# words as JSON.
|
|
1476
|
+
#
|
|
1477
|
+
# A step is each time the card was in it: hand-offs of one step in a row,
|
|
1478
|
+
# from the hand-off before the first to the last, so the time it waited on
|
|
1479
|
+
# the human is inside it. The times are log_view's, as `task log` shows
|
|
1480
|
+
# them, so the two cannot disagree. A `new` or a `start` row has no time
|
|
1481
|
+
# there, so it has no entry here. The step under way runs to now and is
|
|
1482
|
+
# open: the one the log counts as under way (card_agent in agents.sh), or
|
|
1483
|
+
# one whose question still waits.
|
|
1484
|
+
#
|
|
1485
|
+
# A reading counts for its seconds inside the step, as the report counts
|
|
1486
|
+
# one in a period. A step with more than HOST_CARD_POINTS readings is cut
|
|
1487
|
+
# into that many equal parts, to the second, and each part with a reading in
|
|
1488
|
+
# it gives one point: the average CPU and memory over its recorded seconds,
|
|
1489
|
+
# and the worst memory pressure in it. Time with no reading gives no point,
|
|
1490
|
+
# so it is never a number. With recording off, or with no readings kept, the
|
|
1491
|
+
# steps are still listed, each with none.
|
|
1492
|
+
HOST_CARD_POINTS=60
|
|
1493
|
+
HOST_CARD_FORM='ocnus host report --card <space> <card> --json'
|
|
1494
|
+
host_card() {
|
|
1495
|
+
local name='' card='' json=0 asked=0
|
|
1496
|
+
while [ "$#" -gt 0 ]; do
|
|
1497
|
+
case $1 in
|
|
1498
|
+
--json)
|
|
1499
|
+
[ "$json" = 0 ] || die "--json is given once: $HOST_CARD_FORM"
|
|
1500
|
+
json=1
|
|
1501
|
+
;;
|
|
1502
|
+
--card)
|
|
1503
|
+
[ "$asked" = 0 ] || die "--card is given once, for one card: $HOST_CARD_FORM"
|
|
1504
|
+
asked=1
|
|
1505
|
+
case ${2:-} in '' | --*) die "--card takes a space and a card: $HOST_CARD_FORM" ;; esac
|
|
1506
|
+
case ${3:-} in '' | --*) die "--card takes a space and a card: $HOST_CARD_FORM" ;; esac
|
|
1507
|
+
name=$2 card=$3
|
|
1508
|
+
shift 2
|
|
1509
|
+
;;
|
|
1510
|
+
*)
|
|
1511
|
+
[ "$asked" = 1 ] || case " $* " in *' --card '*) asked=1 ;; esac
|
|
1512
|
+
[ "$asked" = 1 ] ||
|
|
1513
|
+
die "--json needs --card: only a card's readings come as JSON, with $HOST_CARD_FORM. The report on a period is in words."
|
|
1514
|
+
die "'$1' does not go with --card: a card's readings are those of its steps, whatever the period. Ask with: $HOST_CARD_FORM"
|
|
1515
|
+
;;
|
|
1516
|
+
esac
|
|
1517
|
+
shift
|
|
1518
|
+
done
|
|
1519
|
+
[ "$asked" = 1 ] ||
|
|
1520
|
+
die "--json needs --card: only a card's readings come as JSON, with $HOST_CARD_FORM. The report on a period is in words."
|
|
1521
|
+
[ "$json" = 1 ] || die "--card needs --json: a card's readings come as JSON alone. Ask with: $HOST_CARD_FORM"
|
|
1522
|
+
space_named "$name" || die "there is no ocnus space called '$name'. See: ocnus space ls"
|
|
1523
|
+
[[ $card =~ $CARD_RE ]] || die "'$card' is not a card ID like ABC-122."
|
|
1524
|
+
card=$(printf '%s' "$card" | tr '[:lower:]' '[:upper:]')
|
|
1525
|
+
have_sqlite || die "$SQLITE is not installed, and the hand-offs and the readings are kept with it."
|
|
1526
|
+
|
|
1527
|
+
local recording=false now uri attach='' out
|
|
1528
|
+
[ ! -d "$HOST_DIR" ] || recording=true
|
|
1529
|
+
# As `task log --json` with no store: the same keys, and no steps.
|
|
1530
|
+
if [ ! -e "$STORE" ]; then
|
|
1531
|
+
printf '{"space":"%s","card":"%s","recording":%s,"steps":[]}\n' "$(json_str "$name")" "$(json_str "$card")" "$recording"
|
|
1532
|
+
return
|
|
1533
|
+
fi
|
|
1534
|
+
now=$(date +%s)
|
|
1535
|
+
# With no readings kept, a table with none stands in for them.
|
|
1536
|
+
local readings='(select 0 as at, 0 as secs, null as cpu_busy, null as mem_used_mb, null as mem_pressure where 0)'
|
|
1537
|
+
if [ -e "$HOST_DB" ]; then
|
|
1538
|
+
# In a URI, % starts an escape, ? the options and # the end.
|
|
1539
|
+
uri=${HOST_DB//\%/%25}; uri=${uri//\?/%3F}; uri=${uri//\#/%23}
|
|
1540
|
+
attach="attach $(sql_str "file:$uri?mode=ro") as host;"
|
|
1541
|
+
readings=host.readings
|
|
1542
|
+
fi
|
|
1543
|
+
# Each table is worked out once, whatever the card's length:
|
|
1544
|
+
# flagged, grouped the card's rows, numbered by the time it was in a step
|
|
1545
|
+
# spans, latest each of those times' first and last row, and the
|
|
1546
|
+
# card's latest row with the step under way, if any
|
|
1547
|
+
# ended, steps the steps, in order, the one under way running to now
|
|
1548
|
+
# inside, counts each reading's seconds inside each step, and how
|
|
1549
|
+
# many readings a step has
|
|
1550
|
+
# spread, pieces for a step to thin, each reading's seconds in each of
|
|
1551
|
+
# the equal parts it reaches: the first and the last of
|
|
1552
|
+
# them are worked out, so no reading is tried against
|
|
1553
|
+
# every part
|
|
1554
|
+
# points, drawn each step's points, and all of them as one array
|
|
1555
|
+
# SQLite builds the JSON, so no value is escaped by hand.
|
|
1556
|
+
out=$(store "$STORE" "$attach
|
|
1557
|
+
$(log_view "$name" "$card"),
|
|
1558
|
+
flagged(id, run, step, kind, status, next, after, t, prev_t, first) as (
|
|
1559
|
+
select id, run, step, kind, status, next, after,
|
|
1560
|
+
cast(strftime('%s', at) as integer), cast(strftime('%s', prev_at) as integer),
|
|
1561
|
+
case when lag(step) over (order by id) is step then 0 else 1 end
|
|
1562
|
+
from shown),
|
|
1563
|
+
grouped(id, run, step, kind, status, next, after, t, prev_t, g) as (
|
|
1564
|
+
select id, run, step, kind, status, next, after, t, prev_t,
|
|
1565
|
+
sum(first) over (order by id rows between unbounded preceding and current row)
|
|
1566
|
+
from flagged),
|
|
1567
|
+
spans(g, first_id, last_id) as (
|
|
1568
|
+
select g, min(id), max(id) from grouped where kind != 'start' group by g),
|
|
1569
|
+
latest(run, step, t, under) as (
|
|
1570
|
+
select run, step, t, case when status in ('answered', 'needs-human') then step
|
|
1571
|
+
when status = 'done' and coalesce(next, '') not in ('', 'start', 'setup', 'merged') then next end
|
|
1572
|
+
from grouped where after is null),
|
|
1573
|
+
ended(o, run, step, s, e, open) as (
|
|
1574
|
+
select sp.g, l.run, l.step, coalesce(f.prev_t, f.t), l.t, l.after is null and l.step is u.under
|
|
1575
|
+
from spans sp join grouped f on f.id = sp.first_id join grouped l on l.id = sp.last_id left join latest u on 1
|
|
1576
|
+
union all
|
|
1577
|
+
select (select max(g) from grouped) + 1, run, under, t, t, 1 from latest
|
|
1578
|
+
where under is not null and under is not step),
|
|
1579
|
+
steps(n, run, step, s, e, open) as (
|
|
1580
|
+
select row_number() over (order by o), run, step, s, case when open then max($now, e) else e end, open from ended),
|
|
1581
|
+
inside(n, at, a, b, cpu, mem, pressure) as (
|
|
1582
|
+
select st.n, g.at, max(g.at - g.secs, st.s), min(g.at, st.e), g.cpu_busy, g.mem_used_mb, g.mem_pressure
|
|
1583
|
+
from steps st cross join $readings g
|
|
1584
|
+
on g.at > st.s and g.at < st.e + $HOST_GAP and g.at - g.secs < st.e
|
|
1585
|
+
where min(g.at, st.e) > max(g.at - g.secs, st.s)),
|
|
1586
|
+
counts(n, readings, recorded) as (select n, count(*), sum(b - a) from inside group by n),
|
|
1587
|
+
spread(n, k, last, s, len, a, b, cpu, mem, pressure) as (
|
|
1588
|
+
select p.n, ($HOST_CARD_POINTS * (p.a - st.s + 1) - 1) / (st.e - st.s), ($HOST_CARD_POINTS * (p.b - st.s) - 1) / (st.e - st.s),
|
|
1589
|
+
st.s, st.e - st.s, p.a, p.b, p.cpu, p.mem, p.pressure
|
|
1590
|
+
from inside p join counts c on c.n = p.n and c.readings > $HOST_CARD_POINTS join steps st on st.n = p.n
|
|
1591
|
+
union all
|
|
1592
|
+
select n, k + 1, last, s, len, a, b, cpu, mem, pressure from spread where k < last),
|
|
1593
|
+
pieces(n, k, lo, hi, d, cpu, mem, pressure) as (
|
|
1594
|
+
select n, k, lo, hi, min(b, hi) - max(a, lo), cpu, mem, pressure from (
|
|
1595
|
+
select n, k, s + len * k / $HOST_CARD_POINTS as lo, s + len * (k + 1) / $HOST_CARD_POINTS as hi, a, b, cpu, mem, pressure
|
|
1596
|
+
from spread)
|
|
1597
|
+
where min(b, hi) > max(a, lo)),
|
|
1598
|
+
points(n, o, a, b, d, cpu, mem, pressure) as (
|
|
1599
|
+
select p.n, p.at, p.a, p.b, p.b - p.a, p.cpu, p.mem, p.pressure
|
|
1600
|
+
from inside p join counts c on c.n = p.n and c.readings <= $HOST_CARD_POINTS
|
|
1601
|
+
union all
|
|
1602
|
+
select n, k, lo, hi, sum(d), 1.0 * sum(cpu * d) / sum(case when cpu is not null then d end),
|
|
1603
|
+
cast(round(1.0 * sum(mem * d) / sum(case when mem is not null then d end)) as integer), max(pressure)
|
|
1604
|
+
from pieces group by n, k),
|
|
1605
|
+
drawn(n, i, points) as (
|
|
1606
|
+
select n, row_number() over (partition by n order by o),
|
|
1607
|
+
json_group_array(json_object(
|
|
1608
|
+
'start', strftime('%Y-%m-%dT%H:%M:%SZ', a, 'unixepoch'),
|
|
1609
|
+
'end', strftime('%Y-%m-%dT%H:%M:%SZ', b, 'unixepoch'), 'seconds', d,
|
|
1610
|
+
'cpu_busy', round(cpu, 1), 'mem_used_mb', mem,
|
|
1611
|
+
'mem_pressure', case when pressure >= 4 then 'critical' when pressure >= 2 then 'warning'
|
|
1612
|
+
when pressure is not null then 'normal' end))
|
|
1613
|
+
over (partition by n order by o rows between unbounded preceding and unbounded following)
|
|
1614
|
+
from points)
|
|
1615
|
+
select json_object('space', $(sql_str "$name"), 'card', $(sql_str "$card"), 'recording', json('$recording'),
|
|
1616
|
+
'steps', json((select json_group_array(json(entry)) from (
|
|
1617
|
+
select json_object('run', st.run, 'step', st.step,
|
|
1618
|
+
'start', strftime('%Y-%m-%dT%H:%M:%SZ', st.s, 'unixepoch'),
|
|
1619
|
+
'end', strftime('%Y-%m-%dT%H:%M:%SZ', st.e, 'unixepoch'),
|
|
1620
|
+
'seconds', max(st.e - st.s, 0), 'open', json(case when st.open then 'true' else 'false' end),
|
|
1621
|
+
'readings', coalesce(c.readings, 0), 'recorded', coalesce(c.recorded, 0),
|
|
1622
|
+
'points', json(coalesce(d.points, '[]'))) as entry
|
|
1623
|
+
from steps st left join counts c on c.n = st.n left join drawn d on d.n = st.n and d.i = 1
|
|
1624
|
+
order by st.n))));") || {
|
|
1625
|
+
# Which of the two it could not read: the hand-offs alone are tried again.
|
|
1626
|
+
[ -n "$attach" ] && store "$STORE" 'select count(*) from handoffs where 0;' >/dev/null ||
|
|
1627
|
+
die "could not read the hand-offs in $STORE. It may not be ocnus's store."
|
|
1628
|
+
die "could not read the readings in $HOST_DB. They may not be the ones ocnus host records."
|
|
1629
|
+
}
|
|
1630
|
+
[ -n "$out" ] || die "could not read the hand-offs in $STORE. It may not be ocnus's store."
|
|
1631
|
+
say "$out"
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1463
1634
|
cmd_host() {
|
|
1464
1635
|
case ${1:-} in
|
|
1465
1636
|
'') [ "$#" -le 1 ] || die "$HOST_USAGE"; host_show ;;
|
package/cli/lib/linear.sh
CHANGED
|
@@ -1311,7 +1311,8 @@ linear_slices() {
|
|
|
1311
1311
|
# sdlc-breakdown records every other card a card or a slice depends on, in
|
|
1312
1312
|
# another parent card too, as one that blocks it, so that the cards start in
|
|
1313
1313
|
# the order the work needs: `task start` holds a card while a card that
|
|
1314
|
-
# blocks it is not done
|
|
1314
|
+
# blocks it is not done, and the chain starts it once they all are
|
|
1315
|
+
# (chain.sh). A blocker is a relation of the kind "blocks", from
|
|
1315
1316
|
# the blocker to the card, as linear slices makes between slices. Nothing
|
|
1316
1317
|
# here ever removes one.
|
|
1317
1318
|
|
|
@@ -1414,6 +1415,202 @@ linear_block() {
|
|
|
1414
1415
|
done
|
|
1415
1416
|
}
|
|
1416
1417
|
|
|
1418
|
+
# --- the cards that wait to start -------------------------------------------
|
|
1419
|
+
#
|
|
1420
|
+
# The chain (chain.sh) starts a card once every card that blocks it is done.
|
|
1421
|
+
# Two questions tell it which cards wait: linear_blocks, for the cards that a
|
|
1422
|
+
# card whose merge was just recorded blocks, and linear_waiting, for every
|
|
1423
|
+
# card of some teams that is in a not-started status, whatever blocks it.
|
|
1424
|
+
# Neither changes anything in Linear.
|
|
1425
|
+
|
|
1426
|
+
# How much of each list the two questions read. Linear caps what one question
|
|
1427
|
+
# may cost, and counts a list inside a list again for every card of the outer
|
|
1428
|
+
# one (SLICE_RELATIONS), so each is kept small: of a card that has merged, and
|
|
1429
|
+
# of the card it was sliced from, the relations that name the cards it blocks;
|
|
1430
|
+
# of a card that waits, and of the card it was sliced from, the relations that
|
|
1431
|
+
# name the cards that block it; a card's sub-issues; and how many cards that
|
|
1432
|
+
# wait are asked for at a time. A card with more than was read says so
|
|
1433
|
+
# (CHAIN_DEFS), and a card that was not read is found by the next question
|
|
1434
|
+
# that asks about every card that waits.
|
|
1435
|
+
CHAIN_RELATIONS=10
|
|
1436
|
+
CHAIN_BLOCKERS=20
|
|
1437
|
+
CHAIN_SUBS=20
|
|
1438
|
+
WAITING_PAGE=20
|
|
1439
|
+
# The kinds of status a card that waits to start is in: approved, and not
|
|
1440
|
+
# started. A card in Backlog is not approved, and is never asked for.
|
|
1441
|
+
WAITING_TYPES='["unstarted"]'
|
|
1442
|
+
|
|
1443
|
+
# A card's relations of every kind that name it as the related card
|
|
1444
|
+
# (CARD_BLOCKERS_READ).
|
|
1445
|
+
CHAIN_BLOCKERS_READ='inverseRelations(first: '$CHAIN_BLOCKERS') {
|
|
1446
|
+
nodes { type issue { identifier state { name type } } } pageInfo { hasNextPage } }'
|
|
1447
|
+
# A card that waits, as both questions read it: its status, its description,
|
|
1448
|
+
# which holds its sections, the cards that block it and those that block the
|
|
1449
|
+
# card it was sliced from, and its sub-issues, each with its status, its
|
|
1450
|
+
# description and when it was made.
|
|
1451
|
+
CHAIN_CARD='identifier description state { name type }
|
|
1452
|
+
'$CHAIN_BLOCKERS_READ'
|
|
1453
|
+
parent { identifier
|
|
1454
|
+
'$CHAIN_BLOCKERS_READ' }
|
|
1455
|
+
children(first: '$CHAIN_SUBS') {
|
|
1456
|
+
nodes { identifier createdAt description state { name type } } pageInfo { hasNextPage } }'
|
|
1457
|
+
# A card's relations of every kind that it is the first card of. Those of the
|
|
1458
|
+
# kind "blocks" name a card it blocks, as their relatedIssue.
|
|
1459
|
+
CHAIN_BLOCKS_READ='relations(first: '$CHAIN_RELATIONS') {
|
|
1460
|
+
nodes { type relatedIssue {
|
|
1461
|
+
'$CHAIN_CARD' } }
|
|
1462
|
+
pageInfo { hasNextPage } }'
|
|
1463
|
+
# The question for linear_blocks: a card, the card it was sliced from, and
|
|
1464
|
+
# the cards each of the two blocks.
|
|
1465
|
+
BLOCKS_QUERY='query($team: String!, $number: Float!) {
|
|
1466
|
+
issues(first: 1, filter: {team: {key: {eq: $team}}, number: {eq: $number}}) {
|
|
1467
|
+
nodes { identifier state { name type }
|
|
1468
|
+
'$CHAIN_BLOCKS_READ'
|
|
1469
|
+
parent { identifier state { name type }
|
|
1470
|
+
'$CHAIN_BLOCKS_READ' } }
|
|
1471
|
+
}
|
|
1472
|
+
}'
|
|
1473
|
+
# The question for linear_waiting: one page of the cards of some teams that
|
|
1474
|
+
# are in a status of the kinds given, in the order they were made, which
|
|
1475
|
+
# nothing changes while the pages are fetched (LIST_QUERY).
|
|
1476
|
+
WAITING_QUERY='query($teams: [String!], $types: [String!], $first: Int, $after: String) {
|
|
1477
|
+
issues(first: $first, after: $after, orderBy: createdAt,
|
|
1478
|
+
filter: {team: {key: {in: $teams}}, state: {type: {in: $types}}}) {
|
|
1479
|
+
nodes { '$CHAIN_CARD' }
|
|
1480
|
+
pageInfo { hasNextPage endCursor }
|
|
1481
|
+
}
|
|
1482
|
+
}'
|
|
1483
|
+
|
|
1484
|
+
# What both shapes below are made of. waiting turns a card, as CHAIN_CARD
|
|
1485
|
+
# reads it, into
|
|
1486
|
+
# {id, status, type, spec, plan, parent, blockers, cut, subs, subsCut}
|
|
1487
|
+
# status and type are the name and the kind of its status, made plain, as
|
|
1488
|
+
# every text of Linear's here is. spec and plan say whether its description
|
|
1489
|
+
# has a Specification and a Plan: the heading `linear section` writes for
|
|
1490
|
+
# each (SECTION_FORMS), which a line inside a fenced code block never is.
|
|
1491
|
+
# parent is the ID of the card it was sliced from, or null. blockers are the
|
|
1492
|
+
# cards that block it, and those that block its parent, each as CARD_SHAPE
|
|
1493
|
+
# has it: {id, status, type, of}, done or not. cut is true when it or its
|
|
1494
|
+
# parent has more relations than were read. subs are its sub-issues, in the
|
|
1495
|
+
# order they were made, which is the order `linear slices` makes a card's
|
|
1496
|
+
# slices in, each as {id, status, type, spec, plan}, and subsCut is true when
|
|
1497
|
+
# it has more than were read. A card, a blocker or a sub-issue whose ID is
|
|
1498
|
+
# not a card ID is left out: an ID is handed to `task start`.
|
|
1499
|
+
CHAIN_DEFS=$PLAIN_DEF'
|
|
1500
|
+
def has_section($name; $open): '$SECTION_FORMS'
|
|
1501
|
+
(split("\n") | map(rtrimstr("\r"))) as $lines
|
|
1502
|
+
| ($lines | in_code) as $code
|
|
1503
|
+
| any(range(0; $lines | length); ($code[.] | not) and ($lines[.] | is_heading));
|
|
1504
|
+
def is_id: type == "string" and test("^[A-Za-z][A-Za-z0-9]*-[0-9]+$");
|
|
1505
|
+
def status: {status: ((.state.name? | strings | plain) // ""), type: ((.state.type? | strings) // "")};
|
|
1506
|
+
def sections: ((.description? | strings) // "") as $text
|
|
1507
|
+
| {spec: ($text | has_section("Specification"; "false")), plan: ($text | has_section("Plan"; "false"))};
|
|
1508
|
+
def blockers: .identifier as $of
|
|
1509
|
+
| [.inverseRelations.nodes[]? | select(.type? == "blocks") | .issue | select(.identifier? | is_id)
|
|
1510
|
+
| {id: .identifier} + status + {of: $of}];
|
|
1511
|
+
def cut: .inverseRelations.pageInfo.hasNextPage? == true;
|
|
1512
|
+
def above: if (.parent | type) == "object" and (.parent.identifier? | is_id) then .parent else null end;
|
|
1513
|
+
def waiting: above as $above
|
|
1514
|
+
| {id: .identifier} + status + sections
|
|
1515
|
+
+ {parent: (if $above == null then null else $above.identifier end),
|
|
1516
|
+
blockers: (blockers + (if $above == null then [] else ($above | blockers) end)),
|
|
1517
|
+
cut: (cut or ($above != null and ($above | cut))),
|
|
1518
|
+
subs: ([.children.nodes[]? | select(.identifier? | is_id)] | sort_by(.createdAt? // "")
|
|
1519
|
+
| map({id: .identifier} + status + sections)),
|
|
1520
|
+
subsCut: (.children.pageInfo.hasNextPage? == true)};
|
|
1521
|
+
def once: reduce .[] as $c ([]; if any(.[]; .id == $c.id) then . else . + [$c] end);'
|
|
1522
|
+
|
|
1523
|
+
# Turn Linear's answer to BLOCKS_QUERY into {card, cards, cut}, or "none"
|
|
1524
|
+
# when Linear has no such card. cards are the cards the card blocks, each as
|
|
1525
|
+
# waiting has it, in Linear's order, each once. When the card it was sliced
|
|
1526
|
+
# from is in a completed status, as once the merge of its last open slice has
|
|
1527
|
+
# closed it, the cards that card blocks come after them: the merge has freed
|
|
1528
|
+
# them too. While it is open, it still blocks them, so they are left out. A
|
|
1529
|
+
# card that is only related is never one of them. cut is true when Linear has
|
|
1530
|
+
# more of the relations than were read, so that a card it blocks may be
|
|
1531
|
+
# missing. An answer with no list of cards in it is not Linear saying it has
|
|
1532
|
+
# none, so it is an error (CARD_SHAPE).
|
|
1533
|
+
BLOCKS_SHAPE=$CHAIN_DEFS'
|
|
1534
|
+
def blocked: [.relations.nodes[]? | select(.type? == "blocks") | .relatedIssue
|
|
1535
|
+
| select((type == "object") and (.identifier? | is_id)) | waiting];
|
|
1536
|
+
def more: .relations.pageInfo.hasNextPage? == true;
|
|
1537
|
+
if (.issues.nodes | type) != "array" then error("no list of cards")
|
|
1538
|
+
elif (.issues.nodes | length) == 0 then "none"
|
|
1539
|
+
else .issues.nodes[0]
|
|
1540
|
+
| (if (.parent | type) == "object" and (.parent.state.type? == "completed") then .parent else null end) as $closed
|
|
1541
|
+
| {card: .identifier,
|
|
1542
|
+
cards: ((blocked + (if $closed == null then [] else ($closed | blocked) end)) | once),
|
|
1543
|
+
cut: (more or ($closed != null and ($closed | more)))}
|
|
1544
|
+
end'
|
|
1545
|
+
|
|
1546
|
+
# Turn the pages Linear answered WAITING_QUERY with, one line of JSON each,
|
|
1547
|
+
# into {cards}: every card that waits, as waiting has it, in the order they
|
|
1548
|
+
# were made, each once. A page with no list of cards in it is an error.
|
|
1549
|
+
WAITING_SHAPE=$CHAIN_DEFS'
|
|
1550
|
+
if any(.[]; (.issues.nodes | type) != "array") then error("no list of cards")
|
|
1551
|
+
else {cards: ([.[].issues.nodes[] | select((type == "object") and (.identifier? | is_id)) | waiting] | once)}
|
|
1552
|
+
end'
|
|
1553
|
+
|
|
1554
|
+
# Print the cards a card blocks, as one line of JSON (BLOCKS_SHAPE), or stop
|
|
1555
|
+
# and say why:
|
|
1556
|
+
# {"card":"ABC-122","cut":false,"cards":[{"id":"ABC-123","status":"Todo","type":"unstarted",
|
|
1557
|
+
# "spec":true,"plan":true,"parent":"ABC-100",
|
|
1558
|
+
# "blockers":[{"id":"ABC-122","status":"Done","type":"completed","of":"ABC-123"}],"cut":false,
|
|
1559
|
+
# "subs":[],"subsCut":false}]}
|
|
1560
|
+
# It asks Linear once.
|
|
1561
|
+
# linear_blocks <card ID, in upper case>
|
|
1562
|
+
linear_blocks() {
|
|
1563
|
+
local card=$1 key vars data found
|
|
1564
|
+
linear_tools
|
|
1565
|
+
key=$(linear_saved_key) || exit 1
|
|
1566
|
+
vars=$(jq -cn --arg team "${card%-*}" --arg number "${card##*-}" \
|
|
1567
|
+
'{team: $team, number: ($number | tonumber)}' 2>/dev/null) ||
|
|
1568
|
+
die "'$card' is not a card ID like ABC-122."
|
|
1569
|
+
data=$(linear_ask "$key" "$BLOCKS_QUERY" "$vars") || exit 1
|
|
1570
|
+
# Judged by what jq prints: some versions exit zero on an empty answer.
|
|
1571
|
+
found=$(printf '%s' "$data" | jq -c "$BLOCKS_SHAPE" 2>/dev/null) || found=
|
|
1572
|
+
case $found in
|
|
1573
|
+
'{'*) printf '%s\n' "$found" ;;
|
|
1574
|
+
'"none"') die "Linear has no card $card that the saved key can see." ;;
|
|
1575
|
+
*) die "Linear's answer was not one ocnus can read. Something between this machine and Linear may be answering for it." ;;
|
|
1576
|
+
esac
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
# Print every card of some Linear teams that waits to start, as one line of
|
|
1580
|
+
# JSON (WAITING_SHAPE), or stop and say why:
|
|
1581
|
+
# {"cards":[{"id":"ABC-123","status":"Todo","type":"unstarted","spec":true,"plan":true,...}]}
|
|
1582
|
+
# It asks Linear once for every WAITING_PAGE cards that wait, so once while
|
|
1583
|
+
# there are no more than that.
|
|
1584
|
+
# linear_waiting <team key>...
|
|
1585
|
+
linear_waiting() {
|
|
1586
|
+
local key teams vars data pages='' after='' more asked=0 found
|
|
1587
|
+
linear_tools
|
|
1588
|
+
key=$(linear_saved_key) || exit 1
|
|
1589
|
+
teams=$(printf '%s\n' "$@" | jq -Rcn '[inputs]')
|
|
1590
|
+
while :; do
|
|
1591
|
+
asked=$((asked + 1))
|
|
1592
|
+
[ "$asked" -le "$LINEAR_PAGES" ] ||
|
|
1593
|
+
die "Linear still had more cards that wait to start after $LINEAR_PAGES pages of $WAITING_PAGE, which is more than ocnus reads."
|
|
1594
|
+
vars=$(jq -cn --argjson teams "$teams" --argjson types "$WAITING_TYPES" --argjson first "$WAITING_PAGE" \
|
|
1595
|
+
--arg after "$after" \
|
|
1596
|
+
'{teams: $teams, types: $types, first: $first, after: (if $after == "" then null else $after end)}')
|
|
1597
|
+
data=$(linear_ask "$key" "$WAITING_QUERY" "$vars") || exit 1
|
|
1598
|
+
pages+=$data$'\n'
|
|
1599
|
+
more=$(printf '%s' "$data" | jq -r '.issues.pageInfo.hasNextPage == true' 2>/dev/null) ||
|
|
1600
|
+
die "Linear's answer was not one ocnus can read."
|
|
1601
|
+
[ "$more" = true ] || break
|
|
1602
|
+
# Judging what came so far would pass a part of the cards for all of them.
|
|
1603
|
+
after=$(printf '%s' "$data" | jq -r '.issues.pageInfo.endCursor | strings' 2>/dev/null) || after=
|
|
1604
|
+
[ -n "$after" ] ||
|
|
1605
|
+
die "Linear said it had more cards that wait to start but not where the next ones start, so some would be missed."
|
|
1606
|
+
done
|
|
1607
|
+
found=$(printf '%s' "$pages" | jq -cs "$WAITING_SHAPE" 2>/dev/null) || found=
|
|
1608
|
+
case $found in
|
|
1609
|
+
'{'*) printf '%s\n' "$found" ;;
|
|
1610
|
+
*) die "Linear's answer was not one ocnus can read. Something between this machine and Linear may be answering for it." ;;
|
|
1611
|
+
esac
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1417
1614
|
# --- moving a card ----------------------------------------------------------
|
|
1418
1615
|
#
|
|
1419
1616
|
# ocnus moves a card at four points: the hand-off that records the
|
package/cli/lib/links.sh
CHANGED
|
@@ -17,7 +17,10 @@ is_linkable() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
# The mods and layouts, each (source, destination) pair one per line,
|
|
20
|
-
# tab-separated. They go in Herdr's folder.
|
|
20
|
+
# tab-separated. They go in Herdr's folder. A layout's picture goes with it:
|
|
21
|
+
# the .svg beside it that its "preview" names, which Herdr's Settings shows
|
|
22
|
+
# for the layout and looks for in its own layouts folder. Nothing else in
|
|
23
|
+
# herdr/layouts is linked.
|
|
21
24
|
herdr_wanted() {
|
|
22
25
|
local m l
|
|
23
26
|
for m in "$REPO"/herdr/mods/*/; do
|
|
@@ -25,7 +28,7 @@ herdr_wanted() {
|
|
|
25
28
|
is_linkable "$m" || continue
|
|
26
29
|
printf '%s\t%s\n' "$m" "$APP_HOME/mods/${m##*/}"
|
|
27
30
|
done
|
|
28
|
-
for l in "$REPO"/herdr/layouts/*.json; do
|
|
31
|
+
for l in "$REPO"/herdr/layouts/*.json "$REPO"/herdr/layouts/*.svg; do
|
|
29
32
|
[ -f "$l" ] || continue
|
|
30
33
|
printf '%s\t%s\n' "$l" "$APP_HOME/layouts/${l##*/}"
|
|
31
34
|
done
|
|
@@ -60,7 +63,7 @@ state_of() {
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
# A short name for a destination: mods/cpu, layouts/default.json,
|
|
63
|
-
# skills/sdlc-plan, agents/ocnus-build.md.
|
|
66
|
+
# layouts/vibe.svg, skills/sdlc-plan, agents/ocnus-build.md.
|
|
64
67
|
label() {
|
|
65
68
|
local dst=$1
|
|
66
69
|
case $dst in
|