webtap-tool 0.1.5__tar.gz → 0.2.1__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.
Potentially problematic release.
This version of webtap-tool might be problematic. Click here for more details.
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/CHANGELOG.md +35 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/PKG-INFO +4 -1
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/pyproject.toml +4 -1
- webtap_tool-0.2.1/src/webtap/commands/setup.py +249 -0
- webtap_tool-0.2.1/src/webtap/services/setup/__init__.py +178 -0
- webtap_tool-0.2.1/src/webtap/services/setup/chrome.py +229 -0
- webtap_tool-0.2.1/src/webtap/services/setup/desktop.py +228 -0
- webtap_tool-0.2.1/src/webtap/services/setup/extension.py +101 -0
- webtap_tool-0.2.1/src/webtap/services/setup/filters.py +89 -0
- webtap_tool-0.2.1/src/webtap/services/setup/platform.py +126 -0
- webtap_tool-0.1.5/src/webtap/commands/setup.py +0 -161
- webtap_tool-0.1.5/src/webtap/services/setup/__init__.py +0 -66
- webtap_tool-0.1.5/src/webtap/services/setup/chrome.py +0 -77
- webtap_tool-0.1.5/src/webtap/services/setup/desktop.py +0 -151
- webtap_tool-0.1.5/src/webtap/services/setup/extension.py +0 -88
- webtap_tool-0.1.5/src/webtap/services/setup/filters.py +0 -79
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/.gitignore +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/ARCHITECTURE.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/README.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/data/filters.json +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/extension/manifest.json +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/extension/popup.html +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/extension/popup.js +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/llms.txt +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/VISION.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/__init__.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/api.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/app.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/README.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/__init__.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/query.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/schema/README.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/schema/cdp_protocol.json +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/schema/cdp_version.json +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/cdp/session.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/DEVELOPER_GUIDE.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/TIPS.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/__init__.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/_builders.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/_errors.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/_tips.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/_utils.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/body.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/connection.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/console.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/events.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/fetch.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/filters.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/inspect.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/javascript.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/launch.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/navigation.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/commands/network.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/filters.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/README.md +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/__init__.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/body.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/console.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/fetch.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/main.py +0 -0
- {webtap_tool-0.1.5 → webtap_tool-0.2.1}/src/webtap/services/network.py +0 -0
|
@@ -15,6 +15,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
15
|
|
|
16
16
|
### Removed
|
|
17
17
|
|
|
18
|
+
## [0.2.1] - 2025-09-12
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Chrome wrapper on macOS now includes `--remote-allow-origins='*'` flag to allow WebSocket connections
|
|
26
|
+
- All Chrome wrappers (Linux standard, Linux bindfs, macOS) now consistently include the flag
|
|
27
|
+
- Removed incorrect Linux-specific instructions from setup-desktop command output on macOS
|
|
28
|
+
- Fixed setup-chrome usage instructions to correctly reference `chrome-debug` instead of `google-chrome-stable`
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
|
|
32
|
+
## [0.2.0] - 2025-09-12
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- Cross-platform support (Linux and macOS)
|
|
36
|
+
- `setup-cleanup` command to identify and remove old WebTap installations
|
|
37
|
+
- `--bindfs` flag for `setup-chrome` to mount real Chrome profile for debugging (Linux only)
|
|
38
|
+
- Unified `chrome-debug` wrapper at `~/.local/bin/chrome-debug`
|
|
39
|
+
- Separate Chrome Debug launcher (doesn't override system Chrome)
|
|
40
|
+
- Platform detection with XDG-compliant paths via platformdirs
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
- Chrome wrapper location from `~/.local/bin/wrappers/google-chrome-stable` to `~/.local/bin/chrome-debug`
|
|
44
|
+
- Desktop entry from `google-chrome.desktop` override to separate `chrome-debug.desktop`
|
|
45
|
+
- Extension location to platform-appropriate data directories
|
|
46
|
+
- Setup service refactored into platform-aware modules
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
- Cleanup command now detects all old installation locations
|
|
50
|
+
|
|
51
|
+
### Removed
|
|
52
|
+
|
|
18
53
|
## [0.1.5] - 2025-09-10
|
|
19
54
|
|
|
20
55
|
### Added
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webtap-tool
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Terminal-based web page inspector for AI debugging sessions
|
|
5
5
|
Author-email: Fredrik Angelsen <fredrikangelsen@gmail.com>
|
|
6
6
|
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
7
9
|
Classifier: Programming Language :: Python :: 3.12
|
|
8
10
|
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
9
11
|
Classifier: Topic :: Software Development :: Debuggers
|
|
@@ -15,6 +17,7 @@ Requires-Dist: fastapi>=0.116.1
|
|
|
15
17
|
Requires-Dist: httpx>=0.28.1
|
|
16
18
|
Requires-Dist: lxml>=6.0.1
|
|
17
19
|
Requires-Dist: msgpack-python>=0.5.6
|
|
20
|
+
Requires-Dist: platformdirs>=4.4.0
|
|
18
21
|
Requires-Dist: protobuf>=6.32.0
|
|
19
22
|
Requires-Dist: pyjwt>=2.10.1
|
|
20
23
|
Requires-Dist: pyyaml>=6.0.2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "webtap-tool"
|
|
3
|
-
version = "0.1
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "Terminal-based web page inspector for AI debugging sessions"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -10,6 +10,8 @@ requires-python = ">=3.12"
|
|
|
10
10
|
classifiers = [
|
|
11
11
|
"Development Status :: 3 - Alpha",
|
|
12
12
|
"Programming Language :: Python :: 3.12",
|
|
13
|
+
"Operating System :: POSIX :: Linux",
|
|
14
|
+
"Operating System :: MacOS :: MacOS X",
|
|
13
15
|
"Topic :: Software Development :: Debuggers",
|
|
14
16
|
"Topic :: Internet :: WWW/HTTP :: Browsers",
|
|
15
17
|
]
|
|
@@ -21,6 +23,7 @@ dependencies = [
|
|
|
21
23
|
"httpx>=0.28.1",
|
|
22
24
|
"lxml>=6.0.1",
|
|
23
25
|
"msgpack-python>=0.5.6",
|
|
26
|
+
"platformdirs>=4.4.0",
|
|
24
27
|
"protobuf>=6.32.0",
|
|
25
28
|
"pyjwt>=2.10.1",
|
|
26
29
|
"pyyaml>=6.0.2",
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"""Setup commands for WebTap components."""
|
|
2
|
+
|
|
3
|
+
from webtap.app import app
|
|
4
|
+
from webtap.services.setup import SetupService
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@app.command(
|
|
8
|
+
display="markdown",
|
|
9
|
+
typer={"name": "setup-filters", "help": "Download filter configuration from GitHub"},
|
|
10
|
+
fastmcp={"enabled": False},
|
|
11
|
+
)
|
|
12
|
+
def setup_filters(state, force: bool = False) -> dict:
|
|
13
|
+
"""Download filter configuration to ./.webtap/filters.json.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
force: Overwrite existing file (default: False)
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
Markdown-formatted result with success/error messages
|
|
20
|
+
"""
|
|
21
|
+
service = SetupService()
|
|
22
|
+
result = service.install_filters(force=force)
|
|
23
|
+
return _format_setup_result(result, "filters")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@app.command(
|
|
27
|
+
display="markdown",
|
|
28
|
+
typer={"name": "setup-extension", "help": "Download Chrome extension from GitHub"},
|
|
29
|
+
fastmcp={"enabled": False},
|
|
30
|
+
)
|
|
31
|
+
def setup_extension(state, force: bool = False) -> dict:
|
|
32
|
+
"""Download Chrome extension to platform-appropriate location.
|
|
33
|
+
|
|
34
|
+
Linux: ~/.local/share/webtap/extension/
|
|
35
|
+
macOS: ~/Library/Application Support/webtap/extension/
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
force: Overwrite existing files (default: False)
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Markdown-formatted result with success/error messages
|
|
42
|
+
"""
|
|
43
|
+
service = SetupService()
|
|
44
|
+
result = service.install_extension(force=force)
|
|
45
|
+
return _format_setup_result(result, "extension")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@app.command(
|
|
49
|
+
display="markdown",
|
|
50
|
+
typer={"name": "setup-chrome", "help": "Install Chrome wrapper script for debugging"},
|
|
51
|
+
fastmcp={"enabled": False},
|
|
52
|
+
)
|
|
53
|
+
def setup_chrome(state, force: bool = False, bindfs: bool = False) -> dict:
|
|
54
|
+
"""Install Chrome wrapper script 'chrome-debug' to ~/.local/bin/.
|
|
55
|
+
|
|
56
|
+
The wrapper enables remote debugging on port 9222.
|
|
57
|
+
Same location on both Linux and macOS: ~/.local/bin/chrome-debug
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
force: Overwrite existing script (default: False)
|
|
61
|
+
bindfs: Use bindfs to mount real Chrome profile for debugging (Linux only, default: False)
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Markdown-formatted result with success/error messages
|
|
65
|
+
"""
|
|
66
|
+
service = SetupService()
|
|
67
|
+
result = service.install_chrome_wrapper(force=force, bindfs=bindfs)
|
|
68
|
+
return _format_setup_result(result, "chrome")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@app.command(
|
|
72
|
+
display="markdown",
|
|
73
|
+
typer={"name": "setup-desktop", "help": "Install Chrome Debug GUI launcher"},
|
|
74
|
+
fastmcp={"enabled": False},
|
|
75
|
+
)
|
|
76
|
+
def setup_desktop(state, force: bool = False) -> dict:
|
|
77
|
+
"""Install Chrome Debug GUI launcher (separate from system Chrome).
|
|
78
|
+
|
|
79
|
+
Linux: Creates desktop entry at ~/.local/share/applications/chrome-debug.desktop
|
|
80
|
+
Shows as "Chrome Debug" in application menu.
|
|
81
|
+
|
|
82
|
+
macOS: Creates app bundle at ~/Applications/Chrome Debug.app
|
|
83
|
+
Shows as "Chrome Debug" in Launchpad and Spotlight.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
force: Overwrite existing launcher (default: False)
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
Markdown-formatted result with success/error messages
|
|
90
|
+
"""
|
|
91
|
+
service = SetupService()
|
|
92
|
+
result = service.install_desktop_entry(force=force)
|
|
93
|
+
return _format_setup_result(result, "desktop")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _format_setup_result(result: dict, component: str) -> dict:
|
|
97
|
+
"""Format setup result as markdown."""
|
|
98
|
+
elements = []
|
|
99
|
+
|
|
100
|
+
# Main message as alert (using "message" key for consistency)
|
|
101
|
+
level = "success" if result["success"] else "error"
|
|
102
|
+
elements.append({"type": "alert", "message": result["message"], "level": level})
|
|
103
|
+
|
|
104
|
+
# Add details if present
|
|
105
|
+
if result.get("path"):
|
|
106
|
+
elements.append({"type": "text", "content": f"**Location:** `{result['path']}`"})
|
|
107
|
+
if result.get("details"):
|
|
108
|
+
elements.append({"type": "text", "content": f"**Details:** {result['details']}"})
|
|
109
|
+
|
|
110
|
+
# Component-specific next steps
|
|
111
|
+
if result["success"]:
|
|
112
|
+
if component == "filters":
|
|
113
|
+
elements.append({"type": "text", "content": "\n**Next steps:**"})
|
|
114
|
+
elements.append(
|
|
115
|
+
{
|
|
116
|
+
"type": "list",
|
|
117
|
+
"items": [
|
|
118
|
+
"Run `filters('load')` to load the filters",
|
|
119
|
+
"Run `filters()` to see loaded categories",
|
|
120
|
+
],
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
elif component == "extension":
|
|
124
|
+
elements.append({"type": "text", "content": "\n**To install in Chrome:**"})
|
|
125
|
+
elements.append(
|
|
126
|
+
{
|
|
127
|
+
"type": "list",
|
|
128
|
+
"items": [
|
|
129
|
+
"Open chrome://extensions/",
|
|
130
|
+
"Enable Developer mode",
|
|
131
|
+
"Click 'Load unpacked'",
|
|
132
|
+
f"Select {result['path']}",
|
|
133
|
+
],
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
elif component == "chrome":
|
|
137
|
+
if "Add to PATH" in result.get("details", ""):
|
|
138
|
+
elements.append({"type": "text", "content": "\n**Setup PATH:**"})
|
|
139
|
+
elements.append(
|
|
140
|
+
{
|
|
141
|
+
"type": "code_block",
|
|
142
|
+
"language": "bash",
|
|
143
|
+
"content": 'export PATH="$HOME/.local/bin/wrappers:$PATH"',
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
elements.append({"type": "text", "content": "Add to ~/.bashrc to make permanent"})
|
|
147
|
+
else:
|
|
148
|
+
elements.append({"type": "text", "content": "\n**Usage:**"})
|
|
149
|
+
elements.append(
|
|
150
|
+
{
|
|
151
|
+
"type": "list",
|
|
152
|
+
"items": [
|
|
153
|
+
"Run `chrome-debug` to start Chrome with debugging",
|
|
154
|
+
"Or use `run-chrome` command for direct launch",
|
|
155
|
+
],
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
elif component == "desktop":
|
|
159
|
+
# Platform-specific instructions are already in the service's details
|
|
160
|
+
pass
|
|
161
|
+
|
|
162
|
+
return {"elements": elements}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@app.command(
|
|
166
|
+
display="markdown",
|
|
167
|
+
typer={"name": "setup-cleanup", "help": "Clean up old WebTap installations"},
|
|
168
|
+
fastmcp={"enabled": False},
|
|
169
|
+
)
|
|
170
|
+
def setup_cleanup(state, dry_run: bool = True) -> dict:
|
|
171
|
+
"""Clean up old WebTap installations from previous versions.
|
|
172
|
+
|
|
173
|
+
Checks for and removes:
|
|
174
|
+
- Old extension location (~/.config/webtap/extension/)
|
|
175
|
+
- Old desktop entries created by webtap
|
|
176
|
+
- Unmounted bindfs directories
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
dry_run: Only show what would be cleaned (default: True)
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Markdown report of cleanup actions
|
|
183
|
+
"""
|
|
184
|
+
service = SetupService()
|
|
185
|
+
result = service.cleanup_old_installations(dry_run=dry_run)
|
|
186
|
+
|
|
187
|
+
elements = []
|
|
188
|
+
|
|
189
|
+
# Header
|
|
190
|
+
elements.append({"type": "heading", "level": 2, "content": "WebTap Cleanup Report"})
|
|
191
|
+
|
|
192
|
+
# Old installations found
|
|
193
|
+
if result.get("old_extension"):
|
|
194
|
+
elements.append({"type": "heading", "level": 3, "content": "Old Extension Location"})
|
|
195
|
+
elements.append({"type": "text", "content": f"Found: `{result['old_extension']['path']}`"})
|
|
196
|
+
elements.append({"type": "text", "content": f"Size: {result['old_extension']['size']}"})
|
|
197
|
+
if not dry_run and result["old_extension"].get("removed"):
|
|
198
|
+
elements.append({"type": "alert", "message": "✓ Removed old extension", "level": "success"})
|
|
199
|
+
elif dry_run:
|
|
200
|
+
elements.append({"type": "alert", "message": "Would remove (dry-run mode)", "level": "info"})
|
|
201
|
+
|
|
202
|
+
# Old Chrome wrapper
|
|
203
|
+
if result.get("old_wrapper"):
|
|
204
|
+
elements.append({"type": "heading", "level": 3, "content": "Old Chrome Wrapper"})
|
|
205
|
+
elements.append({"type": "text", "content": f"Found: `{result['old_wrapper']['path']}`"})
|
|
206
|
+
if not dry_run and result["old_wrapper"].get("removed"):
|
|
207
|
+
elements.append({"type": "alert", "message": "✓ Removed old wrapper", "level": "success"})
|
|
208
|
+
elif dry_run:
|
|
209
|
+
elements.append({"type": "alert", "message": "Would remove (dry-run mode)", "level": "info"})
|
|
210
|
+
|
|
211
|
+
# Old desktop entry
|
|
212
|
+
if result.get("old_desktop"):
|
|
213
|
+
elements.append({"type": "heading", "level": 3, "content": "Old Desktop Entry"})
|
|
214
|
+
elements.append({"type": "text", "content": f"Found: `{result['old_desktop']['path']}`"})
|
|
215
|
+
if not dry_run and result["old_desktop"].get("removed"):
|
|
216
|
+
elements.append({"type": "alert", "message": "✓ Removed old desktop entry", "level": "success"})
|
|
217
|
+
elif dry_run:
|
|
218
|
+
elements.append({"type": "alert", "message": "Would remove (dry-run mode)", "level": "info"})
|
|
219
|
+
|
|
220
|
+
# Check for bindfs mounts
|
|
221
|
+
if result.get("bindfs_mount"):
|
|
222
|
+
elements.append({"type": "heading", "level": 3, "content": "Bindfs Mount Detected"})
|
|
223
|
+
elements.append({"type": "text", "content": f"Mount: `{result['bindfs_mount']}`"})
|
|
224
|
+
elements.append(
|
|
225
|
+
{"type": "alert", "message": "To unmount: fusermount -u " + result["bindfs_mount"], "level": "warning"}
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
# Summary
|
|
229
|
+
elements.append({"type": "heading", "level": 3, "content": "Summary"})
|
|
230
|
+
if dry_run:
|
|
231
|
+
elements.append({"type": "text", "content": "**Dry-run mode** - no changes made"})
|
|
232
|
+
elements.append({"type": "text", "content": "To perform cleanup: `setup-cleanup --no-dry-run`"})
|
|
233
|
+
else:
|
|
234
|
+
elements.append({"type": "alert", "message": "Cleanup completed", "level": "success"})
|
|
235
|
+
|
|
236
|
+
# Next steps
|
|
237
|
+
elements.append({"type": "heading", "level": 3, "content": "Next Steps"})
|
|
238
|
+
elements.append(
|
|
239
|
+
{
|
|
240
|
+
"type": "list",
|
|
241
|
+
"items": [
|
|
242
|
+
"Run `setup-extension` to install extension in new location",
|
|
243
|
+
"Run `setup-chrome --bindfs` for bindfs mode or `setup-chrome` for standard mode",
|
|
244
|
+
"Run `setup-desktop` to create Chrome Debug launcher",
|
|
245
|
+
],
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
return {"elements": elements}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""Setup service for installing WebTap components (cross-platform).
|
|
2
|
+
|
|
3
|
+
PUBLIC API:
|
|
4
|
+
- SetupService: Main service class for all setup operations
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Dict, Any
|
|
8
|
+
|
|
9
|
+
from .filters import FilterSetupService
|
|
10
|
+
from .extension import ExtensionSetupService
|
|
11
|
+
from .chrome import ChromeSetupService
|
|
12
|
+
from .desktop import DesktopSetupService
|
|
13
|
+
from .platform import get_platform_info, ensure_directories
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SetupService:
|
|
17
|
+
"""Orchestrator service for installing WebTap components.
|
|
18
|
+
|
|
19
|
+
Delegates to specialized service classes for each component type.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
"""Initialize setup service with platform information."""
|
|
24
|
+
self.info = get_platform_info()
|
|
25
|
+
ensure_directories()
|
|
26
|
+
|
|
27
|
+
# Initialize component services
|
|
28
|
+
self.filters_service = FilterSetupService()
|
|
29
|
+
self.extension_service = ExtensionSetupService()
|
|
30
|
+
self.chrome_service = ChromeSetupService()
|
|
31
|
+
self.desktop_service = DesktopSetupService()
|
|
32
|
+
|
|
33
|
+
def install_filters(self, force: bool = False) -> Dict[str, Any]:
|
|
34
|
+
"""Install filter configuration.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
force: Overwrite existing file
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Dict with success, message, path, details
|
|
41
|
+
"""
|
|
42
|
+
return self.filters_service.install_filters(force=force)
|
|
43
|
+
|
|
44
|
+
def install_extension(self, force: bool = False) -> Dict[str, Any]:
|
|
45
|
+
"""Install Chrome extension files.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
force: Overwrite existing files
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Dict with success, message, path, details
|
|
52
|
+
"""
|
|
53
|
+
return self.extension_service.install_extension(force=force)
|
|
54
|
+
|
|
55
|
+
def install_chrome_wrapper(self, force: bool = False, bindfs: bool = False) -> Dict[str, Any]:
|
|
56
|
+
"""Install Chrome wrapper script.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
force: Overwrite existing script
|
|
60
|
+
bindfs: Use bindfs to mount real Chrome profile (Linux only)
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Dict with success, message, path, details
|
|
64
|
+
"""
|
|
65
|
+
return self.chrome_service.install_wrapper(force=force, bindfs=bindfs)
|
|
66
|
+
|
|
67
|
+
def install_desktop_entry(self, force: bool = False) -> Dict[str, Any]:
|
|
68
|
+
"""Install desktop entry or app bundle for GUI integration.
|
|
69
|
+
|
|
70
|
+
On Linux: Creates .desktop file
|
|
71
|
+
On macOS: Creates .app bundle
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
force: Overwrite existing entry
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
Dict with success, message, path, details
|
|
78
|
+
"""
|
|
79
|
+
return self.desktop_service.install_launcher(force=force)
|
|
80
|
+
|
|
81
|
+
def get_platform_info(self) -> Dict[str, Any]:
|
|
82
|
+
"""Get platform information for debugging.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
Platform information including paths and capabilities
|
|
86
|
+
"""
|
|
87
|
+
return self.info
|
|
88
|
+
|
|
89
|
+
def cleanup_old_installations(self, dry_run: bool = True) -> Dict[str, Any]:
|
|
90
|
+
"""Clean up old WebTap installations.
|
|
91
|
+
|
|
92
|
+
Checks locations that webtap previously wrote to:
|
|
93
|
+
- ~/.config/webtap/extension/ (old extension location)
|
|
94
|
+
- ~/.local/bin/wrappers/google-chrome-stable (old wrapper location)
|
|
95
|
+
- ~/.local/share/applications/google-chrome.desktop (old desktop entry)
|
|
96
|
+
- ~/.config/google-chrome-debug (bindfs mount)
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
dry_run: If True, only report what would be done
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Dict with cleanup results
|
|
103
|
+
"""
|
|
104
|
+
import shutil
|
|
105
|
+
import subprocess
|
|
106
|
+
from pathlib import Path
|
|
107
|
+
|
|
108
|
+
result = {}
|
|
109
|
+
|
|
110
|
+
# Check old extension location
|
|
111
|
+
old_extension_path = Path.home() / ".config" / "webtap" / "extension"
|
|
112
|
+
if old_extension_path.exists():
|
|
113
|
+
# Calculate size
|
|
114
|
+
size = sum(f.stat().st_size for f in old_extension_path.rglob("*") if f.is_file())
|
|
115
|
+
size_str = f"{size / 1024:.1f} KB" if size > 0 else "empty"
|
|
116
|
+
|
|
117
|
+
result["old_extension"] = {"path": str(old_extension_path), "size": size_str, "removed": False}
|
|
118
|
+
|
|
119
|
+
if not dry_run:
|
|
120
|
+
try:
|
|
121
|
+
shutil.rmtree(old_extension_path)
|
|
122
|
+
result["old_extension"]["removed"] = True
|
|
123
|
+
# Also try to remove parent if empty
|
|
124
|
+
parent = old_extension_path.parent
|
|
125
|
+
if parent.exists() and not any(parent.iterdir()):
|
|
126
|
+
parent.rmdir()
|
|
127
|
+
except Exception as e:
|
|
128
|
+
result["old_extension"]["error"] = str(e)
|
|
129
|
+
|
|
130
|
+
# Check old Chrome wrapper location
|
|
131
|
+
old_wrapper_path = Path.home() / ".local" / "bin" / "wrappers" / "google-chrome-stable"
|
|
132
|
+
if old_wrapper_path.exists():
|
|
133
|
+
result["old_wrapper"] = {"path": str(old_wrapper_path), "removed": False}
|
|
134
|
+
|
|
135
|
+
if not dry_run:
|
|
136
|
+
try:
|
|
137
|
+
old_wrapper_path.unlink()
|
|
138
|
+
result["old_wrapper"]["removed"] = True
|
|
139
|
+
# Try to remove wrappers dir if empty (but keep it if other wrappers exist)
|
|
140
|
+
wrappers_dir = old_wrapper_path.parent
|
|
141
|
+
if wrappers_dir.exists() and not any(wrappers_dir.iterdir()):
|
|
142
|
+
wrappers_dir.rmdir()
|
|
143
|
+
except Exception as e:
|
|
144
|
+
result["old_wrapper"]["error"] = str(e)
|
|
145
|
+
|
|
146
|
+
# Check old desktop entry
|
|
147
|
+
old_desktop_path = Path.home() / ".local" / "share" / "applications" / "google-chrome.desktop"
|
|
148
|
+
if old_desktop_path.exists():
|
|
149
|
+
# Check if it's our override (contains reference to wrapper)
|
|
150
|
+
try:
|
|
151
|
+
content = old_desktop_path.read_text()
|
|
152
|
+
if "wrappers/google-chrome-stable" in content or "webtap" in content.lower():
|
|
153
|
+
result["old_desktop"] = {"path": str(old_desktop_path), "removed": False}
|
|
154
|
+
|
|
155
|
+
if not dry_run:
|
|
156
|
+
try:
|
|
157
|
+
old_desktop_path.unlink()
|
|
158
|
+
result["old_desktop"]["removed"] = True
|
|
159
|
+
except Exception as e:
|
|
160
|
+
result["old_desktop"]["error"] = str(e)
|
|
161
|
+
except Exception:
|
|
162
|
+
pass # If we can't read it, skip it
|
|
163
|
+
|
|
164
|
+
# Check for bindfs mount
|
|
165
|
+
debug_dir = Path.home() / ".config" / "google-chrome-debug"
|
|
166
|
+
if debug_dir.exists():
|
|
167
|
+
try:
|
|
168
|
+
# Check if it's a mount point
|
|
169
|
+
output = subprocess.run(["mountpoint", "-q", str(debug_dir)], capture_output=True)
|
|
170
|
+
if output.returncode == 0:
|
|
171
|
+
result["bindfs_mount"] = str(debug_dir)
|
|
172
|
+
except (FileNotFoundError, OSError):
|
|
173
|
+
pass # mountpoint command might not exist
|
|
174
|
+
|
|
175
|
+
return result
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
__all__ = ["SetupService"]
|