Enable more biome lints and fix things

This commit is contained in:
Mario Zechner 2025-12-21 22:56:20 +01:00
parent 9c18439c4d
commit d5fd685901
57 changed files with 151 additions and 199 deletions

View file

@ -420,7 +420,7 @@ export async function compact(
generateTurnPrefixSummary(turnPrefixMessages, model, settings.reserveTokens, apiKey, signal),
]);
// Merge into single summary
summary = historyResult + "\n\n---\n\n**Turn Context (split turn):**\n\n" + turnPrefixResult;
summary = `${historyResult}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult}`;
} else {
// Just generate history summary
summary = await generateSummary(

View file

@ -84,7 +84,7 @@ function escapeHtml(text: string): string {
function shortenPath(path: string): string {
const home = homedir();
return path.startsWith(home) ? "~" + path.slice(home.length) : path;
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
}
function replaceTabs(text: string): string {

View file

@ -54,7 +54,7 @@ export function isBashExecutionMessage(msg: AppMessage | Message): msg is BashEx
export function bashExecutionToText(msg: BashExecutionMessage): string {
let text = `Ran \`${msg.command}\`\n`;
if (msg.output) {
text += "```\n" + msg.output + "\n```";
text += `\`\`\`\n${msg.output}\n\`\`\``;
} else {
text += "(no output)";
}

View file

@ -76,8 +76,6 @@ const ModelsConfigSchema = Type.Object({
});
type ModelsConfig = Static<typeof ModelsConfigSchema>;
type ProviderConfig = Static<typeof ProviderConfigSchema>;
type ModelDefinition = Static<typeof ModelDefinitionSchema>;
// Custom provider API key mappings (provider name -> apiKey config)
const customProviderApiKeys: Map<string, string> = new Map();

View file

@ -243,7 +243,7 @@ export class SessionManager {
private getSessionDirectory(): string {
const cwd = process.cwd();
// Replace all path separators and colons (for Windows drive letters) with dashes
const safePath = "--" + cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-") + "--";
const safePath = `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
const configDir = getAgentDir();
const sessionDir = join(configDir, "sessions", safePath);
@ -325,9 +325,9 @@ export class SessionManager {
// Write to file only if enabled
if (this.enabled) {
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
appendFileSync(this.sessionFile, `${JSON.stringify(entry)}\n`);
for (const memEntry of this.inMemoryEntries.slice(1)) {
appendFileSync(this.sessionFile, JSON.stringify(memEntry) + "\n");
appendFileSync(this.sessionFile, `${JSON.stringify(memEntry)}\n`);
}
}
}
@ -346,7 +346,7 @@ export class SessionManager {
this.inMemoryEntries.push(entry);
// Write to file only if enabled
if (this.enabled) {
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
appendFileSync(this.sessionFile, `${JSON.stringify(entry)}\n`);
}
}
}
@ -365,7 +365,7 @@ export class SessionManager {
this.inMemoryEntries.push(entry);
// Write to file only if enabled
if (this.enabled) {
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
appendFileSync(this.sessionFile, `${JSON.stringify(entry)}\n`);
}
}
}
@ -385,7 +385,7 @@ export class SessionManager {
this.inMemoryEntries.push(entry);
// Write to file only if enabled
if (this.enabled) {
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
appendFileSync(this.sessionFile, `${JSON.stringify(entry)}\n`);
}
}
}
@ -395,7 +395,7 @@ export class SessionManager {
this.inMemoryEntries.push(entry);
// Write to file only if enabled
if (this.enabled) {
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
appendFileSync(this.sessionFile, `${JSON.stringify(entry)}\n`);
}
}
@ -625,7 +625,7 @@ export class SessionManager {
thinkingLevel: state.thinkingLevel,
branchedFrom: this.sessionFile,
};
appendFileSync(newSessionFile, JSON.stringify(entry) + "\n");
appendFileSync(newSessionFile, `${JSON.stringify(entry)}\n`);
// Write messages up to and including the branch point (if >= 0)
if (branchFromIndex >= 0) {
@ -636,7 +636,7 @@ export class SessionManager {
timestamp: new Date().toISOString(),
message,
};
appendFileSync(newSessionFile, JSON.stringify(messageEntry) + "\n");
appendFileSync(newSessionFile, `${JSON.stringify(messageEntry)}\n`);
}
}
@ -675,7 +675,7 @@ export class SessionManager {
if (this.enabled) {
// Write to file
for (const entry of newEntries) {
appendFileSync(newSessionFile, JSON.stringify(entry) + "\n");
appendFileSync(newSessionFile, `${JSON.stringify(entry)}\n`);
}
return newSessionFile;
} else {

View file

@ -153,12 +153,12 @@ function loadCommandsFromDir(dir: string, source: "user" | "project", subdir: st
content,
source: sourceStr,
});
} catch (error) {
} catch (_error) {
// Silently skip files that can't be read
}
}
}
} catch (error) {
} catch (_error) {
// Silently skip directories that can't be read
}

View file

@ -89,7 +89,7 @@ export const grepTool: AgentTool<typeof grepSchema> = {
let searchStat: Stats;
try {
searchStat = statSync(searchPath);
} catch (err) {
} catch (_err) {
settle(() => reject(new Error(`Path not found: ${searchPath}`)));
return;
}

View file

@ -126,7 +126,6 @@ export const readTool: AgentTool<typeof readSchema> = {
details = { truncation };
} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
// User specified limit, there's more content, but no truncation
const endLineDisplay = startLineDisplay + userLimitedLines - 1;
const remaining = allLines.length - (startLine + userLimitedLines);
const nextOffset = startLine + userLimitedLines + 1;

View file

@ -261,5 +261,5 @@ export function truncateLine(
if (line.length <= maxChars) {
return { text: line, wasTruncated: false };
}
return { text: line.slice(0, maxChars) + "... [truncated]", wasTruncated: true };
return { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };
}

View file

@ -95,13 +95,13 @@ export class ArminComponent implements Component {
// Clip row to available width before applying color
const clipped = row.slice(0, availableWidth).join("");
const padRight = Math.max(0, width - padding - clipped.length);
return " " + theme.fg("accent", clipped) + " ".repeat(padRight);
return ` ${theme.fg("accent", clipped)}${" ".repeat(padRight)}`;
});
// Add "ARMIN SAYS HI" at the end
const message = "ARMIN SAYS HI";
const msgPadRight = Math.max(0, width - padding - message.length);
this.cachedLines.push(" " + theme.fg("accent", message) + " ".repeat(msgPadRight));
this.cachedLines.push(` ${theme.fg("accent", message)}${" ".repeat(msgPadRight)}`);
this.cachedWidth = width;
this.cachedVersion = this.gridVersion;

View file

@ -132,11 +132,11 @@ export class BashExecutionComponent extends Container {
if (this.expanded) {
// Show all lines
const displayText = availableLines.map((line) => theme.fg("muted", line)).join("\n");
this.contentContainer.addChild(new Text("\n" + displayText, 1, 0));
this.contentContainer.addChild(new Text(`\n${displayText}`, 1, 0));
} else {
// Render preview lines, then cap at PREVIEW_LINES visual lines
const tempText = new Text(
"\n" + previewLogicalLines.map((line) => theme.fg("muted", line)).join("\n"),
`\n${previewLogicalLines.map((line) => theme.fg("muted", line)).join("\n")}`,
1,
0,
);
@ -170,7 +170,7 @@ export class BashExecutionComponent extends Container {
}
if (statusParts.length > 0) {
this.contentContainer.addChild(new Text("\n" + statusParts.join("\n"), 1, 0));
this.contentContainer.addChild(new Text(`\n${statusParts.join("\n")}`, 1, 0));
}
}
}

View file

@ -168,17 +168,17 @@ export class FooterComponent implements Component {
// Format token counts (similar to web-ui)
const formatTokens = (count: number): string => {
if (count < 1000) return count.toString();
if (count < 10000) return (count / 1000).toFixed(1) + "k";
if (count < 1000000) return Math.round(count / 1000) + "k";
if (count < 10000000) return (count / 1000000).toFixed(1) + "M";
return Math.round(count / 1000000) + "M";
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
if (count < 1000000) return `${Math.round(count / 1000)}k`;
if (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;
return `${Math.round(count / 1000000)}M`;
};
// Replace home directory with ~
let pwd = process.cwd();
const home = process.env.HOME || process.env.USERPROFILE;
if (home && pwd.startsWith(home)) {
pwd = "~" + pwd.slice(home.length);
pwd = `~${pwd.slice(home.length)}`;
}
// Add git branch if available
@ -247,7 +247,7 @@ export class FooterComponent implements Component {
if (statsLeftWidth > width) {
// Truncate statsLeft to fit width (no room for right side)
const plainStatsLeft = statsLeft.replace(/\x1b\[[0-9;]*m/g, "");
statsLeft = plainStatsLeft.substring(0, width - 3) + "...";
statsLeft = `${plainStatsLeft.substring(0, width - 3)}...`;
statsLeftWidth = visibleWidth(statsLeft);
}

View file

@ -58,7 +58,7 @@ export class HookSelectorComponent extends Container {
if (isSelected) {
text = theme.fg("accent", "→ ") + theme.fg("accent", option);
} else {
text = " " + theme.fg("text", option);
text = ` ${theme.fg("text", option)}`;
}
this.listContainer.addChild(new Text(text, 1, 0));

View file

@ -175,12 +175,12 @@ export class ModelSelectorComponent extends Container {
const modelText = `${item.id}`;
const providerBadge = theme.fg("muted", `[${item.provider}]`);
const checkmark = isCurrent ? theme.fg("success", " ✓") : "";
line = prefix + theme.fg("accent", modelText) + " " + providerBadge + checkmark;
line = `${prefix + theme.fg("accent", modelText)} ${providerBadge}${checkmark}`;
} else {
const modelText = ` ${item.id}`;
const providerBadge = theme.fg("muted", `[${item.provider}]`);
const checkmark = isCurrent ? theme.fg("success", " ✓") : "";
line = modelText + " " + providerBadge + checkmark;
line = `${modelText} ${providerBadge}${checkmark}`;
}
this.listContainer.addChild(new Text(line, 0, 0));

View file

@ -21,7 +21,7 @@ import { renderDiff } from "./diff.js";
function shortenPath(path: string): string {
const home = os.homedir();
if (path.startsWith(home)) {
return "~" + path.slice(home.length);
return `~${path.slice(home.length)}`;
}
return path;
}
@ -269,7 +269,7 @@ export class ToolExecutionComponent extends Container {
);
}
}
text += "\n" + theme.fg("warning", `[${warnings.join(". ")}]`);
text += `\n${theme.fg("warning", `[${warnings.join(". ")}]`)}`;
}
}
} else if (this.toolName === "read") {
@ -284,7 +284,7 @@ export class ToolExecutionComponent extends Container {
pathDisplay += theme.fg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
}
text = theme.fg("toolTitle", theme.bold("read")) + " " + pathDisplay;
text = `${theme.fg("toolTitle", theme.bold("read"))} ${pathDisplay}`;
if (this.result) {
const output = this.getTextOutput();
@ -377,17 +377,17 @@ export class ToolExecutionComponent extends Container {
if (this.result.isError) {
const errorText = this.getTextOutput();
if (errorText) {
text += "\n\n" + theme.fg("error", errorText);
text += `\n\n${theme.fg("error", errorText)}`;
}
} else if (this.result.details?.diff) {
text += "\n\n" + renderDiff(this.result.details.diff, { filePath: rawPath });
text += `\n\n${renderDiff(this.result.details.diff, { filePath: rawPath })}`;
}
}
} else if (this.toolName === "ls") {
const path = shortenPath(this.args?.path || ".");
const limit = this.args?.limit;
text = theme.fg("toolTitle", theme.bold("ls")) + " " + theme.fg("accent", path);
text = `${theme.fg("toolTitle", theme.bold("ls"))} ${theme.fg("accent", path)}`;
if (limit !== undefined) {
text += theme.fg("toolOutput", ` (limit ${limit})`);
}
@ -400,7 +400,7 @@ export class ToolExecutionComponent extends Container {
const displayLines = lines.slice(0, maxLines);
const remaining = lines.length - maxLines;
text += "\n\n" + displayLines.map((line: string) => theme.fg("toolOutput", line)).join("\n");
text += `\n\n${displayLines.map((line: string) => theme.fg("toolOutput", line)).join("\n")}`;
if (remaining > 0) {
text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
}
@ -416,7 +416,7 @@ export class ToolExecutionComponent extends Container {
if (truncation?.truncated) {
warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
}
text += "\n" + theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`);
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
}
}
} else if (this.toolName === "find") {
@ -441,7 +441,7 @@ export class ToolExecutionComponent extends Container {
const displayLines = lines.slice(0, maxLines);
const remaining = lines.length - maxLines;
text += "\n\n" + displayLines.map((line: string) => theme.fg("toolOutput", line)).join("\n");
text += `\n\n${displayLines.map((line: string) => theme.fg("toolOutput", line)).join("\n")}`;
if (remaining > 0) {
text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
}
@ -457,7 +457,7 @@ export class ToolExecutionComponent extends Container {
if (truncation?.truncated) {
warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
}
text += "\n" + theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`);
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
}
}
} else if (this.toolName === "grep") {
@ -486,7 +486,7 @@ export class ToolExecutionComponent extends Container {
const displayLines = lines.slice(0, maxLines);
const remaining = lines.length - maxLines;
text += "\n\n" + displayLines.map((line: string) => theme.fg("toolOutput", line)).join("\n");
text += `\n\n${displayLines.map((line: string) => theme.fg("toolOutput", line)).join("\n")}`;
if (remaining > 0) {
text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
}
@ -506,7 +506,7 @@ export class ToolExecutionComponent extends Container {
if (linesTruncated) {
warnings.push("some lines truncated");
}
text += "\n" + theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`);
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
}
}
} else {
@ -514,10 +514,10 @@ export class ToolExecutionComponent extends Container {
text = theme.fg("toolTitle", theme.bold(this.toolName));
const content = JSON.stringify(this.args, null, 2);
text += "\n\n" + content;
text += `\n\n${content}`;
const output = this.getTextOutput();
if (output) {
text += "\n" + output;
text += `\n${output}`;
}
}

View file

@ -239,7 +239,7 @@ export class InteractiveMode {
"\n" +
theme.fg("dim", "drop files") +
theme.fg("muted", " to attach");
const header = new Text(logo + "\n" + instructions, 1, 0);
const header = new Text(`${logo}\n${instructions}`, 1, 0);
// Setup UI layout
this.ui.addChild(new Spacer(1));
@ -1340,7 +1340,7 @@ export class InteractiveMode {
if (queuedMessages.length > 0) {
this.pendingMessagesContainer.addChild(new Spacer(1));
for (const message of queuedMessages) {
const queuedText = theme.fg("dim", "Queued: " + message);
const queuedText = theme.fg("dim", `Queued: ${message}`);
this.pendingMessagesContainer.addChild(new TruncatedText(queuedText, 1, 0));
}
}
@ -1808,7 +1808,7 @@ export class InteractiveMode {
this.chatContainer.addChild(new Spacer(1));
this.chatContainer.addChild(
new Text(theme.fg("accent", "✓ Context cleared") + "\n" + theme.fg("muted", "Started fresh session"), 1, 1),
new Text(`${theme.fg("accent", "✓ Context cleared")}\n${theme.fg("muted", "Started fresh session")}`, 1, 1),
);
this.ui.requestRender();
}
@ -1840,7 +1840,7 @@ export class InteractiveMode {
this.chatContainer.addChild(new Spacer(1));
this.chatContainer.addChild(
new Text(theme.fg("accent", "✓ Debug log written") + "\n" + theme.fg("muted", debugLogPath), 1, 1),
new Text(`${theme.fg("accent", "✓ Debug log written")}\n${theme.fg("muted", debugLogPath)}`, 1, 1),
);
this.ui.requestRender();
}

View file

@ -534,7 +534,7 @@ export function initTheme(themeName?: string, enableWatcher: boolean = false): v
if (enableWatcher) {
startThemeWatcher();
}
} catch (error) {
} catch (_error) {
// Theme is invalid - fall back to dark theme silently
currentThemeName = "dark";
theme = loadTheme("dark");
@ -598,7 +598,7 @@ function startThemeWatcher(): void {
if (onThemeChangeCallback) {
onThemeChangeCallback();
}
} catch (error) {
} catch (_error) {
// Ignore errors (file might be in invalid state while being edited)
}
}, 100);
@ -619,7 +619,7 @@ function startThemeWatcher(): void {
}, 100);
}
});
} catch (error) {
} catch (_error) {
// Ignore errors starting watcher
}
}

View file

@ -456,7 +456,7 @@ export class RpcClient {
},
});
this.process!.stdin!.write(JSON.stringify(fullCommand) + "\n");
this.process!.stdin!.write(`${JSON.stringify(fullCommand)}\n`);
});
}

View file

@ -44,7 +44,7 @@ export function getShellConfig(): { shell: string; args: string[] } {
return cachedShellConfig;
}
throw new Error(
`Custom shell path not found: ${customShellPath}\n` + `Please update shellPath in ~/.pi/agent/settings.json`,
`Custom shell path not found: ${customShellPath}\nPlease update shellPath in ~/.pi/agent/settings.json`,
);
}