@catalyst-cloud/cli 0.16.19 → 0.16.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +2 -0
- package/dist/args.js +19 -4
- package/dist/capabilities.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/env/shell-declaration.js +147 -0
- package/dist/env/shell-docker.js +137 -0
- package/dist/env/shell-plan.js +120 -0
- package/dist/env/shell-pull.js +123 -0
- package/dist/env/shell.js +288 -0
- package/dist/env.js +11 -6
- package/dist/execution.js +28 -7
- package/dist/onboard-accounts.js +4 -2
- package/dist/onboard-next.js +9 -3
- package/dist/onboard-runner-egress.js +13 -4
- package/dist/onboard-runner.js +1 -1
- package/dist/setup-render.js +15 -13
- package/package.json +1 -1
- package/skills/catalyst-github/SKILL.md +1 -1
- package/skills/catalyst-linear/SKILL.md +1 -1
- package/skills/catalyst-onboard/SKILL.md +1 -1
- package/skills/catalyst-onboard/scripts/where-am-i.mjs +3 -2
- 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/coding-accounts.md +1 -1
- package/vendor/install-session-egress.sh +30 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// shell.ts — `catalyst env shell [--check]`: open this repository's environment on this computer.
|
|
2
|
+
// Every refusal a person can fix in the file or the terminal fires before Docker is touched; the
|
|
3
|
+
// cloud is asked only when a credential-free download is refused (shell-pull.ts).
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
6
|
+
import { basename, isAbsolute, relative, resolve } from "node:path";
|
|
7
|
+
import { parseEnv, promisify } from "node:util";
|
|
8
|
+
import { flagBool, flagList, flagString, positionals } from "../args.js";
|
|
9
|
+
import { UsageError } from "../errors.js";
|
|
10
|
+
import { IMAGE_REF, RUNNER_HOST_IMAGES } from "../onboard-runner.js";
|
|
11
|
+
import { readLocalRepositoryName } from "../onboard-settings-context.js";
|
|
12
|
+
import { readLocalSettings } from "./settings-authority.js";
|
|
13
|
+
import { readShellDeclaration, resolveShellVariables } from "./shell-declaration.js";
|
|
14
|
+
import { spawnEnvShellDocker } from "./shell-docker.js";
|
|
15
|
+
import { parseCheckOutput, shellRunArgs, START_EXIT_TOOLCHAIN, toolchainSpecs } from "./shell-plan.js";
|
|
16
|
+
import { downloadImage } from "./shell-pull.js";
|
|
17
|
+
const DECLARATION = ".catalyst/catalyst.toml";
|
|
18
|
+
const IMAGE_UID = 10001;
|
|
19
|
+
const run = promisify(execFile);
|
|
20
|
+
/** Git with no global or system config, no prompt, bounded: a path, or null. */
|
|
21
|
+
async function gitPath(cwd, args) {
|
|
22
|
+
try {
|
|
23
|
+
const { stdout } = await run("git", args, {
|
|
24
|
+
cwd,
|
|
25
|
+
timeout: 3_000,
|
|
26
|
+
maxBuffer: 16_384,
|
|
27
|
+
env: {
|
|
28
|
+
PATH: process.env.PATH,
|
|
29
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
30
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
31
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const path = stdout.trim();
|
|
35
|
+
return path !== "" && isAbsolute(path) ? path : null;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const defaultGitTopLevel = (cwd) => gitPath(cwd, ["rev-parse", "--show-toplevel"]);
|
|
42
|
+
const defaultGitCommonDir = (root) => gitPath(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
43
|
+
/** The digest shortened for a person: `<name>@sha256:<12 hex>…`. */
|
|
44
|
+
function shortImage(image) {
|
|
45
|
+
return image.replace(/@sha256:([0-9a-f]{12})[0-9a-f]{52}$/, "@sha256:$1…");
|
|
46
|
+
}
|
|
47
|
+
function inside(child, parent) {
|
|
48
|
+
const rel = relative(parent, child);
|
|
49
|
+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
|
|
50
|
+
}
|
|
51
|
+
function unmountable(path) {
|
|
52
|
+
if (path.includes(","))
|
|
53
|
+
return `env shell cannot mount ${path}: the path contains a comma.`;
|
|
54
|
+
if (/[\r\n]/.test(path))
|
|
55
|
+
return `env shell cannot mount ${JSON.stringify(path)}: the path contains a line break.`;
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function toolchainLine(toolchains) {
|
|
59
|
+
return toolchains.length === 0
|
|
60
|
+
? " Toolchain: none declared"
|
|
61
|
+
: ` Toolchain: ${toolchains.map((t) => `${t.name} ${t.version}`).join(", ")} (the first start downloads any version the image lacks)`;
|
|
62
|
+
}
|
|
63
|
+
function joinSources(sources) {
|
|
64
|
+
return sources.length <= 1 ? (sources[0] ?? "") : `${sources.slice(0, -1).join(", ")} and ${sources.at(-1)}`;
|
|
65
|
+
}
|
|
66
|
+
export async function runEnvShell(args, ctx, deps = {}) {
|
|
67
|
+
// 1. Flags.
|
|
68
|
+
const [, ...rest] = positionals(args);
|
|
69
|
+
if (rest.length > 0)
|
|
70
|
+
throw new UsageError(`env shell takes no positional arguments (got "${rest[0]}"); use --root DIR`);
|
|
71
|
+
const check = flagBool(args, "check");
|
|
72
|
+
const json = args.json;
|
|
73
|
+
if (json && !check)
|
|
74
|
+
throw new UsageError("env shell --json needs --check: the shell itself is interactive");
|
|
75
|
+
const imageFlag = flagString(args, "image");
|
|
76
|
+
if (imageFlag !== undefined && !IMAGE_REF.test(imageFlag))
|
|
77
|
+
throw new UsageError("env shell --image needs a digest-pinned reference, such as ghcr.io/owner/image@sha256:<64 hex>");
|
|
78
|
+
const image = imageFlag ?? RUNNER_HOST_IMAGES.runner;
|
|
79
|
+
const say = (line) => {
|
|
80
|
+
if (!json)
|
|
81
|
+
ctx.stdout(line);
|
|
82
|
+
};
|
|
83
|
+
const notice = (line) => (json ? ctx.stderr(line) : ctx.stdout(line));
|
|
84
|
+
const refuse = (refusal) => {
|
|
85
|
+
if (json)
|
|
86
|
+
ctx.stdout(JSON.stringify({ ok: false, refusal }));
|
|
87
|
+
else
|
|
88
|
+
for (const line of refusal.message.split("\n"))
|
|
89
|
+
ctx.stderr(line);
|
|
90
|
+
return 1;
|
|
91
|
+
};
|
|
92
|
+
// 2. Root.
|
|
93
|
+
const rootFlag = flagString(args, "root");
|
|
94
|
+
const start = resolve(rootFlag ?? ".");
|
|
95
|
+
const requested = rootFlag !== undefined ? start : ((await (deps.gitTopLevel ?? defaultGitTopLevel)(start)) ?? start);
|
|
96
|
+
let root;
|
|
97
|
+
try {
|
|
98
|
+
root = realpathSync(requested);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return refuse({
|
|
102
|
+
code: "declaration_missing",
|
|
103
|
+
message: `No ${DECLARATION} in ${requested}. Draft one with: catalyst env draft --write`,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const rootProblem = unmountable(root);
|
|
107
|
+
if (rootProblem)
|
|
108
|
+
return refuse({ code: "repository_path_unsupported", message: rootProblem });
|
|
109
|
+
// 3. Declaration.
|
|
110
|
+
const text = await readLocalSettings(root);
|
|
111
|
+
if (text === null)
|
|
112
|
+
return refuse({
|
|
113
|
+
code: "declaration_missing",
|
|
114
|
+
message: `No ${DECLARATION} in ${root}. Draft one with: catalyst env draft --write`,
|
|
115
|
+
});
|
|
116
|
+
const declaration = readShellDeclaration(text);
|
|
117
|
+
if (declaration.state === "invalid")
|
|
118
|
+
return refuse({
|
|
119
|
+
code: "declaration_invalid",
|
|
120
|
+
message: [...declaration.errors.map((error) => `${DECLARATION}: ${error}`), "Fix the file, then run catalyst env check."].join("\n"),
|
|
121
|
+
});
|
|
122
|
+
if (declaration.state === "unsupported") {
|
|
123
|
+
const { name, version } = declaration.toolchain;
|
|
124
|
+
return refuse({
|
|
125
|
+
code: "toolchain_version_unsupported",
|
|
126
|
+
message: `${name} ${JSON.stringify(version)} is a version range. env shell prepares an exact or prefix version, such as 22 or 22.23.3. Change it in ${DECLARATION}.`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// 4. Variables.
|
|
130
|
+
const envFiles = [];
|
|
131
|
+
for (const path of flagList(args, "env-file")) {
|
|
132
|
+
try {
|
|
133
|
+
envFiles.push({ path, values: parseEnv(readFileSync(resolve(path), "utf8")) });
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return refuse({ code: "env_file_unreadable", message: `could not read --env-file ${path}` });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const variables = resolveShellVariables(declaration.variables, { env: ctx.env, envFiles, platform: deps.platform });
|
|
140
|
+
if (variables.missingRequired.length > 0)
|
|
141
|
+
return refuse({
|
|
142
|
+
code: "variables_missing",
|
|
143
|
+
message: `These required variables are not set in this terminal or an --env-file: ${variables.missingRequired.join(", ")}. Set them, then run catalyst env shell again.`,
|
|
144
|
+
names: variables.missingRequired,
|
|
145
|
+
});
|
|
146
|
+
// 5. Engine.
|
|
147
|
+
const docker = deps.docker ?? spawnEnvShellDocker({ env: ctx.env });
|
|
148
|
+
const server = await docker.server();
|
|
149
|
+
if (server.state === "missing")
|
|
150
|
+
return refuse({
|
|
151
|
+
code: "docker_missing",
|
|
152
|
+
message: "Docker is not installed on this computer. Install Docker Desktop, OrbStack or Docker Engine, then run catalyst env shell again.",
|
|
153
|
+
});
|
|
154
|
+
if (server.state === "not_running")
|
|
155
|
+
return refuse({
|
|
156
|
+
code: "docker_not_running",
|
|
157
|
+
message: "Docker is installed but not running. Start Docker Desktop, OrbStack or Docker Engine, then run catalyst env shell again.",
|
|
158
|
+
});
|
|
159
|
+
if (server.state === "not_linux")
|
|
160
|
+
return refuse({
|
|
161
|
+
code: "docker_not_linux",
|
|
162
|
+
message: `Docker is running ${server.os} containers. Switch it to Linux containers, then run catalyst env shell again.`,
|
|
163
|
+
});
|
|
164
|
+
// 6. Image.
|
|
165
|
+
const readRepositoryName = deps.readRepositoryName ?? readLocalRepositoryName;
|
|
166
|
+
const repository = (await readRepositoryName(root)) ?? basename(root);
|
|
167
|
+
say(`Environment for ${repository}, from ${DECLARATION}`);
|
|
168
|
+
const present = await docker.imagePresent(image);
|
|
169
|
+
say(` Image: ${shortImage(image)} (${present ? "already on this computer" : "not on this computer yet"})`);
|
|
170
|
+
let credential = "none";
|
|
171
|
+
if (!present) {
|
|
172
|
+
const endpoint = await docker.endpoint();
|
|
173
|
+
if (!endpoint.ok)
|
|
174
|
+
return refuse(endpoint.reason === "conflict"
|
|
175
|
+
? {
|
|
176
|
+
code: "docker_endpoint_conflict",
|
|
177
|
+
message: "DOCKER_HOST and DOCKER_CONTEXT are both set. Unset one, then run catalyst env shell again.",
|
|
178
|
+
}
|
|
179
|
+
: {
|
|
180
|
+
code: "docker_endpoint_unreadable",
|
|
181
|
+
message: "Docker's current context could not be read. Check it with docker context ls, then run catalyst env shell again.",
|
|
182
|
+
});
|
|
183
|
+
const downloaded = await downloadImage({ ref: image, host: endpoint.host, root, ctx, docker, notify: notice, readRepositoryName });
|
|
184
|
+
if (!downloaded.ok)
|
|
185
|
+
return refuse(downloaded.refusal);
|
|
186
|
+
credential = downloaded.credential;
|
|
187
|
+
}
|
|
188
|
+
// 7. Git common directory: a worktree's shared .git outside the root is mounted at its own path.
|
|
189
|
+
const commonDir = await (deps.gitCommonDir ?? defaultGitCommonDir)(root);
|
|
190
|
+
let gitCommonDir = null;
|
|
191
|
+
if (commonDir !== null) {
|
|
192
|
+
let real = commonDir;
|
|
193
|
+
try {
|
|
194
|
+
real = realpathSync(commonDir);
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// Not there any more: git inside the shell reports it; nothing is mounted.
|
|
198
|
+
}
|
|
199
|
+
if (!inside(real, root)) {
|
|
200
|
+
const problem = unmountable(real);
|
|
201
|
+
if (problem)
|
|
202
|
+
return refuse({ code: "repository_path_unsupported", message: problem });
|
|
203
|
+
gitCommonDir = real;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// 8. Run.
|
|
207
|
+
const tty = !check && (deps.isTty?.() ?? (process.stdin.isTTY === true && process.stdout.isTTY === true));
|
|
208
|
+
const checkNames = declaration.variables.map((v) => v.name).filter((name) => !variables.skippedReserved.includes(name));
|
|
209
|
+
const argv = shellRunArgs({
|
|
210
|
+
mode: check ? "check" : "shell",
|
|
211
|
+
image,
|
|
212
|
+
root,
|
|
213
|
+
gitCommonDir,
|
|
214
|
+
toolchains: declaration.toolchains,
|
|
215
|
+
passNames: variables.set,
|
|
216
|
+
tty,
|
|
217
|
+
checkNames,
|
|
218
|
+
});
|
|
219
|
+
const runEnv = { ...ctx.env, ...variables.values };
|
|
220
|
+
if (tty)
|
|
221
|
+
runEnv.TERM = ctx.env.TERM || "xterm-256color";
|
|
222
|
+
if (variables.skippedReserved.length > 0)
|
|
223
|
+
notice(` Note: env shell sets ${variables.skippedReserved.join(", ")} itself, so the declared value is not used.`);
|
|
224
|
+
const uid = deps.uid ?? process.getuid?.();
|
|
225
|
+
if ((deps.platform ?? process.platform) === "linux" && uid !== undefined && uid !== IMAGE_UID)
|
|
226
|
+
notice(`Note: the shell runs as uid ${IMAGE_UID}, as Catalyst's agents do. Files here belong to uid ${uid}, so on Docker Engine for Linux the shell may not be able to write them.`);
|
|
227
|
+
const toolchainNotPrepared = {
|
|
228
|
+
code: "toolchain_not_prepared",
|
|
229
|
+
message: `The shell did not start: a declared toolchain could not be prepared (mise's message above says which). Check the name and version in ${DECLARATION}, then run catalyst env shell --check.`,
|
|
230
|
+
};
|
|
231
|
+
const secret = new Set(declaration.variables.filter((v) => v.secret).map((v) => v.name));
|
|
232
|
+
if (!check) {
|
|
233
|
+
say(toolchainLine(declaration.toolchains));
|
|
234
|
+
const set = variables.set.map((name) => (secret.has(name) ? `${name} (secret)` : name));
|
|
235
|
+
const parts = [
|
|
236
|
+
...(set.length > 0 ? [`${set.join(", ")} set from ${joinSources(variables.sources)}`] : []),
|
|
237
|
+
...(variables.unsetOptional.length > 0 ? [`not set: ${variables.unsetOptional.map((name) => `${name} (optional)`).join(", ")}`] : []),
|
|
238
|
+
];
|
|
239
|
+
say(` Variables: ${parts.length > 0 ? parts.join("; ") : "none declared"}`);
|
|
240
|
+
say(` Your repository is at /workspace. Type exit to leave.`);
|
|
241
|
+
const result = await docker.run(argv, runEnv, "interactive");
|
|
242
|
+
if (result.code === START_EXIT_TOOLCHAIN)
|
|
243
|
+
return refuse(toolchainNotPrepared);
|
|
244
|
+
return result.code;
|
|
245
|
+
}
|
|
246
|
+
const result = await docker.run(argv, runEnv, "capture");
|
|
247
|
+
if (result.code === START_EXIT_TOOLCHAIN)
|
|
248
|
+
return refuse(toolchainNotPrepared);
|
|
249
|
+
const specs = toolchainSpecs(declaration.toolchains);
|
|
250
|
+
const report = result.code === 0 ? parseCheckOutput(result.stdout, specs, checkNames) : null;
|
|
251
|
+
if (report === null)
|
|
252
|
+
return refuse({
|
|
253
|
+
code: "check_incomplete",
|
|
254
|
+
message: `The environment check did not finish (exit ${result.code}). Run catalyst env shell --check again; if it repeats, open the shell and run mise doctor.`,
|
|
255
|
+
});
|
|
256
|
+
const byName = new Map(declaration.variables.map((v) => [v.name, v]));
|
|
257
|
+
const resolvedBySpec = new Map(report.toolchains.map((t) => [t.spec, t.resolved]));
|
|
258
|
+
const resolvedOf = (t) => resolvedBySpec.get(`${t.name}@${t.version}`) ?? "";
|
|
259
|
+
if (json) {
|
|
260
|
+
ctx.stdout(JSON.stringify({
|
|
261
|
+
ok: true,
|
|
262
|
+
repository,
|
|
263
|
+
declaration: DECLARATION,
|
|
264
|
+
image: { reference: image, source: present ? "present" : "downloaded", credential },
|
|
265
|
+
toolchains: declaration.toolchains.map((t) => ({ name: t.name, version: t.version, resolved: resolvedOf(t) })),
|
|
266
|
+
variables: report.variables.map((v) => ({
|
|
267
|
+
name: v.name,
|
|
268
|
+
required: byName.get(v.name)?.required === true,
|
|
269
|
+
secret: byName.get(v.name)?.secret === true,
|
|
270
|
+
set: v.set,
|
|
271
|
+
})),
|
|
272
|
+
}));
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
say(declaration.toolchains.length === 0
|
|
276
|
+
? " Toolchain: none declared"
|
|
277
|
+
: ` Toolchain: ${declaration.toolchains.map((t) => `${t.name} ${t.version} → ${resolvedOf(t)}`).join(", ")}`);
|
|
278
|
+
say(` Variables: ${report.variables.length === 0
|
|
279
|
+
? "none declared"
|
|
280
|
+
: report.variables
|
|
281
|
+
.map((v) => {
|
|
282
|
+
const notes = [...(secret.has(v.name) ? ["secret"] : []), ...(!v.set && byName.get(v.name)?.required !== true ? ["optional"] : [])];
|
|
283
|
+
return `${v.name} ${v.set ? "set" : "not set"}${notes.length > 0 ? ` (${notes.join(", ")})` : ""}`;
|
|
284
|
+
})
|
|
285
|
+
.join(", ")}`);
|
|
286
|
+
say("Ready: catalyst env shell opens this environment.");
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
package/dist/env.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// env.ts — `catalyst env inventory` / `
|
|
2
|
-
// validator. Unlike every other verb in this file's siblings,
|
|
3
|
-
// `apiClient` —
|
|
4
|
-
// a person reviews what a repository declares without connecting anything first.
|
|
1
|
+
// env.ts — `catalyst env inventory` / `check` / `migrate` / `draft`: a LOCAL, OFFLINE, repo-scoped
|
|
2
|
+
// reporter and validator. Unlike every other verb in this file's siblings, those four never call
|
|
3
|
+
// `requireConfig` or `apiClient` — they need neither a login nor a network call, which is the whole
|
|
4
|
+
// point of the feature: a person reviews what a repository declares without connecting anything first.
|
|
5
|
+
// `env shell` (env/shell.ts) talks to Docker, and asks the cloud only when a credential-free download
|
|
6
|
+
// of the image is refused; Catalyst's own image needs no login.
|
|
5
7
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
6
8
|
import { dirname, join, resolve } from "node:path";
|
|
7
9
|
import { flagBool, flagString, positionals } from "./args.js";
|
|
@@ -10,11 +12,14 @@ import { convertLegacyEnvironmentJson } from "./env/legacy.js";
|
|
|
10
12
|
import { draftEnvironment } from "./env/draft.js";
|
|
11
13
|
import { inventoryRepo } from "./env/inventory.js";
|
|
12
14
|
import { inventoryToJson, renderInventory } from "./env/render.js";
|
|
15
|
+
import { runEnvShell } from "./env/shell.js";
|
|
13
16
|
import { UsageError } from "./errors.js";
|
|
14
17
|
export async function cmdEnv(args, ctx, deps = {}) {
|
|
15
18
|
const [sub, ...rest] = positionals(args);
|
|
16
19
|
if (sub === undefined)
|
|
17
|
-
throw new UsageError("env needs a subcommand: inventory | check | migrate | draft");
|
|
20
|
+
throw new UsageError("env needs a subcommand: inventory | check | migrate | draft | shell");
|
|
21
|
+
if (sub === "shell")
|
|
22
|
+
return await runEnvShell(args, ctx, deps.shell ?? {});
|
|
18
23
|
if (sub === "draft") {
|
|
19
24
|
if (rest.length > 0)
|
|
20
25
|
throw new UsageError("env draft takes no positional arguments; use --root DIR");
|
|
@@ -172,5 +177,5 @@ export async function cmdEnv(args, ctx, deps = {}) {
|
|
|
172
177
|
ctx.stderr(`${file}: ${error}`);
|
|
173
178
|
return result.state === "invalid" ? 1 : 0;
|
|
174
179
|
}
|
|
175
|
-
throw new UsageError(`unknown env subcommand "${sub}": inventory | check | migrate | draft`);
|
|
180
|
+
throw new UsageError(`unknown env subcommand "${sub}": inventory | check | migrate | draft | shell`);
|
|
176
181
|
}
|
package/dist/execution.js
CHANGED
|
@@ -311,9 +311,12 @@ export async function cmdQueue(args, ctx) {
|
|
|
311
311
|
ctx.stdout(args.json ? JSON.stringify(out) : JSON.stringify(out, null, 2));
|
|
312
312
|
return 0;
|
|
313
313
|
}
|
|
314
|
-
/** The
|
|
314
|
+
/** The status words `/api/v1/coding-accounts` reports, in the words a customer reads. */
|
|
315
315
|
export const ACCOUNT_STATUS = {
|
|
316
|
-
"expired-or-revoked": "expired or
|
|
316
|
+
"expired-or-revoked": "credential expired or missing — replace its credential on the AI accounts page (Settings → AI accounts → the account → Replace credential) before it can take work",
|
|
317
|
+
// CTC-6204: revoked and ended accounts share one history-only end state (Ryan, 2026-10-19).
|
|
318
|
+
ended: "removed — kept for history, takes no work",
|
|
319
|
+
"out-of-rotation": "paused — its owner took it out of rotation",
|
|
317
320
|
walled: "walled — the provider's usage limit is spent for now",
|
|
318
321
|
active: "active — observed working",
|
|
319
322
|
attested: "attested — healthy at last check, no work observed since",
|
|
@@ -326,12 +329,18 @@ export function accountDisplayName(a) {
|
|
|
326
329
|
return v.trim();
|
|
327
330
|
return a.accountSlot ?? "?";
|
|
328
331
|
}
|
|
332
|
+
/** CTC-6204: a revoked account, or one whose paid access ended, can never take work again and takes
|
|
333
|
+
* no new credential. It is kept for history only. An older cloud still calls a revoked account
|
|
334
|
+
* `expired-or-revoked`, so `revokedAtMs` decides as well as the status word. */
|
|
335
|
+
export function historyOnly(a) {
|
|
336
|
+
return typeof a.revokedAtMs === "number" || a.status === "ended";
|
|
337
|
+
}
|
|
329
338
|
/** One slot as a line a human reads: who it is, what state it is in, and what it is spending on. */
|
|
330
339
|
export function renderAccount(a) {
|
|
331
340
|
const display = accountDisplayName(a);
|
|
332
341
|
const name = display === (a.accountSlot ?? "?") ? display : `${display} (${a.accountSlot ?? "?"})`;
|
|
333
342
|
const harness = a.harness ? `/${a.harness}` : "";
|
|
334
|
-
const status = a.status ? (ACCOUNT_STATUS[a.status] ?? a.status) : "status unknown";
|
|
343
|
+
const status = historyOnly(a) ? ACCOUNT_STATUS.ended : a.status ? (ACCOUNT_STATUS[a.status] ?? a.status) : "status unknown";
|
|
335
344
|
const bits = [`${name} ${a.provider ?? "?"}${harness} ${status}`];
|
|
336
345
|
// CTC-4199: a cancelled subscription is kept for reporting and not used; never re-credential it (Ryan, 2026-09-29).
|
|
337
346
|
if (a.renewalStatus === "canceled")
|
|
@@ -367,17 +376,29 @@ export async function cmdAccounts(args, ctx) {
|
|
|
367
376
|
if (res.status === 404)
|
|
368
377
|
throw needsNewerCloud("coding-account status", cfg);
|
|
369
378
|
const accounts = Array.isArray(res.body) ? res.body : (res.body?.accounts ?? []);
|
|
379
|
+
// CTC-6204: removed accounts are history, so they are left out unless --all asks for them. Listed,
|
|
380
|
+
// they read as accounts to repair, and agents kept trying to revive them.
|
|
381
|
+
const shown = flagBool(args, "all") ? accounts : accounts.filter((a) => !historyOnly(a));
|
|
382
|
+
const hidden = accounts.length - shown.length;
|
|
370
383
|
if (args.json) {
|
|
371
|
-
const named =
|
|
372
|
-
ctx.stdout(JSON.stringify(Array.isArray(res.body) ? named : { ...res.body, accounts: named }));
|
|
384
|
+
const named = shown.map((a) => ({ ...a, displayName: accountDisplayName(a), removed: historyOnly(a) }));
|
|
385
|
+
ctx.stdout(JSON.stringify(Array.isArray(res.body) ? named : { ...res.body, accounts: named, removedHidden: hidden }));
|
|
373
386
|
return 0;
|
|
374
387
|
}
|
|
388
|
+
const addAt = `${normalizeBaseUrl(cfg.baseUrl)}/settings/coding-accounts`;
|
|
389
|
+
const hiddenLine = `${hidden} removed account${hidden === 1 ? " is" : "s are"} kept for history and take no work; catalyst accounts --all lists ${hidden === 1 ? "it" : "them"}.`;
|
|
375
390
|
if (accounts.length === 0) {
|
|
376
|
-
ctx.stdout(`No coding accounts are enrolled in this workspace. A workspace owner or admin adds one at ${
|
|
391
|
+
ctx.stdout(`No coding accounts are enrolled in this workspace. A workspace owner or admin adds one at ${addAt}; there is no command for that yet.`);
|
|
392
|
+
return 0;
|
|
393
|
+
}
|
|
394
|
+
if (shown.length === 0) {
|
|
395
|
+
ctx.stdout(`No AI account in this workspace can take work. A workspace owner or admin adds one at ${addAt}. ${hiddenLine}`);
|
|
377
396
|
return 0;
|
|
378
397
|
}
|
|
379
|
-
for (const a of
|
|
398
|
+
for (const a of shown)
|
|
380
399
|
ctx.stdout(renderAccount(a));
|
|
400
|
+
if (hidden > 0)
|
|
401
|
+
ctx.stdout(hiddenLine);
|
|
381
402
|
return 0;
|
|
382
403
|
}
|
|
383
404
|
/**
|
package/dist/onboard-accounts.js
CHANGED
|
@@ -97,11 +97,13 @@ async function inventory(ctx, journal, signal) {
|
|
|
97
97
|
* (the server's isUsableCodingAccount): any provider, any member's account, and a canceled
|
|
98
98
|
* subscription keeps working until its paid access ends. */
|
|
99
99
|
function unusableCause(row, now) {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// CTC-6204: ended first. A revoked account is usually also declared inactive, and "turn it on"
|
|
101
|
+
// is advice it can never take.
|
|
102
102
|
if (row.revokedAtMs !== null ||
|
|
103
103
|
(row.accessEndsAtMs !== null && row.accessEndsAtMs <= now))
|
|
104
104
|
return "coding_account_ended";
|
|
105
|
+
if (row.declaredState !== "active")
|
|
106
|
+
return "coding_account_inactive";
|
|
105
107
|
if (row.needsCredential)
|
|
106
108
|
return "coding_account_needs_login";
|
|
107
109
|
if (row.quarantined)
|
package/dist/onboard-next.js
CHANGED
|
@@ -109,7 +109,6 @@ const REASONS = {
|
|
|
109
109
|
workflow_unavailable: "Setup could not read the team's workflow. Run catalyst onboard again to retry.",
|
|
110
110
|
capacity_context_unverified: "Setup could not confirm this project's registered repositories and its default repository for capacity. Run catalyst ready to see the project checks, then run catalyst setup again. Starting a ticket checks its own repository's admission.",
|
|
111
111
|
capacity_identity_unverified: "Setup could not confirm your workspace and administrator role for the capacity check. Run catalyst login, then run catalyst setup again.",
|
|
112
|
-
capacity_admission_unverified: "No runner is allowed to take work for this workspace yet. Enroll a self-hosted runner host, or ask Catalyst to enable cloud runners for it. Then run catalyst onboard.",
|
|
113
112
|
capacity_currently_full: "Every runner slot for this repository is in use. Run catalyst onboard again after current work finishes.",
|
|
114
113
|
capacity_unavailable: "Setup could not read runner capacity. Run catalyst onboard again to retry.",
|
|
115
114
|
runner_not_selected: "This setup does not start a runner on this machine. To start one, run catalyst onboard --runner.",
|
|
@@ -424,9 +423,16 @@ export function onboardReasonText(step, context = {}) {
|
|
|
424
423
|
? `This setup step is not available on this server yet. Continue in the web app at ${page}, then run catalyst onboard.`
|
|
425
424
|
: "This setup step is not available on this server yet. Run catalyst onboard after the server update.";
|
|
426
425
|
}
|
|
426
|
+
// CTC-6180: the command that enrolls this computer, named with its team.
|
|
427
|
+
// The command is its own line (never wrapped), and runnable as printed: with no known team key,
|
|
428
|
+
// setup asks for the team.
|
|
429
|
+
if (reason === "capacity_admission_unverified") {
|
|
430
|
+
const key = onboardTeamKey(context.journal);
|
|
431
|
+
return `No runner is allowed to take work for this workspace yet. To use Catalyst's cloud runners, ask Catalyst support to turn on cloud runners for your workspace, then run catalyst onboard. To run work on this computer instead, enroll it as a self-hosted runner${key ? "" : " (setup asks for your Linear team)"} with:\ncatalyst onboard --runner${key ? ` --team ${key}` : ""}`;
|
|
432
|
+
}
|
|
427
433
|
if (reason === "runner_native_egress_setup_required") {
|
|
428
|
-
const
|
|
429
|
-
return "Native Linux needs a root-managed session egress
|
|
434
|
+
const command = nativeEgressInstallCommands();
|
|
435
|
+
return "Native Linux needs a root-managed session egress service before this computer can take work. It creates the isolated session network and the nftables rules that keep sessions off private addresses and this machine. It needs systemd, python3, Docker and nftables, and setup has not run it. " + (command ? "Review it, run this one command, then run the same setup command:\n" + command : "Setup could not verify its bundled files. Reinstall the CLI, then run the same setup command.");
|
|
430
436
|
}
|
|
431
437
|
if (reason === "runner_images_unavailable" || reason === "runner_supervisor_image_unavailable") {
|
|
432
438
|
const image = step.evidence?.image;
|
|
@@ -51,10 +51,20 @@ export async function nativeEgressReady(now, signal, io = nodeReads) {
|
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
export const EGRESS_INSTALLER = { name: 'install-session-egress.sh', digest: 'b187180a9e5965ebe5e356a5c133ff2ec715fb294197cd636f8ff1301dc49ff0' };
|
|
55
|
+
const quote = (s) => "'" + s.replaceAll("'", "'\\''") + "'";
|
|
56
|
+
/** CTC-6180: root copies the installer into its own temp file, checks the pinned digest there and
|
|
57
|
+
* runs only those bytes, so an edit to the user-writable CLI install cannot run as root. */
|
|
58
|
+
export function egressInstallCommand(vendor, digest = EGRESS_INSTALLER.digest, sudo = 'sudo ') {
|
|
59
|
+
const script = `t=$(mktemp) && cp -- ${quote(join(vendor, EGRESS_INSTALLER.name))} "$t" && echo ${quote(digest + ' ')}"$t" | sha256sum -c --quiet - && sh "$t" ${quote(vendor)}; s=$?; rm -f "$t"; exit $s`;
|
|
60
|
+
return `${sudo}sh -c ${quote(script)}`;
|
|
61
|
+
}
|
|
62
|
+
/** Exact bundled bytes are checked before showing the one elevated install command (CTC-6180). */
|
|
55
63
|
export function nativeEgressInstallCommands() {
|
|
56
|
-
const
|
|
64
|
+
const vendor = join(packageRoot(), 'vendor'), root = join(vendor, 'self-host/linux-session-egress');
|
|
57
65
|
try {
|
|
66
|
+
if (hash(readFileSync(join(vendor, EGRESS_INSTALLER.name))) !== EGRESS_INSTALLER.digest)
|
|
67
|
+
return null;
|
|
58
68
|
for (const artifact of EGRESS_ARTIFACTS)
|
|
59
69
|
if (hash(readFileSync(join(root, artifact.name))) !== artifact.digest)
|
|
60
70
|
return null;
|
|
@@ -62,6 +72,5 @@ export function nativeEgressInstallCommands() {
|
|
|
62
72
|
catch {
|
|
63
73
|
return null;
|
|
64
74
|
}
|
|
65
|
-
|
|
66
|
-
return EGRESS_ARTIFACTS.map(a => `sudo install ${a.name === 'session-egress.py' ? '-D ' : ''}-o root -g root -m ${a.mode.toString(8)} ${quote(join(root, a.name))} ${quote(a.path)}`).join('\n') + '\nsudo systemctl daemon-reload\nsudo systemctl enable --now catalyst-session-egress.service catalyst-session-egress-attest.timer\nsudo /usr/bin/python3 /usr/lib/catalyst/session-egress.py attest';
|
|
75
|
+
return egressInstallCommand(vendor);
|
|
67
76
|
}
|
package/dist/onboard-runner.js
CHANGED
|
@@ -29,7 +29,7 @@ export const RUNNER_HOST_IMAGES = {
|
|
|
29
29
|
watchdog: "ghcr.io/coalesce-labs/catalyst-deadline-watchdog@sha256:63a9b20c3be3dc3ea328d77aa68dece942a40be46cb3126d9a7868e082828feb",
|
|
30
30
|
runner: "ghcr.io/coalesce-labs/catalyst-runner@sha256:a19f7b0859a9814740935f7aadd8fe5c5c9c5974f9a5956a057b983ada16ea01",
|
|
31
31
|
};
|
|
32
|
-
const IMAGE_REF = /^[a-z0-9][a-z0-9._:/-]{0,255}@sha256:[0-9a-f]{64}$/;
|
|
32
|
+
export const IMAGE_REF = /^[a-z0-9][a-z0-9._:/-]{0,255}@sha256:[0-9a-f]{64}$/;
|
|
33
33
|
const HOST_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
|
|
34
34
|
const JOIN_TOKEN = /^[A-Za-z0-9._~+/=-]{16,1024}$/;
|
|
35
35
|
const ENROLLMENTS = "/api/v1/hosts/enrollments";
|
package/dist/setup-render.js
CHANGED
|
@@ -122,19 +122,21 @@ export function createSetupRenderer(stream, env, banner = {}) {
|
|
|
122
122
|
const indent = /^ */.exec(text)?.[0].length ?? 0;
|
|
123
123
|
col += indent;
|
|
124
124
|
text = text.slice(indent);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
// CTC-6180: each line after the first is a command a person copies, so it is never wrapped.
|
|
126
|
+
const [prose = "", ...commands] = text.split("\n");
|
|
127
|
+
return [...wrapAnsi(prose, Math.max(1, width - col), {
|
|
128
|
+
hard: false,
|
|
129
|
+
wordWrap: true,
|
|
130
|
+
trim: true,
|
|
131
|
+
})
|
|
132
|
+
.split("\n")
|
|
133
|
+
.map((line) => {
|
|
134
|
+
const plain = visible(line);
|
|
135
|
+
const indent = /^https?:\/\/\S+$/.test(plain) && stringWidth(plain) > width - col
|
|
136
|
+
? textCol
|
|
137
|
+
: col;
|
|
138
|
+
return prefix(indent) + line;
|
|
139
|
+
}), ...commands.map((command) => prefix(col) + command)];
|
|
138
140
|
};
|
|
139
141
|
const stepRows = (kind, number, title, outcome, plan = false) => {
|
|
140
142
|
refresh();
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Catalyst's GitHub: show a ticket's pull request with its checks, reviews and review threads, say whether it is mergeable under this repository's policy, and explain what a PR accumulates as the ticket moves (the branch, the draft, the rewrite, the force-pushes, the labels, the queue). Use when someone asks "show me the PR", "what are the checks saying", "why hasn't it merged", "what does the queue need", "what does that label mean", or wants the branch and merge conventions Catalyst follows.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.21 — 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.21 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Catalyst Linear
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ description: >-
|
|
|
4
4
|
Set up Catalyst Cloud and say whether setup is working. Walks a person from nothing to their first ticket running, one step at a time: the coding account, the project, the integrations and connected accounts, each repository's settings file, then one real ticket moving. Also logs this machine in, reads the readiness verdict with who can fix each failure, and checks the optional local replica. Use when someone says "set me up", "onboard me", "I just signed up", "get me started", "what do I do first", "log me in", "which account is this machine on", "am I set up", "what is missing", "why does nothing happen" or "is the replica running", when a login expired, or when a skill script exits 2 saying this machine is not connected. Does every step a key can do through the catalyst CLI, hands over the exact page for the steps only a browser can do, and never claims a step it did not watch succeed.
|
|
5
5
|
allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
|
|
6
6
|
---
|
|
7
|
-
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.
|
|
7
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.21 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# Onboard me
|
|
10
10
|
|
|
@@ -32,7 +32,7 @@ const NOTES = [
|
|
|
32
32
|
"Reads, in this order: `status` (machine), `ready --json` (machine checks and project checks, kept apart),",
|
|
33
33
|
"`replica status --probe --json` and `events status --from-cache --probe --json` (optional local freshness),",
|
|
34
34
|
"`me --json` and personal connection statuses (person), `contract --path …` for the account, the projects and the repositories,",
|
|
35
|
-
"`contract --path codingAccounts` and `accounts --json` (coding accounts, and which one needs a new credential), and each",
|
|
35
|
+
"`contract --path codingAccounts` and `accounts --all --json` (coding accounts, and which one needs a new credential), and each",
|
|
36
36
|
"project's hosts_current check with its fixedWhere (host), and each project's environment_declared check with its per-repository notes (repository declarations). The teams read is refreshed, so a mapping just saved reads back mapped.",
|
|
37
37
|
"Reads `capabilities --json` once: when the installed CLI can run a step for this person's role (`team check`, `team map`), the next step is that command; otherwise the page, with who can.",
|
|
38
38
|
"Reads `legacy --json` when the CLI has the verb: leftovers of the old local Catalyst runtime become a machine line and a note; removing them is the person's yes.",
|
|
@@ -716,7 +716,8 @@ const credentialProblem = (a) => {
|
|
|
716
716
|
return null;
|
|
717
717
|
};
|
|
718
718
|
const readAccountRows = () => {
|
|
719
|
-
|
|
719
|
+
// --all: the CLI leaves removed accounts out by default, and the retire note needs them.
|
|
720
|
+
const acc = runCli(["accounts", "--all", "--json"]);
|
|
720
721
|
const doc = tryJson(acc.stdout);
|
|
721
722
|
const rows = Array.isArray(doc)
|
|
722
723
|
? doc
|
|
@@ -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.21 — 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.21 — 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.21 — 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.21 — written in this repository for customer accounts -->
|
|
8
8
|
|
|
9
9
|
# What this repository needs
|
|
10
10
|
|