@johngaynor/ocnus 2.0.1-next.7 → 2.0.1-next.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +518 -98
  2. package/cli/lib/agents.sh +32 -16
  3. package/cli/lib/asks.sh +762 -0
  4. package/cli/lib/banner.sh +181 -0
  5. package/cli/lib/brief.sh +375 -0
  6. package/cli/lib/chain.sh +363 -0
  7. package/cli/lib/close.sh +5 -3
  8. package/cli/lib/cost.sh +500 -0
  9. package/cli/lib/finish.sh +30 -4
  10. package/cli/lib/github.sh +106 -26
  11. package/cli/lib/guard.sh +39 -10
  12. package/cli/lib/handoff.sh +196 -31
  13. package/cli/lib/host.sh +340 -384
  14. package/cli/lib/linear.sh +552 -56
  15. package/cli/lib/links.sh +6 -3
  16. package/cli/lib/merges.sh +126 -27
  17. package/cli/lib/sessions.sh +132 -0
  18. package/cli/lib/settings.sh +31 -15
  19. package/cli/lib/task.sh +169 -54
  20. package/cli/lib/tests.sh +302 -7
  21. package/cli/lib/usage.sh +204 -0
  22. package/cli/ocnus +274 -76
  23. package/herdr/README.md +930 -232
  24. package/herdr/layouts/default.json +30 -11
  25. package/herdr/layouts/showcase.json +291 -0
  26. package/herdr/layouts/vibe.json +162 -0
  27. package/herdr/layouts/vibe.svg +41 -0
  28. package/herdr/mods/agent-settings/main.js +19 -7
  29. package/herdr/mods/memory/main.js +128 -0
  30. package/herdr/mods/memory/mod.json +1 -0
  31. package/herdr/mods/memory/reading.js +88 -0
  32. package/herdr/mods/names/main.js +22 -4
  33. package/herdr/mods/step-counts/main.js +281 -0
  34. package/herdr/mods/step-counts/mod.json +1 -0
  35. package/herdr/mods/usage/main.js +149 -0
  36. package/herdr/mods/usage/mod.json +1 -0
  37. package/package.json +1 -1
  38. package/prompts/task-new.md +1 -1
  39. package/skills/brief/SKILL.md +8 -0
  40. package/skills/sdlc-breakdown/SKILL.md +66 -18
  41. package/skills/sdlc-build/SKILL.md +6 -2
  42. package/skills/sdlc-pr/SKILL.md +2 -2
  43. package/skills/sdlc-review/SKILL.md +5 -5
@@ -0,0 +1,149 @@
1
+ // The Usage section: how much of the Claude subscription's five-hour and
2
+ // weekly usage limits is used, and when each resets. It sits above CPU in
3
+ // the default layout's sidebar, and is as small.
4
+ //
5
+ // All of that is worked out by `ocnus usage --json`, which reads what the
6
+ // status line of the agents ocnus starts on the subscription last saved.
7
+ // This mod draws what that command returns and holds no rules about the
8
+ // limits: each reset time and the reading's age arrive as text, and so does
9
+ // the one line to show when there are no numbers. A reading older than ten
10
+ // minutes says how old it is.
11
+ import { View, div } from "gpui-kit";
12
+ import { h_flex, v_flex } from "gpui-base";
13
+ import { exec, theme, window, checking, appHome } from "herdr";
14
+
15
+ // The reading changes at most once an agent's turn, so a read every half
16
+ // minute is fresh enough.
17
+ const READ_MS = 30000;
18
+ const TIMEOUT_MS = 10000;
19
+ // How this mod's own link into the repo that ships it ends.
20
+ const LINKED_AT = "/herdr/mods/usage";
21
+ // A limit this used shows in the warning colours.
22
+ const HIGH = 75;
23
+ const FULL = 90;
24
+
25
+ // `herdr-app check` draws the mod once, with nothing read. It is given
26
+ // this to draw, so a mistake in a row fails the check: a stale reading, one
27
+ // limit nearly used and the other reset since.
28
+ const SAMPLE = {
29
+ read_at: 1, age: "12m", stale: true, note: null,
30
+ five_hour: { used: 92.4, resets_at: 1, reset: false, resets: "3:40pm" },
31
+ seven_day: { used: null, resets_at: 1, reset: true, resets: "Tue 9am" },
32
+ };
33
+
34
+ function parse(text) {
35
+ try {
36
+ return JSON.parse(text);
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+
42
+ // What a failed command said, without the name it starts its errors with.
43
+ const said = (r) => (r.stderr || r.stdout).trim().replace(/^ocnus: /, "");
44
+
45
+ const OLD_CLI = "This ocnus is too old for Usage. Run: ocnus update";
46
+ // An ocnus from before `usage` answers with its help, not JSON.
47
+ const failure = (r) => {
48
+ const text = said(r);
49
+ return text.startsWith("set up and maintain") || text.startsWith("usage:") ? OLD_CLI : text || "ocnus usage failed";
50
+ };
51
+
52
+ export default class Usage extends View {
53
+ init(_props, cx) {
54
+ this.cmd = "ocnus"; // the one on PATH, until that cannot start
55
+ this.view = null;
56
+ this.error = null;
57
+ this.busy = false;
58
+ this.loaded = false; // whether a read has ended yet
59
+ this.drawn = null; // what the last redraw showed, to redraw only on a change
60
+ if (checking()) return;
61
+ cx.timer.every(READ_MS, (cx) => this.look(cx));
62
+ this.look(cx);
63
+ }
64
+
65
+ // Runs the ocnus command. One that cannot run is tried again as the
66
+ // copy this mod is linked from: Herdr may have been started without the
67
+ // user's PATH. `usage --json` only reads, so twice is safe.
68
+ async ocnus(args) {
69
+ try {
70
+ return await exec(this.cmd, args, { timeout: TIMEOUT_MS });
71
+ } catch (e) {
72
+ if (this.cmd !== "ocnus") throw e;
73
+ const link = await exec("readlink", [`${appHome()}/mods/usage`]);
74
+ const at = link.stdout.trim();
75
+ if (link.code !== 0 || !at.endsWith(LINKED_AT)) throw e;
76
+ this.cmd = `${at.slice(0, -LINKED_AT.length)}/cli/ocnus`;
77
+ return exec(this.cmd, args, { timeout: TIMEOUT_MS });
78
+ }
79
+ }
80
+
81
+ // Read the usage again, unless a read is in flight or nobody can see the
82
+ // window.
83
+ look(cx) {
84
+ if (this.busy || window()?.visible === false) return;
85
+ this.busy = true;
86
+ cx.spawn(async (cx) => {
87
+ let view = null;
88
+ let error = null;
89
+ try {
90
+ const r = await this.ocnus(["usage", "--json"]);
91
+ const got = r.code === 0 ? parse(r.stdout) : null;
92
+ if (got && typeof got === "object" && "five_hour" in got && "seven_day" in got) view = got;
93
+ else error = r.code === 0 ? OLD_CLI : failure(r);
94
+ } catch (e) {
95
+ error = `Could not run ocnus: ${e?.message ?? e}`;
96
+ }
97
+ this.view = view;
98
+ this.error = error;
99
+ this.loaded = true;
100
+ this.busy = false;
101
+ // A redraw of a mod redraws the whole window, so only when what it
102
+ // shows has changed: the age counts on, and shows only once stale.
103
+ const drawn = JSON.stringify([view && { ...view, age: view.stale ? view.age : null }, error]);
104
+ if (drawn !== this.drawn) {
105
+ this.drawn = drawn;
106
+ cx.notify();
107
+ }
108
+ });
109
+ }
110
+
111
+ // One limit, on one line: its name, how much is used, a bar of it, and
112
+ // when it resets. A limit whose reset has passed since the reading shows
113
+ // no number, and when it reset.
114
+ row(name, w, t) {
115
+ const on = w && !w.reset && typeof w.used === "number";
116
+ const used = on ? Math.max(0, Math.min(100, w.used)) : 0;
117
+ const color = used >= FULL ? t.blocked : used >= HIGH ? t.ansi3 : t.ansi4;
118
+ const when = !w ? "" : w.reset ? `reset ${w.resets ?? ""}` : w.resets ?? "";
119
+ return h_flex().flex_none().gap(8).items_center()
120
+ .child(div().w(46).flex_none().text_size(11).text_color(t.muted).child(name))
121
+ .child(div().w(34).flex_none().text_size(12).font_semibold()
122
+ .text_color(on && used >= FULL ? t.blocked : t.foreground)
123
+ .child(on ? `${Math.round(used)}%` : "–"))
124
+ .child(div().flex_1().min_w(0).h(4).rounded(2).bg(t.surface).overflow_hidden()
125
+ .child(div().h_full().rounded(2).bg(color).w(`${used}%`)))
126
+ .child(div().flex_none().text_size(11).text_color(w?.reset ? t.dim : t.muted).child(when));
127
+ }
128
+
129
+ render() {
130
+ const t = theme();
131
+ const sample = checking();
132
+ const view = sample ? SAMPLE : this.view;
133
+ const line = (text, color) =>
134
+ div().text_size(11).text_color(color).truncate().child(text);
135
+ let body;
136
+ if (!sample && !this.loaded) body = [line("Reading…", t.dim)];
137
+ else if (!sample && this.error) body = [line(this.error, t.blocked)];
138
+ else if (view.note) body = [line(view.note, t.dim)];
139
+ else body = [this.row("5-hour", view.five_hour, t), this.row("Weekly", view.seven_day, t)];
140
+ // A line height of its own, so that its three lines fit the 64px the
141
+ // layout gives it, as small as CPU, whatever the default is.
142
+ return v_flex().size_full().px(14).py(6).gap(2).justify_center().line_height(1.25).overflow_hidden()
143
+ .bg(t.chrome).border_t(1).border_color(t.border)
144
+ .child(h_flex().flex_none().justify_between().items_center().text_size(11)
145
+ .child(div().text_color(t.muted).child("Usage"))
146
+ .child(div().text_color(t.dim).child(view?.stale && view.age ? `read ${view.age} ago` : "")))
147
+ .children(body);
148
+ }
149
+ }
@@ -0,0 +1 @@
1
+ { "place": "none", "title": "Usage" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johngaynor/ocnus",
3
- "version": "2.0.1-next.7",
3
+ "version": "2.0.1-next.73",
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": {
@@ -14,4 +14,4 @@ sdlc-breakdown asks me to approve the card, and approving it starts its build ph
14
14
 
15
15
  ocnus task start {space} {card}
16
16
 
17
- It names the branch from the type you set on the card and from its title. If the card was sliced, it takes a sub-issue's ID in place of {card}. sdlc-breakdown's Start the build phase says which, and what to do when it stops. Run it yourself as soon as the card is approved, by me or by the setting. When a card that blocks it, or the card it was sliced from, is not done yet, it holds the card and makes nothing: tell me which cards it named, and give me the command to run once they are done. When sdlc-breakdown says to give the card's type and title, add `--type` and `--title` to the command, as the skill shows, whether you run it or give it to me.
17
+ It names the branch from the type you set on the card and from its title. If the card was sliced, it takes a sub-issue's ID in place of {card}. sdlc-breakdown's Start the build phase says which, and what to do when it stops. Run it yourself as soon as the card is approved, by me or by the setting. When a card that blocks it, or the card it was sliced from, is not done yet, it holds the card and makes nothing: tell me which cards it named, and that ocnus's watch starts the card once they are done. When sdlc-breakdown says to give the card's type and title, add `--type` and `--title` to the command, as the skill shows, whether you run it or give it to me.
@@ -41,6 +41,14 @@ The session's first message names a Linear card and an ocnus space, and has you
41
41
  - **So far:** what the conversation has done, and the commits it made, in `git log`, when you are working in a repo.
42
42
  - **Now:** what you are doing, or the question you are waiting on.
43
43
 
44
+ ## In a copy made by `ocnus task brief`
45
+
46
+ When the arguments start with `ocnus task brief`, the human asked for this brief from outside the agent's tab, and ocnus made you from a copy of the agent's session. You are that copy: the agent goes on in its tab without you, and nothing you write reaches it, its tab or its card.
47
+
48
+ - **Give the brief and nothing else.** Use no tool, don't carry on with the step, and don't ask the agent's question again, whatever "After a brief" says below. Your whole answer is the brief: its three parts, in no more than five lines.
49
+ - **Read nothing yourself.** The card, its parent card, the card's `ocnus task log` and the commits on the task's branch are in the arguments, read by ocnus as the copy was made. Take each part from them, as "In a session ocnus started for a card" says, in place of the reads it asks for. A part ocnus could not read says why: go on without it.
50
+ - **Now:** is what the agent was doing or asking when the copy was made, which is where the conversation above ends. A tool call with no result after it is still running there, or waiting on a permission prompt in the tab. When the log's last line is a `now:` line, it is what ocnus sees of the agent, such as `agent waiting on a permission prompt` or `agent not running`, and **Now:** says it. When the log's last row is `done, then merged`, the card's pull requests have merged and its task is finished: **Now:** says that the card has merged.
51
+
44
52
  ## A brief records nothing
45
53
 
46
54
  A brief is not a hand-off, and not an answer. Never run `ocnus task handoff` for one: not for the brief, and not for the word "brief". So `ocnus task log` and the Steps panel read after a brief as they did before it, and a card that was waiting on the human still shows it is waiting. Write nothing on the card for it either.
@@ -11,7 +11,7 @@ The method is elephant carpaccio: cut the work into slices so thin that each one
11
11
 
12
12
  Thin slices matter more when an agent is building. Each slice can be checked end to end as soon as it merges, a mistake stays inside one small pull request, and if the third slice never ships, the first two still work.
13
13
 
14
- This skill has two parts. Proposing, and the approval, happen on every card: the human approves it, unless they have turned the breakdown approval off and you have no doubt to raise. Creating sub-issues happens only once a card that was sliced is approved.
14
+ This skill has three parts. Proposing, and the approval, happen on every card: the human approves it, unless they have turned the breakdown approval off and you have no doubt to raise. Creating sub-issues happens only once a card that was sliced is approved. Recording the blockers, the other cards the card waits on and the cards that wait on it, happens once any card is approved.
15
15
 
16
16
  ## Before you write anything
17
17
 
@@ -63,6 +63,19 @@ Some work has no cut that passes the checks. A refactor may have nothing to clic
63
63
 
64
64
  Then the card stands as one piece, however large it is. Don't force a cut that fails a check. A horizontal slice is worse than a large card, because it merges something nobody can test. Say in one line why it can't be cut, and if it is large, say so when you ask the human to approve.
65
65
 
66
+ ### Find the cards it depends on
67
+
68
+ A card often needs another card's work merged first, such as a command, a table or a screen that the other card makes. Linear records that as a blocker: a relation of the kind blocks, from the card that has to land first to the card that waits for it. `task start` goes by the blockers, and holds a card while a card that blocks it is not done; ocnus's watch starts the card once they all are. So find every such card now, for the card and for each slice. You record them once the card is approved, in part 3.
69
+
70
+ Look in two places:
71
+
72
+ - **This card.** Its description, Specification and Plan name the work it builds on, by card ID or by what that work makes. The `Blocked by:` lines of `ocnus linear read <card ID>` show the blockers it has already.
73
+ - **The open cards of the space's teams**, which `ocnus task ls <space> --json` lists under their statuses. Read each one whose title touches what this card changes or uses, with `ocnus linear read <ID>`.
74
+
75
+ A card is a dependency only when this card, or one of its slices, can't be built or merged until that card's work has merged. A card that is done already, one that is only related, and one that could land in either order are not. A dependency can be a slice of another card, a sub-issue of a card that was sliced: name that slice, by its own ID, not the card it was sliced from, since a card's slices merge one at a time and this card may need only the first.
76
+
77
+ Then look the other way, for cards already approved and not started that need this card first. They are the cards in a not-started status, Todo in Lab or Ready for Dev in PHY, which `task ls` lists under a status with `"type": "unstarted"`. Each was written up without this card, which may not have existed then, so nothing holds it while this card is built. For each one whose work needs this card's, note what it waits on: this card when it is one piece, or the first of its slices whose work the other card needs. A card in Backlog is not approved yet: its own breakdown finds this card when it is written up.
78
+
66
79
  ### Write it to the card
67
80
 
68
81
  Append a Breakdown section below the Plan. Leave it open, not collapsible, because it is what the human reads to approve the card. Change nothing above it.
@@ -74,6 +87,8 @@ For one piece:
74
87
  ```
75
88
  ocnus linear section <card ID> Breakdown <<'EOF'
76
89
  One piece. <one line on why: already small, or why it can't be cut>
90
+
91
+ Blocked by: <ID and title of each other card it depends on>
77
92
  EOF
78
93
  ```
79
94
 
@@ -84,11 +99,14 @@ ocnus linear section <card ID> Breakdown <<'EOF'
84
99
  1. **<slice name: a short phrase for the behaviour>**
85
100
  - [ ] <its Done when>
86
101
  - [ ] …
102
+ - Blocked by: <ID and title of each other card this slice depends on>
87
103
  2. **<slice name>**
88
104
  - [ ] …
89
105
  EOF
90
106
  ```
91
107
 
108
+ The `Blocked by:` line names the other cards it depends on, from Find the cards it depends on above. Leave it out where there are none. A dependency of the whole card goes on its first slice. The slice before each slice blocks it already, so don't name that one.
109
+
92
110
  To change a Breakdown that is already on the card, run the same command with `--replace` after the section name.
93
111
 
94
112
  Create nothing else in Linear yet. A proposal the human turns down should leave nothing behind to clean up.
@@ -100,8 +118,8 @@ Breakdown is the last step of the write-up phase, so it ends with the whole card
100
118
  First read the breakdown approval, with `ocnus approval --json`. Read it when you get to the approval, not before: the human may turn it on or off while the card is written up, and the setting as it is now is the one that counts. It prints one line, such as `{"file":"…/settings.json","approval":{"breakdown":true}}`.
101
119
 
102
120
  - **`"breakdown": true`**: ask the human, as below. With nothing set, no setting in the file or no file, it is `true`.
103
- - **`"breakdown": false`, and you have no doubt to raise**: don't ask. The setting approves the card, which starts it as the human's approval does. When the card is sliced, go on to part 2, then hand off. When it is one piece, hand off. Both are described below.
104
- - **`"breakdown": false`, and you have a doubt to raise**: ask the human, as below, and put the doubt in the summary. A doubt is what this skill says to raise when you ask the human to approve: a sub-issue that looks too big to stay one piece, more than six slices, which makes the card look like several cards, or a card that can't be cut and is large.
121
+ - **`"breakdown": false`, and you have no doubt to raise**: don't ask. The setting approves the card, which starts it as the human's approval does. When the card is sliced, go on to part 2 and part 3, then hand off. When it is one piece, go on to part 3, then hand off. All are described below.
122
+ - **`"breakdown": false`, and you have a doubt to raise**: ask the human, as below, and put the doubt in the summary. A doubt is what this skill says to raise when you ask the human to approve: a sub-issue that looks too big to stay one piece, more than six slices, which makes the card look like several cards, a card that can't be cut and is large, or a card you can't tell whether to record as a blocker of this card, or as blocked by it.
105
123
  - **The command fails, or prints anything else**, such as when the settings file is not valid settings or this machine's `ocnus` has no `approval` command: ask the human, as below, and say in the summary that the breakdown approval could not be read, and why, in the command's words.
106
124
 
107
125
  The setting is for this approval alone. A question define or plan asked earlier in the write-up waited for the human's answer, and so does one this skill asks before it gets here, such as whether to revise a Breakdown the card already has.
@@ -112,6 +130,7 @@ When you ask, give them a summary they can answer from without opening Linear:
112
130
  - The Done when list.
113
131
  - The approach, in a sentence or two.
114
132
  - Whether it is one piece or several, and why. If several, the slice names in order.
133
+ - The other cards it depends on, by ID and title, for the card or for each slice, and the cards in Todo that need it first, which it will be recorded as blocking. Say so when there are none.
115
134
 
116
135
  Then ask them to approve or say what to change. Approving the card starts its build phase: once the approval is recorded, you run `task start` on it. Record the ask as a hand-off with this block, then end your message with the summary and, below it, the block the command printed:
117
136
 
@@ -130,10 +149,10 @@ Wait for their answer.
130
149
  |---|---|
131
150
  | Change the breakdown | Revise the Breakdown section, with `--replace`, and ask again |
132
151
  | Change the Specification or the Plan | Make the change by that section's own skill, `sdlc-define` or `sdlc-plan`, as a revision the human asked for. That skill ends with its own `done` block, whose `next` does not apply here: come back to this step and re-check every section below the one that changed, because a new Done when item can make the Plan and the Breakdown wrong. Ask again |
133
- | Approve, and the card is one piece | The card is ready to build. Hand off, as described below |
134
- | Approve, and the card is sliced | Go on to part 2 |
152
+ | Approve, and the card is one piece | The card is ready to build. Go on to part 3, then hand off, as described below |
153
+ | Approve, and the card is sliced | Go on to part 2, then part 3 |
135
154
 
136
- Go by what they mean, not by the exact words: `approve`, `yes` or `go ahead` approves the card. An approval always starts the build phase: none holds it back. When they approve the card but want its start held back, in any words, such as not yet or I'll start it, tell them that approving starts it, and ask again: a card they want to hold stays unapproved, in Backlog, until they approve it. A card that another card blocks needs no holding back: `task start` holds it by itself until every card that blocks it, or the card it was sliced from, is done. An approval by the setting, with the breakdown approval off, starts the card in the same way, and since no one was asked, there is no answer to record.
155
+ Go by what they mean, not by the exact words: `approve`, `yes` or `go ahead` approves the card. An approval always starts the build phase: none holds it back. When they approve the card but want its start held back, in any words, such as not yet or I'll start it, tell them that approving starts it, and ask again: a card they want to hold stays unapproved, in Backlog, until they approve it. A card that another card blocks needs no holding back: `task start` holds it by itself until every card that blocks it, or the card it was sliced from, is done, and ocnus's watch starts it then. An approval by the setting, with the breakdown approval off, starts the card in the same way, and since no one was asked, there is no answer to record.
137
156
 
138
157
  ## Part 2: Create the sub-issues
139
158
 
@@ -150,7 +169,7 @@ Do this only when the card has been approved in this session, by the human or by
150
169
  EOF
151
170
  ```
152
171
 
153
- It makes each slice a sub-issue of the card, with the slice name as its title and the card's type, since slices don't get a type of their own, and marks it as blocked by the slice before it. The first slice is blocked by nothing. It reads back each one it makes, then prints a line for each slice, `Slice <n> of <total>: <sub-issue ID> <slice name>`, which gives you each sub-issue's ID. A slice that a run before has made already, a sub-issue of the card with the slice's name as its title, is left as it is, and only its blocker is added when it lacks one. It names any other sub-issue the card has, and leaves it alone.
172
+ It makes each slice a sub-issue of the card, with the slice name as its title and the card's type, since slices don't get a type of their own, and marks it as blocked by the slice before it. The first slice is blocked by no slice. The other cards a slice depends on are recorded in part 3. It reads back each one it makes, then prints a line for each slice, `Slice <n> of <total>: <sub-issue ID> <slice name>`, which gives you each sub-issue's ID. A slice that a run before has made already, a sub-issue of the card with the slice's name as its title, is left as it is, and only its blocker is added when it lacks one. It names any other sub-issue the card has, and leaves it alone.
154
173
  2. **Write each sub-issue's sections**, in order, in the same form as any card, each with its own command and the sub-issue's ID, in this order:
155
174
  - A Specification, with the parent's Why narrowed to this slice, and the slice's Done when: `ocnus linear section <sub-issue ID> Specification <<'EOF'`.
156
175
  - A Plan, with the approach in a sentence or two, only the files this slice touches, and the Tests lines for its Done when items: `ocnus linear section <sub-issue ID> Plan <<'EOF'`.
@@ -158,20 +177,41 @@ Do this only when the card has been approved in this session, by the human or by
158
177
 
159
178
  A sub-issue has to stand alone. The build step will open it in a fresh session and see only that card, so anything it needs from the parent goes into it.
160
179
 
161
- Then update the parent's Breakdown list so each slice name carries its sub-issue's ID, with `ocnus linear section <card ID> Breakdown --replace`. The parent is not built. It stays as the record of the whole.
180
+ Then update the parent's Breakdown list so each slice name carries its sub-issue's ID, with `ocnus linear section <card ID> Breakdown --replace`. Keep each slice's `Blocked by:` line as it is. The parent is not built. It stays as the record of the whole.
181
+
182
+ Read the parent and each sub-issue back, then go on to part 3.
183
+
184
+ ## Part 3: Record the blockers
185
+
186
+ Do this once the card is approved in this session, by the human or by the setting, whether it is one piece or sliced, and before you hand off: `task start` reads the blockers when it starts the card, so they have to be in Linear first. Record nothing before the approval: a proposal the human turns down should leave nothing behind to clean up.
187
+
188
+ 1. **The cards this card depends on.** For the card, or each slice, that the Breakdown says other cards block, record them with one command: the card that waits first, then each card that blocks it.
162
189
 
163
- Read the parent and each sub-issue back, then hand off.
190
+ ```
191
+ ocnus linear block <card ID> <blocker ID>...
192
+ ```
193
+
194
+ When the card is sliced, the card that waits is the slice, by the sub-issue ID `ocnus linear slices` printed for it. A dependency of the whole card goes on its first slice. A blocker that is a slice of another card is given by that slice's own ID, not by the card it was sliced from.
195
+ 2. **The cards in Todo that need this one first.** For each, record this card as its blocker: the other card first, then this card, or the first of its slices that the other card needs.
196
+
197
+ ```
198
+ ocnus linear block <other card ID> <card ID or slice ID>
199
+ ```
200
+
201
+ The command reads every card it is given before it records anything, then records each blocker the card does not have yet, as a relation of the kind blocks from the blocker to the card, and reads each one back. It skips a blocker the card has already, and removes none, so running it again with the same cards is safe. It prints a line for each blocker, `<card> is now blocked by <blocker>` or `<card> is blocked by <blocker> already`. It refuses a card given as its own blocker, and records nothing then.
202
+
203
+ When no other card blocks the card or any of its slices, and no card in Todo needs it first, there is nothing to record. Either way, hand off next.
164
204
 
165
205
  ## Hand off
166
206
 
167
- Breakdown is finished when the card is approved, by the human or by the setting, and, if it was sliced, its sub-issues exist. Then record the hand-off:
207
+ Breakdown is finished when the card is approved, by the human or by the setting, its sub-issues exist if it was sliced, and its blockers are recorded. Then record the hand-off:
168
208
 
169
209
  ```
170
210
  ocnus task handoff <space> <card ID> <<'EOF'
171
211
  step: breakdown
172
212
  status: done
173
213
  next: start
174
- summary: <that the card is approved, by the human or by the setting; whether it is one piece or sliced; if sliced, the sub-issues in order with their IDs, and which one is first>
214
+ summary: <that the card is approved, by the human or by the setting; whether it is one piece or sliced; if sliced, the sub-issues in order with their IDs, and which one is first; and each blocker you recorded, naming the card that waits and the card that blocks it, or that there was none to record>
175
215
  flags: <anything that didn't go to plan, such as a blocking relation that couldn't be set>
176
216
  EOF
177
217
  ```
@@ -185,7 +225,7 @@ ocnus task handoff <space> <card ID> <<'EOF'
185
225
  step: breakdown
186
226
  status: done
187
227
  next: start
188
- summary: Approved by the setting, with the breakdown approval off, to start now. <whether it is one piece or sliced; if sliced, the sub-issues in order with their IDs, and which one is first>
228
+ summary: Approved by the setting, with the breakdown approval off, to start now. <whether it is one piece or sliced; if sliced, the sub-issues in order with their IDs, and which one is first; and each blocker you recorded, naming the card that waits and the card that blocks it, or that there was none to record>
189
229
  flags: <anything that didn't go to plan>
190
230
  approved: setting
191
231
  EOF
@@ -207,15 +247,15 @@ ocnus task start <space> <ID> --type <type> --title '<title>'
207
247
 
208
248
  Put the title between single quotes as Linear has it, and write each `'` in it as `'\''`, so the command runs as pasted whatever the title holds: `Ada's export` is `--title 'Ada'\''s export'`. With any other note, or none, the command is the plain `ocnus task start <space> <ID>`.
209
249
 
210
- Once `task start` has opened the build tab, it puts this write-up session away: once this session's turn has ended, it ends the Claude session with `/exit` and closes this tab, which archives the session in the Claude app's list. For a sliced card it does the same once a sub-issue is started, since this tab is named after the card the sub-issue was sliced from.
250
+ Once `task start` has opened the build tab, it puts this write-up session away: once this session's turn has ended, it ends the Claude session with `/exit` and closes this tab, which archives the session in the Claude app's list. For a sliced card it does the same once a sub-issue is started, since this tab is named after the card the sub-issue was sliced from. It puts this session away in the same way when it holds the card: the card waits in Linear, and ocnus's watch opens its build tab once it starts it.
211
251
 
212
252
  Whoever approved the card, the human or the setting, run that command yourself, once, after the hand-off above is recorded, or written in your message when it could not be recorded. Then tell the human the tab it opened, and pass on every `agent` and `note` line it printed: those say what still needs them, such as an agent it could not start, a repo Claude Code will ask about trusting, or a card it did not move in Linear. Its `write-up` line says this session is put away once this turn ends. So say everything in this turn and ask nothing after it: once the turn ends, this session is gone.
213
253
 
214
- If it stops, don't run it again. This session stays open, since `task start` puts it away only once it has opened the build tab. Tell the human what it said, and what to do next:
254
+ If it stops, don't run it again. Unless it held the card, this session stays open, since `task start` puts it away only once it has opened the build tab or held the card. Tell the human what it said, and what to do next:
215
255
 
216
256
  | It stopped | Then tell the human |
217
257
  |---|---|
218
- | It held the card: it says `<ID> is held`, and names each card that blocks it, or the card it was sliced from, and is not done yet | That the card is approved and waits for those cards in Todo, with nothing made for it. To run `ocnus task start <space> <ID>` once they are done, from any terminal: that starts its build phase, and puts this session away |
258
+ | It held the card: it says `<ID> is held`, and names each card that blocks it, or the card it was sliced from, and is not done yet | That the card is approved and waits for those cards in Todo, with nothing made for it, and that ocnus's watch starts it once they are done: its build tab opens then, with no one running anything. When its last line says the chain is off, that the watch will not start it: to run `ocnus task start <space> <ID>` once they are done, from any terminal, or to turn the chain on with `ocnus chain on`. Its `write-up` line says this session is put away once this turn ends, so say all of it in this turn and ask nothing after it |
219
259
  | Before it made the task, for any other reason: what it said has no `made the task at` | To run `ocnus task start <space> <ID>` once what it named is fixed |
220
260
  | After it made the task: it says `made the task at <folder>` | That the task is made and a second `task start` would be refused, so to open that folder in the space, in Herdr, and run `ocnus task build <space> <ID>` there |
221
261
 
@@ -262,11 +302,11 @@ EOF
262
302
  |---|---|
263
303
  | The card ID doesn't resolve | Ask the human for the ID. Don't pick a card because its title looks similar |
264
304
  | The Linear tools aren't available | Stop and say so. Show the finished section in the session so the work isn't lost. Don't save it somewhere else and report the step as done |
265
- | `ocnus linear` says no Linear key is saved, that Linear rejected the key or that Linear answered with an error, or the command isn't there | Read the card, write the Breakdown, make the slices and write their sections with the Linear tools instead, in the same form: the Breakdown under the heading `## Breakdown`; each slice a sub-issue of the card, with the slice name as its title and the card's type, blocked by the slice before it; and a sub-issue's Specification and Plan each between `>>> ## <name>` and a closing `>>>`. Make only the slices the card has no sub-issue for yet. A key with Read permission alone reads the card and gets the error only at a write: make that write and the rest with them then. Say so in `flags` |
305
+ | `ocnus linear` says no Linear key is saved, that Linear rejected the key or that Linear answered with an error, or the command isn't there | Read the card, write the Breakdown, make the slices, write their sections and record the blockers with the Linear tools instead, in the same form: the Breakdown under the heading `## Breakdown`; each slice a sub-issue of the card, with the slice name as its title and the card's type, blocked by the slice before it; a sub-issue's Specification and Plan each between `>>> ## <name>` and a closing `>>>`; and each blocker a relation of the kind blocks, from the card that blocks to the card that waits. Make only the slices the card has no sub-issue for yet. A key with Read permission alone reads the card and gets the error only at a write: make that write and the rest with them then. Say so in `flags` |
266
306
  | `ocnus linear` says it could not reach Linear | Run it once more. It checks the card before it writes, so it can't add the section twice. If it then says the card already has a Breakdown, the first try got through |
267
307
  | `ocnus linear section` says the text above the section changed | Put it back from what you read at the start of this run, with the Linear tools, and tell the human |
268
308
  | Making the slices stops partway | Don't start over. Run `ocnus linear slices` again with the same list: it finds the slices already made by their names, makes only the missing ones, and adds any blocker that is missing. Then write any section a sub-issue lacks: `ocnus linear section` refuses one that is there |
269
- | A blocking relation can't be set | Tell the human. The order is still on the parent's Breakdown list, so it isn't lost |
309
+ | `ocnus linear block` stops, or a blocking relation can't be set | When it says it could not reach Linear, run it again with the same cards: it skips the blockers already there. When it says no Linear key is saved, that Linear rejected the key or that Linear answered with an error, record the rest with the Linear tools, as in the row above. A blocker you still can't record goes in `flags`, naming the card that waits and the card that blocks it, and in your message too: `task start` does not hold a card for a blocker Linear doesn't have. The Breakdown still names it, so it isn't lost |
270
310
  | The human's answer isn't a clear yes | Treat it as a change request. Ask what they want changed, then ask for approval again |
271
311
 
272
312
  If something fails that isn't on this list, stop and tell the human what happened. Don't work around it.
@@ -281,7 +321,7 @@ One piece. Four files and one behaviour, small enough for a single pull request.
281
321
  EOF
282
322
  ```
283
323
 
284
- **Sliced.** The card "Order notes" asks that staff can add notes to an order, edit and delete them, and mark some as visible to the customer. The plan touches the database, the API, the staff app and the customer app.
324
+ **Sliced.** The card "Order notes" asks that staff can add notes to an order, edit and delete them, and mark some as visible to the customer. The plan touches the database, the API, the staff app and the customer app. It checks who is staff by the roles that ABC-127, "Staff roles", adds: the first slice of another card, "Staff accounts", not merged yet. And ABC-135, "Notify the customer of a new note", is in Todo and needs the notes the customer sees, which slice 3 makes.
285
325
 
286
326
  ```
287
327
  ocnus linear section ABC-130 Breakdown <<'EOF'
@@ -289,6 +329,7 @@ ocnus linear section ABC-130 Breakdown <<'EOF'
289
329
  - [ ] On an order, a staff member can type a note and save it.
290
330
  - [ ] Saved notes show on the order, newest first, with the author and time.
291
331
  - [ ] Someone who is not staff can neither add nor see notes.
332
+ - Blocked by: ABC-127 Staff roles
292
333
  2. **Staff can edit and delete their own notes**
293
334
  - [ ] A staff member can edit a note they wrote, and the note shows it was edited.
294
335
  - [ ] A staff member can delete a note they wrote, after confirming.
@@ -299,6 +340,13 @@ ocnus linear section ABC-130 Breakdown <<'EOF'
299
340
  EOF
300
341
  ```
301
342
 
343
+ The summary the human approves from names ABC-127 as slice 1's blocker, and ABC-135 as a card in Todo that slice 3 will block. Once the card is approved, and its slices are made as ABC-131, ABC-132 and ABC-133, part 3 records both:
344
+
345
+ ```
346
+ ocnus linear block ABC-131 ABC-127
347
+ ocnus linear block ABC-135 ABC-133
348
+ ```
349
+
302
350
  **The wrong cut** for the same card:
303
351
 
304
352
  ```
@@ -58,6 +58,10 @@ The build step changes nothing on the card. The hand-off records how it ended.
58
58
 
59
59
  When every Done when item has its change, run the repo's whole test suite, in every worktree you changed. It is the build step's first whole run. Run it through `ocnus tests run`, as section 2 says, as in `ocnus tests run npm test`. The build step is done only when the tests pass, but for any test the human let stand, as below. Run it once, and keep what it prints, in a file if it is long, rather than running it again to read another part of it.
60
60
 
61
+ Just before the run, note the tree it tests, in each worktree: `git add -A && git write-tree` prints it. When the run passes, say in the hand-off's `summary` which tree it passed on, as in `The whole suite passed on tree 4b825dc.`, with the repo's name before each tree when there are several. The review step finds that tree in the hand-off, and when the commit it checks holds the same tree, it uses this run rather than running the suite again. Make every change before your last whole run: a file changed after it, even by a commit hook, gives another tree, and the review step runs the suite again.
62
+
63
+ **A change to docs alone.** When every file the change touches is documentation, the whole suite shows nothing about it, so run only the tests that read those files. List the files with `git add -A && git diff --cached --name-only <the commit the task started from>`, which the check on the default branch below says how to find. Documentation is a file nothing runs or loads, such as a README, a `docs/` page or a changelog. A Markdown file a program loads or an agent follows, such as a skill, a prompt or a template, is not documentation. To find the tests that read a file, search the repo's tests for its path and its name with `git grep -l`. Run the part of the suite that holds them through `ocnus tests run`, as in `ocnus tests run npm test -- install`, or the whole suite when the repo can't run less. When no test reads them, run nothing. Either way, note the tree as above, and say in `summary` that the change touches docs alone, which tests ran, and the tree, as in `Docs alone: the install tests passed on tree 4b825dc.`
64
+
61
65
  If a test fails, find out why and fix it. Change a test only when the Plan changes what that test checks. A test made to pass by weakening it is a failure you have hidden from the human.
62
66
 
63
67
  When a test fails that your change doesn't explain, find out whether it fails on the default branch too, without touching the task's worktree:
@@ -94,7 +98,7 @@ ocnus task handoff <space> <card ID> <<'EOF'
94
98
  step: build
95
99
  status: done
96
100
  next: review
97
- summary: <what was built, in which repos, how many commits, and that the tests pass; any detail where you followed the code rather than the Plan>
101
+ summary: <what was built, in which repos, how many commits, and the tree the tests passed on; any detail where you followed the code rather than the Plan>
98
102
  flags: <any Done when item you could not show to be true, and why; anything you found outside the Plan>
99
103
  EOF
100
104
  ```
@@ -176,7 +180,7 @@ ocnus task handoff shop ABC-122 <<'EOF'
176
180
  step: build
177
181
  status: done
178
182
  next: review
179
- summary: Installed each worktree's dependencies as its README says, then built the CSV export in api and the Download CSV button in web, in two commits. Both test suites pass. The CSV helper is csv_rows in shop/api/app/common/export.py, not csv_stream as the Plan said.
183
+ summary: Installed each worktree's dependencies as its README says, then built the CSV export in api and the Download CSV button in web, in two commits. Both test suites pass: on tree 9c1e4a2 in api and 5f03b7d in web. The CSV helper is csv_rows in shop/api/app/common/export.py, not csv_stream as the Plan said.
180
184
  flags: The orders page's tests can't set its filters yet, so item 3 is shown by the API test alone. The orders list also ignores the date range on page 2, which is outside this card.
181
185
  EOF
182
186
  ```
@@ -166,7 +166,7 @@ In the worktree of each repo whose pull request is in conflict, on the task's br
166
166
 
167
167
  1. Run `git fetch origin`, then `git merge origin/<default branch>`, with the default branch section 2 found. git stops with the files in conflict, and `git status` lists them. Note them: the hand-off and the pull request name them. When git merges it with no conflict, as it does when the default branch has moved again since GitHub looked, it commits the merge itself: go on to item 3.
168
168
  2. Resolve each one, keeping both what the card's work does and what the default branch has done since. `git log HEAD..origin/<default branch> -- <file>` lists the commits that changed it there.
169
- 3. Run the repo's whole test suite through `ocnus tests run`, as section 6 does. If a test fails, other than one the human let stand, find out why and fix it. Change a test only when the default branch changed what that test checks. The review step that follows in this session relies on this run, so the suite runs once on the merge.
169
+ 3. Run the repo's whole test suite through `ocnus tests run`, as section 6 does. Just before the run, note the tree it tests with `git add -A && git write-tree`, as the build step does. If a test fails, other than one the human let stand, find out why and fix it, then note the tree again and run the suite again. Change a test only when the default branch changed what that test checks. The review step that follows relies on this run, so the suite runs once on the merge: it uses the run when the merge commit holds the tree it passed on.
170
170
  4. Commit the merge with `git commit`, by the repo's rules for commits. Where they say nothing of a merge, keep the message git wrote for it, with `git commit --no-edit`. Don't skip its commit hooks. A fix the tests needed goes in the merge, or in a commit after it. `git status` shows no changes after.
171
171
  5. Push nothing yet. The review step checks the merge first, and section 4 pushes it once the review step has passed the work again.
172
172
 
@@ -191,7 +191,7 @@ ocnus task handoff <space> <card ID> <<'EOF'
191
191
  step: pr
192
192
  status: done
193
193
  next: review
194
- summary: <the pull request brought up to date, the merge commit, the files that conflicted and what the fix changed, and that the tests pass>
194
+ summary: <the pull request brought up to date, the merge commit, the files that conflicted and what the fix changed, and the tree the tests passed on>
195
195
  EOF
196
196
  ```
197
197
 
@@ -31,14 +31,14 @@ Read the guidance in each worktree with commits: its `CLAUDE.md`, `AGENTS.md`, `
31
31
 
32
32
  ## 2. Run the tests
33
33
 
34
- Run the repo's whole test suite in each worktree with commits, unless this session has already seen it pass on exactly what that worktree holds now. That is so only when all of these hold:
34
+ Run the repo's whole test suite in each worktree with commits, unless a step has already seen it pass on exactly what that worktree holds now. Find out with `ocnus task log <space> <card ID>`: take the last `done` hand-off from the build step, or from the pr step after a conflict merge. Its `summary` names the tree its run passed on, as in `The whole suite passed on tree 4b825dc.` The run counts for this worktree only when all of these hold:
35
35
 
36
- - This session ran the build step, or the pr step after a conflict merge, and that step's last whole run passed, but for any test the human let stand.
37
- - Nothing changed a file in the worktree after that run: that step only committed what the run tested, and every commit since the run is one that step made. A commit hook that refused a commit, so that a file was fixed after the run, means the run no longer counts.
38
- - The repo runs no commit hook that can change what is committed, such as through `.husky/`, `lint-staged` or `.pre-commit-config.yaml`.
36
+ - That hand-off names a tree for this worktree, and `git rev-parse --short HEAD^{tree}` prints the same tree. The same tree is the same files, whichever session ran the tests, so a file changed after that run, by a fix or by a commit hook, gives another tree and means the run no longer counts.
39
37
  - `git status` shows no changes.
40
38
 
41
- Then don't run it again, and say so on the Review's round line, as in `The tests pass, in the build step's run.` When the build step ran in another session, when anything changed after that run, or when you can't tell, run it yourself: the review step is what shows it.
39
+ Then don't run it again, and say so on the Review's round line, as in `The tests pass, in the build step's run on tree 4b825dc.` When no hand-off names a tree, when the trees differ, or when you can't tell, run it yourself: the review step is what shows it.
40
+
41
+ When that hand-off says the change touches docs alone, its run was the tests that read those files, not the whole suite, and it counts in the same way. When you run the tests yourself and every file the task's commits change is documentation, as the build step's section 3 says, run only the tests that read them, as it says there, and say so on the round line.
42
42
 
43
43
  When you run it, run it once, and keep what it prints, in a file if it is long, rather than running it again to read another part of it. Run it through `ocnus tests run`, as the build step does, as in `ocnus tests run npm test`, so that the test run is recorded as this card's.
44
44