@nanocollective/roster 0.1.0-beta.19 → 0.1.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/{agents-Q2DSTLOQ.js → agents-POITEZRI.js} +1 -1
- package/dist/{chunk-JH3LQ34C.js → chunk-FF2WBNNW.js} +18 -1
- package/dist/{chunk-UEZPQ5PV.js → chunk-GDAJPOHK.js} +2 -2
- package/dist/cli.js +1089 -211
- package/dist/{compose-H43W3QI5.js → compose-5DBEHSEV.js} +1 -1
- package/dist/{connectors-U5VT5W2I.js → connectors-5E5ZMGZV.js} +1 -1
- package/dist/worker/assets/assets/css/routines.css +40 -0
- package/dist/worker/assets/assets/js/app.js +4 -1
- package/dist/worker/assets/assets/js/icons.js +2 -0
- package/dist/worker/assets/assets/js/state.js +1 -0
- package/dist/worker/assets/assets/js/views/home.js +1 -0
- package/dist/worker/assets/assets/js/views/routines.js +378 -0
- package/dist/worker/assets/index.html +4 -0
- package/dist/worker/index.js +415 -50
- package/docs/README.md +1 -0
- package/docs/commands.md +45 -0
- package/docs/concepts.md +1 -0
- package/docs/getting-started.md +14 -0
- package/docs/hosting.md +2 -2
- package/docs/portal.md +11 -0
- package/docs/routines.md +65 -0
- package/docs/security.md +5 -3
- package/docs/session-workflow.md +2 -1
- package/docs/staff-yaml.md +1 -0
- package/package.json +1 -1
- package/templates/brain/.gitattributes +3 -0
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +16 -9
- package/templates/brain/staff.yaml +3 -0
- package/templates/ops/.gitattributes +3 -0
- package/templates/ops/.github/workflows/session.yaml +8 -1
- package/templates/ops/compose.mjs +20 -0
- package/templates/ops/prompts/daily.md +21 -0
- package/templates/portal/css/routines.css +40 -0
- package/templates/portal/index.html +4 -0
- package/templates/portal/js/app.js +4 -1
- package/templates/portal/js/icons.js +2 -0
- package/templates/portal/js/state.js +1 -0
- package/templates/portal/js/views/home.js +1 -0
- package/templates/portal/js/views/routines.js +378 -0
- package/templates/skill/SKILL.md +115 -0
package/dist/cli.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
compose,
|
|
4
4
|
parseYaml
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FF2WBNNW.js";
|
|
6
6
|
import {
|
|
7
7
|
CATALOGUE,
|
|
8
8
|
declared,
|
|
9
9
|
secretName,
|
|
10
10
|
withConnectors
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GDAJPOHK.js";
|
|
12
12
|
|
|
13
13
|
// src/commands/app.ts
|
|
14
14
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
@@ -18,7 +18,29 @@ import { join as join5 } from "path";
|
|
|
18
18
|
import { execFile as execFile2 } from "child_process";
|
|
19
19
|
import { randomBytes } from "crypto";
|
|
20
20
|
import { createServer } from "http";
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
// src/lib/browser.ts
|
|
23
|
+
import { spawn } from "child_process";
|
|
24
|
+
function shouldOpen(env, isTTY, noOpen) {
|
|
25
|
+
if (noOpen || !isTTY) return false;
|
|
26
|
+
if (env.CI || env.BROWSER === "none" || env.SSH_CONNECTION) return false;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function openerFor(platform, url) {
|
|
30
|
+
if (platform === "darwin") return ["open", [url]];
|
|
31
|
+
if (platform === "win32") return ["cmd", ["/c", "start", "", url]];
|
|
32
|
+
return ["xdg-open", [url]];
|
|
33
|
+
}
|
|
34
|
+
function openBrowser(url) {
|
|
35
|
+
const [cmd, args] = openerFor(process.platform, url);
|
|
36
|
+
try {
|
|
37
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
38
|
+
child.on("error", () => {
|
|
39
|
+
});
|
|
40
|
+
child.unref();
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
22
44
|
|
|
23
45
|
// src/lib/gh.ts
|
|
24
46
|
import { execFile } from "child_process";
|
|
@@ -64,7 +86,6 @@ async function ghReady() {
|
|
|
64
86
|
}
|
|
65
87
|
|
|
66
88
|
// src/lib/appmanifest.ts
|
|
67
|
-
var run2 = promisify2(execFile2);
|
|
68
89
|
var PERMISSIONS = {
|
|
69
90
|
private: { contents: "write", issues: "write", pull_requests: "write", metadata: "read" },
|
|
70
91
|
public: { contents: "write", issues: "write", pull_requests: "write", metadata: "read" }
|
|
@@ -112,7 +133,7 @@ async function createApp(spec2, opts = {}) {
|
|
|
112
133
|
const state = randomBytes(16).toString("hex");
|
|
113
134
|
const redirectUrl = `http://localhost:${port}/callback`;
|
|
114
135
|
const manifest = buildManifest(spec2, redirectUrl);
|
|
115
|
-
return new Promise((
|
|
136
|
+
return new Promise((resolve8, reject) => {
|
|
116
137
|
let settled = false;
|
|
117
138
|
const finish = (fn) => {
|
|
118
139
|
if (settled) return;
|
|
@@ -155,7 +176,7 @@ async function createApp(spec2, opts = {}) {
|
|
|
155
176
|
"Its keys are saved in the repository's secrets. You can close this tab; the terminal has the next step."
|
|
156
177
|
)
|
|
157
178
|
);
|
|
158
|
-
finish(() =>
|
|
179
|
+
finish(() => resolve8(app));
|
|
159
180
|
}).catch((err) => {
|
|
160
181
|
res.writeHead(502, { "content-type": "text/html" }).end(page("Exchange failed", esc(err.message)));
|
|
161
182
|
finish(() => reject(err));
|
|
@@ -168,7 +189,7 @@ async function createApp(spec2, opts = {}) {
|
|
|
168
189
|
Creating the GitHub App "${spec2.name}" under ${spec2.org}.`);
|
|
169
190
|
log(` Your browser should open. If it does not, go to: ${url}
|
|
170
191
|
`);
|
|
171
|
-
if (!opts.noOpen)
|
|
192
|
+
if (!opts.noOpen) openBrowser(url);
|
|
172
193
|
});
|
|
173
194
|
});
|
|
174
195
|
}
|
|
@@ -196,11 +217,11 @@ function setOrgSecret(org, name, repos, value) {
|
|
|
196
217
|
);
|
|
197
218
|
}
|
|
198
219
|
function secretFromStdin(args, value) {
|
|
199
|
-
return new Promise((
|
|
220
|
+
return new Promise((resolve8, reject) => {
|
|
200
221
|
const child = execFile2(
|
|
201
222
|
"gh",
|
|
202
223
|
args,
|
|
203
|
-
(err, _out, stderr) => err ? reject(new Error(`gh secret set ${args[2]}: ${String(stderr || err.message).trim()}`)) :
|
|
224
|
+
(err, _out, stderr) => err ? reject(new Error(`gh secret set ${args[2]}: ${String(stderr || err.message).trim()}`)) : resolve8()
|
|
204
225
|
);
|
|
205
226
|
child.stdin?.end(value);
|
|
206
227
|
});
|
|
@@ -211,13 +232,6 @@ function page(title, body2) {
|
|
|
211
232
|
padding:0 1.5rem;color:#1b1f26}@media(prefers-color-scheme:dark){body{background:#0e1013;color:#e6e9ef}}</style>
|
|
212
233
|
<h2>${esc(title)}</h2><p>${body2}</p>`;
|
|
213
234
|
}
|
|
214
|
-
async function open(url) {
|
|
215
|
-
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
216
|
-
try {
|
|
217
|
-
await run2(cmd, [url]);
|
|
218
|
-
} catch {
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
235
|
|
|
222
236
|
// src/lib/install.ts
|
|
223
237
|
import { join } from "path";
|
|
@@ -226,11 +240,14 @@ import { join } from "path";
|
|
|
226
240
|
import * as fs from "fs";
|
|
227
241
|
var mounts = /* @__PURE__ */ new Map();
|
|
228
242
|
function mount(prefix, tree) {
|
|
229
|
-
mounts.set(prefix
|
|
243
|
+
mounts.set(slashed(prefix), tree);
|
|
244
|
+
}
|
|
245
|
+
function slashed(path) {
|
|
246
|
+
return String(path).replace(/\\/g, "/").replace(/^[A-Za-z]:(?=\/)/, "").replace(/\/+$/, "");
|
|
230
247
|
}
|
|
231
248
|
function lookup(path) {
|
|
232
249
|
if (!mounts.size) return null;
|
|
233
|
-
const p =
|
|
250
|
+
const p = slashed(path);
|
|
234
251
|
for (const [prefix, tree] of mounts) {
|
|
235
252
|
if (p === prefix) return { tree, rel: "" };
|
|
236
253
|
if (p.startsWith(`${prefix}/`)) return { tree, rel: p.slice(prefix.length + 1) };
|
|
@@ -328,8 +345,114 @@ async function preselectedInstall(slug, org, repos, gh = api) {
|
|
|
328
345
|
// src/lib/render.ts
|
|
329
346
|
import { join as join3 } from "path";
|
|
330
347
|
|
|
348
|
+
// src/lib/routines.ts
|
|
349
|
+
var ROUTINE_ID = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
350
|
+
function routineId(title, taken = []) {
|
|
351
|
+
const base2 = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32).replace(/-+$/, "") || "routine";
|
|
352
|
+
let id = base2;
|
|
353
|
+
for (let n = 2; taken.includes(id); n++) id = `${base2}-${n}`;
|
|
354
|
+
return id;
|
|
355
|
+
}
|
|
356
|
+
function validCron(cron) {
|
|
357
|
+
const fields = cron.trim().split(/\s+/);
|
|
358
|
+
return fields.length === 5 && fields.every((f) => /^(\*|\d+(-\d+)?)(\/\d+)?(,(\d+(-\d+)?)(\/\d+)?)*$/.test(f));
|
|
359
|
+
}
|
|
360
|
+
function checkRoutines(daily, routines) {
|
|
361
|
+
const out = [];
|
|
362
|
+
const ids = /* @__PURE__ */ new Set();
|
|
363
|
+
const crons = /* @__PURE__ */ new Map([[norm(daily), "the daily round"]]);
|
|
364
|
+
if (!validCron(daily))
|
|
365
|
+
out.push(`the daily round's schedule "${daily}" is not a cron GitHub reads`);
|
|
366
|
+
for (const r of routines) {
|
|
367
|
+
const name = r.title || r.id;
|
|
368
|
+
if (!ROUTINE_ID.test(r.id))
|
|
369
|
+
out.push(`"${r.id}" is not a routine id: lowercase letters, numbers and hyphens`);
|
|
370
|
+
if (ids.has(r.id)) out.push(`two routines are called ${r.id}`);
|
|
371
|
+
ids.add(r.id);
|
|
372
|
+
if (!r.title.trim()) out.push(`${r.id} needs a name`);
|
|
373
|
+
if (!r.body.trim()) out.push(`${name} needs something to do`);
|
|
374
|
+
if (!validCron(r.schedule)) {
|
|
375
|
+
out.push(`${name}'s schedule "${r.schedule}" is not a cron GitHub reads`);
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
const clash = crons.get(norm(r.schedule));
|
|
379
|
+
if (clash) out.push(`${name} is at the same time as ${clash}; move one by a minute`);
|
|
380
|
+
crons.set(norm(r.schedule), name);
|
|
381
|
+
}
|
|
382
|
+
return out;
|
|
383
|
+
}
|
|
384
|
+
var norm = (cron) => cron.trim().split(/\s+/).join(" ");
|
|
385
|
+
function routinesOf(manifest) {
|
|
386
|
+
const list2 = Array.isArray(manifest.routines) ? manifest.routines : [];
|
|
387
|
+
return list2.map((r) => ({ id: String(r?.id ?? ""), schedule: String(r?.schedule ?? "") })).filter((r) => ROUTINE_ID.test(r.id) && validCron(r.schedule));
|
|
388
|
+
}
|
|
389
|
+
function routineFile(r) {
|
|
390
|
+
return `# ${r.title.trim()}
|
|
391
|
+
|
|
392
|
+
${r.body.trim()}
|
|
393
|
+
`;
|
|
394
|
+
}
|
|
395
|
+
function parseRoutineFile(text2, id) {
|
|
396
|
+
const m = /^#\s+(.+)\n?/.exec(text2.trimStart());
|
|
397
|
+
if (!m) return { title: id, body: text2.trim() };
|
|
398
|
+
return { title: m[1].trim(), body: text2.trimStart().slice(m[0].length).trim() };
|
|
399
|
+
}
|
|
400
|
+
var routinePath = (id) => `routines/${id}.md`;
|
|
401
|
+
function setRoutinesInManifest(text2, routines) {
|
|
402
|
+
const block = routines.length ? `routines:
|
|
403
|
+
${routines.map((r) => ` - { id: ${r.id}, schedule: "${norm(r.schedule)}" }`).join("\n")}` : "routines: []";
|
|
404
|
+
const lines = text2.split("\n");
|
|
405
|
+
const at = lines.findIndex((l) => /^routines:/.test(l));
|
|
406
|
+
if (at === -1) {
|
|
407
|
+
const comment2 = "# Times this staff member wakes beyond the daily round, each with its own job in\n# routines/<id>.md. Times are UTC. Edit them in the portal or with `roster routine`.";
|
|
408
|
+
const scheduleAt = lines.findIndex((l) => /^schedule:/.test(l));
|
|
409
|
+
if (scheduleAt === -1) return `${text2.trimEnd()}
|
|
410
|
+
|
|
411
|
+
${comment2}
|
|
412
|
+
${block}
|
|
413
|
+
`;
|
|
414
|
+
lines.splice(scheduleAt + 1, 0, comment2, block);
|
|
415
|
+
return lines.join("\n");
|
|
416
|
+
}
|
|
417
|
+
let end = at + 1;
|
|
418
|
+
while (end < lines.length && /^(\s+|$)/.test(lines[end]) && lines[end].trim() !== "") end++;
|
|
419
|
+
lines.splice(at, end - at, block);
|
|
420
|
+
return lines.join("\n");
|
|
421
|
+
}
|
|
422
|
+
function setDailyInManifest(text2, cron) {
|
|
423
|
+
return /^schedule:.*$/m.test(text2) ? text2.replace(/^schedule:.*$/m, `schedule: "${norm(cron)}"`) : `${text2.trimEnd()}
|
|
424
|
+
schedule: "${norm(cron)}"
|
|
425
|
+
`;
|
|
426
|
+
}
|
|
427
|
+
function scheduleLines(daily, routines) {
|
|
428
|
+
return [
|
|
429
|
+
` - cron: "${norm(daily)}"`,
|
|
430
|
+
...routines.map((r) => ` - cron: "${norm(r.schedule)}" # ${r.id}`)
|
|
431
|
+
].join("\n");
|
|
432
|
+
}
|
|
433
|
+
function routineExpression(routines) {
|
|
434
|
+
if (!routines.length) return "''";
|
|
435
|
+
return `(${routines.map((r) => `(github.event.schedule == '${norm(r.schedule)}' && '${r.id}')`).join(" || ")} || '')`;
|
|
436
|
+
}
|
|
437
|
+
var DAY = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
438
|
+
function describeCron(cron) {
|
|
439
|
+
const [min, hour, dom, mon, dow] = norm(cron).split(" ");
|
|
440
|
+
if (!/^\d+$/.test(min ?? "") || !/^\d+$/.test(hour ?? "") || mon !== "*") return cron;
|
|
441
|
+
const at = `at ${hour.padStart(2, "0")}:${min.padStart(2, "0")} UTC`;
|
|
442
|
+
if (dom !== "*") {
|
|
443
|
+
return /^\d+$/.test(dom ?? "") && dow === "*" ? `On the ${ordinal(Number(dom))} of each month ${at}` : cron;
|
|
444
|
+
}
|
|
445
|
+
const days = dow === "*" ? "Every day" : dow === "1-5" ? "Weekdays" : dow === "0,6" || dow === "6,0" ? "Weekends" : /^[0-6](,[0-6])*$/.test(dow ?? "") ? dow.split(",").map((d) => `${DAY[Number(d)]}s`).join(", ").replace(/, ([^,]*)$/, " and $1") : null;
|
|
446
|
+
return days ? `${days} ${at}` : cron;
|
|
447
|
+
}
|
|
448
|
+
function ordinal(n) {
|
|
449
|
+
const tens = n % 100;
|
|
450
|
+
const suffix = tens >= 11 && tens <= 13 ? "th" : ["th", "st", "nd", "rd"][n % 10] ?? "th";
|
|
451
|
+
return `${n}${suffix}`;
|
|
452
|
+
}
|
|
453
|
+
|
|
331
454
|
// src/lib/templates.ts
|
|
332
|
-
import { dirname, join as join2, relative } from "path";
|
|
455
|
+
import { dirname, join as join2, relative as relative2 } from "path";
|
|
333
456
|
import { fileURLToPath } from "url";
|
|
334
457
|
|
|
335
458
|
// src/lib/framework.ts
|
|
@@ -338,6 +461,16 @@ function frameworkRoot() {
|
|
|
338
461
|
return root;
|
|
339
462
|
}
|
|
340
463
|
|
|
464
|
+
// src/lib/paths.ts
|
|
465
|
+
import { isAbsolute, relative, sep } from "path";
|
|
466
|
+
function posix(p) {
|
|
467
|
+
return sep === "/" ? p : p.split(sep).join("/");
|
|
468
|
+
}
|
|
469
|
+
function inside(root2, full) {
|
|
470
|
+
const rel = relative(root2, full);
|
|
471
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
472
|
+
}
|
|
473
|
+
|
|
341
474
|
// src/lib/templates.ts
|
|
342
475
|
function classify(rel) {
|
|
343
476
|
return rel.startsWith("org/") || rel.startsWith("prompts/") ? "seeded" : "managed";
|
|
@@ -366,7 +499,7 @@ function templateFiles(root2) {
|
|
|
366
499
|
if (name === ".DS_Store") continue;
|
|
367
500
|
const full = join2(dir, name);
|
|
368
501
|
if (statSync2(full).isDirectory()) walk3(full);
|
|
369
|
-
else out.push(
|
|
502
|
+
else out.push(posix(relative2(root2, full)));
|
|
370
503
|
}
|
|
371
504
|
};
|
|
372
505
|
walk3(root2);
|
|
@@ -410,6 +543,8 @@ function tokensFor(org, s) {
|
|
|
410
543
|
STATUS_ISSUE: String(s.statusIssue),
|
|
411
544
|
WORKS_IN: s.worksIn.length ? "\n" + s.worksIn.map((r) => ` - { repo: ${r}, role: contributor, checkout: true }`).join("\n") : " []",
|
|
412
545
|
SCHEDULE: s.schedule,
|
|
546
|
+
SCHEDULES: scheduleLines(s.schedule, s.routines ?? []),
|
|
547
|
+
ROUTINE: routineExpression(s.routines ?? []),
|
|
413
548
|
MODEL: s.model,
|
|
414
549
|
TIMEOUT: String(s.timeout),
|
|
415
550
|
MENTION_TIMEOUT: String(s.mentionTimeout),
|
|
@@ -510,19 +645,21 @@ function specFromManifest(m, dir) {
|
|
|
510
645
|
publicTokenEnv: String(m.public_token_env ?? "PUBLIC_TOKEN"),
|
|
511
646
|
agentSecret: String(m.agent_secret ?? "CLAUDE_CODE_OAUTH_TOKEN"),
|
|
512
647
|
// Peer and follow-on runs a day. Mentions are a person asking and never count.
|
|
513
|
-
maxRunsPerDay: Number(m.max_runs_per_day ?? 6)
|
|
648
|
+
maxRunsPerDay: Number(m.max_runs_per_day ?? 6),
|
|
649
|
+
routines: routinesOf(m)
|
|
514
650
|
};
|
|
515
651
|
}
|
|
516
652
|
|
|
517
653
|
// src/lib/workspace.ts
|
|
518
|
-
import { dirname as dirname2, join as join4, resolve } from "path";
|
|
654
|
+
import { basename, dirname as dirname2, join as join4, resolve } from "path";
|
|
655
|
+
import { pathToFileURL } from "url";
|
|
519
656
|
function findWorkspace(start = process.cwd()) {
|
|
520
657
|
let dir = resolve(start);
|
|
521
658
|
for (; ; ) {
|
|
522
659
|
const found = opsInside(dir);
|
|
523
660
|
if (found) return { root: dir, opsDir: join4(dir, found), opsName: found };
|
|
524
661
|
if (existsSync2(join4(dir, "org.yaml"))) {
|
|
525
|
-
return { root: dirname2(dir), opsDir: dir, opsName: dir
|
|
662
|
+
return { root: dirname2(dir), opsDir: dir, opsName: basename(dir) };
|
|
526
663
|
}
|
|
527
664
|
const parent = dirname2(dir);
|
|
528
665
|
if (parent === dir) break;
|
|
@@ -550,7 +687,7 @@ async function loadComposer(opsDir) {
|
|
|
550
687
|
if (!existsSync2(path)) {
|
|
551
688
|
throw new Error(`no compose.mjs in ${opsDir}. Run \`roster upgrade\` to restore it.`);
|
|
552
689
|
}
|
|
553
|
-
return await import(
|
|
690
|
+
return await import(pathToFileURL(path).href);
|
|
554
691
|
}
|
|
555
692
|
function readOrg(opsDir, parseYaml3) {
|
|
556
693
|
return parseYaml3(readFileSync2(join4(opsDir, "org.yaml"), "utf8"), "org.yaml");
|
|
@@ -1337,7 +1474,7 @@ function nextIsIndented(lines, from) {
|
|
|
1337
1474
|
// src/lib/prompt.ts
|
|
1338
1475
|
import { execFileSync } from "child_process";
|
|
1339
1476
|
import { writeFileSync } from "fs";
|
|
1340
|
-
import { dirname as dirname4, join as join10, relative as
|
|
1477
|
+
import { dirname as dirname4, join as join10, relative as relative3, resolve as resolve2 } from "path";
|
|
1341
1478
|
var KINDS = ["daily", "mention"];
|
|
1342
1479
|
function promptView(ws, compose3, staffHandle, brainDir, kind) {
|
|
1343
1480
|
const context = process.env.ROSTER_CONTEXT || (kind !== "daily" ? JSON.stringify({
|
|
@@ -1395,8 +1532,8 @@ function describe(ws, brainDir, rel, optional) {
|
|
|
1395
1532
|
const missing2 = !existsSync2(full);
|
|
1396
1533
|
return {
|
|
1397
1534
|
rel,
|
|
1398
|
-
path:
|
|
1399
|
-
repo: inBrain ?
|
|
1535
|
+
path: posix(relative3(ws.root, full)),
|
|
1536
|
+
repo: inBrain ? posix(relative3(ws.root, brainDir)) : ws.opsName,
|
|
1400
1537
|
bytes: missing2 ? 0 : statSync2(full).size,
|
|
1401
1538
|
optional,
|
|
1402
1539
|
missing: missing2,
|
|
@@ -1414,8 +1551,8 @@ function runtimeReads(ws, brainDir) {
|
|
|
1414
1551
|
const missing2 = !existsSync2(full);
|
|
1415
1552
|
return {
|
|
1416
1553
|
rel,
|
|
1417
|
-
path:
|
|
1418
|
-
repo:
|
|
1554
|
+
path: posix(relative3(ws.root, full)),
|
|
1555
|
+
repo: posix(relative3(ws.root, base2)),
|
|
1419
1556
|
bytes: missing2 ? 0 : statSync2(full).size,
|
|
1420
1557
|
optional: false,
|
|
1421
1558
|
missing: missing2,
|
|
@@ -1427,13 +1564,13 @@ function runtimeReads(ws, brainDir) {
|
|
|
1427
1564
|
}
|
|
1428
1565
|
function isWritable(ws, rel, brainDirs) {
|
|
1429
1566
|
const full = resolve2(ws.root, rel);
|
|
1430
|
-
if (!
|
|
1431
|
-
const opsRel =
|
|
1567
|
+
if (!inside(resolve2(ws.root), full)) return false;
|
|
1568
|
+
const opsRel = posix(relative3(resolve2(ws.opsDir), full));
|
|
1432
1569
|
if (!opsRel.startsWith("..")) {
|
|
1433
1570
|
return /^org\/[\w.-]+\.md$/.test(opsRel) || /^prompts\/[\w.-]+\.md$/.test(opsRel) || opsRel === "org.yaml";
|
|
1434
1571
|
}
|
|
1435
1572
|
for (const dir of brainDirs) {
|
|
1436
|
-
const brainRel =
|
|
1573
|
+
const brainRel = posix(relative3(resolve2(ws.root, dir), full));
|
|
1437
1574
|
if (brainRel.startsWith("..")) continue;
|
|
1438
1575
|
return brainRel === "CHARTER.md" || /^prompts\/[\w.-]+\.md$/.test(brainRel);
|
|
1439
1576
|
}
|
|
@@ -1442,7 +1579,7 @@ function isWritable(ws, rel, brainDirs) {
|
|
|
1442
1579
|
function saveFile(ws, rel, text2, message2) {
|
|
1443
1580
|
const full = resolve2(ws.root, rel);
|
|
1444
1581
|
const repoDir = repoRootOf(full);
|
|
1445
|
-
const repo =
|
|
1582
|
+
const repo = posix(relative3(ws.root, repoDir)) || ".";
|
|
1446
1583
|
const before = existsSync2(full) ? readFileSync2(full, "utf8") : null;
|
|
1447
1584
|
if (before === text2)
|
|
1448
1585
|
return { path: rel, repo, committed: false, pushed: false, note: "no change" };
|
|
@@ -2217,11 +2354,11 @@ async function find() {
|
|
|
2217
2354
|
const env = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
|
|
2218
2355
|
if (env) return { ok: true, gh: githubClient(env), token: env };
|
|
2219
2356
|
const token = await new Promise(
|
|
2220
|
-
(
|
|
2357
|
+
(resolve8) => execFile3(
|
|
2221
2358
|
"gh",
|
|
2222
2359
|
["auth", "token"],
|
|
2223
2360
|
{ encoding: "utf8" },
|
|
2224
|
-
(err, out) =>
|
|
2361
|
+
(err, out) => resolve8(err ? "" : out.trim())
|
|
2225
2362
|
)
|
|
2226
2363
|
);
|
|
2227
2364
|
if (!token) {
|
|
@@ -2303,6 +2440,7 @@ function repoName(full) {
|
|
|
2303
2440
|
import { execFile as execFile4 } from "child_process";
|
|
2304
2441
|
import { mkdirSync } from "fs";
|
|
2305
2442
|
import { join as join12 } from "path";
|
|
2443
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
2306
2444
|
var AGENTS = [
|
|
2307
2445
|
{
|
|
2308
2446
|
id: "claude-code-action",
|
|
@@ -2377,14 +2515,14 @@ function readProducts(opsDir) {
|
|
|
2377
2515
|
const path = join12(opsDir, "org.yaml");
|
|
2378
2516
|
if (!existsSync2(path)) return [];
|
|
2379
2517
|
const out = [];
|
|
2380
|
-
let
|
|
2518
|
+
let inside2 = false;
|
|
2381
2519
|
for (const line of readFileSync2(path, "utf8").split("\n")) {
|
|
2382
2520
|
if (/^repos:\s*$/.test(line)) {
|
|
2383
|
-
|
|
2521
|
+
inside2 = true;
|
|
2384
2522
|
continue;
|
|
2385
2523
|
}
|
|
2386
|
-
if (
|
|
2387
|
-
if (!
|
|
2524
|
+
if (inside2 && /^\S/.test(line)) break;
|
|
2525
|
+
if (!inside2 || !/\brole:\s*product\b/.test(line)) continue;
|
|
2388
2526
|
const m = /\bname:\s*([\w.-]+)/.exec(line);
|
|
2389
2527
|
if (m) out.push(m[1]);
|
|
2390
2528
|
}
|
|
@@ -2395,14 +2533,14 @@ function readBlockNames(opsDir, block, key2) {
|
|
|
2395
2533
|
if (!existsSync2(path)) return [];
|
|
2396
2534
|
const names = [];
|
|
2397
2535
|
const pattern = new RegExp(`\\b${key2}:\\s*([\\w.-]+)`);
|
|
2398
|
-
let
|
|
2536
|
+
let inside2 = false;
|
|
2399
2537
|
for (const line of readFileSync2(path, "utf8").split("\n")) {
|
|
2400
2538
|
if (new RegExp(`^${block}:\\s*$`).test(line)) {
|
|
2401
|
-
|
|
2539
|
+
inside2 = true;
|
|
2402
2540
|
continue;
|
|
2403
2541
|
}
|
|
2404
|
-
if (
|
|
2405
|
-
if (!
|
|
2542
|
+
if (inside2 && /^\S/.test(line)) break;
|
|
2543
|
+
if (!inside2) continue;
|
|
2406
2544
|
const m = pattern.exec(line);
|
|
2407
2545
|
if (m) names.push(m[1]);
|
|
2408
2546
|
}
|
|
@@ -2422,7 +2560,7 @@ function unfinished(opsDir, staffCount) {
|
|
|
2422
2560
|
}
|
|
2423
2561
|
async function loadFrameworkComposer() {
|
|
2424
2562
|
const path = join12(templatesRoot(), "ops", "compose.mjs");
|
|
2425
|
-
return await import(
|
|
2563
|
+
return await import(pathToFileURL2(path).href);
|
|
2426
2564
|
}
|
|
2427
2565
|
async function joinTenant(root2, org) {
|
|
2428
2566
|
mkdirSync(root2, { recursive: true });
|
|
@@ -2435,7 +2573,7 @@ async function joinTenant(root2, org) {
|
|
|
2435
2573
|
if (!existsSync2(join12(opsDir, "org.yaml"))) {
|
|
2436
2574
|
throw new Error(`${org}/roster-ops has no org.yaml, so it is not a roster tenant`);
|
|
2437
2575
|
}
|
|
2438
|
-
const { parseYaml: parseYaml3 } = await import(
|
|
2576
|
+
const { parseYaml: parseYaml3 } = await import(pathToFileURL2(join12(opsDir, "compose.mjs")).href).then(
|
|
2439
2577
|
(m) => m
|
|
2440
2578
|
);
|
|
2441
2579
|
const orgFile = parseYaml3(readFileSync2(join12(opsDir, "org.yaml"), "utf8"), "org.yaml");
|
|
@@ -3340,18 +3478,18 @@ function howTo(org) {
|
|
|
3340
3478
|
function readSecret(prompt) {
|
|
3341
3479
|
const stdin = process.stdin;
|
|
3342
3480
|
if (!stdin.isTTY) {
|
|
3343
|
-
return new Promise((
|
|
3481
|
+
return new Promise((resolve8, reject) => {
|
|
3344
3482
|
let buf = "";
|
|
3345
3483
|
stdin.setEncoding("utf8");
|
|
3346
3484
|
stdin.on("data", (c) => {
|
|
3347
3485
|
buf += c;
|
|
3348
3486
|
});
|
|
3349
|
-
stdin.on("end", () =>
|
|
3487
|
+
stdin.on("end", () => resolve8(buf.trim()));
|
|
3350
3488
|
stdin.on("error", reject);
|
|
3351
3489
|
});
|
|
3352
3490
|
}
|
|
3353
3491
|
process.stdout.write(prompt);
|
|
3354
|
-
return new Promise((
|
|
3492
|
+
return new Promise((resolve8, reject) => {
|
|
3355
3493
|
let buf = "";
|
|
3356
3494
|
stdin.setRawMode(true);
|
|
3357
3495
|
stdin.setEncoding("utf8");
|
|
@@ -3362,7 +3500,7 @@ function readSecret(prompt) {
|
|
|
3362
3500
|
stdin.off("data", onData);
|
|
3363
3501
|
process.stdout.write("\n");
|
|
3364
3502
|
if (err) reject(err);
|
|
3365
|
-
else
|
|
3503
|
+
else resolve8(buf.trim());
|
|
3366
3504
|
};
|
|
3367
3505
|
const onData = (chunk) => {
|
|
3368
3506
|
for (const ch of chunk) {
|
|
@@ -3623,7 +3761,7 @@ function parseFlags5(argv) {
|
|
|
3623
3761
|
}
|
|
3624
3762
|
|
|
3625
3763
|
// src/commands/deploy.ts
|
|
3626
|
-
import { spawn } from "child_process";
|
|
3764
|
+
import { spawn as spawn2 } from "child_process";
|
|
3627
3765
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
3628
3766
|
import { existsSync as existsSync6, mkdirSync as mkdirSync3, mkdtempSync as mkdtempSync2, readFileSync as readFileSync7, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
3629
3767
|
import { tmpdir as tmpdir2 } from "os";
|
|
@@ -3834,17 +3972,19 @@ async function namespaceFor(title, configFile) {
|
|
|
3834
3972
|
const made = await captured(["kv", "namespace", "create", title, "--config", configFile]);
|
|
3835
3973
|
return made.code === 0 ? namespaceId(made.text) : null;
|
|
3836
3974
|
}
|
|
3975
|
+
var NPX_SHELL = process.platform === "win32";
|
|
3837
3976
|
function captured(args) {
|
|
3838
|
-
return new Promise((
|
|
3977
|
+
return new Promise((resolve8) => {
|
|
3839
3978
|
let text2 = "";
|
|
3840
|
-
const child =
|
|
3841
|
-
stdio: ["ignore", "pipe", "inherit"]
|
|
3979
|
+
const child = spawn2("npx", ["--yes", WRANGLER, ...args], {
|
|
3980
|
+
stdio: ["ignore", "pipe", "inherit"],
|
|
3981
|
+
shell: NPX_SHELL
|
|
3842
3982
|
});
|
|
3843
3983
|
child.stdout.on("data", (b) => {
|
|
3844
3984
|
text2 += String(b);
|
|
3845
3985
|
});
|
|
3846
|
-
child.on("close", (code) =>
|
|
3847
|
-
child.on("error", () =>
|
|
3986
|
+
child.on("close", (code) => resolve8({ code: code ?? 1, text: text2 }));
|
|
3987
|
+
child.on("error", () => resolve8({ code: 1, text: text2 }));
|
|
3848
3988
|
});
|
|
3849
3989
|
}
|
|
3850
3990
|
function existingNamespace(text2, title) {
|
|
@@ -3892,10 +4032,13 @@ async function wrangler(args) {
|
|
|
3892
4032
|
return code;
|
|
3893
4033
|
}
|
|
3894
4034
|
function wranglerOnce(args) {
|
|
3895
|
-
return new Promise((
|
|
3896
|
-
const child =
|
|
3897
|
-
|
|
3898
|
-
|
|
4035
|
+
return new Promise((resolve8) => {
|
|
4036
|
+
const child = spawn2("npx", ["--yes", WRANGLER, ...args], {
|
|
4037
|
+
stdio: "inherit",
|
|
4038
|
+
shell: NPX_SHELL
|
|
4039
|
+
});
|
|
4040
|
+
child.on("close", (code) => resolve8(code ?? 1));
|
|
4041
|
+
child.on("error", () => resolve8(1));
|
|
3899
4042
|
});
|
|
3900
4043
|
}
|
|
3901
4044
|
var WORKFLOW_TEXT = `# Redeploys the hosted portal: when its config changes, every morning so roster updates
|
|
@@ -3965,6 +4108,7 @@ function parseFlags6(argv) {
|
|
|
3965
4108
|
// src/commands/doctor.ts
|
|
3966
4109
|
import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync9 } from "fs";
|
|
3967
4110
|
import { join as join20 } from "path";
|
|
4111
|
+
import { pathToFileURL as pathToFileURL3 } from "url";
|
|
3968
4112
|
|
|
3969
4113
|
// src/lib/callable.ts
|
|
3970
4114
|
function accessLink(org, repo) {
|
|
@@ -3998,7 +4142,7 @@ function parseMemory(dir) {
|
|
|
3998
4142
|
const indexPath = join17(dir, "INDEX.md");
|
|
3999
4143
|
if (!existsSync2(indexPath)) throw new Error(`no memory index at ${indexPath}`);
|
|
4000
4144
|
const lines = readFileSync2(indexPath, "utf8").split("\n");
|
|
4001
|
-
const
|
|
4145
|
+
const facts2 = [];
|
|
4002
4146
|
const sections = [];
|
|
4003
4147
|
const preamble = [];
|
|
4004
4148
|
let section = "";
|
|
@@ -4031,7 +4175,7 @@ function parseMemory(dir) {
|
|
|
4031
4175
|
rest = rest.slice(prov[0].length);
|
|
4032
4176
|
}
|
|
4033
4177
|
const so = rest.split(SO_RE);
|
|
4034
|
-
|
|
4178
|
+
facts2.push({
|
|
4035
4179
|
slug,
|
|
4036
4180
|
section,
|
|
4037
4181
|
provenance,
|
|
@@ -4045,19 +4189,19 @@ function parseMemory(dir) {
|
|
|
4045
4189
|
const notesDir = join17(dir, "notes");
|
|
4046
4190
|
const notes = existsSync2(notesDir) ? readdirSync2(notesDir).filter((f) => f.endsWith(".md")).sort() : [];
|
|
4047
4191
|
return {
|
|
4048
|
-
facts,
|
|
4192
|
+
facts: facts2,
|
|
4049
4193
|
sections,
|
|
4050
4194
|
notes,
|
|
4051
4195
|
preamble: preamble.join("\n").trim(),
|
|
4052
|
-
links: extractLinks(
|
|
4196
|
+
links: extractLinks(facts2, notes, dir)
|
|
4053
4197
|
};
|
|
4054
4198
|
}
|
|
4055
4199
|
var WIKILINK_RE = /\[\[([a-z0-9-]+)\]\]/g;
|
|
4056
4200
|
var ISSUE_RE = /(?:^|[\s(])#(\d{1,4})\b/g;
|
|
4057
4201
|
var PATH_RE = /`([a-zA-Z0-9_./-]+\.(?:ts|tsx|mjs|js|md|yaml|yml|json|sql))`/g;
|
|
4058
|
-
function extractLinks(
|
|
4202
|
+
function extractLinks(facts2, notes, dir) {
|
|
4059
4203
|
const links = [];
|
|
4060
|
-
const bySlug = new Set(
|
|
4204
|
+
const bySlug = new Set(facts2.map((f) => f.slug));
|
|
4061
4205
|
const push = (from, to, kind, inferred) => {
|
|
4062
4206
|
if (from === to) return;
|
|
4063
4207
|
if (links.some((l) => l.from === from && l.to === to && l.kind === kind)) return;
|
|
@@ -4071,7 +4215,7 @@ function extractLinks(facts, notes, dir) {
|
|
|
4071
4215
|
if (from !== slug && text2.includes("`" + slug + "`")) push(from, slug, "mention", true);
|
|
4072
4216
|
}
|
|
4073
4217
|
};
|
|
4074
|
-
for (const f of
|
|
4218
|
+
for (const f of facts2) {
|
|
4075
4219
|
if (f.note) push(f.slug, f.note.replace(/^notes\//, ""), "note", false);
|
|
4076
4220
|
scan(f.slug, f.raw);
|
|
4077
4221
|
}
|
|
@@ -4459,12 +4603,12 @@ async function pool(items, size2, work) {
|
|
|
4459
4603
|
}
|
|
4460
4604
|
function spend(rows, days = 30, now = Date.now()) {
|
|
4461
4605
|
const from = now - days * 864e5;
|
|
4462
|
-
const
|
|
4463
|
-
const costed =
|
|
4606
|
+
const inside2 = rows.filter((r) => new Date(r.createdAt).getTime() >= from);
|
|
4607
|
+
const costed = inside2.filter((r) => typeof r.record?.cost_usd === "number");
|
|
4464
4608
|
return {
|
|
4465
4609
|
usd: Math.round(costed.reduce((sum, r) => sum + r.record.cost_usd, 0) * 100) / 100,
|
|
4466
4610
|
known: costed.length,
|
|
4467
|
-
runs:
|
|
4611
|
+
runs: inside2.length
|
|
4468
4612
|
};
|
|
4469
4613
|
}
|
|
4470
4614
|
function budgetOf(value) {
|
|
@@ -5127,7 +5271,7 @@ async function checkAgent(ws, org) {
|
|
|
5127
5271
|
const scope = "workspace";
|
|
5128
5272
|
let agent;
|
|
5129
5273
|
try {
|
|
5130
|
-
const { resolveAgent } = await import(
|
|
5274
|
+
const { resolveAgent } = await import(pathToFileURL3(join20(ws.opsDir, "agents.mjs")).href);
|
|
5131
5275
|
agent = resolveAgent(org, {});
|
|
5132
5276
|
} catch (err) {
|
|
5133
5277
|
return [
|
|
@@ -5443,12 +5587,12 @@ function timeoutOf(callerText) {
|
|
|
5443
5587
|
const m = /timeout_minutes:\s*(\d+)/.exec(callerText);
|
|
5444
5588
|
return m ? Number(m[1]) : 90;
|
|
5445
5589
|
}
|
|
5446
|
-
function runMinutes(
|
|
5447
|
-
return (new Date(
|
|
5590
|
+
function runMinutes(run3) {
|
|
5591
|
+
return (new Date(run3.updatedAt).getTime() - new Date(run3.createdAt).getTime()) / 6e4;
|
|
5448
5592
|
}
|
|
5449
|
-
function isTimeout(
|
|
5450
|
-
if (
|
|
5451
|
-
return runMinutes(
|
|
5593
|
+
function isTimeout(run3, timeout) {
|
|
5594
|
+
if (run3.conclusion !== "cancelled") return false;
|
|
5595
|
+
return runMinutes(run3) >= timeout - 1;
|
|
5452
5596
|
}
|
|
5453
5597
|
function inferredCeiling(cancelled) {
|
|
5454
5598
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -5570,7 +5714,7 @@ async function checkStaffOnline(scope, manifest, callers, humans = [], connector
|
|
|
5570
5714
|
for (const m of c.text.matchAll(/secrets\.([A-Z0-9_]+)/g)) needed.add(m[1]);
|
|
5571
5715
|
for (const name of inheritedSecrets(c.text)) needed.add(name);
|
|
5572
5716
|
}
|
|
5573
|
-
const [secrets, orgSecrets, labels, runs, pinned, workflows,
|
|
5717
|
+
const [secrets, orgSecrets, labels, runs, pinned, workflows, open] = await Promise.all([
|
|
5574
5718
|
api(`repos/${repo}/actions/secrets`),
|
|
5575
5719
|
/* An agent credential kept once for the org, and shared with this repo, is as good as one
|
|
5576
5720
|
on the repo: Actions resolves `secrets.X` from either. Read separately because the two
|
|
@@ -5674,7 +5818,7 @@ async function checkStaffOnline(scope, manifest, callers, humans = [], connector
|
|
|
5674
5818
|
out.push(ownedLabels(scope, repo, have));
|
|
5675
5819
|
out.push(personLabels(scope, repo, have, markers));
|
|
5676
5820
|
}
|
|
5677
|
-
if (
|
|
5821
|
+
if (open.ok) out.push(...unkindedAsks(scope, repo, open.data, humans));
|
|
5678
5822
|
const variable = await api(`repos/${repo}/actions/variables/ROSTER_HUMANS`);
|
|
5679
5823
|
if (variable.ok) out.push(humansVariable(scope, repo, variable.data.value, humans));
|
|
5680
5824
|
const peers = (manifest.peers ?? []).filter((p) => p.label && p.brain);
|
|
@@ -6098,7 +6242,7 @@ import { writeFileSync as writeFileSync8 } from "fs";
|
|
|
6098
6242
|
|
|
6099
6243
|
// src/lib/export.ts
|
|
6100
6244
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
6101
|
-
import { join as join21, relative as
|
|
6245
|
+
import { join as join21, relative as relative4 } from "path";
|
|
6102
6246
|
var gitHistory = {
|
|
6103
6247
|
log: (root2, n, path) => gitLog(root2, n, path ? ["--", path] : []),
|
|
6104
6248
|
factsChanged: (root2, since) => factsChanged(root2, since)
|
|
@@ -6204,14 +6348,14 @@ function readSurfaces(root2, declared3) {
|
|
|
6204
6348
|
}));
|
|
6205
6349
|
}
|
|
6206
6350
|
function walk2(dir, root2, out = []) {
|
|
6207
|
-
for (const name of readdirSync2(dir)) {
|
|
6351
|
+
for (const name of [...readdirSync2(dir)].sort()) {
|
|
6208
6352
|
if (SKIP.has(name)) continue;
|
|
6209
6353
|
const full = join21(dir, name);
|
|
6210
6354
|
const st = statSync2(full);
|
|
6211
6355
|
if (st.isDirectory()) walk2(full, root2, out);
|
|
6212
6356
|
else {
|
|
6213
6357
|
out.push({
|
|
6214
|
-
path:
|
|
6358
|
+
path: posix(relative4(root2, full)),
|
|
6215
6359
|
bytes: st.size,
|
|
6216
6360
|
modified: st.mtime.toISOString(),
|
|
6217
6361
|
ext: name.includes(".") ? name.split(".").pop().toLowerCase() : ""
|
|
@@ -6298,9 +6442,9 @@ async function exportCommand(argv) {
|
|
|
6298
6442
|
const json3 = JSON.stringify(data, null, 2);
|
|
6299
6443
|
if (out) {
|
|
6300
6444
|
writeFileSync8(out, json3 + "\n");
|
|
6301
|
-
const
|
|
6445
|
+
const facts2 = data.staff.reduce((n, s) => n + s.facts.length, 0);
|
|
6302
6446
|
process.stdout.write(
|
|
6303
|
-
` ${out} ${data.staff.length} staff, ${
|
|
6447
|
+
` ${out} ${data.staff.length} staff, ${facts2} facts, ${Math.round(json3.length / 1024)}kb
|
|
6304
6448
|
`
|
|
6305
6449
|
);
|
|
6306
6450
|
} else {
|
|
@@ -6653,6 +6797,7 @@ function parseFlags9(argv) {
|
|
|
6653
6797
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
6654
6798
|
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
|
|
6655
6799
|
import { dirname as dirname8, join as join23, resolve as resolve3 } from "path";
|
|
6800
|
+
import { pathToFileURL as pathToFileURL4 } from "url";
|
|
6656
6801
|
var initHelp = `
|
|
6657
6802
|
roster init --org <github-org> [--name "Acme"] [--human <login>] [--apply]
|
|
6658
6803
|
|
|
@@ -6829,7 +6974,7 @@ async function initFiles(o) {
|
|
|
6829
6974
|
}
|
|
6830
6975
|
async function agentPreset(id) {
|
|
6831
6976
|
const path = join23(opsTemplateDir(), "agents.mjs");
|
|
6832
|
-
const { PRESETS } = await import(
|
|
6977
|
+
const { PRESETS } = await import(pathToFileURL4(path).href);
|
|
6833
6978
|
const preset = PRESETS[id];
|
|
6834
6979
|
if (!preset) {
|
|
6835
6980
|
throw new Error(
|
|
@@ -7085,16 +7230,16 @@ function parseFlags11(argv) {
|
|
|
7085
7230
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
7086
7231
|
import { readFileSync as readFileSync14 } from "fs";
|
|
7087
7232
|
import { createServer as createServer2 } from "http";
|
|
7088
|
-
import { join as
|
|
7233
|
+
import { join as join33, resolve as resolve6 } from "path";
|
|
7089
7234
|
|
|
7090
7235
|
// src/lib/attach.ts
|
|
7091
7236
|
import { execFileSync as execFileSync8 } from "child_process";
|
|
7092
7237
|
import { existsSync as existsSync10, mkdirSync as mkdirSync6, writeFileSync as writeFileSync10 } from "fs";
|
|
7093
|
-
import { basename, extname, join as join25 } from "path";
|
|
7238
|
+
import { basename as basename2, extname, join as join25 } from "path";
|
|
7094
7239
|
var MAX_UPLOAD = 25 * 1024 * 1024;
|
|
7095
7240
|
var ATTACH_DIR = "attachments";
|
|
7096
7241
|
function safeName(raw) {
|
|
7097
|
-
const name =
|
|
7242
|
+
const name = basename2(String(raw ?? "")).replace(/^\.+/, "");
|
|
7098
7243
|
const ext = extname(name).toLowerCase().slice(0, 12);
|
|
7099
7244
|
const stem = name.slice(0, name.length - extname(name).length).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "file";
|
|
7100
7245
|
return stem + ext.replace(/[^a-z0-9.]/g, "");
|
|
@@ -7102,7 +7247,7 @@ function safeName(raw) {
|
|
|
7102
7247
|
function attachPath(name, size2, today, taken) {
|
|
7103
7248
|
if (!size2) throw new Error("that file is empty");
|
|
7104
7249
|
if (size2 > MAX_UPLOAD) {
|
|
7105
|
-
throw new Error(`${
|
|
7250
|
+
throw new Error(`${basename2(name)} is larger than ${MAX_UPLOAD / 1024 / 1024}MB`);
|
|
7106
7251
|
}
|
|
7107
7252
|
return free(`${ATTACH_DIR}/${today}-${safeName(name)}`, taken);
|
|
7108
7253
|
}
|
|
@@ -7124,7 +7269,7 @@ function bin(env = process.env, argv1 = process.argv[1] ?? "") {
|
|
|
7124
7269
|
if (env.npm_command === "exec" || /[\\/]_npx[\\/]/.test(argv1)) return NPX;
|
|
7125
7270
|
return "roster";
|
|
7126
7271
|
}
|
|
7127
|
-
var COMMAND = /\broster(?= (?:init|hire|app|credential|run|doctor|fix|portal|prompt|upgrade|retire|lint|brief|export|help)\b)/g;
|
|
7272
|
+
var COMMAND = /\broster(?= (?:init|setup|skill|hire|app|credential|run|routine|doctor|fix|portal|prompt|upgrade|retire|lint|brief|export|help)\b)/g;
|
|
7128
7273
|
function withBin(text2, name = bin()) {
|
|
7129
7274
|
return name === "roster" ? text2 : text2.replace(COMMAND, name);
|
|
7130
7275
|
}
|
|
@@ -7141,42 +7286,19 @@ function rewriteOutput(name = bin()) {
|
|
|
7141
7286
|
return (text2) => void raw(text2);
|
|
7142
7287
|
}
|
|
7143
7288
|
|
|
7144
|
-
// src/lib/browser.ts
|
|
7145
|
-
import { spawn as spawn2 } from "child_process";
|
|
7146
|
-
function shouldOpen(env, isTTY, noOpen) {
|
|
7147
|
-
if (noOpen || !isTTY) return false;
|
|
7148
|
-
if (env.CI || env.BROWSER === "none" || env.SSH_CONNECTION) return false;
|
|
7149
|
-
return true;
|
|
7150
|
-
}
|
|
7151
|
-
function openerFor(platform, url) {
|
|
7152
|
-
if (platform === "darwin") return ["open", [url]];
|
|
7153
|
-
if (platform === "win32") return ["cmd", ["/c", "start", "", url]];
|
|
7154
|
-
return ["xdg-open", [url]];
|
|
7155
|
-
}
|
|
7156
|
-
function openBrowser(url) {
|
|
7157
|
-
const [cmd, args] = openerFor(process.platform, url);
|
|
7158
|
-
try {
|
|
7159
|
-
const child = spawn2(cmd, args, { stdio: "ignore", detached: true });
|
|
7160
|
-
child.on("error", () => {
|
|
7161
|
-
});
|
|
7162
|
-
child.unref();
|
|
7163
|
-
} catch {
|
|
7164
|
-
}
|
|
7165
|
-
}
|
|
7166
|
-
|
|
7167
7289
|
// src/lib/sync.ts
|
|
7168
7290
|
import { execFile as execFile5 } from "child_process";
|
|
7169
7291
|
import { existsSync as existsSync11 } from "fs";
|
|
7170
7292
|
import { join as join26 } from "path";
|
|
7171
|
-
import { promisify as
|
|
7172
|
-
var
|
|
7293
|
+
import { promisify as promisify2 } from "util";
|
|
7294
|
+
var run2 = promisify2(execFile5);
|
|
7173
7295
|
async function syncRepos(root2, dirs) {
|
|
7174
7296
|
return Promise.all(dirs.map((dir) => syncOne(join26(root2, dir), dir)));
|
|
7175
7297
|
}
|
|
7176
7298
|
async function syncOne(path, dir) {
|
|
7177
7299
|
const base2 = { dir, behind: 0, ahead: 0, dirty: false, pulled: false };
|
|
7178
7300
|
if (!existsSync11(join26(path, ".git"))) return { ...base2, skipped: "no-remote" };
|
|
7179
|
-
const git4 = async (...args) => (await
|
|
7301
|
+
const git4 = async (...args) => (await run2("git", ["-C", path, ...args], { encoding: "utf8" })).stdout.trim();
|
|
7180
7302
|
try {
|
|
7181
7303
|
const remotes = await git4("remote");
|
|
7182
7304
|
if (!remotes) return { ...base2, skipped: "no-remote" };
|
|
@@ -7241,7 +7363,7 @@ var ASSET_MIME = {
|
|
|
7241
7363
|
function portalAsset(rel) {
|
|
7242
7364
|
const root2 = portalDir();
|
|
7243
7365
|
const full = resolve4(root2, rel);
|
|
7244
|
-
if (!
|
|
7366
|
+
if (!inside(resolve4(root2), full)) return null;
|
|
7245
7367
|
const type = ASSET_MIME[extname2(full).toLowerCase()];
|
|
7246
7368
|
if (!type) return null;
|
|
7247
7369
|
if (!existsSync12(full) || statSync3(full).isDirectory()) return null;
|
|
@@ -7249,7 +7371,7 @@ function portalAsset(rel) {
|
|
|
7249
7371
|
}
|
|
7250
7372
|
|
|
7251
7373
|
// src/portal/handler.ts
|
|
7252
|
-
import { join as
|
|
7374
|
+
import { join as join30, relative as relative5, resolve as resolve5 } from "path";
|
|
7253
7375
|
|
|
7254
7376
|
// src/lib/ask.ts
|
|
7255
7377
|
var MAX_PATCH_LINES = 40;
|
|
@@ -7351,10 +7473,10 @@ async function act(gh, req) {
|
|
|
7351
7473
|
if (repo !== ask.staff.brain)
|
|
7352
7474
|
throw new Error(`an ask goes to ${ask.staff.brain}, not to ${repo}`);
|
|
7353
7475
|
if (!ask.body?.trim()) throw new Error("an empty ask is not an ask");
|
|
7354
|
-
const
|
|
7476
|
+
const open = await openAskFor(gh, repo, askHead(ask));
|
|
7355
7477
|
let url;
|
|
7356
|
-
if (
|
|
7357
|
-
url = await comment(gh, repo,
|
|
7478
|
+
if (open) {
|
|
7479
|
+
url = await comment(gh, repo, open, askFollowUp(ask));
|
|
7358
7480
|
} else {
|
|
7359
7481
|
const title = (req.title ?? "").trim() || askTitle(ask);
|
|
7360
7482
|
url = await openIssue(gh, repo, title, askBody(ask), req.labels);
|
|
@@ -7879,6 +8001,10 @@ function short3(e) {
|
|
|
7879
8001
|
// src/lib/live.ts
|
|
7880
8002
|
var FINISHED_HOURS = 6;
|
|
7881
8003
|
function parseTitle(handle, title, workflow = "") {
|
|
8004
|
+
const routine = new RegExp(
|
|
8005
|
+
`^${handle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")} routine ([a-z0-9-]+)\\s*$`
|
|
8006
|
+
).exec(title.trim());
|
|
8007
|
+
if (routine) return { trigger: "routine", issue: null, routine: routine[1] };
|
|
7882
8008
|
const m = new RegExp(
|
|
7883
8009
|
`^${handle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")} (daily|manual|follow-on|mention|peer|ignored)(?: #(\\d+))?\\s*$`
|
|
7884
8010
|
).exec(title.trim());
|
|
@@ -7893,23 +8019,28 @@ function shapeLive(handle, brain, raw, limit, now = Date.now()) {
|
|
|
7893
8019
|
const out = { handle, brain, running: [], finished: [], automatic: 0, limit };
|
|
7894
8020
|
for (const r of raw) {
|
|
7895
8021
|
if (r.conclusion === "skipped") continue;
|
|
7896
|
-
const { trigger, issue } = parseTitle(
|
|
8022
|
+
const { trigger, issue, routine } = parseTitle(
|
|
8023
|
+
handle,
|
|
8024
|
+
r.displayTitle ?? "",
|
|
8025
|
+
r.workflowName ?? ""
|
|
8026
|
+
);
|
|
7897
8027
|
if (trigger === "ignored") continue;
|
|
7898
|
-
const
|
|
8028
|
+
const run3 = {
|
|
7899
8029
|
id: Number(r.databaseId),
|
|
7900
8030
|
trigger,
|
|
7901
8031
|
issue,
|
|
8032
|
+
...routine ? { routine } : {},
|
|
7902
8033
|
status: String(r.status ?? ""),
|
|
7903
8034
|
conclusion: r.conclusion ?? null,
|
|
7904
8035
|
createdAt: String(r.createdAt ?? ""),
|
|
7905
8036
|
updatedAt: String(r.updatedAt ?? r.createdAt ?? ""),
|
|
7906
8037
|
url: String(r.url ?? "")
|
|
7907
8038
|
};
|
|
7908
|
-
if ((trigger === "peer" || trigger === "follow-on") &&
|
|
8039
|
+
if ((trigger === "peer" || trigger === "follow-on") && run3.createdAt.slice(0, 10) === today) {
|
|
7909
8040
|
out.automatic++;
|
|
7910
8041
|
}
|
|
7911
|
-
if (
|
|
7912
|
-
else if (new Date(
|
|
8042
|
+
if (run3.status !== "completed") out.running.push(run3);
|
|
8043
|
+
else if (new Date(run3.updatedAt).getTime() >= since) out.finished.push(run3);
|
|
7913
8044
|
}
|
|
7914
8045
|
out.running.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
7915
8046
|
out.finished.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
@@ -7976,15 +8107,63 @@ async function markRead(gh, thread) {
|
|
|
7976
8107
|
return res.ok;
|
|
7977
8108
|
}
|
|
7978
8109
|
|
|
8110
|
+
// src/lib/routineplan.ts
|
|
8111
|
+
import { join as join28 } from "path";
|
|
8112
|
+
var DAILY_TEMPLATE = ".github/workflows/%%STAFF%%-daily.yaml";
|
|
8113
|
+
function readSchedule(manifest, read3) {
|
|
8114
|
+
return {
|
|
8115
|
+
daily: String(manifest.schedule ?? ""),
|
|
8116
|
+
routines: routinesOf(manifest).map((r) => {
|
|
8117
|
+
const text2 = read3(routinePath(r.id));
|
|
8118
|
+
return {
|
|
8119
|
+
...r,
|
|
8120
|
+
...text2 === void 0 ? { title: r.id, body: "" } : parseRoutineFile(text2, r.id)
|
|
8121
|
+
};
|
|
8122
|
+
})
|
|
8123
|
+
};
|
|
8124
|
+
}
|
|
8125
|
+
function planSchedule(opts) {
|
|
8126
|
+
const errors = checkRoutines(opts.next.daily, opts.next.routines);
|
|
8127
|
+
if (opts.next.routines.length && !/^\s+routine:\s*$/m.test(opts.session)) {
|
|
8128
|
+
errors.push(
|
|
8129
|
+
"the ops repo's session workflow is older than routines. Run `roster upgrade --apply` and push the ops repo first."
|
|
8130
|
+
);
|
|
8131
|
+
}
|
|
8132
|
+
if (errors.length) return { errors, changes: [] };
|
|
8133
|
+
const before = opts.parseYaml(opts.manifest, "staff.yaml");
|
|
8134
|
+
const manifest = setRoutinesInManifest(
|
|
8135
|
+
setDailyInManifest(opts.manifest, opts.next.daily),
|
|
8136
|
+
opts.next.routines.map((r) => ({ id: r.id, schedule: r.schedule }))
|
|
8137
|
+
);
|
|
8138
|
+
const spec2 = specFromManifest(opts.parseYaml(manifest, "staff.yaml"), opts.dir);
|
|
8139
|
+
const tokens = tokensFor(opts.org, spec2);
|
|
8140
|
+
const caller = render(
|
|
8141
|
+
readFileSync2(join28(brainTemplateDir(), DAILY_TEMPLATE), "utf8"),
|
|
8142
|
+
tokens,
|
|
8143
|
+
DAILY_TEMPLATE
|
|
8144
|
+
);
|
|
8145
|
+
const want = [
|
|
8146
|
+
{ path: "staff.yaml", text: manifest },
|
|
8147
|
+
...opts.next.routines.map((r) => ({ path: routinePath(r.id), text: routineFile(r) })),
|
|
8148
|
+
...routinesOf(before).filter((r) => !opts.next.routines.some((n) => n.id === r.id)).map((r) => ({ path: routinePath(r.id), text: null })),
|
|
8149
|
+
{ path: render(DAILY_TEMPLATE, tokens), text: caller }
|
|
8150
|
+
];
|
|
8151
|
+
const changes = want.filter((c) => {
|
|
8152
|
+
const have = opts.current(c.path);
|
|
8153
|
+
return c.text === null ? have !== void 0 : have !== c.text;
|
|
8154
|
+
});
|
|
8155
|
+
return { errors: [], changes };
|
|
8156
|
+
}
|
|
8157
|
+
|
|
7979
8158
|
// src/lib/runonce.ts
|
|
7980
8159
|
function dailyWorkflow(handle) {
|
|
7981
8160
|
return `${handle}-daily.yaml`;
|
|
7982
8161
|
}
|
|
7983
|
-
async function dispatch(gh, repo, workflow) {
|
|
8162
|
+
async function dispatch(gh, repo, workflow, inputs) {
|
|
7984
8163
|
const info = await gh.request("GET", `repos/${repo}`);
|
|
7985
8164
|
if (!info.ok) return { ok: false, error: info.error };
|
|
7986
8165
|
const res = await gh.request("POST", `repos/${repo}/actions/workflows/${workflow}/dispatches`, {
|
|
7987
|
-
body: { ref: info.data?.default_branch ?? "main" }
|
|
8166
|
+
body: { ref: info.data?.default_branch ?? "main", ...inputs ? { inputs } : {} }
|
|
7988
8167
|
});
|
|
7989
8168
|
return res.ok ? { ok: true } : { ok: false, error: res.error };
|
|
7990
8169
|
}
|
|
@@ -8015,14 +8194,14 @@ async function findDispatched(gh, repo, workflow, since, o = {}) {
|
|
|
8015
8194
|
return void 0;
|
|
8016
8195
|
}
|
|
8017
8196
|
async function runState(gh, repo, id) {
|
|
8018
|
-
const [
|
|
8197
|
+
const [run3, jobs] = await Promise.all([
|
|
8019
8198
|
gh.request("GET", `repos/${repo}/actions/runs/${id}`),
|
|
8020
8199
|
gh.request(
|
|
8021
8200
|
"GET",
|
|
8022
8201
|
`repos/${repo}/actions/runs/${id}/jobs?per_page=100`
|
|
8023
8202
|
)
|
|
8024
8203
|
]);
|
|
8025
|
-
if (!
|
|
8204
|
+
if (!run3.ok || !run3.data) throw new Error(`could not read run ${id}: ${run3.error}`);
|
|
8026
8205
|
const list2 = (jobs.data?.jobs ?? []).map((j) => ({
|
|
8027
8206
|
name: String(j.name ?? ""),
|
|
8028
8207
|
conclusion: String(j.conclusion ?? ""),
|
|
@@ -8031,15 +8210,15 @@ async function runState(gh, repo, id) {
|
|
|
8031
8210
|
conclusion: String(s.conclusion ?? "")
|
|
8032
8211
|
}))
|
|
8033
8212
|
}));
|
|
8034
|
-
return { ...runInfo(
|
|
8213
|
+
return { ...runInfo(run3.data), failedAt: failedSteps(list2) };
|
|
8035
8214
|
}
|
|
8036
8215
|
function failedSteps(jobs) {
|
|
8037
8216
|
const out = [];
|
|
8038
8217
|
for (const j of jobs) {
|
|
8039
8218
|
if (j.conclusion !== "failure") continue;
|
|
8040
|
-
const
|
|
8041
|
-
if (!
|
|
8042
|
-
for (const s of
|
|
8219
|
+
const steps2 = (j.steps ?? []).filter((s) => s.conclusion === "failure");
|
|
8220
|
+
if (!steps2.length) out.push(j.name);
|
|
8221
|
+
for (const s of steps2) out.push(`${j.name} \u203A ${s.name}`);
|
|
8043
8222
|
}
|
|
8044
8223
|
return out;
|
|
8045
8224
|
}
|
|
@@ -8061,7 +8240,7 @@ function wait(ms) {
|
|
|
8061
8240
|
}
|
|
8062
8241
|
|
|
8063
8242
|
// src/portal/brief.ts
|
|
8064
|
-
import { join as
|
|
8243
|
+
import { join as join29 } from "path";
|
|
8065
8244
|
function buildPasteBrief(ws, parseYaml3, kind, handle, example, about) {
|
|
8066
8245
|
if (!pasteable(kind)) throw new Error(`there is no paste-mode brief for "${kind}"`);
|
|
8067
8246
|
const org = readOrg(ws.opsDir, parseYaml3);
|
|
@@ -8075,7 +8254,7 @@ function buildPasteBrief(ws, parseYaml3, kind, handle, example, about) {
|
|
|
8075
8254
|
throw new Error(`unknown staff handle "${handle}". org.yaml knows: ${known}`);
|
|
8076
8255
|
}
|
|
8077
8256
|
dir = entry.dir ?? entry.handle;
|
|
8078
|
-
const manifestPath =
|
|
8257
|
+
const manifestPath = join29(ws.root, dir, "staff.yaml");
|
|
8079
8258
|
tokens = tokensFor(
|
|
8080
8259
|
orgSpec(org, ws),
|
|
8081
8260
|
specFromManifest(parseYaml3(readFileSync2(manifestPath, "utf8"), "staff.yaml"), dir)
|
|
@@ -8633,7 +8812,7 @@ function createPortal(opts) {
|
|
|
8633
8812
|
return {
|
|
8634
8813
|
org: opts.org,
|
|
8635
8814
|
opsName: opts.opsName,
|
|
8636
|
-
ws: { root: root2, opsDir:
|
|
8815
|
+
ws: { root: root2, opsDir: join30(root2, opts.opsName), opsName: opts.opsName },
|
|
8637
8816
|
snapshots,
|
|
8638
8817
|
kv: opts.kv,
|
|
8639
8818
|
grants: opts.grants,
|
|
@@ -8716,7 +8895,7 @@ var ROUTES = {
|
|
|
8716
8895
|
"/api/doc": async ({ url }) => {
|
|
8717
8896
|
const page2 = url.searchParams.get("page") ?? "";
|
|
8718
8897
|
if (!docPages().some((d) => d.file === page2)) return notFound();
|
|
8719
|
-
return text(readFileSync2(
|
|
8898
|
+
return text(readFileSync2(join30(docsDir(), page2), "utf8"), "text/plain; charset=utf-8");
|
|
8720
8899
|
},
|
|
8721
8900
|
"/api/docasset": async ({ url }) => {
|
|
8722
8901
|
const asset = docAsset(url.searchParams.get("path") ?? "");
|
|
@@ -8756,7 +8935,7 @@ var ROUTES = {
|
|
|
8756
8935
|
return [...names ?? []].filter((f) => f.endsWith(".md")).sort().map((f) => prefix + f);
|
|
8757
8936
|
};
|
|
8758
8937
|
const files = ["org.yaml", ...listMd("org", "org/"), ...listMd("prompts", "prompts/")].filter((rel) => isWritable(ws, `${ws.opsName}/${rel}`, brains)).map((rel) => {
|
|
8759
|
-
const full =
|
|
8938
|
+
const full = join30(ws.opsDir, rel);
|
|
8760
8939
|
const body2 = readFileSync2(full, "utf8");
|
|
8761
8940
|
return {
|
|
8762
8941
|
path: rel,
|
|
@@ -8775,7 +8954,7 @@ var ROUTES = {
|
|
|
8775
8954
|
const kind = url.searchParams.get("kind") ?? "daily";
|
|
8776
8955
|
const entry = (org.staff ?? []).find((s) => s.handle === handle);
|
|
8777
8956
|
if (!entry || !KINDS.includes(kind)) return bad();
|
|
8778
|
-
const brainDir =
|
|
8957
|
+
const brainDir = join30(portal.ws.root, entry.dir ?? entry.handle);
|
|
8779
8958
|
try {
|
|
8780
8959
|
const view = promptView(portal.ws, compose2, handle, brainDir, kind);
|
|
8781
8960
|
view.problems = auditPrompt(portal.ws, view, workspaceRoots(org));
|
|
@@ -8790,7 +8969,7 @@ var ROUTES = {
|
|
|
8790
8969
|
const handle = url.searchParams.get("staff") ?? "";
|
|
8791
8970
|
const entry = (org.staff ?? []).find((s) => s.handle === handle);
|
|
8792
8971
|
if (!entry) return bad();
|
|
8793
|
-
const brainDir =
|
|
8972
|
+
const brainDir = join30(portal.ws.root, entry.dir ?? entry.handle);
|
|
8794
8973
|
const roots = workspaceRoots(org);
|
|
8795
8974
|
const found = /* @__PURE__ */ new Map();
|
|
8796
8975
|
const errors = [];
|
|
@@ -8832,7 +9011,7 @@ var ROUTES = {
|
|
|
8832
9011
|
const entry = (org.staff ?? []).find((s) => s.handle === handle);
|
|
8833
9012
|
if (!entry) return json({ error: `no staff member "${handle}"` }, 400);
|
|
8834
9013
|
const dir = entry.dir ?? entry.handle;
|
|
8835
|
-
const spec2 = specFromManifest(readManifest2(
|
|
9014
|
+
const spec2 = specFromManifest(readManifest2(join30(portal.ws.root, dir), parseYaml2), dir);
|
|
8836
9015
|
try {
|
|
8837
9016
|
const body2 = await staffProgress(actor.gh, org.org, spec2, dailyWorkflow(entry.handle));
|
|
8838
9017
|
portal.caches.progress.set(handle, { at: Date.now(), body: body2 });
|
|
@@ -8841,24 +9020,80 @@ var ROUTES = {
|
|
|
8841
9020
|
return json({ app: null, publicApp: null, installed: null, credential: null, ran: null });
|
|
8842
9021
|
}
|
|
8843
9022
|
},
|
|
8844
|
-
/* One daily run, now. The repo and the workflow come from the manifest, never
|
|
9023
|
+
/* One daily run, now, or one routine. The repo and the workflow come from the manifest, never
|
|
9024
|
+
the request; a routine is only ever an id the manifest lists. */
|
|
8845
9025
|
"/api/run/start": async (c) => {
|
|
8846
9026
|
const { req, portal, actor } = c;
|
|
8847
9027
|
if (!actor.canWrite) return refuse();
|
|
8848
9028
|
const payload = await body(req);
|
|
8849
9029
|
const brain = await brainOf(c, payload.staff ?? "");
|
|
8850
9030
|
const workflow = dailyWorkflow(payload.staff ?? "");
|
|
9031
|
+
let inputs;
|
|
9032
|
+
if (payload.routine) {
|
|
9033
|
+
const known = (await schedules(c)).find((s) => s.handle === payload.staff);
|
|
9034
|
+
if (!known?.routines.some((r) => r.id === payload.routine)) {
|
|
9035
|
+
return json({ error: `${payload.staff} has no routine "${payload.routine}"` }, 400);
|
|
9036
|
+
}
|
|
9037
|
+
inputs = { trigger: "manual", routine: payload.routine };
|
|
9038
|
+
}
|
|
8851
9039
|
const since = Date.now();
|
|
8852
|
-
const started = await dispatch(actor.gh, brain, workflow);
|
|
9040
|
+
const started = await dispatch(actor.gh, brain, workflow, inputs);
|
|
8853
9041
|
if (!started.ok) return json({ error: `could not start ${workflow}: ${started.error}` }, 400);
|
|
8854
|
-
const
|
|
9042
|
+
const run3 = await findDispatched(actor.gh, brain, workflow, since);
|
|
8855
9043
|
portal.caches.runs = null;
|
|
8856
9044
|
return json({
|
|
8857
9045
|
ok: true,
|
|
8858
|
-
id:
|
|
8859
|
-
url:
|
|
9046
|
+
id: run3?.databaseId,
|
|
9047
|
+
url: run3?.url ?? `https://github.com/${brain}/actions/workflows/${workflow}`
|
|
8860
9048
|
});
|
|
8861
9049
|
},
|
|
9050
|
+
/* Every staff member's daily round and routines, for the Routines screen. */
|
|
9051
|
+
"/api/routines": async (c) => json({ staff: await schedules(c, { force: true }) }),
|
|
9052
|
+
/* One staff member's schedule, saved whole: staff.yaml, each routines/<id>.md and the daily
|
|
9053
|
+
caller, in one commit as the person. A new routine arrives without an id and gets one. */
|
|
9054
|
+
"/api/routines/save": async (c) => {
|
|
9055
|
+
const { req, portal, actor } = c;
|
|
9056
|
+
if (!actor.canWrite) return refuse();
|
|
9057
|
+
const { org } = await ready(c, { force: true });
|
|
9058
|
+
const payload = await body(req);
|
|
9059
|
+
const entry = (org.staff ?? []).find((x) => x.handle === payload.staff);
|
|
9060
|
+
if (!entry) return json({ error: `no staff member "${payload.staff}"` }, 400);
|
|
9061
|
+
const dir = String(entry.dir ?? entry.handle);
|
|
9062
|
+
const root2 = join30(portal.ws.root, dir);
|
|
9063
|
+
const current = (rel) => existsSync2(join30(root2, rel)) ? readFileSync2(join30(root2, rel), "utf8") : void 0;
|
|
9064
|
+
const manifest = current("staff.yaml");
|
|
9065
|
+
if (manifest === void 0) return json({ error: `${dir} has no staff.yaml` }, 400);
|
|
9066
|
+
const taken = [];
|
|
9067
|
+
const next = {
|
|
9068
|
+
daily: String(payload.daily ?? ""),
|
|
9069
|
+
routines: (payload.routines ?? []).map((r) => {
|
|
9070
|
+
const title = String(r.title ?? "").trim();
|
|
9071
|
+
const id = r.id && ROUTINE_ID.test(r.id) ? r.id : routineId(title, taken);
|
|
9072
|
+
taken.push(id);
|
|
9073
|
+
return { id, title, body: String(r.body ?? ""), schedule: String(r.schedule ?? "") };
|
|
9074
|
+
})
|
|
9075
|
+
};
|
|
9076
|
+
const opsSession = join30(portal.ws.opsDir, ".github", "workflows", "session.yaml");
|
|
9077
|
+
const plan2 = planSchedule({
|
|
9078
|
+
manifest,
|
|
9079
|
+
parseYaml: parseYaml2,
|
|
9080
|
+
dir,
|
|
9081
|
+
org: orgSpec(org, portal.ws),
|
|
9082
|
+
next,
|
|
9083
|
+
current,
|
|
9084
|
+
session: existsSync2(opsSession) ? readFileSync2(opsSession, "utf8") : ""
|
|
9085
|
+
});
|
|
9086
|
+
if (plan2.errors.length) return json({ error: plan2.errors.join(". ") }, 400);
|
|
9087
|
+
if (!plan2.changes.length) return json({ ok: true, note: "no change" });
|
|
9088
|
+
const done = await commitFiles(
|
|
9089
|
+
actor.gh,
|
|
9090
|
+
`${portal.org}/${dir}`,
|
|
9091
|
+
plan2.changes,
|
|
9092
|
+
`portal: ${payload.staff}'s routines`
|
|
9093
|
+
);
|
|
9094
|
+
await portal.snapshots.refresh(actor.gh, `${portal.org}/${dir}`, { force: true });
|
|
9095
|
+
return json({ ok: true, ...done });
|
|
9096
|
+
},
|
|
8862
9097
|
"/api/run/state": async (c) => {
|
|
8863
9098
|
const { url, actor } = c;
|
|
8864
9099
|
const brain = await brainOf(c, url.searchParams.get("staff") ?? "");
|
|
@@ -8919,8 +9154,8 @@ var ROUTES = {
|
|
|
8919
9154
|
const entry = (org.staff ?? []).find((s) => s.handle === handle);
|
|
8920
9155
|
if (!entry || !KINDS.includes(kind)) return bad();
|
|
8921
9156
|
const dir = entry.dir ?? entry.handle;
|
|
8922
|
-
const view = promptView(portal.ws, compose2, handle,
|
|
8923
|
-
const manifest =
|
|
9157
|
+
const view = promptView(portal.ws, compose2, handle, join30(portal.ws.root, dir), kind);
|
|
9158
|
+
const manifest = join30(portal.ws.root, dir, "staff.yaml");
|
|
8924
9159
|
const tokens = existsSync2(manifest) ? tokensFor(
|
|
8925
9160
|
orgSpec(org, portal.ws),
|
|
8926
9161
|
specFromManifest(parseYaml2(readFileSync2(manifest, "utf8"), "staff.yaml"), dir)
|
|
@@ -8941,10 +9176,10 @@ var ROUTES = {
|
|
|
8941
9176
|
if (!entry || !KINDS.includes(kind))
|
|
8942
9177
|
return json({ error: "bad request" }, 400);
|
|
8943
9178
|
const dir = entry.dir ?? entry.handle;
|
|
8944
|
-
const view = promptView(portal.ws, compose2, entry.handle,
|
|
9179
|
+
const view = promptView(portal.ws, compose2, entry.handle, join30(portal.ws.root, dir), kind);
|
|
8945
9180
|
const targets = amendTargets(portal.ws, view, brains).map((path) => ({
|
|
8946
9181
|
path,
|
|
8947
|
-
before: existsSync2(
|
|
9182
|
+
before: existsSync2(join30(portal.ws.root, path)) ? readFileSync2(join30(portal.ws.root, path), "utf8") : ""
|
|
8948
9183
|
}));
|
|
8949
9184
|
const result = parsePaste(payload.answer ?? "", targets);
|
|
8950
9185
|
const before = new Map(targets.map((t) => [t.path, t.before]));
|
|
@@ -9413,7 +9648,7 @@ var ROUTES = {
|
|
|
9413
9648
|
const dir = s.dir ?? s.handle;
|
|
9414
9649
|
let m = {};
|
|
9415
9650
|
try {
|
|
9416
|
-
m = readManifest2(
|
|
9651
|
+
m = readManifest2(join30(portal.ws.root, dir), parseYaml2);
|
|
9417
9652
|
} catch {
|
|
9418
9653
|
}
|
|
9419
9654
|
return {
|
|
@@ -9561,12 +9796,12 @@ ${diff}`,
|
|
|
9561
9796
|
await ready(c, { products: true });
|
|
9562
9797
|
const rel = url.searchParams.get("path") ?? "";
|
|
9563
9798
|
const full = resolve5(portal.ws.root, rel);
|
|
9564
|
-
if (!
|
|
9799
|
+
if (!inside(resolve5(portal.ws.root), full) || !existsSync2(full)) return notFound();
|
|
9565
9800
|
const st = statSync2(full);
|
|
9566
9801
|
if (st.isDirectory()) return notFound();
|
|
9567
|
-
const
|
|
9568
|
-
const dir =
|
|
9569
|
-
const path =
|
|
9802
|
+
const within = posix(relative5(resolve5(portal.ws.root), full));
|
|
9803
|
+
const dir = within.slice(0, within.indexOf("/"));
|
|
9804
|
+
const path = within.slice(dir.length + 1);
|
|
9570
9805
|
const type = MIME[extOf(path)] ?? "application/octet-stream";
|
|
9571
9806
|
let bytes2;
|
|
9572
9807
|
try {
|
|
@@ -9626,7 +9861,7 @@ async function orgExport(c, report4) {
|
|
|
9626
9861
|
const snap = portal.snapshots.get(repo);
|
|
9627
9862
|
if (!snap) return;
|
|
9628
9863
|
report4?.(repo, "reading recent history");
|
|
9629
|
-
byRoot.set(
|
|
9864
|
+
byRoot.set(join30(portal.ws.root, dir), await loadHistory(actor.gh, portal.kv, repo, snap.sha));
|
|
9630
9865
|
report4?.(repo, "ready");
|
|
9631
9866
|
})
|
|
9632
9867
|
);
|
|
@@ -9649,7 +9884,7 @@ async function brainOf(c, handle) {
|
|
|
9649
9884
|
const entry = (org.staff ?? []).find((x) => x.handle === handle);
|
|
9650
9885
|
if (!entry) throw new HttpError(400, `no staff member "${handle}"`);
|
|
9651
9886
|
const dir = entry.dir ?? entry.handle;
|
|
9652
|
-
return specFromManifest(readManifest2(
|
|
9887
|
+
return specFromManifest(readManifest2(join30(c.portal.ws.root, dir), parseYaml2), dir).brain;
|
|
9653
9888
|
}
|
|
9654
9889
|
function amendTargets(ws, view, brains) {
|
|
9655
9890
|
return [
|
|
@@ -9658,6 +9893,82 @@ function amendTargets(ws, view, brains) {
|
|
|
9658
9893
|
)
|
|
9659
9894
|
];
|
|
9660
9895
|
}
|
|
9896
|
+
async function schedules(c, opts = {}) {
|
|
9897
|
+
const { org } = await ready(c, opts);
|
|
9898
|
+
return (org.staff ?? []).map((s) => {
|
|
9899
|
+
const dir = String(s.dir ?? s.handle);
|
|
9900
|
+
const root2 = join30(c.portal.ws.root, dir);
|
|
9901
|
+
const path = join30(root2, "staff.yaml");
|
|
9902
|
+
const manifest = existsSync2(path) ? parseYaml2(readFileSync2(path, "utf8"), "staff.yaml") : {};
|
|
9903
|
+
const schedule = readSchedule(
|
|
9904
|
+
manifest,
|
|
9905
|
+
(rel) => existsSync2(join30(root2, rel)) ? readFileSync2(join30(root2, rel), "utf8") : void 0
|
|
9906
|
+
);
|
|
9907
|
+
return {
|
|
9908
|
+
handle: String(s.handle),
|
|
9909
|
+
name: String(s.name ?? s.handle),
|
|
9910
|
+
daily: schedule.daily,
|
|
9911
|
+
dailyWhen: describeCron(schedule.daily),
|
|
9912
|
+
routines: schedule.routines.map((r) => ({ ...r, when: describeCron(r.schedule) }))
|
|
9913
|
+
};
|
|
9914
|
+
});
|
|
9915
|
+
}
|
|
9916
|
+
async function commitFiles(gh, repo, changes, message2) {
|
|
9917
|
+
const fail = (what, error) => {
|
|
9918
|
+
if (/workflow/i.test(error ?? "")) {
|
|
9919
|
+
throw new HttpError(
|
|
9920
|
+
403,
|
|
9921
|
+
"GitHub refused to change the workflow that runs routines. Sign out of the portal and sign in again to grant it."
|
|
9922
|
+
);
|
|
9923
|
+
}
|
|
9924
|
+
throw new HttpError(400, `${what} failed: ${error}`);
|
|
9925
|
+
};
|
|
9926
|
+
const info = await gh.request("GET", `repos/${repo}`);
|
|
9927
|
+
if (!info.ok) fail("reading the repo", info.error);
|
|
9928
|
+
const branch = info.data.default_branch;
|
|
9929
|
+
const ref = await gh.request(
|
|
9930
|
+
"GET",
|
|
9931
|
+
`repos/${repo}/git/ref/heads/${encodePath(branch)}`
|
|
9932
|
+
);
|
|
9933
|
+
if (!ref.ok) fail("reading the branch", ref.error);
|
|
9934
|
+
const parent = ref.data.object.sha;
|
|
9935
|
+
const head2 = await gh.request(
|
|
9936
|
+
"GET",
|
|
9937
|
+
`repos/${repo}/git/commits/${parent}`
|
|
9938
|
+
);
|
|
9939
|
+
if (!head2.ok) fail("reading the commit", head2.error);
|
|
9940
|
+
const tree = await gh.request("POST", `repos/${repo}/git/trees`, {
|
|
9941
|
+
body: {
|
|
9942
|
+
base_tree: head2.data.tree.sha,
|
|
9943
|
+
tree: changes.map(
|
|
9944
|
+
(c) => c.text === null ? { path: c.path, mode: "100644", type: "blob", sha: null } : { path: c.path, mode: "100644", type: "blob", content: c.text }
|
|
9945
|
+
)
|
|
9946
|
+
}
|
|
9947
|
+
});
|
|
9948
|
+
if (!tree.ok) fail("writing the files", tree.error);
|
|
9949
|
+
const commit2 = await gh.request("POST", `repos/${repo}/git/commits`, {
|
|
9950
|
+
body: { message: message2, tree: tree.data.sha, parents: [parent] }
|
|
9951
|
+
});
|
|
9952
|
+
if (!commit2.ok) fail("making the commit", commit2.error);
|
|
9953
|
+
const moved = await gh.request("PATCH", `repos/${repo}/git/refs/heads/${encodePath(branch)}`, {
|
|
9954
|
+
body: { sha: commit2.data.sha, force: false }
|
|
9955
|
+
});
|
|
9956
|
+
if (!moved.ok) {
|
|
9957
|
+
if (moved.status === 422 && !/workflow/i.test(moved.error ?? "")) {
|
|
9958
|
+
throw new HttpError(
|
|
9959
|
+
409,
|
|
9960
|
+
`${repo} changed on GitHub since this page read it. Reload, then save again.`
|
|
9961
|
+
);
|
|
9962
|
+
}
|
|
9963
|
+
fail("moving the branch", moved.error);
|
|
9964
|
+
}
|
|
9965
|
+
return {
|
|
9966
|
+
committed: true,
|
|
9967
|
+
pushed: true,
|
|
9968
|
+
sha: commit2.data.sha.slice(0, 7),
|
|
9969
|
+
files: changes.length
|
|
9970
|
+
};
|
|
9971
|
+
}
|
|
9661
9972
|
async function commitFile(portal, gh, dir, path, body2, message2, base2) {
|
|
9662
9973
|
const repo = `${portal.org}/${dir}`;
|
|
9663
9974
|
const snap = portal.snapshots.get(repo);
|
|
@@ -9878,11 +10189,11 @@ function layeredKV(slow, fast = memoryKV()) {
|
|
|
9878
10189
|
import { createHash } from "crypto";
|
|
9879
10190
|
import { existsSync as existsSync13, mkdirSync as mkdirSync7, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "fs";
|
|
9880
10191
|
import { homedir } from "os";
|
|
9881
|
-
import { join as
|
|
10192
|
+
import { join as join31 } from "path";
|
|
9882
10193
|
function diskKV(dir = defaultDir()) {
|
|
9883
10194
|
const path = (key2) => {
|
|
9884
10195
|
const h = createHash("sha1").update(key2).digest("hex");
|
|
9885
|
-
return
|
|
10196
|
+
return join31(dir, h.slice(0, 2), h.slice(2));
|
|
9886
10197
|
};
|
|
9887
10198
|
return {
|
|
9888
10199
|
async get(key2) {
|
|
@@ -9891,18 +10202,18 @@ function diskKV(dir = defaultDir()) {
|
|
|
9891
10202
|
},
|
|
9892
10203
|
async put(key2, value) {
|
|
9893
10204
|
const p = path(key2);
|
|
9894
|
-
mkdirSync7(
|
|
10205
|
+
mkdirSync7(join31(p, ".."), { recursive: true });
|
|
9895
10206
|
writeFileSync11(p, value);
|
|
9896
10207
|
}
|
|
9897
10208
|
};
|
|
9898
10209
|
}
|
|
9899
10210
|
function defaultDir() {
|
|
9900
|
-
return
|
|
10211
|
+
return join31(process.env.ROSTER_CACHE_DIR ?? join31(homedir(), ".cache", "roster"), "kv");
|
|
9901
10212
|
}
|
|
9902
10213
|
|
|
9903
10214
|
// src/commands/retire.ts
|
|
9904
10215
|
import { existsSync as existsSync14, readdirSync as readdirSync6, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "fs";
|
|
9905
|
-
import { join as
|
|
10216
|
+
import { join as join32 } from "path";
|
|
9906
10217
|
var retireHelp = `
|
|
9907
10218
|
roster retire <handle>
|
|
9908
10219
|
|
|
@@ -9953,23 +10264,23 @@ async function retireCommand(argv) {
|
|
|
9953
10264
|
function buildRetirePlan(ws, org, handle, parseYaml3) {
|
|
9954
10265
|
const entry = (org.staff ?? []).find((s) => s.handle === handle);
|
|
9955
10266
|
const dir = entry.dir ?? entry.handle;
|
|
9956
|
-
const root2 =
|
|
10267
|
+
const root2 = join32(ws.root, dir);
|
|
9957
10268
|
const warnings = [];
|
|
9958
10269
|
const manifest = readManifest3(root2, parseYaml3);
|
|
9959
10270
|
const brain = manifest?.brain;
|
|
9960
10271
|
if (!existsSync14(root2)) warnings.push(`${dir}/ is not checked out, so its files cannot be read`);
|
|
9961
|
-
const wfDir =
|
|
10272
|
+
const wfDir = join32(root2, ".github", "workflows");
|
|
9962
10273
|
const workflows = existsSync14(wfDir) ? readdirSync6(wfDir).filter((f) => /\.ya?ml$/.test(f)).sort() : [];
|
|
9963
10274
|
if (!workflows.length) warnings.push("no workflows found, so nothing to disable");
|
|
9964
10275
|
const peers = [];
|
|
9965
10276
|
for (const other of org.staff ?? []) {
|
|
9966
10277
|
if (other.handle === handle) continue;
|
|
9967
10278
|
const otherDir = other.dir ?? other.handle;
|
|
9968
|
-
const path =
|
|
10279
|
+
const path = join32(ws.root, otherDir, "staff.yaml");
|
|
9969
10280
|
if (!existsSync14(path)) continue;
|
|
9970
10281
|
const text2 = readFileSync13(path, "utf8");
|
|
9971
10282
|
if (!new RegExp(`handle: ${handle}[,\\s}]`).test(text2)) continue;
|
|
9972
|
-
const theirs = readManifest3(
|
|
10283
|
+
const theirs = readManifest3(join32(ws.root, otherDir), parseYaml3);
|
|
9973
10284
|
peers.push({
|
|
9974
10285
|
handle: other.handle,
|
|
9975
10286
|
dir: otherDir,
|
|
@@ -9977,7 +10288,7 @@ function buildRetirePlan(ws, org, handle, parseYaml3) {
|
|
|
9977
10288
|
label: `from-${handle}`
|
|
9978
10289
|
});
|
|
9979
10290
|
}
|
|
9980
|
-
const
|
|
10291
|
+
const facts2 = countFacts(join32(root2, "memory", "INDEX.md"));
|
|
9981
10292
|
return {
|
|
9982
10293
|
handle,
|
|
9983
10294
|
name: entry.name ?? handle,
|
|
@@ -9987,7 +10298,7 @@ function buildRetirePlan(ws, org, handle, parseYaml3) {
|
|
|
9987
10298
|
peers,
|
|
9988
10299
|
keeps: [
|
|
9989
10300
|
brain ? `${brain} \u2014 the repo, untouched` : `${dir}/ \u2014 the repo, untouched`,
|
|
9990
|
-
|
|
10301
|
+
facts2 ? `${facts2} facts and everything in memory/notes/` : "their memory, whatever is in it",
|
|
9991
10302
|
"their issues, open and closed, and their pinned status issue"
|
|
9992
10303
|
],
|
|
9993
10304
|
warnings
|
|
@@ -10035,7 +10346,7 @@ async function applyRetirePlan(ws, plan2) {
|
|
|
10035
10346
|
removeFromOrgYaml(ws, plan2);
|
|
10036
10347
|
process.stdout.write(" removed from org.yaml\n");
|
|
10037
10348
|
for (const p of plan2.peers) {
|
|
10038
|
-
const path =
|
|
10349
|
+
const path = join32(ws.root, p.dir, "staff.yaml");
|
|
10039
10350
|
const text2 = readFileSync13(path, "utf8");
|
|
10040
10351
|
writeFileSync12(path, removePeerLine(text2, plan2.handle));
|
|
10041
10352
|
process.stdout.write(` removed from ${p.dir}/staff.yaml
|
|
@@ -10063,7 +10374,7 @@ async function applyRetirePlan(ws, plan2) {
|
|
|
10063
10374
|
return failed ? 1 : 0;
|
|
10064
10375
|
}
|
|
10065
10376
|
function removeFromOrgYaml(ws, plan2) {
|
|
10066
|
-
const path =
|
|
10377
|
+
const path = join32(ws.opsDir, "org.yaml");
|
|
10067
10378
|
const text2 = readFileSync13(path, "utf8");
|
|
10068
10379
|
writeFileSync12(path, removeOrgLines(text2, plan2.handle, plan2.dir));
|
|
10069
10380
|
}
|
|
@@ -10083,7 +10394,7 @@ function removePeerLine(text2, handle) {
|
|
|
10083
10394
|
}).join("\n");
|
|
10084
10395
|
}
|
|
10085
10396
|
function readManifest3(root2, parseYaml3) {
|
|
10086
|
-
const path =
|
|
10397
|
+
const path = join32(root2, "staff.yaml");
|
|
10087
10398
|
if (!existsSync14(path)) return null;
|
|
10088
10399
|
try {
|
|
10089
10400
|
return parseYaml3(readFileSync13(path, "utf8"), "staff.yaml");
|
|
@@ -10241,7 +10552,7 @@ async function portalCommand(argv) {
|
|
|
10241
10552
|
}
|
|
10242
10553
|
const dir = entry.dir ?? entry.handle;
|
|
10243
10554
|
const spec2 = specFromManifest(
|
|
10244
|
-
parseYaml3(readFileSync14(
|
|
10555
|
+
parseYaml3(readFileSync14(join33(ws.root, dir, "staff.yaml"), "utf8"), "staff.yaml"),
|
|
10245
10556
|
dir
|
|
10246
10557
|
);
|
|
10247
10558
|
const isPublic = payload.scope === "public";
|
|
@@ -10424,7 +10735,7 @@ async function portalCommand(argv) {
|
|
|
10424
10735
|
res.end(JSON.stringify({ error: "a repo name and a known role are needed" }));
|
|
10425
10736
|
return;
|
|
10426
10737
|
}
|
|
10427
|
-
const path =
|
|
10738
|
+
const path = join33(ws.opsDir, "org.yaml");
|
|
10428
10739
|
const text2 = readFileSync14(path, "utf8");
|
|
10429
10740
|
if (new RegExp(`name: ${name}[,\\s}]`).test(text2)) {
|
|
10430
10741
|
json2(res, { ok: true, note: "already there" });
|
|
@@ -10466,7 +10777,7 @@ async function portalCommand(argv) {
|
|
|
10466
10777
|
if (route === "plan") {
|
|
10467
10778
|
json2(res, {
|
|
10468
10779
|
org,
|
|
10469
|
-
dir:
|
|
10780
|
+
dir: join33(startedIn, "roster-ops"),
|
|
10470
10781
|
files: [
|
|
10471
10782
|
...(await initFiles({
|
|
10472
10783
|
org,
|
|
@@ -10497,13 +10808,13 @@ async function portalCommand(argv) {
|
|
|
10497
10808
|
}
|
|
10498
10809
|
res.writeHead(404).end("not found");
|
|
10499
10810
|
};
|
|
10500
|
-
const body2 = (req, limit = 1e6) => new Promise((
|
|
10811
|
+
const body2 = (req, limit = 1e6) => new Promise((resolve8, reject) => {
|
|
10501
10812
|
let buf = "";
|
|
10502
10813
|
req.on("data", (c) => {
|
|
10503
10814
|
buf += c;
|
|
10504
10815
|
if (buf.length > limit) reject(new Error("body too large"));
|
|
10505
10816
|
});
|
|
10506
|
-
req.on("end", () =>
|
|
10817
|
+
req.on("end", () => resolve8(buf));
|
|
10507
10818
|
req.on("error", reject);
|
|
10508
10819
|
});
|
|
10509
10820
|
const server = createServer2((req, res) => {
|
|
@@ -10794,7 +11105,7 @@ function parseFlags13(argv) {
|
|
|
10794
11105
|
return out;
|
|
10795
11106
|
}
|
|
10796
11107
|
function bytes(req) {
|
|
10797
|
-
return new Promise((
|
|
11108
|
+
return new Promise((resolve8, reject) => {
|
|
10798
11109
|
const chunks = [];
|
|
10799
11110
|
let size2 = 0;
|
|
10800
11111
|
req.on("data", (c) => {
|
|
@@ -10802,7 +11113,7 @@ function bytes(req) {
|
|
|
10802
11113
|
if (size2 > Math.ceil(MAX_UPLOAD * 1.4) + 1e6) reject(new Error("body too large"));
|
|
10803
11114
|
else chunks.push(c);
|
|
10804
11115
|
});
|
|
10805
|
-
req.on("end", () =>
|
|
11116
|
+
req.on("end", () => resolve8(Buffer.concat(chunks)));
|
|
10806
11117
|
req.on("error", reject);
|
|
10807
11118
|
});
|
|
10808
11119
|
}
|
|
@@ -10815,7 +11126,8 @@ function signedOut(error) {
|
|
|
10815
11126
|
import { execFileSync as execFileSync9 } from "child_process";
|
|
10816
11127
|
import { existsSync as existsSync15, mkdtempSync as mkdtempSync5, readFileSync as readFileSync16, writeFileSync as writeFileSync13 } from "fs";
|
|
10817
11128
|
import { tmpdir as tmpdir5 } from "os";
|
|
10818
|
-
import { join as
|
|
11129
|
+
import { join as join34 } from "path";
|
|
11130
|
+
import { pathToFileURL as pathToFileURL5 } from "url";
|
|
10819
11131
|
|
|
10820
11132
|
// src/lib/livePrompt.ts
|
|
10821
11133
|
import { readFileSync as readFileSync15 } from "fs";
|
|
@@ -10880,10 +11192,10 @@ async function promptCommand(argv) {
|
|
|
10880
11192
|
process.stdout.write(composed);
|
|
10881
11193
|
return 0;
|
|
10882
11194
|
}
|
|
10883
|
-
const live = extractLivePrompt(
|
|
10884
|
-
const dir = mkdtempSync5(
|
|
10885
|
-
const a =
|
|
10886
|
-
const b =
|
|
11195
|
+
const live = extractLivePrompt(join34(ws.root, opts.diff));
|
|
11196
|
+
const dir = mkdtempSync5(join34(tmpdir5(), "roster-diff-"));
|
|
11197
|
+
const a = join34(dir, "live.md");
|
|
11198
|
+
const b = join34(dir, "composed.md");
|
|
10887
11199
|
writeFileSync13(a, normalise(live));
|
|
10888
11200
|
writeFileSync13(b, normalise(composed));
|
|
10889
11201
|
const entry = org.staff?.find((s) => s.handle === handle);
|
|
@@ -10909,19 +11221,19 @@ async function promptCommand(argv) {
|
|
|
10909
11221
|
}
|
|
10910
11222
|
}
|
|
10911
11223
|
async function gatherInflight(opsDir, root2, handle) {
|
|
10912
|
-
const path =
|
|
11224
|
+
const path = join34(opsDir, "inflight.mjs");
|
|
10913
11225
|
if (!existsSync15(path)) {
|
|
10914
11226
|
throw new Error("this tenant has no inflight.mjs yet. Run `roster upgrade --apply` first.");
|
|
10915
11227
|
}
|
|
10916
|
-
const { describe: describe2, gather: gather2 } = await import(
|
|
11228
|
+
const { describe: describe2, gather: gather2 } = await import(pathToFileURL5(path).href);
|
|
10917
11229
|
const { parseYaml: parseYaml3 } = await loadComposer(opsDir);
|
|
10918
11230
|
const org = readOrg(opsDir, parseYaml3);
|
|
10919
11231
|
const entry = org.staff?.find((s) => s.handle === handle);
|
|
10920
|
-
const manifestPath =
|
|
11232
|
+
const manifestPath = join34(root2, entry?.dir ?? handle, "staff.yaml");
|
|
10921
11233
|
const manifest = existsSync15(manifestPath) ? parseYaml3(readFileSync16(manifestPath, "utf8"), "staff.yaml") : {};
|
|
10922
11234
|
const gh = (args) => execFileSync9("gh", args, { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
|
|
10923
|
-
const dir = mkdtempSync5(
|
|
10924
|
-
writeFileSync13(
|
|
11235
|
+
const dir = mkdtempSync5(join34(tmpdir5(), "roster-inflight-"));
|
|
11236
|
+
writeFileSync13(join34(dir, "inflight.md"), describe2(gather2({ org, manifest, gh })));
|
|
10925
11237
|
return dir;
|
|
10926
11238
|
}
|
|
10927
11239
|
function normalise(text2) {
|
|
@@ -10949,9 +11261,214 @@ function parseFlags14(argv) {
|
|
|
10949
11261
|
return out;
|
|
10950
11262
|
}
|
|
10951
11263
|
|
|
11264
|
+
// src/commands/routine.ts
|
|
11265
|
+
import { execFileSync as execFileSync10 } from "child_process";
|
|
11266
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync8, readFileSync as readFileSync17, rmSync as rmSync5, writeFileSync as writeFileSync14 } from "fs";
|
|
11267
|
+
import { dirname as dirname10, join as join35 } from "path";
|
|
11268
|
+
var routineHelp = `
|
|
11269
|
+
roster routine <handle> list their daily round and routines
|
|
11270
|
+
roster routine <handle> add --name <n> --at <cron> --do <text> [--apply]
|
|
11271
|
+
roster routine <handle> remove <id> [--apply]
|
|
11272
|
+
roster routine <handle> daily <cron> [--apply]
|
|
11273
|
+
roster routine <handle> run <id>
|
|
11274
|
+
|
|
11275
|
+
Routines are the times a staff member wakes beyond the daily round, each with its own job:
|
|
11276
|
+
"every Monday at 09:00, plan the week", "on the 1st, write the month's report". The time
|
|
11277
|
+
goes in staff.yaml, what to do in routines/<id>.md, and both are compiled into the daily
|
|
11278
|
+
caller's schedule, so a routine costs nothing between runs.
|
|
11279
|
+
|
|
11280
|
+
Times are five-field cron, in UTC: "0 9 * * 1" is Mondays at 09:00. The portal's Routines
|
|
11281
|
+
screen writes the same files with a picker.
|
|
11282
|
+
|
|
11283
|
+
Nothing changes without --apply. With it, the brain repo is committed and pushed as you.
|
|
11284
|
+
|
|
11285
|
+
--name <text> what the routine is called
|
|
11286
|
+
--at <cron> when it runs, UTC
|
|
11287
|
+
--do <text> what to do, in your words. --do-file <path> reads it from a file.
|
|
11288
|
+
--apply write, commit and push
|
|
11289
|
+
--ops <dir> ops repo directory (default: found by walking up)
|
|
11290
|
+
`;
|
|
11291
|
+
async function routineCommand(argv) {
|
|
11292
|
+
const [handle, action = "list", ...rest] = argv.filter((a, i) => !(i === 0 && a.startsWith("-")));
|
|
11293
|
+
if (!handle || handle.startsWith("-")) {
|
|
11294
|
+
process.stderr.write(routineHelp);
|
|
11295
|
+
return 2;
|
|
11296
|
+
}
|
|
11297
|
+
const opts = parseFlags15(rest);
|
|
11298
|
+
const ws = findWorkspace(opts.ops);
|
|
11299
|
+
const { parseYaml: parseYaml3 } = await loadComposer(ws.opsDir);
|
|
11300
|
+
const org = readOrg(ws.opsDir, parseYaml3);
|
|
11301
|
+
const entry = (org.staff ?? []).find((s) => s.handle === handle);
|
|
11302
|
+
if (!entry) {
|
|
11303
|
+
process.stderr.write(`roster: no staff member "${handle}" in org.yaml
|
|
11304
|
+
`);
|
|
11305
|
+
return 2;
|
|
11306
|
+
}
|
|
11307
|
+
const dir = entry.dir ?? entry.handle;
|
|
11308
|
+
const root2 = join35(ws.root, dir);
|
|
11309
|
+
const manifestPath = join35(root2, "staff.yaml");
|
|
11310
|
+
if (!existsSync16(manifestPath)) {
|
|
11311
|
+
process.stderr.write(`roster: ${dir}/ is not checked out here
|
|
11312
|
+
`);
|
|
11313
|
+
return 1;
|
|
11314
|
+
}
|
|
11315
|
+
const manifestText = readFileSync17(manifestPath, "utf8");
|
|
11316
|
+
const current = (rel) => existsSync16(join35(root2, rel)) ? readFileSync17(join35(root2, rel), "utf8") : void 0;
|
|
11317
|
+
const now = readSchedule(parseYaml3(manifestText, "staff.yaml"), current);
|
|
11318
|
+
if (action === "list") {
|
|
11319
|
+
process.stdout.write(`
|
|
11320
|
+
${handle}
|
|
11321
|
+
|
|
11322
|
+
${describeCron(now.daily)} daily round
|
|
11323
|
+
`);
|
|
11324
|
+
for (const r of now.routines) {
|
|
11325
|
+
process.stdout.write(` ${describeCron(r.schedule)} ${r.title} (${r.id})
|
|
11326
|
+
`);
|
|
11327
|
+
}
|
|
11328
|
+
if (!now.routines.length) process.stdout.write(" no routines yet\n");
|
|
11329
|
+
process.stdout.write("\n");
|
|
11330
|
+
return 0;
|
|
11331
|
+
}
|
|
11332
|
+
if (action === "run") {
|
|
11333
|
+
const id = opts.positional[0];
|
|
11334
|
+
if (!id || !now.routines.some((r) => r.id === id)) {
|
|
11335
|
+
process.stderr.write(`roster: ${handle} has no routine "${id ?? ""}"
|
|
11336
|
+
`);
|
|
11337
|
+
return 2;
|
|
11338
|
+
}
|
|
11339
|
+
execFileSync10(
|
|
11340
|
+
"gh",
|
|
11341
|
+
["workflow", "run", `${handle}-daily.yaml`, "-R", `${org.org}/${dir}`, "-f", `routine=${id}`],
|
|
11342
|
+
{ stdio: "inherit" }
|
|
11343
|
+
);
|
|
11344
|
+
process.stdout.write(
|
|
11345
|
+
` started ${id}. It shows in the portal and in ${dir}'s Actions as "${handle} routine ${id}".
|
|
11346
|
+
`
|
|
11347
|
+
);
|
|
11348
|
+
return 0;
|
|
11349
|
+
}
|
|
11350
|
+
let next;
|
|
11351
|
+
let message2;
|
|
11352
|
+
if (action === "add") {
|
|
11353
|
+
const body2 = opts.doFile ? readFileSync17(opts.doFile, "utf8") : opts.do;
|
|
11354
|
+
if (!opts.name || !opts.at || !body2) {
|
|
11355
|
+
process.stderr.write("roster: add needs --name, --at and --do (or --do-file)\n");
|
|
11356
|
+
return 2;
|
|
11357
|
+
}
|
|
11358
|
+
const id = routineId(
|
|
11359
|
+
opts.name,
|
|
11360
|
+
now.routines.map((r) => r.id)
|
|
11361
|
+
);
|
|
11362
|
+
next = {
|
|
11363
|
+
...now,
|
|
11364
|
+
routines: [...now.routines, { id, title: opts.name, body: body2, schedule: opts.at }]
|
|
11365
|
+
};
|
|
11366
|
+
message2 = `routines: ${opts.name}, ${describeCron(opts.at)}`;
|
|
11367
|
+
} else if (action === "remove") {
|
|
11368
|
+
const id = opts.positional[0];
|
|
11369
|
+
if (!id || !now.routines.some((r) => r.id === id)) {
|
|
11370
|
+
process.stderr.write(`roster: ${handle} has no routine "${id ?? ""}"
|
|
11371
|
+
`);
|
|
11372
|
+
return 2;
|
|
11373
|
+
}
|
|
11374
|
+
next = { ...now, routines: now.routines.filter((r) => r.id !== id) };
|
|
11375
|
+
message2 = `routines: remove ${id}`;
|
|
11376
|
+
} else if (action === "daily") {
|
|
11377
|
+
const cron = opts.positional[0];
|
|
11378
|
+
if (!cron || !validCron(cron)) {
|
|
11379
|
+
process.stderr.write(`roster: daily needs a cron, e.g. "0 8 * * 1-5"
|
|
11380
|
+
`);
|
|
11381
|
+
return 2;
|
|
11382
|
+
}
|
|
11383
|
+
next = { ...now, daily: cron };
|
|
11384
|
+
message2 = `routines: daily round ${describeCron(cron)}`;
|
|
11385
|
+
} else {
|
|
11386
|
+
process.stderr.write(routineHelp);
|
|
11387
|
+
return 2;
|
|
11388
|
+
}
|
|
11389
|
+
const session = readFileSync17(join35(ws.opsDir, ".github", "workflows", "session.yaml"), "utf8");
|
|
11390
|
+
const plan2 = planSchedule({
|
|
11391
|
+
manifest: manifestText,
|
|
11392
|
+
parseYaml: parseYaml3,
|
|
11393
|
+
dir,
|
|
11394
|
+
org: orgSpecOf(org, ws.opsName),
|
|
11395
|
+
next,
|
|
11396
|
+
current,
|
|
11397
|
+
session
|
|
11398
|
+
});
|
|
11399
|
+
if (plan2.errors.length) {
|
|
11400
|
+
for (const e of plan2.errors) process.stderr.write(`roster: ${e}
|
|
11401
|
+
`);
|
|
11402
|
+
return 1;
|
|
11403
|
+
}
|
|
11404
|
+
process.stdout.write(`
|
|
11405
|
+
${message2}
|
|
11406
|
+
|
|
11407
|
+
`);
|
|
11408
|
+
for (const c of plan2.changes) {
|
|
11409
|
+
process.stdout.write(
|
|
11410
|
+
` ${c.text === null ? "delete" : existsSync16(join35(root2, c.path)) ? "update" : "create"} ${dir}/${c.path}
|
|
11411
|
+
`
|
|
11412
|
+
);
|
|
11413
|
+
}
|
|
11414
|
+
if (!opts.apply) {
|
|
11415
|
+
process.stdout.write("\n Nothing was written. Re-run with --apply.\n\n");
|
|
11416
|
+
return 0;
|
|
11417
|
+
}
|
|
11418
|
+
for (const c of plan2.changes) {
|
|
11419
|
+
const full = join35(root2, c.path);
|
|
11420
|
+
if (c.text === null) rmSync5(full, { force: true });
|
|
11421
|
+
else {
|
|
11422
|
+
mkdirSync8(dirname10(full), { recursive: true });
|
|
11423
|
+
writeFileSync14(full, c.text);
|
|
11424
|
+
}
|
|
11425
|
+
}
|
|
11426
|
+
const done = commitAndPush(
|
|
11427
|
+
root2,
|
|
11428
|
+
plan2.changes.map((c) => c.path),
|
|
11429
|
+
message2
|
|
11430
|
+
);
|
|
11431
|
+
process.stdout.write(
|
|
11432
|
+
done.pushed ? `
|
|
11433
|
+
committed and pushed ${dir} (${done.sha})
|
|
11434
|
+
|
|
11435
|
+
` : `
|
|
11436
|
+
${done.committed ? `committed ${done.sha}; push failed: ` : "not committed: "}${done.note}
|
|
11437
|
+
|
|
11438
|
+
`
|
|
11439
|
+
);
|
|
11440
|
+
return done.committed || done.note === "nothing to commit" ? 0 : 1;
|
|
11441
|
+
}
|
|
11442
|
+
function orgSpecOf(org, opsName) {
|
|
11443
|
+
return {
|
|
11444
|
+
org: org.org,
|
|
11445
|
+
name: org.name,
|
|
11446
|
+
opsRepo: `${org.org}/${opsName}`,
|
|
11447
|
+
opsDirName: opsName,
|
|
11448
|
+
human: "",
|
|
11449
|
+
humanMarker: "human",
|
|
11450
|
+
humanLogins: humanLogins(org),
|
|
11451
|
+
allowedTools: toolsOf(org)
|
|
11452
|
+
};
|
|
11453
|
+
}
|
|
11454
|
+
function parseFlags15(argv) {
|
|
11455
|
+
const out = { positional: [] };
|
|
11456
|
+
for (let i = 0; i < argv.length; i++) {
|
|
11457
|
+
const a = argv[i];
|
|
11458
|
+
if (a === "--name") out.name = argv[++i];
|
|
11459
|
+
else if (a === "--at") out.at = argv[++i];
|
|
11460
|
+
else if (a === "--do") out.do = argv[++i];
|
|
11461
|
+
else if (a === "--do-file") out.doFile = argv[++i];
|
|
11462
|
+
else if (a === "--apply") out.apply = true;
|
|
11463
|
+
else if (a === "--ops") out.ops = argv[++i];
|
|
11464
|
+
else out.positional.push(a);
|
|
11465
|
+
}
|
|
11466
|
+
return out;
|
|
11467
|
+
}
|
|
11468
|
+
|
|
10952
11469
|
// src/commands/run.ts
|
|
10953
|
-
import { existsSync as
|
|
10954
|
-
import { join as
|
|
11470
|
+
import { existsSync as existsSync17, readFileSync as readFileSync18 } from "fs";
|
|
11471
|
+
import { join as join36 } from "path";
|
|
10955
11472
|
var runHelp = `
|
|
10956
11473
|
roster run <handle> [--no-wait] [--apply]
|
|
10957
11474
|
|
|
@@ -10976,7 +11493,7 @@ async function runCommand(argv) {
|
|
|
10976
11493
|
process.stderr.write("roster: run needs a staff handle, e.g. `roster run cto`\n");
|
|
10977
11494
|
return 2;
|
|
10978
11495
|
}
|
|
10979
|
-
const opts =
|
|
11496
|
+
const opts = parseFlags16(argv.slice(1));
|
|
10980
11497
|
const ws = findWorkspace(opts.ops);
|
|
10981
11498
|
const { parseYaml: parseYaml3 } = await loadComposer(ws.opsDir);
|
|
10982
11499
|
const org = readOrg(ws.opsDir, parseYaml3);
|
|
@@ -10987,14 +11504,14 @@ async function runCommand(argv) {
|
|
|
10987
11504
|
return 2;
|
|
10988
11505
|
}
|
|
10989
11506
|
const dir = entry.dir ?? entry.handle;
|
|
10990
|
-
const manifestPath =
|
|
10991
|
-
if (!
|
|
11507
|
+
const manifestPath = join36(ws.root, dir, "staff.yaml");
|
|
11508
|
+
if (!existsSync17(manifestPath)) {
|
|
10992
11509
|
process.stderr.write(`roster: ${dir}/staff.yaml is missing
|
|
10993
11510
|
`);
|
|
10994
11511
|
return 2;
|
|
10995
11512
|
}
|
|
10996
11513
|
const spec2 = specFromManifest(
|
|
10997
|
-
parseYaml3(
|
|
11514
|
+
parseYaml3(readFileSync18(manifestPath, "utf8"), "staff.yaml"),
|
|
10998
11515
|
dir
|
|
10999
11516
|
);
|
|
11000
11517
|
const workflow = dailyWorkflow(handle);
|
|
@@ -11025,8 +11542,8 @@ async function runCommand(argv) {
|
|
|
11025
11542
|
`);
|
|
11026
11543
|
return 1;
|
|
11027
11544
|
}
|
|
11028
|
-
const
|
|
11029
|
-
if (!
|
|
11545
|
+
const run3 = await findDispatched(gh, spec2.brain, workflow, since);
|
|
11546
|
+
if (!run3) {
|
|
11030
11547
|
process.stdout.write(
|
|
11031
11548
|
` started, but the run did not appear in time. Watch it at
|
|
11032
11549
|
https://github.com/${spec2.brain}/actions/workflows/${workflow}
|
|
@@ -11035,19 +11552,19 @@ async function runCommand(argv) {
|
|
|
11035
11552
|
);
|
|
11036
11553
|
return 0;
|
|
11037
11554
|
}
|
|
11038
|
-
process.stdout.write(` started: ${
|
|
11555
|
+
process.stdout.write(` started: ${run3.url}
|
|
11039
11556
|
`);
|
|
11040
11557
|
if (opts.noWait) {
|
|
11041
11558
|
process.stdout.write("\n");
|
|
11042
11559
|
return 0;
|
|
11043
11560
|
}
|
|
11044
|
-
const outcome = await follow(gh, spec2.brain,
|
|
11561
|
+
const outcome = await follow(gh, spec2.brain, run3.databaseId, {
|
|
11045
11562
|
timeoutMs: (spec2.timeout + 15) * 6e4,
|
|
11046
11563
|
onChange: (status) => process.stdout.write(` ${(/* @__PURE__ */ new Date()).toISOString().slice(11, 19)} ${status}
|
|
11047
11564
|
`)
|
|
11048
11565
|
});
|
|
11049
11566
|
if (!outcome) {
|
|
11050
|
-
process.stdout.write(` still going after the ceiling. The log: ${
|
|
11567
|
+
process.stdout.write(` still going after the ceiling. The log: ${run3.url}
|
|
11051
11568
|
|
|
11052
11569
|
`);
|
|
11053
11570
|
return 1;
|
|
@@ -11073,7 +11590,7 @@ async function runCommand(argv) {
|
|
|
11073
11590
|
);
|
|
11074
11591
|
return 1;
|
|
11075
11592
|
}
|
|
11076
|
-
function
|
|
11593
|
+
function parseFlags16(argv) {
|
|
11077
11594
|
const out = {};
|
|
11078
11595
|
for (let i = 0; i < argv.length; i++) {
|
|
11079
11596
|
const flag = argv[i];
|
|
@@ -11088,26 +11605,378 @@ function parseFlags15(argv) {
|
|
|
11088
11605
|
return out;
|
|
11089
11606
|
}
|
|
11090
11607
|
|
|
11091
|
-
// src/
|
|
11092
|
-
import { existsSync as
|
|
11608
|
+
// src/commands/setup.ts
|
|
11609
|
+
import { existsSync as existsSync18, readFileSync as readFileSync19 } from "fs";
|
|
11610
|
+
import { join as join37, resolve as resolve7 } from "path";
|
|
11611
|
+
var setupHelp = `
|
|
11612
|
+
roster setup [--json] [--join <org>] [--add-repo <name>]
|
|
11613
|
+
|
|
11614
|
+
Where setup has got to, and the one thing to do next. Every step is read from GitHub and
|
|
11615
|
+
from disk each time, so it can be run as often as you like and never disagrees with the
|
|
11616
|
+
world.
|
|
11617
|
+
|
|
11618
|
+
This is what the SKILL.md install follows: an AI coding agent runs \`roster setup --json\`,
|
|
11619
|
+
does the next step, and runs it again. Each step says who it is for. "agent" steps are
|
|
11620
|
+
commands to run; "human" steps are a page to open or a command only you can run, and say
|
|
11621
|
+
exactly which.
|
|
11622
|
+
|
|
11623
|
+
--json the steps as JSON, for an agent
|
|
11624
|
+
--join <org> check out an org that already runs roster, here
|
|
11625
|
+
--add-repo <name> add a repo in the org to org.yaml as a product the staff work on
|
|
11626
|
+
--dir <path> where the workspace is, or would be (default: here)
|
|
11627
|
+
`;
|
|
11628
|
+
function steps(f) {
|
|
11629
|
+
const out = [];
|
|
11630
|
+
out.push({
|
|
11631
|
+
id: "gh",
|
|
11632
|
+
done: f.gh.ok,
|
|
11633
|
+
who: "human",
|
|
11634
|
+
title: f.gh.ok ? `GitHub CLI signed in as ${f.gh.login}` : "Sign in to the GitHub CLI",
|
|
11635
|
+
do: "Roster does everything through your own gh. Run this in your terminal and follow its prompts.",
|
|
11636
|
+
command: "gh auth login --scopes admin:org,workflow"
|
|
11637
|
+
});
|
|
11638
|
+
if (!f.gh.ok) return out;
|
|
11639
|
+
if (!f.tenant) {
|
|
11640
|
+
const running = f.orgs.filter((o) => o.tenant);
|
|
11641
|
+
if (running.length) {
|
|
11642
|
+
out.push({
|
|
11643
|
+
id: "join",
|
|
11644
|
+
done: false,
|
|
11645
|
+
who: "agent",
|
|
11646
|
+
title: `Check out ${running.map((o) => o.login).join(" or ")}, which already runs roster`,
|
|
11647
|
+
do: "Ask whether to join one of these or set up a new organisation. To join, check it out here. For a new one, run `roster init --org <org> --apply` instead.",
|
|
11648
|
+
command: `roster setup --join ${running[0].login}`,
|
|
11649
|
+
confirm: true
|
|
11650
|
+
});
|
|
11651
|
+
return out;
|
|
11652
|
+
}
|
|
11653
|
+
if (!f.orgs.length) {
|
|
11654
|
+
out.push({
|
|
11655
|
+
id: "org",
|
|
11656
|
+
done: false,
|
|
11657
|
+
who: "human",
|
|
11658
|
+
title: "Create a GitHub organisation",
|
|
11659
|
+
do: "Your staff live in an organisation of their own. GitHub has no API for making one, so make it on this page (the free plan works), then say when it is done.",
|
|
11660
|
+
command: "https://github.com/account/organizations/new"
|
|
11661
|
+
});
|
|
11662
|
+
return out;
|
|
11663
|
+
}
|
|
11664
|
+
out.push({
|
|
11665
|
+
id: "init",
|
|
11666
|
+
done: false,
|
|
11667
|
+
who: "agent",
|
|
11668
|
+
title: "Set up roster in an organisation",
|
|
11669
|
+
do: `Ask which organisation to use (${f.orgs.map((o) => o.login).join(", ")}) and which coding agent the staff run on (claude-code-action, codex or nanocoder), then create it.`,
|
|
11670
|
+
command: "roster init --org <org> --agent <agent> --apply",
|
|
11671
|
+
confirm: true
|
|
11672
|
+
});
|
|
11673
|
+
return out;
|
|
11674
|
+
}
|
|
11675
|
+
const t = f.tenant;
|
|
11676
|
+
out.push({ id: "init", done: true, who: "agent", title: `roster runs in ${t.org}`, do: "" });
|
|
11677
|
+
out.push({
|
|
11678
|
+
id: "products",
|
|
11679
|
+
done: t.products.length > 0,
|
|
11680
|
+
who: "agent",
|
|
11681
|
+
title: t.products.length ? `Staff work on ${t.products.join(", ")}` : "Choose the repos your staff work on",
|
|
11682
|
+
do: "List the org's repos with `gh repo list <org>`, ask which ones the staff should work on, and add each.",
|
|
11683
|
+
command: "roster setup --add-repo <name>",
|
|
11684
|
+
confirm: true
|
|
11685
|
+
});
|
|
11686
|
+
out.push({
|
|
11687
|
+
id: "business",
|
|
11688
|
+
done: t.business,
|
|
11689
|
+
who: "agent",
|
|
11690
|
+
title: "Describe the business",
|
|
11691
|
+
do: "Print the brief and follow it: interview the person with its questions, in its words, use what you already know about their project, write org/business.md, show it to them, then commit and push the ops repo.",
|
|
11692
|
+
command: "roster brief discover"
|
|
11693
|
+
});
|
|
11694
|
+
out.push({
|
|
11695
|
+
id: "priorities",
|
|
11696
|
+
done: t.priorities,
|
|
11697
|
+
who: "agent",
|
|
11698
|
+
title: "Set this month's priorities",
|
|
11699
|
+
do: "Print the brief and follow it the same way, writing org/priorities.md.",
|
|
11700
|
+
command: "roster brief priorities"
|
|
11701
|
+
});
|
|
11702
|
+
out.push({
|
|
11703
|
+
id: "hire",
|
|
11704
|
+
done: t.staff.length > 0,
|
|
11705
|
+
who: "agent",
|
|
11706
|
+
title: t.staff.length ? `Hired ${t.staff.map((s) => s.handle).join(", ")}` : "Hire your first staff member",
|
|
11707
|
+
do: "Ask what role they need first (a CTO is the usual start). Show them the plan, then hire.",
|
|
11708
|
+
command: "roster hire <handle> --name <role name> --apply",
|
|
11709
|
+
confirm: true
|
|
11710
|
+
});
|
|
11711
|
+
for (const s of t.staff) {
|
|
11712
|
+
out.push({
|
|
11713
|
+
id: `charter.${s.handle}`,
|
|
11714
|
+
done: s.charter,
|
|
11715
|
+
who: "agent",
|
|
11716
|
+
title: `Write ${s.handle}'s charter`,
|
|
11717
|
+
do: `Print the brief and follow it, writing ${s.dir}/CHARTER.md, then commit and push that repo.`,
|
|
11718
|
+
command: `roster brief charter ${s.handle}`
|
|
11719
|
+
});
|
|
11720
|
+
out.push({
|
|
11721
|
+
id: `app.${s.handle}`,
|
|
11722
|
+
done: s.app === true,
|
|
11723
|
+
who: "agent",
|
|
11724
|
+
title: `Create and install ${s.handle}'s GitHub App`,
|
|
11725
|
+
do: "Run the command in the background. It prints a link: give it to the person to confirm on GitHub. Then it prints an install link with the right repos ticked: give them that too, and wait for it to finish.",
|
|
11726
|
+
command: `roster app ${s.handle} --no-open --apply`
|
|
11727
|
+
});
|
|
11728
|
+
}
|
|
11729
|
+
out.push({
|
|
11730
|
+
id: "credential",
|
|
11731
|
+
done: t.credential === true,
|
|
11732
|
+
who: "human",
|
|
11733
|
+
title: "Store the coding agent's credential",
|
|
11734
|
+
do: `Staff run on your agent account, stored as the ${t.tokenEnv} secret. Never ask for it in chat. Ask the person to run these in their own terminal, then say when it is done.`,
|
|
11735
|
+
command: t.tokenEnv === "CLAUDE_CODE_OAUTH_TOKEN" ? "claude setup-token # then: roster credential --apply, and paste it" : "roster credential --apply # paste the key at the hidden prompt"
|
|
11736
|
+
});
|
|
11737
|
+
for (const s of t.staff) {
|
|
11738
|
+
out.push({
|
|
11739
|
+
id: `run.${s.handle}`,
|
|
11740
|
+
done: s.ran === true,
|
|
11741
|
+
who: "agent",
|
|
11742
|
+
title: `${s.handle}'s first run`,
|
|
11743
|
+
do: "A real run does a day's work and costs what one does, so ask before starting it. It is the only proof the App is installed and the secrets are right.",
|
|
11744
|
+
command: `roster run ${s.handle} --apply`,
|
|
11745
|
+
confirm: true
|
|
11746
|
+
});
|
|
11747
|
+
}
|
|
11748
|
+
return out;
|
|
11749
|
+
}
|
|
11750
|
+
async function setupCommand(argv) {
|
|
11751
|
+
const opts = parseFlags17(argv);
|
|
11752
|
+
const dir = resolve7(opts.dir ?? process.cwd());
|
|
11753
|
+
if (opts.join) {
|
|
11754
|
+
const cloned = await joinTenant(dir, opts.join);
|
|
11755
|
+
process.stdout.write(` checked out ${cloned.length ? cloned.join(", ") : "nothing new"}
|
|
11756
|
+
`);
|
|
11757
|
+
return 0;
|
|
11758
|
+
}
|
|
11759
|
+
if (opts.addRepo) return addRepo(dir, opts.addRepo);
|
|
11760
|
+
const list2 = steps(await facts(dir));
|
|
11761
|
+
const next = list2.find((s) => !s.done) ?? null;
|
|
11762
|
+
if (opts.json) {
|
|
11763
|
+
process.stdout.write(
|
|
11764
|
+
`${JSON.stringify({ ready: !next, next, steps: list2, portal: "roster" }, null, 2)}
|
|
11765
|
+
`
|
|
11766
|
+
);
|
|
11767
|
+
return 0;
|
|
11768
|
+
}
|
|
11769
|
+
process.stdout.write("\n");
|
|
11770
|
+
for (const s of list2) process.stdout.write(` ${s.done ? "\u2713" : "\xB7"} ${s.title}
|
|
11771
|
+
`);
|
|
11772
|
+
if (!next) {
|
|
11773
|
+
process.stdout.write("\n Setup is done. `roster` opens the portal.\n\n");
|
|
11774
|
+
return 0;
|
|
11775
|
+
}
|
|
11776
|
+
process.stdout.write(`
|
|
11777
|
+
Next${next.who === "human" ? ", for you" : ""}: ${next.do}
|
|
11778
|
+
`);
|
|
11779
|
+
if (next.command) process.stdout.write(` ${next.command}
|
|
11780
|
+
`);
|
|
11781
|
+
process.stdout.write("\n");
|
|
11782
|
+
return 0;
|
|
11783
|
+
}
|
|
11784
|
+
async function facts(dir) {
|
|
11785
|
+
const status = await setupStatus(dir);
|
|
11786
|
+
const gh = status.gh;
|
|
11787
|
+
const ws = tryWorkspace(dir);
|
|
11788
|
+
if (!gh.ok || !ws) {
|
|
11789
|
+
const orgs = gh.ok ? await Promise.all(
|
|
11790
|
+
status.orgs.slice(0, 30).map(async (login) => ({
|
|
11791
|
+
login,
|
|
11792
|
+
tenant: (await orgHasTenant(login)).exists
|
|
11793
|
+
}))
|
|
11794
|
+
) : [];
|
|
11795
|
+
return { gh, orgs, tenant: null };
|
|
11796
|
+
}
|
|
11797
|
+
const { parseYaml: parseYaml3 } = await loadComposer(ws.opsDir);
|
|
11798
|
+
const org = readOrg(ws.opsDir, parseYaml3);
|
|
11799
|
+
const left = status.tenant.left ?? [];
|
|
11800
|
+
const tokenEnv = agentTokenEnv(org);
|
|
11801
|
+
const staff = await Promise.all(
|
|
11802
|
+
(org.staff ?? []).map(async (p) => {
|
|
11803
|
+
const dirName = p.dir ?? p.handle;
|
|
11804
|
+
const root2 = join37(ws.root, dirName);
|
|
11805
|
+
const charterPath = join37(root2, "CHARTER.md");
|
|
11806
|
+
const charter = existsSync18(charterPath) && !looksUnwritten(readFileSync19(charterPath, "utf8"));
|
|
11807
|
+
const manifestPath = join37(root2, "staff.yaml");
|
|
11808
|
+
const prefix = existsSync18(manifestPath) ? specFromManifest(parseYaml3(readFileSync19(manifestPath, "utf8"), "staff.yaml"), dirName).secretPrefix : p.handle.toUpperCase();
|
|
11809
|
+
const repo = `${org.org}/${dirName}`;
|
|
11810
|
+
const [secrets, runs] = await Promise.all([
|
|
11811
|
+
api(`repos/${repo}/actions/secrets`),
|
|
11812
|
+
ghJson([
|
|
11813
|
+
"run",
|
|
11814
|
+
"list",
|
|
11815
|
+
"--repo",
|
|
11816
|
+
repo,
|
|
11817
|
+
"--status",
|
|
11818
|
+
"success",
|
|
11819
|
+
"--limit",
|
|
11820
|
+
"1",
|
|
11821
|
+
"--json",
|
|
11822
|
+
"databaseId"
|
|
11823
|
+
])
|
|
11824
|
+
]);
|
|
11825
|
+
return {
|
|
11826
|
+
handle: p.handle,
|
|
11827
|
+
dir: dirName,
|
|
11828
|
+
charter,
|
|
11829
|
+
app: secrets.ok ? secrets.data.secrets.some((s) => s.name === `${prefix}_APP_ID`) : null,
|
|
11830
|
+
ran: runs.ok ? (runs.data ?? []).length > 0 : null
|
|
11831
|
+
};
|
|
11832
|
+
})
|
|
11833
|
+
);
|
|
11834
|
+
return {
|
|
11835
|
+
gh,
|
|
11836
|
+
orgs: [],
|
|
11837
|
+
tenant: {
|
|
11838
|
+
org: org.org,
|
|
11839
|
+
products: status.tenant.products ?? [],
|
|
11840
|
+
business: !left.includes("business"),
|
|
11841
|
+
priorities: !left.includes("priorities"),
|
|
11842
|
+
staff,
|
|
11843
|
+
credential: staff.length ? await hasCredential(org.org, staff[0].dir, tokenEnv) : null,
|
|
11844
|
+
tokenEnv
|
|
11845
|
+
}
|
|
11846
|
+
};
|
|
11847
|
+
}
|
|
11848
|
+
async function hasCredential(org, dir, name) {
|
|
11849
|
+
const [own, shared] = await Promise.all([
|
|
11850
|
+
api(`repos/${org}/${dir}/actions/secrets`),
|
|
11851
|
+
api(`repos/${org}/${dir}/actions/organization-secrets`)
|
|
11852
|
+
]);
|
|
11853
|
+
if (!own.ok && !shared.ok) return null;
|
|
11854
|
+
return [own, shared].some((r) => r.ok && r.data.secrets.some((s) => s.name === name));
|
|
11855
|
+
}
|
|
11856
|
+
async function addRepo(dir, name) {
|
|
11857
|
+
const ws = tryWorkspace(dir);
|
|
11858
|
+
if (!ws) {
|
|
11859
|
+
process.stderr.write("roster: no roster workspace here. `roster setup` says what is next.\n");
|
|
11860
|
+
return 2;
|
|
11861
|
+
}
|
|
11862
|
+
if (!/^[\w.-]+$/.test(name)) {
|
|
11863
|
+
process.stderr.write(`roster: "${name}" is not a repo name
|
|
11864
|
+
`);
|
|
11865
|
+
return 2;
|
|
11866
|
+
}
|
|
11867
|
+
const path = join37(ws.opsDir, "org.yaml");
|
|
11868
|
+
const text2 = readFileSync19(path, "utf8");
|
|
11869
|
+
if (new RegExp(`name: ${name}[,\\s}]`).test(text2)) {
|
|
11870
|
+
process.stdout.write(` ${name} is already in org.yaml
|
|
11871
|
+
`);
|
|
11872
|
+
return 0;
|
|
11873
|
+
}
|
|
11874
|
+
const { parseYaml: parseYaml3 } = await loadComposer(ws.opsDir);
|
|
11875
|
+
const org = readOrg(ws.opsDir, parseYaml3).org;
|
|
11876
|
+
const info = await api(`repos/${org}/${name}`);
|
|
11877
|
+
if (!info.ok) {
|
|
11878
|
+
process.stderr.write(`roster: cannot see ${org}/${name}: ${info.error}
|
|
11879
|
+
`);
|
|
11880
|
+
return 1;
|
|
11881
|
+
}
|
|
11882
|
+
const visibility = String(info.data.visibility ?? "private").toLowerCase();
|
|
11883
|
+
const line = ` - { name: ${name}, visibility: ${visibility}, role: product }`;
|
|
11884
|
+
const saved = saveFile(
|
|
11885
|
+
ws,
|
|
11886
|
+
`${ws.opsName}/org.yaml`,
|
|
11887
|
+
insertUnder(text2, "repos", line),
|
|
11888
|
+
`setup: org.yaml lists ${name}`
|
|
11889
|
+
);
|
|
11890
|
+
process.stdout.write(
|
|
11891
|
+
` added ${name} as a product${saved.pushed ? ", committed and pushed" : `, committed; push failed: ${saved.note}`}
|
|
11892
|
+
`
|
|
11893
|
+
);
|
|
11894
|
+
return 0;
|
|
11895
|
+
}
|
|
11896
|
+
function parseFlags17(argv) {
|
|
11897
|
+
const out = {};
|
|
11898
|
+
for (let i = 0; i < argv.length; i++) {
|
|
11899
|
+
const a = argv[i];
|
|
11900
|
+
if (a === "--json") out.json = true;
|
|
11901
|
+
else if (a === "--join") out.join = argv[++i];
|
|
11902
|
+
else if (a === "--add-repo") out.addRepo = argv[++i];
|
|
11903
|
+
else if (a === "--dir") out.dir = argv[++i];
|
|
11904
|
+
}
|
|
11905
|
+
return out;
|
|
11906
|
+
}
|
|
11907
|
+
|
|
11908
|
+
// src/commands/skill.ts
|
|
11909
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync9, readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "fs";
|
|
11093
11910
|
import { homedir as homedir2 } from "os";
|
|
11094
|
-
import { join as
|
|
11911
|
+
import { join as join38 } from "path";
|
|
11912
|
+
var skillHelp = `
|
|
11913
|
+
roster skill install [--print]
|
|
11914
|
+
|
|
11915
|
+
Save Roster's SKILL.md for every coding agent on this machine, so a future session knows how
|
|
11916
|
+
to set up and run Roster without being told. It is the same file served at
|
|
11917
|
+
https://roster.nanocollective.org/SKILL.md.
|
|
11918
|
+
|
|
11919
|
+
It writes to each agent's user-level skills directory that exists: Claude Code
|
|
11920
|
+
(~/.claude/skills/roster) and Codex (~/.codex/skills/roster). Running it again replaces the
|
|
11921
|
+
file, which is how it is updated after a new version.
|
|
11922
|
+
|
|
11923
|
+
--print print the file instead
|
|
11924
|
+
`;
|
|
11925
|
+
var AGENT_HOMES = [
|
|
11926
|
+
{ name: "Claude Code", home: ".claude", dir: join38("skills", "roster") },
|
|
11927
|
+
{ name: "Codex", home: ".codex", dir: join38("skills", "roster") }
|
|
11928
|
+
];
|
|
11929
|
+
function skillText() {
|
|
11930
|
+
return readFileSync20(join38(templatesRoot(), "skill", "SKILL.md"), "utf8");
|
|
11931
|
+
}
|
|
11932
|
+
function installSkill(home = homedir2(), text2 = skillText()) {
|
|
11933
|
+
const done = [];
|
|
11934
|
+
for (const a of AGENT_HOMES) {
|
|
11935
|
+
if (!existsSync19(join38(home, a.home))) continue;
|
|
11936
|
+
const dir = join38(home, a.home, a.dir);
|
|
11937
|
+
mkdirSync9(dir, { recursive: true });
|
|
11938
|
+
writeFileSync15(join38(dir, "SKILL.md"), text2);
|
|
11939
|
+
done.push(a.name);
|
|
11940
|
+
}
|
|
11941
|
+
return done;
|
|
11942
|
+
}
|
|
11943
|
+
async function skillCommand(argv) {
|
|
11944
|
+
if (argv.includes("--print")) {
|
|
11945
|
+
process.stdout.write(skillText());
|
|
11946
|
+
return 0;
|
|
11947
|
+
}
|
|
11948
|
+
if (argv[0] !== "install") {
|
|
11949
|
+
process.stderr.write(skillHelp);
|
|
11950
|
+
return 2;
|
|
11951
|
+
}
|
|
11952
|
+
const done = installSkill();
|
|
11953
|
+
process.stdout.write(
|
|
11954
|
+
done.length ? ` saved the Roster skill for ${done.join(" and ")}
|
|
11955
|
+
` : " no coding agent found (looked for ~/.claude and ~/.codex). `roster skill --print` prints the file.\n"
|
|
11956
|
+
);
|
|
11957
|
+
return 0;
|
|
11958
|
+
}
|
|
11959
|
+
|
|
11960
|
+
// src/lib/runstore.ts
|
|
11961
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync10, readFileSync as readFileSync21, writeFileSync as writeFileSync16 } from "fs";
|
|
11962
|
+
import { homedir as homedir3 } from "os";
|
|
11963
|
+
import { join as join39 } from "path";
|
|
11095
11964
|
function diskRecordStore(dir = defaultDir2()) {
|
|
11096
|
-
const file = (brain, id) =>
|
|
11965
|
+
const file = (brain, id) => join39(dir, brain.replace("/", "__"), `${id}.json`);
|
|
11097
11966
|
return {
|
|
11098
11967
|
async get(brain, id) {
|
|
11099
11968
|
const path = file(brain, id);
|
|
11100
|
-
if (!
|
|
11101
|
-
return JSON.parse(
|
|
11969
|
+
if (!existsSync20(path)) return void 0;
|
|
11970
|
+
return JSON.parse(readFileSync21(path, "utf8"));
|
|
11102
11971
|
},
|
|
11103
11972
|
async put(brain, id, value) {
|
|
11104
|
-
|
|
11105
|
-
|
|
11973
|
+
mkdirSync10(join39(dir, brain.replace("/", "__")), { recursive: true });
|
|
11974
|
+
writeFileSync16(file(brain, id), JSON.stringify(value));
|
|
11106
11975
|
}
|
|
11107
11976
|
};
|
|
11108
11977
|
}
|
|
11109
11978
|
function defaultDir2() {
|
|
11110
|
-
return process.env.ROSTER_CACHE_DIR ??
|
|
11979
|
+
return process.env.ROSTER_CACHE_DIR ?? join39(homedir3(), ".cache", "roster", "runs");
|
|
11111
11980
|
}
|
|
11112
11981
|
|
|
11113
11982
|
// src/cli.ts
|
|
@@ -11115,6 +11984,7 @@ var HELP = `
|
|
|
11115
11984
|
roster \u2014 an agent-run org, powered by GitHub
|
|
11116
11985
|
|
|
11117
11986
|
roster open the portal. With no org here, it sets one up.
|
|
11987
|
+
roster setup where setup has got to, and what to do next
|
|
11118
11988
|
roster init --org <org> stand up a new tenant
|
|
11119
11989
|
roster brief <kind> a brief for authoring a charter, business.md or the voice
|
|
11120
11990
|
roster prompt <handle> compose the runtime prompt for a staff member
|
|
@@ -11126,15 +11996,19 @@ roster \u2014 an agent-run org, powered by GitHub
|
|
|
11126
11996
|
roster credential store the agent's credential, once for the org
|
|
11127
11997
|
roster connector give staff an outside service: Sentry, Linear, Stripe\u2026
|
|
11128
11998
|
roster run <handle> start one daily run now, and follow it to the end
|
|
11999
|
+
roster routine <handle> when they wake beyond the daily round, and what they do
|
|
11129
12000
|
roster retire <handle> stop a staff member, keeping their repo and their memory
|
|
11130
12001
|
roster upgrade carry framework changes into this tenant
|
|
11131
12002
|
roster portal browse every brain, locally
|
|
11132
12003
|
roster portal deploy put the portal on the web, behind Sign in with GitHub
|
|
11133
12004
|
roster export the whole org as one JSON
|
|
12005
|
+
roster skill install teach your coding agents Roster (the SKILL.md)
|
|
11134
12006
|
roster help [command]
|
|
11135
12007
|
|
|
11136
12008
|
`;
|
|
11137
12009
|
var COMMANDS = {
|
|
12010
|
+
setup: setupCommand,
|
|
12011
|
+
skill: skillCommand,
|
|
11138
12012
|
init: initCommand,
|
|
11139
12013
|
brief: briefCommand,
|
|
11140
12014
|
prompt: promptCommand,
|
|
@@ -11147,11 +12021,14 @@ var COMMANDS = {
|
|
|
11147
12021
|
credential: credentialCommand,
|
|
11148
12022
|
connector: connectorCommand,
|
|
11149
12023
|
run: runCommand,
|
|
12024
|
+
routine: routineCommand,
|
|
11150
12025
|
retire: retireCommand,
|
|
11151
12026
|
portal: portalCommand,
|
|
11152
12027
|
export: exportCommand
|
|
11153
12028
|
};
|
|
11154
12029
|
var HELPS = {
|
|
12030
|
+
setup: setupHelp,
|
|
12031
|
+
skill: skillHelp,
|
|
11155
12032
|
init: initHelp,
|
|
11156
12033
|
brief: briefHelp,
|
|
11157
12034
|
prompt: promptHelp,
|
|
@@ -11164,6 +12041,7 @@ var HELPS = {
|
|
|
11164
12041
|
credential: credentialHelp,
|
|
11165
12042
|
connector: connectorHelp,
|
|
11166
12043
|
run: runHelp,
|
|
12044
|
+
routine: routineHelp,
|
|
11167
12045
|
retire: retireHelp,
|
|
11168
12046
|
portal: portalHelp,
|
|
11169
12047
|
deploy: deployHelp,
|
|
@@ -11193,13 +12071,13 @@ async function main(argv) {
|
|
|
11193
12071
|
process.stdout.write(HELPS[topic]);
|
|
11194
12072
|
return 0;
|
|
11195
12073
|
}
|
|
11196
|
-
const
|
|
11197
|
-
if (!
|
|
12074
|
+
const run3 = COMMANDS[command];
|
|
12075
|
+
if (!run3) {
|
|
11198
12076
|
process.stderr.write(`roster: unknown command "${command}"
|
|
11199
12077
|
${HELP}`);
|
|
11200
12078
|
return 2;
|
|
11201
12079
|
}
|
|
11202
|
-
return
|
|
12080
|
+
return run3(rest);
|
|
11203
12081
|
}
|
|
11204
12082
|
main(process.argv.slice(2)).then((code) => process.exit(code)).catch((err) => {
|
|
11205
12083
|
process.stderr.write(`roster: ${err instanceof Error ? err.message : String(err)}
|