browsercontrol 0.1.2__tar.gz → 0.1.3__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.
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/.gitignore +1 -6
- browsercontrol-0.1.3/.pre-commit-config.yaml +56 -0
- browsercontrol-0.1.3/CODE_QUALITY.md +81 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/CONTRIBUTING.md +25 -2
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/PKG-INFO +132 -91
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/README.md +131 -90
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/browser.py +123 -124
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/config.py +12 -18
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/server.py +3 -11
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/content.py +29 -28
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/devtools.py +101 -97
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/forms.py +28 -27
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/interaction.py +45 -37
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/navigation.py +28 -27
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/recording.py +74 -64
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/tabs.py +14 -14
- browsercontrol-0.1.3/node_modules/.cache/prettier/.prettier-caches/91665f0f9d7600991a6f27263bd495571952d52f.json +1 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/pyproject.toml +30 -1
- browsercontrol-0.1.3/tests/__init__.py +0 -0
- browsercontrol-0.1.3/tests/conftest.py +127 -0
- browsercontrol-0.1.3/tests/test_browser.py +232 -0
- browsercontrol-0.1.3/tests/test_content.py +135 -0
- browsercontrol-0.1.3/tests/test_devtools.py +195 -0
- browsercontrol-0.1.3/tests/test_forms.py +140 -0
- browsercontrol-0.1.3/tests/test_interaction.py +222 -0
- browsercontrol-0.1.3/tests/test_navigation.py +167 -0
- browsercontrol-0.1.3/tests/test_recording.py +114 -0
- browsercontrol-0.1.3/tests/test_tabs.py +109 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/uv.lock +106 -1
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/LICENSE +0 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/assets/logo.png +0 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/__init__.py +0 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/__main__.py +0 -0
- {browsercontrol-0.1.2 → browsercontrol-0.1.3}/browsercontrol/tools/__init__.py +3 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
# Ruff - Fast Python linter and formatter
|
|
3
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
4
|
+
rev: v0.8.4
|
|
5
|
+
hooks:
|
|
6
|
+
# Run the linter
|
|
7
|
+
- id: ruff
|
|
8
|
+
args: [--fix]
|
|
9
|
+
# Run the formatter
|
|
10
|
+
- id: ruff-format
|
|
11
|
+
|
|
12
|
+
# General file checks
|
|
13
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
14
|
+
rev: v5.0.0
|
|
15
|
+
hooks:
|
|
16
|
+
- id: trailing-whitespace
|
|
17
|
+
- id: end-of-file-fixer
|
|
18
|
+
- id: check-yaml
|
|
19
|
+
- id: check-toml
|
|
20
|
+
- id: check-json
|
|
21
|
+
- id: check-added-large-files
|
|
22
|
+
args: [--maxkb=1000]
|
|
23
|
+
- id: check-merge-conflict
|
|
24
|
+
- id: check-case-conflict
|
|
25
|
+
- id: mixed-line-ending
|
|
26
|
+
args: [--fix=lf]
|
|
27
|
+
|
|
28
|
+
# Markdown formatting
|
|
29
|
+
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
30
|
+
rev: v4.0.0-alpha.8
|
|
31
|
+
hooks:
|
|
32
|
+
- id: prettier
|
|
33
|
+
types_or: [markdown, yaml, json]
|
|
34
|
+
exclude: ^(uv\.lock|\.vscode/)
|
|
35
|
+
|
|
36
|
+
# Python security checks
|
|
37
|
+
- repo: https://github.com/PyCQA/bandit
|
|
38
|
+
rev: 1.8.0
|
|
39
|
+
hooks:
|
|
40
|
+
- id: bandit
|
|
41
|
+
args: [-c, pyproject.toml]
|
|
42
|
+
additional_dependencies: ["bandit[toml]"]
|
|
43
|
+
exclude: ^tests/
|
|
44
|
+
|
|
45
|
+
# CI configuration
|
|
46
|
+
ci:
|
|
47
|
+
autofix_commit_msg: |
|
|
48
|
+
[pre-commit.ci] auto fixes from pre-commit hooks
|
|
49
|
+
|
|
50
|
+
for more information, see https://pre-commit.ci
|
|
51
|
+
autofix_prs: true
|
|
52
|
+
autoupdate_branch: ""
|
|
53
|
+
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
|
|
54
|
+
autoupdate_schedule: weekly
|
|
55
|
+
skip: []
|
|
56
|
+
submodules: false
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Code Formatting and Quality
|
|
2
|
+
|
|
3
|
+
This project uses automated code formatting and linting tools to maintain code quality.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
- **[Ruff](https://github.com/astral-sh/ruff)** - Fast Python linter and formatter
|
|
8
|
+
- **[Pre-commit](https://pre-commit.com/)** - Git hooks for automated checks
|
|
9
|
+
- **[Prettier](https://prettier.io/)** - Markdown/YAML/JSON formatting
|
|
10
|
+
- **[Bandit](https://bandit.readthedocs.io/)** - Security vulnerability scanner
|
|
11
|
+
|
|
12
|
+
## Setup
|
|
13
|
+
|
|
14
|
+
The tools are already configured. To install the pre-commit hooks:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv sync
|
|
18
|
+
uv run pre-commit install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Manual Formatting
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Check for linting issues
|
|
27
|
+
uv run ruff check .
|
|
28
|
+
|
|
29
|
+
# Auto-fix linting issues
|
|
30
|
+
uv run ruff check . --fix
|
|
31
|
+
|
|
32
|
+
# Format code
|
|
33
|
+
uv run ruff format .
|
|
34
|
+
|
|
35
|
+
# Run all pre-commit hooks manually
|
|
36
|
+
uv run pre-commit run --all-files
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Automatic Formatting
|
|
40
|
+
|
|
41
|
+
Pre-commit hooks run automatically on `git commit`. They will:
|
|
42
|
+
|
|
43
|
+
1. Run ruff linter and formatter
|
|
44
|
+
2. Trim trailing whitespace
|
|
45
|
+
3. Fix end-of-file issues
|
|
46
|
+
4. Format markdown/YAML/JSON with prettier
|
|
47
|
+
5. Check for security issues with bandit
|
|
48
|
+
|
|
49
|
+
If any hook fails, the commit will be aborted and files will be auto-fixed. Review the changes and commit again.
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
### Ruff
|
|
54
|
+
|
|
55
|
+
Configuration in `pyproject.toml`:
|
|
56
|
+
|
|
57
|
+
- **Line length**: 100 characters
|
|
58
|
+
- **Target Python**: 3.11+
|
|
59
|
+
- **Enabled rules**: pycodestyle, pyflakes, isort, pep8-naming, pyupgrade, bugbear, comprehensions, simplify, type-checking, Ruff-specific
|
|
60
|
+
- **Ignored rules**: E501 (line too long), B008 (function call in defaults), N805 (first arg naming), SIM117 (nested with), B904 (exception chaining)
|
|
61
|
+
|
|
62
|
+
### Pre-commit
|
|
63
|
+
|
|
64
|
+
Configuration in `.pre-commit-config.yaml`:
|
|
65
|
+
|
|
66
|
+
- Ruff linter and formatter
|
|
67
|
+
- General file checks (trailing whitespace, EOF, YAML/TOML/JSON validation, large files, merge conflicts)
|
|
68
|
+
- Prettier for markdown formatting
|
|
69
|
+
- Bandit for security checks (excludes tests, allows subprocess for Playwright)
|
|
70
|
+
|
|
71
|
+
## Bypassing Hooks
|
|
72
|
+
|
|
73
|
+
If you need to bypass pre-commit hooks (not recommended):
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git commit --no-verify
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## CI Integration
|
|
80
|
+
|
|
81
|
+
Pre-commit.ci is configured to run automatically on pull requests and can auto-fix issues.
|
|
@@ -23,7 +23,11 @@ We love your input! We want to make contributing to BrowserControl as easy and t
|
|
|
23
23
|
```bash
|
|
24
24
|
uv run playwright install chromium
|
|
25
25
|
```
|
|
26
|
-
5. **
|
|
26
|
+
5. **Install pre-commit hooks**:
|
|
27
|
+
```bash
|
|
28
|
+
uv run pre-commit install
|
|
29
|
+
```
|
|
30
|
+
6. **Run the server in dev mode**:
|
|
27
31
|
```bash
|
|
28
32
|
uv run fastmcp dev browsercontrol/server.py
|
|
29
33
|
```
|
|
@@ -33,11 +37,13 @@ We love your input! We want to make contributing to BrowserControl as easy and t
|
|
|
33
37
|
We use [uv](https://github.com/astral-sh/uv) for dependency management and packaging. It's fast and reliable.
|
|
34
38
|
|
|
35
39
|
### Project Structure
|
|
40
|
+
|
|
36
41
|
- `browsercontrol/server.py`: Main MCP server definition
|
|
37
42
|
- `browsercontrol/browser.py`: Core logic (Playwright + Set of Marks)
|
|
38
43
|
- `browsercontrol/tools/`: Tool implementations split by category
|
|
39
44
|
|
|
40
45
|
### Making Changes
|
|
46
|
+
|
|
41
47
|
1. Create a branch for your feature: `git checkout -b feature/amazing-feature`
|
|
42
48
|
2. Implement your changes
|
|
43
49
|
3. Run tests (see below)
|
|
@@ -48,17 +54,33 @@ We use [uv](https://github.com/astral-sh/uv) for dependency management and packa
|
|
|
48
54
|
|
|
49
55
|
## 🧪 Testing
|
|
50
56
|
|
|
51
|
-
We use `pytest
|
|
57
|
+
We use `pytest` for testing and `ruff` for code quality. Please ensure all checks pass before submitting a PR.
|
|
52
58
|
|
|
53
59
|
```bash
|
|
54
60
|
# Run all tests
|
|
55
61
|
uv run pytest
|
|
56
62
|
|
|
63
|
+
# Run tests with coverage
|
|
64
|
+
uv run pytest --cov=browsercontrol
|
|
65
|
+
|
|
66
|
+
# Check code formatting and linting
|
|
67
|
+
uv run ruff check .
|
|
68
|
+
uv run ruff format .
|
|
69
|
+
|
|
70
|
+
# Run all pre-commit hooks
|
|
71
|
+
uv run pre-commit run --all-files
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
See [CODE_QUALITY.md](CODE_QUALITY.md) for more details on code formatting and quality tools.
|
|
75
|
+
|
|
57
76
|
# Run specific test file
|
|
77
|
+
|
|
58
78
|
uv run pytest tests/test_navigation.py
|
|
79
|
+
|
|
59
80
|
```
|
|
60
81
|
|
|
61
82
|
If you add a new tool or feature, please add a corresponding test case covering:
|
|
83
|
+
|
|
62
84
|
- Happy path (it works)
|
|
63
85
|
- Error handling (it fails gracefully)
|
|
64
86
|
|
|
@@ -82,3 +104,4 @@ Bugs are tracked as GitHub issues. When filing an issue, please explain the prob
|
|
|
82
104
|
## 📄 License
|
|
83
105
|
|
|
84
106
|
By contributing, you agree that your contributions will be licensed under its MIT License.
|
|
107
|
+
```
|