@catalyst-cloud/cli 0.16.27 → 0.16.28
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 +4 -0
- package/README.md +16 -1
- package/dist/args.js +12 -2
- package/dist/cli.js +6 -0
- package/dist/events.js +146 -1
- package/dist/messages.js +47 -0
- package/package.json +4 -4
- package/skills/catalyst-github/SKILL.md +1 -1
- package/skills/catalyst-linear/SKILL.md +1 -1
- package/skills/catalyst-linear/references/reading-from-the-cloud.md +5 -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/skills/whats-happening/references/reading-from-the-cloud.md +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.28
|
|
4
|
+
|
|
5
|
+
`catalyst events wait-for` can now wait on a repository (`--repo owner/name`), a branch (`--ref owner/name:branch`), a pull request (`--pr owner/name#n`), a work session (`--session KEY-123/phase#n`), events addressed to you (`--to me`) or a family of event types (`--type pr.*`). An agent can wait hours for a review or a conflict on its own branch: the wait holds one connection, prints each matching event as one JSON line, and after a dropped connection picks up where it left off without missing or repeating an event. Two new exit codes say why a wait ended without a match. 2 means the cloud refused the wait, for example on a ticket outside your teams, or the wait failed. 3 means `--from-cache` found no local event cache. A wait still exits 1 on a timeout and 4 on an outage, as before, and on a timeout it names the `--after` to resume from. New: `catalyst messages read --ticket KEY-123` prints the messages sent to a ticket on your teams, with each sender and time.
|
|
6
|
+
|
|
3
7
|
## 0.16.27
|
|
4
8
|
|
|
5
9
|
A large workspace's local replica now finishes its first download instead of stopping after 30 seconds: it waits as long as data keeps arriving, and gives up only after 150 seconds with no progress. New commands: `catalyst repo status` lists your repositories and whether each is paused, and `catalyst repo pause|resume` pauses or resumes one (owners and admins). `catalyst runner status|stop|start|uninstall` stops a self-hosted machine taking work, starts it again with the same registration, or removes it and revokes its registration. Setup with local sync off now lists an old local replica's files with their sizes and removes them only after you say yes. Setup with local sync on keeps using the replica you already have. On a Mac where Docker Desktop does not share your home folder, setup now says which setting to change (Settings, then Resources, then File sharing).
|
package/README.md
CHANGED
|
@@ -246,7 +246,22 @@ CLI and skill reads use the cloud API by default, including on a machine with a
|
|
|
246
246
|
|
|
247
247
|
For a local view, `catalyst replica status` checks the writer, heartbeat and cursor. It exits `0` for fresh, `1` for present but stale, `2` for not connected, `3` for absent. `replica status --probe` compares its cursor with the cloud head. These diagnostics do not change the default read source, and an absent replica does not make `catalyst ready` fail.
|
|
248
248
|
|
|
249
|
-
`catalyst events tail`, `wait-for`, `query` and `status` read from the cloud by default, with no local file. `events tail` prints one JSON line per new event and stays in the foreground; `events wait-for --ticket ... --timeout ...` prints the first match and exits 0, or exits 1 when none arrives in time; `events query` reads one page of filtered history (`--ticket`, `--type`, `--limit` up to 200, `--order desc|asc`, `--before`, `--after`); `events status` names the cloud head.
|
|
249
|
+
`catalyst events tail`, `wait-for`, `query` and `status` read from the cloud by default, with no local file. `events tail` prints one JSON line per new event and stays in the foreground; `events wait-for --ticket ... --timeout ...` prints the first match and exits 0, or exits 1 when none arrives in time; `events query` reads one page of filtered history (`--ticket`, `--type`, `--limit` up to 200, `--order desc|asc`, `--before`, `--after`); `events status` names the cloud head.
|
|
250
|
+
|
|
251
|
+
`events wait-for` can also wait on a repository (`--repo owner/name`), a branch (`--ref owner/name:branch`), a pull request (`--pr owner/name#n`), a phase session (`--session TICKET/phase#n`), events addressed to you (`--to me`), or a family of types (`--type pr.*`). Values of one flag are OR'ed and different flags are AND'ed, and `--repo`, `--ref`, `--pr` and `--session` can repeat. Such a wait holds one connection and prints nothing until a match, so a long `--timeout` such as 14400 costs nothing while it waits. It prints every matching event as one JSON line. After a dropped connection it replays from its cursor, so no event is missed or printed twice.
|
|
252
|
+
|
|
253
|
+
| `wait-for` exit | Meaning |
|
|
254
|
+
| --- | --- |
|
|
255
|
+
| 0 | a match, printed on stdout |
|
|
256
|
+
| 1 | none arrived in time; with a scope flag, stderr names the `--after` to resume from |
|
|
257
|
+
| 2 | the cloud refused the wait (for example a ticket outside your teams), or the wait failed; stderr gives the reason |
|
|
258
|
+
| 3 | `--from-cache` and the local event cache is absent or its writer stopped |
|
|
259
|
+
| 4 | the cloud was unreachable for five attempts in a row: an outage, not a timeout |
|
|
260
|
+
| 130 | interrupted |
|
|
261
|
+
|
|
262
|
+
`catalyst messages read --ticket KEY-123 [--since SEQUENCE]` prints the messages sent to a ticket on your teams, with each sender and time, for example after a wait on `--type comms.message.posted` returns.
|
|
263
|
+
|
|
264
|
+
Add `--from-cache` to read this machine's local event cache instead, which pays off when several agents on one machine share one cloud connection. `catalyst events status --from-cache --probe` checks the cache's own cursor against the cloud head; `replica status --probe` checks the separate entity-replica cursor. A fresh replica does not prove event freshness. The replica process is the single writer and reports an event-sync failure without terminating a healthy entity replica. The event cache keeps closed daily segments for at most seven days or 256 MiB per account and reports an explicit gap when a requested sequence has retired.
|
|
250
265
|
|
|
251
266
|
The replica is a Node process, not a service: the supported path is the plain command, and `skills/catalyst-onboard/references/local-sync.md` gives launchd and systemd examples for people who want the writer to survive a reboot.
|
|
252
267
|
|
package/dist/args.js
CHANGED
|
@@ -158,11 +158,16 @@ export const FLAG_TABLES = {
|
|
|
158
158
|
value: false,
|
|
159
159
|
help: "status --from-cache: compare the local event cursor with the cloud event head",
|
|
160
160
|
},
|
|
161
|
-
type: { value: true, help: "exact event type" },
|
|
161
|
+
type: { value: true, help: "exact event type, or for wait-for a family such as pr.*" },
|
|
162
162
|
ticket: {
|
|
163
163
|
value: true,
|
|
164
164
|
help: "ticket identifier found in the event",
|
|
165
165
|
},
|
|
166
|
+
repo: { value: true, repeat: true, help: "wait-for: repository as owner/name (repeatable)" },
|
|
167
|
+
ref: { value: true, repeat: true, help: "wait-for: branch as owner/name:branch (repeatable)" },
|
|
168
|
+
pr: { value: true, repeat: true, help: "wait-for: pull request as owner/name#number (repeatable)" },
|
|
169
|
+
session: { value: true, repeat: true, help: "wait-for: phase session as TICKET/phase#attempt (repeatable)" },
|
|
170
|
+
to: { value: true, help: "wait-for: me, for events addressed to this login" },
|
|
166
171
|
after: {
|
|
167
172
|
value: true,
|
|
168
173
|
help: "event sequence to read after (tail and wait-for default to new events only)",
|
|
@@ -478,6 +483,10 @@ export const FLAG_TABLES = {
|
|
|
478
483
|
},
|
|
479
484
|
},
|
|
480
485
|
identity: {},
|
|
486
|
+
messages: {
|
|
487
|
+
ticket: { value: true, help: "read: the ticket whose messages to read" },
|
|
488
|
+
since: { value: true, help: "read: the first message sequence to read (inclusive)" },
|
|
489
|
+
},
|
|
481
490
|
capabilities: {},
|
|
482
491
|
project: {
|
|
483
492
|
team: {
|
|
@@ -564,7 +573,7 @@ export const VERB_USAGE = {
|
|
|
564
573
|
query: "query <issues|issue <id>|pulls|pull <id>|projects|cycles|search <terms>|changes --since <cursor|head>> [--team K] [--project P] [--state S] [--limit N] [--all] [--source replica|api] [--json]",
|
|
565
574
|
replica: 'replica <start [--detach]|stop|status [--probe] [--json]|sql "<select>"|schema [table]> [--db <path>]',
|
|
566
575
|
runtime: "runtime <status [--json]|install|path|uninstall>",
|
|
567
|
-
events: "events <tail|wait-for|query|status [--probe] [--json]> [--type NAME] [--ticket CTC-N] [--after SEQUENCE] [--limit N] [--timeout SECONDS] [--directory PATH]",
|
|
576
|
+
events: "events <tail|wait-for|query|status [--probe] [--json]> [--type NAME] [--ticket CTC-N] [--repo O/N] [--ref O/N:BRANCH] [--pr O/N#N] [--session T/PHASE#N] [--to me] [--after SEQUENCE] [--limit N] [--timeout SECONDS] [--directory PATH]",
|
|
568
577
|
explain: "explain <ticket> [--history] [--json]",
|
|
569
578
|
history: "history <ticket> [--json]",
|
|
570
579
|
running: "running [--ticket T --phase P] [--json]",
|
|
@@ -582,6 +591,7 @@ export const VERB_USAGE = {
|
|
|
582
591
|
secret: "secret set <NAME> --repo <owner/name> [--command '<cmd>'] [--json] (value from --command, stdin, or a hidden prompt) | secret import <file> --repo <owner/name> [--names NAME[,NAME...]] [--rotate NAME]... [--json]",
|
|
583
592
|
var: "var <set NAME|import <file>> [--repo <owner/name>] [--names NAME[,NAME...]] [--json] (plain environment variables; set reads stdin or a hidden prompt)",
|
|
584
593
|
identity: "identity linear <status|options|set> [<linearUserId>] [--json]",
|
|
594
|
+
messages: "messages read --ticket CTC-N [--since SEQUENCE] [--json]",
|
|
585
595
|
capabilities: "capabilities [--json]",
|
|
586
596
|
project: "project <list [--json] | wip-limit <get|set <n>|set default> [--team K] [--json]>",
|
|
587
597
|
repo: "repo <status|pause <owner/name> --reason <text>|resume <owner/name> [--reason <text>]|agents-block <path> [--write]|agent-setup <path> [--apply] [--with-check]> [--json] (status: visible workspace repositories; agents-block/agent-setup: local checkout)",
|
package/dist/cli.js
CHANGED
|
@@ -47,6 +47,7 @@ import { cmdProject } from "./project.js";
|
|
|
47
47
|
import { cmdRepo } from "./repo.js";
|
|
48
48
|
import { cmdLegacy } from "./legacy.js";
|
|
49
49
|
import { cmdIdentity } from "./identity.js";
|
|
50
|
+
import { cmdMessages } from "./messages.js";
|
|
50
51
|
import { cmdConnections } from "./connections.js";
|
|
51
52
|
import { cmdOnboard, onboardErrorJournal, onboardStatePath, readOnboardJournal, } from "./onboard.js";
|
|
52
53
|
import { createClackOnboardUi, shouldUseOnboardUi, } from "./onboard-ui.js";
|
|
@@ -93,6 +94,7 @@ export function usageText() {
|
|
|
93
94
|
' catalyst replica <start [--detach]|stop|status [--probe]|sql "<select>"|schema [table]>',
|
|
94
95
|
" catalyst runtime <status [--json]|install|path|uninstall> (a pinned Node this CLI manages itself)",
|
|
95
96
|
" catalyst events <tail|wait-for|query|status> [--type NAME] [--ticket CTC-N] [--after SEQUENCE] [--from-cache]",
|
|
97
|
+
" catalyst events wait-for [--repo O/N] [--ref O/N:BRANCH] [--pr O/N#N] [--session T/PHASE#N] [--to me] [--type pr.*] [--timeout SECONDS] (one connection; nothing printed until a match)",
|
|
96
98
|
" catalyst explain <ticket> | history <ticket> | running [--ticket T --phase P] | queue [--team K]",
|
|
97
99
|
" catalyst watch [--team K] [--ticket T]... [--project P] [--exec CMD]",
|
|
98
100
|
" catalyst write <comment|state|label|create|reaction|attachment|session> ...",
|
|
@@ -112,6 +114,7 @@ export function usageText() {
|
|
|
112
114
|
" catalyst repo <agents-block <path> [--write]|agent-setup <path> [--apply] [--with-check]> (a checkout's AGENTS.md block and portable agent layout; working tree only)",
|
|
113
115
|
" catalyst legacy [--remove [--data] [--yes]] (leftovers of the old local Catalyst runtime: list them; remove them only on a yes)",
|
|
114
116
|
" catalyst identity linear <status|options|set> [<linearUserId>] [--json]",
|
|
117
|
+
" catalyst messages read --ticket CTC-N [--since SEQUENCE] [--json] (messages sent to a ticket on your teams)",
|
|
115
118
|
" catalyst connections personal <linear|github> <start|status> [--wait <seconds>] [--json]",
|
|
116
119
|
"",
|
|
117
120
|
"Every verb takes --help. --json makes the output machine-readable.",
|
|
@@ -535,6 +538,8 @@ export async function main(argv, ctx = defaultCtx(), deps = {}) {
|
|
|
535
538
|
return await cmdLegacy(args, ctx, { localSyncSelected: savedLocalSync(ctx), ...deps.legacy });
|
|
536
539
|
case "identity":
|
|
537
540
|
return await cmdIdentity(args, ctx, deps.identity ?? {});
|
|
541
|
+
case "messages":
|
|
542
|
+
return await cmdMessages(args, ctx, deps.messages ?? {});
|
|
538
543
|
case "hosts":
|
|
539
544
|
return await cmdHosts(args, ctx, deps.hosts);
|
|
540
545
|
case "runner":
|
|
@@ -599,6 +604,7 @@ const VERB_HELP_KNOWN = Object.fromEntries([
|
|
|
599
604
|
"environment",
|
|
600
605
|
"connections",
|
|
601
606
|
"identity",
|
|
607
|
+
"messages",
|
|
602
608
|
"mcp",
|
|
603
609
|
"team",
|
|
604
610
|
"capabilities",
|
package/dist/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flagInt, flagString, positionals } from "./args.js";
|
|
1
|
+
import { flagInt, flagList, flagString, positionals } from "./args.js";
|
|
2
2
|
import { normalizeBaseUrl, requireConfig } from "./config.js";
|
|
3
3
|
import { CliError, UsageError } from "./errors.js";
|
|
4
4
|
import { authStrategyFor } from "./oauth.js";
|
|
@@ -39,6 +39,13 @@ export async function cmdEvents(args, ctx, deps = {}) {
|
|
|
39
39
|
throw new UsageError("events needs a subcommand: tail | wait-for | query | status");
|
|
40
40
|
if (!["tail", "wait-for", "query", "status"].includes(sub))
|
|
41
41
|
throw new UsageError(`unknown events subcommand: ${sub}`);
|
|
42
|
+
// CTC-6650 — a scope key or a type family runs on the SDK's wait; the --type/--ticket path is unchanged.
|
|
43
|
+
const scope = scopeFilter(args);
|
|
44
|
+
if (scope) {
|
|
45
|
+
if (sub !== "wait-for")
|
|
46
|
+
throw new UsageError("--repo, --ref, --pr, --session, --to and a type family such as pr.* work with wait-for only");
|
|
47
|
+
return cmdScopedWait(args, ctx, deps, scope);
|
|
48
|
+
}
|
|
42
49
|
// CTC-4554 — the cloud is the default source; the local event file is the opt-in.
|
|
43
50
|
if (args.flags["from-cache"] !== true) {
|
|
44
51
|
if (flagString(args, "directory") !== undefined)
|
|
@@ -118,6 +125,144 @@ function startingCursor(args, name = "after") {
|
|
|
118
125
|
throw new UsageError(`--${name} must be a non-negative event sequence`);
|
|
119
126
|
return parsed;
|
|
120
127
|
}
|
|
128
|
+
const SCOPE_KEYS = ["repo", "ref", "pr", "session"];
|
|
129
|
+
/** The SDK filter when the wait names a scope key or a type family, or null for the original path. */
|
|
130
|
+
function scopeFilter(args) {
|
|
131
|
+
const filter = {};
|
|
132
|
+
for (const key of SCOPE_KEYS) {
|
|
133
|
+
const values = flagList(args, key);
|
|
134
|
+
if (values.length)
|
|
135
|
+
filter[key] = values;
|
|
136
|
+
}
|
|
137
|
+
const to = flagString(args, "to");
|
|
138
|
+
if (to !== undefined) {
|
|
139
|
+
if (to !== "me")
|
|
140
|
+
throw new UsageError("--to accepts only me");
|
|
141
|
+
filter.to = "me";
|
|
142
|
+
}
|
|
143
|
+
const type = flagString(args, "type");
|
|
144
|
+
if (Object.keys(filter).length === 0 && !type?.endsWith(".*"))
|
|
145
|
+
return null;
|
|
146
|
+
const ticket = flagString(args, "ticket");
|
|
147
|
+
return { ...filter, ...(type ? { type } : {}), ...(ticket ? { ticket } : {}) };
|
|
148
|
+
}
|
|
149
|
+
/** Counts consecutive failed requests, so a wait that cannot reach the cloud ends as an outage. */
|
|
150
|
+
function outageFetch(base, signal, onOutage, now) {
|
|
151
|
+
let failures = 0;
|
|
152
|
+
let sinceMs = 0;
|
|
153
|
+
const trouble = () => {
|
|
154
|
+
if (failures === 0)
|
|
155
|
+
sinceMs = now();
|
|
156
|
+
failures += 1;
|
|
157
|
+
if (failures >= OUTAGE_ATTEMPTS)
|
|
158
|
+
onOutage(failures, sinceMs);
|
|
159
|
+
};
|
|
160
|
+
return async (input, init) => {
|
|
161
|
+
try {
|
|
162
|
+
const response = await base(input, init);
|
|
163
|
+
if (response.status >= 500)
|
|
164
|
+
trouble();
|
|
165
|
+
else
|
|
166
|
+
failures = 0;
|
|
167
|
+
return response;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
// A request the SDK timed out counts; one cancelled because this wait ended does not.
|
|
171
|
+
if (!signal.aborted)
|
|
172
|
+
trouble();
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** `wait-for` with scope keys: the SDK's wait, under the CLI's documented exit codes. */
|
|
178
|
+
async function cmdScopedWait(args, ctx, deps, filter) {
|
|
179
|
+
const cfg = requireConfig(ctx);
|
|
180
|
+
const timeout = flagInt(args, "timeout", 300);
|
|
181
|
+
if (timeout < 0)
|
|
182
|
+
throw new UsageError("--timeout must be zero or more seconds");
|
|
183
|
+
const after = startingCursor(args);
|
|
184
|
+
const fromCache = args.flags["from-cache"] === true;
|
|
185
|
+
if (!fromCache && flagString(args, "directory") !== undefined)
|
|
186
|
+
throw new UsageError("--directory names the local event cache; add --from-cache to read it");
|
|
187
|
+
const sdk = await (deps.loadSdk ?? loadEventsSdk)();
|
|
188
|
+
const { waitForEvents, waitForCachedEvents } = sdk;
|
|
189
|
+
if (!waitForEvents || !waitForCachedEvents)
|
|
190
|
+
throw new CliError("the installed SDK cannot wait on scope keys; upgrade the catalyst CLI", "sdk-upgrade-required");
|
|
191
|
+
const controller = new AbortController();
|
|
192
|
+
const abort = () => controller.abort(deps.signal?.reason);
|
|
193
|
+
if (deps.signal?.aborted)
|
|
194
|
+
abort();
|
|
195
|
+
else
|
|
196
|
+
deps.signal?.addEventListener("abort", abort, { once: true });
|
|
197
|
+
let interrupted = false;
|
|
198
|
+
let outage;
|
|
199
|
+
const removeInterrupt = (deps.onInterrupt ?? processInterrupts)(() => {
|
|
200
|
+
interrupted = true;
|
|
201
|
+
controller.abort(new Error("interrupted"));
|
|
202
|
+
});
|
|
203
|
+
try {
|
|
204
|
+
let result;
|
|
205
|
+
if (fromCache) {
|
|
206
|
+
result = await waitForCachedEvents({
|
|
207
|
+
tenantId: cfg.account,
|
|
208
|
+
directory: flagString(args, "directory") ?? sdk.defaultEventCacheDirectory(cfg.account),
|
|
209
|
+
filter,
|
|
210
|
+
after,
|
|
211
|
+
timeoutMs: timeout * 1_000,
|
|
212
|
+
signal: controller.signal,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const auth = authStrategyFor(ctx, cfg);
|
|
217
|
+
if (auth.kind === "cookie")
|
|
218
|
+
throw new CliError("event waits require a token or OAuth session", "events-auth");
|
|
219
|
+
result = await waitForEvents({
|
|
220
|
+
baseUrl: normalizeBaseUrl(cfg.baseUrl),
|
|
221
|
+
auth,
|
|
222
|
+
tenantId: cfg.account,
|
|
223
|
+
filter,
|
|
224
|
+
after,
|
|
225
|
+
timeoutMs: timeout * 1_000,
|
|
226
|
+
signal: controller.signal,
|
|
227
|
+
fetch: outageFetch(ctx.fetch, controller.signal, (failures, sinceMs) => {
|
|
228
|
+
if (outage)
|
|
229
|
+
return;
|
|
230
|
+
outage = { failures, sinceMs };
|
|
231
|
+
controller.abort(new Error("cloud unreachable"));
|
|
232
|
+
}, () => ctx.now().getTime()),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const resume = (cursor) => (cursor === null || cursor === undefined ? "" : `; resume with --after ${cursor}`);
|
|
236
|
+
switch (result.outcome) {
|
|
237
|
+
case "matched":
|
|
238
|
+
for (const event of result.events)
|
|
239
|
+
ctx.stdout(JSON.stringify(event));
|
|
240
|
+
return 0;
|
|
241
|
+
case "timeout":
|
|
242
|
+
ctx.stderr(`events: no matching event within ${timeout} s${resume(result.cursor)}`);
|
|
243
|
+
return 1;
|
|
244
|
+
case "aborted":
|
|
245
|
+
if (interrupted)
|
|
246
|
+
return 130;
|
|
247
|
+
if (outage) {
|
|
248
|
+
ctx.stderr(`events: the cloud event service was unreachable for ${outage.failures} attempts over ${Math.round((ctx.now().getTime() - outage.sinceMs) / 1_000)} s; this is an outage, not a timeout${resume(result.cursor)}`);
|
|
249
|
+
return 4;
|
|
250
|
+
}
|
|
251
|
+
return 1;
|
|
252
|
+
case "refused":
|
|
253
|
+
throw new CliError(`events: ${result.source === "filter" ? "the filter was refused" : `the cloud refused the wait${result.status === null ? "" : ` (${result.status})`}`}${result.key ? ` on --${result.key}${result.value === null ? "" : ` ${result.value}`}` : ""}: ${result.reason}`, "events-refused");
|
|
254
|
+
default:
|
|
255
|
+
// The remaining outcome is "failed"; a default keeps every path ending in a return or throw.
|
|
256
|
+
if (result.code === "cache-missing" || result.code === "cache-writer-stopped")
|
|
257
|
+
throw new CliError(`events: ${result.reason}. Start the local writer with: catalyst replica start --detach, or drop --from-cache to read from the cloud`, "events-absent", 3);
|
|
258
|
+
throw new CliError(`events: the wait failed (${result.code}): ${result.reason}${resume(result.resumeFrom ?? result.cursor)}`, "events-failed");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
removeInterrupt();
|
|
263
|
+
deps.signal?.removeEventListener("abort", abort);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
121
266
|
function eventFilter(args) {
|
|
122
267
|
const type = flagString(args, "type");
|
|
123
268
|
const ticket = flagString(args, "ticket")?.toUpperCase();
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { flagString, positionals } from "./args.js";
|
|
2
|
+
import { requireConfig } from "./config.js";
|
|
3
|
+
import { CliError, UsageError } from "./errors.js";
|
|
4
|
+
import { bearerFor } from "./oauth.js";
|
|
5
|
+
import { loadHttpSdk } from "./sdk.js";
|
|
6
|
+
function failure(result) {
|
|
7
|
+
const reason = "reason" in result && typeof result.reason === "string" ? `: ${result.reason}` : "";
|
|
8
|
+
return `messages: ${result.outcome}${"status" in result && result.status ? ` (${result.status})` : ""}${reason}`;
|
|
9
|
+
}
|
|
10
|
+
export async function cmdMessages(args, ctx, deps = {}) {
|
|
11
|
+
const [action, ...extra] = positionals(args);
|
|
12
|
+
if (action !== "read" || extra.length)
|
|
13
|
+
throw new UsageError("messages takes: read --ticket CTC-N [--since SEQUENCE]");
|
|
14
|
+
const ticket = flagString(args, "ticket")?.trim().toUpperCase();
|
|
15
|
+
if (!ticket)
|
|
16
|
+
throw new UsageError("messages read needs --ticket CTC-N");
|
|
17
|
+
const rawSince = flagString(args, "since");
|
|
18
|
+
const since = rawSince === undefined ? undefined : Number(rawSince);
|
|
19
|
+
if (since !== undefined && (!Number.isSafeInteger(since) || since < 0))
|
|
20
|
+
throw new UsageError("--since must be a non-negative message sequence");
|
|
21
|
+
const cfg = requireConfig(ctx);
|
|
22
|
+
const createClient = deps.createClient ?? (async (options) => (await loadHttpSdk()).createTenantClient(options));
|
|
23
|
+
const client = await createClient({ key: await bearerFor(ctx, cfg), baseUrl: cfg.baseUrl, fetch: ctx.fetch });
|
|
24
|
+
if (!client.messages)
|
|
25
|
+
throw new CliError("the installed SDK cannot read messages; upgrade the catalyst CLI", "sdk-upgrade-required");
|
|
26
|
+
const result = await client.messages.read({ ticket, ...(since === undefined ? {} : { since }) });
|
|
27
|
+
if (result.outcome !== "ok") {
|
|
28
|
+
if (args.json)
|
|
29
|
+
ctx.stdout(JSON.stringify(result));
|
|
30
|
+
else
|
|
31
|
+
ctx.stderr(failure(result));
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
if (args.json)
|
|
35
|
+
ctx.stdout(JSON.stringify({ ticket: result.ticket, messages: result.messages, next: result.next }));
|
|
36
|
+
else if (result.messages.length === 0)
|
|
37
|
+
ctx.stdout(`${result.ticket}: no messages${since === undefined ? "" : ` at or after ${since}`}`);
|
|
38
|
+
else
|
|
39
|
+
for (const message of result.messages) {
|
|
40
|
+
ctx.stdout(`#${message.seq} ${message.sentAt} ${message.from.label} (${message.kind})`);
|
|
41
|
+
for (const line of message.body.split("\n"))
|
|
42
|
+
ctx.stdout(` ${line}`);
|
|
43
|
+
}
|
|
44
|
+
if (result.next !== null)
|
|
45
|
+
ctx.stderr(`more: re-run with --since ${result.next}`);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catalyst-cloud/cli",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.28",
|
|
4
4
|
"description": "Set up Catalyst Cloud, check your tickets and manage your account from the command line.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
"prepublishOnly": "node scripts/release-train-check.mjs --publish cli"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@catalyst-cloud/sdk": "0.16.
|
|
56
|
+
"@catalyst-cloud/sdk": "0.16.19",
|
|
57
57
|
"@clack/prompts": "1.8.1",
|
|
58
58
|
"fast-string-width": "3.0.2",
|
|
59
59
|
"fast-wrap-ansi": "0.2.2",
|
|
60
60
|
"smol-toml": "^1.7.1",
|
|
61
61
|
"yaml": "^2.9.0",
|
|
62
|
-
"@catalyst-cloud/sdk-replica-node": "0.16.
|
|
62
|
+
"@catalyst-cloud/sdk-replica-node": "0.16.19"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@catalyst-cloud/schema": "0.16.
|
|
65
|
+
"@catalyst-cloud/schema": "0.16.16",
|
|
66
66
|
"@types/node": "^26.3.0",
|
|
67
67
|
"@vitest/coverage-v8": "^4.1.11",
|
|
68
68
|
"typescript": "^7.0.2",
|
|
@@ -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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — 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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Catalyst Linear
|
|
10
10
|
|
|
@@ -14,6 +14,8 @@ Cloud reads are the default on every machine. They need no local writer and no l
|
|
|
14
14
|
| Find a ticket by words | `node scripts/search.mjs <terms>` |
|
|
15
15
|
| What happened to it, event by event? | `catalyst events query --ticket <KEY-123>` |
|
|
16
16
|
| Wait until its phase finishes | `catalyst events wait-for --ticket <KEY-123> --type relay.phase.completed --after <head> --timeout 300` |
|
|
17
|
+
| Wait until its branch or PR changes | `catalyst events wait-for --ref <owner/name:branch> --type pr.* --after <head> --timeout 14400` |
|
|
18
|
+
| What messages were sent to it? | `catalyst messages read --ticket <KEY-123>` |
|
|
17
19
|
|
|
18
20
|
## Reading the answer
|
|
19
21
|
|
|
@@ -28,7 +30,9 @@ A smaller read is coming: the cloud will answer a ticket or its execution histor
|
|
|
28
30
|
`catalyst events` reads the cloud by default and needs no local file.
|
|
29
31
|
|
|
30
32
|
- `catalyst events query --ticket <KEY-123>` prints the ticket's events, newest first. Add `--type`, `--limit` (up to 200), `--order asc` and `--before` or `--after` to page. An empty page says which sequences the cloud has indexed, so "no match" is not "never happened".
|
|
31
|
-
- To wait for something to happen, first run `catalyst events status --json` and keep its `head`. Then run `catalyst events wait-for --ticket <KEY-123> --type relay.phase.completed --after <head> --timeout 300`. Exit 0 prints the event, exit 1 is a timeout, and exit 4 means the cloud was unreachable.
|
|
33
|
+
- To wait for something to happen, first run `catalyst events status --json` and keep its `head`. Then run `catalyst events wait-for --ticket <KEY-123> --type relay.phase.completed --after <head> --timeout 300`. Exit 0 prints the event, exit 1 is a timeout, exit 2 is a refusal with its reason, and exit 4 means the cloud was unreachable.
|
|
34
|
+
- To wait on a branch, a pull request, a repository, a phase session or messages addressed to you, use `--ref <owner/name:branch>`, `--pr <owner/name#n>`, `--repo <owner/name>`, `--session <KEY-123/phase#n>` or `--to me`, with `--type pr.*` for a family of types. Such a wait prints nothing until a match, so `--timeout 14400` costs nothing while it waits. On a timeout, stderr names the `--after` to resume from.
|
|
35
|
+
- `catalyst messages read --ticket <KEY-123> [--since <sequence>]` prints the messages sent to the ticket, with sender and time.
|
|
32
36
|
- `catalyst events tail --ticket <KEY-123>` stays in the foreground and prints one JSON line per new event.
|
|
33
37
|
|
|
34
38
|
The ticket filter reads the event's ticket entity, `payload.ticket`, and the lease that caused it. `--from-cache` reads this machine's local event cache instead. It exists only where local sync is on, and it pays off when several agents on one machine share it.
|
|
@@ -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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — 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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — 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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — 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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — 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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — 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?", "what machines do we have?", "how much capacity do we have?", "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.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.28 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What's happening
|
|
10
10
|
|
|
@@ -13,9 +13,11 @@ Cloud reads are the default everywhere and need no local writer or database. Eac
|
|
|
13
13
|
| what changed since a point | `catalyst query changes --since head` |
|
|
14
14
|
| a ticket's events, newest first | `catalyst events query --ticket KEY-123` |
|
|
15
15
|
| wait for a phase to finish | `catalyst events wait-for --ticket KEY-123 --type relay.phase.completed --after <head> --timeout 300` |
|
|
16
|
+
| wait on a branch or PR | `catalyst events wait-for --ref owner/name:branch --type pr.* --after <head> --timeout 14400` |
|
|
17
|
+
| read a ticket's messages | `catalyst messages read --ticket KEY-123` |
|
|
16
18
|
|
|
17
19
|
A status-only read of a ticket and of its execution history is coming. No CLI flag selects it yet; read the full record.
|
|
18
20
|
|
|
19
|
-
Events: `catalyst events` reads the cloud by default. `events status --json` gives the `head` to wait after. Exit 4 from `wait-for` is an outage, not a timeout. `--from-cache` reads the local event cache, which exists only where local sync is on.
|
|
21
|
+
Events: `catalyst events` reads the cloud by default. `events status --json` gives the `head` to wait after. Exit 4 from `wait-for` is an outage, not a timeout; exit 2 is a refusal, with the reason. A wait on `--repo`, `--ref`, `--pr`, `--session` or `--to me` prints nothing until a match, so a long timeout costs nothing. `--from-cache` reads the local event cache, which exists only where local sync is on.
|
|
20
22
|
|
|
21
23
|
Local SQL: `references/local-replica.md`, only when `configured: true`.
|