feat(initial): scaffold @push.rocks/smartchat with core, CLI, and web layers

Three-layer architecture built on @push.rocks/smartagent:
- ts/ — ChatSession wrapping runAgent() with conversation state management
- ts_cli/ — ink-based terminal chat TUI (React.createElement, no JSX)
- ts_web/ — Lit web components (smartchat-window, smartchat-message, smartchat-input)
This commit is contained in:
2026-03-06 23:20:12 +00:00
commit dd04edb420
24 changed files with 11344 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
import { React, h, Box, Text } from './plugins.js';
export interface IChatMessage {
role: 'user' | 'assistant' | 'tool';
content: string;
toolName?: string;
toolInput?: string;
}
interface IMessageProps {
message: IChatMessage;
}
function truncate(text: string, maxLen: number): string {
if (text.length <= maxLen) return text;
return text.substring(0, maxLen) + '...';
}
export function Message({ message }: IMessageProps): React.ReactElement | null {
switch (message.role) {
case 'user':
return h(Box, { marginY: 0 },
h(Text, { bold: true, color: 'blue' }, 'You: '),
h(Text, null, message.content),
);
case 'assistant':
return h(Box, { marginY: 0 },
h(Text, { bold: true, color: 'green' }, 'Assistant: '),
h(Text, null, message.content),
);
case 'tool':
return h(Box, { marginY: 0, marginLeft: 2, flexDirection: 'column' as const },
h(Text, { dimColor: true },
`tool: ${message.toolName}${message.toolInput ? ` (${message.toolInput})` : ''}`,
),
message.content
? h(Box, { marginLeft: 2 },
h(Text, { dimColor: true }, truncate(message.content, 200)),
)
: null,
);
default:
return null;
}
}