strayguard 0.1.0__tar.gz

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,75 @@
1
+ name: publish
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"] # a version tag publishes to PyPI
6
+ workflow_dispatch: # a manual run publishes to TestPyPI only
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build:
13
+ name: Build and check the package
14
+ runs-on: ubuntu-latest
15
+ timeout-minutes: 10
16
+ steps:
17
+ - uses: actions/checkout@v7
18
+ - uses: astral-sh/setup-uv@v10.3.0
19
+ - name: Check that the tag matches the version in pyproject.toml
20
+ if: github.event_name == 'push'
21
+ run: |
22
+ version=$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
23
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
24
+ echo "Tag $GITHUB_REF_NAME does not match version $version in pyproject.toml."
25
+ exit 1
26
+ fi
27
+ - name: Run the unit tests
28
+ run: uv run --no-project --with pytest pytest -q
29
+ - name: Build the wheel and the source archive
30
+ run: uv build
31
+ - name: Check that PyPI can show the README
32
+ run: uvx twine check --strict dist/*
33
+ - uses: actions/upload-artifact@v7
34
+ with:
35
+ name: dist
36
+ path: dist/
37
+
38
+ testpypi:
39
+ name: Publish to TestPyPI
40
+ if: github.event_name == 'workflow_dispatch'
41
+ needs: build
42
+ runs-on: ubuntu-latest
43
+ timeout-minutes: 10
44
+ environment:
45
+ name: testpypi
46
+ url: https://test.pypi.org/p/strayguard
47
+ permissions:
48
+ id-token: write
49
+ steps:
50
+ - uses: actions/download-artifact@v8
51
+ with:
52
+ name: dist
53
+ path: dist/
54
+ - uses: pypa/gh-action-pypi-publish@release/v1
55
+ with:
56
+ repository-url: https://test.pypi.org/legacy/
57
+ skip-existing: true
58
+
59
+ pypi:
60
+ name: Publish to PyPI
61
+ if: github.event_name == 'push'
62
+ needs: build
63
+ runs-on: ubuntu-latest
64
+ timeout-minutes: 10
65
+ environment:
66
+ name: pypi
67
+ url: https://pypi.org/p/strayguard
68
+ permissions:
69
+ id-token: write
70
+ steps:
71
+ - uses: actions/download-artifact@v8
72
+ with:
73
+ name: dist
74
+ path: dist/
75
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,53 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+
12
+ concurrency:
13
+ group: tests-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ test:
18
+ name: Python ${{ matrix.python }} on ${{ matrix.os }}
19
+ runs-on: ${{ matrix.os }}
20
+ timeout-minutes: 10
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ os: [ubuntu-latest]
25
+ python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
26
+ include:
27
+ - os: macos-latest
28
+ python: "3.14"
29
+ steps:
30
+ - uses: actions/checkout@v7
31
+ - uses: astral-sh/setup-uv@v10.3.0
32
+ with:
33
+ python-version: ${{ matrix.python }}
34
+ - name: Run the unit tests
35
+ run: uv run --no-project --with pytest pytest -v
36
+
37
+ build:
38
+ name: Build the package
39
+ runs-on: ubuntu-latest
40
+ timeout-minutes: 10
41
+ steps:
42
+ - uses: actions/checkout@v7
43
+ - uses: astral-sh/setup-uv@v10.3.0
44
+ - name: Build the wheel and the source archive
45
+ run: uv build
46
+ - name: Check the package metadata
47
+ run: |
48
+ unzip -p dist/*.whl '*/METADATA' > METADATA
49
+ grep -q '^License-Expression: MIT' METADATA
50
+ grep -q '^Keywords: ' METADATA
51
+ grep -q '^Requires-Python: >=3.9' METADATA
52
+ echo "Metadata OK"
53
+
@@ -0,0 +1,220 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # uv
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs/Zensical documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
201
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
203
+ # could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
@@ -0,0 +1,11 @@
1
+ - id: strayguard
2
+ name: strayguard
3
+ description: Flag new files that do not belong in the repository, with TypeSafe Jev.
4
+ entry: strayguard check
5
+ language: python
6
+ pass_filenames: false
7
+ always_run: true
8
+ require_serial: true
9
+ verbose: true
10
+ stages: [pre-commit]
11
+ minimum_pre_commit_version: "3.2.0"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eva
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,245 @@
1
+ Metadata-Version: 2.5
2
+ Name: strayguard
3
+ Version: 0.1.0
4
+ Summary: A git pre-commit hook that asks TypeSafe Jev whether each new file belongs in your repo.
5
+ Project-URL: Homepage, https://github.com/Eve2512/Strayguard
6
+ Project-URL: Issues, https://github.com/Eve2512/Strayguard/issues
7
+ Author: Eva Hill
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: git,gitignore,hook,jev,pre-commit,typesafe
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Software Development :: Version Control :: Git
18
+ Requires-Python: >=3.9
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=8; extra == 'dev'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Strayguard
24
+ Catch files that don't belong before you commit them. A git pre-commit hook that asks TypeSafe Jev whether each new file belongs in your repo. It catches scratch scripts, debug dumps, build output and local config before they land. Takes under a second, costs a fraction of a cent, needs no config.
25
+
26
+
27
+ ### Why
28
+
29
+ ```git add .``` adds everything. Sometimes that includes:
30
+
31
+ - ```test_fix2.py```, a throwaway script
32
+ - ```debug_output.json```, which you dumped while chasing a bug
33
+ - ```notes-to-self.md```
34
+ - ```data_export.csv``` with real customer rows
35
+ - ```.env.local``` with your own settings
36
+ - a whole ```dist/``` folder
37
+
38
+ Coding agents make this worse, they create helper scripts and scratch files and often don't clean them up.
39
+ Whatever coding tool you use most likely miss most of these files:
40
+
41
+ | Tool | Catches | Misses |
42
+ |---|---|---|
43
+ | ```.gitignore``` | Names you listed in advance | Every name you didn't think of |
44
+ | Secret scanners | API keys and tokens | Junk scripts, data dumps, notes |
45
+ | Large-file checks | Big files | Small junk files |
46
+ | **strayguard** | **Files that don't look like part of the project** | Changes to files git already tracks |
47
+
48
+
49
+ ### How it works
50
+
51
+ 1. You run ```git commit```.
52
+ 2. strayguard looks only at files that are **new** in this commit.
53
+ 3. A few local rules run first, such as ```.env``` and ```.DS_Store```. Files they match are never sent anywhere.
54
+ 4. For the other files, Jev picks one category: **belongs**, **scratch / leftover**, **output dump**, **build output** or **local only**.
55
+ 5. If Jev is at least 70% sure a file doesn't belong, strayguard shows it to you.
56
+ 6. If everything belongs, you see nothing.
57
+
58
+ Jev never writes text(not good for that anyways) It only picks a category and returns a probability. The same file always gets the same answer, because strayguard caches the result.
59
+
60
+ ### Install
61
+
62
+ You need Python 3.9+ and a [TypeSafe API key](https://console.typesafe.ai/keys).
63
+
64
+ ```bash
65
+ pipx install strayguard
66
+ ```
67
+
68
+ Until the first PyPI release, install it from GitHub instead:
69
+
70
+ ```bash
71
+ pipx install git+https://github.com/Eve2512/Strayguard
72
+ ```
73
+
74
+ ```bash
75
+ export TYPESAFE_API_KEY=your-key
76
+ ```
77
+
78
+ Then, inside your repo:
79
+
80
+ ```bash
81
+ strayguard install
82
+ ```
83
+
84
+ ```text
85
+ ✓ strayguard installed in .git/hooks/pre-commit
86
+ ```
87
+
88
+ That's it, there's no config file
89
+
90
+
91
+ ### With the pre-commit framework
92
+
93
+ Add this to `.pre-commit-config.yaml`:
94
+
95
+ ```yaml
96
+ repos:
97
+ - repo: https://github.com/Eve2512/Strayguard
98
+ rev: v0.1.0
99
+ hooks:
100
+ - id: strayguard
101
+ ```
102
+
103
+ The pre-commit framework captures the output of its hooks, so strayguard cannot ask you questions there. It shows the warning and lets the commit through, as described in [GUI clients, CI and coding agents](#gui-clients-ci-and-coding-agents).
104
+
105
+
106
+ ## What you'll see
107
+
108
+ ### Everything belongs
109
+
110
+ Nothing, your commit goes through as normal.
111
+
112
+ ```text
113
+ $ git commit -m "add login page"
114
+ [main 4f2a91c] add login page
115
+ 3 files changed, 120 insertions(+)
116
+ ```
117
+
118
+ ### Something looks wrong
119
+
120
+ ```text
121
+ $ git commit -m "add login page"
122
+
123
+ ⚠ strayguard: 2 new files look like they don't belong
124
+
125
+ debug_output.json output dump 87%
126
+ test_fix2.py scratch / leftover 91%
127
+
128
+ [u] unstage [g] add to .gitignore [k] keep and commit [o] one by one
129
+ > g
130
+
131
+ ✓ Added 2 files to .gitignore and staged .gitignore.
132
+ ✓ Unstaged 2 files. They are still on your disk.
133
+
134
+ Commit stopped so you can check. Run git commit again.
135
+ ```
136
+
137
+ | Key | What it does |
138
+ |---|---|
139
+ | `u` | Takes the files out of this commit. They stay on your disk. |
140
+ | `g` | Adds the files to `.gitignore` so this never happens again, and takes them out of this commit. |
141
+ | `k` | Commits the files anyway. strayguard won't ask about them again. |
142
+ | `o` | Lets you choose `u`, `g` or `k` for each file. |
143
+ | Enter | Same as `k`. |
144
+
145
+ strayguard **never deletes files**. It stops the commit only if it changed something for you, so you can check before you commit again.
146
+
147
+
148
+ ### GUI clients, CI and coding agents
149
+
150
+ strayguard asks you a question only when its output goes straight to your terminal. GUI git clients, CI, coding agents and the pre-commit framework all capture the output, so there strayguard warns and lets the commit through:
151
+
152
+ ```text
153
+ ⚠ strayguard: 2 new files may not belong (not blocking)
154
+
155
+ debug_output.json output dump 87%
156
+ test_fix2.py scratch / leftover 91%
157
+
158
+ To unstage them:
159
+ git rm --cached -r -- debug_output.json test_fix2.py
160
+ ```
161
+
162
+ To block the commit instead, set `STRAYGUARD_STRICT=1`, this is a good setting for coding-agent sessions.
163
+
164
+
165
+ ### Files caught by a local rule
166
+
167
+ These files are never sent to Jev, so they show `rule` instead of a percentage:
168
+
169
+ ```text
170
+ .env.local local only rule
171
+ ```
172
+
173
+ ### When strayguard can't reach Jev
174
+
175
+ It prints one line, still runs its local rules, and lets the commit through:
176
+
177
+ ```text
178
+ strayguard: no TYPESAFE_API_KEY set, so only the local rules ran.
179
+ strayguard: Jev did not answer in 5 s, so only the local rules ran.
180
+ ```
181
+
182
+ ## Settings
183
+
184
+ Everything is optional except the key.
185
+
186
+ | Variable | Default | What it does |
187
+ |---|---|---|
188
+ | `TYPESAFE_API_KEY` | none | **Required.** Your TypeSafe API key. |
189
+ | `STRAYGUARD=off` | `on` | Skip the check for one commit: `STRAYGUARD=off git commit ...` |
190
+ | `STRAYGUARD_STRICT=1` | `0` | Block the commit when strayguard can't ask you, such as in CI or with agents. |
191
+ | `STRAYGUARD_THRESHOLD` | `0.70` | How sure Jev must be before strayguard warns you. |
192
+ | `STRAYGUARD_MODEL` | `jev-latest` | Pin a version, for example `jev-1.13.0`, to keep answers stable. |
193
+ | `STRAYGUARD_NAMES_ONLY=1` | `0` | Send only file names and sizes, never content. |
194
+
195
+ You can also skip every hook for one commit with `git commit --no-verify`.
196
+
197
+ ## Privacy
198
+
199
+ For each **new** text file, strayguard sends TypeSafe its path, its size, its first 40 lines (at most 2,000 characters) and the names of a few tracked files next to it.
200
+
201
+ It never sends:
202
+
203
+ - files that a local rule catches, such as `.env` files, keys and certificates
204
+ - binary files, or files larger than 1 MB
205
+ - any content at all when `STRAYGUARD_NAMES_ONLY=1` is set
206
+
207
+ TypeSafe says it does not train models on customer data. See its [legal page](https://docs.typesafe.ai/legal).
208
+
209
+ ## Cost and speed
210
+
211
+ - A typical commit costs less than $0.0001.
212
+ - The check usually finishes in under a second.
213
+ - Each file's answer is cached by its content, so running the commit again is instant and free.
214
+
215
+ ## Uninstall
216
+
217
+ ```bash
218
+ strayguard uninstall
219
+ ```
220
+
221
+ This removes the hook only if strayguard wrote it.
222
+
223
+ ## Commands
224
+
225
+ | Command | What it does |
226
+ |---|---|
227
+ | `strayguard install` | Add the pre-commit hook to this repo |
228
+ | `strayguard uninstall` | Remove the hook |
229
+ | `strayguard check` | Run the check on staged new files (the hook runs this) |
230
+ | `strayguard --version` | Show the version |
231
+
232
+ ## Development
233
+
234
+ Run the unit tests. They use no network and no API key:
235
+
236
+ ```bash
237
+ uv run --no-project --with pytest pytest
238
+ ```
239
+
240
+ GitHub Actions runs the same tests on Python 3.9 to 3.14 for each push to `main` and for each pull request.
241
+
242
+ ## License
243
+
244
+ MIT. See [LICENSE](https://github.com/Eve2512/Strayguard/blob/main/LICENSE).
245
+