- Implemented `/undo` command to revert the most recent completed turn, restoring all modified files and rewinding message history. - Introduced `FileMutation` type to capture file changes for undo operations. - Enhanced session management to track and manage undo stack with a maximum of 20 turns. - Updated command parsing to include user-defined commands from `.shiro/commands.md`, allowing for custom command definitions and substitutions. - Added documentation for the new `/undo` command and user commands feature. - Implemented tests for undo functionality and user command parsing to ensure reliability.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import type { AppHooks } from '../src/ui/App';
|
|
|
|
/** Default AppHooks for UI tests; override only what a test cares about. */
|
|
export function testHooks(over: Partial<AppHooks> = {}): AppHooks {
|
|
return {
|
|
sessionId: 'test1234',
|
|
config: () => ({ provider: 'openai', model: 'gpt-5' }),
|
|
switchModel: (id) => `model is now ${id}`,
|
|
switchAgent: (name) => `agent is now ${name}`,
|
|
switchThinking: (level) => `thinking is now ${level}`,
|
|
agentName: () => 'default',
|
|
thinkingLevel: () => 'medium',
|
|
applyProvider: async () => 'configured',
|
|
listModels: async () => ({ models: [] }),
|
|
listSessions: async () => 'no saved sessions',
|
|
listSkills: () => 'no skills loaded',
|
|
listPlugins: () => 'no plugins active',
|
|
listMemory: async () => 'nothing remembered yet',
|
|
summarizeMemory: async () => 'nothing to compact',
|
|
resumeSession: async () => 'resumed',
|
|
saveSession: async () => 'saved',
|
|
instructionFiles: () => [],
|
|
listPaths: async () => [],
|
|
registry: {
|
|
list: async () => [],
|
|
installed: async () => [],
|
|
stage: async () => {
|
|
throw new Error('no registry in tests unless a test provides one');
|
|
},
|
|
install: async () => 'installed',
|
|
remove: async () => 'removed',
|
|
},
|
|
initPrompt: 'write AGENTS.md',
|
|
history: [],
|
|
recordPrompt: () => {},
|
|
listUserCommands: () => [],
|
|
expandUserCommand: async (name) => {
|
|
throw new Error(`no custom command "${name}" in tests`);
|
|
},
|
|
...over,
|
|
};
|
|
}
|