@testchimp/cli 0.1.71 → 0.1.73
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/chimphands/run.js +30 -9
- package/package.json +1 -1
package/dist/chimphands/run.js
CHANGED
|
@@ -1632,10 +1632,8 @@ async function ackWorktreeFileWrite(backend, apiKey, sessionId, requestId, ok, e
|
|
|
1632
1632
|
});
|
|
1633
1633
|
}
|
|
1634
1634
|
async function applyUserFileEdit(backend, apiKey, sessionId, edit, turnActive) {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
return;
|
|
1638
|
-
}
|
|
1635
|
+
// Never hard-nack mid-turn: write to disk immediately so the next agent prompt
|
|
1636
|
+
// sees the edit. Defer commit/push while a turn is active — post-turn always commits.
|
|
1639
1637
|
try {
|
|
1640
1638
|
const relative = normalizeWorktreeRelativePath(edit.path);
|
|
1641
1639
|
const root = process.cwd();
|
|
@@ -1646,6 +1644,11 @@ async function applyUserFileEdit(backend, apiKey, sessionId, edit, turnActive) {
|
|
|
1646
1644
|
}
|
|
1647
1645
|
await fs.mkdir(path.dirname(full), { recursive: true });
|
|
1648
1646
|
await fs.writeFile(full, edit.content, "utf8");
|
|
1647
|
+
if (turnActive()) {
|
|
1648
|
+
console.error(`ChimpHands applied user_file_edit mid-turn (deferred commit): ${relative}`);
|
|
1649
|
+
await ackWorktreeFileWrite(backend, apiKey, sessionId, edit.requestId, true);
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1649
1652
|
const pushed = await commitAndPushDirtyWorktree("User Update");
|
|
1650
1653
|
if (!pushed.ok) {
|
|
1651
1654
|
await ackWorktreeFileWrite(backend, apiKey, sessionId, edit.requestId, false, pushed.error || "commit/push failed");
|
|
@@ -2402,11 +2405,9 @@ export async function runChimphands(opts) {
|
|
|
2402
2405
|
console.error(`ChimpHands turn-end reconcile failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
2403
2406
|
}
|
|
2404
2407
|
}
|
|
2405
|
-
//
|
|
2406
|
-
//
|
|
2407
|
-
|
|
2408
|
-
await commitAndPushDirtyWorktree("chimphands: commit after turn (async / no UI attached)");
|
|
2409
|
-
}
|
|
2408
|
+
// Always checkpoint dirty worktree after each turn so PR + Files pane
|
|
2409
|
+
// (GitHub compare) stay current whether or not a browser UI is attached.
|
|
2410
|
+
await commitAndPushDirtyWorktree("chimphands: commit after turn");
|
|
2410
2411
|
if (attachUrl && opencodeSessionId && midTurnInjectedById.size) {
|
|
2411
2412
|
try {
|
|
2412
2413
|
await releaseUnansweredMidTurnMessages(attachUrl, opencodeSessionId, midTurnInjectedById, queue, wakePromptWaiter, midTurnSidecarAnswered);
|
|
@@ -2681,11 +2682,31 @@ function startTunnelWorker(backend, apiKey, runtimeId, attachUrl, sessionId, han
|
|
|
2681
2682
|
}
|
|
2682
2683
|
};
|
|
2683
2684
|
try {
|
|
2685
|
+
// Prefer JSON for workspace-scoped APIs — OpenCode SPA fallback is text/html.
|
|
2686
|
+
if (opencodeProxyNeedsDirectory(pathPart) && !headers.Accept && !headers.accept) {
|
|
2687
|
+
headers.Accept = "application/json";
|
|
2688
|
+
}
|
|
2684
2689
|
const upstream = await fetch(target, init);
|
|
2685
2690
|
const respHeaders = {};
|
|
2686
2691
|
upstream.headers.forEach((v, k) => {
|
|
2687
2692
|
respHeaders[k] = v;
|
|
2688
2693
|
});
|
|
2694
|
+
const contentType = String(respHeaders["content-type"] || respHeaders["Content-Type"] || "").toLowerCase();
|
|
2695
|
+
// Root-cause: never tunnel OpenCode SPA HTML as a successful VCS/API response.
|
|
2696
|
+
if (opencodeProxyNeedsDirectory(pathPart) &&
|
|
2697
|
+
contentType.includes("text/html")) {
|
|
2698
|
+
const msg = `OpenCode returned HTML SPA shell for ${pathPart} ` +
|
|
2699
|
+
"(expected JSON API; check directory routing / API path)";
|
|
2700
|
+
console.error(`ChimpHands ${msg}`);
|
|
2701
|
+
send({
|
|
2702
|
+
type: "http_response",
|
|
2703
|
+
requestId,
|
|
2704
|
+
status: 502,
|
|
2705
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
2706
|
+
bodyBase64: Buffer.from(msg, "utf8").toString("base64"),
|
|
2707
|
+
});
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2689
2710
|
send({
|
|
2690
2711
|
type: "http_response_start",
|
|
2691
2712
|
requestId,
|
package/package.json
CHANGED