@hanhnd/agent-kit 1.0.7 → 1.0.8
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/dist/kit-server.js +23 -4
- package/dist/tools/integration.js +15 -3
- package/package.json +1 -1
package/dist/kit-server.js
CHANGED
|
@@ -21245,6 +21245,7 @@ function registerAgentTools(server2) {
|
|
|
21245
21245
|
}
|
|
21246
21246
|
|
|
21247
21247
|
// src/tools/integration.ts
|
|
21248
|
+
import { writeFileSync as writeFileSync3 } from "fs";
|
|
21248
21249
|
var BitbucketPrSchema = external_exports.object({
|
|
21249
21250
|
id: external_exports.number(),
|
|
21250
21251
|
title: external_exports.string(),
|
|
@@ -21435,14 +21436,32 @@ ${pr.description || "No description"}`;
|
|
|
21435
21436
|
if (includeDiff) {
|
|
21436
21437
|
const diffUrl = `https://api.bitbucket.org/2.0/repositories/${safeWs}/${safeRepo}/pullrequests/${prId}/diff`;
|
|
21437
21438
|
const diff = await callBitbucketDiffApi(diffUrl);
|
|
21438
|
-
const
|
|
21439
|
-
|
|
21440
|
-
|
|
21439
|
+
const DIFF_FILE_THRESHOLD = 5e4;
|
|
21440
|
+
if (diff.length < DIFF_FILE_THRESHOLD) {
|
|
21441
|
+
output += `
|
|
21441
21442
|
|
|
21442
21443
|
### Diff
|
|
21443
21444
|
\`\`\`diff
|
|
21444
|
-
${
|
|
21445
|
+
${diff}
|
|
21445
21446
|
\`\`\``;
|
|
21447
|
+
} else {
|
|
21448
|
+
const filePath = `/tmp/kit-pr-${prId}-${Date.now()}.diff`;
|
|
21449
|
+
try {
|
|
21450
|
+
writeFileSync3(filePath, diff, "utf8");
|
|
21451
|
+
output += `
|
|
21452
|
+
|
|
21453
|
+
### Diff
|
|
21454
|
+
Diff is large (${diff.length} chars). Full diff written to: \`${filePath}\`. Read this file before reviewing.`;
|
|
21455
|
+
} catch {
|
|
21456
|
+
output += `
|
|
21457
|
+
|
|
21458
|
+
### Diff
|
|
21459
|
+
\u26A0\uFE0F Could not write diff to temp file. Showing inline (may be very large).
|
|
21460
|
+
\`\`\`diff
|
|
21461
|
+
${diff}
|
|
21462
|
+
\`\`\``;
|
|
21463
|
+
}
|
|
21464
|
+
}
|
|
21446
21465
|
}
|
|
21447
21466
|
return { content: [{ type: "text", text: output }] };
|
|
21448
21467
|
} catch (error2) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Integration Tools - Bitbucket, Jira
|
|
3
3
|
* Tools: kit_get_bitbucket_pr, kit_jira_get_ticket
|
|
4
4
|
*/
|
|
5
|
+
import { writeFileSync } from 'fs';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { sanitize } from './security.js';
|
|
7
8
|
// Zod schema for Bitbucket PR REST API response
|
|
@@ -214,9 +215,20 @@ ${pr.description || 'No description'}`;
|
|
|
214
215
|
if (includeDiff) {
|
|
215
216
|
const diffUrl = `https://api.bitbucket.org/2.0/repositories/${safeWs}/${safeRepo}/pullrequests/${prId}/diff`;
|
|
216
217
|
const diff = await callBitbucketDiffApi(diffUrl);
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
const DIFF_FILE_THRESHOLD = 50_000;
|
|
219
|
+
if (diff.length < DIFF_FILE_THRESHOLD) {
|
|
220
|
+
output += `\n\n### Diff\n\`\`\`diff\n${diff}\n\`\`\``;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
const filePath = `/tmp/kit-pr-${prId}-${Date.now()}.diff`;
|
|
224
|
+
try {
|
|
225
|
+
writeFileSync(filePath, diff, 'utf8');
|
|
226
|
+
output += `\n\n### Diff\nDiff is large (${diff.length} chars). Full diff written to: \`${filePath}\`. Read this file before reviewing.`;
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
output += `\n\n### Diff\n⚠️ Could not write diff to temp file. Showing inline (may be very large).\n\`\`\`diff\n${diff}\n\`\`\``;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
220
232
|
}
|
|
221
233
|
return { content: [{ type: 'text', text: output }] };
|
|
222
234
|
}
|