Turnback

io.github.MFaizR77v0.1.0更新于 Sep 29, 2026

Undo a coding agent turn, including shell commands and untracked files.

已验证STDIO仅桌面Developer ToolsAI & ML

安装

在 SourceWeft 中

  1. 打开 控制台中的 Turnback,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Turnback

Turnback records file state before and during a coding agent's turn, then restores it through the CLI or MCP. The shadow Git repo lives in ~/.turnback (or TURNBACK_HOME), separate from the project's .git.

Supports Claude Code, Codex, Gemini CLI, Cursor, OpenCode, and Antigravity CLI. Requires Node.js 22+ and Git 2.25+. Claude Code, Codex, OpenCode, and Antigravity CLI have been tested live; Gemini CLI and Cursor are covered by tests built from their documented hook payloads.

bash
npm install -g turnbackturnback install all --projectturnback listturnback diff <turn-id>turnback undo --dry-runturnback undo --yes

install all without --project installs the user-level config. uninstall all [--project] removes only Turnback entries. --no-mcp installs hooks without MCP. Other config is kept.

Available commands: install, uninstall, list, diff, status, restore, undo, redo, gc, and mcp. restore <turn> --path <file> --dry-run shows the plan. --yes applies it. redo --yes returns to the safety snapshot taken before the last restore. Restoring changes project files; the agent's conversation context is not restored.

Documentation: installation, restore, MCP, and scope.

How it works

The hook before a mutating tool takes the turn baseline. The hook before a shell command captures the whole tree; later edits capture the affected paths. The end of the turn captures the result. The initial snapshot is warmed in the background on install and session start. Hooks always let the agent continue when recording fails; a failed, skipped, or unprotected state is visible through status.

Tracked, untracked, and gitignored files up to 5 MB are covered. Build output and dependency directories are excluded. Extra rules use gitignore syntax in .turnbackignore; global rules go in ~/.turnback/config.json as {"exclude":["pattern"]}.

Workspaces above 100k files or 2 GB switch to edits-only mode: only paths touched by edit tools are snapshotted, shell commands are recorded as unprotected, and restore touches only recorded paths. Turns older than 7 days and outside the last 50 turns are cleaned up automatically, at most once a day.

Development

ModuleContents
src/cli.tsCLI and hook entry point
src/adapters.tsEach agent's hook payload → HookEvent
src/recorder.tsSnapshot rules per event
src/store.tsJournal, snapshots, turn history, status, gc
src/restore.tsRestore planning and execution, undo, redo
src/shadow.tsShadow git repo wrapper
src/workspace.tsWorkspace scanning and exclusion rules
src/journal.ts, src/lock.ts, src/config.tsJSONL journal, per-workspace lock, constants
src/install.tsHook and MCP installation per agent
src/mcp.tsStdio MCP server
bash
npm run checknpm run bench

The benchmark creates a temporary 10k-file repo and reports latency without making it a strict CI gate. CI runs the tests and benchmark on Windows, macOS, and Linux × Node 22/24.

From a clone, run npm ci && npm run build and use node dist/cli.js in place of turnback.

Releasing

Set the same version in package.json and in both version fields of server.json, commit, then push a v<version> tag. The Publish workflow checks that the versions match, runs the tests, publishes to npm through trusted publishing (provenance is attached automatically), and publishes server.json to the MCP registry as io.github.MFaizR77/turnback.

npm trusted publishing is configured on the package page at npmjs.com (repository MFaizR77/turnback, workflow publish.yml), which needs the package to exist. The first version is therefore published once by hand with npm publish --access public; pushing its tag afterwards skips npm (the version exists) and only publishes to the MCP registry. Later tags do both.

License

MIT

来源:README.md,提交 cf62fb9

工具

0
工具元数据尚未被收录。

版本历史

1
  1. v0.1.0最新Sep 29, 2026