ask-bridge 0.2.11 → 0.4.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/README.en.md +195 -4
- package/README.md +305 -5
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -19,7 +19,7 @@ This tool is especially useful for:
|
|
|
19
19
|
|
|
20
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
21
|
|
|
22
|
-
|
|
22
|
+
With the default browser backend, `ask-bridge` operates inside a real Chrome browser with a **persistent user profile**. This means:
|
|
23
23
|
- You log in manually **once** (`ask-bridge login`).
|
|
24
24
|
- You can solve CAPTCHAs, pass provider-side browser checks, and access the selected provider's web features like a normal user.
|
|
25
25
|
- Your session cookies, login state, and chat history are saved persistently.
|
|
@@ -40,6 +40,7 @@ Unlike typical API clients, `ask-bridge` operates inside a real Chrome browser w
|
|
|
40
40
|
- **📎 Image & File Attachments**: Attach local images with `--image` (supported on ChatGPT and Claude), or documents (PDF, Word, Excel, plain text, Markdown, JSON, etc.) with `--file`; Gemini currently supports `--file` and rejects `--image`.
|
|
41
41
|
- **🔀 Model and Reasoning Selection**: Use `--model` for provider models and `--reasoning` for ChatGPT reasoning effort or Gemini Extended Thinking.
|
|
42
42
|
- **Resume Conversations**: Use `--session`, `--session-id`, or `--session-url` to continue an existing provider conversation with a new terminal prompt.
|
|
43
|
+
- **Optional SIWC backend**: Use ChatGPT plan usage through OAuth and the public Responses API without an API key. Sign-in opens your system browser; subsequent questions do not launch Chrome. See the [SIWC quick start](#14-use-your-chatgpt-plan-through-siwc).
|
|
43
44
|
- **Response Timeout**: Use `--timeout <seconds>` to control how long to wait for a provider response, defaulting to `300` seconds.
|
|
44
45
|
- **🔍 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.
|
|
45
46
|
- **Version Info**: Use `-v` or `--version` to print the current version number.
|
|
@@ -48,7 +49,7 @@ Unlike typical API clients, `ask-bridge` operates inside a real Chrome browser w
|
|
|
48
49
|
|
|
49
50
|
## 🛠️ Prerequisites
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
The default browser backend requires the following. For SIWC-specific differences, see the [SIWC quick start](#14-use-your-chatgpt-plan-through-siwc):
|
|
52
53
|
|
|
53
54
|
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`.
|
|
54
55
|
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.
|
|
@@ -138,6 +139,8 @@ npx skills add doggy8088/ask-bridge --skill ask-bridge --agent codex --global
|
|
|
138
139
|
|
|
139
140
|
### 1. First Time Setup: Login to a provider
|
|
140
141
|
|
|
142
|
+
These instructions sign into the browser backend. For SIWC OAuth authorization, follow the [SIWC quick start](#14-use-your-chatgpt-plan-through-siwc).
|
|
143
|
+
|
|
141
144
|
Before sending prompts, you need to log in to the selected provider. ChatGPT is the default when no global provider is configured:
|
|
142
145
|
|
|
143
146
|
```bash
|
|
@@ -349,7 +352,7 @@ ask-bridge --provider claude "Introduce Rust in a few sentences." --model Sonnet
|
|
|
349
352
|
|
|
350
353
|
Argument rules:
|
|
351
354
|
|
|
352
|
-
- **ChatGPT**: `--reasoning` accepts `
|
|
355
|
+
- **ChatGPT**: `--reasoning` accepts `instant`, `medium`, `high`, and `xhigh`, plus the corresponding aliases `即時`, `中`, `中等`, `高`, and `極高`. The redesigned ChatGPT reasoning slider no longer offers Auto, so `auto` only works where that option still exists. ask-bridge always uses ChatGPT's Chat mode and switches the composer back from Work mode before sending.
|
|
353
356
|
- **Gemini**: `--reasoning extended` selects Extended Thinking. Omit `--model` or combine it with an available Pro model.
|
|
354
357
|
- **Claude**: `--reasoning` is unsupported. Existing Sonnet, Opus, and Haiku `--model` selection is unchanged.
|
|
355
358
|
|
|
@@ -377,10 +380,198 @@ ask-bridge close
|
|
|
377
380
|
|
|
378
381
|
`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.
|
|
379
382
|
|
|
380
|
-
|
|
383
|
+
* * *
|
|
384
|
+
|
|
385
|
+
### 14. Use Your ChatGPT Plan Through SIWC
|
|
386
|
+
|
|
387
|
+
**SIWC is opt-in. Browser/CDP remains the default unless you change the configuration.** Sign in with ChatGPT authorizes access to the public Responses API using your ChatGPT plan, without an API key. Use it for single-turn text questions, summaries, and comparisons. Choose the browser backend when you need existing web conversations, attachments, or image generation.
|
|
388
|
+
|
|
389
|
+
#### Providers, backends, and usage
|
|
390
|
+
|
|
391
|
+
| Setting | Meaning |
|
|
392
|
+
| --- | --- |
|
|
393
|
+
| `--provider chatgpt\|gemini\|claude` | Selects the AI service. SIWC currently supports ChatGPT only. |
|
|
394
|
+
| `--backend browser\|siwc` | Selects the backend for this invocation and overrides the saved preference. |
|
|
395
|
+
| `config --chatgpt-backend siwc` | Saves the default ChatGPT backend. `--chatgpt-backend` is not an alias for `--backend`; it only takes effect with `config`. |
|
|
396
|
+
| Usage source | ChatGPT Work/Codex plan usage or credits, rather than API-key billing. |
|
|
397
|
+
| Sign-in state | SIWC OAuth credentials are separate from browser cookies. Signing into the website does not authorize SIWC. |
|
|
398
|
+
|
|
399
|
+
**SIWC does not provide free or unlimited tokens, or guarantee lower total token usage or cost.** If your primary Coding Agent shares the same plan allowance, both may consume that allowance. Eligibility, models, quotas, and credits depend on the account and workspace; a plan name alone does not guarantee access.
|
|
400
|
+
|
|
401
|
+
#### Quick start: sign in and ask a question
|
|
402
|
+
|
|
403
|
+
Install `ask-bridge` using the installation instructions above, then run:
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
# 1. Sign in and authorize ChatGPT plan usage in your system browser
|
|
407
|
+
ask-bridge --provider chatgpt --backend siwc login
|
|
408
|
+
|
|
409
|
+
# 2. Wait for the terminal to confirm sign-in, then ask a question
|
|
410
|
+
ask-bridge --provider chatgpt --backend siwc "Explain three situations where this tool is useful"
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
The first sign-in performs dynamic registration. OAuth authorization opens your system browser; subsequent questions use HTTP streaming and **do not launch Chrome or use CDP/MCP**. SIWC inference itself does not require Node.js/npx. The current installation scripts still check browser-backend dependencies, so follow the installation instructions above.
|
|
414
|
+
|
|
415
|
+
Use an account authorized for ChatGPT plan usage, grant that access on the authorization page, and wait for the browser to return to the local callback. After sign-in, the tool attempts to list up to 10 available model names and slugs. If the browser does not open automatically, use the authorization URL printed in the terminal. The login callback has a fixed 300-second wait; the question's `--timeout` option does not change it.
|
|
416
|
+
|
|
417
|
+
#### Text input, models, timeouts, and output files
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
# Supply a plain-text document as context
|
|
421
|
+
cat report.md | ask-bridge --provider chatgpt --backend siwc "Summarize the key points and open questions"
|
|
422
|
+
|
|
423
|
+
# Read the entire prompt from stdin
|
|
424
|
+
ask-bridge --provider chatgpt --backend siwc < prompt.txt
|
|
425
|
+
|
|
426
|
+
# Set the overall request timeout and save the completed answer
|
|
427
|
+
ask-bridge --provider chatgpt --backend siwc --timeout 120 -o answer.md "Compare two technical approaches"
|
|
428
|
+
|
|
429
|
+
# Replace MODEL_SLUG with an actual slug shown after sign-in
|
|
430
|
+
ask-bridge --provider chatgpt --backend siwc --model "MODEL_SLUG" "Compare two technical approaches"
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
| Option/input | SIWC behavior |
|
|
434
|
+
| --- | --- |
|
|
435
|
+
| Prompt plus stdin | Sends the prompt, two newline characters, and stdin together. Other files are not read automatically. |
|
|
436
|
+
| `--model` | Validated against the account's API model catalog on each request. Accepts a slug or full display name, with case-insensitive name matching. Defaults to the first catalog entry, independently of the web model selector. An unavailable model lists available slugs and aborts without selecting a substitute. |
|
|
437
|
+
| `--timeout` | Defaults to 300 seconds and covers token refresh, the model catalog, and inference streaming. Preflight HTTP requests also have a 30-second limit, so they may fail before the overall deadline. |
|
|
438
|
+
| `-o` / `--output` | Text still streams to the terminal. The file is written only after the successful `response.completed` event. A successful request overwrites an existing file; its parent directory must already exist. |
|
|
439
|
+
|
|
440
|
+
**Partial terminal output is not proof of success.** A usage error, disconnection, or timeout can occur after streaming starts. The process then exits with a nonzero code and does not perform the `-o` write, leaving any existing output file untouched by that inference failure. Shell redirection with `>` can leave partial output; use `-o` and check the exit code when you need a completed answer.
|
|
441
|
+
|
|
442
|
+
#### How do I pass my current working context?
|
|
443
|
+
|
|
444
|
+
**Pipe the relevant text through stdin and describe the task in the prompt.** SIWC does not automatically read your working directory, Git state, IDE selection, or Coding Agent conversation. It receives only what you supply. Passing a file's text through stdin is different from uploading it with `--file`.
|
|
445
|
+
|
|
446
|
+
These examples use Bash/zsh. Label multiple sources so the model can distinguish them:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
# Compare two documents with explicit source labels
|
|
450
|
+
{
|
|
451
|
+
printf '\n--- a.md ---\n'
|
|
452
|
+
cat a.md
|
|
453
|
+
printf '\n--- b.md ---\n'
|
|
454
|
+
cat b.md
|
|
455
|
+
} | ask-bridge --provider chatgpt --backend siwc "Compare these documents and identify contradictions"
|
|
456
|
+
|
|
457
|
+
# Review unstaged changes; use git diff --cached for staged changes
|
|
458
|
+
# git diff does not include untracked files
|
|
459
|
+
git diff -- src/main.rs | ask-bridge --provider chatgpt --backend siwc "Review this diff for logic risks"
|
|
460
|
+
|
|
461
|
+
# Capture test output before asking for analysis
|
|
462
|
+
cargo test > test-output.txt 2>&1
|
|
463
|
+
cat test-output.txt | ask-bridge --provider chatgpt --backend siwc "Analyze the failures and suggest fixes"
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
In Windows PowerShell, use `Get-Content -Raw` to supply text:
|
|
467
|
+
|
|
468
|
+
```powershell
|
|
469
|
+
Get-Content -Raw -Encoding utf8 report.md | ask-bridge --provider chatgpt --backend siwc "Summarize the key points"
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Each invocation is an independent question. The tool does not automatically save or resend earlier context, and `--session` cannot resume a web conversation. To continue a discussion, select the previous question, answer, and necessary background yourself and include them in the next input:
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
# Continue only if the first request succeeds, avoiding a stale summary file
|
|
476
|
+
if cat report.md | ask-bridge --provider chatgpt --backend siwc -o summary.md "Summarize the report and list risks"; then
|
|
477
|
+
{
|
|
478
|
+
printf '\n--- Previous question ---\nSummarize the report and list risks.\n'
|
|
479
|
+
printf '\n--- Previous answer ---\n'
|
|
480
|
+
cat summary.md
|
|
481
|
+
printf '\n--- Relevant source ---\n'
|
|
482
|
+
cat report.md
|
|
483
|
+
} | ask-bridge --provider chatgpt --backend siwc -o follow-up.md "Use the supplied summary and source to propose three improvements"
|
|
484
|
+
fi
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
This manually supplies text context; it is not built-in multi-turn conversation support. Include relevant excerpts and remove passwords, tokens, personal information, or other material you should not send. Repeatedly including all history increases input tokens, latency, and plan usage, and may exceed the model's context limit. Do not pipe PDF, Word, or image binary data as text; extract text first or use the browser backend's supported attachments.
|
|
488
|
+
|
|
489
|
+
#### Save a default or switch back to the browser
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
# Change only the ChatGPT backend preference, preserving other settings
|
|
493
|
+
ask-bridge config --chatgpt-backend siwc
|
|
494
|
+
ask-bridge config
|
|
495
|
+
|
|
496
|
+
# The backend flag is now optional; keep ChatGPT explicit
|
|
497
|
+
ask-bridge --provider chatgpt "Summarize the risks in this design"
|
|
498
|
+
|
|
499
|
+
# Use the browser for this invocation without changing the saved preference
|
|
500
|
+
# Sign into the website first if necessary
|
|
501
|
+
ask-bridge --provider chatgpt --backend browser login
|
|
502
|
+
ask-bridge --provider chatgpt --backend browser "Answer this using the web interface"
|
|
503
|
+
|
|
504
|
+
# Restore the default ChatGPT browser backend
|
|
505
|
+
ask-bridge config --chatgpt-backend browser
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Precedence is `--backend` > `chatgptBackend` in `config.json` > `browser`. Saving SIWC does not change the default provider. If yours is Gemini or Claude, specify `--provider chatgpt` to use SIWC. Gemini/Claude ignore the saved ChatGPT backend preference, but explicitly combining either with `--backend siwc` is an error.
|
|
509
|
+
|
|
510
|
+
#### Browser and SIWC feature matrix
|
|
511
|
+
|
|
512
|
+
| Feature | Browser backend | SIWC backend |
|
|
513
|
+
| --- | --- | --- |
|
|
514
|
+
| Services | ChatGPT, Gemini, Claude | ChatGPT only |
|
|
515
|
+
| Sign-in and transport | Website login, Chrome/CDP/MCP | OAuth; HTTP/SSE for questions |
|
|
516
|
+
| Single-turn text, stdin, `-o` | Supported | Supported |
|
|
517
|
+
| Model selection | Web model menu | Account API model catalog |
|
|
518
|
+
| `--session` / `--session-id` / `--session-url` | Supported | Rejected; cannot read `chatgpt.com/c/...` |
|
|
519
|
+
| `--new` / `--temporary` | Supported | Rejected; each request is independent, with no web temporary-chat mode |
|
|
520
|
+
| `--image` / `--file` | Provider-dependent | Not implemented in this tool; rejected |
|
|
521
|
+
| Image generation and `--image-output` / `-i` | Website-dependent | Unsupported; image-output options are rejected |
|
|
522
|
+
| `--reasoning` | Provider-dependent | Not implemented; rejected |
|
|
523
|
+
| `batch` | Supported | Rejected; explicitly use `--backend browser` if SIWC is your default |
|
|
524
|
+
| Browser commands such as `open` / `get` / `close` | Supported | Rejected; explicitly use `--backend browser` |
|
|
525
|
+
| Usage source | Website product/account limits | ChatGPT Work/Codex plan usage or credits |
|
|
526
|
+
|
|
527
|
+
There is no `--download-images` CLI flag. `downloadImages` is a browser batch-job JSON field; SIWC rejects `batch`, so it cannot enable downloads through that field.
|
|
528
|
+
|
|
529
|
+
The tool's SIWC MVP supports single-turn text inference, without file search, Code Interpreter, image generation, or hosted MCP/connectors. Missing attachment support is a limitation of this tool, not a claim that the upstream SIWC API rejects all image or document input. This HTTP path uses `store: false` and `stream: true`, and does not use `previous_response_id` to continue a conversation. `store: false` is not a guarantee of zero service-side data retention. See OpenAI's [models and inference](https://developers.openai.com/siwc/token-sharing-open-source/models-and-inference) and [Preview limitations](https://developers.openai.com/siwc/token-sharing-open-source/preview-limitations) for API capabilities.
|
|
530
|
+
|
|
531
|
+
#### Reauthorize, sign out, and manage credentials
|
|
532
|
+
|
|
533
|
+
```bash
|
|
534
|
+
# Reauthorize after expiration, revocation, or a refresh failure
|
|
535
|
+
ask-bridge --provider chatgpt --backend siwc login
|
|
536
|
+
|
|
537
|
+
# Clear locally stored SIWC accounts and tokens
|
|
538
|
+
ask-bridge --provider chatgpt --backend siwc logout
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Credentials are saved atomically in `~/.config/ask-bridge/siwc-credentials.json`, with `0600` permissions on Unix. That Unix permission notation does not apply to Windows. The tool refreshes expiring access tokens and saves rotated refresh tokens. Do not share the credential file, commit it to Git, or paste it into an issue.
|
|
542
|
+
|
|
543
|
+
`logout` clears local accounts and tokens while preserving the stable host ID, so the file may remain. It does not call a server-side revocation API, sign you out of the ChatGPT website, or reset your default backend to `browser`. Sign in again before the next SIWC request.
|
|
544
|
+
|
|
545
|
+
#### Troubleshooting
|
|
546
|
+
|
|
547
|
+
| Symptom | Action |
|
|
548
|
+
| --- | --- |
|
|
549
|
+
| `not signed in`, 401, or refresh failure | Run the full SIWC `login` command above. Website login cannot replace OAuth authorization. |
|
|
550
|
+
| Authorization declined or plan-usage permission missing | Check the account, workspace, and plan-usage authorization, then sign in again. A subscription name alone does not guarantee permission. |
|
|
551
|
+
| Unavailable model or empty catalog | Use a slug listed in the error. For an empty catalog, check account permissions and service availability. |
|
|
552
|
+
| 429, `subscription_sharing_usage_limit_exceeded`, or `subscription_sharing_usage_unavailable` | Check plan usage, credits, or account availability and follow the error. These errors may arrive after streaming starts. |
|
|
553
|
+
| Timeout, interrupted stream, or no completion event | The request failed; displayed text may be incomplete. Check connectivity before deciding whether to submit again. |
|
|
554
|
+
| Incompatible option | Remove it or explicitly select `--backend browser` and sign into the website. |
|
|
555
|
+
| `UnknownIssuer` | Ask your administrator to verify the required CA is installed in the system trust store. Do not disable TLS certificate verification. |
|
|
556
|
+
|
|
557
|
+
**Failures never automatically switch to Browser/CDP or API-key billing.** HTTPS uses rustls with built-in CAs and the operating system trust store. Connection errors include their underlying causes without request URLs, headers, or bodies. In TLS-inspection environments such as corporate proxies or antivirus HTTPS scanning, a trusted interceptor can see connection contents, including token exchange and refresh. Use SIWC only when you trust that environment.
|
|
558
|
+
|
|
559
|
+
#### Verification scope and references
|
|
560
|
+
|
|
561
|
+
According to the [issue #40 closure record](https://github.com/doggy8088/ask-bridge/issues/40#issuecomment-6956849874), as of 2026-11-17:
|
|
562
|
+
|
|
563
|
+
- OAuth sign-in and a single text conversation were verified live on Windows.
|
|
564
|
+
- Refresh-token rotation and expired-session reauthorization, revocation effects after logout, exhausted-quota errors, and network-interruption recovery were not individually verified live.
|
|
565
|
+
- No performance or usage-cost benchmarks were available, so this is not evidence of guaranteed latency or token savings.
|
|
566
|
+
|
|
567
|
+
This records verification at issue closure, not coverage of every account, platform, or failure case. Consult `ask-bridge --help` for the current CLI.
|
|
568
|
+
|
|
569
|
+
* * *
|
|
381
570
|
|
|
382
571
|
## ⚙️ How It Works (Under the Hood)
|
|
383
572
|
|
|
573
|
+
The steps below describe the Browser/CDP backend. After OAuth authorization, SIWC instead fetches the account model catalog and calls Responses through HTTP/SSE, bypassing these browser steps.
|
|
574
|
+
|
|
384
575
|
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`).
|
|
385
576
|
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`.
|
|
386
577
|
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.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
`ask-bridge` 不保證網站 provider 的輸出一定正確,也不應取代本機測試、官方文件查證或人工審查。它的定位是降低探索性 AI 工作的操作成本,讓主要 Coding Agent 能以更低摩擦取得外部 AI 協助。
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
在預設的瀏覽器後端中,`ask-bridge` 會在真實 Chrome 瀏覽器中執行,並使用持久化的專屬使用者 profile。這表示:
|
|
23
23
|
|
|
24
24
|
- 只需要手動登入一次,透過 `ask-bridge login` 完成。
|
|
25
25
|
- 可處理 CAPTCHA、Cloudflare,並像一般使用者一樣存取所選 provider 的網頁功能。
|
|
@@ -30,22 +30,27 @@
|
|
|
30
30
|
- **100% Rust 核心**:快速、輕量,編譯後即可執行。
|
|
31
31
|
- **多 provider 支援**:使用 `--provider chatgpt|gemini|claude` 選擇 ChatGPT、Gemini 或 Claude。
|
|
32
32
|
- **全域 provider 設定**:可在 `~/.config/ask-bridge/config.json` 指定預設 provider,CLI 的 `--provider` 會覆蓋設定檔。
|
|
33
|
+
- **可指定瀏覽器**:可用 `--browser-path`、環境變數 `ASK_BRIDGE_BROWSER_PATH` 或設定檔 `browserPath` 改用 ego lite、Brave、Edge、Chromium 等 Chromium 系列瀏覽器,並依瀏覽器使用獨立 profile。
|
|
33
34
|
- **真實瀏覽器自動化**:直接控制監聽 `9223` port 的 Chrome debug profile。
|
|
34
35
|
- **持久登入狀態**:使用專屬本機 profile 目錄 `~/.config/ask-bridge/chrome-profile`,避免重複登入。
|
|
35
36
|
- **回覆輸出**:所選 provider 產生回覆時,將內容輸出到終端機。
|
|
36
37
|
- **思考動畫**:等待 provider 回覆時,在終端機顯示旋轉 spinner,開始輸出內容後自動清除。
|
|
38
|
+
- **ChatGPT 生圖進度**:讀取網頁上的圖片生成百分比,配合生成狀態與圖片載入狀態判斷完成;終端機與 `--verbose` 可顯示進度。
|
|
37
39
|
- **智慧分頁管理**:可重用既有 provider 分頁、聚焦分頁,或開啟新分頁,避免分頁過度增加。
|
|
38
40
|
- **Pipe 與 stdin 支援**:支援透過 standard input 傳入 prompt,例如 `cat report.txt | ask-bridge "summarize this"`。
|
|
39
41
|
- **圖片與文件上傳**:可透過 `--image` 附上圖片(支援 ChatGPT 與 Claude),或透過 `--file` 附上文件(PDF、Word、Excel、純文字、Markdown、JSON 等皆可),一次可指定多個檔案;Gemini 目前支援 `--file`,不支援 `--image` 圖片輸入。
|
|
40
42
|
- **模型與推理模式切換**:使用 `--model` 選模型,並以 `--reasoning` 分別控制 ChatGPT 推理強度或 Gemini 延伸思考。
|
|
41
43
|
- **接續既有對話**:使用 `--session`、`--session-id` 或 `--session-url` 指定既有對話,再從終端機送出新的 prompt。
|
|
44
|
+
- **臨時聊天**:使用 `--temporary` 建立不保留於一般聊天歷史的臨時對話(ChatGPT/Gemini 的 Temporary Chat、Claude 的 Incognito Chat);送出前會先確認已進入臨時模式,無法確認時直接中止、不送出問題。
|
|
45
|
+
- **批次執行**:使用 `ask-bridge batch` 以 JSONL 一次提交多個工作,每個工作使用獨立分頁與獨立輸出目錄,互不串線;結束時輸出各終態的統計摘要。
|
|
46
|
+
- **SIWC API 後端(選用)**:ChatGPT 可改走 Sign in with ChatGPT 官方 OAuth 流程,以訂閱方案額度呼叫公開 Responses API,不需 API Key;OAuth 登入使用系統瀏覽器,後續提問不啟動 Chrome。詳見[第 16 節快速上手](#16-使用-chatgpt-訂閱額度-api-後端siwc)。
|
|
42
47
|
- **回應超時**:使用 `--timeout <秒數>` 設定等待回應上限,預設為 `300` 秒。
|
|
43
48
|
- **預設安靜模式與 verbose 模式**:預設只輸出最終回覆;加上 `--verbose` 可顯示背景瀏覽器控制流程。
|
|
44
49
|
- **版本資訊**:使用 `-v` 或 `--version` 顯示目前版本號。
|
|
45
50
|
|
|
46
51
|
## 前置需求
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
使用預設的瀏覽器後端需要以下環境;僅使用 SIWC 的差異見[第 16 節](#16-使用-chatgpt-訂閱額度-api-後端siwc):
|
|
49
54
|
|
|
50
55
|
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` 階段直接退出。
|
|
51
56
|
2. 已安裝 Google Chrome。macOS 預設路徑通常是 `/Applications/Google Chrome.app`。若缺少 Chrome,且系統有 Homebrew,`make install` 會自動安裝。
|
|
@@ -130,7 +135,7 @@ npx skills add doggy8088/ask-bridge --skill ask-bridge --agent codex --global
|
|
|
130
135
|
|
|
131
136
|
### 1. 首次設定:登入 provider
|
|
132
137
|
|
|
133
|
-
|
|
138
|
+
以下為瀏覽器後端的登入方式;SIWC 請改依[第 16 節](#16-使用-chatgpt-訂閱額度-api-後端siwc)完成 OAuth 授權。送出 prompt 前,需要先登入所選 provider。未設定全域 provider 時,ChatGPT 為預設:
|
|
134
139
|
|
|
135
140
|
```bash
|
|
136
141
|
ask-bridge login
|
|
@@ -179,6 +184,24 @@ ask-bridge config
|
|
|
179
184
|
ask-bridge --provider chatgpt "請摘要這段內容。"
|
|
180
185
|
```
|
|
181
186
|
|
|
187
|
+
#### 指定瀏覽器(Chromium 系列)
|
|
188
|
+
|
|
189
|
+
預設自動偵測 Google Chrome。若要改用其他 Chromium 系列瀏覽器(例如 ego lite、Brave、Microsoft Edge、Chromium),可用 `ask-bridge config` 持久設定,或用環境變數/CLI 參數覆寫。優先序為:CLI 參數 > 環境變數 > 設定檔 > Chrome 自動偵測。
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# 持久設定(寫入 ~/.config/ask-bridge/config.json 的 browserPath)
|
|
193
|
+
ask-bridge config --browser-path "/Applications/ego lite.app/Contents/MacOS/ego lite"
|
|
194
|
+
|
|
195
|
+
# 一次性覆寫
|
|
196
|
+
ask-bridge --browser-path "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" "請摘要這段內容。"
|
|
197
|
+
ASK_BRIDGE_BROWSER_PATH="/usr/bin/chromium" ask-bridge "請摘要這段內容。"
|
|
198
|
+
|
|
199
|
+
# 清除設定(傳入空字串)
|
|
200
|
+
ask-bridge config --browser-path ""
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
自訂瀏覽器預設使用獨立的 profile 目錄 `~/.config/ask-bridge/<瀏覽器名稱>-profile`(例如 `ego-lite-profile`),避免不同瀏覽器共用同一個 profile;也可用 `--browser-profile-dir`、`ASK_BRIDGE_BROWSER_PROFILE_DIR` 或設定檔的 `browserProfileDir` 明確指定。設定的瀏覽器路徑不存在時會直接報錯,不會自動退回 Google Chrome。更換瀏覽器後,請先用該瀏覽器執行一次 `ask-bridge login` 完成登入。
|
|
204
|
+
|
|
182
205
|
### 2. 直接提問
|
|
183
206
|
|
|
184
207
|
將 prompt 作為 argument 傳入:
|
|
@@ -209,6 +232,30 @@ ask-bridge "誰是保哥?" --new
|
|
|
209
232
|
分頁與其他網站分頁都會保留;若無法唯一辨識新分頁,命令會停止且不會改用
|
|
210
233
|
或關閉既有分頁。
|
|
211
234
|
|
|
235
|
+
#### 臨時聊天(`--temporary`)
|
|
236
|
+
|
|
237
|
+
使用 `--temporary` 可建立不保留於一般聊天歷史的臨時對話,適合一次性或
|
|
238
|
+
較敏感的內容:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
ask-bridge --provider chatgpt --temporary "請分析這份資料"
|
|
242
|
+
ask-bridge --provider gemini --temporary "請分析這份資料"
|
|
243
|
+
ask-bridge --provider claude --temporary "請分析這份資料"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`--temporary` 自動包含 `--new` 的效果(每次都開新分頁),且不可與
|
|
247
|
+
`--session`/`--session-id`/`--session-url` 同時使用;模型切換、推理模式、
|
|
248
|
+
附件與 `-o`/`-i` 輸出等既有功能維持不變。
|
|
249
|
+
|
|
250
|
+
三個 provider 進入臨時模式的方式不同:ChatGPT 透過
|
|
251
|
+
`?temporary-chat=true` 參數開啟並以頁面標示驗證;Gemini 需點按頁面的
|
|
252
|
+
「Temporary chat」(僅個人 Google 帳號提供);Claude 需點按右上角的
|
|
253
|
+
Incognito(鬼魂圖示)按鈕。送出問題前,ask-bridge 會確認頁面已進入臨時
|
|
254
|
+
模式;無法確認時會直接中止並且不送出問題,避免內容被誤存入一般聊天
|
|
255
|
+
歷史。請注意,臨時模式由各 provider 定義:對話仍可能依其政策在伺服器端
|
|
256
|
+
短暫保留(例如 Gemini 最長 72 小時、Claude Incognito 約 30 天),並非
|
|
257
|
+
即時刪除。
|
|
258
|
+
|
|
212
259
|
### 4. 接續既有對話
|
|
213
260
|
|
|
214
261
|
使用 provider 對話 ID 或完整對話 URL,可接續網頁端既有的對話脈絡:
|
|
@@ -330,10 +377,22 @@ ask-bridge "幫我檢查這段程式碼有沒有問題。" --file src/main.rs
|
|
|
330
377
|
ask-bridge "請對照這張設計圖與規格文件,指出不一致的地方。" --image design.png --file spec.docx
|
|
331
378
|
```
|
|
332
379
|
|
|
333
|
-
####
|
|
380
|
+
#### 下載生成圖片
|
|
334
381
|
|
|
335
382
|
provider 回覆後,可使用 `-i` / `--image-output` 指定生成圖片的下載路徑(資料夾或檔案路徑)。
|
|
336
383
|
|
|
384
|
+
```bash
|
|
385
|
+
ask-bridge --provider chatgpt "請產生一張茶壺插畫" --image-output /tmp/teapot.png --verbose
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
ChatGPT 顯示圖片生成百分比時,工具會持續讀取進度,避免將生成中的預覽圖當成完成結果。百分比達到 100% 或進度欄位消失後,仍會確認生成已結束且圖片載入完成,再下載圖片;若網頁沒有百分比,則沿用生成狀態與圖片就緒檢查。等待仍受 `--timeout` 限制。
|
|
389
|
+
|
|
390
|
+
回覆中的引用來源 favicon 與來源卡片不會被當成生成圖片,純文字回覆的圖片掃描會立即結束。未指定 `-i` 時,圖片下載失敗只會顯示警告,不影響回覆輸出與 `-o` 檔案寫入;指定 `-i` 時,圖片下載失敗仍會以非零狀態結束。
|
|
391
|
+
|
|
392
|
+
若已偵測到本次 ChatGPT 回覆的生圖進度或候選圖片,但回覆未能在期限內完成,工具會以非零狀態結束,且不會以空內容覆寫 `--output` 檔案;不會因為顯示 100% 就略過圖片就緒檢查。
|
|
393
|
+
|
|
394
|
+
ChatGPT 的多張生成圖片必須全部取得才會回報下載成功;部分圖片無法取得時會重試至逾時,而不會將部分成果誤報為完整下載。此規則僅適用於 ChatGPT,不變更 Gemini 與 Claude 的既有下載行為。
|
|
395
|
+
|
|
337
396
|
### 11. 切換模型與推理模式
|
|
338
397
|
|
|
339
398
|
使用 `--model` 在送出 prompt 前切換 provider 模型;使用 `--reasoning` 分別指定 provider 支援的推理模式。兩者可在同一次 ChatGPT 呼叫中併用;Gemini 的延伸思考只相容於 Pro 模型。
|
|
@@ -348,7 +407,7 @@ ask-bridge --provider claude "用幾句話介紹 Rust。" --model Sonnet
|
|
|
348
407
|
|
|
349
408
|
參數規則:
|
|
350
409
|
|
|
351
|
-
- **ChatGPT**:`--reasoning` 支援 `
|
|
410
|
+
- **ChatGPT**:`--reasoning` 支援 `instant`、`medium`、`high`、`xhigh`,也接受 `即時`、`中`、`中等`、`高`、`極高` 等對應別名。新版 ChatGPT 的推理強度滑桿已移除「自動」,`auto` 只保留給仍提供該選項的介面。ask-bridge 一律使用 ChatGPT 的「對話(Chat)」模式;若撰寫器停在「工作(Work)」模式,會在送出前自動切回。
|
|
352
411
|
- **Gemini**:`--reasoning extended` 選擇 Extended Thinking;可省略 `--model`,或搭配實際存在的 Pro 模型。
|
|
353
412
|
- **Claude**:不支援 `--reasoning`;`--model` 的 Sonnet、Opus、Haiku 選擇流程維持不變。
|
|
354
413
|
|
|
@@ -386,8 +445,249 @@ ask-bridge update
|
|
|
386
445
|
|
|
387
446
|
此命令會依作業系統重新執行 README 建議的官方安裝命令(macOS / Linux 或 Windows)。
|
|
388
447
|
|
|
448
|
+
### 15. 批次執行多個工作(`batch`)
|
|
449
|
+
|
|
450
|
+
使用 `ask-bridge batch` 可一次提交多個彼此獨立的工作(issue #24)。每個
|
|
451
|
+
工作會在自己的瀏覽器分頁中執行,輸出到獨立目錄,互不影響:
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
ask-bridge batch --input jobs.jsonl --output-dir results/
|
|
455
|
+
cat jobs.jsonl | ask-bridge batch --output-dir results/
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
`jobs.jsonl` 為 JSONL 格式,一行一個工作物件:
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{"id":"job-1","provider":"chatgpt","prompt":"請只回覆 JOB-1"}
|
|
462
|
+
{"id":"job-2","provider":"gemini","prompt":"請摘要這份文件","files":["report.pdf"],"timeout":600}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
欄位說明:`id`(可省略,自動產生;限 `[A-Za-z0-9._-]`、不可重複)、
|
|
466
|
+
`provider`(可省略,沿用全域設定)、`prompt`(必填)、`timeout`(秒,
|
|
467
|
+
預設 300)、`session`(接續既有對話)、`temporary`(臨時聊天,不可與
|
|
468
|
+
`session` 併用)、`model`/`reasoning`、`files`/`images` 附件、
|
|
469
|
+
`downloadImages`(預設 `true`)。每個工作固定在自己的新分頁執行,
|
|
470
|
+
`"new": false` 不被接受。
|
|
471
|
+
|
|
472
|
+
每個工作的產出位於 `<output-dir>/<job-id>/`,包含 `response.md`、
|
|
473
|
+
`metadata.json`(provider、分頁 ID、對話連結、終態與錯誤)與 `images/`
|
|
474
|
+
(下載的生成圖片);檔案以暫存檔寫入後原子改名,不會留下半成品。執行
|
|
475
|
+
結束會輸出摘要(Total/Completed/Failed/Timed out/Recoverable/
|
|
476
|
+
Cancelled);任一工作未完成時結束代碼為 1。加上 `--fail-fast` 可在第一
|
|
477
|
+
個未完成的工作後停止啟動後續工作(標記為 Cancelled)。
|
|
478
|
+
|
|
479
|
+
若工作在送出 prompt 時遇到瀏覽器連線中斷,送出結果不明確,該工作會被
|
|
480
|
+
標記為 `Recoverable` 並保留對話連結供人工恢復,**不會自動重送**,避免
|
|
481
|
+
重複提問。
|
|
482
|
+
|
|
483
|
+
`--concurrency N`(預設 `1`)控制同時執行的工作上限:各工作的瀏覽器
|
|
484
|
+
控制操作(選取分頁、送出、擷取)會序列化執行,但 provider 的回覆生成
|
|
485
|
+
在各自分頁中平行進行。結束摘要會另行回報實際觀察到的最大同時執行數
|
|
486
|
+
(max in-flight),不會超過設定的 N。帳號本身的並行上限由各 provider
|
|
487
|
+
決定;若遇到 provider 限流,請調低 `--concurrency`,工具不會因限流而
|
|
488
|
+
自動重送 prompt。工作送出後會先在自己的目錄留下 `in_progress` 狀態的
|
|
489
|
+
`metadata.json`(含分頁 ID 與對話連結),即使程序中途被結束,也能依
|
|
490
|
+
該檔案人工恢復已送出的工作。
|
|
491
|
+
|
|
492
|
+
兩個以上工作指向同一個既有對話(`session`)時,各工作雖有自己的分頁,
|
|
493
|
+
操作的仍是同一個遠端對話、回覆無法隔離,因此 `--concurrency` 大於 1
|
|
494
|
+
時會在預檢階段直接拒絕重複的對話目標;`--concurrency 1` 循序執行則
|
|
495
|
+
依輸入順序進行。工作結束後其分頁會自動關閉,僅 `Recoverable`(送出
|
|
496
|
+
結果不明確)的工作保留分頁供人工復原,保留數量以不明確送出的次數為
|
|
497
|
+
上限。
|
|
498
|
+
|
|
499
|
+
* * *
|
|
500
|
+
|
|
501
|
+
### 16. 使用 ChatGPT 訂閱額度 API 後端(SIWC)
|
|
502
|
+
|
|
503
|
+
**SIWC 是選用後端;未設定時仍使用原本的 Browser/CDP。** Sign in with ChatGPT 讓你透過 OAuth 授權,以 ChatGPT 方案額度呼叫公開 Responses API,不需要 API Key。適合單次文字提問、摘要與方案比較;需要網頁既有對話、附件或生圖時,請選擇瀏覽器後端。
|
|
504
|
+
|
|
505
|
+
#### 先理解 Provider、Backend 與額度
|
|
506
|
+
|
|
507
|
+
| 項目 | 說明 |
|
|
508
|
+
| --- | --- |
|
|
509
|
+
| `--provider chatgpt\|gemini\|claude` | 選擇 AI 服務。SIWC 目前僅適用 ChatGPT。 |
|
|
510
|
+
| `--backend browser\|siwc` | 選擇這次執行的傳輸方式,優先於設定檔。 |
|
|
511
|
+
| `config --chatgpt-backend siwc` | 儲存 ChatGPT 的預設後端;`--chatgpt-backend` 不是 `--backend` 的別名,僅用於 `config`。 |
|
|
512
|
+
| 額度來源 | 使用 ChatGPT Work/Codex 方案額度或 credits,不使用 API Key 計費來源。 |
|
|
513
|
+
| 登入狀態 | SIWC OAuth 憑證與瀏覽器 cookies 分開保存,網站已登入不代表 SIWC 已授權。 |
|
|
514
|
+
|
|
515
|
+
**SIWC 不是免費或無限 token,也不保證減少總 token 或費用。** 若你的主要 Coding Agent 與 SIWC 共用方案額度,兩者可能競爭同一份額度。可用模型、授權資格、額度與 credits 依帳號及 workspace 實際政策為準,不以方案名稱保證可用。
|
|
516
|
+
|
|
517
|
+
#### 快速上手:登入後送出第一個問題
|
|
518
|
+
|
|
519
|
+
先依前面的安裝章節安裝 `ask-bridge`,再執行:
|
|
520
|
+
|
|
521
|
+
```bash
|
|
522
|
+
# 1. 開啟系統瀏覽器,登入並授權 ChatGPT 方案使用
|
|
523
|
+
ask-bridge --provider chatgpt --backend siwc login
|
|
524
|
+
|
|
525
|
+
# 2. 授權完成、終端機確認登入成功後提問
|
|
526
|
+
ask-bridge --provider chatgpt --backend siwc "用三個重點解釋這個工具適合的使用情境"
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
首次登入會進行動態註冊;完成 OAuth 需要系統瀏覽器,後續提問直接透過 HTTP 串流,**不啟動 Chrome、不使用 CDP 或 MCP**。SIWC 提問本身不需要 Node.js/npx;目前安裝腳本仍有瀏覽器模式的相依檢查,請依安裝章節操作。
|
|
530
|
+
|
|
531
|
+
登入時請使用具方案使用權的帳號,完成頁面上的方案使用授權,再等候瀏覽器導回本機 callback。登入成功會嘗試列出最多 10 個可用模型及其 slug;若系統瀏覽器沒有自動開啟,可使用終端機顯示的授權網址。登入 callback 固定最多等待 300 秒,不受提問用的 `--timeout` 調整。
|
|
532
|
+
|
|
533
|
+
#### 提問、stdin、模型與輸出檔
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
# 把純文字文件內容作為上下文
|
|
537
|
+
cat report.md | ask-bridge --provider chatgpt --backend siwc "摘要重點,列出待確認事項"
|
|
538
|
+
|
|
539
|
+
# 也可只從 stdin 讀取完整問題
|
|
540
|
+
ask-bridge --provider chatgpt --backend siwc < prompt.txt
|
|
541
|
+
|
|
542
|
+
# 設定整體請求逾時,成功後將完整回覆寫入檔案
|
|
543
|
+
ask-bridge --provider chatgpt --backend siwc --timeout 120 -o answer.md "比較兩個技術方案"
|
|
544
|
+
|
|
545
|
+
# 將 MODEL_SLUG 換成登入時列出的實際 slug
|
|
546
|
+
ask-bridge --provider chatgpt --backend siwc --model "MODEL_SLUG" "比較兩個技術方案"
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
| 參數/輸入 | SIWC 行為 |
|
|
550
|
+
| --- | --- |
|
|
551
|
+
| prompt 加 stdin | 合併為「prompt、兩個換行、stdin」,一起送出;不會自動讀取其他檔案。 |
|
|
552
|
+
| `--model` | 每次向帳號模型目錄驗證;接受 slug 或完整顯示名稱,名稱比對不分英文大小寫。省略時使用目錄第一個模型,與網頁選單無關。不存在時列出可用 slug 並中止,不會改用其他模型。 |
|
|
553
|
+
| `--timeout` | 預設 300 秒,涵蓋 token 更新、模型目錄與推論串流;前置 HTTP 請求另有 30 秒上限,因此不保證一定等到整體上限。 |
|
|
554
|
+
| `-o`/`--output` | 回覆仍即時輸出到終端機;只有收到成功完成事件 `response.completed` 後,才寫入指定檔案。成功時會覆寫既有檔案,父目錄需先存在。 |
|
|
555
|
+
|
|
556
|
+
**終端機已印出部分文字不代表成功。** 額度錯誤、中斷或逾時可能在串流途中發生;這時程序以非零代碼結束,不執行 `-o` 寫檔,既有輸出檔也不會因本次推論失敗而被覆寫。直接以 `>` 重新導向 stdout 則可能留下不完整文字;需要確認完成的檔案時,請使用 `-o` 並檢查結束代碼。
|
|
557
|
+
|
|
558
|
+
#### 如何把目前工作的上下文傳入?
|
|
559
|
+
|
|
560
|
+
**把相關文字透過 stdin 傳入,再以 prompt 說明任務。** SIWC 不會自動取得目前工作目錄、Git 狀態、IDE 選取內容或 Coding Agent 的對話紀錄。你提供什麼,它才會收到什麼;`--file` 附件與將文字內容 pipe 進 stdin 是不同功能。
|
|
561
|
+
|
|
562
|
+
以下為 Bash/zsh 範例。多份資料請加上檔名或段落標籤,讓模型能分辨來源:
|
|
563
|
+
|
|
564
|
+
```bash
|
|
565
|
+
# 比較兩份文件,明確標示來源
|
|
566
|
+
{
|
|
567
|
+
printf '\n--- a.md ---\n'
|
|
568
|
+
cat a.md
|
|
569
|
+
printf '\n--- b.md ---\n'
|
|
570
|
+
cat b.md
|
|
571
|
+
} | ask-bridge --provider chatgpt --backend siwc "比較兩份文件的差異與矛盾"
|
|
572
|
+
|
|
573
|
+
# 把尚未 staged 的程式碼差異交給模型檢查
|
|
574
|
+
# 已 staged 的變更請改用 git diff --cached
|
|
575
|
+
# git diff 不包含尚未追蹤的檔案
|
|
576
|
+
git diff -- src/main.rs | ask-bridge --provider chatgpt --backend siwc "檢查這份 diff 的邏輯風險"
|
|
577
|
+
|
|
578
|
+
# 先保存測試輸出,再提供給模型分析
|
|
579
|
+
cargo test > test-output.txt 2>&1
|
|
580
|
+
cat test-output.txt | ask-bridge --provider chatgpt --backend siwc "分析失敗原因並建議修正方向"
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
Windows PowerShell 可用 `Get-Content -Raw` 傳入文字內容:
|
|
584
|
+
|
|
585
|
+
```powershell
|
|
586
|
+
Get-Content -Raw -Encoding utf8 report.md | ask-bridge --provider chatgpt --backend siwc "摘要重點"
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
目前每次呼叫都是獨立提問,工具不會自動保存或重送前一輪上下文,也不能用 `--session` 接續網頁對話。需要延續討論時,請自行選取上一輪的問題、回覆與必要背景,整理後再次傳入。例如:
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# 第一輪成功後,才將新產生的摘要與原文傳入下一輪
|
|
593
|
+
if cat report.md | ask-bridge --provider chatgpt --backend siwc -o summary.md "摘要報告並列出風險"; then
|
|
594
|
+
{
|
|
595
|
+
printf '\n--- 上一輪問題 ---\n摘要報告並列出風險\n'
|
|
596
|
+
printf '\n--- 上一輪回覆 ---\n'
|
|
597
|
+
cat summary.md
|
|
598
|
+
printf '\n--- 相關原文 ---\n'
|
|
599
|
+
cat report.md
|
|
600
|
+
} | ask-bridge --provider chatgpt --backend siwc -o follow-up.md "根據提供的上一輪摘要與原文,提出三項改善措施"
|
|
601
|
+
fi
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
這是手動提供文字背景,不是內建多輪會話。只傳入與任務相關的片段,並刪除密碼、token、個資等不應送出的內容;反覆附上全部歷史會增加輸入 token、耗時與額度使用,也可能超過模型上下文上限。PDF、Word 或圖片等二進位檔案不能直接當文字 pipe;請先轉成文字,或改用支援附件的瀏覽器模式。
|
|
605
|
+
|
|
606
|
+
#### 設定預設後端與切回瀏覽器
|
|
607
|
+
|
|
608
|
+
```bash
|
|
609
|
+
# 僅改 ChatGPT 的預設後端,保留其他設定
|
|
610
|
+
ask-bridge config --chatgpt-backend siwc
|
|
611
|
+
ask-bridge config
|
|
612
|
+
|
|
613
|
+
# 設定後可省略 --backend,但仍明確指定 ChatGPT
|
|
614
|
+
ask-bridge --provider chatgpt "摘要這項設計的風險"
|
|
615
|
+
|
|
616
|
+
# 本次改走瀏覽器,不改持久設定;若網站尚未登入,先執行下一行
|
|
617
|
+
ask-bridge --provider chatgpt --backend browser login
|
|
618
|
+
ask-bridge --provider chatgpt --backend browser "使用網頁功能回答這個問題"
|
|
619
|
+
|
|
620
|
+
# 恢復 ChatGPT 的預設瀏覽器後端
|
|
621
|
+
ask-bridge config --chatgpt-backend browser
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
後端優先序為 `--backend` > `config.json` 的 `chatgptBackend` > `browser`。設定 SIWC 不會改變預設 provider;若預設 provider 是 Gemini 或 Claude,仍需用 `--provider chatgpt` 才會使用 SIWC。Gemini/Claude 會忽略持久化的 ChatGPT 後端設定,但明確搭配 `--backend siwc` 會報錯。
|
|
625
|
+
|
|
626
|
+
#### Browser 與 SIWC 功能矩陣
|
|
627
|
+
|
|
628
|
+
| 功能 | Browser 後端 | SIWC 後端 |
|
|
629
|
+
| --- | --- | --- |
|
|
630
|
+
| 服務 | ChatGPT、Gemini、Claude | 僅 ChatGPT |
|
|
631
|
+
| 登入與連線 | 網站登入、Chrome/CDP/MCP | OAuth;提問使用 HTTP/SSE |
|
|
632
|
+
| 單次文字、stdin、`-o` | 支援 | 支援 |
|
|
633
|
+
| 模型選擇 | 網頁模型選單 | 帳號 API 模型目錄 |
|
|
634
|
+
| 既有對話 `--session`/`--session-id`/`--session-url` | 支援 | 拒絕,不讀取 `chatgpt.com/c/...` |
|
|
635
|
+
| `--new`/`--temporary` | 支援 | 拒絕;每次提問獨立,無網頁臨時聊天模式 |
|
|
636
|
+
| `--image`/`--file` | 依 provider 支援 | 本工具尚未實作,會拒絕 |
|
|
637
|
+
| 生圖與 `--image-output`/`-i` | 依網站功能支援 | 不支援,會拒絕圖片輸出選項 |
|
|
638
|
+
| `--reasoning` | 依 provider 支援 | 尚未實作,會拒絕 |
|
|
639
|
+
| `batch` | 支援 | 拒絕;若已設 SIWC 預設值,需明確使用 `--backend browser` |
|
|
640
|
+
| `open`/`get`/`close` 等瀏覽器指令 | 支援 | 拒絕,需明確使用 `--backend browser` |
|
|
641
|
+
| 額度來源 | 各網站產品與帳號限制 | ChatGPT Work/Codex 方案額度或 credits |
|
|
642
|
+
|
|
643
|
+
目前沒有 `--download-images` CLI 參數;`downloadImages` 是瀏覽器批次工作 JSON 的欄位。SIWC 不支援 `batch`,不能以該欄位啟用下載。
|
|
644
|
+
|
|
645
|
+
本工具的 SIWC MVP 僅提供單次純文字推論,不提供 file search、Code Interpreter、圖片生成或 hosted MCP/connectors 等工具。附件未支援是本工具目前的限制,不代表上游 SIWC API 一律不接受圖片或文件。這條 HTTP 路徑使用 `store: false`、`stream: true`,不使用 `previous_response_id` 接續會話;`store: false` 不代表服務端沒有任何資料保留。模型與 API 能力仍以 [OpenAI 模型與推論文件](https://developers.openai.com/siwc/token-sharing-open-source/models-and-inference)及 [Preview 限制](https://developers.openai.com/siwc/token-sharing-open-source/preview-limitations)為準。
|
|
646
|
+
|
|
647
|
+
#### 重新登入、登出與憑證
|
|
648
|
+
|
|
649
|
+
```bash
|
|
650
|
+
# 授權過期、被撤銷或更新失敗時,重新執行登入
|
|
651
|
+
ask-bridge --provider chatgpt --backend siwc login
|
|
652
|
+
|
|
653
|
+
# 清除本機保存的 SIWC 帳號與 token
|
|
654
|
+
ask-bridge --provider chatgpt --backend siwc logout
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
憑證保存於 `~/.config/ask-bridge/siwc-credentials.json`,採原子寫入;Unix 檔案權限為 `0600`,Windows 不適用此 Unix 權限表示法。工具會自動更新即將過期的 access token 並保存輪替後的 refresh token,不應將憑證檔分享、提交到 Git 或貼到問題回報中。
|
|
658
|
+
|
|
659
|
+
`logout` 清除本機帳號與 token,但保留固定的 host ID,因此憑證檔可能仍存在;它不會呼叫伺服器端撤銷 API、不會登出 ChatGPT 網站,也不會將預設後端改回 `browser`。下次使用 SIWC 需重新登入。
|
|
660
|
+
|
|
661
|
+
#### 常見問題與失敗處理
|
|
662
|
+
|
|
663
|
+
| 情況 | 處理方式 |
|
|
664
|
+
| --- | --- |
|
|
665
|
+
| `not signed in`/401/refresh 失敗 | 執行上方完整的 SIWC `login` 指令;網站登入狀態無法代替 OAuth 授權。 |
|
|
666
|
+
| 拒絕授權/缺少方案使用權 | 確認登入的帳號、workspace 與方案使用授權,再重新登入;僅有訂閱名稱不保證權限。 |
|
|
667
|
+
| 模型不存在/模型目錄為空 | 使用錯誤訊息列出的 slug;目錄為空時,確認帳號權限與服務可用狀態。 |
|
|
668
|
+
| 429/`subscription_sharing_usage_limit_exceeded`/`subscription_sharing_usage_unavailable` | 檢查方案用量、credits 或帳號可用狀態,依錯誤恢復;錯誤可能在串流中途才出現。 |
|
|
669
|
+
| 逾時/網路中斷/未收到完成事件 | 本次視為失敗,已顯示文字可能不完整;確認連線後自行決定是否重新送出。 |
|
|
670
|
+
| 選項與 SIWC 不相容 | 移除不支援選項,或明確選擇 `--backend browser` 並完成網站登入。 |
|
|
671
|
+
| `UnknownIssuer` | 請管理員確認所需 CA 已安裝到系統信任庫;不要停用 TLS 憑證驗證。 |
|
|
672
|
+
|
|
673
|
+
**失敗時不會自動切回 Browser/CDP,也不會動用 API Key 額度。** HTTPS 使用 rustls,合併內建 CA 與作業系統信任庫;錯誤會顯示底層連線原因,不包含請求 URL、headers 或 body。在企業代理/防毒 HTTPS 掃描等 TLS 檢查環境中,受信任的攔截方可看到連線內容,包含 token 交換與更新;請只在信任該環境時使用。
|
|
674
|
+
|
|
675
|
+
#### 驗證範圍與參考
|
|
676
|
+
|
|
677
|
+
依 [issue #40 結案紀錄](https://github.com/doggy8088/ask-bridge/issues/40#issuecomment-6956849874),截至 2026-11-17:
|
|
678
|
+
|
|
679
|
+
- 已完成 Windows 真實環境 OAuth 登入與單次文字對話驗證。
|
|
680
|
+
- 尚未逐項進行真實環境驗證:refresh token 輪替與失效重登、登出後的撤銷效果、額度耗盡錯誤呈現、網路中斷恢復。
|
|
681
|
+
- 尚無效能/額度成本基準數據,不能據此宣稱一定更快或更省 token。
|
|
682
|
+
|
|
683
|
+
以上是該 issue 結案時的驗證紀錄,不表示所有帳號、平台與錯誤情境都已驗證;目前指令以 `ask-bridge --help` 為準。
|
|
684
|
+
|
|
685
|
+
* * *
|
|
686
|
+
|
|
389
687
|
## 運作原理
|
|
390
688
|
|
|
689
|
+
以下說明 Browser/CDP 後端;SIWC 在完成 OAuth 授權後,直接取得帳號模型目錄並以 HTTP/SSE 呼叫 Responses API,略過下列瀏覽器流程。
|
|
690
|
+
|
|
391
691
|
1. **瀏覽器初始化**:`ask-bridge` 會檢查 Chrome 是否正在監聽 debug port `9223`。若沒有,會以專屬 profile 目錄 `~/.config/ask-bridge/chrome-profile` 啟動 Google Chrome。
|
|
392
692
|
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`。
|
|
393
693
|
3. **Client 呼叫**:`ask-bridge` 透過內建的 `doggy8088/mcp-cli` Rust library dependency 呼叫 MCP tools,例如 `list_pages`、`select_page`、`type_text` 與 `evaluate_script`,不依賴系統上的外部 `mcp-cli` 命令。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ask-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Automate ChatGPT, Gemini or Claude from the command line through Chrome.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ask-bridge": "npm/cli.cjs",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postinstall": "node npm/postinstall.cjs",
|
|
11
|
-
"test": "node --test tests/postinstall.test.cjs tests/model-selection.test.cjs",
|
|
11
|
+
"test": "node --test tests/postinstall.test.cjs tests/model-selection.test.cjs tests/image-progress.test.cjs tests/temporary-chat.test.cjs",
|
|
12
12
|
"prepublishOnly": "npm test && npm pack --dry-run && node npm/prepublish-check.cjs"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|