@johngaynor/ocnus 0.0.0-stage → 2.0.0
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/LICENSE +21 -0
- package/README.md +988 -2
- package/agents/linear-mcp.json +1 -0
- package/agents/ocnus-build.md +23 -0
- package/agents/ocnus-write-up.md +20 -0
- package/cli/host-mark +36 -0
- package/cli/lib/agents.sh +350 -0
- package/cli/lib/approval.sh +94 -0
- package/cli/lib/archive.sh +447 -0
- package/cli/lib/billing.sh +166 -0
- package/cli/lib/close.sh +189 -0
- package/cli/lib/commands.sh +220 -0
- package/cli/lib/common.sh +215 -0
- package/cli/lib/finish.sh +288 -0
- package/cli/lib/github.sh +162 -0
- package/cli/lib/guard.sh +134 -0
- package/cli/lib/handoff.sh +551 -0
- package/cli/lib/host.sh +1802 -0
- package/cli/lib/linear.sh +1389 -0
- package/cli/lib/links.sh +135 -0
- package/cli/lib/merges.sh +853 -0
- package/cli/lib/recipes.sh +54 -0
- package/cli/lib/settings.sh +465 -0
- package/cli/lib/space.sh +343 -0
- package/cli/lib/task.sh +847 -0
- package/cli/lib/tests.sh +268 -0
- package/cli/lib/trust.sh +70 -0
- package/cli/ocnus +630 -0
- package/herdr/README.md +2238 -0
- package/herdr/layouts/default.json +259 -0
- package/herdr/mods/agent-settings/cog.svg +4 -0
- package/herdr/mods/agent-settings/main.js +356 -0
- package/herdr/mods/agent-settings/mod.json +1 -0
- package/herdr/mods/cards/main.js +450 -0
- package/herdr/mods/cards/mod.json +1 -0
- package/herdr/mods/cards/refresh.svg +4 -0
- package/herdr/mods/cpu/main.js +90 -0
- package/herdr/mods/cpu/mod.json +1 -0
- package/herdr/mods/layout-switch/main.js +48 -0
- package/herdr/mods/layout-switch/mod.json +1 -0
- package/herdr/mods/names/main.js +69 -0
- package/herdr/mods/names/mod.json +1 -0
- package/herdr/mods/ocnus-spaces/main.js +376 -0
- package/herdr/mods/ocnus-spaces/mod.json +1 -0
- package/herdr/mods/steps/main.js +354 -0
- package/herdr/mods/steps/mod.json +1 -0
- package/herdr/spaces/template/SPACE.md +19 -0
- package/package.json +27 -4
- package/prompts/task-build.md +11 -0
- package/prompts/task-new.md +17 -0
- package/skills/brief/SKILL.md +64 -0
- package/skills/sdlc-breakdown/SKILL.md +312 -0
- package/skills/sdlc-build/SKILL.md +182 -0
- package/skills/sdlc-define/SKILL.md +203 -0
- package/skills/sdlc-plan/SKILL.md +202 -0
- package/skills/sdlc-pr/SKILL.md +339 -0
- package/skills/sdlc-review/SKILL.md +227 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "root",
|
|
3
|
+
"cloned_from": {
|
|
4
|
+
"name": "main",
|
|
5
|
+
"version": "0.1.18"
|
|
6
|
+
},
|
|
7
|
+
"type": "row",
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"id": "sidebar",
|
|
11
|
+
"type": "column",
|
|
12
|
+
"children": [
|
|
13
|
+
{
|
|
14
|
+
"id": "brand",
|
|
15
|
+
"type": "block",
|
|
16
|
+
"content": {
|
|
17
|
+
"mod": "workspace-chrome"
|
|
18
|
+
},
|
|
19
|
+
"size": {
|
|
20
|
+
"px": 46
|
|
21
|
+
},
|
|
22
|
+
"window_drag": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "layout-switch",
|
|
26
|
+
"type": "block",
|
|
27
|
+
"size": {
|
|
28
|
+
"px": 40
|
|
29
|
+
},
|
|
30
|
+
"content": {
|
|
31
|
+
"mod": "layout-switch"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "sidebar-lists",
|
|
36
|
+
"type": "column",
|
|
37
|
+
"children": [
|
|
38
|
+
{
|
|
39
|
+
"id": "ocnus-spaces",
|
|
40
|
+
"type": "block",
|
|
41
|
+
"content": {
|
|
42
|
+
"mod": "ocnus-spaces"
|
|
43
|
+
},
|
|
44
|
+
"size": {
|
|
45
|
+
"weight": 1
|
|
46
|
+
},
|
|
47
|
+
"min": 90
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "cards",
|
|
51
|
+
"type": "block",
|
|
52
|
+
"content": {
|
|
53
|
+
"mod": "cards"
|
|
54
|
+
},
|
|
55
|
+
"size": {
|
|
56
|
+
"weight": 1
|
|
57
|
+
},
|
|
58
|
+
"min": 90
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "agents",
|
|
62
|
+
"type": "block",
|
|
63
|
+
"content": {
|
|
64
|
+
"mod": "agents"
|
|
65
|
+
},
|
|
66
|
+
"size": {
|
|
67
|
+
"weight": 1
|
|
68
|
+
},
|
|
69
|
+
"min": 90
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "steps",
|
|
73
|
+
"type": "block",
|
|
74
|
+
"content": {
|
|
75
|
+
"mod": "steps"
|
|
76
|
+
},
|
|
77
|
+
"size": {
|
|
78
|
+
"weight": 1
|
|
79
|
+
},
|
|
80
|
+
"min": 90
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "cpu",
|
|
86
|
+
"type": "block",
|
|
87
|
+
"size": {
|
|
88
|
+
"px": 64
|
|
89
|
+
},
|
|
90
|
+
"content": {
|
|
91
|
+
"mod": "cpu"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"id": "sidebar-footer",
|
|
96
|
+
"type": "block",
|
|
97
|
+
"content": {
|
|
98
|
+
"mod": "workspace-chrome",
|
|
99
|
+
"props": {
|
|
100
|
+
"footer": true
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"size": {
|
|
104
|
+
"px": 69
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"size": {
|
|
109
|
+
"px": 268
|
|
110
|
+
},
|
|
111
|
+
"min": 44,
|
|
112
|
+
"max": 480,
|
|
113
|
+
"background": "chrome",
|
|
114
|
+
"resizable": false
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"id": "work",
|
|
118
|
+
"type": "column",
|
|
119
|
+
"children": [
|
|
120
|
+
{
|
|
121
|
+
"id": "top",
|
|
122
|
+
"type": "row",
|
|
123
|
+
"children": [
|
|
124
|
+
{
|
|
125
|
+
"id": "tabs",
|
|
126
|
+
"type": "block",
|
|
127
|
+
"content": {
|
|
128
|
+
"mod": "tabs"
|
|
129
|
+
},
|
|
130
|
+
"size": {
|
|
131
|
+
"weight": 1
|
|
132
|
+
},
|
|
133
|
+
"window_drag": true
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "agent-settings",
|
|
137
|
+
"type": "block",
|
|
138
|
+
"content": {
|
|
139
|
+
"mod": "agent-settings"
|
|
140
|
+
},
|
|
141
|
+
"size": {
|
|
142
|
+
"px": 104
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "names",
|
|
147
|
+
"type": "block",
|
|
148
|
+
"content": {
|
|
149
|
+
"mod": "names"
|
|
150
|
+
},
|
|
151
|
+
"size": {
|
|
152
|
+
"px": 1
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"size": {
|
|
157
|
+
"px": 42
|
|
158
|
+
},
|
|
159
|
+
"resizable": false
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "work-body",
|
|
163
|
+
"type": "row",
|
|
164
|
+
"children": [
|
|
165
|
+
{
|
|
166
|
+
"id": "main",
|
|
167
|
+
"type": "block",
|
|
168
|
+
"content": {
|
|
169
|
+
"tab": "active",
|
|
170
|
+
"pane": {
|
|
171
|
+
"header": {
|
|
172
|
+
"content": {
|
|
173
|
+
"mod": "pane"
|
|
174
|
+
},
|
|
175
|
+
"reveal": "always",
|
|
176
|
+
"height": 30,
|
|
177
|
+
"position": "top"
|
|
178
|
+
},
|
|
179
|
+
"background": "background",
|
|
180
|
+
"border": {
|
|
181
|
+
"width": 1,
|
|
182
|
+
"color": "border"
|
|
183
|
+
},
|
|
184
|
+
"focus": {
|
|
185
|
+
"width": 1,
|
|
186
|
+
"color": "accent"
|
|
187
|
+
},
|
|
188
|
+
"radius": 10,
|
|
189
|
+
"gap": 8,
|
|
190
|
+
"lone": true
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"id": "panel",
|
|
196
|
+
"type": "column",
|
|
197
|
+
"children": [
|
|
198
|
+
{
|
|
199
|
+
"id": "panel-body",
|
|
200
|
+
"type": "stack",
|
|
201
|
+
"children": [
|
|
202
|
+
{
|
|
203
|
+
"id": "files",
|
|
204
|
+
"type": "block",
|
|
205
|
+
"content": {
|
|
206
|
+
"mod": "files"
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": "changes",
|
|
211
|
+
"type": "block",
|
|
212
|
+
"content": {
|
|
213
|
+
"mod": "changes"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"active": "files"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"size": {
|
|
221
|
+
"px": 368
|
|
222
|
+
},
|
|
223
|
+
"min": 280,
|
|
224
|
+
"max": 900,
|
|
225
|
+
"hidden": true
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"padding": 8,
|
|
229
|
+
"gap": 8
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"id": "status",
|
|
233
|
+
"type": "block",
|
|
234
|
+
"content": {
|
|
235
|
+
"mod": "workspace-status"
|
|
236
|
+
},
|
|
237
|
+
"size": {
|
|
238
|
+
"px": 28
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"resizable": false
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"background": "canvas",
|
|
246
|
+
"terminal_padding": [
|
|
247
|
+
14,
|
|
248
|
+
12
|
|
249
|
+
],
|
|
250
|
+
"divider": {
|
|
251
|
+
"width": 1,
|
|
252
|
+
"color": "border"
|
|
253
|
+
},
|
|
254
|
+
"titlebar": "none",
|
|
255
|
+
"traffic_lights": [
|
|
256
|
+
12,
|
|
257
|
+
16
|
|
258
|
+
]
|
|
259
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<path d="M9.61 5.42 L9.75 2.26 A10 10 0 0 1 14.25 2.26 L14.39 5.42 A7 7 0 0 1 16.50 6.64 L19.31 5.18 A10 10 0 0 1 21.56 9.08 L18.89 10.78 A7 7 0 0 1 18.89 13.22 L21.56 14.92 A10 10 0 0 1 19.31 18.82 L16.50 17.36 A7 7 0 0 1 14.39 18.58 L14.25 21.74 A10 10 0 0 1 9.75 21.74 L9.61 18.58 A7 7 0 0 1 7.50 17.36 L4.69 18.82 A10 10 0 0 1 2.44 14.92 L5.11 13.22 A7 7 0 0 1 5.11 10.78 L2.44 9.08 A10 10 0 0 1 4.69 5.18 L7.50 6.64 A7 7 0 0 1 9.61 5.42 Z"/>
|
|
3
|
+
<circle cx="12" cy="12" r="3"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
// Ocnus's settings: a cog at the right end of the tab bar, and the popup
|
|
2
|
+
// it opens, which shows them and changes them. One mod, two faces: the popup
|
|
3
|
+
// is the same mod again, with props { menu: true }.
|
|
4
|
+
//
|
|
5
|
+
// The popup shows the model and effort each of ocnus's agent profiles
|
|
6
|
+
// runs on, then the breakdown approval, archiving, how the test runs use the
|
|
7
|
+
// processors and which account the agents run on. What the profiles are,
|
|
8
|
+
// what each is set to, and which models and efforts there are to choose
|
|
9
|
+
// from, are the ocnus command's to say: `ocnus profile ls --json`. A
|
|
10
|
+
// change is made with `ocnus profile set <profile> <model|effort>
|
|
11
|
+
// <value>`, which refuses a value it does not take. Each of the other four is
|
|
12
|
+
// read with its own command's --json and set with that command, as SETTINGS
|
|
13
|
+
// lists. This mod draws what ocnus answers and holds no rules of its
|
|
14
|
+
// own: it reads no file, so it and the command cannot disagree.
|
|
15
|
+
import { View, div, svg } from "gpui-kit";
|
|
16
|
+
import { v_flex, h_flex } from "gpui-base";
|
|
17
|
+
import { exec, theme, props, openOverlay, closeOverlay, checking, appHome } from "herdr";
|
|
18
|
+
|
|
19
|
+
const TIMEOUT_MS = 10000;
|
|
20
|
+
const ROW = 28;
|
|
21
|
+
const DIVIDER = 9; // the line between the profiles and the settings, with its margins
|
|
22
|
+
const ERROR_LINE = 36; // one line of what ocnus said, with its margin and padding
|
|
23
|
+
const WIDTH = 330;
|
|
24
|
+
// Tall enough to show the header, the four profiles, the divider and the
|
|
25
|
+
// four settings without scrolling, with one line of error below them: nine
|
|
26
|
+
// rows, the 1px gap between each two of the body's ten children, and the
|
|
27
|
+
// popup's padding, 4px at the top and at the bottom.
|
|
28
|
+
const HEIGHT = 9 * ROW + DIVIDER + 9 * 1 + ERROR_LINE + 2 * 4;
|
|
29
|
+
// The width of a setting's two values, which share it evenly: wide enough
|
|
30
|
+
// for "subscription".
|
|
31
|
+
const SWITCH = 168;
|
|
32
|
+
// How this mod's own link into the repo that ships it ends.
|
|
33
|
+
const LINKED_AT = "/herdr/mods/agent-settings";
|
|
34
|
+
const OLD_CLI = "This ocnus cannot show its settings in Herdr. Run: ocnus update";
|
|
35
|
+
|
|
36
|
+
// The settings below the profiles. Each is read with its command's --json,
|
|
37
|
+
// and value() takes what it is set to from that JSON. A setting has two
|
|
38
|
+
// values, and a click on the one not set runs its command.
|
|
39
|
+
const SETTINGS = [
|
|
40
|
+
{
|
|
41
|
+
key: "approval",
|
|
42
|
+
name: "Breakdown approval",
|
|
43
|
+
hint: "Whether breakdown asks you to approve each card. Off, it approves a card it has no doubt about and starts its build phase",
|
|
44
|
+
read: ["approval", "--json"],
|
|
45
|
+
value: (got) => got?.approval?.breakdown,
|
|
46
|
+
values: [
|
|
47
|
+
{ is: true, label: "on", set: ["approval", "--breakdown", "on"] },
|
|
48
|
+
{ is: false, label: "off", set: ["approval", "--breakdown", "off"] },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "archive",
|
|
53
|
+
name: "Archiving",
|
|
54
|
+
hint: "Whether recording a card's merge archives it in Linear, and every other closed card of the space's teams",
|
|
55
|
+
read: ["linear", "archive", "--json"],
|
|
56
|
+
value: (got) => got?.archive,
|
|
57
|
+
values: [
|
|
58
|
+
{ is: true, label: "on", set: ["linear", "archive", "on"] },
|
|
59
|
+
{ is: false, label: "off", set: ["linear", "archive", "off"] },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "tests",
|
|
64
|
+
name: "Test runs",
|
|
65
|
+
hint: "Whether the runs of ocnus's own tests on this machine share its processors, or go one at a time",
|
|
66
|
+
read: ["tests", "--json"],
|
|
67
|
+
value: (got) => got?.tests,
|
|
68
|
+
values: [
|
|
69
|
+
{ is: "share", label: "share", set: ["tests", "share"] },
|
|
70
|
+
{ is: "queue", label: "queue", set: ["tests", "queue"] },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: "billing",
|
|
75
|
+
name: "Billing",
|
|
76
|
+
hint: "Which account the agents task new and task build start run on: your Claude subscription, or the Anthropic API key saved with ocnus billing key",
|
|
77
|
+
read: ["billing", "--json"],
|
|
78
|
+
value: (got) => got?.billing,
|
|
79
|
+
values: [
|
|
80
|
+
{ is: "subscription", label: "subscription", set: ["billing", "subscription"] },
|
|
81
|
+
{ is: "api", label: "API key", set: ["billing", "api"] },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
// `herdr-app check` draws the mod once, with no ocnus to ask. It draws
|
|
87
|
+
// the button, the popup's list, its choices and the settings from these
|
|
88
|
+
// instead.
|
|
89
|
+
const SAMPLE = {
|
|
90
|
+
profiles: [
|
|
91
|
+
{ name: "write-up", model: "opus", effort: "xhigh", for: "task new" },
|
|
92
|
+
{ name: "build", model: "sonnet", effort: "high", for: "task build" },
|
|
93
|
+
{ name: "reviewer", model: "claude-opus-5-5", effort: "xhigh", for: "the ocnus-reviewer subagent" },
|
|
94
|
+
{ name: "verifier", model: "opus", effort: "max", for: "the ocnus-verifier subagent" },
|
|
95
|
+
],
|
|
96
|
+
models: ["fable", "opus", "sonnet", "haiku"],
|
|
97
|
+
efforts: ["low", "medium", "high", "xhigh", "max"],
|
|
98
|
+
values: { approval: true, archive: false, tests: "share", billing: "subscription" },
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
function parse(text) {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(text);
|
|
104
|
+
} catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// What a failed command said, without the name it starts its errors with.
|
|
110
|
+
const said = (r) => (r.stderr || r.stdout).trim().replace(/^ocnus: /, "");
|
|
111
|
+
// An ocnus from before `profile`, or `approval`, answers with its help
|
|
112
|
+
// text, not JSON, and one from before `tests --json` refuses the --json.
|
|
113
|
+
const failure = (r, what) => {
|
|
114
|
+
const text = said(r);
|
|
115
|
+
return text.startsWith("usage:") || text.startsWith("set up and maintain") || text.startsWith("'--json' is not")
|
|
116
|
+
? OLD_CLI : text || `${what} failed`;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// The choices for a profile's model or effort: ocnus's list, and for a
|
|
120
|
+
// model the profile's own when it is a full name the list does not have.
|
|
121
|
+
function choices(list, profile, field) {
|
|
122
|
+
if (field === "effort") return list.efforts ?? [];
|
|
123
|
+
const models = [...(list.models ?? [])];
|
|
124
|
+
if (profile.model && !models.includes(profile.model)) models.push(profile.model);
|
|
125
|
+
return models;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default class AgentSettings extends View {
|
|
129
|
+
init(_props, cx) {
|
|
130
|
+
this.cmd = "ocnus"; // the one on PATH, until that cannot start
|
|
131
|
+
this.list = null; // what `profile ls --json` answered
|
|
132
|
+
this.values = {}; // what each setting is set to, by its key; none when its read failed
|
|
133
|
+
this.error = null; // what went wrong last, in ocnus's words
|
|
134
|
+
this.picking = null; // { profile, field } whose choices are shown
|
|
135
|
+
this.busy = false; // a read or a change is running
|
|
136
|
+
if (checking() || !props()?.menu) return;
|
|
137
|
+
this.refresh(cx);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Runs the ocnus command. One that cannot start is tried again as the
|
|
141
|
+
// copy this mod is linked from: Herdr may have been started without the
|
|
142
|
+
// user's PATH, so the first run never happened. The reads run side by side,
|
|
143
|
+
// so each goes by the command it tried, not by this.cmd, which another may
|
|
144
|
+
// have changed since.
|
|
145
|
+
async ocnus(args) {
|
|
146
|
+
const tried = this.cmd;
|
|
147
|
+
try {
|
|
148
|
+
return await exec(tried, args, { timeout: TIMEOUT_MS });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
if (tried !== "ocnus") throw e;
|
|
151
|
+
const link = await exec("readlink", [`${appHome()}/mods/agent-settings`]);
|
|
152
|
+
const at = link.stdout.trim();
|
|
153
|
+
if (link.code !== 0 || !at.endsWith(LINKED_AT)) throw e;
|
|
154
|
+
this.cmd = `${at.slice(0, -LINKED_AT.length)}/cli/ocnus`;
|
|
155
|
+
return exec(this.cmd, args, { timeout: TIMEOUT_MS });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Reads the profiles and the settings, all at the same time. Keeps what
|
|
160
|
+
// each answered; a setting whose read failed has no value until the next
|
|
161
|
+
// read. Returns what went wrong, each message once, or null.
|
|
162
|
+
async read() {
|
|
163
|
+
const [profiles, ...settings] = await Promise.all([
|
|
164
|
+
this.ask(["profile", "ls", "--json"], (got) => (Array.isArray(got?.profiles) ? got : undefined)),
|
|
165
|
+
...SETTINGS.map((setting) => this.ask(setting.read, setting.value)),
|
|
166
|
+
]);
|
|
167
|
+
if (profiles.got !== undefined) this.list = profiles.got;
|
|
168
|
+
SETTINGS.forEach((setting, i) => { this.values[setting.key] = settings[i].got; });
|
|
169
|
+
const errors = [...new Set([profiles, ...settings].map((a) => a.error).filter(Boolean))];
|
|
170
|
+
return errors.length ? errors.join("\n") : null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Runs one read, and answers { got }, what take() finds in the JSON it
|
|
174
|
+
// printed, or { error }, in ocnus's words.
|
|
175
|
+
async ask(args, take) {
|
|
176
|
+
try {
|
|
177
|
+
const r = await this.ocnus(args);
|
|
178
|
+
const got = r.code === 0 ? take(parse(r.stdout)) : undefined;
|
|
179
|
+
if (got !== undefined) return { got };
|
|
180
|
+
return { error: r.code === 0 ? OLD_CLI : failure(r, `ocnus ${args.join(" ")}`) };
|
|
181
|
+
} catch (e) {
|
|
182
|
+
return { error: `Could not run ocnus: ${e?.message ?? e}` };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
refresh(cx) {
|
|
187
|
+
if (this.busy) return;
|
|
188
|
+
this.busy = true;
|
|
189
|
+
cx.spawn(async (cx) => {
|
|
190
|
+
this.error = await this.read();
|
|
191
|
+
this.busy = false;
|
|
192
|
+
cx.notify();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Sets one value with ocnus, then reads the profiles and the settings
|
|
197
|
+
// again, so what is shown is what the file now holds.
|
|
198
|
+
set(profile, field, value, cx) {
|
|
199
|
+
this.picking = null;
|
|
200
|
+
if (this.busy || profile[field] === value) {
|
|
201
|
+
cx.notify();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.busy = true;
|
|
205
|
+
cx.notify();
|
|
206
|
+
cx.spawn(async (cx) => {
|
|
207
|
+
let failed = null;
|
|
208
|
+
try {
|
|
209
|
+
const r = await this.ocnus(["profile", "set", profile.name, field, value]);
|
|
210
|
+
if (r.code !== 0) failed = failure(r, "ocnus profile set");
|
|
211
|
+
} catch (e) {
|
|
212
|
+
failed = `Could not run ocnus: ${e?.message ?? e}`;
|
|
213
|
+
}
|
|
214
|
+
const unread = await this.read();
|
|
215
|
+
this.error = failed ?? unread;
|
|
216
|
+
this.busy = false;
|
|
217
|
+
cx.notify();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Sets a setting to one of its values with its command, then reads
|
|
222
|
+
// everything again, as set() does, so what is shown is what the file now
|
|
223
|
+
// holds.
|
|
224
|
+
toggle(setting, to, cx) {
|
|
225
|
+
if (this.busy || this.values[setting.key] === undefined || this.values[setting.key] === to.is) return;
|
|
226
|
+
this.busy = true;
|
|
227
|
+
cx.notify();
|
|
228
|
+
cx.spawn(async (cx) => {
|
|
229
|
+
let failed = null;
|
|
230
|
+
try {
|
|
231
|
+
const r = await this.ocnus(to.set);
|
|
232
|
+
if (r.code !== 0) failed = failure(r, `ocnus ${to.set.join(" ")}`);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
failed = `Could not run ocnus: ${e?.message ?? e}`;
|
|
235
|
+
}
|
|
236
|
+
const unread = await this.read();
|
|
237
|
+
this.error = failed ?? unread;
|
|
238
|
+
this.busy = false;
|
|
239
|
+
cx.notify();
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
render() {
|
|
244
|
+
if (checking()) {
|
|
245
|
+
// Every face, so that a check draws each of them once.
|
|
246
|
+
// The last is a read going on, with the tests setting unread.
|
|
247
|
+
const { tests: _unread, ...some } = SAMPLE.values;
|
|
248
|
+
return v_flex().size_full().child(div().h(42).child(this.button()))
|
|
249
|
+
.child(this.menu({ list: SAMPLE, values: SAMPLE.values, error: "A sample of what ocnus says when it refuses.\nAnd a second thing it said.", picking: null, busy: false }, "rows"))
|
|
250
|
+
.child(this.menu({ list: SAMPLE, values: SAMPLE.values, error: null, picking: { profile: "reviewer", field: "model" }, busy: true }, "pick"))
|
|
251
|
+
.child(this.menu({ list: SAMPLE, values: some, error: null, picking: null, busy: true }, "busy"));
|
|
252
|
+
}
|
|
253
|
+
if (!props()?.menu) return this.button();
|
|
254
|
+
return this.menu(this, "menu");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// The button, at the right end of the tab bar, drawn as the tab bar is: a
|
|
258
|
+
// cog, which takes the colour of the text around it.
|
|
259
|
+
button() {
|
|
260
|
+
const t = theme();
|
|
261
|
+
return h_flex().size_full().px(10).items_center().justify_end().bg(t.chrome).border_b(1).border_color(t.border)
|
|
262
|
+
.child(h_flex().id("agent-settings").h(26).px(8).gap(6).flex_none().items_center().rounded(6)
|
|
263
|
+
.text_size(12).text_color(t.muted).tooltip("Open ocnus's settings")
|
|
264
|
+
.accessibility_label("Open ocnus's settings")
|
|
265
|
+
.hover((s) => s.bg(t.hover).text_color(t.foreground))
|
|
266
|
+
.on_click(() => openOverlay({
|
|
267
|
+
mod: "agent-settings", kind: "popup", width: WIDTH, height: HEIGHT, props: { menu: true },
|
|
268
|
+
}))
|
|
269
|
+
.child(svg("mods/agent-settings/cog.svg").size(14).flex_none())
|
|
270
|
+
.child(div().text_color(t.dim).child("▾")));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// The popup: a row for each profile, then one for each setting, or the
|
|
274
|
+
// choices for one of a profile's values.
|
|
275
|
+
// s what to draw: { list, values, error, picking, busy }
|
|
276
|
+
// key what the ids in it start with
|
|
277
|
+
menu(s, key) {
|
|
278
|
+
const t = theme();
|
|
279
|
+
const profiles = s.list?.profiles ?? [];
|
|
280
|
+
const picked = s.picking && profiles.find((p) => p.name === s.picking.profile);
|
|
281
|
+
const title = picked ? `${picked.name}: ${s.picking.field}` : "Ocnus settings";
|
|
282
|
+
const header = h_flex().h(ROW).flex_none().px(8).gap(8).items_center()
|
|
283
|
+
.when(Boolean(picked), (el) => el.child(div().id(`${key}-back`).flex_none().px(4).rounded(4)
|
|
284
|
+
.text_color(t.muted).cursor_pointer().hover((h) => h.bg(t.hover).text_color(t.foreground))
|
|
285
|
+
.on_click((_e, cx) => { this.picking = null; cx.notify(); })
|
|
286
|
+
.child("‹")))
|
|
287
|
+
.child(div().flex_1().min_w(0).truncate().text_color(t.foreground).font_medium().child(title))
|
|
288
|
+
.child(div().flex_none().text_size(11).text_color(t.dim)
|
|
289
|
+
.child(s.busy ? "Saving…" : picked ? "" : "model · effort"));
|
|
290
|
+
const items = [];
|
|
291
|
+
if (picked) {
|
|
292
|
+
const current = picked[s.picking.field];
|
|
293
|
+
for (const value of choices(s.list, picked, s.picking.field)) {
|
|
294
|
+
const on = value === current;
|
|
295
|
+
items.push(h_flex().id(`${key}-choice-${value}`).h(ROW).flex_none().px(8).gap(8).items_center().rounded(4)
|
|
296
|
+
.cursor_pointer().hover((h) => h.bg(t.hover))
|
|
297
|
+
.on_click((_e, cx) => this.set(picked, s.picking.field, value, cx))
|
|
298
|
+
.child(div().w(12).flex_none().text_color(t.accent).child(on ? "✓" : ""))
|
|
299
|
+
.child(div().flex_1().min_w(0).truncate().text_color(on ? t.foreground : t.muted).child(value)));
|
|
300
|
+
}
|
|
301
|
+
} else if (!s.list && !s.error) {
|
|
302
|
+
items.push(div().px(8).py(6).text_color(t.dim).child("Loading…"));
|
|
303
|
+
} else {
|
|
304
|
+
for (const p of profiles) items.push(this.row(p, s.busy, key, t));
|
|
305
|
+
items.push(div().h(1).flex_none().mx(8).my(4).bg(t.border));
|
|
306
|
+
for (const setting of SETTINGS) items.push(this.settingRow(setting, s.values?.[setting.key], s.busy, key, t));
|
|
307
|
+
}
|
|
308
|
+
if (s.error) {
|
|
309
|
+
items.push(v_flex().id(`${key}-error`).mt(6).px(8).py(4).gap(4).text_size(11.5).text_color(t.blocked)
|
|
310
|
+
.children(s.error.split("\n").map((line) => div().whitespace_normal().child(line))));
|
|
311
|
+
}
|
|
312
|
+
return v_flex().size_full().min_h(0).p(4).bg(t.popover).text_size(12)
|
|
313
|
+
.child(header)
|
|
314
|
+
.child(v_flex().id(`${key}-body`).flex_1().min_h(0).gap(1).overflow_y_scrollbar().children(items));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// A profile's row: its name, and its model and effort, each a button that
|
|
318
|
+
// shows the choices for it.
|
|
319
|
+
row(p, busy, key, t) {
|
|
320
|
+
const value = (field, width) => h_flex().id(`${key}-${p.name}-${field}`).w(width).h(22).flex_none().px(7)
|
|
321
|
+
.items_center().rounded(5).border_1().border_color(t.input).bg(t.raised).text_color(t.foreground)
|
|
322
|
+
.when(busy, (el) => el.opacity(0.5))
|
|
323
|
+
.when(!busy, (el) => el.cursor_pointer().hover((h) => h.bg(t.hover))
|
|
324
|
+
.on_click((_e, cx) => { this.picking = { profile: p.name, field }; cx.notify(); }))
|
|
325
|
+
.child(div().flex_1().min_w(0).truncate().child(p[field]))
|
|
326
|
+
.child(div().flex_none().text_color(t.dim).child("▾"));
|
|
327
|
+
return h_flex().id(`${key}-${p.name}`).h(ROW).flex_none().px(8).gap(6).items_center()
|
|
328
|
+
.child(div().id(`${key}-${p.name}-name`).flex_1().min_w(0).truncate().text_color(t.foreground)
|
|
329
|
+
.tooltip(p.for ? `Runs ${p.for}` : p.name).child(p.name))
|
|
330
|
+
.child(value("model", 128))
|
|
331
|
+
.child(value("effort", 74));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// A setting's row: its name, which says what it does on hover, and its two
|
|
335
|
+
// values side by side, the one it is set to marked. A click on the other
|
|
336
|
+
// sets it. With no value, when ocnus could not read it, neither is
|
|
337
|
+
// marked and neither can be clicked.
|
|
338
|
+
settingRow(setting, current, busy, key, t) {
|
|
339
|
+
const known = current !== undefined;
|
|
340
|
+
const choice = (v) => {
|
|
341
|
+
const on = known && v.is === current;
|
|
342
|
+
return div().id(`${key}-${setting.key}-${v.label}`).flex_1().h_full().flex().items_center().justify_center()
|
|
343
|
+
.rounded(3).text_color(on ? t.foreground : t.muted)
|
|
344
|
+
.when(on, (el) => el.bg(t.selected))
|
|
345
|
+
.when(known && !on && !busy, (el) => el.cursor_pointer().hover((h) => h.bg(t.hover).text_color(t.foreground))
|
|
346
|
+
.on_click((_e, cx) => this.toggle(setting, v, cx)))
|
|
347
|
+
.child(v.label);
|
|
348
|
+
};
|
|
349
|
+
return h_flex().id(`${key}-${setting.key}`).h(ROW).flex_none().px(8).gap(6).items_center()
|
|
350
|
+
.child(div().id(`${key}-${setting.key}-name`).flex_1().min_w(0).truncate().text_color(t.foreground)
|
|
351
|
+
.tooltip(setting.hint).child(setting.name))
|
|
352
|
+
.child(h_flex().w(SWITCH).h(22).flex_none().p(2).gap(2).rounded(5).border_1().border_color(t.input).bg(t.raised)
|
|
353
|
+
.when(busy || !known, (el) => el.opacity(0.5))
|
|
354
|
+
.children(setting.values.map(choice)));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "place": "none", "title": "Ocnus settings" }
|