@fungi.computer/computer 0.18.4 → 0.18.5
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/files-patch.js +15 -1
- package/package.json +1 -1
package/dist/files-patch.js
CHANGED
|
@@ -59,7 +59,21 @@ const nativePatch = {
|
|
|
59
59
|
cwd: workspaceRoot,
|
|
60
60
|
timeoutMs: 30_000,
|
|
61
61
|
mismatchExitCode: 23,
|
|
62
|
+
formatExitCode: 24,
|
|
62
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* A patch the engine rejects as malformed (its format exit code) is often cut
|
|
66
|
+
* short or wrapped. Quote the received last line so the Agent can fix the patch
|
|
67
|
+
* instead of guessing at what the engine saw.
|
|
68
|
+
*/
|
|
69
|
+
function withReceivedLastLine(stderr, patch, exitCode) {
|
|
70
|
+
if (exitCode !== nativePatch.formatExitCode)
|
|
71
|
+
return stderr;
|
|
72
|
+
const lines = patch.trim().split("\n");
|
|
73
|
+
const last = (lines.at(-1) ?? "").trim();
|
|
74
|
+
const shown = last.length > 80 ? `${last.slice(0, 80)}...` : last;
|
|
75
|
+
return `${stderr}\nThe patch you sent has ${String(lines.length)} lines and its last line is: ${JSON.stringify(shown)}. A patch ends with a line that is exactly *** End Patch, and every file line inside it starts with +, - or a space.\n`;
|
|
76
|
+
}
|
|
63
77
|
/** Await Workspace synchronization even when the native engine reports a partial failure. */
|
|
64
78
|
export async function applyWorkspacePatch(workspace, backend, input) {
|
|
65
79
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
@@ -77,7 +91,7 @@ export async function applyWorkspacePatch(workspace, backend, input) {
|
|
|
77
91
|
const stdout = boundExecStream(result.stdout, "stdout");
|
|
78
92
|
const stderr = boundExecStream(synchronizationFailure !== null
|
|
79
93
|
? `${result.stderr}\nPatch filesystem synchronization failed: ${synchronizationFailure}. Earlier patch writes may remain.`
|
|
80
|
-
: result.stderr, "stderr");
|
|
94
|
+
: withReceivedLastLine(result.stderr, patch, result.exitCode), "stderr");
|
|
81
95
|
const output = {
|
|
82
96
|
status: synchronizationFailure !== null ? "failed" : result.status,
|
|
83
97
|
exitCode: synchronizationFailure !== null && result.exitCode === 0
|