feat: add undo functionality to revert the last turn and restore file changes

- 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.
This commit is contained in:
asepharyana
2026-09-04 22:37:38 +07:00
parent e90bcac7c3
commit 4dac34b13f
17 changed files with 777 additions and 24 deletions
+4
View File
@@ -33,6 +33,10 @@ export function testHooks(over: Partial<AppHooks> = {}): AppHooks {
initPrompt: 'write AGENTS.md',
history: [],
recordPrompt: () => {},
listUserCommands: () => [],
expandUserCommand: async (name) => {
throw new Error(`no custom command "${name}" in tests`);
},
...over,
};
}