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:
@@ -0,0 +1,45 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartchat from '../ts/index.js';
|
||||
|
||||
tap.test('should export ChatSession class', async () => {
|
||||
expect(smartchat.ChatSession).toBeTypeOf('function');
|
||||
});
|
||||
|
||||
tap.test('ChatSession should initialize with options', async () => {
|
||||
// Use a mock model (just needs to be an object)
|
||||
const mockModel = {} as any;
|
||||
const session = new smartchat.ChatSession({ model: mockModel });
|
||||
expect(session).toBeInstanceOf(smartchat.ChatSession);
|
||||
});
|
||||
|
||||
tap.test('ChatSession should track usage', async () => {
|
||||
const mockModel = {} as any;
|
||||
const session = new smartchat.ChatSession({ model: mockModel });
|
||||
const usage = session.getUsage();
|
||||
expect(usage.turns).toEqual(0);
|
||||
expect(usage.totalTokens).toEqual(0);
|
||||
});
|
||||
|
||||
tap.test('ChatSession should manage messages', async () => {
|
||||
const mockModel = {} as any;
|
||||
const session = new smartchat.ChatSession({ model: mockModel });
|
||||
|
||||
expect(session.getMessages()).toHaveLength(0);
|
||||
|
||||
// Set messages
|
||||
const fakeMessages = [{ role: 'user' as const, content: 'hello' }] as any[];
|
||||
session.setMessages(fakeMessages);
|
||||
expect(session.getMessages()).toHaveLength(1);
|
||||
|
||||
// Clear
|
||||
session.clear();
|
||||
expect(session.getMessages()).toHaveLength(0);
|
||||
});
|
||||
|
||||
tap.test('ChatSession should report busy state', async () => {
|
||||
const mockModel = {} as any;
|
||||
const session = new smartchat.ChatSession({ model: mockModel });
|
||||
expect(session.isBusy()).toBeFalse();
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user