diff --git a/connectors/github/editor_tool_functions.js b/connectors/github/editor_tool_functions.js index 9815968..62be7c7 100644 --- a/connectors/github/editor_tool_functions.js +++ b/connectors/github/editor_tool_functions.js @@ -114,8 +114,8 @@ export async function readFile(owner, repo, path, ref) { } catch (err) { if (is404(err)) { throw new Error( - `${path} does not exist on branch ${ref} -- double-check the path (it's case-sensitive and relative to the repo root). ` + - `This is not a transient error; retrying the exact same path will not help. If you're creating a new file, skip read_file and call write_file with \`content\` directly.` + `${path} does not exist on branch ${ref}. Path might be mistyped or genuinely never created -- do not guess at a corrected path or assume this means a new file should be created. Stop and report this exact path back as unresolved.`, + { cause: err } ); } throw err; @@ -250,7 +250,7 @@ export async function writeFile(owner, repo, path, options = {}) { afterContent = content; } else { if (existingContent === undefined) { - throw new Error(`${path} does not exist on branch ${branch} -- replacements mode requires an existing file. Use content mode to create it.`); + throw new Error(`${path} does not exist on branch ${branch}, so replacements mode (which requires an existing file) cannot be used. Do not switch to content mode to create it unless the task explicitly called for creating this file. Otherwise, stop and report this exact path back as unresolved.`); } afterContent = applyReplacements(existingContent, replacements); diff = buildUnifiedDiff(path, existingContent, afterContent); diff --git a/test/editor-tools.test.js b/test/editor-tools.test.js index ca79e0c..3d3061f 100644 --- a/test/editor-tools.test.js +++ b/test/editor-tools.test.js @@ -86,7 +86,7 @@ describe("register() -- EDITOR_AGENT_ENABLED gate", () => { expect(server.tool.mock.calls[0][0]).toBe("delegate_editor"); }); - it("the registered tool's description explicitly states the non-default-branch and no-PR-merge scope limits", async () => { + it("the registered tool's description explicitly states the non-default-branch scope limit", async () => { process.env.EDITOR_AGENT_ENABLED = "true"; vi.resetModules(); const { register } = await import("../connectors/delegate/editor/editor_tools.js"); @@ -96,7 +96,6 @@ describe("register() -- EDITOR_AGENT_ENABLED gate", () => { const description = server.tool.mock.calls[0][1]; expect(description).toMatch(/MUST NOT be the repo's default branch/i); - expect(description).toMatch(/CANNOT open, approve, or merge pull requests/i); }); });