@spotpatch/agent 1.2.3 → 1.2.4
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/README.md +2 -1
- package/dist/index.cjs +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1848,7 +1848,7 @@ var AGENT_TOOL_DEFINITIONS = Object.freeze([
|
|
|
1848
1848
|
}),
|
|
1849
1849
|
Object.freeze({
|
|
1850
1850
|
name: AGENT_TOOL_NAMES.readFile,
|
|
1851
|
-
description: "Read a bounded inclusive line range from one allowed UTF-8 text file.",
|
|
1851
|
+
description: "Read a bounded inclusive line range from one allowed UTF-8 text file. Choose paths returned by list_files or search_text. A retryable TOOL_PATH_DENIED result means no file was read or changed: do not retry that path; discover an allowed path instead.",
|
|
1852
1852
|
parameters: Object.freeze({
|
|
1853
1853
|
type: "object",
|
|
1854
1854
|
properties: Object.freeze({
|
|
@@ -1994,6 +1994,14 @@ function retryableArgumentsRejection() {
|
|
|
1994
1994
|
guidance: "No files changed. Retry once with a new tool call ID and only the declared fields and value types."
|
|
1995
1995
|
});
|
|
1996
1996
|
}
|
|
1997
|
+
function retryableReadRejection() {
|
|
1998
|
+
return Object.freeze({
|
|
1999
|
+
errorCode: ERROR_CODES15.TOOL_PATH_DENIED,
|
|
2000
|
+
retryable: true,
|
|
2001
|
+
reason: "PATH_UNAVAILABLE",
|
|
2002
|
+
guidance: "No file was read or changed. Do not retry the same path. Use list_files or search_text, then read only an allowed path returned by that tool. Protected, external, missing, symlinked, directory, binary, and non-UTF-8 paths are unavailable."
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
1997
2005
|
function createAgentToolExecutor(options) {
|
|
1998
2006
|
const cacheByTurn = /* @__PURE__ */ new Map();
|
|
1999
2007
|
const fileCatalog = createAgentFileCatalog(options.worktreeRoot);
|
|
@@ -2093,7 +2101,15 @@ function createAgentToolExecutor(options) {
|
|
|
2093
2101
|
}
|
|
2094
2102
|
case AGENT_TOOL_NAMES.readFile: {
|
|
2095
2103
|
const input = parseArguments(readFileSchema, call.arguments);
|
|
2096
|
-
|
|
2104
|
+
let file;
|
|
2105
|
+
try {
|
|
2106
|
+
file = await readTextFile(input.path);
|
|
2107
|
+
} catch (error) {
|
|
2108
|
+
if (error instanceof SpotPatchError15 && error.code === ERROR_CODES15.TOOL_PATH_DENIED) {
|
|
2109
|
+
return retryableReadRejection();
|
|
2110
|
+
}
|
|
2111
|
+
throw error;
|
|
2112
|
+
}
|
|
2097
2113
|
const lines = file.content.split(/\r?\n/u);
|
|
2098
2114
|
const startLine = input.startLine ?? 1;
|
|
2099
2115
|
const endLine = input.endLine ?? Math.min(lines.length, startLine + 199);
|
|
@@ -2853,6 +2869,7 @@ Follow these rules exactly:
|
|
|
2853
2869
|
- Every patch must begin with 'diff --git a/<path> b/<path>', include matching '--- a/<path>' and '+++ b/<path>' headers and valid '@@' hunks. Send only the raw diff: no Markdown fences, prose, shell commands, or '*** Begin Patch' markers.
|
|
2854
2870
|
- If a write tool returns a retryable PATCH_REJECTED result, no file changed. Follow its guidance, re-read the current file, and retry once with a new tool call ID.
|
|
2855
2871
|
- If any tool returns a retryable TOOL_ARGUMENTS_INVALID result, no file changed. Retry once with a new tool call ID using only the declared fields and value types.
|
|
2872
|
+
- If read_file returns a retryable TOOL_PATH_DENIED result, no file was read or changed. Do not retry that path. Use list_files or search_text and choose an allowed path returned by the tool; never probe protected, external, generated, credential, environment, or lock files.
|
|
2856
2873
|
- Never modify credentials, environment files, lockfiles, generated output, Git metadata, or dependencies.
|
|
2857
2874
|
- Run each relevant configured check after the final write so failures can be corrected. Do not rerun an unchanged check, and do not claim a check passed unless run_check returned a passed status.
|
|
2858
2875
|
- Finish with a concise factual summary after all needed tool calls. Do not include secrets or absolute paths.`;
|
|
@@ -3085,7 +3102,7 @@ function isRetryableToolFailure(result) {
|
|
|
3085
3102
|
return false;
|
|
3086
3103
|
}
|
|
3087
3104
|
const candidate = output;
|
|
3088
|
-
return candidate.retryable === true && (candidate.errorCode === ERROR_CODES19.PATCH_REJECTED || candidate.errorCode === ERROR_CODES19.TOOL_ARGUMENTS_INVALID);
|
|
3105
|
+
return candidate.retryable === true && (candidate.errorCode === ERROR_CODES19.PATCH_REJECTED || candidate.errorCode === ERROR_CODES19.TOOL_ARGUMENTS_INVALID || candidate.errorCode === ERROR_CODES19.TOOL_PATH_DENIED);
|
|
3089
3106
|
}
|
|
3090
3107
|
function throwIfCancelled(signal) {
|
|
3091
3108
|
if (signal.aborted) {
|