Skip to content

Commit 0c7efad

Browse files
flatbenclaude
andcommitted
chore: sync uncommitted work to GitHub
Automated backup of in-progress changes onto a review branch; main is untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 837068d commit 0c7efad

10,541 files changed

Lines changed: 2111 additions & 1329339 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

-14 KB
Binary file not shown.

AGENTS.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# AGENTS.md — Coding Guidelines for ImgTagPlus
2+
3+
ImgTagPlus is a Python CLI/Web tool for AI-powered image tagging using CLIP/Florence models via ONNX Runtime. Tags are saved as XMP sidecar files for DAM compatibility.
4+
5+
---
6+
7+
## Build / Lint / Test Commands
8+
9+
### Install dependencies
10+
```bash
11+
python3 -m venv .venv
12+
source .venv/bin/activate
13+
pip install -r requirements.txt
14+
pip install -r requirements-dev.txt
15+
```
16+
17+
### Run all tests
18+
```bash
19+
pytest
20+
```
21+
22+
### Run a single test file
23+
```bash
24+
pytest tests/test_cli.py
25+
```
26+
27+
### Run a single test function
28+
```bash
29+
pytest tests/test_cli.py::test_start_server_daemon_does_not_restart_when_mode_matches -v
30+
```
31+
32+
### Lint / format code
33+
```bash
34+
ruff check . # Check for lint errors
35+
ruff check --fix . # Auto-fix lint errors
36+
ruff format . # Format code
37+
```
38+
39+
### Build frontend CSS
40+
```bash
41+
npm install
42+
npm run build:css # Compiles Tailwind CSS
43+
```
44+
45+
### Pre-download models for development
46+
```bash
47+
python -m imgtagplus -i ./test_image.jpg --model-id clip --silent --output-dir /tmp/imgtagplus-model-warmup
48+
```
49+
50+
---
51+
52+
## Code Style Guidelines
53+
54+
### Python Version
55+
- Requires Python >= 3.10
56+
- Use modern type hints (e.g., `str | None`, `list[int]`)
57+
58+
### Imports
59+
- Always use `from __future__ import annotations` at the top
60+
- Group imports: stdlib → third-party → local (imgtagplus)
61+
- Use absolute imports for local modules: `from imgtagplus.tagger import ...`
62+
63+
### Formatting
64+
- Line length: 120 characters (configured in pyproject.toml)
65+
- Use Ruff for linting and formatting
66+
- Trailing commas in multi-line structures
67+
68+
### Type Hints
69+
- Use type hints on all function parameters and return values
70+
- Prefer modern union syntax: `str | None` over `Optional[str]`
71+
- Use `from __future__ import annotations` to enable forward references
72+
73+
### Naming Conventions
74+
- `snake_case` for functions, variables, methods
75+
- `PascalCase` for classes
76+
- `UPPER_CASE` for module-level constants and enums
77+
- Private functions/vars: `_leading_underscore`
78+
- Internal constants: `_UPPER_CASE` with leading underscore
79+
80+
### Error Handling
81+
- Catch specific exceptions, avoid bare `except:`
82+
- Use `log = logging.getLogger(__name__)` for module logging
83+
- Handle timeouts and network errors gracefully
84+
- Provide informative error messages to users
85+
86+
### Documentation
87+
- Module-level docstrings explaining purpose
88+
- Function docstrings for public APIs
89+
- Comments for complex algorithms or non-obvious code
90+
91+
---
92+
93+
## Testing Guidelines
94+
95+
### Test Organization
96+
- Tests live in `tests/` directory
97+
- Test files named `test_*.py`
98+
- Test functions named `test_*`
99+
- Use `conftest.py` for shared fixtures
100+
101+
### Writing Tests
102+
- Use pytest fixtures (e.g., `tmp_path`, `monkeypatch`)
103+
- Mock external dependencies (filesystem, network, processes)
104+
- Test both success and error paths
105+
- Keep tests isolated and deterministic
106+
107+
### Running Tests
108+
- Use `-v` for verbose output
109+
- Use `-k pattern` to filter tests by name
110+
111+
---
112+
113+
## Project Structure
114+
115+
```
116+
imgtagplus/
117+
__init__.py # Package version
118+
cli.py # CLI entry points and argument parsing
119+
app.py # Main orchestrator for tagging runs
120+
tagger.py # CLIP-based image tagging
121+
vlm.py # Florence-2 VLM integration
122+
server.py # FastAPI web server
123+
scanner.py # Image file discovery
124+
metadata.py # XMP sidecar writing
125+
monitor.py # Progress monitoring
126+
profiler.py # Model management
127+
tags.py # Tag vocabulary
128+
tui.py # Textual TUI interface
129+
logger.py # Logging setup
130+
131+
tests/ # Test suite
132+
docs/ # Documentation
133+
website/ # Project website
134+
```
135+
136+
---
137+
138+
## CI / Automation
139+
140+
GitHub Actions runs on push/PR:
141+
- Tests across Python 3.10, 3.11, 3.12
142+
- Ruff linting
143+
- Full test suite with pytest
144+
145+
---
146+
147+
## Key Patterns
148+
149+
### Lazy Imports
150+
Keep CLI fast by deferring heavy imports:
151+
```python
152+
def run(args):
153+
from imgtagplus.app import run # noqa: E402
154+
sys.exit(run(args))
155+
```
156+
157+
### Model Caching
158+
Models cache to `~/.cache/imgtagplus` or repo-local `.cache/imgtagplus`.
159+
Never commit model files to Git.
160+
161+
### Server Lifecycle
162+
- PID file: `/tmp/imgtagplus_server_{uid}.pid`
163+
- State file: `/tmp/imgtagplus_server_{uid}.json`
164+
- Health endpoint: `http://127.0.0.1:5000/health`
165+
166+
---
167+
168+
## Contributing Notes
169+
170+
See `CONTRIBUTING.md` for detailed guidelines.
171+
172+
Before PR:
173+
1. Run `ruff check .`
174+
2. Run `pytest`
175+
3. Update `CHANGELOG.md` for user-visible changes
176+
4. Keep sandbox/local-only safety behavior intact

imgtagplus/.DS_Store

-6 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
4.55 KB
Binary file not shown.
0 Bytes
Binary file not shown.
1.17 KB
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)