hyntx 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -1
- package/dist/index.js +359 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ type ParsedArgs = {
|
|
|
110
110
|
readonly history: boolean;
|
|
111
111
|
readonly historySummary: boolean;
|
|
112
112
|
readonly noHistory: boolean;
|
|
113
|
+
readonly watch: boolean;
|
|
114
|
+
readonly quiet: boolean;
|
|
113
115
|
};
|
|
114
116
|
/**
|
|
115
117
|
* Parses command-line arguments.
|
|
@@ -214,6 +216,18 @@ declare function connectProviderWithSpinner(isJsonMode: boolean): Promise<Analys
|
|
|
214
216
|
* @returns Analysis result
|
|
215
217
|
*/
|
|
216
218
|
declare function analyzeWithProgress(provider: AnalysisProvider, prompts: readonly string[], date: string, context: ProjectContext | undefined, isJsonMode: boolean): Promise<AnalysisResult>;
|
|
219
|
+
/**
|
|
220
|
+
* Runs watch mode for real-time prompt analysis.
|
|
221
|
+
*
|
|
222
|
+
* This function runs indefinitely, monitoring log files for new prompts.
|
|
223
|
+
* It only exits when explicitly terminated (Ctrl+C) or an unhandled error occurs.
|
|
224
|
+
*
|
|
225
|
+
* @param provider - Analysis provider
|
|
226
|
+
* @param args - Parsed arguments
|
|
227
|
+
* @param context - Optional project context
|
|
228
|
+
* @returns Promise that never resolves naturally (runs until terminated)
|
|
229
|
+
*/
|
|
230
|
+
declare function runWatchMode(provider: AnalysisProvider, args: ParsedArgs, context: ProjectContext | undefined): Promise<never>;
|
|
217
231
|
/**
|
|
218
232
|
* Displays analysis results.
|
|
219
233
|
*
|
|
@@ -234,4 +248,4 @@ declare function handleError(error: Error, isJsonMode: boolean): void;
|
|
|
234
248
|
*/
|
|
235
249
|
declare function main(): Promise<void>;
|
|
236
250
|
|
|
237
|
-
export { analyzeWithProgress, checkAndRunSetup, connectProviderWithSpinner, displayDryRunSummary, displayResults, getOutputFilePath, handleError, main, parseArguments, readLogsWithSpinner, runConfigCheck, showHelp, showReminderStatus, showVersion, validateArguments, writeMultiDayJsonOutput, writeOutputFile };
|
|
251
|
+
export { type ParsedArgs, analyzeWithProgress, checkAndRunSetup, connectProviderWithSpinner, displayDryRunSummary, displayResults, getOutputFilePath, handleError, main, parseArguments, readLogsWithSpinner, runConfigCheck, runWatchMode, showHelp, showReminderStatus, showVersion, validateArguments, writeMultiDayJsonOutput, writeOutputFile };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import chalk6 from 'chalk';
|
|
3
|
-
import { readFileSync, realpathSync, existsSync, readdirSync, mkdirSync, writeFileSync, chmodSync } from 'fs';
|
|
3
|
+
import { readFileSync, realpathSync, existsSync, readdirSync, mkdirSync, writeFileSync, chmodSync, watch, stat, createReadStream } from 'fs';
|
|
4
4
|
import { homedir } from 'os';
|
|
5
5
|
import { join, dirname, extname, resolve, basename } from 'path';
|
|
6
6
|
import { parseArgs } from 'util';
|
|
@@ -13,6 +13,7 @@ import prompts from 'prompts';
|
|
|
13
13
|
import boxen2 from 'boxen';
|
|
14
14
|
import Table from 'cli-table3';
|
|
15
15
|
import figlet from 'figlet';
|
|
16
|
+
import { EventEmitter } from 'events';
|
|
16
17
|
import { z } from 'zod';
|
|
17
18
|
|
|
18
19
|
var __defProp = Object.defineProperty;
|
|
@@ -2692,6 +2693,216 @@ async function getAvailableProvider(config, onFallback) {
|
|
|
2692
2693
|
|
|
2693
2694
|
// src/index.ts
|
|
2694
2695
|
init_logger();
|
|
2696
|
+
var DEFAULT_DEBOUNCE_MS = 500;
|
|
2697
|
+
function extractDate2(timestamp) {
|
|
2698
|
+
try {
|
|
2699
|
+
const date = parseISO(timestamp);
|
|
2700
|
+
const dateStr = date.toISOString().split("T")[0];
|
|
2701
|
+
return dateStr ?? "unknown";
|
|
2702
|
+
} catch {
|
|
2703
|
+
return "unknown";
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
function processLines(lines, filePath, projectName) {
|
|
2707
|
+
const prompts3 = [];
|
|
2708
|
+
for (const line of lines) {
|
|
2709
|
+
const message = parseLine(line);
|
|
2710
|
+
if (message === null || !isUserMessage(message)) {
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
const content = extractContent(message);
|
|
2714
|
+
if (!content.trim()) {
|
|
2715
|
+
continue;
|
|
2716
|
+
}
|
|
2717
|
+
prompts3.push({
|
|
2718
|
+
content,
|
|
2719
|
+
timestamp: message.timestamp,
|
|
2720
|
+
sessionId: message.sessionId,
|
|
2721
|
+
project: projectName,
|
|
2722
|
+
date: extractDate2(message.timestamp)
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
return prompts3;
|
|
2726
|
+
}
|
|
2727
|
+
async function readNewContent(filePath, startPos) {
|
|
2728
|
+
return new Promise((resolve2, reject) => {
|
|
2729
|
+
const chunks = [];
|
|
2730
|
+
const stream = createReadStream(filePath, { start: startPos });
|
|
2731
|
+
stream.on("data", (chunk) => {
|
|
2732
|
+
chunks.push(chunk);
|
|
2733
|
+
});
|
|
2734
|
+
stream.on("end", () => {
|
|
2735
|
+
const content = Buffer.concat(chunks).toString("utf-8");
|
|
2736
|
+
resolve2(content);
|
|
2737
|
+
});
|
|
2738
|
+
stream.on("error", (error) => {
|
|
2739
|
+
stream.destroy();
|
|
2740
|
+
reject(error);
|
|
2741
|
+
});
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
async function getFileStats(filePath) {
|
|
2745
|
+
return new Promise((resolve2, reject) => {
|
|
2746
|
+
stat(filePath, (error, stats) => {
|
|
2747
|
+
if (error) {
|
|
2748
|
+
reject(error);
|
|
2749
|
+
} else {
|
|
2750
|
+
resolve2({
|
|
2751
|
+
path: filePath,
|
|
2752
|
+
size: stats.size,
|
|
2753
|
+
lastModified: stats.mtimeMs
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
});
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
function createLogWatcher(options = {}) {
|
|
2760
|
+
const {
|
|
2761
|
+
debounceMs = DEFAULT_DEBOUNCE_MS,
|
|
2762
|
+
projectFilter,
|
|
2763
|
+
signal,
|
|
2764
|
+
baseDir = CLAUDE_PROJECTS_DIR
|
|
2765
|
+
} = options;
|
|
2766
|
+
const emitter = new EventEmitter();
|
|
2767
|
+
const watchers = /* @__PURE__ */ new Map();
|
|
2768
|
+
const debounceTimers = /* @__PURE__ */ new Map();
|
|
2769
|
+
const filePositions = /* @__PURE__ */ new Map();
|
|
2770
|
+
let isStarted = false;
|
|
2771
|
+
let signalHandler = null;
|
|
2772
|
+
async function handleFileChange(filePath) {
|
|
2773
|
+
try {
|
|
2774
|
+
const projectName = extractProjectName(filePath);
|
|
2775
|
+
if (projectFilter && !projectName.includes(projectFilter)) {
|
|
2776
|
+
return;
|
|
2777
|
+
}
|
|
2778
|
+
const currentStats = await getFileStats(filePath);
|
|
2779
|
+
const lastPosition = filePositions.get(filePath);
|
|
2780
|
+
if (!lastPosition || currentStats.size < lastPosition.size) {
|
|
2781
|
+
filePositions.set(filePath, currentStats);
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
if (currentStats.size === lastPosition.size) {
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
const newContent = await readNewContent(filePath, lastPosition.size);
|
|
2788
|
+
filePositions.set(filePath, currentStats);
|
|
2789
|
+
const lines = newContent.split("\n").filter((line) => line.trim());
|
|
2790
|
+
const prompts3 = processLines(lines, filePath, projectName);
|
|
2791
|
+
for (const prompt of prompts3) {
|
|
2792
|
+
const event = { prompt, filePath };
|
|
2793
|
+
emitter.emit("prompt", event);
|
|
2794
|
+
}
|
|
2795
|
+
} catch (error) {
|
|
2796
|
+
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2797
|
+
emitter.emit("error", err);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
function handleDebouncedChange(filePath) {
|
|
2801
|
+
const existingTimer = debounceTimers.get(filePath);
|
|
2802
|
+
if (existingTimer) {
|
|
2803
|
+
clearTimeout(existingTimer);
|
|
2804
|
+
}
|
|
2805
|
+
const timer = setTimeout(() => {
|
|
2806
|
+
debounceTimers.delete(filePath);
|
|
2807
|
+
handleFileChange(filePath).catch((error) => {
|
|
2808
|
+
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2809
|
+
emitter.emit("error", err);
|
|
2810
|
+
});
|
|
2811
|
+
}, debounceMs);
|
|
2812
|
+
debounceTimers.set(filePath, timer);
|
|
2813
|
+
}
|
|
2814
|
+
async function watchFile(filePath) {
|
|
2815
|
+
try {
|
|
2816
|
+
const initialStats = await getFileStats(filePath);
|
|
2817
|
+
filePositions.set(filePath, initialStats);
|
|
2818
|
+
const watcher = watch(filePath, (eventType) => {
|
|
2819
|
+
if (eventType === "change") {
|
|
2820
|
+
handleDebouncedChange(filePath);
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2823
|
+
watchers.set(filePath, watcher);
|
|
2824
|
+
} catch (error) {
|
|
2825
|
+
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2826
|
+
emitter.emit("error", err);
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
async function discoverAndWatchFiles() {
|
|
2830
|
+
try {
|
|
2831
|
+
const pattern = `${baseDir}/**/*.jsonl`;
|
|
2832
|
+
const files = await glob(pattern);
|
|
2833
|
+
const projects = Array.from(
|
|
2834
|
+
new Set(files.map((file) => extractProjectName(file)))
|
|
2835
|
+
);
|
|
2836
|
+
const filteredProjects = projectFilter ? projects.filter((p) => p.includes(projectFilter)) : projects;
|
|
2837
|
+
const filesToWatch = files.filter((file) => {
|
|
2838
|
+
const project = extractProjectName(file);
|
|
2839
|
+
return filteredProjects.includes(project);
|
|
2840
|
+
});
|
|
2841
|
+
await Promise.all(filesToWatch.map(watchFile));
|
|
2842
|
+
emitter.emit("ready");
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2845
|
+
emitter.emit("error", err);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
async function start() {
|
|
2849
|
+
if (isStarted) {
|
|
2850
|
+
throw new Error("Watcher is already started");
|
|
2851
|
+
}
|
|
2852
|
+
isStarted = true;
|
|
2853
|
+
if (signal) {
|
|
2854
|
+
if (signal.aborted) {
|
|
2855
|
+
await stop();
|
|
2856
|
+
return;
|
|
2857
|
+
}
|
|
2858
|
+
signal.addEventListener("abort", () => {
|
|
2859
|
+
stop().catch((error) => {
|
|
2860
|
+
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2861
|
+
emitter.emit("error", err);
|
|
2862
|
+
});
|
|
2863
|
+
});
|
|
2864
|
+
}
|
|
2865
|
+
signalHandler = () => {
|
|
2866
|
+
stop().catch((error) => {
|
|
2867
|
+
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
2868
|
+
emitter.emit("error", err);
|
|
2869
|
+
});
|
|
2870
|
+
};
|
|
2871
|
+
process.on("SIGINT", signalHandler);
|
|
2872
|
+
process.on("SIGTERM", signalHandler);
|
|
2873
|
+
await discoverAndWatchFiles();
|
|
2874
|
+
}
|
|
2875
|
+
function stop() {
|
|
2876
|
+
if (!isStarted) {
|
|
2877
|
+
return Promise.resolve();
|
|
2878
|
+
}
|
|
2879
|
+
isStarted = false;
|
|
2880
|
+
if (signalHandler) {
|
|
2881
|
+
process.removeListener("SIGINT", signalHandler);
|
|
2882
|
+
process.removeListener("SIGTERM", signalHandler);
|
|
2883
|
+
signalHandler = null;
|
|
2884
|
+
}
|
|
2885
|
+
for (const timer of debounceTimers.values()) {
|
|
2886
|
+
clearTimeout(timer);
|
|
2887
|
+
}
|
|
2888
|
+
debounceTimers.clear();
|
|
2889
|
+
for (const watcher of watchers.values()) {
|
|
2890
|
+
watcher.close();
|
|
2891
|
+
}
|
|
2892
|
+
watchers.clear();
|
|
2893
|
+
filePositions.clear();
|
|
2894
|
+
emitter.removeAllListeners();
|
|
2895
|
+
return Promise.resolve();
|
|
2896
|
+
}
|
|
2897
|
+
function on(event, callback) {
|
|
2898
|
+
emitter.on(event, callback);
|
|
2899
|
+
}
|
|
2900
|
+
return {
|
|
2901
|
+
start,
|
|
2902
|
+
stop,
|
|
2903
|
+
on
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2695
2906
|
|
|
2696
2907
|
// src/utils/project-config.ts
|
|
2697
2908
|
init_logger();
|
|
@@ -3368,6 +3579,15 @@ function parseArguments() {
|
|
|
3368
3579
|
type: "boolean",
|
|
3369
3580
|
default: false
|
|
3370
3581
|
},
|
|
3582
|
+
watch: {
|
|
3583
|
+
type: "boolean",
|
|
3584
|
+
default: false
|
|
3585
|
+
},
|
|
3586
|
+
quiet: {
|
|
3587
|
+
type: "boolean",
|
|
3588
|
+
short: "q",
|
|
3589
|
+
default: false
|
|
3590
|
+
},
|
|
3371
3591
|
help: {
|
|
3372
3592
|
type: "boolean",
|
|
3373
3593
|
short: "h",
|
|
@@ -3400,7 +3620,9 @@ function parseArguments() {
|
|
|
3400
3620
|
compareMonth: values["compare-month"] || false,
|
|
3401
3621
|
history: values.history || false,
|
|
3402
3622
|
historySummary: values["history-summary"] || false,
|
|
3403
|
-
noHistory: values["no-history"] || false
|
|
3623
|
+
noHistory: values["no-history"] || false,
|
|
3624
|
+
watch: values.watch || false,
|
|
3625
|
+
quiet: values.quiet || false
|
|
3404
3626
|
};
|
|
3405
3627
|
} catch (error) {
|
|
3406
3628
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -3473,6 +3695,43 @@ function validateArguments(args) {
|
|
|
3473
3695
|
if (isHistoryMode && isComparisonMode) {
|
|
3474
3696
|
throw new Error("Cannot use history listing flags with comparison flags.");
|
|
3475
3697
|
}
|
|
3698
|
+
if (args.watch) {
|
|
3699
|
+
if (args.date !== "today") {
|
|
3700
|
+
throw new Error(
|
|
3701
|
+
"Cannot use --watch with --date. Watch mode monitors in real-time."
|
|
3702
|
+
);
|
|
3703
|
+
}
|
|
3704
|
+
if (args.from || args.to) {
|
|
3705
|
+
throw new Error(
|
|
3706
|
+
"Cannot use --watch with --from/--to. Watch mode monitors in real-time."
|
|
3707
|
+
);
|
|
3708
|
+
}
|
|
3709
|
+
if (args.output) {
|
|
3710
|
+
throw new Error(
|
|
3711
|
+
"Cannot use --watch with --output. Watch mode provides continuous console output."
|
|
3712
|
+
);
|
|
3713
|
+
}
|
|
3714
|
+
if (args.dryRun) {
|
|
3715
|
+
throw new Error(
|
|
3716
|
+
"Cannot use --watch with --dry-run. Watch mode performs live analysis."
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3719
|
+
if (isComparisonMode) {
|
|
3720
|
+
throw new Error(
|
|
3721
|
+
"Cannot use --watch with comparison flags. Watch mode analyzes prompts in real-time."
|
|
3722
|
+
);
|
|
3723
|
+
}
|
|
3724
|
+
if (isHistoryMode) {
|
|
3725
|
+
throw new Error(
|
|
3726
|
+
"Cannot use --watch with history flags. Watch mode monitors in real-time."
|
|
3727
|
+
);
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
if (args.quiet && !args.watch) {
|
|
3731
|
+
throw new Error(
|
|
3732
|
+
"Cannot use --quiet without --watch. Quiet mode only applies to watch mode."
|
|
3733
|
+
);
|
|
3734
|
+
}
|
|
3476
3735
|
}
|
|
3477
3736
|
function getOutputFilePath(basePath, date) {
|
|
3478
3737
|
if (!date) {
|
|
@@ -3578,6 +3837,10 @@ ${chalk6.bold("Options:")}
|
|
|
3578
3837
|
-o, --output <file> Write results to file (.md or .json extension)
|
|
3579
3838
|
--dry-run Preview prompts without performing analysis
|
|
3580
3839
|
|
|
3840
|
+
${chalk6.bold("Watch Mode:")}
|
|
3841
|
+
--watch Monitor logs in real-time and analyze new prompts
|
|
3842
|
+
-q, --quiet Show only high-severity patterns (requires --watch)
|
|
3843
|
+
|
|
3581
3844
|
${chalk6.bold("Comparison:")}
|
|
3582
3845
|
--compare-with <date> Compare current analysis with a specific date (YYYY-MM-DD)
|
|
3583
3846
|
--compare-week Compare current analysis with one week ago
|
|
@@ -3627,6 +3890,11 @@ ${chalk6.bold("Examples:")}
|
|
|
3627
3890
|
hyntx --dry-run # Preview without analysis
|
|
3628
3891
|
hyntx --from 2025-01-20 --to 2025-01-25 --dry-run # Preview date range
|
|
3629
3892
|
|
|
3893
|
+
${chalk6.bold("Watch mode:")}
|
|
3894
|
+
hyntx --watch # Monitor and analyze new prompts in real-time
|
|
3895
|
+
hyntx --watch --quiet # Show only high-severity patterns
|
|
3896
|
+
hyntx --watch --project my-app # Watch specific project only
|
|
3897
|
+
|
|
3630
3898
|
${chalk6.bold("Comparison:")}
|
|
3631
3899
|
hyntx --compare-week # Compare today with one week ago
|
|
3632
3900
|
hyntx --compare-month # Compare today with one month ago
|
|
@@ -3836,6 +4104,89 @@ async function analyzeWithProgress(provider, prompts3, date, context, isJsonMode
|
|
|
3836
4104
|
process.exit(EXIT_CODES.ERROR);
|
|
3837
4105
|
}
|
|
3838
4106
|
}
|
|
4107
|
+
function generatePromptKey(prompt) {
|
|
4108
|
+
return `${prompt.project}:${prompt.sessionId}:${prompt.timestamp}`;
|
|
4109
|
+
}
|
|
4110
|
+
function getSeverityIcon(severity) {
|
|
4111
|
+
switch (severity) {
|
|
4112
|
+
case "high":
|
|
4113
|
+
return chalk6.red("\u26A0\uFE0F");
|
|
4114
|
+
case "medium":
|
|
4115
|
+
return chalk6.yellow("\u26A0\uFE0F");
|
|
4116
|
+
case "low":
|
|
4117
|
+
return chalk6.blue("\u2139\uFE0F");
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
async function runWatchMode(provider, args, context) {
|
|
4121
|
+
const MAX_ANALYZED = 1e3;
|
|
4122
|
+
const analyzedPrompts = /* @__PURE__ */ new Map();
|
|
4123
|
+
console.log("");
|
|
4124
|
+
console.log(chalk6.bold.cyan("Watch Mode"));
|
|
4125
|
+
console.log(chalk6.dim("Monitoring Claude Code logs for new prompts..."));
|
|
4126
|
+
if (args.quiet) {
|
|
4127
|
+
console.log(chalk6.dim("Quiet mode: showing only high-severity patterns"));
|
|
4128
|
+
}
|
|
4129
|
+
console.log(chalk6.dim("Press Ctrl+C to stop"));
|
|
4130
|
+
console.log("");
|
|
4131
|
+
const watcher = createLogWatcher({
|
|
4132
|
+
projectFilter: args.project
|
|
4133
|
+
});
|
|
4134
|
+
watcher.on("ready", () => {
|
|
4135
|
+
logger.debug("Watcher ready", "watch");
|
|
4136
|
+
});
|
|
4137
|
+
watcher.on("prompt", ({ prompt }) => {
|
|
4138
|
+
const promptKey = generatePromptKey(prompt);
|
|
4139
|
+
if (analyzedPrompts.has(promptKey)) {
|
|
4140
|
+
return;
|
|
4141
|
+
}
|
|
4142
|
+
if (analyzedPrompts.size >= MAX_ANALYZED) {
|
|
4143
|
+
const firstKey = analyzedPrompts.keys().next().value;
|
|
4144
|
+
if (firstKey !== void 0) {
|
|
4145
|
+
analyzedPrompts.delete(firstKey);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
analyzedPrompts.set(promptKey, Date.now());
|
|
4149
|
+
void (async () => {
|
|
4150
|
+
try {
|
|
4151
|
+
const result = await analyzePrompts({
|
|
4152
|
+
provider,
|
|
4153
|
+
prompts: [prompt.content],
|
|
4154
|
+
date: prompt.date,
|
|
4155
|
+
context
|
|
4156
|
+
});
|
|
4157
|
+
const now = /* @__PURE__ */ new Date();
|
|
4158
|
+
const timeStr = now.toLocaleTimeString("en-US", {
|
|
4159
|
+
hour12: false,
|
|
4160
|
+
hour: "2-digit",
|
|
4161
|
+
minute: "2-digit",
|
|
4162
|
+
second: "2-digit"
|
|
4163
|
+
});
|
|
4164
|
+
const patterns = args.quiet ? result.patterns.filter((p) => p.severity === "high") : result.patterns;
|
|
4165
|
+
if (patterns.length > 0) {
|
|
4166
|
+
for (const pattern of patterns) {
|
|
4167
|
+
const icon = getSeverityIcon(pattern.severity);
|
|
4168
|
+
console.log(
|
|
4169
|
+
`[${chalk6.dim(timeStr)}] ${chalk6.cyan(prompt.project)} ${icon} ${pattern.name}`
|
|
4170
|
+
);
|
|
4171
|
+
}
|
|
4172
|
+
} else if (!args.quiet) {
|
|
4173
|
+
console.log(
|
|
4174
|
+
`[${chalk6.dim(timeStr)}] ${chalk6.cyan(prompt.project)} ${chalk6.green("\u2713")} No issues`
|
|
4175
|
+
);
|
|
4176
|
+
}
|
|
4177
|
+
} catch (error) {
|
|
4178
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4179
|
+
logger.error(`Failed to analyze prompt: ${errorMessage}`, "watch");
|
|
4180
|
+
}
|
|
4181
|
+
})();
|
|
4182
|
+
});
|
|
4183
|
+
watcher.on("error", (error) => {
|
|
4184
|
+
logger.error(`Watcher error: ${error.message}`, "watch");
|
|
4185
|
+
});
|
|
4186
|
+
await watcher.start();
|
|
4187
|
+
return await new Promise(() => {
|
|
4188
|
+
});
|
|
4189
|
+
}
|
|
3839
4190
|
function displayResults(result, format2, compact) {
|
|
3840
4191
|
if (format2 === "json") {
|
|
3841
4192
|
console.log(formatJson(result, compact));
|
|
@@ -3904,6 +4255,11 @@ async function main() {
|
|
|
3904
4255
|
const envConfig = getEnvConfig();
|
|
3905
4256
|
const projectConfig = loadProjectConfigForCwd(process.cwd());
|
|
3906
4257
|
const config = mergeConfigs(envConfig, projectConfig);
|
|
4258
|
+
if (args.watch) {
|
|
4259
|
+
const provider2 = await connectProviderWithSpinner(isJsonMode);
|
|
4260
|
+
await runWatchMode(provider2, args, config.context);
|
|
4261
|
+
return;
|
|
4262
|
+
}
|
|
3907
4263
|
const logResult = await readLogsWithSpinner(args, isJsonMode);
|
|
3908
4264
|
if (args.dryRun) {
|
|
3909
4265
|
displayDryRunSummary(logResult.prompts, args);
|
|
@@ -4075,4 +4431,4 @@ if (isMainModule) {
|
|
|
4075
4431
|
void main();
|
|
4076
4432
|
}
|
|
4077
4433
|
|
|
4078
|
-
export { analyzeWithProgress, checkAndRunSetup, connectProviderWithSpinner, displayDryRunSummary, displayResults, getOutputFilePath, handleError, main, parseArguments, readLogsWithSpinner, runConfigCheck, showHelp, showReminderStatus, showVersion, validateArguments, writeMultiDayJsonOutput, writeOutputFile };
|
|
4434
|
+
export { analyzeWithProgress, checkAndRunSetup, connectProviderWithSpinner, displayDryRunSummary, displayResults, getOutputFilePath, handleError, main, parseArguments, readLogsWithSpinner, runConfigCheck, runWatchMode, showHelp, showReminderStatus, showVersion, validateArguments, writeMultiDayJsonOutput, writeOutputFile };
|