@staff0rd/assist 0.158.0 → 0.158.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +390 -323
- 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.158.
|
|
9
|
+
version: "0.158.2",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -244,6 +244,57 @@ async function done(id, summary) {
|
|
|
244
244
|
import chalk9 from "chalk";
|
|
245
245
|
import enquirer2 from "enquirer";
|
|
246
246
|
|
|
247
|
+
// src/shared/exitOnCancel.ts
|
|
248
|
+
async function exitOnCancel(promise) {
|
|
249
|
+
try {
|
|
250
|
+
return await promise;
|
|
251
|
+
} catch (err) {
|
|
252
|
+
if (err === "" || err === void 0) {
|
|
253
|
+
process.exit(0);
|
|
254
|
+
}
|
|
255
|
+
throw err;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/commands/backlog/acquireLock.ts
|
|
260
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
261
|
+
import { join as join2 } from "path";
|
|
262
|
+
function getLockPath(itemId) {
|
|
263
|
+
return join2(process.cwd(), `.assist-lock-${itemId}.json`);
|
|
264
|
+
}
|
|
265
|
+
function isProcessAlive(pid) {
|
|
266
|
+
try {
|
|
267
|
+
process.kill(pid, 0);
|
|
268
|
+
return true;
|
|
269
|
+
} catch {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function isLockedByOther(itemId) {
|
|
274
|
+
const lockPath = getLockPath(itemId);
|
|
275
|
+
if (!existsSync2(lockPath)) return false;
|
|
276
|
+
try {
|
|
277
|
+
const lock = JSON.parse(readFileSync2(lockPath, "utf-8"));
|
|
278
|
+
if (lock.pid === process.pid) return false;
|
|
279
|
+
return isProcessAlive(lock.pid);
|
|
280
|
+
} catch {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function acquireLock(itemId) {
|
|
285
|
+
writeFileSync2(
|
|
286
|
+
getLockPath(itemId),
|
|
287
|
+
JSON.stringify({ pid: process.pid, timestamp: (/* @__PURE__ */ new Date()).toISOString() })
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
function releaseLock(itemId) {
|
|
291
|
+
const lockPath = getLockPath(itemId);
|
|
292
|
+
try {
|
|
293
|
+
unlinkSync(lockPath);
|
|
294
|
+
} catch {
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
247
298
|
// src/commands/backlog/list/shared.ts
|
|
248
299
|
import chalk4 from "chalk";
|
|
249
300
|
function statusIcon(status2) {
|
|
@@ -394,45 +445,47 @@ function buildReviewPhase() {
|
|
|
394
445
|
import chalk6 from "chalk";
|
|
395
446
|
|
|
396
447
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
397
|
-
import { existsSync as
|
|
448
|
+
import { existsSync as existsSync3, unlinkSync as unlinkSync2 } from "fs";
|
|
398
449
|
import chalk5 from "chalk";
|
|
399
450
|
|
|
400
451
|
// src/commands/backlog/handleIncompletePhase.ts
|
|
401
452
|
import enquirer from "enquirer";
|
|
402
453
|
async function handleIncompletePhase() {
|
|
403
|
-
const { action } = await
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
454
|
+
const { action } = await exitOnCancel(
|
|
455
|
+
enquirer.prompt({
|
|
456
|
+
type: "select",
|
|
457
|
+
name: "action",
|
|
458
|
+
message: "Phase was not marked complete. What would you like to do?",
|
|
459
|
+
choices: ["Retry this phase", "Skip to next phase", "Abort"]
|
|
460
|
+
})
|
|
461
|
+
);
|
|
409
462
|
if (action === "Retry this phase") return "retry";
|
|
410
463
|
if (action === "Skip to next phase") return "skip";
|
|
411
464
|
return "abort";
|
|
412
465
|
}
|
|
413
466
|
|
|
414
467
|
// src/commands/backlog/writeSignal.ts
|
|
415
|
-
import { writeFileSync as
|
|
416
|
-
import { join as
|
|
468
|
+
import { writeFileSync as writeFileSync3 } from "fs";
|
|
469
|
+
import { join as join3 } from "path";
|
|
417
470
|
var SIGNAL_FILE = ".assist-signal.json";
|
|
418
471
|
function getSignalPath() {
|
|
419
|
-
return
|
|
472
|
+
return join3(process.cwd(), SIGNAL_FILE);
|
|
420
473
|
}
|
|
421
474
|
function writeSignal(event, data) {
|
|
422
475
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
423
476
|
const signal = { event, ...sessionId && { sessionId }, ...data };
|
|
424
|
-
|
|
477
|
+
writeFileSync3(getSignalPath(), JSON.stringify(signal));
|
|
425
478
|
}
|
|
426
479
|
|
|
427
480
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
428
481
|
function cleanupSignal() {
|
|
429
482
|
const statusPath = getSignalPath();
|
|
430
|
-
if (
|
|
431
|
-
|
|
483
|
+
if (existsSync3(statusPath)) {
|
|
484
|
+
unlinkSync2(statusPath);
|
|
432
485
|
}
|
|
433
486
|
}
|
|
434
487
|
async function resolvePhaseResult(phaseIndex) {
|
|
435
|
-
if (!
|
|
488
|
+
if (!existsSync3(getSignalPath())) {
|
|
436
489
|
const action = await handleIncompletePhase();
|
|
437
490
|
if (action === "abort") return -1;
|
|
438
491
|
return action === "skip" ? 1 : 0;
|
|
@@ -461,15 +514,15 @@ function spawnClaude(prompt, options2 = {}) {
|
|
|
461
514
|
}
|
|
462
515
|
|
|
463
516
|
// src/commands/backlog/watchForMarker.ts
|
|
464
|
-
import { existsSync as
|
|
517
|
+
import { existsSync as existsSync5, unwatchFile, watchFile } from "fs";
|
|
465
518
|
|
|
466
519
|
// src/commands/backlog/readSignal.ts
|
|
467
|
-
import { existsSync as
|
|
520
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
468
521
|
function readSignal() {
|
|
469
522
|
const path50 = getSignalPath();
|
|
470
|
-
if (!
|
|
523
|
+
if (!existsSync4(path50)) return void 0;
|
|
471
524
|
try {
|
|
472
|
-
return JSON.parse(
|
|
525
|
+
return JSON.parse(readFileSync3(path50, "utf-8"));
|
|
473
526
|
} catch {
|
|
474
527
|
return void 0;
|
|
475
528
|
}
|
|
@@ -480,7 +533,7 @@ function watchForMarker(child) {
|
|
|
480
533
|
const statusPath = getSignalPath();
|
|
481
534
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
482
535
|
watchFile(statusPath, { interval: 1e3 }, () => {
|
|
483
|
-
if (!
|
|
536
|
+
if (!existsSync5(statusPath)) return;
|
|
484
537
|
const signal = readSignal();
|
|
485
538
|
if (signal && (!signal.sessionId || signal.sessionId === sessionId)) {
|
|
486
539
|
unwatchFile(statusPath);
|
|
@@ -557,13 +610,16 @@ async function run(id, spawnOptions) {
|
|
|
557
610
|
if (!prepared) return false;
|
|
558
611
|
const { item, plan: plan2, startPhase } = prepared;
|
|
559
612
|
setStatus(id, "in-progress");
|
|
613
|
+
acquireLock(item.id);
|
|
560
614
|
logProgress(id, item.name, startPhase, plan2.length);
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
615
|
+
try {
|
|
616
|
+
if (!await runPhases(item, startPhase, plan2, spawnOptions)) return false;
|
|
617
|
+
if (!await runReview(item, plan2, spawnOptions)) return false;
|
|
618
|
+
ensureDone(id);
|
|
619
|
+
return true;
|
|
620
|
+
} finally {
|
|
621
|
+
releaseLock(item.id);
|
|
622
|
+
}
|
|
567
623
|
}
|
|
568
624
|
function logProgress(id, name, startPhase, total) {
|
|
569
625
|
console.log(chalk8.bold(`Running plan for #${id}: ${name}`));
|
|
@@ -602,10 +658,27 @@ async function runReview(item, plan2, spawnOptions) {
|
|
|
602
658
|
}
|
|
603
659
|
|
|
604
660
|
// src/commands/backlog/next.ts
|
|
661
|
+
function findResumable(items) {
|
|
662
|
+
return items.find(
|
|
663
|
+
(i) => i.status === "in-progress" && i.plan && !isLockedByOther(i.id)
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
async function selectItem(todo) {
|
|
667
|
+
const choices = todo.map((i) => `${typeLabel(i.type)} #${i.id}: ${i.name}`);
|
|
668
|
+
const { selected } = await exitOnCancel(
|
|
669
|
+
enquirer2.prompt({
|
|
670
|
+
type: "select",
|
|
671
|
+
name: "selected",
|
|
672
|
+
message: "Choose a backlog item to start:",
|
|
673
|
+
choices
|
|
674
|
+
})
|
|
675
|
+
);
|
|
676
|
+
return selected.match(/#(\d+)/)?.[1] ?? "";
|
|
677
|
+
}
|
|
605
678
|
async function next(options2) {
|
|
606
679
|
while (true) {
|
|
607
680
|
const items = loadBacklog();
|
|
608
|
-
const inProgress = items
|
|
681
|
+
const inProgress = findResumable(items);
|
|
609
682
|
if (inProgress) {
|
|
610
683
|
console.log(
|
|
611
684
|
chalk9.bold(
|
|
@@ -627,17 +700,7 @@ async function next(options2) {
|
|
|
627
700
|
console.log(chalk9.bold(`Starting #${only.id}: ${only.name}`));
|
|
628
701
|
id = String(only.id);
|
|
629
702
|
} else {
|
|
630
|
-
|
|
631
|
-
name: `${typeLabel(i.type)} #${i.id}: ${i.name}`,
|
|
632
|
-
value: String(i.id)
|
|
633
|
-
}));
|
|
634
|
-
const { selected } = await enquirer2.prompt({
|
|
635
|
-
type: "select",
|
|
636
|
-
name: "selected",
|
|
637
|
-
message: "Choose a backlog item to start:",
|
|
638
|
-
choices: choices.map((c) => c.name)
|
|
639
|
-
});
|
|
640
|
-
id = selected.match(/#(\d+)/)?.[1] ?? "";
|
|
703
|
+
id = await selectItem(todo);
|
|
641
704
|
}
|
|
642
705
|
const completed = await run(id, options2);
|
|
643
706
|
if (!completed) return;
|
|
@@ -786,11 +849,11 @@ async function start(id) {
|
|
|
786
849
|
|
|
787
850
|
// src/shared/web.ts
|
|
788
851
|
import { exec } from "child_process";
|
|
789
|
-
import { readFileSync as
|
|
852
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
790
853
|
import {
|
|
791
854
|
createServer
|
|
792
855
|
} from "http";
|
|
793
|
-
import { dirname, join as
|
|
856
|
+
import { dirname, join as join4 } from "path";
|
|
794
857
|
import { fileURLToPath } from "url";
|
|
795
858
|
import chalk15 from "chalk";
|
|
796
859
|
function respondJson(res, status2, data) {
|
|
@@ -802,7 +865,7 @@ function createBundleHandler(importMetaUrl, bundlePath) {
|
|
|
802
865
|
let cache;
|
|
803
866
|
return (_req, res) => {
|
|
804
867
|
if (!cache) {
|
|
805
|
-
cache =
|
|
868
|
+
cache = readFileSync4(join4(dir, bundlePath), "utf-8");
|
|
806
869
|
}
|
|
807
870
|
res.writeHead(200, { "Content-Type": "application/javascript" });
|
|
808
871
|
res.end(cache);
|
|
@@ -1004,19 +1067,19 @@ async function launchMode(slashCommand) {
|
|
|
1004
1067
|
import { execSync } from "child_process";
|
|
1005
1068
|
|
|
1006
1069
|
// src/shared/loadConfig.ts
|
|
1007
|
-
import { existsSync as
|
|
1070
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
1008
1071
|
import { homedir } from "os";
|
|
1009
|
-
import { basename, dirname as dirname2, join as
|
|
1072
|
+
import { basename, dirname as dirname2, join as join5 } from "path";
|
|
1010
1073
|
import chalk17 from "chalk";
|
|
1011
1074
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
1012
1075
|
|
|
1013
1076
|
// src/shared/loadRawYaml.ts
|
|
1014
|
-
import { existsSync as
|
|
1077
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
1015
1078
|
import { parse as parseYaml2 } from "yaml";
|
|
1016
1079
|
function loadRawYaml(path50) {
|
|
1017
|
-
if (!
|
|
1080
|
+
if (!existsSync6(path50)) return {};
|
|
1018
1081
|
try {
|
|
1019
|
-
const content =
|
|
1082
|
+
const content = readFileSync5(path50, "utf-8");
|
|
1020
1083
|
return parseYaml2(content) || {};
|
|
1021
1084
|
} catch {
|
|
1022
1085
|
return {};
|
|
@@ -1137,10 +1200,10 @@ var assistConfigSchema = z2.strictObject({
|
|
|
1137
1200
|
function findConfigUp(startDir) {
|
|
1138
1201
|
let current = startDir;
|
|
1139
1202
|
while (current !== dirname2(current)) {
|
|
1140
|
-
const claudePath =
|
|
1141
|
-
if (
|
|
1142
|
-
const rootPath =
|
|
1143
|
-
if (
|
|
1203
|
+
const claudePath = join5(current, ".claude", "assist.yml");
|
|
1204
|
+
if (existsSync7(claudePath)) return claudePath;
|
|
1205
|
+
const rootPath = join5(current, "assist.yml");
|
|
1206
|
+
if (existsSync7(rootPath)) return rootPath;
|
|
1144
1207
|
current = dirname2(current);
|
|
1145
1208
|
}
|
|
1146
1209
|
return null;
|
|
@@ -1148,10 +1211,10 @@ function findConfigUp(startDir) {
|
|
|
1148
1211
|
function getConfigPath() {
|
|
1149
1212
|
const found = findConfigUp(process.cwd());
|
|
1150
1213
|
if (found) return found;
|
|
1151
|
-
return
|
|
1214
|
+
return join5(process.cwd(), "assist.yml");
|
|
1152
1215
|
}
|
|
1153
1216
|
function getGlobalConfigPath() {
|
|
1154
|
-
return
|
|
1217
|
+
return join5(homedir(), ".assist.yml");
|
|
1155
1218
|
}
|
|
1156
1219
|
function loadConfig() {
|
|
1157
1220
|
const globalRaw = loadRawYaml(getGlobalConfigPath());
|
|
@@ -1166,21 +1229,21 @@ function loadGlobalConfigRaw() {
|
|
|
1166
1229
|
return loadRawYaml(getGlobalConfigPath());
|
|
1167
1230
|
}
|
|
1168
1231
|
function saveGlobalConfig(config) {
|
|
1169
|
-
|
|
1232
|
+
writeFileSync4(getGlobalConfigPath(), stringifyYaml2(config, { lineWidth: 0 }));
|
|
1170
1233
|
}
|
|
1171
1234
|
function saveConfig(config) {
|
|
1172
1235
|
const configPath = getConfigPath();
|
|
1173
|
-
|
|
1236
|
+
writeFileSync4(configPath, stringifyYaml2(config, { lineWidth: 0 }));
|
|
1174
1237
|
}
|
|
1175
1238
|
function getRepoName() {
|
|
1176
1239
|
const config = loadConfig();
|
|
1177
1240
|
if (config.devlog?.name) {
|
|
1178
1241
|
return config.devlog.name;
|
|
1179
1242
|
}
|
|
1180
|
-
const packageJsonPath =
|
|
1181
|
-
if (
|
|
1243
|
+
const packageJsonPath = join5(process.cwd(), "package.json");
|
|
1244
|
+
if (existsSync7(packageJsonPath)) {
|
|
1182
1245
|
try {
|
|
1183
|
-
const content =
|
|
1246
|
+
const content = readFileSync6(packageJsonPath, "utf-8");
|
|
1184
1247
|
const pkg = JSON.parse(content);
|
|
1185
1248
|
if (pkg.name) {
|
|
1186
1249
|
return pkg.name;
|
|
@@ -1427,22 +1490,24 @@ import chalk33 from "chalk";
|
|
|
1427
1490
|
import chalk19 from "chalk";
|
|
1428
1491
|
import enquirer3 from "enquirer";
|
|
1429
1492
|
async function promptMultiselect(message, options2) {
|
|
1430
|
-
const { selected } = await
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1493
|
+
const { selected } = await exitOnCancel(
|
|
1494
|
+
enquirer3.prompt({
|
|
1495
|
+
type: "multiselect",
|
|
1496
|
+
name: "selected",
|
|
1497
|
+
message,
|
|
1498
|
+
choices: options2.map((opt) => ({
|
|
1499
|
+
name: opt.value,
|
|
1500
|
+
message: `${opt.name} - ${chalk19.dim(opt.description)}`
|
|
1501
|
+
})),
|
|
1502
|
+
// @ts-expect-error - enquirer types don't include symbols but it's supported
|
|
1503
|
+
symbols: {
|
|
1504
|
+
indicator: {
|
|
1505
|
+
on: "[x]",
|
|
1506
|
+
off: "[ ]"
|
|
1507
|
+
}
|
|
1443
1508
|
}
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1509
|
+
})
|
|
1510
|
+
);
|
|
1446
1511
|
return selected;
|
|
1447
1512
|
}
|
|
1448
1513
|
|
|
@@ -1493,10 +1558,10 @@ function findPackageJsonWithVerifyScripts(startDir) {
|
|
|
1493
1558
|
|
|
1494
1559
|
// src/commands/verify/installPackage.ts
|
|
1495
1560
|
import { execSync as execSync3 } from "child_process";
|
|
1496
|
-
import { writeFileSync as
|
|
1561
|
+
import { writeFileSync as writeFileSync5 } from "fs";
|
|
1497
1562
|
import chalk21 from "chalk";
|
|
1498
1563
|
function writePackageJson(filePath, pkg) {
|
|
1499
|
-
|
|
1564
|
+
writeFileSync5(filePath, `${JSON.stringify(pkg, null, 2)}
|
|
1500
1565
|
`);
|
|
1501
1566
|
}
|
|
1502
1567
|
function addScript(pkg, name, command) {
|
|
@@ -1601,23 +1666,23 @@ import * as path3 from "path";
|
|
|
1601
1666
|
import chalk25 from "chalk";
|
|
1602
1667
|
|
|
1603
1668
|
// src/commands/verify/addToKnipIgnoreBinaries.ts
|
|
1604
|
-
import { existsSync as
|
|
1605
|
-
import { join as
|
|
1669
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
1670
|
+
import { join as join7 } from "path";
|
|
1606
1671
|
import chalk24 from "chalk";
|
|
1607
1672
|
function loadKnipConfig(knipJsonPath) {
|
|
1608
|
-
if (
|
|
1609
|
-
return JSON.parse(
|
|
1673
|
+
if (existsSync9(knipJsonPath)) {
|
|
1674
|
+
return JSON.parse(readFileSync8(knipJsonPath, "utf-8"));
|
|
1610
1675
|
}
|
|
1611
1676
|
return { $schema: "https://unpkg.com/knip@5/schema.json" };
|
|
1612
1677
|
}
|
|
1613
1678
|
function addToKnipIgnoreBinaries(cwd, binary) {
|
|
1614
|
-
const knipJsonPath =
|
|
1679
|
+
const knipJsonPath = join7(cwd, "knip.json");
|
|
1615
1680
|
try {
|
|
1616
1681
|
const knipConfig = loadKnipConfig(knipJsonPath);
|
|
1617
1682
|
const ignoreBinaries = knipConfig.ignoreBinaries ?? [];
|
|
1618
1683
|
if (!ignoreBinaries.includes(binary)) {
|
|
1619
1684
|
knipConfig.ignoreBinaries = [...ignoreBinaries, binary];
|
|
1620
|
-
|
|
1685
|
+
writeFileSync6(
|
|
1621
1686
|
knipJsonPath,
|
|
1622
1687
|
`${JSON.stringify(knipConfig, null, " ")}
|
|
1623
1688
|
`
|
|
@@ -1659,34 +1724,36 @@ import chalk29 from "chalk";
|
|
|
1659
1724
|
|
|
1660
1725
|
// src/commands/lint/init.ts
|
|
1661
1726
|
import { execSync as execSync5 } from "child_process";
|
|
1662
|
-
import { existsSync as
|
|
1663
|
-
import { dirname as dirname7, join as
|
|
1727
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "fs";
|
|
1728
|
+
import { dirname as dirname7, join as join8 } from "path";
|
|
1664
1729
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1665
1730
|
import chalk28 from "chalk";
|
|
1666
1731
|
|
|
1667
1732
|
// src/shared/promptConfirm.ts
|
|
1668
1733
|
import enquirer4 from "enquirer";
|
|
1669
1734
|
async function promptConfirm(message, initial = true) {
|
|
1670
|
-
const { confirmed } = await
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1735
|
+
const { confirmed } = await exitOnCancel(
|
|
1736
|
+
enquirer4.prompt({
|
|
1737
|
+
type: "confirm",
|
|
1738
|
+
name: "confirmed",
|
|
1739
|
+
message,
|
|
1740
|
+
initial,
|
|
1741
|
+
// @ts-expect-error - enquirer types don't include symbols but it's supported
|
|
1742
|
+
symbols: {
|
|
1743
|
+
on: "[x]",
|
|
1744
|
+
off: "[ ]"
|
|
1745
|
+
}
|
|
1746
|
+
})
|
|
1747
|
+
);
|
|
1681
1748
|
return confirmed;
|
|
1682
1749
|
}
|
|
1683
1750
|
|
|
1684
1751
|
// src/shared/removeEslint/index.ts
|
|
1685
1752
|
import { execSync as execSync4 } from "child_process";
|
|
1686
|
-
import { existsSync as
|
|
1753
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "fs";
|
|
1687
1754
|
|
|
1688
1755
|
// src/shared/removeEslint/removeEslintConfigFiles.ts
|
|
1689
|
-
import { existsSync as
|
|
1756
|
+
import { existsSync as existsSync10, unlinkSync as unlinkSync3 } from "fs";
|
|
1690
1757
|
var ESLINT_CONFIG_FILES = [
|
|
1691
1758
|
"eslint.config.js",
|
|
1692
1759
|
"eslint.config.mjs",
|
|
@@ -1702,8 +1769,8 @@ var ESLINT_CONFIG_FILES = [
|
|
|
1702
1769
|
function removeEslintConfigFiles() {
|
|
1703
1770
|
let removed = false;
|
|
1704
1771
|
for (const configFile of ESLINT_CONFIG_FILES) {
|
|
1705
|
-
if (
|
|
1706
|
-
|
|
1772
|
+
if (existsSync10(configFile)) {
|
|
1773
|
+
unlinkSync3(configFile);
|
|
1707
1774
|
console.log(`Removed ${configFile}`);
|
|
1708
1775
|
removed = true;
|
|
1709
1776
|
}
|
|
@@ -1724,16 +1791,16 @@ function removeEslint(options2 = {}) {
|
|
|
1724
1791
|
}
|
|
1725
1792
|
function removeEslintFromPackageJson(options2) {
|
|
1726
1793
|
const packageJsonPath = "package.json";
|
|
1727
|
-
if (!
|
|
1794
|
+
if (!existsSync11(packageJsonPath)) {
|
|
1728
1795
|
return false;
|
|
1729
1796
|
}
|
|
1730
|
-
const packageJson = JSON.parse(
|
|
1797
|
+
const packageJson = JSON.parse(readFileSync9(packageJsonPath, "utf-8"));
|
|
1731
1798
|
let modified = false;
|
|
1732
1799
|
modified = removeEslintDeps(packageJson.dependencies) || modified;
|
|
1733
1800
|
modified = removeEslintDeps(packageJson.devDependencies) || modified;
|
|
1734
1801
|
modified = removeEslintScripts(packageJson.scripts, options2) || modified;
|
|
1735
1802
|
if (modified) {
|
|
1736
|
-
|
|
1803
|
+
writeFileSync7(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
1737
1804
|
`);
|
|
1738
1805
|
console.log("Removed eslint references from package.json");
|
|
1739
1806
|
}
|
|
@@ -1797,17 +1864,17 @@ var __dirname2 = dirname7(fileURLToPath2(import.meta.url));
|
|
|
1797
1864
|
async function init() {
|
|
1798
1865
|
removeEslint();
|
|
1799
1866
|
const biomeConfigPath = "biome.json";
|
|
1800
|
-
if (!
|
|
1867
|
+
if (!existsSync12(biomeConfigPath)) {
|
|
1801
1868
|
console.log("Initializing Biome...");
|
|
1802
1869
|
execSync5("npx @biomejs/biome init", { stdio: "inherit" });
|
|
1803
1870
|
}
|
|
1804
|
-
if (!
|
|
1871
|
+
if (!existsSync12(biomeConfigPath)) {
|
|
1805
1872
|
console.log("No biome.json found, skipping linter config");
|
|
1806
1873
|
return;
|
|
1807
1874
|
}
|
|
1808
|
-
const linterConfigPath =
|
|
1809
|
-
const linterConfig = JSON.parse(
|
|
1810
|
-
const biomeConfig = JSON.parse(
|
|
1875
|
+
const linterConfigPath = join8(__dirname2, "commands/lint/biome.linter.json");
|
|
1876
|
+
const linterConfig = JSON.parse(readFileSync10(linterConfigPath, "utf-8"));
|
|
1877
|
+
const biomeConfig = JSON.parse(readFileSync10(biomeConfigPath, "utf-8"));
|
|
1811
1878
|
const oldContent = `${JSON.stringify(biomeConfig, null, 2)}
|
|
1812
1879
|
`;
|
|
1813
1880
|
biomeConfig.linter = linterConfig.linter;
|
|
@@ -1828,7 +1895,7 @@ async function init() {
|
|
|
1828
1895
|
console.log("Skipped biome.json update");
|
|
1829
1896
|
return;
|
|
1830
1897
|
}
|
|
1831
|
-
|
|
1898
|
+
writeFileSync8(biomeConfigPath, newContent);
|
|
1832
1899
|
console.log("Updated biome.json with linter config");
|
|
1833
1900
|
}
|
|
1834
1901
|
|
|
@@ -2842,11 +2909,11 @@ async function run2(options2 = {}) {
|
|
|
2842
2909
|
|
|
2843
2910
|
// src/commands/new/registerNew/initGit.ts
|
|
2844
2911
|
import { execSync as execSync9 } from "child_process";
|
|
2845
|
-
import { writeFileSync as
|
|
2912
|
+
import { writeFileSync as writeFileSync10 } from "fs";
|
|
2846
2913
|
function initGit() {
|
|
2847
2914
|
console.log("Initializing git repository...");
|
|
2848
2915
|
execSync9("git init", { stdio: "inherit" });
|
|
2849
|
-
|
|
2916
|
+
writeFileSync10(".gitignore", "dist\nnode_modules\n");
|
|
2850
2917
|
}
|
|
2851
2918
|
|
|
2852
2919
|
// src/commands/new/registerNew/newCli/initPackageJson.ts
|
|
@@ -2865,10 +2932,10 @@ function initPackageJson(name) {
|
|
|
2865
2932
|
}
|
|
2866
2933
|
|
|
2867
2934
|
// src/commands/new/registerNew/newCli/writeCliTemplate.ts
|
|
2868
|
-
import { mkdirSync as mkdirSync2, writeFileSync as
|
|
2935
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync11 } from "fs";
|
|
2869
2936
|
function writeCliTemplate(name) {
|
|
2870
2937
|
console.log("Writing tsconfig.json...");
|
|
2871
|
-
|
|
2938
|
+
writeFileSync11(
|
|
2872
2939
|
"tsconfig.json",
|
|
2873
2940
|
JSON.stringify(
|
|
2874
2941
|
{
|
|
@@ -2892,7 +2959,7 @@ function writeCliTemplate(name) {
|
|
|
2892
2959
|
)
|
|
2893
2960
|
);
|
|
2894
2961
|
console.log("Writing tsup.config.ts...");
|
|
2895
|
-
|
|
2962
|
+
writeFileSync11(
|
|
2896
2963
|
"tsup.config.ts",
|
|
2897
2964
|
`import { defineConfig } from "tsup";
|
|
2898
2965
|
export default defineConfig({
|
|
@@ -2907,7 +2974,7 @@ export default defineConfig({
|
|
|
2907
2974
|
);
|
|
2908
2975
|
console.log("Writing src/index.ts...");
|
|
2909
2976
|
mkdirSync2("src", { recursive: true });
|
|
2910
|
-
|
|
2977
|
+
writeFileSync11(
|
|
2911
2978
|
"src/index.ts",
|
|
2912
2979
|
`#!/usr/bin/env node
|
|
2913
2980
|
import { Command } from "commander";
|
|
@@ -2935,7 +3002,7 @@ async function newCli() {
|
|
|
2935
3002
|
|
|
2936
3003
|
// src/commands/new/registerNew/newProject.ts
|
|
2937
3004
|
import { execSync as execSync13 } from "child_process";
|
|
2938
|
-
import { existsSync as
|
|
3005
|
+
import { existsSync as existsSync16, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "fs";
|
|
2939
3006
|
|
|
2940
3007
|
// src/commands/deploy/init/index.ts
|
|
2941
3008
|
import { execSync as execSync12 } from "child_process";
|
|
@@ -2943,33 +3010,33 @@ import chalk40 from "chalk";
|
|
|
2943
3010
|
import enquirer5 from "enquirer";
|
|
2944
3011
|
|
|
2945
3012
|
// src/commands/deploy/init/updateWorkflow.ts
|
|
2946
|
-
import { existsSync as
|
|
2947
|
-
import { dirname as dirname13, join as
|
|
3013
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync12 } from "fs";
|
|
3014
|
+
import { dirname as dirname13, join as join11 } from "path";
|
|
2948
3015
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2949
3016
|
import chalk39 from "chalk";
|
|
2950
3017
|
var WORKFLOW_PATH = ".github/workflows/build.yml";
|
|
2951
3018
|
var __dirname3 = dirname13(fileURLToPath3(import.meta.url));
|
|
2952
3019
|
function getExistingSiteId() {
|
|
2953
|
-
if (!
|
|
3020
|
+
if (!existsSync15(WORKFLOW_PATH)) {
|
|
2954
3021
|
return null;
|
|
2955
3022
|
}
|
|
2956
|
-
const content =
|
|
3023
|
+
const content = readFileSync12(WORKFLOW_PATH, "utf-8");
|
|
2957
3024
|
const match = content.match(/-s\s+([a-f0-9-]{36})/);
|
|
2958
3025
|
return match ? match[1] : null;
|
|
2959
3026
|
}
|
|
2960
3027
|
function getTemplateContent(siteId) {
|
|
2961
|
-
const templatePath =
|
|
2962
|
-
const template =
|
|
3028
|
+
const templatePath = join11(__dirname3, "commands/deploy/build.yml");
|
|
3029
|
+
const template = readFileSync12(templatePath, "utf-8");
|
|
2963
3030
|
return template.replace("{{NETLIFY_SITE_ID}}", siteId);
|
|
2964
3031
|
}
|
|
2965
3032
|
async function updateWorkflow(siteId) {
|
|
2966
3033
|
const newContent = getTemplateContent(siteId);
|
|
2967
3034
|
const workflowDir = ".github/workflows";
|
|
2968
|
-
if (!
|
|
3035
|
+
if (!existsSync15(workflowDir)) {
|
|
2969
3036
|
mkdirSync3(workflowDir, { recursive: true });
|
|
2970
3037
|
}
|
|
2971
|
-
if (
|
|
2972
|
-
const oldContent =
|
|
3038
|
+
if (existsSync15(WORKFLOW_PATH)) {
|
|
3039
|
+
const oldContent = readFileSync12(WORKFLOW_PATH, "utf-8");
|
|
2973
3040
|
if (oldContent === newContent) {
|
|
2974
3041
|
console.log(chalk39.green("build.yml is already up to date"));
|
|
2975
3042
|
return;
|
|
@@ -2983,7 +3050,7 @@ async function updateWorkflow(siteId) {
|
|
|
2983
3050
|
return;
|
|
2984
3051
|
}
|
|
2985
3052
|
}
|
|
2986
|
-
|
|
3053
|
+
writeFileSync12(WORKFLOW_PATH, newContent);
|
|
2987
3054
|
console.log(chalk39.green(`
|
|
2988
3055
|
Created ${WORKFLOW_PATH}`));
|
|
2989
3056
|
}
|
|
@@ -3063,11 +3130,11 @@ async function newProject() {
|
|
|
3063
3130
|
}
|
|
3064
3131
|
function addViteBaseConfig() {
|
|
3065
3132
|
const viteConfigPath = "vite.config.ts";
|
|
3066
|
-
if (!
|
|
3133
|
+
if (!existsSync16(viteConfigPath)) {
|
|
3067
3134
|
console.log("No vite.config.ts found, skipping base config");
|
|
3068
3135
|
return;
|
|
3069
3136
|
}
|
|
3070
|
-
const content =
|
|
3137
|
+
const content = readFileSync13(viteConfigPath, "utf-8");
|
|
3071
3138
|
if (content.includes("base:")) {
|
|
3072
3139
|
console.log("vite.config.ts already has base config");
|
|
3073
3140
|
return;
|
|
@@ -3077,7 +3144,7 @@ function addViteBaseConfig() {
|
|
|
3077
3144
|
'defineConfig({\n base: "./",'
|
|
3078
3145
|
);
|
|
3079
3146
|
if (updated !== content) {
|
|
3080
|
-
|
|
3147
|
+
writeFileSync13(viteConfigPath, updated);
|
|
3081
3148
|
console.log('Added base: "./" to vite.config.ts');
|
|
3082
3149
|
}
|
|
3083
3150
|
}
|
|
@@ -3245,7 +3312,7 @@ function registerCommentCommands(cmd) {
|
|
|
3245
3312
|
}
|
|
3246
3313
|
|
|
3247
3314
|
// src/commands/backlog/add/index.ts
|
|
3248
|
-
import { existsSync as
|
|
3315
|
+
import { existsSync as existsSync17 } from "fs";
|
|
3249
3316
|
import chalk44 from "chalk";
|
|
3250
3317
|
|
|
3251
3318
|
// src/commands/backlog/commitBacklog.ts
|
|
@@ -3264,9 +3331,9 @@ function commitBacklog(id, name) {
|
|
|
3264
3331
|
|
|
3265
3332
|
// src/commands/backlog/add/shared.ts
|
|
3266
3333
|
import { spawnSync } from "child_process";
|
|
3267
|
-
import { mkdtempSync, readFileSync as
|
|
3334
|
+
import { mkdtempSync, readFileSync as readFileSync14, unlinkSync as unlinkSync4, writeFileSync as writeFileSync14 } from "fs";
|
|
3268
3335
|
import { tmpdir } from "os";
|
|
3269
|
-
import { join as
|
|
3336
|
+
import { join as join12 } from "path";
|
|
3270
3337
|
import enquirer6 from "enquirer";
|
|
3271
3338
|
async function promptType() {
|
|
3272
3339
|
const { type } = await enquirer6.prompt({
|
|
@@ -3306,16 +3373,16 @@ async function promptDescription() {
|
|
|
3306
3373
|
}
|
|
3307
3374
|
function openEditor() {
|
|
3308
3375
|
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
3309
|
-
const dir = mkdtempSync(
|
|
3310
|
-
const filePath =
|
|
3311
|
-
|
|
3376
|
+
const dir = mkdtempSync(join12(tmpdir(), "assist-"));
|
|
3377
|
+
const filePath = join12(dir, "description.md");
|
|
3378
|
+
writeFileSync14(filePath, "");
|
|
3312
3379
|
const result = spawnSync(editor, [filePath], { stdio: "inherit" });
|
|
3313
3380
|
if (result.status !== 0) {
|
|
3314
|
-
|
|
3381
|
+
unlinkSync4(filePath);
|
|
3315
3382
|
return void 0;
|
|
3316
3383
|
}
|
|
3317
|
-
const content =
|
|
3318
|
-
|
|
3384
|
+
const content = readFileSync14(filePath, "utf-8").trim();
|
|
3385
|
+
unlinkSync4(filePath);
|
|
3319
3386
|
return content || void 0;
|
|
3320
3387
|
}
|
|
3321
3388
|
async function promptAcceptanceCriteria() {
|
|
@@ -3372,7 +3439,7 @@ async function addInteractive() {
|
|
|
3372
3439
|
console.log(chalk44.green(`Added item #${id}: ${name}`));
|
|
3373
3440
|
}
|
|
3374
3441
|
async function add(options2) {
|
|
3375
|
-
if (!
|
|
3442
|
+
if (!existsSync17(getBacklogPath())) {
|
|
3376
3443
|
console.log(
|
|
3377
3444
|
chalk44.yellow(
|
|
3378
3445
|
"No backlog found. Run 'assist backlog init' to create one."
|
|
@@ -3388,11 +3455,11 @@ async function add(options2) {
|
|
|
3388
3455
|
}
|
|
3389
3456
|
|
|
3390
3457
|
// src/commands/backlog/init/index.ts
|
|
3391
|
-
import { existsSync as
|
|
3458
|
+
import { existsSync as existsSync18 } from "fs";
|
|
3392
3459
|
import chalk45 from "chalk";
|
|
3393
3460
|
async function init6() {
|
|
3394
3461
|
const backlogPath = getBacklogPath();
|
|
3395
|
-
if (
|
|
3462
|
+
if (existsSync18(backlogPath)) {
|
|
3396
3463
|
console.log(chalk45.yellow("assist.backlog.yml already exists."));
|
|
3397
3464
|
return;
|
|
3398
3465
|
}
|
|
@@ -3401,7 +3468,7 @@ async function init6() {
|
|
|
3401
3468
|
}
|
|
3402
3469
|
|
|
3403
3470
|
// src/commands/backlog/list/index.ts
|
|
3404
|
-
import { existsSync as
|
|
3471
|
+
import { existsSync as existsSync19 } from "fs";
|
|
3405
3472
|
import chalk46 from "chalk";
|
|
3406
3473
|
function filterItems(items, options2) {
|
|
3407
3474
|
if (options2.status) return items.filter((i) => i.status === options2.status);
|
|
@@ -3409,7 +3476,7 @@ function filterItems(items, options2) {
|
|
|
3409
3476
|
return items;
|
|
3410
3477
|
}
|
|
3411
3478
|
async function list2(options2) {
|
|
3412
|
-
if (!
|
|
3479
|
+
if (!existsSync19(getBacklogPath())) {
|
|
3413
3480
|
console.log(
|
|
3414
3481
|
chalk46.yellow(
|
|
3415
3482
|
"No backlog found. Run 'assist backlog init' to create one."
|
|
@@ -3559,7 +3626,7 @@ function extractGraphqlQuery(args) {
|
|
|
3559
3626
|
}
|
|
3560
3627
|
|
|
3561
3628
|
// src/shared/loadCliReads.ts
|
|
3562
|
-
import { existsSync as
|
|
3629
|
+
import { existsSync as existsSync20, readFileSync as readFileSync15, writeFileSync as writeFileSync15 } from "fs";
|
|
3563
3630
|
import { dirname as dirname14, resolve as resolve2 } from "path";
|
|
3564
3631
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
3565
3632
|
var __filename2 = fileURLToPath4(import.meta.url);
|
|
@@ -3571,18 +3638,18 @@ var cachedLines;
|
|
|
3571
3638
|
function getCliReadsLines() {
|
|
3572
3639
|
if (cachedLines) return cachedLines;
|
|
3573
3640
|
const path50 = getCliReadsPath();
|
|
3574
|
-
if (!
|
|
3641
|
+
if (!existsSync20(path50)) {
|
|
3575
3642
|
cachedLines = [];
|
|
3576
3643
|
return cachedLines;
|
|
3577
3644
|
}
|
|
3578
|
-
cachedLines =
|
|
3645
|
+
cachedLines = readFileSync15(path50, "utf-8").split("\n").filter((line) => line.trim() !== "");
|
|
3579
3646
|
return cachedLines;
|
|
3580
3647
|
}
|
|
3581
3648
|
function loadCliReads() {
|
|
3582
3649
|
return getCliReadsLines();
|
|
3583
3650
|
}
|
|
3584
3651
|
function saveCliReads(commands) {
|
|
3585
|
-
|
|
3652
|
+
writeFileSync15(getCliReadsPath(), `${commands.join("\n")}
|
|
3586
3653
|
`);
|
|
3587
3654
|
cachedLines = void 0;
|
|
3588
3655
|
}
|
|
@@ -3600,9 +3667,9 @@ function findCliRead(command) {
|
|
|
3600
3667
|
}
|
|
3601
3668
|
|
|
3602
3669
|
// src/shared/matchesBashAllow.ts
|
|
3603
|
-
import { existsSync as
|
|
3670
|
+
import { existsSync as existsSync21, readFileSync as readFileSync16 } from "fs";
|
|
3604
3671
|
import { homedir as homedir3 } from "os";
|
|
3605
|
-
import { join as
|
|
3672
|
+
import { join as join13 } from "path";
|
|
3606
3673
|
var cached;
|
|
3607
3674
|
function loadBashAllowPrefixes() {
|
|
3608
3675
|
if (cached) return cached;
|
|
@@ -3617,9 +3684,9 @@ function matchesBashAllow(command) {
|
|
|
3617
3684
|
}
|
|
3618
3685
|
function collectAllowEntries() {
|
|
3619
3686
|
const paths = [
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3687
|
+
join13(homedir3(), ".claude", "settings.json"),
|
|
3688
|
+
join13(process.cwd(), ".claude", "settings.json"),
|
|
3689
|
+
join13(process.cwd(), ".claude", "settings.local.json")
|
|
3623
3690
|
];
|
|
3624
3691
|
const entries = [];
|
|
3625
3692
|
for (const p of paths) {
|
|
@@ -3628,9 +3695,9 @@ function collectAllowEntries() {
|
|
|
3628
3695
|
return entries;
|
|
3629
3696
|
}
|
|
3630
3697
|
function readAllowArray(filePath) {
|
|
3631
|
-
if (!
|
|
3698
|
+
if (!existsSync21(filePath)) return [];
|
|
3632
3699
|
try {
|
|
3633
|
-
const data = JSON.parse(
|
|
3700
|
+
const data = JSON.parse(readFileSync16(filePath, "utf-8"));
|
|
3634
3701
|
const allow = data?.permissions?.allow;
|
|
3635
3702
|
return Array.isArray(allow) ? allow.filter((e) => typeof e === "string") : [];
|
|
3636
3703
|
} catch {
|
|
@@ -3780,9 +3847,9 @@ ${reasons.join("\n")}`);
|
|
|
3780
3847
|
}
|
|
3781
3848
|
|
|
3782
3849
|
// src/commands/permitCliReads/index.ts
|
|
3783
|
-
import { existsSync as
|
|
3850
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync4, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
3784
3851
|
import { homedir as homedir4 } from "os";
|
|
3785
|
-
import { join as
|
|
3852
|
+
import { join as join14 } from "path";
|
|
3786
3853
|
|
|
3787
3854
|
// src/shared/getInstallDir.ts
|
|
3788
3855
|
import { execSync as execSync15 } from "child_process";
|
|
@@ -4084,17 +4151,17 @@ function updateSettings(cli, commands) {
|
|
|
4084
4151
|
// src/commands/permitCliReads/index.ts
|
|
4085
4152
|
function logPath(cli) {
|
|
4086
4153
|
const safeName = cli.replace(/\s+/g, "-");
|
|
4087
|
-
return
|
|
4154
|
+
return join14(homedir4(), ".assist", `cli-discover-${safeName}.log`);
|
|
4088
4155
|
}
|
|
4089
4156
|
function readCache(cli) {
|
|
4090
4157
|
const path50 = logPath(cli);
|
|
4091
|
-
if (!
|
|
4092
|
-
return
|
|
4158
|
+
if (!existsSync22(path50)) return void 0;
|
|
4159
|
+
return readFileSync17(path50, "utf-8");
|
|
4093
4160
|
}
|
|
4094
4161
|
function writeCache(cli, output) {
|
|
4095
|
-
const dir =
|
|
4162
|
+
const dir = join14(homedir4(), ".assist");
|
|
4096
4163
|
mkdirSync4(dir, { recursive: true });
|
|
4097
|
-
|
|
4164
|
+
writeFileSync16(logPath(cli), output);
|
|
4098
4165
|
}
|
|
4099
4166
|
async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
4100
4167
|
if (!cli) {
|
|
@@ -4637,7 +4704,7 @@ function registerComplexity(program2) {
|
|
|
4637
4704
|
}
|
|
4638
4705
|
|
|
4639
4706
|
// src/commands/deploy/redirect.ts
|
|
4640
|
-
import { existsSync as
|
|
4707
|
+
import { existsSync as existsSync23, readFileSync as readFileSync18, writeFileSync as writeFileSync17 } from "fs";
|
|
4641
4708
|
import chalk54 from "chalk";
|
|
4642
4709
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
4643
4710
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -4646,11 +4713,11 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
4646
4713
|
</script>`;
|
|
4647
4714
|
function redirect() {
|
|
4648
4715
|
const indexPath = "index.html";
|
|
4649
|
-
if (!
|
|
4716
|
+
if (!existsSync23(indexPath)) {
|
|
4650
4717
|
console.log(chalk54.yellow("No index.html found"));
|
|
4651
4718
|
return;
|
|
4652
4719
|
}
|
|
4653
|
-
const content =
|
|
4720
|
+
const content = readFileSync18(indexPath, "utf-8");
|
|
4654
4721
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
4655
4722
|
console.log(chalk54.dim("Trailing slash script already present"));
|
|
4656
4723
|
return;
|
|
@@ -4661,7 +4728,7 @@ function redirect() {
|
|
|
4661
4728
|
return;
|
|
4662
4729
|
}
|
|
4663
4730
|
const newContent = content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT + "\n " + content.slice(headCloseIndex);
|
|
4664
|
-
|
|
4731
|
+
writeFileSync17(indexPath, newContent);
|
|
4665
4732
|
console.log(chalk54.green("Added trailing slash redirect to index.html"));
|
|
4666
4733
|
}
|
|
4667
4734
|
|
|
@@ -4678,10 +4745,10 @@ import { basename as basename3 } from "path";
|
|
|
4678
4745
|
|
|
4679
4746
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
4680
4747
|
import { homedir as homedir5 } from "os";
|
|
4681
|
-
import { join as
|
|
4682
|
-
var BLOG_REPO_ROOT =
|
|
4748
|
+
import { join as join15 } from "path";
|
|
4749
|
+
var BLOG_REPO_ROOT = join15(homedir5(), "git/blog");
|
|
4683
4750
|
function loadBlogSkipDays(repoName) {
|
|
4684
|
-
const config = loadRawYaml(
|
|
4751
|
+
const config = loadRawYaml(join15(BLOG_REPO_ROOT, "assist.yml"));
|
|
4685
4752
|
const devlog = config.devlog;
|
|
4686
4753
|
const skip2 = devlog?.skip;
|
|
4687
4754
|
return new Set(skip2?.[repoName] ?? []);
|
|
@@ -4692,9 +4759,9 @@ import { execSync as execSync17 } from "child_process";
|
|
|
4692
4759
|
import chalk55 from "chalk";
|
|
4693
4760
|
|
|
4694
4761
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
4695
|
-
import { readdirSync, readFileSync as
|
|
4696
|
-
import { join as
|
|
4697
|
-
var DEVLOG_DIR =
|
|
4762
|
+
import { readdirSync, readFileSync as readFileSync19 } from "fs";
|
|
4763
|
+
import { join as join16 } from "path";
|
|
4764
|
+
var DEVLOG_DIR = join16(BLOG_REPO_ROOT, "src/content/devlog");
|
|
4698
4765
|
function extractFrontmatter(content) {
|
|
4699
4766
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
4700
4767
|
return fm?.[1] ?? null;
|
|
@@ -4722,7 +4789,7 @@ function readDevlogFiles(callback) {
|
|
|
4722
4789
|
try {
|
|
4723
4790
|
const files = readdirSync(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
4724
4791
|
for (const file of files) {
|
|
4725
|
-
const content =
|
|
4792
|
+
const content = readFileSync19(join16(DEVLOG_DIR, file), "utf-8");
|
|
4726
4793
|
const parsed = parseFrontmatter(content, file);
|
|
4727
4794
|
if (parsed) callback(parsed);
|
|
4728
4795
|
}
|
|
@@ -5107,12 +5174,12 @@ function repos(options2) {
|
|
|
5107
5174
|
}
|
|
5108
5175
|
|
|
5109
5176
|
// src/commands/devlog/skip.ts
|
|
5110
|
-
import { writeFileSync as
|
|
5111
|
-
import { join as
|
|
5177
|
+
import { writeFileSync as writeFileSync18 } from "fs";
|
|
5178
|
+
import { join as join17 } from "path";
|
|
5112
5179
|
import chalk60 from "chalk";
|
|
5113
5180
|
import { stringify as stringifyYaml4 } from "yaml";
|
|
5114
5181
|
function getBlogConfigPath() {
|
|
5115
|
-
return
|
|
5182
|
+
return join17(BLOG_REPO_ROOT, "assist.yml");
|
|
5116
5183
|
}
|
|
5117
5184
|
function skip(date) {
|
|
5118
5185
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
@@ -5136,7 +5203,7 @@ function skip(date) {
|
|
|
5136
5203
|
skip2[repoName] = skipDays;
|
|
5137
5204
|
devlog.skip = skip2;
|
|
5138
5205
|
config.devlog = devlog;
|
|
5139
|
-
|
|
5206
|
+
writeFileSync18(configPath, stringifyYaml4(config, { lineWidth: 0 }));
|
|
5140
5207
|
console.log(chalk60.green(`Added ${date} to skip list for ${repoName}`));
|
|
5141
5208
|
}
|
|
5142
5209
|
|
|
@@ -5173,16 +5240,16 @@ function registerDevlog(program2) {
|
|
|
5173
5240
|
|
|
5174
5241
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
5175
5242
|
import { closeSync, openSync, readdirSync as readdirSync2 } from "fs";
|
|
5176
|
-
import { join as
|
|
5243
|
+
import { join as join18 } from "path";
|
|
5177
5244
|
import chalk62 from "chalk";
|
|
5178
5245
|
|
|
5179
5246
|
// src/shared/findRepoRoot.ts
|
|
5180
|
-
import { existsSync as
|
|
5247
|
+
import { existsSync as existsSync24 } from "fs";
|
|
5181
5248
|
import path21 from "path";
|
|
5182
5249
|
function findRepoRoot(dir) {
|
|
5183
5250
|
let current = dir;
|
|
5184
5251
|
while (current !== path21.dirname(current)) {
|
|
5185
|
-
if (
|
|
5252
|
+
if (existsSync24(path21.join(current, ".git"))) {
|
|
5186
5253
|
return current;
|
|
5187
5254
|
}
|
|
5188
5255
|
current = path21.dirname(current);
|
|
@@ -5201,7 +5268,7 @@ function isLockedDll(debugDir) {
|
|
|
5201
5268
|
}
|
|
5202
5269
|
for (const file of files) {
|
|
5203
5270
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
5204
|
-
const dllPath =
|
|
5271
|
+
const dllPath = join18(debugDir, file);
|
|
5205
5272
|
try {
|
|
5206
5273
|
const fd = openSync(dllPath, "r+");
|
|
5207
5274
|
closeSync(fd);
|
|
@@ -5219,13 +5286,13 @@ function findFirstLockedDll(dir) {
|
|
|
5219
5286
|
return null;
|
|
5220
5287
|
}
|
|
5221
5288
|
if (entries.includes("bin")) {
|
|
5222
|
-
const locked = isLockedDll(
|
|
5289
|
+
const locked = isLockedDll(join18(dir, "bin", "Debug"));
|
|
5223
5290
|
if (locked) return locked;
|
|
5224
5291
|
}
|
|
5225
5292
|
for (const entry of entries) {
|
|
5226
5293
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
5227
5294
|
continue;
|
|
5228
|
-
const found = findFirstLockedDll(
|
|
5295
|
+
const found = findFirstLockedDll(join18(dir, entry));
|
|
5229
5296
|
if (found) return found;
|
|
5230
5297
|
}
|
|
5231
5298
|
return null;
|
|
@@ -5248,11 +5315,11 @@ async function checkBuildLocksCommand() {
|
|
|
5248
5315
|
}
|
|
5249
5316
|
|
|
5250
5317
|
// src/commands/dotnet/buildTree.ts
|
|
5251
|
-
import { readFileSync as
|
|
5318
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
5252
5319
|
import path22 from "path";
|
|
5253
5320
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
5254
5321
|
function getProjectRefs(csprojPath) {
|
|
5255
|
-
const content =
|
|
5322
|
+
const content = readFileSync20(csprojPath, "utf-8");
|
|
5256
5323
|
const refs = [];
|
|
5257
5324
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
5258
5325
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -5269,7 +5336,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
5269
5336
|
for (const ref of getProjectRefs(abs)) {
|
|
5270
5337
|
const childAbs = path22.resolve(dir, ref);
|
|
5271
5338
|
try {
|
|
5272
|
-
|
|
5339
|
+
readFileSync20(childAbs);
|
|
5273
5340
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
5274
5341
|
} catch {
|
|
5275
5342
|
node.children.push({
|
|
@@ -5294,7 +5361,7 @@ function collectAllDeps(node) {
|
|
|
5294
5361
|
}
|
|
5295
5362
|
|
|
5296
5363
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
5297
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
5364
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync21, statSync } from "fs";
|
|
5298
5365
|
import path23 from "path";
|
|
5299
5366
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
5300
5367
|
if (depth > maxDepth) return [];
|
|
@@ -5329,7 +5396,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
5329
5396
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
5330
5397
|
for (const sln of slnFiles) {
|
|
5331
5398
|
try {
|
|
5332
|
-
const content =
|
|
5399
|
+
const content = readFileSync21(sln, "utf-8");
|
|
5333
5400
|
if (pattern2.test(content)) {
|
|
5334
5401
|
matches.push(path23.relative(repoRoot, sln));
|
|
5335
5402
|
}
|
|
@@ -5393,12 +5460,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
5393
5460
|
}
|
|
5394
5461
|
|
|
5395
5462
|
// src/commands/dotnet/resolveCsproj.ts
|
|
5396
|
-
import { existsSync as
|
|
5463
|
+
import { existsSync as existsSync25 } from "fs";
|
|
5397
5464
|
import path24 from "path";
|
|
5398
5465
|
import chalk64 from "chalk";
|
|
5399
5466
|
function resolveCsproj(csprojPath) {
|
|
5400
5467
|
const resolved = path24.resolve(csprojPath);
|
|
5401
|
-
if (!
|
|
5468
|
+
if (!existsSync25(resolved)) {
|
|
5402
5469
|
console.error(chalk64.red(`File not found: ${resolved}`));
|
|
5403
5470
|
process.exit(1);
|
|
5404
5471
|
}
|
|
@@ -5566,17 +5633,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
5566
5633
|
}
|
|
5567
5634
|
|
|
5568
5635
|
// src/commands/dotnet/resolveSolution.ts
|
|
5569
|
-
import { existsSync as
|
|
5636
|
+
import { existsSync as existsSync26 } from "fs";
|
|
5570
5637
|
import path25 from "path";
|
|
5571
5638
|
import chalk68 from "chalk";
|
|
5572
5639
|
|
|
5573
5640
|
// src/commands/dotnet/findSolution.ts
|
|
5574
5641
|
import { readdirSync as readdirSync4 } from "fs";
|
|
5575
|
-
import { dirname as dirname16, join as
|
|
5642
|
+
import { dirname as dirname16, join as join19 } from "path";
|
|
5576
5643
|
import chalk67 from "chalk";
|
|
5577
5644
|
function findSlnInDir(dir) {
|
|
5578
5645
|
try {
|
|
5579
|
-
return readdirSync4(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
5646
|
+
return readdirSync4(dir).filter((f) => f.endsWith(".sln")).map((f) => join19(dir, f));
|
|
5580
5647
|
} catch {
|
|
5581
5648
|
return [];
|
|
5582
5649
|
}
|
|
@@ -5607,7 +5674,7 @@ function findSolution() {
|
|
|
5607
5674
|
function resolveSolution(sln) {
|
|
5608
5675
|
if (sln) {
|
|
5609
5676
|
const resolved = path25.resolve(sln);
|
|
5610
|
-
if (!
|
|
5677
|
+
if (!existsSync26(resolved)) {
|
|
5611
5678
|
console.error(chalk68.red(`Solution file not found: ${resolved}`));
|
|
5612
5679
|
process.exit(1);
|
|
5613
5680
|
}
|
|
@@ -5647,7 +5714,7 @@ function parseInspectReport(json) {
|
|
|
5647
5714
|
|
|
5648
5715
|
// src/commands/dotnet/runInspectCode.ts
|
|
5649
5716
|
import { execSync as execSync23 } from "child_process";
|
|
5650
|
-
import { existsSync as
|
|
5717
|
+
import { existsSync as existsSync27, readFileSync as readFileSync22, unlinkSync as unlinkSync5 } from "fs";
|
|
5651
5718
|
import { tmpdir as tmpdir2 } from "os";
|
|
5652
5719
|
import path26 from "path";
|
|
5653
5720
|
import chalk69 from "chalk";
|
|
@@ -5678,12 +5745,12 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
5678
5745
|
console.error(chalk69.red("jb inspectcode failed"));
|
|
5679
5746
|
process.exit(1);
|
|
5680
5747
|
}
|
|
5681
|
-
if (!
|
|
5748
|
+
if (!existsSync27(reportPath)) {
|
|
5682
5749
|
console.error(chalk69.red("Report file not generated"));
|
|
5683
5750
|
process.exit(1);
|
|
5684
5751
|
}
|
|
5685
|
-
const xml =
|
|
5686
|
-
|
|
5752
|
+
const xml = readFileSync22(reportPath, "utf-8");
|
|
5753
|
+
unlinkSync5(reportPath);
|
|
5687
5754
|
return xml;
|
|
5688
5755
|
}
|
|
5689
5756
|
|
|
@@ -5910,20 +5977,20 @@ function acceptanceCriteria(issueKey) {
|
|
|
5910
5977
|
import { execSync as execSync26 } from "child_process";
|
|
5911
5978
|
|
|
5912
5979
|
// src/shared/loadJson.ts
|
|
5913
|
-
import { existsSync as
|
|
5980
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync5, readFileSync as readFileSync23, writeFileSync as writeFileSync19 } from "fs";
|
|
5914
5981
|
import { homedir as homedir6 } from "os";
|
|
5915
|
-
import { join as
|
|
5982
|
+
import { join as join20 } from "path";
|
|
5916
5983
|
function getStoreDir() {
|
|
5917
|
-
return
|
|
5984
|
+
return join20(homedir6(), ".assist");
|
|
5918
5985
|
}
|
|
5919
5986
|
function getStorePath(filename) {
|
|
5920
|
-
return
|
|
5987
|
+
return join20(getStoreDir(), filename);
|
|
5921
5988
|
}
|
|
5922
5989
|
function loadJson(filename) {
|
|
5923
5990
|
const path50 = getStorePath(filename);
|
|
5924
|
-
if (
|
|
5991
|
+
if (existsSync28(path50)) {
|
|
5925
5992
|
try {
|
|
5926
|
-
return JSON.parse(
|
|
5993
|
+
return JSON.parse(readFileSync23(path50, "utf-8"));
|
|
5927
5994
|
} catch {
|
|
5928
5995
|
return {};
|
|
5929
5996
|
}
|
|
@@ -5932,20 +5999,20 @@ function loadJson(filename) {
|
|
|
5932
5999
|
}
|
|
5933
6000
|
function saveJson(filename, data) {
|
|
5934
6001
|
const dir = getStoreDir();
|
|
5935
|
-
if (!
|
|
6002
|
+
if (!existsSync28(dir)) {
|
|
5936
6003
|
mkdirSync5(dir, { recursive: true });
|
|
5937
6004
|
}
|
|
5938
|
-
|
|
6005
|
+
writeFileSync19(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
5939
6006
|
}
|
|
5940
6007
|
|
|
5941
6008
|
// src/shared/promptInput.ts
|
|
5942
6009
|
import Enquirer from "enquirer";
|
|
5943
6010
|
var prompts = Enquirer;
|
|
5944
6011
|
async function promptInput(name, message, initial) {
|
|
5945
|
-
return new prompts.Input({ name, message, initial }).run();
|
|
6012
|
+
return exitOnCancel(new prompts.Input({ name, message, initial }).run());
|
|
5946
6013
|
}
|
|
5947
6014
|
async function promptPassword(name, message) {
|
|
5948
|
-
return new prompts.Password({ name, message }).run();
|
|
6015
|
+
return exitOnCancel(new prompts.Password({ name, message }).run());
|
|
5949
6016
|
}
|
|
5950
6017
|
|
|
5951
6018
|
// src/commands/jira/jiraAuth.ts
|
|
@@ -6247,9 +6314,9 @@ function registerNews(program2) {
|
|
|
6247
6314
|
|
|
6248
6315
|
// src/commands/prs/comment.ts
|
|
6249
6316
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
6250
|
-
import { unlinkSync as
|
|
6317
|
+
import { unlinkSync as unlinkSync6, writeFileSync as writeFileSync20 } from "fs";
|
|
6251
6318
|
import { tmpdir as tmpdir3 } from "os";
|
|
6252
|
-
import { join as
|
|
6319
|
+
import { join as join21 } from "path";
|
|
6253
6320
|
|
|
6254
6321
|
// src/commands/prs/shared.ts
|
|
6255
6322
|
import { execSync as execSync27 } from "child_process";
|
|
@@ -6321,8 +6388,8 @@ function comment2(path50, line, body) {
|
|
|
6321
6388
|
validateLine(line);
|
|
6322
6389
|
try {
|
|
6323
6390
|
const prId = getCurrentPrNodeId();
|
|
6324
|
-
const queryFile =
|
|
6325
|
-
|
|
6391
|
+
const queryFile = join21(tmpdir3(), `gh-query-${Date.now()}.graphql`);
|
|
6392
|
+
writeFileSync20(queryFile, MUTATION);
|
|
6326
6393
|
try {
|
|
6327
6394
|
const result = spawnSync2(
|
|
6328
6395
|
"gh",
|
|
@@ -6347,7 +6414,7 @@ function comment2(path50, line, body) {
|
|
|
6347
6414
|
}
|
|
6348
6415
|
console.log(`Added review comment on ${path50}:${line}`);
|
|
6349
6416
|
} finally {
|
|
6350
|
-
|
|
6417
|
+
unlinkSync6(queryFile);
|
|
6351
6418
|
}
|
|
6352
6419
|
} catch (error) {
|
|
6353
6420
|
if (isGhNotInstalled(error)) {
|
|
@@ -6364,29 +6431,29 @@ import { execSync as execSync29 } from "child_process";
|
|
|
6364
6431
|
|
|
6365
6432
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
6366
6433
|
import { execSync as execSync28 } from "child_process";
|
|
6367
|
-
import { unlinkSync as
|
|
6434
|
+
import { unlinkSync as unlinkSync8, writeFileSync as writeFileSync21 } from "fs";
|
|
6368
6435
|
import { tmpdir as tmpdir4 } from "os";
|
|
6369
|
-
import { join as
|
|
6436
|
+
import { join as join23 } from "path";
|
|
6370
6437
|
|
|
6371
6438
|
// src/commands/prs/loadCommentsCache.ts
|
|
6372
|
-
import { existsSync as
|
|
6373
|
-
import { join as
|
|
6439
|
+
import { existsSync as existsSync29, readFileSync as readFileSync24, unlinkSync as unlinkSync7 } from "fs";
|
|
6440
|
+
import { join as join22 } from "path";
|
|
6374
6441
|
import { parse as parse2 } from "yaml";
|
|
6375
6442
|
function getCachePath(prNumber) {
|
|
6376
|
-
return
|
|
6443
|
+
return join22(process.cwd(), ".assist", `pr-${prNumber}-comments.yaml`);
|
|
6377
6444
|
}
|
|
6378
6445
|
function loadCommentsCache(prNumber) {
|
|
6379
6446
|
const cachePath = getCachePath(prNumber);
|
|
6380
|
-
if (!
|
|
6447
|
+
if (!existsSync29(cachePath)) {
|
|
6381
6448
|
return null;
|
|
6382
6449
|
}
|
|
6383
|
-
const content =
|
|
6450
|
+
const content = readFileSync24(cachePath, "utf-8");
|
|
6384
6451
|
return parse2(content);
|
|
6385
6452
|
}
|
|
6386
6453
|
function deleteCommentsCache(prNumber) {
|
|
6387
6454
|
const cachePath = getCachePath(prNumber);
|
|
6388
|
-
if (
|
|
6389
|
-
|
|
6455
|
+
if (existsSync29(cachePath)) {
|
|
6456
|
+
unlinkSync7(cachePath);
|
|
6390
6457
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
6391
6458
|
}
|
|
6392
6459
|
}
|
|
@@ -6400,15 +6467,15 @@ function replyToComment(org, repo, prNumber, commentId, message) {
|
|
|
6400
6467
|
}
|
|
6401
6468
|
function resolveThread(threadId) {
|
|
6402
6469
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
6403
|
-
const queryFile =
|
|
6404
|
-
|
|
6470
|
+
const queryFile = join23(tmpdir4(), `gh-mutation-${Date.now()}.graphql`);
|
|
6471
|
+
writeFileSync21(queryFile, mutation);
|
|
6405
6472
|
try {
|
|
6406
6473
|
execSync28(
|
|
6407
6474
|
`gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
|
|
6408
6475
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
6409
6476
|
);
|
|
6410
6477
|
} finally {
|
|
6411
|
-
|
|
6478
|
+
unlinkSync8(queryFile);
|
|
6412
6479
|
}
|
|
6413
6480
|
}
|
|
6414
6481
|
function requireCache(prNumber) {
|
|
@@ -6482,19 +6549,19 @@ function fixed(commentId, sha) {
|
|
|
6482
6549
|
}
|
|
6483
6550
|
|
|
6484
6551
|
// src/commands/prs/listComments/index.ts
|
|
6485
|
-
import { existsSync as
|
|
6486
|
-
import { join as
|
|
6552
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync6, writeFileSync as writeFileSync23 } from "fs";
|
|
6553
|
+
import { join as join25 } from "path";
|
|
6487
6554
|
import { stringify } from "yaml";
|
|
6488
6555
|
|
|
6489
6556
|
// src/commands/prs/fetchThreadIds.ts
|
|
6490
6557
|
import { execSync as execSync30 } from "child_process";
|
|
6491
|
-
import { unlinkSync as
|
|
6558
|
+
import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync22 } from "fs";
|
|
6492
6559
|
import { tmpdir as tmpdir5 } from "os";
|
|
6493
|
-
import { join as
|
|
6560
|
+
import { join as join24 } from "path";
|
|
6494
6561
|
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 } } } } } } }`;
|
|
6495
6562
|
function fetchThreadIds(org, repo, prNumber) {
|
|
6496
|
-
const queryFile =
|
|
6497
|
-
|
|
6563
|
+
const queryFile = join24(tmpdir5(), `gh-query-${Date.now()}.graphql`);
|
|
6564
|
+
writeFileSync22(queryFile, THREAD_QUERY);
|
|
6498
6565
|
try {
|
|
6499
6566
|
const result = execSync30(
|
|
6500
6567
|
`gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
|
|
@@ -6513,7 +6580,7 @@ function fetchThreadIds(org, repo, prNumber) {
|
|
|
6513
6580
|
}
|
|
6514
6581
|
return { threadMap, resolvedThreadIds };
|
|
6515
6582
|
} finally {
|
|
6516
|
-
|
|
6583
|
+
unlinkSync9(queryFile);
|
|
6517
6584
|
}
|
|
6518
6585
|
}
|
|
6519
6586
|
|
|
@@ -6607,8 +6674,8 @@ function printComments2(result) {
|
|
|
6607
6674
|
|
|
6608
6675
|
// src/commands/prs/listComments/index.ts
|
|
6609
6676
|
function writeCommentsCache(prNumber, comments2) {
|
|
6610
|
-
const assistDir =
|
|
6611
|
-
if (!
|
|
6677
|
+
const assistDir = join25(process.cwd(), ".assist");
|
|
6678
|
+
if (!existsSync30(assistDir)) {
|
|
6612
6679
|
mkdirSync6(assistDir, { recursive: true });
|
|
6613
6680
|
}
|
|
6614
6681
|
const cacheData = {
|
|
@@ -6616,8 +6683,8 @@ function writeCommentsCache(prNumber, comments2) {
|
|
|
6616
6683
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6617
6684
|
comments: comments2
|
|
6618
6685
|
};
|
|
6619
|
-
const cachePath =
|
|
6620
|
-
|
|
6686
|
+
const cachePath = join25(assistDir, `pr-${prNumber}-comments.yaml`);
|
|
6687
|
+
writeFileSync23(cachePath, stringify(cacheData));
|
|
6621
6688
|
}
|
|
6622
6689
|
function handleKnownErrors(error) {
|
|
6623
6690
|
if (isGhNotInstalled(error)) {
|
|
@@ -6649,7 +6716,7 @@ async function listComments() {
|
|
|
6649
6716
|
];
|
|
6650
6717
|
updateCache(prNumber, allComments);
|
|
6651
6718
|
const hasLineComments = allComments.some((c) => c.type === "line");
|
|
6652
|
-
const cachePath = hasLineComments ?
|
|
6719
|
+
const cachePath = hasLineComments ? join25(process.cwd(), ".assist", `pr-${prNumber}-comments.yaml`) : null;
|
|
6653
6720
|
return { comments: allComments, cachePath };
|
|
6654
6721
|
} catch (error) {
|
|
6655
6722
|
const handled = handleKnownErrors(error);
|
|
@@ -8968,8 +9035,8 @@ function registerSeq(program2) {
|
|
|
8968
9035
|
}
|
|
8969
9036
|
|
|
8970
9037
|
// src/commands/transcript/shared.ts
|
|
8971
|
-
import { existsSync as
|
|
8972
|
-
import { basename as basename4, join as
|
|
9038
|
+
import { existsSync as existsSync31, readdirSync as readdirSync5, statSync as statSync2 } from "fs";
|
|
9039
|
+
import { basename as basename4, join as join26, relative } from "path";
|
|
8973
9040
|
import * as readline2 from "readline";
|
|
8974
9041
|
var DATE_PREFIX_REGEX = /^\d{4}-\d{2}-\d{2}/;
|
|
8975
9042
|
function getDatePrefix(daysOffset = 0) {
|
|
@@ -8984,10 +9051,10 @@ function isValidDatePrefix(filename) {
|
|
|
8984
9051
|
return DATE_PREFIX_REGEX.test(filename);
|
|
8985
9052
|
}
|
|
8986
9053
|
function collectFiles(dir, extension) {
|
|
8987
|
-
if (!
|
|
9054
|
+
if (!existsSync31(dir)) return [];
|
|
8988
9055
|
const results = [];
|
|
8989
9056
|
for (const entry of readdirSync5(dir)) {
|
|
8990
|
-
const fullPath =
|
|
9057
|
+
const fullPath = join26(dir, entry);
|
|
8991
9058
|
if (statSync2(fullPath).isDirectory()) {
|
|
8992
9059
|
results.push(...collectFiles(fullPath, extension));
|
|
8993
9060
|
} else if (entry.endsWith(extension)) {
|
|
@@ -9081,14 +9148,14 @@ async function configure() {
|
|
|
9081
9148
|
}
|
|
9082
9149
|
|
|
9083
9150
|
// src/commands/transcript/format/index.ts
|
|
9084
|
-
import { existsSync as
|
|
9151
|
+
import { existsSync as existsSync33 } from "fs";
|
|
9085
9152
|
|
|
9086
9153
|
// src/commands/transcript/format/fixInvalidDatePrefixes/index.ts
|
|
9087
|
-
import { dirname as dirname18, join as
|
|
9154
|
+
import { dirname as dirname18, join as join28 } from "path";
|
|
9088
9155
|
|
|
9089
9156
|
// src/commands/transcript/format/fixInvalidDatePrefixes/promptForDateFix.ts
|
|
9090
9157
|
import { renameSync } from "fs";
|
|
9091
|
-
import { join as
|
|
9158
|
+
import { join as join27 } from "path";
|
|
9092
9159
|
async function resolveDate(rl, choice) {
|
|
9093
9160
|
if (choice === "1") return getDatePrefix(0);
|
|
9094
9161
|
if (choice === "2") return getDatePrefix(-1);
|
|
@@ -9103,7 +9170,7 @@ async function resolveDate(rl, choice) {
|
|
|
9103
9170
|
}
|
|
9104
9171
|
function renameWithPrefix(vttDir, vttFile, prefix2) {
|
|
9105
9172
|
const newFilename = `${prefix2}.${vttFile}`;
|
|
9106
|
-
renameSync(
|
|
9173
|
+
renameSync(join27(vttDir, vttFile), join27(vttDir, newFilename));
|
|
9107
9174
|
console.log(`Renamed to: ${newFilename}`);
|
|
9108
9175
|
return newFilename;
|
|
9109
9176
|
}
|
|
@@ -9137,12 +9204,12 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
9137
9204
|
const vttFileDir = dirname18(vttFile.absolutePath);
|
|
9138
9205
|
const newFilename = await promptForDateFix(vttFile.filename, vttFileDir);
|
|
9139
9206
|
if (newFilename) {
|
|
9140
|
-
const newRelativePath =
|
|
9207
|
+
const newRelativePath = join28(
|
|
9141
9208
|
dirname18(vttFile.relativePath),
|
|
9142
9209
|
newFilename
|
|
9143
9210
|
);
|
|
9144
9211
|
vttFiles[i] = {
|
|
9145
|
-
absolutePath:
|
|
9212
|
+
absolutePath: join28(vttFileDir, newFilename),
|
|
9146
9213
|
relativePath: newRelativePath,
|
|
9147
9214
|
filename: newFilename
|
|
9148
9215
|
};
|
|
@@ -9155,8 +9222,8 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
9155
9222
|
}
|
|
9156
9223
|
|
|
9157
9224
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
9158
|
-
import { existsSync as
|
|
9159
|
-
import { basename as basename5, dirname as dirname19, join as
|
|
9225
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync7, readFileSync as readFileSync25, writeFileSync as writeFileSync24 } from "fs";
|
|
9226
|
+
import { basename as basename5, dirname as dirname19, join as join29 } from "path";
|
|
9160
9227
|
|
|
9161
9228
|
// src/commands/transcript/cleanText.ts
|
|
9162
9229
|
function cleanText(text) {
|
|
@@ -9366,21 +9433,21 @@ function toMdFilename(vttFilename) {
|
|
|
9366
9433
|
return `${basename5(vttFilename, ".vtt").replace(/\s*Transcription\s*/g, " ").trim()}.md`;
|
|
9367
9434
|
}
|
|
9368
9435
|
function resolveOutputDir(relativeDir, transcriptsDir) {
|
|
9369
|
-
return relativeDir === "." ? transcriptsDir :
|
|
9436
|
+
return relativeDir === "." ? transcriptsDir : join29(transcriptsDir, relativeDir);
|
|
9370
9437
|
}
|
|
9371
9438
|
function buildOutputPaths(vttFile, transcriptsDir) {
|
|
9372
9439
|
const mdFile = toMdFilename(vttFile.filename);
|
|
9373
9440
|
const relativeDir = dirname19(vttFile.relativePath);
|
|
9374
9441
|
const outputDir = resolveOutputDir(relativeDir, transcriptsDir);
|
|
9375
|
-
const outputPath =
|
|
9442
|
+
const outputPath = join29(outputDir, mdFile);
|
|
9376
9443
|
return { outputDir, outputPath, mdFile, relativeDir };
|
|
9377
9444
|
}
|
|
9378
9445
|
function logSkipped(relativeDir, mdFile) {
|
|
9379
|
-
console.log(`Skipping (already exists): ${
|
|
9446
|
+
console.log(`Skipping (already exists): ${join29(relativeDir, mdFile)}`);
|
|
9380
9447
|
return "skipped";
|
|
9381
9448
|
}
|
|
9382
9449
|
function ensureDirectory(dir, label2) {
|
|
9383
|
-
if (!
|
|
9450
|
+
if (!existsSync32(dir)) {
|
|
9384
9451
|
mkdirSync7(dir, { recursive: true });
|
|
9385
9452
|
console.log(`Created ${label2}: ${dir}`);
|
|
9386
9453
|
}
|
|
@@ -9403,10 +9470,10 @@ function logReduction(cueCount, messageCount) {
|
|
|
9403
9470
|
}
|
|
9404
9471
|
function readAndParseCues(inputPath) {
|
|
9405
9472
|
console.log(`Reading: ${inputPath}`);
|
|
9406
|
-
return processCues(
|
|
9473
|
+
return processCues(readFileSync25(inputPath, "utf-8"));
|
|
9407
9474
|
}
|
|
9408
9475
|
function writeFormatted(outputPath, content) {
|
|
9409
|
-
|
|
9476
|
+
writeFileSync24(outputPath, content, "utf-8");
|
|
9410
9477
|
console.log(`Written: ${outputPath}`);
|
|
9411
9478
|
}
|
|
9412
9479
|
function convertVttToMarkdown(inputPath, outputPath) {
|
|
@@ -9416,7 +9483,7 @@ function convertVttToMarkdown(inputPath, outputPath) {
|
|
|
9416
9483
|
logReduction(cues.length, chatMessages.length);
|
|
9417
9484
|
}
|
|
9418
9485
|
function tryProcessVtt(vttFile, paths) {
|
|
9419
|
-
if (
|
|
9486
|
+
if (existsSync32(paths.outputPath))
|
|
9420
9487
|
return logSkipped(paths.relativeDir, paths.mdFile);
|
|
9421
9488
|
convertVttToMarkdown(vttFile.absolutePath, paths.outputPath);
|
|
9422
9489
|
return "processed";
|
|
@@ -9442,7 +9509,7 @@ function processAllFiles(vttFiles, transcriptsDir) {
|
|
|
9442
9509
|
logSummary(counts);
|
|
9443
9510
|
}
|
|
9444
9511
|
function requireVttDir(vttDir) {
|
|
9445
|
-
if (!
|
|
9512
|
+
if (!existsSync33(vttDir)) {
|
|
9446
9513
|
console.error(`VTT directory not found: ${vttDir}`);
|
|
9447
9514
|
process.exit(1);
|
|
9448
9515
|
}
|
|
@@ -9474,18 +9541,18 @@ async function format() {
|
|
|
9474
9541
|
}
|
|
9475
9542
|
|
|
9476
9543
|
// src/commands/transcript/summarise/index.ts
|
|
9477
|
-
import { existsSync as
|
|
9478
|
-
import { basename as basename6, dirname as dirname21, join as
|
|
9544
|
+
import { existsSync as existsSync35 } from "fs";
|
|
9545
|
+
import { basename as basename6, dirname as dirname21, join as join31, relative as relative2 } from "path";
|
|
9479
9546
|
|
|
9480
9547
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
9481
9548
|
import {
|
|
9482
|
-
existsSync as
|
|
9549
|
+
existsSync as existsSync34,
|
|
9483
9550
|
mkdirSync as mkdirSync8,
|
|
9484
|
-
readFileSync as
|
|
9551
|
+
readFileSync as readFileSync26,
|
|
9485
9552
|
renameSync as renameSync2,
|
|
9486
9553
|
rmSync
|
|
9487
9554
|
} from "fs";
|
|
9488
|
-
import { dirname as dirname20, join as
|
|
9555
|
+
import { dirname as dirname20, join as join30 } from "path";
|
|
9489
9556
|
|
|
9490
9557
|
// src/commands/transcript/summarise/processStagedFile/validateStagedContent.ts
|
|
9491
9558
|
import chalk107 from "chalk";
|
|
@@ -9514,9 +9581,9 @@ function validateStagedContent(filename, content) {
|
|
|
9514
9581
|
}
|
|
9515
9582
|
|
|
9516
9583
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
9517
|
-
var STAGING_DIR =
|
|
9584
|
+
var STAGING_DIR = join30(process.cwd(), ".assist", "transcript");
|
|
9518
9585
|
function processStagedFile() {
|
|
9519
|
-
if (!
|
|
9586
|
+
if (!existsSync34(STAGING_DIR)) {
|
|
9520
9587
|
return false;
|
|
9521
9588
|
}
|
|
9522
9589
|
const stagedFiles = findMdFilesRecursive(STAGING_DIR);
|
|
@@ -9525,7 +9592,7 @@ function processStagedFile() {
|
|
|
9525
9592
|
}
|
|
9526
9593
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
9527
9594
|
const stagedFile = stagedFiles[0];
|
|
9528
|
-
const content =
|
|
9595
|
+
const content = readFileSync26(stagedFile.absolutePath, "utf-8");
|
|
9529
9596
|
validateStagedContent(stagedFile.filename, content);
|
|
9530
9597
|
const stagedBaseName = getTranscriptBaseName(stagedFile.filename);
|
|
9531
9598
|
const transcriptFiles = findMdFilesRecursive(transcriptsDir);
|
|
@@ -9538,9 +9605,9 @@ function processStagedFile() {
|
|
|
9538
9605
|
);
|
|
9539
9606
|
process.exit(1);
|
|
9540
9607
|
}
|
|
9541
|
-
const destPath =
|
|
9608
|
+
const destPath = join30(summaryDir, matchingTranscript.relativePath);
|
|
9542
9609
|
const destDir = dirname20(destPath);
|
|
9543
|
-
if (!
|
|
9610
|
+
if (!existsSync34(destDir)) {
|
|
9544
9611
|
mkdirSync8(destDir, { recursive: true });
|
|
9545
9612
|
}
|
|
9546
9613
|
renameSync2(stagedFile.absolutePath, destPath);
|
|
@@ -9554,7 +9621,7 @@ function processStagedFile() {
|
|
|
9554
9621
|
// src/commands/transcript/summarise/index.ts
|
|
9555
9622
|
function buildRelativeKey(relativePath, baseName) {
|
|
9556
9623
|
const relDir = dirname21(relativePath);
|
|
9557
|
-
return relDir === "." ? baseName :
|
|
9624
|
+
return relDir === "." ? baseName : join31(relDir, baseName);
|
|
9558
9625
|
}
|
|
9559
9626
|
function buildSummaryIndex(summaryDir) {
|
|
9560
9627
|
const summaryFiles = findMdFilesRecursive(summaryDir);
|
|
@@ -9567,7 +9634,7 @@ function buildSummaryIndex(summaryDir) {
|
|
|
9567
9634
|
function summarise2() {
|
|
9568
9635
|
processStagedFile();
|
|
9569
9636
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
9570
|
-
if (!
|
|
9637
|
+
if (!existsSync35(transcriptsDir)) {
|
|
9571
9638
|
console.log("No transcripts directory found.");
|
|
9572
9639
|
return;
|
|
9573
9640
|
}
|
|
@@ -9588,8 +9655,8 @@ function summarise2() {
|
|
|
9588
9655
|
}
|
|
9589
9656
|
const next3 = missing[0];
|
|
9590
9657
|
const outputFilename = `${getTranscriptBaseName(next3.filename)}.md`;
|
|
9591
|
-
const outputPath =
|
|
9592
|
-
const summaryFileDir =
|
|
9658
|
+
const outputPath = join31(STAGING_DIR, outputFilename);
|
|
9659
|
+
const summaryFileDir = join31(summaryDir, dirname21(next3.relativePath));
|
|
9593
9660
|
const relativeTranscriptPath = encodeURI(
|
|
9594
9661
|
relative2(summaryFileDir, next3.absolutePath).replace(/\\/g, "/")
|
|
9595
9662
|
);
|
|
@@ -9635,50 +9702,50 @@ function registerVerify(program2) {
|
|
|
9635
9702
|
|
|
9636
9703
|
// src/commands/voice/devices.ts
|
|
9637
9704
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
9638
|
-
import { join as
|
|
9705
|
+
import { join as join33 } from "path";
|
|
9639
9706
|
|
|
9640
9707
|
// src/commands/voice/shared.ts
|
|
9641
9708
|
import { homedir as homedir7 } from "os";
|
|
9642
|
-
import { dirname as dirname22, join as
|
|
9709
|
+
import { dirname as dirname22, join as join32 } from "path";
|
|
9643
9710
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
9644
9711
|
var __dirname6 = dirname22(fileURLToPath6(import.meta.url));
|
|
9645
|
-
var VOICE_DIR =
|
|
9712
|
+
var VOICE_DIR = join32(homedir7(), ".assist", "voice");
|
|
9646
9713
|
var voicePaths = {
|
|
9647
9714
|
dir: VOICE_DIR,
|
|
9648
|
-
pid:
|
|
9649
|
-
log:
|
|
9650
|
-
venv:
|
|
9651
|
-
lock:
|
|
9715
|
+
pid: join32(VOICE_DIR, "voice.pid"),
|
|
9716
|
+
log: join32(VOICE_DIR, "voice.log"),
|
|
9717
|
+
venv: join32(VOICE_DIR, ".venv"),
|
|
9718
|
+
lock: join32(VOICE_DIR, "voice.lock")
|
|
9652
9719
|
};
|
|
9653
9720
|
function getPythonDir() {
|
|
9654
|
-
return
|
|
9721
|
+
return join32(__dirname6, "commands", "voice", "python");
|
|
9655
9722
|
}
|
|
9656
9723
|
function getVenvPython() {
|
|
9657
|
-
return process.platform === "win32" ?
|
|
9724
|
+
return process.platform === "win32" ? join32(voicePaths.venv, "Scripts", "python.exe") : join32(voicePaths.venv, "bin", "python");
|
|
9658
9725
|
}
|
|
9659
9726
|
function getLockDir() {
|
|
9660
9727
|
const config = loadConfig();
|
|
9661
9728
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
9662
9729
|
}
|
|
9663
9730
|
function getLockFile() {
|
|
9664
|
-
return
|
|
9731
|
+
return join32(getLockDir(), "voice.lock");
|
|
9665
9732
|
}
|
|
9666
9733
|
|
|
9667
9734
|
// src/commands/voice/devices.ts
|
|
9668
9735
|
function devices() {
|
|
9669
|
-
const script =
|
|
9736
|
+
const script = join33(getPythonDir(), "list_devices.py");
|
|
9670
9737
|
spawnSync3(getVenvPython(), [script], { stdio: "inherit" });
|
|
9671
9738
|
}
|
|
9672
9739
|
|
|
9673
9740
|
// src/commands/voice/logs.ts
|
|
9674
|
-
import { existsSync as
|
|
9741
|
+
import { existsSync as existsSync36, readFileSync as readFileSync27 } from "fs";
|
|
9675
9742
|
function logs(options2) {
|
|
9676
|
-
if (!
|
|
9743
|
+
if (!existsSync36(voicePaths.log)) {
|
|
9677
9744
|
console.log("No voice log file found");
|
|
9678
9745
|
return;
|
|
9679
9746
|
}
|
|
9680
9747
|
const count = Number.parseInt(options2.lines ?? "150", 10);
|
|
9681
|
-
const content =
|
|
9748
|
+
const content = readFileSync27(voicePaths.log, "utf-8").trim();
|
|
9682
9749
|
if (!content) {
|
|
9683
9750
|
console.log("Voice log is empty");
|
|
9684
9751
|
return;
|
|
@@ -9701,13 +9768,13 @@ function logs(options2) {
|
|
|
9701
9768
|
// src/commands/voice/setup.ts
|
|
9702
9769
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
9703
9770
|
import { mkdirSync as mkdirSync10 } from "fs";
|
|
9704
|
-
import { join as
|
|
9771
|
+
import { join as join35 } from "path";
|
|
9705
9772
|
|
|
9706
9773
|
// src/commands/voice/checkLockFile.ts
|
|
9707
9774
|
import { execSync as execSync37 } from "child_process";
|
|
9708
|
-
import { existsSync as
|
|
9709
|
-
import { join as
|
|
9710
|
-
function
|
|
9775
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync9, readFileSync as readFileSync28, writeFileSync as writeFileSync25 } from "fs";
|
|
9776
|
+
import { join as join34 } from "path";
|
|
9777
|
+
function isProcessAlive2(pid) {
|
|
9711
9778
|
try {
|
|
9712
9779
|
process.kill(pid, 0);
|
|
9713
9780
|
return true;
|
|
@@ -9717,10 +9784,10 @@ function isProcessAlive(pid) {
|
|
|
9717
9784
|
}
|
|
9718
9785
|
function checkLockFile() {
|
|
9719
9786
|
const lockFile = getLockFile();
|
|
9720
|
-
if (!
|
|
9787
|
+
if (!existsSync37(lockFile)) return;
|
|
9721
9788
|
try {
|
|
9722
|
-
const lock = JSON.parse(
|
|
9723
|
-
if (lock.pid &&
|
|
9789
|
+
const lock = JSON.parse(readFileSync28(lockFile, "utf-8"));
|
|
9790
|
+
if (lock.pid && isProcessAlive2(lock.pid)) {
|
|
9724
9791
|
console.error(
|
|
9725
9792
|
`Voice daemon already running (PID ${lock.pid}, env: ${lock.env}). Stop it first with: assist voice stop`
|
|
9726
9793
|
);
|
|
@@ -9730,7 +9797,7 @@ function checkLockFile() {
|
|
|
9730
9797
|
}
|
|
9731
9798
|
}
|
|
9732
9799
|
function bootstrapVenv() {
|
|
9733
|
-
if (
|
|
9800
|
+
if (existsSync37(getVenvPython())) return;
|
|
9734
9801
|
console.log("Setting up Python environment...");
|
|
9735
9802
|
const pythonDir = getPythonDir();
|
|
9736
9803
|
execSync37(
|
|
@@ -9743,8 +9810,8 @@ function bootstrapVenv() {
|
|
|
9743
9810
|
}
|
|
9744
9811
|
function writeLockFile(pid) {
|
|
9745
9812
|
const lockFile = getLockFile();
|
|
9746
|
-
mkdirSync9(
|
|
9747
|
-
|
|
9813
|
+
mkdirSync9(join34(lockFile, ".."), { recursive: true });
|
|
9814
|
+
writeFileSync25(
|
|
9748
9815
|
lockFile,
|
|
9749
9816
|
JSON.stringify({
|
|
9750
9817
|
pid,
|
|
@@ -9759,7 +9826,7 @@ function setup() {
|
|
|
9759
9826
|
mkdirSync10(voicePaths.dir, { recursive: true });
|
|
9760
9827
|
bootstrapVenv();
|
|
9761
9828
|
console.log("\nDownloading models...\n");
|
|
9762
|
-
const script =
|
|
9829
|
+
const script = join35(getPythonDir(), "setup_models.py");
|
|
9763
9830
|
const result = spawnSync4(getVenvPython(), [script], {
|
|
9764
9831
|
stdio: "inherit",
|
|
9765
9832
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -9772,8 +9839,8 @@ function setup() {
|
|
|
9772
9839
|
|
|
9773
9840
|
// src/commands/voice/start.ts
|
|
9774
9841
|
import { spawn as spawn5 } from "child_process";
|
|
9775
|
-
import { mkdirSync as mkdirSync11, writeFileSync as
|
|
9776
|
-
import { join as
|
|
9842
|
+
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync26 } from "fs";
|
|
9843
|
+
import { join as join36 } from "path";
|
|
9777
9844
|
|
|
9778
9845
|
// src/commands/voice/buildDaemonEnv.ts
|
|
9779
9846
|
function buildDaemonEnv(options2) {
|
|
@@ -9801,7 +9868,7 @@ function spawnBackground(python, script, env) {
|
|
|
9801
9868
|
console.error("Failed to start voice daemon");
|
|
9802
9869
|
process.exit(1);
|
|
9803
9870
|
}
|
|
9804
|
-
|
|
9871
|
+
writeFileSync26(voicePaths.pid, String(pid));
|
|
9805
9872
|
writeLockFile(pid);
|
|
9806
9873
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
9807
9874
|
}
|
|
@@ -9811,7 +9878,7 @@ function start2(options2) {
|
|
|
9811
9878
|
bootstrapVenv();
|
|
9812
9879
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
9813
9880
|
const env = buildDaemonEnv({ debug });
|
|
9814
|
-
const script =
|
|
9881
|
+
const script = join36(getPythonDir(), "voice_daemon.py");
|
|
9815
9882
|
const python = getVenvPython();
|
|
9816
9883
|
if (options2.foreground) {
|
|
9817
9884
|
spawnForeground(python, script, env);
|
|
@@ -9821,8 +9888,8 @@ function start2(options2) {
|
|
|
9821
9888
|
}
|
|
9822
9889
|
|
|
9823
9890
|
// src/commands/voice/status.ts
|
|
9824
|
-
import { existsSync as
|
|
9825
|
-
function
|
|
9891
|
+
import { existsSync as existsSync38, readFileSync as readFileSync29 } from "fs";
|
|
9892
|
+
function isProcessAlive3(pid) {
|
|
9826
9893
|
try {
|
|
9827
9894
|
process.kill(pid, 0);
|
|
9828
9895
|
return true;
|
|
@@ -9831,17 +9898,17 @@ function isProcessAlive2(pid) {
|
|
|
9831
9898
|
}
|
|
9832
9899
|
}
|
|
9833
9900
|
function readRecentLogs(count) {
|
|
9834
|
-
if (!
|
|
9835
|
-
const lines =
|
|
9901
|
+
if (!existsSync38(voicePaths.log)) return [];
|
|
9902
|
+
const lines = readFileSync29(voicePaths.log, "utf-8").trim().split("\n");
|
|
9836
9903
|
return lines.slice(-count);
|
|
9837
9904
|
}
|
|
9838
9905
|
function status() {
|
|
9839
|
-
if (!
|
|
9906
|
+
if (!existsSync38(voicePaths.pid)) {
|
|
9840
9907
|
console.log("Voice daemon: not running (no PID file)");
|
|
9841
9908
|
return;
|
|
9842
9909
|
}
|
|
9843
|
-
const pid = Number.parseInt(
|
|
9844
|
-
const alive =
|
|
9910
|
+
const pid = Number.parseInt(readFileSync29(voicePaths.pid, "utf-8").trim(), 10);
|
|
9911
|
+
const alive = isProcessAlive3(pid);
|
|
9845
9912
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
9846
9913
|
const recent = readRecentLogs(5);
|
|
9847
9914
|
if (recent.length > 0) {
|
|
@@ -9859,13 +9926,13 @@ function status() {
|
|
|
9859
9926
|
}
|
|
9860
9927
|
|
|
9861
9928
|
// src/commands/voice/stop.ts
|
|
9862
|
-
import { existsSync as
|
|
9929
|
+
import { existsSync as existsSync39, readFileSync as readFileSync30, unlinkSync as unlinkSync10 } from "fs";
|
|
9863
9930
|
function stop() {
|
|
9864
|
-
if (!
|
|
9931
|
+
if (!existsSync39(voicePaths.pid)) {
|
|
9865
9932
|
console.log("Voice daemon is not running (no PID file)");
|
|
9866
9933
|
return;
|
|
9867
9934
|
}
|
|
9868
|
-
const pid = Number.parseInt(
|
|
9935
|
+
const pid = Number.parseInt(readFileSync30(voicePaths.pid, "utf-8").trim(), 10);
|
|
9869
9936
|
try {
|
|
9870
9937
|
process.kill(pid, "SIGTERM");
|
|
9871
9938
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -9873,12 +9940,12 @@ function stop() {
|
|
|
9873
9940
|
console.log(`Voice daemon (PID ${pid}) is not running`);
|
|
9874
9941
|
}
|
|
9875
9942
|
try {
|
|
9876
|
-
|
|
9943
|
+
unlinkSync10(voicePaths.pid);
|
|
9877
9944
|
} catch {
|
|
9878
9945
|
}
|
|
9879
9946
|
try {
|
|
9880
9947
|
const lockFile = getLockFile();
|
|
9881
|
-
if (
|
|
9948
|
+
if (existsSync39(lockFile)) unlinkSync10(lockFile);
|
|
9882
9949
|
} catch {
|
|
9883
9950
|
}
|
|
9884
9951
|
console.log("Voice daemon stopped");
|
|
@@ -10099,15 +10166,15 @@ async function auth() {
|
|
|
10099
10166
|
}
|
|
10100
10167
|
|
|
10101
10168
|
// src/commands/roam/showClaudeCodeIcon.ts
|
|
10102
|
-
import { readFileSync as
|
|
10103
|
-
import { join as
|
|
10169
|
+
import { readFileSync as readFileSync31 } from "fs";
|
|
10170
|
+
import { join as join37 } from "path";
|
|
10104
10171
|
async function showClaudeCodeIcon() {
|
|
10105
10172
|
const appData = process.env.APPDATA;
|
|
10106
10173
|
if (!appData) return;
|
|
10107
|
-
const portFile =
|
|
10174
|
+
const portFile = join37(appData, "Roam", "roam-local-api.port");
|
|
10108
10175
|
let port;
|
|
10109
10176
|
try {
|
|
10110
|
-
port =
|
|
10177
|
+
port = readFileSync31(portFile, "utf-8").trim();
|
|
10111
10178
|
} catch {
|
|
10112
10179
|
return;
|
|
10113
10180
|
}
|
|
@@ -10178,8 +10245,8 @@ Done in ${elapsed}`);
|
|
|
10178
10245
|
}
|
|
10179
10246
|
|
|
10180
10247
|
// src/commands/run/add.ts
|
|
10181
|
-
import { mkdirSync as mkdirSync12, writeFileSync as
|
|
10182
|
-
import { join as
|
|
10248
|
+
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync27 } from "fs";
|
|
10249
|
+
import { join as join38 } from "path";
|
|
10183
10250
|
function findAddIndex() {
|
|
10184
10251
|
const addIndex = process.argv.indexOf("add");
|
|
10185
10252
|
if (addIndex === -1 || addIndex + 2 >= process.argv.length) return -1;
|
|
@@ -10225,7 +10292,7 @@ function saveNewRunConfig(name, command, args) {
|
|
|
10225
10292
|
saveConfig(config);
|
|
10226
10293
|
}
|
|
10227
10294
|
function createCommandFile(name) {
|
|
10228
|
-
const dir =
|
|
10295
|
+
const dir = join38(".claude", "commands");
|
|
10229
10296
|
mkdirSync12(dir, { recursive: true });
|
|
10230
10297
|
const content = `---
|
|
10231
10298
|
description: Run ${name}
|
|
@@ -10233,8 +10300,8 @@ description: Run ${name}
|
|
|
10233
10300
|
|
|
10234
10301
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
10235
10302
|
`;
|
|
10236
|
-
const filePath =
|
|
10237
|
-
|
|
10303
|
+
const filePath = join38(dir, `${name}.md`);
|
|
10304
|
+
writeFileSync27(filePath, content);
|
|
10238
10305
|
console.log(`Created command file: ${filePath}`);
|
|
10239
10306
|
}
|
|
10240
10307
|
function add3() {
|
|
@@ -10304,9 +10371,9 @@ function run3(name, args) {
|
|
|
10304
10371
|
|
|
10305
10372
|
// src/commands/screenshot/index.ts
|
|
10306
10373
|
import { execSync as execSync40 } from "child_process";
|
|
10307
|
-
import { existsSync as
|
|
10374
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync13, unlinkSync as unlinkSync11, writeFileSync as writeFileSync28 } from "fs";
|
|
10308
10375
|
import { tmpdir as tmpdir6 } from "os";
|
|
10309
|
-
import { join as
|
|
10376
|
+
import { join as join39, resolve as resolve5 } from "path";
|
|
10310
10377
|
import chalk109 from "chalk";
|
|
10311
10378
|
|
|
10312
10379
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -10436,22 +10503,22 @@ Write-Output $OutputPath
|
|
|
10436
10503
|
|
|
10437
10504
|
// src/commands/screenshot/index.ts
|
|
10438
10505
|
function buildOutputPath(outputDir, processName) {
|
|
10439
|
-
if (!
|
|
10506
|
+
if (!existsSync40(outputDir)) {
|
|
10440
10507
|
mkdirSync13(outputDir, { recursive: true });
|
|
10441
10508
|
}
|
|
10442
10509
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
10443
10510
|
return resolve5(outputDir, `${processName}-${timestamp}.png`);
|
|
10444
10511
|
}
|
|
10445
10512
|
function runPowerShellScript(processName, outputPath) {
|
|
10446
|
-
const scriptPath =
|
|
10447
|
-
|
|
10513
|
+
const scriptPath = join39(tmpdir6(), `assist-screenshot-${Date.now()}.ps1`);
|
|
10514
|
+
writeFileSync28(scriptPath, captureWindowPs1, "utf-8");
|
|
10448
10515
|
try {
|
|
10449
10516
|
execSync40(
|
|
10450
10517
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
10451
10518
|
{ stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8" }
|
|
10452
10519
|
);
|
|
10453
10520
|
} finally {
|
|
10454
|
-
|
|
10521
|
+
unlinkSync11(scriptPath);
|
|
10455
10522
|
}
|
|
10456
10523
|
}
|
|
10457
10524
|
function screenshot(processName) {
|