@catalyst-cloud/catalyst-skills 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -182
- package/bin/catalyst-skills.js +3 -49
- package/bin/catalyst.js +3 -0
- package/package.json +8 -31
- package/CHANGELOG.md +0 -65
- package/LICENSE +0 -21
- package/dist/args.js +0 -273
- package/dist/ask.js +0 -161
- package/dist/browser.js +0 -20
- package/dist/cli.js +0 -361
- package/dist/config.js +0 -152
- package/dist/contract-types.js +0 -4
- package/dist/contract.js +0 -184
- package/dist/detach.js +0 -10
- package/dist/environment.js +0 -207
- package/dist/errors.js +0 -27
- package/dist/events.js +0 -106
- package/dist/execution.js +0 -451
- package/dist/oauth.js +0 -300
- package/dist/pagination.js +0 -76
- package/dist/prompt.js +0 -35
- package/dist/published.js +0 -75
- package/dist/query.js +0 -248
- package/dist/ready.js +0 -254
- package/dist/release.js +0 -142
- package/dist/replica.js +0 -585
- package/dist/sdk.js +0 -26
- package/dist/semver.js +0 -18
- package/dist/skill-shape.js +0 -189
- package/dist/skills.js +0 -129
- package/dist/transport.js +0 -205
- package/dist/ts-deps-loader.js +0 -113
- package/dist/watch/consumer.js +0 -141
- package/dist/watch/cursor-file.js +0 -62
- package/dist/watch.js +0 -175
- package/dist/write.js +0 -224
- package/skills/catalyst-github/SKILL.md +0 -35
- package/skills/catalyst-github/agents/openai.yaml +0 -6
- package/skills/catalyst-github/agents/portability.yaml +0 -4
- package/skills/catalyst-github/references/is-it-mergeable.md +0 -57
- package/skills/catalyst-github/references/what-a-pr-accumulates.md +0 -61
- package/skills/catalyst-github/scripts/is-it-mergeable.mjs +0 -124
- package/skills/catalyst-github/scripts/lib/cli.mjs +0 -103
- package/skills/catalyst-github/scripts/lib/credential.mjs +0 -29
- package/skills/catalyst-github/scripts/lib/pull.mjs +0 -82
- package/skills/catalyst-github/scripts/read-pr.mjs +0 -97
- package/skills/catalyst-linear/SKILL.md +0 -43
- package/skills/catalyst-linear/agents/openai.yaml +0 -6
- package/skills/catalyst-linear/agents/portability.yaml +0 -5
- package/skills/catalyst-linear/references/reading-a-ticket.md +0 -52
- package/skills/catalyst-linear/references/what-a-ticket-accumulates.md +0 -53
- package/skills/catalyst-linear/references/writing-to-linear.md +0 -43
- package/skills/catalyst-linear/scripts/comment.mjs +0 -59
- package/skills/catalyst-linear/scripts/create-ticket.mjs +0 -44
- package/skills/catalyst-linear/scripts/label.mjs +0 -48
- package/skills/catalyst-linear/scripts/lib/cli.mjs +0 -164
- package/skills/catalyst-linear/scripts/lib/credential.mjs +0 -29
- package/skills/catalyst-linear/scripts/move.mjs +0 -41
- package/skills/catalyst-linear/scripts/read-ticket.mjs +0 -93
- package/skills/catalyst-linear/scripts/search.mjs +0 -49
- package/skills/catalyst-onboard/SKILL.md +0 -49
- package/skills/catalyst-onboard/agents/openai.yaml +0 -6
- package/skills/catalyst-onboard/agents/portability.yaml +0 -5
- package/skills/catalyst-onboard/references/the-one-path.md +0 -143
- package/skills/catalyst-onboard/references/what-the-browser-owns.md +0 -50
- package/skills/catalyst-onboard/references/who-fixes-what.md +0 -41
- package/skills/catalyst-onboard/scripts/lib/cli.mjs +0 -117
- package/skills/catalyst-onboard/scripts/lib/credential.mjs +0 -29
- package/skills/catalyst-onboard/scripts/where-am-i.mjs +0 -245
- package/skills/catalyst-setup/SKILL.md +0 -32
- package/skills/catalyst-setup/agents/openai.yaml +0 -6
- package/skills/catalyst-setup/agents/portability.yaml +0 -4
- package/skills/catalyst-setup/references/what-each-check-means.md +0 -78
- package/skills/catalyst-setup/scripts/check.mjs +0 -75
- package/skills/catalyst-setup/scripts/lib/cli.mjs +0 -103
- package/skills/catalyst-setup/scripts/lib/credential.mjs +0 -29
- package/skills/catalyst-setup/scripts/replica-status.mjs +0 -46
- package/skills/connect-me/SKILL.md +0 -63
- package/skills/connect-me/agents/openai.yaml +0 -6
- package/skills/connect-me/agents/portability.yaml +0 -5
- package/skills/connect-me/references/keeping-the-replica-running.md +0 -88
- package/skills/connect-me/scripts/lib/cli.mjs +0 -185
- package/skills/connect-me/scripts/lib/credential.mjs +0 -29
- package/skills/connect-me/scripts/verify-connection.mjs +0 -68
- package/skills/how-catalyst-works/SKILL.md +0 -42
- package/skills/how-catalyst-works/agents/openai.yaml +0 -6
- package/skills/how-catalyst-works/agents/portability.yaml +0 -4
- package/skills/how-catalyst-works/references/coding-accounts.md +0 -51
- package/skills/how-catalyst-works/references/stages-and-mapping.md +0 -54
- package/skills/how-catalyst-works/references/the-ladder.md +0 -41
- package/skills/how-catalyst-works/references/what-runs-next.md +0 -77
- package/skills/how-catalyst-works/references/when-a-phase-fails.md +0 -57
- package/skills/how-catalyst-works/scripts/explain-ticket.mjs +0 -41
- package/skills/how-catalyst-works/scripts/lib/cli.mjs +0 -164
- package/skills/how-catalyst-works/scripts/lib/credential.mjs +0 -29
- package/skills/how-catalyst-works/scripts/show-my-map.mjs +0 -94
- package/skills/how-catalyst-works/scripts/whats-running.mjs +0 -65
- package/skills/run-this-project/SKILL.md +0 -45
- package/skills/run-this-project/agents/openai.yaml +0 -6
- package/skills/run-this-project/agents/portability.yaml +0 -5
- package/skills/run-this-project/assets/stall-policy.json +0 -15
- package/skills/run-this-project/references/making-work-ready.md +0 -60
- package/skills/run-this-project/references/reacting-to-events.md +0 -76
- package/skills/run-this-project/references/stalls-and-escalation.md +0 -63
- package/skills/run-this-project/scripts/lib/cli.mjs +0 -185
- package/skills/run-this-project/scripts/lib/credential.mjs +0 -29
- package/skills/run-this-project/scripts/make-ready.mjs +0 -64
- package/skills/run-this-project/scripts/scope-status.mjs +0 -0
- package/skills/run-this-project/scripts/watch-scope.mjs +0 -61
- package/skills/unstick/SKILL.md +0 -41
- package/skills/unstick/agents/openai.yaml +0 -6
- package/skills/unstick/agents/portability.yaml +0 -5
- package/skills/unstick/references/playbook.md +0 -51
- package/skills/unstick/scripts/lib/cli.mjs +0 -135
- package/skills/unstick/scripts/lib/credential.mjs +0 -29
- package/skills/unstick/scripts/unstick.mjs +0 -57
- package/skills/what-needs-me/SKILL.md +0 -41
- package/skills/what-needs-me/agents/openai.yaml +0 -6
- package/skills/what-needs-me/agents/portability.yaml +0 -5
- package/skills/what-needs-me/references/raising-a-decision.md +0 -41
- package/skills/what-needs-me/references/reading-the-inbox.md +0 -38
- package/skills/what-needs-me/references/settling-an-answer.md +0 -37
- package/skills/what-needs-me/scripts/inbox.mjs +0 -56
- package/skills/what-needs-me/scripts/lib/cli.mjs +0 -135
- package/skills/what-needs-me/scripts/lib/credential.mjs +0 -29
- package/skills/what-needs-me/scripts/raise.mjs +0 -53
- package/skills/what-needs-me/scripts/settle.mjs +0 -73
- package/skills/whats-happening/SKILL.md +0 -43
- package/skills/whats-happening/agents/openai.yaml +0 -6
- package/skills/whats-happening/agents/portability.yaml +0 -4
- package/skills/whats-happening/assets/status-reply.json +0 -77
- package/skills/whats-happening/references/reading-the-board.md +0 -43
- package/skills/whats-happening/references/reprioritising.md +0 -37
- package/skills/whats-happening/references/routing-work.md +0 -36
- package/skills/whats-happening/references/status-reply.md +0 -34
- package/skills/whats-happening/references/why-is-it-stuck.md +0 -62
- package/skills/whats-happening/scripts/explain.mjs +0 -28
- package/skills/whats-happening/scripts/lib/cli.mjs +0 -135
- package/skills/whats-happening/scripts/lib/credential.mjs +0 -29
- package/skills/whats-happening/scripts/snapshot.mjs +0 -149
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// where-am-i.mjs — how far has setup got? FIVE PARTS, EACH READ BY THE INSTRUMENT THAT OWNS IT, and
|
|
3
|
-
// each finding labelled with the part it belongs to. The whole point of this script is that no part
|
|
4
|
-
// answers for another: a project that is not ready is reported as a project finding with a tenant
|
|
5
|
-
// owner's name on it, never as something the person at this keyboard can fix by running anything.
|
|
6
|
-
//
|
|
7
|
-
// Every count and every name below is read off what a verb printed. Nothing here is written down.
|
|
8
|
-
import { cliTarget, CONNECT_LINE, parseFlags, printHelp, runCli, tryJson, tryLoadConfig } from "./lib/cli.mjs";
|
|
9
|
-
|
|
10
|
-
const SPEC = {
|
|
11
|
-
next: { help: "print only the single next step" },
|
|
12
|
-
json: { help: "one JSON document instead of the report" },
|
|
13
|
-
};
|
|
14
|
-
const NOTES = [
|
|
15
|
-
"Reads, in this order: `status` (machine), `ready --json` (machine checks and project checks, kept apart),",
|
|
16
|
-
"`me --json` (person), and `contract --path …` for the account, the projects and the repositories.",
|
|
17
|
-
"Writes nothing and changes nothing. Runs before this machine is connected — that is one of the states it reports.",
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const { help, flags, positionals } = parseFlags(process.argv.slice(2), SPEC);
|
|
21
|
-
if (help) {
|
|
22
|
-
printHelp("node scripts/where-am-i.mjs [--next] [--json]", SPEC, NOTES);
|
|
23
|
-
process.exit(0);
|
|
24
|
-
}
|
|
25
|
-
if (positionals.length > 0) {
|
|
26
|
-
process.stderr.write(`unexpected argument: ${positionals[0]} (try --help)\n`);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const via = cliTarget().via;
|
|
31
|
-
const parts = [];
|
|
32
|
-
// `blocking` is false for a finding that is real and reportable but does not stop the next step —
|
|
33
|
-
// an unmatched Linear identity is the one that matters: it must be said, and it must not become the
|
|
34
|
-
// thing the person is told to go and do before they can map a project.
|
|
35
|
-
const add = (part, instrument, verdict, lines, owner = null, where = null, blocking = true) =>
|
|
36
|
-
parts.push({ part, instrument, verdict, lines, owner, where, blocking });
|
|
37
|
-
|
|
38
|
-
// ── machine ───────────────────────────────────────────────────────────────────────────────────────
|
|
39
|
-
const status = runCli(["status"]);
|
|
40
|
-
if (!status.ran) {
|
|
41
|
-
process.stderr.write(`${status.stderr}\n`);
|
|
42
|
-
process.stderr.write(`the catalyst-skills CLI could not be started. Install it, then run this again.\n`);
|
|
43
|
-
process.exit(2);
|
|
44
|
-
}
|
|
45
|
-
const statusLines = status.stdout.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
46
|
-
const field = (name) => {
|
|
47
|
-
const line = statusLines.find((l) => l.startsWith(`${name}:`));
|
|
48
|
-
return line ? line.slice(name.length + 1).trim() : null;
|
|
49
|
-
};
|
|
50
|
-
const tenant = field("Tenant");
|
|
51
|
-
const api = field("API");
|
|
52
|
-
const connected = tenant !== null && tryLoadConfig() !== null;
|
|
53
|
-
// The app and the API share an origin; the base URL is whatever this machine was connected to, so
|
|
54
|
-
// no page link in this report is a host anyone typed from memory.
|
|
55
|
-
const cloud = api === null ? null : api.split(" ")[0].replace(/\/+$/, "");
|
|
56
|
-
const link = (path) => (cloud === null ? `<your cloud>${path}` : `${cloud}${path}`);
|
|
57
|
-
|
|
58
|
-
const machineLines = connected ? statusLines : [statusLines[0] ?? "status printed nothing"];
|
|
59
|
-
let machineVerdict = connected ? "ok" : "unfinished";
|
|
60
|
-
|
|
61
|
-
// `ready` is ONE verdict over two parts; split it by check id before anything is reported. A check
|
|
62
|
-
// whose id begins with "team:" belongs to a project and cannot be moved from this machine.
|
|
63
|
-
let projectChecks = [];
|
|
64
|
-
let machineFix = null;
|
|
65
|
-
if (connected) {
|
|
66
|
-
const ready = runCli(["ready", "--json"]);
|
|
67
|
-
const report = tryJson(ready.stdout);
|
|
68
|
-
const checks = Array.isArray(report?.checks) ? report.checks : null;
|
|
69
|
-
if (checks === null) {
|
|
70
|
-
machineLines.push(`ready: could not be read (${(ready.stderr || ready.stdout).trim().split("\n")[0] ?? "no output"})`);
|
|
71
|
-
machineVerdict = "unfinished";
|
|
72
|
-
} else {
|
|
73
|
-
projectChecks = checks.filter((c) => typeof c.id === "string" && c.id.startsWith("team:"));
|
|
74
|
-
const machineChecks = checks.filter((c) => !(typeof c.id === "string" && c.id.startsWith("team:")));
|
|
75
|
-
const failed = machineChecks.filter((c) => !c.ok && !c.note);
|
|
76
|
-
for (const c of machineChecks) machineLines.push(`${c.note ? "note" : c.ok ? "ok " : "FAIL"} ${c.line}${!c.ok && !c.note && c.fix ? ` — fix: ${c.fix}` : ""}`);
|
|
77
|
-
if (failed.length > 0) {
|
|
78
|
-
machineVerdict = "unfinished";
|
|
79
|
-
machineFix = failed.find((c) => typeof c.fix === "string")?.fix ?? null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
add(
|
|
84
|
-
"machine",
|
|
85
|
-
"catalyst-skills status, and the non-team checks of catalyst-skills ready",
|
|
86
|
-
machineVerdict,
|
|
87
|
-
machineLines,
|
|
88
|
-
"you, on this machine",
|
|
89
|
-
connected ? null : CONNECT_LINE,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// ── person ────────────────────────────────────────────────────────────────────────────────────────
|
|
93
|
-
if (!connected) {
|
|
94
|
-
add("person", "catalyst-skills me", "unreadable", ["not readable until this machine is connected"], null, null);
|
|
95
|
-
} else {
|
|
96
|
-
const me = runCli(["me", "--json"]);
|
|
97
|
-
const doc = tryJson(me.stdout);
|
|
98
|
-
const user = doc && typeof doc.user === "object" && doc.user !== null ? doc.user : null;
|
|
99
|
-
if (doc === null) {
|
|
100
|
-
add("person", "catalyst-skills me", "unreadable", [`me could not be read (${(me.stderr || me.stdout).trim().split("\n")[0] ?? "no output"})`], null, null);
|
|
101
|
-
} else if (user === null) {
|
|
102
|
-
add(
|
|
103
|
-
"person",
|
|
104
|
-
"catalyst-skills me",
|
|
105
|
-
"unfinished",
|
|
106
|
-
["this credential names no person — it is a host credential, so nothing an agent writes will carry a name"],
|
|
107
|
-
"you: connect again with your own login",
|
|
108
|
-
CONNECT_LINE,
|
|
109
|
-
);
|
|
110
|
-
} else {
|
|
111
|
-
const matched = typeof user.linearUserId === "string" && user.linearUserId !== "";
|
|
112
|
-
add(
|
|
113
|
-
"person",
|
|
114
|
-
"catalyst-skills me",
|
|
115
|
-
matched ? "ok" : "unfinished",
|
|
116
|
-
[`${user.label ?? "(unnamed)"} (${user.role ?? "role unknown"})`, matched ? "Linear identity matched" : "Linear identity NOT matched — asks assigned to you cannot be told apart from everyone else's. It blocks nothing below; get it fixed when convenient."],
|
|
117
|
-
matched ? null : "a tenant owner or admin",
|
|
118
|
-
matched ? null : link("/settings/account"),
|
|
119
|
-
false,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ── account ───────────────────────────────────────────────────────────────────────────────────────
|
|
125
|
-
if (!connected) {
|
|
126
|
-
add("account", "catalyst-skills contract --path account", "unreadable", ["not readable until this machine is connected"], null, null);
|
|
127
|
-
} else {
|
|
128
|
-
const acct = runCli(["contract", "--path", "account", "--json"]);
|
|
129
|
-
const doc = tryJson(acct.stdout);
|
|
130
|
-
if (doc === null) {
|
|
131
|
-
add("account", "catalyst-skills contract --path account", "unreadable", ["the account block could not be read — try: catalyst-skills contract --refresh"], null, null);
|
|
132
|
-
} else {
|
|
133
|
-
const workspace = typeof doc.linearWorkspaceSlug === "string" && doc.linearWorkspaceSlug !== "" ? doc.linearWorkspaceSlug : typeof doc.linearWorkspaceId === "string" && doc.linearWorkspaceId !== "" ? doc.linearWorkspaceId : null;
|
|
134
|
-
// The declaration is the one part of the account a key can also READ — and it is the one part a
|
|
135
|
-
// key can WRITE, so it is reported here rather than left to the settings page like the rest.
|
|
136
|
-
const envLines = [];
|
|
137
|
-
const env = runCli(["environment", "read", "--json"]);
|
|
138
|
-
const envDoc = tryJson(env.stdout);
|
|
139
|
-
if (envDoc === null) {
|
|
140
|
-
envLines.push(`environment: not readable (${(env.stderr || env.stdout).trim().split("\n")[0] ?? "no output"})`);
|
|
141
|
-
} else if (envDoc.current === null || envDoc.current === undefined) {
|
|
142
|
-
envLines.push("environment: nothing declared yet — declare it with `catalyst-skills environment propose --file <path> --approve`");
|
|
143
|
-
} else {
|
|
144
|
-
envLines.push(`environment: revision ${envDoc.current.revision} (${envDoc.current.canonicalHash}), ${envDoc.isApproved ? "approved" : "NOT approved — a proposal nobody approved changes nothing"}`);
|
|
145
|
-
envLines.push(envDoc.delivered ? `environment delivered to phases: revision ${envDoc.delivered.revision}` : "environment delivered to phases: nothing yet");
|
|
146
|
-
const unresolved = Array.isArray(envDoc.unresolvedReferences) ? envDoc.unresolvedReferences : [];
|
|
147
|
-
if (unresolved.length > 0) envLines.push(`environment names values this tenant does not carry yet: ${unresolved.join(", ")}`);
|
|
148
|
-
}
|
|
149
|
-
add(
|
|
150
|
-
"account",
|
|
151
|
-
"catalyst-skills contract --path account, and catalyst-skills environment read",
|
|
152
|
-
workspace === null ? "unfinished" : "ok",
|
|
153
|
-
[
|
|
154
|
-
`${doc.name ?? "(unnamed tenant)"} (${doc.slug ?? "?"})`,
|
|
155
|
-
workspace === null ? "no Linear workspace resolved on this contract" : `Linear workspace resolved: ${workspace}`,
|
|
156
|
-
"the GitHub App install is NOT carried here — the connections page is the only place that shows it",
|
|
157
|
-
...envLines,
|
|
158
|
-
],
|
|
159
|
-
"a tenant owner or admin",
|
|
160
|
-
link("/settings/connections"),
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ── projects (a project is one Linear team) ───────────────────────────────────────────────────────
|
|
166
|
-
if (!connected) {
|
|
167
|
-
add("projects", "catalyst-skills contract --path teams", "unreadable", ["not readable until this machine is connected"], null, null);
|
|
168
|
-
} else {
|
|
169
|
-
const teams = runCli(["contract", "--path", "teams", "--json"]);
|
|
170
|
-
const doc = tryJson(teams.stdout);
|
|
171
|
-
const rows = Array.isArray(doc) ? doc : null;
|
|
172
|
-
if (rows === null) {
|
|
173
|
-
add("projects", "catalyst-skills contract --path teams", "unreadable", ["the project list could not be read — try: catalyst-skills contract --refresh"], null, null);
|
|
174
|
-
} else {
|
|
175
|
-
const lines = [`${rows.length} mapped`];
|
|
176
|
-
for (const t of rows) {
|
|
177
|
-
const key = t.key ?? t.id ?? "(unkeyed)";
|
|
178
|
-
const readiness = t.readiness ?? {};
|
|
179
|
-
const bad = Array.isArray(readiness.checks) ? readiness.checks.filter((c) => c.state !== "pass") : [];
|
|
180
|
-
lines.push(`${key}: ${readiness.status ?? "unknown"}${bad.length ? ` — ${bad.map((c) => `${c.id} ${c.state}`).join(", ")}` : ""}`);
|
|
181
|
-
}
|
|
182
|
-
for (const c of projectChecks) lines.push(`${c.ok ? "note" : "FAIL"} ${c.line}${c.who ? ` — who: ${c.who}` : ""}`);
|
|
183
|
-
lines.push("⛔ MAPPED projects only. An empty list means nothing is mapped yet, NOT that there are no projects — the full list is on the page below.");
|
|
184
|
-
const ready = rows.length > 0 && rows.every((t) => (t.readiness?.status ?? "unchecked") === "ready");
|
|
185
|
-
add("projects", "catalyst-skills contract --path teams, and the team: checks of ready", ready ? "ok" : "unfinished", lines, "a tenant owner or admin", link("/settings/linear-teams"));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ── repositories ──────────────────────────────────────────────────────────────────────────────────
|
|
190
|
-
if (!connected) {
|
|
191
|
-
add("repositories", "catalyst-skills contract --path merge.repositories", "unreadable", ["not readable until this machine is connected"], null, null);
|
|
192
|
-
} else {
|
|
193
|
-
const repos = runCli(["contract", "--path", "merge.repositories", "--json"]);
|
|
194
|
-
const doc = tryJson(repos.stdout);
|
|
195
|
-
const rows = Array.isArray(doc) ? doc : null;
|
|
196
|
-
if (rows === null) {
|
|
197
|
-
add("repositories", "catalyst-skills contract --path merge.repositories", "unreadable", ["the repository list could not be read — try: catalyst-skills contract --refresh"], null, null);
|
|
198
|
-
} else {
|
|
199
|
-
const lines = [`${rows.length} registered`, ...rows.map((r) => `${r.owner ?? "?"}/${r.name ?? "?"}`)];
|
|
200
|
-
lines.push("⛔ REGISTRATION only. This carries no status and no project attachment, so it never proves a repository can be dispatched into.");
|
|
201
|
-
add("repositories", "catalyst-skills contract --path merge.repositories", rows.length > 0 ? "ok" : "unfinished", lines, "a tenant owner or admin", link("/settings/repositories"));
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ── the single next step ──────────────────────────────────────────────────────────────────────────
|
|
206
|
-
// The machine's next action is not one sentence: an unconnected machine needs the login, and a
|
|
207
|
-
// connected one needs whatever check failed — and `ready` already printed that check's own fix, so
|
|
208
|
-
// this carries it through rather than inventing a second answer to the same question.
|
|
209
|
-
const machineNext = connected
|
|
210
|
-
? `clear the machine check that failed — ${machineFix ?? "see the machine lines above"}`
|
|
211
|
-
: "connect this machine";
|
|
212
|
-
const NEXT = {
|
|
213
|
-
machine: machineNext,
|
|
214
|
-
person: "get this person's seat and Linear identity sorted",
|
|
215
|
-
account: "connect Linear, and install the GitHub App",
|
|
216
|
-
projects: "pick ONE project and map its stages (or adopt the Catalyst workflow)",
|
|
217
|
-
repositories: "register the repository, attaching it to the project you mapped",
|
|
218
|
-
};
|
|
219
|
-
const blocked = parts.filter((p) => p.verdict !== "ok" && p.blocking);
|
|
220
|
-
const stuck = blocked[0] ?? parts.find((p) => p.verdict !== "ok") ?? null;
|
|
221
|
-
const next =
|
|
222
|
-
stuck === null
|
|
223
|
-
? null
|
|
224
|
-
: { part: stuck.part, action: NEXT[stuck.part], owner: stuck.owner, where: stuck.where, blocking: stuck.blocking };
|
|
225
|
-
const finished = parts.every((p) => p.verdict === "ok");
|
|
226
|
-
|
|
227
|
-
if (flags.json) {
|
|
228
|
-
console.log(JSON.stringify({ cli: via, connected, cloud, parts, next, finished }));
|
|
229
|
-
} else if (flags.next) {
|
|
230
|
-
if (next === null) console.log("nothing left: every part this machine can read is finished. Move one card into the project's dispatch stage.");
|
|
231
|
-
else console.log(`${next.part}: ${next.action}${next.blocking ? "" : " (does not block the steps below)"}${next.owner ? ` — who: ${next.owner}` : ""}${next.where ? ` — ${next.where.startsWith("http") ? "where" : "do"}: ${next.where}` : ""}`);
|
|
232
|
-
} else {
|
|
233
|
-
for (const p of parts) {
|
|
234
|
-
console.log(`${p.part} [${p.verdict}]`);
|
|
235
|
-
console.log(` instrument: ${p.instrument}`);
|
|
236
|
-
for (const l of p.lines) console.log(` ${l}`);
|
|
237
|
-
if (p.verdict !== "ok" && p.owner) console.log(` who: ${p.owner}`);
|
|
238
|
-
// A page gets "where"; a command gets "do". Labelling a command "where" is how a person ends up
|
|
239
|
-
// looking for a settings page that is actually a line to run.
|
|
240
|
-
if (p.verdict !== "ok" && p.where) console.log(` ${p.where.startsWith("http") ? "where" : "do"}: ${p.where}`);
|
|
241
|
-
console.log("");
|
|
242
|
-
}
|
|
243
|
-
console.log(next === null ? "next: nothing left — move one card into the project's dispatch stage and watch." : `next: ${next.part} — ${next.action}${next.owner ? ` (${next.owner})` : ""}${next.where ? ` — ${next.where}` : ""}`);
|
|
244
|
-
}
|
|
245
|
-
process.exit(finished ? 0 : 1);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: catalyst-setup
|
|
3
|
-
description: >-
|
|
4
|
-
Am I set up? Machine readiness (Node, the tenant connection, the cached contract, the CLI path, the skills, the SDK, the optional replica) plus tenant readiness from the contract's per-team checks, in one verdict: what passes, what is blocked, what is merely waiting, and who can click what. Use when someone asks "am I set up", "what is missing", "why does nothing happen", "is the replica running", or right after connecting a new machine. Reports; never repairs.
|
|
5
|
-
allowed-tools: Bash(catalyst-skills:*) Bash(npx @catalyst-cloud/catalyst-skills:*)
|
|
6
|
-
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.7.0 — written in this repository for customer tenants -->
|
|
8
|
-
|
|
9
|
-
# Am I set up?
|
|
10
|
-
|
|
11
|
-
You answer one question with one verdict and one list. The verdict is READY or NOT READY. The list is who can click what: the fixes only the person at the keyboard can make, the fixes only a tenant owner or admin can make in settings, and the checks that are simply waiting for the first event. The live check ids, severities, states and the people who can answer come from the contract; the scripts print them, you never restate them.
|
|
12
|
-
|
|
13
|
-
## Run first
|
|
14
|
-
|
|
15
|
-
- `node scripts/check.mjs --help` — every machine and tenant check, one line each, the fix and who for each failure, the verdict, then the who-can-click-what list. Exit 1 when NOT READY.
|
|
16
|
-
- `node scripts/replica-status.mjs --help` — the optional replica's verdict with no network (add `--probe` for how far behind it is). Exit 0 fresh, 1 stale, 2 not connected, 3 absent.
|
|
17
|
-
|
|
18
|
-
## Load on demand
|
|
19
|
-
|
|
20
|
-
| when | read |
|
|
21
|
-
| -- | -- |
|
|
22
|
-
| any check is red, unknown or waiting and the person asks what it proves, how to fix it, or who can | `references/what-each-check-means.md` |
|
|
23
|
-
|
|
24
|
-
## Rules
|
|
25
|
-
|
|
26
|
-
- Report, never repair. No tenant-reachable repair verb exists for a key yet; the settings page is where a tenant owner or admin fixes a mapping, a connection or a label, and you say which one.
|
|
27
|
-
- End every answer with the verdict and the who-can-click-what list, in that order.
|
|
28
|
-
- A stale or absent replica is a note, never a failure: every skill reads the API meanwhile and says so. Do not tell the person to start it unless they want local SQL or cheaper repeated reads.
|
|
29
|
-
- Not connected (exit 2) means the connect step, not a retry: `npx @catalyst-cloud/catalyst-skills login`, which logs the person in keyless in their browser; with a personal key from Settings → API keys instead, prefix it with `CATALYST_CLOUD_TOKEN=<your personal key>`. Never guess a tenant; the login (or the key) is the only selector.
|
|
30
|
-
- Waiting is not failing. "No write observed", "no delivery observed" and "no host connected" clear themselves the first time the thing happens; say that instead of raising them.
|
|
31
|
-
- Unknown is not a pass. A check the engine could not run is reported as such, never rounded up.
|
|
32
|
-
- Never run a check in a loop. If the person wants to know when a waiting check clears, that is the project-running skill's watch.
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
interface:
|
|
2
|
-
display_name: "Am I set up?"
|
|
3
|
-
short_description: "Machine and tenant readiness in one verdict: what passes, what is blocked, and who can click what"
|
|
4
|
-
default_prompt: "Use $catalyst-setup to tell me whether this machine and my tenant are ready, and what is missing."
|
|
5
|
-
policy:
|
|
6
|
-
allow_implicit_invocation: true
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# What each check means
|
|
2
|
-
|
|
3
|
-
This page restates invariants: the per-team readiness checks the cloud runs, what each proves, its fix and who can click it; the machine checks the CLI adds; and the four replica verdicts. The live values are never restated: each check's severity and whether it needs a human's answer come from the contract's `readinessChecks[]`, each team's current states from `teams[].readiness`, and the people who can answer from `humans[]`. `node scripts/check.mjs` prints all of it; this page is how to read what it printed.
|
|
4
|
-
|
|
5
|
-
## How a team's readiness is scored
|
|
6
|
-
|
|
7
|
-
A team's status is one of `ready`, `degraded`, `blocked` or `unchecked`. The engine always reports every check the contract lists; a check it could not run is `unknown`, never `pass`. Any failing check the contract marks as blocking makes the team blocked; any unknown, and any failing check marked degrading, makes it degraded. Unchecked means no readiness pass has run for that team yet, which is a note, not a failure. Readiness is stamped with the account-wide mapping revision it was computed against, so a stale verdict is visible as such.
|
|
8
|
-
|
|
9
|
-
## The checks
|
|
10
|
-
|
|
11
|
-
The contract's `readinessChecks[]` is the list of record. A check that appears there and not here is newer than this page; `node scripts/check.mjs` still prints it with its own severity, fix and owner, so read the printed line and say you did.
|
|
12
|
-
|
|
13
|
-
| check id | proves | when it fails, the fix | who clicks |
|
|
14
|
-
| -- | -- | -- | -- |
|
|
15
|
-
| `oauth_scope` | Catalyst holds the Linear permissions it needs | re-authorise the Linear connection to grant the missing scope | a tenant owner or admin, in settings |
|
|
16
|
-
| `token_live` | the Linear connection is accepted right now | reconnect Linear (expired or revoked), or wait and re-check (Linear unreachable). A distinct reason says Linear was never connected at all | owner or admin |
|
|
17
|
-
| `team_visible` | Catalyst can see this team | most often the team was made private: grant Catalyst access in Linear's team settings, then re-check | owner or admin, in Linear |
|
|
18
|
-
| `mapped_states_exist` | every stage Catalyst mapped still exists in Linear | re-map the team; nothing in the workspace was changed. A pending-write reason means a mapping was just saved and the read has not caught up: wait, do not re-map | owner or admin, in settings |
|
|
19
|
-
| `mapping_total` | every stage Catalyst moves tickets into is mapped | map the missing stages. "Absent" means the team was never mapped; "incomplete" means a few of the load-bearing stages are missing | owner or admin, in settings |
|
|
20
|
-
| `types_compatible` | each load-bearing mapped stage is the right kind (dispatch and intake unstarted or backlog, PR started, done completed, canceled canceled) | change the mapping to a stage of the right kind | owner or admin, in settings |
|
|
21
|
-
| `labels_present` | the labels Catalyst uses exist in the workspace | none needed by a person: Catalyst creates them the first time it uses them | nobody |
|
|
22
|
-
| `writes_land` | Catalyst has written to this team successfully | "no write observed" is waiting, not failing: it clears the first time Catalyst moves a ticket. "Write refused" means Linear rejected the last write: check the connection and the team's permissions | owner or admin when refused; otherwise nobody |
|
|
23
|
-
| `webhook_covers_team` | events for this team are arriving | confirmed once a repository is registered and events flow; "no delivery observed" is waiting | owner or admin, by registering the repository |
|
|
24
|
-
| `hosts_current` | no connected host runs an older mapping revision | a host that is behind re-loads the mapping on its next connect; a host that did not report its revision is flagged rather than assumed current; "no host connected" is waiting | whoever runs that host |
|
|
25
|
-
| `environment_declared` | a committed environment declaration for the team's default repository is in effect (`catalyst.env.json` at the repository root was ingested, is valid, and its latest proposal is approved) | `no_team_repo_default`: register a repository and make it the team's default; `no_environment_declaration`: commit the declaration file to that repository; `declaration_invalid` / `declaration_read_failed`: fix the file (the ingest names the error); `declaration_awaiting_approval`: an owner or admin approves the proposal in Settings → Environment | owner or admin, except committing the file, which is whoever can push to the repository |
|
|
26
|
-
| `tools_resolvable` | every MCP server and CLI the team's approved environment declaration names can be resolved for that team's repository | `tool_reference_unresolved`: the declaration names a vault secret that does not exist — add it at the right scope or correct the declaration; `toolchain_cli_missing`: a declared CLI is not in the runner image, which is not self-service; `tool_declarations_unread` reads as `unknown` and clears itself | owner or admin, in the declaration or Settings → Environment |
|
|
27
|
-
| `reviewer_required` | this team's repository can merge under its own merge policy with the reviewers configured | it fails only under a strict merge policy with no reviewer — configure one at Settings → Repositories → Code reviews, or change the repository's merge policy; work still runs, only the merge waits | owner or admin, in settings |
|
|
28
|
-
| `reviewer_configured` | a code reviewer is configured for this team's repository at all, whatever the current policy requires | a *failing* `reviewer_configured` never blocks or degrades a team — with no reviewer, pull requests merge on green checks and resolved threads alone; configure one at Settings → Repositories → Code reviews. An `unknown` one (`merge_reviewer_unread`: the reviewer registry could not be read) still degrades the team, like any unknown | owner or admin, in settings; nobody is required when it fails |
|
|
29
|
-
|
|
30
|
-
Some checks degrade a team without ever blocking it, and one is informational only — informational means a *fail* never moves the verdict, not that the check cannot: an unknown still degrades. Which check is which is served on `readinessChecks[].severity`; do not memorise the split.
|
|
31
|
-
|
|
32
|
-
## Reasons that look like failures and are not
|
|
33
|
-
|
|
34
|
-
- `no_write_observed`, `no_delivery_observed`, `no_host_connected`: nothing has happened yet. Expected on a fresh tenant; they clear on their own.
|
|
35
|
-
- `stages_pending_write`: a mapping was saved and the read predates it. Re-check shortly; re-mapping would be a second write for no reason.
|
|
36
|
-
- `unknown` on any check: the engine could not look. It is not a pass and not a fail; say so.
|
|
37
|
-
|
|
38
|
-
## The machine checks the CLI adds
|
|
39
|
-
|
|
40
|
-
`catalyst-skills ready` prepends checks about this machine before the tenant's:
|
|
41
|
-
|
|
42
|
-
| id | proves | fix |
|
|
43
|
-
| -- | -- | -- |
|
|
44
|
-
| `node` | Node 22 or newer, which the SDK's built-in SQLite engine needs | install Node 22+ |
|
|
45
|
-
| `config` | this machine is connected: `customer.json` exists and loads | `npx @catalyst-cloud/catalyst-skills login` (keyless: the person approves in their browser); or, with a personal key minted at Settings → API keys, the same command prefixed with `CATALYST_CLOUD_TOKEN=<your personal key>` |
|
|
46
|
-
| `contract` | the tenant contract is cached and its major version is one this bundle accepts | `catalyst-skills contract --refresh`; a version outside the range means update the bundle. A 403 naming an older cloud means the cloud has not yet deployed personal-key access |
|
|
47
|
-
| `bundle` | the installed CLI is at least the version this tenant requires | `npm install -g @catalyst-cloud/catalyst-skills@latest && catalyst-skills login`; a note, never a failure |
|
|
48
|
-
| `cliPath` | the CLI path recorded at login still exists, so skill scripts can spawn it | re-run login |
|
|
49
|
-
| `skills` | every skill of this bundle is present where the CLI installed them | `catalyst-skills install` |
|
|
50
|
-
| `cliRelease` | the installed CLI is not behind the newest published release | the same upgrade command as `bundle`; a note, never a failure |
|
|
51
|
-
| `skillsRelease` | the installed skill files are not behind the newest published bundle | `npx skills update -y`; a note, never a failure. A line saying the check could not run means the registry was unreachable, not that anything is wrong |
|
|
52
|
-
| `sdk` | the SDK loads, so the replica and the watch are available | run under Node 22.15 or newer; every read still works through the API meanwhile |
|
|
53
|
-
| `replica` | the optional replica is fresh | a note, never a failure; see below |
|
|
54
|
-
|
|
55
|
-
## The replica's four verdicts
|
|
56
|
-
|
|
57
|
-
`node scripts/replica-status.mjs` needs no network and exits with the verdict:
|
|
58
|
-
|
|
59
|
-
| exit | verdict | what a skill does with it |
|
|
60
|
-
| -- | -- | -- |
|
|
61
|
-
| 0 | fresh: a live writer, a heartbeat younger than the staleness threshold, a non-empty cursor | reads the replica and says so |
|
|
62
|
-
| 1 | stale: the file exists but the writer is gone, the heartbeat is old, or there is no cursor | reads the API and says so; `catalyst-skills replica start --detach` brings it back |
|
|
63
|
-
| 2 | not connected to a tenant | the connect step first |
|
|
64
|
-
| 3 | absent: no replica file at all | reads the API; the replica is optional and one command away |
|
|
65
|
-
|
|
66
|
-
`--probe` adds the one network call: it compares the local cursor with the cloud's head and prints how far behind the replica is, the only honest "how stale" number. A skill must never refuse to work because the replica is down, and must never silently read a stale one; both halves are one exit code away.
|
|
67
|
-
|
|
68
|
-
## The writer stops itself after repeated snapshot failures
|
|
69
|
-
|
|
70
|
-
`replica start` backs off with jitter after a failed or incomplete snapshot pull, and gives up after five consecutive snapshot failures rather than retrying forever — a writer that keeps failing never hammers the tenant. A snapshot that completes resets the count to zero. Both `catalyst-skills replica status` and `catalyst-skills ready` name the stopped state, the count, the last error, and the command that restarts it. The four exit codes above are unchanged: a stopped writer with a database already on disk still reads stale, since there truly is no live writer.
|
|
71
|
-
|
|
72
|
-
## Who can click what
|
|
73
|
-
|
|
74
|
-
The last block `check.mjs` prints groups every failure by the person it needs. Machine fixes name "you", the person at the keyboard. Tenant fixes name the owner or admin roles the contract lists (as Linear user ids, since that is how the cloud knows them), because the settings page that repairs a mapping, a connection or a label is theirs. A check the contract marks as not needing an answer names nobody: it is informational or self-clearing. This skill reports; it never repairs, because no key-reachable repair verb exists yet.
|
|
75
|
-
|
|
76
|
-
## Setting up one team at a time
|
|
77
|
-
|
|
78
|
-
A team starts receiving work only once its stages are saved, and that is done one team at a time: a tenant owner or admin opens Settings → Linear teams, picks the team and presses Map my stages (or Adopt the Catalyst workflow). No other team's stages or tickets change; only the labels Adopt creates are shared across the workspace. Before saving, the screen lists which of that team's tickets would start and which stay where they are. Once saved, the tickets in the team's dispatch stage start; tickets in other stages that Catalyst never worked on stay where they are. To pilot safely, pick a low-stakes team, move anything in its dispatch stage that should not start back to Backlog, and leave the other teams unmapped. `gitAutomation` in the contract plays no part: nothing reads it.
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// check.mjs — "am I set up?" in one verdict: the machine checks the CLI runs (Node, the connection,
|
|
3
|
-
// the cached contract, the CLI path, the skills, the SDK, the optional replica) plus every team's
|
|
4
|
-
// readiness vector from the tenant contract, then the list of who can click what. Wraps
|
|
5
|
-
// `catalyst-skills ready --json`; reports, never repairs. Exit 0 READY, 1 NOT READY, 2 not connected.
|
|
6
|
-
import { parseJson, runCli } from "./lib/cli.mjs";
|
|
7
|
-
|
|
8
|
-
const HELP = `Usage: node scripts/check.mjs [--json]
|
|
9
|
-
|
|
10
|
-
Prints one line per check (ok / note / FAIL), the fix and who can apply it for every failure, the
|
|
11
|
-
verdict, and a "who can click what" list grouped by the person or role each fix needs.
|
|
12
|
-
A note never flips the verdict (the replica is optional; an informational readiness check is a note).
|
|
13
|
-
|
|
14
|
-
--json prints the CLI's report document {ready, checks[]} unchanged.
|
|
15
|
-
Exit 0 READY, 1 NOT READY, 2 this machine is not connected to a tenant yet.`;
|
|
16
|
-
|
|
17
|
-
const args = process.argv.slice(2);
|
|
18
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
19
|
-
console.log(HELP);
|
|
20
|
-
process.exit(0);
|
|
21
|
-
}
|
|
22
|
-
const unknown = args.filter((a) => a !== "--json");
|
|
23
|
-
if (unknown.length > 0) {
|
|
24
|
-
console.error(`unknown argument: ${unknown.join(" ")}`);
|
|
25
|
-
console.log(HELP);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const res = runCli(["ready", "--json"]);
|
|
30
|
-
if (res.code === 2) {
|
|
31
|
-
console.error(res.stderr.trim() || "catalyst-skills ready refused");
|
|
32
|
-
process.exit(2);
|
|
33
|
-
}
|
|
34
|
-
const report = parseJson(res.stdout);
|
|
35
|
-
if (!report || !Array.isArray(report.checks)) {
|
|
36
|
-
console.error(res.stderr.trim() || res.stdout.trim() || "catalyst-skills ready printed no report");
|
|
37
|
-
process.exit(res.code === 0 ? 1 : res.code);
|
|
38
|
-
}
|
|
39
|
-
if (args.includes("--json")) {
|
|
40
|
-
console.log(JSON.stringify(report));
|
|
41
|
-
process.exit(report.ready ? 0 : 1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const failures = [];
|
|
45
|
-
for (const c of report.checks) {
|
|
46
|
-
const tag = c.note ? "note" : c.ok ? "ok " : "FAIL";
|
|
47
|
-
console.log(`${tag} ${c.line}`);
|
|
48
|
-
if (!c.ok && !c.note) {
|
|
49
|
-
if (c.fix) console.log(` fix: ${c.fix}`);
|
|
50
|
-
if (c.who) console.log(` who: ${c.who}`);
|
|
51
|
-
failures.push(c);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
console.log(report.ready ? "READY" : "NOT READY");
|
|
55
|
-
|
|
56
|
-
if (failures.length > 0) {
|
|
57
|
-
console.log("");
|
|
58
|
-
console.log("Who can click what:");
|
|
59
|
-
const byWho = new Map();
|
|
60
|
-
for (const c of failures) {
|
|
61
|
-
const who = c.who ?? "unknown (the check named nobody)";
|
|
62
|
-
if (!byWho.has(who)) byWho.set(who, []);
|
|
63
|
-
byWho.get(who).push(c);
|
|
64
|
-
}
|
|
65
|
-
for (const [who, list] of byWho) {
|
|
66
|
-
console.log(` ${who}:`);
|
|
67
|
-
for (const c of list) console.log(` - ${c.id}: ${c.fix ?? c.line}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const notes = report.checks.filter((c) => c.note && !c.ok);
|
|
71
|
-
if (notes.length > 0) {
|
|
72
|
-
console.log("");
|
|
73
|
-
console.log(`Notes that do not block: ${notes.map((c) => c.id).join(", ")} — see references/what-each-check-means.md`);
|
|
74
|
-
}
|
|
75
|
-
process.exit(report.ready ? 0 : 1);
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// lib/cli.mjs — the one way a skill script reaches the Catalyst Cloud SDK and API: by spawning the
|
|
3
|
-
// catalyst-skills CLI this bundle installed. It reads customer.json to find that CLI and nothing
|
|
4
|
-
// else; it never holds the key itself. This file is a library — run a sibling script with
|
|
5
|
-
// --help for usage. Identical in every skill of this bundle on purpose (skills install one directory
|
|
6
|
-
// at a time, so nothing shared outside the skill would ever be installed).
|
|
7
|
-
import { spawnSync } from "node:child_process";
|
|
8
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
import { fileURLToPath } from "node:url";
|
|
11
|
-
import { CONNECT_COMMAND, hasCredential } from "./credential.mjs";
|
|
12
|
-
|
|
13
|
-
export const PACKAGE = "@catalyst-cloud/catalyst-skills";
|
|
14
|
-
export const CONNECT_HINT = `this machine is not connected to a tenant yet — run: ${CONNECT_COMMAND}`;
|
|
15
|
-
|
|
16
|
-
/** ~/.config/catalyst-cloud/customer.json, honouring CATALYST_SKILLS_HOME before HOME. */
|
|
17
|
-
export function configPath() {
|
|
18
|
-
const home = process.env.CATALYST_SKILLS_HOME ?? process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
19
|
-
return join(home, ".config", "catalyst-cloud", "customer.json");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** The customer config, or exit 2 with one line naming the connect command. Never throws. */
|
|
23
|
-
export function requireCustomerConfig() {
|
|
24
|
-
const path = configPath();
|
|
25
|
-
if (!existsSync(path)) {
|
|
26
|
-
console.error(CONNECT_HINT);
|
|
27
|
-
process.exit(2);
|
|
28
|
-
}
|
|
29
|
-
let cfg;
|
|
30
|
-
try {
|
|
31
|
-
cfg = JSON.parse(readFileSync(path, "utf8"));
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.error(`${path} could not be read (${err instanceof Error ? err.message : String(err)}) — ${CONNECT_HINT}`);
|
|
34
|
-
process.exit(2);
|
|
35
|
-
}
|
|
36
|
-
if (!hasCredential(cfg) || typeof cfg.baseUrl !== "string") {
|
|
37
|
-
console.error(`${path} is missing required fields — ${CONNECT_HINT}`);
|
|
38
|
-
process.exit(2);
|
|
39
|
-
}
|
|
40
|
-
return cfg;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Run one catalyst-skills verb and return {code, stdout, stderr}. Spawns the CLI whose path the
|
|
45
|
-
* connect step recorded in customer.json; falls back to `npx @catalyst-cloud/catalyst-skills` when
|
|
46
|
-
* no path is recorded or it no longer exists. Exits 2 when the machine is not connected.
|
|
47
|
-
*/
|
|
48
|
-
export function runCli(args, opts = {}) {
|
|
49
|
-
const cfg = requireCustomerConfig();
|
|
50
|
-
const recorded = typeof cfg.cliPath === "string" && existsSync(cfg.cliPath);
|
|
51
|
-
const command = recorded ? process.execPath : process.platform === "win32" ? "npx.cmd" : "npx";
|
|
52
|
-
const argv = recorded ? [cfg.cliPath, ...args] : [PACKAGE, ...args];
|
|
53
|
-
const res = spawnSync(command, argv, {
|
|
54
|
-
encoding: "utf8",
|
|
55
|
-
input: opts.stdin,
|
|
56
|
-
env: process.env,
|
|
57
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
58
|
-
shell: !recorded && process.platform === "win32",
|
|
59
|
-
});
|
|
60
|
-
if (res.error) {
|
|
61
|
-
console.error(`could not run ${recorded ? cfg.cliPath : `npx ${PACKAGE}`}: ${res.error.message}`);
|
|
62
|
-
process.exit(2);
|
|
63
|
-
}
|
|
64
|
-
return { code: res.status ?? 1, stdout: res.stdout ?? "", stderr: res.stderr ?? "" };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Run a verb that must succeed. On exit 2 (the CLI's "not configured / refused" class) the script
|
|
69
|
-
* exits 2; on any other non-zero exit it exits 1. The CLI's own stderr is forwarded either way so the
|
|
70
|
-
* reason is never lost.
|
|
71
|
-
*/
|
|
72
|
-
export function runCliOrExit(args, opts = {}) {
|
|
73
|
-
const res = runCli(args, opts);
|
|
74
|
-
if (res.code === 0) return res;
|
|
75
|
-
const why = res.stderr.trim() || res.stdout.trim() || `catalyst-skills ${args.join(" ")} exited ${res.code}`;
|
|
76
|
-
console.error(why);
|
|
77
|
-
process.exit(res.code === 2 ? 2 : 1);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Parse the CLI's --json stdout; null when it is not JSON (the caller decides what that means). */
|
|
81
|
-
export function parseJson(stdout) {
|
|
82
|
-
try {
|
|
83
|
-
return JSON.parse(stdout);
|
|
84
|
-
} catch {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Forward the `source: replica|api (...)` line a query verb prints, so the answer names its source. */
|
|
90
|
-
export function forwardSourceLine(res) {
|
|
91
|
-
for (const line of res.stderr.split("\n")) {
|
|
92
|
-
if (line.startsWith("source:")) console.error(line);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** True for a ticket identifier such as ABC-123; false for a GitHub node id or anything else. */
|
|
97
|
-
export function looksLikeTicket(s) {
|
|
98
|
-
return /^[A-Za-z][A-Za-z0-9]*-\d+$/.test(s);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
102
|
-
console.log("lib/cli.mjs is a library used by the scripts beside it; run any of those with --help for usage.");
|
|
103
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// lib/credential.mjs — is this machine connected? The ONE place a skill script decides it, vendored
|
|
3
|
-
// byte-identical into every skill's scripts/lib/ from skill-lib/credential.mjs at the package root
|
|
4
|
-
// (`npm run skill-lib:sync`; a test fails on any drift). Skills install one directory at a time, so
|
|
5
|
-
// each carries its own copy. This file is a library — run a sibling script with --help for usage.
|
|
6
|
-
//
|
|
7
|
-
// customer.json carries exactly one credential: a personal key (`key`), or the keyless login's
|
|
8
|
-
// session (`auth`, the recommended rail). A script never reads either for its value: it spawns the
|
|
9
|
-
// catalyst-skills CLI, which authenticates with whichever is present and refreshes a login's token
|
|
10
|
-
// itself. A new credential kind lands here, once.
|
|
11
|
-
|
|
12
|
-
/** The command that connects this machine, as every not-connected line names it. */
|
|
13
|
-
export const CONNECT_COMMAND =
|
|
14
|
-
"npx @catalyst-cloud/catalyst-skills login (or, with a personal key: CATALYST_CLOUD_TOKEN=<your personal key> npx @catalyst-cloud/catalyst-skills login)";
|
|
15
|
-
|
|
16
|
-
/** True when `cfg` (parsed customer.json) holds a usable credential of either kind. Never throws. */
|
|
17
|
-
export function hasCredential(cfg) {
|
|
18
|
-
if (cfg === null || typeof cfg !== "object") return false;
|
|
19
|
-
const key = cfg["key"];
|
|
20
|
-
if (typeof key === "string" && key !== "") return true;
|
|
21
|
-
const login = cfg["auth"];
|
|
22
|
-
return (
|
|
23
|
-
login !== null &&
|
|
24
|
-
typeof login === "object" &&
|
|
25
|
-
login["kind"] === "oauth" &&
|
|
26
|
-
typeof login["refreshToken"] === "string" &&
|
|
27
|
-
login["refreshToken"] !== ""
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// replica-status.mjs — is the optional local replica alive, and how far behind is it? Wraps
|
|
3
|
-
// `catalyst-skills replica status`, which needs no network (a pidfile, a writer-lock heartbeat and
|
|
4
|
-
// the cursor row); `--probe` adds the one network call that compares the cursor with the cloud's
|
|
5
|
-
// head. The CLI's exit code passes straight through: 0 fresh, 1 present but stale, 2 not connected,
|
|
6
|
-
// 3 absent. A skill reads that code to choose its source; it never refuses to work over it.
|
|
7
|
-
import { runCli } from "./lib/cli.mjs";
|
|
8
|
-
|
|
9
|
-
const HELP = `Usage: node scripts/replica-status.mjs [--probe] [--json]
|
|
10
|
-
|
|
11
|
-
--probe also fetch the cloud's head cursor and print how far behind the replica is
|
|
12
|
-
--json print the CLI's status document {verdict, exitCode, cursor, heartbeatAgeMs, ...}
|
|
13
|
-
|
|
14
|
-
Exit codes, passed through from catalyst-skills replica status:
|
|
15
|
-
0 fresh: a live writer, a young heartbeat, a cursor — skills read the replica
|
|
16
|
-
1 stale: the file exists but the writer is gone or behind — skills read the API and say so
|
|
17
|
-
2 not connected to a tenant — run: npx @catalyst-cloud/catalyst-skills login (or, with a personal key: CATALYST_CLOUD_TOKEN=<your personal key> npx @catalyst-cloud/catalyst-skills login)
|
|
18
|
-
3 absent: no replica file — optional; start one with: catalyst-skills replica start --detach`;
|
|
19
|
-
|
|
20
|
-
const args = process.argv.slice(2);
|
|
21
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
22
|
-
console.log(HELP);
|
|
23
|
-
process.exit(0);
|
|
24
|
-
}
|
|
25
|
-
const unknown = args.filter((a) => a !== "--probe" && a !== "--json");
|
|
26
|
-
if (unknown.length > 0) {
|
|
27
|
-
console.error(`unknown argument: ${unknown.join(" ")}`);
|
|
28
|
-
console.log(HELP);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const cliArgs = ["replica", "status"];
|
|
33
|
-
if (args.includes("--probe")) cliArgs.push("--probe");
|
|
34
|
-
if (args.includes("--json")) cliArgs.push("--json");
|
|
35
|
-
const res = runCli(cliArgs);
|
|
36
|
-
if (res.stdout.trim()) console.log(res.stdout.trimEnd());
|
|
37
|
-
if (res.code !== 0 && res.stderr.trim()) console.error(res.stderr.trimEnd());
|
|
38
|
-
|
|
39
|
-
const meaning = {
|
|
40
|
-
0: "fresh — skills read the replica",
|
|
41
|
-
1: "stale — skills read the API and name that source",
|
|
42
|
-
2: "not connected to a tenant",
|
|
43
|
-
3: "absent — the replica is optional; nothing is wrong",
|
|
44
|
-
};
|
|
45
|
-
if (!args.includes("--json")) console.log(`verdict ${res.code}: ${meaning[res.code] ?? "unexpected exit code"}`);
|
|
46
|
-
process.exit(res.code);
|