tring-chat 0.1.21 → 0.1.22
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
CHANGED
|
@@ -547,7 +547,9 @@ button of its own in the bar under the tabs, with the count of cards waiting.
|
|
|
547
547
|
### Orchestrator agent
|
|
548
548
|
|
|
549
549
|
Optional, off by default. Tick **Agent** in the Orchestrator's header and the centre
|
|
550
|
-
becomes a Claude Code session of its own, with the cards in a column beside it.
|
|
550
|
+
becomes a Claude Code session of its own, with the cards in a column beside it. Drag
|
|
551
|
+
the bar between them to make the column wider or narrower; the width is remembered. A
|
|
552
|
+
long reply or plan on a card folds behind **Show all**. Instead of
|
|
551
553
|
typing into each tile, you tell it what you want:
|
|
552
554
|
|
|
553
555
|
> *Which tiles are on which branch? Ask the api tile to run its tests, and start a new
|
|
@@ -572,7 +574,9 @@ green"* — and it goes to the tile that has been working on the reporting box,
|
|
|
572
574
|
already has the context. tring reads each tile's own Claude Code transcript (the path
|
|
573
575
|
every hook reports) for Claude's title for the conversation, the prompts it was given and
|
|
574
576
|
the files it edited, so a tile is found by what it has been doing even after its work is
|
|
575
|
-
committed and its screen has moved on.
|
|
577
|
+
committed and its screen has moved on. The repositories an agent has edited and read in
|
|
578
|
+
count too, so a Claude started in your home directory that has spent the day in one
|
|
579
|
+
repository is found as working in that repository. When two tiles match about equally, or none
|
|
576
580
|
clearly does, the agent asks you which rather than guessing.
|
|
577
581
|
|
|
578
582
|
**Worktrees.** The agent works one branch, one worktree, one agent. A tile is placed
|
package/dist/tring.js
CHANGED
|
@@ -1236,7 +1236,7 @@ var ProjectManager = class _ProjectManager {
|
|
|
1236
1236
|
|
|
1237
1237
|
// src/http.ts
|
|
1238
1238
|
import { createReadStream } from "node:fs";
|
|
1239
|
-
import { readdir as readdir4, realpath, stat as
|
|
1239
|
+
import { readdir as readdir4, realpath, stat as stat6 } from "node:fs/promises";
|
|
1240
1240
|
import os5 from "node:os";
|
|
1241
1241
|
import path12 from "node:path";
|
|
1242
1242
|
|
|
@@ -1982,11 +1982,12 @@ async function uninstallHooks(file = defaultClaudeSettingsPath()) {
|
|
|
1982
1982
|
}
|
|
1983
1983
|
|
|
1984
1984
|
// src/orchestrator-tools.ts
|
|
1985
|
-
import { stat as
|
|
1985
|
+
import { stat as stat5 } from "node:fs/promises";
|
|
1986
1986
|
import path11 from "node:path";
|
|
1987
1987
|
|
|
1988
1988
|
// src/git-worktrees.ts
|
|
1989
1989
|
import { execFile as execFile2 } from "node:child_process";
|
|
1990
|
+
import { stat as stat3 } from "node:fs/promises";
|
|
1990
1991
|
import path9 from "node:path";
|
|
1991
1992
|
import { promisify as promisify2 } from "node:util";
|
|
1992
1993
|
var run2 = promisify2(execFile2);
|
|
@@ -2047,7 +2048,32 @@ function defaultWorktreePath(commonDir, existing, branch) {
|
|
|
2047
2048
|
const repoDir = path9.basename(commonDir) === ".git" ? path9.dirname(commonDir) : commonDir;
|
|
2048
2049
|
return path9.join(path9.dirname(repoDir), `${repoName(commonDir)}.worktrees`, slug);
|
|
2049
2050
|
}
|
|
2051
|
+
var roots = /* @__PURE__ */ new Map();
|
|
2052
|
+
function worktreeRootOf(p) {
|
|
2053
|
+
const start = path9.resolve(p);
|
|
2054
|
+
const k = normal(start);
|
|
2055
|
+
let hit = roots.get(k);
|
|
2056
|
+
if (!hit) {
|
|
2057
|
+
hit = (async () => {
|
|
2058
|
+
let dir = start;
|
|
2059
|
+
for (let i = 0; i < 64; i++) {
|
|
2060
|
+
try {
|
|
2061
|
+
await stat3(path9.join(dir, ".git"));
|
|
2062
|
+
return dir;
|
|
2063
|
+
} catch {
|
|
2064
|
+
}
|
|
2065
|
+
const up = path9.dirname(dir);
|
|
2066
|
+
if (up === dir) return null;
|
|
2067
|
+
dir = up;
|
|
2068
|
+
}
|
|
2069
|
+
return null;
|
|
2070
|
+
})();
|
|
2071
|
+
roots.set(k, hit);
|
|
2072
|
+
}
|
|
2073
|
+
return hit;
|
|
2074
|
+
}
|
|
2050
2075
|
var realGit = {
|
|
2076
|
+
rootOf: worktreeRootOf,
|
|
2051
2077
|
async place(dir) {
|
|
2052
2078
|
const out = await git2(dir, ["rev-parse", "--path-format=absolute", "--show-toplevel", "--git-dir", "--git-common-dir"]);
|
|
2053
2079
|
const [root, gitDir, commonDir] = out?.trim().split(/\r?\n/) ?? [];
|
|
@@ -2090,9 +2116,17 @@ function typePrompt(target, text2) {
|
|
|
2090
2116
|
}
|
|
2091
2117
|
|
|
2092
2118
|
// src/transcript.ts
|
|
2093
|
-
import { open, readdir as readdir3, stat as
|
|
2119
|
+
import { open, readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
2094
2120
|
import path10 from "node:path";
|
|
2121
|
+
var SYSTEM_TAG = /^<(command-|local-command-|task-notification|system-reminder|user-prompt-submit-hook)/;
|
|
2095
2122
|
var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "MultiEdit", "Write", "NotebookEdit"]);
|
|
2123
|
+
var READ_TOOLS = /* @__PURE__ */ new Set(["Read", "Grep", "Glob", "LS", "NotebookRead"]);
|
|
2124
|
+
var SHELL_TOOLS = /* @__PURE__ */ new Set(["Bash", "PowerShell"]);
|
|
2125
|
+
var MAX_PER_TURN = 40;
|
|
2126
|
+
var MAX_COMMAND = 300;
|
|
2127
|
+
var addCapped = (list, v) => {
|
|
2128
|
+
if (list.length < MAX_PER_TURN && !list.includes(v)) list.push(v);
|
|
2129
|
+
};
|
|
2096
2130
|
var WHOLE_BYTES = 8 << 20;
|
|
2097
2131
|
var HEAD_BYTES = 512 << 10;
|
|
2098
2132
|
var TAIL_BYTES = 8 << 20;
|
|
@@ -2109,7 +2143,7 @@ function humanPrompt(j) {
|
|
|
2109
2143
|
text2 = blocks.filter((b) => b.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n") || null;
|
|
2110
2144
|
}
|
|
2111
2145
|
text2 = text2?.trim() ?? null;
|
|
2112
|
-
if (!text2 ||
|
|
2146
|
+
if (!text2 || SYSTEM_TAG.test(text2)) return null;
|
|
2113
2147
|
return text2;
|
|
2114
2148
|
}
|
|
2115
2149
|
function parseTranscript(lines) {
|
|
@@ -2138,21 +2172,32 @@ function parseTranscript(lines) {
|
|
|
2138
2172
|
if (!Array.isArray(blocks)) continue;
|
|
2139
2173
|
const texts = [];
|
|
2140
2174
|
const files = [];
|
|
2175
|
+
const paths = [];
|
|
2176
|
+
const commands = [];
|
|
2141
2177
|
for (const b of blocks) {
|
|
2142
2178
|
if (b.type === "text" && b.text?.trim()) texts.push(b.text.trim());
|
|
2143
|
-
if (b.type
|
|
2144
|
-
|
|
2179
|
+
if (b.type !== "tool_use" || !b.name) continue;
|
|
2180
|
+
const input = b.input ?? {};
|
|
2181
|
+
if (EDIT_TOOLS.has(b.name)) {
|
|
2182
|
+
const f = input["file_path"] ?? input["notebook_path"];
|
|
2145
2183
|
if (typeof f === "string") files.push(f);
|
|
2184
|
+
} else if (READ_TOOLS.has(b.name)) {
|
|
2185
|
+
const p = input["file_path"] ?? input["path"] ?? input["notebook_path"];
|
|
2186
|
+
if (typeof p === "string" && p) addCapped(paths, p);
|
|
2187
|
+
} else if (SHELL_TOOLS.has(b.name) && typeof input["command"] === "string") {
|
|
2188
|
+
addCapped(commands, input["command"].slice(0, MAX_COMMAND));
|
|
2146
2189
|
}
|
|
2147
2190
|
}
|
|
2148
|
-
if (!texts.length && !files.length) continue;
|
|
2149
|
-
|
|
2150
|
-
if (last?.role
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
} else {
|
|
2154
|
-
turns.push({ role: "assistant", text: texts.join("\n\n"), at, ...files.length ? { files: [...new Set(files)] } : {} });
|
|
2191
|
+
if (!texts.length && !files.length && !paths.length && !commands.length) continue;
|
|
2192
|
+
let last = turns[turns.length - 1];
|
|
2193
|
+
if (last?.role !== "assistant") {
|
|
2194
|
+
last = { role: "assistant", text: "", at };
|
|
2195
|
+
turns.push(last);
|
|
2155
2196
|
}
|
|
2197
|
+
if (texts.length) last.text = [last.text, ...texts].filter(Boolean).join("\n\n");
|
|
2198
|
+
if (files.length) last.files = [.../* @__PURE__ */ new Set([...last.files ?? [], ...files])];
|
|
2199
|
+
for (const p of paths) addCapped(last.paths ??= [], p);
|
|
2200
|
+
for (const c of commands) addCapped(last.commands ??= [], c);
|
|
2156
2201
|
}
|
|
2157
2202
|
return { title, turns };
|
|
2158
2203
|
}
|
|
@@ -2171,7 +2216,7 @@ var CACHE_LIMIT = 48;
|
|
|
2171
2216
|
async function readTranscript(file) {
|
|
2172
2217
|
let info;
|
|
2173
2218
|
try {
|
|
2174
|
-
info = await
|
|
2219
|
+
info = await stat4(file);
|
|
2175
2220
|
} catch {
|
|
2176
2221
|
return null;
|
|
2177
2222
|
}
|
|
@@ -2209,7 +2254,7 @@ async function findTranscript(projectsDir, id) {
|
|
|
2209
2254
|
for (const d of dirs) {
|
|
2210
2255
|
const f = path10.join(projectsDir, d, `${id}.jsonl`);
|
|
2211
2256
|
try {
|
|
2212
|
-
if ((await
|
|
2257
|
+
if ((await stat4(f)).isFile()) return f;
|
|
2213
2258
|
} catch {
|
|
2214
2259
|
}
|
|
2215
2260
|
}
|
|
@@ -2344,7 +2389,7 @@ var PROMPT_GRACE_MS = 15e3;
|
|
|
2344
2389
|
var clip = (s, n) => s.length > n ? `${s.slice(0, n)}\u2026 (${s.length - n} more characters)` : s;
|
|
2345
2390
|
async function isDirectory(p) {
|
|
2346
2391
|
try {
|
|
2347
|
-
return (await
|
|
2392
|
+
return (await stat5(p)).isDirectory();
|
|
2348
2393
|
} catch {
|
|
2349
2394
|
return false;
|
|
2350
2395
|
}
|
|
@@ -2441,6 +2486,7 @@ var OrchestratorTools = class {
|
|
|
2441
2486
|
const placed = await this.placeAll();
|
|
2442
2487
|
const byId = new Map(placed.map((p) => [p.s.id, p]));
|
|
2443
2488
|
const talks = new Map(await Promise.all(placed.map(async (p) => [p.s.id, await this.history(p.s)])));
|
|
2489
|
+
const worked = new Map(await Promise.all(placed.map(async (p) => [p.s.id, await this.workedIn(talks.get(p.s.id) ?? null)])));
|
|
2444
2490
|
const out = projects.map((p) => ({
|
|
2445
2491
|
project: p.name,
|
|
2446
2492
|
id: p.id,
|
|
@@ -2464,6 +2510,7 @@ var OrchestratorTools = class {
|
|
|
2464
2510
|
...shared.length ? { sameWorktreeAs: shared } : {},
|
|
2465
2511
|
agent: s?.claude ? "claude" : null,
|
|
2466
2512
|
...conversationSummary(talks.get(info.id) ?? null),
|
|
2513
|
+
...workedSummary(worked.get(info.id) ?? []),
|
|
2467
2514
|
...waiting.length ? { waitingOnUser: waiting.map(summary) } : {},
|
|
2468
2515
|
...s?.lastMessage ? { lastMessage: clip(s.lastMessage, MAX_LAST_MESSAGE) } : {}
|
|
2469
2516
|
};
|
|
@@ -2487,8 +2534,8 @@ var OrchestratorTools = class {
|
|
|
2487
2534
|
if (project) r.projects.add(project);
|
|
2488
2535
|
repos.set(k, r);
|
|
2489
2536
|
};
|
|
2490
|
-
const
|
|
2491
|
-
for (const { p, place } of
|
|
2537
|
+
const roots2 = await Promise.all(projects.map(async (p) => ({ p, place: await this.git.place(p.root) })));
|
|
2538
|
+
for (const { p, place } of roots2) add2(place, p.root, p.name);
|
|
2492
2539
|
const wanted = new Set(projects.map((p) => p.id));
|
|
2493
2540
|
for (const pl of placed) if (wanted.has(pl.s.projectId)) add2(pl.place, workdir(pl.s));
|
|
2494
2541
|
if (repos.size === 0) return "No git repositories: none of these projects or tiles is inside one.";
|
|
@@ -2514,6 +2561,33 @@ var OrchestratorTools = class {
|
|
|
2514
2561
|
}));
|
|
2515
2562
|
return JSON.stringify({ repos: out }, null, 2);
|
|
2516
2563
|
}
|
|
2564
|
+
/**
|
|
2565
|
+
* The worktrees an agent has really been working in, by the files it edited
|
|
2566
|
+
* and read and the paths in the commands it ran — not where its shell sits.
|
|
2567
|
+
* A Claude started in the home directory that spends the day editing one
|
|
2568
|
+
* repository is working in that repository.
|
|
2569
|
+
*/
|
|
2570
|
+
async workedIn(talk) {
|
|
2571
|
+
if (!talk) return [];
|
|
2572
|
+
const tally = /* @__PURE__ */ new Map();
|
|
2573
|
+
const count = async (p, kind) => {
|
|
2574
|
+
if (!path11.isAbsolute(p)) return;
|
|
2575
|
+
const root = await this.git.rootOf(p);
|
|
2576
|
+
if (!root) return;
|
|
2577
|
+
const k = normal(root);
|
|
2578
|
+
const t = tally.get(k) ?? { root, edits: 0, reads: 0 };
|
|
2579
|
+
t[kind]++;
|
|
2580
|
+
tally.set(k, t);
|
|
2581
|
+
};
|
|
2582
|
+
const jobs = [];
|
|
2583
|
+
for (const t of talk.turns) {
|
|
2584
|
+
for (const f of t.files ?? []) jobs.push(count(f, "edits"));
|
|
2585
|
+
for (const p of t.paths ?? []) jobs.push(count(p, "reads"));
|
|
2586
|
+
for (const c of t.commands ?? []) for (const p of pathsIn(c)) jobs.push(count(p, "reads"));
|
|
2587
|
+
}
|
|
2588
|
+
await Promise.all(jobs);
|
|
2589
|
+
return [...tally.values()].sort((a, b) => b.edits * 3 + b.reads - (a.edits * 3 + a.reads)).slice(0, 5);
|
|
2590
|
+
}
|
|
2517
2591
|
/** The tile's conversation, from the transcript its hooks named, or found by id. */
|
|
2518
2592
|
async history(s) {
|
|
2519
2593
|
const t = this.d.transcripts ?? {
|
|
@@ -2560,10 +2634,12 @@ ${body.join("\n\n")}`;
|
|
|
2560
2634
|
const placed = await this.placeAll();
|
|
2561
2635
|
const docs = await Promise.all(placed.map(async (p) => {
|
|
2562
2636
|
const talk = await this.history(p.s);
|
|
2637
|
+
const worked = await this.workedIn(talk);
|
|
2563
2638
|
const fields = [
|
|
2564
2639
|
{ why: "name", text: [p.s.name, p.s.title].filter(Boolean).join(" "), weight: 4 },
|
|
2565
2640
|
{ why: "branch", text: [p.place?.branch, p.place?.root].filter(Boolean).join(" "), weight: 4 },
|
|
2566
2641
|
{ why: "title", text: talk?.title ?? "", weight: 4 },
|
|
2642
|
+
{ why: "worked in", text: worked.map((w) => w.root).join(" "), weight: 4 },
|
|
2567
2643
|
{ why: "last message", text: p.s.lastMessage ?? "", weight: 1 }
|
|
2568
2644
|
];
|
|
2569
2645
|
const turns = talk?.turns ?? [];
|
|
@@ -2572,15 +2648,19 @@ ${body.join("\n\n")}`;
|
|
|
2572
2648
|
if (t.role === "user") fields.push({ why: "prompt", text: t.text, weight: 3 * recent });
|
|
2573
2649
|
else fields.push({ why: "agent said", text: t.text, weight: recent });
|
|
2574
2650
|
if (t.files?.length) fields.push({ why: "edited", text: t.files.join(" "), weight: 3 * recent });
|
|
2651
|
+
if (t.paths?.length) fields.push({ why: "read", text: t.paths.join(" "), weight: recent });
|
|
2652
|
+
if (t.commands?.length) fields.push({ why: "ran", text: t.commands.join(" "), weight: recent });
|
|
2575
2653
|
});
|
|
2576
2654
|
return { p, fields };
|
|
2577
2655
|
}));
|
|
2578
2656
|
const df = new Map(ws.map((w) => [w, docs.filter((d) => d.fields.some((f) => f.text.toLowerCase().includes(w))).length]));
|
|
2657
|
+
const known = ws.filter((w) => df.get(w) > 0);
|
|
2579
2658
|
const ranked = docs.map(({ p, fields }) => {
|
|
2580
2659
|
let score = 0;
|
|
2581
2660
|
const why = /* @__PURE__ */ new Set();
|
|
2582
2661
|
let best = null;
|
|
2583
|
-
let
|
|
2662
|
+
let whole = false;
|
|
2663
|
+
const strong = /* @__PURE__ */ new Set();
|
|
2584
2664
|
for (const f of fields) {
|
|
2585
2665
|
const low = f.text.toLowerCase();
|
|
2586
2666
|
const hit = ws.filter((w) => low.includes(w));
|
|
@@ -2589,8 +2669,10 @@ ${body.join("\n\n")}`;
|
|
|
2589
2669
|
score += s;
|
|
2590
2670
|
why.add(f.why);
|
|
2591
2671
|
if (!best || s > best.score) best = { score: s, text: snippet(f.text, hit[0]) };
|
|
2592
|
-
if (hit.length === ws.length
|
|
2672
|
+
if (hit.length === ws.length) whole = true;
|
|
2673
|
+
if (STRONG.has(f.why)) for (const w of hit) strong.add(w);
|
|
2593
2674
|
}
|
|
2675
|
+
const confident = whole || strong.size >= Math.max(1, known.length / 2) || [...strong].some((w) => df.get(w) === 1);
|
|
2594
2676
|
return { p, score, confident, why: [...why], snippet: best?.text ?? "" };
|
|
2595
2677
|
}).filter((r) => r.score > 0).sort((a, b) => b.score - a.score);
|
|
2596
2678
|
const top = ranked.slice(0, 5);
|
|
@@ -2796,7 +2878,23 @@ function conversationSummary(t) {
|
|
|
2796
2878
|
}
|
|
2797
2879
|
};
|
|
2798
2880
|
}
|
|
2799
|
-
var STRONG = /* @__PURE__ */ new Set(["name", "branch", "title", "prompt", "edited"]);
|
|
2881
|
+
var STRONG = /* @__PURE__ */ new Set(["name", "branch", "title", "worked in", "prompt", "edited"]);
|
|
2882
|
+
function workedSummary(w) {
|
|
2883
|
+
if (!w.length) return {};
|
|
2884
|
+
return { workedIn: w.map((x) => `${x.root} (${x.edits} edits, ${x.reads} reads)`) };
|
|
2885
|
+
}
|
|
2886
|
+
function pathsIn(command) {
|
|
2887
|
+
const out = /* @__PURE__ */ new Set();
|
|
2888
|
+
const abs = /^(?:[A-Za-z]:[\\/]|\/(?!\/))/;
|
|
2889
|
+
for (const m of command.matchAll(/"([^"\n]+)"|'([^'\n]+)'/g)) {
|
|
2890
|
+
const p = (m[1] ?? m[2] ?? "").trim();
|
|
2891
|
+
if (abs.test(p)) out.add(p);
|
|
2892
|
+
}
|
|
2893
|
+
for (const m of command.replace(/"[^"\n]*"|'[^'\n]*'/g, " ").matchAll(/(?:^|[\s=(])((?:[A-Za-z]:[\\/]|\/)[^\s"'`;|&<>()]+)/g)) {
|
|
2894
|
+
if (abs.test(m[1]) && m[1] !== "/") out.add(m[1]);
|
|
2895
|
+
}
|
|
2896
|
+
return [...out].slice(0, 10);
|
|
2897
|
+
}
|
|
2800
2898
|
var STOP = /* @__PURE__ */ new Set([
|
|
2801
2899
|
"the",
|
|
2802
2900
|
"and",
|
|
@@ -2853,7 +2951,56 @@ var STOP = /* @__PURE__ */ new Set([
|
|
|
2853
2951
|
"work",
|
|
2854
2952
|
"working",
|
|
2855
2953
|
"thing",
|
|
2856
|
-
"there"
|
|
2954
|
+
"there",
|
|
2955
|
+
"since",
|
|
2956
|
+
"because",
|
|
2957
|
+
"when",
|
|
2958
|
+
"where",
|
|
2959
|
+
"what",
|
|
2960
|
+
"which",
|
|
2961
|
+
"while",
|
|
2962
|
+
"about",
|
|
2963
|
+
"after",
|
|
2964
|
+
"before",
|
|
2965
|
+
"still",
|
|
2966
|
+
"very",
|
|
2967
|
+
"really",
|
|
2968
|
+
"only",
|
|
2969
|
+
"even",
|
|
2970
|
+
"more",
|
|
2971
|
+
"most",
|
|
2972
|
+
"much",
|
|
2973
|
+
"many",
|
|
2974
|
+
"other",
|
|
2975
|
+
"over",
|
|
2976
|
+
"under",
|
|
2977
|
+
"again",
|
|
2978
|
+
"seems",
|
|
2979
|
+
"look",
|
|
2980
|
+
"looks",
|
|
2981
|
+
"see",
|
|
2982
|
+
"show",
|
|
2983
|
+
"shows",
|
|
2984
|
+
"does",
|
|
2985
|
+
"doesn",
|
|
2986
|
+
"don",
|
|
2987
|
+
"did",
|
|
2988
|
+
"will",
|
|
2989
|
+
"won",
|
|
2990
|
+
"cannot",
|
|
2991
|
+
"edit",
|
|
2992
|
+
"sure",
|
|
2993
|
+
"should",
|
|
2994
|
+
"here",
|
|
2995
|
+
"they",
|
|
2996
|
+
"them",
|
|
2997
|
+
"their",
|
|
2998
|
+
"what",
|
|
2999
|
+
"who",
|
|
3000
|
+
"how",
|
|
3001
|
+
"why",
|
|
3002
|
+
"yes",
|
|
3003
|
+
"okay"
|
|
2857
3004
|
]);
|
|
2858
3005
|
function words(query) {
|
|
2859
3006
|
const out = query.toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length >= 3 && !STOP.has(w)).map((w) => w.length > 5 ? w.replace(/(ing|ed|es|s)$/, "") : w);
|
|
@@ -2971,8 +3118,8 @@ function createHandler(opts) {
|
|
|
2971
3118
|
}
|
|
2972
3119
|
};
|
|
2973
3120
|
const browsable = async (dir) => {
|
|
2974
|
-
const
|
|
2975
|
-
const [target, ...resolved] = await Promise.all([dir, ...
|
|
3121
|
+
const roots2 = [homeDir(), ...pm.list().map((p) => p.root), ...opts.fsRoots ?? []];
|
|
3122
|
+
const [target, ...resolved] = await Promise.all([dir, ...roots2].map(real));
|
|
2976
3123
|
return resolved.some((root) => within(root, target));
|
|
2977
3124
|
};
|
|
2978
3125
|
return async function handle(req, res) {
|
|
@@ -3159,7 +3306,7 @@ function createHandler(opts) {
|
|
|
3159
3306
|
return;
|
|
3160
3307
|
}
|
|
3161
3308
|
try {
|
|
3162
|
-
const info = await
|
|
3309
|
+
const info = await stat6(file);
|
|
3163
3310
|
if (!info.isFile()) throw new Error("not a file");
|
|
3164
3311
|
head(res, 200, MIME[path12.extname(file)] ?? "application/octet-stream");
|
|
3165
3312
|
createReadStream(file).pipe(res);
|
|
@@ -3263,7 +3410,7 @@ var Hub = class {
|
|
|
3263
3410
|
case "activateProject": {
|
|
3264
3411
|
pm.activate(msg.projectId);
|
|
3265
3412
|
c.projectId = msg.projectId;
|
|
3266
|
-
c.focusedId =
|
|
3413
|
+
c.focusedId = this.keepFocus(c);
|
|
3267
3414
|
this.sendState(c);
|
|
3268
3415
|
this.sendSnapshots(c);
|
|
3269
3416
|
break;
|
|
@@ -3280,7 +3427,7 @@ var Hub = class {
|
|
|
3280
3427
|
pm.deleteProject(msg.projectId);
|
|
3281
3428
|
if (c.projectId === msg.projectId) {
|
|
3282
3429
|
c.projectId = pm.activeProjectId;
|
|
3283
|
-
c.focusedId =
|
|
3430
|
+
c.focusedId = this.keepFocus(c);
|
|
3284
3431
|
}
|
|
3285
3432
|
break;
|
|
3286
3433
|
case "create":
|
|
@@ -3417,6 +3564,13 @@ var Hub = class {
|
|
|
3417
3564
|
broadcastAuto() {
|
|
3418
3565
|
if (this.opts.auto) this.broadcast(this.autoMessage(this.opts.auto));
|
|
3419
3566
|
}
|
|
3567
|
+
/**
|
|
3568
|
+
* What a socket stays focused on when its project changes: the orchestrator
|
|
3569
|
+
* agent, which is in no project, and nothing else.
|
|
3570
|
+
*/
|
|
3571
|
+
keepFocus(c) {
|
|
3572
|
+
return c.focusedId && this.opts.agent?.find(c.focusedId) ? c.focusedId : null;
|
|
3573
|
+
}
|
|
3420
3574
|
/** A tile, or the orchestrator agent's own terminal. */
|
|
3421
3575
|
find(id) {
|
|
3422
3576
|
return this.opts.pm.findSession(id) ?? this.opts.agent?.find(id);
|
|
@@ -3461,11 +3615,11 @@ function isWsl() {
|
|
|
3461
3615
|
}
|
|
3462
3616
|
function wslCandidates() {
|
|
3463
3617
|
const user = process.env["WSL_USER"] ?? "";
|
|
3464
|
-
const
|
|
3618
|
+
const roots2 = ["/mnt/c/Program Files", "/mnt/c/Program Files (x86)"];
|
|
3465
3619
|
const paths = [
|
|
3466
|
-
...
|
|
3467
|
-
...
|
|
3468
|
-
...
|
|
3620
|
+
...roots2.map((r) => `${r}/Google/Chrome/Application/chrome.exe`),
|
|
3621
|
+
...roots2.map((r) => `${r}/Microsoft/Edge/Application/msedge.exe`),
|
|
3622
|
+
...roots2.map((r) => `${r}/BraveSoftware/Brave-Browser/Application/brave.exe`)
|
|
3469
3623
|
];
|
|
3470
3624
|
if (user) paths.push(`/mnt/c/Users/${user}/AppData/Local/Google/Chrome/Application/chrome.exe`);
|
|
3471
3625
|
return paths;
|
|
@@ -4139,9 +4293,10 @@ you get the work done through the agents in those tiles.
|
|
|
4139
4293
|
|
|
4140
4294
|
- \`list_sessions\` \u2014 every project and tile: status (busy = working, done =
|
|
4141
4295
|
finished and waiting, idle, exited), the directory its agent works in, its
|
|
4142
|
-
repository, worktree and branch,
|
|
4143
|
-
|
|
4144
|
-
|
|
4296
|
+
repository, worktree and branch, the repositories its agent has edited in
|
|
4297
|
+
(\`workedIn\`), whether it runs Claude Code, what it is waiting on, and what
|
|
4298
|
+
its agent last said. \`sameWorktreeAs\` marks tiles sharing a worktree.
|
|
4299
|
+
Start here whenever you need to know what is going on.
|
|
4145
4300
|
- \`list_worktrees\` \u2014 every worktree of each repository, its branch, and
|
|
4146
4301
|
which tiles are in it. Free worktrees are the ones with no tiles.
|
|
4147
4302
|
- \`find_work\` \u2014 which tiles have been working on a topic, ranked: by name,
|
|
@@ -4190,6 +4345,16 @@ to the agent that has been working on that, which already has the context.
|
|
|
4190
4345
|
4. A clear match that is busy, waiting on the user, or exited: say so, and ask
|
|
4191
4346
|
whether to queue it there or start a new tile.
|
|
4192
4347
|
|
|
4348
|
+
A tile's directory is where its shell started, not what it works on. A Claude
|
|
4349
|
+
started in the home directory may spend all day editing one repository:
|
|
4350
|
+
\`workedIn\` in \`list_sessions\` lists the repositories its agent has really
|
|
4351
|
+
edited and read in. When the user names an app or repository ("edit tring"),
|
|
4352
|
+
look there and in \`find_work\`, not only at directories and branches.
|
|
4353
|
+
|
|
4354
|
+
Never search the disk for a repository (no recursive listings of drives or
|
|
4355
|
+
home folders): it is slow and the user has to stop it. If the tools do not
|
|
4356
|
+
show it, ask the user for the path.
|
|
4357
|
+
|
|
4193
4358
|
## Git worktrees
|
|
4194
4359
|
|
|
4195
4360
|
The user works in git worktrees: one branch, one worktree, one agent. Treat
|