@ligeti/shell 1.2.0 → 1.4.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/README.md +58 -0
- package/dist/bin-resolve.d.ts +5 -0
- package/dist/bin-resolve.d.ts.map +1 -1
- package/dist/bin-resolve.js +12 -3
- package/dist/bin-resolve.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -3
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/installed-versions.d.ts +9 -0
- package/dist/cli/installed-versions.d.ts.map +1 -0
- package/dist/cli/installed-versions.js +50 -0
- package/dist/cli/installed-versions.js.map +1 -0
- package/dist/cli/plugin.d.ts +13 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +188 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/pre-push.d.ts +12 -0
- package/dist/cli/pre-push.d.ts.map +1 -0
- package/dist/cli/pre-push.js +56 -0
- package/dist/cli/pre-push.js.map +1 -0
- package/dist/cli/share-dir.d.ts +3 -0
- package/dist/cli/share-dir.d.ts.map +1 -0
- package/dist/cli/share-dir.js +13 -0
- package/dist/cli/share-dir.js.map +1 -0
- package/dist/cli/steps.d.ts +16 -0
- package/dist/cli/steps.d.ts.map +1 -0
- package/dist/cli/steps.js +102 -0
- package/dist/cli/steps.js.map +1 -0
- package/dist/cli/version.d.ts +6 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +14 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +36 -4
- package/dist/cli.js.map +1 -1
- package/dist/installed-steps.d.ts +8 -0
- package/dist/installed-steps.d.ts.map +1 -0
- package/dist/installed-steps.js +90 -0
- package/dist/installed-steps.js.map +1 -0
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -0
- package/dist/settings.js.map +1 -1
- package/dist/workers.d.ts +4 -1
- package/dist/workers.d.ts.map +1 -1
- package/dist/workers.js +59 -3
- package/dist/workers.js.map +1 -1
- package/package.json +10 -9
- package/share/.claude-plugin/marketplace.json +14 -0
- package/share/plugins/ligeti/.claude-plugin/plugin.json +6 -0
- package/share/plugins/ligeti/README.md +31 -0
- package/share/plugins/ligeti/docs/attestation.md +590 -0
- package/share/plugins/ligeti/docs/shell.md +442 -0
- package/share/plugins/ligeti/docs/troubleshooting.md +28 -0
- package/share/plugins/ligeti/references/rules.md +93 -0
- package/share/plugins/ligeti/skills/authoring-steps/SKILL.md +149 -0
- package/share/plugins/ligeti/skills/authoring-workflows/SKILL.md +146 -0
- package/share/plugins/ligeti/skills/installing-workflows/SKILL.md +121 -0
- package/share/plugins/ligeti/skills/onboard/SKILL.md +290 -0
- package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.github.yml +66 -0
- package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.yml +69 -0
- package/share/plugins/ligeti/skills/onboard/assets/pre-push.sh +11 -0
- package/share/plugins/ligeti/skills/scheduling-workflows/SKILL.md +102 -0
- package/share/plugins/ligeti/skills/troubleshooting/SKILL.md +94 -0
- package/share/plugins/ligeti/templates/step/.prettierignore +3 -0
- package/share/plugins/ligeti/templates/step/README.md +52 -0
- package/share/plugins/ligeti/templates/step/eslint.config.js +105 -0
- package/share/plugins/ligeti/templates/step/package.json +52 -0
- package/share/plugins/ligeti/templates/step/src/index.ts +3 -0
- package/share/plugins/ligeti/templates/step/src/settings.ts +27 -0
- package/share/plugins/ligeti/templates/step/src/tool-version.ts +61 -0
- package/share/plugins/ligeti/templates/step/test/rules.test.ts +144 -0
- package/share/plugins/ligeti/templates/step/test/settings.test.ts +30 -0
- package/share/plugins/ligeti/templates/step/test/tool-version.feature +32 -0
- package/share/plugins/ligeti/templates/step/tsconfig.build.json +26 -0
- package/share/plugins/ligeti/templates/step/tsconfig.json +21 -0
- package/share/plugins/ligeti/templates/workflow/.prettierignore +3 -0
- package/share/plugins/ligeti/templates/workflow/README.md +56 -0
- package/share/plugins/ligeti/templates/workflow/eslint.config.js +99 -0
- package/share/plugins/ligeti/templates/workflow/package.json +46 -0
- package/share/plugins/ligeti/templates/workflow/src/workflow.ts +72 -0
- package/share/plugins/ligeti/templates/workflow/test/__snapshots__/workflow.test.ts.snap +132 -0
- package/share/plugins/ligeti/templates/workflow/test/rules.test.ts +160 -0
- package/share/plugins/ligeti/templates/workflow/test/template-workflow.feature +31 -0
- package/share/plugins/ligeti/templates/workflow/test/workflow.test.ts +64 -0
- package/share/plugins/ligeti/templates/workflow/tsconfig.build.json +26 -0
- package/share/plugins/ligeti/templates/workflow/tsconfig.json +21 -0
- package/share/scripts/pre-push-gate.sh +308 -0
- package/share/scripts/pre-push-lib.sh +64 -0
|
@@ -0,0 +1,149 @@
|
|
|
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`. Keep the `ligeti` field
|
|
46
|
+
(`"kind": "step"`, `"sdk"`) and the `ligeti-step` keyword: they are how `ligeti steps` and
|
|
47
|
+
`npm search` find the package. Rename `template.tool-version`
|
|
48
|
+
(the step's `name` is `<package>.<action>`, unique across the workflow's steps), the file, the
|
|
49
|
+
`.feature` file and the words `template` and `TEMPLATE` in the settings, tests and README.
|
|
50
|
+
2. **Replace its `workspace:*` dependencies.** Remove each from `package.json`, then add it from the
|
|
51
|
+
registry:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
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")'
|
|
55
|
+
pnpm add --save-peer @ligeti/sdk
|
|
56
|
+
pnpm add -D @ligeti/eslint-plugin
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The step lists `@ligeti/sdk` as a peer dependency, so that every step in a workflow shares the
|
|
60
|
+
workflow's one SDK; `--save-peer` also adds it as a dev dependency, to build and test against.
|
|
61
|
+
Add `@ligeti/testing` with `pnpm add -D` if the tests use its doubles.
|
|
62
|
+
|
|
63
|
+
3. **Ignore the output**: `node_modules`, `dist` and `*.tsbuildinfo` in `.gitignore`. The copy's
|
|
64
|
+
`tsconfig.json`, `tsconfig.build.json` and `eslint.config.js` are self-contained.
|
|
65
|
+
4. **Build once**: `pnpm install && pnpm build`.
|
|
66
|
+
|
|
67
|
+
## 3. Choose the kind of step
|
|
68
|
+
|
|
69
|
+
Both are in `@ligeti/sdk`; both require `name`, `input`, `output`, `envVars` and `retry`.
|
|
70
|
+
|
|
71
|
+
| | `defineStep` | `defineResourceStep` |
|
|
72
|
+
| ----------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
73
|
+
| 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 |
|
|
74
|
+
| You write | `run(sctx, input)` | `spawn`, `find` and `close`; optionally a `callbackPayload` schema |
|
|
75
|
+
| 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 |
|
|
76
|
+
| `ctx.run` returns | the output | a `ResourceRef` (`resourceKey`, `output`), which `ctx.waitForCallback` and `ctx.close` take |
|
|
77
|
+
|
|
78
|
+
Use `defineStep` unless the step starts something that must not be started twice and must be
|
|
79
|
+
released afterwards. For a resource step, `handle` must be unique across resource keys and attempts,
|
|
80
|
+
and `find` must rebuild the same handle and output `spawn` returned, from the resource key alone
|
|
81
|
+
(the reaper calls it with no live run). Read `${CLAUDE_PLUGIN_ROOT}/references/rules.md` for the
|
|
82
|
+
record, and `node_modules/@ligeti/sdk` for the exact types.
|
|
83
|
+
|
|
84
|
+
## 4. Retry and idempotency
|
|
85
|
+
|
|
86
|
+
`retry` is required; there is no default
|
|
87
|
+
([ADR-0015](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0015-resource-steps-are-idempotent-and-steps-declare-retry.md)).
|
|
88
|
+
|
|
89
|
+
- A step that only reads: `retry: { maxAttempts: 3, intervalSeconds: 2 }`, optionally with
|
|
90
|
+
`backoffRate`.
|
|
91
|
+
- A step with a side effect must be safe to run twice, because a retry or a replay after a crash
|
|
92
|
+
runs it again: an idempotency key on the API call, a write-once file, a check before the write.
|
|
93
|
+
When that is not possible, `retry: { maxAttempts: 1 }`, and say so in the README.
|
|
94
|
+
- Something paid or non-repeatable, started by the step, is a resource step.
|
|
95
|
+
- Name the reason a step is safe to repeat in a test (`it("is safe to retry because ...")`), not a
|
|
96
|
+
comment.
|
|
97
|
+
|
|
98
|
+
## 5. Settings and env vars
|
|
99
|
+
|
|
100
|
+
- **`src/settings.ts`** is the only file that reads `process.env`
|
|
101
|
+
([ADR-0003](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0003-configuration-is-a-settings-module.md)).
|
|
102
|
+
`defineSettingsSchema({...})` takes a Zod field per variable, each marked
|
|
103
|
+
`.meta({ sensitivity: "public" })` or `"secret"`, and `load<X>Settings(env = process.env)` parses
|
|
104
|
+
it and throws one `Error` listing every failing key. Tests pass `env`; production never does.
|
|
105
|
+
- **`envVars`** declares what the step needs
|
|
106
|
+
([ADR-0027](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0027-steps-declare-env-var-requirements.md)):
|
|
107
|
+
`required` (the worker does not start without it), `optional`, `public` (the subset whose value
|
|
108
|
+
is not secret), and at most one `configuredBy: "LIGETI_STEP_<NAME>_ENV"` whose comma-separated
|
|
109
|
+
value lists more optional names, read in `settings.ts` through `envVarNameList`. `{}` is valid.
|
|
110
|
+
Every settings field belongs in a declaration with the same sensitivity; the template's
|
|
111
|
+
`test/settings.test.ts` checks that with `settingsEnvVarProblems` from `@ligeti/sdk/testing`.
|
|
112
|
+
- **Spawning** a process: an argv array, never `shell: true`, an explicit `timeout`, the step's
|
|
113
|
+
`sctx.signal`, and an environment from `buildSpawnEnv(envVars, { logger: sctx.logger })`, which
|
|
114
|
+
gives the process the SDK's base list and the declared names only. Log through `sctx.logger`.
|
|
115
|
+
- Document the variables in the README as a table, with their defaults and sensitivity.
|
|
116
|
+
|
|
117
|
+
## 6. Test with real doubles
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
pnpm build && pnpm typecheck && pnpm lint && pnpm test
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- A double for an external tool is **a real executable** the step spawns, written by the test to a
|
|
124
|
+
throwaway directory and chosen through the step's setting (`LIGETI_TEMPLATE_TOOL_BIN` in the
|
|
125
|
+
template); a double for a service is a local HTTP server on a real port, with its base URL taken
|
|
126
|
+
from a setting. `@ligeti/testing` already has real doubles for `claude`, `herdr`, GitLab, GitHub,
|
|
127
|
+
Bitbucket, Jira and Telegram
|
|
128
|
+
([ADR-0007](https://gitlab.com/nagyv-projects/ligeti/-/blob/main/adr/0007-test-doubles-are-real-processes.md)).
|
|
129
|
+
- State each rule as a `Rule:` with `Example:`s in `test/<name>.feature`, run by `test/rules.test.ts`
|
|
130
|
+
through `@amiceli/vitest-cucumber`, as the template does. Include the failure examples: a step
|
|
131
|
+
throws, so each is a test that it throws with a message naming the cause.
|
|
132
|
+
- Test that the spawned process sees only declared variables, as the template's last example does.
|
|
133
|
+
- Run the step directly, `step.run(sctx, input)`, with a minimal `StepContext` (`workflowId`,
|
|
134
|
+
`stepId`, `stepName`, `signal`, and a `logger` with `debug`, `info`, `warn` and `error`).
|
|
135
|
+
|
|
136
|
+
## 7. Export and document
|
|
137
|
+
|
|
138
|
+
- `src/index.ts` is the package's one barrel: named exports of each step and its input and output
|
|
139
|
+
schemas, and nothing else. `package.json` `exports["."]` points at the built `dist/index.js`.
|
|
140
|
+
- Give each step `package: { name: pkg.name, version: pkg.version }` so the manifest attributes it
|
|
141
|
+
to this package, and a `description`.
|
|
142
|
+
- The README states the package's steps, each step's inputs and output, its retry behaviour, and its
|
|
143
|
+
environment variables.
|
|
144
|
+
|
|
145
|
+
## Next
|
|
146
|
+
|
|
147
|
+
Use the step from a workflow package with `authoring-workflows`. A workflow gets a new step version
|
|
148
|
+
only when its own repository bumps the dependency, rebuilds, refreshes its manifest snapshot and
|
|
149
|
+
publishes a new workflow version; `installing-workflows` covers upgrading the install.
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
- Find candidates in this order, and stop at the first that fits:
|
|
83
|
+
1. `ligeti steps` lists the step packages the operator already runs, with their directories.
|
|
84
|
+
2. A step package in the author's own repository: one whose `package.json` has
|
|
85
|
+
`"ligeti": { "kind": "step" }`, in its `node_modules` or workspace.
|
|
86
|
+
3. `npm search @ligeti/step-` and `npm search keywords:ligeti-step` for published ones.
|
|
87
|
+
- Run `ligeti steps describe <dir>` on each fitting candidate (after `pnpm add` for a published
|
|
88
|
+
one) to read its steps' input and output JSON Schema and their `envVars`.
|
|
89
|
+
- After `pnpm build`, `pnpm exec ligeti-worker describe .` prints the manifest: each listed step
|
|
90
|
+
with its input and output JSON Schema, and the `envVars` the workflow needs. Run it again after
|
|
91
|
+
each change to `steps`.
|
|
92
|
+
- Every step's `envVars` become the workflow's: tell the author which variables the operator must
|
|
93
|
+
set (`ligeti config`) before the workflow runs, and write them in the README.
|
|
94
|
+
- No existing step does it? Write one with the `authoring-steps` skill, in its own package.
|
|
95
|
+
|
|
96
|
+
## 5. Write the workflow
|
|
97
|
+
|
|
98
|
+
Keep `src/workflow.ts` the package's one entry, with `export default defineWorkflow({...})`.
|
|
99
|
+
|
|
100
|
+
- Input and output are Zod schemas; describe every field with `.describe()`. The output carries a
|
|
101
|
+
`runOutcome`, and every run that returns ends with `await ctx.status("done", { runOutcome })`.
|
|
102
|
+
- Call steps with `ctx.run(step, input)`; wait for an agent with `ctx.waitForCallback`; a human with
|
|
103
|
+
the `@ligeti/step-human-approval` steps; a child workflow with `ctx.child(...).outcome()`.
|
|
104
|
+
- A rule about what the workflow accepts or does is a `Rule:` with `Example:`s in a `.feature` file,
|
|
105
|
+
run by a `*.test.ts` through `@amiceli/vitest-cucumber`, next to the template's own.
|
|
106
|
+
- Update `README.md`: a table of inputs, the output, the steps used, the environment variables, and
|
|
107
|
+
whether the workflow is meant for a schedule.
|
|
108
|
+
|
|
109
|
+
## 6. Test and lint
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
pnpm build && pnpm typecheck && pnpm lint && pnpm test
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- Test the body with `createFakeContext` from `@ligeti/sdk/testing`: it scripts step outputs and
|
|
116
|
+
callbacks and records every call, so the workflow's own chaining is what is tested.
|
|
117
|
+
- `test/workflow.test.ts` describes the package with a real `ligeti-worker` through
|
|
118
|
+
`describeWorkflowPackage` from `@ligeti/testing` and snapshots the manifest, with `codeHash` and
|
|
119
|
+
`sdkVersion` masked. A change to the input schema, the steps or the package version changes it;
|
|
120
|
+
review the diff, then `pnpm vitest run -u`.
|
|
121
|
+
- Doubles for external tools and services are real executables or local servers, never `vi.mock`.
|
|
122
|
+
`@ligeti/testing` has them for `claude`, `herdr`, GitLab, GitHub, Bitbucket, Jira and Telegram.
|
|
123
|
+
- Lint is `eslint .` with `@ligeti/eslint-plugin`'s presets: a deterministic workflow body, no
|
|
124
|
+
`console`, no module mocks, and only the allowed comments. Fix a finding; do not disable the rule.
|
|
125
|
+
|
|
126
|
+
## 7. A workflow meant for a schedule
|
|
127
|
+
|
|
128
|
+
A cron entry starts the same input on every tick, so a workflow for a schedule must:
|
|
129
|
+
|
|
130
|
+
- say so in its README, in a sentence the `scheduling-workflows` skill can find ("Meant for a
|
|
131
|
+
schedule: finds its own work on each tick");
|
|
132
|
+
- **find its own work on each tick** instead of taking it from the input: its first step reads the
|
|
133
|
+
outside state (open issues, unread messages, a directory) and the run returns early, with
|
|
134
|
+
`runOutcome` saying nothing was found, when there is none. Ticks missed while the shell is down
|
|
135
|
+
are not backfilled, so the work must not depend on a tick for each period;
|
|
136
|
+
- declare `queue: { concurrency: 1 }` on `defineWorkflow` when two overlapping ticks would conflict
|
|
137
|
+
(they would both pick up the same work, or write the same place). `concurrency` caps how many of
|
|
138
|
+
this workflow's runs execute at once (it becomes DBOS's `globalConcurrency` for the workflow);
|
|
139
|
+
- be cheap when idle: a frequent schedule starts a run per tick, and an agent session per tick if
|
|
140
|
+
the workflow starts agents.
|
|
141
|
+
|
|
142
|
+
## Next
|
|
143
|
+
|
|
144
|
+
- Installing the package into a shell, and upgrading it: `installing-workflows`.
|
|
145
|
+
- Running it on a schedule: `scheduling-workflows`.
|
|
146
|
+
- 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`.
|