{"_id":"@agora-build/tcap","_rev":"3-f3a99ba9b3b76c19eef376f6d3158c5f","name":"@agora-build/tcap","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@agora-build/tcap","version":"0.1.0","keywords":["terminal","scrollback","capture","tmux","kitty","iterm2","llm","cli"],"author":{"name":"Agora Build","email":"build@agora.io"},"license":"MIT","_id":"@agora-build/tcap@0.1.0","maintainers":[{"name":"agora.build","email":"brent@agora.io"}],"homepage":"https://github.com/Agora-Build/TermCap#readme","bugs":{"url":"https://github.com/Agora-Build/TermCap/issues"},"os":["linux","darwin"],"bin":{"tcap":"bin/tcap"},"cpu":["x64","arm64"],"dist":{"shasum":"de88c9801ea17052aa885868435fa265b7f83288","tarball":"https://registry.npmjs.org/@agora-build/tcap/-/tcap-0.1.0.tgz","fileCount":4,"integrity":"sha512-/4R2GpGopFL8+1kQWXENBI9m5Z29C7VrquW75k56AtSrkMf+Q3VHylT+vPr4l7oxIaZ6+IqRCTTtT+uXKykfMw==","signatures":[{"sig":"MEQCIAoB3NDSzwAyduVrDHZ2tgfOcFEcujpa0mmr7X1uX6aPAiAxfqytix2ChkOmOKoorSxLwOZ3DH+czm3nTPnBeWuTvQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8831},"engines":{"node":">=16"},"gitHead":"b8c193e4d18d8aa09719808008976580a94c184d","scripts":{"postinstall":"node install.js"},"_npmUser":{"name":"agora.build","email":"brent@agora.io"},"repository":{"url":"git+https://github.com/Agora-Build/TermCap.git","type":"git"},"_npmVersion":"10.8.2","description":"Capture the last command and its output from your terminal, ready to pipe into an LLM","directories":{},"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tcap_0.1.0_1789072515272_0.09997845827044038","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@agora-build/tcap","version":"0.1.1","keywords":["terminal","scrollback","capture","tmux","kitty","iterm2","llm","cli"],"author":{"name":"Agora Build","email":"build@agora.io"},"license":"MIT","_id":"@agora-build/tcap@0.1.1","maintainers":[{"name":"agora.build","email":"brent@agora.io"}],"homepage":"https://github.com/Agora-Build/TermCap#readme","bugs":{"url":"https://github.com/Agora-Build/TermCap/issues"},"os":["linux","darwin"],"bin":{"tcap":"bin/tcap"},"cpu":["x64","arm64"],"dist":{"shasum":"50b7aa6d1b4e302eefe43d4f8c5a4d6fa8c425be","tarball":"https://registry.npmjs.org/@agora-build/tcap/-/tcap-0.1.1.tgz","fileCount":4,"integrity":"sha512-AaXxAa+3ttzkK85MegHHkQ3yJktMcAv0/e+hgLaqrqJ/t90EkVlU9KNxtANGDs3PawwUxurUp6Fda3ZGcIbcPQ==","signatures":[{"sig":"MEQCID4n7LA4/Pq/VKck3JqQ8eePb75doD5KxRgMDn4qsTU6AiAwp3pqABckzg2L6VTU2/kEju1Ukgb2IBCq9oyePxiuMg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9397},"engines":{"node":">=16"},"gitHead":"0df4659bdc81911080a4307f2aca332eca5109a4","scripts":{"postinstall":"node install.js"},"_npmUser":{"name":"agora.build","email":"brent@agora.io"},"repository":{"url":"git+https://github.com/Agora-Build/TermCap.git","type":"git"},"_npmVersion":"10.8.2","description":"Capture the last command and its output from your terminal, ready to pipe into an LLM","directories":{},"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tcap_0.1.1_1789115828162_0.617794384745278","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@agora-build/tcap","version":"0.1.2","description":"Capture the last command and its output from your terminal, ready to pipe into an LLM","bin":{"tcap":"bin/tcap"},"scripts":{"postinstall":"node install.js"},"repository":{"type":"git","url":"git+https://github.com/Agora-Build/TermCap.git"},"keywords":["terminal","scrollback","capture","tmux","kitty","iterm2","llm","cli"],"author":{"name":"Agora Build","email":"build@agora.io"},"license":"MIT","bugs":{"url":"https://github.com/Agora-Build/TermCap/issues"},"homepage":"https://github.com/Agora-Build/TermCap#readme","os":["linux","darwin"],"cpu":["x64","arm64"],"engines":{"node":">=16"},"_id":"@agora-build/tcap@0.1.2","gitHead":"f6343bb2d8e3001e9359d1cdd3b03c5daa82eeef","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-dF51dRV6SeytHI2cjC48O1JVJ8t6quXGzTE3TyRjE3D3U9+ZUfSwtwhlgNF9102yw2CGQUJVTPYIJPosQkLoiQ==","shasum":"759df6cb719b33f4d06ac7b73b04b11192f4ec6b","tarball":"https://registry.npmjs.org/@agora-build/tcap/-/tcap-0.1.2.tgz","fileCount":4,"unpackedSize":9447,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCYGwRN9HBqpFyGrjLlaWaKJk9QJsbW7ypoO7VvWB0ewQIhAO1+vgl3QifBU5w8iJIIaOc6nJEWOnBp1q7b0n4YsD8a"}]},"_npmUser":{"name":"agora.build","email":"brent@agora.io"},"directories":{},"maintainers":[{"name":"agora.build","email":"brent@agora.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tcap_0.1.2_1789116382566_0.7476215389588399"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-10T20:35:15.096Z","modified":"2026-09-11T08:46:22.944Z","0.1.0":"2026-09-10T20:35:15.424Z","0.1.1":"2026-09-11T08:37:08.289Z","0.1.2":"2026-09-11T08:46:22.673Z"},"bugs":{"url":"https://github.com/Agora-Build/TermCap/issues"},"author":{"name":"Agora Build","email":"build@agora.io"},"license":"MIT","homepage":"https://github.com/Agora-Build/TermCap#readme","keywords":["terminal","scrollback","capture","tmux","kitty","iterm2","llm","cli"],"repository":{"type":"git","url":"git+https://github.com/Agora-Build/TermCap.git"},"description":"Capture the last command and its output from your terminal, ready to pipe into an LLM","maintainers":[{"name":"agora.build","email":"brent@agora.io"}],"readme":"# @agora-build/tcap\n\nCapture the last command and its output from your terminal, ready to pipe into an LLM.\n\n```console\n$ npm run build\n> app@1.0.0 build\n> tsc\nError: Cannot find module 'foo'\n\n$ tcap | sgpt \"tell me how to fix it\"\n```\n\n`tcap` gives the model the command, its exit code, where it ran, and the output:\n\n```console\n$ npm run build\n# exit: 1  cwd: ~/Dev/app  took: 3.2s\n\n> app@1.0.0 build\n> tsc\nError: Cannot find module 'foo'\n```\n\nThe exit code carries more weight than it looks — it tells the model the command\ngenuinely failed, instead of leaving it to infer that from the text.\n\n## Install\n\n```sh\nnpm i -g @agora-build/tcap\n```\n\nThe postinstall step downloads a prebuilt binary for your platform (macOS and\nLinux, x64 and arm64). If it can't reach GitHub it falls back to\n`dl.agora.build`, and if both fail it exits cleanly rather than breaking your\ninstall — `tcap` then tells you how to recover.\n\nThen enable shell integration and open a new terminal:\n\n```sh\necho 'eval \"$(tcap init zsh)\"' >> ~/.zshrc\n```\n\n```sh\n# bash\necho 'eval \"$(tcap init bash)\"' >> ~/.bashrc\n# fish\necho 'tcap init fish | source' >> ~/.config/fish/config.fish\n```\n\nConfirm it's wired up:\n\n```sh\ntcap doctor\n```\n\nShell integration is what supplies the exit code, duration and command text.\nWithout it you still get output, and `tcap` tells you what's missing and why.\n\n## Usage\n\nTwo axes, each with an index and a count form, under one rule:\n**lowercase selects the Nth from the end, uppercase takes the last N.**\n\n| | index (lowercase) | count (uppercase) |\n|---|---|---|\n| **commands** | `-c 3` — 3rd-from-last block | `-C 3` — last 3 blocks |\n| **lines** | `-l 3` — 3rd-from-last line | `-L 3` — last 3 lines |\n\nThey combine, which is what makes long build logs usable:\n\n```sh\ntcap                  # last command + its output\ntcap -c 2             # the command before the last one\ntcap -C 3             # the last 3 commands, oldest first\ntcap -c 2 -L 50       # 2nd-to-last command, tail 50 lines of its output\n```\n\n### Output formats\n\n```sh\ntcap --output         # output only, no header\ntcap --command        # the command text only\ntcap --raw            # verbatim, ANSI colour intact\ntcap --json           # {command, exit_code, cwd, duration_ms, output, source}\n                      # plus \"approximate\": true when the backend cannot vouch\n                      # that the output belongs to that command\ntcap --copy           # also copy to the clipboard\ntcap --max-bytes 8000 # elide the middle to fit a smaller context window\n```\n\n`--command` prints the command; `-c` selects *which* command. Similar spelling,\nunrelated jobs.\n\n## Terminal support\n\n| Terminal | Last command | Older (`-c 2`) | Needs |\n|---|---|---|---|\n| **tmux** | yes | **yes** | nothing |\n| **kitty** | yes | no | remote control: `yes`, or `socket-only` + `listen_on` |\n| **iTerm2** | yes | no | Shell Integration + `pip install iterm2` |\n| **WezTerm** | not yet | no | run inside tmux |\n| Ghostty, Terminal.app, Alacritty | no | no | run inside tmux |\n\nTwo things worth knowing up front:\n\n**Only tmux can reach past the most recent command.** kitty exposes only the\nlatest output and nothing older; iTerm2 exposes only its latest prompt. So `tcap\n-c 2` fails there with a pointer to tmux rather than quietly returning the wrong\nblock.\n\n**On kitty, output is the last *non-empty* output**, because kitty counts the\nrunning `tcap` as the current command. A command that printed nothing therefore\nyields an older output under the current header; it is labelled with a `# note:` line and\n`\"approximate\": true` in `--json`, plus a one-line stderr reminder once per\nsession. Two `tcap` runs in a row are a hard\nerror instead, since the mismatch is certain there. tmux has no such ambiguity.\n\n**tmux wins whenever it's running.** Inside kitty running tmux, asking kitty for\nits scrollback returns tmux's rendered viewport rather than the shell's real\nhistory, so tmux is always treated as authoritative when it's in the stack.\n\nAnything missing is reported with its cause and fix, on stderr so `tcap | sgpt`\nstill pipes clean text:\n\n```console\n$ tcap\ntcap: captured output only — no command, exit code or duration.\n  Cause: tcap's shell integration is not recording in this session,\n         so there is nothing to annotate the output with.\n  Fix:   add to your ~/.zshrc then open a new shell:\n           eval \"$(tcap init zsh)\"\n```\n\n## Configuration\n\nOptional, at `~/.config/tcap/config.toml`:\n\n```toml\nmax_bytes = 8000        # smaller budget for a smaller context window\nformat    = \"json\"      # default output format\nquiet     = false       # suppress the stderr hints\n```\n\nPrecedence is `flags > environment > config > defaults`. An unknown key is an\nerror rather than a silent no-op, and `--no-quiet` / `--no-copy` escape a config\nboolean for a single run.\n\n## Links\n\n- Source, full docs and issues: <https://github.com/Agora-Build/TermCap>\n- Standalone install: `curl -fsSL https://dl.agora.build/tcap/install.sh | bash`\n\nMIT\n","readmeFilename":"README.md"}