@staff0rd/assist 0.155.1 → 0.156.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 +4 -0
- package/claude/commands/next.md +12 -0
- package/claude/settings.json +3 -0
- package/dist/index.js +596 -552
- 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.156.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -241,7 +241,7 @@ async function done(id, summary) {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
// src/commands/backlog/next.ts
|
|
244
|
-
import
|
|
244
|
+
import chalk9 from "chalk";
|
|
245
245
|
import enquirer2 from "enquirer";
|
|
246
246
|
|
|
247
247
|
// src/commands/backlog/list/shared.ts
|
|
@@ -284,7 +284,7 @@ function printVerboseDetails(item) {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
// src/commands/backlog/run.ts
|
|
287
|
-
import
|
|
287
|
+
import chalk8 from "chalk";
|
|
288
288
|
|
|
289
289
|
// src/commands/backlog/buildAuthoredPhasePrompt.ts
|
|
290
290
|
function buildAuthoredPhasePrompt(item, phaseIndex, phase) {
|
|
@@ -391,11 +391,11 @@ function buildReviewPhase() {
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
// src/commands/backlog/executePhase.ts
|
|
394
|
-
import
|
|
394
|
+
import chalk6 from "chalk";
|
|
395
395
|
|
|
396
396
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
397
397
|
import { existsSync as existsSync2, unlinkSync } from "fs";
|
|
398
|
-
import
|
|
398
|
+
import chalk5 from "chalk";
|
|
399
399
|
|
|
400
400
|
// src/commands/backlog/handleIncompletePhase.ts
|
|
401
401
|
import enquirer from "enquirer";
|
|
@@ -411,53 +411,34 @@ async function handleIncompletePhase() {
|
|
|
411
411
|
return "abort";
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
// src/commands/backlog/
|
|
414
|
+
// src/commands/backlog/writeSignal.ts
|
|
415
415
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
416
416
|
import { join as join2 } from "path";
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return join2(process.cwd(), PHASE_STATUS_FILE);
|
|
417
|
+
var SIGNAL_FILE = ".assist-signal.json";
|
|
418
|
+
function getSignalPath() {
|
|
419
|
+
return join2(process.cwd(), SIGNAL_FILE);
|
|
421
420
|
}
|
|
422
|
-
function
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
writeFileSync2(
|
|
426
|
-
statusPath,
|
|
427
|
-
JSON.stringify({
|
|
428
|
-
itemId: Number.parseInt(id, 10),
|
|
429
|
-
phaseIndex,
|
|
430
|
-
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
431
|
-
})
|
|
432
|
-
);
|
|
433
|
-
const result = loadAndFindItem(id);
|
|
434
|
-
if (result?.item.status === "done") {
|
|
435
|
-
console.log(chalk5.dim(`Item #${id} already done, skipping phase advance.`));
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
if (result) {
|
|
439
|
-
addPhaseSummary(result.item, summary, phaseIndex);
|
|
440
|
-
saveBacklog(result.items);
|
|
441
|
-
}
|
|
442
|
-
setCurrentPhase(id, phaseIndex + 1);
|
|
443
|
-
console.log(chalk5.green(`Phase ${phase} of item #${id} marked as complete.`));
|
|
421
|
+
function writeSignal(event, data) {
|
|
422
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
423
|
+
const signal = { event, ...sessionId && { sessionId }, ...data };
|
|
424
|
+
writeFileSync2(getSignalPath(), JSON.stringify(signal));
|
|
444
425
|
}
|
|
445
426
|
|
|
446
427
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
447
|
-
function
|
|
448
|
-
const statusPath =
|
|
428
|
+
function cleanupSignal() {
|
|
429
|
+
const statusPath = getSignalPath();
|
|
449
430
|
if (existsSync2(statusPath)) {
|
|
450
431
|
unlinkSync(statusPath);
|
|
451
432
|
}
|
|
452
433
|
}
|
|
453
434
|
async function resolvePhaseResult(phaseIndex) {
|
|
454
|
-
if (!existsSync2(
|
|
435
|
+
if (!existsSync2(getSignalPath())) {
|
|
455
436
|
const action = await handleIncompletePhase();
|
|
456
437
|
if (action === "abort") return -1;
|
|
457
438
|
return action === "skip" ? 1 : 0;
|
|
458
439
|
}
|
|
459
|
-
|
|
460
|
-
console.log(
|
|
440
|
+
cleanupSignal();
|
|
441
|
+
console.log(chalk5.green(`
|
|
461
442
|
Phase ${phaseIndex + 1} completed.`));
|
|
462
443
|
return 1;
|
|
463
444
|
}
|
|
@@ -480,30 +461,48 @@ function spawnClaude(prompt, options2 = {}) {
|
|
|
480
461
|
}
|
|
481
462
|
|
|
482
463
|
// src/commands/backlog/watchForMarker.ts
|
|
483
|
-
import { existsSync as
|
|
464
|
+
import { existsSync as existsSync4, unwatchFile, watchFile } from "fs";
|
|
465
|
+
|
|
466
|
+
// src/commands/backlog/readSignal.ts
|
|
467
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
468
|
+
function readSignal() {
|
|
469
|
+
const path50 = getSignalPath();
|
|
470
|
+
if (!existsSync3(path50)) return void 0;
|
|
471
|
+
try {
|
|
472
|
+
return JSON.parse(readFileSync2(path50, "utf-8"));
|
|
473
|
+
} catch {
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// src/commands/backlog/watchForMarker.ts
|
|
484
479
|
function watchForMarker(child) {
|
|
485
|
-
const statusPath =
|
|
480
|
+
const statusPath = getSignalPath();
|
|
481
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
486
482
|
watchFile(statusPath, { interval: 1e3 }, () => {
|
|
487
|
-
if (
|
|
483
|
+
if (!existsSync4(statusPath)) return;
|
|
484
|
+
const signal = readSignal();
|
|
485
|
+
if (signal && (!signal.sessionId || signal.sessionId === sessionId)) {
|
|
488
486
|
unwatchFile(statusPath);
|
|
489
487
|
child.kill("SIGTERM");
|
|
490
488
|
}
|
|
491
489
|
});
|
|
492
490
|
}
|
|
493
491
|
function stopWatching() {
|
|
494
|
-
unwatchFile(
|
|
492
|
+
unwatchFile(getSignalPath());
|
|
495
493
|
}
|
|
496
494
|
|
|
497
495
|
// src/commands/backlog/executePhase.ts
|
|
498
496
|
async function executePhase(item, phaseIndex, phases, spawnOptions) {
|
|
499
497
|
const phase = phases[phaseIndex];
|
|
500
498
|
console.log(
|
|
501
|
-
|
|
499
|
+
chalk6.bold(
|
|
502
500
|
`
|
|
503
501
|
--- Phase ${phaseIndex + 1}/${phases.length}: ${phase.name} ---
|
|
504
502
|
`
|
|
505
503
|
)
|
|
506
504
|
);
|
|
505
|
+
process.env.ASSIST_SESSION_ID = String(process.pid);
|
|
507
506
|
const { child, done: done2 } = spawnClaude(
|
|
508
507
|
buildPhasePrompt(item, phaseIndex, phase),
|
|
509
508
|
spawnOptions
|
|
@@ -516,7 +515,7 @@ async function executePhase(item, phaseIndex, phases, spawnOptions) {
|
|
|
516
515
|
}
|
|
517
516
|
|
|
518
517
|
// src/commands/backlog/prepareRun.ts
|
|
519
|
-
import
|
|
518
|
+
import chalk7 from "chalk";
|
|
520
519
|
|
|
521
520
|
// src/commands/backlog/resolvePlan.ts
|
|
522
521
|
function resolvePlan(item) {
|
|
@@ -539,13 +538,13 @@ function prepareRun(id) {
|
|
|
539
538
|
const plan2 = resolvePlan(item);
|
|
540
539
|
const startPhase = item.currentPhase ?? 0;
|
|
541
540
|
if (item.status === "done") {
|
|
542
|
-
console.log(
|
|
541
|
+
console.log(chalk7.green(`Already done: #${id}: ${item.name}`));
|
|
543
542
|
return void 0;
|
|
544
543
|
}
|
|
545
544
|
if (startPhase > plan2.length) {
|
|
546
545
|
setStatus(id, "done");
|
|
547
546
|
console.log(
|
|
548
|
-
|
|
547
|
+
chalk7.green(`All phases already complete for #${id}: ${item.name}`)
|
|
549
548
|
);
|
|
550
549
|
return void 0;
|
|
551
550
|
}
|
|
@@ -562,16 +561,16 @@ async function run(id, spawnOptions) {
|
|
|
562
561
|
if (!await runPhases(item, startPhase, plan2, spawnOptions)) return;
|
|
563
562
|
if (!await runReview(item, plan2, spawnOptions)) return;
|
|
564
563
|
ensureDone(id);
|
|
565
|
-
console.log(
|
|
564
|
+
console.log(chalk8.green(`
|
|
566
565
|
All phases complete for #${id}: ${item.name}`));
|
|
567
566
|
}
|
|
568
567
|
function logProgress(id, name, startPhase, total) {
|
|
569
|
-
console.log(
|
|
568
|
+
console.log(chalk8.bold(`Running plan for #${id}: ${name}`));
|
|
570
569
|
if (startPhase > 0) {
|
|
571
|
-
console.log(
|
|
570
|
+
console.log(chalk8.dim(`Resuming from phase ${startPhase + 1}/${total}
|
|
572
571
|
`));
|
|
573
572
|
} else {
|
|
574
|
-
console.log(
|
|
573
|
+
console.log(chalk8.dim(`${total} phase(s)
|
|
575
574
|
`));
|
|
576
575
|
}
|
|
577
576
|
}
|
|
@@ -607,7 +606,7 @@ async function next(options2) {
|
|
|
607
606
|
const inProgress = items.find((i) => i.status === "in-progress" && i.plan);
|
|
608
607
|
if (inProgress) {
|
|
609
608
|
console.log(
|
|
610
|
-
|
|
609
|
+
chalk9.bold(
|
|
611
610
|
`Resuming in-progress item #${inProgress.id}: ${inProgress.name}`
|
|
612
611
|
)
|
|
613
612
|
);
|
|
@@ -616,13 +615,13 @@ async function next(options2) {
|
|
|
616
615
|
}
|
|
617
616
|
const todo = items.filter((i) => i.status === "todo");
|
|
618
617
|
if (todo.length === 0) {
|
|
619
|
-
console.log(
|
|
618
|
+
console.log(chalk9.dim("No incomplete backlog items. Opening /draft..."));
|
|
620
619
|
await spawnClaude("/draft", options2);
|
|
621
620
|
return;
|
|
622
621
|
}
|
|
623
622
|
if (todo.length === 1) {
|
|
624
623
|
const only = todo[0];
|
|
625
|
-
console.log(
|
|
624
|
+
console.log(chalk9.bold(`Starting #${only.id}: ${only.name}`));
|
|
626
625
|
await run(String(only.id), options2);
|
|
627
626
|
return;
|
|
628
627
|
}
|
|
@@ -640,6 +639,28 @@ async function next(options2) {
|
|
|
640
639
|
await run(id, options2);
|
|
641
640
|
}
|
|
642
641
|
|
|
642
|
+
// src/commands/backlog/phaseDone.ts
|
|
643
|
+
import chalk10 from "chalk";
|
|
644
|
+
function phaseDone(id, phase, summary) {
|
|
645
|
+
const phaseIndex = Number.parseInt(phase, 10);
|
|
646
|
+
writeSignal("phase-done", {
|
|
647
|
+
itemId: Number.parseInt(id, 10),
|
|
648
|
+
phaseIndex,
|
|
649
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
650
|
+
});
|
|
651
|
+
const result = loadAndFindItem(id);
|
|
652
|
+
if (result?.item.status === "done") {
|
|
653
|
+
console.log(chalk10.dim(`Item #${id} already done, skipping phase advance.`));
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
if (result) {
|
|
657
|
+
addPhaseSummary(result.item, summary, phaseIndex);
|
|
658
|
+
saveBacklog(result.items);
|
|
659
|
+
}
|
|
660
|
+
setCurrentPhase(id, phaseIndex + 1);
|
|
661
|
+
console.log(chalk10.green(`Phase ${phase} of item #${id} marked as complete.`));
|
|
662
|
+
}
|
|
663
|
+
|
|
643
664
|
// src/commands/backlog/plan.ts
|
|
644
665
|
import chalk11 from "chalk";
|
|
645
666
|
function plan(id) {
|
|
@@ -760,7 +781,7 @@ async function start(id) {
|
|
|
760
781
|
|
|
761
782
|
// src/shared/web.ts
|
|
762
783
|
import { exec } from "child_process";
|
|
763
|
-
import { readFileSync as
|
|
784
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
764
785
|
import {
|
|
765
786
|
createServer
|
|
766
787
|
} from "http";
|
|
@@ -776,7 +797,7 @@ function createBundleHandler(importMetaUrl, bundlePath) {
|
|
|
776
797
|
let cache;
|
|
777
798
|
return (_req, res) => {
|
|
778
799
|
if (!cache) {
|
|
779
|
-
cache =
|
|
800
|
+
cache = readFileSync3(join3(dir, bundlePath), "utf-8");
|
|
780
801
|
}
|
|
781
802
|
res.writeHead(200, { "Content-Type": "application/javascript" });
|
|
782
803
|
res.end(cache);
|
|
@@ -958,23 +979,39 @@ async function web(options2) {
|
|
|
958
979
|
);
|
|
959
980
|
}
|
|
960
981
|
|
|
982
|
+
// src/commands/backlog/launchMode.ts
|
|
983
|
+
import chalk16 from "chalk";
|
|
984
|
+
async function launchMode(slashCommand) {
|
|
985
|
+
process.env.ASSIST_SESSION_ID = String(process.pid);
|
|
986
|
+
const { child, done: done2 } = spawnClaude(`/${slashCommand}`);
|
|
987
|
+
watchForMarker(child);
|
|
988
|
+
await done2;
|
|
989
|
+
stopWatching();
|
|
990
|
+
const signal = readSignal();
|
|
991
|
+
cleanupSignal();
|
|
992
|
+
if (signal?.event === "next") {
|
|
993
|
+
console.log(chalk16.bold("\nChaining into assist next...\n"));
|
|
994
|
+
await next({ allowEdits: true });
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
961
998
|
// src/commands/commit.ts
|
|
962
999
|
import { execSync } from "child_process";
|
|
963
1000
|
|
|
964
1001
|
// src/shared/loadConfig.ts
|
|
965
|
-
import { existsSync as
|
|
1002
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
966
1003
|
import { homedir } from "os";
|
|
967
1004
|
import { basename, dirname as dirname2, join as join4 } from "path";
|
|
968
|
-
import
|
|
1005
|
+
import chalk17 from "chalk";
|
|
969
1006
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
970
1007
|
|
|
971
1008
|
// src/shared/loadRawYaml.ts
|
|
972
|
-
import { existsSync as
|
|
1009
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
973
1010
|
import { parse as parseYaml2 } from "yaml";
|
|
974
1011
|
function loadRawYaml(path50) {
|
|
975
|
-
if (!
|
|
1012
|
+
if (!existsSync5(path50)) return {};
|
|
976
1013
|
try {
|
|
977
|
-
const content =
|
|
1014
|
+
const content = readFileSync4(path50, "utf-8");
|
|
978
1015
|
return parseYaml2(content) || {};
|
|
979
1016
|
} catch {
|
|
980
1017
|
return {};
|
|
@@ -1096,9 +1133,9 @@ function findConfigUp(startDir) {
|
|
|
1096
1133
|
let current = startDir;
|
|
1097
1134
|
while (current !== dirname2(current)) {
|
|
1098
1135
|
const claudePath = join4(current, ".claude", "assist.yml");
|
|
1099
|
-
if (
|
|
1136
|
+
if (existsSync6(claudePath)) return claudePath;
|
|
1100
1137
|
const rootPath = join4(current, "assist.yml");
|
|
1101
|
-
if (
|
|
1138
|
+
if (existsSync6(rootPath)) return rootPath;
|
|
1102
1139
|
current = dirname2(current);
|
|
1103
1140
|
}
|
|
1104
1141
|
return null;
|
|
@@ -1136,9 +1173,9 @@ function getRepoName() {
|
|
|
1136
1173
|
return config.devlog.name;
|
|
1137
1174
|
}
|
|
1138
1175
|
const packageJsonPath = join4(process.cwd(), "package.json");
|
|
1139
|
-
if (
|
|
1176
|
+
if (existsSync6(packageJsonPath)) {
|
|
1140
1177
|
try {
|
|
1141
|
-
const content =
|
|
1178
|
+
const content = readFileSync5(packageJsonPath, "utf-8");
|
|
1142
1179
|
const pkg = JSON.parse(content);
|
|
1143
1180
|
if (pkg.name) {
|
|
1144
1181
|
return pkg.name;
|
|
@@ -1152,7 +1189,7 @@ function getTranscriptConfig() {
|
|
|
1152
1189
|
const config = loadConfig();
|
|
1153
1190
|
if (!config.transcript) {
|
|
1154
1191
|
console.error(
|
|
1155
|
-
|
|
1192
|
+
chalk17.red(
|
|
1156
1193
|
"Transcript directories not configured. Run 'assist transcript configure' first."
|
|
1157
1194
|
)
|
|
1158
1195
|
);
|
|
@@ -1241,7 +1278,7 @@ function commit(args) {
|
|
|
1241
1278
|
}
|
|
1242
1279
|
|
|
1243
1280
|
// src/commands/config/index.ts
|
|
1244
|
-
import
|
|
1281
|
+
import chalk18 from "chalk";
|
|
1245
1282
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
1246
1283
|
|
|
1247
1284
|
// src/commands/config/getNestedValue.ts
|
|
@@ -1317,7 +1354,7 @@ function formatIssuePath(issue, key) {
|
|
|
1317
1354
|
function printValidationErrors(issues, key) {
|
|
1318
1355
|
for (const issue of issues) {
|
|
1319
1356
|
console.error(
|
|
1320
|
-
|
|
1357
|
+
chalk18.red(`${formatIssuePath(issue, key)}: ${issue.message}`)
|
|
1321
1358
|
);
|
|
1322
1359
|
}
|
|
1323
1360
|
}
|
|
@@ -1337,13 +1374,13 @@ function applyConfigSet(key, coerced) {
|
|
|
1337
1374
|
function configSet(key, value) {
|
|
1338
1375
|
const coerced = coerceValue(value);
|
|
1339
1376
|
applyConfigSet(key, coerced);
|
|
1340
|
-
console.log(
|
|
1377
|
+
console.log(chalk18.green(`Set ${key} = ${JSON.stringify(coerced)}`));
|
|
1341
1378
|
}
|
|
1342
1379
|
function formatOutput(value) {
|
|
1343
1380
|
return typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);
|
|
1344
1381
|
}
|
|
1345
1382
|
function exitKeyNotSet(key) {
|
|
1346
|
-
console.error(
|
|
1383
|
+
console.error(chalk18.red(`Key "${key}" is not set`));
|
|
1347
1384
|
process.exit(1);
|
|
1348
1385
|
}
|
|
1349
1386
|
function requireNestedValue(config, key) {
|
|
@@ -1379,10 +1416,10 @@ function coverage() {
|
|
|
1379
1416
|
}
|
|
1380
1417
|
|
|
1381
1418
|
// src/commands/verify/init/index.ts
|
|
1382
|
-
import
|
|
1419
|
+
import chalk33 from "chalk";
|
|
1383
1420
|
|
|
1384
1421
|
// src/shared/promptMultiselect.ts
|
|
1385
|
-
import
|
|
1422
|
+
import chalk19 from "chalk";
|
|
1386
1423
|
import enquirer3 from "enquirer";
|
|
1387
1424
|
async function promptMultiselect(message, options2) {
|
|
1388
1425
|
const { selected } = await enquirer3.prompt({
|
|
@@ -1391,7 +1428,7 @@ async function promptMultiselect(message, options2) {
|
|
|
1391
1428
|
message,
|
|
1392
1429
|
choices: options2.map((opt) => ({
|
|
1393
1430
|
name: opt.value,
|
|
1394
|
-
message: `${opt.name} - ${
|
|
1431
|
+
message: `${opt.name} - ${chalk19.dim(opt.description)}`
|
|
1395
1432
|
})),
|
|
1396
1433
|
// @ts-expect-error - enquirer types don't include symbols but it's supported
|
|
1397
1434
|
symbols: {
|
|
@@ -1407,7 +1444,7 @@ async function promptMultiselect(message, options2) {
|
|
|
1407
1444
|
// src/shared/readPackageJson.ts
|
|
1408
1445
|
import * as fs from "fs";
|
|
1409
1446
|
import * as path from "path";
|
|
1410
|
-
import
|
|
1447
|
+
import chalk20 from "chalk";
|
|
1411
1448
|
function findPackageJson() {
|
|
1412
1449
|
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
1413
1450
|
if (fs.existsSync(packageJsonPath)) {
|
|
@@ -1421,7 +1458,7 @@ function readPackageJson(filePath) {
|
|
|
1421
1458
|
function requirePackageJson() {
|
|
1422
1459
|
const packageJsonPath = findPackageJson();
|
|
1423
1460
|
if (!packageJsonPath) {
|
|
1424
|
-
console.error(
|
|
1461
|
+
console.error(chalk20.red("No package.json found in current directory"));
|
|
1425
1462
|
process.exit(1);
|
|
1426
1463
|
}
|
|
1427
1464
|
const pkg = readPackageJson(packageJsonPath);
|
|
@@ -1452,7 +1489,7 @@ function findPackageJsonWithVerifyScripts(startDir) {
|
|
|
1452
1489
|
// src/commands/verify/installPackage.ts
|
|
1453
1490
|
import { execSync as execSync3 } from "child_process";
|
|
1454
1491
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
1455
|
-
import
|
|
1492
|
+
import chalk21 from "chalk";
|
|
1456
1493
|
function writePackageJson(filePath, pkg) {
|
|
1457
1494
|
writeFileSync4(filePath, `${JSON.stringify(pkg, null, 2)}
|
|
1458
1495
|
`);
|
|
@@ -1467,12 +1504,12 @@ function addScript(pkg, name, command) {
|
|
|
1467
1504
|
};
|
|
1468
1505
|
}
|
|
1469
1506
|
function installPackage(name, cwd) {
|
|
1470
|
-
console.log(
|
|
1507
|
+
console.log(chalk21.dim(`Installing ${name}...`));
|
|
1471
1508
|
try {
|
|
1472
1509
|
execSync3(`npm install -D ${name}`, { stdio: "inherit", cwd });
|
|
1473
1510
|
return true;
|
|
1474
1511
|
} catch {
|
|
1475
|
-
console.error(
|
|
1512
|
+
console.error(chalk21.red(`Failed to install ${name}`));
|
|
1476
1513
|
return false;
|
|
1477
1514
|
}
|
|
1478
1515
|
}
|
|
@@ -1519,9 +1556,9 @@ var expectedScripts = {
|
|
|
1519
1556
|
};
|
|
1520
1557
|
|
|
1521
1558
|
// src/commands/verify/setup/setupBuild.ts
|
|
1522
|
-
import
|
|
1559
|
+
import chalk22 from "chalk";
|
|
1523
1560
|
async function setupBuild(_packageJsonPath, writer, hasVite, hasTypescript) {
|
|
1524
|
-
console.log(
|
|
1561
|
+
console.log(chalk22.blue("\nSetting up build verification..."));
|
|
1525
1562
|
let command;
|
|
1526
1563
|
if (hasVite && hasTypescript) {
|
|
1527
1564
|
command = "tsc -b && vite build --logLevel error";
|
|
@@ -1530,21 +1567,21 @@ async function setupBuild(_packageJsonPath, writer, hasVite, hasTypescript) {
|
|
|
1530
1567
|
} else {
|
|
1531
1568
|
command = "npm run build";
|
|
1532
1569
|
}
|
|
1533
|
-
console.log(
|
|
1570
|
+
console.log(chalk22.dim(`Using: ${command}`));
|
|
1534
1571
|
writer("verify:build", command);
|
|
1535
1572
|
}
|
|
1536
1573
|
async function setupTypecheck(_packageJsonPath, writer) {
|
|
1537
|
-
console.log(
|
|
1574
|
+
console.log(chalk22.blue("\nSetting up typecheck verification..."));
|
|
1538
1575
|
const command = "tsc --noEmit";
|
|
1539
|
-
console.log(
|
|
1576
|
+
console.log(chalk22.dim(`Using: ${command}`));
|
|
1540
1577
|
writer("verify:typecheck", command);
|
|
1541
1578
|
}
|
|
1542
1579
|
|
|
1543
1580
|
// src/commands/verify/setup/setupDuplicateCode.ts
|
|
1544
1581
|
import * as path2 from "path";
|
|
1545
|
-
import
|
|
1582
|
+
import chalk23 from "chalk";
|
|
1546
1583
|
async function setupDuplicateCode(packageJsonPath, writer) {
|
|
1547
|
-
console.log(
|
|
1584
|
+
console.log(chalk23.blue("\nSetting up jscpd..."));
|
|
1548
1585
|
const cwd = path2.dirname(packageJsonPath);
|
|
1549
1586
|
const pkg = readPackageJson(packageJsonPath);
|
|
1550
1587
|
const hasJscpd = !!pkg.dependencies?.jscpd || !!pkg.devDependencies?.jscpd;
|
|
@@ -1556,15 +1593,15 @@ async function setupDuplicateCode(packageJsonPath, writer) {
|
|
|
1556
1593
|
|
|
1557
1594
|
// src/commands/verify/setup/setupHardcodedColors.ts
|
|
1558
1595
|
import * as path3 from "path";
|
|
1559
|
-
import
|
|
1596
|
+
import chalk25 from "chalk";
|
|
1560
1597
|
|
|
1561
1598
|
// src/commands/verify/addToKnipIgnoreBinaries.ts
|
|
1562
|
-
import { existsSync as
|
|
1599
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
|
|
1563
1600
|
import { join as join6 } from "path";
|
|
1564
|
-
import
|
|
1601
|
+
import chalk24 from "chalk";
|
|
1565
1602
|
function loadKnipConfig(knipJsonPath) {
|
|
1566
|
-
if (
|
|
1567
|
-
return JSON.parse(
|
|
1603
|
+
if (existsSync8(knipJsonPath)) {
|
|
1604
|
+
return JSON.parse(readFileSync7(knipJsonPath, "utf-8"));
|
|
1568
1605
|
}
|
|
1569
1606
|
return { $schema: "https://unpkg.com/knip@5/schema.json" };
|
|
1570
1607
|
}
|
|
@@ -1580,16 +1617,16 @@ function addToKnipIgnoreBinaries(cwd, binary) {
|
|
|
1580
1617
|
`${JSON.stringify(knipConfig, null, " ")}
|
|
1581
1618
|
`
|
|
1582
1619
|
);
|
|
1583
|
-
console.log(
|
|
1620
|
+
console.log(chalk24.dim(`Added '${binary}' to knip.json ignoreBinaries`));
|
|
1584
1621
|
}
|
|
1585
1622
|
} catch {
|
|
1586
|
-
console.log(
|
|
1623
|
+
console.log(chalk24.yellow("Warning: Could not update knip.json"));
|
|
1587
1624
|
}
|
|
1588
1625
|
}
|
|
1589
1626
|
|
|
1590
1627
|
// src/commands/verify/setup/setupHardcodedColors.ts
|
|
1591
1628
|
async function setupHardcodedColors(packageJsonPath, writer, hasOpenColor) {
|
|
1592
|
-
console.log(
|
|
1629
|
+
console.log(chalk25.blue("\nSetting up hardcoded colors check..."));
|
|
1593
1630
|
const cwd = path3.dirname(packageJsonPath);
|
|
1594
1631
|
if (!hasOpenColor) {
|
|
1595
1632
|
installPackage("open-color", cwd);
|
|
@@ -1600,9 +1637,9 @@ async function setupHardcodedColors(packageJsonPath, writer, hasOpenColor) {
|
|
|
1600
1637
|
|
|
1601
1638
|
// src/commands/verify/setup/setupKnip.ts
|
|
1602
1639
|
import * as path4 from "path";
|
|
1603
|
-
import
|
|
1640
|
+
import chalk26 from "chalk";
|
|
1604
1641
|
async function setupKnip(packageJsonPath, writer) {
|
|
1605
|
-
console.log(
|
|
1642
|
+
console.log(chalk26.blue("\nSetting up knip..."));
|
|
1606
1643
|
const cwd = path4.dirname(packageJsonPath);
|
|
1607
1644
|
const pkg = readPackageJson(packageJsonPath);
|
|
1608
1645
|
if (!pkg.devDependencies?.knip && !installPackage("knip", cwd)) {
|
|
@@ -1613,14 +1650,14 @@ async function setupKnip(packageJsonPath, writer) {
|
|
|
1613
1650
|
|
|
1614
1651
|
// src/commands/verify/setup/setupLint.ts
|
|
1615
1652
|
import * as path5 from "path";
|
|
1616
|
-
import
|
|
1653
|
+
import chalk29 from "chalk";
|
|
1617
1654
|
|
|
1618
1655
|
// src/commands/lint/init.ts
|
|
1619
1656
|
import { execSync as execSync5 } from "child_process";
|
|
1620
|
-
import { existsSync as
|
|
1657
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "fs";
|
|
1621
1658
|
import { dirname as dirname7, join as join7 } from "path";
|
|
1622
1659
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1623
|
-
import
|
|
1660
|
+
import chalk28 from "chalk";
|
|
1624
1661
|
|
|
1625
1662
|
// src/shared/promptConfirm.ts
|
|
1626
1663
|
import enquirer4 from "enquirer";
|
|
@@ -1641,10 +1678,10 @@ async function promptConfirm(message, initial = true) {
|
|
|
1641
1678
|
|
|
1642
1679
|
// src/shared/removeEslint/index.ts
|
|
1643
1680
|
import { execSync as execSync4 } from "child_process";
|
|
1644
|
-
import { existsSync as
|
|
1681
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
1645
1682
|
|
|
1646
1683
|
// src/shared/removeEslint/removeEslintConfigFiles.ts
|
|
1647
|
-
import { existsSync as
|
|
1684
|
+
import { existsSync as existsSync9, unlinkSync as unlinkSync2 } from "fs";
|
|
1648
1685
|
var ESLINT_CONFIG_FILES = [
|
|
1649
1686
|
"eslint.config.js",
|
|
1650
1687
|
"eslint.config.mjs",
|
|
@@ -1660,7 +1697,7 @@ var ESLINT_CONFIG_FILES = [
|
|
|
1660
1697
|
function removeEslintConfigFiles() {
|
|
1661
1698
|
let removed = false;
|
|
1662
1699
|
for (const configFile of ESLINT_CONFIG_FILES) {
|
|
1663
|
-
if (
|
|
1700
|
+
if (existsSync9(configFile)) {
|
|
1664
1701
|
unlinkSync2(configFile);
|
|
1665
1702
|
console.log(`Removed ${configFile}`);
|
|
1666
1703
|
removed = true;
|
|
@@ -1682,10 +1719,10 @@ function removeEslint(options2 = {}) {
|
|
|
1682
1719
|
}
|
|
1683
1720
|
function removeEslintFromPackageJson(options2) {
|
|
1684
1721
|
const packageJsonPath = "package.json";
|
|
1685
|
-
if (!
|
|
1722
|
+
if (!existsSync10(packageJsonPath)) {
|
|
1686
1723
|
return false;
|
|
1687
1724
|
}
|
|
1688
|
-
const packageJson = JSON.parse(
|
|
1725
|
+
const packageJson = JSON.parse(readFileSync8(packageJsonPath, "utf-8"));
|
|
1689
1726
|
let modified = false;
|
|
1690
1727
|
modified = removeEslintDeps(packageJson.dependencies) || modified;
|
|
1691
1728
|
modified = removeEslintDeps(packageJson.devDependencies) || modified;
|
|
@@ -1722,7 +1759,7 @@ function removeEslintScripts(scripts, options2) {
|
|
|
1722
1759
|
}
|
|
1723
1760
|
|
|
1724
1761
|
// src/utils/printDiff.ts
|
|
1725
|
-
import
|
|
1762
|
+
import chalk27 from "chalk";
|
|
1726
1763
|
import * as diff from "diff";
|
|
1727
1764
|
function normalizeJson(content) {
|
|
1728
1765
|
try {
|
|
@@ -1740,11 +1777,11 @@ function printDiff(oldContent, newContent) {
|
|
|
1740
1777
|
const lines = change.value.replace(/\n$/, "").split("\n");
|
|
1741
1778
|
for (const line of lines) {
|
|
1742
1779
|
if (change.added) {
|
|
1743
|
-
console.log(
|
|
1780
|
+
console.log(chalk27.green(`+ ${line}`));
|
|
1744
1781
|
} else if (change.removed) {
|
|
1745
|
-
console.log(
|
|
1782
|
+
console.log(chalk27.red(`- ${line}`));
|
|
1746
1783
|
} else {
|
|
1747
|
-
console.log(
|
|
1784
|
+
console.log(chalk27.dim(` ${line}`));
|
|
1748
1785
|
}
|
|
1749
1786
|
}
|
|
1750
1787
|
}
|
|
@@ -1755,17 +1792,17 @@ var __dirname2 = dirname7(fileURLToPath2(import.meta.url));
|
|
|
1755
1792
|
async function init() {
|
|
1756
1793
|
removeEslint();
|
|
1757
1794
|
const biomeConfigPath = "biome.json";
|
|
1758
|
-
if (!
|
|
1795
|
+
if (!existsSync11(biomeConfigPath)) {
|
|
1759
1796
|
console.log("Initializing Biome...");
|
|
1760
1797
|
execSync5("npx @biomejs/biome init", { stdio: "inherit" });
|
|
1761
1798
|
}
|
|
1762
|
-
if (!
|
|
1799
|
+
if (!existsSync11(biomeConfigPath)) {
|
|
1763
1800
|
console.log("No biome.json found, skipping linter config");
|
|
1764
1801
|
return;
|
|
1765
1802
|
}
|
|
1766
1803
|
const linterConfigPath = join7(__dirname2, "commands/lint/biome.linter.json");
|
|
1767
|
-
const linterConfig = JSON.parse(
|
|
1768
|
-
const biomeConfig = JSON.parse(
|
|
1804
|
+
const linterConfig = JSON.parse(readFileSync9(linterConfigPath, "utf-8"));
|
|
1805
|
+
const biomeConfig = JSON.parse(readFileSync9(biomeConfigPath, "utf-8"));
|
|
1769
1806
|
const oldContent = `${JSON.stringify(biomeConfig, null, 2)}
|
|
1770
1807
|
`;
|
|
1771
1808
|
biomeConfig.linter = linterConfig.linter;
|
|
@@ -1778,10 +1815,10 @@ async function init() {
|
|
|
1778
1815
|
console.log("biome.json already has the correct linter config");
|
|
1779
1816
|
return;
|
|
1780
1817
|
}
|
|
1781
|
-
console.log(
|
|
1818
|
+
console.log(chalk28.yellow("\n\u26A0\uFE0F biome.json will be updated:"));
|
|
1782
1819
|
console.log();
|
|
1783
1820
|
printDiff(oldContent, newContent);
|
|
1784
|
-
const confirm = await promptConfirm(
|
|
1821
|
+
const confirm = await promptConfirm(chalk28.red("Update biome.json?"));
|
|
1785
1822
|
if (!confirm) {
|
|
1786
1823
|
console.log("Skipped biome.json update");
|
|
1787
1824
|
return;
|
|
@@ -1792,7 +1829,7 @@ async function init() {
|
|
|
1792
1829
|
|
|
1793
1830
|
// src/commands/verify/setup/setupLint.ts
|
|
1794
1831
|
async function setupLint(packageJsonPath, writer) {
|
|
1795
|
-
console.log(
|
|
1832
|
+
console.log(chalk29.blue("\nSetting up biome..."));
|
|
1796
1833
|
const cwd = path5.dirname(packageJsonPath);
|
|
1797
1834
|
const pkg = readPackageJson(packageJsonPath);
|
|
1798
1835
|
if (!pkg.devDependencies?.["@biomejs/biome"]) {
|
|
@@ -1806,9 +1843,9 @@ async function setupLint(packageJsonPath, writer) {
|
|
|
1806
1843
|
|
|
1807
1844
|
// src/commands/verify/setup/setupMadge.ts
|
|
1808
1845
|
import * as path6 from "path";
|
|
1809
|
-
import
|
|
1846
|
+
import chalk30 from "chalk";
|
|
1810
1847
|
async function setupMadge(packageJsonPath, writer) {
|
|
1811
|
-
console.log(
|
|
1848
|
+
console.log(chalk30.blue("\nSetting up madge..."));
|
|
1812
1849
|
const cwd = path6.dirname(packageJsonPath);
|
|
1813
1850
|
const pkg = readPackageJson(packageJsonPath);
|
|
1814
1851
|
const hasMadge = !!pkg.dependencies?.madge || !!pkg.devDependencies?.madge;
|
|
@@ -1820,18 +1857,18 @@ async function setupMadge(packageJsonPath, writer) {
|
|
|
1820
1857
|
|
|
1821
1858
|
// src/commands/verify/setup/setupMaintainability.ts
|
|
1822
1859
|
import * as path7 from "path";
|
|
1823
|
-
import
|
|
1860
|
+
import chalk31 from "chalk";
|
|
1824
1861
|
async function setupMaintainability(packageJsonPath, writer) {
|
|
1825
|
-
console.log(
|
|
1862
|
+
console.log(chalk31.blue("\nSetting up maintainability check..."));
|
|
1826
1863
|
addToKnipIgnoreBinaries(path7.dirname(packageJsonPath), "assist");
|
|
1827
1864
|
writer("verify:maintainability", expectedScripts["verify:maintainability"]);
|
|
1828
1865
|
}
|
|
1829
1866
|
|
|
1830
1867
|
// src/commands/verify/setup/setupTest.ts
|
|
1831
1868
|
import * as path8 from "path";
|
|
1832
|
-
import
|
|
1869
|
+
import chalk32 from "chalk";
|
|
1833
1870
|
async function setupTest(packageJsonPath, writer) {
|
|
1834
|
-
console.log(
|
|
1871
|
+
console.log(chalk32.blue("\nSetting up vitest..."));
|
|
1835
1872
|
const cwd = path8.dirname(packageJsonPath);
|
|
1836
1873
|
const pkg = readPackageJson(packageJsonPath);
|
|
1837
1874
|
if (!pkg.devDependencies?.vitest && !installPackage("vitest", cwd)) {
|
|
@@ -2000,25 +2037,25 @@ async function runSelectedSetups(selected, packageJsonPath, writer, handlers) {
|
|
|
2000
2037
|
for (const choice of selected) {
|
|
2001
2038
|
await handlers[choice]?.(packageJsonPath, writer);
|
|
2002
2039
|
}
|
|
2003
|
-
console.log(
|
|
2040
|
+
console.log(chalk33.green(`
|
|
2004
2041
|
Added ${selected.length} verify script(s):`));
|
|
2005
2042
|
for (const choice of selected) {
|
|
2006
|
-
console.log(
|
|
2043
|
+
console.log(chalk33.green(` - verify:${choice}`));
|
|
2007
2044
|
}
|
|
2008
|
-
console.log(
|
|
2045
|
+
console.log(chalk33.dim("\nRun 'assist verify' to run all verify scripts"));
|
|
2009
2046
|
}
|
|
2010
2047
|
async function promptForScripts(availableOptions) {
|
|
2011
2048
|
if (availableOptions.length === 0) {
|
|
2012
|
-
console.log(
|
|
2049
|
+
console.log(chalk33.green("All verify scripts are already configured!"));
|
|
2013
2050
|
return null;
|
|
2014
2051
|
}
|
|
2015
|
-
console.log(
|
|
2052
|
+
console.log(chalk33.bold("Available verify scripts to add:\n"));
|
|
2016
2053
|
const selected = await promptMultiselect(
|
|
2017
2054
|
"Select verify scripts to add:",
|
|
2018
2055
|
availableOptions
|
|
2019
2056
|
);
|
|
2020
2057
|
if (selected.length === 0) {
|
|
2021
|
-
console.log(
|
|
2058
|
+
console.log(chalk33.yellow("No scripts selected"));
|
|
2022
2059
|
return null;
|
|
2023
2060
|
}
|
|
2024
2061
|
return selected;
|
|
@@ -2038,17 +2075,17 @@ async function init2() {
|
|
|
2038
2075
|
}
|
|
2039
2076
|
|
|
2040
2077
|
// src/commands/vscode/init/index.ts
|
|
2041
|
-
import
|
|
2078
|
+
import chalk35 from "chalk";
|
|
2042
2079
|
|
|
2043
2080
|
// src/commands/vscode/init/createLaunchJson.ts
|
|
2044
2081
|
import * as fs2 from "fs";
|
|
2045
2082
|
import * as path9 from "path";
|
|
2046
|
-
import
|
|
2083
|
+
import chalk34 from "chalk";
|
|
2047
2084
|
function ensureVscodeFolder() {
|
|
2048
2085
|
const vscodeDir = path9.join(process.cwd(), ".vscode");
|
|
2049
2086
|
if (!fs2.existsSync(vscodeDir)) {
|
|
2050
2087
|
fs2.mkdirSync(vscodeDir);
|
|
2051
|
-
console.log(
|
|
2088
|
+
console.log(chalk34.dim("Created .vscode folder"));
|
|
2052
2089
|
}
|
|
2053
2090
|
}
|
|
2054
2091
|
function removeVscodeFromGitignore() {
|
|
@@ -2063,7 +2100,7 @@ function removeVscodeFromGitignore() {
|
|
|
2063
2100
|
);
|
|
2064
2101
|
if (filteredLines.length !== lines.length) {
|
|
2065
2102
|
fs2.writeFileSync(gitignorePath, filteredLines.join("\n"));
|
|
2066
|
-
console.log(
|
|
2103
|
+
console.log(chalk34.dim("Removed .vscode references from .gitignore"));
|
|
2067
2104
|
}
|
|
2068
2105
|
}
|
|
2069
2106
|
function createLaunchJson(type) {
|
|
@@ -2082,7 +2119,7 @@ function createLaunchJson(type) {
|
|
|
2082
2119
|
const launchPath = path9.join(process.cwd(), ".vscode", "launch.json");
|
|
2083
2120
|
fs2.writeFileSync(launchPath, `${JSON.stringify(launchConfig, null, " ")}
|
|
2084
2121
|
`);
|
|
2085
|
-
console.log(
|
|
2122
|
+
console.log(chalk34.green("Created .vscode/launch.json"));
|
|
2086
2123
|
}
|
|
2087
2124
|
function createSettingsJson() {
|
|
2088
2125
|
const settings = {
|
|
@@ -2095,7 +2132,7 @@ function createSettingsJson() {
|
|
|
2095
2132
|
const settingsPath = path9.join(process.cwd(), ".vscode", "settings.json");
|
|
2096
2133
|
fs2.writeFileSync(settingsPath, `${JSON.stringify(settings, null, " ")}
|
|
2097
2134
|
`);
|
|
2098
|
-
console.log(
|
|
2135
|
+
console.log(chalk34.green("Created .vscode/settings.json"));
|
|
2099
2136
|
}
|
|
2100
2137
|
function createExtensionsJson() {
|
|
2101
2138
|
const extensions = {
|
|
@@ -2107,7 +2144,7 @@ function createExtensionsJson() {
|
|
|
2107
2144
|
`${JSON.stringify(extensions, null, " ")}
|
|
2108
2145
|
`
|
|
2109
2146
|
);
|
|
2110
|
-
console.log(
|
|
2147
|
+
console.log(chalk34.green("Created .vscode/extensions.json"));
|
|
2111
2148
|
}
|
|
2112
2149
|
|
|
2113
2150
|
// src/commands/vscode/init/detectVscodeSetup.ts
|
|
@@ -2164,7 +2201,7 @@ function applySelections(selected, setup2) {
|
|
|
2164
2201
|
for (const choice of selected) handlers[choice]?.();
|
|
2165
2202
|
}
|
|
2166
2203
|
async function promptForOptions(options2) {
|
|
2167
|
-
console.log(
|
|
2204
|
+
console.log(chalk35.bold("Available VS Code configurations to add:\n"));
|
|
2168
2205
|
return promptMultiselect("Select configurations to add:", options2);
|
|
2169
2206
|
}
|
|
2170
2207
|
async function init3({ all = false } = {}) {
|
|
@@ -2172,17 +2209,17 @@ async function init3({ all = false } = {}) {
|
|
|
2172
2209
|
const setup2 = detectVscodeSetup(pkg);
|
|
2173
2210
|
const options2 = getAvailableOptions2(setup2);
|
|
2174
2211
|
if (options2.length === 0) {
|
|
2175
|
-
console.log(
|
|
2212
|
+
console.log(chalk35.green("VS Code configuration already exists!"));
|
|
2176
2213
|
return;
|
|
2177
2214
|
}
|
|
2178
2215
|
const selected = all ? options2.map((o) => o.value) : await promptForOptions(options2);
|
|
2179
2216
|
if (selected.length === 0) {
|
|
2180
|
-
console.log(
|
|
2217
|
+
console.log(chalk35.yellow("No configurations selected"));
|
|
2181
2218
|
return;
|
|
2182
2219
|
}
|
|
2183
2220
|
applySelections(selected, setup2);
|
|
2184
2221
|
console.log(
|
|
2185
|
-
|
|
2222
|
+
chalk35.green(`
|
|
2186
2223
|
Added ${selected.length} VS Code configuration(s)`)
|
|
2187
2224
|
);
|
|
2188
2225
|
}
|
|
@@ -2195,7 +2232,7 @@ async function init4() {
|
|
|
2195
2232
|
|
|
2196
2233
|
// src/commands/lint/lint/runFileNameCheck.ts
|
|
2197
2234
|
import path16 from "path";
|
|
2198
|
-
import
|
|
2235
|
+
import chalk37 from "chalk";
|
|
2199
2236
|
|
|
2200
2237
|
// src/commands/lint/lint/checkFileNames.ts
|
|
2201
2238
|
import fs5 from "fs";
|
|
@@ -2275,7 +2312,7 @@ function checkFileNames() {
|
|
|
2275
2312
|
}
|
|
2276
2313
|
|
|
2277
2314
|
// src/commands/lint/lint/fixFileNameViolations.ts
|
|
2278
|
-
import
|
|
2315
|
+
import chalk36 from "chalk";
|
|
2279
2316
|
|
|
2280
2317
|
// src/commands/lint/lint/applyMoves.ts
|
|
2281
2318
|
import fs6 from "fs";
|
|
@@ -2360,25 +2397,25 @@ function fixFileNameViolations(moves) {
|
|
|
2360
2397
|
const start3 = performance.now();
|
|
2361
2398
|
const project = createLintProject();
|
|
2362
2399
|
const cwd = process.cwd();
|
|
2363
|
-
applyMoves(project, moves, cwd, (line) => console.log(
|
|
2400
|
+
applyMoves(project, moves, cwd, (line) => console.log(chalk36.green(line)));
|
|
2364
2401
|
const ms = (performance.now() - start3).toFixed(0);
|
|
2365
|
-
console.log(
|
|
2402
|
+
console.log(chalk36.dim(` Done in ${ms}ms`));
|
|
2366
2403
|
}
|
|
2367
2404
|
|
|
2368
2405
|
// src/commands/lint/lint/runFileNameCheck.ts
|
|
2369
2406
|
function reportViolations(violations) {
|
|
2370
|
-
console.error(
|
|
2407
|
+
console.error(chalk37.red("\nFile name check failed:\n"));
|
|
2371
2408
|
console.error(
|
|
2372
|
-
|
|
2409
|
+
chalk37.red(
|
|
2373
2410
|
" Files without classes or React components should not start with a capital letter.\n"
|
|
2374
2411
|
)
|
|
2375
2412
|
);
|
|
2376
2413
|
for (const violation of violations) {
|
|
2377
|
-
console.error(
|
|
2378
|
-
console.error(
|
|
2414
|
+
console.error(chalk37.red(` ${violation.filePath}`));
|
|
2415
|
+
console.error(chalk37.gray(` Rename to: ${violation.suggestedName}
|
|
2379
2416
|
`));
|
|
2380
2417
|
}
|
|
2381
|
-
console.error(
|
|
2418
|
+
console.error(chalk37.dim(" Run with -f to auto-fix.\n"));
|
|
2382
2419
|
}
|
|
2383
2420
|
function runFileNameCheck(fix = false) {
|
|
2384
2421
|
const violations = checkFileNames();
|
|
@@ -2407,17 +2444,17 @@ function runFileNameCheck(fix = false) {
|
|
|
2407
2444
|
import fs8 from "fs";
|
|
2408
2445
|
|
|
2409
2446
|
// src/commands/lint/shared.ts
|
|
2410
|
-
import
|
|
2447
|
+
import chalk38 from "chalk";
|
|
2411
2448
|
function reportViolations2(violations, checkName, errorMessage, successMessage) {
|
|
2412
2449
|
if (violations.length > 0) {
|
|
2413
|
-
console.error(
|
|
2450
|
+
console.error(chalk38.red(`
|
|
2414
2451
|
${checkName} failed:
|
|
2415
2452
|
`));
|
|
2416
|
-
console.error(
|
|
2453
|
+
console.error(chalk38.red(` ${errorMessage}
|
|
2417
2454
|
`));
|
|
2418
2455
|
for (const violation of violations) {
|
|
2419
|
-
console.error(
|
|
2420
|
-
console.error(
|
|
2456
|
+
console.error(chalk38.red(` ${violation.filePath}:${violation.line}`));
|
|
2457
|
+
console.error(chalk38.gray(` ${violation.content}
|
|
2421
2458
|
`));
|
|
2422
2459
|
}
|
|
2423
2460
|
return false;
|
|
@@ -2893,56 +2930,56 @@ async function newCli() {
|
|
|
2893
2930
|
|
|
2894
2931
|
// src/commands/new/registerNew/newProject.ts
|
|
2895
2932
|
import { execSync as execSync13 } from "child_process";
|
|
2896
|
-
import { existsSync as
|
|
2933
|
+
import { existsSync as existsSync15, readFileSync as readFileSync12, writeFileSync as writeFileSync12 } from "fs";
|
|
2897
2934
|
|
|
2898
2935
|
// src/commands/deploy/init/index.ts
|
|
2899
2936
|
import { execSync as execSync12 } from "child_process";
|
|
2900
|
-
import
|
|
2937
|
+
import chalk40 from "chalk";
|
|
2901
2938
|
import enquirer5 from "enquirer";
|
|
2902
2939
|
|
|
2903
2940
|
// src/commands/deploy/init/updateWorkflow.ts
|
|
2904
|
-
import { existsSync as
|
|
2941
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync3, readFileSync as readFileSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
2905
2942
|
import { dirname as dirname13, join as join10 } from "path";
|
|
2906
2943
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2907
|
-
import
|
|
2944
|
+
import chalk39 from "chalk";
|
|
2908
2945
|
var WORKFLOW_PATH = ".github/workflows/build.yml";
|
|
2909
2946
|
var __dirname3 = dirname13(fileURLToPath3(import.meta.url));
|
|
2910
2947
|
function getExistingSiteId() {
|
|
2911
|
-
if (!
|
|
2948
|
+
if (!existsSync14(WORKFLOW_PATH)) {
|
|
2912
2949
|
return null;
|
|
2913
2950
|
}
|
|
2914
|
-
const content =
|
|
2951
|
+
const content = readFileSync11(WORKFLOW_PATH, "utf-8");
|
|
2915
2952
|
const match = content.match(/-s\s+([a-f0-9-]{36})/);
|
|
2916
2953
|
return match ? match[1] : null;
|
|
2917
2954
|
}
|
|
2918
2955
|
function getTemplateContent(siteId) {
|
|
2919
2956
|
const templatePath = join10(__dirname3, "commands/deploy/build.yml");
|
|
2920
|
-
const template =
|
|
2957
|
+
const template = readFileSync11(templatePath, "utf-8");
|
|
2921
2958
|
return template.replace("{{NETLIFY_SITE_ID}}", siteId);
|
|
2922
2959
|
}
|
|
2923
2960
|
async function updateWorkflow(siteId) {
|
|
2924
2961
|
const newContent = getTemplateContent(siteId);
|
|
2925
2962
|
const workflowDir = ".github/workflows";
|
|
2926
|
-
if (!
|
|
2963
|
+
if (!existsSync14(workflowDir)) {
|
|
2927
2964
|
mkdirSync3(workflowDir, { recursive: true });
|
|
2928
2965
|
}
|
|
2929
|
-
if (
|
|
2930
|
-
const oldContent =
|
|
2966
|
+
if (existsSync14(WORKFLOW_PATH)) {
|
|
2967
|
+
const oldContent = readFileSync11(WORKFLOW_PATH, "utf-8");
|
|
2931
2968
|
if (oldContent === newContent) {
|
|
2932
|
-
console.log(
|
|
2969
|
+
console.log(chalk39.green("build.yml is already up to date"));
|
|
2933
2970
|
return;
|
|
2934
2971
|
}
|
|
2935
|
-
console.log(
|
|
2972
|
+
console.log(chalk39.yellow("\nbuild.yml will be updated:"));
|
|
2936
2973
|
console.log();
|
|
2937
2974
|
printDiff(oldContent, newContent);
|
|
2938
|
-
const confirm = await promptConfirm(
|
|
2975
|
+
const confirm = await promptConfirm(chalk39.red("Update build.yml?"));
|
|
2939
2976
|
if (!confirm) {
|
|
2940
2977
|
console.log("Skipped build.yml update");
|
|
2941
2978
|
return;
|
|
2942
2979
|
}
|
|
2943
2980
|
}
|
|
2944
2981
|
writeFileSync11(WORKFLOW_PATH, newContent);
|
|
2945
|
-
console.log(
|
|
2982
|
+
console.log(chalk39.green(`
|
|
2946
2983
|
Created ${WORKFLOW_PATH}`));
|
|
2947
2984
|
}
|
|
2948
2985
|
|
|
@@ -2953,43 +2990,43 @@ async function ensureNetlifyCli() {
|
|
|
2953
2990
|
} catch (error) {
|
|
2954
2991
|
if (!(error instanceof Error) || !error.message.includes("command not found"))
|
|
2955
2992
|
throw error;
|
|
2956
|
-
console.error(
|
|
2993
|
+
console.error(chalk40.red("\nNetlify CLI is not installed.\n"));
|
|
2957
2994
|
const install = await promptConfirm("Would you like to install it now?");
|
|
2958
2995
|
if (!install) {
|
|
2959
2996
|
console.log(
|
|
2960
|
-
|
|
2997
|
+
chalk40.yellow(
|
|
2961
2998
|
"\nInstall it manually with: npm install -g netlify-cli\n"
|
|
2962
2999
|
)
|
|
2963
3000
|
);
|
|
2964
3001
|
process.exit(1);
|
|
2965
3002
|
}
|
|
2966
|
-
console.log(
|
|
3003
|
+
console.log(chalk40.dim("\nInstalling netlify-cli...\n"));
|
|
2967
3004
|
execSync12("npm install -g netlify-cli", { stdio: "inherit" });
|
|
2968
3005
|
console.log();
|
|
2969
3006
|
execSync12("netlify sites:create --disable-linking", { stdio: "inherit" });
|
|
2970
3007
|
}
|
|
2971
3008
|
}
|
|
2972
3009
|
function printSetupInstructions() {
|
|
2973
|
-
console.log(
|
|
3010
|
+
console.log(chalk40.bold("\nDeployment initialized successfully!"));
|
|
2974
3011
|
console.log(
|
|
2975
|
-
|
|
3012
|
+
chalk40.yellow("\nTo complete setup, create a personal access token at:")
|
|
2976
3013
|
);
|
|
2977
3014
|
console.log(
|
|
2978
|
-
|
|
3015
|
+
chalk40.cyan(
|
|
2979
3016
|
"https://app.netlify.com/user/applications#personal-access-tokens"
|
|
2980
3017
|
)
|
|
2981
3018
|
);
|
|
2982
3019
|
console.log(
|
|
2983
|
-
|
|
3020
|
+
chalk40.yellow(
|
|
2984
3021
|
"\nThen add it as NETLIFY_AUTH_TOKEN in your GitHub repository secrets."
|
|
2985
3022
|
)
|
|
2986
3023
|
);
|
|
2987
3024
|
}
|
|
2988
3025
|
async function init5() {
|
|
2989
|
-
console.log(
|
|
3026
|
+
console.log(chalk40.bold("Initializing Netlify deployment...\n"));
|
|
2990
3027
|
const existingSiteId = getExistingSiteId();
|
|
2991
3028
|
if (existingSiteId) {
|
|
2992
|
-
console.log(
|
|
3029
|
+
console.log(chalk40.dim(`Using existing site ID: ${existingSiteId}
|
|
2993
3030
|
`));
|
|
2994
3031
|
await updateWorkflow(existingSiteId);
|
|
2995
3032
|
return;
|
|
@@ -3021,11 +3058,11 @@ async function newProject() {
|
|
|
3021
3058
|
}
|
|
3022
3059
|
function addViteBaseConfig() {
|
|
3023
3060
|
const viteConfigPath = "vite.config.ts";
|
|
3024
|
-
if (!
|
|
3061
|
+
if (!existsSync15(viteConfigPath)) {
|
|
3025
3062
|
console.log("No vite.config.ts found, skipping base config");
|
|
3026
3063
|
return;
|
|
3027
3064
|
}
|
|
3028
|
-
const content =
|
|
3065
|
+
const content = readFileSync12(viteConfigPath, "utf-8");
|
|
3029
3066
|
if (content.includes("base:")) {
|
|
3030
3067
|
console.log("vite.config.ts already has base config");
|
|
3031
3068
|
return;
|
|
@@ -3168,27 +3205,27 @@ async function notify() {
|
|
|
3168
3205
|
}
|
|
3169
3206
|
|
|
3170
3207
|
// src/commands/backlog/comment/index.ts
|
|
3171
|
-
import
|
|
3208
|
+
import chalk41 from "chalk";
|
|
3172
3209
|
function comment(id, text) {
|
|
3173
3210
|
const result = loadAndFindItem(id);
|
|
3174
3211
|
if (!result) process.exit(1);
|
|
3175
3212
|
addComment(result.item, text);
|
|
3176
3213
|
saveBacklog(result.items);
|
|
3177
|
-
console.log(
|
|
3214
|
+
console.log(chalk41.green(`Comment added to item #${id}.`));
|
|
3178
3215
|
}
|
|
3179
3216
|
|
|
3180
3217
|
// src/commands/backlog/comments/index.ts
|
|
3181
|
-
import
|
|
3218
|
+
import chalk42 from "chalk";
|
|
3182
3219
|
function comments(id) {
|
|
3183
3220
|
const result = loadAndFindItem(id);
|
|
3184
3221
|
if (!result) process.exit(1);
|
|
3185
3222
|
const { item } = result;
|
|
3186
3223
|
const entries = item.comments ?? [];
|
|
3187
3224
|
if (entries.length === 0) {
|
|
3188
|
-
console.log(
|
|
3225
|
+
console.log(chalk42.dim(`No comments on item #${id}.`));
|
|
3189
3226
|
return;
|
|
3190
3227
|
}
|
|
3191
|
-
console.log(
|
|
3228
|
+
console.log(chalk42.bold(`Comments for #${id}: ${item.name}
|
|
3192
3229
|
`));
|
|
3193
3230
|
for (const entry of entries) {
|
|
3194
3231
|
console.log(`${formatComment(entry)}
|
|
@@ -3203,12 +3240,12 @@ function registerCommentCommands(cmd) {
|
|
|
3203
3240
|
}
|
|
3204
3241
|
|
|
3205
3242
|
// src/commands/backlog/add/index.ts
|
|
3206
|
-
import { existsSync as
|
|
3207
|
-
import
|
|
3243
|
+
import { existsSync as existsSync16 } from "fs";
|
|
3244
|
+
import chalk44 from "chalk";
|
|
3208
3245
|
|
|
3209
3246
|
// src/commands/backlog/commitBacklog.ts
|
|
3210
3247
|
import { execSync as execSync14 } from "child_process";
|
|
3211
|
-
import
|
|
3248
|
+
import chalk43 from "chalk";
|
|
3212
3249
|
function commitBacklog(id, name) {
|
|
3213
3250
|
try {
|
|
3214
3251
|
const backlogPath = getBacklogPath();
|
|
@@ -3216,13 +3253,13 @@ function commitBacklog(id, name) {
|
|
|
3216
3253
|
execSync14(`git add ${shellQuote(backlogPath)}`, { stdio: "ignore" });
|
|
3217
3254
|
execSync14(`git commit -m ${shellQuote(message)}`, { stdio: "ignore" });
|
|
3218
3255
|
} catch {
|
|
3219
|
-
console.log(
|
|
3256
|
+
console.log(chalk43.yellow("Warning: could not auto-commit backlog file."));
|
|
3220
3257
|
}
|
|
3221
3258
|
}
|
|
3222
3259
|
|
|
3223
3260
|
// src/commands/backlog/add/shared.ts
|
|
3224
3261
|
import { spawnSync } from "child_process";
|
|
3225
|
-
import { mkdtempSync, readFileSync as
|
|
3262
|
+
import { mkdtempSync, readFileSync as readFileSync13, unlinkSync as unlinkSync3, writeFileSync as writeFileSync13 } from "fs";
|
|
3226
3263
|
import { tmpdir } from "os";
|
|
3227
3264
|
import { join as join11 } from "path";
|
|
3228
3265
|
import enquirer6 from "enquirer";
|
|
@@ -3272,7 +3309,7 @@ function openEditor() {
|
|
|
3272
3309
|
unlinkSync3(filePath);
|
|
3273
3310
|
return void 0;
|
|
3274
3311
|
}
|
|
3275
|
-
const content =
|
|
3312
|
+
const content = readFileSync13(filePath, "utf-8").trim();
|
|
3276
3313
|
unlinkSync3(filePath);
|
|
3277
3314
|
return content || void 0;
|
|
3278
3315
|
}
|
|
@@ -3294,7 +3331,7 @@ async function promptAcceptanceCriteria() {
|
|
|
3294
3331
|
var addItemSchema = backlogItemSchema.omit({ id: true, status: true });
|
|
3295
3332
|
async function addFromJson() {
|
|
3296
3333
|
if (process.stdin.isTTY) {
|
|
3297
|
-
console.log(
|
|
3334
|
+
console.log(chalk44.red("--json requires piped input on stdin."));
|
|
3298
3335
|
return;
|
|
3299
3336
|
}
|
|
3300
3337
|
const input = await readStdin();
|
|
@@ -3308,7 +3345,7 @@ async function addFromJson() {
|
|
|
3308
3345
|
items.push({ ...data, id, status: "todo" });
|
|
3309
3346
|
saveBacklog(items);
|
|
3310
3347
|
commitBacklog(id, data.name);
|
|
3311
|
-
console.log(
|
|
3348
|
+
console.log(chalk44.green(`Added item #${id}: ${data.name}`));
|
|
3312
3349
|
}
|
|
3313
3350
|
async function addInteractive() {
|
|
3314
3351
|
const type = await promptType();
|
|
@@ -3327,12 +3364,12 @@ async function addInteractive() {
|
|
|
3327
3364
|
});
|
|
3328
3365
|
saveBacklog(items);
|
|
3329
3366
|
commitBacklog(id, name);
|
|
3330
|
-
console.log(
|
|
3367
|
+
console.log(chalk44.green(`Added item #${id}: ${name}`));
|
|
3331
3368
|
}
|
|
3332
3369
|
async function add(options2) {
|
|
3333
|
-
if (!
|
|
3370
|
+
if (!existsSync16(getBacklogPath())) {
|
|
3334
3371
|
console.log(
|
|
3335
|
-
|
|
3372
|
+
chalk44.yellow(
|
|
3336
3373
|
"No backlog found. Run 'assist backlog init' to create one."
|
|
3337
3374
|
)
|
|
3338
3375
|
);
|
|
@@ -3346,30 +3383,30 @@ async function add(options2) {
|
|
|
3346
3383
|
}
|
|
3347
3384
|
|
|
3348
3385
|
// src/commands/backlog/init/index.ts
|
|
3349
|
-
import { existsSync as
|
|
3350
|
-
import
|
|
3386
|
+
import { existsSync as existsSync17 } from "fs";
|
|
3387
|
+
import chalk45 from "chalk";
|
|
3351
3388
|
async function init6() {
|
|
3352
3389
|
const backlogPath = getBacklogPath();
|
|
3353
|
-
if (
|
|
3354
|
-
console.log(
|
|
3390
|
+
if (existsSync17(backlogPath)) {
|
|
3391
|
+
console.log(chalk45.yellow("assist.backlog.yml already exists."));
|
|
3355
3392
|
return;
|
|
3356
3393
|
}
|
|
3357
3394
|
saveBacklog([]);
|
|
3358
|
-
console.log(
|
|
3395
|
+
console.log(chalk45.green("Created assist.backlog.yml"));
|
|
3359
3396
|
}
|
|
3360
3397
|
|
|
3361
3398
|
// src/commands/backlog/list/index.ts
|
|
3362
|
-
import { existsSync as
|
|
3363
|
-
import
|
|
3399
|
+
import { existsSync as existsSync18 } from "fs";
|
|
3400
|
+
import chalk46 from "chalk";
|
|
3364
3401
|
function filterItems(items, options2) {
|
|
3365
3402
|
if (options2.status) return items.filter((i) => i.status === options2.status);
|
|
3366
3403
|
if (!options2.all) return items.filter((i) => i.status !== "done");
|
|
3367
3404
|
return items;
|
|
3368
3405
|
}
|
|
3369
3406
|
async function list2(options2) {
|
|
3370
|
-
if (!
|
|
3407
|
+
if (!existsSync18(getBacklogPath())) {
|
|
3371
3408
|
console.log(
|
|
3372
|
-
|
|
3409
|
+
chalk46.yellow(
|
|
3373
3410
|
"No backlog found. Run 'assist backlog init' to create one."
|
|
3374
3411
|
)
|
|
3375
3412
|
);
|
|
@@ -3377,12 +3414,12 @@ async function list2(options2) {
|
|
|
3377
3414
|
}
|
|
3378
3415
|
const items = filterItems(loadBacklog(), options2);
|
|
3379
3416
|
if (items.length === 0) {
|
|
3380
|
-
console.log(
|
|
3417
|
+
console.log(chalk46.dim("Backlog is empty."));
|
|
3381
3418
|
return;
|
|
3382
3419
|
}
|
|
3383
3420
|
for (const item of items) {
|
|
3384
3421
|
console.log(
|
|
3385
|
-
`${statusIcon(item.status)} ${typeLabel(item.type)} ${
|
|
3422
|
+
`${statusIcon(item.status)} ${typeLabel(item.type)} ${chalk46.dim(`#${item.id}`)} ${item.name}${phaseLabel(item)}`
|
|
3386
3423
|
);
|
|
3387
3424
|
if (options2.verbose) {
|
|
3388
3425
|
printVerboseDetails(item);
|
|
@@ -3517,7 +3554,7 @@ function extractGraphqlQuery(args) {
|
|
|
3517
3554
|
}
|
|
3518
3555
|
|
|
3519
3556
|
// src/shared/loadCliReads.ts
|
|
3520
|
-
import { existsSync as
|
|
3557
|
+
import { existsSync as existsSync19, readFileSync as readFileSync14, writeFileSync as writeFileSync14 } from "fs";
|
|
3521
3558
|
import { dirname as dirname14, resolve as resolve2 } from "path";
|
|
3522
3559
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
3523
3560
|
var __filename2 = fileURLToPath4(import.meta.url);
|
|
@@ -3529,11 +3566,11 @@ var cachedLines;
|
|
|
3529
3566
|
function getCliReadsLines() {
|
|
3530
3567
|
if (cachedLines) return cachedLines;
|
|
3531
3568
|
const path50 = getCliReadsPath();
|
|
3532
|
-
if (!
|
|
3569
|
+
if (!existsSync19(path50)) {
|
|
3533
3570
|
cachedLines = [];
|
|
3534
3571
|
return cachedLines;
|
|
3535
3572
|
}
|
|
3536
|
-
cachedLines =
|
|
3573
|
+
cachedLines = readFileSync14(path50, "utf-8").split("\n").filter((line) => line.trim() !== "");
|
|
3537
3574
|
return cachedLines;
|
|
3538
3575
|
}
|
|
3539
3576
|
function loadCliReads() {
|
|
@@ -3558,7 +3595,7 @@ function findCliRead(command) {
|
|
|
3558
3595
|
}
|
|
3559
3596
|
|
|
3560
3597
|
// src/shared/matchesBashAllow.ts
|
|
3561
|
-
import { existsSync as
|
|
3598
|
+
import { existsSync as existsSync20, readFileSync as readFileSync15 } from "fs";
|
|
3562
3599
|
import { homedir as homedir3 } from "os";
|
|
3563
3600
|
import { join as join12 } from "path";
|
|
3564
3601
|
var cached;
|
|
@@ -3586,9 +3623,9 @@ function collectAllowEntries() {
|
|
|
3586
3623
|
return entries;
|
|
3587
3624
|
}
|
|
3588
3625
|
function readAllowArray(filePath) {
|
|
3589
|
-
if (!
|
|
3626
|
+
if (!existsSync20(filePath)) return [];
|
|
3590
3627
|
try {
|
|
3591
|
-
const data = JSON.parse(
|
|
3628
|
+
const data = JSON.parse(readFileSync15(filePath, "utf-8"));
|
|
3592
3629
|
const allow = data?.permissions?.allow;
|
|
3593
3630
|
return Array.isArray(allow) ? allow.filter((e) => typeof e === "string") : [];
|
|
3594
3631
|
} catch {
|
|
@@ -3738,7 +3775,7 @@ ${reasons.join("\n")}`);
|
|
|
3738
3775
|
}
|
|
3739
3776
|
|
|
3740
3777
|
// src/commands/permitCliReads/index.ts
|
|
3741
|
-
import { existsSync as
|
|
3778
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync4, readFileSync as readFileSync16, writeFileSync as writeFileSync15 } from "fs";
|
|
3742
3779
|
import { homedir as homedir4 } from "os";
|
|
3743
3780
|
import { join as join13 } from "path";
|
|
3744
3781
|
|
|
@@ -3784,11 +3821,11 @@ function assertCliExists(cli) {
|
|
|
3784
3821
|
}
|
|
3785
3822
|
|
|
3786
3823
|
// src/commands/permitCliReads/colorize.ts
|
|
3787
|
-
import
|
|
3824
|
+
import chalk47 from "chalk";
|
|
3788
3825
|
function colorize(plainOutput) {
|
|
3789
3826
|
return plainOutput.split("\n").map((line) => {
|
|
3790
|
-
if (line.startsWith(" R ")) return
|
|
3791
|
-
if (line.startsWith(" W ")) return
|
|
3827
|
+
if (line.startsWith(" R ")) return chalk47.green(line);
|
|
3828
|
+
if (line.startsWith(" W ")) return chalk47.red(line);
|
|
3792
3829
|
return line;
|
|
3793
3830
|
}).join("\n");
|
|
3794
3831
|
}
|
|
@@ -4046,8 +4083,8 @@ function logPath(cli) {
|
|
|
4046
4083
|
}
|
|
4047
4084
|
function readCache(cli) {
|
|
4048
4085
|
const path50 = logPath(cli);
|
|
4049
|
-
if (!
|
|
4050
|
-
return
|
|
4086
|
+
if (!existsSync21(path50)) return void 0;
|
|
4087
|
+
return readFileSync16(path50, "utf-8");
|
|
4051
4088
|
}
|
|
4052
4089
|
function writeCache(cli, output) {
|
|
4053
4090
|
const dir = join13(homedir4(), ".assist");
|
|
@@ -4102,15 +4139,15 @@ function registerCliHook(program2) {
|
|
|
4102
4139
|
}
|
|
4103
4140
|
|
|
4104
4141
|
// src/commands/complexity/analyze.ts
|
|
4105
|
-
import
|
|
4142
|
+
import chalk53 from "chalk";
|
|
4106
4143
|
|
|
4107
4144
|
// src/commands/complexity/cyclomatic.ts
|
|
4108
|
-
import
|
|
4145
|
+
import chalk49 from "chalk";
|
|
4109
4146
|
|
|
4110
4147
|
// src/commands/complexity/shared/index.ts
|
|
4111
4148
|
import fs12 from "fs";
|
|
4112
4149
|
import path20 from "path";
|
|
4113
|
-
import
|
|
4150
|
+
import chalk48 from "chalk";
|
|
4114
4151
|
import ts5 from "typescript";
|
|
4115
4152
|
|
|
4116
4153
|
// src/commands/complexity/findSourceFiles.ts
|
|
@@ -4356,7 +4393,7 @@ function createSourceFromFile(filePath) {
|
|
|
4356
4393
|
function withSourceFiles(pattern2, callback) {
|
|
4357
4394
|
const files = findSourceFiles2(pattern2);
|
|
4358
4395
|
if (files.length === 0) {
|
|
4359
|
-
console.log(
|
|
4396
|
+
console.log(chalk48.yellow("No files found matching pattern"));
|
|
4360
4397
|
return void 0;
|
|
4361
4398
|
}
|
|
4362
4399
|
return callback(files);
|
|
@@ -4389,11 +4426,11 @@ async function cyclomatic(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4389
4426
|
results.sort((a, b) => b.complexity - a.complexity);
|
|
4390
4427
|
for (const { file, name, complexity } of results) {
|
|
4391
4428
|
const exceedsThreshold = options2.threshold !== void 0 && complexity > options2.threshold;
|
|
4392
|
-
const color = exceedsThreshold ?
|
|
4393
|
-
console.log(`${color(`${file}:${name}`)} \u2192 ${
|
|
4429
|
+
const color = exceedsThreshold ? chalk49.red : chalk49.white;
|
|
4430
|
+
console.log(`${color(`${file}:${name}`)} \u2192 ${chalk49.cyan(complexity)}`);
|
|
4394
4431
|
}
|
|
4395
4432
|
console.log(
|
|
4396
|
-
|
|
4433
|
+
chalk49.dim(
|
|
4397
4434
|
`
|
|
4398
4435
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
4399
4436
|
)
|
|
@@ -4405,7 +4442,7 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
4405
4442
|
}
|
|
4406
4443
|
|
|
4407
4444
|
// src/commands/complexity/halstead.ts
|
|
4408
|
-
import
|
|
4445
|
+
import chalk50 from "chalk";
|
|
4409
4446
|
async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
4410
4447
|
withSourceFiles(pattern2, (files) => {
|
|
4411
4448
|
const results = [];
|
|
@@ -4420,13 +4457,13 @@ async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4420
4457
|
results.sort((a, b) => b.metrics.effort - a.metrics.effort);
|
|
4421
4458
|
for (const { file, name, metrics } of results) {
|
|
4422
4459
|
const exceedsThreshold = options2.threshold !== void 0 && metrics.volume > options2.threshold;
|
|
4423
|
-
const color = exceedsThreshold ?
|
|
4460
|
+
const color = exceedsThreshold ? chalk50.red : chalk50.white;
|
|
4424
4461
|
console.log(
|
|
4425
|
-
`${color(`${file}:${name}`)} \u2192 volume: ${
|
|
4462
|
+
`${color(`${file}:${name}`)} \u2192 volume: ${chalk50.cyan(metrics.volume.toFixed(1))}, difficulty: ${chalk50.yellow(metrics.difficulty.toFixed(1))}, effort: ${chalk50.magenta(metrics.effort.toFixed(1))}`
|
|
4426
4463
|
);
|
|
4427
4464
|
}
|
|
4428
4465
|
console.log(
|
|
4429
|
-
|
|
4466
|
+
chalk50.dim(
|
|
4430
4467
|
`
|
|
4431
4468
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
4432
4469
|
)
|
|
@@ -4441,28 +4478,28 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
4441
4478
|
import fs13 from "fs";
|
|
4442
4479
|
|
|
4443
4480
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
4444
|
-
import
|
|
4481
|
+
import chalk51 from "chalk";
|
|
4445
4482
|
function displayMaintainabilityResults(results, threshold) {
|
|
4446
4483
|
const filtered = threshold !== void 0 ? results.filter((r) => r.minMaintainability < threshold) : results;
|
|
4447
4484
|
if (threshold !== void 0 && filtered.length === 0) {
|
|
4448
|
-
console.log(
|
|
4485
|
+
console.log(chalk51.green("All files pass maintainability threshold"));
|
|
4449
4486
|
} else {
|
|
4450
4487
|
for (const { file, avgMaintainability, minMaintainability } of filtered) {
|
|
4451
|
-
const color = threshold !== void 0 ?
|
|
4488
|
+
const color = threshold !== void 0 ? chalk51.red : chalk51.white;
|
|
4452
4489
|
console.log(
|
|
4453
|
-
`${color(file)} \u2192 avg: ${
|
|
4490
|
+
`${color(file)} \u2192 avg: ${chalk51.cyan(avgMaintainability.toFixed(1))}, min: ${chalk51.yellow(minMaintainability.toFixed(1))}`
|
|
4454
4491
|
);
|
|
4455
4492
|
}
|
|
4456
4493
|
}
|
|
4457
|
-
console.log(
|
|
4494
|
+
console.log(chalk51.dim(`
|
|
4458
4495
|
Analyzed ${results.length} files`));
|
|
4459
4496
|
if (filtered.length > 0 && threshold !== void 0) {
|
|
4460
4497
|
console.error(
|
|
4461
|
-
|
|
4498
|
+
chalk51.red(
|
|
4462
4499
|
`
|
|
4463
4500
|
Fail: ${filtered.length} file(s) below threshold ${threshold}. Maintainability index (0\u2013100) is derived from Halstead volume, cyclomatic complexity, and lines of code.
|
|
4464
4501
|
|
|
4465
|
-
\u26A0\uFE0F ${
|
|
4502
|
+
\u26A0\uFE0F ${chalk51.bold("Diagnose and fix one file at a time")} \u2014 do not investigate or fix multiple files in parallel. Run 'assist complexity <file>' to see all metrics. For larger files, start by extracting responsibilities into smaller files.`
|
|
4466
4503
|
)
|
|
4467
4504
|
);
|
|
4468
4505
|
process.exit(1);
|
|
@@ -4519,7 +4556,7 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4519
4556
|
|
|
4520
4557
|
// src/commands/complexity/sloc.ts
|
|
4521
4558
|
import fs14 from "fs";
|
|
4522
|
-
import
|
|
4559
|
+
import chalk52 from "chalk";
|
|
4523
4560
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
4524
4561
|
withSourceFiles(pattern2, (files) => {
|
|
4525
4562
|
const results = [];
|
|
@@ -4535,12 +4572,12 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4535
4572
|
results.sort((a, b) => b.lines - a.lines);
|
|
4536
4573
|
for (const { file, lines } of results) {
|
|
4537
4574
|
const exceedsThreshold = options2.threshold !== void 0 && lines > options2.threshold;
|
|
4538
|
-
const color = exceedsThreshold ?
|
|
4539
|
-
console.log(`${color(file)} \u2192 ${
|
|
4575
|
+
const color = exceedsThreshold ? chalk52.red : chalk52.white;
|
|
4576
|
+
console.log(`${color(file)} \u2192 ${chalk52.cyan(lines)} lines`);
|
|
4540
4577
|
}
|
|
4541
4578
|
const total = results.reduce((sum, r) => sum + r.lines, 0);
|
|
4542
4579
|
console.log(
|
|
4543
|
-
|
|
4580
|
+
chalk52.dim(`
|
|
4544
4581
|
Total: ${total} lines across ${files.length} files`)
|
|
4545
4582
|
);
|
|
4546
4583
|
if (hasViolation) {
|
|
@@ -4554,21 +4591,21 @@ async function analyze(pattern2) {
|
|
|
4554
4591
|
const searchPattern = pattern2.includes("*") || pattern2.includes("/") ? pattern2 : `**/${pattern2}`;
|
|
4555
4592
|
const files = findSourceFiles2(searchPattern);
|
|
4556
4593
|
if (files.length === 0) {
|
|
4557
|
-
console.log(
|
|
4594
|
+
console.log(chalk53.yellow("No files found matching pattern"));
|
|
4558
4595
|
return;
|
|
4559
4596
|
}
|
|
4560
4597
|
if (files.length === 1) {
|
|
4561
4598
|
const file = files[0];
|
|
4562
|
-
console.log(
|
|
4599
|
+
console.log(chalk53.bold.underline("SLOC"));
|
|
4563
4600
|
await sloc(file);
|
|
4564
4601
|
console.log();
|
|
4565
|
-
console.log(
|
|
4602
|
+
console.log(chalk53.bold.underline("Cyclomatic Complexity"));
|
|
4566
4603
|
await cyclomatic(file);
|
|
4567
4604
|
console.log();
|
|
4568
|
-
console.log(
|
|
4605
|
+
console.log(chalk53.bold.underline("Halstead Metrics"));
|
|
4569
4606
|
await halstead(file);
|
|
4570
4607
|
console.log();
|
|
4571
|
-
console.log(
|
|
4608
|
+
console.log(chalk53.bold.underline("Maintainability Index"));
|
|
4572
4609
|
await maintainability(file);
|
|
4573
4610
|
return;
|
|
4574
4611
|
}
|
|
@@ -4595,8 +4632,8 @@ function registerComplexity(program2) {
|
|
|
4595
4632
|
}
|
|
4596
4633
|
|
|
4597
4634
|
// src/commands/deploy/redirect.ts
|
|
4598
|
-
import { existsSync as
|
|
4599
|
-
import
|
|
4635
|
+
import { existsSync as existsSync22, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
4636
|
+
import chalk54 from "chalk";
|
|
4600
4637
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
4601
4638
|
if (!window.location.pathname.endsWith('/')) {
|
|
4602
4639
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -4604,23 +4641,23 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
4604
4641
|
</script>`;
|
|
4605
4642
|
function redirect() {
|
|
4606
4643
|
const indexPath = "index.html";
|
|
4607
|
-
if (!
|
|
4608
|
-
console.log(
|
|
4644
|
+
if (!existsSync22(indexPath)) {
|
|
4645
|
+
console.log(chalk54.yellow("No index.html found"));
|
|
4609
4646
|
return;
|
|
4610
4647
|
}
|
|
4611
|
-
const content =
|
|
4648
|
+
const content = readFileSync17(indexPath, "utf-8");
|
|
4612
4649
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
4613
|
-
console.log(
|
|
4650
|
+
console.log(chalk54.dim("Trailing slash script already present"));
|
|
4614
4651
|
return;
|
|
4615
4652
|
}
|
|
4616
4653
|
const headCloseIndex = content.indexOf("</head>");
|
|
4617
4654
|
if (headCloseIndex === -1) {
|
|
4618
|
-
console.log(
|
|
4655
|
+
console.log(chalk54.red("Could not find </head> tag in index.html"));
|
|
4619
4656
|
return;
|
|
4620
4657
|
}
|
|
4621
4658
|
const newContent = content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT + "\n " + content.slice(headCloseIndex);
|
|
4622
4659
|
writeFileSync16(indexPath, newContent);
|
|
4623
|
-
console.log(
|
|
4660
|
+
console.log(chalk54.green("Added trailing slash redirect to index.html"));
|
|
4624
4661
|
}
|
|
4625
4662
|
|
|
4626
4663
|
// src/commands/registerDeploy.ts
|
|
@@ -4647,10 +4684,10 @@ function loadBlogSkipDays(repoName) {
|
|
|
4647
4684
|
|
|
4648
4685
|
// src/commands/devlog/shared.ts
|
|
4649
4686
|
import { execSync as execSync17 } from "child_process";
|
|
4650
|
-
import
|
|
4687
|
+
import chalk55 from "chalk";
|
|
4651
4688
|
|
|
4652
4689
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
4653
|
-
import { readdirSync, readFileSync as
|
|
4690
|
+
import { readdirSync, readFileSync as readFileSync18 } from "fs";
|
|
4654
4691
|
import { join as join15 } from "path";
|
|
4655
4692
|
var DEVLOG_DIR = join15(BLOG_REPO_ROOT, "src/content/devlog");
|
|
4656
4693
|
function extractFrontmatter(content) {
|
|
@@ -4680,7 +4717,7 @@ function readDevlogFiles(callback) {
|
|
|
4680
4717
|
try {
|
|
4681
4718
|
const files = readdirSync(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
4682
4719
|
for (const file of files) {
|
|
4683
|
-
const content =
|
|
4720
|
+
const content = readFileSync18(join15(DEVLOG_DIR, file), "utf-8");
|
|
4684
4721
|
const parsed = parseFrontmatter(content, file);
|
|
4685
4722
|
if (parsed) callback(parsed);
|
|
4686
4723
|
}
|
|
@@ -4734,13 +4771,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
4734
4771
|
}
|
|
4735
4772
|
function printCommitsWithFiles(commits, ignore2, verbose) {
|
|
4736
4773
|
for (const commit2 of commits) {
|
|
4737
|
-
console.log(` ${
|
|
4774
|
+
console.log(` ${chalk55.yellow(commit2.hash)} ${commit2.message}`);
|
|
4738
4775
|
if (verbose) {
|
|
4739
4776
|
const visibleFiles = commit2.files.filter(
|
|
4740
4777
|
(file) => !ignore2.some((p) => file.startsWith(p))
|
|
4741
4778
|
);
|
|
4742
4779
|
for (const file of visibleFiles) {
|
|
4743
|
-
console.log(` ${
|
|
4780
|
+
console.log(` ${chalk55.dim(file)}`);
|
|
4744
4781
|
}
|
|
4745
4782
|
}
|
|
4746
4783
|
}
|
|
@@ -4765,15 +4802,15 @@ function parseGitLogCommits(output, ignore2, afterDate) {
|
|
|
4765
4802
|
}
|
|
4766
4803
|
|
|
4767
4804
|
// src/commands/devlog/list/printDateHeader.ts
|
|
4768
|
-
import
|
|
4805
|
+
import chalk56 from "chalk";
|
|
4769
4806
|
function printDateHeader(date, isSkipped, entries) {
|
|
4770
4807
|
if (isSkipped) {
|
|
4771
|
-
console.log(`${
|
|
4808
|
+
console.log(`${chalk56.bold.blue(date)} ${chalk56.dim("skipped")}`);
|
|
4772
4809
|
} else if (entries && entries.length > 0) {
|
|
4773
|
-
const entryInfo = entries.map((e) => `${
|
|
4774
|
-
console.log(`${
|
|
4810
|
+
const entryInfo = entries.map((e) => `${chalk56.green(e.version)} ${e.title}`).join(" | ");
|
|
4811
|
+
console.log(`${chalk56.bold.blue(date)} ${entryInfo}`);
|
|
4775
4812
|
} else {
|
|
4776
|
-
console.log(`${
|
|
4813
|
+
console.log(`${chalk56.bold.blue(date)} ${chalk56.red("\u26A0 devlog missing")}`);
|
|
4777
4814
|
}
|
|
4778
4815
|
}
|
|
4779
4816
|
|
|
@@ -4876,24 +4913,24 @@ function bumpVersion(version2, type) {
|
|
|
4876
4913
|
|
|
4877
4914
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
4878
4915
|
import { execSync as execSync20 } from "child_process";
|
|
4879
|
-
import
|
|
4916
|
+
import chalk58 from "chalk";
|
|
4880
4917
|
|
|
4881
4918
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
4882
|
-
import
|
|
4919
|
+
import chalk57 from "chalk";
|
|
4883
4920
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
4884
4921
|
if (conventional && firstHash) {
|
|
4885
4922
|
const version2 = getVersionAtCommit(firstHash);
|
|
4886
4923
|
if (version2) {
|
|
4887
|
-
console.log(`${
|
|
4924
|
+
console.log(`${chalk57.bold("version:")} ${stripToMinor(version2)}`);
|
|
4888
4925
|
} else {
|
|
4889
|
-
console.log(`${
|
|
4926
|
+
console.log(`${chalk57.bold("version:")} ${chalk57.red("unknown")}`);
|
|
4890
4927
|
}
|
|
4891
4928
|
} else if (patchVersion && minorVersion) {
|
|
4892
4929
|
console.log(
|
|
4893
|
-
`${
|
|
4930
|
+
`${chalk57.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
4894
4931
|
);
|
|
4895
4932
|
} else {
|
|
4896
|
-
console.log(`${
|
|
4933
|
+
console.log(`${chalk57.bold("version:")} v0.1 (initial)`);
|
|
4897
4934
|
}
|
|
4898
4935
|
}
|
|
4899
4936
|
|
|
@@ -4940,16 +4977,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
4940
4977
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
4941
4978
|
}
|
|
4942
4979
|
function logName(repoName) {
|
|
4943
|
-
console.log(`${
|
|
4980
|
+
console.log(`${chalk58.bold("name:")} ${repoName}`);
|
|
4944
4981
|
}
|
|
4945
4982
|
function displayNextEntry(ctx, targetDate, commits) {
|
|
4946
4983
|
logName(ctx.repoName);
|
|
4947
4984
|
printVersionInfo(ctx.config, ctx.lastInfo, commits[0]?.hash);
|
|
4948
|
-
console.log(
|
|
4985
|
+
console.log(chalk58.bold.blue(targetDate));
|
|
4949
4986
|
printCommitsWithFiles(commits, ctx.ignore, ctx.verbose);
|
|
4950
4987
|
}
|
|
4951
4988
|
function logNoCommits(lastInfo) {
|
|
4952
|
-
console.log(
|
|
4989
|
+
console.log(chalk58.dim(noCommitsMessage(!!lastInfo)));
|
|
4953
4990
|
}
|
|
4954
4991
|
|
|
4955
4992
|
// src/commands/devlog/next/index.ts
|
|
@@ -4990,11 +5027,11 @@ function next2(options2) {
|
|
|
4990
5027
|
import { execSync as execSync21 } from "child_process";
|
|
4991
5028
|
|
|
4992
5029
|
// src/commands/devlog/repos/printReposTable.ts
|
|
4993
|
-
import
|
|
5030
|
+
import chalk59 from "chalk";
|
|
4994
5031
|
function colorStatus(status2) {
|
|
4995
|
-
if (status2 === "missing") return
|
|
4996
|
-
if (status2 === "outdated") return
|
|
4997
|
-
return
|
|
5032
|
+
if (status2 === "missing") return chalk59.red(status2);
|
|
5033
|
+
if (status2 === "outdated") return chalk59.yellow(status2);
|
|
5034
|
+
return chalk59.green(status2);
|
|
4998
5035
|
}
|
|
4999
5036
|
function formatRow(row, nameWidth) {
|
|
5000
5037
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -5008,8 +5045,8 @@ function printReposTable(rows) {
|
|
|
5008
5045
|
"Last Devlog".padEnd(11),
|
|
5009
5046
|
"Status"
|
|
5010
5047
|
].join(" ");
|
|
5011
|
-
console.log(
|
|
5012
|
-
console.log(
|
|
5048
|
+
console.log(chalk59.dim(header));
|
|
5049
|
+
console.log(chalk59.dim("-".repeat(header.length)));
|
|
5013
5050
|
for (const row of rows) {
|
|
5014
5051
|
console.log(formatRow(row, nameWidth));
|
|
5015
5052
|
}
|
|
@@ -5067,14 +5104,14 @@ function repos(options2) {
|
|
|
5067
5104
|
// src/commands/devlog/skip.ts
|
|
5068
5105
|
import { writeFileSync as writeFileSync17 } from "fs";
|
|
5069
5106
|
import { join as join16 } from "path";
|
|
5070
|
-
import
|
|
5107
|
+
import chalk60 from "chalk";
|
|
5071
5108
|
import { stringify as stringifyYaml4 } from "yaml";
|
|
5072
5109
|
function getBlogConfigPath() {
|
|
5073
5110
|
return join16(BLOG_REPO_ROOT, "assist.yml");
|
|
5074
5111
|
}
|
|
5075
5112
|
function skip(date) {
|
|
5076
5113
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
5077
|
-
console.log(
|
|
5114
|
+
console.log(chalk60.red("Invalid date format. Use YYYY-MM-DD"));
|
|
5078
5115
|
process.exit(1);
|
|
5079
5116
|
}
|
|
5080
5117
|
const repoName = getRepoName();
|
|
@@ -5085,7 +5122,7 @@ function skip(date) {
|
|
|
5085
5122
|
const skipDays = skip2[repoName] ?? [];
|
|
5086
5123
|
if (skipDays.includes(date)) {
|
|
5087
5124
|
console.log(
|
|
5088
|
-
|
|
5125
|
+
chalk60.yellow(`${date} is already in skip list for ${repoName}`)
|
|
5089
5126
|
);
|
|
5090
5127
|
return;
|
|
5091
5128
|
}
|
|
@@ -5095,20 +5132,20 @@ function skip(date) {
|
|
|
5095
5132
|
devlog.skip = skip2;
|
|
5096
5133
|
config.devlog = devlog;
|
|
5097
5134
|
writeFileSync17(configPath, stringifyYaml4(config, { lineWidth: 0 }));
|
|
5098
|
-
console.log(
|
|
5135
|
+
console.log(chalk60.green(`Added ${date} to skip list for ${repoName}`));
|
|
5099
5136
|
}
|
|
5100
5137
|
|
|
5101
5138
|
// src/commands/devlog/version.ts
|
|
5102
|
-
import
|
|
5139
|
+
import chalk61 from "chalk";
|
|
5103
5140
|
function version() {
|
|
5104
5141
|
const config = loadConfig();
|
|
5105
5142
|
const name = getRepoName();
|
|
5106
5143
|
const lastInfo = getLastVersionInfo(name, config);
|
|
5107
5144
|
const lastVersion = lastInfo?.version ?? null;
|
|
5108
5145
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
5109
|
-
console.log(`${
|
|
5110
|
-
console.log(`${
|
|
5111
|
-
console.log(`${
|
|
5146
|
+
console.log(`${chalk61.bold("name:")} ${name}`);
|
|
5147
|
+
console.log(`${chalk61.bold("last:")} ${lastVersion ?? chalk61.dim("none")}`);
|
|
5148
|
+
console.log(`${chalk61.bold("next:")} ${nextVersion ?? chalk61.dim("none")}`);
|
|
5112
5149
|
}
|
|
5113
5150
|
|
|
5114
5151
|
// src/commands/registerDevlog.ts
|
|
@@ -5132,15 +5169,15 @@ function registerDevlog(program2) {
|
|
|
5132
5169
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
5133
5170
|
import { closeSync, openSync, readdirSync as readdirSync2 } from "fs";
|
|
5134
5171
|
import { join as join17 } from "path";
|
|
5135
|
-
import
|
|
5172
|
+
import chalk62 from "chalk";
|
|
5136
5173
|
|
|
5137
5174
|
// src/shared/findRepoRoot.ts
|
|
5138
|
-
import { existsSync as
|
|
5175
|
+
import { existsSync as existsSync23 } from "fs";
|
|
5139
5176
|
import path21 from "path";
|
|
5140
5177
|
function findRepoRoot(dir) {
|
|
5141
5178
|
let current = dir;
|
|
5142
5179
|
while (current !== path21.dirname(current)) {
|
|
5143
|
-
if (
|
|
5180
|
+
if (existsSync23(path21.join(current, ".git"))) {
|
|
5144
5181
|
return current;
|
|
5145
5182
|
}
|
|
5146
5183
|
current = path21.dirname(current);
|
|
@@ -5195,22 +5232,22 @@ function checkBuildLocks(startDir) {
|
|
|
5195
5232
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
5196
5233
|
if (locked) {
|
|
5197
5234
|
console.error(
|
|
5198
|
-
|
|
5235
|
+
chalk62.red("Build output locked (is VS debugging?): ") + locked
|
|
5199
5236
|
);
|
|
5200
5237
|
process.exit(1);
|
|
5201
5238
|
}
|
|
5202
5239
|
}
|
|
5203
5240
|
async function checkBuildLocksCommand() {
|
|
5204
5241
|
checkBuildLocks();
|
|
5205
|
-
console.log(
|
|
5242
|
+
console.log(chalk62.green("No build locks detected"));
|
|
5206
5243
|
}
|
|
5207
5244
|
|
|
5208
5245
|
// src/commands/dotnet/buildTree.ts
|
|
5209
|
-
import { readFileSync as
|
|
5246
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
5210
5247
|
import path22 from "path";
|
|
5211
5248
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
5212
5249
|
function getProjectRefs(csprojPath) {
|
|
5213
|
-
const content =
|
|
5250
|
+
const content = readFileSync19(csprojPath, "utf-8");
|
|
5214
5251
|
const refs = [];
|
|
5215
5252
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
5216
5253
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -5227,7 +5264,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
5227
5264
|
for (const ref of getProjectRefs(abs)) {
|
|
5228
5265
|
const childAbs = path22.resolve(dir, ref);
|
|
5229
5266
|
try {
|
|
5230
|
-
|
|
5267
|
+
readFileSync19(childAbs);
|
|
5231
5268
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
5232
5269
|
} catch {
|
|
5233
5270
|
node.children.push({
|
|
@@ -5252,7 +5289,7 @@ function collectAllDeps(node) {
|
|
|
5252
5289
|
}
|
|
5253
5290
|
|
|
5254
5291
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
5255
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
5292
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync20, statSync } from "fs";
|
|
5256
5293
|
import path23 from "path";
|
|
5257
5294
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
5258
5295
|
if (depth > maxDepth) return [];
|
|
@@ -5287,7 +5324,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
5287
5324
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
5288
5325
|
for (const sln of slnFiles) {
|
|
5289
5326
|
try {
|
|
5290
|
-
const content =
|
|
5327
|
+
const content = readFileSync20(sln, "utf-8");
|
|
5291
5328
|
if (pattern2.test(content)) {
|
|
5292
5329
|
matches.push(path23.relative(repoRoot, sln));
|
|
5293
5330
|
}
|
|
@@ -5301,30 +5338,30 @@ function escapeRegex(s) {
|
|
|
5301
5338
|
}
|
|
5302
5339
|
|
|
5303
5340
|
// src/commands/dotnet/printTree.ts
|
|
5304
|
-
import
|
|
5341
|
+
import chalk63 from "chalk";
|
|
5305
5342
|
function printNodes(nodes, prefix2) {
|
|
5306
5343
|
for (let i = 0; i < nodes.length; i++) {
|
|
5307
5344
|
const isLast = i === nodes.length - 1;
|
|
5308
5345
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
5309
5346
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
5310
5347
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
5311
|
-
const label2 = isMissing ?
|
|
5348
|
+
const label2 = isMissing ? chalk63.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
5312
5349
|
console.log(`${prefix2}${connector}${label2}`);
|
|
5313
5350
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
5314
5351
|
}
|
|
5315
5352
|
}
|
|
5316
5353
|
function printTree(tree, totalCount, solutions) {
|
|
5317
|
-
console.log(
|
|
5318
|
-
console.log(
|
|
5354
|
+
console.log(chalk63.bold("\nProject Dependency Tree"));
|
|
5355
|
+
console.log(chalk63.cyan(tree.relativePath));
|
|
5319
5356
|
printNodes(tree.children, "");
|
|
5320
|
-
console.log(
|
|
5357
|
+
console.log(chalk63.dim(`
|
|
5321
5358
|
${totalCount} projects total (including root)`));
|
|
5322
|
-
console.log(
|
|
5359
|
+
console.log(chalk63.bold("\nSolution Membership"));
|
|
5323
5360
|
if (solutions.length === 0) {
|
|
5324
|
-
console.log(
|
|
5361
|
+
console.log(chalk63.yellow(" Not found in any .sln"));
|
|
5325
5362
|
} else {
|
|
5326
5363
|
for (const sln of solutions) {
|
|
5327
|
-
console.log(` ${
|
|
5364
|
+
console.log(` ${chalk63.green(sln)}`);
|
|
5328
5365
|
}
|
|
5329
5366
|
}
|
|
5330
5367
|
console.log();
|
|
@@ -5351,18 +5388,18 @@ function printJson(tree, totalCount, solutions) {
|
|
|
5351
5388
|
}
|
|
5352
5389
|
|
|
5353
5390
|
// src/commands/dotnet/resolveCsproj.ts
|
|
5354
|
-
import { existsSync as
|
|
5391
|
+
import { existsSync as existsSync24 } from "fs";
|
|
5355
5392
|
import path24 from "path";
|
|
5356
|
-
import
|
|
5393
|
+
import chalk64 from "chalk";
|
|
5357
5394
|
function resolveCsproj(csprojPath) {
|
|
5358
5395
|
const resolved = path24.resolve(csprojPath);
|
|
5359
|
-
if (!
|
|
5360
|
-
console.error(
|
|
5396
|
+
if (!existsSync24(resolved)) {
|
|
5397
|
+
console.error(chalk64.red(`File not found: ${resolved}`));
|
|
5361
5398
|
process.exit(1);
|
|
5362
5399
|
}
|
|
5363
5400
|
const repoRoot = findRepoRoot(path24.dirname(resolved));
|
|
5364
5401
|
if (!repoRoot) {
|
|
5365
|
-
console.error(
|
|
5402
|
+
console.error(chalk64.red("Could not find git repository root"));
|
|
5366
5403
|
process.exit(1);
|
|
5367
5404
|
}
|
|
5368
5405
|
return { resolved, repoRoot };
|
|
@@ -5412,12 +5449,12 @@ function getChangedCsFiles(scope) {
|
|
|
5412
5449
|
}
|
|
5413
5450
|
|
|
5414
5451
|
// src/commands/dotnet/inSln.ts
|
|
5415
|
-
import
|
|
5452
|
+
import chalk65 from "chalk";
|
|
5416
5453
|
async function inSln(csprojPath) {
|
|
5417
5454
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
5418
5455
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
5419
5456
|
if (solutions.length === 0) {
|
|
5420
|
-
console.log(
|
|
5457
|
+
console.log(chalk65.yellow("Not found in any .sln file"));
|
|
5421
5458
|
process.exit(1);
|
|
5422
5459
|
}
|
|
5423
5460
|
for (const sln of solutions) {
|
|
@@ -5426,7 +5463,7 @@ async function inSln(csprojPath) {
|
|
|
5426
5463
|
}
|
|
5427
5464
|
|
|
5428
5465
|
// src/commands/dotnet/inspect.ts
|
|
5429
|
-
import
|
|
5466
|
+
import chalk71 from "chalk";
|
|
5430
5467
|
|
|
5431
5468
|
// src/shared/formatElapsed.ts
|
|
5432
5469
|
function formatElapsed(ms) {
|
|
@@ -5438,12 +5475,12 @@ function formatElapsed(ms) {
|
|
|
5438
5475
|
}
|
|
5439
5476
|
|
|
5440
5477
|
// src/commands/dotnet/displayIssues.ts
|
|
5441
|
-
import
|
|
5478
|
+
import chalk66 from "chalk";
|
|
5442
5479
|
var SEVERITY_COLOR = {
|
|
5443
|
-
ERROR:
|
|
5444
|
-
WARNING:
|
|
5445
|
-
SUGGESTION:
|
|
5446
|
-
HINT:
|
|
5480
|
+
ERROR: chalk66.red,
|
|
5481
|
+
WARNING: chalk66.yellow,
|
|
5482
|
+
SUGGESTION: chalk66.cyan,
|
|
5483
|
+
HINT: chalk66.dim
|
|
5447
5484
|
};
|
|
5448
5485
|
function groupByFile(issues) {
|
|
5449
5486
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -5459,15 +5496,15 @@ function groupByFile(issues) {
|
|
|
5459
5496
|
}
|
|
5460
5497
|
function displayIssues(issues) {
|
|
5461
5498
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
5462
|
-
console.log(
|
|
5499
|
+
console.log(chalk66.bold(file));
|
|
5463
5500
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
5464
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
5501
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk66.white;
|
|
5465
5502
|
console.log(
|
|
5466
|
-
` ${
|
|
5503
|
+
` ${chalk66.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
5467
5504
|
);
|
|
5468
5505
|
}
|
|
5469
5506
|
}
|
|
5470
|
-
console.log(
|
|
5507
|
+
console.log(chalk66.dim(`
|
|
5471
5508
|
${issues.length} issue(s) found`));
|
|
5472
5509
|
}
|
|
5473
5510
|
|
|
@@ -5524,14 +5561,14 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
5524
5561
|
}
|
|
5525
5562
|
|
|
5526
5563
|
// src/commands/dotnet/resolveSolution.ts
|
|
5527
|
-
import { existsSync as
|
|
5564
|
+
import { existsSync as existsSync25 } from "fs";
|
|
5528
5565
|
import path25 from "path";
|
|
5529
|
-
import
|
|
5566
|
+
import chalk68 from "chalk";
|
|
5530
5567
|
|
|
5531
5568
|
// src/commands/dotnet/findSolution.ts
|
|
5532
5569
|
import { readdirSync as readdirSync4 } from "fs";
|
|
5533
5570
|
import { dirname as dirname16, join as join18 } from "path";
|
|
5534
|
-
import
|
|
5571
|
+
import chalk67 from "chalk";
|
|
5535
5572
|
function findSlnInDir(dir) {
|
|
5536
5573
|
try {
|
|
5537
5574
|
return readdirSync4(dir).filter((f) => f.endsWith(".sln")).map((f) => join18(dir, f));
|
|
@@ -5547,17 +5584,17 @@ function findSolution() {
|
|
|
5547
5584
|
const slnFiles = findSlnInDir(current);
|
|
5548
5585
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
5549
5586
|
if (slnFiles.length > 1) {
|
|
5550
|
-
console.error(
|
|
5587
|
+
console.error(chalk67.red(`Multiple .sln files found in ${current}:`));
|
|
5551
5588
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
5552
5589
|
console.error(
|
|
5553
|
-
|
|
5590
|
+
chalk67.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
5554
5591
|
);
|
|
5555
5592
|
process.exit(1);
|
|
5556
5593
|
}
|
|
5557
5594
|
if (current === ceiling) break;
|
|
5558
5595
|
current = dirname16(current);
|
|
5559
5596
|
}
|
|
5560
|
-
console.error(
|
|
5597
|
+
console.error(chalk67.red("No .sln file found between cwd and repo root"));
|
|
5561
5598
|
process.exit(1);
|
|
5562
5599
|
}
|
|
5563
5600
|
|
|
@@ -5565,8 +5602,8 @@ function findSolution() {
|
|
|
5565
5602
|
function resolveSolution(sln) {
|
|
5566
5603
|
if (sln) {
|
|
5567
5604
|
const resolved = path25.resolve(sln);
|
|
5568
|
-
if (!
|
|
5569
|
-
console.error(
|
|
5605
|
+
if (!existsSync25(resolved)) {
|
|
5606
|
+
console.error(chalk68.red(`Solution file not found: ${resolved}`));
|
|
5570
5607
|
process.exit(1);
|
|
5571
5608
|
}
|
|
5572
5609
|
return resolved;
|
|
@@ -5605,17 +5642,17 @@ function parseInspectReport(json) {
|
|
|
5605
5642
|
|
|
5606
5643
|
// src/commands/dotnet/runInspectCode.ts
|
|
5607
5644
|
import { execSync as execSync23 } from "child_process";
|
|
5608
|
-
import { existsSync as
|
|
5645
|
+
import { existsSync as existsSync26, readFileSync as readFileSync21, unlinkSync as unlinkSync4 } from "fs";
|
|
5609
5646
|
import { tmpdir as tmpdir2 } from "os";
|
|
5610
5647
|
import path26 from "path";
|
|
5611
|
-
import
|
|
5648
|
+
import chalk69 from "chalk";
|
|
5612
5649
|
function assertJbInstalled() {
|
|
5613
5650
|
try {
|
|
5614
5651
|
execSync23("jb inspectcode --version", { stdio: "pipe" });
|
|
5615
5652
|
} catch {
|
|
5616
|
-
console.error(
|
|
5653
|
+
console.error(chalk69.red("jb is not installed. Install with:"));
|
|
5617
5654
|
console.error(
|
|
5618
|
-
|
|
5655
|
+
chalk69.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
5619
5656
|
);
|
|
5620
5657
|
process.exit(1);
|
|
5621
5658
|
}
|
|
@@ -5633,21 +5670,21 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
5633
5670
|
if (err && typeof err === "object" && "stderr" in err) {
|
|
5634
5671
|
process.stderr.write(err.stderr);
|
|
5635
5672
|
}
|
|
5636
|
-
console.error(
|
|
5673
|
+
console.error(chalk69.red("jb inspectcode failed"));
|
|
5637
5674
|
process.exit(1);
|
|
5638
5675
|
}
|
|
5639
|
-
if (!
|
|
5640
|
-
console.error(
|
|
5676
|
+
if (!existsSync26(reportPath)) {
|
|
5677
|
+
console.error(chalk69.red("Report file not generated"));
|
|
5641
5678
|
process.exit(1);
|
|
5642
5679
|
}
|
|
5643
|
-
const xml =
|
|
5680
|
+
const xml = readFileSync21(reportPath, "utf-8");
|
|
5644
5681
|
unlinkSync4(reportPath);
|
|
5645
5682
|
return xml;
|
|
5646
5683
|
}
|
|
5647
5684
|
|
|
5648
5685
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
5649
5686
|
import { execSync as execSync24 } from "child_process";
|
|
5650
|
-
import
|
|
5687
|
+
import chalk70 from "chalk";
|
|
5651
5688
|
function resolveMsbuildPath() {
|
|
5652
5689
|
const config = loadConfig();
|
|
5653
5690
|
const buildConfig = config.run?.find((r) => r.name === "build");
|
|
@@ -5658,9 +5695,9 @@ function assertMsbuildInstalled() {
|
|
|
5658
5695
|
try {
|
|
5659
5696
|
execSync24(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
5660
5697
|
} catch {
|
|
5661
|
-
console.error(
|
|
5698
|
+
console.error(chalk70.red(`msbuild not found at: ${msbuild}`));
|
|
5662
5699
|
console.error(
|
|
5663
|
-
|
|
5700
|
+
chalk70.yellow(
|
|
5664
5701
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
5665
5702
|
)
|
|
5666
5703
|
);
|
|
@@ -5707,17 +5744,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
5707
5744
|
// src/commands/dotnet/inspect.ts
|
|
5708
5745
|
function logScope(changedFiles) {
|
|
5709
5746
|
if (changedFiles === null) {
|
|
5710
|
-
console.log(
|
|
5747
|
+
console.log(chalk71.dim("Inspecting full solution..."));
|
|
5711
5748
|
} else {
|
|
5712
5749
|
console.log(
|
|
5713
|
-
|
|
5750
|
+
chalk71.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
5714
5751
|
);
|
|
5715
5752
|
}
|
|
5716
5753
|
}
|
|
5717
5754
|
function reportResults(issues, elapsed) {
|
|
5718
5755
|
if (issues.length > 0) displayIssues(issues);
|
|
5719
|
-
else console.log(
|
|
5720
|
-
console.log(
|
|
5756
|
+
else console.log(chalk71.green("No issues found"));
|
|
5757
|
+
console.log(chalk71.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
5721
5758
|
if (issues.length > 0) process.exit(1);
|
|
5722
5759
|
}
|
|
5723
5760
|
async function inspect(sln, options2) {
|
|
@@ -5728,7 +5765,7 @@ async function inspect(sln, options2) {
|
|
|
5728
5765
|
const scope = parseScope(options2.scope);
|
|
5729
5766
|
const changedFiles = getChangedCsFiles(scope);
|
|
5730
5767
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
5731
|
-
console.log(
|
|
5768
|
+
console.log(chalk71.green("No changed .cs files found"));
|
|
5732
5769
|
return;
|
|
5733
5770
|
}
|
|
5734
5771
|
logScope(changedFiles);
|
|
@@ -5754,7 +5791,7 @@ function registerDotnet(program2) {
|
|
|
5754
5791
|
}
|
|
5755
5792
|
|
|
5756
5793
|
// src/commands/jira/acceptanceCriteria.ts
|
|
5757
|
-
import
|
|
5794
|
+
import chalk73 from "chalk";
|
|
5758
5795
|
|
|
5759
5796
|
// src/commands/jira/adfToText.ts
|
|
5760
5797
|
function renderInline(node) {
|
|
@@ -5815,7 +5852,7 @@ function adfToText(doc) {
|
|
|
5815
5852
|
|
|
5816
5853
|
// src/commands/jira/fetchIssue.ts
|
|
5817
5854
|
import { execSync as execSync25 } from "child_process";
|
|
5818
|
-
import
|
|
5855
|
+
import chalk72 from "chalk";
|
|
5819
5856
|
function fetchIssue(issueKey, fields) {
|
|
5820
5857
|
let result;
|
|
5821
5858
|
try {
|
|
@@ -5828,15 +5865,15 @@ function fetchIssue(issueKey, fields) {
|
|
|
5828
5865
|
const stderr = error.stderr;
|
|
5829
5866
|
if (stderr.includes("unauthorized")) {
|
|
5830
5867
|
console.error(
|
|
5831
|
-
|
|
5868
|
+
chalk72.red("Jira authentication expired."),
|
|
5832
5869
|
"Run",
|
|
5833
|
-
|
|
5870
|
+
chalk72.cyan("assist jira auth"),
|
|
5834
5871
|
"to re-authenticate."
|
|
5835
5872
|
);
|
|
5836
5873
|
process.exit(1);
|
|
5837
5874
|
}
|
|
5838
5875
|
}
|
|
5839
|
-
console.error(
|
|
5876
|
+
console.error(chalk72.red(`Failed to fetch ${issueKey}.`));
|
|
5840
5877
|
process.exit(1);
|
|
5841
5878
|
}
|
|
5842
5879
|
return JSON.parse(result);
|
|
@@ -5850,7 +5887,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
5850
5887
|
const parsed = fetchIssue(issueKey, field);
|
|
5851
5888
|
const acValue = parsed?.fields?.[field];
|
|
5852
5889
|
if (!acValue) {
|
|
5853
|
-
console.log(
|
|
5890
|
+
console.log(chalk73.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
5854
5891
|
return;
|
|
5855
5892
|
}
|
|
5856
5893
|
if (typeof acValue === "string") {
|
|
@@ -5868,7 +5905,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
5868
5905
|
import { execSync as execSync26 } from "child_process";
|
|
5869
5906
|
|
|
5870
5907
|
// src/shared/loadJson.ts
|
|
5871
|
-
import { existsSync as
|
|
5908
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync5, readFileSync as readFileSync22, writeFileSync as writeFileSync18 } from "fs";
|
|
5872
5909
|
import { homedir as homedir6 } from "os";
|
|
5873
5910
|
import { join as join19 } from "path";
|
|
5874
5911
|
function getStoreDir() {
|
|
@@ -5879,9 +5916,9 @@ function getStorePath(filename) {
|
|
|
5879
5916
|
}
|
|
5880
5917
|
function loadJson(filename) {
|
|
5881
5918
|
const path50 = getStorePath(filename);
|
|
5882
|
-
if (
|
|
5919
|
+
if (existsSync27(path50)) {
|
|
5883
5920
|
try {
|
|
5884
|
-
return JSON.parse(
|
|
5921
|
+
return JSON.parse(readFileSync22(path50, "utf-8"));
|
|
5885
5922
|
} catch {
|
|
5886
5923
|
return {};
|
|
5887
5924
|
}
|
|
@@ -5890,7 +5927,7 @@ function loadJson(filename) {
|
|
|
5890
5927
|
}
|
|
5891
5928
|
function saveJson(filename, data) {
|
|
5892
5929
|
const dir = getStoreDir();
|
|
5893
|
-
if (!
|
|
5930
|
+
if (!existsSync27(dir)) {
|
|
5894
5931
|
mkdirSync5(dir, { recursive: true });
|
|
5895
5932
|
}
|
|
5896
5933
|
writeFileSync18(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
@@ -5945,14 +5982,14 @@ async function jiraAuth() {
|
|
|
5945
5982
|
}
|
|
5946
5983
|
|
|
5947
5984
|
// src/commands/jira/viewIssue.ts
|
|
5948
|
-
import
|
|
5985
|
+
import chalk74 from "chalk";
|
|
5949
5986
|
function viewIssue(issueKey) {
|
|
5950
5987
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
5951
5988
|
const fields = parsed?.fields;
|
|
5952
5989
|
const summary = fields?.summary;
|
|
5953
5990
|
const description = fields?.description;
|
|
5954
5991
|
if (summary) {
|
|
5955
|
-
console.log(
|
|
5992
|
+
console.log(chalk74.bold(summary));
|
|
5956
5993
|
}
|
|
5957
5994
|
if (description) {
|
|
5958
5995
|
if (summary) console.log();
|
|
@@ -5966,7 +6003,7 @@ function viewIssue(issueKey) {
|
|
|
5966
6003
|
}
|
|
5967
6004
|
if (!summary && !description) {
|
|
5968
6005
|
console.log(
|
|
5969
|
-
|
|
6006
|
+
chalk74.yellow(`No summary or description found on ${issueKey}.`)
|
|
5970
6007
|
);
|
|
5971
6008
|
}
|
|
5972
6009
|
}
|
|
@@ -5980,7 +6017,7 @@ function registerJira(program2) {
|
|
|
5980
6017
|
}
|
|
5981
6018
|
|
|
5982
6019
|
// src/commands/news/add/index.ts
|
|
5983
|
-
import
|
|
6020
|
+
import chalk75 from "chalk";
|
|
5984
6021
|
import enquirer7 from "enquirer";
|
|
5985
6022
|
async function add2(url) {
|
|
5986
6023
|
if (!url) {
|
|
@@ -6003,17 +6040,17 @@ async function add2(url) {
|
|
|
6003
6040
|
const news = config.news ?? {};
|
|
6004
6041
|
const feeds = news.feeds ?? [];
|
|
6005
6042
|
if (feeds.includes(url)) {
|
|
6006
|
-
console.log(
|
|
6043
|
+
console.log(chalk75.yellow("Feed already exists in config"));
|
|
6007
6044
|
return;
|
|
6008
6045
|
}
|
|
6009
6046
|
feeds.push(url);
|
|
6010
6047
|
config.news = { ...news, feeds };
|
|
6011
6048
|
saveGlobalConfig(config);
|
|
6012
|
-
console.log(
|
|
6049
|
+
console.log(chalk75.green(`Added feed: ${url}`));
|
|
6013
6050
|
}
|
|
6014
6051
|
|
|
6015
6052
|
// src/commands/news/web/handleRequest.ts
|
|
6016
|
-
import
|
|
6053
|
+
import chalk76 from "chalk";
|
|
6017
6054
|
|
|
6018
6055
|
// src/commands/news/web/shared.ts
|
|
6019
6056
|
import { decodeHTML } from "entities";
|
|
@@ -6149,17 +6186,17 @@ function prefetch() {
|
|
|
6149
6186
|
const config = loadConfig();
|
|
6150
6187
|
const total = config.news.feeds.length;
|
|
6151
6188
|
if (total === 0) return;
|
|
6152
|
-
process.stdout.write(
|
|
6189
|
+
process.stdout.write(chalk76.dim(`Fetching ${total} feed(s)\u2026 `));
|
|
6153
6190
|
prefetchPromise = fetchFeeds(config.news.feeds, (done2, t) => {
|
|
6154
6191
|
const width = 20;
|
|
6155
6192
|
const filled = Math.round(done2 / t * width);
|
|
6156
6193
|
const bar = `${"\u2588".repeat(filled)}${"\u2591".repeat(width - filled)}`;
|
|
6157
6194
|
process.stdout.write(
|
|
6158
|
-
`\r${
|
|
6195
|
+
`\r${chalk76.dim(`Fetching feeds ${bar} ${done2}/${t}`)}`
|
|
6159
6196
|
);
|
|
6160
6197
|
}).then((items) => {
|
|
6161
6198
|
process.stdout.write(
|
|
6162
|
-
`\r${
|
|
6199
|
+
`\r${chalk76.green(`Fetched ${items.length} items from ${total} feed(s)`)}
|
|
6163
6200
|
`
|
|
6164
6201
|
);
|
|
6165
6202
|
cachedItems = items;
|
|
@@ -6327,7 +6364,7 @@ import { tmpdir as tmpdir4 } from "os";
|
|
|
6327
6364
|
import { join as join22 } from "path";
|
|
6328
6365
|
|
|
6329
6366
|
// src/commands/prs/loadCommentsCache.ts
|
|
6330
|
-
import { existsSync as
|
|
6367
|
+
import { existsSync as existsSync28, readFileSync as readFileSync23, unlinkSync as unlinkSync6 } from "fs";
|
|
6331
6368
|
import { join as join21 } from "path";
|
|
6332
6369
|
import { parse as parse2 } from "yaml";
|
|
6333
6370
|
function getCachePath(prNumber) {
|
|
@@ -6335,15 +6372,15 @@ function getCachePath(prNumber) {
|
|
|
6335
6372
|
}
|
|
6336
6373
|
function loadCommentsCache(prNumber) {
|
|
6337
6374
|
const cachePath = getCachePath(prNumber);
|
|
6338
|
-
if (!
|
|
6375
|
+
if (!existsSync28(cachePath)) {
|
|
6339
6376
|
return null;
|
|
6340
6377
|
}
|
|
6341
|
-
const content =
|
|
6378
|
+
const content = readFileSync23(cachePath, "utf-8");
|
|
6342
6379
|
return parse2(content);
|
|
6343
6380
|
}
|
|
6344
6381
|
function deleteCommentsCache(prNumber) {
|
|
6345
6382
|
const cachePath = getCachePath(prNumber);
|
|
6346
|
-
if (
|
|
6383
|
+
if (existsSync28(cachePath)) {
|
|
6347
6384
|
unlinkSync6(cachePath);
|
|
6348
6385
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
6349
6386
|
}
|
|
@@ -6440,7 +6477,7 @@ function fixed(commentId, sha) {
|
|
|
6440
6477
|
}
|
|
6441
6478
|
|
|
6442
6479
|
// src/commands/prs/listComments/index.ts
|
|
6443
|
-
import { existsSync as
|
|
6480
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync6, writeFileSync as writeFileSync22 } from "fs";
|
|
6444
6481
|
import { join as join24 } from "path";
|
|
6445
6482
|
import { stringify } from "yaml";
|
|
6446
6483
|
|
|
@@ -6520,20 +6557,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
6520
6557
|
}
|
|
6521
6558
|
|
|
6522
6559
|
// src/commands/prs/listComments/printComments.ts
|
|
6523
|
-
import
|
|
6560
|
+
import chalk77 from "chalk";
|
|
6524
6561
|
function formatForHuman(comment3) {
|
|
6525
6562
|
if (comment3.type === "review") {
|
|
6526
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
6563
|
+
const stateColor = comment3.state === "APPROVED" ? chalk77.green : comment3.state === "CHANGES_REQUESTED" ? chalk77.red : chalk77.yellow;
|
|
6527
6564
|
return [
|
|
6528
|
-
`${
|
|
6565
|
+
`${chalk77.cyan("Review")} by ${chalk77.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
6529
6566
|
comment3.body,
|
|
6530
6567
|
""
|
|
6531
6568
|
].join("\n");
|
|
6532
6569
|
}
|
|
6533
6570
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
6534
6571
|
return [
|
|
6535
|
-
`${
|
|
6536
|
-
|
|
6572
|
+
`${chalk77.cyan("Line comment")} by ${chalk77.bold(comment3.user)} on ${chalk77.dim(`${comment3.path}${location}`)}`,
|
|
6573
|
+
chalk77.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
6537
6574
|
comment3.body,
|
|
6538
6575
|
""
|
|
6539
6576
|
].join("\n");
|
|
@@ -6566,7 +6603,7 @@ function printComments2(result) {
|
|
|
6566
6603
|
// src/commands/prs/listComments/index.ts
|
|
6567
6604
|
function writeCommentsCache(prNumber, comments2) {
|
|
6568
6605
|
const assistDir = join24(process.cwd(), ".assist");
|
|
6569
|
-
if (!
|
|
6606
|
+
if (!existsSync29(assistDir)) {
|
|
6570
6607
|
mkdirSync6(assistDir, { recursive: true });
|
|
6571
6608
|
}
|
|
6572
6609
|
const cacheData = {
|
|
@@ -6623,13 +6660,13 @@ import { execSync as execSync32 } from "child_process";
|
|
|
6623
6660
|
import enquirer8 from "enquirer";
|
|
6624
6661
|
|
|
6625
6662
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
6626
|
-
import
|
|
6663
|
+
import chalk78 from "chalk";
|
|
6627
6664
|
var STATUS_MAP = {
|
|
6628
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
6629
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
6665
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk78.magenta("merged"), date: pr.mergedAt } : null,
|
|
6666
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk78.red("closed"), date: pr.closedAt } : null
|
|
6630
6667
|
};
|
|
6631
6668
|
function defaultStatus(pr) {
|
|
6632
|
-
return { label:
|
|
6669
|
+
return { label: chalk78.green("opened"), date: pr.createdAt };
|
|
6633
6670
|
}
|
|
6634
6671
|
function getStatus2(pr) {
|
|
6635
6672
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -6638,11 +6675,11 @@ function formatDate(dateStr) {
|
|
|
6638
6675
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
6639
6676
|
}
|
|
6640
6677
|
function formatPrHeader(pr, status2) {
|
|
6641
|
-
return `${
|
|
6678
|
+
return `${chalk78.cyan(`#${pr.number}`)} ${pr.title} ${chalk78.dim(`(${pr.author.login},`)} ${status2.label} ${chalk78.dim(`${formatDate(status2.date)})`)}`;
|
|
6642
6679
|
}
|
|
6643
6680
|
function logPrDetails(pr) {
|
|
6644
6681
|
console.log(
|
|
6645
|
-
|
|
6682
|
+
chalk78.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
6646
6683
|
);
|
|
6647
6684
|
console.log();
|
|
6648
6685
|
}
|
|
@@ -6808,10 +6845,10 @@ function registerPrs(program2) {
|
|
|
6808
6845
|
}
|
|
6809
6846
|
|
|
6810
6847
|
// src/commands/ravendb/ravendbAuth.ts
|
|
6811
|
-
import
|
|
6848
|
+
import chalk84 from "chalk";
|
|
6812
6849
|
|
|
6813
6850
|
// src/shared/createConnectionAuth.ts
|
|
6814
|
-
import
|
|
6851
|
+
import chalk79 from "chalk";
|
|
6815
6852
|
function listConnections(connections, format2) {
|
|
6816
6853
|
if (connections.length === 0) {
|
|
6817
6854
|
console.log("No connections configured.");
|
|
@@ -6824,7 +6861,7 @@ function listConnections(connections, format2) {
|
|
|
6824
6861
|
function removeConnection(connections, name, save) {
|
|
6825
6862
|
const filtered = connections.filter((c) => c.name !== name);
|
|
6826
6863
|
if (filtered.length === connections.length) {
|
|
6827
|
-
console.error(
|
|
6864
|
+
console.error(chalk79.red(`Connection "${name}" not found.`));
|
|
6828
6865
|
process.exit(1);
|
|
6829
6866
|
}
|
|
6830
6867
|
save(filtered);
|
|
@@ -6870,15 +6907,15 @@ function saveConnections(connections) {
|
|
|
6870
6907
|
}
|
|
6871
6908
|
|
|
6872
6909
|
// src/commands/ravendb/promptConnection.ts
|
|
6873
|
-
import
|
|
6910
|
+
import chalk82 from "chalk";
|
|
6874
6911
|
|
|
6875
6912
|
// src/commands/ravendb/selectOpSecret.ts
|
|
6876
|
-
import
|
|
6913
|
+
import chalk81 from "chalk";
|
|
6877
6914
|
import Enquirer2 from "enquirer";
|
|
6878
6915
|
|
|
6879
6916
|
// src/commands/ravendb/searchItems.ts
|
|
6880
6917
|
import { execSync as execSync34 } from "child_process";
|
|
6881
|
-
import
|
|
6918
|
+
import chalk80 from "chalk";
|
|
6882
6919
|
function opExec(args) {
|
|
6883
6920
|
return execSync34(`op ${args}`, {
|
|
6884
6921
|
encoding: "utf-8",
|
|
@@ -6891,7 +6928,7 @@ function searchItems(search) {
|
|
|
6891
6928
|
items = JSON.parse(opExec("item list --format=json"));
|
|
6892
6929
|
} catch {
|
|
6893
6930
|
console.error(
|
|
6894
|
-
|
|
6931
|
+
chalk80.red(
|
|
6895
6932
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
6896
6933
|
)
|
|
6897
6934
|
);
|
|
@@ -6905,7 +6942,7 @@ function getItemFields(itemId) {
|
|
|
6905
6942
|
const item = JSON.parse(opExec(`item get "${itemId}" --format=json`));
|
|
6906
6943
|
return item.fields.filter((f) => f.reference && f.label);
|
|
6907
6944
|
} catch {
|
|
6908
|
-
console.error(
|
|
6945
|
+
console.error(chalk80.red("Failed to get item details from 1Password."));
|
|
6909
6946
|
process.exit(1);
|
|
6910
6947
|
}
|
|
6911
6948
|
}
|
|
@@ -6924,7 +6961,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
6924
6961
|
}).run();
|
|
6925
6962
|
const items = searchItems(search);
|
|
6926
6963
|
if (items.length === 0) {
|
|
6927
|
-
console.error(
|
|
6964
|
+
console.error(chalk81.red(`No items found matching "${search}".`));
|
|
6928
6965
|
process.exit(1);
|
|
6929
6966
|
}
|
|
6930
6967
|
const itemId = await selectOne(
|
|
@@ -6933,7 +6970,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
6933
6970
|
);
|
|
6934
6971
|
const fields = getItemFields(itemId);
|
|
6935
6972
|
if (fields.length === 0) {
|
|
6936
|
-
console.error(
|
|
6973
|
+
console.error(chalk81.red("No fields with references found on this item."));
|
|
6937
6974
|
process.exit(1);
|
|
6938
6975
|
}
|
|
6939
6976
|
const ref = await selectOne(
|
|
@@ -6947,7 +6984,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
6947
6984
|
async function promptConnection(existingNames) {
|
|
6948
6985
|
const name = await promptInput("name", "Connection name:");
|
|
6949
6986
|
if (existingNames.includes(name)) {
|
|
6950
|
-
console.error(
|
|
6987
|
+
console.error(chalk82.red(`Connection "${name}" already exists.`));
|
|
6951
6988
|
process.exit(1);
|
|
6952
6989
|
}
|
|
6953
6990
|
const url = await promptInput(
|
|
@@ -6956,22 +6993,22 @@ async function promptConnection(existingNames) {
|
|
|
6956
6993
|
);
|
|
6957
6994
|
const database = await promptInput("database", "Database name:");
|
|
6958
6995
|
if (!name || !url || !database) {
|
|
6959
|
-
console.error(
|
|
6996
|
+
console.error(chalk82.red("All fields are required."));
|
|
6960
6997
|
process.exit(1);
|
|
6961
6998
|
}
|
|
6962
6999
|
const apiKeyRef = await selectOpSecret();
|
|
6963
|
-
console.log(
|
|
7000
|
+
console.log(chalk82.dim(`Using: ${apiKeyRef}`));
|
|
6964
7001
|
return { name, url, database, apiKeyRef };
|
|
6965
7002
|
}
|
|
6966
7003
|
|
|
6967
7004
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
6968
|
-
import
|
|
7005
|
+
import chalk83 from "chalk";
|
|
6969
7006
|
function ravendbSetConnection(name) {
|
|
6970
7007
|
const raw = loadGlobalConfigRaw();
|
|
6971
7008
|
const ravendb = raw.ravendb ?? {};
|
|
6972
7009
|
const connections = ravendb.connections ?? [];
|
|
6973
7010
|
if (!connections.some((c) => c.name === name)) {
|
|
6974
|
-
console.error(
|
|
7011
|
+
console.error(chalk83.red(`Connection "${name}" not found.`));
|
|
6975
7012
|
console.error(
|
|
6976
7013
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
6977
7014
|
);
|
|
@@ -6987,16 +7024,16 @@ function ravendbSetConnection(name) {
|
|
|
6987
7024
|
var ravendbAuth = createConnectionAuth({
|
|
6988
7025
|
load: loadConnections,
|
|
6989
7026
|
save: saveConnections,
|
|
6990
|
-
format: (c) => `${
|
|
7027
|
+
format: (c) => `${chalk84.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
6991
7028
|
promptNew: promptConnection,
|
|
6992
7029
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
6993
7030
|
});
|
|
6994
7031
|
|
|
6995
7032
|
// src/commands/ravendb/ravendbCollections.ts
|
|
6996
|
-
import
|
|
7033
|
+
import chalk88 from "chalk";
|
|
6997
7034
|
|
|
6998
7035
|
// src/commands/ravendb/ravenFetch.ts
|
|
6999
|
-
import
|
|
7036
|
+
import chalk86 from "chalk";
|
|
7000
7037
|
|
|
7001
7038
|
// src/commands/ravendb/getAccessToken.ts
|
|
7002
7039
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -7033,10 +7070,10 @@ ${errorText}`
|
|
|
7033
7070
|
|
|
7034
7071
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
7035
7072
|
import { execSync as execSync35 } from "child_process";
|
|
7036
|
-
import
|
|
7073
|
+
import chalk85 from "chalk";
|
|
7037
7074
|
function resolveOpSecret(reference) {
|
|
7038
7075
|
if (!reference.startsWith("op://")) {
|
|
7039
|
-
console.error(
|
|
7076
|
+
console.error(chalk85.red(`Invalid secret reference: must start with op://`));
|
|
7040
7077
|
process.exit(1);
|
|
7041
7078
|
}
|
|
7042
7079
|
try {
|
|
@@ -7046,7 +7083,7 @@ function resolveOpSecret(reference) {
|
|
|
7046
7083
|
}).trim();
|
|
7047
7084
|
} catch {
|
|
7048
7085
|
console.error(
|
|
7049
|
-
|
|
7086
|
+
chalk85.red(
|
|
7050
7087
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
7051
7088
|
)
|
|
7052
7089
|
);
|
|
@@ -7073,7 +7110,7 @@ async function ravenFetch(connection, path50) {
|
|
|
7073
7110
|
if (!response.ok) {
|
|
7074
7111
|
const body = await response.text();
|
|
7075
7112
|
console.error(
|
|
7076
|
-
|
|
7113
|
+
chalk86.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
7077
7114
|
);
|
|
7078
7115
|
console.error(body.substring(0, 500));
|
|
7079
7116
|
process.exit(1);
|
|
@@ -7082,7 +7119,7 @@ async function ravenFetch(connection, path50) {
|
|
|
7082
7119
|
}
|
|
7083
7120
|
|
|
7084
7121
|
// src/commands/ravendb/resolveConnection.ts
|
|
7085
|
-
import
|
|
7122
|
+
import chalk87 from "chalk";
|
|
7086
7123
|
function loadRavendb() {
|
|
7087
7124
|
const raw = loadGlobalConfigRaw();
|
|
7088
7125
|
const ravendb = raw.ravendb;
|
|
@@ -7096,7 +7133,7 @@ function resolveConnection(name) {
|
|
|
7096
7133
|
const connectionName = name ?? defaultConnection;
|
|
7097
7134
|
if (!connectionName) {
|
|
7098
7135
|
console.error(
|
|
7099
|
-
|
|
7136
|
+
chalk87.red(
|
|
7100
7137
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
7101
7138
|
)
|
|
7102
7139
|
);
|
|
@@ -7104,7 +7141,7 @@ function resolveConnection(name) {
|
|
|
7104
7141
|
}
|
|
7105
7142
|
const connection = connections.find((c) => c.name === connectionName);
|
|
7106
7143
|
if (!connection) {
|
|
7107
|
-
console.error(
|
|
7144
|
+
console.error(chalk87.red(`Connection "${connectionName}" not found.`));
|
|
7108
7145
|
console.error(
|
|
7109
7146
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
7110
7147
|
);
|
|
@@ -7135,15 +7172,15 @@ async function ravendbCollections(connectionName) {
|
|
|
7135
7172
|
return;
|
|
7136
7173
|
}
|
|
7137
7174
|
for (const c of collections) {
|
|
7138
|
-
console.log(`${
|
|
7175
|
+
console.log(`${chalk88.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
7139
7176
|
}
|
|
7140
7177
|
}
|
|
7141
7178
|
|
|
7142
7179
|
// src/commands/ravendb/ravendbQuery.ts
|
|
7143
|
-
import
|
|
7180
|
+
import chalk90 from "chalk";
|
|
7144
7181
|
|
|
7145
7182
|
// src/commands/ravendb/fetchAllPages.ts
|
|
7146
|
-
import
|
|
7183
|
+
import chalk89 from "chalk";
|
|
7147
7184
|
|
|
7148
7185
|
// src/commands/ravendb/buildQueryPath.ts
|
|
7149
7186
|
function buildQueryPath(opts) {
|
|
@@ -7181,7 +7218,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
7181
7218
|
allResults.push(...results);
|
|
7182
7219
|
start3 += results.length;
|
|
7183
7220
|
process.stderr.write(
|
|
7184
|
-
`\r${
|
|
7221
|
+
`\r${chalk89.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
7185
7222
|
);
|
|
7186
7223
|
if (start3 >= totalResults) break;
|
|
7187
7224
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -7196,7 +7233,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
7196
7233
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
7197
7234
|
const resolved = resolveArgs(connectionName, collection);
|
|
7198
7235
|
if (!resolved.collection && !options2.query) {
|
|
7199
|
-
console.error(
|
|
7236
|
+
console.error(chalk90.red("Provide a collection name or --query filter."));
|
|
7200
7237
|
process.exit(1);
|
|
7201
7238
|
}
|
|
7202
7239
|
const { collection: col } = resolved;
|
|
@@ -7234,7 +7271,7 @@ import { spawn as spawn4 } from "child_process";
|
|
|
7234
7271
|
import * as path27 from "path";
|
|
7235
7272
|
|
|
7236
7273
|
// src/commands/refactor/logViolations.ts
|
|
7237
|
-
import
|
|
7274
|
+
import chalk91 from "chalk";
|
|
7238
7275
|
var DEFAULT_MAX_LINES = 100;
|
|
7239
7276
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
7240
7277
|
if (violations.length === 0) {
|
|
@@ -7243,43 +7280,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
7243
7280
|
}
|
|
7244
7281
|
return;
|
|
7245
7282
|
}
|
|
7246
|
-
console.error(
|
|
7283
|
+
console.error(chalk91.red(`
|
|
7247
7284
|
Refactor check failed:
|
|
7248
7285
|
`));
|
|
7249
|
-
console.error(
|
|
7286
|
+
console.error(chalk91.red(` The following files exceed ${maxLines} lines:
|
|
7250
7287
|
`));
|
|
7251
7288
|
for (const violation of violations) {
|
|
7252
|
-
console.error(
|
|
7289
|
+
console.error(chalk91.red(` ${violation.file} (${violation.lines} lines)`));
|
|
7253
7290
|
}
|
|
7254
7291
|
console.error(
|
|
7255
|
-
|
|
7292
|
+
chalk91.yellow(
|
|
7256
7293
|
`
|
|
7257
7294
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
7258
7295
|
way to refactor it, ignore it with:
|
|
7259
7296
|
`
|
|
7260
7297
|
)
|
|
7261
7298
|
);
|
|
7262
|
-
console.error(
|
|
7299
|
+
console.error(chalk91.gray(` assist refactor ignore <file>
|
|
7263
7300
|
`));
|
|
7264
7301
|
if (process.env.CLAUDECODE) {
|
|
7265
|
-
console.error(
|
|
7302
|
+
console.error(chalk91.cyan(`
|
|
7266
7303
|
## Extracting Code to New Files
|
|
7267
7304
|
`));
|
|
7268
7305
|
console.error(
|
|
7269
|
-
|
|
7306
|
+
chalk91.cyan(
|
|
7270
7307
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
7271
7308
|
`
|
|
7272
7309
|
)
|
|
7273
7310
|
);
|
|
7274
7311
|
console.error(
|
|
7275
|
-
|
|
7312
|
+
chalk91.cyan(
|
|
7276
7313
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
7277
7314
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
7278
7315
|
`
|
|
7279
7316
|
)
|
|
7280
7317
|
);
|
|
7281
7318
|
console.error(
|
|
7282
|
-
|
|
7319
|
+
chalk91.cyan(
|
|
7283
7320
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
7284
7321
|
domains, move it to a common/shared folder.
|
|
7285
7322
|
`
|
|
@@ -7435,7 +7472,7 @@ async function check(pattern2, options2) {
|
|
|
7435
7472
|
|
|
7436
7473
|
// src/commands/refactor/extract/index.ts
|
|
7437
7474
|
import path33 from "path";
|
|
7438
|
-
import
|
|
7475
|
+
import chalk94 from "chalk";
|
|
7439
7476
|
|
|
7440
7477
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
7441
7478
|
import { SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
@@ -7961,23 +7998,23 @@ function buildPlan(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
7961
7998
|
|
|
7962
7999
|
// src/commands/refactor/extract/displayPlan.ts
|
|
7963
8000
|
import path31 from "path";
|
|
7964
|
-
import
|
|
8001
|
+
import chalk92 from "chalk";
|
|
7965
8002
|
function section(title) {
|
|
7966
8003
|
return `
|
|
7967
|
-
${
|
|
8004
|
+
${chalk92.cyan(title)}`;
|
|
7968
8005
|
}
|
|
7969
8006
|
function displayImporters(plan2, cwd) {
|
|
7970
8007
|
if (plan2.importersToUpdate.length === 0) return;
|
|
7971
8008
|
console.log(section("Update importers:"));
|
|
7972
8009
|
for (const imp of plan2.importersToUpdate) {
|
|
7973
8010
|
const rel = path31.relative(cwd, imp.file.getFilePath());
|
|
7974
|
-
console.log(` ${
|
|
8011
|
+
console.log(` ${chalk92.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
7975
8012
|
}
|
|
7976
8013
|
}
|
|
7977
8014
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
7978
|
-
console.log(
|
|
8015
|
+
console.log(chalk92.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
7979
8016
|
`));
|
|
7980
|
-
console.log(` ${
|
|
8017
|
+
console.log(` ${chalk92.cyan("Functions to move:")}`);
|
|
7981
8018
|
for (const name of plan2.extractedNames) {
|
|
7982
8019
|
console.log(` ${name}`);
|
|
7983
8020
|
}
|
|
@@ -8012,7 +8049,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
8012
8049
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
8013
8050
|
import fs17 from "fs";
|
|
8014
8051
|
import path32 from "path";
|
|
8015
|
-
import
|
|
8052
|
+
import chalk93 from "chalk";
|
|
8016
8053
|
import { Project as Project2 } from "ts-morph";
|
|
8017
8054
|
function findTsConfig(sourcePath) {
|
|
8018
8055
|
const rootConfig = path32.resolve("tsconfig.json");
|
|
@@ -8043,7 +8080,7 @@ function loadProjectFile(file) {
|
|
|
8043
8080
|
});
|
|
8044
8081
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
8045
8082
|
if (!sourceFile) {
|
|
8046
|
-
console.log(
|
|
8083
|
+
console.log(chalk93.red(`File not found in project: ${file}`));
|
|
8047
8084
|
process.exit(1);
|
|
8048
8085
|
}
|
|
8049
8086
|
return { project, sourceFile };
|
|
@@ -8066,19 +8103,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
8066
8103
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
8067
8104
|
if (options2.apply) {
|
|
8068
8105
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
8069
|
-
console.log(
|
|
8106
|
+
console.log(chalk94.green("\nExtraction complete"));
|
|
8070
8107
|
} else {
|
|
8071
|
-
console.log(
|
|
8108
|
+
console.log(chalk94.dim("\nDry run. Use --apply to execute."));
|
|
8072
8109
|
}
|
|
8073
8110
|
}
|
|
8074
8111
|
|
|
8075
8112
|
// src/commands/refactor/ignore.ts
|
|
8076
8113
|
import fs18 from "fs";
|
|
8077
|
-
import
|
|
8114
|
+
import chalk95 from "chalk";
|
|
8078
8115
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
8079
8116
|
function ignore(file) {
|
|
8080
8117
|
if (!fs18.existsSync(file)) {
|
|
8081
|
-
console.error(
|
|
8118
|
+
console.error(chalk95.red(`Error: File does not exist: ${file}`));
|
|
8082
8119
|
process.exit(1);
|
|
8083
8120
|
}
|
|
8084
8121
|
const content = fs18.readFileSync(file, "utf-8");
|
|
@@ -8094,7 +8131,7 @@ function ignore(file) {
|
|
|
8094
8131
|
fs18.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
8095
8132
|
}
|
|
8096
8133
|
console.log(
|
|
8097
|
-
|
|
8134
|
+
chalk95.green(
|
|
8098
8135
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
8099
8136
|
)
|
|
8100
8137
|
);
|
|
@@ -8102,26 +8139,26 @@ function ignore(file) {
|
|
|
8102
8139
|
|
|
8103
8140
|
// src/commands/refactor/rename/index.ts
|
|
8104
8141
|
import path34 from "path";
|
|
8105
|
-
import
|
|
8142
|
+
import chalk96 from "chalk";
|
|
8106
8143
|
async function rename(source, destination, options2 = {}) {
|
|
8107
8144
|
const destPath = path34.resolve(destination);
|
|
8108
8145
|
const cwd = process.cwd();
|
|
8109
8146
|
const relSource = path34.relative(cwd, path34.resolve(source));
|
|
8110
8147
|
const relDest = path34.relative(cwd, destPath);
|
|
8111
8148
|
const { project, sourceFile } = loadProjectFile(source);
|
|
8112
|
-
console.log(
|
|
8149
|
+
console.log(chalk96.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
8113
8150
|
if (options2.apply) {
|
|
8114
8151
|
sourceFile.move(destPath);
|
|
8115
8152
|
await project.save();
|
|
8116
|
-
console.log(
|
|
8153
|
+
console.log(chalk96.green("Done"));
|
|
8117
8154
|
} else {
|
|
8118
|
-
console.log(
|
|
8155
|
+
console.log(chalk96.dim("Dry run. Use --apply to execute."));
|
|
8119
8156
|
}
|
|
8120
8157
|
}
|
|
8121
8158
|
|
|
8122
8159
|
// src/commands/refactor/renameSymbol/index.ts
|
|
8123
8160
|
import path36 from "path";
|
|
8124
|
-
import
|
|
8161
|
+
import chalk97 from "chalk";
|
|
8125
8162
|
import { Project as Project3 } from "ts-morph";
|
|
8126
8163
|
|
|
8127
8164
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
@@ -8170,38 +8207,38 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
8170
8207
|
const project = new Project3({ tsConfigFilePath: tsConfigPath });
|
|
8171
8208
|
const sourceFile = project.getSourceFile(filePath);
|
|
8172
8209
|
if (!sourceFile) {
|
|
8173
|
-
console.log(
|
|
8210
|
+
console.log(chalk97.red(`File not found in project: ${file}`));
|
|
8174
8211
|
process.exit(1);
|
|
8175
8212
|
}
|
|
8176
8213
|
const symbol = findSymbol(sourceFile, oldName);
|
|
8177
8214
|
if (!symbol) {
|
|
8178
|
-
console.log(
|
|
8215
|
+
console.log(chalk97.red(`Symbol "${oldName}" not found in ${file}`));
|
|
8179
8216
|
process.exit(1);
|
|
8180
8217
|
}
|
|
8181
8218
|
const grouped = groupReferences(symbol, cwd);
|
|
8182
8219
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
8183
8220
|
console.log(
|
|
8184
|
-
|
|
8221
|
+
chalk97.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
8185
8222
|
`)
|
|
8186
8223
|
);
|
|
8187
8224
|
for (const [refFile, lines] of grouped) {
|
|
8188
8225
|
console.log(
|
|
8189
|
-
` ${
|
|
8226
|
+
` ${chalk97.dim(refFile)}: lines ${chalk97.cyan(lines.join(", "))}`
|
|
8190
8227
|
);
|
|
8191
8228
|
}
|
|
8192
8229
|
if (options2.apply) {
|
|
8193
8230
|
symbol.rename(newName);
|
|
8194
8231
|
await project.save();
|
|
8195
|
-
console.log(
|
|
8232
|
+
console.log(chalk97.green(`
|
|
8196
8233
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
8197
8234
|
} else {
|
|
8198
|
-
console.log(
|
|
8235
|
+
console.log(chalk97.dim("\nDry run. Use --apply to execute."));
|
|
8199
8236
|
}
|
|
8200
8237
|
}
|
|
8201
8238
|
|
|
8202
8239
|
// src/commands/refactor/restructure/index.ts
|
|
8203
8240
|
import path45 from "path";
|
|
8204
|
-
import
|
|
8241
|
+
import chalk100 from "chalk";
|
|
8205
8242
|
|
|
8206
8243
|
// src/commands/refactor/restructure/buildImportGraph/index.ts
|
|
8207
8244
|
import path37 from "path";
|
|
@@ -8444,50 +8481,50 @@ function computeRewrites(moves, edges, allProjectFiles) {
|
|
|
8444
8481
|
|
|
8445
8482
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
8446
8483
|
import path41 from "path";
|
|
8447
|
-
import
|
|
8484
|
+
import chalk98 from "chalk";
|
|
8448
8485
|
function relPath(filePath) {
|
|
8449
8486
|
return path41.relative(process.cwd(), filePath);
|
|
8450
8487
|
}
|
|
8451
8488
|
function displayMoves(plan2) {
|
|
8452
8489
|
if (plan2.moves.length === 0) return;
|
|
8453
|
-
console.log(
|
|
8490
|
+
console.log(chalk98.bold("\nFile moves:"));
|
|
8454
8491
|
for (const move of plan2.moves) {
|
|
8455
8492
|
console.log(
|
|
8456
|
-
` ${
|
|
8493
|
+
` ${chalk98.red(relPath(move.from))} \u2192 ${chalk98.green(relPath(move.to))}`
|
|
8457
8494
|
);
|
|
8458
|
-
console.log(
|
|
8495
|
+
console.log(chalk98.dim(` ${move.reason}`));
|
|
8459
8496
|
}
|
|
8460
8497
|
}
|
|
8461
8498
|
function displayRewrites(rewrites) {
|
|
8462
8499
|
if (rewrites.length === 0) return;
|
|
8463
8500
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
8464
|
-
console.log(
|
|
8501
|
+
console.log(chalk98.bold(`
|
|
8465
8502
|
Import rewrites (${affectedFiles.size} files):`));
|
|
8466
8503
|
for (const file of affectedFiles) {
|
|
8467
|
-
console.log(` ${
|
|
8504
|
+
console.log(` ${chalk98.cyan(relPath(file))}:`);
|
|
8468
8505
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
8469
8506
|
(r) => r.file === file
|
|
8470
8507
|
)) {
|
|
8471
8508
|
console.log(
|
|
8472
|
-
` ${
|
|
8509
|
+
` ${chalk98.red(`"${oldSpecifier}"`)} \u2192 ${chalk98.green(`"${newSpecifier}"`)}`
|
|
8473
8510
|
);
|
|
8474
8511
|
}
|
|
8475
8512
|
}
|
|
8476
8513
|
}
|
|
8477
8514
|
function displayPlan2(plan2) {
|
|
8478
8515
|
if (plan2.warnings.length > 0) {
|
|
8479
|
-
console.log(
|
|
8480
|
-
for (const w of plan2.warnings) console.log(
|
|
8516
|
+
console.log(chalk98.yellow("\nWarnings:"));
|
|
8517
|
+
for (const w of plan2.warnings) console.log(chalk98.yellow(` ${w}`));
|
|
8481
8518
|
}
|
|
8482
8519
|
if (plan2.newDirectories.length > 0) {
|
|
8483
|
-
console.log(
|
|
8520
|
+
console.log(chalk98.bold("\nNew directories:"));
|
|
8484
8521
|
for (const dir of plan2.newDirectories)
|
|
8485
|
-
console.log(
|
|
8522
|
+
console.log(chalk98.green(` ${dir}/`));
|
|
8486
8523
|
}
|
|
8487
8524
|
displayMoves(plan2);
|
|
8488
8525
|
displayRewrites(plan2.rewrites);
|
|
8489
8526
|
console.log(
|
|
8490
|
-
|
|
8527
|
+
chalk98.dim(
|
|
8491
8528
|
`
|
|
8492
8529
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
8493
8530
|
)
|
|
@@ -8497,18 +8534,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
8497
8534
|
// src/commands/refactor/restructure/executePlan.ts
|
|
8498
8535
|
import fs20 from "fs";
|
|
8499
8536
|
import path42 from "path";
|
|
8500
|
-
import
|
|
8537
|
+
import chalk99 from "chalk";
|
|
8501
8538
|
function executePlan(plan2) {
|
|
8502
8539
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
8503
8540
|
for (const [file, content] of updatedContents) {
|
|
8504
8541
|
fs20.writeFileSync(file, content, "utf-8");
|
|
8505
8542
|
console.log(
|
|
8506
|
-
|
|
8543
|
+
chalk99.cyan(` Rewrote imports in ${path42.relative(process.cwd(), file)}`)
|
|
8507
8544
|
);
|
|
8508
8545
|
}
|
|
8509
8546
|
for (const dir of plan2.newDirectories) {
|
|
8510
8547
|
fs20.mkdirSync(dir, { recursive: true });
|
|
8511
|
-
console.log(
|
|
8548
|
+
console.log(chalk99.green(` Created ${path42.relative(process.cwd(), dir)}/`));
|
|
8512
8549
|
}
|
|
8513
8550
|
for (const move of plan2.moves) {
|
|
8514
8551
|
const targetDir = path42.dirname(move.to);
|
|
@@ -8517,7 +8554,7 @@ function executePlan(plan2) {
|
|
|
8517
8554
|
}
|
|
8518
8555
|
fs20.renameSync(move.from, move.to);
|
|
8519
8556
|
console.log(
|
|
8520
|
-
|
|
8557
|
+
chalk99.white(
|
|
8521
8558
|
` Moved ${path42.relative(process.cwd(), move.from)} \u2192 ${path42.relative(process.cwd(), move.to)}`
|
|
8522
8559
|
)
|
|
8523
8560
|
);
|
|
@@ -8532,7 +8569,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
8532
8569
|
if (entries.length === 0) {
|
|
8533
8570
|
fs20.rmdirSync(dir);
|
|
8534
8571
|
console.log(
|
|
8535
|
-
|
|
8572
|
+
chalk99.dim(
|
|
8536
8573
|
` Removed empty directory ${path42.relative(process.cwd(), dir)}`
|
|
8537
8574
|
)
|
|
8538
8575
|
);
|
|
@@ -8665,22 +8702,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
8665
8702
|
const targetPattern = pattern2 ?? "src";
|
|
8666
8703
|
const files = findSourceFiles2(targetPattern);
|
|
8667
8704
|
if (files.length === 0) {
|
|
8668
|
-
console.log(
|
|
8705
|
+
console.log(chalk100.yellow("No files found matching pattern"));
|
|
8669
8706
|
return;
|
|
8670
8707
|
}
|
|
8671
8708
|
const tsConfigPath = path45.resolve("tsconfig.json");
|
|
8672
8709
|
const plan2 = buildPlan2(files, tsConfigPath);
|
|
8673
8710
|
if (plan2.moves.length === 0) {
|
|
8674
|
-
console.log(
|
|
8711
|
+
console.log(chalk100.green("No restructuring needed"));
|
|
8675
8712
|
return;
|
|
8676
8713
|
}
|
|
8677
8714
|
displayPlan2(plan2);
|
|
8678
8715
|
if (options2.apply) {
|
|
8679
|
-
console.log(
|
|
8716
|
+
console.log(chalk100.bold("\nApplying changes..."));
|
|
8680
8717
|
executePlan(plan2);
|
|
8681
|
-
console.log(
|
|
8718
|
+
console.log(chalk100.green("\nRestructuring complete"));
|
|
8682
8719
|
} else {
|
|
8683
|
-
console.log(
|
|
8720
|
+
console.log(chalk100.dim("\nDry run. Use --apply to execute."));
|
|
8684
8721
|
}
|
|
8685
8722
|
}
|
|
8686
8723
|
|
|
@@ -8720,7 +8757,7 @@ function registerRefactor(program2) {
|
|
|
8720
8757
|
}
|
|
8721
8758
|
|
|
8722
8759
|
// src/commands/seq/seqAuth.ts
|
|
8723
|
-
import
|
|
8760
|
+
import chalk102 from "chalk";
|
|
8724
8761
|
|
|
8725
8762
|
// src/commands/seq/loadConnections.ts
|
|
8726
8763
|
function loadConnections2() {
|
|
@@ -8749,11 +8786,11 @@ function setDefaultConnection(name) {
|
|
|
8749
8786
|
}
|
|
8750
8787
|
|
|
8751
8788
|
// src/commands/seq/promptConnection.ts
|
|
8752
|
-
import
|
|
8789
|
+
import chalk101 from "chalk";
|
|
8753
8790
|
async function promptConnection2(existingNames) {
|
|
8754
8791
|
const name = await promptInput("name", "Connection name:", "default");
|
|
8755
8792
|
if (existingNames.includes(name)) {
|
|
8756
|
-
console.error(
|
|
8793
|
+
console.error(chalk101.red(`Connection "${name}" already exists.`));
|
|
8757
8794
|
process.exit(1);
|
|
8758
8795
|
}
|
|
8759
8796
|
const url = await promptInput("url", "Seq URL:", "http://localhost:5341");
|
|
@@ -8765,32 +8802,32 @@ async function promptConnection2(existingNames) {
|
|
|
8765
8802
|
var seqAuth = createConnectionAuth({
|
|
8766
8803
|
load: loadConnections2,
|
|
8767
8804
|
save: saveConnections2,
|
|
8768
|
-
format: (c) => `${
|
|
8805
|
+
format: (c) => `${chalk102.bold(c.name)} ${c.url}`,
|
|
8769
8806
|
promptNew: promptConnection2,
|
|
8770
8807
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
8771
8808
|
});
|
|
8772
8809
|
|
|
8773
8810
|
// src/commands/seq/seqQuery.ts
|
|
8774
|
-
import
|
|
8811
|
+
import chalk105 from "chalk";
|
|
8775
8812
|
|
|
8776
8813
|
// src/commands/seq/formatEvent.ts
|
|
8777
|
-
import
|
|
8814
|
+
import chalk103 from "chalk";
|
|
8778
8815
|
function levelColor(level) {
|
|
8779
8816
|
switch (level) {
|
|
8780
8817
|
case "Fatal":
|
|
8781
|
-
return
|
|
8818
|
+
return chalk103.bgRed.white;
|
|
8782
8819
|
case "Error":
|
|
8783
|
-
return
|
|
8820
|
+
return chalk103.red;
|
|
8784
8821
|
case "Warning":
|
|
8785
|
-
return
|
|
8822
|
+
return chalk103.yellow;
|
|
8786
8823
|
case "Information":
|
|
8787
|
-
return
|
|
8824
|
+
return chalk103.cyan;
|
|
8788
8825
|
case "Debug":
|
|
8789
|
-
return
|
|
8826
|
+
return chalk103.gray;
|
|
8790
8827
|
case "Verbose":
|
|
8791
|
-
return
|
|
8828
|
+
return chalk103.dim;
|
|
8792
8829
|
default:
|
|
8793
|
-
return
|
|
8830
|
+
return chalk103.white;
|
|
8794
8831
|
}
|
|
8795
8832
|
}
|
|
8796
8833
|
function levelAbbrev(level) {
|
|
@@ -8831,31 +8868,31 @@ function formatTimestamp(iso) {
|
|
|
8831
8868
|
function formatEvent(event) {
|
|
8832
8869
|
const color = levelColor(event.Level);
|
|
8833
8870
|
const abbrev = levelAbbrev(event.Level);
|
|
8834
|
-
const ts8 =
|
|
8871
|
+
const ts8 = chalk103.dim(formatTimestamp(event.Timestamp));
|
|
8835
8872
|
const msg = renderMessage(event);
|
|
8836
8873
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
8837
8874
|
if (event.Exception) {
|
|
8838
8875
|
for (const line of event.Exception.split("\n")) {
|
|
8839
|
-
lines.push(
|
|
8876
|
+
lines.push(chalk103.red(` ${line}`));
|
|
8840
8877
|
}
|
|
8841
8878
|
}
|
|
8842
8879
|
return lines.join("\n");
|
|
8843
8880
|
}
|
|
8844
8881
|
|
|
8845
8882
|
// src/commands/seq/resolveConnection.ts
|
|
8846
|
-
import
|
|
8883
|
+
import chalk104 from "chalk";
|
|
8847
8884
|
function resolveConnection2(name) {
|
|
8848
8885
|
const connections = loadConnections2();
|
|
8849
8886
|
if (connections.length === 0) {
|
|
8850
8887
|
console.error(
|
|
8851
|
-
|
|
8888
|
+
chalk104.red("No Seq connections configured. Run 'assist seq auth' first.")
|
|
8852
8889
|
);
|
|
8853
8890
|
process.exit(1);
|
|
8854
8891
|
}
|
|
8855
8892
|
const target = name ?? getDefaultConnection() ?? connections[0].name;
|
|
8856
8893
|
const connection = connections.find((c) => c.name === target);
|
|
8857
8894
|
if (!connection) {
|
|
8858
|
-
console.error(
|
|
8895
|
+
console.error(chalk104.red(`Seq connection "${target}" not found.`));
|
|
8859
8896
|
process.exit(1);
|
|
8860
8897
|
}
|
|
8861
8898
|
return connection;
|
|
@@ -8875,12 +8912,12 @@ async function seqQuery(filter, options2) {
|
|
|
8875
8912
|
});
|
|
8876
8913
|
if (!response.ok) {
|
|
8877
8914
|
const body = await response.text();
|
|
8878
|
-
console.error(
|
|
8915
|
+
console.error(chalk105.red(`Seq returned ${response.status}: ${body}`));
|
|
8879
8916
|
process.exit(1);
|
|
8880
8917
|
}
|
|
8881
8918
|
const events = await response.json();
|
|
8882
8919
|
if (events.length === 0) {
|
|
8883
|
-
console.log(
|
|
8920
|
+
console.log(chalk105.yellow("No events found."));
|
|
8884
8921
|
return;
|
|
8885
8922
|
}
|
|
8886
8923
|
if (options2.json) {
|
|
@@ -8891,11 +8928,11 @@ async function seqQuery(filter, options2) {
|
|
|
8891
8928
|
for (const event of chronological) {
|
|
8892
8929
|
console.log(formatEvent(event));
|
|
8893
8930
|
}
|
|
8894
|
-
console.log(
|
|
8931
|
+
console.log(chalk105.dim(`
|
|
8895
8932
|
${events.length} events`));
|
|
8896
8933
|
if (events.length >= count) {
|
|
8897
8934
|
console.log(
|
|
8898
|
-
|
|
8935
|
+
chalk105.yellow(
|
|
8899
8936
|
`Results limited to ${count}. Use --count to retrieve more.`
|
|
8900
8937
|
)
|
|
8901
8938
|
);
|
|
@@ -8903,11 +8940,11 @@ ${events.length} events`));
|
|
|
8903
8940
|
}
|
|
8904
8941
|
|
|
8905
8942
|
// src/commands/seq/seqSetConnection.ts
|
|
8906
|
-
import
|
|
8943
|
+
import chalk106 from "chalk";
|
|
8907
8944
|
function seqSetConnection(name) {
|
|
8908
8945
|
const connections = loadConnections2();
|
|
8909
8946
|
if (!connections.find((c) => c.name === name)) {
|
|
8910
|
-
console.error(
|
|
8947
|
+
console.error(chalk106.red(`Connection "${name}" not found.`));
|
|
8911
8948
|
process.exit(1);
|
|
8912
8949
|
}
|
|
8913
8950
|
setDefaultConnection(name);
|
|
@@ -8926,7 +8963,7 @@ function registerSeq(program2) {
|
|
|
8926
8963
|
}
|
|
8927
8964
|
|
|
8928
8965
|
// src/commands/transcript/shared.ts
|
|
8929
|
-
import { existsSync as
|
|
8966
|
+
import { existsSync as existsSync30, readdirSync as readdirSync5, statSync as statSync2 } from "fs";
|
|
8930
8967
|
import { basename as basename4, join as join25, relative } from "path";
|
|
8931
8968
|
import * as readline2 from "readline";
|
|
8932
8969
|
var DATE_PREFIX_REGEX = /^\d{4}-\d{2}-\d{2}/;
|
|
@@ -8942,7 +8979,7 @@ function isValidDatePrefix(filename) {
|
|
|
8942
8979
|
return DATE_PREFIX_REGEX.test(filename);
|
|
8943
8980
|
}
|
|
8944
8981
|
function collectFiles(dir, extension) {
|
|
8945
|
-
if (!
|
|
8982
|
+
if (!existsSync30(dir)) return [];
|
|
8946
8983
|
const results = [];
|
|
8947
8984
|
for (const entry of readdirSync5(dir)) {
|
|
8948
8985
|
const fullPath = join25(dir, entry);
|
|
@@ -9039,7 +9076,7 @@ async function configure() {
|
|
|
9039
9076
|
}
|
|
9040
9077
|
|
|
9041
9078
|
// src/commands/transcript/format/index.ts
|
|
9042
|
-
import { existsSync as
|
|
9079
|
+
import { existsSync as existsSync32 } from "fs";
|
|
9043
9080
|
|
|
9044
9081
|
// src/commands/transcript/format/fixInvalidDatePrefixes/index.ts
|
|
9045
9082
|
import { dirname as dirname18, join as join27 } from "path";
|
|
@@ -9113,7 +9150,7 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
9113
9150
|
}
|
|
9114
9151
|
|
|
9115
9152
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
9116
|
-
import { existsSync as
|
|
9153
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync7, readFileSync as readFileSync24, writeFileSync as writeFileSync23 } from "fs";
|
|
9117
9154
|
import { basename as basename5, dirname as dirname19, join as join28 } from "path";
|
|
9118
9155
|
|
|
9119
9156
|
// src/commands/transcript/cleanText.ts
|
|
@@ -9338,7 +9375,7 @@ function logSkipped(relativeDir, mdFile) {
|
|
|
9338
9375
|
return "skipped";
|
|
9339
9376
|
}
|
|
9340
9377
|
function ensureDirectory(dir, label2) {
|
|
9341
|
-
if (!
|
|
9378
|
+
if (!existsSync31(dir)) {
|
|
9342
9379
|
mkdirSync7(dir, { recursive: true });
|
|
9343
9380
|
console.log(`Created ${label2}: ${dir}`);
|
|
9344
9381
|
}
|
|
@@ -9361,7 +9398,7 @@ function logReduction(cueCount, messageCount) {
|
|
|
9361
9398
|
}
|
|
9362
9399
|
function readAndParseCues(inputPath) {
|
|
9363
9400
|
console.log(`Reading: ${inputPath}`);
|
|
9364
|
-
return processCues(
|
|
9401
|
+
return processCues(readFileSync24(inputPath, "utf-8"));
|
|
9365
9402
|
}
|
|
9366
9403
|
function writeFormatted(outputPath, content) {
|
|
9367
9404
|
writeFileSync23(outputPath, content, "utf-8");
|
|
@@ -9374,7 +9411,7 @@ function convertVttToMarkdown(inputPath, outputPath) {
|
|
|
9374
9411
|
logReduction(cues.length, chatMessages.length);
|
|
9375
9412
|
}
|
|
9376
9413
|
function tryProcessVtt(vttFile, paths) {
|
|
9377
|
-
if (
|
|
9414
|
+
if (existsSync31(paths.outputPath))
|
|
9378
9415
|
return logSkipped(paths.relativeDir, paths.mdFile);
|
|
9379
9416
|
convertVttToMarkdown(vttFile.absolutePath, paths.outputPath);
|
|
9380
9417
|
return "processed";
|
|
@@ -9400,7 +9437,7 @@ function processAllFiles(vttFiles, transcriptsDir) {
|
|
|
9400
9437
|
logSummary(counts);
|
|
9401
9438
|
}
|
|
9402
9439
|
function requireVttDir(vttDir) {
|
|
9403
|
-
if (!
|
|
9440
|
+
if (!existsSync32(vttDir)) {
|
|
9404
9441
|
console.error(`VTT directory not found: ${vttDir}`);
|
|
9405
9442
|
process.exit(1);
|
|
9406
9443
|
}
|
|
@@ -9432,28 +9469,28 @@ async function format() {
|
|
|
9432
9469
|
}
|
|
9433
9470
|
|
|
9434
9471
|
// src/commands/transcript/summarise/index.ts
|
|
9435
|
-
import { existsSync as
|
|
9472
|
+
import { existsSync as existsSync34 } from "fs";
|
|
9436
9473
|
import { basename as basename6, dirname as dirname21, join as join30, relative as relative2 } from "path";
|
|
9437
9474
|
|
|
9438
9475
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
9439
9476
|
import {
|
|
9440
|
-
existsSync as
|
|
9477
|
+
existsSync as existsSync33,
|
|
9441
9478
|
mkdirSync as mkdirSync8,
|
|
9442
|
-
readFileSync as
|
|
9479
|
+
readFileSync as readFileSync25,
|
|
9443
9480
|
renameSync as renameSync2,
|
|
9444
9481
|
rmSync
|
|
9445
9482
|
} from "fs";
|
|
9446
9483
|
import { dirname as dirname20, join as join29 } from "path";
|
|
9447
9484
|
|
|
9448
9485
|
// src/commands/transcript/summarise/processStagedFile/validateStagedContent.ts
|
|
9449
|
-
import
|
|
9486
|
+
import chalk107 from "chalk";
|
|
9450
9487
|
var FULL_TRANSCRIPT_REGEX = /^\[Full Transcript\]\(([^)]+)\)/;
|
|
9451
9488
|
function validateStagedContent(filename, content) {
|
|
9452
9489
|
const firstLine = content.split("\n")[0];
|
|
9453
9490
|
const match = firstLine.match(FULL_TRANSCRIPT_REGEX);
|
|
9454
9491
|
if (!match) {
|
|
9455
9492
|
console.error(
|
|
9456
|
-
|
|
9493
|
+
chalk107.red(
|
|
9457
9494
|
`Staged file ${filename} missing [Full Transcript](<path>) link on first line.`
|
|
9458
9495
|
)
|
|
9459
9496
|
);
|
|
@@ -9462,7 +9499,7 @@ function validateStagedContent(filename, content) {
|
|
|
9462
9499
|
const contentAfterLink = content.slice(firstLine.length).trim();
|
|
9463
9500
|
if (!contentAfterLink) {
|
|
9464
9501
|
console.error(
|
|
9465
|
-
|
|
9502
|
+
chalk107.red(
|
|
9466
9503
|
`Staged file ${filename} has no summary content after the transcript link.`
|
|
9467
9504
|
)
|
|
9468
9505
|
);
|
|
@@ -9474,7 +9511,7 @@ function validateStagedContent(filename, content) {
|
|
|
9474
9511
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
9475
9512
|
var STAGING_DIR = join29(process.cwd(), ".assist", "transcript");
|
|
9476
9513
|
function processStagedFile() {
|
|
9477
|
-
if (!
|
|
9514
|
+
if (!existsSync33(STAGING_DIR)) {
|
|
9478
9515
|
return false;
|
|
9479
9516
|
}
|
|
9480
9517
|
const stagedFiles = findMdFilesRecursive(STAGING_DIR);
|
|
@@ -9483,7 +9520,7 @@ function processStagedFile() {
|
|
|
9483
9520
|
}
|
|
9484
9521
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
9485
9522
|
const stagedFile = stagedFiles[0];
|
|
9486
|
-
const content =
|
|
9523
|
+
const content = readFileSync25(stagedFile.absolutePath, "utf-8");
|
|
9487
9524
|
validateStagedContent(stagedFile.filename, content);
|
|
9488
9525
|
const stagedBaseName = getTranscriptBaseName(stagedFile.filename);
|
|
9489
9526
|
const transcriptFiles = findMdFilesRecursive(transcriptsDir);
|
|
@@ -9498,7 +9535,7 @@ function processStagedFile() {
|
|
|
9498
9535
|
}
|
|
9499
9536
|
const destPath = join29(summaryDir, matchingTranscript.relativePath);
|
|
9500
9537
|
const destDir = dirname20(destPath);
|
|
9501
|
-
if (!
|
|
9538
|
+
if (!existsSync33(destDir)) {
|
|
9502
9539
|
mkdirSync8(destDir, { recursive: true });
|
|
9503
9540
|
}
|
|
9504
9541
|
renameSync2(stagedFile.absolutePath, destPath);
|
|
@@ -9525,7 +9562,7 @@ function buildSummaryIndex(summaryDir) {
|
|
|
9525
9562
|
function summarise2() {
|
|
9526
9563
|
processStagedFile();
|
|
9527
9564
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
9528
|
-
if (!
|
|
9565
|
+
if (!existsSync34(transcriptsDir)) {
|
|
9529
9566
|
console.log("No transcripts directory found.");
|
|
9530
9567
|
return;
|
|
9531
9568
|
}
|
|
@@ -9629,14 +9666,14 @@ function devices() {
|
|
|
9629
9666
|
}
|
|
9630
9667
|
|
|
9631
9668
|
// src/commands/voice/logs.ts
|
|
9632
|
-
import { existsSync as
|
|
9669
|
+
import { existsSync as existsSync35, readFileSync as readFileSync26 } from "fs";
|
|
9633
9670
|
function logs(options2) {
|
|
9634
|
-
if (!
|
|
9671
|
+
if (!existsSync35(voicePaths.log)) {
|
|
9635
9672
|
console.log("No voice log file found");
|
|
9636
9673
|
return;
|
|
9637
9674
|
}
|
|
9638
9675
|
const count = Number.parseInt(options2.lines ?? "150", 10);
|
|
9639
|
-
const content =
|
|
9676
|
+
const content = readFileSync26(voicePaths.log, "utf-8").trim();
|
|
9640
9677
|
if (!content) {
|
|
9641
9678
|
console.log("Voice log is empty");
|
|
9642
9679
|
return;
|
|
@@ -9663,7 +9700,7 @@ import { join as join34 } from "path";
|
|
|
9663
9700
|
|
|
9664
9701
|
// src/commands/voice/checkLockFile.ts
|
|
9665
9702
|
import { execSync as execSync37 } from "child_process";
|
|
9666
|
-
import { existsSync as
|
|
9703
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync9, readFileSync as readFileSync27, writeFileSync as writeFileSync24 } from "fs";
|
|
9667
9704
|
import { join as join33 } from "path";
|
|
9668
9705
|
function isProcessAlive(pid) {
|
|
9669
9706
|
try {
|
|
@@ -9675,9 +9712,9 @@ function isProcessAlive(pid) {
|
|
|
9675
9712
|
}
|
|
9676
9713
|
function checkLockFile() {
|
|
9677
9714
|
const lockFile = getLockFile();
|
|
9678
|
-
if (!
|
|
9715
|
+
if (!existsSync36(lockFile)) return;
|
|
9679
9716
|
try {
|
|
9680
|
-
const lock = JSON.parse(
|
|
9717
|
+
const lock = JSON.parse(readFileSync27(lockFile, "utf-8"));
|
|
9681
9718
|
if (lock.pid && isProcessAlive(lock.pid)) {
|
|
9682
9719
|
console.error(
|
|
9683
9720
|
`Voice daemon already running (PID ${lock.pid}, env: ${lock.env}). Stop it first with: assist voice stop`
|
|
@@ -9688,7 +9725,7 @@ function checkLockFile() {
|
|
|
9688
9725
|
}
|
|
9689
9726
|
}
|
|
9690
9727
|
function bootstrapVenv() {
|
|
9691
|
-
if (
|
|
9728
|
+
if (existsSync36(getVenvPython())) return;
|
|
9692
9729
|
console.log("Setting up Python environment...");
|
|
9693
9730
|
const pythonDir = getPythonDir();
|
|
9694
9731
|
execSync37(
|
|
@@ -9779,7 +9816,7 @@ function start2(options2) {
|
|
|
9779
9816
|
}
|
|
9780
9817
|
|
|
9781
9818
|
// src/commands/voice/status.ts
|
|
9782
|
-
import { existsSync as
|
|
9819
|
+
import { existsSync as existsSync37, readFileSync as readFileSync28 } from "fs";
|
|
9783
9820
|
function isProcessAlive2(pid) {
|
|
9784
9821
|
try {
|
|
9785
9822
|
process.kill(pid, 0);
|
|
@@ -9789,16 +9826,16 @@ function isProcessAlive2(pid) {
|
|
|
9789
9826
|
}
|
|
9790
9827
|
}
|
|
9791
9828
|
function readRecentLogs(count) {
|
|
9792
|
-
if (!
|
|
9793
|
-
const lines =
|
|
9829
|
+
if (!existsSync37(voicePaths.log)) return [];
|
|
9830
|
+
const lines = readFileSync28(voicePaths.log, "utf-8").trim().split("\n");
|
|
9794
9831
|
return lines.slice(-count);
|
|
9795
9832
|
}
|
|
9796
9833
|
function status() {
|
|
9797
|
-
if (!
|
|
9834
|
+
if (!existsSync37(voicePaths.pid)) {
|
|
9798
9835
|
console.log("Voice daemon: not running (no PID file)");
|
|
9799
9836
|
return;
|
|
9800
9837
|
}
|
|
9801
|
-
const pid = Number.parseInt(
|
|
9838
|
+
const pid = Number.parseInt(readFileSync28(voicePaths.pid, "utf-8").trim(), 10);
|
|
9802
9839
|
const alive = isProcessAlive2(pid);
|
|
9803
9840
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
9804
9841
|
const recent = readRecentLogs(5);
|
|
@@ -9817,13 +9854,13 @@ function status() {
|
|
|
9817
9854
|
}
|
|
9818
9855
|
|
|
9819
9856
|
// src/commands/voice/stop.ts
|
|
9820
|
-
import { existsSync as
|
|
9857
|
+
import { existsSync as existsSync38, readFileSync as readFileSync29, unlinkSync as unlinkSync9 } from "fs";
|
|
9821
9858
|
function stop() {
|
|
9822
|
-
if (!
|
|
9859
|
+
if (!existsSync38(voicePaths.pid)) {
|
|
9823
9860
|
console.log("Voice daemon is not running (no PID file)");
|
|
9824
9861
|
return;
|
|
9825
9862
|
}
|
|
9826
|
-
const pid = Number.parseInt(
|
|
9863
|
+
const pid = Number.parseInt(readFileSync29(voicePaths.pid, "utf-8").trim(), 10);
|
|
9827
9864
|
try {
|
|
9828
9865
|
process.kill(pid, "SIGTERM");
|
|
9829
9866
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -9836,7 +9873,7 @@ function stop() {
|
|
|
9836
9873
|
}
|
|
9837
9874
|
try {
|
|
9838
9875
|
const lockFile = getLockFile();
|
|
9839
|
-
if (
|
|
9876
|
+
if (existsSync38(lockFile)) unlinkSync9(lockFile);
|
|
9840
9877
|
} catch {
|
|
9841
9878
|
}
|
|
9842
9879
|
console.log("Voice daemon stopped");
|
|
@@ -9855,7 +9892,7 @@ function registerVoice(program2) {
|
|
|
9855
9892
|
|
|
9856
9893
|
// src/commands/roam/auth.ts
|
|
9857
9894
|
import { randomBytes } from "crypto";
|
|
9858
|
-
import
|
|
9895
|
+
import chalk108 from "chalk";
|
|
9859
9896
|
|
|
9860
9897
|
// src/lib/openBrowser.ts
|
|
9861
9898
|
import { execSync as execSync38 } from "child_process";
|
|
@@ -10030,13 +10067,13 @@ async function auth() {
|
|
|
10030
10067
|
saveGlobalConfig(config);
|
|
10031
10068
|
const state = randomBytes(16).toString("hex");
|
|
10032
10069
|
console.log(
|
|
10033
|
-
|
|
10070
|
+
chalk108.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
10034
10071
|
);
|
|
10035
|
-
console.log(
|
|
10036
|
-
console.log(
|
|
10037
|
-
console.log(
|
|
10072
|
+
console.log(chalk108.white("http://localhost:14523/callback\n"));
|
|
10073
|
+
console.log(chalk108.blue("Opening browser for authorization..."));
|
|
10074
|
+
console.log(chalk108.dim("Waiting for authorization callback..."));
|
|
10038
10075
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
10039
|
-
console.log(
|
|
10076
|
+
console.log(chalk108.dim("Exchanging code for tokens..."));
|
|
10040
10077
|
const tokens = await exchangeToken({
|
|
10041
10078
|
code,
|
|
10042
10079
|
clientId,
|
|
@@ -10052,12 +10089,12 @@ async function auth() {
|
|
|
10052
10089
|
};
|
|
10053
10090
|
saveGlobalConfig(config);
|
|
10054
10091
|
console.log(
|
|
10055
|
-
|
|
10092
|
+
chalk108.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
10056
10093
|
);
|
|
10057
10094
|
}
|
|
10058
10095
|
|
|
10059
10096
|
// src/commands/roam/showClaudeCodeIcon.ts
|
|
10060
|
-
import { readFileSync as
|
|
10097
|
+
import { readFileSync as readFileSync30 } from "fs";
|
|
10061
10098
|
import { join as join36 } from "path";
|
|
10062
10099
|
async function showClaudeCodeIcon() {
|
|
10063
10100
|
const appData = process.env.APPDATA;
|
|
@@ -10065,7 +10102,7 @@ async function showClaudeCodeIcon() {
|
|
|
10065
10102
|
const portFile = join36(appData, "Roam", "roam-local-api.port");
|
|
10066
10103
|
let port;
|
|
10067
10104
|
try {
|
|
10068
|
-
port =
|
|
10105
|
+
port = readFileSync30(portFile, "utf-8").trim();
|
|
10069
10106
|
} catch {
|
|
10070
10107
|
return;
|
|
10071
10108
|
}
|
|
@@ -10262,10 +10299,10 @@ function run3(name, args) {
|
|
|
10262
10299
|
|
|
10263
10300
|
// src/commands/screenshot/index.ts
|
|
10264
10301
|
import { execSync as execSync40 } from "child_process";
|
|
10265
|
-
import { existsSync as
|
|
10302
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync13, unlinkSync as unlinkSync10, writeFileSync as writeFileSync27 } from "fs";
|
|
10266
10303
|
import { tmpdir as tmpdir6 } from "os";
|
|
10267
10304
|
import { join as join38, resolve as resolve5 } from "path";
|
|
10268
|
-
import
|
|
10305
|
+
import chalk109 from "chalk";
|
|
10269
10306
|
|
|
10270
10307
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
10271
10308
|
var captureWindowPs1 = `
|
|
@@ -10394,7 +10431,7 @@ Write-Output $OutputPath
|
|
|
10394
10431
|
|
|
10395
10432
|
// src/commands/screenshot/index.ts
|
|
10396
10433
|
function buildOutputPath(outputDir, processName) {
|
|
10397
|
-
if (!
|
|
10434
|
+
if (!existsSync39(outputDir)) {
|
|
10398
10435
|
mkdirSync13(outputDir, { recursive: true });
|
|
10399
10436
|
}
|
|
10400
10437
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -10416,22 +10453,22 @@ function screenshot(processName) {
|
|
|
10416
10453
|
const config = loadConfig();
|
|
10417
10454
|
const outputDir = resolve5(config.screenshot.outputDir);
|
|
10418
10455
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
10419
|
-
console.log(
|
|
10456
|
+
console.log(chalk109.gray(`Capturing window for process "${processName}" ...`));
|
|
10420
10457
|
try {
|
|
10421
10458
|
runPowerShellScript(processName, outputPath);
|
|
10422
|
-
console.log(
|
|
10459
|
+
console.log(chalk109.green(`Screenshot saved: ${outputPath}`));
|
|
10423
10460
|
} catch (error) {
|
|
10424
10461
|
const msg = error instanceof Error ? error.message : String(error);
|
|
10425
|
-
console.error(
|
|
10462
|
+
console.error(chalk109.red(`Failed to capture screenshot: ${msg}`));
|
|
10426
10463
|
process.exit(1);
|
|
10427
10464
|
}
|
|
10428
10465
|
}
|
|
10429
10466
|
|
|
10430
10467
|
// src/commands/statusLine.ts
|
|
10431
|
-
import
|
|
10468
|
+
import chalk111 from "chalk";
|
|
10432
10469
|
|
|
10433
10470
|
// src/commands/buildLimitsSegment.ts
|
|
10434
|
-
import
|
|
10471
|
+
import chalk110 from "chalk";
|
|
10435
10472
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
10436
10473
|
var SEVEN_DAY_SECONDS = 7 * 86400;
|
|
10437
10474
|
function formatTimeLeft(resetsAt) {
|
|
@@ -10454,10 +10491,10 @@ function projectUsage(pct, resetsAt, windowSeconds) {
|
|
|
10454
10491
|
function colorizeRateLimit(pct, resetsAt, windowSeconds) {
|
|
10455
10492
|
const label2 = `${Math.round(pct)}%`;
|
|
10456
10493
|
const projected = projectUsage(pct, resetsAt, windowSeconds);
|
|
10457
|
-
if (projected == null) return
|
|
10458
|
-
if (projected > 100) return
|
|
10459
|
-
if (projected > 75) return
|
|
10460
|
-
return
|
|
10494
|
+
if (projected == null) return chalk110.green(label2);
|
|
10495
|
+
if (projected > 100) return chalk110.red(label2);
|
|
10496
|
+
if (projected > 75) return chalk110.yellow(label2);
|
|
10497
|
+
return chalk110.green(label2);
|
|
10461
10498
|
}
|
|
10462
10499
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel) {
|
|
10463
10500
|
const timeLabel = resetsAt ? formatTimeLeft(resetsAt) : fallbackLabel;
|
|
@@ -10483,14 +10520,14 @@ function buildLimitsSegment(rateLimits) {
|
|
|
10483
10520
|
}
|
|
10484
10521
|
|
|
10485
10522
|
// src/commands/statusLine.ts
|
|
10486
|
-
|
|
10523
|
+
chalk111.level = 3;
|
|
10487
10524
|
function formatNumber(num) {
|
|
10488
10525
|
return num.toLocaleString("en-US");
|
|
10489
10526
|
}
|
|
10490
10527
|
function colorizePercent(pct) {
|
|
10491
10528
|
const label2 = `${Math.round(pct)}%`;
|
|
10492
|
-
if (pct > 80) return
|
|
10493
|
-
if (pct > 40) return
|
|
10529
|
+
if (pct > 80) return chalk111.red(label2);
|
|
10530
|
+
if (pct > 40) return chalk111.yellow(label2);
|
|
10494
10531
|
return label2;
|
|
10495
10532
|
}
|
|
10496
10533
|
async function statusLine() {
|
|
@@ -10513,7 +10550,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
|
|
|
10513
10550
|
// src/commands/sync/syncClaudeMd.ts
|
|
10514
10551
|
import * as fs23 from "fs";
|
|
10515
10552
|
import * as path46 from "path";
|
|
10516
|
-
import
|
|
10553
|
+
import chalk112 from "chalk";
|
|
10517
10554
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
10518
10555
|
const source = path46.join(claudeDir, "CLAUDE.md");
|
|
10519
10556
|
const target = path46.join(targetBase, "CLAUDE.md");
|
|
@@ -10522,12 +10559,12 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
10522
10559
|
const targetContent = fs23.readFileSync(target, "utf-8");
|
|
10523
10560
|
if (sourceContent !== targetContent) {
|
|
10524
10561
|
console.log(
|
|
10525
|
-
|
|
10562
|
+
chalk112.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
10526
10563
|
);
|
|
10527
10564
|
console.log();
|
|
10528
10565
|
printDiff(targetContent, sourceContent);
|
|
10529
10566
|
const confirm = options2?.yes || await promptConfirm(
|
|
10530
|
-
|
|
10567
|
+
chalk112.red("Overwrite existing CLAUDE.md?"),
|
|
10531
10568
|
false
|
|
10532
10569
|
);
|
|
10533
10570
|
if (!confirm) {
|
|
@@ -10543,7 +10580,7 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
10543
10580
|
// src/commands/sync/syncSettings.ts
|
|
10544
10581
|
import * as fs24 from "fs";
|
|
10545
10582
|
import * as path47 from "path";
|
|
10546
|
-
import
|
|
10583
|
+
import chalk113 from "chalk";
|
|
10547
10584
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
10548
10585
|
const source = path47.join(claudeDir, "settings.json");
|
|
10549
10586
|
const target = path47.join(targetBase, "settings.json");
|
|
@@ -10559,14 +10596,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
10559
10596
|
if (mergedContent !== normalizedTarget) {
|
|
10560
10597
|
if (!options2?.yes) {
|
|
10561
10598
|
console.log(
|
|
10562
|
-
|
|
10599
|
+
chalk113.yellow(
|
|
10563
10600
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
10564
10601
|
)
|
|
10565
10602
|
);
|
|
10566
10603
|
console.log();
|
|
10567
10604
|
printDiff(targetContent, mergedContent);
|
|
10568
10605
|
const confirm = await promptConfirm(
|
|
10569
|
-
|
|
10606
|
+
chalk113.red("Overwrite existing settings.json?"),
|
|
10570
10607
|
false
|
|
10571
10608
|
);
|
|
10572
10609
|
if (!confirm) {
|
|
@@ -10689,4 +10726,11 @@ registerSeq(program);
|
|
|
10689
10726
|
registerTranscript(program);
|
|
10690
10727
|
registerVoice(program);
|
|
10691
10728
|
program.command("next").description("Alias for backlog next -w").action(() => next({ allowEdits: true }));
|
|
10729
|
+
program.command("draft").description("Launch Claude in /draft mode, chain into next on /next signal").action(() => launchMode("draft"));
|
|
10730
|
+
program.command("bug").description("Launch Claude in /bug mode, chain into next on /next signal").action(() => launchMode("bug"));
|
|
10731
|
+
var signalCommand = program.command("signal").description("Write an assist signal file");
|
|
10732
|
+
signalCommand.command("next").description("Write a next signal to chain into assist next").action(() => {
|
|
10733
|
+
writeSignal("next");
|
|
10734
|
+
console.log("Signal written.");
|
|
10735
|
+
});
|
|
10692
10736
|
program.parse();
|