xonecas.io
64875
Mc

mini-coder / commit 873ad28

chore: add lefthook, improve type safety, and clean up config

- Add lefthook for git hooks with prepare script
- Remove noConsole biome rule
- Replace `as any` casts with proper types in tests
- Add middleware specificationVersion and proper model typing
- Simplify idea-check command description
- Minor formatting fixes

xonecas2026-03-18 873ad280aa082804740a929048521edbcea8b1c3 parent fb341f7

7 files changed

.agents/commands/idea-check.md+4−5
@@ -2,16 +2,15 @@
22 description: Check the codebase for correctness acording to the original idea.
33 ---
44
5-Do a complete audit the implementation of ./mini-coder-idea.md return a final report
5+Do a complete audit the implementation of ./mini-coder-idea.md in this codebase return a final report.
66
77 Use the shell tool and `bun run dev` to do manual tests. One shot and interactive sessions. And to analyze the console output and ui from a users perspective.
88
9-Employ the perspective of a senior application design architech and senior developer and analysie, simplify, organize and improve the code until it closer reflects the original idea. Avoid excessive abstraction layers, try/catch nesting and other common pitfalls. Employ YAGNI in your review.
10-
11-Question design choices and refactor as needed while staying compliant with the original idea. This includes changing UI and console output as needed.
12-
9+Employ YAGNI in your review.
1310 Check TODO.md for know issues already tracked.
1411
12+Question design choices and rethink as needed while staying compliant with the original idea. This includes changing UI and console output as needed.
13+
1514 If you think the codebase is now at a good place, check the recent commit for all changes and report the final status to the user.
1615
1716 Review your findings with me before doing any changes.
biome.json+1−2
@@ -30,8 +30,7 @@
3030 },
3131 "suspicious": {
3232 "noDebugger": "error",
33- "noExplicitAny": "error",
34- "noConsole": "error"
33+ "noExplicitAny": "error"
3534 },
3635 "correctness": {
3736 "noUnusedVariables": "error",
lefthook.yml+15−0
@@ -0,0 +1,15 @@
1+pre-commit:
2+ parallel: true
3+ commands:
4+ jscpd:
5+ run: bun run jscpd
6+ knip:
7+ run: bun run knip
8+ typecheck:
9+ run: bun run typecheck
10+ format:
11+ run: bun run format
12+ lint:
13+ run: bun run lint
14+ test:
15+ run: bun run test
package.json+2−1
@@ -18,7 +18,7 @@
1818 "test": "bun test --only-failures",
1919 "test:verbose": "bun test",
2020 "jscpd": "jscpd src",
21- "ui-oneshot": "bun scripts/ui-oneshot.ts"
21+ "prepare": "lefthook install"
2222 },
2323 "dependencies": {
2424 "@ai-sdk/anthropic": "^3.0.60",
@@ -37,6 +37,7 @@
3737 "@types/bun": "latest",
3838 "jscpd": "^4.0.8",
3939 "knip": "^5.86.0",
40+ "lefthook": "^2.1.4",
4041 "typescript": "^5.9.3"
4142 },
4243 "knip": {
src/llm-api/turn-context.ts+1−2
@@ -247,8 +247,7 @@ function withCacheBreakpoint(msg: CoreMessage): CoreMessage {
247247 providerOptions: {
248248 ...(msg?.providerOptions ?? {}),
249249 anthropic: {
250- ...((msg?.providerOptions?.anthropic as Record<string, unknown>) ??
251- {}),
250+ ...((msg?.providerOptions?.anthropic as Record<string, unknown>) ?? {}),
252251 cacheControl: { type: "ephemeral" },
253252 },
254253 },
src/llm-api/turn-request.ts+3−2
@@ -2,8 +2,8 @@ import { type streamText, wrapLanguageModel } from "ai";
22
33 import { isAnthropicModelFamily } from "./model-routing.ts";
44 import type { ThinkingEffort } from "./provider-options.ts";
5-import { annotateAnthropicCacheBreakpoints } from "./turn-context.ts";
65 import type { ContextPruningMode } from "./turn-context.ts";
6+import { annotateAnthropicCacheBreakpoints } from "./turn-context.ts";
77 import { prepareTurnMessages } from "./turn-prepare-messages.ts";
88 import { buildTurnProviderOptions } from "./turn-provider-options.ts";
99
@@ -64,9 +64,10 @@ export function buildStreamTextRequest(
6464 // This runs on every step so the cache breakpoints always track the tail.
6565 const model = isAnthropicModelFamily(input.modelString)
6666 ? wrapLanguageModel({
67- model: input.model,
67+ model: input.model as Parameters<typeof wrapLanguageModel>[0]["model"],
6868 middleware: [
6969 {
70+ specificationVersion: "v3" as const,
7071 transformParams: async ({ params }) => ({
7172 ...params,
7273 prompt: annotateAnthropicCacheBreakpoints(
src/llm-api/turn.test.ts+8−7
@@ -1,4 +1,5 @@
11 import { describe, expect, test } from "bun:test";
2+import type { ToolSet } from "ai";
23 import {
34 getReasoningDeltaFromStreamChunk,
45 isOpenAIGPT,
@@ -939,20 +940,20 @@ describe("annotateToolCaching", () => {
939940 const toolSet = {
940941 read: { description: "Read a file" },
941942 write: { description: "Write a file" },
942- } as any;
943+ } as unknown as ToolSet;
943944 const result = annotateToolCaching(toolSet, "anthropic/claude-sonnet-4-6");
944- expect((result.write as any).providerOptions).toEqual({
945+ expect(result.write?.providerOptions).toEqual({
945946 anthropic: { cacheControl: { type: "ephemeral" } },
946947 });
947- expect((result.read as any).providerOptions).toBeUndefined();
948+ expect(result.read?.providerOptions).toBeUndefined();
948949 });
949950
950951 test("adds cache control to last tool for zen anthropic models", () => {
951952 const toolSet = {
952953 shell: { description: "Run shell" },
953- } as any;
954+ } as unknown as ToolSet;
954955 const result = annotateToolCaching(toolSet, "zen/claude-sonnet-4-6");
955- expect((result.shell as any).providerOptions).toEqual({
956+ expect(result.shell?.providerOptions).toEqual({
956957 anthropic: { cacheControl: { type: "ephemeral" } },
957958 });
958959 });
@@ -960,13 +961,13 @@ describe("annotateToolCaching", () => {
960961 test("returns toolset unchanged for non-anthropic models", () => {
961962 const toolSet = {
962963 read: { description: "Read a file" },
963- } as any;
964+ } as unknown as ToolSet;
964965 const result = annotateToolCaching(toolSet, "openai/gpt-5.4");
965966 expect(result).toBe(toolSet);
966967 });
967968
968969 test("returns empty toolset unchanged", () => {
969- const toolSet = {} as any;
970+ const toolSet = {} as unknown as ToolSet;
970971 const result = annotateToolCaching(toolSet, "anthropic/claude-sonnet-4-6");
971972 expect(result).toBe(toolSet);
972973 });