ask-bridge 0.2.9 → 0.2.10

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 CHANGED
@@ -38,7 +38,8 @@ Unlike typical API clients, `ask-bridge` operates inside a real Chrome browser w
38
38
  - **🧠 Intelligent Tab Management**: Reuses existing provider tabs if open, focuses them, or opens new ones, avoiding tab clutter.
39
39
  - **🖥️ Pipe & Stdin Support**: Supports piping prompts via `stdin` (e.g. `cat report.txt | ask-bridge "summarize this"`).
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
- - **🔀 Model Switching**: Use `--model` to switch the provider model before the prompt is sent, such as ChatGPT `GPT-5.4`, Gemini `3.5 Flash`, or Claude `Sonnet`.
41
+ - **🔀 Model and Reasoning Selection**: Use `--model` for provider models and `--reasoning` for ChatGPT reasoning effort or Gemini Extended Thinking.
42
+ - **Resume Conversations**: Use `--session`, `--session-id`, or `--session-url` to continue an existing provider conversation with a new terminal prompt.
42
43
  - **Response Timeout**: Use `--timeout <seconds>` to control how long to wait for a provider response, defaulting to `300` seconds.
43
44
  - **🔍 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.
44
45
  - **Version Info**: Use `-v` or `--version` to print the current version number.
@@ -90,6 +91,10 @@ irm https://raw.githubusercontent.com/doggy8088/ask-bridge/main/install.ps1 | ie
90
91
  > [!NOTE]
91
92
  > 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.
92
93
  > The formal CLI command is `ask-bridge`; the installer also provides `ask` as a backward-compatible alias. The examples below use `ask-bridge`.
94
+ > The Windows installer verifies that the download is a PE executable, runs a
95
+ > `--version` smoke test, and puts the official install directory first in User
96
+ > PATH. Run `where.exe ask-bridge` and confirm that the first expanded path ends
97
+ > with `\.local\bin\ask-bridge.exe`.
93
98
 
94
99
  ### 2. Build & Install from Source (For Developers)
95
100
 
@@ -203,9 +208,29 @@ ask-bridge "誰是保哥?" --new
203
208
  ```
204
209
 
205
210
  - This will open a **brand new selected-provider tab**.
206
- - It will **automatically close previous tabs for the same provider** to keep your workspace clean and organized.
211
+ - All provider and non-provider tabs that existed before the command will be preserved.
212
+ - If the new tab cannot be identified unambiguously, the command stops instead of
213
+ reusing or closing an existing tab.
207
214
 
208
- ### 4. Headless Mode (Default: True)
215
+ ### 4. Resume an Existing Conversation
216
+
217
+ Pass either a provider conversation ID or a full conversation URL to continue its
218
+ existing web context:
219
+
220
+ ```bash
221
+ ask-bridge --provider chatgpt --session-id "conversation-uuid" "Continue the previous plan."
222
+ ask-bridge --session-url "https://chatgpt.com/c/conversation-uuid" "Produce the next steps."
223
+ ask-bridge --provider gemini --session "conversation-id" "Continue the analysis."
224
+ ```
225
+
226
+ `--session`, `--session-id`, and `--session-url` are aliases for the same option.
227
+ An ID uses the selected or configured provider to build the conversation URL. A
228
+ full URL identifies its provider automatically. The command stops before opening
229
+ Chrome when an explicitly selected provider conflicts with the URL, the URL does
230
+ not belong to a supported provider, or `--new` is also supplied. Existing tabs
231
+ are preserved.
232
+
233
+ ### 5. Headless Mode (Default: True)
209
234
 
210
235
  By default, standard queries run Chrome in **headless mode** (`--headless=true`) so that the browser operates silently in the background without stealing your focus or popping up windows.
211
236
 
@@ -217,7 +242,7 @@ ask-bridge "誰是保哥?" --headless=false
217
242
 
218
243
  *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.*
219
244
 
220
- ### 5. Verbose Mode (`--verbose`)
245
+ ### 6. Verbose Mode (`--verbose`)
221
246
 
222
247
  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.
223
248
 
@@ -234,7 +259,7 @@ This will print every stage of the browser automation:
234
259
  - Submitting...
235
260
  - Waiting for provider response...
236
261
 
237
- ### 6. Response Timeout (`--timeout`)
262
+ ### 7. Response Timeout (`--timeout`)
238
263
 
239
264
  The default wait time is 300 seconds. If a provider takes longer, increase (or decrease) the timeout:
240
265
 
@@ -250,7 +275,7 @@ ask-bridge "Short answer" --timeout 60
250
275
 
251
276
  If the response does not complete within the configured seconds, `ask-bridge` will stop waiting and print a timeout warning.
252
277
 
253
- ### 7. Version Info
278
+ ### 8. Version Info
254
279
 
255
280
  Use `-v` or `--version` to print the current version number:
256
281
 
@@ -258,7 +283,7 @@ Use `-v` or `--version` to print the current version number:
258
283
  ask-bridge -v
259
284
  ```
260
285
 
261
- ### 8. Piping & Stdin Support
286
+ ### 9. Piping & Stdin Support
262
287
 
263
288
  You can pipe text or files directly into `ask-bridge`:
264
289
 
@@ -278,7 +303,7 @@ Or read files:
278
303
  cat src/main.rs | ask-bridge "Are there any memory leaks in this Rust code?"
279
304
  ```
280
305
 
281
- ### 8. Attaching Images or Files
306
+ ### 10. Attaching Images or Files
282
307
 
283
308
  Instead of piping file contents into the prompt, you can upload local files as attachments directly to the selected provider.
284
309
 
@@ -310,30 +335,29 @@ You can attach images and documents at the same time:
310
335
  ask-bridge "Compare this design image against the spec document and list inconsistencies." --image design.png --file spec.docx
311
336
  ```
312
337
 
313
- ### 9. Switch Model
338
+ ### 11. Switch Models and Reasoning
314
339
 
315
- Use `--model` to automatically switch the provider model before the prompt is sent. Matching is case- and punctuation-insensitive (`-`, `.`, spaces, etc. are ignored).
340
+ Use `--model` to switch the provider model before the prompt is sent. Use `--reasoning` separately for provider-specific reasoning modes. ChatGPT accepts both in one invocation; Gemini Extended Thinking is compatible only with Pro models.
316
341
 
317
342
  ```bash
318
- ask-bridge "Introduce Rust in a few sentences." --model GPT-5.4
319
- ask-bridge "Prove this math problem." --model o3
320
- ask-bridge "Quickly translate this." --model 即時
321
- ask-bridge --provider gemini "Introduce Rust in a few sentences." --model "3.5 Flash"
322
- ask-bridge --provider gemini "Introduce Rust in a few sentences." --model "3.1 Pro"
343
+ ask-bridge "Prove this math problem." --model "GPT-5.6 Sol" --reasoning high
344
+ ask-bridge "Quickly translate this." --reasoning instant
345
+ ask-bridge --provider gemini "Introduce Rust in a few sentences." --model "3.6 Flash"
346
+ ask-bridge --provider gemini "Prove this math problem." --model "3.1 Pro" --reasoning extended
323
347
  ask-bridge --provider claude "Introduce Rust in a few sentences." --model Sonnet
324
- ask-bridge --provider claude "Prove this math problem." --model Opus
325
348
  ```
326
349
 
327
- Available model names (depending on your account entitlements and provider UI):
350
+ Argument rules:
351
+
352
+ - **ChatGPT**: `--reasoning` accepts `auto`, `instant`, `medium`, and `high`, plus the corresponding aliases `智慧`, `即時`, `中`, `中等`, and `高`.
353
+ - **Gemini**: `--reasoning extended` selects Extended Thinking. Omit `--model` or combine it with an available Pro model.
354
+ - **Claude**: `--reasoning` is unsupported. Existing Sonnet, Opus, and Haiku `--model` selection is unchanged.
328
355
 
329
- - **ChatGPT models**: `GPT-5.5`, `GPT-5.4`, `GPT-5.3`, `o3`
330
- - **ChatGPT thinking levels**: `智慧`, `即時`, `中等`, `高`, `超高`, `專業`
331
- - **Gemini modes**: `3.5 Flash`, `3.1 Flash-Lite`, `3.1 Pro`
332
- - **Claude models**: `Sonnet`, `Opus`, `Haiku` (actual names depend on the claude.ai menu and your plan)
356
+ Model matching uses only each menu item's primary label and ignores subtitles and badges. It remains case- and punctuation-insensitive. The tool never maps an obsolete model version to a different version. If the primary label is unavailable, the error lists the provider options currently found and aborts before sending the prompt.
333
357
 
334
- > 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.
358
+ Legacy forms such as `--model 高` and Gemini `--model 延伸思考` remain temporarily supported with a deprecation warning. Use `--reasoning` instead.
335
359
 
336
- ### 10. Just Open a Provider
360
+ ### 12. Just Open a Provider
337
361
 
338
362
  To quickly launch the browser and open the selected provider without sending any query:
339
363
 
@@ -343,7 +367,7 @@ ask-bridge --provider gemini open
343
367
  ask-bridge --provider claude open
344
368
  ```
345
369
 
346
- ### 11. Close the Browser Instance
370
+ ### 13. Close the Browser Instance
347
371
 
348
372
  To close the Chrome debug profile instance managed by `ask-bridge`:
349
373
 
package/README.md CHANGED
@@ -37,7 +37,8 @@
37
37
  - **智慧分頁管理**:可重用既有 provider 分頁、聚焦分頁,或開啟新分頁,避免分頁過度增加。
38
38
  - **Pipe 與 stdin 支援**:支援透過 standard input 傳入 prompt,例如 `cat report.txt | ask-bridge "summarize this"`。
39
39
  - **圖片與文件上傳**:可透過 `--image` 附上圖片(支援 ChatGPT 與 Claude),或透過 `--file` 附上文件(PDF、Word、Excel、純文字、Markdown、JSON 等皆可),一次可指定多個檔案;Gemini 目前支援 `--file`,不支援 `--image` 圖片輸入。
40
- - **模型切換**:使用 `--model` 在送出 prompt 前自動切換 provider 模型(如 ChatGPT 的 `GPT-5.4`、`o3`,Gemini 的 `3.5 Flash`、`3.1 Pro`,或 Claude 的 `Sonnet`、`Opus`)。
40
+ - **模型與推理模式切換**:使用 `--model` 選模型,並以 `--reasoning` 分別控制 ChatGPT 推理強度或 Gemini 延伸思考。
41
+ - **接續既有對話**:使用 `--session`、`--session-id` 或 `--session-url` 指定既有對話,再從終端機送出新的 prompt。
41
42
  - **回應超時**:使用 `--timeout <秒數>` 設定等待回應上限,預設為 `300` 秒。
42
43
  - **預設安靜模式與 verbose 模式**:預設只輸出最終回覆;加上 `--verbose` 可顯示背景瀏覽器控制流程。
43
44
  - **版本資訊**:使用 `-v` 或 `--version` 顯示目前版本號。
@@ -85,6 +86,9 @@ irm https://raw.githubusercontent.com/doggy8088/ask-bridge/main/install.ps1 | ie
85
86
  > [!NOTE]
86
87
  > 請確保安裝路徑(macOS/Linux 為 `~/.local/bin`;Windows 為 `$HOME\.local\bin`)已加入您的系統 `PATH` 環境變數中。
87
88
  > 正式 CLI 命令為 `ask-bridge`;安裝流程也會提供 `ask` 作為向後相容 alias。以下範例皆以 `ask-bridge` 為準。
89
+ > Windows 安裝程式會驗證下載檔為 PE 執行檔、執行 `--version` smoke test,
90
+ > 並把正式安裝目錄放在 User PATH 最前面。可用 `where.exe ask-bridge`
91
+ > 確認第一筆展開後的完整路徑結尾為 `\.local\bin\ask-bridge.exe`。
88
92
 
89
93
  ### 2. 從原始碼建置與安裝 (適用於開發者)
90
94
 
@@ -201,9 +205,26 @@ ask-bridge --provider claude "Rust struct 和 tuple 有什麼差異?"
201
205
  ask-bridge "誰是保哥?" --new
202
206
  ```
203
207
 
204
- 此模式會開啟新的所選 provider 分頁,並清理先前同一 provider 的分頁。
208
+ 此模式只會開啟並使用新的所選 provider 分頁。執行前已存在的 provider
209
+ 分頁與其他網站分頁都會保留;若無法唯一辨識新分頁,命令會停止且不會改用
210
+ 或關閉既有分頁。
205
211
 
206
- ### 4. Headless 模式
212
+ ### 4. 接續既有對話
213
+
214
+ 使用 provider 對話 ID 或完整對話 URL,可接續網頁端既有的對話脈絡:
215
+
216
+ ```bash
217
+ ask-bridge --provider chatgpt --session-id "conversation-uuid" "請接續先前的規劃。"
218
+ ask-bridge --session-url "https://chatgpt.com/c/conversation-uuid" "請產出下一步計畫。"
219
+ ask-bridge --provider gemini --session "conversation-id" "請繼續分析。"
220
+ ```
221
+
222
+ `--session`、`--session-id` 與 `--session-url` 是相同參數的別名。傳入 ID
223
+ 時會依 `--provider` 或全域設定組成 provider 對話 URL;傳入完整 URL 時會辨識
224
+ provider。若同時明確指定不相符的 `--provider`、URL 不屬於支援的 provider,
225
+ 或與 `--new` 同時使用,命令會在開啟瀏覽器前停止。既有頁籤不會被關閉。
226
+
227
+ ### 5. Headless 模式
207
228
 
208
229
  一般提問預設使用 headless Chrome,也就是 `--headless=true`。Chrome 會在背景執行,不會搶走焦點或跳出視窗。
209
230
 
@@ -215,7 +236,7 @@ ask-bridge "誰是保哥?" --headless=false
215
236
 
216
237
  `ask-bridge login` 會強制使用 headful 模式,方便你和瀏覽器 UI 互動;其他 subcommand 若要可見瀏覽器,請明確加上 `--headless=false`。
217
238
 
218
- ### 5. Verbose 模式
239
+ ### 6. Verbose 模式
219
240
 
220
241
  預設情況下,`ask-bridge` 只輸出所選 provider 的最終回覆,隱藏背景控制訊息。
221
242
 
@@ -233,7 +254,7 @@ Verbose 模式會顯示類似以下流程:
233
254
  - 送出訊息。
234
255
  - 等待 provider 回覆。
235
256
 
236
- ### 6. 回應超時(`--timeout`)
257
+ ### 7. 回應超時(`--timeout`)
237
258
 
238
259
  回答等待預設 300 秒,若 provider 回應時間較長可提高(或降低)等待上限:
239
260
 
@@ -249,7 +270,7 @@ ask-bridge "簡短回覆" --timeout 60
249
270
 
250
271
  超過設定秒數仍未完成時,會輸出超時警告並直接結束回應等待流程。
251
272
 
252
- ### 7. 顯示版本
273
+ ### 8. 顯示版本
253
274
 
254
275
  使用 `-v` 或 `--version` 顯示目前版本號:
255
276
 
@@ -257,7 +278,7 @@ ask-bridge "簡短回覆" --timeout 60
257
278
  ask-bridge -v
258
279
  ```
259
280
 
260
- ### 8. Pipe 與 stdin
281
+ ### 9. Pipe 與 stdin
261
282
 
262
283
  可透過 pipe 將文字或檔案內容傳入 `ask-bridge`:
263
284
 
@@ -277,7 +298,7 @@ cat /Users/will/.copilot/session-state/46cc0f1c-79fd-4622-9548-a0b7fa3794be/rese
277
298
  cat src/main.rs | ask-bridge "這段 Rust code 有記憶體洩漏風險嗎?"
278
299
  ```
279
300
 
280
- ### 8. 附上圖片或文件
301
+ ### 10. 附上圖片或文件
281
302
 
282
303
  除了把檔案內容透過 pipe 傳入 prompt,你也可以直接把本機檔案當作附件上傳給所選 provider。
283
304
 
@@ -313,30 +334,29 @@ ask-bridge "請對照這張設計圖與規格文件,指出不一致的地方
313
334
 
314
335
  provider 回覆後,可使用 `-i` / `--image-output` 指定生成圖片的下載路徑(資料夾或檔案路徑)。
315
336
 
316
- ### 9. 切換模型
337
+ ### 11. 切換模型與推理模式
317
338
 
318
- 使用 `--model` 在送出 prompt 前自動切換 provider 的模型。比對時不分大小寫與標點符號(`-`、`.`、空格 等)。
339
+ 使用 `--model` 在送出 prompt 前切換 provider 模型;使用 `--reasoning` 分別指定 provider 支援的推理模式。兩者可在同一次 ChatGPT 呼叫中併用;Gemini 的延伸思考只相容於 Pro 模型。
319
340
 
320
341
  ```bash
321
- ask-bridge "用幾句話介紹 Rust。" --model GPT-5.4
322
- ask-bridge "證明這個數學問題。" --model o3
323
- ask-bridge "快速翻譯這段話。" --model 即時
324
- ask-bridge --provider gemini "用幾句話介紹 Rust。" --model "3.5 Flash"
325
- ask-bridge --provider gemini "用幾句話介紹 Rust。" --model "3.1 Pro"
342
+ ask-bridge "證明這個數學問題。" --model "GPT-5.6 Sol" --reasoning high
343
+ ask-bridge "快速翻譯這段話。" --reasoning instant
344
+ ask-bridge --provider gemini "用幾句話介紹 Rust。" --model "3.6 Flash"
345
+ ask-bridge --provider gemini "證明這個數學問題。" --model "3.1 Pro" --reasoning extended
326
346
  ask-bridge --provider claude "用幾句話介紹 Rust。" --model Sonnet
327
- ask-bridge --provider claude "證明這個數學問題。" --model Opus
328
347
  ```
329
348
 
330
- 可用的模型名稱(視帳號權限與 provider UI 而定):
349
+ 參數規則:
350
+
351
+ - **ChatGPT**:`--reasoning` 支援 `auto`、`instant`、`medium`、`high`,也接受 `智慧`、`即時`、`中`、`中等`、`高` 等對應別名。
352
+ - **Gemini**:`--reasoning extended` 選擇 Extended Thinking;可省略 `--model`,或搭配實際存在的 Pro 模型。
353
+ - **Claude**:不支援 `--reasoning`;`--model` 的 Sonnet、Opus、Haiku 選擇流程維持不變。
331
354
 
332
- - **ChatGPT 模型**:`GPT-5.5`、`GPT-5.4`、`GPT-5.3`、`o3`
333
- - **ChatGPT 思考強度**:`智慧`、`即時`、`中等`、`高`、`超高`、`專業`
334
- - **Gemini 模式**:`3.5 Flash`、`3.1 Flash-Lite`、`3.1 Pro`
335
- - **Claude 模型**:`Sonnet`、`Opus`、`Haiku`(實際名稱依 claude.ai 選單與帳號方案而定)
355
+ 模型比對只使用選單的主標籤,忽略副標題與 badge;比對仍不分大小寫與標點。工具不會把舊版模型名稱自動改選為其他版本。若主標籤不存在,錯誤會列出目前讀到的 provider 選項,並在送出 prompt 前中止。
336
356
 
337
- > 若指定的名稱在選單中找不到,`ask-bridge` 會回報 `Model switch failed: error: model not found in menu` 並中止,不會送出 prompt。
357
+ 舊用法如 `--model 高` 或 Gemini 的 `--model 延伸思考` 暫時仍可使用,但會顯示棄用警告;請改用 `--reasoning`。
338
358
 
339
- ### 10. 只開啟 provider
359
+ ### 12. 只開啟 provider
340
360
 
341
361
  若只想快速開啟瀏覽器並進入所選 provider:
342
362
 
@@ -346,7 +366,7 @@ ask-bridge --provider gemini open
346
366
  ask-bridge --provider claude open
347
367
  ```
348
368
 
349
- ### 11. 關閉瀏覽器 instance
369
+ ### 13. 關閉瀏覽器 instance
350
370
 
351
371
  若要關閉 `ask-bridge` 管理的 Chrome debug profile instance:
352
372
 
@@ -356,7 +376,7 @@ ask-bridge close
356
376
 
357
377
  `close` 只會關閉使用 `~/.config/ask-bridge/chrome-profile` 且監聽 debug port `9223` 的 `ask-bridge` Chrome instance;若該 port 被非 `ask-bridge` Chrome 程序占用,會回報錯誤而不會關閉它。
358
378
 
359
- ### 12. 更新 ask-bridge
379
+ ### 14. 更新 ask-bridge
360
380
 
361
381
  若要直接自動更新目前安裝的 `ask-bridge`,可直接執行:
362
382
 
@@ -5,9 +5,12 @@ const { createHash } = require('node:crypto');
5
5
  const { spawnSync } = require('node:child_process');
6
6
  const {
7
7
  chmodSync,
8
+ closeSync,
8
9
  copyFileSync,
9
10
  existsSync,
10
11
  mkdirSync,
12
+ openSync,
13
+ readSync,
11
14
  readFileSync,
12
15
  readdirSync,
13
16
  rmSync,
@@ -72,6 +75,60 @@ function verifyChecksum(filePath, checksumText) {
72
75
  }
73
76
  }
74
77
 
78
+ function verifyBinaryFormat(filePath, platform = process.platform) {
79
+ const header = Buffer.alloc(4);
80
+ const descriptor = openSync(filePath, 'r');
81
+ let bytesRead;
82
+ try {
83
+ bytesRead = readSync(descriptor, header, 0, header.length, 0);
84
+ } finally {
85
+ closeSync(descriptor);
86
+ }
87
+ const binaryHeader = header.subarray(0, bytesRead);
88
+ const magic = binaryHeader.toString('hex');
89
+ const supportedMagic = {
90
+ win32: ['4d5a'],
91
+ linux: ['7f454c46'],
92
+ darwin: [
93
+ 'feedface',
94
+ 'cefaedfe',
95
+ 'feedfacf',
96
+ 'cffaedfe',
97
+ 'cafebabe',
98
+ 'bebafeca',
99
+ 'cafebabf',
100
+ 'bfbafeca',
101
+ ],
102
+ };
103
+ const expected = supportedMagic[platform];
104
+ if (!expected) {
105
+ throw new Error(`Unsupported platform for binary verification: ${platform}`);
106
+ }
107
+ if (!expected.some((prefix) => magic.startsWith(prefix))) {
108
+ throw new Error(
109
+ `Downloaded binary format does not match ${platform} (header: ${magic || 'empty'})`,
110
+ );
111
+ }
112
+ }
113
+
114
+ function verifyInstalledBinary(filePath, platform = process.platform) {
115
+ verifyBinaryFormat(filePath, platform);
116
+ const result = spawnSync(filePath, ['--version'], { encoding: 'utf8' });
117
+ if (result.error) {
118
+ throw new Error(`Installed binary could not start: ${result.error.message}`);
119
+ }
120
+ if (result.status !== 0) {
121
+ const detail = `${result.stdout || ''}${result.stderr || ''}`.trim();
122
+ throw new Error(
123
+ `Installed binary failed its version check with exit code ${result.status}${detail ? `: ${detail}` : ''}`,
124
+ );
125
+ }
126
+ const output = `${result.stdout || ''}${result.stderr || ''}`.trim();
127
+ if (!/^ask-bridge\s+\d+\.\d+\.\d+/.test(output)) {
128
+ throw new Error(`Installed binary returned unexpected version output: ${output || '(empty)'}`);
129
+ }
130
+ }
131
+
75
132
  function download(url, destination, redirectsRemaining = 5) {
76
133
  return new Promise((resolve, reject) => {
77
134
  get(url, (res) => {
@@ -129,9 +186,11 @@ function findExtractedBinary(dir, binName = BIN_NAME) {
129
186
  function installFromLocalBuild() {
130
187
  const localRelease = join(PACKAGE_ROOT, 'target', 'release', BIN_NAME);
131
188
  if (!existsSync(localRelease)) return false;
189
+ verifyBinaryFormat(localRelease);
132
190
  mkdirSync(BIN_DIR, { recursive: true });
133
191
  copyFileSync(localRelease, DEST);
134
192
  chmodSync(DEST, 0o755);
193
+ verifyInstalledBinary(DEST);
135
194
  return true;
136
195
  }
137
196
 
@@ -151,9 +210,11 @@ async function installFromRelease() {
151
210
  extract(archivePath, tmpDir);
152
211
 
153
212
  const extracted = findExtractedBinary(tmpDir);
213
+ verifyBinaryFormat(extracted);
154
214
  mkdirSync(BIN_DIR, { recursive: true });
155
215
  copyFileSync(extracted, DEST);
156
216
  chmodSync(DEST, 0o755);
217
+ verifyInstalledBinary(DEST);
157
218
  rmSync(tmpDir, { recursive: true, force: true });
158
219
  }
159
220
 
@@ -195,5 +256,7 @@ module.exports = {
195
256
  platformKey,
196
257
  releaseBaseUrl,
197
258
  sha256,
259
+ verifyBinaryFormat,
198
260
  verifyChecksum,
261
+ verifyInstalledBinary,
199
262
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ask-bridge",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
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",
11
+ "test": "node --test tests/postinstall.test.cjs tests/model-selection.test.cjs",
12
12
  "prepublishOnly": "npm test && npm pack --dry-run && node npm/prepublish-check.cjs"
13
13
  },
14
14
  "files": [