@staff0rd/assist 0.708.2 → 0.710.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/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 +553 -163
- 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.0",
|
|
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,7 +660,8 @@ var assistConfigShape = {
|
|
|
660
660
|
verify: z3.string().optional()
|
|
661
661
|
}).optional(),
|
|
662
662
|
backlog: z3.strictObject({
|
|
663
|
-
previewComments: z3.boolean().default(false)
|
|
663
|
+
previewComments: z3.boolean().default(false),
|
|
664
|
+
crossRepo: z3.boolean().default(false)
|
|
664
665
|
}).optional(),
|
|
665
666
|
backup: z3.strictObject({
|
|
666
667
|
dir: z3.string().default(DEFAULT_BACKUP_DIR)
|
|
@@ -2087,10 +2088,10 @@ function flushIfFailed(exitCode, chunks) {
|
|
|
2087
2088
|
}
|
|
2088
2089
|
|
|
2089
2090
|
// src/commands/verify/run/runAllEntries.ts
|
|
2090
|
-
function logFailedScripts(
|
|
2091
|
+
function logFailedScripts(failed3) {
|
|
2091
2092
|
console.error(`
|
|
2092
|
-
${
|
|
2093
|
-
for (const f of
|
|
2093
|
+
${failed3.length} script(s) failed:`);
|
|
2094
|
+
for (const f of failed3) {
|
|
2094
2095
|
console.error(` - ${f.script} (exit code ${f.code})`);
|
|
2095
2096
|
}
|
|
2096
2097
|
}
|
|
@@ -2115,9 +2116,9 @@ function runEntry(entry) {
|
|
|
2115
2116
|
});
|
|
2116
2117
|
});
|
|
2117
2118
|
}
|
|
2118
|
-
function exitIfFailed(
|
|
2119
|
-
if (
|
|
2120
|
-
logFailedScripts(
|
|
2119
|
+
function exitIfFailed(failed3) {
|
|
2120
|
+
if (failed3.length === 0) return;
|
|
2121
|
+
logFailedScripts(failed3);
|
|
2121
2122
|
process.exit(1);
|
|
2122
2123
|
}
|
|
2123
2124
|
async function runAllEntries(entries) {
|
|
@@ -4204,6 +4205,11 @@ var backlogConfigHelp = [
|
|
|
4204
4205
|
setter: "assist config set backlog.previewComments true",
|
|
4205
4206
|
note: "review 'backlog comment' in the web preview pane before it is written (default: off)"
|
|
4206
4207
|
},
|
|
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
|
+
},
|
|
4207
4213
|
{
|
|
4208
4214
|
key: "clone.baseDir",
|
|
4209
4215
|
setter: "assist config set clone.baseDir ~/git",
|
|
@@ -6507,6 +6513,17 @@ function buildManualCheckLines(manualChecks, commitBeforePhaseEnd) {
|
|
|
6507
6513
|
return [];
|
|
6508
6514
|
}
|
|
6509
6515
|
|
|
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
|
+
|
|
6510
6527
|
// src/commands/backlog/buildAuthoredPhasePrompt.ts
|
|
6511
6528
|
function buildAuthoredPhasePrompt(item, phaseNumber, phase, options2 = {
|
|
6512
6529
|
commitBeforePhaseEnd: false
|
|
@@ -6519,7 +6536,7 @@ function buildAuthoredPhasePrompt(item, phaseNumber, phase, options2 = {
|
|
|
6519
6536
|
...buildJiraStartedLines(item, phaseNumber),
|
|
6520
6537
|
"",
|
|
6521
6538
|
"Focus ONLY on this phase. Do not work on other phases.",
|
|
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
|
|
6539
|
+
options2.crossRepo ? void 0 : "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 to file that work as a separate item in that repo's backlog.",
|
|
6523
6540
|
"If you need to modify backlog items, run `assist backlog --help` to discover available commands.",
|
|
6524
6541
|
"When you have completed all tasks for this phase, run /verify to check your work.",
|
|
6525
6542
|
...buildManualCheckLines(manualChecks, options2.commitBeforePhaseEnd),
|
|
@@ -6546,15 +6563,6 @@ function buildContextLines(item, phaseNumber, phase) {
|
|
|
6546
6563
|
formatTasks(phase)
|
|
6547
6564
|
];
|
|
6548
6565
|
}
|
|
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
|
-
}
|
|
6558
6566
|
function formatTasks(phase) {
|
|
6559
6567
|
return phase.tasks.map((t) => `- ${t.task}`).join("\n");
|
|
6560
6568
|
}
|
|
@@ -6611,13 +6619,14 @@ function buildReviewPrompt(item, phaseNumber, options2 = {
|
|
|
6611
6619
|
// src/commands/backlog/buildPhasePrompt.ts
|
|
6612
6620
|
var REVIEW_PHASE_NAME = "Review";
|
|
6613
6621
|
function buildPhasePrompt(item, phaseNumber, phase) {
|
|
6614
|
-
const worktree = loadConfig()
|
|
6622
|
+
const { worktree, backlog } = loadConfig();
|
|
6615
6623
|
const commitBeforePhaseEnd = worktree?.commitBeforePhaseEnd ?? worktree?.commitBeforeManualChecks ?? false;
|
|
6616
6624
|
if (phase.name === REVIEW_PHASE_NAME) {
|
|
6617
6625
|
return buildReviewPrompt(item, phaseNumber, { commitBeforePhaseEnd });
|
|
6618
6626
|
}
|
|
6619
6627
|
return buildAuthoredPhasePrompt(item, phaseNumber, phase, {
|
|
6620
|
-
commitBeforePhaseEnd
|
|
6628
|
+
commitBeforePhaseEnd,
|
|
6629
|
+
crossRepo: backlog?.crossRepo ?? false
|
|
6621
6630
|
});
|
|
6622
6631
|
}
|
|
6623
6632
|
|
|
@@ -11449,6 +11458,52 @@ async function handleItemRoute(req, res, pathname) {
|
|
|
11449
11458
|
return false;
|
|
11450
11459
|
}
|
|
11451
11460
|
|
|
11461
|
+
// src/commands/sessions/shared/readLogTail.ts
|
|
11462
|
+
import { closeSync as closeSync3, fstatSync, openSync as openSync4, readSync as readSync2 } from "fs";
|
|
11463
|
+
var MAX_TAIL_BYTES = 4 * 1024 * 1024;
|
|
11464
|
+
function completeLines(text18, windowIsPartial) {
|
|
11465
|
+
const all = text18.split("\n");
|
|
11466
|
+
if (all.at(-1) === "") all.pop();
|
|
11467
|
+
if (windowIsPartial) all.shift();
|
|
11468
|
+
return all;
|
|
11469
|
+
}
|
|
11470
|
+
function readLogTail(path103, lines2) {
|
|
11471
|
+
let fd;
|
|
11472
|
+
try {
|
|
11473
|
+
fd = openSync4(path103, "r");
|
|
11474
|
+
} catch {
|
|
11475
|
+
return [];
|
|
11476
|
+
}
|
|
11477
|
+
try {
|
|
11478
|
+
const size = fstatSync(fd).size;
|
|
11479
|
+
const length = Math.min(size, MAX_TAIL_BYTES);
|
|
11480
|
+
const buffer = Buffer.alloc(length);
|
|
11481
|
+
readSync2(fd, buffer, 0, length, size - length);
|
|
11482
|
+
return completeLines(buffer.toString("utf8"), length < size).slice(-lines2);
|
|
11483
|
+
} finally {
|
|
11484
|
+
closeSync3(fd);
|
|
11485
|
+
}
|
|
11486
|
+
}
|
|
11487
|
+
|
|
11488
|
+
// src/commands/sessions/web/daemonLogTail.ts
|
|
11489
|
+
var DEFAULT_LINES = 200;
|
|
11490
|
+
var MAX_LINES = 1e4;
|
|
11491
|
+
function requestedLines(req) {
|
|
11492
|
+
const raw = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
11493
|
+
"lines"
|
|
11494
|
+
);
|
|
11495
|
+
const parsed = Number.parseInt(raw ?? "", 10);
|
|
11496
|
+
if (!Number.isFinite(parsed) || parsed < 1) return DEFAULT_LINES;
|
|
11497
|
+
return Math.min(parsed, MAX_LINES);
|
|
11498
|
+
}
|
|
11499
|
+
async function daemonLogTail(req, res) {
|
|
11500
|
+
respondJson(res, 200, {
|
|
11501
|
+
nodeName: resolveNodeName(),
|
|
11502
|
+
path: daemonPaths.log,
|
|
11503
|
+
lines: readLogTail(daemonPaths.log, requestedLines(req))
|
|
11504
|
+
});
|
|
11505
|
+
}
|
|
11506
|
+
|
|
11452
11507
|
// src/commands/sessions/web/getCwdParam.ts
|
|
11453
11508
|
function getCwdParam(req, res) {
|
|
11454
11509
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -13321,13 +13376,51 @@ function protocolMismatched(msg) {
|
|
|
13321
13376
|
return typeof msg.protocol === "number" && msg.protocol !== PROTOCOL_VERSION;
|
|
13322
13377
|
}
|
|
13323
13378
|
|
|
13379
|
+
// src/commands/sessions/nodes/queryNodes.ts
|
|
13380
|
+
import { createInterface as createInterface5 } from "readline";
|
|
13381
|
+
var QUERY_TIMEOUT_MS = 3e3;
|
|
13382
|
+
async function queryNodes() {
|
|
13383
|
+
let socket;
|
|
13384
|
+
try {
|
|
13385
|
+
socket = await connectToDaemon();
|
|
13386
|
+
} catch {
|
|
13387
|
+
return void 0;
|
|
13388
|
+
}
|
|
13389
|
+
return new Promise((resolve25) => {
|
|
13390
|
+
const finish2 = (result) => {
|
|
13391
|
+
clearTimeout(timer);
|
|
13392
|
+
socket.destroy();
|
|
13393
|
+
resolve25(result);
|
|
13394
|
+
};
|
|
13395
|
+
const timer = setTimeout(() => finish2(void 0), QUERY_TIMEOUT_MS);
|
|
13396
|
+
const lines2 = createInterface5({ input: socket });
|
|
13397
|
+
lines2.on("error", () => {
|
|
13398
|
+
});
|
|
13399
|
+
lines2.on("line", (line) => {
|
|
13400
|
+
try {
|
|
13401
|
+
const data = JSON.parse(line);
|
|
13402
|
+
if (data.type === "nodes") finish2(data);
|
|
13403
|
+
} catch {
|
|
13404
|
+
}
|
|
13405
|
+
});
|
|
13406
|
+
socket.on("error", () => finish2(void 0));
|
|
13407
|
+
socket.write(`${JSON.stringify({ type: "nodes" })}
|
|
13408
|
+
`);
|
|
13409
|
+
});
|
|
13410
|
+
}
|
|
13411
|
+
|
|
13324
13412
|
// src/commands/sessions/web/health.ts
|
|
13325
13413
|
async function health(_req, res) {
|
|
13414
|
+
const [reachable, nodes] = await Promise.all([
|
|
13415
|
+
isDaemonRunning(),
|
|
13416
|
+
queryNodes()
|
|
13417
|
+
]);
|
|
13326
13418
|
respondJson(res, 200, {
|
|
13327
13419
|
nodeName: resolveNodeName(),
|
|
13328
13420
|
version: ASSIST_VERSION,
|
|
13329
13421
|
protocol: PROTOCOL_VERSION,
|
|
13330
|
-
daemon: { reachable
|
|
13422
|
+
daemon: { reachable },
|
|
13423
|
+
links: nodes?.links ?? []
|
|
13331
13424
|
});
|
|
13332
13425
|
}
|
|
13333
13426
|
|
|
@@ -13982,6 +14075,13 @@ async function prList(req, res) {
|
|
|
13982
14075
|
respondJson(res, 200, { prs: await getOpenPrs(cwd) });
|
|
13983
14076
|
}
|
|
13984
14077
|
|
|
14078
|
+
// src/commands/sessions/shared/newTraceId.ts
|
|
14079
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
14080
|
+
var TRACE_HEADER = "x-assist-trace-id";
|
|
14081
|
+
function newTraceId() {
|
|
14082
|
+
return randomUUID7().slice(0, 8);
|
|
14083
|
+
}
|
|
14084
|
+
|
|
13985
14085
|
// src/commands/sessions/web/forwardToPeer.ts
|
|
13986
14086
|
import {
|
|
13987
14087
|
request as httpRequest
|
|
@@ -13990,7 +14090,8 @@ import { request as httpsRequest } from "https";
|
|
|
13990
14090
|
var LINKED_FROM_HEADER = "x-assist-linked-from";
|
|
13991
14091
|
function forwardToPeer(req, res, node, url) {
|
|
13992
14092
|
const started = Date.now();
|
|
13993
|
-
const
|
|
14093
|
+
const traceId = newTraceId();
|
|
14094
|
+
const label2 = `link ${node} http: ${req.method} ${url.pathname} trace=${traceId}`;
|
|
13994
14095
|
const elapsed = () => `${Date.now() - started}ms`;
|
|
13995
14096
|
const send = url.protocol === "https:" ? httpsRequest : httpRequest;
|
|
13996
14097
|
return new Promise((resolve25) => {
|
|
@@ -14001,7 +14102,8 @@ function forwardToPeer(req, res, node, url) {
|
|
|
14001
14102
|
headers: {
|
|
14002
14103
|
...req.headers,
|
|
14003
14104
|
host: url.host,
|
|
14004
|
-
[LINKED_FROM_HEADER]: resolveNodeName()
|
|
14105
|
+
[LINKED_FROM_HEADER]: resolveNodeName(),
|
|
14106
|
+
[TRACE_HEADER]: traceId
|
|
14005
14107
|
}
|
|
14006
14108
|
},
|
|
14007
14109
|
(peer) => {
|
|
@@ -14045,7 +14147,20 @@ function proxyTarget(req) {
|
|
|
14045
14147
|
url: new URL(`${url.pathname}${url.search}`, link3.url)
|
|
14046
14148
|
};
|
|
14047
14149
|
}
|
|
14150
|
+
function logLinkedRequest(req, res) {
|
|
14151
|
+
const started = Date.now();
|
|
14152
|
+
const from = req.headers[LINKED_FROM_HEADER2];
|
|
14153
|
+
const trace = req.headers[TRACE_HEADER] ?? "none";
|
|
14154
|
+
const path103 = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
14155
|
+
res.once(
|
|
14156
|
+
"finish",
|
|
14157
|
+
() => console.log(
|
|
14158
|
+
`link-from ${from} http: ${req.method} ${path103} trace=${trace} -> ${res.statusCode} (${Date.now() - started}ms)`
|
|
14159
|
+
)
|
|
14160
|
+
);
|
|
14161
|
+
}
|
|
14048
14162
|
async function proxyToNode(req, res) {
|
|
14163
|
+
if (arrivedOverLink(req)) logLinkedRequest(req, res);
|
|
14049
14164
|
const target = proxyTarget(req);
|
|
14050
14165
|
if (target.kind === "local") return false;
|
|
14051
14166
|
if (target.kind === "unknown") {
|
|
@@ -14865,11 +14980,11 @@ async function revertDiffPaths(req, res) {
|
|
|
14865
14980
|
}
|
|
14866
14981
|
const root2 = repoRoot(cwd);
|
|
14867
14982
|
const reverted = [];
|
|
14868
|
-
const
|
|
14983
|
+
const failed3 = [];
|
|
14869
14984
|
for (const path103 of paths) {
|
|
14870
14985
|
const target = resolveWithinCwd(cwd, path103);
|
|
14871
14986
|
if (!target) {
|
|
14872
|
-
|
|
14987
|
+
failed3.push({ path: path103, error: "Path outside cwd" });
|
|
14873
14988
|
continue;
|
|
14874
14989
|
}
|
|
14875
14990
|
const relativePath = relative4(root2, target);
|
|
@@ -14877,13 +14992,13 @@ async function revertDiffPaths(req, res) {
|
|
|
14877
14992
|
await revertPathChanges(cwd, relativePath);
|
|
14878
14993
|
reverted.push(relativePath);
|
|
14879
14994
|
} catch (error) {
|
|
14880
|
-
|
|
14995
|
+
failed3.push({
|
|
14881
14996
|
path: relativePath,
|
|
14882
14997
|
error: error instanceof Error ? error.message : "Failed to revert file"
|
|
14883
14998
|
});
|
|
14884
14999
|
}
|
|
14885
15000
|
}
|
|
14886
|
-
respondJson(res, 200, { reverted, failed:
|
|
15001
|
+
respondJson(res, 200, { reverted, failed: failed3 });
|
|
14887
15002
|
}
|
|
14888
15003
|
|
|
14889
15004
|
// src/commands/sessions/web/sessionLayout.ts
|
|
@@ -15779,6 +15894,7 @@ var routes2 = {
|
|
|
15779
15894
|
"text/css"
|
|
15780
15895
|
),
|
|
15781
15896
|
"GET /api/health": health,
|
|
15897
|
+
"GET /api/daemon-log": daemonLogTail,
|
|
15782
15898
|
"GET /api/items": listItems,
|
|
15783
15899
|
"GET /api/backlog/summary": getBacklogSummary,
|
|
15784
15900
|
"GET /api/repo-location": getRepoLocation,
|
|
@@ -16045,7 +16161,7 @@ function installRestartMenu(options2 = {}) {
|
|
|
16045
16161
|
}
|
|
16046
16162
|
|
|
16047
16163
|
// src/commands/sessions/web/streamDaemonLogs.ts
|
|
16048
|
-
import { createInterface as
|
|
16164
|
+
import { createInterface as createInterface6 } from "readline";
|
|
16049
16165
|
var RECONNECT_MS = 3e3;
|
|
16050
16166
|
function streamDaemonLogs() {
|
|
16051
16167
|
void connect2();
|
|
@@ -16064,7 +16180,7 @@ async function connect2() {
|
|
|
16064
16180
|
}
|
|
16065
16181
|
}
|
|
16066
16182
|
function wire(socket) {
|
|
16067
|
-
const lines2 =
|
|
16183
|
+
const lines2 = createInterface6({ input: socket });
|
|
16068
16184
|
lines2.on("error", () => {
|
|
16069
16185
|
});
|
|
16070
16186
|
lines2.on("line", emit);
|
|
@@ -20520,7 +20636,7 @@ function registerDevlog(program2) {
|
|
|
20520
20636
|
}
|
|
20521
20637
|
|
|
20522
20638
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
20523
|
-
import { closeSync as
|
|
20639
|
+
import { closeSync as closeSync4, openSync as openSync5, readdirSync as readdirSync7 } from "fs";
|
|
20524
20640
|
import { join as join57 } from "path";
|
|
20525
20641
|
import chalk151 from "chalk";
|
|
20526
20642
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
@@ -20535,8 +20651,8 @@ function isLockedDll(debugDir) {
|
|
|
20535
20651
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
20536
20652
|
const dllPath = join57(debugDir, file);
|
|
20537
20653
|
try {
|
|
20538
|
-
const fd =
|
|
20539
|
-
|
|
20654
|
+
const fd = openSync5(dllPath, "r+");
|
|
20655
|
+
closeSync4(fd);
|
|
20540
20656
|
} catch {
|
|
20541
20657
|
return dllPath;
|
|
20542
20658
|
}
|
|
@@ -22698,13 +22814,13 @@ function validateProposedContent(labels, title, body) {
|
|
|
22698
22814
|
}
|
|
22699
22815
|
|
|
22700
22816
|
// src/commands/github/issue/reviewProposedIssueComment.ts
|
|
22701
|
-
import { randomUUID as
|
|
22817
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
22702
22818
|
async function reviewProposedIssueComment(title, body) {
|
|
22703
22819
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
22704
22820
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
22705
22821
|
await awaitPreviewApproval("GitHub issue comment preview", {
|
|
22706
22822
|
sessionId,
|
|
22707
|
-
requestId:
|
|
22823
|
+
requestId: randomUUID8(),
|
|
22708
22824
|
title,
|
|
22709
22825
|
body,
|
|
22710
22826
|
prNumber: null,
|
|
@@ -23186,13 +23302,13 @@ function resolveCreateIssueMetadata(options2) {
|
|
|
23186
23302
|
}
|
|
23187
23303
|
|
|
23188
23304
|
// src/commands/github/issue/reviewProposedIssue.ts
|
|
23189
|
-
import { randomUUID as
|
|
23305
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
23190
23306
|
async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
23191
23307
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
23192
23308
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return void 0;
|
|
23193
23309
|
return await awaitPreviewApproval("GitHub issue preview", {
|
|
23194
23310
|
sessionId,
|
|
23195
|
-
requestId:
|
|
23311
|
+
requestId: randomUUID9(),
|
|
23196
23312
|
title,
|
|
23197
23313
|
body,
|
|
23198
23314
|
prNumber: null,
|
|
@@ -23415,7 +23531,7 @@ function pushUnchangedIssue(number, repo, target, fetchedAt, bodyPath) {
|
|
|
23415
23531
|
}
|
|
23416
23532
|
|
|
23417
23533
|
// src/commands/github/issue/reviewProposedIssueEdit.ts
|
|
23418
|
-
import { randomUUID as
|
|
23534
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
23419
23535
|
async function reviewProposedIssueEdit(title, body, working) {
|
|
23420
23536
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
23421
23537
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return body;
|
|
@@ -23423,7 +23539,7 @@ async function reviewProposedIssueEdit(title, body, working) {
|
|
|
23423
23539
|
"GitHub issue edit preview",
|
|
23424
23540
|
{
|
|
23425
23541
|
sessionId,
|
|
23426
|
-
requestId:
|
|
23542
|
+
requestId: randomUUID10(),
|
|
23427
23543
|
title,
|
|
23428
23544
|
body,
|
|
23429
23545
|
prNumber: null,
|
|
@@ -24157,7 +24273,7 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
24157
24273
|
}
|
|
24158
24274
|
|
|
24159
24275
|
// src/commands/reviewPrComments.ts
|
|
24160
|
-
import { randomUUID as
|
|
24276
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
24161
24277
|
|
|
24162
24278
|
// src/commands/review/checkoutPr.ts
|
|
24163
24279
|
import { execFileSync as execFileSync15 } from "child_process";
|
|
@@ -24813,7 +24929,7 @@ async function reviewPrComments(number, options2 = {}) {
|
|
|
24813
24929
|
const resumeSessionId = options2.resumeSessionId;
|
|
24814
24930
|
validateAnnounce(number, announce);
|
|
24815
24931
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
24816
|
-
const claudeSessionId = resumeSessionId ??
|
|
24932
|
+
const claudeSessionId = resumeSessionId ?? randomUUID11();
|
|
24817
24933
|
emitActivity({
|
|
24818
24934
|
kind: "command",
|
|
24819
24935
|
name: "review-pr-comments",
|
|
@@ -24831,14 +24947,14 @@ async function reviewPrComments(number, options2 = {}) {
|
|
|
24831
24947
|
}
|
|
24832
24948
|
|
|
24833
24949
|
// src/commands/fixConflict.ts
|
|
24834
|
-
import { randomUUID as
|
|
24950
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
24835
24951
|
function buildPrompt3(rebase) {
|
|
24836
24952
|
return rebase ? "/fix-conflict --rebase" : "/fix-conflict";
|
|
24837
24953
|
}
|
|
24838
24954
|
async function fixConflict(number, options2 = {}) {
|
|
24839
24955
|
const { resumeSessionId } = options2;
|
|
24840
24956
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
24841
|
-
const claudeSessionId = resumeSessionId ??
|
|
24957
|
+
const claudeSessionId = resumeSessionId ?? randomUUID12();
|
|
24842
24958
|
emitActivity({
|
|
24843
24959
|
kind: "command",
|
|
24844
24960
|
name: "fix-conflict",
|
|
@@ -25382,7 +25498,7 @@ async function offerSaveExtract(extract2, options2, paths = {}) {
|
|
|
25382
25498
|
}
|
|
25383
25499
|
|
|
25384
25500
|
// src/commands/miro/pickAnchors.ts
|
|
25385
|
-
import { randomUUID as
|
|
25501
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
25386
25502
|
|
|
25387
25503
|
// src/commands/miro/isBox.ts
|
|
25388
25504
|
var boxTypes = /* @__PURE__ */ new Set(["shape", "sticky_note"]);
|
|
@@ -25403,7 +25519,7 @@ async function pickAnchors(sessionId, items2) {
|
|
|
25403
25519
|
"Miro anchor selection",
|
|
25404
25520
|
{
|
|
25405
25521
|
sessionId,
|
|
25406
|
-
requestId:
|
|
25522
|
+
requestId: randomUUID13(),
|
|
25407
25523
|
title: "Pick the top-left then the bottom-right box",
|
|
25408
25524
|
body: encodeMiroBoardPreview(items2),
|
|
25409
25525
|
prNumber: null,
|
|
@@ -26593,13 +26709,13 @@ function postReviewComment(vars) {
|
|
|
26593
26709
|
}
|
|
26594
26710
|
|
|
26595
26711
|
// src/commands/prs/reviewProposedPrComment.ts
|
|
26596
|
-
import { randomUUID as
|
|
26712
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
26597
26713
|
async function reviewProposedPrComment(title, body, prNumber) {
|
|
26598
26714
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
26599
26715
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
26600
26716
|
await awaitPreviewApproval("PR comment preview", {
|
|
26601
26717
|
sessionId,
|
|
26602
|
-
requestId:
|
|
26718
|
+
requestId: randomUUID14(),
|
|
26603
26719
|
title,
|
|
26604
26720
|
body,
|
|
26605
26721
|
prNumber,
|
|
@@ -27211,7 +27327,7 @@ function registerPrsComments(prsCommand) {
|
|
|
27211
27327
|
}
|
|
27212
27328
|
|
|
27213
27329
|
// src/commands/prs/edit.ts
|
|
27214
|
-
import { randomUUID as
|
|
27330
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
27215
27331
|
|
|
27216
27332
|
// src/commands/prs/applyEdit.ts
|
|
27217
27333
|
import { execFileSync as execFileSync16 } from "child_process";
|
|
@@ -27406,7 +27522,7 @@ async function edit(options2) {
|
|
|
27406
27522
|
if (process.env.ASSIST_SESSION === "1" && sessionId) {
|
|
27407
27523
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
27408
27524
|
sessionId,
|
|
27409
|
-
requestId:
|
|
27525
|
+
requestId: randomUUID15(),
|
|
27410
27526
|
title: options2.title ?? title,
|
|
27411
27527
|
body: newBody,
|
|
27412
27528
|
prNumber: number
|
|
@@ -27605,7 +27721,7 @@ async function placePr(prNumber, title, body, options2) {
|
|
|
27605
27721
|
}
|
|
27606
27722
|
|
|
27607
27723
|
// src/commands/prs/previewAndPlace.ts
|
|
27608
|
-
import { randomUUID as
|
|
27724
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
27609
27725
|
|
|
27610
27726
|
// src/commands/sessions/shared/requestSession.ts
|
|
27611
27727
|
function parseIncoming(line, type) {
|
|
@@ -27756,7 +27872,7 @@ function enableAutoMerge() {
|
|
|
27756
27872
|
async function previewAndPlace(args) {
|
|
27757
27873
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
27758
27874
|
sessionId: args.sessionId,
|
|
27759
|
-
requestId:
|
|
27875
|
+
requestId: randomUUID16(),
|
|
27760
27876
|
title: args.title,
|
|
27761
27877
|
body: args.body,
|
|
27762
27878
|
prNumber: args.prNumber,
|
|
@@ -30106,13 +30222,13 @@ function runScript(script, cwd) {
|
|
|
30106
30222
|
});
|
|
30107
30223
|
});
|
|
30108
30224
|
}
|
|
30109
|
-
function logFailures(
|
|
30110
|
-
for (const f of
|
|
30225
|
+
function logFailures(failed3) {
|
|
30226
|
+
for (const f of failed3) {
|
|
30111
30227
|
console.error(f.output);
|
|
30112
30228
|
}
|
|
30113
30229
|
console.error(`
|
|
30114
|
-
${
|
|
30115
|
-
for (const f of
|
|
30230
|
+
${failed3.length} verify script(s) failed:`);
|
|
30231
|
+
for (const f of failed3) {
|
|
30116
30232
|
console.error(` - ${f.script} (exit code ${f.code})`);
|
|
30117
30233
|
}
|
|
30118
30234
|
}
|
|
@@ -30123,9 +30239,9 @@ async function runVerifyQuietly() {
|
|
|
30123
30239
|
const results = await Promise.all(
|
|
30124
30240
|
result.verifyScripts.map((script) => runScript(script, packageDir))
|
|
30125
30241
|
);
|
|
30126
|
-
const
|
|
30127
|
-
if (
|
|
30128
|
-
logFailures(
|
|
30242
|
+
const failed3 = results.filter((r) => r.code !== 0);
|
|
30243
|
+
if (failed3.length > 0) {
|
|
30244
|
+
logFailures(failed3);
|
|
30129
30245
|
return false;
|
|
30130
30246
|
}
|
|
30131
30247
|
return true;
|
|
@@ -31921,10 +32037,10 @@ function registerRefactor(program2) {
|
|
|
31921
32037
|
}
|
|
31922
32038
|
|
|
31923
32039
|
// src/commands/review/checkoutOnlySession.ts
|
|
31924
|
-
import { randomUUID as
|
|
32040
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
31925
32041
|
async function checkoutOnlySession(number) {
|
|
31926
32042
|
await checkoutPr(number);
|
|
31927
|
-
const claudeSessionId =
|
|
32043
|
+
const claudeSessionId = randomUUID17();
|
|
31928
32044
|
emitActivity({ kind: "command", name: "review", claudeSessionId });
|
|
31929
32045
|
const { done: done2 } = spawnClaude("", {
|
|
31930
32046
|
permissionMode: "acceptEdits",
|
|
@@ -32661,7 +32777,7 @@ function gatherHighLevelSubject(prNumber, force) {
|
|
|
32661
32777
|
}
|
|
32662
32778
|
|
|
32663
32779
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
32664
|
-
import { randomUUID as
|
|
32780
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
32665
32781
|
|
|
32666
32782
|
// src/commands/review/highLevel/buildHighLevelRecord.ts
|
|
32667
32783
|
function toItem2(check2, decision) {
|
|
@@ -32748,7 +32864,7 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
32748
32864
|
"High-level review",
|
|
32749
32865
|
{
|
|
32750
32866
|
sessionId,
|
|
32751
|
-
requestId:
|
|
32867
|
+
requestId: randomUUID18(),
|
|
32752
32868
|
title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
|
|
32753
32869
|
body: JSON.stringify(highLevelPreviewPayload(subject)),
|
|
32754
32870
|
prNumber: subject.prNumber,
|
|
@@ -32820,11 +32936,11 @@ function formatHighLevelChecklist(checks2) {
|
|
|
32820
32936
|
const deterministic = checks2.filter(
|
|
32821
32937
|
(check2) => check2.kind === "deterministic"
|
|
32822
32938
|
);
|
|
32823
|
-
const
|
|
32939
|
+
const failed3 = deterministic.filter(
|
|
32824
32940
|
(check2) => check2.status === "fail"
|
|
32825
32941
|
).length;
|
|
32826
|
-
const summary =
|
|
32827
|
-
`${
|
|
32942
|
+
const summary = failed3 === 0 ? chalk227.green(`All ${deterministic.length} deterministic checks pass`) : chalk227.red(
|
|
32943
|
+
`${failed3} of ${deterministic.length} deterministic checks fail`
|
|
32828
32944
|
);
|
|
32829
32945
|
return [
|
|
32830
32946
|
...formatGroup("Deterministic", deterministic),
|
|
@@ -33356,7 +33472,7 @@ function buildCommentBody(finding) {
|
|
|
33356
33472
|
}
|
|
33357
33473
|
async function postFindings(findings) {
|
|
33358
33474
|
let posted = 0;
|
|
33359
|
-
let
|
|
33475
|
+
let failed3 = 0;
|
|
33360
33476
|
for (const finding of findings) {
|
|
33361
33477
|
const body = buildCommentBody(finding);
|
|
33362
33478
|
try {
|
|
@@ -33366,14 +33482,14 @@ async function postFindings(findings) {
|
|
|
33366
33482
|
});
|
|
33367
33483
|
posted++;
|
|
33368
33484
|
} catch (error) {
|
|
33369
|
-
|
|
33485
|
+
failed3++;
|
|
33370
33486
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
33371
33487
|
console.error(
|
|
33372
33488
|
`Failed to post comment on ${finding.file}:${finding.line}: ${message3}`
|
|
33373
33489
|
);
|
|
33374
33490
|
}
|
|
33375
33491
|
}
|
|
33376
|
-
return { posted, failed:
|
|
33492
|
+
return { posted, failed: failed3 };
|
|
33377
33493
|
}
|
|
33378
33494
|
|
|
33379
33495
|
// src/commands/review/runReviewSubmission.ts
|
|
@@ -35630,7 +35746,7 @@ function readSlackParts(files) {
|
|
|
35630
35746
|
}
|
|
35631
35747
|
|
|
35632
35748
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
35633
|
-
import { randomUUID as
|
|
35749
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
35634
35750
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
35635
35751
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
35636
35752
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
@@ -35640,7 +35756,7 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
35640
35756
|
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
35641
35757
|
{
|
|
35642
35758
|
sessionId,
|
|
35643
|
-
requestId:
|
|
35759
|
+
requestId: randomUUID19(),
|
|
35644
35760
|
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
35645
35761
|
body,
|
|
35646
35762
|
prNumber: null,
|
|
@@ -39278,6 +39394,22 @@ function registerRun(program2) {
|
|
|
39278
39394
|
registerRunSubcommands(runCommand);
|
|
39279
39395
|
}
|
|
39280
39396
|
|
|
39397
|
+
// src/commands/sessions/nodes/formatLink.ts
|
|
39398
|
+
import chalk249 from "chalk";
|
|
39399
|
+
var STATE_COLOURS = {
|
|
39400
|
+
connected: chalk249.green,
|
|
39401
|
+
connecting: chalk249.yellow,
|
|
39402
|
+
disconnected: chalk249.red,
|
|
39403
|
+
"version-blocked": chalk249.red
|
|
39404
|
+
};
|
|
39405
|
+
function formatLink(link3) {
|
|
39406
|
+
const colour = STATE_COLOURS[link3.state] ?? chalk249.white;
|
|
39407
|
+
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
39408
|
+
const error = link3.error ? `
|
|
39409
|
+
${chalk249.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
39410
|
+
return ` ${link3.name} ${colour(link3.state)} direct ${link3.url}${peer}${error}`;
|
|
39411
|
+
}
|
|
39412
|
+
|
|
39281
39413
|
// src/commands/sessions/daemon/listDaemonPids.ts
|
|
39282
39414
|
import { execFileSync as execFileSync24 } from "child_process";
|
|
39283
39415
|
function listDaemonPids() {
|
|
@@ -39293,7 +39425,7 @@ function listDaemonPids() {
|
|
|
39293
39425
|
}
|
|
39294
39426
|
|
|
39295
39427
|
// src/commands/sessions/daemon/queryDaemon.ts
|
|
39296
|
-
import { createInterface as
|
|
39428
|
+
import { createInterface as createInterface8 } from "readline";
|
|
39297
39429
|
var STATUS_TIMEOUT_MS = 5e3;
|
|
39298
39430
|
function queryDaemon(socket) {
|
|
39299
39431
|
socket.write(`${JSON.stringify({ type: "ping" })}
|
|
@@ -39302,7 +39434,7 @@ function queryDaemon(socket) {
|
|
|
39302
39434
|
const result = { sessions: [] };
|
|
39303
39435
|
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
39304
39436
|
const timer = setTimeout(() => resolve25(result), STATUS_TIMEOUT_MS);
|
|
39305
|
-
const lines2 =
|
|
39437
|
+
const lines2 = createInterface8({ input: socket });
|
|
39306
39438
|
lines2.on("error", () => {
|
|
39307
39439
|
});
|
|
39308
39440
|
lines2.on("line", (line) => {
|
|
@@ -39375,14 +39507,18 @@ async function daemonStatus() {
|
|
|
39375
39507
|
console.log(`Sessions daemon is running${pid ? ` (PID ${pid})` : ""}`);
|
|
39376
39508
|
reportStolenSocket(pid);
|
|
39377
39509
|
reportStrays(listDaemonPids().filter((p) => p !== pid));
|
|
39378
|
-
if (sessions.length === 0)
|
|
39379
|
-
console.log("No sessions");
|
|
39380
|
-
return;
|
|
39381
|
-
}
|
|
39510
|
+
if (sessions.length === 0) console.log("No sessions");
|
|
39382
39511
|
for (const session of sessions) {
|
|
39383
39512
|
const restored = session.restored === false ? " (not restored)" : "";
|
|
39384
39513
|
console.log(` [${session.status}] ${session.name}${restored}`);
|
|
39385
39514
|
}
|
|
39515
|
+
await reportLinks();
|
|
39516
|
+
}
|
|
39517
|
+
async function reportLinks() {
|
|
39518
|
+
const links2 = (await queryNodes())?.links ?? [];
|
|
39519
|
+
if (links2.length === 0) return;
|
|
39520
|
+
console.log("Links:");
|
|
39521
|
+
for (const link3 of links2) console.log(formatLink(link3));
|
|
39386
39522
|
}
|
|
39387
39523
|
function reportStrays(pids) {
|
|
39388
39524
|
if (pids.length === 0) return;
|
|
@@ -39392,7 +39528,7 @@ function reportStrays(pids) {
|
|
|
39392
39528
|
}
|
|
39393
39529
|
|
|
39394
39530
|
// src/commands/sessions/daemon/drainDaemon.ts
|
|
39395
|
-
import { createInterface as
|
|
39531
|
+
import { createInterface as createInterface9 } from "readline";
|
|
39396
39532
|
|
|
39397
39533
|
// src/commands/sessions/daemon/clearPersistedSessionsOnDrain.ts
|
|
39398
39534
|
function clearPersistedSessionsOnDrain() {
|
|
@@ -39434,7 +39570,7 @@ async function drainDaemon(options2 = {}) {
|
|
|
39434
39570
|
clearPersistedSessionsOnDrain();
|
|
39435
39571
|
return;
|
|
39436
39572
|
}
|
|
39437
|
-
const lines2 =
|
|
39573
|
+
const lines2 = createInterface9({ input: socket });
|
|
39438
39574
|
lines2.on("error", () => {
|
|
39439
39575
|
});
|
|
39440
39576
|
const live = await liveSessions(lines2);
|
|
@@ -39782,7 +39918,7 @@ var ClientHub = class extends Set {
|
|
|
39782
39918
|
};
|
|
39783
39919
|
|
|
39784
39920
|
// src/commands/sessions/daemon/createSession.ts
|
|
39785
|
-
import { randomUUID as
|
|
39921
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
39786
39922
|
|
|
39787
39923
|
// src/commands/sessions/daemon/sessionBase.ts
|
|
39788
39924
|
function sessionBase(id, status3) {
|
|
@@ -39988,7 +40124,7 @@ function spawnRun(opts) {
|
|
|
39988
40124
|
function createSession(id, { prompt, cwd, design, auto, harness, holdPty } = {}) {
|
|
39989
40125
|
if (harness && harness !== "claude")
|
|
39990
40126
|
return createHarnessSession(id, harness, prompt, cwd, holdPty);
|
|
39991
|
-
const claudeSessionId =
|
|
40127
|
+
const claudeSessionId = randomUUID20();
|
|
39992
40128
|
return {
|
|
39993
40129
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
39994
40130
|
name: `Session ${id}`,
|
|
@@ -40911,8 +41047,8 @@ function handleErroredExit(session, exitCode, priorStatus, onStatusChange) {
|
|
|
40911
41047
|
|
|
40912
41048
|
// src/commands/sessions/daemon/handleFailedResume.ts
|
|
40913
41049
|
function handleFailedResume(session, exitCode, onStatusChange) {
|
|
40914
|
-
const
|
|
40915
|
-
if (!
|
|
41050
|
+
const failed3 = session.restored === true && exitCode !== 0 && session.scrollback.length === 0;
|
|
41051
|
+
if (!failed3) return false;
|
|
40916
41052
|
session.error = `resume process exited with code ${exitCode} before producing any output`;
|
|
40917
41053
|
daemonLog(
|
|
40918
41054
|
`could not resume restored session "${session.name}" (id ${session.id}): ${session.error}`
|
|
@@ -42159,7 +42295,7 @@ function codexRespawnPlan(session) {
|
|
|
42159
42295
|
}
|
|
42160
42296
|
|
|
42161
42297
|
// src/commands/sessions/daemon/interactiveRespawnPlan.ts
|
|
42162
|
-
import { randomUUID as
|
|
42298
|
+
import { randomUUID as randomUUID21 } from "crypto";
|
|
42163
42299
|
function interactiveRespawnPlan(session, resumes) {
|
|
42164
42300
|
const { claudeSessionId, cwd, initialPrompt, design, auto } = session;
|
|
42165
42301
|
if (!resumes) return null;
|
|
@@ -42179,7 +42315,7 @@ function interactiveRespawnPlan(session, resumes) {
|
|
|
42179
42315
|
return null;
|
|
42180
42316
|
}
|
|
42181
42317
|
function freshClaudePlan(session, prompt, cwd) {
|
|
42182
|
-
const claudeSessionId =
|
|
42318
|
+
const claudeSessionId = randomUUID21();
|
|
42183
42319
|
return {
|
|
42184
42320
|
spawn: () => {
|
|
42185
42321
|
session.claudeSessionId = claudeSessionId;
|
|
@@ -43188,10 +43324,10 @@ function startReusedRunPty(session, assistArgs, itemId2, hold, clients, onStatus
|
|
|
43188
43324
|
}
|
|
43189
43325
|
|
|
43190
43326
|
// src/commands/sessions/daemon/createWatcherSession.ts
|
|
43191
|
-
import { randomUUID as
|
|
43327
|
+
import { randomUUID as randomUUID22 } from "crypto";
|
|
43192
43328
|
var WATCH_PROMPT = "/watch";
|
|
43193
43329
|
function createWatcherSession(id, cwd) {
|
|
43194
|
-
const claudeSessionId =
|
|
43330
|
+
const claudeSessionId = randomUUID22();
|
|
43195
43331
|
return {
|
|
43196
43332
|
...sessionBase(id, "running"),
|
|
43197
43333
|
name: `Session ${id}`,
|
|
@@ -43764,11 +43900,12 @@ function forwardLinkCreate(ctx, client, data) {
|
|
|
43764
43900
|
});
|
|
43765
43901
|
return;
|
|
43766
43902
|
}
|
|
43903
|
+
const traceId = newTraceId();
|
|
43767
43904
|
daemonLog(
|
|
43768
|
-
`link ${node} ws: routing ${data.type} (cwd=${data.cwd ?? "default"})`
|
|
43905
|
+
`link ${node} ws: routing ${data.type} (cwd=${data.cwd ?? "default"}) trace=${traceId}`
|
|
43769
43906
|
);
|
|
43770
43907
|
armCreateTimeout(ctx, client, data);
|
|
43771
|
-
sendToLink(ctx, toPeerMessage(data));
|
|
43908
|
+
sendToLink(ctx, { ...toPeerMessage(data), traceId });
|
|
43772
43909
|
}
|
|
43773
43910
|
|
|
43774
43911
|
// src/commands/sessions/daemon/links/forwardToLink.ts
|
|
@@ -44648,7 +44785,7 @@ function exitAfterFlush(code) {
|
|
|
44648
44785
|
}
|
|
44649
44786
|
|
|
44650
44787
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
44651
|
-
import { createInterface as
|
|
44788
|
+
import { createInterface as createInterface10 } from "readline";
|
|
44652
44789
|
|
|
44653
44790
|
// src/commands/sessions/daemon/handleHelloRequest.ts
|
|
44654
44791
|
var handleHelloRequest = (client, m, d) => {
|
|
@@ -45175,6 +45312,10 @@ var messageHandlers = {
|
|
|
45175
45312
|
|
|
45176
45313
|
// src/commands/sessions/daemon/dispatchMessage.ts
|
|
45177
45314
|
function dispatchMessage(client, manager, data) {
|
|
45315
|
+
if (typeof data.traceId === "string")
|
|
45316
|
+
daemonLog(
|
|
45317
|
+
`linked ${data.type} received (cwd=${data.cwd ?? "default"}) trace=${data.traceId}`
|
|
45318
|
+
);
|
|
45178
45319
|
messageHandlers[data.type]?.(client, manager, data);
|
|
45179
45320
|
}
|
|
45180
45321
|
|
|
@@ -45188,7 +45329,7 @@ function handleConnection(socket, manager) {
|
|
|
45188
45329
|
};
|
|
45189
45330
|
manager.addClient(client);
|
|
45190
45331
|
manager.clients.greet(client);
|
|
45191
|
-
const lines2 =
|
|
45332
|
+
const lines2 = createInterface10({ input: socket });
|
|
45192
45333
|
lines2.on("error", () => {
|
|
45193
45334
|
});
|
|
45194
45335
|
lines2.on("line", (line) => {
|
|
@@ -45379,8 +45520,263 @@ async function closeSession() {
|
|
|
45379
45520
|
}
|
|
45380
45521
|
}
|
|
45381
45522
|
|
|
45523
|
+
// src/commands/sessions/nodes/DoctorProbes.ts
|
|
45524
|
+
function passed(hop, detail) {
|
|
45525
|
+
return { hop, ok: true, detail };
|
|
45526
|
+
}
|
|
45527
|
+
function failed2(hop, error, remediation) {
|
|
45528
|
+
return { hop, ok: false, error, remediation };
|
|
45529
|
+
}
|
|
45530
|
+
|
|
45531
|
+
// src/commands/sessions/nodes/fetchPeerJson.ts
|
|
45532
|
+
var PEER_TIMEOUT_MS = 3e3;
|
|
45533
|
+
function peerErrorCode(error) {
|
|
45534
|
+
if (!(error instanceof Error)) return void 0;
|
|
45535
|
+
const { code, cause } = error;
|
|
45536
|
+
if (code) return code;
|
|
45537
|
+
if (error.name === "TimeoutError") return "ETIMEDOUT";
|
|
45538
|
+
return cause instanceof Error ? peerErrorCode(cause) : void 0;
|
|
45539
|
+
}
|
|
45540
|
+
function describePeerError(error) {
|
|
45541
|
+
if (!(error instanceof Error)) return String(error);
|
|
45542
|
+
const cause = error.cause;
|
|
45543
|
+
return cause instanceof Error ? `${error.message}: ${describePeerError(cause)}` : error.message;
|
|
45544
|
+
}
|
|
45545
|
+
async function fetchPeerJson(baseUrl, path103, timeoutMs = PEER_TIMEOUT_MS) {
|
|
45546
|
+
const res = await fetch(new URL(path103, baseUrl), {
|
|
45547
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
45548
|
+
});
|
|
45549
|
+
if (!res.ok)
|
|
45550
|
+
throw Object.assign(
|
|
45551
|
+
new Error(`GET ${path103} returned ${res.status} ${res.statusText}`),
|
|
45552
|
+
{ status: res.status }
|
|
45553
|
+
);
|
|
45554
|
+
return await res.json();
|
|
45555
|
+
}
|
|
45556
|
+
|
|
45557
|
+
// src/commands/sessions/nodes/helloHop.ts
|
|
45558
|
+
async function helloHop(spec, probes) {
|
|
45559
|
+
let msg;
|
|
45560
|
+
try {
|
|
45561
|
+
msg = await probes.hello(spec.url);
|
|
45562
|
+
} catch (error) {
|
|
45563
|
+
return failed2(
|
|
45564
|
+
"ws",
|
|
45565
|
+
describePeerError(error),
|
|
45566
|
+
`${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}\``
|
|
45567
|
+
);
|
|
45568
|
+
}
|
|
45569
|
+
if (!isHello(msg))
|
|
45570
|
+
return failed2(
|
|
45571
|
+
"ws",
|
|
45572
|
+
`malformed hello: ${JSON.stringify(msg)}`,
|
|
45573
|
+
`run \`assist update\` on ${spec.name}`
|
|
45574
|
+
);
|
|
45575
|
+
const detail = `hello ${msg.version} (protocol ${msg.protocol ?? "legacy"})`;
|
|
45576
|
+
if (helloCompatible(msg)) return passed("ws", detail);
|
|
45577
|
+
const mismatch = `${helloMismatchKind(msg)} mismatch: peer ${msg.version} (protocol ${msg.protocol ?? "legacy"}), this node ${ASSIST_VERSION} (protocol ${PROTOCOL_VERSION})`;
|
|
45578
|
+
const mode = linkVersionCheck();
|
|
45579
|
+
if (mode !== "block")
|
|
45580
|
+
return passed(
|
|
45581
|
+
"ws",
|
|
45582
|
+
`${mismatch}; allowed by sessions.linkVersionCheck=${mode}`
|
|
45583
|
+
);
|
|
45584
|
+
return failed2(
|
|
45585
|
+
"ws",
|
|
45586
|
+
mismatch,
|
|
45587
|
+
`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`
|
|
45588
|
+
);
|
|
45589
|
+
}
|
|
45590
|
+
|
|
45591
|
+
// src/commands/sessions/nodes/linkStateHop.ts
|
|
45592
|
+
function linkStateHop(spec, probes) {
|
|
45593
|
+
const status3 = probes.linkState(spec.name);
|
|
45594
|
+
if (status3 === "no-daemon")
|
|
45595
|
+
return failed2(
|
|
45596
|
+
"link",
|
|
45597
|
+
"this node's daemon is not running",
|
|
45598
|
+
"links run in the daemon \u2014 start this node's web server or run `assist daemon restart`"
|
|
45599
|
+
);
|
|
45600
|
+
if (status3 === "unknown-link")
|
|
45601
|
+
return failed2(
|
|
45602
|
+
"link",
|
|
45603
|
+
`this node's daemon has no link named ${spec.name}`,
|
|
45604
|
+
"the daemon has not loaded sessions.links \u2014 run `assist daemon restart`"
|
|
45605
|
+
);
|
|
45606
|
+
if (status3.state === "connected") return passed("link", "connected");
|
|
45607
|
+
const error = status3.error ?? status3.state;
|
|
45608
|
+
if (status3.state === "version-blocked")
|
|
45609
|
+
return failed2("link", error, `version mismatch \u2014 heal latched. ${error}`);
|
|
45610
|
+
return failed2(
|
|
45611
|
+
"link",
|
|
45612
|
+
error,
|
|
45613
|
+
`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`
|
|
45614
|
+
);
|
|
45615
|
+
}
|
|
45616
|
+
|
|
45617
|
+
// src/commands/sessions/nodes/webHop.ts
|
|
45618
|
+
function webRemediation(spec, error) {
|
|
45619
|
+
const { hostname: hostname2, port } = new URL(spec.url);
|
|
45620
|
+
switch (peerErrorCode(error)) {
|
|
45621
|
+
case "ECONNREFUSED":
|
|
45622
|
+
return `nothing listening on ${port} on ${hostname2} \u2014 is ${spec.name}'s web server running (project-switch webservers)?`;
|
|
45623
|
+
case "ETIMEDOUT":
|
|
45624
|
+
return `${hostname2}:${port} did not answer \u2014 is ${spec.name} up and the port reachable from here?`;
|
|
45625
|
+
case "ENOTFOUND":
|
|
45626
|
+
return `cannot resolve ${hostname2} \u2014 fix the url with \`assist sessions nodes link ${spec.name} <url>\``;
|
|
45627
|
+
}
|
|
45628
|
+
if (error.status === 404)
|
|
45629
|
+
return `${spec.name}'s web server has no /api/health \u2014 run \`assist update\` on ${spec.name}`;
|
|
45630
|
+
return `check the link url ${spec.url} with \`assist sessions nodes\``;
|
|
45631
|
+
}
|
|
45632
|
+
async function webHop(spec, probes) {
|
|
45633
|
+
let health2;
|
|
45634
|
+
try {
|
|
45635
|
+
health2 = await probes.health(spec.url);
|
|
45636
|
+
} catch (error) {
|
|
45637
|
+
return {
|
|
45638
|
+
hop: failed2("web", describePeerError(error), webRemediation(spec, error))
|
|
45639
|
+
};
|
|
45640
|
+
}
|
|
45641
|
+
if (health2.nodeName !== spec.name)
|
|
45642
|
+
return {
|
|
45643
|
+
hop: failed2(
|
|
45644
|
+
"web",
|
|
45645
|
+
`peer reports nodeName ${health2.nodeName}, link expects ${spec.name}`,
|
|
45646
|
+
`relink with \`assist sessions nodes unlink ${spec.name}\` then \`assist sessions nodes link ${health2.nodeName} ${spec.url}\`, or set sessions.nodeName on the peer`
|
|
45647
|
+
)
|
|
45648
|
+
};
|
|
45649
|
+
return {
|
|
45650
|
+
hop: passed(
|
|
45651
|
+
"web",
|
|
45652
|
+
`${health2.nodeName} ${health2.version} (protocol ${health2.protocol})`
|
|
45653
|
+
),
|
|
45654
|
+
health: health2
|
|
45655
|
+
};
|
|
45656
|
+
}
|
|
45657
|
+
|
|
45658
|
+
// src/commands/sessions/nodes/diagnoseLink.ts
|
|
45659
|
+
function peerDaemonHop(spec, health2) {
|
|
45660
|
+
if (health2.daemon?.reachable) return passed("daemon", "reachable");
|
|
45661
|
+
return failed2(
|
|
45662
|
+
"daemon",
|
|
45663
|
+
`${spec.name}'s web server reports its daemon unreachable`,
|
|
45664
|
+
`run \`assist daemon status\` on ${spec.name}; restarting its web server starts the daemon`
|
|
45665
|
+
);
|
|
45666
|
+
}
|
|
45667
|
+
async function diagnoseLink(spec, probes) {
|
|
45668
|
+
const hops = [];
|
|
45669
|
+
const done2 = () => ({ ...spec, ok: hops.every((h) => h.ok), hops });
|
|
45670
|
+
const web3 = await webHop(spec, probes);
|
|
45671
|
+
hops.push(web3.hop);
|
|
45672
|
+
if (!web3.health) return done2();
|
|
45673
|
+
hops.push(peerDaemonHop(spec, web3.health));
|
|
45674
|
+
if (!hops.at(-1)?.ok) return done2();
|
|
45675
|
+
hops.push(await helloHop(spec, probes));
|
|
45676
|
+
if (!hops.at(-1)?.ok) return done2();
|
|
45677
|
+
hops.push(linkStateHop(spec, probes));
|
|
45678
|
+
return done2();
|
|
45679
|
+
}
|
|
45680
|
+
|
|
45681
|
+
// src/commands/sessions/nodes/findUnlinkedWindowsNode.ts
|
|
45682
|
+
var WINDOWS_NODE_URL = "http://127.0.0.1:3101";
|
|
45683
|
+
async function findUnlinkedWindowsNode(health2, platform = detectPlatform()) {
|
|
45684
|
+
if (platform !== "wsl") return void 0;
|
|
45685
|
+
try {
|
|
45686
|
+
const { nodeName } = await health2(WINDOWS_NODE_URL);
|
|
45687
|
+
if (!nodeName) return void 0;
|
|
45688
|
+
return {
|
|
45689
|
+
nodeName,
|
|
45690
|
+
url: WINDOWS_NODE_URL,
|
|
45691
|
+
command: `assist sessions nodes link ${nodeName} ${WINDOWS_NODE_URL}`
|
|
45692
|
+
};
|
|
45693
|
+
} catch {
|
|
45694
|
+
return void 0;
|
|
45695
|
+
}
|
|
45696
|
+
}
|
|
45697
|
+
|
|
45698
|
+
// src/commands/sessions/nodes/probePeerHello.ts
|
|
45699
|
+
var HELLO_TIMEOUT_MS = 5e3;
|
|
45700
|
+
async function probePeerHello(url) {
|
|
45701
|
+
let settle = () => {
|
|
45702
|
+
};
|
|
45703
|
+
const reply2 = new Promise((resolve25) => {
|
|
45704
|
+
settle = resolve25;
|
|
45705
|
+
});
|
|
45706
|
+
const socket = await connectLinkWebSocket(url, {
|
|
45707
|
+
onLine: (line) => {
|
|
45708
|
+
try {
|
|
45709
|
+
const msg = JSON.parse(line);
|
|
45710
|
+
if (msg.type === "hello") settle(msg);
|
|
45711
|
+
} catch {
|
|
45712
|
+
}
|
|
45713
|
+
},
|
|
45714
|
+
onClose: (reason4) => settle(new Error(`closed before hello reply (${reason4})`))
|
|
45715
|
+
});
|
|
45716
|
+
const timer = setTimeout(
|
|
45717
|
+
() => settle(new Error(`no hello reply within ${HELLO_TIMEOUT_MS / 1e3}s`)),
|
|
45718
|
+
HELLO_TIMEOUT_MS
|
|
45719
|
+
);
|
|
45720
|
+
socket.send(JSON.stringify(buildHello()));
|
|
45721
|
+
const result = await reply2;
|
|
45722
|
+
clearTimeout(timer);
|
|
45723
|
+
socket.close();
|
|
45724
|
+
if (result instanceof Error) throw result;
|
|
45725
|
+
return result;
|
|
45726
|
+
}
|
|
45727
|
+
|
|
45728
|
+
// src/commands/sessions/nodes/printReport.ts
|
|
45729
|
+
import chalk250 from "chalk";
|
|
45730
|
+
function printReport(report2) {
|
|
45731
|
+
if (report2.links.length === 0) {
|
|
45732
|
+
console.log(`${report2.local} has no links`);
|
|
45733
|
+
if (report2.suggestion)
|
|
45734
|
+
console.log(
|
|
45735
|
+
`A Windows node (${report2.suggestion.nodeName}) answers on ${report2.suggestion.url} but is not linked. Link it with:
|
|
45736
|
+
${report2.suggestion.command}`
|
|
45737
|
+
);
|
|
45738
|
+
return;
|
|
45739
|
+
}
|
|
45740
|
+
for (const diagnosis of report2.links) printDiagnosis(diagnosis);
|
|
45741
|
+
}
|
|
45742
|
+
function printDiagnosis(diagnosis) {
|
|
45743
|
+
console.log(`${chalk250.bold(diagnosis.name)} ${chalk250.dim(diagnosis.url)}`);
|
|
45744
|
+
for (const hop of diagnosis.hops) {
|
|
45745
|
+
const mark = hop.ok ? chalk250.green("\u2713") : chalk250.red("\u2717");
|
|
45746
|
+
console.log(` ${mark} ${hop.hop.padEnd(6)} ${hop.detail ?? hop.error}`);
|
|
45747
|
+
if (hop.remediation) console.log(` ${chalk250.yellow(hop.remediation)}`);
|
|
45748
|
+
}
|
|
45749
|
+
}
|
|
45750
|
+
|
|
45751
|
+
// src/commands/sessions/nodes/doctorNodes.ts
|
|
45752
|
+
function doctorProbes(live) {
|
|
45753
|
+
return {
|
|
45754
|
+
health: (url) => fetchPeerJson(url, "/api/health"),
|
|
45755
|
+
hello: probePeerHello,
|
|
45756
|
+
linkState: (name) => {
|
|
45757
|
+
if (!live) return "no-daemon";
|
|
45758
|
+
return live.links.find((l) => l.name === name) ?? "unknown-link";
|
|
45759
|
+
}
|
|
45760
|
+
};
|
|
45761
|
+
}
|
|
45762
|
+
async function doctorNodes(name, options2) {
|
|
45763
|
+
const specs = (loadConfig().sessions?.links ?? []).filter(
|
|
45764
|
+
(spec) => !name || spec.name === name
|
|
45765
|
+
);
|
|
45766
|
+
if (name && specs.length === 0)
|
|
45767
|
+
throw new Error(`No link named ${name}; see assist sessions nodes`);
|
|
45768
|
+
const probes = doctorProbes(await queryNodes());
|
|
45769
|
+
const report2 = { local: resolveNodeName(), links: [] };
|
|
45770
|
+
for (const spec of specs) report2.links.push(await diagnoseLink(spec, probes));
|
|
45771
|
+
if (specs.length === 0)
|
|
45772
|
+
report2.suggestion = await findUnlinkedWindowsNode(probes.health);
|
|
45773
|
+
if (report2.links.some((l) => !l.ok)) process.exitCode = 1;
|
|
45774
|
+
if (options2.json) console.log(JSON.stringify(report2, null, 2));
|
|
45775
|
+
else printReport(report2);
|
|
45776
|
+
}
|
|
45777
|
+
|
|
45382
45778
|
// src/commands/sessions/nodes/linkNode.ts
|
|
45383
|
-
import
|
|
45779
|
+
import chalk251 from "chalk";
|
|
45384
45780
|
|
|
45385
45781
|
// src/commands/sessions/nodes/writeLinks.ts
|
|
45386
45782
|
function readLinks() {
|
|
@@ -45412,46 +45808,11 @@ async function linkNode(name, url) {
|
|
|
45412
45808
|
throw new Error(`${name} is this node; link to a different node`);
|
|
45413
45809
|
const others = readLinks().filter((link3) => link3.name !== name);
|
|
45414
45810
|
await writeLinks([...others, { name, url: parseLinkUrl(url) }]);
|
|
45415
|
-
console.log(
|
|
45416
|
-
}
|
|
45417
|
-
|
|
45418
|
-
// src/commands/sessions/nodes/listNodes.ts
|
|
45419
|
-
import chalk250 from "chalk";
|
|
45420
|
-
|
|
45421
|
-
// src/commands/sessions/nodes/queryNodes.ts
|
|
45422
|
-
import { createInterface as createInterface10 } from "readline";
|
|
45423
|
-
var QUERY_TIMEOUT_MS = 3e3;
|
|
45424
|
-
async function queryNodes() {
|
|
45425
|
-
let socket;
|
|
45426
|
-
try {
|
|
45427
|
-
socket = await connectToDaemon();
|
|
45428
|
-
} catch {
|
|
45429
|
-
return void 0;
|
|
45430
|
-
}
|
|
45431
|
-
return new Promise((resolve25) => {
|
|
45432
|
-
const finish2 = (result) => {
|
|
45433
|
-
clearTimeout(timer);
|
|
45434
|
-
socket.destroy();
|
|
45435
|
-
resolve25(result);
|
|
45436
|
-
};
|
|
45437
|
-
const timer = setTimeout(() => finish2(void 0), QUERY_TIMEOUT_MS);
|
|
45438
|
-
const lines2 = createInterface10({ input: socket });
|
|
45439
|
-
lines2.on("error", () => {
|
|
45440
|
-
});
|
|
45441
|
-
lines2.on("line", (line) => {
|
|
45442
|
-
try {
|
|
45443
|
-
const data = JSON.parse(line);
|
|
45444
|
-
if (data.type === "nodes") finish2(data);
|
|
45445
|
-
} catch {
|
|
45446
|
-
}
|
|
45447
|
-
});
|
|
45448
|
-
socket.on("error", () => finish2(void 0));
|
|
45449
|
-
socket.write(`${JSON.stringify({ type: "nodes" })}
|
|
45450
|
-
`);
|
|
45451
|
-
});
|
|
45811
|
+
console.log(chalk251.green(`Linked ${name} (${parseLinkUrl(url)})`));
|
|
45452
45812
|
}
|
|
45453
45813
|
|
|
45454
45814
|
// src/commands/sessions/nodes/listNodes.ts
|
|
45815
|
+
import chalk252 from "chalk";
|
|
45455
45816
|
async function nodesReport() {
|
|
45456
45817
|
const live = await queryNodes();
|
|
45457
45818
|
if (live)
|
|
@@ -45463,43 +45824,64 @@ async function nodesReport() {
|
|
|
45463
45824
|
links: configured.map((link3) => ({ ...link3, state: "disconnected" }))
|
|
45464
45825
|
};
|
|
45465
45826
|
}
|
|
45466
|
-
var STATE_COLOURS = {
|
|
45467
|
-
connected: chalk250.green,
|
|
45468
|
-
connecting: chalk250.yellow,
|
|
45469
|
-
disconnected: chalk250.red,
|
|
45470
|
-
"version-blocked": chalk250.red
|
|
45471
|
-
};
|
|
45472
|
-
function formatLink(link3) {
|
|
45473
|
-
const colour = STATE_COLOURS[link3.state] ?? chalk250.white;
|
|
45474
|
-
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
45475
|
-
const error = link3.error ? `
|
|
45476
|
-
${chalk250.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
45477
|
-
return ` ${link3.name} ${colour(link3.state)} direct ${link3.url}${peer}${error}`;
|
|
45478
|
-
}
|
|
45479
45827
|
async function listNodes(options2) {
|
|
45480
45828
|
const report2 = await nodesReport();
|
|
45481
45829
|
if (options2.json) {
|
|
45482
45830
|
console.log(JSON.stringify(report2, null, 2));
|
|
45483
45831
|
return;
|
|
45484
45832
|
}
|
|
45485
|
-
console.log(`${report2.local} ${
|
|
45833
|
+
console.log(`${report2.local} ${chalk252.dim("(this node)")}`);
|
|
45486
45834
|
if (!report2.daemonRunning)
|
|
45487
|
-
console.log(
|
|
45488
|
-
if (report2.links.length === 0) console.log(
|
|
45835
|
+
console.log(chalk252.dim(" daemon not running; showing configured links"));
|
|
45836
|
+
if (report2.links.length === 0) console.log(chalk252.dim(" no links"));
|
|
45489
45837
|
for (const link3 of report2.links) console.log(formatLink(link3));
|
|
45490
45838
|
}
|
|
45491
45839
|
|
|
45840
|
+
// src/commands/sessions/nodes/nodeLogs.ts
|
|
45841
|
+
async function fetchLogTail(name, lines2) {
|
|
45842
|
+
if (name === resolveNodeName())
|
|
45843
|
+
return {
|
|
45844
|
+
nodeName: name,
|
|
45845
|
+
path: daemonPaths.log,
|
|
45846
|
+
lines: readLogTail(daemonPaths.log, lines2)
|
|
45847
|
+
};
|
|
45848
|
+
const link3 = loadConfig().sessions?.links?.find((l) => l.name === name);
|
|
45849
|
+
if (!link3)
|
|
45850
|
+
throw new Error(`No link named ${name}; see assist sessions nodes`);
|
|
45851
|
+
try {
|
|
45852
|
+
return await fetchPeerJson(
|
|
45853
|
+
link3.url,
|
|
45854
|
+
`/api/daemon-log?lines=${lines2}`
|
|
45855
|
+
);
|
|
45856
|
+
} catch (error) {
|
|
45857
|
+
throw new Error(
|
|
45858
|
+
`Could not read ${name}'s daemon log: ${describePeerError(error)}. Run assist sessions nodes doctor ${name}`
|
|
45859
|
+
);
|
|
45860
|
+
}
|
|
45861
|
+
}
|
|
45862
|
+
async function nodeLogs(name, options2) {
|
|
45863
|
+
const lines2 = Number.parseInt(options2.lines, 10);
|
|
45864
|
+
if (!Number.isInteger(lines2) || lines2 < 1)
|
|
45865
|
+
throw new Error(`-n must be a positive integer, got ${options2.lines}`);
|
|
45866
|
+
const tail = await fetchLogTail(name, lines2);
|
|
45867
|
+
if (options2.json) {
|
|
45868
|
+
console.log(JSON.stringify(tail, null, 2));
|
|
45869
|
+
return;
|
|
45870
|
+
}
|
|
45871
|
+
for (const line of tail.lines) console.log(line);
|
|
45872
|
+
}
|
|
45873
|
+
|
|
45492
45874
|
// src/commands/sessions/nodes/unlinkNode.ts
|
|
45493
|
-
import
|
|
45875
|
+
import chalk253 from "chalk";
|
|
45494
45876
|
async function unlinkNode(name) {
|
|
45495
45877
|
const links2 = readLinks();
|
|
45496
45878
|
const remaining = links2.filter((link3) => link3.name !== name);
|
|
45497
45879
|
if (remaining.length === links2.length) {
|
|
45498
|
-
console.log(
|
|
45880
|
+
console.log(chalk253.yellow(`No link named ${name}`));
|
|
45499
45881
|
return;
|
|
45500
45882
|
}
|
|
45501
45883
|
await writeLinks(remaining);
|
|
45502
|
-
console.log(
|
|
45884
|
+
console.log(chalk253.green(`Unlinked ${name}`));
|
|
45503
45885
|
}
|
|
45504
45886
|
|
|
45505
45887
|
// src/commands/sessions/nodes/registerNodes.ts
|
|
@@ -45509,6 +45891,14 @@ function registerNodes(sessions) {
|
|
|
45509
45891
|
"Link a peer node by its web server URL (name must match the peer's sessions.nodeName)"
|
|
45510
45892
|
).action(linkNode);
|
|
45511
45893
|
cmd.command("unlink <name>").description("Remove a linked node").action(unlinkNode);
|
|
45894
|
+
cmd.command("doctor [name]").description(
|
|
45895
|
+
"Probe each hop of every link (or one) in order and stop at the first failure with a remediation"
|
|
45896
|
+
).option("--json", "Output as JSON").action(
|
|
45897
|
+
(name, _options, command) => doctorNodes(name, command.optsWithGlobals())
|
|
45898
|
+
);
|
|
45899
|
+
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(
|
|
45900
|
+
(name, _options, command) => nodeLogs(name, command.optsWithGlobals())
|
|
45901
|
+
);
|
|
45512
45902
|
configHelp(cmd, nodesConfigHelp);
|
|
45513
45903
|
}
|
|
45514
45904
|
|
|
@@ -45545,7 +45935,7 @@ async function renameSession(title) {
|
|
|
45545
45935
|
|
|
45546
45936
|
// src/commands/sessions/summarise.ts
|
|
45547
45937
|
import * as fs58 from "fs";
|
|
45548
|
-
import
|
|
45938
|
+
import chalk254 from "chalk";
|
|
45549
45939
|
|
|
45550
45940
|
// src/commands/sessions/summarise/shared.ts
|
|
45551
45941
|
import * as fs57 from "fs";
|
|
@@ -45604,22 +45994,22 @@ ${firstMessage}`);
|
|
|
45604
45994
|
async function summarise2(options2) {
|
|
45605
45995
|
const files = await discoverSessionFiles();
|
|
45606
45996
|
if (files.length === 0) {
|
|
45607
|
-
console.log(
|
|
45997
|
+
console.log(chalk254.yellow("No sessions found."));
|
|
45608
45998
|
return;
|
|
45609
45999
|
}
|
|
45610
46000
|
const toProcess = selectCandidates(files, options2);
|
|
45611
46001
|
if (toProcess.length === 0) {
|
|
45612
|
-
console.log(
|
|
46002
|
+
console.log(chalk254.green("All sessions already summarised."));
|
|
45613
46003
|
return;
|
|
45614
46004
|
}
|
|
45615
46005
|
console.log(
|
|
45616
|
-
|
|
46006
|
+
chalk254.cyan(
|
|
45617
46007
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
45618
46008
|
)
|
|
45619
46009
|
);
|
|
45620
|
-
const { succeeded, failed:
|
|
46010
|
+
const { succeeded, failed: failed3 } = processSessions(toProcess);
|
|
45621
46011
|
console.log(
|
|
45622
|
-
|
|
46012
|
+
chalk254.green(`Done: ${succeeded} summarised`) + (failed3 > 0 ? chalk254.yellow(`, ${failed3} skipped`) : "")
|
|
45623
46013
|
);
|
|
45624
46014
|
}
|
|
45625
46015
|
function selectCandidates(files, options2) {
|
|
@@ -45636,23 +46026,23 @@ function selectCandidates(files, options2) {
|
|
|
45636
46026
|
}
|
|
45637
46027
|
function processSessions(files) {
|
|
45638
46028
|
let succeeded = 0;
|
|
45639
|
-
let
|
|
46029
|
+
let failed3 = 0;
|
|
45640
46030
|
for (let i = 0; i < files.length; i++) {
|
|
45641
46031
|
const file = files[i];
|
|
45642
|
-
process.stdout.write(
|
|
46032
|
+
process.stdout.write(chalk254.dim(` [${i + 1}/${files.length}] `));
|
|
45643
46033
|
const summary = summariseSession(file);
|
|
45644
46034
|
if (summary) {
|
|
45645
46035
|
writeSummary(file, summary);
|
|
45646
46036
|
succeeded++;
|
|
45647
|
-
process.stdout.write(`${
|
|
46037
|
+
process.stdout.write(`${chalk254.green("\u2713")} ${summary}
|
|
45648
46038
|
`);
|
|
45649
46039
|
} else {
|
|
45650
|
-
|
|
45651
|
-
process.stdout.write(` ${
|
|
46040
|
+
failed3++;
|
|
46041
|
+
process.stdout.write(` ${chalk254.yellow("skip")}
|
|
45652
46042
|
`);
|
|
45653
46043
|
}
|
|
45654
46044
|
}
|
|
45655
|
-
return { succeeded, failed:
|
|
46045
|
+
return { succeeded, failed: failed3 };
|
|
45656
46046
|
}
|
|
45657
46047
|
|
|
45658
46048
|
// src/commands/sessions/registerSessions.ts
|
|
@@ -45676,10 +46066,10 @@ function registerSessions(program2) {
|
|
|
45676
46066
|
}
|
|
45677
46067
|
|
|
45678
46068
|
// src/reportCliError.ts
|
|
45679
|
-
import
|
|
46069
|
+
import chalk255 from "chalk";
|
|
45680
46070
|
function reportCliError(error) {
|
|
45681
46071
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
45682
|
-
console.error(
|
|
46072
|
+
console.error(chalk255.red(error.message));
|
|
45683
46073
|
} else {
|
|
45684
46074
|
console.error(error);
|
|
45685
46075
|
}
|