@ligeti/shell 1.2.0 → 1.3.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.
Files changed (66) hide show
  1. package/README.md +33 -0
  2. package/dist/cli/installed-versions.d.ts +9 -0
  3. package/dist/cli/installed-versions.d.ts.map +1 -0
  4. package/dist/cli/installed-versions.js +50 -0
  5. package/dist/cli/installed-versions.js.map +1 -0
  6. package/dist/cli/plugin.d.ts +13 -0
  7. package/dist/cli/plugin.d.ts.map +1 -0
  8. package/dist/cli/plugin.js +188 -0
  9. package/dist/cli/plugin.js.map +1 -0
  10. package/dist/cli/pre-push.d.ts +12 -0
  11. package/dist/cli/pre-push.d.ts.map +1 -0
  12. package/dist/cli/pre-push.js +56 -0
  13. package/dist/cli/pre-push.js.map +1 -0
  14. package/dist/cli/share-dir.d.ts +3 -0
  15. package/dist/cli/share-dir.d.ts.map +1 -0
  16. package/dist/cli/share-dir.js +13 -0
  17. package/dist/cli/share-dir.js.map +1 -0
  18. package/dist/cli/version.d.ts +6 -0
  19. package/dist/cli/version.d.ts.map +1 -0
  20. package/dist/cli/version.js +14 -0
  21. package/dist/cli/version.js.map +1 -0
  22. package/dist/cli.d.ts.map +1 -1
  23. package/dist/cli.js +31 -4
  24. package/dist/cli.js.map +1 -1
  25. package/package.json +6 -5
  26. package/share/.claude-plugin/marketplace.json +14 -0
  27. package/share/plugins/ligeti/.claude-plugin/plugin.json +6 -0
  28. package/share/plugins/ligeti/README.md +31 -0
  29. package/share/plugins/ligeti/docs/attestation.md +590 -0
  30. package/share/plugins/ligeti/docs/shell.md +417 -0
  31. package/share/plugins/ligeti/docs/troubleshooting.md +28 -0
  32. package/share/plugins/ligeti/references/rules.md +93 -0
  33. package/share/plugins/ligeti/skills/authoring-steps/SKILL.md +147 -0
  34. package/share/plugins/ligeti/skills/authoring-workflows/SKILL.md +142 -0
  35. package/share/plugins/ligeti/skills/installing-workflows/SKILL.md +121 -0
  36. package/share/plugins/ligeti/skills/onboard/SKILL.md +290 -0
  37. package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.github.yml +66 -0
  38. package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.yml +69 -0
  39. package/share/plugins/ligeti/skills/onboard/assets/pre-push.sh +11 -0
  40. package/share/plugins/ligeti/skills/scheduling-workflows/SKILL.md +102 -0
  41. package/share/plugins/ligeti/skills/troubleshooting/SKILL.md +94 -0
  42. package/share/plugins/ligeti/templates/step/.prettierignore +3 -0
  43. package/share/plugins/ligeti/templates/step/README.md +52 -0
  44. package/share/plugins/ligeti/templates/step/eslint.config.js +105 -0
  45. package/share/plugins/ligeti/templates/step/package.json +45 -0
  46. package/share/plugins/ligeti/templates/step/src/index.ts +3 -0
  47. package/share/plugins/ligeti/templates/step/src/settings.ts +27 -0
  48. package/share/plugins/ligeti/templates/step/src/tool-version.ts +61 -0
  49. package/share/plugins/ligeti/templates/step/test/rules.test.ts +144 -0
  50. package/share/plugins/ligeti/templates/step/test/settings.test.ts +30 -0
  51. package/share/plugins/ligeti/templates/step/test/tool-version.feature +32 -0
  52. package/share/plugins/ligeti/templates/step/tsconfig.build.json +26 -0
  53. package/share/plugins/ligeti/templates/step/tsconfig.json +21 -0
  54. package/share/plugins/ligeti/templates/workflow/.prettierignore +3 -0
  55. package/share/plugins/ligeti/templates/workflow/README.md +56 -0
  56. package/share/plugins/ligeti/templates/workflow/eslint.config.js +99 -0
  57. package/share/plugins/ligeti/templates/workflow/package.json +46 -0
  58. package/share/plugins/ligeti/templates/workflow/src/workflow.ts +72 -0
  59. package/share/plugins/ligeti/templates/workflow/test/__snapshots__/workflow.test.ts.snap +132 -0
  60. package/share/plugins/ligeti/templates/workflow/test/rules.test.ts +160 -0
  61. package/share/plugins/ligeti/templates/workflow/test/template-workflow.feature +31 -0
  62. package/share/plugins/ligeti/templates/workflow/test/workflow.test.ts +64 -0
  63. package/share/plugins/ligeti/templates/workflow/tsconfig.build.json +26 -0
  64. package/share/plugins/ligeti/templates/workflow/tsconfig.json +21 -0
  65. package/share/scripts/pre-push-gate.sh +308 -0
  66. package/share/scripts/pre-push-lib.sh +64 -0
@@ -0,0 +1,417 @@
1
+ # @ligeti/shell
2
+
3
+ The control plane: web UI, callback endpoint, worker supervisor, registry, and the `ligeti` CLI. It
4
+ never calls `DBOS.launch()`, `registerWorkflow` or `registerStep` — enforced by its own ESLint
5
+ preset ([`packages/eslint-plugin`](../eslint-plugin/README.md)) — and talks to workers only through
6
+ `DBOSClient`, never by holding workflow or step code itself.
7
+
8
+ See [ADR-0012](../../adr/0012-a-workflow-package-is-its-own-dbos-application.md) for why each
9
+ configured workflow runs as its own DBOS application, spawned as a separate worker process by the
10
+ Supervisor rather than sharing this process, and [`docs/trust-model.md`](../../docs/trust-model.md)
11
+ for the security posture this control plane sits inside.
12
+
13
+ ## What it exposes
14
+
15
+ - **`ligeti` CLI**:
16
+ - `ligeti serve` — loads `.env` if present, describes every configured workflow, starts the
17
+ Supervisor and the HTTP server, and shuts down cleanly on `SIGTERM`/`SIGINT`.
18
+ - `ligeti run <workflow>` — enqueues one run over this shell's own HTTP API and returns once
19
+ it has started; `--wait` polls it to completion. Documented in full under
20
+ [`ligeti run`](#ligeti-run) below.
21
+ - `ligeti runs`, `ligeti trace <runId|latest-failed>`, `ligeti transcript <runId>` — read-only
22
+ troubleshooting over the same HTTP API. Documented under
23
+ [`ligeti runs / trace / transcript`](#ligeti-runs--trace--transcript) below.
24
+ - `ligeti workflows`, `ligeti schema <workflow>` — list the workflows and print one's input
25
+ fields. Documented under [`ligeti workflows / schema`](#ligeti-workflows--schema) below.
26
+ - `ligeti cron check [<file>]` — validate a cron file without serving. Documented under
27
+ [Cron entries](#cron-entries) below.
28
+ - **`Supervisor`** (`src/supervisor.ts`) — spawns one `ligeti-worker run <dir>` child process per
29
+ configured workflow, restarts it on crash with backoff, and reports each worker's status. It
30
+ manages OS processes only, never DBOS state.
31
+ - **`Registry`** (`src/registry.ts`) — the shell's view of configured workflows: describes each
32
+ configured package directory once at boot (refusing duplicate workflow names), then serves
33
+ manifests from `ligeti.workflow_registrations`, written by each worker.
34
+ - **HTTP routes** (`src/web/routes.tsx`): `GET /healthz`, `GET /` (redirects to `/runs`;
35
+ an old `/?workflow=` bookmark to `/runs/new` with the same query), `GET /runs/new` (the launch page, reached
36
+ from the Runs tab: workflow picker and start form; `?workflow=` selects a workflow), `GET /runs`
37
+ (the Runs tab: recent launched root runs, 50 per page; `?page=` picks a
38
+ 1-based page, clamped to 1 for anything that isn't a positive safe integer and capped at the
39
+ largest page a safe offset can reach for very large values, with "← Newer"/"Older →" links below
40
+ the table; `?workflow=`, repeatable `?status=`, `?createdFrom=` and `?createdTo=` (inclusive
41
+ `YYYY-MM-DD` UTC days) filter the list, a malformed value answers 400), `GET /cron-runs` (the
42
+ Cron runs tab: see [Cron entries](#cron-entries)), `GET /workers` (the Workers tab: each
43
+ configured worker's supervisor status), `GET /config` (the Configuration tab: the configuration the
44
+ running shell loaded at startup, grouped by owner, secrets only as `set`/`unset`; a later `.env`
45
+ edit shows after a restart), `POST /runs` (see
46
+ [Starting a run over HTTP](#starting-a-run-over-http)), `GET /runs/:id`,
47
+ `POST /runs/:id/cancel`, `GET /workflows`, `GET /workflows/:name`, `POST /attest`, `POST /callbacks/:token`,
48
+ `GET /approvals/:token`, `POST /approvals/:token`. Every page shares a tab bar
49
+ (`Runs`/`Cron runs`/`Workers`/`Configuration`, marking the current one active) except the
50
+ token-authenticated approval pages, which a human
51
+ reaches from outside the shell's own UI; the Workers tab carries a warning mark whenever
52
+ any configured worker isn't in the `"running"` status. `GET /workflows` (with
53
+ `Accept: application/json`: `{ workflows: [{ name, description, registered }] }`; otherwise it
54
+ redirects to `/runs/new`) and `GET /workflows/:name` with `Accept: application/json` (the manifest; 404 for
55
+ an unknown name, 503 before the worker has registered) serve `ligeti workflows` and
56
+ `ligeti schema`. `GET /workers` with `Accept: application/json` answers
57
+ `{ workers: [{ name, status, reason? }] }`: the workflow name, its worker's supervisor status
58
+ (`starting`, `running`, `backoff`, `blocked` or `stopped`) and, when there is one, why. Otherwise `GET /workflows/:name` renders the
59
+ manifest's optional `workflow.diagram` (and, for a child whose parent has no diagram, the child's own) as a Mermaid flowchart, rendered
60
+ client-side by `mermaid/dist/mermaid.min.js`, vendored and served locally at a version-tagged
61
+ `GET /assets/mermaid.min.js?v=<version>` (`src/web/mermaid-asset.ts`) rather than loaded from a
62
+ CDN. The console's own assets are served the same way and never leave the host (`src/web/assets/`):
63
+ the stylesheet at `GET /assets/ligeti.css?v=<content hash>` (tokens, components and the `kit-`
64
+ layout, built from `src/web/styles/`); the Saira, Barlow and IBM Plex Mono `woff2` files at
65
+ `GET /assets/fonts/<family>-<subset>-<weight>-<style>.woff2` (from the `@fontsource/*` packages);
66
+ the allowlisted Lucide icons at `GET /assets/icons/<name>.svg` (from `lucide-static`, drawn through
67
+ a CSS mask; an icon outside `ICON_NAMES` answers 404); the per-status favicons at
68
+ `GET /assets/favicons/<status>[-updated].svg?v=<content hash>` (plus a neutral one, and an
69
+ `-updated` twin with a corner dot); the run page's background-refresh script at
70
+ `GET /assets/run-refresh.js?v=<content hash>`; and the licence of each vendored package at
71
+ `GET /assets/licenses/{saira,barlow,ibm-plex-mono,lucide-static}.txt` (SIL OFL 1.1 for the fonts,
72
+ ISC for the icons). `POST /attest` takes `{ app, repository, commit, configPath? }`, runs the local-verification
73
+ gate in a fresh gate checkout of that commit (`src/gate-checkout.ts`, under
74
+ `$LIGETI_STATE_DIR/gate-checkouts/`) and signs the resulting attestation via `@ligeti/attest`; it
75
+ answers `503` when `LIGETI_ATTEST_SECRET`/`LIGETI_ATTEST_KEY_FILE` are not configured, since
76
+ attestation is optional. `POST /callbacks/:token` is where a spawned agent's `wrapper.sh` delivers
77
+ its result
78
+ back to the shell. The JSON read API (`src/web/read-api.ts`; `Accept: application/json`, behind the
79
+ Host allow-list only) serves troubleshooting: `GET /runs` filters by `status`, `workflow` (each
80
+ repeatable or comma-separated), `since` (ISO time), `limit` (1-500, default 50), `children=true`
81
+ and `scope=launched|cron` (default `launched`; `cron` lists the root runs a schedule started and
82
+ cannot be combined with `children=true`) and answers `400 {error}` to a malformed query; `GET /cron-entries` returns `{ entries: [{ name, workflow, schedule, timezone, lastFiredAt }] }`, the configured cron entries in file order (`lastFiredAt` is `null` until one fires); `GET /runs/:id/trace` returns the run's steps (an
83
+ output over 2000 characters is replaced by its size and a preview), `status` event, agent attempts
84
+ and child runs recursively; `GET /runs/:id/steps/:functionId` returns one step in full;
85
+ `GET /runs/:id/attempts/:attemptId/transcript` digests a Claude `transcript.jsonl` or OpenCode
86
+ `opencode-raw-output.json` (`?raw=1` returns the file); `GET /runs/:id/attempts/:attemptId/files/:name`
87
+ returns one attempt file as text. An attempt is recognised from a step's checkpointed output, and
88
+ its files are read only from inside `$LIGETI_STATE_DIR/runs/` -- a path resolving outside is
89
+ treated as absent.
90
+
91
+ ## Starting a run over HTTP
92
+
93
+ `POST /runs` with `Content-Type: application/json` takes `{ "workflow": "<name>", "input": {...} }`
94
+ and answers `201` with `{ "id": "<run id>" }`. An input property the workflow does not declare is
95
+ rejected by name. The body may also carry `"id"`, which becomes the run's id: 1-256 characters of
96
+ letters, digits, `.`, `_`, `:` and `-`, starting with a letter or digit. A repeated id never starts a
97
+ second run: a request sent after the first was answered finds the run, starts nothing and answers
98
+ `200` with the same `{ "id" }`, ignoring the repeat's input; two requests racing before either is
99
+ answered may both answer `201`, still for the one run. An id that names a run of another workflow is
100
+ a `409`. An id starting with `sched-` is a `400`, because the shell reserves that prefix for cron
101
+ runs, and so is the id `new`, because `/runs/new` is the launch page.
102
+
103
+ Every run started this way -- from the launch page, over JSON, or by `ligeti run` -- carries the DBOS
104
+ attribute `launched: true`, and its child runs inherit it. The Runs tab, `GET /runs` and `ligeti runs`
105
+ list only runs carrying it, so a cron run appears on the Cron runs tab alone. Launched runs created
106
+ before the attribute existed are no longer listed but stay reachable at `/runs/<id>`.
107
+
108
+ ## `ligeti run`
109
+
110
+ `ligeti run <workflow>` enqueues a run against a **running `ligeti serve`** over HTTP -- it
111
+ requires the shell to already be up; unlike `serve`, it needs no `.env` and no environment variable
112
+ at all, since it holds no secret and opens no database connection of its own. That statelessness is the point: it works from a git worktree, from a subdirectory of the
113
+ repo, or from a bare checkout with no `.env` in sight, as long as it can reach a shell. It is
114
+ deliberately not a second control plane -- see
115
+ [ADR-0012](../../adr/0012-a-workflow-package-is-its-own-dbos-application.md).
116
+
117
+ It finds the shell by trying, in order, the first one present: `--url <base>`, then
118
+ `$LIGETI_PUBLIC_BASE_URL`, then `http://<LIGETI_HOST>:<LIGETI_PORT>` (`127.0.0.1:8100` by default).
119
+
120
+ Input is a JSON object on stdin:
121
+
122
+ ```sh
123
+ echo '{"field": "value"}' | ligeti run <workflow-name>
124
+ ```
125
+
126
+ Before enqueuing anything, `ligeti run` validates that input against the workflow's manifest
127
+ schema, so a misspelled field fails in milliseconds with the manifest's own error message instead
128
+ of surfacing as a `zod` failure inside a started run minutes later. A field the manifest does not
129
+ declare is rejected by name rather than ignored, since a JSON caller sends only what it meant to
130
+ send: a typo there is a mistake, not a field to drop.
131
+
132
+ Once the run is accepted, `ligeti run` prints `started <workflow> as <id>` to stderr and exits `0`
133
+ at once, with nothing on stdout; follow the run with `ligeti trace <id>` or the Runs tab. With
134
+ `--wait` it instead polls the run to a terminal status, then prints the run's output as one JSON
135
+ line on stdout on success, or a one-line failure summary on stderr if it fails.
136
+
137
+ Exit codes: `0` the run was started (with `--wait`: it succeeded), `1` the workflow has not
138
+ registered yet or the shell speaks a different protocol (with `--wait`, also: the run failed, timed
139
+ out or no worker claimed it), `2` usage or bad stdin, `3` the shell could not be reached (with
140
+ `--wait`, also: contact with it was lost mid-run) -- so a script can tell "my workflow failed" from
141
+ "my control plane is down". A script that needs the result or the verdict passes `--wait`.
142
+
143
+ ## `ligeti runs / trace / transcript`
144
+
145
+ Three read-only commands for finding out why a run went wrong. Like `ligeti run` they need a
146
+ running `ligeti serve`, hold no secret, and find it by `--url <base>`, then
147
+ `$LIGETI_PUBLIC_BASE_URL`, then `http://<LIGETI_HOST>:<LIGETI_PORT>` (`127.0.0.1:8100` by default). They are thin clients of the shell's JSON
148
+ read API (`GET /runs`, `/runs/:id/trace`, `/runs/:id/steps/:functionId`,
149
+ `/runs/:id/attempts/:attemptId/transcript`).
150
+
151
+ | Command | Prints |
152
+ | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
153
+ | `ligeti runs [--status S] [--workflow W] [--since ISO] [--limit N] [--children] [--cron]` | One line per run, newest first: id, workflow, status, creation time, its parent when it is a child run, and the first line of its error. `--status` and `--workflow` repeat; only root runs unless `--children`; launched runs unless `--cron`, which lists cron runs and first one line per cron entry (name, workflow, schedule, time zone, when it last fired). With `--json`, `--cron` prints `{ entries, runs }`. |
154
+ | `ligeti trace <runId\|latest-failed>` | The run header, its status event, numbered steps (`#<functionId> <name> <status> <duration>`, with `→ child <id>`, the error and an output preview), its agent attempts and its child runs indented, then one `agent failed:` line (with its `ligeti transcript` command) for every agent attempt whose result is an error — a workflow may handle an agent failure and still finish `SUCCESS` — and last `failed at:` for the deepest failed step. `latest-failed` is the newest root run in `ERROR`, launched or cron. A truncated output names the `GET /runs/<id>/steps/<functionId>` route that returns all of it. |
155
+ | `ligeti transcript <runId> [--attempt <attemptId>] [--raw]` | One agent attempt as `user:` / `assistant:` / `tool <name>(<input>)` / `→ result:` / `→ error:` lines, then the final `result:` and `error:`. Without `--attempt` it takes the newest attempt anywhere in the run's tree and asks the run that owns it. `--raw` prints the transcript file's bytes instead. |
156
+
157
+ `latest-failed` matches only status `ERROR`. For a run that ended `CANCELLED` or
158
+ `MAX_RECOVERY_ATTEMPTS_EXCEEDED`, find it with `ligeti runs --status <status>` and trace its id.
159
+ `GET /runs` lists only the runs of registered applications, whereas `GET /runs/:id/trace` serves any
160
+ run id.
161
+
162
+ Each takes `--json`, which prints the shell's response (pretty-printed) instead of text; `--json`
163
+ and `--raw` cannot be combined.
164
+
165
+ Exit codes: `0` success, `1` any other failure, `2` usage error, a bad query, or a run, attempt or
166
+ failed run that does not exist, `3` the shell could not be reached.
167
+
168
+ ## `ligeti workflows / schema`
169
+
170
+ Two read-only commands that tell you what can be run and with which input. They find the shell the
171
+ same way as the commands above, and take `--json`.
172
+
173
+ | Command | Prints |
174
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
175
+ | `ligeti workflows` | One line per workflow: name, `registered` or `not registered`, and the first line of its description. `--json` prints the response of `GET /workflows`. |
176
+ | `ligeti schema <workflow>` | The workflow's name and description, then one line per input field: name, type, `required` or `optional`, `default: …` and description, with nested object fields indented under their parent. `--json` prints only the input JSON Schema (draft 2020-12) with `additionalProperties: false` added at the top level, so it rejects undeclared keys as `POST /runs` does. |
177
+
178
+ Exit codes are those of `ligeti runs`: an unknown workflow is `2`, one that has not registered yet is `1`.
179
+
180
+ ## `ligeti config`
181
+
182
+ Lists and edits the variables in `.env`, so an operator or an agent never has to open that file:
183
+ `.env` holds credentials, and an agent that greps it prints them into a transcript that outlives the
184
+ session. Agents use `ligeti config` instead of reading `.env` ([ADR-0028](../../adr/0028-env-vars-are-secret-or-public-and-ligeti-config-never-shows-a-secret.md)).
185
+ In a checkout of this repository `ligeti` is not on `PATH`: run it as `pnpm ligeti config …`.
186
+
187
+ | Command | Does |
188
+ | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
189
+ | `ligeti config` | One line per known variable: name, source and value. A secret shows only `set`, or nothing when it is unset. |
190
+ | `ligeti config get <NAME>` | A public variable's value; for a secret or an unknown name only `set`. Exits `1` when the variable is unset. |
191
+ | `ligeti config set <NAME> <VALUE>` | Writes a public variable to `.env` after validating it against its settings schema. |
192
+ | `ligeti config set <NAME>` | For a secret: prompts on the terminal with echo off, or reads stdin when it is not a terminal (one trailing newline is stripped). |
193
+ | `ligeti config set --force <NAME>` | Sets a name `ligeti config` does not know, as a secret. |
194
+ | `ligeti config unset <NAME>` | Removes the variable's line from `.env`. |
195
+
196
+ A variable is _secret_ or _public_; one whose sensitivity is unknown is a secret. A secret's value is
197
+ never printed and never accepted on the command line, so it cannot land in shell history or a process
198
+ listing. The known variables are the shell's own and those declared in the manifest of every workflow
199
+ in `LIGETI_WORKFLOWS` with their `configuredBy` settings, which are public; a variable the shell
200
+ derives for each worker, such as `LIGETI_CALLBACK_KEY`, is not known. A workflow that cannot be
201
+ described is reported on stderr and skipped. `LIGETI_CONFIG_DIR` is listed as the process environment
202
+ has it and cannot be set: it locates `.env`, so a `LIGETI_CONFIG_DIR` line in `.env` is reported as
203
+ having no effect.
204
+
205
+ The source column is `process env`, `.env`, `default` or `unset`. The process environment wins over
206
+ `.env`, as it does when the shell starts, and a variable set in both says
207
+ `process env (overrides .env)`; `set` and `unset` warn in that case. `ligeti config` parses `.env`
208
+ itself and never loads it into the process environment.
209
+
210
+ `set` and `unset` rewrite `.env` atomically: every other line and comment stays, a value that needs
211
+ quoting is quoted, and the file keeps its mode (a new file gets `0600`, in a config directory that `set`
212
+ creates with `0700`). They take effect on the next
213
+ shell restart. Exit codes: `0` success, `1` a value that does not validate or a variable that is
214
+ unset, `2` a usage error, an unknown name without `--force`, or a secret given on the command line.
215
+
216
+ ```sh
217
+ ligeti config set LIGETI_PORT 8200
218
+ printf '%s' "$TOKEN" | ligeti config set GITLAB_TOKEN
219
+ ```
220
+
221
+ `.env` is `$LIGETI_CONFIG_DIR/.env` when `LIGETI_CONFIG_DIR` is set in the process environment,
222
+ otherwise `.env` in the per-user config directory (the `LIGETI_CONFIG_DIR` row below); a `.env` in the
223
+ working directory is never read. A missing default config directory means no `.env`; `ligeti serve`
224
+ and `ligeti config set` create it with mode `0700`. Every `ligeti` command that loads `.env`
225
+ resolves it the same way, and relative paths in the shell's settings, whether set in `.env` or in
226
+ the process environment, resolve against the directory holding it.
227
+
228
+ ## `ligeti --version / plugin install / pre-push`
229
+
230
+ `ligeti --version` prints one line per installed package, read from its `package.json`, and exits `0`:
231
+
232
+ ```
233
+ @ligeti/shell 1.2.0
234
+ @ligeti/sdk 2.3.0 (major 2)
235
+ @ligeti/attest 2.0.3
236
+ ```
237
+
238
+ `ligeti plugin install [--yes]` registers the share directory as the `ligeti` Claude Code
239
+ marketplace with the `claude` CLI and installs the `ligeti` plugin for the user; the plugin is active
240
+ in the next Claude Code session. It fails when `claude` is not on `PATH`. Running it again is the
241
+ fix for a stale path. When a `ligeti` marketplace is already registered somewhere else, it prints both
242
+ locations, warns that replacing it uninstalls the `ligeti` plugin with its saved options and data, and
243
+ asks `Replace it? [y/N]`: anything but `y` exits `1` and changes nothing. Without a terminal it fails
244
+ the same way unless `--yes` is given.
245
+
246
+ `ligeti pre-push [<remote> <url>]` runs the share directory's `scripts/pre-push-gate.sh` through `bash`
247
+ with git's arguments and standard input, and exits with its status. It runs in the caller's
248
+ environment, with `LIGETI_GATE_ATTEST_CLI` and `LIGETI_GATE_LIGETI_CLI` set to the installed
249
+ `ligeti-attest` and `ligeti` CLIs, `LIGETI_GATE_NODE` to the node running `ligeti`, and
250
+ `LIGETI_GATE_BASE_URL` to the shell's base URL, resolved as for the other HTTP commands from the
251
+ caller's environment and then `.env`. Nothing else from `.env` reaches the gate. A SIGINT or SIGTERM
252
+ is forwarded to the gate, and a gate killed by a signal makes `ligeti pre-push` exit with 128 plus
253
+ the signal number. A target repository's `pre-push` hook is
254
+ `exec ligeti pre-push "$@"` (see [`docs/attestation.md`](../../docs/attestation.md)).
255
+
256
+ The **share directory** is the repository root in a checkout (the directory two levels above this
257
+ package holds `.claude-plugin/marketplace.json`), and the package's own `share/` folder when
258
+ installed. `share/` is built by the package's `prepack` script, and holds the marketplace file, the
259
+ `plugins/ligeti` plugin with its symlinks resolved, and the two gate scripts.
260
+
261
+ ## Cron entries
262
+
263
+ `ligeti serve` reads the cron file (`LIGETI_CRON_FILE`, default `cron.yaml` in the config directory) and applies
264
+ each entry as a DBOS schedule, so any configured workflow can run on a cron. The default path may be
265
+ absent, which means no cron entries; a file named explicitly by `LIGETI_CRON_FILE` that is absent,
266
+ or a file that is present but invalid, fails startup, naming the file or the entry at fault. The file
267
+ is a map from a free-text entry name to its entry:
268
+
269
+ ```yaml
270
+ <entry name>:
271
+ workflow: <name of a configured workflow>
272
+ schedule: "<cron expression>"
273
+ timezone: <IANA time zone name> # optional, defaults to the shell's time zone
274
+ input: # optional, defaults to {}
275
+ <field>: <value>
276
+ ```
277
+
278
+ Entries are strict: an unknown key, a blank name or one longer than 100 characters, a workflow that is not configured, an input that
279
+ does not match that workflow's input schema, or an invalid cron expression is rejected at startup.
280
+ An entry's cron expression is read in its `timezone` when it sets one, otherwise in the shell's own time
281
+ zone, which is `TZ` normalised to an IANA name: a leading `:` is dropped, a `.../zoneinfo/[posix/|right/]X` path
282
+ becomes `X`, and the case is canonicalised. `TZ` unset, or naming the host's zone file (`:/etc/localtime`),
283
+ means the zone the shell process itself resolves. Any other `TZ` that is not an IANA name (`CET-1CEST`, an
284
+ offset like `+01:00`, empty) never stops the shell from starting; startup fails only when an entry has no
285
+ `timezone`, and the error names `TZ`. The normalised name is also the `TZ` every worker and gate child gets
286
+ (an unnormalisable `TZ` is passed on unchanged). An entry's own `timezone` must be an IANA name too; an offset
287
+ is rejected. The stored schedule names its zone explicitly, and the shell logs it with each applied entry;
288
+ changing a zone changes the stored schedule the next time the file is applied.
289
+ A local time that does not exist on a daylight-saving change day is skipped, and one that occurs twice runs
290
+ twice, as with ordinary cron. An entry in a zone other than the shell's can also miss or repeat a run on
291
+ the days either zone changes its clocks.
292
+ Each schedule enqueues onto the `runs` queue of the workflow's own application with the entry's
293
+ `input` as the run's input, and does not backfill runs missed while the shell was down.
294
+
295
+ `ligeti cron check [<file>]` runs the same validation without serving, and prints one line per
296
+ problem, each starting with the file's path. Without `<file>` it checks the file the cron file
297
+ settings name; with it, that file, and a file that cannot be read is a problem, except the default
298
+ `cron.yaml`, which may be absent. The file's structure -- its shape, each entry's keys and name, and
299
+ the cron expression -- is checked offline. That each workflow is configured and not `blocked`, and
300
+ that each input matches the workflow's input schema (the one the running worker registered, which can differ from what the next `serve` reads from disk if the workflow changed since), come from the running shell (`--url`, as for the
301
+ other commands); a workflow that has not registered yet has its input left unchecked, with a notice
302
+ on stderr, and a shell that cannot be reached skips these checks with a notice. The exit code is `0`
303
+ when there is no problem, `1` when there is any, and `2` for a usage error.
304
+
305
+ Startup validates every entry, cron expression included, before it changes any schedule, and applies
306
+ all entries in one transaction, so an invalid entry leaves the stored schedules as they were.
307
+ Applying is idempotent: restarting re-applies every entry, updating a changed one in place. An entry
308
+ moved to another workflow replaces the schedule its old workflow owned. An entry removed from the
309
+ file has its schedule deleted at the next startup, so it stops firing -- and so does every schedule
310
+ of a configured workflow when the file is empty. Only schedules owned by a Ligeti
311
+ application (`wf:<workflow>`) are deleted or moved; another application's, and unclaimed ones, are
312
+ left alone, so an entry named like a schedule that belongs to another application fails startup,
313
+ naming the entry and the application that owns it.
314
+
315
+ The Cron runs tab (`GET /cron-runs`) lists the configured entries with the time zone each is read in and when each last fired, then the
316
+ runs the schedules started -- the root runs whose id starts with `sched-` -- in the Runs tab's table,
317
+ with the same `?page=` pagination. They do not appear on the Runs tab.
318
+
319
+ ## Environment variables
320
+
321
+ Parsed by `src/settings.ts` through Zod, per
322
+ [ADR-0003](../../adr/0003-configuration-is-a-settings-module.md).
323
+
324
+ | Variable | Required | Default | Purpose |
325
+ | -------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
326
+ | `LIGETI_CONFIG_DIR` | no | unset (`~/Library/Application Support/ligeti` on macOS, else `$XDG_CONFIG_HOME/ligeti` or `~/.config/ligeti`) | Config directory: holds `.env`, `cron.yaml`, the attest key. Process env only, never `.env`; a relative path resolves against the cwd. |
327
+ | `LIGETI_DATABASE_URL` | yes | — | Postgres connection URL shared with every worker. |
328
+ | `LIGETI_CALLBACK_SECRET` | yes | — | At least 32 characters. Verifies callback tokens delivered to `POST /callbacks/:token`. |
329
+ | `LIGETI_PUBLIC_BASE_URL` | no | `http://<LIGETI_HOST>:<LIGETI_PORT>`, with `127.0.0.1` for a wildcard or unusable host | The shell's own externally reachable base URL, embedded in callback/approval URLs. Set it behind a proxy. |
330
+ | `LIGETI_HOST` | no | `127.0.0.1` | Interface the HTTP server binds to. |
331
+ | `LIGETI_PORT` | no | `8100` | Port the HTTP server listens on. |
332
+ | `LIGETI_WORKFLOWS` | no | default workflows (`attest-and-publish`, `small-factory`, `launch-small-factory`, `github-small-factory`, `launch-github-small-factory`), dependencies of the shell. | Comma-separated workflow package directories; replaces the default list. Relative paths resolve against the directory holding `.env`. |
333
+ | `LIGETI_ARGUS_URL` | no | unset | Optional dbos-argus URL, surfaced to the UI. |
334
+ | `LIGETI_STATE_DIR` | no | `<config directory>/state` with `LIGETI_CONFIG_DIR`; else `~/Library/Application Support/ligeti/state` (macOS) or `${XDG_STATE_HOME:-~/.local/state}/ligeti` | State directory, shared with every worker; created with mode `0700`. Relative paths resolve against the directory holding `.env`. |
335
+ | `XDG_CONFIG_HOME` / `XDG_STATE_HOME` | no | unset | On Linux, the base of the default config / state directory. Ignored on macOS and when not absolute; process env only, never `.env`. |
336
+ | `LIGETI_CRON_FILE` | no | `cron.yaml` in the config directory | Cron entries applied at `serve` startup; the default may be absent, a named file may not (see Cron entries). A relative path resolves against `.env`'s dir. |
337
+ | `TZ` | no | the system time zone | The time zone cron entries are read in unless they set their own `timezone` (see Cron entries). Normalised to an IANA name (see Cron entries); also forwarded to workers in that form. |
338
+ | `LIGETI_SUPERVISOR_INITIAL_BACKOFF_MS` | no | unset (Supervisor's own default) | Test-only escape hatch (see below); not meant for production tuning. |
339
+ | `LIGETI_ATTEST_SECRET` | no* | unset | At least 32 characters. Signing secret for `POST /attest`. |
340
+ | `LIGETI_ATTEST_KEY_FILE` | no* | unset | Path to the attestation signing key file. |
341
+ | `LIGETI_STEP_<NAME>_ENV` | no | unset | A step's own setting, e.g. `LIGETI_STEP_UAT_ENV`: comma-separated env var names the shell also forwards (see below). |
342
+
343
+ `*` `LIGETI_ATTEST_SECRET` and `LIGETI_ATTEST_KEY_FILE` must be set together or not at all —
344
+ setting only one fails startup, since attestation is either fully configured or fully disabled,
345
+ never half-configured.
346
+
347
+ `LIGETI_SUPERVISOR_INITIAL_BACKOFF_MS` is passed straight through to the Supervisor's own
348
+ `timings.initialBackoffMs`; unset keeps the Supervisor's default. It exists for tests that need a
349
+ worker _not_ to respawn within some observation window — for example an acceptance test proving that
350
+ cleanup came from the reaper, not from a just-restarted worker. That is why `.env.example` does not
351
+ list it.
352
+
353
+ `LIGETI_CALLBACK_SECRET` stays in the shell's own process and is never placed in a spawned worker's
354
+ environment. Each worker instead receives `LIGETI_CALLBACK_KEY`, derived from it per worker, so a
355
+ worker can mint and verify its own callback tokens without holding the secret they are derived
356
+ from. `src/child-env.ts` derives it; `packages/sdk`'s `settings.ts` is what reads it back.
357
+
358
+ ## Installing a third-party workflow package
359
+
360
+ A workflow package published to an npm registry is installed outside the Ligeti repository and
361
+ added to `LIGETI_WORKFLOWS`.
362
+
363
+ 1. Pick an install directory outside the repository, e.g. `~/.ligeti/workflows/`. Put a
364
+ `package.json` in it that pins the workflow package at an exact version (`"1.2.3"`, not a range):
365
+
366
+ ```json
367
+ {
368
+ "private": true,
369
+ "dependencies": { "@acme/workflow-example": "1.2.3" }
370
+ }
371
+ ```
372
+
373
+ 2. If your own scopes live on a private registry, put an `.npmrc` next to it that maps each scope
374
+ to its registry, with the token given as an `${ENV_VAR}` reference and never as a literal.
375
+ `@ligeti/*` packages come from npmjs.org and need no mapping:
376
+
377
+ ```text
378
+ @acme:registry=https://registry.example.com/npm/
379
+ //registry.example.com/npm/:_authToken=${ACME_REGISTRY_TOKEN}
380
+ ```
381
+
382
+ 3. Run `npm install` there, with any token variables your own scopes need set.
383
+ 4. Add the installed package directory, `<install dir>/node_modules/<package name>`, to
384
+ `LIGETI_WORKFLOWS` with `ligeti config set LIGETI_WORKFLOWS <list>`, as absolute paths: `~` is
385
+ not expanded, so write out the home directory. Setting it replaces the default list, so list
386
+ every workflow package you want the shell to run. Run `ligeti config get LIGETI_WORKFLOWS` first
387
+ to see the current list.
388
+ 5. Restart the shell.
389
+
390
+ The workflow package's installed `@ligeti/sdk` major version must equal the shell's, or the shell
391
+ fails at startup. A Ligeti upgrade that bumps the SDK major version therefore requires reinstalling
392
+ a matching workflow package version.
393
+
394
+ To upgrade, run `npm install --save-exact <package>@<version>` in the install directory and restart
395
+ the shell.
396
+ Per [ADR-0016](../../adr/0016-the-dbos-sdk-version-is-pinned.md), the version
397
+ guard refuses to start a worker over parked runs of a different code hash, so drain or cancel
398
+ those runs first.
399
+
400
+ ## What reaches a worker
401
+
402
+ `src/child-env.ts` builds every child's environment from an explicit list, per
403
+ [ADR-0027](../../adr/0027-steps-declare-env-var-requirements.md). A worker and the reaper that
404
+ cleans up its runs get the SDK's base list, every `LIGETI_*` variable and the env vars the workflow
405
+ declares, computed from the manifest: its own declaration, its steps' and its child workflows'. A
406
+ step's `configuredBy` setting, a `LIGETI_STEP_<NAME>_ENV` variable in the shell's environment,
407
+ adds the names it lists as optional; a value that is not a comma-separated list of env var names
408
+ fails startup. `ligeti-worker describe` gets the base list only.
409
+
410
+ The shell's own `LIGETI_ATTEST_SECRET`, `LIGETI_ATTEST_KEY_FILE`, `LIGETI_CALLBACK_SECRET`,
411
+ `LIGETI_DATABASE_URL` and the keys derived from them are never forwarded, whatever a workflow
412
+ declares (`SHELL_ENV_DENYLIST`), nor is `LIGETI_TEST_DATABASE_URL`; the shell sets each worker's
413
+ database URL and derived keys itself.
414
+
415
+ A required env var that is unset or empty in the shell's environment, or on the denylist, blocks the
416
+ worker: it is not spawned and not retried, and `/workers` shows it as `blocked` with the missing
417
+ names. Fix the environment and restart the shell.
@@ -0,0 +1,28 @@
1
+ <!-- ABOUTME: Operator-facing recovery procedures for problems that show up while running Ligeti, -->
2
+ <!-- ABOUTME: as opposed to design rationale, which lives in adr/ and the rest of docs/. -->
3
+
4
+ # Troubleshooting
5
+
6
+ ## Blocked worker (version guard)
7
+
8
+ A worker refuses to start (`state: blocked`, exit code 78) if its `codeHash` (source, non-`dist/`
9
+ published files, and dependency versions -- see `computeCodeHash`) has changed while a run for
10
+ that workflow is still parked mid-flight: resuming it under different code could replay a step
11
+ non-deterministically. `ligeti serve`'s own stderr names the parked run ids; the Workers tab
12
+ (at `/workers`) also shows `blocked` for that workflow. See
13
+ [ADR-0016](../adr/0016-the-dbos-sdk-version-is-pinned.md) for why the guard exists.
14
+
15
+ **A blocked worker only ever retries on a `ligeti serve` restart** -- it never polls or
16
+ self-heals in the background, so leaving it blocked and waiting accomplishes nothing.
17
+
18
+ To recover:
19
+
20
+ 1. Inspect the parked run ids listed in `ligeti serve`'s stderr (or on the Workers tab).
21
+ 2. Either:
22
+ - **Revert the code change** and restart `ligeti serve` (`Ctrl-C`, then `pnpm serve` again)
23
+ -- the parked runs resume where they left off, or
24
+ - **Cancel those runs** from each run's page (accepting that they will not resume) and restart
25
+ `ligeti serve` -- the worker starts cleanly against the new code.
26
+
27
+ There is currently no good way out of a version-guard block beyond one of those two options; GitLab
28
+ issue [#21](https://gitlab.com/nagyv-projects/ligeti/-/issues/21) tracks that gap.
@@ -0,0 +1,93 @@
1
+ # Rules for a Ligeti workflow or step package
2
+
3
+ The rules an outside author most often breaks, condensed from Ligeti's own `CLAUDE.md`. Each links
4
+ the architecture decision record that owns it; the record, not this file, is the home of the rule
5
+ and has the argument and the exceptions. `@ligeti/eslint-plugin` enforces most of them: the
6
+ templates' `eslint.config.js` turns the presets on, and `pnpm lint` fails on a breach.
7
+
8
+ ADR links go to `https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/`.
9
+
10
+ ## Workflow packages
11
+
12
+ - **A workflow body is deterministic.** Inside `run`, no `fs`, no `child_process`, no
13
+ `process.env`, no `Date.now()` or `Math.random()`, no `fetch`, and no `try`/`catch`. Reach the
14
+ outside world through a step, and the clock and randomness through `ctx.now()` and `ctx.uuid()`.
15
+ Start steps concurrently only where their start order is the same on every replay. To react to a
16
+ failed child workflow use `ctx.child(...).outcome()`, not `catch`.
17
+ [ADR-0002](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0002-workflow-bodies-are-deterministic.md)
18
+ - **A workflow's schema lives in its code.** Input and output are Zod schemas on `defineWorkflow`;
19
+ the manifest is generated from them, never written by hand. Every output carries a `runOutcome`,
20
+ and a run that returns ends with a `done` status carrying the same value.
21
+ [ADR-0013](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0013-a-workflows-schema-lives-in-its-code.md)
22
+
23
+ ## Workflow and step packages
24
+
25
+ - **`process.env` is read in `settings.ts` only**, through a Zod schema, behind a
26
+ `load<X>Settings(env: NodeJS.ProcessEnv = process.env)` function. Production never passes `env`;
27
+ tests always do. Every settings field carries a sensitivity (`secret` or `public`), and
28
+ `ligeti config` never shows a secret.
29
+ [ADR-0003](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0003-configuration-is-a-settings-module.md),
30
+ [ADR-0028](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0028-env-vars-are-secret-or-public-and-ligeti-config-never-shows-a-secret.md)
31
+ - **A step declares its env var requirements.** `envVars: { required, optional, public, configuredBy }`
32
+ is mandatory on `defineStep` and `defineResourceStep` (`{}` is a valid declaration). The shell
33
+ forwards a worker exactly the union its steps declare, and a step gives a spawned process only
34
+ what it declared, built with `buildSpawnEnv`. A test with `settingsEnvVarProblems` from
35
+ `@ligeti/sdk/testing` keeps `settings.ts` and `envVars` in step.
36
+ [ADR-0027](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0027-steps-declare-env-var-requirements.md)
37
+ - **Spawn with an argv array and an environment you built.** Never `exec`, never `shell: true`, never
38
+ the parent's environment forwarded wholesale. A bounded `execFile` call passes an explicit
39
+ `timeout`.
40
+ [ADR-0004](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0004-child-processes-take-argv-and-an-explicit-environment.md)
41
+ - **Log through the contextual logger** (`sctx.logger` in a step). Never `console`.
42
+ [ADR-0011](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0011-logging-goes-through-the-contextual-logger.md)
43
+
44
+ ## Step packages
45
+
46
+ - **A step throws on failure.** Do not invent a `{ ok: false }` return. Wrap the cause in an
47
+ `Error` with `{ cause }`; a named `Error` subclass is for a caller that must `instanceof` it.
48
+ [ADR-0005](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0005-steps-throw-results-are-for-expected-traffic.md)
49
+ - **Every step declares `retry`, and a step with a side effect makes it safe to repeat.** There is
50
+ no default retry, and a step may be retried or replayed from a checkpoint. A step that only reads
51
+ takes a few attempts. A step that creates something outside Ligeti (a process, a remote job) is a
52
+ `defineResourceStep`, whose reserve, find-or-spawn and finalize sequence the SDK implements once.
53
+ A plain step whose effect would repeat makes the effect idempotent itself or sets
54
+ `retry: { maxAttempts: 1 }`.
55
+ [ADR-0015](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0015-resource-steps-are-idempotent-and-steps-declare-retry.md)
56
+ - **A step package exports through one `src/index.ts` barrel**, with named exports only. A workflow
57
+ package's `src/workflow.ts` is its one entry and the one file with a default export
58
+ (`export default defineWorkflow({...})`). Object shapes are `interface`s; `type` is for
59
+ `z.infer<>` aliases and unions.
60
+ [ADR-0009](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0009-module-and-file-conventions.md)
61
+
62
+ ## Tests
63
+
64
+ - **Never `vi.mock`.** A test double is a real executable or a real local server that the code under
65
+ test reaches over its actual interface (argv, exit code, stdout, a socket), redirected through an
66
+ environment variable or an injected URL. `@ligeti/testing` ships real doubles for `claude`, `herdr`,
67
+ GitLab, GitHub, Bitbucket, Jira and Telegram, and a throwaway Postgres.
68
+ [ADR-0007](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0007-test-doubles-are-real-processes.md)
69
+ - **A business rule is a Gherkin `Rule:` with `Example:`s** in a `.feature` file next to the test
70
+ that runs it, through `@amiceli/vitest-cucumber`, not a comment or prose.
71
+ [ADR-0021](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0021-requirements-live-in-feature-files-comments-are-allowlisted.md)
72
+
73
+ ## Files and comments
74
+
75
+ - **Every source file starts with two `// ABOUTME:` lines** saying what the file does.
76
+ [ADR-0009](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0009-module-and-file-conventions.md)
77
+ - **A code comment is only ever** the two `ABOUTME:` lines, a tool directive that states its reason
78
+ (`eslint-disable… -- <reason>`, `@ts-expect-error -- <reason>`), or `QUIRK(<tool>): <one sentence> <URL>`
79
+ for behaviour of an external tool that no name, type or test can express. Everything else goes where it belongs:
80
+ what a block does becomes a named function, what a field means becomes a Zod `.describe()`, why a
81
+ step is safe to retry becomes a test named after the reason, a rule becomes a `.feature` file.
82
+ The `ligeti/no-comments` lint rule enforces it.
83
+ [ADR-0021](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0021-requirements-live-in-feature-files-comments-are-allowlisted.md)
84
+ - **Every package has a `README.md`** stating what it is, what it exposes (inputs and output, or
85
+ steps), and its environment variables as a table or "None.".
86
+ [ADR-0021](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0021-requirements-live-in-feature-files-comments-are-allowlisted.md)
87
+
88
+ ## Where the package lives
89
+
90
+ - **A workflow made for one product lives in that product's repository** and is installed into
91
+ Ligeti as a third-party workflow package. `@ligeti/*` packages are public contracts, so depend on
92
+ a major you can accept and expect a breaking change only in a major.
93
+ [ADR-0025](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0025-published-packages-are-public-contracts-product-workflows-live-in-their-product.md)