[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-114636":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":12,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":12,"stars7d":14,"stars30d":15,"stars90d":12,"forks30d":12,"starsTrendScore":12,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":9,"pushedAt":30,"updatedAt":31,"readmeContent":32,"aiSummary":33,"trendingCount":12,"starSnapshotCount":12,"syncStatus":34,"lastSyncTime":35,"discoverSource":36},114636,"turnpack","OnlyTerp\u002Fturnpack","OnlyTerp","Fewer back-and-forth AI turns. Local MCP context pack + test-gated multi-file ship with automatic rollback.",null,"TypeScript",67,0,55,3,9,42.4,"Apache License 2.0",false,"main",true,[22,23,24,25,26,27,28,29],"ai-agents","claude-code","codex","cursor","developer-tools","mcp","mcp-server","typescript","2026-11-15 01:19:45","2026-11-19 11:02:09","\u003Cdiv align=\"center\">\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Fhero-dark.svg\" \u002F>\n  \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"assets\u002Fhero-light.svg\" \u002F>\n  \u003Cimg alt=\"Turnpack: edits that are tested before they stay. Measured on one task in Claude Code: 6 round trips down to 3, 23.4 seconds down to 12.7, $0.131 down to $0.084.\" src=\"assets\u002Fhero-dark.svg\" width=\"100%\" \u002F>\n\u003C\u002Fpicture>\n\n\u003Cbr \u002F>\u003Cbr \u002F>\n\n[![CI](https:\u002F\u002Fgithub.com\u002FOnlyTerp\u002Fturnpack\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002FOnlyTerp\u002Fturnpack\u002Factions\u002Fworkflows\u002Fci.yml)\n[![Measured: 6 to 3 round trips](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fmeasured-6%20%E2%86%92%203%20round%20trips-10B981?style=flat-square)](#how-much-does-it-save)\n![Zero dependencies](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdependencies-0-10B981?style=flat-square)\n![No API keys](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAPI%20keys-none-38BDF8?style=flat-square)\n![Node 22+](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fnode-%3E%3D22-0F172A?style=flat-square)\n![License Apache 2.0](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache--2.0-64748B?style=flat-square)\n\n**[Try the demo](#try-it-in-10-seconds)** · **[See an example](#what-it-looks-like)** · **[Set it up](#set-it-up)** · **[The three tools](#the-three-tools)** · **[What it saves](#how-much-does-it-save)** · **[Safety](#safety)** · **[FAQ](#faq)**\n\n\u003C\u002Fdiv>\n\n---\n\n\u003C!--\nLAUNCH FILM (not added yet, so nothing renders here).\nTo add it: open this file in the editor on github.com, click the empty line under this comment, and drag\nturnpack-readme-720p.mp4 onto it. GitHub uploads the file and writes its URL on that line, and that URL\nrenders as an inline video player. Then remove the comment markers around the caption below.\n-->\n\n\u003C!--\n\u003Cp align=\"center\">\u003Csub>The same rename, done one tool call per turn in nine turns and with Turnpack in three. The nine-turn loop is an illustration: today's apps batch some of those calls, and in \u003Ca href=\"#how-much-does-it-save\">a measured run\u003C\u002Fa> Claude Code needed six round trips without Turnpack and three with it. The film closes on those measured numbers. The Turnpack calls and replies are the real ones from \u003Ca href=\"#what-it-looks-like\">the example below\u003C\u002Fa>.\u003C\u002Fsub>\u003C\u002Fp>\n-->\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Fmeasured-dark.svg\" \u002F>\n  \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"assets\u002Fmeasured-light.svg\" \u002F>\n  \u003Cimg alt=\"Measured on one rename task in Claude Code 2.1.280 with Claude Sonnet 5, median of three runs each: model round trips 6 with built-in tools and 3 with Turnpack, time 23.4 seconds and 12.7, output tokens 2,044 and 873, cost $0.131 and $0.084.\" src=\"assets\u002Fmeasured-dark.svg\" width=\"100%\" \u002F>\n\u003C\u002Fpicture>\n\n\u003Cp align=\"center\">\u003Csub>Drawn from the recorded runs in \u003Ca href=\"bench\u002Fresults\u002F2026-11-13-claude-code.json\">\u003Ccode>bench\u002Fresults\u003C\u002Fcode>\u003C\u002Fa>. One small task, three runs per arm: \u003Ca href=\"#how-much-does-it-save\">what that does and does not show\u003C\u002Fa>.\u003C\u002Fsub>\u003C\u002Fp>\n\nAI coding agents work in round trips: the model asks for something, waits, reads the result, and asks again. Each trip is a full model turn, a wait for the first token and then the tokens themselves. Today's apps already run independent reads side by side, so the trips that are left are the ones that depend on each other. A search has to come back before the agent knows which files to open. An edit has to land before the tests can run. And when the tests fail at the end, your repo is left half-edited while the agent spends more turns backing out.\n\nTurnpack is a small local [MCP](https:\u002F\u002Fmodelcontextprotocol.io) server that gives the agent three tools to fold those trips together:\n\n| Tool | One call does | So that |\n| :--- | :--- | :--- |\n| **`pack`** | A regex search with the code around each hit, several files (whole, by line range, or just one function), glob listings and git status | The agent gets its context in one turn. Replies are size-capped, and `.env` and key files are redacted. |\n| **`ship`** | Edits across any number of files, then your test command | Either everything passes and stays, or every file is restored byte-for-byte and the agent gets the failing output. None of the four apps we checked does this on its own. |\n| **`batch`** | A short read-only script over the repo | \"Which of these 40 files export X?\" costs one turn and a ten-line answer instead of 40 reads. |\n\nIt runs entirely on your machine: no API keys, no account, no telemetry, no network calls, and zero runtime dependencies. It works with Claude Code and Claude Desktop, Codex CLI and the ChatGPT desktop app, OMP, Grok Build, Cursor, Gemini CLI, OpenCode and anything else that speaks MCP over stdio.\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Fhow-it-works-dark.svg\" \u002F>\n  \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"assets\u002Fhow-it-works-light.svg\" \u002F>\n  \u003Cimg alt=\"The rename task as it actually ran. With built-in tools, six round trips: search, read five files, edit five files, read package.json, run the tests, report. With Turnpack, three: one pack call, one ship call that makes nine edits in five files and runs the tests, report.\" src=\"assets\u002Fhow-it-works-dark.svg\" width=\"100%\" \u002F>\n\u003C\u002Fpicture>\n\n\u003Cp align=\"center\">\u003Csub>Both columns are the tool calls of those same recorded runs, not an illustration.\u003C\u002Fsub>\u003C\u002Fp>\n\n## Try it in 10 seconds\n\n```bash\nnpx turnpack demo\n```\n\nThis builds a throwaway repo in your temp folder, runs all three tools against it, and deletes it. Nothing in your own projects or AI app config is touched.\n\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"assets\u002Fdemo.gif\" alt=\"Output of npx turnpack demo and npx turnpack doctor\" width=\"88%\" \u002F>\n\u003C\u002Fdiv>\n\nThe recording is generated from the real output of those two commands ([`scripts\u002Frender-assets.py`](scripts\u002Frender-assets.py)), so it cannot drift from what the tool does. `doctor` is run on a temporary home directory in which `init` has just set up five apps, which is why it lists them.\n\nWant to run it straight from this repository instead of npm? `npx github:OnlyTerp\u002Fturnpack demo`\n\n## What it looks like\n\nA rename that misses a call site is the classic way an agent breaks a build. Here is that mistake going through `ship`. The agent renames a function but forgets the file that imports it:\n\n```json\n{\n  \"edits\": [\n    {\n      \"path\": \"src\u002Ftax.js\",\n      \"search\": \"export function calculateTax(amount)\",\n      \"replace\": \"export function computeTax(amount)\"\n    }\n  ],\n  \"verify\": \"npm test\"\n}\n```\n\n```text\nFAILED_AND_ROLLED_BACK: verify \"npm test\" failed (exit code 1).\n\nRestored 1 file(s) to byte-exact pre-edit snapshots. The workspace is unchanged; fix the edit and ship again.\n\nChanged by this call and tested together: src\u002Ftax.js (line 3).\n\nThe failing output does not mention any file this call changed. It names src\u002Finvoice.js:1, a file this call did not change: often a caller or a test the change has not reached yet.\n\n$ npm test\n> test\n> node test\u002Finvoice.test.js\n\nfile:\u002F\u002F\u002Fhome\u002Fyou\u002Fshop\u002Fsrc\u002Finvoice.js:1\nimport { calculateTax } from \".\u002Ftax.js\";\n         ^^^^^^^^^^^^\nSyntaxError: The requested module '.\u002Ftax.js' does not provide an export named 'calculateTax'\n```\n\nThe repo is exactly as it was, and the reply names the file the edit missed. It ships again with both files:\n\n```json\n{\n  \"edits\": [\n    {\n      \"path\": \"src\u002Ftax.js\",\n      \"search\": \"export function calculateTax(amount)\",\n      \"replace\": \"export function computeTax(amount)\"\n    },\n    {\n      \"path\": \"src\u002Finvoice.js\",\n      \"search\": \"calculateTax\",\n      \"replace\": \"computeTax\",\n      \"replace_all\": true\n    }\n  ],\n  \"verify\": \"npm test\"\n}\n```\n\n```text\nSHIPPED_AND_VERIFIED in 283ms: 2 file(s) changed: src\u002Ftax.js (line 3), src\u002Finvoice.js (lines 1, 4).\n\n$ npm test  (passed)\n> test\n> node test\u002Finvoice.test.js\n\nok - invoice total includes tax\n```\n\nTwo turns, and at no point was the working tree broken. Both replies are real output, with Node's internal stack frames cut from the first and the project path shortened.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>And the \u003Ccode>pack\u003C\u002Fcode> call that came before it\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n```json\n{\n  \"query\": \"calculateTax\",\n  \"files\": [\"src\u002Ftax.js\", { \"path\": \"src\u002Finvoice.js\", \"symbol\": \"invoiceTotal\" }, \".env\"],\n  \"git_status\": true\n}\n```\n\n```text\n## GIT STATUS\n## master\n\n## SEARCH \"calculateTax\" (3 hits, engine=rg)\nsrc\u002Finvoice.js:1: import { calculateTax } from \".\u002Ftax.js\";\nsrc\u002Finvoice.js:4:   return Number((subtotal + calculateTax(subtotal)).toFixed(2));\nsrc\u002Ftax.js:3: export function calculateTax(amount) {\n\n## FILES (3)\n### FILE: src\u002Ftax.js (L1-6\u002F6)\n1 | export const TAX_RATE = 0.08;\n2 |\n3 | export function calculateTax(amount) {\n4 |   return Number((amount * TAX_RATE).toFixed(2));\n5 | }\n6 |\n\n### SYMBOL: src\u002Finvoice.js :: function invoiceTotal (L3-5\u002F6)\n3 | export function invoiceTotal(subtotal) {\n4 |   return Number((subtotal + calculateTax(subtotal)).toFixed(2));\n5 | }\n\n### FILE: .env\n[REDACTED SECRET FILE: .env — pass allow_secrets: true if intentional]\n```\n\n\u003C\u002Fdetails>\n\n## Set it up\n\nYou need Node.js 22 or newer. Then:\n\n```bash\nnpx turnpack init\n```\n\n```bash\nnpx turnpack doctor\n```\n\n`init` finds the AI apps you have installed, shows you exactly what it would change, and asks before writing. By default that is Claude Code, Claude Desktop, Codex (the CLI and the ChatGPT desktop app share one config), OMP and Grok Build.\n\n- **The entry it writes starts a file on your machine, with an absolute path to Node.** That starts in tens of milliseconds, works offline, cannot change version without you, and does not depend on the `PATH` a desktop app happens to be given. If you ran `init` through `npx`, the server's files are first copied to `~\u002F.turnpack\u002Fversions\u002F\u003Cversion>`, because the `npx` cache gets cleaned. Prefer a portable entry? `init --npx` writes `npx -y turnpack@\u003Cversion> serve` instead, pinned to the version.\n- **It then starts the server with that exact command** and tells you whether it answered. An entry in a config file and an entry that works are different things.\n- **It is careful with your files.** Every file it edits gets a `.turnpack.bak` copy, anything you added to an existing entry is kept, a config it cannot parse is left untouched, and the file's own indentation and line endings are preserved. It never adds rules to your `CLAUDE.md` or `AGENTS.md`. `npx turnpack uninstall` removes only what `init` added.\n- **It leaves room for slow tests.** Codex and Grok Build give an MCP tool 60 seconds by default, which is also `ship`'s default verify timeout. `init` sets the app's limit for Turnpack to 10 minutes so a long test run is not cut off by the app.\n\n`doctor` checks the fences and then every app: it reads each app's config and starts the server exactly as that app would, so a stale path shows up as a failure there instead of as tools silently missing in a session. Restart your AI apps after `init` so they load the server.\n\n**Claude Desktop without a terminal.** Each [release](https:\u002F\u002Fgithub.com\u002FOnlyTerp\u002Fturnpack\u002Freleases\u002Flatest) carries `turnpack.mcpb`. Open it and Claude Desktop shows an install dialog and asks, with a folder picker, which project folder Turnpack may work in. It runs on the Node that ships inside Claude Desktop.\n\n\u003Cdetails>\n\u003Csummary>\u003Cstrong>Manual setup and per-app snippets\u003C\u002Fstrong>\u003C\u002Fsummary>\n\n**Claude Code** — one command:\n\n```bash\nclaude mcp add --scope user turnpack -- npx -y turnpack serve\n```\n\nor add this to `~\u002F.claude.json` (this is what `init` writes):\n\n```json\n{\n  \"mcpServers\": {\n    \"turnpack\": { \"command\": \"npx\", \"args\": [\"-y\", \"turnpack\", \"serve\"] }\n  }\n}\n```\n\n**Codex CLI** — `~\u002F.codex\u002Fconfig.toml`:\n\n```toml\n[mcp_servers.turnpack]\ncommand = \"npx\"\nargs = [\"-y\", \"turnpack\", \"serve\"]\n```\n\nThe ChatGPT desktop app reads the same file. Add `tool_timeout_sec = 600` to the block so a test run longer than a minute is not cut off.\n\n**Claude Desktop** — `claude_desktop_config.json` (Settings → Developer → Edit Config). A chat has no project folder, so name one:\n\n```json\n{\n  \"mcpServers\": {\n    \"turnpack\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"turnpack\", \"serve\"],\n      \"env\": { \"TURNPACK_ROOT\": \"\u002Fpath\u002Fto\u002Fyour\u002Fproject\" }\n    }\n  }\n}\n```\n\nor let `init` write it: `npx turnpack init --client claude-desktop --root \u002Fpath\u002Fto\u002Fyour\u002Fproject`\n\n**OMP (`oh-my-pi`)** — `~\u002F.omp\u002Fagent\u002Fmcp.json`, plus an optional status-line extension:\n\n```bash\nnpx turnpack init --client omp --yes\n```\n\n**Grok Build** — `~\u002F.grok\u002Fconfig.toml`, the same `[mcp_servers.turnpack]` block as Codex.\n\n**Cursor, Gemini CLI, OpenCode** — `init` writes only the MCP server entry for these, and only when you name them:\n\n```bash\nnpx turnpack init --client cursor --yes\n```\n\n```bash\nnpx turnpack init --experimental --yes\n```\n\n**On Windows**, `npx` is a batch file, and many apps cannot start one directly. Use `\"command\": \"cmd\"` with `\"args\": [\"\u002Fc\", \"npx\", \"-y\", \"turnpack\", \"serve\"]` in the snippets above. `init` avoids the problem by writing Node's own path.\n\nConfig paths, where each app gets its workspace from, and inline size caps are in [docs\u002Fharness-matrix.md](docs\u002Fharness-matrix.md).\n\n\u003C\u002Fdetails>\n\nTurnpack tells the agent when to use its tools through the MCP `instructions` field: about 230 tokens, the same on every session in a project. In Claude Code, which hides MCP tools behind a search step by default, Turnpack asks for its three tools to be loaded with the session, so the model can call them straight away. If your agent still reaches for one-file-at-a-time tools, [docs\u002Fsteering.md](docs\u002Fsteering.md) has an optional snippet for your rules file, an optional Claude Code hook, and a one-line way to log which tools were called.\n\n## The three tools\n\n### `pack`: gather context in one call\n\n| Argument | What it does |\n| :--- | :--- |\n| `query`, `literal` | Search the repo with a regex, or plain text. Uses ripgrep when installed, a built-in search otherwise. |\n| `context` | Lines of code to return around each hit (up to 30), grouped by file with the hits marked. This is the trip parallel reads cannot save: without it the agent has to see the search result before it knows what to open. |\n| `files` | `\"src\u002Fapp.ts\"` (whole file), `\"src\u002Fapp.ts:10-80\"` (lines), `\"src\u002Fapp.ts#handleLogin\"` (one function or class, in JS\u002FTS, Python, Rust or Go), `\"src\u002Fapp.ts#\"` (an outline). The object form `{ \"path\": …, \"symbol\": … }` works too. When a long file is cut off, the reply lists the functions below the cut. |\n| `globs` | List matching paths, for example `\"src\u002F**\u002F*.test.ts\"`. |\n| `git_status` | Include `git status --short --branch`. |\n| `max_bytes`, `inline_only` | Reply size cap (4,000–44,000 bytes, set per app by default). What fits is returned inline; overflow goes to private files outside your repo that the agent reads only if it needs them. |\n\n### `ship`: edit, test, and undo if it fails\n\n| Argument | What it does |\n| :--- | :--- |\n| `edits` | Search-and-replace. Each `search` must identify one place (or pass `replace_all`). The exact text is tried first. If it is not there, a difference the model did not mean is tolerated, as long as it still points at exactly one place: line endings, indentation, trailing spaces, line numbers copied from a listing, curly quotes. The replacement is re-indented to match the file, and the reply says when this happened. |\n| `patch` | The same change as one patch, in the `apply_patch` format OpenAI's models write or as a unified diff. Hunks are placed by their context, not their line numbers. |\n| `writes`, `moves`, `deletes` | Create, replace, rename or delete whole files. A moved file can be edited under its new name in the same call. |\n| `verify` | Commands that must each exit 0, run in order, for example `[\"npm test\"]` or `[\"tsc --noEmit\", \"npm test\"]`. `{files}` becomes the files the call changed: `\"npx vitest related {files} --run\"`. |\n| `rollback_on_fail` | Defaults to `true`. |\n\nEvery edit is checked before anything is written: a problem in file five means files one to four are never touched. All the problems come back in one reply, each with the closest text in the file, its line numbers and the first line that differs, so the next attempt needs no re-read:\n\n```text\nABORTED_BEFORE_WRITE: src\u002Finvoice.js (edits[1]): search text not found. The closest text is lines 3-5 (2 of 3 line(s) identical apart from indentation):\n  3 | export function invoiceTotal(subtotal) {\n  4 |   return Number((subtotal + calculateTax(subtotal)).toFixed(2));\n  5 | }\nFirst difference, at line 4:\n  search has: \"  return subtotal + calculateTax(subtotal);\"\n  file has:   \"  return Number((subtotal + calculateTax(subtotal)).toFixed(2));\"\n\nNothing was written.\n```\n\nIf the server finds your project's check command (a `test` or `typecheck` script in `package.json`, `cargo check`, `go test`, `pytest`, a `make test` target), it tells the model at the start of the session, so `verify` is not left out for want of knowing what to run.\n\nThe reply always starts with what is true on disk now:\n\n`SHIPPED_AND_VERIFIED` · `APPLIED_NO_VERIFY` · `ABORTED_BEFORE_WRITE` · `FAILED_AND_ROLLED_BACK` · `FAILED_ROLLBACK_PARTIAL` · `FAILED_KEPT_ON_DISK`\n\nWhen verify fails, the agent gets the beginning and the end of the output, because test failures are reported at the end. When it passes, it gets a few lines, because nobody needs 800 lines of green.\n\nReplies also say which lines each file's change covers, which verify command failed and which passed before it, and whether the file and line a failure names is one the call changed. What happens in each edge case (a failure after some edits landed, a process killed mid-test, a file that changed after the agent read it, steps that depend on each other) is in [docs\u002Fbehavior.md](docs\u002Fbehavior.md).\n\n### `batch`: one script instead of forty reads\n\n```js\n\u002F\u002F Which source files still import the old module, and how many functions does each have?\nconst hits = await ctx.grep(\"from \\\".\u002Flegacy\", { literal: true });\nconst files = [...new Set(hits.map((h) => h.relPath))];\nreturn files.map((f) => ({ file: f, functions: ctx.outline(f).length }));\n```\n\nThe script gets `ctx.files(glob)`, `ctx.read(path, start, end)`, `ctx.outline(path)`, `await ctx.grep(pattern)` and `await ctx.gitStatus()`. It cannot write files, start processes, or see your environment variables. See [Safety](#safety) for how that is enforced.\n\n## How much does it save?\n\nFirst, what your app already does. We read the source and documentation of Claude Code, Codex, OMP and Grok Build ([docs\u002Fbaselines.md](docs\u002Fbaselines.md)). All four run independent calls in parallel, so none of them makes one tool call per round trip, and `pack` saves less than a naive count would suggest. Codex and OMP can already edit several files in one call. What none of the four has is a step that edits, runs the check, and puts every file back when the check fails. That is `ship`.\n\nThen, a measurement. One task (rename a function used in five files, then make the tests pass), run through Claude Code 2.1.280 with Claude Sonnet 5, three times per arm, with nothing in the prompt about Turnpack:\n\n| | Solved | Model round trips | Tool calls | Time | Output tokens | Cost |\n| :--- | ---: | ---: | ---: | ---: | ---: | ---: |\n| Built-in tools | 3\u002F3 | 6 | 13 | 23.4 s | 2,044 | $0.131 |\n| Built-in tools, asked to batch | 3\u002F3 | 5 | 13 | 23.9 s | 2,063 | $0.121 |\n| With Turnpack | 3\u002F3 | 3 | 2 | 12.7 s | 873 | $0.084 |\n\nEach figure is the median of three runs; the per-run numbers are in [`bench\u002Fresults\u002F2026-11-13-claude-code.json`](bench\u002Fresults\u002F2026-11-13-claude-code.json), and the charts on this page are drawn from that file. With Turnpack every run was the same three round trips: one `pack` (a search with three lines of context), one `ship` that made nine edits in five files and ran `npm test`, one closing message. The model chose those tools unprompted in all three runs.\n\nRead it with these in mind:\n\n- **It is one small task, one model, three runs per arm.** It shows the direction and that the model reaches for the tools. It is not a benchmark of your work. Bigger tasks have more round trips of thinking that no tool removes.\n- **The built-in arm was already batching.** Its 13 tool calls took 6 round trips, with up to 9 calls in one. Asking it to batch harder changed nothing. The saving came from the dependent steps: search then read, and edit then test.\n- **Other apps: less evidence.** In Codex CLI 0.166, three runs out of three used `pack` and then one `ship` carrying all five edits and the test. We have no Codex comparison without Turnpack: on the test machine its shell sandbox could not start processes in the scratch directory, so that arm could not run the tests at all. OMP and Grok Build were not measured.\n\nRun it on your own setup. It costs a few cents per run:\n\n```bash\nnpm run bench:agents -- --agents claude,codex --arms native,turnpack --runs 3\n```\n\n[`bench\u002Fagent-bench.mjs`](bench\u002Fagent-bench.mjs) builds a throwaway project for every run, hands Turnpack to the CLI through a flag, and leaves your own configs alone. If your result differs, including \"no gain\", please open an issue with it.\n\n### A way to estimate your own case\n\n```text\ntime saved per task = round trips avoided × (time to first token + tokens per turn ÷ tokens per second)\n```\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Ftime-saved-dark.svg\" \u002F>\n  \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"assets\u002Ftime-saved-light.svg\" \u002F>\n  \u003Cimg alt=\"Modeled waiting time for a 16-round-trip task done in 4, across five latency profiles\" src=\"assets\u002Ftime-saved-dark.svg\" width=\"100%\" \u002F>\n\u003C\u002Fpicture>\n\nThe chart models one scenario, a task that would take 16 round trips done in 4, across five latency profiles. That scenario is an agent that makes one tool call per round trip. None of the apps above works that way by default, so treat it as the upper end and put your own round-trip counts into the calculator:\n\n| Latency profile | One turn | 16 turns | 4 turns |\n| :--- | :--- | ---: | ---: |\n| Local GPU, warm cache | 0.5s to first token + 330 tokens at 30\u002Fs = 11.5s | 3m 04s | 46s |\n| Fast cloud API | 2s + 225 tokens at 45\u002Fs = 7s | 1m 52s | 28s |\n| Frontier reasoning model | 6s + 360 tokens at 30\u002Fs = 18s | 4m 48s | 1m 12s |\n| Busy or cold-cache API | 15s + 400 tokens at 20\u002Fs = 35s | 9m 20s | 2m 20s |\n\nRead it with these in mind:\n\n- **The turn counts are an assumption, not a measurement.** Agents that already issue tool calls in parallel make fewer round trips for reads to begin with: 6 rather than 13 in the run above. With those, expect less from `pack` and most of the gain from `ship`, because no built-in tool edits, tests and rolls back in one turn.\n- **The latency numbers are examples.** Yours are easy to measure, and both the CLI and the [interactive calculator](docs\u002Fcalculator.html) take them as input:\n\n  ```bash\n  npx turnpack estimate --ttft 2 --tok-per-turn 300 --tps 40\n  ```\n\n- **It does not count** the turns an agent spends repairing a half-applied edit, which is the cost `ship` exists to remove.\n\nThe formula and every default are written out in [docs\u002Ftime-calculator.md](docs\u002Ftime-calculator.md). The benchmark protocol (native tools, native tools plus a batching prompt, and native tools plus Turnpack, on the same model and task) and how to read its output are in [bench\u002FREADME.md](bench\u002FREADME.md).\n\n### What Turnpack itself costs\n\nThese are measured, by `npm run bench` and `npx turnpack doctor --json` on Linux x64 with Node 22.23:\n\n| | Measured | Notes |\n| :--- | ---: | :--- |\n| Tool schema in your context | 5,179 bytes, about 1,295 tokens | All three tools, plus about 230 tokens of instructions. In Claude Code they load with the session by design; in apps that defer MCP tools (OMP, Grok Build) only the names and instructions load until the first call. |\n| Server start and handshake | 50–60 ms | Local stdio, no network |\n| `pack`: a search, four files and a blocked `.env` | about 8 ms | Median of 5 runs on a 42-file fixture |\n| `ship`: a two-file edit and a `node` verify | about 35 ms | Dominated by starting the verify command |\n| `batch`: outline 40 files | about 80 ms | Most of it is starting the isolated process |\n\n## Safety\n\nAn agent that can edit files and run commands deserves fences. These are the ones Turnpack puts up, and where each one ends.\n\n| Fence | What it does | Where it ends |\n| :--- | :--- | :--- |\n| **Workspace jail** | The workspace is fixed by the server, not by the model: `TURNPACK_ROOT`, else the folders your app reports over MCP `roots`, else `CLAUDE_PROJECT_DIR` (believed only when the client is Claude), else the directory the server started in. A tool call can pick a subdirectory and nothing else. Symlinks are resolved before the check, including ones whose target does not exist yet. | Some desktop apps start the server in your home directory or their own install folder and name no project. Turnpack never treats those as a workspace. There, each call has to name its project folder, the call is confined to that folder, and home, drive roots, system folders and credential folders are refused. That is the one case where the model picks the folder. Set `TURNPACK_ROOT` to pin it. |\n| **Secret shield** | `.env*`, private keys, `.npmrc`, cloud credentials, Terraform state and [similar files](SECURITY.md) are redacted from `pack` and `batch` and refused by `ship`. | It matches file names, not contents, and the agent can pass `allow_secrets`. It prevents accidents; it is not a vault. |\n| **Read-only `batch`** | The script runs in a separate process started under Node's permission model: no file writes, no child processes, no workers, reads limited to the workspace. It is handed no host objects and none of your environment variables, and it is killed at its time limit. | Node's permission model does not restrict network access on Node 22. `TURNPACK_ALLOW_EXEC=1` turns `ctx.exec` on and the read-only promise off. |\n| **Protected paths** | `ship` never writes a `.turnpack.json` or anything inside a `.git` directory, at any depth, so an edit cannot switch off the allowlist or plant a git hook. On Windows the other spellings of those names (`.git::$INDEX_ALLOCATION`, `.turnpack.json::$DATA`, a trailing dot or space, 8.3 short names) are refused in every tool, so they cannot be used to reach a protected or secret file under a second name. | |\n| **Verify allowlist** | Optional. With `{\"enforceVerifyAllowlist\": true, \"allowedVerify\": [\"npm test\"]}` in `.turnpack.json` at the workspace root, `ship` runs only those exact commands, whichever subdirectory a call names. Extra arguments are refused unless an entry opts in with a trailing ` *`. A broken config file blocks verify rather than disabling the list. | The command runs your project's code, and `ship` can edit that code, including the test script itself. It stops unapproved commands from being launched; it does not stop a hijacked agent from changing what an approved one does. Also: an app that sandboxes the model's shell (Codex does) does not sandbox MCP servers, so a verify command runs outside that sandbox. The app's approval prompt for the tool, and this list, are the gates. |\n| **Rollback** | Byte-exact snapshots taken before the first write, restored when verify fails or times out, and when the server receives SIGINT or SIGTERM mid-verify. If the process is ended outright instead (`kill -9`, the app quitting, a power cut), the next Turnpack server to start or handle a call restores the files from a journal on disk, and the model is told what was undone. New files and the directories created for them are removed. A file that something else changed while verify was running (you saved it in your editor) is left as it is and reported, never overwritten. | After a hard kill the edits stay on disk until a Turnpack server starts or handles a call. Side effects of the verify command itself (a migrated database, generated files) are not undone. `ship` cannot tell your save from a verify command that rewrites the files being shipped (a formatter with `--fix`); either way those files are left and the status is `FAILED_ROLLBACK_PARTIAL`. Keep using git. |\n| **Zero dependencies** | `\"dependencies\": {}`. The whole server is the TypeScript in `src\u002F`. | |\n\nEach fence has tests that attack it: sandbox escapes, path traversal, symlink escapes, Windows path aliases, allowlist smuggling, argument injection, runaway regexes, rollback under a kill signal, a save made while the tests run. They are in [`test\u002F`](test), and `npx turnpack doctor` re-checks the main ones on your machine. The full threat model is in [SECURITY.md](SECURITY.md).\n\n## When you don't need it\n\n- **A one-line fix in a file the agent already has open.** One edit is one edit; there is nothing to fold.\n- **Pasting a whole repository into a chat window.** That is what [Repomix](https:\u002F\u002Fgithub.com\u002Fyamadashy\u002Frepomix) is for. Turnpack is for an agent working inside a repo, a slice at a time.\n- **A project with no fast check.** `ship` earns its keep when a test, type check or build takes seconds. Without a `verify` it is a multi-file edit with validation and nothing more.\n\n## FAQ\n\n**My agent already reads several files in parallel. What does `pack` add?**\nLess than it would for an agent that does not, and all four apps in [docs\u002Fbaselines.md](docs\u002Fbaselines.md) do. Parallel calls remove round trips for reads the model already knows it wants. What they cannot remove is the trip between a search and the reads it leads to, which `pack` folds into one call with `context`. It also caps the reply size, redacts secrets, and behaves the same in apps and with models that do not parallelize. If your agent batches reads well, you will mostly notice `ship`.\n\n**Codex and OMP can already edit several files in one call. What does `ship` add there?**\nThe test run in the same call, and putting every file back when it fails or when a write fails part-way. `ship` takes Codex's own patch format, so the model does not have to change how it writes edits to get that.\n\n**Will the model actually use these tools?**\nIn the runs we measured, yes: Claude Code with Sonnet 5 and Codex CLI each chose `pack` and `ship` in three runs out of three, with nothing in the prompt about them. That is two apps, one task and default settings, so it is evidence and not a guarantee. An install with other tools or rules that push the model elsewhere may behave differently; one heavily customised OMP setup we tried solved the task without touching Turnpack. `TURNPACK_LOG` tells you what your own agent does, and [docs\u002Fsteering.md](docs\u002Fsteering.md) covers the optional ways to push harder.\n\n**Why not `git stash` or `git checkout` to roll back?**\n`ship` works without git, never touches your index, staging area or unrelated uncommitted changes, restores only the files it changed, and removes the files it created.\n\n**If the tests fail after some edits landed, is the whole call undone?**\nYes. Every edit is checked before anything is written, the check runs after all of them, and a failure puts every file back, new files and folders included. If the process running the check is killed instead, the next Turnpack server to start puts them back. [docs\u002Fbehavior.md](docs\u002Fbehavior.md) has the edge cases.\n\n**Does `ship` run my whole test suite?**\nIt runs exactly the `verify` commands it is given, in order, and stops at the first failure. `{files}` in a command becomes the changed files, so `\"npx vitest related {files} --run\"` tests only what the change touches. Put a fast check first and the full suite after it.\n\n**Is `batch` a sandbox?**\nIt is two layers. The script gets a tiny API and no host objects, and it runs in a process that Node itself refuses to let write, spawn or read outside the workspace. Node documents its permission model as a safety net against trusted code doing something unintended rather than a defence against deliberately malicious code, and we describe ours the same way. [SECURITY.md](SECURITY.md) says exactly what is and is not blocked.\n\n**Does it send anything anywhere?**\nNo. There is no network code in the server. `ship` runs the verify command you or the agent names, and that command can do whatever your shell can.\n\n**Does it work on Windows?**\nYes, natively. CI runs the full suite on Windows, macOS and Linux. Timed-out verify commands are stopped with `taskkill \u002FT`, and paths are checked across drive letters.\n\n## Prior art\n\nTurnpack builds on ideas from Anthropic's programmatic tool calling, Cloudflare's Code Mode, [`context-mode`](https:\u002F\u002Fgithub.com\u002Fmksglu\u002Fcontext-mode), [Repomix](https:\u002F\u002Fgithub.com\u002Fyamadashy\u002Frepomix) and [Serena](https:\u002F\u002Fgithub.com\u002Foraios\u002Fserena). Its own angle is narrow: three tools, a small schema, and edits that are tested before they are allowed to stay.\n\n## More\n\n- [Recipes](docs\u002Frecipes\u002F01-multi-file-rename.md): multi-file rename, verify allowlist, native Windows, when not to use it\n- [What Turnpack does when a check fails part-way, a process is killed, or a plan changes](docs\u002Fbehavior.md)\n- [Steering your agent toward the tools](docs\u002Fsteering.md)\n- [App compatibility matrix](docs\u002Fharness-matrix.md)\n- [What Claude Code, Codex, OMP and Grok Build already do without Turnpack](docs\u002Fbaselines.md)\n- [Time model and calculator](docs\u002Ftime-calculator.md) · [interactive version](docs\u002Fcalculator.html)\n- [Benchmarks: engine timings and the agent comparison](bench\u002FREADME.md)\n- [Security policy](SECURITY.md) · [Contributing](CONTRIBUTING.md) · [Changelog](CHANGELOG.md)\n\n## License\n\n[Apache License 2.0](LICENSE). You may use, change and redistribute Turnpack, including in commercial products. If you redistribute it, with or without changes, keep the license and the [NOTICE](NOTICE) file with it and say which files you changed. The license grants no right to use the Turnpack name or logo, beyond saying where the software came from.\n\n\u003Cdiv align=\"center\">\n  \u003Csub>Apache License 2.0 · Built by \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FOnlyTerp\">OnlyTerp\u003C\u002Fa>\u003C\u002Fsub>\n\u003C\u002Fdiv>\n","Turnpack 是一个面向 AI 编程代理的本地上下文打包与安全代码变更工具。它通过 MCP（Model Context Protocol）协议封装多文件上下文，并在应用 AI 生成的编辑前自动运行测试验证，失败则自动回滚；支持零依赖、无需 API 密钥的本地执行，显著减少模型往返轮次（实测从 6 轮降至 3 轮）、缩短耗时并降低成本。适用于使用 Claude Code、Cursor 等 MCP 兼容 IDE 的本地 AI 辅助开发场景，尤其适合对变更安全性与效率有要求的日常编码迭代。",2,"2026-11-24 04:49:16","CREATED_QUERY"]