tryharness 0.7.83 → 0.7.86
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/README.md +21 -19
- package/assets/dsh-plugin.mjs +75 -4
- package/assets/herdr-mod/harness/main.js +367 -0
- package/assets/herdr-mod/harness/mod.json +6 -0
- package/assets/opencode-plugin.js +87 -22
- package/assets/pi-extension.ts +81 -2
- package/cli.mjs +544 -208
- package/lib/adapters.mjs +62 -27
- package/lib/agentBinaries.mjs +6 -8
- package/lib/agentClaims.mjs +168 -0
- package/lib/agentReadTools.json +415 -0
- package/lib/agentSignIn.mjs +17 -18
- package/lib/agentWiring.mjs +114 -0
- package/lib/archetypes.js +10 -11
- package/lib/attention.mjs +100 -0
- package/lib/audit.mjs +1 -1
- package/lib/backupSetup.mjs +6 -28
- package/lib/bankrApprovals.mjs +86 -0
- package/lib/boardAccess.mjs +40 -66
- package/lib/boardBackup.mjs +86 -85
- package/lib/boardCommands.mjs +28 -0
- package/lib/boardFileCommands.mjs +29 -36
- package/lib/boardFiles.mjs +83 -15
- package/lib/boardMirror.mjs +78 -11
- package/lib/boardProtocol.json +191 -123
- package/lib/boardThreads.mjs +19 -37
- package/lib/boardTools.mjs +22 -15
- package/lib/boardWatches.mjs +43 -15
- package/lib/bridge.mjs +7 -3
- package/lib/browserAgentTools.mjs +59 -0
- package/lib/browserWake.mjs +0 -6
- package/lib/cards.mjs +52 -0
- package/lib/circling.mjs +189 -0
- package/lib/cleanup.mjs +234 -0
- package/lib/cloudBoot.mjs +21 -4
- package/lib/cloudSave.mjs +46 -5
- package/lib/compaction.mjs +8 -1
- package/lib/completion.mjs +358 -0
- package/lib/computerDevices.mjs +853 -0
- package/lib/connectionStatus.mjs +34 -0
- package/lib/connectors.mjs +139 -1
- package/lib/coordinator.mjs +108 -14
- package/lib/coreModels.mjs +36 -12
- package/lib/daemon.mjs +2426 -338
- package/lib/daemonLock.mjs +103 -0
- package/lib/deviceDoor.mjs +308 -0
- package/lib/deviceIdentity.mjs +114 -0
- package/lib/deviceList.mjs +172 -0
- package/lib/deviceSeal.mjs +74 -0
- package/lib/dispatcher.mjs +497 -26
- package/lib/dispatches.mjs +3 -3
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +67 -41
- package/lib/events.mjs +318 -0
- package/lib/facts.mjs +170 -0
- package/lib/fileSource.mjs +540 -0
- package/lib/files.mjs +47 -2
- package/lib/gitHost.mjs +39 -1
- package/lib/goalCommands.mjs +12 -80
- package/lib/handover.mjs +21 -16
- package/lib/harnessOffers.mjs +140 -15
- package/lib/herdr.mjs +100 -15
- package/lib/herdrAppCall.mjs +19 -0
- package/lib/herdrCore.mjs +59 -0
- package/lib/herdrRuns.mjs +1126 -0
- package/lib/hookDialects.mjs +235 -50
- package/lib/identityLink.mjs +81 -0
- package/lib/inference.mjs +31 -2
- package/lib/jamAccess.mjs +82 -0
- package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
- package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
- package/lib/jamKey.mjs +274 -0
- package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
- package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
- package/lib/jamStore.mjs +973 -0
- package/lib/jamUpgrade.mjs +112 -0
- package/lib/jams.mjs +3079 -0
- package/lib/kanban.mjs +13 -7
- package/lib/landed.mjs +5 -1
- package/lib/library.mjs +41 -22
- package/lib/limits.mjs +91 -0
- package/lib/lineDiff.mjs +97 -0
- package/lib/lineup.mjs +18 -13
- package/lib/link.mjs +584 -0
- package/lib/localStack.mjs +75 -16
- package/lib/localmodels.mjs +58 -78
- package/lib/loopBackstop.mjs +2 -1
- package/lib/machine.mjs +544 -0
- package/lib/machineLink.mjs +446 -0
- package/lib/machineRoutes.mjs +68 -19
- package/lib/machineRuns.mjs +85 -4
- package/lib/machineSeal.mjs +6 -31
- package/lib/manager.mjs +134 -12
- package/lib/mcp-stdio.mjs +492 -215
- package/lib/mcpRelay.mjs +34 -35
- package/lib/members.json +1 -1
- package/lib/modelRoute.mjs +162 -0
- package/lib/nativeHost.mjs +81 -90
- package/lib/nativeSenses.mjs +258 -0
- package/lib/nerves.mjs +523 -0
- package/lib/network.mjs +117 -278
- package/lib/networkPlaces.mjs +578 -0
- package/lib/nextStep.mjs +95 -0
- package/lib/notify.mjs +2 -2
- package/lib/nudge.mjs +116 -10
- package/lib/originals.mjs +216 -0
- package/lib/outsideEvents.mjs +383 -0
- package/lib/outsideRuns.mjs +230 -0
- package/lib/ownMachines.mjs +674 -256
- package/lib/pain.mjs +215 -0
- package/lib/pairing.mjs +91 -11
- package/lib/paths.mjs +42 -3
- package/lib/peerProcess.mjs +21 -7
- package/lib/peopleLink.mjs +268 -0
- package/lib/personNotices.mjs +3 -2
- package/lib/phones.mjs +252 -542
- package/lib/placeCards.mjs +282 -0
- package/lib/placeChecks.mjs +95 -0
- package/lib/placeCommands.mjs +8 -17
- package/lib/placeRequests.mjs +152 -0
- package/lib/placeStore.mjs +295 -0
- package/lib/placeTool.d.ts +12 -0
- package/lib/placeTool.js +40 -0
- package/lib/places.mjs +63 -14
- package/lib/plans.mjs +53 -8
- package/lib/presence.mjs +270 -0
- package/lib/privateNetwork.d.ts +2 -0
- package/lib/privateNetwork.js +93 -0
- package/lib/proposals.mjs +300 -0
- package/lib/publicFetch.d.ts +32 -0
- package/lib/publicFetch.js +248 -0
- package/lib/reach.mjs +128 -0
- package/lib/rebuildable.mjs +72 -0
- package/lib/recall.mjs +216 -0
- package/lib/record.mjs +13 -0
- package/lib/reflexes.mjs +392 -0
- package/lib/relayLimits.mjs +31 -2
- package/lib/releaseNotice.mjs +198 -0
- package/lib/removeHarness.mjs +15 -4
- package/lib/repoLinks.mjs +204 -35
- package/lib/runAuthority.mjs +102 -39
- package/lib/runBrief.mjs +93 -40
- package/lib/runRequests.mjs +52 -14
- package/lib/runUsage.mjs +31 -0
- package/lib/runWorker.mjs +74 -25
- package/lib/runner.mjs +289 -45
- package/lib/runtime-install.mjs +37 -8
- package/lib/schedules.mjs +171 -47
- package/lib/screenWatches.mjs +221 -0
- package/lib/sealed.mjs +12 -30
- package/lib/sealedThreads.mjs +198 -392
- package/lib/secretStore.mjs +178 -0
- package/lib/secrets.mjs +11 -0
- package/lib/seen.mjs +3 -9
- package/lib/selfUpdate.mjs +51 -15
- package/lib/senseCall.mjs +1514 -0
- package/lib/senseHook.mjs +114 -0
- package/lib/senseTools.mjs +1298 -0
- package/lib/sessionBriefs.mjs +87 -0
- package/lib/sessionControl.mjs +63 -13
- package/lib/sessionFiles.mjs +85 -0
- package/lib/setupChoices.mjs +12 -3
- package/lib/setupMode.mjs +70 -25
- package/lib/sharedKeys.mjs +166 -0
- package/lib/sleep.mjs +396 -0
- package/lib/sources.mjs +306 -0
- package/lib/speech.mjs +166 -411
- package/lib/spoken.mjs +210 -0
- package/lib/steerHook.mjs +3 -1
- package/lib/steerQueue.mjs +40 -11
- package/lib/store.mjs +323 -130
- package/lib/stuck.mjs +85 -7
- package/lib/swarm.mjs +157 -49
- package/lib/swarmDevices.mjs +25 -85
- package/lib/swarmMemory.mjs +93 -9
- package/lib/t3.mjs +73 -3
- package/lib/taskCommands.mjs +51 -60
- package/lib/taskRooms.mjs +30 -4
- package/lib/taskRules.json +29 -0
- package/lib/taskRules.mjs +21 -0
- package/lib/taskRuns.mjs +74 -11
- package/lib/team.mjs +2 -1
- package/lib/threadActions.mjs +37 -9
- package/lib/threadAuthority.mjs +4 -4
- package/lib/threadBriefs.mjs +173 -43
- package/lib/threadNotes.mjs +320 -0
- package/lib/threadRecord.mjs +491 -0
- package/lib/threadRuns.mjs +216 -108
- package/lib/threadView.mjs +27 -30
- package/lib/threadWatches.mjs +1962 -0
- package/lib/timeSense.mjs +839 -0
- package/lib/tripwires.mjs +454 -0
- package/lib/ui.mjs +1 -1
- package/lib/vault.mjs +560 -45
- package/lib/vaultCommands.mjs +5 -3
- package/lib/vaultPeers.mjs +165 -0
- package/lib/vaultTools.d.ts +4 -1
- package/lib/vaultTools.js +22 -1
- package/lib/verdicts.mjs +12 -26
- package/lib/versions.mjs +117 -0
- package/lib/waitTool.mjs +278 -0
- package/lib/wakePicture.mjs +268 -0
- package/lib/wakeQueue.mjs +108 -0
- package/lib/watchResponses.mjs +533 -0
- package/lib/watches.mjs +290 -145
- package/lib/windowAsks.mjs +80 -17
- package/lib/worktrees.mjs +159 -9
- package/npm-shrinkwrap.json +138 -631
- package/package.json +7 -6
- package/release.json +211 -129
- package/lib/callSessions.mjs +0 -51
- package/lib/directLink.mjs +0 -349
- package/lib/peopleBoard.mjs +0 -131
- package/lib/projects.mjs +0 -2917
- package/lib/roomChannels.mjs +0 -667
package/lib/worktrees.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { rebuildableKind } from "./rebuildable.mjs";
|
|
4
5
|
|
|
5
6
|
// A coding thread's own copy of the person's repository: a git worktree on its own branch, so several threads work
|
|
6
7
|
// at once without touching each other's files or the person's checkout. Each agent turn is committed on the branch,
|
|
@@ -14,7 +15,8 @@ const IDENTITY = [
|
|
|
14
15
|
];
|
|
15
16
|
const PATCH_LIMIT = 200_000;
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
// `raw`: the output as git wrote it, for a list whose first line may start with a space (git status).
|
|
19
|
+
function git(cwd, args, env = process.env, { raw = false } = {}) {
|
|
18
20
|
const result = spawnSync("git", [...IDENTITY, ...args], {
|
|
19
21
|
cwd,
|
|
20
22
|
env,
|
|
@@ -23,7 +25,7 @@ function git(cwd, args, env = process.env) {
|
|
|
23
25
|
});
|
|
24
26
|
return {
|
|
25
27
|
ok: result.status === 0,
|
|
26
|
-
out: (result.stdout || "").trim(),
|
|
28
|
+
out: raw ? result.stdout || "" : (result.stdout || "").trim(),
|
|
27
29
|
err: (result.stderr || "").trim(),
|
|
28
30
|
};
|
|
29
31
|
}
|
|
@@ -145,14 +147,14 @@ export function createWorktrees({ store, root }) {
|
|
|
145
147
|
: "something in the thread's copy replaced its .git";
|
|
146
148
|
};
|
|
147
149
|
/** git in a thread's copy, on the repository the daemon recorded, with no hooks and no file monitor. */
|
|
148
|
-
const inTree = (tree, args) => {
|
|
150
|
+
const inTree = (tree, args, options) => {
|
|
149
151
|
if (changedGit(tree)) return { ok: false, out: "", err: changedGit(tree) };
|
|
150
152
|
const env = {
|
|
151
153
|
...process.env,
|
|
152
154
|
GIT_DIR: gitDirOf(tree),
|
|
153
155
|
GIT_WORK_TREE: tree.path,
|
|
154
156
|
};
|
|
155
|
-
return git(tree.path, [...NO_HOOKS, ...args], env);
|
|
157
|
+
return git(tree.path, [...NO_HOOKS, ...args], env, options);
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
/** Where a thread's coding runs work: its worktree when the folder is in a repository, else the folder itself. */
|
|
@@ -169,8 +171,18 @@ export function createWorktrees({ store, root }) {
|
|
|
169
171
|
return path.join(current.path, current.inside);
|
|
170
172
|
const repo = repositoryOf(folder);
|
|
171
173
|
if (!repo) return folder;
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
+
// A copy kept after a merge (it held files never committed) still has the usual folder: the next one goes beside it.
|
|
175
|
+
const usual = path.join(root, thread.id);
|
|
176
|
+
let where = usual;
|
|
177
|
+
for (let next = 2; fs.existsSync(where); next++) where = `${usual}-${next}`;
|
|
178
|
+
let branch = `harness/${slug(thread.objective)}-${thread.id.slice(0, 8)}`;
|
|
179
|
+
for (
|
|
180
|
+
let next = 2;
|
|
181
|
+
git(repo.root, ["rev-parse", "--verify", "-q", `refs/heads/${branch}`])
|
|
182
|
+
.ok;
|
|
183
|
+
next++
|
|
184
|
+
)
|
|
185
|
+
branch = `harness/${slug(thread.objective)}-${thread.id.slice(0, 8)}-${next}`;
|
|
174
186
|
const base = git(repo.root, ["rev-parse", "HEAD"]).out;
|
|
175
187
|
fs.mkdirSync(root, { recursive: true });
|
|
176
188
|
const added = git(repo.root, [
|
|
@@ -303,6 +315,61 @@ export function createWorktrees({ store, root }) {
|
|
|
303
315
|
return { state: tree.state, branch: tree.branch, repo: tree.repo, files };
|
|
304
316
|
};
|
|
305
317
|
|
|
318
|
+
/**
|
|
319
|
+
* What in a thread's copy was never committed and cannot be made again: changed and new files, and ignored ones
|
|
320
|
+
* outside a rebuildable folder (rebuildable.mjs). Removing the copy would delete them. A copy git cannot read here
|
|
321
|
+
* is taken as holding something.
|
|
322
|
+
*/
|
|
323
|
+
const leftovers = (tree) => {
|
|
324
|
+
if (!fs.existsSync(tree.path)) return [];
|
|
325
|
+
const listed = inTree(
|
|
326
|
+
tree,
|
|
327
|
+
["status", "--porcelain=v1", "-z", "--untracked-files=all", "--ignored"],
|
|
328
|
+
{ raw: true }
|
|
329
|
+
);
|
|
330
|
+
if (!listed.ok) return [{ path: ".", why: listed.err || "unreadable" }];
|
|
331
|
+
const entries = listed.out.split("\0");
|
|
332
|
+
const left = [];
|
|
333
|
+
for (let index = 0; index < entries.length; index++) {
|
|
334
|
+
const entry = entries[index];
|
|
335
|
+
if (entry.length < 4) continue;
|
|
336
|
+
if (entry[0] === "R" || entry[0] === "C") index++;
|
|
337
|
+
const file = entry.slice(3);
|
|
338
|
+
if (entry.startsWith("!!")) {
|
|
339
|
+
const full = path.join(tree.path, file.replace(/\/$/, ""));
|
|
340
|
+
// Inside or itself a folder a tool makes again (dependencies, build output, caches).
|
|
341
|
+
const parts = file.split("/").filter(Boolean);
|
|
342
|
+
const rebuilt = parts.some((_, at) =>
|
|
343
|
+
rebuildableKind(path.join(tree.path, ...parts.slice(0, at + 1)))
|
|
344
|
+
);
|
|
345
|
+
if (rebuilt || rebuildableKind(full)) continue;
|
|
346
|
+
}
|
|
347
|
+
left.push({ path: file });
|
|
348
|
+
}
|
|
349
|
+
return left;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* A merged thread's copy that holds files never committed stays where it is, off its branch, so the branch can go and
|
|
353
|
+
* the person decides about the files; the next turn makes a copy of its own beside it.
|
|
354
|
+
*/
|
|
355
|
+
const keepMerged = (threadId, tree, into, tip, left) => {
|
|
356
|
+
inTree(tree, ["checkout", "-q", "--detach"]);
|
|
357
|
+
git(tree.repo, ["branch", "-d", tree.branch]);
|
|
358
|
+
save(threadId, {
|
|
359
|
+
...tree,
|
|
360
|
+
state: "merged",
|
|
361
|
+
into,
|
|
362
|
+
tip,
|
|
363
|
+
mergedAt: new Date().toISOString(),
|
|
364
|
+
left: left.length,
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
path: tree.path,
|
|
368
|
+
files: left.length,
|
|
369
|
+
named: left.slice(0, 5).map((entry) => entry.path),
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
|
|
306
373
|
const retire = (tree) => {
|
|
307
374
|
// A copy whose .git was replaced is not one git will remove; it is the daemon's own folder, so it goes as files.
|
|
308
375
|
const ours = path.relative(root, tree.path);
|
|
@@ -312,6 +379,29 @@ export function createWorktrees({ store, root }) {
|
|
|
312
379
|
git(tree.repo, ["worktree", "prune"]);
|
|
313
380
|
};
|
|
314
381
|
|
|
382
|
+
// What the person is in the middle of in their checkout, by the marks git leaves while it lasts. Harness's merge
|
|
383
|
+
// would be mixed into it, and undoing a conflict (merge --abort) would undo the person's own merge with it.
|
|
384
|
+
const UNDER_WAY = {
|
|
385
|
+
MERGE_HEAD: "a merge",
|
|
386
|
+
CHERRY_PICK_HEAD: "a cherry-pick",
|
|
387
|
+
REVERT_HEAD: "a revert",
|
|
388
|
+
REBASE_HEAD: "a rebase",
|
|
389
|
+
"rebase-merge": "a rebase",
|
|
390
|
+
"rebase-apply": "a rebase or git am",
|
|
391
|
+
};
|
|
392
|
+
const gitMark = (repo, name) => {
|
|
393
|
+
const where = git(repo, ["rev-parse", "--git-path", name]).out;
|
|
394
|
+
return Boolean(where) && fs.existsSync(path.resolve(repo, where));
|
|
395
|
+
};
|
|
396
|
+
// Why the person's checkout cannot take a merge now, or null.
|
|
397
|
+
const checkoutBusy = (repo) => {
|
|
398
|
+
const mark = Object.keys(UNDER_WAY).find((name) => gitMark(repo, name));
|
|
399
|
+
if (mark) return `${UNDER_WAY[mark]} is under way there; finish it first`;
|
|
400
|
+
if (!git(repo, ["symbolic-ref", "-q", "HEAD"]).ok)
|
|
401
|
+
return "no branch is checked out there (a detached HEAD); check one out first";
|
|
402
|
+
return null;
|
|
403
|
+
};
|
|
404
|
+
|
|
315
405
|
/** Brings the thread's branch into the branch the person has checked out. A conflict is undone and reported. */
|
|
316
406
|
const merge = (threadId, title) => {
|
|
317
407
|
const tree = get(threadId);
|
|
@@ -324,6 +414,12 @@ export function createWorktrees({ store, root }) {
|
|
|
324
414
|
};
|
|
325
415
|
if (!stat(tree, `${tree.base}..HEAD`).length)
|
|
326
416
|
return { ok: false, error: "this thread has not changed anything" };
|
|
417
|
+
const busy = checkoutBusy(tree.repo);
|
|
418
|
+
if (busy)
|
|
419
|
+
return {
|
|
420
|
+
ok: false,
|
|
421
|
+
error: `Harness did not merge into ${tree.repo}: ${busy}`,
|
|
422
|
+
};
|
|
327
423
|
const into = git(tree.repo, ["rev-parse", "--abbrev-ref", "HEAD"]).out;
|
|
328
424
|
const merged = git(tree.repo, [
|
|
329
425
|
"merge",
|
|
@@ -340,7 +436,9 @@ export function createWorktrees({ store, root }) {
|
|
|
340
436
|
])
|
|
341
437
|
.out.split("\n")
|
|
342
438
|
.filter(Boolean);
|
|
343
|
-
git(
|
|
439
|
+
// Only a merge this one started: git may refuse before starting one (files of the person's it would overwrite).
|
|
440
|
+
if (gitMark(tree.repo, "MERGE_HEAD"))
|
|
441
|
+
git(tree.repo, ["merge", "--abort"]);
|
|
344
442
|
return {
|
|
345
443
|
ok: false,
|
|
346
444
|
conflict: true,
|
|
@@ -352,6 +450,14 @@ export function createWorktrees({ store, root }) {
|
|
|
352
450
|
}
|
|
353
451
|
// The branch goes once it is merged; its last commit stays, so what it brought in can still be shown.
|
|
354
452
|
const tip = git(tree.repo, ["rev-parse", tree.branch]).out || null;
|
|
453
|
+
// What was never committed is never deleted by a merge: the copy stays with it, and the person hears where.
|
|
454
|
+
const left = leftovers(tree);
|
|
455
|
+
if (left.length)
|
|
456
|
+
return {
|
|
457
|
+
ok: true,
|
|
458
|
+
into,
|
|
459
|
+
left: keepMerged(threadId, tree, into, tip, left),
|
|
460
|
+
};
|
|
355
461
|
retire(tree);
|
|
356
462
|
git(tree.repo, ["branch", "-d", tree.branch]);
|
|
357
463
|
save(threadId, {
|
|
@@ -389,8 +495,11 @@ export function createWorktrees({ store, root }) {
|
|
|
389
495
|
ok: false,
|
|
390
496
|
error: `this thread changed files on ${tree.branch}; merge or discard them first`,
|
|
391
497
|
};
|
|
392
|
-
|
|
393
|
-
|
|
498
|
+
// Files never committed stay where they are; the copy is only forgotten (cleanup.mjs tells the person of it).
|
|
499
|
+
if (!leftovers(tree).length) {
|
|
500
|
+
retire(tree);
|
|
501
|
+
git(tree.repo, ["branch", "-D", tree.branch]);
|
|
502
|
+
}
|
|
394
503
|
}
|
|
395
504
|
if (tree) save(threadId, null);
|
|
396
505
|
return { ok: true };
|
|
@@ -449,9 +558,50 @@ export function createWorktrees({ store, root }) {
|
|
|
449
558
|
return inTree(tree, ["rev-parse", "HEAD"]).out || null;
|
|
450
559
|
};
|
|
451
560
|
|
|
561
|
+
/**
|
|
562
|
+
* A thread's branch the person merged outside Harness (another branch holds its last commit) counts as merged: its
|
|
563
|
+
* copy goes, or stays with what was never committed in it. Null when it is not merged, or has nothing of its own.
|
|
564
|
+
*/
|
|
565
|
+
const mergedElsewhere = (threadId) => {
|
|
566
|
+
const tree = openTree(threadId);
|
|
567
|
+
if (!tree || changedGit(tree)) return null;
|
|
568
|
+
const tip = git(tree.repo, [
|
|
569
|
+
"rev-parse",
|
|
570
|
+
"--verify",
|
|
571
|
+
"-q",
|
|
572
|
+
tree.branch,
|
|
573
|
+
]).out;
|
|
574
|
+
if (!tip || !stat(tree.repo, `${tree.base}..${tip}`).length) return null;
|
|
575
|
+
const into = git(tree.repo, [
|
|
576
|
+
"branch",
|
|
577
|
+
"--format=%(refname:short)",
|
|
578
|
+
"--contains",
|
|
579
|
+
tip,
|
|
580
|
+
])
|
|
581
|
+
.out.split("\n")
|
|
582
|
+
.find((branch) => branch && branch !== tree.branch);
|
|
583
|
+
if (!into) return null;
|
|
584
|
+
const left = leftovers(tree);
|
|
585
|
+
if (left.length)
|
|
586
|
+
return { into, left: keepMerged(threadId, tree, into, tip, left) };
|
|
587
|
+
retire(tree);
|
|
588
|
+
git(tree.repo, ["branch", "-d", tree.branch]);
|
|
589
|
+
save(threadId, {
|
|
590
|
+
...tree,
|
|
591
|
+
state: "merged",
|
|
592
|
+
into,
|
|
593
|
+
tip,
|
|
594
|
+
mergedAt: new Date().toISOString(),
|
|
595
|
+
});
|
|
596
|
+
return { into, left: null };
|
|
597
|
+
};
|
|
598
|
+
|
|
452
599
|
return {
|
|
453
600
|
/** The thread's copy as kept: where it is, its branch, what it started from, and open, merged, t3 or in place. */
|
|
454
601
|
record: get,
|
|
602
|
+
mergedElsewhere,
|
|
603
|
+
/** Where the threads' copies are made. */
|
|
604
|
+
root,
|
|
455
605
|
folderFor,
|
|
456
606
|
startTurn,
|
|
457
607
|
commitTurn,
|