4316dbd3be
- Extract shared splitMessage() into channels/utils.ts (dedup 4 adapters) - Add Slack user name resolution with caching (users.info API) - Add withRetry() with exponential backoff + jitter, isRetryable() filter - Wire retry config into ModelRouter.chat() (non-streaming only) - Add assembleSystemPrompt() multi-file template system (SOUL/AGENTS/IDENTITY/USER/TOOLS.md) - Add usage tracking accumulators in NativeAgent + AgentOrchestrator - Add estimateCost() with per-model pricing table - Add /usage TUI command with full usage report formatting - Add retrySchema and promptSchema to config schema Tests: 569 passing, typecheck clean
80 lines
2.6 KiB
TypeScript
80 lines
2.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { parseCommand, getHelpText } from './commands.js';
|
|
|
|
describe('parseCommand', () => {
|
|
it('parses /quit command', () => {
|
|
expect(parseCommand('/quit')).toEqual({ type: 'quit' });
|
|
expect(parseCommand('/exit')).toEqual({ type: 'quit' });
|
|
});
|
|
|
|
it('parses /reset command', () => {
|
|
expect(parseCommand('/reset')).toEqual({ type: 'reset' });
|
|
expect(parseCommand('/clear')).toEqual({ type: 'reset' });
|
|
});
|
|
|
|
it('parses /help command', () => {
|
|
expect(parseCommand('/help')).toEqual({ type: 'help' });
|
|
expect(parseCommand('/?')).toEqual({ type: 'help' });
|
|
});
|
|
|
|
it('parses /status command', () => {
|
|
expect(parseCommand('/status')).toEqual({ type: 'status' });
|
|
});
|
|
|
|
it('parses /fullscreen command', () => {
|
|
expect(parseCommand('/fullscreen')).toEqual({ type: 'fullscreen' });
|
|
expect(parseCommand('/fs')).toEqual({ type: 'fullscreen' });
|
|
});
|
|
|
|
it('parses /compact command', () => {
|
|
expect(parseCommand('/compact')).toEqual({ type: 'compact' });
|
|
});
|
|
|
|
it('parses /usage command', () => {
|
|
expect(parseCommand('/usage')).toEqual({ type: 'usage' });
|
|
});
|
|
|
|
it('parses /model command without argument', () => {
|
|
expect(parseCommand('/model')).toEqual({ type: 'model' });
|
|
});
|
|
|
|
it('parses /model command with argument', () => {
|
|
expect(parseCommand('/model local')).toEqual({ type: 'model', name: 'local' });
|
|
expect(parseCommand('/model opus')).toEqual({ type: 'model', name: 'opus' });
|
|
});
|
|
|
|
it('parses /backend command without argument', () => {
|
|
expect(parseCommand('/backend')).toEqual({ type: 'backend' });
|
|
});
|
|
|
|
it('parses /backend command with argument', () => {
|
|
expect(parseCommand('/backend llamacpp')).toEqual({ type: 'backend', provider: 'llamacpp' });
|
|
expect(parseCommand('/backend ollama')).toEqual({ type: 'backend', provider: 'ollama' });
|
|
});
|
|
|
|
it('parses /transfer command', () => {
|
|
expect(parseCommand('/transfer telegram')).toEqual({ type: 'transfer', target: 'telegram' });
|
|
});
|
|
|
|
it('parses regular message', () => {
|
|
expect(parseCommand('Hello Flynn')).toEqual({ type: 'message', content: 'Hello Flynn' });
|
|
});
|
|
|
|
it('returns null for empty input', () => {
|
|
expect(parseCommand('')).toBeNull();
|
|
expect(parseCommand(' ')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('getHelpText', () => {
|
|
it('returns help text with all commands', () => {
|
|
const help = getHelpText();
|
|
expect(help).toContain('/help');
|
|
expect(help).toContain('/model');
|
|
expect(help).toContain('/reset');
|
|
expect(help).toContain('/compact');
|
|
expect(help).toContain('/usage');
|
|
expect(help).toContain('/quit');
|
|
});
|
|
});
|