@testchimp/cli 0.1.68 → 0.1.69
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 +32 -17
- package/package.json +1 -1
package/dist/chimphands/run.js
CHANGED
|
@@ -1537,6 +1537,11 @@ async function applyUserFileEdit(backend, apiKey, sessionId, edit, turnActive) {
|
|
|
1537
1537
|
}
|
|
1538
1538
|
await fs.mkdir(path.dirname(full), { recursive: true });
|
|
1539
1539
|
await fs.writeFile(full, edit.content, "utf8");
|
|
1540
|
+
const pushed = await commitAndPushDirtyWorktree("User Update");
|
|
1541
|
+
if (!pushed.ok) {
|
|
1542
|
+
await ackWorktreeFileWrite(backend, apiKey, sessionId, edit.requestId, false, pushed.error || "commit/push failed");
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1540
1545
|
await ackWorktreeFileWrite(backend, apiKey, sessionId, edit.requestId, true);
|
|
1541
1546
|
}
|
|
1542
1547
|
catch (err) {
|
|
@@ -2365,26 +2370,30 @@ async function commitAndPushDirtyWorktree(message) {
|
|
|
2365
2370
|
try {
|
|
2366
2371
|
const branch = await run(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
2367
2372
|
if (branch.code !== 0) {
|
|
2368
|
-
|
|
2369
|
-
|
|
2373
|
+
const error = branch.err || branch.out || "git rev-parse failed";
|
|
2374
|
+
console.error(`ChimpHands git rev-parse failed: ${error}`);
|
|
2375
|
+
return { ok: false, error };
|
|
2370
2376
|
}
|
|
2371
2377
|
const current = branch.out.trim();
|
|
2372
2378
|
if (!current || current === "HEAD" || /^(main|master)$/i.test(current)) {
|
|
2373
|
-
|
|
2374
|
-
|
|
2379
|
+
const error = `refusing branch "${current || "(unknown)"}"`;
|
|
2380
|
+
console.error(`ChimpHands skip commit-before-idle: ${error}`);
|
|
2381
|
+
return { ok: false, error };
|
|
2375
2382
|
}
|
|
2376
2383
|
const status = await run(["status", "--porcelain"]);
|
|
2377
2384
|
if (status.code !== 0) {
|
|
2378
|
-
|
|
2379
|
-
|
|
2385
|
+
const error = status.err || status.out || "git status failed";
|
|
2386
|
+
console.error(`ChimpHands git status failed: ${error}`);
|
|
2387
|
+
return { ok: false, error };
|
|
2380
2388
|
}
|
|
2381
2389
|
if (!status.out.trim()) {
|
|
2382
|
-
return;
|
|
2390
|
+
return { ok: true };
|
|
2383
2391
|
}
|
|
2384
2392
|
const add = await run(["add", "-A"]);
|
|
2385
2393
|
if (add.code !== 0) {
|
|
2386
|
-
|
|
2387
|
-
|
|
2394
|
+
const error = add.err || add.out || "git add failed";
|
|
2395
|
+
console.error(`ChimpHands git add failed: ${error}`);
|
|
2396
|
+
return { ok: false, error };
|
|
2388
2397
|
}
|
|
2389
2398
|
const commitEnv = {
|
|
2390
2399
|
GIT_AUTHOR_NAME: process.env.GIT_AUTHOR_NAME || "ChimpHands",
|
|
@@ -2394,8 +2403,9 @@ async function commitAndPushDirtyWorktree(message) {
|
|
|
2394
2403
|
};
|
|
2395
2404
|
const commit = await run(["-c", "user.name=ChimpHands", "-c", "user.email=chimphands@testchimp.io", "commit", "-m", message], commitEnv);
|
|
2396
2405
|
if (commit.code !== 0) {
|
|
2397
|
-
|
|
2398
|
-
|
|
2406
|
+
const error = commit.err || commit.out || "git commit failed";
|
|
2407
|
+
console.error(`ChimpHands git commit: ${error}`);
|
|
2408
|
+
return { ok: false, error };
|
|
2399
2409
|
}
|
|
2400
2410
|
let push = await run(["push", "-u", "origin", "HEAD"]);
|
|
2401
2411
|
if (push.code !== 0) {
|
|
@@ -2408,23 +2418,28 @@ async function commitAndPushDirtyWorktree(message) {
|
|
|
2408
2418
|
await refreshGitAuth();
|
|
2409
2419
|
push = await run(["push", "-u", "origin", "HEAD"]);
|
|
2410
2420
|
if (push.code !== 0) {
|
|
2411
|
-
|
|
2412
|
-
|
|
2421
|
+
const error = push.err || push.out || "git push failed after refresh";
|
|
2422
|
+
console.error(`ChimpHands git push failed after refresh: ${error}`);
|
|
2423
|
+
return { ok: false, error };
|
|
2413
2424
|
}
|
|
2414
2425
|
}
|
|
2415
2426
|
else {
|
|
2416
|
-
return;
|
|
2427
|
+
return { ok: false, error: push.err || push.out || "git push failed" };
|
|
2417
2428
|
}
|
|
2418
2429
|
}
|
|
2419
2430
|
catch (refreshErr) {
|
|
2420
|
-
|
|
2421
|
-
|
|
2431
|
+
const error = refreshErr instanceof Error ? refreshErr.message : String(refreshErr);
|
|
2432
|
+
console.error(`ChimpHands refresh-git-auth after push failure: ${error}`);
|
|
2433
|
+
return { ok: false, error };
|
|
2422
2434
|
}
|
|
2423
2435
|
}
|
|
2424
2436
|
console.error(`ChimpHands committed and pushed dirty worktree on ${current} before shutdown`);
|
|
2437
|
+
return { ok: true };
|
|
2425
2438
|
}
|
|
2426
2439
|
catch (err) {
|
|
2427
|
-
|
|
2440
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
2441
|
+
console.error(`ChimpHands commit-before-idle failed: ${error}`);
|
|
2442
|
+
return { ok: false, error };
|
|
2428
2443
|
}
|
|
2429
2444
|
}
|
|
2430
2445
|
function opencodeProxyNeedsDirectory(path) {
|
package/package.json
CHANGED