@staff0rd/assist 0.827.1 → 0.828.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/claude/skills/review-ci/scripts/review.mjs +150 -145
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +746 -675
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.828.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -280,9 +280,9 @@ function findGitLink(dir) {
|
|
|
280
280
|
}
|
|
281
281
|
return null;
|
|
282
282
|
}
|
|
283
|
-
function isFile(
|
|
283
|
+
function isFile(path109) {
|
|
284
284
|
try {
|
|
285
|
-
return statSync(
|
|
285
|
+
return statSync(path109).isFile();
|
|
286
286
|
} catch {
|
|
287
287
|
return false;
|
|
288
288
|
}
|
|
@@ -301,9 +301,9 @@ function linkedGitDirParent(gitDir) {
|
|
|
301
301
|
const match = /^(.*)[/\\]worktrees[/\\][^/\\]+[/\\]?$/.exec(gitDir);
|
|
302
302
|
return match ? match[1] : null;
|
|
303
303
|
}
|
|
304
|
-
function readTrimmed(
|
|
304
|
+
function readTrimmed(path109) {
|
|
305
305
|
try {
|
|
306
|
-
const content = readFileSync2(
|
|
306
|
+
const content = readFileSync2(path109, "utf8").trim();
|
|
307
307
|
return content === "" ? null : content;
|
|
308
308
|
} catch {
|
|
309
309
|
return null;
|
|
@@ -316,10 +316,10 @@ function absolute(target, from) {
|
|
|
316
316
|
// src/shared/loadRawYaml.ts
|
|
317
317
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
318
318
|
import { parse as parseYaml } from "yaml";
|
|
319
|
-
function loadRawYaml(
|
|
320
|
-
if (!existsSync3(
|
|
319
|
+
function loadRawYaml(path109) {
|
|
320
|
+
if (!existsSync3(path109)) return {};
|
|
321
321
|
try {
|
|
322
|
-
const content = readFileSync3(
|
|
322
|
+
const content = readFileSync3(path109, "utf8");
|
|
323
323
|
return parseYaml(content) || {};
|
|
324
324
|
} catch {
|
|
325
325
|
return {};
|
|
@@ -430,8 +430,8 @@ function getRemoteOriginUrl(cwd) {
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
// src/commands/backlog/getCurrentOrigin.ts
|
|
433
|
-
function stripLeadingSlashes(
|
|
434
|
-
return
|
|
433
|
+
function stripLeadingSlashes(path109) {
|
|
434
|
+
return path109.replace(/^\/+/, "");
|
|
435
435
|
}
|
|
436
436
|
function normalizeOrigin(raw) {
|
|
437
437
|
const trimmed = raw.trim().replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
@@ -474,10 +474,10 @@ function getStorePath(filename) {
|
|
|
474
474
|
return join3(getStoreDir(), filename);
|
|
475
475
|
}
|
|
476
476
|
function loadJson(filename) {
|
|
477
|
-
const
|
|
478
|
-
if (existsSync4(
|
|
477
|
+
const path109 = getStorePath(filename);
|
|
478
|
+
if (existsSync4(path109)) {
|
|
479
479
|
try {
|
|
480
|
-
return JSON.parse(readFileSync4(
|
|
480
|
+
return JSON.parse(readFileSync4(path109, "utf8"));
|
|
481
481
|
} catch {
|
|
482
482
|
return {};
|
|
483
483
|
}
|
|
@@ -497,10 +497,10 @@ function repoConfigCachePath() {
|
|
|
497
497
|
return join4(getStoreDir(), "repo-config-cache.json");
|
|
498
498
|
}
|
|
499
499
|
function readRepoConfigCache() {
|
|
500
|
-
const
|
|
501
|
-
if (!existsSync5(
|
|
500
|
+
const path109 = repoConfigCachePath();
|
|
501
|
+
if (!existsSync5(path109)) return {};
|
|
502
502
|
try {
|
|
503
|
-
const parsed = JSON.parse(readFileSync5(
|
|
503
|
+
const parsed = JSON.parse(readFileSync5(path109, "utf8"));
|
|
504
504
|
return parsed?.repos ?? {};
|
|
505
505
|
} catch {
|
|
506
506
|
return {};
|
|
@@ -510,8 +510,8 @@ function readRepoConfigCache() {
|
|
|
510
510
|
// src/commands/backlog/originDisplayName.ts
|
|
511
511
|
function originDisplayName(origin) {
|
|
512
512
|
if (origin.startsWith("local:")) {
|
|
513
|
-
const
|
|
514
|
-
const segments =
|
|
513
|
+
const path109 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
514
|
+
const segments = path109.split("/").filter(Boolean);
|
|
515
515
|
return segments[segments.length - 1] ?? origin;
|
|
516
516
|
}
|
|
517
517
|
const firstSlash = origin.indexOf("/");
|
|
@@ -911,7 +911,8 @@ var assistConfigShape = {
|
|
|
911
911
|
restructure: z5.strictObject({
|
|
912
912
|
ignore: z5.array(z5.string()).default([]),
|
|
913
913
|
pin: z5.array(z5.string()).default([]),
|
|
914
|
-
maxDepth: z5.number().int().positive().default(10)
|
|
914
|
+
maxDepth: z5.number().int().positive().default(10),
|
|
915
|
+
maxPathLength: z5.number().int().positive().default(200)
|
|
915
916
|
}).optional(),
|
|
916
917
|
jira: z5.strictObject({
|
|
917
918
|
acField: z5.string().default("customfield_11937")
|
|
@@ -3260,9 +3261,9 @@ function readSocketLines(socket, onLine) {
|
|
|
3260
3261
|
function toAttachments(value) {
|
|
3261
3262
|
if (!Array.isArray(value)) return void 0;
|
|
3262
3263
|
return value.flatMap((entry) => {
|
|
3263
|
-
const { path:
|
|
3264
|
-
if (typeof
|
|
3265
|
-
const attachment = { path:
|
|
3264
|
+
const { path: path109, alt, group } = entry ?? {};
|
|
3265
|
+
if (typeof path109 !== "string" || path109 === "") return [];
|
|
3266
|
+
const attachment = { path: path109, alt: typeof alt === "string" ? alt : "" };
|
|
3266
3267
|
return [
|
|
3267
3268
|
typeof group === "string" && group !== "" ? { ...attachment, group } : attachment
|
|
3268
3269
|
];
|
|
@@ -4906,8 +4907,8 @@ function getPreferredRemoteRepo(cwd) {
|
|
|
4906
4907
|
function gitRefUrl(kind, ref, cwd) {
|
|
4907
4908
|
const repo = getPreferredRemoteRepo(cwd);
|
|
4908
4909
|
if (!repo) return void 0;
|
|
4909
|
-
const
|
|
4910
|
-
return `https://github.com/${repo.org}/${repo.repo}/${
|
|
4910
|
+
const path109 = kind === "branch" ? "tree" : "commit";
|
|
4911
|
+
return `https://github.com/${repo.org}/${repo.repo}/${path109}/${ref}`;
|
|
4911
4912
|
}
|
|
4912
4913
|
|
|
4913
4914
|
// src/commands/sessions/shared/resolveSessionTranscript.ts
|
|
@@ -5068,9 +5069,9 @@ var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
|
5068
5069
|
function backupLocalBacklogFiles(dir) {
|
|
5069
5070
|
const moved = [];
|
|
5070
5071
|
for (const name of LOCAL_FILES) {
|
|
5071
|
-
const
|
|
5072
|
-
if (existsSync22(
|
|
5073
|
-
renameSync(
|
|
5072
|
+
const path109 = join23(dir, ".assist", name);
|
|
5073
|
+
if (existsSync22(path109)) {
|
|
5074
|
+
renameSync(path109, `${path109}.bak`);
|
|
5074
5075
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
5075
5076
|
}
|
|
5076
5077
|
}
|
|
@@ -5554,8 +5555,8 @@ var backlogItemSchema = z6.strictObject({
|
|
|
5554
5555
|
var backlogFileSchema = z6.array(backlogItemSchema);
|
|
5555
5556
|
|
|
5556
5557
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
5557
|
-
function parseBacklogJsonl(
|
|
5558
|
-
const content = readFileSync15(
|
|
5558
|
+
function parseBacklogJsonl(path109) {
|
|
5559
|
+
const content = readFileSync15(path109, "utf8").trim();
|
|
5559
5560
|
if (content.length === 0) return [];
|
|
5560
5561
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
5561
5562
|
}
|
|
@@ -6101,9 +6102,9 @@ function originToSshUrl(origin) {
|
|
|
6101
6102
|
const firstSlash = origin.indexOf("/");
|
|
6102
6103
|
if (firstSlash <= 0) return null;
|
|
6103
6104
|
const host = origin.slice(0, firstSlash);
|
|
6104
|
-
const
|
|
6105
|
-
if (!
|
|
6106
|
-
return `git@${host}:${
|
|
6105
|
+
const path109 = origin.slice(firstSlash + 1);
|
|
6106
|
+
if (!path109) return null;
|
|
6107
|
+
return `git@${host}:${path109}.git`;
|
|
6107
6108
|
}
|
|
6108
6109
|
|
|
6109
6110
|
// src/commands/backlog/cloneRepo.ts
|
|
@@ -7860,10 +7861,10 @@ var hooksSettings = {
|
|
|
7860
7861
|
}
|
|
7861
7862
|
};
|
|
7862
7863
|
function ensureHooksSettings() {
|
|
7863
|
-
const
|
|
7864
|
-
mkdirSync6(dirname15(
|
|
7865
|
-
writeFileSync17(
|
|
7866
|
-
return
|
|
7864
|
+
const path109 = daemonPaths.hooksSettings;
|
|
7865
|
+
mkdirSync6(dirname15(path109), { recursive: true });
|
|
7866
|
+
writeFileSync17(path109, JSON.stringify(hooksSettings, null, 2));
|
|
7867
|
+
return path109;
|
|
7867
7868
|
}
|
|
7868
7869
|
|
|
7869
7870
|
// src/shared/spawnInherit.ts
|
|
@@ -8630,24 +8631,24 @@ function getOwnerPath(itemId2) {
|
|
|
8630
8631
|
function recordSignalOwner(itemId2) {
|
|
8631
8632
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
8632
8633
|
if (!sessionId) return;
|
|
8633
|
-
const
|
|
8634
|
-
mkdirSync8(dirname16(
|
|
8635
|
-
writeFileSync19(
|
|
8634
|
+
const path109 = getOwnerPath(itemId2);
|
|
8635
|
+
mkdirSync8(dirname16(path109), { recursive: true });
|
|
8636
|
+
writeFileSync19(path109, JSON.stringify({ sessionId }));
|
|
8636
8637
|
}
|
|
8637
8638
|
function readSignalOwner(itemId2) {
|
|
8638
|
-
const
|
|
8639
|
-
if (!existsSync28(
|
|
8639
|
+
const path109 = getOwnerPath(itemId2);
|
|
8640
|
+
if (!existsSync28(path109)) return void 0;
|
|
8640
8641
|
try {
|
|
8641
|
-
const parsed = JSON.parse(readFileSync20(
|
|
8642
|
+
const parsed = JSON.parse(readFileSync20(path109, "utf8"));
|
|
8642
8643
|
return parsed.sessionId;
|
|
8643
8644
|
} catch {
|
|
8644
8645
|
return void 0;
|
|
8645
8646
|
}
|
|
8646
8647
|
}
|
|
8647
8648
|
function clearSignalOwner(itemId2) {
|
|
8648
|
-
const
|
|
8649
|
+
const path109 = getOwnerPath(itemId2);
|
|
8649
8650
|
try {
|
|
8650
|
-
rmSync(
|
|
8651
|
+
rmSync(path109);
|
|
8651
8652
|
} catch {
|
|
8652
8653
|
}
|
|
8653
8654
|
}
|
|
@@ -8684,19 +8685,19 @@ function resolveSignalTarget(event, data) {
|
|
|
8684
8685
|
function writeSignal(event, data) {
|
|
8685
8686
|
const target = resolveSignalTarget(event, data);
|
|
8686
8687
|
if (!target) return;
|
|
8687
|
-
const
|
|
8688
|
-
if (!
|
|
8688
|
+
const path109 = getSignalPath(target);
|
|
8689
|
+
if (!path109) return;
|
|
8689
8690
|
const signal = { event, sessionId: target, ...data };
|
|
8690
|
-
mkdirSync9(dirname17(
|
|
8691
|
-
writeFileSync20(
|
|
8691
|
+
mkdirSync9(dirname17(path109), { recursive: true });
|
|
8692
|
+
writeFileSync20(path109, JSON.stringify(signal));
|
|
8692
8693
|
}
|
|
8693
8694
|
|
|
8694
8695
|
// src/commands/backlog/readSignal.ts
|
|
8695
8696
|
function readSignal() {
|
|
8696
|
-
const
|
|
8697
|
-
if (!
|
|
8697
|
+
const path109 = getSignalPath();
|
|
8698
|
+
if (!path109 || !existsSync29(path109)) return void 0;
|
|
8698
8699
|
try {
|
|
8699
|
-
return JSON.parse(readFileSync21(
|
|
8700
|
+
return JSON.parse(readFileSync21(path109, "utf8"));
|
|
8700
8701
|
} catch {
|
|
8701
8702
|
return void 0;
|
|
8702
8703
|
}
|
|
@@ -8895,13 +8896,13 @@ function activityPath(sessionId) {
|
|
|
8895
8896
|
function emitActivity(activity2) {
|
|
8896
8897
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
8897
8898
|
if (!sessionId) return;
|
|
8898
|
-
const
|
|
8899
|
-
mkdirSync10(dirname18(
|
|
8900
|
-
writeFileSync21(
|
|
8899
|
+
const path109 = activityPath(sessionId);
|
|
8900
|
+
mkdirSync10(dirname18(path109), { recursive: true });
|
|
8901
|
+
writeFileSync21(path109, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
8901
8902
|
}
|
|
8902
|
-
function readActivity(
|
|
8903
|
+
function readActivity(path109) {
|
|
8903
8904
|
try {
|
|
8904
|
-
return JSON.parse(readFileSync22(
|
|
8905
|
+
return JSON.parse(readFileSync22(path109, "utf8"));
|
|
8905
8906
|
} catch {
|
|
8906
8907
|
return void 0;
|
|
8907
8908
|
}
|
|
@@ -8911,9 +8912,9 @@ function reconcileActivity(sessionId, activity2) {
|
|
|
8911
8912
|
removeActivity(sessionId);
|
|
8912
8913
|
return;
|
|
8913
8914
|
}
|
|
8914
|
-
const
|
|
8915
|
-
mkdirSync10(dirname18(
|
|
8916
|
-
writeFileSync21(
|
|
8915
|
+
const path109 = activityPath(sessionId);
|
|
8916
|
+
mkdirSync10(dirname18(path109), { recursive: true });
|
|
8917
|
+
writeFileSync21(path109, JSON.stringify(activity2));
|
|
8917
8918
|
}
|
|
8918
8919
|
function removeActivity(sessionId) {
|
|
8919
8920
|
try {
|
|
@@ -11213,10 +11214,10 @@ function sweepStagedAttachments(dir = stagedAttachmentsDir, now = Date.now()) {
|
|
|
11213
11214
|
}
|
|
11214
11215
|
for (const name of entries) {
|
|
11215
11216
|
if (!name.startsWith("upload-")) continue;
|
|
11216
|
-
const
|
|
11217
|
+
const path109 = join39(dir, name);
|
|
11217
11218
|
try {
|
|
11218
|
-
if (now - statSync3(
|
|
11219
|
-
rmSync3(
|
|
11219
|
+
if (now - statSync3(path109).mtimeMs > PANE_PERSIST_TTL_MS)
|
|
11220
|
+
rmSync3(path109, { recursive: true, force: true });
|
|
11220
11221
|
} catch {
|
|
11221
11222
|
}
|
|
11222
11223
|
}
|
|
@@ -12143,10 +12144,10 @@ function completeLines(text18, windowIsPartial) {
|
|
|
12143
12144
|
if (windowIsPartial) all.shift();
|
|
12144
12145
|
return all;
|
|
12145
12146
|
}
|
|
12146
|
-
function readLogTail(
|
|
12147
|
+
function readLogTail(path109, lines2) {
|
|
12147
12148
|
let fd;
|
|
12148
12149
|
try {
|
|
12149
|
-
fd = openSync4(
|
|
12150
|
+
fd = openSync4(path109, "r");
|
|
12150
12151
|
} catch {
|
|
12151
12152
|
return [];
|
|
12152
12153
|
}
|
|
@@ -12411,8 +12412,8 @@ async function loadCommittedPaths(cwd, sessionId) {
|
|
|
12411
12412
|
for (const commit2 of commits2) {
|
|
12412
12413
|
const resolved = await resolveCommit(cwd, commit2.sha);
|
|
12413
12414
|
if (!resolved) continue;
|
|
12414
|
-
for (const
|
|
12415
|
-
if (!bases.has(
|
|
12415
|
+
for (const path109 of resolved.paths) {
|
|
12416
|
+
if (!bases.has(path109)) bases.set(path109, resolved.base);
|
|
12416
12417
|
}
|
|
12417
12418
|
}
|
|
12418
12419
|
return { commits: commits2, bases };
|
|
@@ -12430,16 +12431,16 @@ async function itemChangeSet(cwd, sessionId) {
|
|
|
12430
12431
|
}
|
|
12431
12432
|
function groupByBase(bases) {
|
|
12432
12433
|
const groups = /* @__PURE__ */ new Map();
|
|
12433
|
-
for (const [
|
|
12434
|
+
for (const [path109, base] of bases) {
|
|
12434
12435
|
const paths = groups.get(base);
|
|
12435
|
-
if (paths) paths.push(
|
|
12436
|
-
else groups.set(base, [
|
|
12436
|
+
if (paths) paths.push(path109);
|
|
12437
|
+
else groups.set(base, [path109]);
|
|
12437
12438
|
}
|
|
12438
12439
|
return [...groups].map(([base, paths]) => ({ base, paths: paths.sort() }));
|
|
12439
12440
|
}
|
|
12440
12441
|
async function dirtyPaths(cwd, bases) {
|
|
12441
12442
|
const output = await execGit(cwd, ["diff", "--name-only", "HEAD"]);
|
|
12442
|
-
return output.split("\n").filter((
|
|
12443
|
+
return output.split("\n").filter((path109) => path109 && !bases.has(path109)).sort();
|
|
12443
12444
|
}
|
|
12444
12445
|
|
|
12445
12446
|
// src/commands/sessions/web/scopedDiff.ts
|
|
@@ -12448,8 +12449,8 @@ async function scopedDiff(cwd, session, scope) {
|
|
|
12448
12449
|
if (scope.kind === "commit") return commitDiff(cwd, scope.sha);
|
|
12449
12450
|
return await trackedScopeDiff(cwd, session, scope) + await untrackedDiff(cwd);
|
|
12450
12451
|
}
|
|
12451
|
-
async function untrackedFileDiff(cwd,
|
|
12452
|
-
return execGit(cwd, ["diff", "--no-index", "--", "/dev/null",
|
|
12452
|
+
async function untrackedFileDiff(cwd, path109) {
|
|
12453
|
+
return execGit(cwd, ["diff", "--no-index", "--", "/dev/null", path109], {
|
|
12453
12454
|
maxBuffer: MAX_DIFF_BYTES,
|
|
12454
12455
|
allowFailure: true
|
|
12455
12456
|
});
|
|
@@ -12462,7 +12463,7 @@ async function untrackedDiff(cwd) {
|
|
|
12462
12463
|
]);
|
|
12463
12464
|
const paths = list5.split("\n").filter(Boolean);
|
|
12464
12465
|
const diffs = await Promise.all(
|
|
12465
|
-
paths.map((
|
|
12466
|
+
paths.map((path109) => untrackedFileDiff(cwd, path109))
|
|
12466
12467
|
);
|
|
12467
12468
|
return diffs.join("");
|
|
12468
12469
|
}
|
|
@@ -12555,9 +12556,9 @@ import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve11
|
|
|
12555
12556
|
function repoRoot(cwd) {
|
|
12556
12557
|
return resolve11(cwd);
|
|
12557
12558
|
}
|
|
12558
|
-
function resolveWithinCwd(cwd,
|
|
12559
|
+
function resolveWithinCwd(cwd, path109) {
|
|
12559
12560
|
const root2 = repoRoot(cwd);
|
|
12560
|
-
const target = resolve11(root2,
|
|
12561
|
+
const target = resolve11(root2, path109);
|
|
12561
12562
|
const rel = relative2(root2, target);
|
|
12562
12563
|
if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) return null;
|
|
12563
12564
|
return target;
|
|
@@ -12567,14 +12568,14 @@ function resolveWithinCwd(cwd, path108) {
|
|
|
12567
12568
|
function getFileTarget(req, res) {
|
|
12568
12569
|
const cwd = getCwdParam(req, res);
|
|
12569
12570
|
if (!cwd) return null;
|
|
12570
|
-
const
|
|
12571
|
+
const path109 = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
12571
12572
|
"path"
|
|
12572
12573
|
);
|
|
12573
|
-
if (!
|
|
12574
|
+
if (!path109) {
|
|
12574
12575
|
respondJson(res, 400, { error: "Missing path" });
|
|
12575
12576
|
return null;
|
|
12576
12577
|
}
|
|
12577
|
-
const target = resolveWithinCwd(cwd,
|
|
12578
|
+
const target = resolveWithinCwd(cwd, path109);
|
|
12578
12579
|
if (!target) {
|
|
12579
12580
|
respondJson(res, 400, { error: "Path outside cwd" });
|
|
12580
12581
|
return null;
|
|
@@ -12633,9 +12634,9 @@ function segmentText(segment) {
|
|
|
12633
12634
|
if (segment.kind === "index") return `[${segment.index}]`;
|
|
12634
12635
|
return "[]";
|
|
12635
12636
|
}
|
|
12636
|
-
function formatConfigPath(
|
|
12637
|
+
function formatConfigPath(path109) {
|
|
12637
12638
|
let text18 = "";
|
|
12638
|
-
for (const segment of
|
|
12639
|
+
for (const segment of path109) {
|
|
12639
12640
|
const dotted = segment.kind === "key" || segment.kind === "entry";
|
|
12640
12641
|
const rendered = segmentText(segment);
|
|
12641
12642
|
text18 += dotted && text18 ? `.${rendered}` : rendered;
|
|
@@ -12796,11 +12797,11 @@ function enumValues(node) {
|
|
|
12796
12797
|
function opaqueConfigNode(inner, base) {
|
|
12797
12798
|
return { ...base, kind: "other", type: leafTypeOf(inner) };
|
|
12798
12799
|
}
|
|
12799
|
-
function build(node,
|
|
12800
|
+
function build(node, path109) {
|
|
12800
12801
|
const { inner, defaultValue, optional } = unwrapSchemaNode(node);
|
|
12801
12802
|
const secret = isSecretSchemaNode(node) || isSecretSchemaNode(inner);
|
|
12802
12803
|
const base = {
|
|
12803
|
-
path:
|
|
12804
|
+
path: path109,
|
|
12804
12805
|
...optional ? { optional: true } : {},
|
|
12805
12806
|
...defaultValue === void 0 ? {} : { defaultValue },
|
|
12806
12807
|
...secret ? { secret: true } : {}
|
|
@@ -12856,11 +12857,11 @@ function describeConfigLeaves(schema2) {
|
|
|
12856
12857
|
|
|
12857
12858
|
// src/commands/config/globalConfigFileLabel.ts
|
|
12858
12859
|
var WINDOWS_MOUNT_PREFIX = "/mnt/";
|
|
12859
|
-
function globalConfigFileLabel(
|
|
12860
|
-
if (
|
|
12861
|
-
if (
|
|
12862
|
-
return `${
|
|
12863
|
-
return
|
|
12860
|
+
function globalConfigFileLabel(path109) {
|
|
12861
|
+
if (path109 === getGlobalConfigPath()) return "~/.assist.yml";
|
|
12862
|
+
if (path109.startsWith(WINDOWS_MOUNT_PREFIX))
|
|
12863
|
+
return `${path109} on the Windows host`;
|
|
12864
|
+
return path109;
|
|
12864
12865
|
}
|
|
12865
12866
|
|
|
12866
12867
|
// src/commands/config/readRawConfigLayers.ts
|
|
@@ -12912,35 +12913,35 @@ function isPlainRecord(value) {
|
|
|
12912
12913
|
}
|
|
12913
12914
|
|
|
12914
12915
|
// src/shared/mapConfigSecrets.ts
|
|
12915
|
-
function mapChildren(value,
|
|
12916
|
+
function mapChildren(value, path109, childNode, map) {
|
|
12916
12917
|
if (!isPlainRecord(value)) return value;
|
|
12917
12918
|
return Object.fromEntries(
|
|
12918
12919
|
Object.entries(value).map(([name, child]) => [
|
|
12919
12920
|
name,
|
|
12920
|
-
walk(child, [...
|
|
12921
|
+
walk(child, [...path109, name], childNode(name), map)
|
|
12921
12922
|
])
|
|
12922
12923
|
);
|
|
12923
12924
|
}
|
|
12924
|
-
function mapItems(value,
|
|
12925
|
+
function mapItems(value, path109, item, map) {
|
|
12925
12926
|
if (!Array.isArray(value)) return value;
|
|
12926
|
-
return value.map((entry, index2) => walk(entry, [...
|
|
12927
|
+
return value.map((entry, index2) => walk(entry, [...path109, index2], item, map));
|
|
12927
12928
|
}
|
|
12928
|
-
function walk(value,
|
|
12929
|
+
function walk(value, path109, node, map) {
|
|
12929
12930
|
if (!node || value === void 0 || value === null) return value;
|
|
12930
|
-
if (node.secret) return map(value,
|
|
12931
|
+
if (node.secret) return map(value, path109);
|
|
12931
12932
|
switch (node.kind) {
|
|
12932
12933
|
case "object":
|
|
12933
12934
|
case "unionOfObjects":
|
|
12934
12935
|
return mapChildren(
|
|
12935
12936
|
value,
|
|
12936
|
-
|
|
12937
|
+
path109,
|
|
12937
12938
|
(name) => configNodeField(node, name),
|
|
12938
12939
|
map
|
|
12939
12940
|
);
|
|
12940
12941
|
case "objectList":
|
|
12941
|
-
return mapItems(value,
|
|
12942
|
+
return mapItems(value, path109, node.item, map);
|
|
12942
12943
|
case "record":
|
|
12943
|
-
return mapChildren(value,
|
|
12944
|
+
return mapChildren(value, path109, () => node.value, map);
|
|
12944
12945
|
default:
|
|
12945
12946
|
return value;
|
|
12946
12947
|
}
|
|
@@ -12965,9 +12966,9 @@ function isTraversable(value) {
|
|
|
12965
12966
|
function stepInto(current, key) {
|
|
12966
12967
|
return isTraversable(current) ? current[key] : void 0;
|
|
12967
12968
|
}
|
|
12968
|
-
function getNestedValue(obj,
|
|
12969
|
+
function getNestedValue(obj, path109) {
|
|
12969
12970
|
let current = obj;
|
|
12970
|
-
for (const key of
|
|
12971
|
+
for (const key of path109.split(".")) current = stepInto(current, key);
|
|
12971
12972
|
return current;
|
|
12972
12973
|
}
|
|
12973
12974
|
|
|
@@ -13017,9 +13018,9 @@ function step(node, segment) {
|
|
|
13017
13018
|
return void 0;
|
|
13018
13019
|
}
|
|
13019
13020
|
}
|
|
13020
|
-
function findConfigNode(root2,
|
|
13021
|
+
function findConfigNode(root2, path109) {
|
|
13021
13022
|
let current = root2;
|
|
13022
|
-
for (const segment of
|
|
13023
|
+
for (const segment of path109) {
|
|
13023
13024
|
if (!current) return void 0;
|
|
13024
13025
|
current = step(current, segment);
|
|
13025
13026
|
}
|
|
@@ -13036,34 +13037,34 @@ function nameSegment(name) {
|
|
|
13036
13037
|
return name === RECORD_ENTRY_TOKEN ? { kind: "entry" } : { kind: "key", name };
|
|
13037
13038
|
}
|
|
13038
13039
|
function parseConfigPath(text18) {
|
|
13039
|
-
const
|
|
13040
|
+
const path109 = [];
|
|
13040
13041
|
let at2 = 0;
|
|
13041
13042
|
while (at2 < text18.length) {
|
|
13042
13043
|
if (text18[at2] === "[") {
|
|
13043
13044
|
const close = text18.indexOf("]", at2);
|
|
13044
13045
|
const segment = close === -1 ? void 0 : bracketSegment(text18.slice(at2 + 1, close));
|
|
13045
13046
|
if (!segment) return void 0;
|
|
13046
|
-
|
|
13047
|
+
path109.push(segment);
|
|
13047
13048
|
at2 = close + 1;
|
|
13048
13049
|
continue;
|
|
13049
13050
|
}
|
|
13050
13051
|
if (text18[at2] === ".") {
|
|
13051
|
-
if (
|
|
13052
|
+
if (path109.length === 0) return void 0;
|
|
13052
13053
|
at2 += 1;
|
|
13053
13054
|
}
|
|
13054
13055
|
const start2 = at2;
|
|
13055
13056
|
while (at2 < text18.length && text18[at2] !== "." && text18[at2] !== "[") at2 += 1;
|
|
13056
13057
|
const name = text18.slice(start2, at2);
|
|
13057
13058
|
if (!name) return void 0;
|
|
13058
|
-
|
|
13059
|
+
path109.push(nameSegment(name));
|
|
13059
13060
|
}
|
|
13060
|
-
return
|
|
13061
|
+
return path109;
|
|
13061
13062
|
}
|
|
13062
13063
|
|
|
13063
13064
|
// src/commands/config/configEntryNode.ts
|
|
13064
13065
|
function configEntryNode(root2, key) {
|
|
13065
|
-
const
|
|
13066
|
-
return
|
|
13066
|
+
const path109 = parseConfigPath(key);
|
|
13067
|
+
return path109 ? findConfigNode(root2, path109) : void 0;
|
|
13067
13068
|
}
|
|
13068
13069
|
|
|
13069
13070
|
// src/commands/backlog/harnessConfigHelp.ts
|
|
@@ -13342,6 +13343,11 @@ var refactorConfigHelp = [
|
|
|
13342
13343
|
key: "restructure.maxDepth",
|
|
13343
13344
|
setter: "assist config set restructure.maxDepth 10",
|
|
13344
13345
|
note: "deepest folder level the plan may place a file at (default 10); deeper plans list their deep chains with pin guidance, and --check fails"
|
|
13346
|
+
},
|
|
13347
|
+
{
|
|
13348
|
+
key: "restructure.maxPathLength",
|
|
13349
|
+
setter: "assist config set restructure.maxPathLength 200",
|
|
13350
|
+
note: "longest repo-relative path the plan may place a file at (default 200), leaving room for a Windows checkout root under MAX_PATH; longer plans list the paths with pin guidance, and --check fails"
|
|
13345
13351
|
}
|
|
13346
13352
|
];
|
|
13347
13353
|
|
|
@@ -13873,7 +13879,7 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
|
13873
13879
|
const parent = dirname22(branchKeyPath);
|
|
13874
13880
|
const branchPrefix = basename11(branchKeyPath);
|
|
13875
13881
|
if (!existsSync35(parent)) return null;
|
|
13876
|
-
const synthesisFiles = readdirSync5(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join41(parent, name, "synthesis.md")).filter((
|
|
13882
|
+
const synthesisFiles = readdirSync5(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join41(parent, name, "synthesis.md")).filter((path109) => existsSync35(path109)).map((path109) => ({ path: path109, mtime: statSync6(path109).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
13877
13883
|
return synthesisFiles[0]?.path ?? null;
|
|
13878
13884
|
}
|
|
13879
13885
|
|
|
@@ -13903,12 +13909,12 @@ async function getReviewSynthesis(req, res) {
|
|
|
13903
13909
|
const cwd = getCwdParam(req, res);
|
|
13904
13910
|
if (!cwd) return;
|
|
13905
13911
|
try {
|
|
13906
|
-
const
|
|
13907
|
-
if (!
|
|
13912
|
+
const path109 = await resolveSynthesisPath(cwd);
|
|
13913
|
+
if (!path109) {
|
|
13908
13914
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
13909
13915
|
return;
|
|
13910
13916
|
}
|
|
13911
|
-
respondJson(res, 200, { synthesis: readFileSync24(
|
|
13917
|
+
respondJson(res, 200, { synthesis: readFileSync24(path109, "utf8") });
|
|
13912
13918
|
} catch {
|
|
13913
13919
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
13914
13920
|
}
|
|
@@ -13991,8 +13997,8 @@ function parseDiffNameStatus(output) {
|
|
|
13991
13997
|
if (!status2 || fields.length < 2) continue;
|
|
13992
13998
|
const category = categorize(status2[0]);
|
|
13993
13999
|
if (!category) continue;
|
|
13994
|
-
const
|
|
13995
|
-
if (
|
|
14000
|
+
const path109 = fields[fields.length - 1];
|
|
14001
|
+
if (path109) result[category].push(path109);
|
|
13996
14002
|
}
|
|
13997
14003
|
return result;
|
|
13998
14004
|
}
|
|
@@ -14235,21 +14241,21 @@ function subsequenceScore(text18, query) {
|
|
|
14235
14241
|
}
|
|
14236
14242
|
return score - Math.min(text18.length, MAX_LENGTH_PENALTY);
|
|
14237
14243
|
}
|
|
14238
|
-
function scoreFilePath(
|
|
14244
|
+
function scoreFilePath(path109, query) {
|
|
14239
14245
|
const needle = query.trim().toLowerCase();
|
|
14240
14246
|
if (!needle) return 0;
|
|
14241
|
-
const basename36 =
|
|
14247
|
+
const basename36 = path109.slice(path109.lastIndexOf("/") + 1);
|
|
14242
14248
|
const inBasename = subsequenceScore(basename36, needle);
|
|
14243
14249
|
if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
|
|
14244
|
-
return subsequenceScore(
|
|
14250
|
+
return subsequenceScore(path109, needle);
|
|
14245
14251
|
}
|
|
14246
14252
|
|
|
14247
14253
|
// src/commands/sessions/web/rankFilePaths.ts
|
|
14248
14254
|
function rankFilePaths(paths, query, limit) {
|
|
14249
14255
|
const scored = [];
|
|
14250
|
-
for (const
|
|
14251
|
-
const score = scoreFilePath(
|
|
14252
|
-
if (score !== null) scored.push({ path:
|
|
14256
|
+
for (const path109 of paths) {
|
|
14257
|
+
const score = scoreFilePath(path109, query);
|
|
14258
|
+
if (score !== null) scored.push({ path: path109, score });
|
|
14253
14259
|
}
|
|
14254
14260
|
scored.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
|
|
14255
14261
|
return scored.slice(0, limit).map((entry) => entry.path);
|
|
@@ -15746,11 +15752,11 @@ function logLinkedRequest(req, res) {
|
|
|
15746
15752
|
const started = Date.now();
|
|
15747
15753
|
const from = req.headers[LINKED_FROM_HEADER2];
|
|
15748
15754
|
const trace = req.headers[TRACE_HEADER] ?? "none";
|
|
15749
|
-
const
|
|
15755
|
+
const path109 = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
15750
15756
|
res.once("finish", () => {
|
|
15751
|
-
if (isQuietPoll(
|
|
15757
|
+
if (isQuietPoll(path109, res.statusCode)) return;
|
|
15752
15758
|
console.log(
|
|
15753
|
-
`link-from ${from} http: ${req.method} ${
|
|
15759
|
+
`link-from ${from} http: ${req.method} ${path109} trace=${trace} -> ${res.statusCode} (${Date.now() - started}ms)`
|
|
15754
15760
|
);
|
|
15755
15761
|
});
|
|
15756
15762
|
}
|
|
@@ -15775,8 +15781,8 @@ import { stat as stat3 } from "fs/promises";
|
|
|
15775
15781
|
|
|
15776
15782
|
// src/shared/isStagedAttachmentPath.ts
|
|
15777
15783
|
import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve13, sep } from "path";
|
|
15778
|
-
function isStagedAttachmentPath(
|
|
15779
|
-
const rel = relative3(stagedAttachmentsDir, resolve13(
|
|
15784
|
+
function isStagedAttachmentPath(path109) {
|
|
15785
|
+
const rel = relative3(stagedAttachmentsDir, resolve13(path109));
|
|
15780
15786
|
return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute3(rel);
|
|
15781
15787
|
}
|
|
15782
15788
|
|
|
@@ -15796,8 +15802,8 @@ var attachmentMimeTypes = {
|
|
|
15796
15802
|
};
|
|
15797
15803
|
|
|
15798
15804
|
// src/commands/sessions/web/attachmentContentType.ts
|
|
15799
|
-
function attachmentContentType(
|
|
15800
|
-
const ext = extname(
|
|
15805
|
+
function attachmentContentType(path109) {
|
|
15806
|
+
const ext = extname(path109).replace(/^\./, "").toLowerCase();
|
|
15801
15807
|
const match = Object.entries(attachmentMimeTypes).find(([, e]) => e === ext);
|
|
15802
15808
|
return match?.[0] ?? "application/octet-stream";
|
|
15803
15809
|
}
|
|
@@ -15805,22 +15811,22 @@ function attachmentContentType(path108) {
|
|
|
15805
15811
|
// src/commands/sessions/web/previewImage.ts
|
|
15806
15812
|
async function previewImage(req, res) {
|
|
15807
15813
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
15808
|
-
const
|
|
15809
|
-
if (!isStagedAttachmentPath(
|
|
15814
|
+
const path109 = url.searchParams.get("path") ?? "";
|
|
15815
|
+
if (!isStagedAttachmentPath(path109)) {
|
|
15810
15816
|
respondJson(res, 400, { error: "Not a staged attachment." });
|
|
15811
15817
|
return;
|
|
15812
15818
|
}
|
|
15813
|
-
const info = await stat3(
|
|
15819
|
+
const info = await stat3(path109).catch(() => null);
|
|
15814
15820
|
if (!info?.isFile()) {
|
|
15815
15821
|
respondJson(res, 404, { error: "Attachment is no longer staged." });
|
|
15816
15822
|
return;
|
|
15817
15823
|
}
|
|
15818
15824
|
res.writeHead(200, {
|
|
15819
|
-
"Content-Type": attachmentContentType(
|
|
15825
|
+
"Content-Type": attachmentContentType(path109),
|
|
15820
15826
|
"Content-Length": info.size,
|
|
15821
15827
|
"Cache-Control": "no-store"
|
|
15822
15828
|
});
|
|
15823
|
-
createReadStream2(
|
|
15829
|
+
createReadStream2(path109).pipe(res);
|
|
15824
15830
|
}
|
|
15825
15831
|
|
|
15826
15832
|
// src/commands/sessions/web/getCurrentBranch.ts
|
|
@@ -16257,8 +16263,8 @@ async function liveDeployments(cwd, repo, environments) {
|
|
|
16257
16263
|
|
|
16258
16264
|
// src/commands/sessions/web/releases/latestRun.ts
|
|
16259
16265
|
async function latestRun(cwd, repo, workflow) {
|
|
16260
|
-
const
|
|
16261
|
-
const response = await ghJson(cwd, ["api",
|
|
16266
|
+
const path109 = `repos/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?per_page=1&exclude_pull_requests=true`;
|
|
16267
|
+
const response = await ghJson(cwd, ["api", path109]);
|
|
16262
16268
|
const run4 = response.workflow_runs?.[0];
|
|
16263
16269
|
if (!run4) return null;
|
|
16264
16270
|
return {
|
|
@@ -16555,38 +16561,38 @@ async function performRestart(target, deps2 = {}) {
|
|
|
16555
16561
|
import { relative as relative4 } from "path";
|
|
16556
16562
|
|
|
16557
16563
|
// src/commands/sessions/web/revertPathChanges.ts
|
|
16558
|
-
async function isTracked(cwd,
|
|
16564
|
+
async function isTracked(cwd, path109) {
|
|
16559
16565
|
try {
|
|
16560
|
-
await execGit(cwd, ["ls-files", "--error-unmatch", "--",
|
|
16566
|
+
await execGit(cwd, ["ls-files", "--error-unmatch", "--", path109]);
|
|
16561
16567
|
return true;
|
|
16562
16568
|
} catch {
|
|
16563
16569
|
return false;
|
|
16564
16570
|
}
|
|
16565
16571
|
}
|
|
16566
|
-
async function isInHead(cwd,
|
|
16567
|
-
const listing = await execGit(cwd, ["ls-tree", "HEAD", "--",
|
|
16572
|
+
async function isInHead(cwd, path109) {
|
|
16573
|
+
const listing = await execGit(cwd, ["ls-tree", "HEAD", "--", path109]);
|
|
16568
16574
|
return listing.trim().length > 0;
|
|
16569
16575
|
}
|
|
16570
|
-
async function revertPathChanges(cwd,
|
|
16571
|
-
if (!await isTracked(cwd,
|
|
16572
|
-
await execGit(cwd, ["clean", "-f", "--",
|
|
16576
|
+
async function revertPathChanges(cwd, path109) {
|
|
16577
|
+
if (!await isTracked(cwd, path109)) {
|
|
16578
|
+
await execGit(cwd, ["clean", "-f", "--", path109]);
|
|
16573
16579
|
return;
|
|
16574
16580
|
}
|
|
16575
|
-
if (await isInHead(cwd,
|
|
16576
|
-
await execGit(cwd, ["checkout", "HEAD", "--",
|
|
16581
|
+
if (await isInHead(cwd, path109)) {
|
|
16582
|
+
await execGit(cwd, ["checkout", "HEAD", "--", path109]);
|
|
16577
16583
|
return;
|
|
16578
16584
|
}
|
|
16579
|
-
await execGit(cwd, ["rm", "-f", "--",
|
|
16585
|
+
await execGit(cwd, ["rm", "-f", "--", path109]);
|
|
16580
16586
|
}
|
|
16581
16587
|
|
|
16582
16588
|
// src/commands/sessions/web/revertDiffFile.ts
|
|
16583
16589
|
async function revertDiffFile(req, res) {
|
|
16584
16590
|
const resolved = getFileTarget(req, res);
|
|
16585
16591
|
if (!resolved) return;
|
|
16586
|
-
const
|
|
16592
|
+
const path109 = relative4(repoRoot(resolved.cwd), resolved.target);
|
|
16587
16593
|
try {
|
|
16588
|
-
await revertPathChanges(resolved.cwd,
|
|
16589
|
-
respondJson(res, 200, { reverted:
|
|
16594
|
+
await revertPathChanges(resolved.cwd, path109);
|
|
16595
|
+
respondJson(res, 200, { reverted: path109 });
|
|
16590
16596
|
} catch (error) {
|
|
16591
16597
|
respondJson(res, 500, {
|
|
16592
16598
|
error: error instanceof Error ? error.message : "Failed to revert file"
|
|
@@ -16687,7 +16693,7 @@ import { relative as relative5 } from "path";
|
|
|
16687
16693
|
function requestedPaths(body) {
|
|
16688
16694
|
const paths = body.paths;
|
|
16689
16695
|
if (!Array.isArray(paths)) return null;
|
|
16690
|
-
if (paths.some((
|
|
16696
|
+
if (paths.some((path109) => typeof path109 !== "string")) return null;
|
|
16691
16697
|
return paths;
|
|
16692
16698
|
}
|
|
16693
16699
|
async function revertDiffPaths(req, res) {
|
|
@@ -16707,10 +16713,10 @@ async function revertDiffPaths(req, res) {
|
|
|
16707
16713
|
const root2 = repoRoot(cwd);
|
|
16708
16714
|
const reverted = [];
|
|
16709
16715
|
const failed3 = [];
|
|
16710
|
-
for (const
|
|
16711
|
-
const target = resolveWithinCwd(cwd,
|
|
16716
|
+
for (const path109 of paths) {
|
|
16717
|
+
const target = resolveWithinCwd(cwd, path109);
|
|
16712
16718
|
if (!target) {
|
|
16713
|
-
failed3.push({ path:
|
|
16719
|
+
failed3.push({ path: path109, error: "Path outside cwd" });
|
|
16714
16720
|
continue;
|
|
16715
16721
|
}
|
|
16716
16722
|
const relativePath = relative5(root2, target);
|
|
@@ -16756,13 +16762,13 @@ function describePeerError(error) {
|
|
|
16756
16762
|
const cause = error.cause;
|
|
16757
16763
|
return cause instanceof Error ? `${error.message}: ${describePeerError(cause)}` : error.message;
|
|
16758
16764
|
}
|
|
16759
|
-
async function fetchPeerJson(baseUrl,
|
|
16760
|
-
const res = await fetch(new URL(
|
|
16765
|
+
async function fetchPeerJson(baseUrl, path109, timeoutMs = PEER_TIMEOUT_MS) {
|
|
16766
|
+
const res = await fetch(new URL(path109, baseUrl), {
|
|
16761
16767
|
signal: AbortSignal.timeout(timeoutMs)
|
|
16762
16768
|
});
|
|
16763
16769
|
if (!res.ok)
|
|
16764
16770
|
throw Object.assign(
|
|
16765
|
-
new Error(`GET ${
|
|
16771
|
+
new Error(`GET ${path109} returned ${res.status} ${res.statusText}`),
|
|
16766
16772
|
{ status: res.status }
|
|
16767
16773
|
);
|
|
16768
16774
|
return await res.json();
|
|
@@ -17182,11 +17188,11 @@ function parseJson(raw) {
|
|
|
17182
17188
|
}
|
|
17183
17189
|
}
|
|
17184
17190
|
function formatIssue(key, issue) {
|
|
17185
|
-
const
|
|
17191
|
+
const path109 = formatConfigPath([
|
|
17186
17192
|
{ kind: "key", name: key },
|
|
17187
17193
|
...issue.path.map(toSegment)
|
|
17188
17194
|
]);
|
|
17189
|
-
return `${
|
|
17195
|
+
return `${path109}: ${issue.message}`;
|
|
17190
17196
|
}
|
|
17191
17197
|
function toSegment(part) {
|
|
17192
17198
|
return typeof part === "number" ? { kind: "index", index: part } : { kind: "key", name: String(part) };
|
|
@@ -17281,9 +17287,9 @@ function coerceUnion(key, raw, types) {
|
|
|
17281
17287
|
}
|
|
17282
17288
|
|
|
17283
17289
|
// src/shared/valueAtConfigPath.ts
|
|
17284
|
-
function valueAtConfigPath(value,
|
|
17290
|
+
function valueAtConfigPath(value, path109) {
|
|
17285
17291
|
let current = value;
|
|
17286
|
-
for (const key of
|
|
17292
|
+
for (const key of path109) {
|
|
17287
17293
|
if (typeof key === "number") {
|
|
17288
17294
|
if (!Array.isArray(current)) return void 0;
|
|
17289
17295
|
current = current[key];
|
|
@@ -17300,7 +17306,7 @@ function restoreConfigSecrets(value, stored, node) {
|
|
|
17300
17306
|
return mapConfigSecrets(
|
|
17301
17307
|
value,
|
|
17302
17308
|
node,
|
|
17303
|
-
(secret,
|
|
17309
|
+
(secret, path109) => isRedactedSecret(secret) ? valueAtConfigPath(stored, path109) : secret
|
|
17304
17310
|
);
|
|
17305
17311
|
}
|
|
17306
17312
|
|
|
@@ -17349,8 +17355,8 @@ function stepIntoNested(container, key, nextKey) {
|
|
|
17349
17355
|
}
|
|
17350
17356
|
return ensureObject(container, resolved);
|
|
17351
17357
|
}
|
|
17352
|
-
function setNestedValue(obj,
|
|
17353
|
-
const keys =
|
|
17358
|
+
function setNestedValue(obj, path109, value) {
|
|
17359
|
+
const keys = path109.split(".");
|
|
17354
17360
|
const result = { ...obj };
|
|
17355
17361
|
let current = result;
|
|
17356
17362
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
@@ -17377,8 +17383,8 @@ function formatIssue2(issue, key) {
|
|
|
17377
17383
|
return issue.keys.map(
|
|
17378
17384
|
(unrecognized) => `${[...issue.path, unrecognized].join(".")}: Unrecognized key`
|
|
17379
17385
|
);
|
|
17380
|
-
const
|
|
17381
|
-
return [`${
|
|
17386
|
+
const path109 = issue.path.length > 0 ? issue.path.join(".") : key;
|
|
17387
|
+
return [`${path109}: ${issue.message}`];
|
|
17382
17388
|
}
|
|
17383
17389
|
|
|
17384
17390
|
// src/commands/config/applyConfigSet.ts
|
|
@@ -17469,15 +17475,15 @@ async function saveRepoConfig(orm, repoKey, config) {
|
|
|
17469
17475
|
import { mkdirSync as mkdirSync12, renameSync as renameSync2, writeFileSync as writeFileSync22 } from "fs";
|
|
17470
17476
|
import { dirname as dirname24 } from "path";
|
|
17471
17477
|
function writeRepoConfigCache(repos2) {
|
|
17472
|
-
const
|
|
17473
|
-
mkdirSync12(dirname24(
|
|
17478
|
+
const path109 = repoConfigCachePath();
|
|
17479
|
+
mkdirSync12(dirname24(path109), { recursive: true });
|
|
17474
17480
|
const cache6 = {
|
|
17475
17481
|
refreshedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17476
17482
|
repos: repos2
|
|
17477
17483
|
};
|
|
17478
|
-
const tmp = `${
|
|
17484
|
+
const tmp = `${path109}.${process.pid}.tmp`;
|
|
17479
17485
|
writeFileSync22(tmp, JSON.stringify(cache6, null, 2));
|
|
17480
|
-
renameSync2(tmp,
|
|
17486
|
+
renameSync2(tmp, path109);
|
|
17481
17487
|
}
|
|
17482
17488
|
|
|
17483
17489
|
// src/shared/refreshRepoConfigCache.ts
|
|
@@ -17660,8 +17666,8 @@ function removeAt(container, keys) {
|
|
|
17660
17666
|
}
|
|
17661
17667
|
return removeFromChild(container, key, rest);
|
|
17662
17668
|
}
|
|
17663
|
-
function unsetNestedValue(obj,
|
|
17664
|
-
const { container, removed } = removeAt(obj,
|
|
17669
|
+
function unsetNestedValue(obj, path109) {
|
|
17670
|
+
const { container, removed } = removeAt(obj, path109.split("."));
|
|
17665
17671
|
return { config: container, removed };
|
|
17666
17672
|
}
|
|
17667
17673
|
|
|
@@ -17801,12 +17807,12 @@ var sessionsPrefix = "src/commands/sessions/";
|
|
|
17801
17807
|
var restartRules = [
|
|
17802
17808
|
{
|
|
17803
17809
|
target: "webserver",
|
|
17804
|
-
matches: (
|
|
17810
|
+
matches: (path109) => path109.startsWith(webUiPrefix),
|
|
17805
17811
|
advice: "restart the web server, then hard-reload the browser tab"
|
|
17806
17812
|
},
|
|
17807
17813
|
{
|
|
17808
17814
|
target: "daemon",
|
|
17809
|
-
matches: (
|
|
17815
|
+
matches: (path109) => path109.startsWith(sessionsPrefix) && !path109.startsWith(webUiPrefix),
|
|
17810
17816
|
advice: "restart the daemon"
|
|
17811
17817
|
}
|
|
17812
17818
|
];
|
|
@@ -17847,11 +17853,11 @@ import { basename as basename13, join as join45 } from "path";
|
|
|
17847
17853
|
// src/commands/sessions/daemon/worktree/canonicalTreePath.ts
|
|
17848
17854
|
import { realpathSync as realpathSync2 } from "fs";
|
|
17849
17855
|
import { resolve as resolve15 } from "path";
|
|
17850
|
-
function canonicalTreePath(
|
|
17856
|
+
function canonicalTreePath(path109) {
|
|
17851
17857
|
try {
|
|
17852
|
-
return realpathSync2(
|
|
17858
|
+
return realpathSync2(path109);
|
|
17853
17859
|
} catch {
|
|
17854
|
-
return resolve15(
|
|
17860
|
+
return resolve15(path109);
|
|
17855
17861
|
}
|
|
17856
17862
|
}
|
|
17857
17863
|
|
|
@@ -18551,22 +18557,22 @@ function gitCommonDir(cwd) {
|
|
|
18551
18557
|
var REGISTRY_FILE = "worktrees.json";
|
|
18552
18558
|
function readWorktreeRegistry() {
|
|
18553
18559
|
const data = loadJson(REGISTRY_FILE);
|
|
18554
|
-
return Object.entries(data).filter(([, record]) => !record.reaped).map(([
|
|
18560
|
+
return Object.entries(data).filter(([, record]) => !record.reaped).map(([path109, record]) => ({ path: path109, ...record }));
|
|
18555
18561
|
}
|
|
18556
|
-
function worktreeAttributionIncludingReaped(
|
|
18557
|
-
const record = loadJson(REGISTRY_FILE)[
|
|
18562
|
+
function worktreeAttributionIncludingReaped(path109) {
|
|
18563
|
+
const record = loadJson(REGISTRY_FILE)[path109];
|
|
18558
18564
|
return record ? { clone: record.clone, origin: record.origin } : void 0;
|
|
18559
18565
|
}
|
|
18560
|
-
function recordWorktree(
|
|
18566
|
+
function recordWorktree(path109, clone, origin) {
|
|
18561
18567
|
const data = loadJson(REGISTRY_FILE);
|
|
18562
|
-
data[
|
|
18568
|
+
data[path109] = { clone, origin };
|
|
18563
18569
|
saveJson(REGISTRY_FILE, data);
|
|
18564
18570
|
}
|
|
18565
|
-
function forgetWorktree(
|
|
18571
|
+
function forgetWorktree(path109) {
|
|
18566
18572
|
const data = loadJson(REGISTRY_FILE);
|
|
18567
|
-
const record = data[
|
|
18573
|
+
const record = data[path109];
|
|
18568
18574
|
if (!record || record.reaped) return;
|
|
18569
|
-
data[
|
|
18575
|
+
data[path109] = { ...record, reaped: true };
|
|
18570
18576
|
saveJson(REGISTRY_FILE, data);
|
|
18571
18577
|
}
|
|
18572
18578
|
|
|
@@ -19329,10 +19335,10 @@ function flagValue(args, i) {
|
|
|
19329
19335
|
}
|
|
19330
19336
|
function readSourceOrCommandText(source, command) {
|
|
19331
19337
|
if (!source.startsWith("@")) return source;
|
|
19332
|
-
const
|
|
19333
|
-
if (
|
|
19338
|
+
const path109 = source.slice(1);
|
|
19339
|
+
if (path109 === "-") return command;
|
|
19334
19340
|
try {
|
|
19335
|
-
return readFileSync27(
|
|
19341
|
+
return readFileSync27(path109, "utf8");
|
|
19336
19342
|
} catch {
|
|
19337
19343
|
return command;
|
|
19338
19344
|
}
|
|
@@ -19527,13 +19533,13 @@ function findBuiltinDenyRaw(rawCommand) {
|
|
|
19527
19533
|
|
|
19528
19534
|
// src/commands/cliHook/findRestrictedPathDeny.ts
|
|
19529
19535
|
var RESTRICTED_PATHS = [".assist/restricted"];
|
|
19530
|
-
function restrictedPathRegex(
|
|
19531
|
-
const pattern2 =
|
|
19536
|
+
function restrictedPathRegex(path109) {
|
|
19537
|
+
const pattern2 = path109.split("/").map((segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)).join(String.raw`[/\\]`);
|
|
19532
19538
|
return new RegExp(pattern2);
|
|
19533
19539
|
}
|
|
19534
|
-
var RESTRICTED_PATH_RULES = RESTRICTED_PATHS.map((
|
|
19535
|
-
path:
|
|
19536
|
-
regex: restrictedPathRegex(
|
|
19540
|
+
var RESTRICTED_PATH_RULES = RESTRICTED_PATHS.map((path109) => ({
|
|
19541
|
+
path: path109,
|
|
19542
|
+
regex: restrictedPathRegex(path109)
|
|
19537
19543
|
}));
|
|
19538
19544
|
function findRestrictedPathDenyRaw(rawCommand) {
|
|
19539
19545
|
const rule = RESTRICTED_PATH_RULES.find(
|
|
@@ -19710,9 +19716,9 @@ var __dirname4 = dirname26(__filename3);
|
|
|
19710
19716
|
function packageRoot() {
|
|
19711
19717
|
return __dirname4;
|
|
19712
19718
|
}
|
|
19713
|
-
function readLines(
|
|
19714
|
-
if (!existsSync42(
|
|
19715
|
-
return readFileSync28(
|
|
19719
|
+
function readLines(path109) {
|
|
19720
|
+
if (!existsSync42(path109)) return [];
|
|
19721
|
+
return readFileSync28(path109, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
19716
19722
|
}
|
|
19717
19723
|
var cachedReads;
|
|
19718
19724
|
var cachedWrites;
|
|
@@ -20244,14 +20250,14 @@ function showProgress(p, label2) {
|
|
|
20244
20250
|
const pct = Math.round(p.done / p.total * 100);
|
|
20245
20251
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
20246
20252
|
}
|
|
20247
|
-
async function resolveCommand2(cli,
|
|
20248
|
-
showProgress(p,
|
|
20249
|
-
const subHelp = await runHelp([cli, ...
|
|
20253
|
+
async function resolveCommand2(cli, path109, description, depth, p) {
|
|
20254
|
+
showProgress(p, path109.join(" "));
|
|
20255
|
+
const subHelp = await runHelp([cli, ...path109]);
|
|
20250
20256
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
20251
|
-
return [{ path:
|
|
20257
|
+
return [{ path: path109, description }];
|
|
20252
20258
|
}
|
|
20253
|
-
const children = await discoverAt(cli,
|
|
20254
|
-
return children.length > 0 ? children : [{ path:
|
|
20259
|
+
const children = await discoverAt(cli, path109, depth + 1, p);
|
|
20260
|
+
return children.length > 0 ? children : [{ path: path109, description }];
|
|
20255
20261
|
}
|
|
20256
20262
|
async function discoverAt(cli, parentPath, depth, p) {
|
|
20257
20263
|
if (depth > SAFETY_DEPTH) return [];
|
|
@@ -20399,9 +20405,9 @@ function logPath(cli) {
|
|
|
20399
20405
|
return join50(homedir19(), ".assist", `cli-discover-${safeName}.log`);
|
|
20400
20406
|
}
|
|
20401
20407
|
function readCache(cli) {
|
|
20402
|
-
const
|
|
20403
|
-
if (!existsSync44(
|
|
20404
|
-
return readFileSync30(
|
|
20408
|
+
const path109 = logPath(cli);
|
|
20409
|
+
if (!existsSync44(path109)) return void 0;
|
|
20410
|
+
return readFileSync30(path109, "utf8");
|
|
20405
20411
|
}
|
|
20406
20412
|
function writeCache(cli, output) {
|
|
20407
20413
|
const dir = join50(homedir19(), ".assist");
|
|
@@ -20590,9 +20596,9 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
20590
20596
|
}
|
|
20591
20597
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
20592
20598
|
for (const entry of entries) {
|
|
20593
|
-
const
|
|
20599
|
+
const path109 = join52(dir, entry);
|
|
20594
20600
|
try {
|
|
20595
|
-
if (statSync8(
|
|
20601
|
+
if (statSync8(path109).mtimeMs < cutoff) unlinkSync7(path109);
|
|
20596
20602
|
} catch {
|
|
20597
20603
|
continue;
|
|
20598
20604
|
}
|
|
@@ -20602,10 +20608,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
20602
20608
|
// src/commands/codeComment/readPinState.ts
|
|
20603
20609
|
import { existsSync as existsSync45, readFileSync as readFileSync31 } from "fs";
|
|
20604
20610
|
function readPinState(pin2) {
|
|
20605
|
-
const
|
|
20606
|
-
if (!existsSync45(
|
|
20611
|
+
const path109 = getPinStatePath(pin2);
|
|
20612
|
+
if (!existsSync45(path109)) return void 0;
|
|
20607
20613
|
try {
|
|
20608
|
-
const state = JSON.parse(readFileSync31(
|
|
20614
|
+
const state = JSON.parse(readFileSync31(path109, "utf8"));
|
|
20609
20615
|
if (state.pin !== pin2) return void 0;
|
|
20610
20616
|
return state;
|
|
20611
20617
|
} catch {
|
|
@@ -21026,8 +21032,8 @@ function findUnmergedPaths() {
|
|
|
21026
21032
|
}
|
|
21027
21033
|
const found = /* @__PURE__ */ new Set();
|
|
21028
21034
|
for (const line of output.split("\n")) {
|
|
21029
|
-
const
|
|
21030
|
-
if (
|
|
21035
|
+
const path109 = line.split(" ")[1];
|
|
21036
|
+
if (path109) found.add(path109.trim());
|
|
21031
21037
|
}
|
|
21032
21038
|
return [...found];
|
|
21033
21039
|
}
|
|
@@ -22066,8 +22072,8 @@ function diffRepoConfigLeaves(current, incoming) {
|
|
|
22066
22072
|
}
|
|
22067
22073
|
function leaves(node, prefix2 = "") {
|
|
22068
22074
|
return Object.entries(node).flatMap(([key, value]) => {
|
|
22069
|
-
const
|
|
22070
|
-
return isPlainObject4(value) && Object.keys(value).length > 0 ? leaves(value,
|
|
22075
|
+
const path109 = prefix2 ? `${prefix2}.${key}` : key;
|
|
22076
|
+
return isPlainObject4(value) && Object.keys(value).length > 0 ? leaves(value, path109) : [[path109, value]];
|
|
22071
22077
|
});
|
|
22072
22078
|
}
|
|
22073
22079
|
function isPlainObject4(value) {
|
|
@@ -22378,11 +22384,11 @@ async function loadPath(source) {
|
|
|
22378
22384
|
}
|
|
22379
22385
|
}
|
|
22380
22386
|
async function criteriaExtension() {
|
|
22381
|
-
const
|
|
22387
|
+
const path109 = await loadPath(criteriaExtensionDir());
|
|
22382
22388
|
console.log(
|
|
22383
22389
|
chalk141.bold("acceptance criteria outliner \u2014 GitHub browser extension")
|
|
22384
22390
|
);
|
|
22385
|
-
console.log(chalk141.dim(`load the unpacked extension from ${
|
|
22391
|
+
console.log(chalk141.dim(`load the unpacked extension from ${path109}`));
|
|
22386
22392
|
}
|
|
22387
22393
|
|
|
22388
22394
|
// src/commands/criteriaExtension/printCriteriaExtensionUrl.ts
|
|
@@ -22498,7 +22504,7 @@ async function stageCriteriaExtension(source, staging, version2) {
|
|
|
22498
22504
|
await mkdir5(staging, { recursive: true });
|
|
22499
22505
|
await cp3(source, staging, {
|
|
22500
22506
|
recursive: true,
|
|
22501
|
-
filter: (
|
|
22507
|
+
filter: (path109) => basename15(path109) !== "updates.json"
|
|
22502
22508
|
});
|
|
22503
22509
|
const manifest = join58(staging, "manifest.json");
|
|
22504
22510
|
const stamped = stampManifestVersion(
|
|
@@ -22579,10 +22585,10 @@ async function signCriteriaExtension() {
|
|
|
22579
22585
|
return;
|
|
22580
22586
|
}
|
|
22581
22587
|
await writeUpdateManifest(source, ARTIFACTS_DIR, version2);
|
|
22582
|
-
const
|
|
22588
|
+
const path109 = await signedAddonInstallPath(
|
|
22583
22589
|
await copySignedXpi(xpi, ARTIFACTS_DIR)
|
|
22584
22590
|
);
|
|
22585
|
-
console.log(chalk144.dim(`install the signed add-on from ${
|
|
22591
|
+
console.log(chalk144.dim(`install the signed add-on from ${path109}`));
|
|
22586
22592
|
}
|
|
22587
22593
|
|
|
22588
22594
|
// src/commands/registerCriteriaExtension.ts
|
|
@@ -22744,10 +22750,10 @@ function getMigrationApprovalPath(migrationId) {
|
|
|
22744
22750
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
22745
22751
|
import { existsSync as existsSync50, readFileSync as readFileSync33 } from "fs";
|
|
22746
22752
|
function readMigrationPinState(pin2) {
|
|
22747
|
-
const
|
|
22748
|
-
if (!existsSync50(
|
|
22753
|
+
const path109 = getMigrationPinPath(pin2);
|
|
22754
|
+
if (!existsSync50(path109)) return void 0;
|
|
22749
22755
|
try {
|
|
22750
|
-
const state = JSON.parse(readFileSync33(
|
|
22756
|
+
const state = JSON.parse(readFileSync33(path109, "utf8"));
|
|
22751
22757
|
if (state.pin !== pin2) return void 0;
|
|
22752
22758
|
if (!Number.isInteger(state.migrationId)) return void 0;
|
|
22753
22759
|
return state;
|
|
@@ -24657,10 +24663,10 @@ function decideCommentGuard(input, existingContent) {
|
|
|
24657
24663
|
import { existsSync as existsSync56, unlinkSync as unlinkSync11 } from "fs";
|
|
24658
24664
|
function consumeMigrationApproval(migrationId) {
|
|
24659
24665
|
sweepRestrictedDir();
|
|
24660
|
-
const
|
|
24661
|
-
if (!existsSync56(
|
|
24666
|
+
const path109 = getMigrationApprovalPath(migrationId);
|
|
24667
|
+
if (!existsSync56(path109)) return false;
|
|
24662
24668
|
try {
|
|
24663
|
-
unlinkSync11(
|
|
24669
|
+
unlinkSync11(path109);
|
|
24664
24670
|
return true;
|
|
24665
24671
|
} catch {
|
|
24666
24672
|
return false;
|
|
@@ -25600,8 +25606,8 @@ function collectLabels(value, previous) {
|
|
|
25600
25606
|
import { extname as extname3 } from "path";
|
|
25601
25607
|
|
|
25602
25608
|
// src/commands/prs/screenshotReference.ts
|
|
25603
|
-
function screenshotReference({ path:
|
|
25604
|
-
const target = /\s/.test(
|
|
25609
|
+
function screenshotReference({ path: path109, alt }) {
|
|
25610
|
+
const target = /\s/.test(path109) ? `<${path109}>` : path109;
|
|
25605
25611
|
return ``;
|
|
25606
25612
|
}
|
|
25607
25613
|
|
|
@@ -26024,7 +26030,7 @@ async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
|
26024
26030
|
|
|
26025
26031
|
// src/commands/prs/attachArgs.ts
|
|
26026
26032
|
function attachArgs(attachments) {
|
|
26027
|
-
return attachments.flatMap(({ path:
|
|
26033
|
+
return attachments.flatMap(({ path: path109 }) => ["--attach", path109]);
|
|
26028
26034
|
}
|
|
26029
26035
|
|
|
26030
26036
|
// src/commands/prs/runGhWithAttachments.ts
|
|
@@ -26035,8 +26041,8 @@ import { basename as basename18 } from "path";
|
|
|
26035
26041
|
import { rmSync as rmSync4 } from "fs";
|
|
26036
26042
|
import { dirname as dirname29 } from "path";
|
|
26037
26043
|
function removeStagedAttachments(attachments) {
|
|
26038
|
-
for (const { path:
|
|
26039
|
-
const dir = dirname29(
|
|
26044
|
+
for (const { path: path109 } of attachments) {
|
|
26045
|
+
const dir = dirname29(path109);
|
|
26040
26046
|
if (!isStagedAttachmentPath(dir)) continue;
|
|
26041
26047
|
rmSync4(dir, { recursive: true, force: true });
|
|
26042
26048
|
}
|
|
@@ -26046,7 +26052,7 @@ function removeStagedAttachments(attachments) {
|
|
|
26046
26052
|
var PLACED_URL = /https:\/\/\S+\/(pull|issues)\/\d+/;
|
|
26047
26053
|
function reportPartialFailure(attachments, stderr) {
|
|
26048
26054
|
const failed3 = attachments.filter(
|
|
26049
|
-
({ path:
|
|
26055
|
+
({ path: path109 }) => stderr.includes(path109) || stderr.includes(basename18(path109))
|
|
26050
26056
|
);
|
|
26051
26057
|
const named = failed3.length > 0 ? failed3 : attachments;
|
|
26052
26058
|
console.error(
|
|
@@ -26947,7 +26953,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
26947
26953
|
const registered = new Set(listWorktreePaths(clone));
|
|
26948
26954
|
const branches = new Set(listLocalBranches(clone));
|
|
26949
26955
|
const isTaken = (candidate) => registered.has(candidate) || existsSync58(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename20(candidate));
|
|
26950
|
-
const
|
|
26956
|
+
const path109 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
26951
26957
|
const fetchError = fetchQuietly(clone, 0);
|
|
26952
26958
|
if (fetchError)
|
|
26953
26959
|
daemonLog(
|
|
@@ -26959,15 +26965,15 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
26959
26965
|
"add",
|
|
26960
26966
|
start2.track ? "--track" : "--no-track",
|
|
26961
26967
|
"-b",
|
|
26962
|
-
basename20(
|
|
26963
|
-
|
|
26968
|
+
basename20(path109),
|
|
26969
|
+
path109,
|
|
26964
26970
|
start2.ref
|
|
26965
26971
|
]);
|
|
26966
|
-
recordWorktree(
|
|
26972
|
+
recordWorktree(path109, clone, getCurrentOrigin(clone));
|
|
26967
26973
|
daemonLog(
|
|
26968
|
-
start2.track ? `worktree allocated ${
|
|
26974
|
+
start2.track ? `worktree allocated ${path109} (branch ${basename20(path109)} tracking ${start2.ref}) for clone ${clone}` : `worktree allocated ${path109} (branch ${basename20(path109)} off ${start2.ref}, no mainline tracking) for clone ${clone}`
|
|
26969
26975
|
);
|
|
26970
|
-
return
|
|
26976
|
+
return path109;
|
|
26971
26977
|
}
|
|
26972
26978
|
|
|
26973
26979
|
// src/commands/sessions/daemon/worktree/keptInTree.ts
|
|
@@ -27103,13 +27109,13 @@ function allocateTree(requestedCwd, boundTreeRoots2, options2 = {}) {
|
|
|
27103
27109
|
if (forcedSpill) daemonLog(forcedSpill);
|
|
27104
27110
|
else if (reusesClone(clone, boundTreeRoots2, options2))
|
|
27105
27111
|
return { cwd: clone, kind: "primary", created: false, clone };
|
|
27106
|
-
const
|
|
27112
|
+
const path109 = createWorktree(
|
|
27107
27113
|
clone,
|
|
27108
27114
|
{ root: cfg.root, trunk: cfg.trunk },
|
|
27109
27115
|
boundTreeRoots2,
|
|
27110
27116
|
options2.replacesTree
|
|
27111
27117
|
);
|
|
27112
|
-
return { cwd:
|
|
27118
|
+
return { cwd: path109, kind: "worktree", created: true, clone };
|
|
27113
27119
|
}
|
|
27114
27120
|
|
|
27115
27121
|
// src/commands/sessions/daemon/describePersistedSession.ts
|
|
@@ -27508,13 +27514,13 @@ function worktreeHoldingBranch(cwd, branch2) {
|
|
|
27508
27514
|
const listing = gitSyncOrNull(cwd, ["worktree", "list", "--porcelain"]);
|
|
27509
27515
|
if (!listing) return null;
|
|
27510
27516
|
const here = gitSyncOrNull(cwd, ["rev-parse", "--show-toplevel"]);
|
|
27511
|
-
let
|
|
27517
|
+
let path109 = null;
|
|
27512
27518
|
for (const line of listing.split("\n")) {
|
|
27513
27519
|
const trimmed = line.trim();
|
|
27514
27520
|
if (trimmed.startsWith("worktree "))
|
|
27515
|
-
|
|
27521
|
+
path109 = trimmed.slice("worktree ".length).trim();
|
|
27516
27522
|
else if (trimmed === `branch refs/heads/${branch2}`)
|
|
27517
|
-
return
|
|
27523
|
+
return path109 && path109 !== here ? path109 : null;
|
|
27518
27524
|
}
|
|
27519
27525
|
return null;
|
|
27520
27526
|
}
|
|
@@ -28630,9 +28636,9 @@ function parseRscRows(flight) {
|
|
|
28630
28636
|
}
|
|
28631
28637
|
function makeRscResolver(rows) {
|
|
28632
28638
|
return (ref) => {
|
|
28633
|
-
const [id, ...
|
|
28639
|
+
const [id, ...path109] = ref.slice(1).replace(/^[L@]/, "").split(":");
|
|
28634
28640
|
let v = rows[id];
|
|
28635
|
-
for (const key of
|
|
28641
|
+
for (const key of path109) {
|
|
28636
28642
|
if (v == null || typeof v !== "object") return void 0;
|
|
28637
28643
|
v = v[key];
|
|
28638
28644
|
}
|
|
@@ -29383,18 +29389,18 @@ function validateLine(line) {
|
|
|
29383
29389
|
process.exit(1);
|
|
29384
29390
|
}
|
|
29385
29391
|
}
|
|
29386
|
-
async function comment2(
|
|
29392
|
+
async function comment2(path109, line, body, options2 = {}) {
|
|
29387
29393
|
const { startLine, skipPreview } = options2;
|
|
29388
29394
|
validateBody(body);
|
|
29389
29395
|
validateLine(line);
|
|
29390
29396
|
if (startLine !== void 0) validateLine(startLine);
|
|
29391
29397
|
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
29392
29398
|
if (!skipPreview)
|
|
29393
|
-
await reviewProposedPrComment(`Comment on ${
|
|
29399
|
+
await reviewProposedPrComment(`Comment on ${path109}:${range}`, body, null);
|
|
29394
29400
|
try {
|
|
29395
29401
|
const prId = getCurrentPrNodeId();
|
|
29396
|
-
postReviewComment({ prId, body, path:
|
|
29397
|
-
console.log(`Added review comment on ${
|
|
29402
|
+
postReviewComment({ prId, body, path: path109, line, startLine });
|
|
29403
|
+
console.log(`Added review comment on ${path109}:${range}`);
|
|
29398
29404
|
} catch (error) {
|
|
29399
29405
|
if (isGhNotInstalled(error)) {
|
|
29400
29406
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -29971,9 +29977,9 @@ function registerPrsComments(prsCommand) {
|
|
|
29971
29977
|
});
|
|
29972
29978
|
prsCommand.command("comment <path> <line> <body>").description(
|
|
29973
29979
|
"Add a line comment to the pending review (body of - reads it from stdin)"
|
|
29974
|
-
).action(async (
|
|
29980
|
+
).action(async (path109, line, body) => {
|
|
29975
29981
|
await comment2(
|
|
29976
|
-
|
|
29982
|
+
path109,
|
|
29977
29983
|
Number.parseInt(line, 10),
|
|
29978
29984
|
await readBodyArgument(body)
|
|
29979
29985
|
);
|
|
@@ -30099,9 +30105,9 @@ function splitOnce(value, separator) {
|
|
|
30099
30105
|
if (index2 === -1) return null;
|
|
30100
30106
|
return [value.slice(0, index2), value.slice(index2 + separator.length)];
|
|
30101
30107
|
}
|
|
30102
|
-
function isFile2(
|
|
30108
|
+
function isFile2(path109) {
|
|
30103
30109
|
try {
|
|
30104
|
-
return statSync10(
|
|
30110
|
+
return statSync10(path109).isFile();
|
|
30105
30111
|
} catch {
|
|
30106
30112
|
return false;
|
|
30107
30113
|
}
|
|
@@ -30109,16 +30115,16 @@ function isFile2(path108) {
|
|
|
30109
30115
|
function parseScreenshotSpec(spec) {
|
|
30110
30116
|
const [label2, rawPath] = splitOnce(spec, "=") ?? ["", spec];
|
|
30111
30117
|
const [group, caption] = splitOnce(label2, "/") ?? ["", label2];
|
|
30112
|
-
const
|
|
30113
|
-
const ext = extname5(
|
|
30114
|
-
if (!isFile2(
|
|
30115
|
-
throw new Error(`--screenshot '${spec}': file not found: ${
|
|
30118
|
+
const path109 = resolve23(rawPath.trim());
|
|
30119
|
+
const ext = extname5(path109).replace(/^\./, "").toLowerCase();
|
|
30120
|
+
if (!isFile2(path109))
|
|
30121
|
+
throw new Error(`--screenshot '${spec}': file not found: ${path109}`);
|
|
30116
30122
|
if (!ghAttachableExtensions.has(ext))
|
|
30117
30123
|
throw new Error(
|
|
30118
30124
|
`--screenshot '${spec}': gh cannot attach .${ext || "(none)"} files (supported: ${[...ghAttachableExtensions].join(", ")}).`
|
|
30119
30125
|
);
|
|
30120
|
-
const alt = caption.trim() || basename22(
|
|
30121
|
-
return group.trim() ? { path:
|
|
30126
|
+
const alt = caption.trim() || basename22(path109, extname5(path109));
|
|
30127
|
+
return group.trim() ? { path: path109, alt, group: group.trim() } : { path: path109, alt };
|
|
30122
30128
|
}
|
|
30123
30129
|
|
|
30124
30130
|
// src/commands/prs/parseScreenshotSpecs.ts
|
|
@@ -31255,11 +31261,11 @@ async function loadBody(target) {
|
|
|
31255
31261
|
if (target.kind === "file") return readDraftFile(target.path);
|
|
31256
31262
|
return fetchPrBody(target.number, target.repo);
|
|
31257
31263
|
}
|
|
31258
|
-
function readDraftFile(
|
|
31264
|
+
function readDraftFile(path109) {
|
|
31259
31265
|
try {
|
|
31260
|
-
return readFileSync46(
|
|
31266
|
+
return readFileSync46(path109, "utf8");
|
|
31261
31267
|
} catch {
|
|
31262
|
-
console.error(`Error: Could not read \`${
|
|
31268
|
+
console.error(`Error: Could not read \`${path109}\`.`);
|
|
31263
31269
|
console.error(
|
|
31264
31270
|
"Pass a pull request number, a GitHub pull request URL, - for stdin, or a path to a file."
|
|
31265
31271
|
);
|
|
@@ -31539,10 +31545,10 @@ function resolveOpSecret(reference) {
|
|
|
31539
31545
|
}
|
|
31540
31546
|
|
|
31541
31547
|
// src/commands/ravendb/ravenFetch.ts
|
|
31542
|
-
async function ravenFetch(connection,
|
|
31548
|
+
async function ravenFetch(connection, path109) {
|
|
31543
31549
|
const apiKey = resolveOpSecret(connection.apiKeyRef);
|
|
31544
31550
|
let accessToken = await getAccessToken(apiKey);
|
|
31545
|
-
const url = `${connection.url}${
|
|
31551
|
+
const url = `${connection.url}${path109}`;
|
|
31546
31552
|
const headers = {
|
|
31547
31553
|
Authorization: `Bearer ${accessToken}`,
|
|
31548
31554
|
"Content-Type": "application/json"
|
|
@@ -31632,16 +31638,16 @@ import chalk201 from "chalk";
|
|
|
31632
31638
|
// src/commands/ravendb/buildQueryPath.ts
|
|
31633
31639
|
function buildQueryPath(opts) {
|
|
31634
31640
|
const db = encodeURIComponent(opts.db);
|
|
31635
|
-
let
|
|
31641
|
+
let path109;
|
|
31636
31642
|
if (opts.collection) {
|
|
31637
|
-
|
|
31643
|
+
path109 = `/databases/${db}/indexes/dynamic/${encodeURIComponent(opts.collection)}?start=${opts.start}&pageSize=${opts.pageSize}&sort=${encodeURIComponent(opts.sort)}`;
|
|
31638
31644
|
} else {
|
|
31639
|
-
|
|
31645
|
+
path109 = `/databases/${db}/queries?start=${opts.start}&pageSize=${opts.pageSize}`;
|
|
31640
31646
|
}
|
|
31641
31647
|
if (opts.query) {
|
|
31642
|
-
|
|
31648
|
+
path109 += `&query=${encodeURIComponent(opts.query)}`;
|
|
31643
31649
|
}
|
|
31644
|
-
return
|
|
31650
|
+
return path109;
|
|
31645
31651
|
}
|
|
31646
31652
|
|
|
31647
31653
|
// src/commands/ravendb/fetchAllPages.ts
|
|
@@ -31650,7 +31656,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
31650
31656
|
let start2 = 0;
|
|
31651
31657
|
while (true) {
|
|
31652
31658
|
const effectivePageSize = opts.limit !== void 0 ? Math.min(opts.pageSize, opts.limit - allResults.length) : opts.pageSize;
|
|
31653
|
-
const
|
|
31659
|
+
const path109 = buildQueryPath({
|
|
31654
31660
|
db: connection.database,
|
|
31655
31661
|
collection: opts.collection,
|
|
31656
31662
|
start: start2,
|
|
@@ -31658,7 +31664,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
31658
31664
|
sort: opts.sort,
|
|
31659
31665
|
query: opts.query
|
|
31660
31666
|
});
|
|
31661
|
-
const data = await ravenFetch(connection,
|
|
31667
|
+
const data = await ravenFetch(connection, path109);
|
|
31662
31668
|
const results = data.Results ?? [];
|
|
31663
31669
|
const totalResults = data.TotalResults ?? 0;
|
|
31664
31670
|
if (results.length === 0) break;
|
|
@@ -34168,8 +34174,8 @@ Renamed ${oldName} \u2192 ${newName}`));
|
|
|
34168
34174
|
|
|
34169
34175
|
// src/commands/refactor/restructure.ts
|
|
34170
34176
|
import fs38 from "fs";
|
|
34171
|
-
import
|
|
34172
|
-
import
|
|
34177
|
+
import path83 from "path";
|
|
34178
|
+
import chalk230 from "chalk";
|
|
34173
34179
|
|
|
34174
34180
|
// src/commands/refactor/restructure/buildPlan.ts
|
|
34175
34181
|
import path73 from "path";
|
|
@@ -34506,7 +34512,7 @@ function buildPlan3(scopeRoot, files, ignored = [], pinnedModules = []) {
|
|
|
34506
34512
|
}
|
|
34507
34513
|
|
|
34508
34514
|
// src/commands/refactor/restructure/checkPlan.ts
|
|
34509
|
-
import
|
|
34515
|
+
import chalk225 from "chalk";
|
|
34510
34516
|
|
|
34511
34517
|
// src/commands/refactor/restructure/applyCommand.ts
|
|
34512
34518
|
import path74 from "path";
|
|
@@ -34538,7 +34544,7 @@ function displayDrift(plan2, listMoves) {
|
|
|
34538
34544
|
}
|
|
34539
34545
|
|
|
34540
34546
|
// src/commands/refactor/restructure/displayLayoutLimits.ts
|
|
34541
|
-
import
|
|
34547
|
+
import chalk224 from "chalk";
|
|
34542
34548
|
|
|
34543
34549
|
// src/commands/refactor/restructure/displayDeepChains.ts
|
|
34544
34550
|
import chalk222 from "chalk";
|
|
@@ -34567,25 +34573,40 @@ Plan exceeds restructure.maxDepth ${maxDepth}: ${tooDeep} file(s) deeper.`
|
|
|
34567
34573
|
console.log(chalk222.dim(` \u2026and ${chains.length - shownChains} more`));
|
|
34568
34574
|
}
|
|
34569
34575
|
|
|
34576
|
+
// src/commands/refactor/restructure/displayLongPaths.ts
|
|
34577
|
+
import chalk223 from "chalk";
|
|
34578
|
+
function displayLongPaths(longPaths, maxPathLength) {
|
|
34579
|
+
if (longPaths.length === 0) return;
|
|
34580
|
+
console.log(
|
|
34581
|
+
chalk223.red(
|
|
34582
|
+
`
|
|
34583
|
+
Plan exceeds restructure.maxPathLength ${maxPathLength}: ${longPaths.length} repo-relative path(s) longer.`
|
|
34584
|
+
)
|
|
34585
|
+
);
|
|
34586
|
+
for (const { path: path109, length } of longPaths)
|
|
34587
|
+
console.log(` ${path109} [${length}]`);
|
|
34588
|
+
}
|
|
34589
|
+
|
|
34570
34590
|
// src/commands/refactor/restructure/displayLayoutLimits.ts
|
|
34571
34591
|
function pinSteps(apply) {
|
|
34572
34592
|
return [
|
|
34573
34593
|
"Pin feature modules until this check passes:",
|
|
34574
|
-
"1. On each chain, pick the highest module that is a feature boundary: a route, view, page, panel, dialog or card. Never a hook, utility, style file or helper.",
|
|
34575
|
-
"2. Add it to restructure.pin in assist.yml yourself (basename without extension). One pin at a time: one feature pin often fixes several chains.",
|
|
34576
|
-
"3. Re-run this command. Repeat until the plan is within the
|
|
34577
|
-
"4. If a chain has no sensible feature boundary, stop and report
|
|
34594
|
+
"1. On each deep chain or long path, pick the highest module that is a feature boundary: a route, view, page, panel, dialog or card. Never a hook, utility, style file or helper.",
|
|
34595
|
+
"2. Add it to restructure.pin in assist.yml yourself (basename without extension). One pin at a time: one feature pin often fixes several chains or paths.",
|
|
34596
|
+
"3. Re-run this command. Repeat until the plan is within the limits.",
|
|
34597
|
+
"4. If a chain or path has no sensible feature boundary, stop and report it.",
|
|
34578
34598
|
`Then run \`${apply}\`.`
|
|
34579
34599
|
];
|
|
34580
34600
|
}
|
|
34581
34601
|
function exceedsLayoutLimits(limits) {
|
|
34582
|
-
return limits.chains.length > 0;
|
|
34602
|
+
return limits.chains.length > 0 || limits.longPaths.length > 0;
|
|
34583
34603
|
}
|
|
34584
34604
|
function displayLayoutLimits(limits, apply) {
|
|
34585
34605
|
if (!exceedsLayoutLimits(limits)) return;
|
|
34586
34606
|
displayDeepChains(limits.chains, limits.maxDepth);
|
|
34607
|
+
displayLongPaths(limits.longPaths, limits.maxPathLength);
|
|
34587
34608
|
console.log("");
|
|
34588
|
-
for (const line of pinSteps(apply)) console.log(
|
|
34609
|
+
for (const line of pinSteps(apply)) console.log(chalk224.yellow(line));
|
|
34589
34610
|
}
|
|
34590
34611
|
|
|
34591
34612
|
// src/commands/refactor/restructure/checkPlan.ts
|
|
@@ -34597,14 +34618,14 @@ function checkPlan(plan2, limits) {
|
|
|
34597
34618
|
if (exceeds || plan2.errors.length > 0) process.exit(1);
|
|
34598
34619
|
if (plan2.moves.length > 0) {
|
|
34599
34620
|
console.log(
|
|
34600
|
-
|
|
34621
|
+
chalk225.yellow(
|
|
34601
34622
|
`
|
|
34602
34623
|
Run \`${apply}\` to move the files and rewrite their imports.`
|
|
34603
34624
|
)
|
|
34604
34625
|
);
|
|
34605
34626
|
process.exit(1);
|
|
34606
34627
|
}
|
|
34607
|
-
console.log(
|
|
34628
|
+
console.log(chalk225.green("Layout matches the restructure plan"));
|
|
34608
34629
|
}
|
|
34609
34630
|
|
|
34610
34631
|
// src/commands/refactor/restructure/findDeepChains.ts
|
|
@@ -34645,20 +34666,28 @@ function findDeepChains(targets, scopeRoot, maxDepth) {
|
|
|
34645
34666
|
return [...chains.entries()].sort(([ka, a], [kb, b]) => b.tooDeep - a.tooDeep || ka.localeCompare(kb)).map(([, chain2]) => chain2);
|
|
34646
34667
|
}
|
|
34647
34668
|
|
|
34669
|
+
// src/commands/refactor/restructure/findLongPaths.ts
|
|
34670
|
+
import path77 from "path";
|
|
34671
|
+
function findLongPaths(targets, repoRoot2, maxPathLength) {
|
|
34672
|
+
return [...targets].map((t) => path77.relative(repoRoot2, t).split(path77.sep).join("/")).filter((p) => p.length > maxPathLength).map((p) => ({ path: p, length: p.length })).sort((a, b) => b.length - a.length || a.path.localeCompare(b.path));
|
|
34673
|
+
}
|
|
34674
|
+
|
|
34648
34675
|
// src/commands/refactor/restructure/checkLayoutLimits.ts
|
|
34649
|
-
function checkLayoutLimits(plan2, maxDepth) {
|
|
34676
|
+
function checkLayoutLimits(plan2, { maxDepth, maxPathLength, repoRoot: repoRoot2 }) {
|
|
34650
34677
|
return {
|
|
34651
34678
|
maxDepth,
|
|
34652
|
-
chains: findDeepChains(plan2.targets.values(), plan2.scopeRoot, maxDepth)
|
|
34679
|
+
chains: findDeepChains(plan2.targets.values(), plan2.scopeRoot, maxDepth),
|
|
34680
|
+
maxPathLength,
|
|
34681
|
+
longPaths: findLongPaths(plan2.targets.values(), repoRoot2, maxPathLength)
|
|
34653
34682
|
};
|
|
34654
34683
|
}
|
|
34655
34684
|
|
|
34656
34685
|
// src/commands/refactor/restructure/partitionIgnored.ts
|
|
34657
|
-
import
|
|
34686
|
+
import path78 from "path";
|
|
34658
34687
|
import { minimatch as minimatch4 } from "minimatch";
|
|
34659
34688
|
function partitionIgnored(files) {
|
|
34660
34689
|
const globs = loadConfig().restructure?.ignore ?? [];
|
|
34661
|
-
const isIgnored = (file) => globs.some((glob) => minimatch4(
|
|
34690
|
+
const isIgnored = (file) => globs.some((glob) => minimatch4(path78.relative(process.cwd(), file), glob));
|
|
34662
34691
|
return {
|
|
34663
34692
|
scoped: files.filter((f) => !isIgnored(f)),
|
|
34664
34693
|
ignored: files.filter(isIgnored)
|
|
@@ -34666,17 +34695,17 @@ function partitionIgnored(files) {
|
|
|
34666
34695
|
}
|
|
34667
34696
|
|
|
34668
34697
|
// src/commands/refactor/restructure/runPlan.ts
|
|
34669
|
-
import
|
|
34698
|
+
import chalk229 from "chalk";
|
|
34670
34699
|
|
|
34671
34700
|
// src/commands/refactor/restructure/applyPlan.ts
|
|
34672
|
-
import
|
|
34701
|
+
import chalk227 from "chalk";
|
|
34673
34702
|
|
|
34674
34703
|
// src/commands/refactor/restructure/executePlan.ts
|
|
34675
34704
|
import fs37 from "fs";
|
|
34676
|
-
import
|
|
34677
|
-
import
|
|
34705
|
+
import path79 from "path";
|
|
34706
|
+
import chalk226 from "chalk";
|
|
34678
34707
|
function relPath(file) {
|
|
34679
|
-
return
|
|
34708
|
+
return path79.relative(process.cwd(), file);
|
|
34680
34709
|
}
|
|
34681
34710
|
function stagingPath(move2, index2) {
|
|
34682
34711
|
return `${move2.from}.restructure-${process.pid}-${index2}`;
|
|
@@ -34688,34 +34717,34 @@ function moveFiles(moves) {
|
|
|
34688
34717
|
return { move: move2, staging };
|
|
34689
34718
|
});
|
|
34690
34719
|
for (const { move: move2, staging } of staged) {
|
|
34691
|
-
fs37.mkdirSync(
|
|
34720
|
+
fs37.mkdirSync(path79.dirname(move2.to), { recursive: true });
|
|
34692
34721
|
fs37.renameSync(staging, move2.to);
|
|
34693
34722
|
console.log(
|
|
34694
|
-
|
|
34723
|
+
chalk226.white(` Moved ${relPath(move2.from)} \u2192 ${relPath(move2.to)}`)
|
|
34695
34724
|
);
|
|
34696
34725
|
}
|
|
34697
34726
|
}
|
|
34698
34727
|
function removeIfEmpty(dir) {
|
|
34699
34728
|
if (!fs37.existsSync(dir) || fs37.readdirSync(dir).length > 0) return false;
|
|
34700
34729
|
fs37.rmdirSync(dir);
|
|
34701
|
-
console.log(
|
|
34730
|
+
console.log(chalk226.dim(` Removed empty directory ${relPath(dir)}`));
|
|
34702
34731
|
return true;
|
|
34703
34732
|
}
|
|
34704
34733
|
function removeEmptyDirectories(dirs, scopeRoot) {
|
|
34705
34734
|
const deepestFirst = [...new Set(dirs)].sort((a, b) => b.length - a.length);
|
|
34706
34735
|
for (let dir of deepestFirst) {
|
|
34707
|
-
while (dir.startsWith(`${scopeRoot}${
|
|
34708
|
-
dir =
|
|
34736
|
+
while (dir.startsWith(`${scopeRoot}${path79.sep}`) && removeIfEmpty(dir))
|
|
34737
|
+
dir = path79.dirname(dir);
|
|
34709
34738
|
}
|
|
34710
34739
|
}
|
|
34711
34740
|
function executePlan(plan2) {
|
|
34712
34741
|
for (const [file, content] of applyRewrites(plan2.rewrites)) {
|
|
34713
34742
|
fs37.writeFileSync(file, content, "utf8");
|
|
34714
|
-
console.log(
|
|
34743
|
+
console.log(chalk226.cyan(` Rewrote imports in ${relPath(file)}`));
|
|
34715
34744
|
}
|
|
34716
34745
|
moveFiles(plan2.moves);
|
|
34717
34746
|
removeEmptyDirectories(
|
|
34718
|
-
plan2.moves.map((m) =>
|
|
34747
|
+
plan2.moves.map((m) => path79.dirname(m.from)),
|
|
34719
34748
|
plan2.scopeRoot
|
|
34720
34749
|
);
|
|
34721
34750
|
}
|
|
@@ -34723,26 +34752,26 @@ function executePlan(plan2) {
|
|
|
34723
34752
|
// src/commands/refactor/restructure/applyPlan.ts
|
|
34724
34753
|
function applyPlan(plan2) {
|
|
34725
34754
|
if (plan2.errors.length > 0) {
|
|
34726
|
-
console.log(
|
|
34755
|
+
console.log(chalk227.red("\nResolve the errors above before applying."));
|
|
34727
34756
|
process.exit(1);
|
|
34728
34757
|
}
|
|
34729
|
-
console.log(
|
|
34758
|
+
console.log(chalk227.bold("\nApplying changes..."));
|
|
34730
34759
|
executePlan(plan2);
|
|
34731
|
-
console.log(
|
|
34760
|
+
console.log(chalk227.green("\nRestructuring complete"));
|
|
34732
34761
|
}
|
|
34733
34762
|
|
|
34734
34763
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
34735
|
-
import
|
|
34736
|
-
import
|
|
34764
|
+
import path82 from "path";
|
|
34765
|
+
import chalk228 from "chalk";
|
|
34737
34766
|
|
|
34738
34767
|
// src/commands/refactor/restructure/computeDepthStats.ts
|
|
34739
|
-
import
|
|
34768
|
+
import path80 from "path";
|
|
34740
34769
|
function computeDepthStats(targets, scopeRoot) {
|
|
34741
34770
|
const distribution = /* @__PURE__ */ new Map();
|
|
34742
34771
|
let max = 0;
|
|
34743
34772
|
for (const target of targets) {
|
|
34744
|
-
const dir =
|
|
34745
|
-
const depth = dir === "" ? 0 : dir.split(
|
|
34773
|
+
const dir = path80.relative(scopeRoot, path80.dirname(target));
|
|
34774
|
+
const depth = dir === "" ? 0 : dir.split(path80.sep).length;
|
|
34746
34775
|
distribution.set(depth, (distribution.get(depth) ?? 0) + 1);
|
|
34747
34776
|
max = Math.max(max, depth);
|
|
34748
34777
|
}
|
|
@@ -34750,7 +34779,7 @@ function computeDepthStats(targets, scopeRoot) {
|
|
|
34750
34779
|
}
|
|
34751
34780
|
|
|
34752
34781
|
// src/commands/refactor/restructure/formatTree.ts
|
|
34753
|
-
import
|
|
34782
|
+
import path81 from "path";
|
|
34754
34783
|
function insert(root2, parts) {
|
|
34755
34784
|
let node = root2;
|
|
34756
34785
|
for (const part of parts) {
|
|
@@ -34772,7 +34801,7 @@ function render(node, indent3, lines2) {
|
|
|
34772
34801
|
function formatTree(files, scopeRoot) {
|
|
34773
34802
|
const root2 = /* @__PURE__ */ new Map();
|
|
34774
34803
|
for (const file of files)
|
|
34775
|
-
insert(root2,
|
|
34804
|
+
insert(root2, path81.relative(scopeRoot, file).split(path81.sep));
|
|
34776
34805
|
const lines2 = [];
|
|
34777
34806
|
render(root2, "", lines2);
|
|
34778
34807
|
return lines2;
|
|
@@ -34780,21 +34809,21 @@ function formatTree(files, scopeRoot) {
|
|
|
34780
34809
|
|
|
34781
34810
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
34782
34811
|
function relPath2(filePath) {
|
|
34783
|
-
return
|
|
34812
|
+
return path82.relative(process.cwd(), filePath);
|
|
34784
34813
|
}
|
|
34785
34814
|
function displayMoves(plan2) {
|
|
34786
34815
|
if (plan2.moves.length === 0) return;
|
|
34787
|
-
console.log(
|
|
34816
|
+
console.log(chalk228.bold("\nFile moves:"));
|
|
34788
34817
|
for (const move2 of plan2.moves) {
|
|
34789
34818
|
console.log(
|
|
34790
|
-
` ${
|
|
34819
|
+
` ${chalk228.red(relPath2(move2.from))} \u2192 ${chalk228.green(relPath2(move2.to))}`
|
|
34791
34820
|
);
|
|
34792
|
-
console.log(
|
|
34821
|
+
console.log(chalk228.dim(` ${move2.reason}`));
|
|
34793
34822
|
}
|
|
34794
34823
|
}
|
|
34795
34824
|
function displayTree(plan2) {
|
|
34796
34825
|
console.log(
|
|
34797
|
-
|
|
34826
|
+
chalk228.bold(`
|
|
34798
34827
|
Resulting tree (${relPath2(plan2.scopeRoot) || "."}/):`)
|
|
34799
34828
|
);
|
|
34800
34829
|
for (const line of formatTree(plan2.targets.values(), plan2.scopeRoot))
|
|
@@ -34805,15 +34834,15 @@ function displayDepthStats(plan2) {
|
|
|
34805
34834
|
plan2.targets.values(),
|
|
34806
34835
|
plan2.scopeRoot
|
|
34807
34836
|
);
|
|
34808
|
-
console.log(
|
|
34837
|
+
console.log(chalk228.bold(`
|
|
34809
34838
|
Depth (max ${max}):`));
|
|
34810
34839
|
for (const depth of [...distribution.keys()].sort((a, b) => a - b))
|
|
34811
34840
|
console.log(` ${depth}: ${distribution.get(depth)} file(s)`);
|
|
34812
34841
|
}
|
|
34813
34842
|
function displayErrors(errors) {
|
|
34814
34843
|
if (errors.length === 0) return;
|
|
34815
|
-
console.log(
|
|
34816
|
-
for (const error of errors) console.log(
|
|
34844
|
+
console.log(chalk228.red("\nErrors:"));
|
|
34845
|
+
for (const error of errors) console.log(chalk228.red(` ${error}`));
|
|
34817
34846
|
}
|
|
34818
34847
|
function displayPlan2(plan2) {
|
|
34819
34848
|
displayMoves(plan2);
|
|
@@ -34822,7 +34851,7 @@ function displayPlan2(plan2) {
|
|
|
34822
34851
|
displayErrors(plan2.errors);
|
|
34823
34852
|
const rewrittenFiles = new Set(plan2.rewrites.map((r) => r.file)).size;
|
|
34824
34853
|
console.log(
|
|
34825
|
-
|
|
34854
|
+
chalk228.dim(
|
|
34826
34855
|
`
|
|
34827
34856
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten across ${rewrittenFiles} file(s), ${plan2.errors.length} error(s)`
|
|
34828
34857
|
)
|
|
@@ -34834,11 +34863,11 @@ function runPlan(plan2, limits, apply) {
|
|
|
34834
34863
|
displayPlan2(plan2);
|
|
34835
34864
|
displayLayoutLimits(limits, applyCommand(plan2.scopeRoot));
|
|
34836
34865
|
if (plan2.moves.length === 0 && plan2.errors.length === 0) {
|
|
34837
|
-
console.log(
|
|
34866
|
+
console.log(chalk229.green("No restructuring needed"));
|
|
34838
34867
|
return;
|
|
34839
34868
|
}
|
|
34840
34869
|
if (!apply) {
|
|
34841
|
-
console.log(
|
|
34870
|
+
console.log(chalk229.dim("\nDry run. Use --apply to execute."));
|
|
34842
34871
|
return;
|
|
34843
34872
|
}
|
|
34844
34873
|
applyPlan(plan2);
|
|
@@ -34846,21 +34875,30 @@ function runPlan(plan2, limits, apply) {
|
|
|
34846
34875
|
|
|
34847
34876
|
// src/commands/refactor/restructure.ts
|
|
34848
34877
|
async function restructure(root2, options2 = {}) {
|
|
34849
|
-
const scopeRoot =
|
|
34878
|
+
const scopeRoot = path83.resolve(root2 ?? "src");
|
|
34850
34879
|
if (!fs38.existsSync(scopeRoot) || !fs38.statSync(scopeRoot).isDirectory()) {
|
|
34851
|
-
console.log(
|
|
34880
|
+
console.log(chalk230.red(`Not a directory: ${root2 ?? "src"}`));
|
|
34852
34881
|
process.exit(1);
|
|
34853
34882
|
}
|
|
34854
34883
|
const found = [];
|
|
34855
34884
|
walkSourceFiles(scopeRoot, found);
|
|
34856
34885
|
const { scoped, ignored } = partitionIgnored(found);
|
|
34857
34886
|
if (scoped.length === 0) {
|
|
34858
|
-
console.log(
|
|
34887
|
+
console.log(chalk230.yellow("No files found under root"));
|
|
34859
34888
|
return;
|
|
34860
34889
|
}
|
|
34861
|
-
const {
|
|
34890
|
+
const {
|
|
34891
|
+
pin: pin2 = [],
|
|
34892
|
+
maxDepth = 10,
|
|
34893
|
+
maxPathLength = 200
|
|
34894
|
+
} = loadConfig().restructure ?? {};
|
|
34862
34895
|
const plan2 = buildPlan3(scopeRoot, scoped, ignored, pin2);
|
|
34863
|
-
const
|
|
34896
|
+
const repoRoot2 = tryGit2(`-C "${scopeRoot}" rev-parse --show-toplevel`) ?? process.cwd();
|
|
34897
|
+
const limits = checkLayoutLimits(plan2, {
|
|
34898
|
+
maxDepth,
|
|
34899
|
+
maxPathLength,
|
|
34900
|
+
repoRoot: repoRoot2
|
|
34901
|
+
});
|
|
34864
34902
|
if (options2.check) return checkPlan(plan2, limits);
|
|
34865
34903
|
runPlan(plan2, limits, options2.apply === true);
|
|
34866
34904
|
}
|
|
@@ -34917,7 +34955,7 @@ async function checkoutPrSession(number, prompt = "", permissionMode = "acceptEd
|
|
|
34917
34955
|
}
|
|
34918
34956
|
|
|
34919
34957
|
// src/commands/review/highLevel/configureHighLevelReview.ts
|
|
34920
|
-
import
|
|
34958
|
+
import chalk234 from "chalk";
|
|
34921
34959
|
|
|
34922
34960
|
// src/commands/config/promptConfigScope.ts
|
|
34923
34961
|
import Enquirer3 from "enquirer";
|
|
@@ -34943,7 +34981,7 @@ async function promptConfigScope() {
|
|
|
34943
34981
|
}
|
|
34944
34982
|
|
|
34945
34983
|
// src/commands/config/resolveConfigKeyAnswer.ts
|
|
34946
|
-
import
|
|
34984
|
+
import chalk231 from "chalk";
|
|
34947
34985
|
async function resolveConfigKeyAnswer(question, supplied) {
|
|
34948
34986
|
if (supplied !== void 0) return coerceSupplied(question.key, supplied);
|
|
34949
34987
|
for (; ; ) {
|
|
@@ -34951,7 +34989,7 @@ async function resolveConfigKeyAnswer(question, supplied) {
|
|
|
34951
34989
|
if (answer === "") return void 0;
|
|
34952
34990
|
const coercion = coerceCliConfigValue(question.key, answer);
|
|
34953
34991
|
if (coercion.ok) return coercion.value;
|
|
34954
|
-
console.error(
|
|
34992
|
+
console.error(chalk231.red(coercion.error));
|
|
34955
34993
|
}
|
|
34956
34994
|
}
|
|
34957
34995
|
function coerceSupplied(key, supplied) {
|
|
@@ -35018,7 +35056,7 @@ function suggestGlobs(current, proposed) {
|
|
|
35018
35056
|
}
|
|
35019
35057
|
|
|
35020
35058
|
// src/commands/review/highLevel/parseConfigureAnswers.ts
|
|
35021
|
-
import
|
|
35059
|
+
import chalk232 from "chalk";
|
|
35022
35060
|
function parseConfigureAnswers(answers) {
|
|
35023
35061
|
const known = Object.values(highLevelConfigKeys);
|
|
35024
35062
|
const parsed = {};
|
|
@@ -35036,13 +35074,13 @@ function answersCoverEveryKey(answers) {
|
|
|
35036
35074
|
return Object.values(highLevelConfigKeys).every((key) => key in answers);
|
|
35037
35075
|
}
|
|
35038
35076
|
function exitWith(message3) {
|
|
35039
|
-
console.error(
|
|
35077
|
+
console.error(chalk232.red(`Error: ${message3}.`));
|
|
35040
35078
|
process.exit(1);
|
|
35041
35079
|
}
|
|
35042
35080
|
|
|
35043
35081
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
35044
35082
|
import { execFileSync as execFileSync21 } from "child_process";
|
|
35045
|
-
import
|
|
35083
|
+
import chalk233 from "chalk";
|
|
35046
35084
|
|
|
35047
35085
|
// src/commands/review/highLevel/buildGlobProposalPrompt.ts
|
|
35048
35086
|
function buildGlobProposalPrompt(tree) {
|
|
@@ -35135,12 +35173,12 @@ function proposeHighLevelGlobs(cwd = process.cwd()) {
|
|
|
35135
35173
|
const tree = summariseRepoTree(cwd);
|
|
35136
35174
|
if (tree === "") return NOTHING_PROPOSED;
|
|
35137
35175
|
console.log(
|
|
35138
|
-
|
|
35176
|
+
chalk233.dim("Asking Claude to propose globs from the repo's own tree...")
|
|
35139
35177
|
);
|
|
35140
35178
|
const output = askClaude(buildGlobProposalPrompt(tree), cwd);
|
|
35141
35179
|
if (output === void 0) {
|
|
35142
35180
|
console.log(
|
|
35143
|
-
|
|
35181
|
+
chalk233.yellow(
|
|
35144
35182
|
"Claude proposed nothing; answer each key from its current value."
|
|
35145
35183
|
)
|
|
35146
35184
|
);
|
|
@@ -35200,25 +35238,25 @@ function asConfigKeyScope(value) {
|
|
|
35200
35238
|
function reportConfigured(result) {
|
|
35201
35239
|
for (const write of result.written)
|
|
35202
35240
|
console.log(
|
|
35203
|
-
|
|
35241
|
+
chalk234.green(`Set ${write.key} = ${JSON.stringify(write.value)}`)
|
|
35204
35242
|
);
|
|
35205
|
-
for (const key of result.skipped) console.log(
|
|
35206
|
-
console.log(
|
|
35243
|
+
for (const key of result.skipped) console.log(chalk234.dim(`Left ${key} unset`));
|
|
35244
|
+
console.log(chalk234.dim(`Written to ${result.target}`));
|
|
35207
35245
|
}
|
|
35208
35246
|
|
|
35209
35247
|
// src/commands/review/highLevel/announceSavedReview.ts
|
|
35210
|
-
import
|
|
35248
|
+
import chalk235 from "chalk";
|
|
35211
35249
|
function announceSavedReview(subject, force) {
|
|
35212
35250
|
const head = subject.headSha.slice(0, 7);
|
|
35213
35251
|
if (subject.saved)
|
|
35214
35252
|
console.log(
|
|
35215
|
-
|
|
35253
|
+
chalk235.dim(
|
|
35216
35254
|
`Reopening the review saved for ${head} at ${subject.saved.reviewedAt} (${subject.saved.verdict}); pass --force to start fresh.`
|
|
35217
35255
|
)
|
|
35218
35256
|
);
|
|
35219
35257
|
else if (force)
|
|
35220
35258
|
console.log(
|
|
35221
|
-
|
|
35259
|
+
chalk235.dim(
|
|
35222
35260
|
`Discarding any review saved for ${head} and starting fresh (--force).`
|
|
35223
35261
|
)
|
|
35224
35262
|
);
|
|
@@ -35247,8 +35285,8 @@ function groupFilesByDirectory(files) {
|
|
|
35247
35285
|
}
|
|
35248
35286
|
|
|
35249
35287
|
// src/commands/review/highLevel/buildHighLevelTree.ts
|
|
35250
|
-
function basename24(
|
|
35251
|
-
return
|
|
35288
|
+
function basename24(path109) {
|
|
35289
|
+
return path109.slice(path109.lastIndexOf("/") + 1);
|
|
35252
35290
|
}
|
|
35253
35291
|
function sum(nodes, key) {
|
|
35254
35292
|
return nodes.reduce((total, node) => total + node[key], 0);
|
|
@@ -35271,19 +35309,19 @@ function nodesOf(at2, prefix2) {
|
|
|
35271
35309
|
}
|
|
35272
35310
|
function collapsedDirNode(name, at2, prefix2) {
|
|
35273
35311
|
let label2 = name;
|
|
35274
|
-
let
|
|
35312
|
+
let path109 = prefix2 ? `${prefix2}/${name}` : name;
|
|
35275
35313
|
let node = at2;
|
|
35276
35314
|
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
35277
35315
|
const [childName, child] = [...node.dirs][0];
|
|
35278
35316
|
label2 = `${label2}/${childName}`;
|
|
35279
|
-
|
|
35317
|
+
path109 = `${path109}/${childName}`;
|
|
35280
35318
|
node = child;
|
|
35281
35319
|
}
|
|
35282
|
-
const children = nodesOf(node,
|
|
35320
|
+
const children = nodesOf(node, path109);
|
|
35283
35321
|
return {
|
|
35284
35322
|
kind: "dir",
|
|
35285
35323
|
name: label2,
|
|
35286
|
-
path:
|
|
35324
|
+
path: path109,
|
|
35287
35325
|
additions: sum(children, "additions"),
|
|
35288
35326
|
deletions: sum(children, "deletions"),
|
|
35289
35327
|
children
|
|
@@ -35490,13 +35528,13 @@ function visit(node, context) {
|
|
|
35490
35528
|
}
|
|
35491
35529
|
];
|
|
35492
35530
|
}
|
|
35493
|
-
function extractTestHierarchy(
|
|
35531
|
+
function extractTestHierarchy(path109, text18, changed) {
|
|
35494
35532
|
const project = new Project4({
|
|
35495
35533
|
useInMemoryFileSystem: true,
|
|
35496
35534
|
compilerOptions: { allowJs: true }
|
|
35497
35535
|
});
|
|
35498
|
-
const source = project.createSourceFile(`/${
|
|
35499
|
-
return collect7(source, { path:
|
|
35536
|
+
const source = project.createSourceFile(`/${path109}`, text18);
|
|
35537
|
+
return collect7(source, { path: path109, ...changed ? { changed } : {} });
|
|
35500
35538
|
}
|
|
35501
35539
|
|
|
35502
35540
|
// src/commands/review/highLevel/patchAddedLines.ts
|
|
@@ -35524,8 +35562,8 @@ function testFile(file, repoRoot2) {
|
|
|
35524
35562
|
changed
|
|
35525
35563
|
);
|
|
35526
35564
|
if (tests.length === 0) return [];
|
|
35527
|
-
const { path:
|
|
35528
|
-
return [{ path:
|
|
35565
|
+
const { path: path109, status: status2, additions, deletions, diffUrl: diffUrl2 } = file;
|
|
35566
|
+
return [{ path: path109, status: status2, additions, deletions, diffUrl: diffUrl2, tests }];
|
|
35529
35567
|
}
|
|
35530
35568
|
function collectHighLevelTests(files, testPaths, repoRoot2) {
|
|
35531
35569
|
return files.filter(
|
|
@@ -35714,8 +35752,8 @@ function toStatus(status2) {
|
|
|
35714
35752
|
if (status2 === "removed") return "removed";
|
|
35715
35753
|
return "modified";
|
|
35716
35754
|
}
|
|
35717
|
-
function diffUrl(repo, prNumber,
|
|
35718
|
-
const anchor = createHash4("sha256").update(
|
|
35755
|
+
function diffUrl(repo, prNumber, path109) {
|
|
35756
|
+
const anchor = createHash4("sha256").update(path109).digest("hex");
|
|
35719
35757
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
35720
35758
|
}
|
|
35721
35759
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
@@ -35774,10 +35812,10 @@ function highLevelReviewPath(repo, headRef, headSha) {
|
|
|
35774
35812
|
|
|
35775
35813
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
35776
35814
|
function loadHighLevelReview(repo, headRef, headSha) {
|
|
35777
|
-
const
|
|
35778
|
-
if (!existsSync66(
|
|
35815
|
+
const path109 = highLevelReviewPath(repo, headRef, headSha);
|
|
35816
|
+
if (!existsSync66(path109)) return void 0;
|
|
35779
35817
|
try {
|
|
35780
|
-
return JSON.parse(readFileSync50(
|
|
35818
|
+
return JSON.parse(readFileSync50(path109, "utf8"));
|
|
35781
35819
|
} catch {
|
|
35782
35820
|
return void 0;
|
|
35783
35821
|
}
|
|
@@ -35788,8 +35826,8 @@ import { minimatch as minimatch8 } from "minimatch";
|
|
|
35788
35826
|
function selectCriticalDiffs(files, criticalPaths) {
|
|
35789
35827
|
if (criticalPaths.length === 0) return [];
|
|
35790
35828
|
return files.filter((file) => criticalPaths.some((glob) => minimatch8(file.path, glob))).map(
|
|
35791
|
-
({ path:
|
|
35792
|
-
path:
|
|
35829
|
+
({ path: path109, status: status2, additions, deletions, diffUrl: diffUrl2, patch: patch2, truncated }) => ({
|
|
35830
|
+
path: path109,
|
|
35793
35831
|
status: status2,
|
|
35794
35832
|
additions,
|
|
35795
35833
|
deletions,
|
|
@@ -35843,11 +35881,11 @@ import { randomUUID as randomUUID19 } from "crypto";
|
|
|
35843
35881
|
// src/commands/review/highLevel/indexHighLevelTests.ts
|
|
35844
35882
|
function indexHighLevelTests(files) {
|
|
35845
35883
|
const index2 = /* @__PURE__ */ new Map();
|
|
35846
|
-
const walk2 = (
|
|
35884
|
+
const walk2 = (path109, node, parents) => {
|
|
35847
35885
|
const title = [...parents, node.name];
|
|
35848
35886
|
if (node.kind === "it")
|
|
35849
|
-
index2.set(node.id, { path:
|
|
35850
|
-
else for (const child of node.children) walk2(
|
|
35887
|
+
index2.set(node.id, { path: path109, line: node.line, title });
|
|
35888
|
+
else for (const child of node.children) walk2(path109, child, title);
|
|
35851
35889
|
};
|
|
35852
35890
|
for (const file of files)
|
|
35853
35891
|
for (const node of file.tests) walk2(file.path, node, []);
|
|
@@ -35957,11 +35995,11 @@ function highLevelPreviewPayload(subject) {
|
|
|
35957
35995
|
import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync40 } from "fs";
|
|
35958
35996
|
import { dirname as dirname38 } from "path";
|
|
35959
35997
|
function saveHighLevelReview(record) {
|
|
35960
|
-
const
|
|
35961
|
-
mkdirSync23(dirname38(
|
|
35962
|
-
writeFileSync40(
|
|
35998
|
+
const path109 = highLevelReviewPath(record.repo, record.headRef, record.headSha);
|
|
35999
|
+
mkdirSync23(dirname38(path109), { recursive: true });
|
|
36000
|
+
writeFileSync40(path109, `${JSON.stringify(record, null, 2)}
|
|
35963
36001
|
`);
|
|
35964
|
-
return
|
|
36002
|
+
return path109;
|
|
35965
36003
|
}
|
|
35966
36004
|
|
|
35967
36005
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
@@ -35980,63 +36018,63 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
35980
36018
|
{ rejectIsOutcome: true }
|
|
35981
36019
|
);
|
|
35982
36020
|
const record = buildHighLevelRecord(subject, decision);
|
|
35983
|
-
const
|
|
36021
|
+
const path109 = saveHighLevelReview(record);
|
|
35984
36022
|
console.log(`Verdict: ${record.verdict}`);
|
|
35985
|
-
console.log(`Saved ${
|
|
36023
|
+
console.log(`Saved ${path109}`);
|
|
35986
36024
|
console.log("Nothing was posted to GitHub.");
|
|
35987
36025
|
return record;
|
|
35988
36026
|
}
|
|
35989
36027
|
|
|
35990
36028
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
35991
|
-
import
|
|
36029
|
+
import chalk240 from "chalk";
|
|
35992
36030
|
|
|
35993
36031
|
// src/commands/review/highLevel/formatCriticalDiffs.ts
|
|
35994
|
-
import
|
|
36032
|
+
import chalk236 from "chalk";
|
|
35995
36033
|
var PATCH_LINE_COLOURS = {
|
|
35996
|
-
"+":
|
|
35997
|
-
"-":
|
|
35998
|
-
"@":
|
|
36034
|
+
"+": chalk236.green,
|
|
36035
|
+
"-": chalk236.red,
|
|
36036
|
+
"@": chalk236.cyan
|
|
35999
36037
|
};
|
|
36000
36038
|
function formatPatch(patch2) {
|
|
36001
36039
|
return patch2.split("\n").map(
|
|
36002
|
-
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ??
|
|
36040
|
+
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ?? chalk236.dim)(line)}`
|
|
36003
36041
|
);
|
|
36004
36042
|
}
|
|
36005
36043
|
function formatDiff(diff3) {
|
|
36006
36044
|
return [
|
|
36007
36045
|
"",
|
|
36008
|
-
` ${
|
|
36009
|
-
...diff3.patch === null ? [` ${
|
|
36046
|
+
` ${chalk236.bold(diff3.path)} ${chalk236.dim(`(${diff3.status})`)} ${chalk236.green(`+${diff3.additions}`)} ${chalk236.red(`-${diff3.deletions}`)}`,
|
|
36047
|
+
...diff3.patch === null ? [` ${chalk236.dim(`no diff available; see ${diff3.diffUrl}`)}`] : formatPatch(diff3.patch)
|
|
36010
36048
|
];
|
|
36011
36049
|
}
|
|
36012
36050
|
function formatCriticalDiffs(diffs, criticalPaths) {
|
|
36013
36051
|
if (criticalPaths.length === 0)
|
|
36014
|
-
return `${
|
|
36015
|
-
${
|
|
36052
|
+
return `${chalk236.bold.underline("Critical diffs")}
|
|
36053
|
+
${chalk236.dim("review.highLevel.criticalPaths is unset, so no diffs are shown")}`;
|
|
36016
36054
|
if (diffs.length === 0)
|
|
36017
|
-
return `${
|
|
36018
|
-
${
|
|
36055
|
+
return `${chalk236.bold.underline("Critical diffs")}
|
|
36056
|
+
${chalk236.dim(`no changed file matches ${criticalPaths.join(", ")}`)}`;
|
|
36019
36057
|
return [
|
|
36020
|
-
|
|
36058
|
+
chalk236.bold.underline("Critical diffs"),
|
|
36021
36059
|
...diffs.flatMap(formatDiff)
|
|
36022
36060
|
].join("\n");
|
|
36023
36061
|
}
|
|
36024
36062
|
|
|
36025
36063
|
// src/commands/review/highLevel/formatHighLevelChecklist.ts
|
|
36026
|
-
import
|
|
36064
|
+
import chalk237 from "chalk";
|
|
36027
36065
|
var MARKERS = {
|
|
36028
|
-
pass: () =>
|
|
36029
|
-
fail: () =>
|
|
36030
|
-
manual: () =>
|
|
36066
|
+
pass: () => chalk237.green("\u2714"),
|
|
36067
|
+
fail: () => chalk237.red("\u2718"),
|
|
36068
|
+
manual: () => chalk237.yellow("\u25A1")
|
|
36031
36069
|
};
|
|
36032
36070
|
function formatCheck(check2) {
|
|
36033
|
-
const title = check2.status === "fail" ?
|
|
36071
|
+
const title = check2.status === "fail" ? chalk237.red(check2.title) : chalk237.bold(check2.title);
|
|
36034
36072
|
return ` ${MARKERS[check2.status]()} ${title}
|
|
36035
|
-
${
|
|
36073
|
+
${chalk237.dim(check2.reason)}`;
|
|
36036
36074
|
}
|
|
36037
36075
|
function formatGroup(heading2, checks2) {
|
|
36038
36076
|
if (checks2.length === 0) return [];
|
|
36039
|
-
return ["",
|
|
36077
|
+
return ["", chalk237.bold.underline(heading2), ...checks2.map(formatCheck)];
|
|
36040
36078
|
}
|
|
36041
36079
|
function formatHighLevelChecklist(checks2) {
|
|
36042
36080
|
const deterministic = checks2.filter(
|
|
@@ -36045,7 +36083,7 @@ function formatHighLevelChecklist(checks2) {
|
|
|
36045
36083
|
const failed3 = deterministic.filter(
|
|
36046
36084
|
(check2) => check2.status === "fail"
|
|
36047
36085
|
).length;
|
|
36048
|
-
const summary = failed3 === 0 ?
|
|
36086
|
+
const summary = failed3 === 0 ? chalk237.green(`All ${deterministic.length} deterministic checks pass`) : chalk237.red(
|
|
36049
36087
|
`${failed3} of ${deterministic.length} deterministic checks fail`
|
|
36050
36088
|
);
|
|
36051
36089
|
return [
|
|
@@ -36060,37 +36098,37 @@ function formatHighLevelChecklist(checks2) {
|
|
|
36060
36098
|
}
|
|
36061
36099
|
|
|
36062
36100
|
// src/commands/review/highLevel/formatHighLevelStructure.ts
|
|
36063
|
-
import
|
|
36101
|
+
import chalk238 from "chalk";
|
|
36064
36102
|
var STATUS_MARKERS = {
|
|
36065
|
-
added: () =>
|
|
36066
|
-
removed: () =>
|
|
36067
|
-
modified: () =>
|
|
36103
|
+
added: () => chalk238.green("A"),
|
|
36104
|
+
removed: () => chalk238.red("D"),
|
|
36105
|
+
modified: () => chalk238.yellow("M")
|
|
36068
36106
|
};
|
|
36069
36107
|
function counts(additions, deletions) {
|
|
36070
|
-
return `${
|
|
36108
|
+
return `${chalk238.green(`+${additions}`)} ${chalk238.red(`-${deletions}`)}`;
|
|
36071
36109
|
}
|
|
36072
36110
|
function formatNode(node, indent3) {
|
|
36073
36111
|
if (node.kind === "file")
|
|
36074
36112
|
return [
|
|
36075
|
-
`${indent3}${STATUS_MARKERS[node.status]()} ${node.name} ${
|
|
36113
|
+
`${indent3}${STATUS_MARKERS[node.status]()} ${node.name} ${chalk238.dim(counts(node.additions, node.deletions))}`
|
|
36076
36114
|
];
|
|
36077
36115
|
const dir = node;
|
|
36078
36116
|
return [
|
|
36079
|
-
`${indent3}${
|
|
36117
|
+
`${indent3}${chalk238.bold(`${dir.name}/`)} ${chalk238.dim(counts(dir.additions, dir.deletions))}`,
|
|
36080
36118
|
...dir.children.flatMap((child) => formatNode(child, `${indent3} `))
|
|
36081
36119
|
];
|
|
36082
36120
|
}
|
|
36083
36121
|
function formatHighLevelStructure(structure) {
|
|
36084
36122
|
const summary = `${structure.added} added \xB7 ${structure.removed} deleted \xB7 ${structure.modified} modified \xB7 ${counts(structure.additions, structure.deletions)}`;
|
|
36085
36123
|
return [
|
|
36086
|
-
|
|
36124
|
+
chalk238.bold.underline("Structure"),
|
|
36087
36125
|
` ${summary}`,
|
|
36088
36126
|
...structure.tree.flatMap((node) => formatNode(node, " "))
|
|
36089
36127
|
].join("\n");
|
|
36090
36128
|
}
|
|
36091
36129
|
|
|
36092
36130
|
// src/commands/review/highLevel/formatHighLevelTests.ts
|
|
36093
|
-
import
|
|
36131
|
+
import chalk239 from "chalk";
|
|
36094
36132
|
function changeMarker(change) {
|
|
36095
36133
|
if (change === "added") return "A";
|
|
36096
36134
|
if (change === "modified") return "M";
|
|
@@ -36099,22 +36137,22 @@ function changeMarker(change) {
|
|
|
36099
36137
|
function formatNode2(node, depth) {
|
|
36100
36138
|
const indent3 = " ".repeat(depth + 2);
|
|
36101
36139
|
if (node.kind === "it")
|
|
36102
|
-
return [`${indent3}${
|
|
36140
|
+
return [`${indent3}${chalk239.dim(changeMarker(node.change))} ${node.name}`];
|
|
36103
36141
|
return [
|
|
36104
|
-
`${indent3}${
|
|
36142
|
+
`${indent3}${chalk239.bold(node.name)}`,
|
|
36105
36143
|
...node.children.flatMap((child) => formatNode2(child, depth + 1))
|
|
36106
36144
|
];
|
|
36107
36145
|
}
|
|
36108
36146
|
function formatHighLevelTests(files, testPaths) {
|
|
36109
|
-
const heading2 =
|
|
36147
|
+
const heading2 = chalk239.bold.underline("Changed tests");
|
|
36110
36148
|
if (files.length === 0)
|
|
36111
36149
|
return `${heading2}
|
|
36112
|
-
${
|
|
36150
|
+
${chalk239.dim(`no changed test in files matching ${testPaths.join(", ")}`)}`;
|
|
36113
36151
|
return [
|
|
36114
36152
|
heading2,
|
|
36115
36153
|
...files.flatMap((file) => [
|
|
36116
36154
|
"",
|
|
36117
|
-
` ${
|
|
36155
|
+
` ${chalk239.bold(file.path)} ${chalk239.dim(`(${file.status})`)}`,
|
|
36118
36156
|
...file.tests.flatMap((node) => formatNode2(node, 0))
|
|
36119
36157
|
])
|
|
36120
36158
|
].join("\n");
|
|
@@ -36123,10 +36161,10 @@ function formatHighLevelTests(files, testPaths) {
|
|
|
36123
36161
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
36124
36162
|
function printHighLevelChecklist(subject) {
|
|
36125
36163
|
console.log(
|
|
36126
|
-
|
|
36164
|
+
chalk240.bold(
|
|
36127
36165
|
`High-level review of ${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`
|
|
36128
36166
|
),
|
|
36129
|
-
|
|
36167
|
+
chalk240.dim(
|
|
36130
36168
|
`\xB7 ${highLevelChangedFileCount(subject.structure)} changed files`
|
|
36131
36169
|
)
|
|
36132
36170
|
);
|
|
@@ -36140,12 +36178,12 @@ function printHighLevelChecklist(subject) {
|
|
|
36140
36178
|
console.log("");
|
|
36141
36179
|
console.log(formatHighLevelTests(subject.tests, subject.testPaths));
|
|
36142
36180
|
console.log(
|
|
36143
|
-
|
|
36181
|
+
chalk240.dim(
|
|
36144
36182
|
"\nManual items are for the reviewer to judge; see docs/high-level-review.md."
|
|
36145
36183
|
)
|
|
36146
36184
|
);
|
|
36147
36185
|
console.log(
|
|
36148
|
-
|
|
36186
|
+
chalk240.dim(
|
|
36149
36187
|
"Run this inside an assist session to step through the checklist in the web overlay."
|
|
36150
36188
|
)
|
|
36151
36189
|
);
|
|
@@ -36420,18 +36458,18 @@ function partitionFindingsByDiff(findings, index2) {
|
|
|
36420
36458
|
}
|
|
36421
36459
|
|
|
36422
36460
|
// src/commands/review/warnOutOfDiff.ts
|
|
36423
|
-
import
|
|
36461
|
+
import chalk241 from "chalk";
|
|
36424
36462
|
function warnOutOfDiff(outOfDiff) {
|
|
36425
36463
|
if (outOfDiff.length === 0) return;
|
|
36426
36464
|
console.warn(
|
|
36427
|
-
|
|
36465
|
+
chalk241.yellow(
|
|
36428
36466
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
36429
36467
|
)
|
|
36430
36468
|
);
|
|
36431
36469
|
for (const finding of outOfDiff) {
|
|
36432
36470
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
36433
36471
|
console.warn(
|
|
36434
|
-
` ${
|
|
36472
|
+
` ${chalk241.yellow("\xB7")} ${finding.title} ${chalk241.dim(
|
|
36435
36473
|
`(${finding.file}:${range})`
|
|
36436
36474
|
)}`
|
|
36437
36475
|
);
|
|
@@ -36455,18 +36493,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
36455
36493
|
}
|
|
36456
36494
|
|
|
36457
36495
|
// src/commands/review/warnUnlocated.ts
|
|
36458
|
-
import
|
|
36496
|
+
import chalk242 from "chalk";
|
|
36459
36497
|
function warnUnlocated(unlocated) {
|
|
36460
36498
|
if (unlocated.length === 0) return;
|
|
36461
36499
|
console.warn(
|
|
36462
|
-
|
|
36500
|
+
chalk242.yellow(
|
|
36463
36501
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
36464
36502
|
)
|
|
36465
36503
|
);
|
|
36466
36504
|
for (const finding of unlocated) {
|
|
36467
|
-
const where = finding.location ||
|
|
36505
|
+
const where = finding.location || chalk242.dim("missing");
|
|
36468
36506
|
console.warn(
|
|
36469
|
-
` ${
|
|
36507
|
+
` ${chalk242.yellow("\xB7")} ${finding.title} ${chalk242.dim(`(${where})`)}`
|
|
36470
36508
|
);
|
|
36471
36509
|
}
|
|
36472
36510
|
}
|
|
@@ -36598,10 +36636,22 @@ function submitPendingReview(body) {
|
|
|
36598
36636
|
runReviewSubmission(MUTATION7, body);
|
|
36599
36637
|
}
|
|
36600
36638
|
|
|
36601
|
-
// src/commands/review/
|
|
36602
|
-
function
|
|
36603
|
-
return
|
|
36639
|
+
// src/commands/review/appendCiFooter.ts
|
|
36640
|
+
function appendCiFooter(body, ciFooter) {
|
|
36641
|
+
return ciFooter ? `${body}
|
|
36642
|
+
|
|
36643
|
+
${ciFooter}` : body;
|
|
36604
36644
|
}
|
|
36645
|
+
|
|
36646
|
+
// src/commands/review/buildReviewBody.ts
|
|
36647
|
+
function buildReviewBody(markdown, unanchored, ciFooter) {
|
|
36648
|
+
return appendCiFooter(
|
|
36649
|
+
sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
|
|
36650
|
+
ciFooter
|
|
36651
|
+
);
|
|
36652
|
+
}
|
|
36653
|
+
|
|
36654
|
+
// src/commands/review/postAndMaybeSubmit.ts
|
|
36605
36655
|
function submitReview(body, posted) {
|
|
36606
36656
|
if (posted > 0) submitPendingReview(body);
|
|
36607
36657
|
else submitBodyOnlyReview(body);
|
|
@@ -36624,7 +36674,10 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
|
|
|
36624
36674
|
return { posted: 0, submitted: false };
|
|
36625
36675
|
const shouldSubmit = await decideSubmit(options2);
|
|
36626
36676
|
if (shouldSubmit) {
|
|
36627
|
-
submitReview(
|
|
36677
|
+
submitReview(
|
|
36678
|
+
buildReviewBody(markdown, unanchored, options2.ciFooter),
|
|
36679
|
+
result.posted
|
|
36680
|
+
);
|
|
36628
36681
|
return { posted: result.posted, submitted: true };
|
|
36629
36682
|
}
|
|
36630
36683
|
console.log("Leaving the review unsubmitted.");
|
|
@@ -36651,14 +36704,26 @@ function stillOnReviewedPr(prNumber) {
|
|
|
36651
36704
|
return false;
|
|
36652
36705
|
}
|
|
36653
36706
|
|
|
36654
|
-
// src/commands/review/
|
|
36655
|
-
|
|
36707
|
+
// src/commands/review/submitNoFindingsReview.ts
|
|
36708
|
+
function submitNoFindingsReview(markdown, ciFooter) {
|
|
36709
|
+
const body = sanitiseReviewerNames(
|
|
36710
|
+
`${buildReviewSummary(markdown)}
|
|
36711
|
+
|
|
36712
|
+
No findings were raised.`
|
|
36713
|
+
);
|
|
36714
|
+
submitBodyOnlyReview(appendCiFooter(body, ciFooter));
|
|
36715
|
+
}
|
|
36716
|
+
|
|
36717
|
+
// src/commands/review/describeWork.ts
|
|
36656
36718
|
function describeWork(comments3, carried) {
|
|
36657
36719
|
const parts = [];
|
|
36658
36720
|
if (comments3 > 0) parts.push(`${comments3} line comment(s)`);
|
|
36659
36721
|
if (carried > 0) parts.push(`${carried} finding(s) in the review body`);
|
|
36660
36722
|
return parts.join(" and ");
|
|
36661
36723
|
}
|
|
36724
|
+
|
|
36725
|
+
// src/commands/review/postReviewToPr.ts
|
|
36726
|
+
var NOTHING_POSTED = { posted: 0, submitted: false };
|
|
36662
36727
|
async function confirmPost(prNumber, work, options2) {
|
|
36663
36728
|
if (!options2.prompt) return true;
|
|
36664
36729
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
@@ -36667,7 +36732,11 @@ async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
|
36667
36732
|
const markdown = readFileSync52(synthesisPath, "utf8");
|
|
36668
36733
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
36669
36734
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
36670
|
-
if (inDiff.length === 0 && carried.length === 0)
|
|
36735
|
+
if (inDiff.length === 0 && carried.length === 0) {
|
|
36736
|
+
if (!options2.ciFooter) return NOTHING_POSTED;
|
|
36737
|
+
submitNoFindingsReview(markdown, options2.ciFooter);
|
|
36738
|
+
return { posted: 0, submitted: true };
|
|
36739
|
+
}
|
|
36671
36740
|
const work = describeWork(inDiff.length, carried.length);
|
|
36672
36741
|
console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
|
|
36673
36742
|
const confirmed = await confirmPost(prInfo.prNumber, work, options2);
|
|
@@ -36791,7 +36860,8 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
36791
36860
|
prompt: options2.prompt,
|
|
36792
36861
|
submit: options2.submit,
|
|
36793
36862
|
addressComments: options2.addressComments,
|
|
36794
|
-
announce: options2.announce
|
|
36863
|
+
announce: options2.announce,
|
|
36864
|
+
ciFooter: options2.ciFooter
|
|
36795
36865
|
});
|
|
36796
36866
|
return;
|
|
36797
36867
|
}
|
|
@@ -38044,8 +38114,8 @@ function fetchExistingComments() {
|
|
|
38044
38114
|
// src/commands/review/prepareReviewDir.ts
|
|
38045
38115
|
import { existsSync as existsSync69, mkdirSync as mkdirSync25, unlinkSync as unlinkSync20, writeFileSync as writeFileSync42 } from "fs";
|
|
38046
38116
|
function clearReviewFiles(paths) {
|
|
38047
|
-
for (const
|
|
38048
|
-
if (existsSync69(
|
|
38117
|
+
for (const path109 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
38118
|
+
if (existsSync69(path109)) unlinkSync20(path109);
|
|
38049
38119
|
}
|
|
38050
38120
|
}
|
|
38051
38121
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -38176,7 +38246,8 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
38176
38246
|
prompt: options2.prompt ?? true,
|
|
38177
38247
|
submit: options2.submit ?? false,
|
|
38178
38248
|
addressComments: options2.addressComments ?? false,
|
|
38179
|
-
announce: options2.announce ?? false
|
|
38249
|
+
announce: options2.announce ?? false,
|
|
38250
|
+
ciFooter: options2.ci?.footer
|
|
38180
38251
|
});
|
|
38181
38252
|
}
|
|
38182
38253
|
async function reviewPr(repoRoot2, options2) {
|
|
@@ -38371,8 +38442,8 @@ function registerReview(program2) {
|
|
|
38371
38442
|
|
|
38372
38443
|
// src/commands/rules/addRule.ts
|
|
38373
38444
|
import { existsSync as existsSync72, readFileSync as readFileSync57, writeFileSync as writeFileSync44 } from "fs";
|
|
38374
|
-
import
|
|
38375
|
-
import
|
|
38445
|
+
import path88 from "path";
|
|
38446
|
+
import chalk243 from "chalk";
|
|
38376
38447
|
|
|
38377
38448
|
// src/commands/rules/insertRuleBullet.ts
|
|
38378
38449
|
function ruleBullet({ code, title, text: text18 }) {
|
|
@@ -38399,7 +38470,7 @@ import { readFileSync as readFileSync54 } from "fs";
|
|
|
38399
38470
|
|
|
38400
38471
|
// src/commands/rules/findClaudeFiles.ts
|
|
38401
38472
|
import { readdirSync as readdirSync13 } from "fs";
|
|
38402
|
-
import
|
|
38473
|
+
import path84 from "path";
|
|
38403
38474
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
38404
38475
|
function findClaudeFiles(dir) {
|
|
38405
38476
|
const results = [];
|
|
@@ -38407,9 +38478,9 @@ function findClaudeFiles(dir) {
|
|
|
38407
38478
|
if (entry.isDirectory()) {
|
|
38408
38479
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
38409
38480
|
continue;
|
|
38410
|
-
results.push(...findClaudeFiles(
|
|
38481
|
+
results.push(...findClaudeFiles(path84.join(dir, entry.name)));
|
|
38411
38482
|
} else if (entry.name === "CLAUDE.md") {
|
|
38412
|
-
results.push(
|
|
38483
|
+
results.push(path84.join(dir, entry.name));
|
|
38413
38484
|
}
|
|
38414
38485
|
}
|
|
38415
38486
|
return results;
|
|
@@ -38428,34 +38499,34 @@ function nextRuleCode(root2) {
|
|
|
38428
38499
|
|
|
38429
38500
|
// src/commands/rules/resolveRuleScope.ts
|
|
38430
38501
|
import { existsSync as existsSync70 } from "fs";
|
|
38431
|
-
import
|
|
38502
|
+
import path85 from "path";
|
|
38432
38503
|
function resolveRuleScope(target) {
|
|
38433
|
-
const resolved =
|
|
38434
|
-
if (
|
|
38504
|
+
const resolved = path85.resolve(target);
|
|
38505
|
+
if (path85.basename(resolved) === "CLAUDE.md") return resolved;
|
|
38435
38506
|
const startDir = scopeDirectory(resolved);
|
|
38436
38507
|
const root2 = findRepoRoot(startDir) ?? startDir;
|
|
38437
38508
|
let current = startDir;
|
|
38438
38509
|
while (true) {
|
|
38439
|
-
const candidate =
|
|
38510
|
+
const candidate = path85.join(current, "CLAUDE.md");
|
|
38440
38511
|
if (existsSync70(candidate)) return candidate;
|
|
38441
|
-
if (current === root2 || current ===
|
|
38442
|
-
current =
|
|
38512
|
+
if (current === root2 || current === path85.dirname(current)) break;
|
|
38513
|
+
current = path85.dirname(current);
|
|
38443
38514
|
}
|
|
38444
|
-
return
|
|
38515
|
+
return path85.join(root2, "CLAUDE.md");
|
|
38445
38516
|
}
|
|
38446
38517
|
|
|
38447
38518
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
38448
38519
|
import { existsSync as existsSync71, readFileSync as readFileSync56, writeFileSync as writeFileSync43 } from "fs";
|
|
38449
|
-
import
|
|
38520
|
+
import path87 from "path";
|
|
38450
38521
|
|
|
38451
38522
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
38452
38523
|
import { readFileSync as readFileSync55 } from "fs";
|
|
38453
|
-
import
|
|
38524
|
+
import path86 from "path";
|
|
38454
38525
|
function scopedRuleDirectories(root2) {
|
|
38455
38526
|
return findClaudeFiles(root2).filter(
|
|
38456
|
-
(file) =>
|
|
38527
|
+
(file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync55(file, "utf8")).length > 0
|
|
38457
38528
|
).map(
|
|
38458
|
-
(file) => `${
|
|
38529
|
+
(file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
|
|
38459
38530
|
).sort();
|
|
38460
38531
|
}
|
|
38461
38532
|
|
|
@@ -38494,7 +38565,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
38494
38565
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
38495
38566
|
function updateScopedRulesIndex(root2) {
|
|
38496
38567
|
const directories = scopedRuleDirectories(root2);
|
|
38497
|
-
const rootFile =
|
|
38568
|
+
const rootFile = path87.join(root2, "CLAUDE.md");
|
|
38498
38569
|
const before = existsSync71(rootFile) ? readFileSync56(rootFile, "utf8") : "";
|
|
38499
38570
|
const after = upsertScopedRulesPointer(before, directories);
|
|
38500
38571
|
if (after !== before) writeFileSync43(rootFile, after);
|
|
@@ -38508,12 +38579,12 @@ function read2(file) {
|
|
|
38508
38579
|
function addRule(text18, options2) {
|
|
38509
38580
|
const rule = text18.trim();
|
|
38510
38581
|
if (rule === "") {
|
|
38511
|
-
console.error(
|
|
38582
|
+
console.error(chalk243.red("Rule text is required"));
|
|
38512
38583
|
process.exitCode = 1;
|
|
38513
38584
|
return;
|
|
38514
38585
|
}
|
|
38515
38586
|
const target = resolveRuleScope(options2.scope ?? process.cwd());
|
|
38516
|
-
const targetDir =
|
|
38587
|
+
const targetDir = path88.dirname(target);
|
|
38517
38588
|
const root2 = findRepoRoot(targetDir) ?? targetDir;
|
|
38518
38589
|
const code = nextRuleCode(root2);
|
|
38519
38590
|
writeFileSync44(
|
|
@@ -38526,38 +38597,38 @@ function addRule(text18, options2) {
|
|
|
38526
38597
|
);
|
|
38527
38598
|
updateScopedRulesIndex(root2);
|
|
38528
38599
|
console.log(
|
|
38529
|
-
`Added ${
|
|
38600
|
+
`Added ${chalk243.cyan(code)} to ${path88.relative(process.cwd(), target) || target}`
|
|
38530
38601
|
);
|
|
38531
38602
|
}
|
|
38532
38603
|
|
|
38533
38604
|
// src/commands/rules/indexRules.ts
|
|
38534
|
-
import
|
|
38535
|
-
import
|
|
38605
|
+
import path89 from "path";
|
|
38606
|
+
import chalk244 from "chalk";
|
|
38536
38607
|
function indexRules() {
|
|
38537
38608
|
const startDir = scopeDirectory(process.cwd());
|
|
38538
38609
|
const root2 = findRepoRoot(startDir) ?? startDir;
|
|
38539
38610
|
const directories = updateScopedRulesIndex(root2);
|
|
38540
|
-
const rootFile =
|
|
38611
|
+
const rootFile = path89.relative(process.cwd(), path89.join(root2, "CLAUDE.md"));
|
|
38541
38612
|
if (directories.length === 0) {
|
|
38542
38613
|
console.log(
|
|
38543
|
-
|
|
38614
|
+
chalk244.gray(`No directories carry their own \`## Rules\` under ${root2}`)
|
|
38544
38615
|
);
|
|
38545
38616
|
return;
|
|
38546
38617
|
}
|
|
38547
38618
|
console.log(`Recorded in ${rootFile || "CLAUDE.md"}`);
|
|
38548
38619
|
for (const directory of directories)
|
|
38549
|
-
console.log(` ${
|
|
38620
|
+
console.log(` ${chalk244.cyan(directory)}`);
|
|
38550
38621
|
}
|
|
38551
38622
|
|
|
38552
38623
|
// src/commands/rules/listRules.ts
|
|
38553
|
-
import
|
|
38554
|
-
import
|
|
38624
|
+
import path90 from "path";
|
|
38625
|
+
import chalk245 from "chalk";
|
|
38555
38626
|
function listRules(target, options2 = {}) {
|
|
38556
|
-
const resolved =
|
|
38627
|
+
const resolved = path90.resolve(target ?? process.cwd());
|
|
38557
38628
|
const rules2 = readScopedRules(resolved);
|
|
38558
38629
|
if (rules2.length === 0) {
|
|
38559
|
-
const label2 =
|
|
38560
|
-
console.log(
|
|
38630
|
+
const label2 = path90.relative(process.cwd(), resolved) || ".";
|
|
38631
|
+
console.log(chalk245.gray(`No rules in scope for ${label2}`));
|
|
38561
38632
|
return;
|
|
38562
38633
|
}
|
|
38563
38634
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -38567,14 +38638,14 @@ function listRules(target, options2 = {}) {
|
|
|
38567
38638
|
if (rule.source !== shown) {
|
|
38568
38639
|
shown = rule.source;
|
|
38569
38640
|
console.log(
|
|
38570
|
-
|
|
38641
|
+
chalk245.dim(base ? path90.relative(base, rule.source) : rule.source)
|
|
38571
38642
|
);
|
|
38572
38643
|
}
|
|
38573
38644
|
console.log(
|
|
38574
|
-
` ${
|
|
38645
|
+
` ${chalk245.cyan(rule.code.padEnd(width))} ${rule.title ?? rule.text}`
|
|
38575
38646
|
);
|
|
38576
38647
|
if (options2.full && rule.title)
|
|
38577
|
-
console.log(` ${" ".repeat(width)} ${
|
|
38648
|
+
console.log(` ${" ".repeat(width)} ${chalk245.dim(rule.text)}`);
|
|
38578
38649
|
}
|
|
38579
38650
|
}
|
|
38580
38651
|
|
|
@@ -38603,7 +38674,7 @@ function registerRules(program2) {
|
|
|
38603
38674
|
}
|
|
38604
38675
|
|
|
38605
38676
|
// src/commands/seq/seqAuth.ts
|
|
38606
|
-
import
|
|
38677
|
+
import chalk247 from "chalk";
|
|
38607
38678
|
|
|
38608
38679
|
// src/commands/seq/loadConnections.ts
|
|
38609
38680
|
function loadConnections2() {
|
|
@@ -38632,10 +38703,10 @@ function setDefaultConnection(name) {
|
|
|
38632
38703
|
}
|
|
38633
38704
|
|
|
38634
38705
|
// src/shared/assertUniqueName.ts
|
|
38635
|
-
import
|
|
38706
|
+
import chalk246 from "chalk";
|
|
38636
38707
|
function assertUniqueName(existingNames, name) {
|
|
38637
38708
|
if (existingNames.includes(name)) {
|
|
38638
|
-
console.error(
|
|
38709
|
+
console.error(chalk246.red(`Connection "${name}" already exists.`));
|
|
38639
38710
|
process.exit(1);
|
|
38640
38711
|
}
|
|
38641
38712
|
}
|
|
@@ -38653,18 +38724,18 @@ async function promptConnection2(existingNames) {
|
|
|
38653
38724
|
var seqAuth = createConnectionAuth({
|
|
38654
38725
|
load: loadConnections2,
|
|
38655
38726
|
save: saveConnections2,
|
|
38656
|
-
format: (c) => `${
|
|
38727
|
+
format: (c) => `${chalk247.bold(c.name)} ${c.url}`,
|
|
38657
38728
|
promptNew: promptConnection2,
|
|
38658
38729
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
38659
38730
|
});
|
|
38660
38731
|
|
|
38661
38732
|
// src/commands/seq/seqQuery.ts
|
|
38662
|
-
import
|
|
38733
|
+
import chalk251 from "chalk";
|
|
38663
38734
|
|
|
38664
38735
|
// src/commands/seq/fetchSeq.ts
|
|
38665
|
-
import
|
|
38666
|
-
async function fetchSeq(conn,
|
|
38667
|
-
const url = `${conn.url}${
|
|
38736
|
+
import chalk248 from "chalk";
|
|
38737
|
+
async function fetchSeq(conn, path109, params) {
|
|
38738
|
+
const url = `${conn.url}${path109}?${params}`;
|
|
38668
38739
|
const response = await fetch(url, {
|
|
38669
38740
|
headers: {
|
|
38670
38741
|
Accept: "application/json",
|
|
@@ -38673,7 +38744,7 @@ async function fetchSeq(conn, path108, params) {
|
|
|
38673
38744
|
});
|
|
38674
38745
|
if (!response.ok) {
|
|
38675
38746
|
const body = await response.text();
|
|
38676
|
-
console.error(
|
|
38747
|
+
console.error(chalk248.red(`Seq returned ${response.status}: ${body}`));
|
|
38677
38748
|
process.exit(1);
|
|
38678
38749
|
}
|
|
38679
38750
|
return response;
|
|
@@ -38732,23 +38803,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
38732
38803
|
}
|
|
38733
38804
|
|
|
38734
38805
|
// src/commands/seq/formatEvent.ts
|
|
38735
|
-
import
|
|
38806
|
+
import chalk249 from "chalk";
|
|
38736
38807
|
function levelColor(level) {
|
|
38737
38808
|
switch (level) {
|
|
38738
38809
|
case "Fatal":
|
|
38739
|
-
return
|
|
38810
|
+
return chalk249.bgRed.white;
|
|
38740
38811
|
case "Error":
|
|
38741
|
-
return
|
|
38812
|
+
return chalk249.red;
|
|
38742
38813
|
case "Warning":
|
|
38743
|
-
return
|
|
38814
|
+
return chalk249.yellow;
|
|
38744
38815
|
case "Information":
|
|
38745
|
-
return
|
|
38816
|
+
return chalk249.cyan;
|
|
38746
38817
|
case "Debug":
|
|
38747
|
-
return
|
|
38818
|
+
return chalk249.gray;
|
|
38748
38819
|
case "Verbose":
|
|
38749
|
-
return
|
|
38820
|
+
return chalk249.dim;
|
|
38750
38821
|
default:
|
|
38751
|
-
return
|
|
38822
|
+
return chalk249.white;
|
|
38752
38823
|
}
|
|
38753
38824
|
}
|
|
38754
38825
|
function levelAbbrev(level) {
|
|
@@ -38789,12 +38860,12 @@ function formatTimestamp(iso) {
|
|
|
38789
38860
|
function formatEvent(event) {
|
|
38790
38861
|
const color = levelColor(event.Level);
|
|
38791
38862
|
const abbrev = levelAbbrev(event.Level);
|
|
38792
|
-
const ts10 =
|
|
38863
|
+
const ts10 = chalk249.dim(formatTimestamp(event.Timestamp));
|
|
38793
38864
|
const msg = renderMessage(event);
|
|
38794
38865
|
const lines2 = [`${ts10} ${color(`[${abbrev}]`)} ${msg}`];
|
|
38795
38866
|
if (event.Exception) {
|
|
38796
38867
|
for (const line of event.Exception.split("\n")) {
|
|
38797
|
-
lines2.push(
|
|
38868
|
+
lines2.push(chalk249.red(` ${line}`));
|
|
38798
38869
|
}
|
|
38799
38870
|
}
|
|
38800
38871
|
return lines2.join("\n");
|
|
@@ -38827,11 +38898,11 @@ function rejectTimestampFilter(filter) {
|
|
|
38827
38898
|
}
|
|
38828
38899
|
|
|
38829
38900
|
// src/shared/resolveNamedConnection.ts
|
|
38830
|
-
import
|
|
38901
|
+
import chalk250 from "chalk";
|
|
38831
38902
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
38832
38903
|
if (connections.length === 0) {
|
|
38833
38904
|
console.error(
|
|
38834
|
-
|
|
38905
|
+
chalk250.red(
|
|
38835
38906
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
38836
38907
|
)
|
|
38837
38908
|
);
|
|
@@ -38840,7 +38911,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
38840
38911
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
38841
38912
|
const connection = connections.find((c) => c.name === target);
|
|
38842
38913
|
if (!connection) {
|
|
38843
|
-
console.error(
|
|
38914
|
+
console.error(chalk250.red(`${kind} connection "${target}" not found.`));
|
|
38844
38915
|
process.exit(1);
|
|
38845
38916
|
}
|
|
38846
38917
|
return connection;
|
|
@@ -38869,7 +38940,7 @@ async function seqQuery(filter, options2) {
|
|
|
38869
38940
|
new URLSearchParams({ filter, count: String(count8) })
|
|
38870
38941
|
);
|
|
38871
38942
|
if (events.length === 0) {
|
|
38872
|
-
console.log(
|
|
38943
|
+
console.log(chalk251.yellow("No events found."));
|
|
38873
38944
|
return;
|
|
38874
38945
|
}
|
|
38875
38946
|
if (options2.json) {
|
|
@@ -38880,11 +38951,11 @@ async function seqQuery(filter, options2) {
|
|
|
38880
38951
|
for (const event of chronological) {
|
|
38881
38952
|
console.log(formatEvent(event));
|
|
38882
38953
|
}
|
|
38883
|
-
console.log(
|
|
38954
|
+
console.log(chalk251.dim(`
|
|
38884
38955
|
${events.length} events`));
|
|
38885
38956
|
if (events.length >= count8) {
|
|
38886
38957
|
console.log(
|
|
38887
|
-
|
|
38958
|
+
chalk251.yellow(
|
|
38888
38959
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
38889
38960
|
)
|
|
38890
38961
|
);
|
|
@@ -38892,10 +38963,10 @@ ${events.length} events`));
|
|
|
38892
38963
|
}
|
|
38893
38964
|
|
|
38894
38965
|
// src/shared/setNamedDefaultConnection.ts
|
|
38895
|
-
import
|
|
38966
|
+
import chalk252 from "chalk";
|
|
38896
38967
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
38897
38968
|
if (!connections.find((c) => c.name === name)) {
|
|
38898
|
-
console.error(
|
|
38969
|
+
console.error(chalk252.red(`Connection "${name}" not found.`));
|
|
38899
38970
|
process.exit(1);
|
|
38900
38971
|
}
|
|
38901
38972
|
setDefault(name);
|
|
@@ -39116,7 +39187,7 @@ async function previewSlackThreadParts({
|
|
|
39116
39187
|
`Approved for ${target}. The ${bodies.length} bodies to post, in thread order, are at:`
|
|
39117
39188
|
);
|
|
39118
39189
|
paths.forEach(
|
|
39119
|
-
(
|
|
39190
|
+
(path109, index2) => console.log(`${index2 + 1}/${paths.length} ${path109}`)
|
|
39120
39191
|
);
|
|
39121
39192
|
console.log(
|
|
39122
39193
|
threadTs ? `Post every part as a reply with thread_ts ${threadTs}.` : `Post 1/${paths.length} to ${channel}, then the rest with the thread_ts it returns.`
|
|
@@ -39187,7 +39258,7 @@ function registerSlack(program2) {
|
|
|
39187
39258
|
}
|
|
39188
39259
|
|
|
39189
39260
|
// src/commands/sql/sqlAuth.ts
|
|
39190
|
-
import
|
|
39261
|
+
import chalk254 from "chalk";
|
|
39191
39262
|
|
|
39192
39263
|
// src/commands/sql/loadConnections.ts
|
|
39193
39264
|
function loadConnections3() {
|
|
@@ -39216,7 +39287,7 @@ function setDefaultConnection2(name) {
|
|
|
39216
39287
|
}
|
|
39217
39288
|
|
|
39218
39289
|
// src/commands/sql/promptConnection.ts
|
|
39219
|
-
import
|
|
39290
|
+
import chalk253 from "chalk";
|
|
39220
39291
|
async function promptConnection3(existingNames) {
|
|
39221
39292
|
const name = await promptInput("name", "Connection name:", "default");
|
|
39222
39293
|
assertUniqueName(existingNames, name);
|
|
@@ -39224,7 +39295,7 @@ async function promptConnection3(existingNames) {
|
|
|
39224
39295
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
39225
39296
|
const port = Number.parseInt(portStr, 10);
|
|
39226
39297
|
if (!Number.isFinite(port)) {
|
|
39227
|
-
console.error(
|
|
39298
|
+
console.error(chalk253.red(`Invalid port "${portStr}".`));
|
|
39228
39299
|
process.exit(1);
|
|
39229
39300
|
}
|
|
39230
39301
|
const user = await promptInput("user", "User:");
|
|
@@ -39237,13 +39308,13 @@ async function promptConnection3(existingNames) {
|
|
|
39237
39308
|
var sqlAuth = createConnectionAuth({
|
|
39238
39309
|
load: loadConnections3,
|
|
39239
39310
|
save: saveConnections3,
|
|
39240
|
-
format: (c) => `${
|
|
39311
|
+
format: (c) => `${chalk254.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
39241
39312
|
promptNew: promptConnection3,
|
|
39242
39313
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
39243
39314
|
});
|
|
39244
39315
|
|
|
39245
39316
|
// src/commands/sql/printTable.ts
|
|
39246
|
-
import
|
|
39317
|
+
import chalk255 from "chalk";
|
|
39247
39318
|
function formatCell(value) {
|
|
39248
39319
|
if (value === null || value === void 0) return "";
|
|
39249
39320
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -39252,7 +39323,7 @@ function formatCell(value) {
|
|
|
39252
39323
|
}
|
|
39253
39324
|
function printTable(rows) {
|
|
39254
39325
|
if (rows.length === 0) {
|
|
39255
|
-
console.log(
|
|
39326
|
+
console.log(chalk255.yellow("(no rows)"));
|
|
39256
39327
|
return;
|
|
39257
39328
|
}
|
|
39258
39329
|
const columns = Object.keys(rows[0]);
|
|
@@ -39260,13 +39331,13 @@ function printTable(rows) {
|
|
|
39260
39331
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
39261
39332
|
);
|
|
39262
39333
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
39263
|
-
console.log(
|
|
39264
|
-
console.log(
|
|
39334
|
+
console.log(chalk255.dim(header));
|
|
39335
|
+
console.log(chalk255.dim("-".repeat(header.length)));
|
|
39265
39336
|
for (const row2 of rows) {
|
|
39266
39337
|
const line = columns.map((c, i) => formatCell(row2[c]).padEnd(widths[i])).join(" ");
|
|
39267
39338
|
console.log(line);
|
|
39268
39339
|
}
|
|
39269
|
-
console.log(
|
|
39340
|
+
console.log(chalk255.dim(`
|
|
39270
39341
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
39271
39342
|
}
|
|
39272
39343
|
|
|
@@ -39326,7 +39397,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
39326
39397
|
}
|
|
39327
39398
|
|
|
39328
39399
|
// src/commands/sql/sqlMutate.ts
|
|
39329
|
-
import
|
|
39400
|
+
import chalk256 from "chalk";
|
|
39330
39401
|
|
|
39331
39402
|
// src/commands/sql/isMutation.ts
|
|
39332
39403
|
var MUTATION_KEYWORDS = [
|
|
@@ -39360,7 +39431,7 @@ function isMutation(sql29) {
|
|
|
39360
39431
|
async function sqlMutate(query, connectionName) {
|
|
39361
39432
|
if (!isMutation(query)) {
|
|
39362
39433
|
console.error(
|
|
39363
|
-
|
|
39434
|
+
chalk256.red(
|
|
39364
39435
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
39365
39436
|
)
|
|
39366
39437
|
);
|
|
@@ -39370,18 +39441,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
39370
39441
|
const pool = await sqlConnect(conn);
|
|
39371
39442
|
try {
|
|
39372
39443
|
const result = await pool.request().query(query);
|
|
39373
|
-
console.log(
|
|
39444
|
+
console.log(chalk256.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
39374
39445
|
} finally {
|
|
39375
39446
|
await pool.close();
|
|
39376
39447
|
}
|
|
39377
39448
|
}
|
|
39378
39449
|
|
|
39379
39450
|
// src/commands/sql/sqlQuery.ts
|
|
39380
|
-
import
|
|
39451
|
+
import chalk257 from "chalk";
|
|
39381
39452
|
async function sqlQuery(query, connectionName) {
|
|
39382
39453
|
if (isMutation(query)) {
|
|
39383
39454
|
console.error(
|
|
39384
|
-
|
|
39455
|
+
chalk257.red(
|
|
39385
39456
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
39386
39457
|
)
|
|
39387
39458
|
);
|
|
@@ -39396,7 +39467,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
39396
39467
|
printTable(rows);
|
|
39397
39468
|
} else {
|
|
39398
39469
|
console.log(
|
|
39399
|
-
|
|
39470
|
+
chalk257.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
39400
39471
|
);
|
|
39401
39472
|
}
|
|
39402
39473
|
} finally {
|
|
@@ -39458,15 +39529,15 @@ function registerSql(program2) {
|
|
|
39458
39529
|
|
|
39459
39530
|
// src/commands/sync.ts
|
|
39460
39531
|
import * as os5 from "os";
|
|
39461
|
-
import * as
|
|
39532
|
+
import * as path102 from "path";
|
|
39462
39533
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
39463
39534
|
|
|
39464
39535
|
// src/commands/sync/pruneCommands.ts
|
|
39465
|
-
import * as
|
|
39536
|
+
import * as path92 from "path";
|
|
39466
39537
|
|
|
39467
39538
|
// src/commands/sync/pruneTarget.ts
|
|
39468
39539
|
import * as fs39 from "fs";
|
|
39469
|
-
import * as
|
|
39540
|
+
import * as path91 from "path";
|
|
39470
39541
|
function pruneTarget(targetDir, keepNames, shape, options2) {
|
|
39471
39542
|
const result = {
|
|
39472
39543
|
orphans: [],
|
|
@@ -39484,7 +39555,7 @@ function pruneTarget(targetDir, keepNames, shape, options2) {
|
|
|
39484
39555
|
}
|
|
39485
39556
|
if (keep.has(name)) continue;
|
|
39486
39557
|
result.orphans.push(entry.name);
|
|
39487
|
-
const entryPath =
|
|
39558
|
+
const entryPath = path91.join(targetDir, entry.name);
|
|
39488
39559
|
const reason4 = shape.blockedBy?.(entryPath);
|
|
39489
39560
|
if (reason4) {
|
|
39490
39561
|
result.skipped.push({ name: entry.name, reason: reason4 });
|
|
@@ -39504,7 +39575,7 @@ function pruneCommands(targetDir, commandNames, options2) {
|
|
|
39504
39575
|
targetDir,
|
|
39505
39576
|
commandNames,
|
|
39506
39577
|
{
|
|
39507
|
-
nameOf: (entry) => entry.isFile() && entry.name.endsWith(".md") ?
|
|
39578
|
+
nameOf: (entry) => entry.isFile() && entry.name.endsWith(".md") ? path92.basename(entry.name, ".md") : void 0
|
|
39508
39579
|
},
|
|
39509
39580
|
options2
|
|
39510
39581
|
);
|
|
@@ -39539,16 +39610,16 @@ function reportPrune(label2, result, force) {
|
|
|
39539
39610
|
|
|
39540
39611
|
// src/commands/sync/syncClaudeCommands.ts
|
|
39541
39612
|
import * as fs43 from "fs";
|
|
39542
|
-
import * as
|
|
39613
|
+
import * as path96 from "path";
|
|
39543
39614
|
|
|
39544
39615
|
// src/commands/sync/syncCodex.ts
|
|
39545
|
-
import * as
|
|
39616
|
+
import * as path95 from "path";
|
|
39546
39617
|
|
|
39547
39618
|
// src/commands/sync/installHarnessCommands.ts
|
|
39548
39619
|
import * as fs40 from "fs";
|
|
39549
|
-
import * as
|
|
39620
|
+
import * as path93 from "path";
|
|
39550
39621
|
function installHarnessCommands(claudeDir, harness, transform) {
|
|
39551
|
-
const commandsSource =
|
|
39622
|
+
const commandsSource = path93.join(claudeDir, "commands");
|
|
39552
39623
|
const files = fs40.readdirSync(commandsSource);
|
|
39553
39624
|
const names = [];
|
|
39554
39625
|
let synced = 0;
|
|
@@ -39556,9 +39627,9 @@ function installHarnessCommands(claudeDir, harness, transform) {
|
|
|
39556
39627
|
if (!file.endsWith(".md")) continue;
|
|
39557
39628
|
const name = file.replace(/\.md$/, "");
|
|
39558
39629
|
names.push(name);
|
|
39559
|
-
const content = fs40.readFileSync(
|
|
39560
|
-
const target =
|
|
39561
|
-
fs40.mkdirSync(
|
|
39630
|
+
const content = fs40.readFileSync(path93.join(commandsSource, file), "utf8");
|
|
39631
|
+
const target = path93.join(harness.homeDir, harness.sync.commandDest(name));
|
|
39632
|
+
fs40.mkdirSync(path93.dirname(target), { recursive: true });
|
|
39562
39633
|
fs40.writeFileSync(target, transform(name, content));
|
|
39563
39634
|
synced++;
|
|
39564
39635
|
}
|
|
@@ -39587,7 +39658,7 @@ function unexpectedContent(skillDir) {
|
|
|
39587
39658
|
|
|
39588
39659
|
// src/commands/sync/syncCodexHooks.ts
|
|
39589
39660
|
import * as fs42 from "fs";
|
|
39590
|
-
import * as
|
|
39661
|
+
import * as path94 from "path";
|
|
39591
39662
|
var BEGIN = "# >>> assist codex hooks (managed) \u2014 do not edit >>>";
|
|
39592
39663
|
var END = "# <<< assist codex hooks (managed) <<<";
|
|
39593
39664
|
function upsertManagedBlock(existing, body) {
|
|
@@ -39618,9 +39689,9 @@ ${rest}
|
|
|
39618
39689
|
}
|
|
39619
39690
|
function syncCodexHooks(sourcePath) {
|
|
39620
39691
|
const body = fs42.readFileSync(sourcePath, "utf8");
|
|
39621
|
-
const configPath =
|
|
39692
|
+
const configPath = path94.join(harnesses.codex.homeDir, "config.toml");
|
|
39622
39693
|
const existing = fs42.existsSync(configPath) ? fs42.readFileSync(configPath, "utf8") : "";
|
|
39623
|
-
fs42.mkdirSync(
|
|
39694
|
+
fs42.mkdirSync(path94.dirname(configPath), { recursive: true });
|
|
39624
39695
|
fs42.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
39625
39696
|
console.log(
|
|
39626
39697
|
"Registered assist codex-hook in ~/.codex/config.toml (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop)"
|
|
@@ -39652,13 +39723,13 @@ function syncCodex(claudeDir, options2) {
|
|
|
39652
39723
|
harnesses.codex,
|
|
39653
39724
|
commandToSkill
|
|
39654
39725
|
);
|
|
39655
|
-
syncCodexHooks(
|
|
39726
|
+
syncCodexHooks(path95.join(claudeDir, "..", "codex", "config.toml"));
|
|
39656
39727
|
console.log(`Synced ${total} skill(s) to ~/.codex/skills`);
|
|
39657
39728
|
if (!options2?.prune) return;
|
|
39658
39729
|
const force = options2.force ?? false;
|
|
39659
39730
|
reportPrune(
|
|
39660
39731
|
"~/.codex/skills",
|
|
39661
|
-
pruneSkills(
|
|
39732
|
+
pruneSkills(path95.join(harnesses.codex.homeDir, "skills"), names, { force }),
|
|
39662
39733
|
force
|
|
39663
39734
|
);
|
|
39664
39735
|
}
|
|
@@ -39673,30 +39744,30 @@ function replaceFileWithoutFollowingSymlink(file, content) {
|
|
|
39673
39744
|
fs43.writeFileSync(file, content);
|
|
39674
39745
|
}
|
|
39675
39746
|
function writeSkill(targetBase, name, content) {
|
|
39676
|
-
const skillDir =
|
|
39747
|
+
const skillDir = path96.join(targetBase, "skills", name);
|
|
39677
39748
|
fs43.mkdirSync(skillDir, { recursive: true });
|
|
39678
39749
|
replaceFileWithoutFollowingSymlink(
|
|
39679
|
-
|
|
39750
|
+
path96.join(skillDir, "SKILL.md"),
|
|
39680
39751
|
commandToSkill(name, content)
|
|
39681
39752
|
);
|
|
39682
|
-
fs43.rmSync(
|
|
39753
|
+
fs43.rmSync(path96.join(targetBase, "commands", `${name}.md`), { force: true });
|
|
39683
39754
|
console.log(`Wrote ${name} as a skill to ${skillDir}`);
|
|
39684
39755
|
}
|
|
39685
39756
|
function syncClaudeCommands(claudeDir, targetBase) {
|
|
39686
|
-
const sourceDir =
|
|
39687
|
-
const targetDir =
|
|
39757
|
+
const sourceDir = path96.join(claudeDir, "commands");
|
|
39758
|
+
const targetDir = path96.join(targetBase, "commands");
|
|
39688
39759
|
fs43.mkdirSync(targetDir, { recursive: true });
|
|
39689
39760
|
const files = fs43.readdirSync(sourceDir);
|
|
39690
39761
|
for (const file of files) {
|
|
39691
|
-
const source =
|
|
39762
|
+
const source = path96.join(sourceDir, file);
|
|
39692
39763
|
if (file.endsWith(".md")) {
|
|
39693
39764
|
const content = fs43.readFileSync(source, "utf8");
|
|
39694
39765
|
if (isSkillFlagged(content)) {
|
|
39695
|
-
writeSkill(targetBase,
|
|
39766
|
+
writeSkill(targetBase, path96.basename(file, ".md"), content);
|
|
39696
39767
|
continue;
|
|
39697
39768
|
}
|
|
39698
39769
|
}
|
|
39699
|
-
fs43.copyFileSync(source,
|
|
39770
|
+
fs43.copyFileSync(source, path96.join(targetDir, file));
|
|
39700
39771
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
39701
39772
|
}
|
|
39702
39773
|
console.log(`Synced ${files.length} command(s) to ~/.claude`);
|
|
@@ -39705,11 +39776,11 @@ function syncClaudeCommands(claudeDir, targetBase) {
|
|
|
39705
39776
|
|
|
39706
39777
|
// src/commands/sync/reportRetiredAgentsFiles.ts
|
|
39707
39778
|
import * as fs44 from "fs";
|
|
39708
|
-
import * as
|
|
39779
|
+
import * as path97 from "path";
|
|
39709
39780
|
var retired = [
|
|
39710
|
-
|
|
39711
|
-
|
|
39712
|
-
|
|
39781
|
+
path97.join(harnesses.claude.homeDir, "CLAUDE.md"),
|
|
39782
|
+
path97.join(harnesses.codex.homeDir, "AGENTS.md"),
|
|
39783
|
+
path97.join(harnesses.pi.homeDir, "AGENTS.md")
|
|
39713
39784
|
];
|
|
39714
39785
|
function reportRetiredAgentsFiles() {
|
|
39715
39786
|
const leftovers = retired.filter((file) => fs44.existsSync(file));
|
|
@@ -39725,21 +39796,21 @@ function reportRetiredAgentsFiles() {
|
|
|
39725
39796
|
|
|
39726
39797
|
// src/commands/sync/syncDesign.ts
|
|
39727
39798
|
import * as fs45 from "fs";
|
|
39728
|
-
import * as
|
|
39799
|
+
import * as path98 from "path";
|
|
39729
39800
|
function syncDesign(claudeDir, targetBase) {
|
|
39730
|
-
const systemPromptSource =
|
|
39731
|
-
const systemPromptTarget =
|
|
39801
|
+
const systemPromptSource = path98.join(claudeDir, "design-system-prompt.md");
|
|
39802
|
+
const systemPromptTarget = path98.join(targetBase, "design-system-prompt.md");
|
|
39732
39803
|
fs45.copyFileSync(systemPromptSource, systemPromptTarget);
|
|
39733
39804
|
console.log(
|
|
39734
39805
|
"Copied design-system-prompt.md to ~/.claude/design-system-prompt.md"
|
|
39735
39806
|
);
|
|
39736
|
-
const skillsSource =
|
|
39737
|
-
const skillsTarget =
|
|
39807
|
+
const skillsSource = path98.join(claudeDir, "skills");
|
|
39808
|
+
const skillsTarget = path98.join(targetBase, "skills");
|
|
39738
39809
|
fs45.mkdirSync(skillsTarget, { recursive: true });
|
|
39739
39810
|
const entries = fs45.readdirSync(skillsSource, { withFileTypes: true });
|
|
39740
39811
|
for (const entry of entries) {
|
|
39741
|
-
const source =
|
|
39742
|
-
const target =
|
|
39812
|
+
const source = path98.join(skillsSource, entry.name);
|
|
39813
|
+
const target = path98.join(skillsTarget, entry.name);
|
|
39743
39814
|
if (entry.isDirectory()) {
|
|
39744
39815
|
fs45.rmSync(target, { recursive: true, force: true });
|
|
39745
39816
|
fs45.cpSync(source, target, { recursive: true });
|
|
@@ -39751,13 +39822,13 @@ function syncDesign(claudeDir, targetBase) {
|
|
|
39751
39822
|
}
|
|
39752
39823
|
|
|
39753
39824
|
// src/commands/sync/syncPi.ts
|
|
39754
|
-
import * as
|
|
39825
|
+
import * as path100 from "path";
|
|
39755
39826
|
|
|
39756
39827
|
// src/commands/sync/syncPiHooks.ts
|
|
39757
39828
|
import * as fs46 from "fs";
|
|
39758
|
-
import * as
|
|
39829
|
+
import * as path99 from "path";
|
|
39759
39830
|
function piExtensionsDir() {
|
|
39760
|
-
return
|
|
39831
|
+
return path99.join(harnesses.pi.homeDir, "extensions");
|
|
39761
39832
|
}
|
|
39762
39833
|
function syncPiHooks(sourceDir) {
|
|
39763
39834
|
const target = piExtensionsDir();
|
|
@@ -39765,8 +39836,8 @@ function syncPiHooks(sourceDir) {
|
|
|
39765
39836
|
const files = fs46.readdirSync(sourceDir).filter((f) => f.endsWith(".ts"));
|
|
39766
39837
|
for (const file of files) {
|
|
39767
39838
|
fs46.copyFileSync(
|
|
39768
|
-
|
|
39769
|
-
|
|
39839
|
+
path99.join(sourceDir, file),
|
|
39840
|
+
path99.join(target, `assist-${file}`)
|
|
39770
39841
|
);
|
|
39771
39842
|
}
|
|
39772
39843
|
console.log(
|
|
@@ -39803,24 +39874,24 @@ function syncPi(claudeDir, options2) {
|
|
|
39803
39874
|
harnesses.pi,
|
|
39804
39875
|
commandToPrompt
|
|
39805
39876
|
);
|
|
39806
|
-
syncPiHooks(
|
|
39877
|
+
syncPiHooks(path100.join(claudeDir, "..", "pi"));
|
|
39807
39878
|
console.log(`Synced ${synced} prompt(s) to ~/.pi/agent/prompts`);
|
|
39808
39879
|
if (!options2?.prune) return;
|
|
39809
39880
|
const force = options2.force ?? false;
|
|
39810
39881
|
reportPrune(
|
|
39811
39882
|
"~/.pi/agent/prompts",
|
|
39812
|
-
pruneCommands(
|
|
39883
|
+
pruneCommands(path100.join(harnesses.pi.homeDir, "prompts"), names, { force }),
|
|
39813
39884
|
force
|
|
39814
39885
|
);
|
|
39815
39886
|
}
|
|
39816
39887
|
|
|
39817
39888
|
// src/commands/sync/syncSettings.ts
|
|
39818
39889
|
import * as fs47 from "fs";
|
|
39819
|
-
import * as
|
|
39820
|
-
import
|
|
39890
|
+
import * as path101 from "path";
|
|
39891
|
+
import chalk258 from "chalk";
|
|
39821
39892
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
39822
|
-
const source =
|
|
39823
|
-
const target =
|
|
39893
|
+
const source = path101.join(claudeDir, "settings.json");
|
|
39894
|
+
const target = path101.join(targetBase, "settings.json");
|
|
39824
39895
|
const sourceContent = fs47.readFileSync(source, "utf8");
|
|
39825
39896
|
const sourceSettings = JSON.parse(sourceContent);
|
|
39826
39897
|
const targetExists = fs47.existsSync(target);
|
|
@@ -39836,7 +39907,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
39836
39907
|
if (mergedContent !== normalizedTarget) {
|
|
39837
39908
|
if (!options2?.yes) {
|
|
39838
39909
|
console.log(
|
|
39839
|
-
|
|
39910
|
+
chalk258.yellow(
|
|
39840
39911
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
39841
39912
|
)
|
|
39842
39913
|
);
|
|
@@ -39844,7 +39915,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
39844
39915
|
printDiff(targetContent, mergedContent);
|
|
39845
39916
|
printAutoConfirmHint();
|
|
39846
39917
|
const confirm = await promptConfirm(
|
|
39847
|
-
|
|
39918
|
+
chalk258.red("Overwrite existing settings.json?"),
|
|
39848
39919
|
false
|
|
39849
39920
|
);
|
|
39850
39921
|
if (!confirm) {
|
|
@@ -39860,13 +39931,13 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
39860
39931
|
|
|
39861
39932
|
// src/commands/sync.ts
|
|
39862
39933
|
var __filename4 = fileURLToPath8(import.meta.url);
|
|
39863
|
-
var __dirname5 =
|
|
39934
|
+
var __dirname5 = path102.dirname(__filename4);
|
|
39864
39935
|
async function sync(options2) {
|
|
39865
39936
|
const config = loadConfig();
|
|
39866
39937
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
39867
39938
|
const prune = { prune: options2?.prune, force: options2?.force };
|
|
39868
|
-
const claudeDir =
|
|
39869
|
-
const targetBase =
|
|
39939
|
+
const claudeDir = path102.join(__dirname5, "..", "claude");
|
|
39940
|
+
const targetBase = path102.join(os5.homedir(), ".claude");
|
|
39870
39941
|
const commandFiles = syncClaudeCommands(claudeDir, targetBase);
|
|
39871
39942
|
syncDesign(claudeDir, targetBase);
|
|
39872
39943
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
@@ -39874,11 +39945,11 @@ async function sync(options2) {
|
|
|
39874
39945
|
syncPi(claudeDir, prune);
|
|
39875
39946
|
reportRetiredAgentsFiles();
|
|
39876
39947
|
if (!options2?.prune) return;
|
|
39877
|
-
const commandNames = commandFiles.filter((file) => file.endsWith(".md")).map((file) =>
|
|
39948
|
+
const commandNames = commandFiles.filter((file) => file.endsWith(".md")).map((file) => path102.basename(file, ".md"));
|
|
39878
39949
|
const force = options2.force ?? false;
|
|
39879
39950
|
reportPrune(
|
|
39880
39951
|
"~/.claude/commands",
|
|
39881
|
-
pruneCommands(
|
|
39952
|
+
pruneCommands(path102.join(targetBase, "commands"), commandNames, { force }),
|
|
39882
39953
|
force
|
|
39883
39954
|
);
|
|
39884
39955
|
}
|
|
@@ -40934,9 +41005,9 @@ import { existsSync as existsSync81, readFileSync as readFileSync64 } from "fs";
|
|
|
40934
41005
|
|
|
40935
41006
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
40936
41007
|
import { minimatch as minimatch10 } from "minimatch";
|
|
40937
|
-
function resolveStringsAtPath(data,
|
|
41008
|
+
function resolveStringsAtPath(data, path109) {
|
|
40938
41009
|
let current = data;
|
|
40939
|
-
for (const segment of
|
|
41010
|
+
for (const segment of path109.split(".")) {
|
|
40940
41011
|
if (current === null || typeof current !== "object") return [];
|
|
40941
41012
|
current = current[segment];
|
|
40942
41013
|
}
|
|
@@ -40949,10 +41020,10 @@ function resolveStringsAtPath(data, path108) {
|
|
|
40949
41020
|
}
|
|
40950
41021
|
function findRuleViolations(data, rule) {
|
|
40951
41022
|
const violations = [];
|
|
40952
|
-
for (const
|
|
40953
|
-
for (const value of resolveStringsAtPath(data,
|
|
41023
|
+
for (const path109 of rule.paths) {
|
|
41024
|
+
for (const value of resolveStringsAtPath(data, path109)) {
|
|
40954
41025
|
if (minimatch10(value, rule.disallowed))
|
|
40955
|
-
violations.push({ file: rule.file, path:
|
|
41026
|
+
violations.push({ file: rule.file, path: path109, value });
|
|
40956
41027
|
}
|
|
40957
41028
|
}
|
|
40958
41029
|
return violations;
|
|
@@ -40991,8 +41062,8 @@ function forbiddenStrings() {
|
|
|
40991
41062
|
process.exit(0);
|
|
40992
41063
|
}
|
|
40993
41064
|
console.log("Forbidden strings found:\n");
|
|
40994
|
-
for (const { file, path:
|
|
40995
|
-
console.log(` ${file} ${
|
|
41065
|
+
for (const { file, path: path109, value } of violations) {
|
|
41066
|
+
console.log(` ${file} ${path109}: ${value}`);
|
|
40996
41067
|
}
|
|
40997
41068
|
console.log(`
|
|
40998
41069
|
Total: ${violations.length} forbidden string(s).`);
|
|
@@ -41048,7 +41119,7 @@ Total: ${lines2.length} hardcoded color(s)`);
|
|
|
41048
41119
|
|
|
41049
41120
|
// src/commands/verify/migrations.ts
|
|
41050
41121
|
import { readFileSync as readFileSync65 } from "fs";
|
|
41051
|
-
import
|
|
41122
|
+
import path104 from "path";
|
|
41052
41123
|
|
|
41053
41124
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
41054
41125
|
function checkAppendOnly(baseline, current) {
|
|
@@ -41140,15 +41211,15 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
41140
41211
|
} catch {
|
|
41141
41212
|
return baseline;
|
|
41142
41213
|
}
|
|
41143
|
-
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((
|
|
41144
|
-
for (const
|
|
41214
|
+
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path109) => MIGRATION_FILE3.test(basename31(path109)));
|
|
41215
|
+
for (const path109 of paths) {
|
|
41145
41216
|
try {
|
|
41146
|
-
const content = execSync64(`git show "${ref}:${
|
|
41217
|
+
const content = execSync64(`git show "${ref}:${path109}"`, {
|
|
41147
41218
|
encoding: "utf8",
|
|
41148
41219
|
maxBuffer: 16 * 1024 * 1024,
|
|
41149
41220
|
stdio: ["pipe", "pipe", "pipe"]
|
|
41150
41221
|
});
|
|
41151
|
-
baseline.set(basename31(
|
|
41222
|
+
baseline.set(basename31(path109), content);
|
|
41152
41223
|
} catch {
|
|
41153
41224
|
}
|
|
41154
41225
|
}
|
|
@@ -41187,11 +41258,11 @@ function resolveBaselineRef() {
|
|
|
41187
41258
|
}
|
|
41188
41259
|
|
|
41189
41260
|
// src/commands/verify/migrations/migrationsDir.ts
|
|
41190
|
-
import
|
|
41261
|
+
import path103 from "path";
|
|
41191
41262
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
41192
41263
|
function migrationsDir() {
|
|
41193
|
-
return
|
|
41194
|
-
|
|
41264
|
+
return path103.resolve(
|
|
41265
|
+
path103.dirname(fileURLToPath9(import.meta.url)),
|
|
41195
41266
|
"../../../shared/db/migrations"
|
|
41196
41267
|
);
|
|
41197
41268
|
}
|
|
@@ -41212,7 +41283,7 @@ function migrations2() {
|
|
|
41212
41283
|
if (ref) {
|
|
41213
41284
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
41214
41285
|
const current = new Map(
|
|
41215
|
-
files.map((file) => [file, readFileSync65(
|
|
41286
|
+
files.map((file) => [file, readFileSync65(path104.join(dir, file), "utf8")])
|
|
41216
41287
|
);
|
|
41217
41288
|
for (const finding of checkAppendOnly(baseline, current)) {
|
|
41218
41289
|
problems.push(
|
|
@@ -41491,27 +41562,27 @@ function restartAdvice(paths) {
|
|
|
41491
41562
|
// src/commands/watch/syncAdvice.ts
|
|
41492
41563
|
var rules = [
|
|
41493
41564
|
{
|
|
41494
|
-
matches: (
|
|
41565
|
+
matches: (path109) => path109.startsWith("claude/commands/"),
|
|
41495
41566
|
reason: "claude/commands changed"
|
|
41496
41567
|
},
|
|
41497
41568
|
{
|
|
41498
|
-
matches: (
|
|
41569
|
+
matches: (path109) => path109.startsWith("claude/skills/"),
|
|
41499
41570
|
reason: "claude/skills changed"
|
|
41500
41571
|
},
|
|
41501
41572
|
{
|
|
41502
|
-
matches: (
|
|
41573
|
+
matches: (path109) => path109 === "claude/settings.json",
|
|
41503
41574
|
reason: "claude/settings.json changed"
|
|
41504
41575
|
},
|
|
41505
41576
|
{
|
|
41506
|
-
matches: (
|
|
41577
|
+
matches: (path109) => path109 === "claude/design-system-prompt.md",
|
|
41507
41578
|
reason: "claude/design-system-prompt.md changed"
|
|
41508
41579
|
},
|
|
41509
41580
|
{
|
|
41510
|
-
matches: (
|
|
41581
|
+
matches: (path109) => path109.startsWith("codex/"),
|
|
41511
41582
|
reason: "codex sources changed"
|
|
41512
41583
|
},
|
|
41513
41584
|
{
|
|
41514
|
-
matches: (
|
|
41585
|
+
matches: (path109) => path109.startsWith("pi/"),
|
|
41515
41586
|
reason: "pi sources changed"
|
|
41516
41587
|
}
|
|
41517
41588
|
];
|
|
@@ -41888,10 +41959,10 @@ ${buildWatchReport(from)}`);
|
|
|
41888
41959
|
|
|
41889
41960
|
// src/commands/watch/consumeMarker.ts
|
|
41890
41961
|
import { existsSync as existsSync83, rmSync as rmSync8 } from "fs";
|
|
41891
|
-
function consumeMarker(
|
|
41962
|
+
function consumeMarker(path109) {
|
|
41892
41963
|
try {
|
|
41893
|
-
if (!existsSync83(
|
|
41894
|
-
rmSync8(
|
|
41964
|
+
if (!existsSync83(path109)) return false;
|
|
41965
|
+
rmSync8(path109);
|
|
41895
41966
|
return true;
|
|
41896
41967
|
} catch {
|
|
41897
41968
|
return false;
|
|
@@ -42065,7 +42136,7 @@ function registerWatch(program2) {
|
|
|
42065
42136
|
|
|
42066
42137
|
// src/commands/roam/auth.ts
|
|
42067
42138
|
import { randomBytes } from "crypto";
|
|
42068
|
-
import
|
|
42139
|
+
import chalk259 from "chalk";
|
|
42069
42140
|
|
|
42070
42141
|
// src/commands/roam/waitForCallback.ts
|
|
42071
42142
|
import { createServer as createServer3 } from "http";
|
|
@@ -42196,13 +42267,13 @@ async function auth() {
|
|
|
42196
42267
|
saveGlobalConfig(config);
|
|
42197
42268
|
const state = randomBytes(16).toString("hex");
|
|
42198
42269
|
console.log(
|
|
42199
|
-
|
|
42270
|
+
chalk259.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
42200
42271
|
);
|
|
42201
|
-
console.log(
|
|
42202
|
-
console.log(
|
|
42203
|
-
console.log(
|
|
42272
|
+
console.log(chalk259.white("http://localhost:14523/callback\n"));
|
|
42273
|
+
console.log(chalk259.blue("Opening browser for authorization..."));
|
|
42274
|
+
console.log(chalk259.dim("Waiting for authorization callback..."));
|
|
42204
42275
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
42205
|
-
console.log(
|
|
42276
|
+
console.log(chalk259.dim("Exchanging code for tokens..."));
|
|
42206
42277
|
const tokens = await exchangeToken({
|
|
42207
42278
|
code,
|
|
42208
42279
|
clientId,
|
|
@@ -42218,7 +42289,7 @@ async function auth() {
|
|
|
42218
42289
|
};
|
|
42219
42290
|
saveGlobalConfig(config);
|
|
42220
42291
|
console.log(
|
|
42221
|
-
|
|
42292
|
+
chalk259.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
42222
42293
|
);
|
|
42223
42294
|
}
|
|
42224
42295
|
|
|
@@ -42234,9 +42305,9 @@ function findPortFile(roamDir) {
|
|
|
42234
42305
|
return void 0;
|
|
42235
42306
|
}
|
|
42236
42307
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
42237
|
-
const
|
|
42308
|
+
const path109 = join102(roamDir, name);
|
|
42238
42309
|
try {
|
|
42239
|
-
return { path:
|
|
42310
|
+
return { path: path109, mtimeMs: statSync14(path109).mtimeMs };
|
|
42240
42311
|
} catch {
|
|
42241
42312
|
return void 0;
|
|
42242
42313
|
}
|
|
@@ -42539,11 +42610,11 @@ function findLinkIndex() {
|
|
|
42539
42610
|
function parseLinkArgs() {
|
|
42540
42611
|
const idx = findLinkIndex();
|
|
42541
42612
|
if (idx === -1) return null;
|
|
42542
|
-
const
|
|
42613
|
+
const path109 = process.argv[idx + 1];
|
|
42543
42614
|
const rest = process.argv.slice(idx + 2);
|
|
42544
42615
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
42545
42616
|
if (!prefix2) return null;
|
|
42546
|
-
return { path:
|
|
42617
|
+
return { path: path109, prefix: prefix2 };
|
|
42547
42618
|
}
|
|
42548
42619
|
function hasDuplicateLink(runList, linkPath) {
|
|
42549
42620
|
return runList.some(
|
|
@@ -42658,18 +42729,18 @@ function registerRun(program2) {
|
|
|
42658
42729
|
}
|
|
42659
42730
|
|
|
42660
42731
|
// src/commands/sessions/nodes/formatLink.ts
|
|
42661
|
-
import
|
|
42732
|
+
import chalk260 from "chalk";
|
|
42662
42733
|
var STATE_COLOURS = {
|
|
42663
|
-
connected:
|
|
42664
|
-
connecting:
|
|
42665
|
-
disconnected:
|
|
42666
|
-
"version-blocked":
|
|
42734
|
+
connected: chalk260.green,
|
|
42735
|
+
connecting: chalk260.yellow,
|
|
42736
|
+
disconnected: chalk260.red,
|
|
42737
|
+
"version-blocked": chalk260.red
|
|
42667
42738
|
};
|
|
42668
42739
|
function formatLink(link3) {
|
|
42669
|
-
const colour = STATE_COLOURS[link3.state] ??
|
|
42740
|
+
const colour = STATE_COLOURS[link3.state] ?? chalk260.white;
|
|
42670
42741
|
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
42671
42742
|
const error = link3.error ? `
|
|
42672
|
-
${
|
|
42743
|
+
${chalk260.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
42673
42744
|
return ` ${link3.name} ${colour(link3.state)} ${link3.url}${peer}${error}`;
|
|
42674
42745
|
}
|
|
42675
42746
|
|
|
@@ -43510,14 +43581,14 @@ import * as pty from "node-pty";
|
|
|
43510
43581
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
43511
43582
|
import { chmodSync, existsSync as existsSync86, statSync as statSync15 } from "fs";
|
|
43512
43583
|
import { createRequire as createRequire3 } from "module";
|
|
43513
|
-
import
|
|
43584
|
+
import path105 from "path";
|
|
43514
43585
|
var require4 = createRequire3(import.meta.url);
|
|
43515
43586
|
var ensured = false;
|
|
43516
43587
|
function ensureSpawnHelperExecutable() {
|
|
43517
43588
|
if (ensured || process.platform !== "darwin") return;
|
|
43518
43589
|
ensured = true;
|
|
43519
|
-
const ptyRoot =
|
|
43520
|
-
const helper =
|
|
43590
|
+
const ptyRoot = path105.join(path105.dirname(require4.resolve("node-pty")), "..");
|
|
43591
|
+
const helper = path105.join(
|
|
43521
43592
|
ptyRoot,
|
|
43522
43593
|
"prebuilds",
|
|
43523
43594
|
`${process.platform}-${process.arch}`,
|
|
@@ -43665,12 +43736,12 @@ function serverRunMeta(runName, cwd) {
|
|
|
43665
43736
|
|
|
43666
43737
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
43667
43738
|
import * as fs50 from "fs";
|
|
43668
|
-
import * as
|
|
43739
|
+
import * as path106 from "path";
|
|
43669
43740
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
43670
43741
|
var __filename5 = fileURLToPath10(import.meta.url);
|
|
43671
|
-
var __dirname6 =
|
|
43742
|
+
var __dirname6 = path106.dirname(__filename5);
|
|
43672
43743
|
function readDesignSystemPrompt() {
|
|
43673
|
-
const promptPath =
|
|
43744
|
+
const promptPath = path106.join(
|
|
43674
43745
|
__dirname6,
|
|
43675
43746
|
"..",
|
|
43676
43747
|
"claude",
|
|
@@ -43883,16 +43954,16 @@ import { readFileSync as readFileSync70, writeFileSync as writeFileSync57 } from
|
|
|
43883
43954
|
var KEEP_TAIL = 256 * 1024;
|
|
43884
43955
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
43885
43956
|
function trimWatcherLog(cwd) {
|
|
43886
|
-
const
|
|
43957
|
+
const path109 = watcherLogPath(cwd);
|
|
43887
43958
|
let log2;
|
|
43888
43959
|
try {
|
|
43889
|
-
log2 = readFileSync70(
|
|
43960
|
+
log2 = readFileSync70(path109, "utf8");
|
|
43890
43961
|
} catch {
|
|
43891
43962
|
return;
|
|
43892
43963
|
}
|
|
43893
43964
|
if (log2.length <= MAX_LOG_SIZE) return;
|
|
43894
|
-
writeFileSync57(
|
|
43895
|
-
daemonLog(`auto-update: log ${
|
|
43965
|
+
writeFileSync57(path109, log2.slice(-KEEP_TAIL));
|
|
43966
|
+
daemonLog(`auto-update: log ${path109} trimmed to its last ${KEEP_TAIL} chars`);
|
|
43896
43967
|
}
|
|
43897
43968
|
|
|
43898
43969
|
// src/commands/sessions/daemon/worktree/appendWatcherLog.ts
|
|
@@ -43900,9 +43971,9 @@ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync35 } from "fs"
|
|
|
43900
43971
|
import { dirname as dirname43 } from "path";
|
|
43901
43972
|
function appendWatcherLog(cwd, data) {
|
|
43902
43973
|
try {
|
|
43903
|
-
const
|
|
43904
|
-
mkdirSync35(dirname43(
|
|
43905
|
-
appendFileSync4(
|
|
43974
|
+
const path109 = watcherLogPath(cwd);
|
|
43975
|
+
mkdirSync35(dirname43(path109), { recursive: true });
|
|
43976
|
+
appendFileSync4(path109, data);
|
|
43906
43977
|
} catch {
|
|
43907
43978
|
}
|
|
43908
43979
|
}
|
|
@@ -44083,8 +44154,8 @@ import { rmSync as rmSync10 } from "fs";
|
|
|
44083
44154
|
function clearLapSignals(cwd) {
|
|
44084
44155
|
const control = watchControlPaths(cwd);
|
|
44085
44156
|
if (!control) return;
|
|
44086
|
-
for (const
|
|
44087
|
-
rmSync10(
|
|
44157
|
+
for (const path109 of [control.check, control.stop])
|
|
44158
|
+
rmSync10(path109, { force: true });
|
|
44088
44159
|
}
|
|
44089
44160
|
function runUpdateLap(cwd, onOutput) {
|
|
44090
44161
|
clearLapSignals(cwd);
|
|
@@ -45256,8 +45327,8 @@ async function seedRunningMsFromUsage(session, notify2) {
|
|
|
45256
45327
|
var DEBOUNCE_MS2 = 50;
|
|
45257
45328
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
45258
45329
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
45259
|
-
const
|
|
45260
|
-
const dir = dirname44(
|
|
45330
|
+
const path109 = activityPath(session.id);
|
|
45331
|
+
const dir = dirname44(path109);
|
|
45261
45332
|
try {
|
|
45262
45333
|
mkdirSync36(dir, { recursive: true });
|
|
45263
45334
|
} catch {
|
|
@@ -45267,7 +45338,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
45267
45338
|
let timer = null;
|
|
45268
45339
|
const read3 = () => {
|
|
45269
45340
|
timer = null;
|
|
45270
|
-
const activity2 = readActivity(
|
|
45341
|
+
const activity2 = readActivity(path109);
|
|
45271
45342
|
if (!activity2) return;
|
|
45272
45343
|
applyActivityToSession(session, activity2);
|
|
45273
45344
|
if (activity2.claudeSessionId) onClaudeSessionId?.(session);
|
|
@@ -45276,11 +45347,11 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
45276
45347
|
notify2();
|
|
45277
45348
|
};
|
|
45278
45349
|
session.activityWatcher = watch2(dir, (_event, filename) => {
|
|
45279
|
-
if (filename && !
|
|
45350
|
+
if (filename && !path109.endsWith(filename)) return;
|
|
45280
45351
|
if (timer) clearTimeout(timer);
|
|
45281
45352
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
45282
45353
|
});
|
|
45283
|
-
if (existsSync93(
|
|
45354
|
+
if (existsSync93(path109)) read3();
|
|
45284
45355
|
}
|
|
45285
45356
|
function refreshActivity(session) {
|
|
45286
45357
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -45424,12 +45495,12 @@ import { watch as watch3 } from "fs";
|
|
|
45424
45495
|
|
|
45425
45496
|
// src/commands/sessions/shared/findTranscriptPathSync.ts
|
|
45426
45497
|
import * as fs52 from "fs";
|
|
45427
|
-
import * as
|
|
45498
|
+
import * as path107 from "path";
|
|
45428
45499
|
function projectDirForCwd(cwd) {
|
|
45429
|
-
return
|
|
45500
|
+
return path107.join(claudeProjectsRoot(), projectSlug(cwd));
|
|
45430
45501
|
}
|
|
45431
45502
|
function transcriptPathFor(cwd, claudeSessionId) {
|
|
45432
|
-
return
|
|
45503
|
+
return path107.join(projectDirForCwd(cwd), `${claudeSessionId}.jsonl`);
|
|
45433
45504
|
}
|
|
45434
45505
|
function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
45435
45506
|
const direct = transcriptPathFor(cwd, claudeSessionId);
|
|
@@ -45443,8 +45514,8 @@ function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
|
45443
45514
|
}
|
|
45444
45515
|
for (const file of files) {
|
|
45445
45516
|
if (!file.endsWith(".jsonl")) continue;
|
|
45446
|
-
if (headContainsSessionId(
|
|
45447
|
-
return
|
|
45517
|
+
if (headContainsSessionId(path107.join(dir, file), claudeSessionId))
|
|
45518
|
+
return path107.join(dir, file);
|
|
45448
45519
|
}
|
|
45449
45520
|
return null;
|
|
45450
45521
|
}
|
|
@@ -46747,9 +46818,9 @@ function tempRoots() {
|
|
|
46747
46818
|
}
|
|
46748
46819
|
return [...roots];
|
|
46749
46820
|
}
|
|
46750
|
-
function underTempRoot(
|
|
46821
|
+
function underTempRoot(path109) {
|
|
46751
46822
|
return tempRoots().some(
|
|
46752
|
-
(root2) =>
|
|
46823
|
+
(root2) => path109.startsWith(root2.endsWith(sep5) ? root2 : root2 + sep5)
|
|
46753
46824
|
);
|
|
46754
46825
|
}
|
|
46755
46826
|
|
|
@@ -47260,15 +47331,15 @@ function accountedTrees(sessions) {
|
|
|
47260
47331
|
import { existsSync as existsSync95 } from "fs";
|
|
47261
47332
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
47262
47333
|
if (!existsSync95(clone)) {
|
|
47263
|
-
for (const { path:
|
|
47334
|
+
for (const { path: path109 } of paths) forgetWorktree(path109);
|
|
47264
47335
|
daemonLog(
|
|
47265
47336
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
47266
47337
|
);
|
|
47267
47338
|
return;
|
|
47268
47339
|
}
|
|
47269
47340
|
await pruneBookkeeping2(clone);
|
|
47270
|
-
for (const { path:
|
|
47271
|
-
if (await reclaimBranch(clone, branch2)) forgetWorktree(
|
|
47341
|
+
for (const { path: path109, branch: branch2 } of paths)
|
|
47342
|
+
if (await reclaimBranch(clone, branch2)) forgetWorktree(path109);
|
|
47272
47343
|
}
|
|
47273
47344
|
async function pruneBookkeeping2(clone) {
|
|
47274
47345
|
try {
|
|
@@ -47295,37 +47366,37 @@ async function reclaimBranch(clone, branch2) {
|
|
|
47295
47366
|
}
|
|
47296
47367
|
|
|
47297
47368
|
// src/commands/sessions/daemon/worktree/logVanishedTree.ts
|
|
47298
|
-
function logVanishedTree(sessions,
|
|
47369
|
+
function logVanishedTree(sessions, path109) {
|
|
47299
47370
|
const claimants = [...sessions.values()].filter(
|
|
47300
|
-
(s) => s.cwd ===
|
|
47371
|
+
(s) => s.cwd === path109 || s.worktree?.path === path109
|
|
47301
47372
|
);
|
|
47302
47373
|
if (claimants.length === 0) {
|
|
47303
|
-
daemonLog(`worktree ${
|
|
47374
|
+
daemonLog(`worktree ${path109} gone from disk and unclaimed; reclaiming it`);
|
|
47304
47375
|
return;
|
|
47305
47376
|
}
|
|
47306
47377
|
for (const s of claimants)
|
|
47307
47378
|
daemonLog(
|
|
47308
|
-
`session ${s.id} ("${s.name}") claims worktree ${
|
|
47379
|
+
`session ${s.id} ("${s.name}") claims worktree ${path109}, which is gone from disk; reclaiming it`
|
|
47309
47380
|
);
|
|
47310
47381
|
}
|
|
47311
47382
|
|
|
47312
47383
|
// src/commands/sessions/daemon/worktree/describeHeldWork.ts
|
|
47313
47384
|
var MAX_ITEMS = 20;
|
|
47314
|
-
async function describeHeldWork(
|
|
47315
|
-
if (reason4.startsWith("uncommitted")) return await changedFiles(
|
|
47316
|
-
if (reason4.startsWith("unpushed")) return await unpushedCommits(
|
|
47385
|
+
async function describeHeldWork(path109, reason4) {
|
|
47386
|
+
if (reason4.startsWith("uncommitted")) return await changedFiles(path109);
|
|
47387
|
+
if (reason4.startsWith("unpushed")) return await unpushedCommits(path109, reason4);
|
|
47317
47388
|
return { summary: reason4, items: [] };
|
|
47318
47389
|
}
|
|
47319
|
-
async function changedFiles(
|
|
47320
|
-
const status2 = await gitResult(
|
|
47390
|
+
async function changedFiles(path109) {
|
|
47391
|
+
const status2 = await gitResult(path109, ["status", "--porcelain"]);
|
|
47321
47392
|
const lines2 = status2.ok ? nonEmptyLines(status2.out) : [];
|
|
47322
47393
|
return {
|
|
47323
47394
|
summary: `${lines2.length} uncommitted ${lines2.length === 1 ? "file" : "files"}`,
|
|
47324
47395
|
items: capped2(lines2)
|
|
47325
47396
|
};
|
|
47326
47397
|
}
|
|
47327
|
-
async function unpushedCommits(
|
|
47328
|
-
const log2 = await gitResult(
|
|
47398
|
+
async function unpushedCommits(path109, reason4) {
|
|
47399
|
+
const log2 = await gitResult(path109, ["log", "--oneline", "@{upstream}..HEAD"]);
|
|
47329
47400
|
if (!log2.ok) return { summary: reason4, items: [] };
|
|
47330
47401
|
const lines2 = nonEmptyLines(log2.out);
|
|
47331
47402
|
return {
|
|
@@ -47417,24 +47488,24 @@ function reconcileWorktreesOnRestore(sessions, spawnWith, notify2) {
|
|
|
47417
47488
|
async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
47418
47489
|
const accounted = accountedTrees(sessions);
|
|
47419
47490
|
const vanished = /* @__PURE__ */ new Map();
|
|
47420
|
-
for (const { path:
|
|
47421
|
-
if (underTempRoot(
|
|
47422
|
-
forgetWorktree(
|
|
47491
|
+
for (const { path: path109, clone } of readWorktreeRegistry()) {
|
|
47492
|
+
if (underTempRoot(path109)) {
|
|
47493
|
+
forgetWorktree(path109);
|
|
47423
47494
|
daemonLog(
|
|
47424
|
-
`worktree ${
|
|
47495
|
+
`worktree ${path109} lies outside any project root; pruned from the registry rather than recovered`
|
|
47425
47496
|
);
|
|
47426
47497
|
continue;
|
|
47427
47498
|
}
|
|
47428
|
-
if (!existsSync96(
|
|
47429
|
-
logVanishedTree(sessions,
|
|
47499
|
+
if (!existsSync96(path109)) {
|
|
47500
|
+
logVanishedTree(sessions, path109);
|
|
47430
47501
|
vanished.set(clone, [
|
|
47431
47502
|
...vanished.get(clone) ?? [],
|
|
47432
|
-
{ path:
|
|
47503
|
+
{ path: path109, branch: basename34(path109) }
|
|
47433
47504
|
]);
|
|
47434
47505
|
continue;
|
|
47435
47506
|
}
|
|
47436
|
-
if (accounted.has(
|
|
47437
|
-
await recoverOrphan(sessions, spawnWith, { path:
|
|
47507
|
+
if (accounted.has(path109)) continue;
|
|
47508
|
+
await recoverOrphan(sessions, spawnWith, { path: path109, clone }, notify2);
|
|
47438
47509
|
}
|
|
47439
47510
|
for (const [clone, paths] of vanished)
|
|
47440
47511
|
await reclaimVanishedWorktrees(clone, paths);
|
|
@@ -49039,12 +49110,12 @@ function handleSetStatus(client, m, d) {
|
|
|
49039
49110
|
import * as fs56 from "fs";
|
|
49040
49111
|
|
|
49041
49112
|
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
49042
|
-
import * as
|
|
49113
|
+
import * as path108 from "path";
|
|
49043
49114
|
async function findCodexRolloutPath(sessionId) {
|
|
49044
49115
|
if (!sessionId) return null;
|
|
49045
49116
|
const paths = await discoverCodexRolloutPaths();
|
|
49046
49117
|
const suffix = `-${sessionId}.jsonl`;
|
|
49047
|
-
return paths.find((file) =>
|
|
49118
|
+
return paths.find((file) => path108.basename(file).endsWith(suffix)) ?? null;
|
|
49048
49119
|
}
|
|
49049
49120
|
|
|
49050
49121
|
// src/commands/sessions/shared/codex/codexToolTarget.ts
|
|
@@ -49647,7 +49718,7 @@ async function findUnlinkedWindowsNode(health2, platform = detectPlatform()) {
|
|
|
49647
49718
|
}
|
|
49648
49719
|
|
|
49649
49720
|
// src/commands/sessions/nodes/printReport.ts
|
|
49650
|
-
import
|
|
49721
|
+
import chalk261 from "chalk";
|
|
49651
49722
|
function printReport(report) {
|
|
49652
49723
|
if (report.links.length === 0) {
|
|
49653
49724
|
console.log(`${report.local} has no links`);
|
|
@@ -49661,11 +49732,11 @@ function printReport(report) {
|
|
|
49661
49732
|
for (const diagnosis of report.links) printDiagnosis(diagnosis);
|
|
49662
49733
|
}
|
|
49663
49734
|
function printDiagnosis(diagnosis) {
|
|
49664
|
-
console.log(`${
|
|
49735
|
+
console.log(`${chalk261.bold(diagnosis.name)} ${chalk261.dim(diagnosis.url)}`);
|
|
49665
49736
|
for (const hop of diagnosis.hops) {
|
|
49666
|
-
const mark = hop.ok ?
|
|
49737
|
+
const mark = hop.ok ? chalk261.green("\u2713") : chalk261.red("\u2717");
|
|
49667
49738
|
console.log(` ${mark} ${hop.hop.padEnd(9)} ${hop.detail ?? hop.error}`);
|
|
49668
|
-
if (hop.remediation) console.log(` ${
|
|
49739
|
+
if (hop.remediation) console.log(` ${chalk261.yellow(hop.remediation)}`);
|
|
49669
49740
|
}
|
|
49670
49741
|
}
|
|
49671
49742
|
|
|
@@ -49685,7 +49756,7 @@ async function doctorNodes(name, options2) {
|
|
|
49685
49756
|
}
|
|
49686
49757
|
|
|
49687
49758
|
// src/commands/sessions/nodes/listNodes.ts
|
|
49688
|
-
import
|
|
49759
|
+
import chalk262 from "chalk";
|
|
49689
49760
|
async function nodesReport() {
|
|
49690
49761
|
const live = await queryNodes();
|
|
49691
49762
|
if (live)
|
|
@@ -49702,10 +49773,10 @@ async function listNodes(options2) {
|
|
|
49702
49773
|
console.log(JSON.stringify(report, null, 2));
|
|
49703
49774
|
return;
|
|
49704
49775
|
}
|
|
49705
|
-
console.log(`${report.local} ${
|
|
49776
|
+
console.log(`${report.local} ${chalk262.dim("(this node)")}`);
|
|
49706
49777
|
if (!report.daemonRunning)
|
|
49707
|
-
console.log(
|
|
49708
|
-
if (report.links.length === 0) console.log(
|
|
49778
|
+
console.log(chalk262.dim(" daemon not running; showing configured links"));
|
|
49779
|
+
if (report.links.length === 0) console.log(chalk262.dim(" no links"));
|
|
49709
49780
|
for (const link3 of report.links) console.log(formatLink(link3));
|
|
49710
49781
|
}
|
|
49711
49782
|
|
|
@@ -49744,14 +49815,14 @@ async function nodeLogs(name, options2) {
|
|
|
49744
49815
|
}
|
|
49745
49816
|
|
|
49746
49817
|
// src/commands/sessions/nodes/linkNode.ts
|
|
49747
|
-
import
|
|
49818
|
+
import chalk265 from "chalk";
|
|
49748
49819
|
|
|
49749
49820
|
// src/commands/sessions/nodes/notifyDaemonLinks.ts
|
|
49750
|
-
import
|
|
49821
|
+
import chalk263 from "chalk";
|
|
49751
49822
|
async function notifyDaemonLinks() {
|
|
49752
49823
|
if (!await isDaemonRunning()) {
|
|
49753
49824
|
console.log(
|
|
49754
|
-
|
|
49825
|
+
chalk263.yellow(
|
|
49755
49826
|
"The sessions daemon is not running; it loads the links when it starts."
|
|
49756
49827
|
)
|
|
49757
49828
|
);
|
|
@@ -49759,11 +49830,11 @@ async function notifyDaemonLinks() {
|
|
|
49759
49830
|
}
|
|
49760
49831
|
try {
|
|
49761
49832
|
await sendToDaemonAwaitAck({ type: "reload-links" });
|
|
49762
|
-
console.log(
|
|
49833
|
+
console.log(chalk263.dim("The sessions daemon reloaded its links."));
|
|
49763
49834
|
} catch (error) {
|
|
49764
49835
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
49765
49836
|
console.log(
|
|
49766
|
-
|
|
49837
|
+
chalk263.yellow(
|
|
49767
49838
|
`Could not notify the sessions daemon (${message3}); run \`assist daemon restart\` to apply the change.`
|
|
49768
49839
|
)
|
|
49769
49840
|
);
|
|
@@ -49771,7 +49842,7 @@ async function notifyDaemonLinks() {
|
|
|
49771
49842
|
}
|
|
49772
49843
|
|
|
49773
49844
|
// src/commands/sessions/nodes/readLinks.ts
|
|
49774
|
-
import
|
|
49845
|
+
import chalk264 from "chalk";
|
|
49775
49846
|
|
|
49776
49847
|
// src/commands/sessions/nodes/writeLinks.ts
|
|
49777
49848
|
async function writeLinks(links2) {
|
|
@@ -49794,7 +49865,7 @@ async function readLinks() {
|
|
|
49794
49865
|
await writeLinks(links2);
|
|
49795
49866
|
const dropped = stored.filter((link3) => !link3.url).map((link3) => link3.name);
|
|
49796
49867
|
console.log(
|
|
49797
|
-
|
|
49868
|
+
chalk264.yellow(`Removed ${dropped.join(", ")}: ${SSH_LINK_RETIRED}`)
|
|
49798
49869
|
);
|
|
49799
49870
|
return links2;
|
|
49800
49871
|
}
|
|
@@ -49850,7 +49921,7 @@ async function linkNode(name, url, options2) {
|
|
|
49850
49921
|
throw new Error(`${name} is this node; link to a different node`);
|
|
49851
49922
|
const link3 = await buildLink(name, url, options2);
|
|
49852
49923
|
await writeLinks([...others, link3]);
|
|
49853
|
-
console.log(
|
|
49924
|
+
console.log(chalk265.green(`Linked ${name} (${link3.url})`));
|
|
49854
49925
|
await notifyDaemonLinks();
|
|
49855
49926
|
}
|
|
49856
49927
|
|
|
@@ -49884,8 +49955,8 @@ async function awaitLinkReturn(name, options2, deps2 = {}) {
|
|
|
49884
49955
|
}
|
|
49885
49956
|
|
|
49886
49957
|
// src/commands/sessions/nodes/postToPeer.ts
|
|
49887
|
-
async function postToPeer(baseUrl,
|
|
49888
|
-
const res = await fetch(new URL(
|
|
49958
|
+
async function postToPeer(baseUrl, path109, traceId, timeoutMs) {
|
|
49959
|
+
const res = await fetch(new URL(path109, baseUrl), {
|
|
49889
49960
|
method: "POST",
|
|
49890
49961
|
headers: {
|
|
49891
49962
|
"x-assist-linked-from": resolveNodeName(),
|
|
@@ -49895,7 +49966,7 @@ async function postToPeer(baseUrl, path108, traceId, timeoutMs) {
|
|
|
49895
49966
|
});
|
|
49896
49967
|
if (res.ok) return;
|
|
49897
49968
|
const body = await res.json().catch(() => ({}));
|
|
49898
|
-
throw new Error(body.error ?? `POST ${
|
|
49969
|
+
throw new Error(body.error ?? `POST ${path109} returned ${res.status}`);
|
|
49899
49970
|
}
|
|
49900
49971
|
|
|
49901
49972
|
// src/commands/sessions/nodes/startPeerAction.ts
|
|
@@ -49955,16 +50026,16 @@ async function restartNode(name, options2) {
|
|
|
49955
50026
|
}
|
|
49956
50027
|
|
|
49957
50028
|
// src/commands/sessions/nodes/unlinkNode.ts
|
|
49958
|
-
import
|
|
50029
|
+
import chalk266 from "chalk";
|
|
49959
50030
|
async function unlinkNode(name) {
|
|
49960
50031
|
const links2 = await readLinks();
|
|
49961
50032
|
const remaining = links2.filter((link3) => link3.name !== name);
|
|
49962
50033
|
if (remaining.length === links2.length) {
|
|
49963
|
-
console.log(
|
|
50034
|
+
console.log(chalk266.yellow(`No link named ${name}`));
|
|
49964
50035
|
return;
|
|
49965
50036
|
}
|
|
49966
50037
|
await writeLinks(remaining);
|
|
49967
|
-
console.log(
|
|
50038
|
+
console.log(chalk266.green(`Unlinked ${name}`));
|
|
49968
50039
|
await notifyDaemonLinks();
|
|
49969
50040
|
}
|
|
49970
50041
|
|
|
@@ -50163,7 +50234,7 @@ async function renameSession(title) {
|
|
|
50163
50234
|
|
|
50164
50235
|
// src/commands/sessions/summarise.ts
|
|
50165
50236
|
import * as fs58 from "fs";
|
|
50166
|
-
import
|
|
50237
|
+
import chalk267 from "chalk";
|
|
50167
50238
|
|
|
50168
50239
|
// src/commands/sessions/summarise/shared.ts
|
|
50169
50240
|
import * as fs57 from "fs";
|
|
@@ -50222,22 +50293,22 @@ ${firstMessage}`);
|
|
|
50222
50293
|
async function summarise2(options2) {
|
|
50223
50294
|
const files = await discoverSessionFiles();
|
|
50224
50295
|
if (files.length === 0) {
|
|
50225
|
-
console.log(
|
|
50296
|
+
console.log(chalk267.yellow("No sessions found."));
|
|
50226
50297
|
return;
|
|
50227
50298
|
}
|
|
50228
50299
|
const toProcess = selectCandidates(files, options2);
|
|
50229
50300
|
if (toProcess.length === 0) {
|
|
50230
|
-
console.log(
|
|
50301
|
+
console.log(chalk267.green("All sessions already summarised."));
|
|
50231
50302
|
return;
|
|
50232
50303
|
}
|
|
50233
50304
|
console.log(
|
|
50234
|
-
|
|
50305
|
+
chalk267.cyan(
|
|
50235
50306
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
50236
50307
|
)
|
|
50237
50308
|
);
|
|
50238
50309
|
const { succeeded, failed: failed3 } = processSessions(toProcess);
|
|
50239
50310
|
console.log(
|
|
50240
|
-
|
|
50311
|
+
chalk267.green(`Done: ${succeeded} summarised`) + (failed3 > 0 ? chalk267.yellow(`, ${failed3} skipped`) : "")
|
|
50241
50312
|
);
|
|
50242
50313
|
}
|
|
50243
50314
|
function selectCandidates(files, options2) {
|
|
@@ -50257,16 +50328,16 @@ function processSessions(files) {
|
|
|
50257
50328
|
let failed3 = 0;
|
|
50258
50329
|
for (let i = 0; i < files.length; i++) {
|
|
50259
50330
|
const file = files[i];
|
|
50260
|
-
process.stdout.write(
|
|
50331
|
+
process.stdout.write(chalk267.dim(` [${i + 1}/${files.length}] `));
|
|
50261
50332
|
const summary = summariseSession(file);
|
|
50262
50333
|
if (summary) {
|
|
50263
50334
|
writeSummary(file, summary);
|
|
50264
50335
|
succeeded++;
|
|
50265
|
-
process.stdout.write(`${
|
|
50336
|
+
process.stdout.write(`${chalk267.green("\u2713")} ${summary}
|
|
50266
50337
|
`);
|
|
50267
50338
|
} else {
|
|
50268
50339
|
failed3++;
|
|
50269
|
-
process.stdout.write(` ${
|
|
50340
|
+
process.stdout.write(` ${chalk267.yellow("skip")}
|
|
50270
50341
|
`);
|
|
50271
50342
|
}
|
|
50272
50343
|
}
|
|
@@ -50300,10 +50371,10 @@ function registerSessions(program2) {
|
|
|
50300
50371
|
}
|
|
50301
50372
|
|
|
50302
50373
|
// src/reportCliError.ts
|
|
50303
|
-
import
|
|
50374
|
+
import chalk268 from "chalk";
|
|
50304
50375
|
function reportCliError(error) {
|
|
50305
50376
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
50306
|
-
console.error(
|
|
50377
|
+
console.error(chalk268.red(error.message));
|
|
50307
50378
|
} else {
|
|
50308
50379
|
console.error(error);
|
|
50309
50380
|
}
|