kneepad 0.3.0__py3-none-any.whl

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.
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: kneepad
3
+ Version: 0.3.0
4
+ Summary: Local safety layer for AI coding agents on Linux, macOS and Windows: blocks or snapshots destructive commands, with a footgun database and a tamper-evident audit log.
5
+ License: MIT
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: POSIX :: Linux
8
+ Classifier: Operating System :: MacOS
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Topic :: Security
12
+ Classifier: Topic :: Software Development :: Quality Assurance
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # Kneepad
19
+
20
+ A local safety layer for AI coding agents. It sits in front of the commands your agent runs, stops the ones that cannot be undone, takes a safety copy of the ones that can, and keeps a tamper-evident record of what happened.
21
+
22
+ Zero dependencies. Python 3.11+. Linux, macOS and Windows. Runs entirely on your machine. MIT licensed.
23
+
24
+ ## What it does
25
+
26
+ - **Footgun database.** 249 rules (216 pattern rules plus 33 emitted by engine code) for the commands that ruin days: `rm -rf` on the wrong path, `git push --force` to main, `terraform destroy`, `DROP TABLE`, `kubectl delete ns`, `aws s3 rb --force`, `prisma migrate reset`, `curl | sh`, writes to `~/.ssh` and `.bashrc`, and more. Rules are pattern families (one rule covers every `delete`/`destroy`/`terminate` subcommand of a cloud CLI, for example), across about 560 named tools, including Windows and macOS tools. Count of rules is not coverage: more rules also means more false positives, so every rule must pass the benign corpus. Every rule ships with examples that the test suite executes.
27
+ - **Understands shell, not just text.** Quotes, `$(...)`, backticks, heredocs, pipes, `bash -c`, `eval`, `ssh host '...'`, `docker exec`, `kubectl exec --`, `sudo`/`env`/`nice` wrappers, `npx`/`poetry run`/`bundle exec`, and shell scripts the agent is about to run. `echo "rm -rf /"` is not flagged. `DIR=; rm -rf $DIR/` is.
28
+ - **Snapshots before risky-but-allowed actions.** Deleting untracked files, `git reset --hard`, `git clean`, `git branch -D` each take a copy first. Restore with `kneepad snapshots restore <id>`.
29
+ - **Hash-chained audit log.** Every decision is appended to a JSONL log where each entry commits to the previous one and is signed with a local key. Editing, deleting, reordering or inserting entries is detected by `kneepad verify`.
30
+ - **"Protected by Kneepad" badge.** `kneepad badge` writes an SVG, and refuses to if the hook is not installed or the log does not verify.
31
+
32
+ Decision model: Kneepad never says "allow". Safe commands pass through silently and keep your normal permission flow. Risky ones get `ask`. Catastrophic ones get `deny`. If Kneepad itself errors, it answers `ask`.
33
+
34
+ ## Works with
35
+
36
+ Claude Code, OpenAI Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, Cline, any tool with a command hook (generic JSON), any agent that runs `$SHELL -c` (`kneepad-shell`), and your own Python agents (`kneepad.api`). The decision is made on the action, so it does not matter which LLM is driving. Each integration is tested against the vendor's documented hook contract; none has yet been verified inside the real vendor app. See [docs/INTEGRATIONS.md](docs/INTEGRATIONS.md) for the exact status and known vendor-side limits.
37
+
38
+ ## Platforms
39
+
40
+ | | Linux | macOS | Windows |
41
+ |---|---|---|---|
42
+ | Command analysis | yes | yes: `diskutil`, `tmutil`, `csrutil`, `launchctl`, `security`, `dscl`, `osascript do shell script`, `/private` paths, case-insensitive volumes | yes: cmd.exe and PowerShell syntax, drive and UNC paths, `Remove-Item`/`del`/`rd`, registry, `-EncodedCommand` is decoded, `wsl`/`cmd /c`/`powershell -c` are unwrapped |
43
+ | Agent hook installers | all | all | all except Cline (its docs say macOS and Linux only) |
44
+ | Continuous integration | full suite | full suite | rule examples and platform tests (experimental, not yet seen green) |
45
+
46
+ Be clear about what this means. The Windows and macOS logic was written and unit-tested on Linux by simulating those platforms' paths and syntax, plus a mutation pass over the new code. The CI workflow runs on macOS and Windows runners, but until you have seen it pass there, treat both as unproven on real machines. No agent integration has been run inside its real vendor app on any operating system. Known gaps are listed in [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md).
47
+
48
+ ## Install
49
+
50
+ ```
51
+ pip install kneepad # Windows: py -m pip install kneepad
52
+ kneepad init --claude-code # Claude Code
53
+ kneepad init --target cursor --target gemini --target codex # others (or --target all)
54
+ kneepad doctor
55
+ ```
56
+
57
+ From a checkout instead:
58
+
59
+ ```
60
+ pip install .
61
+ kneepad init --claude-code --scope project # hook for this repo only
62
+ ```
63
+
64
+ `init` backs up your settings file, preserves everything in it, and is safe to run twice. `kneepad uninstall` removes only its own entry.
65
+
66
+ ## Try it without installing the hook
67
+
68
+ ```
69
+ kneepad check 'rm -rf /' # exit 20 (deny)
70
+ kneepad check 'terraform destroy' # exit 10 (ask)
71
+ kneepad check 'ls -la' # exit 0
72
+ kneepad run -- git push --force origin main
73
+ ```
74
+
75
+ ## Everyday commands
76
+
77
+ | command | purpose |
78
+ |---|---|
79
+ | `kneepad log` | recent decisions |
80
+ | `kneepad verify` | check the hash chain and signatures |
81
+ | `kneepad anchor` | print `SEQ:HASH` to store somewhere else (detects tail truncation) |
82
+ | `kneepad snapshots list/show/restore/prune` | safety copies |
83
+ | `kneepad rules list/show/validate` | browse and validate the footgun database |
84
+ | `kneepad badge` | write the badge SVG |
85
+
86
+ ## Configuration
87
+
88
+ User config at `~/.kneepad/config.toml` is trusted and can relax rules (`disable_rules`, `allow_patterns`, `allow_write_paths`, `mode = "monitor"`). A project `.kneepad.toml` is untrusted, because a cloned repo could carry one, so it can only tighten: extra `protected_paths`, `prod_markers`, `protected_branches`, `escalate`, a lower snapshot size cap. Rules marked `no_override` (for example `rm -rf /`) cannot be disabled by any config.
89
+
90
+ A production marker (`prod`, `production`, `prd` as a whole word) in a destructive infrastructure or database command escalates `ask` to `deny`.
91
+
92
+ ## What it is not
93
+
94
+ Read [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md) before relying on it. In short: this catches accidents and common agent mistakes. It is not a sandbox, and it does not stop a determined adversary who can obfuscate commands.
95
+
96
+ ## Development
97
+
98
+ ```
99
+ python3 -m unittest discover -s tests
100
+ ```
101
+
102
+ 258 tests: parser, SQL scanner, every rule example, about 280 everyday commands that must pass silently, about 120 destructive commands that must be stopped, audit tamper fuzzing (every single byte flip is detected), concurrent writers, hostile-repo handling, random-input robustness, and Windows and macOS path and syntax simulation. `python tools/smoke_hook.py` installs the hooks into a throwaway home and runs the written hook command through your real OS shell.
103
+
104
+ Adding a rule: see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md). The rule list is in [docs/FOOTGUNS.md](docs/FOOTGUNS.md).
@@ -0,0 +1,29 @@
1
+ kneepad/__init__.py,sha256=3bDNJyFvQadt1dUQlt_On5CwNeDR1oHq02mTCjU2HrM,70
2
+ kneepad/__main__.py,sha256=4JMK66Wj4uLZTKbF-sT3LAxOsr6buig77PmOkJCRRxw,83
3
+ kneepad/adapters.py,sha256=TcjOneMEF1DmUU0LPcGob8HCamtHqMOEuxuK8oNvVXE,10327
4
+ kneepad/api.py,sha256=Ue_uSZ0bWI0LCuX5OTcfWg25H8xW9fDl6CDu7xsGTfw,2188
5
+ kneepad/argvtools.py,sha256=aeQLcwhEnaVCzWMQrwU8bRWOMhbbVjb-SHId68wyzXw,13563
6
+ kneepad/audit.py,sha256=RLlCds-PALoTyUNniUuUEZq6Cj1t9UkHwa9CP5D8fGs,12327
7
+ kneepad/badge.py,sha256=hN9PmcahBmT43rC9361EO0h_yJvba39nvI2Cmpyw2qc,1546
8
+ kneepad/cli.py,sha256=PVRxei2YUmAbE8f5b4csXsKwAsbzMQ1NHYvE1Vfwo1g,19540
9
+ kneepad/config.py,sha256=OoCZpQmKCeecxSfVdSKk9N-DhqJSTZpvSvHKA7nL9Nk,7537
10
+ kneepad/engine.py,sha256=qiig2IMt25bl_brUaJXGfUEOcRe8AZ0xXhrIgc68uxw,48168
11
+ kneepad/hook.py,sha256=6jWIBSZI45qk3VbffAqAFCZqjlJE-ST1hPa-QUjBwcI,7136
12
+ kneepad/installer.py,sha256=9co9mUbh8XWlgvcElbtr7bTGPqZpfAK9AinRi5A3x34,4211
13
+ kneepad/integrations.py,sha256=PkxjUdfDvSGqpOmVsyD-XLlG3J96qbPdCEQcZHRYp9I,9376
14
+ kneepad/rules.py,sha256=AjsAqBBvmWbRdwk05Y2mEjZBnle9ZM68vf6WiTexXNI,8870
15
+ kneepad/shellparse.py,sha256=A7JoLn4ixPZLEfxN_bn42jcXZnE801E8eObS3OJXCKc,16029
16
+ kneepad/snapshots.py,sha256=jm0MBpt2fUNLEdwmGhW0W_goyAXRmUqnkMVnCkOJAig,14872
17
+ kneepad/sqlscan.py,sha256=1IA-Lzkj0SYF_VcFc2eccfcBrSOCb22PzJ2wOmLN3t0,8549
18
+ kneepad/util.py,sha256=1u2fX__3iCC9wS1hLEr5GMZgSDfEvf36xaQNaVRUWgY,2734
19
+ kneepad/winshell.py,sha256=z4mklxKXo5phX2oP0b6djjcvph5we7AUJEyvHQVx6ik,24403
20
+ kneepad/data/footguns.toml,sha256=o0CdzKwoc1-nmF3avwHKTj6EazaS49oq6VFdwVhaYNE,84528
21
+ kneepad/data/footguns_ext.toml,sha256=irnVw4wtEImnHHaZsmXVu1mex22rKjP69hkDcvf2dDE,42826
22
+ kneepad/data/footguns_macos.toml,sha256=O6GMTucqari9fFIE8R1iBzw_-sUpWG8K8ef8wa44qrQ,14538
23
+ kneepad/data/footguns_windows.toml,sha256=nnQ0hNbc4O39vAHJJ_gWp7_VFpP2PINEh3ancSon_rQ,26009
24
+ kneepad-0.3.0.dist-info/licenses/LICENSE,sha256=nbEgEaZqF5PxUh-dH4uqRUdTIqTwrp_KqvnZ_r1IdW0,1077
25
+ kneepad-0.3.0.dist-info/METADATA,sha256=4HcwgTbBL4cOA1nT2q8t9OxG5GylazP6Y7x7dhDZpZI,7187
26
+ kneepad-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
27
+ kneepad-0.3.0.dist-info/entry_points.txt,sha256=SEtOa7qyRqJAeqCcPFcSYZUl-37S6jGP19BfAwghyfY,84
28
+ kneepad-0.3.0.dist-info/top_level.txt,sha256=R66vvy7__kyY5uJRIvnsmFAyMEhVvHSXvtXPysFPzvE,8
29
+ kneepad-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ kneepad = kneepad.cli:main
3
+ kneepad-shell = kneepad.cli:shell_main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kneepad contributors
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.
@@ -0,0 +1 @@
1
+ kneepad