style: auto-fix ESLint issues (curly braces and formatting)
- Add curly braces to all if/else/for/while statements - Fix indentation and trailing spaces - Auto-fixed 372 linting errors using eslint --fix - Remaining issues are warnings only (non-null assertions, explicit any types)
This commit is contained in:
@@ -49,7 +49,7 @@ export function createTelegramBot(config: TelegramBotConfig): Bot {
|
||||
});
|
||||
await ctx.editMessageText(
|
||||
ctx.callbackQuery.message?.text + `\n\n${parsed.approved ? '✅ Approved' : '❌ Denied'}`,
|
||||
{ parse_mode: 'Markdown' }
|
||||
{ parse_mode: 'Markdown' },
|
||||
);
|
||||
} else {
|
||||
await ctx.answerCallbackQuery({ text: 'Confirmation expired or not found' });
|
||||
|
||||
@@ -16,7 +16,7 @@ export type Command =
|
||||
|
||||
export function parseCommand(input: string): Command | null {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) return null;
|
||||
if (!trimmed) {return null;}
|
||||
|
||||
// Quit
|
||||
if (trimmed === '/quit' || trimmed === '/exit') {
|
||||
@@ -65,12 +65,12 @@ export function parseCommand(input: string): Command | null {
|
||||
if (trimmed.startsWith('/model ')) {
|
||||
const args = trimmed.slice('/model '.length).trim();
|
||||
const parts = args.split(/\s+/);
|
||||
|
||||
|
||||
// /model <tier> <provider/model> - change tier's provider/model
|
||||
if (parts.length === 2 && parts[1].includes('/')) {
|
||||
return { type: 'model', name: parts[0], providerModel: parts[1] };
|
||||
}
|
||||
|
||||
|
||||
// /model <name> - single word (backward compatibility)
|
||||
const name = parts[0];
|
||||
return { type: 'model', name };
|
||||
@@ -205,12 +205,12 @@ export const MODEL_TOOLTIPS: Record<string, string> = {
|
||||
|
||||
export function getCommandCompletions(partial: string): string[] {
|
||||
const trimmed = partial.trim();
|
||||
|
||||
|
||||
// Complete /model <tier> <provider/model>
|
||||
if (trimmed.startsWith('/model ')) {
|
||||
const args = trimmed.slice('/model '.length).trim();
|
||||
const parts = args.split(/\s+/);
|
||||
|
||||
|
||||
if (parts.length === 1) {
|
||||
// Single word - suggest model aliases
|
||||
const modelPartial = parts[0].toLowerCase();
|
||||
@@ -225,23 +225,23 @@ export function getCommandCompletions(partial: string): string[] {
|
||||
.map(provider => `/model ${parts[0]} ${provider}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Complete slash commands
|
||||
if (trimmed.startsWith('/')) {
|
||||
return SLASH_COMMANDS.filter(cmd => cmd.startsWith(trimmed.toLowerCase()));
|
||||
}
|
||||
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
export function getCommandTooltip(partial: string): string | null {
|
||||
const trimmed = partial.trim().toLowerCase();
|
||||
|
||||
|
||||
// Tooltip for /model arguments
|
||||
if (trimmed.startsWith('/model ')) {
|
||||
const args = trimmed.slice('/model '.length).trim();
|
||||
const parts = args.split(/\s+/);
|
||||
|
||||
|
||||
if (parts.length === 1) {
|
||||
// Single word - model tier or provider
|
||||
const modelArg = parts[0].toLowerCase();
|
||||
@@ -261,15 +261,15 @@ export function getCommandTooltip(partial: string): string | null {
|
||||
if (matches.length === 1) {
|
||||
return `Enter provider/model (e.g. ${matches[0]}/...)`;
|
||||
}
|
||||
return `Enter provider/model (e.g. anthropic/claude-sonnet-4)`;
|
||||
return 'Enter provider/model (e.g. anthropic/claude-sonnet-4)';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Exact match tooltip
|
||||
if (COMMAND_TOOLTIPS[trimmed]) {
|
||||
return COMMAND_TOOLTIPS[trimmed];
|
||||
}
|
||||
|
||||
|
||||
// Partial match - show tooltip if only one command matches
|
||||
if (trimmed.startsWith('/')) {
|
||||
const matches = SLASH_COMMANDS.filter(cmd => cmd.startsWith(trimmed));
|
||||
@@ -277,7 +277,7 @@ export function getCommandTooltip(partial: string): string | null {
|
||||
return COMMAND_TOOLTIPS[matches[0]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ function formatToolName(name: string): string {
|
||||
|
||||
/** Format tool args as a compact, readable summary. */
|
||||
function formatToolArgs(args: unknown): string {
|
||||
if (!args || typeof args !== 'object') return '';
|
||||
if (!args || typeof args !== 'object') {return '';}
|
||||
const entries = Object.entries(args as Record<string, unknown>);
|
||||
if (entries.length === 0) return '';
|
||||
if (entries.length === 0) {return '';}
|
||||
const parts = entries.map(([key, value]) => {
|
||||
if (typeof value === 'string') {
|
||||
const display = value.length > 50 ? value.slice(0, 47) + '...' : value;
|
||||
@@ -71,7 +71,7 @@ export function App({
|
||||
// This replaces the process.stdout.write callback (which corrupts Ink rendering)
|
||||
// with one that updates React state to show tool activity in the streaming area.
|
||||
useEffect(() => {
|
||||
if (!agent) return;
|
||||
if (!agent) {return;}
|
||||
|
||||
const handleToolEvent = (event: ToolUseEvent) => {
|
||||
if (event.type === 'start') {
|
||||
@@ -137,7 +137,7 @@ export function App({
|
||||
|
||||
const handleSubmit = useCallback(async (value: string) => {
|
||||
const command = parseCommand(value);
|
||||
if (!command) return;
|
||||
if (!command) {return;}
|
||||
|
||||
setInput('');
|
||||
|
||||
@@ -212,7 +212,7 @@ export function App({
|
||||
return;
|
||||
|
||||
case 'transfer': {
|
||||
const xferMsg: Message = { role: 'assistant', content: `Transfer not supported in fullscreen mode.` };
|
||||
const xferMsg: Message = { role: 'assistant', content: 'Transfer not supported in fullscreen mode.' };
|
||||
const xferWithTs = session.addMessage(xferMsg);
|
||||
setMessages(prev => [...prev, xferWithTs]);
|
||||
return;
|
||||
@@ -222,7 +222,7 @@ export function App({
|
||||
break; // Continue to message handling
|
||||
}
|
||||
|
||||
if (command.type !== 'message' || isStreaming) return;
|
||||
if (command.type !== 'message' || isStreaming) {return;}
|
||||
|
||||
// Add user message to UI (and session if no agent — agent adds it internally)
|
||||
const userMessage: Message = { role: 'user', content: command.content };
|
||||
|
||||
@@ -19,15 +19,15 @@ export const InputBar = memo(function InputBar({
|
||||
placeholder = 'Type a message...',
|
||||
}: InputBarProps): React.ReactElement {
|
||||
const completions = useMemo(() => {
|
||||
if (!value.startsWith('/')) return [];
|
||||
if (!value.startsWith('/')) {return [];}
|
||||
return getCommandCompletions(value);
|
||||
}, [value]);
|
||||
|
||||
|
||||
const tooltip = useMemo(() => {
|
||||
if (!value.startsWith('/')) return null;
|
||||
if (!value.startsWith('/')) {return null;}
|
||||
return getCommandTooltip(value);
|
||||
}, [value]);
|
||||
|
||||
|
||||
const showTooltip = value.startsWith('/') && (tooltip || completions.length > 1);
|
||||
|
||||
return (
|
||||
@@ -36,14 +36,14 @@ export const InputBar = memo(function InputBar({
|
||||
{showTooltip && (
|
||||
<Box paddingX={2} height={1} justifyContent="center">
|
||||
<Text color="gray">
|
||||
{tooltip
|
||||
{tooltip
|
||||
? `→ ${tooltip}`
|
||||
: `${completions.length} commands (Tab)`
|
||||
}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
|
||||
{/* Input bar */}
|
||||
<Box borderStyle="single" borderColor="blue" paddingX={1}>
|
||||
<Text color="blue">{'> '}</Text>
|
||||
|
||||
@@ -19,26 +19,26 @@ function formatTimestamp(timestamp: number): string {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
|
||||
if (seconds < 60) return 'just now';
|
||||
if (minutes < 60) return `${minutes}m ago`;
|
||||
if (hours < 24) return `${hours}h ago`;
|
||||
if (days < 7) return `${days}d ago`;
|
||||
|
||||
if (seconds < 60) {return 'just now';}
|
||||
if (minutes < 60) {return `${minutes}m ago`;}
|
||||
if (hours < 24) {return `${hours}h ago`;}
|
||||
if (days < 7) {return `${days}d ago`;}
|
||||
return new Date(timestamp).toLocaleDateString([], { month: 'short', day: 'numeric' });
|
||||
}
|
||||
|
||||
// Individual message component
|
||||
const MessageItem = memo(function MessageItem({
|
||||
message,
|
||||
index
|
||||
}: {
|
||||
message: Message;
|
||||
const MessageItem = memo(function MessageItem({
|
||||
message,
|
||||
index,
|
||||
}: {
|
||||
message: Message;
|
||||
index: number;
|
||||
}): React.ReactElement {
|
||||
const isUser = message.role === 'user';
|
||||
const accentColor = isUser ? 'blue' : '#ff8c00';
|
||||
const timestampText = message.timestamp ? formatTimestamp(message.timestamp) : '';
|
||||
|
||||
|
||||
return (
|
||||
<Box
|
||||
key={index}
|
||||
@@ -59,7 +59,7 @@ const MessageItem = memo(function MessageItem({
|
||||
</Text>
|
||||
<Text color="gray">| {timestampText}</Text>
|
||||
</Box>
|
||||
|
||||
|
||||
{/* Content */}
|
||||
<Text wrap="wrap">
|
||||
{message.role === 'assistant'
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function startFullscreenTui(config: FullscreenTuiConfig): Promise<v
|
||||
model: config.model,
|
||||
agent: config.agent,
|
||||
onExit: config.onExit,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
await waitUntilExit();
|
||||
|
||||
@@ -91,10 +91,10 @@ const terminalRenderer: RendererObject = {
|
||||
table({ header, rows, align }: Tokens.Table): string {
|
||||
// Render cell contents
|
||||
const headerTexts = header.map((cell: Tokens.TableCell) =>
|
||||
this.parser.parseInline(cell.tokens)
|
||||
this.parser.parseInline(cell.tokens),
|
||||
);
|
||||
const rowTexts = rows.map((row: Tokens.TableCell[]) =>
|
||||
row.map((cell: Tokens.TableCell) => this.parser.parseInline(cell.tokens))
|
||||
row.map((cell: Tokens.TableCell) => this.parser.parseInline(cell.tokens)),
|
||||
);
|
||||
|
||||
// Calculate column widths (strip ANSI for measurement)
|
||||
@@ -108,8 +108,8 @@ const terminalRenderer: RendererObject = {
|
||||
const pad = (text: string, width: number, alignment: string | null) => {
|
||||
const visible = stripAnsi(text).length;
|
||||
const diff = width - visible;
|
||||
if (diff <= 0) return text;
|
||||
if (alignment === 'right') return ' '.repeat(diff) + text;
|
||||
if (diff <= 0) {return text;}
|
||||
if (alignment === 'right') {return ' '.repeat(diff) + text;}
|
||||
if (alignment === 'center') {
|
||||
const left = Math.floor(diff / 2);
|
||||
return ' '.repeat(left) + text + ' '.repeat(diff - left);
|
||||
@@ -119,7 +119,7 @@ const terminalRenderer: RendererObject = {
|
||||
|
||||
// Build header row
|
||||
const headerRow = ' ' + headerTexts.map((h: string, i: number) =>
|
||||
`\x1b[1m${pad(h, colWidths[i], align[i])}\x1b[0m`
|
||||
`\x1b[1m${pad(h, colWidths[i], align[i])}\x1b[0m`,
|
||||
).join(' │ ');
|
||||
|
||||
// Build separator
|
||||
@@ -128,8 +128,8 @@ const terminalRenderer: RendererObject = {
|
||||
// Build data rows
|
||||
const dataRows = rowTexts.map((row: string[]) =>
|
||||
' ' + row.map((cell: string, i: number) =>
|
||||
pad(cell, colWidths[i], align[i])
|
||||
).join(' │ ')
|
||||
pad(cell, colWidths[i], align[i]),
|
||||
).join(' │ '),
|
||||
);
|
||||
|
||||
return [headerRow, separator, ...dataRows].join('\n') + '\n';
|
||||
|
||||
@@ -63,21 +63,21 @@ export class MinimalTui {
|
||||
|
||||
const completions = getCommandCompletions(line);
|
||||
const tooltip = getCommandTooltip(line);
|
||||
|
||||
|
||||
let hint = '';
|
||||
|
||||
|
||||
if (completions.length === 1 && completions[0] !== line) {
|
||||
// Show the remaining part of the completion as a hint
|
||||
hint = completions[0].slice(line.length);
|
||||
}
|
||||
|
||||
|
||||
// Add tooltip if available
|
||||
if (tooltip) {
|
||||
hint += ` ${colors.gray}— ${tooltip}${colors.reset}`;
|
||||
} else if (completions.length > 1) {
|
||||
hint += ` ${colors.gray}[${completions.length} options, Tab to complete]${colors.reset}`;
|
||||
}
|
||||
|
||||
|
||||
if (hint && hint !== this.currentHint) {
|
||||
this.clearHint();
|
||||
this.currentHint = hint;
|
||||
@@ -467,7 +467,7 @@ export class MinimalTui {
|
||||
fullContent += event.content;
|
||||
}
|
||||
if (event.type === 'fallback_warning' && event.fallbackReason) {
|
||||
console.warn(`\n⚠ Using fallback model`);
|
||||
console.warn('\n⚠ Using fallback model');
|
||||
}
|
||||
if (event.type === 'done' && event.usage) {
|
||||
this.totalUsage.inputTokens += event.usage.inputTokens;
|
||||
|
||||
Reference in New Issue
Block a user