fix(coding-agent): export Theme and ThemeColor for hooks to use proper types

This commit is contained in:
Mario Zechner 2026-01-03 00:12:05 +01:00
parent 65d3081d80
commit 8c227052d3
2 changed files with 6 additions and 7 deletions

View file

@ -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<void>((_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());
});
},
});

View file

@ -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";