-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathgetDiff.ts
More file actions
40 lines (35 loc) · 1.12 KB
/
getDiff.ts
File metadata and controls
40 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { getDiff, GetDiffResult } from '@/features/git';
import { getDiffRequestSchema } from '@/features/git/schemas';
import { isServiceError } from '@/lib/utils';
import description from './getDiff.txt';
import { logger } from './logger';
import { ToolDefinition } from './types';
export type GetDiffMetadata = GetDiffResult & {
repo: string;
base: string;
head: string;
};
export const getDiffDefinition: ToolDefinition<'get_diff', typeof getDiffRequestSchema.shape, GetDiffMetadata> = {
name: 'get_diff',
title: 'Get diff',
isReadOnly: true,
isIdempotent: true,
description,
inputSchema: getDiffRequestSchema,
execute: async ({ repo, base, head }, _context) => {
logger.debug('get_diff', { repo, base, head });
const response = await getDiff({ repo, base, head });
if (isServiceError(response)) {
throw new Error(response.message);
}
return {
output: JSON.stringify(response),
metadata: {
...response,
repo,
base,
head,
},
};
},
};