agent-yes 1.113.0 → 1.114.0
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/{SUPPORTED_CLIS-BpO7ZYx_.js → SUPPORTED_CLIS--15XPtGd.js} +2 -2
- package/dist/SUPPORTED_CLIS-DE31jVYi.js +8 -0
- package/dist/cli.js +3 -3
- package/dist/index.js +2 -2
- package/dist/{serve-YPd9gtRO.js → serve-DEDkRdog.js} +59 -14
- package/dist/{subcommands-DU5RXU0g.js → subcommands-8hMGFqkQ.js} +1 -1
- package/dist/{subcommands-Za5uwCq6.js → subcommands-Di_pcW0_.js} +2 -2
- package/dist/{ts-ChVJOKNr.js → ts-CZQs_t8w.js} +2 -2
- package/dist/{versionChecker-wxlWV_VT.js → versionChecker-C1W2s4ZP.js} +2 -2
- package/lab/ui/console-logic.js +24 -1
- package/lab/ui/index.html +24 -0
- package/package.json +1 -1
- package/ts/serve.ts +58 -7
- package/dist/SUPPORTED_CLIS-DtJakX4G.js +0 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { t as CLIS_CONFIG } from "./ts-CZQs_t8w.js";
|
|
2
2
|
|
|
3
3
|
//#region ts/SUPPORTED_CLIS.ts
|
|
4
4
|
const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { SUPPORTED_CLIS as t };
|
|
8
|
-
//# sourceMappingURL=SUPPORTED_CLIS
|
|
8
|
+
//# sourceMappingURL=SUPPORTED_CLIS--15XPtGd.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./ts-CZQs_t8w.js";
|
|
2
|
+
import "./logger-B9h0djqx.js";
|
|
3
|
+
import "./versionChecker-C1W2s4ZP.js";
|
|
4
|
+
import "./pidStore-DBjlqzo8.js";
|
|
5
|
+
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS--15XPtGd.js";
|
|
7
|
+
|
|
8
|
+
export { SUPPORTED_CLIS };
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { n as logger } from "./logger-B9h0djqx.js";
|
|
3
|
-
import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-
|
|
3
|
+
import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-C1W2s4ZP.js";
|
|
4
4
|
import { argv } from "process";
|
|
5
5
|
import { execFileSync, spawn } from "child_process";
|
|
6
6
|
import ms from "ms";
|
|
@@ -482,7 +482,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
|
|
|
482
482
|
{
|
|
483
483
|
const rawArg = process.argv[2];
|
|
484
484
|
const isHelpFlag = rawArg === "-h" || rawArg === "--help";
|
|
485
|
-
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-
|
|
485
|
+
const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-8hMGFqkQ.js");
|
|
486
486
|
if (isHelpFlag && process.argv.length === 3) {
|
|
487
487
|
cmdHelp();
|
|
488
488
|
process.exit(0);
|
|
@@ -515,7 +515,7 @@ if (config.useRust) {
|
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
if (rustBinary) {
|
|
518
|
-
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-
|
|
518
|
+
const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-DE31jVYi.js");
|
|
519
519
|
const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
|
|
520
520
|
if (config.verbose) {
|
|
521
521
|
console.log(`[rust] Using binary: ${rustBinary}`);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-
|
|
1
|
+
import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-CZQs_t8w.js";
|
|
2
2
|
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-
|
|
3
|
+
import "./versionChecker-C1W2s4ZP.js";
|
|
4
4
|
import "./pidStore-DBjlqzo8.js";
|
|
5
5
|
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
6
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./ts-
|
|
1
|
+
import "./ts-CZQs_t8w.js";
|
|
2
2
|
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-
|
|
3
|
+
import "./versionChecker-C1W2s4ZP.js";
|
|
4
4
|
import "./pidStore-DBjlqzo8.js";
|
|
5
5
|
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS
|
|
6
|
+
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS--15XPtGd.js";
|
|
7
7
|
import "./remotes-C3xPRtfg.js";
|
|
8
|
-
import { c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, m as snapshotStatus, r as controlCodeFromName, u as readNotes } from "./subcommands-
|
|
8
|
+
import { c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, m as snapshotStatus, r as controlCodeFromName, u as readNotes } from "./subcommands-Di_pcW0_.js";
|
|
9
9
|
import yargs from "yargs";
|
|
10
10
|
import { mkdir, open, readFile, writeFile } from "fs/promises";
|
|
11
11
|
import { homedir, hostname, userInfo } from "os";
|
|
@@ -220,6 +220,58 @@ Options:
|
|
|
220
220
|
return null;
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
+
const GIT_TTL_MS = 5e3;
|
|
224
|
+
const gitCache = /* @__PURE__ */ new Map();
|
|
225
|
+
const gitStatus = async (cwd) => {
|
|
226
|
+
if (!cwd) return null;
|
|
227
|
+
const now = Date.now();
|
|
228
|
+
const hit = gitCache.get(cwd);
|
|
229
|
+
if (hit && now - hit.at < GIT_TTL_MS) return hit.val;
|
|
230
|
+
let val = null;
|
|
231
|
+
try {
|
|
232
|
+
const proc = Bun.spawn([
|
|
233
|
+
"git",
|
|
234
|
+
"status",
|
|
235
|
+
"--porcelain",
|
|
236
|
+
"--branch"
|
|
237
|
+
], {
|
|
238
|
+
cwd,
|
|
239
|
+
stdout: "pipe",
|
|
240
|
+
stderr: "ignore",
|
|
241
|
+
signal: AbortSignal.timeout(2e3)
|
|
242
|
+
});
|
|
243
|
+
const out = await new Response(proc.stdout).text();
|
|
244
|
+
await proc.exited;
|
|
245
|
+
if (proc.exitCode === 0) {
|
|
246
|
+
const lines = out.split("\n");
|
|
247
|
+
const h = /^## (.+)$/.exec(lines[0] ?? "")?.[1] ?? "";
|
|
248
|
+
const unborn = /^No commits yet on (.+)$/.exec(h);
|
|
249
|
+
const branch = unborn ? unborn[1] : /^(.+?)(?:\.\.\.|\s|$)/.exec(h)?.[1] || null;
|
|
250
|
+
const ahead = Number(/\bahead (\d+)/.exec(h)?.[1] ?? 0);
|
|
251
|
+
const behind = Number(/\bbehind (\d+)/.exec(h)?.[1] ?? 0);
|
|
252
|
+
const changed = lines.slice(1).filter((l) => l.trim().length > 0).length;
|
|
253
|
+
val = {
|
|
254
|
+
branch,
|
|
255
|
+
dirty: changed > 0,
|
|
256
|
+
changed,
|
|
257
|
+
ahead,
|
|
258
|
+
behind
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
} catch {
|
|
262
|
+
val = null;
|
|
263
|
+
}
|
|
264
|
+
gitCache.set(cwd, {
|
|
265
|
+
at: now,
|
|
266
|
+
val
|
|
267
|
+
});
|
|
268
|
+
return val;
|
|
269
|
+
};
|
|
270
|
+
const withMeta = async (r) => ({
|
|
271
|
+
...r,
|
|
272
|
+
title: await logTitle(r.log_file),
|
|
273
|
+
git: r.status === "exited" ? null : await gitStatus(r.cwd)
|
|
274
|
+
});
|
|
223
275
|
const apiFetch = async (req) => {
|
|
224
276
|
if (!checkAuth(req, token)) return new Response("Unauthorized", { status: 401 });
|
|
225
277
|
const url = new URL(req.url);
|
|
@@ -232,11 +284,7 @@ Options:
|
|
|
232
284
|
});
|
|
233
285
|
try {
|
|
234
286
|
const records = await listRecords(keyword, opts);
|
|
235
|
-
|
|
236
|
-
...r,
|
|
237
|
-
title: await logTitle(r.log_file)
|
|
238
|
-
})));
|
|
239
|
-
return Response.json(withTitles);
|
|
287
|
+
return Response.json(await Promise.all(records.map(withMeta)));
|
|
240
288
|
} catch (e) {
|
|
241
289
|
return new Response(e.message, { status: 500 });
|
|
242
290
|
}
|
|
@@ -258,10 +306,7 @@ Options:
|
|
|
258
306
|
const sent = /* @__PURE__ */ new Map();
|
|
259
307
|
const compute = async () => {
|
|
260
308
|
const records = await listRecords(keyword, opts);
|
|
261
|
-
return Promise.all(records.map(
|
|
262
|
-
...r,
|
|
263
|
-
title: await logTitle(r.log_file)
|
|
264
|
-
})));
|
|
309
|
+
return Promise.all(records.map(withMeta));
|
|
265
310
|
};
|
|
266
311
|
const tick = async (first) => {
|
|
267
312
|
if (closed) return;
|
|
@@ -633,4 +678,4 @@ Options:
|
|
|
633
678
|
|
|
634
679
|
//#endregion
|
|
635
680
|
export { cmdServe };
|
|
636
|
-
//# sourceMappingURL=serve-
|
|
681
|
+
//# sourceMappingURL=serve-DEDkRdog.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./logger-B9h0djqx.js";
|
|
2
2
|
import "./globalPidIndex-yVd3mbsV.js";
|
|
3
3
|
import "./remotes-C3xPRtfg.js";
|
|
4
|
-
import { a as finalizedLines, c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, h as stopTipForCli, i as cursorAbs, l as matchKeyword, m as snapshotStatus, n as cmdHelp, o as isPidAlive, p as runSubcommand, r as controlCodeFromName, s as isSubcommand, t as GRACEFUL_EXIT_COMMANDS, u as readNotes } from "./subcommands-
|
|
4
|
+
import { a as finalizedLines, c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, h as stopTipForCli, i as cursorAbs, l as matchKeyword, m as snapshotStatus, n as cmdHelp, o as isPidAlive, p as runSubcommand, r as controlCodeFromName, s as isSubcommand, t as GRACEFUL_EXIT_COMMANDS, u as readNotes } from "./subcommands-Di_pcW0_.js";
|
|
5
5
|
|
|
6
6
|
export { cmdHelp, isSubcommand, runSubcommand };
|
|
@@ -163,7 +163,7 @@ async function runSubcommand(argv) {
|
|
|
163
163
|
case "restart": return await cmdRestart(rest);
|
|
164
164
|
case "note": return await cmdNote(rest);
|
|
165
165
|
case "serve": {
|
|
166
|
-
const { cmdServe } = await import("./serve-
|
|
166
|
+
const { cmdServe } = await import("./serve-DEDkRdog.js");
|
|
167
167
|
return cmdServe(rest);
|
|
168
168
|
}
|
|
169
169
|
case "setup": {
|
|
@@ -1595,4 +1595,4 @@ async function cmdStatus(rest) {
|
|
|
1595
1595
|
|
|
1596
1596
|
//#endregion
|
|
1597
1597
|
export { finalizedLines as a, listRecords as c, renderRawLog as d, resolveOne as f, writeToIpc as g, stopTipForCli as h, cursorAbs as i, matchKeyword as l, snapshotStatus as m, cmdHelp as n, isPidAlive as o, runSubcommand as p, controlCodeFromName as r, isSubcommand as s, GRACEFUL_EXIT_COMMANDS as t, readNotes as u };
|
|
1598
|
-
//# sourceMappingURL=subcommands-
|
|
1598
|
+
//# sourceMappingURL=subcommands-Di_pcW0_.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as logger, t as addTransport } from "./logger-B9h0djqx.js";
|
|
2
|
-
import { r as getInstalledPackage } from "./versionChecker-
|
|
2
|
+
import { r as getInstalledPackage } from "./versionChecker-C1W2s4ZP.js";
|
|
3
3
|
import { n as agentYesHome, t as PidStore } from "./pidStore-DBjlqzo8.js";
|
|
4
4
|
import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-CJxsoGdb.js";
|
|
5
5
|
import { i as readGlobalPids } from "./globalPidIndex-yVd3mbsV.js";
|
|
@@ -1714,4 +1714,4 @@ function sleep(ms) {
|
|
|
1714
1714
|
|
|
1715
1715
|
//#endregion
|
|
1716
1716
|
export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
|
|
1717
|
-
//# sourceMappingURL=ts-
|
|
1717
|
+
//# sourceMappingURL=ts-CZQs_t8w.js.map
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name = "agent-yes";
|
|
10
|
-
var version = "1.
|
|
10
|
+
var version = "1.114.0";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region ts/versionChecker.ts
|
|
@@ -221,4 +221,4 @@ async function displayVersion() {
|
|
|
221
221
|
|
|
222
222
|
//#endregion
|
|
223
223
|
export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
|
|
224
|
-
//# sourceMappingURL=versionChecker-
|
|
224
|
+
//# sourceMappingURL=versionChecker-C1W2s4ZP.js.map
|
package/lab/ui/console-logic.js
CHANGED
|
@@ -115,6 +115,20 @@ export function tagsFor(e) {
|
|
|
115
115
|
return t;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// Compact git indicator from the record's `git` snapshot (server-side
|
|
119
|
+
// `git status --porcelain --branch`): "±3" changed files, "↑1" ahead, "↓2"
|
|
120
|
+
// behind. Returns "" when there's no git info or the tree is clean and in sync,
|
|
121
|
+
// so a tidy repo adds no noise. Branch itself is shown via the path identity.
|
|
122
|
+
export function gitLabel(e) {
|
|
123
|
+
const g = e.git;
|
|
124
|
+
if (!g) return "";
|
|
125
|
+
const parts = [];
|
|
126
|
+
if (g.changed > 0) parts.push("±" + g.changed);
|
|
127
|
+
if (g.ahead > 0) parts.push("↑" + g.ahead);
|
|
128
|
+
if (g.behind > 0) parts.push("↓" + g.behind);
|
|
129
|
+
return parts.join(" ");
|
|
130
|
+
}
|
|
131
|
+
|
|
118
132
|
// Human age of an agent ("12s" / "5m" / "3h"). `now` is injectable so tests
|
|
119
133
|
// don't depend on the wall clock; the browser calls age(e) and gets Date.now().
|
|
120
134
|
export function age(e, now = Date.now()) {
|
|
@@ -130,7 +144,16 @@ export function age(e, now = Date.now()) {
|
|
|
130
144
|
// case-insensitive substring search over title/prompt/cli/cwd/status.
|
|
131
145
|
export function matches(e, toks) {
|
|
132
146
|
const hay =
|
|
133
|
-
(e.title || "") +
|
|
147
|
+
(e.title || "") +
|
|
148
|
+
" " +
|
|
149
|
+
(e.prompt || "") +
|
|
150
|
+
" " +
|
|
151
|
+
e.cli +
|
|
152
|
+
" " +
|
|
153
|
+
(e.cwd || "") +
|
|
154
|
+
" " +
|
|
155
|
+
e.status +
|
|
156
|
+
(e.git?.dirty ? " dirty" : "");
|
|
134
157
|
return toks.every((tok) => {
|
|
135
158
|
tok = tok.toLowerCase();
|
|
136
159
|
const ci = tok.indexOf(":");
|
package/lab/ui/index.html
CHANGED
|
@@ -505,6 +505,17 @@
|
|
|
505
505
|
color: var(--muted);
|
|
506
506
|
font-size: 11.5px;
|
|
507
507
|
}
|
|
508
|
+
/* git chip: ±changed ↑ahead ↓behind, amber when the worktree is dirty */
|
|
509
|
+
.git {
|
|
510
|
+
font-family: var(--mono);
|
|
511
|
+
font-size: 10.5px;
|
|
512
|
+
color: var(--muted);
|
|
513
|
+
white-space: nowrap;
|
|
514
|
+
flex: none;
|
|
515
|
+
}
|
|
516
|
+
.git.dirty {
|
|
517
|
+
color: var(--amber);
|
|
518
|
+
}
|
|
508
519
|
.detail {
|
|
509
520
|
color: var(--muted);
|
|
510
521
|
font-size: 12.5px;
|
|
@@ -821,6 +832,7 @@
|
|
|
821
832
|
repoBranch,
|
|
822
833
|
ident,
|
|
823
834
|
tagsFor,
|
|
835
|
+
gitLabel,
|
|
824
836
|
age,
|
|
825
837
|
matches,
|
|
826
838
|
nextIndex,
|
|
@@ -1333,6 +1345,16 @@
|
|
|
1333
1345
|
// Compact list: one line per agent (dot + cli + title), persisted per device.
|
|
1334
1346
|
let compactList = localStorage.getItem("ay.compactList") === "1";
|
|
1335
1347
|
|
|
1348
|
+
// A small git chip (±changed ↑ahead ↓behind) for a row, amber when the tree
|
|
1349
|
+
// is dirty. Empty for clean/in-sync repos and non-git cwds — no noise.
|
|
1350
|
+
function gitChipHtml(e) {
|
|
1351
|
+
const label = gitLabel(e);
|
|
1352
|
+
if (!label) return "";
|
|
1353
|
+
const g = e.git || {};
|
|
1354
|
+
const tip = `git: ${g.changed || 0} changed · ${g.ahead || 0} ahead · ${g.behind || 0} behind`;
|
|
1355
|
+
return `<span class="git${g.dirty ? " dirty" : ""}" title="${esc(tip)}">${esc(label)}</span>`;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1336
1358
|
function renderList() {
|
|
1337
1359
|
const toks = $("q").value.trim().split(/\s+/).filter(Boolean);
|
|
1338
1360
|
const shown = entries.filter((e) => matches(e, toks));
|
|
@@ -1355,6 +1377,7 @@
|
|
|
1355
1377
|
${hasIdent(id) ? `<span class="cident" title="${esc(fullIdent(e))}">${esc(id)}</span>` : ""}
|
|
1356
1378
|
${cli ? `<span class="cname">${esc(cli)}</span>` : ""}
|
|
1357
1379
|
<span class="ctitle ${e.title ? "" : "dim"}" title="${esc(t)}">${esc(t)}</span>
|
|
1380
|
+
${gitChipHtml(e)}
|
|
1358
1381
|
<span class="age">${age(e)}</span></div>`;
|
|
1359
1382
|
})
|
|
1360
1383
|
.join("") || `<div class="empty">no match</div>`;
|
|
@@ -1376,6 +1399,7 @@
|
|
|
1376
1399
|
<div class="r1"><span class="dot ${esc(e.status)}"></span>
|
|
1377
1400
|
<span class="name">${esc(cliLabel(e) || ident(e) || "agent")}</span>
|
|
1378
1401
|
<span class="badge">pid ${e.pid}</span>
|
|
1402
|
+
${gitChipHtml(e)}
|
|
1379
1403
|
<span class="age">${age(e)}</span></div>
|
|
1380
1404
|
${e.title ? `<div class="rowtitle" title="${esc(e.title)}">${esc(e.title)}</div>` : ""}
|
|
1381
1405
|
${e.prompt ? `<div class="detail" title="${esc(e.prompt)}">${esc(e.prompt)}</div>` : ""}
|
package/package.json
CHANGED
package/ts/serve.ts
CHANGED
|
@@ -291,6 +291,62 @@ export async function cmdServe(rest: string[]): Promise<number> {
|
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
+
// Per-cwd git snapshot for the list: branch + dirty/changed count + ahead/behind
|
|
295
|
+
// vs upstream, all from a single `git status --porcelain --branch`. Cached per
|
|
296
|
+
// cwd with a short TTL so the 1s subscribe tick (and /api/ls polls) spawn at most
|
|
297
|
+
// one git per repo every few seconds — agents sharing a cwd share the result.
|
|
298
|
+
// Non-git dirs, errors, and timeouts cache as null.
|
|
299
|
+
interface GitInfo {
|
|
300
|
+
branch: string | null;
|
|
301
|
+
dirty: boolean;
|
|
302
|
+
changed: number;
|
|
303
|
+
ahead: number;
|
|
304
|
+
behind: number;
|
|
305
|
+
}
|
|
306
|
+
const GIT_TTL_MS = 5000;
|
|
307
|
+
const gitCache = new Map<string, { at: number; val: GitInfo | null }>();
|
|
308
|
+
const gitStatus = async (cwd: string | null | undefined): Promise<GitInfo | null> => {
|
|
309
|
+
if (!cwd) return null;
|
|
310
|
+
const now = Date.now();
|
|
311
|
+
const hit = gitCache.get(cwd);
|
|
312
|
+
if (hit && now - hit.at < GIT_TTL_MS) return hit.val;
|
|
313
|
+
let val: GitInfo | null = null;
|
|
314
|
+
try {
|
|
315
|
+
const proc = Bun.spawn(["git", "status", "--porcelain", "--branch"], {
|
|
316
|
+
cwd,
|
|
317
|
+
stdout: "pipe",
|
|
318
|
+
stderr: "ignore",
|
|
319
|
+
signal: AbortSignal.timeout(2000),
|
|
320
|
+
});
|
|
321
|
+
const out = await new Response(proc.stdout).text();
|
|
322
|
+
await proc.exited;
|
|
323
|
+
if (proc.exitCode === 0) {
|
|
324
|
+
const lines = out.split("\n");
|
|
325
|
+
// Branch header, e.g. "## main...origin/main [ahead 1, behind 2]",
|
|
326
|
+
// "## main" (no upstream), "## HEAD (no branch)", or "## No commits yet on x".
|
|
327
|
+
const h = /^## (.+)$/.exec(lines[0] ?? "")?.[1] ?? "";
|
|
328
|
+
const unborn = /^No commits yet on (.+)$/.exec(h);
|
|
329
|
+
const branch = unborn ? unborn[1]! : /^(.+?)(?:\.\.\.|\s|$)/.exec(h)?.[1] || null;
|
|
330
|
+
const ahead = Number(/\bahead (\d+)/.exec(h)?.[1] ?? 0);
|
|
331
|
+
const behind = Number(/\bbehind (\d+)/.exec(h)?.[1] ?? 0);
|
|
332
|
+
const changed = lines.slice(1).filter((l) => l.trim().length > 0).length;
|
|
333
|
+
val = { branch, dirty: changed > 0, changed, ahead, behind };
|
|
334
|
+
}
|
|
335
|
+
} catch {
|
|
336
|
+
val = null; // git missing, not a repo, or timed out
|
|
337
|
+
}
|
|
338
|
+
gitCache.set(cwd, { at: now, val });
|
|
339
|
+
return val;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// One agent record decorated for the console: the latest OSC title + a git
|
|
343
|
+
// snapshot (skipped for exited agents — their repo state is no longer live).
|
|
344
|
+
const withMeta = async (r: Awaited<ReturnType<typeof listRecords>>[number]) => ({
|
|
345
|
+
...r,
|
|
346
|
+
title: await logTitle(r.log_file),
|
|
347
|
+
git: r.status === "exited" ? null : await gitStatus(r.cwd),
|
|
348
|
+
});
|
|
349
|
+
|
|
294
350
|
// The whole API as a plain handler: served over HTTP by Bun.serve (--http)
|
|
295
351
|
// and called in-process by the WebRTC bridge (--webrtc) — the latter needs
|
|
296
352
|
// no TCP port at all.
|
|
@@ -311,10 +367,7 @@ export async function cmdServe(rest: string[]): Promise<number> {
|
|
|
311
367
|
});
|
|
312
368
|
try {
|
|
313
369
|
const records = await listRecords(keyword, opts);
|
|
314
|
-
|
|
315
|
-
records.map(async (r) => ({ ...r, title: await logTitle(r.log_file) })),
|
|
316
|
-
);
|
|
317
|
-
return Response.json(withTitles);
|
|
370
|
+
return Response.json(await Promise.all(records.map(withMeta)));
|
|
318
371
|
} catch (e) {
|
|
319
372
|
return new Response((e as Error).message, { status: 500 });
|
|
320
373
|
}
|
|
@@ -348,9 +401,7 @@ export async function cmdServe(rest: string[]): Promise<number> {
|
|
|
348
401
|
const sent = new Map<number, string>();
|
|
349
402
|
const compute = async () => {
|
|
350
403
|
const records = await listRecords(keyword, opts);
|
|
351
|
-
return Promise.all(
|
|
352
|
-
records.map(async (r) => ({ ...r, title: await logTitle(r.log_file) })),
|
|
353
|
-
);
|
|
404
|
+
return Promise.all(records.map(withMeta));
|
|
354
405
|
};
|
|
355
406
|
const tick = async (first: boolean) => {
|
|
356
407
|
if (closed) return;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "./ts-ChVJOKNr.js";
|
|
2
|
-
import "./logger-B9h0djqx.js";
|
|
3
|
-
import "./versionChecker-wxlWV_VT.js";
|
|
4
|
-
import "./pidStore-DBjlqzo8.js";
|
|
5
|
-
import "./globalPidIndex-yVd3mbsV.js";
|
|
6
|
-
import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BpO7ZYx_.js";
|
|
7
|
-
|
|
8
|
-
export { SUPPORTED_CLIS };
|