@johngaynor/ocnus 2.0.1-next.9 → 2.0.1-next.98

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 (53) hide show
  1. package/README.md +659 -106
  2. package/cli/lib/agents.sh +85 -34
  3. package/cli/lib/asks.sh +837 -0
  4. package/cli/lib/banner.sh +249 -0
  5. package/cli/lib/brief.sh +375 -0
  6. package/cli/lib/chain.sh +501 -0
  7. package/cli/lib/close.sh +5 -3
  8. package/cli/lib/commands.sh +42 -3
  9. package/cli/lib/cost.sh +505 -0
  10. package/cli/lib/events.sh +485 -0
  11. package/cli/lib/finish.sh +30 -4
  12. package/cli/lib/github.sh +106 -26
  13. package/cli/lib/guard.sh +41 -10
  14. package/cli/lib/handoff.sh +279 -37
  15. package/cli/lib/host.sh +470 -475
  16. package/cli/lib/linear.sh +428 -34
  17. package/cli/lib/links.sh +10 -7
  18. package/cli/lib/merges.sh +129 -30
  19. package/cli/lib/progress.sh +301 -0
  20. package/cli/lib/sessions.sh +132 -0
  21. package/cli/lib/settings.sh +35 -19
  22. package/cli/lib/task.sh +170 -54
  23. package/cli/lib/tests.sh +302 -7
  24. package/cli/lib/usage.sh +204 -0
  25. package/cli/ocnus +323 -73
  26. package/herdr/README.md +1314 -268
  27. package/herdr/layouts/default.json +40 -11
  28. package/herdr/layouts/showcase.json +324 -0
  29. package/herdr/layouts/vibe.json +169 -0
  30. package/herdr/layouts/vibe.svg +41 -0
  31. package/herdr/mods/agent-settings/main.js +19 -7
  32. package/herdr/mods/card-list/main.js +658 -0
  33. package/herdr/mods/card-list/mod.json +1 -0
  34. package/herdr/mods/memory/main.js +128 -0
  35. package/herdr/mods/memory/mod.json +1 -0
  36. package/herdr/mods/memory/reading.js +88 -0
  37. package/herdr/mods/names/main.js +22 -4
  38. package/herdr/mods/needs-you/main.js +526 -0
  39. package/herdr/mods/needs-you/mod.json +1 -0
  40. package/herdr/mods/step-counts/main.js +281 -0
  41. package/herdr/mods/step-counts/mod.json +1 -0
  42. package/herdr/mods/test-runs/fit.js +78 -0
  43. package/herdr/mods/test-runs/main.js +242 -0
  44. package/herdr/mods/test-runs/mod.json +1 -0
  45. package/herdr/mods/usage/main.js +149 -0
  46. package/herdr/mods/usage/mod.json +1 -0
  47. package/package.json +1 -1
  48. package/prompts/task-new.md +1 -1
  49. package/skills/brief/SKILL.md +8 -0
  50. package/skills/sdlc-breakdown/SKILL.md +5 -5
  51. package/skills/sdlc-build/SKILL.md +7 -3
  52. package/skills/sdlc-pr/SKILL.md +2 -2
  53. package/skills/sdlc-review/SKILL.md +5 -5
package/cli/lib/agents.sh CHANGED
@@ -26,11 +26,19 @@
26
26
  # error, working, done, idle.
27
27
  #
28
28
  # The rules:
29
+ # - A card ocnus's watch asked the human about, since a canceled card holds
30
+ # it (chain.sh), has no agent: its latest hand-off is start needs-human,
31
+ # which only the watch records. Its state is asked, labelled with the
32
+ # question, whatever Herdr says, and with Herdr's tabs read or not, so
33
+ # that the Cards panel marks it, until the card starts or the human
34
+ # answers. The answer, start answered, is no step under way: no agent
35
+ # takes it (`task answer`, in asks.sh).
29
36
  # - Blocked or error always shows.
30
37
  # - While a step is under way, an agent whose turn has ended (done or idle)
31
38
  # has stopped without handing off. A step is under way when the latest
32
- # hand-off is an answer, or done with a step an agent runs next: not
33
- # start (or setup, its old name), which the human runs, nor merged.
39
+ # hand-off is an answer, but for an answer to the watch's question, or
40
+ # done with a step an agent runs next: not start (or setup, its old
41
+ # name), which the human runs, nor merged.
34
42
  # - While a step is under way, a tab that is closed, or whose terminals all
35
43
  # have their own shell in the foreground and no status, has no agent
36
44
  # running: it has exited, or never started.
@@ -49,12 +57,22 @@
49
57
  # is not running, ocnus's watch is not running, or gh could not
50
58
  # ask GitHub. That holds whatever the agent in the tab is doing.
51
59
  # Otherwise, with ocnus's watch watching, the card shows as it does
52
- # with no agent state.
60
+ # with no agent state. Such a card is noted as ready to merge when the
61
+ # watch's last pass saw every pull request of the card open and ready
62
+ # (MERGES_READY). That is not an agent state: the log says nothing of
63
+ # it, and only the counts in the list's JSON show it, as the mark
64
+ # ready (counts_sql in handoff.sh).
53
65
  # - No card gets an agent state when jq is missing. None but those whose
54
66
  # pull requests wait on the human get one when hc is missing, or when
55
67
  # neither place can list the space's tabs: herdr-core cannot list its
56
68
  # terminals, and the app is not running or `herdr-app ls` fails. With no
57
69
  # tab to look in, no agent is running then.
70
+ # - What was seen in the card's tab is kept beside its agent state, as
71
+ # seen, whether or not the agent has anything to say: closed when the
72
+ # tab is not open, or when it was not looked for, as with no tab to look
73
+ # in. It is not an agent state either: the list's JSON reads it to say
74
+ # whether the card is running, as the card list in Herdr shows it
75
+ # (cards_sql in handoff.sh).
58
76
 
59
77
  # The seconds after a start row in which the agent is still starting.
60
78
  AGENT_START_GRACE=15
@@ -211,25 +229,41 @@ card_seen() {
211
229
  # Work out a card's agent from its latest hand-off, as AGENT_JSON: null when
212
230
  # there is nothing to say, or one line of JSON, {state, kind, tab, label,
213
231
  # for, seconds, pulls}. state is blocked, error, stopped, not running,
214
- # closed, conflict or unwatched; kind is permission, question, auth or null;
215
- # tab is the tab's name, or null when it is closed; pulls are the URLs of
216
- # the pull requests the label names, a list that is empty for any state but
217
- # closed and conflict. for and seconds count from when hc says the status
218
- # last changed, or from the hand-off when it gives no time, and always from
219
- # the hand-off for closed, conflict and unwatched, which are about the pull
220
- # requests. AGENT_LABEL and AGENT_FOR are the label and for as they are, for
221
- # the card's own log. It runs for every card in the log, so it starts no
232
+ # closed, conflict, unwatched or asked; kind is permission, question, auth or
233
+ # null; tab is the tab's name, or null when it is closed or there is no
234
+ # agent; pulls are the URLs of the pull requests the label names, a list that
235
+ # is empty for any state but closed and conflict. for and seconds count from
236
+ # when hc says the status last changed, or from the hand-off when it gives no
237
+ # time, and always from the hand-off for closed, conflict and unwatched,
238
+ # which are about the pull requests, and for asked, the watch's question.
239
+ # AGENT_LABEL and AGENT_FOR are the label and for as they are, for the card's
240
+ # own log. It runs for every card in the log, so it starts no
222
241
  # program for a card with no tab open whose pull requests do not wait on the
223
242
  # human, and sets AGENT_JSON rather than printing it, which would take a
224
243
  # subshell. With Herdr's tabs not read (AGENTS_ON 0), only a card whose pull
225
244
  # requests wait on the human has anything to say: with no tab to look in, no
226
245
  # agent is running.
246
+ #
247
+ # AGENT_READY is 1 for a card ready to merge: its pull requests wait on the
248
+ # human, it has no agent state, and ocnus's watch says they are ready
249
+ # (merges_seen). It is 0 for any other card, and AGENT_JSON is null with it.
250
+ # AGENT_SEEN is left as card_seen saw the card's tab, and is closed when it
251
+ # did not look, whatever AGENT_JSON is.
227
252
  # card_agent <card> <the card in lower case> <step> <status> <next>
228
- # <seconds since the hand-off> <space>
229
- AGENT_JSON=null AGENT_LABEL='' AGENT_FOR=''
253
+ # <seconds since the hand-off> <space> [<the hand-off's question>]
254
+ AGENT_JSON=null AGENT_LABEL='' AGENT_FOR='' AGENT_READY=0
230
255
  card_agent() {
231
- local card=$1 low=$2 step=$3 status=$4 next=$5 since=$6 space=$7
232
- AGENT_JSON=null AGENT_LABEL='' AGENT_FOR=''
256
+ local card=$1 low=$2 step=$3 status=$4 next=$5 since=$6 space=$7 question=${8:-}
257
+ AGENT_JSON=null AGENT_LABEL='' AGENT_FOR='' AGENT_READY=0 AGENT_SEEN=closed
258
+ # The watch's question about a card it could not start: the question shows.
259
+ if [ "$step $status" = 'start needs-human' ]; then
260
+ AGENT_LABEL="waiting on the human: $question"
261
+ took_text "$since"
262
+ AGENT_FOR=$TOOK
263
+ printf -v AGENT_JSON '{"state":"asked","kind":null,"tab":null,"label":"%s","for":"%s","seconds":%s,"pulls":[]}' \
264
+ "$(json_str "$AGENT_LABEL")" "$TOOK" "$since"
265
+ return 0
266
+ fi
233
267
  # Its pull requests wait on the human.
234
268
  local waits=0
235
269
  [ "$step $status" != 'pr needs-human' ] || waits=1
@@ -237,7 +271,8 @@ card_agent() {
237
271
 
238
272
  local under=0
239
273
  case $status in
240
- answered) under=1 ;;
274
+ # An answer to the watch's question is no agent's to take.
275
+ answered) [ "$step" = start ] || under=1 ;;
241
276
  done) case $next in '' | start | setup | merged) ;; *) under=1 ;; esac ;;
242
277
  esac
243
278
 
@@ -280,6 +315,9 @@ card_agent() {
280
315
  names=${names:+$names, }$PULL_NAME
281
316
  done
282
317
  ;;
318
+ # Nothing to say of its agent or its pull requests: it is ready to
319
+ # merge when the watch says so.
320
+ '') AGENT_READY=$MERGES_READY ;;
283
321
  esac
284
322
  fi
285
323
 
@@ -318,33 +356,46 @@ card_agent() {
318
356
  }
319
357
 
320
358
  # Work out the agent of every card in a view of the log, as AGENTS_SQL: the
321
- # SQL for the table agents (card, agent) that the log's query joins, with
322
- # each card whose agent has something to say and its JSON. The space's tabs
323
- # are read here, once. AGENT_NOW is the last such agent's label and how long
324
- # it has been so, as the list shows them, for the `now:` line of the log of
325
- # one card. Nothing is worked out without jq, which reads hc's answers, as
326
- # ocnus's watch on the merges needs it to run.
359
+ # SQL for the table agents (card, agent, ready, seen) that the log's query
360
+ # joins, with each card whose agent has something to say and its JSON, with
361
+ # ready 0; each card ready to merge, which has no agent state: its agent is
362
+ # null and its ready 1, for the list's counts (counts_sql in handoff.sh); and
363
+ # each other card whose tab is open, with its agent null and its ready 0.
364
+ # seen is what card_seen saw in the card's tab, closed when it is not open,
365
+ # for whether the card is running (cards_sql in handoff.sh). A card with no
366
+ # row has no agent state, and its tab is closed.
367
+ # The space's tabs are read here, once. AGENT_NOW is the last agent's label
368
+ # and how long it has been so, as the list shows them, for the `now:` line
369
+ # of the log of one card. Nothing is worked out without jq, which reads hc's
370
+ # answers, as ocnus's watch on the merges needs it to run. With no tabs
371
+ # read, only the cards whose pull requests wait on the human, and those the
372
+ # watch asked the human about, are looked at.
327
373
  # agents_table <view> <space> <the space's folder>
328
- AGENTS_SQL='agents (card, agent) as (select null, null where 0)'
374
+ AGENTS_SQL='agents (card, agent, ready, seen) as (select null, null, null, null where 0)'
329
375
  AGENT_NOW=''
330
376
  agents_table() {
331
- local view=$1 name=$2 dir=$3 rows sep=$'\x1f' card low step status next since values='' only=''
332
- AGENTS_SQL='agents (card, agent) as (select null, null where 0)' AGENT_NOW=''
377
+ local view=$1 name=$2 dir=$3 rows sep=$'\x1f' card low step status next since question values='' only=''
378
+ AGENTS_SQL='agents (card, agent, ready, seen) as (select null, null, null, null where 0)' AGENT_NOW=''
333
379
  [ -n "$view" ] || return 0
334
380
  command -v jq >/dev/null 2>&1 || return 0
335
381
  agents_read "$name" "$dir"
336
- # With no tabs read, only the cards whose pull requests wait on the human.
337
- [ "$AGENTS_ON" = 1 ] || only="and step = 'pr' and status = 'needs-human'"
382
+ # With no tabs read, only the cards whose pull requests wait on the human,
383
+ # and those the watch asked the human about.
384
+ [ "$AGENTS_ON" = 1 ] || only="and step in ('pr', 'start') and status = 'needs-human'"
338
385
  rows=$(store -separator "$sep" "$STORE" "$view
339
386
  select card, lower(card), step, status, coalesce(next, ''),
340
- max(cast(strftime('%s', 'now') - strftime('%s', at) as integer), 0)
387
+ max(cast(strftime('%s', 'now') - strftime('%s', at) as integer), 0), coalesce(question, '')
341
388
  from shown where after is null $only order by id;") || return 0
342
- while IFS=$sep read -r card low step status next since; do
389
+ while IFS=$sep read -r card low step status next since question; do
343
390
  [ -n "$card" ] || continue
344
- card_agent "$card" "$low" "$step" "$status" "$next" "$since" "$name" || AGENT_JSON=null
345
- [ "$AGENT_JSON" != null ] || continue
346
- values="$values${values:+, }($(sql_str "$card"), $(sql_str "$AGENT_JSON"))"
347
- AGENT_NOW="$AGENT_LABEL, for $AGENT_FOR"
391
+ card_agent "$card" "$low" "$step" "$status" "$next" "$since" "$name" "$question" ||
392
+ AGENT_JSON=null AGENT_READY=0 AGENT_SEEN=closed
393
+ if [ "$AGENT_JSON" != null ]; then
394
+ values="$values${values:+, }($(sql_str "$card"), $(sql_str "$AGENT_JSON"), 0, $(sql_str "$AGENT_SEEN"))"
395
+ AGENT_NOW="$AGENT_LABEL, for $AGENT_FOR"
396
+ elif [ "$AGENT_READY" = 1 ] || [ "$AGENT_SEEN" != closed ]; then
397
+ values="$values${values:+, }($(sql_str "$card"), null, $AGENT_READY, $(sql_str "$AGENT_SEEN"))"
398
+ fi
348
399
  done <<< "$rows"
349
- [ -z "$values" ] || AGENTS_SQL="agents (card, agent) as (values $values)"
400
+ [ -z "$values" ] || AGENTS_SQL="agents (card, agent, ready, seen) as (values $values)"
350
401
  }