@staff0rd/assist 0.871.0 → 0.872.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.872.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1206,6 +1206,10 @@ function buildRunEntry(name, command, args, options2) {
|
|
|
1206
1206
|
if (options2?.server !== void 0) entry.server = options2.server;
|
|
1207
1207
|
if (options2?.port !== void 0) entry.port = options2.port;
|
|
1208
1208
|
if (options2?.env) entry.env = options2.env;
|
|
1209
|
+
if (options2?.pre) entry.pre = options2.pre;
|
|
1210
|
+
if (options2?.filter) entry.filter = options2.filter;
|
|
1211
|
+
if (options2?.quiet) entry.quiet = true;
|
|
1212
|
+
if (options2?.params) entry.params = options2.params;
|
|
1209
1213
|
return entry;
|
|
1210
1214
|
}
|
|
1211
1215
|
|
|
@@ -13671,7 +13675,7 @@ var rootConfigHelp = {
|
|
|
13671
13675
|
var runConfigHelp = [
|
|
13672
13676
|
{
|
|
13673
13677
|
key: "run",
|
|
13674
|
-
setter: "assist run add <name> <command> [--env KEY=VALUE] [--server [group]] [--repo]",
|
|
13678
|
+
setter: "assist run add <name> <command> [--env KEY=VALUE] [--pre <cmd>] [--param <spec>] [--server [group]] [--repo] (see --help)",
|
|
13675
13679
|
note: "configured commands runnable via assist run <name>"
|
|
13676
13680
|
}
|
|
13677
13681
|
];
|
|
@@ -14112,6 +14116,15 @@ async function getReviewSynthesis(req, res) {
|
|
|
14112
14116
|
// src/commands/sessions/web/githubFileContent.ts
|
|
14113
14117
|
import { execFile as execFile7 } from "child_process";
|
|
14114
14118
|
import { promisify as promisify6 } from "util";
|
|
14119
|
+
|
|
14120
|
+
// src/shared/ghFailure.ts
|
|
14121
|
+
function ghFailure(error) {
|
|
14122
|
+
const stderr = error.stderr;
|
|
14123
|
+
if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
|
|
14124
|
+
return error instanceof Error ? error.message : "gh api failed";
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
// src/commands/sessions/web/githubFileContent.ts
|
|
14115
14128
|
var execFileAsync6 = promisify6(execFile7);
|
|
14116
14129
|
var MAX_FILE_BYTES2 = 2 * 1024 * 1024;
|
|
14117
14130
|
var REPO = /^[\w.-]+\/[\w.-]+$/;
|
|
@@ -14119,11 +14132,6 @@ var SHA = /^[0-9a-f]{7,40}$/i;
|
|
|
14119
14132
|
function validPath(path109) {
|
|
14120
14133
|
return path109.length > 0 && !path109.startsWith("/") && path109.split("/").every((part) => part !== "" && part !== "..");
|
|
14121
14134
|
}
|
|
14122
|
-
function ghFailure(error) {
|
|
14123
|
-
const stderr = error.stderr;
|
|
14124
|
-
if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
|
|
14125
|
-
return error instanceof Error ? error.message : "gh api failed";
|
|
14126
|
-
}
|
|
14127
14135
|
async function githubFileContent(req, res) {
|
|
14128
14136
|
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
14129
14137
|
const repo = params.get("repo") ?? "";
|
|
@@ -35817,8 +35825,6 @@ function capHighLevelTestSources(files) {
|
|
|
35817
35825
|
}
|
|
35818
35826
|
|
|
35819
35827
|
// src/commands/review/highLevel/collectHighLevelTests.ts
|
|
35820
|
-
import { existsSync as existsSync65, readFileSync as readFileSync49 } from "fs";
|
|
35821
|
-
import { join as join82 } from "path";
|
|
35822
35828
|
import { minimatch as minimatch6 } from "minimatch";
|
|
35823
35829
|
|
|
35824
35830
|
// src/commands/review/highLevel/extractTestHierarchy.ts
|
|
@@ -35940,23 +35946,17 @@ function patchAddedLines(patch2) {
|
|
|
35940
35946
|
}
|
|
35941
35947
|
|
|
35942
35948
|
// src/commands/review/highLevel/collectHighLevelTests.ts
|
|
35943
|
-
function testFile(file,
|
|
35944
|
-
const absolute2 = join82(repoRoot2, file.path);
|
|
35945
|
-
if (!existsSync65(absolute2)) return [];
|
|
35949
|
+
function testFile(file, readSource4) {
|
|
35946
35950
|
const changed = file.patch === void 0 ? void 0 : patchAddedLines(file.patch);
|
|
35947
|
-
const tests = extractTestHierarchy(
|
|
35948
|
-
file.path,
|
|
35949
|
-
readFileSync49(absolute2, "utf8"),
|
|
35950
|
-
changed
|
|
35951
|
-
);
|
|
35951
|
+
const tests = extractTestHierarchy(file.path, readSource4(file.path), changed);
|
|
35952
35952
|
if (tests.length === 0) return [];
|
|
35953
35953
|
const { path: path109, status: status2, additions, deletions, diffUrl: diffUrl2 } = file;
|
|
35954
35954
|
return [{ path: path109, status: status2, additions, deletions, diffUrl: diffUrl2, tests }];
|
|
35955
35955
|
}
|
|
35956
|
-
function collectHighLevelTests(files, testPaths,
|
|
35956
|
+
function collectHighLevelTests(files, testPaths, readSource4) {
|
|
35957
35957
|
return files.filter(
|
|
35958
35958
|
(file) => file.status !== "removed" && testPaths.some((glob) => minimatch6(file.path, glob))
|
|
35959
|
-
).flatMap((file) => testFile(file,
|
|
35959
|
+
).flatMap((file) => testFile(file, readSource4));
|
|
35960
35960
|
}
|
|
35961
35961
|
|
|
35962
35962
|
// src/commands/review/highLevel/checkDescriptionLinksIssue.ts
|
|
@@ -36157,8 +36157,34 @@ function evaluateHighLevelChecks(subject) {
|
|
|
36157
36157
|
});
|
|
36158
36158
|
}
|
|
36159
36159
|
|
|
36160
|
-
// src/commands/review/highLevel/
|
|
36160
|
+
// src/commands/review/highLevel/fetchFileAtSha.ts
|
|
36161
36161
|
import { execFileSync as execFileSync26 } from "child_process";
|
|
36162
|
+
function fetchFileAtSha(repo, sha, path109) {
|
|
36163
|
+
const encodedPath = path109.split("/").map(encodeURIComponent).join("/");
|
|
36164
|
+
try {
|
|
36165
|
+
return execFileSync26(
|
|
36166
|
+
"gh",
|
|
36167
|
+
[
|
|
36168
|
+
"api",
|
|
36169
|
+
"-H",
|
|
36170
|
+
"Accept: application/vnd.github.raw",
|
|
36171
|
+
`repos/${repo}/contents/${encodedPath}?ref=${sha}`
|
|
36172
|
+
],
|
|
36173
|
+
{
|
|
36174
|
+
encoding: "utf8",
|
|
36175
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
36176
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
36177
|
+
}
|
|
36178
|
+
);
|
|
36179
|
+
} catch (error) {
|
|
36180
|
+
throw new Error(
|
|
36181
|
+
`Could not read ${path109} at PR head ${sha.slice(0, 7)}: ${ghFailure(error)}`
|
|
36182
|
+
);
|
|
36183
|
+
}
|
|
36184
|
+
}
|
|
36185
|
+
|
|
36186
|
+
// src/commands/review/highLevel/fetchHighLevelFiles.ts
|
|
36187
|
+
import { execFileSync as execFileSync27 } from "child_process";
|
|
36162
36188
|
import { createHash as createHash4 } from "crypto";
|
|
36163
36189
|
var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
|
|
36164
36190
|
function toStatus(status2) {
|
|
@@ -36171,7 +36197,7 @@ function diffUrl(repo, prNumber, path109) {
|
|
|
36171
36197
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
36172
36198
|
}
|
|
36173
36199
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
36174
|
-
const out =
|
|
36200
|
+
const out = execFileSync27(
|
|
36175
36201
|
"gh",
|
|
36176
36202
|
["api", `repos/${repo}/pulls/${prNumber}/files`, "--paginate", "--jq", JQ],
|
|
36177
36203
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
@@ -36238,15 +36264,15 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
36238
36264
|
}
|
|
36239
36265
|
|
|
36240
36266
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
36241
|
-
import { existsSync as
|
|
36267
|
+
import { existsSync as existsSync65, readFileSync as readFileSync49 } from "fs";
|
|
36242
36268
|
|
|
36243
36269
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
36244
|
-
import { join as
|
|
36270
|
+
import { join as join82 } from "path";
|
|
36245
36271
|
function slug(value) {
|
|
36246
36272
|
return value.replace(/[^\w.-]+/g, "-");
|
|
36247
36273
|
}
|
|
36248
36274
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
36249
|
-
return
|
|
36275
|
+
return join82(
|
|
36250
36276
|
getStoreDir(),
|
|
36251
36277
|
"high-level-reviews",
|
|
36252
36278
|
slug(repo),
|
|
@@ -36257,9 +36283,9 @@ function highLevelReviewPath(repo, headRef, headSha) {
|
|
|
36257
36283
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
36258
36284
|
function loadHighLevelReview(repo, headRef, headSha) {
|
|
36259
36285
|
const path109 = highLevelReviewPath(repo, headRef, headSha);
|
|
36260
|
-
if (!
|
|
36286
|
+
if (!existsSync65(path109)) return void 0;
|
|
36261
36287
|
try {
|
|
36262
|
-
return JSON.parse(
|
|
36288
|
+
return JSON.parse(readFileSync49(path109, "utf8"));
|
|
36263
36289
|
} catch {
|
|
36264
36290
|
return void 0;
|
|
36265
36291
|
}
|
|
@@ -36312,7 +36338,7 @@ function gatherHighLevelSubject(prNumber, force) {
|
|
|
36312
36338
|
collectHighLevelTests(
|
|
36313
36339
|
fetched,
|
|
36314
36340
|
config.testPaths,
|
|
36315
|
-
|
|
36341
|
+
(path109) => fetchFileAtSha(slug2, pr.headSha, path109)
|
|
36316
36342
|
)
|
|
36317
36343
|
),
|
|
36318
36344
|
testPaths: config.testPaths,
|
|
@@ -36811,9 +36837,19 @@ function resolvePrNumber2(number) {
|
|
|
36811
36837
|
}
|
|
36812
36838
|
return parsed;
|
|
36813
36839
|
}
|
|
36840
|
+
function gatherSubject(prNumber, force) {
|
|
36841
|
+
try {
|
|
36842
|
+
return gatherHighLevelSubject(prNumber, force);
|
|
36843
|
+
} catch (error) {
|
|
36844
|
+
console.error(
|
|
36845
|
+
`Error: ${error instanceof Error ? error.message : String(error)}`
|
|
36846
|
+
);
|
|
36847
|
+
process.exit(1);
|
|
36848
|
+
}
|
|
36849
|
+
}
|
|
36814
36850
|
async function runHighLevelReview(number, options2 = {}) {
|
|
36815
36851
|
const force = options2.force === true;
|
|
36816
|
-
const subject =
|
|
36852
|
+
const subject = gatherSubject(resolvePrNumber2(number), force);
|
|
36817
36853
|
announceSavedReview(subject, force);
|
|
36818
36854
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
36819
36855
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId)
|
|
@@ -36822,7 +36858,7 @@ async function runHighLevelReview(number, options2 = {}) {
|
|
|
36822
36858
|
}
|
|
36823
36859
|
|
|
36824
36860
|
// src/commands/review/ci/writeJobSummary.ts
|
|
36825
|
-
import { appendFileSync as appendFileSync2, readFileSync as
|
|
36861
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync50 } from "fs";
|
|
36826
36862
|
|
|
36827
36863
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
36828
36864
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -37198,7 +37234,7 @@ function buildTokenUsageTable(usages) {
|
|
|
37198
37234
|
// src/commands/review/ci/writeJobSummary.ts
|
|
37199
37235
|
function writeJobSummary(synthesisPath, prInfo, summaryPath, slots) {
|
|
37200
37236
|
if (!summaryPath) return;
|
|
37201
|
-
const markdown =
|
|
37237
|
+
const markdown = readFileSync50(synthesisPath, "utf8");
|
|
37202
37238
|
const { unanchored } = selectPostableFindings(markdown, prInfo);
|
|
37203
37239
|
const usageTable = buildTokenUsageTable(slots.map((slot) => slot.usage));
|
|
37204
37240
|
appendFileSync2(
|
|
@@ -37317,7 +37353,7 @@ import { format as format2 } from "util";
|
|
|
37317
37353
|
|
|
37318
37354
|
// src/commands/review/createReviewLogSink.ts
|
|
37319
37355
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync24 } from "fs";
|
|
37320
|
-
import { join as
|
|
37356
|
+
import { join as join83 } from "path";
|
|
37321
37357
|
var LOG_FILE = "review.log";
|
|
37322
37358
|
function createReviewLogSink() {
|
|
37323
37359
|
let logPath2;
|
|
@@ -37334,7 +37370,7 @@ function createReviewLogSink() {
|
|
|
37334
37370
|
},
|
|
37335
37371
|
attach(reviewDir) {
|
|
37336
37372
|
mkdirSync24(reviewDir, { recursive: true });
|
|
37337
|
-
logPath2 =
|
|
37373
|
+
logPath2 = join83(reviewDir, LOG_FILE);
|
|
37338
37374
|
const lines2 = [
|
|
37339
37375
|
"",
|
|
37340
37376
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -38033,7 +38069,7 @@ async function runClaudeReviewer(spec) {
|
|
|
38033
38069
|
}
|
|
38034
38070
|
|
|
38035
38071
|
// src/commands/review/runCodexReviewer.ts
|
|
38036
|
-
import { existsSync as
|
|
38072
|
+
import { existsSync as existsSync66, unlinkSync as unlinkSync16 } from "fs";
|
|
38037
38073
|
|
|
38038
38074
|
// src/commands/review/parseCodexUsage.ts
|
|
38039
38075
|
function parseCodexUsage(usage) {
|
|
@@ -38122,7 +38158,7 @@ async function runCodexReviewer(spec) {
|
|
|
38122
38158
|
...override.args.length > 0 ? { env: override.env } : {},
|
|
38123
38159
|
onLine
|
|
38124
38160
|
});
|
|
38125
|
-
if (result.exitCode !== 0 &&
|
|
38161
|
+
if (result.exitCode !== 0 && existsSync66(spec.outputPath)) {
|
|
38126
38162
|
unlinkSync16(spec.outputPath);
|
|
38127
38163
|
}
|
|
38128
38164
|
const finalised = finaliseReviewerRun(
|
|
@@ -38213,10 +38249,10 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
38213
38249
|
}
|
|
38214
38250
|
|
|
38215
38251
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
38216
|
-
import { existsSync as
|
|
38252
|
+
import { existsSync as existsSync67, unlinkSync as unlinkSync17 } from "fs";
|
|
38217
38253
|
|
|
38218
38254
|
// src/commands/review/synthesise.ts
|
|
38219
|
-
import { readFileSync as
|
|
38255
|
+
import { readFileSync as readFileSync51 } from "fs";
|
|
38220
38256
|
|
|
38221
38257
|
// src/commands/review/buildSynthesisStdin.ts
|
|
38222
38258
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -38285,7 +38321,7 @@ Files:
|
|
|
38285
38321
|
|
|
38286
38322
|
// src/commands/review/synthesise.ts
|
|
38287
38323
|
function printSummary2(synthesisPath) {
|
|
38288
|
-
const markdown =
|
|
38324
|
+
const markdown = readFileSync51(synthesisPath, "utf8");
|
|
38289
38325
|
console.log("");
|
|
38290
38326
|
console.log(buildReviewSummary(markdown));
|
|
38291
38327
|
console.log("");
|
|
@@ -38320,7 +38356,7 @@ async function synthesise(paths, options2) {
|
|
|
38320
38356
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
38321
38357
|
async function synthesiseAfterReviewers(input) {
|
|
38322
38358
|
const { paths, failures } = input;
|
|
38323
|
-
if (input.anyFresh &&
|
|
38359
|
+
if (input.anyFresh && existsSync67(paths.synthesisPath)) {
|
|
38324
38360
|
unlinkSync17(paths.synthesisPath);
|
|
38325
38361
|
}
|
|
38326
38362
|
const synthesisResult = await synthesise(paths, {
|
|
@@ -38549,9 +38585,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
38549
38585
|
|
|
38550
38586
|
// src/commands/review/buildReviewPaths.ts
|
|
38551
38587
|
import { homedir as homedir25 } from "os";
|
|
38552
|
-
import { basename as basename25, join as
|
|
38588
|
+
import { basename as basename25, join as join84 } from "path";
|
|
38553
38589
|
function buildReviewPaths(repoRoot2, key) {
|
|
38554
|
-
const reviewDir =
|
|
38590
|
+
const reviewDir = join84(
|
|
38555
38591
|
homedir25(),
|
|
38556
38592
|
".assist",
|
|
38557
38593
|
"reviews",
|
|
@@ -38560,10 +38596,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
38560
38596
|
);
|
|
38561
38597
|
return {
|
|
38562
38598
|
reviewDir,
|
|
38563
|
-
requestPath:
|
|
38564
|
-
claudePath:
|
|
38565
|
-
codexPath:
|
|
38566
|
-
synthesisPath:
|
|
38599
|
+
requestPath: join84(reviewDir, "request.md"),
|
|
38600
|
+
claudePath: join84(reviewDir, "claude.md"),
|
|
38601
|
+
codexPath: join84(reviewDir, "codex.md"),
|
|
38602
|
+
synthesisPath: join84(reviewDir, "synthesis.md")
|
|
38567
38603
|
};
|
|
38568
38604
|
}
|
|
38569
38605
|
|
|
@@ -38601,10 +38637,10 @@ function fetchExistingComments() {
|
|
|
38601
38637
|
}
|
|
38602
38638
|
|
|
38603
38639
|
// src/commands/review/prepareReviewDir.ts
|
|
38604
|
-
import { existsSync as
|
|
38640
|
+
import { existsSync as existsSync68, mkdirSync as mkdirSync25, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
|
|
38605
38641
|
function clearReviewFiles(paths) {
|
|
38606
38642
|
for (const path109 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
38607
|
-
if (
|
|
38643
|
+
if (existsSync68(path109)) unlinkSync18(path109);
|
|
38608
38644
|
}
|
|
38609
38645
|
}
|
|
38610
38646
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -38727,7 +38763,7 @@ function gatherChangedContext() {
|
|
|
38727
38763
|
}
|
|
38728
38764
|
|
|
38729
38765
|
// src/commands/review/postReviewToPr.ts
|
|
38730
|
-
import { readFileSync as
|
|
38766
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
38731
38767
|
|
|
38732
38768
|
// src/commands/review/chainAddressComments.ts
|
|
38733
38769
|
function chainAddressComments(prNumber, announce) {
|
|
@@ -38909,7 +38945,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
38909
38945
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
38910
38946
|
}
|
|
38911
38947
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
38912
|
-
const markdown =
|
|
38948
|
+
const markdown = readFileSync52(synthesisPath, "utf8");
|
|
38913
38949
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
38914
38950
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
38915
38951
|
if (inDiff.length === 0 && carried.length === 0)
|
|
@@ -39255,7 +39291,7 @@ function registerReview(program2) {
|
|
|
39255
39291
|
}
|
|
39256
39292
|
|
|
39257
39293
|
// src/commands/rules/addRule.ts
|
|
39258
|
-
import { existsSync as
|
|
39294
|
+
import { existsSync as existsSync71, readFileSync as readFileSync56, writeFileSync as writeFileSync42 } from "fs";
|
|
39259
39295
|
import path88 from "path";
|
|
39260
39296
|
import chalk244 from "chalk";
|
|
39261
39297
|
|
|
@@ -39280,7 +39316,7 @@ function insertRuleBullet(content, rule) {
|
|
|
39280
39316
|
}
|
|
39281
39317
|
|
|
39282
39318
|
// src/commands/rules/nextRuleCode.ts
|
|
39283
|
-
import { readFileSync as
|
|
39319
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
39284
39320
|
|
|
39285
39321
|
// src/commands/rules/findClaudeFiles.ts
|
|
39286
39322
|
import { readdirSync as readdirSync13 } from "fs";
|
|
@@ -39304,7 +39340,7 @@ function findClaudeFiles(dir) {
|
|
|
39304
39340
|
var CODE_PREFIX = "R";
|
|
39305
39341
|
function nextRuleCode(root2) {
|
|
39306
39342
|
const numbers = findClaudeFiles(root2).flatMap(
|
|
39307
|
-
(file) => parseRulesSection(
|
|
39343
|
+
(file) => parseRulesSection(readFileSync53(file, "utf8")).map(
|
|
39308
39344
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
39309
39345
|
)
|
|
39310
39346
|
);
|
|
@@ -39312,7 +39348,7 @@ function nextRuleCode(root2) {
|
|
|
39312
39348
|
}
|
|
39313
39349
|
|
|
39314
39350
|
// src/commands/rules/resolveRuleScope.ts
|
|
39315
|
-
import { existsSync as
|
|
39351
|
+
import { existsSync as existsSync69 } from "fs";
|
|
39316
39352
|
import path85 from "path";
|
|
39317
39353
|
function resolveRuleScope(target) {
|
|
39318
39354
|
const resolved = path85.resolve(target);
|
|
@@ -39322,7 +39358,7 @@ function resolveRuleScope(target) {
|
|
|
39322
39358
|
let current = startDir;
|
|
39323
39359
|
while (true) {
|
|
39324
39360
|
const candidate = path85.join(current, "CLAUDE.md");
|
|
39325
|
-
if (
|
|
39361
|
+
if (existsSync69(candidate)) return candidate;
|
|
39326
39362
|
if (current === root2 || current === path85.dirname(current)) break;
|
|
39327
39363
|
current = path85.dirname(current);
|
|
39328
39364
|
}
|
|
@@ -39330,15 +39366,15 @@ function resolveRuleScope(target) {
|
|
|
39330
39366
|
}
|
|
39331
39367
|
|
|
39332
39368
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
39333
|
-
import { existsSync as
|
|
39369
|
+
import { existsSync as existsSync70, readFileSync as readFileSync55, writeFileSync as writeFileSync41 } from "fs";
|
|
39334
39370
|
import path87 from "path";
|
|
39335
39371
|
|
|
39336
39372
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
39337
|
-
import { readFileSync as
|
|
39373
|
+
import { readFileSync as readFileSync54 } from "fs";
|
|
39338
39374
|
import path86 from "path";
|
|
39339
39375
|
function scopedRuleDirectories(root2) {
|
|
39340
39376
|
return findClaudeFiles(root2).filter(
|
|
39341
|
-
(file) => path86.dirname(file) !== root2 && parseRulesSection(
|
|
39377
|
+
(file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync54(file, "utf8")).length > 0
|
|
39342
39378
|
).map(
|
|
39343
39379
|
(file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
|
|
39344
39380
|
).sort();
|
|
@@ -39380,7 +39416,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
39380
39416
|
function updateScopedRulesIndex(root2) {
|
|
39381
39417
|
const directories = scopedRuleDirectories(root2);
|
|
39382
39418
|
const rootFile = path87.join(root2, "CLAUDE.md");
|
|
39383
|
-
const before =
|
|
39419
|
+
const before = existsSync70(rootFile) ? readFileSync55(rootFile, "utf8") : "";
|
|
39384
39420
|
const after = upsertScopedRulesPointer(before, directories);
|
|
39385
39421
|
if (after !== before) writeFileSync41(rootFile, after);
|
|
39386
39422
|
return directories;
|
|
@@ -39388,7 +39424,7 @@ function updateScopedRulesIndex(root2) {
|
|
|
39388
39424
|
|
|
39389
39425
|
// src/commands/rules/addRule.ts
|
|
39390
39426
|
function read2(file) {
|
|
39391
|
-
return
|
|
39427
|
+
return existsSync71(file) ? readFileSync56(file, "utf8") : "";
|
|
39392
39428
|
}
|
|
39393
39429
|
function addRule(text18, options2) {
|
|
39394
39430
|
const rule = text18.trim();
|
|
@@ -39923,12 +39959,12 @@ import { mkdirSync as mkdirSync27, writeFileSync as writeFileSync44 } from "fs";
|
|
|
39923
39959
|
import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync43 } from "fs";
|
|
39924
39960
|
|
|
39925
39961
|
// src/commands/slack/readSlackParts.ts
|
|
39926
|
-
import { readFileSync as
|
|
39962
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
39927
39963
|
function readSlackParts(files) {
|
|
39928
39964
|
return files.map((file) => {
|
|
39929
39965
|
let contents;
|
|
39930
39966
|
try {
|
|
39931
|
-
contents =
|
|
39967
|
+
contents = readFileSync57(file, "utf8");
|
|
39932
39968
|
} catch {
|
|
39933
39969
|
console.error(`Error: Part file not found: ${file}`);
|
|
39934
39970
|
process.exit(1);
|
|
@@ -39966,12 +40002,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
39966
40002
|
}
|
|
39967
40003
|
|
|
39968
40004
|
// src/commands/slack/slackWorkingFile.ts
|
|
39969
|
-
import { join as
|
|
40005
|
+
import { join as join85 } from "path";
|
|
39970
40006
|
function slackWorkingFile(channel, partIndex) {
|
|
39971
40007
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
39972
|
-
const dir =
|
|
40008
|
+
const dir = join85(getStoreDir(), "slack");
|
|
39973
40009
|
const name = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
39974
|
-
return { dir, bodyPath:
|
|
40010
|
+
return { dir, bodyPath: join85(dir, `${name}.md`) };
|
|
39975
40011
|
}
|
|
39976
40012
|
|
|
39977
40013
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -40789,7 +40825,7 @@ function registerSync(program2) {
|
|
|
40789
40825
|
}
|
|
40790
40826
|
|
|
40791
40827
|
// src/commands/transcript/clean.ts
|
|
40792
|
-
import { existsSync as
|
|
40828
|
+
import { existsSync as existsSync76 } from "fs";
|
|
40793
40829
|
|
|
40794
40830
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
40795
40831
|
function pad(value, width2) {
|
|
@@ -41039,9 +41075,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
41039
41075
|
}
|
|
41040
41076
|
|
|
41041
41077
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
41042
|
-
import { readFileSync as
|
|
41078
|
+
import { readFileSync as readFileSync62 } from "fs";
|
|
41043
41079
|
function readCleanedCues(inputPath) {
|
|
41044
|
-
return deduplicateCues(parseVtt(
|
|
41080
|
+
return deduplicateCues(parseVtt(readFileSync62(inputPath, "utf8")));
|
|
41045
41081
|
}
|
|
41046
41082
|
|
|
41047
41083
|
// src/commands/transcript/clean.ts
|
|
@@ -41067,7 +41103,7 @@ function clean(file, options2 = {}) {
|
|
|
41067
41103
|
);
|
|
41068
41104
|
process.exit(1);
|
|
41069
41105
|
}
|
|
41070
|
-
if (!
|
|
41106
|
+
if (!existsSync76(file)) {
|
|
41071
41107
|
console.error(`Error: VTT file not found: ${file}`);
|
|
41072
41108
|
process.exit(1);
|
|
41073
41109
|
}
|
|
@@ -41150,21 +41186,21 @@ async function configure() {
|
|
|
41150
41186
|
}
|
|
41151
41187
|
|
|
41152
41188
|
// src/commands/transcript/list.ts
|
|
41153
|
-
import { existsSync as
|
|
41154
|
-
import { join as
|
|
41189
|
+
import { existsSync as existsSync77, readdirSync as readdirSync20, statSync as statSync13 } from "fs";
|
|
41190
|
+
import { join as join97 } from "path";
|
|
41155
41191
|
function list3() {
|
|
41156
41192
|
const { vttDir } = getTranscriptConfig();
|
|
41157
|
-
if (!
|
|
41193
|
+
if (!existsSync77(vttDir)) return;
|
|
41158
41194
|
for (const entry of readdirSync20(vttDir)) {
|
|
41159
41195
|
if (!entry.endsWith(".vtt")) continue;
|
|
41160
|
-
if (statSync13(
|
|
41196
|
+
if (statSync13(join97(vttDir, entry)).isDirectory()) continue;
|
|
41161
41197
|
console.log(entry);
|
|
41162
41198
|
}
|
|
41163
41199
|
}
|
|
41164
41200
|
|
|
41165
41201
|
// src/commands/transcript/move.ts
|
|
41166
|
-
import { existsSync as
|
|
41167
|
-
import { basename as basename29, join as
|
|
41202
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync33, renameSync as renameSync4, writeFileSync as writeFileSync49 } from "fs";
|
|
41203
|
+
import { basename as basename29, join as join98 } from "path";
|
|
41168
41204
|
|
|
41169
41205
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
41170
41206
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -41174,9 +41210,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
41174
41210
|
// src/commands/transcript/move.ts
|
|
41175
41211
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
41176
41212
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
41177
|
-
const processedDir =
|
|
41213
|
+
const processedDir = join98(vttDir, "processed");
|
|
41178
41214
|
mkdirSync33(processedDir, { recursive: true });
|
|
41179
|
-
renameSync4(sourcePath,
|
|
41215
|
+
renameSync4(sourcePath, join98(processedDir, filename));
|
|
41180
41216
|
}
|
|
41181
41217
|
function move(file, options2) {
|
|
41182
41218
|
const { date, client } = options2;
|
|
@@ -41186,25 +41222,25 @@ function move(file, options2) {
|
|
|
41186
41222
|
}
|
|
41187
41223
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
41188
41224
|
const filename = basename29(file);
|
|
41189
|
-
const sourcePath =
|
|
41190
|
-
if (!
|
|
41225
|
+
const sourcePath = join98(vttDir, filename);
|
|
41226
|
+
if (!existsSync78(sourcePath)) {
|
|
41191
41227
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
41192
41228
|
process.exit(1);
|
|
41193
41229
|
}
|
|
41194
41230
|
const base = basename29(filename, ".vtt").replace(/ Transcription$/, "");
|
|
41195
41231
|
const outputName = `${date} ${base}.md`;
|
|
41196
|
-
const formattedDir =
|
|
41232
|
+
const formattedDir = join98(transcriptsDir, client);
|
|
41197
41233
|
mkdirSync33(formattedDir, { recursive: true });
|
|
41198
|
-
const formattedPath =
|
|
41234
|
+
const formattedPath = join98(formattedDir, outputName);
|
|
41199
41235
|
writeFileSync49(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
41200
41236
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
41201
|
-
const summaryPath =
|
|
41237
|
+
const summaryPath = join98(summaryDir, client, outputName);
|
|
41202
41238
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
41203
41239
|
console.log(`Summary target: ${summaryPath}`);
|
|
41204
41240
|
}
|
|
41205
41241
|
|
|
41206
41242
|
// src/commands/transcript/merge.ts
|
|
41207
|
-
import { existsSync as
|
|
41243
|
+
import { existsSync as existsSync79, writeFileSync as writeFileSync50 } from "fs";
|
|
41208
41244
|
import { basename as basename30 } from "path";
|
|
41209
41245
|
|
|
41210
41246
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -41348,7 +41384,7 @@ function widenAudience(passages) {
|
|
|
41348
41384
|
|
|
41349
41385
|
// src/commands/transcript/merge.ts
|
|
41350
41386
|
function readSource3(file) {
|
|
41351
|
-
if (!
|
|
41387
|
+
if (!existsSync79(file)) failTranscript(`VTT file not found: ${file}`);
|
|
41352
41388
|
const cues = readCleanedCues(file);
|
|
41353
41389
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
41354
41390
|
return { path: file, name: basename30(file), cues };
|
|
@@ -41815,7 +41851,7 @@ function configKeys2() {
|
|
|
41815
41851
|
}
|
|
41816
41852
|
|
|
41817
41853
|
// src/commands/verify/forbiddenStrings.ts
|
|
41818
|
-
import { existsSync as
|
|
41854
|
+
import { existsSync as existsSync80, readFileSync as readFileSync63 } from "fs";
|
|
41819
41855
|
|
|
41820
41856
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
41821
41857
|
import { minimatch as minimatch10 } from "minimatch";
|
|
@@ -41856,13 +41892,13 @@ function forbiddenStrings() {
|
|
|
41856
41892
|
const cache6 = /* @__PURE__ */ new Map();
|
|
41857
41893
|
const readJson = (file) => {
|
|
41858
41894
|
if (cache6.has(file)) return cache6.get(file);
|
|
41859
|
-
if (!
|
|
41895
|
+
if (!existsSync80(file)) {
|
|
41860
41896
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
41861
41897
|
process.exit(1);
|
|
41862
41898
|
}
|
|
41863
41899
|
let parsed;
|
|
41864
41900
|
try {
|
|
41865
|
-
parsed = JSON.parse(
|
|
41901
|
+
parsed = JSON.parse(readFileSync63(file, "utf8"));
|
|
41866
41902
|
} catch (error) {
|
|
41867
41903
|
console.log(`Could not parse ${file}: ${error.message}`);
|
|
41868
41904
|
process.exit(1);
|
|
@@ -41888,13 +41924,13 @@ Total: ${violations.length} forbidden string(s).`);
|
|
|
41888
41924
|
}
|
|
41889
41925
|
|
|
41890
41926
|
// src/commands/verify/hardcodedColors.ts
|
|
41891
|
-
import { execFileSync as
|
|
41927
|
+
import { execFileSync as execFileSync28 } from "child_process";
|
|
41892
41928
|
import { minimatch as minimatch11 } from "minimatch";
|
|
41893
41929
|
var pattern = "0x[0-9a-fA-F]{6}|#[0-9a-fA-F]{3,6}";
|
|
41894
41930
|
function hardcodedColors() {
|
|
41895
41931
|
const ignoreGlobs = loadConfig().hardcodedColors?.ignore ?? [];
|
|
41896
41932
|
try {
|
|
41897
|
-
const output =
|
|
41933
|
+
const output = execFileSync28("grep", ["-rEnH", "-f", "-", "src/"], {
|
|
41898
41934
|
encoding: "utf8",
|
|
41899
41935
|
input: `${pattern}
|
|
41900
41936
|
`
|
|
@@ -41934,7 +41970,7 @@ Total: ${lines2.length} hardcoded color(s)`);
|
|
|
41934
41970
|
}
|
|
41935
41971
|
|
|
41936
41972
|
// src/commands/verify/migrations.ts
|
|
41937
|
-
import { readFileSync as
|
|
41973
|
+
import { readFileSync as readFileSync64 } from "fs";
|
|
41938
41974
|
import path104 from "path";
|
|
41939
41975
|
|
|
41940
41976
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
@@ -42099,7 +42135,7 @@ function migrations2() {
|
|
|
42099
42135
|
if (ref) {
|
|
42100
42136
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
42101
42137
|
const current = new Map(
|
|
42102
|
-
files.map((file) => [file,
|
|
42138
|
+
files.map((file) => [file, readFileSync64(path104.join(dir, file), "utf8")])
|
|
42103
42139
|
);
|
|
42104
42140
|
for (const finding of checkAppendOnly(baseline, current)) {
|
|
42105
42141
|
problems.push(
|
|
@@ -42645,7 +42681,7 @@ function resolveParams(params, cliArgs) {
|
|
|
42645
42681
|
}
|
|
42646
42682
|
|
|
42647
42683
|
// src/commands/run/resolveRunCwd.ts
|
|
42648
|
-
import { existsSync as
|
|
42684
|
+
import { existsSync as existsSync81 } from "fs";
|
|
42649
42685
|
import { resolve as resolve28 } from "path";
|
|
42650
42686
|
var MissingRunCwdError = class extends Error {
|
|
42651
42687
|
constructor(runName, cwd) {
|
|
@@ -42658,7 +42694,7 @@ var MissingRunCwdError = class extends Error {
|
|
|
42658
42694
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
42659
42695
|
if (!config.cwd) return void 0;
|
|
42660
42696
|
const cwd = resolve28(baseDir, config.cwd);
|
|
42661
|
-
if (!
|
|
42697
|
+
if (!existsSync81(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
42662
42698
|
return cwd;
|
|
42663
42699
|
}
|
|
42664
42700
|
|
|
@@ -42778,10 +42814,10 @@ ${buildWatchReport(from)}`);
|
|
|
42778
42814
|
}
|
|
42779
42815
|
|
|
42780
42816
|
// src/commands/watch/consumeMarker.ts
|
|
42781
|
-
import { existsSync as
|
|
42817
|
+
import { existsSync as existsSync82, rmSync as rmSync9 } from "fs";
|
|
42782
42818
|
function consumeMarker(path109) {
|
|
42783
42819
|
try {
|
|
42784
|
-
if (!
|
|
42820
|
+
if (!existsSync82(path109)) return false;
|
|
42785
42821
|
rmSync9(path109);
|
|
42786
42822
|
return true;
|
|
42787
42823
|
} catch {
|
|
@@ -43114,9 +43150,9 @@ async function auth() {
|
|
|
43114
43150
|
}
|
|
43115
43151
|
|
|
43116
43152
|
// src/commands/roam/postRoamActivity.ts
|
|
43117
|
-
import { execFileSync as
|
|
43118
|
-
import { readdirSync as readdirSync22, readFileSync as
|
|
43119
|
-
import { join as
|
|
43153
|
+
import { execFileSync as execFileSync29 } from "child_process";
|
|
43154
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync65, statSync as statSync14 } from "fs";
|
|
43155
|
+
import { join as join99 } from "path";
|
|
43120
43156
|
function findPortFile(roamDir) {
|
|
43121
43157
|
let entries;
|
|
43122
43158
|
try {
|
|
@@ -43125,7 +43161,7 @@ function findPortFile(roamDir) {
|
|
|
43125
43161
|
return void 0;
|
|
43126
43162
|
}
|
|
43127
43163
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
43128
|
-
const path109 =
|
|
43164
|
+
const path109 = join99(roamDir, name);
|
|
43129
43165
|
try {
|
|
43130
43166
|
return { path: path109, mtimeMs: statSync14(path109).mtimeMs };
|
|
43131
43167
|
} catch {
|
|
@@ -43142,18 +43178,18 @@ var PID_BY_APP = {
|
|
|
43142
43178
|
function postRoamActivity(app, event) {
|
|
43143
43179
|
const appData = process.env.APPDATA;
|
|
43144
43180
|
if (!appData) return;
|
|
43145
|
-
const portFile = findPortFile(
|
|
43181
|
+
const portFile = findPortFile(join99(appData, "Roam"));
|
|
43146
43182
|
if (!portFile) return;
|
|
43147
43183
|
let port;
|
|
43148
43184
|
try {
|
|
43149
|
-
port =
|
|
43185
|
+
port = readFileSync65(portFile, "utf8").trim();
|
|
43150
43186
|
} catch {
|
|
43151
43187
|
return;
|
|
43152
43188
|
}
|
|
43153
43189
|
const pid = PID_BY_APP[app] ?? 99999;
|
|
43154
43190
|
const url = `http://127.0.0.1:${port}/api/v1/activity/${app}/${event}?pid=${pid}`;
|
|
43155
43191
|
try {
|
|
43156
|
-
|
|
43192
|
+
execFileSync29("curl", ["-sf", "--max-time", "0.2", "-X", "POST", url], {
|
|
43157
43193
|
stdio: "ignore"
|
|
43158
43194
|
});
|
|
43159
43195
|
} catch {
|
|
@@ -43328,7 +43364,7 @@ function link2() {
|
|
|
43328
43364
|
|
|
43329
43365
|
// src/commands/run/add.ts
|
|
43330
43366
|
import { mkdirSync as mkdirSync34, writeFileSync as writeFileSync52 } from "fs";
|
|
43331
|
-
import { join as
|
|
43367
|
+
import { join as join100 } from "path";
|
|
43332
43368
|
|
|
43333
43369
|
// src/commands/run/editRepoRunList.ts
|
|
43334
43370
|
async function editRepoRunList(repoName, cwd, edit2) {
|
|
@@ -43358,6 +43394,12 @@ function addRepoRunConfig(entry, repoName, cwd = process.cwd()) {
|
|
|
43358
43394
|
});
|
|
43359
43395
|
}
|
|
43360
43396
|
|
|
43397
|
+
// src/commands/run/extractFlag.ts
|
|
43398
|
+
function extractFlag(args, flag) {
|
|
43399
|
+
const remaining = args.filter((arg) => arg !== flag);
|
|
43400
|
+
return { present: remaining.length < args.length, remaining };
|
|
43401
|
+
}
|
|
43402
|
+
|
|
43361
43403
|
// src/commands/run/extractOptionalValueFlag.ts
|
|
43362
43404
|
function extractOptionalValueFlag(args, flag) {
|
|
43363
43405
|
const index2 = args.indexOf(flag);
|
|
@@ -43402,6 +43444,32 @@ function parseEnvPairs(pairs) {
|
|
|
43402
43444
|
return env;
|
|
43403
43445
|
}
|
|
43404
43446
|
|
|
43447
|
+
// src/commands/run/parseParamSpecs.ts
|
|
43448
|
+
function fail7(spec) {
|
|
43449
|
+
console.error(
|
|
43450
|
+
`--param must be <name>, <name>! or <name>=<default>, got "${spec}"`
|
|
43451
|
+
);
|
|
43452
|
+
process.exit(1);
|
|
43453
|
+
}
|
|
43454
|
+
function parseParamSpec(spec) {
|
|
43455
|
+
const eq48 = spec.indexOf("=");
|
|
43456
|
+
const name = eq48 === -1 ? spec : spec.slice(0, eq48);
|
|
43457
|
+
if (eq48 !== -1) {
|
|
43458
|
+
if (eq48 === 0 || name.endsWith("!")) fail7(spec);
|
|
43459
|
+
return { name, default: spec.slice(eq48 + 1) };
|
|
43460
|
+
}
|
|
43461
|
+
if (name.endsWith("!")) {
|
|
43462
|
+
if (name.length === 1) fail7(spec);
|
|
43463
|
+
return { name: name.slice(0, -1), required: true };
|
|
43464
|
+
}
|
|
43465
|
+
if (name.length === 0) fail7(spec);
|
|
43466
|
+
return { name };
|
|
43467
|
+
}
|
|
43468
|
+
function parseParamSpecs(specs) {
|
|
43469
|
+
if (specs.length === 0) return void 0;
|
|
43470
|
+
return specs.map(parseParamSpec);
|
|
43471
|
+
}
|
|
43472
|
+
|
|
43405
43473
|
// src/commands/run/requireParsedArgs.ts
|
|
43406
43474
|
function findAddIndex() {
|
|
43407
43475
|
const addIndex = process.argv.indexOf("add");
|
|
@@ -43420,7 +43488,11 @@ function parsePort(raw) {
|
|
|
43420
43488
|
function extractAddArgs(addIndex) {
|
|
43421
43489
|
const rawArgs = process.argv.slice(addIndex + 3);
|
|
43422
43490
|
const env = extractRepeatedOption(rawArgs, "--env");
|
|
43423
|
-
const
|
|
43491
|
+
const pre = extractRepeatedOption(env.remaining, "--pre");
|
|
43492
|
+
const param = extractRepeatedOption(pre.remaining, "--param");
|
|
43493
|
+
const quiet = extractFlag(param.remaining, "--quiet");
|
|
43494
|
+
const filter = extractOption(quiet.remaining, "--filter");
|
|
43495
|
+
const cwd = extractOption(filter.remaining, "--cwd");
|
|
43424
43496
|
const port = extractOption(cwd.remaining, "--port");
|
|
43425
43497
|
const server = extractOptionalValueFlag(port.remaining, "--server");
|
|
43426
43498
|
const repo = extractOptionalValueFlag(server.remaining, "--repo");
|
|
@@ -43432,7 +43504,11 @@ function extractAddArgs(addIndex) {
|
|
|
43432
43504
|
cwd: cwd.value,
|
|
43433
43505
|
server: server.value,
|
|
43434
43506
|
port: parsePort(port.value),
|
|
43435
|
-
env: parseEnvPairs(env.values)
|
|
43507
|
+
env: parseEnvPairs(env.values),
|
|
43508
|
+
pre: pre.values.length > 0 ? pre.values : void 0,
|
|
43509
|
+
filter: filter.value,
|
|
43510
|
+
quiet: quiet.present || void 0,
|
|
43511
|
+
params: parseParamSpecs(param.values)
|
|
43436
43512
|
},
|
|
43437
43513
|
repo: repo.value
|
|
43438
43514
|
};
|
|
@@ -43459,7 +43535,7 @@ function saveProjectRunConfig(entry) {
|
|
|
43459
43535
|
saveConfig(config);
|
|
43460
43536
|
}
|
|
43461
43537
|
function createCommandFile(name) {
|
|
43462
|
-
const dir =
|
|
43538
|
+
const dir = join100(".claude", "commands");
|
|
43463
43539
|
mkdirSync34(dir, { recursive: true });
|
|
43464
43540
|
const content = `---
|
|
43465
43541
|
description: Run ${name}
|
|
@@ -43467,7 +43543,7 @@ description: Run ${name}
|
|
|
43467
43543
|
|
|
43468
43544
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
43469
43545
|
`;
|
|
43470
|
-
const filePath =
|
|
43546
|
+
const filePath = join100(dir, `${name}.md`);
|
|
43471
43547
|
writeFileSync52(filePath, content);
|
|
43472
43548
|
console.log(`Created command file: ${filePath}`);
|
|
43473
43549
|
}
|
|
@@ -43507,19 +43583,19 @@ var properties = [
|
|
|
43507
43583
|
["port", "--port <port>", "display-only port on the serving card"],
|
|
43508
43584
|
[
|
|
43509
43585
|
"pre",
|
|
43510
|
-
"
|
|
43511
|
-
"shell
|
|
43586
|
+
"--pre <command>",
|
|
43587
|
+
"shell command run before this one (repeatable, runs in order)"
|
|
43512
43588
|
],
|
|
43513
43589
|
[
|
|
43514
43590
|
"filter",
|
|
43515
|
-
"
|
|
43591
|
+
"--filter <glob>",
|
|
43516
43592
|
"verify: entries only run when a changed file matches this glob"
|
|
43517
43593
|
],
|
|
43518
|
-
["quiet", "
|
|
43594
|
+
["quiet", "--quiet", "suppress the command's output unless it fails"],
|
|
43519
43595
|
[
|
|
43520
43596
|
"params",
|
|
43521
|
-
"
|
|
43522
|
-
"positional
|
|
43597
|
+
"--param <spec>",
|
|
43598
|
+
"positional param filled from assist run args (repeatable, see below)"
|
|
43523
43599
|
]
|
|
43524
43600
|
];
|
|
43525
43601
|
var width = Math.max(...properties.map(([key]) => key.length));
|
|
@@ -43531,17 +43607,19 @@ var runAddHelpText = [
|
|
|
43531
43607
|
([key, flag, note]) => ` ${key.padEnd(width)} ${flag.padEnd(flagWidth)} ${note}`
|
|
43532
43608
|
),
|
|
43533
43609
|
"",
|
|
43534
|
-
'The command is spawned without a shell, so "FOO=bar cmd", "&&", pipes and redirects do not work; use --env for environment variables and pre for setup steps.',
|
|
43610
|
+
'The command is spawned without a shell, so "FOO=bar cmd", "&&", pipes and redirects do not work; use --env for environment variables and --pre for setup steps (--pre commands do run in a shell).',
|
|
43535
43611
|
"",
|
|
43536
43612
|
'Options go after <command>. --server and --repo take the next argument as their value unless it starts with "-", so put them last or before another option:',
|
|
43537
43613
|
" assist run add dev npm run dev --env PORT=3000 --server --port 3000 --repo",
|
|
43614
|
+
"These flags are taken from anywhere after <command>; to pass one to the command itself, quote the whole command:",
|
|
43615
|
+
' assist run add build "pnpm --filter web build"',
|
|
43538
43616
|
"",
|
|
43539
|
-
"
|
|
43540
|
-
"
|
|
43541
|
-
|
|
43542
|
-
"
|
|
43543
|
-
|
|
43544
|
-
"
|
|
43617
|
+
"--param <spec> appends params in order; each fills the next arg given to assist run:",
|
|
43618
|
+
" <name> optional, omitted when not given",
|
|
43619
|
+
" <name>! required, assist run fails when it is missing",
|
|
43620
|
+
" <name>=<default> used when not given",
|
|
43621
|
+
' assist run add deploy ./deploy.sh --param env! --param tag=latest # assist run deploy prod \u2192 "./deploy.sh prod latest"',
|
|
43622
|
+
"A param's description is set in config."
|
|
43545
43623
|
].join("\n");
|
|
43546
43624
|
|
|
43547
43625
|
// src/commands/run/registerRunAdd.ts
|
|
@@ -43557,6 +43635,12 @@ function registerRunAdd(runCommand) {
|
|
|
43557
43635
|
).option("--port <port>", "Display-only port shown on the serving card").option(
|
|
43558
43636
|
"--env <KEY=VALUE>",
|
|
43559
43637
|
"Environment variable for the command (repeatable)"
|
|
43638
|
+
).option("--pre <command>", "Shell command run first (repeatable)").option(
|
|
43639
|
+
"--filter <glob>",
|
|
43640
|
+
"Only run a verify: entry when a changed file matches"
|
|
43641
|
+
).option("--quiet", "Suppress output unless the command fails").option(
|
|
43642
|
+
"--param <spec>",
|
|
43643
|
+
"Positional param: <name>, <name>! (required) or <name>=<default> (repeatable)"
|
|
43560
43644
|
).option(
|
|
43561
43645
|
"--repo [name]",
|
|
43562
43646
|
"Write to a repo's override in the shared db, seen by every node, instead of assist.yml (defaults to the current repo; no command file is created)"
|
|
@@ -43564,8 +43648,8 @@ function registerRunAdd(runCommand) {
|
|
|
43564
43648
|
}
|
|
43565
43649
|
|
|
43566
43650
|
// src/commands/run/remove.ts
|
|
43567
|
-
import { existsSync as
|
|
43568
|
-
import { join as
|
|
43651
|
+
import { existsSync as existsSync83, unlinkSync as unlinkSync19 } from "fs";
|
|
43652
|
+
import { join as join101 } from "path";
|
|
43569
43653
|
|
|
43570
43654
|
// src/commands/run/removeRepoRunConfig.ts
|
|
43571
43655
|
function isNamed(entry, name) {
|
|
@@ -43583,8 +43667,8 @@ function removeRepoRunConfig(name, repoName, cwd = process.cwd()) {
|
|
|
43583
43667
|
|
|
43584
43668
|
// src/commands/run/remove.ts
|
|
43585
43669
|
function deleteCommandFile(name) {
|
|
43586
|
-
const filePath =
|
|
43587
|
-
if (
|
|
43670
|
+
const filePath = join101(".claude", "commands", `${name}.md`);
|
|
43671
|
+
if (existsSync83(filePath)) {
|
|
43588
43672
|
unlinkSync19(filePath);
|
|
43589
43673
|
console.log(`Deleted command file: ${filePath}`);
|
|
43590
43674
|
}
|
|
@@ -43653,11 +43737,11 @@ function formatLink(link3) {
|
|
|
43653
43737
|
}
|
|
43654
43738
|
|
|
43655
43739
|
// src/commands/sessions/daemon/listDaemonPids.ts
|
|
43656
|
-
import { execFileSync as
|
|
43740
|
+
import { execFileSync as execFileSync30 } from "child_process";
|
|
43657
43741
|
function listDaemonPids() {
|
|
43658
43742
|
if (process.platform === "win32") return [];
|
|
43659
43743
|
try {
|
|
43660
|
-
const out =
|
|
43744
|
+
const out = execFileSync30("ps", ["-eo", "pid=,args="], {
|
|
43661
43745
|
encoding: "utf8"
|
|
43662
43746
|
});
|
|
43663
43747
|
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));
|
|
@@ -43703,11 +43787,11 @@ function applyLine(result, pending, line) {
|
|
|
43703
43787
|
}
|
|
43704
43788
|
|
|
43705
43789
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
43706
|
-
import { readFileSync as
|
|
43790
|
+
import { readFileSync as readFileSync66 } from "fs";
|
|
43707
43791
|
function readDaemonPidFile() {
|
|
43708
43792
|
try {
|
|
43709
43793
|
const pid = Number.parseInt(
|
|
43710
|
-
|
|
43794
|
+
readFileSync66(daemonPaths.pid, "utf8").trim(),
|
|
43711
43795
|
10
|
|
43712
43796
|
);
|
|
43713
43797
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -44023,12 +44107,12 @@ function toSessionRunInfo({
|
|
|
44023
44107
|
}
|
|
44024
44108
|
|
|
44025
44109
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
44026
|
-
import { existsSync as
|
|
44110
|
+
import { existsSync as existsSync84 } from "fs";
|
|
44027
44111
|
function joinRefusal(session) {
|
|
44028
44112
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
44029
44113
|
if (session.closing === true) return "the session is closing";
|
|
44030
44114
|
if (!session.cwd) return "the session has no working directory";
|
|
44031
|
-
if (!
|
|
44115
|
+
if (!existsSync84(session.cwd))
|
|
44032
44116
|
return "the session's workspace no longer exists";
|
|
44033
44117
|
return void 0;
|
|
44034
44118
|
}
|
|
@@ -44177,7 +44261,7 @@ function sendResizeSnapshot(s, send) {
|
|
|
44177
44261
|
}
|
|
44178
44262
|
|
|
44179
44263
|
// src/commands/sessions/daemon/viewerSize.ts
|
|
44180
|
-
import { readFileSync as
|
|
44264
|
+
import { readFileSync as readFileSync67, writeFileSync as writeFileSync53 } from "fs";
|
|
44181
44265
|
var DEFAULT_SIZE = { cols: 120, rows: 30 };
|
|
44182
44266
|
var remembered;
|
|
44183
44267
|
function rememberViewerSize(cols, rows) {
|
|
@@ -44199,7 +44283,7 @@ function viewerSize() {
|
|
|
44199
44283
|
function readSavedSize() {
|
|
44200
44284
|
try {
|
|
44201
44285
|
const { cols, rows } = JSON.parse(
|
|
44202
|
-
|
|
44286
|
+
readFileSync67(daemonPaths.viewerSize, "utf8")
|
|
44203
44287
|
);
|
|
44204
44288
|
if (typeof cols === "number" && typeof rows === "number" && cols > 0)
|
|
44205
44289
|
return { cols, rows };
|
|
@@ -44494,11 +44578,11 @@ function sessionBase(id, status2) {
|
|
|
44494
44578
|
}
|
|
44495
44579
|
|
|
44496
44580
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
44497
|
-
import { existsSync as
|
|
44581
|
+
import { existsSync as existsSync86 } from "fs";
|
|
44498
44582
|
import * as pty from "node-pty";
|
|
44499
44583
|
|
|
44500
44584
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
44501
|
-
import { chmodSync, existsSync as
|
|
44585
|
+
import { chmodSync, existsSync as existsSync85, statSync as statSync15 } from "fs";
|
|
44502
44586
|
import { createRequire as createRequire3 } from "module";
|
|
44503
44587
|
import path105 from "path";
|
|
44504
44588
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -44513,7 +44597,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
44513
44597
|
`${process.platform}-${process.arch}`,
|
|
44514
44598
|
"spawn-helper"
|
|
44515
44599
|
);
|
|
44516
|
-
if (!
|
|
44600
|
+
if (!existsSync85(helper)) return;
|
|
44517
44601
|
const mode = statSync15(helper).mode;
|
|
44518
44602
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
44519
44603
|
}
|
|
@@ -44569,7 +44653,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
44569
44653
|
});
|
|
44570
44654
|
}
|
|
44571
44655
|
function refuseMissingCwd(cwd, sessionId) {
|
|
44572
|
-
if (!cwd ||
|
|
44656
|
+
if (!cwd || existsSync86(cwd)) return;
|
|
44573
44657
|
daemonLog(
|
|
44574
44658
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
44575
44659
|
);
|
|
@@ -44739,7 +44823,7 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
|
44739
44823
|
}
|
|
44740
44824
|
|
|
44741
44825
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
|
|
44742
|
-
import { existsSync as
|
|
44826
|
+
import { existsSync as existsSync87, rmSync as rmSync10, writeFileSync as writeFileSync54 } from "fs";
|
|
44743
44827
|
var paused;
|
|
44744
44828
|
var wake;
|
|
44745
44829
|
function persist2(value) {
|
|
@@ -44751,7 +44835,7 @@ function persist2(value) {
|
|
|
44751
44835
|
}
|
|
44752
44836
|
var autoUpdateControl = {
|
|
44753
44837
|
paused: () => {
|
|
44754
|
-
paused ??=
|
|
44838
|
+
paused ??= existsSync87(daemonPaths.autoUpdatePaused);
|
|
44755
44839
|
return paused;
|
|
44756
44840
|
},
|
|
44757
44841
|
setPaused: (value) => {
|
|
@@ -44869,14 +44953,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
44869
44953
|
}
|
|
44870
44954
|
|
|
44871
44955
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
44872
|
-
import { readFileSync as
|
|
44956
|
+
import { readFileSync as readFileSync69, writeFileSync as writeFileSync55 } from "fs";
|
|
44873
44957
|
var KEEP_TAIL = 256 * 1024;
|
|
44874
44958
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
44875
44959
|
function trimWatcherLog(cwd) {
|
|
44876
44960
|
const path109 = watcherLogPath(cwd);
|
|
44877
44961
|
let log2;
|
|
44878
44962
|
try {
|
|
44879
|
-
log2 =
|
|
44963
|
+
log2 = readFileSync69(path109, "utf8");
|
|
44880
44964
|
} catch {
|
|
44881
44965
|
return;
|
|
44882
44966
|
}
|
|
@@ -45189,17 +45273,17 @@ function setStatus2(session, newStatus) {
|
|
|
45189
45273
|
}
|
|
45190
45274
|
|
|
45191
45275
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
45192
|
-
import { existsSync as
|
|
45276
|
+
import { existsSync as existsSync89 } from "fs";
|
|
45193
45277
|
import { basename as basename32 } from "path";
|
|
45194
45278
|
|
|
45195
45279
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
45196
|
-
import { existsSync as
|
|
45197
|
-
import { join as
|
|
45280
|
+
import { existsSync as existsSync88 } from "fs";
|
|
45281
|
+
import { join as join104 } from "path";
|
|
45198
45282
|
|
|
45199
45283
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
45200
45284
|
import { statSync as statSync16 } from "fs";
|
|
45201
45285
|
import { rm as rm3 } from "fs/promises";
|
|
45202
|
-
import { join as
|
|
45286
|
+
import { join as join103 } from "path";
|
|
45203
45287
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
45204
45288
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
45205
45289
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -45227,7 +45311,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
45227
45311
|
return { removed: true };
|
|
45228
45312
|
}
|
|
45229
45313
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
45230
|
-
return statSync16(
|
|
45314
|
+
return statSync16(join103(worktreePath, ".git"), {
|
|
45231
45315
|
throwIfNoEntry: false
|
|
45232
45316
|
})?.isDirectory() === true;
|
|
45233
45317
|
}
|
|
@@ -45263,7 +45347,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
45263
45347
|
);
|
|
45264
45348
|
}
|
|
45265
45349
|
function strandedReason(worktreePath, cause) {
|
|
45266
|
-
if (!
|
|
45350
|
+
if (!existsSync88(join104(worktreePath, ".git")))
|
|
45267
45351
|
return "its .git link is already gone";
|
|
45268
45352
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
45269
45353
|
return "git no longer recognises it as a working tree";
|
|
@@ -45315,7 +45399,7 @@ function reason3(error) {
|
|
|
45315
45399
|
|
|
45316
45400
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
45317
45401
|
async function reapWorktree(worktreePath, force = false) {
|
|
45318
|
-
if (!
|
|
45402
|
+
if (!existsSync89(worktreePath)) {
|
|
45319
45403
|
forgetWorktree(worktreePath);
|
|
45320
45404
|
daemonLog(
|
|
45321
45405
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -45340,7 +45424,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
45340
45424
|
}
|
|
45341
45425
|
function owningClone(worktreePath) {
|
|
45342
45426
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
45343
|
-
if (recorded &&
|
|
45427
|
+
if (recorded && existsSync89(recorded)) return recorded;
|
|
45344
45428
|
const detected = mainWorktree(worktreePath);
|
|
45345
45429
|
if (detected) return detected;
|
|
45346
45430
|
daemonLog(
|
|
@@ -45541,12 +45625,12 @@ async function closeBlockReason(sessionId, tree) {
|
|
|
45541
45625
|
}
|
|
45542
45626
|
|
|
45543
45627
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
45544
|
-
import { existsSync as
|
|
45628
|
+
import { existsSync as existsSync90, watch } from "fs";
|
|
45545
45629
|
var DEBOUNCE_MS = 500;
|
|
45546
45630
|
var POLL_MS3 = 3e4;
|
|
45547
45631
|
function watchGitState(cwd, onChange) {
|
|
45548
45632
|
const common = gitCommonDir(cwd);
|
|
45549
|
-
if (!common || !
|
|
45633
|
+
if (!common || !existsSync90(common)) return void 0;
|
|
45550
45634
|
const watchers = [
|
|
45551
45635
|
watchGitDir(common, onChange),
|
|
45552
45636
|
pollGitState(cwd, onChange)
|
|
@@ -46194,10 +46278,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
46194
46278
|
}
|
|
46195
46279
|
|
|
46196
46280
|
// src/commands/sessions/daemon/exitReason.ts
|
|
46197
|
-
import { existsSync as
|
|
46281
|
+
import { existsSync as existsSync91 } from "fs";
|
|
46198
46282
|
import { resolve as resolve29 } from "path";
|
|
46199
46283
|
function exitDetail(session) {
|
|
46200
|
-
if (session.cwd && !
|
|
46284
|
+
if (session.cwd && !existsSync91(session.cwd))
|
|
46201
46285
|
return `working directory ${session.cwd} no longer exists`;
|
|
46202
46286
|
return missingRunConfigCwd(session);
|
|
46203
46287
|
}
|
|
@@ -46211,7 +46295,7 @@ function missingRunConfigCwd(session) {
|
|
|
46211
46295
|
const config = resolveRunConfig(session.runName, dir);
|
|
46212
46296
|
if (!config?.cwd) return void 0;
|
|
46213
46297
|
const configured = resolve29(runConfigBaseDirFrom(dir), config.cwd);
|
|
46214
|
-
if (
|
|
46298
|
+
if (existsSync91(configured)) return void 0;
|
|
46215
46299
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
46216
46300
|
}
|
|
46217
46301
|
|
|
@@ -46259,7 +46343,7 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
|
46259
46343
|
}
|
|
46260
46344
|
|
|
46261
46345
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
46262
|
-
import { existsSync as
|
|
46346
|
+
import { existsSync as existsSync92, mkdirSync as mkdirSync36, watch as watch2 } from "fs";
|
|
46263
46347
|
import { dirname as dirname44 } from "path";
|
|
46264
46348
|
|
|
46265
46349
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -46345,7 +46429,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
46345
46429
|
if (timer) clearTimeout(timer);
|
|
46346
46430
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
46347
46431
|
});
|
|
46348
|
-
if (
|
|
46432
|
+
if (existsSync92(path109)) read3();
|
|
46349
46433
|
}
|
|
46350
46434
|
function refreshActivity(session) {
|
|
46351
46435
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -47616,7 +47700,7 @@ function releaseClient(client, clients, prPreview, verify) {
|
|
|
47616
47700
|
}
|
|
47617
47701
|
|
|
47618
47702
|
// src/commands/sessions/daemon/findPortHolderPid.ts
|
|
47619
|
-
import { execFileSync as
|
|
47703
|
+
import { execFileSync as execFileSync31 } from "child_process";
|
|
47620
47704
|
var PROBE_TIMEOUT_MS = 3e3;
|
|
47621
47705
|
function findPortHolderPid(port) {
|
|
47622
47706
|
try {
|
|
@@ -47626,7 +47710,7 @@ function findPortHolderPid(port) {
|
|
|
47626
47710
|
}
|
|
47627
47711
|
}
|
|
47628
47712
|
function probe(command, args) {
|
|
47629
|
-
return
|
|
47713
|
+
return execFileSync31(command, args, {
|
|
47630
47714
|
encoding: "utf8",
|
|
47631
47715
|
timeout: PROBE_TIMEOUT_MS,
|
|
47632
47716
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -48310,7 +48394,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
48310
48394
|
}
|
|
48311
48395
|
|
|
48312
48396
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
48313
|
-
import { existsSync as
|
|
48397
|
+
import { existsSync as existsSync95 } from "fs";
|
|
48314
48398
|
import { basename as basename34 } from "path";
|
|
48315
48399
|
|
|
48316
48400
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -48331,9 +48415,9 @@ function accountedTrees(sessions) {
|
|
|
48331
48415
|
}
|
|
48332
48416
|
|
|
48333
48417
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
48334
|
-
import { existsSync as
|
|
48418
|
+
import { existsSync as existsSync94 } from "fs";
|
|
48335
48419
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
48336
|
-
if (!
|
|
48420
|
+
if (!existsSync94(clone)) {
|
|
48337
48421
|
for (const { path: path109 } of paths) forgetWorktree(path109);
|
|
48338
48422
|
daemonLog(
|
|
48339
48423
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -48499,7 +48583,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
48499
48583
|
);
|
|
48500
48584
|
continue;
|
|
48501
48585
|
}
|
|
48502
|
-
if (!
|
|
48586
|
+
if (!existsSync95(path109)) {
|
|
48503
48587
|
logVanishedTree(sessions, path109);
|
|
48504
48588
|
vanished.set(clone, [
|
|
48505
48589
|
...vanished.get(clone) ?? [],
|
|
@@ -49570,7 +49654,7 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
|
|
|
49570
49654
|
}
|
|
49571
49655
|
|
|
49572
49656
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
49573
|
-
import { existsSync as
|
|
49657
|
+
import { existsSync as existsSync98 } from "fs";
|
|
49574
49658
|
|
|
49575
49659
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
49576
49660
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -49601,11 +49685,11 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
49601
49685
|
}
|
|
49602
49686
|
|
|
49603
49687
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
49604
|
-
import { existsSync as
|
|
49688
|
+
import { existsSync as existsSync97 } from "fs";
|
|
49605
49689
|
|
|
49606
49690
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
49607
|
-
import { copyFileSync as copyFileSync5, existsSync as
|
|
49608
|
-
import { join as
|
|
49691
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync96, mkdirSync as mkdirSync38 } from "fs";
|
|
49692
|
+
import { join as join106 } from "path";
|
|
49609
49693
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
49610
49694
|
const dir = projectDirForCwd(toCwd);
|
|
49611
49695
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -49614,8 +49698,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
49614
49698
|
);
|
|
49615
49699
|
return;
|
|
49616
49700
|
}
|
|
49617
|
-
const dest =
|
|
49618
|
-
if (
|
|
49701
|
+
const dest = join106(dir, `${claudeSessionId}.jsonl`);
|
|
49702
|
+
if (existsSync96(dest)) {
|
|
49619
49703
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
49620
49704
|
return;
|
|
49621
49705
|
}
|
|
@@ -49666,7 +49750,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
49666
49750
|
}
|
|
49667
49751
|
function cloneForReapedTree(missingCwd) {
|
|
49668
49752
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
49669
|
-
if (!clone || !
|
|
49753
|
+
if (!clone || !existsSync97(clone))
|
|
49670
49754
|
throw new Error(
|
|
49671
49755
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
49672
49756
|
);
|
|
@@ -49675,7 +49759,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
49675
49759
|
|
|
49676
49760
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
49677
49761
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
49678
|
-
if (!
|
|
49762
|
+
if (!existsSync98(cwd))
|
|
49679
49763
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
49680
49764
|
const id = ctx.spawnWith(
|
|
49681
49765
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -50638,7 +50722,7 @@ var sessionSettingHandlers = {
|
|
|
50638
50722
|
|
|
50639
50723
|
// src/commands/sessions/daemon/worktree/prCheckoutHolder.ts
|
|
50640
50724
|
import { execFile as execFile14 } from "child_process";
|
|
50641
|
-
import { existsSync as
|
|
50725
|
+
import { existsSync as existsSync99 } from "fs";
|
|
50642
50726
|
function prHeadBranch2(number, cwd) {
|
|
50643
50727
|
return new Promise((resolve30) => {
|
|
50644
50728
|
execFile14(
|
|
@@ -50651,12 +50735,12 @@ function prHeadBranch2(number, cwd) {
|
|
|
50651
50735
|
}
|
|
50652
50736
|
async function prCheckoutHolder(assistArgs, cwd) {
|
|
50653
50737
|
const number = prCheckoutNumber(assistArgs);
|
|
50654
|
-
if (!number || !cwd || !
|
|
50738
|
+
if (!number || !cwd || !existsSync99(cwd)) return void 0;
|
|
50655
50739
|
const headRef = await prHeadBranch2(number, cwd);
|
|
50656
50740
|
if (!headRef) return void 0;
|
|
50657
50741
|
const listing = await gitOrNull(cwd, ["worktree", "list", "--porcelain"]);
|
|
50658
50742
|
const holder = listing ? worktreeWithBranch(listing, headRef) : null;
|
|
50659
|
-
if (!holder || !
|
|
50743
|
+
if (!holder || !existsSync99(holder)) return void 0;
|
|
50660
50744
|
daemonLog(
|
|
50661
50745
|
`pr #${number} assist ${assistArgs[0]} launched in its checkout ${holder}: head branch ${headRef} is already checked out there, so no worktree is allocated`
|
|
50662
50746
|
);
|
|
@@ -50828,7 +50912,7 @@ function handleConnection(socket, manager) {
|
|
|
50828
50912
|
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync57 } from "fs";
|
|
50829
50913
|
|
|
50830
50914
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
50831
|
-
import { readFileSync as
|
|
50915
|
+
import { readFileSync as readFileSync70 } from "fs";
|
|
50832
50916
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
50833
50917
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
50834
50918
|
const timer = setInterval(() => {
|
|
@@ -50839,7 +50923,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
50839
50923
|
}
|
|
50840
50924
|
function ownsPidFile() {
|
|
50841
50925
|
try {
|
|
50842
|
-
return
|
|
50926
|
+
return readFileSync70(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
50843
50927
|
} catch {
|
|
50844
50928
|
return false;
|
|
50845
50929
|
}
|
|
@@ -51280,14 +51364,14 @@ function startPeerAction(name, action) {
|
|
|
51280
51364
|
const line = `nodes ${action} ${name} trace=${traceId}`;
|
|
51281
51365
|
console.log(line);
|
|
51282
51366
|
appendDaemonLog(line);
|
|
51283
|
-
const
|
|
51367
|
+
const fail9 = async (summary, error) => new Error(await describeFailure(name, summary, error));
|
|
51284
51368
|
return {
|
|
51285
51369
|
spec,
|
|
51286
51370
|
traceId,
|
|
51287
|
-
fail:
|
|
51371
|
+
fail: fail9,
|
|
51288
51372
|
async awaitReturn(sawDown, timeoutMs = RETURN_TIMEOUT_MS) {
|
|
51289
51373
|
const link3 = await awaitLinkReturn(name, { sawDown, timeoutMs });
|
|
51290
|
-
if (!link3) throw await
|
|
51374
|
+
if (!link3) throw await fail9(`${name} did not come back`);
|
|
51291
51375
|
return link3;
|
|
51292
51376
|
}
|
|
51293
51377
|
};
|
|
@@ -51470,17 +51554,17 @@ function resolveTarget3(sessionId, server) {
|
|
|
51470
51554
|
async function sessionOutput(sessionId, options2) {
|
|
51471
51555
|
const count10 = Number.parseInt(options2.lines, 10);
|
|
51472
51556
|
if (!Number.isInteger(count10) || count10 < 1)
|
|
51473
|
-
return
|
|
51557
|
+
return fail8(`-n must be a positive integer, got ${options2.lines}`);
|
|
51474
51558
|
const target = resolveTarget3(sessionId, options2.server);
|
|
51475
|
-
if (typeof target === "string") return
|
|
51559
|
+
if (typeof target === "string") return fail8(target);
|
|
51476
51560
|
try {
|
|
51477
51561
|
const scrollback = await requestSessionOutput(target);
|
|
51478
51562
|
for (const line of lastLines(scrollback, count10)) console.log(line);
|
|
51479
51563
|
} catch (error) {
|
|
51480
|
-
|
|
51564
|
+
fail8(error instanceof Error ? error.message : String(error));
|
|
51481
51565
|
}
|
|
51482
51566
|
}
|
|
51483
|
-
function
|
|
51567
|
+
function fail8(message3) {
|
|
51484
51568
|
console.error(message3);
|
|
51485
51569
|
process.exitCode = 1;
|
|
51486
51570
|
}
|
|
@@ -51544,7 +51628,7 @@ function summaryPathFor(jsonlPath2) {
|
|
|
51544
51628
|
}
|
|
51545
51629
|
|
|
51546
51630
|
// src/commands/sessions/summarise/summariseSession.ts
|
|
51547
|
-
import { execFileSync as
|
|
51631
|
+
import { execFileSync as execFileSync32 } from "child_process";
|
|
51548
51632
|
function summariseSession(jsonlPath2) {
|
|
51549
51633
|
const firstMessage = extractFirstUserMessage(jsonlPath2);
|
|
51550
51634
|
const backlogIds = scanSessionBacklogRefs(jsonlPath2);
|
|
@@ -51553,7 +51637,7 @@ function summariseSession(jsonlPath2) {
|
|
|
51553
51637
|
}
|
|
51554
51638
|
const prompt = buildPrompt6(firstMessage, backlogIds);
|
|
51555
51639
|
try {
|
|
51556
|
-
const output =
|
|
51640
|
+
const output = execFileSync32("claude", ["-p", "--model", "haiku", prompt], {
|
|
51557
51641
|
encoding: "utf8",
|
|
51558
51642
|
timeout: 3e4,
|
|
51559
51643
|
stdio: ["ignore", "pipe", "ignore"]
|