ai-browser-bridge 0.1.0
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.
- package/LICENSE +21 -0
- package/README.es.md +130 -0
- package/README.he.md +152 -0
- package/README.md +250 -0
- package/README.zh.md +130 -0
- package/dist/bridge.d.ts +1 -0
- package/dist/bridge.js +11085 -0
- package/dist/bridge.js.map +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 YosefHayim
|
|
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.
|
package/README.es.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/hero.png" alt="chatgpt-local-bridge — controla una sesión de ChatGPT en el navegador desde tu terminal mediante un puente MCP aislado" width="640" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# chatgpt-local-bridge
|
|
6
|
+
|
|
7
|
+
[English](README.md) · [עברית](README.he.md) · **Español** · [中文](README.zh.md)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
> Controla una conversación real de ChatGPT en el navegador desde tu terminal y dale un conjunto reducido y aislado (sandbox) de herramientas locales del repositorio vía MCP — sin entregarle nunca una shell.
|
|
18
|
+
|
|
19
|
+
## Por qué existe
|
|
20
|
+
|
|
21
|
+
ChatGPT rinde mejor en el navegador: el estado real de la cuenta, el selector de modelos, la edición de mensajes, la regeneración y el historial de conversación se mantienen intactos. Programar rinde mejor en la terminal, donde archivos, pruebas, diffs y parches se inspeccionan y modifican directamente.
|
|
22
|
+
|
|
23
|
+
`chatgpt-local-bridge` conecta esas dos superficies. Un prompt en la terminal controla tu sesión existente de ChatGPT en el navegador, y ChatGPT puede acceder al repositorio actual mediante un pequeño conjunto de **herramientas MCP validadas** — `grep`, `read`, `apply_patch`, `run_tests`, `git_diff` — en lugar de acceso directo a la shell. Tú permaneces en un único flujo de terminal; ChatGPT conserva su interfaz real.
|
|
24
|
+
|
|
25
|
+
## Características
|
|
26
|
+
|
|
27
|
+
- **ChatGPT desde la terminal** — envía prompts y recibe respuestas sin salir de la shell; la conversación real del navegador es la fuente de verdad.
|
|
28
|
+
- **Herramientas locales en sandbox vía MCP** — cada operación de archivo se valida contra la raíz del repositorio seleccionado; sin shell arbitraria, solo comandos de prueba en lista blanca.
|
|
29
|
+
- **Acciones del navegador como comandos** — `/resume`, `/new`, `/model`, `/rewind`, `/stop`, `/context`, `/diff`, `/compact` y más.
|
|
30
|
+
- **Sesiones y transcripciones locales por repositorio** — cada ejecución se registra en `<repo>/.bridge/` y se exporta como Markdown, JSON o JSONL.
|
|
31
|
+
- **Controles de seguridad** — modos de permiso (`read-only` / `ask` / `auto`) y checkpoints automáticos de archivos alrededor de cada parche.
|
|
32
|
+
- **Convenciones del proyecto** — comandos personalizados además de `AGENTS.md` / `CLAUDE.md` se envían a ChatGPT en las ejecuciones de `/task`.
|
|
33
|
+
- **Un editor real** — historial de prompts, búsqueda inversa, cola de prompts y autocompletado de menciones `@file`.
|
|
34
|
+
|
|
35
|
+
## Arquitectura
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
terminal (you)
|
|
39
|
+
│
|
|
40
|
+
│ Ink / React CLI
|
|
41
|
+
▼
|
|
42
|
+
orchestrator ──────────────┬───────────────────────────────┐
|
|
43
|
+
│ browser automation │ MCP server │
|
|
44
|
+
▼ (Playwright + CDP) │ (MCP SDK) ▼
|
|
45
|
+
ChatGPT browser UI │ local repo tools
|
|
46
|
+
▲ │ (grep/read/patch/test/diff)
|
|
47
|
+
│ ▼ │
|
|
48
|
+
└───── Cloudflare Tunnel (cloudflared) ◄────────────────┘
|
|
49
|
+
public https://…trycloudflare.com/mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Cuatro capas, cada una con un solo trabajo:
|
|
53
|
+
|
|
54
|
+
| Capa | Tecnología | Responsabilidad |
|
|
55
|
+
|------|------------|-----------------|
|
|
56
|
+
| **CLI** | Ink / React | Interfaz de terminal: panel de mensajes, barra de estado, menciones `@file`, comandos `/`. |
|
|
57
|
+
| **Navegador** | Playwright + Chrome DevTools Protocol | Controla la pestaña real de ChatGPT y captura respuestas. Los selectores están aislados en `src/browser/chatgpt-page.ts` para que los cambios de UI sean fáciles de arreglar. |
|
|
58
|
+
| **Servidor MCP** | MCP SDK + Zod | Expone las herramientas locales del repositorio a ChatGPT como handlers validados por esquema y en sandbox. |
|
|
59
|
+
| **Túnel** | Cloudflare Tunnel (`cloudflared`) | Da al servidor MCP local una URL HTTPS pública temporal que el conector de ChatGPT puede alcanzar — sin despliegue. |
|
|
60
|
+
|
|
61
|
+
**¿Por qué un túnel?** El conector MCP de ChatGPT llama a las herramientas por HTTPS, pero el servidor de herramientas se ejecuta en tu máquina. En lugar de desplegar nada, el bridge levanta un túnel efímero de Cloudflare (`*.trycloudflare.com`) frente al puerto local y sincroniza esa URL `…/mcp` con la app de ChatGPT al iniciar. (ngrok resolvería el mismo problema de alcance; se usa `cloudflared` de Cloudflare porque sus túneles rápidos no requieren cuenta ni token.)
|
|
62
|
+
|
|
63
|
+
## Inicio rápido
|
|
64
|
+
|
|
65
|
+
**Requisitos previos**
|
|
66
|
+
|
|
67
|
+
- **macOS** — Chrome se inicia desde `/Applications/Google Chrome.app`, y los ayudantes de portapapeles/procesos usan `pbcopy`/`lsof`.
|
|
68
|
+
- **Node.js ≥ 20** y **pnpm** (el repo fija `pnpm@10.14.0`).
|
|
69
|
+
- **Google Chrome** — el bridge controla un perfil real de Chrome.
|
|
70
|
+
- **`cloudflared`** *(opcional)* — solo necesario para que ChatGPT llame a herramientas locales. Sin él la TUI igual funciona. Instala con `brew install cloudflared`.
|
|
71
|
+
|
|
72
|
+
**Instalar y construir**
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/YosefHayim/chatgpt-local-bridge.git
|
|
76
|
+
cd chatgpt-local-bridge
|
|
77
|
+
pnpm install
|
|
78
|
+
pnpm build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Inicia sesión una vez y luego ejecuta**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Abre el perfil aislado de Chrome del bridge e inicia sesión en ChatGPT (persiste entre ejecuciones)
|
|
85
|
+
node dist/bridge.js login
|
|
86
|
+
|
|
87
|
+
# Lanza la interfaz de terminal sobre el repositorio donde ChatGPT trabajará
|
|
88
|
+
node dist/bridge.js --repo /path/to/your/project
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
¿Prefieres un comando `bridge` global? Ejecuta `pnpm link --global` tras construir, y usa `bridge`, `bridge login`, `bridge ask "…"`, etc.
|
|
92
|
+
|
|
93
|
+
## Dónde se guarda el estado
|
|
94
|
+
|
|
95
|
+
Todo el estado del bridge para un proyecto se escribe **dentro de ese proyecto**, bajo `<repo>/.bridge/`. En el primer uso, el bridge escribe `.bridge/.gitignore` con un único `*`. Eso hace que git ignore **todo** lo que hay en el directorio — incluidas las transcripciones y las cookies de inicio de sesión — de modo que nada pueda llegar a un commit, aunque viva dentro del repositorio. Tanto `git add -A` como `git add .bridge/` lo omiten; solo un `git add -f` explícito podría forzarlo. El archivo se reafirma en cada ejecución, así que borrarlo o manipularlo se cura automáticamente.
|
|
96
|
+
|
|
97
|
+
> La configuración escrita por el usuario y destinada a aplicarse a **todos** los repositorios sigue en tu directorio home: comandos personalizados en `~/.chatgpt-local-bridge/commands/*.md` y hooks de usuario en `~/.chatgpt-local-bridge/hooks.json`.
|
|
98
|
+
|
|
99
|
+
## Permisos y checkpoints
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
/permissions read-only # grep_code, read_file, git_diff
|
|
103
|
+
/permissions auto # también las herramientas de escritura/prueba acotadas
|
|
104
|
+
/permissions ask # bloquea herramientas de escritura/prueba/proceso (confirmación interactiva pendiente)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`apply_patch` toma un snapshot de cada ruta tocada antes y después del cambio. Recupera con `/checkpoints`, `/restore <id>` o `/rewind --files <id>`.
|
|
108
|
+
|
|
109
|
+
## Pruebas
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pnpm test # vitest run
|
|
113
|
+
pnpm typecheck # tsc --noEmit
|
|
114
|
+
pnpm verify:push # typecheck + test + build (ejecutar antes de push)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
La cobertura se centra en las rutas sensibles a la seguridad — validación de sandbox, resolución de rutas locales del repositorio, la auto-exclusión de `.bridge/`, los almacenes de sesiones/checkpoints, permisos y conteo de contexto.
|
|
118
|
+
|
|
119
|
+
## Limitaciones
|
|
120
|
+
|
|
121
|
+
- **Solo macOS** por ahora (ruta de Chrome fija y ayudantes `pbcopy`/`lsof`).
|
|
122
|
+
- Los selectores del navegador de ChatGPT pueden romperse cuando cambia la UI web; los arreglos están localizados en la capa del navegador.
|
|
123
|
+
- El uso de contexto es una **estimación** — el navegador no expone el conteo exacto de tokens del servidor.
|
|
124
|
+
- El túnel de Cloudflare requiere `cloudflared` instalado.
|
|
125
|
+
- Local-first por diseño; no es un servicio multiusuario alojado.
|
|
126
|
+
- La ejecución de comandos de hooks se analiza y reporta pero aún no se ejecuta.
|
|
127
|
+
|
|
128
|
+
## Licencia
|
|
129
|
+
|
|
130
|
+
[MIT](LICENSE) © YosefHayim
|
package/README.he.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/hero.png" alt="chatgpt-local-bridge — drive a ChatGPT browser session from your terminal over a sandboxed MCP bridge" width="640" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# chatgpt-local-bridge
|
|
6
|
+
|
|
7
|
+
[English](README.md) · **עברית** · [Español](README.es.md) · [中文](README.zh.md)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
<div dir="rtl">
|
|
16
|
+
|
|
17
|
+
> הפעילו שיחת ChatGPT אמיתית מהדפדפן ישירות מהטרמינל, ותנו לה גישה מצומצמת ומבוקרת (sandbox) לכלי הריפו המקומי דרך MCP — בלי למסור לה אף פעם גישת shell.
|
|
18
|
+
|
|
19
|
+
## למה זה קיים
|
|
20
|
+
|
|
21
|
+
ChatGPT נמצא בשיאו בדפדפן — מצב החשבון האמיתי, בורר המודלים, עריכת הודעות, רגנרציה והיסטוריית השיחה נשמרים במלואם. פיתוח קוד נמצא בשיאו בטרמינל, שם בודקים ומשנים קבצים, טסטים, diffs ו-patches ישירות.
|
|
22
|
+
|
|
23
|
+
`chatgpt-local-bridge` מחבר בין שני המשטחים האלה. שורת פקודה בטרמינל מפעילה את שיחת ה-ChatGPT הקיימת שלכם בדפדפן, ו-ChatGPT יכול לגשת לריפו הנוכחי דרך מספר מצומצם של **כלי MCP מאומתים** — `grep`, `read`, `apply_patch`, `run_tests`, `git_diff` — במקום גישת shell חופשית. אתם נשארים בתהליך עבודה אחד בטרמינל; ל-ChatGPT נשאר ה-UI האמיתי שלו.
|
|
24
|
+
|
|
25
|
+
## יכולות
|
|
26
|
+
|
|
27
|
+
- **הפעלת ChatGPT מהטרמינל** — שולחים פרומפטים ומקבלים תשובות בלי לעזוב את ה-shell; שיחת הדפדפן האמיתית היא מקור האמת.
|
|
28
|
+
- **כלים מקומיים ב-sandbox דרך MCP** — כל פעולת קובץ מאומתת מול שורש הריפו הנבחר; אין shell חופשי, רק פקודות טסט מאושרות מראש.
|
|
29
|
+
- **פעולות דפדפן כפקודות** — `/resume`, `/new`, `/model`, `/rewind`, `/stop`, `/context`, `/diff`, `/compact` ועוד.
|
|
30
|
+
- **סשנים ותמלולים מקומיים לריפו** — כל הרצה נשמרת תחת `<repo>/.bridge/` וניתנת לייצוא כ-Markdown, JSON או JSONL.
|
|
31
|
+
- **בקרות בטיחות** — מצבי הרשאה (`read-only` / `ask` / `auto`) ו-checkpoints אוטומטיים של קבצים סביב כל patch.
|
|
32
|
+
- **מוסכמות פרויקט** — פקודות מותאמות אישית וגם `AGENTS.md` / `CLAUDE.md` מוזנים ל-ChatGPT בהרצות `/task`.
|
|
33
|
+
- **קומפוזר אמיתי** — היסטוריית פרומפטים, חיפוש לאחור, תור פרומפטים, והשלמה אוטומטית לאזכורי `@file`.
|
|
34
|
+
|
|
35
|
+
## ארכיטקטורה
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
terminal (you)
|
|
41
|
+
│
|
|
42
|
+
│ Ink / React CLI
|
|
43
|
+
▼
|
|
44
|
+
orchestrator ──────────────┬───────────────────────────────┐
|
|
45
|
+
│ browser automation │ MCP server │
|
|
46
|
+
▼ (Playwright + CDP) │ (MCP SDK) ▼
|
|
47
|
+
ChatGPT browser UI │ local repo tools
|
|
48
|
+
▲ │ (grep/read/patch/test/diff)
|
|
49
|
+
│ ▼ │
|
|
50
|
+
└───── Cloudflare Tunnel (cloudflared) ◄────────────────┘
|
|
51
|
+
public https://…trycloudflare.com/mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<div dir="rtl">
|
|
55
|
+
|
|
56
|
+
ארבע שכבות, לכל אחת תפקיד אחד:
|
|
57
|
+
|
|
58
|
+
| שכבה | טכנולוגיה | אחריות |
|
|
59
|
+
|------|-----------|--------|
|
|
60
|
+
| **CLI** | Ink / React | ממשק טרמינל: חלונית הודעות, שורת סטטוס, אזכורי `@file`, פקודות `/`. |
|
|
61
|
+
| **דפדפן** | Playwright + Chrome DevTools Protocol | מפעיל את לשונית ה-ChatGPT האמיתית ולוכד תשובות. הסלקטורים מבודדים ב-`src/browser/chatgpt-page.ts` כך ששינויי UI קלים לתיקון. |
|
|
62
|
+
| **שרת MCP** | MCP SDK + Zod | חושף את כלי הריפו המקומיים ל-ChatGPT כ-handlers מאומתי-סכמה ומוגני-sandbox. |
|
|
63
|
+
| **מנהרה** | Cloudflare Tunnel (`cloudflared`) | מעניק לשרת ה-MCP המקומי כתובת HTTPS ציבורית זמנית שה-connector של ChatGPT יכול להגיע אליה — ללא פריסה. |
|
|
64
|
+
|
|
65
|
+
**למה בכלל מנהרה?** ה-connector של ChatGPT קורא לכלים דרך HTTPS, אבל שרת הכלים רץ על המחשב שלכם. במקום לפרוס משהו, ה-bridge מקים מנהרת Cloudflare זמנית (`*.trycloudflare.com`) מול הפורט המקומי ומסנכרן את כתובת ה-`…/mcp` הזו אל אפליקציית ChatGPT בעת ההפעלה. (ngrok היה פותר את אותה בעיית נגישות; נבחר `cloudflared` של Cloudflare מכיוון שמנהרות ה-quick שלו אינן דורשות חשבון או טוקן.)
|
|
66
|
+
|
|
67
|
+
## התחלה מהירה
|
|
68
|
+
|
|
69
|
+
**דרישות מקדימות**
|
|
70
|
+
|
|
71
|
+
- **macOS** — Chrome מופעל מ-`/Applications/Google Chrome.app`, ועוזרי הלוח/תהליכים משתמשים ב-`pbcopy`/`lsof`.
|
|
72
|
+
- **Node.js ≥ 20** ו-**pnpm** (הריפו מקבע `pnpm@10.14.0`).
|
|
73
|
+
- **Google Chrome** — ה-bridge מפעיל פרופיל Chrome אמיתי.
|
|
74
|
+
- **`cloudflared`** *(אופציונלי)* — נדרש רק כדי ש-ChatGPT יקרא לכלים מקומיים. בלעדיו ה-TUI עדיין רץ. התקנה: `brew install cloudflared`.
|
|
75
|
+
|
|
76
|
+
**התקנה ובנייה**
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone https://github.com/YosefHayim/chatgpt-local-bridge.git
|
|
82
|
+
cd chatgpt-local-bridge
|
|
83
|
+
pnpm install
|
|
84
|
+
pnpm build
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
<div dir="rtl">
|
|
88
|
+
|
|
89
|
+
**התחברו פעם אחת, ואז הריצו**
|
|
90
|
+
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# פתיחת פרופיל ה-Chrome המבודד של ה-bridge והתחברות ל-ChatGPT (נשמר בין הרצות)
|
|
95
|
+
node dist/bridge.js login
|
|
96
|
+
|
|
97
|
+
# הפעלת ממשק הטרמינל מול הריפו שבו ChatGPT יעבוד
|
|
98
|
+
node dist/bridge.js --repo /path/to/your/project
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
<div dir="rtl">
|
|
102
|
+
|
|
103
|
+
מעדיפים פקודת `bridge` גלובלית? הריצו `pnpm link --global` אחרי הבנייה, ואז השתמשו ב-`bridge`, `bridge login`, `bridge ask "…"` וכו'.
|
|
104
|
+
|
|
105
|
+
## איפה נשמר המצב (state)
|
|
106
|
+
|
|
107
|
+
כל מצב ה-bridge של פרויקט נכתב **בתוך אותו פרויקט**, תחת `<repo>/.bridge/`. בשימוש הראשון נכתב `.bridge/.gitignore` המכיל `*` בודד. זה גורם ל-git להתעלם מ**כל** מה שבתיקייה — כולל התמלולים ועוגיות ההתחברות — כך ששום דבר לא יכול להיכנס ל-commit, למרות שהוא נמצא בתוך הריפו. גם `git add -A` וגם `git add .bridge/` מדלגים עליו; רק `git add -f` מפורש יכול לעקוף. הקובץ נכתב מחדש בכל הרצה, כך שמחיקה או שינוי שלו מתרפאים אוטומטית.
|
|
108
|
+
|
|
109
|
+
> תצורה שנכתבת על ידי המשתמש ומיועדת לחול על **כל** הריפואים נשמרת עדיין בתיקיית הבית: פקודות מותאמות ב-`~/.chatgpt-local-bridge/commands/*.md` ו-hooks ברמת המשתמש ב-`~/.chatgpt-local-bridge/hooks.json`.
|
|
110
|
+
|
|
111
|
+
## הרשאות ו-checkpoints
|
|
112
|
+
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
/permissions read-only # grep_code, read_file, git_diff
|
|
117
|
+
/permissions auto # גם כלי הכתיבה/טסט המצומצמים
|
|
118
|
+
/permissions ask # חוסם כלי כתיבה/טסט/תהליך (אישור אינטראקטיבי בהמשך)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
<div dir="rtl">
|
|
122
|
+
|
|
123
|
+
`apply_patch` שומר snapshot של כל נתיב שנגעו בו לפני ואחרי השינוי. שחזור עם `/checkpoints`, `/restore <id>` או `/rewind --files <id>`.
|
|
124
|
+
|
|
125
|
+
## בדיקות
|
|
126
|
+
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pnpm test # vitest run
|
|
131
|
+
pnpm typecheck # tsc --noEmit
|
|
132
|
+
pnpm verify:push # typecheck + test + build (להריץ לפני push)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
<div dir="rtl">
|
|
136
|
+
|
|
137
|
+
הכיסוי מתמקד בנתיבים רגישי-בטיחות — אימות sandbox, רזולוציית נתיבים מקומיים לריפו, מנגנון ההתעלמות העצמית של `.bridge/`, מאגרי הסשנים/checkpoints, הרשאות וספירת הקשר.
|
|
138
|
+
|
|
139
|
+
## מגבלות
|
|
140
|
+
|
|
141
|
+
- **macOS בלבד** כיום (נתיב Chrome קשיח ועוזרי `pbcopy`/`lsof`).
|
|
142
|
+
- סלקטורים של ChatGPT עלולים להישבר כשממשק הווב משתנה; התיקונים ממוקדים בשכבת הדפדפן.
|
|
143
|
+
- ניצול ההקשר הוא **הערכה** — הדפדפן אינו חושף ספירת טוקנים מדויקת מצד השרת.
|
|
144
|
+
- מנהרת Cloudflare דורשת `cloudflared` מותקן.
|
|
145
|
+
- מקומי-תחילה מעיצובו; אינו שירות רב-משתמשים מאוחסן.
|
|
146
|
+
- הרצת פקודות hook מנותחת ומדווחת אך עדיין אינה מבוצעת.
|
|
147
|
+
|
|
148
|
+
## רישיון
|
|
149
|
+
|
|
150
|
+
[MIT](LICENSE) © YosefHayim
|
|
151
|
+
|
|
152
|
+
</div>
|
package/README.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/hero.png" alt="ai-browser-bridge — drive ChatGPT or Gemini from your terminal over a sandboxed MCP bridge" width="640" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# ai-browser-bridge
|
|
6
|
+
|
|
7
|
+
> Drive a real ChatGPT or Gemini browser conversation from your terminal, and give ChatGPT a narrow, sandboxed set of local repo tools over MCP — without ever handing it a shell.
|
|
8
|
+
|
|
9
|
+
**English** · [עברית](README.he.md) · [Español](README.es.md) · [中文](README.zh.md)
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Why this exists
|
|
20
|
+
|
|
21
|
+
ChatGPT is at its best in the browser — real account state, the model picker, message editing, regeneration, and conversation history all intact. Coding is at its best in the terminal, where files, tests, diffs, and patches are inspected and changed directly.
|
|
22
|
+
|
|
23
|
+
`ai-browser-bridge` connects those two surfaces. A terminal prompt drives your existing ChatGPT or Gemini browser session, and ChatGPT can reach into the current repo through a small set of **validated MCP tools** — `grep`, `read`, `apply_patch`, `run_tests`, `git_diff` — instead of raw shell access. You stay in one terminal workflow; the provider keeps its real UI.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **Terminal-driven ChatGPT** — send prompts and stream replies without leaving the shell; the real browser conversation stays the source of truth.
|
|
28
|
+
- **Six providers, one command** — `chatgpt`, `gemini`, `claude`, `deepseek`, `grok`, `perplexity`. Pick one with `--provider`, or **fan out** across several (`--provider claude,deepseek,grok`) and get every reply keyed by provider in one call.
|
|
29
|
+
- **Built for agents** — a stable non-interactive `bridge ask … --json` contract (never hangs in a pipe) plus an outbound MCP `ask` tool, so any agent can drive a web chat.
|
|
30
|
+
- **Sandboxed local tools over MCP** — every file operation is validated against the selected repo root; no arbitrary shell, allowlisted test commands only.
|
|
31
|
+
- **Browser actions as commands** — `/resume`, `/new`, `/model`, `/rewind`, `/stop`, `/context`, `/diff`, `/compact`, and more.
|
|
32
|
+
- **Repo-local sessions & transcripts** — every run is recorded under `<repo>/.bridge/` and exportable as Markdown, JSON, or JSONL.
|
|
33
|
+
- **Safety controls** — permission modes (`read-only` / `ask` / `auto`) and automatic file checkpoints around every patch.
|
|
34
|
+
- **Project conventions** — custom commands plus `AGENTS.md` / `CLAUDE.md` are fed to ChatGPT for `/task` runs.
|
|
35
|
+
- **A real composer** — prompt history, reverse search, queued prompts, and `@file` mention autocomplete.
|
|
36
|
+
|
|
37
|
+
## Architecture
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
terminal (you)
|
|
41
|
+
│
|
|
42
|
+
│ Ink / React CLI
|
|
43
|
+
▼
|
|
44
|
+
orchestrator ──────────────┬───────────────────────────────┐
|
|
45
|
+
│ browser automation │ MCP server │
|
|
46
|
+
▼ (Playwright + CDP) │ (MCP SDK) ▼
|
|
47
|
+
ChatGPT browser UI │ local repo tools
|
|
48
|
+
▲ │ (grep/read/patch/test/diff)
|
|
49
|
+
│ ▼ │
|
|
50
|
+
└───── Cloudflare Tunnel (cloudflared) ◄────────────────┘
|
|
51
|
+
public https://…trycloudflare.com/mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Four layers, each with one job:
|
|
55
|
+
|
|
56
|
+
| Layer | Tech | Responsibility |
|
|
57
|
+
|-------|------|----------------|
|
|
58
|
+
| **CLI** | Ink / React | Terminal UI: message pane, status line, `@file` mentions, `/commands`. |
|
|
59
|
+
| **Browser** | Playwright + Chrome DevTools Protocol | Drives the real ChatGPT or Gemini tab; captures responses. Selectors live under `src/features/providers/chatgpt/` and `src/features/providers/gemini/`. |
|
|
60
|
+
| **MCP server** | MCP SDK + Zod | Exposes the local repo tools to ChatGPT as schema-validated, sandboxed handlers. |
|
|
61
|
+
| **Tunnel** | Cloudflare Tunnel (`cloudflared`) | Gives the local MCP server a temporary public HTTPS URL that ChatGPT's connector can reach — no deployment required. |
|
|
62
|
+
|
|
63
|
+
**Why a tunnel at all?** ChatGPT's MCP connector calls tools over HTTPS, but the tool server runs on your machine. Rather than deploy anything, the bridge spins up an ephemeral Cloudflare Tunnel (`*.trycloudflare.com`) in front of the local port and syncs that `…/mcp` URL into the ChatGPT app on startup. (ngrok would solve the same reachability problem; Cloudflare's `cloudflared` is used because its quick tunnels need no account or auth token.)
|
|
64
|
+
|
|
65
|
+
## Quick start
|
|
66
|
+
|
|
67
|
+
**Prerequisites**
|
|
68
|
+
|
|
69
|
+
- **macOS** — Chrome is launched from `/Applications/Google Chrome.app`, and clipboard/process helpers use `pbcopy`/`lsof`.
|
|
70
|
+
- **Node.js ≥ 20** and **pnpm** (the repo pins `pnpm@10.14.0`).
|
|
71
|
+
- **Google Chrome** — the bridge drives a real Chrome profile.
|
|
72
|
+
- **`cloudflared`** *(optional, ChatGPT only)* — only needed for ChatGPT to call local MCP tools. Without it the TUI still runs. Install with `brew install cloudflared`.
|
|
73
|
+
|
|
74
|
+
**Install & build**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git clone https://github.com/YosefHayim/ai-browser-bridge.git
|
|
78
|
+
cd ai-browser-bridge
|
|
79
|
+
pnpm install
|
|
80
|
+
pnpm build
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Sign in once, then run (ChatGPT — default)**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
node dist/bridge.js login
|
|
87
|
+
node dist/bridge.js --repo /path/to/your/project
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Sign in once, then run (Gemini web)**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
node dist/bridge.js login --provider gemini
|
|
94
|
+
node dist/bridge.js --provider gemini --repo /path/to/your/project
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Prefer a global `bridge` command? Run `pnpm link --global` after building, then use `bridge`, `bridge login`, `bridge ask "…"`, etc.
|
|
98
|
+
|
|
99
|
+
**One-shot, non-interactive**
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
node dist/bridge.js ask "summarize @src/core/engine.ts" --repo /path/to/project
|
|
103
|
+
node dist/bridge.js ask "hello" --provider gemini --repo /path/to/project
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Usage
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
/help list commands /sessions list local sessions
|
|
110
|
+
/resume <query> resume by number/title/id /transcript print the session transcript
|
|
111
|
+
/new start a new conversation /export export transcript (md/json/jsonl)
|
|
112
|
+
/model [name] show or switch the model /permissions show or switch MCP permission mode
|
|
113
|
+
/rewind [text] edit last prompt + regen /checkpoints list file checkpoints
|
|
114
|
+
/stop stop the active response /restore <id> restore files from a checkpoint
|
|
115
|
+
/context model-aware context est. /status repo/model/context/session status
|
|
116
|
+
/diff ask ChatGPT to read diff /mcp connector + exposed tools
|
|
117
|
+
/task <request> project-agent task (MCP) /connector (re)run ChatGPT connector setup
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**File mentions** — reference repo files inline; they are resolved inside the repo and expanded before ChatGPT sees them:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
refactor the CLI input flow in @src/features/terminal/tui/App.tsx
|
|
124
|
+
compare @src/features/store/fileResolver.ts with @src/features/store/fileResolver.test.ts
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Paths that escape the repo root are skipped; files over 100 KB are summarized rather than inlined.
|
|
128
|
+
|
|
129
|
+
## Agents & fan-out
|
|
130
|
+
|
|
131
|
+
`bridge ask` is a stable, non-interactive surface for scripts and agents — it prints to stdout, never prompts in a pipe, and `--json` emits a machine-readable payload.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# one provider
|
|
135
|
+
bridge ask --provider claude --json "summarize the tradeoffs of optimistic locking"
|
|
136
|
+
|
|
137
|
+
# fan out across several free chats; one call, replies keyed by provider
|
|
138
|
+
bridge ask --provider claude,deepseek,grok --json "same question, three models"
|
|
139
|
+
# → { "claude": { "ok": true, "reply": "…", "elapsedMs": 8123 },
|
|
140
|
+
# "deepseek": { "ok": true, "reply": "…", "elapsedMs": 6210 },
|
|
141
|
+
# "grok": { "ok": false, "error": "…", "elapsedMs": 300000 } }
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Fan-out is **partial-failure tolerant**: the run exits non-zero only when *every* provider fails, or — with `--strict` — when *any* fails. A one-time `bridge login --provider <name>` signs each provider in (an isolated Chrome profile per provider; your daily browser is untouched).
|
|
145
|
+
|
|
146
|
+
The same fan-out core is exposed as an **outbound MCP `ask` tool** — launch it as a stdio MCP server with `bridge serve` and any MCP-capable agent can call `ask({ prompt, providers })` as a native tool instead of shelling out. Register it with Claude Code:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
claude mcp add ai-browser-bridge -- bridge serve
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
…or add it to any MCP client config directly (the standard stdio-server shape):
|
|
153
|
+
|
|
154
|
+
```jsonc
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"ai-browser-bridge": { "command": "bridge", "args": ["serve"] }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The `ask` tool takes `{ prompt, providers?, timeoutSeconds? }` and returns each provider's reply keyed by id (the same partial-failure-tolerant fan-out as `bridge ask`). Run `bridge login --provider <name>` once first, so the gateway has a signed-in session to drive. This is the opposite direction to the inbound MCP server, which exposes your repo tools *to* the web model.
|
|
163
|
+
|
|
164
|
+
> Provider adapters other than ChatGPT/Gemini ship with best-effort selectors marked `LIVE-VERIFY` — confirm them against the live signed-in site before relying on them in production.
|
|
165
|
+
|
|
166
|
+
## Where state lives
|
|
167
|
+
|
|
168
|
+
All bridge state for a project is written **inside that project**, under `<repo>/.bridge/`:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
<repo>/.bridge/
|
|
172
|
+
├── .gitignore # a single "*", written automatically — see below
|
|
173
|
+
├── config.json # per-repo settings (includes `provider`: chatgpt | gemini)
|
|
174
|
+
├── chrome-profile/ # signed-in ChatGPT session for this repo
|
|
175
|
+
├── chrome-profile-gemini/ # signed-in Gemini session for this repo
|
|
176
|
+
├── sessions/<id>/ # metadata.json + append-only events.jsonl transcript
|
|
177
|
+
├── logs/<date>.jsonl # prompts, replies, and MCP tool-call summaries
|
|
178
|
+
├── checkpoints/ # before/after snapshots around each apply_patch
|
|
179
|
+
├── exports/ # /export output
|
|
180
|
+
├── downloads/<conv>/ # attachment downloads (default when no --out given)
|
|
181
|
+
└── screenshots/ # /screenshot and /ui-qa captures
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
On first use the bridge writes `.bridge/.gitignore` containing a single `*`. That makes git ignore **everything** in the directory — the session transcripts and the login cookies included — so none of it can be committed, even though it lives inside the repo. `git add -A` and `git add .bridge/` both skip it; only an explicit `git add -f` could override. The file is re-asserted on every run, so deleting or tampering with it heals automatically.
|
|
185
|
+
|
|
186
|
+
> User-authored config meant to apply across **all** repos lives in your home directory: custom commands in `~/.ai-browser-bridge/commands/*.md` and user-level hooks in `~/.ai-browser-bridge/hooks.json`.
|
|
187
|
+
|
|
188
|
+
### Migrating from `chatgpt-local-bridge`
|
|
189
|
+
|
|
190
|
+
The package was renamed to **`ai-browser-bridge`**. Global user config moved from `~/.chatgpt-local-bridge/` to `~/.ai-browser-bridge/` — copy your `commands/` folder and `hooks.json` if you had them. Repo-local state stays at `<repo>/.bridge/` (unchanged). Re-run `/connector` or `bridge ask --tools` once so ChatGPT picks up the renamed MCP connector app.
|
|
191
|
+
|
|
192
|
+
## Permissions & checkpoints
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
/permissions read-only # grep_code, read_file, git_diff
|
|
196
|
+
/permissions auto # also the narrow write/test tools
|
|
197
|
+
/permissions ask # blocks write/test/process tools (interactive confirm pending)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`apply_patch` snapshots every touched path before and after the change. Recover with `/checkpoints`, `/restore <id>`, or `/rewind --files <id>`.
|
|
201
|
+
|
|
202
|
+
## Testing
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
pnpm test # vitest run
|
|
206
|
+
pnpm typecheck # tsc --noEmit
|
|
207
|
+
pnpm verify:push # biome ci + typecheck + test + build + check:class-api + check:tsdoc + check:boundaries
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Coverage focuses on the safety-sensitive paths — sandbox validation, repo-local path resolution, the `.bridge/` self-ignore guard, session/checkpoint stores, permissions, and context counting.
|
|
211
|
+
|
|
212
|
+
## Gemini web support
|
|
213
|
+
|
|
214
|
+
The bridge can drive **gemini.google.com** from the terminal with the same Playwright/CDP pattern as ChatGPT:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
bridge login --provider gemini
|
|
218
|
+
bridge --provider gemini --repo /path/to/project
|
|
219
|
+
bridge ask "explain this repo" --provider gemini --repo /path/to/project
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**What works on Gemini web**
|
|
223
|
+
|
|
224
|
+
- Terminal-driven prompts and captured replies
|
|
225
|
+
- `@file` mention expansion (read-only repo context inlined into prompts)
|
|
226
|
+
- Model detection/switching when the Gemini UI exposes a picker
|
|
227
|
+
- Separate Chrome profile at `<repo>/.bridge/chrome-profile-gemini/`
|
|
228
|
+
|
|
229
|
+
**What does not work on Gemini web (today)**
|
|
230
|
+
|
|
231
|
+
- **MCP connector** — gemini.google.com has no custom connector UI like ChatGPT Settings → Connectors. The bridge skips the MCP server and Cloudflare tunnel when `--provider gemini`.
|
|
232
|
+
- **`/task`, `/connector`, `/mcp`** — these require live MCP tools; use ChatGPT for those workflows.
|
|
233
|
+
- **Attachment download** — `bridge download` is ChatGPT-only for now.
|
|
234
|
+
|
|
235
|
+
For full MCP on Gemini, use the official [Gemini API Remote MCP](https://ai.google.dev/gemini-api/docs/function-calling) or [Gemini CLI](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md) instead of the browser UI.
|
|
236
|
+
|
|
237
|
+
**Selector maintenance:** when Google changes the Gemini web UI, fix selectors only in [`src/browser/gemini-page.ts`](src/browser/gemini-page.ts).
|
|
238
|
+
|
|
239
|
+
## Limitations
|
|
240
|
+
|
|
241
|
+
- **macOS-only** today (hardcoded Chrome path and `pbcopy`/`lsof` helpers).
|
|
242
|
+
- ChatGPT and Gemini browser selectors can break when the web UI changes; fixes are localized to the browser layer.
|
|
243
|
+
- Context usage is an **estimate** — the browser does not expose exact server-side token counts.
|
|
244
|
+
- The Cloudflare Tunnel requires `cloudflared` installed.
|
|
245
|
+
- Local-first by design; not a hosted multi-user service.
|
|
246
|
+
- Hook command execution is parsed and reported but not yet executed (an allowlisted confirmation flow is pending).
|
|
247
|
+
|
|
248
|
+
## License
|
|
249
|
+
|
|
250
|
+
[MIT](LICENSE) © YosefHayim
|