@catalyst-cloud/cli 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/CHANGELOG.md +75 -0
- package/LICENSE +21 -0
- package/README.md +205 -0
- package/bin/catalyst-skills.js +8 -0
- package/bin/catalyst.js +5 -0
- package/bin/launch.js +154 -0
- package/dist/args.js +280 -0
- package/dist/ask.js +161 -0
- package/dist/browser.js +20 -0
- package/dist/cli.js +397 -0
- package/dist/config.js +241 -0
- package/dist/contract-types.js +4 -0
- package/dist/contract.js +184 -0
- package/dist/detach.js +10 -0
- package/dist/environment.js +207 -0
- package/dist/errors.js +27 -0
- package/dist/events.js +106 -0
- package/dist/execution.js +451 -0
- package/dist/oauth.js +300 -0
- package/dist/pagination.js +76 -0
- package/dist/prompt.js +35 -0
- package/dist/published.js +79 -0
- package/dist/query.js +248 -0
- package/dist/ready.js +380 -0
- package/dist/release.js +142 -0
- package/dist/replica.js +614 -0
- package/dist/runtime-store.js +135 -0
- package/dist/runtime-verb.js +66 -0
- package/dist/runtime.js +87 -0
- package/dist/sdk.js +29 -0
- package/dist/secret.js +190 -0
- package/dist/semver.js +18 -0
- package/dist/skill-shape.js +189 -0
- package/dist/skills.js +129 -0
- package/dist/transport.js +205 -0
- package/dist/ts-deps-loader.js +113 -0
- package/dist/watch/consumer.js +141 -0
- package/dist/watch/cursor-file.js +62 -0
- package/dist/watch.js +175 -0
- package/dist/write.js +224 -0
- package/package.json +60 -0
- package/skills/catalyst-github/SKILL.md +35 -0
- package/skills/catalyst-github/agents/openai.yaml +6 -0
- package/skills/catalyst-github/agents/portability.yaml +4 -0
- package/skills/catalyst-github/references/is-it-mergeable.md +57 -0
- package/skills/catalyst-github/references/what-a-pr-accumulates.md +61 -0
- package/skills/catalyst-github/scripts/is-it-mergeable.mjs +124 -0
- package/skills/catalyst-github/scripts/lib/cli.mjs +103 -0
- package/skills/catalyst-github/scripts/lib/credential.mjs +29 -0
- package/skills/catalyst-github/scripts/lib/pull.mjs +82 -0
- package/skills/catalyst-github/scripts/read-pr.mjs +97 -0
- package/skills/catalyst-linear/SKILL.md +43 -0
- package/skills/catalyst-linear/agents/openai.yaml +6 -0
- package/skills/catalyst-linear/agents/portability.yaml +5 -0
- package/skills/catalyst-linear/references/reading-a-ticket.md +52 -0
- package/skills/catalyst-linear/references/what-a-ticket-accumulates.md +53 -0
- package/skills/catalyst-linear/references/writing-to-linear.md +43 -0
- package/skills/catalyst-linear/scripts/comment.mjs +59 -0
- package/skills/catalyst-linear/scripts/create-ticket.mjs +44 -0
- package/skills/catalyst-linear/scripts/label.mjs +48 -0
- package/skills/catalyst-linear/scripts/lib/cli.mjs +164 -0
- package/skills/catalyst-linear/scripts/lib/credential.mjs +29 -0
- package/skills/catalyst-linear/scripts/move.mjs +41 -0
- package/skills/catalyst-linear/scripts/read-ticket.mjs +93 -0
- package/skills/catalyst-linear/scripts/search.mjs +49 -0
- package/skills/catalyst-onboard/SKILL.md +57 -0
- package/skills/catalyst-onboard/agents/openai.yaml +6 -0
- package/skills/catalyst-onboard/agents/portability.yaml +5 -0
- package/skills/catalyst-onboard/references/declaring-a-repository.md +23 -0
- package/skills/catalyst-onboard/references/skill-sources.md +35 -0
- package/skills/catalyst-onboard/references/the-one-path.md +149 -0
- package/skills/catalyst-onboard/references/what-a-phase-needs.md +46 -0
- package/skills/catalyst-onboard/references/what-the-browser-owns.md +50 -0
- package/skills/catalyst-onboard/references/who-fixes-what.md +44 -0
- package/skills/catalyst-onboard/scripts/lib/cli.mjs +117 -0
- package/skills/catalyst-onboard/scripts/lib/credential.mjs +29 -0
- package/skills/catalyst-onboard/scripts/where-am-i.mjs +345 -0
- package/skills/catalyst-setup/SKILL.md +36 -0
- package/skills/catalyst-setup/agents/openai.yaml +6 -0
- package/skills/catalyst-setup/agents/portability.yaml +4 -0
- package/skills/catalyst-setup/references/what-each-check-means.md +88 -0
- package/skills/catalyst-setup/scripts/check.mjs +75 -0
- package/skills/catalyst-setup/scripts/lib/cli.mjs +103 -0
- package/skills/catalyst-setup/scripts/lib/credential.mjs +29 -0
- package/skills/catalyst-setup/scripts/replica-status.mjs +46 -0
- package/skills/connect-me/SKILL.md +63 -0
- package/skills/connect-me/agents/openai.yaml +6 -0
- package/skills/connect-me/agents/portability.yaml +5 -0
- package/skills/connect-me/references/keeping-the-replica-running.md +88 -0
- package/skills/connect-me/scripts/lib/cli.mjs +185 -0
- package/skills/connect-me/scripts/lib/credential.mjs +29 -0
- package/skills/connect-me/scripts/verify-connection.mjs +68 -0
- package/skills/how-catalyst-works/SKILL.md +43 -0
- package/skills/how-catalyst-works/agents/openai.yaml +6 -0
- package/skills/how-catalyst-works/agents/portability.yaml +4 -0
- package/skills/how-catalyst-works/references/coding-accounts.md +51 -0
- package/skills/how-catalyst-works/references/stages-and-mapping.md +56 -0
- package/skills/how-catalyst-works/references/the-ladder.md +41 -0
- package/skills/how-catalyst-works/references/what-catalyst-is.md +30 -0
- package/skills/how-catalyst-works/references/what-runs-next.md +77 -0
- package/skills/how-catalyst-works/references/when-a-phase-fails.md +57 -0
- package/skills/how-catalyst-works/scripts/explain-ticket.mjs +41 -0
- package/skills/how-catalyst-works/scripts/lib/cli.mjs +164 -0
- package/skills/how-catalyst-works/scripts/lib/credential.mjs +29 -0
- package/skills/how-catalyst-works/scripts/show-my-map.mjs +94 -0
- package/skills/how-catalyst-works/scripts/whats-running.mjs +65 -0
- package/skills/run-this-project/SKILL.md +45 -0
- package/skills/run-this-project/agents/openai.yaml +6 -0
- package/skills/run-this-project/agents/portability.yaml +5 -0
- package/skills/run-this-project/assets/stall-policy.json +15 -0
- package/skills/run-this-project/references/making-work-ready.md +60 -0
- package/skills/run-this-project/references/reacting-to-events.md +76 -0
- package/skills/run-this-project/references/stalls-and-escalation.md +63 -0
- package/skills/run-this-project/scripts/lib/cli.mjs +185 -0
- package/skills/run-this-project/scripts/lib/credential.mjs +29 -0
- package/skills/run-this-project/scripts/make-ready.mjs +64 -0
- package/skills/run-this-project/scripts/scope-status.mjs +0 -0
- package/skills/run-this-project/scripts/watch-scope.mjs +61 -0
- package/skills/unstick/SKILL.md +41 -0
- package/skills/unstick/agents/openai.yaml +6 -0
- package/skills/unstick/agents/portability.yaml +5 -0
- package/skills/unstick/references/playbook.md +51 -0
- package/skills/unstick/scripts/lib/cli.mjs +135 -0
- package/skills/unstick/scripts/lib/credential.mjs +29 -0
- package/skills/unstick/scripts/unstick.mjs +57 -0
- package/skills/what-needs-me/SKILL.md +41 -0
- package/skills/what-needs-me/agents/openai.yaml +6 -0
- package/skills/what-needs-me/agents/portability.yaml +5 -0
- package/skills/what-needs-me/references/raising-a-decision.md +41 -0
- package/skills/what-needs-me/references/reading-the-inbox.md +38 -0
- package/skills/what-needs-me/references/settling-an-answer.md +37 -0
- package/skills/what-needs-me/scripts/inbox.mjs +56 -0
- package/skills/what-needs-me/scripts/lib/cli.mjs +135 -0
- package/skills/what-needs-me/scripts/lib/credential.mjs +29 -0
- package/skills/what-needs-me/scripts/raise.mjs +53 -0
- package/skills/what-needs-me/scripts/settle.mjs +73 -0
- package/skills/whats-happening/SKILL.md +43 -0
- package/skills/whats-happening/agents/openai.yaml +6 -0
- package/skills/whats-happening/agents/portability.yaml +4 -0
- package/skills/whats-happening/assets/status-reply.json +77 -0
- package/skills/whats-happening/references/reading-the-board.md +43 -0
- package/skills/whats-happening/references/reprioritising.md +37 -0
- package/skills/whats-happening/references/routing-work.md +36 -0
- package/skills/whats-happening/references/status-reply.md +34 -0
- package/skills/whats-happening/references/why-is-it-stuck.md +62 -0
- package/skills/whats-happening/scripts/explain.mjs +28 -0
- package/skills/whats-happening/scripts/lib/cli.mjs +135 -0
- package/skills/whats-happening/scripts/lib/credential.mjs +29 -0
- package/skills/whats-happening/scripts/snapshot.mjs +149 -0
- package/vendor/README.md +9 -0
- package/vendor/paths/index.d.ts +85 -0
- package/vendor/paths/index.js +148 -0
- package/vendor/paths/legacy-installer.d.ts +36 -0
- package/vendor/paths/legacy-installer.js +154 -0
- package/vendor/paths/node.d.ts +18 -0
- package/vendor/paths/node.js +102 -0
- package/vendor/paths/provenance.json +17 -0
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
| `runtime` | this runtime can run the CLI: Node 22.15+ (22.15 is where `node:module.registerHooks` arrives, which the SDK's TypeScript dependencies need) or bun 1.4+ (1.4 is where `node:sqlite` arrives, which the replica needs) | `npx -y @catalyst-cloud/catalyst-skills runtime install` — installs a pinned Node under the CLI's own cache and uses it from then on; it does not change your default Node |
|
|
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 in the Cloud setup and operations pack is present in its install scope; this check does not cover coding workflow skills | read `catalyst-onboard`'s `references/skill-sources.md` and install `coalesce-labs/catalyst-cloud-skills` in the intended scope. A count lower than what you just installed means the CLI is older than the skills: `ready` counts its own roster, not the folders on disk. Update the CLI (the `bundle` row). Nothing else is affected meanwhile. |
|
|
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 | check the active lock and every same-named agent path as described in this pack's README, then re-run `npx skills@latest add coalesce-labs/catalyst-cloud-skills --all -g` for a verified global install or omit `-g` inside a project; stop on independent, changed, or uncertain copies. Re-adding picks up new skills. 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 | the same one command (`npx -y @catalyst-cloud/catalyst-skills runtime install`); 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.
|
|
79
|
+
|
|
80
|
+
Explain every button on a team before you recommend one.
|
|
81
|
+
|
|
82
|
+
- **Re-check** reads the team's Linear setup again and saves the new verdict. It changes no ticket and no mapping, so an unmapped team stays unmapped. If something is still missing, it files one setup ticket in that team for an admin. Only an owner or admin can press it.
|
|
83
|
+
- **Map my stages** saves a mapping from the team's existing Linear stages onto Catalyst's slots. It needs no write access to Linear and creates nothing.
|
|
84
|
+
- **Adopt the Catalyst workflow** creates the stages the team lacks, plus Catalyst's standard labels. It needs that admin's own Linear authorisation, so the page offers it only when it can run.
|
|
85
|
+
|
|
86
|
+
Recommend Map my stages when the team's stages already cover the work, and Adopt when they do not. Say which and why.
|
|
87
|
+
|
|
88
|
+
Adopt creates the hold label a failed phase uses when the team has no remediate stage (`teams[].labels.hold`). Creating a label puts it on no ticket. Seeing it right after Adopt means the label exists, not that anything failed.
|
|
@@ -0,0 +1,75 @@
|
|
|
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);
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: connect-me
|
|
3
|
+
description: >-
|
|
4
|
+
Connect this machine to the person's Catalyst Cloud tenant as themselves — keyless (a browser device-code login) or with their own personal key — cache the tenant contract, and verify. Use when a person is getting started, when their config is missing or broken, when their login expired or they rotated their key, when a skill script exits 2 saying the machine is not connected, or when they ask which tenant this machine belongs to. The login names the tenant and the person, so nobody types an account id. Installing the skills is not this skill's job; the agent's own install command did that.
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
allowed-tools: Bash(catalyst-skills:*) Bash(npx @catalyst-cloud/catalyst-skills:*)
|
|
7
|
+
---
|
|
8
|
+
<!-- vendored-from: @catalyst-cloud/catalyst-skills@0.8.0 — written in this repository for customer tenants -->
|
|
9
|
+
|
|
10
|
+
# Connect me
|
|
11
|
+
|
|
12
|
+
Connecting is one command. Keyless is the preferred rail — with no key, `login` opens a browser device-code flow and logs the person in as themselves:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
catalyst-skills login
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
It prints a short code and a URL; the person approves in a browser (or from a phone, on a machine with no browser) and this machine is connected as them. The short-lived session refreshes silently on every request, so they stay connected for months.
|
|
19
|
+
|
|
20
|
+
A **personal key** still works for a script or an unattended shell — the environment form keeps it out of shell history; `--key <personal-key>` is the third form:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
CATALYST_CLOUD_TOKEN=<your-personal-key> catalyst-skills login
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`npx @catalyst-cloud/catalyst-skills login` works when the package is not installed globally. A non-default cloud is pinned with `CATALYST_CLOUD_BASE_URL` or `--base-url`.
|
|
27
|
+
|
|
28
|
+
**This skill never installs skills.** You are already reading one, so the person's agent installed the set with its own command. Connecting is only about the credential and the contract.
|
|
29
|
+
|
|
30
|
+
**What it writes.** `~/.config/catalyst-cloud/customer.json` (mode 0600) holding the credential — a keyless login session (`auth`), or a personal key — the tenant it resolved, the person it resolved (`user`: id, label, role, Linear user id), and the absolute path of this CLI so skill scripts can spawn it; `~/.config/catalyst-cloud/contract.json`, the tenant contract with its ETag. A keyless session's token rotates on its own and the file is rewritten atomically each time. The directory sits under `$HOME`; `CATALYST_SKILLS_HOME` overrides it. With no home directory (a container, or `HOME` unset or `/`) the config lands under `/`. Stop, confirm this is the person's own machine, and set `CATALYST_SKILLS_HOME` if it is.
|
|
31
|
+
|
|
32
|
+
**The replica is optional and one command away.** Nothing has to be running for reads, writes, asks or explanations; the API is origin-fresh. `catalyst-skills replica start --detach` starts the local replica for cheap repeated reads and ad hoc SQL, but only start it when the person asks: it is off by default for large projects. Every skill checks `catalyst-skills replica status` first and falls back to the API when the replica is absent or stale, saying so.
|
|
33
|
+
|
|
34
|
+
## What you do
|
|
35
|
+
|
|
36
|
+
1. Prefer keyless: run `catalyst-skills login` with no key and have the person approve the code in their browser (or from a phone). Nothing to mint, nothing to paste, nothing to keep out of the transcript. A **personal key** is the fallback for a script or unattended shell — they mint it at Settings → API keys (every active member can; no admin is needed) and hand it to the login command via `CATALYST_CLOUD_TOKEN`; it is shown once, so never put it in a file, a ticket, or this conversation beyond that one command. Either way, do not ask an admin for the tenant's **account key** (`ctc_acct_`, Settings → Account keys): that is a host credential — runners, daemons, the host replica — and a person connected with it has no name on anything their agent writes, and "what needs me" cannot mean them. If they connect with one anyway, login says so on stderr and still works.
|
|
37
|
+
2. Run the login command. Its output names the tenant (`Connected to <name> (<slug>)`), the person (`Connected as <label> (<role>)`), the config path, and the cached contract version. If the person line says their Linear identity is not matched yet, tell them: an admin matches it in Settings → Members, and until then "what needs me" shows everyone's asks.
|
|
38
|
+
3. Verify with `node scripts/verify-connection.mjs`: one line each for the tenant, the contract version, and the replica; exit 1 when the machine is not connected.
|
|
39
|
+
4. Run `catalyst-skills ready` and read the verdict to them.
|
|
40
|
+
5. Do not offer the replica. It is optional and off by default for large projects while the snapshot path is made safe, and every read works through the API without it. Start it only if the person asks for local SQL, and then load `references/keeping-the-replica-running.md`.
|
|
41
|
+
6. If login fails: a keyless session that reports "your login expired or was revoked" needs one fresh `catalyst-skills login`, never a retry loop (it means the session was revoked or lapsed past the inactivity window — routine expiry refreshes silently and never surfaces). A `401` on the key rail means a stale, mistyped or revoked key — mint a new one at Settings → API keys, never a retry loop; a network error names the URL, check `--base-url`. A `403` on the contract naming an older cloud means the cloud has not yet deployed personal-key access: update the cloud, or connect with the account key until it has. If login succeeds but prints a line naming two contract versions, the tenant serves a contract outside this bundle's range: update the bundle before using the other skills. A refusal naming `jwt-no-membership` means the cloud has not met this person yet: it learns of a person at their first sign-in to the app. Have them sign in once with this tenant active, then run `login` again. If it repeats, their seat is not active, and a tenant owner or admin activates it.
|
|
42
|
+
|
|
43
|
+
## The verbs a session runs first
|
|
44
|
+
|
|
45
|
+
Every skill session opens with these, in this order, before doing anything else:
|
|
46
|
+
|
|
47
|
+
1. `catalyst-skills status` to confirm the tenant this machine belongs to and where the config and contract live.
|
|
48
|
+
2. `catalyst-skills contract` to load the tenant contract (cached per its own policy; `--refresh` forces a revalidation; `--path teams.0.stages` prints one sub-document).
|
|
49
|
+
3. `catalyst-skills replica status` to learn the read source: exit 0 fresh, 1 stale, 2 not configured, 3 absent.
|
|
50
|
+
4. `catalyst-skills ready` for the full verdict: Node, config, contract, CLI path, skills, SDK, replica, and the tenant's own readiness checks with who can fix each.
|
|
51
|
+
|
|
52
|
+
## Load on demand
|
|
53
|
+
|
|
54
|
+
| when | read |
|
|
55
|
+
| -- | -- |
|
|
56
|
+
| the person wants the replica writer to survive a reboot, or asks what it stores and whether anything needs cleaning | `references/keeping-the-replica-running.md` |
|
|
57
|
+
| the full readiness vector and what each check means | the `catalyst-setup` skill |
|
|
58
|
+
|
|
59
|
+
## Rules
|
|
60
|
+
|
|
61
|
+
- **The credential is a secret.** Keyless is safest — nothing to handle. A key goes into the login command or `CATALYST_CLOUD_TOKEN` and nowhere else: not into tickets, transcripts, or any file you write besides the one login writes; and never read back the `auth` block a keyless session stores.
|
|
62
|
+
- **Never guess a tenant.** There is no `--account`; the credential is the only tenant selector, on purpose. If the cloud names no tenant for the login, stop and say so.
|
|
63
|
+
- **Read the update notice.** After a bundle update, the next command prints one line with the changelog entry and what to run; read it to the person if they are watching.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Connect me"
|
|
3
|
+
short_description: "Connect this machine to your Catalyst Cloud tenant with your own personal key, cache the tenant contract, and verify"
|
|
4
|
+
default_prompt: "Use $connect-me to connect this machine to my Catalyst Cloud tenant."
|
|
5
|
+
policy:
|
|
6
|
+
allow_implicit_invocation: false
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Keeping the replica running
|
|
2
|
+
|
|
3
|
+
This reference restates invariants of the local replica the Catalyst Cloud SDK manages. Paths are the CLI's defaults; the replica file can be moved with `--db` and the config records it.
|
|
4
|
+
|
|
5
|
+
## The supported path is the plain command
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
catalyst-skills replica start --detach # start in the background, write a pidfile, return
|
|
9
|
+
catalyst-skills replica status # 0 fresh, 1 stale, 2 not configured, 3 absent; one line either way
|
|
10
|
+
catalyst-skills replica status --probe # also compare the local cursor with the cloud head
|
|
11
|
+
catalyst-skills replica stop # signal the pidfile's process
|
|
12
|
+
catalyst-skills replica start # foreground, Ctrl-C to stop
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
It is a Node process, not a service. Node 22.15 or newer (or bun 1.4 or newer) with its built-in SQLite module runs it the same on macOS, Linux and Windows, and the bundle never requires a daemon, because a required service is the first thing that breaks on a laptop. The writer is not a prerequisite for any skill; a fresh one is a preference. A skill must never refuse to work because the replica is down, and must never silently read a stale one; `replica status` is the one exit code that settles both.
|
|
16
|
+
|
|
17
|
+
## What it holds on disk, and why nothing rotates
|
|
18
|
+
|
|
19
|
+
Under `~/.config/catalyst-cloud/` by default:
|
|
20
|
+
|
|
21
|
+
| file | what it is |
|
|
22
|
+
| -- | -- |
|
|
23
|
+
| `replica.db` | one SQLite file: the tenant's mirrored tables, kept current by upserts and deletes from the stream |
|
|
24
|
+
| `replica.db.writer.lock` | the writer's lock, with a heartbeat the status check reads |
|
|
25
|
+
| `replica.db.pid` | the background writer's process id, written by `--detach` |
|
|
26
|
+
| a `sync_meta` row inside the database | the stream cursor, so a restart resumes where it stopped |
|
|
27
|
+
| `watch-cursor.json` | the events-only cursor for `catalyst-skills watch`, stamped with the tenant; a few bytes |
|
|
28
|
+
|
|
29
|
+
The replica is upserts and deletes into one file, so it neither grows without bound nor needs pruning; the cursor is a row. There is no directory of old files to clean and nothing to rotate. If the writer logs, it logs to standard error and the shell decides where that goes; nothing under the config directory is a log.
|
|
30
|
+
|
|
31
|
+
The first start seeds the file from the cloud's snapshot (one full copy of the tables) and then follows the stream; a restart resumes from the saved cursor. When the cloud can no longer replay from that cursor it tells the writer to re-seed, which the writer does on its own.
|
|
32
|
+
|
|
33
|
+
## Freshness, as the status check judges it
|
|
34
|
+
|
|
35
|
+
`replica status` needs no network. It answers fresh when the pidfile's process is alive, the writer lock's heartbeat is younger than the staleness threshold (15 seconds by default; `--stale-ms` overrides), and the cursor row is non-empty. Anything else is stale (exit 1) with the reasons listed, absent (exit 3) when there is no file, or not configured (exit 2) when the machine is not connected. `--probe` adds the one network call, fetching the cloud head to print how far behind the local cursor is. Every read verb prints `source: replica (cursor N)` or `source: api (replica stale|absent|not configured)` on standard error, so the answer always names where it came from.
|
|
36
|
+
|
|
37
|
+
## Surviving a reboot
|
|
38
|
+
|
|
39
|
+
Optional. The plain command is the supported path; these are for people who want the writer back after a restart. Each example assumes a global install (`npm install -g @catalyst-cloud/catalyst-skills`); substitute the absolute path `catalyst-skills status` prints as the CLI path if you prefer. Run the writer in the foreground under the supervisor (no `--detach`), so the supervisor owns the process.
|
|
40
|
+
|
|
41
|
+
### macOS, launchd
|
|
42
|
+
|
|
43
|
+
Save as `~/Library/LaunchAgents/dev.catalystcloud.replica.plist`, then `launchctl load ~/Library/LaunchAgents/dev.catalystcloud.replica.plist`:
|
|
44
|
+
|
|
45
|
+
```xml
|
|
46
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
47
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
48
|
+
<plist version="1.0"><dict>
|
|
49
|
+
<key>Label</key><string>dev.catalystcloud.replica</string>
|
|
50
|
+
<key>ProgramArguments</key><array>
|
|
51
|
+
<string>/usr/local/bin/catalyst-skills</string><string>replica</string><string>start</string>
|
|
52
|
+
</array>
|
|
53
|
+
<key>RunAtLoad</key><true/>
|
|
54
|
+
<key>KeepAlive</key><true/>
|
|
55
|
+
<key>StandardErrorPath</key><string>/tmp/catalyst-cloud-replica.err</string>
|
|
56
|
+
</dict></plist>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Check the path to the binary with `which catalyst-skills`; Homebrew Node installs under `/opt/homebrew/bin`. `launchctl unload` the same file to stop it.
|
|
60
|
+
|
|
61
|
+
### Linux, systemd user unit
|
|
62
|
+
|
|
63
|
+
Save as `~/.config/systemd/user/catalyst-cloud-replica.service`, then `systemctl --user daemon-reload && systemctl --user enable --now catalyst-cloud-replica`:
|
|
64
|
+
|
|
65
|
+
```ini
|
|
66
|
+
[Unit]
|
|
67
|
+
Description=Catalyst Cloud local replica
|
|
68
|
+
After=network-online.target
|
|
69
|
+
|
|
70
|
+
[Service]
|
|
71
|
+
ExecStart=/usr/bin/env catalyst-skills replica start
|
|
72
|
+
Restart=on-failure
|
|
73
|
+
RestartSec=5
|
|
74
|
+
|
|
75
|
+
[Install]
|
|
76
|
+
WantedBy=default.target
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For a writer that should run while nobody is logged in, `loginctl enable-linger $USER` once. `journalctl --user -u catalyst-cloud-replica` shows its standard error.
|
|
80
|
+
|
|
81
|
+
### Windows
|
|
82
|
+
|
|
83
|
+
There is no service wrapper in the bundle. Task Scheduler runs `catalyst-skills replica start` at logon with "Run whether user is logged on or not" and "If the task fails, restart every 1 minute"; or run `catalyst-skills replica start --detach` from a shell after logging in, which is the plain path and works the same as elsewhere.
|
|
84
|
+
|
|
85
|
+
## Two things that look like problems and are not
|
|
86
|
+
|
|
87
|
+
- **Two writers.** The writer lock guards the file, so a second writer on the same file is refused rather than allowed to corrupt it. Stop the first (`replica stop`, or the supervisor) before starting another or moving the file.
|
|
88
|
+
- **A stale verdict right after start.** The first start seeds the whole snapshot before it goes live; `status` reads stale until the cursor row appears. Ask again once `replica start` has printed its live line, or watch `status --probe` count the lag down.
|