Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 102 additions & 9 deletions bun.lock

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions docs/guide/browser-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,46 @@ Key rules:
- `tab select <targetId>` makes that tab the default target for later untargeted `opencli browser ...` commands.
- `tab close <targetId>` removes the tab; if it was the current default target, the stored default is cleared.

## Multiple Chrome Profiles

If you install the Browser Bridge extension in more than one Chrome profile (e.g. `Work` and `Personal`), all of them stay connected to the same daemon simultaneously. Commands route by profile so each CLI invocation lands in the Chrome profile you intended instead of silently hitting whichever extension connected last.

### Label a profile

Each extension generates a unique `profileId` the first time it runs. The popup shows a default label (`Profile-<short-hash>`); click the pencil icon on the chip to rename it to something short like `work` or `home`. That label is what you use in the CLI.

### Select which profile a command runs in

Resolution order (highest priority first):

1. `--profile <name>` flag on the individual command
2. `OPENCLI_PROFILE` environment variable (per-shell)
3. `opencli profile use <name>` persistent default (`~/.opencli/config.json`)
4. Automatic routing when exactly one profile is connected (backwards-compatible)

```bash
opencli profile list # See connected profiles
opencli profile use work # Persist a default
opencli profile current # Show the resolved default
opencli --profile personal reddit saved # Override for one command
```

### Concurrent sessions on different profiles

Use `OPENCLI_PROFILE` (per-shell env) when running two terminals / Claude Code sessions / Codex sessions at the same time. Each session targets its own profile without fighting over a shared default.

```bash
# Terminal 1
export OPENCLI_PROFILE=work
opencli reddit saved

# Terminal 2 — independent, concurrent
export OPENCLI_PROFILE=personal
opencli reddit saved
```

Both commands reach their own Chrome profile's automation window; cookies, session state, and logins stay fully isolated.

## How It Works

```
Expand Down
17 changes: 17 additions & 0 deletions docs/guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
- Ensure the opencli Browser Bridge extension is installed and **enabled** in `chrome://extensions`.
- Run `opencli doctor` to diagnose connectivity.

### "Multiple profiles connected. Pick one..."

You have the Browser Bridge extension installed in more than one Chrome profile and no default has been set. Choose a profile in one of three ways:

- Per-command: `opencli --profile <name> ...`
- Per-shell: `export OPENCLI_PROFILE=<name>`
- Persistent default: `opencli profile use <name>`

Run `opencli profile list` to see connected labels, and use the extension popup's pencil icon to rename profiles to short, memorable labels (`work`, `home`, etc.).

### "Profile 'X' not connected"

The label or profileId you specified is not in the daemon's active set. Common causes:

- The target Chrome profile is not currently running, or its extension is disabled in `chrome://extensions`.
- The label does not match. Run `opencli profile list` to see what's actually connected; rename via the extension popup if needed.

### Empty data or 'Unauthorized' error

- Your login session in Chrome might have expired. Open a normal Chrome tab, navigate to the target site, and log in or refresh the page.
Expand Down
40 changes: 40 additions & 0 deletions docs/zh/guide/browser-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,46 @@ opencli browser tab close <targetId>
- `tab select <targetId>` 会把该 tab 设为后续未显式指定 target 的 `opencli browser ...` 命令默认目标。
- `tab close <targetId>` 会关闭该 tab;如果它正好是当前默认目标,会一并清掉这条默认绑定。

## 多 Chrome Profile

如果你在多个 Chrome profile(例如 `Work` 和 `Personal`)里都装了 Browser Bridge 扩展,它们会同时连到同一个 daemon。命令按 profile 路由,每条 CLI 调用都会命中你指定的那个浏览器,而不是静默落到最后连上来的那个。

### 给 profile 命名

每个扩展首次启动会生成唯一的 `profileId`。popup 默认显示 `Profile-<短 hash>`,点 chip 上的铅笔图标可以改成 `work`、`home` 这样的短名。CLI 里引用的就是这个 label。

### 选择命令跑在哪个 profile

优先级(从高到低):

1. 单条命令上的 `--profile <name>` 参数
2. `OPENCLI_PROFILE` 环境变量(shell 级)
3. `opencli profile use <name>` 持久化默认(`~/.opencli/config.json`)
4. 仅一个 profile 在线时的自动路由(向后兼容)

```bash
opencli profile list # 查看已连接的 profile
opencli profile use work # 持久化默认
opencli profile current # 查看当前默认来源
opencli --profile personal reddit saved # 单条命令覆盖
```

### 多个 session 同时操作不同 profile

用 `OPENCLI_PROFILE`(进程级环境变量)——两个 terminal / Claude Code session / Codex session 各自指向不同 profile,不会互相覆盖共享默认。

```bash
# Terminal 1
export OPENCLI_PROFILE=work
opencli reddit saved

# Terminal 2 —— 并发独立
export OPENCLI_PROFILE=personal
opencli reddit saved
```

两条命令分别进入各自 Chrome profile 的自动化窗口,cookie、会话状态、登录信息完全隔离。

## Daemon 生命周期

Daemon 在首次运行浏览器命令时自动启动,之后保持常驻运行。
Expand Down
Loading