xonecas.io
64875
Mc

mini-coder / commit e1c84e3

feat: add 12 stricter biome lint rules

New rules added to biome.json:

style:
- noShoutyConstants: discourage SCREAMING_SNAKE for non-exported consts
- noEnum: prefer union types over TypeScript enums
- noNestedTernary: ban nested ternary expressions
- useCollapsedIf: merge nested if into else-if
- useThrowNewError: require `new` with Error constructors
- useThrowOnlyError: only throw Error objects
- useNumberNamespace: prefer Number.X over global X
- useAtIndex: prefer .at(-n) over arr[arr.length - n]

complexity:
- noUselessStringConcat: ban redundant string concatenation
- noForEach: prefer for-of over .forEach()

suspicious:
- noConsole: ban console.log (catches debug leftovers)
- noEvolvingTypes: ban implicitly widening types

Fixed 15 existing violations (12 nested ternaries, 3 useAtIndex).

xonecas2026-03-18 e1c84e3343d8ba460fdb680ef7cc3f4e49195de2 parent 817223c

14 files changed

.agents/commands/ui-probe.md+5−2
@@ -4,11 +4,13 @@ description: Run one-shot mc sessions across all SDK paths, capture output, and
44
55 The goal is to capture a realistic perspective of what the users see when using mini-coder.
66
7-Run `mc` one-shots using one cheap model per Zen SDK path, capture their raw terminal output, then analyse it yourself and write `UI-REPORT.md` in the repo root. Do NOT delegate the report to the models under test.
7+Run `mc` one-shots using one cheap model per Zen SDK path, capture their raw terminal output, then analyse it yourself and write `UI-REPORT.md` in the repo root.
8+Do NOT delegate the report to the models under test.
9+Use `tmux` so you can test interactive sessions properly.
810
911 ## Models to use (one per SDK path)
1012
11-Pick cheap/free options. Verify available models at https://opencode.ai/docs/zen/ if needed, then choose:
13+Pick cheap options. Verify available models at https://opencode.ai/docs/zen/ if needed, then choose:
1214
1315 - `@ai-sdk/anthropic` path → a `zen/claude-*` haiku-class model
1416 - `@ai-sdk/google` path → a `zen/gemini-*` flash-class model
@@ -16,6 +18,7 @@ Pick cheap/free options. Verify available models at https://opencode.ai/docs/zen
1618 - `@ai-sdk/openai-compatible` path → `zen/*` or similar small low cost model
1719
1820 Avoid free models due to rate limit issues.
21+Also use a Anthropic Oauth model for completness
1922
2023 ## Prompt to give each model
2124
biome.json+15−3
@@ -26,14 +26,26 @@
2626 "style": {
2727 "noNonNullAssertion": "error",
2828 "noParameterAssign": "error",
29- "useConst": "error"
29+ "noShoutyConstants": "error",
30+ "noEnum": "error",
31+ "noNestedTernary": "error",
32+ "useConst": "error",
33+ "useCollapsedIf": "error",
34+ "useThrowNewError": "error",
35+ "useThrowOnlyError": "error",
36+ "useNumberNamespace": "error",
37+ "useAtIndex": "error"
3038 },
3139 "complexity": {
32- "noUselessCatch": "error"
40+ "noUselessCatch": "error",
41+ "noUselessStringConcat": "error",
42+ "noForEach": "error"
3343 },
3444 "suspicious": {
3545 "noDebugger": "error",
36- "noExplicitAny": "error"
46+ "noExplicitAny": "error",
47+ "noConsole": "error",
48+ "noEvolvingTypes": "error"
3749 },
3850 "correctness": {
3951 "noUnusedVariables": "error",
src/cli/commands-login.ts+3−6
@@ -91,12 +91,9 @@ export async function handleLoginCommand(
9191 writeln(` ${c.cyan(url)}`);
9292 writeln();
9393 // Try to open the browser
94- const open =
95- process.platform === "darwin"
96- ? "open"
97- : process.platform === "win32"
98- ? "start"
99- : "xdg-open";
94+ let open = "xdg-open";
95+ if (process.platform === "darwin") open = "open";
96+ else if (process.platform === "win32") open = "start";
10097 Bun.spawn([open, url], { stdout: "ignore", stderr: "ignore" });
10198 ctx.startSpinner("waiting for browser callback");
10299 },
src/cli/commands-mcp.ts+2−5
@@ -28,11 +28,8 @@ export async function handleMcpCommand(
2828 }
2929 writeln();
3030 for (const s of servers) {
31- const detail = s.url
32- ? c.dim(` ${s.url}`)
33- : s.command
34- ? c.dim(` ${s.command}`)
35- : "";
31+ const detailText = s.url ?? s.command ?? "";
32+ const detail = detailText ? c.dim(` ${detailText}`) : "";
3633 writeln(
3734 ` ${c.yellow("⚙")} ${c.bold(s.name)} ${c.dim(s.transport)}${detail}`,
3835 );
src/cli/status-bar.ts+3−2
@@ -27,8 +27,9 @@ function buildContextSegment(opts: {
2727
2828 const pct = Math.round((opts.contextTokens / opts.contextWindow) * 100);
2929 const pctStr = `${pct}%`;
30- const pctColored =
31- pct >= 90 ? c.red(pctStr) : pct >= 75 ? c.yellow(pctStr) : c.dim(pctStr);
30+ let pctColored = c.dim(pctStr);
31+ if (pct >= 90) pctColored = c.red(pctStr);
32+ else if (pct >= 75) pctColored = c.yellow(pctStr);
3233 return (
3334 c.dim(
3435 `ctx ${fmtTokens(opts.contextTokens)}/${fmtTokens(opts.contextWindow)} `,
src/cli/tool-render.ts+4−6
@@ -129,12 +129,10 @@ export function renderToolCall(toolName: string, args: unknown): void {
129129 }
130130
131131 function formatErrorBadge(result: unknown): string {
132- const msg =
133- typeof result === "string"
134- ? result
135- : result instanceof Error
136- ? result.message
137- : JSON.stringify(result);
132+ let msg: string;
133+ if (typeof result === "string") msg = result;
134+ else if (result instanceof Error) msg = result.message;
135+ else msg = JSON.stringify(result);
138136 const oneLiner = msg.split("\n")[0] ?? msg;
139137 return `${G.err} ${c.red(oneLiner)}`;
140138 }
src/cli/tool-result-renderers.ts+3−5
@@ -135,11 +135,9 @@ function renderShellResult(
135135 const stdoutLines = countShellLines(r.stdout);
136136 const stderrLines = countShellLines(r.stderr);
137137 const stdoutSingleLine = getSingleShellLine(r.stdout);
138- const badge = r.timedOut
139- ? c.yellow("timeout")
140- : r.success
141- ? c.green("done")
142- : c.red("error");
138+ let badge = c.red("error");
139+ if (r.timedOut) badge = c.yellow("timeout");
140+ else if (r.success) badge = c.green("done");
143141 const parts = buildShellSummaryParts({
144142 exitCode: r.exitCode,
145143 stdoutLines,
src/internal/file-edit/path.ts+5−6
@@ -4,7 +4,7 @@ import { join, relative } from "node:path";
44 function stripMatchingQuotes(value: string): string {
55 if (value.length < 2) return value;
66 const first = value[0];
7- const last = value[value.length - 1];
7+ const last = value.at(-1);
88 if ((first === '"' || first === "'") && first === last) {
99 return value.slice(1, -1);
1010 }
@@ -27,11 +27,10 @@ export function resolvePath(
2727 ): ResolvedPath {
2828 const cwd = cwdInput ?? process.cwd();
2929 const normalizedInput = normalizePathInput(pathInput);
30- const expanded = normalizedInput.startsWith("~/")
31- ? join(homedir(), normalizedInput.slice(2))
32- : normalizedInput === "~"
33- ? homedir()
34- : normalizedInput;
30+ let expanded = normalizedInput;
31+ if (normalizedInput.startsWith("~/"))
32+ expanded = join(homedir(), normalizedInput.slice(2));
33+ else if (normalizedInput === "~") expanded = homedir();
3534 const filePath = expanded.startsWith("/") ? expanded : join(cwd, expanded);
3635
3736 const relPath = relative(cwd, filePath);
src/llm-api/provider-options.ts+2−1
@@ -44,7 +44,8 @@ function getAnthropicThinkingOptions(
4444 /^claude-opus-4/.test(modelId);
4545 if (isAdaptive) {
4646 const isOpus = /^claude-opus-4/.test(modelId);
47- const mapped = effort === "xhigh" ? (isOpus ? "max" : "high") : effort;
47+ const xhighMapping = isOpus ? "max" : "high";
48+ const mapped = effort === "xhigh" ? xhighMapping : effort;
4849 return { anthropic: { thinking: { type: "adaptive" }, effort: mapped } };
4950 }
5051
src/llm-api/turn-context.ts+6−8
@@ -88,12 +88,9 @@ export function getMessageDiagnostics(
8888 typeof rawToolName === "string" && rawToolName.length > 0
8989 ? rawToolName
9090 : "unknown";
91- const payload =
92- "output" in partRecord
93- ? partRecord.output
94- : "result" in partRecord
95- ? partRecord.result
96- : null;
91+ let payload: unknown = null;
92+ if ("output" in partRecord) payload = partRecord.output;
93+ else if ("result" in partRecord) payload = partRecord.result;
9794 const payloadBytes = getByteLength(safeStringify(payload));
9895 toolResultBytes += payloadBytes;
9996
@@ -196,8 +193,9 @@ export function compactToolResultPayloads(
196193 const partType = (part as { type?: unknown }).type;
197194 if (partType !== "tool-result") return part;
198195
199- const payload =
200- "output" in part ? part.output : "result" in part ? part.result : null;
196+ let payload: unknown = null;
197+ if ("output" in part) payload = part.output;
198+ else if ("result" in part) payload = part.result;
201199 const serializedPayload = safeStringify(payload);
202200 const originalBytes = getByteLength(serializedPayload);
203201 if (originalBytes <= capBytes) return part;
src/llm-api/turn-execution.ts+5−6
@@ -74,7 +74,7 @@ export function annotateToolCaching(
7474 if (!isAnthropicModelFamily(modelString)) return toolSet;
7575 const keys = Object.keys(toolSet);
7676 if (keys.length === 0) return toolSet;
77- const lastKey = keys[keys.length - 1] as string;
77+ const lastKey = keys.at(-1) as string;
7878 const lastTool = (toolSet as Record<string, ToolEntry>)[lastKey] as ToolEntry;
7979 return {
8080 ...toolSet,
@@ -162,11 +162,10 @@ function normalizeToolName(raw: unknown): string {
162162 function getOpenAITextPhase(
163163 chunk: StreamTextChunk,
164164 ): "commentary" | "final_answer" | null {
165- const providerData = isRecord(chunk.providerMetadata)
166- ? chunk.providerMetadata
167- : isRecord(chunk.providerOptions)
168- ? chunk.providerOptions
169- : null;
165+ let providerData: Record<string, unknown> | null = null;
166+ if (isRecord(chunk.providerMetadata)) providerData = chunk.providerMetadata;
167+ else if (isRecord(chunk.providerOptions))
168+ providerData = chunk.providerOptions;
170169 if (!providerData) return null;
171170 const openai = providerData.openai;
172171 if (!isRecord(openai)) return null;
src/llm-api/turn-prepare-messages.ts+5−6
@@ -111,12 +111,11 @@ export function prepareTurnMessages(input: {
111111 : getMessageStats(normalised);
112112 if (apiLogOn) logApiEvent("turn context pre-prune", preStats);
113113 // Reuse preStats when pruning was a no-op (same array reference)
114- postStats =
115- pruned === normalised
116- ? preStats
117- : apiLogOn
118- ? getMessageDiagnostics(pruned)
119- : getMessageStats(pruned);
114+ if (pruned === normalised) postStats = preStats;
115+ else
116+ postStats = apiLogOn
117+ ? getMessageDiagnostics(pruned)
118+ : getMessageStats(pruned);
120119 if (apiLogOn) logApiEvent("turn context post-prune", postStats);
121120 }
122121
src/llm-api/turn-stream-events.ts+4−1
@@ -63,11 +63,14 @@ export function mapStreamChunkToTurnEvent(c: StreamChunk): TurnEvent | null {
6363 };
6464 }
6565 case "tool-result": {
66+ let result: unknown;
67+ if ("output" in c) result = c.output;
68+ else if ("result" in c) result = c.result;
6669 return {
6770 type: "tool-result",
6871 toolCallId: String(c.toolCallId ?? ""),
6972 toolName: String(c.toolName ?? ""),
70- result: "output" in c ? c.output : "result" in c ? c.result : undefined,
73+ result,
7174 isError: "isError" in c ? Boolean(c.isError) : false,
7275 };
7376 }
src/llm-api/turn.test.ts+1−1
@@ -793,7 +793,7 @@ describe("applyContextPruning", () => {
793793
794794 const pruned = applyContextPruning(messages, "balanced");
795795 expect(pruned.length).toBeLessThan(messages.length);
796- expect(pruned[pruned.length - 1]?.role).toBe("user");
796+ expect(pruned.at(-1)?.role).toBe("user");
797797 });
798798 });