@staff0rd/assist 0.706.4 → 0.707.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/allowed.cli-reads +1 -0
- package/dist/allowed.cli-reads +1 -0
- package/dist/commands/sessions/web/bundle.js +402 -402
- package/dist/index.js +1346 -1293
- 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.707.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -540,6 +540,12 @@ function resolveRepoWriteLabel(globalRaw, origin) {
|
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
// src/shared/stripLegacyConfigKeys.ts
|
|
543
|
+
var LEGACY_SESSIONS_KEYS = [
|
|
544
|
+
"windowsProjectsRoot",
|
|
545
|
+
"windowsDaemonHost",
|
|
546
|
+
"windowsDaemonPort",
|
|
547
|
+
"windowsVersionCheck"
|
|
548
|
+
];
|
|
543
549
|
function stripLegacyConfigKeys(config) {
|
|
544
550
|
const stripped = { ...config };
|
|
545
551
|
const news = stripped.news;
|
|
@@ -547,6 +553,12 @@ function stripLegacyConfigKeys(config) {
|
|
|
547
553
|
const { feeds: _feeds, ...rest } = news;
|
|
548
554
|
stripped.news = rest;
|
|
549
555
|
}
|
|
556
|
+
const sessions = stripped.sessions;
|
|
557
|
+
if (sessions && typeof sessions === "object") {
|
|
558
|
+
const rest = { ...sessions };
|
|
559
|
+
for (const key of LEGACY_SESSIONS_KEYS) delete rest[key];
|
|
560
|
+
stripped.sessions = rest;
|
|
561
|
+
}
|
|
550
562
|
return stripped;
|
|
551
563
|
}
|
|
552
564
|
|
|
@@ -812,13 +824,8 @@ var assistConfigShape = {
|
|
|
812
824
|
}).default({ outputDir: "./screenshots" }),
|
|
813
825
|
sessions: z3.strictObject({
|
|
814
826
|
nodeName: z3.string().optional(),
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
// why: host the WSL daemon dials to reach the native Windows daemon over TCP (WSL can't use the Windows named pipe); defaults to 127.0.0.1 (WSL2 mirrored networking). NAT-mode users set the Windows host IP.
|
|
818
|
-
windowsDaemonHost: z3.string().optional(),
|
|
819
|
-
// why: TCP port the native Windows daemon listens on for the WSL bridge; defaults to 51764
|
|
820
|
-
windowsDaemonPort: z3.number().optional(),
|
|
821
|
-
windowsVersionCheck: z3.enum(["block", "warn", "off"]).default("block"),
|
|
827
|
+
links: z3.array(z3.strictObject({ name: z3.string(), url: z3.string() })).optional(),
|
|
828
|
+
linkVersionCheck: z3.enum(["block", "warn", "off"]).default("block"),
|
|
822
829
|
includeCommittedChanges: z3.boolean().default(true),
|
|
823
830
|
topBar: z3.boolean().default(true),
|
|
824
831
|
floatWaiting: z3.boolean().default(true),
|
|
@@ -8453,12 +8460,9 @@ async function readHeadLines(handle) {
|
|
|
8453
8460
|
|
|
8454
8461
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
8455
8462
|
function sessionRoots() {
|
|
8456
|
-
|
|
8463
|
+
return [
|
|
8457
8464
|
{ dir: path22.join(os4.homedir(), ".claude", "projects"), origin: "wsl" }
|
|
8458
8465
|
];
|
|
8459
|
-
const windowsRoot = loadConfig().sessions?.windowsProjectsRoot;
|
|
8460
|
-
if (windowsRoot) roots.push({ dir: windowsRoot, origin: "windows" });
|
|
8461
|
-
return roots;
|
|
8462
8466
|
}
|
|
8463
8467
|
async function discoverSessionJsonlPaths() {
|
|
8464
8468
|
const results = [];
|
|
@@ -10682,14 +10686,6 @@ function delay(ms) {
|
|
|
10682
10686
|
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
10683
10687
|
}
|
|
10684
10688
|
|
|
10685
|
-
// src/commands/sessions/daemon/isWindowsCwd.ts
|
|
10686
|
-
function isWindowsCwd(cwd) {
|
|
10687
|
-
return /^[A-Za-z]:[\\/]/.test(cwd);
|
|
10688
|
-
}
|
|
10689
|
-
function shouldProxyToWindows(cwd) {
|
|
10690
|
-
return detectPlatform() === "wsl" && isWindowsCwd(cwd);
|
|
10691
|
-
}
|
|
10692
|
-
|
|
10693
10689
|
// src/commands/sessions/daemon/originForCwd.ts
|
|
10694
10690
|
var cache = /* @__PURE__ */ new Map();
|
|
10695
10691
|
function originResolutionForCwd(cwd) {
|
|
@@ -10885,14 +10881,14 @@ function resolveRepoGroup(cwd) {
|
|
|
10885
10881
|
const origin = clone ? originResolutionForCwd(clone) : void 0;
|
|
10886
10882
|
if (clone && origin)
|
|
10887
10883
|
return {
|
|
10888
|
-
group: hostedGroup(
|
|
10884
|
+
group: hostedGroup(origin.origin, clone),
|
|
10889
10885
|
stable: origin.stable
|
|
10890
10886
|
};
|
|
10891
10887
|
const reaped = worktreeAttributionIncludingReaped(cwd);
|
|
10892
10888
|
if (!reaped) return { group: void 0, stable: repoDirExists(cwd) };
|
|
10893
10889
|
const current = currentOriginOfClone(reaped.clone);
|
|
10894
10890
|
return {
|
|
10895
|
-
group: hostedGroup(
|
|
10891
|
+
group: hostedGroup(current?.origin ?? reaped.origin, reaped.clone),
|
|
10896
10892
|
stable: current?.stable === true
|
|
10897
10893
|
};
|
|
10898
10894
|
}
|
|
@@ -10900,11 +10896,8 @@ function currentOriginOfClone(clone) {
|
|
|
10900
10896
|
const main = mainWorktree(clone);
|
|
10901
10897
|
return main ? originResolutionForCwd(main) : void 0;
|
|
10902
10898
|
}
|
|
10903
|
-
function hostedGroup(
|
|
10904
|
-
return {
|
|
10905
|
-
origin: shouldProxyToWindows(cwd) ? `windows:${origin}` : origin,
|
|
10906
|
-
clone
|
|
10907
|
-
};
|
|
10899
|
+
function hostedGroup(origin, clone) {
|
|
10900
|
+
return { origin, clone };
|
|
10908
10901
|
}
|
|
10909
10902
|
|
|
10910
10903
|
// src/commands/sessions/web/attachSessionSocket.ts
|
|
@@ -10912,6 +10905,61 @@ import { WebSocketServer } from "ws";
|
|
|
10912
10905
|
|
|
10913
10906
|
// src/commands/sessions/web/handleSocket.ts
|
|
10914
10907
|
import { createInterface as createInterface4 } from "readline";
|
|
10908
|
+
|
|
10909
|
+
// src/commands/sessions/daemon/links/isLinkCreate.ts
|
|
10910
|
+
var CREATE_TYPES = /* @__PURE__ */ new Set([
|
|
10911
|
+
"create",
|
|
10912
|
+
"create-assist",
|
|
10913
|
+
"create-run",
|
|
10914
|
+
"resume"
|
|
10915
|
+
]);
|
|
10916
|
+
var SESSION_REF_KEYS = ["sessionId", "joinSessionId", "launchedFrom"];
|
|
10917
|
+
function isLinkCreate(type) {
|
|
10918
|
+
return typeof type === "string" && CREATE_TYPES.has(type);
|
|
10919
|
+
}
|
|
10920
|
+
function sessionRefKeys(type) {
|
|
10921
|
+
return type === "resume" ? [] : SESSION_REF_KEYS;
|
|
10922
|
+
}
|
|
10923
|
+
|
|
10924
|
+
// src/commands/sessions/daemon/links/splitNodeSessionId.ts
|
|
10925
|
+
function toNodeSessionId(node, id) {
|
|
10926
|
+
return `${node}:${id}`;
|
|
10927
|
+
}
|
|
10928
|
+
function splitNodeSessionId(id) {
|
|
10929
|
+
const at2 = id.indexOf(":");
|
|
10930
|
+
if (at2 <= 0) return void 0;
|
|
10931
|
+
return { node: id.slice(0, at2), id: id.slice(at2 + 1) };
|
|
10932
|
+
}
|
|
10933
|
+
|
|
10934
|
+
// src/commands/sessions/daemon/links/resolveLinkTarget.ts
|
|
10935
|
+
function resolveLinkTarget(data, localNode, isLinked) {
|
|
10936
|
+
for (const key of sessionRefKeys(data.type)) {
|
|
10937
|
+
const value = data[key];
|
|
10938
|
+
if (typeof value !== "string") continue;
|
|
10939
|
+
const split = splitNodeSessionId(value);
|
|
10940
|
+
if (!split) return { kind: "local" };
|
|
10941
|
+
return byNode(split.node, localNode, isLinked);
|
|
10942
|
+
}
|
|
10943
|
+
if (typeof data.node === "string" && data.node)
|
|
10944
|
+
return byNode(data.node, localNode, isLinked);
|
|
10945
|
+
return { kind: "local" };
|
|
10946
|
+
}
|
|
10947
|
+
function byNode(node, localNode, isLinked) {
|
|
10948
|
+
if (node === localNode) return { kind: "local" };
|
|
10949
|
+
return isLinked(node) ? { kind: "link", node } : { kind: "unknown", node };
|
|
10950
|
+
}
|
|
10951
|
+
|
|
10952
|
+
// src/commands/sessions/shared/resolveNodeName.ts
|
|
10953
|
+
import { hostname } from "os";
|
|
10954
|
+
function defaultNodeName(host = hostname(), platform = detectPlatform()) {
|
|
10955
|
+
const base = host.split(".")[0].toLowerCase();
|
|
10956
|
+
return platform === "wsl" ? `${base}-wsl` : base;
|
|
10957
|
+
}
|
|
10958
|
+
function resolveNodeName() {
|
|
10959
|
+
return loadConfig().sessions?.nodeName?.trim() || defaultNodeName();
|
|
10960
|
+
}
|
|
10961
|
+
|
|
10962
|
+
// src/commands/sessions/web/handleSocket.ts
|
|
10915
10963
|
var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
|
|
10916
10964
|
function handleSocket(ws, ctx) {
|
|
10917
10965
|
const connection = openDaemonConnection(ws, ctx);
|
|
@@ -10963,12 +11011,16 @@ function withDefaultCwd(raw, serverCwd) {
|
|
|
10963
11011
|
try {
|
|
10964
11012
|
const data = JSON.parse(raw);
|
|
10965
11013
|
if (!CWD_DEFAULTED_TYPES.has(data.type) || data.cwd) return raw;
|
|
11014
|
+
if (targetsLinkedNode(data)) return raw;
|
|
10966
11015
|
data.cwd = serverCwd;
|
|
10967
11016
|
return JSON.stringify(data);
|
|
10968
11017
|
} catch {
|
|
10969
11018
|
return raw;
|
|
10970
11019
|
}
|
|
10971
11020
|
}
|
|
11021
|
+
function targetsLinkedNode(data) {
|
|
11022
|
+
return resolveLinkTarget(data, resolveNodeName(), () => true).kind !== "local";
|
|
11023
|
+
}
|
|
10972
11024
|
function withRepoCwd(line, repoCwd) {
|
|
10973
11025
|
if (!repoCwd) return line;
|
|
10974
11026
|
try {
|
|
@@ -11836,36 +11888,6 @@ async function getBackups(_req, res) {
|
|
|
11836
11888
|
respondJson(res, 200, await listBackups(await getDb()));
|
|
11837
11889
|
}
|
|
11838
11890
|
|
|
11839
|
-
// src/shared/globalConfigTargetFor.ts
|
|
11840
|
-
import { existsSync as existsSync34 } from "fs";
|
|
11841
|
-
import { posix as posix2 } from "path";
|
|
11842
|
-
|
|
11843
|
-
// src/shared/windowsHomeFromWsl.ts
|
|
11844
|
-
import { posix } from "path";
|
|
11845
|
-
function windowsHomeFromWsl() {
|
|
11846
|
-
const projectsRootUnderWinHome = loadConfig().sessions?.windowsProjectsRoot;
|
|
11847
|
-
if (!projectsRootUnderWinHome) return null;
|
|
11848
|
-
return posix.dirname(posix.dirname(projectsRootUnderWinHome));
|
|
11849
|
-
}
|
|
11850
|
-
|
|
11851
|
-
// src/shared/globalConfigTargetFor.ts
|
|
11852
|
-
function globalConfigTargetFor(cwd) {
|
|
11853
|
-
if (!shouldProxyToWindows(cwd))
|
|
11854
|
-
return { ok: true, path: getGlobalConfigPath() };
|
|
11855
|
-
const winHome = windowsHomeFromWsl();
|
|
11856
|
-
if (!winHome)
|
|
11857
|
-
return {
|
|
11858
|
-
ok: false,
|
|
11859
|
-
error: `${cwd} runs on the Windows host, whose ~/.assist.yml cannot be located because sessions.windowsProjectsRoot is unset. Set it with: assist config set sessions.windowsProjectsRoot /mnt/c/Users/<you>/.claude/projects`
|
|
11860
|
-
};
|
|
11861
|
-
if (!existsSync34(winHome))
|
|
11862
|
-
return {
|
|
11863
|
-
ok: false,
|
|
11864
|
-
error: `${cwd} runs on the Windows host, whose home ${winHome} is not reachable from here. Check that the Windows drive is mounted and sessions.windowsProjectsRoot points at it.`
|
|
11865
|
-
};
|
|
11866
|
-
return { ok: true, path: posix2.join(winHome, ".assist.yml") };
|
|
11867
|
-
}
|
|
11868
|
-
|
|
11869
11891
|
// src/shared/configEnumDescriptions.ts
|
|
11870
11892
|
var byKey = {
|
|
11871
11893
|
"advice.sections": adviceFragmentTitles
|
|
@@ -12695,33 +12717,27 @@ var seqConfigHelp = [
|
|
|
12695
12717
|
}
|
|
12696
12718
|
];
|
|
12697
12719
|
|
|
12720
|
+
// src/commands/sessions/nodes/nodesConfigHelp.ts
|
|
12721
|
+
var nodesConfigHelp = [
|
|
12722
|
+
{
|
|
12723
|
+
key: "sessions.links",
|
|
12724
|
+
setter: "assist sessions nodes link <name> http://127.0.0.1:<port>",
|
|
12725
|
+
note: "linked nodes whose sessions merge into this node's web UI; each name must match the peer's sessions.nodeName"
|
|
12726
|
+
},
|
|
12727
|
+
{
|
|
12728
|
+
key: "sessions.linkVersionCheck",
|
|
12729
|
+
setter: "assist config set sessions.linkVersionCheck block -g",
|
|
12730
|
+
note: "reaction to a version mismatch with a linked node: block (default) heals an older peer via its /api/self-update and latches if the gap remains, warn proceeds, off skips the check"
|
|
12731
|
+
}
|
|
12732
|
+
];
|
|
12733
|
+
|
|
12698
12734
|
// src/commands/sessions/sessionsConfigHelp.ts
|
|
12699
12735
|
var sessionsConfigHelp = [
|
|
12700
12736
|
{
|
|
12701
12737
|
key: "sessions.nodeName",
|
|
12702
|
-
setter: "assist config set sessions.nodeName
|
|
12738
|
+
setter: "assist config set sessions.nodeName <name> -g",
|
|
12703
12739
|
note: "this install's node label, shown in the web UI hamburger menu and reported by /api/health (default: OS hostname, with -wsl under WSL)"
|
|
12704
12740
|
},
|
|
12705
|
-
{
|
|
12706
|
-
key: "sessions.windowsProjectsRoot",
|
|
12707
|
-
setter: "assist config set sessions.windowsProjectsRoot /mnt/c/Users/you/.claude/projects",
|
|
12708
|
-
note: "WSL path to the Windows .claude/projects root to discover"
|
|
12709
|
-
},
|
|
12710
|
-
{
|
|
12711
|
-
key: "sessions.windowsDaemonHost",
|
|
12712
|
-
setter: "assist config set sessions.windowsDaemonHost 127.0.0.1",
|
|
12713
|
-
note: "host the WSL daemon dials to reach the Windows daemon (default: 127.0.0.1)"
|
|
12714
|
-
},
|
|
12715
|
-
{
|
|
12716
|
-
key: "sessions.windowsDaemonPort",
|
|
12717
|
-
setter: "assist config set sessions.windowsDaemonPort 51764",
|
|
12718
|
-
note: "TCP port the Windows daemon listens on (default: 51764)"
|
|
12719
|
-
},
|
|
12720
|
-
{
|
|
12721
|
-
key: "sessions.windowsVersionCheck",
|
|
12722
|
-
setter: "assist config set sessions.windowsVersionCheck block",
|
|
12723
|
-
note: "Windows daemon version mismatch handling: block | warn | off"
|
|
12724
|
-
},
|
|
12725
12741
|
{
|
|
12726
12742
|
key: "sessions.includeCommittedChanges",
|
|
12727
12743
|
setter: "assist config set sessions.includeCommittedChanges false -g",
|
|
@@ -12928,6 +12944,7 @@ var configHelpEntries = [
|
|
|
12928
12944
|
...runConfigHelp,
|
|
12929
12945
|
...seqConfigHelp,
|
|
12930
12946
|
...sessionsConfigHelp,
|
|
12947
|
+
...nodesConfigHelp,
|
|
12931
12948
|
...slackConfigHelp,
|
|
12932
12949
|
...sqlConfigHelp,
|
|
12933
12950
|
...transcriptConfigHelp,
|
|
@@ -12990,13 +13007,8 @@ function readConfigEntries(cwd, globalConfigPath = getGlobalConfigPath()) {
|
|
|
12990
13007
|
function getConfig(req, res) {
|
|
12991
13008
|
const cwd = getCwdParam(req, res);
|
|
12992
13009
|
if (!cwd) return;
|
|
12993
|
-
const target = globalConfigTargetFor(cwd);
|
|
12994
|
-
if (!target.ok) {
|
|
12995
|
-
respondJson(res, 500, { error: target.error });
|
|
12996
|
-
return;
|
|
12997
|
-
}
|
|
12998
13010
|
try {
|
|
12999
|
-
respondJson(res, 200, readConfigEntries(toGitCwd(cwd)
|
|
13011
|
+
respondJson(res, 200, readConfigEntries(toGitCwd(cwd)));
|
|
13000
13012
|
} catch (error) {
|
|
13001
13013
|
respondJson(res, 500, {
|
|
13002
13014
|
error: error instanceof Error ? error.message : "Failed to read config"
|
|
@@ -13060,14 +13072,14 @@ import { basename as basename11, join as join37 } from "path";
|
|
|
13060
13072
|
import { promisify as promisify3 } from "util";
|
|
13061
13073
|
|
|
13062
13074
|
// src/commands/sessions/web/findSynthesisForBranch.ts
|
|
13063
|
-
import { existsSync as
|
|
13075
|
+
import { existsSync as existsSync34, readdirSync as readdirSync4, statSync as statSync5 } from "fs";
|
|
13064
13076
|
import { basename as basename10, dirname as dirname22, join as join36 } from "path";
|
|
13065
13077
|
function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
13066
13078
|
const branchKeyPath = join36(repoReviewsDir, `${branch2}-`);
|
|
13067
13079
|
const parent = dirname22(branchKeyPath);
|
|
13068
13080
|
const branchPrefix = basename10(branchKeyPath);
|
|
13069
|
-
if (!
|
|
13070
|
-
const synthesisFiles = readdirSync4(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join36(parent, name, "synthesis.md")).filter((path103) =>
|
|
13081
|
+
if (!existsSync34(parent)) return null;
|
|
13082
|
+
const synthesisFiles = readdirSync4(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join36(parent, name, "synthesis.md")).filter((path103) => existsSync34(path103)).map((path103) => ({ path: path103, mtime: statSync5(path103).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
13071
13083
|
return synthesisFiles[0]?.path ?? null;
|
|
13072
13084
|
}
|
|
13073
13085
|
|
|
@@ -13289,8 +13301,14 @@ function harnessCapabilities(_req, res) {
|
|
|
13289
13301
|
// src/commands/sessions/daemon/buildHello.ts
|
|
13290
13302
|
var ASSIST_VERSION = package_default.version;
|
|
13291
13303
|
var PROTOCOL_VERSION = 2;
|
|
13292
|
-
function buildHello() {
|
|
13293
|
-
return {
|
|
13304
|
+
function buildHello(extra = {}) {
|
|
13305
|
+
return {
|
|
13306
|
+
type: "hello",
|
|
13307
|
+
version: ASSIST_VERSION,
|
|
13308
|
+
protocol: PROTOCOL_VERSION,
|
|
13309
|
+
nodeName: resolveNodeName(),
|
|
13310
|
+
...extra
|
|
13311
|
+
};
|
|
13294
13312
|
}
|
|
13295
13313
|
function isHello(msg) {
|
|
13296
13314
|
return msg.type === "hello" && typeof msg.version === "string" && (msg.protocol === void 0 || typeof msg.protocol === "number");
|
|
@@ -13306,16 +13324,6 @@ function protocolMismatched(msg) {
|
|
|
13306
13324
|
return typeof msg.protocol === "number" && msg.protocol !== PROTOCOL_VERSION;
|
|
13307
13325
|
}
|
|
13308
13326
|
|
|
13309
|
-
// src/commands/sessions/shared/resolveNodeName.ts
|
|
13310
|
-
import { hostname } from "os";
|
|
13311
|
-
function defaultNodeName(host = hostname(), platform = detectPlatform()) {
|
|
13312
|
-
const base = host.split(".")[0].toLowerCase();
|
|
13313
|
-
return platform === "wsl" ? `${base}-wsl` : base;
|
|
13314
|
-
}
|
|
13315
|
-
function resolveNodeName() {
|
|
13316
|
-
return loadConfig().sessions?.nodeName?.trim() || defaultNodeName();
|
|
13317
|
-
}
|
|
13318
|
-
|
|
13319
13327
|
// src/commands/sessions/web/health.ts
|
|
13320
13328
|
async function health(_req, res) {
|
|
13321
13329
|
respondJson(res, 200, {
|
|
@@ -13544,7 +13552,7 @@ function newsNavConfig(_req, res) {
|
|
|
13544
13552
|
import path27 from "path";
|
|
13545
13553
|
|
|
13546
13554
|
// src/commands/rules/readScopedRules.ts
|
|
13547
|
-
import { existsSync as
|
|
13555
|
+
import { existsSync as existsSync36, readFileSync as readFileSync23 } from "fs";
|
|
13548
13556
|
import path26 from "path";
|
|
13549
13557
|
|
|
13550
13558
|
// src/commands/rules/rulesSectionRange.ts
|
|
@@ -13593,11 +13601,11 @@ function parseRulesSection(content) {
|
|
|
13593
13601
|
}
|
|
13594
13602
|
|
|
13595
13603
|
// src/commands/rules/scopeDirectory.ts
|
|
13596
|
-
import { existsSync as
|
|
13604
|
+
import { existsSync as existsSync35, statSync as statSync6 } from "fs";
|
|
13597
13605
|
import path25 from "path";
|
|
13598
13606
|
function scopeDirectory(target) {
|
|
13599
13607
|
const resolved = path25.resolve(target);
|
|
13600
|
-
return
|
|
13608
|
+
return existsSync35(resolved) && statSync6(resolved).isDirectory() ? resolved : path25.dirname(resolved);
|
|
13601
13609
|
}
|
|
13602
13610
|
|
|
13603
13611
|
// src/commands/rules/readScopedRules.ts
|
|
@@ -13608,7 +13616,7 @@ function scopedClaudeFiles(target) {
|
|
|
13608
13616
|
let current = startDir;
|
|
13609
13617
|
while (true) {
|
|
13610
13618
|
const candidate = path26.join(current, "CLAUDE.md");
|
|
13611
|
-
if (
|
|
13619
|
+
if (existsSync36(candidate)) files.push(candidate);
|
|
13612
13620
|
if (current === root2 || current === path26.dirname(current)) break;
|
|
13613
13621
|
current = path26.dirname(current);
|
|
13614
13622
|
}
|
|
@@ -14472,7 +14480,7 @@ async function streamState(cwd, stream, repoEnvironments2 = streamEnvironments(s
|
|
|
14472
14480
|
edges: stream.edges
|
|
14473
14481
|
};
|
|
14474
14482
|
try {
|
|
14475
|
-
const [deployments, { run: run4, byNode }] = await Promise.all([
|
|
14483
|
+
const [deployments, { run: run4, byNode: byNode2 }] = await Promise.all([
|
|
14476
14484
|
liveDeployments(cwd, stream.repo, repoEnvironments2),
|
|
14477
14485
|
streamRunState(cwd, stream)
|
|
14478
14486
|
]);
|
|
@@ -14486,7 +14494,7 @@ async function streamState(cwd, stream, repoEnvironments2 = streamEnvironments(s
|
|
|
14486
14494
|
node,
|
|
14487
14495
|
deployments,
|
|
14488
14496
|
behind,
|
|
14489
|
-
|
|
14497
|
+
byNode2.get(node.id) ?? null
|
|
14490
14498
|
)
|
|
14491
14499
|
),
|
|
14492
14500
|
run: run4
|
|
@@ -14602,7 +14610,6 @@ function reExecWebServer(deps2 = {}) {
|
|
|
14602
14610
|
// src/commands/sessions/web/restartWeb.ts
|
|
14603
14611
|
var TARGETS = ["daemon", "webserver", "both"];
|
|
14604
14612
|
async function restartWeb(req, res, deps2 = {}) {
|
|
14605
|
-
const { restartDaemonFn = restartDaemon, reExecFn = reExecWebServer } = deps2;
|
|
14606
14613
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
14607
14614
|
const target = url.searchParams.get("target");
|
|
14608
14615
|
if (!target || !TARGETS.includes(target)) {
|
|
@@ -14613,6 +14620,10 @@ async function restartWeb(req, res, deps2 = {}) {
|
|
|
14613
14620
|
res.once("finish", resolve25);
|
|
14614
14621
|
respondJson(res, 200, { ok: true });
|
|
14615
14622
|
});
|
|
14623
|
+
await performRestart(target, deps2);
|
|
14624
|
+
}
|
|
14625
|
+
async function performRestart(target, deps2 = {}) {
|
|
14626
|
+
const { restartDaemonFn = restartDaemon, reExecFn = reExecWebServer } = deps2;
|
|
14616
14627
|
if (target === "daemon" || target === "both") {
|
|
14617
14628
|
await restartDaemonFn();
|
|
14618
14629
|
}
|
|
@@ -14664,6 +14675,89 @@ async function revertDiffFile(req, res) {
|
|
|
14664
14675
|
}
|
|
14665
14676
|
}
|
|
14666
14677
|
|
|
14678
|
+
// src/commands/run/runCommandToCompletion.ts
|
|
14679
|
+
import { spawn as spawn4 } from "child_process";
|
|
14680
|
+
import { existsSync as existsSync38 } from "fs";
|
|
14681
|
+
|
|
14682
|
+
// src/commands/run/resolveCommand.ts
|
|
14683
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
14684
|
+
import { existsSync as existsSync37 } from "fs";
|
|
14685
|
+
import { dirname as dirname23, join as join38, resolve as resolve12 } from "path";
|
|
14686
|
+
function resolveCommand(command) {
|
|
14687
|
+
if (process.platform !== "win32" || command !== "bash") return command;
|
|
14688
|
+
try {
|
|
14689
|
+
const gitPath = execFileSync3("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
14690
|
+
const gitRoot = resolve12(dirname23(gitPath), "..");
|
|
14691
|
+
const gitBash = join38(gitRoot, "bin", "bash.exe");
|
|
14692
|
+
if (existsSync37(gitBash)) return gitBash;
|
|
14693
|
+
} catch {
|
|
14694
|
+
return command;
|
|
14695
|
+
}
|
|
14696
|
+
return command;
|
|
14697
|
+
}
|
|
14698
|
+
|
|
14699
|
+
// src/commands/run/runCommandToCompletion.ts
|
|
14700
|
+
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
14701
|
+
return new Promise((resolveResult) => {
|
|
14702
|
+
if (cwd && !existsSync38(cwd)) {
|
|
14703
|
+
resolveResult({
|
|
14704
|
+
kind: "failed",
|
|
14705
|
+
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
14706
|
+
});
|
|
14707
|
+
return;
|
|
14708
|
+
}
|
|
14709
|
+
const child = spawn4(resolveCommand(command), args, {
|
|
14710
|
+
stdio: quiet ? "pipe" : "inherit",
|
|
14711
|
+
env: env ? { ...process.env, ...expandEnv(env) } : void 0,
|
|
14712
|
+
cwd
|
|
14713
|
+
});
|
|
14714
|
+
const chunks = [];
|
|
14715
|
+
if (quiet) {
|
|
14716
|
+
child.stdout?.on("data", (data) => chunks.push(data));
|
|
14717
|
+
child.stderr?.on("data", (data) => chunks.push(data));
|
|
14718
|
+
}
|
|
14719
|
+
child.on("close", (code) => {
|
|
14720
|
+
resolveResult({
|
|
14721
|
+
kind: "completed",
|
|
14722
|
+
exitCode: code ?? 0,
|
|
14723
|
+
output: Buffer.concat(chunks).toString()
|
|
14724
|
+
});
|
|
14725
|
+
});
|
|
14726
|
+
child.on("error", (err) => {
|
|
14727
|
+
resolveResult({
|
|
14728
|
+
kind: "failed",
|
|
14729
|
+
message: `Failed to execute command: ${err.message}`
|
|
14730
|
+
});
|
|
14731
|
+
});
|
|
14732
|
+
});
|
|
14733
|
+
}
|
|
14734
|
+
|
|
14735
|
+
// src/commands/sessions/web/selfUpdate.ts
|
|
14736
|
+
async function runAssistUpdate() {
|
|
14737
|
+
const result = await runCommandToCompletion("assist", ["update"]);
|
|
14738
|
+
if (result.kind === "failed") throw new Error(result.message);
|
|
14739
|
+
if (result.exitCode !== 0)
|
|
14740
|
+
throw new Error(`assist update exited with code ${result.exitCode}`);
|
|
14741
|
+
}
|
|
14742
|
+
async function selfUpdate(_req, res, deps2 = {}) {
|
|
14743
|
+
const { runUpdate = runAssistUpdate, ...restartDeps } = deps2;
|
|
14744
|
+
console.log("self-update: requested by a linked node; running assist update");
|
|
14745
|
+
try {
|
|
14746
|
+
await runUpdate();
|
|
14747
|
+
} catch (error) {
|
|
14748
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
14749
|
+
console.log(`self-update: failed: ${message3}`);
|
|
14750
|
+
respondJson(res, 500, { error: message3 });
|
|
14751
|
+
return;
|
|
14752
|
+
}
|
|
14753
|
+
console.log("self-update: updated; restarting daemon and web server");
|
|
14754
|
+
await new Promise((resolve25) => {
|
|
14755
|
+
res.once("finish", resolve25);
|
|
14756
|
+
respondJson(res, 200, { ok: true });
|
|
14757
|
+
});
|
|
14758
|
+
await performRestart("both", restartDeps);
|
|
14759
|
+
}
|
|
14760
|
+
|
|
14667
14761
|
// src/commands/sessions/web/revertDiffPaths.ts
|
|
14668
14762
|
import { relative as relative4 } from "path";
|
|
14669
14763
|
|
|
@@ -15097,11 +15191,6 @@ function applyScopedConfigSet(key, value, cwd, scope, globalConfigPath) {
|
|
|
15097
15191
|
return result.ok ? { ok: true, payload: { target: result.target } } : result;
|
|
15098
15192
|
}
|
|
15099
15193
|
|
|
15100
|
-
// src/commands/config/writesGlobalConfigFile.ts
|
|
15101
|
-
function writesGlobalConfigFile(scope) {
|
|
15102
|
-
return scope !== "project";
|
|
15103
|
-
}
|
|
15104
|
-
|
|
15105
15194
|
// src/commands/config/ConfigWriteScope.ts
|
|
15106
15195
|
function isConfigWriteScope(value) {
|
|
15107
15196
|
return value === "project" || value === "global" || value === "repo";
|
|
@@ -15132,17 +15221,8 @@ async function handleConfigWrite(req, res, apply) {
|
|
|
15132
15221
|
respondJson(res, 400, { error: parsed.error });
|
|
15133
15222
|
return;
|
|
15134
15223
|
}
|
|
15135
|
-
const target = globalConfigTargetFor(parsed.cwd);
|
|
15136
|
-
if (!target.ok && writesGlobalConfigFile(parsed.scope)) {
|
|
15137
|
-
respondJson(res, 400, { error: target.error, errors: [target.error] });
|
|
15138
|
-
return;
|
|
15139
|
-
}
|
|
15140
15224
|
try {
|
|
15141
|
-
const result = apply({
|
|
15142
|
-
...parsed,
|
|
15143
|
-
cwd: toGitCwd(parsed.cwd),
|
|
15144
|
-
globalConfigPath: target.ok ? target.path : void 0
|
|
15145
|
-
});
|
|
15225
|
+
const result = apply({ ...parsed, cwd: toGitCwd(parsed.cwd) });
|
|
15146
15226
|
if (!result.ok) {
|
|
15147
15227
|
respondJson(res, 400, {
|
|
15148
15228
|
error: result.errors.join("\n"),
|
|
@@ -15163,20 +15243,14 @@ function setConfig(req, res) {
|
|
|
15163
15243
|
return handleConfigWrite(req, res, (request) => {
|
|
15164
15244
|
const coerced = coerceConfigValue(
|
|
15165
15245
|
request.key,
|
|
15166
|
-
restoreConfigWriteSecrets(
|
|
15167
|
-
request.key,
|
|
15168
|
-
request.value,
|
|
15169
|
-
request.cwd,
|
|
15170
|
-
request.globalConfigPath
|
|
15171
|
-
)
|
|
15246
|
+
restoreConfigWriteSecrets(request.key, request.value, request.cwd)
|
|
15172
15247
|
);
|
|
15173
15248
|
if (!coerced.ok) return { ok: false, errors: [coerced.error] };
|
|
15174
15249
|
return applyScopedConfigSet(
|
|
15175
15250
|
request.key,
|
|
15176
15251
|
coerced.value,
|
|
15177
15252
|
request.cwd,
|
|
15178
|
-
request.scope
|
|
15179
|
-
request.globalConfigPath
|
|
15253
|
+
request.scope
|
|
15180
15254
|
);
|
|
15181
15255
|
});
|
|
15182
15256
|
}
|
|
@@ -15336,12 +15410,7 @@ function unsetConfig(req, res) {
|
|
|
15336
15410
|
return handleConfigWrite(req, res, (request) => {
|
|
15337
15411
|
if (!isKnownConfigKey(request.key))
|
|
15338
15412
|
return { ok: false, errors: [`Unknown config key "${request.key}"`] };
|
|
15339
|
-
return applyScopedConfigUnset(
|
|
15340
|
-
request.key,
|
|
15341
|
-
request.cwd,
|
|
15342
|
-
request.scope,
|
|
15343
|
-
request.globalConfigPath
|
|
15344
|
-
);
|
|
15413
|
+
return applyScopedConfigUnset(request.key, request.cwd, request.scope);
|
|
15345
15414
|
});
|
|
15346
15415
|
}
|
|
15347
15416
|
|
|
@@ -15422,7 +15491,7 @@ function uploadSizeLimit(contentType) {
|
|
|
15422
15491
|
// src/commands/sessions/web/writeTempImage.ts
|
|
15423
15492
|
import { mkdtemp, writeFile as writeFile2 } from "fs/promises";
|
|
15424
15493
|
import { tmpdir as tmpdir2 } from "os";
|
|
15425
|
-
import { extname, join as
|
|
15494
|
+
import { extname, join as join39 } from "path";
|
|
15426
15495
|
var EXT_BY_MIME = {
|
|
15427
15496
|
"image/png": "png",
|
|
15428
15497
|
"image/jpeg": "jpg",
|
|
@@ -15453,8 +15522,8 @@ function safeBaseName(name) {
|
|
|
15453
15522
|
return base.replace(/^-+|-+$/g, "").slice(0, 60) || "screenshot";
|
|
15454
15523
|
}
|
|
15455
15524
|
async function writeTempImage(name, contentType, body) {
|
|
15456
|
-
const dir = await mkdtemp(
|
|
15457
|
-
const filePath =
|
|
15525
|
+
const dir = await mkdtemp(join39(tmpdir2(), "assist-pr-img-"));
|
|
15526
|
+
const filePath = join39(
|
|
15458
15527
|
dir,
|
|
15459
15528
|
`${safeBaseName(name)}.${pickExtension(name, contentType)}`
|
|
15460
15529
|
);
|
|
@@ -15505,17 +15574,17 @@ import { readFile as readFile3, stat as stat3, writeFile as writeFile3 } from "f
|
|
|
15505
15574
|
|
|
15506
15575
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
15507
15576
|
import { execFile as execFile10 } from "child_process";
|
|
15508
|
-
import { existsSync as
|
|
15509
|
-
import { dirname as
|
|
15577
|
+
import { existsSync as existsSync39 } from "fs";
|
|
15578
|
+
import { dirname as dirname24, join as join40 } from "path";
|
|
15510
15579
|
import { promisify as promisify10 } from "util";
|
|
15511
15580
|
var execFileAsync9 = promisify10(execFile10);
|
|
15512
15581
|
var TIMEOUT_MS = 15e3;
|
|
15513
15582
|
function findOxfmtScript(root2) {
|
|
15514
15583
|
let dir = root2;
|
|
15515
15584
|
for (; ; ) {
|
|
15516
|
-
const candidate =
|
|
15517
|
-
if (
|
|
15518
|
-
const parent =
|
|
15585
|
+
const candidate = join40(dir, "node_modules", "oxfmt", "bin", "oxfmt");
|
|
15586
|
+
if (existsSync39(candidate)) return candidate;
|
|
15587
|
+
const parent = dirname24(dir);
|
|
15519
15588
|
if (parent === dir) return void 0;
|
|
15520
15589
|
dir = parent;
|
|
15521
15590
|
}
|
|
@@ -15642,6 +15711,7 @@ var routes2 = {
|
|
|
15642
15711
|
"POST /api/pr-preview/upload-image": uploadPrImage,
|
|
15643
15712
|
"GET /api/pr-preview/image": previewImage,
|
|
15644
15713
|
"POST /api/restart": restartWeb,
|
|
15714
|
+
"POST /api/self-update": selfUpdate,
|
|
15645
15715
|
"GET /api/github-url": githubUrl,
|
|
15646
15716
|
"GET /api/git-status": gitStatus,
|
|
15647
15717
|
"GET /api/diff": diff2,
|
|
@@ -16869,7 +16939,7 @@ function findTruncatedReadDenyRaw(rawCommand) {
|
|
|
16869
16939
|
}
|
|
16870
16940
|
|
|
16871
16941
|
// src/shared/isApprovedRead.ts
|
|
16872
|
-
import { resolve as
|
|
16942
|
+
import { resolve as resolve14, sep } from "path";
|
|
16873
16943
|
|
|
16874
16944
|
// src/shared/appliesFixStructure.ts
|
|
16875
16945
|
var APPLY_RE = /^assist\s+github\s+issue\s+fix-structure\b.*\s--apply\b/;
|
|
@@ -16922,29 +16992,29 @@ function extractGraphqlQuery(args) {
|
|
|
16922
16992
|
}
|
|
16923
16993
|
|
|
16924
16994
|
// src/shared/loadCliReads.ts
|
|
16925
|
-
import { existsSync as
|
|
16926
|
-
import { dirname as
|
|
16995
|
+
import { existsSync as existsSync40, readFileSync as readFileSync25, writeFileSync as writeFileSync22 } from "fs";
|
|
16996
|
+
import { dirname as dirname25, resolve as resolve13 } from "path";
|
|
16927
16997
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
16928
16998
|
var __filename3 = fileURLToPath5(import.meta.url);
|
|
16929
|
-
var __dirname4 =
|
|
16999
|
+
var __dirname4 = dirname25(__filename3);
|
|
16930
17000
|
function packageRoot() {
|
|
16931
17001
|
return __dirname4;
|
|
16932
17002
|
}
|
|
16933
17003
|
function readLines(path103) {
|
|
16934
|
-
if (!
|
|
17004
|
+
if (!existsSync40(path103)) return [];
|
|
16935
17005
|
return readFileSync25(path103, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
16936
17006
|
}
|
|
16937
17007
|
var cachedReads;
|
|
16938
17008
|
var cachedWrites;
|
|
16939
17009
|
function getCliReadsLines() {
|
|
16940
17010
|
if (!cachedReads) {
|
|
16941
|
-
cachedReads = readLines(
|
|
17011
|
+
cachedReads = readLines(resolve13(packageRoot(), "allowed.cli-reads"));
|
|
16942
17012
|
}
|
|
16943
17013
|
return cachedReads;
|
|
16944
17014
|
}
|
|
16945
17015
|
function getCliWritesLines() {
|
|
16946
17016
|
if (!cachedWrites) {
|
|
16947
|
-
cachedWrites = readLines(
|
|
17017
|
+
cachedWrites = readLines(resolve13(packageRoot(), "allowed.cli-writes"));
|
|
16948
17018
|
}
|
|
16949
17019
|
return cachedWrites;
|
|
16950
17020
|
}
|
|
@@ -16953,7 +17023,7 @@ function loadCliReads() {
|
|
|
16953
17023
|
}
|
|
16954
17024
|
function saveCliReads(commands) {
|
|
16955
17025
|
writeFileSync22(
|
|
16956
|
-
|
|
17026
|
+
resolve13(packageRoot(), "allowed.cli-reads"),
|
|
16957
17027
|
`${commands.join("\n")}
|
|
16958
17028
|
`
|
|
16959
17029
|
);
|
|
@@ -16978,14 +17048,14 @@ function findCliWrite(command) {
|
|
|
16978
17048
|
}
|
|
16979
17049
|
|
|
16980
17050
|
// src/shared/readSettingsPerms.ts
|
|
16981
|
-
import { existsSync as
|
|
17051
|
+
import { existsSync as existsSync41, readFileSync as readFileSync26 } from "fs";
|
|
16982
17052
|
import { homedir as homedir15 } from "os";
|
|
16983
|
-
import { join as
|
|
17053
|
+
import { join as join41 } from "path";
|
|
16984
17054
|
function readSettingsPerms(key) {
|
|
16985
17055
|
const paths = [
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
17056
|
+
join41(homedir15(), ".claude", "settings.json"),
|
|
17057
|
+
join41(process.cwd(), ".claude", "settings.json"),
|
|
17058
|
+
join41(process.cwd(), ".claude", "settings.local.json")
|
|
16989
17059
|
];
|
|
16990
17060
|
const entries = [];
|
|
16991
17061
|
for (const p of paths) {
|
|
@@ -16994,7 +17064,7 @@ function readSettingsPerms(key) {
|
|
|
16994
17064
|
return entries;
|
|
16995
17065
|
}
|
|
16996
17066
|
function readPermissionArray(filePath, key) {
|
|
16997
|
-
if (!
|
|
17067
|
+
if (!existsSync41(filePath)) return [];
|
|
16998
17068
|
try {
|
|
16999
17069
|
const data = JSON.parse(readFileSync26(filePath, "utf8"));
|
|
17000
17070
|
const arr = data?.permissions?.[key];
|
|
@@ -17054,6 +17124,12 @@ function parsePerms(entries) {
|
|
|
17054
17124
|
return map;
|
|
17055
17125
|
}
|
|
17056
17126
|
|
|
17127
|
+
// src/shared/mutatesNodeLinks.ts
|
|
17128
|
+
var MUTATE_RE = /^assist\s+sessions\s+nodes\s+(link|unlink)\b/;
|
|
17129
|
+
function mutatesNodeLinks(command) {
|
|
17130
|
+
return MUTATE_RE.test(command);
|
|
17131
|
+
}
|
|
17132
|
+
|
|
17057
17133
|
// src/shared/revealsConfigSecret.ts
|
|
17058
17134
|
var REVEAL_RE = /^assist\s+config\s+get\b.*\s--reveal\b/;
|
|
17059
17135
|
function revealsConfigSecret(command) {
|
|
@@ -17071,6 +17147,7 @@ function isApprovedRead(command, toolName = "Bash") {
|
|
|
17071
17147
|
if (cdRead) return cdRead;
|
|
17072
17148
|
if (appliesFixStructure(command)) return void 0;
|
|
17073
17149
|
if (configuresReleases(command)) return void 0;
|
|
17150
|
+
if (mutatesNodeLinks(command)) return void 0;
|
|
17074
17151
|
const matchedRead = findCliRead(command);
|
|
17075
17152
|
if (matchedRead) return `Read-only CLI command: ${matchedRead}`;
|
|
17076
17153
|
const matchedWrite = findCliWrite(command);
|
|
@@ -17084,19 +17161,19 @@ function isCdToCwd(command) {
|
|
|
17084
17161
|
const parts = command.split(/\s+/);
|
|
17085
17162
|
if (parts[0] !== "cd" || parts.length > 2) return false;
|
|
17086
17163
|
if (parts.length === 1) return false;
|
|
17087
|
-
const resolved =
|
|
17088
|
-
return resolved ===
|
|
17164
|
+
const resolved = resolve14(normalizeMsysPath(parts[1]));
|
|
17165
|
+
return resolved === resolve14(process.cwd());
|
|
17089
17166
|
}
|
|
17090
17167
|
function isCdToReadAllowedDir(command) {
|
|
17091
17168
|
const parts = command.split(/\s+/);
|
|
17092
17169
|
if (parts[0] !== "cd" || parts.length !== 2) return void 0;
|
|
17093
|
-
const target =
|
|
17170
|
+
const target = resolve14(normalizeMsysPath(parts[1]));
|
|
17094
17171
|
for (const entry of readSettingsPerms("allow")) {
|
|
17095
17172
|
const m = entry.match(READ_RE);
|
|
17096
17173
|
if (!m) continue;
|
|
17097
17174
|
const base = globBaseDir(m[1]);
|
|
17098
17175
|
if (!base) continue;
|
|
17099
|
-
const resolved =
|
|
17176
|
+
const resolved = resolve14(normalizeMsysPath(base));
|
|
17100
17177
|
if (target === resolved || target.startsWith(resolved + sep)) {
|
|
17101
17178
|
return `cd to Read-allowed directory: ${entry}`;
|
|
17102
17179
|
}
|
|
@@ -17202,11 +17279,11 @@ function decideCommand(toolName, rawCommand) {
|
|
|
17202
17279
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
17203
17280
|
import { mkdirSync as mkdirSync12 } from "fs";
|
|
17204
17281
|
import { homedir as homedir16 } from "os";
|
|
17205
|
-
import { join as
|
|
17282
|
+
import { join as join42 } from "path";
|
|
17206
17283
|
import Database from "better-sqlite3";
|
|
17207
17284
|
var _db;
|
|
17208
17285
|
function getDbDir() {
|
|
17209
|
-
return
|
|
17286
|
+
return join42(homedir16(), ".assist");
|
|
17210
17287
|
}
|
|
17211
17288
|
function initSchema(db) {
|
|
17212
17289
|
db.exec(`
|
|
@@ -17225,7 +17302,7 @@ function openPromptsDb(dir) {
|
|
|
17225
17302
|
if (_db) return _db;
|
|
17226
17303
|
const dbDir = dir ?? getDbDir();
|
|
17227
17304
|
mkdirSync12(dbDir, { recursive: true });
|
|
17228
|
-
const db = new Database(
|
|
17305
|
+
const db = new Database(join42(dbDir, "assist.db"));
|
|
17229
17306
|
db.pragma("journal_mode = WAL");
|
|
17230
17307
|
initSchema(db);
|
|
17231
17308
|
_db = db;
|
|
@@ -17344,9 +17421,9 @@ ${reasons.join("\n")}`);
|
|
|
17344
17421
|
}
|
|
17345
17422
|
|
|
17346
17423
|
// src/commands/permitCliReads.ts
|
|
17347
|
-
import { existsSync as
|
|
17424
|
+
import { existsSync as existsSync42, mkdirSync as mkdirSync13, readFileSync as readFileSync27, writeFileSync as writeFileSync23 } from "fs";
|
|
17348
17425
|
import { homedir as homedir17 } from "os";
|
|
17349
|
-
import { join as
|
|
17426
|
+
import { join as join43 } from "path";
|
|
17350
17427
|
|
|
17351
17428
|
// src/commands/permitCliReads/assertCliExists.ts
|
|
17352
17429
|
function assertCliExists(cli) {
|
|
@@ -17457,7 +17534,7 @@ function showProgress(p, label2) {
|
|
|
17457
17534
|
const pct = Math.round(p.done / p.total * 100);
|
|
17458
17535
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
17459
17536
|
}
|
|
17460
|
-
async function
|
|
17537
|
+
async function resolveCommand2(cli, path103, description, depth, p) {
|
|
17461
17538
|
showProgress(p, path103.join(" "));
|
|
17462
17539
|
const subHelp = await runHelp([cli, ...path103]);
|
|
17463
17540
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
@@ -17474,7 +17551,7 @@ async function discoverAt(cli, parentPath, depth, p) {
|
|
|
17474
17551
|
const results = await mapAsync(
|
|
17475
17552
|
cmds,
|
|
17476
17553
|
CONCURRENCY,
|
|
17477
|
-
(cmd) =>
|
|
17554
|
+
(cmd) => resolveCommand2(cli, [...parentPath, cmd.name], cmd.description, depth, p)
|
|
17478
17555
|
);
|
|
17479
17556
|
return results.flat();
|
|
17480
17557
|
}
|
|
@@ -17483,7 +17560,7 @@ async function discoverAll(cli, prefixPath = []) {
|
|
|
17483
17560
|
const p = { done: 0, total: topLevel.length };
|
|
17484
17561
|
const results = await mapAsync(topLevel, CONCURRENCY, async (cmd) => {
|
|
17485
17562
|
showProgress(p, cmd.name);
|
|
17486
|
-
const resolved = await
|
|
17563
|
+
const resolved = await resolveCommand2(
|
|
17487
17564
|
cli,
|
|
17488
17565
|
[...prefixPath, cmd.name],
|
|
17489
17566
|
cmd.description,
|
|
@@ -17609,15 +17686,15 @@ function updateSettings(cli, commands) {
|
|
|
17609
17686
|
// src/commands/permitCliReads.ts
|
|
17610
17687
|
function logPath(cli) {
|
|
17611
17688
|
const safeName = cli.replace(/\s+/g, "-");
|
|
17612
|
-
return
|
|
17689
|
+
return join43(homedir17(), ".assist", `cli-discover-${safeName}.log`);
|
|
17613
17690
|
}
|
|
17614
17691
|
function readCache(cli) {
|
|
17615
17692
|
const path103 = logPath(cli);
|
|
17616
|
-
if (!
|
|
17693
|
+
if (!existsSync42(path103)) return void 0;
|
|
17617
17694
|
return readFileSync27(path103, "utf8");
|
|
17618
17695
|
}
|
|
17619
17696
|
function writeCache(cli, output) {
|
|
17620
|
-
const dir =
|
|
17697
|
+
const dir = join43(homedir17(), ".assist");
|
|
17621
17698
|
mkdirSync13(dir, { recursive: true });
|
|
17622
17699
|
writeFileSync23(logPath(cli), output);
|
|
17623
17700
|
}
|
|
@@ -17748,7 +17825,7 @@ function registerCliHook(program2) {
|
|
|
17748
17825
|
}
|
|
17749
17826
|
|
|
17750
17827
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
17751
|
-
import { existsSync as
|
|
17828
|
+
import { existsSync as existsSync44, readFileSync as readFileSync29, unlinkSync as unlinkSync8, writeFileSync as writeFileSync24 } from "fs";
|
|
17752
17829
|
import chalk119 from "chalk";
|
|
17753
17830
|
|
|
17754
17831
|
// src/shared/isHashCommentFile.ts
|
|
@@ -17782,17 +17859,17 @@ function isHashCommentFile(filePath) {
|
|
|
17782
17859
|
|
|
17783
17860
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
17784
17861
|
import { homedir as homedir18 } from "os";
|
|
17785
|
-
import { join as
|
|
17862
|
+
import { join as join44 } from "path";
|
|
17786
17863
|
function getRestrictedDir() {
|
|
17787
|
-
return
|
|
17864
|
+
return join44(homedir18(), ".assist", "restricted");
|
|
17788
17865
|
}
|
|
17789
17866
|
function getPinStatePath(pin2) {
|
|
17790
|
-
return
|
|
17867
|
+
return join44(getRestrictedDir(), `code-comment-${pin2}.json`);
|
|
17791
17868
|
}
|
|
17792
17869
|
|
|
17793
17870
|
// src/commands/codeComment/sweepRestrictedDir.ts
|
|
17794
17871
|
import { readdirSync as readdirSync5, statSync as statSync7, unlinkSync as unlinkSync7 } from "fs";
|
|
17795
|
-
import { join as
|
|
17872
|
+
import { join as join45 } from "path";
|
|
17796
17873
|
var STALE_AFTER_MS = 30 * 60 * 1e3;
|
|
17797
17874
|
function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
17798
17875
|
let entries;
|
|
@@ -17803,7 +17880,7 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
17803
17880
|
}
|
|
17804
17881
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
17805
17882
|
for (const entry of entries) {
|
|
17806
|
-
const path103 =
|
|
17883
|
+
const path103 = join45(dir, entry);
|
|
17807
17884
|
try {
|
|
17808
17885
|
if (statSync7(path103).mtimeMs < cutoff) unlinkSync7(path103);
|
|
17809
17886
|
} catch {
|
|
@@ -17813,10 +17890,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
17813
17890
|
}
|
|
17814
17891
|
|
|
17815
17892
|
// src/commands/codeComment/readPinState.ts
|
|
17816
|
-
import { existsSync as
|
|
17893
|
+
import { existsSync as existsSync43, readFileSync as readFileSync28 } from "fs";
|
|
17817
17894
|
function readPinState(pin2) {
|
|
17818
17895
|
const path103 = getPinStatePath(pin2);
|
|
17819
|
-
if (!
|
|
17896
|
+
if (!existsSync43(path103)) return void 0;
|
|
17820
17897
|
try {
|
|
17821
17898
|
const state = JSON.parse(readFileSync28(path103, "utf8"));
|
|
17822
17899
|
if (state.pin !== pin2) return void 0;
|
|
@@ -17835,7 +17912,7 @@ function codeCommentConfirm(pin2) {
|
|
|
17835
17912
|
process.exitCode = 1;
|
|
17836
17913
|
return;
|
|
17837
17914
|
}
|
|
17838
|
-
if (!
|
|
17915
|
+
if (!existsSync44(state.file)) {
|
|
17839
17916
|
console.error(chalk119.red(`Target file no longer exists: ${state.file}`));
|
|
17840
17917
|
process.exitCode = 1;
|
|
17841
17918
|
return;
|
|
@@ -17901,7 +17978,7 @@ import { randomInt } from "crypto";
|
|
|
17901
17978
|
import notifier from "node-notifier";
|
|
17902
17979
|
|
|
17903
17980
|
// src/commands/notify/showNotification/showWindowsNotificationFromWsl.ts
|
|
17904
|
-
import { spawn as
|
|
17981
|
+
import { spawn as spawn5 } from "child_process";
|
|
17905
17982
|
import fs16 from "fs";
|
|
17906
17983
|
import { createRequire as createRequire2 } from "module";
|
|
17907
17984
|
import path29 from "path";
|
|
@@ -17921,7 +17998,7 @@ function showWindowsNotificationFromWsl(options2) {
|
|
|
17921
17998
|
if (sound) {
|
|
17922
17999
|
args.push("-s", "ms-winsoundevent:Notification.Default");
|
|
17923
18000
|
}
|
|
17924
|
-
const child =
|
|
18001
|
+
const child = spawn5(snoreToastPath, args, {
|
|
17925
18002
|
detached: true,
|
|
17926
18003
|
stdio: "ignore"
|
|
17927
18004
|
});
|
|
@@ -19456,19 +19533,19 @@ import { cp } from "fs/promises";
|
|
|
19456
19533
|
import chalk137 from "chalk";
|
|
19457
19534
|
|
|
19458
19535
|
// src/commands/criteriaExtension/criteriaExtensionDir.ts
|
|
19459
|
-
import { existsSync as
|
|
19460
|
-
import { dirname as
|
|
19536
|
+
import { existsSync as existsSync45 } from "fs";
|
|
19537
|
+
import { dirname as dirname26, join as join46 } from "path";
|
|
19461
19538
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
19462
|
-
var moduleDir =
|
|
19539
|
+
var moduleDir = dirname26(fileURLToPath6(import.meta.url));
|
|
19463
19540
|
function criteriaExtensionDir() {
|
|
19464
|
-
const bundled =
|
|
19541
|
+
const bundled = join46(
|
|
19465
19542
|
moduleDir,
|
|
19466
19543
|
"commands",
|
|
19467
19544
|
"criteriaExtension",
|
|
19468
19545
|
"criteria-extension"
|
|
19469
19546
|
);
|
|
19470
|
-
if (
|
|
19471
|
-
return
|
|
19547
|
+
if (existsSync45(bundled)) return bundled;
|
|
19548
|
+
return join46(moduleDir, "..", "..", "..", "criteria-extension");
|
|
19472
19549
|
}
|
|
19473
19550
|
|
|
19474
19551
|
// src/commands/criteriaExtension/criteriaExtension.ts
|
|
@@ -19497,28 +19574,28 @@ async function criteriaExtension() {
|
|
|
19497
19574
|
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19498
19575
|
import { rm as rm3 } from "fs/promises";
|
|
19499
19576
|
import { homedir as homedir19, tmpdir as tmpdir4 } from "os";
|
|
19500
|
-
import { join as
|
|
19577
|
+
import { join as join51 } from "path";
|
|
19501
19578
|
import chalk139 from "chalk";
|
|
19502
19579
|
|
|
19503
19580
|
// src/commands/criteriaExtension/copySignedXpi.ts
|
|
19504
19581
|
import { copyFile } from "fs/promises";
|
|
19505
|
-
import { join as
|
|
19582
|
+
import { join as join47 } from "path";
|
|
19506
19583
|
var SIGNED_XPI_NAME = "criteria-extension.xpi";
|
|
19507
19584
|
async function copySignedXpi(xpi, dir) {
|
|
19508
|
-
const fixed2 =
|
|
19585
|
+
const fixed2 = join47(dir, SIGNED_XPI_NAME);
|
|
19509
19586
|
if (fixed2 === xpi) return fixed2;
|
|
19510
19587
|
await copyFile(xpi, fixed2);
|
|
19511
19588
|
return fixed2;
|
|
19512
19589
|
}
|
|
19513
19590
|
|
|
19514
19591
|
// src/commands/criteriaExtension/findSignedXpi.ts
|
|
19515
|
-
import { existsSync as
|
|
19592
|
+
import { existsSync as existsSync46 } from "fs";
|
|
19516
19593
|
import { readdir } from "fs/promises";
|
|
19517
|
-
import { join as
|
|
19594
|
+
import { join as join48 } from "path";
|
|
19518
19595
|
async function findSignedXpi(dir) {
|
|
19519
|
-
if (!
|
|
19596
|
+
if (!existsSync46(dir)) return null;
|
|
19520
19597
|
const name = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
19521
|
-
return name ?
|
|
19598
|
+
return name ? join48(dir, name) : null;
|
|
19522
19599
|
}
|
|
19523
19600
|
|
|
19524
19601
|
// src/commands/criteriaExtension/signedAddonInstallPath.ts
|
|
@@ -19540,11 +19617,11 @@ async function signedAddonInstallPath(xpi) {
|
|
|
19540
19617
|
}
|
|
19541
19618
|
|
|
19542
19619
|
// src/commands/criteriaExtension/signPreflightProblem.ts
|
|
19543
|
-
import { existsSync as
|
|
19544
|
-
import { join as
|
|
19620
|
+
import { existsSync as existsSync47 } from "fs";
|
|
19621
|
+
import { join as join49 } from "path";
|
|
19545
19622
|
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
19546
19623
|
function signPreflightProblem(source) {
|
|
19547
|
-
if (!
|
|
19624
|
+
if (!existsSync47(join49(source, "content.js")))
|
|
19548
19625
|
return {
|
|
19549
19626
|
message: `no content.js in ${source}`,
|
|
19550
19627
|
hint: "run npm run build to bundle the content script"
|
|
@@ -19559,7 +19636,7 @@ function signPreflightProblem(source) {
|
|
|
19559
19636
|
|
|
19560
19637
|
// src/commands/criteriaExtension/stageCriteriaExtension.ts
|
|
19561
19638
|
import { cp as cp3, mkdir as mkdir4, readFile as readFile4, rm as rm2, writeFile as writeFile4 } from "fs/promises";
|
|
19562
|
-
import { join as
|
|
19639
|
+
import { join as join50 } from "path";
|
|
19563
19640
|
|
|
19564
19641
|
// src/commands/criteriaExtension/stampManifestVersion.ts
|
|
19565
19642
|
function stampManifestVersion(manifest, version2) {
|
|
@@ -19573,7 +19650,7 @@ async function stageCriteriaExtension(source, staging, version2) {
|
|
|
19573
19650
|
await rm2(staging, { recursive: true, force: true });
|
|
19574
19651
|
await mkdir4(staging, { recursive: true });
|
|
19575
19652
|
await cp3(source, staging, { recursive: true });
|
|
19576
|
-
const manifest =
|
|
19653
|
+
const manifest = join50(staging, "manifest.json");
|
|
19577
19654
|
const stamped = stampManifestVersion(
|
|
19578
19655
|
await readFile4(manifest, "utf8"),
|
|
19579
19656
|
version2
|
|
@@ -19582,8 +19659,8 @@ async function stageCriteriaExtension(source, staging, version2) {
|
|
|
19582
19659
|
}
|
|
19583
19660
|
|
|
19584
19661
|
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19585
|
-
var ARTIFACTS_DIR =
|
|
19586
|
-
var STAGING_DIR =
|
|
19662
|
+
var ARTIFACTS_DIR = join51(homedir19(), ".assist", "criteria-extension");
|
|
19663
|
+
var STAGING_DIR = join51(tmpdir4(), "assist-criteria-extension");
|
|
19587
19664
|
async function signCriteriaExtension() {
|
|
19588
19665
|
const source = criteriaExtensionDir();
|
|
19589
19666
|
const problem = signPreflightProblem(source);
|
|
@@ -19706,19 +19783,19 @@ import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs"
|
|
|
19706
19783
|
import chalk141 from "chalk";
|
|
19707
19784
|
|
|
19708
19785
|
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
19709
|
-
import { join as
|
|
19786
|
+
import { join as join52 } from "path";
|
|
19710
19787
|
function getMigrationPinPath(pin2) {
|
|
19711
|
-
return
|
|
19788
|
+
return join52(getRestrictedDir(), `db-migration-pin-${pin2}.json`);
|
|
19712
19789
|
}
|
|
19713
19790
|
function getMigrationApprovalPath(migrationId) {
|
|
19714
|
-
return
|
|
19791
|
+
return join52(getRestrictedDir(), `db-migration-approval-${migrationId}.json`);
|
|
19715
19792
|
}
|
|
19716
19793
|
|
|
19717
19794
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
19718
|
-
import { existsSync as
|
|
19795
|
+
import { existsSync as existsSync48, readFileSync as readFileSync30 } from "fs";
|
|
19719
19796
|
function readMigrationPinState(pin2) {
|
|
19720
19797
|
const path103 = getMigrationPinPath(pin2);
|
|
19721
|
-
if (!
|
|
19798
|
+
if (!existsSync48(path103)) return void 0;
|
|
19722
19799
|
try {
|
|
19723
19800
|
const state = JSON.parse(readFileSync30(path103, "utf8"));
|
|
19724
19801
|
if (state.pin !== pin2) return void 0;
|
|
@@ -19807,7 +19884,7 @@ function registerDbMigration(parent) {
|
|
|
19807
19884
|
}
|
|
19808
19885
|
|
|
19809
19886
|
// src/commands/deploy/redirect.ts
|
|
19810
|
-
import { existsSync as
|
|
19887
|
+
import { existsSync as existsSync49, readFileSync as readFileSync31, writeFileSync as writeFileSync28 } from "fs";
|
|
19811
19888
|
import chalk143 from "chalk";
|
|
19812
19889
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
19813
19890
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -19816,7 +19893,7 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
19816
19893
|
</script>`;
|
|
19817
19894
|
function redirect() {
|
|
19818
19895
|
const indexPath = "index.html";
|
|
19819
|
-
if (!
|
|
19896
|
+
if (!existsSync49(indexPath)) {
|
|
19820
19897
|
console.log(chalk143.yellow("No index.html found"));
|
|
19821
19898
|
return;
|
|
19822
19899
|
}
|
|
@@ -19844,15 +19921,15 @@ function registerDeploy(program2) {
|
|
|
19844
19921
|
}
|
|
19845
19922
|
|
|
19846
19923
|
// src/commands/devlog/list.ts
|
|
19847
|
-
import { execFileSync as
|
|
19924
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
19848
19925
|
import { basename as basename14 } from "path";
|
|
19849
19926
|
|
|
19850
19927
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
19851
19928
|
import { homedir as homedir20 } from "os";
|
|
19852
|
-
import { join as
|
|
19853
|
-
var BLOG_REPO_ROOT =
|
|
19929
|
+
import { join as join53 } from "path";
|
|
19930
|
+
var BLOG_REPO_ROOT = join53(homedir20(), "git/blog");
|
|
19854
19931
|
function loadBlogSkipDays(repoName) {
|
|
19855
|
-
const config = loadRawYaml(
|
|
19932
|
+
const config = loadRawYaml(join53(BLOG_REPO_ROOT, "assist.yml"));
|
|
19856
19933
|
const devlog = config.devlog;
|
|
19857
19934
|
const skip2 = devlog?.skip;
|
|
19858
19935
|
return new Set(skip2?.[repoName]);
|
|
@@ -19863,15 +19940,15 @@ import { execSync as execSync31 } from "child_process";
|
|
|
19863
19940
|
import chalk144 from "chalk";
|
|
19864
19941
|
|
|
19865
19942
|
// src/shared/getRepoName.ts
|
|
19866
|
-
import { existsSync as
|
|
19867
|
-
import { basename as basename13, join as
|
|
19943
|
+
import { existsSync as existsSync50, readFileSync as readFileSync32 } from "fs";
|
|
19944
|
+
import { basename as basename13, join as join54 } from "path";
|
|
19868
19945
|
function getRepoName() {
|
|
19869
19946
|
const config = loadConfig();
|
|
19870
19947
|
if (config.devlog?.name) {
|
|
19871
19948
|
return config.devlog.name;
|
|
19872
19949
|
}
|
|
19873
|
-
const packageJsonPath =
|
|
19874
|
-
if (
|
|
19950
|
+
const packageJsonPath = join54(process.cwd(), "package.json");
|
|
19951
|
+
if (existsSync50(packageJsonPath)) {
|
|
19875
19952
|
try {
|
|
19876
19953
|
const content = readFileSync32(packageJsonPath, "utf8");
|
|
19877
19954
|
const pkg = JSON.parse(content);
|
|
@@ -19886,8 +19963,8 @@ function getRepoName() {
|
|
|
19886
19963
|
|
|
19887
19964
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
19888
19965
|
import { readdirSync as readdirSync6, readFileSync as readFileSync33 } from "fs";
|
|
19889
|
-
import { join as
|
|
19890
|
-
var DEVLOG_DIR =
|
|
19966
|
+
import { join as join55 } from "path";
|
|
19967
|
+
var DEVLOG_DIR = join55(BLOG_REPO_ROOT, "src/content/devlog");
|
|
19891
19968
|
function extractFrontmatter(content) {
|
|
19892
19969
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
19893
19970
|
return fm?.[1] ?? null;
|
|
@@ -19915,7 +19992,7 @@ function readDevlogFiles(callback) {
|
|
|
19915
19992
|
try {
|
|
19916
19993
|
const files = readdirSync6(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
19917
19994
|
for (const file of files) {
|
|
19918
|
-
const content = readFileSync33(
|
|
19995
|
+
const content = readFileSync33(join55(DEVLOG_DIR, file), "utf8");
|
|
19919
19996
|
const parsed = parseFrontmatter(content, file);
|
|
19920
19997
|
if (parsed) callback(parsed);
|
|
19921
19998
|
}
|
|
@@ -20024,7 +20101,7 @@ function list2(options2) {
|
|
|
20024
20101
|
if (options2.reverse) args.push("--reverse");
|
|
20025
20102
|
else args.push("-n", "500");
|
|
20026
20103
|
args.push("--pretty=format:%ad|%h|%s", "--date=short");
|
|
20027
|
-
const output =
|
|
20104
|
+
const output = execFileSync4("git", args, { encoding: "utf8" });
|
|
20028
20105
|
const commitsByDate = parseGitLogCommits(output, ignore3);
|
|
20029
20106
|
let dateCount = 0;
|
|
20030
20107
|
let isFirst = true;
|
|
@@ -20047,7 +20124,7 @@ function list2(options2) {
|
|
|
20047
20124
|
}
|
|
20048
20125
|
|
|
20049
20126
|
// src/commands/devlog/getLastVersionInfo.ts
|
|
20050
|
-
import { execFileSync as
|
|
20127
|
+
import { execFileSync as execFileSync5, execSync as execSync32 } from "child_process";
|
|
20051
20128
|
import semver from "semver";
|
|
20052
20129
|
function getVersionAtCommit(hash) {
|
|
20053
20130
|
try {
|
|
@@ -20066,7 +20143,7 @@ function stripToMinor(version2) {
|
|
|
20066
20143
|
}
|
|
20067
20144
|
function getLastVersionInfoFromGit() {
|
|
20068
20145
|
try {
|
|
20069
|
-
const output =
|
|
20146
|
+
const output = execFileSync5(
|
|
20070
20147
|
"git",
|
|
20071
20148
|
["log", "-1", "--pretty=format:%ad|%h", "--date=short"],
|
|
20072
20149
|
{
|
|
@@ -20111,7 +20188,7 @@ function bumpVersion(version2, type) {
|
|
|
20111
20188
|
}
|
|
20112
20189
|
|
|
20113
20190
|
// src/commands/devlog/next/displayNextEntry.ts
|
|
20114
|
-
import { execFileSync as
|
|
20191
|
+
import { execFileSync as execFileSync6 } from "child_process";
|
|
20115
20192
|
import chalk147 from "chalk";
|
|
20116
20193
|
|
|
20117
20194
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
@@ -20145,7 +20222,7 @@ function findTargetDate(commitsByDate, skipDays) {
|
|
|
20145
20222
|
return Array.from(commitsByDate.keys()).filter((d) => !skipDays.has(d)).sort()[0];
|
|
20146
20223
|
}
|
|
20147
20224
|
function fetchCommitsByDate(ignore3, lastDate) {
|
|
20148
|
-
const output =
|
|
20225
|
+
const output = execFileSync6(
|
|
20149
20226
|
"git",
|
|
20150
20227
|
["log", "--pretty=format:%ad|%h|%s", "--date=short", "-n", "500"],
|
|
20151
20228
|
{ encoding: "utf8" }
|
|
@@ -20303,11 +20380,11 @@ function repos(options2) {
|
|
|
20303
20380
|
|
|
20304
20381
|
// src/commands/devlog/skip.ts
|
|
20305
20382
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
20306
|
-
import { join as
|
|
20383
|
+
import { join as join56 } from "path";
|
|
20307
20384
|
import chalk149 from "chalk";
|
|
20308
20385
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
20309
20386
|
function getBlogConfigPath() {
|
|
20310
|
-
return
|
|
20387
|
+
return join56(BLOG_REPO_ROOT, "assist.yml");
|
|
20311
20388
|
}
|
|
20312
20389
|
function skip(date) {
|
|
20313
20390
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
@@ -20369,7 +20446,7 @@ function registerDevlog(program2) {
|
|
|
20369
20446
|
|
|
20370
20447
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
20371
20448
|
import { closeSync as closeSync3, openSync as openSync4, readdirSync as readdirSync7 } from "fs";
|
|
20372
|
-
import { join as
|
|
20449
|
+
import { join as join57 } from "path";
|
|
20373
20450
|
import chalk151 from "chalk";
|
|
20374
20451
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
20375
20452
|
function isLockedDll(debugDir) {
|
|
@@ -20381,7 +20458,7 @@ function isLockedDll(debugDir) {
|
|
|
20381
20458
|
}
|
|
20382
20459
|
for (const file of files) {
|
|
20383
20460
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
20384
|
-
const dllPath =
|
|
20461
|
+
const dllPath = join57(debugDir, file);
|
|
20385
20462
|
try {
|
|
20386
20463
|
const fd = openSync4(dllPath, "r+");
|
|
20387
20464
|
closeSync3(fd);
|
|
@@ -20399,13 +20476,13 @@ function findFirstLockedDll(dir) {
|
|
|
20399
20476
|
return null;
|
|
20400
20477
|
}
|
|
20401
20478
|
if (entries.includes("bin")) {
|
|
20402
|
-
const locked = isLockedDll(
|
|
20479
|
+
const locked = isLockedDll(join57(dir, "bin", "Debug"));
|
|
20403
20480
|
if (locked) return locked;
|
|
20404
20481
|
}
|
|
20405
20482
|
for (const entry of entries) {
|
|
20406
20483
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
20407
20484
|
continue;
|
|
20408
|
-
const found = findFirstLockedDll(
|
|
20485
|
+
const found = findFirstLockedDll(join57(dir, entry));
|
|
20409
20486
|
if (found) return found;
|
|
20410
20487
|
}
|
|
20411
20488
|
return null;
|
|
@@ -20573,12 +20650,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
20573
20650
|
}
|
|
20574
20651
|
|
|
20575
20652
|
// src/commands/dotnet/resolveCsproj.ts
|
|
20576
|
-
import { existsSync as
|
|
20653
|
+
import { existsSync as existsSync51 } from "fs";
|
|
20577
20654
|
import path36 from "path";
|
|
20578
20655
|
import chalk153 from "chalk";
|
|
20579
20656
|
function resolveCsproj(csprojPath) {
|
|
20580
20657
|
const resolved = path36.resolve(csprojPath);
|
|
20581
|
-
if (!
|
|
20658
|
+
if (!existsSync51(resolved)) {
|
|
20582
20659
|
console.error(chalk153.red(`File not found: ${resolved}`));
|
|
20583
20660
|
process.exit(1);
|
|
20584
20661
|
}
|
|
@@ -20746,17 +20823,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
20746
20823
|
}
|
|
20747
20824
|
|
|
20748
20825
|
// src/commands/dotnet/resolveSolution.ts
|
|
20749
|
-
import { existsSync as
|
|
20826
|
+
import { existsSync as existsSync52 } from "fs";
|
|
20750
20827
|
import path37 from "path";
|
|
20751
20828
|
import chalk157 from "chalk";
|
|
20752
20829
|
|
|
20753
20830
|
// src/commands/dotnet/findSolution.ts
|
|
20754
20831
|
import { readdirSync as readdirSync9 } from "fs";
|
|
20755
|
-
import { dirname as
|
|
20832
|
+
import { dirname as dirname27, join as join58 } from "path";
|
|
20756
20833
|
import chalk156 from "chalk";
|
|
20757
20834
|
function findSlnInDir(dir) {
|
|
20758
20835
|
try {
|
|
20759
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
20836
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".sln")).map((f) => join58(dir, f));
|
|
20760
20837
|
} catch {
|
|
20761
20838
|
return [];
|
|
20762
20839
|
}
|
|
@@ -20777,7 +20854,7 @@ function findSolution() {
|
|
|
20777
20854
|
process.exit(1);
|
|
20778
20855
|
}
|
|
20779
20856
|
if (current === ceiling) break;
|
|
20780
|
-
current =
|
|
20857
|
+
current = dirname27(current);
|
|
20781
20858
|
}
|
|
20782
20859
|
console.error(chalk156.red("No .sln file found between cwd and repo root"));
|
|
20783
20860
|
process.exit(1);
|
|
@@ -20787,7 +20864,7 @@ function findSolution() {
|
|
|
20787
20864
|
function resolveSolution(sln) {
|
|
20788
20865
|
if (sln) {
|
|
20789
20866
|
const resolved = path37.resolve(sln);
|
|
20790
|
-
if (!
|
|
20867
|
+
if (!existsSync52(resolved)) {
|
|
20791
20868
|
console.error(chalk157.red(`Solution file not found: ${resolved}`));
|
|
20792
20869
|
process.exit(1);
|
|
20793
20870
|
}
|
|
@@ -20827,7 +20904,7 @@ function parseInspectReport(json) {
|
|
|
20827
20904
|
|
|
20828
20905
|
// src/commands/dotnet/runInspectCode.ts
|
|
20829
20906
|
import { execSync as execSync35 } from "child_process";
|
|
20830
|
-
import { existsSync as
|
|
20907
|
+
import { existsSync as existsSync53, readFileSync as readFileSync36, unlinkSync as unlinkSync10 } from "fs";
|
|
20831
20908
|
import { tmpdir as tmpdir5 } from "os";
|
|
20832
20909
|
import path38 from "path";
|
|
20833
20910
|
import chalk158 from "chalk";
|
|
@@ -20858,7 +20935,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
20858
20935
|
console.error(chalk158.red("jb inspectcode failed"));
|
|
20859
20936
|
process.exit(1);
|
|
20860
20937
|
}
|
|
20861
|
-
if (!
|
|
20938
|
+
if (!existsSync53(reportPath)) {
|
|
20862
20939
|
console.error(chalk158.red("Report file not generated"));
|
|
20863
20940
|
process.exit(1);
|
|
20864
20941
|
}
|
|
@@ -21526,11 +21603,11 @@ function decideCommentGuard(input, existingContent) {
|
|
|
21526
21603
|
}
|
|
21527
21604
|
|
|
21528
21605
|
// src/commands/dbMigration/consumeMigrationApproval.ts
|
|
21529
|
-
import { existsSync as
|
|
21606
|
+
import { existsSync as existsSync54, unlinkSync as unlinkSync11 } from "fs";
|
|
21530
21607
|
function consumeMigrationApproval(migrationId) {
|
|
21531
21608
|
sweepRestrictedDir();
|
|
21532
21609
|
const path103 = getMigrationApprovalPath(migrationId);
|
|
21533
|
-
if (!
|
|
21610
|
+
if (!existsSync54(path103)) return false;
|
|
21534
21611
|
try {
|
|
21535
21612
|
unlinkSync11(path103);
|
|
21536
21613
|
return true;
|
|
@@ -21650,7 +21727,7 @@ function aggregateCommitters(authorLists) {
|
|
|
21650
21727
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
21651
21728
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
21652
21729
|
import { tmpdir as tmpdir6 } from "os";
|
|
21653
|
-
import { join as
|
|
21730
|
+
import { join as join59 } from "path";
|
|
21654
21731
|
|
|
21655
21732
|
// src/shared/throwOnGraphqlErrors.ts
|
|
21656
21733
|
function throwOnGraphqlErrors(stdout) {
|
|
@@ -21679,7 +21756,7 @@ function buildArgs2(queryFile, vars) {
|
|
|
21679
21756
|
return args;
|
|
21680
21757
|
}
|
|
21681
21758
|
function runGhGraphql(mutation, vars) {
|
|
21682
|
-
const queryFile =
|
|
21759
|
+
const queryFile = join59(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
21683
21760
|
writeFileSync30(queryFile, mutation);
|
|
21684
21761
|
try {
|
|
21685
21762
|
const result = spawnSync4("gh", buildArgs2(queryFile, vars), {
|
|
@@ -22417,7 +22494,7 @@ async function readBodyArgument(value) {
|
|
|
22417
22494
|
}
|
|
22418
22495
|
|
|
22419
22496
|
// src/commands/github/issue/commentIssue.ts
|
|
22420
|
-
import { execFileSync as
|
|
22497
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
22421
22498
|
|
|
22422
22499
|
// src/shared/validateProposedContent.ts
|
|
22423
22500
|
function validateProposedContent(labels, title, body) {
|
|
@@ -22478,7 +22555,7 @@ async function commentIssue(numberArg, options2) {
|
|
|
22478
22555
|
const args = ["issue", "comment", String(number), "--body", body];
|
|
22479
22556
|
if (options2.repo) args.push("--repo", options2.repo);
|
|
22480
22557
|
try {
|
|
22481
|
-
|
|
22558
|
+
execFileSync7("gh", args, { stdio: "inherit" });
|
|
22482
22559
|
} catch {
|
|
22483
22560
|
process.exit(1);
|
|
22484
22561
|
}
|
|
@@ -22949,13 +23026,13 @@ async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
|
22949
23026
|
}
|
|
22950
23027
|
|
|
22951
23028
|
// src/commands/github/issue/runGhIssueCreate.ts
|
|
22952
|
-
import { execFileSync as
|
|
23029
|
+
import { execFileSync as execFileSync8 } from "child_process";
|
|
22953
23030
|
function runGhIssueCreate(title, body, repo, labels) {
|
|
22954
23031
|
const args = ["issue", "create", "--title", title, "--body", body];
|
|
22955
23032
|
if (repo) args.push("--repo", repo);
|
|
22956
23033
|
for (const label2 of labels ?? []) args.push("--label", label2);
|
|
22957
23034
|
try {
|
|
22958
|
-
return
|
|
23035
|
+
return execFileSync8("gh", args, {
|
|
22959
23036
|
encoding: "utf8",
|
|
22960
23037
|
stdio: ["ignore", "pipe", "inherit"]
|
|
22961
23038
|
});
|
|
@@ -23035,7 +23112,7 @@ function inWebSession() {
|
|
|
23035
23112
|
}
|
|
23036
23113
|
|
|
23037
23114
|
// src/commands/github/issue/fetchIssue.ts
|
|
23038
|
-
import { execFileSync as
|
|
23115
|
+
import { execFileSync as execFileSync9 } from "child_process";
|
|
23039
23116
|
function fetchIssue2(number, repo) {
|
|
23040
23117
|
const args = [
|
|
23041
23118
|
"issue",
|
|
@@ -23047,7 +23124,7 @@ function fetchIssue2(number, repo) {
|
|
|
23047
23124
|
if (repo) args.push("--repo", repo);
|
|
23048
23125
|
let raw;
|
|
23049
23126
|
try {
|
|
23050
|
-
raw =
|
|
23127
|
+
raw = execFileSync9("gh", args, { encoding: "utf8" });
|
|
23051
23128
|
} catch {
|
|
23052
23129
|
console.error(`Could not fetch issue #${number} with gh issue view`);
|
|
23053
23130
|
process.exit(1);
|
|
@@ -23061,24 +23138,24 @@ function fetchIssue2(number, repo) {
|
|
|
23061
23138
|
}
|
|
23062
23139
|
|
|
23063
23140
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
23064
|
-
import { existsSync as
|
|
23141
|
+
import { existsSync as existsSync55, readFileSync as readFileSync37 } from "fs";
|
|
23065
23142
|
|
|
23066
23143
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
23067
|
-
import { join as
|
|
23144
|
+
import { join as join60 } from "path";
|
|
23068
23145
|
function issueWorkingFile(slug2, number) {
|
|
23069
23146
|
const [owner = "unknown", repo = "unknown"] = slug2.split("/");
|
|
23070
|
-
const dir =
|
|
23147
|
+
const dir = join60(getStoreDir(), "github-issues", owner, repo);
|
|
23071
23148
|
return {
|
|
23072
23149
|
dir,
|
|
23073
|
-
bodyPath:
|
|
23074
|
-
metaPath:
|
|
23150
|
+
bodyPath: join60(dir, `${number}.md`),
|
|
23151
|
+
metaPath: join60(dir, `${number}.json`)
|
|
23075
23152
|
};
|
|
23076
23153
|
}
|
|
23077
23154
|
|
|
23078
23155
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
23079
23156
|
function resumeIssueBody(slug2, number, updatedAt) {
|
|
23080
23157
|
const { bodyPath, metaPath } = issueWorkingFile(slug2, number);
|
|
23081
|
-
if (!
|
|
23158
|
+
if (!existsSync55(bodyPath) || !existsSync55(metaPath)) return void 0;
|
|
23082
23159
|
try {
|
|
23083
23160
|
const meta = JSON.parse(readFileSync37(metaPath, "utf8"));
|
|
23084
23161
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
@@ -23138,12 +23215,12 @@ function prepareIssueEdit(number, repo, fresh) {
|
|
|
23138
23215
|
}
|
|
23139
23216
|
|
|
23140
23217
|
// src/commands/github/issue/pushIssueBody.ts
|
|
23141
|
-
import { execFileSync as
|
|
23218
|
+
import { execFileSync as execFileSync10 } from "child_process";
|
|
23142
23219
|
function pushIssueBody(number, repo, bodyPath) {
|
|
23143
23220
|
const args = ["issue", "edit", String(number), "--body-file", bodyPath];
|
|
23144
23221
|
if (repo) args.push("--repo", repo);
|
|
23145
23222
|
try {
|
|
23146
|
-
|
|
23223
|
+
execFileSync10("gh", args, { stdio: "inherit" });
|
|
23147
23224
|
} catch {
|
|
23148
23225
|
process.exit(1);
|
|
23149
23226
|
}
|
|
@@ -23203,12 +23280,12 @@ function setIssueParent(number, repo, parentArg) {
|
|
|
23203
23280
|
}
|
|
23204
23281
|
|
|
23205
23282
|
// src/commands/github/issue/viewIssue.ts
|
|
23206
|
-
import { execFileSync as
|
|
23283
|
+
import { execFileSync as execFileSync11 } from "child_process";
|
|
23207
23284
|
function viewIssue(number, repo) {
|
|
23208
23285
|
const args = ["issue", "view", String(number)];
|
|
23209
23286
|
if (repo) args.push("--repo", repo);
|
|
23210
23287
|
try {
|
|
23211
|
-
|
|
23288
|
+
execFileSync11("gh", args, { stdio: "inherit" });
|
|
23212
23289
|
} catch {
|
|
23213
23290
|
process.exit(1);
|
|
23214
23291
|
}
|
|
@@ -23264,7 +23341,7 @@ function registerEditIssue(issueCommand) {
|
|
|
23264
23341
|
}
|
|
23265
23342
|
|
|
23266
23343
|
// src/commands/github/issue/editIssueComment.ts
|
|
23267
|
-
import { execFileSync as
|
|
23344
|
+
import { execFileSync as execFileSync12 } from "child_process";
|
|
23268
23345
|
var USAGE4 = "Usage: assist github issue edit-comment <comment-id> --body <body> [-R <owner>/<repo>]";
|
|
23269
23346
|
async function editIssueComment(commentIdArg, options2) {
|
|
23270
23347
|
const commentId = Number.parseInt(commentIdArg, 10);
|
|
@@ -23291,7 +23368,7 @@ async function editIssueComment(commentIdArg, options2) {
|
|
|
23291
23368
|
];
|
|
23292
23369
|
let raw;
|
|
23293
23370
|
try {
|
|
23294
|
-
raw =
|
|
23371
|
+
raw = execFileSync12("gh", args, {
|
|
23295
23372
|
input: JSON.stringify({ body }),
|
|
23296
23373
|
encoding: "utf8"
|
|
23297
23374
|
});
|
|
@@ -23330,7 +23407,7 @@ function registerEditIssueComment(issueCommand) {
|
|
|
23330
23407
|
}
|
|
23331
23408
|
|
|
23332
23409
|
// src/commands/github/issue/assignIssueToSelf.ts
|
|
23333
|
-
import { execFileSync as
|
|
23410
|
+
import { execFileSync as execFileSync13 } from "child_process";
|
|
23334
23411
|
function assignIssueToSelf(number, repo) {
|
|
23335
23412
|
const args = [
|
|
23336
23413
|
"issue",
|
|
@@ -23342,7 +23419,7 @@ function assignIssueToSelf(number, repo) {
|
|
|
23342
23419
|
"@me"
|
|
23343
23420
|
];
|
|
23344
23421
|
try {
|
|
23345
|
-
|
|
23422
|
+
execFileSync13("gh", args, { stdio: ["ignore", "ignore", "inherit"] });
|
|
23346
23423
|
} catch {
|
|
23347
23424
|
process.exit(1);
|
|
23348
23425
|
}
|
|
@@ -23506,24 +23583,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
23506
23583
|
|
|
23507
23584
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
23508
23585
|
import {
|
|
23509
|
-
existsSync as
|
|
23586
|
+
existsSync as existsSync56,
|
|
23510
23587
|
readdirSync as readdirSync10,
|
|
23511
23588
|
readFileSync as readFileSync38,
|
|
23512
23589
|
rmSync as rmSync3,
|
|
23513
23590
|
statSync as statSync9
|
|
23514
23591
|
} from "fs";
|
|
23515
|
-
import { basename as basename15, join as
|
|
23592
|
+
import { basename as basename15, join as join63 } from "path";
|
|
23516
23593
|
|
|
23517
23594
|
// src/commands/handover/getHandoverPath.ts
|
|
23518
|
-
import { join as
|
|
23595
|
+
import { join as join61 } from "path";
|
|
23519
23596
|
function getHandoverPath(cwd = process.cwd()) {
|
|
23520
|
-
return
|
|
23597
|
+
return join61(cwd, ".assist", "HANDOVER.md");
|
|
23521
23598
|
}
|
|
23522
23599
|
|
|
23523
23600
|
// src/commands/handover/getHandoversDir.ts
|
|
23524
|
-
import { join as
|
|
23601
|
+
import { join as join62 } from "path";
|
|
23525
23602
|
function getHandoversDir(cwd = process.cwd()) {
|
|
23526
|
-
return
|
|
23603
|
+
return join62(cwd, ".assist", "handovers");
|
|
23527
23604
|
}
|
|
23528
23605
|
|
|
23529
23606
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -23561,10 +23638,10 @@ function summariseHandoverContent(content) {
|
|
|
23561
23638
|
|
|
23562
23639
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
23563
23640
|
function collectMarkdown(dir) {
|
|
23564
|
-
if (!
|
|
23641
|
+
if (!existsSync56(dir)) return [];
|
|
23565
23642
|
const out = [];
|
|
23566
23643
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
23567
|
-
const full =
|
|
23644
|
+
const full = join63(dir, entry.name);
|
|
23568
23645
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
23569
23646
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
23570
23647
|
}
|
|
@@ -23588,7 +23665,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
23588
23665
|
migrated++;
|
|
23589
23666
|
}
|
|
23590
23667
|
const handoverPath = getHandoverPath(cwd);
|
|
23591
|
-
if (
|
|
23668
|
+
if (existsSync56(handoverPath)) {
|
|
23592
23669
|
await migrateFile(orm, origin, handoverPath, statSync9(handoverPath).mtime);
|
|
23593
23670
|
migrated++;
|
|
23594
23671
|
}
|
|
@@ -23907,7 +23984,7 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
23907
23984
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
23908
23985
|
|
|
23909
23986
|
// src/commands/review/checkoutPr.ts
|
|
23910
|
-
import { execFileSync as
|
|
23987
|
+
import { execFileSync as execFileSync15 } from "child_process";
|
|
23911
23988
|
import chalk168 from "chalk";
|
|
23912
23989
|
|
|
23913
23990
|
// src/commands/sessions/daemon/daemonLog.ts
|
|
@@ -23915,48 +23992,48 @@ var RING_CAPACITY = 1e3;
|
|
|
23915
23992
|
var ring = [];
|
|
23916
23993
|
var sink;
|
|
23917
23994
|
function daemonLog(message3) {
|
|
23918
|
-
emit3(`${(/* @__PURE__ */ new Date()).toISOString()} [${process.pid}] ${message3}
|
|
23995
|
+
emit3(`${(/* @__PURE__ */ new Date()).toISOString()} [${process.pid}] ${message3}`, false);
|
|
23919
23996
|
}
|
|
23920
|
-
function relayDaemonLog(line) {
|
|
23921
|
-
emit3(`[
|
|
23997
|
+
function relayDaemonLog(node, line) {
|
|
23998
|
+
emit3(`[${node}] ${line}`, true);
|
|
23922
23999
|
}
|
|
23923
|
-
function emit3(line) {
|
|
24000
|
+
function emit3(line, relayed) {
|
|
23924
24001
|
console.log(line);
|
|
23925
|
-
ring.push(line);
|
|
24002
|
+
ring.push({ line, relayed });
|
|
23926
24003
|
if (ring.length > RING_CAPACITY) ring.shift();
|
|
23927
|
-
sink?.(line);
|
|
24004
|
+
sink?.(line, relayed);
|
|
23928
24005
|
}
|
|
23929
24006
|
function setDaemonLogSink(next3) {
|
|
23930
24007
|
sink = next3;
|
|
23931
24008
|
}
|
|
23932
|
-
function recentDaemonLogLines() {
|
|
23933
|
-
return
|
|
24009
|
+
function recentDaemonLogLines(includeRelayed = true) {
|
|
24010
|
+
return ring.filter((entry) => includeRelayed || !entry.relayed).map((entry) => entry.line);
|
|
23934
24011
|
}
|
|
23935
24012
|
|
|
23936
24013
|
// src/commands/sessions/daemon/worktree/canonicalTreePath.ts
|
|
23937
24014
|
import { realpathSync as realpathSync2 } from "fs";
|
|
23938
|
-
import { resolve as
|
|
24015
|
+
import { resolve as resolve15 } from "path";
|
|
23939
24016
|
function canonicalTreePath(path103) {
|
|
23940
24017
|
try {
|
|
23941
24018
|
return realpathSync2(path103);
|
|
23942
24019
|
} catch {
|
|
23943
|
-
return
|
|
24020
|
+
return resolve15(path103);
|
|
23944
24021
|
}
|
|
23945
24022
|
}
|
|
23946
24023
|
|
|
23947
24024
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
23948
|
-
import { existsSync as
|
|
23949
|
-
import { basename as basename17, dirname as
|
|
24025
|
+
import { existsSync as existsSync57 } from "fs";
|
|
24026
|
+
import { basename as basename17, dirname as dirname28 } from "path";
|
|
23950
24027
|
|
|
23951
24028
|
// src/commands/sessions/daemon/worktree/planAllocation.ts
|
|
23952
|
-
import { basename as basename16, join as
|
|
24029
|
+
import { basename as basename16, join as join64 } from "path";
|
|
23953
24030
|
function planAllocation(clone, boundTreeRoots2) {
|
|
23954
24031
|
return boundTreeRoots2.has(clone) ? "spill" : "primary";
|
|
23955
24032
|
}
|
|
23956
24033
|
function nextWorktreePath(clone, base, isTaken) {
|
|
23957
24034
|
const name = basename16(clone);
|
|
23958
24035
|
for (let n = 2; n < 1e3; n++) {
|
|
23959
|
-
const candidate =
|
|
24036
|
+
const candidate = join64(base, `${name}-${n}`);
|
|
23960
24037
|
if (!isTaken(candidate)) return candidate;
|
|
23961
24038
|
}
|
|
23962
24039
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -23989,10 +24066,10 @@ function cloneHead(clone) {
|
|
|
23989
24066
|
|
|
23990
24067
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
23991
24068
|
function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
23992
|
-
const base = strategy.root ? expandTilde2(strategy.root) :
|
|
24069
|
+
const base = strategy.root ? expandTilde2(strategy.root) : dirname28(clone);
|
|
23993
24070
|
const registered = new Set(listWorktreePaths(clone));
|
|
23994
24071
|
const branches = new Set(listLocalBranches(clone));
|
|
23995
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
24072
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync57(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename17(candidate));
|
|
23996
24073
|
const path103 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
23997
24074
|
const start3 = worktreeStartPoint(clone, strategy.trunk);
|
|
23998
24075
|
gitSync(clone, [
|
|
@@ -24018,7 +24095,7 @@ function keptInTree(cwd, reason4) {
|
|
|
24018
24095
|
}
|
|
24019
24096
|
|
|
24020
24097
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
24021
|
-
import { existsSync as
|
|
24098
|
+
import { existsSync as existsSync58 } from "fs";
|
|
24022
24099
|
var treeIsGone = { durable: true, gone: true };
|
|
24023
24100
|
function treeDurability(state) {
|
|
24024
24101
|
if (state.dirty) return { durable: false, reason: "uncommitted changes" };
|
|
@@ -24049,14 +24126,14 @@ function* durabilityProbes() {
|
|
|
24049
24126
|
});
|
|
24050
24127
|
}
|
|
24051
24128
|
async function checkDurability(cwd) {
|
|
24052
|
-
if (!
|
|
24129
|
+
if (!existsSync58(cwd)) return treeIsGone;
|
|
24053
24130
|
const probes = durabilityProbes();
|
|
24054
24131
|
let step3 = probes.next();
|
|
24055
24132
|
while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
|
|
24056
24133
|
return step3.value;
|
|
24057
24134
|
}
|
|
24058
24135
|
function checkDurabilitySync(cwd) {
|
|
24059
|
-
if (!
|
|
24136
|
+
if (!existsSync58(cwd)) return treeIsGone;
|
|
24060
24137
|
const probes = durabilityProbes();
|
|
24061
24138
|
let step3 = probes.next();
|
|
24062
24139
|
while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
|
|
@@ -24254,6 +24331,10 @@ function loadPersistedSessions() {
|
|
|
24254
24331
|
const rejected = [];
|
|
24255
24332
|
const loaded = data.flatMap((entry) => {
|
|
24256
24333
|
const parsed = persistedSessionSchema.safeParse(entry);
|
|
24334
|
+
if (parsed.success && parsed.data.id?.startsWith("w-")) {
|
|
24335
|
+
rejected.push(`${parsed.data.id}: legacy windows-proxy session`);
|
|
24336
|
+
return [];
|
|
24337
|
+
}
|
|
24257
24338
|
if (parsed.success) return [parsed.data];
|
|
24258
24339
|
rejected.push(
|
|
24259
24340
|
`${describePersistedSession(entry)}: ${parsed.error.issues.map((i) => `${i.path.join(".")} ${i.message}`).join("; ")}`
|
|
@@ -24301,20 +24382,20 @@ function persistedTreeRoots() {
|
|
|
24301
24382
|
}
|
|
24302
24383
|
|
|
24303
24384
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
24304
|
-
import { copyFileSync, existsSync as
|
|
24305
|
-
import { dirname as
|
|
24385
|
+
import { copyFileSync, existsSync as existsSync60, mkdirSync as mkdirSync17 } from "fs";
|
|
24386
|
+
import { dirname as dirname29, join as join66 } from "path";
|
|
24306
24387
|
|
|
24307
24388
|
// src/commands/sessions/daemon/worktree/runInstall.ts
|
|
24308
|
-
import { spawn as
|
|
24389
|
+
import { spawn as spawn6 } from "child_process";
|
|
24309
24390
|
|
|
24310
24391
|
// src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
|
|
24311
|
-
import { existsSync as
|
|
24312
|
-
import { join as
|
|
24392
|
+
import { existsSync as existsSync59 } from "fs";
|
|
24393
|
+
import { join as join65 } from "path";
|
|
24313
24394
|
function detectInstallCommand(repoRoot2) {
|
|
24314
|
-
if (!
|
|
24315
|
-
if (
|
|
24316
|
-
if (
|
|
24317
|
-
if (
|
|
24395
|
+
if (!existsSync59(join65(repoRoot2, "package.json"))) return null;
|
|
24396
|
+
if (existsSync59(join65(repoRoot2, "pnpm-lock.yaml"))) return "pnpm install";
|
|
24397
|
+
if (existsSync59(join65(repoRoot2, "yarn.lock"))) return "yarn install";
|
|
24398
|
+
if (existsSync59(join65(repoRoot2, "bun.lockb"))) return "bun install";
|
|
24318
24399
|
return "npm install";
|
|
24319
24400
|
}
|
|
24320
24401
|
function resolveInstallCommand(repoRoot2, install) {
|
|
@@ -24394,7 +24475,7 @@ function runInstall(worktreePath, clone, install, onSeeded) {
|
|
|
24394
24475
|
return;
|
|
24395
24476
|
}
|
|
24396
24477
|
daemonLog(`worktree ${worktreePath} installing deps: ${command}`);
|
|
24397
|
-
const child =
|
|
24478
|
+
const child = spawn6(...installInvocation(worktreePath, command));
|
|
24398
24479
|
trackInstall(worktreePath, child);
|
|
24399
24480
|
let stderr = "";
|
|
24400
24481
|
child.stderr?.on("data", (chunk) => {
|
|
@@ -24426,11 +24507,11 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
24426
24507
|
}
|
|
24427
24508
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
24428
24509
|
for (const rel of copy) {
|
|
24429
|
-
const src =
|
|
24430
|
-
if (!
|
|
24431
|
-
const dest =
|
|
24510
|
+
const src = join66(clone, rel);
|
|
24511
|
+
if (!existsSync60(src)) continue;
|
|
24512
|
+
const dest = join66(worktreePath, rel);
|
|
24432
24513
|
try {
|
|
24433
|
-
mkdirSync17(
|
|
24514
|
+
mkdirSync17(dirname29(dest), { recursive: true });
|
|
24434
24515
|
copyFileSync(src, dest);
|
|
24435
24516
|
daemonLog(`worktree ${worktreePath} seeded ${rel}`);
|
|
24436
24517
|
} catch (error) {
|
|
@@ -24469,10 +24550,10 @@ async function moveToPrCheckoutTree() {
|
|
|
24469
24550
|
}
|
|
24470
24551
|
|
|
24471
24552
|
// src/commands/review/prHeadBranch.ts
|
|
24472
|
-
import { execFileSync as
|
|
24553
|
+
import { execFileSync as execFileSync14 } from "child_process";
|
|
24473
24554
|
function prHeadBranch(number) {
|
|
24474
24555
|
try {
|
|
24475
|
-
const out =
|
|
24556
|
+
const out = execFileSync14(
|
|
24476
24557
|
"gh",
|
|
24477
24558
|
["pr", "view", number, "--json", "headRefName", "-q", ".headRefName"],
|
|
24478
24559
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
@@ -24534,7 +24615,7 @@ async function checkoutPr(number) {
|
|
|
24534
24615
|
if (headRef && await moveToExistingCheckout(number, headRef)) return;
|
|
24535
24616
|
await moveToPrCheckoutTree();
|
|
24536
24617
|
try {
|
|
24537
|
-
|
|
24618
|
+
execFileSync15("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
24538
24619
|
} catch {
|
|
24539
24620
|
console.error(chalk168.red(`gh pr checkout ${number} failed; aborting.`));
|
|
24540
24621
|
process.exit(1);
|
|
@@ -24733,12 +24814,12 @@ function registerLitellm(program2) {
|
|
|
24733
24814
|
|
|
24734
24815
|
// src/commands/mermaidExport.ts
|
|
24735
24816
|
import { mkdirSync as mkdirSync18, readdirSync as readdirSync11 } from "fs";
|
|
24736
|
-
import { resolve as
|
|
24817
|
+
import { resolve as resolve17 } from "path";
|
|
24737
24818
|
import chalk173 from "chalk";
|
|
24738
24819
|
|
|
24739
24820
|
// src/commands/mermaid/exportFile.ts
|
|
24740
24821
|
import { readFileSync as readFileSync39, writeFileSync as writeFileSync32 } from "fs";
|
|
24741
|
-
import { basename as basename18, extname as extname2, resolve as
|
|
24822
|
+
import { basename as basename18, extname as extname2, resolve as resolve16 } from "path";
|
|
24742
24823
|
import chalk172 from "chalk";
|
|
24743
24824
|
|
|
24744
24825
|
// src/commands/mermaid/renderBlock.ts
|
|
@@ -24786,7 +24867,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
24786
24867
|
for (const [i, source] of blocks.entries()) {
|
|
24787
24868
|
const idx = i + 1;
|
|
24788
24869
|
if (onlyIndex !== void 0 && idx !== onlyIndex) continue;
|
|
24789
|
-
const outPath =
|
|
24870
|
+
const outPath = resolve16(outDir, `${stem}-${idx}.svg`);
|
|
24790
24871
|
const svg = await renderBlock(krokiUrl, source);
|
|
24791
24872
|
writeFileSync32(outPath, svg, "utf8");
|
|
24792
24873
|
console.log(chalk172.green(` \u2192 ${outPath}`));
|
|
@@ -24800,7 +24881,7 @@ function extractMermaidBlocks(markdown) {
|
|
|
24800
24881
|
// src/commands/mermaidExport.ts
|
|
24801
24882
|
async function mermaidExport(file, options2 = {}) {
|
|
24802
24883
|
const { mermaid } = loadConfig();
|
|
24803
|
-
const outDir =
|
|
24884
|
+
const outDir = resolve17(process.cwd(), options2.out ?? ".");
|
|
24804
24885
|
mkdirSync18(outDir, { recursive: true });
|
|
24805
24886
|
if (options2.index !== void 0) {
|
|
24806
24887
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
@@ -24897,7 +24978,7 @@ import { stringify as stringify2 } from "yaml";
|
|
|
24897
24978
|
|
|
24898
24979
|
// src/commands/miro/writeExtract.ts
|
|
24899
24980
|
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync33 } from "fs";
|
|
24900
|
-
import { dirname as
|
|
24981
|
+
import { dirname as dirname30 } from "path";
|
|
24901
24982
|
import { stringify } from "yaml";
|
|
24902
24983
|
function headerLines(header) {
|
|
24903
24984
|
const { rect } = header;
|
|
@@ -24910,7 +24991,7 @@ function headerLines(header) {
|
|
|
24910
24991
|
];
|
|
24911
24992
|
}
|
|
24912
24993
|
function writeExtract(file, header, texts) {
|
|
24913
|
-
mkdirSync19(
|
|
24994
|
+
mkdirSync19(dirname30(file), { recursive: true });
|
|
24914
24995
|
writeFileSync33(file, `${headerLines(header).join("\n")}
|
|
24915
24996
|
${stringify(texts)}`);
|
|
24916
24997
|
}
|
|
@@ -24928,17 +25009,17 @@ function emitExtract(out, header, texts) {
|
|
|
24928
25009
|
}
|
|
24929
25010
|
|
|
24930
25011
|
// src/commands/miro/resolveExtractPath.ts
|
|
24931
|
-
import { isAbsolute as isAbsolute3, relative as relative5, resolve as
|
|
25012
|
+
import { isAbsolute as isAbsolute3, relative as relative5, resolve as resolve18 } from "path";
|
|
24932
25013
|
function extractRoot(cwd) {
|
|
24933
25014
|
return findConfigUp(cwd)?.rootDir ?? cwd;
|
|
24934
25015
|
}
|
|
24935
25016
|
function resolveExtractPath(value, cwd) {
|
|
24936
25017
|
if (value === void 0) return void 0;
|
|
24937
|
-
return isAbsolute3(value) ? value :
|
|
25018
|
+
return isAbsolute3(value) ? value : resolve18(extractRoot(cwd), value);
|
|
24938
25019
|
}
|
|
24939
25020
|
function storedExtractPath(value, cwd) {
|
|
24940
25021
|
if (value === void 0) return void 0;
|
|
24941
|
-
const absolute2 =
|
|
25022
|
+
const absolute2 = resolve18(cwd, value);
|
|
24942
25023
|
const within = relative5(extractRoot(cwd), absolute2);
|
|
24943
25024
|
return within.startsWith("..") ? absolute2 : within;
|
|
24944
25025
|
}
|
|
@@ -24975,10 +25056,10 @@ function applyIgnore(texts, ignore3) {
|
|
|
24975
25056
|
}
|
|
24976
25057
|
|
|
24977
25058
|
// src/commands/miro/readIgnoreList.ts
|
|
24978
|
-
import { existsSync as
|
|
25059
|
+
import { existsSync as existsSync61, readFileSync as readFileSync40 } from "fs";
|
|
24979
25060
|
import { parse as parse2 } from "yaml";
|
|
24980
25061
|
function readIgnoreList(file) {
|
|
24981
|
-
if (!
|
|
25062
|
+
if (!existsSync61(file))
|
|
24982
25063
|
throw new MiroExtractError(
|
|
24983
25064
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
24984
25065
|
);
|
|
@@ -25383,7 +25464,7 @@ function registerMiro(program2) {
|
|
|
25383
25464
|
// src/commands/netcap/netcap.ts
|
|
25384
25465
|
import { mkdir as mkdir5 } from "fs/promises";
|
|
25385
25466
|
import { createServer as createServer2 } from "http";
|
|
25386
|
-
import { dirname as
|
|
25467
|
+
import { dirname as dirname32 } from "path";
|
|
25387
25468
|
import chalk177 from "chalk";
|
|
25388
25469
|
|
|
25389
25470
|
// src/commands/netcap/corsHeaders.ts
|
|
@@ -25462,15 +25543,15 @@ function createNetcapHandler(options2) {
|
|
|
25462
25543
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
25463
25544
|
import { cp as cp4, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
25464
25545
|
import { networkInterfaces } from "os";
|
|
25465
|
-
import { join as
|
|
25546
|
+
import { join as join68 } from "path";
|
|
25466
25547
|
import chalk176 from "chalk";
|
|
25467
25548
|
|
|
25468
25549
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
25469
|
-
import { dirname as
|
|
25550
|
+
import { dirname as dirname31, join as join67 } from "path";
|
|
25470
25551
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
25471
|
-
var moduleDir2 =
|
|
25552
|
+
var moduleDir2 = dirname31(fileURLToPath7(import.meta.url));
|
|
25472
25553
|
function netcapExtensionDir() {
|
|
25473
|
-
return
|
|
25554
|
+
return join67(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
25474
25555
|
}
|
|
25475
25556
|
|
|
25476
25557
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -25485,7 +25566,7 @@ function lanIPv4() {
|
|
|
25485
25566
|
return void 0;
|
|
25486
25567
|
}
|
|
25487
25568
|
async function configureBackground(dir, host, port, filter) {
|
|
25488
|
-
const file =
|
|
25569
|
+
const file = join68(dir, "background.js");
|
|
25489
25570
|
const source = await readFile5(file, "utf8");
|
|
25490
25571
|
await writeFile5(
|
|
25491
25572
|
file,
|
|
@@ -25525,20 +25606,20 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
25525
25606
|
}
|
|
25526
25607
|
|
|
25527
25608
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
25528
|
-
import { isAbsolute as isAbsolute4, join as
|
|
25609
|
+
import { isAbsolute as isAbsolute4, join as join70, resolve as resolve19 } from "path";
|
|
25529
25610
|
|
|
25530
25611
|
// src/commands/netcap/defaultCapturePath.ts
|
|
25531
25612
|
import { homedir as homedir21 } from "os";
|
|
25532
|
-
import { join as
|
|
25613
|
+
import { join as join69 } from "path";
|
|
25533
25614
|
function defaultCapturePath() {
|
|
25534
|
-
return
|
|
25615
|
+
return join69(homedir21(), ".assist", "netcap", "capture.jsonl");
|
|
25535
25616
|
}
|
|
25536
25617
|
|
|
25537
25618
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
25538
25619
|
function resolveNetcapOutPath(out) {
|
|
25539
25620
|
if (!out) return defaultCapturePath();
|
|
25540
|
-
const dir = isAbsolute4(out) ? out :
|
|
25541
|
-
return
|
|
25621
|
+
const dir = isAbsolute4(out) ? out : resolve19(process.cwd(), out);
|
|
25622
|
+
return join70(dir, "capture.jsonl");
|
|
25542
25623
|
}
|
|
25543
25624
|
|
|
25544
25625
|
// src/commands/netcap/netcap.ts
|
|
@@ -25546,7 +25627,7 @@ async function netcap(options2) {
|
|
|
25546
25627
|
const port = Number(options2.port);
|
|
25547
25628
|
const outPath = resolveNetcapOutPath(options2.out);
|
|
25548
25629
|
const filter = options2.filter ?? "";
|
|
25549
|
-
await mkdir5(
|
|
25630
|
+
await mkdir5(dirname32(outPath), { recursive: true });
|
|
25550
25631
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
25551
25632
|
let count8 = 0;
|
|
25552
25633
|
const handler = createNetcapHandler({
|
|
@@ -25585,7 +25666,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
25585
25666
|
|
|
25586
25667
|
// src/commands/netcap/netcapExtract.ts
|
|
25587
25668
|
import { writeFileSync as writeFileSync34 } from "fs";
|
|
25588
|
-
import { join as
|
|
25669
|
+
import { join as join71 } from "path";
|
|
25589
25670
|
import chalk178 from "chalk";
|
|
25590
25671
|
|
|
25591
25672
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
@@ -26030,7 +26111,7 @@ function extractPostsFromCapture(captureFile) {
|
|
|
26030
26111
|
function netcapExtract(file) {
|
|
26031
26112
|
const captureFile = file ?? defaultCapturePath();
|
|
26032
26113
|
const posts = extractPostsFromCapture(captureFile);
|
|
26033
|
-
const outFile =
|
|
26114
|
+
const outFile = join71(captureFile, "..", "posts.json");
|
|
26034
26115
|
writeFileSync34(outFile, `${JSON.stringify(posts, null, 2)}
|
|
26035
26116
|
`);
|
|
26036
26117
|
console.log(
|
|
@@ -26393,17 +26474,17 @@ import { execSync as execSync41 } from "child_process";
|
|
|
26393
26474
|
import { execSync as execSync40 } from "child_process";
|
|
26394
26475
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync35 } from "fs";
|
|
26395
26476
|
import { tmpdir as tmpdir7 } from "os";
|
|
26396
|
-
import { join as
|
|
26477
|
+
import { join as join73 } from "path";
|
|
26397
26478
|
|
|
26398
26479
|
// src/commands/prs/loadCommentsCache.ts
|
|
26399
|
-
import { existsSync as
|
|
26480
|
+
import { existsSync as existsSync62, readFileSync as readFileSync43, unlinkSync as unlinkSync13 } from "fs";
|
|
26400
26481
|
import { parse as parse3 } from "yaml";
|
|
26401
26482
|
|
|
26402
26483
|
// src/commands/prs/commentsCachePath.ts
|
|
26403
26484
|
import { homedir as homedir22 } from "os";
|
|
26404
|
-
import { join as
|
|
26485
|
+
import { join as join72 } from "path";
|
|
26405
26486
|
function commentsCachePath(org, repo, prNumber) {
|
|
26406
|
-
return
|
|
26487
|
+
return join72(
|
|
26407
26488
|
homedir22(),
|
|
26408
26489
|
".assist",
|
|
26409
26490
|
"pr-comments",
|
|
@@ -26416,7 +26497,7 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
26416
26497
|
// src/commands/prs/loadCommentsCache.ts
|
|
26417
26498
|
function loadCommentsCache(org, repo, prNumber) {
|
|
26418
26499
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26419
|
-
if (!
|
|
26500
|
+
if (!existsSync62(cachePath)) {
|
|
26420
26501
|
return null;
|
|
26421
26502
|
}
|
|
26422
26503
|
const content = readFileSync43(cachePath, "utf8");
|
|
@@ -26424,7 +26505,7 @@ function loadCommentsCache(org, repo, prNumber) {
|
|
|
26424
26505
|
}
|
|
26425
26506
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
26426
26507
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26427
|
-
if (
|
|
26508
|
+
if (existsSync62(cachePath)) {
|
|
26428
26509
|
unlinkSync13(cachePath);
|
|
26429
26510
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
26430
26511
|
}
|
|
@@ -26452,7 +26533,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
26452
26533
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
26453
26534
|
function resolveThread(threadId) {
|
|
26454
26535
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
26455
|
-
const queryFile =
|
|
26536
|
+
const queryFile = join73(tmpdir7(), `gh-mutation-${Date.now()}.graphql`);
|
|
26456
26537
|
writeFileSync35(queryFile, mutation);
|
|
26457
26538
|
try {
|
|
26458
26539
|
execSync40(
|
|
@@ -26537,10 +26618,10 @@ function fixed(commentId, sha) {
|
|
|
26537
26618
|
import { execSync as execSync42 } from "child_process";
|
|
26538
26619
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync36 } from "fs";
|
|
26539
26620
|
import { tmpdir as tmpdir8 } from "os";
|
|
26540
|
-
import { join as
|
|
26621
|
+
import { join as join74 } from "path";
|
|
26541
26622
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
26542
26623
|
function fetchThreadIds(org, repo, prNumber) {
|
|
26543
|
-
const queryFile =
|
|
26624
|
+
const queryFile = join74(tmpdir8(), `gh-query-${Date.now()}.graphql`);
|
|
26544
26625
|
writeFileSync36(queryFile, THREAD_QUERY);
|
|
26545
26626
|
try {
|
|
26546
26627
|
const result = execSync42(
|
|
@@ -26610,15 +26691,15 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
26610
26691
|
|
|
26611
26692
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
26612
26693
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync37 } from "fs";
|
|
26613
|
-
import { dirname as
|
|
26694
|
+
import { dirname as dirname33 } from "path";
|
|
26614
26695
|
import { stringify as stringify3 } from "yaml";
|
|
26615
26696
|
|
|
26616
26697
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
26617
26698
|
import { readdirSync as readdirSync12, unlinkSync as unlinkSync16 } from "fs";
|
|
26618
|
-
import { join as
|
|
26699
|
+
import { join as join75 } from "path";
|
|
26619
26700
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
26620
26701
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
26621
|
-
const dir =
|
|
26702
|
+
const dir = join75(cwd, ".assist");
|
|
26622
26703
|
let entries;
|
|
26623
26704
|
try {
|
|
26624
26705
|
entries = readdirSync12(dir);
|
|
@@ -26626,14 +26707,14 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
|
26626
26707
|
return;
|
|
26627
26708
|
}
|
|
26628
26709
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
26629
|
-
unlinkSync16(
|
|
26710
|
+
unlinkSync16(join75(dir, entry));
|
|
26630
26711
|
}
|
|
26631
26712
|
}
|
|
26632
26713
|
|
|
26633
26714
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
26634
26715
|
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
26635
26716
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26636
|
-
mkdirSync20(
|
|
26717
|
+
mkdirSync20(dirname33(cachePath), { recursive: true });
|
|
26637
26718
|
const cacheData = {
|
|
26638
26719
|
prNumber,
|
|
26639
26720
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -26957,13 +27038,13 @@ function registerPrsComments(prsCommand) {
|
|
|
26957
27038
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
26958
27039
|
|
|
26959
27040
|
// src/commands/prs/applyEdit.ts
|
|
26960
|
-
import { execFileSync as
|
|
27041
|
+
import { execFileSync as execFileSync16 } from "child_process";
|
|
26961
27042
|
function applyEdit(number, title, body) {
|
|
26962
27043
|
const args = ["pr", "edit", String(number)];
|
|
26963
27044
|
if (title) args.push("--title", title);
|
|
26964
27045
|
args.push("--body", body);
|
|
26965
27046
|
try {
|
|
26966
|
-
|
|
27047
|
+
execFileSync16("gh", args, { stdio: "inherit" });
|
|
26967
27048
|
} catch {
|
|
26968
27049
|
process.exit(1);
|
|
26969
27050
|
}
|
|
@@ -27255,7 +27336,7 @@ function buildValidatedBody(options2, usage) {
|
|
|
27255
27336
|
}
|
|
27256
27337
|
|
|
27257
27338
|
// src/commands/prs/placePr.ts
|
|
27258
|
-
import { execFileSync as
|
|
27339
|
+
import { execFileSync as execFileSync17 } from "child_process";
|
|
27259
27340
|
|
|
27260
27341
|
// src/commands/prs/buildCreateArgs.ts
|
|
27261
27342
|
function buildEditArgs(number, title, body) {
|
|
@@ -27322,7 +27403,7 @@ async function recordPrActivity() {
|
|
|
27322
27403
|
// src/commands/prs/placePr.ts
|
|
27323
27404
|
function hasUpstream2() {
|
|
27324
27405
|
try {
|
|
27325
|
-
|
|
27406
|
+
execFileSync17(
|
|
27326
27407
|
"git",
|
|
27327
27408
|
["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
|
|
27328
27409
|
{ stdio: "pipe" }
|
|
@@ -27334,13 +27415,13 @@ function hasUpstream2() {
|
|
|
27334
27415
|
}
|
|
27335
27416
|
function ensureBranchPushed() {
|
|
27336
27417
|
const args = hasUpstream2() ? ["push"] : ["push", "--set-upstream", "origin", "HEAD"];
|
|
27337
|
-
|
|
27418
|
+
execFileSync17("git", args, { stdio: "inherit" });
|
|
27338
27419
|
}
|
|
27339
27420
|
async function placePr(prNumber, title, body, options2) {
|
|
27340
27421
|
const args = prNumber !== null ? buildEditArgs(prNumber, title, body) : buildCreateArgs(title, body, options2);
|
|
27341
27422
|
try {
|
|
27342
27423
|
if (prNumber === null && !options2.head) ensureBranchPushed();
|
|
27343
|
-
|
|
27424
|
+
execFileSync17("gh", args, { stdio: "inherit" });
|
|
27344
27425
|
} catch {
|
|
27345
27426
|
process.exit(1);
|
|
27346
27427
|
}
|
|
@@ -27480,10 +27561,10 @@ function warn(reason4) {
|
|
|
27480
27561
|
}
|
|
27481
27562
|
|
|
27482
27563
|
// src/commands/prs/enableAutoMerge.ts
|
|
27483
|
-
import { execFileSync as
|
|
27564
|
+
import { execFileSync as execFileSync18 } from "child_process";
|
|
27484
27565
|
function enableAutoMerge() {
|
|
27485
27566
|
try {
|
|
27486
|
-
|
|
27567
|
+
execFileSync18(
|
|
27487
27568
|
"gh",
|
|
27488
27569
|
["pr", "merge", getCurrentBranch2(), "--auto", "--squash"],
|
|
27489
27570
|
{ stdio: "inherit" }
|
|
@@ -29244,9 +29325,9 @@ async function notify() {
|
|
|
29244
29325
|
|
|
29245
29326
|
// src/commands/screenshot.ts
|
|
29246
29327
|
import { execSync as execSync52 } from "child_process";
|
|
29247
|
-
import { existsSync as
|
|
29328
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
29248
29329
|
import { tmpdir as tmpdir9 } from "os";
|
|
29249
|
-
import { join as
|
|
29330
|
+
import { join as join76, resolve as resolve20 } from "path";
|
|
29250
29331
|
import chalk203 from "chalk";
|
|
29251
29332
|
|
|
29252
29333
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -29376,14 +29457,14 @@ Write-Output $OutputPath
|
|
|
29376
29457
|
|
|
29377
29458
|
// src/commands/screenshot.ts
|
|
29378
29459
|
function buildOutputPath(outputDir, processName) {
|
|
29379
|
-
if (!
|
|
29460
|
+
if (!existsSync63(outputDir)) {
|
|
29380
29461
|
mkdirSync21(outputDir, { recursive: true });
|
|
29381
29462
|
}
|
|
29382
29463
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
29383
|
-
return
|
|
29464
|
+
return resolve20(outputDir, `${processName}-${timestamp6}.png`);
|
|
29384
29465
|
}
|
|
29385
29466
|
function runPowerShellScript(processName, outputPath) {
|
|
29386
|
-
const scriptPath =
|
|
29467
|
+
const scriptPath = join76(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
29387
29468
|
writeFileSync38(scriptPath, captureWindowPs1, "utf8");
|
|
29388
29469
|
try {
|
|
29389
29470
|
execSync52(
|
|
@@ -29396,7 +29477,7 @@ function runPowerShellScript(processName, outputPath) {
|
|
|
29396
29477
|
}
|
|
29397
29478
|
function screenshot(processName) {
|
|
29398
29479
|
const config = loadConfig();
|
|
29399
|
-
const outputDir =
|
|
29480
|
+
const outputDir = resolve20(config.screenshot.outputDir);
|
|
29400
29481
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
29401
29482
|
console.log(chalk203.gray(`Capturing window for process "${processName}" ...`));
|
|
29402
29483
|
try {
|
|
@@ -29498,9 +29579,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
29498
29579
|
|
|
29499
29580
|
// src/commands/readGitBranch.ts
|
|
29500
29581
|
import { readFileSync as readFileSync46, statSync as statSync10 } from "fs";
|
|
29501
|
-
import { isAbsolute as isAbsolute5, join as
|
|
29582
|
+
import { isAbsolute as isAbsolute5, join as join77, resolve as resolve21 } from "path";
|
|
29502
29583
|
function resolveGitDir(cwd) {
|
|
29503
|
-
const dotGit =
|
|
29584
|
+
const dotGit = join77(cwd, ".git");
|
|
29504
29585
|
let stat4;
|
|
29505
29586
|
try {
|
|
29506
29587
|
stat4 = statSync10(dotGit);
|
|
@@ -29521,7 +29602,7 @@ function resolveGitDir(cwd) {
|
|
|
29521
29602
|
return null;
|
|
29522
29603
|
}
|
|
29523
29604
|
const gitDir = match[1].trim();
|
|
29524
|
-
return isAbsolute5(gitDir) ? gitDir :
|
|
29605
|
+
return isAbsolute5(gitDir) ? gitDir : resolve21(cwd, gitDir);
|
|
29525
29606
|
}
|
|
29526
29607
|
function readGitBranch(cwd) {
|
|
29527
29608
|
const gitDir = resolveGitDir(cwd);
|
|
@@ -29530,7 +29611,7 @@ function readGitBranch(cwd) {
|
|
|
29530
29611
|
}
|
|
29531
29612
|
let head;
|
|
29532
29613
|
try {
|
|
29533
|
-
head = readFileSync46(
|
|
29614
|
+
head = readFileSync46(join77(gitDir, "HEAD"), "utf8");
|
|
29534
29615
|
} catch {
|
|
29535
29616
|
return null;
|
|
29536
29617
|
}
|
|
@@ -29684,7 +29765,7 @@ function registerRootCommands(program2) {
|
|
|
29684
29765
|
}
|
|
29685
29766
|
|
|
29686
29767
|
// src/commands/refactor/check.ts
|
|
29687
|
-
import { spawn as
|
|
29768
|
+
import { spawn as spawn7 } from "child_process";
|
|
29688
29769
|
import * as path46 from "path";
|
|
29689
29770
|
|
|
29690
29771
|
// src/commands/refactor/logViolations.ts
|
|
@@ -29832,7 +29913,7 @@ function getViolations(pattern2, options2 = {}, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
29832
29913
|
// src/commands/refactor/check.ts
|
|
29833
29914
|
function runScript(script, cwd) {
|
|
29834
29915
|
return new Promise((resolve25) => {
|
|
29835
|
-
const child =
|
|
29916
|
+
const child = spawn7("npm", ["run", script], {
|
|
29836
29917
|
stdio: "pipe",
|
|
29837
29918
|
shell: true,
|
|
29838
29919
|
cwd
|
|
@@ -31795,7 +31876,7 @@ function exitWith(message3) {
|
|
|
31795
31876
|
}
|
|
31796
31877
|
|
|
31797
31878
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
31798
|
-
import { execFileSync as
|
|
31879
|
+
import { execFileSync as execFileSync20 } from "child_process";
|
|
31799
31880
|
import chalk223 from "chalk";
|
|
31800
31881
|
|
|
31801
31882
|
// src/commands/review/highLevel/buildGlobProposalPrompt.ts
|
|
@@ -31843,8 +31924,8 @@ function readGlobs(value) {
|
|
|
31843
31924
|
}
|
|
31844
31925
|
|
|
31845
31926
|
// src/commands/review/highLevel/summariseRepoTree.ts
|
|
31846
|
-
import { execFileSync as
|
|
31847
|
-
import { dirname as
|
|
31927
|
+
import { execFileSync as execFileSync19 } from "child_process";
|
|
31928
|
+
import { dirname as dirname35, extname as extname3 } from "path";
|
|
31848
31929
|
var MAX_DIRECTORIES = 200;
|
|
31849
31930
|
var MAX_EXTENSIONS_PER_DIRECTORY = 6;
|
|
31850
31931
|
function summariseRepoTree(cwd = process.cwd()) {
|
|
@@ -31859,7 +31940,7 @@ function summariseRepoTree(cwd = process.cwd()) {
|
|
|
31859
31940
|
}
|
|
31860
31941
|
function listTrackedFiles(cwd) {
|
|
31861
31942
|
try {
|
|
31862
|
-
return
|
|
31943
|
+
return execFileSync19("git", ["ls-files"], {
|
|
31863
31944
|
cwd,
|
|
31864
31945
|
encoding: "utf8",
|
|
31865
31946
|
maxBuffer: 64 * 1024 * 1024
|
|
@@ -31871,7 +31952,7 @@ function listTrackedFiles(cwd) {
|
|
|
31871
31952
|
function countByDirectory(files) {
|
|
31872
31953
|
const directories = /* @__PURE__ */ new Map();
|
|
31873
31954
|
for (const file of files) {
|
|
31874
|
-
const directory =
|
|
31955
|
+
const directory = dirname35(file) === "." ? "(repo root)" : dirname35(file);
|
|
31875
31956
|
const extensions = directories.get(directory) ?? /* @__PURE__ */ new Map();
|
|
31876
31957
|
const extension = extname3(file) === "" ? "(no extension)" : extname3(file);
|
|
31877
31958
|
extensions.set(extension, (extensions.get(extension) ?? 0) + 1);
|
|
@@ -31904,7 +31985,7 @@ function proposeHighLevelGlobs(cwd = process.cwd()) {
|
|
|
31904
31985
|
}
|
|
31905
31986
|
function askClaude(prompt, cwd) {
|
|
31906
31987
|
try {
|
|
31907
|
-
return
|
|
31988
|
+
return execFileSync20("claude", ["-p", "--model", "sonnet", prompt], {
|
|
31908
31989
|
cwd,
|
|
31909
31990
|
encoding: "utf8",
|
|
31910
31991
|
timeout: 12e4,
|
|
@@ -32330,15 +32411,15 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
32330
32411
|
}
|
|
32331
32412
|
|
|
32332
32413
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
32333
|
-
import { existsSync as
|
|
32414
|
+
import { existsSync as existsSync64, readFileSync as readFileSync47 } from "fs";
|
|
32334
32415
|
|
|
32335
32416
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
32336
|
-
import { join as
|
|
32417
|
+
import { join as join78 } from "path";
|
|
32337
32418
|
function slug(value) {
|
|
32338
32419
|
return value.replace(/[^\w.-]+/g, "-");
|
|
32339
32420
|
}
|
|
32340
32421
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
32341
|
-
return
|
|
32422
|
+
return join78(
|
|
32342
32423
|
getStoreDir(),
|
|
32343
32424
|
"high-level-reviews",
|
|
32344
32425
|
slug(repo),
|
|
@@ -32349,7 +32430,7 @@ function highLevelReviewPath(repo, headRef, headSha) {
|
|
|
32349
32430
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
32350
32431
|
function loadHighLevelReview(repo, headRef, headSha) {
|
|
32351
32432
|
const path103 = highLevelReviewPath(repo, headRef, headSha);
|
|
32352
|
-
if (!
|
|
32433
|
+
if (!existsSync64(path103)) return void 0;
|
|
32353
32434
|
try {
|
|
32354
32435
|
return JSON.parse(readFileSync47(path103, "utf8"));
|
|
32355
32436
|
} catch {
|
|
@@ -32476,10 +32557,10 @@ function highLevelPreviewPayload(subject) {
|
|
|
32476
32557
|
|
|
32477
32558
|
// src/commands/review/highLevel/saveHighLevelReview.ts
|
|
32478
32559
|
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync39 } from "fs";
|
|
32479
|
-
import { dirname as
|
|
32560
|
+
import { dirname as dirname36 } from "path";
|
|
32480
32561
|
function saveHighLevelReview(record) {
|
|
32481
32562
|
const path103 = highLevelReviewPath(record.repo, record.headRef, record.headSha);
|
|
32482
|
-
mkdirSync22(
|
|
32563
|
+
mkdirSync22(dirname36(path103), { recursive: true });
|
|
32483
32564
|
writeFileSync39(path103, `${JSON.stringify(record, null, 2)}
|
|
32484
32565
|
`);
|
|
32485
32566
|
return path103;
|
|
@@ -32773,9 +32854,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
32773
32854
|
|
|
32774
32855
|
// src/commands/review/buildReviewPaths.ts
|
|
32775
32856
|
import { homedir as homedir23 } from "os";
|
|
32776
|
-
import { basename as basename20, join as
|
|
32857
|
+
import { basename as basename20, join as join79 } from "path";
|
|
32777
32858
|
function buildReviewPaths(repoRoot2, key) {
|
|
32778
|
-
const reviewDir =
|
|
32859
|
+
const reviewDir = join79(
|
|
32779
32860
|
homedir23(),
|
|
32780
32861
|
".assist",
|
|
32781
32862
|
"reviews",
|
|
@@ -32784,10 +32865,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
32784
32865
|
);
|
|
32785
32866
|
return {
|
|
32786
32867
|
reviewDir,
|
|
32787
|
-
requestPath:
|
|
32788
|
-
claudePath:
|
|
32789
|
-
codexPath:
|
|
32790
|
-
synthesisPath:
|
|
32868
|
+
requestPath: join79(reviewDir, "request.md"),
|
|
32869
|
+
claudePath: join79(reviewDir, "claude.md"),
|
|
32870
|
+
codexPath: join79(reviewDir, "codex.md"),
|
|
32871
|
+
synthesisPath: join79(reviewDir, "synthesis.md")
|
|
32791
32872
|
};
|
|
32792
32873
|
}
|
|
32793
32874
|
|
|
@@ -33516,10 +33597,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
33516
33597
|
}
|
|
33517
33598
|
|
|
33518
33599
|
// src/commands/review/prepareReviewDir.ts
|
|
33519
|
-
import { existsSync as
|
|
33600
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
|
|
33520
33601
|
function clearReviewFiles(paths) {
|
|
33521
33602
|
for (const path103 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
33522
|
-
if (
|
|
33603
|
+
if (existsSync65(path103)) unlinkSync18(path103);
|
|
33523
33604
|
}
|
|
33524
33605
|
}
|
|
33525
33606
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -33581,7 +33662,7 @@ import { format } from "util";
|
|
|
33581
33662
|
|
|
33582
33663
|
// src/commands/review/createReviewLogSink.ts
|
|
33583
33664
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync24 } from "fs";
|
|
33584
|
-
import { join as
|
|
33665
|
+
import { join as join80 } from "path";
|
|
33585
33666
|
|
|
33586
33667
|
// src/shared/stripAnsi.ts
|
|
33587
33668
|
var ANSI = new RegExp(
|
|
@@ -33609,7 +33690,7 @@ function createReviewLogSink() {
|
|
|
33609
33690
|
},
|
|
33610
33691
|
attach(reviewDir) {
|
|
33611
33692
|
mkdirSync24(reviewDir, { recursive: true });
|
|
33612
|
-
logPath2 =
|
|
33693
|
+
logPath2 = join80(reviewDir, LOG_FILE);
|
|
33613
33694
|
const lines2 = [
|
|
33614
33695
|
"",
|
|
33615
33696
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -33823,7 +33904,7 @@ function printReviewerFailures(results) {
|
|
|
33823
33904
|
}
|
|
33824
33905
|
|
|
33825
33906
|
// src/commands/review/runAndSynthesise.ts
|
|
33826
|
-
import { existsSync as
|
|
33907
|
+
import { existsSync as existsSync67, unlinkSync as unlinkSync20 } from "fs";
|
|
33827
33908
|
|
|
33828
33909
|
// src/commands/review/buildReviewerStdin.ts
|
|
33829
33910
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
|
|
@@ -34033,7 +34114,7 @@ function reportReviewerToolUse(name, use, spinner, model) {
|
|
|
34033
34114
|
}
|
|
34034
34115
|
|
|
34035
34116
|
// src/commands/review/runStreamingChild.ts
|
|
34036
|
-
import { spawn as
|
|
34117
|
+
import { spawn as spawn8 } from "child_process";
|
|
34037
34118
|
|
|
34038
34119
|
// src/commands/review/attachLineParser.ts
|
|
34039
34120
|
function flushBuffer(buffer, onLine) {
|
|
@@ -34187,7 +34268,7 @@ function writeStdinSafely(child, payload) {
|
|
|
34187
34268
|
}
|
|
34188
34269
|
}
|
|
34189
34270
|
function startChild(spec) {
|
|
34190
|
-
const child =
|
|
34271
|
+
const child = spawn8(spec.command, spec.args, {
|
|
34191
34272
|
stdio: ["pipe", "pipe", "pipe"],
|
|
34192
34273
|
shell: process.platform === "win32",
|
|
34193
34274
|
...spec.env ? { env: { ...process.env, ...spec.env } } : {}
|
|
@@ -34268,7 +34349,7 @@ function buildCodexModelArgs() {
|
|
|
34268
34349
|
}
|
|
34269
34350
|
|
|
34270
34351
|
// src/commands/review/runCodexReviewer.ts
|
|
34271
|
-
import { existsSync as
|
|
34352
|
+
import { existsSync as existsSync66, unlinkSync as unlinkSync19 } from "fs";
|
|
34272
34353
|
|
|
34273
34354
|
// src/commands/review/parseCodexEvent.ts
|
|
34274
34355
|
function isItemStarted(value) {
|
|
@@ -34323,7 +34404,7 @@ async function runCodexReviewer(spec) {
|
|
|
34323
34404
|
reportReviewerToolUse(spec.name, event, spinner, override.model);
|
|
34324
34405
|
}
|
|
34325
34406
|
});
|
|
34326
|
-
if (result.exitCode !== 0 &&
|
|
34407
|
+
if (result.exitCode !== 0 && existsSync66(spec.outputPath)) {
|
|
34327
34408
|
unlinkSync19(spec.outputPath);
|
|
34328
34409
|
}
|
|
34329
34410
|
return finaliseReviewerRun(
|
|
@@ -34491,7 +34572,7 @@ async function runAndSynthesise(args) {
|
|
|
34491
34572
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
34492
34573
|
return { ok: false, failures };
|
|
34493
34574
|
}
|
|
34494
|
-
if (anyFresh &&
|
|
34575
|
+
if (anyFresh && existsSync67(paths.synthesisPath)) {
|
|
34495
34576
|
unlinkSync20(paths.synthesisPath);
|
|
34496
34577
|
}
|
|
34497
34578
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -34756,7 +34837,7 @@ function registerReview(program2) {
|
|
|
34756
34837
|
}
|
|
34757
34838
|
|
|
34758
34839
|
// src/commands/rules/addRule.ts
|
|
34759
|
-
import { existsSync as
|
|
34840
|
+
import { existsSync as existsSync70, readFileSync as readFileSync53, writeFileSync as writeFileSync43 } from "fs";
|
|
34760
34841
|
import path83 from "path";
|
|
34761
34842
|
import chalk232 from "chalk";
|
|
34762
34843
|
|
|
@@ -34813,7 +34894,7 @@ function nextRuleCode(root2) {
|
|
|
34813
34894
|
}
|
|
34814
34895
|
|
|
34815
34896
|
// src/commands/rules/resolveRuleScope.ts
|
|
34816
|
-
import { existsSync as
|
|
34897
|
+
import { existsSync as existsSync68 } from "fs";
|
|
34817
34898
|
import path80 from "path";
|
|
34818
34899
|
function resolveRuleScope(target) {
|
|
34819
34900
|
const resolved = path80.resolve(target);
|
|
@@ -34823,7 +34904,7 @@ function resolveRuleScope(target) {
|
|
|
34823
34904
|
let current = startDir;
|
|
34824
34905
|
while (true) {
|
|
34825
34906
|
const candidate = path80.join(current, "CLAUDE.md");
|
|
34826
|
-
if (
|
|
34907
|
+
if (existsSync68(candidate)) return candidate;
|
|
34827
34908
|
if (current === root2 || current === path80.dirname(current)) break;
|
|
34828
34909
|
current = path80.dirname(current);
|
|
34829
34910
|
}
|
|
@@ -34831,7 +34912,7 @@ function resolveRuleScope(target) {
|
|
|
34831
34912
|
}
|
|
34832
34913
|
|
|
34833
34914
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
34834
|
-
import { existsSync as
|
|
34915
|
+
import { existsSync as existsSync69, readFileSync as readFileSync52, writeFileSync as writeFileSync42 } from "fs";
|
|
34835
34916
|
import path82 from "path";
|
|
34836
34917
|
|
|
34837
34918
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
@@ -34881,7 +34962,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
34881
34962
|
function updateScopedRulesIndex(root2) {
|
|
34882
34963
|
const directories = scopedRuleDirectories(root2);
|
|
34883
34964
|
const rootFile = path82.join(root2, "CLAUDE.md");
|
|
34884
|
-
const before =
|
|
34965
|
+
const before = existsSync69(rootFile) ? readFileSync52(rootFile, "utf8") : "";
|
|
34885
34966
|
const after = upsertScopedRulesPointer(before, directories);
|
|
34886
34967
|
if (after !== before) writeFileSync42(rootFile, after);
|
|
34887
34968
|
return directories;
|
|
@@ -34889,7 +34970,7 @@ function updateScopedRulesIndex(root2) {
|
|
|
34889
34970
|
|
|
34890
34971
|
// src/commands/rules/addRule.ts
|
|
34891
34972
|
function read2(file) {
|
|
34892
|
-
return
|
|
34973
|
+
return existsSync70(file) ? readFileSync53(file, "utf8") : "";
|
|
34893
34974
|
}
|
|
34894
34975
|
function addRule(text18, options2) {
|
|
34895
34976
|
const rule = text18.trim();
|
|
@@ -35396,12 +35477,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
35396
35477
|
}
|
|
35397
35478
|
|
|
35398
35479
|
// src/commands/slack/slackWorkingFile.ts
|
|
35399
|
-
import { join as
|
|
35480
|
+
import { join as join81 } from "path";
|
|
35400
35481
|
function slackWorkingFile(channel, partIndex) {
|
|
35401
35482
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
35402
|
-
const dir =
|
|
35483
|
+
const dir = join81(getStoreDir(), "slack");
|
|
35403
35484
|
const name = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
35404
|
-
return { dir, bodyPath:
|
|
35485
|
+
return { dir, bodyPath: join81(dir, `${name}.md`) };
|
|
35405
35486
|
}
|
|
35406
35487
|
|
|
35407
35488
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -36184,7 +36265,7 @@ function registerSync(program2) {
|
|
|
36184
36265
|
}
|
|
36185
36266
|
|
|
36186
36267
|
// src/commands/transcript/clean.ts
|
|
36187
|
-
import { existsSync as
|
|
36268
|
+
import { existsSync as existsSync75 } from "fs";
|
|
36188
36269
|
|
|
36189
36270
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
36190
36271
|
function pad(value, width) {
|
|
@@ -36462,7 +36543,7 @@ function clean(file, options2 = {}) {
|
|
|
36462
36543
|
);
|
|
36463
36544
|
process.exit(1);
|
|
36464
36545
|
}
|
|
36465
|
-
if (!
|
|
36546
|
+
if (!existsSync75(file)) {
|
|
36466
36547
|
console.error(`Error: VTT file not found: ${file}`);
|
|
36467
36548
|
process.exit(1);
|
|
36468
36549
|
}
|
|
@@ -36545,21 +36626,21 @@ async function configure() {
|
|
|
36545
36626
|
}
|
|
36546
36627
|
|
|
36547
36628
|
// src/commands/transcript/list.ts
|
|
36548
|
-
import { existsSync as
|
|
36549
|
-
import { join as
|
|
36629
|
+
import { existsSync as existsSync76, readdirSync as readdirSync20, statSync as statSync12 } from "fs";
|
|
36630
|
+
import { join as join92 } from "path";
|
|
36550
36631
|
function list3() {
|
|
36551
36632
|
const { vttDir } = getTranscriptConfig();
|
|
36552
|
-
if (!
|
|
36633
|
+
if (!existsSync76(vttDir)) return;
|
|
36553
36634
|
for (const entry of readdirSync20(vttDir)) {
|
|
36554
36635
|
if (!entry.endsWith(".vtt")) continue;
|
|
36555
|
-
if (statSync12(
|
|
36636
|
+
if (statSync12(join92(vttDir, entry)).isDirectory()) continue;
|
|
36556
36637
|
console.log(entry);
|
|
36557
36638
|
}
|
|
36558
36639
|
}
|
|
36559
36640
|
|
|
36560
36641
|
// src/commands/transcript/move.ts
|
|
36561
|
-
import { existsSync as
|
|
36562
|
-
import { basename as basename23, join as
|
|
36642
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync32, renameSync as renameSync2, writeFileSync as writeFileSync49 } from "fs";
|
|
36643
|
+
import { basename as basename23, join as join93 } from "path";
|
|
36563
36644
|
|
|
36564
36645
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
36565
36646
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -36569,9 +36650,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
36569
36650
|
// src/commands/transcript/move.ts
|
|
36570
36651
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
36571
36652
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
36572
|
-
const processedDir =
|
|
36653
|
+
const processedDir = join93(vttDir, "processed");
|
|
36573
36654
|
mkdirSync32(processedDir, { recursive: true });
|
|
36574
|
-
renameSync2(sourcePath,
|
|
36655
|
+
renameSync2(sourcePath, join93(processedDir, filename));
|
|
36575
36656
|
}
|
|
36576
36657
|
function move(file, options2) {
|
|
36577
36658
|
const { date, client } = options2;
|
|
@@ -36581,25 +36662,25 @@ function move(file, options2) {
|
|
|
36581
36662
|
}
|
|
36582
36663
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
36583
36664
|
const filename = basename23(file);
|
|
36584
|
-
const sourcePath =
|
|
36585
|
-
if (!
|
|
36665
|
+
const sourcePath = join93(vttDir, filename);
|
|
36666
|
+
if (!existsSync77(sourcePath)) {
|
|
36586
36667
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
36587
36668
|
process.exit(1);
|
|
36588
36669
|
}
|
|
36589
36670
|
const base = basename23(filename, ".vtt").replace(/ Transcription$/, "");
|
|
36590
36671
|
const outputName = `${date} ${base}.md`;
|
|
36591
|
-
const formattedDir =
|
|
36672
|
+
const formattedDir = join93(transcriptsDir, client);
|
|
36592
36673
|
mkdirSync32(formattedDir, { recursive: true });
|
|
36593
|
-
const formattedPath =
|
|
36674
|
+
const formattedPath = join93(formattedDir, outputName);
|
|
36594
36675
|
writeFileSync49(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
36595
36676
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
36596
|
-
const summaryPath =
|
|
36677
|
+
const summaryPath = join93(summaryDir, client, outputName);
|
|
36597
36678
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
36598
36679
|
console.log(`Summary target: ${summaryPath}`);
|
|
36599
36680
|
}
|
|
36600
36681
|
|
|
36601
36682
|
// src/commands/transcript/merge.ts
|
|
36602
|
-
import { existsSync as
|
|
36683
|
+
import { existsSync as existsSync78, writeFileSync as writeFileSync50 } from "fs";
|
|
36603
36684
|
import { basename as basename24 } from "path";
|
|
36604
36685
|
|
|
36605
36686
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -36743,7 +36824,7 @@ function widenAudience(passages) {
|
|
|
36743
36824
|
|
|
36744
36825
|
// src/commands/transcript/merge.ts
|
|
36745
36826
|
function readSource3(file) {
|
|
36746
|
-
if (!
|
|
36827
|
+
if (!existsSync78(file)) failTranscript(`VTT file not found: ${file}`);
|
|
36747
36828
|
const cues = readCleanedCues(file);
|
|
36748
36829
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
36749
36830
|
return { path: file, name: basename24(file), cues };
|
|
@@ -37207,7 +37288,7 @@ function configKeys2() {
|
|
|
37207
37288
|
}
|
|
37208
37289
|
|
|
37209
37290
|
// src/commands/verify/forbiddenStrings.ts
|
|
37210
|
-
import { existsSync as
|
|
37291
|
+
import { existsSync as existsSync79, readFileSync as readFileSync59 } from "fs";
|
|
37211
37292
|
|
|
37212
37293
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
37213
37294
|
import { minimatch as minimatch9 } from "minimatch";
|
|
@@ -37248,7 +37329,7 @@ function forbiddenStrings() {
|
|
|
37248
37329
|
const cache6 = /* @__PURE__ */ new Map();
|
|
37249
37330
|
const readJson = (file) => {
|
|
37250
37331
|
if (cache6.has(file)) return cache6.get(file);
|
|
37251
|
-
if (!
|
|
37332
|
+
if (!existsSync79(file)) {
|
|
37252
37333
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
37253
37334
|
process.exit(1);
|
|
37254
37335
|
}
|
|
@@ -37626,45 +37707,45 @@ function registerVerify(program2) {
|
|
|
37626
37707
|
|
|
37627
37708
|
// src/commands/voice/devices.ts
|
|
37628
37709
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
37629
|
-
import { join as
|
|
37710
|
+
import { join as join95 } from "path";
|
|
37630
37711
|
|
|
37631
37712
|
// src/commands/voice/shared.ts
|
|
37632
37713
|
import { homedir as homedir25 } from "os";
|
|
37633
|
-
import { dirname as
|
|
37714
|
+
import { dirname as dirname40, join as join94 } from "path";
|
|
37634
37715
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
37635
|
-
var __dirname6 =
|
|
37636
|
-
var VOICE_DIR =
|
|
37716
|
+
var __dirname6 = dirname40(fileURLToPath10(import.meta.url));
|
|
37717
|
+
var VOICE_DIR = join94(homedir25(), ".assist", "voice");
|
|
37637
37718
|
var voicePaths = {
|
|
37638
37719
|
dir: VOICE_DIR,
|
|
37639
|
-
pid:
|
|
37640
|
-
log:
|
|
37641
|
-
venv:
|
|
37642
|
-
lock:
|
|
37720
|
+
pid: join94(VOICE_DIR, "voice.pid"),
|
|
37721
|
+
log: join94(VOICE_DIR, "voice.log"),
|
|
37722
|
+
venv: join94(VOICE_DIR, ".venv"),
|
|
37723
|
+
lock: join94(VOICE_DIR, "voice.lock")
|
|
37643
37724
|
};
|
|
37644
37725
|
function getPythonDir() {
|
|
37645
|
-
return
|
|
37726
|
+
return join94(__dirname6, "commands", "voice", "python");
|
|
37646
37727
|
}
|
|
37647
37728
|
function getVenvPython() {
|
|
37648
|
-
return process.platform === "win32" ?
|
|
37729
|
+
return process.platform === "win32" ? join94(voicePaths.venv, "Scripts", "python.exe") : join94(voicePaths.venv, "bin", "python");
|
|
37649
37730
|
}
|
|
37650
37731
|
function getLockDir() {
|
|
37651
37732
|
const config = loadConfig();
|
|
37652
37733
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
37653
37734
|
}
|
|
37654
37735
|
function getLockFile() {
|
|
37655
|
-
return
|
|
37736
|
+
return join94(getLockDir(), "voice.lock");
|
|
37656
37737
|
}
|
|
37657
37738
|
|
|
37658
37739
|
// src/commands/voice/devices.ts
|
|
37659
37740
|
function devices() {
|
|
37660
|
-
const script =
|
|
37741
|
+
const script = join95(getPythonDir(), "list_devices.py");
|
|
37661
37742
|
spawnSync9(getVenvPython(), [script], { stdio: "inherit" });
|
|
37662
37743
|
}
|
|
37663
37744
|
|
|
37664
37745
|
// src/commands/voice/logs.ts
|
|
37665
|
-
import { existsSync as
|
|
37746
|
+
import { existsSync as existsSync80, readFileSync as readFileSync61 } from "fs";
|
|
37666
37747
|
function logs(options2) {
|
|
37667
|
-
if (!
|
|
37748
|
+
if (!existsSync80(voicePaths.log)) {
|
|
37668
37749
|
console.log("No voice log file found");
|
|
37669
37750
|
return;
|
|
37670
37751
|
}
|
|
@@ -37692,12 +37773,12 @@ function logs(options2) {
|
|
|
37692
37773
|
// src/commands/voice/setup.ts
|
|
37693
37774
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
37694
37775
|
import { mkdirSync as mkdirSync34 } from "fs";
|
|
37695
|
-
import { join as
|
|
37776
|
+
import { join as join97 } from "path";
|
|
37696
37777
|
|
|
37697
37778
|
// src/commands/voice/checkLockFile.ts
|
|
37698
37779
|
import { execSync as execSync66 } from "child_process";
|
|
37699
|
-
import { existsSync as
|
|
37700
|
-
import { join as
|
|
37780
|
+
import { existsSync as existsSync81, mkdirSync as mkdirSync33, readFileSync as readFileSync62, writeFileSync as writeFileSync51 } from "fs";
|
|
37781
|
+
import { join as join96 } from "path";
|
|
37701
37782
|
function isProcessAlive2(pid) {
|
|
37702
37783
|
try {
|
|
37703
37784
|
process.kill(pid, 0);
|
|
@@ -37708,7 +37789,7 @@ function isProcessAlive2(pid) {
|
|
|
37708
37789
|
}
|
|
37709
37790
|
function checkLockFile() {
|
|
37710
37791
|
const lockFile = getLockFile();
|
|
37711
|
-
if (!
|
|
37792
|
+
if (!existsSync81(lockFile)) return;
|
|
37712
37793
|
try {
|
|
37713
37794
|
const lock2 = JSON.parse(readFileSync62(lockFile, "utf8"));
|
|
37714
37795
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
@@ -37721,7 +37802,7 @@ function checkLockFile() {
|
|
|
37721
37802
|
}
|
|
37722
37803
|
}
|
|
37723
37804
|
function bootstrapVenv() {
|
|
37724
|
-
if (
|
|
37805
|
+
if (existsSync81(getVenvPython())) return;
|
|
37725
37806
|
console.log("Setting up Python environment...");
|
|
37726
37807
|
const pythonDir = getPythonDir();
|
|
37727
37808
|
execSync66(
|
|
@@ -37734,7 +37815,7 @@ function bootstrapVenv() {
|
|
|
37734
37815
|
}
|
|
37735
37816
|
function writeLockFile(pid) {
|
|
37736
37817
|
const lockFile = getLockFile();
|
|
37737
|
-
mkdirSync33(
|
|
37818
|
+
mkdirSync33(join96(lockFile, ".."), { recursive: true });
|
|
37738
37819
|
writeFileSync51(
|
|
37739
37820
|
lockFile,
|
|
37740
37821
|
JSON.stringify({
|
|
@@ -37750,7 +37831,7 @@ function setup() {
|
|
|
37750
37831
|
mkdirSync34(voicePaths.dir, { recursive: true });
|
|
37751
37832
|
bootstrapVenv();
|
|
37752
37833
|
console.log("\nDownloading models...\n");
|
|
37753
|
-
const script =
|
|
37834
|
+
const script = join97(getPythonDir(), "setup_models.py");
|
|
37754
37835
|
const result = spawnSync10(getVenvPython(), [script], {
|
|
37755
37836
|
stdio: "inherit",
|
|
37756
37837
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -37762,9 +37843,9 @@ function setup() {
|
|
|
37762
37843
|
}
|
|
37763
37844
|
|
|
37764
37845
|
// src/commands/voice/start.ts
|
|
37765
|
-
import { spawn as
|
|
37846
|
+
import { spawn as spawn9 } from "child_process";
|
|
37766
37847
|
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync52 } from "fs";
|
|
37767
|
-
import { join as
|
|
37848
|
+
import { join as join98 } from "path";
|
|
37768
37849
|
|
|
37769
37850
|
// src/commands/voice/buildDaemonEnv.ts
|
|
37770
37851
|
function buildDaemonEnv(options2) {
|
|
@@ -37777,11 +37858,11 @@ function buildDaemonEnv(options2) {
|
|
|
37777
37858
|
// src/commands/voice/start.ts
|
|
37778
37859
|
function spawnForeground(python, script, env) {
|
|
37779
37860
|
console.log("Starting voice daemon in foreground...");
|
|
37780
|
-
const child =
|
|
37861
|
+
const child = spawn9(python, [script], { stdio: "inherit", env });
|
|
37781
37862
|
child.on("exit", (code) => process.exit(code ?? 0));
|
|
37782
37863
|
}
|
|
37783
37864
|
function spawnBackground(python, script, env) {
|
|
37784
|
-
const child =
|
|
37865
|
+
const child = spawn9(python, [script], {
|
|
37785
37866
|
detached: true,
|
|
37786
37867
|
stdio: "ignore",
|
|
37787
37868
|
env
|
|
@@ -37802,7 +37883,7 @@ function start2(options2) {
|
|
|
37802
37883
|
bootstrapVenv();
|
|
37803
37884
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
37804
37885
|
const env = buildDaemonEnv({ debug });
|
|
37805
|
-
const script =
|
|
37886
|
+
const script = join98(getPythonDir(), "voice_daemon.py");
|
|
37806
37887
|
const python = getVenvPython();
|
|
37807
37888
|
if (options2.foreground) {
|
|
37808
37889
|
spawnForeground(python, script, env);
|
|
@@ -37812,7 +37893,7 @@ function start2(options2) {
|
|
|
37812
37893
|
}
|
|
37813
37894
|
|
|
37814
37895
|
// src/commands/voice/status.ts
|
|
37815
|
-
import { existsSync as
|
|
37896
|
+
import { existsSync as existsSync82, readFileSync as readFileSync63 } from "fs";
|
|
37816
37897
|
function isProcessAlive3(pid) {
|
|
37817
37898
|
try {
|
|
37818
37899
|
process.kill(pid, 0);
|
|
@@ -37822,12 +37903,12 @@ function isProcessAlive3(pid) {
|
|
|
37822
37903
|
}
|
|
37823
37904
|
}
|
|
37824
37905
|
function readRecentLogs(count8) {
|
|
37825
|
-
if (!
|
|
37906
|
+
if (!existsSync82(voicePaths.log)) return [];
|
|
37826
37907
|
const lines2 = readFileSync63(voicePaths.log, "utf8").trim().split("\n");
|
|
37827
37908
|
return lines2.slice(-count8);
|
|
37828
37909
|
}
|
|
37829
37910
|
function status2() {
|
|
37830
|
-
if (!
|
|
37911
|
+
if (!existsSync82(voicePaths.pid)) {
|
|
37831
37912
|
console.log("Voice daemon: not running (no PID file)");
|
|
37832
37913
|
return;
|
|
37833
37914
|
}
|
|
@@ -37850,9 +37931,9 @@ function status2() {
|
|
|
37850
37931
|
}
|
|
37851
37932
|
|
|
37852
37933
|
// src/commands/voice/stop.ts
|
|
37853
|
-
import { existsSync as
|
|
37934
|
+
import { existsSync as existsSync83, readFileSync as readFileSync64, unlinkSync as unlinkSync21 } from "fs";
|
|
37854
37935
|
function stop2() {
|
|
37855
|
-
if (!
|
|
37936
|
+
if (!existsSync83(voicePaths.pid)) {
|
|
37856
37937
|
console.log("Voice daemon is not running (no PID file)");
|
|
37857
37938
|
return;
|
|
37858
37939
|
}
|
|
@@ -37869,7 +37950,7 @@ function stop2() {
|
|
|
37869
37950
|
}
|
|
37870
37951
|
try {
|
|
37871
37952
|
const lockFile = getLockFile();
|
|
37872
|
-
if (
|
|
37953
|
+
if (existsSync83(lockFile)) unlinkSync21(lockFile);
|
|
37873
37954
|
} catch {
|
|
37874
37955
|
}
|
|
37875
37956
|
console.log("Voice daemon stopped");
|
|
@@ -37888,9 +37969,9 @@ function registerVoice(program2) {
|
|
|
37888
37969
|
}
|
|
37889
37970
|
|
|
37890
37971
|
// src/commands/watch/resolveUpstream.ts
|
|
37891
|
-
import { execFileSync as
|
|
37972
|
+
import { execFileSync as execFileSync21 } from "child_process";
|
|
37892
37973
|
function runGit3(args, cwd) {
|
|
37893
|
-
return
|
|
37974
|
+
return execFileSync21("git", args, {
|
|
37894
37975
|
encoding: "utf8",
|
|
37895
37976
|
stdio: ["pipe", "pipe", "pipe"],
|
|
37896
37977
|
cwd
|
|
@@ -37933,11 +38014,11 @@ function changedPaths(from, cwd) {
|
|
|
37933
38014
|
}
|
|
37934
38015
|
|
|
37935
38016
|
// src/commands/watch/readBuiltVersion.ts
|
|
37936
|
-
import { join as
|
|
38017
|
+
import { join as join99 } from "path";
|
|
37937
38018
|
function readBuiltVersion(cwd) {
|
|
37938
38019
|
try {
|
|
37939
38020
|
const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
37940
|
-
return readPackageJson(
|
|
38021
|
+
return readPackageJson(join99(root2, "package.json")).version ?? "unknown";
|
|
37941
38022
|
} catch {
|
|
37942
38023
|
return "unknown";
|
|
37943
38024
|
}
|
|
@@ -38270,8 +38351,8 @@ function resolveParams(params, cliArgs) {
|
|
|
38270
38351
|
}
|
|
38271
38352
|
|
|
38272
38353
|
// src/commands/run/resolveRunCwd.ts
|
|
38273
|
-
import { existsSync as
|
|
38274
|
-
import { resolve as
|
|
38354
|
+
import { existsSync as existsSync84 } from "fs";
|
|
38355
|
+
import { resolve as resolve23 } from "path";
|
|
38275
38356
|
var MissingRunCwdError = class extends Error {
|
|
38276
38357
|
constructor(runName, cwd) {
|
|
38277
38358
|
super(`run config "${runName}": cwd ${cwd} does not exist`);
|
|
@@ -38282,68 +38363,11 @@ var MissingRunCwdError = class extends Error {
|
|
|
38282
38363
|
};
|
|
38283
38364
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
38284
38365
|
if (!config.cwd) return void 0;
|
|
38285
|
-
const cwd =
|
|
38286
|
-
if (!
|
|
38366
|
+
const cwd = resolve23(baseDir, config.cwd);
|
|
38367
|
+
if (!existsSync84(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
38287
38368
|
return cwd;
|
|
38288
38369
|
}
|
|
38289
38370
|
|
|
38290
|
-
// src/commands/run/runCommandToCompletion.ts
|
|
38291
|
-
import { spawn as spawn9 } from "child_process";
|
|
38292
|
-
import { existsSync as existsSync85 } from "fs";
|
|
38293
|
-
|
|
38294
|
-
// src/commands/run/resolveCommand.ts
|
|
38295
|
-
import { execFileSync as execFileSync21 } from "child_process";
|
|
38296
|
-
import { existsSync as existsSync84 } from "fs";
|
|
38297
|
-
import { dirname as dirname40, join as join99, resolve as resolve23 } from "path";
|
|
38298
|
-
function resolveCommand2(command) {
|
|
38299
|
-
if (process.platform !== "win32" || command !== "bash") return command;
|
|
38300
|
-
try {
|
|
38301
|
-
const gitPath = execFileSync21("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
38302
|
-
const gitRoot = resolve23(dirname40(gitPath), "..");
|
|
38303
|
-
const gitBash = join99(gitRoot, "bin", "bash.exe");
|
|
38304
|
-
if (existsSync84(gitBash)) return gitBash;
|
|
38305
|
-
} catch {
|
|
38306
|
-
return command;
|
|
38307
|
-
}
|
|
38308
|
-
return command;
|
|
38309
|
-
}
|
|
38310
|
-
|
|
38311
|
-
// src/commands/run/runCommandToCompletion.ts
|
|
38312
|
-
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
38313
|
-
return new Promise((resolveResult) => {
|
|
38314
|
-
if (cwd && !existsSync85(cwd)) {
|
|
38315
|
-
resolveResult({
|
|
38316
|
-
kind: "failed",
|
|
38317
|
-
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
38318
|
-
});
|
|
38319
|
-
return;
|
|
38320
|
-
}
|
|
38321
|
-
const child = spawn9(resolveCommand2(command), args, {
|
|
38322
|
-
stdio: quiet ? "pipe" : "inherit",
|
|
38323
|
-
env: env ? { ...process.env, ...expandEnv(env) } : void 0,
|
|
38324
|
-
cwd
|
|
38325
|
-
});
|
|
38326
|
-
const chunks = [];
|
|
38327
|
-
if (quiet) {
|
|
38328
|
-
child.stdout?.on("data", (data) => chunks.push(data));
|
|
38329
|
-
child.stderr?.on("data", (data) => chunks.push(data));
|
|
38330
|
-
}
|
|
38331
|
-
child.on("close", (code) => {
|
|
38332
|
-
resolveResult({
|
|
38333
|
-
kind: "completed",
|
|
38334
|
-
exitCode: code ?? 0,
|
|
38335
|
-
output: Buffer.concat(chunks).toString()
|
|
38336
|
-
});
|
|
38337
|
-
});
|
|
38338
|
-
child.on("error", (err) => {
|
|
38339
|
-
resolveResult({
|
|
38340
|
-
kind: "failed",
|
|
38341
|
-
message: `Failed to execute command: ${err.message}`
|
|
38342
|
-
});
|
|
38343
|
-
});
|
|
38344
|
-
});
|
|
38345
|
-
}
|
|
38346
|
-
|
|
38347
38371
|
// src/commands/run/runPreCommands.ts
|
|
38348
38372
|
import { execSync as execSync67 } from "child_process";
|
|
38349
38373
|
function runPreCommands(pre, cwd) {
|
|
@@ -39015,7 +39039,7 @@ function link2() {
|
|
|
39015
39039
|
}
|
|
39016
39040
|
|
|
39017
39041
|
// src/commands/run/remove.ts
|
|
39018
|
-
import { existsSync as
|
|
39042
|
+
import { existsSync as existsSync85, unlinkSync as unlinkSync22 } from "fs";
|
|
39019
39043
|
import { join as join102 } from "path";
|
|
39020
39044
|
function findRemoveIndex() {
|
|
39021
39045
|
const idx = process.argv.indexOf("remove");
|
|
@@ -39032,7 +39056,7 @@ function parseRemoveName() {
|
|
|
39032
39056
|
}
|
|
39033
39057
|
function deleteCommandFile(name) {
|
|
39034
39058
|
const filePath = join102(".claude", "commands", `${name}.md`);
|
|
39035
|
-
if (
|
|
39059
|
+
if (existsSync85(filePath)) {
|
|
39036
39060
|
unlinkSync22(filePath);
|
|
39037
39061
|
console.log(`Deleted command file: ${filePath}`);
|
|
39038
39062
|
}
|
|
@@ -39393,12 +39417,12 @@ function toSessionRunInfo({
|
|
|
39393
39417
|
}
|
|
39394
39418
|
|
|
39395
39419
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
39396
|
-
import { existsSync as
|
|
39420
|
+
import { existsSync as existsSync86 } from "fs";
|
|
39397
39421
|
function joinRefusal(session) {
|
|
39398
39422
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
39399
39423
|
if (session.closing === true) return "the session is closing";
|
|
39400
39424
|
if (!session.cwd) return "the session has no working directory";
|
|
39401
|
-
if (!
|
|
39425
|
+
if (!existsSync86(session.cwd))
|
|
39402
39426
|
return "the session's workspace no longer exists";
|
|
39403
39427
|
return void 0;
|
|
39404
39428
|
}
|
|
@@ -39457,14 +39481,17 @@ function toSessionInfo(session) {
|
|
|
39457
39481
|
}
|
|
39458
39482
|
|
|
39459
39483
|
// src/commands/sessions/daemon/broadcastSessions.ts
|
|
39460
|
-
function broadcastSessions(sessions, clients,
|
|
39484
|
+
function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
39461
39485
|
persistLiveSessions(sessions);
|
|
39462
39486
|
const local = [...sessions.values()].map(toSessionInfo);
|
|
39463
|
-
|
|
39487
|
+
const viewers = clients.viewers();
|
|
39488
|
+
broadcast(viewers, {
|
|
39464
39489
|
type: "sessions",
|
|
39465
|
-
sessions: local.concat(
|
|
39490
|
+
sessions: local.concat(linkedSessions),
|
|
39466
39491
|
active: active?.toJSON() ?? {}
|
|
39467
39492
|
});
|
|
39493
|
+
const peers = new Set([...clients].filter((c) => !viewers.has(c)));
|
|
39494
|
+
broadcast(peers, { type: "sessions", sessions: local, active: {} });
|
|
39468
39495
|
}
|
|
39469
39496
|
|
|
39470
39497
|
// src/shared/activeWindows.ts
|
|
@@ -39518,6 +39545,7 @@ var ClientHub = class extends Set {
|
|
|
39518
39545
|
harnessLimits = /* @__PURE__ */ new Map();
|
|
39519
39546
|
// why: log delivery is opt-in so browser tabs aren't spammed; only connections that ask via subscribe-logs receive daemonLog lines.
|
|
39520
39547
|
logSubscribers = /* @__PURE__ */ new Set();
|
|
39548
|
+
peers = /* @__PURE__ */ new Set();
|
|
39521
39549
|
updateLimits(rateLimits) {
|
|
39522
39550
|
this.latestLimits = rateLimits;
|
|
39523
39551
|
broadcast(this, { type: "limits", rateLimits });
|
|
@@ -39544,9 +39572,18 @@ var ClientHub = class extends Set {
|
|
|
39544
39572
|
for (const [harness, rateLimits] of this.harnessLimits)
|
|
39545
39573
|
sendTo(client, { type: "limits", harness, rateLimits });
|
|
39546
39574
|
}
|
|
39575
|
+
markPeer(client) {
|
|
39576
|
+
this.peers.add(client);
|
|
39577
|
+
}
|
|
39578
|
+
isPeer(client) {
|
|
39579
|
+
return this.peers.has(client);
|
|
39580
|
+
}
|
|
39581
|
+
viewers() {
|
|
39582
|
+
return new Set([...this].filter((client) => !this.peers.has(client)));
|
|
39583
|
+
}
|
|
39547
39584
|
subscribeLogs(client, replay = true) {
|
|
39548
39585
|
if (replay) {
|
|
39549
|
-
for (const line of recentDaemonLogLines()) {
|
|
39586
|
+
for (const line of recentDaemonLogLines(!this.isPeer(client))) {
|
|
39550
39587
|
sendTo(client, { type: "log", line });
|
|
39551
39588
|
}
|
|
39552
39589
|
}
|
|
@@ -39554,10 +39591,12 @@ var ClientHub = class extends Set {
|
|
|
39554
39591
|
}
|
|
39555
39592
|
unsubscribeLogs(client) {
|
|
39556
39593
|
this.logSubscribers.delete(client);
|
|
39594
|
+
this.peers.delete(client);
|
|
39557
39595
|
}
|
|
39558
39596
|
// why: bound so it can be handed to setDaemonLogSink as a bare reference.
|
|
39559
|
-
emitLog = (line) => {
|
|
39597
|
+
emitLog = (line, relayed = false) => {
|
|
39560
39598
|
for (const client of this.logSubscribers) {
|
|
39599
|
+
if (relayed && this.isPeer(client)) continue;
|
|
39561
39600
|
sendTo(client, { type: "log", line });
|
|
39562
39601
|
}
|
|
39563
39602
|
};
|
|
@@ -39583,11 +39622,11 @@ function sessionBase(id, status3) {
|
|
|
39583
39622
|
}
|
|
39584
39623
|
|
|
39585
39624
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
39586
|
-
import { existsSync as
|
|
39625
|
+
import { existsSync as existsSync88 } from "fs";
|
|
39587
39626
|
import * as pty from "node-pty";
|
|
39588
39627
|
|
|
39589
39628
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
39590
|
-
import { chmodSync, existsSync as
|
|
39629
|
+
import { chmodSync, existsSync as existsSync87, statSync as statSync14 } from "fs";
|
|
39591
39630
|
import { createRequire as createRequire3 } from "module";
|
|
39592
39631
|
import path99 from "path";
|
|
39593
39632
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -39602,7 +39641,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
39602
39641
|
`${process.platform}-${process.arch}`,
|
|
39603
39642
|
"spawn-helper"
|
|
39604
39643
|
);
|
|
39605
|
-
if (!
|
|
39644
|
+
if (!existsSync87(helper)) return;
|
|
39606
39645
|
const mode = statSync14(helper).mode;
|
|
39607
39646
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
39608
39647
|
}
|
|
@@ -39638,7 +39677,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
39638
39677
|
});
|
|
39639
39678
|
}
|
|
39640
39679
|
function refuseMissingCwd(cwd, sessionId) {
|
|
39641
|
-
if (!cwd ||
|
|
39680
|
+
if (!cwd || existsSync88(cwd)) return;
|
|
39642
39681
|
daemonLog(
|
|
39643
39682
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
39644
39683
|
);
|
|
@@ -39831,11 +39870,11 @@ function setStatus2(session, newStatus) {
|
|
|
39831
39870
|
}
|
|
39832
39871
|
|
|
39833
39872
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
39834
|
-
import { existsSync as
|
|
39873
|
+
import { existsSync as existsSync90 } from "fs";
|
|
39835
39874
|
import { basename as basename26 } from "path";
|
|
39836
39875
|
|
|
39837
39876
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
39838
|
-
import { existsSync as
|
|
39877
|
+
import { existsSync as existsSync89 } from "fs";
|
|
39839
39878
|
import { join as join105 } from "path";
|
|
39840
39879
|
|
|
39841
39880
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
@@ -39905,7 +39944,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
39905
39944
|
);
|
|
39906
39945
|
}
|
|
39907
39946
|
function strandedReason(worktreePath, cause) {
|
|
39908
|
-
if (!
|
|
39947
|
+
if (!existsSync89(join105(worktreePath, ".git")))
|
|
39909
39948
|
return "its .git link is already gone";
|
|
39910
39949
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
39911
39950
|
return "git no longer recognises it as a working tree";
|
|
@@ -39957,7 +39996,7 @@ function reason3(error) {
|
|
|
39957
39996
|
|
|
39958
39997
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
39959
39998
|
async function reapWorktree(worktreePath, force = false) {
|
|
39960
|
-
if (!
|
|
39999
|
+
if (!existsSync90(worktreePath)) {
|
|
39961
40000
|
forgetWorktree(worktreePath);
|
|
39962
40001
|
daemonLog(
|
|
39963
40002
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -39982,7 +40021,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
39982
40021
|
}
|
|
39983
40022
|
function owningClone(worktreePath) {
|
|
39984
40023
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
39985
|
-
if (recorded &&
|
|
40024
|
+
if (recorded && existsSync90(recorded)) return recorded;
|
|
39986
40025
|
const detected = mainWorktree(worktreePath);
|
|
39987
40026
|
if (detected) return detected;
|
|
39988
40027
|
daemonLog(
|
|
@@ -40149,12 +40188,12 @@ function closeGateApplies(sessions, session) {
|
|
|
40149
40188
|
}
|
|
40150
40189
|
|
|
40151
40190
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
40152
|
-
import { existsSync as
|
|
40191
|
+
import { existsSync as existsSync91, watch } from "fs";
|
|
40153
40192
|
var DEBOUNCE_MS = 500;
|
|
40154
40193
|
var POLL_MS = 3e4;
|
|
40155
40194
|
function watchGitState(cwd, onChange) {
|
|
40156
40195
|
const common = gitCommonDir(cwd);
|
|
40157
|
-
if (!common || !
|
|
40196
|
+
if (!common || !existsSync91(common)) return void 0;
|
|
40158
40197
|
const watchers = [
|
|
40159
40198
|
watchGitDir(common, onChange),
|
|
40160
40199
|
pollGitState(cwd, onChange)
|
|
@@ -40358,10 +40397,10 @@ function replayScrollback(sessions, client) {
|
|
|
40358
40397
|
}
|
|
40359
40398
|
|
|
40360
40399
|
// src/commands/sessions/daemon/greetClient.ts
|
|
40361
|
-
function greetClient(client, sessions,
|
|
40400
|
+
function greetClient(client, sessions, links2) {
|
|
40362
40401
|
replayScrollback(sessions, client);
|
|
40363
|
-
|
|
40364
|
-
|
|
40402
|
+
links2.replayScrollback(client);
|
|
40403
|
+
links2.sendNodes(client);
|
|
40365
40404
|
}
|
|
40366
40405
|
|
|
40367
40406
|
// src/commands/sessions/daemon/decidePrPreview.ts
|
|
@@ -40650,10 +40689,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
40650
40689
|
}
|
|
40651
40690
|
|
|
40652
40691
|
// src/commands/sessions/daemon/exitReason.ts
|
|
40653
|
-
import { existsSync as
|
|
40692
|
+
import { existsSync as existsSync92 } from "fs";
|
|
40654
40693
|
import { resolve as resolve24 } from "path";
|
|
40655
40694
|
function exitDetail(session) {
|
|
40656
|
-
if (session.cwd && !
|
|
40695
|
+
if (session.cwd && !existsSync92(session.cwd))
|
|
40657
40696
|
return `working directory ${session.cwd} no longer exists`;
|
|
40658
40697
|
return missingRunConfigCwd(session);
|
|
40659
40698
|
}
|
|
@@ -40667,7 +40706,7 @@ function missingRunConfigCwd(session) {
|
|
|
40667
40706
|
const config = resolveRunConfig(session.runName, dir);
|
|
40668
40707
|
if (!config?.cwd) return void 0;
|
|
40669
40708
|
const configured = resolve24(runConfigBaseDirFrom(dir), config.cwd);
|
|
40670
|
-
if (
|
|
40709
|
+
if (existsSync92(configured)) return void 0;
|
|
40671
40710
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
40672
40711
|
}
|
|
40673
40712
|
|
|
@@ -40704,7 +40743,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
40704
40743
|
}
|
|
40705
40744
|
|
|
40706
40745
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
40707
|
-
import { existsSync as
|
|
40746
|
+
import { existsSync as existsSync93, mkdirSync as mkdirSync37, watch as watch2 } from "fs";
|
|
40708
40747
|
import { dirname as dirname42 } from "path";
|
|
40709
40748
|
|
|
40710
40749
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -40790,7 +40829,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
40790
40829
|
if (timer) clearTimeout(timer);
|
|
40791
40830
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
40792
40831
|
});
|
|
40793
|
-
if (
|
|
40832
|
+
if (existsSync93(path103)) read3();
|
|
40794
40833
|
}
|
|
40795
40834
|
function refreshActivity(session) {
|
|
40796
40835
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -42574,7 +42613,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
42574
42613
|
}
|
|
42575
42614
|
|
|
42576
42615
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
42577
|
-
import { existsSync as
|
|
42616
|
+
import { existsSync as existsSync96 } from "fs";
|
|
42578
42617
|
import { basename as basename28 } from "path";
|
|
42579
42618
|
|
|
42580
42619
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -42629,9 +42668,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
42629
42668
|
}
|
|
42630
42669
|
|
|
42631
42670
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
42632
|
-
import { existsSync as
|
|
42671
|
+
import { existsSync as existsSync95 } from "fs";
|
|
42633
42672
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
42634
|
-
if (!
|
|
42673
|
+
if (!existsSync95(clone)) {
|
|
42635
42674
|
for (const { path: path103 } of paths) forgetWorktree(path103);
|
|
42636
42675
|
daemonLog(
|
|
42637
42676
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -42797,7 +42836,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
42797
42836
|
);
|
|
42798
42837
|
continue;
|
|
42799
42838
|
}
|
|
42800
|
-
if (!
|
|
42839
|
+
if (!existsSync96(path103)) {
|
|
42801
42840
|
logVanishedTree(sessions, path103);
|
|
42802
42841
|
vanished.set(clone, [
|
|
42803
42842
|
...vanished.get(clone) ?? [],
|
|
@@ -42822,10 +42861,10 @@ function restoreAllSessions(spawner, sessions, notify2) {
|
|
|
42822
42861
|
|
|
42823
42862
|
// src/commands/sessions/daemon/retrySession.ts
|
|
42824
42863
|
function retrySession(session, clients, onStatusChange) {
|
|
42825
|
-
const
|
|
42826
|
-
if (!
|
|
42864
|
+
const spawn11 = respawnThunk(session);
|
|
42865
|
+
if (!spawn11) return false;
|
|
42827
42866
|
const respawn = () => {
|
|
42828
|
-
respawnSession(session,
|
|
42867
|
+
respawnSession(session, spawn11, "running", clients, onStatusChange);
|
|
42829
42868
|
daemonLog(`session ${session.id} retried: ${session.name}`);
|
|
42830
42869
|
};
|
|
42831
42870
|
const pty2 = session.pty;
|
|
@@ -43307,273 +43346,118 @@ var VerifyTracker = class {
|
|
|
43307
43346
|
}
|
|
43308
43347
|
};
|
|
43309
43348
|
|
|
43310
|
-
// src/commands/sessions/daemon/
|
|
43311
|
-
import
|
|
43312
|
-
|
|
43313
|
-
|
|
43314
|
-
|
|
43315
|
-
|
|
43316
|
-
|
|
43317
|
-
return loadConfig().sessions?.windowsDaemonPort ?? DEFAULT_PORT;
|
|
43349
|
+
// src/commands/sessions/daemon/links/connectLinkWebSocket.ts
|
|
43350
|
+
import WebSocket from "ws";
|
|
43351
|
+
var HANDSHAKE_TIMEOUT_MS = 5e3;
|
|
43352
|
+
function linkWebSocketUrl(url) {
|
|
43353
|
+
const target = new URL("/ws", url);
|
|
43354
|
+
target.protocol = target.protocol === "https:" ? "wss:" : "ws:";
|
|
43355
|
+
return target.toString();
|
|
43318
43356
|
}
|
|
43319
|
-
function
|
|
43320
|
-
return loadConfig().sessions?.windowsDaemonHost ?? DEFAULT_HOST;
|
|
43321
|
-
}
|
|
43322
|
-
|
|
43323
|
-
// src/commands/sessions/daemon/connectToWindowsDaemon.ts
|
|
43324
|
-
var CONNECT_TIMEOUT_MS = 2e3;
|
|
43325
|
-
var KEEPALIVE_PROBE_MS = 1e4;
|
|
43326
|
-
function connectToWindowsDaemon() {
|
|
43357
|
+
function connectLinkWebSocket(url, handlers) {
|
|
43327
43358
|
return new Promise((resolve25, reject) => {
|
|
43328
|
-
const
|
|
43329
|
-
|
|
43330
|
-
|
|
43331
|
-
|
|
43332
|
-
|
|
43359
|
+
const ws = new WebSocket(linkWebSocketUrl(url), {
|
|
43360
|
+
handshakeTimeout: HANDSHAKE_TIMEOUT_MS
|
|
43361
|
+
});
|
|
43362
|
+
let open = false;
|
|
43363
|
+
ws.on("open", () => {
|
|
43364
|
+
open = true;
|
|
43365
|
+
resolve25({
|
|
43366
|
+
send: (line) => {
|
|
43367
|
+
if (ws.readyState !== WebSocket.OPEN) return false;
|
|
43368
|
+
ws.send(line);
|
|
43369
|
+
return true;
|
|
43370
|
+
},
|
|
43371
|
+
close: () => ws.close()
|
|
43372
|
+
});
|
|
43333
43373
|
});
|
|
43334
|
-
|
|
43335
|
-
|
|
43336
|
-
|
|
43337
|
-
|
|
43374
|
+
ws.on("message", (data) => handlers.onLine(data.toString()));
|
|
43375
|
+
ws.on("error", (error) => {
|
|
43376
|
+
if (!open) reject(error);
|
|
43377
|
+
});
|
|
43378
|
+
ws.on("close", (code, reason4) => {
|
|
43379
|
+
const detail = `code ${code}${reason4.length ? ` ${reason4.toString()}` : ""}`;
|
|
43380
|
+
if (open) handlers.onClose(detail);
|
|
43381
|
+
else reject(new Error(`closed before open (${detail})`));
|
|
43338
43382
|
});
|
|
43339
|
-
socket.once("error", reject);
|
|
43340
43383
|
});
|
|
43341
43384
|
}
|
|
43342
|
-
async function isWindowsDaemonRunning() {
|
|
43343
|
-
try {
|
|
43344
|
-
(await connectToWindowsDaemon()).destroy();
|
|
43345
|
-
return true;
|
|
43346
|
-
} catch {
|
|
43347
|
-
return false;
|
|
43348
|
-
}
|
|
43349
|
-
}
|
|
43350
|
-
|
|
43351
|
-
// src/commands/sessions/daemon/ensureWindowsDaemonRunning.ts
|
|
43352
|
-
import { spawn as spawn11 } from "child_process";
|
|
43353
43385
|
|
|
43354
|
-
// src/commands/sessions/daemon/
|
|
43355
|
-
|
|
43356
|
-
function
|
|
43357
|
-
|
|
43358
|
-
|
|
43359
|
-
|
|
43360
|
-
daemonLog(`[${label2}] ${line}`);
|
|
43361
|
-
onLine?.(line);
|
|
43362
|
-
});
|
|
43363
|
-
lines2.on("error", () => {
|
|
43386
|
+
// src/commands/sessions/daemon/links/selfUpdatePeer.ts
|
|
43387
|
+
var SELF_UPDATE_TIMEOUT_MS = 10 * 6e4;
|
|
43388
|
+
async function selfUpdatePeer(url) {
|
|
43389
|
+
const response = await fetch(new URL("/api/self-update", url), {
|
|
43390
|
+
method: "POST",
|
|
43391
|
+
signal: AbortSignal.timeout(SELF_UPDATE_TIMEOUT_MS)
|
|
43364
43392
|
});
|
|
43393
|
+
if (response.ok) return;
|
|
43394
|
+
const body = await response.json().catch(() => ({}));
|
|
43395
|
+
throw new Error(body.error ?? `self-update responded ${response.status}`);
|
|
43365
43396
|
}
|
|
43366
43397
|
|
|
43367
|
-
// src/commands/sessions/daemon/
|
|
43368
|
-
|
|
43369
|
-
|
|
43370
|
-
|
|
43371
|
-
|
|
43372
|
-
|
|
43373
|
-
|
|
43374
|
-
|
|
43375
|
-
var SPAWN_TIMEOUT_MS2 = 3e4;
|
|
43376
|
-
var RETRY_DELAY_MS3 = 300;
|
|
43377
|
-
async function ensureWindowsDaemonRunning() {
|
|
43378
|
-
if (await isWindowsDaemonRunning()) {
|
|
43379
|
-
daemonLog("windows daemon: already running");
|
|
43380
|
-
return;
|
|
43381
|
-
}
|
|
43382
|
-
daemonLog("windows daemon: not running, launching via pwsh.exe");
|
|
43383
|
-
await waitForWindowsDaemon(launchWindowsDaemon());
|
|
43384
|
-
}
|
|
43385
|
-
function launchWindowsDaemon() {
|
|
43386
|
-
const child = spawn11("pwsh.exe", ["-Command", "assist daemon run"], {
|
|
43387
|
-
detached: true,
|
|
43388
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
43389
|
-
});
|
|
43390
|
-
let cause = null;
|
|
43391
|
-
const watchForFailure = (line) => {
|
|
43392
|
-
cause ??= windowsBridgeFailureCause(line);
|
|
43398
|
+
// src/commands/sessions/daemon/links/linkDeps.ts
|
|
43399
|
+
function linkDeps(options2, callbacks) {
|
|
43400
|
+
return {
|
|
43401
|
+
...callbacks,
|
|
43402
|
+
transport: options2.transport ?? connectLinkWebSocket,
|
|
43403
|
+
heal: options2.heal ?? selfUpdatePeer,
|
|
43404
|
+
reconnectMs: options2.reconnectMs ?? 3e3,
|
|
43405
|
+
createTimeoutMs: options2.createTimeoutMs ?? 15e3
|
|
43393
43406
|
};
|
|
43394
|
-
logChildStream(child.stdout, "windows daemon run", watchForFailure);
|
|
43395
|
-
logChildStream(child.stderr, "windows daemon run", watchForFailure);
|
|
43396
|
-
child.on("error", (e) => {
|
|
43397
|
-
daemonLog(`failed to launch windows daemon: ${e.message}`);
|
|
43398
|
-
cause ??= `could not launch pwsh.exe: ${e.message}`;
|
|
43399
|
-
});
|
|
43400
|
-
child.on("exit", (code) => {
|
|
43401
|
-
if (code !== 0)
|
|
43402
|
-
daemonLog(`windows daemon launch exited early with code ${code}`);
|
|
43403
|
-
});
|
|
43404
|
-
child.unref();
|
|
43405
|
-
return { failureCause: () => cause };
|
|
43406
|
-
}
|
|
43407
|
-
async function waitForWindowsDaemon(launch) {
|
|
43408
|
-
const start3 = Date.now();
|
|
43409
|
-
const deadline = start3 + SPAWN_TIMEOUT_MS2;
|
|
43410
|
-
let attempts = 0;
|
|
43411
|
-
while (Date.now() < deadline) {
|
|
43412
|
-
await delay2(RETRY_DELAY_MS3);
|
|
43413
|
-
attempts++;
|
|
43414
|
-
if (await isWindowsDaemonRunning()) {
|
|
43415
|
-
daemonLog(
|
|
43416
|
-
`windows daemon: up after ${Date.now() - start3}ms (${attempts} attempts)`
|
|
43417
|
-
);
|
|
43418
|
-
return;
|
|
43419
|
-
}
|
|
43420
|
-
const cause = launch.failureCause();
|
|
43421
|
-
if (cause) {
|
|
43422
|
-
daemonLog(
|
|
43423
|
-
`windows daemon: launch failed after ${attempts} attempts: ${cause}`
|
|
43424
|
-
);
|
|
43425
|
-
throw new Error(`Windows daemon failed to start: ${cause}`);
|
|
43426
|
-
}
|
|
43427
|
-
}
|
|
43428
|
-
daemonLog(
|
|
43429
|
-
`windows daemon: did NOT start within ${SPAWN_TIMEOUT_MS2}ms (${attempts} attempts)`
|
|
43430
|
-
);
|
|
43431
|
-
throw new Error(
|
|
43432
|
-
"Windows daemon did not start; is assist installed on the Windows host?"
|
|
43433
|
-
);
|
|
43434
|
-
}
|
|
43435
|
-
function delay2(ms) {
|
|
43436
|
-
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
43437
|
-
}
|
|
43438
|
-
|
|
43439
|
-
// src/commands/sessions/daemon/defaultConnect.ts
|
|
43440
|
-
async function defaultConnect() {
|
|
43441
|
-
await ensureWindowsDaemonRunning();
|
|
43442
|
-
return connectToWindowsDaemon();
|
|
43443
43407
|
}
|
|
43444
43408
|
|
|
43445
|
-
// src/commands/sessions/daemon/
|
|
43446
|
-
|
|
43447
|
-
|
|
43448
|
-
|
|
43449
|
-
|
|
43450
|
-
|
|
43451
|
-
try {
|
|
43452
|
-
if (!existsSync98(sessionsFile)) return false;
|
|
43453
|
-
const data = JSON.parse(readFileSync68(sessionsFile, "utf8"));
|
|
43454
|
-
return Array.isArray(data) && data.length > 0;
|
|
43455
|
-
} catch (error) {
|
|
43456
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
43457
|
-
daemonLog(
|
|
43458
|
-
`windows proxy: could not read windows sessions.json: ${message3}`
|
|
43459
|
-
);
|
|
43460
|
-
return false;
|
|
43409
|
+
// src/commands/sessions/daemon/LaunchCircuitBreaker.ts
|
|
43410
|
+
var MAX_FAILURES = 3;
|
|
43411
|
+
var BACKOFF_MS = 6e4;
|
|
43412
|
+
var LaunchCircuitBreaker = class {
|
|
43413
|
+
constructor(label2) {
|
|
43414
|
+
this.label = label2;
|
|
43461
43415
|
}
|
|
43462
|
-
|
|
43463
|
-
|
|
43464
|
-
|
|
43465
|
-
|
|
43466
|
-
|
|
43467
|
-
}
|
|
43468
|
-
|
|
43469
|
-
// src/commands/sessions/daemon/discoverWindowsSessions.ts
|
|
43470
|
-
async function discoverWindowsSessions(conn) {
|
|
43471
|
-
if (conn.connected) return;
|
|
43472
|
-
if (await isWindowsDaemonRunning()) {
|
|
43473
|
-
daemonLog("windows proxy: discovering sessions on running windows daemon");
|
|
43474
|
-
} else if (hasPersistedWindowsSessions()) {
|
|
43475
|
-
daemonLog(
|
|
43476
|
-
"windows proxy: launching windows daemon to restore persisted sessions"
|
|
43477
|
-
);
|
|
43478
|
-
} else {
|
|
43479
|
-
return;
|
|
43416
|
+
failures = 0;
|
|
43417
|
+
until = 0;
|
|
43418
|
+
lastCause = "";
|
|
43419
|
+
tripped() {
|
|
43420
|
+
return this.failures >= MAX_FAILURES && Date.now() < this.until;
|
|
43480
43421
|
}
|
|
43481
|
-
|
|
43482
|
-
|
|
43483
|
-
} catch (error) {
|
|
43484
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
43485
|
-
daemonLog(`windows proxy: discovery failed: ${message3}`);
|
|
43422
|
+
remainingMs() {
|
|
43423
|
+
return Math.max(this.until - Date.now(), 0);
|
|
43486
43424
|
}
|
|
43487
|
-
|
|
43488
|
-
|
|
43489
|
-
|
|
43490
|
-
|
|
43491
|
-
function toWindowsSessionId(id) {
|
|
43492
|
-
return isWindowsSessionId(id) ? id : `${PREFIX}${id}`;
|
|
43493
|
-
}
|
|
43494
|
-
function isWindowsSessionId(id) {
|
|
43495
|
-
return id.startsWith(PREFIX);
|
|
43496
|
-
}
|
|
43497
|
-
function stripWindowsSessionId(id) {
|
|
43498
|
-
let stripped = id;
|
|
43499
|
-
while (stripped.startsWith(PREFIX)) stripped = stripped.slice(PREFIX.length);
|
|
43500
|
-
return stripped;
|
|
43501
|
-
}
|
|
43502
|
-
|
|
43503
|
-
// src/commands/sessions/daemon/forwardWindowsCreate.ts
|
|
43504
|
-
async function forwardWindowsCreate(conn, state, client, data) {
|
|
43505
|
-
daemonLog(`windows proxy: routing ${data.type} (cwd=${data.cwd})`);
|
|
43506
|
-
try {
|
|
43507
|
-
await conn.ensure();
|
|
43508
|
-
daemonLog("windows proxy: connection ready, forwarding create");
|
|
43509
|
-
const timer = setTimeout(() => {
|
|
43510
|
-
const index3 = state.pendingCreators.findIndex((p) => p.timer === timer);
|
|
43511
|
-
if (index3 === -1) return;
|
|
43512
|
-
state.pendingCreators.splice(index3, 1);
|
|
43513
|
-
daemonLog(`windows proxy: create timed out (cwd=${data.cwd})`);
|
|
43514
|
-
sendTo(client, {
|
|
43515
|
-
type: "error",
|
|
43516
|
-
message: "Windows session did not start: the Windows daemon did not respond."
|
|
43517
|
-
});
|
|
43518
|
-
}, state.createTimeoutMs);
|
|
43519
|
-
timer.unref?.();
|
|
43520
|
-
state.pendingCreators.push({ client, timer });
|
|
43521
|
-
conn.write(stripOutboundSessionId(data));
|
|
43522
|
-
} catch (error) {
|
|
43523
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
43524
|
-
daemonLog(`windows proxy: forwardCreate failed: ${message3}`);
|
|
43525
|
-
sendTo(client, {
|
|
43526
|
-
type: "error",
|
|
43527
|
-
message: `Windows session unavailable: ${message3}`
|
|
43528
|
-
});
|
|
43425
|
+
reason() {
|
|
43426
|
+
const secs = Math.ceil(this.remainingMs() / 1e3);
|
|
43427
|
+
const summary = `${this.failures} times in a row; not retrying for ${secs}s`;
|
|
43428
|
+
return this.lastCause ? `${this.lastCause} (failed ${summary})` : `${this.label} failed ${summary}`;
|
|
43529
43429
|
}
|
|
43530
|
-
|
|
43531
|
-
|
|
43532
|
-
|
|
43533
|
-
|
|
43534
|
-
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
function logWindowsForward(delivered, type, sessionId) {
|
|
43541
|
-
if (!delivered)
|
|
43430
|
+
clear() {
|
|
43431
|
+
this.failures = 0;
|
|
43432
|
+
this.until = 0;
|
|
43433
|
+
this.lastCause = "";
|
|
43434
|
+
}
|
|
43435
|
+
fail(cause) {
|
|
43436
|
+
this.failures++;
|
|
43437
|
+
this.lastCause = cause;
|
|
43438
|
+
if (this.failures < MAX_FAILURES) return;
|
|
43439
|
+
this.until = Date.now() + BACKOFF_MS;
|
|
43542
43440
|
daemonLog(
|
|
43543
|
-
|
|
43441
|
+
`${this.label}: ${this.failures} consecutive failures; backing off ${BACKOFF_MS / 1e3}s; last error: ${cause}`
|
|
43544
43442
|
);
|
|
43545
|
-
|
|
43546
|
-
|
|
43547
|
-
}
|
|
43548
|
-
|
|
43549
|
-
// src/commands/sessions/daemon/forwardWindowsIo.ts
|
|
43550
|
-
function forwardWindowsIo(conn, data) {
|
|
43551
|
-
const sessionId = stripWindowsSessionId(data.sessionId);
|
|
43552
|
-
const delivered = conn.trySend({ ...data, sessionId });
|
|
43553
|
-
logWindowsForward(delivered, data.type, data.sessionId);
|
|
43554
|
-
}
|
|
43443
|
+
}
|
|
43444
|
+
};
|
|
43555
43445
|
|
|
43556
|
-
// src/commands/sessions/daemon/
|
|
43446
|
+
// src/commands/sessions/daemon/links/LinkRelayState.ts
|
|
43557
43447
|
var MAX_SCROLLBACK2 = 256 * 1024;
|
|
43558
|
-
|
|
43559
|
-
function createState(broadcast2, onSessionsChanged, onVersionMismatch, onVersionOk = () => {
|
|
43560
|
-
}, createTimeoutMs = DEFAULT_CREATE_TIMEOUT_MS) {
|
|
43448
|
+
function createRelayState(node, viewers, onSessionsChanged) {
|
|
43561
43449
|
return {
|
|
43562
|
-
|
|
43450
|
+
node,
|
|
43451
|
+
sessions: [],
|
|
43563
43452
|
scrollback: /* @__PURE__ */ new Map(),
|
|
43564
43453
|
pendingCreators: [],
|
|
43565
|
-
|
|
43566
|
-
|
|
43567
|
-
onSessionsChanged
|
|
43568
|
-
onVersionMismatch,
|
|
43569
|
-
onVersionOk
|
|
43454
|
+
historyWaiters: [],
|
|
43455
|
+
viewers,
|
|
43456
|
+
onSessionsChanged
|
|
43570
43457
|
};
|
|
43571
43458
|
}
|
|
43572
|
-
function
|
|
43573
|
-
state.
|
|
43574
|
-
state.scrollback.clear();
|
|
43575
|
-
for (const { timer } of state.pendingCreators) clearTimeout(timer);
|
|
43576
|
-
state.pendingCreators = [];
|
|
43459
|
+
function broadcastToViewers(state, msg) {
|
|
43460
|
+
broadcast(state.viewers(), msg);
|
|
43577
43461
|
}
|
|
43578
43462
|
function takePendingCreator(state) {
|
|
43579
43463
|
const pending = state.pendingCreators.shift();
|
|
@@ -43588,7 +43472,15 @@ function failPendingCreators(state, message3) {
|
|
|
43588
43472
|
}
|
|
43589
43473
|
state.pendingCreators = [];
|
|
43590
43474
|
}
|
|
43591
|
-
function
|
|
43475
|
+
function resetRelayState(state, reason4) {
|
|
43476
|
+
failPendingCreators(state, reason4);
|
|
43477
|
+
for (const resolve25 of state.historyWaiters) resolve25([]);
|
|
43478
|
+
state.historyWaiters = [];
|
|
43479
|
+
state.sessions = [];
|
|
43480
|
+
state.lastSnapshot = void 0;
|
|
43481
|
+
state.scrollback.clear();
|
|
43482
|
+
}
|
|
43483
|
+
function replayLinkScrollback(state, client) {
|
|
43592
43484
|
for (const [sessionId, data] of state.scrollback)
|
|
43593
43485
|
if (data)
|
|
43594
43486
|
sendTo(client, {
|
|
@@ -43605,332 +43497,220 @@ function appendScrollback(state, sessionId, data) {
|
|
|
43605
43497
|
);
|
|
43606
43498
|
}
|
|
43607
43499
|
|
|
43608
|
-
// src/commands/sessions/daemon/
|
|
43609
|
-
function
|
|
43610
|
-
|
|
43611
|
-
|
|
43612
|
-
|
|
43613
|
-
|
|
43614
|
-
|
|
43615
|
-
|
|
43616
|
-
|
|
43617
|
-
|
|
43500
|
+
// src/commands/sessions/daemon/links/createLinkContext.ts
|
|
43501
|
+
function createLinkContext(spec, deps2) {
|
|
43502
|
+
return {
|
|
43503
|
+
spec,
|
|
43504
|
+
deps: deps2,
|
|
43505
|
+
relay: createRelayState(spec.name, deps2.viewers, deps2.onSessionsChanged),
|
|
43506
|
+
breaker: new LaunchCircuitBreaker(`link ${spec.name} ws`),
|
|
43507
|
+
socket: null,
|
|
43508
|
+
greeted: false,
|
|
43509
|
+
state: "disconnected",
|
|
43510
|
+
disposed: false,
|
|
43511
|
+
connect: () => {
|
|
43512
|
+
},
|
|
43513
|
+
onMismatch: () => {
|
|
43514
|
+
},
|
|
43515
|
+
onCompatible: () => {
|
|
43516
|
+
}
|
|
43517
|
+
};
|
|
43618
43518
|
}
|
|
43619
43519
|
|
|
43620
|
-
// src/commands/sessions/daemon/
|
|
43621
|
-
function
|
|
43622
|
-
return
|
|
43520
|
+
// src/commands/sessions/daemon/links/describeLink.ts
|
|
43521
|
+
function describeLink(ctx) {
|
|
43522
|
+
return {
|
|
43523
|
+
name: ctx.spec.name,
|
|
43524
|
+
url: ctx.spec.url,
|
|
43525
|
+
state: ctx.state,
|
|
43526
|
+
error: ctx.blockedMessage ?? ctx.lastError?.message,
|
|
43527
|
+
errorAt: ctx.lastError?.at,
|
|
43528
|
+
peerVersion: ctx.peer?.version,
|
|
43529
|
+
peerProtocol: ctx.peer?.protocol
|
|
43530
|
+
};
|
|
43623
43531
|
}
|
|
43624
|
-
|
|
43625
|
-
|
|
43626
|
-
|
|
43627
|
-
|
|
43628
|
-
if (helloCompatible(msg)) {
|
|
43629
|
-
state.onVersionOk();
|
|
43630
|
-
return;
|
|
43631
|
-
}
|
|
43632
|
-
const mode = windowsVersionCheck();
|
|
43633
|
-
const mismatch = `windows daemon ${helloMismatchKind(msg)} mismatch`;
|
|
43634
|
-
const detail = `protocol ${msg.protocol ?? "legacy"} version ${msg.version} (wsl protocol ${PROTOCOL_VERSION} version ${ASSIST_VERSION})`;
|
|
43635
|
-
if (mode === "off") {
|
|
43636
|
-
daemonLog(
|
|
43637
|
-
`${mismatch}: ${detail}; check disabled (sessions.windowsVersionCheck=off), proceeding`
|
|
43638
|
-
);
|
|
43639
|
-
return;
|
|
43640
|
-
}
|
|
43641
|
-
if (mode === "warn") {
|
|
43642
|
-
daemonLog(
|
|
43643
|
-
`${mismatch}: ${detail}; proceeding with warning (sessions.windowsVersionCheck=warn)`
|
|
43644
|
-
);
|
|
43645
|
-
return;
|
|
43646
|
-
}
|
|
43647
|
-
daemonLog(`${mismatch}: ${detail}`);
|
|
43648
|
-
state.onVersionMismatch(msg.version);
|
|
43532
|
+
function unavailableReason(ctx) {
|
|
43533
|
+
if (ctx.blockedMessage) return ctx.blockedMessage;
|
|
43534
|
+
const detail = ctx.lastError ? `: ${ctx.lastError.message}` : "";
|
|
43535
|
+
return `${ctx.spec.name} is ${ctx.state}${detail}`;
|
|
43649
43536
|
}
|
|
43650
43537
|
|
|
43651
|
-
// src/commands/sessions/daemon/
|
|
43652
|
-
function
|
|
43653
|
-
|
|
43654
|
-
|
|
43655
|
-
|
|
43656
|
-
|
|
43657
|
-
return;
|
|
43658
|
-
}
|
|
43659
|
-
inbound[msg.type]?.(state, msg);
|
|
43660
|
-
}
|
|
43661
|
-
var inbound = {
|
|
43662
|
-
hello: handleHello,
|
|
43663
|
-
created: handleCreated,
|
|
43664
|
-
sessions: handleSessions,
|
|
43665
|
-
output: handleOutput,
|
|
43666
|
-
// why: relay the Windows daemon's own log lines into this daemon's stream (ring + subscribers) so assist.log shows both daemons; not state.broadcast — browsers must not receive log spam.
|
|
43667
|
-
log: (_state, msg) => {
|
|
43668
|
-
if (typeof msg.line === "string") relayDaemonLog(msg.line);
|
|
43669
|
-
},
|
|
43670
|
-
clear: relayWithSessionId,
|
|
43671
|
-
error: (state, msg) => {
|
|
43672
|
-
daemonLog(`windows daemon: inbound error: ${msg.message}`);
|
|
43673
|
-
state.broadcast(msg);
|
|
43674
|
-
}
|
|
43675
|
-
};
|
|
43676
|
-
function handleCreated(state, msg) {
|
|
43677
|
-
daemonLog(`windows daemon: created session ${nsId(msg)}`);
|
|
43678
|
-
const client = takePendingCreator(state);
|
|
43679
|
-
if (client)
|
|
43680
|
-
sendTo(client, {
|
|
43681
|
-
type: "created",
|
|
43682
|
-
sessionId: nsId(msg),
|
|
43683
|
-
isNew: msg.isNew
|
|
43684
|
-
});
|
|
43685
|
-
else daemonLog("windows daemon: created with no pending creator (dropped)");
|
|
43538
|
+
// src/commands/sessions/daemon/links/setLinkState.ts
|
|
43539
|
+
function setLinkState(ctx, next3) {
|
|
43540
|
+
if (ctx.state === next3) return;
|
|
43541
|
+
daemonLog(`link ${ctx.spec.name} ws: state ${ctx.state} -> ${next3}`);
|
|
43542
|
+
ctx.state = next3;
|
|
43543
|
+
ctx.deps.onStateChanged();
|
|
43686
43544
|
}
|
|
43687
|
-
function
|
|
43688
|
-
|
|
43689
|
-
const data = msg.data;
|
|
43690
|
-
appendScrollback(state, sessionId, data);
|
|
43691
|
-
state.broadcast({ type: "output", sessionId, data });
|
|
43692
|
-
}
|
|
43693
|
-
function relayWithSessionId(state, msg) {
|
|
43694
|
-
state.broadcast({ ...msg, sessionId: nsId(msg) });
|
|
43695
|
-
}
|
|
43696
|
-
function nsId(msg) {
|
|
43697
|
-
return toWindowsSessionId(msg.sessionId);
|
|
43698
|
-
}
|
|
43699
|
-
|
|
43700
|
-
// src/commands/sessions/daemon/handleWindowsClose.ts
|
|
43701
|
-
function handleWindowsClose(state) {
|
|
43702
|
-
daemonLog("windows proxy: connection to windows daemon closed");
|
|
43703
|
-
failPendingCreators(state, "Windows daemon connection closed");
|
|
43704
|
-
resetState(state);
|
|
43705
|
-
state.onSessionsChanged();
|
|
43545
|
+
function sendToLink(ctx, msg) {
|
|
43546
|
+
return ctx.socket?.send(JSON.stringify(msg)) ?? false;
|
|
43706
43547
|
}
|
|
43707
43548
|
|
|
43708
|
-
// src/commands/sessions/daemon/
|
|
43709
|
-
|
|
43710
|
-
|
|
43711
|
-
|
|
43712
|
-
|
|
43713
|
-
|
|
43714
|
-
|
|
43715
|
-
await runOnWindowsHost("assist update", UPDATE_TIMEOUT_MS);
|
|
43716
|
-
} catch (error) {
|
|
43717
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
43718
|
-
daemonLog(
|
|
43719
|
-
`windows daemon: auto-heal: \`assist update\` failed: ${message3}`
|
|
43720
|
-
);
|
|
43721
|
-
throw error;
|
|
43549
|
+
// src/commands/sessions/daemon/links/toPeerMessage.ts
|
|
43550
|
+
function toPeerMessage(data) {
|
|
43551
|
+
const { node: _node, ...stripped } = data;
|
|
43552
|
+
for (const key of sessionRefKeys(data.type)) {
|
|
43553
|
+
const value = stripped[key];
|
|
43554
|
+
if (typeof value !== "string") continue;
|
|
43555
|
+
stripped[key] = splitNodeSessionId(value)?.id ?? value;
|
|
43722
43556
|
}
|
|
43723
|
-
|
|
43724
|
-
await runOnWindowsHost("assist daemon stop", STOP_TIMEOUT_MS2);
|
|
43725
|
-
daemonLog("windows daemon: auto-heal: stale daemon stopped");
|
|
43726
|
-
}
|
|
43727
|
-
function runOnWindowsHost(command, timeoutMs) {
|
|
43728
|
-
return new Promise((resolve25, reject) => {
|
|
43729
|
-
const child = spawn12("pwsh.exe", ["-Command", command], {
|
|
43730
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
43731
|
-
});
|
|
43732
|
-
logChildStream(child.stdout, `windows ${command}`);
|
|
43733
|
-
logChildStream(child.stderr, `windows ${command}`);
|
|
43734
|
-
const timer = setTimeout(() => {
|
|
43735
|
-
child.kill();
|
|
43736
|
-
reject(
|
|
43737
|
-
new Error(
|
|
43738
|
-
`'${command}' on the Windows host timed out after ${timeoutMs}ms`
|
|
43739
|
-
)
|
|
43740
|
-
);
|
|
43741
|
-
}, timeoutMs);
|
|
43742
|
-
child.on("error", (e) => {
|
|
43743
|
-
clearTimeout(timer);
|
|
43744
|
-
reject(e);
|
|
43745
|
-
});
|
|
43746
|
-
child.on("exit", (code) => {
|
|
43747
|
-
clearTimeout(timer);
|
|
43748
|
-
if (code === 0) resolve25();
|
|
43749
|
-
else
|
|
43750
|
-
reject(
|
|
43751
|
-
new Error(
|
|
43752
|
-
`'${command}' on the Windows host exited with code ${code}`
|
|
43753
|
-
)
|
|
43754
|
-
);
|
|
43755
|
-
});
|
|
43756
|
-
});
|
|
43557
|
+
return stripped;
|
|
43757
43558
|
}
|
|
43758
43559
|
|
|
43759
|
-
// src/commands/sessions/daemon/
|
|
43760
|
-
function
|
|
43761
|
-
|
|
43560
|
+
// src/commands/sessions/daemon/links/forwardLinkCreate.ts
|
|
43561
|
+
function armCreateTimeout(ctx, client, data) {
|
|
43562
|
+
const node = ctx.spec.name;
|
|
43563
|
+
const timer = setTimeout(() => {
|
|
43564
|
+
const pending = ctx.relay.pendingCreators;
|
|
43565
|
+
const index3 = pending.findIndex((p) => p.timer === timer);
|
|
43566
|
+
if (index3 === -1) return;
|
|
43567
|
+
pending.splice(index3, 1);
|
|
43568
|
+
daemonLog(`link ${node} ws: ${data.type} timed out (cwd=${data.cwd})`);
|
|
43569
|
+
sendTo(client, {
|
|
43570
|
+
type: "error",
|
|
43571
|
+
message: `Session on ${node} did not start: the peer did not respond.`
|
|
43572
|
+
});
|
|
43573
|
+
}, ctx.deps.createTimeoutMs);
|
|
43574
|
+
timer.unref?.();
|
|
43575
|
+
ctx.relay.pendingCreators.push({ client, timer });
|
|
43762
43576
|
}
|
|
43763
|
-
function
|
|
43764
|
-
|
|
43577
|
+
function forwardLinkCreate(ctx, client, data) {
|
|
43578
|
+
const node = ctx.spec.name;
|
|
43579
|
+
if (!ctx.greeted) {
|
|
43580
|
+
const reason4 = unavailableReason(ctx);
|
|
43581
|
+
daemonLog(`link ${node} ws: refusing ${data.type}: ${reason4}`);
|
|
43582
|
+
sendTo(client, {
|
|
43583
|
+
type: "error",
|
|
43584
|
+
message: `${node} unavailable: ${reason4}`
|
|
43585
|
+
});
|
|
43586
|
+
return;
|
|
43587
|
+
}
|
|
43588
|
+
daemonLog(
|
|
43589
|
+
`link ${node} ws: routing ${data.type} (cwd=${data.cwd ?? "default"})`
|
|
43590
|
+
);
|
|
43591
|
+
armCreateTimeout(ctx, client, data);
|
|
43592
|
+
sendToLink(ctx, toPeerMessage(data));
|
|
43765
43593
|
}
|
|
43766
43594
|
|
|
43767
|
-
// src/commands/sessions/daemon/
|
|
43768
|
-
|
|
43769
|
-
|
|
43770
|
-
|
|
43771
|
-
|
|
43772
|
-
|
|
43773
|
-
|
|
43774
|
-
failures = 0;
|
|
43775
|
-
until = 0;
|
|
43776
|
-
lastCause = "";
|
|
43777
|
-
tripped() {
|
|
43778
|
-
return this.failures >= MAX_FAILURES && Date.now() < this.until;
|
|
43779
|
-
}
|
|
43780
|
-
reason() {
|
|
43781
|
-
const secs = Math.ceil((this.until - Date.now()) / 1e3);
|
|
43782
|
-
const summary = `${this.failures} times in a row; not retrying for ${secs}s`;
|
|
43783
|
-
return this.lastCause ? `${this.lastCause} (failed ${summary})` : `Windows daemon failed to start ${summary}`;
|
|
43784
|
-
}
|
|
43785
|
-
clear() {
|
|
43786
|
-
this.failures = 0;
|
|
43787
|
-
this.until = 0;
|
|
43788
|
-
this.lastCause = "";
|
|
43789
|
-
}
|
|
43790
|
-
fail(cause) {
|
|
43791
|
-
this.failures++;
|
|
43792
|
-
this.lastCause = cause;
|
|
43793
|
-
if (this.failures < MAX_FAILURES) return;
|
|
43794
|
-
this.until = Date.now() + BACKOFF_MS;
|
|
43595
|
+
// src/commands/sessions/daemon/links/forwardToLink.ts
|
|
43596
|
+
function forwardToLink(ctx, client, data) {
|
|
43597
|
+
ctx.relay.lastRequester = client;
|
|
43598
|
+
if (isLinkCreate(data.type)) return forwardLinkCreate(ctx, client, data);
|
|
43599
|
+
const node = ctx.spec.name;
|
|
43600
|
+
const delivered = ctx.greeted && sendToLink(ctx, toPeerMessage(data));
|
|
43601
|
+
if (!delivered)
|
|
43795
43602
|
daemonLog(
|
|
43796
|
-
`
|
|
43603
|
+
`link ${node} ws: DROPPED ${data.type} for ${data.sessionId} (${unavailableReason(ctx)})`
|
|
43797
43604
|
);
|
|
43798
|
-
|
|
43799
|
-
};
|
|
43800
|
-
|
|
43801
|
-
// src/commands/sessions/daemon/WindowsConnection.ts
|
|
43802
|
-
var WindowsConnection = class {
|
|
43803
|
-
constructor(deps2) {
|
|
43804
|
-
this.deps = deps2;
|
|
43805
|
-
}
|
|
43806
|
-
connection = null;
|
|
43807
|
-
socket = null;
|
|
43808
|
-
// why: survives reset()/dispose() so a reconnect can't re-arm it into a loop; only a successful open clears it
|
|
43809
|
-
breaker = new LaunchCircuitBreaker();
|
|
43810
|
-
get connected() {
|
|
43811
|
-
return this.connection !== null;
|
|
43812
|
-
}
|
|
43813
|
-
ensure() {
|
|
43814
|
-
if (this.connection) return this.connection;
|
|
43815
|
-
if (this.breaker.tripped())
|
|
43816
|
-
return Promise.reject(new Error(this.breaker.reason()));
|
|
43817
|
-
const connection = this.open();
|
|
43818
|
-
this.connection = connection;
|
|
43819
|
-
connection.then(
|
|
43820
|
-
() => this.breaker.clear(),
|
|
43821
|
-
(error) => this.onOpenFailure(connection, error)
|
|
43822
|
-
);
|
|
43823
|
-
return connection;
|
|
43824
|
-
}
|
|
43825
|
-
onOpenFailure(connection, error) {
|
|
43826
|
-
if (this.connection === connection) this.connection = null;
|
|
43827
|
-
this.breaker.fail(
|
|
43828
|
-
error instanceof Error ? error.message : String(error ?? "unknown error")
|
|
43829
|
-
);
|
|
43830
|
-
}
|
|
43831
|
-
write(msg) {
|
|
43832
|
-
this.socket?.write(`${JSON.stringify(msg)}
|
|
43833
|
-
`);
|
|
43834
|
-
}
|
|
43835
|
-
trySend(msg) {
|
|
43836
|
-
if (!this.socket?.writable) return false;
|
|
43837
|
-
this.write(msg);
|
|
43838
|
-
return true;
|
|
43839
|
-
}
|
|
43840
|
-
dispose() {
|
|
43841
|
-
this.socket?.destroy();
|
|
43842
|
-
this.reset();
|
|
43843
|
-
}
|
|
43844
|
-
async open() {
|
|
43845
|
-
daemonLog("windows connection: opening (launch + tcp connect)");
|
|
43846
|
-
const socket = await this.deps.connect();
|
|
43847
|
-
daemonLog("windows connection: tcp connected, sending hello");
|
|
43848
|
-
this.socket = socket;
|
|
43849
|
-
this.wire(socket);
|
|
43850
|
-
this.write(buildHello());
|
|
43851
|
-
this.write({ type: "subscribe-logs" });
|
|
43852
|
-
return socket;
|
|
43853
|
-
}
|
|
43854
|
-
wire(socket) {
|
|
43855
|
-
const lines2 = createInterface10({ input: socket });
|
|
43856
|
-
lines2.on("error", () => {
|
|
43857
|
-
});
|
|
43858
|
-
lines2.on("line", (line) => this.deps.onLine(line));
|
|
43859
|
-
socket.on("error", () => {
|
|
43860
|
-
});
|
|
43861
|
-
socket.on("close", () => {
|
|
43862
|
-
this.reset();
|
|
43863
|
-
this.deps.onClose();
|
|
43864
|
-
});
|
|
43865
|
-
}
|
|
43866
|
-
reset() {
|
|
43867
|
-
this.socket = null;
|
|
43868
|
-
this.connection = null;
|
|
43869
|
-
}
|
|
43870
|
-
};
|
|
43605
|
+
else if (data.type !== "input")
|
|
43606
|
+
daemonLog(`link ${node} ws: forwarded ${data.type} for ${data.sessionId}`);
|
|
43607
|
+
}
|
|
43871
43608
|
|
|
43872
|
-
// src/commands/sessions/daemon/
|
|
43609
|
+
// src/commands/sessions/daemon/links/linkHealRefusal.ts
|
|
43873
43610
|
import semver2 from "semver";
|
|
43611
|
+
function peerIsNewer(peerVersion) {
|
|
43612
|
+
return semver2.valid(peerVersion) !== null && semver2.valid(ASSIST_VERSION) !== null && semver2.gt(peerVersion, ASSIST_VERSION);
|
|
43613
|
+
}
|
|
43614
|
+
function linkHealRefusal(node, peerVersion, healAttempted) {
|
|
43615
|
+
if (peerIsNewer(peerVersion))
|
|
43616
|
+
return `This node (${ASSIST_VERSION}) is older than ${node} (${peerVersion}); update this node and restart its daemon.`;
|
|
43617
|
+
if (healAttempted)
|
|
43618
|
+
return `${node} is still on ${peerVersion} after auto-update (this node is ${ASSIST_VERSION}); update ${node} manually, then restart this daemon.`;
|
|
43619
|
+
return void 0;
|
|
43620
|
+
}
|
|
43874
43621
|
|
|
43875
|
-
// src/commands/sessions/daemon/
|
|
43876
|
-
|
|
43877
|
-
|
|
43878
|
-
|
|
43622
|
+
// src/commands/sessions/daemon/links/scheduleReconnect.ts
|
|
43623
|
+
function armReconnect(ctx, delay2) {
|
|
43624
|
+
clearTimeout(ctx.reconnectTimer);
|
|
43625
|
+
ctx.reconnectTimer = setTimeout(ctx.connect, delay2);
|
|
43626
|
+
ctx.reconnectTimer.unref?.();
|
|
43627
|
+
}
|
|
43628
|
+
function scheduleReconnect2(ctx) {
|
|
43629
|
+
if (ctx.disposed || ctx.blockedMessage) return;
|
|
43630
|
+
const delay2 = ctx.breaker.tripped() ? ctx.breaker.remainingMs() : ctx.deps.reconnectMs;
|
|
43631
|
+
armReconnect(ctx, delay2);
|
|
43632
|
+
}
|
|
43633
|
+
function reconnectNow(ctx) {
|
|
43634
|
+
ctx.breaker.clear();
|
|
43635
|
+
armReconnect(ctx, ctx.deps.reconnectMs);
|
|
43636
|
+
}
|
|
43637
|
+
|
|
43638
|
+
// src/commands/sessions/daemon/links/teardownLink.ts
|
|
43639
|
+
function teardownLink(ctx) {
|
|
43640
|
+
const hadSessions = ctx.relay.sessions.length > 0;
|
|
43641
|
+
ctx.socket = null;
|
|
43642
|
+
ctx.greeted = false;
|
|
43643
|
+
resetRelayState(ctx.relay, `${ctx.spec.name} connection closed`);
|
|
43644
|
+
if (!ctx.blockedMessage) setLinkState(ctx, "disconnected");
|
|
43645
|
+
if (hadSessions) ctx.deps.onSessionsChanged();
|
|
43646
|
+
}
|
|
43647
|
+
function disconnectLink(ctx) {
|
|
43648
|
+
const socket = ctx.socket;
|
|
43649
|
+
teardownLink(ctx);
|
|
43650
|
+
socket?.close();
|
|
43651
|
+
}
|
|
43652
|
+
function failLink(ctx, message3) {
|
|
43653
|
+
daemonLog(`link ${ctx.spec.name} ws: ${message3}`);
|
|
43654
|
+
ctx.lastError = { message: message3, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
43655
|
+
ctx.breaker.fail(message3);
|
|
43656
|
+
setLinkState(ctx, ctx.blockedMessage ? "version-blocked" : "disconnected");
|
|
43657
|
+
scheduleReconnect2(ctx);
|
|
43658
|
+
}
|
|
43659
|
+
function blockLink(ctx, message3) {
|
|
43660
|
+
ctx.blockedMessage = message3;
|
|
43661
|
+
clearTimeout(ctx.reconnectTimer);
|
|
43662
|
+
disconnectLink(ctx);
|
|
43663
|
+
setLinkState(ctx, "version-blocked");
|
|
43664
|
+
broadcastToViewers(ctx.relay, { type: "error", message: message3 });
|
|
43665
|
+
}
|
|
43666
|
+
|
|
43667
|
+
// src/commands/sessions/daemon/links/runLinkHeal.ts
|
|
43668
|
+
async function runLinkHeal(ctx, peerVersion) {
|
|
43669
|
+
const node = ctx.spec.name;
|
|
43670
|
+
daemonLog(
|
|
43671
|
+
`link ${node} heal: peer ${peerVersion} is older than ${ASSIST_VERSION}; requesting self-update`
|
|
43672
|
+
);
|
|
43673
|
+
failPendingCreators(
|
|
43674
|
+
ctx.relay,
|
|
43675
|
+
`${node} is out of date; updating it now \u2014 retry once the update finishes.`
|
|
43676
|
+
);
|
|
43677
|
+
disconnectLink(ctx);
|
|
43879
43678
|
try {
|
|
43880
|
-
|
|
43881
|
-
|
|
43882
|
-
daemonLog("windows proxy: heal complete, reconnecting to windows daemon");
|
|
43883
|
-
await conn.ensure();
|
|
43679
|
+
await ctx.deps.heal(ctx.spec.url);
|
|
43680
|
+
daemonLog(`link ${node} heal: self-update done, reconnecting`);
|
|
43884
43681
|
} catch (error) {
|
|
43885
43682
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
43886
|
-
daemonLog(`
|
|
43887
|
-
|
|
43683
|
+
daemonLog(`link ${node} heal: self-update failed: ${message3}`);
|
|
43684
|
+
broadcastToViewers(ctx.relay, {
|
|
43888
43685
|
type: "error",
|
|
43889
|
-
message:
|
|
43686
|
+
message: `${node} auto-update failed: ${message3}`
|
|
43890
43687
|
});
|
|
43891
43688
|
}
|
|
43892
|
-
|
|
43893
|
-
function notifyHealing(state) {
|
|
43894
|
-
failPendingCreators(
|
|
43895
|
-
state,
|
|
43896
|
-
"Windows host is out of date; updating it now \u2014 reselect the repo once the update finishes."
|
|
43897
|
-
);
|
|
43689
|
+
reconnectNow(ctx);
|
|
43898
43690
|
}
|
|
43899
43691
|
|
|
43900
|
-
// src/commands/sessions/daemon/
|
|
43901
|
-
var
|
|
43902
|
-
|
|
43903
|
-
|
|
43904
|
-
}
|
|
43905
|
-
function windowsIsNewer(windowsVersion) {
|
|
43906
|
-
return semver2.valid(windowsVersion) !== null && semver2.valid(ASSIST_VERSION) !== null && semver2.gt(windowsVersion, ASSIST_VERSION);
|
|
43907
|
-
}
|
|
43908
|
-
var HEALED_MESSAGE = "Windows host is up to date \u2014 you can reselect the repo now.";
|
|
43909
|
-
var WindowsVersionHealer = class {
|
|
43910
|
-
constructor(conn, state, heal) {
|
|
43911
|
-
this.conn = conn;
|
|
43912
|
-
this.state = state;
|
|
43913
|
-
this.heal = heal;
|
|
43692
|
+
// src/commands/sessions/daemon/links/LinkHealer.ts
|
|
43693
|
+
var LinkHealer = class {
|
|
43694
|
+
constructor(ctx) {
|
|
43695
|
+
this.ctx = ctx;
|
|
43914
43696
|
}
|
|
43915
43697
|
healAttempted = false;
|
|
43916
43698
|
healing = false;
|
|
43917
|
-
unrecoverable = false;
|
|
43918
43699
|
awaitingConfirmation = false;
|
|
43919
|
-
|
|
43920
|
-
|
|
43921
|
-
|
|
43922
|
-
|
|
43923
|
-
|
|
43924
|
-
|
|
43925
|
-
|
|
43926
|
-
|
|
43927
|
-
|
|
43928
|
-
if (this.healAttempted) return this.giveUp(version2);
|
|
43700
|
+
async onMismatch(peerVersion) {
|
|
43701
|
+
if (this.healing) return;
|
|
43702
|
+
const node = this.ctx.spec.name;
|
|
43703
|
+
const refusal = linkHealRefusal(node, peerVersion, this.healAttempted);
|
|
43704
|
+
if (refusal) {
|
|
43705
|
+
this.awaitingConfirmation = false;
|
|
43706
|
+
daemonLog(`link ${node} heal: latched, not reconnecting: ${refusal}`);
|
|
43707
|
+
return blockLink(this.ctx, refusal);
|
|
43708
|
+
}
|
|
43929
43709
|
this.healing = true;
|
|
43930
43710
|
this.healAttempted = true;
|
|
43931
43711
|
this.awaitingConfirmation = true;
|
|
43932
43712
|
try {
|
|
43933
|
-
await
|
|
43713
|
+
await runLinkHeal(this.ctx, peerVersion);
|
|
43934
43714
|
} finally {
|
|
43935
43715
|
this.healing = false;
|
|
43936
43716
|
}
|
|
@@ -43938,78 +43718,298 @@ var WindowsVersionHealer = class {
|
|
|
43938
43718
|
onCompatible() {
|
|
43939
43719
|
if (!this.awaitingConfirmation) return;
|
|
43940
43720
|
this.awaitingConfirmation = false;
|
|
43941
|
-
|
|
43942
|
-
|
|
43943
|
-
|
|
43944
|
-
|
|
43721
|
+
const node = this.ctx.spec.name;
|
|
43722
|
+
daemonLog(`link ${node} heal: post-heal handshake compatible`);
|
|
43723
|
+
broadcastToViewers(this.ctx.relay, {
|
|
43724
|
+
type: "notice",
|
|
43725
|
+
message: `${node} is up to date.`
|
|
43726
|
+
});
|
|
43945
43727
|
}
|
|
43946
|
-
|
|
43947
|
-
|
|
43948
|
-
|
|
43949
|
-
|
|
43950
|
-
|
|
43728
|
+
};
|
|
43729
|
+
|
|
43730
|
+
// src/commands/sessions/daemon/links/linkVersionCheck.ts
|
|
43731
|
+
function linkVersionCheck() {
|
|
43732
|
+
return loadConfig().sessions?.linkVersionCheck ?? "block";
|
|
43733
|
+
}
|
|
43734
|
+
|
|
43735
|
+
// src/commands/sessions/daemon/links/acceptPeerHello.ts
|
|
43736
|
+
function acceptPeerHello(linkName, msg) {
|
|
43737
|
+
if (!isHello(msg)) return { kind: "reject", reason: "malformed hello" };
|
|
43738
|
+
const peer = { version: msg.version, protocol: msg.protocol };
|
|
43739
|
+
if (msg.nodeName && msg.nodeName !== linkName)
|
|
43740
|
+
return {
|
|
43741
|
+
kind: "reject",
|
|
43742
|
+
reason: `peer reports nodeName ${msg.nodeName}, link expects ${linkName}`,
|
|
43743
|
+
peer
|
|
43744
|
+
};
|
|
43745
|
+
if (helloCompatible(msg)) {
|
|
43746
|
+
daemonLog(`link ${linkName} ws: hello ok (${msg.version})`);
|
|
43747
|
+
return { kind: "accept", peer };
|
|
43748
|
+
}
|
|
43749
|
+
const mode = linkVersionCheck();
|
|
43750
|
+
const detail = `${helloMismatchKind(msg)} mismatch: peer protocol ${msg.protocol ?? "legacy"} version ${msg.version} (this node protocol ${PROTOCOL_VERSION} version ${ASSIST_VERSION})`;
|
|
43751
|
+
if (mode !== "block") {
|
|
43951
43752
|
daemonLog(
|
|
43952
|
-
`
|
|
43753
|
+
`link ${linkName} ws: ${detail}; proceeding (sessions.linkVersionCheck=${mode})`
|
|
43953
43754
|
);
|
|
43954
|
-
|
|
43955
|
-
this.state.broadcast(this.refusal());
|
|
43755
|
+
return { kind: "accept", peer };
|
|
43956
43756
|
}
|
|
43757
|
+
daemonLog(`link ${linkName} ws: ${detail}`);
|
|
43758
|
+
return { kind: "heal", peer };
|
|
43759
|
+
}
|
|
43760
|
+
|
|
43761
|
+
// src/commands/sessions/daemon/links/relayLinkSessions.ts
|
|
43762
|
+
function relayLinkSessions(state, msg) {
|
|
43763
|
+
const snapshot = JSON.stringify(msg.sessions ?? []);
|
|
43764
|
+
if (snapshot === state.lastSnapshot) return;
|
|
43765
|
+
state.lastSnapshot = snapshot;
|
|
43766
|
+
const ns = (id) => toNodeSessionId(state.node, id);
|
|
43767
|
+
state.sessions = (msg.sessions ?? []).map((s) => ({
|
|
43768
|
+
...s,
|
|
43769
|
+
id: ns(s.id),
|
|
43770
|
+
launchedFrom: s.launchedFrom ? ns(s.launchedFrom) : void 0,
|
|
43771
|
+
node: state.node
|
|
43772
|
+
}));
|
|
43773
|
+
const live = new Set(state.sessions.map((s) => s.id));
|
|
43774
|
+
for (const id of state.scrollback.keys())
|
|
43775
|
+
if (!live.has(id)) state.scrollback.delete(id);
|
|
43776
|
+
state.onSessionsChanged();
|
|
43777
|
+
}
|
|
43778
|
+
|
|
43779
|
+
// src/commands/sessions/daemon/links/relayRunConflict.ts
|
|
43780
|
+
function relayRunConflict(state, msg) {
|
|
43781
|
+
const ns = (id) => typeof id === "string" ? toNodeSessionId(state.node, id) : id;
|
|
43782
|
+
const existing = msg.existing;
|
|
43783
|
+
const namespaced = {
|
|
43784
|
+
...msg,
|
|
43785
|
+
sessionId: ns(msg.sessionId),
|
|
43786
|
+
existing: existing && { ...existing, id: ns(existing.id) },
|
|
43787
|
+
node: state.node
|
|
43788
|
+
};
|
|
43789
|
+
const client = takePendingCreator(state) ?? state.lastRequester;
|
|
43790
|
+
if (client) sendTo(client, namespaced);
|
|
43791
|
+
else broadcastToViewers(state, namespaced);
|
|
43792
|
+
}
|
|
43793
|
+
|
|
43794
|
+
// src/commands/sessions/daemon/links/relayLinkMessage.ts
|
|
43795
|
+
var nsId = (state, msg) => toNodeSessionId(state.node, msg.sessionId);
|
|
43796
|
+
var relayOutput = (state, msg) => {
|
|
43797
|
+
const sessionId = nsId(state, msg);
|
|
43798
|
+
appendScrollback(state, sessionId, msg.data);
|
|
43799
|
+
broadcastToViewers(state, { type: "output", sessionId, data: msg.data });
|
|
43800
|
+
};
|
|
43801
|
+
var relayToCreator = (label2) => (state, msg) => {
|
|
43802
|
+
daemonLog(
|
|
43803
|
+
`link ${state.node} ws: ${label2} ${msg.sessionId ?? msg.message}`
|
|
43804
|
+
);
|
|
43805
|
+
const client = takePendingCreator(state);
|
|
43806
|
+
const reply2 = msg.type === "created" ? { ...msg, sessionId: nsId(state, msg) } : msg;
|
|
43807
|
+
if (client) sendTo(client, reply2);
|
|
43808
|
+
else if (msg.type === "error") broadcastToViewers(state, reply2);
|
|
43809
|
+
else
|
|
43810
|
+
daemonLog(`link ${state.node} ws: ${msg.type} with no pending creator`);
|
|
43811
|
+
};
|
|
43812
|
+
var relayHistory = (state, msg) => {
|
|
43813
|
+
const sessions = msg.sessions ?? [];
|
|
43814
|
+
state.historyWaiters.shift()?.(
|
|
43815
|
+
sessions.map((s) => ({ ...s, node: state.node }))
|
|
43816
|
+
);
|
|
43957
43817
|
};
|
|
43818
|
+
var relays = {
|
|
43819
|
+
sessions: relayLinkSessions,
|
|
43820
|
+
output: relayOutput,
|
|
43821
|
+
clear: (state, msg) => broadcastToViewers(state, { ...msg, sessionId: nsId(state, msg) }),
|
|
43822
|
+
created: relayToCreator("created session"),
|
|
43823
|
+
error: relayToCreator("peer error:"),
|
|
43824
|
+
notice: (state, msg) => broadcastToViewers(state, msg),
|
|
43825
|
+
"run-conflict": relayRunConflict,
|
|
43826
|
+
history: relayHistory,
|
|
43827
|
+
log: (state, msg) => {
|
|
43828
|
+
if (typeof msg.line === "string") relayDaemonLog(state.node, msg.line);
|
|
43829
|
+
}
|
|
43830
|
+
};
|
|
43831
|
+
function relayLinkMessage(state, msg) {
|
|
43832
|
+
relays[msg.type]?.(state, msg);
|
|
43833
|
+
}
|
|
43834
|
+
|
|
43835
|
+
// src/commands/sessions/daemon/links/onLinkLine.ts
|
|
43836
|
+
function onHello(ctx, msg) {
|
|
43837
|
+
const verdict = acceptPeerHello(ctx.spec.name, msg);
|
|
43838
|
+
if (verdict.peer) ctx.peer = verdict.peer;
|
|
43839
|
+
if (verdict.kind === "reject") {
|
|
43840
|
+
disconnectLink(ctx);
|
|
43841
|
+
return failLink(ctx, verdict.reason);
|
|
43842
|
+
}
|
|
43843
|
+
if (verdict.kind === "heal") return ctx.onMismatch(verdict.peer.version);
|
|
43844
|
+
ctx.greeted = true;
|
|
43845
|
+
ctx.breaker.clear();
|
|
43846
|
+
ctx.lastError = void 0;
|
|
43847
|
+
setLinkState(ctx, "connected");
|
|
43848
|
+
ctx.onCompatible();
|
|
43849
|
+
}
|
|
43850
|
+
function onLinkLine(ctx, line) {
|
|
43851
|
+
let msg;
|
|
43852
|
+
try {
|
|
43853
|
+
msg = JSON.parse(line);
|
|
43854
|
+
} catch {
|
|
43855
|
+
return;
|
|
43856
|
+
}
|
|
43857
|
+
if (msg.type === "hello") return onHello(ctx, msg);
|
|
43858
|
+
if (ctx.greeted) relayLinkMessage(ctx.relay, msg);
|
|
43859
|
+
}
|
|
43958
43860
|
|
|
43959
|
-
// src/commands/sessions/daemon/
|
|
43960
|
-
|
|
43961
|
-
|
|
43962
|
-
|
|
43963
|
-
|
|
43964
|
-
|
|
43965
|
-
|
|
43966
|
-
|
|
43967
|
-
|
|
43968
|
-
|
|
43969
|
-
|
|
43970
|
-
|
|
43971
|
-
|
|
43972
|
-
|
|
43973
|
-
|
|
43974
|
-
|
|
43975
|
-
connect: connect4,
|
|
43976
|
-
onLine: (line) => handleInbound(this.state, line),
|
|
43977
|
-
onClose: () => handleWindowsClose(this.state)
|
|
43861
|
+
// src/commands/sessions/daemon/links/openLink.ts
|
|
43862
|
+
function onLinkClose(ctx, socket, reason4) {
|
|
43863
|
+
if (ctx.socket !== socket) return;
|
|
43864
|
+
daemonLog(`link ${ctx.spec.name} ws: closed (${reason4})`);
|
|
43865
|
+
teardownLink(ctx);
|
|
43866
|
+
scheduleReconnect2(ctx);
|
|
43867
|
+
}
|
|
43868
|
+
async function openLink(ctx) {
|
|
43869
|
+
if (ctx.disposed || ctx.blockedMessage || ctx.socket) return;
|
|
43870
|
+
if (ctx.breaker.tripped()) return scheduleReconnect2(ctx);
|
|
43871
|
+
setLinkState(ctx, "connecting");
|
|
43872
|
+
daemonLog(`link ${ctx.spec.name} ws: connecting to ${ctx.spec.url}`);
|
|
43873
|
+
try {
|
|
43874
|
+
const socket = await ctx.deps.transport(ctx.spec.url, {
|
|
43875
|
+
onLine: (line) => onLinkLine(ctx, line),
|
|
43876
|
+
onClose: (reason4) => onLinkClose(ctx, socket, reason4)
|
|
43978
43877
|
});
|
|
43979
|
-
|
|
43980
|
-
|
|
43981
|
-
|
|
43982
|
-
|
|
43878
|
+
if (ctx.disposed) return socket.close();
|
|
43879
|
+
ctx.socket = socket;
|
|
43880
|
+
daemonLog(`link ${ctx.spec.name} ws: open, sending hello`);
|
|
43881
|
+
sendToLink(ctx, buildHello({ peer: true }));
|
|
43882
|
+
sendToLink(ctx, { type: "subscribe-logs" });
|
|
43883
|
+
} catch (error) {
|
|
43884
|
+
failLink(ctx, error instanceof Error ? error.message : String(error));
|
|
43983
43885
|
}
|
|
43984
|
-
|
|
43985
|
-
|
|
43986
|
-
|
|
43886
|
+
}
|
|
43887
|
+
|
|
43888
|
+
// src/commands/sessions/daemon/links/requestLinkHistory.ts
|
|
43889
|
+
var HISTORY_TIMEOUT_MS = 5e3;
|
|
43890
|
+
function requestLinkHistory(ctx) {
|
|
43891
|
+
if (!ctx.greeted) return Promise.resolve([]);
|
|
43892
|
+
const waiters = ctx.relay.historyWaiters;
|
|
43893
|
+
return new Promise((resolve25) => {
|
|
43894
|
+
const settle = (sessions) => {
|
|
43895
|
+
clearTimeout(timer);
|
|
43896
|
+
resolve25(sessions);
|
|
43897
|
+
};
|
|
43898
|
+
const timer = setTimeout(() => {
|
|
43899
|
+
const index3 = waiters.indexOf(settle);
|
|
43900
|
+
if (index3 !== -1) waiters.splice(index3, 1);
|
|
43901
|
+
daemonLog(`link ${ctx.spec.name} ws: history timed out`);
|
|
43902
|
+
resolve25([]);
|
|
43903
|
+
}, HISTORY_TIMEOUT_MS);
|
|
43904
|
+
timer.unref?.();
|
|
43905
|
+
waiters.push(settle);
|
|
43906
|
+
sendToLink(ctx, { type: "history" });
|
|
43907
|
+
});
|
|
43908
|
+
}
|
|
43909
|
+
|
|
43910
|
+
// src/commands/sessions/daemon/links/NodeLink.ts
|
|
43911
|
+
var NodeLink = class {
|
|
43912
|
+
constructor(spec, deps2) {
|
|
43913
|
+
this.spec = spec;
|
|
43914
|
+
const ctx = createLinkContext(spec, deps2);
|
|
43915
|
+
const healer = new LinkHealer(ctx);
|
|
43916
|
+
ctx.connect = () => void openLink(ctx);
|
|
43917
|
+
ctx.onMismatch = (version2) => void healer.onMismatch(version2);
|
|
43918
|
+
ctx.onCompatible = () => healer.onCompatible();
|
|
43919
|
+
this.ctx = ctx;
|
|
43920
|
+
}
|
|
43921
|
+
ctx;
|
|
43922
|
+
start = () => this.ctx.connect();
|
|
43923
|
+
sessions = () => this.ctx.relay.sessions;
|
|
43924
|
+
status = () => describeLink(this.ctx);
|
|
43925
|
+
history = () => requestLinkHistory(this.ctx);
|
|
43926
|
+
route(client, data) {
|
|
43927
|
+
forwardToLink(this.ctx, client, data);
|
|
43987
43928
|
}
|
|
43988
43929
|
replayScrollback(client) {
|
|
43989
|
-
|
|
43930
|
+
replayLinkScrollback(this.ctx.relay, client);
|
|
43990
43931
|
}
|
|
43991
|
-
|
|
43992
|
-
|
|
43993
|
-
|
|
43994
|
-
|
|
43995
|
-
if (isWindowsCreate(data)) return this.routeCreate(client, data);
|
|
43996
|
-
if (isWindowsIo(data)) {
|
|
43997
|
-
forwardWindowsIo(this.conn, data);
|
|
43998
|
-
return true;
|
|
43999
|
-
}
|
|
44000
|
-
return false;
|
|
43932
|
+
dispose() {
|
|
43933
|
+
this.ctx.disposed = true;
|
|
43934
|
+
clearTimeout(this.ctx.reconnectTimer);
|
|
43935
|
+
disconnectLink(this.ctx);
|
|
44001
43936
|
}
|
|
44002
|
-
|
|
44003
|
-
|
|
44004
|
-
|
|
44005
|
-
|
|
44006
|
-
|
|
44007
|
-
|
|
44008
|
-
|
|
43937
|
+
};
|
|
43938
|
+
|
|
43939
|
+
// src/commands/sessions/daemon/links/reconcileLinks.ts
|
|
43940
|
+
function reconcileLinks(links2, specs, create) {
|
|
43941
|
+
const wanted = new Map(specs.map((spec) => [spec.name, spec]));
|
|
43942
|
+
for (const [name, link3] of links2) {
|
|
43943
|
+
if (wanted.get(name)?.url === link3.spec.url) continue;
|
|
43944
|
+
daemonLog(`link ${name}: removed`);
|
|
43945
|
+
link3.dispose();
|
|
43946
|
+
links2.delete(name);
|
|
43947
|
+
}
|
|
43948
|
+
for (const spec of specs) {
|
|
43949
|
+
if (links2.has(spec.name)) continue;
|
|
43950
|
+
daemonLog(`link ${spec.name}: added (${spec.url})`);
|
|
43951
|
+
const link3 = create(spec);
|
|
43952
|
+
links2.set(spec.name, link3);
|
|
43953
|
+
link3.start();
|
|
43954
|
+
}
|
|
43955
|
+
}
|
|
43956
|
+
|
|
43957
|
+
// src/commands/sessions/daemon/links/routeToLink.ts
|
|
43958
|
+
function routeToLink(links2, localNode, client, data) {
|
|
43959
|
+
const target = resolveLinkTarget(data, localNode, (node) => links2.has(node));
|
|
43960
|
+
if (target.kind === "local") return false;
|
|
43961
|
+
const link3 = links2.get(target.node);
|
|
43962
|
+
if (link3) {
|
|
43963
|
+
link3.route(client, data);
|
|
44009
43964
|
return true;
|
|
44010
43965
|
}
|
|
43966
|
+
daemonLog(`link routing: ${data.type} names unknown node ${target.node}`);
|
|
43967
|
+
sendTo(client, { type: "error", message: `No link to node ${target.node}` });
|
|
43968
|
+
return true;
|
|
43969
|
+
}
|
|
43970
|
+
|
|
43971
|
+
// src/commands/sessions/daemon/links/NodeLinks.ts
|
|
43972
|
+
var NodeLinks = class {
|
|
43973
|
+
constructor(clients, onSessionsChanged) {
|
|
43974
|
+
this.clients = clients;
|
|
43975
|
+
this.onSessionsChanged = onSessionsChanged;
|
|
43976
|
+
}
|
|
43977
|
+
links = /* @__PURE__ */ new Map();
|
|
43978
|
+
options = {};
|
|
43979
|
+
configure(options2) {
|
|
43980
|
+
this.options = options2;
|
|
43981
|
+
}
|
|
43982
|
+
reload() {
|
|
43983
|
+
const specs = this.options.specs?.() ?? loadConfig().sessions?.links ?? [];
|
|
43984
|
+
const deps2 = linkDeps(this.options, {
|
|
43985
|
+
viewers: () => this.clients.viewers(),
|
|
43986
|
+
onSessionsChanged: this.onSessionsChanged,
|
|
43987
|
+
onStateChanged: () => broadcast(this.clients.viewers(), this.nodes())
|
|
43988
|
+
});
|
|
43989
|
+
reconcileLinks(this.links, specs, (spec) => new NodeLink(spec, deps2));
|
|
43990
|
+
this.onSessionsChanged();
|
|
43991
|
+
broadcast(this.clients.viewers(), this.nodes());
|
|
43992
|
+
}
|
|
43993
|
+
all = () => [...this.links.values()];
|
|
43994
|
+
localNode = () => this.options.localNode?.() ?? resolveNodeName();
|
|
43995
|
+
sessions = () => this.all().flatMap((link3) => link3.sessions());
|
|
43996
|
+
replayScrollback(client) {
|
|
43997
|
+
for (const link3 of this.all()) link3.replayScrollback(client);
|
|
43998
|
+
}
|
|
43999
|
+
history = async () => (await Promise.all(this.all().map((link3) => link3.history()))).flat();
|
|
44000
|
+
nodes = () => ({
|
|
44001
|
+
type: "nodes",
|
|
44002
|
+
local: this.localNode(),
|
|
44003
|
+
links: this.all().map((link3) => link3.status())
|
|
44004
|
+
});
|
|
44005
|
+
sendNodes = (client) => sendTo(client, this.nodes());
|
|
44006
|
+
route(client, data) {
|
|
44007
|
+
if (this.clients.isPeer(client)) return false;
|
|
44008
|
+
return routeToLink(this.links, this.localNode(), client, data);
|
|
44009
|
+
}
|
|
44011
44010
|
dispose() {
|
|
44012
|
-
this.
|
|
44011
|
+
for (const link3 of this.all()) link3.dispose();
|
|
44012
|
+
this.links.clear();
|
|
44013
44013
|
}
|
|
44014
44014
|
};
|
|
44015
44015
|
|
|
@@ -44176,7 +44176,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
44176
44176
|
}
|
|
44177
44177
|
|
|
44178
44178
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
44179
|
-
import { existsSync as
|
|
44179
|
+
import { existsSync as existsSync99 } from "fs";
|
|
44180
44180
|
|
|
44181
44181
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
44182
44182
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -44207,10 +44207,10 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
44207
44207
|
}
|
|
44208
44208
|
|
|
44209
44209
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
44210
|
-
import { existsSync as
|
|
44210
|
+
import { existsSync as existsSync98 } from "fs";
|
|
44211
44211
|
|
|
44212
44212
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
44213
|
-
import { copyFileSync as copyFileSync5, existsSync as
|
|
44213
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync97, mkdirSync as mkdirSync39 } from "fs";
|
|
44214
44214
|
import { join as join107 } from "path";
|
|
44215
44215
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
44216
44216
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -44221,7 +44221,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
44221
44221
|
return;
|
|
44222
44222
|
}
|
|
44223
44223
|
const dest = join107(dir, `${claudeSessionId}.jsonl`);
|
|
44224
|
-
if (
|
|
44224
|
+
if (existsSync97(dest)) {
|
|
44225
44225
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
44226
44226
|
return;
|
|
44227
44227
|
}
|
|
@@ -44272,7 +44272,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
44272
44272
|
}
|
|
44273
44273
|
function cloneForReapedTree(missingCwd) {
|
|
44274
44274
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
44275
|
-
if (!clone || !
|
|
44275
|
+
if (!clone || !existsSync98(clone))
|
|
44276
44276
|
throw new Error(
|
|
44277
44277
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
44278
44278
|
);
|
|
@@ -44281,7 +44281,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
44281
44281
|
|
|
44282
44282
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
44283
44283
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
44284
|
-
if (!
|
|
44284
|
+
if (!existsSync99(cwd))
|
|
44285
44285
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
44286
44286
|
const id = ctx.spawnWith(
|
|
44287
44287
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -44307,13 +44307,13 @@ var SessionManager = class {
|
|
|
44307
44307
|
clients = new ClientHub(persistUsagePeak);
|
|
44308
44308
|
idCounter = { next: 1 };
|
|
44309
44309
|
shuttingDown = false;
|
|
44310
|
-
|
|
44311
|
-
windowsProxy = new WindowsProxy(this.clients, () => this.notify());
|
|
44310
|
+
links = new NodeLinks(this.clients, () => this.notify());
|
|
44312
44311
|
addClient(client) {
|
|
44313
44312
|
this.clients.add(client);
|
|
44314
44313
|
this.notify();
|
|
44315
|
-
greetClient(client, this.sessions, this.
|
|
44314
|
+
greetClient(client, this.sessions, this.links);
|
|
44316
44315
|
}
|
|
44316
|
+
replayLocal = (client) => replayScrollback(this.sessions, client);
|
|
44317
44317
|
removeClient(client) {
|
|
44318
44318
|
releaseClient(client, this.clients, this.prPreview, this.verify);
|
|
44319
44319
|
this.onIdleChange?.(this.isIdle());
|
|
@@ -44436,21 +44436,19 @@ var SessionManager = class {
|
|
|
44436
44436
|
usedPct
|
|
44437
44437
|
);
|
|
44438
44438
|
}
|
|
44439
|
-
|
|
44440
|
-
|
|
44441
|
-
return local.concat(this.windowsProxy.sessions());
|
|
44442
|
-
};
|
|
44439
|
+
localSessions = () => [...this.sessions.values()].map(toSessionInfo);
|
|
44440
|
+
listSessions = () => this.localSessions().concat(this.links.sessions());
|
|
44443
44441
|
notify = () => {
|
|
44444
44442
|
if (this.shuttingDown) return;
|
|
44445
|
-
const
|
|
44446
|
-
broadcastSessions(this.sessions, this.clients,
|
|
44443
|
+
const linked = this.links.sessions();
|
|
44444
|
+
broadcastSessions(this.sessions, this.clients, linked, this.active);
|
|
44447
44445
|
this.onIdleChange?.(this.isIdle());
|
|
44448
44446
|
};
|
|
44449
44447
|
};
|
|
44450
44448
|
|
|
44451
44449
|
// src/commands/sessions/daemon/startDaemonServer.ts
|
|
44452
44450
|
import { unlinkSync as unlinkSync24 } from "fs";
|
|
44453
|
-
import * as
|
|
44451
|
+
import * as net2 from "net";
|
|
44454
44452
|
|
|
44455
44453
|
// src/commands/sessions/daemon/exitAfterFlush.ts
|
|
44456
44454
|
var FLUSH_TIMEOUT_MS = 2e3;
|
|
@@ -44470,13 +44468,25 @@ function exitAfterFlush(code) {
|
|
|
44470
44468
|
}
|
|
44471
44469
|
|
|
44472
44470
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
44473
|
-
import { createInterface as
|
|
44471
|
+
import { createInterface as createInterface9 } from "readline";
|
|
44472
|
+
|
|
44473
|
+
// src/commands/sessions/daemon/handleHelloRequest.ts
|
|
44474
|
+
var handleHelloRequest = (client, m, d) => {
|
|
44475
|
+
sendTo(client, buildHello());
|
|
44476
|
+
if (d.peer !== true) return;
|
|
44477
|
+
daemonLog(
|
|
44478
|
+
`peer link from ${d.nodeName ?? "unknown node"} (${d.version ?? "unknown version"}); exporting local sessions only`
|
|
44479
|
+
);
|
|
44480
|
+
m.clients.markPeer(client);
|
|
44481
|
+
sendTo(client, { type: "sessions", sessions: m.localSessions(), active: {} });
|
|
44482
|
+
m.replayLocal(client);
|
|
44483
|
+
};
|
|
44474
44484
|
|
|
44475
44485
|
// src/commands/sessions/daemon/creator.ts
|
|
44476
|
-
function creator(isNew,
|
|
44486
|
+
function creator(isNew, spawn11) {
|
|
44477
44487
|
return (client, m, d) => {
|
|
44478
|
-
if (m.
|
|
44479
|
-
const result =
|
|
44488
|
+
if (m.links.route(client, d)) return;
|
|
44489
|
+
const result = spawn11(m, d);
|
|
44480
44490
|
if (typeof result !== "string") {
|
|
44481
44491
|
sendTo(client, { type: "error", message: result.error });
|
|
44482
44492
|
return;
|
|
@@ -44582,7 +44592,7 @@ function applyCodexUsage(sessions, sessionId, usage, windows) {
|
|
|
44582
44592
|
|
|
44583
44593
|
// src/commands/sessions/daemon/handleCodexUsage.ts
|
|
44584
44594
|
var handleCodexUsage = (client, m, d) => {
|
|
44585
|
-
if (m.
|
|
44595
|
+
if (m.links.route(client, d)) return;
|
|
44586
44596
|
const sessionId = d.sessionId;
|
|
44587
44597
|
daemonLog(`codex-usage received: id=${sessionId}`);
|
|
44588
44598
|
if (d.ack) sendTo(client, { type: "ack", sessionId });
|
|
@@ -44611,7 +44621,7 @@ function spawnContextFrom(d) {
|
|
|
44611
44621
|
|
|
44612
44622
|
// src/commands/sessions/daemon/handleCreateRun.ts
|
|
44613
44623
|
function handleCreateRun(client, m, d) {
|
|
44614
|
-
if (m.
|
|
44624
|
+
if (m.links.route(client, d)) return;
|
|
44615
44625
|
const runName = d.runName;
|
|
44616
44626
|
const cwd = d.cwd;
|
|
44617
44627
|
const runArgs = d.runArgs ?? [];
|
|
@@ -44651,7 +44661,7 @@ function handleSetStatus(client, m, d) {
|
|
|
44651
44661
|
daemonLog(
|
|
44652
44662
|
`set-status received: id=${d.sessionId} status=${d.status}${d.source ? ` source=${d.source}` : ""}`
|
|
44653
44663
|
);
|
|
44654
|
-
if (m.
|
|
44664
|
+
if (m.links.route(client, d)) return;
|
|
44655
44665
|
m.setStatus({
|
|
44656
44666
|
id: d.sessionId,
|
|
44657
44667
|
status: d.status,
|
|
@@ -44792,10 +44802,13 @@ function withRepoGroups(sessions) {
|
|
|
44792
44802
|
}
|
|
44793
44803
|
|
|
44794
44804
|
// src/commands/sessions/daemon/lifecycleHandlers.ts
|
|
44795
|
-
function handleHistory(client) {
|
|
44796
|
-
|
|
44797
|
-
|
|
44798
|
-
|
|
44805
|
+
async function handleHistory(client, manager) {
|
|
44806
|
+
const linked = manager.clients.isPeer(client) ? [] : manager.links.history();
|
|
44807
|
+
const [local, remote] = await Promise.all([discoverSessions(), linked]);
|
|
44808
|
+
sendTo(client, {
|
|
44809
|
+
type: "history",
|
|
44810
|
+
sessions: withRepoGroups(local).concat(remote)
|
|
44811
|
+
});
|
|
44799
44812
|
}
|
|
44800
44813
|
function handleFetchTranscript(client, _manager, data) {
|
|
44801
44814
|
const sessionId = data.sessionId;
|
|
@@ -44823,7 +44836,7 @@ var lifecycleHandlers = {
|
|
|
44823
44836
|
// src/commands/sessions/daemon/routed.ts
|
|
44824
44837
|
function routed(local) {
|
|
44825
44838
|
return (client, m, d) => {
|
|
44826
|
-
if (!m.
|
|
44839
|
+
if (!m.links.route(client, d)) local(client, m, d);
|
|
44827
44840
|
};
|
|
44828
44841
|
}
|
|
44829
44842
|
|
|
@@ -44907,7 +44920,12 @@ function spawnCreate(m, d) {
|
|
|
44907
44920
|
var messageHandlers = {
|
|
44908
44921
|
ping: (client) => sendTo(client, { type: "pong", pid: process.pid }),
|
|
44909
44922
|
"subscribe-logs": (client, m, d) => m.clients.subscribeLogs(client, d.replay !== false),
|
|
44910
|
-
hello:
|
|
44923
|
+
hello: handleHelloRequest,
|
|
44924
|
+
nodes: (client, m) => m.links.sendNodes(client),
|
|
44925
|
+
"reload-links": (_client, m) => {
|
|
44926
|
+
daemonLog("reload-links received");
|
|
44927
|
+
m.links.reload();
|
|
44928
|
+
},
|
|
44911
44929
|
create: creator(true, spawnCreate),
|
|
44912
44930
|
"create-run": handleCreateRun,
|
|
44913
44931
|
"create-assist": creator(
|
|
@@ -44990,7 +45008,7 @@ function handleConnection(socket, manager) {
|
|
|
44990
45008
|
};
|
|
44991
45009
|
manager.addClient(client);
|
|
44992
45010
|
manager.clients.greet(client);
|
|
44993
|
-
const lines2 =
|
|
45011
|
+
const lines2 = createInterface9({ input: socket });
|
|
44994
45012
|
lines2.on("error", () => {
|
|
44995
45013
|
});
|
|
44996
45014
|
lines2.on("line", (line) => {
|
|
@@ -45020,7 +45038,7 @@ function handleConnection(socket, manager) {
|
|
|
45020
45038
|
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync54 } from "fs";
|
|
45021
45039
|
|
|
45022
45040
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
45023
|
-
import { readFileSync as
|
|
45041
|
+
import { readFileSync as readFileSync68 } from "fs";
|
|
45024
45042
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
45025
45043
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
45026
45044
|
const timer = setInterval(() => {
|
|
@@ -45031,7 +45049,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
45031
45049
|
}
|
|
45032
45050
|
function ownsPidFile() {
|
|
45033
45051
|
try {
|
|
45034
|
-
return
|
|
45052
|
+
return readFileSync68(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
45035
45053
|
} catch {
|
|
45036
45054
|
return false;
|
|
45037
45055
|
}
|
|
@@ -45060,6 +45078,7 @@ function onListening(manager, checkAutoExit) {
|
|
|
45060
45078
|
restored.length > 0 ? `restored ${restored.length} session(s): ${restored.join(", ")}` : "no persisted sessions to restore"
|
|
45061
45079
|
);
|
|
45062
45080
|
daemonLog(`listening on ${daemonPaths.socket}`);
|
|
45081
|
+
manager.links.reload();
|
|
45063
45082
|
checkAutoExit(manager.isIdle());
|
|
45064
45083
|
}
|
|
45065
45084
|
function cleanupOwnedFiles() {
|
|
@@ -45076,99 +45095,6 @@ function cleanupOwnedFiles() {
|
|
|
45076
45095
|
}
|
|
45077
45096
|
}
|
|
45078
45097
|
|
|
45079
|
-
// src/commands/sessions/daemon/startWindowsBridge.ts
|
|
45080
|
-
import * as net3 from "net";
|
|
45081
|
-
|
|
45082
|
-
// src/commands/sessions/daemon/findPortHolderPid.ts
|
|
45083
|
-
import { execFileSync as execFileSync25 } from "child_process";
|
|
45084
|
-
var PROBE_TIMEOUT_MS = 3e3;
|
|
45085
|
-
function findPortHolderPid(port) {
|
|
45086
|
-
try {
|
|
45087
|
-
return process.platform === "win32" ? netstatListenerPid(probe("netstat", ["-ano"]), port) : firstPid(probe("lsof", ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN", "-t"]));
|
|
45088
|
-
} catch {
|
|
45089
|
-
return void 0;
|
|
45090
|
-
}
|
|
45091
|
-
}
|
|
45092
|
-
function probe(command, args) {
|
|
45093
|
-
return execFileSync25(command, args, {
|
|
45094
|
-
encoding: "utf8",
|
|
45095
|
-
timeout: PROBE_TIMEOUT_MS,
|
|
45096
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
45097
|
-
});
|
|
45098
|
-
}
|
|
45099
|
-
function netstatListenerPid(output, port) {
|
|
45100
|
-
const suffix = `:${port}`;
|
|
45101
|
-
for (const line of output.split("\n")) {
|
|
45102
|
-
const [protocol, local, , state, pid] = line.trim().split(/\s+/);
|
|
45103
|
-
if (protocol?.toUpperCase() !== "TCP") continue;
|
|
45104
|
-
if (state?.toUpperCase() !== "LISTENING") continue;
|
|
45105
|
-
if (!local?.endsWith(suffix)) continue;
|
|
45106
|
-
const holder = Number.parseInt(pid ?? "", 10);
|
|
45107
|
-
if (Number.isInteger(holder)) return holder;
|
|
45108
|
-
}
|
|
45109
|
-
return void 0;
|
|
45110
|
-
}
|
|
45111
|
-
function firstPid(output) {
|
|
45112
|
-
for (const line of output.split("\n")) {
|
|
45113
|
-
const pid = Number.parseInt(line.trim(), 10);
|
|
45114
|
-
if (Number.isInteger(pid)) return pid;
|
|
45115
|
-
}
|
|
45116
|
-
return void 0;
|
|
45117
|
-
}
|
|
45118
|
-
|
|
45119
|
-
// src/commands/sessions/daemon/startWindowsBridge.ts
|
|
45120
|
-
var BIND_ATTEMPTS = 3;
|
|
45121
|
-
var BIND_RETRY_DELAY_MS = 250;
|
|
45122
|
-
var KEEPALIVE_PROBE_MS2 = 1e4;
|
|
45123
|
-
async function startWindowsBridge(manager) {
|
|
45124
|
-
const port = windowsDaemonPort();
|
|
45125
|
-
for (let attempt = 1; attempt <= BIND_ATTEMPTS; attempt++) {
|
|
45126
|
-
const error = await bindBridge(manager, port);
|
|
45127
|
-
if (!error) {
|
|
45128
|
-
daemonLog(`windows bridge listening on :${port}`);
|
|
45129
|
-
return true;
|
|
45130
|
-
}
|
|
45131
|
-
daemonLog(
|
|
45132
|
-
`windows bridge bind attempt ${attempt}/${BIND_ATTEMPTS} on :${port} failed: ${error.message}`
|
|
45133
|
-
);
|
|
45134
|
-
if (attempt < BIND_ATTEMPTS) await delay3(BIND_RETRY_DELAY_MS);
|
|
45135
|
-
}
|
|
45136
|
-
daemonLog(
|
|
45137
|
-
`${WINDOWS_BRIDGE_FAILURE_PREFIX} could not bind port ${port} after ${BIND_ATTEMPTS} attempts; ${describePortHolder(port)}`
|
|
45138
|
-
);
|
|
45139
|
-
return false;
|
|
45140
|
-
}
|
|
45141
|
-
function describePortHolder(port) {
|
|
45142
|
-
const holder = findPortHolderPid(port);
|
|
45143
|
-
return holder !== void 0 && holder !== process.pid ? `PID ${holder} is listening on it \u2014 kill PID ${holder} to free the port` : "the port is held by another process or reserved by a Hyper-V/WSL dynamic port range \u2014 set sessions.windowsDaemonPort to a free port outside 49152-65535";
|
|
45144
|
-
}
|
|
45145
|
-
function bindBridge(manager, port) {
|
|
45146
|
-
return new Promise((resolve25) => {
|
|
45147
|
-
const bridge = net3.createServer((socket) => {
|
|
45148
|
-
socket.setKeepAlive(true, KEEPALIVE_PROBE_MS2);
|
|
45149
|
-
handleConnection(socket, manager);
|
|
45150
|
-
});
|
|
45151
|
-
bridge.once("error", (error) => {
|
|
45152
|
-
bridge.close(() => {
|
|
45153
|
-
});
|
|
45154
|
-
resolve25(error);
|
|
45155
|
-
});
|
|
45156
|
-
bridge.listen(port, () => {
|
|
45157
|
-
bridge.removeAllListeners("error");
|
|
45158
|
-
bridge.on("error", (error) => {
|
|
45159
|
-
daemonLog(
|
|
45160
|
-
`${WINDOWS_BRIDGE_FAILURE_PREFIX} ${error.message} after listening; exiting so the next launch can take over`
|
|
45161
|
-
);
|
|
45162
|
-
exitAfterFlush(1);
|
|
45163
|
-
});
|
|
45164
|
-
resolve25(null);
|
|
45165
|
-
});
|
|
45166
|
-
});
|
|
45167
|
-
}
|
|
45168
|
-
function delay3(ms) {
|
|
45169
|
-
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
45170
|
-
}
|
|
45171
|
-
|
|
45172
45098
|
// src/commands/sessions/daemon/describeWedgedHolder.ts
|
|
45173
45099
|
function describeWedgedHolder() {
|
|
45174
45100
|
const recorded = readDaemonPidFile();
|
|
@@ -45179,14 +45105,7 @@ function describeWedgedHolder() {
|
|
|
45179
45105
|
|
|
45180
45106
|
// src/commands/sessions/daemon/startDaemonServer.ts
|
|
45181
45107
|
async function startDaemonServer(manager, checkAutoExit) {
|
|
45182
|
-
|
|
45183
|
-
daemonLog(
|
|
45184
|
-
"exiting before binding the pipe so the next launch can take over"
|
|
45185
|
-
);
|
|
45186
|
-
exitAfterFlush(1);
|
|
45187
|
-
return;
|
|
45188
|
-
}
|
|
45189
|
-
const server = net4.createServer(
|
|
45108
|
+
const server = net2.createServer(
|
|
45190
45109
|
(socket) => handleConnection(socket, manager)
|
|
45191
45110
|
);
|
|
45192
45111
|
let retried = false;
|
|
@@ -45280,6 +45199,139 @@ async function closeSession() {
|
|
|
45280
45199
|
}
|
|
45281
45200
|
}
|
|
45282
45201
|
|
|
45202
|
+
// src/commands/sessions/nodes/linkNode.ts
|
|
45203
|
+
import chalk249 from "chalk";
|
|
45204
|
+
|
|
45205
|
+
// src/commands/sessions/nodes/writeLinks.ts
|
|
45206
|
+
function readLinks() {
|
|
45207
|
+
const sessions = loadGlobalConfigRaw().sessions;
|
|
45208
|
+
return sessions?.links ?? [];
|
|
45209
|
+
}
|
|
45210
|
+
async function writeLinks(links2) {
|
|
45211
|
+
const config = loadGlobalConfigRaw();
|
|
45212
|
+
const sessions = { ...config.sessions };
|
|
45213
|
+
if (links2.length > 0) sessions.links = links2;
|
|
45214
|
+
else delete sessions.links;
|
|
45215
|
+
const updated2 = { ...config, sessions };
|
|
45216
|
+
const validation = validateConfig(updated2, "sessions.links");
|
|
45217
|
+
if (!validation.ok) throw new Error(validation.errors.join("\n"));
|
|
45218
|
+
saveGlobalConfig(updated2);
|
|
45219
|
+
if (await isDaemonRunning()) await sendToDaemon({ type: "reload-links" });
|
|
45220
|
+
}
|
|
45221
|
+
|
|
45222
|
+
// src/commands/sessions/nodes/linkNode.ts
|
|
45223
|
+
function parseLinkUrl(url) {
|
|
45224
|
+
const parsed = new URL(url);
|
|
45225
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
45226
|
+
throw new Error(`link url must be http(s): ${url}`);
|
|
45227
|
+
return parsed.origin;
|
|
45228
|
+
}
|
|
45229
|
+
async function linkNode(name, url) {
|
|
45230
|
+
if (name.includes(":")) throw new Error("node names cannot contain ':'");
|
|
45231
|
+
if (name === resolveNodeName())
|
|
45232
|
+
throw new Error(`${name} is this node; link to a different node`);
|
|
45233
|
+
const others = readLinks().filter((link3) => link3.name !== name);
|
|
45234
|
+
await writeLinks([...others, { name, url: parseLinkUrl(url) }]);
|
|
45235
|
+
console.log(chalk249.green(`Linked ${name} (${parseLinkUrl(url)})`));
|
|
45236
|
+
}
|
|
45237
|
+
|
|
45238
|
+
// src/commands/sessions/nodes/listNodes.ts
|
|
45239
|
+
import chalk250 from "chalk";
|
|
45240
|
+
|
|
45241
|
+
// src/commands/sessions/nodes/queryNodes.ts
|
|
45242
|
+
import { createInterface as createInterface10 } from "readline";
|
|
45243
|
+
var QUERY_TIMEOUT_MS = 3e3;
|
|
45244
|
+
async function queryNodes() {
|
|
45245
|
+
let socket;
|
|
45246
|
+
try {
|
|
45247
|
+
socket = await connectToDaemon();
|
|
45248
|
+
} catch {
|
|
45249
|
+
return void 0;
|
|
45250
|
+
}
|
|
45251
|
+
return new Promise((resolve25) => {
|
|
45252
|
+
const finish2 = (result) => {
|
|
45253
|
+
clearTimeout(timer);
|
|
45254
|
+
socket.destroy();
|
|
45255
|
+
resolve25(result);
|
|
45256
|
+
};
|
|
45257
|
+
const timer = setTimeout(() => finish2(void 0), QUERY_TIMEOUT_MS);
|
|
45258
|
+
const lines2 = createInterface10({ input: socket });
|
|
45259
|
+
lines2.on("error", () => {
|
|
45260
|
+
});
|
|
45261
|
+
lines2.on("line", (line) => {
|
|
45262
|
+
try {
|
|
45263
|
+
const data = JSON.parse(line);
|
|
45264
|
+
if (data.type === "nodes") finish2(data);
|
|
45265
|
+
} catch {
|
|
45266
|
+
}
|
|
45267
|
+
});
|
|
45268
|
+
socket.on("error", () => finish2(void 0));
|
|
45269
|
+
socket.write(`${JSON.stringify({ type: "nodes" })}
|
|
45270
|
+
`);
|
|
45271
|
+
});
|
|
45272
|
+
}
|
|
45273
|
+
|
|
45274
|
+
// src/commands/sessions/nodes/listNodes.ts
|
|
45275
|
+
async function nodesReport() {
|
|
45276
|
+
const live = await queryNodes();
|
|
45277
|
+
if (live)
|
|
45278
|
+
return { local: live.local, daemonRunning: true, links: live.links };
|
|
45279
|
+
const configured = loadConfig().sessions?.links ?? [];
|
|
45280
|
+
return {
|
|
45281
|
+
local: resolveNodeName(),
|
|
45282
|
+
daemonRunning: false,
|
|
45283
|
+
links: configured.map((link3) => ({ ...link3, state: "disconnected" }))
|
|
45284
|
+
};
|
|
45285
|
+
}
|
|
45286
|
+
var STATE_COLOURS = {
|
|
45287
|
+
connected: chalk250.green,
|
|
45288
|
+
connecting: chalk250.yellow,
|
|
45289
|
+
disconnected: chalk250.red,
|
|
45290
|
+
"version-blocked": chalk250.red
|
|
45291
|
+
};
|
|
45292
|
+
function formatLink(link3) {
|
|
45293
|
+
const colour = STATE_COLOURS[link3.state] ?? chalk250.white;
|
|
45294
|
+
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
45295
|
+
const error = link3.error ? `
|
|
45296
|
+
${chalk250.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
45297
|
+
return ` ${link3.name} ${colour(link3.state)} direct ${link3.url}${peer}${error}`;
|
|
45298
|
+
}
|
|
45299
|
+
async function listNodes(options2) {
|
|
45300
|
+
const report2 = await nodesReport();
|
|
45301
|
+
if (options2.json) {
|
|
45302
|
+
console.log(JSON.stringify(report2, null, 2));
|
|
45303
|
+
return;
|
|
45304
|
+
}
|
|
45305
|
+
console.log(`${report2.local} ${chalk250.dim("(this node)")}`);
|
|
45306
|
+
if (!report2.daemonRunning)
|
|
45307
|
+
console.log(chalk250.dim(" daemon not running; showing configured links"));
|
|
45308
|
+
if (report2.links.length === 0) console.log(chalk250.dim(" no links"));
|
|
45309
|
+
for (const link3 of report2.links) console.log(formatLink(link3));
|
|
45310
|
+
}
|
|
45311
|
+
|
|
45312
|
+
// src/commands/sessions/nodes/unlinkNode.ts
|
|
45313
|
+
import chalk251 from "chalk";
|
|
45314
|
+
async function unlinkNode(name) {
|
|
45315
|
+
const links2 = readLinks();
|
|
45316
|
+
const remaining = links2.filter((link3) => link3.name !== name);
|
|
45317
|
+
if (remaining.length === links2.length) {
|
|
45318
|
+
console.log(chalk251.yellow(`No link named ${name}`));
|
|
45319
|
+
return;
|
|
45320
|
+
}
|
|
45321
|
+
await writeLinks(remaining);
|
|
45322
|
+
console.log(chalk251.green(`Unlinked ${name}`));
|
|
45323
|
+
}
|
|
45324
|
+
|
|
45325
|
+
// src/commands/sessions/nodes/registerNodes.ts
|
|
45326
|
+
function registerNodes(sessions) {
|
|
45327
|
+
const cmd = sessions.command("nodes").description("List this node and every linked node with its link state").option("--json", "Output as JSON").action(listNodes);
|
|
45328
|
+
cmd.command("link <name> <url>").description(
|
|
45329
|
+
"Link a peer node by its web server URL (name must match the peer's sessions.nodeName)"
|
|
45330
|
+
).action(linkNode);
|
|
45331
|
+
cmd.command("unlink <name>").description("Remove a linked node").action(unlinkNode);
|
|
45332
|
+
configHelp(cmd, nodesConfigHelp);
|
|
45333
|
+
}
|
|
45334
|
+
|
|
45283
45335
|
// src/commands/sessions/registerSetStatusCommand.ts
|
|
45284
45336
|
function registerSetStatusCommand(cmd) {
|
|
45285
45337
|
cmd.command("set-status <status>").description(
|
|
@@ -45313,7 +45365,7 @@ async function renameSession(title) {
|
|
|
45313
45365
|
|
|
45314
45366
|
// src/commands/sessions/summarise.ts
|
|
45315
45367
|
import * as fs58 from "fs";
|
|
45316
|
-
import
|
|
45368
|
+
import chalk252 from "chalk";
|
|
45317
45369
|
|
|
45318
45370
|
// src/commands/sessions/summarise/shared.ts
|
|
45319
45371
|
import * as fs57 from "fs";
|
|
@@ -45329,7 +45381,7 @@ function summaryPathFor(jsonlPath2) {
|
|
|
45329
45381
|
}
|
|
45330
45382
|
|
|
45331
45383
|
// src/commands/sessions/summarise/summariseSession.ts
|
|
45332
|
-
import { execFileSync as
|
|
45384
|
+
import { execFileSync as execFileSync25 } from "child_process";
|
|
45333
45385
|
function summariseSession(jsonlPath2) {
|
|
45334
45386
|
const firstMessage = extractFirstUserMessage(jsonlPath2);
|
|
45335
45387
|
const backlogIds = scanSessionBacklogRefs(jsonlPath2);
|
|
@@ -45338,7 +45390,7 @@ function summariseSession(jsonlPath2) {
|
|
|
45338
45390
|
}
|
|
45339
45391
|
const prompt = buildPrompt6(firstMessage, backlogIds);
|
|
45340
45392
|
try {
|
|
45341
|
-
const output =
|
|
45393
|
+
const output = execFileSync25("claude", ["-p", "--model", "haiku", prompt], {
|
|
45342
45394
|
encoding: "utf8",
|
|
45343
45395
|
timeout: 3e4,
|
|
45344
45396
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -45372,22 +45424,22 @@ ${firstMessage}`);
|
|
|
45372
45424
|
async function summarise2(options2) {
|
|
45373
45425
|
const files = await discoverSessionFiles();
|
|
45374
45426
|
if (files.length === 0) {
|
|
45375
|
-
console.log(
|
|
45427
|
+
console.log(chalk252.yellow("No sessions found."));
|
|
45376
45428
|
return;
|
|
45377
45429
|
}
|
|
45378
45430
|
const toProcess = selectCandidates(files, options2);
|
|
45379
45431
|
if (toProcess.length === 0) {
|
|
45380
|
-
console.log(
|
|
45432
|
+
console.log(chalk252.green("All sessions already summarised."));
|
|
45381
45433
|
return;
|
|
45382
45434
|
}
|
|
45383
45435
|
console.log(
|
|
45384
|
-
|
|
45436
|
+
chalk252.cyan(
|
|
45385
45437
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
45386
45438
|
)
|
|
45387
45439
|
);
|
|
45388
45440
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
45389
45441
|
console.log(
|
|
45390
|
-
|
|
45442
|
+
chalk252.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk252.yellow(`, ${failed2} skipped`) : "")
|
|
45391
45443
|
);
|
|
45392
45444
|
}
|
|
45393
45445
|
function selectCandidates(files, options2) {
|
|
@@ -45407,16 +45459,16 @@ function processSessions(files) {
|
|
|
45407
45459
|
let failed2 = 0;
|
|
45408
45460
|
for (let i = 0; i < files.length; i++) {
|
|
45409
45461
|
const file = files[i];
|
|
45410
|
-
process.stdout.write(
|
|
45462
|
+
process.stdout.write(chalk252.dim(` [${i + 1}/${files.length}] `));
|
|
45411
45463
|
const summary = summariseSession(file);
|
|
45412
45464
|
if (summary) {
|
|
45413
45465
|
writeSummary(file, summary);
|
|
45414
45466
|
succeeded++;
|
|
45415
|
-
process.stdout.write(`${
|
|
45467
|
+
process.stdout.write(`${chalk252.green("\u2713")} ${summary}
|
|
45416
45468
|
`);
|
|
45417
45469
|
} else {
|
|
45418
45470
|
failed2++;
|
|
45419
|
-
process.stdout.write(` ${
|
|
45471
|
+
process.stdout.write(` ${chalk252.yellow("skip")}
|
|
45420
45472
|
`);
|
|
45421
45473
|
}
|
|
45422
45474
|
}
|
|
@@ -45439,14 +45491,15 @@ function registerSessions(program2) {
|
|
|
45439
45491
|
"Retitle the current daemon-managed session, overriding the generated title for the rest of its life"
|
|
45440
45492
|
).action(renameSession);
|
|
45441
45493
|
registerSetStatusCommand(cmd);
|
|
45494
|
+
registerNodes(cmd);
|
|
45442
45495
|
configHelp(cmd, sessionsConfigHelp);
|
|
45443
45496
|
}
|
|
45444
45497
|
|
|
45445
45498
|
// src/reportCliError.ts
|
|
45446
|
-
import
|
|
45499
|
+
import chalk253 from "chalk";
|
|
45447
45500
|
function reportCliError(error) {
|
|
45448
45501
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
45449
|
-
console.error(
|
|
45502
|
+
console.error(chalk253.red(error.message));
|
|
45450
45503
|
} else {
|
|
45451
45504
|
console.error(error);
|
|
45452
45505
|
}
|