feat(commands,audit): add /context command and proactive compaction audit events
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
import { createElevateCommand, createModelCommand, createQueueCommand } from './index.js';
|
||||
import { createContextCommand, createElevateCommand, createModelCommand, createQueueCommand } from './index.js';
|
||||
|
||||
describe('builtin /model command', () => {
|
||||
it('passes through the full argument string', async () => {
|
||||
@@ -111,3 +111,31 @@ describe('builtin /queue command', () => {
|
||||
expect(result).toEqual({ handled: true, text: 'reset' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('builtin /context command', () => {
|
||||
it('returns context usage text from services', async () => {
|
||||
const cmd = createContextCommand();
|
||||
const getContext = vi.fn(() => 'Context Usage\n\n75.0%');
|
||||
const result = await cmd.execute([], {
|
||||
channel: 'test',
|
||||
senderId: 'user',
|
||||
sessionId: 's1',
|
||||
rawInput: '/context',
|
||||
services: { getContext },
|
||||
});
|
||||
expect(getContext).toHaveBeenCalledOnce();
|
||||
expect(result).toEqual({ handled: true, text: 'Context Usage\n\n75.0%' });
|
||||
});
|
||||
|
||||
it('returns not-available when service is missing', async () => {
|
||||
const cmd = createContextCommand();
|
||||
const result = await cmd.execute([], {
|
||||
channel: 'test',
|
||||
senderId: 'user',
|
||||
sessionId: 's1',
|
||||
rawInput: '/context',
|
||||
services: {},
|
||||
});
|
||||
expect(result).toEqual({ handled: true, text: 'Context command is not available in this session.' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user