Skip to content

Using the CLI

Local replica and watch

Watching your workspace live from the cloud, and the opt-in local sync.

Local sync is off unless you start it, and without it Catalyst reads from the cloud. Every command and skill works through the API with nothing running on your machine. The events commands read the cloud too, from the CLI release after 0.14.7; in 0.14.7 and earlier they still need local sync (see Events). Local sync is an opt-in: a replica of your workspace plus a local event file, kept current on your machine. Turn it on only if you want ad hoc SQL on a local copy, or you run many local agents that read the same data.

watch follows your workspace’s change feed live from the cloud and prints frames as they land. It needs no local sync. Scope it to what you care about:

Terminal window
catalyst watch --team ENG
catalyst watch --ticket ENG-42
catalyst watch --exec 'cat >> changes.log'

The cursor persists in ~/.config/catalyst-cloud/watch-cursor.json, so a restarted watch picks up where it left off. --exec runs a shell command per frame with the frame on stdin, which is how you turn the feed into notifications or triggers.

catalyst events tail and catalyst events wait-for are the way to follow Catalyst’s own events, such as a phase finishing on a ticket.

Terminal window
catalyst events tail
catalyst events wait-for --ticket ENG-42 --type relay.phase.completed --timeout 300
catalyst events query --ticket ENG-42 --type relay.phase.completed --limit 1
catalyst events status

The events commands read the cloud by default, so they need no local sync. This ships in the CLI release after 0.14.7. In 0.14.7 and earlier they read the local event file and need local sync; on those versions, use catalyst watch when local sync is off.

  • tail prints each event as one JSON line as it arrives. When it stops, it names the cursor to resume from (--after N).
  • wait-for prints the first event that matches and exits 0, or exits 1 when the timeout passes. That is the right way to wait for one thing instead of polling.
  • query reads one page of your workspace’s event history from GET /api/v1/events/query. It takes --ticket, --type, --limit (at most 200) and --order desc|asc; newest first is the default. An empty page says which range the cloud has indexed, so “no match” is not read as “never happened”. The completion of a phase is relay.phase.completed.
  • status names the source it reads and how far behind it is.

--from-cache makes any of them read this machine’s local event file instead, which local sync fills. It is opt-in: several agents on one machine can share that file rather than each reading the cloud.

Local sync has two parts with separate cursors: the replica and the event file. A fresh replica does not prove fresh events.

The replica is a SQLite copy of your workspace: issues, pull requests, projects, the board. A background writer keeps it current, and reads from it are then local and cheap.

Terminal window
catalyst replica start --detach
catalyst replica status --probe
catalyst replica sql "select identifier, state from issues where team_key = 'ENG' limit 10"
catalyst replica schema issues
catalyst replica stop

replica start also fills the local event file that catalyst events --from-cache reads. catalyst login --start-replica starts it as part of signing in. A default install does not start it.

start --detach runs an unsupervised writer with a pidfile: nothing restarts it after a crash or a reboot. That is a limitation of the current release. Check its status after a reboot or a crash, and start it again if needed.

status --probe makes one network call and compares the local cursor with the cloud head. Exit 0 is fresh; exit 1 is stale (restart with start --detach); exit 3 is absent; exit 2 means the machine is not connected. Every read verb names its source on standard error, so you always know whether you just read the replica or the API.

The first start seeds the whole snapshot before going live, so status reads stale until the cursor appears. Files stay bounded under ~/.config/catalyst-cloud/. To survive a reboot, run the writer under your platform’s supervisor: a launchd agent with KeepAlive on macOS, a systemd user unit with Restart=on-failure on Linux.

  • ad hoc SQL across issues and pull requests,
  • many local agents or scripts reading the same data without each calling the API,
  • many local agents waiting on events from one shared local file, with events wait-for --from-cache.

What it is not for: truth. When the replica and the cloud disagree, the cloud wins, and status --probe tells you which state you are in.