@ai-development-environment/control-agent 0.0.79 → 0.0.81
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/control-agent.js +313 -37
- package/package.json +1 -1
package/dist/control-agent.js
CHANGED
|
@@ -4184,7 +4184,7 @@ var require_cross_spawn = __commonJS({
|
|
|
4184
4184
|
var cp3 = __require("child_process");
|
|
4185
4185
|
var parse2 = require_parse();
|
|
4186
4186
|
var enoent = require_enoent();
|
|
4187
|
-
function
|
|
4187
|
+
function spawn9(command3, args, options) {
|
|
4188
4188
|
const parsed = parse2(command3, args, options);
|
|
4189
4189
|
const spawned = cp3.spawn(parsed.command, parsed.args, parsed.options);
|
|
4190
4190
|
enoent.hookChildProcess(spawned, parsed);
|
|
@@ -4196,8 +4196,8 @@ var require_cross_spawn = __commonJS({
|
|
|
4196
4196
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
4197
4197
|
return result;
|
|
4198
4198
|
}
|
|
4199
|
-
module.exports =
|
|
4200
|
-
module.exports.spawn =
|
|
4199
|
+
module.exports = spawn9;
|
|
4200
|
+
module.exports.spawn = spawn9;
|
|
4201
4201
|
module.exports.sync = spawnSync2;
|
|
4202
4202
|
module.exports._parse = parse2;
|
|
4203
4203
|
module.exports._enoent = enoent;
|
|
@@ -6106,6 +6106,7 @@ function codebaseGitOperationPayload(value) {
|
|
|
6106
6106
|
// ../agent-contract/src/worktrees.ts
|
|
6107
6107
|
var WORKTREE_INSPECT_JOB_KIND = "worktree.inspect";
|
|
6108
6108
|
var WORKTREE_OPERATION_JOB_KIND = "worktree.operation";
|
|
6109
|
+
var WORKTREE_COMMIT_JOB_KIND = "worktree.commit";
|
|
6109
6110
|
var WORKTREE_AUTO_SYNC_JOB_KIND = "worktree.auto-sync";
|
|
6110
6111
|
var WORKTREE_GIT_INSPECT_JOB_KIND = "worktree.git.inspect";
|
|
6111
6112
|
var WORKTREE_GIT_OPERATION_JOB_KIND = "worktree.git.operation";
|
|
@@ -6119,6 +6120,7 @@ var WORKTREE_DIFF_ASSET_JOB_KIND = "worktree.diff.asset";
|
|
|
6119
6120
|
var WORKTREE_JOB_KINDS = [
|
|
6120
6121
|
WORKTREE_INSPECT_JOB_KIND,
|
|
6121
6122
|
WORKTREE_OPERATION_JOB_KIND,
|
|
6123
|
+
WORKTREE_COMMIT_JOB_KIND,
|
|
6122
6124
|
WORKTREE_AUTO_SYNC_JOB_KIND,
|
|
6123
6125
|
WORKTREE_GIT_INSPECT_JOB_KIND,
|
|
6124
6126
|
WORKTREE_GIT_OPERATION_JOB_KIND,
|
|
@@ -6145,6 +6147,7 @@ var WORKTREE_OPERATIONS = [
|
|
|
6145
6147
|
"SYNC",
|
|
6146
6148
|
"REBASE",
|
|
6147
6149
|
"CANCEL_REBASE",
|
|
6150
|
+
"PULL",
|
|
6148
6151
|
"PUSH",
|
|
6149
6152
|
"RESET",
|
|
6150
6153
|
"STASH_ALL",
|
|
@@ -6463,6 +6466,71 @@ function worktreeDeleteJobPayload(value) {
|
|
|
6463
6466
|
expectedHeadSha
|
|
6464
6467
|
};
|
|
6465
6468
|
}
|
|
6469
|
+
function worktreeCommitJobPayload(value) {
|
|
6470
|
+
const payload = objectValue4(value, "worktree commit payload");
|
|
6471
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
6472
|
+
"codebaseId",
|
|
6473
|
+
"folder",
|
|
6474
|
+
"gitDirectory",
|
|
6475
|
+
"expectedOrigin",
|
|
6476
|
+
"baseBranch",
|
|
6477
|
+
"message",
|
|
6478
|
+
"signed",
|
|
6479
|
+
"stageAll",
|
|
6480
|
+
"paths"
|
|
6481
|
+
]);
|
|
6482
|
+
const unexpected = Object.keys(payload).find((key) => !allowed.has(key));
|
|
6483
|
+
if (unexpected) {
|
|
6484
|
+
throw new Error(`Unexpected worktree commit payload field: ${unexpected}`);
|
|
6485
|
+
}
|
|
6486
|
+
const message = stringValue4(
|
|
6487
|
+
payload.message,
|
|
6488
|
+
"worktree commit payload.message"
|
|
6489
|
+
);
|
|
6490
|
+
if (!message.trim()) throw new Error("Commit message must not be blank");
|
|
6491
|
+
if (message.length > 5e4) throw new Error("Commit message is too long");
|
|
6492
|
+
if (payload.signed !== null && typeof payload.signed !== "boolean") {
|
|
6493
|
+
throw new Error("worktree commit payload.signed must be a boolean or null");
|
|
6494
|
+
}
|
|
6495
|
+
if (typeof payload.stageAll !== "boolean") {
|
|
6496
|
+
throw new Error("worktree commit payload.stageAll must be a boolean");
|
|
6497
|
+
}
|
|
6498
|
+
if (!Array.isArray(payload.paths) || payload.paths.length > 500) {
|
|
6499
|
+
throw new Error("worktree commit payload.paths is invalid");
|
|
6500
|
+
}
|
|
6501
|
+
const paths = payload.paths.map(
|
|
6502
|
+
(path, index) => safeRelativePath(path, `worktree commit payload.paths[${index}]`)
|
|
6503
|
+
);
|
|
6504
|
+
if (new Set(paths).size !== paths.length) {
|
|
6505
|
+
throw new Error("worktree commit payload.paths must be unique");
|
|
6506
|
+
}
|
|
6507
|
+
if (!payload.stageAll && paths.length === 0) {
|
|
6508
|
+
throw new Error("A partial commit requires at least one path");
|
|
6509
|
+
}
|
|
6510
|
+
return {
|
|
6511
|
+
codebaseId: stringValue4(
|
|
6512
|
+
payload.codebaseId,
|
|
6513
|
+
"worktree commit payload.codebaseId"
|
|
6514
|
+
),
|
|
6515
|
+
folder: stringValue4(payload.folder, "worktree commit payload.folder"),
|
|
6516
|
+
gitDirectory: stringValue4(
|
|
6517
|
+
payload.gitDirectory,
|
|
6518
|
+
"worktree commit payload.gitDirectory"
|
|
6519
|
+
),
|
|
6520
|
+
expectedOrigin: stringValue4(
|
|
6521
|
+
payload.expectedOrigin,
|
|
6522
|
+
"worktree commit payload.expectedOrigin"
|
|
6523
|
+
),
|
|
6524
|
+
baseBranch: nullableString3(
|
|
6525
|
+
payload.baseBranch,
|
|
6526
|
+
"worktree commit payload.baseBranch"
|
|
6527
|
+
),
|
|
6528
|
+
message,
|
|
6529
|
+
signed: payload.signed,
|
|
6530
|
+
stageAll: payload.stageAll,
|
|
6531
|
+
paths
|
|
6532
|
+
};
|
|
6533
|
+
}
|
|
6466
6534
|
function worktreeJobPayload(value) {
|
|
6467
6535
|
const payload = objectValue4(value, "worktree payload");
|
|
6468
6536
|
const allowed = /* @__PURE__ */ new Set([
|
|
@@ -14218,12 +14286,16 @@ import { tmpdir as tmpdir5 } from "node:os";
|
|
|
14218
14286
|
import { join as join12 } from "node:path";
|
|
14219
14287
|
|
|
14220
14288
|
// src/runs/git-checkpoint.ts
|
|
14221
|
-
import { execFile as execFile2 } from "node:child_process";
|
|
14289
|
+
import { execFile as execFile2, spawn as spawn6 } from "node:child_process";
|
|
14222
14290
|
import { copyFile, mkdtemp as mkdtemp4, rm as rm7 } from "node:fs/promises";
|
|
14223
14291
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
14224
14292
|
import { join as join11 } from "node:path";
|
|
14225
14293
|
import { promisify as promisify2 } from "node:util";
|
|
14226
14294
|
var execFileAsync = promisify2(execFile2);
|
|
14295
|
+
var PATCH_LIMIT = 2e6;
|
|
14296
|
+
var SUMMARY_LIMIT = 24e4;
|
|
14297
|
+
var MANIFEST_LIMIT = 2e6;
|
|
14298
|
+
var TRUNCATION_RESERVE = 200;
|
|
14227
14299
|
async function git2(cwd, args, env) {
|
|
14228
14300
|
const result = await execFileAsync("git", args, {
|
|
14229
14301
|
cwd,
|
|
@@ -14240,24 +14312,111 @@ async function optionalGit(cwd, args) {
|
|
|
14240
14312
|
return null;
|
|
14241
14313
|
}
|
|
14242
14314
|
}
|
|
14315
|
+
function cappedGit(cwd, args, limit) {
|
|
14316
|
+
const budget = limit - TRUNCATION_RESERVE;
|
|
14317
|
+
return new Promise((resolve8, reject) => {
|
|
14318
|
+
const child = spawn6("git", args, {
|
|
14319
|
+
cwd,
|
|
14320
|
+
env: {
|
|
14321
|
+
...process.env,
|
|
14322
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
14323
|
+
GIT_OPTIONAL_LOCKS: "0"
|
|
14324
|
+
},
|
|
14325
|
+
shell: false,
|
|
14326
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
14327
|
+
});
|
|
14328
|
+
const chunks = [];
|
|
14329
|
+
const errorChunks = [];
|
|
14330
|
+
let collected = 0;
|
|
14331
|
+
let errorCollected = 0;
|
|
14332
|
+
let truncated = false;
|
|
14333
|
+
let settled = false;
|
|
14334
|
+
child.stdout.on("data", (chunk) => {
|
|
14335
|
+
if (truncated) return;
|
|
14336
|
+
const remaining = budget - collected;
|
|
14337
|
+
if (chunk.length >= remaining) {
|
|
14338
|
+
chunks.push(chunk.subarray(0, remaining));
|
|
14339
|
+
collected = budget;
|
|
14340
|
+
truncated = true;
|
|
14341
|
+
child.stdout.destroy();
|
|
14342
|
+
if (child.exitCode === null && !child.killed) child.kill("SIGTERM");
|
|
14343
|
+
return;
|
|
14344
|
+
}
|
|
14345
|
+
chunks.push(chunk);
|
|
14346
|
+
collected += chunk.length;
|
|
14347
|
+
});
|
|
14348
|
+
child.stderr.on("data", (chunk) => {
|
|
14349
|
+
if (errorCollected >= 8192) return;
|
|
14350
|
+
errorChunks.push(chunk);
|
|
14351
|
+
errorCollected += chunk.length;
|
|
14352
|
+
});
|
|
14353
|
+
child.once("error", (error) => {
|
|
14354
|
+
if (settled) return;
|
|
14355
|
+
settled = true;
|
|
14356
|
+
reject(error);
|
|
14357
|
+
});
|
|
14358
|
+
child.once("close", (exitCode) => {
|
|
14359
|
+
if (settled) return;
|
|
14360
|
+
settled = true;
|
|
14361
|
+
if (!truncated && exitCode !== 0) {
|
|
14362
|
+
const message = Buffer.concat(errorChunks).toString("utf8").trim() || `git ${args[0]} exited with code ${exitCode}`;
|
|
14363
|
+
reject(new Error(message));
|
|
14364
|
+
return;
|
|
14365
|
+
}
|
|
14366
|
+
const output = Buffer.concat(chunks).toString("utf8");
|
|
14367
|
+
resolve8(
|
|
14368
|
+
truncated ? `${output.trimEnd()}
|
|
14369
|
+
|
|
14370
|
+
[Truncated after ${budget} bytes]` : output.trim()
|
|
14371
|
+
);
|
|
14372
|
+
});
|
|
14373
|
+
});
|
|
14374
|
+
}
|
|
14375
|
+
async function optionalCappedGit(cwd, args, limit) {
|
|
14376
|
+
try {
|
|
14377
|
+
return await cappedGit(cwd, args, limit) || null;
|
|
14378
|
+
} catch {
|
|
14379
|
+
return null;
|
|
14380
|
+
}
|
|
14381
|
+
}
|
|
14382
|
+
function manifestPayload(manifest) {
|
|
14383
|
+
let value = manifest;
|
|
14384
|
+
let json = JSON.stringify({ porcelainV2: value });
|
|
14385
|
+
while (json.length > MANIFEST_LIMIT && value.length > 0) {
|
|
14386
|
+
value = value.slice(
|
|
14387
|
+
0,
|
|
14388
|
+
Math.floor(value.length * MANIFEST_LIMIT / json.length) - 1
|
|
14389
|
+
);
|
|
14390
|
+
json = JSON.stringify({ porcelainV2: value });
|
|
14391
|
+
}
|
|
14392
|
+
return json;
|
|
14393
|
+
}
|
|
14243
14394
|
async function compareGitCheckpoint(cwd, target2, current) {
|
|
14244
14395
|
if (!target2.worktreeTree || !current.worktreeTree) {
|
|
14245
14396
|
throw new Error("The worktree checkpoint is incomplete");
|
|
14246
14397
|
}
|
|
14247
|
-
const worktreePatch = await
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14398
|
+
const worktreePatch = await cappedGit(
|
|
14399
|
+
cwd,
|
|
14400
|
+
[
|
|
14401
|
+
"diff",
|
|
14402
|
+
"--binary",
|
|
14403
|
+
"--find-renames",
|
|
14404
|
+
target2.worktreeTree,
|
|
14405
|
+
current.worktreeTree
|
|
14406
|
+
],
|
|
14407
|
+
PATCH_LIMIT
|
|
14408
|
+
);
|
|
14409
|
+
const indexPatch = target2.indexTree && current.indexTree ? await cappedGit(
|
|
14410
|
+
cwd,
|
|
14411
|
+
[
|
|
14412
|
+
"diff",
|
|
14413
|
+
"--binary",
|
|
14414
|
+
"--find-renames",
|
|
14415
|
+
target2.indexTree,
|
|
14416
|
+
current.indexTree
|
|
14417
|
+
],
|
|
14418
|
+
PATCH_LIMIT
|
|
14419
|
+
) : "";
|
|
14261
14420
|
const upstream = await optionalGit(cwd, ["rev-parse", "@{upstream}"]);
|
|
14262
14421
|
const pushedCount = target2.headSha && upstream ? Number(
|
|
14263
14422
|
await optionalGit(cwd, [
|
|
@@ -14274,7 +14433,7 @@ ${worktreePatch}`,
|
|
|
14274
14433
|
indexPatch && `Index changes that will be undone:
|
|
14275
14434
|
|
|
14276
14435
|
${indexPatch}`
|
|
14277
|
-
].filter(Boolean).join("\n\n").slice(0,
|
|
14436
|
+
].filter(Boolean).join("\n\n").slice(0, PATCH_LIMIT),
|
|
14278
14437
|
pushedCommitWarning: pushedCount > 0 ? `${pushedCount} commit${pushedCount === 1 ? "" : "s"} after this question appear on the upstream branch. Remote refs will not be changed.` : null
|
|
14279
14438
|
};
|
|
14280
14439
|
}
|
|
@@ -14333,9 +14492,21 @@ async function captureGitCheckpoint(cwd, runId, kind) {
|
|
|
14333
14492
|
]);
|
|
14334
14493
|
const upstreamSha = await optionalGit(cwd, ["rev-parse", "@{upstream}"]);
|
|
14335
14494
|
const indexTree = await optionalGit(cwd, ["write-tree"]);
|
|
14336
|
-
const manifest = await
|
|
14337
|
-
|
|
14338
|
-
|
|
14495
|
+
const manifest = await optionalCappedGit(
|
|
14496
|
+
cwd,
|
|
14497
|
+
["status", "--porcelain=v2", "-z"],
|
|
14498
|
+
MANIFEST_LIMIT
|
|
14499
|
+
);
|
|
14500
|
+
const staged = await optionalCappedGit(
|
|
14501
|
+
cwd,
|
|
14502
|
+
["diff", "--cached", "--stat", "HEAD"],
|
|
14503
|
+
SUMMARY_LIMIT
|
|
14504
|
+
);
|
|
14505
|
+
const unstaged = await optionalCappedGit(
|
|
14506
|
+
cwd,
|
|
14507
|
+
["diff", "--stat", "HEAD"],
|
|
14508
|
+
SUMMARY_LIMIT
|
|
14509
|
+
);
|
|
14339
14510
|
const directory = await mkdtemp4(join11(tmpdir4(), "aide-run-index-"));
|
|
14340
14511
|
let worktreeTree = null;
|
|
14341
14512
|
let refName = null;
|
|
@@ -14383,17 +14554,15 @@ async function captureGitCheckpoint(cwd, runId, kind) {
|
|
|
14383
14554
|
indexTree,
|
|
14384
14555
|
worktreeTree,
|
|
14385
14556
|
refName,
|
|
14386
|
-
manifestJson:
|
|
14557
|
+
manifestJson: manifestPayload(manifest ?? ""),
|
|
14387
14558
|
diffSummary: [staged && `Staged:
|
|
14388
14559
|
${staged}`, unstaged && `Working tree:
|
|
14389
14560
|
${unstaged}`].filter(Boolean).join("\n\n") || null,
|
|
14390
|
-
diffPatch: headSha && worktreeTree ?
|
|
14391
|
-
|
|
14392
|
-
"--binary",
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
worktreeTree
|
|
14396
|
-
])).slice(0, 2e6) || null : null
|
|
14561
|
+
diffPatch: headSha && worktreeTree ? await cappedGit(
|
|
14562
|
+
cwd,
|
|
14563
|
+
["diff", "--binary", "--find-renames", headSha, worktreeTree],
|
|
14564
|
+
PATCH_LIMIT
|
|
14565
|
+
) || null : null
|
|
14397
14566
|
};
|
|
14398
14567
|
}
|
|
14399
14568
|
|
|
@@ -14508,7 +14677,7 @@ import { createWriteStream as createWriteStream2, watch } from "node:fs";
|
|
|
14508
14677
|
import { mkdtemp as mkdtemp6, open as open2, readFile as readFile8, realpath as realpath8, rm as rm9, stat as stat10 } from "node:fs/promises";
|
|
14509
14678
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
14510
14679
|
import { basename as basename5, dirname as dirname7, isAbsolute as isAbsolute6, join as join13, relative as relative7 } from "node:path";
|
|
14511
|
-
import { spawn as
|
|
14680
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
14512
14681
|
var successfulProcess8 = {
|
|
14513
14682
|
exitCode: 0,
|
|
14514
14683
|
signal: null,
|
|
@@ -15164,10 +15333,16 @@ async function inspectCommits(folder, baseBranch, timeoutMs, signal) {
|
|
|
15164
15333
|
return { commits: commits.slice(0, 100), truncated: commits.length > 100 };
|
|
15165
15334
|
}
|
|
15166
15335
|
async function inspectWorktreeDetail(folder, baseBranch, timeoutMs, signal) {
|
|
15167
|
-
const [commitResult, changeResult, branchResult] = await Promise.all([
|
|
15336
|
+
const [commitResult, changeResult, branchResult, signingResult] = await Promise.all([
|
|
15168
15337
|
inspectCommits(folder, baseBranch, timeoutMs, signal),
|
|
15169
15338
|
inspectChanges(folder, timeoutMs, signal),
|
|
15170
|
-
inspectBranchChanges(folder, baseBranch, timeoutMs, signal)
|
|
15339
|
+
inspectBranchChanges(folder, baseBranch, timeoutMs, signal),
|
|
15340
|
+
git3(
|
|
15341
|
+
folder,
|
|
15342
|
+
["config", "--bool", "--get", "commit.gpgsign"],
|
|
15343
|
+
timeoutMs,
|
|
15344
|
+
signal
|
|
15345
|
+
)
|
|
15171
15346
|
]);
|
|
15172
15347
|
return {
|
|
15173
15348
|
commits: commitResult.commits,
|
|
@@ -15175,7 +15350,8 @@ async function inspectWorktreeDetail(folder, baseBranch, timeoutMs, signal) {
|
|
|
15175
15350
|
branchChanges: branchResult.changes,
|
|
15176
15351
|
commitsTruncated: commitResult.truncated,
|
|
15177
15352
|
changesTruncated: changeResult.truncated,
|
|
15178
|
-
branchChangesTruncated: branchResult.truncated
|
|
15353
|
+
branchChangesTruncated: branchResult.truncated,
|
|
15354
|
+
commitSigningEnabled: signingResult.exitCode === 0 && signingResult.stdout.trim() === "true"
|
|
15179
15355
|
};
|
|
15180
15356
|
}
|
|
15181
15357
|
async function baseMergeCommit(folder, baseBranch, timeoutMs, signal) {
|
|
@@ -15501,7 +15677,7 @@ function imageContentType(path) {
|
|
|
15501
15677
|
}
|
|
15502
15678
|
async function writeGitObject(folder, specification, destination, timeoutMs, signal) {
|
|
15503
15679
|
await new Promise((resolvePromise, rejectPromise) => {
|
|
15504
|
-
const child =
|
|
15680
|
+
const child = spawn7(
|
|
15505
15681
|
"git",
|
|
15506
15682
|
["-C", folder, "cat-file", "blob", specification],
|
|
15507
15683
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
@@ -15701,6 +15877,97 @@ var inspectWorktreeGit = async (payload, timeoutMs, signal) => {
|
|
|
15701
15877
|
)
|
|
15702
15878
|
};
|
|
15703
15879
|
};
|
|
15880
|
+
var commitWorktree = async (payload, timeoutMs, signal) => {
|
|
15881
|
+
const input = worktreeCommitJobPayload(payload);
|
|
15882
|
+
const folder = await validateWorktree2(input, timeoutMs, signal);
|
|
15883
|
+
const runGit = async (args, fallback) => requireSuccess3(await git3(folder, args, timeoutMs, signal), fallback);
|
|
15884
|
+
if (input.stageAll) {
|
|
15885
|
+
await runGit(["add", "--all"], "Could not stage worktree changes");
|
|
15886
|
+
} else {
|
|
15887
|
+
const current = await inspectChanges(folder, timeoutMs, signal);
|
|
15888
|
+
const byPath = new Map(
|
|
15889
|
+
current.changes.map((change) => [change.path, change])
|
|
15890
|
+
);
|
|
15891
|
+
const selected = input.paths.map((path) => {
|
|
15892
|
+
const change = byPath.get(path);
|
|
15893
|
+
if (!change) throw new Error(`Worktree change no longer exists: ${path}`);
|
|
15894
|
+
return change;
|
|
15895
|
+
});
|
|
15896
|
+
const head = await git3(
|
|
15897
|
+
folder,
|
|
15898
|
+
["rev-parse", "--verify", "HEAD"],
|
|
15899
|
+
timeoutMs,
|
|
15900
|
+
signal
|
|
15901
|
+
);
|
|
15902
|
+
if (head.exitCode === 0) {
|
|
15903
|
+
await runGit(
|
|
15904
|
+
["reset", "--mixed", "HEAD", "--"],
|
|
15905
|
+
"Could not reset the Git index"
|
|
15906
|
+
);
|
|
15907
|
+
} else {
|
|
15908
|
+
await runGit(
|
|
15909
|
+
["rm", "--cached", "-r", "--ignore-unmatch", "."],
|
|
15910
|
+
"Could not reset the Git index"
|
|
15911
|
+
);
|
|
15912
|
+
}
|
|
15913
|
+
const selectedPaths = [
|
|
15914
|
+
...new Set(
|
|
15915
|
+
selected.flatMap(
|
|
15916
|
+
(change) => change.previousPath ? [change.previousPath, change.path] : [change.path]
|
|
15917
|
+
)
|
|
15918
|
+
)
|
|
15919
|
+
];
|
|
15920
|
+
await runGit(
|
|
15921
|
+
["--literal-pathspecs", "add", "--all", "--", ...selectedPaths],
|
|
15922
|
+
"Could not stage selected worktree changes"
|
|
15923
|
+
);
|
|
15924
|
+
}
|
|
15925
|
+
const staged = await git3(
|
|
15926
|
+
folder,
|
|
15927
|
+
["diff", "--cached", "--quiet", "--exit-code"],
|
|
15928
|
+
timeoutMs,
|
|
15929
|
+
signal
|
|
15930
|
+
);
|
|
15931
|
+
if (staged.exitCode === 0) throw new Error("No staged changes to commit");
|
|
15932
|
+
if (staged.exitCode !== 1)
|
|
15933
|
+
requireSuccess3(staged, "Could not inspect staged changes");
|
|
15934
|
+
let signed = input.signed;
|
|
15935
|
+
if (signed === null) {
|
|
15936
|
+
const configured = await git3(
|
|
15937
|
+
folder,
|
|
15938
|
+
["config", "--bool", "--get", "commit.gpgsign"],
|
|
15939
|
+
timeoutMs,
|
|
15940
|
+
signal
|
|
15941
|
+
);
|
|
15942
|
+
signed = configured.exitCode === 0 && configured.stdout.trim() === "true";
|
|
15943
|
+
}
|
|
15944
|
+
await runGit(
|
|
15945
|
+
["commit", signed ? "--gpg-sign" : "--no-gpg-sign", "-m", input.message],
|
|
15946
|
+
"Commit failed"
|
|
15947
|
+
);
|
|
15948
|
+
const sha = runGit(["rev-parse", "HEAD"], "Could not read the new commit");
|
|
15949
|
+
const subject = runGit(
|
|
15950
|
+
["log", "-1", "--format=%s"],
|
|
15951
|
+
"Could not read the new commit subject"
|
|
15952
|
+
);
|
|
15953
|
+
const [shaResult, subjectResult] = await Promise.all([sha, subject]);
|
|
15954
|
+
return {
|
|
15955
|
+
...successfulProcess8,
|
|
15956
|
+
commit: {
|
|
15957
|
+
sha: shaResult.stdout.trim(),
|
|
15958
|
+
subject: subjectResult.stdout.trim(),
|
|
15959
|
+
signed
|
|
15960
|
+
},
|
|
15961
|
+
worktree: await inspectWorktreeItem(
|
|
15962
|
+
folder,
|
|
15963
|
+
folder,
|
|
15964
|
+
input.baseBranch,
|
|
15965
|
+
false,
|
|
15966
|
+
Math.min(timeoutMs, 3e4),
|
|
15967
|
+
signal
|
|
15968
|
+
)
|
|
15969
|
+
};
|
|
15970
|
+
};
|
|
15704
15971
|
var operateWorktreeGit = async (payload, timeoutMs, signal) => {
|
|
15705
15972
|
const input = worktreeGitOperationPayload(payload);
|
|
15706
15973
|
const folder = await validateWorktree2(input, timeoutMs, signal);
|
|
@@ -16456,6 +16723,14 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
|
|
|
16456
16723
|
await runGit(["rebase", "--abort"], "Could not cancel rebase");
|
|
16457
16724
|
break;
|
|
16458
16725
|
}
|
|
16726
|
+
case "PULL": {
|
|
16727
|
+
if (!branch || !upstream)
|
|
16728
|
+
throw new Error("Pull requires a branch with an upstream");
|
|
16729
|
+
const remote = upstream.split("/")[0] || "origin";
|
|
16730
|
+
await runGit(["fetch", remote], `Could not fetch ${remote}`);
|
|
16731
|
+
await runGit(["merge", "--ff-only", "@{upstream}"], "Pull failed");
|
|
16732
|
+
break;
|
|
16733
|
+
}
|
|
16459
16734
|
case "PUSH":
|
|
16460
16735
|
if (!branch) throw new Error("Push requires a branch");
|
|
16461
16736
|
await runGit(
|
|
@@ -16735,6 +17010,7 @@ var handlers = {
|
|
|
16735
17010
|
[WORKTREE_INSPECT_JOB_KIND]: inspectWorktree,
|
|
16736
17011
|
[WORKTREE_AUTO_SYNC_JOB_KIND]: autoSyncWorktree,
|
|
16737
17012
|
[WORKTREE_BRANCH_JOB_KIND]: branchWorktree,
|
|
17013
|
+
[WORKTREE_COMMIT_JOB_KIND]: commitWorktree,
|
|
16738
17014
|
[WORKTREE_MOVE_PUSH_JOB_KIND]: pushMovedWorktree,
|
|
16739
17015
|
[WORKTREE_MOVE_CHECKOUT_JOB_KIND]: checkoutMovedWorktree,
|
|
16740
17016
|
[WORKTREE_DELETE_JOB_KIND]: deleteWorktree,
|
|
@@ -43340,7 +43616,7 @@ var ClaudeAdapter = class {
|
|
|
43340
43616
|
// src/runs/codex-adapter.ts
|
|
43341
43617
|
import {
|
|
43342
43618
|
execFile as execFile3,
|
|
43343
|
-
spawn as
|
|
43619
|
+
spawn as spawn8
|
|
43344
43620
|
} from "node:child_process";
|
|
43345
43621
|
import { mkdtemp as mkdtemp7, rm as rm12, writeFile as writeFile8 } from "node:fs/promises";
|
|
43346
43622
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
@@ -43429,7 +43705,7 @@ var CodexAppServer = class {
|
|
|
43429
43705
|
const executable = this.executable();
|
|
43430
43706
|
const modelCatalogPath = await this.createBundledModelCatalog(executable);
|
|
43431
43707
|
const modelCatalogDirectory = this.modelCatalogDirectory;
|
|
43432
|
-
const child =
|
|
43708
|
+
const child = spawn8(executable, codexAppServerArgs(modelCatalogPath), {
|
|
43433
43709
|
stdio: ["pipe", "pipe", "pipe"],
|
|
43434
43710
|
env: process.env
|
|
43435
43711
|
});
|