Turnback

io.github.MFaizR77由 GitHub 帳號 MFaizR77 發布v0.9.1更新於 Oct 24, 2026

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

已驗證STDIO僅桌面檔案與儲存開發者工具

概覽

AI 產生的概覽

Turnback 在每個智慧體回合與 shell 指令前為工作區建立快照,讓助理能列出、比對並還原自己的回合。

可以做什麼
  • 列出最近的回合與其提示詞,檢視回合中的每個編輯與 shell 指令
  • 比對某個回合的變更,並在多個回合之間比較或搜尋
  • 還原整個回合,或回到某個步驟之前,先產生計畫再執行變更
  • 找回被刪除的單一檔案或資料夾,並查看每一行由哪個回合與提示詞寫入
  • 把任意指令記錄成可復原的回合,並匯出歷史,包括為拉取請求標註提示詞來源
適用情境
當 AI 編碼智慧體執行 rm -rf、mv、程式碼產生器或 git checkout 等破壞性或生成性 shell 指令時適用,因為內建檢查點只追蹤編輯工具。也適合在多個智慧體之間共用一份復原歷史,或把程式碼行與分支變更追溯到產生它們的提示詞。
執行需求
以 npm 套件 turnback 透過 stdio 在本機執行,需要 Node.js 22+ 與 Git 2.25+。透過命令列或外掛市集為各智慧體安裝鉤子與 MCP;未宣告任何 API 金鑰或環境變數。
安裝前請注意
快照存放在家目錄下的影子 git 儲存庫,涵蓋受追蹤、未追蹤與被 gitignore 的檔案(最大 5 MB),因此 .env 等機密檔案可能被複製進去。還原、復原與重做會改動工作區檔案,export --commit 會寫入專案的 .git。舊回合會被自動清理,超大工作區會退化為僅編輯模式,此時 shell 指令處於未保護狀態。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Turnback,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[Turnback]

Undo for AI coding agents, even after rm -rf.

One undo history for Claude Code, Codex, Cursor, Gemini CLI, OpenCode, and Antigravity CLI.

[npm] [CI] [License: MIT]

[An agent runs rm -rf src .env; turnback undo brings both back]

A real Turnback run. The agent is simulated with Claude Code's hook payloads; the rm -rf and every Turnback line are real. Recreate it with python scripts/demo/make_demo.py.

Why

Agent checkpoints track the agent's own edit tools. Claude Code's documentation says it plainly: "Checkpointing does not track files modified by Bash commands." So when an agent runs rm -rf, mv, a code generator, or git checkout -- ., rewind cannot bring those files back.

Turnback snapshots the workspace before every shell command and edit, into a shadow git repo under ~/.turnback:

  • Undo a whole turn, or go back to just before one step of it.
  • Tracked, untracked, and gitignored files (like .env) up to 5 MB are covered.
  • Nothing writes to your project's .git unless you run turnback export --commit, and hooks never block the agent.
  • One history across six agents. Through MCP, the agent can list and diff its own turns and restore them in two steps: a plan first, then the change.

Install

In Claude Code:

bash
claude plugin marketplace add MFaizR77/turnbackclaude plugin install turnback@turnback

Then use /turnback:turns, /turnback:diff-turn, /turnback:undo, and /turnback:report.

In Codex (available in the next npm release):

bash
codex plugin marketplace add MFaizR77/turnbackcodex plugin add turnback@turnback

Start a new session, review and trust Turnback's hooks in /hooks, then use $turnback:turns, $turnback:diff-turn, $turnback:undo, and $turnback:report.

The plugin needs Turnback 0.9.1 or later. To try unreleased plugin changes from a checkout, see local testing.

For Codex, Cursor, Gemini CLI, OpenCode, Antigravity CLI, or the CLI on its own (Node.js 22+ and Git 2.25+):

bash
npm install -g turnbackturnback install all            # user-level hooks and MCP for every agentturnback install codex --project  # or one agent, in this project only

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. Details per agent: installation.

Compared with Claude Code's /rewind

/rewindTurnback
Edits made by the agent's edit tools✅✅
Files changed by shell commands (rm, mv, codegen)❌✅
Untracked and gitignored filesonly files its edit tools changed✅ up to 5 MB
Other agents❌Codex, Cursor, Gemini CLI, OpenCode, Antigravity CLI
Go back to a point inside a turn❌✅ --before-step
Rewind the conversation✅❌ files only

They work side by side: rewind the conversation with /rewind, and the files with Turnback.

Everyday use

bash
turnback --help                     # commands, options, and quick-start examplesturnback list                       # recent turns with their promptsturnback diff <turn>                # what a turn changedturnback undo --dry-run             # show the planturnback undo --yes                 # undo the latest turnturnback redo --yes                 # changed your mindturnback steps <turn>               # each edit and shell command in a turnturnback restore <turn> --before-step 3 --yesturnback mark "before migration"    # a checkpoint of your ownturnback run -- npm run codegen     # any command as an undoable turn, no agent neededturnback recover src/app.ts         # bring back one file (or a folder) an agent deleted turns agoturnback blame src/auth.ts          # which turn and prompt wrote each lineturnback report --pr --apply        # add which prompts wrote this branch to its pull requestturnback du                         # Turnback's disk use for every workspaceturnback ui                         # timeline in the browser

Without an agent

turnback run records any command as a turn, so a code generator, a codemod, or an agent without hooks gets the same undo. blame shows which turn wrote each line, and recover brings back a single file:

[turnback run records a code generator; blame shows its lines; recover brings back the file it deleted]

All commands, including log, search, report, compare, and export: commands. More: restore, MCP, scope and limits.

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, in every workspace and not only the one in use. Data of a workspace that was deleted is removed after 30 idle days; set {"autoClean": false} in ~/.turnback/config.json to keep it.

Contributing

Issues labeled good first issue are small and say which files they touch, and support for more agents is welcome. Start with CONTRIBUTING.md and the architecture overview. Questions and ideas go to Discussions.

Contributors

[Contributors]

Every merged pull request is credited in the release notes.

Development

ModuleContents
src/cli/main.ts: CLI and hook entry point (built as dist/cli.js); args.ts: argument parsing
src/core/recorder.ts: snapshot rules per event; store.ts: journal, snapshots, turns, steps, marks, status, gc; restore.ts: restore planning and execution, undo, redo; format.ts: text output; quote.ts: shell-safe arguments; journal.ts, lock.ts, config.ts, types.ts
src/git/shadow.ts: shadow git repo wrapper
src/workspace/workspace.ts: workspace scanning and exclusion rules
src/agents/adapters.ts: each agent's hook payload → HookEvent; install.ts: hook and MCP installation per agent; opencode-plugin.ts: generated OpenCode plugin
src/mcp/server.ts: stdio MCP server
src/ui/server.ts: read-only local server for turnback ui; page.ts: its single page
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.

Also update src/core/config.ts, both plugin manifests, and the npm ranges in .claude-plugin/marketplace.json and .agents/plugins/marketplace.json.

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,提交 2b468da

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

6
  1. v0.9.1最新Oct 14, 2026
  2. v0.9.0Oct 1, 2026
  3. v0.8.0Sep 30, 2026
  4. v0.5.0Sep 30, 2026
  5. v0.4.0Sep 30, 2026
  6. v0.1.0Sep 29, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分