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
+5 -1
View File
@@ -145,10 +145,14 @@ Type `/` and a menu appears, narrowing as you type.
```
/help /agent [name] /think [level] /provider /models /model <id>
/skills /plugins /registry [search|add|remove] /init /context
/todos /notes /memory /tools /compact /cost
/todos /notes /memory /tools /compact /undo /cost /max-spend [usd]
/sessions /resume <id> /save /clear /exit
```
Your own slash commands live in `.shiro/commands.md` — see
[docs/user-commands.md](docs/user-commands.md). `/undo` restores the files a
completed turn changed and rewinds — see [docs/undo.md](docs/undo.md).
`esc` dismisses a panel, interrupts a running turn, and clears the queue. `ctrl-c` kills the
running command but keeps the turn. `ctrl-r` expands the reasoning panel. `@` completes a
workspace path. Up and down recall earlier prompts.