opencastle 1.13.0 → 1.13.1
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/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +8 -5
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +25 -4
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +8 -5
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/convoy/engine.d.ts.map +1 -1
- package/dist/cli/convoy/engine.git.test.js +206 -1
- package/dist/cli/convoy/engine.git.test.js.map +1 -1
- package/dist/cli/convoy/engine.js +116 -13
- package/dist/cli/convoy/engine.js.map +1 -1
- package/dist/cli/convoy/merge.d.ts +24 -5
- package/dist/cli/convoy/merge.d.ts.map +1 -1
- package/dist/cli/convoy/merge.js +108 -10
- package/dist/cli/convoy/merge.js.map +1 -1
- package/dist/cli/convoy/merge.test.js +59 -0
- package/dist/cli/convoy/merge.test.js.map +1 -1
- package/dist/cli/convoy/worktree.d.ts +6 -1
- package/dist/cli/convoy/worktree.d.ts.map +1 -1
- package/dist/cli/convoy/worktree.js +7 -0
- package/dist/cli/convoy/worktree.js.map +1 -1
- package/dist/cli/convoy/worktree.test.js +15 -1
- package/dist/cli/convoy/worktree.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +23 -3
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/foreign-skills.d.ts +23 -0
- package/dist/cli/foreign-skills.d.ts.map +1 -1
- package/dist/cli/foreign-skills.js +91 -1
- package/dist/cli/foreign-skills.js.map +1 -1
- package/dist/cli/foreign-skills.test.js +95 -2
- package/dist/cli/foreign-skills.test.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +17 -5
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/lock.d.ts +9 -0
- package/dist/cli/lock.d.ts.map +1 -1
- package/dist/cli/lock.js +16 -0
- package/dist/cli/lock.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts +6 -3
- package/dist/cli/mcp-audit.d.ts.map +1 -1
- package/dist/cli/mcp-audit.js +22 -7
- package/dist/cli/mcp-audit.js.map +1 -1
- package/dist/cli/mcp-ownership.test.d.ts +2 -0
- package/dist/cli/mcp-ownership.test.d.ts.map +1 -0
- package/dist/cli/mcp-ownership.test.js +141 -0
- package/dist/cli/mcp-ownership.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +36 -5
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +101 -33
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +4 -4
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/root-files.d.ts +59 -0
- package/dist/cli/root-files.d.ts.map +1 -0
- package/dist/cli/root-files.js +133 -0
- package/dist/cli/root-files.js.map +1 -0
- package/dist/cli/root-files.test.d.ts +2 -0
- package/dist/cli/root-files.test.d.ts.map +1 -0
- package/dist/cli/root-files.test.js +152 -0
- package/dist/cli/root-files.test.js.map +1 -0
- package/dist/cli/sync-check.d.ts +1 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +19 -4
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/team-ci.test.js +8 -1
- package/dist/cli/team-ci.test.js.map +1 -1
- package/dist/cli/unreadable-report.d.ts.map +1 -1
- package/dist/cli/unreadable-report.js +3 -0
- package/dist/cli/unreadable-report.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +33 -8
- package/dist/cli/update.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/adapters/rules-dir-base.ts +6 -5
- package/src/cli/adapters/single-file-base.ts +25 -4
- package/src/cli/adapters/vscode.ts +10 -6
- package/src/cli/convoy/engine.git.test.ts +227 -1
- package/src/cli/convoy/engine.ts +112 -12
- package/src/cli/convoy/merge.test.ts +72 -0
- package/src/cli/convoy/merge.ts +128 -15
- package/src/cli/convoy/worktree.test.ts +16 -1
- package/src/cli/convoy/worktree.ts +13 -3
- package/src/cli/doctor.ts +23 -1
- package/src/cli/foreign-skills.test.ts +111 -2
- package/src/cli/foreign-skills.ts +93 -1
- package/src/cli/init.ts +15 -5
- package/src/cli/lock.ts +18 -0
- package/src/cli/mcp-audit.ts +22 -6
- package/src/cli/mcp-ownership.test.ts +167 -0
- package/src/cli/mcp.ts +104 -29
- package/src/cli/remove.ts +4 -3
- package/src/cli/root-files.test.ts +169 -0
- package/src/cli/root-files.ts +140 -0
- package/src/cli/sync-check.ts +20 -5
- package/src/cli/team-ci.test.ts +8 -1
- package/src/cli/unreadable-report.ts +3 -0
- package/src/cli/update.ts +30 -7
|
@@ -6,7 +6,7 @@ import { createConvoyStore, ConvoyArtifactLimitError } from './store.js';
|
|
|
6
6
|
import { acquireEngineLock } from './lock.js';
|
|
7
7
|
import { createEventEmitter, ndjsonPathForConvoy, recoverNdjson } from './events.js';
|
|
8
8
|
import { createWorktreeManager, ensureRootWorktree, removeRootWorktree, mainRepoRoot, currentRef, listAllWorktrees, worktreesDirFor, workerBranchName, commitAllIn, commitPathsIn, git, BranchInUseError, } from './worktree.js';
|
|
9
|
-
import { createMergeQueue, MergeConflictError } from './merge.js';
|
|
9
|
+
import { ChangedAfterChecksError, createMergeQueue, MergeConflictError } from './merge.js';
|
|
10
10
|
import { collectFindings, recordLessons, LESSON_PATHS } from './findings.js';
|
|
11
11
|
import { parseTimeout } from '../run/schema.js';
|
|
12
12
|
import { getAdapter } from '../run/adapters/index.js';
|
|
@@ -904,6 +904,18 @@ async function runConvoy(ctx) {
|
|
|
904
904
|
}
|
|
905
905
|
const wt = worktreePath;
|
|
906
906
|
const startSha = wtManager.head ? await wtManager.head(wt) : null;
|
|
907
|
+
// The branches there are before the agent runs, so one it makes for itself
|
|
908
|
+
// ("branch first" is a common project rule) can be told from the user's.
|
|
909
|
+
const branchesBefore = new Set();
|
|
910
|
+
if (wtManager.commitAll) {
|
|
911
|
+
try {
|
|
912
|
+
for (const name of (await git(['for-each-ref', '--format=%(refname:short)', 'refs/heads'], repoRoot)).split('\n')) {
|
|
913
|
+
if (name.trim())
|
|
914
|
+
branchesBefore.add(name.trim());
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
catch { /* none known: no branch of the agent's is removed */ }
|
|
918
|
+
}
|
|
907
919
|
store.insertWorker({
|
|
908
920
|
id: workerId,
|
|
909
921
|
task_id: rec.id,
|
|
@@ -1036,9 +1048,40 @@ async function runConvoy(ctx) {
|
|
|
1036
1048
|
return retryOrFail('failed', `Could not commit the task's work: ${firstLine(err.stderr) || err.message}`, { kind: 'commit' });
|
|
1037
1049
|
}
|
|
1038
1050
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1051
|
+
// The commit every check below looks at, and the one that merges. Taken
|
|
1052
|
+
// again after the task's gates, which may fix what they check; anything
|
|
1053
|
+
// written after that (a post_task hook) was not scanned or reviewed, and
|
|
1054
|
+
// the merge refuses it rather than taking it along.
|
|
1055
|
+
let checkedCommit = wtManager.head ? await wtManager.head(wt) : null;
|
|
1056
|
+
let changes = startSha && wtManager.changes ? await wtManager.changes(wt, startSha) : null;
|
|
1057
|
+
// What the agent itself changed: the no-op gate's question, which a
|
|
1058
|
+
// formatter run as a gate must not answer for it.
|
|
1059
|
+
const agentChanges = changes;
|
|
1060
|
+
let changedFiles = changes?.files ?? [];
|
|
1061
|
+
let diff = changes?.diff ?? '';
|
|
1062
|
+
// ── Built on the task's starting point ──────────────────────────────────
|
|
1063
|
+
// An agent that checked out another base (`git switch -c x origin/main`)
|
|
1064
|
+
// left a commit whose diff from the start undoes everything merged since:
|
|
1065
|
+
// the review would judge that, and the merge would bring something else.
|
|
1066
|
+
// Stopped here, before any gate or review is spent on it, with the work
|
|
1067
|
+
// kept on the worker branch.
|
|
1068
|
+
if (startSha && checkedCommit && checkedCommit !== startSha && wtManager.commitAll) {
|
|
1069
|
+
let onBase = true;
|
|
1070
|
+
try {
|
|
1071
|
+
await git(['merge-base', '--is-ancestor', startSha, checkedCommit], wt);
|
|
1072
|
+
}
|
|
1073
|
+
catch {
|
|
1074
|
+
onBase = false;
|
|
1075
|
+
}
|
|
1076
|
+
if (!onBase) {
|
|
1077
|
+
const kept = workerBranchName(workerId);
|
|
1078
|
+
try {
|
|
1079
|
+
await git(['update-ref', `refs/heads/${kept}`, checkedCommit], wt);
|
|
1080
|
+
}
|
|
1081
|
+
catch { /* the message still names it */ }
|
|
1082
|
+
return fail('failed', `Not merged: the agent's commit ${checkedCommit.slice(0, 12)} is not built on the task's starting point ${startSha.slice(0, 12)} — it switched to another base. The work is kept on branch ${kept}`, { kind: 'off-base', keepBranch: kept, failureType: 'off-base' });
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1042
1085
|
// ── Per-task gates from the spec ────────────────────────────────────────
|
|
1043
1086
|
const taskGates = parseJsonList(rec.gates);
|
|
1044
1087
|
for (const command of taskGates) {
|
|
@@ -1058,6 +1101,26 @@ async function runConvoy(ctx) {
|
|
|
1058
1101
|
});
|
|
1059
1102
|
}
|
|
1060
1103
|
}
|
|
1104
|
+
// A gate that fixes as it checks — `eslint --fix`, `prettier --write` — made
|
|
1105
|
+
// changes that belong to the work. Committed now, so the secret scan, the
|
|
1106
|
+
// review and the merge below all see the same thing: the change as it will
|
|
1107
|
+
// land. Leaving them out of the checked commit failed every task whose
|
|
1108
|
+
// gates formatted anything.
|
|
1109
|
+
if (taskGates.length > 0 && wtManager.commitAll) {
|
|
1110
|
+
let committed = false;
|
|
1111
|
+
try {
|
|
1112
|
+
committed = await wtManager.commitAll(wt, `convoy(${rec.id}): what its gates changed`);
|
|
1113
|
+
}
|
|
1114
|
+
catch (err) {
|
|
1115
|
+
return retryOrFail('failed', `Could not commit what the task's gates changed: ${firstLine(err.stderr) || err.message}`, { kind: 'commit' });
|
|
1116
|
+
}
|
|
1117
|
+
if (committed) {
|
|
1118
|
+
checkedCommit = wtManager.head ? await wtManager.head(wt) : null;
|
|
1119
|
+
changes = startSha && wtManager.changes ? await wtManager.changes(wt, startSha) : null;
|
|
1120
|
+
changedFiles = changes?.files ?? [];
|
|
1121
|
+
diff = changes?.diff ?? '';
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1061
1124
|
const builtInGates = spec.defaults?.built_in_gates;
|
|
1062
1125
|
const contractResult = validateOutput(rec.agent, result.output);
|
|
1063
1126
|
// ── No-op gate ──────────────────────────────────────────────────────────
|
|
@@ -1066,7 +1129,7 @@ async function runConvoy(ctx) {
|
|
|
1066
1129
|
if (files.length > 0 && (builtInGates ? builtInGates.no_op !== false : true)) {
|
|
1067
1130
|
const noOp = noOpGate({
|
|
1068
1131
|
declaredFiles: files,
|
|
1069
|
-
changedFiles:
|
|
1132
|
+
changedFiles: agentChanges ? agentChanges.files : null,
|
|
1070
1133
|
agent: rec.agent,
|
|
1071
1134
|
contractData: contractResult.data,
|
|
1072
1135
|
});
|
|
@@ -1319,12 +1382,24 @@ async function runConvoy(ctx) {
|
|
|
1319
1382
|
return requeue();
|
|
1320
1383
|
// ── Merge ───────────────────────────────────────────────────────────────
|
|
1321
1384
|
const workerBranch = workerBranchName(workerId);
|
|
1385
|
+
// A branch the agent made and left its checkout on: once its commit is on
|
|
1386
|
+
// the convoy branch it is only clutter, one per task, in the user's
|
|
1387
|
+
// repository. One that was there before the task is never touched.
|
|
1388
|
+
let agentBranch = null;
|
|
1389
|
+
if (wtManager.commitAll) {
|
|
1390
|
+
try {
|
|
1391
|
+
const name = (await git(['symbolic-ref', '--quiet', '--short', 'HEAD'], wt)).trim();
|
|
1392
|
+
if (name && name !== workerBranch && !branchesBefore.has(name))
|
|
1393
|
+
agentBranch = name;
|
|
1394
|
+
}
|
|
1395
|
+
catch { /* detached: no branch of its own */ }
|
|
1396
|
+
}
|
|
1322
1397
|
const nothingToMerge = changes !== null && changedFiles.length === 0;
|
|
1323
1398
|
const finalOutput = redactSecrets(result.output).text;
|
|
1324
1399
|
if (!nothingToMerge) {
|
|
1325
1400
|
let merged;
|
|
1326
1401
|
try {
|
|
1327
|
-
merged = await mergeQueue.merge(wt, workerBranch, branch);
|
|
1402
|
+
merged = await mergeQueue.merge(wt, workerBranch, branch, checkedCommit ? { commit: checkedCommit } : undefined);
|
|
1328
1403
|
}
|
|
1329
1404
|
catch (err) {
|
|
1330
1405
|
const fresh = store.getTask(rec.id, convoyId) ?? rec;
|
|
@@ -1356,7 +1431,10 @@ async function runConvoy(ctx) {
|
|
|
1356
1431
|
error: message,
|
|
1357
1432
|
...(conflicting ? { conflicting_files: conflicting } : {}),
|
|
1358
1433
|
}, { convoy_id: convoyId, task_id: rec.id });
|
|
1359
|
-
|
|
1434
|
+
const said = err instanceof ChangedAfterChecksError
|
|
1435
|
+
? `Not merged: ${message}. The work, with those changes on top, is kept on branch ${workerBranch}`
|
|
1436
|
+
: `Merge failed (${message}); the work is kept on branch ${workerBranch}`;
|
|
1437
|
+
return fail('failed', said, {
|
|
1360
1438
|
kind: 'merge-failed',
|
|
1361
1439
|
keepBranch: workerBranch,
|
|
1362
1440
|
failureType: 'merge-failed',
|
|
@@ -1377,12 +1455,35 @@ async function runConvoy(ctx) {
|
|
|
1377
1455
|
events.emit('task_merged', { branch, files: changedFiles.length }, { convoy_id: convoyId, task_id: rec.id });
|
|
1378
1456
|
}
|
|
1379
1457
|
await cleanup();
|
|
1458
|
+
if (agentBranch) {
|
|
1459
|
+
try {
|
|
1460
|
+
await git(['merge-base', '--is-ancestor', `refs/heads/${agentBranch}`, `refs/heads/${branch}`], repoRoot);
|
|
1461
|
+
await git(['branch', '-D', agentBranch], repoRoot);
|
|
1462
|
+
}
|
|
1463
|
+
catch { /* not all of it is on the convoy branch: it stays */ }
|
|
1464
|
+
}
|
|
1465
|
+
// A branch kept from an earlier failed merge goes only when its work is on
|
|
1466
|
+
// the convoy branch. It was deleted whenever the task next finished, on
|
|
1467
|
+
// the grounds that the new attempt superseded it — including a re-run that
|
|
1468
|
+
// changed nothing and merged nothing, which deleted the work the failure
|
|
1469
|
+
// message had said was kept, with none of it anywhere else.
|
|
1470
|
+
let keptBranch = null;
|
|
1380
1471
|
if (rec.branch && rec.branch !== workerBranch && wtManager.commitAll) {
|
|
1381
|
-
|
|
1472
|
+
keptBranch = rec.branch;
|
|
1382
1473
|
try {
|
|
1383
|
-
await git(['
|
|
1474
|
+
await git(['rev-parse', '--verify', '--quiet', `refs/heads/${rec.branch}`], repoRoot);
|
|
1475
|
+
}
|
|
1476
|
+
catch {
|
|
1477
|
+
keptBranch = null; // already gone
|
|
1478
|
+
}
|
|
1479
|
+
if (keptBranch) {
|
|
1480
|
+
try {
|
|
1481
|
+
await git(['merge-base', '--is-ancestor', `refs/heads/${rec.branch}`, `refs/heads/${branch}`], repoRoot);
|
|
1482
|
+
await git(['branch', '-D', rec.branch], repoRoot);
|
|
1483
|
+
keptBranch = null;
|
|
1484
|
+
}
|
|
1485
|
+
catch { /* not on the convoy branch: it stays, and the summary still names it */ }
|
|
1384
1486
|
}
|
|
1385
|
-
catch { /* already gone */ }
|
|
1386
1487
|
}
|
|
1387
1488
|
// ── Outputs and artifacts ──────────────────────────────────────────────
|
|
1388
1489
|
if (rec.outputs) {
|
|
@@ -1478,7 +1579,7 @@ async function runConvoy(ctx) {
|
|
|
1478
1579
|
output: finalOutput,
|
|
1479
1580
|
exit_code: result.exitCode,
|
|
1480
1581
|
contract_result: JSON.stringify(contractResult),
|
|
1481
|
-
branch:
|
|
1582
|
+
branch: keptBranch,
|
|
1482
1583
|
retry_note: null,
|
|
1483
1584
|
});
|
|
1484
1585
|
store.updateWorkerStatus(workerId, 'done', { finished_at: now() });
|
|
@@ -2303,8 +2404,10 @@ export function createConvoyEngine(options) {
|
|
|
2303
2404
|
const mergeQueue = options._mergeQueue ?? createMergeQueue(checkout.path, { worktreesDir: worktreesDirFor(repoRoot) });
|
|
2304
2405
|
await settleMergedTasks(store, events, convoyId, branch, repoRoot, progress);
|
|
2305
2406
|
const reset = resetForResume(store, events, convoyId);
|
|
2306
|
-
// Worktrees left by
|
|
2307
|
-
|
|
2407
|
+
// Worktrees left by this convoy's run that died — not the integration
|
|
2408
|
+
// checkout, and not another convoy's: the folder is shared by every
|
|
2409
|
+
// checkout of the repository, and one of them may be running now.
|
|
2410
|
+
await wtManager.removeAll({ except: [checkout.path], owner: shortConvoyId(convoyId) });
|
|
2308
2411
|
recoverNdjson(store, convoyId, ndjsonPath);
|
|
2309
2412
|
store.updateConvoyStatus(convoyId, 'running', {});
|
|
2310
2413
|
events.emit('convoy_resumed', { original_created_at: convoy.created_at, reset }, { convoy_id: convoyId });
|