ask-bridge 0.1.0 → 0.1.5
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/README.en.md +139 -46
- package/README.md +138 -47
- package/npm/postinstall.cjs +18 -0
- package/package.json +2 -1
package/README.en.md
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
# Ask Bridge 🦀
|
|
2
2
|
|
|
3
|
-
`ask` is a powerful, lightweight command-line tool written in **Rust** that automates ChatGPT or Gemini directly in your real Chrome browser. It uses the **Model Context Protocol (MCP)** and **Chrome DevTools Protocol (CDP)** via the embedded `doggy8088/mcp-cli` Rust library dependency and `chrome-devtools-mcp` to control Chrome, input prompts, click submit, and print the response back to your terminal. ChatGPT is the default provider; use `--provider gemini` to switch to Gemini.
|
|
3
|
+
`ask-bridge` is a powerful, lightweight command-line tool written in **Rust** that automates ChatGPT or Gemini directly in your real Chrome browser. It uses the **Model Context Protocol (MCP)** and **Chrome DevTools Protocol (CDP)** via the embedded `doggy8088/mcp-cli` Rust library dependency and `chrome-devtools-mcp` to control Chrome, input prompts, click submit, and print the response back to your terminal. ChatGPT is the default when no global provider is configured; use `--provider gemini` or the global config file to switch to Gemini.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
## Design Intent
|
|
6
|
+
|
|
7
|
+
The core purpose of `ask-bridge` is not to replace ChatGPT, Gemini, or any Coding Agent. It is to bridge them together. During software development, many AI-assisted tasks are exploratory: researching background information, summarizing documents, comparing options, digesting error messages, analyzing code snippets, drafting text, or clarifying uncertain technical questions. These tasks do not always need to be handled directly by the primary Coding Agent, and they do not always justify using the same agent budget that should be reserved for code editing, testing, refactoring, and integration work.
|
|
8
|
+
|
|
9
|
+
With `ask-bridge`, a Coding Agent can delegate low-risk, exploratory, and research-oriented tasks to the ChatGPT or Gemini websites, then bring the website response back into the terminal or the next step of the local workflow. Because ChatGPT and Gemini website usage quotas are typically separate from Coding Agent execution quotas, `ask-bridge` gives developers a more flexible way to allocate AI resources: the primary agent can focus on understanding the repository, modifying code, running tests, and integrating results, while website-based AI handles background research, text processing, and candidate solution generation.
|
|
10
|
+
|
|
11
|
+
In other words, `ask-bridge` is an external research bridge for AI Agents. It turns the manual workflow of switching to a browser, pasting a prompt, waiting for a response, and copying the result back into a command-line-driven automation capability. This lets an agent request help from ChatGPT or Gemini without leaving the local development workflow, then use the response as supporting context for its own judgment.
|
|
12
|
+
|
|
13
|
+
This tool is especially useful for:
|
|
14
|
+
|
|
15
|
+
- Sending large documents, error messages, or code snippets to a website-based AI for summarization, comparison, or first-pass analysis.
|
|
16
|
+
- Letting a Coding Agent outsource background research, alternative analysis, or checklist generation before implementation.
|
|
17
|
+
- Moving AI tasks that do not directly modify project files out of the primary agent workflow.
|
|
18
|
+
- Reusing existing ChatGPT or Gemini web accounts for interactive website features outside an API workflow.
|
|
19
|
+
|
|
20
|
+
`ask-bridge` does not guarantee that provider output is correct, and it should not replace local tests, official documentation checks, or human review. Its role is to reduce the operational cost of exploratory AI work and let the primary Coding Agent obtain external AI assistance with less friction.
|
|
21
|
+
|
|
22
|
+
Unlike typical API clients, `ask-bridge` operates inside a real Chrome browser with a **persistent user profile**. This means:
|
|
23
|
+
- You log in manually **once** (`ask-bridge login`).
|
|
7
24
|
- You can solve CAPTCHAs, pass provider-side browser checks, and access the selected provider's web features like a normal user.
|
|
8
25
|
- Your session cookies, login state, and chat history are saved persistently.
|
|
9
26
|
|
|
@@ -13,12 +30,13 @@ Unlike typical API clients, `ask` operates inside a real Chrome browser with a *
|
|
|
13
30
|
|
|
14
31
|
- **🦀 100% Rust Core**: Extremely fast, lightweight, and compile-once, run-anywhere binary.
|
|
15
32
|
- **Multi-provider support**: Choose ChatGPT or Gemini with `--provider chatgpt|gemini`.
|
|
33
|
+
- **Global provider config**: Set the default provider in `~/.config/ask-bridge/config.json`; CLI `--provider` overrides the config file.
|
|
16
34
|
- **🌐 Real Browser Automation**: Directly interacts with Chrome on port `9223` (isolated debug profile).
|
|
17
35
|
- **🔒 Persistent Login**: Uses a dedicated local profile directory (`~/.config/ask-bridge/chrome-profile`) so you never lose your login state.
|
|
18
36
|
- **Response Output**: Prints the selected provider's response back to your terminal.
|
|
19
37
|
- **🌀 TUI Thinking Animation**: Displays a rotating spinner while waiting for the provider to reply, then clears it once output starts.
|
|
20
38
|
- **🧠 Intelligent Tab Management**: Reuses existing provider tabs if open, focuses them, or opens new ones, avoiding tab clutter.
|
|
21
|
-
- **🖥️ Pipe & Stdin Support**: Supports piping prompts via `stdin` (e.g. `cat report.txt | ask "summarize this"`).
|
|
39
|
+
- **🖥️ Pipe & Stdin Support**: Supports piping prompts via `stdin` (e.g. `cat report.txt | ask-bridge "summarize this"`).
|
|
22
40
|
- **📎 Image & File Attachments**: Attach local images to ChatGPT with `--image`, or documents (PDF, Word, Excel, plain text, Markdown, JSON, etc.) with `--file`; Gemini currently supports `--file` and rejects `--image`.
|
|
23
41
|
- **🔀 Model Switching**: Use `--model` to switch the provider model before the prompt is sent, such as ChatGPT `GPT-5.4` or Gemini `3.5 Flash`.
|
|
24
42
|
- **🔍 Quiet by Default & Verbose Mode**: Quiet and clean output by default (displaying only the generated response), with an optional `--verbose` flag to display full browser state logs if needed.
|
|
@@ -30,26 +48,59 @@ Unlike typical API clients, `ask` operates inside a real Chrome browser with a *
|
|
|
30
48
|
|
|
31
49
|
To run this tool, you need:
|
|
32
50
|
|
|
33
|
-
1.
|
|
51
|
+
1. **Node.js 20.19.0 LTS or newer LTS**, with both `node` and `npx` available in the current shell's `PATH`. `ask-bridge` starts `chrome-devtools-mcp@latest` through `npx`; older Node.js versions, such as `v20.11.0`, can cause the MCP server to exit during `initialize`.
|
|
34
52
|
2. **Google Chrome** installed (normally located at `/Applications/Google Chrome.app` on macOS). `make install` installs it with Homebrew when it is missing and Homebrew is available.
|
|
35
53
|
|
|
54
|
+
Check the Node.js version visible to your current shell:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
node -v
|
|
58
|
+
npx -v
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
| Platform | Notes |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| macOS | Install a Node.js LTS release with Homebrew or nvm. If you use nvm, make sure the same shell that runs `ask-bridge` has loaded nvm and that `node -v` reports `v20.19.0` or newer. Chrome is detected at `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` by default. |
|
|
64
|
+
| Windows | Install a Node.js LTS release with the official installer, winget, or nvm-windows. Reopen PowerShell after installation, then verify that `node -v` and `npx -v` work. Chrome is detected from the standard `Program Files`, `Program Files (x86)`, and `%LOCALAPPDATA%` install paths. |
|
|
65
|
+
| Linux | Distribution package repositories may provide an older Node.js version. Prefer NodeSource, nvm, or an official Node.js LTS source. Install Google Chrome Stable and make sure `google-chrome` or `google-chrome-stable` is available in `PATH`; Snap, Flatpak, or Chromium installs may not match the default detection logic. |
|
|
66
|
+
|
|
36
67
|
You do **not** need a global `mcp-cli` executable. The Rust binary uses `mcp-cli` as a Cargo dependency from `https://github.com/doggy8088/mcp-cli`.
|
|
37
68
|
|
|
38
69
|
---
|
|
39
70
|
|
|
40
71
|
## 🚀 Installation & Build
|
|
41
72
|
|
|
42
|
-
### 1.
|
|
73
|
+
### 1. Quick Installation (Recommended)
|
|
43
74
|
|
|
44
|
-
|
|
75
|
+
If you only want to use the pre-compiled Release version (without installing the Rust toolchain), you can run one of the following one-liner installation scripts. They will automatically verify the Node.js requirement, download the appropriate binary for your system architecture, and place it in your `~/.local/bin/` folder.
|
|
76
|
+
|
|
77
|
+
#### macOS / Linux
|
|
78
|
+
Open your terminal and run:
|
|
79
|
+
```bash
|
|
80
|
+
curl -fsSL https://raw.githubusercontent.com/doggy8088/ask-bridge/main/install.sh | bash
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Windows
|
|
84
|
+
Open PowerShell (recommended to Run as Administrator) and run:
|
|
85
|
+
```powershell
|
|
86
|
+
irm https://raw.githubusercontent.com/doggy8088/ask-bridge/main/install.ps1 | iex
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> [!NOTE]
|
|
90
|
+
> Make sure the installation path (`~/.local/bin` for macOS/Linux, and `$HOME\.local\bin` for Windows) is added to your system's `PATH` environment variable.
|
|
91
|
+
> The formal CLI command is `ask-bridge`; the installer also provides `ask` as a backward-compatible alias. The examples below use `ask-bridge`.
|
|
92
|
+
|
|
93
|
+
### 2. Build & Install from Source (For Developers)
|
|
94
|
+
|
|
95
|
+
Clone or navigate to the project directory and build/install with Make:
|
|
45
96
|
|
|
46
97
|
```bash
|
|
47
98
|
make install
|
|
48
99
|
```
|
|
49
100
|
|
|
50
|
-
This installs the required Chrome browser
|
|
101
|
+
This verifies the Node.js environment, installs the required Chrome browser if needed, builds the optimized binary, links the formal command to `~/.local/bin/ask-bridge`, and also creates the `ask` alias.
|
|
51
102
|
|
|
52
|
-
###
|
|
103
|
+
### 3. Build Only
|
|
53
104
|
|
|
54
105
|
If you only want to build without installing:
|
|
55
106
|
|
|
@@ -59,22 +110,38 @@ cargo build --release
|
|
|
59
110
|
|
|
60
111
|
The compiled binary will be located at `target/release/ask-bridge`.
|
|
61
112
|
|
|
113
|
+
### 4. Install the Agent Skill
|
|
114
|
+
|
|
115
|
+
This repository provides an `ask-bridge` Agent Skill so Skills-compatible Coding Agents can use `ask-bridge` to delegate exploratory research, summarization, document analysis, or option comparison tasks to the ChatGPT or Gemini websites.
|
|
116
|
+
|
|
117
|
+
Install it with `npx skills`; you do not need to copy the `skills/` directory manually:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npx skills add doggy8088/ask-bridge --skill ask-bridge
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
To install it globally for Codex, specify the agent and global scope:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npx skills add doggy8088/ask-bridge --skill ask-bridge --agent codex --global
|
|
127
|
+
```
|
|
128
|
+
|
|
62
129
|
---
|
|
63
130
|
|
|
64
131
|
## 📖 Usage Guide
|
|
65
132
|
|
|
66
133
|
### 1. First Time Setup: Login to a provider
|
|
67
134
|
|
|
68
|
-
Before sending prompts, you need to log in to the selected provider. ChatGPT is the default:
|
|
135
|
+
Before sending prompts, you need to log in to the selected provider. ChatGPT is the default when no global provider is configured:
|
|
69
136
|
|
|
70
137
|
```bash
|
|
71
|
-
ask login
|
|
138
|
+
ask-bridge login
|
|
72
139
|
```
|
|
73
140
|
|
|
74
141
|
For Gemini:
|
|
75
142
|
|
|
76
143
|
```bash
|
|
77
|
-
ask --provider gemini login
|
|
144
|
+
ask-bridge --provider gemini login
|
|
78
145
|
```
|
|
79
146
|
|
|
80
147
|
- This will automatically launch Google Chrome with a dedicated, persistent debug profile.
|
|
@@ -82,13 +149,39 @@ ask --provider gemini login
|
|
|
82
149
|
- Once logged in, return to your terminal and press **`[Enter]`**.
|
|
83
150
|
- The tool will verify your login status and save your profile. You only need to do this **once**!
|
|
84
151
|
|
|
152
|
+
#### Global Provider Config
|
|
153
|
+
|
|
154
|
+
To use Gemini by default when `--provider` is not specified:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
ask-bridge config --provider gemini
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
To switch the default back to ChatGPT:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
ask-bridge config --provider chatgpt
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
You can check the current setting with:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
ask-bridge config
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`--provider` has higher priority than the global config file, so this command temporarily uses ChatGPT:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
ask-bridge --provider chatgpt "Summarize this text."
|
|
176
|
+
```
|
|
177
|
+
|
|
85
178
|
### 2. Send Prompts Directly
|
|
86
179
|
|
|
87
180
|
Simply pass your prompt as an argument:
|
|
88
181
|
|
|
89
182
|
```bash
|
|
90
|
-
ask "What is the difference between a struct and a tuple in Rust?"
|
|
91
|
-
ask --provider gemini "What is the difference between a struct and a tuple in Rust?"
|
|
183
|
+
ask-bridge "What is the difference between a struct and a tuple in Rust?"
|
|
184
|
+
ask-bridge --provider gemini "What is the difference between a struct and a tuple in Rust?"
|
|
92
185
|
```
|
|
93
186
|
|
|
94
187
|
- Chrome will open or focus on your selected provider tab.
|
|
@@ -97,12 +190,12 @@ ask --provider gemini "What is the difference between a struct and a tuple in Ru
|
|
|
97
190
|
|
|
98
191
|
### 3. Open a Brand New Session (`--new`)
|
|
99
192
|
|
|
100
|
-
By default, `ask` will reuse any existing open tab for the selected provider to avoid cluttering your browser with too many tabs.
|
|
193
|
+
By default, `ask-bridge` will reuse any existing open tab for the selected provider to avoid cluttering your browser with too many tabs.
|
|
101
194
|
|
|
102
195
|
If you want to start a **completely fresh conversation session** (equivalent to clicking "New Chat" in the sidebar), use the `--new` flag:
|
|
103
196
|
|
|
104
197
|
```bash
|
|
105
|
-
ask "誰是保哥?" --new
|
|
198
|
+
ask-bridge "誰是保哥?" --new
|
|
106
199
|
```
|
|
107
200
|
|
|
108
201
|
- This will open a **brand new selected-provider tab**.
|
|
@@ -115,19 +208,19 @@ By default, standard queries run Chrome in **headless mode** (`--headless=true`)
|
|
|
115
208
|
If you want to watch Chrome work in real-time or need to manually check what's happening on the page, you can run in **headful mode** by setting `--headless=false`:
|
|
116
209
|
|
|
117
210
|
```bash
|
|
118
|
-
ask "誰是保哥?" --headless=false
|
|
211
|
+
ask-bridge "誰是保哥?" --headless=false
|
|
119
212
|
```
|
|
120
213
|
|
|
121
|
-
*Note: `ask login` always overrides the default and runs in **headful mode** so you can interact with the UI. For other subcommands, pass `--headless=false` when you want a visible browser.*
|
|
214
|
+
*Note: `ask-bridge login` always overrides the default and runs in **headful mode** so you can interact with the UI. For other subcommands, pass `--headless=false` when you want a visible browser.*
|
|
122
215
|
|
|
123
216
|
### 5. Verbose Mode (`--verbose`)
|
|
124
217
|
|
|
125
|
-
By default, `ask` runs in a **quiet, clean mode** that hides all background browser-control logs (such as "Checking open Chrome tabs...", "Typing prompt...", etc.) and only displays the final markdown answer. However, it still plays an animated rotating spinner in your terminal while waiting for the provider to generate a response.
|
|
218
|
+
By default, `ask-bridge` runs in a **quiet, clean mode** that hides all background browser-control logs (such as "Checking open Chrome tabs...", "Typing prompt...", etc.) and only displays the final markdown answer. However, it still plays an animated rotating spinner in your terminal while waiting for the provider to generate a response.
|
|
126
219
|
|
|
127
|
-
If you want to see detailed step-by-step status logs of what `ask` is doing behind the scenes, add the `--verbose` flag:
|
|
220
|
+
If you want to see detailed step-by-step status logs of what `ask-bridge` is doing behind the scenes, add the `--verbose` flag:
|
|
128
221
|
|
|
129
222
|
```bash
|
|
130
|
-
ask "誰是保哥?" --verbose
|
|
223
|
+
ask-bridge "誰是保哥?" --verbose
|
|
131
224
|
```
|
|
132
225
|
|
|
133
226
|
This will print every stage of the browser automation:
|
|
@@ -142,27 +235,27 @@ This will print every stage of the browser automation:
|
|
|
142
235
|
Use `-v` or `--version` to print the current version number:
|
|
143
236
|
|
|
144
237
|
```bash
|
|
145
|
-
ask -v
|
|
238
|
+
ask-bridge -v
|
|
146
239
|
```
|
|
147
240
|
|
|
148
241
|
### 7. Piping & Stdin Support
|
|
149
242
|
|
|
150
|
-
You can pipe text or files directly into `ask`:
|
|
243
|
+
You can pipe text or files directly into `ask-bridge`:
|
|
151
244
|
|
|
152
245
|
```bash
|
|
153
|
-
echo "Explain quantum computing in one sentence" | ask
|
|
246
|
+
echo "Explain quantum computing in one sentence" | ask-bridge
|
|
154
247
|
```
|
|
155
248
|
|
|
156
|
-
When you also pass a prompt argument, `ask` uses the prompt first and then appends stdin content after two newlines:
|
|
249
|
+
When you also pass a prompt argument, `ask-bridge` uses the prompt first and then appends stdin content after two newlines:
|
|
157
250
|
|
|
158
251
|
```bash
|
|
159
|
-
cat /Users/will/.copilot/session-state/46cc0f1c-79fd-4622-9548-a0b7fa3794be/research/does-cursor-support-byok.md | ask 'What is this?'
|
|
252
|
+
cat /Users/will/.copilot/session-state/46cc0f1c-79fd-4622-9548-a0b7fa3794be/research/does-cursor-support-byok.md | ask-bridge 'What is this?'
|
|
160
253
|
```
|
|
161
254
|
|
|
162
255
|
Or read files:
|
|
163
256
|
|
|
164
257
|
```bash
|
|
165
|
-
cat src/main.rs | ask "Are there any memory leaks in this Rust code?"
|
|
258
|
+
cat src/main.rs | ask-bridge "Are there any memory leaks in this Rust code?"
|
|
166
259
|
```
|
|
167
260
|
|
|
168
261
|
### 8. Attaching Images or Files
|
|
@@ -174,8 +267,8 @@ Instead of piping file contents into the prompt, you can upload local files as a
|
|
|
174
267
|
Use `--image` (repeatable) to attach one or more local images. This currently supports ChatGPT; Gemini image input is not enabled and exits with an explicit error when used with `--provider gemini`.
|
|
175
268
|
|
|
176
269
|
```bash
|
|
177
|
-
ask "Describe this image." --image screenshot.png
|
|
178
|
-
ask "Compare these two images." --image v1.png --image v2.png
|
|
270
|
+
ask-bridge "Describe this image." --image screenshot.png
|
|
271
|
+
ask-bridge "Compare these two images." --image v1.png --image v2.png
|
|
179
272
|
```
|
|
180
273
|
|
|
181
274
|
Supported formats include PNG, JPEG, GIF, WebP, SVG, BMP, and more.
|
|
@@ -185,15 +278,15 @@ Supported formats include PNG, JPEG, GIF, WebP, SVG, BMP, and more.
|
|
|
185
278
|
Use `--file` (repeatable) to attach documents such as PDF, Word, Excel, PowerPoint, plain text, Markdown, CSV, JSON, or source code. This flow supports both ChatGPT and Gemini.
|
|
186
279
|
|
|
187
280
|
```bash
|
|
188
|
-
ask "Summarize this PDF." --file report.pdf
|
|
189
|
-
ask "How many rows are in this CSV?" --file data.csv
|
|
190
|
-
ask "Check this code for issues." --file src/main.rs
|
|
281
|
+
ask-bridge "Summarize this PDF." --file report.pdf
|
|
282
|
+
ask-bridge "How many rows are in this CSV?" --file data.csv
|
|
283
|
+
ask-bridge "Check this code for issues." --file src/main.rs
|
|
191
284
|
```
|
|
192
285
|
|
|
193
286
|
You can attach images and documents at the same time:
|
|
194
287
|
|
|
195
288
|
```bash
|
|
196
|
-
ask "Compare this design image against the spec document and list inconsistencies." --image design.png --file spec.docx
|
|
289
|
+
ask-bridge "Compare this design image against the spec document and list inconsistencies." --image design.png --file spec.docx
|
|
197
290
|
```
|
|
198
291
|
|
|
199
292
|
### 9. Switch Model
|
|
@@ -201,11 +294,11 @@ ask "Compare this design image against the spec document and list inconsistencie
|
|
|
201
294
|
Use `--model` to automatically switch the provider model before the prompt is sent. Matching is case- and punctuation-insensitive (`-`, `.`, spaces, etc. are ignored).
|
|
202
295
|
|
|
203
296
|
```bash
|
|
204
|
-
ask "Introduce Rust in a few sentences." --model GPT-5.4
|
|
205
|
-
ask "Prove this math problem." --model o3
|
|
206
|
-
ask "Quickly translate this." --model 即時
|
|
207
|
-
ask --provider gemini "Introduce Rust in a few sentences." --model "3.5 Flash"
|
|
208
|
-
ask --provider gemini "Introduce Rust in a few sentences." --model "3.1 Pro"
|
|
297
|
+
ask-bridge "Introduce Rust in a few sentences." --model GPT-5.4
|
|
298
|
+
ask-bridge "Prove this math problem." --model o3
|
|
299
|
+
ask-bridge "Quickly translate this." --model 即時
|
|
300
|
+
ask-bridge --provider gemini "Introduce Rust in a few sentences." --model "3.5 Flash"
|
|
301
|
+
ask-bridge --provider gemini "Introduce Rust in a few sentences." --model "3.1 Pro"
|
|
209
302
|
```
|
|
210
303
|
|
|
211
304
|
Available model names (depending on your account entitlements and provider UI):
|
|
@@ -214,34 +307,34 @@ Available model names (depending on your account entitlements and provider UI):
|
|
|
214
307
|
- **ChatGPT thinking levels**: `智慧`, `即時`, `中等`, `高`, `超高`, `專業`
|
|
215
308
|
- **Gemini modes**: `3.5 Flash`, `3.1 Flash-Lite`, `3.1 Pro`
|
|
216
309
|
|
|
217
|
-
> If the requested name is not found in the menu, `ask` reports `Model switch failed: error: model not found in menu` and aborts without submitting the prompt.
|
|
310
|
+
> If the requested name is not found in the menu, `ask-bridge` reports `Model switch failed: error: model not found in menu` and aborts without submitting the prompt.
|
|
218
311
|
|
|
219
312
|
### 10. Just Open a Provider
|
|
220
313
|
|
|
221
314
|
To quickly launch the browser and open the selected provider without sending any query:
|
|
222
315
|
|
|
223
316
|
```bash
|
|
224
|
-
ask open
|
|
225
|
-
ask --provider gemini open
|
|
317
|
+
ask-bridge open
|
|
318
|
+
ask-bridge --provider gemini open
|
|
226
319
|
```
|
|
227
320
|
|
|
228
321
|
### 11. Close the Browser Instance
|
|
229
322
|
|
|
230
|
-
To close the Chrome debug profile instance managed by `ask`:
|
|
323
|
+
To close the Chrome debug profile instance managed by `ask-bridge`:
|
|
231
324
|
|
|
232
325
|
```bash
|
|
233
|
-
ask close
|
|
326
|
+
ask-bridge close
|
|
234
327
|
```
|
|
235
328
|
|
|
236
|
-
`close` only shuts down the `ask` Chrome instance that uses `~/.config/ask-bridge/chrome-profile` and listens on debug port `9223`. If that port is occupied by a non-`ask` Chrome process, it reports an error instead of closing it.
|
|
329
|
+
`close` only shuts down the `ask-bridge` Chrome instance that uses `~/.config/ask-bridge/chrome-profile` and listens on debug port `9223`. If that port is occupied by a non-`ask-bridge` Chrome process, it reports an error instead of closing it.
|
|
237
330
|
|
|
238
331
|
---
|
|
239
332
|
|
|
240
333
|
## ⚙️ How It Works (Under the Hood)
|
|
241
334
|
|
|
242
|
-
1. **Browser Initialization**: `ask` checks if Chrome is listening on debugging port `9223`. If not, it spawns Google Chrome as a background process with a custom profile directory (`~/.config/ask-bridge/chrome-profile`).
|
|
335
|
+
1. **Browser Initialization**: `ask-bridge` checks if Chrome is listening on debugging port `9223`. If not, it spawns Google Chrome as a background process with a custom profile directory (`~/.config/ask-bridge/chrome-profile`).
|
|
243
336
|
2. **MCP Bridge Config**: On startup, it automatically writes a custom `mcp_servers.json` to `~/.config/ask-bridge/mcp_servers.json`, configuring the Chrome DevTools MCP server by default with `chrome-devtools-mcp@latest` and `--browser-url=http://127.0.0.1:9223`.
|
|
244
|
-
3. **Client Call**: `ask` calls the embedded `doggy8088/mcp-cli` Rust library dependency, invoking `list_pages`, `select_page`, `type_text`, and `evaluate_script` tools to automate the DOM without relying on an external `mcp-cli` executable.
|
|
337
|
+
3. **Client Call**: `ask-bridge` calls the embedded `doggy8088/mcp-cli` Rust library dependency, invoking `list_pages`, `select_page`, `type_text`, and `evaluate_script` tools to automate the DOM without relying on an external `mcp-cli` executable.
|
|
245
338
|
4. **State Polling**: During generation, a lightweight JavaScript engine checks the provider's send/stop button states and extracts response element inner-text for terminal output.
|
|
246
339
|
|
|
247
340
|
---
|
package/README.md
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
# Ask Bridge 🦀
|
|
2
2
|
|
|
3
|
-
`ask` 是以 Rust 撰寫的輕量命令列工具,可透過真實 Chrome 瀏覽器自動操作 ChatGPT 與 Gemini。它使用 Model Context Protocol MCP 與 Chrome DevTools Protocol CDP,並透過內建的 `doggy8088/mcp-cli` Rust library dependency 搭配 `chrome-devtools-mcp` 控制 Chrome、輸入 prompt
|
|
3
|
+
`ask-bridge` 是以 Rust 撰寫的輕量命令列工具,可透過真實 Chrome 瀏覽器自動操作 ChatGPT 與 Gemini。它使用 Model Context Protocol MCP 與 Chrome DevTools Protocol CDP,並透過內建的 `doggy8088/mcp-cli` Rust library dependency 搭配 `chrome-devtools-mcp` 控制 Chrome、輸入 prompt、送出訊息,並將回覆輸出到終端機。未設定全域 provider 時預設使用 ChatGPT,可用 `--provider gemini` 或全域設定檔切換到 Gemini。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 設計意圖
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
`ask-bridge` 的核心目的不是取代 ChatGPT、Gemini 或任何 Coding Agent,而是把它們橋接在一起。開發過程中常會出現大量探索性的 AI 需求,例如查資料、整理文件、比較方案、摘要錯誤訊息、分析程式片段、產生初稿或協助釐清不確定的技術問題。這類任務通常不一定需要由主要 Coding Agent 親自完成,也不一定值得消耗與程式碼編輯、測試、重構等高價值工作相同的 agent 額度。
|
|
8
|
+
|
|
9
|
+
透過 `ask-bridge`,Coding Agent 可以把這些低風險、探索性、可委派的研究工作轉交給 ChatGPT 或 Gemini 網站處理,再把網站回覆取回終端機或後續工作流程中。由於 ChatGPT、Gemini 網站的使用額度與 Coding Agent 的執行額度通常分開計算,`ask-bridge` 可以讓開發者更有彈性地分配 AI 資源:主要 agent 專注在理解專案、修改程式、執行測試與整合結果;網站型 AI 則負責背景研究、文字處理與候選方案產出。
|
|
10
|
+
|
|
11
|
+
換句話說,`ask-bridge` 是一個給 AI Agent 使用的外部研究橋接器:它把原本需要人類切換瀏覽器、貼上 prompt、等待回覆、再複製結果的流程,包裝成可由命令列驅動的自動化能力。這讓 agent 可以在不離開本機工作流程的情況下,自主向 ChatGPT 或 Gemini 發出請求,取得輔助資訊,並將其納入後續判斷。
|
|
12
|
+
|
|
13
|
+
此工具特別適合:
|
|
14
|
+
|
|
15
|
+
- 將大型文件、錯誤訊息或程式片段交給網站型 AI 做摘要、比對或初步分析。
|
|
16
|
+
- 讓 Coding Agent 在實作前先委外蒐集背景資料、整理替代方案或產生檢查清單。
|
|
17
|
+
- 把不需要直接修改專案檔案的 AI 任務移出主要 agent 執行流程。
|
|
18
|
+
- 利用既有 ChatGPT 或 Gemini 網頁帳號的能力,處理 API 以外的互動式網站功能。
|
|
19
|
+
|
|
20
|
+
`ask-bridge` 不保證網站 provider 的輸出一定正確,也不應取代本機測試、官方文件查證或人工審查。它的定位是降低探索性 AI 工作的操作成本,讓主要 Coding Agent 能以更低摩擦取得外部 AI 協助。
|
|
21
|
+
|
|
22
|
+
不同於一般 API client,`ask-bridge` 會在真實 Chrome 瀏覽器中執行,並使用持久化的專屬使用者 profile。這表示:
|
|
23
|
+
|
|
24
|
+
- 只需要手動登入一次,透過 `ask-bridge login` 完成。
|
|
8
25
|
- 可處理 CAPTCHA、Cloudflare,並像一般使用者一樣存取所選 provider 的網頁功能。
|
|
9
26
|
- Session cookies、登入狀態與對話紀錄會持久保存。
|
|
10
27
|
|
|
@@ -12,12 +29,13 @@
|
|
|
12
29
|
|
|
13
30
|
- **100% Rust 核心**:快速、輕量,編譯後即可執行。
|
|
14
31
|
- **多 provider 支援**:使用 `--provider chatgpt|gemini` 選擇 ChatGPT 或 Gemini。
|
|
32
|
+
- **全域 provider 設定**:可在 `~/.config/ask-bridge/config.json` 指定預設 provider,CLI 的 `--provider` 會覆蓋設定檔。
|
|
15
33
|
- **真實瀏覽器自動化**:直接控制監聽 `9223` port 的 Chrome debug profile。
|
|
16
34
|
- **持久登入狀態**:使用專屬本機 profile 目錄 `~/.config/ask-bridge/chrome-profile`,避免重複登入。
|
|
17
35
|
- **回覆輸出**:所選 provider 產生回覆時,將內容輸出到終端機。
|
|
18
36
|
- **思考動畫**:等待 provider 回覆時,在終端機顯示旋轉 spinner,開始輸出內容後自動清除。
|
|
19
37
|
- **智慧分頁管理**:可重用既有 provider 分頁、聚焦分頁,或開啟新分頁,避免分頁過度增加。
|
|
20
|
-
- **Pipe 與 stdin 支援**:支援透過 standard input 傳入 prompt,例如 `cat report.txt | ask "summarize this"`。
|
|
38
|
+
- **Pipe 與 stdin 支援**:支援透過 standard input 傳入 prompt,例如 `cat report.txt | ask-bridge "summarize this"`。
|
|
21
39
|
- **圖片與文件上傳**:可透過 `--image` 附上 ChatGPT 圖片,或透過 `--file` 附上文件(PDF、Word、Excel、純文字、Markdown、JSON 等皆可),一次可指定多個檔案;Gemini 目前支援 `--file`,不支援 `--image` 圖片輸入。
|
|
22
40
|
- **模型切換**:使用 `--model` 在送出 prompt 前自動切換 provider 模型(如 ChatGPT 的 `GPT-5.4`、`o3`,或 Gemini 的 `3.5 Flash`、`3.1 Pro`)。
|
|
23
41
|
- **預設安靜模式與 verbose 模式**:預設只輸出最終回覆;加上 `--verbose` 可顯示背景瀏覽器控制流程。
|
|
@@ -27,26 +45,57 @@
|
|
|
27
45
|
|
|
28
46
|
執行此工具需要:
|
|
29
47
|
|
|
30
|
-
1. 已安裝 `node` 與 `npx
|
|
48
|
+
1. 已安裝 **Node.js 20.19.0 LTS 以上,或更新的 LTS 版本**,並確保 `node` 與 `npx` 可在目前 shell 的 `PATH` 中執行。`ask-bridge` 會透過 `npx` 啟動 `chrome-devtools-mcp@latest`;若 Node.js 版本過舊,例如 `v20.11.0`,MCP server 會在 `initialize` 階段直接退出。
|
|
31
49
|
2. 已安裝 Google Chrome。macOS 預設路徑通常是 `/Applications/Google Chrome.app`。若缺少 Chrome,且系統有 Homebrew,`make install` 會自動安裝。
|
|
32
50
|
|
|
51
|
+
可用以下命令確認目前 shell 看到的 Node.js 版本:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
node -v
|
|
55
|
+
npx -v
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
| 平台 | 注意事項 |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| macOS | 可使用 Homebrew 或 nvm 安裝 Node.js LTS。若使用 nvm,請確認執行 `ask-bridge` 的同一個 shell 已載入 nvm,且 `node -v` 顯示 `v20.19.0` 以上。Chrome 預設偵測 `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`。 |
|
|
61
|
+
| Windows | 可使用 Node.js 官方安裝程式、winget 或 nvm-windows 安裝 Node.js LTS。安裝後請重新開啟 PowerShell,並確認 `node -v` 與 `npx -v` 可執行。Chrome 會優先偵測 `Program Files`、`Program Files (x86)` 與 `%LOCALAPPDATA%` 底下的標準安裝路徑。 |
|
|
62
|
+
| Linux | 許多發行版內建套件庫可能提供較舊的 Node.js;建議使用 NodeSource、nvm 或官方 Node.js LTS 來源安裝。請安裝 Google Chrome Stable,並確認 `google-chrome` 或 `google-chrome-stable` 位於 `PATH` 中;Snap、Flatpak 或 Chromium 安裝方式可能不符合預設偵測邏輯。 |
|
|
63
|
+
|
|
33
64
|
不需要安裝全域 `mcp-cli` 執行檔。Rust binary 會透過 Cargo 從 `https://github.com/doggy8088/mcp-cli` 使用 `mcp-cli` 作為 dependency。
|
|
34
65
|
|
|
35
66
|
## 安裝與建置
|
|
36
67
|
|
|
37
|
-
### 1.
|
|
68
|
+
### 1. 快速安裝 (推薦)
|
|
38
69
|
|
|
39
|
-
|
|
70
|
+
若您只想使用已編譯好的 Release 版本(不需要安裝 Rust 工具鏈),可直接使用以下一鍵安裝腳本。安裝腳本會自動檢查 Node.js 需求、下載適合您系統架構的 ask-bridge binary,並將其放入 `~/.local/bin/` 目錄中。
|
|
40
71
|
|
|
72
|
+
#### macOS / Linux
|
|
73
|
+
請開啟終端機執行:
|
|
41
74
|
```bash
|
|
42
|
-
|
|
75
|
+
curl -fsSL https://raw.githubusercontent.com/doggy8088/ask-bridge/main/install.sh | bash
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Windows
|
|
79
|
+
請開啟 PowerShell (建議以系統管理員身分) 執行:
|
|
80
|
+
```powershell
|
|
81
|
+
irm https://raw.githubusercontent.com/doggy8088/ask-bridge/main/install.ps1 | iex
|
|
43
82
|
```
|
|
44
83
|
|
|
45
|
-
|
|
84
|
+
> [!NOTE]
|
|
85
|
+
> 請確保安裝路徑(macOS/Linux 為 `~/.local/bin`;Windows 為 `$HOME\.local\bin`)已加入您的系統 `PATH` 環境變數中。
|
|
86
|
+
> 正式 CLI 命令為 `ask-bridge`;安裝流程也會提供 `ask` 作為向後相容 alias。以下範例皆以 `ask-bridge` 為準。
|
|
87
|
+
|
|
88
|
+
### 2. 從原始碼建置與安裝 (適用於開發者)
|
|
89
|
+
|
|
90
|
+
若您想從原始碼編譯並安裝,請在複製本專案後,在專案目錄下執行:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
make install
|
|
94
|
+
```
|
|
46
95
|
|
|
47
|
-
|
|
96
|
+
此命令會自動檢查 Node.js 環境、檢查與安裝 Chrome 瀏覽器、建置最佳化的 binary,並在 `~/.local/bin/ask-bridge` 建立正式命令符號連結 (symlink),同時建立 `ask` alias。
|
|
48
97
|
|
|
49
|
-
###
|
|
98
|
+
### 3. 只建置不安裝
|
|
50
99
|
|
|
51
100
|
若只想建置 binary:
|
|
52
101
|
|
|
@@ -56,20 +105,36 @@ cargo build --release
|
|
|
56
105
|
|
|
57
106
|
編譯後的 binary 會位於 `target/release/ask-bridge`。
|
|
58
107
|
|
|
108
|
+
### 4. 安裝 Agent Skill
|
|
109
|
+
|
|
110
|
+
本專案提供 `ask-bridge` Agent Skill,讓支援 Skills 的 Coding Agent 可以在適合的情境下,自主使用 `ask-bridge` 將探索性研究、摘要、文件分析或方案比較等工作委派給 ChatGPT 或 Gemini 網站。
|
|
111
|
+
|
|
112
|
+
請使用 `npx skills` 安裝,不需要手動複製 `skills/` 目錄:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx skills add doggy8088/ask-bridge --skill ask-bridge
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
若要安裝到 Codex 的全域 Skills 目錄,可指定 agent 與 global scope:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npx skills add doggy8088/ask-bridge --skill ask-bridge --agent codex --global
|
|
122
|
+
```
|
|
123
|
+
|
|
59
124
|
## 使用方式
|
|
60
125
|
|
|
61
126
|
### 1. 首次設定:登入 provider
|
|
62
127
|
|
|
63
|
-
送出 prompt 前,需要先登入所選 provider
|
|
128
|
+
送出 prompt 前,需要先登入所選 provider。未設定全域 provider 時,ChatGPT 為預設:
|
|
64
129
|
|
|
65
130
|
```bash
|
|
66
|
-
ask login
|
|
131
|
+
ask-bridge login
|
|
67
132
|
```
|
|
68
133
|
|
|
69
134
|
若要登入 Gemini:
|
|
70
135
|
|
|
71
136
|
```bash
|
|
72
|
-
ask --provider gemini login
|
|
137
|
+
ask-bridge --provider gemini login
|
|
73
138
|
```
|
|
74
139
|
|
|
75
140
|
此命令會:
|
|
@@ -81,13 +146,39 @@ ask --provider gemini login
|
|
|
81
146
|
|
|
82
147
|
此流程通常只需要執行一次。
|
|
83
148
|
|
|
149
|
+
#### 全域 provider 設定
|
|
150
|
+
|
|
151
|
+
若希望未指定 `--provider` 時預設使用 Gemini,可用 `ask-bridge config` 指定:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
ask-bridge config --provider gemini
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
若要改回 ChatGPT:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
ask-bridge config --provider chatgpt
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
可檢視目前設定:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
ask-bridge config
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`--provider` 的優先權高於全域設定檔,因此以下命令會暫時使用 ChatGPT:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
ask-bridge --provider chatgpt "請摘要這段內容。"
|
|
173
|
+
```
|
|
174
|
+
|
|
84
175
|
### 2. 直接提問
|
|
85
176
|
|
|
86
177
|
將 prompt 作為 argument 傳入:
|
|
87
178
|
|
|
88
179
|
```bash
|
|
89
|
-
ask "Rust struct 和 tuple 有什麼差異?"
|
|
90
|
-
ask --provider gemini "Rust struct 和 tuple 有什麼差異?"
|
|
180
|
+
ask-bridge "Rust struct 和 tuple 有什麼差異?"
|
|
181
|
+
ask-bridge --provider gemini "Rust struct 和 tuple 有什麼差異?"
|
|
91
182
|
```
|
|
92
183
|
|
|
93
184
|
執行後:
|
|
@@ -98,12 +189,12 @@ ask --provider gemini "Rust struct 和 tuple 有什麼差異?"
|
|
|
98
189
|
|
|
99
190
|
### 3. 開啟全新對話
|
|
100
191
|
|
|
101
|
-
預設情況下,`ask` 會重用既有所選 provider 分頁,以避免建立過多分頁。
|
|
192
|
+
預設情況下,`ask-bridge` 會重用既有所選 provider 分頁,以避免建立過多分頁。
|
|
102
193
|
|
|
103
194
|
若要開啟全新的 provider 對話,使用 `--new`:
|
|
104
195
|
|
|
105
196
|
```bash
|
|
106
|
-
ask "誰是保哥?" --new
|
|
197
|
+
ask-bridge "誰是保哥?" --new
|
|
107
198
|
```
|
|
108
199
|
|
|
109
200
|
此模式會開啟新的所選 provider 分頁,並清理先前同一 provider 的分頁。
|
|
@@ -115,19 +206,19 @@ ask "誰是保哥?" --new
|
|
|
115
206
|
若想觀察 Chrome 的操作過程,或需要手動檢查頁面狀態,可改用 headful 模式:
|
|
116
207
|
|
|
117
208
|
```bash
|
|
118
|
-
ask "誰是保哥?" --headless=false
|
|
209
|
+
ask-bridge "誰是保哥?" --headless=false
|
|
119
210
|
```
|
|
120
211
|
|
|
121
|
-
`ask login` 會強制使用 headful 模式,方便你和瀏覽器 UI 互動;其他 subcommand 若要可見瀏覽器,請明確加上 `--headless=false`。
|
|
212
|
+
`ask-bridge login` 會強制使用 headful 模式,方便你和瀏覽器 UI 互動;其他 subcommand 若要可見瀏覽器,請明確加上 `--headless=false`。
|
|
122
213
|
|
|
123
214
|
### 5. Verbose 模式
|
|
124
215
|
|
|
125
|
-
預設情況下,`ask` 只輸出所選 provider 的最終回覆,隱藏背景控制訊息。
|
|
216
|
+
預設情況下,`ask-bridge` 只輸出所選 provider 的最終回覆,隱藏背景控制訊息。
|
|
126
217
|
|
|
127
218
|
若要查看完整瀏覽器自動化流程,加入 `--verbose`:
|
|
128
219
|
|
|
129
220
|
```bash
|
|
130
|
-
ask "誰是保哥?" --verbose
|
|
221
|
+
ask-bridge "誰是保哥?" --verbose
|
|
131
222
|
```
|
|
132
223
|
|
|
133
224
|
Verbose 模式會顯示類似以下流程:
|
|
@@ -143,27 +234,27 @@ Verbose 模式會顯示類似以下流程:
|
|
|
143
234
|
使用 `-v` 或 `--version` 顯示目前版本號:
|
|
144
235
|
|
|
145
236
|
```bash
|
|
146
|
-
ask -v
|
|
237
|
+
ask-bridge -v
|
|
147
238
|
```
|
|
148
239
|
|
|
149
240
|
### 7. Pipe 與 stdin
|
|
150
241
|
|
|
151
|
-
可透過 pipe 將文字或檔案內容傳入 `ask`:
|
|
242
|
+
可透過 pipe 將文字或檔案內容傳入 `ask-bridge`:
|
|
152
243
|
|
|
153
244
|
```bash
|
|
154
|
-
echo "用一句話解釋 quantum computing" | ask
|
|
245
|
+
echo "用一句話解釋 quantum computing" | ask-bridge
|
|
155
246
|
```
|
|
156
247
|
|
|
157
|
-
若同時提供 prompt argument,`ask` 會先送出該 prompt,接著加上兩個換行後再附加管道內容:
|
|
248
|
+
若同時提供 prompt argument,`ask-bridge` 會先送出該 prompt,接著加上兩個換行後再附加管道內容:
|
|
158
249
|
|
|
159
250
|
```bash
|
|
160
|
-
cat /Users/will/.copilot/session-state/46cc0f1c-79fd-4622-9548-a0b7fa3794be/research/does-cursor-support-byok.md | ask 'What is this?'
|
|
251
|
+
cat /Users/will/.copilot/session-state/46cc0f1c-79fd-4622-9548-a0b7fa3794be/research/does-cursor-support-byok.md | ask-bridge 'What is this?'
|
|
161
252
|
```
|
|
162
253
|
|
|
163
254
|
也可以讀取檔案內容:
|
|
164
255
|
|
|
165
256
|
```bash
|
|
166
|
-
cat src/main.rs | ask "這段 Rust code 有記憶體洩漏風險嗎?"
|
|
257
|
+
cat src/main.rs | ask-bridge "這段 Rust code 有記憶體洩漏風險嗎?"
|
|
167
258
|
```
|
|
168
259
|
|
|
169
260
|
### 8. 附上圖片或文件
|
|
@@ -175,8 +266,8 @@ cat src/main.rs | ask "這段 Rust code 有記憶體洩漏風險嗎?"
|
|
|
175
266
|
使用 `--image` 附上一或多張本機圖片(可重複指定)。此功能目前支援 ChatGPT;Gemini 圖片輸入尚未支援,搭配 `--provider gemini` 使用會立即回報錯誤。
|
|
176
267
|
|
|
177
268
|
```bash
|
|
178
|
-
ask "請描述這張圖片的內容。" --image screenshot.png
|
|
179
|
-
ask "比較這兩張圖的差異。" --image v1.png --image v2.png
|
|
269
|
+
ask-bridge "請描述這張圖片的內容。" --image screenshot.png
|
|
270
|
+
ask-bridge "比較這兩張圖的差異。" --image v1.png --image v2.png
|
|
180
271
|
```
|
|
181
272
|
|
|
182
273
|
支援的格式包含 PNG、JPEG、GIF、WebP、SVG、BMP 等。
|
|
@@ -186,15 +277,15 @@ ask "比較這兩張圖的差異。" --image v1.png --image v2.png
|
|
|
186
277
|
使用 `--file` 附上一或多份本機文件(可重複指定),例如 PDF、Word、Excel、PowerPoint、純文字、Markdown、CSV、JSON、程式碼等。ChatGPT 與 Gemini 都支援此流程。
|
|
187
278
|
|
|
188
279
|
```bash
|
|
189
|
-
ask "請摘要這份 PDF 的重點。" --file report.pdf
|
|
190
|
-
ask "這份 CSV 總共有幾筆資料?" --file data.csv
|
|
191
|
-
ask "幫我檢查這段程式碼有沒有問題。" --file src/main.rs
|
|
280
|
+
ask-bridge "請摘要這份 PDF 的重點。" --file report.pdf
|
|
281
|
+
ask-bridge "這份 CSV 總共有幾筆資料?" --file data.csv
|
|
282
|
+
ask-bridge "幫我檢查這段程式碼有沒有問題。" --file src/main.rs
|
|
192
283
|
```
|
|
193
284
|
|
|
194
285
|
也可以同時附上圖片與文件:
|
|
195
286
|
|
|
196
287
|
```bash
|
|
197
|
-
ask "請對照這張設計圖與規格文件,指出不一致的地方。" --image design.png --file spec.docx
|
|
288
|
+
ask-bridge "請對照這張設計圖與規格文件,指出不一致的地方。" --image design.png --file spec.docx
|
|
198
289
|
```
|
|
199
290
|
|
|
200
291
|
#### 顯示上傳結果
|
|
@@ -206,11 +297,11 @@ provider 回覆後,可使用 `-i` / `--image-output` 指定生成圖片的下
|
|
|
206
297
|
使用 `--model` 在送出 prompt 前自動切換 provider 的模型。比對時不分大小寫與標點符號(`-`、`.`、空格 等)。
|
|
207
298
|
|
|
208
299
|
```bash
|
|
209
|
-
ask "用幾句話介紹 Rust。" --model GPT-5.4
|
|
210
|
-
ask "證明這個數學問題。" --model o3
|
|
211
|
-
ask "快速翻譯這段話。" --model 即時
|
|
212
|
-
ask --provider gemini "用幾句話介紹 Rust。" --model "3.5 Flash"
|
|
213
|
-
ask --provider gemini "用幾句話介紹 Rust。" --model "3.1 Pro"
|
|
300
|
+
ask-bridge "用幾句話介紹 Rust。" --model GPT-5.4
|
|
301
|
+
ask-bridge "證明這個數學問題。" --model o3
|
|
302
|
+
ask-bridge "快速翻譯這段話。" --model 即時
|
|
303
|
+
ask-bridge --provider gemini "用幾句話介紹 Rust。" --model "3.5 Flash"
|
|
304
|
+
ask-bridge --provider gemini "用幾句話介紹 Rust。" --model "3.1 Pro"
|
|
214
305
|
```
|
|
215
306
|
|
|
216
307
|
可用的模型名稱(視帳號權限與 provider UI 而定):
|
|
@@ -219,32 +310,32 @@ ask --provider gemini "用幾句話介紹 Rust。" --model "3.1 Pro"
|
|
|
219
310
|
- **ChatGPT 思考強度**:`智慧`、`即時`、`中等`、`高`、`超高`、`專業`
|
|
220
311
|
- **Gemini 模式**:`3.5 Flash`、`3.1 Flash-Lite`、`3.1 Pro`
|
|
221
312
|
|
|
222
|
-
> 若指定的名稱在選單中找不到,`ask` 會回報 `Model switch failed: error: model not found in menu` 並中止,不會送出 prompt。
|
|
313
|
+
> 若指定的名稱在選單中找不到,`ask-bridge` 會回報 `Model switch failed: error: model not found in menu` 並中止,不會送出 prompt。
|
|
223
314
|
|
|
224
315
|
### 10. 只開啟 provider
|
|
225
316
|
|
|
226
317
|
若只想快速開啟瀏覽器並進入所選 provider:
|
|
227
318
|
|
|
228
319
|
```bash
|
|
229
|
-
ask open
|
|
230
|
-
ask --provider gemini open
|
|
320
|
+
ask-bridge open
|
|
321
|
+
ask-bridge --provider gemini open
|
|
231
322
|
```
|
|
232
323
|
|
|
233
324
|
### 11. 關閉瀏覽器 instance
|
|
234
325
|
|
|
235
|
-
若要關閉 `ask` 管理的 Chrome debug profile instance:
|
|
326
|
+
若要關閉 `ask-bridge` 管理的 Chrome debug profile instance:
|
|
236
327
|
|
|
237
328
|
```bash
|
|
238
|
-
ask close
|
|
329
|
+
ask-bridge close
|
|
239
330
|
```
|
|
240
331
|
|
|
241
|
-
`close` 只會關閉使用 `~/.config/ask-bridge/chrome-profile` 且監聽 debug port `9223` 的 `ask` Chrome instance;若該 port 被非 `ask` Chrome 程序占用,會回報錯誤而不會關閉它。
|
|
332
|
+
`close` 只會關閉使用 `~/.config/ask-bridge/chrome-profile` 且監聽 debug port `9223` 的 `ask-bridge` Chrome instance;若該 port 被非 `ask-bridge` Chrome 程序占用,會回報錯誤而不會關閉它。
|
|
242
333
|
|
|
243
334
|
## 運作原理
|
|
244
335
|
|
|
245
|
-
1. **瀏覽器初始化**:`ask` 會檢查 Chrome 是否正在監聽 debug port `9223`。若沒有,會以專屬 profile 目錄 `~/.config/ask-bridge/chrome-profile` 啟動 Google Chrome。
|
|
336
|
+
1. **瀏覽器初始化**:`ask-bridge` 會檢查 Chrome 是否正在監聽 debug port `9223`。若沒有,會以專屬 profile 目錄 `~/.config/ask-bridge/chrome-profile` 啟動 Google Chrome。
|
|
246
337
|
2. **MCP Bridge 設定**:啟動時會自動寫入 `~/.config/ask-bridge/mcp_servers.json`,預設設定 Chrome DevTools MCP server,使用 `chrome-devtools-mcp@latest` 與 `--browser-url=http://127.0.0.1:9223`。
|
|
247
|
-
3. **Client 呼叫**:`ask` 透過內建的 `doggy8088/mcp-cli` Rust library dependency 呼叫 MCP tools,例如 `list_pages`、`select_page`、`type_text` 與 `evaluate_script`,不依賴系統上的外部 `mcp-cli` 命令。
|
|
338
|
+
3. **Client 呼叫**:`ask-bridge` 透過內建的 `doggy8088/mcp-cli` Rust library dependency 呼叫 MCP tools,例如 `list_pages`、`select_page`、`type_text` 與 `evaluate_script`,不依賴系統上的外部 `mcp-cli` 命令。
|
|
248
339
|
4. **狀態輪詢**:provider 產生回覆期間,工具會以 JavaScript 檢查送出與停止按鈕狀態,擷取回覆元素的文字內容,並輸出到 `stdout`。
|
|
249
340
|
|
|
250
341
|
## 相關文件
|
package/npm/postinstall.cjs
CHANGED
|
@@ -157,9 +157,26 @@ async function installFromRelease() {
|
|
|
157
157
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
function checkChrome() {
|
|
161
|
+
const chromePaths = {
|
|
162
|
+
darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
163
|
+
linux: '/usr/bin/google-chrome',
|
|
164
|
+
win32: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
165
|
+
};
|
|
166
|
+
const chromePath = chromePaths[process.platform];
|
|
167
|
+
if (chromePath && !existsSync(chromePath)) {
|
|
168
|
+
console.warn('');
|
|
169
|
+
console.warn('⚠️ Google Chrome was not found on your system.');
|
|
170
|
+
console.warn(' ask-bridge requires Chrome to automate ChatGPT / Gemini.');
|
|
171
|
+
console.warn(' Please install it from: https://www.google.com/chrome/');
|
|
172
|
+
console.warn('');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
160
176
|
async function main() {
|
|
161
177
|
if (installFromLocalBuild()) return;
|
|
162
178
|
await installFromRelease();
|
|
179
|
+
checkChrome();
|
|
163
180
|
}
|
|
164
181
|
|
|
165
182
|
if (require.main === module) {
|
|
@@ -173,6 +190,7 @@ module.exports = {
|
|
|
173
190
|
TARGETS,
|
|
174
191
|
artifactName,
|
|
175
192
|
cargoTarget,
|
|
193
|
+
checkChrome,
|
|
176
194
|
findExtractedBinary,
|
|
177
195
|
platformKey,
|
|
178
196
|
releaseBaseUrl,
|
package/package.json
CHANGED