@staff0rd/assist 0.583.0 → 0.585.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/dist/commands/sessions/web/bundle.js +432 -432
- package/dist/index.js +626 -380
- 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.585.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -483,6 +483,15 @@ var transcriptConfigSchema = z3.strictObject({
|
|
|
483
483
|
transcriptsDir: z3.string(),
|
|
484
484
|
summaryDir: z3.string()
|
|
485
485
|
});
|
|
486
|
+
var miroExtractSchema = z3.strictObject({
|
|
487
|
+
board: z3.string().optional(),
|
|
488
|
+
frame: z3.string().optional(),
|
|
489
|
+
topLeft: z3.string(),
|
|
490
|
+
bottomRight: z3.string(),
|
|
491
|
+
items: z3.string(),
|
|
492
|
+
ignore: z3.string().optional(),
|
|
493
|
+
out: z3.string().optional()
|
|
494
|
+
});
|
|
486
495
|
var DEFAULT_WAKE_WORDS = ["computer"];
|
|
487
496
|
var DEFAULT_MODELS_DIR = "~/.assist/voice/models";
|
|
488
497
|
var DEFAULT_BACKUP_DIR = "~/.assist/backups";
|
|
@@ -629,6 +638,9 @@ var assistConfigShape = {
|
|
|
629
638
|
mermaid: z3.strictObject({
|
|
630
639
|
krokiUrl: z3.string().default("https://kroki.io")
|
|
631
640
|
}).default({ krokiUrl: "https://kroki.io" }),
|
|
641
|
+
miro: z3.strictObject({
|
|
642
|
+
extracts: z3.record(z3.string(), miroExtractSchema).optional()
|
|
643
|
+
}).optional(),
|
|
632
644
|
deny: z3.array(
|
|
633
645
|
z3.strictObject({
|
|
634
646
|
pattern: z3.string(),
|
|
@@ -4489,6 +4501,15 @@ var mermaidConfigHelp = [
|
|
|
4489
4501
|
}
|
|
4490
4502
|
];
|
|
4491
4503
|
|
|
4504
|
+
// src/commands/miro/miroConfigHelp.ts
|
|
4505
|
+
var miroConfigHelp = [
|
|
4506
|
+
{
|
|
4507
|
+
key: "miro.extracts",
|
|
4508
|
+
setter: "assist miro extract --save <name>",
|
|
4509
|
+
note: "named box selections (board, frame, anchors, items, ignore, out) replayed by miro extract <name>"
|
|
4510
|
+
}
|
|
4511
|
+
];
|
|
4512
|
+
|
|
4492
4513
|
// src/commands/prs/prsConfigHelp.ts
|
|
4493
4514
|
var prsRaiseConfigHelp = [
|
|
4494
4515
|
{
|
|
@@ -4850,6 +4871,7 @@ var configHelpEntries = [
|
|
|
4850
4871
|
...harnessConfigHelp,
|
|
4851
4872
|
...jiraConfigHelp,
|
|
4852
4873
|
...mermaidConfigHelp,
|
|
4874
|
+
...miroConfigHelp,
|
|
4853
4875
|
...prsConfigHelp,
|
|
4854
4876
|
...ravendbConfigHelp,
|
|
4855
4877
|
...refactorConfigHelp,
|
|
@@ -5436,9 +5458,9 @@ var daemonPaths = {
|
|
|
5436
5458
|
|
|
5437
5459
|
// src/commands/sessions/daemon/connectToDaemon.ts
|
|
5438
5460
|
function connectToDaemon() {
|
|
5439
|
-
return new Promise((
|
|
5461
|
+
return new Promise((resolve25, reject) => {
|
|
5440
5462
|
const socket = net.connect(daemonPaths.socket);
|
|
5441
|
-
socket.once("connect", () =>
|
|
5463
|
+
socket.once("connect", () => resolve25(socket));
|
|
5442
5464
|
socket.once("error", reject);
|
|
5443
5465
|
});
|
|
5444
5466
|
}
|
|
@@ -5591,7 +5613,7 @@ ${failed2.length} script(s) failed:`);
|
|
|
5591
5613
|
}
|
|
5592
5614
|
}
|
|
5593
5615
|
function runEntry(entry) {
|
|
5594
|
-
return new Promise((
|
|
5616
|
+
return new Promise((resolve25) => {
|
|
5595
5617
|
const startTime = Date.now();
|
|
5596
5618
|
const child = spawnCommand(
|
|
5597
5619
|
entry.fullCommand,
|
|
@@ -5603,7 +5625,7 @@ function runEntry(entry) {
|
|
|
5603
5625
|
child.on("close", (code) => {
|
|
5604
5626
|
const exitCode = code ?? 1;
|
|
5605
5627
|
flushIfFailed(exitCode, chunks);
|
|
5606
|
-
|
|
5628
|
+
resolve25({
|
|
5607
5629
|
script: entry.name,
|
|
5608
5630
|
code: exitCode,
|
|
5609
5631
|
durationMs: Date.now() - startTime
|
|
@@ -6757,8 +6779,8 @@ function spawnInherit(command, args, options2 = {}) {
|
|
|
6757
6779
|
env,
|
|
6758
6780
|
cwd: options2.cwd
|
|
6759
6781
|
});
|
|
6760
|
-
const done2 = new Promise((
|
|
6761
|
-
child.on("close", (code) =>
|
|
6782
|
+
const done2 = new Promise((resolve25, reject) => {
|
|
6783
|
+
child.on("close", (code) => resolve25(code ?? 0));
|
|
6762
6784
|
child.on("error", reject);
|
|
6763
6785
|
});
|
|
6764
6786
|
return { child, done: done2 };
|
|
@@ -7905,7 +7927,7 @@ Failed to launch Claude for ${context}: ${message3}`)
|
|
|
7905
7927
|
// src/commands/sessions/daemon/sendToDaemon.ts
|
|
7906
7928
|
var WRITE_TIMEOUT_MS = 500;
|
|
7907
7929
|
function sendToDaemon(message3) {
|
|
7908
|
-
return new Promise((
|
|
7930
|
+
return new Promise((resolve25, reject) => {
|
|
7909
7931
|
connectToDaemon().then((socket) => {
|
|
7910
7932
|
const timer = setTimeout(() => {
|
|
7911
7933
|
socket.destroy();
|
|
@@ -7919,7 +7941,7 @@ function sendToDaemon(message3) {
|
|
|
7919
7941
|
`, () => {
|
|
7920
7942
|
clearTimeout(timer);
|
|
7921
7943
|
socket.end();
|
|
7922
|
-
|
|
7944
|
+
resolve25();
|
|
7923
7945
|
});
|
|
7924
7946
|
}, reject);
|
|
7925
7947
|
});
|
|
@@ -7942,7 +7964,7 @@ function readSocketLines(socket, onLine) {
|
|
|
7942
7964
|
// src/commands/sessions/daemon/sendToDaemonAwaitAck.ts
|
|
7943
7965
|
var ACK_TIMEOUT_MS = 1e3;
|
|
7944
7966
|
function sendToDaemonAwaitAck(message3) {
|
|
7945
|
-
return new Promise((
|
|
7967
|
+
return new Promise((resolve25, reject) => {
|
|
7946
7968
|
connectToDaemon().then((socket) => {
|
|
7947
7969
|
let settled = false;
|
|
7948
7970
|
const finish = (error) => {
|
|
@@ -7951,7 +7973,7 @@ function sendToDaemonAwaitAck(message3) {
|
|
|
7951
7973
|
clearTimeout(timer);
|
|
7952
7974
|
socket.destroy();
|
|
7953
7975
|
if (error) reject(error);
|
|
7954
|
-
else
|
|
7976
|
+
else resolve25();
|
|
7955
7977
|
};
|
|
7956
7978
|
const timer = setTimeout(
|
|
7957
7979
|
() => finish(new Error("timed out awaiting daemon ack")),
|
|
@@ -8025,7 +8047,7 @@ async function deliverReliably(sessionId, status3, payload) {
|
|
|
8025
8047
|
}
|
|
8026
8048
|
}
|
|
8027
8049
|
function sleep(ms) {
|
|
8028
|
-
return new Promise((
|
|
8050
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
8029
8051
|
}
|
|
8030
8052
|
function describeError(error) {
|
|
8031
8053
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -9899,7 +9921,7 @@ function spawnDaemon(reason4) {
|
|
|
9899
9921
|
child.unref();
|
|
9900
9922
|
}
|
|
9901
9923
|
function delay(ms) {
|
|
9902
|
-
return new Promise((
|
|
9924
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
9903
9925
|
}
|
|
9904
9926
|
|
|
9905
9927
|
// src/commands/sessions/daemon/isWindowsCwd.ts
|
|
@@ -9965,10 +9987,10 @@ function gitInvocation(cwd, args) {
|
|
|
9965
9987
|
}
|
|
9966
9988
|
function git2(cwd, args) {
|
|
9967
9989
|
const { file, argv, options: options2 } = gitInvocation(cwd, args);
|
|
9968
|
-
return new Promise((
|
|
9990
|
+
return new Promise((resolve25, reject) => {
|
|
9969
9991
|
execFile2(file, argv, options2, (error, stdout) => {
|
|
9970
9992
|
if (error) reject(error);
|
|
9971
|
-
else
|
|
9993
|
+
else resolve25(stdout.toString());
|
|
9972
9994
|
});
|
|
9973
9995
|
});
|
|
9974
9996
|
}
|
|
@@ -10389,12 +10411,12 @@ async function loadVisibleItems(req) {
|
|
|
10389
10411
|
|
|
10390
10412
|
// src/commands/backlog/web/parseStatusBody.ts
|
|
10391
10413
|
function readBody(req) {
|
|
10392
|
-
return new Promise((
|
|
10414
|
+
return new Promise((resolve25, reject) => {
|
|
10393
10415
|
let body = "";
|
|
10394
10416
|
req.on("data", (chunk) => {
|
|
10395
10417
|
body += chunk.toString();
|
|
10396
10418
|
});
|
|
10397
|
-
req.on("end", () =>
|
|
10419
|
+
req.on("end", () => resolve25(body));
|
|
10398
10420
|
req.on("error", reject);
|
|
10399
10421
|
});
|
|
10400
10422
|
}
|
|
@@ -12080,17 +12102,17 @@ async function stopDaemon() {
|
|
|
12080
12102
|
}
|
|
12081
12103
|
}
|
|
12082
12104
|
function closedBeforeTimeout(socket) {
|
|
12083
|
-
return new Promise((
|
|
12105
|
+
return new Promise((resolve25) => {
|
|
12084
12106
|
const timer = setTimeout(() => {
|
|
12085
12107
|
socket.destroy();
|
|
12086
|
-
|
|
12108
|
+
resolve25(false);
|
|
12087
12109
|
}, STOP_TIMEOUT_MS);
|
|
12088
12110
|
socket.resume();
|
|
12089
12111
|
socket.on("error", () => {
|
|
12090
12112
|
});
|
|
12091
12113
|
socket.once("close", () => {
|
|
12092
12114
|
clearTimeout(timer);
|
|
12093
|
-
|
|
12115
|
+
resolve25(true);
|
|
12094
12116
|
});
|
|
12095
12117
|
});
|
|
12096
12118
|
}
|
|
@@ -12141,8 +12163,8 @@ async function restartWeb(req, res, deps2 = {}) {
|
|
|
12141
12163
|
respondJson(res, 400, { error: "Invalid target" });
|
|
12142
12164
|
return;
|
|
12143
12165
|
}
|
|
12144
|
-
await new Promise((
|
|
12145
|
-
res.once("finish",
|
|
12166
|
+
await new Promise((resolve25) => {
|
|
12167
|
+
res.once("finish", resolve25);
|
|
12146
12168
|
respondJson(res, 200, { ok: true });
|
|
12147
12169
|
});
|
|
12148
12170
|
if (target === "daemon" || target === "both") {
|
|
@@ -14010,7 +14032,7 @@ function parsePreviewDecision(line, requestId) {
|
|
|
14010
14032
|
|
|
14011
14033
|
// src/commands/sessions/shared/requestPreviewDecision.ts
|
|
14012
14034
|
function requestPreviewDecision(request) {
|
|
14013
|
-
return new Promise((
|
|
14035
|
+
return new Promise((resolve25, reject) => {
|
|
14014
14036
|
connectToDaemon().then((socket) => {
|
|
14015
14037
|
let settled = false;
|
|
14016
14038
|
const finish = (error, decision) => {
|
|
@@ -14018,7 +14040,7 @@ function requestPreviewDecision(request) {
|
|
|
14018
14040
|
settled = true;
|
|
14019
14041
|
socket.destroy();
|
|
14020
14042
|
if (error) reject(error);
|
|
14021
|
-
else
|
|
14043
|
+
else resolve25(decision);
|
|
14022
14044
|
};
|
|
14023
14045
|
readSocketLines(socket, (line) => {
|
|
14024
14046
|
const incoming = parsePreviewDecision(line, request.requestId);
|
|
@@ -17423,12 +17445,12 @@ function hasSubcommands(helpText) {
|
|
|
17423
17445
|
// src/commands/permitCliReads/runHelp.ts
|
|
17424
17446
|
import { exec as exec2 } from "child_process";
|
|
17425
17447
|
function runHelp(args) {
|
|
17426
|
-
return new Promise((
|
|
17448
|
+
return new Promise((resolve25) => {
|
|
17427
17449
|
exec2(
|
|
17428
17450
|
`${args.join(" ")} --help`,
|
|
17429
17451
|
{ encoding: "utf8", timeout: 3e4 },
|
|
17430
17452
|
(_err, stdout, stderr) => {
|
|
17431
|
-
|
|
17453
|
+
resolve25(stdout || stderr || "");
|
|
17432
17454
|
}
|
|
17433
17455
|
);
|
|
17434
17456
|
});
|
|
@@ -22604,7 +22626,7 @@ function placedByDaemon() {
|
|
|
22604
22626
|
function seed(worktreePath, clone) {
|
|
22605
22627
|
console.log(`Preparing ${worktreePath}\u2026`);
|
|
22606
22628
|
return new Promise(
|
|
22607
|
-
(
|
|
22629
|
+
(resolve25) => seedWorktree(worktreePath, clone, resolve25)
|
|
22608
22630
|
);
|
|
22609
22631
|
}
|
|
22610
22632
|
async function moveToPrCheckoutTree() {
|
|
@@ -22917,10 +22939,6 @@ function registerMermaid(program2) {
|
|
|
22917
22939
|
configHelp(cmd, mermaidConfigHelp);
|
|
22918
22940
|
}
|
|
22919
22941
|
|
|
22920
|
-
// src/commands/miro/runExtract.ts
|
|
22921
|
-
import chalk171 from "chalk";
|
|
22922
|
-
import { stringify as stringify2 } from "yaml";
|
|
22923
|
-
|
|
22924
22942
|
// src/commands/miro/MiroExtractError.ts
|
|
22925
22943
|
var MiroExtractError = class extends Error {
|
|
22926
22944
|
constructor(message3) {
|
|
@@ -22952,16 +22970,6 @@ function anchorSource(options2) {
|
|
|
22952
22970
|
return { pick: true, sessionId };
|
|
22953
22971
|
}
|
|
22954
22972
|
|
|
22955
|
-
// src/commands/miro/applyIgnore.ts
|
|
22956
|
-
function applyIgnore(texts, ignore3) {
|
|
22957
|
-
const dropped = new Set(ignore3);
|
|
22958
|
-
const present = new Set(texts);
|
|
22959
|
-
return {
|
|
22960
|
-
texts: texts.filter((text18) => !dropped.has(text18)),
|
|
22961
|
-
unmatched: [...new Set(ignore3)].filter((entry) => !present.has(entry))
|
|
22962
|
-
};
|
|
22963
|
-
}
|
|
22964
|
-
|
|
22965
22973
|
// src/commands/miro/miroSource.ts
|
|
22966
22974
|
function boardId(url) {
|
|
22967
22975
|
return url ? /\/board\/([^/?]+)/.exec(url)?.[1] : void 0;
|
|
@@ -22975,6 +22983,137 @@ function miroSource(items2, anchorId) {
|
|
|
22975
22983
|
};
|
|
22976
22984
|
}
|
|
22977
22985
|
|
|
22986
|
+
// src/commands/miro/boardSource.ts
|
|
22987
|
+
function boardSource(raw, anchorId, options2) {
|
|
22988
|
+
const derived = miroSource(raw, anchorId);
|
|
22989
|
+
return {
|
|
22990
|
+
board: options2.board ?? derived.board,
|
|
22991
|
+
frame: options2.frame ?? derived.frame
|
|
22992
|
+
};
|
|
22993
|
+
}
|
|
22994
|
+
|
|
22995
|
+
// src/commands/miro/emitExtract.ts
|
|
22996
|
+
import { stringify as stringify2 } from "yaml";
|
|
22997
|
+
|
|
22998
|
+
// src/commands/miro/writeExtract.ts
|
|
22999
|
+
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync33 } from "fs";
|
|
23000
|
+
import { dirname as dirname27 } from "path";
|
|
23001
|
+
import { stringify } from "yaml";
|
|
23002
|
+
function headerLines(header) {
|
|
23003
|
+
const { rect } = header;
|
|
23004
|
+
return [
|
|
23005
|
+
`# board: ${header.board ?? "unknown"}`,
|
|
23006
|
+
`# frame: ${header.frame ?? "unknown"}`,
|
|
23007
|
+
`# top-left: ${header.topLeft}`,
|
|
23008
|
+
`# bottom-right: ${header.bottomRight}`,
|
|
23009
|
+
`# rectangle: ${rect.left},${rect.top} to ${rect.right},${rect.bottom}`
|
|
23010
|
+
];
|
|
23011
|
+
}
|
|
23012
|
+
function writeExtract(file, header, texts) {
|
|
23013
|
+
mkdirSync19(dirname27(file), { recursive: true });
|
|
23014
|
+
writeFileSync33(file, `${headerLines(header).join("\n")}
|
|
23015
|
+
${stringify(texts)}`);
|
|
23016
|
+
}
|
|
23017
|
+
|
|
23018
|
+
// src/commands/miro/emitExtract.ts
|
|
23019
|
+
function emitExtract(out, header, texts) {
|
|
23020
|
+
if (!out) {
|
|
23021
|
+
process.stdout.write(stringify2(texts));
|
|
23022
|
+
return;
|
|
23023
|
+
}
|
|
23024
|
+
writeExtract(out, header, texts);
|
|
23025
|
+
console.log(
|
|
23026
|
+
`Wrote ${texts.length} ${texts.length === 1 ? "box" : "boxes"} to ${out}`
|
|
23027
|
+
);
|
|
23028
|
+
}
|
|
23029
|
+
|
|
23030
|
+
// src/commands/miro/resolveExtractPath.ts
|
|
23031
|
+
import { isAbsolute as isAbsolute3, relative as relative5, resolve as resolve17 } from "path";
|
|
23032
|
+
function extractRoot(cwd) {
|
|
23033
|
+
return findConfigUp(cwd)?.rootDir ?? cwd;
|
|
23034
|
+
}
|
|
23035
|
+
function resolveExtractPath(value, cwd) {
|
|
23036
|
+
if (value === void 0) return void 0;
|
|
23037
|
+
return isAbsolute3(value) ? value : resolve17(extractRoot(cwd), value);
|
|
23038
|
+
}
|
|
23039
|
+
function storedExtractPath(value, cwd) {
|
|
23040
|
+
if (value === void 0) return void 0;
|
|
23041
|
+
const absolute2 = resolve17(cwd, value);
|
|
23042
|
+
const within = relative5(extractRoot(cwd), absolute2);
|
|
23043
|
+
return within.startsWith("..") ? absolute2 : within;
|
|
23044
|
+
}
|
|
23045
|
+
|
|
23046
|
+
// src/commands/miro/extractToSave.ts
|
|
23047
|
+
function defined2(value) {
|
|
23048
|
+
return Object.fromEntries(
|
|
23049
|
+
Object.entries(value).filter(([, field]) => field !== void 0)
|
|
23050
|
+
);
|
|
23051
|
+
}
|
|
23052
|
+
function extractToSave(details, cwd = process.cwd()) {
|
|
23053
|
+
return defined2({
|
|
23054
|
+
board: details.board,
|
|
23055
|
+
frame: details.frame,
|
|
23056
|
+
topLeft: details.topLeft,
|
|
23057
|
+
bottomRight: details.bottomRight,
|
|
23058
|
+
items: storedExtractPath(details.items, cwd),
|
|
23059
|
+
ignore: storedExtractPath(details.options.ignore, cwd),
|
|
23060
|
+
out: storedExtractPath(details.options.out, cwd)
|
|
23061
|
+
});
|
|
23062
|
+
}
|
|
23063
|
+
|
|
23064
|
+
// src/commands/miro/keptTexts.ts
|
|
23065
|
+
import chalk171 from "chalk";
|
|
23066
|
+
|
|
23067
|
+
// src/commands/miro/applyIgnore.ts
|
|
23068
|
+
function applyIgnore(texts, ignore3) {
|
|
23069
|
+
const dropped = new Set(ignore3);
|
|
23070
|
+
const present = new Set(texts);
|
|
23071
|
+
return {
|
|
23072
|
+
texts: texts.filter((text18) => !dropped.has(text18)),
|
|
23073
|
+
unmatched: [...new Set(ignore3)].filter((entry) => !present.has(entry))
|
|
23074
|
+
};
|
|
23075
|
+
}
|
|
23076
|
+
|
|
23077
|
+
// src/commands/miro/readIgnoreList.ts
|
|
23078
|
+
import { existsSync as existsSync54, readFileSync as readFileSync40 } from "fs";
|
|
23079
|
+
import { parse as parse2 } from "yaml";
|
|
23080
|
+
function readIgnoreList(file) {
|
|
23081
|
+
if (!existsSync54(file))
|
|
23082
|
+
throw new MiroExtractError(
|
|
23083
|
+
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
23084
|
+
);
|
|
23085
|
+
const parsed = parse2(readFileSync40(file, "utf8"));
|
|
23086
|
+
if (parsed === null || parsed === void 0) return [];
|
|
23087
|
+
if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string"))
|
|
23088
|
+
throw new MiroExtractError(
|
|
23089
|
+
`${file} must be a YAML list of box texts to drop, one string per entry.`
|
|
23090
|
+
);
|
|
23091
|
+
return parsed.map((entry) => entry.trim()).filter(Boolean);
|
|
23092
|
+
}
|
|
23093
|
+
|
|
23094
|
+
// src/commands/miro/uniqueTexts.ts
|
|
23095
|
+
function uniqueTexts(boxes) {
|
|
23096
|
+
return [...new Set(boxes.map((box) => box.text))];
|
|
23097
|
+
}
|
|
23098
|
+
|
|
23099
|
+
// src/commands/miro/keptTexts.ts
|
|
23100
|
+
function warnUnmatched(file, unmatched) {
|
|
23101
|
+
if (unmatched.length === 0) return;
|
|
23102
|
+
const entries = unmatched.map((entry) => ` - ${entry}`).join("\n");
|
|
23103
|
+
console.error(
|
|
23104
|
+
chalk171.yellow(
|
|
23105
|
+
`${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
|
|
23106
|
+
${entries}`
|
|
23107
|
+
)
|
|
23108
|
+
);
|
|
23109
|
+
}
|
|
23110
|
+
function keptTexts(options2, boxes) {
|
|
23111
|
+
const ignore3 = options2.ignore ? readIgnoreList(options2.ignore) : [];
|
|
23112
|
+
const kept = applyIgnore(uniqueTexts(boxes), ignore3);
|
|
23113
|
+
if (options2.ignore) warnUnmatched(options2.ignore, kept.unmatched);
|
|
23114
|
+
return kept.texts;
|
|
23115
|
+
}
|
|
23116
|
+
|
|
22978
23117
|
// src/commands/miro/stripHtml.ts
|
|
22979
23118
|
var namedEntities = {
|
|
22980
23119
|
amp: "&",
|
|
@@ -23033,6 +23172,58 @@ function normaliseItems(items2) {
|
|
|
23033
23172
|
return items2.map(toItem);
|
|
23034
23173
|
}
|
|
23035
23174
|
|
|
23175
|
+
// src/commands/miro/saveMiroExtract.ts
|
|
23176
|
+
function saveToRepo(key, extract2, repo, { cwd, globalConfigPath }) {
|
|
23177
|
+
const result = applyRepoConfigSet(
|
|
23178
|
+
key,
|
|
23179
|
+
extract2,
|
|
23180
|
+
typeof repo === "string" ? repo : void 0,
|
|
23181
|
+
cwd,
|
|
23182
|
+
globalConfigPath
|
|
23183
|
+
);
|
|
23184
|
+
if (!result.ok) throw new MiroExtractError(result.errors.join("\n"));
|
|
23185
|
+
return `${globalConfigFileLabel(globalConfigPath)} under repos.${result.label}`;
|
|
23186
|
+
}
|
|
23187
|
+
function saveMiroExtract(name, extract2, options2, paths = {}) {
|
|
23188
|
+
const resolved = {
|
|
23189
|
+
cwd: paths.cwd ?? process.cwd(),
|
|
23190
|
+
globalConfigPath: paths.globalConfigPath ?? getGlobalConfigPath()
|
|
23191
|
+
};
|
|
23192
|
+
if (options2.repo !== void 0 && !options2.global)
|
|
23193
|
+
throw new MiroExtractError(
|
|
23194
|
+
"--repo writes to the global config; add -g (e.g. -g --repo)"
|
|
23195
|
+
);
|
|
23196
|
+
const key = `miro.extracts.${name}`;
|
|
23197
|
+
if (options2.repo !== void 0)
|
|
23198
|
+
return saveToRepo(key, extract2, options2.repo, resolved);
|
|
23199
|
+
const result = applyConfigSet(
|
|
23200
|
+
key,
|
|
23201
|
+
extract2,
|
|
23202
|
+
options2.global ?? false,
|
|
23203
|
+
resolved.cwd,
|
|
23204
|
+
resolved.globalConfigPath
|
|
23205
|
+
);
|
|
23206
|
+
if (!result.ok) throw new MiroExtractError(result.errors.join("\n"));
|
|
23207
|
+
return result.target === "global" ? globalConfigFileLabel(resolved.globalConfigPath) : projectConfigPathFrom(resolved.cwd);
|
|
23208
|
+
}
|
|
23209
|
+
|
|
23210
|
+
// src/commands/miro/offerSaveExtract.ts
|
|
23211
|
+
async function extractName(options2) {
|
|
23212
|
+
if (options2.save) return options2.save;
|
|
23213
|
+
if (!process.stdin.isTTY) return void 0;
|
|
23214
|
+
if (!await promptConfirm("Save this selection as a named extract?", false))
|
|
23215
|
+
return void 0;
|
|
23216
|
+
const name = (await promptInput("name", "Extract name")).trim();
|
|
23217
|
+
return name === "" ? void 0 : name;
|
|
23218
|
+
}
|
|
23219
|
+
async function offerSaveExtract(extract2, options2, paths = {}) {
|
|
23220
|
+
const name = await extractName(options2);
|
|
23221
|
+
if (!name) return;
|
|
23222
|
+
console.log(
|
|
23223
|
+
`Saved extract "${name}" to ${saveMiroExtract(name, extract2, options2, paths)}`
|
|
23224
|
+
);
|
|
23225
|
+
}
|
|
23226
|
+
|
|
23036
23227
|
// src/commands/miro/pickAnchors.ts
|
|
23037
23228
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
23038
23229
|
|
|
@@ -23072,23 +23263,6 @@ async function pickAnchors(sessionId, items2) {
|
|
|
23072
23263
|
return [selection.topLeft, selection.bottomRight];
|
|
23073
23264
|
}
|
|
23074
23265
|
|
|
23075
|
-
// src/commands/miro/readIgnoreList.ts
|
|
23076
|
-
import { existsSync as existsSync54, readFileSync as readFileSync40 } from "fs";
|
|
23077
|
-
import { parse as parse2 } from "yaml";
|
|
23078
|
-
function readIgnoreList(file) {
|
|
23079
|
-
if (!existsSync54(file))
|
|
23080
|
-
throw new MiroExtractError(
|
|
23081
|
-
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
23082
|
-
);
|
|
23083
|
-
const parsed = parse2(readFileSync40(file, "utf8"));
|
|
23084
|
-
if (parsed === null || parsed === void 0) return [];
|
|
23085
|
-
if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string"))
|
|
23086
|
-
throw new MiroExtractError(
|
|
23087
|
-
`${file} must be a YAML list of box texts to drop, one string per entry.`
|
|
23088
|
-
);
|
|
23089
|
-
return parsed.map((entry) => entry.trim()).filter(Boolean);
|
|
23090
|
-
}
|
|
23091
|
-
|
|
23092
23266
|
// src/commands/miro/readMiroItems.ts
|
|
23093
23267
|
import { readFileSync as readFileSync41 } from "fs";
|
|
23094
23268
|
function tryParse(text18) {
|
|
@@ -23129,6 +23303,89 @@ function readMiroItems(file) {
|
|
|
23129
23303
|
return items2;
|
|
23130
23304
|
}
|
|
23131
23305
|
|
|
23306
|
+
// src/commands/miro/resolveExtractOptions.ts
|
|
23307
|
+
import chalk172 from "chalk";
|
|
23308
|
+
|
|
23309
|
+
// src/commands/miro/extractLayers.ts
|
|
23310
|
+
function extractsIn(layer) {
|
|
23311
|
+
const value = getNestedValue(layer, "miro.extracts");
|
|
23312
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23313
|
+
}
|
|
23314
|
+
function extractLayers(layers, cwd, globalConfigPath) {
|
|
23315
|
+
const globalFile = globalConfigFileLabel(globalConfigPath);
|
|
23316
|
+
return [
|
|
23317
|
+
{ file: projectConfigPathFrom(cwd), extracts: extractsIn(layers.project) },
|
|
23318
|
+
{
|
|
23319
|
+
file: `${globalFile} under repos.${layers.repoKey}`,
|
|
23320
|
+
extracts: extractsIn(layers.repoOverride)
|
|
23321
|
+
},
|
|
23322
|
+
{ file: globalFile, extracts: extractsIn(layers.global) }
|
|
23323
|
+
];
|
|
23324
|
+
}
|
|
23325
|
+
function unknownExtract(name, layers) {
|
|
23326
|
+
const names = [
|
|
23327
|
+
...new Set(layers.flatMap((layer) => Object.keys(layer.extracts)))
|
|
23328
|
+
].sort();
|
|
23329
|
+
if (names.length === 0)
|
|
23330
|
+
return `No extract named "${name}" is configured. Pick a rectangle with no anchor flags, then save it as "${name}".`;
|
|
23331
|
+
return `No extract named "${name}" is configured. Configured extracts: ${names.join(", ")}.`;
|
|
23332
|
+
}
|
|
23333
|
+
|
|
23334
|
+
// src/commands/miro/mergeExtractOptions.ts
|
|
23335
|
+
function mergeExtractOptions(options2, extract2, cwd) {
|
|
23336
|
+
return {
|
|
23337
|
+
...options2,
|
|
23338
|
+
board: options2.board ?? extract2.board,
|
|
23339
|
+
frame: options2.frame ?? extract2.frame,
|
|
23340
|
+
topLeft: options2.topLeft ?? extract2.topLeft,
|
|
23341
|
+
bottomRight: options2.bottomRight ?? extract2.bottomRight,
|
|
23342
|
+
items: options2.items ?? resolveExtractPath(extract2.items, cwd),
|
|
23343
|
+
ignore: options2.ignore ?? resolveExtractPath(extract2.ignore, cwd),
|
|
23344
|
+
out: options2.out ?? resolveExtractPath(extract2.out, cwd)
|
|
23345
|
+
};
|
|
23346
|
+
}
|
|
23347
|
+
|
|
23348
|
+
// src/commands/miro/parseExtract.ts
|
|
23349
|
+
function parseExtract(name, value) {
|
|
23350
|
+
const parsed = miroExtractSchema.safeParse(value);
|
|
23351
|
+
if (parsed.success) return parsed.data;
|
|
23352
|
+
const issues = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
|
|
23353
|
+
throw new MiroExtractError(`Extract "${name}" is not valid: ${issues}`);
|
|
23354
|
+
}
|
|
23355
|
+
|
|
23356
|
+
// src/commands/miro/resolveMiroExtract.ts
|
|
23357
|
+
function resolveMiroExtract(name, options2, cwd = process.cwd(), globalConfigPath = getGlobalConfigPath()) {
|
|
23358
|
+
const byPrecedence = extractLayers(
|
|
23359
|
+
readRawConfigLayers(cwd, globalConfigPath),
|
|
23360
|
+
cwd,
|
|
23361
|
+
globalConfigPath
|
|
23362
|
+
);
|
|
23363
|
+
const found = byPrecedence.filter((layer) => name in layer.extracts);
|
|
23364
|
+
if (found.length === 0)
|
|
23365
|
+
throw new MiroExtractError(unknownExtract(name, byPrecedence));
|
|
23366
|
+
const merged = Object.assign(
|
|
23367
|
+
{},
|
|
23368
|
+
...[...found].reverse().map((layer) => layer.extracts[name])
|
|
23369
|
+
);
|
|
23370
|
+
return {
|
|
23371
|
+
options: mergeExtractOptions(options2, parseExtract(name, merged), cwd),
|
|
23372
|
+
from: found.map((layer) => layer.file).join(" merged with ")
|
|
23373
|
+
};
|
|
23374
|
+
}
|
|
23375
|
+
|
|
23376
|
+
// src/commands/miro/resolveExtractOptions.ts
|
|
23377
|
+
function resolveExtractOptions(name, options2, paths) {
|
|
23378
|
+
if (!name) return options2;
|
|
23379
|
+
const resolved = resolveMiroExtract(
|
|
23380
|
+
name,
|
|
23381
|
+
options2,
|
|
23382
|
+
paths.cwd,
|
|
23383
|
+
paths.globalConfigPath
|
|
23384
|
+
);
|
|
23385
|
+
console.error(chalk172.dim(`Extract "${name}" from ${resolved.from}`));
|
|
23386
|
+
return resolved.options;
|
|
23387
|
+
}
|
|
23388
|
+
|
|
23132
23389
|
// src/commands/miro/selectBoxes.ts
|
|
23133
23390
|
function findAnchor(items2, id) {
|
|
23134
23391
|
const anchor = items2.find((item) => item.id === id);
|
|
@@ -23156,31 +23413,6 @@ function selectBoxes(items2, topLeftId, bottomRightId) {
|
|
|
23156
23413
|
return { rect, boxes };
|
|
23157
23414
|
}
|
|
23158
23415
|
|
|
23159
|
-
// src/commands/miro/uniqueTexts.ts
|
|
23160
|
-
function uniqueTexts(boxes) {
|
|
23161
|
-
return [...new Set(boxes.map((box) => box.text))];
|
|
23162
|
-
}
|
|
23163
|
-
|
|
23164
|
-
// src/commands/miro/writeExtract.ts
|
|
23165
|
-
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync33 } from "fs";
|
|
23166
|
-
import { dirname as dirname27 } from "path";
|
|
23167
|
-
import { stringify } from "yaml";
|
|
23168
|
-
function headerLines(header) {
|
|
23169
|
-
const { rect } = header;
|
|
23170
|
-
return [
|
|
23171
|
-
`# board: ${header.board ?? "unknown"}`,
|
|
23172
|
-
`# frame: ${header.frame ?? "unknown"}`,
|
|
23173
|
-
`# top-left: ${header.topLeft}`,
|
|
23174
|
-
`# bottom-right: ${header.bottomRight}`,
|
|
23175
|
-
`# rectangle: ${rect.left},${rect.top} to ${rect.right},${rect.bottom}`
|
|
23176
|
-
];
|
|
23177
|
-
}
|
|
23178
|
-
function writeExtract(file, header, texts) {
|
|
23179
|
-
mkdirSync19(dirname27(file), { recursive: true });
|
|
23180
|
-
writeFileSync33(file, `${headerLines(header).join("\n")}
|
|
23181
|
-
${stringify(texts)}`);
|
|
23182
|
-
}
|
|
23183
|
-
|
|
23184
23416
|
// src/commands/miro/runExtract.ts
|
|
23185
23417
|
function requireItems(file) {
|
|
23186
23418
|
if (!file)
|
|
@@ -23189,56 +23421,70 @@ function requireItems(file) {
|
|
|
23189
23421
|
);
|
|
23190
23422
|
return file;
|
|
23191
23423
|
}
|
|
23192
|
-
function
|
|
23193
|
-
|
|
23194
|
-
const
|
|
23195
|
-
|
|
23196
|
-
|
|
23197
|
-
`${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
|
|
23198
|
-
${entries}`
|
|
23199
|
-
)
|
|
23200
|
-
);
|
|
23201
|
-
}
|
|
23202
|
-
async function runExtract(options2) {
|
|
23203
|
-
const source = anchorSource(options2);
|
|
23204
|
-
const raw = readMiroItems(requireItems(options2.items));
|
|
23424
|
+
async function runExtract(name, options2, paths = {}) {
|
|
23425
|
+
const resolved = resolveExtractOptions(name, options2, paths);
|
|
23426
|
+
const source = anchorSource(resolved);
|
|
23427
|
+
const itemsFile = requireItems(resolved.items);
|
|
23428
|
+
const raw = readMiroItems(itemsFile);
|
|
23205
23429
|
const items2 = normaliseItems(raw);
|
|
23206
23430
|
const [topLeft, bottomRight] = source.pick ? await pickAnchors(source.sessionId, items2) : [source.topLeft, source.bottomRight];
|
|
23207
23431
|
const selection = selectBoxes(items2, topLeft, bottomRight);
|
|
23208
|
-
const
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23432
|
+
const board = boardSource(raw, topLeft, resolved);
|
|
23433
|
+
emitExtract(
|
|
23434
|
+
resolved.out,
|
|
23435
|
+
{ ...board, topLeft, bottomRight, rect: selection.rect },
|
|
23436
|
+
keptTexts(resolved, selection.boxes)
|
|
23437
|
+
);
|
|
23438
|
+
if (source.pick || resolved.save)
|
|
23439
|
+
await offerSaveExtract(
|
|
23440
|
+
extractToSave(
|
|
23441
|
+
{ options: resolved, items: itemsFile, topLeft, bottomRight, ...board },
|
|
23442
|
+
paths.cwd
|
|
23443
|
+
),
|
|
23444
|
+
resolved,
|
|
23445
|
+
paths
|
|
23446
|
+
);
|
|
23223
23447
|
}
|
|
23224
23448
|
|
|
23225
23449
|
// src/commands/miro/registerMiro.ts
|
|
23226
23450
|
function registerMiro(program2) {
|
|
23227
23451
|
const miroCommand = program2.command("miro").description("Miro board utilities");
|
|
23228
|
-
miroCommand.command("extract").description("Print the text of every box inside a rectangle on a board").
|
|
23452
|
+
const extract2 = miroCommand.command("extract").description("Print the text of every box inside a rectangle on a board").argument(
|
|
23453
|
+
"[name]",
|
|
23454
|
+
"Named extract from config supplying every field; any flag overrides its field"
|
|
23455
|
+
).option("--items <file>", "File of raw board_list_items response pages").option(
|
|
23229
23456
|
"--top-left <id>",
|
|
23230
23457
|
"Widget id or ?moveToWidget=<id> link of the top-left box (omit both anchors to pick them in the assist web UI)"
|
|
23231
23458
|
).option(
|
|
23232
23459
|
"--bottom-right <id>",
|
|
23233
23460
|
"Widget id or ?moveToWidget=<id> link of the bottom-right box"
|
|
23234
|
-
).option("--ignore <file>", "YAML list of box texts to drop from the output").option("--out <file>", "Write the YAML to this file instead of stdout").
|
|
23461
|
+
).option("--ignore <file>", "YAML list of box texts to drop from the output").option("--out <file>", "Write the YAML to this file instead of stdout").option(
|
|
23462
|
+
"--board <id>",
|
|
23463
|
+
"Board id for the --out header (else read from the items)"
|
|
23464
|
+
).option(
|
|
23465
|
+
"--frame <id>",
|
|
23466
|
+
"Frame id for the --out header (else read from the items)"
|
|
23467
|
+
).option(
|
|
23468
|
+
"--save <name>",
|
|
23469
|
+
"Save the selection as this named extract without asking"
|
|
23470
|
+
).option("-g, --global", "Save the extract to global ~/.assist.yml").option(
|
|
23471
|
+
"-r, --repo [name]",
|
|
23472
|
+
"Requires -g: scope the saved extract to a repo's identity (defaults to the current repo)"
|
|
23473
|
+
).action(
|
|
23474
|
+
(name, options2) => runExtract(name, options2)
|
|
23475
|
+
);
|
|
23476
|
+
configHelp(
|
|
23477
|
+
extract2,
|
|
23478
|
+
miroConfigHelp,
|
|
23479
|
+
"Paths in a saved extract are resolved from the repo root."
|
|
23480
|
+
);
|
|
23235
23481
|
}
|
|
23236
23482
|
|
|
23237
23483
|
// src/commands/netcap/netcap.ts
|
|
23238
23484
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
23239
23485
|
import { createServer as createServer2 } from "http";
|
|
23240
23486
|
import { dirname as dirname29 } from "path";
|
|
23241
|
-
import
|
|
23487
|
+
import chalk174 from "chalk";
|
|
23242
23488
|
|
|
23243
23489
|
// src/commands/netcap/corsHeaders.ts
|
|
23244
23490
|
var corsHeaders = {
|
|
@@ -23317,7 +23563,7 @@ function createNetcapHandler(options2) {
|
|
|
23317
23563
|
import { cp, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
23318
23564
|
import { networkInterfaces } from "os";
|
|
23319
23565
|
import { join as join58 } from "path";
|
|
23320
|
-
import
|
|
23566
|
+
import chalk173 from "chalk";
|
|
23321
23567
|
|
|
23322
23568
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
23323
23569
|
import { dirname as dirname28, join as join57 } from "path";
|
|
@@ -23361,7 +23607,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
23361
23607
|
const host = lanIPv4();
|
|
23362
23608
|
if (!host) {
|
|
23363
23609
|
console.log(
|
|
23364
|
-
|
|
23610
|
+
chalk173.yellow("could not determine the WSL IP for the extension")
|
|
23365
23611
|
);
|
|
23366
23612
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
23367
23613
|
return source;
|
|
@@ -23372,14 +23618,14 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
23372
23618
|
return WSL_WINDOWS_PATH;
|
|
23373
23619
|
} catch {
|
|
23374
23620
|
console.log(
|
|
23375
|
-
|
|
23621
|
+
chalk173.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
23376
23622
|
);
|
|
23377
23623
|
return source;
|
|
23378
23624
|
}
|
|
23379
23625
|
}
|
|
23380
23626
|
|
|
23381
23627
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
23382
|
-
import { isAbsolute as
|
|
23628
|
+
import { isAbsolute as isAbsolute4, join as join60, resolve as resolve18 } from "path";
|
|
23383
23629
|
|
|
23384
23630
|
// src/commands/netcap/defaultCapturePath.ts
|
|
23385
23631
|
import { homedir as homedir20 } from "os";
|
|
@@ -23391,7 +23637,7 @@ function defaultCapturePath() {
|
|
|
23391
23637
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
23392
23638
|
function resolveNetcapOutPath(out) {
|
|
23393
23639
|
if (!out) return defaultCapturePath();
|
|
23394
|
-
const dir =
|
|
23640
|
+
const dir = isAbsolute4(out) ? out : resolve18(process.cwd(), out);
|
|
23395
23641
|
return join60(dir, "capture.jsonl");
|
|
23396
23642
|
}
|
|
23397
23643
|
|
|
@@ -23405,30 +23651,30 @@ async function netcap(options2) {
|
|
|
23405
23651
|
let count8 = 0;
|
|
23406
23652
|
const handler = createNetcapHandler({
|
|
23407
23653
|
outPath,
|
|
23408
|
-
onPing: () => console.log(
|
|
23654
|
+
onPing: () => console.log(chalk174.dim("ping from extension")),
|
|
23409
23655
|
onCapture: (entry) => {
|
|
23410
23656
|
count8 += 1;
|
|
23411
23657
|
console.log(
|
|
23412
|
-
|
|
23413
|
-
|
|
23658
|
+
chalk174.green(`captured #${count8}`),
|
|
23659
|
+
chalk174.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
23414
23660
|
);
|
|
23415
23661
|
}
|
|
23416
23662
|
});
|
|
23417
23663
|
const server = createServer2(handler);
|
|
23418
23664
|
server.listen(port, () => {
|
|
23419
23665
|
console.log(
|
|
23420
|
-
|
|
23666
|
+
chalk174.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
23421
23667
|
);
|
|
23422
|
-
console.log(
|
|
23668
|
+
console.log(chalk174.dim(`appending captures to ${outPath}`));
|
|
23423
23669
|
if (filter)
|
|
23424
|
-
console.log(
|
|
23425
|
-
console.log(
|
|
23426
|
-
console.log(
|
|
23670
|
+
console.log(chalk174.dim(`forwarding only URLs matching "${filter}"`));
|
|
23671
|
+
console.log(chalk174.dim(`load the unpacked extension from ${extensionPath}`));
|
|
23672
|
+
console.log(chalk174.dim("press Ctrl-C to stop"));
|
|
23427
23673
|
});
|
|
23428
23674
|
process.on("SIGINT", () => {
|
|
23429
23675
|
server.close();
|
|
23430
23676
|
console.log(
|
|
23431
|
-
|
|
23677
|
+
chalk174.bold(
|
|
23432
23678
|
`
|
|
23433
23679
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
23434
23680
|
)
|
|
@@ -23440,7 +23686,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
23440
23686
|
// src/commands/netcap/netcapExtract.ts
|
|
23441
23687
|
import { writeFileSync as writeFileSync34 } from "fs";
|
|
23442
23688
|
import { join as join61 } from "path";
|
|
23443
|
-
import
|
|
23689
|
+
import chalk175 from "chalk";
|
|
23444
23690
|
|
|
23445
23691
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
23446
23692
|
import { readFileSync as readFileSync42 } from "fs";
|
|
@@ -23482,25 +23728,25 @@ function isVisibleText(t) {
|
|
|
23482
23728
|
return /[a-zA-Z]{3,}/.test(t);
|
|
23483
23729
|
}
|
|
23484
23730
|
var isHashtag = (t) => /^#[A-Za-z0-9_]+$/.test(t);
|
|
23485
|
-
function collectRscText(v,
|
|
23731
|
+
function collectRscText(v, resolve25, sink2, seen) {
|
|
23486
23732
|
if (v == null) return;
|
|
23487
23733
|
if (typeof v === "string") {
|
|
23488
23734
|
if (isRscRef(v)) {
|
|
23489
23735
|
if (!seen.has(v)) {
|
|
23490
23736
|
seen.add(v);
|
|
23491
|
-
collectRscText(
|
|
23737
|
+
collectRscText(resolve25(v), resolve25, sink2, seen);
|
|
23492
23738
|
}
|
|
23493
23739
|
} else if (isHashtag(v)) sink2.hashtags.push(v);
|
|
23494
23740
|
else if (isVisibleText(v)) sink2.text.push(v);
|
|
23495
23741
|
return;
|
|
23496
23742
|
}
|
|
23497
23743
|
if (Array.isArray(v)) {
|
|
23498
|
-
for (const x of v) collectRscText(x,
|
|
23744
|
+
for (const x of v) collectRscText(x, resolve25, sink2, seen);
|
|
23499
23745
|
return;
|
|
23500
23746
|
}
|
|
23501
23747
|
if (typeof v === "object") {
|
|
23502
23748
|
for (const val of Object.values(v)) {
|
|
23503
|
-
collectRscText(val,
|
|
23749
|
+
collectRscText(val, resolve25, sink2, seen);
|
|
23504
23750
|
}
|
|
23505
23751
|
}
|
|
23506
23752
|
}
|
|
@@ -23532,7 +23778,7 @@ function visitObjects(root, fn) {
|
|
|
23532
23778
|
}
|
|
23533
23779
|
}
|
|
23534
23780
|
}
|
|
23535
|
-
function buildMentionMap(rows,
|
|
23781
|
+
function buildMentionMap(rows, resolve25) {
|
|
23536
23782
|
const map = /* @__PURE__ */ new Map();
|
|
23537
23783
|
visitObjects(rows, (o) => {
|
|
23538
23784
|
const url = profileActionUrl(o);
|
|
@@ -23540,7 +23786,7 @@ function buildMentionMap(rows, resolve24) {
|
|
|
23540
23786
|
const slug = slugFromProfileUrl(url);
|
|
23541
23787
|
if (!slug || map.has(slug)) return;
|
|
23542
23788
|
const sink2 = { text: [], hashtags: [] };
|
|
23543
|
-
collectRscText(o.children,
|
|
23789
|
+
collectRscText(o.children, resolve25, sink2, /* @__PURE__ */ new Set());
|
|
23544
23790
|
const name = sink2.text.join(" ").replace(/\s+/g, " ").trim();
|
|
23545
23791
|
map.set(slug, name ? { slug, name, url } : { slug, url });
|
|
23546
23792
|
});
|
|
@@ -23626,10 +23872,10 @@ function buildPost(raw, mentionMap, author) {
|
|
|
23626
23872
|
|
|
23627
23873
|
// src/commands/netcap/walkPostRow.ts
|
|
23628
23874
|
var isCommentary = (o) => asObject(o.viewTrackingSpecs)?.viewName === "feed-commentary";
|
|
23629
|
-
function walkPostRow(v,
|
|
23875
|
+
function walkPostRow(v, resolve25, raw) {
|
|
23630
23876
|
if (v == null || typeof v !== "object") return;
|
|
23631
23877
|
if (Array.isArray(v)) {
|
|
23632
|
-
for (const x of v) walkPostRow(x,
|
|
23878
|
+
for (const x of v) walkPostRow(x, resolve25, raw);
|
|
23633
23879
|
return;
|
|
23634
23880
|
}
|
|
23635
23881
|
const o = v;
|
|
@@ -23643,9 +23889,9 @@ function walkPostRow(v, resolve24, raw) {
|
|
|
23643
23889
|
}
|
|
23644
23890
|
if (isCommentary(o)) {
|
|
23645
23891
|
const sink2 = { text: raw.text, hashtags: raw.hashtags };
|
|
23646
|
-
collectRscText(o.children,
|
|
23892
|
+
collectRscText(o.children, resolve25, sink2, /* @__PURE__ */ new Set());
|
|
23647
23893
|
}
|
|
23648
|
-
for (const val of Object.values(o)) walkPostRow(val,
|
|
23894
|
+
for (const val of Object.values(o)) walkPostRow(val, resolve25, raw);
|
|
23649
23895
|
}
|
|
23650
23896
|
|
|
23651
23897
|
// src/commands/netcap/extractLinkedInPosts.ts
|
|
@@ -23659,8 +23905,8 @@ function findCommentaryRows(rows) {
|
|
|
23659
23905
|
}
|
|
23660
23906
|
function extractLinkedInPosts(flight, author = findAuthorSlug(flight)) {
|
|
23661
23907
|
const rows = parseRscRows(flight);
|
|
23662
|
-
const
|
|
23663
|
-
const mentionMap = buildMentionMap(rows,
|
|
23908
|
+
const resolve25 = makeRscResolver(rows);
|
|
23909
|
+
const mentionMap = buildMentionMap(rows, resolve25);
|
|
23664
23910
|
const posts = [];
|
|
23665
23911
|
for (const id of findCommentaryRows(rows)) {
|
|
23666
23912
|
const raw = {
|
|
@@ -23670,7 +23916,7 @@ function extractLinkedInPosts(flight, author = findAuthorSlug(flight)) {
|
|
|
23670
23916
|
links: [],
|
|
23671
23917
|
related: []
|
|
23672
23918
|
};
|
|
23673
|
-
walkPostRow(rows[id],
|
|
23919
|
+
walkPostRow(rows[id], resolve25, raw);
|
|
23674
23920
|
const post = buildPost(raw, mentionMap, author);
|
|
23675
23921
|
if (post) posts.push(post);
|
|
23676
23922
|
}
|
|
@@ -23888,8 +24134,8 @@ function netcapExtract(file) {
|
|
|
23888
24134
|
writeFileSync34(outFile, `${JSON.stringify(posts, null, 2)}
|
|
23889
24135
|
`);
|
|
23890
24136
|
console.log(
|
|
23891
|
-
|
|
23892
|
-
|
|
24137
|
+
chalk175.green(`extracted ${posts.length} posts`),
|
|
24138
|
+
chalk175.dim(`-> ${outFile}`)
|
|
23893
24139
|
);
|
|
23894
24140
|
}
|
|
23895
24141
|
|
|
@@ -23910,7 +24156,7 @@ function registerNetcap(program2) {
|
|
|
23910
24156
|
}
|
|
23911
24157
|
|
|
23912
24158
|
// src/commands/news/add/index.ts
|
|
23913
|
-
import
|
|
24159
|
+
import chalk176 from "chalk";
|
|
23914
24160
|
import enquirer8 from "enquirer";
|
|
23915
24161
|
async function add2(url) {
|
|
23916
24162
|
if (!url) {
|
|
@@ -23932,10 +24178,10 @@ async function add2(url) {
|
|
|
23932
24178
|
const { orm } = await getReady();
|
|
23933
24179
|
const added = await addFeed(orm, url);
|
|
23934
24180
|
if (!added) {
|
|
23935
|
-
console.log(
|
|
24181
|
+
console.log(chalk176.yellow("Feed already exists"));
|
|
23936
24182
|
return;
|
|
23937
24183
|
}
|
|
23938
|
-
console.log(
|
|
24184
|
+
console.log(chalk176.green(`Added feed: ${url}`));
|
|
23939
24185
|
}
|
|
23940
24186
|
|
|
23941
24187
|
// src/commands/registerNews.ts
|
|
@@ -23982,7 +24228,7 @@ function registerPiHook(program2) {
|
|
|
23982
24228
|
}
|
|
23983
24229
|
|
|
23984
24230
|
// src/commands/prompts/printPromptsTable.ts
|
|
23985
|
-
import
|
|
24231
|
+
import chalk177 from "chalk";
|
|
23986
24232
|
function truncate(str, max) {
|
|
23987
24233
|
if (str.length <= max) return str;
|
|
23988
24234
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -24000,14 +24246,14 @@ function printPromptsTable(rows) {
|
|
|
24000
24246
|
"Command".padEnd(commandWidth),
|
|
24001
24247
|
"Repos"
|
|
24002
24248
|
].join(" ");
|
|
24003
|
-
console.log(
|
|
24004
|
-
console.log(
|
|
24249
|
+
console.log(chalk177.dim(header));
|
|
24250
|
+
console.log(chalk177.dim("-".repeat(header.length)));
|
|
24005
24251
|
for (const row of rows) {
|
|
24006
24252
|
const count8 = String(row.count).padStart(countWidth);
|
|
24007
24253
|
const tool = row.tool.padEnd(toolWidth);
|
|
24008
24254
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
24009
24255
|
console.log(
|
|
24010
|
-
`${
|
|
24256
|
+
`${chalk177.yellow(count8)} ${tool} ${command} ${chalk177.dim(row.repos)}`
|
|
24011
24257
|
);
|
|
24012
24258
|
}
|
|
24013
24259
|
}
|
|
@@ -24674,13 +24920,13 @@ function agentFooter(unresolvedCount) {
|
|
|
24674
24920
|
}
|
|
24675
24921
|
|
|
24676
24922
|
// src/commands/prs/listComments/commentStyle.ts
|
|
24677
|
-
import
|
|
24923
|
+
import chalk178 from "chalk";
|
|
24678
24924
|
var plain = (text18) => text18;
|
|
24679
24925
|
function colouredState(state) {
|
|
24680
24926
|
const label2 = `[${state}]`;
|
|
24681
|
-
if (state === "APPROVED") return
|
|
24682
|
-
if (state === "CHANGES_REQUESTED") return
|
|
24683
|
-
return
|
|
24927
|
+
if (state === "APPROVED") return chalk178.green(label2);
|
|
24928
|
+
if (state === "CHANGES_REQUESTED") return chalk178.red(label2);
|
|
24929
|
+
return chalk178.yellow(label2);
|
|
24684
24930
|
}
|
|
24685
24931
|
function commentStyle() {
|
|
24686
24932
|
if (isClaudeCode()) {
|
|
@@ -24694,9 +24940,9 @@ function commentStyle() {
|
|
|
24694
24940
|
};
|
|
24695
24941
|
}
|
|
24696
24942
|
return {
|
|
24697
|
-
cyan:
|
|
24698
|
-
bold:
|
|
24699
|
-
dim:
|
|
24943
|
+
cyan: chalk178.cyan,
|
|
24944
|
+
bold: chalk178.bold,
|
|
24945
|
+
dim: chalk178.dim,
|
|
24700
24946
|
state: colouredState,
|
|
24701
24947
|
diffHunk: true,
|
|
24702
24948
|
agent: false
|
|
@@ -24866,13 +25112,13 @@ import { execSync as execSync48 } from "child_process";
|
|
|
24866
25112
|
import enquirer9 from "enquirer";
|
|
24867
25113
|
|
|
24868
25114
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
24869
|
-
import
|
|
25115
|
+
import chalk179 from "chalk";
|
|
24870
25116
|
var STATUS_MAP = {
|
|
24871
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
24872
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
25117
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk179.magenta("merged"), date: pr.mergedAt } : null,
|
|
25118
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk179.red("closed"), date: pr.closedAt } : null
|
|
24873
25119
|
};
|
|
24874
25120
|
function defaultStatus(pr) {
|
|
24875
|
-
return { label:
|
|
25121
|
+
return { label: chalk179.green("opened"), date: pr.createdAt };
|
|
24876
25122
|
}
|
|
24877
25123
|
function getStatus2(pr) {
|
|
24878
25124
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -24881,11 +25127,11 @@ function formatDate(dateStr) {
|
|
|
24881
25127
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
24882
25128
|
}
|
|
24883
25129
|
function formatPrHeader(pr, status3) {
|
|
24884
|
-
return `${
|
|
25130
|
+
return `${chalk179.cyan(`#${pr.number}`)} ${pr.title} ${chalk179.dim(`(${pr.author.login},`)} ${status3.label} ${chalk179.dim(`${formatDate(status3.date)})`)}`;
|
|
24885
25131
|
}
|
|
24886
25132
|
function logPrDetails(pr) {
|
|
24887
25133
|
console.log(
|
|
24888
|
-
|
|
25134
|
+
chalk179.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
24889
25135
|
);
|
|
24890
25136
|
console.log();
|
|
24891
25137
|
}
|
|
@@ -25114,7 +25360,7 @@ function parseIncoming(line, type) {
|
|
|
25114
25360
|
}
|
|
25115
25361
|
}
|
|
25116
25362
|
function requestSession(message3) {
|
|
25117
|
-
return new Promise((
|
|
25363
|
+
return new Promise((resolve25, reject) => {
|
|
25118
25364
|
connectToDaemon().then((socket) => {
|
|
25119
25365
|
let settled = false;
|
|
25120
25366
|
const finish = (error, sessionId) => {
|
|
@@ -25122,7 +25368,7 @@ function requestSession(message3) {
|
|
|
25122
25368
|
settled = true;
|
|
25123
25369
|
socket.destroy();
|
|
25124
25370
|
if (error) reject(error);
|
|
25125
|
-
else
|
|
25371
|
+
else resolve25(sessionId);
|
|
25126
25372
|
};
|
|
25127
25373
|
readSocketLines(socket, (line) => {
|
|
25128
25374
|
const incoming = parseIncoming(line, message3.type);
|
|
@@ -25600,10 +25846,10 @@ function registerPrs(program2) {
|
|
|
25600
25846
|
}
|
|
25601
25847
|
|
|
25602
25848
|
// src/commands/ravendb/ravendbAuth.ts
|
|
25603
|
-
import
|
|
25849
|
+
import chalk185 from "chalk";
|
|
25604
25850
|
|
|
25605
25851
|
// src/shared/createConnectionAuth.ts
|
|
25606
|
-
import
|
|
25852
|
+
import chalk180 from "chalk";
|
|
25607
25853
|
function listConnections(connections, format) {
|
|
25608
25854
|
if (connections.length === 0) {
|
|
25609
25855
|
console.log("No connections configured.");
|
|
@@ -25616,7 +25862,7 @@ function listConnections(connections, format) {
|
|
|
25616
25862
|
function removeConnection(connections, name, save) {
|
|
25617
25863
|
const filtered = connections.filter((c) => c.name !== name);
|
|
25618
25864
|
if (filtered.length === connections.length) {
|
|
25619
|
-
console.error(
|
|
25865
|
+
console.error(chalk180.red(`Connection "${name}" not found.`));
|
|
25620
25866
|
process.exit(1);
|
|
25621
25867
|
}
|
|
25622
25868
|
save(filtered);
|
|
@@ -25662,15 +25908,15 @@ function saveConnections(connections) {
|
|
|
25662
25908
|
}
|
|
25663
25909
|
|
|
25664
25910
|
// src/commands/ravendb/promptConnection.ts
|
|
25665
|
-
import
|
|
25911
|
+
import chalk183 from "chalk";
|
|
25666
25912
|
|
|
25667
25913
|
// src/commands/ravendb/selectOpSecret.ts
|
|
25668
|
-
import
|
|
25914
|
+
import chalk182 from "chalk";
|
|
25669
25915
|
import Enquirer2 from "enquirer";
|
|
25670
25916
|
|
|
25671
25917
|
// src/commands/ravendb/searchItems.ts
|
|
25672
25918
|
import { execSync as execSync51 } from "child_process";
|
|
25673
|
-
import
|
|
25919
|
+
import chalk181 from "chalk";
|
|
25674
25920
|
function opExec(args) {
|
|
25675
25921
|
return execSync51(`op ${args}`, {
|
|
25676
25922
|
encoding: "utf8",
|
|
@@ -25683,7 +25929,7 @@ function searchItems(search2) {
|
|
|
25683
25929
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
25684
25930
|
} catch {
|
|
25685
25931
|
console.error(
|
|
25686
|
-
|
|
25932
|
+
chalk181.red(
|
|
25687
25933
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
25688
25934
|
)
|
|
25689
25935
|
);
|
|
@@ -25697,7 +25943,7 @@ function getItemFields(itemId2) {
|
|
|
25697
25943
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
25698
25944
|
return item.fields.filter((f) => f.reference && f.label);
|
|
25699
25945
|
} catch {
|
|
25700
|
-
console.error(
|
|
25946
|
+
console.error(chalk181.red("Failed to get item details from 1Password."));
|
|
25701
25947
|
process.exit(1);
|
|
25702
25948
|
}
|
|
25703
25949
|
}
|
|
@@ -25716,7 +25962,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
25716
25962
|
}).run();
|
|
25717
25963
|
const items2 = searchItems(search2);
|
|
25718
25964
|
if (items2.length === 0) {
|
|
25719
|
-
console.error(
|
|
25965
|
+
console.error(chalk182.red(`No items found matching "${search2}".`));
|
|
25720
25966
|
process.exit(1);
|
|
25721
25967
|
}
|
|
25722
25968
|
const itemId2 = await selectOne(
|
|
@@ -25725,7 +25971,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
25725
25971
|
);
|
|
25726
25972
|
const fields = getItemFields(itemId2);
|
|
25727
25973
|
if (fields.length === 0) {
|
|
25728
|
-
console.error(
|
|
25974
|
+
console.error(chalk182.red("No fields with references found on this item."));
|
|
25729
25975
|
process.exit(1);
|
|
25730
25976
|
}
|
|
25731
25977
|
const ref = await selectOne(
|
|
@@ -25739,7 +25985,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
25739
25985
|
async function promptConnection(existingNames) {
|
|
25740
25986
|
const name = await promptInput("name", "Connection name:");
|
|
25741
25987
|
if (existingNames.includes(name)) {
|
|
25742
|
-
console.error(
|
|
25988
|
+
console.error(chalk183.red(`Connection "${name}" already exists.`));
|
|
25743
25989
|
process.exit(1);
|
|
25744
25990
|
}
|
|
25745
25991
|
const url = await promptInput(
|
|
@@ -25748,22 +25994,22 @@ async function promptConnection(existingNames) {
|
|
|
25748
25994
|
);
|
|
25749
25995
|
const database = await promptInput("database", "Database name:");
|
|
25750
25996
|
if (!name || !url || !database) {
|
|
25751
|
-
console.error(
|
|
25997
|
+
console.error(chalk183.red("All fields are required."));
|
|
25752
25998
|
process.exit(1);
|
|
25753
25999
|
}
|
|
25754
26000
|
const apiKeyRef = await selectOpSecret();
|
|
25755
|
-
console.log(
|
|
26001
|
+
console.log(chalk183.dim(`Using: ${apiKeyRef}`));
|
|
25756
26002
|
return { name, url, database, apiKeyRef };
|
|
25757
26003
|
}
|
|
25758
26004
|
|
|
25759
26005
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
25760
|
-
import
|
|
26006
|
+
import chalk184 from "chalk";
|
|
25761
26007
|
function ravendbSetConnection(name) {
|
|
25762
26008
|
const raw = loadGlobalConfigRaw();
|
|
25763
26009
|
const ravendb = raw.ravendb ?? {};
|
|
25764
26010
|
const connections = ravendb.connections ?? [];
|
|
25765
26011
|
if (!connections.some((c) => c.name === name)) {
|
|
25766
|
-
console.error(
|
|
26012
|
+
console.error(chalk184.red(`Connection "${name}" not found.`));
|
|
25767
26013
|
console.error(
|
|
25768
26014
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
25769
26015
|
);
|
|
@@ -25779,16 +26025,16 @@ function ravendbSetConnection(name) {
|
|
|
25779
26025
|
var ravendbAuth = createConnectionAuth({
|
|
25780
26026
|
load: loadConnections,
|
|
25781
26027
|
save: saveConnections,
|
|
25782
|
-
format: (c) => `${
|
|
26028
|
+
format: (c) => `${chalk185.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
25783
26029
|
promptNew: promptConnection,
|
|
25784
26030
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
25785
26031
|
});
|
|
25786
26032
|
|
|
25787
26033
|
// src/commands/ravendb/ravendbCollections.ts
|
|
25788
|
-
import
|
|
26034
|
+
import chalk189 from "chalk";
|
|
25789
26035
|
|
|
25790
26036
|
// src/commands/ravendb/ravenFetch.ts
|
|
25791
|
-
import
|
|
26037
|
+
import chalk187 from "chalk";
|
|
25792
26038
|
|
|
25793
26039
|
// src/commands/ravendb/getAccessToken.ts
|
|
25794
26040
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -25825,10 +26071,10 @@ ${errorText}`
|
|
|
25825
26071
|
|
|
25826
26072
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
25827
26073
|
import { execSync as execSync52 } from "child_process";
|
|
25828
|
-
import
|
|
26074
|
+
import chalk186 from "chalk";
|
|
25829
26075
|
function resolveOpSecret(reference) {
|
|
25830
26076
|
if (!reference.startsWith("op://")) {
|
|
25831
|
-
console.error(
|
|
26077
|
+
console.error(chalk186.red(`Invalid secret reference: must start with op://`));
|
|
25832
26078
|
process.exit(1);
|
|
25833
26079
|
}
|
|
25834
26080
|
try {
|
|
@@ -25838,7 +26084,7 @@ function resolveOpSecret(reference) {
|
|
|
25838
26084
|
}).trim();
|
|
25839
26085
|
} catch {
|
|
25840
26086
|
console.error(
|
|
25841
|
-
|
|
26087
|
+
chalk186.red(
|
|
25842
26088
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
25843
26089
|
)
|
|
25844
26090
|
);
|
|
@@ -25865,7 +26111,7 @@ async function ravenFetch(connection, path80) {
|
|
|
25865
26111
|
if (!response.ok) {
|
|
25866
26112
|
const body = await response.text();
|
|
25867
26113
|
console.error(
|
|
25868
|
-
|
|
26114
|
+
chalk187.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
25869
26115
|
);
|
|
25870
26116
|
console.error(body.substring(0, 500));
|
|
25871
26117
|
process.exit(1);
|
|
@@ -25874,7 +26120,7 @@ async function ravenFetch(connection, path80) {
|
|
|
25874
26120
|
}
|
|
25875
26121
|
|
|
25876
26122
|
// src/commands/ravendb/resolveConnection.ts
|
|
25877
|
-
import
|
|
26123
|
+
import chalk188 from "chalk";
|
|
25878
26124
|
function loadRavendb() {
|
|
25879
26125
|
const raw = loadGlobalConfigRaw();
|
|
25880
26126
|
const ravendb = raw.ravendb;
|
|
@@ -25888,7 +26134,7 @@ function resolveConnection(name) {
|
|
|
25888
26134
|
const connectionName = name ?? defaultConnection;
|
|
25889
26135
|
if (!connectionName) {
|
|
25890
26136
|
console.error(
|
|
25891
|
-
|
|
26137
|
+
chalk188.red(
|
|
25892
26138
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
25893
26139
|
)
|
|
25894
26140
|
);
|
|
@@ -25896,7 +26142,7 @@ function resolveConnection(name) {
|
|
|
25896
26142
|
}
|
|
25897
26143
|
const connection = connections.find((c) => c.name === connectionName);
|
|
25898
26144
|
if (!connection) {
|
|
25899
|
-
console.error(
|
|
26145
|
+
console.error(chalk188.red(`Connection "${connectionName}" not found.`));
|
|
25900
26146
|
console.error(
|
|
25901
26147
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
25902
26148
|
);
|
|
@@ -25927,15 +26173,15 @@ async function ravendbCollections(connectionName) {
|
|
|
25927
26173
|
return;
|
|
25928
26174
|
}
|
|
25929
26175
|
for (const c of collections) {
|
|
25930
|
-
console.log(`${
|
|
26176
|
+
console.log(`${chalk189.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
25931
26177
|
}
|
|
25932
26178
|
}
|
|
25933
26179
|
|
|
25934
26180
|
// src/commands/ravendb/ravendbQuery.ts
|
|
25935
|
-
import
|
|
26181
|
+
import chalk191 from "chalk";
|
|
25936
26182
|
|
|
25937
26183
|
// src/commands/ravendb/fetchAllPages.ts
|
|
25938
|
-
import
|
|
26184
|
+
import chalk190 from "chalk";
|
|
25939
26185
|
|
|
25940
26186
|
// src/commands/ravendb/buildQueryPath.ts
|
|
25941
26187
|
function buildQueryPath(opts) {
|
|
@@ -25973,7 +26219,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
25973
26219
|
allResults.push(...results);
|
|
25974
26220
|
start3 += results.length;
|
|
25975
26221
|
process.stderr.write(
|
|
25976
|
-
`\r${
|
|
26222
|
+
`\r${chalk190.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
25977
26223
|
);
|
|
25978
26224
|
if (start3 >= totalResults) break;
|
|
25979
26225
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -25988,7 +26234,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
25988
26234
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
25989
26235
|
const resolved = resolveArgs(connectionName, collection);
|
|
25990
26236
|
if (!resolved.collection && !options2.query) {
|
|
25991
|
-
console.error(
|
|
26237
|
+
console.error(chalk191.red("Provide a collection name or --query filter."));
|
|
25992
26238
|
process.exit(1);
|
|
25993
26239
|
}
|
|
25994
26240
|
const { collection: col } = resolved;
|
|
@@ -26027,7 +26273,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
26027
26273
|
import * as path42 from "path";
|
|
26028
26274
|
|
|
26029
26275
|
// src/commands/refactor/logViolations.ts
|
|
26030
|
-
import
|
|
26276
|
+
import chalk192 from "chalk";
|
|
26031
26277
|
var DEFAULT_MAX_LINES2 = 100;
|
|
26032
26278
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
26033
26279
|
if (violations.length === 0) {
|
|
@@ -26036,43 +26282,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
26036
26282
|
}
|
|
26037
26283
|
return;
|
|
26038
26284
|
}
|
|
26039
|
-
console.error(
|
|
26285
|
+
console.error(chalk192.red(`
|
|
26040
26286
|
Refactor check failed:
|
|
26041
26287
|
`));
|
|
26042
|
-
console.error(
|
|
26288
|
+
console.error(chalk192.red(` The following files exceed ${maxLines} lines:
|
|
26043
26289
|
`));
|
|
26044
26290
|
for (const violation of violations) {
|
|
26045
|
-
console.error(
|
|
26291
|
+
console.error(chalk192.red(` ${violation.file} (${violation.lines} lines)`));
|
|
26046
26292
|
}
|
|
26047
26293
|
console.error(
|
|
26048
|
-
|
|
26294
|
+
chalk192.yellow(
|
|
26049
26295
|
`
|
|
26050
26296
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
26051
26297
|
way to refactor it, ignore it with:
|
|
26052
26298
|
`
|
|
26053
26299
|
)
|
|
26054
26300
|
);
|
|
26055
|
-
console.error(
|
|
26301
|
+
console.error(chalk192.gray(` assist refactor ignore <file>
|
|
26056
26302
|
`));
|
|
26057
26303
|
if (process.env.CLAUDECODE) {
|
|
26058
|
-
console.error(
|
|
26304
|
+
console.error(chalk192.cyan(`
|
|
26059
26305
|
## Extracting Code to New Files
|
|
26060
26306
|
`));
|
|
26061
26307
|
console.error(
|
|
26062
|
-
|
|
26308
|
+
chalk192.cyan(
|
|
26063
26309
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
26064
26310
|
`
|
|
26065
26311
|
)
|
|
26066
26312
|
);
|
|
26067
26313
|
console.error(
|
|
26068
|
-
|
|
26314
|
+
chalk192.cyan(
|
|
26069
26315
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
26070
26316
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
26071
26317
|
`
|
|
26072
26318
|
)
|
|
26073
26319
|
);
|
|
26074
26320
|
console.error(
|
|
26075
|
-
|
|
26321
|
+
chalk192.cyan(
|
|
26076
26322
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
26077
26323
|
domains, move it to a common/shared folder.
|
|
26078
26324
|
`
|
|
@@ -26170,7 +26416,7 @@ function getViolations(pattern2, options2 = {}, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
26170
26416
|
|
|
26171
26417
|
// src/commands/refactor/check/index.ts
|
|
26172
26418
|
function runScript(script, cwd) {
|
|
26173
|
-
return new Promise((
|
|
26419
|
+
return new Promise((resolve25) => {
|
|
26174
26420
|
const child = spawn6("npm", ["run", script], {
|
|
26175
26421
|
stdio: "pipe",
|
|
26176
26422
|
shell: true,
|
|
@@ -26184,7 +26430,7 @@ function runScript(script, cwd) {
|
|
|
26184
26430
|
output += data.toString();
|
|
26185
26431
|
});
|
|
26186
26432
|
child.on("close", (code) => {
|
|
26187
|
-
|
|
26433
|
+
resolve25({ script, code: code ?? 1, output });
|
|
26188
26434
|
});
|
|
26189
26435
|
});
|
|
26190
26436
|
}
|
|
@@ -26228,7 +26474,7 @@ async function check(pattern2, options2) {
|
|
|
26228
26474
|
|
|
26229
26475
|
// src/commands/refactor/extract/index.ts
|
|
26230
26476
|
import path50 from "path";
|
|
26231
|
-
import
|
|
26477
|
+
import chalk195 from "chalk";
|
|
26232
26478
|
|
|
26233
26479
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
26234
26480
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -26827,23 +27073,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
26827
27073
|
|
|
26828
27074
|
// src/commands/refactor/extract/displayPlan.ts
|
|
26829
27075
|
import path46 from "path";
|
|
26830
|
-
import
|
|
27076
|
+
import chalk193 from "chalk";
|
|
26831
27077
|
function section2(title) {
|
|
26832
27078
|
return `
|
|
26833
|
-
${
|
|
27079
|
+
${chalk193.cyan(title)}`;
|
|
26834
27080
|
}
|
|
26835
27081
|
function displayImporters(plan2, cwd) {
|
|
26836
27082
|
if (plan2.importersToUpdate.length === 0) return;
|
|
26837
27083
|
console.log(section2("Update importers:"));
|
|
26838
27084
|
for (const imp of plan2.importersToUpdate) {
|
|
26839
27085
|
const rel = path46.relative(cwd, imp.file.getFilePath());
|
|
26840
|
-
console.log(` ${
|
|
27086
|
+
console.log(` ${chalk193.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
26841
27087
|
}
|
|
26842
27088
|
}
|
|
26843
27089
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
26844
|
-
console.log(
|
|
27090
|
+
console.log(chalk193.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
26845
27091
|
`));
|
|
26846
|
-
console.log(` ${
|
|
27092
|
+
console.log(` ${chalk193.cyan("Functions to move:")}`);
|
|
26847
27093
|
for (const name of plan2.extractedNames) {
|
|
26848
27094
|
console.log(` ${name}`);
|
|
26849
27095
|
}
|
|
@@ -26877,7 +27123,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
26877
27123
|
|
|
26878
27124
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
26879
27125
|
import path49 from "path";
|
|
26880
|
-
import
|
|
27126
|
+
import chalk194 from "chalk";
|
|
26881
27127
|
import { Project as Project4 } from "ts-morph";
|
|
26882
27128
|
|
|
26883
27129
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -26969,7 +27215,7 @@ function loadProjectFile(file) {
|
|
|
26969
27215
|
});
|
|
26970
27216
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
26971
27217
|
if (!sourceFile) {
|
|
26972
|
-
console.log(
|
|
27218
|
+
console.log(chalk194.red(`File not found in project: ${file}`));
|
|
26973
27219
|
process.exit(1);
|
|
26974
27220
|
}
|
|
26975
27221
|
return { project, sourceFile };
|
|
@@ -26992,19 +27238,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
26992
27238
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
26993
27239
|
if (options2.apply) {
|
|
26994
27240
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
26995
|
-
console.log(
|
|
27241
|
+
console.log(chalk195.green("\nExtraction complete"));
|
|
26996
27242
|
} else {
|
|
26997
|
-
console.log(
|
|
27243
|
+
console.log(chalk195.dim("\nDry run. Use --apply to execute."));
|
|
26998
27244
|
}
|
|
26999
27245
|
}
|
|
27000
27246
|
|
|
27001
27247
|
// src/commands/refactor/ignore.ts
|
|
27002
27248
|
import fs33 from "fs";
|
|
27003
|
-
import
|
|
27249
|
+
import chalk196 from "chalk";
|
|
27004
27250
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
27005
27251
|
function ignore2(file) {
|
|
27006
27252
|
if (!fs33.existsSync(file)) {
|
|
27007
|
-
console.error(
|
|
27253
|
+
console.error(chalk196.red(`Error: File does not exist: ${file}`));
|
|
27008
27254
|
process.exit(1);
|
|
27009
27255
|
}
|
|
27010
27256
|
const content = fs33.readFileSync(file, "utf8");
|
|
@@ -27020,7 +27266,7 @@ function ignore2(file) {
|
|
|
27020
27266
|
fs33.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
27021
27267
|
}
|
|
27022
27268
|
console.log(
|
|
27023
|
-
|
|
27269
|
+
chalk196.green(
|
|
27024
27270
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
27025
27271
|
)
|
|
27026
27272
|
);
|
|
@@ -27029,12 +27275,12 @@ function ignore2(file) {
|
|
|
27029
27275
|
// src/commands/refactor/rename/index.ts
|
|
27030
27276
|
import fs36 from "fs";
|
|
27031
27277
|
import path55 from "path";
|
|
27032
|
-
import
|
|
27278
|
+
import chalk199 from "chalk";
|
|
27033
27279
|
|
|
27034
27280
|
// src/commands/refactor/rename/applyRename.ts
|
|
27035
27281
|
import fs35 from "fs";
|
|
27036
27282
|
import path52 from "path";
|
|
27037
|
-
import
|
|
27283
|
+
import chalk197 from "chalk";
|
|
27038
27284
|
|
|
27039
27285
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
27040
27286
|
import path51 from "path";
|
|
@@ -27139,13 +27385,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
27139
27385
|
const updatedContents = applyRewrites(rewrites);
|
|
27140
27386
|
for (const [file, content] of updatedContents) {
|
|
27141
27387
|
fs35.writeFileSync(file, content, "utf8");
|
|
27142
|
-
console.log(
|
|
27388
|
+
console.log(chalk197.cyan(` Updated imports in ${path52.relative(cwd, file)}`));
|
|
27143
27389
|
}
|
|
27144
27390
|
const destDir = path52.dirname(destPath);
|
|
27145
27391
|
if (!fs35.existsSync(destDir)) fs35.mkdirSync(destDir, { recursive: true });
|
|
27146
27392
|
fs35.renameSync(sourcePath, destPath);
|
|
27147
27393
|
console.log(
|
|
27148
|
-
|
|
27394
|
+
chalk197.white(
|
|
27149
27395
|
` Moved ${path52.relative(cwd, sourcePath)} \u2192 ${path52.relative(cwd, destPath)}`
|
|
27150
27396
|
)
|
|
27151
27397
|
);
|
|
@@ -27232,16 +27478,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
27232
27478
|
|
|
27233
27479
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
27234
27480
|
import path54 from "path";
|
|
27235
|
-
import
|
|
27481
|
+
import chalk198 from "chalk";
|
|
27236
27482
|
function printRenamePreview(rewrites, cwd) {
|
|
27237
27483
|
for (const rewrite of rewrites) {
|
|
27238
27484
|
console.log(
|
|
27239
|
-
|
|
27485
|
+
chalk198.dim(
|
|
27240
27486
|
` ${path54.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
27241
27487
|
)
|
|
27242
27488
|
);
|
|
27243
27489
|
}
|
|
27244
|
-
console.log(
|
|
27490
|
+
console.log(chalk198.dim("Dry run. Use --apply to execute."));
|
|
27245
27491
|
}
|
|
27246
27492
|
|
|
27247
27493
|
// src/commands/refactor/rename/index.ts
|
|
@@ -27252,20 +27498,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27252
27498
|
const relSource = path55.relative(cwd, sourcePath);
|
|
27253
27499
|
const relDest = path55.relative(cwd, destPath);
|
|
27254
27500
|
if (!fs36.existsSync(sourcePath)) {
|
|
27255
|
-
console.log(
|
|
27501
|
+
console.log(chalk199.red(`File not found: ${source}`));
|
|
27256
27502
|
process.exit(1);
|
|
27257
27503
|
}
|
|
27258
27504
|
if (destPath !== sourcePath && fs36.existsSync(destPath)) {
|
|
27259
|
-
console.log(
|
|
27505
|
+
console.log(chalk199.red(`Destination already exists: ${destination}`));
|
|
27260
27506
|
process.exit(1);
|
|
27261
27507
|
}
|
|
27262
|
-
console.log(
|
|
27263
|
-
console.log(
|
|
27264
|
-
console.log(
|
|
27508
|
+
console.log(chalk199.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
27509
|
+
console.log(chalk199.dim("Loading project..."));
|
|
27510
|
+
console.log(chalk199.dim("Scanning imports across the project..."));
|
|
27265
27511
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
27266
27512
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
27267
27513
|
console.log(
|
|
27268
|
-
|
|
27514
|
+
chalk199.dim(
|
|
27269
27515
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
27270
27516
|
)
|
|
27271
27517
|
);
|
|
@@ -27274,11 +27520,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27274
27520
|
return;
|
|
27275
27521
|
}
|
|
27276
27522
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
27277
|
-
console.log(
|
|
27523
|
+
console.log(chalk199.green("Done"));
|
|
27278
27524
|
}
|
|
27279
27525
|
|
|
27280
27526
|
// src/commands/refactor/renameSymbol/index.ts
|
|
27281
|
-
import
|
|
27527
|
+
import chalk200 from "chalk";
|
|
27282
27528
|
|
|
27283
27529
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
27284
27530
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -27324,33 +27570,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
27324
27570
|
const { project, sourceFile } = loadProjectFile(file);
|
|
27325
27571
|
const symbol = findSymbol(sourceFile, oldName);
|
|
27326
27572
|
if (!symbol) {
|
|
27327
|
-
console.log(
|
|
27573
|
+
console.log(chalk200.red(`Symbol "${oldName}" not found in ${file}`));
|
|
27328
27574
|
process.exit(1);
|
|
27329
27575
|
}
|
|
27330
27576
|
const grouped = groupReferences(symbol, cwd);
|
|
27331
27577
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
27332
27578
|
console.log(
|
|
27333
|
-
|
|
27579
|
+
chalk200.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
27334
27580
|
`)
|
|
27335
27581
|
);
|
|
27336
27582
|
for (const [refFile, lines2] of grouped) {
|
|
27337
27583
|
console.log(
|
|
27338
|
-
` ${
|
|
27584
|
+
` ${chalk200.dim(refFile)}: lines ${chalk200.cyan(lines2.join(", "))}`
|
|
27339
27585
|
);
|
|
27340
27586
|
}
|
|
27341
27587
|
if (options2.apply) {
|
|
27342
27588
|
symbol.rename(newName);
|
|
27343
27589
|
await project.save();
|
|
27344
|
-
console.log(
|
|
27590
|
+
console.log(chalk200.green(`
|
|
27345
27591
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
27346
27592
|
} else {
|
|
27347
|
-
console.log(
|
|
27593
|
+
console.log(chalk200.dim("\nDry run. Use --apply to execute."));
|
|
27348
27594
|
}
|
|
27349
27595
|
}
|
|
27350
27596
|
|
|
27351
27597
|
// src/commands/refactor/restructure/index.ts
|
|
27352
27598
|
import path63 from "path";
|
|
27353
|
-
import
|
|
27599
|
+
import chalk203 from "chalk";
|
|
27354
27600
|
|
|
27355
27601
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
27356
27602
|
import path57 from "path";
|
|
@@ -27429,50 +27675,50 @@ function clusterFiles(graph) {
|
|
|
27429
27675
|
|
|
27430
27676
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
27431
27677
|
import path59 from "path";
|
|
27432
|
-
import
|
|
27678
|
+
import chalk201 from "chalk";
|
|
27433
27679
|
function relPath(filePath) {
|
|
27434
27680
|
return path59.relative(process.cwd(), filePath);
|
|
27435
27681
|
}
|
|
27436
27682
|
function displayMoves(plan2) {
|
|
27437
27683
|
if (plan2.moves.length === 0) return;
|
|
27438
|
-
console.log(
|
|
27684
|
+
console.log(chalk201.bold("\nFile moves:"));
|
|
27439
27685
|
for (const move2 of plan2.moves) {
|
|
27440
27686
|
console.log(
|
|
27441
|
-
` ${
|
|
27687
|
+
` ${chalk201.red(relPath(move2.from))} \u2192 ${chalk201.green(relPath(move2.to))}`
|
|
27442
27688
|
);
|
|
27443
|
-
console.log(
|
|
27689
|
+
console.log(chalk201.dim(` ${move2.reason}`));
|
|
27444
27690
|
}
|
|
27445
27691
|
}
|
|
27446
27692
|
function displayRewrites(rewrites) {
|
|
27447
27693
|
if (rewrites.length === 0) return;
|
|
27448
27694
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
27449
|
-
console.log(
|
|
27695
|
+
console.log(chalk201.bold(`
|
|
27450
27696
|
Import rewrites (${affectedFiles.size} files):`));
|
|
27451
27697
|
for (const file of affectedFiles) {
|
|
27452
|
-
console.log(` ${
|
|
27698
|
+
console.log(` ${chalk201.cyan(relPath(file))}:`);
|
|
27453
27699
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
27454
27700
|
(r) => r.file === file
|
|
27455
27701
|
)) {
|
|
27456
27702
|
console.log(
|
|
27457
|
-
` ${
|
|
27703
|
+
` ${chalk201.red(`"${oldSpecifier}"`)} \u2192 ${chalk201.green(`"${newSpecifier}"`)}`
|
|
27458
27704
|
);
|
|
27459
27705
|
}
|
|
27460
27706
|
}
|
|
27461
27707
|
}
|
|
27462
27708
|
function displayPlan2(plan2) {
|
|
27463
27709
|
if (plan2.warnings.length > 0) {
|
|
27464
|
-
console.log(
|
|
27465
|
-
for (const w of plan2.warnings) console.log(
|
|
27710
|
+
console.log(chalk201.yellow("\nWarnings:"));
|
|
27711
|
+
for (const w of plan2.warnings) console.log(chalk201.yellow(` ${w}`));
|
|
27466
27712
|
}
|
|
27467
27713
|
if (plan2.newDirectories.length > 0) {
|
|
27468
|
-
console.log(
|
|
27714
|
+
console.log(chalk201.bold("\nNew directories:"));
|
|
27469
27715
|
for (const dir of plan2.newDirectories)
|
|
27470
|
-
console.log(
|
|
27716
|
+
console.log(chalk201.green(` ${dir}/`));
|
|
27471
27717
|
}
|
|
27472
27718
|
displayMoves(plan2);
|
|
27473
27719
|
displayRewrites(plan2.rewrites);
|
|
27474
27720
|
console.log(
|
|
27475
|
-
|
|
27721
|
+
chalk201.dim(
|
|
27476
27722
|
`
|
|
27477
27723
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
27478
27724
|
)
|
|
@@ -27482,18 +27728,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
27482
27728
|
// src/commands/refactor/restructure/executePlan.ts
|
|
27483
27729
|
import fs37 from "fs";
|
|
27484
27730
|
import path60 from "path";
|
|
27485
|
-
import
|
|
27731
|
+
import chalk202 from "chalk";
|
|
27486
27732
|
function executePlan(plan2) {
|
|
27487
27733
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
27488
27734
|
for (const [file, content] of updatedContents) {
|
|
27489
27735
|
fs37.writeFileSync(file, content, "utf8");
|
|
27490
27736
|
console.log(
|
|
27491
|
-
|
|
27737
|
+
chalk202.cyan(` Rewrote imports in ${path60.relative(process.cwd(), file)}`)
|
|
27492
27738
|
);
|
|
27493
27739
|
}
|
|
27494
27740
|
for (const dir of plan2.newDirectories) {
|
|
27495
27741
|
fs37.mkdirSync(dir, { recursive: true });
|
|
27496
|
-
console.log(
|
|
27742
|
+
console.log(chalk202.green(` Created ${path60.relative(process.cwd(), dir)}/`));
|
|
27497
27743
|
}
|
|
27498
27744
|
for (const move2 of plan2.moves) {
|
|
27499
27745
|
const targetDir = path60.dirname(move2.to);
|
|
@@ -27502,7 +27748,7 @@ function executePlan(plan2) {
|
|
|
27502
27748
|
}
|
|
27503
27749
|
fs37.renameSync(move2.from, move2.to);
|
|
27504
27750
|
console.log(
|
|
27505
|
-
|
|
27751
|
+
chalk202.white(
|
|
27506
27752
|
` Moved ${path60.relative(process.cwd(), move2.from)} \u2192 ${path60.relative(process.cwd(), move2.to)}`
|
|
27507
27753
|
)
|
|
27508
27754
|
);
|
|
@@ -27517,7 +27763,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
27517
27763
|
if (entries.length === 0) {
|
|
27518
27764
|
fs37.rmdirSync(dir);
|
|
27519
27765
|
console.log(
|
|
27520
|
-
|
|
27766
|
+
chalk202.dim(
|
|
27521
27767
|
` Removed empty directory ${path60.relative(process.cwd(), dir)}`
|
|
27522
27768
|
)
|
|
27523
27769
|
);
|
|
@@ -27650,22 +27896,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
27650
27896
|
const targetPattern = pattern2 ?? "src";
|
|
27651
27897
|
const files = findSourceFiles2(targetPattern);
|
|
27652
27898
|
if (files.length === 0) {
|
|
27653
|
-
console.log(
|
|
27899
|
+
console.log(chalk203.yellow("No files found matching pattern"));
|
|
27654
27900
|
return;
|
|
27655
27901
|
}
|
|
27656
27902
|
const tsConfigPath = findTsConfig(path63.resolve(files[0]));
|
|
27657
27903
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
27658
27904
|
if (plan2.moves.length === 0) {
|
|
27659
|
-
console.log(
|
|
27905
|
+
console.log(chalk203.green("No restructuring needed"));
|
|
27660
27906
|
return;
|
|
27661
27907
|
}
|
|
27662
27908
|
displayPlan2(plan2);
|
|
27663
27909
|
if (options2.apply) {
|
|
27664
|
-
console.log(
|
|
27910
|
+
console.log(chalk203.bold("\nApplying changes..."));
|
|
27665
27911
|
executePlan(plan2);
|
|
27666
|
-
console.log(
|
|
27912
|
+
console.log(chalk203.green("\nRestructuring complete"));
|
|
27667
27913
|
} else {
|
|
27668
|
-
console.log(
|
|
27914
|
+
console.log(chalk203.dim("\nDry run. Use --apply to execute."));
|
|
27669
27915
|
}
|
|
27670
27916
|
}
|
|
27671
27917
|
|
|
@@ -28323,18 +28569,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
28323
28569
|
}
|
|
28324
28570
|
|
|
28325
28571
|
// src/commands/review/warnOutOfDiff.ts
|
|
28326
|
-
import
|
|
28572
|
+
import chalk204 from "chalk";
|
|
28327
28573
|
function warnOutOfDiff(outOfDiff) {
|
|
28328
28574
|
if (outOfDiff.length === 0) return;
|
|
28329
28575
|
console.warn(
|
|
28330
|
-
|
|
28576
|
+
chalk204.yellow(
|
|
28331
28577
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
28332
28578
|
)
|
|
28333
28579
|
);
|
|
28334
28580
|
for (const finding of outOfDiff) {
|
|
28335
28581
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
28336
28582
|
console.warn(
|
|
28337
|
-
` ${
|
|
28583
|
+
` ${chalk204.yellow("\xB7")} ${finding.title} ${chalk204.dim(
|
|
28338
28584
|
`(${finding.file}:${range})`
|
|
28339
28585
|
)}`
|
|
28340
28586
|
);
|
|
@@ -28358,18 +28604,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
28358
28604
|
}
|
|
28359
28605
|
|
|
28360
28606
|
// src/commands/review/warnUnlocated.ts
|
|
28361
|
-
import
|
|
28607
|
+
import chalk205 from "chalk";
|
|
28362
28608
|
function warnUnlocated(unlocated) {
|
|
28363
28609
|
if (unlocated.length === 0) return;
|
|
28364
28610
|
console.warn(
|
|
28365
|
-
|
|
28611
|
+
chalk205.yellow(
|
|
28366
28612
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
28367
28613
|
)
|
|
28368
28614
|
);
|
|
28369
28615
|
for (const finding of unlocated) {
|
|
28370
|
-
const where = finding.location ||
|
|
28616
|
+
const where = finding.location || chalk205.dim("missing");
|
|
28371
28617
|
console.warn(
|
|
28372
|
-
` ${
|
|
28618
|
+
` ${chalk205.yellow("\xB7")} ${finding.title} ${chalk205.dim(`(${where})`)}`
|
|
28373
28619
|
);
|
|
28374
28620
|
}
|
|
28375
28621
|
}
|
|
@@ -29135,12 +29381,12 @@ function onCloseResult(ctx, code) {
|
|
|
29135
29381
|
return { ...closed, stderr: ctx.stderr.value, stdout: ctx.stdout.value };
|
|
29136
29382
|
}
|
|
29137
29383
|
function waitForChildExit(ctx) {
|
|
29138
|
-
return new Promise((
|
|
29384
|
+
return new Promise((resolve25) => {
|
|
29139
29385
|
let settled = false;
|
|
29140
29386
|
const settle = (result) => {
|
|
29141
29387
|
if (settled) return;
|
|
29142
29388
|
settled = true;
|
|
29143
|
-
|
|
29389
|
+
resolve25(result);
|
|
29144
29390
|
};
|
|
29145
29391
|
ctx.child.on("error", (err) => settle(onErrorResult(ctx, err)));
|
|
29146
29392
|
ctx.child.on("close", (code) => settle(onCloseResult(ctx, code)));
|
|
@@ -29624,7 +29870,7 @@ function registerReview(program2) {
|
|
|
29624
29870
|
}
|
|
29625
29871
|
|
|
29626
29872
|
// src/commands/seq/seqAuth.ts
|
|
29627
|
-
import
|
|
29873
|
+
import chalk207 from "chalk";
|
|
29628
29874
|
|
|
29629
29875
|
// src/commands/seq/loadConnections.ts
|
|
29630
29876
|
function loadConnections2() {
|
|
@@ -29653,10 +29899,10 @@ function setDefaultConnection(name) {
|
|
|
29653
29899
|
}
|
|
29654
29900
|
|
|
29655
29901
|
// src/shared/assertUniqueName.ts
|
|
29656
|
-
import
|
|
29902
|
+
import chalk206 from "chalk";
|
|
29657
29903
|
function assertUniqueName(existingNames, name) {
|
|
29658
29904
|
if (existingNames.includes(name)) {
|
|
29659
|
-
console.error(
|
|
29905
|
+
console.error(chalk206.red(`Connection "${name}" already exists.`));
|
|
29660
29906
|
process.exit(1);
|
|
29661
29907
|
}
|
|
29662
29908
|
}
|
|
@@ -29674,16 +29920,16 @@ async function promptConnection2(existingNames) {
|
|
|
29674
29920
|
var seqAuth = createConnectionAuth({
|
|
29675
29921
|
load: loadConnections2,
|
|
29676
29922
|
save: saveConnections2,
|
|
29677
|
-
format: (c) => `${
|
|
29923
|
+
format: (c) => `${chalk207.bold(c.name)} ${c.url}`,
|
|
29678
29924
|
promptNew: promptConnection2,
|
|
29679
29925
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
29680
29926
|
});
|
|
29681
29927
|
|
|
29682
29928
|
// src/commands/seq/seqQuery.ts
|
|
29683
|
-
import
|
|
29929
|
+
import chalk211 from "chalk";
|
|
29684
29930
|
|
|
29685
29931
|
// src/commands/seq/fetchSeq.ts
|
|
29686
|
-
import
|
|
29932
|
+
import chalk208 from "chalk";
|
|
29687
29933
|
async function fetchSeq(conn, path80, params) {
|
|
29688
29934
|
const url = `${conn.url}${path80}?${params}`;
|
|
29689
29935
|
const response = await fetch(url, {
|
|
@@ -29694,7 +29940,7 @@ async function fetchSeq(conn, path80, params) {
|
|
|
29694
29940
|
});
|
|
29695
29941
|
if (!response.ok) {
|
|
29696
29942
|
const body = await response.text();
|
|
29697
|
-
console.error(
|
|
29943
|
+
console.error(chalk208.red(`Seq returned ${response.status}: ${body}`));
|
|
29698
29944
|
process.exit(1);
|
|
29699
29945
|
}
|
|
29700
29946
|
return response;
|
|
@@ -29753,23 +29999,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
29753
29999
|
}
|
|
29754
30000
|
|
|
29755
30001
|
// src/commands/seq/formatEvent.ts
|
|
29756
|
-
import
|
|
30002
|
+
import chalk209 from "chalk";
|
|
29757
30003
|
function levelColor(level) {
|
|
29758
30004
|
switch (level) {
|
|
29759
30005
|
case "Fatal":
|
|
29760
|
-
return
|
|
30006
|
+
return chalk209.bgRed.white;
|
|
29761
30007
|
case "Error":
|
|
29762
|
-
return
|
|
30008
|
+
return chalk209.red;
|
|
29763
30009
|
case "Warning":
|
|
29764
|
-
return
|
|
30010
|
+
return chalk209.yellow;
|
|
29765
30011
|
case "Information":
|
|
29766
|
-
return
|
|
30012
|
+
return chalk209.cyan;
|
|
29767
30013
|
case "Debug":
|
|
29768
|
-
return
|
|
30014
|
+
return chalk209.gray;
|
|
29769
30015
|
case "Verbose":
|
|
29770
|
-
return
|
|
30016
|
+
return chalk209.dim;
|
|
29771
30017
|
default:
|
|
29772
|
-
return
|
|
30018
|
+
return chalk209.white;
|
|
29773
30019
|
}
|
|
29774
30020
|
}
|
|
29775
30021
|
function levelAbbrev(level) {
|
|
@@ -29810,12 +30056,12 @@ function formatTimestamp(iso) {
|
|
|
29810
30056
|
function formatEvent(event) {
|
|
29811
30057
|
const color = levelColor(event.Level);
|
|
29812
30058
|
const abbrev = levelAbbrev(event.Level);
|
|
29813
|
-
const ts8 =
|
|
30059
|
+
const ts8 = chalk209.dim(formatTimestamp(event.Timestamp));
|
|
29814
30060
|
const msg = renderMessage(event);
|
|
29815
30061
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
29816
30062
|
if (event.Exception) {
|
|
29817
30063
|
for (const line of event.Exception.split("\n")) {
|
|
29818
|
-
lines2.push(
|
|
30064
|
+
lines2.push(chalk209.red(` ${line}`));
|
|
29819
30065
|
}
|
|
29820
30066
|
}
|
|
29821
30067
|
return lines2.join("\n");
|
|
@@ -29848,11 +30094,11 @@ function rejectTimestampFilter(filter) {
|
|
|
29848
30094
|
}
|
|
29849
30095
|
|
|
29850
30096
|
// src/shared/resolveNamedConnection.ts
|
|
29851
|
-
import
|
|
30097
|
+
import chalk210 from "chalk";
|
|
29852
30098
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
29853
30099
|
if (connections.length === 0) {
|
|
29854
30100
|
console.error(
|
|
29855
|
-
|
|
30101
|
+
chalk210.red(
|
|
29856
30102
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
29857
30103
|
)
|
|
29858
30104
|
);
|
|
@@ -29861,7 +30107,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
29861
30107
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
29862
30108
|
const connection = connections.find((c) => c.name === target);
|
|
29863
30109
|
if (!connection) {
|
|
29864
|
-
console.error(
|
|
30110
|
+
console.error(chalk210.red(`${kind} connection "${target}" not found.`));
|
|
29865
30111
|
process.exit(1);
|
|
29866
30112
|
}
|
|
29867
30113
|
return connection;
|
|
@@ -29890,7 +30136,7 @@ async function seqQuery(filter, options2) {
|
|
|
29890
30136
|
new URLSearchParams({ filter, count: String(count8) })
|
|
29891
30137
|
);
|
|
29892
30138
|
if (events.length === 0) {
|
|
29893
|
-
console.log(
|
|
30139
|
+
console.log(chalk211.yellow("No events found."));
|
|
29894
30140
|
return;
|
|
29895
30141
|
}
|
|
29896
30142
|
if (options2.json) {
|
|
@@ -29901,11 +30147,11 @@ async function seqQuery(filter, options2) {
|
|
|
29901
30147
|
for (const event of chronological) {
|
|
29902
30148
|
console.log(formatEvent(event));
|
|
29903
30149
|
}
|
|
29904
|
-
console.log(
|
|
30150
|
+
console.log(chalk211.dim(`
|
|
29905
30151
|
${events.length} events`));
|
|
29906
30152
|
if (events.length >= count8) {
|
|
29907
30153
|
console.log(
|
|
29908
|
-
|
|
30154
|
+
chalk211.yellow(
|
|
29909
30155
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
29910
30156
|
)
|
|
29911
30157
|
);
|
|
@@ -29913,10 +30159,10 @@ ${events.length} events`));
|
|
|
29913
30159
|
}
|
|
29914
30160
|
|
|
29915
30161
|
// src/shared/setNamedDefaultConnection.ts
|
|
29916
|
-
import
|
|
30162
|
+
import chalk212 from "chalk";
|
|
29917
30163
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
29918
30164
|
if (!connections.find((c) => c.name === name)) {
|
|
29919
|
-
console.error(
|
|
30165
|
+
console.error(chalk212.red(`Connection "${name}" not found.`));
|
|
29920
30166
|
process.exit(1);
|
|
29921
30167
|
}
|
|
29922
30168
|
setDefault(name);
|
|
@@ -29965,7 +30211,7 @@ function registerSignal(program2) {
|
|
|
29965
30211
|
}
|
|
29966
30212
|
|
|
29967
30213
|
// src/commands/sql/sqlAuth.ts
|
|
29968
|
-
import
|
|
30214
|
+
import chalk214 from "chalk";
|
|
29969
30215
|
|
|
29970
30216
|
// src/commands/sql/loadConnections.ts
|
|
29971
30217
|
function loadConnections3() {
|
|
@@ -29994,7 +30240,7 @@ function setDefaultConnection2(name) {
|
|
|
29994
30240
|
}
|
|
29995
30241
|
|
|
29996
30242
|
// src/commands/sql/promptConnection.ts
|
|
29997
|
-
import
|
|
30243
|
+
import chalk213 from "chalk";
|
|
29998
30244
|
async function promptConnection3(existingNames) {
|
|
29999
30245
|
const name = await promptInput("name", "Connection name:", "default");
|
|
30000
30246
|
assertUniqueName(existingNames, name);
|
|
@@ -30002,7 +30248,7 @@ async function promptConnection3(existingNames) {
|
|
|
30002
30248
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
30003
30249
|
const port = Number.parseInt(portStr, 10);
|
|
30004
30250
|
if (!Number.isFinite(port)) {
|
|
30005
|
-
console.error(
|
|
30251
|
+
console.error(chalk213.red(`Invalid port "${portStr}".`));
|
|
30006
30252
|
process.exit(1);
|
|
30007
30253
|
}
|
|
30008
30254
|
const user = await promptInput("user", "User:");
|
|
@@ -30015,13 +30261,13 @@ async function promptConnection3(existingNames) {
|
|
|
30015
30261
|
var sqlAuth = createConnectionAuth({
|
|
30016
30262
|
load: loadConnections3,
|
|
30017
30263
|
save: saveConnections3,
|
|
30018
|
-
format: (c) => `${
|
|
30264
|
+
format: (c) => `${chalk214.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
30019
30265
|
promptNew: promptConnection3,
|
|
30020
30266
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
30021
30267
|
});
|
|
30022
30268
|
|
|
30023
30269
|
// src/commands/sql/printTable.ts
|
|
30024
|
-
import
|
|
30270
|
+
import chalk215 from "chalk";
|
|
30025
30271
|
function formatCell(value) {
|
|
30026
30272
|
if (value === null || value === void 0) return "";
|
|
30027
30273
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -30030,7 +30276,7 @@ function formatCell(value) {
|
|
|
30030
30276
|
}
|
|
30031
30277
|
function printTable(rows) {
|
|
30032
30278
|
if (rows.length === 0) {
|
|
30033
|
-
console.log(
|
|
30279
|
+
console.log(chalk215.yellow("(no rows)"));
|
|
30034
30280
|
return;
|
|
30035
30281
|
}
|
|
30036
30282
|
const columns = Object.keys(rows[0]);
|
|
@@ -30038,13 +30284,13 @@ function printTable(rows) {
|
|
|
30038
30284
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
30039
30285
|
);
|
|
30040
30286
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
30041
|
-
console.log(
|
|
30042
|
-
console.log(
|
|
30287
|
+
console.log(chalk215.dim(header));
|
|
30288
|
+
console.log(chalk215.dim("-".repeat(header.length)));
|
|
30043
30289
|
for (const row of rows) {
|
|
30044
30290
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
30045
30291
|
console.log(line);
|
|
30046
30292
|
}
|
|
30047
|
-
console.log(
|
|
30293
|
+
console.log(chalk215.dim(`
|
|
30048
30294
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
30049
30295
|
}
|
|
30050
30296
|
|
|
@@ -30104,7 +30350,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
30104
30350
|
}
|
|
30105
30351
|
|
|
30106
30352
|
// src/commands/sql/sqlMutate.ts
|
|
30107
|
-
import
|
|
30353
|
+
import chalk216 from "chalk";
|
|
30108
30354
|
|
|
30109
30355
|
// src/commands/sql/isMutation.ts
|
|
30110
30356
|
var MUTATION_KEYWORDS = [
|
|
@@ -30138,7 +30384,7 @@ function isMutation(sql25) {
|
|
|
30138
30384
|
async function sqlMutate(query, connectionName) {
|
|
30139
30385
|
if (!isMutation(query)) {
|
|
30140
30386
|
console.error(
|
|
30141
|
-
|
|
30387
|
+
chalk216.red(
|
|
30142
30388
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
30143
30389
|
)
|
|
30144
30390
|
);
|
|
@@ -30148,18 +30394,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
30148
30394
|
const pool = await sqlConnect(conn);
|
|
30149
30395
|
try {
|
|
30150
30396
|
const result = await pool.request().query(query);
|
|
30151
|
-
console.log(
|
|
30397
|
+
console.log(chalk216.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
30152
30398
|
} finally {
|
|
30153
30399
|
await pool.close();
|
|
30154
30400
|
}
|
|
30155
30401
|
}
|
|
30156
30402
|
|
|
30157
30403
|
// src/commands/sql/sqlQuery.ts
|
|
30158
|
-
import
|
|
30404
|
+
import chalk217 from "chalk";
|
|
30159
30405
|
async function sqlQuery(query, connectionName) {
|
|
30160
30406
|
if (isMutation(query)) {
|
|
30161
30407
|
console.error(
|
|
30162
|
-
|
|
30408
|
+
chalk217.red(
|
|
30163
30409
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
30164
30410
|
)
|
|
30165
30411
|
);
|
|
@@ -30174,7 +30420,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
30174
30420
|
printTable(rows);
|
|
30175
30421
|
} else {
|
|
30176
30422
|
console.log(
|
|
30177
|
-
|
|
30423
|
+
chalk217.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
30178
30424
|
);
|
|
30179
30425
|
}
|
|
30180
30426
|
} finally {
|
|
@@ -30319,7 +30565,7 @@ function reportPrune(label2, result, force) {
|
|
|
30319
30565
|
// src/commands/sync/syncClaudeMd.ts
|
|
30320
30566
|
import * as fs41 from "fs";
|
|
30321
30567
|
import * as path66 from "path";
|
|
30322
|
-
import
|
|
30568
|
+
import chalk218 from "chalk";
|
|
30323
30569
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
30324
30570
|
const source = path66.join(claudeDir, "CLAUDE.md");
|
|
30325
30571
|
const target = path66.join(targetBase, "CLAUDE.md");
|
|
@@ -30328,14 +30574,14 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
30328
30574
|
const targetContent = fs41.readFileSync(target, "utf8");
|
|
30329
30575
|
if (sourceContent !== targetContent) {
|
|
30330
30576
|
console.log(
|
|
30331
|
-
|
|
30577
|
+
chalk218.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
30332
30578
|
);
|
|
30333
30579
|
console.log();
|
|
30334
30580
|
printDiff(targetContent, sourceContent);
|
|
30335
30581
|
if (!options2?.yes) {
|
|
30336
30582
|
printAutoConfirmHint();
|
|
30337
30583
|
const confirm = await promptConfirm(
|
|
30338
|
-
|
|
30584
|
+
chalk218.red("Overwrite existing CLAUDE.md?"),
|
|
30339
30585
|
false
|
|
30340
30586
|
);
|
|
30341
30587
|
if (!confirm) {
|
|
@@ -30568,7 +30814,7 @@ function syncPi(claudeDir, options2) {
|
|
|
30568
30814
|
// src/commands/sync/syncSettings.ts
|
|
30569
30815
|
import * as fs47 from "fs";
|
|
30570
30816
|
import * as path73 from "path";
|
|
30571
|
-
import
|
|
30817
|
+
import chalk219 from "chalk";
|
|
30572
30818
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
30573
30819
|
const source = path73.join(claudeDir, "settings.json");
|
|
30574
30820
|
const target = path73.join(targetBase, "settings.json");
|
|
@@ -30587,7 +30833,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
30587
30833
|
if (mergedContent !== normalizedTarget) {
|
|
30588
30834
|
if (!options2?.yes) {
|
|
30589
30835
|
console.log(
|
|
30590
|
-
|
|
30836
|
+
chalk219.yellow(
|
|
30591
30837
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
30592
30838
|
)
|
|
30593
30839
|
);
|
|
@@ -30595,7 +30841,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
30595
30841
|
printDiff(targetContent, mergedContent);
|
|
30596
30842
|
printAutoConfirmHint();
|
|
30597
30843
|
const confirm = await promptConfirm(
|
|
30598
|
-
|
|
30844
|
+
chalk219.red("Overwrite existing settings.json?"),
|
|
30599
30845
|
false
|
|
30600
30846
|
);
|
|
30601
30847
|
if (!confirm) {
|
|
@@ -30675,9 +30921,9 @@ function createReadlineInterface() {
|
|
|
30675
30921
|
});
|
|
30676
30922
|
}
|
|
30677
30923
|
function askQuestion(rl, question) {
|
|
30678
|
-
return new Promise((
|
|
30924
|
+
return new Promise((resolve25) => {
|
|
30679
30925
|
rl.question(question, (answer) => {
|
|
30680
|
-
|
|
30926
|
+
resolve25(answer.trim());
|
|
30681
30927
|
});
|
|
30682
30928
|
});
|
|
30683
30929
|
}
|
|
@@ -31725,7 +31971,7 @@ function resolveParams(params, cliArgs) {
|
|
|
31725
31971
|
|
|
31726
31972
|
// src/commands/run/resolveRunCwd.ts
|
|
31727
31973
|
import { existsSync as existsSync69 } from "fs";
|
|
31728
|
-
import { resolve as
|
|
31974
|
+
import { resolve as resolve19 } from "path";
|
|
31729
31975
|
var MissingRunCwdError = class extends Error {
|
|
31730
31976
|
constructor(runName, cwd) {
|
|
31731
31977
|
super(`run config "${runName}": cwd ${cwd} does not exist`);
|
|
@@ -31736,7 +31982,7 @@ var MissingRunCwdError = class extends Error {
|
|
|
31736
31982
|
};
|
|
31737
31983
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
31738
31984
|
if (!config.cwd) return void 0;
|
|
31739
|
-
const cwd =
|
|
31985
|
+
const cwd = resolve19(baseDir, config.cwd);
|
|
31740
31986
|
if (!existsSync69(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
31741
31987
|
return cwd;
|
|
31742
31988
|
}
|
|
@@ -31748,12 +31994,12 @@ import { existsSync as existsSync71 } from "fs";
|
|
|
31748
31994
|
// src/commands/run/resolveCommand.ts
|
|
31749
31995
|
import { execFileSync as execFileSync16 } from "child_process";
|
|
31750
31996
|
import { existsSync as existsSync70 } from "fs";
|
|
31751
|
-
import { dirname as dirname36, join as join85, resolve as
|
|
31997
|
+
import { dirname as dirname36, join as join85, resolve as resolve20 } from "path";
|
|
31752
31998
|
function resolveCommand2(command) {
|
|
31753
31999
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
31754
32000
|
try {
|
|
31755
32001
|
const gitPath = execFileSync16("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
31756
|
-
const gitRoot =
|
|
32002
|
+
const gitRoot = resolve20(dirname36(gitPath), "..");
|
|
31757
32003
|
const gitBash = join85(gitRoot, "bin", "bash.exe");
|
|
31758
32004
|
if (existsSync70(gitBash)) return gitBash;
|
|
31759
32005
|
} catch {
|
|
@@ -31909,7 +32155,7 @@ function readMovement(cwd) {
|
|
|
31909
32155
|
// src/commands/watch/pollForMovement.ts
|
|
31910
32156
|
function pollForMovement(options2) {
|
|
31911
32157
|
const { upstream, intervalMs, timeoutMs, timeout, cwd } = options2;
|
|
31912
|
-
return new Promise((
|
|
32158
|
+
return new Promise((resolve25) => {
|
|
31913
32159
|
let settled = false;
|
|
31914
32160
|
const finish = (outcome) => {
|
|
31915
32161
|
if (settled) return;
|
|
@@ -31917,7 +32163,7 @@ function pollForMovement(options2) {
|
|
|
31917
32163
|
clearInterval(ticker);
|
|
31918
32164
|
clearTimeout(deadline);
|
|
31919
32165
|
process.off("SIGINT", onInterrupt);
|
|
31920
|
-
|
|
32166
|
+
resolve25(outcome);
|
|
31921
32167
|
};
|
|
31922
32168
|
const onInterrupt = () => finish({ kind: "interrupted" });
|
|
31923
32169
|
const ticker = setInterval(() => {
|
|
@@ -32022,7 +32268,7 @@ function registerWatch(program2) {
|
|
|
32022
32268
|
|
|
32023
32269
|
// src/commands/roam/auth.ts
|
|
32024
32270
|
import { randomBytes } from "crypto";
|
|
32025
|
-
import
|
|
32271
|
+
import chalk220 from "chalk";
|
|
32026
32272
|
|
|
32027
32273
|
// src/commands/roam/waitForCallback.ts
|
|
32028
32274
|
import { createServer as createServer3 } from "http";
|
|
@@ -32043,7 +32289,7 @@ function extractCode(url, expectedState) {
|
|
|
32043
32289
|
return code;
|
|
32044
32290
|
}
|
|
32045
32291
|
function waitForCallback(port, expectedState) {
|
|
32046
|
-
return new Promise((
|
|
32292
|
+
return new Promise((resolve25, reject) => {
|
|
32047
32293
|
const timeout = setTimeout(() => {
|
|
32048
32294
|
server.close();
|
|
32049
32295
|
reject(new Error("Authorization timed out after 120 seconds"));
|
|
@@ -32060,7 +32306,7 @@ function waitForCallback(port, expectedState) {
|
|
|
32060
32306
|
const code = extractCode(url, expectedState);
|
|
32061
32307
|
respondHtml(res, 200, "Authorization successful!");
|
|
32062
32308
|
server.close();
|
|
32063
|
-
|
|
32309
|
+
resolve25(code);
|
|
32064
32310
|
} catch (error) {
|
|
32065
32311
|
respondHtml(res, 400, error.message);
|
|
32066
32312
|
server.close();
|
|
@@ -32153,13 +32399,13 @@ async function auth() {
|
|
|
32153
32399
|
saveGlobalConfig(config);
|
|
32154
32400
|
const state = randomBytes(16).toString("hex");
|
|
32155
32401
|
console.log(
|
|
32156
|
-
|
|
32402
|
+
chalk220.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
32157
32403
|
);
|
|
32158
|
-
console.log(
|
|
32159
|
-
console.log(
|
|
32160
|
-
console.log(
|
|
32404
|
+
console.log(chalk220.white("http://localhost:14523/callback\n"));
|
|
32405
|
+
console.log(chalk220.blue("Opening browser for authorization..."));
|
|
32406
|
+
console.log(chalk220.dim("Waiting for authorization callback..."));
|
|
32161
32407
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
32162
|
-
console.log(
|
|
32408
|
+
console.log(chalk220.dim("Exchanging code for tokens..."));
|
|
32163
32409
|
const tokens = await exchangeToken({
|
|
32164
32410
|
code,
|
|
32165
32411
|
clientId,
|
|
@@ -32175,7 +32421,7 @@ async function auth() {
|
|
|
32175
32421
|
};
|
|
32176
32422
|
saveGlobalConfig(config);
|
|
32177
32423
|
console.log(
|
|
32178
|
-
|
|
32424
|
+
chalk220.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
32179
32425
|
);
|
|
32180
32426
|
}
|
|
32181
32427
|
|
|
@@ -32525,8 +32771,8 @@ function registerRun(program2) {
|
|
|
32525
32771
|
import { execSync as execSync60 } from "child_process";
|
|
32526
32772
|
import { existsSync as existsSync73, mkdirSync as mkdirSync32, unlinkSync as unlinkSync22, writeFileSync as writeFileSync47 } from "fs";
|
|
32527
32773
|
import { tmpdir as tmpdir8 } from "os";
|
|
32528
|
-
import { join as join89, resolve as
|
|
32529
|
-
import
|
|
32774
|
+
import { join as join89, resolve as resolve21 } from "path";
|
|
32775
|
+
import chalk221 from "chalk";
|
|
32530
32776
|
|
|
32531
32777
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
32532
32778
|
var captureWindowPs1 = `
|
|
@@ -32659,7 +32905,7 @@ function buildOutputPath(outputDir, processName) {
|
|
|
32659
32905
|
mkdirSync32(outputDir, { recursive: true });
|
|
32660
32906
|
}
|
|
32661
32907
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
32662
|
-
return
|
|
32908
|
+
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
32663
32909
|
}
|
|
32664
32910
|
function runPowerShellScript(processName, outputPath) {
|
|
32665
32911
|
const scriptPath = join89(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
|
|
@@ -32675,15 +32921,15 @@ function runPowerShellScript(processName, outputPath) {
|
|
|
32675
32921
|
}
|
|
32676
32922
|
function screenshot(processName) {
|
|
32677
32923
|
const config = loadConfig();
|
|
32678
|
-
const outputDir =
|
|
32924
|
+
const outputDir = resolve21(config.screenshot.outputDir);
|
|
32679
32925
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
32680
|
-
console.log(
|
|
32926
|
+
console.log(chalk221.gray(`Capturing window for process "${processName}" ...`));
|
|
32681
32927
|
try {
|
|
32682
32928
|
runPowerShellScript(processName, outputPath);
|
|
32683
|
-
console.log(
|
|
32929
|
+
console.log(chalk221.green(`Screenshot saved: ${outputPath}`));
|
|
32684
32930
|
} catch (error) {
|
|
32685
32931
|
const msg = error instanceof Error ? error.message : String(error);
|
|
32686
|
-
console.error(
|
|
32932
|
+
console.error(chalk221.red(`Failed to capture screenshot: ${msg}`));
|
|
32687
32933
|
process.exit(1);
|
|
32688
32934
|
}
|
|
32689
32935
|
}
|
|
@@ -32708,10 +32954,10 @@ var STATUS_TIMEOUT_MS = 5e3;
|
|
|
32708
32954
|
function queryDaemon(socket) {
|
|
32709
32955
|
socket.write(`${JSON.stringify({ type: "ping" })}
|
|
32710
32956
|
`);
|
|
32711
|
-
return new Promise((
|
|
32957
|
+
return new Promise((resolve25) => {
|
|
32712
32958
|
const result = { sessions: [] };
|
|
32713
32959
|
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
32714
|
-
const timer = setTimeout(() =>
|
|
32960
|
+
const timer = setTimeout(() => resolve25(result), STATUS_TIMEOUT_MS);
|
|
32715
32961
|
const lines2 = createInterface6({ input: socket });
|
|
32716
32962
|
lines2.on("error", () => {
|
|
32717
32963
|
});
|
|
@@ -32719,7 +32965,7 @@ function queryDaemon(socket) {
|
|
|
32719
32965
|
applyLine(result, pending, line);
|
|
32720
32966
|
if (pending.size === 0) {
|
|
32721
32967
|
clearTimeout(timer);
|
|
32722
|
-
|
|
32968
|
+
resolve25(result);
|
|
32723
32969
|
}
|
|
32724
32970
|
});
|
|
32725
32971
|
});
|
|
@@ -32815,11 +33061,11 @@ function clearPersistedSessionsOnDrain() {
|
|
|
32815
33061
|
|
|
32816
33062
|
// src/commands/sessions/daemon/readDaemonMessage.ts
|
|
32817
33063
|
function readDaemonMessage(lines2, timeoutMs, fallback, match) {
|
|
32818
|
-
return new Promise((
|
|
33064
|
+
return new Promise((resolve25) => {
|
|
32819
33065
|
const finish = (value) => {
|
|
32820
33066
|
clearTimeout(timer);
|
|
32821
33067
|
lines2.off("line", onLine);
|
|
32822
|
-
|
|
33068
|
+
resolve25(value);
|
|
32823
33069
|
};
|
|
32824
33070
|
const timer = setTimeout(() => finish(fallback), timeoutMs);
|
|
32825
33071
|
const onLine = (line) => {
|
|
@@ -34171,7 +34417,7 @@ function emitSessionOutput(session, clients, data) {
|
|
|
34171
34417
|
|
|
34172
34418
|
// src/commands/sessions/daemon/exitReason.ts
|
|
34173
34419
|
import { existsSync as existsSync80 } from "fs";
|
|
34174
|
-
import { resolve as
|
|
34420
|
+
import { resolve as resolve22 } from "path";
|
|
34175
34421
|
function exitDetail(session) {
|
|
34176
34422
|
if (session.cwd && !existsSync80(session.cwd))
|
|
34177
34423
|
return `working directory ${session.cwd} no longer exists`;
|
|
@@ -34186,7 +34432,7 @@ function missingRunConfigCwd(session) {
|
|
|
34186
34432
|
const dir = session.cwd ?? process.cwd();
|
|
34187
34433
|
const config = resolveRunConfig(session.runName, dir);
|
|
34188
34434
|
if (!config?.cwd) return void 0;
|
|
34189
|
-
const configured =
|
|
34435
|
+
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
34190
34436
|
if (existsSync80(configured)) return void 0;
|
|
34191
34437
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
34192
34438
|
}
|
|
@@ -36657,7 +36903,7 @@ function windowsDaemonHost() {
|
|
|
36657
36903
|
var CONNECT_TIMEOUT_MS = 2e3;
|
|
36658
36904
|
var KEEPALIVE_PROBE_MS = 1e4;
|
|
36659
36905
|
function connectToWindowsDaemon() {
|
|
36660
|
-
return new Promise((
|
|
36906
|
+
return new Promise((resolve25, reject) => {
|
|
36661
36907
|
const socket = net2.connect(windowsDaemonPort(), windowsDaemonHost());
|
|
36662
36908
|
socket.setTimeout(CONNECT_TIMEOUT_MS);
|
|
36663
36909
|
socket.once("timeout", () => {
|
|
@@ -36667,7 +36913,7 @@ function connectToWindowsDaemon() {
|
|
|
36667
36913
|
socket.once("connect", () => {
|
|
36668
36914
|
socket.setTimeout(0);
|
|
36669
36915
|
socket.setKeepAlive(true, KEEPALIVE_PROBE_MS);
|
|
36670
|
-
|
|
36916
|
+
resolve25(socket);
|
|
36671
36917
|
});
|
|
36672
36918
|
socket.once("error", reject);
|
|
36673
36919
|
});
|
|
@@ -36766,7 +37012,7 @@ async function waitForWindowsDaemon(launch) {
|
|
|
36766
37012
|
);
|
|
36767
37013
|
}
|
|
36768
37014
|
function delay2(ms) {
|
|
36769
|
-
return new Promise((
|
|
37015
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
36770
37016
|
}
|
|
36771
37017
|
|
|
36772
37018
|
// src/commands/sessions/daemon/defaultConnect.ts
|
|
@@ -37078,7 +37324,7 @@ async function healWindowsDaemon() {
|
|
|
37078
37324
|
daemonLog("windows daemon: auto-heal: stale daemon stopped");
|
|
37079
37325
|
}
|
|
37080
37326
|
function runOnWindowsHost(command, timeoutMs) {
|
|
37081
|
-
return new Promise((
|
|
37327
|
+
return new Promise((resolve25, reject) => {
|
|
37082
37328
|
const child = spawn12("pwsh.exe", ["-Command", command], {
|
|
37083
37329
|
stdio: ["ignore", "pipe", "pipe"]
|
|
37084
37330
|
});
|
|
@@ -37098,7 +37344,7 @@ function runOnWindowsHost(command, timeoutMs) {
|
|
|
37098
37344
|
});
|
|
37099
37345
|
child.on("exit", (code) => {
|
|
37100
37346
|
clearTimeout(timer);
|
|
37101
|
-
if (code === 0)
|
|
37347
|
+
if (code === 0) resolve25();
|
|
37102
37348
|
else
|
|
37103
37349
|
reject(
|
|
37104
37350
|
new Error(
|
|
@@ -38324,7 +38570,7 @@ function describePortHolder(port) {
|
|
|
38324
38570
|
return holder !== void 0 && holder !== process.pid ? `PID ${holder} is listening on it \u2014 kill PID ${holder} to free the port` : "the port is held by another process or reserved by a Hyper-V/WSL dynamic port range \u2014 set sessions.windowsDaemonPort to a free port outside 49152-65535";
|
|
38325
38571
|
}
|
|
38326
38572
|
function bindBridge(manager, port) {
|
|
38327
|
-
return new Promise((
|
|
38573
|
+
return new Promise((resolve25) => {
|
|
38328
38574
|
const bridge = net3.createServer((socket) => {
|
|
38329
38575
|
socket.setKeepAlive(true, KEEPALIVE_PROBE_MS2);
|
|
38330
38576
|
handleConnection(socket, manager);
|
|
@@ -38332,7 +38578,7 @@ function bindBridge(manager, port) {
|
|
|
38332
38578
|
bridge.once("error", (error) => {
|
|
38333
38579
|
bridge.close(() => {
|
|
38334
38580
|
});
|
|
38335
|
-
|
|
38581
|
+
resolve25(error);
|
|
38336
38582
|
});
|
|
38337
38583
|
bridge.listen(port, () => {
|
|
38338
38584
|
bridge.removeAllListeners("error");
|
|
@@ -38342,12 +38588,12 @@ function bindBridge(manager, port) {
|
|
|
38342
38588
|
);
|
|
38343
38589
|
exitAfterFlush(1);
|
|
38344
38590
|
});
|
|
38345
|
-
|
|
38591
|
+
resolve25(null);
|
|
38346
38592
|
});
|
|
38347
38593
|
});
|
|
38348
38594
|
}
|
|
38349
38595
|
function delay3(ms) {
|
|
38350
|
-
return new Promise((
|
|
38596
|
+
return new Promise((resolve25) => setTimeout(resolve25, ms));
|
|
38351
38597
|
}
|
|
38352
38598
|
|
|
38353
38599
|
// src/commands/sessions/daemon/describeWedgedHolder.ts
|
|
@@ -38462,7 +38708,7 @@ function registerSetStatusCommand(cmd) {
|
|
|
38462
38708
|
|
|
38463
38709
|
// src/commands/sessions/summarise/index.ts
|
|
38464
38710
|
import * as fs56 from "fs";
|
|
38465
|
-
import
|
|
38711
|
+
import chalk222 from "chalk";
|
|
38466
38712
|
|
|
38467
38713
|
// src/commands/sessions/summarise/shared.ts
|
|
38468
38714
|
import * as fs55 from "fs";
|
|
@@ -38521,22 +38767,22 @@ ${firstMessage}`);
|
|
|
38521
38767
|
async function summarise2(options2) {
|
|
38522
38768
|
const files = await discoverSessionFiles();
|
|
38523
38769
|
if (files.length === 0) {
|
|
38524
|
-
console.log(
|
|
38770
|
+
console.log(chalk222.yellow("No sessions found."));
|
|
38525
38771
|
return;
|
|
38526
38772
|
}
|
|
38527
38773
|
const toProcess = selectCandidates(files, options2);
|
|
38528
38774
|
if (toProcess.length === 0) {
|
|
38529
|
-
console.log(
|
|
38775
|
+
console.log(chalk222.green("All sessions already summarised."));
|
|
38530
38776
|
return;
|
|
38531
38777
|
}
|
|
38532
38778
|
console.log(
|
|
38533
|
-
|
|
38779
|
+
chalk222.cyan(
|
|
38534
38780
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
38535
38781
|
)
|
|
38536
38782
|
);
|
|
38537
38783
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
38538
38784
|
console.log(
|
|
38539
|
-
|
|
38785
|
+
chalk222.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk222.yellow(`, ${failed2} skipped`) : "")
|
|
38540
38786
|
);
|
|
38541
38787
|
}
|
|
38542
38788
|
function selectCandidates(files, options2) {
|
|
@@ -38556,16 +38802,16 @@ function processSessions(files) {
|
|
|
38556
38802
|
let failed2 = 0;
|
|
38557
38803
|
for (let i = 0; i < files.length; i++) {
|
|
38558
38804
|
const file = files[i];
|
|
38559
|
-
process.stdout.write(
|
|
38805
|
+
process.stdout.write(chalk222.dim(` [${i + 1}/${files.length}] `));
|
|
38560
38806
|
const summary = summariseSession(file);
|
|
38561
38807
|
if (summary) {
|
|
38562
38808
|
writeSummary(file, summary);
|
|
38563
38809
|
succeeded++;
|
|
38564
|
-
process.stdout.write(`${
|
|
38810
|
+
process.stdout.write(`${chalk222.green("\u2713")} ${summary}
|
|
38565
38811
|
`);
|
|
38566
38812
|
} else {
|
|
38567
38813
|
failed2++;
|
|
38568
|
-
process.stdout.write(` ${
|
|
38814
|
+
process.stdout.write(` ${chalk222.yellow("skip")}
|
|
38569
38815
|
`);
|
|
38570
38816
|
}
|
|
38571
38817
|
}
|
|
@@ -38586,7 +38832,7 @@ function registerSessions(program2) {
|
|
|
38586
38832
|
}
|
|
38587
38833
|
|
|
38588
38834
|
// src/commands/statusLine.ts
|
|
38589
|
-
import
|
|
38835
|
+
import chalk224 from "chalk";
|
|
38590
38836
|
|
|
38591
38837
|
// src/shared/contextLevel.ts
|
|
38592
38838
|
function contextLevel(pct) {
|
|
@@ -38596,7 +38842,7 @@ function contextLevel(pct) {
|
|
|
38596
38842
|
}
|
|
38597
38843
|
|
|
38598
38844
|
// src/commands/buildLimitsSegment.ts
|
|
38599
|
-
import
|
|
38845
|
+
import chalk223 from "chalk";
|
|
38600
38846
|
|
|
38601
38847
|
// src/shared/rateLimitLevel.ts
|
|
38602
38848
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -38634,9 +38880,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
38634
38880
|
|
|
38635
38881
|
// src/commands/buildLimitsSegment.ts
|
|
38636
38882
|
var LEVEL_COLOR = {
|
|
38637
|
-
ok:
|
|
38638
|
-
warn:
|
|
38639
|
-
over:
|
|
38883
|
+
ok: chalk223.green,
|
|
38884
|
+
warn: chalk223.yellow,
|
|
38885
|
+
over: chalk223.red
|
|
38640
38886
|
};
|
|
38641
38887
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
38642
38888
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -38668,7 +38914,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
38668
38914
|
|
|
38669
38915
|
// src/commands/readGitBranch.ts
|
|
38670
38916
|
import { readFileSync as readFileSync61, statSync as statSync15 } from "fs";
|
|
38671
|
-
import { isAbsolute as
|
|
38917
|
+
import { isAbsolute as isAbsolute5, join as join95, resolve as resolve23 } from "path";
|
|
38672
38918
|
function resolveGitDir(cwd) {
|
|
38673
38919
|
const dotGit = join95(cwd, ".git");
|
|
38674
38920
|
let stat4;
|
|
@@ -38691,7 +38937,7 @@ function resolveGitDir(cwd) {
|
|
|
38691
38937
|
return null;
|
|
38692
38938
|
}
|
|
38693
38939
|
const gitDir = match[1].trim();
|
|
38694
|
-
return
|
|
38940
|
+
return isAbsolute5(gitDir) ? gitDir : resolve23(cwd, gitDir);
|
|
38695
38941
|
}
|
|
38696
38942
|
function readGitBranch(cwd) {
|
|
38697
38943
|
const gitDir = resolveGitDir(cwd);
|
|
@@ -38732,7 +38978,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
38732
38978
|
}
|
|
38733
38979
|
|
|
38734
38980
|
// src/commands/statusLine.ts
|
|
38735
|
-
|
|
38981
|
+
chalk224.level = 3;
|
|
38736
38982
|
function formatNumber(num) {
|
|
38737
38983
|
return num.toLocaleString("en-US");
|
|
38738
38984
|
}
|
|
@@ -38740,9 +38986,9 @@ function colorizePercent(pct) {
|
|
|
38740
38986
|
const label2 = `${Math.round(pct)}%`;
|
|
38741
38987
|
switch (contextLevel(pct)) {
|
|
38742
38988
|
case "red":
|
|
38743
|
-
return
|
|
38989
|
+
return chalk224.red(label2);
|
|
38744
38990
|
case "yellow":
|
|
38745
|
-
return
|
|
38991
|
+
return chalk224.yellow(label2);
|
|
38746
38992
|
default:
|
|
38747
38993
|
return label2;
|
|
38748
38994
|
}
|
|
@@ -38755,7 +39001,7 @@ async function statusLine() {
|
|
|
38755
39001
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
38756
39002
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
38757
39003
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
38758
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
39004
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk224.cyan(branch2)} | ` : "";
|
|
38759
39005
|
console.log(
|
|
38760
39006
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
38761
39007
|
);
|
|
@@ -38825,10 +39071,10 @@ async function update2() {
|
|
|
38825
39071
|
}
|
|
38826
39072
|
|
|
38827
39073
|
// src/reportCliError.ts
|
|
38828
|
-
import
|
|
39074
|
+
import chalk225 from "chalk";
|
|
38829
39075
|
function reportCliError(error) {
|
|
38830
39076
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
38831
|
-
console.error(
|
|
39077
|
+
console.error(chalk225.red(error.message));
|
|
38832
39078
|
} else {
|
|
38833
39079
|
console.error(error);
|
|
38834
39080
|
}
|