@staff0rd/assist 0.709.0 → 0.710.1
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 +7 -3
- package/allowed.cli-reads +2 -0
- package/claude/commands/draft.md +1 -1
- package/claude/commands/refine.md +1 -1
- package/dist/allowed.cli-reads +2 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +544 -172
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.710.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -283,13 +283,13 @@ function remoteUrl(cwd) {
|
|
|
283
283
|
if (origin.out) return { url: origin.out, ok: true };
|
|
284
284
|
const remotes = runGit(cwd, ["remote"]);
|
|
285
285
|
if (!remotes.ok) return { url: null, ok: false };
|
|
286
|
-
let
|
|
286
|
+
let failed3 = false;
|
|
287
287
|
for (const remote of remotes.out.split("\n").map((r) => r.trim()).filter(Boolean)) {
|
|
288
288
|
const url = runGit(cwd, ["remote", "get-url", remote]);
|
|
289
289
|
if (url.out) return { url: url.out, ok: true };
|
|
290
|
-
if (!url.ok)
|
|
290
|
+
if (!url.ok) failed3 = true;
|
|
291
291
|
}
|
|
292
|
-
return { url: null, ok: !
|
|
292
|
+
return { url: null, ok: !failed3 };
|
|
293
293
|
}
|
|
294
294
|
function getRemoteOriginUrl(cwd) {
|
|
295
295
|
return remoteUrl(cwd).url;
|
|
@@ -660,8 +660,7 @@ var assistConfigShape = {
|
|
|
660
660
|
verify: z3.string().optional()
|
|
661
661
|
}).optional(),
|
|
662
662
|
backlog: z3.strictObject({
|
|
663
|
-
previewComments: z3.boolean().default(false)
|
|
664
|
-
crossRepo: z3.boolean().default(false)
|
|
663
|
+
previewComments: z3.boolean().default(false)
|
|
665
664
|
}).optional(),
|
|
666
665
|
backup: z3.strictObject({
|
|
667
666
|
dir: z3.string().default(DEFAULT_BACKUP_DIR)
|
|
@@ -2088,10 +2087,10 @@ function flushIfFailed(exitCode, chunks) {
|
|
|
2088
2087
|
}
|
|
2089
2088
|
|
|
2090
2089
|
// src/commands/verify/run/runAllEntries.ts
|
|
2091
|
-
function logFailedScripts(
|
|
2090
|
+
function logFailedScripts(failed3) {
|
|
2092
2091
|
console.error(`
|
|
2093
|
-
${
|
|
2094
|
-
for (const f of
|
|
2092
|
+
${failed3.length} script(s) failed:`);
|
|
2093
|
+
for (const f of failed3) {
|
|
2095
2094
|
console.error(` - ${f.script} (exit code ${f.code})`);
|
|
2096
2095
|
}
|
|
2097
2096
|
}
|
|
@@ -2116,9 +2115,9 @@ function runEntry(entry) {
|
|
|
2116
2115
|
});
|
|
2117
2116
|
});
|
|
2118
2117
|
}
|
|
2119
|
-
function exitIfFailed(
|
|
2120
|
-
if (
|
|
2121
|
-
logFailedScripts(
|
|
2118
|
+
function exitIfFailed(failed3) {
|
|
2119
|
+
if (failed3.length === 0) return;
|
|
2120
|
+
logFailedScripts(failed3);
|
|
2122
2121
|
process.exit(1);
|
|
2123
2122
|
}
|
|
2124
2123
|
async function runAllEntries(entries) {
|
|
@@ -4205,11 +4204,6 @@ var backlogConfigHelp = [
|
|
|
4205
4204
|
setter: "assist config set backlog.previewComments true",
|
|
4206
4205
|
note: "review 'backlog comment' in the web preview pane before it is written (default: off)"
|
|
4207
4206
|
},
|
|
4208
|
-
{
|
|
4209
|
-
key: "backlog.crossRepo",
|
|
4210
|
-
setter: "assist config set backlog.crossRepo true",
|
|
4211
|
-
note: "let phase runs, /draft and /refine plan and make changes in other repos (default: off, limited to this repo)"
|
|
4212
|
-
},
|
|
4213
4207
|
{
|
|
4214
4208
|
key: "clone.baseDir",
|
|
4215
4209
|
setter: "assist config set clone.baseDir ~/git",
|
|
@@ -6513,17 +6507,6 @@ function buildManualCheckLines(manualChecks, commitBeforePhaseEnd) {
|
|
|
6513
6507
|
return [];
|
|
6514
6508
|
}
|
|
6515
6509
|
|
|
6516
|
-
// src/commands/backlog/buildJiraStartedLines.ts
|
|
6517
|
-
function buildJiraStartedLines(item, phaseNumber) {
|
|
6518
|
-
if (phaseNumber !== 1 || !item.jiraKey) {
|
|
6519
|
-
return [];
|
|
6520
|
-
}
|
|
6521
|
-
return [
|
|
6522
|
-
"",
|
|
6523
|
-
`As your first step, before any implementation, run \`/jira started ${item.jiraKey}\` to assign the issue to yourself and transition it to In Progress.`
|
|
6524
|
-
];
|
|
6525
|
-
}
|
|
6526
|
-
|
|
6527
6510
|
// src/commands/backlog/buildAuthoredPhasePrompt.ts
|
|
6528
6511
|
function buildAuthoredPhasePrompt(item, phaseNumber, phase, options2 = {
|
|
6529
6512
|
commitBeforePhaseEnd: false
|
|
@@ -6536,7 +6519,7 @@ function buildAuthoredPhasePrompt(item, phaseNumber, phase, options2 = {
|
|
|
6536
6519
|
...buildJiraStartedLines(item, phaseNumber),
|
|
6537
6520
|
"",
|
|
6538
6521
|
"Focus ONLY on this phase. Do not work on other phases.",
|
|
6539
|
-
|
|
6522
|
+
"Work only in this item's own repo. Do not modify, commit or push any other repo without the user's explicit permission \u2014 if a task needs changes elsewhere, stop and ask the user, and suggest filing that work as a separate item in that repo's backlog.",
|
|
6540
6523
|
"If you need to modify backlog items, run `assist backlog --help` to discover available commands.",
|
|
6541
6524
|
"When you have completed all tasks for this phase, run /verify to check your work.",
|
|
6542
6525
|
...buildManualCheckLines(manualChecks, options2.commitBeforePhaseEnd),
|
|
@@ -6563,6 +6546,15 @@ function buildContextLines(item, phaseNumber, phase) {
|
|
|
6563
6546
|
formatTasks(phase)
|
|
6564
6547
|
];
|
|
6565
6548
|
}
|
|
6549
|
+
function buildJiraStartedLines(item, phaseNumber) {
|
|
6550
|
+
if (phaseNumber !== 1 || !item.jiraKey) {
|
|
6551
|
+
return [];
|
|
6552
|
+
}
|
|
6553
|
+
return [
|
|
6554
|
+
"",
|
|
6555
|
+
`As your first step, before any implementation, run \`/jira started ${item.jiraKey}\` to assign the issue to yourself and transition it to In Progress.`
|
|
6556
|
+
];
|
|
6557
|
+
}
|
|
6566
6558
|
function formatTasks(phase) {
|
|
6567
6559
|
return phase.tasks.map((t) => `- ${t.task}`).join("\n");
|
|
6568
6560
|
}
|
|
@@ -6619,14 +6611,13 @@ function buildReviewPrompt(item, phaseNumber, options2 = {
|
|
|
6619
6611
|
// src/commands/backlog/buildPhasePrompt.ts
|
|
6620
6612
|
var REVIEW_PHASE_NAME = "Review";
|
|
6621
6613
|
function buildPhasePrompt(item, phaseNumber, phase) {
|
|
6622
|
-
const
|
|
6614
|
+
const worktree = loadConfig().worktree;
|
|
6623
6615
|
const commitBeforePhaseEnd = worktree?.commitBeforePhaseEnd ?? worktree?.commitBeforeManualChecks ?? false;
|
|
6624
6616
|
if (phase.name === REVIEW_PHASE_NAME) {
|
|
6625
6617
|
return buildReviewPrompt(item, phaseNumber, { commitBeforePhaseEnd });
|
|
6626
6618
|
}
|
|
6627
6619
|
return buildAuthoredPhasePrompt(item, phaseNumber, phase, {
|
|
6628
|
-
commitBeforePhaseEnd
|
|
6629
|
-
crossRepo: backlog?.crossRepo ?? false
|
|
6620
|
+
commitBeforePhaseEnd
|
|
6630
6621
|
});
|
|
6631
6622
|
}
|
|
6632
6623
|
|
|
@@ -11458,6 +11449,52 @@ async function handleItemRoute(req, res, pathname) {
|
|
|
11458
11449
|
return false;
|
|
11459
11450
|
}
|
|
11460
11451
|
|
|
11452
|
+
// src/commands/sessions/shared/readLogTail.ts
|
|
11453
|
+
import { closeSync as closeSync3, fstatSync, openSync as openSync4, readSync as readSync2 } from "fs";
|
|
11454
|
+
var MAX_TAIL_BYTES = 4 * 1024 * 1024;
|
|
11455
|
+
function completeLines(text18, windowIsPartial) {
|
|
11456
|
+
const all = text18.split("\n");
|
|
11457
|
+
if (all.at(-1) === "") all.pop();
|
|
11458
|
+
if (windowIsPartial) all.shift();
|
|
11459
|
+
return all;
|
|
11460
|
+
}
|
|
11461
|
+
function readLogTail(path103, lines2) {
|
|
11462
|
+
let fd;
|
|
11463
|
+
try {
|
|
11464
|
+
fd = openSync4(path103, "r");
|
|
11465
|
+
} catch {
|
|
11466
|
+
return [];
|
|
11467
|
+
}
|
|
11468
|
+
try {
|
|
11469
|
+
const size = fstatSync(fd).size;
|
|
11470
|
+
const length = Math.min(size, MAX_TAIL_BYTES);
|
|
11471
|
+
const buffer = Buffer.alloc(length);
|
|
11472
|
+
readSync2(fd, buffer, 0, length, size - length);
|
|
11473
|
+
return completeLines(buffer.toString("utf8"), length < size).slice(-lines2);
|
|
11474
|
+
} finally {
|
|
11475
|
+
closeSync3(fd);
|
|
11476
|
+
}
|
|
11477
|
+
}
|
|
11478
|
+
|
|
11479
|
+
// src/commands/sessions/web/daemonLogTail.ts
|
|
11480
|
+
var DEFAULT_LINES = 200;
|
|
11481
|
+
var MAX_LINES = 1e4;
|
|
11482
|
+
function requestedLines(req) {
|
|
11483
|
+
const raw = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
11484
|
+
"lines"
|
|
11485
|
+
);
|
|
11486
|
+
const parsed = Number.parseInt(raw ?? "", 10);
|
|
11487
|
+
if (!Number.isFinite(parsed) || parsed < 1) return DEFAULT_LINES;
|
|
11488
|
+
return Math.min(parsed, MAX_LINES);
|
|
11489
|
+
}
|
|
11490
|
+
async function daemonLogTail(req, res) {
|
|
11491
|
+
respondJson(res, 200, {
|
|
11492
|
+
nodeName: resolveNodeName(),
|
|
11493
|
+
path: daemonPaths.log,
|
|
11494
|
+
lines: readLogTail(daemonPaths.log, requestedLines(req))
|
|
11495
|
+
});
|
|
11496
|
+
}
|
|
11497
|
+
|
|
11461
11498
|
// src/commands/sessions/web/getCwdParam.ts
|
|
11462
11499
|
function getCwdParam(req, res) {
|
|
11463
11500
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -13330,13 +13367,51 @@ function protocolMismatched(msg) {
|
|
|
13330
13367
|
return typeof msg.protocol === "number" && msg.protocol !== PROTOCOL_VERSION;
|
|
13331
13368
|
}
|
|
13332
13369
|
|
|
13370
|
+
// src/commands/sessions/nodes/queryNodes.ts
|
|
13371
|
+
import { createInterface as createInterface5 } from "readline";
|
|
13372
|
+
var QUERY_TIMEOUT_MS = 3e3;
|
|
13373
|
+
async function queryNodes() {
|
|
13374
|
+
let socket;
|
|
13375
|
+
try {
|
|
13376
|
+
socket = await connectToDaemon();
|
|
13377
|
+
} catch {
|
|
13378
|
+
return void 0;
|
|
13379
|
+
}
|
|
13380
|
+
return new Promise((resolve25) => {
|
|
13381
|
+
const finish2 = (result) => {
|
|
13382
|
+
clearTimeout(timer);
|
|
13383
|
+
socket.destroy();
|
|
13384
|
+
resolve25(result);
|
|
13385
|
+
};
|
|
13386
|
+
const timer = setTimeout(() => finish2(void 0), QUERY_TIMEOUT_MS);
|
|
13387
|
+
const lines2 = createInterface5({ input: socket });
|
|
13388
|
+
lines2.on("error", () => {
|
|
13389
|
+
});
|
|
13390
|
+
lines2.on("line", (line) => {
|
|
13391
|
+
try {
|
|
13392
|
+
const data = JSON.parse(line);
|
|
13393
|
+
if (data.type === "nodes") finish2(data);
|
|
13394
|
+
} catch {
|
|
13395
|
+
}
|
|
13396
|
+
});
|
|
13397
|
+
socket.on("error", () => finish2(void 0));
|
|
13398
|
+
socket.write(`${JSON.stringify({ type: "nodes" })}
|
|
13399
|
+
`);
|
|
13400
|
+
});
|
|
13401
|
+
}
|
|
13402
|
+
|
|
13333
13403
|
// src/commands/sessions/web/health.ts
|
|
13334
13404
|
async function health(_req, res) {
|
|
13405
|
+
const [reachable, nodes] = await Promise.all([
|
|
13406
|
+
isDaemonRunning(),
|
|
13407
|
+
queryNodes()
|
|
13408
|
+
]);
|
|
13335
13409
|
respondJson(res, 200, {
|
|
13336
13410
|
nodeName: resolveNodeName(),
|
|
13337
13411
|
version: ASSIST_VERSION,
|
|
13338
13412
|
protocol: PROTOCOL_VERSION,
|
|
13339
|
-
daemon: { reachable
|
|
13413
|
+
daemon: { reachable },
|
|
13414
|
+
links: nodes?.links ?? []
|
|
13340
13415
|
});
|
|
13341
13416
|
}
|
|
13342
13417
|
|
|
@@ -13991,6 +14066,13 @@ async function prList(req, res) {
|
|
|
13991
14066
|
respondJson(res, 200, { prs: await getOpenPrs(cwd) });
|
|
13992
14067
|
}
|
|
13993
14068
|
|
|
14069
|
+
// src/commands/sessions/shared/newTraceId.ts
|
|
14070
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
14071
|
+
var TRACE_HEADER = "x-assist-trace-id";
|
|
14072
|
+
function newTraceId() {
|
|
14073
|
+
return randomUUID7().slice(0, 8);
|
|
14074
|
+
}
|
|
14075
|
+
|
|
13994
14076
|
// src/commands/sessions/web/forwardToPeer.ts
|
|
13995
14077
|
import {
|
|
13996
14078
|
request as httpRequest
|
|
@@ -13999,7 +14081,8 @@ import { request as httpsRequest } from "https";
|
|
|
13999
14081
|
var LINKED_FROM_HEADER = "x-assist-linked-from";
|
|
14000
14082
|
function forwardToPeer(req, res, node, url) {
|
|
14001
14083
|
const started = Date.now();
|
|
14002
|
-
const
|
|
14084
|
+
const traceId = newTraceId();
|
|
14085
|
+
const label2 = `link ${node} http: ${req.method} ${url.pathname} trace=${traceId}`;
|
|
14003
14086
|
const elapsed = () => `${Date.now() - started}ms`;
|
|
14004
14087
|
const send = url.protocol === "https:" ? httpsRequest : httpRequest;
|
|
14005
14088
|
return new Promise((resolve25) => {
|
|
@@ -14010,7 +14093,8 @@ function forwardToPeer(req, res, node, url) {
|
|
|
14010
14093
|
headers: {
|
|
14011
14094
|
...req.headers,
|
|
14012
14095
|
host: url.host,
|
|
14013
|
-
[LINKED_FROM_HEADER]: resolveNodeName()
|
|
14096
|
+
[LINKED_FROM_HEADER]: resolveNodeName(),
|
|
14097
|
+
[TRACE_HEADER]: traceId
|
|
14014
14098
|
}
|
|
14015
14099
|
},
|
|
14016
14100
|
(peer) => {
|
|
@@ -14054,7 +14138,20 @@ function proxyTarget(req) {
|
|
|
14054
14138
|
url: new URL(`${url.pathname}${url.search}`, link3.url)
|
|
14055
14139
|
};
|
|
14056
14140
|
}
|
|
14141
|
+
function logLinkedRequest(req, res) {
|
|
14142
|
+
const started = Date.now();
|
|
14143
|
+
const from = req.headers[LINKED_FROM_HEADER2];
|
|
14144
|
+
const trace = req.headers[TRACE_HEADER] ?? "none";
|
|
14145
|
+
const path103 = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
14146
|
+
res.once(
|
|
14147
|
+
"finish",
|
|
14148
|
+
() => console.log(
|
|
14149
|
+
`link-from ${from} http: ${req.method} ${path103} trace=${trace} -> ${res.statusCode} (${Date.now() - started}ms)`
|
|
14150
|
+
)
|
|
14151
|
+
);
|
|
14152
|
+
}
|
|
14057
14153
|
async function proxyToNode(req, res) {
|
|
14154
|
+
if (arrivedOverLink(req)) logLinkedRequest(req, res);
|
|
14058
14155
|
const target = proxyTarget(req);
|
|
14059
14156
|
if (target.kind === "local") return false;
|
|
14060
14157
|
if (target.kind === "unknown") {
|
|
@@ -14874,11 +14971,11 @@ async function revertDiffPaths(req, res) {
|
|
|
14874
14971
|
}
|
|
14875
14972
|
const root2 = repoRoot(cwd);
|
|
14876
14973
|
const reverted = [];
|
|
14877
|
-
const
|
|
14974
|
+
const failed3 = [];
|
|
14878
14975
|
for (const path103 of paths) {
|
|
14879
14976
|
const target = resolveWithinCwd(cwd, path103);
|
|
14880
14977
|
if (!target) {
|
|
14881
|
-
|
|
14978
|
+
failed3.push({ path: path103, error: "Path outside cwd" });
|
|
14882
14979
|
continue;
|
|
14883
14980
|
}
|
|
14884
14981
|
const relativePath = relative4(root2, target);
|
|
@@ -14886,13 +14983,13 @@ async function revertDiffPaths(req, res) {
|
|
|
14886
14983
|
await revertPathChanges(cwd, relativePath);
|
|
14887
14984
|
reverted.push(relativePath);
|
|
14888
14985
|
} catch (error) {
|
|
14889
|
-
|
|
14986
|
+
failed3.push({
|
|
14890
14987
|
path: relativePath,
|
|
14891
14988
|
error: error instanceof Error ? error.message : "Failed to revert file"
|
|
14892
14989
|
});
|
|
14893
14990
|
}
|
|
14894
14991
|
}
|
|
14895
|
-
respondJson(res, 200, { reverted, failed:
|
|
14992
|
+
respondJson(res, 200, { reverted, failed: failed3 });
|
|
14896
14993
|
}
|
|
14897
14994
|
|
|
14898
14995
|
// src/commands/sessions/web/sessionLayout.ts
|
|
@@ -15788,6 +15885,7 @@ var routes2 = {
|
|
|
15788
15885
|
"text/css"
|
|
15789
15886
|
),
|
|
15790
15887
|
"GET /api/health": health,
|
|
15888
|
+
"GET /api/daemon-log": daemonLogTail,
|
|
15791
15889
|
"GET /api/items": listItems,
|
|
15792
15890
|
"GET /api/backlog/summary": getBacklogSummary,
|
|
15793
15891
|
"GET /api/repo-location": getRepoLocation,
|
|
@@ -16054,7 +16152,7 @@ function installRestartMenu(options2 = {}) {
|
|
|
16054
16152
|
}
|
|
16055
16153
|
|
|
16056
16154
|
// src/commands/sessions/web/streamDaemonLogs.ts
|
|
16057
|
-
import { createInterface as
|
|
16155
|
+
import { createInterface as createInterface6 } from "readline";
|
|
16058
16156
|
var RECONNECT_MS = 3e3;
|
|
16059
16157
|
function streamDaemonLogs() {
|
|
16060
16158
|
void connect2();
|
|
@@ -16073,7 +16171,7 @@ async function connect2() {
|
|
|
16073
16171
|
}
|
|
16074
16172
|
}
|
|
16075
16173
|
function wire(socket) {
|
|
16076
|
-
const lines2 =
|
|
16174
|
+
const lines2 = createInterface6({ input: socket });
|
|
16077
16175
|
lines2.on("error", () => {
|
|
16078
16176
|
});
|
|
16079
16177
|
lines2.on("line", emit);
|
|
@@ -20529,7 +20627,7 @@ function registerDevlog(program2) {
|
|
|
20529
20627
|
}
|
|
20530
20628
|
|
|
20531
20629
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
20532
|
-
import { closeSync as
|
|
20630
|
+
import { closeSync as closeSync4, openSync as openSync5, readdirSync as readdirSync7 } from "fs";
|
|
20533
20631
|
import { join as join57 } from "path";
|
|
20534
20632
|
import chalk151 from "chalk";
|
|
20535
20633
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
@@ -20544,8 +20642,8 @@ function isLockedDll(debugDir) {
|
|
|
20544
20642
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
20545
20643
|
const dllPath = join57(debugDir, file);
|
|
20546
20644
|
try {
|
|
20547
|
-
const fd =
|
|
20548
|
-
|
|
20645
|
+
const fd = openSync5(dllPath, "r+");
|
|
20646
|
+
closeSync4(fd);
|
|
20549
20647
|
} catch {
|
|
20550
20648
|
return dllPath;
|
|
20551
20649
|
}
|
|
@@ -22707,13 +22805,13 @@ function validateProposedContent(labels, title, body) {
|
|
|
22707
22805
|
}
|
|
22708
22806
|
|
|
22709
22807
|
// src/commands/github/issue/reviewProposedIssueComment.ts
|
|
22710
|
-
import { randomUUID as
|
|
22808
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
22711
22809
|
async function reviewProposedIssueComment(title, body) {
|
|
22712
22810
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
22713
22811
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
22714
22812
|
await awaitPreviewApproval("GitHub issue comment preview", {
|
|
22715
22813
|
sessionId,
|
|
22716
|
-
requestId:
|
|
22814
|
+
requestId: randomUUID8(),
|
|
22717
22815
|
title,
|
|
22718
22816
|
body,
|
|
22719
22817
|
prNumber: null,
|
|
@@ -23195,13 +23293,13 @@ function resolveCreateIssueMetadata(options2) {
|
|
|
23195
23293
|
}
|
|
23196
23294
|
|
|
23197
23295
|
// src/commands/github/issue/reviewProposedIssue.ts
|
|
23198
|
-
import { randomUUID as
|
|
23296
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
23199
23297
|
async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
23200
23298
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
23201
23299
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return void 0;
|
|
23202
23300
|
return await awaitPreviewApproval("GitHub issue preview", {
|
|
23203
23301
|
sessionId,
|
|
23204
|
-
requestId:
|
|
23302
|
+
requestId: randomUUID9(),
|
|
23205
23303
|
title,
|
|
23206
23304
|
body,
|
|
23207
23305
|
prNumber: null,
|
|
@@ -23424,7 +23522,7 @@ function pushUnchangedIssue(number, repo, target, fetchedAt, bodyPath) {
|
|
|
23424
23522
|
}
|
|
23425
23523
|
|
|
23426
23524
|
// src/commands/github/issue/reviewProposedIssueEdit.ts
|
|
23427
|
-
import { randomUUID as
|
|
23525
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
23428
23526
|
async function reviewProposedIssueEdit(title, body, working) {
|
|
23429
23527
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
23430
23528
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return body;
|
|
@@ -23432,7 +23530,7 @@ async function reviewProposedIssueEdit(title, body, working) {
|
|
|
23432
23530
|
"GitHub issue edit preview",
|
|
23433
23531
|
{
|
|
23434
23532
|
sessionId,
|
|
23435
|
-
requestId:
|
|
23533
|
+
requestId: randomUUID10(),
|
|
23436
23534
|
title,
|
|
23437
23535
|
body,
|
|
23438
23536
|
prNumber: null,
|
|
@@ -24166,7 +24264,7 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
24166
24264
|
}
|
|
24167
24265
|
|
|
24168
24266
|
// src/commands/reviewPrComments.ts
|
|
24169
|
-
import { randomUUID as
|
|
24267
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
24170
24268
|
|
|
24171
24269
|
// src/commands/review/checkoutPr.ts
|
|
24172
24270
|
import { execFileSync as execFileSync15 } from "child_process";
|
|
@@ -24822,7 +24920,7 @@ async function reviewPrComments(number, options2 = {}) {
|
|
|
24822
24920
|
const resumeSessionId = options2.resumeSessionId;
|
|
24823
24921
|
validateAnnounce(number, announce);
|
|
24824
24922
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
24825
|
-
const claudeSessionId = resumeSessionId ??
|
|
24923
|
+
const claudeSessionId = resumeSessionId ?? randomUUID11();
|
|
24826
24924
|
emitActivity({
|
|
24827
24925
|
kind: "command",
|
|
24828
24926
|
name: "review-pr-comments",
|
|
@@ -24840,14 +24938,14 @@ async function reviewPrComments(number, options2 = {}) {
|
|
|
24840
24938
|
}
|
|
24841
24939
|
|
|
24842
24940
|
// src/commands/fixConflict.ts
|
|
24843
|
-
import { randomUUID as
|
|
24941
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
24844
24942
|
function buildPrompt3(rebase) {
|
|
24845
24943
|
return rebase ? "/fix-conflict --rebase" : "/fix-conflict";
|
|
24846
24944
|
}
|
|
24847
24945
|
async function fixConflict(number, options2 = {}) {
|
|
24848
24946
|
const { resumeSessionId } = options2;
|
|
24849
24947
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
24850
|
-
const claudeSessionId = resumeSessionId ??
|
|
24948
|
+
const claudeSessionId = resumeSessionId ?? randomUUID12();
|
|
24851
24949
|
emitActivity({
|
|
24852
24950
|
kind: "command",
|
|
24853
24951
|
name: "fix-conflict",
|
|
@@ -25391,7 +25489,7 @@ async function offerSaveExtract(extract2, options2, paths = {}) {
|
|
|
25391
25489
|
}
|
|
25392
25490
|
|
|
25393
25491
|
// src/commands/miro/pickAnchors.ts
|
|
25394
|
-
import { randomUUID as
|
|
25492
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
25395
25493
|
|
|
25396
25494
|
// src/commands/miro/isBox.ts
|
|
25397
25495
|
var boxTypes = /* @__PURE__ */ new Set(["shape", "sticky_note"]);
|
|
@@ -25412,7 +25510,7 @@ async function pickAnchors(sessionId, items2) {
|
|
|
25412
25510
|
"Miro anchor selection",
|
|
25413
25511
|
{
|
|
25414
25512
|
sessionId,
|
|
25415
|
-
requestId:
|
|
25513
|
+
requestId: randomUUID13(),
|
|
25416
25514
|
title: "Pick the top-left then the bottom-right box",
|
|
25417
25515
|
body: encodeMiroBoardPreview(items2),
|
|
25418
25516
|
prNumber: null,
|
|
@@ -26602,13 +26700,13 @@ function postReviewComment(vars) {
|
|
|
26602
26700
|
}
|
|
26603
26701
|
|
|
26604
26702
|
// src/commands/prs/reviewProposedPrComment.ts
|
|
26605
|
-
import { randomUUID as
|
|
26703
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
26606
26704
|
async function reviewProposedPrComment(title, body, prNumber) {
|
|
26607
26705
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
26608
26706
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
26609
26707
|
await awaitPreviewApproval("PR comment preview", {
|
|
26610
26708
|
sessionId,
|
|
26611
|
-
requestId:
|
|
26709
|
+
requestId: randomUUID14(),
|
|
26612
26710
|
title,
|
|
26613
26711
|
body,
|
|
26614
26712
|
prNumber,
|
|
@@ -27220,7 +27318,7 @@ function registerPrsComments(prsCommand) {
|
|
|
27220
27318
|
}
|
|
27221
27319
|
|
|
27222
27320
|
// src/commands/prs/edit.ts
|
|
27223
|
-
import { randomUUID as
|
|
27321
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
27224
27322
|
|
|
27225
27323
|
// src/commands/prs/applyEdit.ts
|
|
27226
27324
|
import { execFileSync as execFileSync16 } from "child_process";
|
|
@@ -27415,7 +27513,7 @@ async function edit(options2) {
|
|
|
27415
27513
|
if (process.env.ASSIST_SESSION === "1" && sessionId) {
|
|
27416
27514
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
27417
27515
|
sessionId,
|
|
27418
|
-
requestId:
|
|
27516
|
+
requestId: randomUUID15(),
|
|
27419
27517
|
title: options2.title ?? title,
|
|
27420
27518
|
body: newBody,
|
|
27421
27519
|
prNumber: number
|
|
@@ -27614,7 +27712,7 @@ async function placePr(prNumber, title, body, options2) {
|
|
|
27614
27712
|
}
|
|
27615
27713
|
|
|
27616
27714
|
// src/commands/prs/previewAndPlace.ts
|
|
27617
|
-
import { randomUUID as
|
|
27715
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
27618
27716
|
|
|
27619
27717
|
// src/commands/sessions/shared/requestSession.ts
|
|
27620
27718
|
function parseIncoming(line, type) {
|
|
@@ -27765,7 +27863,7 @@ function enableAutoMerge() {
|
|
|
27765
27863
|
async function previewAndPlace(args) {
|
|
27766
27864
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
27767
27865
|
sessionId: args.sessionId,
|
|
27768
|
-
requestId:
|
|
27866
|
+
requestId: randomUUID16(),
|
|
27769
27867
|
title: args.title,
|
|
27770
27868
|
body: args.body,
|
|
27771
27869
|
prNumber: args.prNumber,
|
|
@@ -30115,13 +30213,13 @@ function runScript(script, cwd) {
|
|
|
30115
30213
|
});
|
|
30116
30214
|
});
|
|
30117
30215
|
}
|
|
30118
|
-
function logFailures(
|
|
30119
|
-
for (const f of
|
|
30216
|
+
function logFailures(failed3) {
|
|
30217
|
+
for (const f of failed3) {
|
|
30120
30218
|
console.error(f.output);
|
|
30121
30219
|
}
|
|
30122
30220
|
console.error(`
|
|
30123
|
-
${
|
|
30124
|
-
for (const f of
|
|
30221
|
+
${failed3.length} verify script(s) failed:`);
|
|
30222
|
+
for (const f of failed3) {
|
|
30125
30223
|
console.error(` - ${f.script} (exit code ${f.code})`);
|
|
30126
30224
|
}
|
|
30127
30225
|
}
|
|
@@ -30132,9 +30230,9 @@ async function runVerifyQuietly() {
|
|
|
30132
30230
|
const results = await Promise.all(
|
|
30133
30231
|
result.verifyScripts.map((script) => runScript(script, packageDir))
|
|
30134
30232
|
);
|
|
30135
|
-
const
|
|
30136
|
-
if (
|
|
30137
|
-
logFailures(
|
|
30233
|
+
const failed3 = results.filter((r) => r.code !== 0);
|
|
30234
|
+
if (failed3.length > 0) {
|
|
30235
|
+
logFailures(failed3);
|
|
30138
30236
|
return false;
|
|
30139
30237
|
}
|
|
30140
30238
|
return true;
|
|
@@ -31930,10 +32028,10 @@ function registerRefactor(program2) {
|
|
|
31930
32028
|
}
|
|
31931
32029
|
|
|
31932
32030
|
// src/commands/review/checkoutOnlySession.ts
|
|
31933
|
-
import { randomUUID as
|
|
32031
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
31934
32032
|
async function checkoutOnlySession(number) {
|
|
31935
32033
|
await checkoutPr(number);
|
|
31936
|
-
const claudeSessionId =
|
|
32034
|
+
const claudeSessionId = randomUUID17();
|
|
31937
32035
|
emitActivity({ kind: "command", name: "review", claudeSessionId });
|
|
31938
32036
|
const { done: done2 } = spawnClaude("", {
|
|
31939
32037
|
permissionMode: "acceptEdits",
|
|
@@ -32670,7 +32768,7 @@ function gatherHighLevelSubject(prNumber, force) {
|
|
|
32670
32768
|
}
|
|
32671
32769
|
|
|
32672
32770
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
32673
|
-
import { randomUUID as
|
|
32771
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
32674
32772
|
|
|
32675
32773
|
// src/commands/review/highLevel/buildHighLevelRecord.ts
|
|
32676
32774
|
function toItem2(check2, decision) {
|
|
@@ -32757,7 +32855,7 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
32757
32855
|
"High-level review",
|
|
32758
32856
|
{
|
|
32759
32857
|
sessionId,
|
|
32760
|
-
requestId:
|
|
32858
|
+
requestId: randomUUID18(),
|
|
32761
32859
|
title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
|
|
32762
32860
|
body: JSON.stringify(highLevelPreviewPayload(subject)),
|
|
32763
32861
|
prNumber: subject.prNumber,
|
|
@@ -32829,11 +32927,11 @@ function formatHighLevelChecklist(checks2) {
|
|
|
32829
32927
|
const deterministic = checks2.filter(
|
|
32830
32928
|
(check2) => check2.kind === "deterministic"
|
|
32831
32929
|
);
|
|
32832
|
-
const
|
|
32930
|
+
const failed3 = deterministic.filter(
|
|
32833
32931
|
(check2) => check2.status === "fail"
|
|
32834
32932
|
).length;
|
|
32835
|
-
const summary =
|
|
32836
|
-
`${
|
|
32933
|
+
const summary = failed3 === 0 ? chalk227.green(`All ${deterministic.length} deterministic checks pass`) : chalk227.red(
|
|
32934
|
+
`${failed3} of ${deterministic.length} deterministic checks fail`
|
|
32837
32935
|
);
|
|
32838
32936
|
return [
|
|
32839
32937
|
...formatGroup("Deterministic", deterministic),
|
|
@@ -33365,7 +33463,7 @@ function buildCommentBody(finding) {
|
|
|
33365
33463
|
}
|
|
33366
33464
|
async function postFindings(findings) {
|
|
33367
33465
|
let posted = 0;
|
|
33368
|
-
let
|
|
33466
|
+
let failed3 = 0;
|
|
33369
33467
|
for (const finding of findings) {
|
|
33370
33468
|
const body = buildCommentBody(finding);
|
|
33371
33469
|
try {
|
|
@@ -33375,14 +33473,14 @@ async function postFindings(findings) {
|
|
|
33375
33473
|
});
|
|
33376
33474
|
posted++;
|
|
33377
33475
|
} catch (error) {
|
|
33378
|
-
|
|
33476
|
+
failed3++;
|
|
33379
33477
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
33380
33478
|
console.error(
|
|
33381
33479
|
`Failed to post comment on ${finding.file}:${finding.line}: ${message3}`
|
|
33382
33480
|
);
|
|
33383
33481
|
}
|
|
33384
33482
|
}
|
|
33385
|
-
return { posted, failed:
|
|
33483
|
+
return { posted, failed: failed3 };
|
|
33386
33484
|
}
|
|
33387
33485
|
|
|
33388
33486
|
// src/commands/review/runReviewSubmission.ts
|
|
@@ -35639,7 +35737,7 @@ function readSlackParts(files) {
|
|
|
35639
35737
|
}
|
|
35640
35738
|
|
|
35641
35739
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
35642
|
-
import { randomUUID as
|
|
35740
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
35643
35741
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
35644
35742
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
35645
35743
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
@@ -35649,7 +35747,7 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
35649
35747
|
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
35650
35748
|
{
|
|
35651
35749
|
sessionId,
|
|
35652
|
-
requestId:
|
|
35750
|
+
requestId: randomUUID19(),
|
|
35653
35751
|
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
35654
35752
|
body,
|
|
35655
35753
|
prNumber: null,
|
|
@@ -39287,6 +39385,22 @@ function registerRun(program2) {
|
|
|
39287
39385
|
registerRunSubcommands(runCommand);
|
|
39288
39386
|
}
|
|
39289
39387
|
|
|
39388
|
+
// src/commands/sessions/nodes/formatLink.ts
|
|
39389
|
+
import chalk249 from "chalk";
|
|
39390
|
+
var STATE_COLOURS = {
|
|
39391
|
+
connected: chalk249.green,
|
|
39392
|
+
connecting: chalk249.yellow,
|
|
39393
|
+
disconnected: chalk249.red,
|
|
39394
|
+
"version-blocked": chalk249.red
|
|
39395
|
+
};
|
|
39396
|
+
function formatLink(link3) {
|
|
39397
|
+
const colour = STATE_COLOURS[link3.state] ?? chalk249.white;
|
|
39398
|
+
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
39399
|
+
const error = link3.error ? `
|
|
39400
|
+
${chalk249.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
39401
|
+
return ` ${link3.name} ${colour(link3.state)} direct ${link3.url}${peer}${error}`;
|
|
39402
|
+
}
|
|
39403
|
+
|
|
39290
39404
|
// src/commands/sessions/daemon/listDaemonPids.ts
|
|
39291
39405
|
import { execFileSync as execFileSync24 } from "child_process";
|
|
39292
39406
|
function listDaemonPids() {
|
|
@@ -39302,7 +39416,7 @@ function listDaemonPids() {
|
|
|
39302
39416
|
}
|
|
39303
39417
|
|
|
39304
39418
|
// src/commands/sessions/daemon/queryDaemon.ts
|
|
39305
|
-
import { createInterface as
|
|
39419
|
+
import { createInterface as createInterface8 } from "readline";
|
|
39306
39420
|
var STATUS_TIMEOUT_MS = 5e3;
|
|
39307
39421
|
function queryDaemon(socket) {
|
|
39308
39422
|
socket.write(`${JSON.stringify({ type: "ping" })}
|
|
@@ -39311,7 +39425,7 @@ function queryDaemon(socket) {
|
|
|
39311
39425
|
const result = { sessions: [] };
|
|
39312
39426
|
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
39313
39427
|
const timer = setTimeout(() => resolve25(result), STATUS_TIMEOUT_MS);
|
|
39314
|
-
const lines2 =
|
|
39428
|
+
const lines2 = createInterface8({ input: socket });
|
|
39315
39429
|
lines2.on("error", () => {
|
|
39316
39430
|
});
|
|
39317
39431
|
lines2.on("line", (line) => {
|
|
@@ -39384,14 +39498,18 @@ async function daemonStatus() {
|
|
|
39384
39498
|
console.log(`Sessions daemon is running${pid ? ` (PID ${pid})` : ""}`);
|
|
39385
39499
|
reportStolenSocket(pid);
|
|
39386
39500
|
reportStrays(listDaemonPids().filter((p) => p !== pid));
|
|
39387
|
-
if (sessions.length === 0)
|
|
39388
|
-
console.log("No sessions");
|
|
39389
|
-
return;
|
|
39390
|
-
}
|
|
39501
|
+
if (sessions.length === 0) console.log("No sessions");
|
|
39391
39502
|
for (const session of sessions) {
|
|
39392
39503
|
const restored = session.restored === false ? " (not restored)" : "";
|
|
39393
39504
|
console.log(` [${session.status}] ${session.name}${restored}`);
|
|
39394
39505
|
}
|
|
39506
|
+
await reportLinks();
|
|
39507
|
+
}
|
|
39508
|
+
async function reportLinks() {
|
|
39509
|
+
const links2 = (await queryNodes())?.links ?? [];
|
|
39510
|
+
if (links2.length === 0) return;
|
|
39511
|
+
console.log("Links:");
|
|
39512
|
+
for (const link3 of links2) console.log(formatLink(link3));
|
|
39395
39513
|
}
|
|
39396
39514
|
function reportStrays(pids) {
|
|
39397
39515
|
if (pids.length === 0) return;
|
|
@@ -39401,7 +39519,7 @@ function reportStrays(pids) {
|
|
|
39401
39519
|
}
|
|
39402
39520
|
|
|
39403
39521
|
// src/commands/sessions/daemon/drainDaemon.ts
|
|
39404
|
-
import { createInterface as
|
|
39522
|
+
import { createInterface as createInterface9 } from "readline";
|
|
39405
39523
|
|
|
39406
39524
|
// src/commands/sessions/daemon/clearPersistedSessionsOnDrain.ts
|
|
39407
39525
|
function clearPersistedSessionsOnDrain() {
|
|
@@ -39443,7 +39561,7 @@ async function drainDaemon(options2 = {}) {
|
|
|
39443
39561
|
clearPersistedSessionsOnDrain();
|
|
39444
39562
|
return;
|
|
39445
39563
|
}
|
|
39446
|
-
const lines2 =
|
|
39564
|
+
const lines2 = createInterface9({ input: socket });
|
|
39447
39565
|
lines2.on("error", () => {
|
|
39448
39566
|
});
|
|
39449
39567
|
const live = await liveSessions(lines2);
|
|
@@ -39791,7 +39909,7 @@ var ClientHub = class extends Set {
|
|
|
39791
39909
|
};
|
|
39792
39910
|
|
|
39793
39911
|
// src/commands/sessions/daemon/createSession.ts
|
|
39794
|
-
import { randomUUID as
|
|
39912
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
39795
39913
|
|
|
39796
39914
|
// src/commands/sessions/daemon/sessionBase.ts
|
|
39797
39915
|
function sessionBase(id, status3) {
|
|
@@ -39997,7 +40115,7 @@ function spawnRun(opts) {
|
|
|
39997
40115
|
function createSession(id, { prompt, cwd, design, auto, harness, holdPty } = {}) {
|
|
39998
40116
|
if (harness && harness !== "claude")
|
|
39999
40117
|
return createHarnessSession(id, harness, prompt, cwd, holdPty);
|
|
40000
|
-
const claudeSessionId =
|
|
40118
|
+
const claudeSessionId = randomUUID20();
|
|
40001
40119
|
return {
|
|
40002
40120
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
40003
40121
|
name: `Session ${id}`,
|
|
@@ -40920,8 +41038,8 @@ function handleErroredExit(session, exitCode, priorStatus, onStatusChange) {
|
|
|
40920
41038
|
|
|
40921
41039
|
// src/commands/sessions/daemon/handleFailedResume.ts
|
|
40922
41040
|
function handleFailedResume(session, exitCode, onStatusChange) {
|
|
40923
|
-
const
|
|
40924
|
-
if (!
|
|
41041
|
+
const failed3 = session.restored === true && exitCode !== 0 && session.scrollback.length === 0;
|
|
41042
|
+
if (!failed3) return false;
|
|
40925
41043
|
session.error = `resume process exited with code ${exitCode} before producing any output`;
|
|
40926
41044
|
daemonLog(
|
|
40927
41045
|
`could not resume restored session "${session.name}" (id ${session.id}): ${session.error}`
|
|
@@ -42168,7 +42286,7 @@ function codexRespawnPlan(session) {
|
|
|
42168
42286
|
}
|
|
42169
42287
|
|
|
42170
42288
|
// src/commands/sessions/daemon/interactiveRespawnPlan.ts
|
|
42171
|
-
import { randomUUID as
|
|
42289
|
+
import { randomUUID as randomUUID21 } from "crypto";
|
|
42172
42290
|
function interactiveRespawnPlan(session, resumes) {
|
|
42173
42291
|
const { claudeSessionId, cwd, initialPrompt, design, auto } = session;
|
|
42174
42292
|
if (!resumes) return null;
|
|
@@ -42188,7 +42306,7 @@ function interactiveRespawnPlan(session, resumes) {
|
|
|
42188
42306
|
return null;
|
|
42189
42307
|
}
|
|
42190
42308
|
function freshClaudePlan(session, prompt, cwd) {
|
|
42191
|
-
const claudeSessionId =
|
|
42309
|
+
const claudeSessionId = randomUUID21();
|
|
42192
42310
|
return {
|
|
42193
42311
|
spawn: () => {
|
|
42194
42312
|
session.claudeSessionId = claudeSessionId;
|
|
@@ -43197,10 +43315,10 @@ function startReusedRunPty(session, assistArgs, itemId2, hold, clients, onStatus
|
|
|
43197
43315
|
}
|
|
43198
43316
|
|
|
43199
43317
|
// src/commands/sessions/daemon/createWatcherSession.ts
|
|
43200
|
-
import { randomUUID as
|
|
43318
|
+
import { randomUUID as randomUUID22 } from "crypto";
|
|
43201
43319
|
var WATCH_PROMPT = "/watch";
|
|
43202
43320
|
function createWatcherSession(id, cwd) {
|
|
43203
|
-
const claudeSessionId =
|
|
43321
|
+
const claudeSessionId = randomUUID22();
|
|
43204
43322
|
return {
|
|
43205
43323
|
...sessionBase(id, "running"),
|
|
43206
43324
|
name: `Session ${id}`,
|
|
@@ -43773,11 +43891,12 @@ function forwardLinkCreate(ctx, client, data) {
|
|
|
43773
43891
|
});
|
|
43774
43892
|
return;
|
|
43775
43893
|
}
|
|
43894
|
+
const traceId = newTraceId();
|
|
43776
43895
|
daemonLog(
|
|
43777
|
-
`link ${node} ws: routing ${data.type} (cwd=${data.cwd ?? "default"})`
|
|
43896
|
+
`link ${node} ws: routing ${data.type} (cwd=${data.cwd ?? "default"}) trace=${traceId}`
|
|
43778
43897
|
);
|
|
43779
43898
|
armCreateTimeout(ctx, client, data);
|
|
43780
|
-
sendToLink(ctx, toPeerMessage(data));
|
|
43899
|
+
sendToLink(ctx, { ...toPeerMessage(data), traceId });
|
|
43781
43900
|
}
|
|
43782
43901
|
|
|
43783
43902
|
// src/commands/sessions/daemon/links/forwardToLink.ts
|
|
@@ -44657,7 +44776,7 @@ function exitAfterFlush(code) {
|
|
|
44657
44776
|
}
|
|
44658
44777
|
|
|
44659
44778
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
44660
|
-
import { createInterface as
|
|
44779
|
+
import { createInterface as createInterface10 } from "readline";
|
|
44661
44780
|
|
|
44662
44781
|
// src/commands/sessions/daemon/handleHelloRequest.ts
|
|
44663
44782
|
var handleHelloRequest = (client, m, d) => {
|
|
@@ -45184,6 +45303,10 @@ var messageHandlers = {
|
|
|
45184
45303
|
|
|
45185
45304
|
// src/commands/sessions/daemon/dispatchMessage.ts
|
|
45186
45305
|
function dispatchMessage(client, manager, data) {
|
|
45306
|
+
if (typeof data.traceId === "string")
|
|
45307
|
+
daemonLog(
|
|
45308
|
+
`linked ${data.type} received (cwd=${data.cwd ?? "default"}) trace=${data.traceId}`
|
|
45309
|
+
);
|
|
45187
45310
|
messageHandlers[data.type]?.(client, manager, data);
|
|
45188
45311
|
}
|
|
45189
45312
|
|
|
@@ -45197,7 +45320,7 @@ function handleConnection(socket, manager) {
|
|
|
45197
45320
|
};
|
|
45198
45321
|
manager.addClient(client);
|
|
45199
45322
|
manager.clients.greet(client);
|
|
45200
|
-
const lines2 =
|
|
45323
|
+
const lines2 = createInterface10({ input: socket });
|
|
45201
45324
|
lines2.on("error", () => {
|
|
45202
45325
|
});
|
|
45203
45326
|
lines2.on("line", (line) => {
|
|
@@ -45388,8 +45511,263 @@ async function closeSession() {
|
|
|
45388
45511
|
}
|
|
45389
45512
|
}
|
|
45390
45513
|
|
|
45514
|
+
// src/commands/sessions/nodes/DoctorProbes.ts
|
|
45515
|
+
function passed(hop, detail) {
|
|
45516
|
+
return { hop, ok: true, detail };
|
|
45517
|
+
}
|
|
45518
|
+
function failed2(hop, error, remediation) {
|
|
45519
|
+
return { hop, ok: false, error, remediation };
|
|
45520
|
+
}
|
|
45521
|
+
|
|
45522
|
+
// src/commands/sessions/nodes/fetchPeerJson.ts
|
|
45523
|
+
var PEER_TIMEOUT_MS = 3e3;
|
|
45524
|
+
function peerErrorCode(error) {
|
|
45525
|
+
if (!(error instanceof Error)) return void 0;
|
|
45526
|
+
const { code, cause } = error;
|
|
45527
|
+
if (code) return code;
|
|
45528
|
+
if (error.name === "TimeoutError") return "ETIMEDOUT";
|
|
45529
|
+
return cause instanceof Error ? peerErrorCode(cause) : void 0;
|
|
45530
|
+
}
|
|
45531
|
+
function describePeerError(error) {
|
|
45532
|
+
if (!(error instanceof Error)) return String(error);
|
|
45533
|
+
const cause = error.cause;
|
|
45534
|
+
return cause instanceof Error ? `${error.message}: ${describePeerError(cause)}` : error.message;
|
|
45535
|
+
}
|
|
45536
|
+
async function fetchPeerJson(baseUrl, path103, timeoutMs = PEER_TIMEOUT_MS) {
|
|
45537
|
+
const res = await fetch(new URL(path103, baseUrl), {
|
|
45538
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
45539
|
+
});
|
|
45540
|
+
if (!res.ok)
|
|
45541
|
+
throw Object.assign(
|
|
45542
|
+
new Error(`GET ${path103} returned ${res.status} ${res.statusText}`),
|
|
45543
|
+
{ status: res.status }
|
|
45544
|
+
);
|
|
45545
|
+
return await res.json();
|
|
45546
|
+
}
|
|
45547
|
+
|
|
45548
|
+
// src/commands/sessions/nodes/helloHop.ts
|
|
45549
|
+
async function helloHop(spec, probes) {
|
|
45550
|
+
let msg;
|
|
45551
|
+
try {
|
|
45552
|
+
msg = await probes.hello(spec.url);
|
|
45553
|
+
} catch (error) {
|
|
45554
|
+
return failed2(
|
|
45555
|
+
"ws",
|
|
45556
|
+
describePeerError(error),
|
|
45557
|
+
`${spec.name}'s /api/health answers but its /ws does not \u2014 restart the web server on ${spec.name}, then check \`assist sessions nodes logs ${spec.name}\``
|
|
45558
|
+
);
|
|
45559
|
+
}
|
|
45560
|
+
if (!isHello(msg))
|
|
45561
|
+
return failed2(
|
|
45562
|
+
"ws",
|
|
45563
|
+
`malformed hello: ${JSON.stringify(msg)}`,
|
|
45564
|
+
`run \`assist update\` on ${spec.name}`
|
|
45565
|
+
);
|
|
45566
|
+
const detail = `hello ${msg.version} (protocol ${msg.protocol ?? "legacy"})`;
|
|
45567
|
+
if (helloCompatible(msg)) return passed("ws", detail);
|
|
45568
|
+
const mismatch = `${helloMismatchKind(msg)} mismatch: peer ${msg.version} (protocol ${msg.protocol ?? "legacy"}), this node ${ASSIST_VERSION} (protocol ${PROTOCOL_VERSION})`;
|
|
45569
|
+
const mode = linkVersionCheck();
|
|
45570
|
+
if (mode !== "block")
|
|
45571
|
+
return passed(
|
|
45572
|
+
"ws",
|
|
45573
|
+
`${mismatch}; allowed by sessions.linkVersionCheck=${mode}`
|
|
45574
|
+
);
|
|
45575
|
+
return failed2(
|
|
45576
|
+
"ws",
|
|
45577
|
+
mismatch,
|
|
45578
|
+
`this node heals an older peer via its /api/self-update on connect; if the heal latched, run \`assist update\` on the older node, then \`assist daemon restart\` here`
|
|
45579
|
+
);
|
|
45580
|
+
}
|
|
45581
|
+
|
|
45582
|
+
// src/commands/sessions/nodes/linkStateHop.ts
|
|
45583
|
+
function linkStateHop(spec, probes) {
|
|
45584
|
+
const status3 = probes.linkState(spec.name);
|
|
45585
|
+
if (status3 === "no-daemon")
|
|
45586
|
+
return failed2(
|
|
45587
|
+
"link",
|
|
45588
|
+
"this node's daemon is not running",
|
|
45589
|
+
"links run in the daemon \u2014 start this node's web server or run `assist daemon restart`"
|
|
45590
|
+
);
|
|
45591
|
+
if (status3 === "unknown-link")
|
|
45592
|
+
return failed2(
|
|
45593
|
+
"link",
|
|
45594
|
+
`this node's daemon has no link named ${spec.name}`,
|
|
45595
|
+
"the daemon has not loaded sessions.links \u2014 run `assist daemon restart`"
|
|
45596
|
+
);
|
|
45597
|
+
if (status3.state === "connected") return passed("link", "connected");
|
|
45598
|
+
const error = status3.error ?? status3.state;
|
|
45599
|
+
if (status3.state === "version-blocked")
|
|
45600
|
+
return failed2("link", error, `version mismatch \u2014 heal latched. ${error}`);
|
|
45601
|
+
return failed2(
|
|
45602
|
+
"link",
|
|
45603
|
+
error,
|
|
45604
|
+
`every probe passed but the daemon's link is ${status3.state}; it retries behind the circuit breaker \u2014 check this node's daemon.log for \`link ${spec.name} ws:\` lines`
|
|
45605
|
+
);
|
|
45606
|
+
}
|
|
45607
|
+
|
|
45608
|
+
// src/commands/sessions/nodes/webHop.ts
|
|
45609
|
+
function webRemediation(spec, error) {
|
|
45610
|
+
const { hostname: hostname2, port } = new URL(spec.url);
|
|
45611
|
+
switch (peerErrorCode(error)) {
|
|
45612
|
+
case "ECONNREFUSED":
|
|
45613
|
+
return `nothing listening on ${port} on ${hostname2} \u2014 is ${spec.name}'s web server running (project-switch webservers)?`;
|
|
45614
|
+
case "ETIMEDOUT":
|
|
45615
|
+
return `${hostname2}:${port} did not answer \u2014 is ${spec.name} up and the port reachable from here?`;
|
|
45616
|
+
case "ENOTFOUND":
|
|
45617
|
+
return `cannot resolve ${hostname2} \u2014 fix the url with \`assist sessions nodes link ${spec.name} <url>\``;
|
|
45618
|
+
}
|
|
45619
|
+
if (error.status === 404)
|
|
45620
|
+
return `${spec.name}'s web server has no /api/health \u2014 run \`assist update\` on ${spec.name}`;
|
|
45621
|
+
return `check the link url ${spec.url} with \`assist sessions nodes\``;
|
|
45622
|
+
}
|
|
45623
|
+
async function webHop(spec, probes) {
|
|
45624
|
+
let health2;
|
|
45625
|
+
try {
|
|
45626
|
+
health2 = await probes.health(spec.url);
|
|
45627
|
+
} catch (error) {
|
|
45628
|
+
return {
|
|
45629
|
+
hop: failed2("web", describePeerError(error), webRemediation(spec, error))
|
|
45630
|
+
};
|
|
45631
|
+
}
|
|
45632
|
+
if (health2.nodeName !== spec.name)
|
|
45633
|
+
return {
|
|
45634
|
+
hop: failed2(
|
|
45635
|
+
"web",
|
|
45636
|
+
`peer reports nodeName ${health2.nodeName}, link expects ${spec.name}`,
|
|
45637
|
+
`relink with \`assist sessions nodes unlink ${spec.name}\` then \`assist sessions nodes link ${health2.nodeName} ${spec.url}\`, or set sessions.nodeName on the peer`
|
|
45638
|
+
)
|
|
45639
|
+
};
|
|
45640
|
+
return {
|
|
45641
|
+
hop: passed(
|
|
45642
|
+
"web",
|
|
45643
|
+
`${health2.nodeName} ${health2.version} (protocol ${health2.protocol})`
|
|
45644
|
+
),
|
|
45645
|
+
health: health2
|
|
45646
|
+
};
|
|
45647
|
+
}
|
|
45648
|
+
|
|
45649
|
+
// src/commands/sessions/nodes/diagnoseLink.ts
|
|
45650
|
+
function peerDaemonHop(spec, health2) {
|
|
45651
|
+
if (health2.daemon?.reachable) return passed("daemon", "reachable");
|
|
45652
|
+
return failed2(
|
|
45653
|
+
"daemon",
|
|
45654
|
+
`${spec.name}'s web server reports its daemon unreachable`,
|
|
45655
|
+
`run \`assist daemon status\` on ${spec.name}; restarting its web server starts the daemon`
|
|
45656
|
+
);
|
|
45657
|
+
}
|
|
45658
|
+
async function diagnoseLink(spec, probes) {
|
|
45659
|
+
const hops = [];
|
|
45660
|
+
const done2 = () => ({ ...spec, ok: hops.every((h) => h.ok), hops });
|
|
45661
|
+
const web3 = await webHop(spec, probes);
|
|
45662
|
+
hops.push(web3.hop);
|
|
45663
|
+
if (!web3.health) return done2();
|
|
45664
|
+
hops.push(peerDaemonHop(spec, web3.health));
|
|
45665
|
+
if (!hops.at(-1)?.ok) return done2();
|
|
45666
|
+
hops.push(await helloHop(spec, probes));
|
|
45667
|
+
if (!hops.at(-1)?.ok) return done2();
|
|
45668
|
+
hops.push(linkStateHop(spec, probes));
|
|
45669
|
+
return done2();
|
|
45670
|
+
}
|
|
45671
|
+
|
|
45672
|
+
// src/commands/sessions/nodes/findUnlinkedWindowsNode.ts
|
|
45673
|
+
var WINDOWS_NODE_URL = "http://127.0.0.1:3101";
|
|
45674
|
+
async function findUnlinkedWindowsNode(health2, platform = detectPlatform()) {
|
|
45675
|
+
if (platform !== "wsl") return void 0;
|
|
45676
|
+
try {
|
|
45677
|
+
const { nodeName } = await health2(WINDOWS_NODE_URL);
|
|
45678
|
+
if (!nodeName) return void 0;
|
|
45679
|
+
return {
|
|
45680
|
+
nodeName,
|
|
45681
|
+
url: WINDOWS_NODE_URL,
|
|
45682
|
+
command: `assist sessions nodes link ${nodeName} ${WINDOWS_NODE_URL}`
|
|
45683
|
+
};
|
|
45684
|
+
} catch {
|
|
45685
|
+
return void 0;
|
|
45686
|
+
}
|
|
45687
|
+
}
|
|
45688
|
+
|
|
45689
|
+
// src/commands/sessions/nodes/probePeerHello.ts
|
|
45690
|
+
var HELLO_TIMEOUT_MS = 5e3;
|
|
45691
|
+
async function probePeerHello(url) {
|
|
45692
|
+
let settle = () => {
|
|
45693
|
+
};
|
|
45694
|
+
const reply2 = new Promise((resolve25) => {
|
|
45695
|
+
settle = resolve25;
|
|
45696
|
+
});
|
|
45697
|
+
const socket = await connectLinkWebSocket(url, {
|
|
45698
|
+
onLine: (line) => {
|
|
45699
|
+
try {
|
|
45700
|
+
const msg = JSON.parse(line);
|
|
45701
|
+
if (msg.type === "hello") settle(msg);
|
|
45702
|
+
} catch {
|
|
45703
|
+
}
|
|
45704
|
+
},
|
|
45705
|
+
onClose: (reason4) => settle(new Error(`closed before hello reply (${reason4})`))
|
|
45706
|
+
});
|
|
45707
|
+
const timer = setTimeout(
|
|
45708
|
+
() => settle(new Error(`no hello reply within ${HELLO_TIMEOUT_MS / 1e3}s`)),
|
|
45709
|
+
HELLO_TIMEOUT_MS
|
|
45710
|
+
);
|
|
45711
|
+
socket.send(JSON.stringify(buildHello()));
|
|
45712
|
+
const result = await reply2;
|
|
45713
|
+
clearTimeout(timer);
|
|
45714
|
+
socket.close();
|
|
45715
|
+
if (result instanceof Error) throw result;
|
|
45716
|
+
return result;
|
|
45717
|
+
}
|
|
45718
|
+
|
|
45719
|
+
// src/commands/sessions/nodes/printReport.ts
|
|
45720
|
+
import chalk250 from "chalk";
|
|
45721
|
+
function printReport(report2) {
|
|
45722
|
+
if (report2.links.length === 0) {
|
|
45723
|
+
console.log(`${report2.local} has no links`);
|
|
45724
|
+
if (report2.suggestion)
|
|
45725
|
+
console.log(
|
|
45726
|
+
`A Windows node (${report2.suggestion.nodeName}) answers on ${report2.suggestion.url} but is not linked. Link it with:
|
|
45727
|
+
${report2.suggestion.command}`
|
|
45728
|
+
);
|
|
45729
|
+
return;
|
|
45730
|
+
}
|
|
45731
|
+
for (const diagnosis of report2.links) printDiagnosis(diagnosis);
|
|
45732
|
+
}
|
|
45733
|
+
function printDiagnosis(diagnosis) {
|
|
45734
|
+
console.log(`${chalk250.bold(diagnosis.name)} ${chalk250.dim(diagnosis.url)}`);
|
|
45735
|
+
for (const hop of diagnosis.hops) {
|
|
45736
|
+
const mark = hop.ok ? chalk250.green("\u2713") : chalk250.red("\u2717");
|
|
45737
|
+
console.log(` ${mark} ${hop.hop.padEnd(6)} ${hop.detail ?? hop.error}`);
|
|
45738
|
+
if (hop.remediation) console.log(` ${chalk250.yellow(hop.remediation)}`);
|
|
45739
|
+
}
|
|
45740
|
+
}
|
|
45741
|
+
|
|
45742
|
+
// src/commands/sessions/nodes/doctorNodes.ts
|
|
45743
|
+
function doctorProbes(live) {
|
|
45744
|
+
return {
|
|
45745
|
+
health: (url) => fetchPeerJson(url, "/api/health"),
|
|
45746
|
+
hello: probePeerHello,
|
|
45747
|
+
linkState: (name) => {
|
|
45748
|
+
if (!live) return "no-daemon";
|
|
45749
|
+
return live.links.find((l) => l.name === name) ?? "unknown-link";
|
|
45750
|
+
}
|
|
45751
|
+
};
|
|
45752
|
+
}
|
|
45753
|
+
async function doctorNodes(name, options2) {
|
|
45754
|
+
const specs = (loadConfig().sessions?.links ?? []).filter(
|
|
45755
|
+
(spec) => !name || spec.name === name
|
|
45756
|
+
);
|
|
45757
|
+
if (name && specs.length === 0)
|
|
45758
|
+
throw new Error(`No link named ${name}; see assist sessions nodes`);
|
|
45759
|
+
const probes = doctorProbes(await queryNodes());
|
|
45760
|
+
const report2 = { local: resolveNodeName(), links: [] };
|
|
45761
|
+
for (const spec of specs) report2.links.push(await diagnoseLink(spec, probes));
|
|
45762
|
+
if (specs.length === 0)
|
|
45763
|
+
report2.suggestion = await findUnlinkedWindowsNode(probes.health);
|
|
45764
|
+
if (report2.links.some((l) => !l.ok)) process.exitCode = 1;
|
|
45765
|
+
if (options2.json) console.log(JSON.stringify(report2, null, 2));
|
|
45766
|
+
else printReport(report2);
|
|
45767
|
+
}
|
|
45768
|
+
|
|
45391
45769
|
// src/commands/sessions/nodes/linkNode.ts
|
|
45392
|
-
import
|
|
45770
|
+
import chalk251 from "chalk";
|
|
45393
45771
|
|
|
45394
45772
|
// src/commands/sessions/nodes/writeLinks.ts
|
|
45395
45773
|
function readLinks() {
|
|
@@ -45421,46 +45799,11 @@ async function linkNode(name, url) {
|
|
|
45421
45799
|
throw new Error(`${name} is this node; link to a different node`);
|
|
45422
45800
|
const others = readLinks().filter((link3) => link3.name !== name);
|
|
45423
45801
|
await writeLinks([...others, { name, url: parseLinkUrl(url) }]);
|
|
45424
|
-
console.log(
|
|
45425
|
-
}
|
|
45426
|
-
|
|
45427
|
-
// src/commands/sessions/nodes/listNodes.ts
|
|
45428
|
-
import chalk250 from "chalk";
|
|
45429
|
-
|
|
45430
|
-
// src/commands/sessions/nodes/queryNodes.ts
|
|
45431
|
-
import { createInterface as createInterface10 } from "readline";
|
|
45432
|
-
var QUERY_TIMEOUT_MS = 3e3;
|
|
45433
|
-
async function queryNodes() {
|
|
45434
|
-
let socket;
|
|
45435
|
-
try {
|
|
45436
|
-
socket = await connectToDaemon();
|
|
45437
|
-
} catch {
|
|
45438
|
-
return void 0;
|
|
45439
|
-
}
|
|
45440
|
-
return new Promise((resolve25) => {
|
|
45441
|
-
const finish2 = (result) => {
|
|
45442
|
-
clearTimeout(timer);
|
|
45443
|
-
socket.destroy();
|
|
45444
|
-
resolve25(result);
|
|
45445
|
-
};
|
|
45446
|
-
const timer = setTimeout(() => finish2(void 0), QUERY_TIMEOUT_MS);
|
|
45447
|
-
const lines2 = createInterface10({ input: socket });
|
|
45448
|
-
lines2.on("error", () => {
|
|
45449
|
-
});
|
|
45450
|
-
lines2.on("line", (line) => {
|
|
45451
|
-
try {
|
|
45452
|
-
const data = JSON.parse(line);
|
|
45453
|
-
if (data.type === "nodes") finish2(data);
|
|
45454
|
-
} catch {
|
|
45455
|
-
}
|
|
45456
|
-
});
|
|
45457
|
-
socket.on("error", () => finish2(void 0));
|
|
45458
|
-
socket.write(`${JSON.stringify({ type: "nodes" })}
|
|
45459
|
-
`);
|
|
45460
|
-
});
|
|
45802
|
+
console.log(chalk251.green(`Linked ${name} (${parseLinkUrl(url)})`));
|
|
45461
45803
|
}
|
|
45462
45804
|
|
|
45463
45805
|
// src/commands/sessions/nodes/listNodes.ts
|
|
45806
|
+
import chalk252 from "chalk";
|
|
45464
45807
|
async function nodesReport() {
|
|
45465
45808
|
const live = await queryNodes();
|
|
45466
45809
|
if (live)
|
|
@@ -45472,43 +45815,64 @@ async function nodesReport() {
|
|
|
45472
45815
|
links: configured.map((link3) => ({ ...link3, state: "disconnected" }))
|
|
45473
45816
|
};
|
|
45474
45817
|
}
|
|
45475
|
-
var STATE_COLOURS = {
|
|
45476
|
-
connected: chalk250.green,
|
|
45477
|
-
connecting: chalk250.yellow,
|
|
45478
|
-
disconnected: chalk250.red,
|
|
45479
|
-
"version-blocked": chalk250.red
|
|
45480
|
-
};
|
|
45481
|
-
function formatLink(link3) {
|
|
45482
|
-
const colour = STATE_COLOURS[link3.state] ?? chalk250.white;
|
|
45483
|
-
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
45484
|
-
const error = link3.error ? `
|
|
45485
|
-
${chalk250.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
45486
|
-
return ` ${link3.name} ${colour(link3.state)} direct ${link3.url}${peer}${error}`;
|
|
45487
|
-
}
|
|
45488
45818
|
async function listNodes(options2) {
|
|
45489
45819
|
const report2 = await nodesReport();
|
|
45490
45820
|
if (options2.json) {
|
|
45491
45821
|
console.log(JSON.stringify(report2, null, 2));
|
|
45492
45822
|
return;
|
|
45493
45823
|
}
|
|
45494
|
-
console.log(`${report2.local} ${
|
|
45824
|
+
console.log(`${report2.local} ${chalk252.dim("(this node)")}`);
|
|
45495
45825
|
if (!report2.daemonRunning)
|
|
45496
|
-
console.log(
|
|
45497
|
-
if (report2.links.length === 0) console.log(
|
|
45826
|
+
console.log(chalk252.dim(" daemon not running; showing configured links"));
|
|
45827
|
+
if (report2.links.length === 0) console.log(chalk252.dim(" no links"));
|
|
45498
45828
|
for (const link3 of report2.links) console.log(formatLink(link3));
|
|
45499
45829
|
}
|
|
45500
45830
|
|
|
45831
|
+
// src/commands/sessions/nodes/nodeLogs.ts
|
|
45832
|
+
async function fetchLogTail(name, lines2) {
|
|
45833
|
+
if (name === resolveNodeName())
|
|
45834
|
+
return {
|
|
45835
|
+
nodeName: name,
|
|
45836
|
+
path: daemonPaths.log,
|
|
45837
|
+
lines: readLogTail(daemonPaths.log, lines2)
|
|
45838
|
+
};
|
|
45839
|
+
const link3 = loadConfig().sessions?.links?.find((l) => l.name === name);
|
|
45840
|
+
if (!link3)
|
|
45841
|
+
throw new Error(`No link named ${name}; see assist sessions nodes`);
|
|
45842
|
+
try {
|
|
45843
|
+
return await fetchPeerJson(
|
|
45844
|
+
link3.url,
|
|
45845
|
+
`/api/daemon-log?lines=${lines2}`
|
|
45846
|
+
);
|
|
45847
|
+
} catch (error) {
|
|
45848
|
+
throw new Error(
|
|
45849
|
+
`Could not read ${name}'s daemon log: ${describePeerError(error)}. Run assist sessions nodes doctor ${name}`
|
|
45850
|
+
);
|
|
45851
|
+
}
|
|
45852
|
+
}
|
|
45853
|
+
async function nodeLogs(name, options2) {
|
|
45854
|
+
const lines2 = Number.parseInt(options2.lines, 10);
|
|
45855
|
+
if (!Number.isInteger(lines2) || lines2 < 1)
|
|
45856
|
+
throw new Error(`-n must be a positive integer, got ${options2.lines}`);
|
|
45857
|
+
const tail = await fetchLogTail(name, lines2);
|
|
45858
|
+
if (options2.json) {
|
|
45859
|
+
console.log(JSON.stringify(tail, null, 2));
|
|
45860
|
+
return;
|
|
45861
|
+
}
|
|
45862
|
+
for (const line of tail.lines) console.log(line);
|
|
45863
|
+
}
|
|
45864
|
+
|
|
45501
45865
|
// src/commands/sessions/nodes/unlinkNode.ts
|
|
45502
|
-
import
|
|
45866
|
+
import chalk253 from "chalk";
|
|
45503
45867
|
async function unlinkNode(name) {
|
|
45504
45868
|
const links2 = readLinks();
|
|
45505
45869
|
const remaining = links2.filter((link3) => link3.name !== name);
|
|
45506
45870
|
if (remaining.length === links2.length) {
|
|
45507
|
-
console.log(
|
|
45871
|
+
console.log(chalk253.yellow(`No link named ${name}`));
|
|
45508
45872
|
return;
|
|
45509
45873
|
}
|
|
45510
45874
|
await writeLinks(remaining);
|
|
45511
|
-
console.log(
|
|
45875
|
+
console.log(chalk253.green(`Unlinked ${name}`));
|
|
45512
45876
|
}
|
|
45513
45877
|
|
|
45514
45878
|
// src/commands/sessions/nodes/registerNodes.ts
|
|
@@ -45518,6 +45882,14 @@ function registerNodes(sessions) {
|
|
|
45518
45882
|
"Link a peer node by its web server URL (name must match the peer's sessions.nodeName)"
|
|
45519
45883
|
).action(linkNode);
|
|
45520
45884
|
cmd.command("unlink <name>").description("Remove a linked node").action(unlinkNode);
|
|
45885
|
+
cmd.command("doctor [name]").description(
|
|
45886
|
+
"Probe each hop of every link (or one) in order and stop at the first failure with a remediation"
|
|
45887
|
+
).option("--json", "Output as JSON").action(
|
|
45888
|
+
(name, _options, command) => doctorNodes(name, command.optsWithGlobals())
|
|
45889
|
+
);
|
|
45890
|
+
cmd.command("logs <name>").description("Tail a linked node's daemon.log through its web server").option("-n, --lines <lines>", "Number of lines", "200").option("--json", "Output as JSON").action(
|
|
45891
|
+
(name, _options, command) => nodeLogs(name, command.optsWithGlobals())
|
|
45892
|
+
);
|
|
45521
45893
|
configHelp(cmd, nodesConfigHelp);
|
|
45522
45894
|
}
|
|
45523
45895
|
|
|
@@ -45554,7 +45926,7 @@ async function renameSession(title) {
|
|
|
45554
45926
|
|
|
45555
45927
|
// src/commands/sessions/summarise.ts
|
|
45556
45928
|
import * as fs58 from "fs";
|
|
45557
|
-
import
|
|
45929
|
+
import chalk254 from "chalk";
|
|
45558
45930
|
|
|
45559
45931
|
// src/commands/sessions/summarise/shared.ts
|
|
45560
45932
|
import * as fs57 from "fs";
|
|
@@ -45613,22 +45985,22 @@ ${firstMessage}`);
|
|
|
45613
45985
|
async function summarise2(options2) {
|
|
45614
45986
|
const files = await discoverSessionFiles();
|
|
45615
45987
|
if (files.length === 0) {
|
|
45616
|
-
console.log(
|
|
45988
|
+
console.log(chalk254.yellow("No sessions found."));
|
|
45617
45989
|
return;
|
|
45618
45990
|
}
|
|
45619
45991
|
const toProcess = selectCandidates(files, options2);
|
|
45620
45992
|
if (toProcess.length === 0) {
|
|
45621
|
-
console.log(
|
|
45993
|
+
console.log(chalk254.green("All sessions already summarised."));
|
|
45622
45994
|
return;
|
|
45623
45995
|
}
|
|
45624
45996
|
console.log(
|
|
45625
|
-
|
|
45997
|
+
chalk254.cyan(
|
|
45626
45998
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
45627
45999
|
)
|
|
45628
46000
|
);
|
|
45629
|
-
const { succeeded, failed:
|
|
46001
|
+
const { succeeded, failed: failed3 } = processSessions(toProcess);
|
|
45630
46002
|
console.log(
|
|
45631
|
-
|
|
46003
|
+
chalk254.green(`Done: ${succeeded} summarised`) + (failed3 > 0 ? chalk254.yellow(`, ${failed3} skipped`) : "")
|
|
45632
46004
|
);
|
|
45633
46005
|
}
|
|
45634
46006
|
function selectCandidates(files, options2) {
|
|
@@ -45645,23 +46017,23 @@ function selectCandidates(files, options2) {
|
|
|
45645
46017
|
}
|
|
45646
46018
|
function processSessions(files) {
|
|
45647
46019
|
let succeeded = 0;
|
|
45648
|
-
let
|
|
46020
|
+
let failed3 = 0;
|
|
45649
46021
|
for (let i = 0; i < files.length; i++) {
|
|
45650
46022
|
const file = files[i];
|
|
45651
|
-
process.stdout.write(
|
|
46023
|
+
process.stdout.write(chalk254.dim(` [${i + 1}/${files.length}] `));
|
|
45652
46024
|
const summary = summariseSession(file);
|
|
45653
46025
|
if (summary) {
|
|
45654
46026
|
writeSummary(file, summary);
|
|
45655
46027
|
succeeded++;
|
|
45656
|
-
process.stdout.write(`${
|
|
46028
|
+
process.stdout.write(`${chalk254.green("\u2713")} ${summary}
|
|
45657
46029
|
`);
|
|
45658
46030
|
} else {
|
|
45659
|
-
|
|
45660
|
-
process.stdout.write(` ${
|
|
46031
|
+
failed3++;
|
|
46032
|
+
process.stdout.write(` ${chalk254.yellow("skip")}
|
|
45661
46033
|
`);
|
|
45662
46034
|
}
|
|
45663
46035
|
}
|
|
45664
|
-
return { succeeded, failed:
|
|
46036
|
+
return { succeeded, failed: failed3 };
|
|
45665
46037
|
}
|
|
45666
46038
|
|
|
45667
46039
|
// src/commands/sessions/registerSessions.ts
|
|
@@ -45685,10 +46057,10 @@ function registerSessions(program2) {
|
|
|
45685
46057
|
}
|
|
45686
46058
|
|
|
45687
46059
|
// src/reportCliError.ts
|
|
45688
|
-
import
|
|
46060
|
+
import chalk255 from "chalk";
|
|
45689
46061
|
function reportCliError(error) {
|
|
45690
46062
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
45691
|
-
console.error(
|
|
46063
|
+
console.error(chalk255.red(error.message));
|
|
45692
46064
|
} else {
|
|
45693
46065
|
console.error(error);
|
|
45694
46066
|
}
|