tryharness 0.7.53 → 0.7.57
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 +23 -19
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +484 -90
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +173 -222
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +34 -18
- package/lib/agentSignIn.mjs +456 -0
- package/lib/answers.mjs +5 -5
- package/lib/archetypes.d.ts +64 -0
- package/lib/archetypes.js +989 -0
- package/lib/asks.mjs +4 -4
- package/lib/audit.mjs +666 -0
- package/lib/backupSetup.mjs +143 -0
- package/lib/boardAccess.mjs +24 -11
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +124 -25
- package/lib/boardProtocol.json +88 -2
- package/lib/boardWaits.mjs +101 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +6 -6
- package/lib/cards.mjs +138 -28
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +119 -0
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +19 -5
- package/lib/contractGate.mjs +399 -0
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +252 -144
- package/lib/daemon.mjs +1351 -2767
- package/lib/desk.mjs +240 -0
- package/lib/desktop.mjs +178 -74
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +247 -9
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +20 -16
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +25 -7
- package/lib/goals.mjs +7 -7
- package/lib/guestRequests.mjs +94 -0
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +4 -4
- package/lib/harnessModel.mjs +6 -6
- package/lib/harnessOffers.mjs +266 -0
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +887 -0
- package/lib/lane.mjs +42 -11
- package/lib/lessons.mjs +16 -16
- package/lib/library.mjs +3 -3
- package/lib/lineup.mjs +3 -0
- package/lib/linkRelay.mjs +574 -0
- package/lib/live.mjs +284 -13
- package/lib/localAgentAsk.mjs +74 -0
- package/lib/localStack.mjs +536 -0
- package/lib/localmodels.mjs +6 -4
- package/lib/loopBackstop.mjs +4 -4
- package/lib/machineIdentity.mjs +9 -1
- package/lib/machineRoutes.mjs +181 -2
- package/lib/machineRuns.mjs +76 -1
- package/lib/machineSeal.mjs +39 -12
- package/lib/mcp-stdio.mjs +163 -27
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +29 -2
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +85 -31
- package/lib/museSession.mjs +21 -13
- package/lib/nativeHost.mjs +36 -8
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +50 -19
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +1223 -140
- package/lib/pairing.mjs +60 -16
- package/lib/paths.mjs +19 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +89 -0
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +538 -31
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +400 -12
- package/lib/profile.mjs +67 -14
- package/lib/projectGit.mjs +158 -14
- package/lib/projectPieces.mjs +902 -0
- package/lib/projectSettings.mjs +7 -4
- package/lib/projects.mjs +384 -62
- package/lib/provenance.mjs +5 -1
- package/lib/proxyLinks.mjs +267 -0
- package/lib/reactions.mjs +7 -5
- package/lib/readiness.mjs +145 -23
- package/lib/record.mjs +128 -0
- package/lib/redact.mjs +4 -4
- package/lib/relayLimits.mjs +62 -0
- package/lib/release.mjs +170 -0
- package/lib/releaseKeys.json +6 -0
- package/lib/repoLinks.mjs +4 -4
- package/lib/roomChannels.mjs +24 -0
- package/lib/roomPage.mjs +1 -1
- package/lib/runAuthority.mjs +101 -0
- package/lib/runBrief.mjs +19 -8
- package/lib/runWorker.mjs +31 -7
- package/lib/runner.mjs +223 -29
- package/lib/runtime-install.mjs +143 -9
- package/lib/schedules.mjs +2 -2
- package/lib/screens.mjs +1 -1
- package/lib/sealed.mjs +11 -2
- package/lib/sealedThreads.mjs +671 -0
- package/lib/secretPatterns.json +1 -1
- package/lib/secrets.mjs +4 -4
- package/lib/seen.mjs +6 -6
- package/lib/serverWords.mjs +175 -0
- package/lib/service.mjs +22 -12
- package/lib/sessionControl.mjs +378 -90
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +57 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +420 -36
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +304 -37
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +24 -15
- package/lib/taskCommands.mjs +80 -20
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +45 -3
- package/lib/team.json +255 -148
- package/lib/team.mjs +554 -190
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +209 -50
- package/lib/threadView.mjs +20 -7
- package/lib/usageTotals.mjs +2 -3
- package/lib/vault.mjs +101 -10
- package/lib/vaultCloud.mjs +2 -2
- package/lib/vaultCommands.mjs +15 -6
- package/lib/vaultTools.js +2 -2
- package/lib/verdicts.mjs +328 -0
- package/lib/wakes.mjs +1 -1
- package/lib/watches.mjs +2 -2
- package/lib/windowAsks.mjs +13 -5
- package/lib/worktrees.mjs +157 -25
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +12 -11
- package/release.json +220 -0
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
package/lib/windowAsks.mjs
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
// This computer asking the person's own Harness window for what only it holds (phones.mjs ask): this computer's own
|
|
2
2
|
// windows first, then those linked to each of the person's other computers (ownMachines.mjs). With no Harness window
|
|
3
3
|
// open, the browser that listens for this computer (browserWake.mjs, the extension's native host) is woken: the
|
|
4
|
-
// extension brings up its hidden Harness page, which answers like a tab (
|
|
5
|
-
//
|
|
4
|
+
// extension brings up its hidden Harness page, which answers like a tab (the swarm reads what the person has seen from
|
|
5
|
+
// the hidden page). It is asked again as it comes up, until WAKE_DEADLINE_MS.
|
|
6
6
|
|
|
7
|
-
// How long to keep asking a woken hidden page:
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// How long to keep asking a woken hidden page: one minute, a chosen value. Measured only against a local app on
|
|
8
|
+
// loopback (an end-to-end test: closed page to answer 1.04 to 1.08 s, 5 samples on an M5 Pro), never against
|
|
9
|
+
// tryharness.ai.
|
|
10
10
|
export const WAKE_DEADLINE_MS = 60_000;
|
|
11
|
+
// What home may ask the windows linked to a worker (ownMachines.mjs): the person's screen history, as its agents' tools
|
|
12
|
+
// ask it (boardTools.mjs search_screen, seen.mjs). A worker refuses any other tool home names (security audit
|
|
13
|
+
// 2026-10-25, M6).
|
|
14
|
+
export const WINDOW_TOOLS = new Set([
|
|
15
|
+
"search_screen_text",
|
|
16
|
+
"search_screen_semantic",
|
|
17
|
+
"screen_seen_since",
|
|
18
|
+
]);
|
|
11
19
|
const ASK_EVERY_MS = 1_000;
|
|
12
20
|
|
|
13
21
|
export function createWindowAsks({
|
package/lib/worktrees.mjs
CHANGED
|
@@ -14,9 +14,10 @@ const IDENTITY = [
|
|
|
14
14
|
];
|
|
15
15
|
const PATCH_LIMIT = 200_000;
|
|
16
16
|
|
|
17
|
-
function git(cwd, args) {
|
|
17
|
+
function git(cwd, args, env = process.env) {
|
|
18
18
|
const result = spawnSync("git", [...IDENTITY, ...args], {
|
|
19
19
|
cwd,
|
|
20
|
+
env,
|
|
20
21
|
encoding: "utf8",
|
|
21
22
|
maxBuffer: 16 * 1024 * 1024,
|
|
22
23
|
});
|
|
@@ -27,6 +28,49 @@ function git(cwd, args) {
|
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
// A thread's copy is where an agent's run writes, a restricted one included, so nothing in it decides what git runs
|
|
32
|
+
// when the daemon commits there: the repository is the one the daemon recorded (GIT_DIR), never the copy's own .git
|
|
33
|
+
// file, and no hook or file monitor runs. A copy whose .git file no longer points where the daemon made it is not
|
|
34
|
+
// touched at all (changedGit).
|
|
35
|
+
const NO_HOOKS = [
|
|
36
|
+
"-c",
|
|
37
|
+
"core.hooksPath=/dev/null",
|
|
38
|
+
"-c",
|
|
39
|
+
"core.fsmonitor=false",
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// git writes every path it records resolved through symlinks (macOS's /var is /private/var), so a path the daemon
|
|
43
|
+
// holds is compared the same way.
|
|
44
|
+
const sameFile = (a, b) => {
|
|
45
|
+
const real = (file) => {
|
|
46
|
+
try {
|
|
47
|
+
return fs.realpathSync(file);
|
|
48
|
+
} catch {
|
|
49
|
+
return path.resolve(file);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return real(a) === real(b);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** The worktree's own folder in its repository's .git, found from the repository the person's checkout uses. */
|
|
56
|
+
function adminDirOf(repo, where) {
|
|
57
|
+
const common = git(repo, [
|
|
58
|
+
"rev-parse",
|
|
59
|
+
"--path-format=absolute",
|
|
60
|
+
"--git-common-dir",
|
|
61
|
+
]).out;
|
|
62
|
+
const admin = path.join(common, "worktrees");
|
|
63
|
+
const target = path.resolve(where, ".git");
|
|
64
|
+
for (const name of fs.existsSync(admin) ? fs.readdirSync(admin) : []) {
|
|
65
|
+
const pointer = path.join(admin, name, "gitdir");
|
|
66
|
+
try {
|
|
67
|
+
if (sameFile(fs.readFileSync(pointer, "utf8").trim(), target))
|
|
68
|
+
return path.join(admin, name);
|
|
69
|
+
} catch {}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
30
74
|
/** The repository a folder is in, and the folder's place inside it; null when it is not in one. */
|
|
31
75
|
export function repositoryOf(folder) {
|
|
32
76
|
if (!folder || !fs.existsSync(folder)) return null;
|
|
@@ -64,6 +108,10 @@ export function mainCheckout(folder) {
|
|
|
64
108
|
);
|
|
65
109
|
}
|
|
66
110
|
|
|
111
|
+
/** Files as a thread says them: the first five, and how many more. */
|
|
112
|
+
export const namedFiles = (files) =>
|
|
113
|
+
`${files.slice(0, 5).join(", ")}${files.length > 5 ? ` and ${files.length - 5} more` : ""}`;
|
|
114
|
+
|
|
67
115
|
const slug = (text) =>
|
|
68
116
|
String(text)
|
|
69
117
|
.toLowerCase()
|
|
@@ -80,6 +128,33 @@ export function createWorktrees({ store, root }) {
|
|
|
80
128
|
const save = (threadId, value) =>
|
|
81
129
|
store.meta(key(threadId), value ? JSON.stringify(value) : "null");
|
|
82
130
|
|
|
131
|
+
// The copy's repository as the daemon made it; a record from before it was kept is found from the person's checkout.
|
|
132
|
+
const gitDirOf = (tree) => tree.gitDir ?? adminDirOf(tree.repo, tree.path);
|
|
133
|
+
/** Why the daemon will not run git in a thread's copy, or null: its .git no longer points where the daemon made it. */
|
|
134
|
+
const changedGit = (tree) => {
|
|
135
|
+
const gitDir = gitDirOf(tree);
|
|
136
|
+
if (!gitDir)
|
|
137
|
+
return "Harness cannot find the repository it made this copy in";
|
|
138
|
+
let pointer = "";
|
|
139
|
+
try {
|
|
140
|
+
pointer = fs.readFileSync(path.join(tree.path, ".git"), "utf8").trim();
|
|
141
|
+
} catch {}
|
|
142
|
+
const named = /^gitdir: (.+)$/.exec(pointer)?.[1];
|
|
143
|
+
return named && sameFile(path.resolve(tree.path, named), gitDir)
|
|
144
|
+
? null
|
|
145
|
+
: "something in the thread's copy replaced its .git";
|
|
146
|
+
};
|
|
147
|
+
/** git in a thread's copy, on the repository the daemon recorded, with no hooks and no file monitor. */
|
|
148
|
+
const inTree = (tree, args) => {
|
|
149
|
+
if (changedGit(tree)) return { ok: false, out: "", err: changedGit(tree) };
|
|
150
|
+
const env = {
|
|
151
|
+
...process.env,
|
|
152
|
+
GIT_DIR: gitDirOf(tree),
|
|
153
|
+
GIT_WORK_TREE: tree.path,
|
|
154
|
+
};
|
|
155
|
+
return git(tree.path, [...NO_HOOKS, ...args], env);
|
|
156
|
+
};
|
|
157
|
+
|
|
83
158
|
/** Where a thread's coding runs work: its worktree when the folder is in a repository, else the folder itself. */
|
|
84
159
|
const folderFor = (thread) => {
|
|
85
160
|
const folder = thread.goal.workspace;
|
|
@@ -117,31 +192,66 @@ export function createWorktrees({ store, root }) {
|
|
|
117
192
|
path: where,
|
|
118
193
|
branch,
|
|
119
194
|
base,
|
|
195
|
+
gitDir: adminDirOf(repo.root, where),
|
|
120
196
|
});
|
|
121
197
|
return path.join(where, repo.inside);
|
|
122
198
|
};
|
|
123
199
|
|
|
124
|
-
|
|
125
|
-
const commitTurn = (threadId, runId, message) => {
|
|
200
|
+
const openTree = (threadId) => {
|
|
126
201
|
const tree = get(threadId);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
202
|
+
return tree?.state === "open" && fs.existsSync(tree.path) ? tree : null;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/** Where the thread's branch is as a turn starts, so commits the agent makes itself count as that turn's too. */
|
|
206
|
+
const startTurn = (threadId, runId) => {
|
|
207
|
+
const tree = openTree(threadId);
|
|
208
|
+
if (!tree) return;
|
|
209
|
+
store.meta(`turn-from:${runId}`, inTree(tree, ["rev-parse", "HEAD"]).out);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Commits what a turn left uncommitted on the thread's branch. The turn's diff runs from where the branch was when it
|
|
214
|
+
* started (startTurn) to the commit it ends on, so commits the agent made itself are its own too. Null when the turn
|
|
215
|
+
* changed nothing on the branch.
|
|
216
|
+
*/
|
|
217
|
+
const commitTurn = (threadId, runId, message) => {
|
|
218
|
+
const tree = openTree(threadId);
|
|
219
|
+
if (!tree || changedGit(tree)) return null;
|
|
220
|
+
inTree(tree, ["add", "-A"]);
|
|
221
|
+
const staged = !inTree(tree, ["diff", "--cached", "--quiet"]).ok;
|
|
222
|
+
const committed =
|
|
223
|
+
staged &&
|
|
224
|
+
inTree(tree, [
|
|
225
|
+
"commit",
|
|
226
|
+
"-q",
|
|
227
|
+
"--no-verify",
|
|
228
|
+
"-m",
|
|
229
|
+
String(message).slice(0, 200),
|
|
230
|
+
]).ok;
|
|
231
|
+
const sha = inTree(tree, ["rev-parse", "HEAD"]).out;
|
|
232
|
+
// A turn from before turns recorded their start counts only the commit made here.
|
|
233
|
+
const from = store.meta(`turn-from:${runId}`);
|
|
234
|
+
const moved = from ? sha !== from : committed;
|
|
235
|
+
if (!moved) return null;
|
|
139
236
|
store.meta(`turn:${runId}`, sha);
|
|
140
237
|
return sha;
|
|
141
238
|
};
|
|
142
239
|
|
|
143
|
-
|
|
144
|
-
|
|
240
|
+
/** The files in the thread's copy that are not committed on its branch, such as a change git would not commit. */
|
|
241
|
+
const uncommitted = (threadId) => {
|
|
242
|
+
const tree = openTree(threadId);
|
|
243
|
+
if (!tree) return [];
|
|
244
|
+
const lines = (args) => inTree(tree, args).out.split("\n").filter(Boolean);
|
|
245
|
+
const changed = lines(["diff", "--name-only", "HEAD"]);
|
|
246
|
+
const added = lines(["ls-files", "--others", "--exclude-standard"]);
|
|
247
|
+
return [...new Set([...changed, ...added])];
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// `where`: a thread's copy (its record) or the person's checkout (a folder).
|
|
251
|
+
const run = (where, args) =>
|
|
252
|
+
typeof where === "string" ? git(where, args) : inTree(where, args);
|
|
253
|
+
const stat = (where, range) => {
|
|
254
|
+
const out = run(where, ["diff", "--numstat", range]).out;
|
|
145
255
|
const files = out
|
|
146
256
|
? out.split("\n").map((line) => {
|
|
147
257
|
const [added, removed, file] = line.split("\t");
|
|
@@ -160,15 +270,16 @@ export function createWorktrees({ store, root }) {
|
|
|
160
270
|
const tree = get(threadId);
|
|
161
271
|
if (!tree)
|
|
162
272
|
return { ok: false, error: "this thread has no copy of a repository" };
|
|
163
|
-
const cwd = fs.existsSync(tree.path) ? tree
|
|
273
|
+
const cwd = fs.existsSync(tree.path) ? tree : tree.repo;
|
|
164
274
|
let range;
|
|
165
275
|
if (runId) {
|
|
166
276
|
const sha = store.meta(`turn:${runId}`);
|
|
167
277
|
if (!sha) return { ok: true, files: [], patch: "" };
|
|
168
|
-
|
|
278
|
+
const from = store.meta(`turn-from:${runId}`);
|
|
279
|
+
range = from ? `${from}..${sha}` : `${sha}~1..${sha}`;
|
|
169
280
|
} else
|
|
170
281
|
range = `${tree.base}..${tree.state === "open" ? "HEAD" : tree.branch}`;
|
|
171
|
-
const patch =
|
|
282
|
+
const patch = run(cwd, ["diff", range]).out;
|
|
172
283
|
return {
|
|
173
284
|
ok: true,
|
|
174
285
|
files: stat(cwd, range),
|
|
@@ -187,13 +298,17 @@ export function createWorktrees({ store, root }) {
|
|
|
187
298
|
if (!tree || tree.state === "in_place" || tree.state === "t3") return null;
|
|
188
299
|
const files =
|
|
189
300
|
tree.state === "open" && fs.existsSync(tree.path)
|
|
190
|
-
? stat(tree
|
|
301
|
+
? stat(tree, `${tree.base}..HEAD`).length
|
|
191
302
|
: 0;
|
|
192
303
|
return { state: tree.state, branch: tree.branch, repo: tree.repo, files };
|
|
193
304
|
};
|
|
194
305
|
|
|
195
306
|
const retire = (tree) => {
|
|
196
|
-
git
|
|
307
|
+
// 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
|
+
const ours = path.relative(root, tree.path);
|
|
309
|
+
if (changedGit(tree) && ours && !ours.startsWith(".."))
|
|
310
|
+
fs.rmSync(tree.path, { recursive: true, force: true });
|
|
311
|
+
else git(tree.repo, ["worktree", "remove", "--force", tree.path]);
|
|
197
312
|
git(tree.repo, ["worktree", "prune"]);
|
|
198
313
|
};
|
|
199
314
|
|
|
@@ -202,7 +317,12 @@ export function createWorktrees({ store, root }) {
|
|
|
202
317
|
const tree = get(threadId);
|
|
203
318
|
if (!tree || tree.state !== "open")
|
|
204
319
|
return { ok: false, error: "there is nothing of this thread's to merge" };
|
|
205
|
-
if (
|
|
320
|
+
if (changedGit(tree))
|
|
321
|
+
return {
|
|
322
|
+
ok: false,
|
|
323
|
+
error: `${changedGit(tree)}, so Harness does not merge it; discard it`,
|
|
324
|
+
};
|
|
325
|
+
if (!stat(tree, `${tree.base}..HEAD`).length)
|
|
206
326
|
return { ok: false, error: "this thread has not changed anything" };
|
|
207
327
|
const into = git(tree.repo, ["rev-parse", "--abbrev-ref", "HEAD"]).out;
|
|
208
328
|
const merged = git(tree.repo, [
|
|
@@ -230,12 +350,15 @@ export function createWorktrees({ store, root }) {
|
|
|
230
350
|
: `git would not merge into ${into}: ${merged.err.split("\n")[0]}; nothing was merged`,
|
|
231
351
|
};
|
|
232
352
|
}
|
|
353
|
+
// The branch goes once it is merged; its last commit stays, so what it brought in can still be shown.
|
|
354
|
+
const tip = git(tree.repo, ["rev-parse", tree.branch]).out || null;
|
|
233
355
|
retire(tree);
|
|
234
356
|
git(tree.repo, ["branch", "-d", tree.branch]);
|
|
235
357
|
save(threadId, {
|
|
236
358
|
...tree,
|
|
237
359
|
state: "merged",
|
|
238
360
|
into,
|
|
361
|
+
tip,
|
|
239
362
|
mergedAt: new Date().toISOString(),
|
|
240
363
|
});
|
|
241
364
|
return { ok: true, into };
|
|
@@ -261,7 +384,7 @@ export function createWorktrees({ store, root }) {
|
|
|
261
384
|
const moved = (threadId) => {
|
|
262
385
|
const tree = get(threadId);
|
|
263
386
|
if (tree?.state === "open" && fs.existsSync(tree.path)) {
|
|
264
|
-
if (stat(tree
|
|
387
|
+
if (stat(tree, `${tree.base}..HEAD`).length)
|
|
265
388
|
return {
|
|
266
389
|
ok: false,
|
|
267
390
|
error: `this thread changed files on ${tree.branch}; merge or discard them first`,
|
|
@@ -323,12 +446,21 @@ export function createWorktrees({ store, root }) {
|
|
|
323
446
|
const tree = get(threadId);
|
|
324
447
|
if (!tree || tree.state !== "open" || !fs.existsSync(tree.path))
|
|
325
448
|
return null;
|
|
326
|
-
return
|
|
449
|
+
return inTree(tree, ["rev-parse", "HEAD"]).out || null;
|
|
327
450
|
};
|
|
328
451
|
|
|
329
452
|
return {
|
|
453
|
+
/** The thread's copy as kept: where it is, its branch, what it started from, and open, merged, t3 or in place. */
|
|
454
|
+
record: get,
|
|
330
455
|
folderFor,
|
|
456
|
+
startTurn,
|
|
331
457
|
commitTurn,
|
|
458
|
+
/** Why the daemon no longer runs git in the thread's copy, or null (a run replaced its .git). */
|
|
459
|
+
changedGit: (threadId) => {
|
|
460
|
+
const tree = openTree(threadId);
|
|
461
|
+
return tree ? changedGit(tree) : null;
|
|
462
|
+
},
|
|
463
|
+
uncommitted,
|
|
332
464
|
head,
|
|
333
465
|
diff,
|
|
334
466
|
summary,
|