@staff0rd/assist 0.580.0 → 0.582.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 +393 -389
- package/dist/index.js +484 -390
- 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.582.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3847,9 +3847,9 @@ function extractCsharpComments(content) {
|
|
|
3847
3847
|
|
|
3848
3848
|
// src/commands/verify/blockCodeComments/collectCsharpComments.ts
|
|
3849
3849
|
function collectCsharpComments(content) {
|
|
3850
|
-
const
|
|
3850
|
+
const headerLines2 = csharpHeaderLineCount(content);
|
|
3851
3851
|
return extractCsharpComments(content).filter(
|
|
3852
|
-
(comment3) => comment3.line >
|
|
3852
|
+
(comment3) => comment3.line > headerLines2
|
|
3853
3853
|
);
|
|
3854
3854
|
}
|
|
3855
3855
|
|
|
@@ -11939,7 +11939,7 @@ import { execFile as execFile5 } from "child_process";
|
|
|
11939
11939
|
import { promisify as promisify5 } from "util";
|
|
11940
11940
|
var execFileAsync4 = promisify5(execFile5);
|
|
11941
11941
|
var CACHE_TTL_MS4 = 3e4;
|
|
11942
|
-
function createCachedGhJson(args,
|
|
11942
|
+
function createCachedGhJson(args, parse4, fallback, options2 = {}) {
|
|
11943
11943
|
const { cacheFallback = true } = options2;
|
|
11944
11944
|
const cache5 = /* @__PURE__ */ new Map();
|
|
11945
11945
|
return async (cwd, extraArgs = []) => {
|
|
@@ -11954,7 +11954,7 @@ function createCachedGhJson(args, parse3, fallback, options2 = {}) {
|
|
|
11954
11954
|
windowsHide: true,
|
|
11955
11955
|
cwd: toGitCwd(cwd)
|
|
11956
11956
|
});
|
|
11957
|
-
value =
|
|
11957
|
+
value = parse4(stdout);
|
|
11958
11958
|
} catch {
|
|
11959
11959
|
value = fallback;
|
|
11960
11960
|
}
|
|
@@ -22918,7 +22918,8 @@ function registerMermaid(program2) {
|
|
|
22918
22918
|
}
|
|
22919
22919
|
|
|
22920
22920
|
// src/commands/miro/runExtract.ts
|
|
22921
|
-
import
|
|
22921
|
+
import chalk171 from "chalk";
|
|
22922
|
+
import { stringify as stringify2 } from "yaml";
|
|
22922
22923
|
|
|
22923
22924
|
// src/commands/miro/MiroExtractError.ts
|
|
22924
22925
|
var MiroExtractError = class extends Error {
|
|
@@ -22928,6 +22929,52 @@ var MiroExtractError = class extends Error {
|
|
|
22928
22929
|
}
|
|
22929
22930
|
};
|
|
22930
22931
|
|
|
22932
|
+
// src/commands/miro/parseAnchorId.ts
|
|
22933
|
+
function parseAnchorId(value) {
|
|
22934
|
+
const trimmed = value.trim();
|
|
22935
|
+
const link3 = /[?&]moveToWidget=([^&#]+)/.exec(trimmed);
|
|
22936
|
+
return link3 ? decodeURIComponent(link3[1]).trim() : trimmed;
|
|
22937
|
+
}
|
|
22938
|
+
|
|
22939
|
+
// src/commands/miro/anchorSource.ts
|
|
22940
|
+
function anchorSource(options2) {
|
|
22941
|
+
if (options2.topLeft && options2.bottomRight)
|
|
22942
|
+
return {
|
|
22943
|
+
pick: false,
|
|
22944
|
+
topLeft: parseAnchorId(options2.topLeft),
|
|
22945
|
+
bottomRight: parseAnchorId(options2.bottomRight)
|
|
22946
|
+
};
|
|
22947
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
22948
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId)
|
|
22949
|
+
throw new MiroExtractError(
|
|
22950
|
+
"Both --top-left <id|link> and --bottom-right <id|link> are required: there is no assist session to host the picker pane."
|
|
22951
|
+
);
|
|
22952
|
+
return { pick: true, sessionId };
|
|
22953
|
+
}
|
|
22954
|
+
|
|
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
|
+
// src/commands/miro/miroSource.ts
|
|
22966
|
+
function boardId(url) {
|
|
22967
|
+
return url ? /\/board\/([^/?]+)/.exec(url)?.[1] : void 0;
|
|
22968
|
+
}
|
|
22969
|
+
function miroSource(items2, anchorId) {
|
|
22970
|
+
const anchor = items2.find((item) => item.id === anchorId);
|
|
22971
|
+
const ordered = anchor ? [anchor, ...items2] : items2;
|
|
22972
|
+
return {
|
|
22973
|
+
board: boardId(ordered.find((item) => item.miro_url)?.miro_url),
|
|
22974
|
+
frame: ordered.find((item) => item.parent?.id)?.parent?.id
|
|
22975
|
+
};
|
|
22976
|
+
}
|
|
22977
|
+
|
|
22931
22978
|
// src/commands/miro/stripHtml.ts
|
|
22932
22979
|
var namedEntities = {
|
|
22933
22980
|
amp: "&",
|
|
@@ -22986,13 +23033,6 @@ function normaliseItems(items2) {
|
|
|
22986
23033
|
return items2.map(toItem);
|
|
22987
23034
|
}
|
|
22988
23035
|
|
|
22989
|
-
// src/commands/miro/parseAnchorId.ts
|
|
22990
|
-
function parseAnchorId(value) {
|
|
22991
|
-
const trimmed = value.trim();
|
|
22992
|
-
const link3 = /[?&]moveToWidget=([^&#]+)/.exec(trimmed);
|
|
22993
|
-
return link3 ? decodeURIComponent(link3[1]).trim() : trimmed;
|
|
22994
|
-
}
|
|
22995
|
-
|
|
22996
23036
|
// src/commands/miro/pickAnchors.ts
|
|
22997
23037
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
22998
23038
|
|
|
@@ -23032,8 +23072,25 @@ async function pickAnchors(sessionId, items2) {
|
|
|
23032
23072
|
return [selection.topLeft, selection.bottomRight];
|
|
23033
23073
|
}
|
|
23034
23074
|
|
|
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
|
+
|
|
23035
23092
|
// src/commands/miro/readMiroItems.ts
|
|
23036
|
-
import { readFileSync as
|
|
23093
|
+
import { readFileSync as readFileSync41 } from "fs";
|
|
23037
23094
|
function tryParse(text18) {
|
|
23038
23095
|
try {
|
|
23039
23096
|
return JSON.parse(text18);
|
|
@@ -23062,7 +23119,7 @@ function parsePages(raw, file) {
|
|
|
23062
23119
|
return Array.isArray(parsed) ? parsed.map(toPage) : [toPage(parsed)];
|
|
23063
23120
|
}
|
|
23064
23121
|
function readMiroItems(file) {
|
|
23065
|
-
const items2 = parsePages(
|
|
23122
|
+
const items2 = parsePages(readFileSync41(file, "utf8"), file).flatMap(
|
|
23066
23123
|
(page) => page.data ?? []
|
|
23067
23124
|
);
|
|
23068
23125
|
if (items2.length === 0)
|
|
@@ -23095,7 +23152,33 @@ function selectBoxes(items2, topLeftId, bottomRightId) {
|
|
|
23095
23152
|
right: bottomRight.right,
|
|
23096
23153
|
bottom: bottomRight.bottom
|
|
23097
23154
|
};
|
|
23098
|
-
|
|
23155
|
+
const boxes = items2.filter((item) => isBox(item) && centreInside(rect, item)).sort((a, b) => a.left - b.left || a.top - b.top);
|
|
23156
|
+
return { rect, boxes };
|
|
23157
|
+
}
|
|
23158
|
+
|
|
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)}`);
|
|
23099
23182
|
}
|
|
23100
23183
|
|
|
23101
23184
|
// src/commands/miro/runExtract.ts
|
|
@@ -23106,26 +23189,37 @@ function requireItems(file) {
|
|
|
23106
23189
|
);
|
|
23107
23190
|
return file;
|
|
23108
23191
|
}
|
|
23109
|
-
function
|
|
23110
|
-
if (
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
|
|
23115
|
-
|
|
23116
|
-
|
|
23117
|
-
|
|
23118
|
-
throw new MiroExtractError(
|
|
23119
|
-
"Both --top-left <id|link> and --bottom-right <id|link> are required: there is no assist session to host the picker pane."
|
|
23120
|
-
);
|
|
23121
|
-
return { pick: true, sessionId };
|
|
23192
|
+
function warnUnmatched(file, unmatched) {
|
|
23193
|
+
if (unmatched.length === 0) return;
|
|
23194
|
+
const entries = unmatched.map((entry) => ` - ${entry}`).join("\n");
|
|
23195
|
+
console.error(
|
|
23196
|
+
chalk171.yellow(
|
|
23197
|
+
`${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
|
|
23198
|
+
${entries}`
|
|
23199
|
+
)
|
|
23200
|
+
);
|
|
23122
23201
|
}
|
|
23123
23202
|
async function runExtract(options2) {
|
|
23124
23203
|
const source = anchorSource(options2);
|
|
23125
|
-
const
|
|
23204
|
+
const raw = readMiroItems(requireItems(options2.items));
|
|
23205
|
+
const items2 = normaliseItems(raw);
|
|
23126
23206
|
const [topLeft, bottomRight] = source.pick ? await pickAnchors(source.sessionId, items2) : [source.topLeft, source.bottomRight];
|
|
23127
|
-
const
|
|
23128
|
-
|
|
23207
|
+
const selection = selectBoxes(items2, topLeft, bottomRight);
|
|
23208
|
+
const ignore3 = options2.ignore ? readIgnoreList(options2.ignore) : [];
|
|
23209
|
+
const kept = applyIgnore(uniqueTexts(selection.boxes), ignore3);
|
|
23210
|
+
if (options2.ignore) warnUnmatched(options2.ignore, kept.unmatched);
|
|
23211
|
+
if (!options2.out) {
|
|
23212
|
+
process.stdout.write(stringify2(kept.texts));
|
|
23213
|
+
return;
|
|
23214
|
+
}
|
|
23215
|
+
writeExtract(
|
|
23216
|
+
options2.out,
|
|
23217
|
+
{ ...miroSource(raw, topLeft), topLeft, bottomRight, rect: selection.rect },
|
|
23218
|
+
kept.texts
|
|
23219
|
+
);
|
|
23220
|
+
console.log(
|
|
23221
|
+
`Wrote ${kept.texts.length} ${kept.texts.length === 1 ? "box" : "boxes"} to ${options2.out}`
|
|
23222
|
+
);
|
|
23129
23223
|
}
|
|
23130
23224
|
|
|
23131
23225
|
// src/commands/miro/registerMiro.ts
|
|
@@ -23137,14 +23231,14 @@ function registerMiro(program2) {
|
|
|
23137
23231
|
).option(
|
|
23138
23232
|
"--bottom-right <id>",
|
|
23139
23233
|
"Widget id or ?moveToWidget=<id> link of the bottom-right box"
|
|
23140
|
-
).action(runExtract);
|
|
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").action(runExtract);
|
|
23141
23235
|
}
|
|
23142
23236
|
|
|
23143
23237
|
// src/commands/netcap/netcap.ts
|
|
23144
23238
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
23145
23239
|
import { createServer as createServer2 } from "http";
|
|
23146
|
-
import { dirname as
|
|
23147
|
-
import
|
|
23240
|
+
import { dirname as dirname29 } from "path";
|
|
23241
|
+
import chalk173 from "chalk";
|
|
23148
23242
|
|
|
23149
23243
|
// src/commands/netcap/corsHeaders.ts
|
|
23150
23244
|
var corsHeaders = {
|
|
@@ -23223,12 +23317,12 @@ function createNetcapHandler(options2) {
|
|
|
23223
23317
|
import { cp, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
23224
23318
|
import { networkInterfaces } from "os";
|
|
23225
23319
|
import { join as join58 } from "path";
|
|
23226
|
-
import
|
|
23320
|
+
import chalk172 from "chalk";
|
|
23227
23321
|
|
|
23228
23322
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
23229
|
-
import { dirname as
|
|
23323
|
+
import { dirname as dirname28, join as join57 } from "path";
|
|
23230
23324
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
23231
|
-
var moduleDir =
|
|
23325
|
+
var moduleDir = dirname28(fileURLToPath6(import.meta.url));
|
|
23232
23326
|
function netcapExtensionDir() {
|
|
23233
23327
|
return join57(moduleDir, "commands", "netcap", "netcap-extension");
|
|
23234
23328
|
}
|
|
@@ -23267,7 +23361,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
23267
23361
|
const host = lanIPv4();
|
|
23268
23362
|
if (!host) {
|
|
23269
23363
|
console.log(
|
|
23270
|
-
|
|
23364
|
+
chalk172.yellow("could not determine the WSL IP for the extension")
|
|
23271
23365
|
);
|
|
23272
23366
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
23273
23367
|
return source;
|
|
@@ -23278,7 +23372,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
23278
23372
|
return WSL_WINDOWS_PATH;
|
|
23279
23373
|
} catch {
|
|
23280
23374
|
console.log(
|
|
23281
|
-
|
|
23375
|
+
chalk172.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
23282
23376
|
);
|
|
23283
23377
|
return source;
|
|
23284
23378
|
}
|
|
@@ -23306,35 +23400,35 @@ async function netcap(options2) {
|
|
|
23306
23400
|
const port = Number(options2.port);
|
|
23307
23401
|
const outPath = resolveNetcapOutPath(options2.out);
|
|
23308
23402
|
const filter = options2.filter ?? "";
|
|
23309
|
-
await mkdir4(
|
|
23403
|
+
await mkdir4(dirname29(outPath), { recursive: true });
|
|
23310
23404
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
23311
23405
|
let count8 = 0;
|
|
23312
23406
|
const handler = createNetcapHandler({
|
|
23313
23407
|
outPath,
|
|
23314
|
-
onPing: () => console.log(
|
|
23408
|
+
onPing: () => console.log(chalk173.dim("ping from extension")),
|
|
23315
23409
|
onCapture: (entry) => {
|
|
23316
23410
|
count8 += 1;
|
|
23317
23411
|
console.log(
|
|
23318
|
-
|
|
23319
|
-
|
|
23412
|
+
chalk173.green(`captured #${count8}`),
|
|
23413
|
+
chalk173.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
23320
23414
|
);
|
|
23321
23415
|
}
|
|
23322
23416
|
});
|
|
23323
23417
|
const server = createServer2(handler);
|
|
23324
23418
|
server.listen(port, () => {
|
|
23325
23419
|
console.log(
|
|
23326
|
-
|
|
23420
|
+
chalk173.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
23327
23421
|
);
|
|
23328
|
-
console.log(
|
|
23422
|
+
console.log(chalk173.dim(`appending captures to ${outPath}`));
|
|
23329
23423
|
if (filter)
|
|
23330
|
-
console.log(
|
|
23331
|
-
console.log(
|
|
23332
|
-
console.log(
|
|
23424
|
+
console.log(chalk173.dim(`forwarding only URLs matching "${filter}"`));
|
|
23425
|
+
console.log(chalk173.dim(`load the unpacked extension from ${extensionPath}`));
|
|
23426
|
+
console.log(chalk173.dim("press Ctrl-C to stop"));
|
|
23333
23427
|
});
|
|
23334
23428
|
process.on("SIGINT", () => {
|
|
23335
23429
|
server.close();
|
|
23336
23430
|
console.log(
|
|
23337
|
-
|
|
23431
|
+
chalk173.bold(
|
|
23338
23432
|
`
|
|
23339
23433
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
23340
23434
|
)
|
|
@@ -23344,12 +23438,12 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
23344
23438
|
}
|
|
23345
23439
|
|
|
23346
23440
|
// src/commands/netcap/netcapExtract.ts
|
|
23347
|
-
import { writeFileSync as
|
|
23441
|
+
import { writeFileSync as writeFileSync34 } from "fs";
|
|
23348
23442
|
import { join as join61 } from "path";
|
|
23349
|
-
import
|
|
23443
|
+
import chalk174 from "chalk";
|
|
23350
23444
|
|
|
23351
23445
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
23352
|
-
import { readFileSync as
|
|
23446
|
+
import { readFileSync as readFileSync42 } from "fs";
|
|
23353
23447
|
|
|
23354
23448
|
// src/commands/netcap/parseRscRows.ts
|
|
23355
23449
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -23745,7 +23839,7 @@ function extractVoyagerPosts(body) {
|
|
|
23745
23839
|
|
|
23746
23840
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
23747
23841
|
function captureEntries(captureFile) {
|
|
23748
|
-
const lines2 =
|
|
23842
|
+
const lines2 = readFileSync42(captureFile, "utf8").split("\n").filter(Boolean);
|
|
23749
23843
|
const entries = [];
|
|
23750
23844
|
for (const line of lines2) {
|
|
23751
23845
|
let entry;
|
|
@@ -23791,11 +23885,11 @@ function netcapExtract(file) {
|
|
|
23791
23885
|
const captureFile = file ?? defaultCapturePath();
|
|
23792
23886
|
const posts = extractPostsFromCapture(captureFile);
|
|
23793
23887
|
const outFile = join61(captureFile, "..", "posts.json");
|
|
23794
|
-
|
|
23888
|
+
writeFileSync34(outFile, `${JSON.stringify(posts, null, 2)}
|
|
23795
23889
|
`);
|
|
23796
23890
|
console.log(
|
|
23797
|
-
|
|
23798
|
-
|
|
23891
|
+
chalk174.green(`extracted ${posts.length} posts`),
|
|
23892
|
+
chalk174.dim(`-> ${outFile}`)
|
|
23799
23893
|
);
|
|
23800
23894
|
}
|
|
23801
23895
|
|
|
@@ -23816,7 +23910,7 @@ function registerNetcap(program2) {
|
|
|
23816
23910
|
}
|
|
23817
23911
|
|
|
23818
23912
|
// src/commands/news/add/index.ts
|
|
23819
|
-
import
|
|
23913
|
+
import chalk175 from "chalk";
|
|
23820
23914
|
import enquirer8 from "enquirer";
|
|
23821
23915
|
async function add2(url) {
|
|
23822
23916
|
if (!url) {
|
|
@@ -23838,10 +23932,10 @@ async function add2(url) {
|
|
|
23838
23932
|
const { orm } = await getReady();
|
|
23839
23933
|
const added = await addFeed(orm, url);
|
|
23840
23934
|
if (!added) {
|
|
23841
|
-
console.log(
|
|
23935
|
+
console.log(chalk175.yellow("Feed already exists"));
|
|
23842
23936
|
return;
|
|
23843
23937
|
}
|
|
23844
|
-
console.log(
|
|
23938
|
+
console.log(chalk175.green(`Added feed: ${url}`));
|
|
23845
23939
|
}
|
|
23846
23940
|
|
|
23847
23941
|
// src/commands/registerNews.ts
|
|
@@ -23888,7 +23982,7 @@ function registerPiHook(program2) {
|
|
|
23888
23982
|
}
|
|
23889
23983
|
|
|
23890
23984
|
// src/commands/prompts/printPromptsTable.ts
|
|
23891
|
-
import
|
|
23985
|
+
import chalk176 from "chalk";
|
|
23892
23986
|
function truncate(str, max) {
|
|
23893
23987
|
if (str.length <= max) return str;
|
|
23894
23988
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -23906,14 +24000,14 @@ function printPromptsTable(rows) {
|
|
|
23906
24000
|
"Command".padEnd(commandWidth),
|
|
23907
24001
|
"Repos"
|
|
23908
24002
|
].join(" ");
|
|
23909
|
-
console.log(
|
|
23910
|
-
console.log(
|
|
24003
|
+
console.log(chalk176.dim(header));
|
|
24004
|
+
console.log(chalk176.dim("-".repeat(header.length)));
|
|
23911
24005
|
for (const row of rows) {
|
|
23912
24006
|
const count8 = String(row.count).padStart(countWidth);
|
|
23913
24007
|
const tool = row.tool.padEnd(toolWidth);
|
|
23914
24008
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
23915
24009
|
console.log(
|
|
23916
|
-
`${
|
|
24010
|
+
`${chalk176.yellow(count8)} ${tool} ${command} ${chalk176.dim(row.repos)}`
|
|
23917
24011
|
);
|
|
23918
24012
|
}
|
|
23919
24013
|
}
|
|
@@ -24314,13 +24408,13 @@ import { execSync as execSync45 } from "child_process";
|
|
|
24314
24408
|
|
|
24315
24409
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
24316
24410
|
import { execSync as execSync44 } from "child_process";
|
|
24317
|
-
import { unlinkSync as unlinkSync14, writeFileSync as
|
|
24411
|
+
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync35 } from "fs";
|
|
24318
24412
|
import { tmpdir as tmpdir6 } from "os";
|
|
24319
24413
|
import { join as join63 } from "path";
|
|
24320
24414
|
|
|
24321
24415
|
// src/commands/prs/loadCommentsCache.ts
|
|
24322
|
-
import { existsSync as
|
|
24323
|
-
import { parse as
|
|
24416
|
+
import { existsSync as existsSync55, readFileSync as readFileSync43, unlinkSync as unlinkSync13 } from "fs";
|
|
24417
|
+
import { parse as parse3 } from "yaml";
|
|
24324
24418
|
|
|
24325
24419
|
// src/commands/prs/commentsCachePath.ts
|
|
24326
24420
|
import { homedir as homedir21 } from "os";
|
|
@@ -24339,15 +24433,15 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
24339
24433
|
// src/commands/prs/loadCommentsCache.ts
|
|
24340
24434
|
function loadCommentsCache(org, repo, prNumber) {
|
|
24341
24435
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24342
|
-
if (!
|
|
24436
|
+
if (!existsSync55(cachePath)) {
|
|
24343
24437
|
return null;
|
|
24344
24438
|
}
|
|
24345
|
-
const content =
|
|
24346
|
-
return
|
|
24439
|
+
const content = readFileSync43(cachePath, "utf8");
|
|
24440
|
+
return parse3(content);
|
|
24347
24441
|
}
|
|
24348
24442
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
24349
24443
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24350
|
-
if (
|
|
24444
|
+
if (existsSync55(cachePath)) {
|
|
24351
24445
|
unlinkSync13(cachePath);
|
|
24352
24446
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
24353
24447
|
}
|
|
@@ -24376,7 +24470,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
24376
24470
|
function resolveThread(threadId) {
|
|
24377
24471
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
24378
24472
|
const queryFile = join63(tmpdir6(), `gh-mutation-${Date.now()}.graphql`);
|
|
24379
|
-
|
|
24473
|
+
writeFileSync35(queryFile, mutation);
|
|
24380
24474
|
try {
|
|
24381
24475
|
execSync44(
|
|
24382
24476
|
`gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
|
|
@@ -24458,13 +24552,13 @@ function fixed(commentId, sha) {
|
|
|
24458
24552
|
|
|
24459
24553
|
// src/commands/prs/fetchThreadIds.ts
|
|
24460
24554
|
import { execSync as execSync46 } from "child_process";
|
|
24461
|
-
import { unlinkSync as unlinkSync15, writeFileSync as
|
|
24555
|
+
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync36 } from "fs";
|
|
24462
24556
|
import { tmpdir as tmpdir7 } from "os";
|
|
24463
24557
|
import { join as join64 } from "path";
|
|
24464
24558
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
24465
24559
|
function fetchThreadIds(org, repo, prNumber) {
|
|
24466
24560
|
const queryFile = join64(tmpdir7(), `gh-query-${Date.now()}.graphql`);
|
|
24467
|
-
|
|
24561
|
+
writeFileSync36(queryFile, THREAD_QUERY);
|
|
24468
24562
|
try {
|
|
24469
24563
|
const result = execSync46(
|
|
24470
24564
|
`gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
|
|
@@ -24532,9 +24626,9 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
24532
24626
|
}
|
|
24533
24627
|
|
|
24534
24628
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
24535
|
-
import { mkdirSync as
|
|
24536
|
-
import { dirname as
|
|
24537
|
-
import { stringify as
|
|
24629
|
+
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync37 } from "fs";
|
|
24630
|
+
import { dirname as dirname30 } from "path";
|
|
24631
|
+
import { stringify as stringify3 } from "yaml";
|
|
24538
24632
|
|
|
24539
24633
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
24540
24634
|
import { readdirSync as readdirSync12, unlinkSync as unlinkSync16 } from "fs";
|
|
@@ -24556,13 +24650,13 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
|
24556
24650
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
24557
24651
|
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
24558
24652
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24559
|
-
|
|
24653
|
+
mkdirSync20(dirname30(cachePath), { recursive: true });
|
|
24560
24654
|
const cacheData = {
|
|
24561
24655
|
prNumber,
|
|
24562
24656
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
24563
24657
|
comments: comments3
|
|
24564
24658
|
};
|
|
24565
|
-
|
|
24659
|
+
writeFileSync37(cachePath, stringify3(cacheData));
|
|
24566
24660
|
}
|
|
24567
24661
|
function updateCommentsCache(org, repo, prNumber, comments3) {
|
|
24568
24662
|
removeStaleCommentsCaches();
|
|
@@ -24580,13 +24674,13 @@ function agentFooter(unresolvedCount) {
|
|
|
24580
24674
|
}
|
|
24581
24675
|
|
|
24582
24676
|
// src/commands/prs/listComments/commentStyle.ts
|
|
24583
|
-
import
|
|
24677
|
+
import chalk177 from "chalk";
|
|
24584
24678
|
var plain = (text18) => text18;
|
|
24585
24679
|
function colouredState(state) {
|
|
24586
24680
|
const label2 = `[${state}]`;
|
|
24587
|
-
if (state === "APPROVED") return
|
|
24588
|
-
if (state === "CHANGES_REQUESTED") return
|
|
24589
|
-
return
|
|
24681
|
+
if (state === "APPROVED") return chalk177.green(label2);
|
|
24682
|
+
if (state === "CHANGES_REQUESTED") return chalk177.red(label2);
|
|
24683
|
+
return chalk177.yellow(label2);
|
|
24590
24684
|
}
|
|
24591
24685
|
function commentStyle() {
|
|
24592
24686
|
if (isClaudeCode()) {
|
|
@@ -24600,9 +24694,9 @@ function commentStyle() {
|
|
|
24600
24694
|
};
|
|
24601
24695
|
}
|
|
24602
24696
|
return {
|
|
24603
|
-
cyan:
|
|
24604
|
-
bold:
|
|
24605
|
-
dim:
|
|
24697
|
+
cyan: chalk177.cyan,
|
|
24698
|
+
bold: chalk177.bold,
|
|
24699
|
+
dim: chalk177.dim,
|
|
24606
24700
|
state: colouredState,
|
|
24607
24701
|
diffHunk: true,
|
|
24608
24702
|
agent: false
|
|
@@ -24772,13 +24866,13 @@ import { execSync as execSync48 } from "child_process";
|
|
|
24772
24866
|
import enquirer9 from "enquirer";
|
|
24773
24867
|
|
|
24774
24868
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
24775
|
-
import
|
|
24869
|
+
import chalk178 from "chalk";
|
|
24776
24870
|
var STATUS_MAP = {
|
|
24777
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
24778
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
24871
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk178.magenta("merged"), date: pr.mergedAt } : null,
|
|
24872
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk178.red("closed"), date: pr.closedAt } : null
|
|
24779
24873
|
};
|
|
24780
24874
|
function defaultStatus(pr) {
|
|
24781
|
-
return { label:
|
|
24875
|
+
return { label: chalk178.green("opened"), date: pr.createdAt };
|
|
24782
24876
|
}
|
|
24783
24877
|
function getStatus2(pr) {
|
|
24784
24878
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -24787,11 +24881,11 @@ function formatDate(dateStr) {
|
|
|
24787
24881
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
24788
24882
|
}
|
|
24789
24883
|
function formatPrHeader(pr, status3) {
|
|
24790
|
-
return `${
|
|
24884
|
+
return `${chalk178.cyan(`#${pr.number}`)} ${pr.title} ${chalk178.dim(`(${pr.author.login},`)} ${status3.label} ${chalk178.dim(`${formatDate(status3.date)})`)}`;
|
|
24791
24885
|
}
|
|
24792
24886
|
function logPrDetails(pr) {
|
|
24793
24887
|
console.log(
|
|
24794
|
-
|
|
24888
|
+
chalk178.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
24795
24889
|
);
|
|
24796
24890
|
console.log();
|
|
24797
24891
|
}
|
|
@@ -25506,10 +25600,10 @@ function registerPrs(program2) {
|
|
|
25506
25600
|
}
|
|
25507
25601
|
|
|
25508
25602
|
// src/commands/ravendb/ravendbAuth.ts
|
|
25509
|
-
import
|
|
25603
|
+
import chalk184 from "chalk";
|
|
25510
25604
|
|
|
25511
25605
|
// src/shared/createConnectionAuth.ts
|
|
25512
|
-
import
|
|
25606
|
+
import chalk179 from "chalk";
|
|
25513
25607
|
function listConnections(connections, format) {
|
|
25514
25608
|
if (connections.length === 0) {
|
|
25515
25609
|
console.log("No connections configured.");
|
|
@@ -25522,7 +25616,7 @@ function listConnections(connections, format) {
|
|
|
25522
25616
|
function removeConnection(connections, name, save) {
|
|
25523
25617
|
const filtered = connections.filter((c) => c.name !== name);
|
|
25524
25618
|
if (filtered.length === connections.length) {
|
|
25525
|
-
console.error(
|
|
25619
|
+
console.error(chalk179.red(`Connection "${name}" not found.`));
|
|
25526
25620
|
process.exit(1);
|
|
25527
25621
|
}
|
|
25528
25622
|
save(filtered);
|
|
@@ -25568,15 +25662,15 @@ function saveConnections(connections) {
|
|
|
25568
25662
|
}
|
|
25569
25663
|
|
|
25570
25664
|
// src/commands/ravendb/promptConnection.ts
|
|
25571
|
-
import
|
|
25665
|
+
import chalk182 from "chalk";
|
|
25572
25666
|
|
|
25573
25667
|
// src/commands/ravendb/selectOpSecret.ts
|
|
25574
|
-
import
|
|
25668
|
+
import chalk181 from "chalk";
|
|
25575
25669
|
import Enquirer2 from "enquirer";
|
|
25576
25670
|
|
|
25577
25671
|
// src/commands/ravendb/searchItems.ts
|
|
25578
25672
|
import { execSync as execSync51 } from "child_process";
|
|
25579
|
-
import
|
|
25673
|
+
import chalk180 from "chalk";
|
|
25580
25674
|
function opExec(args) {
|
|
25581
25675
|
return execSync51(`op ${args}`, {
|
|
25582
25676
|
encoding: "utf8",
|
|
@@ -25589,7 +25683,7 @@ function searchItems(search2) {
|
|
|
25589
25683
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
25590
25684
|
} catch {
|
|
25591
25685
|
console.error(
|
|
25592
|
-
|
|
25686
|
+
chalk180.red(
|
|
25593
25687
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
25594
25688
|
)
|
|
25595
25689
|
);
|
|
@@ -25603,7 +25697,7 @@ function getItemFields(itemId2) {
|
|
|
25603
25697
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
25604
25698
|
return item.fields.filter((f) => f.reference && f.label);
|
|
25605
25699
|
} catch {
|
|
25606
|
-
console.error(
|
|
25700
|
+
console.error(chalk180.red("Failed to get item details from 1Password."));
|
|
25607
25701
|
process.exit(1);
|
|
25608
25702
|
}
|
|
25609
25703
|
}
|
|
@@ -25622,7 +25716,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
25622
25716
|
}).run();
|
|
25623
25717
|
const items2 = searchItems(search2);
|
|
25624
25718
|
if (items2.length === 0) {
|
|
25625
|
-
console.error(
|
|
25719
|
+
console.error(chalk181.red(`No items found matching "${search2}".`));
|
|
25626
25720
|
process.exit(1);
|
|
25627
25721
|
}
|
|
25628
25722
|
const itemId2 = await selectOne(
|
|
@@ -25631,7 +25725,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
25631
25725
|
);
|
|
25632
25726
|
const fields = getItemFields(itemId2);
|
|
25633
25727
|
if (fields.length === 0) {
|
|
25634
|
-
console.error(
|
|
25728
|
+
console.error(chalk181.red("No fields with references found on this item."));
|
|
25635
25729
|
process.exit(1);
|
|
25636
25730
|
}
|
|
25637
25731
|
const ref = await selectOne(
|
|
@@ -25645,7 +25739,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
25645
25739
|
async function promptConnection(existingNames) {
|
|
25646
25740
|
const name = await promptInput("name", "Connection name:");
|
|
25647
25741
|
if (existingNames.includes(name)) {
|
|
25648
|
-
console.error(
|
|
25742
|
+
console.error(chalk182.red(`Connection "${name}" already exists.`));
|
|
25649
25743
|
process.exit(1);
|
|
25650
25744
|
}
|
|
25651
25745
|
const url = await promptInput(
|
|
@@ -25654,22 +25748,22 @@ async function promptConnection(existingNames) {
|
|
|
25654
25748
|
);
|
|
25655
25749
|
const database = await promptInput("database", "Database name:");
|
|
25656
25750
|
if (!name || !url || !database) {
|
|
25657
|
-
console.error(
|
|
25751
|
+
console.error(chalk182.red("All fields are required."));
|
|
25658
25752
|
process.exit(1);
|
|
25659
25753
|
}
|
|
25660
25754
|
const apiKeyRef = await selectOpSecret();
|
|
25661
|
-
console.log(
|
|
25755
|
+
console.log(chalk182.dim(`Using: ${apiKeyRef}`));
|
|
25662
25756
|
return { name, url, database, apiKeyRef };
|
|
25663
25757
|
}
|
|
25664
25758
|
|
|
25665
25759
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
25666
|
-
import
|
|
25760
|
+
import chalk183 from "chalk";
|
|
25667
25761
|
function ravendbSetConnection(name) {
|
|
25668
25762
|
const raw = loadGlobalConfigRaw();
|
|
25669
25763
|
const ravendb = raw.ravendb ?? {};
|
|
25670
25764
|
const connections = ravendb.connections ?? [];
|
|
25671
25765
|
if (!connections.some((c) => c.name === name)) {
|
|
25672
|
-
console.error(
|
|
25766
|
+
console.error(chalk183.red(`Connection "${name}" not found.`));
|
|
25673
25767
|
console.error(
|
|
25674
25768
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
25675
25769
|
);
|
|
@@ -25685,16 +25779,16 @@ function ravendbSetConnection(name) {
|
|
|
25685
25779
|
var ravendbAuth = createConnectionAuth({
|
|
25686
25780
|
load: loadConnections,
|
|
25687
25781
|
save: saveConnections,
|
|
25688
|
-
format: (c) => `${
|
|
25782
|
+
format: (c) => `${chalk184.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
25689
25783
|
promptNew: promptConnection,
|
|
25690
25784
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
25691
25785
|
});
|
|
25692
25786
|
|
|
25693
25787
|
// src/commands/ravendb/ravendbCollections.ts
|
|
25694
|
-
import
|
|
25788
|
+
import chalk188 from "chalk";
|
|
25695
25789
|
|
|
25696
25790
|
// src/commands/ravendb/ravenFetch.ts
|
|
25697
|
-
import
|
|
25791
|
+
import chalk186 from "chalk";
|
|
25698
25792
|
|
|
25699
25793
|
// src/commands/ravendb/getAccessToken.ts
|
|
25700
25794
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -25731,10 +25825,10 @@ ${errorText}`
|
|
|
25731
25825
|
|
|
25732
25826
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
25733
25827
|
import { execSync as execSync52 } from "child_process";
|
|
25734
|
-
import
|
|
25828
|
+
import chalk185 from "chalk";
|
|
25735
25829
|
function resolveOpSecret(reference) {
|
|
25736
25830
|
if (!reference.startsWith("op://")) {
|
|
25737
|
-
console.error(
|
|
25831
|
+
console.error(chalk185.red(`Invalid secret reference: must start with op://`));
|
|
25738
25832
|
process.exit(1);
|
|
25739
25833
|
}
|
|
25740
25834
|
try {
|
|
@@ -25744,7 +25838,7 @@ function resolveOpSecret(reference) {
|
|
|
25744
25838
|
}).trim();
|
|
25745
25839
|
} catch {
|
|
25746
25840
|
console.error(
|
|
25747
|
-
|
|
25841
|
+
chalk185.red(
|
|
25748
25842
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
25749
25843
|
)
|
|
25750
25844
|
);
|
|
@@ -25771,7 +25865,7 @@ async function ravenFetch(connection, path80) {
|
|
|
25771
25865
|
if (!response.ok) {
|
|
25772
25866
|
const body = await response.text();
|
|
25773
25867
|
console.error(
|
|
25774
|
-
|
|
25868
|
+
chalk186.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
25775
25869
|
);
|
|
25776
25870
|
console.error(body.substring(0, 500));
|
|
25777
25871
|
process.exit(1);
|
|
@@ -25780,7 +25874,7 @@ async function ravenFetch(connection, path80) {
|
|
|
25780
25874
|
}
|
|
25781
25875
|
|
|
25782
25876
|
// src/commands/ravendb/resolveConnection.ts
|
|
25783
|
-
import
|
|
25877
|
+
import chalk187 from "chalk";
|
|
25784
25878
|
function loadRavendb() {
|
|
25785
25879
|
const raw = loadGlobalConfigRaw();
|
|
25786
25880
|
const ravendb = raw.ravendb;
|
|
@@ -25794,7 +25888,7 @@ function resolveConnection(name) {
|
|
|
25794
25888
|
const connectionName = name ?? defaultConnection;
|
|
25795
25889
|
if (!connectionName) {
|
|
25796
25890
|
console.error(
|
|
25797
|
-
|
|
25891
|
+
chalk187.red(
|
|
25798
25892
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
25799
25893
|
)
|
|
25800
25894
|
);
|
|
@@ -25802,7 +25896,7 @@ function resolveConnection(name) {
|
|
|
25802
25896
|
}
|
|
25803
25897
|
const connection = connections.find((c) => c.name === connectionName);
|
|
25804
25898
|
if (!connection) {
|
|
25805
|
-
console.error(
|
|
25899
|
+
console.error(chalk187.red(`Connection "${connectionName}" not found.`));
|
|
25806
25900
|
console.error(
|
|
25807
25901
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
25808
25902
|
);
|
|
@@ -25833,15 +25927,15 @@ async function ravendbCollections(connectionName) {
|
|
|
25833
25927
|
return;
|
|
25834
25928
|
}
|
|
25835
25929
|
for (const c of collections) {
|
|
25836
|
-
console.log(`${
|
|
25930
|
+
console.log(`${chalk188.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
25837
25931
|
}
|
|
25838
25932
|
}
|
|
25839
25933
|
|
|
25840
25934
|
// src/commands/ravendb/ravendbQuery.ts
|
|
25841
|
-
import
|
|
25935
|
+
import chalk190 from "chalk";
|
|
25842
25936
|
|
|
25843
25937
|
// src/commands/ravendb/fetchAllPages.ts
|
|
25844
|
-
import
|
|
25938
|
+
import chalk189 from "chalk";
|
|
25845
25939
|
|
|
25846
25940
|
// src/commands/ravendb/buildQueryPath.ts
|
|
25847
25941
|
function buildQueryPath(opts) {
|
|
@@ -25879,7 +25973,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
25879
25973
|
allResults.push(...results);
|
|
25880
25974
|
start3 += results.length;
|
|
25881
25975
|
process.stderr.write(
|
|
25882
|
-
`\r${
|
|
25976
|
+
`\r${chalk189.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
25883
25977
|
);
|
|
25884
25978
|
if (start3 >= totalResults) break;
|
|
25885
25979
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -25894,7 +25988,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
25894
25988
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
25895
25989
|
const resolved = resolveArgs(connectionName, collection);
|
|
25896
25990
|
if (!resolved.collection && !options2.query) {
|
|
25897
|
-
console.error(
|
|
25991
|
+
console.error(chalk190.red("Provide a collection name or --query filter."));
|
|
25898
25992
|
process.exit(1);
|
|
25899
25993
|
}
|
|
25900
25994
|
const { collection: col } = resolved;
|
|
@@ -25933,7 +26027,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
25933
26027
|
import * as path42 from "path";
|
|
25934
26028
|
|
|
25935
26029
|
// src/commands/refactor/logViolations.ts
|
|
25936
|
-
import
|
|
26030
|
+
import chalk191 from "chalk";
|
|
25937
26031
|
var DEFAULT_MAX_LINES2 = 100;
|
|
25938
26032
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
25939
26033
|
if (violations.length === 0) {
|
|
@@ -25942,43 +26036,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
25942
26036
|
}
|
|
25943
26037
|
return;
|
|
25944
26038
|
}
|
|
25945
|
-
console.error(
|
|
26039
|
+
console.error(chalk191.red(`
|
|
25946
26040
|
Refactor check failed:
|
|
25947
26041
|
`));
|
|
25948
|
-
console.error(
|
|
26042
|
+
console.error(chalk191.red(` The following files exceed ${maxLines} lines:
|
|
25949
26043
|
`));
|
|
25950
26044
|
for (const violation of violations) {
|
|
25951
|
-
console.error(
|
|
26045
|
+
console.error(chalk191.red(` ${violation.file} (${violation.lines} lines)`));
|
|
25952
26046
|
}
|
|
25953
26047
|
console.error(
|
|
25954
|
-
|
|
26048
|
+
chalk191.yellow(
|
|
25955
26049
|
`
|
|
25956
26050
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
25957
26051
|
way to refactor it, ignore it with:
|
|
25958
26052
|
`
|
|
25959
26053
|
)
|
|
25960
26054
|
);
|
|
25961
|
-
console.error(
|
|
26055
|
+
console.error(chalk191.gray(` assist refactor ignore <file>
|
|
25962
26056
|
`));
|
|
25963
26057
|
if (process.env.CLAUDECODE) {
|
|
25964
|
-
console.error(
|
|
26058
|
+
console.error(chalk191.cyan(`
|
|
25965
26059
|
## Extracting Code to New Files
|
|
25966
26060
|
`));
|
|
25967
26061
|
console.error(
|
|
25968
|
-
|
|
26062
|
+
chalk191.cyan(
|
|
25969
26063
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
25970
26064
|
`
|
|
25971
26065
|
)
|
|
25972
26066
|
);
|
|
25973
26067
|
console.error(
|
|
25974
|
-
|
|
26068
|
+
chalk191.cyan(
|
|
25975
26069
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
25976
26070
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
25977
26071
|
`
|
|
25978
26072
|
)
|
|
25979
26073
|
);
|
|
25980
26074
|
console.error(
|
|
25981
|
-
|
|
26075
|
+
chalk191.cyan(
|
|
25982
26076
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
25983
26077
|
domains, move it to a common/shared folder.
|
|
25984
26078
|
`
|
|
@@ -26134,7 +26228,7 @@ async function check(pattern2, options2) {
|
|
|
26134
26228
|
|
|
26135
26229
|
// src/commands/refactor/extract/index.ts
|
|
26136
26230
|
import path50 from "path";
|
|
26137
|
-
import
|
|
26231
|
+
import chalk194 from "chalk";
|
|
26138
26232
|
|
|
26139
26233
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
26140
26234
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -26733,23 +26827,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
26733
26827
|
|
|
26734
26828
|
// src/commands/refactor/extract/displayPlan.ts
|
|
26735
26829
|
import path46 from "path";
|
|
26736
|
-
import
|
|
26830
|
+
import chalk192 from "chalk";
|
|
26737
26831
|
function section2(title) {
|
|
26738
26832
|
return `
|
|
26739
|
-
${
|
|
26833
|
+
${chalk192.cyan(title)}`;
|
|
26740
26834
|
}
|
|
26741
26835
|
function displayImporters(plan2, cwd) {
|
|
26742
26836
|
if (plan2.importersToUpdate.length === 0) return;
|
|
26743
26837
|
console.log(section2("Update importers:"));
|
|
26744
26838
|
for (const imp of plan2.importersToUpdate) {
|
|
26745
26839
|
const rel = path46.relative(cwd, imp.file.getFilePath());
|
|
26746
|
-
console.log(` ${
|
|
26840
|
+
console.log(` ${chalk192.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
26747
26841
|
}
|
|
26748
26842
|
}
|
|
26749
26843
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
26750
|
-
console.log(
|
|
26844
|
+
console.log(chalk192.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
26751
26845
|
`));
|
|
26752
|
-
console.log(` ${
|
|
26846
|
+
console.log(` ${chalk192.cyan("Functions to move:")}`);
|
|
26753
26847
|
for (const name of plan2.extractedNames) {
|
|
26754
26848
|
console.log(` ${name}`);
|
|
26755
26849
|
}
|
|
@@ -26783,7 +26877,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
26783
26877
|
|
|
26784
26878
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
26785
26879
|
import path49 from "path";
|
|
26786
|
-
import
|
|
26880
|
+
import chalk193 from "chalk";
|
|
26787
26881
|
import { Project as Project4 } from "ts-morph";
|
|
26788
26882
|
|
|
26789
26883
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -26875,7 +26969,7 @@ function loadProjectFile(file) {
|
|
|
26875
26969
|
});
|
|
26876
26970
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
26877
26971
|
if (!sourceFile) {
|
|
26878
|
-
console.log(
|
|
26972
|
+
console.log(chalk193.red(`File not found in project: ${file}`));
|
|
26879
26973
|
process.exit(1);
|
|
26880
26974
|
}
|
|
26881
26975
|
return { project, sourceFile };
|
|
@@ -26898,19 +26992,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
26898
26992
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
26899
26993
|
if (options2.apply) {
|
|
26900
26994
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
26901
|
-
console.log(
|
|
26995
|
+
console.log(chalk194.green("\nExtraction complete"));
|
|
26902
26996
|
} else {
|
|
26903
|
-
console.log(
|
|
26997
|
+
console.log(chalk194.dim("\nDry run. Use --apply to execute."));
|
|
26904
26998
|
}
|
|
26905
26999
|
}
|
|
26906
27000
|
|
|
26907
27001
|
// src/commands/refactor/ignore.ts
|
|
26908
27002
|
import fs33 from "fs";
|
|
26909
|
-
import
|
|
27003
|
+
import chalk195 from "chalk";
|
|
26910
27004
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
26911
27005
|
function ignore2(file) {
|
|
26912
27006
|
if (!fs33.existsSync(file)) {
|
|
26913
|
-
console.error(
|
|
27007
|
+
console.error(chalk195.red(`Error: File does not exist: ${file}`));
|
|
26914
27008
|
process.exit(1);
|
|
26915
27009
|
}
|
|
26916
27010
|
const content = fs33.readFileSync(file, "utf8");
|
|
@@ -26926,7 +27020,7 @@ function ignore2(file) {
|
|
|
26926
27020
|
fs33.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
26927
27021
|
}
|
|
26928
27022
|
console.log(
|
|
26929
|
-
|
|
27023
|
+
chalk195.green(
|
|
26930
27024
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
26931
27025
|
)
|
|
26932
27026
|
);
|
|
@@ -26935,12 +27029,12 @@ function ignore2(file) {
|
|
|
26935
27029
|
// src/commands/refactor/rename/index.ts
|
|
26936
27030
|
import fs36 from "fs";
|
|
26937
27031
|
import path55 from "path";
|
|
26938
|
-
import
|
|
27032
|
+
import chalk198 from "chalk";
|
|
26939
27033
|
|
|
26940
27034
|
// src/commands/refactor/rename/applyRename.ts
|
|
26941
27035
|
import fs35 from "fs";
|
|
26942
27036
|
import path52 from "path";
|
|
26943
|
-
import
|
|
27037
|
+
import chalk196 from "chalk";
|
|
26944
27038
|
|
|
26945
27039
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
26946
27040
|
import path51 from "path";
|
|
@@ -27045,13 +27139,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
27045
27139
|
const updatedContents = applyRewrites(rewrites);
|
|
27046
27140
|
for (const [file, content] of updatedContents) {
|
|
27047
27141
|
fs35.writeFileSync(file, content, "utf8");
|
|
27048
|
-
console.log(
|
|
27142
|
+
console.log(chalk196.cyan(` Updated imports in ${path52.relative(cwd, file)}`));
|
|
27049
27143
|
}
|
|
27050
27144
|
const destDir = path52.dirname(destPath);
|
|
27051
27145
|
if (!fs35.existsSync(destDir)) fs35.mkdirSync(destDir, { recursive: true });
|
|
27052
27146
|
fs35.renameSync(sourcePath, destPath);
|
|
27053
27147
|
console.log(
|
|
27054
|
-
|
|
27148
|
+
chalk196.white(
|
|
27055
27149
|
` Moved ${path52.relative(cwd, sourcePath)} \u2192 ${path52.relative(cwd, destPath)}`
|
|
27056
27150
|
)
|
|
27057
27151
|
);
|
|
@@ -27138,16 +27232,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
27138
27232
|
|
|
27139
27233
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
27140
27234
|
import path54 from "path";
|
|
27141
|
-
import
|
|
27235
|
+
import chalk197 from "chalk";
|
|
27142
27236
|
function printRenamePreview(rewrites, cwd) {
|
|
27143
27237
|
for (const rewrite of rewrites) {
|
|
27144
27238
|
console.log(
|
|
27145
|
-
|
|
27239
|
+
chalk197.dim(
|
|
27146
27240
|
` ${path54.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
27147
27241
|
)
|
|
27148
27242
|
);
|
|
27149
27243
|
}
|
|
27150
|
-
console.log(
|
|
27244
|
+
console.log(chalk197.dim("Dry run. Use --apply to execute."));
|
|
27151
27245
|
}
|
|
27152
27246
|
|
|
27153
27247
|
// src/commands/refactor/rename/index.ts
|
|
@@ -27158,20 +27252,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27158
27252
|
const relSource = path55.relative(cwd, sourcePath);
|
|
27159
27253
|
const relDest = path55.relative(cwd, destPath);
|
|
27160
27254
|
if (!fs36.existsSync(sourcePath)) {
|
|
27161
|
-
console.log(
|
|
27255
|
+
console.log(chalk198.red(`File not found: ${source}`));
|
|
27162
27256
|
process.exit(1);
|
|
27163
27257
|
}
|
|
27164
27258
|
if (destPath !== sourcePath && fs36.existsSync(destPath)) {
|
|
27165
|
-
console.log(
|
|
27259
|
+
console.log(chalk198.red(`Destination already exists: ${destination}`));
|
|
27166
27260
|
process.exit(1);
|
|
27167
27261
|
}
|
|
27168
|
-
console.log(
|
|
27169
|
-
console.log(
|
|
27170
|
-
console.log(
|
|
27262
|
+
console.log(chalk198.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
27263
|
+
console.log(chalk198.dim("Loading project..."));
|
|
27264
|
+
console.log(chalk198.dim("Scanning imports across the project..."));
|
|
27171
27265
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
27172
27266
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
27173
27267
|
console.log(
|
|
27174
|
-
|
|
27268
|
+
chalk198.dim(
|
|
27175
27269
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
27176
27270
|
)
|
|
27177
27271
|
);
|
|
@@ -27180,11 +27274,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27180
27274
|
return;
|
|
27181
27275
|
}
|
|
27182
27276
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
27183
|
-
console.log(
|
|
27277
|
+
console.log(chalk198.green("Done"));
|
|
27184
27278
|
}
|
|
27185
27279
|
|
|
27186
27280
|
// src/commands/refactor/renameSymbol/index.ts
|
|
27187
|
-
import
|
|
27281
|
+
import chalk199 from "chalk";
|
|
27188
27282
|
|
|
27189
27283
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
27190
27284
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -27230,33 +27324,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
27230
27324
|
const { project, sourceFile } = loadProjectFile(file);
|
|
27231
27325
|
const symbol = findSymbol(sourceFile, oldName);
|
|
27232
27326
|
if (!symbol) {
|
|
27233
|
-
console.log(
|
|
27327
|
+
console.log(chalk199.red(`Symbol "${oldName}" not found in ${file}`));
|
|
27234
27328
|
process.exit(1);
|
|
27235
27329
|
}
|
|
27236
27330
|
const grouped = groupReferences(symbol, cwd);
|
|
27237
27331
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
27238
27332
|
console.log(
|
|
27239
|
-
|
|
27333
|
+
chalk199.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
27240
27334
|
`)
|
|
27241
27335
|
);
|
|
27242
27336
|
for (const [refFile, lines2] of grouped) {
|
|
27243
27337
|
console.log(
|
|
27244
|
-
` ${
|
|
27338
|
+
` ${chalk199.dim(refFile)}: lines ${chalk199.cyan(lines2.join(", "))}`
|
|
27245
27339
|
);
|
|
27246
27340
|
}
|
|
27247
27341
|
if (options2.apply) {
|
|
27248
27342
|
symbol.rename(newName);
|
|
27249
27343
|
await project.save();
|
|
27250
|
-
console.log(
|
|
27344
|
+
console.log(chalk199.green(`
|
|
27251
27345
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
27252
27346
|
} else {
|
|
27253
|
-
console.log(
|
|
27347
|
+
console.log(chalk199.dim("\nDry run. Use --apply to execute."));
|
|
27254
27348
|
}
|
|
27255
27349
|
}
|
|
27256
27350
|
|
|
27257
27351
|
// src/commands/refactor/restructure/index.ts
|
|
27258
27352
|
import path63 from "path";
|
|
27259
|
-
import
|
|
27353
|
+
import chalk202 from "chalk";
|
|
27260
27354
|
|
|
27261
27355
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
27262
27356
|
import path57 from "path";
|
|
@@ -27335,50 +27429,50 @@ function clusterFiles(graph) {
|
|
|
27335
27429
|
|
|
27336
27430
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
27337
27431
|
import path59 from "path";
|
|
27338
|
-
import
|
|
27432
|
+
import chalk200 from "chalk";
|
|
27339
27433
|
function relPath(filePath) {
|
|
27340
27434
|
return path59.relative(process.cwd(), filePath);
|
|
27341
27435
|
}
|
|
27342
27436
|
function displayMoves(plan2) {
|
|
27343
27437
|
if (plan2.moves.length === 0) return;
|
|
27344
|
-
console.log(
|
|
27438
|
+
console.log(chalk200.bold("\nFile moves:"));
|
|
27345
27439
|
for (const move2 of plan2.moves) {
|
|
27346
27440
|
console.log(
|
|
27347
|
-
` ${
|
|
27441
|
+
` ${chalk200.red(relPath(move2.from))} \u2192 ${chalk200.green(relPath(move2.to))}`
|
|
27348
27442
|
);
|
|
27349
|
-
console.log(
|
|
27443
|
+
console.log(chalk200.dim(` ${move2.reason}`));
|
|
27350
27444
|
}
|
|
27351
27445
|
}
|
|
27352
27446
|
function displayRewrites(rewrites) {
|
|
27353
27447
|
if (rewrites.length === 0) return;
|
|
27354
27448
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
27355
|
-
console.log(
|
|
27449
|
+
console.log(chalk200.bold(`
|
|
27356
27450
|
Import rewrites (${affectedFiles.size} files):`));
|
|
27357
27451
|
for (const file of affectedFiles) {
|
|
27358
|
-
console.log(` ${
|
|
27452
|
+
console.log(` ${chalk200.cyan(relPath(file))}:`);
|
|
27359
27453
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
27360
27454
|
(r) => r.file === file
|
|
27361
27455
|
)) {
|
|
27362
27456
|
console.log(
|
|
27363
|
-
` ${
|
|
27457
|
+
` ${chalk200.red(`"${oldSpecifier}"`)} \u2192 ${chalk200.green(`"${newSpecifier}"`)}`
|
|
27364
27458
|
);
|
|
27365
27459
|
}
|
|
27366
27460
|
}
|
|
27367
27461
|
}
|
|
27368
27462
|
function displayPlan2(plan2) {
|
|
27369
27463
|
if (plan2.warnings.length > 0) {
|
|
27370
|
-
console.log(
|
|
27371
|
-
for (const w of plan2.warnings) console.log(
|
|
27464
|
+
console.log(chalk200.yellow("\nWarnings:"));
|
|
27465
|
+
for (const w of plan2.warnings) console.log(chalk200.yellow(` ${w}`));
|
|
27372
27466
|
}
|
|
27373
27467
|
if (plan2.newDirectories.length > 0) {
|
|
27374
|
-
console.log(
|
|
27468
|
+
console.log(chalk200.bold("\nNew directories:"));
|
|
27375
27469
|
for (const dir of plan2.newDirectories)
|
|
27376
|
-
console.log(
|
|
27470
|
+
console.log(chalk200.green(` ${dir}/`));
|
|
27377
27471
|
}
|
|
27378
27472
|
displayMoves(plan2);
|
|
27379
27473
|
displayRewrites(plan2.rewrites);
|
|
27380
27474
|
console.log(
|
|
27381
|
-
|
|
27475
|
+
chalk200.dim(
|
|
27382
27476
|
`
|
|
27383
27477
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
27384
27478
|
)
|
|
@@ -27388,18 +27482,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
27388
27482
|
// src/commands/refactor/restructure/executePlan.ts
|
|
27389
27483
|
import fs37 from "fs";
|
|
27390
27484
|
import path60 from "path";
|
|
27391
|
-
import
|
|
27485
|
+
import chalk201 from "chalk";
|
|
27392
27486
|
function executePlan(plan2) {
|
|
27393
27487
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
27394
27488
|
for (const [file, content] of updatedContents) {
|
|
27395
27489
|
fs37.writeFileSync(file, content, "utf8");
|
|
27396
27490
|
console.log(
|
|
27397
|
-
|
|
27491
|
+
chalk201.cyan(` Rewrote imports in ${path60.relative(process.cwd(), file)}`)
|
|
27398
27492
|
);
|
|
27399
27493
|
}
|
|
27400
27494
|
for (const dir of plan2.newDirectories) {
|
|
27401
27495
|
fs37.mkdirSync(dir, { recursive: true });
|
|
27402
|
-
console.log(
|
|
27496
|
+
console.log(chalk201.green(` Created ${path60.relative(process.cwd(), dir)}/`));
|
|
27403
27497
|
}
|
|
27404
27498
|
for (const move2 of plan2.moves) {
|
|
27405
27499
|
const targetDir = path60.dirname(move2.to);
|
|
@@ -27408,7 +27502,7 @@ function executePlan(plan2) {
|
|
|
27408
27502
|
}
|
|
27409
27503
|
fs37.renameSync(move2.from, move2.to);
|
|
27410
27504
|
console.log(
|
|
27411
|
-
|
|
27505
|
+
chalk201.white(
|
|
27412
27506
|
` Moved ${path60.relative(process.cwd(), move2.from)} \u2192 ${path60.relative(process.cwd(), move2.to)}`
|
|
27413
27507
|
)
|
|
27414
27508
|
);
|
|
@@ -27423,7 +27517,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
27423
27517
|
if (entries.length === 0) {
|
|
27424
27518
|
fs37.rmdirSync(dir);
|
|
27425
27519
|
console.log(
|
|
27426
|
-
|
|
27520
|
+
chalk201.dim(
|
|
27427
27521
|
` Removed empty directory ${path60.relative(process.cwd(), dir)}`
|
|
27428
27522
|
)
|
|
27429
27523
|
);
|
|
@@ -27556,22 +27650,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
27556
27650
|
const targetPattern = pattern2 ?? "src";
|
|
27557
27651
|
const files = findSourceFiles2(targetPattern);
|
|
27558
27652
|
if (files.length === 0) {
|
|
27559
|
-
console.log(
|
|
27653
|
+
console.log(chalk202.yellow("No files found matching pattern"));
|
|
27560
27654
|
return;
|
|
27561
27655
|
}
|
|
27562
27656
|
const tsConfigPath = findTsConfig(path63.resolve(files[0]));
|
|
27563
27657
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
27564
27658
|
if (plan2.moves.length === 0) {
|
|
27565
|
-
console.log(
|
|
27659
|
+
console.log(chalk202.green("No restructuring needed"));
|
|
27566
27660
|
return;
|
|
27567
27661
|
}
|
|
27568
27662
|
displayPlan2(plan2);
|
|
27569
27663
|
if (options2.apply) {
|
|
27570
|
-
console.log(
|
|
27664
|
+
console.log(chalk202.bold("\nApplying changes..."));
|
|
27571
27665
|
executePlan(plan2);
|
|
27572
|
-
console.log(
|
|
27666
|
+
console.log(chalk202.green("\nRestructuring complete"));
|
|
27573
27667
|
} else {
|
|
27574
|
-
console.log(
|
|
27668
|
+
console.log(chalk202.dim("\nDry run. Use --apply to execute."));
|
|
27575
27669
|
}
|
|
27576
27670
|
}
|
|
27577
27671
|
|
|
@@ -27894,7 +27988,7 @@ function gatherContext() {
|
|
|
27894
27988
|
}
|
|
27895
27989
|
|
|
27896
27990
|
// src/commands/review/postReviewToPr.ts
|
|
27897
|
-
import { readFileSync as
|
|
27991
|
+
import { readFileSync as readFileSync44 } from "fs";
|
|
27898
27992
|
|
|
27899
27993
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
27900
27994
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -28229,18 +28323,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
28229
28323
|
}
|
|
28230
28324
|
|
|
28231
28325
|
// src/commands/review/warnOutOfDiff.ts
|
|
28232
|
-
import
|
|
28326
|
+
import chalk203 from "chalk";
|
|
28233
28327
|
function warnOutOfDiff(outOfDiff) {
|
|
28234
28328
|
if (outOfDiff.length === 0) return;
|
|
28235
28329
|
console.warn(
|
|
28236
|
-
|
|
28330
|
+
chalk203.yellow(
|
|
28237
28331
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
28238
28332
|
)
|
|
28239
28333
|
);
|
|
28240
28334
|
for (const finding of outOfDiff) {
|
|
28241
28335
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
28242
28336
|
console.warn(
|
|
28243
|
-
` ${
|
|
28337
|
+
` ${chalk203.yellow("\xB7")} ${finding.title} ${chalk203.dim(
|
|
28244
28338
|
`(${finding.file}:${range})`
|
|
28245
28339
|
)}`
|
|
28246
28340
|
);
|
|
@@ -28264,18 +28358,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
28264
28358
|
}
|
|
28265
28359
|
|
|
28266
28360
|
// src/commands/review/warnUnlocated.ts
|
|
28267
|
-
import
|
|
28361
|
+
import chalk204 from "chalk";
|
|
28268
28362
|
function warnUnlocated(unlocated) {
|
|
28269
28363
|
if (unlocated.length === 0) return;
|
|
28270
28364
|
console.warn(
|
|
28271
|
-
|
|
28365
|
+
chalk204.yellow(
|
|
28272
28366
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
28273
28367
|
)
|
|
28274
28368
|
);
|
|
28275
28369
|
for (const finding of unlocated) {
|
|
28276
|
-
const where = finding.location ||
|
|
28370
|
+
const where = finding.location || chalk204.dim("missing");
|
|
28277
28371
|
console.warn(
|
|
28278
|
-
` ${
|
|
28372
|
+
` ${chalk204.yellow("\xB7")} ${finding.title} ${chalk204.dim(`(${where})`)}`
|
|
28279
28373
|
);
|
|
28280
28374
|
}
|
|
28281
28375
|
}
|
|
@@ -28342,7 +28436,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
28342
28436
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
28343
28437
|
}
|
|
28344
28438
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
28345
|
-
const markdown =
|
|
28439
|
+
const markdown = readFileSync44(synthesisPath, "utf8");
|
|
28346
28440
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
28347
28441
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
28348
28442
|
if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
|
|
@@ -28478,16 +28572,16 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
28478
28572
|
}
|
|
28479
28573
|
|
|
28480
28574
|
// src/commands/review/prepareReviewDir.ts
|
|
28481
|
-
import { existsSync as
|
|
28575
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
28482
28576
|
function clearReviewFiles(paths) {
|
|
28483
28577
|
for (const path80 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
28484
|
-
if (
|
|
28578
|
+
if (existsSync56(path80)) unlinkSync17(path80);
|
|
28485
28579
|
}
|
|
28486
28580
|
}
|
|
28487
28581
|
function prepareReviewDir(paths, requestBody, force) {
|
|
28488
|
-
|
|
28582
|
+
mkdirSync21(paths.reviewDir, { recursive: true });
|
|
28489
28583
|
if (force) clearReviewFiles(paths);
|
|
28490
|
-
|
|
28584
|
+
writeFileSync38(paths.requestPath, requestBody);
|
|
28491
28585
|
}
|
|
28492
28586
|
|
|
28493
28587
|
// src/commands/review/cachedReviewerResult.ts
|
|
@@ -28708,7 +28802,7 @@ function printReviewerFailures(results) {
|
|
|
28708
28802
|
}
|
|
28709
28803
|
|
|
28710
28804
|
// src/commands/review/runAndSynthesise.ts
|
|
28711
|
-
import { existsSync as
|
|
28805
|
+
import { existsSync as existsSync58, unlinkSync as unlinkSync19 } from "fs";
|
|
28712
28806
|
|
|
28713
28807
|
// src/commands/review/buildReviewerStdin.ts
|
|
28714
28808
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
|
|
@@ -28783,7 +28877,7 @@ The review request is at: ${requestPath}
|
|
|
28783
28877
|
}
|
|
28784
28878
|
|
|
28785
28879
|
// src/commands/review/runClaudeReviewer.ts
|
|
28786
|
-
import { writeFileSync as
|
|
28880
|
+
import { writeFileSync as writeFileSync39 } from "fs";
|
|
28787
28881
|
|
|
28788
28882
|
// src/commands/review/finaliseReviewerSpinner.ts
|
|
28789
28883
|
var SUMMARY_MAX_LEN = 80;
|
|
@@ -29119,7 +29213,7 @@ async function runClaudeReviewer(spec) {
|
|
|
29119
29213
|
}
|
|
29120
29214
|
});
|
|
29121
29215
|
if (result.exitCode === 0 && finalText)
|
|
29122
|
-
|
|
29216
|
+
writeFileSync39(spec.outputPath, finalText);
|
|
29123
29217
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
29124
29218
|
}
|
|
29125
29219
|
|
|
@@ -29137,7 +29231,7 @@ function resolveClaude(args) {
|
|
|
29137
29231
|
}
|
|
29138
29232
|
|
|
29139
29233
|
// src/commands/review/runCodexReviewer.ts
|
|
29140
|
-
import { existsSync as
|
|
29234
|
+
import { existsSync as existsSync57, unlinkSync as unlinkSync18 } from "fs";
|
|
29141
29235
|
|
|
29142
29236
|
// src/commands/review/parseCodexEvent.ts
|
|
29143
29237
|
function isItemStarted(value) {
|
|
@@ -29189,7 +29283,7 @@ async function runCodexReviewer(spec) {
|
|
|
29189
29283
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
29190
29284
|
}
|
|
29191
29285
|
});
|
|
29192
|
-
if (result.exitCode !== 0 &&
|
|
29286
|
+
if (result.exitCode !== 0 && existsSync57(spec.outputPath)) {
|
|
29193
29287
|
unlinkSync18(spec.outputPath);
|
|
29194
29288
|
}
|
|
29195
29289
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -29231,7 +29325,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
29231
29325
|
}
|
|
29232
29326
|
|
|
29233
29327
|
// src/commands/review/synthesise.ts
|
|
29234
|
-
import { readFileSync as
|
|
29328
|
+
import { readFileSync as readFileSync45 } from "fs";
|
|
29235
29329
|
|
|
29236
29330
|
// src/commands/review/buildSynthesisStdin.ts
|
|
29237
29331
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -29296,7 +29390,7 @@ Files:
|
|
|
29296
29390
|
|
|
29297
29391
|
// src/commands/review/synthesise.ts
|
|
29298
29392
|
function printSummary2(synthesisPath) {
|
|
29299
|
-
const markdown =
|
|
29393
|
+
const markdown = readFileSync45(synthesisPath, "utf8");
|
|
29300
29394
|
console.log("");
|
|
29301
29395
|
console.log(buildReviewSummary(markdown));
|
|
29302
29396
|
console.log("");
|
|
@@ -29344,7 +29438,7 @@ async function runAndSynthesise(args) {
|
|
|
29344
29438
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
29345
29439
|
return { ok: false, failures };
|
|
29346
29440
|
}
|
|
29347
|
-
if (anyFresh &&
|
|
29441
|
+
if (anyFresh && existsSync58(paths.synthesisPath)) {
|
|
29348
29442
|
unlinkSync19(paths.synthesisPath);
|
|
29349
29443
|
}
|
|
29350
29444
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -29530,7 +29624,7 @@ function registerReview(program2) {
|
|
|
29530
29624
|
}
|
|
29531
29625
|
|
|
29532
29626
|
// src/commands/seq/seqAuth.ts
|
|
29533
|
-
import
|
|
29627
|
+
import chalk206 from "chalk";
|
|
29534
29628
|
|
|
29535
29629
|
// src/commands/seq/loadConnections.ts
|
|
29536
29630
|
function loadConnections2() {
|
|
@@ -29559,10 +29653,10 @@ function setDefaultConnection(name) {
|
|
|
29559
29653
|
}
|
|
29560
29654
|
|
|
29561
29655
|
// src/shared/assertUniqueName.ts
|
|
29562
|
-
import
|
|
29656
|
+
import chalk205 from "chalk";
|
|
29563
29657
|
function assertUniqueName(existingNames, name) {
|
|
29564
29658
|
if (existingNames.includes(name)) {
|
|
29565
|
-
console.error(
|
|
29659
|
+
console.error(chalk205.red(`Connection "${name}" already exists.`));
|
|
29566
29660
|
process.exit(1);
|
|
29567
29661
|
}
|
|
29568
29662
|
}
|
|
@@ -29580,16 +29674,16 @@ async function promptConnection2(existingNames) {
|
|
|
29580
29674
|
var seqAuth = createConnectionAuth({
|
|
29581
29675
|
load: loadConnections2,
|
|
29582
29676
|
save: saveConnections2,
|
|
29583
|
-
format: (c) => `${
|
|
29677
|
+
format: (c) => `${chalk206.bold(c.name)} ${c.url}`,
|
|
29584
29678
|
promptNew: promptConnection2,
|
|
29585
29679
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
29586
29680
|
});
|
|
29587
29681
|
|
|
29588
29682
|
// src/commands/seq/seqQuery.ts
|
|
29589
|
-
import
|
|
29683
|
+
import chalk210 from "chalk";
|
|
29590
29684
|
|
|
29591
29685
|
// src/commands/seq/fetchSeq.ts
|
|
29592
|
-
import
|
|
29686
|
+
import chalk207 from "chalk";
|
|
29593
29687
|
async function fetchSeq(conn, path80, params) {
|
|
29594
29688
|
const url = `${conn.url}${path80}?${params}`;
|
|
29595
29689
|
const response = await fetch(url, {
|
|
@@ -29600,7 +29694,7 @@ async function fetchSeq(conn, path80, params) {
|
|
|
29600
29694
|
});
|
|
29601
29695
|
if (!response.ok) {
|
|
29602
29696
|
const body = await response.text();
|
|
29603
|
-
console.error(
|
|
29697
|
+
console.error(chalk207.red(`Seq returned ${response.status}: ${body}`));
|
|
29604
29698
|
process.exit(1);
|
|
29605
29699
|
}
|
|
29606
29700
|
return response;
|
|
@@ -29659,23 +29753,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
29659
29753
|
}
|
|
29660
29754
|
|
|
29661
29755
|
// src/commands/seq/formatEvent.ts
|
|
29662
|
-
import
|
|
29756
|
+
import chalk208 from "chalk";
|
|
29663
29757
|
function levelColor(level) {
|
|
29664
29758
|
switch (level) {
|
|
29665
29759
|
case "Fatal":
|
|
29666
|
-
return
|
|
29760
|
+
return chalk208.bgRed.white;
|
|
29667
29761
|
case "Error":
|
|
29668
|
-
return
|
|
29762
|
+
return chalk208.red;
|
|
29669
29763
|
case "Warning":
|
|
29670
|
-
return
|
|
29764
|
+
return chalk208.yellow;
|
|
29671
29765
|
case "Information":
|
|
29672
|
-
return
|
|
29766
|
+
return chalk208.cyan;
|
|
29673
29767
|
case "Debug":
|
|
29674
|
-
return
|
|
29768
|
+
return chalk208.gray;
|
|
29675
29769
|
case "Verbose":
|
|
29676
|
-
return
|
|
29770
|
+
return chalk208.dim;
|
|
29677
29771
|
default:
|
|
29678
|
-
return
|
|
29772
|
+
return chalk208.white;
|
|
29679
29773
|
}
|
|
29680
29774
|
}
|
|
29681
29775
|
function levelAbbrev(level) {
|
|
@@ -29716,12 +29810,12 @@ function formatTimestamp(iso) {
|
|
|
29716
29810
|
function formatEvent(event) {
|
|
29717
29811
|
const color = levelColor(event.Level);
|
|
29718
29812
|
const abbrev = levelAbbrev(event.Level);
|
|
29719
|
-
const ts8 =
|
|
29813
|
+
const ts8 = chalk208.dim(formatTimestamp(event.Timestamp));
|
|
29720
29814
|
const msg = renderMessage(event);
|
|
29721
29815
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
29722
29816
|
if (event.Exception) {
|
|
29723
29817
|
for (const line of event.Exception.split("\n")) {
|
|
29724
|
-
lines2.push(
|
|
29818
|
+
lines2.push(chalk208.red(` ${line}`));
|
|
29725
29819
|
}
|
|
29726
29820
|
}
|
|
29727
29821
|
return lines2.join("\n");
|
|
@@ -29754,11 +29848,11 @@ function rejectTimestampFilter(filter) {
|
|
|
29754
29848
|
}
|
|
29755
29849
|
|
|
29756
29850
|
// src/shared/resolveNamedConnection.ts
|
|
29757
|
-
import
|
|
29851
|
+
import chalk209 from "chalk";
|
|
29758
29852
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
29759
29853
|
if (connections.length === 0) {
|
|
29760
29854
|
console.error(
|
|
29761
|
-
|
|
29855
|
+
chalk209.red(
|
|
29762
29856
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
29763
29857
|
)
|
|
29764
29858
|
);
|
|
@@ -29767,7 +29861,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
29767
29861
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
29768
29862
|
const connection = connections.find((c) => c.name === target);
|
|
29769
29863
|
if (!connection) {
|
|
29770
|
-
console.error(
|
|
29864
|
+
console.error(chalk209.red(`${kind} connection "${target}" not found.`));
|
|
29771
29865
|
process.exit(1);
|
|
29772
29866
|
}
|
|
29773
29867
|
return connection;
|
|
@@ -29796,7 +29890,7 @@ async function seqQuery(filter, options2) {
|
|
|
29796
29890
|
new URLSearchParams({ filter, count: String(count8) })
|
|
29797
29891
|
);
|
|
29798
29892
|
if (events.length === 0) {
|
|
29799
|
-
console.log(
|
|
29893
|
+
console.log(chalk210.yellow("No events found."));
|
|
29800
29894
|
return;
|
|
29801
29895
|
}
|
|
29802
29896
|
if (options2.json) {
|
|
@@ -29807,11 +29901,11 @@ async function seqQuery(filter, options2) {
|
|
|
29807
29901
|
for (const event of chronological) {
|
|
29808
29902
|
console.log(formatEvent(event));
|
|
29809
29903
|
}
|
|
29810
|
-
console.log(
|
|
29904
|
+
console.log(chalk210.dim(`
|
|
29811
29905
|
${events.length} events`));
|
|
29812
29906
|
if (events.length >= count8) {
|
|
29813
29907
|
console.log(
|
|
29814
|
-
|
|
29908
|
+
chalk210.yellow(
|
|
29815
29909
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
29816
29910
|
)
|
|
29817
29911
|
);
|
|
@@ -29819,10 +29913,10 @@ ${events.length} events`));
|
|
|
29819
29913
|
}
|
|
29820
29914
|
|
|
29821
29915
|
// src/shared/setNamedDefaultConnection.ts
|
|
29822
|
-
import
|
|
29916
|
+
import chalk211 from "chalk";
|
|
29823
29917
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
29824
29918
|
if (!connections.find((c) => c.name === name)) {
|
|
29825
|
-
console.error(
|
|
29919
|
+
console.error(chalk211.red(`Connection "${name}" not found.`));
|
|
29826
29920
|
process.exit(1);
|
|
29827
29921
|
}
|
|
29828
29922
|
setDefault(name);
|
|
@@ -29871,7 +29965,7 @@ function registerSignal(program2) {
|
|
|
29871
29965
|
}
|
|
29872
29966
|
|
|
29873
29967
|
// src/commands/sql/sqlAuth.ts
|
|
29874
|
-
import
|
|
29968
|
+
import chalk213 from "chalk";
|
|
29875
29969
|
|
|
29876
29970
|
// src/commands/sql/loadConnections.ts
|
|
29877
29971
|
function loadConnections3() {
|
|
@@ -29900,7 +29994,7 @@ function setDefaultConnection2(name) {
|
|
|
29900
29994
|
}
|
|
29901
29995
|
|
|
29902
29996
|
// src/commands/sql/promptConnection.ts
|
|
29903
|
-
import
|
|
29997
|
+
import chalk212 from "chalk";
|
|
29904
29998
|
async function promptConnection3(existingNames) {
|
|
29905
29999
|
const name = await promptInput("name", "Connection name:", "default");
|
|
29906
30000
|
assertUniqueName(existingNames, name);
|
|
@@ -29908,7 +30002,7 @@ async function promptConnection3(existingNames) {
|
|
|
29908
30002
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
29909
30003
|
const port = Number.parseInt(portStr, 10);
|
|
29910
30004
|
if (!Number.isFinite(port)) {
|
|
29911
|
-
console.error(
|
|
30005
|
+
console.error(chalk212.red(`Invalid port "${portStr}".`));
|
|
29912
30006
|
process.exit(1);
|
|
29913
30007
|
}
|
|
29914
30008
|
const user = await promptInput("user", "User:");
|
|
@@ -29921,13 +30015,13 @@ async function promptConnection3(existingNames) {
|
|
|
29921
30015
|
var sqlAuth = createConnectionAuth({
|
|
29922
30016
|
load: loadConnections3,
|
|
29923
30017
|
save: saveConnections3,
|
|
29924
|
-
format: (c) => `${
|
|
30018
|
+
format: (c) => `${chalk213.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
29925
30019
|
promptNew: promptConnection3,
|
|
29926
30020
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
29927
30021
|
});
|
|
29928
30022
|
|
|
29929
30023
|
// src/commands/sql/printTable.ts
|
|
29930
|
-
import
|
|
30024
|
+
import chalk214 from "chalk";
|
|
29931
30025
|
function formatCell(value) {
|
|
29932
30026
|
if (value === null || value === void 0) return "";
|
|
29933
30027
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -29936,7 +30030,7 @@ function formatCell(value) {
|
|
|
29936
30030
|
}
|
|
29937
30031
|
function printTable(rows) {
|
|
29938
30032
|
if (rows.length === 0) {
|
|
29939
|
-
console.log(
|
|
30033
|
+
console.log(chalk214.yellow("(no rows)"));
|
|
29940
30034
|
return;
|
|
29941
30035
|
}
|
|
29942
30036
|
const columns = Object.keys(rows[0]);
|
|
@@ -29944,13 +30038,13 @@ function printTable(rows) {
|
|
|
29944
30038
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
29945
30039
|
);
|
|
29946
30040
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
29947
|
-
console.log(
|
|
29948
|
-
console.log(
|
|
30041
|
+
console.log(chalk214.dim(header));
|
|
30042
|
+
console.log(chalk214.dim("-".repeat(header.length)));
|
|
29949
30043
|
for (const row of rows) {
|
|
29950
30044
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
29951
30045
|
console.log(line);
|
|
29952
30046
|
}
|
|
29953
|
-
console.log(
|
|
30047
|
+
console.log(chalk214.dim(`
|
|
29954
30048
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
29955
30049
|
}
|
|
29956
30050
|
|
|
@@ -30010,7 +30104,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
30010
30104
|
}
|
|
30011
30105
|
|
|
30012
30106
|
// src/commands/sql/sqlMutate.ts
|
|
30013
|
-
import
|
|
30107
|
+
import chalk215 from "chalk";
|
|
30014
30108
|
|
|
30015
30109
|
// src/commands/sql/isMutation.ts
|
|
30016
30110
|
var MUTATION_KEYWORDS = [
|
|
@@ -30044,7 +30138,7 @@ function isMutation(sql25) {
|
|
|
30044
30138
|
async function sqlMutate(query, connectionName) {
|
|
30045
30139
|
if (!isMutation(query)) {
|
|
30046
30140
|
console.error(
|
|
30047
|
-
|
|
30141
|
+
chalk215.red(
|
|
30048
30142
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
30049
30143
|
)
|
|
30050
30144
|
);
|
|
@@ -30054,18 +30148,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
30054
30148
|
const pool = await sqlConnect(conn);
|
|
30055
30149
|
try {
|
|
30056
30150
|
const result = await pool.request().query(query);
|
|
30057
|
-
console.log(
|
|
30151
|
+
console.log(chalk215.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
30058
30152
|
} finally {
|
|
30059
30153
|
await pool.close();
|
|
30060
30154
|
}
|
|
30061
30155
|
}
|
|
30062
30156
|
|
|
30063
30157
|
// src/commands/sql/sqlQuery.ts
|
|
30064
|
-
import
|
|
30158
|
+
import chalk216 from "chalk";
|
|
30065
30159
|
async function sqlQuery(query, connectionName) {
|
|
30066
30160
|
if (isMutation(query)) {
|
|
30067
30161
|
console.error(
|
|
30068
|
-
|
|
30162
|
+
chalk216.red(
|
|
30069
30163
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
30070
30164
|
)
|
|
30071
30165
|
);
|
|
@@ -30080,7 +30174,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
30080
30174
|
printTable(rows);
|
|
30081
30175
|
} else {
|
|
30082
30176
|
console.log(
|
|
30083
|
-
|
|
30177
|
+
chalk216.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
30084
30178
|
);
|
|
30085
30179
|
}
|
|
30086
30180
|
} finally {
|
|
@@ -30225,7 +30319,7 @@ function reportPrune(label2, result, force) {
|
|
|
30225
30319
|
// src/commands/sync/syncClaudeMd.ts
|
|
30226
30320
|
import * as fs41 from "fs";
|
|
30227
30321
|
import * as path66 from "path";
|
|
30228
|
-
import
|
|
30322
|
+
import chalk217 from "chalk";
|
|
30229
30323
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
30230
30324
|
const source = path66.join(claudeDir, "CLAUDE.md");
|
|
30231
30325
|
const target = path66.join(targetBase, "CLAUDE.md");
|
|
@@ -30234,14 +30328,14 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
30234
30328
|
const targetContent = fs41.readFileSync(target, "utf8");
|
|
30235
30329
|
if (sourceContent !== targetContent) {
|
|
30236
30330
|
console.log(
|
|
30237
|
-
|
|
30331
|
+
chalk217.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
30238
30332
|
);
|
|
30239
30333
|
console.log();
|
|
30240
30334
|
printDiff(targetContent, sourceContent);
|
|
30241
30335
|
if (!options2?.yes) {
|
|
30242
30336
|
printAutoConfirmHint();
|
|
30243
30337
|
const confirm = await promptConfirm(
|
|
30244
|
-
|
|
30338
|
+
chalk217.red("Overwrite existing CLAUDE.md?"),
|
|
30245
30339
|
false
|
|
30246
30340
|
);
|
|
30247
30341
|
if (!confirm) {
|
|
@@ -30474,7 +30568,7 @@ function syncPi(claudeDir, options2) {
|
|
|
30474
30568
|
// src/commands/sync/syncSettings.ts
|
|
30475
30569
|
import * as fs47 from "fs";
|
|
30476
30570
|
import * as path73 from "path";
|
|
30477
|
-
import
|
|
30571
|
+
import chalk218 from "chalk";
|
|
30478
30572
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
30479
30573
|
const source = path73.join(claudeDir, "settings.json");
|
|
30480
30574
|
const target = path73.join(targetBase, "settings.json");
|
|
@@ -30493,7 +30587,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
30493
30587
|
if (mergedContent !== normalizedTarget) {
|
|
30494
30588
|
if (!options2?.yes) {
|
|
30495
30589
|
console.log(
|
|
30496
|
-
|
|
30590
|
+
chalk218.yellow(
|
|
30497
30591
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
30498
30592
|
)
|
|
30499
30593
|
);
|
|
@@ -30501,7 +30595,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
30501
30595
|
printDiff(targetContent, mergedContent);
|
|
30502
30596
|
printAutoConfirmHint();
|
|
30503
30597
|
const confirm = await promptConfirm(
|
|
30504
|
-
|
|
30598
|
+
chalk218.red("Overwrite existing settings.json?"),
|
|
30505
30599
|
false
|
|
30506
30600
|
);
|
|
30507
30601
|
if (!confirm) {
|
|
@@ -30643,11 +30737,11 @@ async function configure() {
|
|
|
30643
30737
|
}
|
|
30644
30738
|
|
|
30645
30739
|
// src/commands/transcript/list.ts
|
|
30646
|
-
import { existsSync as
|
|
30740
|
+
import { existsSync as existsSync63, readdirSync as readdirSync19, statSync as statSync10 } from "fs";
|
|
30647
30741
|
import { join as join77 } from "path";
|
|
30648
30742
|
function list4() {
|
|
30649
30743
|
const { vttDir } = getTranscriptConfig();
|
|
30650
|
-
if (!
|
|
30744
|
+
if (!existsSync63(vttDir)) return;
|
|
30651
30745
|
for (const entry of readdirSync19(vttDir)) {
|
|
30652
30746
|
if (!entry.endsWith(".vtt")) continue;
|
|
30653
30747
|
if (statSync10(join77(vttDir, entry)).isDirectory()) continue;
|
|
@@ -30657,11 +30751,11 @@ function list4() {
|
|
|
30657
30751
|
|
|
30658
30752
|
// src/commands/transcript/move.ts
|
|
30659
30753
|
import {
|
|
30660
|
-
existsSync as
|
|
30661
|
-
mkdirSync as
|
|
30662
|
-
readFileSync as
|
|
30754
|
+
existsSync as existsSync64,
|
|
30755
|
+
mkdirSync as mkdirSync27,
|
|
30756
|
+
readFileSync as readFileSync50,
|
|
30663
30757
|
renameSync as renameSync2,
|
|
30664
|
-
writeFileSync as
|
|
30758
|
+
writeFileSync as writeFileSync43
|
|
30665
30759
|
} from "fs";
|
|
30666
30760
|
import { basename as basename21, join as join78 } from "path";
|
|
30667
30761
|
|
|
@@ -30871,13 +30965,13 @@ function formatChatLog(messages) {
|
|
|
30871
30965
|
// src/commands/transcript/move.ts
|
|
30872
30966
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
30873
30967
|
function convertVttToMarkdown(inputPath) {
|
|
30874
|
-
const cues = parseVtt(
|
|
30968
|
+
const cues = parseVtt(readFileSync50(inputPath, "utf8"));
|
|
30875
30969
|
const messages = cuesToChatMessages(deduplicateCues(cues));
|
|
30876
30970
|
return formatChatLog(messages);
|
|
30877
30971
|
}
|
|
30878
30972
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
30879
30973
|
const processedDir = join78(vttDir, "processed");
|
|
30880
|
-
|
|
30974
|
+
mkdirSync27(processedDir, { recursive: true });
|
|
30881
30975
|
renameSync2(sourcePath, join78(processedDir, filename));
|
|
30882
30976
|
}
|
|
30883
30977
|
function move(file, options2) {
|
|
@@ -30889,16 +30983,16 @@ function move(file, options2) {
|
|
|
30889
30983
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
30890
30984
|
const filename = basename21(file);
|
|
30891
30985
|
const sourcePath = join78(vttDir, filename);
|
|
30892
|
-
if (!
|
|
30986
|
+
if (!existsSync64(sourcePath)) {
|
|
30893
30987
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
30894
30988
|
process.exit(1);
|
|
30895
30989
|
}
|
|
30896
30990
|
const base = basename21(filename, ".vtt").replace(/ Transcription$/, "");
|
|
30897
30991
|
const outputName = `${date} ${base}.md`;
|
|
30898
30992
|
const formattedDir = join78(transcriptsDir, client);
|
|
30899
|
-
|
|
30993
|
+
mkdirSync27(formattedDir, { recursive: true });
|
|
30900
30994
|
const formattedPath = join78(formattedDir, outputName);
|
|
30901
|
-
|
|
30995
|
+
writeFileSync43(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
30902
30996
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
30903
30997
|
const summaryPath = join78(summaryDir, client, outputName);
|
|
30904
30998
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
@@ -30986,9 +31080,9 @@ import { join as join80 } from "path";
|
|
|
30986
31080
|
|
|
30987
31081
|
// src/commands/voice/shared.ts
|
|
30988
31082
|
import { homedir as homedir24 } from "os";
|
|
30989
|
-
import { dirname as
|
|
31083
|
+
import { dirname as dirname35, join as join79 } from "path";
|
|
30990
31084
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
30991
|
-
var __dirname6 =
|
|
31085
|
+
var __dirname6 = dirname35(fileURLToPath8(import.meta.url));
|
|
30992
31086
|
var VOICE_DIR = join79(homedir24(), ".assist", "voice");
|
|
30993
31087
|
var voicePaths = {
|
|
30994
31088
|
dir: VOICE_DIR,
|
|
@@ -31018,14 +31112,14 @@ function devices() {
|
|
|
31018
31112
|
}
|
|
31019
31113
|
|
|
31020
31114
|
// src/commands/voice/logs.ts
|
|
31021
|
-
import { existsSync as
|
|
31115
|
+
import { existsSync as existsSync65, readFileSync as readFileSync51 } from "fs";
|
|
31022
31116
|
function logs(options2) {
|
|
31023
|
-
if (!
|
|
31117
|
+
if (!existsSync65(voicePaths.log)) {
|
|
31024
31118
|
console.log("No voice log file found");
|
|
31025
31119
|
return;
|
|
31026
31120
|
}
|
|
31027
31121
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
31028
|
-
const content =
|
|
31122
|
+
const content = readFileSync51(voicePaths.log, "utf8").trim();
|
|
31029
31123
|
if (!content) {
|
|
31030
31124
|
console.log("Voice log is empty");
|
|
31031
31125
|
return;
|
|
@@ -31047,12 +31141,12 @@ function logs(options2) {
|
|
|
31047
31141
|
|
|
31048
31142
|
// src/commands/voice/setup.ts
|
|
31049
31143
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
31050
|
-
import { mkdirSync as
|
|
31144
|
+
import { mkdirSync as mkdirSync29 } from "fs";
|
|
31051
31145
|
import { join as join82 } from "path";
|
|
31052
31146
|
|
|
31053
31147
|
// src/commands/voice/checkLockFile.ts
|
|
31054
31148
|
import { execSync as execSync58 } from "child_process";
|
|
31055
|
-
import { existsSync as
|
|
31149
|
+
import { existsSync as existsSync66, mkdirSync as mkdirSync28, readFileSync as readFileSync52, writeFileSync as writeFileSync44 } from "fs";
|
|
31056
31150
|
import { join as join81 } from "path";
|
|
31057
31151
|
function isProcessAlive2(pid) {
|
|
31058
31152
|
try {
|
|
@@ -31064,9 +31158,9 @@ function isProcessAlive2(pid) {
|
|
|
31064
31158
|
}
|
|
31065
31159
|
function checkLockFile() {
|
|
31066
31160
|
const lockFile = getLockFile();
|
|
31067
|
-
if (!
|
|
31161
|
+
if (!existsSync66(lockFile)) return;
|
|
31068
31162
|
try {
|
|
31069
|
-
const lock2 = JSON.parse(
|
|
31163
|
+
const lock2 = JSON.parse(readFileSync52(lockFile, "utf8"));
|
|
31070
31164
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
31071
31165
|
console.error(
|
|
31072
31166
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -31077,7 +31171,7 @@ function checkLockFile() {
|
|
|
31077
31171
|
}
|
|
31078
31172
|
}
|
|
31079
31173
|
function bootstrapVenv() {
|
|
31080
|
-
if (
|
|
31174
|
+
if (existsSync66(getVenvPython())) return;
|
|
31081
31175
|
console.log("Setting up Python environment...");
|
|
31082
31176
|
const pythonDir = getPythonDir();
|
|
31083
31177
|
execSync58(
|
|
@@ -31090,8 +31184,8 @@ function bootstrapVenv() {
|
|
|
31090
31184
|
}
|
|
31091
31185
|
function writeLockFile(pid) {
|
|
31092
31186
|
const lockFile = getLockFile();
|
|
31093
|
-
|
|
31094
|
-
|
|
31187
|
+
mkdirSync28(join81(lockFile, ".."), { recursive: true });
|
|
31188
|
+
writeFileSync44(
|
|
31095
31189
|
lockFile,
|
|
31096
31190
|
JSON.stringify({
|
|
31097
31191
|
pid,
|
|
@@ -31103,7 +31197,7 @@ function writeLockFile(pid) {
|
|
|
31103
31197
|
|
|
31104
31198
|
// src/commands/voice/setup.ts
|
|
31105
31199
|
function setup() {
|
|
31106
|
-
|
|
31200
|
+
mkdirSync29(voicePaths.dir, { recursive: true });
|
|
31107
31201
|
bootstrapVenv();
|
|
31108
31202
|
console.log("\nDownloading models...\n");
|
|
31109
31203
|
const script = join82(getPythonDir(), "setup_models.py");
|
|
@@ -31119,7 +31213,7 @@ function setup() {
|
|
|
31119
31213
|
|
|
31120
31214
|
// src/commands/voice/start.ts
|
|
31121
31215
|
import { spawn as spawn8 } from "child_process";
|
|
31122
|
-
import { mkdirSync as
|
|
31216
|
+
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync45 } from "fs";
|
|
31123
31217
|
import { join as join83 } from "path";
|
|
31124
31218
|
|
|
31125
31219
|
// src/commands/voice/buildDaemonEnv.ts
|
|
@@ -31148,12 +31242,12 @@ function spawnBackground(python, script, env) {
|
|
|
31148
31242
|
console.error("Failed to start voice daemon");
|
|
31149
31243
|
process.exit(1);
|
|
31150
31244
|
}
|
|
31151
|
-
|
|
31245
|
+
writeFileSync45(voicePaths.pid, String(pid));
|
|
31152
31246
|
writeLockFile(pid);
|
|
31153
31247
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
31154
31248
|
}
|
|
31155
31249
|
function start2(options2) {
|
|
31156
|
-
|
|
31250
|
+
mkdirSync30(voicePaths.dir, { recursive: true });
|
|
31157
31251
|
checkLockFile();
|
|
31158
31252
|
bootstrapVenv();
|
|
31159
31253
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
@@ -31168,7 +31262,7 @@ function start2(options2) {
|
|
|
31168
31262
|
}
|
|
31169
31263
|
|
|
31170
31264
|
// src/commands/voice/status.ts
|
|
31171
|
-
import { existsSync as
|
|
31265
|
+
import { existsSync as existsSync67, readFileSync as readFileSync53 } from "fs";
|
|
31172
31266
|
function isProcessAlive3(pid) {
|
|
31173
31267
|
try {
|
|
31174
31268
|
process.kill(pid, 0);
|
|
@@ -31178,16 +31272,16 @@ function isProcessAlive3(pid) {
|
|
|
31178
31272
|
}
|
|
31179
31273
|
}
|
|
31180
31274
|
function readRecentLogs(count8) {
|
|
31181
|
-
if (!
|
|
31182
|
-
const lines2 =
|
|
31275
|
+
if (!existsSync67(voicePaths.log)) return [];
|
|
31276
|
+
const lines2 = readFileSync53(voicePaths.log, "utf8").trim().split("\n");
|
|
31183
31277
|
return lines2.slice(-count8);
|
|
31184
31278
|
}
|
|
31185
31279
|
function status2() {
|
|
31186
|
-
if (!
|
|
31280
|
+
if (!existsSync67(voicePaths.pid)) {
|
|
31187
31281
|
console.log("Voice daemon: not running (no PID file)");
|
|
31188
31282
|
return;
|
|
31189
31283
|
}
|
|
31190
|
-
const pid = Number.parseInt(
|
|
31284
|
+
const pid = Number.parseInt(readFileSync53(voicePaths.pid, "utf8").trim(), 10);
|
|
31191
31285
|
const alive = isProcessAlive3(pid);
|
|
31192
31286
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
31193
31287
|
const recent = readRecentLogs(5);
|
|
@@ -31206,13 +31300,13 @@ function status2() {
|
|
|
31206
31300
|
}
|
|
31207
31301
|
|
|
31208
31302
|
// src/commands/voice/stop.ts
|
|
31209
|
-
import { existsSync as
|
|
31303
|
+
import { existsSync as existsSync68, readFileSync as readFileSync54, unlinkSync as unlinkSync20 } from "fs";
|
|
31210
31304
|
function stop2() {
|
|
31211
|
-
if (!
|
|
31305
|
+
if (!existsSync68(voicePaths.pid)) {
|
|
31212
31306
|
console.log("Voice daemon is not running (no PID file)");
|
|
31213
31307
|
return;
|
|
31214
31308
|
}
|
|
31215
|
-
const pid = Number.parseInt(
|
|
31309
|
+
const pid = Number.parseInt(readFileSync54(voicePaths.pid, "utf8").trim(), 10);
|
|
31216
31310
|
try {
|
|
31217
31311
|
process.kill(pid, "SIGTERM");
|
|
31218
31312
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -31225,7 +31319,7 @@ function stop2() {
|
|
|
31225
31319
|
}
|
|
31226
31320
|
try {
|
|
31227
31321
|
const lockFile = getLockFile();
|
|
31228
|
-
if (
|
|
31322
|
+
if (existsSync68(lockFile)) unlinkSync20(lockFile);
|
|
31229
31323
|
} catch {
|
|
31230
31324
|
}
|
|
31231
31325
|
console.log("Voice daemon stopped");
|
|
@@ -31630,7 +31724,7 @@ function resolveParams(params, cliArgs) {
|
|
|
31630
31724
|
}
|
|
31631
31725
|
|
|
31632
31726
|
// src/commands/run/resolveRunCwd.ts
|
|
31633
|
-
import { existsSync as
|
|
31727
|
+
import { existsSync as existsSync69 } from "fs";
|
|
31634
31728
|
import { resolve as resolve18 } from "path";
|
|
31635
31729
|
var MissingRunCwdError = class extends Error {
|
|
31636
31730
|
constructor(runName, cwd) {
|
|
@@ -31643,25 +31737,25 @@ var MissingRunCwdError = class extends Error {
|
|
|
31643
31737
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
31644
31738
|
if (!config.cwd) return void 0;
|
|
31645
31739
|
const cwd = resolve18(baseDir, config.cwd);
|
|
31646
|
-
if (!
|
|
31740
|
+
if (!existsSync69(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
31647
31741
|
return cwd;
|
|
31648
31742
|
}
|
|
31649
31743
|
|
|
31650
31744
|
// src/commands/run/runCommandToCompletion.ts
|
|
31651
31745
|
import { spawn as spawn9 } from "child_process";
|
|
31652
|
-
import { existsSync as
|
|
31746
|
+
import { existsSync as existsSync71 } from "fs";
|
|
31653
31747
|
|
|
31654
31748
|
// src/commands/run/resolveCommand.ts
|
|
31655
31749
|
import { execFileSync as execFileSync16 } from "child_process";
|
|
31656
|
-
import { existsSync as
|
|
31657
|
-
import { dirname as
|
|
31750
|
+
import { existsSync as existsSync70 } from "fs";
|
|
31751
|
+
import { dirname as dirname36, join as join85, resolve as resolve19 } from "path";
|
|
31658
31752
|
function resolveCommand2(command) {
|
|
31659
31753
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
31660
31754
|
try {
|
|
31661
31755
|
const gitPath = execFileSync16("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
31662
|
-
const gitRoot = resolve19(
|
|
31756
|
+
const gitRoot = resolve19(dirname36(gitPath), "..");
|
|
31663
31757
|
const gitBash = join85(gitRoot, "bin", "bash.exe");
|
|
31664
|
-
if (
|
|
31758
|
+
if (existsSync70(gitBash)) return gitBash;
|
|
31665
31759
|
} catch {
|
|
31666
31760
|
return command;
|
|
31667
31761
|
}
|
|
@@ -31671,7 +31765,7 @@ function resolveCommand2(command) {
|
|
|
31671
31765
|
// src/commands/run/runCommandToCompletion.ts
|
|
31672
31766
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
31673
31767
|
return new Promise((resolveResult) => {
|
|
31674
|
-
if (cwd && !
|
|
31768
|
+
if (cwd && !existsSync71(cwd)) {
|
|
31675
31769
|
resolveResult({
|
|
31676
31770
|
kind: "failed",
|
|
31677
31771
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -31928,7 +32022,7 @@ function registerWatch(program2) {
|
|
|
31928
32022
|
|
|
31929
32023
|
// src/commands/roam/auth.ts
|
|
31930
32024
|
import { randomBytes } from "crypto";
|
|
31931
|
-
import
|
|
32025
|
+
import chalk219 from "chalk";
|
|
31932
32026
|
|
|
31933
32027
|
// src/commands/roam/waitForCallback.ts
|
|
31934
32028
|
import { createServer as createServer3 } from "http";
|
|
@@ -32059,13 +32153,13 @@ async function auth() {
|
|
|
32059
32153
|
saveGlobalConfig(config);
|
|
32060
32154
|
const state = randomBytes(16).toString("hex");
|
|
32061
32155
|
console.log(
|
|
32062
|
-
|
|
32156
|
+
chalk219.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
32063
32157
|
);
|
|
32064
|
-
console.log(
|
|
32065
|
-
console.log(
|
|
32066
|
-
console.log(
|
|
32158
|
+
console.log(chalk219.white("http://localhost:14523/callback\n"));
|
|
32159
|
+
console.log(chalk219.blue("Opening browser for authorization..."));
|
|
32160
|
+
console.log(chalk219.dim("Waiting for authorization callback..."));
|
|
32067
32161
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
32068
|
-
console.log(
|
|
32162
|
+
console.log(chalk219.dim("Exchanging code for tokens..."));
|
|
32069
32163
|
const tokens = await exchangeToken({
|
|
32070
32164
|
code,
|
|
32071
32165
|
clientId,
|
|
@@ -32081,13 +32175,13 @@ async function auth() {
|
|
|
32081
32175
|
};
|
|
32082
32176
|
saveGlobalConfig(config);
|
|
32083
32177
|
console.log(
|
|
32084
|
-
|
|
32178
|
+
chalk219.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
32085
32179
|
);
|
|
32086
32180
|
}
|
|
32087
32181
|
|
|
32088
32182
|
// src/commands/roam/postRoamActivity.ts
|
|
32089
32183
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
32090
|
-
import { readdirSync as readdirSync20, readFileSync as
|
|
32184
|
+
import { readdirSync as readdirSync20, readFileSync as readFileSync55, statSync as statSync11 } from "fs";
|
|
32091
32185
|
import { join as join86 } from "path";
|
|
32092
32186
|
function findPortFile(roamDir) {
|
|
32093
32187
|
let entries;
|
|
@@ -32113,7 +32207,7 @@ function postRoamActivity(app, event) {
|
|
|
32113
32207
|
if (!portFile) return;
|
|
32114
32208
|
let port;
|
|
32115
32209
|
try {
|
|
32116
|
-
port =
|
|
32210
|
+
port = readFileSync55(portFile, "utf8").trim();
|
|
32117
32211
|
} catch {
|
|
32118
32212
|
return;
|
|
32119
32213
|
}
|
|
@@ -32241,7 +32335,7 @@ async function run3(name, args) {
|
|
|
32241
32335
|
}
|
|
32242
32336
|
|
|
32243
32337
|
// src/commands/run/add.ts
|
|
32244
|
-
import { mkdirSync as
|
|
32338
|
+
import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync46 } from "fs";
|
|
32245
32339
|
import { join as join87 } from "path";
|
|
32246
32340
|
|
|
32247
32341
|
// src/commands/run/extractOption.ts
|
|
@@ -32304,7 +32398,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
32304
32398
|
}
|
|
32305
32399
|
function createCommandFile(name) {
|
|
32306
32400
|
const dir = join87(".claude", "commands");
|
|
32307
|
-
|
|
32401
|
+
mkdirSync31(dir, { recursive: true });
|
|
32308
32402
|
const content = `---
|
|
32309
32403
|
description: Run ${name}
|
|
32310
32404
|
---
|
|
@@ -32312,7 +32406,7 @@ description: Run ${name}
|
|
|
32312
32406
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
32313
32407
|
`;
|
|
32314
32408
|
const filePath = join87(dir, `${name}.md`);
|
|
32315
|
-
|
|
32409
|
+
writeFileSync46(filePath, content);
|
|
32316
32410
|
console.log(`Created command file: ${filePath}`);
|
|
32317
32411
|
}
|
|
32318
32412
|
function add3() {
|
|
@@ -32367,7 +32461,7 @@ function link2() {
|
|
|
32367
32461
|
}
|
|
32368
32462
|
|
|
32369
32463
|
// src/commands/run/remove.ts
|
|
32370
|
-
import { existsSync as
|
|
32464
|
+
import { existsSync as existsSync72, unlinkSync as unlinkSync21 } from "fs";
|
|
32371
32465
|
import { join as join88 } from "path";
|
|
32372
32466
|
function findRemoveIndex() {
|
|
32373
32467
|
const idx = process.argv.indexOf("remove");
|
|
@@ -32384,7 +32478,7 @@ function parseRemoveName() {
|
|
|
32384
32478
|
}
|
|
32385
32479
|
function deleteCommandFile(name) {
|
|
32386
32480
|
const filePath = join88(".claude", "commands", `${name}.md`);
|
|
32387
|
-
if (
|
|
32481
|
+
if (existsSync72(filePath)) {
|
|
32388
32482
|
unlinkSync21(filePath);
|
|
32389
32483
|
console.log(`Deleted command file: ${filePath}`);
|
|
32390
32484
|
}
|
|
@@ -32429,10 +32523,10 @@ function registerRun(program2) {
|
|
|
32429
32523
|
|
|
32430
32524
|
// src/commands/screenshot/index.ts
|
|
32431
32525
|
import { execSync as execSync60 } from "child_process";
|
|
32432
|
-
import { existsSync as
|
|
32526
|
+
import { existsSync as existsSync73, mkdirSync as mkdirSync32, unlinkSync as unlinkSync22, writeFileSync as writeFileSync47 } from "fs";
|
|
32433
32527
|
import { tmpdir as tmpdir8 } from "os";
|
|
32434
32528
|
import { join as join89, resolve as resolve20 } from "path";
|
|
32435
|
-
import
|
|
32529
|
+
import chalk220 from "chalk";
|
|
32436
32530
|
|
|
32437
32531
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
32438
32532
|
var captureWindowPs1 = `
|
|
@@ -32561,15 +32655,15 @@ Write-Output $OutputPath
|
|
|
32561
32655
|
|
|
32562
32656
|
// src/commands/screenshot/index.ts
|
|
32563
32657
|
function buildOutputPath(outputDir, processName) {
|
|
32564
|
-
if (!
|
|
32565
|
-
|
|
32658
|
+
if (!existsSync73(outputDir)) {
|
|
32659
|
+
mkdirSync32(outputDir, { recursive: true });
|
|
32566
32660
|
}
|
|
32567
32661
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
32568
32662
|
return resolve20(outputDir, `${processName}-${timestamp6}.png`);
|
|
32569
32663
|
}
|
|
32570
32664
|
function runPowerShellScript(processName, outputPath) {
|
|
32571
32665
|
const scriptPath = join89(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
|
|
32572
|
-
|
|
32666
|
+
writeFileSync47(scriptPath, captureWindowPs1, "utf8");
|
|
32573
32667
|
try {
|
|
32574
32668
|
execSync60(
|
|
32575
32669
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -32583,13 +32677,13 @@ function screenshot(processName) {
|
|
|
32583
32677
|
const config = loadConfig();
|
|
32584
32678
|
const outputDir = resolve20(config.screenshot.outputDir);
|
|
32585
32679
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
32586
|
-
console.log(
|
|
32680
|
+
console.log(chalk220.gray(`Capturing window for process "${processName}" ...`));
|
|
32587
32681
|
try {
|
|
32588
32682
|
runPowerShellScript(processName, outputPath);
|
|
32589
|
-
console.log(
|
|
32683
|
+
console.log(chalk220.green(`Screenshot saved: ${outputPath}`));
|
|
32590
32684
|
} catch (error) {
|
|
32591
32685
|
const msg = error instanceof Error ? error.message : String(error);
|
|
32592
|
-
console.error(
|
|
32686
|
+
console.error(chalk220.red(`Failed to capture screenshot: ${msg}`));
|
|
32593
32687
|
process.exit(1);
|
|
32594
32688
|
}
|
|
32595
32689
|
}
|
|
@@ -32645,11 +32739,11 @@ function applyLine(result, pending, line) {
|
|
|
32645
32739
|
}
|
|
32646
32740
|
|
|
32647
32741
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
32648
|
-
import { readFileSync as
|
|
32742
|
+
import { readFileSync as readFileSync56 } from "fs";
|
|
32649
32743
|
function readDaemonPidFile() {
|
|
32650
32744
|
try {
|
|
32651
32745
|
const pid = Number.parseInt(
|
|
32652
|
-
|
|
32746
|
+
readFileSync56(daemonPaths.pid, "utf8").trim(),
|
|
32653
32747
|
10
|
|
32654
32748
|
);
|
|
32655
32749
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -32802,7 +32896,7 @@ function requestDrain(socket, lines2) {
|
|
|
32802
32896
|
}
|
|
32803
32897
|
|
|
32804
32898
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
32805
|
-
import { mkdirSync as
|
|
32899
|
+
import { mkdirSync as mkdirSync36 } from "fs";
|
|
32806
32900
|
|
|
32807
32901
|
// src/commands/sessions/daemon/createAutoExit.ts
|
|
32808
32902
|
var DEFAULT_GRACE_MS = 6e4;
|
|
@@ -32906,12 +33000,12 @@ function toSessionRunInfo({
|
|
|
32906
33000
|
}
|
|
32907
33001
|
|
|
32908
33002
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
32909
|
-
import { existsSync as
|
|
33003
|
+
import { existsSync as existsSync74 } from "fs";
|
|
32910
33004
|
function joinRefusal(session) {
|
|
32911
33005
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
32912
33006
|
if (session.closing === true) return "the session is closing";
|
|
32913
33007
|
if (!session.cwd) return "the session has no working directory";
|
|
32914
|
-
if (!
|
|
33008
|
+
if (!existsSync74(session.cwd))
|
|
32915
33009
|
return "the session's workspace no longer exists";
|
|
32916
33010
|
return void 0;
|
|
32917
33011
|
}
|
|
@@ -33075,11 +33169,11 @@ function sessionBase(id, status3) {
|
|
|
33075
33169
|
}
|
|
33076
33170
|
|
|
33077
33171
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
33078
|
-
import { existsSync as
|
|
33172
|
+
import { existsSync as existsSync76 } from "fs";
|
|
33079
33173
|
import * as pty from "node-pty";
|
|
33080
33174
|
|
|
33081
33175
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
33082
|
-
import { chmodSync, existsSync as
|
|
33176
|
+
import { chmodSync, existsSync as existsSync75, statSync as statSync12 } from "fs";
|
|
33083
33177
|
import { createRequire as createRequire3 } from "module";
|
|
33084
33178
|
import path75 from "path";
|
|
33085
33179
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -33094,7 +33188,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
33094
33188
|
`${process.platform}-${process.arch}`,
|
|
33095
33189
|
"spawn-helper"
|
|
33096
33190
|
);
|
|
33097
|
-
if (!
|
|
33191
|
+
if (!existsSync75(helper)) return;
|
|
33098
33192
|
const mode = statSync12(helper).mode;
|
|
33099
33193
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
33100
33194
|
}
|
|
@@ -33130,7 +33224,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
33130
33224
|
});
|
|
33131
33225
|
}
|
|
33132
33226
|
function refuseMissingCwd(cwd, sessionId) {
|
|
33133
|
-
if (!cwd ||
|
|
33227
|
+
if (!cwd || existsSync76(cwd)) return;
|
|
33134
33228
|
daemonLog(
|
|
33135
33229
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
33136
33230
|
);
|
|
@@ -33312,11 +33406,11 @@ function setStatus2(session, newStatus) {
|
|
|
33312
33406
|
}
|
|
33313
33407
|
|
|
33314
33408
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
33315
|
-
import { existsSync as
|
|
33409
|
+
import { existsSync as existsSync78 } from "fs";
|
|
33316
33410
|
import { basename as basename22 } from "path";
|
|
33317
33411
|
|
|
33318
33412
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
33319
|
-
import { existsSync as
|
|
33413
|
+
import { existsSync as existsSync77 } from "fs";
|
|
33320
33414
|
import { join as join92 } from "path";
|
|
33321
33415
|
|
|
33322
33416
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
@@ -33386,7 +33480,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
33386
33480
|
);
|
|
33387
33481
|
}
|
|
33388
33482
|
function strandedReason(worktreePath, cause) {
|
|
33389
|
-
if (!
|
|
33483
|
+
if (!existsSync77(join92(worktreePath, ".git")))
|
|
33390
33484
|
return "its .git link is already gone";
|
|
33391
33485
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
33392
33486
|
return "git no longer recognises it as a working tree";
|
|
@@ -33438,7 +33532,7 @@ function reason3(error) {
|
|
|
33438
33532
|
|
|
33439
33533
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
33440
33534
|
async function reapWorktree(worktreePath, force = false) {
|
|
33441
|
-
if (!
|
|
33535
|
+
if (!existsSync78(worktreePath)) {
|
|
33442
33536
|
forgetWorktree(worktreePath);
|
|
33443
33537
|
daemonLog(
|
|
33444
33538
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -33463,7 +33557,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
33463
33557
|
}
|
|
33464
33558
|
function owningClone(worktreePath) {
|
|
33465
33559
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
33466
|
-
if (recorded &&
|
|
33560
|
+
if (recorded && existsSync78(recorded)) return recorded;
|
|
33467
33561
|
const detected = mainWorktree(worktreePath);
|
|
33468
33562
|
if (detected) return detected;
|
|
33469
33563
|
daemonLog(
|
|
@@ -33594,12 +33688,12 @@ function closeGateApplies(sessions, session) {
|
|
|
33594
33688
|
}
|
|
33595
33689
|
|
|
33596
33690
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
33597
|
-
import { existsSync as
|
|
33691
|
+
import { existsSync as existsSync79, watch } from "fs";
|
|
33598
33692
|
var DEBOUNCE_MS = 500;
|
|
33599
33693
|
var POLL_MS = 3e4;
|
|
33600
33694
|
function watchGitState(cwd, onChange) {
|
|
33601
33695
|
const common = gitCommonDir(cwd);
|
|
33602
|
-
if (!common || !
|
|
33696
|
+
if (!common || !existsSync79(common)) return void 0;
|
|
33603
33697
|
const watchers = [
|
|
33604
33698
|
watchGitDir(common, onChange),
|
|
33605
33699
|
pollGitState(cwd, onChange)
|
|
@@ -34076,10 +34170,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
34076
34170
|
}
|
|
34077
34171
|
|
|
34078
34172
|
// src/commands/sessions/daemon/exitReason.ts
|
|
34079
|
-
import { existsSync as
|
|
34173
|
+
import { existsSync as existsSync80 } from "fs";
|
|
34080
34174
|
import { resolve as resolve21 } from "path";
|
|
34081
34175
|
function exitDetail(session) {
|
|
34082
|
-
if (session.cwd && !
|
|
34176
|
+
if (session.cwd && !existsSync80(session.cwd))
|
|
34083
34177
|
return `working directory ${session.cwd} no longer exists`;
|
|
34084
34178
|
return missingRunConfigCwd(session);
|
|
34085
34179
|
}
|
|
@@ -34093,7 +34187,7 @@ function missingRunConfigCwd(session) {
|
|
|
34093
34187
|
const config = resolveRunConfig(session.runName, dir);
|
|
34094
34188
|
if (!config?.cwd) return void 0;
|
|
34095
34189
|
const configured = resolve21(runConfigBaseDirFrom(dir), config.cwd);
|
|
34096
|
-
if (
|
|
34190
|
+
if (existsSync80(configured)) return void 0;
|
|
34097
34191
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
34098
34192
|
}
|
|
34099
34193
|
|
|
@@ -34134,8 +34228,8 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
34134
34228
|
}
|
|
34135
34229
|
|
|
34136
34230
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
34137
|
-
import { existsSync as
|
|
34138
|
-
import { dirname as
|
|
34231
|
+
import { existsSync as existsSync81, mkdirSync as mkdirSync33, watch as watch2 } from "fs";
|
|
34232
|
+
import { dirname as dirname38 } from "path";
|
|
34139
34233
|
|
|
34140
34234
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
34141
34235
|
function applyActivityToSession(session, activity2) {
|
|
@@ -34197,9 +34291,9 @@ var DEBOUNCE_MS2 = 50;
|
|
|
34197
34291
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
34198
34292
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
34199
34293
|
const path80 = activityPath(session.id);
|
|
34200
|
-
const dir =
|
|
34294
|
+
const dir = dirname38(path80);
|
|
34201
34295
|
try {
|
|
34202
|
-
|
|
34296
|
+
mkdirSync33(dir, { recursive: true });
|
|
34203
34297
|
} catch {
|
|
34204
34298
|
return;
|
|
34205
34299
|
}
|
|
@@ -34220,7 +34314,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
34220
34314
|
if (timer) clearTimeout(timer);
|
|
34221
34315
|
timer = setTimeout(read2, DEBOUNCE_MS2);
|
|
34222
34316
|
});
|
|
34223
|
-
if (
|
|
34317
|
+
if (existsSync81(path80)) read2();
|
|
34224
34318
|
}
|
|
34225
34319
|
function refreshActivity(session) {
|
|
34226
34320
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -34402,10 +34496,10 @@ function headContainsSessionId(filePath, claudeSessionId) {
|
|
|
34402
34496
|
}
|
|
34403
34497
|
|
|
34404
34498
|
// src/commands/sessions/daemon/ensureProjectDirExists.ts
|
|
34405
|
-
import { mkdirSync as
|
|
34499
|
+
import { mkdirSync as mkdirSync34 } from "fs";
|
|
34406
34500
|
function ensureProjectDirExists(dir, sessionId) {
|
|
34407
34501
|
try {
|
|
34408
|
-
|
|
34502
|
+
mkdirSync34(dir, { recursive: true });
|
|
34409
34503
|
return true;
|
|
34410
34504
|
} catch (error) {
|
|
34411
34505
|
daemonLog(
|
|
@@ -35842,7 +35936,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
35842
35936
|
}
|
|
35843
35937
|
|
|
35844
35938
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
35845
|
-
import { existsSync as
|
|
35939
|
+
import { existsSync as existsSync84 } from "fs";
|
|
35846
35940
|
import { basename as basename24 } from "path";
|
|
35847
35941
|
|
|
35848
35942
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -35897,9 +35991,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
35897
35991
|
}
|
|
35898
35992
|
|
|
35899
35993
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
35900
|
-
import { existsSync as
|
|
35994
|
+
import { existsSync as existsSync83 } from "fs";
|
|
35901
35995
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
35902
|
-
if (!
|
|
35996
|
+
if (!existsSync83(clone)) {
|
|
35903
35997
|
for (const { path: path80 } of paths) forgetWorktree(path80);
|
|
35904
35998
|
daemonLog(
|
|
35905
35999
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -36065,7 +36159,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
36065
36159
|
);
|
|
36066
36160
|
continue;
|
|
36067
36161
|
}
|
|
36068
|
-
if (!
|
|
36162
|
+
if (!existsSync84(path80)) {
|
|
36069
36163
|
logVanishedTree(sessions, path80);
|
|
36070
36164
|
vanished.set(clone, [
|
|
36071
36165
|
...vanished.get(clone) ?? [],
|
|
@@ -36682,14 +36776,14 @@ async function defaultConnect() {
|
|
|
36682
36776
|
}
|
|
36683
36777
|
|
|
36684
36778
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
36685
|
-
import { existsSync as
|
|
36779
|
+
import { existsSync as existsSync85, readFileSync as readFileSync58 } from "fs";
|
|
36686
36780
|
import { posix as posix3 } from "path";
|
|
36687
36781
|
function hasPersistedWindowsSessions() {
|
|
36688
36782
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
36689
36783
|
if (!sessionsFile) return false;
|
|
36690
36784
|
try {
|
|
36691
|
-
if (!
|
|
36692
|
-
const data = JSON.parse(
|
|
36785
|
+
if (!existsSync85(sessionsFile)) return false;
|
|
36786
|
+
const data = JSON.parse(readFileSync58(sessionsFile, "utf8"));
|
|
36693
36787
|
return Array.isArray(data) && data.length > 0;
|
|
36694
36788
|
} catch (error) {
|
|
36695
36789
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -37423,7 +37517,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
37423
37517
|
}
|
|
37424
37518
|
|
|
37425
37519
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
37426
|
-
import { existsSync as
|
|
37520
|
+
import { existsSync as existsSync88 } from "fs";
|
|
37427
37521
|
|
|
37428
37522
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
37429
37523
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -37454,10 +37548,10 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
37454
37548
|
}
|
|
37455
37549
|
|
|
37456
37550
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
37457
|
-
import { existsSync as
|
|
37551
|
+
import { existsSync as existsSync87 } from "fs";
|
|
37458
37552
|
|
|
37459
37553
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
37460
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
37554
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync86, mkdirSync as mkdirSync35 } from "fs";
|
|
37461
37555
|
import { join as join94 } from "path";
|
|
37462
37556
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
37463
37557
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -37468,7 +37562,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
37468
37562
|
return;
|
|
37469
37563
|
}
|
|
37470
37564
|
const dest = join94(dir, `${claudeSessionId}.jsonl`);
|
|
37471
|
-
if (
|
|
37565
|
+
if (existsSync86(dest)) {
|
|
37472
37566
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
37473
37567
|
return;
|
|
37474
37568
|
}
|
|
@@ -37480,7 +37574,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
37480
37574
|
return;
|
|
37481
37575
|
}
|
|
37482
37576
|
try {
|
|
37483
|
-
|
|
37577
|
+
mkdirSync35(dir, { recursive: true });
|
|
37484
37578
|
copyFileSync7(source, dest);
|
|
37485
37579
|
daemonLog(
|
|
37486
37580
|
`transcript ${source} copied to ${dest} so ${toCwd} can resume it`
|
|
@@ -37519,7 +37613,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
37519
37613
|
}
|
|
37520
37614
|
function cloneForReapedTree(missingCwd) {
|
|
37521
37615
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
37522
|
-
if (!clone || !
|
|
37616
|
+
if (!clone || !existsSync87(clone))
|
|
37523
37617
|
throw new Error(
|
|
37524
37618
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
37525
37619
|
);
|
|
@@ -37528,7 +37622,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
37528
37622
|
|
|
37529
37623
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
37530
37624
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
37531
|
-
if (!
|
|
37625
|
+
if (!existsSync88(cwd))
|
|
37532
37626
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
37533
37627
|
const id = ctx.spawnWith(
|
|
37534
37628
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -37872,10 +37966,10 @@ async function parseTranscript(sessionId) {
|
|
|
37872
37966
|
if (rollout) return readMessages(rollout, parseCodexTranscriptLines);
|
|
37873
37967
|
return [];
|
|
37874
37968
|
}
|
|
37875
|
-
async function readMessages(filePath,
|
|
37969
|
+
async function readMessages(filePath, parse4) {
|
|
37876
37970
|
try {
|
|
37877
37971
|
const raw = await fs54.promises.readFile(filePath, "utf8");
|
|
37878
|
-
return
|
|
37972
|
+
return parse4(raw.split("\n"));
|
|
37879
37973
|
} catch {
|
|
37880
37974
|
return [];
|
|
37881
37975
|
}
|
|
@@ -38104,10 +38198,10 @@ function handleConnection(socket, manager) {
|
|
|
38104
38198
|
}
|
|
38105
38199
|
|
|
38106
38200
|
// src/commands/sessions/daemon/onListening.ts
|
|
38107
|
-
import { unlinkSync as unlinkSync23, writeFileSync as
|
|
38201
|
+
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync48 } from "fs";
|
|
38108
38202
|
|
|
38109
38203
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
38110
|
-
import { readFileSync as
|
|
38204
|
+
import { readFileSync as readFileSync59 } from "fs";
|
|
38111
38205
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
38112
38206
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
38113
38207
|
const timer = setInterval(() => {
|
|
@@ -38118,7 +38212,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
38118
38212
|
}
|
|
38119
38213
|
function ownsPidFile() {
|
|
38120
38214
|
try {
|
|
38121
|
-
return
|
|
38215
|
+
return readFileSync59(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
38122
38216
|
} catch {
|
|
38123
38217
|
return false;
|
|
38124
38218
|
}
|
|
@@ -38126,7 +38220,7 @@ function ownsPidFile() {
|
|
|
38126
38220
|
|
|
38127
38221
|
// src/commands/sessions/daemon/onListening.ts
|
|
38128
38222
|
function onListening(manager, checkAutoExit) {
|
|
38129
|
-
|
|
38223
|
+
writeFileSync48(daemonPaths.pid, String(process.pid));
|
|
38130
38224
|
startPidFileWatchdog(() => {
|
|
38131
38225
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
38132
38226
|
void manager.flushActiveMs().finally(() => {
|
|
@@ -38313,7 +38407,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
38313
38407
|
|
|
38314
38408
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
38315
38409
|
async function runDaemon() {
|
|
38316
|
-
|
|
38410
|
+
mkdirSync36(daemonPaths.dir, { recursive: true });
|
|
38317
38411
|
daemonLog(
|
|
38318
38412
|
`starting (reason: ${process.env.ASSIST_DAEMON_SPAWN_REASON ?? "manual"})`
|
|
38319
38413
|
);
|
|
@@ -38368,7 +38462,7 @@ function registerSetStatusCommand(cmd) {
|
|
|
38368
38462
|
|
|
38369
38463
|
// src/commands/sessions/summarise/index.ts
|
|
38370
38464
|
import * as fs56 from "fs";
|
|
38371
|
-
import
|
|
38465
|
+
import chalk221 from "chalk";
|
|
38372
38466
|
|
|
38373
38467
|
// src/commands/sessions/summarise/shared.ts
|
|
38374
38468
|
import * as fs55 from "fs";
|
|
@@ -38427,22 +38521,22 @@ ${firstMessage}`);
|
|
|
38427
38521
|
async function summarise2(options2) {
|
|
38428
38522
|
const files = await discoverSessionFiles();
|
|
38429
38523
|
if (files.length === 0) {
|
|
38430
|
-
console.log(
|
|
38524
|
+
console.log(chalk221.yellow("No sessions found."));
|
|
38431
38525
|
return;
|
|
38432
38526
|
}
|
|
38433
38527
|
const toProcess = selectCandidates(files, options2);
|
|
38434
38528
|
if (toProcess.length === 0) {
|
|
38435
|
-
console.log(
|
|
38529
|
+
console.log(chalk221.green("All sessions already summarised."));
|
|
38436
38530
|
return;
|
|
38437
38531
|
}
|
|
38438
38532
|
console.log(
|
|
38439
|
-
|
|
38533
|
+
chalk221.cyan(
|
|
38440
38534
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
38441
38535
|
)
|
|
38442
38536
|
);
|
|
38443
38537
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
38444
38538
|
console.log(
|
|
38445
|
-
|
|
38539
|
+
chalk221.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk221.yellow(`, ${failed2} skipped`) : "")
|
|
38446
38540
|
);
|
|
38447
38541
|
}
|
|
38448
38542
|
function selectCandidates(files, options2) {
|
|
@@ -38462,16 +38556,16 @@ function processSessions(files) {
|
|
|
38462
38556
|
let failed2 = 0;
|
|
38463
38557
|
for (let i = 0; i < files.length; i++) {
|
|
38464
38558
|
const file = files[i];
|
|
38465
|
-
process.stdout.write(
|
|
38559
|
+
process.stdout.write(chalk221.dim(` [${i + 1}/${files.length}] `));
|
|
38466
38560
|
const summary = summariseSession(file);
|
|
38467
38561
|
if (summary) {
|
|
38468
38562
|
writeSummary(file, summary);
|
|
38469
38563
|
succeeded++;
|
|
38470
|
-
process.stdout.write(`${
|
|
38564
|
+
process.stdout.write(`${chalk221.green("\u2713")} ${summary}
|
|
38471
38565
|
`);
|
|
38472
38566
|
} else {
|
|
38473
38567
|
failed2++;
|
|
38474
|
-
process.stdout.write(` ${
|
|
38568
|
+
process.stdout.write(` ${chalk221.yellow("skip")}
|
|
38475
38569
|
`);
|
|
38476
38570
|
}
|
|
38477
38571
|
}
|
|
@@ -38492,7 +38586,7 @@ function registerSessions(program2) {
|
|
|
38492
38586
|
}
|
|
38493
38587
|
|
|
38494
38588
|
// src/commands/statusLine.ts
|
|
38495
|
-
import
|
|
38589
|
+
import chalk223 from "chalk";
|
|
38496
38590
|
|
|
38497
38591
|
// src/shared/contextLevel.ts
|
|
38498
38592
|
function contextLevel(pct) {
|
|
@@ -38502,7 +38596,7 @@ function contextLevel(pct) {
|
|
|
38502
38596
|
}
|
|
38503
38597
|
|
|
38504
38598
|
// src/commands/buildLimitsSegment.ts
|
|
38505
|
-
import
|
|
38599
|
+
import chalk222 from "chalk";
|
|
38506
38600
|
|
|
38507
38601
|
// src/shared/rateLimitLevel.ts
|
|
38508
38602
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -38540,9 +38634,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
38540
38634
|
|
|
38541
38635
|
// src/commands/buildLimitsSegment.ts
|
|
38542
38636
|
var LEVEL_COLOR = {
|
|
38543
|
-
ok:
|
|
38544
|
-
warn:
|
|
38545
|
-
over:
|
|
38637
|
+
ok: chalk222.green,
|
|
38638
|
+
warn: chalk222.yellow,
|
|
38639
|
+
over: chalk222.red
|
|
38546
38640
|
};
|
|
38547
38641
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
38548
38642
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -38573,7 +38667,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
38573
38667
|
}
|
|
38574
38668
|
|
|
38575
38669
|
// src/commands/readGitBranch.ts
|
|
38576
|
-
import { readFileSync as
|
|
38670
|
+
import { readFileSync as readFileSync61, statSync as statSync15 } from "fs";
|
|
38577
38671
|
import { isAbsolute as isAbsolute4, join as join95, resolve as resolve22 } from "path";
|
|
38578
38672
|
function resolveGitDir(cwd) {
|
|
38579
38673
|
const dotGit = join95(cwd, ".git");
|
|
@@ -38588,7 +38682,7 @@ function resolveGitDir(cwd) {
|
|
|
38588
38682
|
}
|
|
38589
38683
|
let contents;
|
|
38590
38684
|
try {
|
|
38591
|
-
contents =
|
|
38685
|
+
contents = readFileSync61(dotGit, "utf8");
|
|
38592
38686
|
} catch {
|
|
38593
38687
|
return null;
|
|
38594
38688
|
}
|
|
@@ -38606,7 +38700,7 @@ function readGitBranch(cwd) {
|
|
|
38606
38700
|
}
|
|
38607
38701
|
let head;
|
|
38608
38702
|
try {
|
|
38609
|
-
head =
|
|
38703
|
+
head = readFileSync61(join95(gitDir, "HEAD"), "utf8");
|
|
38610
38704
|
} catch {
|
|
38611
38705
|
return null;
|
|
38612
38706
|
}
|
|
@@ -38638,7 +38732,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
38638
38732
|
}
|
|
38639
38733
|
|
|
38640
38734
|
// src/commands/statusLine.ts
|
|
38641
|
-
|
|
38735
|
+
chalk223.level = 3;
|
|
38642
38736
|
function formatNumber(num) {
|
|
38643
38737
|
return num.toLocaleString("en-US");
|
|
38644
38738
|
}
|
|
@@ -38646,9 +38740,9 @@ function colorizePercent(pct) {
|
|
|
38646
38740
|
const label2 = `${Math.round(pct)}%`;
|
|
38647
38741
|
switch (contextLevel(pct)) {
|
|
38648
38742
|
case "red":
|
|
38649
|
-
return
|
|
38743
|
+
return chalk223.red(label2);
|
|
38650
38744
|
case "yellow":
|
|
38651
|
-
return
|
|
38745
|
+
return chalk223.yellow(label2);
|
|
38652
38746
|
default:
|
|
38653
38747
|
return label2;
|
|
38654
38748
|
}
|
|
@@ -38661,7 +38755,7 @@ async function statusLine() {
|
|
|
38661
38755
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
38662
38756
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
38663
38757
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
38664
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
38758
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk223.cyan(branch2)} | ` : "";
|
|
38665
38759
|
console.log(
|
|
38666
38760
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
38667
38761
|
);
|
|
@@ -38731,10 +38825,10 @@ async function update2() {
|
|
|
38731
38825
|
}
|
|
38732
38826
|
|
|
38733
38827
|
// src/reportCliError.ts
|
|
38734
|
-
import
|
|
38828
|
+
import chalk224 from "chalk";
|
|
38735
38829
|
function reportCliError(error) {
|
|
38736
38830
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
38737
|
-
console.error(
|
|
38831
|
+
console.error(chalk224.red(error.message));
|
|
38738
38832
|
} else {
|
|
38739
38833
|
console.error(error);
|
|
38740
38834
|
}
|