tabwright 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.
- tabwright-0.1.0/.github/workflows/ci.yml +27 -0
- tabwright-0.1.0/.github/workflows/publish.yml +19 -0
- tabwright-0.1.0/.gitignore +6 -0
- tabwright-0.1.0/CHANGELOG.md +20 -0
- tabwright-0.1.0/CONTRIBUTING.md +60 -0
- tabwright-0.1.0/LICENSE +21 -0
- tabwright-0.1.0/PKG-INFO +275 -0
- tabwright-0.1.0/README.md +245 -0
- tabwright-0.1.0/docs/PLAN.md +99 -0
- tabwright-0.1.0/docs/img/gui.png +0 -0
- tabwright-0.1.0/pyproject.toml +50 -0
- tabwright-0.1.0/src/tabwright/__init__.py +3 -0
- tabwright-0.1.0/src/tabwright/adapters/__init__.py +20 -0
- tabwright-0.1.0/src/tabwright/adapters/chromium.py +133 -0
- tabwright-0.1.0/src/tabwright/adapters/firefox.py +319 -0
- tabwright-0.1.0/src/tabwright/adapters/snss.py +261 -0
- tabwright-0.1.0/src/tabwright/cli.py +461 -0
- tabwright-0.1.0/src/tabwright/extension/background.js +161 -0
- tabwright-0.1.0/src/tabwright/extension/manifest.json +25 -0
- tabwright-0.1.0/src/tabwright/gui.py +672 -0
- tabwright-0.1.0/src/tabwright/library.py +52 -0
- tabwright-0.1.0/src/tabwright/live.py +126 -0
- tabwright-0.1.0/src/tabwright/mcp_server.py +107 -0
- tabwright-0.1.0/src/tabwright/model.py +183 -0
- tabwright-0.1.0/src/tabwright/native_host.py +143 -0
- tabwright-0.1.0/src/tabwright/policy.py +36 -0
- tabwright-0.1.0/src/tabwright/tools.py +316 -0
- tabwright-0.1.0/tests/__init__.py +0 -0
- tabwright-0.1.0/tests/test_cli.py +31 -0
- tabwright-0.1.0/tests/test_firefox.py +86 -0
- tabwright-0.1.0/tests/test_gui.py +51 -0
- tabwright-0.1.0/tests/test_live.py +121 -0
- tabwright-0.1.0/tests/test_mcp.py +44 -0
- tabwright-0.1.0/tests/test_phase4.py +48 -0
- tabwright-0.1.0/tests/test_snss.py +84 -0
- tabwright-0.1.0/tests/test_tools.py +120 -0
- tabwright-0.1.0/uv.lock +914 -0
- tabwright-0.1.0/uv.toml +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python: ["3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python }}
|
|
19
|
+
- run: uv sync --extra gui --extra agent
|
|
20
|
+
- run: uv run ruff check src tests
|
|
21
|
+
- run: uv run ruff format --check src tests
|
|
22
|
+
- run: node --check src/tabwright/extension/background.js
|
|
23
|
+
# Qt offscreen needs the EGL/GL runtime libraries even without a display
|
|
24
|
+
- run: sudo apt-get update -q && sudo apt-get install -y -q libegl1 libgl1 libxkbcommon0 libdbus-1-3
|
|
25
|
+
- run: uv run pytest -q
|
|
26
|
+
env:
|
|
27
|
+
QT_QPA_PLATFORM: offscreen
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
pypi:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write # PyPI trusted publishing (OIDC); no token stored anywhere
|
|
14
|
+
contents: read
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: astral-sh/setup-uv@v5
|
|
18
|
+
- run: uv build
|
|
19
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-12-05)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- Browser-neutral model: session > windows > (tabs | groups > tabs), with window geometry,
|
|
8
|
+
group colour and collapse state, pinned and active tabs; JSON Schema via `tabwright schema`.
|
|
9
|
+
- Chromium family (Brave, Chrome, Chromium, Edge, Vivaldi): SNSS session read and write,
|
|
10
|
+
restore-on-start marking, process stop/start.
|
|
11
|
+
- Firefox family (Firefox, Tor Browser): sessionstore read and write with a pure-Python
|
|
12
|
+
mozlz4 codec, profiles.ini resolution over deb and snap roots.
|
|
13
|
+
- Tools: find-duplicates, stats, export, check-urls, dedupe, strip-tracking-params, sort,
|
|
14
|
+
group-by-domain; `move` with position; `color`; `drop` with rescue.
|
|
15
|
+
- Library of named sets at every scope and `compose` to build sessions from them.
|
|
16
|
+
- PySide6 desktop GUI with drag-and-drop, tool context menus, library pane and tooltips.
|
|
17
|
+
- Live bridge: companion MV3 extension plus native messaging host; `--live` on every
|
|
18
|
+
command, `push`, extension listing and enable/disable; verified on Brave and Firefox.
|
|
19
|
+
- Managed-policy output for durable extension state.
|
|
20
|
+
- MCP server (`tabwright mcp`) exposing the CLI contract to agents.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Issues and pull requests are welcome. Please keep the pieces you touch small and tested.
|
|
4
|
+
|
|
5
|
+
## Set up
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
git clone https://github.com/mostlyharmless-ai/tabwright && cd tabwright
|
|
9
|
+
uv sync --extra gui --extra agent
|
|
10
|
+
uv run pytest -q # add QT_QPA_PLATFORM=offscreen on a headless box
|
|
11
|
+
uv run ruff check src tests && uv run ruff format src tests
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Never test writes against a profile you care about. Launch a scratch profile instead:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
tabwright start -b brave --data-dir /tmp/tw-scratch -- --no-first-run https://example.com
|
|
18
|
+
tabwright start -b firefox --data-dir ~/snap/firefox/common/tw-scratch # snaps cannot see /tmp
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For live-bridge work, load `src/tabwright/extension` unpacked (Chromium) or as a temporary
|
|
22
|
+
add-on (Firefox) in that scratch browser. After editing `background.js`, reload the extension:
|
|
23
|
+
browsers cache the service worker.
|
|
24
|
+
|
|
25
|
+
## Where things live
|
|
26
|
+
|
|
27
|
+
| Path | What |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `src/tabwright/model.py` | the browser-neutral model and its JSON Schema |
|
|
30
|
+
| `src/tabwright/adapters/` | one module per browser family: read, write, find, stop, start |
|
|
31
|
+
| `src/tabwright/tools.py` | the tool registry; a new tool is one decorated function |
|
|
32
|
+
| `src/tabwright/cli.py` | argparse front end; tools become subcommands automatically |
|
|
33
|
+
| `src/tabwright/gui.py` | PySide6 desktop GUI |
|
|
34
|
+
| `src/tabwright/live.py`, `native_host.py`, `extension/` | the live bridge |
|
|
35
|
+
| `src/tabwright/mcp_server.py` | MCP server over the CLI contract |
|
|
36
|
+
| `docs/PLAN.md` | design, phases, what is verified and what is not |
|
|
37
|
+
|
|
38
|
+
## Adding a tool
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
@tool("my-tool", ("window", "group"), transform=True, options={"--limit": {"type": int, "default": 5}})
|
|
42
|
+
def my_tool(node, limit=5, **_):
|
|
43
|
+
...
|
|
44
|
+
return {"changed": n}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Reports are plain dicts. Transforms edit the node in place and return a report. The CLI,
|
|
48
|
+
the GUI context menu and the MCP `run` tool pick the new tool up without further wiring.
|
|
49
|
+
|
|
50
|
+
## Compatibility promises
|
|
51
|
+
|
|
52
|
+
`tabwright list --json` output and `tabwright schema` are consumed by scripts and agents.
|
|
53
|
+
A change to the model's JSON shape needs a schema version bump and a note in `docs/PLAN.md`
|
|
54
|
+
before it ships.
|
|
55
|
+
|
|
56
|
+
## Adding a browser
|
|
57
|
+
|
|
58
|
+
An adapter module exposes `read`, `read_profile`, `write_file`, `apply`, `pids`, `stop` and
|
|
59
|
+
`start`, and registers its browser names in `adapters/__init__.py`. Keep browser-specific
|
|
60
|
+
facts in each node's `extra` so they round-trip without the model learning about them.
|
tabwright-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MostlyHarmless-AI
|
|
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.
|
tabwright-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tabwright
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Browser session manager: windows, tab groups, tabs and extensions as a browser-neutral model
|
|
5
|
+
Project-URL: Homepage, https://github.com/mostlyharmless-ai/tabwright
|
|
6
|
+
Project-URL: Issues, https://github.com/mostlyharmless-ai/tabwright/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/mostlyharmless-ai/tabwright/blob/main/CHANGELOG.md
|
|
8
|
+
Author: MostlyHarmless-AI
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: brave,browser,chrome,firefox,mcp,pyside6,session,tab-groups,tabs
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.12
|
|
25
|
+
Provides-Extra: agent
|
|
26
|
+
Requires-Dist: mcp>=1.2; extra == 'agent'
|
|
27
|
+
Provides-Extra: gui
|
|
28
|
+
Requires-Dist: pyside6>=6.7; extra == 'gui'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# tabwright
|
|
32
|
+
|
|
33
|
+
[](https://github.com/mostlyharmless-ai/tabwright/actions/workflows/ci.yml)
|
|
34
|
+
[](LICENSE)
|
|
35
|
+

|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
**Your browser's windows, tab groups and tabs as a plain, editable model.**
|
|
39
|
+
Inspect them, fix them, save pieces as named sets, recompose, and write back:
|
|
40
|
+
from a CLI, a desktop GUI, or an agent over MCP. Works on the session files of a
|
|
41
|
+
stopped browser, or live inside a running one through a small companion extension.
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
## Why
|
|
46
|
+
|
|
47
|
+
A browser with hundreds of tabs in thirty groups is a working environment, and browsers
|
|
48
|
+
give you almost no tools to manage it: no way to reorder groups in bulk, dedupe, save a
|
|
49
|
+
group for later, or recover an exact layout after a crash scrambles it. tabwright treats
|
|
50
|
+
the tab strip as data. Every write path honours the order you give it.
|
|
51
|
+
|
|
52
|
+
- **Browsers**: Brave, Chrome, Chromium, Edge, Vivaldi (Chromium session files) and
|
|
53
|
+
Firefox, Tor Browser (sessionstore), with a browser-neutral model in between.
|
|
54
|
+
- **Offline**: read the newest session, edit, write it back; the browser restores it on
|
|
55
|
+
the next start. A forced stop leaves a hung browser's files untouched.
|
|
56
|
+
- **Live**: a companion extension snapshots and reconciles the running browser, and lists
|
|
57
|
+
or toggles its extensions.
|
|
58
|
+
- **Tools**: dedupe, find duplicates, check URLs, strip tracking parameters, sort, group by
|
|
59
|
+
domain, export; colour; positional move. One decorated function adds a tool to the CLI,
|
|
60
|
+
the GUI menu and the agent surface at once.
|
|
61
|
+
- **Library**: save any session, window, group or tab as a named set; compose new sessions
|
|
62
|
+
from sets.
|
|
63
|
+
- **Agents**: non-interactive CLI with stable JSON, `tabwright schema`, and `tabwright mcp`.
|
|
64
|
+
|
|
65
|
+
Linux today. The model and the live bridge are platform-neutral; profile discovery and
|
|
66
|
+
process control are not yet ported elsewhere.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
uv tool install git+https://github.com/mostlyharmless-ai/tabwright --with 'PySide6>=6.7' --with mcp
|
|
72
|
+
# or, in a checkout
|
|
73
|
+
uv sync --extra gui --extra agent && uv run tabwright --help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The core has no dependencies. `PySide6` is only for `tabwright gui`, `mcp` only for
|
|
77
|
+
`tabwright mcp`.
|
|
78
|
+
|
|
79
|
+
## Quick start
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
tabwright list -b brave --tabs # tree of the profile's newest session
|
|
83
|
+
tabwright list --live --tabs # the running browser, via the companion
|
|
84
|
+
tabwright dedupe --live --dry-run # what would change; nothing written
|
|
85
|
+
tabwright dedupe --live --apply # do it, live
|
|
86
|
+
tabwright save work w0/g2 # save a group as a named set
|
|
87
|
+
tabwright compose work notes research --apply # new session from three named sets
|
|
88
|
+
tabwright gui # the desktop GUI
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Recovering from a hang:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
tabwright stop -b brave --force # SIGKILL: session files stay as on disk
|
|
95
|
+
tabwright drop w3 --rescue-to w0 --apply # remove a window, keep its unique tabs
|
|
96
|
+
tabwright start -b brave # browser offers to restore the edited session
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Node paths: `w0` window, `w0/g2` item 2 of window 0 (a group), `w0/g2/t1` tab in a
|
|
100
|
+
group, `w0/t5` fifth tab of the window counting through groups.
|
|
101
|
+
|
|
102
|
+
Every command that produces a session accepts `--json`, `--out FILE` (the browser's
|
|
103
|
+
native format), `--apply` (into the stopped browser's profile), `--live --apply` (into
|
|
104
|
+
the running browser) or `--dry-run`.
|
|
105
|
+
|
|
106
|
+
## Tools
|
|
107
|
+
|
|
108
|
+
Each tool is a subcommand that takes an optional scope path (default: the whole
|
|
109
|
+
session) and refuses scopes it does not apply to. `tabwright tools` lists them.
|
|
110
|
+
|
|
111
|
+
| Tool | Kind | Scopes |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `find-duplicates` | report | session, window, group |
|
|
114
|
+
| `stats` | report | session, window, group |
|
|
115
|
+
| `export --format md\|urls` | report | session, window, group, tab |
|
|
116
|
+
| `check-urls --timeout --workers` | report | session, window, group, tab |
|
|
117
|
+
| `dedupe` | transform | session, window, group |
|
|
118
|
+
| `strip-tracking-params` | transform | session, window, group, tab |
|
|
119
|
+
| `sort --by domain\|title\|url` | transform | session, window, group |
|
|
120
|
+
| `group-by-domain --min N` | transform | session, window |
|
|
121
|
+
| `move SRC DST` | transform | tab or group into window or group |
|
|
122
|
+
| `drop PATH [--rescue-to W]` | transform | window, group, tab |
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
tabwright find-duplicates w2 --json
|
|
126
|
+
tabwright dedupe w2 --dry-run # shows what would change, writes nothing
|
|
127
|
+
tabwright check-urls w0/g3 # dead and redirected URLs in one group
|
|
128
|
+
tabwright export w1 > vercel-tabs.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Reports print as JSON with `--json`; transforms print their report to stderr and
|
|
132
|
+
the resulting session through the chosen sink. Adding a tool is one decorated
|
|
133
|
+
function in `tools.py`; the CLI, scope checks and help text follow from the registry.
|
|
134
|
+
|
|
135
|
+
Library: `save NAME [PATH]`, `library`, `show NAME`, `rename OLD NEW`, `delete NAME`,
|
|
136
|
+
`compose NAME... [--separate]`.
|
|
137
|
+
|
|
138
|
+
## GUI
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
uv sync --extra gui && uv run tabwright gui # or: pip install 'tabwright[gui]'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
A tree of windows, groups and tabs over the same model. Drag and drop moves tabs
|
|
145
|
+
between windows and groups and groups between windows; illegal drops are refused.
|
|
146
|
+
Right-click shows the tools that apply to the selected node kind, plus rename,
|
|
147
|
+
group, ungroup, drop and new window. The top row selects browser and profile, shows
|
|
148
|
+
whether it is running, and offers stop, forced stop, start, and apply (enabled only
|
|
149
|
+
while the browser is stopped). The library pane saves the selection as a named set
|
|
150
|
+
and loads sets into the selection. Reports appear in the pane below the tree.
|
|
151
|
+
|
|
152
|
+
## Live: the companion extension
|
|
153
|
+
|
|
154
|
+
Every source flag set accepts `--live`: the session is read from the running browser
|
|
155
|
+
instead of its session file, and `--apply` writes back into the running browser.
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
tabwright live install -b brave # host manifest + wrapper; prints the extension dir
|
|
159
|
+
tabwright live install -b firefox # Firefox: then about:debugging > Load Temporary Add-on (unsigned)
|
|
160
|
+
# load that dir unpacked (brave://extensions, Developer mode) or pass --load-extension=DIR
|
|
161
|
+
tabwright live status -b brave
|
|
162
|
+
tabwright list --live --tabs
|
|
163
|
+
tabwright dedupe --live --apply # any transform, applied to the running browser
|
|
164
|
+
tabwright list --live --json > s.json # edit, then:
|
|
165
|
+
tabwright push -f s.json --live # reconcile the browser to the file
|
|
166
|
+
tabwright live extensions
|
|
167
|
+
tabwright live extension <id> --disable
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The extension (`src/tabwright/extension`, MV3, permissions `tabs tabGroups management
|
|
171
|
+
nativeMessaging`) connects to the native messaging host `tabwright.native_host`, which
|
|
172
|
+
the browser launches. The host listens on `$XDG_RUNTIME_DIR/tabwright/<browser>.sock`
|
|
173
|
+
and relays one JSON request per connection. Reconcile rules on apply: tabs, groups and
|
|
174
|
+
windows carrying ids in `extra` are moved and regrouped; nodes without ids are created;
|
|
175
|
+
live tabs absent from the session are closed. In the GUI, "Load (bridge)" and "Apply
|
|
176
|
+
(bridge)" use the same path, and the running indicator shows "+ bridge" when the socket
|
|
177
|
+
is up.
|
|
178
|
+
|
|
179
|
+
Chromium reads host manifests from the browser's default user data dir even when it
|
|
180
|
+
runs on `--user-data-dir`; the host finds the actual data dir from its parent process,
|
|
181
|
+
so one `live install` per browser covers every profile and data dir.
|
|
182
|
+
|
|
183
|
+
## Agents
|
|
184
|
+
|
|
185
|
+
`tabwright schema` prints the model's JSON Schema and the command contract. Every command
|
|
186
|
+
is non-interactive: stdout is data, stderr is commentary, exit 0 ok, 1 refused or failed
|
|
187
|
+
with the reason on stderr, 2 usage. With the `agent` extra, `tabwright mcp` serves the
|
|
188
|
+
same contract over the Model Context Protocol on stdio: tools `run` (any CLI argument
|
|
189
|
+
list, returns code/stdout/stderr), `snapshot` (model JSON, live or from file) and `push`
|
|
190
|
+
(model JSON into the running or stopped browser), plus the `tabwright://schema` resource.
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{"mcpServers": {"tabwright": {"command": "tabwright", "args": ["mcp"]}}}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
uv tool install --editable . --with mcp # or: pip install 'tabwright[agent]'
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Geometry, colour, order
|
|
201
|
+
|
|
202
|
+
Every window carries `geometry` (`x`, `y`, `width`, `height`, `state`), read from and
|
|
203
|
+
written to Chromium session files, Firefox session stores and the live bridge, and kept in
|
|
204
|
+
library sets. Wayland compositors do not let applications place their own windows, so
|
|
205
|
+
there `x`/`y` are stored but ignored and the live snapshot reports them as 0; size and
|
|
206
|
+
state still apply, and under X11 or XWayland placement across screens works as stored.
|
|
207
|
+
|
|
208
|
+
Browsers colour groups, not tabs. `tabwright color PATH COLOR` colours a group, or wraps a
|
|
209
|
+
bare tab in a one-tab untitled group, which shows as a coloured chip and is remembered like
|
|
210
|
+
any group. In the GUI: right-click, Colour….
|
|
211
|
+
|
|
212
|
+
Order is the model. Every list is the tab-strip order and every write path honours it, so
|
|
213
|
+
an agent can reorder by editing the JSON and pushing it back. `move SRC DST` appends by
|
|
214
|
+
default; `--index N` or `--before PATH` places the node. `tabwright schema` prints the
|
|
215
|
+
model's JSON Schema and the command contract (sources, sinks, tools, exit codes).
|
|
216
|
+
|
|
217
|
+
## Firefox and Tor Browser
|
|
218
|
+
|
|
219
|
+
`-b firefox` reads the profile's session store (`sessionstore-backups/recovery.jsonlz4`
|
|
220
|
+
while running or after a crash, else `sessionstore.jsonlz4`). `--profile` is a name from
|
|
221
|
+
`profiles.ini` ("Default" picks the default-marked one); `--data-dir` is an explicit
|
|
222
|
+
profile directory. Both the deb and the snap profile roots are searched. Tab groups
|
|
223
|
+
(Firefox 138+) map onto the model with Firefox's `gray` spelled `grey`. The mozlz4 codec
|
|
224
|
+
is pure Python; files written by tabwright are stored as LZ4 literals, so they are a
|
|
225
|
+
little larger than Firefox's own.
|
|
226
|
+
|
|
227
|
+
Apply writes both session files and leaves `sessionCheckpoints.json` in the
|
|
228
|
+
unfinished-shutdown shape, so Firefox restores the session on launch whatever its
|
|
229
|
+
startup-page setting. `-b tor` resolves the Tor Browser Launcher profile; Tor keeps no
|
|
230
|
+
session on disk, so only the live path can read it.
|
|
231
|
+
|
|
232
|
+
## Extension policy
|
|
233
|
+
|
|
234
|
+
Durable extension state in both families comes from managed policy files, which live in
|
|
235
|
+
root-owned paths. tabwright prints the file and the path; you install it:
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
tabwright policy -b brave --block <id> --force <id> > tabwright.json
|
|
239
|
+
sudo install -D -m 644 tabwright.json /etc/brave/policies/managed/tabwright.json
|
|
240
|
+
tabwright policy -b firefox --force uBlock0@raymondhill.net
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## How the write path works
|
|
244
|
+
|
|
245
|
+
Chromium offers no CLI or DevTools route to tab groups, so tabwright edits the
|
|
246
|
+
`Session_*` SNSS file with the browser stopped, then marks the profile as crashed
|
|
247
|
+
so the browser offers to restore on next launch. A forced stop leaves the files
|
|
248
|
+
exactly as on disk; a graceful stop lets the browser rewrite them first.
|
|
249
|
+
|
|
250
|
+
## Model
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{"kind": "session", "browser": "brave", "windows": [
|
|
254
|
+
{"kind": "window", "items": [
|
|
255
|
+
{"kind": "tab", "url": "...", "title": "...", "pinned": false, "active": true, "extra": {}},
|
|
256
|
+
{"kind": "group", "title": "work", "color": "blue", "collapsed": true, "tabs": [...], "extra": {}}
|
|
257
|
+
], "extra": {}}
|
|
258
|
+
], "extra": {}}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`extra` carries browser-specific identifiers; the model ignores it.
|
|
262
|
+
|
|
263
|
+
## Status and roadmap
|
|
264
|
+
|
|
265
|
+
Everything above is implemented and exercised against real Brave and Firefox profiles;
|
|
266
|
+
`docs/PLAN.md` records the design, what has been verified and what has not. Not yet:
|
|
267
|
+
macOS and Windows profile paths, a signed Firefox build of the companion, Safari.
|
|
268
|
+
|
|
269
|
+
## Contributing
|
|
270
|
+
|
|
271
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Changes are listed in [CHANGELOG.md](CHANGELOG.md).
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
MIT.
|