ci: add typechecking, fail fast in CI, and patch typechecking errors (#63)

This commit is contained in:
Charles Packer
2025-11-04 11:50:07 -08:00
committed by GitHub
parent 42eb671bf4
commit cf73f3a11f
27 changed files with 183 additions and 69 deletions

View File

@@ -11,8 +11,8 @@ describe("Bash background tools", () => {
run_in_background: true,
});
expect(result.content[0].text).toContain("background with ID:");
expect(result.content[0].text).toMatch(/bash_\d+/);
expect(result.content[0]?.text).toContain("background with ID:");
expect(result.content[0]?.text).toMatch(/bash_\d+/);
});
test("BashOutput retrieves output from background shell", async () => {
@@ -24,7 +24,7 @@ describe("Bash background tools", () => {
});
// Extract bash_id from the response text
const match = startResult.content[0].text.match(/bash_(\d+)/);
const match = startResult.content[0]?.text.match(/bash_(\d+)/);
expect(match).toBeDefined();
const bashId = `bash_${match?.[1]}`;
@@ -51,7 +51,7 @@ describe("Bash background tools", () => {
run_in_background: true,
});
const match = startResult.content[0].text.match(/bash_(\d+)/);
const match = startResult.content[0]?.text.match(/bash_(\d+)/);
const bashId = `bash_${match?.[1]}`;
// Kill it (KillBash uses shell_id parameter)

View File

@@ -9,7 +9,7 @@ describe("Bash tool", () => {
});
expect(result.content).toBeDefined();
expect(result.content[0].text).toContain("Hello, World!");
expect(result.content[0]?.text).toContain("Hello, World!");
expect(result.isError).toBeUndefined();
});
@@ -19,7 +19,7 @@ describe("Bash tool", () => {
description: "Test stderr",
});
expect(result.content[0].text).toContain("error message");
expect(result.content[0]?.text).toContain("error message");
});
test("returns error for failed command", async () => {
@@ -29,7 +29,7 @@ describe("Bash tool", () => {
});
expect(result.isError).toBe(true);
expect(result.content[0].text).toContain("Exit code");
expect(result.content[0]?.text).toContain("Exit code");
});
test("times out long-running command", async () => {
@@ -40,7 +40,7 @@ describe("Bash tool", () => {
});
expect(result.isError).toBe(true);
expect(result.content[0].text).toContain("timed out");
expect(result.content[0]?.text).toContain("timed out");
}, 2000);
test("runs command in background mode", async () => {
@@ -50,8 +50,8 @@ describe("Bash tool", () => {
run_in_background: true,
});
expect(result.content[0].text).toContain("background with ID:");
expect(result.content[0].text).toMatch(/bash_\d+/);
expect(result.content[0]?.text).toContain("background with ID:");
expect(result.content[0]?.text).toMatch(/bash_\d+/);
});
test("handles complex commands with pipes", async () => {
@@ -65,8 +65,8 @@ describe("Bash tool", () => {
description: "Test pipe",
});
expect(result.content[0].text).toContain("bar");
expect(result.content[0].text).not.toContain("foo");
expect(result.content[0]?.text).toContain("bar");
expect(result.content[0]?.text).not.toContain("foo");
});
test("lists background processes with /bashes command", async () => {
@@ -76,7 +76,7 @@ describe("Bash tool", () => {
});
expect(result.content).toBeDefined();
expect(result.content[0].text).toBeDefined();
expect(result.content[0]?.text).toBeDefined();
});
test("throws error when command is missing", async () => {

View File

@@ -108,7 +108,7 @@ describe("Edit tool", () => {
file_path: file,
old_string: "World",
new_str: "Bun",
} as Parameters<typeof edit>[0]),
} as unknown as Parameters<typeof edit>[0]),
).rejects.toThrow(/missing required parameter.*new_string/);
});
});

View File

@@ -17,9 +17,9 @@ describe("LS tool", () => {
const result = await ls({ path: testDir.path });
expect(result.content[0].text).toContain("file1.txt");
expect(result.content[0].text).toContain("file2.txt");
expect(result.content[0].text).toContain("subdir/");
expect(result.content[0]?.text).toContain("file1.txt");
expect(result.content[0]?.text).toContain("file2.txt");
expect(result.content[0]?.text).toContain("subdir/");
});
test("shows directories with trailing slash", async () => {
@@ -29,8 +29,8 @@ describe("LS tool", () => {
const result = await ls({ path: testDir.path });
expect(result.content[0].text).toContain("folder/");
expect(result.content[0].text).toContain("file.txt");
expect(result.content[0]?.text).toContain("folder/");
expect(result.content[0]?.text).toContain("file.txt");
});
test("throws error for non-existent directory", async () => {
@@ -64,10 +64,10 @@ describe("LS tool", () => {
ignore: ["*.log", "node_modules"],
});
expect(result.content[0].text).toContain("file1.txt");
expect(result.content[0].text).toContain("important.txt");
expect(result.content[0].text).not.toContain("file2.log");
expect(result.content[0].text).not.toContain("node_modules");
expect(result.content[0]?.text).toContain("file1.txt");
expect(result.content[0]?.text).toContain("important.txt");
expect(result.content[0]?.text).not.toContain("file2.log");
expect(result.content[0]?.text).not.toContain("node_modules");
});
test("throws error when ignore is a string instead of array", async () => {

View File

@@ -96,7 +96,7 @@ describe("MultiEdit tool", () => {
multi_edit({
file_path: file,
edits: [
{ old_string: "foo", new_str: "baz" } as Parameters<
{ old_string: "foo", new_str: "baz" } as unknown as Parameters<
typeof multi_edit
>[0]["edits"][0],
],

View File

@@ -267,6 +267,7 @@ describe("tool truncation integration tests", () => {
const bashIdMatch = message.match(/with ID: (.+)/);
expect(bashIdMatch).toBeTruthy();
const bashId = bashIdMatch?.[1];
if (!bashId) throw new Error("bashId not found");
// Wait a bit for output to accumulate
await new Promise((resolve) => setTimeout(resolve, 100));