@johngaynor/ocnus 2.0.1-next.89 → 2.0.1-next.94

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 CHANGED
@@ -648,6 +648,12 @@ and as the last line of the card's own log. It is read from herdr-core each
648
648
  time and never stored, so it shows with the Herdr app closed too. See
649
649
  [herdr/README.md](herdr/README.md#hand-offs).
650
650
 
651
+ A card that ocnus's watch asked you about, because a canceled card holds it
652
+ (see the chain, below), has no agent: its question shows in place of where it
653
+ stands, as `waiting on the human:` and the question, in the list, in the
654
+ card's own log and in the Steps and Cards panels, until the card starts or
655
+ you answer it.
656
+
651
657
  While a card's pull requests wait on you to merge them, `task log` also
652
658
  says when what should happen for them cannot. When one is closed without merging, or in conflict with
653
659
  its default branch, and the card has no agent running to wake, since its
@@ -720,7 +726,7 @@ kinds:
720
726
  |---|---|---|
721
727
  | `approval` | sdlc-breakdown, for your approval of the card | the skill's own: `approve`, or the section to change |
722
728
  | `merge` | sdlc-pr, waiting for you to merge the card's pull requests. It comes with the links of those still open, as ocnus's watch last saw them, or as the question names them before its first pass | `merge`, a change you want made, or to stop |
723
- | `choice` | any other question an agent handed off as `needs-human`, such as which way to settle a conflict | the agent's own list |
729
+ | `choice` | any other question an agent handed off as `needs-human`, such as which way to settle a conflict, or the one ocnus's watch asks about a card a canceled card holds (see the chain, below) | the agent's own list, or the watch's |
724
730
  | `permission` | Claude Code, before it runs a tool. The text names the tool and what it would do: the command, the file or the address | `allow`, `refuse` and, where the prompt offers it, `allow from now on` |
725
731
 
726
732
  The first three are a card's latest hand-off, while that is `needs-human`,
@@ -732,7 +738,8 @@ its hand-off's, or for a permission prompt the step its card stands on, or
732
738
  `null` for a card with no hand-off), `text`, `options` (a list), `at` (when
733
739
  it was asked, in UTC), `seconds` (how long ago), `summary` (or `null`),
734
740
  `words` (whether it can be answered in your own words) and `running`
735
- (whether its agent is running, to take an answer). A merge also has `pulls`,
741
+ (whether its agent is running, to take an answer; always `true` for the
742
+ watch's question, which needs none). A merge also has `pulls`,
736
743
  the links of its open pull requests, and a permission prompt `tool`, the
737
744
  tool's name.
738
745
 
@@ -768,6 +775,11 @@ ocnus task answer my-space ABC-77 38 merge
768
775
  `gh`, signed in. In a repo whose method is a squash or a rebase, the watch
769
776
  records the merge and leaves the task for you to finish, as when you merge
770
777
  that way on GitHub (see `task finish`, below).
778
+ - **The watch's question** about a card it could not start has no agent to
779
+ take an answer: the card has no task yet. Your answer, one of its options
780
+ or your own words, is recorded as the card's `start` `answered`, which
781
+ ends its wait in `task log`, and nothing is sent. What it says, such as
782
+ removing a relation in Linear and starting the card, is yours to do.
771
783
 
772
784
  An answer is for one question, the one the list showed. When that question
773
785
  no longer waits, because it was answered in the tab or by an earlier answer,
@@ -776,11 +788,12 @@ command says why and exits non-zero. The same goes for a question whose
776
788
  agent is not running, with its tab closed or its own shell in the
777
789
  foreground, which the list marks with `agent not running`: an answer goes
778
790
  to a running agent, so start it again in its tab first. A merge answered
779
- with `merge` needs no agent. An agent still ending its turn is waited for,
780
- for half a minute. The command exits zero only once the agent has taken the
781
- answer, which is once Herdr shows it working again, once the hook of a
782
- permission prompt has taken the option, or once the pull requests have
783
- merged.
791
+ with `merge` needs no agent, and nor does the watch's question. An agent
792
+ still ending its turn is waited for, for half a minute. The command exits
793
+ zero only once the agent has taken the answer, which is once Herdr shows it
794
+ working again, once the hook of a permission prompt has taken the option,
795
+ once the pull requests have merged, or, for the watch's question, once the
796
+ answer is recorded.
784
797
 
785
798
  Only you answer. Run from inside the session of an agent ocnus started,
786
799
  `task answer` sends nothing and merges nothing, and says so; `task asks`
@@ -1254,7 +1267,7 @@ them under the merge:
1254
1267
  ```
1255
1268
  2026-03-02T10:14:09Z pr done, then merged 0s
1256
1269
  summary: Merged on GitHub: https://github.com/acme/api/pull/7. Recorded by ocnus's watch.
1257
- flags: ABC-123 was started; ABC-124 was not started: ABC-121, in In Review, still blocks it; ABC-125 was not started: it has no Plan
1270
+ flags: ABC-123 was started; ABC-124 was not started: ABC-121, in In Review, still blocks it (a comment on it in Linear says so); ABC-125 was not started: it has no Plan
1258
1271
  ```
1259
1272
 
1260
1273
  A card it leaves because it cannot be sure of it is named too: one whose
@@ -1264,6 +1277,29 @@ in Linear than it reads, one that has a task on this machine already, and one
1264
1277
  asked, the flags say that the cards were not looked for. With no Linear key
1265
1278
  saved, it looks for none and says nothing.
1266
1279
 
1280
+ At a merge, it also tells you, on the card in Linear, about each card the
1281
+ merge freed in part that another card still holds:
1282
+
1283
+ - **A card that a card not done yet still blocks**, itself or the card it
1284
+ was sliced from, gets a comment that names each of them, and says the
1285
+ watch starts it once they are done. Nothing is needed from you.
1286
+ - **A card that a canceled card blocks** can never start by itself, since a
1287
+ canceled card is never done. The comment names the canceled card, and asks
1288
+ you what should happen: remove the relation in Linear, then start the card
1289
+ with `ocnus task start`, through its first open slice when it was
1290
+ sliced, or cancel it. Nothing removes a relation for you. The watch also
1291
+ records the question as the card's hand-off, `start` `needs-human`, so
1292
+ that `task log`, `task asks` and the Steps and Cards panels show the card
1293
+ waiting on you, with the question. It waits until the card starts, which
1294
+ records its start, or until you answer it with `task answer`. A later
1295
+ merge that frees it in part again comments again, and does not record the
1296
+ question twice.
1297
+
1298
+ The merge's flags say which, as for ABC-124 above, and say so when Linear
1299
+ did not make a comment, with why. The merge stays recorded either way. The
1300
+ catch-up below comments on nothing and records nothing, so that a card that
1301
+ waits is not told the same every half hour.
1302
+
1267
1303
  A start can be missed at the merge: `task start` stopped, Linear could not be
1268
1304
  asked, the chain was off, or the last blocker was closed some other way, such
1269
1305
  as by hand in Linear, with no merge for the watch to see. The catch-up starts
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.
@@ -221,14 +229,15 @@ card_seen() {
221
229
  # Work out a card's agent from its latest hand-off, as AGENT_JSON: null when
222
230
  # there is nothing to say, or one line of JSON, {state, kind, tab, label,
223
231
  # for, seconds, pulls}. state is blocked, error, stopped, not running,
224
- # closed, conflict or unwatched; kind is permission, question, auth or null;
225
- # tab is the tab's name, or null when it is closed; pulls are the URLs of
226
- # the pull requests the label names, a list that is empty for any state but
227
- # closed and conflict. for and seconds count from when hc says the status
228
- # last changed, or from the hand-off when it gives no time, and always from
229
- # the hand-off for closed, conflict and unwatched, which are about the pull
230
- # requests. AGENT_LABEL and AGENT_FOR are the label and for as they are, for
231
- # 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
232
241
  # program for a card with no tab open whose pull requests do not wait on the
233
242
  # human, and sets AGENT_JSON rather than printing it, which would take a
234
243
  # subshell. With Herdr's tabs not read (AGENTS_ON 0), only a card whose pull
@@ -241,11 +250,20 @@ card_seen() {
241
250
  # AGENT_SEEN is left as card_seen saw the card's tab, and is closed when it
242
251
  # did not look, whatever AGENT_JSON is.
243
252
  # card_agent <card> <the card in lower case> <step> <status> <next>
244
- # <seconds since the hand-off> <space>
253
+ # <seconds since the hand-off> <space> [<the hand-off's question>]
245
254
  AGENT_JSON=null AGENT_LABEL='' AGENT_FOR='' AGENT_READY=0
246
255
  card_agent() {
247
- local card=$1 low=$2 step=$3 status=$4 next=$5 since=$6 space=$7
256
+ local card=$1 low=$2 step=$3 status=$4 next=$5 since=$6 space=$7 question=${8:-}
248
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
249
267
  # Its pull requests wait on the human.
250
268
  local waits=0
251
269
  [ "$step $status" != 'pr needs-human' ] || waits=1
@@ -253,7 +271,8 @@ card_agent() {
253
271
 
254
272
  local under=0
255
273
  case $status in
256
- answered) under=1 ;;
274
+ # An answer to the watch's question is no agent's to take.
275
+ answered) [ "$step" = start ] || under=1 ;;
257
276
  done) case $next in '' | start | setup | merged) ;; *) under=1 ;; esac ;;
258
277
  esac
259
278
 
@@ -348,25 +367,28 @@ card_agent() {
348
367
  # The space's tabs are read here, once. AGENT_NOW is the last agent's label
349
368
  # and how long it has been so, as the list shows them, for the `now:` line
350
369
  # of the log of one card. Nothing is worked out without jq, which reads hc's
351
- # answers, as ocnus's watch on the merges needs it to run.
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.
352
373
  # agents_table <view> <space> <the space's folder>
353
374
  AGENTS_SQL='agents (card, agent, ready, seen) as (select null, null, null, null where 0)'
354
375
  AGENT_NOW=''
355
376
  agents_table() {
356
- local view=$1 name=$2 dir=$3 rows sep=$'\x1f' card low step status next since values='' only=''
377
+ local view=$1 name=$2 dir=$3 rows sep=$'\x1f' card low step status next since question values='' only=''
357
378
  AGENTS_SQL='agents (card, agent, ready, seen) as (select null, null, null, null where 0)' AGENT_NOW=''
358
379
  [ -n "$view" ] || return 0
359
380
  command -v jq >/dev/null 2>&1 || return 0
360
381
  agents_read "$name" "$dir"
361
- # With no tabs read, only the cards whose pull requests wait on the human.
362
- [ "$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'"
363
385
  rows=$(store -separator "$sep" "$STORE" "$view
364
386
  select card, lower(card), step, status, coalesce(next, ''),
365
- 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, '')
366
388
  from shown where after is null $only order by id;") || return 0
367
- 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
368
390
  [ -n "$card" ] || continue
369
- card_agent "$card" "$low" "$step" "$status" "$next" "$since" "$name" ||
391
+ card_agent "$card" "$low" "$step" "$status" "$next" "$since" "$name" "$question" ||
370
392
  AGENT_JSON=null AGENT_READY=0 AGENT_SEEN=closed
371
393
  if [ "$AGENT_JSON" != null ]; then
372
394
  values="$values${values:+, }($(sql_str "$card"), $(sql_str "$AGENT_JSON"), 0, $(sql_str "$AGENT_SEEN"))"
package/cli/lib/asks.sh CHANGED
@@ -30,6 +30,14 @@
30
30
  # hc has sent it and the terminal says the agent is working, or at a prompt
31
31
  # it has come to since.
32
32
  #
33
+ # A question ocnus's watch on the merges asked about a card it could not
34
+ # start, as a canceled card holds it (chain.sh), has no agent: it is a start
35
+ # needs-human hand-off, which only the watch records, and the card has no
36
+ # task yet. So it counts as running, and `task answer` sends it nothing: it
37
+ # records the answer as the card's start answered, which ends the wait, and
38
+ # what the answer says, such as removing a relation in Linear and starting
39
+ # the card, is the human's to do.
40
+ #
33
41
  # A merge answered with merge is not sent to the agent: it merges each of the
34
42
  # card's open pull requests on GitHub (github.sh), by the method GitHub's own
35
43
  # merge button would use for the human in that repo, and only when GitHub
@@ -339,9 +347,11 @@ asks_stands() {
339
347
  # a permission prompt. Each has its step: the step of its hand-off, or for a
340
348
  # permission prompt the step its card stands on (asks_stands), null for a
341
349
  # 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.
350
+ # files and hc, and changes nothing. The space's tabs are read only when an
351
+ # agent's hand-off waits, and a hand-off's agent counts as not running when
352
+ # its tab is closed or holds its own shell alone, as it is with no tab to
353
+ # look in. The watch's question has no agent, and counts as running: `task
354
+ # answer` records its answer.
345
355
  # asks_collect <space> <the space's folder>
346
356
  asks_collect() {
347
357
  local space=$1 dir=$2 sep=$'\x1f' rows='' tabs=0 now
@@ -358,10 +368,12 @@ asks_collect() {
358
368
  fi
359
369
  while IFS=$sep read -r id card step at asked seconds text options summary; do
360
370
  [ -n "$id" ] || continue
361
- [ "$tabs" = 1 ] || { agents_read "$space" "$dir"; tabs=1; }
362
- card_seen "$card" "$(printf '%s' "$card" | tr '[:upper:]' '[:lower:]')" "$step"
363
371
  running=true
364
- case $AGENT_SEEN in closed | none) running=false ;; esac
372
+ if [ "$step" != start ]; then
373
+ [ "$tabs" = 1 ] || { agents_read "$space" "$dir"; tabs=1; }
374
+ card_seen "$card" "$(printf '%s' "$card" | tr '[:upper:]' '[:lower:]')" "$step"
375
+ case $AGENT_SEEN in closed | none) running=false ;; esac
376
+ fi
365
377
  ask_kind "$step" "$options"
366
378
  pulls=''
367
379
  [ "$ASK_KIND" != merge ] || pulls=$(ask_pulls "$space" "$card" "$text")
@@ -753,11 +765,36 @@ answer_permission() {
753
765
  say "Claude Code was given the answer to $card's permission prompt: $answer"
754
766
  }
755
767
 
768
+ # Record the human's answer to the question ocnus's watch asked about a card
769
+ # it could not start, as the card's start answered, since no agent runs to
770
+ # take it. It is recorded only while that question is the card's latest
771
+ # hand-off, checked in the same statement, so that nothing recorded since,
772
+ # such as the card's start, is ever followed by it. The answer is made one
773
+ # plain line, cut to fit HANDOFF_LINE_MAX, as the watch cuts its notes.
774
+ # answer_record <space> <card> <question> <answer>
775
+ answer_record() {
776
+ local name=$1 card=$2 id=$3 answer s c row
777
+ answer=$(plain_note "$4")
778
+ [ "${#answer}" -le "$HANDOFF_LINE_MAX" ] || answer="${answer:0:$((HANDOFF_LINE_MAX - 3))}..."
779
+ s=$(sql_str "$name") c=$(sql_str "$card")
780
+ row=$(store -bail "$STORE" "begin immediate;
781
+ insert into handoffs (at, space, card, step, status, answer)
782
+ select $(sql_str "$(date -u +%Y-%m-%dT%H:%M:%SZ)"), $s, $c, 'start', 'answered', $(sql_str "$answer")
783
+ where (select id from handoffs where space = $s and card = $c order by id desc limit 1) = $id;
784
+ select changes();
785
+ commit;") || die "could not record the answer to $card's question $id in $STORE. Nothing was recorded."
786
+ [ "$row" = 1 ] ||
787
+ die "$card's question $id no longer waits: it was answered already, or the card has started since. Nothing was recorded."
788
+ say "Recorded your answer to $card's question: $answer"
789
+ say "No agent takes it, since $card has not started: what it says is yours to do, in Linear or with ocnus task start $name $card. task log no longer shows $card waiting on you."
790
+ }
791
+
756
792
  # Answer one question, the one `task asks` listed under that id, with one of
757
793
  # its options or, for any kind but a permission prompt, the human's own
758
794
  # words. Words after the first are joined to it, so the answer need not be
759
795
  # quoted. It exits zero only once the agent has taken the answer, the hook
760
- # has, or the pull requests have merged.
796
+ # has, or the pull requests have merged, or, for the question of ocnus's
797
+ # watch, once the answer is recorded.
761
798
  task_answer() {
762
799
  local name=${1:-} card=${2:-} id=${3:-} answer plain dir
763
800
  [ "$#" -ge 4 ] && [ -n "$name" ] && [ -n "$id" ] || die "$ANSWER_USAGE"
@@ -788,7 +825,9 @@ task_answer() {
788
825
  have_sqlite || die "$SQLITE is not installed, so no hand-offs are recorded on this machine."
789
826
  answer_waits "$name" "$card" "$id"
790
827
  ask_kind "$ASK_STEP" "$ASK_OPTIONS"
791
- if [ "$ASK_KIND" = merge ] && [ "$answer" = merge ]; then
828
+ if [ "$ASK_STEP" = start ]; then
829
+ answer_record "$name" "$card" "$id" "$answer"
830
+ elif [ "$ASK_KIND" = merge ] && [ "$answer" = merge ]; then
792
831
  answer_merge "$name" "$dir" "$card"
793
832
  else
794
833
  answer_send "$name" "$dir" "$card" "$id" "$ASK_STEP" "$answer"
package/cli/lib/chain.sh CHANGED
@@ -34,6 +34,25 @@
34
34
  # merge, each start and each card not started goes on the merge's flags, so
35
35
  # that `task log` shows them (merge_record).
36
36
  #
37
+ # At a merge, the watch also tells the human, on the card in Linear, about a
38
+ # card the merge freed in part that another card still holds (chain_tell):
39
+ #
40
+ # - A card that a card not done yet still blocks, itself or the card it was
41
+ # sliced from, gets a comment naming each one, and saying the watch starts
42
+ # it once they are done.
43
+ # - A card that a canceled card blocks can never start by itself, since a
44
+ # canceled card is never done. The comment asks the human what to do:
45
+ # remove the relation in Linear, then start the card, or cancel it. The
46
+ # same question is recorded as a hand-off of the card's, start
47
+ # needs-human, so that `task log`, `task asks` and the Cards panel show
48
+ # the card waiting on the human (agents.sh). The card starting, which
49
+ # records its start, or the human's answer, which `task answer` records
50
+ # as start answered (asks.sh), ends the wait.
51
+ #
52
+ # Nothing removes a relation: ocnus has no way to. The catch-up comments on
53
+ # nothing and records nothing, so that a card that waits is not told the same
54
+ # every half hour.
55
+ #
37
56
  # The chain is on unless the settings file says "chain": false (settings.sh),
38
57
  # which `ocnus chain off` writes. Off, the watch starts no card, at a merge
39
58
  # or at a catch-up. `task ready` starts the ready cards whatever the setting
@@ -130,16 +149,26 @@ chain_teams() {
130
149
  # Judge each card that waits, from {cards}, as linear_blocks and
131
150
  # linear_waiting print them (CHAIN_DEFS in linear.sh), on stdin. $teams is
132
151
  # what chain_teams prints, and $home the space to start a card in when its
133
- # teams hold the card's team, or '' when there is none. It prints a line for
134
- # each card that is ready and each that is not, its fields separated by the
135
- # unit separator:
152
+ # teams hold the card's team, or '' when there is none. $merged is the card
153
+ # whose merge freed them, or '' at the catch-up. It prints a line for each
154
+ # card that is ready and each that is not, its fields separated by the unit
155
+ # separator:
136
156
  # start <card> <the card to start> <its space>
137
157
  # skip <card> <> <> <why it was not started>
158
+ # skip <card> <> <its space> <why> <held> <comment> <question> <options>
138
159
  # The card to start is the card itself, or its first open slice when it was
139
160
  # sliced. A card that is started, done or canceled already does not wait, so
140
161
  # it gets no line; neither does a sliced card with every slice started or
141
162
  # closed.
142
163
  #
164
+ # A card that another card still blocks is held: open when each of them is
165
+ # not done yet, and canceled when one of them was canceled, which no merge
166
+ # will ever make done. At a merge, a held card's line has what chain_tell
167
+ # says of it, each on one line: the comment to make on it, and for a card
168
+ # a canceled card holds, the question to ask the human and its options. They
169
+ # name the command that starts it once the relation is gone: `task start`,
170
+ # of the card itself, or of its first open slice when it was sliced.
171
+ #
143
172
  # The space is $home when its teams hold the card's team, or else the one
144
173
  # space that lists the team. A card's team is what its ID starts with. The
145
174
  # checks come in the order the reasons are worth giving: a card that is not
@@ -159,7 +188,28 @@ CHAIN_VERDICTS='
159
188
  def over: .type == "started" or .type == "completed" or .type == "canceled";
160
189
  def blocks($card): "\(.id), \(in_status), still blocks "
161
190
  + (if .of == $card then "it" else "\(.of), the card it was sliced from" end);
162
- def sliced: ([.subs[] | select(over | not)] | .[0]) as $sub
191
+ def first_open: [.subs[] | select(over | not)] | .[0];
192
+ def still($c; $why): "\($merged) has merged, but \($watch) did not start \($c.id): \($why). "
193
+ + "\($watch) starts \($c.id) once every card that blocks it"
194
+ + (if $c.parent == null then "" else ", or the card it was sliced from," end) + " is done.";
195
+ def asking($c; $space; $gone; $open):
196
+ $c.id as $id
197
+ | ($gone | length) as $n
198
+ | (if $n == 1 then "the relation" else "those relations" end) as $rel
199
+ | (($gone | map("\(.id), which blocks "
200
+ + (if .of == $id then $id else "\(.of), the card \($id) was sliced from" end)) | join(", and "))
201
+ + ", \(if $n == 1 then "was" else "were" end) canceled, so \($id) cannot start while "
202
+ + (if $n == 1 then "that relation stays." else "those relations stay." end)) as $why
203
+ | "What should happen to \($id)?" as $ask
204
+ | ($c | first_open) as $sub
205
+ | (if $sub == null then "start \($id)" else "start \($sub.id), its first open slice," end) as $how
206
+ | "ocnus task start \($space) \($sub.id // $id)" as $cmd
207
+ | {question: "\($why) \($ask)",
208
+ options: "remove \($rel) in Linear, then \($how) with: \($cmd) | cancel \($id) in Linear",
209
+ comment: ("\($merged) has merged, but \($watch) did not start \($id): \($why) "
210
+ + (if ($open | length) > 0 then ($open | map(blocks($id)) | join(", and ")) + ", too. " else "" end)
211
+ + "\($ask) Remove \($rel) in Linear, then \($how) with: `\($cmd)`. Or cancel \($id).")};
212
+ def sliced: first_open as $sub
163
213
  | if $sub == null then empty
164
214
  elif $sub.type != "unstarted" then
165
215
  {kind: "skip", why: "its first open slice, \($sub.id), is \($sub | in_status), so it is not approved yet"}
@@ -174,13 +224,20 @@ CHAIN_VERDICTS='
174
224
  elif ($spaces | length) == 1 then $spaces[0]
175
225
  else null end) as $space
176
226
  | [.blockers[] | select(.type != "completed")] as $open
227
+ | [$open[] | select(.type == "canceled")] as $gone
228
+ | [$open[] | select(.type != "canceled")] as $waits
177
229
  | (if over then empty
178
230
  elif .type != "unstarted" then {kind: "skip", why: "it is \(in_status), so it is not approved yet"}
179
231
  elif lacks != null then {kind: "skip", why: "it has \(lacks)"}
180
232
  elif ($spaces | length) == 0 then {kind: "skip", why: "its team, \($team), is in the teams of no space"}
181
233
  elif $space == null then
182
234
  {kind: "skip", why: "its team, \($team), is in the teams of more than one space (\($spaces | join(", "))), so ocnus cannot tell which one to start it in"}
183
- elif ($open | length) > 0 then {kind: "skip", why: ($open | map(blocks($c.id)) | join(", and "))}
235
+ elif ($open | length) > 0 then
236
+ {kind: "skip", why: ($open | map(blocks($c.id)) | join(", and ")),
237
+ held: (if ($gone | length) > 0 then "canceled" else "open" end)}
238
+ | if $merged == "" then .
239
+ elif .held == "canceled" then . + asking($c; $space; $gone; $waits)
240
+ else . + {comment: still($c; .why)} end
184
241
  elif .cut then
185
242
  {kind: "skip", why: "it, or the card it was sliced from, has more relations in Linear than ocnus reads, so a card that blocks it may be among the rest"}
186
243
  elif .subsCut then
@@ -188,7 +245,8 @@ CHAIN_VERDICTS='
188
245
  elif (.subs | length) > 0 then sliced
189
246
  else {kind: "start", start: .id}
190
247
  end) as $v
191
- | [$v.kind, .id, ($v.start // ""), (if $v.kind == "start" then $space else "" end), ($v.why // "")]
248
+ | [$v.kind, .id, ($v.start // ""), (if $v.kind == "start" or $v.held != null then $space else "" end),
249
+ ($v.why // ""), ($v.held // ""), ($v.comment // ""), ($v.question // ""), ($v.options // "")]
192
250
  | join("\u001f")'
193
251
 
194
252
  # Whether a card has a task in a space already: a folder for it under the
@@ -217,6 +275,9 @@ chain_merged() {
217
275
  # ABC-123 was started
218
276
  # ABC-131 was started, the first open slice of ABC-130
219
277
  # ABC-124 was not started: ABC-122, in In Review, still blocks it
278
+ # Given the card whose merge freed them, it tells the human about each card
279
+ # another card still holds (chain_tell), and says so at the end of its line:
280
+ # ABC-124 was not started: ABC-122, in In Review, still blocks it (a comment on it in Linear says so)
220
281
  # A card is started with `task start <space> <card>`, run as its own command,
221
282
  # as the human would run it, so that a start that stops does not stop this.
222
283
  # All it prints goes to stderr, for whoever is watching, and a start that
@@ -231,25 +292,33 @@ chain_merged() {
231
292
  #
232
293
  # CHAIN_FAILED is 1 when a card that was ready could not be started.
233
294
  # chain_start <the cards, as linear_blocks or linear_waiting prints them> <the home space, or ''>
295
+ # [<the card whose merge freed them>]
234
296
  CHAIN_FAILED=0
235
297
  chain_start() {
236
- local found=$1 home=$2 teams lines sep=$'\x1f' kind card start space why of dir out rc line held stopped tried=' '
237
- local left=' '
298
+ local found=$1 home=$2 merged=${3:-} teams lines sep=$'\x1f' kind card start space why of dir out rc line held stopped
299
+ local tried=' ' left=' ' hold comment question options
238
300
  CHAIN_FAILED=0
239
301
  teams=$(chain_teams) || teams='{}'
240
- if ! lines=$(printf '%s' "$found" |
241
- jq -r --argjson teams "$teams" --arg home "$home" "$CHAIN_VERDICTS" 2>/dev/null); then
302
+ if ! lines=$(printf '%s' "$found" | jq -r --argjson teams "$teams" --arg home "$home" \
303
+ --arg merged "$merged" --arg watch "ocnus's watch" "$CHAIN_VERDICTS" 2>/dev/null); then
242
304
  CHAIN_FAILED=1
243
305
  say "no card was started: what Linear said of the cards that wait is not something ocnus can read"
244
306
  return 0
245
307
  fi
246
308
  # The cards that are not ready, each of which has a line of its own.
247
- while IFS=$sep read -r kind card start space why; do
309
+ while IFS=$sep read -r kind card start space why hold comment question options; do
248
310
  [ "$kind" != skip ] || left+="$card "
249
311
  done <<< "$lines"
250
- while IFS=$sep read -r kind card start space why; do
312
+ while IFS=$sep read -r kind card start space why hold comment question options; do
251
313
  case $kind in
252
- skip) say "$card was not started: $why"; continue ;;
314
+ skip)
315
+ if [ -n "$merged" ] && [ -n "$hold" ] && [ -n "$comment" ]; then
316
+ say "$card was not started: $why$(chain_tell "$merged" "$space" "$card" "$why" "$hold" "$comment" "$question" "$options")"
317
+ else
318
+ say "$card was not started: $why"
319
+ fi
320
+ continue
321
+ ;;
253
322
  start) ;;
254
323
  *) continue ;;
255
324
  esac
@@ -307,11 +376,80 @@ chain_start() {
307
376
 
308
377
  # --- at a merge -------------------------------------------------------------
309
378
 
379
+ # Tell the human about a card that the merge of $1 freed in part, which
380
+ # another card still holds, and print what came of it, for the end of the
381
+ # card's line: a comment on it in Linear, and for a card a canceled card
382
+ # holds, the question recorded too (chain_ask). Neither stops anything: what
383
+ # could not be done is said instead.
384
+ # chain_tell <the merged card> <the card's space> <card> <why it was not started>
385
+ # <open|canceled> <the comment> <the question> <its options>
386
+ chain_tell() {
387
+ local merged=$1 space=$2 card=$3 why=$4 held=$5 comment=$6 question=$7 options=$8 out made=0 told summary
388
+ # In a subshell of its own: it stops, as die does, when Linear cannot make
389
+ # the comment.
390
+ if out=$(linear_comment "$card" "$comment" 2>&1); then
391
+ made=1
392
+ else
393
+ out=$(first_sentence "$out")
394
+ [ -n "$out" ] || out='linear_comment stopped without saying why'
395
+ fi
396
+ if [ "$held" != canceled ]; then
397
+ if [ "$made" = 1 ]; then printf ' (a comment on it in Linear says so)'
398
+ else printf ' (the comment on it in Linear was not made: %s)' "$out"
399
+ fi
400
+ return 0
401
+ fi
402
+ told='a comment on it in Linear asks you what to do'
403
+ summary="$merged has merged, but ocnus's watch did not start $card: $why. Recorded by ocnus's watch."
404
+ if [ "$made" = 1 ]; then
405
+ summary+=" A comment on $card in Linear asks the same."
406
+ else
407
+ told="the comment on it in Linear was not made: $out"
408
+ summary+=" The comment on $card in Linear that asks the same was not made: $out."
409
+ fi
410
+ if chain_ask "$space" "$card" "$summary" "$question" "$options"; then
411
+ if [ "$made" = 1 ]; then printf ' (%s, and task log shows it waiting on you)' "$told"
412
+ else printf ' (%s, but task log shows it waiting on you)' "$told"
413
+ fi
414
+ elif [ "$made" = 1 ]; then
415
+ printf ' (%s, but the question could not be recorded, so task log does not show it)' "$told"
416
+ else
417
+ printf ' (%s, and the question could not be recorded, so task log does not show it)' "$told"
418
+ fi
419
+ }
420
+
421
+ # Record the question ocnus's watch asks about a card a canceled card holds
422
+ # as a hand-off of the card's, step start and status needs-human, so that it
423
+ # waits on the human until the card starts or the human answers it. Only the
424
+ # watch records a start that is not done: `task handoff` refuses step start
425
+ # (handoff.sh). Each line is cut to fit HANDOFF_LINE_MAX. Nothing is recorded
426
+ # when the card's latest hand-off is the same question already, as when a
427
+ # later merge frees it in part again, or is its merge. It fails when the
428
+ # question is not waiting once it is done.
429
+ # chain_ask <space> <card> <summary> <question> <options>
430
+ chain_ask() {
431
+ local space=$1 card=$2 v id lines=()
432
+ for v in "$3" "$4" "$5"; do
433
+ v=$(plain_note "$v")
434
+ [ "${#v}" -le "$HANDOFF_LINE_MAX" ] || v="${v:0:$((HANDOFF_LINE_MAX - 3))}..."
435
+ lines+=("$v")
436
+ done
437
+ have_sqlite && store_ready || return 1
438
+ [ "$(store "$STORE" "select coalesce((select step = 'start' and status = 'needs-human'
439
+ and question is $(sql_str "${lines[1]}") from handoffs
440
+ where space = $(sql_str "$space") and card = $(sql_str "$card") order by id desc limit 1), 0);")" != 1 ] ||
441
+ return 0
442
+ id=$(store_handoff --unless-merged "$space" "$card" start needs-human '' "${lines[0]}" '' "${lines[1]}" "${lines[2]}" '' '' '') ||
443
+ return 1
444
+ case $id in '' | *[!0-9]*) return 1 ;; esac
445
+ }
446
+
310
447
  # Start the cards that the card $2, whose merge was just recorded in the
311
448
  # space $1, was blocking, and print a line for each card started and each
312
449
  # card not started, as chain_start does, for the merge's flags. It asks
313
- # Linear once. It never stops what called it: what it could not do is a line
314
- # too, and the catch-up starts what it missed.
450
+ # Linear once for the cards, and once more for each comment on a card another
451
+ # card still holds. It never stops what called it: what it could not do is a
452
+ # line too, and the catch-up starts what it missed.
315
453
  #
316
454
  # With the chain off, it does nothing. With no Linear key saved, it does
317
455
  # nothing either, and says nothing: Linear is not used on this machine, which
@@ -333,7 +471,7 @@ merge_chain() {
333
471
  found=${found##*$'\n'}
334
472
  [ "$(printf '%s' "$found" | jq -r '.cut' 2>/dev/null)" != true ] ||
335
473
  say "$card blocks more cards in Linear than ocnus reads at once, so some were not looked at"
336
- chain_start "$found" "$space"
474
+ chain_start "$found" "$space" "$card"
337
475
  }
338
476
 
339
477
  # --- the catch-up -----------------------------------------------------------
package/cli/lib/cost.sh CHANGED
@@ -345,7 +345,11 @@ sql_dollars() {
345
345
  # rows, had its first reading in the row's run and no later than the row. A
346
346
  # new or start row goes by the row after it, so by the write-up's session and
347
347
  # the build's, and the step the card is in by any session of its phase in
348
- # the run. What is not recorded has null in tokens and cost, never 0, and
348
+ # the run. The question ocnus's watch asks about a card it could not start,
349
+ # and the human's answer to it, come between the write-up phase and the
350
+ # build phase, with no agent of their own: what the write-up agent said after
351
+ # the approval is on them, as on a start row, so they go by the write-up's
352
+ # session. What is not recorded has null in tokens and cost, never 0, and
349
353
  # adds nothing to its card's total.
350
354
  #
351
355
  # tokens and cost are JSON, as `task log --json` gives them:
@@ -383,9 +387,10 @@ cost_view() {
383
387
  from shown),
384
388
  phased as (
385
389
  select *,
386
- case when step in ('new', 'define', 'plan', 'breakdown') then 'write-up'
390
+ case when step in ('new', 'define', 'plan', 'breakdown') or (step = 'start' and status <> 'done')
391
+ then 'write-up'
387
392
  when step in ('start', 'build', 'review', 'pr') then 'build' end as phase,
388
- case when step in ('new', 'start') then next_at else at end as until,
393
+ case when step = 'new' or (step = 'start' and status = 'done') then next_at else at end as until,
389
394
  case when status = 'done' and next is not null then next else step end as stands
390
395
  from spans),
391
396
  units as (
package/cli/lib/events.sh CHANGED
@@ -406,7 +406,9 @@ task_events() {
406
406
  # run; and steps, each with its number n, its run, the step, the seconds it
407
407
  # started and ended, s and e, and whether it is open. With no store it has
408
408
  # none. The steps are worked out as host_card works them out, from the same
409
- # view, so that a step here is the step there.
409
+ # view, so that a step here is the step there: the start step is no step,
410
+ # so neither is the question ocnus's watch asks about a card it could not
411
+ # start, nor the human's answer to it.
410
412
  # events_base <space> <card>
411
413
  events_base() {
412
414
  local now
@@ -426,9 +428,10 @@ events_base() {
426
428
  sum(first) over (order by id rows between unbounded preceding and current row)
427
429
  from flagged),
428
430
  spans(g, first_id, last_id) as (
429
- select g, min(id), max(id) from grouped where kind != 'start' group by g),
431
+ select g, min(id), max(id) from grouped where kind != 'start' and step != 'start' group by g),
430
432
  latest(run, step, t, under) as (
431
- select run, step, t, case when status in ('answered', 'needs-human') then step
433
+ select run, step, t, case when step = 'start' and status <> 'done' then null
434
+ when status in ('answered', 'needs-human') then step
432
435
  when status = 'done' and coalesce(next, '') not in ('', 'start', 'setup', 'merged') then next end
433
436
  from grouped where after is null),
434
437
  ended(o, run, step, s, e, open) as (
@@ -367,6 +367,11 @@ sql_took() {
367
367
  # space, as the table `shown`. Each card's rows are worked out on their own.
368
368
  # prev is the id of the row before each row, which the row's figures are
369
369
  # read by (cost_view, in cost.sh), and after the id of the row after it.
370
+ # A start row, of `task new` or `task start`, is no step's work, so it has no
371
+ # time and reads as started. The question ocnus's watch asks about a card it
372
+ # could not start (chain.sh), start needs-human, is no work either, so it has
373
+ # no time, and reads as a question; the human's answer to it is timed as the
374
+ # wait on them it ends.
370
375
  # A store made before the approved line has no column for it until a
371
376
  # hand-off is recorded in it, and the log never adds one, since it reads a
372
377
  # store it cannot write too: its rows are read with approved null.
@@ -385,18 +390,18 @@ log_view() {
385
390
  window w as (partition by card order by id)),
386
391
  timed as (
387
392
  select *,
388
- case when step in ('new', 'start') or prev_at is null then null
393
+ case when step = 'new' or (step = 'start' and status <> 'answered') or prev_at is null then null
389
394
  else max(cast(strftime('%%s', at) - strftime('%%s', prev_at) as integer), 0) end as seconds,
390
395
  case when after is null and status = 'needs-human'
391
396
  then max(cast(strftime('%%s', 'now') - strftime('%%s', at) as integer), 0) end as open_seconds
392
397
  from base),
393
398
  labeled as (
394
399
  select *,
395
- case when step in ('new', 'start') then 'start'
400
+ case when step = 'new' or (step = 'start' and status = 'done') then 'start'
396
401
  when status = 'answered' and before = 'needs-human' then 'wait'
397
402
  else 'step' end as kind,
398
403
  status || case when next is null then '' else ', then ' || next end as what,
399
- case when step in ('new', 'start') then 'started'
404
+ case when step = 'new' or (step = 'start' and status = 'done') then 'started'
400
405
  when status = 'done' then step || ' done'
401
406
  when status = 'needs-human' then step || ' asked a question'
402
407
  when status = 'answered' then 'answered'
@@ -413,7 +418,7 @@ log_view() {
413
418
  shown as (
414
419
  select *,
415
420
  case when status = 'needs-human' then 'waiting on the human'
416
- when step in ('new', 'start') then 'started'
421
+ when step = 'new' or (step = 'start' and status = 'done') then 'started'
417
422
  when status = 'done' and next = 'merged' then 'merged'
418
423
  else label || substr(what, length(status) + 1) end as state
419
424
  from labeled)" \
@@ -542,12 +547,14 @@ counts_none() {
542
547
  # word is the card's status in the list, the first of these that holds, with
543
548
  # its mark, the colour the counts give it, and its need, its place in the
544
549
  # order of need, from 0, the most urgent:
545
- # Stuck stuck 0 its agent has any state but blocked, as the
546
- # log says it, or its step failed
550
+ # Stuck stuck 0 its agent has any state but blocked or asked,
551
+ # as the log says it, or its step failed
547
552
  # Permission needs-human 1 its agent is blocked on a permission prompt
548
553
  # Approve? needs-human 1 breakdown asks the human to approve the card
549
554
  # Asking needs-human 1 its agent is blocked otherwise, or it asks
550
- # any other question but for the merge
555
+ # any other question but for the merge, as
556
+ # ocnus's watch asks about a card a canceled
557
+ # card holds (asked, in agents.sh)
551
558
  # Merge? needs-human 2 its pull requests wait on the human to merge
552
559
  # or ready them: ready once ocnus's watch says they
553
560
  # are ready (the agents table's ready)
@@ -565,7 +572,7 @@ cards_sql() {
565
572
  when 'Asking' then 1 when 'Merge?' then 2 when 'Working' then 3 end as need
566
573
  from (
567
574
  select *,
568
- case when (doing is not null and doing <> 'blocked') or status = 'failed' then 'Stuck'
575
+ case when (doing is not null and doing not in ('blocked', 'asked')) or status = 'failed' then 'Stuck'
569
576
  when doing = 'blocked' and prompt = 'permission' then 'Permission'
570
577
  when asked = 'approval' then 'Approve?'
571
578
  when doing = 'blocked' or asked = 'choice' then 'Asking'
package/cli/lib/host.sh CHANGED
@@ -1629,9 +1629,11 @@ EOF
1629
1629
  # from the hand-off before the first to the last, so the time it waited on
1630
1630
  # the human is inside it. The times are log_view's, as `task log` shows
1631
1631
  # them, so the two cannot disagree. A `new` or a `start` row has no time
1632
- # there, so it has no entry here. The step under way runs to now and is
1633
- # open: the one the log counts as under way (card_agent in agents.sh), or
1634
- # one whose question still waits.
1632
+ # there, so it has no entry here. Nor has the start step at all: no agent
1633
+ # runs it, so the question ocnus's watch asks about a card it could not
1634
+ # start, and the human's answer to it, are no step's time either. The step
1635
+ # under way runs to now and is open: the one the log counts as under way
1636
+ # (card_agent in agents.sh), or one whose question still waits.
1635
1637
  #
1636
1638
  # A reading counts for its seconds inside the step, as the report counts
1637
1639
  # one in a period. A step with more than HOST_CARD_POINTS readings is cut
@@ -1716,9 +1718,10 @@ host_card() {
1716
1718
  sum(first) over (order by id rows between unbounded preceding and current row)
1717
1719
  from flagged),
1718
1720
  spans(g, first_id, last_id) as (
1719
- select g, min(id), max(id) from grouped where kind != 'start' group by g),
1721
+ select g, min(id), max(id) from grouped where kind != 'start' and step != 'start' group by g),
1720
1722
  latest(run, step, t, under) as (
1721
- select run, step, t, case when status in ('answered', 'needs-human') then step
1723
+ select run, step, t, case when step = 'start' and status <> 'done' then null
1724
+ when status in ('answered', 'needs-human') then step
1722
1725
  when status = 'done' and coalesce(next, '') not in ('', 'start', 'setup', 'merged') then next end
1723
1726
  from grouped where after is null),
1724
1727
  ended(o, run, step, s, e, open) as (
package/cli/lib/linear.sh CHANGED
@@ -1611,6 +1611,37 @@ linear_waiting() {
1611
1611
  esac
1612
1612
  }
1613
1613
 
1614
+ # --- commenting on a card ---------------------------------------------------
1615
+ #
1616
+ # ocnus's watch on the merges comments on a card that a merge freed in part
1617
+ # but that it could not start (chain.sh), so that the human hears of it on
1618
+ # the card. A comment is all it writes there: nothing else in Linear is
1619
+ # changed, and no relation is removed.
1620
+
1621
+ # The question that makes a comment. Linear takes the card by its ID, such as
1622
+ # ABC-122, and answers with the comment it made and the card it is on.
1623
+ COMMENT_CREATE='mutation($input: CommentCreateInput!) {
1624
+ commentCreate(input: $input) { success comment { id body issue { identifier } } }
1625
+ }'
1626
+
1627
+ # Comment on a card, and read back from Linear's answer that the comment was
1628
+ # made, on that card, or stop and say why. Its text is not read back: Linear
1629
+ # may change the Markdown as it saves it. It asks Linear once, and prints
1630
+ # nothing when the comment is made.
1631
+ # linear_comment <card ID, in upper case> <the comment, in Markdown>
1632
+ linear_comment() {
1633
+ local card=$1 body=$2 key vars made
1634
+ linear_tools
1635
+ key=$(linear_saved_key) || exit 1
1636
+ vars=$(jq -cn --arg card "$card" --arg body "$body" '{input: {issueId: $card, body: $body}}' 2>/dev/null) ||
1637
+ die "could not put the comment on $card together."
1638
+ made=$(linear_ask "$key" "$COMMENT_CREATE" "$vars") || exit 1
1639
+ [ "$(printf '%s' "$made" | jq -r --arg card "$card" '.commentCreate | type == "object" and .success == true
1640
+ and (.comment | type == "object") and (.comment.id | type == "string")
1641
+ and .comment.issue.identifier? == $card' 2>/dev/null)" = true ] ||
1642
+ die "Linear's answer did not show the comment made on $card. Look at $card in Linear."
1643
+ }
1644
+
1614
1645
  # --- moving a card ----------------------------------------------------------
1615
1646
  #
1616
1647
  # ocnus moves a card at four points: the hand-off that records the
package/cli/ocnus CHANGED
@@ -320,9 +320,10 @@ with its card, its kind, its id, when it was asked, its text and its
320
320
  options. A question is an approval, which sdlc-breakdown asks for; a merge,
321
321
  sdlc-pr's wait for you to merge the card's pull requests, listed with the
322
322
  links of those still open; a choice, any other question an agent handed off
323
- with options of its own; or a permission, a Claude Code prompt to allow a
324
- tool, naming the tool and what it would do. One whose agent is not running
325
- says so. With --json it prints the same as one line, for programs.
323
+ with options of its own, or the one ocnus's watch asks about a card a
324
+ canceled card holds (see `chain` below); or a permission, a Claude Code
325
+ prompt to allow a tool, naming the tool and what it would do. One whose
326
+ agent is not running says so. With --json it prints the same as one line, for programs.
326
327
  `task answer` answers one, named by its card and its id, with no one typing
327
328
  in the agent's tab: with one of its options, or for any kind but a
328
329
  permission prompt with your own words, which the agent gets as if you had
@@ -335,8 +336,11 @@ no auto-merge is turned on, and it names the pull request and why. An answer
335
336
  is for that one question: when it was answered already, in the tab or by an
336
337
  earlier answer, when its agent has asked another since, or when its agent is
337
338
  not running, nothing is sent and it says why; a merge alone needs no agent
338
- running. It exits zero only once the agent has taken the answer or the pull
339
- requests have merged. Only you answer: run from inside the session of an
339
+ running. Nor does the watch's question: the answer to it is sent to no
340
+ agent, but recorded as the card's start answered, which ends its wait, and
341
+ what it says is yours to do. It exits zero only once the agent has taken
342
+ the answer, the pull requests have merged, or the answer to the watch's
343
+ question is recorded. Only you answer: run from inside the session of an
340
344
  agent ocnus started, it sends nothing and merges nothing. A permission
341
345
  prompt is seen through a hook that `task new` and `task build` give every
342
346
  claude they start, `task hold`, which Claude Code runs beside the prompt.
@@ -612,13 +616,21 @@ is done; a canceled blocker still holds it. A ready card that was sliced
612
616
  starts through its first sub-issue that is not started, done or canceled.
613
617
  Each starts from its repos' default branches as they are after the merge.
614
618
  The merge's flags, which `task log` shows, name each card started and each
615
- card not started, with why. `task ready <space>` starts every ready card
619
+ card not started, with why. At a merge, the watch also comments in Linear
620
+ on each card it freed in part that another card still holds. One that a
621
+ card not done yet blocks is told it starts once that card is done. One that
622
+ a canceled card blocks can never start by itself, so the comment asks you
623
+ what to do: remove the relation in Linear, then start it with `task start`,
624
+ or cancel it. The watch records that question as the card's start
625
+ needs-human too, so `task log`, `task asks` and the Cards panel show the
626
+ card waiting on you until it starts or you answer with `task answer`.
627
+ Nothing removes a relation. `task ready <space>` starts every ready card
616
628
  of the space's teams, whatever freed it: a blocker closed by hand in
617
629
  Linear, a start that stopped, a merge recorded while Linear could not be
618
630
  asked or the chain was off. It asks Linear for the cards that wait, 20 to a
619
- question, and says what became of each. The watch runs it for every space
620
- once its last run is half an hour old, starting none whose team more than
621
- one space lists. With the chain off, the watch starts no card, at a merge or
631
+ question, and says what became of each, commenting on none. The watch
632
+ runs it for every space once its last run is half an hour old, starting
633
+ none whose team more than one space lists. With the chain off, the watch starts no card, at a merge or
622
634
  each half hour, and `task ready` still starts them when you run it. With no
623
635
  Linear key saved, the watch looks for none.
624
636
 
package/herdr/README.md CHANGED
@@ -594,7 +594,10 @@ has merged.
594
594
  does a card whose pull requests wait on you while one is closed or in
595
595
  conflict with no agent running to wake, or while nothing is watching
596
596
  them, with what `task log` says, such as
597
- `acme/api#7 in conflict, no agent running`. The
597
+ `acme/api#7 in conflict, no agent running`. So does a card ocnus's
598
+ watch asked you about, because a canceled card holds it (see
599
+ [The chain](#the-chain)), with the question in its tooltip, until the card
600
+ starts or you answer it. The
598
601
  panel reads `ocnus task log <space> --json` after each read of the
599
602
  cards, every 6 seconds, and as soon as Herdr's tabs in the space change,
600
603
  so a change shows within 5 seconds while the window is visible. When
@@ -661,7 +664,7 @@ agent with a click, without looking for a tab or opening Linear.
661
664
  | Stuck | Red | `task log` says its agent is stuck or has stopped: it hit an error, stopped without handing off or is not running, or a pull request of the card's is closed, in conflict or unwatched. A card whose step failed is Stuck too |
662
665
  | Permission | Amber | Its agent waits on a permission prompt in its tab |
663
666
  | Approve? | Amber | `sdlc-breakdown` asks you to approve the card |
664
- | Asking | Amber | It waits on you for anything else: a question its step asked, or its agent asking in its tab or waiting for a sign-in |
667
+ | Asking | Amber | It waits on you for anything else: a question its step asked, its agent asking in its tab or waiting for a sign-in, or the question ocnus's watch asks about a card a canceled card holds (see [The chain](#the-chain)) |
665
668
  | Merge? | Green or amber | Its pull requests wait on you to merge them: green once the card is ready to merge, as its dot in the Step counts section is, and amber until then |
666
669
  | Working | Blue | It is running, and none of those holds: its step is under way |
667
670
 
@@ -1166,9 +1169,11 @@ ocnus task answer <space> <card> <question> <answer>
1166
1169
  | The pull requests wait on you, ocnus's watch saw one closed without merging, and no agent is running to wake: the tab is closed, or its shell is back in the foreground | `acme/api#7 closed without merging, no agent running`, naming each one closed |
1167
1170
  | The same, with one in conflict with its default branch | `acme/api#7 in conflict, no agent running`, naming each one in conflict |
1168
1171
  | The pull requests wait on you, and nothing can watch them: ocnus's watch is not running, or it cannot ask GitHub | `nothing watching its pull requests:` and why: `herdr-core not running`, `Herdr's hc not installed`, `ocnus's watch not running`, or what `gh` said, such as that it needs signing in |
1172
+ | ocnus's watch asked you what to do about a card a canceled card holds, so that it cannot start (see [The chain](#the-chain)): the latest hand-off is `start` `needs-human`, which only the watch records | `waiting on the human:` and the question, whatever the tab shows, and with Herdr's tabs read or not |
1169
1173
 
1170
- A step is under way when the latest hand-off is an answer, or `done` with
1171
- a step an agent runs next. A card waiting on you, failed, approved and not
1174
+ A step is under way when the latest hand-off is an answer, but for an
1175
+ answer to the watch's question, which no agent takes, or `done` with a
1176
+ step an agent runs next. A card waiting on you, failed, approved and not
1172
1177
  yet started, or merged has none, so it shows as before unless its agent is
1173
1178
  blocked or hit an error. The exception is a card whose pull requests wait
1174
1179
  on you, its latest hand-off the `pr` step's question: then it shows what
@@ -1202,9 +1207,10 @@ ocnus task answer <space> <card> <question> <answer>
1202
1207
  latest hand-off, and for the pull requests always from the latest
1203
1208
  hand-off. A card's own log ends with `now:` and the same.
1204
1209
  `--json` gives each card an `agent`: null, or its `state` (`blocked`,
1205
- `error`, `stopped`, `not running`, `closed`, `conflict` or `unwatched`),
1206
- its `kind` (`permission`, `question`, `auth` or null), its `tab` (null
1207
- when closed), its `label`, `for`, `seconds` and `pulls`: the URLs of the
1210
+ `error`, `stopped`, `not running`, `closed`, `conflict`, `unwatched` or
1211
+ `asked`, the watch's question), its `kind` (`permission`, `question`,
1212
+ `auth` or null), its `tab` (null when closed, and for `asked`, which has
1213
+ no agent), its `label`, `for`, `seconds` and `pulls`: the URLs of the
1208
1214
  pull requests its label names, an empty list for any state but `closed`
1209
1215
  and `conflict`. The card's own `state`, `for` and `seconds` keep
1210
1216
  their meaning. With no card, `--json` gives `counts` too, beside `cards`:
@@ -1221,7 +1227,7 @@ ocnus task answer <space> <card> <question> <answer>
1221
1227
  |---|---|
1222
1228
  | `stand` | The step the card stands on, as the counts place it, so the card's row and its dot are on the same step: the step that comes next after one that is done, or the step that asked, was answered or failed. `null` once its pull requests have merged |
1223
1229
  | `running` | `true` while a tab ocnus opened for the card is open for the phase going on: the tab its agent is looked for in, until the card has merged. At `start`, the card is approved, and it is running only while its write-up agent is working, blocked or has hit an error. `false` with no tab to look in |
1224
- | `word` | Its status in the card list, the first of these that holds: `Stuck` (any agent state but `blocked`, or a step that failed), `Permission` (`blocked` on a permission prompt), `Approve?` (breakdown's question for the approval), `Asking` (`blocked` otherwise, or any other question but the wait for the merge), `Merge?` (the pr step's wait for the merge) and `Working` (the card is running). `null` when none holds. The approval and the merge are told as `task asks` tells them |
1230
+ | `word` | Its status in the card list, the first of these that holds: `Stuck` (any agent state but `blocked` and `asked`, or a step that failed), `Permission` (`blocked` on a permission prompt), `Approve?` (breakdown's question for the approval), `Asking` (`blocked` otherwise, or any other question but the wait for the merge, the watch's among them), `Merge?` (the pr step's wait for the merge) and `Working` (the card is running). `null` when none holds. The approval and the merge are told as `task asks` tells them |
1225
1231
  | `mark` | The word's colour, as the marks of `counts` name them: `stuck` for Stuck, `ready` for a Merge? that is ready to merge, `working` for Working, and `needs-human` for the rest; `null` with no word |
1226
1232
  | `need` | The word's place in the order of need: 0 for Stuck, 1 for Permission, Approve? and Asking, 2 for Merge? and 3 for Working; `null` with no word |
1227
1233
 
@@ -1230,7 +1236,8 @@ ocnus task answer <space> <card> <question> <answer>
1230
1236
  missing, every card shows as before. With `hc` missing, or with neither
1231
1237
  herdr-core able to list its terminals nor the app open and able to list
1232
1238
  its tabs, every card shows as before but one whose pull requests wait on
1233
- you, for which no agent is running then.
1239
+ you, for which no agent is running then, and one the watch asked you
1240
+ about, which shows its question as ever.
1234
1241
  - **It records each agent's Claude Code session.** `task new` and
1235
1242
  `task build` choose the ID of the session they start `claude` in, give it
1236
1243
  as `--session-id=<ID>`, the last flag before the first message, and record
@@ -1429,6 +1436,14 @@ in the agent's tab. An agent with no question waiting is not in it.
1429
1436
  it shows `✓ Sent:` and the choice until ocnus no longer lists the
1430
1437
  question. Each question has its own state, so one being sent holds no
1431
1438
  other. The questions are read again as soon as an answer has ended.
1439
+ - **The question ocnus's watch asks about a card a canceled card holds**
1440
+ (see [The chain](#the-chain)) shows as Asking, at `start`, with the
1441
+ watch's two options as rows. It has no agent: a click on one has
1442
+ `task answer` record it as your answer, which ends the card's wait, and
1443
+ shows `✓ Sent:` once that is recorded. What it says, such as removing the
1444
+ relation in Linear and starting the card, is yours to do. Its Something
1445
+ else has no agent to open: give your own words with
1446
+ `ocnus task answer <space> <card> <question> <answer>` instead.
1432
1447
  - **When ocnus refuses the answer or cannot deliver it,** the question shows
1433
1448
  what `task answer` said, with its buttons or rows back under it, and
1434
1449
  nothing reads as sent, so a question that still waits can be answered
@@ -1945,7 +1960,7 @@ ocnus task ready <space>
1945
1960
  and each card left, with why, goes on the merge's flags, in Linear's order:
1946
1961
 
1947
1962
  ```
1948
- flags: ABC-123 was started; ABC-131 was started, the first open slice of ABC-130; ABC-124 was not started: ABC-121, in In Review, still blocks it; ABC-125 was not started: it has no Plan
1963
+ flags: ABC-123 was started; ABC-131 was started, the first open slice of ABC-130; ABC-124 was not started: ABC-121, in In Review, still blocks it (a comment on it in Linear says so); ABC-125 was not started: it has no Plan
1949
1964
  ```
1950
1965
 
1951
1966
  A card that is started, done or canceled already does not wait, so it is
@@ -1960,6 +1975,41 @@ ocnus task ready <space>
1960
1975
  has more than 10 relations of its own, the flags say that some cards were
1961
1976
  not looked at, and when Linear cannot be asked, that none were looked for.
1962
1977
  None of this stops the merge from being recorded.
1978
+ - **At a merge, it tells you about a card another card still holds**, on
1979
+ the card in Linear, with one comment each. A card that a card not done
1980
+ yet blocks, itself or the card it was sliced from, gets a comment naming
1981
+ each such card, which says the watch starts it once they are done:
1982
+
1983
+ ```
1984
+ ABC-1 has merged, but ocnus's watch did not start ABC-124: ABC-121, in In Review, still blocks it. ocnus's watch starts ABC-124 once every card that blocks it is done.
1985
+ ```
1986
+
1987
+ A card that a canceled card blocks can never start by itself, since a
1988
+ canceled card is never done, so the comment asks you what to do. It names
1989
+ the canceled card and how to go on: remove the relation in Linear, then
1990
+ start the card, through its first open slice when it was sliced, or cancel
1991
+ it. Each card not done yet that blocks it too is named.
1992
+
1993
+ ```
1994
+ ABC-1 has merged, but ocnus's watch did not start ABC-126: ABC-122, which blocks ABC-126, was canceled, so ABC-126 cannot start while that relation stays. What should happen to ABC-126? Remove the relation in Linear, then start ABC-126 with: `ocnus task start my-space ABC-126`. Or cancel ABC-126.
1995
+ ```
1996
+
1997
+ The watch also records that question as a hand-off of the card's, `start`
1998
+ `needs-human`, with the comment's question and two options, so that it is
1999
+ not only a comment: `task log` and `task asks` show the card waiting on
2000
+ you, and so do the Steps and Cards panels, which mark it, with the
2001
+ question in the tooltip (see [Hand-offs](#hand-offs)). Only the watch
2002
+ records a `start` that is not `done`; `task handoff` refuses one. The
2003
+ wait ends when the card starts, since `task start` records its start, or
2004
+ when you answer it with `ocnus task answer <space> <card> <question>
2005
+ <answer>`, which records your answer as `start` `answered`, sends it to no
2006
+ agent, and leaves what it says for you to do. A later merge that frees the
2007
+ card in part again comments again, and does not record the question twice.
2008
+ Nothing removes a relation: ocnus has no way to. The merge's flags end each
2009
+ such card's line with what came of it: `(a comment on it in Linear says
2010
+ so)`, `(a comment on it in Linear asks you what to do, and task log shows
2011
+ it waiting on you)`, or why the comment was not made, as when the key
2012
+ cannot write. Each comment is one question to Linear more.
1963
2013
  - **The catch-up starts what a merge missed.** A start is missed when `task
1964
2014
  start` stopped, Linear could not be asked, the chain was off, or the last
1965
2015
  blocker was closed with no merge to see, such as by hand in Linear.
@@ -1981,6 +2031,8 @@ ocnus task ready <space>
1981
2031
  space, so it leaves a card whose team more than one space lists. What it
1982
2032
  found is in its terminal, which `hc attach ocnus-merges` shows while it
1983
2033
  runs, and is recorded nowhere: a card that starts records its own start.
2034
+ The catch-up comments on no card and asks you nothing, so that a card
2035
+ that waits is not told the same every half hour: only a merge does.
1984
2036
  - **With no Linear key saved, the watch looks for no card**, at a merge or at
1985
2037
  the catch-up, and says nothing of it.
1986
2038
  - **A worktree's copy of ocnus refuses `task ready`**, since it starts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johngaynor/ocnus",
3
- "version": "2.0.1-next.89",
3
+ "version": "2.0.1-next.94",
4
4
  "description": "A software factory: agent skills and the Herdr setup to run them, installed with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {