import '@johnlindquist/kit';
const logFile = await path({ placeholder: 'Select a log file' });
const logContent = await readFile(logFile, 'utf-8');
const errorRegex = /error|exception|fail/i;
const errorLines = logContent.split('\n').filter(line => errorRegex.test(line));
const pattern = await arg({ placeholder: 'Enter a pattern to search for' });
const patternRegex = new RegExp(pattern);
const patternLines = logContent.split('\n').filter(line => patternRegex.test(line));
const summary = `
# Log Analysis Report
## Log File:
${logFile}
## Error Summary:
${errorLines.length} errors found
${errorLines.join('\n')}
## Pattern Summary:
${patternLines.length} lines found matching "${pattern}"
${patternLines.join('\n')}
`;
await div(md(summary));