@staff0rd/assist 0.136.1 → 0.136.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +386 -361
- 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.136.
|
|
9
|
+
version: "0.136.2",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -2601,17 +2601,14 @@ async function list2(options2) {
|
|
|
2601
2601
|
}
|
|
2602
2602
|
|
|
2603
2603
|
// src/commands/backlog/next.ts
|
|
2604
|
-
import
|
|
2604
|
+
import chalk36 from "chalk";
|
|
2605
2605
|
import enquirer6 from "enquirer";
|
|
2606
2606
|
|
|
2607
2607
|
// src/commands/backlog/run.ts
|
|
2608
|
-
import
|
|
2608
|
+
import chalk35 from "chalk";
|
|
2609
2609
|
|
|
2610
2610
|
// src/commands/backlog/executePhase.ts
|
|
2611
|
-
import
|
|
2612
|
-
import { existsSync as existsSync16, unlinkSync as unlinkSync3 } from "fs";
|
|
2613
|
-
import chalk33 from "chalk";
|
|
2614
|
-
import enquirer5 from "enquirer";
|
|
2611
|
+
import chalk34 from "chalk";
|
|
2615
2612
|
|
|
2616
2613
|
// src/commands/backlog/buildPhasePrompt.ts
|
|
2617
2614
|
function buildPhasePrompt(item, phaseIndex, phase) {
|
|
@@ -2634,11 +2631,17 @@ function buildPhasePrompt(item, phaseIndex, phase) {
|
|
|
2634
2631
|
tasks,
|
|
2635
2632
|
"",
|
|
2636
2633
|
"Focus ONLY on this phase. Do not work on other phases.",
|
|
2637
|
-
|
|
2638
|
-
|
|
2634
|
+
"When you have completed all tasks for this phase, run /verify to check your work.",
|
|
2635
|
+
`Once verify passes, run: assist backlog phase-done ${item.id} ${phaseIndex}`
|
|
2639
2636
|
].filter((line) => line !== void 0).join("\n");
|
|
2640
2637
|
}
|
|
2641
2638
|
|
|
2639
|
+
// src/commands/backlog/resolvePhaseResult.ts
|
|
2640
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
2641
|
+
import { existsSync as existsSync16, unlinkSync as unlinkSync3 } from "fs";
|
|
2642
|
+
import chalk33 from "chalk";
|
|
2643
|
+
import enquirer5 from "enquirer";
|
|
2644
|
+
|
|
2642
2645
|
// src/commands/backlog/phaseDone.ts
|
|
2643
2646
|
import { writeFileSync as writeFileSync13 } from "fs";
|
|
2644
2647
|
import { join as join10 } from "path";
|
|
@@ -2662,19 +2665,7 @@ function phaseDone(id, phase) {
|
|
|
2662
2665
|
console.log(chalk32.green(`Phase ${phase} of item #${id} marked as complete.`));
|
|
2663
2666
|
}
|
|
2664
2667
|
|
|
2665
|
-
// src/commands/backlog/
|
|
2666
|
-
import { spawn as spawn3 } from "child_process";
|
|
2667
|
-
function spawnClaude(prompt) {
|
|
2668
|
-
return new Promise((resolve7, reject) => {
|
|
2669
|
-
const child = spawn3("claude", [prompt], {
|
|
2670
|
-
stdio: "inherit"
|
|
2671
|
-
});
|
|
2672
|
-
child.on("close", (code) => resolve7(code ?? 0));
|
|
2673
|
-
child.on("error", reject);
|
|
2674
|
-
});
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
// src/commands/backlog/executePhase.ts
|
|
2668
|
+
// src/commands/backlog/resolvePhaseResult.ts
|
|
2678
2669
|
function cleanupMarker() {
|
|
2679
2670
|
const statusPath = getPhaseStatusPath();
|
|
2680
2671
|
if (existsSync16(statusPath)) {
|
|
@@ -2726,17 +2717,51 @@ async function resolvePhaseResult(phaseIndex) {
|
|
|
2726
2717
|
if (action === "abort") return -1;
|
|
2727
2718
|
return action === "skip" ? 1 : 0;
|
|
2728
2719
|
}
|
|
2720
|
+
|
|
2721
|
+
// src/commands/backlog/spawnClaude.ts
|
|
2722
|
+
import { spawn as spawn3 } from "child_process";
|
|
2723
|
+
function spawnClaude(prompt) {
|
|
2724
|
+
const child = spawn3("claude", [prompt], {
|
|
2725
|
+
stdio: "inherit"
|
|
2726
|
+
});
|
|
2727
|
+
const done2 = new Promise((resolve7, reject) => {
|
|
2728
|
+
child.on("close", (code) => resolve7(code ?? 0));
|
|
2729
|
+
child.on("error", reject);
|
|
2730
|
+
});
|
|
2731
|
+
return { child, done: done2 };
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
// src/commands/backlog/watchForMarker.ts
|
|
2735
|
+
import { existsSync as existsSync17, unwatchFile, watchFile } from "fs";
|
|
2736
|
+
function watchForMarker(child) {
|
|
2737
|
+
const statusPath = getPhaseStatusPath();
|
|
2738
|
+
watchFile(statusPath, { interval: 1e3 }, () => {
|
|
2739
|
+
if (existsSync17(statusPath)) {
|
|
2740
|
+
unwatchFile(statusPath);
|
|
2741
|
+
child.kill("SIGTERM");
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
2745
|
+
function stopWatching() {
|
|
2746
|
+
unwatchFile(getPhaseStatusPath());
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
// src/commands/backlog/executePhase.ts
|
|
2729
2750
|
async function executePhase(item, phaseIndex, phases) {
|
|
2730
2751
|
const phase = phases[phaseIndex];
|
|
2731
2752
|
console.log(
|
|
2732
|
-
|
|
2753
|
+
chalk34.bold(
|
|
2733
2754
|
`
|
|
2734
2755
|
--- Phase ${phaseIndex + 1}/${phases.length}: ${phase.name} ---
|
|
2735
2756
|
`
|
|
2736
2757
|
)
|
|
2737
2758
|
);
|
|
2738
|
-
|
|
2739
|
-
|
|
2759
|
+
const { child, done: done2 } = spawnClaude(
|
|
2760
|
+
buildPhasePrompt(item, phaseIndex, phase)
|
|
2761
|
+
);
|
|
2762
|
+
watchForMarker(child);
|
|
2763
|
+
await done2;
|
|
2764
|
+
stopWatching();
|
|
2740
2765
|
const delta = await resolvePhaseResult(phaseIndex);
|
|
2741
2766
|
return delta < 0 ? -1 : phaseIndex + delta;
|
|
2742
2767
|
}
|
|
@@ -2745,7 +2770,7 @@ async function executePhase(item, phaseIndex, phases) {
|
|
|
2745
2770
|
function validatePlan(item) {
|
|
2746
2771
|
if (!item.plan || item.plan.length === 0) {
|
|
2747
2772
|
console.log(
|
|
2748
|
-
|
|
2773
|
+
chalk35.red("Item has no plan. Use /draft to create one with phases.")
|
|
2749
2774
|
);
|
|
2750
2775
|
return void 0;
|
|
2751
2776
|
}
|
|
@@ -2759,14 +2784,14 @@ async function run2(id) {
|
|
|
2759
2784
|
if (!plan2) return;
|
|
2760
2785
|
setStatus(id, "in-progress");
|
|
2761
2786
|
const startPhase = item.currentPhase ?? 0;
|
|
2762
|
-
console.log(
|
|
2787
|
+
console.log(chalk35.bold(`Running plan for #${id}: ${item.name}`));
|
|
2763
2788
|
if (startPhase > 0) {
|
|
2764
2789
|
console.log(
|
|
2765
|
-
|
|
2790
|
+
chalk35.dim(`Resuming from phase ${startPhase + 1}/${plan2.length}
|
|
2766
2791
|
`)
|
|
2767
2792
|
);
|
|
2768
2793
|
} else {
|
|
2769
|
-
console.log(
|
|
2794
|
+
console.log(chalk35.dim(`${plan2.length} phase(s)
|
|
2770
2795
|
`));
|
|
2771
2796
|
}
|
|
2772
2797
|
let phaseIndex = startPhase;
|
|
@@ -2774,9 +2799,9 @@ async function run2(id) {
|
|
|
2774
2799
|
phaseIndex = await executePhase(item, phaseIndex, plan2);
|
|
2775
2800
|
if (phaseIndex < 0) return;
|
|
2776
2801
|
}
|
|
2777
|
-
console.log(
|
|
2802
|
+
console.log(chalk35.green(`
|
|
2778
2803
|
All phases complete for #${id}: ${item.name}`));
|
|
2779
|
-
console.log(
|
|
2804
|
+
console.log(chalk35.dim("Review the changes, then use /commit when ready."));
|
|
2780
2805
|
}
|
|
2781
2806
|
|
|
2782
2807
|
// src/commands/backlog/next.ts
|
|
@@ -2785,7 +2810,7 @@ async function next() {
|
|
|
2785
2810
|
const inProgress = items.find((i) => i.status === "in-progress" && i.plan);
|
|
2786
2811
|
if (inProgress) {
|
|
2787
2812
|
console.log(
|
|
2788
|
-
|
|
2813
|
+
chalk36.bold(
|
|
2789
2814
|
`Resuming in-progress item #${inProgress.id}: ${inProgress.name}`
|
|
2790
2815
|
)
|
|
2791
2816
|
);
|
|
@@ -2794,7 +2819,7 @@ async function next() {
|
|
|
2794
2819
|
}
|
|
2795
2820
|
const todo = items.filter((i) => i.status === "todo");
|
|
2796
2821
|
if (todo.length === 0) {
|
|
2797
|
-
console.log(
|
|
2822
|
+
console.log(chalk36.dim("No incomplete backlog items. Opening /draft..."));
|
|
2798
2823
|
await spawnClaude("/draft");
|
|
2799
2824
|
return;
|
|
2800
2825
|
}
|
|
@@ -2813,23 +2838,23 @@ async function next() {
|
|
|
2813
2838
|
}
|
|
2814
2839
|
|
|
2815
2840
|
// src/commands/backlog/plan.ts
|
|
2816
|
-
import
|
|
2841
|
+
import chalk37 from "chalk";
|
|
2817
2842
|
function plan(id) {
|
|
2818
2843
|
const result = loadAndFindItem(id);
|
|
2819
2844
|
if (!result) return;
|
|
2820
2845
|
const { item } = result;
|
|
2821
2846
|
if (!item.plan || item.plan.length === 0) {
|
|
2822
|
-
console.log(
|
|
2847
|
+
console.log(chalk37.dim("No plan defined for this item."));
|
|
2823
2848
|
return;
|
|
2824
2849
|
}
|
|
2825
|
-
console.log(
|
|
2850
|
+
console.log(chalk37.bold(item.name));
|
|
2826
2851
|
console.log();
|
|
2827
2852
|
for (const [i, phase] of item.plan.entries()) {
|
|
2828
|
-
console.log(`${
|
|
2853
|
+
console.log(`${chalk37.bold(`Phase ${i + 1}:`)} ${phase.name}`);
|
|
2829
2854
|
for (const task of phase.tasks) {
|
|
2830
2855
|
console.log(` - ${task.task}`);
|
|
2831
2856
|
if (task.verify) {
|
|
2832
|
-
console.log(` ${
|
|
2857
|
+
console.log(` ${chalk37.dim(`verify: ${task.verify}`)}`);
|
|
2833
2858
|
}
|
|
2834
2859
|
}
|
|
2835
2860
|
console.log();
|
|
@@ -2837,11 +2862,11 @@ function plan(id) {
|
|
|
2837
2862
|
}
|
|
2838
2863
|
|
|
2839
2864
|
// src/commands/backlog/start/index.ts
|
|
2840
|
-
import
|
|
2865
|
+
import chalk38 from "chalk";
|
|
2841
2866
|
async function start(id) {
|
|
2842
2867
|
const name = setStatus(id, "in-progress");
|
|
2843
2868
|
if (name) {
|
|
2844
|
-
console.log(
|
|
2869
|
+
console.log(chalk38.green(`Started item #${id}: ${name}`));
|
|
2845
2870
|
}
|
|
2846
2871
|
}
|
|
2847
2872
|
|
|
@@ -2853,7 +2878,7 @@ import {
|
|
|
2853
2878
|
} from "http";
|
|
2854
2879
|
import { dirname as dirname13, join as join11 } from "path";
|
|
2855
2880
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2856
|
-
import
|
|
2881
|
+
import chalk39 from "chalk";
|
|
2857
2882
|
function respondJson(res, status2, data) {
|
|
2858
2883
|
res.writeHead(status2, { "Content-Type": "application/json" });
|
|
2859
2884
|
res.end(JSON.stringify(data));
|
|
@@ -2897,8 +2922,8 @@ function startWebServer(label2, port, handler) {
|
|
|
2897
2922
|
handler(req, res, port);
|
|
2898
2923
|
});
|
|
2899
2924
|
server.listen(port, () => {
|
|
2900
|
-
console.log(
|
|
2901
|
-
console.log(
|
|
2925
|
+
console.log(chalk39.green(`${label2}: ${url}`));
|
|
2926
|
+
console.log(chalk39.dim("Press Ctrl+C to stop"));
|
|
2902
2927
|
exec(`open ${url}`);
|
|
2903
2928
|
});
|
|
2904
2929
|
}
|
|
@@ -3152,7 +3177,7 @@ function extractGraphqlQuery(args) {
|
|
|
3152
3177
|
}
|
|
3153
3178
|
|
|
3154
3179
|
// src/shared/loadCliReads.ts
|
|
3155
|
-
import { existsSync as
|
|
3180
|
+
import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync14 } from "fs";
|
|
3156
3181
|
import { dirname as dirname14, resolve as resolve2 } from "path";
|
|
3157
3182
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
3158
3183
|
var __filename2 = fileURLToPath4(import.meta.url);
|
|
@@ -3164,7 +3189,7 @@ var cachedLines;
|
|
|
3164
3189
|
function getCliReadsLines() {
|
|
3165
3190
|
if (cachedLines) return cachedLines;
|
|
3166
3191
|
const path44 = getCliReadsPath();
|
|
3167
|
-
if (!
|
|
3192
|
+
if (!existsSync18(path44)) {
|
|
3168
3193
|
cachedLines = [];
|
|
3169
3194
|
return cachedLines;
|
|
3170
3195
|
}
|
|
@@ -3193,7 +3218,7 @@ function findCliRead(command) {
|
|
|
3193
3218
|
}
|
|
3194
3219
|
|
|
3195
3220
|
// src/shared/matchesBashAllow.ts
|
|
3196
|
-
import { existsSync as
|
|
3221
|
+
import { existsSync as existsSync19, readFileSync as readFileSync14 } from "fs";
|
|
3197
3222
|
import { homedir as homedir3 } from "os";
|
|
3198
3223
|
import { join as join12 } from "path";
|
|
3199
3224
|
var cached;
|
|
@@ -3221,7 +3246,7 @@ function collectAllowEntries() {
|
|
|
3221
3246
|
return entries;
|
|
3222
3247
|
}
|
|
3223
3248
|
function readAllowArray(filePath) {
|
|
3224
|
-
if (!
|
|
3249
|
+
if (!existsSync19(filePath)) return [];
|
|
3225
3250
|
try {
|
|
3226
3251
|
const data = JSON.parse(readFileSync14(filePath, "utf-8"));
|
|
3227
3252
|
const allow = data?.permissions?.allow;
|
|
@@ -3371,7 +3396,7 @@ ${reasons.join("\n")}`);
|
|
|
3371
3396
|
}
|
|
3372
3397
|
|
|
3373
3398
|
// src/commands/permitCliReads/index.ts
|
|
3374
|
-
import { existsSync as
|
|
3399
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync4, readFileSync as readFileSync15, writeFileSync as writeFileSync15 } from "fs";
|
|
3375
3400
|
import { homedir as homedir4 } from "os";
|
|
3376
3401
|
import { join as join13 } from "path";
|
|
3377
3402
|
|
|
@@ -3417,11 +3442,11 @@ function assertCliExists(cli) {
|
|
|
3417
3442
|
}
|
|
3418
3443
|
|
|
3419
3444
|
// src/commands/permitCliReads/colorize.ts
|
|
3420
|
-
import
|
|
3445
|
+
import chalk40 from "chalk";
|
|
3421
3446
|
function colorize(plainOutput) {
|
|
3422
3447
|
return plainOutput.split("\n").map((line) => {
|
|
3423
|
-
if (line.startsWith(" R ")) return
|
|
3424
|
-
if (line.startsWith(" W ")) return
|
|
3448
|
+
if (line.startsWith(" R ")) return chalk40.green(line);
|
|
3449
|
+
if (line.startsWith(" W ")) return chalk40.red(line);
|
|
3425
3450
|
return line;
|
|
3426
3451
|
}).join("\n");
|
|
3427
3452
|
}
|
|
@@ -3679,7 +3704,7 @@ function logPath(cli) {
|
|
|
3679
3704
|
}
|
|
3680
3705
|
function readCache(cli) {
|
|
3681
3706
|
const path44 = logPath(cli);
|
|
3682
|
-
if (!
|
|
3707
|
+
if (!existsSync20(path44)) return void 0;
|
|
3683
3708
|
return readFileSync15(path44, "utf-8");
|
|
3684
3709
|
}
|
|
3685
3710
|
function writeCache(cli, output) {
|
|
@@ -3735,15 +3760,15 @@ function registerCliHook(program2) {
|
|
|
3735
3760
|
}
|
|
3736
3761
|
|
|
3737
3762
|
// src/commands/complexity/analyze.ts
|
|
3738
|
-
import
|
|
3763
|
+
import chalk46 from "chalk";
|
|
3739
3764
|
|
|
3740
3765
|
// src/commands/complexity/cyclomatic.ts
|
|
3741
|
-
import
|
|
3766
|
+
import chalk42 from "chalk";
|
|
3742
3767
|
|
|
3743
3768
|
// src/commands/complexity/shared/index.ts
|
|
3744
3769
|
import fs12 from "fs";
|
|
3745
3770
|
import path20 from "path";
|
|
3746
|
-
import
|
|
3771
|
+
import chalk41 from "chalk";
|
|
3747
3772
|
import ts5 from "typescript";
|
|
3748
3773
|
|
|
3749
3774
|
// src/commands/complexity/findSourceFiles.ts
|
|
@@ -3989,7 +4014,7 @@ function createSourceFromFile(filePath) {
|
|
|
3989
4014
|
function withSourceFiles(pattern2, callback) {
|
|
3990
4015
|
const files = findSourceFiles2(pattern2);
|
|
3991
4016
|
if (files.length === 0) {
|
|
3992
|
-
console.log(
|
|
4017
|
+
console.log(chalk41.yellow("No files found matching pattern"));
|
|
3993
4018
|
return void 0;
|
|
3994
4019
|
}
|
|
3995
4020
|
return callback(files);
|
|
@@ -4022,11 +4047,11 @@ async function cyclomatic(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4022
4047
|
results.sort((a, b) => b.complexity - a.complexity);
|
|
4023
4048
|
for (const { file, name, complexity } of results) {
|
|
4024
4049
|
const exceedsThreshold = options2.threshold !== void 0 && complexity > options2.threshold;
|
|
4025
|
-
const color = exceedsThreshold ?
|
|
4026
|
-
console.log(`${color(`${file}:${name}`)} \u2192 ${
|
|
4050
|
+
const color = exceedsThreshold ? chalk42.red : chalk42.white;
|
|
4051
|
+
console.log(`${color(`${file}:${name}`)} \u2192 ${chalk42.cyan(complexity)}`);
|
|
4027
4052
|
}
|
|
4028
4053
|
console.log(
|
|
4029
|
-
|
|
4054
|
+
chalk42.dim(
|
|
4030
4055
|
`
|
|
4031
4056
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
4032
4057
|
)
|
|
@@ -4038,7 +4063,7 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
4038
4063
|
}
|
|
4039
4064
|
|
|
4040
4065
|
// src/commands/complexity/halstead.ts
|
|
4041
|
-
import
|
|
4066
|
+
import chalk43 from "chalk";
|
|
4042
4067
|
async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
4043
4068
|
withSourceFiles(pattern2, (files) => {
|
|
4044
4069
|
const results = [];
|
|
@@ -4053,13 +4078,13 @@ async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4053
4078
|
results.sort((a, b) => b.metrics.effort - a.metrics.effort);
|
|
4054
4079
|
for (const { file, name, metrics } of results) {
|
|
4055
4080
|
const exceedsThreshold = options2.threshold !== void 0 && metrics.volume > options2.threshold;
|
|
4056
|
-
const color = exceedsThreshold ?
|
|
4081
|
+
const color = exceedsThreshold ? chalk43.red : chalk43.white;
|
|
4057
4082
|
console.log(
|
|
4058
|
-
`${color(`${file}:${name}`)} \u2192 volume: ${
|
|
4083
|
+
`${color(`${file}:${name}`)} \u2192 volume: ${chalk43.cyan(metrics.volume.toFixed(1))}, difficulty: ${chalk43.yellow(metrics.difficulty.toFixed(1))}, effort: ${chalk43.magenta(metrics.effort.toFixed(1))}`
|
|
4059
4084
|
);
|
|
4060
4085
|
}
|
|
4061
4086
|
console.log(
|
|
4062
|
-
|
|
4087
|
+
chalk43.dim(
|
|
4063
4088
|
`
|
|
4064
4089
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
4065
4090
|
)
|
|
@@ -4074,28 +4099,28 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
4074
4099
|
import fs13 from "fs";
|
|
4075
4100
|
|
|
4076
4101
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
4077
|
-
import
|
|
4102
|
+
import chalk44 from "chalk";
|
|
4078
4103
|
function displayMaintainabilityResults(results, threshold) {
|
|
4079
4104
|
const filtered = threshold !== void 0 ? results.filter((r) => r.minMaintainability < threshold) : results;
|
|
4080
4105
|
if (threshold !== void 0 && filtered.length === 0) {
|
|
4081
|
-
console.log(
|
|
4106
|
+
console.log(chalk44.green("All files pass maintainability threshold"));
|
|
4082
4107
|
} else {
|
|
4083
4108
|
for (const { file, avgMaintainability, minMaintainability } of filtered) {
|
|
4084
|
-
const color = threshold !== void 0 ?
|
|
4109
|
+
const color = threshold !== void 0 ? chalk44.red : chalk44.white;
|
|
4085
4110
|
console.log(
|
|
4086
|
-
`${color(file)} \u2192 avg: ${
|
|
4111
|
+
`${color(file)} \u2192 avg: ${chalk44.cyan(avgMaintainability.toFixed(1))}, min: ${chalk44.yellow(minMaintainability.toFixed(1))}`
|
|
4087
4112
|
);
|
|
4088
4113
|
}
|
|
4089
4114
|
}
|
|
4090
|
-
console.log(
|
|
4115
|
+
console.log(chalk44.dim(`
|
|
4091
4116
|
Analyzed ${results.length} files`));
|
|
4092
4117
|
if (filtered.length > 0 && threshold !== void 0) {
|
|
4093
4118
|
console.error(
|
|
4094
|
-
|
|
4119
|
+
chalk44.red(
|
|
4095
4120
|
`
|
|
4096
4121
|
Fail: ${filtered.length} file(s) below threshold ${threshold}. Maintainability index (0\u2013100) is derived from Halstead volume, cyclomatic complexity, and lines of code.
|
|
4097
4122
|
|
|
4098
|
-
\u26A0\uFE0F ${
|
|
4123
|
+
\u26A0\uFE0F ${chalk44.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.`
|
|
4099
4124
|
)
|
|
4100
4125
|
);
|
|
4101
4126
|
process.exit(1);
|
|
@@ -4152,7 +4177,7 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4152
4177
|
|
|
4153
4178
|
// src/commands/complexity/sloc.ts
|
|
4154
4179
|
import fs14 from "fs";
|
|
4155
|
-
import
|
|
4180
|
+
import chalk45 from "chalk";
|
|
4156
4181
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
4157
4182
|
withSourceFiles(pattern2, (files) => {
|
|
4158
4183
|
const results = [];
|
|
@@ -4168,12 +4193,12 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
4168
4193
|
results.sort((a, b) => b.lines - a.lines);
|
|
4169
4194
|
for (const { file, lines } of results) {
|
|
4170
4195
|
const exceedsThreshold = options2.threshold !== void 0 && lines > options2.threshold;
|
|
4171
|
-
const color = exceedsThreshold ?
|
|
4172
|
-
console.log(`${color(file)} \u2192 ${
|
|
4196
|
+
const color = exceedsThreshold ? chalk45.red : chalk45.white;
|
|
4197
|
+
console.log(`${color(file)} \u2192 ${chalk45.cyan(lines)} lines`);
|
|
4173
4198
|
}
|
|
4174
4199
|
const total = results.reduce((sum, r) => sum + r.lines, 0);
|
|
4175
4200
|
console.log(
|
|
4176
|
-
|
|
4201
|
+
chalk45.dim(`
|
|
4177
4202
|
Total: ${total} lines across ${files.length} files`)
|
|
4178
4203
|
);
|
|
4179
4204
|
if (hasViolation) {
|
|
@@ -4187,21 +4212,21 @@ async function analyze(pattern2) {
|
|
|
4187
4212
|
const searchPattern = pattern2.includes("*") || pattern2.includes("/") ? pattern2 : `**/${pattern2}`;
|
|
4188
4213
|
const files = findSourceFiles2(searchPattern);
|
|
4189
4214
|
if (files.length === 0) {
|
|
4190
|
-
console.log(
|
|
4215
|
+
console.log(chalk46.yellow("No files found matching pattern"));
|
|
4191
4216
|
return;
|
|
4192
4217
|
}
|
|
4193
4218
|
if (files.length === 1) {
|
|
4194
4219
|
const file = files[0];
|
|
4195
|
-
console.log(
|
|
4220
|
+
console.log(chalk46.bold.underline("SLOC"));
|
|
4196
4221
|
await sloc(file);
|
|
4197
4222
|
console.log();
|
|
4198
|
-
console.log(
|
|
4223
|
+
console.log(chalk46.bold.underline("Cyclomatic Complexity"));
|
|
4199
4224
|
await cyclomatic(file);
|
|
4200
4225
|
console.log();
|
|
4201
|
-
console.log(
|
|
4226
|
+
console.log(chalk46.bold.underline("Halstead Metrics"));
|
|
4202
4227
|
await halstead(file);
|
|
4203
4228
|
console.log();
|
|
4204
|
-
console.log(
|
|
4229
|
+
console.log(chalk46.bold.underline("Maintainability Index"));
|
|
4205
4230
|
await maintainability(file);
|
|
4206
4231
|
return;
|
|
4207
4232
|
}
|
|
@@ -4228,8 +4253,8 @@ function registerComplexity(program2) {
|
|
|
4228
4253
|
}
|
|
4229
4254
|
|
|
4230
4255
|
// src/commands/deploy/redirect.ts
|
|
4231
|
-
import { existsSync as
|
|
4232
|
-
import
|
|
4256
|
+
import { existsSync as existsSync21, readFileSync as readFileSync16, writeFileSync as writeFileSync16 } from "fs";
|
|
4257
|
+
import chalk47 from "chalk";
|
|
4233
4258
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
4234
4259
|
if (!window.location.pathname.endsWith('/')) {
|
|
4235
4260
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -4237,23 +4262,23 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
4237
4262
|
</script>`;
|
|
4238
4263
|
function redirect() {
|
|
4239
4264
|
const indexPath = "index.html";
|
|
4240
|
-
if (!
|
|
4241
|
-
console.log(
|
|
4265
|
+
if (!existsSync21(indexPath)) {
|
|
4266
|
+
console.log(chalk47.yellow("No index.html found"));
|
|
4242
4267
|
return;
|
|
4243
4268
|
}
|
|
4244
4269
|
const content = readFileSync16(indexPath, "utf-8");
|
|
4245
4270
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
4246
|
-
console.log(
|
|
4271
|
+
console.log(chalk47.dim("Trailing slash script already present"));
|
|
4247
4272
|
return;
|
|
4248
4273
|
}
|
|
4249
4274
|
const headCloseIndex = content.indexOf("</head>");
|
|
4250
4275
|
if (headCloseIndex === -1) {
|
|
4251
|
-
console.log(
|
|
4276
|
+
console.log(chalk47.red("Could not find </head> tag in index.html"));
|
|
4252
4277
|
return;
|
|
4253
4278
|
}
|
|
4254
4279
|
const newContent = content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT + "\n " + content.slice(headCloseIndex);
|
|
4255
4280
|
writeFileSync16(indexPath, newContent);
|
|
4256
|
-
console.log(
|
|
4281
|
+
console.log(chalk47.green("Added trailing slash redirect to index.html"));
|
|
4257
4282
|
}
|
|
4258
4283
|
|
|
4259
4284
|
// src/commands/registerDeploy.ts
|
|
@@ -4280,7 +4305,7 @@ function loadBlogSkipDays(repoName) {
|
|
|
4280
4305
|
|
|
4281
4306
|
// src/commands/devlog/shared.ts
|
|
4282
4307
|
import { execSync as execSync15 } from "child_process";
|
|
4283
|
-
import
|
|
4308
|
+
import chalk48 from "chalk";
|
|
4284
4309
|
|
|
4285
4310
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
4286
4311
|
import { readdirSync, readFileSync as readFileSync17 } from "fs";
|
|
@@ -4367,13 +4392,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
4367
4392
|
}
|
|
4368
4393
|
function printCommitsWithFiles(commits, ignore2, verbose) {
|
|
4369
4394
|
for (const commit2 of commits) {
|
|
4370
|
-
console.log(` ${
|
|
4395
|
+
console.log(` ${chalk48.yellow(commit2.hash)} ${commit2.message}`);
|
|
4371
4396
|
if (verbose) {
|
|
4372
4397
|
const visibleFiles = commit2.files.filter(
|
|
4373
4398
|
(file) => !ignore2.some((p) => file.startsWith(p))
|
|
4374
4399
|
);
|
|
4375
4400
|
for (const file of visibleFiles) {
|
|
4376
|
-
console.log(` ${
|
|
4401
|
+
console.log(` ${chalk48.dim(file)}`);
|
|
4377
4402
|
}
|
|
4378
4403
|
}
|
|
4379
4404
|
}
|
|
@@ -4398,15 +4423,15 @@ function parseGitLogCommits(output, ignore2, afterDate) {
|
|
|
4398
4423
|
}
|
|
4399
4424
|
|
|
4400
4425
|
// src/commands/devlog/list/printDateHeader.ts
|
|
4401
|
-
import
|
|
4426
|
+
import chalk49 from "chalk";
|
|
4402
4427
|
function printDateHeader(date, isSkipped, entries) {
|
|
4403
4428
|
if (isSkipped) {
|
|
4404
|
-
console.log(`${
|
|
4429
|
+
console.log(`${chalk49.bold.blue(date)} ${chalk49.dim("skipped")}`);
|
|
4405
4430
|
} else if (entries && entries.length > 0) {
|
|
4406
|
-
const entryInfo = entries.map((e) => `${
|
|
4407
|
-
console.log(`${
|
|
4431
|
+
const entryInfo = entries.map((e) => `${chalk49.green(e.version)} ${e.title}`).join(" | ");
|
|
4432
|
+
console.log(`${chalk49.bold.blue(date)} ${entryInfo}`);
|
|
4408
4433
|
} else {
|
|
4409
|
-
console.log(`${
|
|
4434
|
+
console.log(`${chalk49.bold.blue(date)} ${chalk49.red("\u26A0 devlog missing")}`);
|
|
4410
4435
|
}
|
|
4411
4436
|
}
|
|
4412
4437
|
|
|
@@ -4509,24 +4534,24 @@ function bumpVersion(version2, type) {
|
|
|
4509
4534
|
|
|
4510
4535
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
4511
4536
|
import { execSync as execSync18 } from "child_process";
|
|
4512
|
-
import
|
|
4537
|
+
import chalk51 from "chalk";
|
|
4513
4538
|
|
|
4514
4539
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
4515
|
-
import
|
|
4540
|
+
import chalk50 from "chalk";
|
|
4516
4541
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
4517
4542
|
if (conventional && firstHash) {
|
|
4518
4543
|
const version2 = getVersionAtCommit(firstHash);
|
|
4519
4544
|
if (version2) {
|
|
4520
|
-
console.log(`${
|
|
4545
|
+
console.log(`${chalk50.bold("version:")} ${stripToMinor(version2)}`);
|
|
4521
4546
|
} else {
|
|
4522
|
-
console.log(`${
|
|
4547
|
+
console.log(`${chalk50.bold("version:")} ${chalk50.red("unknown")}`);
|
|
4523
4548
|
}
|
|
4524
4549
|
} else if (patchVersion && minorVersion) {
|
|
4525
4550
|
console.log(
|
|
4526
|
-
`${
|
|
4551
|
+
`${chalk50.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
4527
4552
|
);
|
|
4528
4553
|
} else {
|
|
4529
|
-
console.log(`${
|
|
4554
|
+
console.log(`${chalk50.bold("version:")} v0.1 (initial)`);
|
|
4530
4555
|
}
|
|
4531
4556
|
}
|
|
4532
4557
|
|
|
@@ -4573,16 +4598,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
4573
4598
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
4574
4599
|
}
|
|
4575
4600
|
function logName(repoName) {
|
|
4576
|
-
console.log(`${
|
|
4601
|
+
console.log(`${chalk51.bold("name:")} ${repoName}`);
|
|
4577
4602
|
}
|
|
4578
4603
|
function displayNextEntry(ctx, targetDate, commits) {
|
|
4579
4604
|
logName(ctx.repoName);
|
|
4580
4605
|
printVersionInfo(ctx.config, ctx.lastInfo, commits[0]?.hash);
|
|
4581
|
-
console.log(
|
|
4606
|
+
console.log(chalk51.bold.blue(targetDate));
|
|
4582
4607
|
printCommitsWithFiles(commits, ctx.ignore, ctx.verbose);
|
|
4583
4608
|
}
|
|
4584
4609
|
function logNoCommits(lastInfo) {
|
|
4585
|
-
console.log(
|
|
4610
|
+
console.log(chalk51.dim(noCommitsMessage(!!lastInfo)));
|
|
4586
4611
|
}
|
|
4587
4612
|
|
|
4588
4613
|
// src/commands/devlog/next/index.ts
|
|
@@ -4623,11 +4648,11 @@ function next2(options2) {
|
|
|
4623
4648
|
import { execSync as execSync19 } from "child_process";
|
|
4624
4649
|
|
|
4625
4650
|
// src/commands/devlog/repos/printReposTable.ts
|
|
4626
|
-
import
|
|
4651
|
+
import chalk52 from "chalk";
|
|
4627
4652
|
function colorStatus(status2) {
|
|
4628
|
-
if (status2 === "missing") return
|
|
4629
|
-
if (status2 === "outdated") return
|
|
4630
|
-
return
|
|
4653
|
+
if (status2 === "missing") return chalk52.red(status2);
|
|
4654
|
+
if (status2 === "outdated") return chalk52.yellow(status2);
|
|
4655
|
+
return chalk52.green(status2);
|
|
4631
4656
|
}
|
|
4632
4657
|
function formatRow(row, nameWidth) {
|
|
4633
4658
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -4641,8 +4666,8 @@ function printReposTable(rows) {
|
|
|
4641
4666
|
"Last Devlog".padEnd(11),
|
|
4642
4667
|
"Status"
|
|
4643
4668
|
].join(" ");
|
|
4644
|
-
console.log(
|
|
4645
|
-
console.log(
|
|
4669
|
+
console.log(chalk52.dim(header));
|
|
4670
|
+
console.log(chalk52.dim("-".repeat(header.length)));
|
|
4646
4671
|
for (const row of rows) {
|
|
4647
4672
|
console.log(formatRow(row, nameWidth));
|
|
4648
4673
|
}
|
|
@@ -4700,14 +4725,14 @@ function repos(options2) {
|
|
|
4700
4725
|
// src/commands/devlog/skip.ts
|
|
4701
4726
|
import { writeFileSync as writeFileSync17 } from "fs";
|
|
4702
4727
|
import { join as join16 } from "path";
|
|
4703
|
-
import
|
|
4728
|
+
import chalk53 from "chalk";
|
|
4704
4729
|
import { stringify as stringifyYaml4 } from "yaml";
|
|
4705
4730
|
function getBlogConfigPath() {
|
|
4706
4731
|
return join16(BLOG_REPO_ROOT, "assist.yml");
|
|
4707
4732
|
}
|
|
4708
4733
|
function skip(date) {
|
|
4709
4734
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
4710
|
-
console.log(
|
|
4735
|
+
console.log(chalk53.red("Invalid date format. Use YYYY-MM-DD"));
|
|
4711
4736
|
process.exit(1);
|
|
4712
4737
|
}
|
|
4713
4738
|
const repoName = getRepoName();
|
|
@@ -4718,7 +4743,7 @@ function skip(date) {
|
|
|
4718
4743
|
const skipDays = skip2[repoName] ?? [];
|
|
4719
4744
|
if (skipDays.includes(date)) {
|
|
4720
4745
|
console.log(
|
|
4721
|
-
|
|
4746
|
+
chalk53.yellow(`${date} is already in skip list for ${repoName}`)
|
|
4722
4747
|
);
|
|
4723
4748
|
return;
|
|
4724
4749
|
}
|
|
@@ -4728,20 +4753,20 @@ function skip(date) {
|
|
|
4728
4753
|
devlog.skip = skip2;
|
|
4729
4754
|
config.devlog = devlog;
|
|
4730
4755
|
writeFileSync17(configPath, stringifyYaml4(config, { lineWidth: 0 }));
|
|
4731
|
-
console.log(
|
|
4756
|
+
console.log(chalk53.green(`Added ${date} to skip list for ${repoName}`));
|
|
4732
4757
|
}
|
|
4733
4758
|
|
|
4734
4759
|
// src/commands/devlog/version.ts
|
|
4735
|
-
import
|
|
4760
|
+
import chalk54 from "chalk";
|
|
4736
4761
|
function version() {
|
|
4737
4762
|
const config = loadConfig();
|
|
4738
4763
|
const name = getRepoName();
|
|
4739
4764
|
const lastInfo = getLastVersionInfo(name, config);
|
|
4740
4765
|
const lastVersion = lastInfo?.version ?? null;
|
|
4741
4766
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
4742
|
-
console.log(`${
|
|
4743
|
-
console.log(`${
|
|
4744
|
-
console.log(`${
|
|
4767
|
+
console.log(`${chalk54.bold("name:")} ${name}`);
|
|
4768
|
+
console.log(`${chalk54.bold("last:")} ${lastVersion ?? chalk54.dim("none")}`);
|
|
4769
|
+
console.log(`${chalk54.bold("next:")} ${nextVersion ?? chalk54.dim("none")}`);
|
|
4745
4770
|
}
|
|
4746
4771
|
|
|
4747
4772
|
// src/commands/registerDevlog.ts
|
|
@@ -4765,15 +4790,15 @@ function registerDevlog(program2) {
|
|
|
4765
4790
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
4766
4791
|
import { closeSync, openSync, readdirSync as readdirSync2 } from "fs";
|
|
4767
4792
|
import { join as join17 } from "path";
|
|
4768
|
-
import
|
|
4793
|
+
import chalk55 from "chalk";
|
|
4769
4794
|
|
|
4770
4795
|
// src/shared/findRepoRoot.ts
|
|
4771
|
-
import { existsSync as
|
|
4796
|
+
import { existsSync as existsSync22 } from "fs";
|
|
4772
4797
|
import path21 from "path";
|
|
4773
4798
|
function findRepoRoot(dir) {
|
|
4774
4799
|
let current = dir;
|
|
4775
4800
|
while (current !== path21.dirname(current)) {
|
|
4776
|
-
if (
|
|
4801
|
+
if (existsSync22(path21.join(current, ".git"))) {
|
|
4777
4802
|
return current;
|
|
4778
4803
|
}
|
|
4779
4804
|
current = path21.dirname(current);
|
|
@@ -4828,14 +4853,14 @@ function checkBuildLocks(startDir) {
|
|
|
4828
4853
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
4829
4854
|
if (locked) {
|
|
4830
4855
|
console.error(
|
|
4831
|
-
|
|
4856
|
+
chalk55.red("Build output locked (is VS debugging?): ") + locked
|
|
4832
4857
|
);
|
|
4833
4858
|
process.exit(1);
|
|
4834
4859
|
}
|
|
4835
4860
|
}
|
|
4836
4861
|
async function checkBuildLocksCommand() {
|
|
4837
4862
|
checkBuildLocks();
|
|
4838
|
-
console.log(
|
|
4863
|
+
console.log(chalk55.green("No build locks detected"));
|
|
4839
4864
|
}
|
|
4840
4865
|
|
|
4841
4866
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -4934,30 +4959,30 @@ function escapeRegex(s) {
|
|
|
4934
4959
|
}
|
|
4935
4960
|
|
|
4936
4961
|
// src/commands/dotnet/printTree.ts
|
|
4937
|
-
import
|
|
4962
|
+
import chalk56 from "chalk";
|
|
4938
4963
|
function printNodes(nodes, prefix2) {
|
|
4939
4964
|
for (let i = 0; i < nodes.length; i++) {
|
|
4940
4965
|
const isLast = i === nodes.length - 1;
|
|
4941
4966
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
4942
4967
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
4943
4968
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
4944
|
-
const label2 = isMissing ?
|
|
4969
|
+
const label2 = isMissing ? chalk56.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
4945
4970
|
console.log(`${prefix2}${connector}${label2}`);
|
|
4946
4971
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
4947
4972
|
}
|
|
4948
4973
|
}
|
|
4949
4974
|
function printTree(tree, totalCount, solutions) {
|
|
4950
|
-
console.log(
|
|
4951
|
-
console.log(
|
|
4975
|
+
console.log(chalk56.bold("\nProject Dependency Tree"));
|
|
4976
|
+
console.log(chalk56.cyan(tree.relativePath));
|
|
4952
4977
|
printNodes(tree.children, "");
|
|
4953
|
-
console.log(
|
|
4978
|
+
console.log(chalk56.dim(`
|
|
4954
4979
|
${totalCount} projects total (including root)`));
|
|
4955
|
-
console.log(
|
|
4980
|
+
console.log(chalk56.bold("\nSolution Membership"));
|
|
4956
4981
|
if (solutions.length === 0) {
|
|
4957
|
-
console.log(
|
|
4982
|
+
console.log(chalk56.yellow(" Not found in any .sln"));
|
|
4958
4983
|
} else {
|
|
4959
4984
|
for (const sln of solutions) {
|
|
4960
|
-
console.log(` ${
|
|
4985
|
+
console.log(` ${chalk56.green(sln)}`);
|
|
4961
4986
|
}
|
|
4962
4987
|
}
|
|
4963
4988
|
console.log();
|
|
@@ -4984,18 +5009,18 @@ function printJson(tree, totalCount, solutions) {
|
|
|
4984
5009
|
}
|
|
4985
5010
|
|
|
4986
5011
|
// src/commands/dotnet/resolveCsproj.ts
|
|
4987
|
-
import { existsSync as
|
|
5012
|
+
import { existsSync as existsSync23 } from "fs";
|
|
4988
5013
|
import path24 from "path";
|
|
4989
|
-
import
|
|
5014
|
+
import chalk57 from "chalk";
|
|
4990
5015
|
function resolveCsproj(csprojPath) {
|
|
4991
5016
|
const resolved = path24.resolve(csprojPath);
|
|
4992
|
-
if (!
|
|
4993
|
-
console.error(
|
|
5017
|
+
if (!existsSync23(resolved)) {
|
|
5018
|
+
console.error(chalk57.red(`File not found: ${resolved}`));
|
|
4994
5019
|
process.exit(1);
|
|
4995
5020
|
}
|
|
4996
5021
|
const repoRoot = findRepoRoot(path24.dirname(resolved));
|
|
4997
5022
|
if (!repoRoot) {
|
|
4998
|
-
console.error(
|
|
5023
|
+
console.error(chalk57.red("Could not find git repository root"));
|
|
4999
5024
|
process.exit(1);
|
|
5000
5025
|
}
|
|
5001
5026
|
return { resolved, repoRoot };
|
|
@@ -5045,12 +5070,12 @@ function getChangedCsFiles(scope) {
|
|
|
5045
5070
|
}
|
|
5046
5071
|
|
|
5047
5072
|
// src/commands/dotnet/inSln.ts
|
|
5048
|
-
import
|
|
5073
|
+
import chalk58 from "chalk";
|
|
5049
5074
|
async function inSln(csprojPath) {
|
|
5050
5075
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
5051
5076
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
5052
5077
|
if (solutions.length === 0) {
|
|
5053
|
-
console.log(
|
|
5078
|
+
console.log(chalk58.yellow("Not found in any .sln file"));
|
|
5054
5079
|
process.exit(1);
|
|
5055
5080
|
}
|
|
5056
5081
|
for (const sln of solutions) {
|
|
@@ -5059,7 +5084,7 @@ async function inSln(csprojPath) {
|
|
|
5059
5084
|
}
|
|
5060
5085
|
|
|
5061
5086
|
// src/commands/dotnet/inspect.ts
|
|
5062
|
-
import
|
|
5087
|
+
import chalk64 from "chalk";
|
|
5063
5088
|
|
|
5064
5089
|
// src/shared/formatElapsed.ts
|
|
5065
5090
|
function formatElapsed(ms) {
|
|
@@ -5071,12 +5096,12 @@ function formatElapsed(ms) {
|
|
|
5071
5096
|
}
|
|
5072
5097
|
|
|
5073
5098
|
// src/commands/dotnet/displayIssues.ts
|
|
5074
|
-
import
|
|
5099
|
+
import chalk59 from "chalk";
|
|
5075
5100
|
var SEVERITY_COLOR = {
|
|
5076
|
-
ERROR:
|
|
5077
|
-
WARNING:
|
|
5078
|
-
SUGGESTION:
|
|
5079
|
-
HINT:
|
|
5101
|
+
ERROR: chalk59.red,
|
|
5102
|
+
WARNING: chalk59.yellow,
|
|
5103
|
+
SUGGESTION: chalk59.cyan,
|
|
5104
|
+
HINT: chalk59.dim
|
|
5080
5105
|
};
|
|
5081
5106
|
function groupByFile(issues) {
|
|
5082
5107
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -5092,15 +5117,15 @@ function groupByFile(issues) {
|
|
|
5092
5117
|
}
|
|
5093
5118
|
function displayIssues(issues) {
|
|
5094
5119
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
5095
|
-
console.log(
|
|
5120
|
+
console.log(chalk59.bold(file));
|
|
5096
5121
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
5097
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
5122
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk59.white;
|
|
5098
5123
|
console.log(
|
|
5099
|
-
` ${
|
|
5124
|
+
` ${chalk59.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
5100
5125
|
);
|
|
5101
5126
|
}
|
|
5102
5127
|
}
|
|
5103
|
-
console.log(
|
|
5128
|
+
console.log(chalk59.dim(`
|
|
5104
5129
|
${issues.length} issue(s) found`));
|
|
5105
5130
|
}
|
|
5106
5131
|
|
|
@@ -5157,14 +5182,14 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
5157
5182
|
}
|
|
5158
5183
|
|
|
5159
5184
|
// src/commands/dotnet/resolveSolution.ts
|
|
5160
|
-
import { existsSync as
|
|
5185
|
+
import { existsSync as existsSync24 } from "fs";
|
|
5161
5186
|
import path25 from "path";
|
|
5162
|
-
import
|
|
5187
|
+
import chalk61 from "chalk";
|
|
5163
5188
|
|
|
5164
5189
|
// src/commands/dotnet/findSolution.ts
|
|
5165
5190
|
import { readdirSync as readdirSync4 } from "fs";
|
|
5166
5191
|
import { dirname as dirname16, join as join18 } from "path";
|
|
5167
|
-
import
|
|
5192
|
+
import chalk60 from "chalk";
|
|
5168
5193
|
function findSlnInDir(dir) {
|
|
5169
5194
|
try {
|
|
5170
5195
|
return readdirSync4(dir).filter((f) => f.endsWith(".sln")).map((f) => join18(dir, f));
|
|
@@ -5180,17 +5205,17 @@ function findSolution() {
|
|
|
5180
5205
|
const slnFiles = findSlnInDir(current);
|
|
5181
5206
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
5182
5207
|
if (slnFiles.length > 1) {
|
|
5183
|
-
console.error(
|
|
5208
|
+
console.error(chalk60.red(`Multiple .sln files found in ${current}:`));
|
|
5184
5209
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
5185
5210
|
console.error(
|
|
5186
|
-
|
|
5211
|
+
chalk60.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
5187
5212
|
);
|
|
5188
5213
|
process.exit(1);
|
|
5189
5214
|
}
|
|
5190
5215
|
if (current === ceiling) break;
|
|
5191
5216
|
current = dirname16(current);
|
|
5192
5217
|
}
|
|
5193
|
-
console.error(
|
|
5218
|
+
console.error(chalk60.red("No .sln file found between cwd and repo root"));
|
|
5194
5219
|
process.exit(1);
|
|
5195
5220
|
}
|
|
5196
5221
|
|
|
@@ -5198,8 +5223,8 @@ function findSolution() {
|
|
|
5198
5223
|
function resolveSolution(sln) {
|
|
5199
5224
|
if (sln) {
|
|
5200
5225
|
const resolved = path25.resolve(sln);
|
|
5201
|
-
if (!
|
|
5202
|
-
console.error(
|
|
5226
|
+
if (!existsSync24(resolved)) {
|
|
5227
|
+
console.error(chalk61.red(`Solution file not found: ${resolved}`));
|
|
5203
5228
|
process.exit(1);
|
|
5204
5229
|
}
|
|
5205
5230
|
return resolved;
|
|
@@ -5238,17 +5263,17 @@ function parseInspectReport(json) {
|
|
|
5238
5263
|
|
|
5239
5264
|
// src/commands/dotnet/runInspectCode.ts
|
|
5240
5265
|
import { execSync as execSync21 } from "child_process";
|
|
5241
|
-
import { existsSync as
|
|
5266
|
+
import { existsSync as existsSync25, readFileSync as readFileSync20, unlinkSync as unlinkSync4 } from "fs";
|
|
5242
5267
|
import { tmpdir as tmpdir2 } from "os";
|
|
5243
5268
|
import path26 from "path";
|
|
5244
|
-
import
|
|
5269
|
+
import chalk62 from "chalk";
|
|
5245
5270
|
function assertJbInstalled() {
|
|
5246
5271
|
try {
|
|
5247
5272
|
execSync21("jb inspectcode --version", { stdio: "pipe" });
|
|
5248
5273
|
} catch {
|
|
5249
|
-
console.error(
|
|
5274
|
+
console.error(chalk62.red("jb is not installed. Install with:"));
|
|
5250
5275
|
console.error(
|
|
5251
|
-
|
|
5276
|
+
chalk62.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
5252
5277
|
);
|
|
5253
5278
|
process.exit(1);
|
|
5254
5279
|
}
|
|
@@ -5266,11 +5291,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
5266
5291
|
if (err && typeof err === "object" && "stderr" in err) {
|
|
5267
5292
|
process.stderr.write(err.stderr);
|
|
5268
5293
|
}
|
|
5269
|
-
console.error(
|
|
5294
|
+
console.error(chalk62.red("jb inspectcode failed"));
|
|
5270
5295
|
process.exit(1);
|
|
5271
5296
|
}
|
|
5272
|
-
if (!
|
|
5273
|
-
console.error(
|
|
5297
|
+
if (!existsSync25(reportPath)) {
|
|
5298
|
+
console.error(chalk62.red("Report file not generated"));
|
|
5274
5299
|
process.exit(1);
|
|
5275
5300
|
}
|
|
5276
5301
|
const xml = readFileSync20(reportPath, "utf-8");
|
|
@@ -5280,7 +5305,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
5280
5305
|
|
|
5281
5306
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
5282
5307
|
import { execSync as execSync22 } from "child_process";
|
|
5283
|
-
import
|
|
5308
|
+
import chalk63 from "chalk";
|
|
5284
5309
|
function resolveMsbuildPath() {
|
|
5285
5310
|
const config = loadConfig();
|
|
5286
5311
|
const buildConfig = config.run?.find((r) => r.name === "build");
|
|
@@ -5291,9 +5316,9 @@ function assertMsbuildInstalled() {
|
|
|
5291
5316
|
try {
|
|
5292
5317
|
execSync22(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
5293
5318
|
} catch {
|
|
5294
|
-
console.error(
|
|
5319
|
+
console.error(chalk63.red(`msbuild not found at: ${msbuild}`));
|
|
5295
5320
|
console.error(
|
|
5296
|
-
|
|
5321
|
+
chalk63.yellow(
|
|
5297
5322
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
5298
5323
|
)
|
|
5299
5324
|
);
|
|
@@ -5340,17 +5365,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
5340
5365
|
// src/commands/dotnet/inspect.ts
|
|
5341
5366
|
function logScope(changedFiles) {
|
|
5342
5367
|
if (changedFiles === null) {
|
|
5343
|
-
console.log(
|
|
5368
|
+
console.log(chalk64.dim("Inspecting full solution..."));
|
|
5344
5369
|
} else {
|
|
5345
5370
|
console.log(
|
|
5346
|
-
|
|
5371
|
+
chalk64.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
5347
5372
|
);
|
|
5348
5373
|
}
|
|
5349
5374
|
}
|
|
5350
5375
|
function reportResults(issues, elapsed) {
|
|
5351
5376
|
if (issues.length > 0) displayIssues(issues);
|
|
5352
|
-
else console.log(
|
|
5353
|
-
console.log(
|
|
5377
|
+
else console.log(chalk64.green("No issues found"));
|
|
5378
|
+
console.log(chalk64.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
5354
5379
|
if (issues.length > 0) process.exit(1);
|
|
5355
5380
|
}
|
|
5356
5381
|
async function inspect(sln, options2) {
|
|
@@ -5361,7 +5386,7 @@ async function inspect(sln, options2) {
|
|
|
5361
5386
|
const scope = parseScope(options2.scope);
|
|
5362
5387
|
const changedFiles = getChangedCsFiles(scope);
|
|
5363
5388
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
5364
|
-
console.log(
|
|
5389
|
+
console.log(chalk64.green("No changed .cs files found"));
|
|
5365
5390
|
return;
|
|
5366
5391
|
}
|
|
5367
5392
|
logScope(changedFiles);
|
|
@@ -5387,7 +5412,7 @@ function registerDotnet(program2) {
|
|
|
5387
5412
|
}
|
|
5388
5413
|
|
|
5389
5414
|
// src/commands/jira/acceptanceCriteria.ts
|
|
5390
|
-
import
|
|
5415
|
+
import chalk66 from "chalk";
|
|
5391
5416
|
|
|
5392
5417
|
// src/commands/jira/adfToText.ts
|
|
5393
5418
|
function renderInline(node) {
|
|
@@ -5448,7 +5473,7 @@ function adfToText(doc) {
|
|
|
5448
5473
|
|
|
5449
5474
|
// src/commands/jira/fetchIssue.ts
|
|
5450
5475
|
import { execSync as execSync23 } from "child_process";
|
|
5451
|
-
import
|
|
5476
|
+
import chalk65 from "chalk";
|
|
5452
5477
|
function fetchIssue(issueKey, fields) {
|
|
5453
5478
|
let result;
|
|
5454
5479
|
try {
|
|
@@ -5461,15 +5486,15 @@ function fetchIssue(issueKey, fields) {
|
|
|
5461
5486
|
const stderr = error.stderr;
|
|
5462
5487
|
if (stderr.includes("unauthorized")) {
|
|
5463
5488
|
console.error(
|
|
5464
|
-
|
|
5489
|
+
chalk65.red("Jira authentication expired."),
|
|
5465
5490
|
"Run",
|
|
5466
|
-
|
|
5491
|
+
chalk65.cyan("assist jira auth"),
|
|
5467
5492
|
"to re-authenticate."
|
|
5468
5493
|
);
|
|
5469
5494
|
process.exit(1);
|
|
5470
5495
|
}
|
|
5471
5496
|
}
|
|
5472
|
-
console.error(
|
|
5497
|
+
console.error(chalk65.red(`Failed to fetch ${issueKey}.`));
|
|
5473
5498
|
process.exit(1);
|
|
5474
5499
|
}
|
|
5475
5500
|
return JSON.parse(result);
|
|
@@ -5483,7 +5508,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
5483
5508
|
const parsed = fetchIssue(issueKey, field);
|
|
5484
5509
|
const acValue = parsed?.fields?.[field];
|
|
5485
5510
|
if (!acValue) {
|
|
5486
|
-
console.log(
|
|
5511
|
+
console.log(chalk66.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
5487
5512
|
return;
|
|
5488
5513
|
}
|
|
5489
5514
|
if (typeof acValue === "string") {
|
|
@@ -5501,7 +5526,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
5501
5526
|
import { execSync as execSync24 } from "child_process";
|
|
5502
5527
|
|
|
5503
5528
|
// src/shared/loadJson.ts
|
|
5504
|
-
import { existsSync as
|
|
5529
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync5, readFileSync as readFileSync21, writeFileSync as writeFileSync18 } from "fs";
|
|
5505
5530
|
import { homedir as homedir6 } from "os";
|
|
5506
5531
|
import { join as join19 } from "path";
|
|
5507
5532
|
function getStoreDir() {
|
|
@@ -5512,7 +5537,7 @@ function getStorePath(filename) {
|
|
|
5512
5537
|
}
|
|
5513
5538
|
function loadJson(filename) {
|
|
5514
5539
|
const path44 = getStorePath(filename);
|
|
5515
|
-
if (
|
|
5540
|
+
if (existsSync26(path44)) {
|
|
5516
5541
|
try {
|
|
5517
5542
|
return JSON.parse(readFileSync21(path44, "utf-8"));
|
|
5518
5543
|
} catch {
|
|
@@ -5523,7 +5548,7 @@ function loadJson(filename) {
|
|
|
5523
5548
|
}
|
|
5524
5549
|
function saveJson(filename, data) {
|
|
5525
5550
|
const dir = getStoreDir();
|
|
5526
|
-
if (!
|
|
5551
|
+
if (!existsSync26(dir)) {
|
|
5527
5552
|
mkdirSync5(dir, { recursive: true });
|
|
5528
5553
|
}
|
|
5529
5554
|
writeFileSync18(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
@@ -5578,14 +5603,14 @@ async function jiraAuth() {
|
|
|
5578
5603
|
}
|
|
5579
5604
|
|
|
5580
5605
|
// src/commands/jira/viewIssue.ts
|
|
5581
|
-
import
|
|
5606
|
+
import chalk67 from "chalk";
|
|
5582
5607
|
function viewIssue(issueKey) {
|
|
5583
5608
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
5584
5609
|
const fields = parsed?.fields;
|
|
5585
5610
|
const summary = fields?.summary;
|
|
5586
5611
|
const description = fields?.description;
|
|
5587
5612
|
if (summary) {
|
|
5588
|
-
console.log(
|
|
5613
|
+
console.log(chalk67.bold(summary));
|
|
5589
5614
|
}
|
|
5590
5615
|
if (description) {
|
|
5591
5616
|
if (summary) console.log();
|
|
@@ -5599,7 +5624,7 @@ function viewIssue(issueKey) {
|
|
|
5599
5624
|
}
|
|
5600
5625
|
if (!summary && !description) {
|
|
5601
5626
|
console.log(
|
|
5602
|
-
|
|
5627
|
+
chalk67.yellow(`No summary or description found on ${issueKey}.`)
|
|
5603
5628
|
);
|
|
5604
5629
|
}
|
|
5605
5630
|
}
|
|
@@ -5613,7 +5638,7 @@ function registerJira(program2) {
|
|
|
5613
5638
|
}
|
|
5614
5639
|
|
|
5615
5640
|
// src/commands/news/add/index.ts
|
|
5616
|
-
import
|
|
5641
|
+
import chalk68 from "chalk";
|
|
5617
5642
|
import enquirer7 from "enquirer";
|
|
5618
5643
|
async function add2(url) {
|
|
5619
5644
|
if (!url) {
|
|
@@ -5636,17 +5661,17 @@ async function add2(url) {
|
|
|
5636
5661
|
const news = config.news ?? {};
|
|
5637
5662
|
const feeds = news.feeds ?? [];
|
|
5638
5663
|
if (feeds.includes(url)) {
|
|
5639
|
-
console.log(
|
|
5664
|
+
console.log(chalk68.yellow("Feed already exists in config"));
|
|
5640
5665
|
return;
|
|
5641
5666
|
}
|
|
5642
5667
|
feeds.push(url);
|
|
5643
5668
|
config.news = { ...news, feeds };
|
|
5644
5669
|
saveGlobalConfig(config);
|
|
5645
|
-
console.log(
|
|
5670
|
+
console.log(chalk68.green(`Added feed: ${url}`));
|
|
5646
5671
|
}
|
|
5647
5672
|
|
|
5648
5673
|
// src/commands/news/web/handleRequest.ts
|
|
5649
|
-
import
|
|
5674
|
+
import chalk69 from "chalk";
|
|
5650
5675
|
|
|
5651
5676
|
// src/commands/news/web/shared.ts
|
|
5652
5677
|
import { decodeHTML } from "entities";
|
|
@@ -5782,17 +5807,17 @@ function prefetch() {
|
|
|
5782
5807
|
const config = loadConfig();
|
|
5783
5808
|
const total = config.news.feeds.length;
|
|
5784
5809
|
if (total === 0) return;
|
|
5785
|
-
process.stdout.write(
|
|
5810
|
+
process.stdout.write(chalk69.dim(`Fetching ${total} feed(s)\u2026 `));
|
|
5786
5811
|
prefetchPromise = fetchFeeds(config.news.feeds, (done2, t) => {
|
|
5787
5812
|
const width = 20;
|
|
5788
5813
|
const filled = Math.round(done2 / t * width);
|
|
5789
5814
|
const bar = `${"\u2588".repeat(filled)}${"\u2591".repeat(width - filled)}`;
|
|
5790
5815
|
process.stdout.write(
|
|
5791
|
-
`\r${
|
|
5816
|
+
`\r${chalk69.dim(`Fetching feeds ${bar} ${done2}/${t}`)}`
|
|
5792
5817
|
);
|
|
5793
5818
|
}).then((items) => {
|
|
5794
5819
|
process.stdout.write(
|
|
5795
|
-
`\r${
|
|
5820
|
+
`\r${chalk69.green(`Fetched ${items.length} items from ${total} feed(s)`)}
|
|
5796
5821
|
`
|
|
5797
5822
|
);
|
|
5798
5823
|
cachedItems = items;
|
|
@@ -5960,7 +5985,7 @@ import { tmpdir as tmpdir4 } from "os";
|
|
|
5960
5985
|
import { join as join22 } from "path";
|
|
5961
5986
|
|
|
5962
5987
|
// src/commands/prs/loadCommentsCache.ts
|
|
5963
|
-
import { existsSync as
|
|
5988
|
+
import { existsSync as existsSync27, readFileSync as readFileSync22, unlinkSync as unlinkSync6 } from "fs";
|
|
5964
5989
|
import { join as join21 } from "path";
|
|
5965
5990
|
import { parse as parse2 } from "yaml";
|
|
5966
5991
|
function getCachePath(prNumber) {
|
|
@@ -5968,7 +5993,7 @@ function getCachePath(prNumber) {
|
|
|
5968
5993
|
}
|
|
5969
5994
|
function loadCommentsCache(prNumber) {
|
|
5970
5995
|
const cachePath = getCachePath(prNumber);
|
|
5971
|
-
if (!
|
|
5996
|
+
if (!existsSync27(cachePath)) {
|
|
5972
5997
|
return null;
|
|
5973
5998
|
}
|
|
5974
5999
|
const content = readFileSync22(cachePath, "utf-8");
|
|
@@ -5976,7 +6001,7 @@ function loadCommentsCache(prNumber) {
|
|
|
5976
6001
|
}
|
|
5977
6002
|
function deleteCommentsCache(prNumber) {
|
|
5978
6003
|
const cachePath = getCachePath(prNumber);
|
|
5979
|
-
if (
|
|
6004
|
+
if (existsSync27(cachePath)) {
|
|
5980
6005
|
unlinkSync6(cachePath);
|
|
5981
6006
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
5982
6007
|
}
|
|
@@ -6073,7 +6098,7 @@ function fixed(commentId, sha) {
|
|
|
6073
6098
|
}
|
|
6074
6099
|
|
|
6075
6100
|
// src/commands/prs/listComments/index.ts
|
|
6076
|
-
import { existsSync as
|
|
6101
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync6, writeFileSync as writeFileSync22 } from "fs";
|
|
6077
6102
|
import { join as join24 } from "path";
|
|
6078
6103
|
import { stringify } from "yaml";
|
|
6079
6104
|
|
|
@@ -6153,20 +6178,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
6153
6178
|
}
|
|
6154
6179
|
|
|
6155
6180
|
// src/commands/prs/listComments/printComments.ts
|
|
6156
|
-
import
|
|
6181
|
+
import chalk70 from "chalk";
|
|
6157
6182
|
function formatForHuman(comment2) {
|
|
6158
6183
|
if (comment2.type === "review") {
|
|
6159
|
-
const stateColor = comment2.state === "APPROVED" ?
|
|
6184
|
+
const stateColor = comment2.state === "APPROVED" ? chalk70.green : comment2.state === "CHANGES_REQUESTED" ? chalk70.red : chalk70.yellow;
|
|
6160
6185
|
return [
|
|
6161
|
-
`${
|
|
6186
|
+
`${chalk70.cyan("Review")} by ${chalk70.bold(comment2.user)} ${stateColor(`[${comment2.state}]`)}`,
|
|
6162
6187
|
comment2.body,
|
|
6163
6188
|
""
|
|
6164
6189
|
].join("\n");
|
|
6165
6190
|
}
|
|
6166
6191
|
const location = comment2.line ? `:${comment2.line}` : "";
|
|
6167
6192
|
return [
|
|
6168
|
-
`${
|
|
6169
|
-
|
|
6193
|
+
`${chalk70.cyan("Line comment")} by ${chalk70.bold(comment2.user)} on ${chalk70.dim(`${comment2.path}${location}`)}`,
|
|
6194
|
+
chalk70.dim(comment2.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
6170
6195
|
comment2.body,
|
|
6171
6196
|
""
|
|
6172
6197
|
].join("\n");
|
|
@@ -6199,7 +6224,7 @@ function printComments(result) {
|
|
|
6199
6224
|
// src/commands/prs/listComments/index.ts
|
|
6200
6225
|
function writeCommentsCache(prNumber, comments) {
|
|
6201
6226
|
const assistDir = join24(process.cwd(), ".assist");
|
|
6202
|
-
if (!
|
|
6227
|
+
if (!existsSync28(assistDir)) {
|
|
6203
6228
|
mkdirSync6(assistDir, { recursive: true });
|
|
6204
6229
|
}
|
|
6205
6230
|
const cacheData = {
|
|
@@ -6256,13 +6281,13 @@ import { execSync as execSync30 } from "child_process";
|
|
|
6256
6281
|
import enquirer8 from "enquirer";
|
|
6257
6282
|
|
|
6258
6283
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
6259
|
-
import
|
|
6284
|
+
import chalk71 from "chalk";
|
|
6260
6285
|
var STATUS_MAP = {
|
|
6261
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
6262
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
6286
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk71.magenta("merged"), date: pr.mergedAt } : null,
|
|
6287
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk71.red("closed"), date: pr.closedAt } : null
|
|
6263
6288
|
};
|
|
6264
6289
|
function defaultStatus(pr) {
|
|
6265
|
-
return { label:
|
|
6290
|
+
return { label: chalk71.green("opened"), date: pr.createdAt };
|
|
6266
6291
|
}
|
|
6267
6292
|
function getStatus2(pr) {
|
|
6268
6293
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -6271,11 +6296,11 @@ function formatDate(dateStr) {
|
|
|
6271
6296
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
6272
6297
|
}
|
|
6273
6298
|
function formatPrHeader(pr, status2) {
|
|
6274
|
-
return `${
|
|
6299
|
+
return `${chalk71.cyan(`#${pr.number}`)} ${pr.title} ${chalk71.dim(`(${pr.author.login},`)} ${status2.label} ${chalk71.dim(`${formatDate(status2.date)})`)}`;
|
|
6275
6300
|
}
|
|
6276
6301
|
function logPrDetails(pr) {
|
|
6277
6302
|
console.log(
|
|
6278
|
-
|
|
6303
|
+
chalk71.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
6279
6304
|
);
|
|
6280
6305
|
console.log();
|
|
6281
6306
|
}
|
|
@@ -6441,10 +6466,10 @@ function registerPrs(program2) {
|
|
|
6441
6466
|
}
|
|
6442
6467
|
|
|
6443
6468
|
// src/commands/ravendb/ravendbAuth.ts
|
|
6444
|
-
import
|
|
6469
|
+
import chalk77 from "chalk";
|
|
6445
6470
|
|
|
6446
6471
|
// src/shared/createConnectionAuth.ts
|
|
6447
|
-
import
|
|
6472
|
+
import chalk72 from "chalk";
|
|
6448
6473
|
function listConnections(connections, format2) {
|
|
6449
6474
|
if (connections.length === 0) {
|
|
6450
6475
|
console.log("No connections configured.");
|
|
@@ -6457,7 +6482,7 @@ function listConnections(connections, format2) {
|
|
|
6457
6482
|
function removeConnection(connections, name, save) {
|
|
6458
6483
|
const filtered = connections.filter((c) => c.name !== name);
|
|
6459
6484
|
if (filtered.length === connections.length) {
|
|
6460
|
-
console.error(
|
|
6485
|
+
console.error(chalk72.red(`Connection "${name}" not found.`));
|
|
6461
6486
|
process.exit(1);
|
|
6462
6487
|
}
|
|
6463
6488
|
save(filtered);
|
|
@@ -6503,15 +6528,15 @@ function saveConnections(connections) {
|
|
|
6503
6528
|
}
|
|
6504
6529
|
|
|
6505
6530
|
// src/commands/ravendb/promptConnection.ts
|
|
6506
|
-
import
|
|
6531
|
+
import chalk75 from "chalk";
|
|
6507
6532
|
|
|
6508
6533
|
// src/commands/ravendb/selectOpSecret.ts
|
|
6509
|
-
import
|
|
6534
|
+
import chalk74 from "chalk";
|
|
6510
6535
|
import Enquirer2 from "enquirer";
|
|
6511
6536
|
|
|
6512
6537
|
// src/commands/ravendb/searchItems.ts
|
|
6513
6538
|
import { execSync as execSync32 } from "child_process";
|
|
6514
|
-
import
|
|
6539
|
+
import chalk73 from "chalk";
|
|
6515
6540
|
function opExec(args) {
|
|
6516
6541
|
return execSync32(`op ${args}`, {
|
|
6517
6542
|
encoding: "utf-8",
|
|
@@ -6524,7 +6549,7 @@ function searchItems(search) {
|
|
|
6524
6549
|
items = JSON.parse(opExec("item list --format=json"));
|
|
6525
6550
|
} catch {
|
|
6526
6551
|
console.error(
|
|
6527
|
-
|
|
6552
|
+
chalk73.red(
|
|
6528
6553
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
6529
6554
|
)
|
|
6530
6555
|
);
|
|
@@ -6538,7 +6563,7 @@ function getItemFields(itemId) {
|
|
|
6538
6563
|
const item = JSON.parse(opExec(`item get "${itemId}" --format=json`));
|
|
6539
6564
|
return item.fields.filter((f) => f.reference && f.label);
|
|
6540
6565
|
} catch {
|
|
6541
|
-
console.error(
|
|
6566
|
+
console.error(chalk73.red("Failed to get item details from 1Password."));
|
|
6542
6567
|
process.exit(1);
|
|
6543
6568
|
}
|
|
6544
6569
|
}
|
|
@@ -6557,7 +6582,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
6557
6582
|
}).run();
|
|
6558
6583
|
const items = searchItems(search);
|
|
6559
6584
|
if (items.length === 0) {
|
|
6560
|
-
console.error(
|
|
6585
|
+
console.error(chalk74.red(`No items found matching "${search}".`));
|
|
6561
6586
|
process.exit(1);
|
|
6562
6587
|
}
|
|
6563
6588
|
const itemId = await selectOne(
|
|
@@ -6566,7 +6591,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
6566
6591
|
);
|
|
6567
6592
|
const fields = getItemFields(itemId);
|
|
6568
6593
|
if (fields.length === 0) {
|
|
6569
|
-
console.error(
|
|
6594
|
+
console.error(chalk74.red("No fields with references found on this item."));
|
|
6570
6595
|
process.exit(1);
|
|
6571
6596
|
}
|
|
6572
6597
|
const ref = await selectOne(
|
|
@@ -6580,7 +6605,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
6580
6605
|
async function promptConnection(existingNames) {
|
|
6581
6606
|
const name = await promptInput("name", "Connection name:");
|
|
6582
6607
|
if (existingNames.includes(name)) {
|
|
6583
|
-
console.error(
|
|
6608
|
+
console.error(chalk75.red(`Connection "${name}" already exists.`));
|
|
6584
6609
|
process.exit(1);
|
|
6585
6610
|
}
|
|
6586
6611
|
const url = await promptInput(
|
|
@@ -6589,22 +6614,22 @@ async function promptConnection(existingNames) {
|
|
|
6589
6614
|
);
|
|
6590
6615
|
const database = await promptInput("database", "Database name:");
|
|
6591
6616
|
if (!name || !url || !database) {
|
|
6592
|
-
console.error(
|
|
6617
|
+
console.error(chalk75.red("All fields are required."));
|
|
6593
6618
|
process.exit(1);
|
|
6594
6619
|
}
|
|
6595
6620
|
const apiKeyRef = await selectOpSecret();
|
|
6596
|
-
console.log(
|
|
6621
|
+
console.log(chalk75.dim(`Using: ${apiKeyRef}`));
|
|
6597
6622
|
return { name, url, database, apiKeyRef };
|
|
6598
6623
|
}
|
|
6599
6624
|
|
|
6600
6625
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
6601
|
-
import
|
|
6626
|
+
import chalk76 from "chalk";
|
|
6602
6627
|
function ravendbSetConnection(name) {
|
|
6603
6628
|
const raw = loadGlobalConfigRaw();
|
|
6604
6629
|
const ravendb = raw.ravendb ?? {};
|
|
6605
6630
|
const connections = ravendb.connections ?? [];
|
|
6606
6631
|
if (!connections.some((c) => c.name === name)) {
|
|
6607
|
-
console.error(
|
|
6632
|
+
console.error(chalk76.red(`Connection "${name}" not found.`));
|
|
6608
6633
|
console.error(
|
|
6609
6634
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
6610
6635
|
);
|
|
@@ -6620,16 +6645,16 @@ function ravendbSetConnection(name) {
|
|
|
6620
6645
|
var ravendbAuth = createConnectionAuth({
|
|
6621
6646
|
load: loadConnections,
|
|
6622
6647
|
save: saveConnections,
|
|
6623
|
-
format: (c) => `${
|
|
6648
|
+
format: (c) => `${chalk77.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
6624
6649
|
promptNew: promptConnection,
|
|
6625
6650
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
6626
6651
|
});
|
|
6627
6652
|
|
|
6628
6653
|
// src/commands/ravendb/ravendbCollections.ts
|
|
6629
|
-
import
|
|
6654
|
+
import chalk81 from "chalk";
|
|
6630
6655
|
|
|
6631
6656
|
// src/commands/ravendb/ravenFetch.ts
|
|
6632
|
-
import
|
|
6657
|
+
import chalk79 from "chalk";
|
|
6633
6658
|
|
|
6634
6659
|
// src/commands/ravendb/getAccessToken.ts
|
|
6635
6660
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -6666,10 +6691,10 @@ ${errorText}`
|
|
|
6666
6691
|
|
|
6667
6692
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
6668
6693
|
import { execSync as execSync33 } from "child_process";
|
|
6669
|
-
import
|
|
6694
|
+
import chalk78 from "chalk";
|
|
6670
6695
|
function resolveOpSecret(reference) {
|
|
6671
6696
|
if (!reference.startsWith("op://")) {
|
|
6672
|
-
console.error(
|
|
6697
|
+
console.error(chalk78.red(`Invalid secret reference: must start with op://`));
|
|
6673
6698
|
process.exit(1);
|
|
6674
6699
|
}
|
|
6675
6700
|
try {
|
|
@@ -6679,7 +6704,7 @@ function resolveOpSecret(reference) {
|
|
|
6679
6704
|
}).trim();
|
|
6680
6705
|
} catch {
|
|
6681
6706
|
console.error(
|
|
6682
|
-
|
|
6707
|
+
chalk78.red(
|
|
6683
6708
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
6684
6709
|
)
|
|
6685
6710
|
);
|
|
@@ -6706,7 +6731,7 @@ async function ravenFetch(connection, path44) {
|
|
|
6706
6731
|
if (!response.ok) {
|
|
6707
6732
|
const body = await response.text();
|
|
6708
6733
|
console.error(
|
|
6709
|
-
|
|
6734
|
+
chalk79.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
6710
6735
|
);
|
|
6711
6736
|
console.error(body.substring(0, 500));
|
|
6712
6737
|
process.exit(1);
|
|
@@ -6715,7 +6740,7 @@ async function ravenFetch(connection, path44) {
|
|
|
6715
6740
|
}
|
|
6716
6741
|
|
|
6717
6742
|
// src/commands/ravendb/resolveConnection.ts
|
|
6718
|
-
import
|
|
6743
|
+
import chalk80 from "chalk";
|
|
6719
6744
|
function loadRavendb() {
|
|
6720
6745
|
const raw = loadGlobalConfigRaw();
|
|
6721
6746
|
const ravendb = raw.ravendb;
|
|
@@ -6729,7 +6754,7 @@ function resolveConnection(name) {
|
|
|
6729
6754
|
const connectionName = name ?? defaultConnection;
|
|
6730
6755
|
if (!connectionName) {
|
|
6731
6756
|
console.error(
|
|
6732
|
-
|
|
6757
|
+
chalk80.red(
|
|
6733
6758
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
6734
6759
|
)
|
|
6735
6760
|
);
|
|
@@ -6737,7 +6762,7 @@ function resolveConnection(name) {
|
|
|
6737
6762
|
}
|
|
6738
6763
|
const connection = connections.find((c) => c.name === connectionName);
|
|
6739
6764
|
if (!connection) {
|
|
6740
|
-
console.error(
|
|
6765
|
+
console.error(chalk80.red(`Connection "${connectionName}" not found.`));
|
|
6741
6766
|
console.error(
|
|
6742
6767
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
6743
6768
|
);
|
|
@@ -6768,15 +6793,15 @@ async function ravendbCollections(connectionName) {
|
|
|
6768
6793
|
return;
|
|
6769
6794
|
}
|
|
6770
6795
|
for (const c of collections) {
|
|
6771
|
-
console.log(`${
|
|
6796
|
+
console.log(`${chalk81.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
6772
6797
|
}
|
|
6773
6798
|
}
|
|
6774
6799
|
|
|
6775
6800
|
// src/commands/ravendb/ravendbQuery.ts
|
|
6776
|
-
import
|
|
6801
|
+
import chalk83 from "chalk";
|
|
6777
6802
|
|
|
6778
6803
|
// src/commands/ravendb/fetchAllPages.ts
|
|
6779
|
-
import
|
|
6804
|
+
import chalk82 from "chalk";
|
|
6780
6805
|
|
|
6781
6806
|
// src/commands/ravendb/buildQueryPath.ts
|
|
6782
6807
|
function buildQueryPath(opts) {
|
|
@@ -6814,7 +6839,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
6814
6839
|
allResults.push(...results);
|
|
6815
6840
|
start3 += results.length;
|
|
6816
6841
|
process.stderr.write(
|
|
6817
|
-
`\r${
|
|
6842
|
+
`\r${chalk82.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
6818
6843
|
);
|
|
6819
6844
|
if (start3 >= totalResults) break;
|
|
6820
6845
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -6829,7 +6854,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
6829
6854
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
6830
6855
|
const resolved = resolveArgs(connectionName, collection);
|
|
6831
6856
|
if (!resolved.collection && !options2.query) {
|
|
6832
|
-
console.error(
|
|
6857
|
+
console.error(chalk83.red("Provide a collection name or --query filter."));
|
|
6833
6858
|
process.exit(1);
|
|
6834
6859
|
}
|
|
6835
6860
|
const { collection: col } = resolved;
|
|
@@ -6867,7 +6892,7 @@ import { spawn as spawn4 } from "child_process";
|
|
|
6867
6892
|
import * as path27 from "path";
|
|
6868
6893
|
|
|
6869
6894
|
// src/commands/refactor/logViolations.ts
|
|
6870
|
-
import
|
|
6895
|
+
import chalk84 from "chalk";
|
|
6871
6896
|
var DEFAULT_MAX_LINES = 100;
|
|
6872
6897
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
6873
6898
|
if (violations.length === 0) {
|
|
@@ -6876,43 +6901,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
6876
6901
|
}
|
|
6877
6902
|
return;
|
|
6878
6903
|
}
|
|
6879
|
-
console.error(
|
|
6904
|
+
console.error(chalk84.red(`
|
|
6880
6905
|
Refactor check failed:
|
|
6881
6906
|
`));
|
|
6882
|
-
console.error(
|
|
6907
|
+
console.error(chalk84.red(` The following files exceed ${maxLines} lines:
|
|
6883
6908
|
`));
|
|
6884
6909
|
for (const violation of violations) {
|
|
6885
|
-
console.error(
|
|
6910
|
+
console.error(chalk84.red(` ${violation.file} (${violation.lines} lines)`));
|
|
6886
6911
|
}
|
|
6887
6912
|
console.error(
|
|
6888
|
-
|
|
6913
|
+
chalk84.yellow(
|
|
6889
6914
|
`
|
|
6890
6915
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
6891
6916
|
way to refactor it, ignore it with:
|
|
6892
6917
|
`
|
|
6893
6918
|
)
|
|
6894
6919
|
);
|
|
6895
|
-
console.error(
|
|
6920
|
+
console.error(chalk84.gray(` assist refactor ignore <file>
|
|
6896
6921
|
`));
|
|
6897
6922
|
if (process.env.CLAUDECODE) {
|
|
6898
|
-
console.error(
|
|
6923
|
+
console.error(chalk84.cyan(`
|
|
6899
6924
|
## Extracting Code to New Files
|
|
6900
6925
|
`));
|
|
6901
6926
|
console.error(
|
|
6902
|
-
|
|
6927
|
+
chalk84.cyan(
|
|
6903
6928
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
6904
6929
|
`
|
|
6905
6930
|
)
|
|
6906
6931
|
);
|
|
6907
6932
|
console.error(
|
|
6908
|
-
|
|
6933
|
+
chalk84.cyan(
|
|
6909
6934
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
6910
6935
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
6911
6936
|
`
|
|
6912
6937
|
)
|
|
6913
6938
|
);
|
|
6914
6939
|
console.error(
|
|
6915
|
-
|
|
6940
|
+
chalk84.cyan(
|
|
6916
6941
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
6917
6942
|
domains, move it to a common/shared folder.
|
|
6918
6943
|
`
|
|
@@ -7068,11 +7093,11 @@ async function check(pattern2, options2) {
|
|
|
7068
7093
|
|
|
7069
7094
|
// src/commands/refactor/ignore.ts
|
|
7070
7095
|
import fs17 from "fs";
|
|
7071
|
-
import
|
|
7096
|
+
import chalk85 from "chalk";
|
|
7072
7097
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
7073
7098
|
function ignore(file) {
|
|
7074
7099
|
if (!fs17.existsSync(file)) {
|
|
7075
|
-
console.error(
|
|
7100
|
+
console.error(chalk85.red(`Error: File does not exist: ${file}`));
|
|
7076
7101
|
process.exit(1);
|
|
7077
7102
|
}
|
|
7078
7103
|
const content = fs17.readFileSync(file, "utf-8");
|
|
@@ -7088,7 +7113,7 @@ function ignore(file) {
|
|
|
7088
7113
|
fs17.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
7089
7114
|
}
|
|
7090
7115
|
console.log(
|
|
7091
|
-
|
|
7116
|
+
chalk85.green(
|
|
7092
7117
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
7093
7118
|
)
|
|
7094
7119
|
);
|
|
@@ -7096,7 +7121,7 @@ function ignore(file) {
|
|
|
7096
7121
|
|
|
7097
7122
|
// src/commands/refactor/rename/index.ts
|
|
7098
7123
|
import path28 from "path";
|
|
7099
|
-
import
|
|
7124
|
+
import chalk86 from "chalk";
|
|
7100
7125
|
import { Project as Project2 } from "ts-morph";
|
|
7101
7126
|
async function rename(source, destination, options2 = {}) {
|
|
7102
7127
|
const sourcePath = path28.resolve(source);
|
|
@@ -7109,22 +7134,22 @@ async function rename(source, destination, options2 = {}) {
|
|
|
7109
7134
|
});
|
|
7110
7135
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
7111
7136
|
if (!sourceFile) {
|
|
7112
|
-
console.log(
|
|
7137
|
+
console.log(chalk86.red(`File not found in project: ${source}`));
|
|
7113
7138
|
process.exit(1);
|
|
7114
7139
|
}
|
|
7115
|
-
console.log(
|
|
7140
|
+
console.log(chalk86.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
7116
7141
|
if (options2.apply) {
|
|
7117
7142
|
sourceFile.move(destPath);
|
|
7118
7143
|
await project.save();
|
|
7119
|
-
console.log(
|
|
7144
|
+
console.log(chalk86.green("Done"));
|
|
7120
7145
|
} else {
|
|
7121
|
-
console.log(
|
|
7146
|
+
console.log(chalk86.dim("Dry run. Use --apply to execute."));
|
|
7122
7147
|
}
|
|
7123
7148
|
}
|
|
7124
7149
|
|
|
7125
7150
|
// src/commands/refactor/renameSymbol/index.ts
|
|
7126
7151
|
import path30 from "path";
|
|
7127
|
-
import
|
|
7152
|
+
import chalk87 from "chalk";
|
|
7128
7153
|
import { Project as Project3 } from "ts-morph";
|
|
7129
7154
|
|
|
7130
7155
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
@@ -7173,38 +7198,38 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
7173
7198
|
const project = new Project3({ tsConfigFilePath: tsConfigPath });
|
|
7174
7199
|
const sourceFile = project.getSourceFile(filePath);
|
|
7175
7200
|
if (!sourceFile) {
|
|
7176
|
-
console.log(
|
|
7201
|
+
console.log(chalk87.red(`File not found in project: ${file}`));
|
|
7177
7202
|
process.exit(1);
|
|
7178
7203
|
}
|
|
7179
7204
|
const symbol = findSymbol(sourceFile, oldName);
|
|
7180
7205
|
if (!symbol) {
|
|
7181
|
-
console.log(
|
|
7206
|
+
console.log(chalk87.red(`Symbol "${oldName}" not found in ${file}`));
|
|
7182
7207
|
process.exit(1);
|
|
7183
7208
|
}
|
|
7184
7209
|
const grouped = groupReferences(symbol, cwd);
|
|
7185
7210
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
7186
7211
|
console.log(
|
|
7187
|
-
|
|
7212
|
+
chalk87.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
7188
7213
|
`)
|
|
7189
7214
|
);
|
|
7190
7215
|
for (const [refFile, lines] of grouped) {
|
|
7191
7216
|
console.log(
|
|
7192
|
-
` ${
|
|
7217
|
+
` ${chalk87.dim(refFile)}: lines ${chalk87.cyan(lines.join(", "))}`
|
|
7193
7218
|
);
|
|
7194
7219
|
}
|
|
7195
7220
|
if (options2.apply) {
|
|
7196
7221
|
symbol.rename(newName);
|
|
7197
7222
|
await project.save();
|
|
7198
|
-
console.log(
|
|
7223
|
+
console.log(chalk87.green(`
|
|
7199
7224
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
7200
7225
|
} else {
|
|
7201
|
-
console.log(
|
|
7226
|
+
console.log(chalk87.dim("\nDry run. Use --apply to execute."));
|
|
7202
7227
|
}
|
|
7203
7228
|
}
|
|
7204
7229
|
|
|
7205
7230
|
// src/commands/refactor/restructure/index.ts
|
|
7206
7231
|
import path39 from "path";
|
|
7207
|
-
import
|
|
7232
|
+
import chalk90 from "chalk";
|
|
7208
7233
|
|
|
7209
7234
|
// src/commands/refactor/restructure/buildImportGraph/index.ts
|
|
7210
7235
|
import path31 from "path";
|
|
@@ -7447,50 +7472,50 @@ function computeRewrites(moves, edges, allProjectFiles) {
|
|
|
7447
7472
|
|
|
7448
7473
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
7449
7474
|
import path35 from "path";
|
|
7450
|
-
import
|
|
7475
|
+
import chalk88 from "chalk";
|
|
7451
7476
|
function relPath(filePath) {
|
|
7452
7477
|
return path35.relative(process.cwd(), filePath);
|
|
7453
7478
|
}
|
|
7454
7479
|
function displayMoves(plan2) {
|
|
7455
7480
|
if (plan2.moves.length === 0) return;
|
|
7456
|
-
console.log(
|
|
7481
|
+
console.log(chalk88.bold("\nFile moves:"));
|
|
7457
7482
|
for (const move of plan2.moves) {
|
|
7458
7483
|
console.log(
|
|
7459
|
-
` ${
|
|
7484
|
+
` ${chalk88.red(relPath(move.from))} \u2192 ${chalk88.green(relPath(move.to))}`
|
|
7460
7485
|
);
|
|
7461
|
-
console.log(
|
|
7486
|
+
console.log(chalk88.dim(` ${move.reason}`));
|
|
7462
7487
|
}
|
|
7463
7488
|
}
|
|
7464
7489
|
function displayRewrites(rewrites) {
|
|
7465
7490
|
if (rewrites.length === 0) return;
|
|
7466
7491
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
7467
|
-
console.log(
|
|
7492
|
+
console.log(chalk88.bold(`
|
|
7468
7493
|
Import rewrites (${affectedFiles.size} files):`));
|
|
7469
7494
|
for (const file of affectedFiles) {
|
|
7470
|
-
console.log(` ${
|
|
7495
|
+
console.log(` ${chalk88.cyan(relPath(file))}:`);
|
|
7471
7496
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
7472
7497
|
(r) => r.file === file
|
|
7473
7498
|
)) {
|
|
7474
7499
|
console.log(
|
|
7475
|
-
` ${
|
|
7500
|
+
` ${chalk88.red(`"${oldSpecifier}"`)} \u2192 ${chalk88.green(`"${newSpecifier}"`)}`
|
|
7476
7501
|
);
|
|
7477
7502
|
}
|
|
7478
7503
|
}
|
|
7479
7504
|
}
|
|
7480
7505
|
function displayPlan(plan2) {
|
|
7481
7506
|
if (plan2.warnings.length > 0) {
|
|
7482
|
-
console.log(
|
|
7483
|
-
for (const w of plan2.warnings) console.log(
|
|
7507
|
+
console.log(chalk88.yellow("\nWarnings:"));
|
|
7508
|
+
for (const w of plan2.warnings) console.log(chalk88.yellow(` ${w}`));
|
|
7484
7509
|
}
|
|
7485
7510
|
if (plan2.newDirectories.length > 0) {
|
|
7486
|
-
console.log(
|
|
7511
|
+
console.log(chalk88.bold("\nNew directories:"));
|
|
7487
7512
|
for (const dir of plan2.newDirectories)
|
|
7488
|
-
console.log(
|
|
7513
|
+
console.log(chalk88.green(` ${dir}/`));
|
|
7489
7514
|
}
|
|
7490
7515
|
displayMoves(plan2);
|
|
7491
7516
|
displayRewrites(plan2.rewrites);
|
|
7492
7517
|
console.log(
|
|
7493
|
-
|
|
7518
|
+
chalk88.dim(
|
|
7494
7519
|
`
|
|
7495
7520
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
7496
7521
|
)
|
|
@@ -7500,18 +7525,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
7500
7525
|
// src/commands/refactor/restructure/executePlan.ts
|
|
7501
7526
|
import fs19 from "fs";
|
|
7502
7527
|
import path36 from "path";
|
|
7503
|
-
import
|
|
7528
|
+
import chalk89 from "chalk";
|
|
7504
7529
|
function executePlan(plan2) {
|
|
7505
7530
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
7506
7531
|
for (const [file, content] of updatedContents) {
|
|
7507
7532
|
fs19.writeFileSync(file, content, "utf-8");
|
|
7508
7533
|
console.log(
|
|
7509
|
-
|
|
7534
|
+
chalk89.cyan(` Rewrote imports in ${path36.relative(process.cwd(), file)}`)
|
|
7510
7535
|
);
|
|
7511
7536
|
}
|
|
7512
7537
|
for (const dir of plan2.newDirectories) {
|
|
7513
7538
|
fs19.mkdirSync(dir, { recursive: true });
|
|
7514
|
-
console.log(
|
|
7539
|
+
console.log(chalk89.green(` Created ${path36.relative(process.cwd(), dir)}/`));
|
|
7515
7540
|
}
|
|
7516
7541
|
for (const move of plan2.moves) {
|
|
7517
7542
|
const targetDir = path36.dirname(move.to);
|
|
@@ -7520,7 +7545,7 @@ function executePlan(plan2) {
|
|
|
7520
7545
|
}
|
|
7521
7546
|
fs19.renameSync(move.from, move.to);
|
|
7522
7547
|
console.log(
|
|
7523
|
-
|
|
7548
|
+
chalk89.white(
|
|
7524
7549
|
` Moved ${path36.relative(process.cwd(), move.from)} \u2192 ${path36.relative(process.cwd(), move.to)}`
|
|
7525
7550
|
)
|
|
7526
7551
|
);
|
|
@@ -7535,7 +7560,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
7535
7560
|
if (entries.length === 0) {
|
|
7536
7561
|
fs19.rmdirSync(dir);
|
|
7537
7562
|
console.log(
|
|
7538
|
-
|
|
7563
|
+
chalk89.dim(
|
|
7539
7564
|
` Removed empty directory ${path36.relative(process.cwd(), dir)}`
|
|
7540
7565
|
)
|
|
7541
7566
|
);
|
|
@@ -7668,22 +7693,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
7668
7693
|
const targetPattern = pattern2 ?? "src";
|
|
7669
7694
|
const files = findSourceFiles2(targetPattern);
|
|
7670
7695
|
if (files.length === 0) {
|
|
7671
|
-
console.log(
|
|
7696
|
+
console.log(chalk90.yellow("No files found matching pattern"));
|
|
7672
7697
|
return;
|
|
7673
7698
|
}
|
|
7674
7699
|
const tsConfigPath = path39.resolve("tsconfig.json");
|
|
7675
7700
|
const plan2 = buildPlan(files, tsConfigPath);
|
|
7676
7701
|
if (plan2.moves.length === 0) {
|
|
7677
|
-
console.log(
|
|
7702
|
+
console.log(chalk90.green("No restructuring needed"));
|
|
7678
7703
|
return;
|
|
7679
7704
|
}
|
|
7680
7705
|
displayPlan(plan2);
|
|
7681
7706
|
if (options2.apply) {
|
|
7682
|
-
console.log(
|
|
7707
|
+
console.log(chalk90.bold("\nApplying changes..."));
|
|
7683
7708
|
executePlan(plan2);
|
|
7684
|
-
console.log(
|
|
7709
|
+
console.log(chalk90.green("\nRestructuring complete"));
|
|
7685
7710
|
} else {
|
|
7686
|
-
console.log(
|
|
7711
|
+
console.log(chalk90.dim("\nDry run. Use --apply to execute."));
|
|
7687
7712
|
}
|
|
7688
7713
|
}
|
|
7689
7714
|
|
|
@@ -7711,7 +7736,7 @@ function registerRefactor(program2) {
|
|
|
7711
7736
|
}
|
|
7712
7737
|
|
|
7713
7738
|
// src/commands/seq/seqAuth.ts
|
|
7714
|
-
import
|
|
7739
|
+
import chalk92 from "chalk";
|
|
7715
7740
|
|
|
7716
7741
|
// src/commands/seq/loadConnections.ts
|
|
7717
7742
|
function loadConnections2() {
|
|
@@ -7740,11 +7765,11 @@ function setDefaultConnection(name) {
|
|
|
7740
7765
|
}
|
|
7741
7766
|
|
|
7742
7767
|
// src/commands/seq/promptConnection.ts
|
|
7743
|
-
import
|
|
7768
|
+
import chalk91 from "chalk";
|
|
7744
7769
|
async function promptConnection2(existingNames) {
|
|
7745
7770
|
const name = await promptInput("name", "Connection name:", "default");
|
|
7746
7771
|
if (existingNames.includes(name)) {
|
|
7747
|
-
console.error(
|
|
7772
|
+
console.error(chalk91.red(`Connection "${name}" already exists.`));
|
|
7748
7773
|
process.exit(1);
|
|
7749
7774
|
}
|
|
7750
7775
|
const url = await promptInput("url", "Seq URL:", "http://localhost:5341");
|
|
@@ -7756,32 +7781,32 @@ async function promptConnection2(existingNames) {
|
|
|
7756
7781
|
var seqAuth = createConnectionAuth({
|
|
7757
7782
|
load: loadConnections2,
|
|
7758
7783
|
save: saveConnections2,
|
|
7759
|
-
format: (c) => `${
|
|
7784
|
+
format: (c) => `${chalk92.bold(c.name)} ${c.url}`,
|
|
7760
7785
|
promptNew: promptConnection2,
|
|
7761
7786
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
7762
7787
|
});
|
|
7763
7788
|
|
|
7764
7789
|
// src/commands/seq/seqQuery.ts
|
|
7765
|
-
import
|
|
7790
|
+
import chalk95 from "chalk";
|
|
7766
7791
|
|
|
7767
7792
|
// src/commands/seq/formatEvent.ts
|
|
7768
|
-
import
|
|
7793
|
+
import chalk93 from "chalk";
|
|
7769
7794
|
function levelColor(level) {
|
|
7770
7795
|
switch (level) {
|
|
7771
7796
|
case "Fatal":
|
|
7772
|
-
return
|
|
7797
|
+
return chalk93.bgRed.white;
|
|
7773
7798
|
case "Error":
|
|
7774
|
-
return
|
|
7799
|
+
return chalk93.red;
|
|
7775
7800
|
case "Warning":
|
|
7776
|
-
return
|
|
7801
|
+
return chalk93.yellow;
|
|
7777
7802
|
case "Information":
|
|
7778
|
-
return
|
|
7803
|
+
return chalk93.cyan;
|
|
7779
7804
|
case "Debug":
|
|
7780
|
-
return
|
|
7805
|
+
return chalk93.gray;
|
|
7781
7806
|
case "Verbose":
|
|
7782
|
-
return
|
|
7807
|
+
return chalk93.dim;
|
|
7783
7808
|
default:
|
|
7784
|
-
return
|
|
7809
|
+
return chalk93.white;
|
|
7785
7810
|
}
|
|
7786
7811
|
}
|
|
7787
7812
|
function levelAbbrev(level) {
|
|
@@ -7822,31 +7847,31 @@ function formatTimestamp(iso) {
|
|
|
7822
7847
|
function formatEvent(event) {
|
|
7823
7848
|
const color = levelColor(event.Level);
|
|
7824
7849
|
const abbrev = levelAbbrev(event.Level);
|
|
7825
|
-
const ts8 =
|
|
7850
|
+
const ts8 = chalk93.dim(formatTimestamp(event.Timestamp));
|
|
7826
7851
|
const msg = renderMessage(event);
|
|
7827
7852
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
7828
7853
|
if (event.Exception) {
|
|
7829
7854
|
for (const line of event.Exception.split("\n")) {
|
|
7830
|
-
lines.push(
|
|
7855
|
+
lines.push(chalk93.red(` ${line}`));
|
|
7831
7856
|
}
|
|
7832
7857
|
}
|
|
7833
7858
|
return lines.join("\n");
|
|
7834
7859
|
}
|
|
7835
7860
|
|
|
7836
7861
|
// src/commands/seq/resolveConnection.ts
|
|
7837
|
-
import
|
|
7862
|
+
import chalk94 from "chalk";
|
|
7838
7863
|
function resolveConnection2(name) {
|
|
7839
7864
|
const connections = loadConnections2();
|
|
7840
7865
|
if (connections.length === 0) {
|
|
7841
7866
|
console.error(
|
|
7842
|
-
|
|
7867
|
+
chalk94.red("No Seq connections configured. Run 'assist seq auth' first.")
|
|
7843
7868
|
);
|
|
7844
7869
|
process.exit(1);
|
|
7845
7870
|
}
|
|
7846
7871
|
const target = name ?? getDefaultConnection() ?? connections[0].name;
|
|
7847
7872
|
const connection = connections.find((c) => c.name === target);
|
|
7848
7873
|
if (!connection) {
|
|
7849
|
-
console.error(
|
|
7874
|
+
console.error(chalk94.red(`Seq connection "${target}" not found.`));
|
|
7850
7875
|
process.exit(1);
|
|
7851
7876
|
}
|
|
7852
7877
|
return connection;
|
|
@@ -7866,12 +7891,12 @@ async function seqQuery(filter, options2) {
|
|
|
7866
7891
|
});
|
|
7867
7892
|
if (!response.ok) {
|
|
7868
7893
|
const body = await response.text();
|
|
7869
|
-
console.error(
|
|
7894
|
+
console.error(chalk95.red(`Seq returned ${response.status}: ${body}`));
|
|
7870
7895
|
process.exit(1);
|
|
7871
7896
|
}
|
|
7872
7897
|
const events = await response.json();
|
|
7873
7898
|
if (events.length === 0) {
|
|
7874
|
-
console.log(
|
|
7899
|
+
console.log(chalk95.yellow("No events found."));
|
|
7875
7900
|
return;
|
|
7876
7901
|
}
|
|
7877
7902
|
if (options2.json) {
|
|
@@ -7882,11 +7907,11 @@ async function seqQuery(filter, options2) {
|
|
|
7882
7907
|
for (const event of chronological) {
|
|
7883
7908
|
console.log(formatEvent(event));
|
|
7884
7909
|
}
|
|
7885
|
-
console.log(
|
|
7910
|
+
console.log(chalk95.dim(`
|
|
7886
7911
|
${events.length} events`));
|
|
7887
7912
|
if (events.length >= count) {
|
|
7888
7913
|
console.log(
|
|
7889
|
-
|
|
7914
|
+
chalk95.yellow(
|
|
7890
7915
|
`Results limited to ${count}. Use --count to retrieve more.`
|
|
7891
7916
|
)
|
|
7892
7917
|
);
|
|
@@ -7894,11 +7919,11 @@ ${events.length} events`));
|
|
|
7894
7919
|
}
|
|
7895
7920
|
|
|
7896
7921
|
// src/commands/seq/seqSetConnection.ts
|
|
7897
|
-
import
|
|
7922
|
+
import chalk96 from "chalk";
|
|
7898
7923
|
function seqSetConnection(name) {
|
|
7899
7924
|
const connections = loadConnections2();
|
|
7900
7925
|
if (!connections.find((c) => c.name === name)) {
|
|
7901
|
-
console.error(
|
|
7926
|
+
console.error(chalk96.red(`Connection "${name}" not found.`));
|
|
7902
7927
|
process.exit(1);
|
|
7903
7928
|
}
|
|
7904
7929
|
setDefaultConnection(name);
|
|
@@ -7917,7 +7942,7 @@ function registerSeq(program2) {
|
|
|
7917
7942
|
}
|
|
7918
7943
|
|
|
7919
7944
|
// src/commands/transcript/shared.ts
|
|
7920
|
-
import { existsSync as
|
|
7945
|
+
import { existsSync as existsSync29, readdirSync as readdirSync5, statSync as statSync2 } from "fs";
|
|
7921
7946
|
import { basename as basename4, join as join25, relative } from "path";
|
|
7922
7947
|
import * as readline2 from "readline";
|
|
7923
7948
|
var DATE_PREFIX_REGEX = /^\d{4}-\d{2}-\d{2}/;
|
|
@@ -7933,7 +7958,7 @@ function isValidDatePrefix(filename) {
|
|
|
7933
7958
|
return DATE_PREFIX_REGEX.test(filename);
|
|
7934
7959
|
}
|
|
7935
7960
|
function collectFiles(dir, extension) {
|
|
7936
|
-
if (!
|
|
7961
|
+
if (!existsSync29(dir)) return [];
|
|
7937
7962
|
const results = [];
|
|
7938
7963
|
for (const entry of readdirSync5(dir)) {
|
|
7939
7964
|
const fullPath = join25(dir, entry);
|
|
@@ -8030,7 +8055,7 @@ async function configure() {
|
|
|
8030
8055
|
}
|
|
8031
8056
|
|
|
8032
8057
|
// src/commands/transcript/format/index.ts
|
|
8033
|
-
import { existsSync as
|
|
8058
|
+
import { existsSync as existsSync31 } from "fs";
|
|
8034
8059
|
|
|
8035
8060
|
// src/commands/transcript/format/fixInvalidDatePrefixes/index.ts
|
|
8036
8061
|
import { dirname as dirname18, join as join27 } from "path";
|
|
@@ -8104,7 +8129,7 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
8104
8129
|
}
|
|
8105
8130
|
|
|
8106
8131
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
8107
|
-
import { existsSync as
|
|
8132
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync7, readFileSync as readFileSync23, writeFileSync as writeFileSync23 } from "fs";
|
|
8108
8133
|
import { basename as basename5, dirname as dirname19, join as join28 } from "path";
|
|
8109
8134
|
|
|
8110
8135
|
// src/commands/transcript/cleanText.ts
|
|
@@ -8329,7 +8354,7 @@ function logSkipped(relativeDir, mdFile) {
|
|
|
8329
8354
|
return "skipped";
|
|
8330
8355
|
}
|
|
8331
8356
|
function ensureDirectory(dir, label2) {
|
|
8332
|
-
if (!
|
|
8357
|
+
if (!existsSync30(dir)) {
|
|
8333
8358
|
mkdirSync7(dir, { recursive: true });
|
|
8334
8359
|
console.log(`Created ${label2}: ${dir}`);
|
|
8335
8360
|
}
|
|
@@ -8365,7 +8390,7 @@ function convertVttToMarkdown(inputPath, outputPath) {
|
|
|
8365
8390
|
logReduction(cues.length, chatMessages.length);
|
|
8366
8391
|
}
|
|
8367
8392
|
function tryProcessVtt(vttFile, paths) {
|
|
8368
|
-
if (
|
|
8393
|
+
if (existsSync30(paths.outputPath))
|
|
8369
8394
|
return logSkipped(paths.relativeDir, paths.mdFile);
|
|
8370
8395
|
convertVttToMarkdown(vttFile.absolutePath, paths.outputPath);
|
|
8371
8396
|
return "processed";
|
|
@@ -8391,7 +8416,7 @@ function processAllFiles(vttFiles, transcriptsDir) {
|
|
|
8391
8416
|
logSummary(counts);
|
|
8392
8417
|
}
|
|
8393
8418
|
function requireVttDir(vttDir) {
|
|
8394
|
-
if (!
|
|
8419
|
+
if (!existsSync31(vttDir)) {
|
|
8395
8420
|
console.error(`VTT directory not found: ${vttDir}`);
|
|
8396
8421
|
process.exit(1);
|
|
8397
8422
|
}
|
|
@@ -8423,12 +8448,12 @@ async function format() {
|
|
|
8423
8448
|
}
|
|
8424
8449
|
|
|
8425
8450
|
// src/commands/transcript/summarise/index.ts
|
|
8426
|
-
import { existsSync as
|
|
8451
|
+
import { existsSync as existsSync33 } from "fs";
|
|
8427
8452
|
import { basename as basename6, dirname as dirname21, join as join30, relative as relative2 } from "path";
|
|
8428
8453
|
|
|
8429
8454
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
8430
8455
|
import {
|
|
8431
|
-
existsSync as
|
|
8456
|
+
existsSync as existsSync32,
|
|
8432
8457
|
mkdirSync as mkdirSync8,
|
|
8433
8458
|
readFileSync as readFileSync24,
|
|
8434
8459
|
renameSync as renameSync2,
|
|
@@ -8437,14 +8462,14 @@ import {
|
|
|
8437
8462
|
import { dirname as dirname20, join as join29 } from "path";
|
|
8438
8463
|
|
|
8439
8464
|
// src/commands/transcript/summarise/processStagedFile/validateStagedContent.ts
|
|
8440
|
-
import
|
|
8465
|
+
import chalk97 from "chalk";
|
|
8441
8466
|
var FULL_TRANSCRIPT_REGEX = /^\[Full Transcript\]\(([^)]+)\)/;
|
|
8442
8467
|
function validateStagedContent(filename, content) {
|
|
8443
8468
|
const firstLine = content.split("\n")[0];
|
|
8444
8469
|
const match = firstLine.match(FULL_TRANSCRIPT_REGEX);
|
|
8445
8470
|
if (!match) {
|
|
8446
8471
|
console.error(
|
|
8447
|
-
|
|
8472
|
+
chalk97.red(
|
|
8448
8473
|
`Staged file ${filename} missing [Full Transcript](<path>) link on first line.`
|
|
8449
8474
|
)
|
|
8450
8475
|
);
|
|
@@ -8453,7 +8478,7 @@ function validateStagedContent(filename, content) {
|
|
|
8453
8478
|
const contentAfterLink = content.slice(firstLine.length).trim();
|
|
8454
8479
|
if (!contentAfterLink) {
|
|
8455
8480
|
console.error(
|
|
8456
|
-
|
|
8481
|
+
chalk97.red(
|
|
8457
8482
|
`Staged file ${filename} has no summary content after the transcript link.`
|
|
8458
8483
|
)
|
|
8459
8484
|
);
|
|
@@ -8465,7 +8490,7 @@ function validateStagedContent(filename, content) {
|
|
|
8465
8490
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
8466
8491
|
var STAGING_DIR = join29(process.cwd(), ".assist", "transcript");
|
|
8467
8492
|
function processStagedFile() {
|
|
8468
|
-
if (!
|
|
8493
|
+
if (!existsSync32(STAGING_DIR)) {
|
|
8469
8494
|
return false;
|
|
8470
8495
|
}
|
|
8471
8496
|
const stagedFiles = findMdFilesRecursive(STAGING_DIR);
|
|
@@ -8489,7 +8514,7 @@ function processStagedFile() {
|
|
|
8489
8514
|
}
|
|
8490
8515
|
const destPath = join29(summaryDir, matchingTranscript.relativePath);
|
|
8491
8516
|
const destDir = dirname20(destPath);
|
|
8492
|
-
if (!
|
|
8517
|
+
if (!existsSync32(destDir)) {
|
|
8493
8518
|
mkdirSync8(destDir, { recursive: true });
|
|
8494
8519
|
}
|
|
8495
8520
|
renameSync2(stagedFile.absolutePath, destPath);
|
|
@@ -8516,7 +8541,7 @@ function buildSummaryIndex(summaryDir) {
|
|
|
8516
8541
|
function summarise2() {
|
|
8517
8542
|
processStagedFile();
|
|
8518
8543
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
8519
|
-
if (!
|
|
8544
|
+
if (!existsSync33(transcriptsDir)) {
|
|
8520
8545
|
console.log("No transcripts directory found.");
|
|
8521
8546
|
return;
|
|
8522
8547
|
}
|
|
@@ -8620,9 +8645,9 @@ function devices() {
|
|
|
8620
8645
|
}
|
|
8621
8646
|
|
|
8622
8647
|
// src/commands/voice/logs.ts
|
|
8623
|
-
import { existsSync as
|
|
8648
|
+
import { existsSync as existsSync34, readFileSync as readFileSync25 } from "fs";
|
|
8624
8649
|
function logs(options2) {
|
|
8625
|
-
if (!
|
|
8650
|
+
if (!existsSync34(voicePaths.log)) {
|
|
8626
8651
|
console.log("No voice log file found");
|
|
8627
8652
|
return;
|
|
8628
8653
|
}
|
|
@@ -8654,7 +8679,7 @@ import { join as join34 } from "path";
|
|
|
8654
8679
|
|
|
8655
8680
|
// src/commands/voice/checkLockFile.ts
|
|
8656
8681
|
import { execSync as execSync35 } from "child_process";
|
|
8657
|
-
import { existsSync as
|
|
8682
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync9, readFileSync as readFileSync26, writeFileSync as writeFileSync24 } from "fs";
|
|
8658
8683
|
import { join as join33 } from "path";
|
|
8659
8684
|
function isProcessAlive(pid) {
|
|
8660
8685
|
try {
|
|
@@ -8666,7 +8691,7 @@ function isProcessAlive(pid) {
|
|
|
8666
8691
|
}
|
|
8667
8692
|
function checkLockFile() {
|
|
8668
8693
|
const lockFile = getLockFile();
|
|
8669
|
-
if (!
|
|
8694
|
+
if (!existsSync35(lockFile)) return;
|
|
8670
8695
|
try {
|
|
8671
8696
|
const lock = JSON.parse(readFileSync26(lockFile, "utf-8"));
|
|
8672
8697
|
if (lock.pid && isProcessAlive(lock.pid)) {
|
|
@@ -8679,7 +8704,7 @@ function checkLockFile() {
|
|
|
8679
8704
|
}
|
|
8680
8705
|
}
|
|
8681
8706
|
function bootstrapVenv() {
|
|
8682
|
-
if (
|
|
8707
|
+
if (existsSync35(getVenvPython())) return;
|
|
8683
8708
|
console.log("Setting up Python environment...");
|
|
8684
8709
|
const pythonDir = getPythonDir();
|
|
8685
8710
|
execSync35(
|
|
@@ -8770,7 +8795,7 @@ function start2(options2) {
|
|
|
8770
8795
|
}
|
|
8771
8796
|
|
|
8772
8797
|
// src/commands/voice/status.ts
|
|
8773
|
-
import { existsSync as
|
|
8798
|
+
import { existsSync as existsSync36, readFileSync as readFileSync27 } from "fs";
|
|
8774
8799
|
function isProcessAlive2(pid) {
|
|
8775
8800
|
try {
|
|
8776
8801
|
process.kill(pid, 0);
|
|
@@ -8780,12 +8805,12 @@ function isProcessAlive2(pid) {
|
|
|
8780
8805
|
}
|
|
8781
8806
|
}
|
|
8782
8807
|
function readRecentLogs(count) {
|
|
8783
|
-
if (!
|
|
8808
|
+
if (!existsSync36(voicePaths.log)) return [];
|
|
8784
8809
|
const lines = readFileSync27(voicePaths.log, "utf-8").trim().split("\n");
|
|
8785
8810
|
return lines.slice(-count);
|
|
8786
8811
|
}
|
|
8787
8812
|
function status() {
|
|
8788
|
-
if (!
|
|
8813
|
+
if (!existsSync36(voicePaths.pid)) {
|
|
8789
8814
|
console.log("Voice daemon: not running (no PID file)");
|
|
8790
8815
|
return;
|
|
8791
8816
|
}
|
|
@@ -8808,9 +8833,9 @@ function status() {
|
|
|
8808
8833
|
}
|
|
8809
8834
|
|
|
8810
8835
|
// src/commands/voice/stop.ts
|
|
8811
|
-
import { existsSync as
|
|
8836
|
+
import { existsSync as existsSync37, readFileSync as readFileSync28, unlinkSync as unlinkSync9 } from "fs";
|
|
8812
8837
|
function stop() {
|
|
8813
|
-
if (!
|
|
8838
|
+
if (!existsSync37(voicePaths.pid)) {
|
|
8814
8839
|
console.log("Voice daemon is not running (no PID file)");
|
|
8815
8840
|
return;
|
|
8816
8841
|
}
|
|
@@ -8827,7 +8852,7 @@ function stop() {
|
|
|
8827
8852
|
}
|
|
8828
8853
|
try {
|
|
8829
8854
|
const lockFile = getLockFile();
|
|
8830
|
-
if (
|
|
8855
|
+
if (existsSync37(lockFile)) unlinkSync9(lockFile);
|
|
8831
8856
|
} catch {
|
|
8832
8857
|
}
|
|
8833
8858
|
console.log("Voice daemon stopped");
|
|
@@ -8846,7 +8871,7 @@ function registerVoice(program2) {
|
|
|
8846
8871
|
|
|
8847
8872
|
// src/commands/roam/auth.ts
|
|
8848
8873
|
import { randomBytes } from "crypto";
|
|
8849
|
-
import
|
|
8874
|
+
import chalk98 from "chalk";
|
|
8850
8875
|
|
|
8851
8876
|
// src/lib/openBrowser.ts
|
|
8852
8877
|
import { execSync as execSync36 } from "child_process";
|
|
@@ -9021,13 +9046,13 @@ async function auth() {
|
|
|
9021
9046
|
saveGlobalConfig(config);
|
|
9022
9047
|
const state = randomBytes(16).toString("hex");
|
|
9023
9048
|
console.log(
|
|
9024
|
-
|
|
9049
|
+
chalk98.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
9025
9050
|
);
|
|
9026
|
-
console.log(
|
|
9027
|
-
console.log(
|
|
9028
|
-
console.log(
|
|
9051
|
+
console.log(chalk98.white("http://localhost:14523/callback\n"));
|
|
9052
|
+
console.log(chalk98.blue("Opening browser for authorization..."));
|
|
9053
|
+
console.log(chalk98.dim("Waiting for authorization callback..."));
|
|
9029
9054
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
9030
|
-
console.log(
|
|
9055
|
+
console.log(chalk98.dim("Exchanging code for tokens..."));
|
|
9031
9056
|
const tokens = await exchangeToken({
|
|
9032
9057
|
code,
|
|
9033
9058
|
clientId,
|
|
@@ -9043,7 +9068,7 @@ async function auth() {
|
|
|
9043
9068
|
};
|
|
9044
9069
|
saveGlobalConfig(config);
|
|
9045
9070
|
console.log(
|
|
9046
|
-
|
|
9071
|
+
chalk98.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
9047
9072
|
);
|
|
9048
9073
|
}
|
|
9049
9074
|
|
|
@@ -9261,10 +9286,10 @@ function run3(name, args) {
|
|
|
9261
9286
|
|
|
9262
9287
|
// src/commands/screenshot/index.ts
|
|
9263
9288
|
import { execSync as execSync38 } from "child_process";
|
|
9264
|
-
import { existsSync as
|
|
9289
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync13, unlinkSync as unlinkSync10, writeFileSync as writeFileSync27 } from "fs";
|
|
9265
9290
|
import { tmpdir as tmpdir6 } from "os";
|
|
9266
9291
|
import { join as join38, resolve as resolve5 } from "path";
|
|
9267
|
-
import
|
|
9292
|
+
import chalk99 from "chalk";
|
|
9268
9293
|
|
|
9269
9294
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
9270
9295
|
var captureWindowPs1 = `
|
|
@@ -9393,7 +9418,7 @@ Write-Output $OutputPath
|
|
|
9393
9418
|
|
|
9394
9419
|
// src/commands/screenshot/index.ts
|
|
9395
9420
|
function buildOutputPath(outputDir, processName) {
|
|
9396
|
-
if (!
|
|
9421
|
+
if (!existsSync38(outputDir)) {
|
|
9397
9422
|
mkdirSync13(outputDir, { recursive: true });
|
|
9398
9423
|
}
|
|
9399
9424
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -9415,22 +9440,22 @@ function screenshot(processName) {
|
|
|
9415
9440
|
const config = loadConfig();
|
|
9416
9441
|
const outputDir = resolve5(config.screenshot.outputDir);
|
|
9417
9442
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
9418
|
-
console.log(
|
|
9443
|
+
console.log(chalk99.gray(`Capturing window for process "${processName}" ...`));
|
|
9419
9444
|
try {
|
|
9420
9445
|
runPowerShellScript(processName, outputPath);
|
|
9421
|
-
console.log(
|
|
9446
|
+
console.log(chalk99.green(`Screenshot saved: ${outputPath}`));
|
|
9422
9447
|
} catch (error) {
|
|
9423
9448
|
const msg = error instanceof Error ? error.message : String(error);
|
|
9424
|
-
console.error(
|
|
9449
|
+
console.error(chalk99.red(`Failed to capture screenshot: ${msg}`));
|
|
9425
9450
|
process.exit(1);
|
|
9426
9451
|
}
|
|
9427
9452
|
}
|
|
9428
9453
|
|
|
9429
9454
|
// src/commands/statusLine.ts
|
|
9430
|
-
import
|
|
9455
|
+
import chalk101 from "chalk";
|
|
9431
9456
|
|
|
9432
9457
|
// src/commands/buildLimitsSegment.ts
|
|
9433
|
-
import
|
|
9458
|
+
import chalk100 from "chalk";
|
|
9434
9459
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
9435
9460
|
var SEVEN_DAY_SECONDS = 7 * 86400;
|
|
9436
9461
|
function formatTimeLeft(resetsAt) {
|
|
@@ -9453,10 +9478,10 @@ function projectUsage(pct, resetsAt, windowSeconds) {
|
|
|
9453
9478
|
function colorizeRateLimit(pct, resetsAt, windowSeconds) {
|
|
9454
9479
|
const label2 = `${Math.round(pct)}%`;
|
|
9455
9480
|
const projected = projectUsage(pct, resetsAt, windowSeconds);
|
|
9456
|
-
if (projected == null) return
|
|
9457
|
-
if (projected > 100) return
|
|
9458
|
-
if (projected > 75) return
|
|
9459
|
-
return
|
|
9481
|
+
if (projected == null) return chalk100.green(label2);
|
|
9482
|
+
if (projected > 100) return chalk100.red(label2);
|
|
9483
|
+
if (projected > 75) return chalk100.yellow(label2);
|
|
9484
|
+
return chalk100.green(label2);
|
|
9460
9485
|
}
|
|
9461
9486
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel) {
|
|
9462
9487
|
const timeLabel = resetsAt ? formatTimeLeft(resetsAt) : fallbackLabel;
|
|
@@ -9482,14 +9507,14 @@ function buildLimitsSegment(rateLimits) {
|
|
|
9482
9507
|
}
|
|
9483
9508
|
|
|
9484
9509
|
// src/commands/statusLine.ts
|
|
9485
|
-
|
|
9510
|
+
chalk101.level = 3;
|
|
9486
9511
|
function formatNumber(num) {
|
|
9487
9512
|
return num.toLocaleString("en-US");
|
|
9488
9513
|
}
|
|
9489
9514
|
function colorizePercent(pct) {
|
|
9490
9515
|
const label2 = `${Math.round(pct)}%`;
|
|
9491
|
-
if (pct > 80) return
|
|
9492
|
-
if (pct > 40) return
|
|
9516
|
+
if (pct > 80) return chalk101.red(label2);
|
|
9517
|
+
if (pct > 40) return chalk101.yellow(label2);
|
|
9493
9518
|
return label2;
|
|
9494
9519
|
}
|
|
9495
9520
|
async function statusLine() {
|
|
@@ -9512,7 +9537,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
|
|
|
9512
9537
|
// src/commands/sync/syncClaudeMd.ts
|
|
9513
9538
|
import * as fs22 from "fs";
|
|
9514
9539
|
import * as path40 from "path";
|
|
9515
|
-
import
|
|
9540
|
+
import chalk102 from "chalk";
|
|
9516
9541
|
async function syncClaudeMd(claudeDir, targetBase) {
|
|
9517
9542
|
const source = path40.join(claudeDir, "CLAUDE.md");
|
|
9518
9543
|
const target = path40.join(targetBase, "CLAUDE.md");
|
|
@@ -9521,12 +9546,12 @@ async function syncClaudeMd(claudeDir, targetBase) {
|
|
|
9521
9546
|
const targetContent = fs22.readFileSync(target, "utf-8");
|
|
9522
9547
|
if (sourceContent !== targetContent) {
|
|
9523
9548
|
console.log(
|
|
9524
|
-
|
|
9549
|
+
chalk102.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
9525
9550
|
);
|
|
9526
9551
|
console.log();
|
|
9527
9552
|
printDiff(targetContent, sourceContent);
|
|
9528
9553
|
const confirm = await promptConfirm(
|
|
9529
|
-
|
|
9554
|
+
chalk102.red("Overwrite existing CLAUDE.md?"),
|
|
9530
9555
|
false
|
|
9531
9556
|
);
|
|
9532
9557
|
if (!confirm) {
|
|
@@ -9542,7 +9567,7 @@ async function syncClaudeMd(claudeDir, targetBase) {
|
|
|
9542
9567
|
// src/commands/sync/syncSettings.ts
|
|
9543
9568
|
import * as fs23 from "fs";
|
|
9544
9569
|
import * as path41 from "path";
|
|
9545
|
-
import
|
|
9570
|
+
import chalk103 from "chalk";
|
|
9546
9571
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
9547
9572
|
const source = path41.join(claudeDir, "settings.json");
|
|
9548
9573
|
const target = path41.join(targetBase, "settings.json");
|
|
@@ -9558,14 +9583,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
9558
9583
|
if (mergedContent !== normalizedTarget) {
|
|
9559
9584
|
if (!options2?.yes) {
|
|
9560
9585
|
console.log(
|
|
9561
|
-
|
|
9586
|
+
chalk103.yellow(
|
|
9562
9587
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
9563
9588
|
)
|
|
9564
9589
|
);
|
|
9565
9590
|
console.log();
|
|
9566
9591
|
printDiff(targetContent, mergedContent);
|
|
9567
9592
|
const confirm = await promptConfirm(
|
|
9568
|
-
|
|
9593
|
+
chalk103.red("Overwrite existing settings.json?"),
|
|
9569
9594
|
false
|
|
9570
9595
|
);
|
|
9571
9596
|
if (!confirm) {
|