From 8c227052d38bcbb748745e233dd6978738c77b67 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sat, 3 Jan 2026 00:12:05 +0100 Subject: [PATCH] fix(coding-agent): export Theme and ThemeColor for hooks to use proper types --- packages/coding-agent/examples/hooks/todo/index.ts | 9 ++++----- packages/coding-agent/src/index.ts | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/coding-agent/examples/hooks/todo/index.ts b/packages/coding-agent/examples/hooks/todo/index.ts index ecd9bfff..607eb6d0 100644 --- a/packages/coding-agent/examples/hooks/todo/index.ts +++ b/packages/coding-agent/examples/hooks/todo/index.ts @@ -5,7 +5,7 @@ * with a nice custom UI. */ -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI, Theme } from "@mariozechner/pi-coding-agent"; import { isCtrlC, isEscape, truncateToWidth } from "@mariozechner/pi-tui"; interface Todo { @@ -23,12 +23,12 @@ interface TodoDetails { class TodoListComponent { private todos: Todo[]; - private theme: { fg: (color: string, text: string) => string }; + private theme: Theme; private onClose: () => void; private cachedWidth?: number; private cachedLines?: string[]; - constructor(todos: Todo[], theme: { fg: (color: string, text: string) => string }, onClose: () => void) { + constructor(todos: Todo[], theme: Theme, onClose: () => void) { this.todos = todos; this.theme = theme; this.onClose = onClose; @@ -127,8 +127,7 @@ export default function (pi: HookAPI) { const todos = getTodos(ctx); await ctx.ui.custom((_tui, theme, done) => { - // Cast: Theme.fg uses ThemeColor union type, but we only use standard colors - return new TodoListComponent(todos, theme as { fg: (color: string, text: string) => string }, () => done()); + return new TodoListComponent(todos, theme, () => done()); }); }, }); diff --git a/packages/coding-agent/src/index.ts b/packages/coding-agent/src/index.ts index ba2e1a52..80e84c6f 100644 --- a/packages/coding-agent/src/index.ts +++ b/packages/coding-agent/src/index.ts @@ -157,5 +157,5 @@ export { export { main } from "./main.js"; // UI components for hooks export { BorderedLoader } from "./modes/interactive/components/bordered-loader.js"; -// Theme utilities for custom tools -export { getMarkdownTheme } from "./modes/interactive/theme/theme.js"; +// Theme utilities for custom tools and hooks +export { getMarkdownTheme, Theme, type ThemeColor } from "./modes/interactive/theme/theme.js";