@clinebot/core 0.0.12 → 0.0.14

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.
@@ -16,6 +16,7 @@ import {
16
16
  EditFileInputSchema,
17
17
  type FetchWebContentInput,
18
18
  FetchWebContentInputSchema,
19
+ INPUT_ARG_CHAR_LIMIT,
19
20
  type ReadFileRequest,
20
21
  type ReadFilesInput,
21
22
  ReadFilesInputSchema,
@@ -57,6 +58,21 @@ function formatError(error: unknown): string {
57
58
  return String(error);
58
59
  }
59
60
 
61
+ function getEditorSizeError(input: EditFileInput): string | null {
62
+ if (
63
+ typeof input.old_text === "string" &&
64
+ input.old_text.length > INPUT_ARG_CHAR_LIMIT
65
+ ) {
66
+ return `Editor input too large: old_text was ${input.old_text.length} characters, exceeding the recommended limit of ${INPUT_ARG_CHAR_LIMIT}. Split the edit into smaller tool calls so later tool calls are less likely to be truncated or time out.`;
67
+ }
68
+
69
+ if (input.new_text.length > INPUT_ARG_CHAR_LIMIT) {
70
+ return `Editor input too large: new_text was ${input.new_text.length} characters, exceeding the recommended limit of ${INPUT_ARG_CHAR_LIMIT}. Split the edit into smaller tool calls so later tool calls are less likely to be truncated or time out.`;
71
+ }
72
+
73
+ return null;
74
+ }
75
+
60
76
  /**
61
77
  * Create a timeout-wrapped promise
62
78
  */
@@ -480,6 +496,16 @@ export function createEditorTool(
480
496
  execute: async (input, context) => {
481
497
  const validatedInput = validateWithZod(EditFileInputSchema, input);
482
498
  const operation = validatedInput.insert_line == null ? "edit" : "insert";
499
+ const sizeError = getEditorSizeError(validatedInput);
500
+
501
+ if (sizeError) {
502
+ return {
503
+ query: `${operation}:${validatedInput.path}`,
504
+ result: "",
505
+ error: sizeError,
506
+ success: false,
507
+ };
508
+ }
483
509
 
484
510
  try {
485
511
  const result = await withTimeout(
@@ -7,6 +7,8 @@
7
7
 
8
8
  import { z } from "zod";
9
9
 
10
+ export const INPUT_ARG_CHAR_LIMIT = 6000;
11
+
10
12
  /**
11
13
  * Schema for read tool input
12
14
  */
@@ -105,9 +107,8 @@ export const SearchCodebaseUnionInputSchema = z.union([
105
107
 
106
108
  const CommandInputSchema = z
107
109
  .string()
108
- .max(2000)
109
110
  .describe(
110
- "The non-interactive shell command to execute - MUST keep input short and concise to avoid timeouts",
111
+ `The non-interactive shell command to execute - MUST keep input short and concise (within ${INPUT_ARG_CHAR_LIMIT * 2} characters) to avoid timeouts.`,
111
112
  );
112
113
  /**
113
114
  * Schema for run_commands tool input
@@ -156,17 +157,15 @@ export const EditFileInputSchema = z
156
157
  .describe("The absolute file path for the action to be performed on"),
157
158
  old_text: z
158
159
  .string()
159
- .max(3000)
160
160
  .nullable()
161
161
  .optional()
162
162
  .describe(
163
- "Exact text to replace (must match exactly once). Omit this when creating a missing file or inserting via insert_line.",
163
+ `Exact text to replace (must match exactly once). Omit this when creating a missing file or inserting via insert_line. Keep this at or below ${INPUT_ARG_CHAR_LIMIT} characters when possible; larger payloads should be split across multiple tool calls to avoid timeouts.`,
164
164
  ),
165
165
  new_text: z
166
166
  .string()
167
- .max(3000)
168
167
  .describe(
169
- "The new content to write when creating a missing file, the replacement text for edits, or the inserted text when insert_line is provided - IMPORTANT: keep this as small as possible to avoid timeouts. For large edits, use multiple calls with small chunks of new_text and precise old_text to iteratively edit the file.",
168
+ `The new content to write when creating a missing file, the replacement text for edits, or the inserted text when insert_line is provided. Keep this at or below ${INPUT_ARG_CHAR_LIMIT} characters when possible; for large edits, use multiple calls with small chunks of old_text and new_text to iteratively edit the file.`,
170
169
  ),
171
170
  insert_line: z
172
171
  .number()