@johngaynor/ocnus 2.0.0 → 2.0.1-next.12

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/cli/lib/task.sh CHANGED
@@ -6,8 +6,9 @@
6
6
  # task new an agent writes the card up, in a tab in the space
7
7
  # task start a worktree of each repo on the card's branch, in a tab of its
8
8
  # own, which runs `task build` to start the agent that builds
9
- # the card. The write-up agent runs it once the human approves
10
- # the card, unless they hold it; then they run it.
9
+ # the card. The write-up agent runs it as soon as the card is
10
+ # approved. It makes nothing for a card that a card not done
11
+ # yet blocks, and the human runs it again once that is done.
11
12
  # The agent runs `task handoff` as each step ends, and `task log` shows what
12
13
  # it recorded. Both are in handoff.sh. While the pull requests wait on the
13
14
  # human, `task merges`, ocnus's watch on the merges, watches them on
@@ -52,6 +53,14 @@ PROFILE_MCP=$REPO/agents/linear-mcp.json
52
53
  # of that card's phase (host_hooks, in host.sh); when they cannot be given,
53
54
  # the agent starts without them.
54
55
  #
56
+ # On the subscription, --settings= also gives claude a statusLine: the
57
+ # command Claude Code hands the subscription's usage limits to each time it
58
+ # updates the status line, `ocnus usage record` (usage.sh), which saves
59
+ # them for the Usage section and prints nothing. With hooks, it goes in their
60
+ # object, put together with jq, which the hooks need anyway; without, in an
61
+ # object of its own, which needs no jq. It overrides a statusLine of the
62
+ # human's own, for ocnus's agents alone.
63
+ #
55
64
  # It also leaves in AGENT_ENV the words claude is started after, which run it
56
65
  # without ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN, so that the agent runs
57
66
  # on the Claude subscription signed in to with /login: in Claude Code's order
@@ -69,12 +78,13 @@ PROFILE_MCP=$REPO/agents/linear-mcp.json
69
78
  # /login sign-in in Claude Code's order. The key itself is in no argument and
70
79
  # in no environment, and env's words still drop the exported variables,
71
80
  # which would come before the helper. With no key saved it stops, before an
72
- # agent is started. The profile's model and effort hold either way.
81
+ # agent is started. An agent on the API has no usage limits to read, so it
82
+ # gets no statusLine. The profile's model and effort hold either way.
73
83
  # $1 the profile $2 its name in the settings file
74
84
  # $3 the space $4 the card $5 the phase, write-up or build
75
85
  PROFILE_ARGS=() AGENT_ENV=()
76
86
  profile_args() {
77
- local profile=$1 settings=$2 hooks
87
+ local profile=$1 settings=$2 hooks line both
78
88
  PROFILE_ARGS=() AGENT_ENV=()
79
89
  [ "${HARNESS##*/}" = claude ] || return 0
80
90
  [ -f "$AGENTS_HOME/$profile.md" ] ||
@@ -82,9 +92,16 @@ profile_args() {
82
92
  settings_check
83
93
  PROFILE_ARGS=("--agent=$profile" --strict-mcp-config "--mcp-config=$PROFILE_MCP"
84
94
  "--model=$(profile_model "$settings")" "--effort=$(profile_effort "$settings")")
85
- if hooks=$(host_hooks "$3" "$4" "$5") && [ -n "$hooks" ]; then
86
- PROFILE_ARGS+=("--settings=$hooks")
95
+ hooks=$(host_hooks "$3" "$4" "$5") || hooks=''
96
+ if [ "$SET_BILLING" != api ]; then
97
+ line=$(usage_status_line)
98
+ if [ -z "$hooks" ]; then
99
+ hooks="{\"statusLine\":$line}"
100
+ elif both=$(jq -c --argjson line "$line" '.statusLine = $line' <<< "$hooks" 2>/dev/null) && [ -n "$both" ]; then
101
+ hooks=$both
102
+ fi
87
103
  fi
104
+ [ -z "$hooks" ] || PROFILE_ARGS+=("--settings=$hooks")
88
105
  AGENT_ENV=(env -u ANTHROPIC_API_KEY -u ANTHROPIC_AUTH_TOKEN)
89
106
  if [ "$SET_BILLING" = api ]; then
90
107
  [ -n "$SAVED_ANTHROPIC_KEY" ] || die "$BILLING_NO_KEY"
@@ -323,8 +340,12 @@ short_name() {
323
340
  # Name the branch a card's task is on, <type>/<card ID>-<short name>: like
324
341
  # feat/abc-122-export-orders-as-csv. It leaves the branch in BRANCH, in
325
342
  # BRANCH_NOTES what `task start` says about where the type and title came
326
- # from, and in CARD_PARENT the card it was sliced from, as Linear names it,
327
- # or nothing when it has none or Linear was not asked. It runs in the main
343
+ # from and whether the card's blockers were checked, in CARD_PARENT the card
344
+ # it was sliced from, as Linear names it, or nothing when it has none or
345
+ # Linear was not asked, and in CARD_STATUS the name of the card's status in
346
+ # Linear, or nothing. CARD_OPEN is the cards that block it or its parent and
347
+ # are not done yet, as a JSON list of {id, status, of} (CARD_SHAPE), or
348
+ # nothing when every one is done or Linear was not asked. It runs in the main
328
349
  # shell, not in $( ), so that it can leave them, and every stop is before
329
350
  # anything is made.
330
351
  # card_branch <space> <card ID, in upper case> [<type> <title>]
@@ -334,11 +355,12 @@ short_name() {
334
355
  # wins when it can be asked: Linear's type and title name the branch, by the
335
356
  # same checks, with a note for each given one that differs. With no key
336
357
  # saved, or a Linear that cannot be asked (a rejected key, no network, no
337
- # curl or jq), the given ones name it, with a note on why.
338
- BRANCH='' BRANCH_NOTES=() CARD_PARENT=''
358
+ # curl or jq), the given ones name it, with a note on why, and a note that
359
+ # the blockers were not checked.
360
+ BRANCH='' BRANCH_NOTES=() CARD_PARENT='' CARD_STATUS='' CARD_OPEN=''
339
361
  card_branch() {
340
362
  local name=$1 card=$2 given_type=${3:-} given_title=${4:-} found out rc=0 type title short branch parent
341
- BRANCH='' BRANCH_NOTES=() CARD_PARENT=''
363
+ BRANCH='' BRANCH_NOTES=() CARD_PARENT='' CARD_STATUS='' CARD_OPEN=''
342
364
  if [ -z "$given_type" ]; then
343
365
  [ -n "${LINEAR_API_KEY:-}" ] ||
344
366
  die "no Linear key is saved, so ocnus cannot read $card's type and title in Linear. Save a key with ocnus linear key (make one in $KEY_PLACE), or give the type and title: ocnus task start $name $card --type <type> --title '<title>'"
@@ -367,6 +389,15 @@ card_branch() {
367
389
  # Only a card ID: it is looked for among the space's tabs.
368
390
  parent=$(printf '%s' "$found" | jq -r '.parent // empty')
369
391
  [[ ! $parent =~ $CARD_RE ]] || CARD_PARENT=$(printf '%s' "$parent" | tr '[:lower:]' '[:upper:]')
392
+ # Linear's text, made plain, as task ls makes it, for task start to say.
393
+ CARD_STATUS=$(printf '%s' "$found" | jq -r "$PLAIN_DEF"' .status // empty | plain')
394
+ # A blocker not done yet holds the card. One that is done holds nothing.
395
+ CARD_OPEN=$(printf '%s' "$found" |
396
+ jq -c "$PLAIN_DEF"' [.blockers[]? | select(.type != "completed")
397
+ | {id: (.id | plain), status: (.status | plain), of: (.of | plain)}] | select(length > 0)')
398
+ if [ "$(printf '%s' "$found" | jq -r '.blockersCut')" = true ]; then
399
+ BRANCH_NOTES+=("$card or the card it was sliced from has more relations in Linear than ocnus reads, so a card that blocks it may not have been checked")
400
+ fi
370
401
  # The notes are said only once the branch is made, so a type of
371
402
  # Linear's that no branch can hold stops below before any is said.
372
403
  if [ -n "$given_type" ] && [ "$given_type" != "$type" ]; then
@@ -378,6 +409,8 @@ card_branch() {
378
409
  fi
379
410
  else
380
411
  type=$given_type title=$given_title
412
+ # The reason is in the note above: Linear was not asked.
413
+ BRANCH_NOTES+=("$card's blockers were not checked, since Linear was not asked: it starts whether or not a card that blocks it is done")
381
414
  fi
382
415
  short=$(printf '%s' "$title" | short_name)
383
416
  branch=$type/$(printf '%s' "$card" | tr '[:upper:]' '[:lower:]')${short:+-$short}
@@ -546,6 +579,20 @@ parse_targets() {
546
579
  done
547
580
  }
548
581
 
582
+ # What `task start` says when it holds a card, from CARD_OPEN and
583
+ # CARD_STATUS (card_branch): each card that blocks it, or the card it was
584
+ # sliced from, and is not done yet, and that the card stays where it is.
585
+ # held_message <card ID>
586
+ held_message() {
587
+ local card=$1 where='where it is in Linear'
588
+ [ -z "$CARD_STATUS" ] || where="in $CARD_STATUS"
589
+ printf '%s is held: a card that blocks it is not done yet, so no task was made for it.\n' "$card"
590
+ printf '%s' "$CARD_OPEN" | jq -r --arg card "$card" '.[]
591
+ | " blocker \(.id)\(if .status == "" then "" else ", in \(.status)," end) blocks "
592
+ + (if .of == $card then $card else "\(.of), the card \($card) was sliced from" end)'
593
+ printf '%s stays %s. Run this again once the cards that block it are done.' "$card" "$where"
594
+ }
595
+
549
596
  # What `task start` takes after the card.
550
597
  START_ARGS='[--type <type> --title <title>] [<repo>[:<group>[,<group>...]] ...]'
551
598
 
@@ -620,6 +667,9 @@ task_start() {
620
667
  # Linear names the branch, or the type and title given when Linear cannot,
621
668
  # once everything here has been checked.
622
669
  card_branch "$name" "$card" "$given_type" "$given_title"
670
+ # A card waits until every card that blocks it, or the card it was sliced
671
+ # from, is done, so it is held before anything is fetched or made.
672
+ [ -z "$CARD_OPEN" ] || die "$(held_message "$card")"
623
673
  branch=$BRANCH
624
674
  task=$(task_name "$branch")
625
675
  tdir=$dir/tasks/$task
@@ -0,0 +1,159 @@
1
+ # How much of the Claude subscription's usage limits is used: the five-hour
2
+ # limit and the weekly one, and when each resets. Sourced by cli/ocnus.
3
+
4
+ # Claude Code hands a status line command a JSON on stdin each time it
5
+ # updates the status line, and while it runs on a Claude subscription,
6
+ # once the first answer has come, that JSON has rate_limits.five_hour and
7
+ # rate_limits.seven_day, each with used_percentage (0 to 100) and resets_at
8
+ # (seconds since 1970). A window is left out once its resets_at has passed,
9
+ # until the next answer, and both are left out on an API key.
10
+ #
11
+ # With billing on the subscription, every agent `task new` and `task build`
12
+ # start gets a statusLine that runs `ocnus usage record` (profile_args, in
13
+ # task.sh), which saves the two windows, and when they were read, to
14
+ # usage.json in ocnus's folder. `ocnus usage` reads that file back, and
15
+ # the Usage section in Herdr's sidebar runs `ocnus usage --json` every 30
16
+ # seconds. So the reading is as fresh as the last update of an ocnus
17
+ # agent's status line: it ages while no agent works, says how old it is, and
18
+ # a window whose reset has passed since is shown as reset, not as a number.
19
+ # Claude Code sessions the human starts are not read: their settings are
20
+ # their own.
21
+
22
+ # The last reading: {"read_at": <seconds>, "five_hour": {"used": <0 to 100>,
23
+ # "resets_at": <seconds>} | null, "seven_day": the same | null}.
24
+ USAGE_FILE=$ENT_HOME/usage.json
25
+ USAGE_TAKES='usage: ocnus usage [--json]: it takes nothing, to say how much of your Claude usage limits is used, or --json for programs'
26
+ # A reading older than this, in seconds, says how old it is.
27
+ USAGE_STALE=600
28
+
29
+ # ocnus usage [--json | record]: say how much of the usage limits is used,
30
+ # as a person reads it or, with --json, as one line for programs, or, with
31
+ # record, save the reading in the status line JSON on stdin. Only the
32
+ # agents' statusLine runs record.
33
+ cmd_usage() {
34
+ case $# in
35
+ 0) usage_show plain ;;
36
+ 1)
37
+ case $1 in
38
+ --json) usage_show json ;;
39
+ record) usage_record ;;
40
+ *) die "$USAGE_TAKES" ;;
41
+ esac
42
+ ;;
43
+ *) die "$USAGE_TAKES" ;;
44
+ esac
45
+ }
46
+
47
+ # Save the two windows of the status line JSON on stdin, with the time now,
48
+ # in the usage file, through a file of its own that takes the old one's place
49
+ # at once, so that the section never reads half a file and two agents
50
+ # writing at once leave one whole reading. It is a status line command, so it
51
+ # prints nothing, and it never fails: a JSON with neither window in it, as
52
+ # before an agent's first answer or on an API key, leaves the last reading as
53
+ # it was, and so does anything that goes wrong. stdin is read to its end
54
+ # either way.
55
+ usage_record() {
56
+ local now tmp
57
+ if ! command -v jq >/dev/null 2>&1 || ! mkdir -p "$ENT_HOME" 2>/dev/null; then
58
+ cat >/dev/null 2>&1 || true
59
+ return 0
60
+ fi
61
+ now=$(date +%s)
62
+ tmp=$USAGE_FILE.ocnus.$$
63
+ if jq -cn --argjson now "$now" '
64
+ def win: if type == "object" and (.used_percentage | type) == "number" and (.resets_at | type) == "number"
65
+ then {used: .used_percentage, resets_at: (.resets_at | floor)} else null end;
66
+ [inputs] | last
67
+ | (if type == "object" and (.rate_limits | type) == "object" then .rate_limits else {} end) as $r
68
+ | {read_at: $now, five_hour: ($r.five_hour | win), seven_day: ($r.seven_day | win)}
69
+ | select(.five_hour != null or .seven_day != null)' > "$tmp" 2>/dev/null && [ -s "$tmp" ]; then
70
+ mv -f "$tmp" "$USAGE_FILE" 2>/dev/null || true
71
+ fi
72
+ rm -f "$tmp" 2>/dev/null || true
73
+ return 0
74
+ }
75
+
76
+ # Say what the last reading holds: plain, for a person, or json, for
77
+ # programs, as one line:
78
+ # {"file": …, "read_at": <seconds> | null, "age": "3m" | null,
79
+ # "stale": <older than ten minutes>,
80
+ # "five_hour": <window> | null, "seven_day": <window> | null,
81
+ # "note": <the one line to show instead of numbers> | null}
82
+ # where a window is {"used": <0 to 100> | null, "resets_at": <seconds>,
83
+ # "reset": <its reset has passed>, "resets": "3:40pm"}: used is null once
84
+ # reset is true, since the window the reading was of is over. resets is when,
85
+ # in the machine's own time: the clock alone on the same day, the weekday
86
+ # too within six days, and the date further away. A window the reading has
87
+ # none of is null. note says why there are no numbers when there are none:
88
+ # no reading yet, a file that cannot be read, or both limits reset since.
89
+ usage_show() {
90
+ local mode=$1 now got=missing reading=null view
91
+ command -v jq >/dev/null 2>&1 ||
92
+ die "jq is not installed, and ocnus reads the usage reading with it. Install it, then run this again."
93
+ now=$(date +%s)
94
+ if [ -e "$USAGE_FILE" ] || [ -L "$USAGE_FILE" ]; then
95
+ if reading=$(jq -cs 'if length == 1 and (.[0] | type) == "object" then .[0] else null end' "$USAGE_FILE" 2>/dev/null) &&
96
+ [ -n "$reading" ] && [ "$reading" != null ]; then
97
+ got=ok
98
+ else
99
+ got=bad reading=null
100
+ fi
101
+ fi
102
+ view=$(jq -cn --argjson r "$reading" --arg got "$got" --argjson now "$now" --argjson stale "$USAGE_STALE" \
103
+ --arg file "$USAGE_FILE" '
104
+ def num: type == "number";
105
+ def clock: (strflocaltime("%H") | tonumber) as $h | strflocaltime("%M") as $m
106
+ | "\(if $h % 12 == 0 then 12 else $h % 12 end)\(if $m == "00" then "" else ":" + $m end)\(if $h < 12 then "am" else "pm" end)";
107
+ def when: (if . > $now then . - $now else $now - . end) as $far
108
+ | if strflocaltime("%Y-%m-%d") == ($now | strflocaltime("%Y-%m-%d")) then clock
109
+ elif $far < 6 * 86400 then "\(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][strflocaltime("%w") | tonumber]) \(clock)"
110
+ else "\(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][(strflocaltime("%m") | tonumber) - 1]) \(strflocaltime("%d") | tonumber) \(clock)"
111
+ end;
112
+ def ago: floor
113
+ | if . < 60 then "\(.)s" elif . < 3600 then "\(. / 60 | floor)m"
114
+ elif . < 86400 then "\(. / 3600 | floor)h \(. % 3600 / 60 | floor)m"
115
+ else "\(. / 86400 | floor)d \(. % 86400 / 3600 | floor)h" end;
116
+ def window: if type == "object" and (.used | num) and (.resets_at | num) then
117
+ (.resets_at <= $now) as $reset
118
+ | {used: (if $reset then null else .used end), resets_at, reset: $reset, resets: (.resets_at | when)}
119
+ else null end;
120
+ (if ($r | type) == "object" and ($r.read_at | num) then $r else null end) as $r
121
+ | ($r.five_hour | window) as $five | ($r.seven_day | window) as $week
122
+ | (if $r then [$now - $r.read_at, 0] | max else null end) as $age
123
+ | ([$five, $week] | map(select(. != null))) as $windows
124
+ | {file: $file, read_at: $r.read_at, age: (if $age then $age | ago else null end),
125
+ stale: ($age != null and $age > $stale), five_hour: $five, seven_day: $week,
126
+ note: (if $got == "bad" or ($got == "ok" and $r == null) then "The last reading could not be read"
127
+ elif $r == null or ($windows | length) == 0 then "No reading yet"
128
+ elif ($windows | all(.reset)) then "Both limits have reset since the last reading"
129
+ else null end)}')
130
+ if [ "$mode" = json ]; then
131
+ printf '%s\n' "$view"
132
+ return
133
+ fi
134
+ jq -r '
135
+ def row($name): " \($name) " + (if . == null then "no reading"
136
+ elif .reset then "reset at \(.resets), no reading since"
137
+ else "\(.used + 0.5 | floor)% used, resets \(.resets)" end);
138
+ if .read_at == null then
139
+ if .note == "No reading yet" then "No reading of your Claude usage limits yet."
140
+ else "The last reading of your Claude usage limits, in \(.file), could not be read." end
141
+ else
142
+ "Claude usage limits, read \(.age) ago:",
143
+ (.five_hour | row("five-hour")),
144
+ (.seven_day | row("weekly "))
145
+ end' <<< "$view"
146
+ say "An agent task new or task build starts on your Claude subscription reads them as it works, and saves the reading in $USAGE_FILE."
147
+ if settings_load 2>/dev/null && [ "$SET_BILLING" = api ]; then
148
+ say "Billing is on the API, so the agents ocnus starts read no usage limits: switch back with: ocnus billing subscription"
149
+ fi
150
+ }
151
+
152
+ # The statusLine claude is given on the subscription (profile_args, in
153
+ # task.sh), as one line of JSON: a command that runs this copy of ocnus,
154
+ # told where ocnus's folder is, as billing_helper is, to save the reading
155
+ # it is handed. Each word is quoted for the shell claude runs it in.
156
+ usage_status_line() {
157
+ printf '{"type":"command","command":"%s"}' \
158
+ "$(json_str "OCNUS_HOME=$(sh_quote "$ENT_HOME") $(sh_quote "$REPO/cli/ocnus") usage record")"
159
+ }
package/cli/ocnus CHANGED
@@ -53,8 +53,9 @@ Usage:
53
53
  or with no card the cards that have hand-offs and where each stands
54
54
  ocnus linear key save your Linear API key, so ocnus can read and write Linear cards
55
55
  (it says when the key can read cards but not change them)
56
- ocnus linear read <card> [--json] print a card whole: its head, description, comments and
57
- sub-issues (--json for programs)
56
+ ocnus linear read <card> [--json] print a card whole: its head, with the cards that block it
57
+ and that it blocks, description, comments and sub-issues
58
+ (--json for programs)
58
59
  ocnus linear type <card> <feat|fix|chore>
59
60
  set a card's type, its label in the Type group
60
61
  ocnus linear section <card> <Specification|Plan|Breakdown|Review> [--replace]
@@ -62,6 +63,9 @@ Usage:
62
63
  ocnus linear slices <card> make a card's slices as its sub-issues, each with the card's
63
64
  type and blocked by the one before; the slices on stdin,
64
65
  and a run again makes only the ones still missing
66
+ ocnus linear block <card> <blocker>...
67
+ record in Linear that each blocker blocks the card, skipping
68
+ one it has already; it removes none
65
69
  ocnus linear move <card> <approved|started|review|done>
66
70
  move a card forward in Linear: to its team's first
67
71
  not-started status (Todo) with its sub-issues, its first
@@ -82,6 +86,9 @@ Usage:
82
86
  or on an Anthropic API key, or set it (--json for programs)
83
87
  ocnus billing key save the Anthropic API key the agents run on with billing
84
88
  on api
89
+ ocnus usage [--json] say how much of your Claude subscription's five-hour and
90
+ weekly usage limits is used, and when each resets, as the
91
+ agents ocnus starts last read it (--json for programs)
85
92
  ocnus host say whether how hard this machine works is recorded
86
93
  ocnus host on record it every 10 seconds while an agent is open
87
94
  ocnus host off stop recording, and delete every reading
@@ -109,8 +116,8 @@ status. It needs two things set once. `linear key` asks for a Linear API key
109
116
  and saves it (make one in Linear, under Settings, Account, Security & access,
110
117
  Personal API keys; Read permission is enough to list cards and for
111
118
  `linear read`, which the card skills read a card with, and the card skills'
112
- writes, `linear type`, `linear section`, `linear slices` and `linear move`,
113
- need Write too).
119
+ writes, `linear type`, `linear section`, `linear slices`, `linear block` and
120
+ `linear move`, need Write too).
114
121
  `linear key` and `status` check whether the key can change cards, by asking
115
122
  Linear to change a card that cannot exist, which changes nothing. A key that
116
123
  can read cards but not change them is still saved, and `linear key` says
@@ -123,7 +130,7 @@ with jq.
123
130
  `task new` takes the card's ID, like ABC-122. It opens a tab in the space,
124
131
  in Herdr, and starts an agent there, which writes the card up with the
125
132
  sdlc-define, sdlc-plan and sdlc-breakdown skills and asks you to approve it.
126
- Once you do, it runs task start, unless you hold the build phase for later.
133
+ Once you do, it runs task start: approving a card starts it.
127
134
  With the breakdown approval off (see `approval` below), it asks only about a
128
135
  card it has a doubt about, and approves and starts any other by itself.
129
136
  The Herdr app need not be open: with it closed, the agent starts in a
@@ -138,11 +145,15 @@ Linear for the card and names the branch from it, <type>/<card-id>-<short-name>
138
145
  group, and the short name is the first four words of its title, leaving out
139
146
  a, an and the, like feat/abc-122-export-orders-as-csv. It stops before it
140
147
  makes anything when Linear has no such card, the card has no type, no key is
141
- saved, or Linear cannot be asked. Without a key Linear accepts, give the
148
+ saved, or Linear cannot be asked. It also holds a card, making nothing and
149
+ leaving it in Todo, while a card that blocks it, or the card it was sliced
150
+ from, is not done yet: it names each such card, and you run it again once
151
+ they are done. Without a key Linear accepts, give the
142
152
  card's type and title after it, as the command the write-up phase runs or
143
153
  gives you then does: `--type feat --title 'Export orders as CSV'` names the
144
154
  branch Linear's would. They are used only when no key is saved or Linear cannot be
145
- asked (a rejected key, the network, no curl or jq), with a note saying why.
155
+ asked (a rejected key, the network, no curl or jq), with a note saying why,
156
+ and a note that the card's blockers were not checked.
146
157
  With a key Linear accepts, Linear's type and title win, with a note naming
147
158
  each given one that differs. Both are given or neither, and a type that is
148
159
  not a branch type stops it. It makes a folder in the space's tasks/ folder
@@ -224,9 +235,9 @@ from: it starts `task close` for it in herdr-core, detached, with no tab.
224
235
  session with /exit, which archives it in the Claude app's list, then closes
225
236
  its tab, or with the Herdr app closed ends its terminal. It never kills a
226
237
  live agent: one that has not exited 30 seconds after /exit, or a program in
227
- the tab that reports no status, leaves the tab open. With start later, the
228
- session stays open until task start is run, and a task start that stops
229
- leaves it open. Run in the write-up tab itself, task close refuses.
238
+ the tab that reports no status, leaves the tab open. A task start that
239
+ stops, or holds the card, leaves the write-up session open until task start
240
+ is run again and opens the build tab. Run in the write-up tab itself, task close refuses.
230
241
  `task finish` ends a task once its work has merged: it removes the task's
231
242
  worktrees, deletes its branch in each repo, deletes its folder and closes its
232
243
  tab, or with the Herdr app closed ends the tab's terminals in herdr-core. It
@@ -431,6 +442,15 @@ harness starts as it always has. A Claude Code signed in with /login to a
431
442
  Console API key uses that key whatever is set. The settings button switches
432
443
  it with `billing api` and `billing subscription`; the key is saved in a
433
444
  terminal.
445
+ `usage` says how much of your Claude subscription's five-hour and weekly
446
+ usage limits is used, and when each resets. On the subscription, claude
447
+ starts with a statusLine, given with --settings=, that runs
448
+ `usage record`, which saves the limits Claude Code hands it to usage.json
449
+ in ocnus's folder; it prints nothing, so the agents' status line is blank.
450
+ So the reading is as fresh as the last turn of an agent ocnus started, and
451
+ says how old it is; a limit whose reset has passed since is shown as reset.
452
+ Claude Code sessions you start yourself are not read. The Usage section,
453
+ above CPU in Herdr's sidebar, shows the same with `usage --json`.
434
454
 
435
455
  These variables, and your Linear key as LINEAR_API_KEY, can be exported in
436
456
  your shell or written as NAME=value lines in ~/.config/ocnus/.env, which
@@ -447,8 +467,8 @@ The copy of ocnus in a git worktree of the ocnus repo, run as
447
467
  ./cli/ocnus, is a change being built. It runs only the commands that
448
468
  read: help, status, space ls, space team <name> with no teams,
449
469
  profile ls, linear archive alone or with --json, tests alone or with
450
- --json, approval alone or with --json, billing alone or with --json, task ls
451
- and task log. Every other command
470
+ --json, approval alone or with --json, billing alone or with --json, usage
471
+ alone or with --json, task ls and task log. Every other command
452
472
  stops before it does anything, says why, and leaves this machine as it was.
453
473
  OCNUS_LIVE=1, set for that one run, runs it for real. The installed
454
474
  ocnus is never stopped, whatever folder it is run from.
@@ -603,7 +623,7 @@ TEMPLATE_MARK='<!-- ocnus:template -->'
603
623
 
604
624
  # Sourced, so every file shares the settings above and each other's functions.
605
625
  LIB=$REPO/cli/lib
606
- for part in common guard links recipes trust settings space linear archive tests approval billing task finish close agents github merges handoff host commands; do
626
+ for part in common guard links recipes trust settings space linear archive tests approval billing usage task finish close agents github merges handoff host commands; do
607
627
  [ -f "$LIB/$part.sh" ] ||
608
628
  { printf 'ocnus: %s is missing; reinstall ocnus\n' "$LIB/$part.sh" >&2; exit 1; }
609
629
  # shellcheck source=/dev/null
@@ -624,6 +644,7 @@ case ${1:-help} in
624
644
  tests) shift; cmd_tests "$@" ;;
625
645
  approval) shift; cmd_approval "$@" ;;
626
646
  billing) shift; cmd_billing "$@" ;;
647
+ usage) shift; cmd_usage "$@" ;;
627
648
  host) shift; cmd_host "$@" ;;
628
649
  help | -h | --help) usage ;;
629
650
  *) usage >&2; exit 2 ;;