@staff0rd/assist 0.927.1 → 0.928.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/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.928.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1554,15 +1554,15 @@ async function ensureTailscaleServe(port, deps2 = {}) {
|
|
|
1554
1554
|
if (!enabled()) return "skipped, sessions.tailscaleServe is false";
|
|
1555
1555
|
const current = await runningStatus(status2);
|
|
1556
1556
|
if (typeof current === "string") return current;
|
|
1557
|
-
for (let
|
|
1557
|
+
for (let attempt2 = 1; ; attempt2++) {
|
|
1558
1558
|
const plan2 = planServe(current, await serveStatus(), port, httpsPort(port));
|
|
1559
1559
|
if (plan2.alreadyServing) return `${plan2.url} already serves ${plan2.target}`;
|
|
1560
1560
|
try {
|
|
1561
1561
|
await serve(plan2.args);
|
|
1562
1562
|
return `serving ${plan2.target} at ${plan2.url}`;
|
|
1563
1563
|
} catch (error) {
|
|
1564
|
-
if (
|
|
1565
|
-
await sleep2(
|
|
1564
|
+
if (attempt2 >= SERVE_WRITE_ATTEMPTS) throw error;
|
|
1565
|
+
await sleep2(attempt2 * 500 + Math.random() * 500);
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
}
|
|
@@ -5220,7 +5220,12 @@ var prActions = [
|
|
|
5220
5220
|
];
|
|
5221
5221
|
|
|
5222
5222
|
// src/shared/azureDevops/azureDevopsPrActions.ts
|
|
5223
|
-
var SUPPORTED = /* @__PURE__ */ new Set([
|
|
5223
|
+
var SUPPORTED = /* @__PURE__ */ new Set([
|
|
5224
|
+
"Checkout",
|
|
5225
|
+
"Address Comments",
|
|
5226
|
+
"Address Comments (batch)",
|
|
5227
|
+
"Address Comments (auto)"
|
|
5228
|
+
]);
|
|
5224
5229
|
var azureDevopsPrActions = prActions.filter(
|
|
5225
5230
|
({ label: label2 }) => SUPPORTED.has(label2)
|
|
5226
5231
|
);
|
|
@@ -17072,12 +17077,12 @@ function buildPayload(sessionId, status2, source, claudeSessionId) {
|
|
|
17072
17077
|
return payload;
|
|
17073
17078
|
}
|
|
17074
17079
|
async function deliver(sessionId, status2, payload, attempts) {
|
|
17075
|
-
for (let
|
|
17080
|
+
for (let attempt2 = 1; attempt2 <= attempts; attempt2++) {
|
|
17076
17081
|
try {
|
|
17077
17082
|
await sendToDaemonAwaitAck(payload);
|
|
17078
17083
|
return;
|
|
17079
17084
|
} catch (error) {
|
|
17080
|
-
if (
|
|
17085
|
+
if (attempt2 < attempts) {
|
|
17081
17086
|
await sleep(RETRY_DELAY_MS2);
|
|
17082
17087
|
continue;
|
|
17083
17088
|
}
|
|
@@ -29993,11 +29998,265 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
29993
29998
|
);
|
|
29994
29999
|
}
|
|
29995
30000
|
|
|
29996
|
-
// src/commands/prs/
|
|
30001
|
+
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
30002
|
+
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync36 } from "fs";
|
|
30003
|
+
import { dirname as dirname36 } from "path";
|
|
30004
|
+
import { stringify as stringify3 } from "yaml";
|
|
30005
|
+
|
|
30006
|
+
// src/commands/prs/loadCommentsCache.ts
|
|
30007
|
+
import { existsSync as existsSync64, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
|
|
30008
|
+
import { parse as parse3 } from "yaml";
|
|
30009
|
+
function loadCommentsCache(org, repo, prNumber) {
|
|
30010
|
+
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30011
|
+
if (!existsSync64(cachePath)) {
|
|
30012
|
+
return null;
|
|
30013
|
+
}
|
|
30014
|
+
const content = readFileSync45(cachePath, "utf8");
|
|
30015
|
+
return parse3(content);
|
|
30016
|
+
}
|
|
30017
|
+
function deleteCommentsCache(org, repo, prNumber) {
|
|
30018
|
+
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30019
|
+
if (existsSync64(cachePath)) {
|
|
30020
|
+
unlinkSync13(cachePath);
|
|
30021
|
+
console.log("No more unresolved line comments. Cache dropped.");
|
|
30022
|
+
}
|
|
30023
|
+
}
|
|
30024
|
+
|
|
30025
|
+
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
30026
|
+
import { readdirSync as readdirSync13, unlinkSync as unlinkSync14 } from "fs";
|
|
30027
|
+
import { join as join80 } from "path";
|
|
30028
|
+
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
30029
|
+
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
30030
|
+
const dir = join80(cwd, ".assist");
|
|
30031
|
+
let entries;
|
|
30032
|
+
try {
|
|
30033
|
+
entries = readdirSync13(dir);
|
|
30034
|
+
} catch {
|
|
30035
|
+
return;
|
|
30036
|
+
}
|
|
30037
|
+
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
30038
|
+
unlinkSync14(join80(dir, entry));
|
|
30039
|
+
}
|
|
30040
|
+
}
|
|
30041
|
+
|
|
30042
|
+
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
30043
|
+
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
30044
|
+
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30045
|
+
mkdirSync22(dirname36(cachePath), { recursive: true });
|
|
30046
|
+
const cacheData = {
|
|
30047
|
+
prNumber,
|
|
30048
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30049
|
+
comments: comments3
|
|
30050
|
+
};
|
|
30051
|
+
writeFileSync36(cachePath, stringify3(cacheData));
|
|
30052
|
+
}
|
|
30053
|
+
function updateCommentsCache(org, repo, prNumber, comments3) {
|
|
30054
|
+
removeStaleCommentsCaches();
|
|
30055
|
+
if (comments3.some((c) => c.type === "line")) {
|
|
30056
|
+
writeCommentsCache(org, repo, prNumber, comments3);
|
|
30057
|
+
} else {
|
|
30058
|
+
deleteCommentsCache(org, repo, prNumber);
|
|
30059
|
+
}
|
|
30060
|
+
}
|
|
30061
|
+
|
|
30062
|
+
// src/commands/prs/azureDevops/azureDevopsCacheRepo.ts
|
|
30063
|
+
function azureDevopsCacheRepo({ org, project, repo }) {
|
|
30064
|
+
return { org, repo: `${project}/${repo}` };
|
|
30065
|
+
}
|
|
30066
|
+
|
|
30067
|
+
// src/commands/prs/azureDevops/azureDevopsRepoUrl.ts
|
|
30068
|
+
function azureDevopsRepoUrl({ org, project, repo }) {
|
|
30069
|
+
return `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_git/${encodeURIComponent(repo)}`;
|
|
30070
|
+
}
|
|
30071
|
+
|
|
30072
|
+
// src/commands/prs/azureDevops/azureDevopsThreadRequests.ts
|
|
30073
|
+
function prRoute(pr) {
|
|
30074
|
+
return {
|
|
30075
|
+
project: pr.project,
|
|
30076
|
+
repositoryId: pr.repo,
|
|
30077
|
+
pullRequestId: pr.prId
|
|
30078
|
+
};
|
|
30079
|
+
}
|
|
30080
|
+
var azureDevopsThreadRequests = {
|
|
30081
|
+
list(pr) {
|
|
30082
|
+
return {
|
|
30083
|
+
org: pr.org,
|
|
30084
|
+
resource: "pullRequestThreads",
|
|
30085
|
+
routeParameters: prRoute(pr)
|
|
30086
|
+
};
|
|
30087
|
+
},
|
|
30088
|
+
reply(pr, threadId, content) {
|
|
30089
|
+
return {
|
|
30090
|
+
org: pr.org,
|
|
30091
|
+
resource: "pullRequestThreadComments",
|
|
30092
|
+
routeParameters: { ...prRoute(pr), threadId },
|
|
30093
|
+
method: "POST",
|
|
30094
|
+
body: { content, commentType: 1 }
|
|
30095
|
+
};
|
|
30096
|
+
},
|
|
30097
|
+
status(pr, threadId, status2) {
|
|
30098
|
+
return {
|
|
30099
|
+
org: pr.org,
|
|
30100
|
+
resource: "pullRequestThreads",
|
|
30101
|
+
routeParameters: { ...prRoute(pr), threadId },
|
|
30102
|
+
method: "PATCH",
|
|
30103
|
+
body: { status: status2 }
|
|
30104
|
+
};
|
|
30105
|
+
}
|
|
30106
|
+
};
|
|
30107
|
+
|
|
30108
|
+
// src/commands/prs/azureDevops/currentAzureDevopsPr.ts
|
|
29997
30109
|
import { execFileSync as execFileSync20 } from "child_process";
|
|
30110
|
+
function findPrForBranch(repo, branch2) {
|
|
30111
|
+
const stdout = execFileSync20(
|
|
30112
|
+
"az",
|
|
30113
|
+
[
|
|
30114
|
+
"repos",
|
|
30115
|
+
"pr",
|
|
30116
|
+
"list",
|
|
30117
|
+
"--source-branch",
|
|
30118
|
+
branch2,
|
|
30119
|
+
"--status",
|
|
30120
|
+
"active",
|
|
30121
|
+
"--org",
|
|
30122
|
+
`https://dev.azure.com/${repo.org}`,
|
|
30123
|
+
"--project",
|
|
30124
|
+
repo.project,
|
|
30125
|
+
"--repository",
|
|
30126
|
+
repo.repo,
|
|
30127
|
+
"--query",
|
|
30128
|
+
"[0].pullRequestId",
|
|
30129
|
+
"--only-show-errors",
|
|
30130
|
+
"-o",
|
|
30131
|
+
"tsv"
|
|
30132
|
+
],
|
|
30133
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], windowsHide: true }
|
|
30134
|
+
);
|
|
30135
|
+
return Number.parseInt(stdout.trim(), 10);
|
|
30136
|
+
}
|
|
30137
|
+
function currentAzureDevopsPr(repo) {
|
|
30138
|
+
const prId = getPinnedPr() ?? findPrForBranch(repo, getCurrentBranch2());
|
|
30139
|
+
if (Number.isNaN(prId)) {
|
|
30140
|
+
console.error("Error: No pull request found for the current branch.");
|
|
30141
|
+
process.exit(1);
|
|
30142
|
+
}
|
|
30143
|
+
return { ...repo, prId };
|
|
30144
|
+
}
|
|
30145
|
+
|
|
30146
|
+
// src/commands/prs/azureDevops/failAzureDevops.ts
|
|
30147
|
+
function errorOutput(error) {
|
|
30148
|
+
const stderr = error.stderr?.toString();
|
|
30149
|
+
if (stderr?.trim()) return stderr.trim();
|
|
30150
|
+
return error instanceof Error ? error.message : String(error);
|
|
30151
|
+
}
|
|
30152
|
+
function failAzureDevops(error) {
|
|
30153
|
+
console.error(`Error: ${azCliProblem() ?? errorOutput(error)}`);
|
|
30154
|
+
process.exit(1);
|
|
30155
|
+
}
|
|
30156
|
+
|
|
30157
|
+
// src/commands/prs/azureDevops/invokeAzDevops.ts
|
|
30158
|
+
import { execFileSync as execFileSync21 } from "child_process";
|
|
30159
|
+
import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync37 } from "fs";
|
|
30160
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
30161
|
+
import { join as join81 } from "path";
|
|
30162
|
+
function azDevopsInvokeArgs(request, inFile) {
|
|
30163
|
+
return [
|
|
30164
|
+
"devops",
|
|
30165
|
+
"invoke",
|
|
30166
|
+
"--area",
|
|
30167
|
+
"git",
|
|
30168
|
+
"--resource",
|
|
30169
|
+
request.resource,
|
|
30170
|
+
"--route-parameters",
|
|
30171
|
+
...Object.entries(request.routeParameters).map(
|
|
30172
|
+
([key, value]) => `${key}=${value}`
|
|
30173
|
+
),
|
|
30174
|
+
"--org",
|
|
30175
|
+
`https://dev.azure.com/${request.org}`,
|
|
30176
|
+
"--api-version",
|
|
30177
|
+
"7.1",
|
|
30178
|
+
"--http-method",
|
|
30179
|
+
request.method ?? "GET",
|
|
30180
|
+
...inFile ? ["--in-file", inFile] : [],
|
|
30181
|
+
"--only-show-errors",
|
|
30182
|
+
"-o",
|
|
30183
|
+
"json"
|
|
30184
|
+
];
|
|
30185
|
+
}
|
|
30186
|
+
function runAz2(args) {
|
|
30187
|
+
const stdout = execFileSync21("az", args, {
|
|
30188
|
+
encoding: "utf8",
|
|
30189
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
30190
|
+
windowsHide: true
|
|
30191
|
+
});
|
|
30192
|
+
return stdout.trim() ? JSON.parse(stdout) : null;
|
|
30193
|
+
}
|
|
30194
|
+
function invokeAzDevops(request) {
|
|
30195
|
+
if (request.body === void 0) return runAz2(azDevopsInvokeArgs(request));
|
|
30196
|
+
const dir = mkdtempSync2(join81(tmpdir6(), "assist-az-"));
|
|
30197
|
+
const inFile = join81(dir, "body.json");
|
|
30198
|
+
try {
|
|
30199
|
+
writeFileSync37(inFile, JSON.stringify(request.body));
|
|
30200
|
+
return runAz2(azDevopsInvokeArgs(request, inFile));
|
|
30201
|
+
} finally {
|
|
30202
|
+
rmSync6(dir, { recursive: true, force: true });
|
|
30203
|
+
}
|
|
30204
|
+
}
|
|
30205
|
+
|
|
30206
|
+
// src/commands/prs/azureDevops/mapAzureDevopsThreads.ts
|
|
30207
|
+
var OPEN_STATUSES = /* @__PURE__ */ new Set(["active", "pending", "unknown"]);
|
|
30208
|
+
function isResolved(status2) {
|
|
30209
|
+
return status2 !== void 0 && !OPEN_STATUSES.has(status2);
|
|
30210
|
+
}
|
|
30211
|
+
function threadLine(thread) {
|
|
30212
|
+
const context = thread.threadContext;
|
|
30213
|
+
return context?.rightFileStart?.line ?? context?.leftFileStart?.line ?? null;
|
|
30214
|
+
}
|
|
30215
|
+
function threadPath(thread) {
|
|
30216
|
+
return thread.threadContext?.filePath?.replace(/^[/]/, "") ?? "";
|
|
30217
|
+
}
|
|
30218
|
+
function mapAzureDevopsThreads(threads, prUrl) {
|
|
30219
|
+
return threads.filter((thread) => !thread.isDeleted).flatMap(
|
|
30220
|
+
(thread) => (thread.comments ?? []).filter((c) => !c.isDeleted && c.commentType !== "system" && c.content).map(
|
|
30221
|
+
(c) => ({
|
|
30222
|
+
type: "line",
|
|
30223
|
+
id: thread.id,
|
|
30224
|
+
threadId: String(thread.id),
|
|
30225
|
+
user: c.author?.displayName ?? c.author?.uniqueName ?? "unknown",
|
|
30226
|
+
path: threadPath(thread),
|
|
30227
|
+
line: threadLine(thread),
|
|
30228
|
+
body: c.content ?? "",
|
|
30229
|
+
diff_hunk: "",
|
|
30230
|
+
html_url: `${prUrl}?discussionId=${thread.id}`,
|
|
30231
|
+
resolved: isResolved(thread.status)
|
|
30232
|
+
})
|
|
30233
|
+
)
|
|
30234
|
+
);
|
|
30235
|
+
}
|
|
30236
|
+
|
|
30237
|
+
// src/commands/prs/azureDevops/listAzureDevopsComments.ts
|
|
30238
|
+
function listAzureDevopsComments(repo) {
|
|
30239
|
+
try {
|
|
30240
|
+
const pr = currentAzureDevopsPr(repo);
|
|
30241
|
+
const response = invokeAzDevops(azureDevopsThreadRequests.list(pr));
|
|
30242
|
+
const comments3 = mapAzureDevopsThreads(
|
|
30243
|
+
response?.value ?? [],
|
|
30244
|
+
`${azureDevopsRepoUrl(pr)}/pullrequest/${pr.prId}`
|
|
30245
|
+
);
|
|
30246
|
+
const { org, repo: cacheRepo } = azureDevopsCacheRepo(pr);
|
|
30247
|
+
updateCommentsCache(org, cacheRepo, pr.prId, comments3);
|
|
30248
|
+
const cachePath = comments3.length > 0 ? commentsCachePath(org, cacheRepo, pr.prId) : null;
|
|
30249
|
+
return { comments: comments3, cachePath };
|
|
30250
|
+
} catch (error) {
|
|
30251
|
+
failAzureDevops(error);
|
|
30252
|
+
}
|
|
30253
|
+
}
|
|
30254
|
+
|
|
30255
|
+
// src/commands/prs/fetchThreadIds.ts
|
|
30256
|
+
import { execFileSync as execFileSync22 } from "child_process";
|
|
29998
30257
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
29999
30258
|
function fetchThreadIds(org, repo, prNumber) {
|
|
30000
|
-
const result =
|
|
30259
|
+
const result = execFileSync22(
|
|
30001
30260
|
"gh",
|
|
30002
30261
|
[
|
|
30003
30262
|
"api",
|
|
@@ -30071,67 +30330,6 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
30071
30330
|
);
|
|
30072
30331
|
}
|
|
30073
30332
|
|
|
30074
|
-
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
30075
|
-
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync36 } from "fs";
|
|
30076
|
-
import { dirname as dirname36 } from "path";
|
|
30077
|
-
import { stringify as stringify3 } from "yaml";
|
|
30078
|
-
|
|
30079
|
-
// src/commands/prs/loadCommentsCache.ts
|
|
30080
|
-
import { existsSync as existsSync64, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
|
|
30081
|
-
import { parse as parse3 } from "yaml";
|
|
30082
|
-
function loadCommentsCache(org, repo, prNumber) {
|
|
30083
|
-
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30084
|
-
if (!existsSync64(cachePath)) {
|
|
30085
|
-
return null;
|
|
30086
|
-
}
|
|
30087
|
-
const content = readFileSync45(cachePath, "utf8");
|
|
30088
|
-
return parse3(content);
|
|
30089
|
-
}
|
|
30090
|
-
function deleteCommentsCache(org, repo, prNumber) {
|
|
30091
|
-
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30092
|
-
if (existsSync64(cachePath)) {
|
|
30093
|
-
unlinkSync13(cachePath);
|
|
30094
|
-
console.log("No more unresolved line comments. Cache dropped.");
|
|
30095
|
-
}
|
|
30096
|
-
}
|
|
30097
|
-
|
|
30098
|
-
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
30099
|
-
import { readdirSync as readdirSync13, unlinkSync as unlinkSync14 } from "fs";
|
|
30100
|
-
import { join as join80 } from "path";
|
|
30101
|
-
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
30102
|
-
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
30103
|
-
const dir = join80(cwd, ".assist");
|
|
30104
|
-
let entries;
|
|
30105
|
-
try {
|
|
30106
|
-
entries = readdirSync13(dir);
|
|
30107
|
-
} catch {
|
|
30108
|
-
return;
|
|
30109
|
-
}
|
|
30110
|
-
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
30111
|
-
unlinkSync14(join80(dir, entry));
|
|
30112
|
-
}
|
|
30113
|
-
}
|
|
30114
|
-
|
|
30115
|
-
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
30116
|
-
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
30117
|
-
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30118
|
-
mkdirSync22(dirname36(cachePath), { recursive: true });
|
|
30119
|
-
const cacheData = {
|
|
30120
|
-
prNumber,
|
|
30121
|
-
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30122
|
-
comments: comments3
|
|
30123
|
-
};
|
|
30124
|
-
writeFileSync36(cachePath, stringify3(cacheData));
|
|
30125
|
-
}
|
|
30126
|
-
function updateCommentsCache(org, repo, prNumber, comments3) {
|
|
30127
|
-
removeStaleCommentsCaches();
|
|
30128
|
-
if (comments3.some((c) => c.type === "line")) {
|
|
30129
|
-
writeCommentsCache(org, repo, prNumber, comments3);
|
|
30130
|
-
} else {
|
|
30131
|
-
deleteCommentsCache(org, repo, prNumber);
|
|
30132
|
-
}
|
|
30133
|
-
}
|
|
30134
|
-
|
|
30135
30333
|
// src/commands/prs/isNotFound.ts
|
|
30136
30334
|
function isNotFound(error) {
|
|
30137
30335
|
if (error instanceof Error) {
|
|
@@ -30154,6 +30352,8 @@ function handleKnownErrors(error) {
|
|
|
30154
30352
|
return null;
|
|
30155
30353
|
}
|
|
30156
30354
|
async function listComments() {
|
|
30355
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30356
|
+
if (azure) return listAzureDevopsComments(azure);
|
|
30157
30357
|
try {
|
|
30158
30358
|
const prNumber = getCurrentPrNumber();
|
|
30159
30359
|
const { org, repo } = getRepoInfo();
|
|
@@ -30211,6 +30411,7 @@ function commentStyle() {
|
|
|
30211
30411
|
|
|
30212
30412
|
// src/commands/prs/listComments/groupThreads.ts
|
|
30213
30413
|
function threadLocation(comment3) {
|
|
30414
|
+
if (!comment3.path) return "the PR";
|
|
30214
30415
|
return comment3.line ? `${comment3.path}:${comment3.line}` : comment3.path;
|
|
30215
30416
|
}
|
|
30216
30417
|
function groupThreads(comments3) {
|
|
@@ -30335,8 +30536,32 @@ function printComments2(result) {
|
|
|
30335
30536
|
// src/commands/prs/fixed.ts
|
|
30336
30537
|
import { execSync as execSync41 } from "child_process";
|
|
30337
30538
|
|
|
30338
|
-
// src/commands/prs/
|
|
30339
|
-
import { execFileSync as
|
|
30539
|
+
// src/commands/prs/threadTarget.ts
|
|
30540
|
+
import { execFileSync as execFileSync23 } from "child_process";
|
|
30541
|
+
|
|
30542
|
+
// src/commands/prs/azureDevops/azureDevopsThreadActions.ts
|
|
30543
|
+
function attempt(run4) {
|
|
30544
|
+
try {
|
|
30545
|
+
return run4();
|
|
30546
|
+
} catch (error) {
|
|
30547
|
+
failAzureDevops(error);
|
|
30548
|
+
}
|
|
30549
|
+
}
|
|
30550
|
+
var azureDevopsThreadActions = {
|
|
30551
|
+
currentPr(repo) {
|
|
30552
|
+
return attempt(() => currentAzureDevopsPr(repo));
|
|
30553
|
+
},
|
|
30554
|
+
reply(pr, threadId, content) {
|
|
30555
|
+
attempt(
|
|
30556
|
+
() => invokeAzDevops(azureDevopsThreadRequests.reply(pr, threadId, content))
|
|
30557
|
+
);
|
|
30558
|
+
},
|
|
30559
|
+
setStatus(pr, threadId, status2) {
|
|
30560
|
+
attempt(
|
|
30561
|
+
() => invokeAzDevops(azureDevopsThreadRequests.status(pr, threadId, status2))
|
|
30562
|
+
);
|
|
30563
|
+
}
|
|
30564
|
+
};
|
|
30340
30565
|
|
|
30341
30566
|
// src/commands/prs/replyToComment.ts
|
|
30342
30567
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
@@ -30357,15 +30582,40 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
30357
30582
|
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
30358
30583
|
}
|
|
30359
30584
|
|
|
30360
|
-
// src/commands/prs/
|
|
30585
|
+
// src/commands/prs/threadTarget.ts
|
|
30361
30586
|
function resolveThread(threadId) {
|
|
30362
30587
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
30363
|
-
|
|
30588
|
+
execFileSync23(
|
|
30364
30589
|
"gh",
|
|
30365
30590
|
["api", "graphql", "-f", `query=${mutation}`, "-f", `threadId=${threadId}`],
|
|
30366
30591
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
30367
30592
|
);
|
|
30368
30593
|
}
|
|
30594
|
+
function githubTarget() {
|
|
30595
|
+
const prNumber = getCurrentPrNumber();
|
|
30596
|
+
const { org, repo } = getRepoInfo();
|
|
30597
|
+
return {
|
|
30598
|
+
org,
|
|
30599
|
+
repo,
|
|
30600
|
+
prNumber,
|
|
30601
|
+
reply: (comment3, message3) => replyToComment(org, repo, prNumber, comment3.id, message3),
|
|
30602
|
+
resolve: (comment3) => resolveThread(comment3.threadId)
|
|
30603
|
+
};
|
|
30604
|
+
}
|
|
30605
|
+
function threadTarget(status2) {
|
|
30606
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30607
|
+
if (!azure) return githubTarget();
|
|
30608
|
+
const pr = azureDevopsThreadActions.currentPr(azure);
|
|
30609
|
+
const threadId = (comment3) => Number(comment3.threadId);
|
|
30610
|
+
return {
|
|
30611
|
+
...azureDevopsCacheRepo(pr),
|
|
30612
|
+
prNumber: pr.prId,
|
|
30613
|
+
reply: (comment3, message3) => azureDevopsThreadActions.reply(pr, threadId(comment3), message3),
|
|
30614
|
+
resolve: (comment3) => azureDevopsThreadActions.setStatus(pr, threadId(comment3), status2)
|
|
30615
|
+
};
|
|
30616
|
+
}
|
|
30617
|
+
|
|
30618
|
+
// src/commands/prs/resolveCommentWithReply.ts
|
|
30369
30619
|
function requireCache(org, repo, prNumber) {
|
|
30370
30620
|
const cache7 = loadCommentsCache(org, repo, prNumber);
|
|
30371
30621
|
if (!cache7) {
|
|
@@ -30389,22 +30639,21 @@ function requireLineComment(cache7, commentId) {
|
|
|
30389
30639
|
}
|
|
30390
30640
|
return comment3;
|
|
30391
30641
|
}
|
|
30392
|
-
function cleanupCacheIfDone(cache7, org, repo, prNumber, commentId) {
|
|
30642
|
+
function cleanupCacheIfDone(cache7, { org, repo, prNumber }, commentId) {
|
|
30393
30643
|
const hasRemaining = cache7.comments.some(
|
|
30394
30644
|
(c) => c.type === "line" && c.id !== commentId
|
|
30395
30645
|
);
|
|
30396
30646
|
if (!hasRemaining) deleteCommentsCache(org, repo, prNumber);
|
|
30397
30647
|
}
|
|
30398
|
-
function resolveCommentWithReply(commentId, message3) {
|
|
30399
|
-
const
|
|
30400
|
-
const
|
|
30401
|
-
const cache7 = requireCache(org, repo, prNumber);
|
|
30648
|
+
function resolveCommentWithReply(commentId, message3, status2) {
|
|
30649
|
+
const target = threadTarget(status2);
|
|
30650
|
+
const cache7 = requireCache(target.org, target.repo, target.prNumber);
|
|
30402
30651
|
const comment3 = requireLineComment(cache7, commentId);
|
|
30403
|
-
|
|
30652
|
+
target.reply(comment3, message3);
|
|
30404
30653
|
console.log("Reply posted successfully.");
|
|
30405
|
-
|
|
30654
|
+
target.resolve(comment3);
|
|
30406
30655
|
console.log("Thread resolved successfully.");
|
|
30407
|
-
cleanupCacheIfDone(cache7,
|
|
30656
|
+
cleanupCacheIfDone(cache7, target, commentId);
|
|
30408
30657
|
}
|
|
30409
30658
|
|
|
30410
30659
|
// src/commands/prs/fixed.ts
|
|
@@ -30418,14 +30667,18 @@ function verifySha(sha) {
|
|
|
30418
30667
|
process.exit(1);
|
|
30419
30668
|
}
|
|
30420
30669
|
}
|
|
30670
|
+
function repoUrl() {
|
|
30671
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30672
|
+
if (azure) return azureDevopsRepoUrl(azure);
|
|
30673
|
+
const { org, repo } = getRepoInfo();
|
|
30674
|
+
return `https://github.com/${org}/${repo}`;
|
|
30675
|
+
}
|
|
30421
30676
|
function fixed(commentId, sha) {
|
|
30422
30677
|
try {
|
|
30423
30678
|
const fullSha = verifySha(sha);
|
|
30424
|
-
const
|
|
30425
|
-
const repoUrl = `https://github.com/${org}/${repo}`;
|
|
30426
|
-
const message3 = `Fixed in [${fullSha}](${repoUrl}/commit/${fullSha})`;
|
|
30679
|
+
const message3 = `Fixed in [${fullSha}](${repoUrl()}/commit/${fullSha})`;
|
|
30427
30680
|
pushCommit(loadConfig().worktree?.trunk === true);
|
|
30428
|
-
resolveCommentWithReply(commentId, message3);
|
|
30681
|
+
resolveCommentWithReply(commentId, message3, "fixed");
|
|
30429
30682
|
} catch (error) {
|
|
30430
30683
|
if (isGhNotInstalled(error)) {
|
|
30431
30684
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -30447,6 +30700,13 @@ function validateBody2(body) {
|
|
|
30447
30700
|
async function reply(commentId, body) {
|
|
30448
30701
|
validateBody2(body);
|
|
30449
30702
|
await reviewProposedPrComment(`Reply to comment #${commentId}`, body, null);
|
|
30703
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30704
|
+
if (azure) {
|
|
30705
|
+
const pr = azureDevopsThreadActions.currentPr(azure);
|
|
30706
|
+
azureDevopsThreadActions.reply(pr, commentId, body);
|
|
30707
|
+
console.log("Reply posted successfully.");
|
|
30708
|
+
return;
|
|
30709
|
+
}
|
|
30450
30710
|
try {
|
|
30451
30711
|
const prNumber = getCurrentPrNumber();
|
|
30452
30712
|
const { org, repo } = getRepoInfo();
|
|
@@ -30472,7 +30732,7 @@ function validateReason(reason4) {
|
|
|
30472
30732
|
}
|
|
30473
30733
|
}
|
|
30474
30734
|
function validateShaReferences(reason4) {
|
|
30475
|
-
const commitLinkPattern = /\[[0-9a-f]{7}\]\(https:\/\/github\.com\/[^/]+\/[^/]+\/commit\/([0-9a-f]{40})\)/gi;
|
|
30735
|
+
const commitLinkPattern = /\[[0-9a-f]{7}\]\(https:\/\/(?:github\.com\/[^/]+\/[^/]+|dev\.azure\.com\/[^/]+\/[^/]+\/_git\/[^/]+)\/commit\/([0-9a-f]{40})\)/gi;
|
|
30476
30736
|
const shas = Array.from(reason4.matchAll(commitLinkPattern), (m) => m[1]);
|
|
30477
30737
|
if (shas.length === 0) {
|
|
30478
30738
|
return;
|
|
@@ -30501,7 +30761,7 @@ async function wontfix(commentId, reason4) {
|
|
|
30501
30761
|
null
|
|
30502
30762
|
);
|
|
30503
30763
|
try {
|
|
30504
|
-
resolveCommentWithReply(commentId, reason4);
|
|
30764
|
+
resolveCommentWithReply(commentId, reason4, "wontFix");
|
|
30505
30765
|
} catch (error) {
|
|
30506
30766
|
if (isGhNotInstalled(error)) {
|
|
30507
30767
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -30965,7 +31225,7 @@ function buildValidatedBody(options2, usage) {
|
|
|
30965
31225
|
}
|
|
30966
31226
|
|
|
30967
31227
|
// src/commands/prs/placePr.ts
|
|
30968
|
-
import { execFileSync as
|
|
31228
|
+
import { execFileSync as execFileSync24 } from "child_process";
|
|
30969
31229
|
|
|
30970
31230
|
// src/commands/prs/buildCreateArgs.ts
|
|
30971
31231
|
function buildCreateArgs(title, body, options2, attachments = []) {
|
|
@@ -31051,7 +31311,7 @@ function buildEditArgs(number, title, body, attachments = []) {
|
|
|
31051
31311
|
// src/commands/prs/placePr.ts
|
|
31052
31312
|
function hasUpstream2() {
|
|
31053
31313
|
try {
|
|
31054
|
-
|
|
31314
|
+
execFileSync24(
|
|
31055
31315
|
"git",
|
|
31056
31316
|
["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
|
|
31057
31317
|
{ stdio: "pipe" }
|
|
@@ -31063,7 +31323,7 @@ function hasUpstream2() {
|
|
|
31063
31323
|
}
|
|
31064
31324
|
function ensureBranchPushed() {
|
|
31065
31325
|
const args = hasUpstream2() ? ["push"] : ["push", "--set-upstream", "origin", "HEAD"];
|
|
31066
|
-
|
|
31326
|
+
execFileSync24("git", args, { stdio: "inherit" });
|
|
31067
31327
|
}
|
|
31068
31328
|
async function placePr(prNumber, title, body, options2, attachments = []) {
|
|
31069
31329
|
const args = prNumber !== null ? buildEditArgs(prNumber, title, body, attachments) : buildCreateArgs(title, body, options2, attachments);
|
|
@@ -31134,10 +31394,10 @@ function warn(reason4) {
|
|
|
31134
31394
|
}
|
|
31135
31395
|
|
|
31136
31396
|
// src/commands/prs/enableAutoMerge.ts
|
|
31137
|
-
import { execFileSync as
|
|
31397
|
+
import { execFileSync as execFileSync25 } from "child_process";
|
|
31138
31398
|
function enableAutoMerge() {
|
|
31139
31399
|
try {
|
|
31140
|
-
|
|
31400
|
+
execFileSync25(
|
|
31141
31401
|
"gh",
|
|
31142
31402
|
["pr", "merge", getCurrentBranch2(), "--auto", "--squash"],
|
|
31143
31403
|
{ stdio: "inherit" }
|
|
@@ -31395,10 +31655,10 @@ function prsSlackChannel() {
|
|
|
31395
31655
|
}
|
|
31396
31656
|
|
|
31397
31657
|
// src/commands/prs/status/fetchReviewThreads.ts
|
|
31398
|
-
import { execFileSync as
|
|
31658
|
+
import { execFileSync as execFileSync26 } from "child_process";
|
|
31399
31659
|
var THREAD_QUERY2 = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { isResolved } } } } }`;
|
|
31400
31660
|
function fetchReviewThreads(org, repo, prNumber) {
|
|
31401
|
-
const output =
|
|
31661
|
+
const output = execFileSync26(
|
|
31402
31662
|
"gh",
|
|
31403
31663
|
[
|
|
31404
31664
|
"api",
|
|
@@ -32955,9 +33215,9 @@ async function notify() {
|
|
|
32955
33215
|
|
|
32956
33216
|
// src/commands/screenshot.ts
|
|
32957
33217
|
import { execSync as execSync49 } from "child_process";
|
|
32958
|
-
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync15, writeFileSync as
|
|
32959
|
-
import { tmpdir as
|
|
32960
|
-
import { join as
|
|
33218
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync15, writeFileSync as writeFileSync38 } from "fs";
|
|
33219
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
33220
|
+
import { join as join82, resolve as resolve24 } from "path";
|
|
32961
33221
|
import chalk208 from "chalk";
|
|
32962
33222
|
|
|
32963
33223
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -33094,8 +33354,8 @@ function buildOutputPath(outputDir, processName) {
|
|
|
33094
33354
|
return resolve24(outputDir, `${processName}-${timestamp6}.png`);
|
|
33095
33355
|
}
|
|
33096
33356
|
function runPowerShellScript(processName, outputPath) {
|
|
33097
|
-
const scriptPath =
|
|
33098
|
-
|
|
33357
|
+
const scriptPath = join82(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
33358
|
+
writeFileSync38(scriptPath, captureWindowPs1, "utf8");
|
|
33099
33359
|
try {
|
|
33100
33360
|
execSync49(
|
|
33101
33361
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -33209,9 +33469,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
33209
33469
|
|
|
33210
33470
|
// src/commands/readGitBranch.ts
|
|
33211
33471
|
import { readFileSync as readFileSync48, statSync as statSync10 } from "fs";
|
|
33212
|
-
import { isAbsolute as isAbsolute6, join as
|
|
33472
|
+
import { isAbsolute as isAbsolute6, join as join83, resolve as resolve25 } from "path";
|
|
33213
33473
|
function resolveGitDir(cwd) {
|
|
33214
|
-
const dotGit =
|
|
33474
|
+
const dotGit = join83(cwd, ".git");
|
|
33215
33475
|
let stat5;
|
|
33216
33476
|
try {
|
|
33217
33477
|
stat5 = statSync10(dotGit);
|
|
@@ -33241,7 +33501,7 @@ function readGitBranch(cwd) {
|
|
|
33241
33501
|
}
|
|
33242
33502
|
let head;
|
|
33243
33503
|
try {
|
|
33244
|
-
head = readFileSync48(
|
|
33504
|
+
head = readFileSync48(join83(gitDir, "HEAD"), "utf8");
|
|
33245
33505
|
} catch {
|
|
33246
33506
|
return null;
|
|
33247
33507
|
}
|
|
@@ -35717,7 +35977,7 @@ function exitWith(message3) {
|
|
|
35717
35977
|
}
|
|
35718
35978
|
|
|
35719
35979
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
35720
|
-
import { execFileSync as
|
|
35980
|
+
import { execFileSync as execFileSync28 } from "child_process";
|
|
35721
35981
|
import chalk232 from "chalk";
|
|
35722
35982
|
|
|
35723
35983
|
// src/commands/review/highLevel/buildGlobProposalPrompt.ts
|
|
@@ -35766,7 +36026,7 @@ function readGlobs(value) {
|
|
|
35766
36026
|
}
|
|
35767
36027
|
|
|
35768
36028
|
// src/commands/review/highLevel/summariseRepoTree.ts
|
|
35769
|
-
import { execFileSync as
|
|
36029
|
+
import { execFileSync as execFileSync27 } from "child_process";
|
|
35770
36030
|
import { dirname as dirname38, extname as extname6 } from "path";
|
|
35771
36031
|
var MAX_DIRECTORIES = 200;
|
|
35772
36032
|
var MAX_EXTENSIONS_PER_DIRECTORY = 6;
|
|
@@ -35782,7 +36042,7 @@ function summariseRepoTree(cwd = process.cwd()) {
|
|
|
35782
36042
|
}
|
|
35783
36043
|
function listTrackedFiles(cwd) {
|
|
35784
36044
|
try {
|
|
35785
|
-
return
|
|
36045
|
+
return execFileSync27("git", ["ls-files"], {
|
|
35786
36046
|
cwd,
|
|
35787
36047
|
encoding: "utf8",
|
|
35788
36048
|
maxBuffer: 64 * 1024 * 1024
|
|
@@ -35827,7 +36087,7 @@ function proposeHighLevelGlobs(cwd = process.cwd()) {
|
|
|
35827
36087
|
}
|
|
35828
36088
|
function askClaude(prompt, cwd) {
|
|
35829
36089
|
try {
|
|
35830
|
-
return
|
|
36090
|
+
return execFileSync28("claude", ["-p", "--model", "sonnet", prompt], {
|
|
35831
36091
|
cwd,
|
|
35832
36092
|
encoding: "utf8",
|
|
35833
36093
|
timeout: 12e4,
|
|
@@ -36421,11 +36681,11 @@ function evaluateHighLevelChecks(subject) {
|
|
|
36421
36681
|
}
|
|
36422
36682
|
|
|
36423
36683
|
// src/commands/review/highLevel/fetchFileAtSha.ts
|
|
36424
|
-
import { execFileSync as
|
|
36684
|
+
import { execFileSync as execFileSync29 } from "child_process";
|
|
36425
36685
|
function fetchFileAtSha(repo, sha, path108) {
|
|
36426
36686
|
const encodedPath = path108.split("/").map(encodeURIComponent).join("/");
|
|
36427
36687
|
try {
|
|
36428
|
-
return
|
|
36688
|
+
return execFileSync29(
|
|
36429
36689
|
"gh",
|
|
36430
36690
|
[
|
|
36431
36691
|
"api",
|
|
@@ -36447,7 +36707,7 @@ function fetchFileAtSha(repo, sha, path108) {
|
|
|
36447
36707
|
}
|
|
36448
36708
|
|
|
36449
36709
|
// src/commands/review/highLevel/fetchHighLevelFiles.ts
|
|
36450
|
-
import { execFileSync as
|
|
36710
|
+
import { execFileSync as execFileSync30 } from "child_process";
|
|
36451
36711
|
import { createHash as createHash4 } from "crypto";
|
|
36452
36712
|
var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
|
|
36453
36713
|
function toStatus(status2) {
|
|
@@ -36460,7 +36720,7 @@ function diffUrl(repo, prNumber, path108) {
|
|
|
36460
36720
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
36461
36721
|
}
|
|
36462
36722
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
36463
|
-
const out =
|
|
36723
|
+
const out = execFileSync30(
|
|
36464
36724
|
"gh",
|
|
36465
36725
|
["api", `repos/${repo}/pulls/${prNumber}/files`, "--paginate", "--jq", JQ],
|
|
36466
36726
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
@@ -36489,7 +36749,7 @@ function sleepSync(ms) {
|
|
|
36489
36749
|
}
|
|
36490
36750
|
function waitForMergeable(initial, refetch, delayMs = DELAY_MS) {
|
|
36491
36751
|
let mergeable = initial;
|
|
36492
|
-
for (let
|
|
36752
|
+
for (let attempt2 = 1; mergeable === "UNKNOWN" && attempt2 < MAX_ATTEMPTS; attempt2++) {
|
|
36493
36753
|
sleepSync(delayMs);
|
|
36494
36754
|
mergeable = refetch();
|
|
36495
36755
|
}
|
|
@@ -36527,12 +36787,12 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
36527
36787
|
}
|
|
36528
36788
|
|
|
36529
36789
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
36530
|
-
import { join as
|
|
36790
|
+
import { join as join84 } from "path";
|
|
36531
36791
|
function slug(value) {
|
|
36532
36792
|
return value.replace(/[^\w.-]+/g, "-");
|
|
36533
36793
|
}
|
|
36534
36794
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
36535
|
-
return
|
|
36795
|
+
return join84(
|
|
36536
36796
|
getStoreDir(),
|
|
36537
36797
|
"high-level-reviews",
|
|
36538
36798
|
slug(repo),
|
|
@@ -36698,17 +36958,17 @@ function buildHighLevelRecord(subject, decision) {
|
|
|
36698
36958
|
}
|
|
36699
36959
|
|
|
36700
36960
|
// src/commands/review/highLevel/clearHighLevelDraft.ts
|
|
36701
|
-
import { rmSync as
|
|
36961
|
+
import { rmSync as rmSync7 } from "fs";
|
|
36702
36962
|
function clearHighLevelDraft(repo, headRef, headSha) {
|
|
36703
|
-
|
|
36963
|
+
rmSync7(highLevelDraftPath(repo, headRef, headSha), { force: true });
|
|
36704
36964
|
}
|
|
36705
36965
|
|
|
36706
36966
|
// src/commands/review/highLevel/writeJsonFile.ts
|
|
36707
|
-
import { mkdirSync as mkdirSync24, writeFileSync as
|
|
36967
|
+
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync39 } from "fs";
|
|
36708
36968
|
import { dirname as dirname39 } from "path";
|
|
36709
36969
|
function writeJsonFile(path108, data) {
|
|
36710
36970
|
mkdirSync24(dirname39(path108), { recursive: true });
|
|
36711
|
-
|
|
36971
|
+
writeFileSync39(path108, `${JSON.stringify(data, null, 2)}
|
|
36712
36972
|
`);
|
|
36713
36973
|
return path108;
|
|
36714
36974
|
}
|
|
@@ -37691,7 +37951,7 @@ import { format as format2 } from "util";
|
|
|
37691
37951
|
|
|
37692
37952
|
// src/commands/review/createReviewLogSink.ts
|
|
37693
37953
|
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync25 } from "fs";
|
|
37694
|
-
import { join as
|
|
37954
|
+
import { join as join85 } from "path";
|
|
37695
37955
|
var LOG_FILE = "review.log";
|
|
37696
37956
|
function createReviewLogSink() {
|
|
37697
37957
|
let logPath2;
|
|
@@ -37708,7 +37968,7 @@ function createReviewLogSink() {
|
|
|
37708
37968
|
},
|
|
37709
37969
|
attach(reviewDir) {
|
|
37710
37970
|
mkdirSync25(reviewDir, { recursive: true });
|
|
37711
|
-
logPath2 =
|
|
37971
|
+
logPath2 = join85(reviewDir, LOG_FILE);
|
|
37712
37972
|
const lines2 = [
|
|
37713
37973
|
"",
|
|
37714
37974
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -37958,7 +38218,7 @@ function buildCodexModelArgs() {
|
|
|
37958
38218
|
}
|
|
37959
38219
|
|
|
37960
38220
|
// src/commands/review/runClaudeReviewer.ts
|
|
37961
|
-
import { writeFileSync as
|
|
38221
|
+
import { writeFileSync as writeFileSync40 } from "fs";
|
|
37962
38222
|
|
|
37963
38223
|
// src/commands/review/formatToolSummary.ts
|
|
37964
38224
|
function truncate2(value, max = 80) {
|
|
@@ -38397,7 +38657,7 @@ async function runClaudeReviewer(spec) {
|
|
|
38397
38657
|
onLine
|
|
38398
38658
|
});
|
|
38399
38659
|
if (result.exitCode === 0 && state.finalText)
|
|
38400
|
-
|
|
38660
|
+
writeFileSync40(spec.outputPath, state.finalText);
|
|
38401
38661
|
const finalised = finaliseReviewerRun(
|
|
38402
38662
|
{ ...spec, command, model: override?.model },
|
|
38403
38663
|
spinner,
|
|
@@ -38923,9 +39183,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
38923
39183
|
|
|
38924
39184
|
// src/commands/review/buildReviewPaths.ts
|
|
38925
39185
|
import { homedir as homedir25 } from "os";
|
|
38926
|
-
import { basename as basename24, join as
|
|
39186
|
+
import { basename as basename24, join as join86 } from "path";
|
|
38927
39187
|
function buildReviewPaths(repoRoot2, key) {
|
|
38928
|
-
const reviewDir =
|
|
39188
|
+
const reviewDir = join86(
|
|
38929
39189
|
homedir25(),
|
|
38930
39190
|
".assist",
|
|
38931
39191
|
"reviews",
|
|
@@ -38934,10 +39194,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
38934
39194
|
);
|
|
38935
39195
|
return {
|
|
38936
39196
|
reviewDir,
|
|
38937
|
-
requestPath:
|
|
38938
|
-
claudePath:
|
|
38939
|
-
codexPath:
|
|
38940
|
-
synthesisPath:
|
|
39197
|
+
requestPath: join86(reviewDir, "request.md"),
|
|
39198
|
+
claudePath: join86(reviewDir, "claude.md"),
|
|
39199
|
+
codexPath: join86(reviewDir, "codex.md"),
|
|
39200
|
+
synthesisPath: join86(reviewDir, "synthesis.md")
|
|
38941
39201
|
};
|
|
38942
39202
|
}
|
|
38943
39203
|
|
|
@@ -38975,7 +39235,7 @@ function fetchExistingComments() {
|
|
|
38975
39235
|
}
|
|
38976
39236
|
|
|
38977
39237
|
// src/commands/review/prepareReviewDir.ts
|
|
38978
|
-
import { existsSync as existsSync69, mkdirSync as mkdirSync26, unlinkSync as unlinkSync18, writeFileSync as
|
|
39238
|
+
import { existsSync as existsSync69, mkdirSync as mkdirSync26, unlinkSync as unlinkSync18, writeFileSync as writeFileSync41 } from "fs";
|
|
38979
39239
|
function clearReviewFiles(paths) {
|
|
38980
39240
|
for (const path108 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
38981
39241
|
if (existsSync69(path108)) unlinkSync18(path108);
|
|
@@ -38984,7 +39244,7 @@ function clearReviewFiles(paths) {
|
|
|
38984
39244
|
function prepareReviewDir(paths, requestBody, force) {
|
|
38985
39245
|
mkdirSync26(paths.reviewDir, { recursive: true });
|
|
38986
39246
|
if (force) clearReviewFiles(paths);
|
|
38987
|
-
|
|
39247
|
+
writeFileSync41(paths.requestPath, requestBody);
|
|
38988
39248
|
}
|
|
38989
39249
|
|
|
38990
39250
|
// src/commands/review/setupReviewDir.ts
|
|
@@ -39632,7 +39892,7 @@ function registerReview(program) {
|
|
|
39632
39892
|
}
|
|
39633
39893
|
|
|
39634
39894
|
// src/commands/rules/addRule.ts
|
|
39635
|
-
import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as
|
|
39895
|
+
import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as writeFileSync43 } from "fs";
|
|
39636
39896
|
import path87 from "path";
|
|
39637
39897
|
import chalk242 from "chalk";
|
|
39638
39898
|
|
|
@@ -39707,7 +39967,7 @@ function resolveRuleScope(target) {
|
|
|
39707
39967
|
}
|
|
39708
39968
|
|
|
39709
39969
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
39710
|
-
import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as
|
|
39970
|
+
import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as writeFileSync42 } from "fs";
|
|
39711
39971
|
import path86 from "path";
|
|
39712
39972
|
|
|
39713
39973
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
@@ -39759,7 +40019,7 @@ function updateScopedRulesIndex(root2) {
|
|
|
39759
40019
|
const rootFile = path86.join(root2, "CLAUDE.md");
|
|
39760
40020
|
const before = existsSync71(rootFile) ? readFileSync55(rootFile, "utf8") : "";
|
|
39761
40021
|
const after = upsertScopedRulesPointer(before, directories);
|
|
39762
|
-
if (after !== before)
|
|
40022
|
+
if (after !== before) writeFileSync42(rootFile, after);
|
|
39763
40023
|
return directories;
|
|
39764
40024
|
}
|
|
39765
40025
|
|
|
@@ -39778,7 +40038,7 @@ function addRule(text17, options2) {
|
|
|
39778
40038
|
const targetDir = path87.dirname(target);
|
|
39779
40039
|
const root2 = findRepoRoot(targetDir) ?? targetDir;
|
|
39780
40040
|
const code = nextRuleCode(root2);
|
|
39781
|
-
|
|
40041
|
+
writeFileSync43(
|
|
39782
40042
|
target,
|
|
39783
40043
|
insertRuleBullet(read2(target), {
|
|
39784
40044
|
code,
|
|
@@ -40309,10 +40569,10 @@ function parseSlackThreadRef(value) {
|
|
|
40309
40569
|
}
|
|
40310
40570
|
|
|
40311
40571
|
// src/commands/slack/postSlackMessage.ts
|
|
40312
|
-
import { mkdirSync as mkdirSync28, writeFileSync as
|
|
40572
|
+
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync45 } from "fs";
|
|
40313
40573
|
|
|
40314
40574
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
40315
|
-
import { mkdirSync as mkdirSync27, writeFileSync as
|
|
40575
|
+
import { mkdirSync as mkdirSync27, writeFileSync as writeFileSync44 } from "fs";
|
|
40316
40576
|
|
|
40317
40577
|
// src/commands/slack/readSlackParts.ts
|
|
40318
40578
|
import { readFileSync as readFileSync57 } from "fs";
|
|
@@ -40358,12 +40618,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
40358
40618
|
}
|
|
40359
40619
|
|
|
40360
40620
|
// src/commands/slack/slackWorkingFile.ts
|
|
40361
|
-
import { join as
|
|
40621
|
+
import { join as join87 } from "path";
|
|
40362
40622
|
function slackWorkingFile(channel, partIndex) {
|
|
40363
40623
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
40364
|
-
const dir =
|
|
40624
|
+
const dir = join87(getStoreDir(), "slack");
|
|
40365
40625
|
const name = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
40366
|
-
return { dir, bodyPath:
|
|
40626
|
+
return { dir, bodyPath: join87(dir, `${name}.md`) };
|
|
40367
40627
|
}
|
|
40368
40628
|
|
|
40369
40629
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -40378,7 +40638,7 @@ async function previewSlackThreadParts({
|
|
|
40378
40638
|
mkdirSync27(dir, { recursive: true });
|
|
40379
40639
|
const paths = bodies.map((body, index2) => {
|
|
40380
40640
|
const { bodyPath } = slackWorkingFile(channel, index2 + 1);
|
|
40381
|
-
|
|
40641
|
+
writeFileSync44(bodyPath, `${body}
|
|
40382
40642
|
`);
|
|
40383
40643
|
return bodyPath;
|
|
40384
40644
|
});
|
|
@@ -40430,7 +40690,7 @@ async function postSlackMessage(channelArg, options2) {
|
|
|
40430
40690
|
}
|
|
40431
40691
|
const { dir, bodyPath } = slackWorkingFile(channel);
|
|
40432
40692
|
mkdirSync28(dir, { recursive: true });
|
|
40433
|
-
|
|
40693
|
+
writeFileSync45(bodyPath, `${body}
|
|
40434
40694
|
`);
|
|
40435
40695
|
await reviewProposedSlackMessage({ channel, threadTs }, body, bodyPath);
|
|
40436
40696
|
console.log(`Approved for ${target}. The body to post is at:`);
|
|
@@ -41546,20 +41806,20 @@ async function configure() {
|
|
|
41546
41806
|
|
|
41547
41807
|
// src/commands/transcript/list.ts
|
|
41548
41808
|
import { existsSync as existsSync78, readdirSync as readdirSync21, statSync as statSync12 } from "fs";
|
|
41549
|
-
import { join as
|
|
41809
|
+
import { join as join99 } from "path";
|
|
41550
41810
|
function list4() {
|
|
41551
41811
|
const { vttDir } = getTranscriptConfig();
|
|
41552
41812
|
if (!existsSync78(vttDir)) return;
|
|
41553
41813
|
for (const entry of readdirSync21(vttDir)) {
|
|
41554
41814
|
if (!entry.endsWith(".vtt")) continue;
|
|
41555
|
-
if (statSync12(
|
|
41815
|
+
if (statSync12(join99(vttDir, entry)).isDirectory()) continue;
|
|
41556
41816
|
console.log(entry);
|
|
41557
41817
|
}
|
|
41558
41818
|
}
|
|
41559
41819
|
|
|
41560
41820
|
// src/commands/transcript/move.ts
|
|
41561
|
-
import { existsSync as existsSync79, mkdirSync as mkdirSync34, renameSync as renameSync4, writeFileSync as
|
|
41562
|
-
import { basename as basename27, join as
|
|
41821
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync34, renameSync as renameSync4, writeFileSync as writeFileSync50 } from "fs";
|
|
41822
|
+
import { basename as basename27, join as join100 } from "path";
|
|
41563
41823
|
|
|
41564
41824
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
41565
41825
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -41569,9 +41829,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
41569
41829
|
// src/commands/transcript/move.ts
|
|
41570
41830
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
41571
41831
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
41572
|
-
const processedDir =
|
|
41832
|
+
const processedDir = join100(vttDir, "processed");
|
|
41573
41833
|
mkdirSync34(processedDir, { recursive: true });
|
|
41574
|
-
renameSync4(sourcePath,
|
|
41834
|
+
renameSync4(sourcePath, join100(processedDir, filename));
|
|
41575
41835
|
}
|
|
41576
41836
|
function move(file, options2) {
|
|
41577
41837
|
const { date, client } = options2;
|
|
@@ -41581,25 +41841,25 @@ function move(file, options2) {
|
|
|
41581
41841
|
}
|
|
41582
41842
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
41583
41843
|
const filename = basename27(file);
|
|
41584
|
-
const sourcePath =
|
|
41844
|
+
const sourcePath = join100(vttDir, filename);
|
|
41585
41845
|
if (!existsSync79(sourcePath)) {
|
|
41586
41846
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
41587
41847
|
process.exit(1);
|
|
41588
41848
|
}
|
|
41589
41849
|
const base = basename27(filename, ".vtt").replace(/ Transcription$/, "");
|
|
41590
41850
|
const outputName = `${date} ${base}.md`;
|
|
41591
|
-
const formattedDir =
|
|
41851
|
+
const formattedDir = join100(transcriptsDir, client);
|
|
41592
41852
|
mkdirSync34(formattedDir, { recursive: true });
|
|
41593
|
-
const formattedPath =
|
|
41594
|
-
|
|
41853
|
+
const formattedPath = join100(formattedDir, outputName);
|
|
41854
|
+
writeFileSync50(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
41595
41855
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
41596
|
-
const summaryPath =
|
|
41856
|
+
const summaryPath = join100(summaryDir, client, outputName);
|
|
41597
41857
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
41598
41858
|
console.log(`Summary target: ${summaryPath}`);
|
|
41599
41859
|
}
|
|
41600
41860
|
|
|
41601
41861
|
// src/commands/transcript/merge.ts
|
|
41602
|
-
import { existsSync as existsSync80, writeFileSync as
|
|
41862
|
+
import { existsSync as existsSync80, writeFileSync as writeFileSync51 } from "fs";
|
|
41603
41863
|
import { basename as basename28 } from "path";
|
|
41604
41864
|
|
|
41605
41865
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -41776,7 +42036,7 @@ async function merge(files, options2 = {}) {
|
|
|
41776
42036
|
console.log(document);
|
|
41777
42037
|
return;
|
|
41778
42038
|
}
|
|
41779
|
-
|
|
42039
|
+
writeFileSync51(options2.out, `${document}
|
|
41780
42040
|
`, "utf8");
|
|
41781
42041
|
console.log(`Merged transcript: ${options2.out}`);
|
|
41782
42042
|
}
|
|
@@ -42289,13 +42549,13 @@ Total: ${violations.length} forbidden string(s).`);
|
|
|
42289
42549
|
}
|
|
42290
42550
|
|
|
42291
42551
|
// src/commands/verify/hardcodedColors.ts
|
|
42292
|
-
import { execFileSync as
|
|
42552
|
+
import { execFileSync as execFileSync31 } from "child_process";
|
|
42293
42553
|
import { minimatch as minimatch11 } from "minimatch";
|
|
42294
42554
|
var pattern = "0x[0-9a-fA-F]{6}|#[0-9a-fA-F]{3,6}";
|
|
42295
42555
|
function hardcodedColors() {
|
|
42296
42556
|
const ignoreGlobs = loadConfig().hardcodedColors?.ignore ?? [];
|
|
42297
42557
|
try {
|
|
42298
|
-
const output =
|
|
42558
|
+
const output = execFileSync31("grep", ["-rEnH", "-f", "-", "src/"], {
|
|
42299
42559
|
encoding: "utf8",
|
|
42300
42560
|
input: `${pattern}
|
|
42301
42561
|
`
|
|
@@ -43078,11 +43338,11 @@ ${buildWatchReport(from)}`);
|
|
|
43078
43338
|
}
|
|
43079
43339
|
|
|
43080
43340
|
// src/commands/watch/consumeMarker.ts
|
|
43081
|
-
import { existsSync as existsSync83, rmSync as
|
|
43341
|
+
import { existsSync as existsSync83, rmSync as rmSync11 } from "fs";
|
|
43082
43342
|
function consumeMarker(path108) {
|
|
43083
43343
|
try {
|
|
43084
43344
|
if (!existsSync83(path108)) return false;
|
|
43085
|
-
|
|
43345
|
+
rmSync11(path108);
|
|
43086
43346
|
return true;
|
|
43087
43347
|
} catch {
|
|
43088
43348
|
return false;
|
|
@@ -43259,10 +43519,10 @@ function registerWatchWait(watchCommand) {
|
|
|
43259
43519
|
}
|
|
43260
43520
|
|
|
43261
43521
|
// src/commands/watch/simulateDivergence.ts
|
|
43262
|
-
import { writeFileSync as
|
|
43522
|
+
import { writeFileSync as writeFileSync52 } from "fs";
|
|
43263
43523
|
function simulateDivergence() {
|
|
43264
43524
|
try {
|
|
43265
|
-
|
|
43525
|
+
writeFileSync52(simulatedDivergencePath(), "");
|
|
43266
43526
|
console.log(
|
|
43267
43527
|
`the next assist watch wait poll in ${runGit3(["rev-parse", "--show-toplevel"])} will exit 3 as a simulated divergence`
|
|
43268
43528
|
);
|
|
@@ -43514,9 +43774,9 @@ async function auth() {
|
|
|
43514
43774
|
}
|
|
43515
43775
|
|
|
43516
43776
|
// src/commands/roam/postRoamActivity.ts
|
|
43517
|
-
import { execFileSync as
|
|
43777
|
+
import { execFileSync as execFileSync32 } from "child_process";
|
|
43518
43778
|
import { readdirSync as readdirSync23, readFileSync as readFileSync65, statSync as statSync13 } from "fs";
|
|
43519
|
-
import { join as
|
|
43779
|
+
import { join as join101 } from "path";
|
|
43520
43780
|
function findPortFile(roamDir) {
|
|
43521
43781
|
let entries;
|
|
43522
43782
|
try {
|
|
@@ -43525,7 +43785,7 @@ function findPortFile(roamDir) {
|
|
|
43525
43785
|
return void 0;
|
|
43526
43786
|
}
|
|
43527
43787
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
43528
|
-
const path108 =
|
|
43788
|
+
const path108 = join101(roamDir, name);
|
|
43529
43789
|
try {
|
|
43530
43790
|
return { path: path108, mtimeMs: statSync13(path108).mtimeMs };
|
|
43531
43791
|
} catch {
|
|
@@ -43542,7 +43802,7 @@ var PID_BY_APP = {
|
|
|
43542
43802
|
function postRoamActivity(app, event) {
|
|
43543
43803
|
const appData = process.env.APPDATA;
|
|
43544
43804
|
if (!appData) return;
|
|
43545
|
-
const portFile = findPortFile(
|
|
43805
|
+
const portFile = findPortFile(join101(appData, "Roam"));
|
|
43546
43806
|
if (!portFile) return;
|
|
43547
43807
|
let port;
|
|
43548
43808
|
try {
|
|
@@ -43553,7 +43813,7 @@ function postRoamActivity(app, event) {
|
|
|
43553
43813
|
const pid = PID_BY_APP[app] ?? 99999;
|
|
43554
43814
|
const url = `http://127.0.0.1:${port}/api/v1/activity/${app}/${event}?pid=${pid}`;
|
|
43555
43815
|
try {
|
|
43556
|
-
|
|
43816
|
+
execFileSync32("curl", ["-sf", "--max-time", "0.2", "-X", "POST", url], {
|
|
43557
43817
|
stdio: "ignore"
|
|
43558
43818
|
});
|
|
43559
43819
|
} catch {
|
|
@@ -43727,8 +43987,8 @@ function link2() {
|
|
|
43727
43987
|
}
|
|
43728
43988
|
|
|
43729
43989
|
// src/commands/run/add.ts
|
|
43730
|
-
import { mkdirSync as mkdirSync35, writeFileSync as
|
|
43731
|
-
import { join as
|
|
43990
|
+
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync53 } from "fs";
|
|
43991
|
+
import { join as join102 } from "path";
|
|
43732
43992
|
|
|
43733
43993
|
// src/commands/run/editRepoRunList.ts
|
|
43734
43994
|
async function editRepoRunList(repoName, cwd, edit2) {
|
|
@@ -43899,7 +44159,7 @@ function saveProjectRunConfig(entry) {
|
|
|
43899
44159
|
saveConfig(config);
|
|
43900
44160
|
}
|
|
43901
44161
|
function createCommandFile(name) {
|
|
43902
|
-
const dir =
|
|
44162
|
+
const dir = join102(".claude", "commands");
|
|
43903
44163
|
mkdirSync35(dir, { recursive: true });
|
|
43904
44164
|
const content = `---
|
|
43905
44165
|
description: Run ${name}
|
|
@@ -43907,8 +44167,8 @@ description: Run ${name}
|
|
|
43907
44167
|
|
|
43908
44168
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
43909
44169
|
`;
|
|
43910
|
-
const filePath =
|
|
43911
|
-
|
|
44170
|
+
const filePath = join102(dir, `${name}.md`);
|
|
44171
|
+
writeFileSync53(filePath, content);
|
|
43912
44172
|
console.log(`Created command file: ${filePath}`);
|
|
43913
44173
|
}
|
|
43914
44174
|
async function add4() {
|
|
@@ -44013,7 +44273,7 @@ function registerRunAdd(runCommand) {
|
|
|
44013
44273
|
|
|
44014
44274
|
// src/commands/run/remove.ts
|
|
44015
44275
|
import { existsSync as existsSync84, unlinkSync as unlinkSync19 } from "fs";
|
|
44016
|
-
import { join as
|
|
44276
|
+
import { join as join103 } from "path";
|
|
44017
44277
|
|
|
44018
44278
|
// src/commands/run/removeRepoRunConfig.ts
|
|
44019
44279
|
function isNamed(entry, name) {
|
|
@@ -44031,7 +44291,7 @@ function removeRepoRunConfig(name, repoName, cwd = process.cwd()) {
|
|
|
44031
44291
|
|
|
44032
44292
|
// src/commands/run/remove.ts
|
|
44033
44293
|
function deleteCommandFile(name) {
|
|
44034
|
-
const filePath =
|
|
44294
|
+
const filePath = join103(".claude", "commands", `${name}.md`);
|
|
44035
44295
|
if (existsSync84(filePath)) {
|
|
44036
44296
|
unlinkSync19(filePath);
|
|
44037
44297
|
console.log(`Deleted command file: ${filePath}`);
|
|
@@ -44101,11 +44361,11 @@ function formatLink(link3) {
|
|
|
44101
44361
|
}
|
|
44102
44362
|
|
|
44103
44363
|
// src/commands/sessions/daemon/listDaemonPids.ts
|
|
44104
|
-
import { execFileSync as
|
|
44364
|
+
import { execFileSync as execFileSync33 } from "child_process";
|
|
44105
44365
|
function listDaemonPids() {
|
|
44106
44366
|
if (process.platform === "win32") return [];
|
|
44107
44367
|
try {
|
|
44108
|
-
const out =
|
|
44368
|
+
const out = execFileSync33("ps", ["-eo", "pid=,args="], {
|
|
44109
44369
|
encoding: "utf8"
|
|
44110
44370
|
});
|
|
44111
44371
|
return out.split("\n").filter((line) => line.includes("assist") && / daemon run\b/.test(line)).map((line) => Number.parseInt(line.trim(), 10)).filter((pid) => Number.isInteger(pid));
|
|
@@ -44567,7 +44827,7 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
|
44567
44827
|
|
|
44568
44828
|
// src/commands/sessions/daemon/findServerParents.ts
|
|
44569
44829
|
import { existsSync as existsSync86 } from "fs";
|
|
44570
|
-
import { join as
|
|
44830
|
+
import { join as join104, resolve as resolve29 } from "path";
|
|
44571
44831
|
function isLive(session) {
|
|
44572
44832
|
return !!session.pty && session.status !== "done" && session.status !== "error";
|
|
44573
44833
|
}
|
|
@@ -44576,7 +44836,7 @@ function isLiveAgent(session) {
|
|
|
44576
44836
|
}
|
|
44577
44837
|
function serverRunDirs(sessions, file) {
|
|
44578
44838
|
return new Set(
|
|
44579
|
-
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve29(s.cwd)).filter((dir) => existsSync86(
|
|
44839
|
+
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve29(s.cwd)).filter((dir) => existsSync86(join104(dir, file)))
|
|
44580
44840
|
);
|
|
44581
44841
|
}
|
|
44582
44842
|
function findServerParents(sessions, file) {
|
|
@@ -44794,7 +45054,7 @@ function sendResizeSnapshot(s, send) {
|
|
|
44794
45054
|
}
|
|
44795
45055
|
|
|
44796
45056
|
// src/commands/sessions/daemon/viewerSize.ts
|
|
44797
|
-
import { readFileSync as readFileSync67, writeFileSync as
|
|
45057
|
+
import { readFileSync as readFileSync67, writeFileSync as writeFileSync54 } from "fs";
|
|
44798
45058
|
var DEFAULT_SIZE = { cols: 120, rows: 30 };
|
|
44799
45059
|
var remembered;
|
|
44800
45060
|
function rememberViewerSize(cols, rows) {
|
|
@@ -44802,7 +45062,7 @@ function rememberViewerSize(cols, rows) {
|
|
|
44802
45062
|
if (remembered?.cols === cols && remembered.rows === rows) return;
|
|
44803
45063
|
remembered = { cols, rows };
|
|
44804
45064
|
try {
|
|
44805
|
-
|
|
45065
|
+
writeFileSync54(daemonPaths.viewerSize, JSON.stringify(remembered));
|
|
44806
45066
|
} catch (error) {
|
|
44807
45067
|
daemonLog(
|
|
44808
45068
|
`viewer size ${cols}x${rows} not saved: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -45437,13 +45697,13 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
|
45437
45697
|
}
|
|
45438
45698
|
|
|
45439
45699
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
|
|
45440
|
-
import { existsSync as existsSync90, rmSync as
|
|
45700
|
+
import { existsSync as existsSync90, rmSync as rmSync12, writeFileSync as writeFileSync55 } from "fs";
|
|
45441
45701
|
var paused;
|
|
45442
45702
|
var wake;
|
|
45443
45703
|
function persist2(value) {
|
|
45444
45704
|
try {
|
|
45445
|
-
if (value)
|
|
45446
|
-
else
|
|
45705
|
+
if (value) writeFileSync55(daemonPaths.autoUpdatePaused, "");
|
|
45706
|
+
else rmSync12(daemonPaths.autoUpdatePaused, { force: true });
|
|
45447
45707
|
} catch {
|
|
45448
45708
|
}
|
|
45449
45709
|
}
|
|
@@ -45567,7 +45827,7 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
45567
45827
|
}
|
|
45568
45828
|
|
|
45569
45829
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
45570
|
-
import { readFileSync as readFileSync69, writeFileSync as
|
|
45830
|
+
import { readFileSync as readFileSync69, writeFileSync as writeFileSync56 } from "fs";
|
|
45571
45831
|
var KEEP_TAIL = 256 * 1024;
|
|
45572
45832
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
45573
45833
|
function trimWatcherLog(cwd) {
|
|
@@ -45579,7 +45839,7 @@ function trimWatcherLog(cwd) {
|
|
|
45579
45839
|
return;
|
|
45580
45840
|
}
|
|
45581
45841
|
if (log2.length <= MAX_LOG_SIZE) return;
|
|
45582
|
-
|
|
45842
|
+
writeFileSync56(path108, log2.slice(-KEEP_TAIL));
|
|
45583
45843
|
daemonLog(`auto-update: log ${path108} trimmed to its last ${KEEP_TAIL} chars`);
|
|
45584
45844
|
}
|
|
45585
45845
|
|
|
@@ -45829,12 +46089,12 @@ function noteAutoUpdate(installDir, text17) {
|
|
|
45829
46089
|
|
|
45830
46090
|
// src/commands/sessions/daemon/autoUpdate/runUpdateLap.ts
|
|
45831
46091
|
import { spawn as spawn11 } from "child_process";
|
|
45832
|
-
import { rmSync as
|
|
46092
|
+
import { rmSync as rmSync13 } from "fs";
|
|
45833
46093
|
function clearLapSignals(cwd) {
|
|
45834
46094
|
const control = watchControlPaths(cwd);
|
|
45835
46095
|
if (!control) return;
|
|
45836
46096
|
for (const path108 of [control.check, control.stop])
|
|
45837
|
-
|
|
46097
|
+
rmSync13(path108, { force: true });
|
|
45838
46098
|
}
|
|
45839
46099
|
function runUpdateLap(cwd, onOutput) {
|
|
45840
46100
|
clearLapSignals(cwd);
|
|
@@ -45943,12 +46203,12 @@ import { basename as basename30 } from "path";
|
|
|
45943
46203
|
|
|
45944
46204
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
45945
46205
|
import { existsSync as existsSync92 } from "fs";
|
|
45946
|
-
import { join as
|
|
46206
|
+
import { join as join108 } from "path";
|
|
45947
46207
|
|
|
45948
46208
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
45949
46209
|
import { statSync as statSync15 } from "fs";
|
|
45950
46210
|
import { rm as rm3 } from "fs/promises";
|
|
45951
|
-
import { join as
|
|
46211
|
+
import { join as join107 } from "path";
|
|
45952
46212
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
45953
46213
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
45954
46214
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -45976,7 +46236,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
45976
46236
|
return { removed: true };
|
|
45977
46237
|
}
|
|
45978
46238
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
45979
|
-
return statSync15(
|
|
46239
|
+
return statSync15(join107(worktreePath, ".git"), {
|
|
45980
46240
|
throwIfNoEntry: false
|
|
45981
46241
|
})?.isDirectory() === true;
|
|
45982
46242
|
}
|
|
@@ -46012,7 +46272,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
46012
46272
|
);
|
|
46013
46273
|
}
|
|
46014
46274
|
function strandedReason(worktreePath, cause) {
|
|
46015
|
-
if (!existsSync92(
|
|
46275
|
+
if (!existsSync92(join108(worktreePath, ".git")))
|
|
46016
46276
|
return "its .git link is already gone";
|
|
46017
46277
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
46018
46278
|
return "git no longer recognises it as a working tree";
|
|
@@ -48386,7 +48646,7 @@ function releaseClient(client, clients, prPreview, verify) {
|
|
|
48386
48646
|
}
|
|
48387
48647
|
|
|
48388
48648
|
// src/commands/sessions/daemon/findPortHolderPid.ts
|
|
48389
|
-
import { execFileSync as
|
|
48649
|
+
import { execFileSync as execFileSync34 } from "child_process";
|
|
48390
48650
|
var PROBE_TIMEOUT_MS = 3e3;
|
|
48391
48651
|
function findPortHolderPid(port) {
|
|
48392
48652
|
try {
|
|
@@ -48396,7 +48656,7 @@ function findPortHolderPid(port) {
|
|
|
48396
48656
|
}
|
|
48397
48657
|
}
|
|
48398
48658
|
function probe(command, args) {
|
|
48399
|
-
return
|
|
48659
|
+
return execFileSync34(command, args, {
|
|
48400
48660
|
encoding: "utf8",
|
|
48401
48661
|
timeout: PROBE_TIMEOUT_MS,
|
|
48402
48662
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -48583,10 +48843,10 @@ function deferralNotice(persisted, cap2) {
|
|
|
48583
48843
|
|
|
48584
48844
|
// src/commands/sessions/daemon/worktree/underTempRoot.ts
|
|
48585
48845
|
import { realpathSync as realpathSync3 } from "fs";
|
|
48586
|
-
import { tmpdir as
|
|
48846
|
+
import { tmpdir as tmpdir8 } from "os";
|
|
48587
48847
|
import { sep as sep5 } from "path";
|
|
48588
48848
|
function tempRoots() {
|
|
48589
|
-
const raw =
|
|
48849
|
+
const raw = tmpdir8();
|
|
48590
48850
|
const roots = /* @__PURE__ */ new Set([raw]);
|
|
48591
48851
|
try {
|
|
48592
48852
|
roots.add(realpathSync3(raw));
|
|
@@ -50402,7 +50662,7 @@ import { existsSync as existsSync100 } from "fs";
|
|
|
50402
50662
|
|
|
50403
50663
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
50404
50664
|
import { copyFileSync as copyFileSync4, existsSync as existsSync99, mkdirSync as mkdirSync39 } from "fs";
|
|
50405
|
-
import { join as
|
|
50665
|
+
import { join as join109 } from "path";
|
|
50406
50666
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
50407
50667
|
const dir = projectDirForCwd(toCwd);
|
|
50408
50668
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -50411,7 +50671,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
50411
50671
|
);
|
|
50412
50672
|
return;
|
|
50413
50673
|
}
|
|
50414
|
-
const dest =
|
|
50674
|
+
const dest = join109(dir, `${claudeSessionId}.jsonl`);
|
|
50415
50675
|
if (existsSync99(dest)) {
|
|
50416
50676
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
50417
50677
|
return;
|
|
@@ -50725,10 +50985,10 @@ function autoUpdateReply() {
|
|
|
50725
50985
|
}
|
|
50726
50986
|
|
|
50727
50987
|
// src/commands/sessions/daemon/autoUpdate/applyAutoUpdateAction.ts
|
|
50728
|
-
import { rmSync as
|
|
50988
|
+
import { rmSync as rmSync14, writeFileSync as writeFileSync57 } from "fs";
|
|
50729
50989
|
function signalLap(installDir, marker2) {
|
|
50730
50990
|
const control = watchControlPaths(installDir);
|
|
50731
|
-
if (control)
|
|
50991
|
+
if (control) writeFileSync57(control[marker2], "");
|
|
50732
50992
|
}
|
|
50733
50993
|
function applyAutoUpdateAction(action) {
|
|
50734
50994
|
const installDir = getInstallDir();
|
|
@@ -50736,7 +50996,7 @@ function applyAutoUpdateAction(action) {
|
|
|
50736
50996
|
if (action === "resume") {
|
|
50737
50997
|
if (!autoUpdateControl.paused()) return void 0;
|
|
50738
50998
|
const control = watchControlPaths(installDir);
|
|
50739
|
-
if (control)
|
|
50999
|
+
if (control) rmSync14(control.stop, { force: true });
|
|
50740
51000
|
autoUpdateControl.setPaused(false);
|
|
50741
51001
|
noteAutoUpdate(installDir, "resumed from Updates");
|
|
50742
51002
|
return void 0;
|
|
@@ -51660,7 +51920,7 @@ function handleConnection(socket, manager) {
|
|
|
51660
51920
|
}
|
|
51661
51921
|
|
|
51662
51922
|
// src/commands/sessions/daemon/onListening.ts
|
|
51663
|
-
import { unlinkSync as unlinkSync20, writeFileSync as
|
|
51923
|
+
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync58 } from "fs";
|
|
51664
51924
|
|
|
51665
51925
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
51666
51926
|
import { readFileSync as readFileSync70 } from "fs";
|
|
@@ -51682,7 +51942,7 @@ function ownsPidFile() {
|
|
|
51682
51942
|
|
|
51683
51943
|
// src/commands/sessions/daemon/onListening.ts
|
|
51684
51944
|
function onListening(manager, checkAutoExit) {
|
|
51685
|
-
|
|
51945
|
+
writeFileSync58(daemonPaths.pid, String(process.pid));
|
|
51686
51946
|
startPidFileWatchdog(() => {
|
|
51687
51947
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
51688
51948
|
void manager.flushActiveMs().finally(() => {
|