@staff0rd/assist 0.1081.1 → 0.1082.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-version +1 -1
- package/dist/commands/extension/extension/updates.json +2 -2
- package/dist/commands/sessions/web/bundle.js +487 -487
- package/dist/index.js +1289 -944
- 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.1082.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1802,11 +1802,11 @@ function createLinkState({
|
|
|
1802
1802
|
// src/commands/sessions/web/browser/createPendingReplies.ts
|
|
1803
1803
|
import { randomUUID } from "crypto";
|
|
1804
1804
|
function createPendingReplies() {
|
|
1805
|
-
const
|
|
1805
|
+
const pending = /* @__PURE__ */ new Map();
|
|
1806
1806
|
function take(id) {
|
|
1807
|
-
const entry =
|
|
1807
|
+
const entry = pending.get(id);
|
|
1808
1808
|
if (!entry) return void 0;
|
|
1809
|
-
|
|
1809
|
+
pending.delete(id);
|
|
1810
1810
|
clearTimeout(entry.timer);
|
|
1811
1811
|
return entry;
|
|
1812
1812
|
}
|
|
@@ -1815,7 +1815,7 @@ function createPendingReplies() {
|
|
|
1815
1815
|
const id = randomUUID();
|
|
1816
1816
|
return new Promise((resolve34, reject) => {
|
|
1817
1817
|
const timer = setTimeout(() => {
|
|
1818
|
-
|
|
1818
|
+
pending.delete(id);
|
|
1819
1819
|
reject(
|
|
1820
1820
|
relayError(
|
|
1821
1821
|
`the assist extension did not reply within ${timeoutMs / 1e3}s`,
|
|
@@ -1823,7 +1823,7 @@ function createPendingReplies() {
|
|
|
1823
1823
|
)
|
|
1824
1824
|
);
|
|
1825
1825
|
}, timeoutMs);
|
|
1826
|
-
|
|
1826
|
+
pending.set(id, { ws, timer, resolve: resolve34, reject });
|
|
1827
1827
|
write2(id);
|
|
1828
1828
|
});
|
|
1829
1829
|
},
|
|
@@ -1831,7 +1831,7 @@ function createPendingReplies() {
|
|
|
1831
1831
|
take(id)?.resolve(reply2);
|
|
1832
1832
|
},
|
|
1833
1833
|
dropSocket(ws) {
|
|
1834
|
-
for (const [id, entry] of
|
|
1834
|
+
for (const [id, entry] of pending) {
|
|
1835
1835
|
if (entry.ws !== ws) continue;
|
|
1836
1836
|
take(id)?.reject(
|
|
1837
1837
|
relayError("the assist extension disconnected before replying", 502)
|
|
@@ -3640,9 +3640,9 @@ function compareMigrations(appliedIds) {
|
|
|
3640
3640
|
const expected = maxId(bundledIds);
|
|
3641
3641
|
const ahead = appliedIds.filter((id) => !bundledSet.has(id));
|
|
3642
3642
|
if (ahead.length > 0) return { state: "ahead", applied, expected };
|
|
3643
|
-
const
|
|
3644
|
-
if (
|
|
3645
|
-
return { state: "behind", applied, expected, pending
|
|
3643
|
+
const pending = bundledIds.filter((id) => !appliedSet.has(id));
|
|
3644
|
+
if (pending.length > 0)
|
|
3645
|
+
return { state: "behind", applied, expected, pending };
|
|
3646
3646
|
return { state: "in-sync", version: expected };
|
|
3647
3647
|
}
|
|
3648
3648
|
async function readAppliedIds2(exec3) {
|
|
@@ -5102,8 +5102,8 @@ async function committedPaths(cwd, sessionId2) {
|
|
|
5102
5102
|
const key = `${cwd} ${sessionId2}`;
|
|
5103
5103
|
const cached2 = cache.get(key);
|
|
5104
5104
|
if (cached2 && cached2.expiresAt > Date.now()) return cached2.value;
|
|
5105
|
-
const
|
|
5106
|
-
if (
|
|
5105
|
+
const pending = inFlight.get(key);
|
|
5106
|
+
if (pending) return pending;
|
|
5107
5107
|
const lookup = loadCommittedPaths(cwd, sessionId2).then((value) => {
|
|
5108
5108
|
cache.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS });
|
|
5109
5109
|
return value;
|
|
@@ -8826,6 +8826,14 @@ function newTraceId() {
|
|
|
8826
8826
|
return randomUUID2().slice(0, 8);
|
|
8827
8827
|
}
|
|
8828
8828
|
|
|
8829
|
+
// src/commands/sessions/shared/viaDaemonLinkPaths.ts
|
|
8830
|
+
var LINK_UPDATE_STATUS_PATH = "/api/updates/link-status";
|
|
8831
|
+
var RESTART_WEB_VIA_LINK_PATH = "/api/updates/restart-web";
|
|
8832
|
+
var viaDaemonLinkPaths = /* @__PURE__ */ new Set([
|
|
8833
|
+
LINK_UPDATE_STATUS_PATH,
|
|
8834
|
+
RESTART_WEB_VIA_LINK_PATH
|
|
8835
|
+
]);
|
|
8836
|
+
|
|
8829
8837
|
// src/commands/sessions/web/forwardToPeer.ts
|
|
8830
8838
|
import {
|
|
8831
8839
|
request as httpRequest
|
|
@@ -8913,6 +8921,7 @@ function proxyTarget(req) {
|
|
|
8913
8921
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
8914
8922
|
const node = url.searchParams.get("node");
|
|
8915
8923
|
if (!url.pathname.startsWith("/api/") || !node) return { kind: "local" };
|
|
8924
|
+
if (viaDaemonLinkPaths.has(url.pathname)) return { kind: "local" };
|
|
8916
8925
|
if (arrivedOverLink(req) || node === resolveNodeName())
|
|
8917
8926
|
return { kind: "local" };
|
|
8918
8927
|
const link3 = findLinkSpec(node);
|
|
@@ -9241,8 +9250,8 @@ function subsequenceScore(text20, query) {
|
|
|
9241
9250
|
function scoreFilePath(path109, query) {
|
|
9242
9251
|
const needle = query.trim().toLowerCase();
|
|
9243
9252
|
if (!needle) return 0;
|
|
9244
|
-
const
|
|
9245
|
-
const inBasename = subsequenceScore(
|
|
9253
|
+
const basename38 = path109.slice(path109.lastIndexOf("/") + 1);
|
|
9254
|
+
const inBasename = subsequenceScore(basename38, needle);
|
|
9246
9255
|
if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
|
|
9247
9256
|
return subsequenceScore(path109, needle);
|
|
9248
9257
|
}
|
|
@@ -12501,6 +12510,364 @@ async function nodeDoctor(req, res) {
|
|
|
12501
12510
|
respondJson(res, 200, { hop: await firstBrokenHop(link3) ?? null });
|
|
12502
12511
|
}
|
|
12503
12512
|
|
|
12513
|
+
// src/commands/testflight/addToBetaGroup.ts
|
|
12514
|
+
async function addToBetaGroup(client, groupId, email) {
|
|
12515
|
+
const inGroup = await client.get("/v1/betaTesters", {
|
|
12516
|
+
"filter[email]": email,
|
|
12517
|
+
"filter[betaGroups]": groupId,
|
|
12518
|
+
limit: "1"
|
|
12519
|
+
});
|
|
12520
|
+
if (inGroup.data.length > 0) return "already-in-group";
|
|
12521
|
+
const existing = await client.get("/v1/betaTesters", {
|
|
12522
|
+
"filter[email]": email,
|
|
12523
|
+
limit: "1"
|
|
12524
|
+
});
|
|
12525
|
+
const tester = existing.data[0];
|
|
12526
|
+
if (tester) {
|
|
12527
|
+
await client.post(`/v1/betaGroups/${groupId}/relationships/betaTesters`, {
|
|
12528
|
+
data: [{ type: "betaTesters", id: tester.id }]
|
|
12529
|
+
});
|
|
12530
|
+
return "added";
|
|
12531
|
+
}
|
|
12532
|
+
await client.post("/v1/betaTesters", {
|
|
12533
|
+
data: {
|
|
12534
|
+
type: "betaTesters",
|
|
12535
|
+
attributes: { email },
|
|
12536
|
+
relationships: {
|
|
12537
|
+
betaGroups: { data: [{ type: "betaGroups", id: groupId }] }
|
|
12538
|
+
}
|
|
12539
|
+
}
|
|
12540
|
+
});
|
|
12541
|
+
return "created";
|
|
12542
|
+
}
|
|
12543
|
+
|
|
12544
|
+
// src/commands/testflight/nameFromEmail.ts
|
|
12545
|
+
function capitalise(word) {
|
|
12546
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
12547
|
+
}
|
|
12548
|
+
function nameFromEmail(email) {
|
|
12549
|
+
const [first = email, ...rest] = email.split("@")[0].split(/[._+-]+/).filter(Boolean).map(capitalise);
|
|
12550
|
+
return { firstName: first, lastName: rest.join(" ") || "Tester" };
|
|
12551
|
+
}
|
|
12552
|
+
|
|
12553
|
+
// src/commands/testflight/inviteTeamMember.ts
|
|
12554
|
+
async function inviteTeamMember(client, appId, email) {
|
|
12555
|
+
const { firstName, lastName } = nameFromEmail(email);
|
|
12556
|
+
await client.post("/v1/userInvitations", {
|
|
12557
|
+
data: {
|
|
12558
|
+
type: "userInvitations",
|
|
12559
|
+
attributes: {
|
|
12560
|
+
email,
|
|
12561
|
+
firstName,
|
|
12562
|
+
lastName,
|
|
12563
|
+
roles: ["DEVELOPER"],
|
|
12564
|
+
allAppsVisible: false,
|
|
12565
|
+
provisioningAllowed: false
|
|
12566
|
+
},
|
|
12567
|
+
relationships: {
|
|
12568
|
+
visibleApps: { data: [{ type: "apps", id: appId }] }
|
|
12569
|
+
}
|
|
12570
|
+
}
|
|
12571
|
+
});
|
|
12572
|
+
}
|
|
12573
|
+
|
|
12574
|
+
// src/commands/testflight/addInternalTester.ts
|
|
12575
|
+
async function hasMatch(client, path109, params, attribute, email) {
|
|
12576
|
+
const { data } = await client.get(path109, params);
|
|
12577
|
+
return data.some(
|
|
12578
|
+
(item) => String(item.attributes?.[attribute]).toLowerCase() === email.toLowerCase()
|
|
12579
|
+
);
|
|
12580
|
+
}
|
|
12581
|
+
async function addInternalTester(client, target, email) {
|
|
12582
|
+
const isMember = await hasMatch(
|
|
12583
|
+
client,
|
|
12584
|
+
"/v1/users",
|
|
12585
|
+
{ "filter[username]": email, "fields[users]": "username" },
|
|
12586
|
+
"username",
|
|
12587
|
+
email
|
|
12588
|
+
);
|
|
12589
|
+
if (isMember) return addToBetaGroup(client, target.groupId, email);
|
|
12590
|
+
const isInvited = await hasMatch(
|
|
12591
|
+
client,
|
|
12592
|
+
"/v1/userInvitations",
|
|
12593
|
+
{ "filter[email]": email, "fields[userInvitations]": "email" },
|
|
12594
|
+
"email",
|
|
12595
|
+
email
|
|
12596
|
+
);
|
|
12597
|
+
if (isInvited) return "invite-pending";
|
|
12598
|
+
await inviteTeamMember(client, target.appId, email);
|
|
12599
|
+
return "invited";
|
|
12600
|
+
}
|
|
12601
|
+
|
|
12602
|
+
// src/commands/testflight/formatAscError.ts
|
|
12603
|
+
var statusHints = {
|
|
12604
|
+
401: "Check testflight.keyId, testflight.issuerId and that testflight.keyRef points at the matching .p8.",
|
|
12605
|
+
403: "The App Store Connect API key may lack the role this action needs (team invitations need Admin)."
|
|
12606
|
+
};
|
|
12607
|
+
function parseErrors(body) {
|
|
12608
|
+
try {
|
|
12609
|
+
const parsed = JSON.parse(body);
|
|
12610
|
+
return (parsed.errors ?? []).map(
|
|
12611
|
+
(error) => [error.title, error.detail].filter(Boolean).join(": ")
|
|
12612
|
+
);
|
|
12613
|
+
} catch {
|
|
12614
|
+
return body ? [body] : [];
|
|
12615
|
+
}
|
|
12616
|
+
}
|
|
12617
|
+
function formatAscError(method, path109, status2, body) {
|
|
12618
|
+
const lines = [
|
|
12619
|
+
`App Store Connect ${method} ${path109} failed (${status2})`,
|
|
12620
|
+
...parseErrors(body).map((line) => ` ${line}`)
|
|
12621
|
+
];
|
|
12622
|
+
const hint = statusHints[status2];
|
|
12623
|
+
if (hint) lines.push(hint);
|
|
12624
|
+
return lines.join("\n");
|
|
12625
|
+
}
|
|
12626
|
+
|
|
12627
|
+
// src/commands/testflight/TestflightError.ts
|
|
12628
|
+
var TestflightError = class extends Error {
|
|
12629
|
+
name = "TestflightError";
|
|
12630
|
+
};
|
|
12631
|
+
|
|
12632
|
+
// src/commands/testflight/ascRequest.ts
|
|
12633
|
+
var BASE_URL = "https://api.appstoreconnect.apple.com";
|
|
12634
|
+
async function send(fetchFn, token, method, path109, body) {
|
|
12635
|
+
try {
|
|
12636
|
+
return await fetchFn(`${BASE_URL}${path109}`, {
|
|
12637
|
+
method,
|
|
12638
|
+
headers: {
|
|
12639
|
+
Authorization: `Bearer ${token}`,
|
|
12640
|
+
Accept: "application/json",
|
|
12641
|
+
...body === void 0 ? {} : { "Content-Type": "application/json" }
|
|
12642
|
+
},
|
|
12643
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
12644
|
+
});
|
|
12645
|
+
} catch (error) {
|
|
12646
|
+
const reason4 = error instanceof Error ? error.message : String(error);
|
|
12647
|
+
throw new TestflightError(`Failed to reach App Store Connect: ${reason4}`);
|
|
12648
|
+
}
|
|
12649
|
+
}
|
|
12650
|
+
async function ascRequest(fetchFn, token, method, path109, body) {
|
|
12651
|
+
const response = await send(fetchFn, token, method, path109, body);
|
|
12652
|
+
const text20 = await response.text();
|
|
12653
|
+
if (!response.ok) {
|
|
12654
|
+
throw new TestflightError(
|
|
12655
|
+
formatAscError(method, path109.split("?")[0], response.status, text20)
|
|
12656
|
+
);
|
|
12657
|
+
}
|
|
12658
|
+
return text20 ? JSON.parse(text20) : void 0;
|
|
12659
|
+
}
|
|
12660
|
+
|
|
12661
|
+
// src/commands/testflight/createAscClient.ts
|
|
12662
|
+
function createAscClient(token, fetchFn = fetch) {
|
|
12663
|
+
return {
|
|
12664
|
+
get: (path109, params) => {
|
|
12665
|
+
const query = params ? `?${new URLSearchParams(params)}` : "";
|
|
12666
|
+
return ascRequest(fetchFn, token, "GET", `${path109}${query}`);
|
|
12667
|
+
},
|
|
12668
|
+
post: (path109, body) => ascRequest(fetchFn, token, "POST", path109, body)
|
|
12669
|
+
};
|
|
12670
|
+
}
|
|
12671
|
+
|
|
12672
|
+
// src/commands/testflight/createAscToken.ts
|
|
12673
|
+
import { createPrivateKey, sign } from "crypto";
|
|
12674
|
+
var TOKEN_LIFETIME_SECONDS = 20 * 60;
|
|
12675
|
+
function base64url(value) {
|
|
12676
|
+
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
12677
|
+
}
|
|
12678
|
+
function createAscToken(options2) {
|
|
12679
|
+
const iat = Math.floor((options2.now ?? Date.now()) / 1e3);
|
|
12680
|
+
const header = { alg: "ES256", kid: options2.keyId, typ: "JWT" };
|
|
12681
|
+
const payload = {
|
|
12682
|
+
iss: options2.issuerId,
|
|
12683
|
+
iat,
|
|
12684
|
+
exp: iat + TOKEN_LIFETIME_SECONDS,
|
|
12685
|
+
aud: "appstoreconnect-v1"
|
|
12686
|
+
};
|
|
12687
|
+
const signingInput = `${base64url(header)}.${base64url(payload)}`;
|
|
12688
|
+
const signature = sign("sha256", Buffer.from(signingInput), {
|
|
12689
|
+
key: createPrivateKey(options2.privateKey),
|
|
12690
|
+
dsaEncoding: "ieee-p1363"
|
|
12691
|
+
});
|
|
12692
|
+
return `${signingInput}.${signature.toString("base64url")}`;
|
|
12693
|
+
}
|
|
12694
|
+
|
|
12695
|
+
// src/commands/testflight/findAppId.ts
|
|
12696
|
+
async function findAppId(client, bundleId) {
|
|
12697
|
+
const { data } = await client.get("/v1/apps", {
|
|
12698
|
+
"filter[bundleId]": bundleId,
|
|
12699
|
+
"fields[apps]": "bundleId"
|
|
12700
|
+
});
|
|
12701
|
+
const app = data.find((item) => item.attributes?.bundleId === bundleId);
|
|
12702
|
+
if (!app) {
|
|
12703
|
+
throw new TestflightError(
|
|
12704
|
+
`No App Store Connect app has bundle id ${bundleId} (testflight.bundleId)`
|
|
12705
|
+
);
|
|
12706
|
+
}
|
|
12707
|
+
return app.id;
|
|
12708
|
+
}
|
|
12709
|
+
|
|
12710
|
+
// src/commands/testflight/readAscKey.ts
|
|
12711
|
+
import { execFile as execFile9 } from "child_process";
|
|
12712
|
+
import { promisify as promisify10 } from "util";
|
|
12713
|
+
var run = promisify10(execFile9);
|
|
12714
|
+
async function readAscKey(reference) {
|
|
12715
|
+
if (!reference.startsWith("op://"))
|
|
12716
|
+
throw new TestflightError(
|
|
12717
|
+
"testflight.keyRef must be a 1Password reference starting with op://"
|
|
12718
|
+
);
|
|
12719
|
+
try {
|
|
12720
|
+
const { stdout } = await run("op", ["read", reference]);
|
|
12721
|
+
return stdout.trim();
|
|
12722
|
+
} catch (error) {
|
|
12723
|
+
const reason4 = error.stderr?.trim() || (error instanceof Error ? error.message : String(error));
|
|
12724
|
+
throw new TestflightError(
|
|
12725
|
+
`Failed to read testflight.keyRef from 1Password (is op installed and signed in?): ${reason4}`
|
|
12726
|
+
);
|
|
12727
|
+
}
|
|
12728
|
+
}
|
|
12729
|
+
|
|
12730
|
+
// src/commands/testflight/connectAsc.ts
|
|
12731
|
+
async function connectAsc(config, options2 = {}) {
|
|
12732
|
+
const privateKey = await (options2.readKey ?? readAscKey)(config.keyRef);
|
|
12733
|
+
const token = createAscToken({
|
|
12734
|
+
keyId: config.keyId,
|
|
12735
|
+
issuerId: config.issuerId,
|
|
12736
|
+
privateKey
|
|
12737
|
+
});
|
|
12738
|
+
const client = createAscClient(token, options2.fetchFn);
|
|
12739
|
+
return { client, appId: await findAppId(client, config.bundleId) };
|
|
12740
|
+
}
|
|
12741
|
+
|
|
12742
|
+
// src/commands/testflight/findBetaGroupId.ts
|
|
12743
|
+
async function findBetaGroupId(client, appId, lookup) {
|
|
12744
|
+
const { data } = await client.get(`/v1/apps/${appId}/betaGroups`, {
|
|
12745
|
+
"fields[betaGroups]": "name,isInternalGroup",
|
|
12746
|
+
limit: "200"
|
|
12747
|
+
});
|
|
12748
|
+
const group = data.find((item) => item.attributes?.name === lookup.name);
|
|
12749
|
+
if (!group) {
|
|
12750
|
+
const available = data.map((item) => String(item.attributes?.name)).join(", ");
|
|
12751
|
+
throw new TestflightError(
|
|
12752
|
+
`No beta group named "${lookup.name}" (${lookup.configKey}). Available groups: ${available || "none"}`
|
|
12753
|
+
);
|
|
12754
|
+
}
|
|
12755
|
+
if (Boolean(group.attributes?.isInternalGroup) !== lookup.internal) {
|
|
12756
|
+
const kind = lookup.internal ? "an internal" : "an external";
|
|
12757
|
+
throw new TestflightError(
|
|
12758
|
+
`Beta group "${lookup.name}" (${lookup.configKey}) must be ${kind} group`
|
|
12759
|
+
);
|
|
12760
|
+
}
|
|
12761
|
+
return group.id;
|
|
12762
|
+
}
|
|
12763
|
+
|
|
12764
|
+
// src/commands/testflight/requireInternalGroup.ts
|
|
12765
|
+
function requireInternalGroup(config) {
|
|
12766
|
+
if (config.internalGroup) return config.internalGroup;
|
|
12767
|
+
const entry = testflightConfigHelp.find(
|
|
12768
|
+
(help) => help.key === "testflight.internalGroup"
|
|
12769
|
+
);
|
|
12770
|
+
throw new TestflightError(
|
|
12771
|
+
`testflight.internalGroup is not set. Set it with: ${entry?.setter}`
|
|
12772
|
+
);
|
|
12773
|
+
}
|
|
12774
|
+
|
|
12775
|
+
// src/commands/testflight/addTester.ts
|
|
12776
|
+
async function addTester(config, email, options2 = {}) {
|
|
12777
|
+
const internalGroup = options2.internal ? requireInternalGroup(config) : void 0;
|
|
12778
|
+
const { client, appId } = await connectAsc(config, options2);
|
|
12779
|
+
const groupId = await findBetaGroupId(client, appId, {
|
|
12780
|
+
name: internalGroup ?? config.externalGroup,
|
|
12781
|
+
configKey: internalGroup ? "testflight.internalGroup" : "testflight.externalGroup",
|
|
12782
|
+
internal: Boolean(internalGroup)
|
|
12783
|
+
});
|
|
12784
|
+
return internalGroup ? addInternalTester(client, { appId, groupId }, email) : addToBetaGroup(client, groupId, email);
|
|
12785
|
+
}
|
|
12786
|
+
|
|
12787
|
+
// src/commands/testflight/addTesterOutcome.ts
|
|
12788
|
+
var messages = {
|
|
12789
|
+
created: (email, group) => `Invited ${email} to TestFlight group "${group}"`,
|
|
12790
|
+
added: (email, group) => `Added existing tester ${email} to TestFlight group "${group}"`,
|
|
12791
|
+
"already-in-group": (email, group) => `${email} is already in TestFlight group "${group}"`,
|
|
12792
|
+
invited: (email) => `Sent ${email} an App Store Connect team invite. Once they accept, add them again to put them in TestFlight.`,
|
|
12793
|
+
"invite-pending": (email) => `${email} has not yet accepted their App Store Connect team invite. Add them again once they do.`
|
|
12794
|
+
};
|
|
12795
|
+
var waitingResults = /* @__PURE__ */ new Set([
|
|
12796
|
+
"already-in-group",
|
|
12797
|
+
"invite-pending"
|
|
12798
|
+
]);
|
|
12799
|
+
async function addTesterOutcome(config, email, options2 = {}) {
|
|
12800
|
+
const result = await addTester(config, email, options2);
|
|
12801
|
+
const group = options2.internal ? config.internalGroup ?? "" : config.externalGroup;
|
|
12802
|
+
return {
|
|
12803
|
+
result,
|
|
12804
|
+
message: messages[result](email, group),
|
|
12805
|
+
waiting: waitingResults.has(result)
|
|
12806
|
+
};
|
|
12807
|
+
}
|
|
12808
|
+
|
|
12809
|
+
// src/commands/testflight/readTestflightConfig.ts
|
|
12810
|
+
var requiredKeys = [
|
|
12811
|
+
"keyId",
|
|
12812
|
+
"issuerId",
|
|
12813
|
+
"keyRef",
|
|
12814
|
+
"bundleId",
|
|
12815
|
+
"externalGroup"
|
|
12816
|
+
];
|
|
12817
|
+
function readTestflightConfig(config) {
|
|
12818
|
+
const testflight = config.testflight ?? {};
|
|
12819
|
+
const missing = requiredKeys.filter((key) => !testflight[key]);
|
|
12820
|
+
if (missing.length > 0) {
|
|
12821
|
+
const lines = missing.map((key) => {
|
|
12822
|
+
const entry = testflightConfigHelp.find(
|
|
12823
|
+
(help) => help.key === `testflight.${key}`
|
|
12824
|
+
);
|
|
12825
|
+
return ` testflight.${key} is not set. Set it with: ${entry?.setter}`;
|
|
12826
|
+
});
|
|
12827
|
+
throw new TestflightError(
|
|
12828
|
+
["TestFlight is not configured", ...lines].join("\n")
|
|
12829
|
+
);
|
|
12830
|
+
}
|
|
12831
|
+
return testflight;
|
|
12832
|
+
}
|
|
12833
|
+
|
|
12834
|
+
// src/commands/sessions/web/parseAddTesterRequest.ts
|
|
12835
|
+
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
12836
|
+
async function parseAddTesterRequest(req) {
|
|
12837
|
+
let body;
|
|
12838
|
+
try {
|
|
12839
|
+
body = await readJsonBody(req) ?? {};
|
|
12840
|
+
} catch {
|
|
12841
|
+
return { ok: false, error: "Invalid JSON body" };
|
|
12842
|
+
}
|
|
12843
|
+
const email = typeof body.email === "string" ? body.email.trim() : "";
|
|
12844
|
+
if (!EMAIL_PATTERN.test(email))
|
|
12845
|
+
return { ok: false, error: "email must be a valid email address" };
|
|
12846
|
+
if (body.internal !== void 0 && typeof body.internal !== "boolean")
|
|
12847
|
+
return { ok: false, error: "internal must be a boolean" };
|
|
12848
|
+
return { ok: true, email, internal: body.internal ?? false };
|
|
12849
|
+
}
|
|
12850
|
+
|
|
12851
|
+
// src/commands/sessions/web/postTestflightTester.ts
|
|
12852
|
+
async function postTestflightTester(req, res) {
|
|
12853
|
+
const parsed = await parseAddTesterRequest(req);
|
|
12854
|
+
if (!parsed.ok) {
|
|
12855
|
+
respondJson(res, 400, { error: parsed.error });
|
|
12856
|
+
return;
|
|
12857
|
+
}
|
|
12858
|
+
try {
|
|
12859
|
+
const config = readTestflightConfig(loadConfig());
|
|
12860
|
+
const outcome = await addTesterOutcome(config, parsed.email, {
|
|
12861
|
+
internal: parsed.internal
|
|
12862
|
+
});
|
|
12863
|
+
respondJson(res, 200, outcome);
|
|
12864
|
+
} catch (error) {
|
|
12865
|
+
respondJson(res, 500, {
|
|
12866
|
+
error: error instanceof Error ? error.message : "Failed to add tester"
|
|
12867
|
+
});
|
|
12868
|
+
}
|
|
12869
|
+
}
|
|
12870
|
+
|
|
12504
12871
|
// src/commands/config/configScopeNames.ts
|
|
12505
12872
|
var configScopeNames = {
|
|
12506
12873
|
project: "repo (git)",
|
|
@@ -13015,168 +13382,6 @@ function setConfig(req, res) {
|
|
|
13015
13382
|
});
|
|
13016
13383
|
}
|
|
13017
13384
|
|
|
13018
|
-
// src/commands/testflight/formatAscError.ts
|
|
13019
|
-
var statusHints = {
|
|
13020
|
-
401: "Check testflight.keyId, testflight.issuerId and that testflight.keyRef points at the matching .p8.",
|
|
13021
|
-
403: "The App Store Connect API key may lack the role this action needs (team invitations need Admin)."
|
|
13022
|
-
};
|
|
13023
|
-
function parseErrors(body) {
|
|
13024
|
-
try {
|
|
13025
|
-
const parsed = JSON.parse(body);
|
|
13026
|
-
return (parsed.errors ?? []).map(
|
|
13027
|
-
(error) => [error.title, error.detail].filter(Boolean).join(": ")
|
|
13028
|
-
);
|
|
13029
|
-
} catch {
|
|
13030
|
-
return body ? [body] : [];
|
|
13031
|
-
}
|
|
13032
|
-
}
|
|
13033
|
-
function formatAscError(method, path109, status2, body) {
|
|
13034
|
-
const lines = [
|
|
13035
|
-
`App Store Connect ${method} ${path109} failed (${status2})`,
|
|
13036
|
-
...parseErrors(body).map((line) => ` ${line}`)
|
|
13037
|
-
];
|
|
13038
|
-
const hint = statusHints[status2];
|
|
13039
|
-
if (hint) lines.push(hint);
|
|
13040
|
-
return lines.join("\n");
|
|
13041
|
-
}
|
|
13042
|
-
|
|
13043
|
-
// src/commands/testflight/TestflightError.ts
|
|
13044
|
-
var TestflightError = class extends Error {
|
|
13045
|
-
name = "TestflightError";
|
|
13046
|
-
};
|
|
13047
|
-
|
|
13048
|
-
// src/commands/testflight/ascRequest.ts
|
|
13049
|
-
var BASE_URL = "https://api.appstoreconnect.apple.com";
|
|
13050
|
-
async function send(fetchFn, token, method, path109, body) {
|
|
13051
|
-
try {
|
|
13052
|
-
return await fetchFn(`${BASE_URL}${path109}`, {
|
|
13053
|
-
method,
|
|
13054
|
-
headers: {
|
|
13055
|
-
Authorization: `Bearer ${token}`,
|
|
13056
|
-
Accept: "application/json",
|
|
13057
|
-
...body === void 0 ? {} : { "Content-Type": "application/json" }
|
|
13058
|
-
},
|
|
13059
|
-
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
13060
|
-
});
|
|
13061
|
-
} catch (error) {
|
|
13062
|
-
const reason4 = error instanceof Error ? error.message : String(error);
|
|
13063
|
-
throw new TestflightError(`Failed to reach App Store Connect: ${reason4}`);
|
|
13064
|
-
}
|
|
13065
|
-
}
|
|
13066
|
-
async function ascRequest(fetchFn, token, method, path109, body) {
|
|
13067
|
-
const response = await send(fetchFn, token, method, path109, body);
|
|
13068
|
-
const text20 = await response.text();
|
|
13069
|
-
if (!response.ok) {
|
|
13070
|
-
throw new TestflightError(
|
|
13071
|
-
formatAscError(method, path109.split("?")[0], response.status, text20)
|
|
13072
|
-
);
|
|
13073
|
-
}
|
|
13074
|
-
return text20 ? JSON.parse(text20) : void 0;
|
|
13075
|
-
}
|
|
13076
|
-
|
|
13077
|
-
// src/commands/testflight/createAscClient.ts
|
|
13078
|
-
function createAscClient(token, fetchFn = fetch) {
|
|
13079
|
-
return {
|
|
13080
|
-
get: (path109, params) => {
|
|
13081
|
-
const query = params ? `?${new URLSearchParams(params)}` : "";
|
|
13082
|
-
return ascRequest(fetchFn, token, "GET", `${path109}${query}`);
|
|
13083
|
-
},
|
|
13084
|
-
post: (path109, body) => ascRequest(fetchFn, token, "POST", path109, body)
|
|
13085
|
-
};
|
|
13086
|
-
}
|
|
13087
|
-
|
|
13088
|
-
// src/commands/testflight/createAscToken.ts
|
|
13089
|
-
import { createPrivateKey, sign } from "crypto";
|
|
13090
|
-
var TOKEN_LIFETIME_SECONDS = 20 * 60;
|
|
13091
|
-
function base64url(value) {
|
|
13092
|
-
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
13093
|
-
}
|
|
13094
|
-
function createAscToken(options2) {
|
|
13095
|
-
const iat = Math.floor((options2.now ?? Date.now()) / 1e3);
|
|
13096
|
-
const header = { alg: "ES256", kid: options2.keyId, typ: "JWT" };
|
|
13097
|
-
const payload = {
|
|
13098
|
-
iss: options2.issuerId,
|
|
13099
|
-
iat,
|
|
13100
|
-
exp: iat + TOKEN_LIFETIME_SECONDS,
|
|
13101
|
-
aud: "appstoreconnect-v1"
|
|
13102
|
-
};
|
|
13103
|
-
const signingInput = `${base64url(header)}.${base64url(payload)}`;
|
|
13104
|
-
const signature = sign("sha256", Buffer.from(signingInput), {
|
|
13105
|
-
key: createPrivateKey(options2.privateKey),
|
|
13106
|
-
dsaEncoding: "ieee-p1363"
|
|
13107
|
-
});
|
|
13108
|
-
return `${signingInput}.${signature.toString("base64url")}`;
|
|
13109
|
-
}
|
|
13110
|
-
|
|
13111
|
-
// src/commands/testflight/findAppId.ts
|
|
13112
|
-
async function findAppId(client, bundleId) {
|
|
13113
|
-
const { data } = await client.get("/v1/apps", {
|
|
13114
|
-
"filter[bundleId]": bundleId,
|
|
13115
|
-
"fields[apps]": "bundleId"
|
|
13116
|
-
});
|
|
13117
|
-
const app = data.find((item) => item.attributes?.bundleId === bundleId);
|
|
13118
|
-
if (!app) {
|
|
13119
|
-
throw new TestflightError(
|
|
13120
|
-
`No App Store Connect app has bundle id ${bundleId} (testflight.bundleId)`
|
|
13121
|
-
);
|
|
13122
|
-
}
|
|
13123
|
-
return app.id;
|
|
13124
|
-
}
|
|
13125
|
-
|
|
13126
|
-
// src/commands/testflight/readAscKey.ts
|
|
13127
|
-
import { execFile as execFile9 } from "child_process";
|
|
13128
|
-
import { promisify as promisify10 } from "util";
|
|
13129
|
-
var run = promisify10(execFile9);
|
|
13130
|
-
async function readAscKey(reference) {
|
|
13131
|
-
if (!reference.startsWith("op://"))
|
|
13132
|
-
throw new TestflightError(
|
|
13133
|
-
"testflight.keyRef must be a 1Password reference starting with op://"
|
|
13134
|
-
);
|
|
13135
|
-
try {
|
|
13136
|
-
const { stdout } = await run("op", ["read", reference]);
|
|
13137
|
-
return stdout.trim();
|
|
13138
|
-
} catch (error) {
|
|
13139
|
-
const reason4 = error.stderr?.trim() || (error instanceof Error ? error.message : String(error));
|
|
13140
|
-
throw new TestflightError(
|
|
13141
|
-
`Failed to read testflight.keyRef from 1Password (is op installed and signed in?): ${reason4}`
|
|
13142
|
-
);
|
|
13143
|
-
}
|
|
13144
|
-
}
|
|
13145
|
-
|
|
13146
|
-
// src/commands/testflight/connectAsc.ts
|
|
13147
|
-
async function connectAsc(config, options2 = {}) {
|
|
13148
|
-
const privateKey = await (options2.readKey ?? readAscKey)(config.keyRef);
|
|
13149
|
-
const token = createAscToken({
|
|
13150
|
-
keyId: config.keyId,
|
|
13151
|
-
issuerId: config.issuerId,
|
|
13152
|
-
privateKey
|
|
13153
|
-
});
|
|
13154
|
-
const client = createAscClient(token, options2.fetchFn);
|
|
13155
|
-
return { client, appId: await findAppId(client, config.bundleId) };
|
|
13156
|
-
}
|
|
13157
|
-
|
|
13158
|
-
// src/commands/testflight/findBetaGroupId.ts
|
|
13159
|
-
async function findBetaGroupId(client, appId, lookup) {
|
|
13160
|
-
const { data } = await client.get(`/v1/apps/${appId}/betaGroups`, {
|
|
13161
|
-
"fields[betaGroups]": "name,isInternalGroup",
|
|
13162
|
-
limit: "200"
|
|
13163
|
-
});
|
|
13164
|
-
const group = data.find((item) => item.attributes?.name === lookup.name);
|
|
13165
|
-
if (!group) {
|
|
13166
|
-
const available = data.map((item) => String(item.attributes?.name)).join(", ");
|
|
13167
|
-
throw new TestflightError(
|
|
13168
|
-
`No beta group named "${lookup.name}" (${lookup.configKey}). Available groups: ${available || "none"}`
|
|
13169
|
-
);
|
|
13170
|
-
}
|
|
13171
|
-
if (Boolean(group.attributes?.isInternalGroup) !== lookup.internal) {
|
|
13172
|
-
const kind = lookup.internal ? "an internal" : "an external";
|
|
13173
|
-
throw new TestflightError(
|
|
13174
|
-
`Beta group "${lookup.name}" (${lookup.configKey}) must be ${kind} group`
|
|
13175
|
-
);
|
|
13176
|
-
}
|
|
13177
|
-
return group.id;
|
|
13178
|
-
}
|
|
13179
|
-
|
|
13180
13385
|
// src/commands/testflight/listAppTeam.ts
|
|
13181
13386
|
function seesApp(item, appId) {
|
|
13182
13387
|
if (item.attributes?.allAppsVisible) return true;
|
|
@@ -13282,31 +13487,6 @@ async function listTesters(config, options2 = {}) {
|
|
|
13282
13487
|
return { bundleId: config.bundleId, internal, external };
|
|
13283
13488
|
}
|
|
13284
13489
|
|
|
13285
|
-
// src/commands/testflight/readTestflightConfig.ts
|
|
13286
|
-
var requiredKeys = [
|
|
13287
|
-
"keyId",
|
|
13288
|
-
"issuerId",
|
|
13289
|
-
"keyRef",
|
|
13290
|
-
"bundleId",
|
|
13291
|
-
"externalGroup"
|
|
13292
|
-
];
|
|
13293
|
-
function readTestflightConfig(config) {
|
|
13294
|
-
const testflight = config.testflight ?? {};
|
|
13295
|
-
const missing = requiredKeys.filter((key) => !testflight[key]);
|
|
13296
|
-
if (missing.length > 0) {
|
|
13297
|
-
const lines = missing.map((key) => {
|
|
13298
|
-
const entry = testflightConfigHelp.find(
|
|
13299
|
-
(help) => help.key === `testflight.${key}`
|
|
13300
|
-
);
|
|
13301
|
-
return ` testflight.${key} is not set. Set it with: ${entry?.setter}`;
|
|
13302
|
-
});
|
|
13303
|
-
throw new TestflightError(
|
|
13304
|
-
["TestFlight is not configured", ...lines].join("\n")
|
|
13305
|
-
);
|
|
13306
|
-
}
|
|
13307
|
-
return testflight;
|
|
13308
|
-
}
|
|
13309
|
-
|
|
13310
13490
|
// src/commands/sessions/web/testflightTesters.ts
|
|
13311
13491
|
async function testflightTesters(_req, res) {
|
|
13312
13492
|
try {
|
|
@@ -13854,6 +14034,49 @@ async function updatesControl(req, res) {
|
|
|
13854
14034
|
respondJson(res, 200, { ok: true });
|
|
13855
14035
|
}
|
|
13856
14036
|
|
|
14037
|
+
// src/commands/sessions/web/updates/requestViaLink.ts
|
|
14038
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
14039
|
+
var LINK_REPLY_TIMEOUT_MS = 8e3;
|
|
14040
|
+
function requestViaLink(req, type) {
|
|
14041
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
14042
|
+
const node = url.searchParams.get("node") ?? void 0;
|
|
14043
|
+
return requestDaemonReply(
|
|
14044
|
+
{ type, node, requestId: randomUUID3() },
|
|
14045
|
+
type,
|
|
14046
|
+
LINK_REPLY_TIMEOUT_MS
|
|
14047
|
+
);
|
|
14048
|
+
}
|
|
14049
|
+
|
|
14050
|
+
// src/commands/sessions/web/updates/linkUpdateStatus.ts
|
|
14051
|
+
async function linkUpdateStatus(req, res) {
|
|
14052
|
+
const reply2 = await requestViaLink(req, "auto-update");
|
|
14053
|
+
if (!reply2) {
|
|
14054
|
+
respondJson(res, 503, { error: "Daemon link did not answer" });
|
|
14055
|
+
return;
|
|
14056
|
+
}
|
|
14057
|
+
respondJson(res, 200, reply2);
|
|
14058
|
+
}
|
|
14059
|
+
|
|
14060
|
+
// src/commands/sessions/web/updates/restartWebViaLink.ts
|
|
14061
|
+
async function restartWebViaLink(req, res) {
|
|
14062
|
+
const node = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
14063
|
+
"node"
|
|
14064
|
+
);
|
|
14065
|
+
console.log(
|
|
14066
|
+
`restart webserver of ${node ?? "this node"} via daemon link ${linkedRequester(req)}`
|
|
14067
|
+
);
|
|
14068
|
+
const reply2 = await requestViaLink(req, "restart-webserver");
|
|
14069
|
+
if (!reply2) {
|
|
14070
|
+
respondJson(res, 503, { error: "Daemon link did not answer" });
|
|
14071
|
+
return;
|
|
14072
|
+
}
|
|
14073
|
+
if (!reply2.ok) {
|
|
14074
|
+
respondJson(res, 409, { error: reply2.error ?? "restart failed" });
|
|
14075
|
+
return;
|
|
14076
|
+
}
|
|
14077
|
+
respondJson(res, 200, { ok: true });
|
|
14078
|
+
}
|
|
14079
|
+
|
|
13857
14080
|
// src/commands/sessions/web/readRequestBuffer.ts
|
|
13858
14081
|
async function readRequestBuffer(req, limit) {
|
|
13859
14082
|
const chunks = [];
|
|
@@ -14200,8 +14423,11 @@ var routes2 = {
|
|
|
14200
14423
|
"POST /api/config/unset": unsetConfig,
|
|
14201
14424
|
"GET /api/review/synthesis": getReviewSynthesis,
|
|
14202
14425
|
"GET /api/testflight/testers": testflightTesters,
|
|
14426
|
+
"POST /api/testflight/testers": postTestflightTester,
|
|
14203
14427
|
"GET /api/updates": updates,
|
|
14204
|
-
"POST /api/updates/control": updatesControl
|
|
14428
|
+
"POST /api/updates/control": updatesControl,
|
|
14429
|
+
[`GET ${LINK_UPDATE_STATUS_PATH}`]: linkUpdateStatus,
|
|
14430
|
+
[`POST ${RESTART_WEB_VIA_LINK_PATH}`]: restartWebViaLink
|
|
14205
14431
|
};
|
|
14206
14432
|
var handleRequest = createFallbackHandler(
|
|
14207
14433
|
routes2,
|
|
@@ -14442,7 +14668,7 @@ async function connect2() {
|
|
|
14442
14668
|
const socket = await connectToDaemon();
|
|
14443
14669
|
wire(socket);
|
|
14444
14670
|
socket.write(
|
|
14445
|
-
`${JSON.stringify({ type: "subscribe-logs", replay: false })}
|
|
14671
|
+
`${JSON.stringify({ type: "subscribe-logs", replay: false, webServer: true })}
|
|
14446
14672
|
`
|
|
14447
14673
|
);
|
|
14448
14674
|
} catch {
|
|
@@ -14463,6 +14689,10 @@ function emit(line) {
|
|
|
14463
14689
|
const data = JSON.parse(line);
|
|
14464
14690
|
if (data.type === "log" && typeof data.line === "string")
|
|
14465
14691
|
console.log(data.line);
|
|
14692
|
+
if (data.type === "restart-webserver") {
|
|
14693
|
+
console.log("restart webserver requested by the daemon");
|
|
14694
|
+
reExecWebServer();
|
|
14695
|
+
}
|
|
14466
14696
|
} catch {
|
|
14467
14697
|
}
|
|
14468
14698
|
}
|
|
@@ -16020,13 +16250,30 @@ function resolveEntries() {
|
|
|
16020
16250
|
|
|
16021
16251
|
// src/commands/verify/run/spawnCommand.ts
|
|
16022
16252
|
import { spawn as spawn4 } from "child_process";
|
|
16253
|
+
|
|
16254
|
+
// src/lib/isClaudeCode.ts
|
|
16255
|
+
function isClaudeCode() {
|
|
16256
|
+
return process.env.CLAUDECODE !== void 0;
|
|
16257
|
+
}
|
|
16258
|
+
|
|
16259
|
+
// src/lib/isCodex.ts
|
|
16260
|
+
function isCodex() {
|
|
16261
|
+
return process.env.CODEX_TOOL_CALL_ID !== void 0 || process.env.CODEX_THREAD_ID !== void 0;
|
|
16262
|
+
}
|
|
16263
|
+
|
|
16264
|
+
// src/lib/isAgentHarness.ts
|
|
16265
|
+
function isAgentHarness() {
|
|
16266
|
+
return isClaudeCode() || isCodex();
|
|
16267
|
+
}
|
|
16268
|
+
|
|
16269
|
+
// src/commands/verify/run/spawnCommand.ts
|
|
16023
16270
|
var verboseMode = false;
|
|
16024
16271
|
function setVerbose(verbose) {
|
|
16025
16272
|
verboseMode = verbose;
|
|
16026
16273
|
}
|
|
16027
16274
|
function shouldSuppress(quiet) {
|
|
16028
16275
|
if (verboseMode) return false;
|
|
16029
|
-
return !!quiet ||
|
|
16276
|
+
return !!quiet || isAgentHarness();
|
|
16030
16277
|
}
|
|
16031
16278
|
function spawnCommand(fullCommand, cwd, env, quiet) {
|
|
16032
16279
|
return spawn4(fullCommand, [], {
|
|
@@ -16808,7 +17055,7 @@ function internalCommand(command, calledBy5) {
|
|
|
16808
17055
|
}
|
|
16809
17056
|
|
|
16810
17057
|
// src/commands/ask.ts
|
|
16811
|
-
import { randomUUID as
|
|
17058
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
16812
17059
|
|
|
16813
17060
|
// src/commands/backlog/import/readStdinBuffer.ts
|
|
16814
17061
|
async function readStdinBuffer() {
|
|
@@ -17056,7 +17303,7 @@ async function ask(options2) {
|
|
|
17056
17303
|
options2.title,
|
|
17057
17304
|
{
|
|
17058
17305
|
sessionId: sessionId2,
|
|
17059
|
-
requestId:
|
|
17306
|
+
requestId: randomUUID4(),
|
|
17060
17307
|
title: options2.title,
|
|
17061
17308
|
body,
|
|
17062
17309
|
prNumber: null,
|
|
@@ -17083,7 +17330,7 @@ function registerAsk(program) {
|
|
|
17083
17330
|
}
|
|
17084
17331
|
|
|
17085
17332
|
// src/commands/askCheck.ts
|
|
17086
|
-
import { randomUUID as
|
|
17333
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
17087
17334
|
|
|
17088
17335
|
// src/commands/backlog/moveManualCheck.ts
|
|
17089
17336
|
import { and as and15, eq as eq33 } from "drizzle-orm";
|
|
@@ -17332,7 +17579,7 @@ async function askCheck(options2) {
|
|
|
17332
17579
|
check2.title,
|
|
17333
17580
|
{
|
|
17334
17581
|
sessionId: sessionId2,
|
|
17335
|
-
requestId:
|
|
17582
|
+
requestId: randomUUID5(),
|
|
17336
17583
|
title: check2.title,
|
|
17337
17584
|
body: JSON.stringify(
|
|
17338
17585
|
bump ? { ...check2, laterPhases: bump.laterPhases } : check2
|
|
@@ -17372,7 +17619,7 @@ function registerAskCheck(program) {
|
|
|
17372
17619
|
}
|
|
17373
17620
|
|
|
17374
17621
|
// src/commands/askDesign.ts
|
|
17375
|
-
import { randomUUID as
|
|
17622
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
17376
17623
|
|
|
17377
17624
|
// src/commands/askDesign/designReviewSessionId.ts
|
|
17378
17625
|
async function designReviewSessionId() {
|
|
@@ -17414,7 +17661,7 @@ ${body}`);
|
|
|
17414
17661
|
options2.title,
|
|
17415
17662
|
{
|
|
17416
17663
|
sessionId: sessionId2,
|
|
17417
|
-
requestId:
|
|
17664
|
+
requestId: randomUUID6(),
|
|
17418
17665
|
title: options2.title,
|
|
17419
17666
|
body: body || DEFAULT_BODY,
|
|
17420
17667
|
prNumber: null,
|
|
@@ -17442,7 +17689,7 @@ function registerAskDesign(program) {
|
|
|
17442
17689
|
}
|
|
17443
17690
|
|
|
17444
17691
|
// src/commands/askQuestion.ts
|
|
17445
|
-
import { randomUUID as
|
|
17692
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
17446
17693
|
|
|
17447
17694
|
// src/commands/askQuestion/formatAskQuestionAnswers.ts
|
|
17448
17695
|
function formatAskQuestionAnswers(questions, answers) {
|
|
@@ -17517,7 +17764,7 @@ async function askQuestion(options2) {
|
|
|
17517
17764
|
title,
|
|
17518
17765
|
{
|
|
17519
17766
|
sessionId: sessionId2,
|
|
17520
|
-
requestId:
|
|
17767
|
+
requestId: randomUUID7(),
|
|
17521
17768
|
title,
|
|
17522
17769
|
body: JSON.stringify({ questions }),
|
|
17523
17770
|
prNumber: null,
|
|
@@ -18763,21 +19010,6 @@ function registerImportCommand(cmd) {
|
|
|
18763
19010
|
// src/commands/backlog/add.ts
|
|
18764
19011
|
import chalk56 from "chalk";
|
|
18765
19012
|
|
|
18766
|
-
// src/lib/isClaudeCode.ts
|
|
18767
|
-
function isClaudeCode() {
|
|
18768
|
-
return process.env.CLAUDECODE !== void 0;
|
|
18769
|
-
}
|
|
18770
|
-
|
|
18771
|
-
// src/lib/isCodex.ts
|
|
18772
|
-
function isCodex() {
|
|
18773
|
-
return process.env.CODEX_TOOL_CALL_ID !== void 0 || process.env.CODEX_THREAD_ID !== void 0;
|
|
18774
|
-
}
|
|
18775
|
-
|
|
18776
|
-
// src/lib/isAgentHarness.ts
|
|
18777
|
-
function isAgentHarness() {
|
|
18778
|
-
return isClaudeCode() || isCodex();
|
|
18779
|
-
}
|
|
18780
|
-
|
|
18781
19013
|
// src/commands/backlog/ensureRemoteOrigin.ts
|
|
18782
19014
|
import chalk55 from "chalk";
|
|
18783
19015
|
function ensureRemoteOrigin() {
|
|
@@ -18911,7 +19143,7 @@ async function resolveInsertPosition(orm, itemId2, position) {
|
|
|
18911
19143
|
}
|
|
18912
19144
|
|
|
18913
19145
|
// src/commands/backlog/addPhase/reviewProposedPhase.ts
|
|
18914
|
-
import { randomUUID as
|
|
19146
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
18915
19147
|
|
|
18916
19148
|
// src/commands/backlog/renderPhaseSection.ts
|
|
18917
19149
|
function renderPhaseSection(phase, idx) {
|
|
@@ -18931,11 +19163,11 @@ function renderPhaseSection(phase, idx) {
|
|
|
18931
19163
|
// src/commands/backlog/addPhase/reviewProposedPhase.ts
|
|
18932
19164
|
async function reviewProposedPhase(item, phaseIdx, phase) {
|
|
18933
19165
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
18934
|
-
if (!
|
|
19166
|
+
if (!isAgentHarness() || process.env.ASSIST_SESSION !== "1" || !sessionId2)
|
|
18935
19167
|
return;
|
|
18936
19168
|
await awaitPreviewApproval("Backlog phase preview", {
|
|
18937
19169
|
sessionId: sessionId2,
|
|
18938
|
-
requestId:
|
|
19170
|
+
requestId: randomUUID8(),
|
|
18939
19171
|
title: `Add a phase to ${formatItemId(item.id)}: ${item.name}`,
|
|
18940
19172
|
body: renderPhaseSection(phase, phaseIdx),
|
|
18941
19173
|
prNumber: null,
|
|
@@ -19102,7 +19334,7 @@ function readProposedItem(source) {
|
|
|
19102
19334
|
}
|
|
19103
19335
|
|
|
19104
19336
|
// src/commands/backlog/propose/reviewProposal.ts
|
|
19105
|
-
import { randomUUID as
|
|
19337
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
19106
19338
|
import chalk61 from "chalk";
|
|
19107
19339
|
|
|
19108
19340
|
// src/shared/renderMarkdownTerminal.ts
|
|
@@ -19144,7 +19376,7 @@ async function reviewProposal(item, sessionId2, confirmed, revises) {
|
|
|
19144
19376
|
if (sessionId2) {
|
|
19145
19377
|
const decision = await awaitPreviewApproval("Backlog item preview", {
|
|
19146
19378
|
sessionId: sessionId2,
|
|
19147
|
-
requestId:
|
|
19379
|
+
requestId: randomUUID9(),
|
|
19148
19380
|
title: revises === void 0 ? item.name : `Update ${formatItemId(revises)}: ${item.name}`,
|
|
19149
19381
|
body,
|
|
19150
19382
|
prNumber: null,
|
|
@@ -19267,7 +19499,7 @@ function startProposedRun(id) {
|
|
|
19267
19499
|
}
|
|
19268
19500
|
|
|
19269
19501
|
// src/commands/backlog/propose/trackProposal.ts
|
|
19270
|
-
import { randomUUID as
|
|
19502
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
19271
19503
|
|
|
19272
19504
|
// src/commands/backlog/propose/mutateLedger.ts
|
|
19273
19505
|
import { mkdirSync as mkdirSync11, readFileSync as readFileSync25, renameSync as renameSync4, writeFileSync as writeFileSync20 } from "fs";
|
|
@@ -19323,7 +19555,7 @@ function proposalLedgerPath(sessionId2) {
|
|
|
19323
19555
|
var STALE_OPEN_MS = 60 * 6e4;
|
|
19324
19556
|
function trackProposal(sessionId2) {
|
|
19325
19557
|
const path109 = proposalLedgerPath(sessionId2);
|
|
19326
|
-
const token =
|
|
19558
|
+
const token = randomUUID10();
|
|
19327
19559
|
const startedAt = Date.now();
|
|
19328
19560
|
mutateLedger(path109, (ledger) => {
|
|
19329
19561
|
ledger.open = ledger.open.filter(
|
|
@@ -20001,10 +20233,118 @@ async function recordBranchActivity(branchName) {
|
|
|
20001
20233
|
]);
|
|
20002
20234
|
}
|
|
20003
20235
|
|
|
20004
|
-
// src/
|
|
20236
|
+
// src/shared/runOneShotPrompt.ts
|
|
20005
20237
|
import { execFile as execFile12 } from "child_process";
|
|
20238
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
20006
20239
|
import { promisify as promisify12 } from "util";
|
|
20007
20240
|
|
|
20241
|
+
// src/commands/litellm/buildCodexProviderArgs.ts
|
|
20242
|
+
var API_KEY_ENV = "ASSIST_LITELLM_API_KEY";
|
|
20243
|
+
function buildCodexProviderArgs(responsesBaseUrl, apiKey, model) {
|
|
20244
|
+
return {
|
|
20245
|
+
args: [
|
|
20246
|
+
"-c",
|
|
20247
|
+
"model_providers.litellm.name=LiteLLM",
|
|
20248
|
+
"-c",
|
|
20249
|
+
`model_providers.litellm.base_url=${responsesBaseUrl}`,
|
|
20250
|
+
"-c",
|
|
20251
|
+
`model_providers.litellm.env_key=${API_KEY_ENV}`,
|
|
20252
|
+
"-c",
|
|
20253
|
+
"model_providers.litellm.wire_api=responses",
|
|
20254
|
+
"-c",
|
|
20255
|
+
"model_provider=litellm",
|
|
20256
|
+
"-m",
|
|
20257
|
+
model
|
|
20258
|
+
],
|
|
20259
|
+
env: { [API_KEY_ENV]: apiKey },
|
|
20260
|
+
model
|
|
20261
|
+
};
|
|
20262
|
+
}
|
|
20263
|
+
|
|
20264
|
+
// src/commands/litellm/readLitellmConfig.ts
|
|
20265
|
+
function readLitellmConfig() {
|
|
20266
|
+
const litellm = loadConfig().litellm;
|
|
20267
|
+
const baseUrl = litellm?.baseUrl?.trim();
|
|
20268
|
+
const apiKey = litellm?.apiKey?.trim();
|
|
20269
|
+
const missing = [
|
|
20270
|
+
...baseUrl ? [] : ["litellm.baseUrl"],
|
|
20271
|
+
...apiKey ? [] : ["litellm.apiKey"]
|
|
20272
|
+
];
|
|
20273
|
+
if (!baseUrl || !apiKey) return { config: null, missing };
|
|
20274
|
+
return { config: { baseUrl: baseUrl.replace(/\/+$/, ""), apiKey }, missing };
|
|
20275
|
+
}
|
|
20276
|
+
|
|
20277
|
+
// src/commands/litellm/buildLitellmCodexArgs.ts
|
|
20278
|
+
function buildLitellmCodexArgs(rawModel) {
|
|
20279
|
+
const model = rawModel?.trim();
|
|
20280
|
+
if (!model) return { args: [], env: {} };
|
|
20281
|
+
const { config } = readLitellmConfig();
|
|
20282
|
+
if (!config) return { args: [], env: {} };
|
|
20283
|
+
return buildCodexProviderArgs(`${config.baseUrl}/v1`, config.apiKey, model);
|
|
20284
|
+
}
|
|
20285
|
+
|
|
20286
|
+
// src/shared/buildHarnessCodexArgs.ts
|
|
20287
|
+
function buildHarnessCodexArgs() {
|
|
20288
|
+
return buildLitellmCodexArgs(loadConfig().harness.codexModel);
|
|
20289
|
+
}
|
|
20290
|
+
|
|
20291
|
+
// src/shared/codexIsolatedHookArgs.ts
|
|
20292
|
+
var codexIsolatedHookArgs = ["--no-daemon"];
|
|
20293
|
+
|
|
20294
|
+
// src/shared/runOneShotPrompt.ts
|
|
20295
|
+
var execFileAsync10 = promisify12(execFile12);
|
|
20296
|
+
function resolveOneShotHarness(preferred) {
|
|
20297
|
+
const kind = preferred ?? (isCodex() ? "codex" : loadConfig().harness.engine);
|
|
20298
|
+
return kind === "codex" ? "codex" : "claude";
|
|
20299
|
+
}
|
|
20300
|
+
function envDetachedFromTrackedSession(extra) {
|
|
20301
|
+
const {
|
|
20302
|
+
ASSIST_SESSION: _session,
|
|
20303
|
+
ASSIST_SESSION_ID: _sessionId,
|
|
20304
|
+
ASSIST_ACTIVITY_ID: _activityId,
|
|
20305
|
+
...env
|
|
20306
|
+
} = process.env;
|
|
20307
|
+
return { ...env, ...extra };
|
|
20308
|
+
}
|
|
20309
|
+
function runCodex(prompt, timeout) {
|
|
20310
|
+
const override = buildHarnessCodexArgs();
|
|
20311
|
+
const run5 = execFileAsync10(
|
|
20312
|
+
"codex",
|
|
20313
|
+
[
|
|
20314
|
+
...codexIsolatedHookArgs,
|
|
20315
|
+
"exec",
|
|
20316
|
+
...override.args,
|
|
20317
|
+
"--ephemeral",
|
|
20318
|
+
"--skip-git-repo-check",
|
|
20319
|
+
"--sandbox",
|
|
20320
|
+
"read-only",
|
|
20321
|
+
"-c",
|
|
20322
|
+
'model_reasoning_effort="low"',
|
|
20323
|
+
prompt
|
|
20324
|
+
],
|
|
20325
|
+
{
|
|
20326
|
+
encoding: "utf8",
|
|
20327
|
+
windowsHide: true,
|
|
20328
|
+
timeout,
|
|
20329
|
+
cwd: tmpdir2(),
|
|
20330
|
+
env: envDetachedFromTrackedSession(override.env)
|
|
20331
|
+
}
|
|
20332
|
+
);
|
|
20333
|
+
run5.child?.stdin?.end();
|
|
20334
|
+
return run5;
|
|
20335
|
+
}
|
|
20336
|
+
async function runOneShotPrompt(prompt, options2 = {}) {
|
|
20337
|
+
const timeout = options2.timeout ?? 3e4;
|
|
20338
|
+
if (resolveOneShotHarness(options2.harness) === "codex")
|
|
20339
|
+
return (await runCodex(prompt, timeout)).stdout;
|
|
20340
|
+
const { stdout } = await execFileAsync10(
|
|
20341
|
+
"claude",
|
|
20342
|
+
["-p", "--model", "haiku", prompt],
|
|
20343
|
+
{ encoding: "utf8", windowsHide: true, timeout }
|
|
20344
|
+
);
|
|
20345
|
+
return stdout;
|
|
20346
|
+
}
|
|
20347
|
+
|
|
20008
20348
|
// src/shared/withSpinner.ts
|
|
20009
20349
|
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
20010
20350
|
var TICK_MS = 80;
|
|
@@ -20039,7 +20379,6 @@ function isConciseSlug(slug2) {
|
|
|
20039
20379
|
}
|
|
20040
20380
|
|
|
20041
20381
|
// src/commands/branch/generateBranchSlug.ts
|
|
20042
|
-
var execFileAsync10 = promisify12(execFile12);
|
|
20043
20382
|
async function generateBranchSlug(description) {
|
|
20044
20383
|
const fallback = deriveBranchSlug(description);
|
|
20045
20384
|
const suggestion = await requestSlug(description);
|
|
@@ -20049,13 +20388,9 @@ async function generateBranchSlug(description) {
|
|
|
20049
20388
|
}
|
|
20050
20389
|
async function requestSlug(description) {
|
|
20051
20390
|
try {
|
|
20052
|
-
const
|
|
20391
|
+
const stdout = await withSpinner(
|
|
20053
20392
|
"Generating a concise branch name",
|
|
20054
|
-
() =>
|
|
20055
|
-
"claude",
|
|
20056
|
-
["-p", "--model", "haiku", buildPrompt(description)],
|
|
20057
|
-
{ encoding: "utf8", timeout: 3e4 }
|
|
20058
|
-
)
|
|
20393
|
+
() => runOneShotPrompt(buildPrompt(description))
|
|
20059
20394
|
);
|
|
20060
20395
|
const slug2 = stdout.trim().split("\n")[0].replace(/^["'`]|["'`]$/g, "").trim();
|
|
20061
20396
|
return slug2 || void 0;
|
|
@@ -20545,59 +20880,6 @@ function assertCodexResumeSupported(options2) {
|
|
|
20545
20880
|
}
|
|
20546
20881
|
}
|
|
20547
20882
|
|
|
20548
|
-
// src/commands/litellm/buildCodexProviderArgs.ts
|
|
20549
|
-
var API_KEY_ENV = "ASSIST_LITELLM_API_KEY";
|
|
20550
|
-
function buildCodexProviderArgs(responsesBaseUrl, apiKey, model) {
|
|
20551
|
-
return {
|
|
20552
|
-
args: [
|
|
20553
|
-
"-c",
|
|
20554
|
-
"model_providers.litellm.name=LiteLLM",
|
|
20555
|
-
"-c",
|
|
20556
|
-
`model_providers.litellm.base_url=${responsesBaseUrl}`,
|
|
20557
|
-
"-c",
|
|
20558
|
-
`model_providers.litellm.env_key=${API_KEY_ENV}`,
|
|
20559
|
-
"-c",
|
|
20560
|
-
"model_providers.litellm.wire_api=responses",
|
|
20561
|
-
"-c",
|
|
20562
|
-
"model_provider=litellm",
|
|
20563
|
-
"-m",
|
|
20564
|
-
model
|
|
20565
|
-
],
|
|
20566
|
-
env: { [API_KEY_ENV]: apiKey },
|
|
20567
|
-
model
|
|
20568
|
-
};
|
|
20569
|
-
}
|
|
20570
|
-
|
|
20571
|
-
// src/commands/litellm/readLitellmConfig.ts
|
|
20572
|
-
function readLitellmConfig() {
|
|
20573
|
-
const litellm = loadConfig().litellm;
|
|
20574
|
-
const baseUrl = litellm?.baseUrl?.trim();
|
|
20575
|
-
const apiKey = litellm?.apiKey?.trim();
|
|
20576
|
-
const missing = [
|
|
20577
|
-
...baseUrl ? [] : ["litellm.baseUrl"],
|
|
20578
|
-
...apiKey ? [] : ["litellm.apiKey"]
|
|
20579
|
-
];
|
|
20580
|
-
if (!baseUrl || !apiKey) return { config: null, missing };
|
|
20581
|
-
return { config: { baseUrl: baseUrl.replace(/\/+$/, ""), apiKey }, missing };
|
|
20582
|
-
}
|
|
20583
|
-
|
|
20584
|
-
// src/commands/litellm/buildLitellmCodexArgs.ts
|
|
20585
|
-
function buildLitellmCodexArgs(rawModel) {
|
|
20586
|
-
const model = rawModel?.trim();
|
|
20587
|
-
if (!model) return { args: [], env: {} };
|
|
20588
|
-
const { config } = readLitellmConfig();
|
|
20589
|
-
if (!config) return { args: [], env: {} };
|
|
20590
|
-
return buildCodexProviderArgs(`${config.baseUrl}/v1`, config.apiKey, model);
|
|
20591
|
-
}
|
|
20592
|
-
|
|
20593
|
-
// src/shared/buildHarnessCodexArgs.ts
|
|
20594
|
-
function buildHarnessCodexArgs() {
|
|
20595
|
-
return buildLitellmCodexArgs(loadConfig().harness.codexModel);
|
|
20596
|
-
}
|
|
20597
|
-
|
|
20598
|
-
// src/shared/codexIsolatedHookArgs.ts
|
|
20599
|
-
var codexIsolatedHookArgs = ["--no-daemon"];
|
|
20600
|
-
|
|
20601
20883
|
// src/shared/codexSandboxNetworkArgs.ts
|
|
20602
20884
|
var codexSandboxNetworkArgs = [
|
|
20603
20885
|
"-c",
|
|
@@ -20796,7 +21078,7 @@ Phase ${phaseNumber} completed.`));
|
|
|
20796
21078
|
}
|
|
20797
21079
|
|
|
20798
21080
|
// src/commands/backlog/preparePhaseSession.ts
|
|
20799
|
-
import { randomUUID as
|
|
21081
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
20800
21082
|
|
|
20801
21083
|
// src/commands/backlog/persistPhaseSession.ts
|
|
20802
21084
|
import os4 from "os";
|
|
@@ -20986,7 +21268,7 @@ async function verifyPhaseResume(itemId2, resumeSessionId, phaseLabel2) {
|
|
|
20986
21268
|
// src/commands/backlog/preparePhaseSession.ts
|
|
20987
21269
|
async function preparePhaseSession(item, phase, phaseIndex, phaseNumber, totalPhases, phaseLabel2, spawnOptions) {
|
|
20988
21270
|
const resumeSessionId = spawnOptions?.resumeSessionId;
|
|
20989
|
-
const claudeSessionId = resumeSessionId ??
|
|
21271
|
+
const claudeSessionId = resumeSessionId ?? randomUUID11();
|
|
20990
21272
|
if (resumeSessionId && !await verifyPhaseResume(item.id, resumeSessionId, phaseLabel2)) {
|
|
20991
21273
|
return void 0;
|
|
20992
21274
|
}
|
|
@@ -21336,7 +21618,7 @@ import chalk87 from "chalk";
|
|
|
21336
21618
|
import enquirer7 from "enquirer";
|
|
21337
21619
|
|
|
21338
21620
|
// src/commands/backlog/launchMode.ts
|
|
21339
|
-
import { randomUUID as
|
|
21621
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
21340
21622
|
|
|
21341
21623
|
// src/commands/backlog/handleLaunchSignal.ts
|
|
21342
21624
|
import chalk86 from "chalk";
|
|
@@ -21458,7 +21740,7 @@ async function launchMode(slashCommand, options2) {
|
|
|
21458
21740
|
const resumeSessionId = options2?.resumeSessionId;
|
|
21459
21741
|
if (!resumeSessionId) await pullIfConfigured();
|
|
21460
21742
|
process.env.ASSIST_SESSION_ID ??= String(process.pid);
|
|
21461
|
-
const claudeSessionId = resumeSessionId ??
|
|
21743
|
+
const claudeSessionId = resumeSessionId ?? randomUUID12();
|
|
21462
21744
|
const harness = options2?.harness ?? "claude";
|
|
21463
21745
|
reportLaunchActivity(slashCommand, claudeSessionId, harness, options2);
|
|
21464
21746
|
const prompt = resumeSessionId ? resumeNudge() : buildSlashCommand(slashCommand, options2?.description);
|
|
@@ -21659,14 +21941,14 @@ async function done(id, summary) {
|
|
|
21659
21941
|
const { orm, item } = found;
|
|
21660
21942
|
if (item.plan && item.plan.length > 0) {
|
|
21661
21943
|
const completedCount = (item.currentPhase ?? 1) - 1;
|
|
21662
|
-
const
|
|
21663
|
-
if (
|
|
21944
|
+
const pending = authoredPhases(item.plan).slice(completedCount);
|
|
21945
|
+
if (pending.length > 0) {
|
|
21664
21946
|
console.log(
|
|
21665
21947
|
chalk92.red(
|
|
21666
|
-
`Cannot complete item ${formatItemId(item.id)}: ${
|
|
21948
|
+
`Cannot complete item ${formatItemId(item.id)}: ${pending.length} pending phase(s):`
|
|
21667
21949
|
)
|
|
21668
21950
|
);
|
|
21669
|
-
for (const phase of
|
|
21951
|
+
for (const phase of pending) {
|
|
21670
21952
|
console.log(chalk92.yellow(` - ${phase.name}`));
|
|
21671
21953
|
}
|
|
21672
21954
|
process.exitCode = 1;
|
|
@@ -22296,7 +22578,7 @@ function readPlanUpdate(source) {
|
|
|
22296
22578
|
}
|
|
22297
22579
|
|
|
22298
22580
|
// src/commands/backlog/updatePlan/reviewPlanUpdate.ts
|
|
22299
|
-
import { randomUUID as
|
|
22581
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
22300
22582
|
import chalk108 from "chalk";
|
|
22301
22583
|
|
|
22302
22584
|
// src/commands/backlog/updatePlan/isCompleted.ts
|
|
@@ -22453,7 +22735,7 @@ async function reviewPlanUpdate(item, phases) {
|
|
|
22453
22735
|
if (process.env.ASSIST_SESSION === "1" && sessionId2) {
|
|
22454
22736
|
const decision = await awaitPreviewApproval("Plan update preview", {
|
|
22455
22737
|
sessionId: sessionId2,
|
|
22456
|
-
requestId:
|
|
22738
|
+
requestId: randomUUID13(),
|
|
22457
22739
|
title: `Update the plan for ${formatItemId(item.id)}: ${item.name}`,
|
|
22458
22740
|
body,
|
|
22459
22741
|
prNumber: null,
|
|
@@ -22935,7 +23217,7 @@ async function isDocsLocked() {
|
|
|
22935
23217
|
import { parse } from "shell-quote";
|
|
22936
23218
|
|
|
22937
23219
|
// src/shared/consumeRedirect.ts
|
|
22938
|
-
import { tmpdir as
|
|
23220
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
22939
23221
|
|
|
22940
23222
|
// src/shared/isRedirectTargetAllowed.ts
|
|
22941
23223
|
function isRedirectTargetAllowed(target, tmp) {
|
|
@@ -22963,7 +23245,7 @@ function consumeRedirect(tokens, opIndex, current2) {
|
|
|
22963
23245
|
if (typeof target !== "string") {
|
|
22964
23246
|
return { ok: false, error: "unable to parse" };
|
|
22965
23247
|
}
|
|
22966
|
-
if (!isRedirectTargetAllowed(target,
|
|
23248
|
+
if (!isRedirectTargetAllowed(target, tmpdir3())) {
|
|
22967
23249
|
return {
|
|
22968
23250
|
ok: false,
|
|
22969
23251
|
error: `redirect target '${target}' is outside the OS temp directory`
|
|
@@ -23100,7 +23382,7 @@ function skipBody(command, start2, delimiter) {
|
|
|
23100
23382
|
function stripHeredocBodies(command) {
|
|
23101
23383
|
if (!command.includes("<<")) return command;
|
|
23102
23384
|
let out = "";
|
|
23103
|
-
let
|
|
23385
|
+
let pending = [];
|
|
23104
23386
|
let quote;
|
|
23105
23387
|
let i = 0;
|
|
23106
23388
|
while (i < command.length) {
|
|
@@ -23122,15 +23404,15 @@ function stripHeredocBodies(command) {
|
|
|
23122
23404
|
i++;
|
|
23123
23405
|
continue;
|
|
23124
23406
|
}
|
|
23125
|
-
if (char === "\n" &&
|
|
23407
|
+
if (char === "\n" && pending.length > 0) {
|
|
23126
23408
|
out += char;
|
|
23127
|
-
i = skipHeredocBodies(command, i + 1,
|
|
23128
|
-
|
|
23409
|
+
i = skipHeredocBodies(command, i + 1, pending);
|
|
23410
|
+
pending = [];
|
|
23129
23411
|
continue;
|
|
23130
23412
|
}
|
|
23131
23413
|
if (char === "<") {
|
|
23132
23414
|
const header = matchHeredocHeader(command, i);
|
|
23133
|
-
if (header.delimiter !== void 0)
|
|
23415
|
+
if (header.delimiter !== void 0) pending.push(header.delimiter);
|
|
23134
23416
|
out += header.text;
|
|
23135
23417
|
i += header.text.length;
|
|
23136
23418
|
continue;
|
|
@@ -23594,25 +23876,141 @@ function findCliWrite(command) {
|
|
|
23594
23876
|
}
|
|
23595
23877
|
|
|
23596
23878
|
// src/shared/readSettingsPerms.ts
|
|
23597
|
-
import { existsSync as
|
|
23879
|
+
import { existsSync as existsSync51, readFileSync as readFileSync33 } from "fs";
|
|
23598
23880
|
import { homedir as homedir18 } from "os";
|
|
23881
|
+
import { join as join57 } from "path";
|
|
23882
|
+
|
|
23883
|
+
// src/lib/activeHarness.ts
|
|
23884
|
+
var declaredByHookEntryPoint;
|
|
23885
|
+
function markActiveHarness(harness) {
|
|
23886
|
+
declaredByHookEntryPoint = harness;
|
|
23887
|
+
}
|
|
23888
|
+
function activeHarness() {
|
|
23889
|
+
if (declaredByHookEntryPoint) return declaredByHookEntryPoint;
|
|
23890
|
+
if (isClaudeCode()) return "claude";
|
|
23891
|
+
if (isCodex()) return "codex";
|
|
23892
|
+
return void 0;
|
|
23893
|
+
}
|
|
23894
|
+
|
|
23895
|
+
// src/shared/readCodexRulePerms.ts
|
|
23896
|
+
import { existsSync as existsSync50, readdirSync as readdirSync9, readFileSync as readFileSync32 } from "fs";
|
|
23599
23897
|
import { join as join56 } from "path";
|
|
23898
|
+
|
|
23899
|
+
// src/shared/readPatternList.ts
|
|
23900
|
+
function readString(text20, start2) {
|
|
23901
|
+
const quote = text20[start2];
|
|
23902
|
+
let value = "";
|
|
23903
|
+
let i = start2 + 1;
|
|
23904
|
+
while (i < text20.length && text20[i] !== quote) {
|
|
23905
|
+
if (text20[i] === "\\") i++;
|
|
23906
|
+
value += text20[i];
|
|
23907
|
+
i++;
|
|
23908
|
+
}
|
|
23909
|
+
return [value, i + 1];
|
|
23910
|
+
}
|
|
23911
|
+
function readPatternList(text20, start2) {
|
|
23912
|
+
const items3 = [];
|
|
23913
|
+
let i = start2 + 1;
|
|
23914
|
+
while (i < text20.length && text20[i] !== "]") {
|
|
23915
|
+
const ch = text20[i];
|
|
23916
|
+
if (ch === '"' || ch === "'") {
|
|
23917
|
+
const [value, next3] = readString(text20, i);
|
|
23918
|
+
items3.push(value);
|
|
23919
|
+
i = next3;
|
|
23920
|
+
} else if (ch === "[") {
|
|
23921
|
+
const [list7, next3] = readPatternList(text20, i);
|
|
23922
|
+
items3.push(list7);
|
|
23923
|
+
i = next3;
|
|
23924
|
+
} else i++;
|
|
23925
|
+
}
|
|
23926
|
+
return [items3, i + 1];
|
|
23927
|
+
}
|
|
23928
|
+
|
|
23929
|
+
// src/shared/parseCodexRules.ts
|
|
23930
|
+
var PREFIX_RULE_RE = /prefix_rule\s*\(/g;
|
|
23931
|
+
var DECISION_RE = /decision\s*=\s*["'](\w+)["']/;
|
|
23932
|
+
var PATTERN_RE = /pattern\s*=\s*\[/;
|
|
23933
|
+
function expandPattern(tokens) {
|
|
23934
|
+
return tokens.reduce(
|
|
23935
|
+
(prefixes, token) => {
|
|
23936
|
+
const alternatives = Array.isArray(token) ? token.filter((t) => typeof t === "string") : [token];
|
|
23937
|
+
return prefixes.flatMap(
|
|
23938
|
+
(prefix2) => alternatives.map((alt) => prefix2 ? `${prefix2} ${alt}` : alt)
|
|
23939
|
+
);
|
|
23940
|
+
},
|
|
23941
|
+
[""]
|
|
23942
|
+
);
|
|
23943
|
+
}
|
|
23944
|
+
function ruleBody(text20, start2) {
|
|
23945
|
+
let depth = 1;
|
|
23946
|
+
let i = start2;
|
|
23947
|
+
while (i < text20.length && depth > 0) {
|
|
23948
|
+
if (text20[i] === "(") depth++;
|
|
23949
|
+
if (text20[i] === ")") depth--;
|
|
23950
|
+
i++;
|
|
23951
|
+
}
|
|
23952
|
+
return text20.slice(start2, i);
|
|
23953
|
+
}
|
|
23954
|
+
function parseCodexRules(text20) {
|
|
23955
|
+
const perms = { allow: [], deny: [] };
|
|
23956
|
+
for (const match of text20.matchAll(PREFIX_RULE_RE)) {
|
|
23957
|
+
const body = ruleBody(text20, match.index + match[0].length);
|
|
23958
|
+
const patternMatch = PATTERN_RE.exec(body);
|
|
23959
|
+
if (!patternMatch) continue;
|
|
23960
|
+
const [tokens] = readPatternList(
|
|
23961
|
+
body,
|
|
23962
|
+
patternMatch.index + patternMatch[0].length - 1
|
|
23963
|
+
);
|
|
23964
|
+
const decision = DECISION_RE.exec(body)?.[1] ?? "allow";
|
|
23965
|
+
const target = decision === "allow" ? perms.allow : decision === "forbidden" ? perms.deny : void 0;
|
|
23966
|
+
if (!target) continue;
|
|
23967
|
+
for (const command of expandPattern(tokens))
|
|
23968
|
+
if (command) target.push(`Bash(${command}:*)`);
|
|
23969
|
+
}
|
|
23970
|
+
return perms;
|
|
23971
|
+
}
|
|
23972
|
+
|
|
23973
|
+
// src/shared/readCodexRulePerms.ts
|
|
23974
|
+
function ruleFiles(dir) {
|
|
23975
|
+
if (!existsSync50(dir)) return [];
|
|
23976
|
+
try {
|
|
23977
|
+
return readdirSync9(dir).filter((name) => name.endsWith(".rules")).sort().map((name) => join56(dir, name));
|
|
23978
|
+
} catch {
|
|
23979
|
+
return [];
|
|
23980
|
+
}
|
|
23981
|
+
}
|
|
23982
|
+
function readCodexRulePerms(key) {
|
|
23983
|
+
const dirs = [
|
|
23984
|
+
join56(harnesses.codex.homeDir, "rules"),
|
|
23985
|
+
join56(process.cwd(), ".codex", "rules")
|
|
23986
|
+
];
|
|
23987
|
+
return dirs.flatMap(ruleFiles).flatMap((file) => {
|
|
23988
|
+
try {
|
|
23989
|
+
return parseCodexRules(readFileSync32(file, "utf8"))[key];
|
|
23990
|
+
} catch {
|
|
23991
|
+
return [];
|
|
23992
|
+
}
|
|
23993
|
+
});
|
|
23994
|
+
}
|
|
23995
|
+
|
|
23996
|
+
// src/shared/readSettingsPerms.ts
|
|
23600
23997
|
function readSettingsPerms(key) {
|
|
23601
23998
|
const paths = [
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23999
|
+
join57(homedir18(), ".claude", "settings.json"),
|
|
24000
|
+
join57(process.cwd(), ".claude", "settings.json"),
|
|
24001
|
+
join57(process.cwd(), ".claude", "settings.local.json")
|
|
23605
24002
|
];
|
|
23606
24003
|
const entries = [];
|
|
23607
24004
|
for (const p of paths) {
|
|
23608
24005
|
entries.push(...readPermissionArray(p, key));
|
|
23609
24006
|
}
|
|
24007
|
+
if (activeHarness() === "codex") entries.push(...readCodexRulePerms(key));
|
|
23610
24008
|
return entries;
|
|
23611
24009
|
}
|
|
23612
24010
|
function readPermissionArray(filePath, key) {
|
|
23613
|
-
if (!
|
|
24011
|
+
if (!existsSync51(filePath)) return [];
|
|
23614
24012
|
try {
|
|
23615
|
-
const data = JSON.parse(
|
|
24013
|
+
const data = JSON.parse(readFileSync33(filePath, "utf8"));
|
|
23616
24014
|
const arr = data?.permissions?.[key];
|
|
23617
24015
|
return Array.isArray(arr) ? arr.filter((e) => typeof e === "string") : [];
|
|
23618
24016
|
} catch {
|
|
@@ -23882,14 +24280,14 @@ function findDocsPathDeny(toolName, rawCommand, root2) {
|
|
|
23882
24280
|
}
|
|
23883
24281
|
|
|
23884
24282
|
// src/commands/schema/isSchemaPath.ts
|
|
23885
|
-
import { readFileSync as
|
|
24283
|
+
import { readFileSync as readFileSync34 } from "fs";
|
|
23886
24284
|
import { relative as relative7, resolve as resolve21 } from "path";
|
|
23887
24285
|
var SCHEMA_LOCK_REASON = "Database schema files (src/shared/db/migrations/migrationNNNN*.ts, src/shared/db/migrations.ts, src/shared/db/schema.ts and any src/shared/db/*.ts that defines a pgTable) are locked: a schema change needs the user's sign-off (see src/shared/db/CLAUDE.md). Confirm the schema change with the user first, then run `assist schema unlock` to request a PIN and wait for the user to confirm it with `assist schema confirm <pin>` before retrying. In a backlog item session the unlock lasts for the current phase; otherwise it lasts for this Claude session.";
|
|
23888
24286
|
var FIXED_SCHEMA_PATH = /^src\/shared\/db\/(?:migrations\/migration\d{4}[^/]*\.ts|migrations\.ts|schema\.ts)$/;
|
|
23889
24287
|
var DB_MODULE = /^src\/shared\/db\/[^/]+\.ts$/;
|
|
23890
24288
|
function readOrEmpty2(path109) {
|
|
23891
24289
|
try {
|
|
23892
|
-
return
|
|
24290
|
+
return readFileSync34(path109, "utf8");
|
|
23893
24291
|
} catch {
|
|
23894
24292
|
return "";
|
|
23895
24293
|
}
|
|
@@ -23958,11 +24356,11 @@ function findSchemaPathDeny(toolName, rawCommand, root2 = getProjectRoot()) {
|
|
|
23958
24356
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
23959
24357
|
import { mkdirSync as mkdirSync16 } from "fs";
|
|
23960
24358
|
import { homedir as homedir19 } from "os";
|
|
23961
|
-
import { join as
|
|
24359
|
+
import { join as join58 } from "path";
|
|
23962
24360
|
import Database from "better-sqlite3";
|
|
23963
24361
|
var _db;
|
|
23964
24362
|
function getDbDir() {
|
|
23965
|
-
return
|
|
24363
|
+
return join58(homedir19(), ".assist");
|
|
23966
24364
|
}
|
|
23967
24365
|
function initSchema(db) {
|
|
23968
24366
|
db.exec(`
|
|
@@ -23981,7 +24379,7 @@ function openPromptsDb(dir) {
|
|
|
23981
24379
|
if (_db) return _db;
|
|
23982
24380
|
const dbDir = dir ?? getDbDir();
|
|
23983
24381
|
mkdirSync16(dbDir, { recursive: true });
|
|
23984
|
-
const db = new Database(
|
|
24382
|
+
const db = new Database(join58(dbDir, "assist.db"));
|
|
23985
24383
|
db.pragma("journal_mode = WAL");
|
|
23986
24384
|
initSchema(db);
|
|
23987
24385
|
_db = db;
|
|
@@ -24045,29 +24443,29 @@ function tryParseInput(raw) {
|
|
|
24045
24443
|
}
|
|
24046
24444
|
|
|
24047
24445
|
// src/commands/schema/isSchemaLocked.ts
|
|
24048
|
-
import { existsSync as
|
|
24446
|
+
import { existsSync as existsSync52 } from "fs";
|
|
24049
24447
|
|
|
24050
24448
|
// src/commands/schema/getSchemaSessionApprovalPath.ts
|
|
24051
|
-
import { join as
|
|
24449
|
+
import { join as join60 } from "path";
|
|
24052
24450
|
|
|
24053
24451
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
24054
24452
|
import { homedir as homedir20 } from "os";
|
|
24055
|
-
import { join as
|
|
24453
|
+
import { join as join59 } from "path";
|
|
24056
24454
|
function getRestrictedDir() {
|
|
24057
|
-
return
|
|
24455
|
+
return join59(homedir20(), ".assist", "restricted");
|
|
24058
24456
|
}
|
|
24059
24457
|
function getPinStatePath(pin2) {
|
|
24060
|
-
return
|
|
24458
|
+
return join59(getRestrictedDir(), `code-comment-${pin2}.json`);
|
|
24061
24459
|
}
|
|
24062
24460
|
|
|
24063
24461
|
// src/commands/schema/getSchemaSessionApprovalPath.ts
|
|
24064
24462
|
var SESSION_ID = /^[\w-]+$/;
|
|
24065
24463
|
function getSchemaSessionApprovalDir() {
|
|
24066
|
-
return
|
|
24464
|
+
return join60(getRestrictedDir(), "schema-sessions");
|
|
24067
24465
|
}
|
|
24068
24466
|
function getSchemaSessionApprovalPath(claudeSessionId) {
|
|
24069
24467
|
if (!SESSION_ID.test(claudeSessionId)) return void 0;
|
|
24070
|
-
return
|
|
24468
|
+
return join60(getSchemaSessionApprovalDir(), `${claudeSessionId}.json`);
|
|
24071
24469
|
}
|
|
24072
24470
|
|
|
24073
24471
|
// src/commands/schema/isSchemaLocked.ts
|
|
@@ -24075,7 +24473,7 @@ function hasSessionApproval() {
|
|
|
24075
24473
|
const claudeSessionId = process.env.CLAUDE_CODE_SESSION_ID;
|
|
24076
24474
|
if (!claudeSessionId) return false;
|
|
24077
24475
|
const path109 = getSchemaSessionApprovalPath(claudeSessionId);
|
|
24078
|
-
return path109 !== void 0 &&
|
|
24476
|
+
return path109 !== void 0 && existsSync52(path109);
|
|
24079
24477
|
}
|
|
24080
24478
|
async function isSchemaLocked() {
|
|
24081
24479
|
if (!process.env.CLAUDECODE) return false;
|
|
@@ -24164,9 +24562,9 @@ ${reasons.join("\n")}`);
|
|
|
24164
24562
|
}
|
|
24165
24563
|
|
|
24166
24564
|
// src/commands/permitCliReads.ts
|
|
24167
|
-
import { existsSync as
|
|
24565
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync17, readFileSync as readFileSync35, writeFileSync as writeFileSync26 } from "fs";
|
|
24168
24566
|
import { homedir as homedir21 } from "os";
|
|
24169
|
-
import { join as
|
|
24567
|
+
import { join as join61 } from "path";
|
|
24170
24568
|
|
|
24171
24569
|
// src/commands/permitCliReads/assertCliExists.ts
|
|
24172
24570
|
function assertCliExists(cli) {
|
|
@@ -24271,7 +24669,7 @@ function runHelp(args) {
|
|
|
24271
24669
|
// src/commands/permitCliReads/discoverAll.ts
|
|
24272
24670
|
var SAFETY_DEPTH = 10;
|
|
24273
24671
|
var CONCURRENCY = 8;
|
|
24274
|
-
var interactive = !
|
|
24672
|
+
var interactive = !isAgentHarness();
|
|
24275
24673
|
function showProgress(p, label) {
|
|
24276
24674
|
if (!interactive) return;
|
|
24277
24675
|
const pct = Math.round(p.done / p.total * 100);
|
|
@@ -24429,15 +24827,15 @@ function updateSettings(cli, commands) {
|
|
|
24429
24827
|
// src/commands/permitCliReads.ts
|
|
24430
24828
|
function logPath(cli) {
|
|
24431
24829
|
const safeName = cli.replace(/\s+/g, "-");
|
|
24432
|
-
return
|
|
24830
|
+
return join61(homedir21(), ".assist", `cli-discover-${safeName}.log`);
|
|
24433
24831
|
}
|
|
24434
24832
|
function readCache(cli) {
|
|
24435
24833
|
const path109 = logPath(cli);
|
|
24436
|
-
if (!
|
|
24437
|
-
return
|
|
24834
|
+
if (!existsSync53(path109)) return void 0;
|
|
24835
|
+
return readFileSync35(path109, "utf8");
|
|
24438
24836
|
}
|
|
24439
24837
|
function writeCache(cli, output) {
|
|
24440
|
-
const dir =
|
|
24838
|
+
const dir = join61(homedir21(), ".assist");
|
|
24441
24839
|
mkdirSync17(dir, { recursive: true });
|
|
24442
24840
|
writeFileSync26(logPath(cli), output);
|
|
24443
24841
|
}
|
|
@@ -24569,7 +24967,7 @@ function registerCliHook(program) {
|
|
|
24569
24967
|
}
|
|
24570
24968
|
|
|
24571
24969
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
24572
|
-
import { existsSync as
|
|
24970
|
+
import { existsSync as existsSync55, readFileSync as readFileSync37, unlinkSync as unlinkSync8, writeFileSync as writeFileSync27 } from "fs";
|
|
24573
24971
|
import chalk120 from "chalk";
|
|
24574
24972
|
|
|
24575
24973
|
// src/shared/isHashCommentFile.ts
|
|
@@ -24602,19 +25000,19 @@ function isHashCommentFile(filePath) {
|
|
|
24602
25000
|
}
|
|
24603
25001
|
|
|
24604
25002
|
// src/commands/codeComment/sweepRestrictedDir.ts
|
|
24605
|
-
import { readdirSync as
|
|
24606
|
-
import { join as
|
|
25003
|
+
import { readdirSync as readdirSync10, statSync as statSync8, unlinkSync as unlinkSync7 } from "fs";
|
|
25004
|
+
import { join as join62 } from "path";
|
|
24607
25005
|
var STALE_AFTER_MS = 30 * 60 * 1e3;
|
|
24608
25006
|
function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
24609
25007
|
let entries;
|
|
24610
25008
|
try {
|
|
24611
|
-
entries =
|
|
25009
|
+
entries = readdirSync10(dir);
|
|
24612
25010
|
} catch {
|
|
24613
25011
|
return;
|
|
24614
25012
|
}
|
|
24615
25013
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
24616
25014
|
for (const entry of entries) {
|
|
24617
|
-
const path109 =
|
|
25015
|
+
const path109 = join62(dir, entry);
|
|
24618
25016
|
try {
|
|
24619
25017
|
if (statSync8(path109).mtimeMs < cutoff) unlinkSync7(path109);
|
|
24620
25018
|
} catch {
|
|
@@ -24624,12 +25022,12 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
24624
25022
|
}
|
|
24625
25023
|
|
|
24626
25024
|
// src/commands/codeComment/readPinState.ts
|
|
24627
|
-
import { existsSync as
|
|
25025
|
+
import { existsSync as existsSync54, readFileSync as readFileSync36 } from "fs";
|
|
24628
25026
|
function readPinState(pin2) {
|
|
24629
25027
|
const path109 = getPinStatePath(pin2);
|
|
24630
|
-
if (!
|
|
25028
|
+
if (!existsSync54(path109)) return void 0;
|
|
24631
25029
|
try {
|
|
24632
|
-
const state = JSON.parse(
|
|
25030
|
+
const state = JSON.parse(readFileSync36(path109, "utf8"));
|
|
24633
25031
|
if (state.pin !== pin2) return void 0;
|
|
24634
25032
|
return state;
|
|
24635
25033
|
} catch {
|
|
@@ -24646,12 +25044,12 @@ function codeCommentConfirm(pin2) {
|
|
|
24646
25044
|
process.exitCode = 1;
|
|
24647
25045
|
return;
|
|
24648
25046
|
}
|
|
24649
|
-
if (!
|
|
25047
|
+
if (!existsSync55(state.file)) {
|
|
24650
25048
|
console.error(chalk120.red(`Target file no longer exists: ${state.file}`));
|
|
24651
25049
|
process.exitCode = 1;
|
|
24652
25050
|
return;
|
|
24653
25051
|
}
|
|
24654
|
-
const original =
|
|
25052
|
+
const original = readFileSync37(state.file, "utf8");
|
|
24655
25053
|
const lines = original.split("\n");
|
|
24656
25054
|
const index3 = state.line - 1;
|
|
24657
25055
|
if (index3 > lines.length) {
|
|
@@ -24709,7 +25107,7 @@ import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync28 } from "fs";
|
|
|
24709
25107
|
import { randomInt } from "crypto";
|
|
24710
25108
|
|
|
24711
25109
|
// src/commands/notify/deliverPinNotification.ts
|
|
24712
|
-
import { randomUUID as
|
|
25110
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
24713
25111
|
|
|
24714
25112
|
// src/commands/notify/showNotification.ts
|
|
24715
25113
|
import notifier from "node-notifier";
|
|
@@ -24771,7 +25169,7 @@ var ROUTE_TIMEOUT_MS = 1e4;
|
|
|
24771
25169
|
async function relayToViewerNode(notification) {
|
|
24772
25170
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
24773
25171
|
if (!sessionId2) return void 0;
|
|
24774
|
-
const requestId =
|
|
25172
|
+
const requestId = randomUUID14();
|
|
24775
25173
|
const reply2 = await requestDaemonReply(
|
|
24776
25174
|
{ type: "notify-pin", sessionId: sessionId2, requestId, ...notification },
|
|
24777
25175
|
"notify-pin-result",
|
|
@@ -24884,6 +25282,8 @@ function parseCodexHookInput(raw) {
|
|
|
24884
25282
|
};
|
|
24885
25283
|
const transcriptPath2 = optionalString2(data.transcript_path);
|
|
24886
25284
|
if (transcriptPath2) base.transcriptPath = transcriptPath2;
|
|
25285
|
+
const sessionId2 = optionalString2(data.session_id);
|
|
25286
|
+
if (sessionId2) base.sessionId = sessionId2;
|
|
24887
25287
|
const command = data.tool_input?.command;
|
|
24888
25288
|
if (typeof command !== "string" || !command.trim()) return base;
|
|
24889
25289
|
if (!data.tool_name || !SUPPORTED_TOOLS.has(data.tool_name)) return base;
|
|
@@ -24893,6 +25293,23 @@ function parseCodexHookInput(raw) {
|
|
|
24893
25293
|
}
|
|
24894
25294
|
}
|
|
24895
25295
|
|
|
25296
|
+
// src/commands/codexHook/logCodexDeniedCall.ts
|
|
25297
|
+
import { basename as basename16 } from "path";
|
|
25298
|
+
function logCodexDeniedCall(input, decision) {
|
|
25299
|
+
if (decision?.permissionDecision !== "deny") return;
|
|
25300
|
+
if (!input.toolName || !input.command) return;
|
|
25301
|
+
try {
|
|
25302
|
+
logDeniedToolCall({
|
|
25303
|
+
tool: input.toolName,
|
|
25304
|
+
command: input.command,
|
|
25305
|
+
repo: basename16(input.cwd ?? process.cwd()),
|
|
25306
|
+
sessionId: input.sessionId ?? process.env.CODEX_THREAD_ID,
|
|
25307
|
+
denyReason: decision.permissionDecisionReason
|
|
25308
|
+
});
|
|
25309
|
+
} catch {
|
|
25310
|
+
}
|
|
25311
|
+
}
|
|
25312
|
+
|
|
24896
25313
|
// src/commands/codexHook/relayCodexUsage.ts
|
|
24897
25314
|
var USAGE_EVENTS = /* @__PURE__ */ new Set(["PostToolUse", "Stop"]);
|
|
24898
25315
|
async function relayCodexUsage(event, transcriptPath2) {
|
|
@@ -24969,11 +25386,13 @@ function outputFor(input, decision) {
|
|
|
24969
25386
|
return preToolUseOutput(decision);
|
|
24970
25387
|
}
|
|
24971
25388
|
async function codexHook() {
|
|
25389
|
+
markActiveHarness("codex");
|
|
24972
25390
|
const input = parseCodexHookInput(await readStdin());
|
|
24973
25391
|
if (!input) return;
|
|
24974
25392
|
const decision = decide2(input);
|
|
24975
25393
|
const output = outputFor(input, decision);
|
|
24976
25394
|
if (output) console.log(JSON.stringify(output));
|
|
25395
|
+
logCodexDeniedCall(input, decision);
|
|
24977
25396
|
await reportCodexStatus(input.event, decision !== void 0);
|
|
24978
25397
|
await relayCodexUsage(input.event, input.transcriptPath);
|
|
24979
25398
|
}
|
|
@@ -26835,7 +27254,7 @@ async function browserInspect(selector, options2) {
|
|
|
26835
27254
|
}
|
|
26836
27255
|
|
|
26837
27256
|
// src/commands/browser/browserRun.ts
|
|
26838
|
-
import { readFileSync as
|
|
27257
|
+
import { readFileSync as readFileSync38 } from "fs";
|
|
26839
27258
|
import chalk149 from "chalk";
|
|
26840
27259
|
|
|
26841
27260
|
// src/commands/browser/formatRunOutcome.ts
|
|
@@ -26855,7 +27274,7 @@ function formatRunOutcome(run5) {
|
|
|
26855
27274
|
async function browserRun(options2) {
|
|
26856
27275
|
let code;
|
|
26857
27276
|
try {
|
|
26858
|
-
code =
|
|
27277
|
+
code = readFileSync38(options2.file, "utf8");
|
|
26859
27278
|
} catch (error) {
|
|
26860
27279
|
console.error(
|
|
26861
27280
|
chalk149.red(
|
|
@@ -26885,11 +27304,11 @@ import { dirname as dirname31 } from "path";
|
|
|
26885
27304
|
|
|
26886
27305
|
// src/commands/browser/snapshotPath.ts
|
|
26887
27306
|
import { homedir as homedir22 } from "os";
|
|
26888
|
-
import { join as
|
|
27307
|
+
import { join as join63 } from "path";
|
|
26889
27308
|
function snapshotPath(tabUrl, now) {
|
|
26890
27309
|
const host = new URL(tabUrl).host.replace(/[^\w.-]/g, "-");
|
|
26891
27310
|
const timestamp9 = now.toISOString().replace(/[:.]/g, "-");
|
|
26892
|
-
return
|
|
27311
|
+
return join63(homedir22(), ".assist", "browser", `${host}-${timestamp9}.html`);
|
|
26893
27312
|
}
|
|
26894
27313
|
|
|
26895
27314
|
// src/commands/browser/browserSnapshot.ts
|
|
@@ -27095,29 +27514,29 @@ async function printExtensionUrl() {
|
|
|
27095
27514
|
|
|
27096
27515
|
// src/commands/extension/signExtension.ts
|
|
27097
27516
|
import { rm as rm2 } from "fs/promises";
|
|
27098
|
-
import { homedir as homedir23, tmpdir as
|
|
27099
|
-
import { join as
|
|
27517
|
+
import { homedir as homedir23, tmpdir as tmpdir4 } from "os";
|
|
27518
|
+
import { join as join69 } from "path";
|
|
27100
27519
|
import chalk154 from "chalk";
|
|
27101
27520
|
|
|
27102
27521
|
// src/commands/extension/copySignedXpi.ts
|
|
27103
27522
|
import { copyFile } from "fs/promises";
|
|
27104
|
-
import { join as
|
|
27523
|
+
import { join as join64 } from "path";
|
|
27105
27524
|
var SIGNED_XPI_NAME = "assist-extension.xpi";
|
|
27106
27525
|
async function copySignedXpi(xpi, dir) {
|
|
27107
|
-
const fixed2 =
|
|
27526
|
+
const fixed2 = join64(dir, SIGNED_XPI_NAME);
|
|
27108
27527
|
if (fixed2 === xpi) return fixed2;
|
|
27109
27528
|
await copyFile(xpi, fixed2);
|
|
27110
27529
|
return fixed2;
|
|
27111
27530
|
}
|
|
27112
27531
|
|
|
27113
27532
|
// src/commands/extension/findSignedXpi.ts
|
|
27114
|
-
import { existsSync as
|
|
27533
|
+
import { existsSync as existsSync56 } from "fs";
|
|
27115
27534
|
import { readdir } from "fs/promises";
|
|
27116
|
-
import { join as
|
|
27535
|
+
import { join as join65 } from "path";
|
|
27117
27536
|
async function findSignedXpi(dir) {
|
|
27118
|
-
if (!
|
|
27537
|
+
if (!existsSync56(dir)) return null;
|
|
27119
27538
|
const name = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
27120
|
-
return name ?
|
|
27539
|
+
return name ? join65(dir, name) : null;
|
|
27121
27540
|
}
|
|
27122
27541
|
|
|
27123
27542
|
// src/commands/extension/signedAddonInstallPath.ts
|
|
@@ -27139,11 +27558,11 @@ async function signedAddonInstallPath(xpi) {
|
|
|
27139
27558
|
}
|
|
27140
27559
|
|
|
27141
27560
|
// src/commands/extension/signPreflightProblem.ts
|
|
27142
|
-
import { existsSync as
|
|
27143
|
-
import { join as
|
|
27561
|
+
import { existsSync as existsSync57 } from "fs";
|
|
27562
|
+
import { join as join66 } from "path";
|
|
27144
27563
|
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
27145
27564
|
function signPreflightProblem(source) {
|
|
27146
|
-
if (!
|
|
27565
|
+
if (!existsSync57(join66(source, "content.js")))
|
|
27147
27566
|
return {
|
|
27148
27567
|
message: `no content.js in ${source}`,
|
|
27149
27568
|
hint: "run npm run build to bundle the content script"
|
|
@@ -27158,7 +27577,7 @@ function signPreflightProblem(source) {
|
|
|
27158
27577
|
|
|
27159
27578
|
// src/commands/extension/stageExtension.ts
|
|
27160
27579
|
import { cp as cp3, mkdir as mkdir5, readFile as readFile5, rm, writeFile as writeFile4 } from "fs/promises";
|
|
27161
|
-
import { basename as
|
|
27580
|
+
import { basename as basename17, join as join67 } from "path";
|
|
27162
27581
|
|
|
27163
27582
|
// src/commands/extension/stampManifestVersion.ts
|
|
27164
27583
|
function stampManifestVersion(manifest, version2) {
|
|
@@ -27173,9 +27592,9 @@ async function stageExtension(source, staging, version2) {
|
|
|
27173
27592
|
await mkdir5(staging, { recursive: true });
|
|
27174
27593
|
await cp3(source, staging, {
|
|
27175
27594
|
recursive: true,
|
|
27176
|
-
filter: (path109) =>
|
|
27595
|
+
filter: (path109) => basename17(path109) !== "updates.json"
|
|
27177
27596
|
});
|
|
27178
|
-
const manifest =
|
|
27597
|
+
const manifest = join67(staging, "manifest.json");
|
|
27179
27598
|
const stamped = stampManifestVersion(
|
|
27180
27599
|
await readFile5(manifest, "utf8"),
|
|
27181
27600
|
version2
|
|
@@ -27185,7 +27604,7 @@ async function stageExtension(source, staging, version2) {
|
|
|
27185
27604
|
|
|
27186
27605
|
// src/commands/extension/writeUpdateManifest.ts
|
|
27187
27606
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
27188
|
-
import { join as
|
|
27607
|
+
import { join as join68 } from "path";
|
|
27189
27608
|
|
|
27190
27609
|
// src/commands/extension/buildUpdateManifest.ts
|
|
27191
27610
|
var RELEASE_DOWNLOAD_URL = "https://github.com/staff0rd/assist/releases/download";
|
|
@@ -27210,17 +27629,17 @@ function buildUpdateManifest(manifest, version2) {
|
|
|
27210
27629
|
// src/commands/extension/writeUpdateManifest.ts
|
|
27211
27630
|
async function writeUpdateManifest(source, dir, version2) {
|
|
27212
27631
|
await writeFile5(
|
|
27213
|
-
|
|
27632
|
+
join68(dir, "updates.json"),
|
|
27214
27633
|
buildUpdateManifest(
|
|
27215
|
-
await readFile6(
|
|
27634
|
+
await readFile6(join68(source, "manifest.json"), "utf8"),
|
|
27216
27635
|
version2
|
|
27217
27636
|
)
|
|
27218
27637
|
);
|
|
27219
27638
|
}
|
|
27220
27639
|
|
|
27221
27640
|
// src/commands/extension/signExtension.ts
|
|
27222
|
-
var ARTIFACTS_DIR =
|
|
27223
|
-
var STAGING_DIR =
|
|
27641
|
+
var ARTIFACTS_DIR = join69(homedir23(), ".assist", "extension");
|
|
27642
|
+
var STAGING_DIR = join69(tmpdir4(), "assist-extension");
|
|
27224
27643
|
async function signExtension() {
|
|
27225
27644
|
const source = extensionDir();
|
|
27226
27645
|
const problem = signPreflightProblem(source);
|
|
@@ -27404,7 +27823,7 @@ function registerDb(program) {
|
|
|
27404
27823
|
}
|
|
27405
27824
|
|
|
27406
27825
|
// src/commands/deploy/redirect.ts
|
|
27407
|
-
import { existsSync as
|
|
27826
|
+
import { existsSync as existsSync58, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
|
|
27408
27827
|
import chalk157 from "chalk";
|
|
27409
27828
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
27410
27829
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -27413,11 +27832,11 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
27413
27832
|
</script>`;
|
|
27414
27833
|
function redirect() {
|
|
27415
27834
|
const indexPath = "index.html";
|
|
27416
|
-
if (!
|
|
27835
|
+
if (!existsSync58(indexPath)) {
|
|
27417
27836
|
console.log(chalk157.yellow("No index.html found"));
|
|
27418
27837
|
return;
|
|
27419
27838
|
}
|
|
27420
|
-
const content =
|
|
27839
|
+
const content = readFileSync39(indexPath, "utf8");
|
|
27421
27840
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
27422
27841
|
console.log(chalk157.dim("Trailing slash script already present"));
|
|
27423
27842
|
return;
|
|
@@ -27508,22 +27927,22 @@ function printWeekHeader(week, state) {
|
|
|
27508
27927
|
}
|
|
27509
27928
|
|
|
27510
27929
|
// src/commands/devlog/loadDevEntry.ts
|
|
27511
|
-
import { readFileSync as
|
|
27512
|
-
import { join as
|
|
27930
|
+
import { readFileSync as readFileSync40 } from "fs";
|
|
27931
|
+
import { join as join70 } from "path";
|
|
27513
27932
|
import { parse as parseYaml3 } from "yaml";
|
|
27514
27933
|
function asString(value) {
|
|
27515
27934
|
return value === void 0 || value === null ? null : String(value);
|
|
27516
27935
|
}
|
|
27517
27936
|
function readFrontmatter(path109) {
|
|
27518
27937
|
try {
|
|
27519
|
-
const match =
|
|
27938
|
+
const match = readFileSync40(path109, "utf8").match(/^---\n([\s\S]*?)\n---/);
|
|
27520
27939
|
return match ? parseYaml3(match[1]) ?? {} : null;
|
|
27521
27940
|
} catch {
|
|
27522
27941
|
return null;
|
|
27523
27942
|
}
|
|
27524
27943
|
}
|
|
27525
27944
|
function loadDevEntry(repoName, week, devDir) {
|
|
27526
|
-
const path109 =
|
|
27945
|
+
const path109 = join70(devDir, repoName, `${week.toLowerCase()}.md`);
|
|
27527
27946
|
const frontmatter2 = readFrontmatter(path109);
|
|
27528
27947
|
if (!frontmatter2) return null;
|
|
27529
27948
|
const versions = frontmatter2.versions;
|
|
@@ -27619,17 +28038,17 @@ function findTargetWeek(weeks, { lastWeek, skip: skip3, today }) {
|
|
|
27619
28038
|
import chalk160 from "chalk";
|
|
27620
28039
|
|
|
27621
28040
|
// src/shared/getRepoName.ts
|
|
27622
|
-
import { existsSync as
|
|
27623
|
-
import { basename as
|
|
28041
|
+
import { existsSync as existsSync59, readFileSync as readFileSync41 } from "fs";
|
|
28042
|
+
import { basename as basename18, join as join71 } from "path";
|
|
27624
28043
|
function getRepoName() {
|
|
27625
28044
|
const config = loadConfig();
|
|
27626
28045
|
if (config.devlog?.name) {
|
|
27627
28046
|
return config.devlog.name;
|
|
27628
28047
|
}
|
|
27629
|
-
const packageJsonPath =
|
|
27630
|
-
if (
|
|
28048
|
+
const packageJsonPath = join71(process.cwd(), "package.json");
|
|
28049
|
+
if (existsSync59(packageJsonPath)) {
|
|
27631
28050
|
try {
|
|
27632
|
-
const content =
|
|
28051
|
+
const content = readFileSync41(packageJsonPath, "utf8");
|
|
27633
28052
|
const pkg = JSON.parse(content);
|
|
27634
28053
|
if (pkg.name) {
|
|
27635
28054
|
return pkg.name;
|
|
@@ -27637,7 +28056,7 @@ function getRepoName() {
|
|
|
27637
28056
|
} catch {
|
|
27638
28057
|
}
|
|
27639
28058
|
}
|
|
27640
|
-
return
|
|
28059
|
+
return basename18(process.cwd());
|
|
27641
28060
|
}
|
|
27642
28061
|
|
|
27643
28062
|
// src/commands/devlog/shared.ts
|
|
@@ -27704,8 +28123,8 @@ function list2(options2) {
|
|
|
27704
28123
|
}
|
|
27705
28124
|
|
|
27706
28125
|
// src/commands/devlog/loadDevWeeks.ts
|
|
27707
|
-
import { readdirSync as
|
|
27708
|
-
import { join as
|
|
28126
|
+
import { readdirSync as readdirSync11 } from "fs";
|
|
28127
|
+
import { join as join72 } from "path";
|
|
27709
28128
|
var DEV_FILENAME_PATTERN = /^(\d{4})-w(\d{2})\.md$/;
|
|
27710
28129
|
function parseDevWeekFilename(filename) {
|
|
27711
28130
|
const match = filename.match(DEV_FILENAME_PATTERN);
|
|
@@ -27713,13 +28132,13 @@ function parseDevWeekFilename(filename) {
|
|
|
27713
28132
|
}
|
|
27714
28133
|
function readFilenames(dir) {
|
|
27715
28134
|
try {
|
|
27716
|
-
return
|
|
28135
|
+
return readdirSync11(dir);
|
|
27717
28136
|
} catch {
|
|
27718
28137
|
return [];
|
|
27719
28138
|
}
|
|
27720
28139
|
}
|
|
27721
28140
|
function loadDevWeeks(repoName, devDir) {
|
|
27722
|
-
return readFilenames(
|
|
28141
|
+
return readFilenames(join72(devDir, repoName)).map(parseDevWeekFilename).filter((week) => week !== null).sort();
|
|
27723
28142
|
}
|
|
27724
28143
|
|
|
27725
28144
|
// src/commands/devlog/next/displayNextEntry.ts
|
|
@@ -27936,7 +28355,7 @@ async function skip2(week, cwd = process.cwd()) {
|
|
|
27936
28355
|
|
|
27937
28356
|
// src/commands/devlog/write.ts
|
|
27938
28357
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync31 } from "fs";
|
|
27939
|
-
import { dirname as dirname32, join as
|
|
28358
|
+
import { dirname as dirname32, join as join73 } from "path";
|
|
27940
28359
|
import chalk165 from "chalk";
|
|
27941
28360
|
|
|
27942
28361
|
// src/commands/devlog/write/devEntryInputSchema.ts
|
|
@@ -28029,7 +28448,7 @@ async function write() {
|
|
|
28029
28448
|
}
|
|
28030
28449
|
const devDir = resolveDevDir();
|
|
28031
28450
|
const repoName = getRepoName();
|
|
28032
|
-
const path109 =
|
|
28451
|
+
const path109 = join73(devDir, repoName, `${result.data.week.toLowerCase()}.md`);
|
|
28033
28452
|
mkdirSync20(dirname32(path109), { recursive: true });
|
|
28034
28453
|
writeFileSync31(path109, formatDevEntry(repoName, result.data));
|
|
28035
28454
|
console.log(chalk165.green(`Wrote ${path109}`));
|
|
@@ -28055,10 +28474,10 @@ function registerDevlogEntryCommands(devlogCommand) {
|
|
|
28055
28474
|
import { execSync as execSync38 } from "child_process";
|
|
28056
28475
|
|
|
28057
28476
|
// src/commands/devlog/loadAllDevLatestWeeks.ts
|
|
28058
|
-
import { readdirSync as
|
|
28477
|
+
import { readdirSync as readdirSync12 } from "fs";
|
|
28059
28478
|
function readRepoDirs(devDir) {
|
|
28060
28479
|
try {
|
|
28061
|
-
return
|
|
28480
|
+
return readdirSync12(devDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
28062
28481
|
} catch {
|
|
28063
28482
|
return [];
|
|
28064
28483
|
}
|
|
@@ -28216,21 +28635,21 @@ async function findPhaseUnlockItem(itemId2, phase) {
|
|
|
28216
28635
|
}
|
|
28217
28636
|
|
|
28218
28637
|
// src/commands/docs/getDocsUnlockPinPath.ts
|
|
28219
|
-
import { join as
|
|
28638
|
+
import { join as join74 } from "path";
|
|
28220
28639
|
function getDocsUnlockPinPath(pin2) {
|
|
28221
|
-
return
|
|
28640
|
+
return join74(getRestrictedDir(), `docs-unlock-pin-${pin2}.json`);
|
|
28222
28641
|
}
|
|
28223
28642
|
|
|
28224
28643
|
// src/commands/docs/readDocsUnlockPinState.ts
|
|
28225
|
-
import { existsSync as
|
|
28644
|
+
import { existsSync as existsSync60, readFileSync as readFileSync42 } from "fs";
|
|
28226
28645
|
function isPositiveInteger(value) {
|
|
28227
28646
|
return Number.isInteger(value) && value > 0;
|
|
28228
28647
|
}
|
|
28229
28648
|
function readDocsUnlockPinState(pin2) {
|
|
28230
28649
|
const path109 = getDocsUnlockPinPath(pin2);
|
|
28231
|
-
if (!
|
|
28650
|
+
if (!existsSync60(path109)) return void 0;
|
|
28232
28651
|
try {
|
|
28233
|
-
const state = JSON.parse(
|
|
28652
|
+
const state = JSON.parse(readFileSync42(path109, "utf8"));
|
|
28234
28653
|
if (state.pin !== pin2) return void 0;
|
|
28235
28654
|
if (!isPositiveInteger(state.itemId)) return void 0;
|
|
28236
28655
|
if (!isPositiveInteger(state.phase)) return void 0;
|
|
@@ -28366,13 +28785,13 @@ import { mkdirSync as mkdirSync22, unlinkSync as unlinkSync11, writeFileSync as
|
|
|
28366
28785
|
import chalk171 from "chalk";
|
|
28367
28786
|
|
|
28368
28787
|
// src/commands/schema/getSchemaUnlockPinPath.ts
|
|
28369
|
-
import { join as
|
|
28788
|
+
import { join as join75 } from "path";
|
|
28370
28789
|
function getSchemaUnlockPinPath(pin2) {
|
|
28371
|
-
return
|
|
28790
|
+
return join75(getRestrictedDir(), `schema-unlock-pin-${pin2}.json`);
|
|
28372
28791
|
}
|
|
28373
28792
|
|
|
28374
28793
|
// src/commands/schema/readSchemaUnlockPinState.ts
|
|
28375
|
-
import { existsSync as
|
|
28794
|
+
import { existsSync as existsSync61, readFileSync as readFileSync43 } from "fs";
|
|
28376
28795
|
function isPositiveInteger2(value) {
|
|
28377
28796
|
return Number.isInteger(value) && value > 0;
|
|
28378
28797
|
}
|
|
@@ -28386,9 +28805,9 @@ function toState(raw) {
|
|
|
28386
28805
|
}
|
|
28387
28806
|
function readSchemaUnlockPinState(pin2) {
|
|
28388
28807
|
const path109 = getSchemaUnlockPinPath(pin2);
|
|
28389
|
-
if (!
|
|
28808
|
+
if (!existsSync61(path109)) return void 0;
|
|
28390
28809
|
try {
|
|
28391
|
-
const raw = JSON.parse(
|
|
28810
|
+
const raw = JSON.parse(readFileSync43(path109, "utf8"));
|
|
28392
28811
|
if (raw.pin !== pin2) return void 0;
|
|
28393
28812
|
return toState(raw);
|
|
28394
28813
|
} catch {
|
|
@@ -28510,20 +28929,20 @@ function registerSchema(parent) {
|
|
|
28510
28929
|
}
|
|
28511
28930
|
|
|
28512
28931
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
28513
|
-
import { closeSync as closeSync5, openSync as openSync6, readdirSync as
|
|
28514
|
-
import { join as
|
|
28932
|
+
import { closeSync as closeSync5, openSync as openSync6, readdirSync as readdirSync13 } from "fs";
|
|
28933
|
+
import { join as join76 } from "path";
|
|
28515
28934
|
import chalk173 from "chalk";
|
|
28516
28935
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
28517
28936
|
function isLockedDll(debugDir) {
|
|
28518
28937
|
let files;
|
|
28519
28938
|
try {
|
|
28520
|
-
files =
|
|
28939
|
+
files = readdirSync13(debugDir, { recursive: true });
|
|
28521
28940
|
} catch {
|
|
28522
28941
|
return null;
|
|
28523
28942
|
}
|
|
28524
28943
|
for (const file of files) {
|
|
28525
28944
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
28526
|
-
const dllPath =
|
|
28945
|
+
const dllPath = join76(debugDir, file);
|
|
28527
28946
|
try {
|
|
28528
28947
|
const fd = openSync6(dllPath, "r+");
|
|
28529
28948
|
closeSync5(fd);
|
|
@@ -28536,18 +28955,18 @@ function isLockedDll(debugDir) {
|
|
|
28536
28955
|
function findFirstLockedDll(dir) {
|
|
28537
28956
|
let entries;
|
|
28538
28957
|
try {
|
|
28539
|
-
entries =
|
|
28958
|
+
entries = readdirSync13(dir);
|
|
28540
28959
|
} catch {
|
|
28541
28960
|
return null;
|
|
28542
28961
|
}
|
|
28543
28962
|
if (entries.includes("bin")) {
|
|
28544
|
-
const locked = isLockedDll(
|
|
28963
|
+
const locked = isLockedDll(join76(dir, "bin", "Debug"));
|
|
28545
28964
|
if (locked) return locked;
|
|
28546
28965
|
}
|
|
28547
28966
|
for (const entry of entries) {
|
|
28548
28967
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
28549
28968
|
continue;
|
|
28550
|
-
const found = findFirstLockedDll(
|
|
28969
|
+
const found = findFirstLockedDll(join76(dir, entry));
|
|
28551
28970
|
if (found) return found;
|
|
28552
28971
|
}
|
|
28553
28972
|
return null;
|
|
@@ -28570,11 +28989,11 @@ async function checkBuildLocksCommand() {
|
|
|
28570
28989
|
}
|
|
28571
28990
|
|
|
28572
28991
|
// src/commands/dotnet/buildTree.ts
|
|
28573
|
-
import { readFileSync as
|
|
28992
|
+
import { readFileSync as readFileSync44 } from "fs";
|
|
28574
28993
|
import path36 from "path";
|
|
28575
28994
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
28576
28995
|
function getProjectRefs(csprojPath) {
|
|
28577
|
-
const content =
|
|
28996
|
+
const content = readFileSync44(csprojPath, "utf8");
|
|
28578
28997
|
const refs = [];
|
|
28579
28998
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
28580
28999
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -28591,7 +29010,7 @@ function buildTree(csprojPath, repoRoot2, visited = /* @__PURE__ */ new Set()) {
|
|
|
28591
29010
|
for (const ref of getProjectRefs(abs)) {
|
|
28592
29011
|
const childAbs = path36.resolve(dir, ref);
|
|
28593
29012
|
try {
|
|
28594
|
-
|
|
29013
|
+
readFileSync44(childAbs);
|
|
28595
29014
|
node.children.push(buildTree(childAbs, repoRoot2, visited));
|
|
28596
29015
|
} catch {
|
|
28597
29016
|
node.children.push({
|
|
@@ -28616,14 +29035,14 @@ function collectAllDeps(node) {
|
|
|
28616
29035
|
}
|
|
28617
29036
|
|
|
28618
29037
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
28619
|
-
import { readdirSync as
|
|
29038
|
+
import { readdirSync as readdirSync14, readFileSync as readFileSync45, statSync as statSync9 } from "fs";
|
|
28620
29039
|
import path37 from "path";
|
|
28621
29040
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
28622
29041
|
if (depth > maxDepth) return [];
|
|
28623
29042
|
const results = [];
|
|
28624
29043
|
let entries;
|
|
28625
29044
|
try {
|
|
28626
|
-
entries =
|
|
29045
|
+
entries = readdirSync14(dir);
|
|
28627
29046
|
} catch {
|
|
28628
29047
|
return results;
|
|
28629
29048
|
}
|
|
@@ -28651,7 +29070,7 @@ function findContainingSolutions(csprojPath, repoRoot2) {
|
|
|
28651
29070
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
28652
29071
|
for (const sln of slnFiles) {
|
|
28653
29072
|
try {
|
|
28654
|
-
const content =
|
|
29073
|
+
const content = readFileSync45(sln, "utf8");
|
|
28655
29074
|
if (pattern2.test(content)) {
|
|
28656
29075
|
matches.push(path37.relative(repoRoot2, sln));
|
|
28657
29076
|
}
|
|
@@ -28715,12 +29134,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
28715
29134
|
}
|
|
28716
29135
|
|
|
28717
29136
|
// src/commands/dotnet/resolveCsproj.ts
|
|
28718
|
-
import { existsSync as
|
|
29137
|
+
import { existsSync as existsSync62 } from "fs";
|
|
28719
29138
|
import path38 from "path";
|
|
28720
29139
|
import chalk175 from "chalk";
|
|
28721
29140
|
function resolveCsproj(csprojPath) {
|
|
28722
29141
|
const resolved = path38.resolve(csprojPath);
|
|
28723
|
-
if (!
|
|
29142
|
+
if (!existsSync62(resolved)) {
|
|
28724
29143
|
console.error(chalk175.red(`File not found: ${resolved}`));
|
|
28725
29144
|
process.exit(1);
|
|
28726
29145
|
}
|
|
@@ -28888,17 +29307,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
28888
29307
|
}
|
|
28889
29308
|
|
|
28890
29309
|
// src/commands/dotnet/resolveSolution.ts
|
|
28891
|
-
import { existsSync as
|
|
29310
|
+
import { existsSync as existsSync63 } from "fs";
|
|
28892
29311
|
import path39 from "path";
|
|
28893
29312
|
import chalk179 from "chalk";
|
|
28894
29313
|
|
|
28895
29314
|
// src/commands/dotnet/findSolution.ts
|
|
28896
|
-
import { readdirSync as
|
|
28897
|
-
import { dirname as dirname33, join as
|
|
29315
|
+
import { readdirSync as readdirSync15 } from "fs";
|
|
29316
|
+
import { dirname as dirname33, join as join77 } from "path";
|
|
28898
29317
|
import chalk178 from "chalk";
|
|
28899
29318
|
function findSlnInDir(dir) {
|
|
28900
29319
|
try {
|
|
28901
|
-
return
|
|
29320
|
+
return readdirSync15(dir).filter((f) => f.endsWith(".sln")).map((f) => join77(dir, f));
|
|
28902
29321
|
} catch {
|
|
28903
29322
|
return [];
|
|
28904
29323
|
}
|
|
@@ -28929,7 +29348,7 @@ function findSolution() {
|
|
|
28929
29348
|
function resolveSolution(sln) {
|
|
28930
29349
|
if (sln) {
|
|
28931
29350
|
const resolved = path39.resolve(sln);
|
|
28932
|
-
if (!
|
|
29351
|
+
if (!existsSync63(resolved)) {
|
|
28933
29352
|
console.error(chalk179.red(`Solution file not found: ${resolved}`));
|
|
28934
29353
|
process.exit(1);
|
|
28935
29354
|
}
|
|
@@ -28969,8 +29388,8 @@ function parseInspectReport(json) {
|
|
|
28969
29388
|
|
|
28970
29389
|
// src/commands/dotnet/runInspectCode.ts
|
|
28971
29390
|
import { execSync as execSync40 } from "child_process";
|
|
28972
|
-
import { existsSync as
|
|
28973
|
-
import { tmpdir as
|
|
29391
|
+
import { existsSync as existsSync64, readFileSync as readFileSync46, unlinkSync as unlinkSync12 } from "fs";
|
|
29392
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
28974
29393
|
import path40 from "path";
|
|
28975
29394
|
import chalk180 from "chalk";
|
|
28976
29395
|
function assertJbInstalled() {
|
|
@@ -28985,7 +29404,7 @@ function assertJbInstalled() {
|
|
|
28985
29404
|
}
|
|
28986
29405
|
}
|
|
28987
29406
|
function runInspectCode(slnPath, include, swea) {
|
|
28988
|
-
const reportPath = path40.join(
|
|
29407
|
+
const reportPath = path40.join(tmpdir5(), `inspect-${Date.now()}.xml`);
|
|
28989
29408
|
const includeFlag = include ? ` --include="${include}"` : "";
|
|
28990
29409
|
const sweaFlag = swea ? " --swea" : "";
|
|
28991
29410
|
try {
|
|
@@ -29000,11 +29419,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
29000
29419
|
console.error(chalk180.red("jb inspectcode failed"));
|
|
29001
29420
|
process.exit(1);
|
|
29002
29421
|
}
|
|
29003
|
-
if (!
|
|
29422
|
+
if (!existsSync64(reportPath)) {
|
|
29004
29423
|
console.error(chalk180.red("Report file not generated"));
|
|
29005
29424
|
process.exit(1);
|
|
29006
29425
|
}
|
|
29007
|
-
const xml =
|
|
29426
|
+
const xml = readFileSync46(reportPath, "utf8");
|
|
29008
29427
|
unlinkSync12(reportPath);
|
|
29009
29428
|
return xml;
|
|
29010
29429
|
}
|
|
@@ -29916,8 +30335,8 @@ function aggregateCommitters(authorLists) {
|
|
|
29916
30335
|
// src/shared/runGhGraphql.ts
|
|
29917
30336
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
29918
30337
|
import { unlinkSync as unlinkSync13, writeFileSync as writeFileSync34 } from "fs";
|
|
29919
|
-
import { tmpdir as
|
|
29920
|
-
import { join as
|
|
30338
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
30339
|
+
import { join as join78 } from "path";
|
|
29921
30340
|
function buildArgs2(queryFile, vars) {
|
|
29922
30341
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
29923
30342
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -29927,7 +30346,7 @@ function buildArgs2(queryFile, vars) {
|
|
|
29927
30346
|
return args;
|
|
29928
30347
|
}
|
|
29929
30348
|
function runGhGraphql(mutation, vars) {
|
|
29930
|
-
const queryFile =
|
|
30349
|
+
const queryFile = join78(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
29931
30350
|
writeFileSync34(queryFile, mutation);
|
|
29932
30351
|
try {
|
|
29933
30352
|
const result = spawnSync6("gh", buildArgs2(queryFile, vars), {
|
|
@@ -30659,13 +31078,13 @@ function validateProposedContent(labels, title, body) {
|
|
|
30659
31078
|
}
|
|
30660
31079
|
|
|
30661
31080
|
// src/commands/github/issue/reviewProposedIssueComment.ts
|
|
30662
|
-
import { randomUUID as
|
|
31081
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
30663
31082
|
async function reviewProposedIssueComment(title, body) {
|
|
30664
31083
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
30665
31084
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
|
|
30666
31085
|
await awaitPreviewApproval("GitHub issue comment preview", {
|
|
30667
31086
|
sessionId: sessionId2,
|
|
30668
|
-
requestId:
|
|
31087
|
+
requestId: randomUUID15(),
|
|
30669
31088
|
title,
|
|
30670
31089
|
body,
|
|
30671
31090
|
prNumber: null,
|
|
@@ -31172,13 +31591,13 @@ function resolveCreateIssueMetadata(options2) {
|
|
|
31172
31591
|
}
|
|
31173
31592
|
|
|
31174
31593
|
// src/commands/github/issue/reviewProposedIssue.ts
|
|
31175
|
-
import { randomUUID as
|
|
31594
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
31176
31595
|
async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
31177
31596
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
31178
31597
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return void 0;
|
|
31179
31598
|
return await awaitPreviewApproval("GitHub issue preview", {
|
|
31180
31599
|
sessionId: sessionId2,
|
|
31181
|
-
requestId:
|
|
31600
|
+
requestId: randomUUID16(),
|
|
31182
31601
|
title,
|
|
31183
31602
|
body,
|
|
31184
31603
|
prNumber: null,
|
|
@@ -31194,7 +31613,7 @@ function attachArgs(attachments) {
|
|
|
31194
31613
|
|
|
31195
31614
|
// src/commands/prs/runGhWithAttachments.ts
|
|
31196
31615
|
import { execFileSync as execFileSync11 } from "child_process";
|
|
31197
|
-
import { basename as
|
|
31616
|
+
import { basename as basename19 } from "path";
|
|
31198
31617
|
|
|
31199
31618
|
// src/shared/removeStagedAttachments.ts
|
|
31200
31619
|
import { rmSync as rmSync5 } from "fs";
|
|
@@ -31211,7 +31630,7 @@ function removeStagedAttachments(attachments) {
|
|
|
31211
31630
|
var PLACED_URL = /https:\/\/\S+\/(pull|issues)\/\d+/;
|
|
31212
31631
|
function reportPartialFailure(attachments, stderr) {
|
|
31213
31632
|
const failed3 = attachments.filter(
|
|
31214
|
-
({ path: path109 }) => stderr.includes(path109) || stderr.includes(
|
|
31633
|
+
({ path: path109 }) => stderr.includes(path109) || stderr.includes(basename19(path109))
|
|
31215
31634
|
);
|
|
31216
31635
|
const named = failed3.length > 0 ? failed3 : attachments;
|
|
31217
31636
|
console.error(
|
|
@@ -31367,14 +31786,14 @@ function slugFromUrl(url) {
|
|
|
31367
31786
|
import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync35 } from "fs";
|
|
31368
31787
|
|
|
31369
31788
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
31370
|
-
import { join as
|
|
31789
|
+
import { join as join79 } from "path";
|
|
31371
31790
|
function issueWorkingFile(slug2, number) {
|
|
31372
31791
|
const [owner = "unknown", repo = "unknown"] = slug2.split("/");
|
|
31373
|
-
const dir =
|
|
31792
|
+
const dir = join79(getStoreDir(), "github-issues", owner, repo);
|
|
31374
31793
|
return {
|
|
31375
31794
|
dir,
|
|
31376
|
-
bodyPath:
|
|
31377
|
-
metaPath:
|
|
31795
|
+
bodyPath: join79(dir, `${number}.md`),
|
|
31796
|
+
metaPath: join79(dir, `${number}.json`)
|
|
31378
31797
|
};
|
|
31379
31798
|
}
|
|
31380
31799
|
|
|
@@ -31409,14 +31828,14 @@ function fetchIssueToWorkingFile(number, repo) {
|
|
|
31409
31828
|
}
|
|
31410
31829
|
|
|
31411
31830
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
31412
|
-
import { existsSync as
|
|
31831
|
+
import { existsSync as existsSync65, readFileSync as readFileSync47 } from "fs";
|
|
31413
31832
|
function resumeIssueBody(slug2, number, updatedAt) {
|
|
31414
31833
|
const { bodyPath, metaPath } = issueWorkingFile(slug2, number);
|
|
31415
|
-
if (!
|
|
31834
|
+
if (!existsSync65(bodyPath) || !existsSync65(metaPath)) return void 0;
|
|
31416
31835
|
try {
|
|
31417
|
-
const meta = JSON.parse(
|
|
31836
|
+
const meta = JSON.parse(readFileSync47(metaPath, "utf8"));
|
|
31418
31837
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
31419
|
-
return
|
|
31838
|
+
return readFileSync47(bodyPath, "utf8");
|
|
31420
31839
|
} catch {
|
|
31421
31840
|
return void 0;
|
|
31422
31841
|
}
|
|
@@ -31478,7 +31897,7 @@ function pushUnchangedIssue(number, repo, target, fetchedAt, bodyPath) {
|
|
|
31478
31897
|
}
|
|
31479
31898
|
|
|
31480
31899
|
// src/commands/github/issue/reviewProposedIssueEdit.ts
|
|
31481
|
-
import { randomUUID as
|
|
31900
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
31482
31901
|
async function reviewProposedIssueEdit(title, body, working) {
|
|
31483
31902
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
31484
31903
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return body;
|
|
@@ -31486,7 +31905,7 @@ async function reviewProposedIssueEdit(title, body, working) {
|
|
|
31486
31905
|
"GitHub issue edit preview",
|
|
31487
31906
|
{
|
|
31488
31907
|
sessionId: sessionId2,
|
|
31489
|
-
requestId:
|
|
31908
|
+
requestId: randomUUID17(),
|
|
31490
31909
|
title,
|
|
31491
31910
|
body,
|
|
31492
31911
|
prNumber: null,
|
|
@@ -32012,10 +32431,10 @@ function errorEvent(detail) {
|
|
|
32012
32431
|
async function scanUnopenedThreads(threadIds, scanThreads, onEvent = () => {
|
|
32013
32432
|
}) {
|
|
32014
32433
|
const messages2 = [];
|
|
32015
|
-
let
|
|
32016
|
-
for (let attempt2 = 0; attempt2 < MAX_ATTEMPTS &&
|
|
32434
|
+
let pending = threadIds;
|
|
32435
|
+
for (let attempt2 = 0; attempt2 < MAX_ATTEMPTS && pending.length; attempt2++) {
|
|
32017
32436
|
const results = await mapAsync(
|
|
32018
|
-
chunk(
|
|
32437
|
+
chunk(pending, BATCH_SIZE),
|
|
32019
32438
|
CONCURRENCY2,
|
|
32020
32439
|
(batch) => scanThreads(batch).catch((error) => {
|
|
32021
32440
|
onEvent(
|
|
@@ -32026,12 +32445,12 @@ async function scanUnopenedThreads(threadIds, scanThreads, onEvent = () => {
|
|
|
32026
32445
|
);
|
|
32027
32446
|
const opened = new Set(results.flatMap((r) => r?.threads.opened ?? []));
|
|
32028
32447
|
messages2.push(...results.flatMap((r) => r?.messages ?? []));
|
|
32029
|
-
|
|
32448
|
+
pending = pending.filter((id) => !opened.has(id));
|
|
32030
32449
|
}
|
|
32031
|
-
if (
|
|
32450
|
+
if (pending.length)
|
|
32032
32451
|
onEvent(
|
|
32033
32452
|
errorEvent(
|
|
32034
|
-
`${
|
|
32453
|
+
`${pending.length} unread thread(s) never opened: ${pending.join(" ")}`
|
|
32035
32454
|
)
|
|
32036
32455
|
);
|
|
32037
32456
|
return messages2;
|
|
@@ -32365,7 +32784,7 @@ function registerRefineLaunch(program, resumeFlag) {
|
|
|
32365
32784
|
}
|
|
32366
32785
|
|
|
32367
32786
|
// src/commands/fixConflict.ts
|
|
32368
|
-
import { randomUUID as
|
|
32787
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
32369
32788
|
|
|
32370
32789
|
// src/commands/review/checkoutPr.ts
|
|
32371
32790
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
@@ -32424,15 +32843,15 @@ function recentDaemonLogLines(includeRelayed = true) {
|
|
|
32424
32843
|
}
|
|
32425
32844
|
|
|
32426
32845
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
32427
|
-
import { existsSync as
|
|
32428
|
-
import { basename as
|
|
32846
|
+
import { existsSync as existsSync66 } from "fs";
|
|
32847
|
+
import { basename as basename21, dirname as dirname35 } from "path";
|
|
32429
32848
|
|
|
32430
32849
|
// src/commands/sessions/daemon/worktree/nextWorktreePath.ts
|
|
32431
|
-
import { basename as
|
|
32850
|
+
import { basename as basename20, join as join80 } from "path";
|
|
32432
32851
|
function nextWorktreePath(clone, base, isTaken) {
|
|
32433
|
-
const name =
|
|
32852
|
+
const name = basename20(clone);
|
|
32434
32853
|
for (let n = 2; n < 1e3; n++) {
|
|
32435
|
-
const candidate =
|
|
32854
|
+
const candidate = join80(base, `${name}-${n}`);
|
|
32436
32855
|
if (!isTaken(candidate)) return candidate;
|
|
32437
32856
|
}
|
|
32438
32857
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -32456,7 +32875,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
32456
32875
|
const base = strategy.root ? expandTilde(strategy.root) : dirname35(clone);
|
|
32457
32876
|
const registered = new Set(listWorktreePaths(clone));
|
|
32458
32877
|
const branches = new Set(listLocalBranches(clone));
|
|
32459
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
32878
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync66(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename21(candidate));
|
|
32460
32879
|
const path109 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
32461
32880
|
const ready = addWorktree(clone, path109, strategy.trunk);
|
|
32462
32881
|
ready.catch(() => {
|
|
@@ -32479,13 +32898,13 @@ async function addWorktree(clone, path109, trunk) {
|
|
|
32479
32898
|
"add",
|
|
32480
32899
|
start2.track ? "--track" : "--no-track",
|
|
32481
32900
|
"-b",
|
|
32482
|
-
|
|
32901
|
+
basename21(path109),
|
|
32483
32902
|
path109,
|
|
32484
32903
|
start2.ref
|
|
32485
32904
|
]);
|
|
32486
32905
|
recordWorktree(path109, clone, getCachedOrigin(clone));
|
|
32487
32906
|
daemonLog(
|
|
32488
|
-
start2.track ? `worktree allocated ${path109} (branch ${
|
|
32907
|
+
start2.track ? `worktree allocated ${path109} (branch ${basename21(path109)} tracking ${start2.ref}) for clone ${clone}` : `worktree allocated ${path109} (branch ${basename21(path109)} off ${start2.ref}, no mainline tracking) for clone ${clone}`
|
|
32489
32908
|
);
|
|
32490
32909
|
}
|
|
32491
32910
|
|
|
@@ -32696,8 +33115,8 @@ function persistedTreeRoots() {
|
|
|
32696
33115
|
}
|
|
32697
33116
|
|
|
32698
33117
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
32699
|
-
import { copyFileSync, existsSync as
|
|
32700
|
-
import { dirname as dirname36, join as
|
|
33118
|
+
import { copyFileSync, existsSync as existsSync68, mkdirSync as mkdirSync24 } from "fs";
|
|
33119
|
+
import { dirname as dirname36, join as join82 } from "path";
|
|
32701
33120
|
|
|
32702
33121
|
// src/commands/sessions/daemon/worktree/installPaths.ts
|
|
32703
33122
|
import { resolve as resolve22 } from "path";
|
|
@@ -32727,14 +33146,14 @@ function pendingPathAction(enclosing, states2, paths, stopped) {
|
|
|
32727
33146
|
}
|
|
32728
33147
|
|
|
32729
33148
|
// src/commands/sessions/daemon/worktree/detectInstallCommand.ts
|
|
32730
|
-
import { existsSync as
|
|
32731
|
-
import { join as
|
|
33149
|
+
import { existsSync as existsSync67 } from "fs";
|
|
33150
|
+
import { join as join81 } from "path";
|
|
32732
33151
|
function detectInstallCommand(dir) {
|
|
32733
|
-
if (!
|
|
32734
|
-
if (
|
|
32735
|
-
if (
|
|
32736
|
-
if (
|
|
32737
|
-
if (
|
|
33152
|
+
if (!existsSync67(join81(dir, "package.json"))) return null;
|
|
33153
|
+
if (existsSync67(join81(dir, "pnpm-lock.yaml"))) return "pnpm install";
|
|
33154
|
+
if (existsSync67(join81(dir, "yarn.lock"))) return "yarn install";
|
|
33155
|
+
if (existsSync67(join81(dir, "bun.lockb"))) return "bun install";
|
|
33156
|
+
if (existsSync67(join81(dir, "package-lock.json"))) return "npm ci";
|
|
32738
33157
|
return "npm install";
|
|
32739
33158
|
}
|
|
32740
33159
|
|
|
@@ -32926,9 +33345,9 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
32926
33345
|
}
|
|
32927
33346
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
32928
33347
|
for (const rel of copy) {
|
|
32929
|
-
const src =
|
|
32930
|
-
if (!
|
|
32931
|
-
const dest =
|
|
33348
|
+
const src = join82(clone, rel);
|
|
33349
|
+
if (!existsSync68(src)) continue;
|
|
33350
|
+
const dest = join82(worktreePath, rel);
|
|
32932
33351
|
try {
|
|
32933
33352
|
mkdirSync24(dirname36(dest), { recursive: true });
|
|
32934
33353
|
copyFileSync(src, dest);
|
|
@@ -33203,7 +33622,7 @@ function buildPrompt2(rebase) {
|
|
|
33203
33622
|
async function fixConflict(number, options2 = {}) {
|
|
33204
33623
|
const { resumeSessionId } = options2;
|
|
33205
33624
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
33206
|
-
const claudeSessionId = resumeSessionId ??
|
|
33625
|
+
const claudeSessionId = resumeSessionId ?? randomUUID18();
|
|
33207
33626
|
emitActivity({
|
|
33208
33627
|
kind: "command",
|
|
33209
33628
|
name: "fix-conflict",
|
|
@@ -33231,7 +33650,7 @@ function registerFixConflict(program, resumeFlag) {
|
|
|
33231
33650
|
}
|
|
33232
33651
|
|
|
33233
33652
|
// src/commands/reviewPrComments.ts
|
|
33234
|
-
import { randomUUID as
|
|
33653
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
33235
33654
|
function buildPrompt3(number, announce, options2) {
|
|
33236
33655
|
const args = [
|
|
33237
33656
|
"/review-pr-comments",
|
|
@@ -33250,7 +33669,7 @@ async function reviewPrComments(number, options2 = {}) {
|
|
|
33250
33669
|
const resumeSessionId = options2.resumeSessionId;
|
|
33251
33670
|
validateAnnounce(number, announce);
|
|
33252
33671
|
if (number && !resumeSessionId) await checkoutPr(number);
|
|
33253
|
-
const claudeSessionId = resumeSessionId ??
|
|
33672
|
+
const claudeSessionId = resumeSessionId ?? randomUUID19();
|
|
33254
33673
|
emitActivity({
|
|
33255
33674
|
kind: "command",
|
|
33256
33675
|
name: "review-pr-comments",
|
|
@@ -33397,13 +33816,13 @@ function registerLitellm(program) {
|
|
|
33397
33816
|
}
|
|
33398
33817
|
|
|
33399
33818
|
// src/commands/mermaidExport.ts
|
|
33400
|
-
import { mkdirSync as mkdirSync25, readdirSync as
|
|
33819
|
+
import { mkdirSync as mkdirSync25, readdirSync as readdirSync16 } from "fs";
|
|
33401
33820
|
import { resolve as resolve24 } from "path";
|
|
33402
33821
|
import chalk197 from "chalk";
|
|
33403
33822
|
|
|
33404
33823
|
// src/commands/mermaid/exportFile.ts
|
|
33405
|
-
import { readFileSync as
|
|
33406
|
-
import { basename as
|
|
33824
|
+
import { readFileSync as readFileSync48, writeFileSync as writeFileSync36 } from "fs";
|
|
33825
|
+
import { basename as basename22, extname as extname4, resolve as resolve23 } from "path";
|
|
33407
33826
|
import chalk196 from "chalk";
|
|
33408
33827
|
|
|
33409
33828
|
// src/commands/mermaid/renderBlock.ts
|
|
@@ -33428,9 +33847,9 @@ async function renderBlock(krokiUrl, source) {
|
|
|
33428
33847
|
|
|
33429
33848
|
// src/commands/mermaid/exportFile.ts
|
|
33430
33849
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
33431
|
-
const content =
|
|
33850
|
+
const content = readFileSync48(file, "utf8");
|
|
33432
33851
|
const blocks2 = extractMermaidBlocks(content);
|
|
33433
|
-
const stem =
|
|
33852
|
+
const stem = basename22(file, extname4(file));
|
|
33434
33853
|
if (onlyIndex !== void 0) {
|
|
33435
33854
|
if (onlyIndex < 1 || onlyIndex > blocks2.length) {
|
|
33436
33855
|
console.error(
|
|
@@ -33479,7 +33898,7 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
33479
33898
|
process.exit(1);
|
|
33480
33899
|
}
|
|
33481
33900
|
}
|
|
33482
|
-
const files = file ? [file] :
|
|
33901
|
+
const files = file ? [file] : readdirSync16(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
33483
33902
|
if (files.length === 0) {
|
|
33484
33903
|
console.log(chalk197.gray("No markdown files found in current directory."));
|
|
33485
33904
|
return;
|
|
@@ -33640,14 +34059,14 @@ function applyIgnore(texts, ignore3) {
|
|
|
33640
34059
|
}
|
|
33641
34060
|
|
|
33642
34061
|
// src/commands/miro/readIgnoreList.ts
|
|
33643
|
-
import { existsSync as
|
|
34062
|
+
import { existsSync as existsSync69, readFileSync as readFileSync49 } from "fs";
|
|
33644
34063
|
import { parse as parse2 } from "yaml";
|
|
33645
34064
|
function readIgnoreList(file) {
|
|
33646
|
-
if (!
|
|
34065
|
+
if (!existsSync69(file))
|
|
33647
34066
|
throw new MiroExtractError(
|
|
33648
34067
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
33649
34068
|
);
|
|
33650
|
-
const parsed = parse2(
|
|
34069
|
+
const parsed = parse2(readFileSync49(file, "utf8"));
|
|
33651
34070
|
if (parsed === null || parsed === void 0) return [];
|
|
33652
34071
|
if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string"))
|
|
33653
34072
|
throw new MiroExtractError(
|
|
@@ -33788,7 +34207,7 @@ async function offerSaveExtract(extract2, options2, paths = {}) {
|
|
|
33788
34207
|
}
|
|
33789
34208
|
|
|
33790
34209
|
// src/commands/miro/pickAnchors.ts
|
|
33791
|
-
import { randomUUID as
|
|
34210
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
33792
34211
|
|
|
33793
34212
|
// src/commands/miro/isBox.ts
|
|
33794
34213
|
var boxTypes = /* @__PURE__ */ new Set(["shape", "sticky_note"]);
|
|
@@ -33809,7 +34228,7 @@ async function pickAnchors(sessionId2, items3) {
|
|
|
33809
34228
|
"Miro anchor selection",
|
|
33810
34229
|
{
|
|
33811
34230
|
sessionId: sessionId2,
|
|
33812
|
-
requestId:
|
|
34231
|
+
requestId: randomUUID20(),
|
|
33813
34232
|
title: "Pick the top-left then the bottom-right box",
|
|
33814
34233
|
body: encodeMiroBoardPreview(items3),
|
|
33815
34234
|
prNumber: null,
|
|
@@ -33827,7 +34246,7 @@ async function pickAnchors(sessionId2, items3) {
|
|
|
33827
34246
|
}
|
|
33828
34247
|
|
|
33829
34248
|
// src/commands/miro/readMiroItems.ts
|
|
33830
|
-
import { readFileSync as
|
|
34249
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
33831
34250
|
function tryParse(text20) {
|
|
33832
34251
|
try {
|
|
33833
34252
|
return JSON.parse(text20);
|
|
@@ -33856,7 +34275,7 @@ function parsePages(raw, file) {
|
|
|
33856
34275
|
return Array.isArray(parsed) ? parsed.map(toPage) : [toPage(parsed)];
|
|
33857
34276
|
}
|
|
33858
34277
|
function readMiroItems(file) {
|
|
33859
|
-
const items3 = parsePages(
|
|
34278
|
+
const items3 = parsePages(readFileSync50(file, "utf8"), file).flatMap(
|
|
33860
34279
|
(page) => page.data ?? []
|
|
33861
34280
|
);
|
|
33862
34281
|
if (items3.length === 0)
|
|
@@ -34128,15 +34547,15 @@ function createNetcapHandler(options2) {
|
|
|
34128
34547
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
34129
34548
|
import { cp as cp4, readFile as readFile7, writeFile as writeFile6 } from "fs/promises";
|
|
34130
34549
|
import { networkInterfaces } from "os";
|
|
34131
|
-
import { join as
|
|
34550
|
+
import { join as join84 } from "path";
|
|
34132
34551
|
import chalk200 from "chalk";
|
|
34133
34552
|
|
|
34134
34553
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
34135
|
-
import { dirname as dirname38, join as
|
|
34554
|
+
import { dirname as dirname38, join as join83 } from "path";
|
|
34136
34555
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
34137
34556
|
var moduleDir2 = dirname38(fileURLToPath7(import.meta.url));
|
|
34138
34557
|
function netcapExtensionDir() {
|
|
34139
|
-
return
|
|
34558
|
+
return join83(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
34140
34559
|
}
|
|
34141
34560
|
|
|
34142
34561
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -34151,7 +34570,7 @@ function lanIPv4() {
|
|
|
34151
34570
|
return void 0;
|
|
34152
34571
|
}
|
|
34153
34572
|
async function configureBackground(dir, host, port, filter) {
|
|
34154
|
-
const file =
|
|
34573
|
+
const file = join84(dir, "background.js");
|
|
34155
34574
|
const source = await readFile7(file, "utf8");
|
|
34156
34575
|
await writeFile6(
|
|
34157
34576
|
file,
|
|
@@ -34191,20 +34610,20 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
34191
34610
|
}
|
|
34192
34611
|
|
|
34193
34612
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
34194
|
-
import { isAbsolute as isAbsolute6, join as
|
|
34613
|
+
import { isAbsolute as isAbsolute6, join as join86, resolve as resolve26 } from "path";
|
|
34195
34614
|
|
|
34196
34615
|
// src/commands/netcap/defaultCapturePath.ts
|
|
34197
34616
|
import { homedir as homedir24 } from "os";
|
|
34198
|
-
import { join as
|
|
34617
|
+
import { join as join85 } from "path";
|
|
34199
34618
|
function defaultCapturePath() {
|
|
34200
|
-
return
|
|
34619
|
+
return join85(homedir24(), ".assist", "netcap", "capture.jsonl");
|
|
34201
34620
|
}
|
|
34202
34621
|
|
|
34203
34622
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
34204
34623
|
function resolveNetcapOutPath(out) {
|
|
34205
34624
|
if (!out) return defaultCapturePath();
|
|
34206
34625
|
const dir = isAbsolute6(out) ? out : resolve26(process.cwd(), out);
|
|
34207
|
-
return
|
|
34626
|
+
return join86(dir, "capture.jsonl");
|
|
34208
34627
|
}
|
|
34209
34628
|
|
|
34210
34629
|
// src/commands/netcap/netcap.ts
|
|
@@ -34251,11 +34670,11 @@ netcap stopped \u2014 captured ${count10} ${count10 === 1 ? "entry" : "entries"}
|
|
|
34251
34670
|
|
|
34252
34671
|
// src/commands/netcap/netcapExtract.ts
|
|
34253
34672
|
import { writeFileSync as writeFileSync38 } from "fs";
|
|
34254
|
-
import { join as
|
|
34673
|
+
import { join as join87 } from "path";
|
|
34255
34674
|
import chalk202 from "chalk";
|
|
34256
34675
|
|
|
34257
34676
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
34258
|
-
import { readFileSync as
|
|
34677
|
+
import { readFileSync as readFileSync51 } from "fs";
|
|
34259
34678
|
|
|
34260
34679
|
// src/commands/netcap/parseRscRows.ts
|
|
34261
34680
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -34651,7 +35070,7 @@ function extractVoyagerPosts(body) {
|
|
|
34651
35070
|
|
|
34652
35071
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
34653
35072
|
function captureEntries(captureFile) {
|
|
34654
|
-
const lines =
|
|
35073
|
+
const lines = readFileSync51(captureFile, "utf8").split("\n").filter(Boolean);
|
|
34655
35074
|
const entries = [];
|
|
34656
35075
|
for (const line of lines) {
|
|
34657
35076
|
let entry;
|
|
@@ -34696,7 +35115,7 @@ function extractPostsFromCapture(captureFile) {
|
|
|
34696
35115
|
function netcapExtract(file) {
|
|
34697
35116
|
const captureFile = file ?? defaultCapturePath();
|
|
34698
35117
|
const posts = extractPostsFromCapture(captureFile);
|
|
34699
|
-
const outFile =
|
|
35118
|
+
const outFile = join87(captureFile, "..", "posts.json");
|
|
34700
35119
|
writeFileSync38(outFile, `${JSON.stringify(posts, null, 2)}
|
|
34701
35120
|
`);
|
|
34702
35121
|
console.log(
|
|
@@ -35040,13 +35459,13 @@ function postReviewComment(vars) {
|
|
|
35040
35459
|
}
|
|
35041
35460
|
|
|
35042
35461
|
// src/commands/prs/reviewProposedPrComment.ts
|
|
35043
|
-
import { randomUUID as
|
|
35462
|
+
import { randomUUID as randomUUID21 } from "crypto";
|
|
35044
35463
|
async function reviewProposedPrComment(title, body, prNumber) {
|
|
35045
35464
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
35046
35465
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
|
|
35047
35466
|
await awaitPreviewApproval("PR comment preview", {
|
|
35048
35467
|
sessionId: sessionId2,
|
|
35049
|
-
requestId:
|
|
35468
|
+
requestId: randomUUID21(),
|
|
35050
35469
|
title,
|
|
35051
35470
|
body,
|
|
35052
35471
|
prNumber,
|
|
@@ -35092,9 +35511,9 @@ async function comment2(path109, line, body, options2 = {}) {
|
|
|
35092
35511
|
|
|
35093
35512
|
// src/commands/prs/commentsCachePath.ts
|
|
35094
35513
|
import { homedir as homedir25 } from "os";
|
|
35095
|
-
import { join as
|
|
35514
|
+
import { join as join88 } from "path";
|
|
35096
35515
|
function commentsCachePath(org, repo, prNumber) {
|
|
35097
|
-
return
|
|
35516
|
+
return join88(
|
|
35098
35517
|
homedir25(),
|
|
35099
35518
|
".assist",
|
|
35100
35519
|
"pr-comments",
|
|
@@ -35110,38 +35529,38 @@ import { dirname as dirname40 } from "path";
|
|
|
35110
35529
|
import { stringify as stringify3 } from "yaml";
|
|
35111
35530
|
|
|
35112
35531
|
// src/commands/prs/loadCommentsCache.ts
|
|
35113
|
-
import { existsSync as
|
|
35532
|
+
import { existsSync as existsSync70, readFileSync as readFileSync52, unlinkSync as unlinkSync14 } from "fs";
|
|
35114
35533
|
import { parse as parse3 } from "yaml";
|
|
35115
35534
|
function loadCommentsCache(org, repo, prNumber) {
|
|
35116
35535
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
35117
|
-
if (!
|
|
35536
|
+
if (!existsSync70(cachePath)) {
|
|
35118
35537
|
return null;
|
|
35119
35538
|
}
|
|
35120
|
-
const content =
|
|
35539
|
+
const content = readFileSync52(cachePath, "utf8");
|
|
35121
35540
|
return parse3(content);
|
|
35122
35541
|
}
|
|
35123
35542
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
35124
35543
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
35125
|
-
if (
|
|
35544
|
+
if (existsSync70(cachePath)) {
|
|
35126
35545
|
unlinkSync14(cachePath);
|
|
35127
35546
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
35128
35547
|
}
|
|
35129
35548
|
}
|
|
35130
35549
|
|
|
35131
35550
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
35132
|
-
import { readdirSync as
|
|
35133
|
-
import { join as
|
|
35551
|
+
import { readdirSync as readdirSync17, unlinkSync as unlinkSync15 } from "fs";
|
|
35552
|
+
import { join as join89 } from "path";
|
|
35134
35553
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
35135
35554
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
35136
|
-
const dir =
|
|
35555
|
+
const dir = join89(cwd, ".assist");
|
|
35137
35556
|
let entries;
|
|
35138
35557
|
try {
|
|
35139
|
-
entries =
|
|
35558
|
+
entries = readdirSync17(dir);
|
|
35140
35559
|
} catch {
|
|
35141
35560
|
return;
|
|
35142
35561
|
}
|
|
35143
35562
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
35144
|
-
unlinkSync15(
|
|
35563
|
+
unlinkSync15(join89(dir, entry));
|
|
35145
35564
|
}
|
|
35146
35565
|
}
|
|
35147
35566
|
|
|
@@ -35258,8 +35677,8 @@ function failAzureDevops(error) {
|
|
|
35258
35677
|
// src/commands/prs/azureDevops/invokeAzDevops.ts
|
|
35259
35678
|
import { execFileSync as execFileSync20 } from "child_process";
|
|
35260
35679
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync40 } from "fs";
|
|
35261
|
-
import { tmpdir as
|
|
35262
|
-
import { join as
|
|
35680
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
35681
|
+
import { join as join90 } from "path";
|
|
35263
35682
|
function azDevopsInvokeArgs(request, inFile) {
|
|
35264
35683
|
return [
|
|
35265
35684
|
"devops",
|
|
@@ -35294,8 +35713,8 @@ function runAz2(args) {
|
|
|
35294
35713
|
}
|
|
35295
35714
|
function invokeAzDevops(request) {
|
|
35296
35715
|
if (request.body === void 0) return runAz2(azDevopsInvokeArgs(request));
|
|
35297
|
-
const dir = mkdtempSync2(
|
|
35298
|
-
const inFile =
|
|
35716
|
+
const dir = mkdtempSync2(join90(tmpdir7(), "assist-az-"));
|
|
35717
|
+
const inFile = join90(dir, "body.json");
|
|
35299
35718
|
try {
|
|
35300
35719
|
writeFileSync40(inFile, JSON.stringify(request.body));
|
|
35301
35720
|
return runAz2(azDevopsInvokeArgs(request, inFile));
|
|
@@ -35488,7 +35907,7 @@ function colouredState(state) {
|
|
|
35488
35907
|
return chalk208.yellow(label);
|
|
35489
35908
|
}
|
|
35490
35909
|
function commentStyle() {
|
|
35491
|
-
if (
|
|
35910
|
+
if (isAgentHarness()) {
|
|
35492
35911
|
return {
|
|
35493
35912
|
cyan: plain,
|
|
35494
35913
|
bold: plain,
|
|
@@ -36040,7 +36459,7 @@ ${resolves}` : baseWhy);
|
|
|
36040
36459
|
|
|
36041
36460
|
// src/commands/prs/parseScreenshotSpec.ts
|
|
36042
36461
|
import { statSync as statSync10 } from "fs";
|
|
36043
|
-
import { basename as
|
|
36462
|
+
import { basename as basename23, extname as extname5, resolve as resolve27 } from "path";
|
|
36044
36463
|
function splitOnce(value, separator) {
|
|
36045
36464
|
const index3 = value.indexOf(separator);
|
|
36046
36465
|
if (index3 === -1) return null;
|
|
@@ -36064,7 +36483,7 @@ function parseScreenshotSpec(spec) {
|
|
|
36064
36483
|
throw new Error(
|
|
36065
36484
|
`--screenshot '${spec}': gh cannot attach .${ext || "(none)"} files (supported: ${[...ghAttachableExtensions].join(", ")}).`
|
|
36066
36485
|
);
|
|
36067
|
-
const alt = caption.trim() ||
|
|
36486
|
+
const alt = caption.trim() || basename23(path109, extname5(path109));
|
|
36068
36487
|
return group.trim() ? { path: path109, alt, group: group.trim() } : { path: path109, alt };
|
|
36069
36488
|
}
|
|
36070
36489
|
|
|
@@ -36079,16 +36498,16 @@ function parseScreenshotSpecs(specs) {
|
|
|
36079
36498
|
}
|
|
36080
36499
|
|
|
36081
36500
|
// src/commands/prs/previewAndApplyEdit.ts
|
|
36082
|
-
import { randomUUID as
|
|
36501
|
+
import { randomUUID as randomUUID22 } from "crypto";
|
|
36083
36502
|
|
|
36084
36503
|
// src/commands/prs/stageScreenshots.ts
|
|
36085
36504
|
import { readFile as readFile8 } from "fs/promises";
|
|
36086
|
-
import { basename as
|
|
36505
|
+
import { basename as basename24 } from "path";
|
|
36087
36506
|
function stageScreenshots(screenshots = []) {
|
|
36088
36507
|
return Promise.all(
|
|
36089
36508
|
screenshots.map(async (screenshot2) => {
|
|
36090
36509
|
const { filePath } = await stageAttachment(
|
|
36091
|
-
|
|
36510
|
+
basename24(screenshot2.path),
|
|
36092
36511
|
attachmentContentType(screenshot2.path),
|
|
36093
36512
|
await readFile8(screenshot2.path)
|
|
36094
36513
|
);
|
|
@@ -36101,7 +36520,7 @@ function stageScreenshots(screenshots = []) {
|
|
|
36101
36520
|
async function previewAndApplyEdit(args) {
|
|
36102
36521
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
36103
36522
|
sessionId: args.sessionId,
|
|
36104
|
-
requestId:
|
|
36523
|
+
requestId: randomUUID22(),
|
|
36105
36524
|
title: args.title ?? args.currentTitle,
|
|
36106
36525
|
body: args.body,
|
|
36107
36526
|
prNumber: args.number,
|
|
@@ -36436,7 +36855,7 @@ async function placePr(prNumber, title, body, options2, attachments = []) {
|
|
|
36436
36855
|
}
|
|
36437
36856
|
|
|
36438
36857
|
// src/commands/prs/previewAndPlace.ts
|
|
36439
|
-
import { randomUUID as
|
|
36858
|
+
import { randomUUID as randomUUID23 } from "crypto";
|
|
36440
36859
|
|
|
36441
36860
|
// src/commands/review/announcePr.ts
|
|
36442
36861
|
function announcePr(prNumber) {
|
|
@@ -36512,7 +36931,7 @@ function enableAutoMerge() {
|
|
|
36512
36931
|
async function previewAndPlace(args) {
|
|
36513
36932
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
36514
36933
|
sessionId: args.sessionId,
|
|
36515
|
-
requestId:
|
|
36934
|
+
requestId: randomUUID23(),
|
|
36516
36935
|
title: args.title,
|
|
36517
36936
|
body: args.body,
|
|
36518
36937
|
prNumber: args.prNumber,
|
|
@@ -37081,7 +37500,7 @@ function registerPrsStatus(prsCommand) {
|
|
|
37081
37500
|
}
|
|
37082
37501
|
|
|
37083
37502
|
// src/commands/readTime/readTime.ts
|
|
37084
|
-
import { readFileSync as
|
|
37503
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
37085
37504
|
|
|
37086
37505
|
// src/commands/readTime/countReadingWords.ts
|
|
37087
37506
|
var FENCE_PATTERN = /^\s*(```|~~~)/;
|
|
@@ -37242,7 +37661,7 @@ async function loadBody(target) {
|
|
|
37242
37661
|
}
|
|
37243
37662
|
function readDraftFile(path109) {
|
|
37244
37663
|
try {
|
|
37245
|
-
return
|
|
37664
|
+
return readFileSync53(path109, "utf8");
|
|
37246
37665
|
} catch {
|
|
37247
37666
|
console.error(`Error: Could not read \`${path109}\`.`);
|
|
37248
37667
|
console.error(
|
|
@@ -37749,10 +38168,10 @@ function checkStreamGraph(streams) {
|
|
|
37749
38168
|
}
|
|
37750
38169
|
|
|
37751
38170
|
// src/commands/releases/readStreamsInput.ts
|
|
37752
|
-
import { readFileSync as
|
|
38171
|
+
import { readFileSync as readFileSync54 } from "fs";
|
|
37753
38172
|
import { parse as parse4 } from "yaml";
|
|
37754
38173
|
function readSource2(source) {
|
|
37755
|
-
return
|
|
38174
|
+
return readFileSync54(source === "-" ? 0 : source, "utf8");
|
|
37756
38175
|
}
|
|
37757
38176
|
function readStreamsInput(source) {
|
|
37758
38177
|
let parsed;
|
|
@@ -38167,7 +38586,7 @@ function reportViolations(violations) {
|
|
|
38167
38586
|
function runFileNameCheck(fix = false) {
|
|
38168
38587
|
const violations = checkFileNames();
|
|
38169
38588
|
if (violations.length === 0) {
|
|
38170
|
-
if (!
|
|
38589
|
+
if (!isAgentHarness()) {
|
|
38171
38590
|
console.log(
|
|
38172
38591
|
"File name check passed. All PascalCase files contain classes or components."
|
|
38173
38592
|
);
|
|
@@ -38206,7 +38625,7 @@ ${checkName2} failed:
|
|
|
38206
38625
|
}
|
|
38207
38626
|
return false;
|
|
38208
38627
|
}
|
|
38209
|
-
if (!
|
|
38628
|
+
if (!isAgentHarness()) {
|
|
38210
38629
|
console.log(successMessage);
|
|
38211
38630
|
}
|
|
38212
38631
|
return true;
|
|
@@ -38423,9 +38842,9 @@ async function notify() {
|
|
|
38423
38842
|
|
|
38424
38843
|
// src/commands/screenshot.ts
|
|
38425
38844
|
import { execSync as execSync54 } from "child_process";
|
|
38426
|
-
import { existsSync as
|
|
38427
|
-
import { tmpdir as
|
|
38428
|
-
import { join as
|
|
38845
|
+
import { existsSync as existsSync71, mkdirSync as mkdirSync28, unlinkSync as unlinkSync16, writeFileSync as writeFileSync41 } from "fs";
|
|
38846
|
+
import { tmpdir as tmpdir8 } from "os";
|
|
38847
|
+
import { join as join91, resolve as resolve28 } from "path";
|
|
38429
38848
|
import chalk229 from "chalk";
|
|
38430
38849
|
|
|
38431
38850
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -38555,14 +38974,14 @@ Write-Output $OutputPath
|
|
|
38555
38974
|
|
|
38556
38975
|
// src/commands/screenshot.ts
|
|
38557
38976
|
function buildOutputPath(outputDir, processName) {
|
|
38558
|
-
if (!
|
|
38977
|
+
if (!existsSync71(outputDir)) {
|
|
38559
38978
|
mkdirSync28(outputDir, { recursive: true });
|
|
38560
38979
|
}
|
|
38561
38980
|
const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
38562
38981
|
return resolve28(outputDir, `${processName}-${timestamp9}.png`);
|
|
38563
38982
|
}
|
|
38564
38983
|
function runPowerShellScript(processName, outputPath) {
|
|
38565
|
-
const scriptPath =
|
|
38984
|
+
const scriptPath = join91(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
|
|
38566
38985
|
writeFileSync41(scriptPath, captureWindowPs1, "utf8");
|
|
38567
38986
|
try {
|
|
38568
38987
|
execSync54(
|
|
@@ -38663,10 +39082,10 @@ function buildLimitsSegment(rateLimits) {
|
|
|
38663
39082
|
}
|
|
38664
39083
|
|
|
38665
39084
|
// src/commands/readGitBranch.ts
|
|
38666
|
-
import { readFileSync as
|
|
38667
|
-
import { isAbsolute as isAbsolute7, join as
|
|
39085
|
+
import { readFileSync as readFileSync55, statSync as statSync11 } from "fs";
|
|
39086
|
+
import { isAbsolute as isAbsolute7, join as join92, resolve as resolve29 } from "path";
|
|
38668
39087
|
function resolveGitDir(cwd) {
|
|
38669
|
-
const dotGit =
|
|
39088
|
+
const dotGit = join92(cwd, ".git");
|
|
38670
39089
|
let stat5;
|
|
38671
39090
|
try {
|
|
38672
39091
|
stat5 = statSync11(dotGit);
|
|
@@ -38678,7 +39097,7 @@ function resolveGitDir(cwd) {
|
|
|
38678
39097
|
}
|
|
38679
39098
|
let contents;
|
|
38680
39099
|
try {
|
|
38681
|
-
contents =
|
|
39100
|
+
contents = readFileSync55(dotGit, "utf8");
|
|
38682
39101
|
} catch {
|
|
38683
39102
|
return null;
|
|
38684
39103
|
}
|
|
@@ -38696,7 +39115,7 @@ function readGitBranch(cwd) {
|
|
|
38696
39115
|
}
|
|
38697
39116
|
let head;
|
|
38698
39117
|
try {
|
|
38699
|
-
head =
|
|
39118
|
+
head = readFileSync55(join92(gitDir, "HEAD"), "utf8");
|
|
38700
39119
|
} catch {
|
|
38701
39120
|
return null;
|
|
38702
39121
|
}
|
|
@@ -38881,7 +39300,7 @@ import chalk233 from "chalk";
|
|
|
38881
39300
|
var DEFAULT_MAX_LINES2 = 100;
|
|
38882
39301
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
38883
39302
|
if (violations.length === 0) {
|
|
38884
|
-
if (!
|
|
39303
|
+
if (!isAgentHarness()) {
|
|
38885
39304
|
console.log(`Refactor check passed. No files exceed ${maxLines} lines.`);
|
|
38886
39305
|
}
|
|
38887
39306
|
return;
|
|
@@ -38904,7 +39323,7 @@ Refactor check failed:
|
|
|
38904
39323
|
);
|
|
38905
39324
|
console.error(chalk233.gray(` assist refactor ignore <file>
|
|
38906
39325
|
`));
|
|
38907
|
-
if (
|
|
39326
|
+
if (isAgentHarness()) {
|
|
38908
39327
|
console.error(chalk233.cyan(`
|
|
38909
39328
|
## Extracting Code to New Files
|
|
38910
39329
|
`));
|
|
@@ -41041,10 +41460,10 @@ function registerRefactor(program) {
|
|
|
41041
41460
|
}
|
|
41042
41461
|
|
|
41043
41462
|
// src/commands/review/checkoutPrSession.ts
|
|
41044
|
-
import { randomUUID as
|
|
41463
|
+
import { randomUUID as randomUUID24 } from "crypto";
|
|
41045
41464
|
async function checkoutPrSession(number, prompt = "") {
|
|
41046
41465
|
await checkoutPr(number);
|
|
41047
|
-
const claudeSessionId =
|
|
41466
|
+
const claudeSessionId = randomUUID24();
|
|
41048
41467
|
emitActivity({ kind: "command", name: "review", claudeSessionId });
|
|
41049
41468
|
const { done: done2 } = spawnClaude(prompt, {
|
|
41050
41469
|
permissionMode: "auto",
|
|
@@ -41401,7 +41820,7 @@ function groupFilesByDirectory(files) {
|
|
|
41401
41820
|
}
|
|
41402
41821
|
|
|
41403
41822
|
// src/commands/review/highLevel/buildHighLevelTree.ts
|
|
41404
|
-
function
|
|
41823
|
+
function basename25(path109) {
|
|
41405
41824
|
return path109.slice(path109.lastIndexOf("/") + 1);
|
|
41406
41825
|
}
|
|
41407
41826
|
function sum(nodes, key) {
|
|
@@ -41416,7 +41835,7 @@ function nodesOf(at2, prefix2) {
|
|
|
41416
41835
|
);
|
|
41417
41836
|
const files = at2.files.map((file) => ({
|
|
41418
41837
|
kind: "file",
|
|
41419
|
-
name:
|
|
41838
|
+
name: basename25(file.path),
|
|
41420
41839
|
...file
|
|
41421
41840
|
}));
|
|
41422
41841
|
return [...dirs.sort(byName), ...files.sort(byName)];
|
|
@@ -41812,7 +42231,7 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
41812
42231
|
}
|
|
41813
42232
|
|
|
41814
42233
|
// src/commands/review/highLevel/gatherHighLevelSlices.ts
|
|
41815
|
-
import { readFileSync as
|
|
42234
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
41816
42235
|
|
|
41817
42236
|
// src/commands/review/highLevel/formatSlicingRequest.ts
|
|
41818
42237
|
var RULES = [
|
|
@@ -41873,12 +42292,12 @@ function formatSlicingRequest(hunks) {
|
|
|
41873
42292
|
}
|
|
41874
42293
|
|
|
41875
42294
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
41876
|
-
import { join as
|
|
42295
|
+
import { join as join93 } from "path";
|
|
41877
42296
|
function slug(value) {
|
|
41878
42297
|
return value.replace(/[^\w.-]+/g, "-");
|
|
41879
42298
|
}
|
|
41880
42299
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
41881
|
-
return
|
|
42300
|
+
return join93(
|
|
41882
42301
|
getStoreDir(),
|
|
41883
42302
|
"high-level-reviews",
|
|
41884
42303
|
slug(repo),
|
|
@@ -41930,11 +42349,11 @@ function listHighLevelHunks(files) {
|
|
|
41930
42349
|
}
|
|
41931
42350
|
|
|
41932
42351
|
// src/commands/review/highLevel/readJsonFile.ts
|
|
41933
|
-
import { existsSync as
|
|
42352
|
+
import { existsSync as existsSync72, readFileSync as readFileSync56 } from "fs";
|
|
41934
42353
|
function readJsonFile(path109) {
|
|
41935
|
-
if (!
|
|
42354
|
+
if (!existsSync72(path109)) return void 0;
|
|
41936
42355
|
try {
|
|
41937
|
-
return JSON.parse(
|
|
42356
|
+
return JSON.parse(readFileSync56(path109, "utf8"));
|
|
41938
42357
|
} catch {
|
|
41939
42358
|
return void 0;
|
|
41940
42359
|
}
|
|
@@ -42025,7 +42444,7 @@ function writeJsonFile(path109, data) {
|
|
|
42025
42444
|
// src/commands/review/highLevel/gatherHighLevelSlices.ts
|
|
42026
42445
|
function readSlicesFile(file) {
|
|
42027
42446
|
try {
|
|
42028
|
-
return JSON.parse(
|
|
42447
|
+
return JSON.parse(readFileSync57(file, "utf8"));
|
|
42029
42448
|
} catch (error) {
|
|
42030
42449
|
throw new Error(
|
|
42031
42450
|
`could not read slices from ${file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -42381,7 +42800,7 @@ function gatherHighLevelSubject(prNumber, force, slicing) {
|
|
|
42381
42800
|
}
|
|
42382
42801
|
|
|
42383
42802
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
42384
|
-
import { randomUUID as
|
|
42803
|
+
import { randomUUID as randomUUID25 } from "crypto";
|
|
42385
42804
|
|
|
42386
42805
|
// src/commands/review/highLevel/isHighLevelSliceCheck.ts
|
|
42387
42806
|
var SLICE_CHECKS = /* @__PURE__ */ new Set([
|
|
@@ -42722,7 +43141,7 @@ async function openHighLevelOverlay(sessionId2, subject, onRestart = async () =>
|
|
|
42722
43141
|
"High-level review",
|
|
42723
43142
|
{
|
|
42724
43143
|
sessionId: sessionId2,
|
|
42725
|
-
requestId:
|
|
43144
|
+
requestId: randomUUID25(),
|
|
42726
43145
|
title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
|
|
42727
43146
|
body: JSON.stringify(highLevelPreviewPayload(subject)),
|
|
42728
43147
|
prNumber: subject.prNumber,
|
|
@@ -42959,7 +43378,7 @@ async function runHighLevelReview(number, options2 = {}) {
|
|
|
42959
43378
|
}
|
|
42960
43379
|
|
|
42961
43380
|
// src/commands/review/reviewPr.ts
|
|
42962
|
-
import { basename as
|
|
43381
|
+
import { basename as basename27 } from "path";
|
|
42963
43382
|
|
|
42964
43383
|
// src/commands/review/cachedReviewerResult.ts
|
|
42965
43384
|
import { statSync as statSync12 } from "fs";
|
|
@@ -43014,7 +43433,7 @@ import { format } from "util";
|
|
|
43014
43433
|
|
|
43015
43434
|
// src/commands/review/createReviewLogSink.ts
|
|
43016
43435
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync30 } from "fs";
|
|
43017
|
-
import { join as
|
|
43436
|
+
import { join as join94 } from "path";
|
|
43018
43437
|
var LOG_FILE = "review.log";
|
|
43019
43438
|
function createReviewLogSink() {
|
|
43020
43439
|
let logPath2;
|
|
@@ -43031,7 +43450,7 @@ function createReviewLogSink() {
|
|
|
43031
43450
|
},
|
|
43032
43451
|
attach(reviewDir) {
|
|
43033
43452
|
mkdirSync30(reviewDir, { recursive: true });
|
|
43034
|
-
logPath2 =
|
|
43453
|
+
logPath2 = join94(reviewDir, LOG_FILE);
|
|
43035
43454
|
const lines = [
|
|
43036
43455
|
"",
|
|
43037
43456
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -43716,7 +44135,7 @@ function buildCodexModelArgs() {
|
|
|
43716
44135
|
}
|
|
43717
44136
|
|
|
43718
44137
|
// src/commands/review/runCodexReviewer.ts
|
|
43719
|
-
import { existsSync as
|
|
44138
|
+
import { existsSync as existsSync73, unlinkSync as unlinkSync17 } from "fs";
|
|
43720
44139
|
|
|
43721
44140
|
// src/commands/review/parseCodexUsage.ts
|
|
43722
44141
|
function parseCodexUsage(usage) {
|
|
@@ -43805,7 +44224,7 @@ async function runCodexReviewer(spec) {
|
|
|
43805
44224
|
...override.args.length > 0 ? { env: override.env } : {},
|
|
43806
44225
|
onLine
|
|
43807
44226
|
});
|
|
43808
|
-
if (result.exitCode !== 0 &&
|
|
44227
|
+
if (result.exitCode !== 0 && existsSync73(spec.outputPath)) {
|
|
43809
44228
|
unlinkSync17(spec.outputPath);
|
|
43810
44229
|
}
|
|
43811
44230
|
const finalised = finaliseReviewerRun(
|
|
@@ -43864,10 +44283,10 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
43864
44283
|
}
|
|
43865
44284
|
|
|
43866
44285
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
43867
|
-
import { existsSync as
|
|
44286
|
+
import { existsSync as existsSync74, unlinkSync as unlinkSync18 } from "fs";
|
|
43868
44287
|
|
|
43869
44288
|
// src/commands/review/synthesise.ts
|
|
43870
|
-
import { readFileSync as
|
|
44289
|
+
import { readFileSync as readFileSync58 } from "fs";
|
|
43871
44290
|
|
|
43872
44291
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
43873
44292
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -44067,7 +44486,7 @@ Files:
|
|
|
44067
44486
|
|
|
44068
44487
|
// src/commands/review/synthesise.ts
|
|
44069
44488
|
function printSummary2(synthesisPath) {
|
|
44070
|
-
const markdown =
|
|
44489
|
+
const markdown = readFileSync58(synthesisPath, "utf8");
|
|
44071
44490
|
console.log("");
|
|
44072
44491
|
console.log(buildReviewSummary(markdown));
|
|
44073
44492
|
console.log("");
|
|
@@ -44097,7 +44516,7 @@ async function synthesise(paths, options2) {
|
|
|
44097
44516
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
44098
44517
|
async function synthesiseAfterReviewers(input) {
|
|
44099
44518
|
const { paths, failures } = input;
|
|
44100
|
-
if (input.anyFresh &&
|
|
44519
|
+
if (input.anyFresh && existsSync74(paths.synthesisPath)) {
|
|
44101
44520
|
unlinkSync18(paths.synthesisPath);
|
|
44102
44521
|
}
|
|
44103
44522
|
const synthesisResult = await synthesise(paths, { multi: input.multi });
|
|
@@ -44317,21 +44736,21 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
44317
44736
|
|
|
44318
44737
|
// src/commands/review/buildReviewPaths.ts
|
|
44319
44738
|
import { homedir as homedir26 } from "os";
|
|
44320
|
-
import { basename as
|
|
44739
|
+
import { basename as basename26, join as join95 } from "path";
|
|
44321
44740
|
function buildReviewPaths(repoRoot2, key) {
|
|
44322
|
-
const reviewDir =
|
|
44741
|
+
const reviewDir = join95(
|
|
44323
44742
|
homedir26(),
|
|
44324
44743
|
".assist",
|
|
44325
44744
|
"reviews",
|
|
44326
|
-
|
|
44745
|
+
basename26(repoRoot2),
|
|
44327
44746
|
key
|
|
44328
44747
|
);
|
|
44329
44748
|
return {
|
|
44330
44749
|
reviewDir,
|
|
44331
|
-
requestPath:
|
|
44332
|
-
claudePath:
|
|
44333
|
-
codexPath:
|
|
44334
|
-
synthesisPath:
|
|
44750
|
+
requestPath: join95(reviewDir, "request.md"),
|
|
44751
|
+
claudePath: join95(reviewDir, "claude.md"),
|
|
44752
|
+
codexPath: join95(reviewDir, "codex.md"),
|
|
44753
|
+
synthesisPath: join95(reviewDir, "synthesis.md")
|
|
44335
44754
|
};
|
|
44336
44755
|
}
|
|
44337
44756
|
|
|
@@ -44369,10 +44788,10 @@ function fetchExistingComments() {
|
|
|
44369
44788
|
}
|
|
44370
44789
|
|
|
44371
44790
|
// src/commands/review/prepareReviewDir.ts
|
|
44372
|
-
import { existsSync as
|
|
44791
|
+
import { existsSync as existsSync75, mkdirSync as mkdirSync31, unlinkSync as unlinkSync19, writeFileSync as writeFileSync44 } from "fs";
|
|
44373
44792
|
function clearReviewFiles(paths) {
|
|
44374
44793
|
for (const path109 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
44375
|
-
if (
|
|
44794
|
+
if (existsSync75(path109)) unlinkSync19(path109);
|
|
44376
44795
|
}
|
|
44377
44796
|
}
|
|
44378
44797
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -44519,7 +44938,7 @@ function gatherChangedContext() {
|
|
|
44519
44938
|
}
|
|
44520
44939
|
|
|
44521
44940
|
// src/commands/review/postReviewToPr.ts
|
|
44522
|
-
import { readFileSync as
|
|
44941
|
+
import { readFileSync as readFileSync59 } from "fs";
|
|
44523
44942
|
|
|
44524
44943
|
// src/commands/review/chainAddressComments.ts
|
|
44525
44944
|
function chainAddressComments(prNumber, announce) {
|
|
@@ -44869,7 +45288,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
44869
45288
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
44870
45289
|
}
|
|
44871
45290
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
44872
|
-
const markdown =
|
|
45291
|
+
const markdown = readFileSync59(synthesisPath, "utf8");
|
|
44873
45292
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
44874
45293
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
44875
45294
|
if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
|
|
@@ -45024,7 +45443,7 @@ async function reviewPr(repoRoot2, options2) {
|
|
|
45024
45443
|
attachReviewLog(paths.reviewDir);
|
|
45025
45444
|
const outcome = await runReviewPipeline(paths, {
|
|
45026
45445
|
verbose: options2.verbose ?? false,
|
|
45027
|
-
job: { repo:
|
|
45446
|
+
job: { repo: basename27(repoRoot2), prNumber: context.prNumber }
|
|
45028
45447
|
});
|
|
45029
45448
|
if (outcome.ok) await runPostSynthesis(paths.synthesisPath, context, options2);
|
|
45030
45449
|
console.log(`Done. Review folder: ${paths.reviewDir}`);
|
|
@@ -45116,7 +45535,7 @@ async function review(options2 = {}) {
|
|
|
45116
45535
|
const invokedIn = resolveRepoRoot();
|
|
45117
45536
|
if (options2.checkoutOnly && options2.number)
|
|
45118
45537
|
return checkoutPrSession(options2.number);
|
|
45119
|
-
if (options2.highLevel && options2.number && !
|
|
45538
|
+
if (options2.highLevel && options2.number && !isAgentHarness())
|
|
45120
45539
|
return checkoutPrSession(
|
|
45121
45540
|
options2.number,
|
|
45122
45541
|
`/review-high-level ${options2.number}${options2.force ? " --force" : ""}`
|
|
@@ -45217,20 +45636,20 @@ import path88 from "path";
|
|
|
45217
45636
|
import chalk264 from "chalk";
|
|
45218
45637
|
|
|
45219
45638
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
45220
|
-
import { existsSync as
|
|
45639
|
+
import { existsSync as existsSync76, readFileSync as readFileSync61, writeFileSync as writeFileSync45 } from "fs";
|
|
45221
45640
|
import path87 from "path";
|
|
45222
45641
|
|
|
45223
45642
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
45224
|
-
import { readFileSync as
|
|
45643
|
+
import { readFileSync as readFileSync60 } from "fs";
|
|
45225
45644
|
import path86 from "path";
|
|
45226
45645
|
|
|
45227
45646
|
// src/commands/rules/findClaudeFiles.ts
|
|
45228
|
-
import { readdirSync as
|
|
45647
|
+
import { readdirSync as readdirSync18 } from "fs";
|
|
45229
45648
|
import path85 from "path";
|
|
45230
45649
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
45231
45650
|
function findClaudeFiles(dir) {
|
|
45232
45651
|
const results = [];
|
|
45233
|
-
for (const entry of
|
|
45652
|
+
for (const entry of readdirSync18(dir, { withFileTypes: true })) {
|
|
45234
45653
|
if (entry.isDirectory()) {
|
|
45235
45654
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
45236
45655
|
continue;
|
|
@@ -45245,7 +45664,7 @@ function findClaudeFiles(dir) {
|
|
|
45245
45664
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
45246
45665
|
function scopedRuleDirectories(root2) {
|
|
45247
45666
|
return findClaudeFiles(root2).filter(
|
|
45248
|
-
(file) => path86.dirname(file) !== root2 && parseRulesSection(
|
|
45667
|
+
(file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync60(file, "utf8")).length > 0
|
|
45249
45668
|
).map(
|
|
45250
45669
|
(file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
|
|
45251
45670
|
).sort();
|
|
@@ -45287,7 +45706,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
45287
45706
|
function updateScopedRulesIndex(root2) {
|
|
45288
45707
|
const directories = scopedRuleDirectories(root2);
|
|
45289
45708
|
const rootFile = path87.join(root2, "CLAUDE.md");
|
|
45290
|
-
const before =
|
|
45709
|
+
const before = existsSync76(rootFile) ? readFileSync61(rootFile, "utf8") : "";
|
|
45291
45710
|
const after = upsertScopedRulesPointer(before, directories);
|
|
45292
45711
|
if (after !== before) writeFileSync45(rootFile, after);
|
|
45293
45712
|
return directories;
|
|
@@ -45340,7 +45759,7 @@ function listRules(target, options2 = {}) {
|
|
|
45340
45759
|
}
|
|
45341
45760
|
|
|
45342
45761
|
// src/commands/rules/addRule.ts
|
|
45343
|
-
import { existsSync as
|
|
45762
|
+
import { existsSync as existsSync78, readFileSync as readFileSync63, writeFileSync as writeFileSync46 } from "fs";
|
|
45344
45763
|
import path91 from "path";
|
|
45345
45764
|
import chalk266 from "chalk";
|
|
45346
45765
|
|
|
@@ -45365,11 +45784,11 @@ function insertRuleBullet(content, rule) {
|
|
|
45365
45784
|
}
|
|
45366
45785
|
|
|
45367
45786
|
// src/commands/rules/nextRuleCode.ts
|
|
45368
|
-
import { readFileSync as
|
|
45787
|
+
import { readFileSync as readFileSync62 } from "fs";
|
|
45369
45788
|
var CODE_PREFIX = "R";
|
|
45370
45789
|
function nextRuleCode(root2) {
|
|
45371
45790
|
const numbers = findClaudeFiles(root2).flatMap(
|
|
45372
|
-
(file) => parseRulesSection(
|
|
45791
|
+
(file) => parseRulesSection(readFileSync62(file, "utf8")).map(
|
|
45373
45792
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
45374
45793
|
)
|
|
45375
45794
|
);
|
|
@@ -45377,7 +45796,7 @@ function nextRuleCode(root2) {
|
|
|
45377
45796
|
}
|
|
45378
45797
|
|
|
45379
45798
|
// src/commands/rules/resolveRuleScope.ts
|
|
45380
|
-
import { existsSync as
|
|
45799
|
+
import { existsSync as existsSync77 } from "fs";
|
|
45381
45800
|
import path90 from "path";
|
|
45382
45801
|
function resolveRuleScope(target) {
|
|
45383
45802
|
const resolved = path90.resolve(target);
|
|
@@ -45387,7 +45806,7 @@ function resolveRuleScope(target) {
|
|
|
45387
45806
|
let current2 = startDir;
|
|
45388
45807
|
while (true) {
|
|
45389
45808
|
const candidate = path90.join(current2, "CLAUDE.md");
|
|
45390
|
-
if (
|
|
45809
|
+
if (existsSync77(candidate)) return candidate;
|
|
45391
45810
|
if (current2 === root2 || current2 === path90.dirname(current2)) break;
|
|
45392
45811
|
current2 = path90.dirname(current2);
|
|
45393
45812
|
}
|
|
@@ -45396,7 +45815,7 @@ function resolveRuleScope(target) {
|
|
|
45396
45815
|
|
|
45397
45816
|
// src/commands/rules/addRule.ts
|
|
45398
45817
|
function read3(file) {
|
|
45399
|
-
return
|
|
45818
|
+
return existsSync78(file) ? readFileSync63(file, "utf8") : "";
|
|
45400
45819
|
}
|
|
45401
45820
|
function addRule(text20, options2) {
|
|
45402
45821
|
const rule = text20.trim();
|
|
@@ -45841,7 +46260,7 @@ function registerSeq(program) {
|
|
|
45841
46260
|
}
|
|
45842
46261
|
|
|
45843
46262
|
// src/commands/show.ts
|
|
45844
|
-
import { randomUUID as
|
|
46263
|
+
import { randomUUID as randomUUID26 } from "crypto";
|
|
45845
46264
|
|
|
45846
46265
|
// src/commands/sessions/shared/sendShowPreview.ts
|
|
45847
46266
|
async function sendShowPreview(request) {
|
|
@@ -45919,7 +46338,7 @@ function findShownSessionFiles(body, writtenPaths, locations) {
|
|
|
45919
46338
|
}
|
|
45920
46339
|
|
|
45921
46340
|
// src/commands/show/sessionWrittenPaths.ts
|
|
45922
|
-
import { readFileSync as
|
|
46341
|
+
import { readFileSync as readFileSync64 } from "fs";
|
|
45923
46342
|
|
|
45924
46343
|
// src/commands/sessions/shared/asRecord.ts
|
|
45925
46344
|
function asRecord(value) {
|
|
@@ -45947,7 +46366,7 @@ function writtenFilePaths(entry) {
|
|
|
45947
46366
|
function sessionWrittenPaths(transcriptPath2) {
|
|
45948
46367
|
let text20;
|
|
45949
46368
|
try {
|
|
45950
|
-
text20 =
|
|
46369
|
+
text20 = readFileSync64(transcriptPath2, "utf8");
|
|
45951
46370
|
} catch {
|
|
45952
46371
|
return [];
|
|
45953
46372
|
}
|
|
@@ -46000,7 +46419,7 @@ async function show3(options2) {
|
|
|
46000
46419
|
try {
|
|
46001
46420
|
await sendShowPreview({
|
|
46002
46421
|
sessionId: sessionId2,
|
|
46003
|
-
requestId:
|
|
46422
|
+
requestId: randomUUID26(),
|
|
46004
46423
|
title: options2.title ?? "Show",
|
|
46005
46424
|
body
|
|
46006
46425
|
});
|
|
@@ -46066,12 +46485,12 @@ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync48 } from "fs";
|
|
|
46066
46485
|
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync47 } from "fs";
|
|
46067
46486
|
|
|
46068
46487
|
// src/commands/slack/readSlackParts.ts
|
|
46069
|
-
import { readFileSync as
|
|
46488
|
+
import { readFileSync as readFileSync65 } from "fs";
|
|
46070
46489
|
function readSlackParts(files) {
|
|
46071
46490
|
return files.map((file) => {
|
|
46072
46491
|
let contents;
|
|
46073
46492
|
try {
|
|
46074
|
-
contents =
|
|
46493
|
+
contents = readFileSync65(file, "utf8");
|
|
46075
46494
|
} catch {
|
|
46076
46495
|
console.error(`Error: Part file not found: ${file}`);
|
|
46077
46496
|
process.exit(1);
|
|
@@ -46086,7 +46505,7 @@ function readSlackParts(files) {
|
|
|
46086
46505
|
}
|
|
46087
46506
|
|
|
46088
46507
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
46089
|
-
import { randomUUID as
|
|
46508
|
+
import { randomUUID as randomUUID27 } from "crypto";
|
|
46090
46509
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
46091
46510
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
46092
46511
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId2) return;
|
|
@@ -46096,7 +46515,7 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
46096
46515
|
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
46097
46516
|
{
|
|
46098
46517
|
sessionId: sessionId2,
|
|
46099
|
-
requestId:
|
|
46518
|
+
requestId: randomUUID27(),
|
|
46100
46519
|
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
46101
46520
|
body,
|
|
46102
46521
|
prNumber: null,
|
|
@@ -46109,12 +46528,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
46109
46528
|
}
|
|
46110
46529
|
|
|
46111
46530
|
// src/commands/slack/slackWorkingFile.ts
|
|
46112
|
-
import { join as
|
|
46531
|
+
import { join as join96 } from "path";
|
|
46113
46532
|
function slackWorkingFile(channel, partIndex) {
|
|
46114
46533
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
46115
|
-
const dir =
|
|
46534
|
+
const dir = join96(getStoreDir(), "slack");
|
|
46116
46535
|
const name = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
46117
|
-
return { dir, bodyPath:
|
|
46536
|
+
return { dir, bodyPath: join96(dir, `${name}.md`) };
|
|
46118
46537
|
}
|
|
46119
46538
|
|
|
46120
46539
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -46936,142 +47355,13 @@ function registerSync(program) {
|
|
|
46936
47355
|
|
|
46937
47356
|
// src/commands/testflight/testflightAdd.ts
|
|
46938
47357
|
import chalk281 from "chalk";
|
|
46939
|
-
|
|
46940
|
-
// src/commands/testflight/addToBetaGroup.ts
|
|
46941
|
-
async function addToBetaGroup(client, groupId, email) {
|
|
46942
|
-
const inGroup = await client.get("/v1/betaTesters", {
|
|
46943
|
-
"filter[email]": email,
|
|
46944
|
-
"filter[betaGroups]": groupId,
|
|
46945
|
-
limit: "1"
|
|
46946
|
-
});
|
|
46947
|
-
if (inGroup.data.length > 0) return "already-in-group";
|
|
46948
|
-
const existing = await client.get("/v1/betaTesters", {
|
|
46949
|
-
"filter[email]": email,
|
|
46950
|
-
limit: "1"
|
|
46951
|
-
});
|
|
46952
|
-
const tester = existing.data[0];
|
|
46953
|
-
if (tester) {
|
|
46954
|
-
await client.post(`/v1/betaGroups/${groupId}/relationships/betaTesters`, {
|
|
46955
|
-
data: [{ type: "betaTesters", id: tester.id }]
|
|
46956
|
-
});
|
|
46957
|
-
return "added";
|
|
46958
|
-
}
|
|
46959
|
-
await client.post("/v1/betaTesters", {
|
|
46960
|
-
data: {
|
|
46961
|
-
type: "betaTesters",
|
|
46962
|
-
attributes: { email },
|
|
46963
|
-
relationships: {
|
|
46964
|
-
betaGroups: { data: [{ type: "betaGroups", id: groupId }] }
|
|
46965
|
-
}
|
|
46966
|
-
}
|
|
46967
|
-
});
|
|
46968
|
-
return "created";
|
|
46969
|
-
}
|
|
46970
|
-
|
|
46971
|
-
// src/commands/testflight/nameFromEmail.ts
|
|
46972
|
-
function capitalise(word) {
|
|
46973
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
46974
|
-
}
|
|
46975
|
-
function nameFromEmail(email) {
|
|
46976
|
-
const [first = email, ...rest] = email.split("@")[0].split(/[._+-]+/).filter(Boolean).map(capitalise);
|
|
46977
|
-
return { firstName: first, lastName: rest.join(" ") || "Tester" };
|
|
46978
|
-
}
|
|
46979
|
-
|
|
46980
|
-
// src/commands/testflight/inviteTeamMember.ts
|
|
46981
|
-
async function inviteTeamMember(client, appId, email) {
|
|
46982
|
-
const { firstName, lastName } = nameFromEmail(email);
|
|
46983
|
-
await client.post("/v1/userInvitations", {
|
|
46984
|
-
data: {
|
|
46985
|
-
type: "userInvitations",
|
|
46986
|
-
attributes: {
|
|
46987
|
-
email,
|
|
46988
|
-
firstName,
|
|
46989
|
-
lastName,
|
|
46990
|
-
roles: ["DEVELOPER"],
|
|
46991
|
-
allAppsVisible: false,
|
|
46992
|
-
provisioningAllowed: false
|
|
46993
|
-
},
|
|
46994
|
-
relationships: {
|
|
46995
|
-
visibleApps: { data: [{ type: "apps", id: appId }] }
|
|
46996
|
-
}
|
|
46997
|
-
}
|
|
46998
|
-
});
|
|
46999
|
-
}
|
|
47000
|
-
|
|
47001
|
-
// src/commands/testflight/addInternalTester.ts
|
|
47002
|
-
async function hasMatch(client, path109, params, attribute, email) {
|
|
47003
|
-
const { data } = await client.get(path109, params);
|
|
47004
|
-
return data.some(
|
|
47005
|
-
(item) => String(item.attributes?.[attribute]).toLowerCase() === email.toLowerCase()
|
|
47006
|
-
);
|
|
47007
|
-
}
|
|
47008
|
-
async function addInternalTester(client, target, email) {
|
|
47009
|
-
const isMember = await hasMatch(
|
|
47010
|
-
client,
|
|
47011
|
-
"/v1/users",
|
|
47012
|
-
{ "filter[username]": email, "fields[users]": "username" },
|
|
47013
|
-
"username",
|
|
47014
|
-
email
|
|
47015
|
-
);
|
|
47016
|
-
if (isMember) return addToBetaGroup(client, target.groupId, email);
|
|
47017
|
-
const isInvited = await hasMatch(
|
|
47018
|
-
client,
|
|
47019
|
-
"/v1/userInvitations",
|
|
47020
|
-
{ "filter[email]": email, "fields[userInvitations]": "email" },
|
|
47021
|
-
"email",
|
|
47022
|
-
email
|
|
47023
|
-
);
|
|
47024
|
-
if (isInvited) return "invite-pending";
|
|
47025
|
-
await inviteTeamMember(client, target.appId, email);
|
|
47026
|
-
return "invited";
|
|
47027
|
-
}
|
|
47028
|
-
|
|
47029
|
-
// src/commands/testflight/requireInternalGroup.ts
|
|
47030
|
-
function requireInternalGroup(config) {
|
|
47031
|
-
if (config.internalGroup) return config.internalGroup;
|
|
47032
|
-
const entry = testflightConfigHelp.find(
|
|
47033
|
-
(help) => help.key === "testflight.internalGroup"
|
|
47034
|
-
);
|
|
47035
|
-
throw new TestflightError(
|
|
47036
|
-
`testflight.internalGroup is not set. Set it with: ${entry?.setter}`
|
|
47037
|
-
);
|
|
47038
|
-
}
|
|
47039
|
-
|
|
47040
|
-
// src/commands/testflight/addTester.ts
|
|
47041
|
-
async function addTester(config, email, options2 = {}) {
|
|
47042
|
-
const internalGroup = options2.internal ? requireInternalGroup(config) : void 0;
|
|
47043
|
-
const { client, appId } = await connectAsc(config, options2);
|
|
47044
|
-
const groupId = await findBetaGroupId(client, appId, {
|
|
47045
|
-
name: internalGroup ?? config.externalGroup,
|
|
47046
|
-
configKey: internalGroup ? "testflight.internalGroup" : "testflight.externalGroup",
|
|
47047
|
-
internal: Boolean(internalGroup)
|
|
47048
|
-
});
|
|
47049
|
-
return internalGroup ? addInternalTester(client, { appId, groupId }, email) : addToBetaGroup(client, groupId, email);
|
|
47050
|
-
}
|
|
47051
|
-
|
|
47052
|
-
// src/commands/testflight/testflightAdd.ts
|
|
47053
|
-
var messages = {
|
|
47054
|
-
created: (email, group) => `Invited ${email} to TestFlight group "${group}"`,
|
|
47055
|
-
added: (email, group) => `Added existing tester ${email} to TestFlight group "${group}"`,
|
|
47056
|
-
"already-in-group": (email, group) => `${email} is already in TestFlight group "${group}"`,
|
|
47057
|
-
invited: (email) => `Sent ${email} an App Store Connect team invite. Once they accept, re-run this command to add them to TestFlight.`,
|
|
47058
|
-
"invite-pending": (email) => `${email} has not yet accepted their App Store Connect team invite. Re-run this command once they do.`
|
|
47059
|
-
};
|
|
47060
|
-
var pending = /* @__PURE__ */ new Set([
|
|
47061
|
-
"already-in-group",
|
|
47062
|
-
"invite-pending"
|
|
47063
|
-
]);
|
|
47064
47358
|
async function testflightAdd(email, options2) {
|
|
47065
47359
|
try {
|
|
47066
47360
|
const config = readTestflightConfig(loadConfig());
|
|
47067
|
-
const
|
|
47361
|
+
const { message: message3, waiting: waiting2 } = await addTesterOutcome(config, email, {
|
|
47068
47362
|
internal: options2.internal
|
|
47069
47363
|
});
|
|
47070
|
-
|
|
47071
|
-
const message3 = messages[result](email, group);
|
|
47072
|
-
console.log(
|
|
47073
|
-
pending.has(result) ? chalk281.yellow(message3) : chalk281.green(message3)
|
|
47074
|
-
);
|
|
47364
|
+
console.log(waiting2 ? chalk281.yellow(message3) : chalk281.green(message3));
|
|
47075
47365
|
} catch (error) {
|
|
47076
47366
|
if (!(error instanceof TestflightError)) throw error;
|
|
47077
47367
|
console.error(chalk281.red(error.message));
|
|
@@ -47094,7 +47384,7 @@ function registerTestflight(program) {
|
|
|
47094
47384
|
}
|
|
47095
47385
|
|
|
47096
47386
|
// src/commands/transcript/clean.ts
|
|
47097
|
-
import { existsSync as
|
|
47387
|
+
import { existsSync as existsSync83 } from "fs";
|
|
47098
47388
|
|
|
47099
47389
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
47100
47390
|
function pad2(value, width2) {
|
|
@@ -47344,9 +47634,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
47344
47634
|
}
|
|
47345
47635
|
|
|
47346
47636
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
47347
|
-
import { readFileSync as
|
|
47637
|
+
import { readFileSync as readFileSync70 } from "fs";
|
|
47348
47638
|
function readCleanedCues(inputPath) {
|
|
47349
|
-
return deduplicateCues(parseVtt(
|
|
47639
|
+
return deduplicateCues(parseVtt(readFileSync70(inputPath, "utf8")));
|
|
47350
47640
|
}
|
|
47351
47641
|
|
|
47352
47642
|
// src/commands/transcript/clean.ts
|
|
@@ -47372,7 +47662,7 @@ function clean(file, options2 = {}) {
|
|
|
47372
47662
|
);
|
|
47373
47663
|
process.exit(1);
|
|
47374
47664
|
}
|
|
47375
|
-
if (!
|
|
47665
|
+
if (!existsSync83(file)) {
|
|
47376
47666
|
console.error(`Error: VTT file not found: ${file}`);
|
|
47377
47667
|
process.exit(1);
|
|
47378
47668
|
}
|
|
@@ -47455,21 +47745,21 @@ async function configure() {
|
|
|
47455
47745
|
}
|
|
47456
47746
|
|
|
47457
47747
|
// src/commands/transcript/list.ts
|
|
47458
|
-
import { existsSync as
|
|
47459
|
-
import { join as
|
|
47748
|
+
import { existsSync as existsSync84, readdirSync as readdirSync25, statSync as statSync13 } from "fs";
|
|
47749
|
+
import { join as join108 } from "path";
|
|
47460
47750
|
function list5() {
|
|
47461
47751
|
const { vttDir } = getTranscriptConfig();
|
|
47462
|
-
if (!
|
|
47463
|
-
for (const entry of
|
|
47752
|
+
if (!existsSync84(vttDir)) return;
|
|
47753
|
+
for (const entry of readdirSync25(vttDir)) {
|
|
47464
47754
|
if (!entry.endsWith(".vtt")) continue;
|
|
47465
|
-
if (statSync13(
|
|
47755
|
+
if (statSync13(join108(vttDir, entry)).isDirectory()) continue;
|
|
47466
47756
|
console.log(entry);
|
|
47467
47757
|
}
|
|
47468
47758
|
}
|
|
47469
47759
|
|
|
47470
47760
|
// src/commands/transcript/move.ts
|
|
47471
|
-
import { existsSync as
|
|
47472
|
-
import { basename as
|
|
47761
|
+
import { existsSync as existsSync85, mkdirSync as mkdirSync39, renameSync as renameSync5, writeFileSync as writeFileSync53 } from "fs";
|
|
47762
|
+
import { basename as basename30, join as join109 } from "path";
|
|
47473
47763
|
|
|
47474
47764
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
47475
47765
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -47479,9 +47769,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
47479
47769
|
// src/commands/transcript/move.ts
|
|
47480
47770
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
47481
47771
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
47482
|
-
const processedDir =
|
|
47772
|
+
const processedDir = join109(vttDir, "processed");
|
|
47483
47773
|
mkdirSync39(processedDir, { recursive: true });
|
|
47484
|
-
renameSync5(sourcePath,
|
|
47774
|
+
renameSync5(sourcePath, join109(processedDir, filename));
|
|
47485
47775
|
}
|
|
47486
47776
|
function move(file, options2) {
|
|
47487
47777
|
const { date, client } = options2;
|
|
@@ -47490,27 +47780,27 @@ function move(file, options2) {
|
|
|
47490
47780
|
process.exit(1);
|
|
47491
47781
|
}
|
|
47492
47782
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
47493
|
-
const filename =
|
|
47494
|
-
const sourcePath =
|
|
47495
|
-
if (!
|
|
47783
|
+
const filename = basename30(file);
|
|
47784
|
+
const sourcePath = join109(vttDir, filename);
|
|
47785
|
+
if (!existsSync85(sourcePath)) {
|
|
47496
47786
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
47497
47787
|
process.exit(1);
|
|
47498
47788
|
}
|
|
47499
|
-
const base =
|
|
47789
|
+
const base = basename30(filename, ".vtt").replace(/ Transcription$/, "");
|
|
47500
47790
|
const outputName = `${date} ${base}.md`;
|
|
47501
|
-
const formattedDir =
|
|
47791
|
+
const formattedDir = join109(transcriptsDir, client);
|
|
47502
47792
|
mkdirSync39(formattedDir, { recursive: true });
|
|
47503
|
-
const formattedPath =
|
|
47793
|
+
const formattedPath = join109(formattedDir, outputName);
|
|
47504
47794
|
writeFileSync53(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
47505
47795
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
47506
|
-
const summaryPath =
|
|
47796
|
+
const summaryPath = join109(summaryDir, client, outputName);
|
|
47507
47797
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
47508
47798
|
console.log(`Summary target: ${summaryPath}`);
|
|
47509
47799
|
}
|
|
47510
47800
|
|
|
47511
47801
|
// src/commands/transcript/merge.ts
|
|
47512
|
-
import { existsSync as
|
|
47513
|
-
import { basename as
|
|
47802
|
+
import { existsSync as existsSync86, writeFileSync as writeFileSync54 } from "fs";
|
|
47803
|
+
import { basename as basename31 } from "path";
|
|
47514
47804
|
|
|
47515
47805
|
// src/commands/transcript/failTranscript.ts
|
|
47516
47806
|
function failTranscript(message3) {
|
|
@@ -47653,10 +47943,10 @@ function widenAudience(passages) {
|
|
|
47653
47943
|
|
|
47654
47944
|
// src/commands/transcript/merge.ts
|
|
47655
47945
|
function readSource3(file) {
|
|
47656
|
-
if (!
|
|
47946
|
+
if (!existsSync86(file)) failTranscript(`VTT file not found: ${file}`);
|
|
47657
47947
|
const cues = readCleanedCues(file);
|
|
47658
47948
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
47659
|
-
return { path: file, name:
|
|
47949
|
+
return { path: file, name: basename31(file), cues };
|
|
47660
47950
|
}
|
|
47661
47951
|
function wholePassages(sources) {
|
|
47662
47952
|
return sources.map((source) => ({
|
|
@@ -48090,14 +48380,14 @@ var pendingConfigDocumentation = /* @__PURE__ */ new Set([
|
|
|
48090
48380
|
function configKeys2() {
|
|
48091
48381
|
const schemaKeys = new Set(enumerateConfigLeafKeys(assistConfigSchema));
|
|
48092
48382
|
const documented = getDocumentedConfigKeys();
|
|
48093
|
-
const
|
|
48383
|
+
const pending = pendingConfigDocumentation;
|
|
48094
48384
|
const aggregated = new Set(configHelpEntries.map((entry) => entry.key));
|
|
48095
48385
|
reportVerifyProblems(
|
|
48096
48386
|
[
|
|
48097
48387
|
verifySection(
|
|
48098
48388
|
"Config keys documented by no command (surface them with configHelp)",
|
|
48099
48389
|
[...schemaKeys].filter(
|
|
48100
|
-
(key) => !documented.has(key) && !
|
|
48390
|
+
(key) => !documented.has(key) && !pending.has(key)
|
|
48101
48391
|
)
|
|
48102
48392
|
),
|
|
48103
48393
|
verifySection(
|
|
@@ -48106,11 +48396,11 @@ function configKeys2() {
|
|
|
48106
48396
|
),
|
|
48107
48397
|
verifySection(
|
|
48108
48398
|
"Keys now documented but still in pendingConfigDocumentation (remove them)",
|
|
48109
|
-
[...
|
|
48399
|
+
[...pending].filter((key) => documented.has(key))
|
|
48110
48400
|
),
|
|
48111
48401
|
verifySection(
|
|
48112
48402
|
"pendingConfigDocumentation lists keys not in assistConfigSchema (remove them)",
|
|
48113
|
-
[...
|
|
48403
|
+
[...pending].filter((key) => !schemaKeys.has(key))
|
|
48114
48404
|
),
|
|
48115
48405
|
verifySection(
|
|
48116
48406
|
"Keys documented by a command but missing from configHelpEntries (add their module to src/commands/configHelpEntries.ts)",
|
|
@@ -48126,7 +48416,7 @@ function configKeys2() {
|
|
|
48126
48416
|
}
|
|
48127
48417
|
|
|
48128
48418
|
// src/commands/verify/forbiddenStrings.ts
|
|
48129
|
-
import { existsSync as
|
|
48419
|
+
import { existsSync as existsSync87, readFileSync as readFileSync71 } from "fs";
|
|
48130
48420
|
|
|
48131
48421
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
48132
48422
|
import { minimatch as minimatch10 } from "minimatch";
|
|
@@ -48167,13 +48457,13 @@ function forbiddenStrings() {
|
|
|
48167
48457
|
const cache7 = /* @__PURE__ */ new Map();
|
|
48168
48458
|
const readJson = (file) => {
|
|
48169
48459
|
if (cache7.has(file)) return cache7.get(file);
|
|
48170
|
-
if (!
|
|
48460
|
+
if (!existsSync87(file)) {
|
|
48171
48461
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
48172
48462
|
process.exit(1);
|
|
48173
48463
|
}
|
|
48174
48464
|
let parsed;
|
|
48175
48465
|
try {
|
|
48176
|
-
parsed = JSON.parse(
|
|
48466
|
+
parsed = JSON.parse(readFileSync71(file, "utf8"));
|
|
48177
48467
|
} catch (error) {
|
|
48178
48468
|
console.log(`Could not parse ${file}: ${error.message}`);
|
|
48179
48469
|
process.exit(1);
|
|
@@ -48245,7 +48535,7 @@ Total: ${lines.length} hardcoded color(s)`);
|
|
|
48245
48535
|
}
|
|
48246
48536
|
|
|
48247
48537
|
// src/commands/verify/migrations.ts
|
|
48248
|
-
import { readFileSync as
|
|
48538
|
+
import { readFileSync as readFileSync72 } from "fs";
|
|
48249
48539
|
import path105 from "path";
|
|
48250
48540
|
|
|
48251
48541
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
@@ -48317,15 +48607,15 @@ function checkSequential(migrations3, files) {
|
|
|
48317
48607
|
}
|
|
48318
48608
|
|
|
48319
48609
|
// src/commands/verify/migrations/listMigrationFiles.ts
|
|
48320
|
-
import { readdirSync as
|
|
48610
|
+
import { readdirSync as readdirSync26 } from "fs";
|
|
48321
48611
|
var MIGRATION_FILE2 = /^migration\d+[A-Za-z0-9]*\.ts$/;
|
|
48322
48612
|
function listMigrationFiles(dir) {
|
|
48323
|
-
return
|
|
48613
|
+
return readdirSync26(dir).filter((file) => MIGRATION_FILE2.test(file));
|
|
48324
48614
|
}
|
|
48325
48615
|
|
|
48326
48616
|
// src/commands/verify/migrations/readBaselineMigrations.ts
|
|
48327
48617
|
import { execSync as execSync63 } from "child_process";
|
|
48328
|
-
import { basename as
|
|
48618
|
+
import { basename as basename32 } from "path";
|
|
48329
48619
|
var MIGRATION_FILE3 = /^migration\d+[A-Za-z0-9]*\.ts$/;
|
|
48330
48620
|
function readBaselineMigrations(repoRelativeDir, ref) {
|
|
48331
48621
|
const baseline = /* @__PURE__ */ new Map();
|
|
@@ -48338,7 +48628,7 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
48338
48628
|
} catch {
|
|
48339
48629
|
return baseline;
|
|
48340
48630
|
}
|
|
48341
|
-
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path109) => MIGRATION_FILE3.test(
|
|
48631
|
+
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path109) => MIGRATION_FILE3.test(basename32(path109)));
|
|
48342
48632
|
for (const path109 of paths) {
|
|
48343
48633
|
try {
|
|
48344
48634
|
const content = execSync63(`git show "${ref}:${path109}"`, {
|
|
@@ -48346,7 +48636,7 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
48346
48636
|
maxBuffer: 16 * 1024 * 1024,
|
|
48347
48637
|
stdio: ["pipe", "pipe", "pipe"]
|
|
48348
48638
|
});
|
|
48349
|
-
baseline.set(
|
|
48639
|
+
baseline.set(basename32(path109), content);
|
|
48350
48640
|
} catch {
|
|
48351
48641
|
}
|
|
48352
48642
|
}
|
|
@@ -48410,7 +48700,7 @@ function migrations2() {
|
|
|
48410
48700
|
if (ref) {
|
|
48411
48701
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
48412
48702
|
const current2 = new Map(
|
|
48413
|
-
files.map((file) => [file,
|
|
48703
|
+
files.map((file) => [file, readFileSync72(path105.join(dir, file), "utf8")])
|
|
48414
48704
|
);
|
|
48415
48705
|
for (const finding of checkAppendOnly(baseline, current2)) {
|
|
48416
48706
|
problems.push(
|
|
@@ -48598,7 +48888,7 @@ function clearBuildPending() {
|
|
|
48598
48888
|
}
|
|
48599
48889
|
|
|
48600
48890
|
// src/commands/watch/isSyncPending.ts
|
|
48601
|
-
import { existsSync as
|
|
48891
|
+
import { existsSync as existsSync88 } from "fs";
|
|
48602
48892
|
|
|
48603
48893
|
// src/commands/watch/syncPendingPath.ts
|
|
48604
48894
|
function syncPendingPath(cwd) {
|
|
@@ -48608,7 +48898,7 @@ function syncPendingPath(cwd) {
|
|
|
48608
48898
|
// src/commands/watch/isSyncPending.ts
|
|
48609
48899
|
function isSyncPending() {
|
|
48610
48900
|
try {
|
|
48611
|
-
return
|
|
48901
|
+
return existsSync88(syncPendingPath());
|
|
48612
48902
|
} catch {
|
|
48613
48903
|
return false;
|
|
48614
48904
|
}
|
|
@@ -48735,7 +49025,7 @@ function resolveParams(params, cliArgs) {
|
|
|
48735
49025
|
}
|
|
48736
49026
|
|
|
48737
49027
|
// src/commands/run/resolveRunCwd.ts
|
|
48738
|
-
import { existsSync as
|
|
49028
|
+
import { existsSync as existsSync89 } from "fs";
|
|
48739
49029
|
import { resolve as resolve31 } from "path";
|
|
48740
49030
|
var MissingRunCwdError = class extends Error {
|
|
48741
49031
|
constructor(runName, cwd) {
|
|
@@ -48750,7 +49040,7 @@ var MissingRunCwdError = class extends Error {
|
|
|
48750
49040
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
48751
49041
|
if (!config.cwd) return void 0;
|
|
48752
49042
|
const cwd = resolve31(baseDir, config.cwd);
|
|
48753
|
-
if (!
|
|
49043
|
+
if (!existsSync89(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
48754
49044
|
return cwd;
|
|
48755
49045
|
}
|
|
48756
49046
|
|
|
@@ -49085,10 +49375,10 @@ ${buildWatchReport(from)}`);
|
|
|
49085
49375
|
}
|
|
49086
49376
|
|
|
49087
49377
|
// src/commands/watch/consumeMarker.ts
|
|
49088
|
-
import { existsSync as
|
|
49378
|
+
import { existsSync as existsSync90, rmSync as rmSync14 } from "fs";
|
|
49089
49379
|
function consumeMarker(path109) {
|
|
49090
49380
|
try {
|
|
49091
|
-
if (!
|
|
49381
|
+
if (!existsSync90(path109)) return false;
|
|
49092
49382
|
rmSync14(path109);
|
|
49093
49383
|
return true;
|
|
49094
49384
|
} catch {
|
|
@@ -49385,17 +49675,17 @@ function registerWatch(program) {
|
|
|
49385
49675
|
|
|
49386
49676
|
// src/commands/roam/postRoamActivity.ts
|
|
49387
49677
|
import { execFileSync as execFileSync32 } from "child_process";
|
|
49388
|
-
import { readdirSync as
|
|
49389
|
-
import { join as
|
|
49678
|
+
import { readdirSync as readdirSync27, readFileSync as readFileSync73, statSync as statSync14 } from "fs";
|
|
49679
|
+
import { join as join110 } from "path";
|
|
49390
49680
|
function findPortFile(roamDir) {
|
|
49391
49681
|
let entries;
|
|
49392
49682
|
try {
|
|
49393
|
-
entries =
|
|
49683
|
+
entries = readdirSync27(roamDir);
|
|
49394
49684
|
} catch {
|
|
49395
49685
|
return void 0;
|
|
49396
49686
|
}
|
|
49397
49687
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
49398
|
-
const path109 =
|
|
49688
|
+
const path109 = join110(roamDir, name);
|
|
49399
49689
|
try {
|
|
49400
49690
|
return { path: path109, mtimeMs: statSync14(path109).mtimeMs };
|
|
49401
49691
|
} catch {
|
|
@@ -49412,11 +49702,11 @@ var PID_BY_APP = {
|
|
|
49412
49702
|
function postRoamActivity(app, event) {
|
|
49413
49703
|
const appData = process.env.APPDATA;
|
|
49414
49704
|
if (!appData) return;
|
|
49415
|
-
const portFile = findPortFile(
|
|
49705
|
+
const portFile = findPortFile(join110(appData, "Roam"));
|
|
49416
49706
|
if (!portFile) return;
|
|
49417
49707
|
let port;
|
|
49418
49708
|
try {
|
|
49419
|
-
port =
|
|
49709
|
+
port = readFileSync73(portFile, "utf8").trim();
|
|
49420
49710
|
} catch {
|
|
49421
49711
|
return;
|
|
49422
49712
|
}
|
|
@@ -49755,11 +50045,11 @@ function requireParsedArgs() {
|
|
|
49755
50045
|
}
|
|
49756
50046
|
|
|
49757
50047
|
// src/commands/run/runCommandFilePath.ts
|
|
49758
|
-
import { join as
|
|
50048
|
+
import { join as join111 } from "path";
|
|
49759
50049
|
function runCommandFilePath(name) {
|
|
49760
50050
|
const segments = name.split(":");
|
|
49761
50051
|
const file = `${segments.pop()}.md`;
|
|
49762
|
-
return
|
|
50052
|
+
return join111(".claude", "commands", ...segments, file);
|
|
49763
50053
|
}
|
|
49764
50054
|
|
|
49765
50055
|
// src/commands/run/add.ts
|
|
@@ -49887,8 +50177,8 @@ function registerRunAdd(runCommand) {
|
|
|
49887
50177
|
}
|
|
49888
50178
|
|
|
49889
50179
|
// src/commands/run/remove.ts
|
|
49890
|
-
import { existsSync as
|
|
49891
|
-
import { dirname as dirname48, join as
|
|
50180
|
+
import { existsSync as existsSync91, readdirSync as readdirSync28, rmdirSync, unlinkSync as unlinkSync20 } from "fs";
|
|
50181
|
+
import { dirname as dirname48, join as join112 } from "path";
|
|
49892
50182
|
|
|
49893
50183
|
// src/commands/run/removeRepoRunConfig.ts
|
|
49894
50184
|
function isNamed(entry, name) {
|
|
@@ -49906,17 +50196,17 @@ function removeRepoRunConfig(name, repoName, cwd = process.cwd()) {
|
|
|
49906
50196
|
|
|
49907
50197
|
// src/commands/run/remove.ts
|
|
49908
50198
|
function removeEmptyNamespaceDirs(filePath) {
|
|
49909
|
-
const root2 =
|
|
50199
|
+
const root2 = join112(".claude", "commands");
|
|
49910
50200
|
for (let dir = dirname48(filePath); dir !== root2; dir = dirname48(dir)) {
|
|
49911
|
-
if (!
|
|
50201
|
+
if (!existsSync91(dir) || readdirSync28(dir).length > 0) return;
|
|
49912
50202
|
rmdirSync(dir);
|
|
49913
50203
|
}
|
|
49914
50204
|
}
|
|
49915
50205
|
function deleteCommandFile(name) {
|
|
49916
50206
|
const filePath = runCommandFilePath(name);
|
|
49917
|
-
const legacyPath =
|
|
50207
|
+
const legacyPath = join112(".claude", "commands", `${name}.md`);
|
|
49918
50208
|
for (const path109 of /* @__PURE__ */ new Set([filePath, legacyPath])) {
|
|
49919
|
-
if (
|
|
50209
|
+
if (existsSync91(path109)) {
|
|
49920
50210
|
unlinkSync20(path109);
|
|
49921
50211
|
console.log(`Deleted command file: ${path109}`);
|
|
49922
50212
|
}
|
|
@@ -50008,40 +50298,40 @@ function queryDaemon(socket) {
|
|
|
50008
50298
|
`);
|
|
50009
50299
|
return new Promise((resolve34) => {
|
|
50010
50300
|
const result = { sessions: [] };
|
|
50011
|
-
const
|
|
50301
|
+
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
50012
50302
|
const timer = setTimeout(() => resolve34(result), STATUS_TIMEOUT_MS2);
|
|
50013
50303
|
const lines = createInterface8({ input: socket });
|
|
50014
50304
|
lines.on("error", () => {
|
|
50015
50305
|
});
|
|
50016
50306
|
lines.on("line", (line) => {
|
|
50017
|
-
applyLine(result,
|
|
50018
|
-
if (
|
|
50307
|
+
applyLine(result, pending, line);
|
|
50308
|
+
if (pending.size === 0) {
|
|
50019
50309
|
clearTimeout(timer);
|
|
50020
50310
|
resolve34(result);
|
|
50021
50311
|
}
|
|
50022
50312
|
});
|
|
50023
50313
|
});
|
|
50024
50314
|
}
|
|
50025
|
-
function applyLine(result,
|
|
50315
|
+
function applyLine(result, pending, line) {
|
|
50026
50316
|
try {
|
|
50027
50317
|
const data = JSON.parse(line);
|
|
50028
50318
|
if (data.type === "sessions") {
|
|
50029
50319
|
result.sessions = data.sessions ?? [];
|
|
50030
|
-
|
|
50320
|
+
pending.delete("sessions");
|
|
50031
50321
|
} else if (data.type === "pong") {
|
|
50032
50322
|
result.pid = data.pid;
|
|
50033
|
-
|
|
50323
|
+
pending.delete("pong");
|
|
50034
50324
|
}
|
|
50035
50325
|
} catch {
|
|
50036
50326
|
}
|
|
50037
50327
|
}
|
|
50038
50328
|
|
|
50039
50329
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
50040
|
-
import { readFileSync as
|
|
50330
|
+
import { readFileSync as readFileSync74 } from "fs";
|
|
50041
50331
|
function readDaemonPidFile() {
|
|
50042
50332
|
try {
|
|
50043
50333
|
const pid = Number.parseInt(
|
|
50044
|
-
|
|
50334
|
+
readFileSync74(daemonPaths.pid, "utf8").trim(),
|
|
50045
50335
|
10
|
|
50046
50336
|
);
|
|
50047
50337
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -50241,17 +50531,17 @@ async function failInterruptedJobRuns(startedBefore = /* @__PURE__ */ new Date()
|
|
|
50241
50531
|
// src/commands/sessions/daemon/inbox/createActivityThrottle.ts
|
|
50242
50532
|
var ACTIVITY_THROTTLE_MS = 1e3;
|
|
50243
50533
|
function createActivityThrottle(onActivity) {
|
|
50244
|
-
let
|
|
50534
|
+
let pending;
|
|
50245
50535
|
return {
|
|
50246
50536
|
schedule() {
|
|
50247
|
-
|
|
50248
|
-
|
|
50537
|
+
pending ??= setTimeout(() => {
|
|
50538
|
+
pending = void 0;
|
|
50249
50539
|
onActivity();
|
|
50250
50540
|
}, ACTIVITY_THROTTLE_MS);
|
|
50251
50541
|
},
|
|
50252
50542
|
cancel() {
|
|
50253
|
-
clearTimeout(
|
|
50254
|
-
|
|
50543
|
+
clearTimeout(pending);
|
|
50544
|
+
pending = void 0;
|
|
50255
50545
|
}
|
|
50256
50546
|
};
|
|
50257
50547
|
}
|
|
@@ -50648,12 +50938,12 @@ function toSessionViewInfo({
|
|
|
50648
50938
|
}
|
|
50649
50939
|
|
|
50650
50940
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
50651
|
-
import { existsSync as
|
|
50941
|
+
import { existsSync as existsSync92 } from "fs";
|
|
50652
50942
|
function joinRefusal(session) {
|
|
50653
50943
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
50654
50944
|
if (session.closing === true) return "the session is closing";
|
|
50655
50945
|
if (!session.cwd) return "the session has no working directory";
|
|
50656
|
-
if (!
|
|
50946
|
+
if (!existsSync92(session.cwd))
|
|
50657
50947
|
return "the session's workspace no longer exists";
|
|
50658
50948
|
return void 0;
|
|
50659
50949
|
}
|
|
@@ -50740,8 +51030,8 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
|
50740
51030
|
}
|
|
50741
51031
|
|
|
50742
51032
|
// src/commands/sessions/daemon/findServerParents.ts
|
|
50743
|
-
import { existsSync as
|
|
50744
|
-
import { join as
|
|
51033
|
+
import { existsSync as existsSync93 } from "fs";
|
|
51034
|
+
import { join as join113, resolve as resolve32 } from "path";
|
|
50745
51035
|
function isLive(session) {
|
|
50746
51036
|
return !!session.pty && session.status !== "done" && session.status !== "error";
|
|
50747
51037
|
}
|
|
@@ -50750,7 +51040,7 @@ function isLiveAgent(session) {
|
|
|
50750
51040
|
}
|
|
50751
51041
|
function serverRunDirs(sessions, file) {
|
|
50752
51042
|
return new Set(
|
|
50753
|
-
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve32(s.cwd)).filter((dir) =>
|
|
51043
|
+
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve32(s.cwd)).filter((dir) => existsSync93(join113(dir, file)))
|
|
50754
51044
|
);
|
|
50755
51045
|
}
|
|
50756
51046
|
function findServerParents(sessions, file) {
|
|
@@ -50904,7 +51194,7 @@ function sendResizeSnapshot(s, send2) {
|
|
|
50904
51194
|
}
|
|
50905
51195
|
|
|
50906
51196
|
// src/commands/sessions/daemon/viewerSize.ts
|
|
50907
|
-
import { readFileSync as
|
|
51197
|
+
import { readFileSync as readFileSync75, writeFileSync as writeFileSync59 } from "fs";
|
|
50908
51198
|
var DEFAULT_SIZE = { cols: 120, rows: 30 };
|
|
50909
51199
|
var remembered;
|
|
50910
51200
|
function rememberViewerSize(cols, rows) {
|
|
@@ -50926,7 +51216,7 @@ function viewerSize() {
|
|
|
50926
51216
|
function readSavedSize() {
|
|
50927
51217
|
try {
|
|
50928
51218
|
const { cols, rows } = JSON.parse(
|
|
50929
|
-
|
|
51219
|
+
readFileSync75(daemonPaths.viewerSize, "utf8")
|
|
50930
51220
|
);
|
|
50931
51221
|
if (typeof cols === "number" && typeof rows === "number" && cols > 0)
|
|
50932
51222
|
return { cols, rows };
|
|
@@ -51148,10 +51438,10 @@ function clearPendingSubmit(session) {
|
|
|
51148
51438
|
function watchSubmitOutcome(session, onStatusChange) {
|
|
51149
51439
|
clearPendingSubmit(session);
|
|
51150
51440
|
const fingerprint = session.transcriptFingerprint;
|
|
51151
|
-
const
|
|
51441
|
+
const pending = { fingerprint, cancel: () => {
|
|
51152
51442
|
} };
|
|
51153
51443
|
const check2 = async () => {
|
|
51154
|
-
if (session.pendingSubmit !==
|
|
51444
|
+
if (session.pendingSubmit !== pending) return;
|
|
51155
51445
|
session.pendingSubmit = void 0;
|
|
51156
51446
|
if (session.status !== "running") return;
|
|
51157
51447
|
if (await turnStarted(session, fingerprint)) return;
|
|
@@ -51163,8 +51453,8 @@ function watchSubmitOutcome(session, onStatusChange) {
|
|
|
51163
51453
|
};
|
|
51164
51454
|
const timer = setTimeout(() => void check2(), SUBMIT_GRACE_MS);
|
|
51165
51455
|
timer.unref?.();
|
|
51166
|
-
|
|
51167
|
-
session.pendingSubmit =
|
|
51456
|
+
pending.cancel = () => clearTimeout(timer);
|
|
51457
|
+
session.pendingSubmit = pending;
|
|
51168
51458
|
}
|
|
51169
51459
|
|
|
51170
51460
|
// src/commands/sessions/daemon/watchPromptSubmit.ts
|
|
@@ -51343,6 +51633,7 @@ var ClientHub = class extends Set {
|
|
|
51343
51633
|
// why: log delivery is opt-in so browser tabs aren't spammed; only connections that ask via subscribe-logs receive daemonLog lines.
|
|
51344
51634
|
logSubscribers = /* @__PURE__ */ new Set();
|
|
51345
51635
|
peers = /* @__PURE__ */ new Map();
|
|
51636
|
+
webServers = /* @__PURE__ */ new Set();
|
|
51346
51637
|
updateLimits(rateLimits) {
|
|
51347
51638
|
this.latestLimits = rateLimits;
|
|
51348
51639
|
broadcast(this, { type: "limits", rateLimits });
|
|
@@ -51383,7 +51674,8 @@ var ClientHub = class extends Set {
|
|
|
51383
51674
|
viewers() {
|
|
51384
51675
|
return new Set([...this].filter((client) => !this.peers.has(client)));
|
|
51385
51676
|
}
|
|
51386
|
-
subscribeLogs(client, replay = true) {
|
|
51677
|
+
subscribeLogs(client, replay = true, webServer = false) {
|
|
51678
|
+
if (webServer) this.webServers.add(client);
|
|
51387
51679
|
if (replay) {
|
|
51388
51680
|
for (const line of recentDaemonLogLines(!this.isPeer(client))) {
|
|
51389
51681
|
sendTo(client, { type: "log", line });
|
|
@@ -51393,8 +51685,13 @@ var ClientHub = class extends Set {
|
|
|
51393
51685
|
}
|
|
51394
51686
|
unsubscribeLogs(client) {
|
|
51395
51687
|
this.logSubscribers.delete(client);
|
|
51688
|
+
this.webServers.delete(client);
|
|
51396
51689
|
this.peers.delete(client);
|
|
51397
51690
|
}
|
|
51691
|
+
restartWebServers() {
|
|
51692
|
+
broadcast(this.webServers, { type: "restart-webserver" });
|
|
51693
|
+
return this.webServers.size;
|
|
51694
|
+
}
|
|
51398
51695
|
// why: bound so it can be handed to setDaemonLogSink as a bare reference.
|
|
51399
51696
|
emitLog = (line, relayed = false) => {
|
|
51400
51697
|
for (const client of this.logSubscribers) {
|
|
@@ -51405,7 +51702,7 @@ var ClientHub = class extends Set {
|
|
|
51405
51702
|
};
|
|
51406
51703
|
|
|
51407
51704
|
// src/commands/sessions/daemon/createSession.ts
|
|
51408
|
-
import { randomUUID as
|
|
51705
|
+
import { randomUUID as randomUUID28 } from "crypto";
|
|
51409
51706
|
|
|
51410
51707
|
// src/commands/sessions/daemon/sessionBase.ts
|
|
51411
51708
|
function sessionBase(id, status2) {
|
|
@@ -51424,11 +51721,11 @@ function sessionBase(id, status2) {
|
|
|
51424
51721
|
}
|
|
51425
51722
|
|
|
51426
51723
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
51427
|
-
import { existsSync as
|
|
51724
|
+
import { existsSync as existsSync95 } from "fs";
|
|
51428
51725
|
import * as pty from "node-pty";
|
|
51429
51726
|
|
|
51430
51727
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
51431
|
-
import { chmodSync, existsSync as
|
|
51728
|
+
import { chmodSync, existsSync as existsSync94, statSync as statSync15 } from "fs";
|
|
51432
51729
|
import { createRequire as createRequire3 } from "module";
|
|
51433
51730
|
import path106 from "path";
|
|
51434
51731
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -51443,7 +51740,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
51443
51740
|
`${process.platform}-${process.arch}`,
|
|
51444
51741
|
"spawn-helper"
|
|
51445
51742
|
);
|
|
51446
|
-
if (!
|
|
51743
|
+
if (!existsSync94(helper)) return;
|
|
51447
51744
|
const mode = statSync15(helper).mode;
|
|
51448
51745
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
51449
51746
|
}
|
|
@@ -51500,7 +51797,7 @@ function spawnPty(args, cwd, sessionId2, extraEnv) {
|
|
|
51500
51797
|
});
|
|
51501
51798
|
}
|
|
51502
51799
|
function refuseMissingCwd(cwd, sessionId2) {
|
|
51503
|
-
if (!cwd ||
|
|
51800
|
+
if (!cwd || existsSync95(cwd)) return;
|
|
51504
51801
|
daemonLog(
|
|
51505
51802
|
`${sessionId2 ? `session ${sessionId2}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
51506
51803
|
);
|
|
@@ -51634,7 +51931,7 @@ function spawnRun(opts) {
|
|
|
51634
51931
|
function createSession(id, { prompt, cwd, design, auto, harness, holdPty } = {}) {
|
|
51635
51932
|
if (harness && harness !== "claude")
|
|
51636
51933
|
return createHarnessSession(id, harness, prompt, cwd, holdPty);
|
|
51637
|
-
const claudeSessionId =
|
|
51934
|
+
const claudeSessionId = randomUUID28();
|
|
51638
51935
|
return {
|
|
51639
51936
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
51640
51937
|
name: `Session ${id}`,
|
|
@@ -51675,7 +51972,7 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
|
51675
51972
|
}
|
|
51676
51973
|
|
|
51677
51974
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
|
|
51678
|
-
import { existsSync as
|
|
51975
|
+
import { existsSync as existsSync96, rmSync as rmSync15, writeFileSync as writeFileSync60 } from "fs";
|
|
51679
51976
|
var paused;
|
|
51680
51977
|
var wake;
|
|
51681
51978
|
var holdReleased = false;
|
|
@@ -51688,7 +51985,7 @@ function persist2(value) {
|
|
|
51688
51985
|
}
|
|
51689
51986
|
var autoUpdateControl = {
|
|
51690
51987
|
paused: () => {
|
|
51691
|
-
paused ??=
|
|
51988
|
+
paused ??= existsSync96(daemonPaths.autoUpdatePaused);
|
|
51692
51989
|
return paused;
|
|
51693
51990
|
},
|
|
51694
51991
|
setPaused: (value) => {
|
|
@@ -51828,14 +52125,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
51828
52125
|
}
|
|
51829
52126
|
|
|
51830
52127
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
51831
|
-
import { readFileSync as
|
|
52128
|
+
import { readFileSync as readFileSync76, writeFileSync as writeFileSync61 } from "fs";
|
|
51832
52129
|
var KEEP_TAIL = 256 * 1024;
|
|
51833
52130
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
51834
52131
|
function trimWatcherLog(cwd) {
|
|
51835
52132
|
const path109 = watcherLogPath(cwd);
|
|
51836
52133
|
let log2;
|
|
51837
52134
|
try {
|
|
51838
|
-
log2 =
|
|
52135
|
+
log2 = readFileSync76(path109, "utf8");
|
|
51839
52136
|
} catch {
|
|
51840
52137
|
return;
|
|
51841
52138
|
}
|
|
@@ -51923,13 +52220,13 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
51923
52220
|
}
|
|
51924
52221
|
|
|
51925
52222
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
51926
|
-
import { existsSync as
|
|
52223
|
+
import { existsSync as existsSync98 } from "fs";
|
|
51927
52224
|
|
|
51928
52225
|
// src/commands/sessions/daemon/worktree/holdsNoCheckout.ts
|
|
51929
|
-
import { existsSync as
|
|
51930
|
-
import { join as
|
|
52226
|
+
import { existsSync as existsSync97 } from "fs";
|
|
52227
|
+
import { join as join115 } from "path";
|
|
51931
52228
|
function holdsNoCheckout(path109) {
|
|
51932
|
-
return
|
|
52229
|
+
return existsSync97(path109) && !existsSync97(join115(path109, ".git"));
|
|
51933
52230
|
}
|
|
51934
52231
|
|
|
51935
52232
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
@@ -51967,14 +52264,14 @@ function notACheckout(cwd, error) {
|
|
|
51967
52264
|
return holdsNoCheckout(cwd) && /not a git repository/i.test(error);
|
|
51968
52265
|
}
|
|
51969
52266
|
async function checkDurability(cwd) {
|
|
51970
|
-
if (!
|
|
52267
|
+
if (!existsSync98(cwd)) return treeIsGone;
|
|
51971
52268
|
const probes = durabilityProbes(cwd);
|
|
51972
52269
|
let step3 = probes.next();
|
|
51973
52270
|
while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
|
|
51974
52271
|
return step3.value;
|
|
51975
52272
|
}
|
|
51976
52273
|
function checkDurabilitySync(cwd) {
|
|
51977
|
-
if (!
|
|
52274
|
+
if (!existsSync98(cwd)) return treeIsGone;
|
|
51978
52275
|
const probes = durabilityProbes(cwd);
|
|
51979
52276
|
let step3 = probes.next();
|
|
51980
52277
|
while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
|
|
@@ -52097,10 +52394,10 @@ function escalateDivergence(ctx, cwd, output) {
|
|
|
52097
52394
|
|
|
52098
52395
|
// src/commands/sessions/daemon/autoUpdate/lineRecorder.ts
|
|
52099
52396
|
function lineRecorder(onLine) {
|
|
52100
|
-
let
|
|
52397
|
+
let pending = "";
|
|
52101
52398
|
return (text20) => {
|
|
52102
|
-
const lines = (
|
|
52103
|
-
|
|
52399
|
+
const lines = (pending + text20).split(/\r?\n|\r/);
|
|
52400
|
+
pending = lines.pop() ?? "";
|
|
52104
52401
|
for (const line of lines) {
|
|
52105
52402
|
const clean2 = stripAnsi(line).trimEnd();
|
|
52106
52403
|
if (clean2.trim()) onLine(clean2);
|
|
@@ -52258,17 +52555,17 @@ function setStatus2(session, newStatus) {
|
|
|
52258
52555
|
}
|
|
52259
52556
|
|
|
52260
52557
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
52261
|
-
import { existsSync as
|
|
52262
|
-
import { basename as
|
|
52558
|
+
import { existsSync as existsSync100 } from "fs";
|
|
52559
|
+
import { basename as basename33 } from "path";
|
|
52263
52560
|
|
|
52264
52561
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
52265
|
-
import { existsSync as
|
|
52266
|
-
import { join as
|
|
52562
|
+
import { existsSync as existsSync99 } from "fs";
|
|
52563
|
+
import { join as join117 } from "path";
|
|
52267
52564
|
|
|
52268
52565
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
52269
52566
|
import { statSync as statSync16 } from "fs";
|
|
52270
52567
|
import { rm as rm3 } from "fs/promises";
|
|
52271
|
-
import { join as
|
|
52568
|
+
import { join as join116 } from "path";
|
|
52272
52569
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
52273
52570
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
52274
52571
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -52297,7 +52594,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
52297
52594
|
return { removed: true };
|
|
52298
52595
|
}
|
|
52299
52596
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
52300
|
-
return statSync16(
|
|
52597
|
+
return statSync16(join116(worktreePath, ".git"), {
|
|
52301
52598
|
throwIfNoEntry: false
|
|
52302
52599
|
})?.isDirectory() === true;
|
|
52303
52600
|
}
|
|
@@ -52338,7 +52635,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
52338
52635
|
);
|
|
52339
52636
|
}
|
|
52340
52637
|
function strandedReason(worktreePath, cause) {
|
|
52341
|
-
if (!
|
|
52638
|
+
if (!existsSync99(join117(worktreePath, ".git")))
|
|
52342
52639
|
return "its .git link is already gone";
|
|
52343
52640
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
52344
52641
|
return "git no longer recognises it as a working tree";
|
|
@@ -52390,7 +52687,7 @@ function reason3(error) {
|
|
|
52390
52687
|
|
|
52391
52688
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
52392
52689
|
async function reapWorktree(worktreePath, force = false) {
|
|
52393
|
-
if (!
|
|
52690
|
+
if (!existsSync100(worktreePath)) {
|
|
52394
52691
|
forgetWorktree(worktreePath);
|
|
52395
52692
|
daemonLog(
|
|
52396
52693
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -52408,14 +52705,14 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
52408
52705
|
const clone = owningClone(worktreePath);
|
|
52409
52706
|
const removal = await removeTree(clone, worktreePath, force);
|
|
52410
52707
|
if (!removal.removed) return removal;
|
|
52411
|
-
await deleteWorktreeBranch(clone,
|
|
52708
|
+
await deleteWorktreeBranch(clone, basename33(worktreePath));
|
|
52412
52709
|
forgetWorktree(worktreePath);
|
|
52413
52710
|
daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
|
|
52414
52711
|
return removal;
|
|
52415
52712
|
}
|
|
52416
52713
|
function owningClone(worktreePath) {
|
|
52417
52714
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
52418
|
-
if (recorded &&
|
|
52715
|
+
if (recorded && existsSync100(recorded)) return recorded;
|
|
52419
52716
|
const detected = mainWorktree(worktreePath);
|
|
52420
52717
|
if (detected) return detected;
|
|
52421
52718
|
daemonLog(
|
|
@@ -52504,10 +52801,10 @@ function killPtyTree(pty2) {
|
|
|
52504
52801
|
|
|
52505
52802
|
// src/commands/sessions/daemon/reportUndeliveredPrompts.ts
|
|
52506
52803
|
function reportUndeliveredPrompts(session, why) {
|
|
52507
|
-
const
|
|
52508
|
-
if (!
|
|
52804
|
+
const pending = session.pendingPrompts;
|
|
52805
|
+
if (!pending?.length) return;
|
|
52509
52806
|
session.pendingPrompts = void 0;
|
|
52510
|
-
for (const text20 of
|
|
52807
|
+
for (const text20 of pending) {
|
|
52511
52808
|
daemonLog(
|
|
52512
52809
|
`session ${session.id} ${why}; queued prompt undelivered: ${JSON.stringify(text20)}`
|
|
52513
52810
|
);
|
|
@@ -52584,14 +52881,14 @@ function closeGateApplies(sessions, session) {
|
|
|
52584
52881
|
}
|
|
52585
52882
|
|
|
52586
52883
|
// src/commands/sessions/daemon/worktree/liveProcessesInTree.ts
|
|
52587
|
-
import { readdirSync as
|
|
52884
|
+
import { readdirSync as readdirSync29, readlinkSync } from "fs";
|
|
52588
52885
|
import { sep as sep4 } from "path";
|
|
52589
52886
|
|
|
52590
52887
|
// src/commands/sessions/daemon/worktree/readProc.ts
|
|
52591
|
-
import { readFileSync as
|
|
52888
|
+
import { readFileSync as readFileSync77 } from "fs";
|
|
52592
52889
|
function readProc(procRoot, pid, file) {
|
|
52593
52890
|
try {
|
|
52594
|
-
return
|
|
52891
|
+
return readFileSync77(`${procRoot}/${pid}/${file}`, "utf8");
|
|
52595
52892
|
} catch {
|
|
52596
52893
|
return void 0;
|
|
52597
52894
|
}
|
|
@@ -52607,7 +52904,7 @@ function isCodexAppServer(pid, procRoot = "/proc") {
|
|
|
52607
52904
|
function liveProcessesInTree(treePath, procRoot = "/proc") {
|
|
52608
52905
|
let entries;
|
|
52609
52906
|
try {
|
|
52610
|
-
entries =
|
|
52907
|
+
entries = readdirSync29(procRoot);
|
|
52611
52908
|
} catch {
|
|
52612
52909
|
return [];
|
|
52613
52910
|
}
|
|
@@ -52732,12 +53029,12 @@ async function closeBlockReason(sessionId2, tree) {
|
|
|
52732
53029
|
}
|
|
52733
53030
|
|
|
52734
53031
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
52735
|
-
import { existsSync as
|
|
53032
|
+
import { existsSync as existsSync101, watch } from "fs";
|
|
52736
53033
|
var DEBOUNCE_MS = 500;
|
|
52737
53034
|
var POLL_MS5 = 3e4;
|
|
52738
53035
|
function watchGitState(cwd, onChange) {
|
|
52739
53036
|
const common = gitCommonDir(cwd);
|
|
52740
|
-
if (!common || !
|
|
53037
|
+
if (!common || !existsSync101(common)) return void 0;
|
|
52741
53038
|
const watchers = [
|
|
52742
53039
|
watchGitDir(common, onChange),
|
|
52743
53040
|
pollGitState(cwd, onChange)
|
|
@@ -53131,18 +53428,18 @@ function previewTargetLabel(kind, itemType, prNumber, draft) {
|
|
|
53131
53428
|
|
|
53132
53429
|
// src/commands/sessions/daemon/placeShowPreview.ts
|
|
53133
53430
|
function placeShowPreview(session, show4) {
|
|
53134
|
-
const
|
|
53135
|
-
if (!
|
|
53431
|
+
const pending = session.pendingPrPreview;
|
|
53432
|
+
if (!pending || pending.kind === "show") {
|
|
53136
53433
|
session.pendingPrPreview = show4;
|
|
53137
53434
|
session.pendingShow = void 0;
|
|
53138
53435
|
return false;
|
|
53139
53436
|
}
|
|
53140
53437
|
session.pendingShow = show4;
|
|
53141
53438
|
const target = previewTargetLabel(
|
|
53142
|
-
|
|
53143
|
-
|
|
53144
|
-
|
|
53145
|
-
|
|
53439
|
+
pending.kind ?? "pr",
|
|
53440
|
+
pending.itemType ?? "story",
|
|
53441
|
+
pending.prNumber,
|
|
53442
|
+
pending.draft === true
|
|
53146
53443
|
);
|
|
53147
53444
|
daemonLog(
|
|
53148
53445
|
`pr-preview show stacked: id=${session.id} requestId=${show4.requestId} over=${target}`
|
|
@@ -53152,18 +53449,18 @@ function placeShowPreview(session, show4) {
|
|
|
53152
53449
|
|
|
53153
53450
|
// src/commands/sessions/daemon/supersedePendingPreview.ts
|
|
53154
53451
|
function supersedePendingPreview(session, waiters, newRequestId) {
|
|
53155
|
-
const
|
|
53452
|
+
const pending = session.pendingPrPreview;
|
|
53156
53453
|
const waiter = waiters.get(session.id);
|
|
53157
|
-
if (!
|
|
53454
|
+
if (!pending || pending.kind === "show" || !waiter) return void 0;
|
|
53158
53455
|
sendTo(waiter, {
|
|
53159
53456
|
type: "pr-superseded",
|
|
53160
|
-
requestId:
|
|
53457
|
+
requestId: pending.requestId,
|
|
53161
53458
|
supersededBy: newRequestId
|
|
53162
53459
|
});
|
|
53163
53460
|
daemonLog(
|
|
53164
|
-
`pr-preview superseded: id=${session.id} old=${
|
|
53461
|
+
`pr-preview superseded: id=${session.id} old=${pending.requestId} new=${newRequestId}`
|
|
53165
53462
|
);
|
|
53166
|
-
return
|
|
53463
|
+
return pending.requestId;
|
|
53167
53464
|
}
|
|
53168
53465
|
|
|
53169
53466
|
// src/commands/sessions/daemon/holdBlockingPreview.ts
|
|
@@ -53310,17 +53607,10 @@ function isBacklogItemId(text20) {
|
|
|
53310
53607
|
}
|
|
53311
53608
|
|
|
53312
53609
|
// src/commands/sessions/daemon/generateSessionTitle.ts
|
|
53313
|
-
import { execFile as execFile14 } from "child_process";
|
|
53314
|
-
import { promisify as promisify13 } from "util";
|
|
53315
|
-
var execFileAsync11 = promisify13(execFile14);
|
|
53316
53610
|
var SESSION_TITLE_MAX_LENGTH = 48;
|
|
53317
|
-
async function generateSessionTitle(prompt) {
|
|
53611
|
+
async function generateSessionTitle(prompt, harness) {
|
|
53318
53612
|
try {
|
|
53319
|
-
const
|
|
53320
|
-
"claude",
|
|
53321
|
-
["-p", "--model", "haiku", buildPrompt5(prompt)],
|
|
53322
|
-
{ encoding: "utf8", windowsHide: true, timeout: 3e4 }
|
|
53323
|
-
);
|
|
53613
|
+
const stdout = await runOneShotPrompt(buildPrompt5(prompt), { harness });
|
|
53324
53614
|
return normaliseTitle(stdout);
|
|
53325
53615
|
} catch {
|
|
53326
53616
|
return void 0;
|
|
@@ -53377,7 +53667,8 @@ function rememberSessionTitle(session) {
|
|
|
53377
53667
|
function runSessionTitleGeneration(session, prompt, notify2, fallback) {
|
|
53378
53668
|
if (session.generatedTitle || session.titleGenerationStarted) return;
|
|
53379
53669
|
session.titleGenerationStarted = true;
|
|
53380
|
-
|
|
53670
|
+
const generation = session.harness ? generateSessionTitle(prompt, session.harness) : generateSessionTitle(prompt);
|
|
53671
|
+
void generation.then((generated) => {
|
|
53381
53672
|
const title = generated ?? fallback;
|
|
53382
53673
|
if (!title) {
|
|
53383
53674
|
daemonLog(
|
|
@@ -53471,10 +53762,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
53471
53762
|
}
|
|
53472
53763
|
|
|
53473
53764
|
// src/commands/sessions/daemon/exitReason.ts
|
|
53474
|
-
import { existsSync as
|
|
53765
|
+
import { existsSync as existsSync102 } from "fs";
|
|
53475
53766
|
import { resolve as resolve33 } from "path";
|
|
53476
53767
|
function exitDetail(session) {
|
|
53477
|
-
if (session.cwd && !
|
|
53768
|
+
if (session.cwd && !existsSync102(session.cwd))
|
|
53478
53769
|
return `working directory ${session.cwd} no longer exists`;
|
|
53479
53770
|
return missingRunConfigCwd(session);
|
|
53480
53771
|
}
|
|
@@ -53488,7 +53779,7 @@ function missingRunConfigCwd(session) {
|
|
|
53488
53779
|
const config = resolveRunConfig(session.runName, dir);
|
|
53489
53780
|
if (!config?.cwd) return void 0;
|
|
53490
53781
|
const configured = resolve33(runConfigBaseDirFrom(dir), config.cwd);
|
|
53491
|
-
if (
|
|
53782
|
+
if (existsSync102(configured)) return void 0;
|
|
53492
53783
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
53493
53784
|
}
|
|
53494
53785
|
|
|
@@ -53536,7 +53827,7 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
|
53536
53827
|
}
|
|
53537
53828
|
|
|
53538
53829
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
53539
|
-
import { existsSync as
|
|
53830
|
+
import { existsSync as existsSync103, mkdirSync as mkdirSync42, watch as watch2 } from "fs";
|
|
53540
53831
|
import { dirname as dirname51 } from "path";
|
|
53541
53832
|
|
|
53542
53833
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -53621,7 +53912,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
53621
53912
|
if (timer) clearTimeout(timer);
|
|
53622
53913
|
timer = setTimeout(read4, DEBOUNCE_MS2);
|
|
53623
53914
|
});
|
|
53624
|
-
if (
|
|
53915
|
+
if (existsSync103(path109)) read4();
|
|
53625
53916
|
}
|
|
53626
53917
|
function refreshActivity(session) {
|
|
53627
53918
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -54647,7 +54938,7 @@ function transferRefusal(s, target, links2) {
|
|
|
54647
54938
|
}
|
|
54648
54939
|
|
|
54649
54940
|
// src/commands/sessions/daemon/transfer/pushTransferSnapshot.ts
|
|
54650
|
-
import { basename as
|
|
54941
|
+
import { basename as basename34 } from "path";
|
|
54651
54942
|
|
|
54652
54943
|
// src/commands/sessions/daemon/transfer/TransferSnapshot.ts
|
|
54653
54944
|
function transferRefFor(itemId2) {
|
|
@@ -54683,7 +54974,7 @@ var WIP_COMMIT = [
|
|
|
54683
54974
|
];
|
|
54684
54975
|
async function currentBranch6(path109, treeRoot) {
|
|
54685
54976
|
const branch2 = await gitOrNull(path109, ["symbolic-ref", "--short", "HEAD"]);
|
|
54686
|
-
if (!branch2 || treeRoot && branch2 ===
|
|
54977
|
+
if (!branch2 || treeRoot && branch2 === basename34(treeRoot)) return void 0;
|
|
54687
54978
|
return branch2;
|
|
54688
54979
|
}
|
|
54689
54980
|
async function upstreamBranch2(path109) {
|
|
@@ -54975,7 +55266,7 @@ function codexRespawnPlan(session) {
|
|
|
54975
55266
|
}
|
|
54976
55267
|
|
|
54977
55268
|
// src/commands/sessions/daemon/interactiveRespawnPlan.ts
|
|
54978
|
-
import { randomUUID as
|
|
55269
|
+
import { randomUUID as randomUUID29 } from "crypto";
|
|
54979
55270
|
|
|
54980
55271
|
// src/commands/sessions/daemon/hasTranscriptOnDisk.ts
|
|
54981
55272
|
function hasTranscriptOnDisk(session) {
|
|
@@ -55002,7 +55293,7 @@ function interactiveRespawnPlan(session, resumes) {
|
|
|
55002
55293
|
return null;
|
|
55003
55294
|
}
|
|
55004
55295
|
function freshClaudePlan(session, prompt, cwd) {
|
|
55005
|
-
const claudeSessionId =
|
|
55296
|
+
const claudeSessionId = randomUUID29();
|
|
55006
55297
|
return {
|
|
55007
55298
|
spawn: () => {
|
|
55008
55299
|
session.claudeSessionId = claudeSessionId;
|
|
@@ -55311,10 +55602,10 @@ function deferralNotice(persisted, cap3) {
|
|
|
55311
55602
|
|
|
55312
55603
|
// src/commands/sessions/daemon/worktree/underTempRoot.ts
|
|
55313
55604
|
import { realpathSync as realpathSync3 } from "fs";
|
|
55314
|
-
import { tmpdir as
|
|
55605
|
+
import { tmpdir as tmpdir9 } from "os";
|
|
55315
55606
|
import { sep as sep5 } from "path";
|
|
55316
55607
|
function tempRoots() {
|
|
55317
|
-
const raw =
|
|
55608
|
+
const raw = tmpdir9();
|
|
55318
55609
|
const roots = /* @__PURE__ */ new Set([raw]);
|
|
55319
55610
|
try {
|
|
55320
55611
|
roots.add(realpathSync3(raw));
|
|
@@ -55911,8 +56202,8 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
55911
56202
|
}
|
|
55912
56203
|
|
|
55913
56204
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
55914
|
-
import { existsSync as
|
|
55915
|
-
import { basename as
|
|
56205
|
+
import { existsSync as existsSync105 } from "fs";
|
|
56206
|
+
import { basename as basename36 } from "path";
|
|
55916
56207
|
|
|
55917
56208
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
55918
56209
|
function accountedTrees(sessions) {
|
|
@@ -55932,9 +56223,9 @@ function accountedTrees(sessions) {
|
|
|
55932
56223
|
}
|
|
55933
56224
|
|
|
55934
56225
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
55935
|
-
import { existsSync as
|
|
56226
|
+
import { existsSync as existsSync104 } from "fs";
|
|
55936
56227
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
55937
|
-
if (!
|
|
56228
|
+
if (!existsSync104(clone)) {
|
|
55938
56229
|
for (const { path: path109 } of paths) forgetWorktree(path109);
|
|
55939
56230
|
daemonLog(
|
|
55940
56231
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -56020,7 +56311,7 @@ function capped2(lines) {
|
|
|
56020
56311
|
}
|
|
56021
56312
|
|
|
56022
56313
|
// src/commands/sessions/daemon/worktree/resurfaceOrphanedWorktree.ts
|
|
56023
|
-
import { basename as
|
|
56314
|
+
import { basename as basename35 } from "path";
|
|
56024
56315
|
function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
|
|
56025
56316
|
const { orphan, reason: reason4, held } = recovered;
|
|
56026
56317
|
let id;
|
|
@@ -56043,7 +56334,7 @@ function orphanedSession(id, recovered) {
|
|
|
56043
56334
|
const { orphan, reason: reason4, held } = recovered;
|
|
56044
56335
|
return {
|
|
56045
56336
|
...sessionBase(id, "stopped"),
|
|
56046
|
-
name: `recovered ${
|
|
56337
|
+
name: `recovered ${basename35(orphan.path)}`,
|
|
56047
56338
|
subtitle: `${held.summary} in ${orphan.path}`,
|
|
56048
56339
|
commandType: "claude",
|
|
56049
56340
|
pty: null,
|
|
@@ -56100,11 +56391,11 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
56100
56391
|
);
|
|
56101
56392
|
continue;
|
|
56102
56393
|
}
|
|
56103
|
-
if (!
|
|
56394
|
+
if (!existsSync105(path109)) {
|
|
56104
56395
|
logVanishedTree(sessions, path109);
|
|
56105
56396
|
vanished.set(clone, [
|
|
56106
56397
|
...vanished.get(clone) ?? [],
|
|
56107
|
-
{ path: path109, branch:
|
|
56398
|
+
{ path: path109, branch: basename36(path109) }
|
|
56108
56399
|
]);
|
|
56109
56400
|
continue;
|
|
56110
56401
|
}
|
|
@@ -56525,6 +56816,7 @@ function createRelayState(node, { viewers, onSessionsChanged, onHistoryChanged }
|
|
|
56525
56816
|
scrollback: /* @__PURE__ */ new Map(),
|
|
56526
56817
|
pendingCreators: [],
|
|
56527
56818
|
historyWaiters: [],
|
|
56819
|
+
pendingReplies: /* @__PURE__ */ new Map(),
|
|
56528
56820
|
unrecognisedTypes: /* @__PURE__ */ new Set(),
|
|
56529
56821
|
viewers,
|
|
56530
56822
|
onSessionsChanged,
|
|
@@ -56601,6 +56893,17 @@ function unavailableReason(ctx) {
|
|
|
56601
56893
|
return `${ctx.spec.name} is ${ctx.state}${detail}`;
|
|
56602
56894
|
}
|
|
56603
56895
|
|
|
56896
|
+
// src/commands/sessions/daemon/links/awaitLinkReply.ts
|
|
56897
|
+
var REPLY_TIMEOUT_MS = 3e4;
|
|
56898
|
+
function awaitLinkReply(state, requestId, client) {
|
|
56899
|
+
if (typeof requestId !== "string") return;
|
|
56900
|
+
state.pendingReplies.set(requestId, client);
|
|
56901
|
+
setTimeout(
|
|
56902
|
+
() => state.pendingReplies.delete(requestId),
|
|
56903
|
+
REPLY_TIMEOUT_MS
|
|
56904
|
+
).unref?.();
|
|
56905
|
+
}
|
|
56906
|
+
|
|
56604
56907
|
// src/commands/sessions/daemon/links/setLinkState.ts
|
|
56605
56908
|
function setLinkState(ctx, next3) {
|
|
56606
56909
|
if (ctx.state === next3) return;
|
|
@@ -56633,10 +56936,10 @@ function armCreateTimeout(ctx, client, data, traceId) {
|
|
|
56633
56936
|
const node = ctx.spec.name;
|
|
56634
56937
|
const timer = setTimeout(
|
|
56635
56938
|
() => {
|
|
56636
|
-
const
|
|
56637
|
-
const index3 =
|
|
56939
|
+
const pending = ctx.relay.pendingCreators;
|
|
56940
|
+
const index3 = pending.findIndex((p) => p.timer === timer);
|
|
56638
56941
|
if (index3 === -1) return;
|
|
56639
|
-
|
|
56942
|
+
pending.splice(index3, 1);
|
|
56640
56943
|
daemonLog(`link ${node} ws: ${data.type} timed out (cwd=${data.cwd})`);
|
|
56641
56944
|
sendTo(client, {
|
|
56642
56945
|
type: "error",
|
|
@@ -56670,6 +56973,7 @@ function forwardLinkCreate(ctx, client, data) {
|
|
|
56670
56973
|
// src/commands/sessions/daemon/links/forwardToLink.ts
|
|
56671
56974
|
function forwardToLink(ctx, client, data) {
|
|
56672
56975
|
ctx.relay.lastRequester = client;
|
|
56976
|
+
awaitLinkReply(ctx.relay, data.requestId, client);
|
|
56673
56977
|
if (isLinkCreate(data.type)) return forwardLinkCreate(ctx, client, data);
|
|
56674
56978
|
const node = ctx.spec.name;
|
|
56675
56979
|
const delivered = ctx.greeted && sendToLink(ctx, toPeerMessage(data));
|
|
@@ -56747,14 +57051,25 @@ function relayLinkSessions(state, msg) {
|
|
|
56747
57051
|
state.onSessionsChanged();
|
|
56748
57052
|
}
|
|
56749
57053
|
|
|
57054
|
+
// src/commands/sessions/daemon/links/relayReply.ts
|
|
57055
|
+
function relayReply(state, msg) {
|
|
57056
|
+
const id = typeof msg.requestId === "string" ? msg.requestId : void 0;
|
|
57057
|
+
const client = id ? state.pendingReplies.get(id) : state.lastRequester;
|
|
57058
|
+
if (id) state.pendingReplies.delete(id);
|
|
57059
|
+
daemonLog(
|
|
57060
|
+
`link ${state.node} ws: ${msg.type} reply${id ? ` ${id}` : ""}${client ? "" : " with no requester"}`
|
|
57061
|
+
);
|
|
57062
|
+
if (client) sendTo(client, msg);
|
|
57063
|
+
}
|
|
57064
|
+
|
|
56750
57065
|
// src/commands/sessions/daemon/links/takePendingCreator.ts
|
|
56751
57066
|
function takePendingCreator(state, traceId) {
|
|
56752
57067
|
const index3 = pendingIndex(state, traceId);
|
|
56753
57068
|
if (index3 === -1) return void 0;
|
|
56754
|
-
const [
|
|
56755
|
-
if (!
|
|
56756
|
-
clearTimeout(
|
|
56757
|
-
return
|
|
57069
|
+
const [pending] = state.pendingCreators.splice(index3, 1);
|
|
57070
|
+
if (!pending) return void 0;
|
|
57071
|
+
clearTimeout(pending.timer);
|
|
57072
|
+
return pending.client;
|
|
56758
57073
|
}
|
|
56759
57074
|
function pendingIndex(state, traceId) {
|
|
56760
57075
|
if (typeof traceId !== "string") return 0;
|
|
@@ -56826,6 +57141,8 @@ var relays = {
|
|
|
56826
57141
|
inbox: (state, msg) => broadcastToViewers(state, msg),
|
|
56827
57142
|
"run-conflict": relayRunConflict,
|
|
56828
57143
|
history: relayHistory,
|
|
57144
|
+
"auto-update": relayReply,
|
|
57145
|
+
"restart-webserver": relayReply,
|
|
56829
57146
|
"user-messages": (state, msg) => broadcastToViewers(state, { ...msg, sessionId: nsId(state, msg) }),
|
|
56830
57147
|
log: (state, msg) => {
|
|
56831
57148
|
if (typeof msg.line === "string") relayDaemonLog(state.node, msg.line);
|
|
@@ -57305,7 +57622,7 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
|
|
|
57305
57622
|
}
|
|
57306
57623
|
|
|
57307
57624
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
57308
|
-
import { existsSync as
|
|
57625
|
+
import { existsSync as existsSync108 } from "fs";
|
|
57309
57626
|
|
|
57310
57627
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
57311
57628
|
function resumeSession(id, sessionId2, cwd, name, holdPty, harness) {
|
|
@@ -57336,11 +57653,11 @@ function resumeSession(id, sessionId2, cwd, name, holdPty, harness) {
|
|
|
57336
57653
|
}
|
|
57337
57654
|
|
|
57338
57655
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
57339
|
-
import { existsSync as
|
|
57656
|
+
import { existsSync as existsSync107 } from "fs";
|
|
57340
57657
|
|
|
57341
57658
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
57342
|
-
import { copyFileSync as copyFileSync4, existsSync as
|
|
57343
|
-
import { join as
|
|
57659
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync106, mkdirSync as mkdirSync44 } from "fs";
|
|
57660
|
+
import { join as join118 } from "path";
|
|
57344
57661
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
57345
57662
|
const dir = projectDirForCwd(toCwd);
|
|
57346
57663
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -57349,8 +57666,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
57349
57666
|
);
|
|
57350
57667
|
return;
|
|
57351
57668
|
}
|
|
57352
|
-
const dest =
|
|
57353
|
-
if (
|
|
57669
|
+
const dest = join118(dir, `${claudeSessionId}.jsonl`);
|
|
57670
|
+
if (existsSync106(dest)) {
|
|
57354
57671
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
57355
57672
|
return;
|
|
57356
57673
|
}
|
|
@@ -57401,7 +57718,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
57401
57718
|
}
|
|
57402
57719
|
function cloneForReapedTree(missingCwd) {
|
|
57403
57720
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
57404
|
-
if (!clone || !
|
|
57721
|
+
if (!clone || !existsSync107(clone))
|
|
57405
57722
|
throw new Error(
|
|
57406
57723
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
57407
57724
|
);
|
|
@@ -57410,7 +57727,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
57410
57727
|
|
|
57411
57728
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
57412
57729
|
function resumeInTree(ctx, sessionId2, cwd, name, harness) {
|
|
57413
|
-
if (!
|
|
57730
|
+
if (!existsSync108(cwd))
|
|
57414
57731
|
return resumeInReplacementTree(ctx, sessionId2, cwd, name, harness);
|
|
57415
57732
|
const id = ctx.spawnWith(
|
|
57416
57733
|
(sid) => resumeSession(sid, sessionId2, cwd, name, void 0, harness)
|
|
@@ -57657,16 +57974,30 @@ function exitAfterFlush(code) {
|
|
|
57657
57974
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
57658
57975
|
import { createInterface as createInterface11 } from "readline";
|
|
57659
57976
|
|
|
57977
|
+
// src/commands/sessions/daemon/routed.ts
|
|
57978
|
+
function routed(local) {
|
|
57979
|
+
return (client, m, d) => {
|
|
57980
|
+
if (!m.links.route(client, d)) local(client, m, d);
|
|
57981
|
+
};
|
|
57982
|
+
}
|
|
57983
|
+
|
|
57660
57984
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateReply.ts
|
|
57661
|
-
function autoUpdateReply() {
|
|
57985
|
+
function autoUpdateReply(requestId) {
|
|
57662
57986
|
return {
|
|
57663
57987
|
type: "auto-update",
|
|
57664
57988
|
version: ASSIST_VERSION,
|
|
57989
|
+
built: readBuiltVersion(getInstallDir()),
|
|
57665
57990
|
startCommit: autoUpdateState.startCommit(),
|
|
57666
|
-
loop: { ...autoUpdateState.loop(), paused: autoUpdateControl.paused() }
|
|
57991
|
+
loop: { ...autoUpdateState.loop(), paused: autoUpdateControl.paused() },
|
|
57992
|
+
...typeof requestId === "string" ? { requestId } : {}
|
|
57667
57993
|
};
|
|
57668
57994
|
}
|
|
57669
57995
|
|
|
57996
|
+
// src/commands/sessions/daemon/autoUpdate/handleAutoUpdate.ts
|
|
57997
|
+
var handleAutoUpdate = routed(
|
|
57998
|
+
(client, _m, d) => sendTo(client, autoUpdateReply(d.requestId))
|
|
57999
|
+
);
|
|
58000
|
+
|
|
57670
58001
|
// src/commands/sessions/daemon/autoUpdate/applyAutoUpdateAction.ts
|
|
57671
58002
|
import { rmSync as rmSync17, writeFileSync as writeFileSync62 } from "fs";
|
|
57672
58003
|
function signalLap(installDir, marker2) {
|
|
@@ -58132,13 +58463,6 @@ function handleCreateRun(client, m, d) {
|
|
|
58132
58463
|
});
|
|
58133
58464
|
}
|
|
58134
58465
|
|
|
58135
|
-
// src/commands/sessions/daemon/routed.ts
|
|
58136
|
-
function routed(local) {
|
|
58137
|
-
return (client, m, d) => {
|
|
58138
|
-
if (!m.links.route(client, d)) local(client, m, d);
|
|
58139
|
-
};
|
|
58140
|
-
}
|
|
58141
|
-
|
|
58142
58466
|
// src/commands/sessions/daemon/handleDismiss.ts
|
|
58143
58467
|
var handleDismiss = routed((_client, m, d) => {
|
|
58144
58468
|
const closeServerRuns = d.closeServerRuns === true;
|
|
@@ -58209,6 +58533,18 @@ var handleReloadLinks = (client, m) => {
|
|
|
58209
58533
|
sendTo(client, { type: "ack" });
|
|
58210
58534
|
};
|
|
58211
58535
|
|
|
58536
|
+
// src/commands/sessions/daemon/handleRestartWebServer.ts
|
|
58537
|
+
var handleRestartWebServer = routed((client, m, d) => {
|
|
58538
|
+
const count10 = m.clients.restartWebServers();
|
|
58539
|
+
daemonLog(`restart-webserver: signalled ${count10} web server(s)`);
|
|
58540
|
+
sendTo(client, {
|
|
58541
|
+
type: "restart-webserver",
|
|
58542
|
+
ok: count10 > 0,
|
|
58543
|
+
error: count10 > 0 ? void 0 : "no web server is connected to the daemon",
|
|
58544
|
+
...typeof d.requestId === "string" ? { requestId: d.requestId } : {}
|
|
58545
|
+
});
|
|
58546
|
+
});
|
|
58547
|
+
|
|
58212
58548
|
// src/commands/sessions/daemon/handleSetStatus.ts
|
|
58213
58549
|
function handleSetStatus(client, m, d) {
|
|
58214
58550
|
daemonLog(
|
|
@@ -58224,6 +58560,9 @@ function handleSetStatus(client, m, d) {
|
|
|
58224
58560
|
if (d.ack) sendTo(client, { type: "ack", sessionId: d.sessionId });
|
|
58225
58561
|
}
|
|
58226
58562
|
|
|
58563
|
+
// src/commands/sessions/daemon/handleSubscribeLogs.ts
|
|
58564
|
+
var handleSubscribeLogs = (client, m, d) => m.clients.subscribeLogs(client, d.replay !== false, d.webServer === true);
|
|
58565
|
+
|
|
58227
58566
|
// src/commands/sessions/daemon/handleTypePrompt.ts
|
|
58228
58567
|
var handleTypePrompt = (client, m, d) => {
|
|
58229
58568
|
const reply2 = m.io.typePrompt(String(d.sessionId), String(d.text ?? ""));
|
|
@@ -58416,6 +58755,24 @@ var pinHandlers = {
|
|
|
58416
58755
|
"notify-pin-result": (_client, m, d) => m.links.pins.settleDelivery(d.requestId, d.delivered === true)
|
|
58417
58756
|
};
|
|
58418
58757
|
|
|
58758
|
+
// src/commands/sessions/daemon/retryHandlers.ts
|
|
58759
|
+
var retryHandlers = {
|
|
58760
|
+
retry: routed((client, m, d) => {
|
|
58761
|
+
const conflict = m.retrySession(d.sessionId, d.replace === true);
|
|
58762
|
+
if (conflict)
|
|
58763
|
+
sendTo(client, {
|
|
58764
|
+
type: "run-conflict",
|
|
58765
|
+
sessionId: d.sessionId,
|
|
58766
|
+
existing: conflict
|
|
58767
|
+
});
|
|
58768
|
+
}),
|
|
58769
|
+
restart: routed((client, m, d) => {
|
|
58770
|
+
const result = m.restart(d.sessionId);
|
|
58771
|
+
if (!result.ok && result.reason)
|
|
58772
|
+
sendTo(client, { type: "error", message: result.reason });
|
|
58773
|
+
})
|
|
58774
|
+
};
|
|
58775
|
+
|
|
58419
58776
|
// src/commands/sessions/daemon/handleSnapshotRequest.ts
|
|
58420
58777
|
var handleSnapshotRequest = (client, m, d) => {
|
|
58421
58778
|
const sessionId2 = d.sessionId;
|
|
@@ -58691,12 +59048,12 @@ function isPrCheckoutArgs(args) {
|
|
|
58691
59048
|
}
|
|
58692
59049
|
|
|
58693
59050
|
// src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
|
|
58694
|
-
import { execFile as
|
|
58695
|
-
import { existsSync as
|
|
59051
|
+
import { execFile as execFile14 } from "child_process";
|
|
59052
|
+
import { existsSync as existsSync109 } from "fs";
|
|
58696
59053
|
function prHeadBranch2(number, cwd) {
|
|
58697
59054
|
const { headBranch } = prCliCommands(number, cwd);
|
|
58698
59055
|
return new Promise((resolve34) => {
|
|
58699
|
-
|
|
59056
|
+
execFile14(
|
|
58700
59057
|
headBranch.file,
|
|
58701
59058
|
headBranch.args,
|
|
58702
59059
|
{ cwd, encoding: "utf8", windowsHide: true },
|
|
@@ -58706,12 +59063,12 @@ function prHeadBranch2(number, cwd) {
|
|
|
58706
59063
|
}
|
|
58707
59064
|
async function prCheckoutHolder(assistArgs, cwd) {
|
|
58708
59065
|
const number = prCheckoutNumber(assistArgs);
|
|
58709
|
-
if (!number || !cwd || !
|
|
59066
|
+
if (!number || !cwd || !existsSync109(cwd)) return void 0;
|
|
58710
59067
|
const headRef = await prHeadBranch2(number, cwd);
|
|
58711
59068
|
if (!headRef) return void 0;
|
|
58712
59069
|
const listing = await gitOrNull(cwd, ["worktree", "list", "--porcelain"]);
|
|
58713
59070
|
const holder = listing ? worktreeWithBranch(listing, headRef) : null;
|
|
58714
|
-
if (!holder || !
|
|
59071
|
+
if (!holder || !existsSync109(holder)) return void 0;
|
|
58715
59072
|
daemonLog(
|
|
58716
59073
|
`pr #${number} assist ${assistArgs[0]} launched in its checkout ${holder}: head branch ${headRef} is already checked out there, so no worktree is allocated`
|
|
58717
59074
|
);
|
|
@@ -58810,12 +59167,13 @@ var handleCancelTransfer = routed((_client, m, d) => {
|
|
|
58810
59167
|
// src/commands/sessions/daemon/messageHandlers.ts
|
|
58811
59168
|
var messageHandlers = {
|
|
58812
59169
|
ping: (client) => sendTo(client, { type: "pong", pid: process.pid }),
|
|
58813
|
-
"subscribe-logs":
|
|
59170
|
+
"subscribe-logs": handleSubscribeLogs,
|
|
59171
|
+
"restart-webserver": handleRestartWebServer,
|
|
58814
59172
|
"web-log": handleWebLog,
|
|
58815
59173
|
hello: handleHelloRequest,
|
|
58816
59174
|
output: handleOutputRequest,
|
|
58817
59175
|
nodes: (client, m) => m.links.sendNodes(client),
|
|
58818
|
-
"auto-update":
|
|
59176
|
+
"auto-update": handleAutoUpdate,
|
|
58819
59177
|
"auto-update-control": handleAutoUpdateControl,
|
|
58820
59178
|
"search-history": (client, _m, d) => handleSearchHistory(client, d),
|
|
58821
59179
|
...inboxHandlers,
|
|
@@ -58845,20 +59203,7 @@ var messageHandlers = {
|
|
|
58845
59203
|
...pinHandlers,
|
|
58846
59204
|
"type-prompt": handleTypePrompt,
|
|
58847
59205
|
"type-prompt-to-writer": handleTypePromptToWriter,
|
|
58848
|
-
|
|
58849
|
-
const conflict = m.retrySession(d.sessionId, d.replace === true);
|
|
58850
|
-
if (conflict)
|
|
58851
|
-
sendTo(client, {
|
|
58852
|
-
type: "run-conflict",
|
|
58853
|
-
sessionId: d.sessionId,
|
|
58854
|
-
existing: conflict
|
|
58855
|
-
});
|
|
58856
|
-
}),
|
|
58857
|
-
restart: routed((client, m, d) => {
|
|
58858
|
-
const result = m.restart(d.sessionId);
|
|
58859
|
-
if (!result.ok && result.reason)
|
|
58860
|
-
sendTo(client, { type: "error", message: result.reason });
|
|
58861
|
-
}),
|
|
59206
|
+
...retryHandlers,
|
|
58862
59207
|
dismiss: handleDismiss,
|
|
58863
59208
|
discard: routed((_client, m, d) => m.discardSession(d.sessionId)),
|
|
58864
59209
|
stop: routed((_client, m, d) => m.stopSession(d.sessionId)),
|
|
@@ -58932,7 +59277,7 @@ function handleConnection(socket, manager) {
|
|
|
58932
59277
|
import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync63 } from "fs";
|
|
58933
59278
|
|
|
58934
59279
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
58935
|
-
import { readFileSync as
|
|
59280
|
+
import { readFileSync as readFileSync78 } from "fs";
|
|
58936
59281
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
58937
59282
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
58938
59283
|
const timer = setInterval(() => {
|
|
@@ -58943,7 +59288,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
58943
59288
|
}
|
|
58944
59289
|
function ownsPidFile() {
|
|
58945
59290
|
try {
|
|
58946
|
-
return
|
|
59291
|
+
return readFileSync78(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
58947
59292
|
} catch {
|
|
58948
59293
|
return false;
|
|
58949
59294
|
}
|