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