@staff0rd/assist 0.762.0 → 0.764.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 +2 -1
- package/dist/commands/sessions/web/bundle.js +422 -422
- package/dist/index.js +330 -253
- 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.764.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1792,9 +1792,9 @@ var daemonPaths = {
|
|
|
1792
1792
|
|
|
1793
1793
|
// src/commands/sessions/daemon/connectToDaemon.ts
|
|
1794
1794
|
function connectToDaemon() {
|
|
1795
|
-
return new Promise((
|
|
1795
|
+
return new Promise((resolve27, reject) => {
|
|
1796
1796
|
const socket = net.connect(daemonPaths.socket);
|
|
1797
|
-
socket.once("connect", () =>
|
|
1797
|
+
socket.once("connect", () => resolve27(socket));
|
|
1798
1798
|
socket.once("error", reject);
|
|
1799
1799
|
});
|
|
1800
1800
|
}
|
|
@@ -2112,7 +2112,7 @@ ${failed3.length} script(s) failed:`);
|
|
|
2112
2112
|
}
|
|
2113
2113
|
}
|
|
2114
2114
|
function runEntry(entry) {
|
|
2115
|
-
return new Promise((
|
|
2115
|
+
return new Promise((resolve27) => {
|
|
2116
2116
|
const startTime = Date.now();
|
|
2117
2117
|
const child = spawnCommand(
|
|
2118
2118
|
entry.fullCommand,
|
|
@@ -2124,7 +2124,7 @@ function runEntry(entry) {
|
|
|
2124
2124
|
child.on("close", (code) => {
|
|
2125
2125
|
const exitCode = code ?? 1;
|
|
2126
2126
|
flushIfFailed(exitCode, chunks);
|
|
2127
|
-
|
|
2127
|
+
resolve27({
|
|
2128
2128
|
script: entry.name,
|
|
2129
2129
|
code: exitCode,
|
|
2130
2130
|
durationMs: Date.now() - startTime
|
|
@@ -2974,7 +2974,7 @@ function parsePreviewDecision(line, requestId) {
|
|
|
2974
2974
|
|
|
2975
2975
|
// src/commands/sessions/shared/requestPreviewDecision.ts
|
|
2976
2976
|
function requestPreviewDecision(request) {
|
|
2977
|
-
return new Promise((
|
|
2977
|
+
return new Promise((resolve27, reject) => {
|
|
2978
2978
|
connectToDaemon().then((socket) => {
|
|
2979
2979
|
let settled = false;
|
|
2980
2980
|
const finish2 = (error, decision) => {
|
|
@@ -2982,7 +2982,7 @@ function requestPreviewDecision(request) {
|
|
|
2982
2982
|
settled = true;
|
|
2983
2983
|
socket.destroy();
|
|
2984
2984
|
if (error) reject(error);
|
|
2985
|
-
else
|
|
2985
|
+
else resolve27(decision);
|
|
2986
2986
|
};
|
|
2987
2987
|
readSocketLines(socket, (line) => {
|
|
2988
2988
|
const incoming = parsePreviewDecision(line, request.requestId);
|
|
@@ -7225,8 +7225,8 @@ function spawnInherit(command, args, options2 = {}) {
|
|
|
7225
7225
|
env: { ...env, ...options2.env },
|
|
7226
7226
|
cwd: options2.cwd
|
|
7227
7227
|
});
|
|
7228
|
-
const done2 = new Promise((
|
|
7229
|
-
child.on("close", (code) =>
|
|
7228
|
+
const done2 = new Promise((resolve27, reject) => {
|
|
7229
|
+
child.on("close", (code) => resolve27(code ?? 0));
|
|
7230
7230
|
child.on("error", reject);
|
|
7231
7231
|
});
|
|
7232
7232
|
return { child, done: done2 };
|
|
@@ -7658,7 +7658,7 @@ Failed to launch Claude for ${context}: ${message3}`)
|
|
|
7658
7658
|
// src/commands/sessions/daemon/sendToDaemon.ts
|
|
7659
7659
|
var WRITE_TIMEOUT_MS = 500;
|
|
7660
7660
|
function sendToDaemon(message3) {
|
|
7661
|
-
return new Promise((
|
|
7661
|
+
return new Promise((resolve27, reject) => {
|
|
7662
7662
|
connectToDaemon().then((socket) => {
|
|
7663
7663
|
const timer = setTimeout(() => {
|
|
7664
7664
|
socket.destroy();
|
|
@@ -7672,7 +7672,7 @@ function sendToDaemon(message3) {
|
|
|
7672
7672
|
`, () => {
|
|
7673
7673
|
clearTimeout(timer);
|
|
7674
7674
|
socket.end();
|
|
7675
|
-
|
|
7675
|
+
resolve27();
|
|
7676
7676
|
});
|
|
7677
7677
|
}, reject);
|
|
7678
7678
|
});
|
|
@@ -7681,7 +7681,7 @@ function sendToDaemon(message3) {
|
|
|
7681
7681
|
// src/commands/sessions/daemon/sendToDaemonAwaitAck.ts
|
|
7682
7682
|
var ACK_TIMEOUT_MS = 1e3;
|
|
7683
7683
|
function sendToDaemonAwaitAck(message3) {
|
|
7684
|
-
return new Promise((
|
|
7684
|
+
return new Promise((resolve27, reject) => {
|
|
7685
7685
|
connectToDaemon().then((socket) => {
|
|
7686
7686
|
let settled = false;
|
|
7687
7687
|
const finish2 = (error) => {
|
|
@@ -7690,7 +7690,7 @@ function sendToDaemonAwaitAck(message3) {
|
|
|
7690
7690
|
clearTimeout(timer);
|
|
7691
7691
|
socket.destroy();
|
|
7692
7692
|
if (error) reject(error);
|
|
7693
|
-
else
|
|
7693
|
+
else resolve27();
|
|
7694
7694
|
};
|
|
7695
7695
|
const timer = setTimeout(
|
|
7696
7696
|
() => finish2(new Error("timed out awaiting daemon ack")),
|
|
@@ -7781,7 +7781,7 @@ async function deliverReliably(sessionId, status2, payload) {
|
|
|
7781
7781
|
}
|
|
7782
7782
|
}
|
|
7783
7783
|
function sleep(ms) {
|
|
7784
|
-
return new Promise((
|
|
7784
|
+
return new Promise((resolve27) => setTimeout(resolve27, ms));
|
|
7785
7785
|
}
|
|
7786
7786
|
function describeError(error) {
|
|
7787
7787
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -8232,6 +8232,7 @@ var activitySchema = z7.object({
|
|
|
8232
8232
|
phaseName: z7.string().optional(),
|
|
8233
8233
|
totalPhases: z7.number().optional(),
|
|
8234
8234
|
claudeSessionId: z7.string().optional(),
|
|
8235
|
+
watchState: z7.enum(["waiting", "updating"]).optional(),
|
|
8235
8236
|
startedAt: z7.number()
|
|
8236
8237
|
});
|
|
8237
8238
|
function activityPath(sessionId) {
|
|
@@ -10756,7 +10757,7 @@ function spawnDaemon(reason4) {
|
|
|
10756
10757
|
child.unref();
|
|
10757
10758
|
}
|
|
10758
10759
|
function delay(ms) {
|
|
10759
|
-
return new Promise((
|
|
10760
|
+
return new Promise((resolve27) => setTimeout(resolve27, ms));
|
|
10760
10761
|
}
|
|
10761
10762
|
|
|
10762
10763
|
// src/commands/sessions/daemon/originForCwd.ts
|
|
@@ -10798,10 +10799,10 @@ function gitInvocation(cwd, args) {
|
|
|
10798
10799
|
}
|
|
10799
10800
|
function git(cwd, args) {
|
|
10800
10801
|
const { file, argv, options: options2 } = gitInvocation(cwd, args);
|
|
10801
|
-
return new Promise((
|
|
10802
|
+
return new Promise((resolve27, reject) => {
|
|
10802
10803
|
execFile2(file, argv, options2, (error, stdout) => {
|
|
10803
10804
|
if (error) reject(error);
|
|
10804
|
-
else
|
|
10805
|
+
else resolve27(stdout.toString());
|
|
10805
10806
|
});
|
|
10806
10807
|
});
|
|
10807
10808
|
}
|
|
@@ -11060,7 +11061,7 @@ var defaultDeps = {
|
|
|
11060
11061
|
serve: async (args) => {
|
|
11061
11062
|
await runTailscale(args);
|
|
11062
11063
|
},
|
|
11063
|
-
sleep: (ms) => new Promise((
|
|
11064
|
+
sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
|
|
11064
11065
|
httpsPort: tailnetHttpsPort
|
|
11065
11066
|
};
|
|
11066
11067
|
async function ensureTailscaleServe(port, deps2 = {}) {
|
|
@@ -11467,12 +11468,12 @@ async function loadVisibleItems(req) {
|
|
|
11467
11468
|
|
|
11468
11469
|
// src/commands/backlog/web/parseStatusBody.ts
|
|
11469
11470
|
function readBody(req) {
|
|
11470
|
-
return new Promise((
|
|
11471
|
+
return new Promise((resolve27, reject) => {
|
|
11471
11472
|
let body = "";
|
|
11472
11473
|
req.on("data", (chunk) => {
|
|
11473
11474
|
body += chunk.toString();
|
|
11474
11475
|
});
|
|
11475
|
-
req.on("end", () =>
|
|
11476
|
+
req.on("end", () => resolve27(body));
|
|
11476
11477
|
req.on("error", reject);
|
|
11477
11478
|
});
|
|
11478
11479
|
}
|
|
@@ -13581,11 +13582,11 @@ async function queryNodes() {
|
|
|
13581
13582
|
} catch {
|
|
13582
13583
|
return void 0;
|
|
13583
13584
|
}
|
|
13584
|
-
return new Promise((
|
|
13585
|
+
return new Promise((resolve27) => {
|
|
13585
13586
|
const finish2 = (result) => {
|
|
13586
13587
|
clearTimeout(timer);
|
|
13587
13588
|
socket.destroy();
|
|
13588
|
-
|
|
13589
|
+
resolve27(result);
|
|
13589
13590
|
};
|
|
13590
13591
|
const timer = setTimeout(() => finish2(void 0), QUERY_TIMEOUT_MS);
|
|
13591
13592
|
const lines2 = createInterface5({ input: socket });
|
|
@@ -15033,20 +15034,26 @@ import {
|
|
|
15033
15034
|
} from "http";
|
|
15034
15035
|
import { request as httpsRequest } from "https";
|
|
15035
15036
|
|
|
15036
|
-
// src/commands/sessions/web/peerTimeoutMs.ts
|
|
15037
|
-
var peerTimeoutMs = 2e4;
|
|
15038
|
-
|
|
15039
15037
|
// src/commands/sessions/web/boundUpstream.ts
|
|
15040
|
-
function boundUpstream(upstream, res) {
|
|
15038
|
+
function boundUpstream(upstream, res, timeoutMs) {
|
|
15041
15039
|
upstream.setTimeout(
|
|
15042
|
-
|
|
15043
|
-
() => upstream.destroy(new Error(`no response after ${
|
|
15040
|
+
timeoutMs,
|
|
15041
|
+
() => upstream.destroy(new Error(`no response after ${timeoutMs}ms`))
|
|
15044
15042
|
);
|
|
15045
15043
|
res.on("close", () => {
|
|
15046
15044
|
if (!res.writableFinished) upstream.destroy();
|
|
15047
15045
|
});
|
|
15048
15046
|
}
|
|
15049
15047
|
|
|
15048
|
+
// src/commands/sessions/web/peerTimeoutMs.ts
|
|
15049
|
+
var peerTimeoutMs = 2e4;
|
|
15050
|
+
|
|
15051
|
+
// src/commands/sessions/web/peerTimeoutFor.ts
|
|
15052
|
+
var ASSIST_UPDATE_DURATION_MS = 6e5;
|
|
15053
|
+
function peerTimeoutFor(pathname) {
|
|
15054
|
+
return pathname === "/api/self-update" ? ASSIST_UPDATE_DURATION_MS : peerTimeoutMs;
|
|
15055
|
+
}
|
|
15056
|
+
|
|
15050
15057
|
// src/commands/sessions/web/isQuietPoll.ts
|
|
15051
15058
|
var POLLED_PATHS = /* @__PURE__ */ new Set(["/api/git-status"]);
|
|
15052
15059
|
function isQuietPoll(pathname, status2) {
|
|
@@ -15071,7 +15078,7 @@ function forwardToPeer(req, res, node, url) {
|
|
|
15071
15078
|
const label2 = `link ${node} http: ${req.method} ${url.pathname} trace=${traceId}`;
|
|
15072
15079
|
const log2 = (outcome) => console.log(`${label2} -> ${outcome} (${Date.now() - started}ms)`);
|
|
15073
15080
|
const send = url.protocol === "https:" ? httpsRequest : httpRequest;
|
|
15074
|
-
return new Promise((
|
|
15081
|
+
return new Promise((resolve27) => {
|
|
15075
15082
|
const upstream = send(
|
|
15076
15083
|
url,
|
|
15077
15084
|
{
|
|
@@ -15083,9 +15090,9 @@ function forwardToPeer(req, res, node, url) {
|
|
|
15083
15090
|
[TRACE_HEADER]: traceId
|
|
15084
15091
|
}
|
|
15085
15092
|
},
|
|
15086
|
-
(peer) => relayPeerResponse(peer, res, url.pathname, log2,
|
|
15093
|
+
(peer) => relayPeerResponse(peer, res, url.pathname, log2, resolve27)
|
|
15087
15094
|
);
|
|
15088
|
-
boundUpstream(upstream, res);
|
|
15095
|
+
boundUpstream(upstream, res, peerTimeoutFor(url.pathname));
|
|
15089
15096
|
upstream.on("error", (error) => {
|
|
15090
15097
|
log2(`failed: ${error.message}`);
|
|
15091
15098
|
if (res.headersSent) res.destroy();
|
|
@@ -15093,7 +15100,7 @@ function forwardToPeer(req, res, node, url) {
|
|
|
15093
15100
|
respondJson(res, 502, {
|
|
15094
15101
|
error: `${node} unreachable: ${error.message}`
|
|
15095
15102
|
});
|
|
15096
|
-
|
|
15103
|
+
resolve27();
|
|
15097
15104
|
});
|
|
15098
15105
|
req.pipe(upstream);
|
|
15099
15106
|
});
|
|
@@ -15673,17 +15680,17 @@ async function stopDaemon() {
|
|
|
15673
15680
|
}
|
|
15674
15681
|
}
|
|
15675
15682
|
function closedBeforeTimeout(socket) {
|
|
15676
|
-
return new Promise((
|
|
15683
|
+
return new Promise((resolve27) => {
|
|
15677
15684
|
const timer = setTimeout(() => {
|
|
15678
15685
|
socket.destroy();
|
|
15679
|
-
|
|
15686
|
+
resolve27(false);
|
|
15680
15687
|
}, STOP_TIMEOUT_MS);
|
|
15681
15688
|
socket.resume();
|
|
15682
15689
|
socket.on("error", () => {
|
|
15683
15690
|
});
|
|
15684
15691
|
socket.once("close", () => {
|
|
15685
15692
|
clearTimeout(timer);
|
|
15686
|
-
|
|
15693
|
+
resolve27(true);
|
|
15687
15694
|
});
|
|
15688
15695
|
});
|
|
15689
15696
|
}
|
|
@@ -15697,6 +15704,11 @@ async function restartDaemon() {
|
|
|
15697
15704
|
);
|
|
15698
15705
|
}
|
|
15699
15706
|
|
|
15707
|
+
// src/commands/sessions/web/linkedRequester.ts
|
|
15708
|
+
function linkedRequester(req) {
|
|
15709
|
+
return `from=${req.headers["x-assist-linked-from"] ?? "local"} trace=${req.headers[TRACE_HEADER] ?? "none"}`;
|
|
15710
|
+
}
|
|
15711
|
+
|
|
15700
15712
|
// src/commands/sessions/web/restartMenu/reExecWebServer.ts
|
|
15701
15713
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
15702
15714
|
function resolveExecve() {
|
|
@@ -15735,11 +15747,9 @@ async function restartWeb(req, res, deps2 = {}) {
|
|
|
15735
15747
|
respondJson(res, 400, { error: "Invalid target" });
|
|
15736
15748
|
return;
|
|
15737
15749
|
}
|
|
15738
|
-
console.log(
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
await new Promise((resolve26) => {
|
|
15742
|
-
res.once("finish", resolve26);
|
|
15750
|
+
console.log(`restart ${target} ${linkedRequester(req)}`);
|
|
15751
|
+
await new Promise((resolve27) => {
|
|
15752
|
+
res.once("finish", resolve27);
|
|
15743
15753
|
respondJson(res, 200, { ok: true });
|
|
15744
15754
|
});
|
|
15745
15755
|
await performRestart(target, deps2);
|
|
@@ -15861,9 +15871,11 @@ async function runAssistUpdate() {
|
|
|
15861
15871
|
if (result.exitCode !== 0)
|
|
15862
15872
|
throw new Error(`assist update exited with code ${result.exitCode}`);
|
|
15863
15873
|
}
|
|
15864
|
-
async function selfUpdate(
|
|
15874
|
+
async function selfUpdate(req, res, deps2 = {}) {
|
|
15865
15875
|
const { runUpdate = runAssistUpdate, ...restartDeps } = deps2;
|
|
15866
|
-
console.log(
|
|
15876
|
+
console.log(
|
|
15877
|
+
`self-update: requested ${linkedRequester(req)}; running assist update`
|
|
15878
|
+
);
|
|
15867
15879
|
try {
|
|
15868
15880
|
await runUpdate();
|
|
15869
15881
|
} catch (error) {
|
|
@@ -15873,8 +15885,8 @@ async function selfUpdate(_req, res, deps2 = {}) {
|
|
|
15873
15885
|
return;
|
|
15874
15886
|
}
|
|
15875
15887
|
console.log("self-update: updated; restarting daemon and web server");
|
|
15876
|
-
await new Promise((
|
|
15877
|
-
res.once("finish",
|
|
15888
|
+
await new Promise((resolve27) => {
|
|
15889
|
+
res.once("finish", resolve27);
|
|
15878
15890
|
respondJson(res, 200, { ok: true });
|
|
15879
15891
|
});
|
|
15880
15892
|
await performRestart("both", restartDeps);
|
|
@@ -15975,14 +15987,14 @@ function linkWebSocketUrl(url) {
|
|
|
15975
15987
|
return target.toString();
|
|
15976
15988
|
}
|
|
15977
15989
|
function connectLinkWebSocket(url, handlers) {
|
|
15978
|
-
return new Promise((
|
|
15990
|
+
return new Promise((resolve27, reject) => {
|
|
15979
15991
|
const ws = new WebSocket(linkWebSocketUrl(url), {
|
|
15980
15992
|
handshakeTimeout: HANDSHAKE_TIMEOUT_MS
|
|
15981
15993
|
});
|
|
15982
15994
|
let open = false;
|
|
15983
15995
|
ws.on("open", () => {
|
|
15984
15996
|
open = true;
|
|
15985
|
-
|
|
15997
|
+
resolve27({
|
|
15986
15998
|
send: (line) => {
|
|
15987
15999
|
if (ws.readyState !== WebSocket.OPEN) return false;
|
|
15988
16000
|
ws.send(line);
|
|
@@ -16008,8 +16020,8 @@ var HELLO_TIMEOUT_MS = 5e3;
|
|
|
16008
16020
|
async function probePeerHello(url) {
|
|
16009
16021
|
let settle = () => {
|
|
16010
16022
|
};
|
|
16011
|
-
const reply2 = new Promise((
|
|
16012
|
-
settle =
|
|
16023
|
+
const reply2 = new Promise((resolve27) => {
|
|
16024
|
+
settle = resolve27;
|
|
16013
16025
|
});
|
|
16014
16026
|
const socket = await connectLinkWebSocket(url, {
|
|
16015
16027
|
onLine: (line) => {
|
|
@@ -19048,12 +19060,12 @@ function hasSubcommands(helpText) {
|
|
|
19048
19060
|
// src/commands/permitCliReads/runHelp.ts
|
|
19049
19061
|
import { exec as exec2 } from "child_process";
|
|
19050
19062
|
function runHelp(args) {
|
|
19051
|
-
return new Promise((
|
|
19063
|
+
return new Promise((resolve27) => {
|
|
19052
19064
|
exec2(
|
|
19053
19065
|
`${args.join(" ")} --help`,
|
|
19054
19066
|
{ encoding: "utf8", timeout: 3e4 },
|
|
19055
19067
|
(_err, stdout, stderr) => {
|
|
19056
|
-
|
|
19068
|
+
resolve27(stdout || stderr || "");
|
|
19057
19069
|
}
|
|
19058
19070
|
);
|
|
19059
19071
|
});
|
|
@@ -19690,9 +19702,9 @@ function codexStatusFor(event, autoDecided) {
|
|
|
19690
19702
|
|
|
19691
19703
|
// src/commands/codexHook/reportCodexStatus.ts
|
|
19692
19704
|
async function reportCodexStatus(event, autoDecided) {
|
|
19693
|
-
const
|
|
19694
|
-
if (!
|
|
19695
|
-
await setSessionStatus(
|
|
19705
|
+
const report = codexStatusFor(event, autoDecided);
|
|
19706
|
+
if (!report) return;
|
|
19707
|
+
await setSessionStatus(report.status, { source: report.source, ack: true });
|
|
19696
19708
|
}
|
|
19697
19709
|
|
|
19698
19710
|
// src/commands/codexHook.ts
|
|
@@ -23567,8 +23579,8 @@ function printRepoAuthorBreakdown(repos2) {
|
|
|
23567
23579
|
}
|
|
23568
23580
|
|
|
23569
23581
|
// src/commands/github/printCommitsReport.ts
|
|
23570
|
-
function printCommitsReport(
|
|
23571
|
-
const { org, since, totalRepos, repos: repos2, committers, repoAuthors } =
|
|
23582
|
+
function printCommitsReport(report) {
|
|
23583
|
+
const { org, since, totalRepos, repos: repos2, committers, repoAuthors } = report;
|
|
23572
23584
|
const scope = repos2.length < totalRepos ? ` (top ${repos2.length} of ${totalRepos} repos)` : "";
|
|
23573
23585
|
console.log(`Top repos by commits in ${org} since ${since}${scope}:
|
|
23574
23586
|
`);
|
|
@@ -23597,7 +23609,7 @@ function commits(org, options2) {
|
|
|
23597
23609
|
name: repo.name,
|
|
23598
23610
|
authors: fetchRepoCommitAuthors(org, repo.name, since)
|
|
23599
23611
|
}));
|
|
23600
|
-
const
|
|
23612
|
+
const report = {
|
|
23601
23613
|
org,
|
|
23602
23614
|
since: sinceDate,
|
|
23603
23615
|
totalRepos: allRepos.length,
|
|
@@ -23606,11 +23618,11 @@ function commits(org, options2) {
|
|
|
23606
23618
|
repoAuthors
|
|
23607
23619
|
};
|
|
23608
23620
|
if (options2.json) {
|
|
23609
|
-
console.log(JSON.stringify(
|
|
23621
|
+
console.log(JSON.stringify(report, null, 2));
|
|
23610
23622
|
} else if (repos2.length === 0) {
|
|
23611
23623
|
console.log(`No commits found in ${org} since ${sinceDate}.`);
|
|
23612
23624
|
} else {
|
|
23613
|
-
printCommitsReport(
|
|
23625
|
+
printCommitsReport(report);
|
|
23614
23626
|
}
|
|
23615
23627
|
}
|
|
23616
23628
|
|
|
@@ -25961,7 +25973,7 @@ function placedByDaemon() {
|
|
|
25961
25973
|
function seed(worktreePath, clone) {
|
|
25962
25974
|
console.log(`Preparing ${worktreePath}\u2026`);
|
|
25963
25975
|
return new Promise(
|
|
25964
|
-
(
|
|
25976
|
+
(resolve27) => seedWorktree(worktreePath, clone, resolve27)
|
|
25965
25977
|
);
|
|
25966
25978
|
}
|
|
25967
25979
|
async function moveToPrCheckoutTree() {
|
|
@@ -27138,25 +27150,25 @@ function isVisibleText(t) {
|
|
|
27138
27150
|
return /[a-zA-Z]{3,}/.test(t);
|
|
27139
27151
|
}
|
|
27140
27152
|
var isHashtag = (t) => /^#[A-Za-z0-9_]+$/.test(t);
|
|
27141
|
-
function collectRscText(v,
|
|
27153
|
+
function collectRscText(v, resolve27, sink3, seen) {
|
|
27142
27154
|
if (v == null) return;
|
|
27143
27155
|
if (typeof v === "string") {
|
|
27144
27156
|
if (isRscRef(v)) {
|
|
27145
27157
|
if (!seen.has(v)) {
|
|
27146
27158
|
seen.add(v);
|
|
27147
|
-
collectRscText(
|
|
27159
|
+
collectRscText(resolve27(v), resolve27, sink3, seen);
|
|
27148
27160
|
}
|
|
27149
27161
|
} else if (isHashtag(v)) sink3.hashtags.push(v);
|
|
27150
27162
|
else if (isVisibleText(v)) sink3.text.push(v);
|
|
27151
27163
|
return;
|
|
27152
27164
|
}
|
|
27153
27165
|
if (Array.isArray(v)) {
|
|
27154
|
-
for (const x of v) collectRscText(x,
|
|
27166
|
+
for (const x of v) collectRscText(x, resolve27, sink3, seen);
|
|
27155
27167
|
return;
|
|
27156
27168
|
}
|
|
27157
27169
|
if (typeof v === "object") {
|
|
27158
27170
|
for (const val of Object.values(v)) {
|
|
27159
|
-
collectRscText(val,
|
|
27171
|
+
collectRscText(val, resolve27, sink3, seen);
|
|
27160
27172
|
}
|
|
27161
27173
|
}
|
|
27162
27174
|
}
|
|
@@ -27188,7 +27200,7 @@ function visitObjects(root2, fn) {
|
|
|
27188
27200
|
}
|
|
27189
27201
|
}
|
|
27190
27202
|
}
|
|
27191
|
-
function buildMentionMap(rows,
|
|
27203
|
+
function buildMentionMap(rows, resolve27) {
|
|
27192
27204
|
const map = /* @__PURE__ */ new Map();
|
|
27193
27205
|
visitObjects(rows, (o) => {
|
|
27194
27206
|
const url = profileActionUrl(o);
|
|
@@ -27196,7 +27208,7 @@ function buildMentionMap(rows, resolve26) {
|
|
|
27196
27208
|
const slug2 = slugFromProfileUrl(url);
|
|
27197
27209
|
if (!slug2 || map.has(slug2)) return;
|
|
27198
27210
|
const sink3 = { text: [], hashtags: [] };
|
|
27199
|
-
collectRscText(o.children,
|
|
27211
|
+
collectRscText(o.children, resolve27, sink3, /* @__PURE__ */ new Set());
|
|
27200
27212
|
const name = sink3.text.join(" ").replace(/\s+/g, " ").trim();
|
|
27201
27213
|
map.set(slug2, name ? { slug: slug2, name, url } : { slug: slug2, url });
|
|
27202
27214
|
});
|
|
@@ -27282,10 +27294,10 @@ function buildPost(raw, mentionMap, author) {
|
|
|
27282
27294
|
|
|
27283
27295
|
// src/commands/netcap/walkPostRow.ts
|
|
27284
27296
|
var isCommentary = (o) => asObject(o.viewTrackingSpecs)?.viewName === "feed-commentary";
|
|
27285
|
-
function walkPostRow(v,
|
|
27297
|
+
function walkPostRow(v, resolve27, raw) {
|
|
27286
27298
|
if (v == null || typeof v !== "object") return;
|
|
27287
27299
|
if (Array.isArray(v)) {
|
|
27288
|
-
for (const x of v) walkPostRow(x,
|
|
27300
|
+
for (const x of v) walkPostRow(x, resolve27, raw);
|
|
27289
27301
|
return;
|
|
27290
27302
|
}
|
|
27291
27303
|
const o = v;
|
|
@@ -27299,9 +27311,9 @@ function walkPostRow(v, resolve26, raw) {
|
|
|
27299
27311
|
}
|
|
27300
27312
|
if (isCommentary(o)) {
|
|
27301
27313
|
const sink3 = { text: raw.text, hashtags: raw.hashtags };
|
|
27302
|
-
collectRscText(o.children,
|
|
27314
|
+
collectRscText(o.children, resolve27, sink3, /* @__PURE__ */ new Set());
|
|
27303
27315
|
}
|
|
27304
|
-
for (const val of Object.values(o)) walkPostRow(val,
|
|
27316
|
+
for (const val of Object.values(o)) walkPostRow(val, resolve27, raw);
|
|
27305
27317
|
}
|
|
27306
27318
|
|
|
27307
27319
|
// src/commands/netcap/extractLinkedInPosts.ts
|
|
@@ -27315,8 +27327,8 @@ function findCommentaryRows(rows) {
|
|
|
27315
27327
|
}
|
|
27316
27328
|
function extractLinkedInPosts(flight, author = findAuthorSlug(flight)) {
|
|
27317
27329
|
const rows = parseRscRows(flight);
|
|
27318
|
-
const
|
|
27319
|
-
const mentionMap = buildMentionMap(rows,
|
|
27330
|
+
const resolve27 = makeRscResolver(rows);
|
|
27331
|
+
const mentionMap = buildMentionMap(rows, resolve27);
|
|
27320
27332
|
const posts = [];
|
|
27321
27333
|
for (const id of findCommentaryRows(rows)) {
|
|
27322
27334
|
const raw = {
|
|
@@ -27326,7 +27338,7 @@ function extractLinkedInPosts(flight, author = findAuthorSlug(flight)) {
|
|
|
27326
27338
|
links: [],
|
|
27327
27339
|
related: []
|
|
27328
27340
|
};
|
|
27329
|
-
walkPostRow(rows[id],
|
|
27341
|
+
walkPostRow(rows[id], resolve27, raw);
|
|
27330
27342
|
const post = buildPost(raw, mentionMap, author);
|
|
27331
27343
|
if (post) posts.push(post);
|
|
27332
27344
|
}
|
|
@@ -28881,7 +28893,7 @@ function parseIncoming(line, type) {
|
|
|
28881
28893
|
}
|
|
28882
28894
|
}
|
|
28883
28895
|
function requestSession(message3) {
|
|
28884
|
-
return new Promise((
|
|
28896
|
+
return new Promise((resolve27, reject) => {
|
|
28885
28897
|
connectToDaemon().then((socket) => {
|
|
28886
28898
|
let settled = false;
|
|
28887
28899
|
const finish2 = (error, sessionId) => {
|
|
@@ -28889,7 +28901,7 @@ function requestSession(message3) {
|
|
|
28889
28901
|
settled = true;
|
|
28890
28902
|
socket.destroy();
|
|
28891
28903
|
if (error) reject(error);
|
|
28892
|
-
else
|
|
28904
|
+
else resolve27(sessionId);
|
|
28893
28905
|
};
|
|
28894
28906
|
readSocketLines(socket, (line) => {
|
|
28895
28907
|
const incoming = parseIncoming(line, message3.type);
|
|
@@ -29484,8 +29496,8 @@ function printPrStatus(pr) {
|
|
|
29484
29496
|
}
|
|
29485
29497
|
|
|
29486
29498
|
// src/commands/prs/status/printPrsStatus.ts
|
|
29487
|
-
function printPrsStatus(
|
|
29488
|
-
for (const repo of
|
|
29499
|
+
function printPrsStatus(report) {
|
|
29500
|
+
for (const repo of report.repos) {
|
|
29489
29501
|
const count8 = repo.pullRequests.length;
|
|
29490
29502
|
console.log(`${chalk185.bold(repo.repo)} ${chalk185.dim(`(${count8} open)`)}`);
|
|
29491
29503
|
for (const pr of repo.pullRequests) {
|
|
@@ -29494,9 +29506,9 @@ function printPrsStatus(report2) {
|
|
|
29494
29506
|
if (count8 === 0) console.log(chalk185.dim(" no open pull requests"));
|
|
29495
29507
|
console.log();
|
|
29496
29508
|
}
|
|
29497
|
-
if (
|
|
29509
|
+
if (report.errors.length === 0) return;
|
|
29498
29510
|
console.log(chalk185.bold("Errors"));
|
|
29499
|
-
for (const failure of
|
|
29511
|
+
for (const failure of report.errors) {
|
|
29500
29512
|
console.log(` ${chalk185.red(failure.repo)}: ${failure.error}`);
|
|
29501
29513
|
}
|
|
29502
29514
|
console.log();
|
|
@@ -29504,12 +29516,12 @@ function printPrsStatus(report2) {
|
|
|
29504
29516
|
|
|
29505
29517
|
// src/commands/prs/prsStatus.ts
|
|
29506
29518
|
function prsStatus(repos2, options2) {
|
|
29507
|
-
const
|
|
29519
|
+
const report = buildPrsStatusReport(repos2);
|
|
29508
29520
|
if (options2.json) {
|
|
29509
|
-
console.log(JSON.stringify(
|
|
29521
|
+
console.log(JSON.stringify(report, null, 2));
|
|
29510
29522
|
return;
|
|
29511
29523
|
}
|
|
29512
|
-
printPrsStatus(
|
|
29524
|
+
printPrsStatus(report);
|
|
29513
29525
|
}
|
|
29514
29526
|
|
|
29515
29527
|
// src/commands/registerPrsStatus.ts
|
|
@@ -31343,7 +31355,7 @@ function getViolations(pattern2, options2 = {}, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
31343
31355
|
|
|
31344
31356
|
// src/commands/refactor/check.ts
|
|
31345
31357
|
function runScript(script, cwd) {
|
|
31346
|
-
return new Promise((
|
|
31358
|
+
return new Promise((resolve27) => {
|
|
31347
31359
|
const child = spawn7("npm", ["run", script], {
|
|
31348
31360
|
stdio: "pipe",
|
|
31349
31361
|
shell: true,
|
|
@@ -31357,7 +31369,7 @@ function runScript(script, cwd) {
|
|
|
31357
31369
|
output += data.toString();
|
|
31358
31370
|
});
|
|
31359
31371
|
child.on("close", (code) => {
|
|
31360
|
-
|
|
31372
|
+
resolve27({ script, code: code ?? 1, output });
|
|
31361
31373
|
});
|
|
31362
31374
|
});
|
|
31363
31375
|
}
|
|
@@ -35665,12 +35677,12 @@ function onCloseResult(ctx, code) {
|
|
|
35665
35677
|
return { ...closed, stderr: ctx.stderr.value, stdout: ctx.stdout.value };
|
|
35666
35678
|
}
|
|
35667
35679
|
function waitForChildExit(ctx) {
|
|
35668
|
-
return new Promise((
|
|
35680
|
+
return new Promise((resolve27) => {
|
|
35669
35681
|
let settled = false;
|
|
35670
35682
|
const settle = (result) => {
|
|
35671
35683
|
if (settled) return;
|
|
35672
35684
|
settled = true;
|
|
35673
|
-
|
|
35685
|
+
resolve27(result);
|
|
35674
35686
|
};
|
|
35675
35687
|
ctx.child.on("error", (err) => settle(onErrorResult(ctx, err)));
|
|
35676
35688
|
ctx.child.on("close", (code) => settle(onCloseResult(ctx, code)));
|
|
@@ -37042,11 +37054,11 @@ import { randomUUID as randomUUID20 } from "crypto";
|
|
|
37042
37054
|
// src/commands/sessions/shared/sendShowPreview.ts
|
|
37043
37055
|
async function sendShowPreview(request) {
|
|
37044
37056
|
const socket = await connectToDaemon();
|
|
37045
|
-
await new Promise((
|
|
37057
|
+
await new Promise((resolve27, reject) => {
|
|
37046
37058
|
const finish2 = (error) => {
|
|
37047
37059
|
socket.destroy();
|
|
37048
37060
|
if (error) reject(error);
|
|
37049
|
-
else
|
|
37061
|
+
else resolve27();
|
|
37050
37062
|
};
|
|
37051
37063
|
readSocketLines(socket, (line) => {
|
|
37052
37064
|
const reply2 = parseReply(line);
|
|
@@ -38309,9 +38321,9 @@ function createReadlineInterface() {
|
|
|
38309
38321
|
});
|
|
38310
38322
|
}
|
|
38311
38323
|
function askQuestion(rl, question) {
|
|
38312
|
-
return new Promise((
|
|
38324
|
+
return new Promise((resolve27) => {
|
|
38313
38325
|
rl.question(question, (answer) => {
|
|
38314
|
-
|
|
38326
|
+
resolve27(answer.trim());
|
|
38315
38327
|
});
|
|
38316
38328
|
});
|
|
38317
38329
|
}
|
|
@@ -39453,47 +39465,18 @@ function registerVerify(program2) {
|
|
|
39453
39465
|
configHelp(verifyCommand, verifyConfigHelp);
|
|
39454
39466
|
}
|
|
39455
39467
|
|
|
39456
|
-
// src/commands/watch/
|
|
39457
|
-
|
|
39458
|
-
function decideLap(end, interrupted) {
|
|
39459
|
-
if (interrupted) return { kind: "exit", code: 130 };
|
|
39460
|
-
if (end.code === null) return { kind: "relaunch" };
|
|
39461
|
-
if (RELAUNCH_CODES.has(end.code)) return { kind: "relaunch" };
|
|
39462
|
-
return { kind: "exit", code: end.code };
|
|
39463
|
-
}
|
|
39468
|
+
// src/commands/watch/simulateDivergence.ts
|
|
39469
|
+
import { writeFileSync as writeFileSync52 } from "fs";
|
|
39464
39470
|
|
|
39465
|
-
// src/commands/watch/
|
|
39466
|
-
|
|
39467
|
-
|
|
39468
|
-
|
|
39469
|
-
|
|
39470
|
-
|
|
39471
|
-
stdio: "inherit",
|
|
39472
|
-
shell: process.platform === "win32"
|
|
39473
|
-
});
|
|
39474
|
-
assistFromPath.on("close", (code, signal) => resolve26({ code, signal }));
|
|
39475
|
-
assistFromPath.on("error", reject);
|
|
39476
|
-
});
|
|
39477
|
-
}
|
|
39478
|
-
|
|
39479
|
-
// src/commands/watch/watchLoop.ts
|
|
39480
|
-
async function watchLoop() {
|
|
39481
|
-
let interrupted = false;
|
|
39482
|
-
const recordInterruptAndLetLapFinish = () => {
|
|
39483
|
-
interrupted = true;
|
|
39484
|
-
};
|
|
39485
|
-
process.on("SIGINT", recordInterruptAndLetLapFinish);
|
|
39486
|
-
for (let lap = 1; ; lap++) {
|
|
39487
|
-
console.log(`lap ${lap}: assist ${WATCH_LAP_ARGS.join(" ")}`);
|
|
39488
|
-
const end = await runWatchLap();
|
|
39489
|
-
const decision = decideLap(end, interrupted);
|
|
39490
|
-
const how = end.signal ? `killed by ${end.signal}` : `exited ${end.code}`;
|
|
39491
|
-
if (decision.kind === "exit") {
|
|
39492
|
-
console.error(`lap ${lap} ${how} \u2014 stopping`);
|
|
39493
|
-
return process.exit(decision.code);
|
|
39494
|
-
}
|
|
39495
|
-
console.log(`lap ${lap} ${how} \u2014 relaunching`);
|
|
39471
|
+
// src/commands/watch/gitFailureReason.ts
|
|
39472
|
+
function gitFailureReason(error) {
|
|
39473
|
+
const streams = error;
|
|
39474
|
+
for (const stream of [streams?.stderr, streams?.stdout]) {
|
|
39475
|
+
const text17 = stream == null ? "" : String(stream).trim();
|
|
39476
|
+
if (text17) return text17;
|
|
39496
39477
|
}
|
|
39478
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
39479
|
+
return message3.trim() || "git failed without reporting a reason";
|
|
39497
39480
|
}
|
|
39498
39481
|
|
|
39499
39482
|
// src/commands/watch/resolveUpstream.ts
|
|
@@ -39536,6 +39519,71 @@ function resolveUpstream(cwd) {
|
|
|
39536
39519
|
}
|
|
39537
39520
|
}
|
|
39538
39521
|
|
|
39522
|
+
// src/commands/watch/simulatedDivergencePath.ts
|
|
39523
|
+
import { resolve as resolve24 } from "path";
|
|
39524
|
+
function simulatedDivergencePath(cwd) {
|
|
39525
|
+
return resolve24(
|
|
39526
|
+
cwd ?? process.cwd(),
|
|
39527
|
+
runGit3(["rev-parse", "--git-path", "assist-simulate-divergence"], cwd)
|
|
39528
|
+
);
|
|
39529
|
+
}
|
|
39530
|
+
|
|
39531
|
+
// src/commands/watch/simulateDivergence.ts
|
|
39532
|
+
function simulateDivergence() {
|
|
39533
|
+
try {
|
|
39534
|
+
writeFileSync52(simulatedDivergencePath(), "");
|
|
39535
|
+
console.log(
|
|
39536
|
+
`the next assist watch wait poll in ${runGit3(["rev-parse", "--show-toplevel"])} will exit 3 as a simulated divergence`
|
|
39537
|
+
);
|
|
39538
|
+
} catch (error) {
|
|
39539
|
+
console.error(`cannot simulate a divergence: ${gitFailureReason(error)}`);
|
|
39540
|
+
process.exit(1);
|
|
39541
|
+
}
|
|
39542
|
+
}
|
|
39543
|
+
|
|
39544
|
+
// src/commands/watch/decideLap.ts
|
|
39545
|
+
var RELAUNCH_CODES = /* @__PURE__ */ new Set([0, 2, 4]);
|
|
39546
|
+
function decideLap(end, interrupted) {
|
|
39547
|
+
if (interrupted) return { kind: "exit", code: 130 };
|
|
39548
|
+
if (end.code === null) return { kind: "relaunch" };
|
|
39549
|
+
if (RELAUNCH_CODES.has(end.code)) return { kind: "relaunch" };
|
|
39550
|
+
return { kind: "exit", code: end.code };
|
|
39551
|
+
}
|
|
39552
|
+
|
|
39553
|
+
// src/commands/watch/runWatchLap.ts
|
|
39554
|
+
import { spawn as spawn9 } from "child_process";
|
|
39555
|
+
var WATCH_LAP_ARGS = ["watch", "wait", "--pull", "--build"];
|
|
39556
|
+
function runWatchLap() {
|
|
39557
|
+
return new Promise((resolve27, reject) => {
|
|
39558
|
+
const assistFromPath = spawn9("assist", WATCH_LAP_ARGS, {
|
|
39559
|
+
stdio: "inherit",
|
|
39560
|
+
shell: process.platform === "win32"
|
|
39561
|
+
});
|
|
39562
|
+
assistFromPath.on("close", (code, signal) => resolve27({ code, signal }));
|
|
39563
|
+
assistFromPath.on("error", reject);
|
|
39564
|
+
});
|
|
39565
|
+
}
|
|
39566
|
+
|
|
39567
|
+
// src/commands/watch/watchLoop.ts
|
|
39568
|
+
async function watchLoop() {
|
|
39569
|
+
let interrupted = false;
|
|
39570
|
+
const recordInterruptAndLetLapFinish = () => {
|
|
39571
|
+
interrupted = true;
|
|
39572
|
+
};
|
|
39573
|
+
process.on("SIGINT", recordInterruptAndLetLapFinish);
|
|
39574
|
+
for (let lap = 1; ; lap++) {
|
|
39575
|
+
console.log(`lap ${lap}: assist ${WATCH_LAP_ARGS.join(" ")}`);
|
|
39576
|
+
const end = await runWatchLap();
|
|
39577
|
+
const decision = decideLap(end, interrupted);
|
|
39578
|
+
const how = end.signal ? `killed by ${end.signal}` : `exited ${end.code}`;
|
|
39579
|
+
if (decision.kind === "exit") {
|
|
39580
|
+
console.error(`lap ${lap} ${how} \u2014 stopping`);
|
|
39581
|
+
return process.exit(decision.code);
|
|
39582
|
+
}
|
|
39583
|
+
console.log(`lap ${lap} ${how} \u2014 relaunching`);
|
|
39584
|
+
}
|
|
39585
|
+
}
|
|
39586
|
+
|
|
39539
39587
|
// src/commands/watch/changedPaths.ts
|
|
39540
39588
|
function changedPaths(from, cwd) {
|
|
39541
39589
|
return runGit3(["diff", "--name-only", `${from}..HEAD`], cwd).split("\n").filter((line) => line.length > 0);
|
|
@@ -39659,17 +39707,6 @@ function buildWatchReport(from, cwd) {
|
|
|
39659
39707
|
});
|
|
39660
39708
|
}
|
|
39661
39709
|
|
|
39662
|
-
// src/commands/watch/gitFailureReason.ts
|
|
39663
|
-
function gitFailureReason(error) {
|
|
39664
|
-
const streams = error;
|
|
39665
|
-
for (const stream of [streams?.stderr, streams?.stdout]) {
|
|
39666
|
-
const text17 = stream == null ? "" : String(stream).trim();
|
|
39667
|
-
if (text17) return text17;
|
|
39668
|
-
}
|
|
39669
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
39670
|
-
return message3.trim() || "git failed without reporting a reason";
|
|
39671
|
-
}
|
|
39672
|
-
|
|
39673
39710
|
// src/commands/watch/watchReport.ts
|
|
39674
39711
|
function watchReport(options2) {
|
|
39675
39712
|
try {
|
|
@@ -39694,6 +39731,11 @@ function describeOutcome(outcome) {
|
|
|
39694
39731
|
exitCode: 2,
|
|
39695
39732
|
message: `no movement on ${outcome.upstream} after ${outcome.timeout}`
|
|
39696
39733
|
};
|
|
39734
|
+
case "simulated-divergence":
|
|
39735
|
+
return {
|
|
39736
|
+
exitCode: 3,
|
|
39737
|
+
message: `simulated divergence from ${outcome.upstream} (requested by assist watch simulate-divergence; nothing has actually diverged)`
|
|
39738
|
+
};
|
|
39697
39739
|
case "unavailable":
|
|
39698
39740
|
return { exitCode: 1, message: `cannot wait: ${outcome.reason}` };
|
|
39699
39741
|
case "interrupted":
|
|
@@ -39701,19 +39743,9 @@ function describeOutcome(outcome) {
|
|
|
39701
39743
|
}
|
|
39702
39744
|
}
|
|
39703
39745
|
|
|
39704
|
-
// src/commands/watch/
|
|
39705
|
-
function
|
|
39706
|
-
|
|
39707
|
-
return {
|
|
39708
|
-
exitCode: 0,
|
|
39709
|
-
message: `pulled --ff-only \u2192 ${result.sha.slice(0, 7)}`
|
|
39710
|
-
};
|
|
39711
|
-
}
|
|
39712
|
-
return {
|
|
39713
|
-
exitCode: 3,
|
|
39714
|
-
message: `pull was not a fast-forward:
|
|
39715
|
-
${result.reason}`
|
|
39716
|
-
};
|
|
39746
|
+
// src/commands/watch/emitWatchState.ts
|
|
39747
|
+
function emitWatchState(watchState) {
|
|
39748
|
+
emitActivity({ kind: "command", name: "watch", watchState });
|
|
39717
39749
|
}
|
|
39718
39750
|
|
|
39719
39751
|
// src/commands/watch/parseDuration.ts
|
|
@@ -39748,6 +39780,21 @@ function parseWatchDurations(interval, timeout) {
|
|
|
39748
39780
|
};
|
|
39749
39781
|
}
|
|
39750
39782
|
|
|
39783
|
+
// src/commands/watch/describePull.ts
|
|
39784
|
+
function describePull(result) {
|
|
39785
|
+
if (result.kind === "fast-forwarded") {
|
|
39786
|
+
return {
|
|
39787
|
+
exitCode: 0,
|
|
39788
|
+
message: `pulled --ff-only \u2192 ${result.sha.slice(0, 7)}`
|
|
39789
|
+
};
|
|
39790
|
+
}
|
|
39791
|
+
return {
|
|
39792
|
+
exitCode: 3,
|
|
39793
|
+
message: `pull was not a fast-forward:
|
|
39794
|
+
${result.reason}`
|
|
39795
|
+
};
|
|
39796
|
+
}
|
|
39797
|
+
|
|
39751
39798
|
// src/commands/watch/pullFastForward.ts
|
|
39752
39799
|
var STASH_MESSAGE = "assist watch";
|
|
39753
39800
|
function attemptGit(args, cwd) {
|
|
@@ -39880,7 +39927,7 @@ function resolveParams(params, cliArgs) {
|
|
|
39880
39927
|
|
|
39881
39928
|
// src/commands/run/resolveRunCwd.ts
|
|
39882
39929
|
import { existsSync as existsSync80 } from "fs";
|
|
39883
|
-
import { resolve as
|
|
39930
|
+
import { resolve as resolve25 } from "path";
|
|
39884
39931
|
var MissingRunCwdError = class extends Error {
|
|
39885
39932
|
constructor(runName, cwd) {
|
|
39886
39933
|
super(`run config "${runName}": cwd ${cwd} does not exist`);
|
|
@@ -39891,7 +39938,7 @@ var MissingRunCwdError = class extends Error {
|
|
|
39891
39938
|
};
|
|
39892
39939
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
39893
39940
|
if (!config.cwd) return void 0;
|
|
39894
|
-
const cwd =
|
|
39941
|
+
const cwd = resolve25(baseDir, config.cwd);
|
|
39895
39942
|
if (!existsSync80(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
39896
39943
|
return cwd;
|
|
39897
39944
|
}
|
|
@@ -39960,6 +40007,12 @@ async function reportBuildOrExit(entry) {
|
|
|
39960
40007
|
process.exit(4);
|
|
39961
40008
|
}
|
|
39962
40009
|
|
|
40010
|
+
// src/commands/watch/reportOutcome.ts
|
|
40011
|
+
function reportOutcome({ exitCode, message: message3 }) {
|
|
40012
|
+
if (exitCode === 0) console.log(message3);
|
|
40013
|
+
else console.error(message3);
|
|
40014
|
+
}
|
|
40015
|
+
|
|
39963
40016
|
// src/commands/watch/runPostBuildSync.ts
|
|
39964
40017
|
async function runPostBuildSync() {
|
|
39965
40018
|
return toBuildOutcome(
|
|
@@ -39985,6 +40038,39 @@ async function reportSyncOrExit() {
|
|
|
39985
40038
|
process.exit(4);
|
|
39986
40039
|
}
|
|
39987
40040
|
|
|
40041
|
+
// src/commands/watch/pullAndBuild.ts
|
|
40042
|
+
var DEFAULT_BUILD_ENTRY = "auto-build";
|
|
40043
|
+
async function pullAndBuild(from, build2) {
|
|
40044
|
+
emitWatchState("updating");
|
|
40045
|
+
const pullResult = pullFastForward();
|
|
40046
|
+
const pullReport = describePull(pullResult);
|
|
40047
|
+
reportOutcome(pullReport);
|
|
40048
|
+
if (pullResult.kind !== "fast-forwarded")
|
|
40049
|
+
return process.exit(pullReport.exitCode);
|
|
40050
|
+
console.log(`
|
|
40051
|
+
${buildWatchReport(from)}`);
|
|
40052
|
+
if (build2) {
|
|
40053
|
+
await reportBuildOrExit(
|
|
40054
|
+
typeof build2 === "string" ? build2 : DEFAULT_BUILD_ENTRY
|
|
40055
|
+
);
|
|
40056
|
+
if (syncAdvice(changedPaths(from)).length > 0) await reportSyncOrExit();
|
|
40057
|
+
}
|
|
40058
|
+
process.exit(0);
|
|
40059
|
+
}
|
|
40060
|
+
|
|
40061
|
+
// src/commands/watch/consumeSimulatedDivergence.ts
|
|
40062
|
+
import { existsSync as existsSync81, rmSync as rmSync6 } from "fs";
|
|
40063
|
+
function consumeSimulatedDivergence(cwd) {
|
|
40064
|
+
try {
|
|
40065
|
+
const path106 = simulatedDivergencePath(cwd);
|
|
40066
|
+
if (!existsSync81(path106)) return false;
|
|
40067
|
+
rmSync6(path106);
|
|
40068
|
+
return true;
|
|
40069
|
+
} catch {
|
|
40070
|
+
return false;
|
|
40071
|
+
}
|
|
40072
|
+
}
|
|
40073
|
+
|
|
39988
40074
|
// src/commands/watch/fetchQuietly.ts
|
|
39989
40075
|
import { execFileSync as execFileSync22 } from "child_process";
|
|
39990
40076
|
var MIN_FETCH_TIMEOUT_MS = 6e4;
|
|
@@ -40021,7 +40107,7 @@ function readMovement(cwd) {
|
|
|
40021
40107
|
// src/commands/watch/pollForMovement.ts
|
|
40022
40108
|
function pollForMovement(options2) {
|
|
40023
40109
|
const { upstream, intervalMs, timeoutMs, timeout, cwd } = options2;
|
|
40024
|
-
return new Promise((
|
|
40110
|
+
return new Promise((resolve27) => {
|
|
40025
40111
|
let settled = false;
|
|
40026
40112
|
const finish2 = (outcome) => {
|
|
40027
40113
|
if (settled) return;
|
|
@@ -40029,10 +40115,12 @@ function pollForMovement(options2) {
|
|
|
40029
40115
|
clearInterval(ticker);
|
|
40030
40116
|
clearTimeout(deadline);
|
|
40031
40117
|
process.off("SIGINT", onInterrupt);
|
|
40032
|
-
|
|
40118
|
+
resolve27(outcome);
|
|
40033
40119
|
};
|
|
40034
40120
|
const onInterrupt = () => finish2({ kind: "interrupted" });
|
|
40035
40121
|
const ticker = setInterval(() => {
|
|
40122
|
+
if (consumeSimulatedDivergence(cwd))
|
|
40123
|
+
return finish2({ kind: "simulated-divergence", upstream });
|
|
40036
40124
|
fetchQuietly(cwd, intervalMs);
|
|
40037
40125
|
const found = readMovement(cwd);
|
|
40038
40126
|
if (found) finish2({ kind: "moved", upstream, ...found });
|
|
@@ -40058,6 +40146,8 @@ function waitForUpstream(options2) {
|
|
|
40058
40146
|
});
|
|
40059
40147
|
}
|
|
40060
40148
|
onStart?.(upstream);
|
|
40149
|
+
if (consumeSimulatedDivergence(cwd))
|
|
40150
|
+
return Promise.resolve({ kind: "simulated-divergence", upstream });
|
|
40061
40151
|
fetchQuietly(cwd, intervalMs);
|
|
40062
40152
|
const moved = readMovement(cwd);
|
|
40063
40153
|
if (moved) return Promise.resolve({ kind: "moved", upstream, ...moved });
|
|
@@ -40065,11 +40155,6 @@ function waitForUpstream(options2) {
|
|
|
40065
40155
|
}
|
|
40066
40156
|
|
|
40067
40157
|
// src/commands/watch/watchWait.ts
|
|
40068
|
-
var DEFAULT_BUILD_ENTRY = "auto-build";
|
|
40069
|
-
function report({ exitCode, message: message3 }) {
|
|
40070
|
-
if (exitCode === 0) console.log(message3);
|
|
40071
|
-
else console.error(message3);
|
|
40072
|
-
}
|
|
40073
40158
|
async function watchWait(options2) {
|
|
40074
40159
|
const { intervalMs, timeoutMs } = parseWatchDurations(
|
|
40075
40160
|
options2.interval,
|
|
@@ -40079,27 +40164,16 @@ async function watchWait(options2) {
|
|
|
40079
40164
|
intervalMs,
|
|
40080
40165
|
timeoutMs,
|
|
40081
40166
|
timeout: options2.timeout,
|
|
40082
|
-
onStart: (upstream) =>
|
|
40167
|
+
onStart: (upstream) => {
|
|
40168
|
+
emitWatchState("waiting");
|
|
40169
|
+
console.log(`waiting on ${upstream} \u2026`);
|
|
40170
|
+
}
|
|
40083
40171
|
});
|
|
40084
40172
|
const waitReport = describeOutcome(outcome);
|
|
40085
|
-
|
|
40173
|
+
reportOutcome(waitReport);
|
|
40086
40174
|
if (outcome.kind !== "moved" || !options2.pull)
|
|
40087
40175
|
return process.exit(waitReport.exitCode);
|
|
40088
|
-
|
|
40089
|
-
const pullReport = describePull(pullResult);
|
|
40090
|
-
report(pullReport);
|
|
40091
|
-
if (pullResult.kind !== "fast-forwarded")
|
|
40092
|
-
return process.exit(pullReport.exitCode);
|
|
40093
|
-
console.log(`
|
|
40094
|
-
${buildWatchReport(outcome.from)}`);
|
|
40095
|
-
if (options2.build) {
|
|
40096
|
-
await reportBuildOrExit(
|
|
40097
|
-
typeof options2.build === "string" ? options2.build : DEFAULT_BUILD_ENTRY
|
|
40098
|
-
);
|
|
40099
|
-
if (syncAdvice(changedPaths(outcome.from)).length > 0)
|
|
40100
|
-
await reportSyncOrExit();
|
|
40101
|
-
}
|
|
40102
|
-
process.exit(0);
|
|
40176
|
+
await pullAndBuild(outcome.from, options2.build);
|
|
40103
40177
|
}
|
|
40104
40178
|
|
|
40105
40179
|
// src/commands/registerWatch.ts
|
|
@@ -40127,6 +40201,9 @@ function registerWatch(program2) {
|
|
|
40127
40201
|
watchCommand.command("loop").description(
|
|
40128
40202
|
"Run assist watch wait --pull --build as a fresh child per lap, relaunching after exit 0, 2 or 4 or a signal kill, and exit with the child's code on 1, 3 or 130"
|
|
40129
40203
|
).action(() => watchLoop());
|
|
40204
|
+
watchCommand.command("simulate-divergence").description(
|
|
40205
|
+
"Make the next assist watch wait poll in this repo exit 3 as if the branch had diverged, to test the watcher's divergence escalation"
|
|
40206
|
+
).action(() => simulateDivergence());
|
|
40130
40207
|
watchCommand.command("report").description(
|
|
40131
40208
|
"Print the built version, the last 10 commits as a markdown table, the restarts the new commits make necessary, and whether ~/.claude needs a sync"
|
|
40132
40209
|
).option(
|
|
@@ -40158,7 +40235,7 @@ function extractCode(url, expectedState) {
|
|
|
40158
40235
|
return code;
|
|
40159
40236
|
}
|
|
40160
40237
|
function waitForCallback(port, expectedState) {
|
|
40161
|
-
return new Promise((
|
|
40238
|
+
return new Promise((resolve27, reject) => {
|
|
40162
40239
|
const timeout = setTimeout(() => {
|
|
40163
40240
|
server.close();
|
|
40164
40241
|
reject(new Error("Authorization timed out after 120 seconds"));
|
|
@@ -40175,7 +40252,7 @@ function waitForCallback(port, expectedState) {
|
|
|
40175
40252
|
const code = extractCode(url, expectedState);
|
|
40176
40253
|
respondHtml(res, 200, "Authorization successful!");
|
|
40177
40254
|
server.close();
|
|
40178
|
-
|
|
40255
|
+
resolve27(code);
|
|
40179
40256
|
} catch (error) {
|
|
40180
40257
|
respondHtml(res, 400, error.message);
|
|
40181
40258
|
server.close();
|
|
@@ -40458,7 +40535,7 @@ async function run3(name, args) {
|
|
|
40458
40535
|
}
|
|
40459
40536
|
|
|
40460
40537
|
// src/commands/run/add.ts
|
|
40461
|
-
import { mkdirSync as mkdirSync33, writeFileSync as
|
|
40538
|
+
import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync53 } from "fs";
|
|
40462
40539
|
import { join as join95 } from "path";
|
|
40463
40540
|
|
|
40464
40541
|
// src/commands/run/extractOption.ts
|
|
@@ -40529,7 +40606,7 @@ description: Run ${name}
|
|
|
40529
40606
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
40530
40607
|
`;
|
|
40531
40608
|
const filePath = join95(dir, `${name}.md`);
|
|
40532
|
-
|
|
40609
|
+
writeFileSync53(filePath, content);
|
|
40533
40610
|
console.log(`Created command file: ${filePath}`);
|
|
40534
40611
|
}
|
|
40535
40612
|
function add4() {
|
|
@@ -40584,7 +40661,7 @@ function link2() {
|
|
|
40584
40661
|
}
|
|
40585
40662
|
|
|
40586
40663
|
// src/commands/run/remove.ts
|
|
40587
|
-
import { existsSync as
|
|
40664
|
+
import { existsSync as existsSync82, unlinkSync as unlinkSync21 } from "fs";
|
|
40588
40665
|
import { join as join96 } from "path";
|
|
40589
40666
|
function findRemoveIndex() {
|
|
40590
40667
|
const idx = process.argv.indexOf("remove");
|
|
@@ -40601,7 +40678,7 @@ function parseRemoveName() {
|
|
|
40601
40678
|
}
|
|
40602
40679
|
function deleteCommandFile(name) {
|
|
40603
40680
|
const filePath = join96(".claude", "commands", `${name}.md`);
|
|
40604
|
-
if (
|
|
40681
|
+
if (existsSync82(filePath)) {
|
|
40605
40682
|
unlinkSync21(filePath);
|
|
40606
40683
|
console.log(`Deleted command file: ${filePath}`);
|
|
40607
40684
|
}
|
|
@@ -40680,10 +40757,10 @@ var STATUS_TIMEOUT_MS2 = 5e3;
|
|
|
40680
40757
|
function queryDaemon(socket) {
|
|
40681
40758
|
socket.write(`${JSON.stringify({ type: "ping" })}
|
|
40682
40759
|
`);
|
|
40683
|
-
return new Promise((
|
|
40760
|
+
return new Promise((resolve27) => {
|
|
40684
40761
|
const result = { sessions: [] };
|
|
40685
40762
|
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
40686
|
-
const timer = setTimeout(() =>
|
|
40763
|
+
const timer = setTimeout(() => resolve27(result), STATUS_TIMEOUT_MS2);
|
|
40687
40764
|
const lines2 = createInterface8({ input: socket });
|
|
40688
40765
|
lines2.on("error", () => {
|
|
40689
40766
|
});
|
|
@@ -40691,7 +40768,7 @@ function queryDaemon(socket) {
|
|
|
40691
40768
|
applyLine(result, pending, line);
|
|
40692
40769
|
if (pending.size === 0) {
|
|
40693
40770
|
clearTimeout(timer);
|
|
40694
|
-
|
|
40771
|
+
resolve27(result);
|
|
40695
40772
|
}
|
|
40696
40773
|
});
|
|
40697
40774
|
});
|
|
@@ -40791,11 +40868,11 @@ function clearPersistedSessionsOnDrain() {
|
|
|
40791
40868
|
|
|
40792
40869
|
// src/commands/sessions/daemon/readDaemonMessage.ts
|
|
40793
40870
|
function readDaemonMessage(lines2, timeoutMs, fallback, match) {
|
|
40794
|
-
return new Promise((
|
|
40871
|
+
return new Promise((resolve27) => {
|
|
40795
40872
|
const finish2 = (value) => {
|
|
40796
40873
|
clearTimeout(timer);
|
|
40797
40874
|
lines2.off("line", onLine);
|
|
40798
|
-
|
|
40875
|
+
resolve27(value);
|
|
40799
40876
|
};
|
|
40800
40877
|
const timer = setTimeout(() => finish2(fallback), timeoutMs);
|
|
40801
40878
|
const onLine = (line) => {
|
|
@@ -40982,12 +41059,12 @@ function toSessionRunInfo({
|
|
|
40982
41059
|
}
|
|
40983
41060
|
|
|
40984
41061
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
40985
|
-
import { existsSync as
|
|
41062
|
+
import { existsSync as existsSync83 } from "fs";
|
|
40986
41063
|
function joinRefusal(session) {
|
|
40987
41064
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
40988
41065
|
if (session.closing === true) return "the session is closing";
|
|
40989
41066
|
if (!session.cwd) return "the session has no working directory";
|
|
40990
|
-
if (!
|
|
41067
|
+
if (!existsSync83(session.cwd))
|
|
40991
41068
|
return "the session's workspace no longer exists";
|
|
40992
41069
|
return void 0;
|
|
40993
41070
|
}
|
|
@@ -41362,11 +41439,11 @@ function sessionBase(id, status2) {
|
|
|
41362
41439
|
}
|
|
41363
41440
|
|
|
41364
41441
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
41365
|
-
import { existsSync as
|
|
41442
|
+
import { existsSync as existsSync85 } from "fs";
|
|
41366
41443
|
import * as pty from "node-pty";
|
|
41367
41444
|
|
|
41368
41445
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
41369
|
-
import { chmodSync, existsSync as
|
|
41446
|
+
import { chmodSync, existsSync as existsSync84, statSync as statSync13 } from "fs";
|
|
41370
41447
|
import { createRequire as createRequire3 } from "module";
|
|
41371
41448
|
import path102 from "path";
|
|
41372
41449
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -41381,7 +41458,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
41381
41458
|
`${process.platform}-${process.arch}`,
|
|
41382
41459
|
"spawn-helper"
|
|
41383
41460
|
);
|
|
41384
|
-
if (!
|
|
41461
|
+
if (!existsSync84(helper)) return;
|
|
41385
41462
|
const mode = statSync13(helper).mode;
|
|
41386
41463
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
41387
41464
|
}
|
|
@@ -41417,7 +41494,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
41417
41494
|
});
|
|
41418
41495
|
}
|
|
41419
41496
|
function refuseMissingCwd(cwd, sessionId) {
|
|
41420
|
-
if (!cwd ||
|
|
41497
|
+
if (!cwd || existsSync85(cwd)) return;
|
|
41421
41498
|
daemonLog(
|
|
41422
41499
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
41423
41500
|
);
|
|
@@ -41610,11 +41687,11 @@ function setStatus2(session, newStatus) {
|
|
|
41610
41687
|
}
|
|
41611
41688
|
|
|
41612
41689
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
41613
|
-
import { existsSync as
|
|
41690
|
+
import { existsSync as existsSync87 } from "fs";
|
|
41614
41691
|
import { basename as basename27 } from "path";
|
|
41615
41692
|
|
|
41616
41693
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
41617
|
-
import { existsSync as
|
|
41694
|
+
import { existsSync as existsSync86 } from "fs";
|
|
41618
41695
|
import { join as join99 } from "path";
|
|
41619
41696
|
|
|
41620
41697
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
@@ -41684,7 +41761,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
41684
41761
|
);
|
|
41685
41762
|
}
|
|
41686
41763
|
function strandedReason(worktreePath, cause) {
|
|
41687
|
-
if (!
|
|
41764
|
+
if (!existsSync86(join99(worktreePath, ".git")))
|
|
41688
41765
|
return "its .git link is already gone";
|
|
41689
41766
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
41690
41767
|
return "git no longer recognises it as a working tree";
|
|
@@ -41736,7 +41813,7 @@ function reason3(error) {
|
|
|
41736
41813
|
|
|
41737
41814
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
41738
41815
|
async function reapWorktree(worktreePath, force = false) {
|
|
41739
|
-
if (!
|
|
41816
|
+
if (!existsSync87(worktreePath)) {
|
|
41740
41817
|
forgetWorktree(worktreePath);
|
|
41741
41818
|
daemonLog(
|
|
41742
41819
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -41761,7 +41838,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
41761
41838
|
}
|
|
41762
41839
|
function owningClone(worktreePath) {
|
|
41763
41840
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
41764
|
-
if (recorded &&
|
|
41841
|
+
if (recorded && existsSync87(recorded)) return recorded;
|
|
41765
41842
|
const detected = mainWorktree(worktreePath);
|
|
41766
41843
|
if (detected) return detected;
|
|
41767
41844
|
daemonLog(
|
|
@@ -41958,12 +42035,12 @@ function processCwd(link3) {
|
|
|
41958
42035
|
var POLL_MS = 500;
|
|
41959
42036
|
var GRACE_MS = 5e3;
|
|
41960
42037
|
function awaitTreeVacated(session, treePath) {
|
|
41961
|
-
return new Promise((
|
|
42038
|
+
return new Promise((resolve27) => {
|
|
41962
42039
|
let ticks = GRACE_MS / POLL_MS;
|
|
41963
42040
|
const settle = (outcome) => {
|
|
41964
42041
|
clearTimeout(timer);
|
|
41965
42042
|
session.closeGrace = void 0;
|
|
41966
|
-
|
|
42043
|
+
resolve27(outcome);
|
|
41967
42044
|
};
|
|
41968
42045
|
const tick = () => {
|
|
41969
42046
|
if (liveProcessesInTree(treePath).length === 0) settle("vacated");
|
|
@@ -41999,12 +42076,12 @@ async function closeBlockReason(sessionId, tree) {
|
|
|
41999
42076
|
}
|
|
42000
42077
|
|
|
42001
42078
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
42002
|
-
import { existsSync as
|
|
42079
|
+
import { existsSync as existsSync88, watch } from "fs";
|
|
42003
42080
|
var DEBOUNCE_MS = 500;
|
|
42004
42081
|
var POLL_MS2 = 3e4;
|
|
42005
42082
|
function watchGitState(cwd, onChange) {
|
|
42006
42083
|
const common = gitCommonDir(cwd);
|
|
42007
|
-
if (!common || !
|
|
42084
|
+
if (!common || !existsSync88(common)) return void 0;
|
|
42008
42085
|
const watchers = [
|
|
42009
42086
|
watchGitDir(common, onChange),
|
|
42010
42087
|
pollGitState(cwd, onChange)
|
|
@@ -42551,10 +42628,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
42551
42628
|
}
|
|
42552
42629
|
|
|
42553
42630
|
// src/commands/sessions/daemon/exitReason.ts
|
|
42554
|
-
import { existsSync as
|
|
42555
|
-
import { resolve as
|
|
42631
|
+
import { existsSync as existsSync89 } from "fs";
|
|
42632
|
+
import { resolve as resolve26 } from "path";
|
|
42556
42633
|
function exitDetail(session) {
|
|
42557
|
-
if (session.cwd && !
|
|
42634
|
+
if (session.cwd && !existsSync89(session.cwd))
|
|
42558
42635
|
return `working directory ${session.cwd} no longer exists`;
|
|
42559
42636
|
return missingRunConfigCwd(session);
|
|
42560
42637
|
}
|
|
@@ -42567,8 +42644,8 @@ function missingRunConfigCwd(session) {
|
|
|
42567
42644
|
const dir = session.cwd ?? process.cwd();
|
|
42568
42645
|
const config = resolveRunConfig(session.runName, dir);
|
|
42569
42646
|
if (!config?.cwd) return void 0;
|
|
42570
|
-
const configured =
|
|
42571
|
-
if (
|
|
42647
|
+
const configured = resolve26(runConfigBaseDirFrom(dir), config.cwd);
|
|
42648
|
+
if (existsSync89(configured)) return void 0;
|
|
42572
42649
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
42573
42650
|
}
|
|
42574
42651
|
|
|
@@ -42616,7 +42693,7 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
|
42616
42693
|
}
|
|
42617
42694
|
|
|
42618
42695
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
42619
|
-
import { existsSync as
|
|
42696
|
+
import { existsSync as existsSync90, mkdirSync as mkdirSync34, watch as watch2 } from "fs";
|
|
42620
42697
|
import { dirname as dirname41 } from "path";
|
|
42621
42698
|
|
|
42622
42699
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -42702,7 +42779,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
42702
42779
|
if (timer) clearTimeout(timer);
|
|
42703
42780
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
42704
42781
|
});
|
|
42705
|
-
if (
|
|
42782
|
+
if (existsSync90(path106)) read3();
|
|
42706
42783
|
}
|
|
42707
42784
|
function refreshActivity(session) {
|
|
42708
42785
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -44118,16 +44195,16 @@ function rebindClaudeSession(session, claudeSessionId, notify2, onStatusChange)
|
|
|
44118
44195
|
}
|
|
44119
44196
|
|
|
44120
44197
|
// src/commands/sessions/daemon/setStatusFromHook.ts
|
|
44121
|
-
function setStatusFromHook(sessions,
|
|
44198
|
+
function setStatusFromHook(sessions, report, notify2, onStatusChange) {
|
|
44122
44199
|
applySetStatus(
|
|
44123
44200
|
sessions,
|
|
44124
|
-
|
|
44125
|
-
|
|
44126
|
-
|
|
44201
|
+
report.id,
|
|
44202
|
+
report.status,
|
|
44203
|
+
report.source,
|
|
44127
44204
|
onStatusChange,
|
|
44128
44205
|
(session) => rebindClaudeSession(
|
|
44129
44206
|
session,
|
|
44130
|
-
|
|
44207
|
+
report.claudeSessionId,
|
|
44131
44208
|
notify2,
|
|
44132
44209
|
onStatusChange
|
|
44133
44210
|
)
|
|
@@ -44908,7 +44985,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
44908
44985
|
}
|
|
44909
44986
|
|
|
44910
44987
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
44911
|
-
import { existsSync as
|
|
44988
|
+
import { existsSync as existsSync93 } from "fs";
|
|
44912
44989
|
import { basename as basename29 } from "path";
|
|
44913
44990
|
|
|
44914
44991
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -44929,9 +45006,9 @@ function accountedTrees(sessions) {
|
|
|
44929
45006
|
}
|
|
44930
45007
|
|
|
44931
45008
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
44932
|
-
import { existsSync as
|
|
45009
|
+
import { existsSync as existsSync92 } from "fs";
|
|
44933
45010
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
44934
|
-
if (!
|
|
45011
|
+
if (!existsSync92(clone)) {
|
|
44935
45012
|
for (const { path: path106 } of paths) forgetWorktree(path106);
|
|
44936
45013
|
daemonLog(
|
|
44937
45014
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -45097,7 +45174,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
45097
45174
|
);
|
|
45098
45175
|
continue;
|
|
45099
45176
|
}
|
|
45100
|
-
if (!
|
|
45177
|
+
if (!existsSync93(path106)) {
|
|
45101
45178
|
logVanishedTree(sessions, path106);
|
|
45102
45179
|
vanished.set(clone, [
|
|
45103
45180
|
...vanished.get(clone) ?? [],
|
|
@@ -45513,7 +45590,7 @@ function failPendingCreators(state, message3) {
|
|
|
45513
45590
|
}
|
|
45514
45591
|
function resetRelayState(state, reason4) {
|
|
45515
45592
|
failPendingCreators(state, reason4);
|
|
45516
|
-
for (const
|
|
45593
|
+
for (const resolve27 of state.historyWaiters) resolve27([]);
|
|
45517
45594
|
state.historyWaiters = [];
|
|
45518
45595
|
state.sessions = [];
|
|
45519
45596
|
state.lastSnapshot = void 0;
|
|
@@ -45954,16 +46031,16 @@ var HISTORY_TIMEOUT_MS = 5e3;
|
|
|
45954
46031
|
function requestLinkHistory(ctx) {
|
|
45955
46032
|
if (!ctx.greeted) return Promise.resolve([]);
|
|
45956
46033
|
const waiters = ctx.relay.historyWaiters;
|
|
45957
|
-
return new Promise((
|
|
46034
|
+
return new Promise((resolve27) => {
|
|
45958
46035
|
const settle = (sessions) => {
|
|
45959
46036
|
clearTimeout(timer);
|
|
45960
|
-
|
|
46037
|
+
resolve27(sessions);
|
|
45961
46038
|
};
|
|
45962
46039
|
const timer = setTimeout(() => {
|
|
45963
46040
|
const index2 = waiters.indexOf(settle);
|
|
45964
46041
|
if (index2 !== -1) waiters.splice(index2, 1);
|
|
45965
46042
|
daemonLog(`link ${ctx.spec.name} ws: history timed out`);
|
|
45966
|
-
|
|
46043
|
+
resolve27(ctx.relay.lastHistory ?? []);
|
|
45967
46044
|
}, HISTORY_TIMEOUT_MS);
|
|
45968
46045
|
timer.unref?.();
|
|
45969
46046
|
waiters.push(settle);
|
|
@@ -46187,7 +46264,7 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
|
|
|
46187
46264
|
}
|
|
46188
46265
|
|
|
46189
46266
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
46190
|
-
import { existsSync as
|
|
46267
|
+
import { existsSync as existsSync96 } from "fs";
|
|
46191
46268
|
|
|
46192
46269
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
46193
46270
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -46218,10 +46295,10 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
46218
46295
|
}
|
|
46219
46296
|
|
|
46220
46297
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
46221
|
-
import { existsSync as
|
|
46298
|
+
import { existsSync as existsSync95 } from "fs";
|
|
46222
46299
|
|
|
46223
46300
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
46224
|
-
import { copyFileSync as copyFileSync5, existsSync as
|
|
46301
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync94, mkdirSync as mkdirSync36 } from "fs";
|
|
46225
46302
|
import { join as join101 } from "path";
|
|
46226
46303
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
46227
46304
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -46232,7 +46309,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
46232
46309
|
return;
|
|
46233
46310
|
}
|
|
46234
46311
|
const dest = join101(dir, `${claudeSessionId}.jsonl`);
|
|
46235
|
-
if (
|
|
46312
|
+
if (existsSync94(dest)) {
|
|
46236
46313
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
46237
46314
|
return;
|
|
46238
46315
|
}
|
|
@@ -46283,7 +46360,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
46283
46360
|
}
|
|
46284
46361
|
function cloneForReapedTree(missingCwd) {
|
|
46285
46362
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
46286
|
-
if (!clone || !
|
|
46363
|
+
if (!clone || !existsSync95(clone))
|
|
46287
46364
|
throw new Error(
|
|
46288
46365
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
46289
46366
|
);
|
|
@@ -46292,7 +46369,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
46292
46369
|
|
|
46293
46370
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
46294
46371
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
46295
|
-
if (!
|
|
46372
|
+
if (!existsSync96(cwd))
|
|
46296
46373
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
46297
46374
|
const id = ctx.spawnWith(
|
|
46298
46375
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -46427,8 +46504,8 @@ var SessionManager = class {
|
|
|
46427
46504
|
update(mutate) {
|
|
46428
46505
|
if (mutate(this.sessions)) this.notify();
|
|
46429
46506
|
}
|
|
46430
|
-
setStatus(
|
|
46431
|
-
setStatusFromHook(this.sessions,
|
|
46507
|
+
setStatus(report) {
|
|
46508
|
+
setStatusFromHook(this.sessions, report, this.notify, this.onStatusChange);
|
|
46432
46509
|
}
|
|
46433
46510
|
/* why: the status line relays token totals keyed by Claude's session id; join
|
|
46434
46511
|
* it to the running backlog phase so the spend accumulates against that row. */
|
|
@@ -47114,7 +47191,7 @@ function handleConnection(socket, manager) {
|
|
|
47114
47191
|
}
|
|
47115
47192
|
|
|
47116
47193
|
// src/commands/sessions/daemon/onListening.ts
|
|
47117
|
-
import { unlinkSync as unlinkSync22, writeFileSync as
|
|
47194
|
+
import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync54 } from "fs";
|
|
47118
47195
|
|
|
47119
47196
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
47120
47197
|
import { readFileSync as readFileSync65 } from "fs";
|
|
@@ -47136,7 +47213,7 @@ function ownsPidFile() {
|
|
|
47136
47213
|
|
|
47137
47214
|
// src/commands/sessions/daemon/onListening.ts
|
|
47138
47215
|
function onListening(manager, checkAutoExit) {
|
|
47139
|
-
|
|
47216
|
+
writeFileSync54(daemonPaths.pid, String(process.pid));
|
|
47140
47217
|
startPidFileWatchdog(() => {
|
|
47141
47218
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
47142
47219
|
void manager.flushActiveMs().finally(() => {
|
|
@@ -47297,17 +47374,17 @@ async function findUnlinkedWindowsNode(health2, platform = detectPlatform()) {
|
|
|
47297
47374
|
|
|
47298
47375
|
// src/commands/sessions/nodes/printReport.ts
|
|
47299
47376
|
import chalk254 from "chalk";
|
|
47300
|
-
function printReport(
|
|
47301
|
-
if (
|
|
47302
|
-
console.log(`${
|
|
47303
|
-
if (
|
|
47377
|
+
function printReport(report) {
|
|
47378
|
+
if (report.links.length === 0) {
|
|
47379
|
+
console.log(`${report.local} has no links`);
|
|
47380
|
+
if (report.suggestion)
|
|
47304
47381
|
console.log(
|
|
47305
|
-
`A Windows node (${
|
|
47306
|
-
${
|
|
47382
|
+
`A Windows node (${report.suggestion.nodeName}) answers on ${report.suggestion.url} but is not linked. Link it with:
|
|
47383
|
+
${report.suggestion.command}`
|
|
47307
47384
|
);
|
|
47308
47385
|
return;
|
|
47309
47386
|
}
|
|
47310
|
-
for (const diagnosis of
|
|
47387
|
+
for (const diagnosis of report.links) printDiagnosis(diagnosis);
|
|
47311
47388
|
}
|
|
47312
47389
|
function printDiagnosis(diagnosis) {
|
|
47313
47390
|
console.log(`${chalk254.bold(diagnosis.name)} ${chalk254.dim(diagnosis.url)}`);
|
|
@@ -47324,13 +47401,13 @@ async function doctorNodes(name, options2) {
|
|
|
47324
47401
|
if (name && specs.length === 0)
|
|
47325
47402
|
throw new Error(`No link named ${name}; see assist sessions nodes`);
|
|
47326
47403
|
const probes = buildDoctorProbes(await queryNodes());
|
|
47327
|
-
const
|
|
47328
|
-
for (const spec of specs)
|
|
47404
|
+
const report = { local: resolveNodeName(), links: [] };
|
|
47405
|
+
for (const spec of specs) report.links.push(await diagnoseLink(spec, probes));
|
|
47329
47406
|
if (specs.length === 0)
|
|
47330
|
-
|
|
47331
|
-
if (
|
|
47332
|
-
if (options2.json) console.log(JSON.stringify(
|
|
47333
|
-
else printReport(
|
|
47407
|
+
report.suggestion = await findUnlinkedWindowsNode(probes.health);
|
|
47408
|
+
if (report.links.some((l) => !l.ok)) process.exitCode = 1;
|
|
47409
|
+
if (options2.json) console.log(JSON.stringify(report, null, 2));
|
|
47410
|
+
else printReport(report);
|
|
47334
47411
|
}
|
|
47335
47412
|
|
|
47336
47413
|
// src/commands/sessions/nodes/listNodes.ts
|
|
@@ -47346,16 +47423,16 @@ async function nodesReport() {
|
|
|
47346
47423
|
};
|
|
47347
47424
|
}
|
|
47348
47425
|
async function listNodes(options2) {
|
|
47349
|
-
const
|
|
47426
|
+
const report = await nodesReport();
|
|
47350
47427
|
if (options2.json) {
|
|
47351
|
-
console.log(JSON.stringify(
|
|
47428
|
+
console.log(JSON.stringify(report, null, 2));
|
|
47352
47429
|
return;
|
|
47353
47430
|
}
|
|
47354
|
-
console.log(`${
|
|
47355
|
-
if (!
|
|
47431
|
+
console.log(`${report.local} ${chalk255.dim("(this node)")}`);
|
|
47432
|
+
if (!report.daemonRunning)
|
|
47356
47433
|
console.log(chalk255.dim(" daemon not running; showing configured links"));
|
|
47357
|
-
if (
|
|
47358
|
-
for (const link3 of
|
|
47434
|
+
if (report.links.length === 0) console.log(chalk255.dim(" no links"));
|
|
47435
|
+
for (const link3 of report.links) console.log(formatLink(link3));
|
|
47359
47436
|
}
|
|
47360
47437
|
|
|
47361
47438
|
// src/commands/sessions/nodes/nodeLogs.ts
|