@catalyst-cloud/cli 0.15.3 → 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 +6 -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-ui.js +127 -27
- package/dist/onboard.js +14 -5
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.4
|
|
4
|
+
|
|
5
|
+
- Setup shows a colour mark and clearer progress, with a plain display when your terminal needs it.
|
|
6
|
+
- Setup separates your next steps from tasks waiting on an owner or admin, and reports when it stops waiting for an account connection.
|
|
7
|
+
- Setup wraps long text by words and keeps numbered steps in order.
|
|
8
|
+
|
|
3
9
|
## 0.15.3
|
|
4
10
|
|
|
5
11
|
- Setup can finish once the steps needed to run work are ready. It lists optional next steps and keeps your first-ticket choice when you resume.
|
package/README.md
CHANGED
|
@@ -133,6 +133,8 @@ catalyst onboard
|
|
|
133
133
|
catalyst ready --onboarding --json
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
`catalyst setup` opens with the Catalyst Cloud mark in your terminal's colours. It asks the terminal whether its background is light or dark; set `CATALYST_THEME=light` or `CATALYST_THEME=dark` when it guesses wrong. `--no-color` or `NO_COLOR` prints plain text without the mark.
|
|
137
|
+
|
|
136
138
|
The dry run writes no files. `--only <step>` runs one step and reports its scope separately from full onboarding. Exit 10 means a failed step, 11 means waiting, and 12 means a guard refused the action. The private receipt is `install/last-run.json` under your machine's Catalyst state directory; credentials stay in the login config. A fake HOME reports old services and keeps them intact.
|
|
137
139
|
|
|
138
140
|
### Headless setup (CI, image builds, agent VMs)
|
package/dist/args.js
CHANGED
|
@@ -64,6 +64,10 @@ export const FLAG_TABLES = {
|
|
|
64
64
|
value: false,
|
|
65
65
|
help: "do not run Catalyst's work on this machine, and do not ask",
|
|
66
66
|
},
|
|
67
|
+
"no-color": {
|
|
68
|
+
value: false,
|
|
69
|
+
help: "print setup in plain text, without colour or the Catalyst Cloud mark",
|
|
70
|
+
},
|
|
67
71
|
"resume-from": {
|
|
68
72
|
value: true,
|
|
69
73
|
help: "resume at a verified onboarding step",
|
|
@@ -459,7 +463,7 @@ export const FLAG_TABLES = {
|
|
|
459
463
|
export const VERB_USAGE = {
|
|
460
464
|
setup: "setup [onboard options] (sets up Catalyst step by step; same as catalyst onboard) | setup --engine <file> --engine-sha256 <hex> [-- <install options>] (run by install.sh; install.sh --help lists the options)",
|
|
461
465
|
login: "login [--base-url <url>] [--start-replica] (keyless; or --key <personal-key> / CATALYST_CLOUD_TOKEN)",
|
|
462
|
-
onboard: "onboard [--team <ID|key>] [--repo <owner/name>]... [--coding-account <slot>] [--resume-from <step>] [--only <step>] [--local-sync] [--runner|--no-runner] [--yes] [--dry-run] [--json] | onboard --headless [--key-file <path>] [--team ...] [--repo ...]... [--coding-account ...] [--runner yes|no] [--json]",
|
|
466
|
+
onboard: "onboard [--team <ID|key>] [--repo <owner/name>]... [--coding-account <slot>] [--resume-from <step>] [--only <step>] [--local-sync] [--runner|--no-runner] [--no-color] [--yes] [--dry-run] [--json] | onboard --headless [--key-file <path>] [--team ...] [--repo ...]... [--coding-account ...] [--runner yes|no] [--json]",
|
|
463
467
|
install: "install [--skills-dir <dir>] [--force]",
|
|
464
468
|
status: "status",
|
|
465
469
|
notice: "notice",
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// cli.ts — the `catalyst` dispatcher (npm: @catalyst-cloud/cli). Verbs live in
|
|
2
2
|
// their own modules; this file keeps every export the 0.1 tests and the bin import.
|
|
3
|
-
import { createSetupRenderer } from "./setup-render.js";
|
|
3
|
+
import { createSetupRenderer, setupBanner, } from "./setup-render.js";
|
|
4
4
|
import { existsSync, openSync, closeSync } from "node:fs";
|
|
5
5
|
import { ReadStream as TerminalInput } from "node:tty";
|
|
6
6
|
import { Writable } from "node:stream";
|
|
@@ -210,6 +210,7 @@ export async function main(argv, ctx = defaultCtx(), deps = {}) {
|
|
|
210
210
|
// CTC-4625: setup passes the install options through to its engine untouched, so they never meet
|
|
211
211
|
// this CLI's own flag tables. CTC-4680: without --engine, `setup` is the name a person types for
|
|
212
212
|
// the onboard flow, so it runs exactly that.
|
|
213
|
+
const viaSetup = drawsMark(argv);
|
|
213
214
|
if (argv[0] === "setup") {
|
|
214
215
|
const rest = argv.slice(1);
|
|
215
216
|
const own = rest.indexOf("--") === -1 ? rest : rest.slice(0, rest.indexOf("--"));
|
|
@@ -278,6 +279,9 @@ export async function main(argv, ctx = defaultCtx(), deps = {}) {
|
|
|
278
279
|
// Headless runs drop the terminal UI, browser sign-in and every browser action (CTC-4633).
|
|
279
280
|
const runOnboard = async (args, ctx, headless) => {
|
|
280
281
|
let ui = headless ? undefined : deps.setupUi;
|
|
282
|
+
// --no-color reaches the renderer as NO_COLOR, so the banner and every step row go plain.
|
|
283
|
+
const noColor = args.flags["no-color"] === true;
|
|
284
|
+
const rendererEnv = noColor ? { ...ctx.env, NO_COLOR: "1" } : ctx.env;
|
|
281
285
|
let terminal;
|
|
282
286
|
let input = process.stdin;
|
|
283
287
|
const originalRaw = Boolean(input.isRaw);
|
|
@@ -300,10 +304,18 @@ export async function main(argv, ctx = defaultCtx(), deps = {}) {
|
|
|
300
304
|
}
|
|
301
305
|
if (input.isTTY) {
|
|
302
306
|
try {
|
|
307
|
+
const banner = await setupBanner({
|
|
308
|
+
setup: viaSetup,
|
|
309
|
+
env: rendererEnv,
|
|
310
|
+
input,
|
|
311
|
+
stdout: process.stdout,
|
|
312
|
+
stream: bannerStream(ctx),
|
|
313
|
+
noColor,
|
|
314
|
+
});
|
|
303
315
|
ui = createClackOnboardUi(await import("@clack/prompts"), { input, output: process.stdout }, {
|
|
304
316
|
baseUrl: () => savedOnboardBaseUrl(ctx.home),
|
|
305
317
|
verbose: args.flags.verbose === true,
|
|
306
|
-
renderer: createSetupRenderer(process.stdout,
|
|
318
|
+
renderer: createSetupRenderer(process.stdout, rendererEnv, banner),
|
|
307
319
|
disposeRenderer: true,
|
|
308
320
|
signinTimeoutMs: deps.onboardSigninTimeoutMs,
|
|
309
321
|
version: manifest.version,
|
|
@@ -326,7 +338,14 @@ export async function main(argv, ctx = defaultCtx(), deps = {}) {
|
|
|
326
338
|
});
|
|
327
339
|
ui = createClackOnboardUi(await import("@clack/prompts"), { input: process.stdin, output }, {
|
|
328
340
|
baseUrl: () => savedOnboardBaseUrl(ctx.home),
|
|
329
|
-
renderer: createSetupRenderer(output,
|
|
341
|
+
renderer: createSetupRenderer(output, rendererEnv, await setupBanner({
|
|
342
|
+
setup: viaSetup,
|
|
343
|
+
env: rendererEnv,
|
|
344
|
+
input: process.stdin,
|
|
345
|
+
stdout: process.stdout,
|
|
346
|
+
stream: bannerStream(ctx),
|
|
347
|
+
noColor,
|
|
348
|
+
})),
|
|
330
349
|
disposeRenderer: true,
|
|
331
350
|
signinTimeoutMs: deps.onboardSigninTimeoutMs,
|
|
332
351
|
version: manifest.version,
|
|
@@ -560,6 +579,23 @@ const VERB_HELP_KNOWN = Object.fromEntries([
|
|
|
560
579
|
"legacy",
|
|
561
580
|
"onboard",
|
|
562
581
|
].map((v) => [v, true]));
|
|
582
|
+
/** CTC-4680: the Pixel Nucleus mark belongs to `catalyst setup` alone. `setup` runs the onboard
|
|
583
|
+
* flow, so this is read from the verb typed, before setup becomes onboard. */
|
|
584
|
+
export function drawsMark(argv) {
|
|
585
|
+
return argv[0] === "setup";
|
|
586
|
+
}
|
|
587
|
+
/** CTC-4680: the banner goes to stderr, through ctx when stderr is not a terminal. */
|
|
588
|
+
function bannerStream(ctx) {
|
|
589
|
+
if (process.stderr.isTTY === true)
|
|
590
|
+
return process.stderr;
|
|
591
|
+
return {
|
|
592
|
+
write(chunk) {
|
|
593
|
+
for (const line of chunk.replace(/\n$/, "").split("\n"))
|
|
594
|
+
ctx.stderr(line);
|
|
595
|
+
return true;
|
|
596
|
+
},
|
|
597
|
+
};
|
|
598
|
+
}
|
|
563
599
|
/** CTC-4625: `catalyst setup`, wired to this terminal, @clack/prompts and the keyless login. */
|
|
564
600
|
async function runSetup(argv, ctx, deps) {
|
|
565
601
|
if (argv[0] === "--help" || argv[0] === "-h") {
|
|
@@ -235,8 +235,9 @@ export function connectChecklistAdapter(options) {
|
|
|
235
235
|
// The contract advertised the route for this read; the wait's polls read the checklist alone.
|
|
236
236
|
const origin = new URL(url).origin;
|
|
237
237
|
let instruction;
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
// One tab per run: a second wait (Keep waiting, or another step) points at the page already
|
|
239
|
+
// open, and the wait still shows its address.
|
|
240
|
+
if (options.page.openedBy === null) {
|
|
240
241
|
try {
|
|
241
242
|
await options.openBrowser(url, signal);
|
|
242
243
|
options.page.openedBy = options.step;
|
package/dist/onboard-ui.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { COMPUTER_CHECKS, standalonePlan, standalonePlanNotes, pendingContinuation, } from "./onboard-standalone-copy.js";
|
|
2
2
|
import { trackedPrompt } from "./setup-prompt-frame.js";
|
|
3
3
|
import { createOnboardInterrupts } from "./onboard-interrupts.js";
|
|
4
|
-
import { setupStepView, CONNECTION_REPAIR_REASONS, setupFinalScreen, setupBrowserInstruction, setupCommandWords as say, setupPartHeading, setupPartProgress, setupTrackerRows, SETUP_PART_NUMBERS, SETUP_PART_OF, SETUP_PARTS, } from "./setup-onboard-copy.js";
|
|
4
|
+
import { setupStepView, CONNECTION_REPAIR_REASONS, setupFinalScreen, setupBrowserInstruction, setupCommandWords as say, setupWaitsOnAdmin, TIMED_OUT_REASONS, setupPartHeading, setupPartProgress, setupTrackerRows, SETUP_PART_NUMBERS, SETUP_PART_OF, SETUP_PARTS, } from "./setup-onboard-copy.js";
|
|
5
5
|
import { createOnboardProgress, } from "./onboard-progress.js";
|
|
6
6
|
import { CREATE_TEAM_CHOICE, suggestTeamKey, teamKeyProblem, teamNameProblem, } from "./onboard-team-create.js";
|
|
7
7
|
import { FIRST_TICKET_SAMPLE, FIRST_TICKET_SKIP, } from "./onboard-first-ticket.js";
|
|
8
|
-
import { ONBOARD_STEPS, ONBOARD_TITLES, stepSatisfied, onboardIdentityLines, onboardNextActions, onboardReadyForWork, onboardStepAction, } from "./onboard.js";
|
|
8
|
+
import { ONBOARD_STEPS, ONBOARD_TITLES, stepSatisfied, onboardHeaderIdentity, onboardIdentityLines, onboardNextActions, onboardReadyForWork, onboardStepAction, } from "./onboard.js";
|
|
9
9
|
import { onboardStepDetail, onboardReasonText } from "./onboard-next.js";
|
|
10
|
+
import { CONNECT_PAGE_PATH } from "./onboard-checklist.js";
|
|
10
11
|
export function shouldUseOnboardUi(args, stdoutTty) {
|
|
11
12
|
return (stdoutTty &&
|
|
12
13
|
!args.json &&
|
|
@@ -43,6 +44,11 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
43
44
|
let planned = {};
|
|
44
45
|
let rechecking = false;
|
|
45
46
|
let shownPlan;
|
|
47
|
+
// CTC-4680: steps whose wait was on the Connect accounts page. That page does not expire, so a
|
|
48
|
+
// wait that ran out is setup giving up, and the way back is the same page.
|
|
49
|
+
const connectWaits = new Map();
|
|
50
|
+
const onConnectPage = (step) => connectWaits.has(step.id) && TIMED_OUT_REASONS.has(step.reason ?? "");
|
|
51
|
+
const outcome = (step, view) => onConnectPage(step) ? "setup stopped waiting" : view.outcome;
|
|
46
52
|
let browserOpened = true;
|
|
47
53
|
let questionOpen = false;
|
|
48
54
|
let signinShown = false;
|
|
@@ -98,11 +104,15 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
98
104
|
renderer.heading(setupPartHeading(next, renderer.traits.unicode));
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
|
-
const progress = setupPartProgress(journalSeen, planned.scope);
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
const progress = setupPartProgress(journalSeen, planned.scope, "run");
|
|
108
|
+
const got = progress[previous];
|
|
109
|
+
const left = got.total - got.done;
|
|
110
|
+
// Mid-run nothing yet says whether an owner or admin has done their part, so this is neutral.
|
|
111
|
+
renderer.heading(!left
|
|
112
|
+
? `Part ${previous} done. ${SETUP_PARTS[previous].done}`
|
|
113
|
+
: left === got.admin + got.aside
|
|
114
|
+
? `The rest of part ${previous} is for an owner or admin of your Catalyst workspace.`
|
|
115
|
+
: `Part ${previous} has ${left === 1 ? "1 step" : `${left} steps`} left. Setup carries on with part ${next}.`);
|
|
106
116
|
renderer.tracker(setupTrackerRows(progress, { next }));
|
|
107
117
|
planPart(renderer, next, journalSeen);
|
|
108
118
|
renderer.blank();
|
|
@@ -221,10 +231,54 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
221
231
|
return result.answer;
|
|
222
232
|
};
|
|
223
233
|
let summaryShown = false;
|
|
224
|
-
|
|
234
|
+
/**
|
|
235
|
+
* The end screen's actions, split by who acts: the person's own, and an owner's or admin's
|
|
236
|
+
* (CTC-4680). A step paused with Ctrl-C is not an action: the last line says how to carry on.
|
|
237
|
+
*/
|
|
238
|
+
const sortActions = (journal) => {
|
|
225
239
|
const screen = setupFinalScreen(journal, deps.baseUrl?.(), abort.signal.aborted);
|
|
240
|
+
const step = (id) => journal.steps.find((s) => s.id === id) ?? { id, state: "pending" };
|
|
241
|
+
const text = (action) => {
|
|
242
|
+
const row = step(action.id);
|
|
243
|
+
if (!onConnectPage(row))
|
|
244
|
+
return say(action.text);
|
|
245
|
+
const kinds = row.evidence?.aiAccountKinds;
|
|
246
|
+
// #277's rule: subscription wording only for a workspace the cloud enables for it.
|
|
247
|
+
const what = action.id === "accounts"
|
|
248
|
+
? typeof kinds === "string" && kinds.split(",").includes("subscription")
|
|
249
|
+
? "add an API key or connect a subscription"
|
|
250
|
+
: "add an API key"
|
|
251
|
+
: action.id === "github.install"
|
|
252
|
+
? "install Catalyst on GitHub"
|
|
253
|
+
: `finish "${title(action.id)}" there`;
|
|
254
|
+
return `Open ${connectWaits.get(action.id)} and ${what}.`;
|
|
255
|
+
};
|
|
256
|
+
const live = screen.actions.filter((action) => step(action.id).reason !== "interrupted");
|
|
257
|
+
const theirs = live.filter((action) => setupWaitsOnAdmin(step(action.id), journal));
|
|
258
|
+
const mine = live.filter((action) => !theirs.includes(action));
|
|
259
|
+
// Steps only an owner or admin can do, less any already listed as their task above.
|
|
260
|
+
const skipped = journal.steps.filter((s) => s.reason === "member_scope" &&
|
|
261
|
+
setupWaitsOnAdmin(s, journal) &&
|
|
262
|
+
SETUP_PART_NUMBERS[s.id] !== undefined &&
|
|
263
|
+
s.id !== "projects" &&
|
|
264
|
+
!theirs.some((action) => action.id === s.id));
|
|
265
|
+
const waiting = theirs.length > 0 || skipped.length > 0;
|
|
266
|
+
const own = mine.length;
|
|
267
|
+
const next = screen.paused ||
|
|
268
|
+
!/^Next: run catalyst onboard after you finish/.test(screen.next)
|
|
269
|
+
? say(screen.next)
|
|
270
|
+
: own
|
|
271
|
+
? `Next: run catalyst setup after you finish ${own === 1 ? "1" : own === 2 ? "1 and 2" : `1 to ${own}`}.`
|
|
272
|
+
: waiting
|
|
273
|
+
? "Next: run catalyst setup once they have."
|
|
274
|
+
: "Next: run catalyst setup to check again.";
|
|
275
|
+
return { screen, mine, theirs, skipped, waiting, next, text, live };
|
|
276
|
+
};
|
|
277
|
+
const summary = (journal) => {
|
|
278
|
+
const sorted = sortActions(journal);
|
|
279
|
+
const { screen, mine, theirs, skipped } = sorted;
|
|
226
280
|
if (!renderer)
|
|
227
|
-
return
|
|
281
|
+
return sorted;
|
|
228
282
|
renderer.suspendLive();
|
|
229
283
|
active = false;
|
|
230
284
|
renderer.heading(screen.heading);
|
|
@@ -233,12 +287,34 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
233
287
|
renderer.tracker(setupTrackerRows(setupPartProgress(journal, planned.scope), "end"));
|
|
234
288
|
if (screen.readinessCause)
|
|
235
289
|
renderer.line(say(screen.readinessCause));
|
|
236
|
-
if (
|
|
237
|
-
renderer.line(`${
|
|
238
|
-
|
|
290
|
+
if (mine.length) {
|
|
291
|
+
renderer.line(`${mine.length} ${mine.length === 1 ? "thing needs" : "things need"} you:`);
|
|
292
|
+
mine.forEach((action, i) => renderer.item(`${i + 1}. `, sorted.text(action)));
|
|
239
293
|
if (screen.more)
|
|
240
294
|
renderer.line(`and ${screen.more} more after these`);
|
|
241
|
-
|
|
295
|
+
}
|
|
296
|
+
if (sorted.waiting) {
|
|
297
|
+
renderer.line("Waiting on an owner or admin of your Catalyst workspace:");
|
|
298
|
+
for (const action of theirs)
|
|
299
|
+
renderer.item("· ", sorted.text(action));
|
|
300
|
+
if (skipped.length) {
|
|
301
|
+
renderer.item("· ", `Steps only they can do: ${skipped.map((s) => title(s.id)).join(", ")}.`);
|
|
302
|
+
const base = deps.baseUrl?.();
|
|
303
|
+
const integrations = base
|
|
304
|
+
? new URL("/settings/connections", base).href
|
|
305
|
+
: undefined;
|
|
306
|
+
if (integrations && !theirs.some((a) => a.text.includes(integrations)))
|
|
307
|
+
renderer.item("· ", `They start at ${integrations}, the Integrations page.`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// A step skipped with Ctrl-C is no action, but it is still to come: the line below names it.
|
|
311
|
+
if (screen.actions.length || skipped.length) {
|
|
312
|
+
const continuation = pendingContinuation(journal,
|
|
313
|
+
// A step paused with Ctrl-C is still to come, so it stays in this line.
|
|
314
|
+
new Set([
|
|
315
|
+
...sorted.live.map((action) => action.id),
|
|
316
|
+
...skipped.map((s) => s.id),
|
|
317
|
+
]));
|
|
242
318
|
if (continuation)
|
|
243
319
|
renderer.line(continuation);
|
|
244
320
|
}
|
|
@@ -246,7 +322,7 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
246
322
|
renderer.line("Catalyst is ready to work on your team's tickets.");
|
|
247
323
|
if (deps.logPath?.())
|
|
248
324
|
renderer.line(`Full log: ${deps.logPath()}`);
|
|
249
|
-
return
|
|
325
|
+
return sorted;
|
|
250
326
|
};
|
|
251
327
|
const ui = {
|
|
252
328
|
signal: abort.signal,
|
|
@@ -264,14 +340,16 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
264
340
|
machineChecks.clear();
|
|
265
341
|
machineBlocked = false;
|
|
266
342
|
stop();
|
|
343
|
+
// Signed in already, the header carries who and where, so the lines below would repeat it.
|
|
344
|
+
let identityShown = false;
|
|
267
345
|
if (!introduced) {
|
|
268
346
|
if (renderer)
|
|
269
|
-
renderer.brand("setup", deps.version);
|
|
347
|
+
identityShown = renderer.brand("setup", deps.version, identity ? onboardHeaderIdentity(identity) : undefined);
|
|
270
348
|
else
|
|
271
349
|
prompts.intro("Catalyst setup", { output: streams.output });
|
|
272
350
|
introduced = true;
|
|
273
351
|
}
|
|
274
|
-
if (identity !== undefined)
|
|
352
|
+
if (identity !== undefined && !identityShown)
|
|
275
353
|
for (const line of onboardIdentityLines(identity))
|
|
276
354
|
if (renderer)
|
|
277
355
|
renderer.line(line);
|
|
@@ -586,25 +664,35 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
586
664
|
async retryTimedOut(id) {
|
|
587
665
|
if (abort.signal.aborted)
|
|
588
666
|
return false;
|
|
667
|
+
// The Connect accounts page does not expire: setup stopped waiting, and can wait again.
|
|
668
|
+
const page = connectWaits.has(id);
|
|
669
|
+
const why = page
|
|
670
|
+
? "Setup stopped waiting for the Connect accounts page."
|
|
671
|
+
: "The link timed out.";
|
|
589
672
|
if (renderer) {
|
|
590
673
|
// The question draws under this row, so the reason stays on screen while it is asked.
|
|
591
674
|
stop();
|
|
592
|
-
renderer.begin(number(id), title(id), "the link timed out", "ask");
|
|
675
|
+
renderer.begin(number(id), title(id), page ? "setup stopped waiting" : "the link timed out", "ask");
|
|
676
|
+
if (page)
|
|
677
|
+
renderer.detail(why);
|
|
593
678
|
active = true;
|
|
594
679
|
questionOpen = true;
|
|
595
680
|
}
|
|
596
681
|
else {
|
|
597
682
|
stop();
|
|
598
|
-
prompts.log.message(`${title(id)}:
|
|
683
|
+
prompts.log.message(`${title(id)}: ${why}`, {
|
|
599
684
|
output: streams.output,
|
|
600
685
|
});
|
|
601
686
|
}
|
|
602
687
|
const answer = await select({
|
|
603
688
|
...options,
|
|
604
|
-
message: "Ready to try again?",
|
|
689
|
+
message: page ? "Keep waiting?" : "Ready to try again?",
|
|
605
690
|
initialValue: "again",
|
|
606
691
|
options: [
|
|
607
|
-
{
|
|
692
|
+
{
|
|
693
|
+
value: "again",
|
|
694
|
+
label: page ? "Yes, keep waiting" : "Yes, give me a new link",
|
|
695
|
+
},
|
|
608
696
|
{ value: "stop", label: "Stop here. Run catalyst setup later to carry on." },
|
|
609
697
|
],
|
|
610
698
|
});
|
|
@@ -716,7 +804,7 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
716
804
|
}
|
|
717
805
|
if (step.id === "ready" || (hidden(step.id) && step.state !== "failed"))
|
|
718
806
|
return;
|
|
719
|
-
if (
|
|
807
|
+
if (step.id === "github.repos" &&
|
|
720
808
|
step.state === "done")
|
|
721
809
|
return;
|
|
722
810
|
if (step.id === "projects" &&
|
|
@@ -725,7 +813,7 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
725
813
|
const view = setupStepView(step, journal);
|
|
726
814
|
if (hidden(step.id))
|
|
727
815
|
enterPart(step.id);
|
|
728
|
-
renderer.step(view.mark, view.number, view.title, view
|
|
816
|
+
renderer.step(view.mark, view.number, view.title, outcome(step, view));
|
|
729
817
|
const granted = deps.verbose ? onboardStepDetail(step) : undefined;
|
|
730
818
|
if (granted)
|
|
731
819
|
renderer.detail(granted);
|
|
@@ -772,7 +860,7 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
772
860
|
if (!renderer ||
|
|
773
861
|
!interactive ||
|
|
774
862
|
abort.signal.aborted ||
|
|
775
|
-
!
|
|
863
|
+
!sortActions(journal).mine.length)
|
|
776
864
|
return false;
|
|
777
865
|
active = false;
|
|
778
866
|
summary(journal);
|
|
@@ -819,15 +907,14 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
819
907
|
}
|
|
820
908
|
if (renderer) {
|
|
821
909
|
active = false;
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
: summary(journal);
|
|
910
|
+
const sorted = summaryShown ? sortActions(journal) : summary(journal);
|
|
911
|
+
const { screen } = sorted;
|
|
825
912
|
if (summaryShown && screen.paused) {
|
|
826
913
|
renderer.heading(screen.heading);
|
|
827
914
|
renderer.line("Your progress is saved.");
|
|
828
915
|
}
|
|
829
916
|
summaryShown = false;
|
|
830
|
-
renderer.outro(
|
|
917
|
+
renderer.outro(sorted.next);
|
|
831
918
|
return;
|
|
832
919
|
}
|
|
833
920
|
stop();
|
|
@@ -852,6 +939,19 @@ export function createClackOnboardUi(prompts, streams, deps = {}) {
|
|
|
852
939
|
prompts.outro(text, { output: streams.output });
|
|
853
940
|
},
|
|
854
941
|
async wait(text, run, page) {
|
|
942
|
+
if (currentStep && page) {
|
|
943
|
+
let path = "";
|
|
944
|
+
try {
|
|
945
|
+
path = new URL(page.url).pathname;
|
|
946
|
+
}
|
|
947
|
+
catch {
|
|
948
|
+
// Not a URL, so not the Connect accounts page.
|
|
949
|
+
}
|
|
950
|
+
if (path === CONNECT_PAGE_PATH)
|
|
951
|
+
connectWaits.set(currentStep, page.url);
|
|
952
|
+
else
|
|
953
|
+
connectWaits.delete(currentStep);
|
|
954
|
+
}
|
|
855
955
|
const browser = currentStep && renderer && page
|
|
856
956
|
? page
|
|
857
957
|
: currentStep &&
|
package/dist/onboard.js
CHANGED
|
@@ -45,16 +45,25 @@ function dailyUpdateChoice(value) {
|
|
|
45
45
|
return { state: "skipped", reason: "no_scheduler" };
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
|
48
|
+
const identityLabel = (text) => text
|
|
49
|
+
.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, " ")
|
|
50
|
+
.replace(/\s+/g, " ")
|
|
51
|
+
.trim()
|
|
52
|
+
.slice(0, 180);
|
|
53
|
+
/** CTC-4680: who and where for the lines beside setup's mark, "user: …" and "workspace: …". */
|
|
54
|
+
export function onboardHeaderIdentity(identity) {
|
|
55
|
+
const display = identity.display;
|
|
56
|
+
return {
|
|
57
|
+
user: identityLabel(display?.email || display?.personLabel || identity.membershipId),
|
|
58
|
+
workspace: identityLabel(display?.workspaceName || identity.account),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
48
61
|
export function onboardIdentityLines(identity) {
|
|
49
62
|
if (!identity)
|
|
50
63
|
return [
|
|
51
64
|
"Use an existing Catalyst account or accept your invitation before approving sign-in.",
|
|
52
65
|
];
|
|
53
|
-
const label =
|
|
54
|
-
.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, " ")
|
|
55
|
-
.replace(/\s+/g, " ")
|
|
56
|
-
.trim()
|
|
57
|
-
.slice(0, 180);
|
|
66
|
+
const label = identityLabel;
|
|
58
67
|
const display = identity.display;
|
|
59
68
|
const person = label(display?.personLabel || identity.membershipId);
|
|
60
69
|
const email = display?.email ? label(display.email) : "";
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/** Ring order runs from the top tip, round the back, to the bottom tip, as in the brand script. */
|
|
2
|
+
export const RING = [
|
|
3
|
+
[3, 0],
|
|
4
|
+
[2, 0],
|
|
5
|
+
[1, 0],
|
|
6
|
+
[0, 1],
|
|
7
|
+
[0, 2],
|
|
8
|
+
[1, 3],
|
|
9
|
+
[2, 3],
|
|
10
|
+
[3, 3],
|
|
11
|
+
];
|
|
12
|
+
export const CORE = [
|
|
13
|
+
[1, 1],
|
|
14
|
+
[2, 1],
|
|
15
|
+
[1, 2],
|
|
16
|
+
[2, 2],
|
|
17
|
+
];
|
|
18
|
+
export const MARK_SIZE = { dot: 3, gap: 1 };
|
|
19
|
+
export const markSpan = (size = MARK_SIZE) => 4 * size.dot + 3 * size.gap;
|
|
20
|
+
export const markLines = (size = MARK_SIZE) => Math.ceil(markSpan(size) / 2);
|
|
21
|
+
const paintOf = (col, row) => RING.some(([c, r]) => c === col && r === row)
|
|
22
|
+
? "ring"
|
|
23
|
+
: CORE.some(([c, r]) => c === col && r === row)
|
|
24
|
+
? "core"
|
|
25
|
+
: null;
|
|
26
|
+
/** The mark as a grid of square units, `markSpan` rows of half lines by `markSpan` columns. */
|
|
27
|
+
export function markUnits(size = MARK_SIZE) {
|
|
28
|
+
const span = markSpan(size);
|
|
29
|
+
const pitch = size.dot + size.gap;
|
|
30
|
+
return Array.from({ length: span }, (_, y) => Array.from({ length: span }, (_, x) => x % pitch >= size.dot || y % pitch >= size.dot
|
|
31
|
+
? null
|
|
32
|
+
: paintOf(Math.floor(x / pitch), Math.floor(y / pitch))));
|
|
33
|
+
}
|
|
34
|
+
const BRAND = {
|
|
35
|
+
ink: "#11100e",
|
|
36
|
+
cream: "#f1ebe2",
|
|
37
|
+
copper: "#d28e63",
|
|
38
|
+
rust: "#a9512f",
|
|
39
|
+
};
|
|
40
|
+
/** The brand rules: a cream C and copper core on dark, an ink C and rust core on light. */
|
|
41
|
+
const PALETTES = {
|
|
42
|
+
dark: { ring: BRAND.cream, core: BRAND.copper },
|
|
43
|
+
light: { ring: BRAND.ink, core: BRAND.rust },
|
|
44
|
+
};
|
|
45
|
+
export function colourLevel(env, terminal) {
|
|
46
|
+
if (terminal.noColor)
|
|
47
|
+
return "none";
|
|
48
|
+
const force = env.FORCE_COLOR;
|
|
49
|
+
if (force !== undefined) {
|
|
50
|
+
if (force === "0" || force === "false")
|
|
51
|
+
return "none";
|
|
52
|
+
if (force === "" || force === "1" || force === "true")
|
|
53
|
+
return "16";
|
|
54
|
+
if (force === "2")
|
|
55
|
+
return "256";
|
|
56
|
+
if (force === "3")
|
|
57
|
+
return "truecolor";
|
|
58
|
+
}
|
|
59
|
+
if (env.NO_COLOR !== undefined || !terminal.tty)
|
|
60
|
+
return "none";
|
|
61
|
+
if (!env.TERM || env.TERM === "dumb")
|
|
62
|
+
return "none";
|
|
63
|
+
if (/^(truecolor|24bit)$/i.test(env.COLORTERM ?? ""))
|
|
64
|
+
return "truecolor";
|
|
65
|
+
return /256/.test(env.TERM) ? "256" : "16";
|
|
66
|
+
}
|
|
67
|
+
/** CI as most tools read it: set, and not "", "0" or "false". */
|
|
68
|
+
export function inCi(env) {
|
|
69
|
+
return ![undefined, "", "0", "false"].includes(env.CI);
|
|
70
|
+
}
|
|
71
|
+
export const MARK_MIN_COLUMNS = 60;
|
|
72
|
+
/**
|
|
73
|
+
* Why the mark is left off, or null to draw it. Off for every verb but setup, without a terminal,
|
|
74
|
+
* in CI, with --no-color or NO_COLOR or no colour at all, without UTF-8 (the blocks are UTF-8), and
|
|
75
|
+
* below 60 columns. The text lines are printed either way.
|
|
76
|
+
*/
|
|
77
|
+
export function markSkipped(options) {
|
|
78
|
+
const { env } = options;
|
|
79
|
+
if (!options.setup)
|
|
80
|
+
return "not catalyst setup";
|
|
81
|
+
if (!options.tty)
|
|
82
|
+
return "not a terminal";
|
|
83
|
+
if (inCi(env))
|
|
84
|
+
return "CI";
|
|
85
|
+
if (options.noColor)
|
|
86
|
+
return "--no-color";
|
|
87
|
+
if (env.NO_COLOR !== undefined)
|
|
88
|
+
return "NO_COLOR";
|
|
89
|
+
if (colourLevel(env, options) === "none")
|
|
90
|
+
return "no colour";
|
|
91
|
+
if (!/utf-?8/i.test(env.LC_ALL || env.LC_CTYPE || env.LANG || ""))
|
|
92
|
+
return "not UTF-8";
|
|
93
|
+
if (options.columns < MARK_MIN_COLUMNS)
|
|
94
|
+
return "narrow";
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const rgb = (hex) => [
|
|
98
|
+
Number.parseInt(hex.slice(1, 3), 16),
|
|
99
|
+
Number.parseInt(hex.slice(3, 5), 16),
|
|
100
|
+
Number.parseInt(hex.slice(5, 7), 16),
|
|
101
|
+
];
|
|
102
|
+
const distance = (a, b) => (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2;
|
|
103
|
+
/** The nearest xterm-256 colour: the 6×6×6 cube or the 24-step grey ramp, whichever is closer. */
|
|
104
|
+
export function nearest256(hex) {
|
|
105
|
+
const colour = rgb(hex);
|
|
106
|
+
const levels = [0, 95, 135, 175, 215, 255];
|
|
107
|
+
const step = (v) => levels.reduce((best, l, i) => (Math.abs(l - v) < Math.abs(levels[best] - v) ? i : best), 0);
|
|
108
|
+
const [ri, gi, bi] = colour.map(step);
|
|
109
|
+
const avg = (colour[0] + colour[1] + colour[2]) / 3;
|
|
110
|
+
const greyIndex = Math.min(23, Math.max(0, Math.round((avg - 8) / 10)));
|
|
111
|
+
const grey = 8 + 10 * greyIndex;
|
|
112
|
+
return distance([levels[ri], levels[gi], levels[bi]], colour) <=
|
|
113
|
+
distance([grey, grey, grey], colour)
|
|
114
|
+
? 16 + 36 * ri + 6 * gi + bi
|
|
115
|
+
: 232 + greyIndex;
|
|
116
|
+
}
|
|
117
|
+
/** xterm's default 16 colours, as SGR foreground codes. */
|
|
118
|
+
const XTERM16 = [
|
|
119
|
+
[30, [0, 0, 0]],
|
|
120
|
+
[31, [205, 0, 0]],
|
|
121
|
+
[32, [0, 205, 0]],
|
|
122
|
+
[33, [205, 205, 0]],
|
|
123
|
+
[34, [0, 0, 238]],
|
|
124
|
+
[35, [205, 0, 205]],
|
|
125
|
+
[36, [0, 205, 205]],
|
|
126
|
+
[37, [229, 229, 229]],
|
|
127
|
+
[90, [127, 127, 127]],
|
|
128
|
+
[91, [255, 0, 0]],
|
|
129
|
+
[92, [0, 255, 0]],
|
|
130
|
+
[93, [255, 255, 0]],
|
|
131
|
+
[94, [92, 92, 255]],
|
|
132
|
+
[95, [255, 0, 255]],
|
|
133
|
+
[96, [0, 255, 255]],
|
|
134
|
+
[97, [255, 255, 255]],
|
|
135
|
+
];
|
|
136
|
+
/**
|
|
137
|
+
* The nearest of xterm's 16 default colours. Plain distance puts copper nearest grey (90), and the
|
|
138
|
+
* core is the mark's one accent, so the core picks from the coloured entries only: copper is then
|
|
139
|
+
* yellow (33) and rust red (31). The ring takes plain distance: cream is white (37), ink black (30).
|
|
140
|
+
*/
|
|
141
|
+
export function nearest16(hex, accent = false) {
|
|
142
|
+
const colour = rgb(hex);
|
|
143
|
+
const greys = [30, 37, 90, 97];
|
|
144
|
+
return XTERM16.filter(([code]) => !accent || !greys.includes(code)).reduce((best, entry) => distance(entry[1], colour) < distance(best[1], colour) ? entry : best)[0];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The SGR parameters for one of the mark's colours on a `theme` background, as a foreground or a
|
|
148
|
+
* background. With 16 colours the core is also bold, which most terminals draw brighter.
|
|
149
|
+
*/
|
|
150
|
+
export function markColour(paint, theme, level, layer = "fg") {
|
|
151
|
+
const hex = PALETTES[theme][paint];
|
|
152
|
+
const lead = layer === "fg" ? 38 : 48;
|
|
153
|
+
if (level === "truecolor")
|
|
154
|
+
return `${lead};2;${rgb(hex).join(";")}`;
|
|
155
|
+
if (level === "256")
|
|
156
|
+
return `${lead};5;${nearest256(hex)}`;
|
|
157
|
+
const code = nearest16(hex, paint === "core") + (layer === "fg" ? 0 : 10);
|
|
158
|
+
return paint === "core" && layer === "fg" ? `1;${code}` : String(code);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Units to terminal lines, two unit rows per line: both halves set is a full block (or an upper
|
|
162
|
+
* half block on the lower colour's background when they differ), one half is a half block, neither
|
|
163
|
+
* is a space. Each run of one glyph colour is closed with a reset.
|
|
164
|
+
*/
|
|
165
|
+
export function unitLines(units, theme, level) {
|
|
166
|
+
const lines = [];
|
|
167
|
+
for (let y = 0; y < units.length; y += 2) {
|
|
168
|
+
const upper = units[y];
|
|
169
|
+
const lower = units[y + 1] ?? [];
|
|
170
|
+
let out = "";
|
|
171
|
+
let open = "";
|
|
172
|
+
for (let x = 0; x < upper.length; x++) {
|
|
173
|
+
const [top, bottom] = [upper[x] ?? null, lower[x] ?? null];
|
|
174
|
+
const sgr = top && bottom && top !== bottom
|
|
175
|
+
? `${markColour(top, theme, level)};${markColour(bottom, theme, level, "bg")}`
|
|
176
|
+
: top || bottom
|
|
177
|
+
? markColour((top ?? bottom), theme, level)
|
|
178
|
+
: "";
|
|
179
|
+
if (sgr !== open) {
|
|
180
|
+
if (open)
|
|
181
|
+
out += "\u001b[0m";
|
|
182
|
+
if (sgr)
|
|
183
|
+
out += `\u001b[${sgr}m`;
|
|
184
|
+
open = sgr;
|
|
185
|
+
}
|
|
186
|
+
out +=
|
|
187
|
+
!top && !bottom
|
|
188
|
+
? " "
|
|
189
|
+
: top && bottom && top === bottom
|
|
190
|
+
? "█"
|
|
191
|
+
: top
|
|
192
|
+
? "▀"
|
|
193
|
+
: "▄";
|
|
194
|
+
}
|
|
195
|
+
lines.push(open ? `${out}\u001b[0m` : out);
|
|
196
|
+
}
|
|
197
|
+
return lines;
|
|
198
|
+
}
|
|
199
|
+
/** The mark, one string per terminal line: `markLines` lines of `markSpan` columns. */
|
|
200
|
+
export function pixelNucleusLines(theme, level, size = MARK_SIZE) {
|
|
201
|
+
return unitLines(markUnits(size), theme, level);
|
|
202
|
+
}
|
|
@@ -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.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
|
|
|
@@ -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
|
|
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
|
|
|
@@ -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.4 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What's happening
|
|
10
10
|
|