@catalyst-cloud/cli 0.16.33 → 0.16.35

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.
@@ -1,64 +1,263 @@
1
- // update-skills.ts — the Cloud skills pack moves to its approved version (CTC-6708). The pack
2
- // ships inside the CLI package of the same version, so a release check installs that exact CLI
3
- // package into its own directory (update-cli.ts's stageCliRuntime, which checks it and selects
4
- // nothing), checks that its bundled skills carry the approved version's stamp, and refreshes the
5
- // copies of those skills this install already made. That works while the CLI itself is held: the
6
- // pack comes from the staged package, never from the older CLI's own bundle.
7
- //
8
- // It changes only what installSkills already treats as its own: a skill folder stamped by this
9
- // package. A person's own skill of the same name, a symlinked entry (a plugin or the installer's
10
- // link) and any skill not installed yet are left as they are. Success is read back from the stamps
11
- // on disk.
12
- import { existsSync, lstatSync, readdirSync } from "node:fs";
13
- import { join } from "node:path";
14
- import { installedBundleVersion, installSkills } from "./skills.js";
1
+ import { randomUUID } from "node:crypto";
2
+ // Reconcile owned filesystem packs to an approved Git commit, publishing the receipt last.
3
+ import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ import { configDirFor } from "./config.js";
15
6
  import { stageCliRuntime, stagedSkillsDir } from "./update-cli.js";
16
- const skillNames = (dir) => readdirSync(dir, { withFileTypes: true })
17
- .filter((e) => e.isDirectory() && existsSync(join(dir, e.name, "SKILL.md")))
18
- .map((e) => e.name);
19
- /** Stamped Cloud skills that are links: installSkills never writes through one, so copying cannot move them. */
20
- function linkedPackEntries(skillsDir) {
21
- let entries;
7
+ import { contentDigest, record, safeName, skillTreeHash, stageSkillSource } from "./update-skill-source.js";
8
+ import { destinationMatches, inspectSkillInstallation, plainDirectory, readSkillLock, skillLockPath, writeSkillReceipt } from "./update-skill-state.js";
9
+ /** One writer for receipts, adopted locks and plugin source selection. Dead owners are retryable. */
10
+ export function withSkillUpdateLock(home, busy, run) {
11
+ const root = configDirFor(home);
12
+ mkdirSync(root, { recursive: true, mode: 0o700 });
13
+ const lock = join(root, ".skill-update.lock");
14
+ const owner = JSON.stringify({ pid: process.pid, token: randomUUID() });
22
15
  try {
23
- entries = readdirSync(skillsDir);
16
+ writeFileSync(lock, owner, { flag: "wx", mode: 0o600 });
24
17
  }
25
18
  catch {
26
- return [];
27
- }
28
- return entries.filter((name) => {
19
+ // Only one reclaimer can inspect and remove a dead owner's lock. A process interrupted
20
+ // inside this short section leaves the guard in place and fails closed, never admits peers.
21
+ const reclaim = `${lock}.reclaim`;
29
22
  try {
30
- return lstatSync(join(skillsDir, name)).isSymbolicLink() && installedBundleVersion(skillsDir, [name]).version !== null;
23
+ mkdirSync(reclaim, { mode: 0o700 });
31
24
  }
32
25
  catch {
33
- return false;
26
+ return busy;
34
27
  }
35
- });
36
- }
37
- /** Refresh the Cloud pack's installed skills in `skillsDir` to exact version `target`. */
38
- export function applyCloudPackUpdate(home, skillsDir, target, deps = {}) {
39
- // Checked before any download, so a linked pack is not fetched again on every run.
40
- if (linkedPackEntries(skillsDir).length > 0)
41
- return { outcome: "linked", detail: "installation_owner_unknown", version: null };
42
- const staged = stageCliRuntime(home, target, deps);
43
- if (!staged.ok)
44
- return { outcome: "failed", detail: staged.detail, version: null };
45
- const source = stagedSkillsDir(staged.root);
46
- let names;
28
+ try {
29
+ const saved = JSON.parse(readFileSync(lock, "utf8"));
30
+ if (!record(saved) || typeof saved.pid !== "number" || !Number.isSafeInteger(saved.pid) || saved.pid <= 0)
31
+ return busy;
32
+ try {
33
+ process.kill(saved.pid, 0);
34
+ return busy;
35
+ }
36
+ catch (error) {
37
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "ESRCH")
38
+ return busy;
39
+ }
40
+ rmSync(lock);
41
+ writeFileSync(lock, owner, { flag: "wx", mode: 0o600 });
42
+ }
43
+ catch {
44
+ return busy;
45
+ }
46
+ finally {
47
+ rmSync(reclaim, { recursive: true, force: true });
48
+ }
49
+ }
47
50
  try {
48
- names = skillNames(source);
51
+ return run();
49
52
  }
50
- catch {
51
- return { outcome: "failed", detail: "pack_mismatch", version: null };
53
+ finally {
54
+ try {
55
+ if (readFileSync(lock, "utf8") === owner)
56
+ rmSync(lock);
57
+ }
58
+ catch { /* Another owner is never unlocked here. */ }
52
59
  }
53
- // The staged package must carry exactly the approved pack, or nothing is copied.
54
- if (names.length === 0 || installedBundleVersion(source, names).version !== target)
55
- return { outcome: "failed", detail: "pack_mismatch", version: null };
60
+ }
61
+ /** Recover a durable transaction after a dead writer, validating every destination before writes. */
62
+ function recover(home, env, pack, dir) {
63
+ const journal = join(configDirFor(home), ".skill-transaction.json");
64
+ if (!existsSync(journal))
65
+ return true;
56
66
  try {
57
- installSkills(skillsDir, { onlyExisting: true }, source, target);
67
+ const raw = JSON.parse(readFileSync(journal, "utf8"));
68
+ if (!record(raw) || raw.pack !== pack || raw.dir !== dir || (raw.kind !== "legacy" && raw.kind !== "npx") || !Array.isArray(raw.replacements) || typeof raw.receiptBefore !== "string" && raw.receiptBefore !== null || typeof raw.lockBefore !== "string" && raw.lockBefore !== null)
69
+ return false;
70
+ if (raw.kind === "npx" && (raw.lockPath !== skillLockPath(home, env) || typeof raw.lockBefore !== "string"))
71
+ return false;
72
+ if (raw.kind === "legacy" && raw.lockPath !== undefined)
73
+ return false;
74
+ const roots = [...new Set([dir, ...[".claude", ".codex", ".cursor", ".opencode", ".config/opencode"].map((agent) => join(home, agent, "skills"))])];
75
+ const entries = [];
76
+ for (const item of raw.replacements) {
77
+ if (!record(item) || !record(item.destination))
78
+ return false;
79
+ const d = item.destination;
80
+ if (typeof d.name !== "string" || !safeName(d.name) || d.path !== join(raw.kind === "npx" ? join(home, ".agents/skills") : dir, d.name) || typeof d.digest !== "string" || !/^[a-f0-9]{64}$/.test(d.digest) || !Array.isArray(d.links) || !d.links.every((link) => typeof link === "string" && roots.some((root) => link === join(root, String(d.name)))))
81
+ return false;
82
+ const destination = { name: d.name, path: String(d.path), digest: d.digest, links: d.links, skillPath: `skills/${d.name}` };
83
+ if (item.backup !== `${destination.path}.catalyst-backup` || item.staged !== `${destination.path}.catalyst-staged` || !plainDirectory(dirname(destination.path)))
84
+ return false;
85
+ if (existsSync(item.backup)) {
86
+ if (!plainDirectory(item.backup) || contentDigest(item.backup) !== destination.digest)
87
+ return false;
88
+ // Someone may have edited the selected files after a crash. Never discard those bytes.
89
+ if (raw.committed !== true && existsSync(destination.path) && (!plainDirectory(destination.path) || contentDigest(destination.path) !== item.nextDigest))
90
+ return false;
91
+ }
92
+ for (const link of destination.links) {
93
+ try {
94
+ if (!lstatSync(link).isSymbolicLink() || realpathSync(link) !== destination.path)
95
+ return false;
96
+ }
97
+ catch (error) {
98
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT")
99
+ return false;
100
+ }
101
+ }
102
+ entries.push({ destination, backup: item.backup, staged: item.staged });
103
+ }
104
+ if (raw.committed === true) {
105
+ const receipt = readFileSync(join(configDirFor(home), "skill-installations.json"), "utf8");
106
+ if (receipt !== raw.receiptAfter)
107
+ return false;
108
+ // The transaction already committed. Finish only its backup cleanup; selected files stay.
109
+ for (const item of entries) {
110
+ rmSync(item.backup, { recursive: true, force: true });
111
+ rmSync(item.staged, { recursive: true, force: true });
112
+ }
113
+ rmSync(journal);
114
+ return true;
115
+ }
116
+ for (const item of entries.reverse()) {
117
+ if (existsSync(item.backup)) {
118
+ rmSync(item.destination.path, { recursive: true, force: true });
119
+ renameSync(item.backup, item.destination.path);
120
+ }
121
+ for (const link of item.destination.links) {
122
+ try {
123
+ lstatSync(link);
124
+ }
125
+ catch {
126
+ symlinkSync(item.destination.path, link);
127
+ }
128
+ }
129
+ rmSync(item.staged, { recursive: true, force: true });
130
+ }
131
+ if (typeof raw.lockPath === "string" && typeof raw.lockBefore === "string") {
132
+ const previous = JSON.parse(raw.lockBefore);
133
+ const lock = readSkillLock(raw.lockPath);
134
+ if (!record(previous) || !record(previous.skills) || !lock)
135
+ return false;
136
+ for (const { destination } of entries)
137
+ lock.skills[destination.name] = previous.skills[destination.name];
138
+ writeFileSync(raw.lockPath, JSON.stringify(lock), { mode: 0o600 });
139
+ }
140
+ const receiptPath = join(configDirFor(home), "skill-installations.json");
141
+ if (raw.receiptBefore === null)
142
+ rmSync(receiptPath, { force: true });
143
+ else
144
+ writeFileSync(receiptPath, raw.receiptBefore, { mode: 0o600 });
145
+ if (!entries.every((entry) => destinationMatches(entry.destination)))
146
+ return false;
147
+ rmSync(journal);
148
+ return true;
58
149
  }
59
150
  catch {
60
- return { outcome: "failed", detail: "install_failed", version: installedBundleVersion(skillsDir, names).version };
151
+ return false;
61
152
  }
62
- const now = installedBundleVersion(skillsDir, names).version;
63
- return now === target ? { outcome: "updated", detail: "refreshed", version: now } : { outcome: "failed", detail: "verify_failed", version: now };
153
+ }
154
+ export function applyPackUpdate(home, env, pack, dir, target, deps = {}) {
155
+ const failed = (detail) => ({ outcome: "failed", detail, version: null, commit: null });
156
+ return withSkillUpdateLock(home, failed("update_in_progress"), () => {
157
+ if (!recover(home, env, pack, dir))
158
+ return failed("recovery_failed");
159
+ const evidence = inspectSkillInstallation(home, env, pack, dir);
160
+ if (evidence.reason === "local_changes")
161
+ return failed("local_changes");
162
+ if (!evidence.present || !evidence.candidate)
163
+ return { outcome: "linked", detail: "installation_owner_unknown", version: evidence.version, commit: null };
164
+ if (evidence.commit === target.commit && evidence.version === target.version)
165
+ return { outcome: "current", detail: "current", version: evidence.version, commit: evidence.commit };
166
+ try {
167
+ if (!evidence.receipt) {
168
+ if (evidence.kind === "npx") {
169
+ if (!evidence.destinations.every((d) => skillTreeHash(d.path, env) === d.lockHash))
170
+ return failed("local_changes");
171
+ }
172
+ else {
173
+ if (evidence.version === null)
174
+ return failed("installation_owner_unknown");
175
+ const baseline = stageCliRuntime(home, evidence.version, { ...deps.baseline, env });
176
+ if (!baseline.ok)
177
+ return { outcome: "linked", detail: "installation_owner_unknown", version: evidence.version };
178
+ if (!evidence.destinations.every((d) => contentDigest(join(stagedSkillsDir(baseline.root), d.name)) === d.digest))
179
+ return failed("local_changes");
180
+ }
181
+ }
182
+ const source = stageSkillSource(home, pack, target, { ...deps, env });
183
+ if (!source.ok)
184
+ return failed(source.detail);
185
+ const replacements = [];
186
+ const after = [];
187
+ for (const destination of evidence.destinations) {
188
+ const backup = `${destination.path}.catalyst-backup`, staged = `${destination.path}.catalyst-staged`;
189
+ if (existsSync(backup) || existsSync(staged) || !plainDirectory(dirname(destination.path)))
190
+ return failed("activation_conflict");
191
+ const next = join(source.dir, destination.skillPath);
192
+ const retired = !existsSync(join(next, "SKILL.md"));
193
+ replacements.push({ destination, backup, staged, retired, nextDigest: retired ? null : contentDigest(next) });
194
+ if (!retired)
195
+ after.push({ ...destination, digest: contentDigest(next), lockHash: skillTreeHash(next, env) });
196
+ }
197
+ const receiptPath = join(configDirFor(home), "skill-installations.json");
198
+ const receiptBefore = existsSync(receiptPath) ? readFileSync(receiptPath, "utf8") : null;
199
+ const lockBefore = evidence.lockPath ? readFileSync(evidence.lockPath, "utf8") : null;
200
+ const journal = join(configDirFor(home), ".skill-transaction.json");
201
+ writeFileSync(journal, JSON.stringify({ pack, dir, kind: evidence.kind, replacements, receiptBefore, lockBefore, lockPath: evidence.lockPath }), { mode: 0o600 });
202
+ try {
203
+ for (const item of replacements)
204
+ if (!item.retired)
205
+ cpSync(join(source.dir, item.destination.skillPath), item.staged, { recursive: true, dereference: false });
206
+ if (!evidence.destinations.every(destinationMatches))
207
+ throw new Error("local_changes");
208
+ const rename = deps.rename ?? renameSync;
209
+ for (const item of replacements) {
210
+ rename(item.destination.path, item.backup);
211
+ if (!item.retired)
212
+ rename(item.staged, item.destination.path);
213
+ else
214
+ for (const link of item.destination.links)
215
+ rmSync(link);
216
+ }
217
+ if (evidence.lockPath) {
218
+ if (readFileSync(evidence.lockPath, "utf8") !== lockBefore)
219
+ throw new Error("lock_changed");
220
+ const lock = readSkillLock(evidence.lockPath);
221
+ if (!lock)
222
+ throw new Error("source_mismatch");
223
+ for (const d of evidence.destinations) {
224
+ const next = after.find((item) => item.name === d.name);
225
+ if (!next)
226
+ delete lock.skills[d.name];
227
+ else {
228
+ const old = lock.skills[d.name];
229
+ if (!record(old))
230
+ throw new Error("source_mismatch");
231
+ lock.skills[d.name] = { ...old, ref: target.commit, skillFolderHash: next.lockHash };
232
+ }
233
+ }
234
+ const temporary = `${evidence.lockPath}.${process.pid}.tmp`;
235
+ writeFileSync(temporary, JSON.stringify(lock), { mode: 0o600 });
236
+ renameSync(temporary, evidence.lockPath);
237
+ }
238
+ if (!after.every(destinationMatches))
239
+ throw new Error("verify_failed");
240
+ const receipt = { pack, ...target, kind: evidence.kind === "npx" ? "npx" : "legacy", dir, destinations: after, ...(evidence.lockPath ? { lockPath: evidence.lockPath } : {}) };
241
+ (deps.writeReceipt ?? writeSkillReceipt)(home, receipt);
242
+ const saved = JSON.parse(readFileSync(receiptPath, "utf8"));
243
+ if (!record(saved) || !record(saved.packs) || JSON.stringify(saved.packs[pack]) !== JSON.stringify(receipt) || !after.every(destinationMatches))
244
+ throw new Error("verify_failed");
245
+ // Keep a durable committed marker until fixed-name backups are all removed.
246
+ const committed = `${journal}.tmp`;
247
+ writeFileSync(committed, JSON.stringify({ pack, dir, kind: evidence.kind, replacements, receiptBefore, lockBefore, lockPath: evidence.lockPath, committed: true, receiptAfter: readFileSync(receiptPath, "utf8") }), { mode: 0o600 });
248
+ renameSync(committed, journal);
249
+ for (const item of replacements)
250
+ rmSync(item.backup, { recursive: true, force: true });
251
+ rmSync(journal);
252
+ return { outcome: "updated", detail: "approved_commit_installed", version: target.version, commit: target.commit };
253
+ }
254
+ catch (error) {
255
+ const restored = recover(home, env, pack, dir);
256
+ return failed(restored ? error instanceof Error ? error.message : "activate_failed" : "rollback_failed");
257
+ }
258
+ }
259
+ catch (error) {
260
+ return failed(error instanceof Error ? error.message : "install_failed");
261
+ }
262
+ });
64
263
  }
package/dist/update.js CHANGED
@@ -8,21 +8,15 @@
8
8
  // member route. The runner, supervisor and watchdog move through runner-update.ts's engine with that
9
9
  // same read, so the image half and the component half can never come from different approvals.
10
10
  //
11
- // This CLI applies the image components itself, moves the CLI to the approved version (installed
12
- // beside the running one and selected through the person's own command: update-cli.ts), and then
13
- // restarts a running local replica on it with its data (update-replica.ts). The Cloud skills pack
14
- // moves to its own approved version from that version's package, even while the CLI is held
15
- // (update-skills.ts), and its Claude plugin form moves through Claude Code when the plugin's
16
- // marketplace serves the approved version (update-plugin.ts). The Dev pack carries no version this CLI can read, so it is reported, never
17
- // moved. A project's SDK is reported
18
- // with its update command; an applying run changes a project's files only when its owner turned that
19
- // project's SDK updates on, and a check never does.
11
+ // Filesystem packs and the user-scope Cloud plugin reconcile exact approved Git commits.
12
+ // CLI, SDK and image versions retain their no-downgrade policies. Each adapter verifies its own
13
+ // installed state, while this coordinator keeps one approval read and rechecks component holds.
20
14
  import { compareVersions, hostApproval, readApprovalCache, readMemberApproval, supportedReleaseLine, writeApprovalCache, } from "./approved-release.js";
21
15
  import { loadConfig } from "./config.js";
22
16
  import { applyCliUpdate } from "./update-cli.js";
23
17
  import { readInventory } from "./update-inventory.js";
24
18
  import { restartPending, restartReplica } from "./update-replica.js";
25
- import { applyCloudPackUpdate } from "./update-skills.js";
19
+ import { applyPackUpdate } from "./update-skills.js";
26
20
  import { applyCloudPluginUpdate, CLOUD_PLUGIN_COMMAND } from "./update-plugin.js";
27
21
  import { onboardStatePath, readOnboardJournal } from "./onboard.js";
28
22
  import { effectivePolicy, projectIdentityHolds, readUpdatePolicy, UPDATE_COMPONENTS, withMigratedHolds, } from "./update-policy.js";
@@ -148,22 +142,21 @@ function componentRows(inventory, policy, release, unavailable, crossTrain) {
148
142
  const target = release?.skills[pack] ?? null;
149
143
  const found = inventory.skills[pack];
150
144
  const approved = target?.version ?? null;
145
+ const evidence = found.evidence;
146
+ const base = { installed: evidence?.version ?? (found.state === "installed" ? found.version : null), approved, installedCommit: evidence?.commit ?? null, approvedCommit: target?.commit ?? null, action: null };
151
147
  if (found.state === "not_installed")
152
- return finish(r, { installed: null, approved, status: "not_installed", reason: "not_installed", action: null });
153
- if (found.state === "unknown")
154
- return finish(r, { installed: null, approved, status: "unknown", reason: found.reason, action: null });
148
+ return finish(r, { ...base, status: "not_installed", reason: "not_installed" });
155
149
  if (target === null)
156
- return finish(r, { installed: found.version, approved: null, status: "approval_unavailable", reason: unavailable, action: null });
150
+ return finish(r, { ...base, status: "approval_unavailable", reason: release ? "pack_not_approved" : unavailable });
157
151
  if (crossTrain)
158
- return finish(r, { installed: found.version, approved, status: "cross_train", reason: "cross_train", action: null });
159
- const decided = versionStatus(found.version, target.version, r.enabled);
160
- return finish(r, {
161
- installed: found.version,
162
- approved,
163
- ...decided,
164
- // An applying run moves the Cloud pack itself; the Dev pack's command is the owner's to run.
165
- action: decided.status === "update_available" && pack === "dev" ? `npx skills add https://github.com/${target.repository}/tree/${target.commit} --all -g` : null,
166
- });
152
+ return finish(r, { ...base, status: "cross_train", reason: "cross_train" });
153
+ if (!r.enabled)
154
+ return finish(r, { ...base, status: "held", reason: "owner_setting" });
155
+ if (!evidence?.candidate)
156
+ return finish(r, { ...base, status: "unknown", reason: evidence?.reason ?? "installation_owner_unknown" });
157
+ if (evidence.commit === target.commit && evidence.version === target.version)
158
+ return finish(r, { ...base, status: "current", reason: "current" });
159
+ return finish(r, { ...base, status: "update_available", reason: evidence.commit === null ? "commit_unrecorded" : "commit_mismatch" });
167
160
  };
168
161
  // CTC-6791: the Claude plugin form follows the Cloud pack's setting, and is listed only where it is installed.
169
162
  const pluginRow = (() => {
@@ -172,15 +165,19 @@ function componentRows(inventory, policy, release, unavailable, crossTrain) {
172
165
  return null;
173
166
  const r = { ...row("skills-cloud"), id: "skills-cloud-plugin" };
174
167
  const approved = release?.members.plugin ?? null;
175
- if (found.state === "unknown")
176
- return finish(r, { installed: null, approved, status: "unknown", reason: found.reason, action: null });
177
- if (approved === null)
178
- return finish(r, { installed: found.version, approved: null, status: "approval_unavailable", reason: unavailable, action: null });
168
+ const target = release?.skills.cloud;
169
+ const base = { installed: found.state === "installed" ? found.version : null, approved, installedCommit: found.state === "installed" ? found.commit : null, approvedCommit: target?.commit ?? null, action: null };
170
+ if (!target || !approved)
171
+ return finish(r, { ...base, status: "approval_unavailable", reason: release ? "pack_not_approved" : unavailable });
179
172
  if (crossTrain)
180
- return finish(r, { installed: found.version, approved, status: "cross_train", reason: "cross_train", action: null });
181
- const decided = versionStatus(found.version, approved, r.enabled);
182
- // An applying run moves it through Claude Code; with no `claude` command found, the owner runs it.
183
- return finish(r, { installed: found.version, approved, ...decided, action: decided.status === "update_available" && found.claude === null ? CLOUD_PLUGIN_COMMAND : null });
173
+ return finish(r, { ...base, status: "cross_train", reason: "cross_train" });
174
+ if (!r.enabled)
175
+ return finish(r, { ...base, status: "held", reason: "owner_setting" });
176
+ if (found.state === "unknown")
177
+ return finish(r, { ...base, status: "unknown", reason: found.reason });
178
+ if (found.commit === target.commit && found.version === approved)
179
+ return finish(r, { ...base, status: "current", reason: "current" });
180
+ return finish(r, { ...base, status: "update_available", reason: found.claude === null ? "claude_not_found" : found.commit === null ? "commit_unrecorded" : "commit_mismatch", action: found.claude === null ? CLOUD_PLUGIN_COMMAND : null });
184
181
  })();
185
182
  const replica = row("replica");
186
183
  const replicaRow = (() => {
@@ -351,38 +348,42 @@ export async function runUpdate(ctx, options) {
351
348
  Object.assign(cliRow, { status: "updated", reason: moved.detail, installed: moved.version });
352
349
  }
353
350
  }
354
- const packRow = components.find((c) => c.id === "skills-cloud");
355
- const pack = inventory.skills.cloud;
356
- if (packRow && packRow.status === "update_available" && packRow.approved !== null && pack.state === "installed") {
357
- if (!effectivePolicy(current, "skills-cloud").enabled)
358
- Object.assign(packRow, { status: "held", reason: "owner_setting" });
359
- else {
360
- const moved = (options.packApply ?? applyCloudPackUpdate)(ctx.home, pack.dir, packRow.approved);
361
- if (moved.outcome === "updated")
362
- Object.assign(packRow, { status: "updated", reason: moved.detail, installed: moved.version });
363
- else if (moved.outcome === "linked")
364
- Object.assign(packRow, { status: "unknown", reason: moved.detail });
365
- else
366
- Object.assign(packRow, { status: "failed", reason: moved.detail, installed: moved.version ?? packRow.installed });
351
+ for (const name of ["cloud", "dev"]) {
352
+ const id = name === "cloud" ? "skills-cloud" : "skills-dev";
353
+ const packRow = components.find((c) => c.id === id);
354
+ const pack = inventory.skills[name];
355
+ const target = release.skills[name];
356
+ if (packRow && target && pack.dir && (packRow.status === "update_available" || packRow.reason === "local_changes")) {
357
+ if (!effectivePolicy(readEffectivePolicy(ctx), id).enabled)
358
+ Object.assign(packRow, { status: "held", reason: "owner_setting" });
359
+ else {
360
+ const moved = (options.packApply ?? applyPackUpdate)(ctx.home, ctx.env, name, pack.dir, target);
361
+ if (moved.outcome === "updated" || moved.outcome === "current")
362
+ Object.assign(packRow, { status: moved.outcome, reason: moved.detail, installed: moved.version, installedCommit: moved.commit ?? null });
363
+ else if (moved.outcome === "linked")
364
+ Object.assign(packRow, { status: "unknown", reason: moved.detail });
365
+ else
366
+ Object.assign(packRow, { status: "failed", reason: moved.detail, installed: moved.version ?? packRow.installed, installedCommit: null });
367
+ }
367
368
  }
368
369
  }
369
370
  const pluginRow = components.find((c) => c.id === "skills-cloud-plugin");
370
371
  const plugin = inventory.plugin;
371
- if (pluginRow && pluginRow.status === "update_available" && pluginRow.approved !== null && plugin.state === "installed" && plugin.claude !== null) {
372
- if (!effectivePolicy(current, "skills-cloud").enabled)
372
+ if (pluginRow && pluginRow.status === "update_available" && pluginRow.approved !== null && plugin.state === "installed" && plugin.claude !== null && release.skills.cloud) {
373
+ if (!effectivePolicy(readEffectivePolicy(ctx), "skills-cloud").enabled)
373
374
  Object.assign(pluginRow, { status: "held", reason: "owner_setting" });
374
375
  else {
375
- const moved = (options.pluginApply ?? applyCloudPluginUpdate)(ctx.home, ctx.env, pluginRow.approved, plugin.scope, { claudePath: plugin.claude });
376
+ const moved = (options.pluginApply ?? applyCloudPluginUpdate)(ctx.home, ctx.env, release.skills.cloud, pluginRow.approved, plugin.scope, { claudePath: plugin.claude });
376
377
  if (moved.outcome === "updated")
377
- Object.assign(pluginRow, { status: "updated", reason: moved.detail, installed: moved.version });
378
- else if (moved.outcome === "waiting")
379
- Object.assign(pluginRow, { status: "pending", reason: moved.detail });
378
+ Object.assign(pluginRow, { status: "updated", reason: moved.detail, installed: moved.version, installedCommit: moved.commit ?? null });
380
379
  else if (moved.outcome === "no_claude")
381
380
  Object.assign(pluginRow, { action: CLOUD_PLUGIN_COMMAND });
382
381
  else
383
382
  Object.assign(pluginRow, { status: "failed", reason: moved.detail, installed: moved.version ?? pluginRow.installed });
384
383
  }
385
384
  }
385
+ if (pluginRow?.reason === "local_changes" && pluginRow.policy === "on")
386
+ Object.assign(pluginRow, { status: "failed" });
386
387
  if (replicaRow && replicaRow.approved !== null) {
387
388
  const cliRuns = cliRow?.status === "updated" || cliRow?.status === "current" || cliRow?.status === "installed_newer";
388
389
  const due = (replicaRow.status === "restart_after_cli" && cliRuns) ||
@@ -517,11 +518,21 @@ export function updateReportLines(report) {
517
518
  for (const project of report.projects)
518
519
  for (const r of sdkRows(project))
519
520
  lines.push(`${cell(r.label, 19)}${cell(r.installed, 16)}${cell(r.approved, 16)}${r.status}`);
521
+ for (const component of report.components) {
522
+ if (component.approvedCommit && component.status !== "not_installed")
523
+ lines.push(`${COMPONENT_LABELS[component.id]} commit: ${component.installedCommit ?? "unknown"} -> ${component.approvedCommit}`);
524
+ if (component.reason === "pack_not_approved")
525
+ lines.push(`${COMPONENT_LABELS[component.id]}: no approved pack was provided; the installed pack was kept.`);
526
+ if (component.status === "failed" && component.approvedCommit)
527
+ lines.push(`${COMPONENT_LABELS[component.id]}: the approved commit was not installed (${component.reason}).${component.reason === "local_changes" ? " Local changes were kept." : ""} Run catalyst update --check --json to inspect the result.`);
528
+ }
520
529
  if (report.projects.length === 0)
521
530
  lines.push("SDK projects: none registered");
522
531
  for (const c of report.components)
523
532
  if (c.action !== null && (c.status === "update_available" || c.status === "pending"))
524
- lines.push(`${COMPONENT_LABELS[c.id]}: this CLI does not install ${c.approved ?? "it"} by itself yet. Run: ${c.action}`);
533
+ lines.push(c.id === "skills-cloud-plugin" && c.reason === "claude_not_found"
534
+ ? `Cloud skills plugin: Claude Code was not found. Make the claude command available, then run catalyst update.`
535
+ : `${COMPONENT_LABELS[c.id]}: this CLI does not install ${c.approved ?? "it"} by itself yet. Run: ${c.action}`);
525
536
  for (const project of report.projects)
526
537
  if (project.command !== null && project.applied?.outcome !== "updated")
527
538
  lines.push(`Update this project's SDK: ${project.command}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catalyst-cloud/cli",
3
- "version": "0.16.33",
3
+ "version": "0.16.35",
4
4
  "description": "Set up Catalyst Cloud, check your tickets and manage your account from the command line.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,6 +39,7 @@
39
39
  "typecheck": "tsc --noEmit",
40
40
  "build": "tsc -p tsconfig.build.json",
41
41
  "prepare": "tsc -p tsconfig.build.json",
42
+ "postinstall": "node bin/postinstall.js",
42
43
  "test": "vitest run",
43
44
  "test:coverage": "vitest run --coverage",
44
45
  "version:sync": "node scripts/sync-plugin-version.mjs",
@@ -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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — 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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — 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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — written in this repository for customer accounts -->
8
8
 
9
9
  # Onboard me
10
10
 
@@ -17,11 +17,12 @@ Global (`-g`) installs go to `~/.agents/skills/`, linked from `~/.claude/skills/
17
17
 
18
18
  ## Keeping each pack current
19
19
 
20
- Check installed components with `catalyst update --check --json`. Read each component's installed version, approved version, status and reason.
21
- Apply enabled updates with `catalyst update` when the person asks you to update. For a component it does not install itself, it prints the exact command; offer that command the same way.
22
- Keep every saved component hold. Do not turn a hold off without the person's instruction.
20
+ Check installed components with `catalyst update --check --json`. For each installed skills pack and Cloud plugin, compare `installedCommit` with `approvedCommit` and read its status and reason. A matching version alone does not prove the approved skills are installed.
21
+ When the person asks to update, run `catalyst update`. Keep every saved component hold. Do not turn a hold off without the person's instruction.
22
+ If the report says `pack_not_approved`, keep that pack and explain that the approved release does not name it. Do not substitute a repository's newest commit or schedule a raw `npx skills add` command.
23
+ If ownership is unknown or local changes are reported, keep those files and show the reason. Do not force a replacement.
23
24
  For a project's SDK, run `catalyst update --check --project <absolute project path>` and show the command it names. Run that command only when the person asks to update that project.
24
- After a plugin update, start a new agent session to load the installed version.
25
+ After a Cloud plugin update, run `/reload-plugins` in Claude Code or start a new session to load it.
25
26
 
26
27
  ## Is each pack there
27
28
 
@@ -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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — written in this repository for customer accounts -->
8
8
 
9
9
  # Run this project
10
10
 
@@ -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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — 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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — 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.33 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.35 — written in this repository for customer accounts -->
8
8
 
9
9
  # What this repository needs
10
10