@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.
- package/README.md +33 -0
- 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/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 +31 -4
- package/dist/cli.js.map +1 -1
- package/package.json +6 -5
- 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 +417 -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 +147 -0
- package/share/plugins/ligeti/skills/authoring-workflows/SKILL.md +142 -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 +45 -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,99 @@
|
|
|
1
|
+
// ABOUTME: Flat ESLint config for a workflow package: strict type-checked rules plus @ligeti/eslint-plugin's
|
|
2
|
+
// ABOUTME: presets for a deterministic workflow body, 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/workflow presets: a workflow body is deterministic (ADR-0002)",
|
|
69
|
+
files: ["src/**/*.{ts,tsx}"],
|
|
70
|
+
rules: ligetiPresets.workflow.rules,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "ligeti/no raw DBOS.recv in a workflow: use ctx.waitFor",
|
|
74
|
+
files: ["src/**/*.{ts,tsx}"],
|
|
75
|
+
rules: ligetiPresets.noRawRecv.rules,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "ligeti/no-console: log through the contextual logger (ADR-0011)",
|
|
79
|
+
files: ["src/**/*.{ts,tsx}"],
|
|
80
|
+
rules: { "no-console": "error" },
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "ligeti/test doubles are real processes or servers, never module mocks (ADR-0007)",
|
|
84
|
+
files: ["**/*.test.ts", "**/*.test.tsx"],
|
|
85
|
+
rules: ligetiPresets.testDoubles.rules,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
files: ["**/*.js", "**/*.mjs"],
|
|
89
|
+
...tseslint.configs.disableTypeChecked,
|
|
90
|
+
languageOptions: {
|
|
91
|
+
globals: globals.node,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
files: ["vitest.config.ts"],
|
|
96
|
+
...tseslint.configs.disableTypeChecked,
|
|
97
|
+
},
|
|
98
|
+
eslintConfigPrettier,
|
|
99
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ligeti/template-workflow",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Template for a Ligeti workflow package: copy it, rename it, replace its workspace dependencies.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"ligeti": {
|
|
9
|
+
"kind": "workflow",
|
|
10
|
+
"entry": "./dist/workflow.js",
|
|
11
|
+
"sdk": "^2.0.0"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.build.json",
|
|
18
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
19
|
+
"lint": "eslint . && prettier --check .",
|
|
20
|
+
"test": "vitest run"
|
|
21
|
+
},
|
|
22
|
+
"prettier": {
|
|
23
|
+
"printWidth": 100,
|
|
24
|
+
"trailingComma": "all"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@ligeti/sdk": "workspace:*",
|
|
28
|
+
"@ligeti/step-agent": "workspace:*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@amiceli/vitest-cucumber": "8.0.0",
|
|
32
|
+
"@eslint-community/eslint-plugin-eslint-comments": "4.8.1",
|
|
33
|
+
"@eslint/js": "^10.0.1",
|
|
34
|
+
"@ligeti/eslint-plugin": "workspace:*",
|
|
35
|
+
"@ligeti/testing": "workspace:*",
|
|
36
|
+
"@types/node": "^22.15.0",
|
|
37
|
+
"ajv": "^8.20.0",
|
|
38
|
+
"eslint": "^10.10.0",
|
|
39
|
+
"eslint-config-prettier": "^10.1.8",
|
|
40
|
+
"globals": "^17.12.0",
|
|
41
|
+
"prettier": "^3.9.7",
|
|
42
|
+
"typescript": "^5.9.2",
|
|
43
|
+
"typescript-eslint": "^8.70.0",
|
|
44
|
+
"vitest": "^5.0.1"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// ABOUTME: The template workflow: launch an agent on a prompt, wait for its callback, collect and return
|
|
2
|
+
// ABOUTME: its result. Replace the name, the input and the body; keep `export default defineWorkflow`.
|
|
3
|
+
import { defineWorkflow, NonBlankString, z } from "@ligeti/sdk";
|
|
4
|
+
import { AgentResult, collectResult, launchAgent } from "@ligeti/step-agent";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_TIMEOUT_SECONDS = 3600;
|
|
7
|
+
|
|
8
|
+
const TemplateOutput = AgentResult.omit({ status: true }).extend({
|
|
9
|
+
runOutcome: AgentResult.shape.status,
|
|
10
|
+
});
|
|
11
|
+
type TemplateOutput = z.infer<typeof TemplateOutput>;
|
|
12
|
+
|
|
13
|
+
function toOutput({ status, ...rest }: z.infer<typeof AgentResult>): TemplateOutput {
|
|
14
|
+
return { runOutcome: status, ...rest };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function timedOut(): TemplateOutput {
|
|
18
|
+
return {
|
|
19
|
+
runOutcome: "timed_out",
|
|
20
|
+
resultText: null,
|
|
21
|
+
isError: false,
|
|
22
|
+
exitCode: null,
|
|
23
|
+
costUsd: null,
|
|
24
|
+
sessionId: null,
|
|
25
|
+
error: "agent did not respond before the timeout",
|
|
26
|
+
failureReason: null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default defineWorkflow({
|
|
31
|
+
name: "template-workflow",
|
|
32
|
+
description: "Run a single Claude Code prompt in the given working directory.",
|
|
33
|
+
input: z.object({
|
|
34
|
+
prompt: NonBlankString.describe("What the agent should do"),
|
|
35
|
+
repoPath: z.string().min(1).describe("Directory the agent should run in"),
|
|
36
|
+
timeoutSeconds: z
|
|
37
|
+
.number()
|
|
38
|
+
.int()
|
|
39
|
+
.positive()
|
|
40
|
+
.default(DEFAULT_TIMEOUT_SECONDS)
|
|
41
|
+
.describe("How long to wait for the agent to finish before giving up"),
|
|
42
|
+
}),
|
|
43
|
+
output: TemplateOutput,
|
|
44
|
+
steps: [launchAgent, collectResult],
|
|
45
|
+
|
|
46
|
+
async run(ctx, { prompt, repoPath, timeoutSeconds }) {
|
|
47
|
+
await ctx.status("launching");
|
|
48
|
+
const agent = await ctx.run(launchAgent, { prompt, workdir: repoPath });
|
|
49
|
+
|
|
50
|
+
await ctx.status("waiting_for_agent", {
|
|
51
|
+
resourceKey: agent.resourceKey,
|
|
52
|
+
agentId: agent.output.agentId,
|
|
53
|
+
});
|
|
54
|
+
const message = await ctx.waitForCallback(launchAgent, agent, { timeoutSeconds });
|
|
55
|
+
|
|
56
|
+
if (message === null) {
|
|
57
|
+
const result = timedOut();
|
|
58
|
+
await ctx.status("done", { runOutcome: result.runOutcome });
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
await ctx.status("collecting_result");
|
|
63
|
+
const collected = await ctx.run(collectResult, {
|
|
64
|
+
outputPath: agent.output.outputPath,
|
|
65
|
+
logPath: agent.output.logPath,
|
|
66
|
+
exitCode: message.payload.exitCode,
|
|
67
|
+
});
|
|
68
|
+
const result = toOutput(collected);
|
|
69
|
+
await ctx.status("done", { runOutcome: result.runOutcome });
|
|
70
|
+
return result;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`template workflow manifest > matches the committed snapshot, with codeHash and sdkVersion masked and each step reduced to its identity 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"children": [],
|
|
6
|
+
"envVars": {
|
|
7
|
+
"optional": [],
|
|
8
|
+
"public": [],
|
|
9
|
+
"required": [],
|
|
10
|
+
},
|
|
11
|
+
"input": {
|
|
12
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
13
|
+
"properties": {
|
|
14
|
+
"prompt": {
|
|
15
|
+
"description": "What the agent should do",
|
|
16
|
+
"minLength": 1,
|
|
17
|
+
"pattern": "\\S",
|
|
18
|
+
"type": "string",
|
|
19
|
+
},
|
|
20
|
+
"repoPath": {
|
|
21
|
+
"description": "Directory the agent should run in",
|
|
22
|
+
"minLength": 1,
|
|
23
|
+
"type": "string",
|
|
24
|
+
},
|
|
25
|
+
"timeoutSeconds": {
|
|
26
|
+
"default": 3600,
|
|
27
|
+
"description": "How long to wait for the agent to finish before giving up",
|
|
28
|
+
"exclusiveMinimum": 0,
|
|
29
|
+
"maximum": 9007199254740991,
|
|
30
|
+
"type": "integer",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"required": [
|
|
34
|
+
"prompt",
|
|
35
|
+
"repoPath",
|
|
36
|
+
],
|
|
37
|
+
"type": "object",
|
|
38
|
+
},
|
|
39
|
+
"manifestVersion": 2,
|
|
40
|
+
"output": {
|
|
41
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"properties": {
|
|
44
|
+
"costUsd": {
|
|
45
|
+
"type": [
|
|
46
|
+
"number",
|
|
47
|
+
"null",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
"error": {
|
|
51
|
+
"type": [
|
|
52
|
+
"string",
|
|
53
|
+
"null",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
"exitCode": {
|
|
57
|
+
"anyOf": [
|
|
58
|
+
{
|
|
59
|
+
"maximum": 9007199254740991,
|
|
60
|
+
"minimum": -9007199254740991,
|
|
61
|
+
"type": "integer",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "null",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
"failureReason": {
|
|
69
|
+
"default": null,
|
|
70
|
+
"type": [
|
|
71
|
+
"string",
|
|
72
|
+
"null",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
"isError": {
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
},
|
|
78
|
+
"resultText": {
|
|
79
|
+
"type": [
|
|
80
|
+
"string",
|
|
81
|
+
"null",
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
"runOutcome": {
|
|
85
|
+
"enum": [
|
|
86
|
+
"succeeded",
|
|
87
|
+
"failed",
|
|
88
|
+
"timed_out",
|
|
89
|
+
],
|
|
90
|
+
"type": "string",
|
|
91
|
+
},
|
|
92
|
+
"sessionId": {
|
|
93
|
+
"type": [
|
|
94
|
+
"string",
|
|
95
|
+
"null",
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
"required": [
|
|
100
|
+
"resultText",
|
|
101
|
+
"isError",
|
|
102
|
+
"exitCode",
|
|
103
|
+
"costUsd",
|
|
104
|
+
"sessionId",
|
|
105
|
+
"error",
|
|
106
|
+
"failureReason",
|
|
107
|
+
"runOutcome",
|
|
108
|
+
],
|
|
109
|
+
"type": "object",
|
|
110
|
+
},
|
|
111
|
+
"package": {
|
|
112
|
+
"name": "@ligeti/template-workflow",
|
|
113
|
+
"version": "0.0.0",
|
|
114
|
+
},
|
|
115
|
+
"steps": [
|
|
116
|
+
{
|
|
117
|
+
"kind": "resource",
|
|
118
|
+
"name": "agent.launch",
|
|
119
|
+
"package": "@ligeti/step-agent",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"kind": "step",
|
|
123
|
+
"name": "agent.collect-result",
|
|
124
|
+
"package": "@ligeti/step-agent",
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
"workflow": {
|
|
128
|
+
"description": "Run a single Claude Code prompt in the given working directory.",
|
|
129
|
+
"name": "template-workflow",
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// ABOUTME: Runs template-workflow.feature's Rules against the template workflow with a fake workflow
|
|
2
|
+
// ABOUTME: context that scripts the agent steps, so the run body's own chaining is what is tested.
|
|
3
|
+
import { describeFeature, loadFeature } from "@amiceli/vitest-cucumber";
|
|
4
|
+
import { createFakeContext } from "@ligeti/sdk/testing";
|
|
5
|
+
import { expect } from "vitest";
|
|
6
|
+
import templateWorkflow from "../src/workflow.js";
|
|
7
|
+
|
|
8
|
+
interface Finished {
|
|
9
|
+
fake: ReturnType<typeof createFakeContext>;
|
|
10
|
+
output: Awaited<ReturnType<typeof templateWorkflow.run>>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function complete(
|
|
14
|
+
agentAnswers: boolean,
|
|
15
|
+
extraInput: Record<string, unknown> = {},
|
|
16
|
+
): Promise<Finished> {
|
|
17
|
+
const fake = createFakeContext({
|
|
18
|
+
steps: {
|
|
19
|
+
"agent.launch": {
|
|
20
|
+
output: {
|
|
21
|
+
backend: "subprocess",
|
|
22
|
+
agentId: "agent-1",
|
|
23
|
+
sessionId: null,
|
|
24
|
+
promptPath: "/work/prompt.txt",
|
|
25
|
+
outputPath: "/work/output.json",
|
|
26
|
+
logPath: "/work/log.txt",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
"agent.collect-result": {
|
|
30
|
+
status: "succeeded",
|
|
31
|
+
resultText: "ok",
|
|
32
|
+
isError: false,
|
|
33
|
+
exitCode: 0,
|
|
34
|
+
costUsd: 0.1,
|
|
35
|
+
sessionId: "sess-1",
|
|
36
|
+
error: null,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
callbacks: {
|
|
40
|
+
"agent.launch": agentAnswers
|
|
41
|
+
? { attemptId: "attempt-0", payload: { attemptId: "attempt-0", exitCode: 0 } }
|
|
42
|
+
: null,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const output = await templateWorkflow.run(
|
|
46
|
+
fake.ctx,
|
|
47
|
+
templateWorkflow.input.parse({ prompt: "hi", repoPath: "/work", ...extraInput }),
|
|
48
|
+
);
|
|
49
|
+
return { fake, output };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describeFeature(await loadFeature("./template-workflow.feature"), ({ Rule }) => {
|
|
53
|
+
Rule("an input without a timeout defaults to one hour", ({ RuleScenario }) => {
|
|
54
|
+
RuleScenario("an input without a timeout gets one hour", ({ Given, When, Then }) => {
|
|
55
|
+
let input: Record<string, unknown>;
|
|
56
|
+
let timeoutSeconds: number;
|
|
57
|
+
|
|
58
|
+
Given("a template-workflow input without a timeout", () => {
|
|
59
|
+
input = { prompt: "hi", repoPath: "/tmp/work" };
|
|
60
|
+
});
|
|
61
|
+
When("the input is parsed", () => {
|
|
62
|
+
timeoutSeconds = templateWorkflow.input.parse(input).timeoutSeconds;
|
|
63
|
+
});
|
|
64
|
+
Then("the timeout is 3600 seconds", () => {
|
|
65
|
+
expect(timeoutSeconds).toBe(3600);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
Rule(
|
|
71
|
+
"template-workflow reports the agent's status as its runOutcome and ends every run that returns with a done phase carrying it",
|
|
72
|
+
({ RuleScenario }) => {
|
|
73
|
+
RuleScenario(
|
|
74
|
+
"a run whose agent succeeds ends done with the succeeded runOutcome",
|
|
75
|
+
({ Given, When, Then, And }) => {
|
|
76
|
+
let finished: Finished;
|
|
77
|
+
let answers: boolean;
|
|
78
|
+
|
|
79
|
+
Given("a run whose agent answers and succeeds", () => {
|
|
80
|
+
answers = true;
|
|
81
|
+
});
|
|
82
|
+
When("the run completes", async () => {
|
|
83
|
+
finished = await complete(answers);
|
|
84
|
+
});
|
|
85
|
+
Then('the output reports the runOutcome "succeeded" and no status', () => {
|
|
86
|
+
expect(finished.output).toMatchObject({ runOutcome: "succeeded" });
|
|
87
|
+
expect(finished.output).not.toHaveProperty("status");
|
|
88
|
+
});
|
|
89
|
+
And('the last phase is done carrying the runOutcome "succeeded"', () => {
|
|
90
|
+
expect(finished.fake.calls.at(-1)).toEqual({
|
|
91
|
+
method: "status",
|
|
92
|
+
name: "done",
|
|
93
|
+
input: { runOutcome: "succeeded" },
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
RuleScenario(
|
|
100
|
+
"a run whose agent never answers ends done with the timed_out runOutcome",
|
|
101
|
+
({ Given, When, Then, And }) => {
|
|
102
|
+
let finished: Finished;
|
|
103
|
+
let answers: boolean;
|
|
104
|
+
|
|
105
|
+
Given("a run whose agent does not answer before the timeout", () => {
|
|
106
|
+
answers = false;
|
|
107
|
+
});
|
|
108
|
+
When("the run completes", async () => {
|
|
109
|
+
finished = await complete(answers);
|
|
110
|
+
});
|
|
111
|
+
Then('the output reports the runOutcome "timed_out" and no status', () => {
|
|
112
|
+
expect(finished.output).toMatchObject({ runOutcome: "timed_out" });
|
|
113
|
+
expect(finished.output).not.toHaveProperty("status");
|
|
114
|
+
});
|
|
115
|
+
And('the last phase is done carrying the runOutcome "timed_out"', () => {
|
|
116
|
+
expect(finished.fake.calls.at(-1)).toEqual({
|
|
117
|
+
method: "status",
|
|
118
|
+
name: "done",
|
|
119
|
+
input: { runOutcome: "timed_out" },
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
Rule(
|
|
128
|
+
"template-workflow hands the agent its prompt and directory, and waits no longer than the timeout it was given",
|
|
129
|
+
({ RuleScenario }) => {
|
|
130
|
+
RuleScenario(
|
|
131
|
+
"the prompt and directory reach the launch step and the timeout reaches the wait",
|
|
132
|
+
({ Given, When, Then, And }) => {
|
|
133
|
+
let input: Record<string, unknown>;
|
|
134
|
+
let finished: Finished;
|
|
135
|
+
|
|
136
|
+
Given("a template-workflow input with a 120 second timeout", () => {
|
|
137
|
+
input = { timeoutSeconds: 120 };
|
|
138
|
+
});
|
|
139
|
+
When("the run completes", async () => {
|
|
140
|
+
finished = await complete(true, input);
|
|
141
|
+
});
|
|
142
|
+
Then("the launch step receives the prompt and the working directory", () => {
|
|
143
|
+
expect(finished.fake.runInputsFor("agent.launch")).toMatchObject([
|
|
144
|
+
{ prompt: "hi", workdir: "/work" },
|
|
145
|
+
]);
|
|
146
|
+
});
|
|
147
|
+
And("the result is collected from the paths and exit code the agent reported", () => {
|
|
148
|
+
expect(finished.fake.runInputsFor("agent.collect-result")).toEqual([
|
|
149
|
+
{ outputPath: "/work/output.json", logPath: "/work/log.txt", exitCode: 0 },
|
|
150
|
+
]);
|
|
151
|
+
});
|
|
152
|
+
And("the wait for the agent lasts 120 seconds", () => {
|
|
153
|
+
const wait = finished.fake.calls.find((call) => call.method === "waitForCallback");
|
|
154
|
+
expect(wait?.input).toMatchObject({ options: { timeoutSeconds: 120 } });
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Feature: the template workflow reports how its agent ended and hands it only what it was given
|
|
2
|
+
|
|
3
|
+
Rule: an input without a timeout defaults to one hour
|
|
4
|
+
|
|
5
|
+
Example: an input without a timeout gets one hour
|
|
6
|
+
Given a template-workflow input without a timeout
|
|
7
|
+
When the input is parsed
|
|
8
|
+
Then the timeout is 3600 seconds
|
|
9
|
+
|
|
10
|
+
Rule: template-workflow reports the agent's status as its runOutcome and ends every run that returns with a done phase carrying it
|
|
11
|
+
|
|
12
|
+
Example: a run whose agent succeeds ends done with the succeeded runOutcome
|
|
13
|
+
Given a run whose agent answers and succeeds
|
|
14
|
+
When the run completes
|
|
15
|
+
Then the output reports the runOutcome "succeeded" and no status
|
|
16
|
+
And the last phase is done carrying the runOutcome "succeeded"
|
|
17
|
+
|
|
18
|
+
Example: a run whose agent never answers ends done with the timed_out runOutcome
|
|
19
|
+
Given a run whose agent does not answer before the timeout
|
|
20
|
+
When the run completes
|
|
21
|
+
Then the output reports the runOutcome "timed_out" and no status
|
|
22
|
+
And the last phase is done carrying the runOutcome "timed_out"
|
|
23
|
+
|
|
24
|
+
Rule: template-workflow hands the agent its prompt and directory, and waits no longer than the timeout it was given
|
|
25
|
+
|
|
26
|
+
Example: the prompt and directory reach the launch step and the timeout reaches the wait
|
|
27
|
+
Given a template-workflow input with a 120 second timeout
|
|
28
|
+
When the run completes
|
|
29
|
+
Then the launch step receives the prompt and the working directory
|
|
30
|
+
And the result is collected from the paths and exit code the agent reported
|
|
31
|
+
And the wait for the agent lasts 120 seconds
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// ABOUTME: Unit tests for the template workflow's definition: its input schema and the manifest the shell
|
|
2
|
+
// ABOUTME: reads, described by a real ligeti-worker and checked against a committed snapshot.
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { describeWorkflowPackage } from "@ligeti/testing";
|
|
6
|
+
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import templateWorkflow from "../src/workflow.js";
|
|
9
|
+
|
|
10
|
+
const packageDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
11
|
+
|
|
12
|
+
describe("template workflow input schema", () => {
|
|
13
|
+
it("accepts a prompt and a directory", () => {
|
|
14
|
+
expect(() =>
|
|
15
|
+
templateWorkflow.input.parse({ prompt: "hi", repoPath: "/tmp/work" }),
|
|
16
|
+
).not.toThrow();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("rejects an empty object", () => {
|
|
20
|
+
expect(() => templateWorkflow.input.parse({})).toThrow();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("rejects a whitespace-only prompt", () => {
|
|
24
|
+
expect(() => templateWorkflow.input.parse({ prompt: " ", repoPath: "/tmp/work" })).toThrow();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("rejects a non-positive timeoutSeconds", () => {
|
|
28
|
+
expect(() =>
|
|
29
|
+
templateWorkflow.input.parse({ prompt: "hi", repoPath: "/tmp/work", timeoutSeconds: 0 }),
|
|
30
|
+
).toThrow();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
interface DescribedManifest {
|
|
35
|
+
codeHash: string;
|
|
36
|
+
sdkVersion: string;
|
|
37
|
+
input: object;
|
|
38
|
+
steps: { name: string; kind: string; package: string }[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe("template workflow manifest", () => {
|
|
42
|
+
const described = describeWorkflowPackage(packageDir) as unknown as Promise<DescribedManifest>;
|
|
43
|
+
|
|
44
|
+
it("matches the committed snapshot, with codeHash and sdkVersion masked and each step reduced to its identity", async () => {
|
|
45
|
+
const { codeHash, sdkVersion, ...rest } = await described;
|
|
46
|
+
expect(codeHash).toMatch(/^sha256:[0-9a-f]{64}$/);
|
|
47
|
+
expect(sdkVersion).toMatch(/^\d+\.\d+\.\d+/);
|
|
48
|
+
const steps = rest.steps.map(({ name, kind, package: stepPackage }) => ({
|
|
49
|
+
name,
|
|
50
|
+
kind,
|
|
51
|
+
package: stepPackage,
|
|
52
|
+
}));
|
|
53
|
+
expect({ ...rest, steps }).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("the manifest's own JSON Schema accepts and rejects the inputs the shell would validate", async () => {
|
|
57
|
+
const manifest = await described;
|
|
58
|
+
const validate = new Ajv2020({ strict: false }).compile(manifest.input);
|
|
59
|
+
|
|
60
|
+
expect(validate({ prompt: "hi", repoPath: "/tmp/work" })).toBe(true);
|
|
61
|
+
expect(validate({ prompt: " ", repoPath: "/tmp/work" })).toBe(false);
|
|
62
|
+
expect(validate({})).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// ABOUTME: TypeScript build config for the workflow template: strict NodeNext options written out in full
|
|
2
|
+
// ABOUTME: so a copy builds anywhere; compiles src into dist, which package.json's ligeti.entry names.
|
|
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
|
+
}
|