@empiricalrun/test-gen 0.48.1 → 0.49.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/CHANGELOG.md +7 -0
- package/dist/agent/chat.d.ts.map +1 -1
- package/dist/agent/chat.js +5 -3
- package/dist/tools/browser-agent.d.ts.map +1 -1
- package/dist/tools/browser-agent.js +21 -43
- package/dist/tools/codegen-agent.d.ts.map +1 -1
- package/dist/tools/codegen-agent.js +14 -30
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +9 -15
- package/dist/tools/grep.d.ts +3 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +62 -0
- package/dist/tools/test-run.d.ts.map +1 -1
- package/dist/tools/test-run.js +14 -28
- package/dist/tools/types.d.ts +36 -9
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +10 -0
- package/dist/tools/zod-schema.d.ts +19 -0
- package/dist/tools/zod-schema.d.ts.map +1 -0
- package/dist/tools/zod-schema.js +95 -0
- package/dist/utils/repo-tree.d.ts +1 -0
- package/dist/utils/repo-tree.d.ts.map +1 -1
- package/dist/utils/repo-tree.js +3 -3
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
package/dist/agent/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/agent/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA6D1D,wBAAsB,SAAS,CAAC,EAC9B,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/agent/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA6D1D,wBAAsB,SAAS,CAAC,EAC9B,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,8CAqEA"}
|
package/dist/agent/chat.js
CHANGED
|
@@ -9,7 +9,9 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const human_in_the_loop_1 = require("../human-in-the-loop");
|
|
10
10
|
const browser_agent_1 = require("../tools/browser-agent");
|
|
11
11
|
const diagnosis_fetcher_1 = require("../tools/diagnosis-fetcher");
|
|
12
|
+
const grep_1 = require("../tools/grep");
|
|
12
13
|
const test_run_1 = require("../tools/test-run");
|
|
14
|
+
const zod_schema_1 = require("../tools/zod-schema");
|
|
13
15
|
const repo_tree_1 = require("../utils/repo-tree");
|
|
14
16
|
const systemPrompt = `
|
|
15
17
|
You are a helpful assistant that can answer questions and help with tasks.
|
|
@@ -47,9 +49,9 @@ While specifying paths to files, use relative paths from the current working dir
|
|
|
47
49
|
- Correct path: "tests/lesson.spec.ts"
|
|
48
50
|
- Incorrect path: "/repo/tests/lesson.spec.ts" or "${path_1.default.basename(process.cwd())}/tests/lesson.spec.ts"
|
|
49
51
|
`;
|
|
50
|
-
const tools = [test_run_1.runTestTool, browser_agent_1.browserAgentTool, diagnosis_fetcher_1.diagnosisTool];
|
|
52
|
+
const tools = [test_run_1.runTestTool, browser_agent_1.browserAgentTool, diagnosis_fetcher_1.diagnosisTool, grep_1.grepTool];
|
|
51
53
|
const toolExecutors = {
|
|
52
|
-
...Object.fromEntries(tools.map((tool) => [tool.schema.
|
|
54
|
+
...Object.fromEntries(tools.map((tool) => [tool.schema.name, tool.execute])),
|
|
53
55
|
str_replace_editor: claude_1.strReplaceEditorTool,
|
|
54
56
|
};
|
|
55
57
|
async function chatAgent({ prompt, }) {
|
|
@@ -84,7 +86,7 @@ async function chatAgent({ prompt, }) {
|
|
|
84
86
|
continue;
|
|
85
87
|
}
|
|
86
88
|
const response = await (0, claude_1.createChatCompletion)(systemPrompt, chatState.getMessages(), [
|
|
87
|
-
...tools.map((tool) => (0, claude_1.convertOpenAISchemaToAnthropic)(tool.schema)),
|
|
89
|
+
...tools.map((tool) => (0, claude_1.convertOpenAISchemaToAnthropic)((0, zod_schema_1.zodToOpenAITool)(tool.schema))),
|
|
88
90
|
{
|
|
89
91
|
type: "text_editor_20250124",
|
|
90
92
|
name: "str_replace_editor",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-agent.d.ts","sourceRoot":"","sources":["../../src/tools/browser-agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser-agent.d.ts","sourceRoot":"","sources":["../../src/tools/browser-agent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAmDpC,eAAO,MAAM,gBAAgB,EAAE,IA6C9B,CAAC"}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.browserAgentTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
4
5
|
const run_1 = require("../agent/browsing/run");
|
|
5
6
|
const utils_1 = require("../agent/browsing/utils");
|
|
6
7
|
const scenarios_1 = require("../bin/utils/scenarios");
|
|
7
8
|
const git_1 = require("../utils/git");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const BrowserAgentSchema = zod_1.z.object({
|
|
10
|
+
testName: zod_1.z.string().describe("The name of the test to create or modify"),
|
|
11
|
+
testSuites: zod_1.z
|
|
12
|
+
.array(zod_1.z.string())
|
|
13
|
+
.describe("The suites (describe blocks) where the test is located"),
|
|
14
|
+
fileName: zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.describe("The name of the file where the test is located. File name must end with .spec.ts"),
|
|
17
|
+
project: zod_1.z
|
|
18
|
+
.string()
|
|
19
|
+
.describe("The Playwright project to run tests against (e.g. 'chromium' or 'firefox')"),
|
|
20
|
+
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
21
|
+
});
|
|
22
|
+
const BROWSER_AGENT_DESCRIPTION = `
|
|
14
23
|
Create or modify a test case with browser agent. The browser agent can take user interactions in a web browser
|
|
15
24
|
and generate Playwright code for that actions. This is a useful tool when the modifications require knowing the
|
|
16
25
|
locator/selector for an element on the page.
|
|
@@ -39,43 +48,12 @@ test("Example test code", async ({ page }) => {
|
|
|
39
48
|
await page.getByRole("button", { name: "Login" }).click();
|
|
40
49
|
});
|
|
41
50
|
\`\`\`
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
description: "The name of the test to create or modify",
|
|
49
|
-
},
|
|
50
|
-
testSuites: {
|
|
51
|
-
type: "array",
|
|
52
|
-
description: "The suites (describe blocks) where the test is located",
|
|
53
|
-
items: {
|
|
54
|
-
type: "string",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
fileName: {
|
|
58
|
-
type: "string",
|
|
59
|
-
description: "The name of the file where the test is located. File name must end with .spec.ts",
|
|
60
|
-
},
|
|
61
|
-
project: {
|
|
62
|
-
type: "string",
|
|
63
|
-
description: "The Playwright project to run tests against (e.g. 'chromium' or 'firefox')",
|
|
64
|
-
},
|
|
65
|
-
changeToMake: {
|
|
66
|
-
type: "string",
|
|
67
|
-
description: "The change to make to the test",
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
required: [
|
|
71
|
-
"testName",
|
|
72
|
-
"testSuites",
|
|
73
|
-
"fileName",
|
|
74
|
-
"changeToMake",
|
|
75
|
-
"project",
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
},
|
|
51
|
+
`;
|
|
52
|
+
exports.browserAgentTool = {
|
|
53
|
+
schema: {
|
|
54
|
+
name: "generateTestWithBrowserAgent",
|
|
55
|
+
description: BROWSER_AGENT_DESCRIPTION,
|
|
56
|
+
parameters: BrowserAgentSchema,
|
|
79
57
|
},
|
|
80
58
|
execute: async (input) => {
|
|
81
59
|
const { testName, testSuites, fileName, changeToMake, project } = input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-agent.d.ts","sourceRoot":"","sources":["../../src/tools/codegen-agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codegen-agent.d.ts","sourceRoot":"","sources":["../../src/tools/codegen-agent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAepC,eAAO,MAAM,WAAW,EAAE,IAyBzB,CAAC"}
|
|
@@ -1,39 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codegenTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
4
5
|
const run_1 = require("../agent/codegen/run");
|
|
6
|
+
const CodegenSchema = zod_1.z.object({
|
|
7
|
+
testName: zod_1.z.string().describe("The name of the test to create or modify"),
|
|
8
|
+
testSuites: zod_1.z
|
|
9
|
+
.array(zod_1.z.string())
|
|
10
|
+
.describe("The suites (describe blocks) where the test is located"),
|
|
11
|
+
fileName: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("The name of the file where the test is located. File name must end with .spec.ts"),
|
|
14
|
+
changeToMake: zod_1.z.string().describe("The change to make to the test"),
|
|
15
|
+
});
|
|
5
16
|
exports.codegenTool = {
|
|
6
17
|
schema: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
description: "Create or modify a test case with code generation. This is useful when modifications can be done with TypeScript only, and don't require any browser interactions or element selectors.",
|
|
11
|
-
parameters: {
|
|
12
|
-
type: "object",
|
|
13
|
-
properties: {
|
|
14
|
-
testName: {
|
|
15
|
-
type: "string",
|
|
16
|
-
description: "The name of the test to create or modify",
|
|
17
|
-
},
|
|
18
|
-
testSuites: {
|
|
19
|
-
type: "array",
|
|
20
|
-
description: "The suites (describe blocks) where the test is located",
|
|
21
|
-
items: {
|
|
22
|
-
type: "string",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
fileName: {
|
|
26
|
-
type: "string",
|
|
27
|
-
description: "The name of the file where the test is located. File name must end with .spec.ts",
|
|
28
|
-
},
|
|
29
|
-
changeToMake: {
|
|
30
|
-
type: "string",
|
|
31
|
-
description: "The change to make to the test",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
required: ["testName", "testSuites", "fileName", "changeToMake"],
|
|
35
|
-
},
|
|
36
|
-
},
|
|
18
|
+
name: "generateTestWithCodegen",
|
|
19
|
+
description: "Create or modify a test case with code generation. This is useful when modifications can be done with TypeScript only, and don't require any browser interactions or element selectors.",
|
|
20
|
+
parameters: CodegenSchema,
|
|
37
21
|
},
|
|
38
22
|
execute: async (input) => {
|
|
39
23
|
const { testName, testSuites, fileName, changeToMake } = input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnosis-fetcher.d.ts","sourceRoot":"","sources":["../../src/tools/diagnosis-fetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnosis-fetcher.d.ts","sourceRoot":"","sources":["../../src/tools/diagnosis-fetcher.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAUpC,eAAO,MAAM,aAAa,EAAE,IA+E3B,CAAC"}
|
|
@@ -6,23 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.diagnosisTool = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const DiagnosisSchema = zod_1.z.object({
|
|
11
|
+
diagnosisUrl: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("The full URL of the diagnosis (e.g. https://dash.empirical.run/shopflo-tests/diagnosis/split-cod-place-the-order--byynrPjCml57)"),
|
|
14
|
+
});
|
|
9
15
|
exports.diagnosisTool = {
|
|
10
16
|
schema: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
description: "Fetch details about a test case diagnosis using its URL or slug",
|
|
15
|
-
parameters: {
|
|
16
|
-
type: "object",
|
|
17
|
-
properties: {
|
|
18
|
-
diagnosisUrl: {
|
|
19
|
-
type: "string",
|
|
20
|
-
description: "The full URL of the diagnosis (e.g. https://dash.empirical.run/shopflo-tests/diagnosis/split-cod-place-the-order--byynrPjCml57)",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
required: ["diagnosisUrl"],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
17
|
+
name: "fetchDiagnosisDetails",
|
|
18
|
+
description: "Fetch details about a test case diagnosis using its URL or slug",
|
|
19
|
+
parameters: DiagnosisSchema,
|
|
26
20
|
},
|
|
27
21
|
execute: async (input) => {
|
|
28
22
|
const { diagnosisUrl } = input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAc,MAAM,SAAS,CAAC;AAgB3C,eAAO,MAAM,QAAQ,EAAE,IA+CtB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.grepTool = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const util_1 = require("util");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const repo_tree_1 = require("../utils/repo-tree");
|
|
8
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
9
|
+
const GrepInputSchema = zod_1.z.object({
|
|
10
|
+
pattern: zod_1.z.string().describe("The pattern to search for"),
|
|
11
|
+
directory: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("The directory to search in (defaults to current directory)"),
|
|
15
|
+
filePattern: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("File pattern to search in (e.g., '*.ts' for TypeScript files)"),
|
|
19
|
+
});
|
|
20
|
+
exports.grepTool = {
|
|
21
|
+
schema: {
|
|
22
|
+
name: "grep",
|
|
23
|
+
description: "Search for a pattern in files using grep (case insensitive)",
|
|
24
|
+
parameters: GrepInputSchema,
|
|
25
|
+
},
|
|
26
|
+
execute: async (input) => {
|
|
27
|
+
try {
|
|
28
|
+
const dir = input.directory || process.cwd();
|
|
29
|
+
// Create exclude pattern for grep
|
|
30
|
+
const excludePatterns = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
|
|
31
|
+
.map((pattern) => `--exclude-dir="${pattern}"`)
|
|
32
|
+
.join(" ");
|
|
33
|
+
// Using -n to show line numbers in output
|
|
34
|
+
let cmd = `grep -rin ${excludePatterns} "${input.pattern}" ${dir}`;
|
|
35
|
+
if (input.filePattern) {
|
|
36
|
+
// For file pattern searches, we'll use find with exclusions
|
|
37
|
+
const excludeFind = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
|
|
38
|
+
.map((pattern) => `-not -path "*/${pattern}/*"`)
|
|
39
|
+
.join(" ");
|
|
40
|
+
// Using -n to show line numbers and removed -l to show actual matches
|
|
41
|
+
cmd = `find ${dir} ${excludeFind} -name "${input.filePattern}" -exec grep -rin "${input.pattern}" {} \\;`;
|
|
42
|
+
}
|
|
43
|
+
const { stdout, stderr } = await execAsync(cmd);
|
|
44
|
+
if (stderr) {
|
|
45
|
+
return {
|
|
46
|
+
isError: true,
|
|
47
|
+
result: stderr,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
isError: false,
|
|
52
|
+
result: stdout,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
isError: true,
|
|
58
|
+
result: error instanceof Error ? error.message : String(error),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAepC,eAAO,MAAM,WAAW,EAAE,IAmBzB,CAAC"}
|
package/dist/tools/test-run.js
CHANGED
|
@@ -2,36 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTestTool = void 0;
|
|
4
4
|
const test_run_1 = require("@empiricalrun/test-run");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const RunTestSchema = zod_1.z.object({
|
|
7
|
+
testName: zod_1.z.string().describe("The name of the test to run"),
|
|
8
|
+
suites: zod_1.z
|
|
9
|
+
.array(zod_1.z.string())
|
|
10
|
+
.describe("The suites (describe blocks) where the test is located."),
|
|
11
|
+
fileName: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("The name of the file where the test is located. File name must end with .spec.ts"),
|
|
14
|
+
project: zod_1.z.string().describe("The project to run the test on"),
|
|
15
|
+
});
|
|
5
16
|
exports.runTestTool = {
|
|
6
17
|
schema: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
description: "Run a test",
|
|
11
|
-
parameters: {
|
|
12
|
-
type: "object",
|
|
13
|
-
properties: {
|
|
14
|
-
testName: {
|
|
15
|
-
type: "string",
|
|
16
|
-
description: "The name of the test to run",
|
|
17
|
-
},
|
|
18
|
-
suites: {
|
|
19
|
-
type: "array",
|
|
20
|
-
description: "The suites (describe blocks) where the test is located.",
|
|
21
|
-
items: { type: "string" },
|
|
22
|
-
},
|
|
23
|
-
fileName: {
|
|
24
|
-
type: "string",
|
|
25
|
-
description: "The name of the file where the test is located. File name must end with .spec.ts",
|
|
26
|
-
},
|
|
27
|
-
project: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "The project to run the test on",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
required: ["testName", "suites", "fileName", "project"],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
18
|
+
name: "runTest",
|
|
19
|
+
description: "Run a test",
|
|
20
|
+
parameters: RunTestSchema,
|
|
35
21
|
},
|
|
36
22
|
execute: async (input) => {
|
|
37
23
|
const { testName, suites, fileName, project } = input;
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Base schema for all tools. Each tool should extend this with their specific parameters.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BaseToolSchema: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
description: z.ZodString;
|
|
8
|
+
parameters: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
parameters: {} & {
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
}, {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
parameters: {} & {
|
|
19
|
+
[k: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export type ToolSchema = z.infer<typeof BaseToolSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Interface for creating a tool with its schema and execute function
|
|
25
|
+
*/
|
|
26
|
+
export interface Tool {
|
|
27
|
+
schema: {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
parameters: z.ZodType;
|
|
31
|
+
};
|
|
9
32
|
execute: (input: any) => Promise<ToolResult>;
|
|
10
|
-
}
|
|
33
|
+
}
|
|
34
|
+
export interface ToolResult {
|
|
35
|
+
isError: boolean;
|
|
36
|
+
result: string;
|
|
37
|
+
}
|
|
11
38
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC;KACvB,CAAC;IACF,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/tools/types.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseToolSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Base schema for all tools. Each tool should extend this with their specific parameters.
|
|
7
|
+
*/
|
|
8
|
+
exports.BaseToolSchema = zod_1.z.object({
|
|
9
|
+
name: zod_1.z.string(),
|
|
10
|
+
description: zod_1.z.string(),
|
|
11
|
+
parameters: zod_1.z.object({}).passthrough(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type OpenAI from "openai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a tool schema to OpenAI tool format
|
|
5
|
+
*/
|
|
6
|
+
export declare function zodToOpenAITool(schema: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
parameters: z.ZodType;
|
|
10
|
+
}): OpenAI.Chat.Completions.ChatCompletionTool;
|
|
11
|
+
/**
|
|
12
|
+
* Convert Zod schema to JSON Schema
|
|
13
|
+
*/
|
|
14
|
+
export declare function zodToJsonSchema(schema: z.ZodType): any;
|
|
15
|
+
/**
|
|
16
|
+
* Convert specific Zod type to JSON Schema
|
|
17
|
+
*/
|
|
18
|
+
export declare function zodTypeToJsonSchema(zodType: z.ZodType): any;
|
|
19
|
+
//# sourceMappingURL=zod-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-schema.d.ts","sourceRoot":"","sources":["../../src/tools/zod-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC;CACvB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAS7C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,GAAG,CAuBtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,GAAG,CAoD3D"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zodTypeToJsonSchema = exports.zodToJsonSchema = exports.zodToOpenAITool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Convert a tool schema to OpenAI tool format
|
|
7
|
+
*/
|
|
8
|
+
function zodToOpenAITool(schema) {
|
|
9
|
+
return {
|
|
10
|
+
type: "function",
|
|
11
|
+
function: {
|
|
12
|
+
name: schema.name,
|
|
13
|
+
description: schema.description,
|
|
14
|
+
parameters: zodToJsonSchema(schema.parameters),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.zodToOpenAITool = zodToOpenAITool;
|
|
19
|
+
/**
|
|
20
|
+
* Convert Zod schema to JSON Schema
|
|
21
|
+
*/
|
|
22
|
+
function zodToJsonSchema(schema) {
|
|
23
|
+
if (schema instanceof zod_1.z.ZodObject) {
|
|
24
|
+
const shape = schema._def.shape();
|
|
25
|
+
const properties = {};
|
|
26
|
+
const required = [];
|
|
27
|
+
Object.entries(shape).forEach(([key, value]) => {
|
|
28
|
+
properties[key] = zodTypeToJsonSchema(value);
|
|
29
|
+
// Check if this field is required
|
|
30
|
+
if (!(value instanceof zod_1.z.ZodOptional)) {
|
|
31
|
+
required.push(key);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties,
|
|
37
|
+
...(required.length > 0 ? { required } : {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return { type: "string" }; // Fallback
|
|
41
|
+
}
|
|
42
|
+
exports.zodToJsonSchema = zodToJsonSchema;
|
|
43
|
+
/**
|
|
44
|
+
* Convert specific Zod type to JSON Schema
|
|
45
|
+
*/
|
|
46
|
+
function zodTypeToJsonSchema(zodType) {
|
|
47
|
+
// Handle string types
|
|
48
|
+
if (zodType instanceof zod_1.z.ZodString) {
|
|
49
|
+
const schema = { type: "string" };
|
|
50
|
+
if (zodType.description)
|
|
51
|
+
schema.description = zodType.description;
|
|
52
|
+
return schema;
|
|
53
|
+
}
|
|
54
|
+
// Handle number types
|
|
55
|
+
if (zodType instanceof zod_1.z.ZodNumber) {
|
|
56
|
+
const schema = { type: "number" };
|
|
57
|
+
if (zodType.description)
|
|
58
|
+
schema.description = zodType.description;
|
|
59
|
+
return schema;
|
|
60
|
+
}
|
|
61
|
+
// Handle boolean
|
|
62
|
+
if (zodType instanceof zod_1.z.ZodBoolean) {
|
|
63
|
+
const schema = { type: "boolean" };
|
|
64
|
+
if (zodType.description)
|
|
65
|
+
schema.description = zodType.description;
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
// Handle arrays
|
|
69
|
+
if (zodType instanceof zod_1.z.ZodArray) {
|
|
70
|
+
return {
|
|
71
|
+
type: "array",
|
|
72
|
+
items: zodTypeToJsonSchema(zodType._def.type),
|
|
73
|
+
...(zodType.description ? { description: zodType.description } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Handle objects
|
|
77
|
+
if (zodType instanceof zod_1.z.ZodObject) {
|
|
78
|
+
return zodToJsonSchema(zodType);
|
|
79
|
+
}
|
|
80
|
+
// Handle enums
|
|
81
|
+
if (zodType instanceof zod_1.z.ZodEnum) {
|
|
82
|
+
return {
|
|
83
|
+
type: "string",
|
|
84
|
+
enum: zodType._def.values,
|
|
85
|
+
...(zodType.description ? { description: zodType.description } : {}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Handle optional types
|
|
89
|
+
if (zodType instanceof zod_1.z.ZodOptional) {
|
|
90
|
+
return zodTypeToJsonSchema(zodType._def.innerType);
|
|
91
|
+
}
|
|
92
|
+
// Default fallback
|
|
93
|
+
return { type: "string" };
|
|
94
|
+
}
|
|
95
|
+
exports.zodTypeToJsonSchema = zodTypeToJsonSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-tree.d.ts","sourceRoot":"","sources":["../../src/utils/repo-tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repo-tree.d.ts","sourceRoot":"","sources":["../../src/utils/repo-tree.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,qBAO3B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,UAsE9D"}
|
package/dist/utils/repo-tree.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateAsciiTree = void 0;
|
|
6
|
+
exports.generateAsciiTree = exports.DEFAULT_EXCLUDE = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
|
|
9
|
+
exports.DEFAULT_EXCLUDE = [
|
|
10
10
|
"node_modules",
|
|
11
11
|
"dist",
|
|
12
12
|
"build",
|
|
@@ -17,7 +17,7 @@ const DEFAULT_EXCLUDE = [
|
|
|
17
17
|
function generateAsciiTree(dirPath, options = {}) {
|
|
18
18
|
const defaultOptions = {
|
|
19
19
|
showHidden: false,
|
|
20
|
-
exclude: DEFAULT_EXCLUDE,
|
|
20
|
+
exclude: exports.DEFAULT_EXCLUDE,
|
|
21
21
|
maxDepth: 10,
|
|
22
22
|
};
|
|
23
23
|
const opts = { ...defaultOptions, ...options };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"ts-morph": "^23.0.0",
|
|
74
74
|
"tsx": "^4.16.2",
|
|
75
75
|
"typescript": "^5.3.3",
|
|
76
|
+
"zod": "^3.23.8",
|
|
76
77
|
"@empiricalrun/llm": "^0.10.1",
|
|
77
78
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
78
79
|
"@empiricalrun/reporter": "^0.23.1",
|