Skip to content

Commit e255c6f

Browse files
committed
fix: ensure results are arrays for applicable tools
1 parent d5ba7ce commit e255c6f

File tree

6 files changed

+45
-48
lines changed

6 files changed

+45
-48
lines changed

src/tools/listMobSessionCoauthorTrailers.test.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ describe("[tools] listMobSessionCoauthorTrailers", () => {
5555
expect(listMobSessionCoauthorTrailers).toHaveBeenCalledWith();
5656
expect(result).toEqual({
5757
isError: false,
58-
content: [{ type: "text", text: trailers }],
58+
content: [
59+
{ type: "text", text: "Co-authored-by: John Doe <john@example.com>" },
60+
{
61+
type: "text",
62+
text: "Co-authored-by: Jane Smith <jane@example.com>",
63+
},
64+
],
5965
});
6066
});
6167

@@ -74,20 +80,5 @@ describe("[tools] listMobSessionCoauthorTrailers", () => {
7480
content: [{ type: "text", text: errorMessage }],
7581
});
7682
});
77-
78-
it("should handle null/undefined value by returning empty string", async () => {
79-
mockListMobSessionCoauthorTrailers.mockResolvedValueOnce({
80-
ok: true,
81-
value: null,
82-
});
83-
84-
const result = await tool.callback({});
85-
86-
expect(listMobSessionCoauthorTrailers).toHaveBeenCalledWith();
87-
expect(result).toEqual({
88-
isError: false,
89-
content: [{ type: "text", text: "" }],
90-
});
91-
});
9283
});
9384
});

src/tools/listMobSessionCoauthorTrailers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ const annotations: ToolAnnotations = {
2323

2424
const callback: ToolCallback<typeof inputSchema> = async () => {
2525
const { ok, value } = await listMobSessionCoauthorTrailers();
26-
return { isError: !ok, content: [{ type: "text", text: value || "" }] };
26+
27+
if (!ok) {
28+
return { isError: true, content: [{ type: "text", text: value }] };
29+
}
30+
31+
const lines = value.split("\n").filter((line) => line.trim() !== "");
32+
return {
33+
isError: false,
34+
content: lines.map((line) => ({ type: "text", text: line })),
35+
};
2736
};
2837

2938
const tool: GitMobTool<typeof inputSchema, Record<string, never>> = {

src/tools/listMobSessionCoauthors.test.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ describe("[tools] listMobSessionCoauthors", () => {
5353
expect(listMobSessionCoauthors).toHaveBeenCalledWith();
5454
expect(result).toEqual({
5555
isError: false,
56-
content: [{ type: "text", text: coauthors }],
56+
content: [
57+
{ type: "text", text: "john John Doe john@example.com" },
58+
{ type: "text", text: "jane Jane Smith jane@example.com" },
59+
],
5760
});
5861
});
5962

@@ -72,20 +75,5 @@ describe("[tools] listMobSessionCoauthors", () => {
7275
content: [{ type: "text", text: errorMessage }],
7376
});
7477
});
75-
76-
it("should handle null/undefined value by returning empty string", async () => {
77-
mockListMobSessionCoauthors.mockResolvedValueOnce({
78-
ok: true,
79-
value: null,
80-
});
81-
82-
const result = await tool.callback({});
83-
84-
expect(listMobSessionCoauthors).toHaveBeenCalledWith();
85-
expect(result).toEqual({
86-
isError: false,
87-
content: [{ type: "text", text: "" }],
88-
});
89-
});
9078
});
9179
});

src/tools/listMobSessionCoauthors.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ const annotations: ToolAnnotations = {
2222

2323
const callback: ToolCallback<typeof inputSchema> = async () => {
2424
const { ok, value } = await listMobSessionCoauthors();
25-
return { isError: !ok, content: [{ type: "text", text: value || "" }] };
25+
26+
if (!ok) {
27+
return { isError: true, content: [{ type: "text", text: value }] };
28+
}
29+
30+
const lines = value.split("\n").filter((line) => line.trim() !== "");
31+
return {
32+
isError: false,
33+
content: lines.map((line) => ({ type: "text", text: line })),
34+
};
2635
};
2736

2837
const tool: GitMobTool<typeof inputSchema, Record<string, never>> = {

src/tools/listTeamMembers.test.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ describe("[tools] listTeamMembers", () => {
5151
expect(listCoauthors).toHaveBeenCalledWith();
5252
expect(result).toEqual({
5353
isError: false,
54-
content: [{ type: "text", text: teamMembers }],
54+
content: [
55+
{ type: "text", text: "john John Doe john@example.com" },
56+
{ type: "text", text: "jane Jane Smith jane@example.com" },
57+
],
5558
});
5659
});
5760

@@ -70,17 +73,5 @@ describe("[tools] listTeamMembers", () => {
7073
content: [{ type: "text", text: errorMessage }],
7174
});
7275
});
73-
74-
it("should handle null/undefined value by returning empty string", async () => {
75-
mockListCoauthors.mockResolvedValueOnce({ ok: true, value: null });
76-
77-
const result = await tool.callback({});
78-
79-
expect(listCoauthors).toHaveBeenCalledWith();
80-
expect(result).toEqual({
81-
isError: false,
82-
content: [{ type: "text", text: "" }],
83-
});
84-
});
8576
});
8677
});

src/tools/listTeamMembers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ const annotations: ToolAnnotations = {
2323

2424
const callback: ToolCallback<typeof inputSchema> = async () => {
2525
const { ok, value } = await listCoauthors();
26-
return { isError: !ok, content: [{ type: "text", text: value || "" }] };
26+
27+
if (!ok) {
28+
return { isError: true, content: [{ type: "text", text: value }] };
29+
}
30+
31+
const lines = value.split("\n").filter((line) => line.trim() !== "");
32+
return {
33+
isError: false,
34+
content: lines.map((line) => ({ type: "text", text: line })),
35+
};
2736
};
2837

2938
const tool: GitMobTool<typeof inputSchema, Record<string, never>> = {

0 commit comments

Comments
 (0)