tollgate-cli 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kartik Manral
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # tollgate-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Your team approves before your coding agent does something you can't undo.
4
+
5
+ `tollgate-cli` installs a [Claude Code](https://claude.com/claude-code) `PreToolUse` hook. When the agent is about to run a risky shell command (a prod deploy, a database migration, `npm publish`, `terraform apply`, an `rm -rf` outside the repo), the hook posts it to your team's Tollgate room and waits:
6
+
7
+ - **Approved:** the command continues, through Claude Code's normal permission check (Guard mode, the default).
8
+ - **Denied with a reason:** the agent receives the reason as its next instruction and revises its plan.
9
+ - **Nobody answers in time:** the gate is **parked** and approvers who haven't voted get a reminder (and one more an hour later). The agent moves on, and once a teammate approves, the exact same command passes on retry (single use, 24 h).
10
+
11
+ Every other command runs untouched; the hook adds about 50 ms.
12
+
13
+ ## Set up
14
+
15
+ 1. In your team's Tollgate room, open **Settings › Repos › Link a repo** and copy the command it shows.
16
+ 2. Run it in the repo:
17
+
18
+ ```bash
19
+ npx tollgate-cli init --server https://your-tollgate.example --token tg_…
20
+ ```
21
+
22
+ 3. Restart Claude Code in the repo, then check the whole loop:
23
+
24
+ ```bash
25
+ npx tollgate-cli test
26
+ ```
27
+
28
+ `init` writes:
29
+
30
+ | File | Commit it? |
31
+ | ----------------------------- | ---------------------------------------------------------------- |
32
+ | `.tollgate.json` | Yes: server, repo and presets, shared by the team |
33
+ | `.claude/settings.local.json` | No (added to `.gitignore`): your personal hook registration |
34
+ | `~/.config/tollgate/` | Never in a repo: your token (file mode 0600) and the hook bundle |
35
+
36
+ ## What leaves your machine
37
+
38
+ Only for commands that match a preset: the command and working directory after **local redaction** (known token formats, `KEY=value` secrets, passwords in URLs, secret flags, and every value from your `.env*` files), Claude Code's one-line description of the command (shown to approvers as the agent's reason), your git branch, the last commit subject, and for migrations the newest migration's SQL (capped at 2 KB). The card shows how many values were hidden. The server redacts everything again.
39
+
40
+ ## Commands
41
+
42
+ | Command | What it does |
43
+ | -------- | ------------------------------------------------------------------- |
44
+ | `init` | Link this repo, store the token, write the presets and hook |
45
+ | `status` | Show the link, presets and token check |
46
+ | `test` | Raise a harmless gate for `echo tollgate-test` |
47
+ | `unlink` | Forget this repo's token on this machine (revoke it in the web app) |
48
+ | `hook` | The hook itself; Claude Code calls it with JSON on stdin |
49
+
50
+ ## Safety notes
51
+
52
+ - **Fails closed.** If the server can't be reached, a risky command is blocked, with a message saying why.
53
+ - **Always answers before Claude Code's hook timeout.** Claude Code runs the command if a hook times out, so Tollgate parks the gate 15 s early and has a watchdog as well.
54
+ - **Emergency bypass.** Start Claude Code with `TOLLGATE_BYPASS=1`. Every bypass is logged to `~/.config/tollgate/audit.log`. The agent can't set this itself: the hook reads Claude Code's environment, not the Bash tool's shell.
55
+ - **Delegate mode** (opt-in per repo, owner only) makes a team approval skip Claude Code's own prompt for that exact command.
56
+
57
+ Requires Node 20.19 or later.