@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,147 @@
1
+ ---
2
+ name: authoring-steps
3
+ description: Use when creating a Ligeti step package in the author's own repository: copying the template, choosing between a plain step and a resource step, declaring retry, settings and env vars, and testing it against a real process double.
4
+ ---
5
+
6
+ # Authoring a step package
7
+
8
+ This skill is written for **`@ligeti/sdk` major 2**. You work **in the author's repository**, not in
9
+ Ligeti. A step reaches the shell only as a dependency of a workflow package, so the outcome is a
10
+ step package that a workflow package imports (`authoring-workflows`).
11
+
12
+ Read `${CLAUDE_PLUGIN_ROOT}/references/rules.md` before you write any code and follow it; each rule
13
+ links the decision record that owns it. `@ligeti/eslint-plugin` enforces most of them.
14
+
15
+ ## Do not
16
+
17
+ - Never read `.env`; configure only through `ligeti config`.
18
+ - Never read `process.env` outside `settings.ts`, spawn with `exec` or `shell: true`, or log with
19
+ `console`.
20
+ - Never return `{ ok: false }` for a failure; throw.
21
+ - Never mock a module in a test (`vi.mock`); use a real executable or a local server.
22
+ - Do not leave a `workspace:*` version in the copied `package.json`.
23
+
24
+ ## 1. Check the SDK major
25
+
26
+ ```sh
27
+ node -p "require('./node_modules/@ligeti/sdk/package.json').version" # in the project, once installed
28
+ ligeti --version # the shell's own SDK
29
+ ```
30
+
31
+ `ligeti --version` prints a line like `@ligeti/sdk 2.3.0 (major 2)`. If either major is not 2, stop
32
+ and report the mismatch: the template and this skill describe major 2. Do not guess at an API of
33
+ another major.
34
+
35
+ ## 2. Copy the template
36
+
37
+ ```sh
38
+ rsync -a --exclude node_modules --exclude dist --exclude '*.tsbuildinfo' \
39
+ "${CLAUDE_PLUGIN_ROOT}/templates/step/" <package-directory>/
40
+ ```
41
+
42
+ Then, in the copy:
43
+
44
+ 1. **Rename it.** In `package.json` set `name`, `version`, `description` and `license`, drop
45
+ `"private": true` if it will be published, and add `repository`. Rename `template.tool-version`
46
+ (the step's `name` is `<package>.<action>`, unique across the workflow's steps), the file, the
47
+ `.feature` file and the words `template` and `TEMPLATE` in the settings, tests and README.
48
+ 2. **Replace its `workspace:*` dependencies.** Remove each from `package.json`, then add it from the
49
+ registry:
50
+
51
+ ```sh
52
+ node -e 'const fs=require("fs");const p=JSON.parse(fs.readFileSync("package.json"));for(const k of ["dependencies","devDependencies","peerDependencies"])for(const n of Object.keys(p[k]??{}))if(p[k][n].startsWith("workspace:"))delete p[k][n];fs.writeFileSync("package.json",JSON.stringify(p,null,2)+"\n")'
53
+ pnpm add --save-peer @ligeti/sdk
54
+ pnpm add -D @ligeti/eslint-plugin
55
+ ```
56
+
57
+ The step lists `@ligeti/sdk` as a peer dependency, so that every step in a workflow shares the
58
+ workflow's one SDK; `--save-peer` also adds it as a dev dependency, to build and test against.
59
+ Add `@ligeti/testing` with `pnpm add -D` if the tests use its doubles.
60
+
61
+ 3. **Ignore the output**: `node_modules`, `dist` and `*.tsbuildinfo` in `.gitignore`. The copy's
62
+ `tsconfig.json`, `tsconfig.build.json` and `eslint.config.js` are self-contained.
63
+ 4. **Build once**: `pnpm install && pnpm build`.
64
+
65
+ ## 3. Choose the kind of step
66
+
67
+ Both are in `@ligeti/sdk`; both require `name`, `input`, `output`, `envVars` and `retry`.
68
+
69
+ | | `defineStep` | `defineResourceStep` |
70
+ | ----------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
71
+ | It is | an idempotent, checkpointed unit of work: call an API, run a subprocess, write a file | something longer-lived that exists outside Ligeti and must be closed: an agent process, a remote job |
72
+ | You write | `run(sctx, input)` | `spawn`, `find` and `close`; optionally a `callbackPayload` schema |
73
+ | The SDK adds | checkpointing and output validation | the same, plus reserve, find-or-spawn and finalize once per resource key, and `close` when the run ends, fails or is cancelled |
74
+ | `ctx.run` returns | the output | a `ResourceRef` (`resourceKey`, `output`), which `ctx.waitForCallback` and `ctx.close` take |
75
+
76
+ Use `defineStep` unless the step starts something that must not be started twice and must be
77
+ released afterwards. For a resource step, `handle` must be unique across resource keys and attempts,
78
+ and `find` must rebuild the same handle and output `spawn` returned, from the resource key alone
79
+ (the reaper calls it with no live run). Read `${CLAUDE_PLUGIN_ROOT}/references/rules.md` for the
80
+ record, and `node_modules/@ligeti/sdk` for the exact types.
81
+
82
+ ## 4. Retry and idempotency
83
+
84
+ `retry` is required; there is no default
85
+ ([ADR-0015](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0015-resource-steps-are-idempotent-and-steps-declare-retry.md)).
86
+
87
+ - A step that only reads: `retry: { maxAttempts: 3, intervalSeconds: 2 }`, optionally with
88
+ `backoffRate`.
89
+ - A step with a side effect must be safe to run twice, because a retry or a replay after a crash
90
+ runs it again: an idempotency key on the API call, a write-once file, a check before the write.
91
+ When that is not possible, `retry: { maxAttempts: 1 }`, and say so in the README.
92
+ - Something paid or non-repeatable, started by the step, is a resource step.
93
+ - Name the reason a step is safe to repeat in a test (`it("is safe to retry because ...")`), not a
94
+ comment.
95
+
96
+ ## 5. Settings and env vars
97
+
98
+ - **`src/settings.ts`** is the only file that reads `process.env`
99
+ ([ADR-0003](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0003-configuration-is-a-settings-module.md)).
100
+ `defineSettingsSchema({...})` takes a Zod field per variable, each marked
101
+ `.meta({ sensitivity: "public" })` or `"secret"`, and `load<X>Settings(env = process.env)` parses
102
+ it and throws one `Error` listing every failing key. Tests pass `env`; production never does.
103
+ - **`envVars`** declares what the step needs
104
+ ([ADR-0027](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0027-steps-declare-env-var-requirements.md)):
105
+ `required` (the worker does not start without it), `optional`, `public` (the subset whose value
106
+ is not secret), and at most one `configuredBy: "LIGETI_STEP_<NAME>_ENV"` whose comma-separated
107
+ value lists more optional names, read in `settings.ts` through `envVarNameList`. `{}` is valid.
108
+ Every settings field belongs in a declaration with the same sensitivity; the template's
109
+ `test/settings.test.ts` checks that with `settingsEnvVarProblems` from `@ligeti/sdk/testing`.
110
+ - **Spawning** a process: an argv array, never `shell: true`, an explicit `timeout`, the step's
111
+ `sctx.signal`, and an environment from `buildSpawnEnv(envVars, { logger: sctx.logger })`, which
112
+ gives the process the SDK's base list and the declared names only. Log through `sctx.logger`.
113
+ - Document the variables in the README as a table, with their defaults and sensitivity.
114
+
115
+ ## 6. Test with real doubles
116
+
117
+ ```sh
118
+ pnpm build && pnpm typecheck && pnpm lint && pnpm test
119
+ ```
120
+
121
+ - A double for an external tool is **a real executable** the step spawns, written by the test to a
122
+ throwaway directory and chosen through the step's setting (`LIGETI_TEMPLATE_TOOL_BIN` in the
123
+ template); a double for a service is a local HTTP server on a real port, with its base URL taken
124
+ from a setting. `@ligeti/testing` already has real doubles for `claude`, `herdr`, GitLab, GitHub,
125
+ Bitbucket, Jira and Telegram
126
+ ([ADR-0007](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0007-test-doubles-are-real-processes.md)).
127
+ - State each rule as a `Rule:` with `Example:`s in `test/<name>.feature`, run by `test/rules.test.ts`
128
+ through `@amiceli/vitest-cucumber`, as the template does. Include the failure examples: a step
129
+ throws, so each is a test that it throws with a message naming the cause.
130
+ - Test that the spawned process sees only declared variables, as the template's last example does.
131
+ - Run the step directly, `step.run(sctx, input)`, with a minimal `StepContext` (`workflowId`,
132
+ `stepId`, `stepName`, `signal`, and a `logger` with `debug`, `info`, `warn` and `error`).
133
+
134
+ ## 7. Export and document
135
+
136
+ - `src/index.ts` is the package's one barrel: named exports of each step and its input and output
137
+ schemas, and nothing else. `package.json` `exports["."]` points at the built `dist/index.js`.
138
+ - Give each step `package: { name: pkg.name, version: pkg.version }` so the manifest attributes it
139
+ to this package, and a `description`.
140
+ - The README states the package's steps, each step's inputs and output, its retry behaviour, and its
141
+ environment variables.
142
+
143
+ ## Next
144
+
145
+ Use the step from a workflow package with `authoring-workflows`. A workflow gets a new step version
146
+ only when its own repository bumps the dependency, rebuilds, refreshes its manifest snapshot and
147
+ publishes a new workflow version; `installing-workflows` covers upgrading the install.
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: authoring-workflows
3
+ description: Use when creating a Ligeti workflow package, from existing steps or with a new step of its own, in the author's own repository: copying the template, choosing steps, writing the workflow, testing and linting it, and making it fit a schedule.
4
+ ---
5
+
6
+ # Authoring a workflow package
7
+
8
+ This skill is written for **`@ligeti/sdk` major 2**, the major of the template's `ligeti.sdk` range
9
+ (`^2.0.0`). You work **in the author's repository**, not in Ligeti. The outcome is a built, tested,
10
+ linted package that the shell can load (`ligeti.entry`).
11
+
12
+ Read `${CLAUDE_PLUGIN_ROOT}/references/rules.md` before you write any code and follow it; each rule
13
+ links the decision record that owns it. `@ligeti/eslint-plugin` enforces most of them.
14
+
15
+ ## Do not
16
+
17
+ - Never read `.env`; configure only through `ligeti config`.
18
+ - Do not put I/O in the workflow body: no `fs`, `child_process`, `process.env`, `Date.now()`, no
19
+ `try`/`catch`. A body that needs one of them needs a step (`authoring-steps`).
20
+ - Do not leave a `workspace:*` version in the copied `package.json`.
21
+
22
+ ## 1. Check the SDK major
23
+
24
+ Find the SDK the author's project uses, and the one their shell runs:
25
+
26
+ ```sh
27
+ node -p "require('./node_modules/@ligeti/sdk/package.json').version" # in the project, once installed
28
+ ligeti --version # the shell's own SDK
29
+ ```
30
+
31
+ `ligeti --version` prints a line like `@ligeti/sdk 2.3.0 (major 2)`. If either major is not 2, stop
32
+ and report the mismatch: the template, `rules.md` and this skill describe major 2, and the shell
33
+ refuses a worker whose `ligeti.sdk` range does not accept its SDK. Do not guess at an API of
34
+ another major.
35
+
36
+ ## 2. Pick the place
37
+
38
+ A workflow made for one product lives in **that product's repository**, as its own package, and is
39
+ installed into Ligeti as a third-party workflow package
40
+ ([ADR-0025](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0025-published-packages-are-public-contracts-product-workflows-live-in-their-product.md)).
41
+ Ask where, if the author has not said (a `workflows/<name>/` directory is typical). A generic
42
+ workflow meant for everyone belongs in Ligeti itself, not here.
43
+
44
+ ## 3. Copy the template
45
+
46
+ Copy without build output or installed dependencies, into the package directory:
47
+
48
+ ```sh
49
+ rsync -a --exclude node_modules --exclude dist --exclude '*.tsbuildinfo' \
50
+ "${CLAUDE_PLUGIN_ROOT}/templates/workflow/" <package-directory>/
51
+ ```
52
+
53
+ Then, in the copy:
54
+
55
+ 1. **Rename it.** In `package.json` set `name`, `version`, `description` and `license`, drop
56
+ `"private": true` if it will be published, and add `repository`. In `src/workflow.ts` set the
57
+ workflow `name` (lowercase letters, digits and `-`) and `description`. Rename the `.feature`
58
+ file and its `loadFeature` call, the `template-workflow` words in the tests and in the README,
59
+ and the README's title. The README's first paragraph says what the workflow does, not what the
60
+ template is.
61
+ 2. **Replace its `workspace:*` dependencies.** Remove each one from `package.json`, then add it from
62
+ the registry so the author gets real version ranges:
63
+
64
+ ```sh
65
+ node -e 'const fs=require("fs");const p=JSON.parse(fs.readFileSync("package.json"));for(const k of ["dependencies","devDependencies","peerDependencies"])for(const n of Object.keys(p[k]??{}))if(p[k][n].startsWith("workspace:"))delete p[k][n];fs.writeFileSync("package.json",JSON.stringify(p,null,2)+"\n")'
66
+ pnpm add @ligeti/sdk @ligeti/step-agent
67
+ pnpm add -D @ligeti/eslint-plugin @ligeti/testing
68
+ ```
69
+
70
+ Add every other `@ligeti/step-*` the workflow uses with `pnpm add`. Check that `ligeti.sdk` in
71
+ `package.json` still accepts the installed `@ligeti/sdk` (`^2.0.0` for major 2).
72
+
73
+ 3. **Make the repository ignore the output**: `node_modules`, `dist` and `*.tsbuildinfo` in
74
+ `.gitignore`. The copy's `tsconfig.json`, `tsconfig.build.json` and `eslint.config.js` are
75
+ self-contained; keep them, or extend them from the repository's own base config if it has one.
76
+ 4. **Build once** so the manifest test can run: `pnpm install && pnpm build`.
77
+
78
+ ## 4. Choose the steps
79
+
80
+ A workflow can only call steps it lists in `steps`. Start from what exists before you write one:
81
+
82
+ - Read the README of each candidate in `node_modules/@ligeti/step-*/README.md`: its steps, their
83
+ inputs and outputs, its retry behaviour and its environment variables. They match the installed
84
+ versions exactly.
85
+ - After `pnpm build`, `pnpm exec ligeti-worker describe .` prints the manifest: each listed step
86
+ with its input and output JSON Schema, and the `envVars` the workflow needs. Run it again after
87
+ each change to `steps`.
88
+ - Every step's `envVars` become the workflow's: tell the author which variables the operator must
89
+ set (`ligeti config`) before the workflow runs, and write them in the README.
90
+ - No existing step does it? Write one with the `authoring-steps` skill, in its own package.
91
+
92
+ ## 5. Write the workflow
93
+
94
+ Keep `src/workflow.ts` the package's one entry, with `export default defineWorkflow({...})`.
95
+
96
+ - Input and output are Zod schemas; describe every field with `.describe()`. The output carries a
97
+ `runOutcome`, and every run that returns ends with `await ctx.status("done", { runOutcome })`.
98
+ - Call steps with `ctx.run(step, input)`; wait for an agent with `ctx.waitForCallback`; a human with
99
+ the `@ligeti/step-human-approval` steps; a child workflow with `ctx.child(...).outcome()`.
100
+ - A rule about what the workflow accepts or does is a `Rule:` with `Example:`s in a `.feature` file,
101
+ run by a `*.test.ts` through `@amiceli/vitest-cucumber`, next to the template's own.
102
+ - Update `README.md`: a table of inputs, the output, the steps used, the environment variables, and
103
+ whether the workflow is meant for a schedule.
104
+
105
+ ## 6. Test and lint
106
+
107
+ ```sh
108
+ pnpm build && pnpm typecheck && pnpm lint && pnpm test
109
+ ```
110
+
111
+ - Test the body with `createFakeContext` from `@ligeti/sdk/testing`: it scripts step outputs and
112
+ callbacks and records every call, so the workflow's own chaining is what is tested.
113
+ - `test/workflow.test.ts` describes the package with a real `ligeti-worker` through
114
+ `describeWorkflowPackage` from `@ligeti/testing` and snapshots the manifest, with `codeHash` and
115
+ `sdkVersion` masked. A change to the input schema, the steps or the package version changes it;
116
+ review the diff, then `pnpm vitest run -u`.
117
+ - Doubles for external tools and services are real executables or local servers, never `vi.mock`.
118
+ `@ligeti/testing` has them for `claude`, `herdr`, GitLab, GitHub, Bitbucket, Jira and Telegram.
119
+ - Lint is `eslint .` with `@ligeti/eslint-plugin`'s presets: a deterministic workflow body, no
120
+ `console`, no module mocks, and only the allowed comments. Fix a finding; do not disable the rule.
121
+
122
+ ## 7. A workflow meant for a schedule
123
+
124
+ A cron entry starts the same input on every tick, so a workflow for a schedule must:
125
+
126
+ - say so in its README, in a sentence the `scheduling-workflows` skill can find ("Meant for a
127
+ schedule: finds its own work on each tick");
128
+ - **find its own work on each tick** instead of taking it from the input: its first step reads the
129
+ outside state (open issues, unread messages, a directory) and the run returns early, with
130
+ `runOutcome` saying nothing was found, when there is none. Ticks missed while the shell is down
131
+ are not backfilled, so the work must not depend on a tick for each period;
132
+ - declare `queue: { concurrency: 1 }` on `defineWorkflow` when two overlapping ticks would conflict
133
+ (they would both pick up the same work, or write the same place). `concurrency` caps how many of
134
+ this workflow's runs execute at once (it becomes DBOS's `globalConcurrency` for the workflow);
135
+ - be cheap when idle: a frequent schedule starts a run per tick, and an agent session per tick if
136
+ the workflow starts agents.
137
+
138
+ ## Next
139
+
140
+ - Installing the package into a shell, and upgrading it: `installing-workflows`.
141
+ - Running it on a schedule: `scheduling-workflows`.
142
+ - Gating pushes to the repository: `onboard`.
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: installing-workflows
3
+ description: Use when installing, upgrading or removing a third-party Ligeti workflow package in a shell, or when a step a workflow uses needs a newer version — a step reaches the shell only as a dependency of a workflow package, so upgrading one is a chain of steps across two repositories.
4
+ ---
5
+
6
+ # Installing, upgrading and removing workflow packages
7
+
8
+ The reference is `${CLAUDE_PLUGIN_ROOT}/docs/shell.md`, section "Installing a third-party workflow
9
+ package". This file is the order to do it in, with the checks that section leaves to you.
10
+
11
+ The shell runs workflow packages listed in `LIGETI_WORKFLOWS`. It never installs anything itself,
12
+ and setting `LIGETI_WORKFLOWS` **replaces** the default list (the five `@ligeti/workflow-*`
13
+ packages the shell depends on), so a new value must list every package you want, defaults
14
+ included.
15
+
16
+ ## Do not
17
+
18
+ - Never read `.env`. Configure only through `ligeti config`.
19
+ - Do not set a secret yourself: ask the operator to run `ligeti config set NAME`, which prompts.
20
+ - Do not restart the shell yourself. Ask the operator to, then check it.
21
+ - Do not use a version range for the workflow package in the install directory; pin an exact one.
22
+
23
+ ## Prechecks
24
+
25
+ 1. **SDK major.** Read the package's `ligeti.sdk` range in its `package.json`
26
+ (`"ligeti": { "kind": "workflow", "sdk": "^2.0.0" }`; for a published package,
27
+ `npm view <package>@<version> ligeti.sdk`). Run `ligeti --version`; it prints a line like
28
+ `@ligeti/sdk 2.3.0 (major 2)`. The range must accept that SDK version. A mismatch makes the worker
29
+ fail at startup; stop and report it instead of installing. A shell upgrade that changes the SDK
30
+ major needs a workflow version built for the new major.
31
+ 2. **No parked runs.** The version guard blocks a worker whose code hash changed while a run of
32
+ that workflow is still parked (ADR-0016; `${CLAUDE_PLUGIN_ROOT}/docs/troubleshooting.md`, "Blocked
33
+ worker"). Installing a package for the first time has none. Before an upgrade, list unfinished
34
+ runs of the workflow:
35
+
36
+ ```sh
37
+ ligeti runs --workflow <name> --status PENDING --status ENQUEUED
38
+ ```
39
+
40
+ If any exist, ask the operator to let them finish or cancel them from each run's page first.
41
+ Never cancel a run on your own.
42
+
43
+ ## Install
44
+
45
+ 1. Ask the operator which directory to install into, outside any Ligeti checkout (for example
46
+ `~/.ligeti/workflows/`). Write out the home directory in any path you put in config: `~` is not
47
+ expanded.
48
+ 2. In it, create a `package.json` that pins the package exactly:
49
+
50
+ ```json
51
+ {
52
+ "private": true,
53
+ "dependencies": { "@acme/workflow-example": "1.2.3" }
54
+ }
55
+ ```
56
+
57
+ One install directory can hold several packages. If the package's scope is on a private
58
+ registry, add an `.npmrc` that maps the scope and takes its token from an `${ENV_VAR}`
59
+ reference, never a literal. `@ligeti/*` comes from npmjs.org and needs no mapping.
60
+
61
+ 3. Run `npm install` there, with any token variable the operator's registry needs set.
62
+ 4. Read the current list with `ligeti config get LIGETI_WORKFLOWS` (it exits `1` when unset, which
63
+ means the defaults apply). Entries are comma-separated absolute directories; the installed
64
+ package is `<install dir>/node_modules/<package name>`. When the list is unset and the operator
65
+ still wants the defaults, they must be listed too, each as the directory of the
66
+ `@ligeti/workflow-*` package the shell resolves; ask the operator for them or where the shell is
67
+ installed rather than guessing. Then:
68
+
69
+ ```sh
70
+ ligeti config set LIGETI_WORKFLOWS /abs/dir/one,/abs/dir/two
71
+ ```
72
+
73
+ 5. Ask the operator to restart `ligeti serve`, and wait for them to say it is up.
74
+ 6. Verify:
75
+
76
+ ```sh
77
+ ligeti workflows
78
+ curl -s -H 'Accept: application/json' "$BASE/workers"
79
+ ```
80
+
81
+ `ligeti workflows` lists the new workflow as `registered`; `not registered` right after a
82
+ restart usually means the worker is still starting. `/workers` (`$BASE` is the shell's base URL:
83
+ `ligeti --url <base>` or `$LIGETI_PUBLIC_BASE_URL`, else `http://<LIGETI_HOST>:<LIGETI_PORT>`)
84
+ answers `{ "workers": [{ "name", "status", "reason?" }] }`; the status must be `running`. A
85
+ `blocked` or `backoff` worker goes to the `troubleshooting` skill and
86
+ `${CLAUDE_PLUGIN_ROOT}/docs/troubleshooting.md`. A missing required env var shows as `blocked`
87
+ with the names; the workflow's README (`<install dir>/node_modules/<package>/README.md`) lists
88
+ them, and `ligeti config` shows which are set.
89
+
90
+ ## Upgrade a workflow package
91
+
92
+ 1. Run both prechecks for the new version.
93
+ 2. In the install directory: `npm install --save-exact <package>@<version>`.
94
+ 3. Ask the operator to restart, then verify as above.
95
+
96
+ ## Remove a workflow package
97
+
98
+ 1. Check for unfinished runs as in the prechecks; removing a package strands them.
99
+ 2. Set `LIGETI_WORKFLOWS` to the list without that directory (every other entry included).
100
+ 3. Remove its cron entries (`scheduling-workflows` skill); a cron entry for an unconfigured
101
+ workflow fails startup.
102
+ 4. Ask the operator to restart, then verify. Deleting the install directory afterwards is optional.
103
+
104
+ ## Upgrade a step
105
+
106
+ A step is an npm package, but the shell loads only workflow packages: a step reaches it as a
107
+ dependency of a workflow. Upgrading a step therefore happens in the **workflow package's own
108
+ repository**, then reaches the shell as a workflow upgrade.
109
+
110
+ 1. In the workflow package's repository, bump the step dependency
111
+ (`pnpm add <step package>@<version>`, or the repository's own package manager) and rebuild.
112
+ 2. Run the package's tests. They compare the workflow's manifest, which embeds each step's input
113
+ schema, with a committed snapshot, so a step that changed its schema fails there. Refresh the
114
+ snapshot with the test runner's update flag (`pnpm vitest run -u` for the examples) and review
115
+ the diff: an input schema change is a change to what callers must send.
116
+ 3. Publish a new workflow version. Its `ligeti.sdk` range must still match the shell's SDK major.
117
+ 4. Run "Upgrade a workflow package" above with that version.
118
+
119
+ A step's own README (`node_modules/<step package>/README.md` in the workflow package) documents its
120
+ settings and env vars; read it when the bump changes them, and set public ones with
121
+ `ligeti config set`.