@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.
Files changed (89) hide show
  1. package/README.md +58 -0
  2. package/dist/bin-resolve.d.ts +5 -0
  3. package/dist/bin-resolve.d.ts.map +1 -1
  4. package/dist/bin-resolve.js +12 -3
  5. package/dist/bin-resolve.js.map +1 -1
  6. package/dist/cli/config.d.ts.map +1 -1
  7. package/dist/cli/config.js +2 -3
  8. package/dist/cli/config.js.map +1 -1
  9. package/dist/cli/installed-versions.d.ts +9 -0
  10. package/dist/cli/installed-versions.d.ts.map +1 -0
  11. package/dist/cli/installed-versions.js +50 -0
  12. package/dist/cli/installed-versions.js.map +1 -0
  13. package/dist/cli/plugin.d.ts +13 -0
  14. package/dist/cli/plugin.d.ts.map +1 -0
  15. package/dist/cli/plugin.js +188 -0
  16. package/dist/cli/plugin.js.map +1 -0
  17. package/dist/cli/pre-push.d.ts +12 -0
  18. package/dist/cli/pre-push.d.ts.map +1 -0
  19. package/dist/cli/pre-push.js +56 -0
  20. package/dist/cli/pre-push.js.map +1 -0
  21. package/dist/cli/share-dir.d.ts +3 -0
  22. package/dist/cli/share-dir.d.ts.map +1 -0
  23. package/dist/cli/share-dir.js +13 -0
  24. package/dist/cli/share-dir.js.map +1 -0
  25. package/dist/cli/steps.d.ts +16 -0
  26. package/dist/cli/steps.d.ts.map +1 -0
  27. package/dist/cli/steps.js +102 -0
  28. package/dist/cli/steps.js.map +1 -0
  29. package/dist/cli/version.d.ts +6 -0
  30. package/dist/cli/version.d.ts.map +1 -0
  31. package/dist/cli/version.js +14 -0
  32. package/dist/cli/version.js.map +1 -0
  33. package/dist/cli.d.ts.map +1 -1
  34. package/dist/cli.js +36 -4
  35. package/dist/cli.js.map +1 -1
  36. package/dist/installed-steps.d.ts +8 -0
  37. package/dist/installed-steps.d.ts.map +1 -0
  38. package/dist/installed-steps.js +90 -0
  39. package/dist/installed-steps.js.map +1 -0
  40. package/dist/settings.d.ts +1 -0
  41. package/dist/settings.d.ts.map +1 -1
  42. package/dist/settings.js +4 -0
  43. package/dist/settings.js.map +1 -1
  44. package/dist/workers.d.ts +4 -1
  45. package/dist/workers.d.ts.map +1 -1
  46. package/dist/workers.js +59 -3
  47. package/dist/workers.js.map +1 -1
  48. package/package.json +10 -9
  49. package/share/.claude-plugin/marketplace.json +14 -0
  50. package/share/plugins/ligeti/.claude-plugin/plugin.json +6 -0
  51. package/share/plugins/ligeti/README.md +31 -0
  52. package/share/plugins/ligeti/docs/attestation.md +590 -0
  53. package/share/plugins/ligeti/docs/shell.md +442 -0
  54. package/share/plugins/ligeti/docs/troubleshooting.md +28 -0
  55. package/share/plugins/ligeti/references/rules.md +93 -0
  56. package/share/plugins/ligeti/skills/authoring-steps/SKILL.md +149 -0
  57. package/share/plugins/ligeti/skills/authoring-workflows/SKILL.md +146 -0
  58. package/share/plugins/ligeti/skills/installing-workflows/SKILL.md +121 -0
  59. package/share/plugins/ligeti/skills/onboard/SKILL.md +290 -0
  60. package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.github.yml +66 -0
  61. package/share/plugins/ligeti/skills/onboard/assets/ligeti-verify-attestation.yml +69 -0
  62. package/share/plugins/ligeti/skills/onboard/assets/pre-push.sh +11 -0
  63. package/share/plugins/ligeti/skills/scheduling-workflows/SKILL.md +102 -0
  64. package/share/plugins/ligeti/skills/troubleshooting/SKILL.md +94 -0
  65. package/share/plugins/ligeti/templates/step/.prettierignore +3 -0
  66. package/share/plugins/ligeti/templates/step/README.md +52 -0
  67. package/share/plugins/ligeti/templates/step/eslint.config.js +105 -0
  68. package/share/plugins/ligeti/templates/step/package.json +52 -0
  69. package/share/plugins/ligeti/templates/step/src/index.ts +3 -0
  70. package/share/plugins/ligeti/templates/step/src/settings.ts +27 -0
  71. package/share/plugins/ligeti/templates/step/src/tool-version.ts +61 -0
  72. package/share/plugins/ligeti/templates/step/test/rules.test.ts +144 -0
  73. package/share/plugins/ligeti/templates/step/test/settings.test.ts +30 -0
  74. package/share/plugins/ligeti/templates/step/test/tool-version.feature +32 -0
  75. package/share/plugins/ligeti/templates/step/tsconfig.build.json +26 -0
  76. package/share/plugins/ligeti/templates/step/tsconfig.json +21 -0
  77. package/share/plugins/ligeti/templates/workflow/.prettierignore +3 -0
  78. package/share/plugins/ligeti/templates/workflow/README.md +56 -0
  79. package/share/plugins/ligeti/templates/workflow/eslint.config.js +99 -0
  80. package/share/plugins/ligeti/templates/workflow/package.json +46 -0
  81. package/share/plugins/ligeti/templates/workflow/src/workflow.ts +72 -0
  82. package/share/plugins/ligeti/templates/workflow/test/__snapshots__/workflow.test.ts.snap +132 -0
  83. package/share/plugins/ligeti/templates/workflow/test/rules.test.ts +160 -0
  84. package/share/plugins/ligeti/templates/workflow/test/template-workflow.feature +31 -0
  85. package/share/plugins/ligeti/templates/workflow/test/workflow.test.ts +64 -0
  86. package/share/plugins/ligeti/templates/workflow/tsconfig.build.json +26 -0
  87. package/share/plugins/ligeti/templates/workflow/tsconfig.json +21 -0
  88. package/share/scripts/pre-push-gate.sh +308 -0
  89. package/share/scripts/pre-push-lib.sh +64 -0
@@ -0,0 +1,52 @@
1
+ # @ligeti/template-step
2
+
3
+ The template the `authoring-steps` skill of the `ligeti` plugin copies to start a step package. It
4
+ is a real package in the Ligeti workspace, so the ordinary build, type-check, lint and tests keep it
5
+ working; a copy outside the repository replaces its `workspace:*` dependencies with `pnpm add`.
6
+ Ligeti's own copy is private and is never published.
7
+
8
+ It holds one plain step, `template.tool-version`, which spawns a configured tool with an argv array
9
+ and an explicit environment. Replace it with your own step and keep its shape.
10
+
11
+ ## Steps
12
+
13
+ | Step | Kind | Retry | What it does |
14
+ | ----------------------- | ----- | -------------------- | --------------------------------------------------------- |
15
+ | `template.tool-version` | plain | 3 attempts, 2s apart | Runs the configured tool with `--version` in a directory. |
16
+
17
+ `template.tool-version` only reads, so a retry is safe. A step that creates something outside
18
+ Ligeti is a resource step (`defineResourceStep`); a plain step whose effect would repeat makes it
19
+ idempotent or sets `retry: { maxAttempts: 1 }`.
20
+
21
+ ### Inputs
22
+
23
+ | Input | Required | Notes |
24
+ | --------- | -------- | ------------------------------------------------ |
25
+ | `workdir` | yes | Absolute path of the directory the tool runs in. |
26
+
27
+ ### Output
28
+
29
+ `{ version: string }`: the first line the tool printed. The step throws when the tool cannot be
30
+ started, exits non-zero, times out after 30 seconds or prints nothing.
31
+
32
+ ## Environment variables
33
+
34
+ | Variable | Default | Public | Notes |
35
+ | -------------------------- | ------- | ------ | --------------------------------------------------------- |
36
+ | `LIGETI_TEMPLATE_TOOL_BIN` | `git` | yes | The executable the step runs; a path or a name on `PATH`. |
37
+
38
+ The tool sees only the SDK's base variables (`PATH`, `HOME`, `USER`, `LOGNAME`, `LANG`, `LC_ALL`,
39
+ `TMPDIR`, `SHELL`, `TERM`, `TZ`) and the variables the step declares in its `envVars`.
40
+
41
+ ## Developing
42
+
43
+ ```sh
44
+ pnpm install
45
+ pnpm build
46
+ pnpm typecheck
47
+ pnpm lint
48
+ pnpm test
49
+ ```
50
+
51
+ `test/tool-version.feature` states the step's rules, and `test/rules.test.ts` runs them against real
52
+ executables written to a throwaway directory, never against a module mock.
@@ -0,0 +1,105 @@
1
+ // ABOUTME: Flat ESLint config for a step package: strict type-checked rules plus @ligeti/eslint-plugin's
2
+ // ABOUTME: presets for explicit spawn environments, contextual logging, real test doubles and no comments.
3
+ import js from "@eslint/js";
4
+ import tseslint from "typescript-eslint";
5
+ import eslintConfigPrettier from "eslint-config-prettier";
6
+ import eslintComments from "@eslint-community/eslint-plugin-eslint-comments";
7
+ import globals from "globals";
8
+ import { plugin as ligetiPlugin, presets as ligetiPresets } from "@ligeti/eslint-plugin";
9
+
10
+ export default tseslint.config(
11
+ {
12
+ name: "ligeti/linter options: an unused disable directive is an error",
13
+ linterOptions: {
14
+ reportUnusedDisableDirectives: "error",
15
+ reportUnusedInlineConfigs: "error",
16
+ },
17
+ },
18
+ {
19
+ name: "ligeti/ignores: build output and installed dependencies",
20
+ ignores: ["dist/**", "coverage/**", "node_modules/**", "**/*.tsbuildinfo"],
21
+ },
22
+ js.configs.recommended,
23
+ ...tseslint.configs.strictTypeChecked,
24
+ ...tseslint.configs.stylisticTypeChecked,
25
+ {
26
+ name: "ligeti/typescript-eslint project service and comment-directive rules",
27
+ plugins: { ligeti: ligetiPlugin, "@eslint-community/eslint-comments": eslintComments },
28
+ languageOptions: {
29
+ parserOptions: {
30
+ projectService: {
31
+ allowDefaultProject: ["*.js", "*.cjs", "*.mjs", "vitest.config.ts"],
32
+ },
33
+ tsconfigRootDir: import.meta.dirname,
34
+ },
35
+ },
36
+ rules: {
37
+ "@typescript-eslint/no-floating-promises": "error",
38
+ "@typescript-eslint/no-misused-promises": "error",
39
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
40
+ "@typescript-eslint/ban-ts-comment": [
41
+ "error",
42
+ {
43
+ "ts-expect-error": "allow-with-description",
44
+ minimumDescriptionLength: 10,
45
+ "ts-ignore": true,
46
+ "ts-nocheck": true,
47
+ "ts-check": false,
48
+ },
49
+ ],
50
+ "no-warning-comments": [
51
+ "error",
52
+ { terms: ["todo", "fixme", "xxx", "hack"], location: "anywhere" },
53
+ ],
54
+ "@eslint-community/eslint-comments/require-description": "error",
55
+ "@eslint-community/eslint-comments/no-unlimited-disable": "error",
56
+ "@eslint-community/eslint-comments/disable-enable-pair": "error",
57
+ "@eslint-community/eslint-comments/no-unused-enable": "error",
58
+ },
59
+ },
60
+ {
61
+ name: "ligeti/no-comments: an error in every JS and TS file (ADR-0021)",
62
+ files: ["**/*.{ts,tsx,js,mjs,cjs}"],
63
+ rules: {
64
+ "ligeti/no-comments": ["error", ligetiPresets.noComments.rules["ligeti/no-comments"][1]],
65
+ },
66
+ },
67
+ {
68
+ name: "ligeti/runtime preset: no blocking calls on the shared event loop",
69
+ files: ["src/**/*.{ts,tsx}"],
70
+ rules: ligetiPresets.runtime.rules,
71
+ },
72
+ {
73
+ name: "ligeti/no-console: log through the contextual logger (ADR-0011)",
74
+ files: ["src/**/*.{ts,tsx}"],
75
+ rules: { "no-console": "error" },
76
+ },
77
+ {
78
+ name: "ligeti/step runtime guards: no raw recv, no shell:true, no process.env (ADR-0003, ADR-0004)",
79
+ files: ["src/**/*.{ts,tsx}"],
80
+ ignores: ["**/settings.ts"],
81
+ rules: ligetiPresets.stepRuntimeGuards.rules,
82
+ },
83
+ {
84
+ name: "ligeti/settings.ts keeps the shell:true and exec bans (ADR-0004)",
85
+ files: ["src/settings.ts"],
86
+ rules: ligetiPresets.settingsGuards.rules,
87
+ },
88
+ {
89
+ name: "ligeti/test doubles are real processes or servers, never module mocks (ADR-0007)",
90
+ files: ["**/*.test.ts", "**/*.test.tsx"],
91
+ rules: ligetiPresets.testDoubles.rules,
92
+ },
93
+ {
94
+ files: ["**/*.js", "**/*.mjs"],
95
+ ...tseslint.configs.disableTypeChecked,
96
+ languageOptions: {
97
+ globals: globals.node,
98
+ },
99
+ },
100
+ {
101
+ files: ["vitest.config.ts"],
102
+ ...tseslint.configs.disableTypeChecked,
103
+ },
104
+ eslintConfigPrettier,
105
+ );
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@ligeti/template-step",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "Template for a Ligeti step package: copy it, rename it, replace its workspace dependencies.",
6
+ "keywords": [
7
+ "ligeti-step"
8
+ ],
9
+ "ligeti": {
10
+ "kind": "step",
11
+ "sdk": "^2.0.0"
12
+ },
13
+ "type": "module",
14
+ "license": "Apache-2.0",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsc -p tsconfig.build.json",
26
+ "typecheck": "tsc -p tsconfig.json --noEmit",
27
+ "lint": "eslint . && prettier --check .",
28
+ "test": "vitest run"
29
+ },
30
+ "prettier": {
31
+ "printWidth": 100,
32
+ "trailingComma": "all"
33
+ },
34
+ "peerDependencies": {
35
+ "@ligeti/sdk": "workspace:^"
36
+ },
37
+ "devDependencies": {
38
+ "@amiceli/vitest-cucumber": "8.0.0",
39
+ "@eslint-community/eslint-plugin-eslint-comments": "4.8.1",
40
+ "@eslint/js": "^10.0.1",
41
+ "@ligeti/eslint-plugin": "workspace:*",
42
+ "@ligeti/sdk": "workspace:*",
43
+ "@types/node": "^22.15.0",
44
+ "eslint": "^10.10.0",
45
+ "eslint-config-prettier": "^10.1.8",
46
+ "globals": "^17.12.0",
47
+ "prettier": "^3.9.7",
48
+ "typescript": "^5.9.2",
49
+ "typescript-eslint": "^8.70.0",
50
+ "vitest": "^5.0.1"
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ // ABOUTME: Public entry point of @ligeti/template-step: the toolVersion step and its input and output
2
+ // ABOUTME: schemas. A workflow package imports steps from here, never from a deeper path.
3
+ export { toolVersion, ToolVersionInput, ToolVersionOutput } from "./tool-version.js";
@@ -0,0 +1,27 @@
1
+ // ABOUTME: @ligeti/template-step settings loaded from the environment, parsed with zod. The only file
2
+ // ABOUTME: in the package that reads process.env; steps call loadToolSettings and never read it directly.
3
+ import { defineSettingsSchema, z, type EnvVarRequirements } from "@ligeti/sdk";
4
+
5
+ export const TOOL_ENV_VARS = {
6
+ optional: ["LIGETI_TEMPLATE_TOOL_BIN"],
7
+ public: ["LIGETI_TEMPLATE_TOOL_BIN"],
8
+ } satisfies EnvVarRequirements;
9
+
10
+ export const settingsSchema = defineSettingsSchema({
11
+ LIGETI_TEMPLATE_TOOL_BIN: z.string().min(1).default("git").meta({ sensitivity: "public" }),
12
+ });
13
+
14
+ export interface ToolSettings {
15
+ readonly toolBin: string;
16
+ }
17
+
18
+ export function loadToolSettings(env: NodeJS.ProcessEnv = process.env): ToolSettings {
19
+ const result = settingsSchema.safeParse(env);
20
+ if (!result.success) {
21
+ const issues = result.error.issues
22
+ .map((issue) => ` - ${issue.path.join(".")}: ${issue.message}`)
23
+ .join("\n");
24
+ throw new Error(`invalid template step environment:\n${issues}`);
25
+ }
26
+ return { toolBin: result.data.LIGETI_TEMPLATE_TOOL_BIN };
27
+ }
@@ -0,0 +1,61 @@
1
+ // ABOUTME: template.tool-version, the plain step that asks the configured tool for its version by spawning it
2
+ // ABOUTME: with an argv array and an explicit environment. Replace it with your step; keep its shape.
3
+ import { execFile } from "node:child_process";
4
+ import path from "node:path";
5
+ import { promisify } from "node:util";
6
+ import { buildSpawnEnv, defineStep, z } from "@ligeti/sdk";
7
+ import pkg from "../package.json" with { type: "json" };
8
+ import { loadToolSettings, TOOL_ENV_VARS } from "./settings.js";
9
+
10
+ const execFileAsync = promisify(execFile);
11
+
12
+ const TOOL_TIMEOUT_MS = 30_000;
13
+
14
+ export const ToolVersionInput = z.object({
15
+ workdir: z
16
+ .string()
17
+ .min(1)
18
+ .refine((value) => path.isAbsolute(value), { message: "must be an absolute path" })
19
+ .describe("Absolute path of the directory the tool runs in."),
20
+ });
21
+ export type ToolVersionInput = z.infer<typeof ToolVersionInput>;
22
+
23
+ export const ToolVersionOutput = z.object({
24
+ version: z.string().describe("The first line the tool printed for --version."),
25
+ });
26
+ export type ToolVersionOutput = z.infer<typeof ToolVersionOutput>;
27
+
28
+ export const toolVersion = defineStep({
29
+ name: "template.tool-version",
30
+ envVars: TOOL_ENV_VARS,
31
+ description: "Asks the configured tool for its version.",
32
+ package: { name: pkg.name, version: pkg.version },
33
+ input: ToolVersionInput,
34
+ output: ToolVersionOutput,
35
+ retry: { maxAttempts: 3, intervalSeconds: 2 },
36
+
37
+ async run(sctx, input) {
38
+ const { toolBin } = loadToolSettings();
39
+ const env = buildSpawnEnv(TOOL_ENV_VARS, { logger: sctx.logger });
40
+ let stdout: string;
41
+ try {
42
+ ({ stdout } = await execFileAsync(toolBin, ["--version"], {
43
+ cwd: input.workdir,
44
+ env,
45
+ timeout: TOOL_TIMEOUT_MS,
46
+ signal: sctx.signal,
47
+ }));
48
+ } catch (err) {
49
+ const detail = err instanceof Error ? err.message : String(err);
50
+ throw new Error(`template.tool-version: ${toolBin} --version failed: ${detail}`, {
51
+ cause: err,
52
+ });
53
+ }
54
+ const version = stdout.split("\n")[0]?.trim() ?? "";
55
+ if (version === "") {
56
+ throw new Error(`template.tool-version: ${toolBin} --version printed nothing`);
57
+ }
58
+ sctx.logger.info("template.tool-version: resolved", { toolBin, version });
59
+ return { version };
60
+ },
61
+ });
@@ -0,0 +1,144 @@
1
+ // ABOUTME: Runs tool-version.feature's Rules against template.tool-version with real executables written to a
2
+ // ABOUTME: throwaway directory, so the step's behaviour is checked against real processes (ADR-0007).
3
+ import { chmod, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
4
+ import { tmpdir } from "node:os";
5
+ import path from "node:path";
6
+ import { describeFeature, loadFeature } from "@amiceli/vitest-cucumber";
7
+ import type { StepContext } from "@ligeti/sdk";
8
+ import { expect } from "vitest";
9
+ import { toolVersion, ToolVersionInput } from "../src/tool-version.js";
10
+
11
+ const ENV_KEYS = ["LIGETI_TEMPLATE_TOOL_BIN", "TEMPLATE_UNDECLARED"] as const;
12
+
13
+ function stepContext(): StepContext {
14
+ return {
15
+ workflowId: "wf-template",
16
+ stepId: 1,
17
+ stepName: "template.tool-version",
18
+ signal: new AbortController().signal,
19
+ logger: {
20
+ debug: () => undefined,
21
+ info: () => undefined,
22
+ warn: () => undefined,
23
+ error: () => undefined,
24
+ },
25
+ };
26
+ }
27
+
28
+ describeFeature(
29
+ await loadFeature("./tool-version.feature"),
30
+ ({ Rule, BeforeEachScenario, AfterEachScenario }) => {
31
+ let directory: string;
32
+ let savedEnv: Record<string, string | undefined>;
33
+ let version: string;
34
+ let failure: unknown;
35
+
36
+ BeforeEachScenario(async () => {
37
+ directory = await mkdtemp(path.join(tmpdir(), "ligeti-template-step-"));
38
+ savedEnv = Object.fromEntries(ENV_KEYS.map((key) => [key, Reflect.get(process.env, key)]));
39
+ failure = undefined;
40
+ });
41
+
42
+ AfterEachScenario(async () => {
43
+ await rm(directory, { recursive: true, force: true });
44
+ for (const key of ENV_KEYS) {
45
+ const value = savedEnv[key];
46
+ if (value === undefined) {
47
+ Reflect.deleteProperty(process.env, key);
48
+ } else {
49
+ Reflect.set(process.env, key, value);
50
+ }
51
+ }
52
+ });
53
+
54
+ async function givenTool(body: string): Promise<void> {
55
+ const tool = path.join(directory, "fake-tool");
56
+ await writeFile(tool, `#!/bin/sh\n${body}\n`);
57
+ await chmod(tool, 0o755);
58
+ process.env.LIGETI_TEMPLATE_TOOL_BIN = tool;
59
+ }
60
+
61
+ const whenStepRuns = async (): Promise<void> => {
62
+ try {
63
+ version = (
64
+ await toolVersion.run(stepContext(), ToolVersionInput.parse({ workdir: directory }))
65
+ ).version;
66
+ } catch (err) {
67
+ failure = err;
68
+ }
69
+ };
70
+
71
+ function thrownMessage(): string {
72
+ return failure instanceof Error ? failure.message : "";
73
+ }
74
+
75
+ Rule("the version is the first line the tool prints for --version", ({ RuleScenario }) => {
76
+ RuleScenario("a tool that prints a version line", ({ Given, When, Then }) => {
77
+ Given('a tool that prints "fake-tool 1.2.3" and a second line for --version', () =>
78
+ givenTool('echo "fake-tool 1.2.3"\necho "second line"'),
79
+ );
80
+ When("template.tool-version runs it", whenStepRuns);
81
+ Then('the version is "fake-tool 1.2.3"', () => {
82
+ expect(version).toBe("fake-tool 1.2.3");
83
+ });
84
+ });
85
+ });
86
+
87
+ Rule("a tool that cannot report a version makes the step throw", ({ RuleScenario }) => {
88
+ RuleScenario("a tool that exits non-zero", ({ Given, When, Then }) => {
89
+ Given('a tool that writes "refusing" to stderr and exits 3', () =>
90
+ givenTool('echo "refusing" >&2\nexit 3'),
91
+ );
92
+ When("template.tool-version runs it", whenStepRuns);
93
+ Then('the step throws naming the tool and "refusing"', () => {
94
+ expect(thrownMessage()).toContain("fake-tool");
95
+ expect(thrownMessage()).toContain("refusing");
96
+ });
97
+ });
98
+
99
+ RuleScenario("a tool that prints nothing", ({ Given, When, Then }) => {
100
+ Given("a tool that prints nothing and exits 0", () => givenTool("exit 0"));
101
+ When("template.tool-version runs it", whenStepRuns);
102
+ Then("the step throws saying the tool printed nothing", () => {
103
+ expect(thrownMessage()).toContain("printed nothing");
104
+ });
105
+ });
106
+
107
+ RuleScenario("a tool that does not exist", ({ Given, When, Then }) => {
108
+ Given("LIGETI_TEMPLATE_TOOL_BIN names an executable that does not exist", () => {
109
+ process.env.LIGETI_TEMPLATE_TOOL_BIN = path.join(directory, "no-such-tool");
110
+ });
111
+ When("template.tool-version runs it", whenStepRuns);
112
+ Then("the step throws naming the tool", () => {
113
+ expect(thrownMessage()).toContain("no-such-tool");
114
+ });
115
+ });
116
+ });
117
+
118
+ Rule(
119
+ "the tool sees only the base environment and the variables the step declares",
120
+ ({ RuleScenario }) => {
121
+ RuleScenario(
122
+ "a variable the step does not declare is withheld",
123
+ ({ Given, When, Then }) => {
124
+ Given(
125
+ "the worker's environment holds TEMPLATE_UNDECLARED and the tool records its environment",
126
+ async () => {
127
+ process.env.TEMPLATE_UNDECLARED = "secret-value";
128
+ await givenTool(
129
+ `env > "${path.join(directory, "seen-env")}"\necho "fake-tool 1.2.3"`,
130
+ );
131
+ },
132
+ );
133
+ When("template.tool-version runs it", whenStepRuns);
134
+ Then("the tool saw PATH and not TEMPLATE_UNDECLARED", async () => {
135
+ const seen = await readFile(path.join(directory, "seen-env"), "utf8");
136
+ expect(seen).toMatch(/^PATH=/m);
137
+ expect(seen).not.toContain("TEMPLATE_UNDECLARED");
138
+ });
139
+ },
140
+ );
141
+ },
142
+ );
143
+ },
144
+ );
@@ -0,0 +1,30 @@
1
+ // ABOUTME: Unit tests for @ligeti/template-step's settings: the default and an override of the tool, and
2
+ // ABOUTME: that every settings field is declared by the step's envVars with the same sensitivity (ADR-0027).
3
+ import { settingsEnvVarProblems } from "@ligeti/sdk/testing";
4
+ import { describe, expect, it } from "vitest";
5
+ import { loadToolSettings, settingsSchema } from "../src/settings.js";
6
+ import { toolVersion } from "../src/tool-version.js";
7
+
8
+ describe("loadToolSettings", () => {
9
+ it("runs git by default", () => {
10
+ expect(loadToolSettings({}).toolBin).toBe("git");
11
+ });
12
+
13
+ it("takes the tool from LIGETI_TEMPLATE_TOOL_BIN", () => {
14
+ expect(loadToolSettings({ LIGETI_TEMPLATE_TOOL_BIN: "/opt/tool/bin/tool" }).toolBin).toBe(
15
+ "/opt/tool/bin/tool",
16
+ );
17
+ });
18
+
19
+ it("rejects an empty LIGETI_TEMPLATE_TOOL_BIN, naming it", () => {
20
+ expect(() => loadToolSettings({ LIGETI_TEMPLATE_TOOL_BIN: "" })).toThrow(
21
+ /LIGETI_TEMPLATE_TOOL_BIN/,
22
+ );
23
+ });
24
+ });
25
+
26
+ describe("settings sensitivities", () => {
27
+ it("are declared by the envVars of the step, with the same sensitivity", () => {
28
+ expect(settingsEnvVarProblems(settingsSchema.shape, [toolVersion.envVars])).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,32 @@
1
+ Feature: template.tool-version reports the version of the tool it is configured to run
2
+
3
+ Rule: the version is the first line the tool prints for --version
4
+
5
+ Example: a tool that prints a version line
6
+ Given a tool that prints "fake-tool 1.2.3" and a second line for --version
7
+ When template.tool-version runs it
8
+ Then the version is "fake-tool 1.2.3"
9
+
10
+ Rule: a tool that cannot report a version makes the step throw
11
+
12
+ Example: a tool that exits non-zero
13
+ Given a tool that writes "refusing" to stderr and exits 3
14
+ When template.tool-version runs it
15
+ Then the step throws naming the tool and "refusing"
16
+
17
+ Example: a tool that prints nothing
18
+ Given a tool that prints nothing and exits 0
19
+ When template.tool-version runs it
20
+ Then the step throws saying the tool printed nothing
21
+
22
+ Example: a tool that does not exist
23
+ Given LIGETI_TEMPLATE_TOOL_BIN names an executable that does not exist
24
+ When template.tool-version runs it
25
+ Then the step throws naming the tool
26
+
27
+ Rule: the tool sees only the base environment and the variables the step declares
28
+
29
+ Example: a variable the step does not declare is withheld
30
+ Given the worker's environment holds TEMPLATE_UNDECLARED and the tool records its environment
31
+ When template.tool-version runs it
32
+ Then the tool saw PATH and not TEMPLATE_UNDECLARED
@@ -0,0 +1,26 @@
1
+ // ABOUTME: TypeScript build config for the step template: strict NodeNext options written out in full
2
+ // ABOUTME: so a copy builds anywhere; compiles src into dist, which package.json's exports name.
3
+ {
4
+ "compilerOptions": {
5
+ "target": "ES2023",
6
+ "lib": ["ES2023"],
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext",
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "strict": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "exactOptionalPropertyTypes": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "composite": true,
17
+ "sourceMap": true,
18
+ "skipLibCheck": true,
19
+ "resolveJsonModule": true,
20
+ "verbatimModuleSyntax": true,
21
+ "isolatedModules": true,
22
+ "rootDir": "src",
23
+ "outDir": "dist"
24
+ },
25
+ "include": ["src"]
26
+ }
@@ -0,0 +1,21 @@
1
+ // ABOUTME: TypeScript project for editors, ESLint's type-aware rules and `pnpm typecheck`: src and test,
2
+ // ABOUTME: the same strict options as tsconfig.build.json, no output.
3
+ {
4
+ "compilerOptions": {
5
+ "target": "ES2023",
6
+ "lib": ["ES2023"],
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext",
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "strict": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "exactOptionalPropertyTypes": true,
14
+ "skipLibCheck": true,
15
+ "resolveJsonModule": true,
16
+ "verbatimModuleSyntax": true,
17
+ "isolatedModules": true,
18
+ "noEmit": true
19
+ },
20
+ "include": ["src", "test"]
21
+ }
@@ -0,0 +1,3 @@
1
+ dist
2
+ coverage
3
+ pnpm-lock.yaml
@@ -0,0 +1,56 @@
1
+ # @ligeti/template-workflow
2
+
3
+ The template the `authoring-workflows` skill of the `ligeti` plugin copies to start a workflow
4
+ package. It is a real package in the Ligeti workspace, so the ordinary build, type-check, lint and
5
+ tests keep it working; a copy outside the repository replaces its `workspace:*` dependencies with
6
+ `pnpm add`. Ligeti's own copy is private and is never published.
7
+
8
+ It runs a single Claude Code prompt in a given working directory and returns the result:
9
+ `@ligeti/step-agent`'s `agent.launch` starts the agent, the workflow waits for its callback, and
10
+ `agent.collect-result` reads what it produced.
11
+
12
+ **Not meant for a schedule.** Every run does what its input says and finds no work of its own, and
13
+ nothing serialises two runs. A workflow for a cron entry reads its work from the outside on each
14
+ tick and declares `queue: { concurrency: 1 }` when overlapping ticks would conflict; say so here
15
+ once it does.
16
+
17
+ ## Inputs
18
+
19
+ | Input | Required | Default | Notes |
20
+ | ---------------- | -------- | ------- | ---------------------------------------------------------- |
21
+ | `prompt` | yes | -- | What the agent should do. Must not be empty or blank. |
22
+ | `repoPath` | yes | -- | Directory the agent should run in. It must already exist. |
23
+ | `timeoutSeconds` | no | `3600` | How long to wait for the agent to finish before giving up. |
24
+
25
+ ## Output
26
+
27
+ `@ligeti/step-agent`'s `AgentResult` with its `status` reported as `runOutcome`, one of
28
+ `"succeeded"`, `"failed"` or `"timed_out"`. When the agent does not respond before `timeoutSeconds`,
29
+ the workflow returns `runOutcome: "timed_out"` without collecting a result. Every run that returns
30
+ ends with a `done` status carrying the same `runOutcome`.
31
+
32
+ ## Steps
33
+
34
+ `@ligeti/step-agent`'s `agent.launch` and `agent.collect-result`. Its README, at
35
+ `node_modules/@ligeti/step-agent/README.md` once installed, lists their inputs, outputs and retry
36
+ behaviour.
37
+
38
+ ## Configuration
39
+
40
+ This workflow reads no environment variables. The agent backend, the `claude` binary and the state
41
+ directory are `@ligeti/step-agent`'s concern, described in its README under "Environment
42
+ variables".
43
+
44
+ ## Developing
45
+
46
+ ```sh
47
+ pnpm install
48
+ pnpm build
49
+ pnpm typecheck
50
+ pnpm lint
51
+ pnpm test
52
+ ```
53
+
54
+ `pnpm build` writes `dist/workflow.js`, the `ligeti.entry` the shell loads. The manifest snapshot in
55
+ `test/__snapshots__/` comes from a real `ligeti-worker describe`; a change to the input schema or
56
+ to a step this workflow lists changes it, and `pnpm vitest run -u` refreshes it.