@catalyst-cloud/cli 0.15.2 → 0.15.4
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 +13 -0
- package/README.md +4 -2
- package/dist/args.js +5 -1
- package/dist/cli.js +44 -20
- package/dist/oauth.js +1 -1
- package/dist/onboard-accounts.js +67 -171
- package/dist/onboard-checklist.js +310 -0
- package/dist/onboard-existing.js +1 -1
- package/dist/onboard-first-ticket.js +199 -0
- package/dist/onboard-headless.js +2 -2
- package/dist/onboard-housekeeping.js +93 -0
- package/dist/onboard-next.js +108 -9
- package/dist/onboard-ready.js +61 -0
- package/dist/onboard-runtime.js +60 -27
- package/dist/onboard-standalone-copy.js +73 -66
- package/dist/onboard-ui.js +278 -105
- package/dist/onboard-values.js +47 -0
- package/dist/onboard.js +63 -18
- package/dist/ready-copy.js +87 -0
- package/dist/ready.js +1 -57
- package/dist/setup-brand.js +202 -0
- package/dist/setup-onboard-copy.js +314 -42
- package/dist/setup-render.js +99 -17
- package/dist/setup.js +6 -3
- 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 +3 -3
- package/skills/catalyst-onboard/references/replacing-a-credential.md +9 -15
- package/skills/catalyst-onboard/references/what-a-phase-needs.md +4 -11
- package/skills/catalyst-onboard/scripts/where-am-i.mjs +1 -1
- package/skills/run-this-project/SKILL.md +2 -2
- 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 +2 -2
- package/skills/whats-happening/references/coding-accounts.md +1 -1
- package/skills/whats-happening/scripts/snapshot.mjs +1 -1
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 || "");
|
|
@@ -60,6 +63,7 @@ const ASCII_MARKS = {
|
|
|
60
63
|
later: "[later]",
|
|
61
64
|
run: "[..]",
|
|
62
65
|
ask: "[?]",
|
|
66
|
+
now: "[next]",
|
|
63
67
|
};
|
|
64
68
|
const UNICODE_MARKS = {
|
|
65
69
|
done: ["✓", "green"],
|
|
@@ -69,8 +73,22 @@ const UNICODE_MARKS = {
|
|
|
69
73
|
later: ["·", "gray"],
|
|
70
74
|
run: ["◐", "cyan"],
|
|
71
75
|
ask: ["◆", "cyan"],
|
|
76
|
+
now: ["◆", "cyan"],
|
|
72
77
|
};
|
|
73
|
-
|
|
78
|
+
/**
|
|
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.
|
|
81
|
+
*/
|
|
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) };
|
|
90
|
+
}
|
|
91
|
+
export function createSetupRenderer(stream, env, banner = {}) {
|
|
74
92
|
let traits = terminalTraits(stream, env);
|
|
75
93
|
const style = (format, text) => traits.color ? styleText(format, text, { validateStream: false }) : text;
|
|
76
94
|
let width = Math.min(traits.columns, 100);
|
|
@@ -85,12 +103,14 @@ export function createSetupRenderer(stream, env) {
|
|
|
85
103
|
const visible = (text) => text
|
|
86
104
|
.replace(/\u001b\]8;;[^\u001b]*\u001b\\/g, "")
|
|
87
105
|
.replace(/\u001b\[[0-9;]*m/g, "");
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const
|
|
106
|
+
// CTC-4680 (round 2): headings and prose at column 2, step rows at 4, and their details 4 more,
|
|
107
|
+
// at 8, so the eye doesn't travel across a small screen to read them. No rail: the same columns
|
|
108
|
+
// on a terminal and in a pipe.
|
|
109
|
+
const textCol = 2;
|
|
110
|
+
const rowCol = 4;
|
|
111
|
+
const titleCol = rowCol + 4;
|
|
112
|
+
const outcomeCol = rowCol + (traits.unicode ? 38 : 43);
|
|
113
|
+
const prefix = (col) => " ".repeat(col);
|
|
94
114
|
const mark = (kind) => {
|
|
95
115
|
if (!traits.unicode)
|
|
96
116
|
return ASCII_MARKS[kind];
|
|
@@ -111,9 +131,7 @@ export function createSetupRenderer(stream, env) {
|
|
|
111
131
|
.map((line) => {
|
|
112
132
|
const plain = visible(line);
|
|
113
133
|
const indent = /^https?:\/\/\S+$/.test(plain) && stringWidth(plain) > width - col
|
|
114
|
-
?
|
|
115
|
-
? 3
|
|
116
|
-
: 0
|
|
134
|
+
? textCol
|
|
117
135
|
: col;
|
|
118
136
|
return prefix(indent) + line;
|
|
119
137
|
});
|
|
@@ -122,13 +140,13 @@ export function createSetupRenderer(stream, env) {
|
|
|
122
140
|
refresh();
|
|
123
141
|
const lead = plan
|
|
124
142
|
? traits.unicode
|
|
125
|
-
? "
|
|
143
|
+
? " "
|
|
126
144
|
: " "
|
|
127
145
|
: traits.unicode
|
|
128
146
|
? mark(kind)
|
|
129
147
|
: mark(kind).padEnd(7);
|
|
130
148
|
const titleWidth = stringWidth(visible(title));
|
|
131
|
-
const label = `${lead}${traits.unicode ? " " : " "}${String(number || "").padStart(2)} ${title}`;
|
|
149
|
+
const label = `${prefix(rowCol)}${lead}${traits.unicode ? " " : " "}${String(number || "").padStart(2)} ${title}`;
|
|
132
150
|
if (!outcome)
|
|
133
151
|
return [label];
|
|
134
152
|
if (width < 80 || titleWidth > 30)
|
|
@@ -214,6 +232,7 @@ export function createSetupRenderer(stream, env) {
|
|
|
214
232
|
clear();
|
|
215
233
|
abandon();
|
|
216
234
|
};
|
|
235
|
+
let branded = false;
|
|
217
236
|
const r = {
|
|
218
237
|
get traits() {
|
|
219
238
|
refresh();
|
|
@@ -221,11 +240,66 @@ export function createSetupRenderer(stream, env) {
|
|
|
221
240
|
},
|
|
222
241
|
intro(title) {
|
|
223
242
|
refresh();
|
|
224
|
-
ordinary([
|
|
243
|
+
ordinary([prefix(textCol) + style("bold", title)]);
|
|
244
|
+
},
|
|
245
|
+
brand(program, version, identity) {
|
|
246
|
+
if (branded)
|
|
247
|
+
return false;
|
|
248
|
+
branded = true;
|
|
249
|
+
refresh();
|
|
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;
|
|
268
|
+
}
|
|
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;
|
|
295
|
+
},
|
|
296
|
+
tracker(parts) {
|
|
297
|
+
ordinary(parts.flatMap((p) => stepRows(p.mark, p.number, p.title, p.note)));
|
|
225
298
|
},
|
|
226
299
|
outro(text) {
|
|
227
300
|
abandon();
|
|
228
|
-
|
|
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)]);
|
|
229
303
|
},
|
|
230
304
|
plan(number, title, text) {
|
|
231
305
|
ordinary(stepRows("run", number, title, text, true));
|
|
@@ -318,14 +392,22 @@ export function createSetupRenderer(stream, env) {
|
|
|
318
392
|
},
|
|
319
393
|
heading(text) {
|
|
320
394
|
abandon();
|
|
321
|
-
write(
|
|
395
|
+
write(["", prefix(textCol) + style("bold", text)]);
|
|
322
396
|
},
|
|
323
397
|
line(text) {
|
|
324
|
-
ordinary(rows(text,
|
|
398
|
+
ordinary(rows(text, textCol));
|
|
399
|
+
},
|
|
400
|
+
item(label, text) {
|
|
401
|
+
const col = textCol + stringWidth(label);
|
|
402
|
+
const lines = rows(text, col);
|
|
403
|
+
const hang = prefix(col);
|
|
404
|
+
ordinary(lines[0].startsWith(hang)
|
|
405
|
+
? [prefix(textCol) + label + lines[0].slice(col), ...lines.slice(1)]
|
|
406
|
+
: [prefix(textCol) + label.trimEnd(), ...lines]);
|
|
325
407
|
},
|
|
326
408
|
blank() {
|
|
327
409
|
refresh();
|
|
328
|
-
ordinary([
|
|
410
|
+
ordinary([""]);
|
|
329
411
|
},
|
|
330
412
|
link(url) {
|
|
331
413
|
return traits.links
|
package/dist/setup.js
CHANGED
|
@@ -19,6 +19,7 @@ import { Readable, Writable } from "node:stream";
|
|
|
19
19
|
import { VERB_USAGE } from "./args.js";
|
|
20
20
|
import { plainSetupLine, SetupEventStream, } from "./setup-events.js";
|
|
21
21
|
import { createSetupRenderer, } from "./setup-render.js";
|
|
22
|
+
import { setupPartHeading } from "./setup-onboard-copy.js";
|
|
22
23
|
const MACHINE_TITLES = {
|
|
23
24
|
1: "Install the catalyst command",
|
|
24
25
|
2: "Add the Catalyst skills",
|
|
@@ -107,7 +108,7 @@ function planRenderer(r) {
|
|
|
107
108
|
},
|
|
108
109
|
more(text) {
|
|
109
110
|
if (!hidden)
|
|
110
|
-
r.line(`
|
|
111
|
+
r.line(` ${text}`);
|
|
111
112
|
},
|
|
112
113
|
close() {
|
|
113
114
|
open = false;
|
|
@@ -238,7 +239,9 @@ async function runEngine(engine, args, flags, ctx, deps) {
|
|
|
238
239
|
}
|
|
239
240
|
if (!deps.onboard ||
|
|
240
241
|
!["What’s left", "What\'s left"].includes(event.text))
|
|
241
|
-
r.heading(event.text === "Setting up"
|
|
242
|
+
r.heading(event.text === "Setting up"
|
|
243
|
+
? setupPartHeading(1, r.traits.unicode)
|
|
244
|
+
: event.text);
|
|
242
245
|
return;
|
|
243
246
|
case "plan":
|
|
244
247
|
plan.plan(event.number, event.title, event.text);
|
|
@@ -399,7 +402,7 @@ async function runEngine(engine, args, flags, ctx, deps) {
|
|
|
399
402
|
return await deps.onboard(r, flags);
|
|
400
403
|
}
|
|
401
404
|
catch {
|
|
402
|
-
errors.line("catalyst setup: onboarding could not finish. Run catalyst
|
|
405
|
+
errors.line("catalyst setup: onboarding could not finish. Run catalyst setup to try again.");
|
|
403
406
|
if (flags.json)
|
|
404
407
|
deps.writeJson(`${JSON.stringify({ schema: "catalyst-install-last-run/1", state: "failed", exitCode: 10, steps: [] })}\n`);
|
|
405
408
|
return 10;
|
|
@@ -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.4 — 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.4 — 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.4 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Onboard me
|
|
10
10
|
|
|
@@ -14,9 +14,9 @@ Guide setup through the same `catalyst onboard` flow that the installer runs. Th
|
|
|
14
14
|
|
|
15
15
|
1. Run `catalyst capabilities --json`. If its `onboard` entry is available and advertises `bootstrapHandoff: true`, use this path. If absent, use the older step-by-step references below and name the CLI update needed for the continuous flow.
|
|
16
16
|
2. For a requested setup, run `catalyst onboard`. To inspect first, run `catalyst onboard --dry-run --json`. Resume with `catalyst onboard`; the command rechecks saved results. Do not ask the person to confirm completed browser steps or add a separate approval before the command's plan question.
|
|
17
|
-
3. In a terminal, the command shows the verified person, workspace and plan before approval. Without terminal input, or with `--json`, use `--yes` only when the person has accepted the displayed defaults; otherwise setup waits with exit 11 and keeps the saved connection and receipt. JSON keeps progress, identity
|
|
17
|
+
3. In a terminal, the command shows the verified person, workspace and plan before approval. Without terminal input, or with `--json`, use `--yes` only when the person has accepted the displayed defaults; otherwise setup waits with exit 11 and keeps the saved connection and receipt. JSON keeps progress, identity and the plan on stderr and returns one result on stdout. A supplied key needs `catalyst login` before onboarding; browser sign-in does not replace it.
|
|
18
18
|
4. For the current onboarding checks, run `catalyst ready --onboarding --json`. A failed check needs attention. An unknown check needs evidence. Report observed project work separately from incomplete setup; an unknown setup check does not prove work stopped.
|
|
19
|
-
5. Exit 0 completes the requested scope. For a full run, exit 0 means work can start. If the receipt's `complete` is false, repository
|
|
19
|
+
5. Exit 0 completes the requested scope. For a full run, exit 0 means work can start. If the receipt's `complete` is false, a repository value or the first ticket is still open, and the command lists it under "Next, when you want". The daily update never keeps `complete` false, and neither do repository settings this computer cannot review (no checkout here, or not yet approved); a settings review that timed out or could not keep its draft does. Only a person at a terminal picks the first ticket; `--yes`, `--json` and headless runs leave it waiting with an action. Exit 10 means a failed step, 11 means waiting, and 12 means a guard refused the action. A successful `--only` step does not mean onboarding is complete. Keep the command's safe fix and supported resume command in your reply.
|
|
20
20
|
|
|
21
21
|
Use cloud reads for ordinary workstation setup checks. Offer local sync for local SQL or sustained local reads inside the plan review. Local sync does not promise offline browsing. It is optional; do not make an absent replica a setup failure. Browser approval belongs to the person. Missing bearer capabilities stay unfinished; never call a session-only route from the CLI or invent a command.
|
|
22
22
|
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
# Replacing
|
|
1
|
+
# Replacing an AI account's credential
|
|
2
2
|
|
|
3
3
|
When the script prints "<provider> account <slot> needs a new credential" (quarantined, expired, revoked, or three or more polls failed on the credential), replace that account's credential on its own page. Do not enroll a second account. It would be a duplicate beside the dead one. A workspace owner or admin does it in the browser, from the link the script prints; the person copies and pastes the credential, and you never read, print or paste it.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## The steps
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
For an API key, billed per token by its provider:
|
|
8
8
|
|
|
9
|
-
1.
|
|
10
|
-
2.
|
|
11
|
-
3.
|
|
12
|
-
4.
|
|
9
|
+
1. The person creates a new key in the provider's console, under the same provider account the AI account was made from.
|
|
10
|
+
2. In the browser, they open Settings → AI accounts, then that account.
|
|
11
|
+
3. They paste the new key into the replacement field and press Replace credential.
|
|
12
|
+
4. Once the account reads healthy, they can revoke the old key in the provider's console if nothing else uses it.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
If the account's page asks for something other than a key, follow the steps the page shows. When the page names the login the account belongs to, the new credential must come from that same login: one from another login would put a live account onto the wrong record. If a tool on the person's machine mints the credential, have them confirm it is signed in to the login the page names before minting; such tools mint for whoever is signed in, not for the account. When the page says Catalyst takes over the login, say so before the paste, and that the person signs in again locally afterwards.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
The field is "Replacement setup token". `claude setup-token` mints a token for whichever account the terminal is logged into, not for the slot, so match them first: compare the slot's email on the AI accounts page with what `/status` in `claude` shows, and log in to the slot's account if they differ. Then run `claude setup-token`, paste the token, and press Replace credential.
|
|
19
|
-
|
|
20
|
-
## Any other provider
|
|
21
|
-
|
|
22
|
-
The same page, with the credential it asks for. A cancelled or ended account is not a credential problem, and no token revives it.
|
|
16
|
+
A cancelled or ended account is not a credential problem, and no new credential revives it.
|
|
23
17
|
|
|
24
18
|
## Afterwards
|
|
25
19
|
|
|
@@ -4,20 +4,13 @@ A phase needs the `coding accounts` and `host` parts of `node scripts/where-am-i
|
|
|
4
4
|
|
|
5
5
|
## Coding accounts
|
|
6
6
|
|
|
7
|
-
One coding account is enough to start. A second
|
|
7
|
+
One coding account is enough to start. A second gives the router somewhere to go at a limit; offer it later.
|
|
8
8
|
|
|
9
9
|
### The kinds, and enrolling
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
| -- | -- | -- |
|
|
13
|
-
| "Claude Pro or Max", "I use Claude Code" | Claude setup token | what `claude setup-token` prints, after `/status` in `claude` shows the account they mean |
|
|
14
|
-
| "ChatGPT", "Codex" | Codex auth file | `~/.codex/auth.json` after `codex login` (steps in `references/replacing-a-credential.md`) |
|
|
15
|
-
| "a GLM key", "Z.ai" | GLM API key | the key from the provider's console |
|
|
16
|
-
| "a Qwen key", "Alibaba Model Studio" | Qwen API key | the key from the provider's console |
|
|
17
|
-
|
|
18
|
-
A plain Anthropic or OpenAI API key cannot be enrolled; say so and ask whether they have one of these. Before a Codex paste, say Catalyst takes over that login: its refresh token is single-use, so they sign in to Codex again locally afterwards.
|
|
11
|
+
Settings → AI accounts lists the providers this workspace can connect and what each one asks for; an API key is billed per token by its provider. Do not promise a provider. Ask the person to open Settings → AI accounts and choose from the providers it lists; if the one they name is not there, say so and ask whether they have a key from one that is.
|
|
19
12
|
|
|
20
|
-
Enrolling is a browser step by construction: on Settings → AI accounts, an owner or admin picks the provider, labels the account, and pastes the
|
|
13
|
+
Enrolling is a browser step by construction: on Settings → AI accounts, an owner or admin picks the provider, labels the account, and pastes the key into a write-only field. If the page says Catalyst takes over a login, say so before the paste. Call an account by its label, else its email, else its slot (`displayName` in `catalyst accounts --json`).
|
|
21
14
|
|
|
22
15
|
### The states
|
|
23
16
|
|
|
@@ -30,7 +23,7 @@ Enrolling is a browser step by construction: on Settings → AI accounts, an own
|
|
|
30
23
|
| `inactive` | every account is out of rotation | reactivate one on its page, never enrol another |
|
|
31
24
|
| `unread` | the cloud could not read them | it is not "no accounts"; read again later |
|
|
32
25
|
|
|
33
|
-
**A cancelled or ended account** stays for reporting, unused, and does not hold setup up; say so in one clause. It keeps its own login: a token from another login would put a live account onto a dead slot. It stays enrolled rather than retired or deleted, and
|
|
26
|
+
**A cancelled or ended account** stays for reporting, unused, and does not hold setup up; say so in one clause. It keeps its own login: a token from another login would put a live account onto a dead slot. It stays enrolled rather than retired or deleted, and is reactivated on its page only if it can run again.
|
|
34
27
|
|
|
35
28
|
## Host
|
|
36
29
|
|
|
@@ -753,7 +753,7 @@ if (!connected) {
|
|
|
753
753
|
retirable.length === 0
|
|
754
754
|
? []
|
|
755
755
|
: [
|
|
756
|
-
`${retirable.length} account(s) cancelled or ended (${retirable.map((a) => `${who(a) ?? a.displayName ?? a.accountSlot ?? "?"} (${a.provider ?? "unknown provider"})`).join(", ")}): kept for reporting, not used, and not counted here. Never replace their credential; reactivate one on the AI accounts page only if
|
|
756
|
+
`${retirable.length} account(s) cancelled or ended (${retirable.map((a) => `${who(a) ?? a.displayName ?? a.accountSlot ?? "?"} (${a.provider ?? "unknown provider"})`).join(", ")}): kept for reporting, not used, and not counted here. Never replace their credential; reactivate one on the AI accounts page only if it can run again.`,
|
|
757
757
|
];
|
|
758
758
|
retireNote = retireLine[0] ?? null;
|
|
759
759
|
if (rows === null) {
|
|
@@ -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.4 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Run this project
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ You are the steward: the single-threaded owner of ONE project or ticket set unti
|
|
|
15
15
|
Scripts are run, never read. Each prints `--help`, and exits 2 when this machine is not connected (`catalyst login`), 1 when its own check fails.
|
|
16
16
|
|
|
17
17
|
1. `node scripts/scope-status.mjs --project <id>` (or `--team <key>`): tickets by stage, what is running and queued in scope, and stalls against the local policy. Run it to take the scope, and again after a resync.
|
|
18
|
-
2. `node scripts/watch-scope.mjs --project <id>`: the
|
|
18
|
+
2. `node scripts/watch-scope.mjs --project <id>`: the live watch. In Claude Code, arm a monitor on it and react to each printed line in the same turn; elsewhere add `--exec <command>` so a reaction runs per frame.
|
|
19
19
|
3. `node scripts/make-ready.mjs <ticket>` dispatches; `--park` stops; `--note <why>` records it.
|
|
20
20
|
4. `catalyst explain <ticket>` whenever a ticket is not moving.
|
|
21
21
|
|
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.4 — 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.4 — 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.4 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What this repository needs
|
|
10
10
|
|