@catalyst-cloud/cli 0.15.3 → 0.15.5
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/CHANGELOG.md +10 -0
- package/README.md +2 -0
- package/dist/args.js +5 -1
- package/dist/cli.js +39 -3
- package/dist/onboard-checklist.js +3 -2
- package/dist/onboard-headless.js +3 -0
- package/dist/onboard-repositories.js +197 -6
- package/dist/onboard-standalone-copy.js +21 -5
- package/dist/onboard-ui.js +166 -29
- package/dist/onboard.js +24 -7
- package/dist/setup-brand.js +202 -0
- package/dist/setup-onboard-copy.js +92 -16
- package/dist/setup-render.js +62 -37
- package/dist/terminal-background.js +220 -0
- package/package.json +1 -1
- package/skills/catalyst-github/SKILL.md +1 -1
- package/skills/catalyst-linear/SKILL.md +1 -1
- package/skills/catalyst-onboard/SKILL.md +1 -1
- package/skills/run-this-project/SKILL.md +1 -1
- package/skills/unstick/SKILL.md +1 -1
- package/skills/what-needs-me/SKILL.md +1 -1
- package/skills/what-this-repo-needs/SKILL.md +1 -1
- package/skills/whats-happening/SKILL.md +1 -1
|
@@ -212,7 +212,9 @@ function unfinished(step) {
|
|
|
212
212
|
if (step.reason === "runner_docker_missing")
|
|
213
213
|
return "Docker is not running";
|
|
214
214
|
if (step.reason === "member_scope")
|
|
215
|
-
return "
|
|
215
|
+
return step.id === "linear.team" || step.id === "values"
|
|
216
|
+
? "run catalyst setup --team <KEY> to choose your team"
|
|
217
|
+
: "an admin handles this step";
|
|
216
218
|
if (step.reason === "automation_management_unavailable")
|
|
217
219
|
return "could not read them; checked again before work starts";
|
|
218
220
|
if (step.reason === "interrupted" || step.reason === "first_ticket_skipped")
|
|
@@ -306,14 +308,62 @@ export function setupStepView(step, journal, required = false) {
|
|
|
306
308
|
outcome,
|
|
307
309
|
};
|
|
308
310
|
}
|
|
311
|
+
/** The signed-in person's Catalyst role, when the sign-in step recorded one. */
|
|
312
|
+
function signedInRole(journal) {
|
|
313
|
+
const role = journal?.steps.find((s) => s.id === "signin" && s.state === "done")?.evidence?.role;
|
|
314
|
+
return typeof role === "string" ? role : undefined;
|
|
315
|
+
}
|
|
316
|
+
const notOwnerOrAdmin = (journal) => {
|
|
317
|
+
const role = signedInRole(journal);
|
|
318
|
+
return role !== undefined && role !== "owner" && role !== "admin";
|
|
319
|
+
};
|
|
320
|
+
/** The steps readiness says an owner or admin has left (`admin_setup_pending`), if it said so. */
|
|
321
|
+
function readinessAdminSteps(journal) {
|
|
322
|
+
const ready = journal?.steps.find((s) => s.id === "ready");
|
|
323
|
+
const ids = ready?.evidence?.admin;
|
|
324
|
+
return ready?.reason === "admin_setup_pending" && typeof ids === "string"
|
|
325
|
+
? new Set(ids.split(","))
|
|
326
|
+
: new Set();
|
|
327
|
+
}
|
|
328
|
+
/** A member's skip of their own team (or the values it gates): rerun with --team, nobody else. */
|
|
329
|
+
const memberOwnSkip = (step) => step.reason === "member_scope" &&
|
|
330
|
+
(step.id === "linear.team" || step.id === "values");
|
|
331
|
+
/**
|
|
332
|
+
* CTC-4680: a step only an owner or admin of the Catalyst workspace can finish, for the person
|
|
333
|
+
* running setup. A member's run skips every admin step whether or not the admin has done it, so a
|
|
334
|
+
* skip waits on an admin only when readiness names that step. Refusals for the person's role, a
|
|
335
|
+
* member's unverified runner or workflow, and a member's AI account or values do too.
|
|
336
|
+
*/
|
|
337
|
+
export function setupWaitsOnAdmin(step, journal) {
|
|
338
|
+
if (step.state === "done")
|
|
339
|
+
return false;
|
|
340
|
+
const reason = step.reason ?? "";
|
|
341
|
+
if (reason === "member_scope")
|
|
342
|
+
return !memberOwnSkip(step) && readinessAdminSteps(journal).has(step.id);
|
|
343
|
+
if (reason === "github_installation_admin_required")
|
|
344
|
+
return true;
|
|
345
|
+
if (reason === "runner_identity_unverified" ||
|
|
346
|
+
reason === "workflow_identity_unverified")
|
|
347
|
+
return notOwnerOrAdmin(journal);
|
|
348
|
+
// Only reasons an owner or admin clears. A probe that could not finish (a stale read, a login
|
|
349
|
+
// to refresh) is the person's own to check again.
|
|
350
|
+
if ((step.id === "accounts" &&
|
|
351
|
+
(reason === "account_enrollment_required" ||
|
|
352
|
+
reason === "ai_account_not_usable")) ||
|
|
353
|
+
(step.id === "values" && reason === "required_values_missing"))
|
|
354
|
+
return notOwnerOrAdmin(journal);
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
309
357
|
/** How far each part has got, by its numbered rows. A row is done when every step in it is done
|
|
310
|
-
* or skipped,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
};
|
|
358
|
+
* or skipped by choice, needs someone when any of its steps does, and waits on an owner or admin
|
|
359
|
+
* when only they can finish it. */
|
|
360
|
+
export function setupPartProgress(journal, scope,
|
|
361
|
+
/** "run" before readiness is known: a member's admin skips count aside, neither done nor owed.
|
|
362
|
+
* At the end they count done only when readiness passed. */
|
|
363
|
+
moment = "end") {
|
|
364
|
+
const empty = () => ({ total: 0, done: 0, needs: 0, failed: 0, admin: 0, aside: 0 });
|
|
365
|
+
const progress = { 1: empty(), 2: empty(), 3: empty() };
|
|
366
|
+
const readinessPassed = journal.steps.find((s) => s.id === "ready")?.state === "done";
|
|
317
367
|
const rows = new Map();
|
|
318
368
|
for (const id of ONBOARD_STEPS) {
|
|
319
369
|
const number = SETUP_PART_NUMBERS[id];
|
|
@@ -324,18 +374,36 @@ export function setupPartProgress(journal, scope) {
|
|
|
324
374
|
state: "pending",
|
|
325
375
|
};
|
|
326
376
|
const key = `${SETUP_PART_OF[id]}:${number}`;
|
|
327
|
-
rows.set(key, [
|
|
377
|
+
rows.set(key, [
|
|
378
|
+
...(rows.get(key) ?? []),
|
|
379
|
+
{
|
|
380
|
+
// A member's own skip (no --team) is theirs to finish, so it is never counted done.
|
|
381
|
+
mark: memberOwnSkip(step) ? "act" : setupStepView(step, journal).mark,
|
|
382
|
+
kind: setupWaitsOnAdmin(step, journal)
|
|
383
|
+
? "admin"
|
|
384
|
+
: step.reason === "member_scope" &&
|
|
385
|
+
!memberOwnSkip(step) &&
|
|
386
|
+
(moment === "run" || !readinessPassed)
|
|
387
|
+
? "aside"
|
|
388
|
+
: "own",
|
|
389
|
+
},
|
|
390
|
+
]);
|
|
328
391
|
}
|
|
329
|
-
for (const [key,
|
|
392
|
+
for (const [key, steps] of rows) {
|
|
330
393
|
const part = progress[Number(key.split(":")[0])];
|
|
331
394
|
part.total++;
|
|
332
|
-
|
|
395
|
+
const own = steps.filter((s) => s.kind === "own");
|
|
396
|
+
if (own.length === steps.length && own.every((s) => s.mark === "done" || s.mark === "skip"))
|
|
333
397
|
part.done++;
|
|
334
|
-
else if (
|
|
398
|
+
else if (own.some((s) => s.mark === "act" || s.mark === "fail")) {
|
|
335
399
|
part.needs++;
|
|
336
|
-
if (
|
|
400
|
+
if (own.some((s) => s.mark === "fail"))
|
|
337
401
|
part.failed++;
|
|
338
402
|
}
|
|
403
|
+
else if (steps.some((s) => s.kind === "admin"))
|
|
404
|
+
part.admin++;
|
|
405
|
+
else if (steps.some((s) => s.kind === "aside"))
|
|
406
|
+
part.aside++;
|
|
339
407
|
}
|
|
340
408
|
return progress;
|
|
341
409
|
}
|
|
@@ -345,6 +413,7 @@ export function setupPartProgress(journal, scope) {
|
|
|
345
413
|
*/
|
|
346
414
|
export function setupTrackerRows(progress, moment) {
|
|
347
415
|
const steps = (n) => `${n} ${n === 1 ? "step" : "steps"}`;
|
|
416
|
+
const waiting = (n) => `${steps(n)} ${n === 1 ? "waits" : "wait"} on an owner or admin`;
|
|
348
417
|
return [1, 2, 3]
|
|
349
418
|
.filter((p) => progress[p].total > 0)
|
|
350
419
|
.map((p) => {
|
|
@@ -365,14 +434,21 @@ export function setupTrackerRows(progress, moment) {
|
|
|
365
434
|
return row("now", `next · ${estimate}`);
|
|
366
435
|
if (p > moment.next)
|
|
367
436
|
return row("later", estimate);
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
437
|
+
if (finished)
|
|
438
|
+
return row("done", "done");
|
|
439
|
+
const theirs = got.admin + got.aside;
|
|
440
|
+
if (theirs && got.done + theirs === got.total)
|
|
441
|
+
return row("act", `${steps(theirs)} ${theirs === 1 ? "is" : "are"} for an owner or admin`);
|
|
442
|
+
return row(needsMark, `${steps(got.total - got.done)} not finished`);
|
|
371
443
|
}
|
|
372
444
|
if (finished)
|
|
373
445
|
return row("done", "");
|
|
374
446
|
if (got.needs)
|
|
375
447
|
return row(needsMark, `${steps(got.needs)} ${got.needs === 1 ? "needs" : "need"} someone`);
|
|
448
|
+
if (got.admin)
|
|
449
|
+
return row("act", waiting(got.admin));
|
|
450
|
+
if (got.aside)
|
|
451
|
+
return row("act", `${steps(got.aside)} ${got.aside === 1 ? "is" : "are"} for an owner or admin`);
|
|
376
452
|
return row("later", `${got.done} of ${steps(got.total)} done`);
|
|
377
453
|
});
|
|
378
454
|
}
|
package/dist/setup-render.js
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
import { styleText } from "node:util";
|
|
9
9
|
import { wrapAnsi } from "fast-wrap-ansi";
|
|
10
10
|
import stringWidth from "fast-string-width";
|
|
11
|
+
import { colourLevel, markSkipped, markSpan, pixelNucleusLines, } from "./setup-brand.js";
|
|
12
|
+
import { detectTheme, envTheme, } from "./terminal-background.js";
|
|
11
13
|
const DEFAULT_COLUMNS = 80;
|
|
14
|
+
const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
12
15
|
const MIN_COLUMNS = 40;
|
|
13
16
|
function utf8Locale(env) {
|
|
14
17
|
return /utf-?8/i.test(env.LC_ALL || env.LC_CTYPE || env.LANG || "");
|
|
@@ -72,33 +75,20 @@ const UNICODE_MARKS = {
|
|
|
72
75
|
ask: ["◆", "cyan"],
|
|
73
76
|
now: ["◆", "cyan"],
|
|
74
77
|
};
|
|
75
|
-
/** CTC-4680: the Pixel Nucleus core, copper on a dark terminal and rust on a light one
|
|
76
|
-
* (catalyst-cloud docs/brand-mark.md), with the nearest 256- and 16-colour background. */
|
|
77
|
-
const CORE = {
|
|
78
|
-
dark: { rgb: "210;142;99", x256: 173, x16: 43 },
|
|
79
|
-
light: { rgb: "169;81;47", x256: 130, x16: 41 },
|
|
80
|
-
};
|
|
81
78
|
/**
|
|
82
|
-
* The
|
|
83
|
-
*
|
|
84
|
-
* foreground is ever set and the C reads on light and dark terminals alike. The second line
|
|
85
|
-
* reverses video so the core's half block takes the copper and its other half the ring.
|
|
79
|
+
* The banner options for the onboard flow: the mark only for `catalyst setup`, and the background
|
|
80
|
+
* asked of the terminal only when the mark will be drawn and both stdin and stdout are terminals.
|
|
86
81
|
*/
|
|
87
|
-
export function
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
?
|
|
93
|
-
:
|
|
94
|
-
|
|
95
|
-
: String(core.x16);
|
|
96
|
-
return [
|
|
97
|
-
`▄▄\u001b[${bg}m▀▀▀▀\u001b[49m▀▀`,
|
|
98
|
-
`▀▀\u001b[7;${bg}m▀▀▀▀\u001b[27;49m▄▄`,
|
|
99
|
-
];
|
|
82
|
+
export async function setupBanner(options) {
|
|
83
|
+
const { setup, env, input, stream, noColor } = options;
|
|
84
|
+
const tty = stream.isTTY === true && options.stdout.isTTY === true;
|
|
85
|
+
const columns = stream.columns && stream.columns > 0 ? stream.columns : DEFAULT_COLUMNS;
|
|
86
|
+
const ask = !markSkipped({ setup, tty, columns, env, noColor }) && input.isTTY === true
|
|
87
|
+
? { input, output: stream }
|
|
88
|
+
: undefined;
|
|
89
|
+
return { mark: setup, stream, noColor, theme: await detectTheme(env, ask) };
|
|
100
90
|
}
|
|
101
|
-
export function createSetupRenderer(stream, env) {
|
|
91
|
+
export function createSetupRenderer(stream, env, banner = {}) {
|
|
102
92
|
let traits = terminalTraits(stream, env);
|
|
103
93
|
const style = (format, text) => traits.color ? styleText(format, text, { validateStream: false }) : text;
|
|
104
94
|
let width = Math.min(traits.columns, 100);
|
|
@@ -252,29 +242,64 @@ export function createSetupRenderer(stream, env) {
|
|
|
252
242
|
refresh();
|
|
253
243
|
ordinary([prefix(textCol) + style("bold", title)]);
|
|
254
244
|
},
|
|
255
|
-
brand(program, version) {
|
|
245
|
+
brand(program, version, identity) {
|
|
256
246
|
if (branded)
|
|
257
|
-
return;
|
|
247
|
+
return false;
|
|
258
248
|
branded = true;
|
|
259
249
|
refresh();
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
250
|
+
const out = banner.stream ?? stream;
|
|
251
|
+
const tty = out.isTTY === true && stream.isTTY === true;
|
|
252
|
+
const columns = tty && out.columns && out.columns > 0 ? out.columns : traits.columns;
|
|
253
|
+
const separator = utf8Locale(env) ? " · " : " ";
|
|
254
|
+
const words = [
|
|
255
|
+
"Catalyst Cloud",
|
|
256
|
+
`${program}${version ? `${separator}${version}` : ""}`,
|
|
257
|
+
...(identity
|
|
258
|
+
? [`user: ${identity.user}`, `workspace: ${identity.workspace}`]
|
|
259
|
+
: []),
|
|
260
|
+
];
|
|
261
|
+
const print = (lines) => out.write(lines.join("\n") + "\n");
|
|
262
|
+
const level = colourLevel(env, { tty, noColor: banner.noColor });
|
|
263
|
+
if (level === "none" ||
|
|
264
|
+
markSkipped({ setup: banner.mark === true, tty, columns, env, noColor: banner.noColor })) {
|
|
265
|
+
// Without the mark the words carry everything, plainly: a screen reader reads blocks aloud.
|
|
266
|
+
print(words.map((w) => prefix(textCol) + w));
|
|
267
|
+
return identity !== undefined;
|
|
265
268
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
// Beside the middle of the mark, 4 columns from it, each cut short with … rather than
|
|
270
|
+
// wrapped under it when the terminal is narrow.
|
|
271
|
+
const textAt = textCol + markSpan() + 4;
|
|
272
|
+
const room = columns - textAt - 1;
|
|
273
|
+
const fit = (text) => {
|
|
274
|
+
if (stringWidth(text) <= room)
|
|
275
|
+
return text;
|
|
276
|
+
// Cut by what the terminal draws: whole graphemes, counted in columns.
|
|
277
|
+
let cut = "";
|
|
278
|
+
for (const { segment } of graphemes.segment(text)) {
|
|
279
|
+
if (stringWidth(cut + segment) > room - 1)
|
|
280
|
+
break;
|
|
281
|
+
cut += segment;
|
|
282
|
+
}
|
|
283
|
+
return `${cut}…`;
|
|
284
|
+
};
|
|
285
|
+
const styled = words.map((w, i) => i === 0 && fit(w) === w ? `\u001b[1m${w}\u001b[22m` : fit(w));
|
|
286
|
+
const mark = pixelNucleusLines(banner.theme ?? envTheme(env) ?? "dark", level);
|
|
287
|
+
const first = Math.floor((mark.length - styled.length) / 2);
|
|
288
|
+
print(mark.map((line, i) => {
|
|
289
|
+
const text = styled[i - first];
|
|
290
|
+
return text
|
|
291
|
+
? `${prefix(textCol)}${line} ${text}`
|
|
292
|
+
: `${prefix(textCol)}${line}`.trimEnd();
|
|
293
|
+
}));
|
|
294
|
+
return identity !== undefined;
|
|
271
295
|
},
|
|
272
296
|
tracker(parts) {
|
|
273
297
|
ordinary(parts.flatMap((p) => stepRows(p.mark, p.number, p.title, p.note)));
|
|
274
298
|
},
|
|
275
299
|
outro(text) {
|
|
276
300
|
abandon();
|
|
277
|
-
|
|
301
|
+
// Wrapped by words like any prose, a link kept whole on its own line when it is too long.
|
|
302
|
+
write(["", ...rows(text, textCol)]);
|
|
278
303
|
},
|
|
279
304
|
plan(number, title, text) {
|
|
280
305
|
ordinary(stepRows("run", number, title, text, true));
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// terminal-background.ts — CTC-4680: is the terminal's background light or dark, so setup's mark
|
|
2
|
+
// takes the brand's light or dark colours. The order: CATALYST_THEME, then COLORFGBG, then asking
|
|
3
|
+
// the terminal (OSC 11), then dark. Asking is the only part that touches the terminal, and it must
|
|
4
|
+
// leave nothing behind: the input's mode is restored, the reply never reaches the first prompt, and
|
|
5
|
+
// a key the person pressed meanwhile is handed back to the input rather than eaten.
|
|
6
|
+
/** CATALYST_THEME=light|dark, then COLORFGBG ("fg;bg", where 7 and 15 are light). Null when
|
|
7
|
+
* neither says. */
|
|
8
|
+
export function envTheme(env) {
|
|
9
|
+
const chosen = (env.CATALYST_THEME ?? "").trim().toLowerCase();
|
|
10
|
+
if (chosen === "light" || chosen === "dark")
|
|
11
|
+
return chosen;
|
|
12
|
+
const bg = (env.COLORFGBG ?? "").split(";").at(-1) ?? "";
|
|
13
|
+
if (!/^[0-9]+$/.test(bg))
|
|
14
|
+
return null;
|
|
15
|
+
return bg === "7" || bg === "15" ? "light" : "dark";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The colour in an OSC 11 reply, `ESC ] 11 ; rgb:RRRR/GGGG/BBBB` ended by BEL or ST. Each part is
|
|
19
|
+
* 1 to 4 hex digits, scaled to 0..1.
|
|
20
|
+
*/
|
|
21
|
+
export function parseOsc11(reply) {
|
|
22
|
+
const m = /\u001b\]11;rgba?:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})/i.exec(reply);
|
|
23
|
+
if (!m)
|
|
24
|
+
return null;
|
|
25
|
+
const scale = (hex) => Number.parseInt(hex, 16) / (16 ** hex.length - 1);
|
|
26
|
+
return [scale(m[1]), scale(m[2]), scale(m[3])];
|
|
27
|
+
}
|
|
28
|
+
/** Light above 0.5 luma (Rec. 709 weights on the colour as sent). */
|
|
29
|
+
export function themeOf(rgb) {
|
|
30
|
+
return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2] > 0.5
|
|
31
|
+
? "light"
|
|
32
|
+
: "dark";
|
|
33
|
+
}
|
|
34
|
+
const OSC11_REPLY = /\u001b\]11;[^\u0007\u001b]*(?:\u0007|\u001b\\)/;
|
|
35
|
+
/** Primary device attributes (DA1). Terminals answer in order and nearly all answer DA1, so once
|
|
36
|
+
* its reply is in, no OSC 11 reply can follow: the query ends there, not at the timeout. */
|
|
37
|
+
const DA1_REPLY = /\u001b\[\?[0-9;]*c/;
|
|
38
|
+
/** Bytes that may be the start of a reply still arriving. */
|
|
39
|
+
const REPLY_START = /^\u001b(?:$|\](?:1(?:1(?:;[^\u0007\u001b]*(?:\u001b)?)?)?)?$|\[(?:\?[0-9;]*)?$)/;
|
|
40
|
+
export const QUERY_TIMEOUT_MS = 150;
|
|
41
|
+
/**
|
|
42
|
+
* After the timeout the answer is dark, but a slow terminal may still reply. For this long the
|
|
43
|
+
* replies are still taken out of the input, so a late one never reaches the shell or the first
|
|
44
|
+
* prompt. It ends sooner when the DA1 reply arrives.
|
|
45
|
+
*/
|
|
46
|
+
export const LATE_MS = 350;
|
|
47
|
+
/** Splits terminal replies out of the input as it arrives; what is left is what the person typed. */
|
|
48
|
+
function replyFilter() {
|
|
49
|
+
let pending = "";
|
|
50
|
+
return {
|
|
51
|
+
/** What is held back as a possible reply start, emptied. */
|
|
52
|
+
release() {
|
|
53
|
+
const held = pending;
|
|
54
|
+
pending = "";
|
|
55
|
+
return held;
|
|
56
|
+
},
|
|
57
|
+
/** Adds `text`; returns the keys in it and whether DA1 (the last reply) is in. */
|
|
58
|
+
take(text) {
|
|
59
|
+
pending += text;
|
|
60
|
+
let osc = null;
|
|
61
|
+
let answered = false;
|
|
62
|
+
for (;;) {
|
|
63
|
+
const reply = OSC11_REPLY.exec(pending);
|
|
64
|
+
if (reply) {
|
|
65
|
+
const rgb = parseOsc11(reply[0]);
|
|
66
|
+
if (rgb)
|
|
67
|
+
osc = themeOf(rgb);
|
|
68
|
+
pending = pending.slice(0, reply.index) + pending.slice(reply.index + reply[0].length);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const da1 = DA1_REPLY.exec(pending);
|
|
72
|
+
if (!da1)
|
|
73
|
+
break;
|
|
74
|
+
pending = pending.slice(0, da1.index) + pending.slice(da1.index + da1[0].length);
|
|
75
|
+
answered = true;
|
|
76
|
+
}
|
|
77
|
+
// Whatever cannot be the start of a reply is a key; after DA1 nothing is a reply.
|
|
78
|
+
let keep = pending.length;
|
|
79
|
+
if (!answered)
|
|
80
|
+
for (let i = pending.indexOf("\u001b"); i !== -1; i = pending.indexOf("\u001b", i + 1))
|
|
81
|
+
if (REPLY_START.test(pending.slice(i))) {
|
|
82
|
+
keep = i;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
const keys = pending.slice(0, keep);
|
|
86
|
+
pending = pending.slice(keep);
|
|
87
|
+
return { keys, osc, answered };
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const text = (chunk) => typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("latin1");
|
|
92
|
+
/**
|
|
93
|
+
* Ask the terminal for its background (OSC 11, then DA1 as the end marker). Resolves to the theme,
|
|
94
|
+
* or null when the terminal said nothing usable within the timeout.
|
|
95
|
+
*
|
|
96
|
+
* Raw mode is on only while this function is the input's reader; the input's own mode and flow are
|
|
97
|
+
* restored after. Keys typed meanwhile go back to the input for its next reader, except Ctrl-C,
|
|
98
|
+
* which raw mode would otherwise swallow: it ends the query and is raised as an interrupt. After
|
|
99
|
+
* the timeout, a late reply is still taken out for LATE_MS. When something else starts reading in
|
|
100
|
+
* that time (the first prompt), the replies are taken out of the data it receives instead.
|
|
101
|
+
*/
|
|
102
|
+
export function queryBackground(input, output, timeoutMs = QUERY_TIMEOUT_MS, interrupt = () => process.kill(process.pid, "SIGINT")) {
|
|
103
|
+
if (input.isTTY !== true || typeof input.setRawMode !== "function")
|
|
104
|
+
return Promise.resolve(null);
|
|
105
|
+
const wasRaw = input.isRaw === true;
|
|
106
|
+
// A stream nobody reads yet (readableFlowing null) must not be left flowing: with no listener,
|
|
107
|
+
// a late byte or a handed-back key would be emitted to nobody. Readers resume it themselves.
|
|
108
|
+
const wasFlowing = input.readableFlowing === true;
|
|
109
|
+
const filter = replyFilter();
|
|
110
|
+
const ownEmit = input.emit;
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
let typed = "";
|
|
113
|
+
let theme = null;
|
|
114
|
+
let settled = false;
|
|
115
|
+
let reading = true; // this function is the input's only reader
|
|
116
|
+
let done = false;
|
|
117
|
+
let timer;
|
|
118
|
+
const settle = () => {
|
|
119
|
+
if (!settled) {
|
|
120
|
+
settled = true;
|
|
121
|
+
resolve(theme);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/** Stop being the reader: listener off, mode and flow back, typed keys back, followed by any
|
|
125
|
+
* held bytes in the order they came (the filter on the prompt's data holds them again). */
|
|
126
|
+
const stopReading = () => {
|
|
127
|
+
if (!reading)
|
|
128
|
+
return;
|
|
129
|
+
reading = false;
|
|
130
|
+
input.off("data", onData);
|
|
131
|
+
input.off("newListener", onReader);
|
|
132
|
+
try {
|
|
133
|
+
input.setRawMode(wasRaw);
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
if (!wasFlowing)
|
|
137
|
+
input.pause?.();
|
|
138
|
+
const back = typed + filter.release();
|
|
139
|
+
if (back && input.unshift)
|
|
140
|
+
input.unshift(Buffer.from(back, "latin1"));
|
|
141
|
+
typed = "";
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const end = () => {
|
|
145
|
+
if (done)
|
|
146
|
+
return;
|
|
147
|
+
done = true;
|
|
148
|
+
if (timer)
|
|
149
|
+
clearTimeout(timer);
|
|
150
|
+
// A lone Esc still held at the end was a key, not the start of a reply that never came.
|
|
151
|
+
const esc = filter.release() === "\u001b";
|
|
152
|
+
const wasReading = reading;
|
|
153
|
+
if (esc && wasReading)
|
|
154
|
+
typed += "\u001b";
|
|
155
|
+
stopReading();
|
|
156
|
+
input.emit = ownEmit;
|
|
157
|
+
if (esc && !wasReading)
|
|
158
|
+
input.unshift?.(Buffer.from("\u001b"));
|
|
159
|
+
settle();
|
|
160
|
+
};
|
|
161
|
+
const onData = (chunk) => {
|
|
162
|
+
const { keys, osc, answered } = filter.take(text(chunk));
|
|
163
|
+
if (osc && !settled)
|
|
164
|
+
theme = osc;
|
|
165
|
+
typed += keys;
|
|
166
|
+
if (typed.includes("\u0003")) {
|
|
167
|
+
typed = typed.replaceAll("\u0003", "");
|
|
168
|
+
end();
|
|
169
|
+
interrupt();
|
|
170
|
+
}
|
|
171
|
+
else if (answered)
|
|
172
|
+
end();
|
|
173
|
+
};
|
|
174
|
+
// A prompt starting to read during the late wait: hand it the input, and take the replies out
|
|
175
|
+
// of the data it is given until the wait ends.
|
|
176
|
+
const onReader = (event) => {
|
|
177
|
+
if (event !== "data" && event !== "keypress" && event !== "readable")
|
|
178
|
+
return;
|
|
179
|
+
input.emit = function (event, ...args) {
|
|
180
|
+
if (event !== "data")
|
|
181
|
+
return ownEmit.call(input, event, ...args);
|
|
182
|
+
const { keys, answered } = filter.take(text(args[0]));
|
|
183
|
+
if (answered)
|
|
184
|
+
end();
|
|
185
|
+
if (!keys)
|
|
186
|
+
return true;
|
|
187
|
+
return ownEmit.call(input, "data", typeof args[0] === "string" ? keys : Buffer.from(keys, "latin1"));
|
|
188
|
+
};
|
|
189
|
+
stopReading();
|
|
190
|
+
};
|
|
191
|
+
input.on("data", onData);
|
|
192
|
+
try {
|
|
193
|
+
input.setRawMode(true);
|
|
194
|
+
output.write("\u001b]11;?\u0007\u001b[c");
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
end();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (done)
|
|
201
|
+
return;
|
|
202
|
+
input.on("newListener", onReader);
|
|
203
|
+
timer = setTimeout(() => {
|
|
204
|
+
settle();
|
|
205
|
+
timer = setTimeout(end, LATE_MS);
|
|
206
|
+
}, timeoutMs);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The background, in order: CATALYST_THEME, COLORFGBG, the terminal's own answer (only when
|
|
211
|
+
* `ask` holds), then dark.
|
|
212
|
+
*/
|
|
213
|
+
export async function detectTheme(env, ask, timeoutMs = QUERY_TIMEOUT_MS) {
|
|
214
|
+
const known = envTheme(env);
|
|
215
|
+
if (known)
|
|
216
|
+
return known;
|
|
217
|
+
if (!ask)
|
|
218
|
+
return "dark";
|
|
219
|
+
return (await queryBackground(ask.input, ask.output, timeoutMs)) ?? "dark";
|
|
220
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Catalyst's GitHub: show a ticket's pull request with its checks, reviews and review threads, say whether it is mergeable under this repository's policy, and explain what a PR accumulates as the ticket moves (the branch, the draft, the rewrite, the force-pushes, the labels, the queue). Use when someone asks "show me the PR", "what are the checks saying", "why hasn't it merged", "what does the queue need", "what does that label mean", or wants the branch and merge conventions Catalyst follows.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Catalyst's GitHub
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Catalyst's view of Linear on the customer's own cloud account. Reads a ticket with its comments, relations, labels, linked pull requests and agent sessions inline, from the cloud API by default, with local replica reads available as an explicit opt-in, always naming the source; searches tickets, PRs, projects and initiatives; writes comments, card moves, labels and new tickets through the account's agent proxy as the app actor, with every route, stage id, label id and marker read from the account's contract. Knows what a ticket accumulates as Catalyst works it (phase-outcome comments, the document per phase, the agent session, the labels, the single blocks relation, the bookkeeping marker, the eyes acknowledgement). Use when a person says "show me the ticket", "what did Catalyst write on it", "comment on it", "move it", "label it" or "file a ticket". Not for raising a decision for a human (what-needs-me) and not for pull requests (catalyst-github).
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Catalyst Linear
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Set up Catalyst Cloud and say whether setup is working. Walks a person from nothing to their first ticket running, one step at a time: the coding account, the project, the integrations and connected accounts, each repository's settings file, then one real ticket moving. Also logs this machine in, reads the readiness verdict with who can fix each failure, and checks the optional local replica. Use when someone says "set me up", "onboard me", "I just signed up", "get me started", "what do I do first", "log me in", "which account is this machine on", "am I set up", "what is missing", "why does nothing happen" or "is the replica running", when a login expired, or when a skill script exits 2 saying this machine is not connected. Does every step a key can do through the catalyst CLI, hands over the exact page for the steps only a browser can do, and never claims a step it did not watch succeed.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Onboard me
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Own one Catalyst Cloud project end to end until it closes. Use when the person says "run this project for me", "own this until it ships", "keep this moving", or hands you a project id or a set of tickets to drive. Subscribes to the account's event stream for the scope through the catalyst CLI, reacts to each change in the same turn, makes tickets ready and moves them to dispatch, parks what should stop, chases stalls, escalates inward, and keeps one status summary current. Writes to Linear as the app actor; never polls.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Run this project
|
|
10
10
|
|
package/skills/unstick/SKILL.md
CHANGED
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Get a stuck Catalyst Cloud ticket moving again. Use when the person asks "why is this parked and can you release it?", "unpark this", "get things flowing again", "the outage is over, retry what failed", or hands you a ticket that is not moving. Reads why nothing runs and what holds the ticket through the catalyst CLI, decides whether the recorded cause is fixed, previews the release, releases every governor holding the ticket the right way (or one failure class across a team), and raises an ask only for what a person has to do. Never releases a cause it cannot show changed without saying so.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Unstick
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
The human's decision inbox on Catalyst Cloud, and the one way an agent raises a decision on their behalf. Use when the person asks "what needs me?", "what am I blocking?", or when active work is gated on a choice only they can make. Lists open asks ranked by how much open work each one holds, files an ask through the cloud's ask route with the account's own template, and records the answer so the held work releases. Never answers as the human, never duplicates an open ask.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What needs me
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
What environment variable names does this repository need, and where does each one come from? Scans the repository offline (no login, no network) and lists the names in three groups (build/test, deploy-only, bindings), each with where it was found, what uses it, and where a local value would come from. Never reads a value or prints one. Also checks the environment variable table in `.catalyst/catalyst.toml` offline. Use when someone asks "what does catalyst.env.json mean", "what env vars does this repo need", "why does the container need this", or before reviewing or writing the declaration.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What this repository needs
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Use for "what's happening?", "where are we?", "why is that stuck?", "what closed?", "what's next?", "how does this work?", "why did it do that?", "how does it prioritise?" and "what does this setting do, where is it set?" in Catalyst Cloud, or asks for something to be done rather than known. Reads the contract via catalyst CLI. Read-only: route work/decisions, never answer as the human.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.15.5 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What's happening
|
|
10
10
|
|