xonecas.io
64875
Mc

mini-coder / commit 40f0799

chore: fix knip findings

xonecas2026-04-08 40f0799b1e9d822083038a0fc66eb64df7a0b06c parent 0c58d3f

14 files changed

package.json+1−1
@@ -20,13 +20,13 @@
2020 "dependencies": {
2121 "@cel-tui/components": "^0.4.1",
2222 "@cel-tui/core": "^0.4.1",
23+ "@cel-tui/types": "^0.4.1",
2324 "@mariozechner/pi-ai": "^0.65.0",
2425 "diff": "^8.0.4"
2526 },
2627 "devDependencies": {
2728 "@biomejs/biome": "^2.4.6",
2829 "@types/bun": "latest",
29- "@types/diff": "^8.0.0",
3030 "lefthook": "^2.1.4",
3131 "prettier": "^3.8.1",
3232 "typescript": "^5.9.3"
src/agent.ts+2−2
@@ -81,7 +81,7 @@ export type AgentEvent =
8181 | { type: "aborted"; message: AssistantMessage };
8282
8383 /** Options for the agent loop. */
84-export interface RunAgentOpts {
84+interface RunAgentOpts {
8585 /** Open database handle. */
8686 db: Database;
8787 /** Current session ID. */
@@ -111,7 +111,7 @@ export interface RunAgentOpts {
111111 }
112112
113113 /** Result of the agent loop. */
114-export interface AgentLoopResult {
114+interface AgentLoopResult {
115115 /** The updated message history. */
116116 messages: Message[];
117117 /** How the loop ended. */
src/input.ts+3−3
@@ -31,7 +31,7 @@ export const COMMANDS = [
3131 ] as const;
3232
3333 /** A recognized slash command name. */
34-export type Command = (typeof COMMANDS)[number];
34+type Command = (typeof COMMANDS)[number];
3535
3636 const COMMAND_SET: ReadonlySet<string> = new Set(COMMANDS);
3737
@@ -49,14 +49,14 @@ const IMAGE_EXTENSIONS: ReadonlySet<string> = new Set([
4949 // ---------------------------------------------------------------------------
5050
5151 /** Result of parsing user input. */
52-export type ParsedInput =
52+type ParsedInput =
5353 | { type: "command"; command: Command; args: string }
5454 | { type: "skill"; skillName: string; userText: string }
5555 | { type: "image"; path: string }
5656 | { type: "text"; text: string };
5757
5858 /** Options for input parsing. */
59-export interface ParseInputOpts {
59+interface ParseInputOpts {
6060 /** Whether the current model supports image input. */
6161 supportsImages?: boolean;
6262 /** Working directory for resolving relative image paths. */
src/package.test.ts+10−0
@@ -41,6 +41,16 @@ test("package.json bin points to a checked-in mc launcher", async () => {
4141 expect(Bun.file(join(REPO_ROOT, launcher)).size).toBeGreaterThan(0);
4242 });
4343
44+test("package.json declares direct UI types and omits redundant diff typings", async () => {
45+ const pkg = (await Bun.file(join(REPO_ROOT, "package.json")).json()) as {
46+ dependencies?: Record<string, string>;
47+ devDependencies?: Record<string, string>;
48+ };
49+
50+ expect(pkg.dependencies).toHaveProperty("@cel-tui/types");
51+ expect(pkg.devDependencies).not.toHaveProperty("@types/diff");
52+});
53+
4454 test("pack dry-run includes the mc launcher and runtime entrypoint", async () => {
4555 const result = await packDryRun();
4656
src/prompt.ts+1−1
@@ -27,7 +27,7 @@ export interface AgentsMdFile {
2727 }
2828
2929 /** Options for building the system prompt. */
30-export interface BuildSystemPromptOpts {
30+interface BuildSystemPromptOpts {
3131 /** Current working directory. */
3232 cwd: string;
3333 /** Current date string (YYYY-MM-DD). */
src/session.ts+4−4
@@ -60,7 +60,7 @@ export interface SessionStats {
6060 }
6161
6262 /** A raw submitted prompt stored for global input-history search. */
63-export interface PromptHistoryEntry {
63+interface PromptHistoryEntry {
6464 /** Monotonic row id. */
6565 id: number;
6666 /** Exact raw prompt text as submitted by the user. */
@@ -74,7 +74,7 @@ export interface PromptHistoryEntry {
7474 }
7575
7676 /** Options for appending a raw prompt-history entry. */
77-export interface AppendPromptHistoryOpts {
77+interface AppendPromptHistoryOpts {
7878 /** Exact raw prompt text as submitted by the user. */
7979 text: string;
8080 /** Working directory where the prompt was submitted. */
@@ -96,7 +96,7 @@ export interface UiMessage {
9696 }
9797
9898 /** Any message persisted in session history. */
99-export type PersistedMessage = Message | UiMessage;
99+type PersistedMessage = Message | UiMessage;
100100
101101 /** Options for creating a new session. */
102102 interface CreateSessionOpts {
@@ -352,7 +352,7 @@ export function createUiMessage(content: string): UiMessage {
352352 * @param message - Message to inspect.
353353 * @returns `true` when the message is a {@link UiMessage}.
354354 */
355-export function isUiMessage(message: PersistedMessage): message is UiMessage {
355+function isUiMessage(message: PersistedMessage): message is UiMessage {
356356 return message.role === "ui";
357357 }
358358
src/settings.ts+2−2
@@ -12,7 +12,7 @@ import { dirname } from "node:path";
1212 import type { ThinkingLevel } from "@mariozechner/pi-ai";
1313
1414 /** Default reasoning effort when no saved setting exists. */
15-export const DEFAULT_EFFORT: ThinkingLevel = "medium";
15+const DEFAULT_EFFORT: ThinkingLevel = "medium";
1616
1717 /** Default reasoning visibility when no saved setting exists. */
1818 export const DEFAULT_SHOW_REASONING = true;
@@ -33,7 +33,7 @@ export interface UserSettings {
3333 }
3434
3535 /** Resolved startup settings after applying defaults and availability checks. */
36-export interface StartupSettings {
36+interface StartupSettings {
3737 /** Model to use for this launch, or `null` if none are available. */
3838 modelId: string | null;
3939 /** Effective reasoning effort. */
src/tools.ts+4−4
@@ -62,7 +62,7 @@ function normalizeLineEndings(
6262 // ---------------------------------------------------------------------------
6363
6464 /** Arguments for the `edit` tool. */
65-export interface EditArgs {
65+interface EditArgs {
6666 /** File path (absolute or relative to cwd). */
6767 path: string;
6868 /** Exact text to find. Empty string means "create new file". */
@@ -139,13 +139,13 @@ export function executeEdit(args: EditArgs, cwd: string): ToolExecResult {
139139 // ---------------------------------------------------------------------------
140140
141141 /** Arguments for the `shell` tool. */
142-export interface ShellArgs {
142+interface ShellArgs {
143143 /** The command to run. */
144144 command: string;
145145 }
146146
147147 /** Options for shell execution. */
148-export interface ShellOpts {
148+interface ShellOpts {
149149 /** Maximum output lines before truncation. Default: 1000. */
150150 maxLines?: number;
151151 /** Maximum UTF-8 bytes before truncation. Default: 50_000. */
@@ -476,7 +476,7 @@ const IMAGE_MIME_TYPES: Record<string, string> = {
476476 };
477477
478478 /** Arguments for the `readImage` tool. */
479-export interface ReadImageArgs {
479+interface ReadImageArgs {
480480 /** File path (absolute or relative to cwd). */
481481 path: string;
482482 }
src/ui.test.ts+15−0
@@ -23,6 +23,7 @@ import {
2323 } from "./session.ts";
2424 import { DEFAULT_SHOW_REASONING, DEFAULT_VERBOSE } from "./settings.ts";
2525 import { DEFAULT_THEME } from "./theme.ts";
26+import * as uiModule from "./ui.ts";
2627 import {
2728 buildConversationLog,
2829 createInputController,
@@ -146,6 +147,20 @@ async function stopRunningTurn(
146147 }
147148
148149 describe("ui rendering", () => {
150+ test("ui.ts keeps command and render helpers private", () => {
151+ const exports = Object.keys(uiModule);
152+
153+ expect(exports).not.toContain("applyEffortSelection");
154+ expect(exports).not.toContain("applyModelSelection");
155+ expect(exports).not.toContain("buildHelpText");
156+ expect(exports).not.toContain("formatPromptHistoryPreview");
157+ expect(exports).not.toContain("formatRelativeDate");
158+ expect(exports).not.toContain("previewToolRenderLines");
159+ expect(exports).not.toContain("renderAssistantMessage");
160+ expect(exports).not.toContain("renderStatusBar");
161+ expect(exports).not.toContain("renderToolResult");
162+ });
163+
149164 test("reasoning defaults on and verbose defaults off", () => {
150165 expect(DEFAULT_SHOW_REASONING).toBe(true);
151166 expect(DEFAULT_VERBOSE).toBe(false);
src/ui.ts+0−17
@@ -40,24 +40,7 @@ import {
4040 import { type ActiveOverlay, renderOverlay } from "./ui/overlay.ts";
4141 import { renderStatusBar } from "./ui/status.ts";
4242
43-export {
44- applyEffortSelection,
45- applyModelSelection,
46- formatPromptHistoryPreview,
47- formatRelativeDate,
48-} from "./ui/commands.ts";
49-export {
50- type ConversationRenderOpts,
51- type PendingToolCall,
52- previewToolRenderLines,
53- renderAssistantMessage,
54- renderToolResult,
55- type ToolRenderLine,
56- type ToolRenderLineKind,
57-} from "./ui/conversation.ts";
58-export { buildHelpText, type HelpRenderState } from "./ui/help.ts";
5943 export type { InputController } from "./ui/input.ts";
60-export { renderStatusBar } from "./ui/status.ts";
6144
6245 // ---------------------------------------------------------------------------
6346 // Constants
src/ui/agent.ts+2−2
@@ -46,7 +46,7 @@ let isStreaming = false;
4646 let pendingToolCalls: PendingToolCall[] = [];
4747
4848 /** Hooks implemented by `ui.ts` to bridge controller logic with runtime UI state. */
49-export interface UiAgentRuntime {
49+interface UiAgentRuntime {
5050 /** Ensure a persisted session exists for the active conversation. */
5151 ensureSession: (state: AppState) => NonNullable<AppState["session"]>;
5252 /** Append a UI-only informational message to the conversation log. */
@@ -64,7 +64,7 @@ export interface UiAgentRuntime {
6464 }
6565
6666 /** Public controller API for raw input dispatch and streaming state. */
67-export interface UiAgentController {
67+interface UiAgentController {
6868 /** Route raw user input through parseInput and dispatch accordingly. */
6969 handleInput: (raw: string, state: AppState) => void;
7070 }
src/ui/commands.test.ts+8−0
@@ -9,6 +9,7 @@ import { COMMANDS } from "../input.ts";
99 import { appendPromptHistory, openDatabase } from "../session.ts";
1010 import { loadSettings } from "../settings.ts";
1111 import { DEFAULT_THEME } from "../theme.ts";
12+import * as commandsModule from "./commands.ts";
1213 import {
1314 createCommandController,
1415 formatPromptHistoryPreview,
@@ -91,6 +92,13 @@ afterEach(() => {
9192 });
9293
9394 describe("ui/commands", () => {
95+ test("commands.ts keeps selection helpers private", () => {
96+ const exports = Object.keys(commandsModule);
97+
98+ expect(exports).not.toContain("applyEffortSelection");
99+ expect(exports).not.toContain("applyModelSelection");
100+ });
101+
94102 test("showCommandAutocomplete clears the current draft and opens the commands overlay", () => {
95103 const state = createTestState();
96104 const runtimeState = { overlay: null as ActiveOverlay | null };
src/ui/commands.ts+4−10
@@ -43,7 +43,7 @@ function getErrorMessage(error: unknown): string {
4343 }
4444
4545 /** Runtime hooks injected from the stateful UI module. */
46-export interface UiCommandRuntime {
46+interface UiCommandRuntime {
4747 /** Open an overlay and trigger a re-render. */
4848 openOverlay: (overlay: ActiveOverlay) => void;
4949 /** Dismiss the active overlay and trigger a re-render. */
@@ -63,7 +63,7 @@ export interface UiCommandRuntime {
6363 }
6464
6565 /** Public command actions consumed by `ui.ts` and unit tests. */
66-export interface UiCommandController {
66+interface UiCommandController {
6767 /** Apply a model selection and persist it to settings. */
6868 applyModelSelection: (
6969 state: AppState,
@@ -85,10 +85,7 @@ export interface UiCommandController {
8585 * @param state - Application state.
8686 * @param model - Selected model.
8787 */
88-export function applyModelSelection(
89- state: AppState,
90- model: Model<string>,
91-): void {
88+function applyModelSelection(state: AppState, model: Model<string>): void {
9289 state.model = model;
9390 state.settings = updateSettings(state.settingsPath, {
9491 defaultModel: `${model.provider}/${model.id}`,
@@ -101,10 +98,7 @@ export function applyModelSelection(
10198 * @param state - Application state.
10299 * @param effort - Selected reasoning effort.
103100 */
104-export function applyEffortSelection(
105- state: AppState,
106- effort: ThinkingLevel,
107-): void {
101+function applyEffortSelection(state: AppState, effort: ThinkingLevel): void {
108102 state.effort = effort;
109103 state.settings = updateSettings(state.settingsPath, {
110104 defaultEffort: effort,
src/ui/conversation.ts+2−2
@@ -42,7 +42,7 @@ export interface PendingToolCall {
4242 }
4343
4444 /** Render options shared by completed and in-progress assistant content. */
45-export interface ConversationRenderOpts {
45+interface ConversationRenderOpts {
4646 /** Whether reasoning blocks are visible. */
4747 showReasoning: boolean;
4848 /** Whether tool output should be truncated in the UI. */
@@ -72,7 +72,7 @@ interface AssistantRenderState {
7272 }
7373
7474 /** Semantic line kinds used when rendering tool output in the log. */
75-export type ToolRenderLineKind =
75+type ToolRenderLineKind =
7676 | "command"
7777 | "path"
7878 | "toolName"