tryharness 0.7.53 → 0.7.54
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 +10 -5
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +115 -36
- package/lib/adapters.mjs +157 -222
- package/lib/agentRuntimes.mjs +26 -16
- package/lib/agentSignIn.mjs +226 -0
- package/lib/audit.mjs +643 -0
- package/lib/backupSetup.mjs +141 -0
- package/lib/boardAccess.mjs +8 -1
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardMirror.mjs +71 -7
- package/lib/boardProtocol.json +59 -2
- package/lib/boardWaits.mjs +102 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +1 -1
- package/lib/cards.mjs +138 -28
- package/lib/cloudBoot.mjs +124 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +18 -4
- package/lib/contractGate.mjs +377 -0
- package/lib/coordinator.mjs +149 -43
- package/lib/daemon.mjs +349 -28
- package/lib/desk.mjs +239 -0
- package/lib/desktop.mjs +106 -6
- package/lib/environments.mjs +237 -7
- package/lib/folders.mjs +2 -2
- package/lib/gitHost.mjs +174 -0
- package/lib/hookDialects.mjs +298 -0
- package/lib/landed.mjs +887 -0
- package/lib/live.mjs +284 -13
- package/lib/mcp-stdio.mjs +68 -2
- package/lib/members.json +16 -2
- package/lib/models.mjs +8 -8
- package/lib/museSession.mjs +16 -13
- package/lib/nativeHost.mjs +1 -1
- package/lib/neovim.mjs +126 -0
- package/lib/nudge.mjs +47 -16
- package/lib/ownMachines.mjs +343 -39
- package/lib/pairing.mjs +27 -10
- package/lib/paths.mjs +4 -0
- package/lib/personModel.mjs +89 -0
- package/lib/phones.mjs +66 -11
- package/lib/places.mjs +330 -10
- package/lib/readiness.mjs +135 -18
- package/lib/record.mjs +115 -0
- package/lib/runWorker.mjs +17 -2
- package/lib/runner.mjs +8 -4
- package/lib/sessionControl.mjs +377 -89
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +58 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/store.mjs +284 -1
- package/lib/swarm.mjs +137 -21
- package/lib/t3.mjs +13 -4
- package/lib/taskCommands.mjs +36 -9
- package/lib/taskRuns.mjs +9 -2
- package/lib/team.json +255 -148
- package/lib/team.mjs +529 -188
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +75 -11
- package/lib/threadView.mjs +15 -2
- package/lib/worktrees.mjs +51 -13
- package/package.json +4 -4
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { askLocal } from "./personModel.mjs";
|
|
2
|
+
|
|
3
|
+
// The line that puts the person back into a thread at a glance (owner, October 23: "what was the last thing I said
|
|
4
|
+
// here", and titles are "incredibly lossy"): their last move, in their own words, and what it was about.
|
|
5
|
+
// "go ahead and deploy" → "deploy DeepSeek support".
|
|
6
|
+
//
|
|
7
|
+
// Most of what a person last says in a thread answers the agent ("yes", "commit this"), and agents end by asking them
|
|
8
|
+
// to decide something. So agents name it in a last line, `Deciding: deploy DeepSeek support` (mcp-stdio.mjs's
|
|
9
|
+
// instructions), and a short reply right after one is about that. A longer message is a new ask or a steer: the
|
|
10
|
+
// person's own local model names its work, when they have one (personModel.mjs). With neither, the thread's title says
|
|
11
|
+
// what it is about. Worked out once per message and kept, never while the person waits.
|
|
12
|
+
|
|
13
|
+
/** A reply this short answers what the agent asked rather than saying something new. */
|
|
14
|
+
const SHORT_WORDS = 8;
|
|
15
|
+
/** What is kept of a move or what it was about. */
|
|
16
|
+
const MOVE_CHARS = 60;
|
|
17
|
+
const ABOUT_CHARS = 80;
|
|
18
|
+
|
|
19
|
+
const NAME_WORK = `You label a message a person sent to an AI agent, so that weeks later they recognize the thread at a glance.
|
|
20
|
+
Reply with JSON only: {"move": "...", "object": "..."}.
|
|
21
|
+
- move: 1 to 3 words for what the person asked for, in their own word when they used one (look into, fix, build, write, remake, deep dive). A question: "asked".
|
|
22
|
+
- object: 2 to 6 words naming the work: the feature, bug, decision or document. Never mechanics: no file counts, "the change", "this", "it".
|
|
23
|
+
Lowercase except names. No sentences. Think briefly.`;
|
|
24
|
+
|
|
25
|
+
const tidy = (text) =>
|
|
26
|
+
String(text ?? "")
|
|
27
|
+
.replace(/\s+/g, " ")
|
|
28
|
+
.trim();
|
|
29
|
+
const words = (text) => tidy(text).split(" ").filter(Boolean);
|
|
30
|
+
const cut = (text, limit) => {
|
|
31
|
+
const clean = tidy(text);
|
|
32
|
+
if (clean.length <= limit) return clean;
|
|
33
|
+
const end = clean.lastIndexOf(" ", limit - 1);
|
|
34
|
+
return `${clean.slice(0, end > limit / 2 ? end : limit - 1)}…`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** What an agent's message asks the person to decide: its last `Deciding:` line, or null. */
|
|
38
|
+
export function decidingOf(text) {
|
|
39
|
+
const lines = String(text ?? "").split("\n");
|
|
40
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
41
|
+
const said = /^\s*[*_]*deciding:[*_]*\s*(.+?)\s*$/i.exec(lines[i]);
|
|
42
|
+
if (!said) continue;
|
|
43
|
+
const named = said[1].replace(/^[`*_"]+|[`*_".]+$/g, "").trim();
|
|
44
|
+
return named ? cut(named, ABOUT_CHARS) : null;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* `store` keeps each thread's line by the message it was made from. `nameWork(message)`, when given, names a longer
|
|
51
|
+
* message's work ({ move, object } or null); by default the person's local model does.
|
|
52
|
+
*/
|
|
53
|
+
export function createThreadLine({
|
|
54
|
+
store,
|
|
55
|
+
log = () => {},
|
|
56
|
+
nameWork = (message) => askLocal(NAME_WORK, message),
|
|
57
|
+
}) {
|
|
58
|
+
const kept = (key) => {
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(store.meta(`thread-line:${key}`) || "null");
|
|
61
|
+
} catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
// One label at a time: the local model runs on the person's computer.
|
|
66
|
+
let queue = Promise.resolve();
|
|
67
|
+
|
|
68
|
+
async function lineOf({ title, mine, answered }) {
|
|
69
|
+
const at = mine.at ?? null;
|
|
70
|
+
if (words(mine.text).length <= SHORT_WORDS) {
|
|
71
|
+
const asked = decidingOf(answered);
|
|
72
|
+
return {
|
|
73
|
+
move: cut(mine.text, MOVE_CHARS),
|
|
74
|
+
about: asked ?? cut(title, ABOUT_CHARS),
|
|
75
|
+
by: asked ? "agent" : "title",
|
|
76
|
+
at,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const named = await nameWork(cut(mine.text, 1500)).catch(() => null);
|
|
80
|
+
if (named?.move && named?.object)
|
|
81
|
+
return {
|
|
82
|
+
move: cut(named.move, MOVE_CHARS),
|
|
83
|
+
about: cut(named.object, ABOUT_CHARS),
|
|
84
|
+
by: "model",
|
|
85
|
+
at,
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
move: `${words(mine.text).slice(0, 4).join(" ")}…`,
|
|
89
|
+
about: cut(title, ABOUT_CHARS),
|
|
90
|
+
by: "title",
|
|
91
|
+
at,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
/** The thread's line, as last worked out, or null. */
|
|
97
|
+
of: (key) => kept(key)?.line ?? null,
|
|
98
|
+
/**
|
|
99
|
+
* Works out the thread's line from the person's last message (`mine`: id, text, at) and the agent's message before
|
|
100
|
+
* it (`answered`, its text), unless it was already made from that message. Resolves to whether it changed.
|
|
101
|
+
*/
|
|
102
|
+
update(key, { title, mine, answered = null }) {
|
|
103
|
+
const next = queue.then(async () => {
|
|
104
|
+
if (kept(key)?.message === mine.id) return false;
|
|
105
|
+
const line = await lineOf({ title, mine, answered });
|
|
106
|
+
store.meta(
|
|
107
|
+
`thread-line:${key}`,
|
|
108
|
+
JSON.stringify({ message: mine.id, line })
|
|
109
|
+
);
|
|
110
|
+
return true;
|
|
111
|
+
});
|
|
112
|
+
queue = next.catch((error) => log(`thread line: ${error.message}`));
|
|
113
|
+
return next.catch(() => false);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
package/lib/threadRuns.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import { oneLine } from "./oneLine.mjs";
|
|
|
6
6
|
import { setRunPick } from "./models.mjs";
|
|
7
7
|
import { t3Access, startT3SignIn, steerT3Run } from "./t3.mjs";
|
|
8
8
|
import { t3Model, t3Open, t3Project, t3Provider } from "./places.mjs";
|
|
9
|
+
import { within } from "./folders.mjs";
|
|
10
|
+
import { namedFiles } from "./worktrees.mjs";
|
|
9
11
|
|
|
10
12
|
// The agents with a read-only switch (runner.mjs): only they talk out a clash in a shared project without waiting.
|
|
11
13
|
const REVIEWERS = new Set(
|
|
@@ -31,6 +33,8 @@ export function createThreadRuns({
|
|
|
31
33
|
placeElsewhere = () => null,
|
|
32
34
|
// Projects shared with another person's swarm (projects.mjs): their check before work, and each agent's own branch.
|
|
33
35
|
projects = () => null,
|
|
36
|
+
// The step of the thread's route an agent was last given (team.mjs), or null.
|
|
37
|
+
stepHeld = () => null,
|
|
34
38
|
}) {
|
|
35
39
|
const { RUNNERS } = authority;
|
|
36
40
|
const inT3 = (thread, agent, review) => {
|
|
@@ -68,18 +72,32 @@ export function createThreadRuns({
|
|
|
68
72
|
? { in: "t3", why: null }
|
|
69
73
|
: { in: "here", why: gap };
|
|
70
74
|
};
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
|
|
75
|
+
// Whether a task works in its thread's folder: the thread's repository, or Harness's copy of it where the agent that
|
|
76
|
+
// handed the work on was running.
|
|
77
|
+
const inThreadFolder = (task, room) => {
|
|
78
|
+
const folder = path.resolve(task.run_workspace);
|
|
79
|
+
const copy = worktrees.get(room.id)?.path;
|
|
80
|
+
return (
|
|
81
|
+
within(folder, room.goal.workspace) ||
|
|
82
|
+
Boolean(copy && within(folder, copy))
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
// A task's run goes where its room's turns go: into T3 Code when the person uses the agent there. That is the room's
|
|
86
|
+
// first job, and work an agent handed on into a thread in that thread's folder, a turn of the agent there like any
|
|
87
|
+
// other (owner, October 23: it opens where the person uses that agent most). Not when it would run restricted (work
|
|
88
|
+
// another agent asked for on a goal's authority): only this computer holds a run to that. Nor in a shared project,
|
|
89
|
+
// whose agents work on their own branches here.
|
|
74
90
|
const taskInT3 = (task, agent) => {
|
|
75
91
|
const room = task.parent_id ? store.getTask(task.parent_id) : null;
|
|
76
92
|
if (
|
|
77
93
|
task.kind !== "task" ||
|
|
78
94
|
room?.kind !== "goal" ||
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
!task.run_workspace ||
|
|
96
|
+
projects()?.isProjectRoom(room.id)
|
|
81
97
|
)
|
|
82
98
|
return false;
|
|
99
|
+
const ownJob = store.meta(`task-room:${room.id}`) === task.id;
|
|
100
|
+
if (!ownJob && !inThreadFolder(task, room)) return false;
|
|
83
101
|
const restricted =
|
|
84
102
|
task.trust !== "user" &&
|
|
85
103
|
task.run_authorized_by === "goal" &&
|
|
@@ -438,7 +456,7 @@ export function createThreadRuns({
|
|
|
438
456
|
const key = `overlap:${[goalId, other.id].sort().join(":")}:${shared.join(",")}`;
|
|
439
457
|
if (!shared.length || store.meta(key)) continue;
|
|
440
458
|
store.meta(key, "1");
|
|
441
|
-
const named =
|
|
459
|
+
const named = namedFiles(shared);
|
|
442
460
|
for (const [here, there] of [
|
|
443
461
|
[goalId, other],
|
|
444
462
|
[other.id, store.getTask(goalId)],
|
|
@@ -453,16 +471,61 @@ export function createThreadRuns({
|
|
|
453
471
|
}
|
|
454
472
|
}
|
|
455
473
|
};
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
const
|
|
474
|
+
// A run that may change its thread's copy: every turn woken there, and work handed on as a task into that copy. A
|
|
475
|
+
// review runs read-only (runner.mjs) beside whoever writes there, so what it would commit is never its own.
|
|
476
|
+
const inThreadCopy = (task) => {
|
|
477
|
+
const thread = task.parent_id ? store.getTask(task.parent_id) : null;
|
|
478
|
+
if (thread?.kind !== "goal" || !task.run_workspace) return false;
|
|
479
|
+
if (store.meta(`review:${task.id}`) === "1") return false;
|
|
480
|
+
if (task.kind === "wake") return true;
|
|
481
|
+
const copy = worktrees.get(thread.id)?.path;
|
|
482
|
+
return Boolean(copy && within(path.resolve(task.run_workspace), copy));
|
|
483
|
+
};
|
|
484
|
+
const startTurn = (task) => {
|
|
485
|
+
if (inThreadCopy(task)) worktrees.startTurn(task.parent_id, task.id);
|
|
486
|
+
};
|
|
487
|
+
// For code, made means committed on the thread's branch: a run's changes in its thread's copy are committed as soon
|
|
488
|
+
// as it ends, whatever kind of run it was, before another run can start there. A shared project's agent commits on
|
|
489
|
+
// its own branch (projects.mjs, undefined for any other thread).
|
|
490
|
+
const commitRun = (task) => {
|
|
491
|
+
if (!inThreadCopy(task)) return null;
|
|
459
492
|
const onBranch = projects()?.committed(task);
|
|
460
493
|
if (onBranch !== undefined) return onBranch;
|
|
461
|
-
|
|
494
|
+
const sha = worktrees.commitTurn(
|
|
462
495
|
task.parent_id,
|
|
463
496
|
task.id,
|
|
464
497
|
`${task.target_agent}: ${task.objective.replace(/^Room: /, "")}`
|
|
465
498
|
);
|
|
499
|
+
noteUncommitted(task);
|
|
500
|
+
return sha;
|
|
501
|
+
};
|
|
502
|
+
// What git would not commit (a hook refused it, say) stays in the copy. After a make run it is a fact: the thread's,
|
|
503
|
+
// for the next check's brief (team.mjs) until the branch is clean again, and the run's, for the audit (audit.mjs),
|
|
504
|
+
// with a note naming the agent and the files. A check or a frame does not make the change.
|
|
505
|
+
const noteUncommitted = (task) => {
|
|
506
|
+
const goalId = task.parent_id;
|
|
507
|
+
const files = worktrees.uncommitted(goalId);
|
|
508
|
+
if (!files.length) {
|
|
509
|
+
if (store.meta(`uncommitted:${goalId}`))
|
|
510
|
+
store.meta(`uncommitted:${goalId}`, "");
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const agent = task.target_agent;
|
|
514
|
+
const step = store.getTask(task.id)?.step ?? stepHeld(goalId, agent);
|
|
515
|
+
const makes = !step || step === "make";
|
|
516
|
+
if (!makes) return;
|
|
517
|
+
store.meta(
|
|
518
|
+
`uncommitted:${goalId}`,
|
|
519
|
+
JSON.stringify({ agent, files, run: task.id })
|
|
520
|
+
);
|
|
521
|
+
store.meta(`uncommitted:${task.id}`, JSON.stringify({ files }));
|
|
522
|
+
store.roomPost({
|
|
523
|
+
goalId,
|
|
524
|
+
author: "harness",
|
|
525
|
+
kind: "note",
|
|
526
|
+
text: `${nameOf(agent)}'s change is not committed on this thread's branch, so it is not made yet: ${namedFiles(files)} ${files.length === 1 ? "is" : "are"} still uncommitted in the thread's copy.`,
|
|
527
|
+
});
|
|
528
|
+
notifyBoard(store.getTask(goalId));
|
|
466
529
|
};
|
|
467
530
|
const settleWake = (task, kind, text, startedAt) => {
|
|
468
531
|
const goalId = task.parent_id;
|
|
@@ -544,7 +607,8 @@ export function createThreadRuns({
|
|
|
544
607
|
recover,
|
|
545
608
|
where: runsIn,
|
|
546
609
|
worker: {
|
|
547
|
-
|
|
610
|
+
startTurn,
|
|
611
|
+
commitRun,
|
|
548
612
|
settleWake,
|
|
549
613
|
wakeBrief,
|
|
550
614
|
ranOutsideT3,
|
package/lib/threadView.mjs
CHANGED
|
@@ -90,6 +90,11 @@ export function createThreadView({
|
|
|
90
90
|
computerOf = () => null,
|
|
91
91
|
// Whether the person's browser is listening for this computer (browserWake.mjs), so Harness can use it now.
|
|
92
92
|
browserListening = () => false,
|
|
93
|
+
// Where the person left the thread: their last move and what it was about (threadLine.mjs).
|
|
94
|
+
whereLeft = () => null,
|
|
95
|
+
// What waits on the person about an agent rather than a thread (kind "agent", specialtyNotice.mjs): an agent not
|
|
96
|
+
// living up to a specialty. Each opens the agent in the Swarm map.
|
|
97
|
+
agentNeeds = () => [],
|
|
93
98
|
}) {
|
|
94
99
|
// Words from an agent on the person's computers say which one: the buddy reads it "Codex (linux)".
|
|
95
100
|
const writtenOn = (post) => {
|
|
@@ -325,6 +330,7 @@ export function createThreadView({
|
|
|
325
330
|
if (item.kind === "review") return "Ready for your review";
|
|
326
331
|
if (item.kind === "held") return item.text;
|
|
327
332
|
if (item.kind === "window") return "Harness needs your browser to finish";
|
|
333
|
+
if (item.kind === "agent") return item.text;
|
|
328
334
|
return `${who} needs you to decide: ${shorten(item.text, 120)}`;
|
|
329
335
|
}
|
|
330
336
|
|
|
@@ -350,6 +356,7 @@ export function createThreadView({
|
|
|
350
356
|
late: state === "working" && Boolean(lateHandoff(runs)),
|
|
351
357
|
needsYou: items,
|
|
352
358
|
done: doneOf(thread, state, posts),
|
|
359
|
+
you: whereLeft(thread.id),
|
|
353
360
|
};
|
|
354
361
|
}
|
|
355
362
|
|
|
@@ -485,8 +492,14 @@ export function createThreadView({
|
|
|
485
492
|
const items = needsYouOf(thread, posts, store.threadRuns(thread.id));
|
|
486
493
|
const title = titleOf(thread, posts);
|
|
487
494
|
return items.map((item) => ({ ...item, threadId: thread.id, title }));
|
|
488
|
-
})
|
|
495
|
+
})
|
|
496
|
+
.concat(swarmNeeds().map((item) => ({ ...item, threadId: null })));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/** What waits on the person outside any thread, newest last: the same items on every surface. */
|
|
500
|
+
function swarmNeeds() {
|
|
501
|
+
return agentNeeds();
|
|
489
502
|
}
|
|
490
503
|
|
|
491
|
-
return { row, timeline, file, waiting, itemLine };
|
|
504
|
+
return { row, timeline, file, waiting, itemLine, swarmNeeds };
|
|
492
505
|
}
|
package/lib/worktrees.mjs
CHANGED
|
@@ -64,6 +64,10 @@ export function mainCheckout(folder) {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** Files as a thread says them: the first five, and how many more. */
|
|
68
|
+
export const namedFiles = (files) =>
|
|
69
|
+
`${files.slice(0, 5).join(", ")}${files.length > 5 ? ` and ${files.length - 5} more` : ""}`;
|
|
70
|
+
|
|
67
71
|
const slug = (text) =>
|
|
68
72
|
String(text)
|
|
69
73
|
.toLowerCase()
|
|
@@ -121,25 +125,51 @@ export function createWorktrees({ store, root }) {
|
|
|
121
125
|
return path.join(where, repo.inside);
|
|
122
126
|
};
|
|
123
127
|
|
|
124
|
-
|
|
125
|
-
const commitTurn = (threadId, runId, message) => {
|
|
128
|
+
const openTree = (threadId) => {
|
|
126
129
|
const tree = get(threadId);
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
return tree?.state === "open" && fs.existsSync(tree.path) ? tree : null;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/** Where the thread's branch is as a turn starts, so commits the agent makes itself count as that turn's too. */
|
|
134
|
+
const startTurn = (threadId, runId) => {
|
|
135
|
+
const tree = openTree(threadId);
|
|
136
|
+
if (!tree) return;
|
|
137
|
+
store.meta(`turn-from:${runId}`, git(tree.path, ["rev-parse", "HEAD"]).out);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Commits what a turn left uncommitted on the thread's branch. The turn's diff runs from where the branch was when it
|
|
142
|
+
* started (startTurn) to the commit it ends on, so commits the agent made itself are its own too. Null when the turn
|
|
143
|
+
* changed nothing on the branch.
|
|
144
|
+
*/
|
|
145
|
+
const commitTurn = (threadId, runId, message) => {
|
|
146
|
+
const tree = openTree(threadId);
|
|
147
|
+
if (!tree) return null;
|
|
129
148
|
git(tree.path, ["add", "-A"]);
|
|
130
|
-
|
|
131
|
-
const committed =
|
|
132
|
-
|
|
133
|
-
"-q",
|
|
134
|
-
"-m",
|
|
135
|
-
String(message).slice(0, 200),
|
|
136
|
-
]);
|
|
137
|
-
if (!committed.ok) return null;
|
|
149
|
+
const staged = !git(tree.path, ["diff", "--cached", "--quiet"]).ok;
|
|
150
|
+
const committed =
|
|
151
|
+
staged &&
|
|
152
|
+
git(tree.path, ["commit", "-q", "-m", String(message).slice(0, 200)]).ok;
|
|
138
153
|
const sha = git(tree.path, ["rev-parse", "HEAD"]).out;
|
|
154
|
+
// A turn from before turns recorded their start counts only the commit made here.
|
|
155
|
+
const from = store.meta(`turn-from:${runId}`);
|
|
156
|
+
const moved = from ? sha !== from : committed;
|
|
157
|
+
if (!moved) return null;
|
|
139
158
|
store.meta(`turn:${runId}`, sha);
|
|
140
159
|
return sha;
|
|
141
160
|
};
|
|
142
161
|
|
|
162
|
+
/** The files in the thread's copy that are not committed on its branch, such as a change git would not commit. */
|
|
163
|
+
const uncommitted = (threadId) => {
|
|
164
|
+
const tree = openTree(threadId);
|
|
165
|
+
if (!tree) return [];
|
|
166
|
+
const lines = (args) =>
|
|
167
|
+
git(tree.path, args).out.split("\n").filter(Boolean);
|
|
168
|
+
const changed = lines(["diff", "--name-only", "HEAD"]);
|
|
169
|
+
const added = lines(["ls-files", "--others", "--exclude-standard"]);
|
|
170
|
+
return [...new Set([...changed, ...added])];
|
|
171
|
+
};
|
|
172
|
+
|
|
143
173
|
const stat = (cwd, range) => {
|
|
144
174
|
const out = git(cwd, ["diff", "--numstat", range]).out;
|
|
145
175
|
const files = out
|
|
@@ -165,7 +195,8 @@ export function createWorktrees({ store, root }) {
|
|
|
165
195
|
if (runId) {
|
|
166
196
|
const sha = store.meta(`turn:${runId}`);
|
|
167
197
|
if (!sha) return { ok: true, files: [], patch: "" };
|
|
168
|
-
|
|
198
|
+
const from = store.meta(`turn-from:${runId}`);
|
|
199
|
+
range = from ? `${from}..${sha}` : `${sha}~1..${sha}`;
|
|
169
200
|
} else
|
|
170
201
|
range = `${tree.base}..${tree.state === "open" ? "HEAD" : tree.branch}`;
|
|
171
202
|
const patch = git(cwd, ["diff", range]).out;
|
|
@@ -230,12 +261,15 @@ export function createWorktrees({ store, root }) {
|
|
|
230
261
|
: `git would not merge into ${into}: ${merged.err.split("\n")[0]}; nothing was merged`,
|
|
231
262
|
};
|
|
232
263
|
}
|
|
264
|
+
// The branch goes once it is merged; its last commit stays, so what it brought in can still be shown.
|
|
265
|
+
const tip = git(tree.repo, ["rev-parse", tree.branch]).out || null;
|
|
233
266
|
retire(tree);
|
|
234
267
|
git(tree.repo, ["branch", "-d", tree.branch]);
|
|
235
268
|
save(threadId, {
|
|
236
269
|
...tree,
|
|
237
270
|
state: "merged",
|
|
238
271
|
into,
|
|
272
|
+
tip,
|
|
239
273
|
mergedAt: new Date().toISOString(),
|
|
240
274
|
});
|
|
241
275
|
return { ok: true, into };
|
|
@@ -327,8 +361,12 @@ export function createWorktrees({ store, root }) {
|
|
|
327
361
|
};
|
|
328
362
|
|
|
329
363
|
return {
|
|
364
|
+
/** The thread's copy as kept: where it is, its branch, what it started from, and open, merged, t3 or in place. */
|
|
365
|
+
record: get,
|
|
330
366
|
folderFor,
|
|
367
|
+
startTurn,
|
|
331
368
|
commitTurn,
|
|
369
|
+
uncommitted,
|
|
332
370
|
head,
|
|
333
371
|
diff,
|
|
334
372
|
summary,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tryharness",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.54",
|
|
4
4
|
"description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tryharness": "cli.mjs"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "node --test test/*.test.mjs"
|
|
9
|
+
"test": "node --test --test-concurrency=1 test/*.test.mjs"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"engines": {
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"zod": "^4.4.3"
|
|
47
47
|
},
|
|
48
48
|
"optionalDependencies": {
|
|
49
|
-
"tryharness-desktop-darwin-arm64": "0.7.
|
|
50
|
-
"tryharness-desktop-darwin-x64": "0.7.
|
|
49
|
+
"tryharness-desktop-darwin-arm64": "0.7.54",
|
|
50
|
+
"tryharness-desktop-darwin-x64": "0.7.54",
|
|
51
51
|
"tryharness-desktop-linux-x64": "0.7.4",
|
|
52
52
|
"tryharness-desktop-win32-x64": "0.7.4"
|
|
53
53
|
}
|