ESC
科技 1 分钟阅读

无损、无头编码代理框架UNCUT发布:7MB静态二进制文件,四工具,纯stdin/stdout

UNCUT是一款专为shell管道、CI任务、容器和agent实验设计的极简编码代理框架。它以7MB静态二进制文件为核心,提供read_file、write_file、replace、run_command四个工具,通过纯标准输入输出与模型交互。项目强调‘无损’特性——不截断、不压缩、不静默裁剪上下文,遇到provider输出限制时直接报错而非返回残缺结果。支持OpenAI兼容接口及本地Ollam

来源:GitHub

\n \"UNCUT\n

UNCUT

\n

The lossless, headless coding agent harness.

\n

One 7 MB static binary, four tools, plain stdin/stdout.
No TUI. No telemetry. No silent context cuts.

\n

Linux · macOS · Windows · amd64 + arm64 · MIT

\n

Landing page: balanov.pro/uncut

\n
\n\n[![CI](https://github.com/Balanov/uncut/actions/workflows/ci.yml/badge.svg)](https://github.com/Balanov/uncut/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/Balanov/uncut)](https://github.com/Balanov/uncut/releases/latest)\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Go](https://img.shields.io/badge/Go-1.26%2B-00ADD8?logo=go&logoColor=white)](go.mod)\n\nUNCUT is a tiny coding-agent harness for shell pipelines, CI jobs, containers, and agent experiments. It deliberately has no TUI, telemetry, plugin system, background agents, automatic retries, or context compaction.\n\nThe entire conversation is sent on every model call. File contents and combined command output are never truncated by UNCUT. If the provider cuts a response at its output limit, UNCUT exits with an error instead of presenting a partial answer as success. [Run the proof yourself](bench/README.md) or inspect the [recorded measurements](BENCHMARKS.md).\n\n## Why UNCUT?\n\n- **Lossless by default.** No summarization, pruning, sliding windows, or silent output caps.\n- **Headless only.** Final text goes to stdout; structured NDJSON events are available with `--json`.\n- **Small and portable.** One statically linked Go binary, no runtime or third-party Go dependencies.\n- **Provider neutral.** Works with OpenAI-compatible Chat Completions endpoints, including local servers.\n- **Resumable.** Optional append-only JSONL sessions preserve every message and tool result.\n- **Forkable.** 837 lines of implementation Go, four tools, one provider protocol, one agent loop, MIT license.\n\n## Install\n\n### Linux\n\n```sh\nVERSION=0.1.1\nARCH=amd64 # Use arm64 on ARM64.\ncurl -fSLo uncut \"https://github.com/Balanov/uncut/releases/download/v${VERSION}/uncut-linux-${ARCH}\"\nmkdir -p \"$HOME/.local/bin\"\ninstall -m 0755 uncut \"$HOME/.local/bin/uncut\"\nexport PATH=\"$HOME/.local/bin:$PATH\"\nuncut --version\n```\n\nMake sure `$HOME/.local/bin` is on your `PATH`.\n\n### macOS\n\n```sh\nVERSION=0.1.1\nARCH=arm64 # Use amd64 on Intel.\ncurl -fSLo uncut \"https://github.com/Balanov/uncut/releases/download/v${VERSION}/uncut-darwin-${ARCH}\"\nmkdir -p \"$HOME/.local/bin\"\ninstall -m 0755 uncut \"$HOME/.local/bin/uncut\"\nexport PATH=\"$HOME/.local/bin:$PATH\"\nuncut --version\n```\n\n### Windows PowerShell\n\n```powershell\n$Version = \"0.1.1\"\n$Arch = \"amd64\" # Use arm64 on ARM64.\n$Dest = \"$env:LOCALAPPDATA\\Programs\\UNCUT\"\nNew-Item -ItemType Directory -Force $Dest | Out-Null\nInvoke-WebRequest -Uri \"https://github.com/Balanov/uncut/releases/download/v$Version/uncut-windows-$Arch.exe\" -OutFile \"$Dest\\uncut.exe\"\n$env:Path = \"$Dest;$env:Path\"\nuncut --version\n```\n\nAdd `$Dest` to your user `PATH` to make UNCUT available in future terminals.\n\n### Checksums and OS warnings\n\nEvery release includes `checksums.txt`. For example, verify a Linux download with:\n\n```sh\nVERSION=0.1.1\nARCH=amd64\ncurl -fSLO \"https://github.com/Balanov/uncut/releases/download/v${VERSION}/checksums.txt\"\ngrep \"uncut-linux-${ARCH}$\" checksums.txt | sha256sum -c -\n```\n\nThe binaries are not code-signed yet, so SmartScreen or Gatekeeper may warn. Verify the SHA-256 checksum before allowing a downloaded executable. On macOS, after verification, remove quarantine from this file only:\n\n```sh\nxattr -d com.apple.quarantine \"$HOME/.local/bin/uncut\"\n```\n\nYou can also build from source instead.\n\n### Go install and source builds\n\nWith Go 1.26+:\n\n```sh\ngo install github.com/Balanov/uncut/cmd/uncut@latest\n```\n\nOr build a checkout:\n\n```sh\ngit clone https://github.com/Balanov/uncut.git\ncd uncut\ngo build -trimpath -ldflags=\"-s -w\" -o bin/uncut ./cmd/uncut\n```\n\nOn Windows, use `bin/uncut.exe` as the output path.\n\n## Quick start\n\nSet a model and API key:\n\n```sh\nexport UNCUT_API_KEY=\"your-api-key\"\nexport UNCUT_MODEL=\"your-model-id\"\nuncut \"Inspect this repository and fix the failing tests\"\n```\n\nFor an OpenAI-compatible provider, also set its base URL:\n\n```sh\nexport UNCUT_BASE_URL=\"https://openrouter.ai/api/v1\"\n```\n\nFor a local Ollama server with an installed tool-capable model (this exact setup was smoke-tested with `qwen3:8b`):\n\n```sh\nollama pull qwen3:8b\nexport UNCUT_BASE_URL=\"http://localhost:11434/v1\"\nexport UNCUT_MODEL=\"qwen3:8b\"\nuncut \"Explain this repository\"\n```\n\nNo API key is required by default for local endpoints. In PowerShell, set variables with `$env:UNCUT_BASE_URL = \"...\"` and `$env:UNCUT_MODEL = \"...\"`. Replace the example model with one actually installed on your machine; tool-call behavior depends on the model.\n\n### Unix pipelines\n\n```sh\ngit diff | uncut \"Review this diff. Do not edit files.\"\ncat failing-test.log | uncut \"Find the likely cause\"\n```\n\nPiped input is appended to the prompt verbatim. UNCUT accepts valid UTF-8 text and rejects invalid input rather than replacing bytes silently.\n\n### JSONL events\n\n```sh\nuncut --json \"Run the tests and fix the failure\"\n```\n\nThe event stream contains `user`, `assistant`, `assistant_meta`, `tool`, and finally `done` or `error` records. Assistant messages include complete tool calls; tool messages include complete results. Usage and finish reasons are separate `assistant_meta` events.\n\n### Sessions\n\n```sh\nuncut --session .uncut/work.jsonl \"Start the refactor\"\nuncut --session .uncut/work.jsonl \"Continue with the tests\"\n```\n\nIf the file exists, UNCUT resumes its complete history. New messages are appended and synced after each step. Invalid or partial records cause an explicit error; they are never discarded to make a session load.\n\nSession files can contain source code, command output, and secrets. Store them accordingly and do not commit them accidentally.\n\n## Configuration\n\n| Environment variable | Purpose | Default |\n| --- | --- | --- |\n| `UNCUT_MODEL` | Model ID; required unless `--model` is used | none |\n| `UNCUT_BASE_URL` | OpenAI-compatible base URL | `OPENAI_BASE_URL`, then `https://api.openai.com/v1` |\n| `UNCUT_API_KEY` | Bearer token | `OPENAI_API_KEY`, then no token |\n\nUseful flags:\n\n| Flag | Default | Meaning |\n| --- | --- | --- |\n| `--cwd` | current directory | Workspace for file tools and shell commands |\n| `--session ` | disabled | Create or resume an append-only JSONL session |\n| `--max-steps ` | `32` | Maximum model calls before exit code 4 |\n| `--max-tokens ` | provider default | Explicit provider output limit |\n| `--request-timeout ` | `10m` | Per-request timeout; `0` disables it |\n| `--no-agents` | false | Do not read workspace `AGENTS.md` |\n| `--json` | false | Emit NDJSON events instead of only final text |\n| `--version` | — | Print version and exit |\n\n`AGENTS.md` is read in full from the workspace root and added to the system prompt. On a resumed session, the original stored system message is reused.\n\n## Tools\n\n| Tool | Behavior |\n| --- | --- |\n| `read_file` | Reads an entire UTF-8 text file |\n| `write_file` | Writes complete file contents and creates parent directories |\n| `replace` | Replaces exactly one occurrence; zero or multiple matches fail |\n| `run_command` | Returns the exit code and complete combined stdout/stderr |\n\nFile paths must stay inside the workspace. `run_command` uses `/bin/sh -c` on Unix and `cmd.exe /D /S /C` on Windows.\n\nSome Windows utilities can emit UTF-16 or code-page output rather than UTF-8. UNCUT rejects that output instead of guessing a conversion; configure commands to emit UTF-8 when possible.\n\n## Exit codes\n\n| Code | Meaning |\n| --- | --- |\n| `0` | Successful final answer |\n| `1` | Provider, I/O, session, or execution error |\n| `2` | Invalid command-line usage |\n| `3` | Provider returned `finish_reason=length` or `max_tokens`; partial answer rejected |\n| `4` | `--max-steps` reached before a final answer |\n\n## What “lossless” means\n\nUNCUT does not truncate, summarize, or rewrite valid UTF-8 prompts, stored messages, file contents, or command output. It does not extend a model's context window, and it cannot control provider-side processing. When the context or output limit is exceeded, the provider may reject or cut the response; UNCUT surfaces that failure instead of hiding it.\n\nBinary files and invalid UTF-8 are rejected explicitly. UNCUT uses non-streaming Chat Completions and supports text plus tool calls, not images.\n\n## Safety\n\n**UNCUT is not a sandbox.** The model can execute shell commands with your operating-system user's permissions. Workspace checks on file tools do not constrain what a shell command can access. Run untrusted tasks in a disposable container or isolated environment, and review sessions and changes yourself.\n\nThere are no approval popups, automatic commits, automatic retries, or hidden recovery loops.\n\n## Verify the lossless contract\n\nThe proof script drives the real binary against a deterministic local provider. It needs Python 3, but no API key, model, or third-party package:\n\n```sh\ngo build -o bin/uncut ./cmd/uncut\npython bench/proof.py ./bin/uncut\n```\n\nIt checks complete large-file and command-output transport, exact session resume, edits, explicit truncation failures, step limits, and invalid UTF-8 handling. See the [recorded results](BENCHMARKS.md) and [reproduction commands](bench/README.md). These are transport tests, not model-quality benchmarks.\n\n## Develop\n\n```sh\ngofmt -w cmd internal\ngo test -count=1 ./...\ngo vet ./...\n```\n\nThe test suite includes complete large-file and large-command-output round trips, session resume, provider truncation, JSON output, and platform-specific shell behavior. See [CONTRIBUTING.md](CONTRIBUTING.md) for the project contract and PR checklist.\n\n```text\ncmd/uncut/ CLI and process exit

codes internal/harness/ agent loop, provider, tools, sessions, platform shells bench/ lossless proof and benchmark drivers assets/ logo and editable brand source docs/ launch material


## License

MIT. Fork it, modify it, ship it. See [LICENSE](LICENSE).