opencode-antigravity-auth 1.1.4 → 1.2.1

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.
Files changed (60) hide show
  1. package/README.md +223 -99
  2. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  3. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  4. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  5. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  6. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  7. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  8. package/dist/src/hooks/auto-update-checker/checker.js +237 -0
  9. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  10. package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
  11. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  12. package/dist/src/hooks/auto-update-checker/constants.js +23 -0
  13. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  14. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  15. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  16. package/dist/src/hooks/auto-update-checker/index.js +121 -0
  17. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  18. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  19. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  20. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  21. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  22. package/dist/src/plugin/accounts.d.ts +21 -10
  23. package/dist/src/plugin/accounts.d.ts.map +1 -1
  24. package/dist/src/plugin/accounts.js +101 -55
  25. package/dist/src/plugin/accounts.js.map +1 -1
  26. package/dist/src/plugin/cache.d.ts +14 -0
  27. package/dist/src/plugin/cache.d.ts.map +1 -1
  28. package/dist/src/plugin/cache.js +82 -0
  29. package/dist/src/plugin/cache.js.map +1 -1
  30. package/dist/src/plugin/debug.d.ts +32 -0
  31. package/dist/src/plugin/debug.d.ts.map +1 -1
  32. package/dist/src/plugin/debug.js +140 -12
  33. package/dist/src/plugin/debug.js.map +1 -1
  34. package/dist/src/plugin/request-helpers.d.ts +13 -4
  35. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  36. package/dist/src/plugin/request-helpers.js +171 -18
  37. package/dist/src/plugin/request-helpers.js.map +1 -1
  38. package/dist/src/plugin/request.d.ts +10 -2
  39. package/dist/src/plugin/request.d.ts.map +1 -1
  40. package/dist/src/plugin/request.js +614 -67
  41. package/dist/src/plugin/request.js.map +1 -1
  42. package/dist/src/plugin/storage.d.ts +23 -7
  43. package/dist/src/plugin/storage.d.ts.map +1 -1
  44. package/dist/src/plugin/storage.js +54 -10
  45. package/dist/src/plugin/storage.js.map +1 -1
  46. package/dist/src/plugin/types.d.ts +13 -1
  47. package/dist/src/plugin/types.d.ts.map +1 -1
  48. package/dist/src/plugin.d.ts +3 -3
  49. package/dist/src/plugin.d.ts.map +1 -1
  50. package/dist/src/plugin.js +780 -474
  51. package/dist/src/plugin.js.map +1 -1
  52. package/package.json +1 -1
  53. package/dist/src/plugin/accounts.test.d.ts +0 -2
  54. package/dist/src/plugin/accounts.test.d.ts.map +0 -1
  55. package/dist/src/plugin/accounts.test.js +0 -139
  56. package/dist/src/plugin/accounts.test.js.map +0 -1
  57. package/dist/src/plugin/token.test.d.ts +0 -2
  58. package/dist/src/plugin/token.test.d.ts.map +0 -1
  59. package/dist/src/plugin/token.test.js +0 -64
  60. package/dist/src/plugin/token.test.js.map +0 -1
package/README.md CHANGED
@@ -8,137 +8,234 @@ Enable Opencode to authenticate against **Antigravity** (Google's IDE) via OAuth
8
8
 
9
9
  - **Google OAuth sign-in** (multi-account via `opencode auth login`) with automatic token refresh
10
10
  - **Multi-account load balancing** Automatically cycle through multiple Google accounts to maximize rate limits
11
+ - **Real-time SSE streaming** including thinking blocks and incremental output
12
+ - **Advanced Claude support** Interleaved thinking, stable multi-turn signatures, and validated tool calling
11
13
  - **Automatic endpoint fallback** between Antigravity API endpoints (daily → autopush → prod)
12
14
  - **Antigravity API compatibility** for OpenAI-style requests
13
15
  - **Debug logging** for requests and responses
14
16
  - **Drop-in setup** Opencode auto-installs the plugin from config
15
17
 
16
- ## Quick start
18
+ ## Installation
17
19
 
18
- ### Step 1: Create your config file
20
+ ### For Humans
19
21
 
20
- If this is your first time using Opencode, create the config directory first:
22
+ **Option A: Let an LLM do it for you**
23
+
24
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
25
+
26
+ ```
27
+ Install the opencode-antigravity-auth plugin and add the Antigravity model definitions (see "Available models") to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/README.md
28
+ ```
29
+
30
+ If the agent only installs the plugin, ask it to also add models under `provider.google.models`.
31
+
32
+ **Option B: Do it yourself**
33
+
34
+ 1. **Add the plugin to your config:**
35
+
36
+ ```bash
37
+ mkdir -p ~/.config/opencode
38
+ ```
39
+
40
+ Create or edit `~/.config/opencode/opencode.json`:
41
+
42
+ ```json
43
+ {
44
+ "plugin": ["opencode-antigravity-auth@1.2.1"]
45
+ }
46
+ ```
47
+
48
+ 2. **Authenticate:**
49
+
50
+ ```bash
51
+ opencode auth login
52
+ ```
53
+
54
+ Select **Google** → **OAuth with Google (Antigravity)** → Press Enter to skip Project ID → Sign in via browser.
55
+
56
+ 3. **Add models to your config:**
57
+
58
+ Add the models you want to use to the same config file:
59
+
60
+ ```json
61
+ {
62
+ "plugin": ["opencode-antigravity-auth@1.2.1"],
63
+ "provider": {
64
+ "google": {
65
+ "models": {
66
+ "gemini-3-pro-high": {
67
+ "name": "Gemini 3 Pro High (Antigravity)",
68
+ "limit": { "context": 1048576, "output": 65535 },
69
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
70
+ },
71
+ "claude-sonnet-4-5": {
72
+ "name": "Claude Sonnet 4.5 (Antigravity)",
73
+ "limit": { "context": 200000, "output": 64000 },
74
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ > See [Available models](#available-models) for the full list.
83
+
84
+ 4. **Use it:**
85
+
86
+ ```bash
87
+ opencode run "Hello" --model=google/gemini-3-pro-high
88
+ ```
89
+
90
+ ---
91
+
92
+ ### For LLMs
93
+
94
+ <details>
95
+ <summary><b>🤖 Detailed Installation Guide for LLM Agents</b> (click to expand)</summary>
96
+
97
+ If you're an LLM agent helping a user set up this plugin, follow these steps:
98
+
99
+ #### Step 1: Verify OpenCode is installed
21
100
 
22
101
  ```bash
23
- mkdir -p ~/.config/opencode
102
+ command -v opencode && opencode --version || echo "OpenCode not installed - see https://opencode.ai/docs"
24
103
  ```
25
104
 
26
- Then create or edit the config file at `~/.config/opencode/opencode.json`:
105
+ #### Step 2: Create or update the config
27
106
 
28
- ```json
29
- {
30
- "plugin": ["opencode-antigravity-auth@1.1.4"]
31
- }
107
+ ```bash
108
+ mkdir -p ~/.config/opencode
109
+
110
+ if [ -f ~/.config/opencode/opencode.json ]; then
111
+ if command -v jq &> /dev/null; then
112
+ jq '.plugin = ((.plugin // []) + ["opencode-antigravity-auth@1.2.1"] | unique)' \
113
+ ~/.config/opencode/opencode.json > /tmp/oc.json && \
114
+ mv /tmp/oc.json ~/.config/opencode/opencode.json
115
+ else
116
+ echo "Add \"opencode-antigravity-auth@1.2.1\" to the plugin array manually"
117
+ fi
118
+ else
119
+ echo '{"plugin":["opencode-antigravity-auth@1.2.1"]}' > ~/.config/opencode/opencode.json
120
+ fi
32
121
  ```
33
122
 
34
- > **Note:** You can also use a project-local `.opencode.json` file in your project root instead. The global config at `~/.config/opencode/opencode.json` applies to all projects.
123
+ #### Step 3: Ask user about multi-account setup
35
124
 
36
- ### Step 2: Authenticate
125
+ Before running `opencode auth login`, ask the user:
37
126
 
38
- Run the authentication command:
127
+ > **Do you want to add multiple Google accounts for load balancing?**
128
+ > - Adding 2-10 accounts maximizes rate limits and provides automatic failover
129
+ > - You can always add more accounts later
130
+
131
+ Based on their answer:
132
+ - **Yes, multiple accounts** → After first login, prompt: "Sign in complete. Add another account? (up to 10 supported)"
133
+ - **No, just one** → Single account is fine, they can add more later with `opencode auth login`
134
+
135
+ #### Step 4: Run authentication
136
+
137
+ Tell the user to run:
39
138
 
40
139
  ```bash
41
140
  opencode auth login
42
141
  ```
43
142
 
143
+ Guide them through the prompts:
44
144
  1. Select **Google** as the provider
45
145
  2. Select **OAuth with Google (Antigravity)**
46
- 3. **Project ID prompt:** You'll see this prompt:
47
- ```
48
- Project ID (leave blank to use your default project):
49
- ```
50
- **Just press Enter to skip this** — it's optional and only needed if you want to use a specific Google Cloud project. Most users can leave it blank.
51
- 4. Sign in via the browser and return to Opencode. If the browser doesn't open, copy the displayed URL manually.
52
- 5. After signing in, you can add more Google accounts (up to 10) for load balancing, or press Enter to finish.
146
+ 3. **Project ID prompt** → Tell user: "Press Enter to skip (most users don't need this)"
147
+ 4. Browser opens for Google sign-in
148
+ 5. If multi-account: repeat for additional accounts, or press Enter to finish
149
+
150
+ #### Step 5: Add models to config
151
+
152
+ Merge model definitions into the user's config file (`~/.config/opencode/opencode.json`):
153
+
154
+ ```bash
155
+ # If jq is available, merge models programmatically
156
+ if command -v jq &> /dev/null; then
157
+ jq '.provider.google.models = {
158
+ "gemini-3-pro-high": {"name": "Gemini 3 Pro High (Antigravity)", "limit": {"context": 1048576, "output": 65535}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}},
159
+ "gemini-3-pro-low": {"name": "Gemini 3 Pro Low (Antigravity)", "limit": {"context": 1048576, "output": 65535}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}},
160
+ "gemini-3-flash": {"name": "Gemini 3 Flash (Antigravity)", "limit": {"context": 1048576, "output": 65536}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}},
161
+ "claude-sonnet-4-5": {"name": "Claude Sonnet 4.5 (Antigravity)", "limit": {"context": 200000, "output": 64000}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}},
162
+ "claude-sonnet-4-5-thinking": {"name": "Claude Sonnet 4.5 Thinking (Antigravity)", "limit": {"context": 200000, "output": 64000}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}},
163
+ "claude-opus-4-5-thinking": {"name": "Claude Opus 4.5 Thinking (Antigravity)", "limit": {"context": 200000, "output": 64000}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}},
164
+ "gpt-oss-120b-medium": {"name": "GPT-OSS 120B Medium (Antigravity)", "limit": {"context": 131072, "output": 32768}, "modalities": {"input": ["text", "image", "pdf"], "output": ["text"]}}
165
+ } + (.provider.google.models // {})' ~/.config/opencode/opencode.json > /tmp/oc.json && mv /tmp/oc.json ~/.config/opencode/opencode.json
166
+ fi
167
+ ```
168
+
169
+ Or edit the file manually and add the models from the [Available models](#available-models) section.
170
+
171
+ #### Step 6: Verify setup
53
172
 
54
- > **Alternative:** For a quick single-account setup without project ID options, open `opencode` and use the `/connect` command instead.
173
+ ```bash
174
+ opencode run "Hello" --model=google/gemini-3-pro-high
175
+ ```
55
176
 
56
- ### Step 3: Add the models you want to use
177
+ If successful, tell the user: **"Setup complete! You can now use Antigravity models in OpenCode."**
57
178
 
58
- Open the **same config file** you created in Step 1 (`~/.config/opencode/opencode.json`) and add the models under `provider.google.models`:
179
+ </details>
180
+
181
+ ---
182
+
183
+ ## Available models
184
+
185
+ Add these models to your `~/.config/opencode/opencode.json` under `provider.google.models`:
186
+
187
+ | Model ID | Description |
188
+ |----------|-------------|
189
+ | `gemini-3-pro-high` | Gemini 3 Pro High |
190
+ | `gemini-3-pro-low` | Gemini 3 Pro Low |
191
+ | `gemini-3-flash` | Gemini 3 Flash |
192
+ | `claude-sonnet-4-5` | Claude Sonnet 4.5 |
193
+ | `claude-sonnet-4-5-thinking` | Claude Sonnet 4.5 with thinking |
194
+ | `claude-opus-4-5-thinking` | Claude Opus 4.5 with thinking |
195
+ | `gpt-oss-120b-medium` | GPT-OSS 120B Medium |
196
+
197
+ <details>
198
+ <summary><b>Full model configuration</b> (click to expand)</summary>
59
199
 
60
200
  ```json
61
201
  {
62
- "plugin": ["opencode-antigravity-auth@1.1.4"],
63
202
  "provider": {
64
203
  "google": {
65
204
  "models": {
66
205
  "gemini-3-pro-high": {
67
206
  "name": "Gemini 3 Pro High (Antigravity)",
68
- "limit": {
69
- "context": 1048576,
70
- "output": 65535
71
- },
72
- "modalities": {
73
- "input": ["text", "image", "pdf"],
74
- "output": ["text"]
75
- }
207
+ "limit": { "context": 1048576, "output": 65535 },
208
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
76
209
  },
77
210
  "gemini-3-pro-low": {
78
211
  "name": "Gemini 3 Pro Low (Antigravity)",
79
- "limit": {
80
- "context": 1048576,
81
- "output": 65535
82
- },
83
- "modalities": {
84
- "input": ["text", "image", "pdf"],
85
- "output": ["text"]
86
- }
212
+ "limit": { "context": 1048576, "output": 65535 },
213
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
87
214
  },
88
215
  "gemini-3-flash": {
89
216
  "name": "Gemini 3 Flash (Antigravity)",
90
- "limit": {
91
- "context": 1048576,
92
- "output": 65536
93
- },
94
- "modalities": {
95
- "input": ["text", "image", "pdf"],
96
- "output": ["text"]
97
- }
217
+ "limit": { "context": 1048576, "output": 65536 },
218
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
98
219
  },
99
220
  "claude-sonnet-4-5": {
100
221
  "name": "Claude Sonnet 4.5 (Antigravity)",
101
- "limit": {
102
- "context": 200000,
103
- "output": 64000
104
- },
105
- "modalities": {
106
- "input": ["text", "image", "pdf"],
107
- "output": ["text"]
108
- }
222
+ "limit": { "context": 200000, "output": 64000 },
223
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
109
224
  },
110
225
  "claude-sonnet-4-5-thinking": {
111
226
  "name": "Claude Sonnet 4.5 Thinking (Antigravity)",
112
- "limit": {
113
- "context": 200000,
114
- "output": 64000
115
- },
116
- "modalities": {
117
- "input": ["text", "image", "pdf"],
118
- "output": ["text"]
119
- }
227
+ "limit": { "context": 200000, "output": 64000 },
228
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
120
229
  },
121
230
  "claude-opus-4-5-thinking": {
122
231
  "name": "Claude Opus 4.5 Thinking (Antigravity)",
123
- "limit": {
124
- "context": 200000,
125
- "output": 64000
126
- },
127
- "modalities": {
128
- "input": ["text", "image", "pdf"],
129
- "output": ["text"]
130
- }
232
+ "limit": { "context": 200000, "output": 64000 },
233
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
131
234
  },
132
235
  "gpt-oss-120b-medium": {
133
236
  "name": "GPT-OSS 120B Medium (Antigravity)",
134
- "limit": {
135
- "context": 131072,
136
- "output": 32768
137
- },
138
- "modalities": {
139
- "input": ["text", "image", "pdf"],
140
- "output": ["text"]
141
- }
237
+ "limit": { "context": 131072, "output": 32768 },
238
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
142
239
  }
143
240
  }
144
241
  }
@@ -146,19 +243,7 @@ Open the **same config file** you created in Step 1 (`~/.config/opencode/opencod
146
243
  }
147
244
  ```
148
245
 
149
- > **Tip:** You only need to add the models you plan to use. The example above includes all available models, but you can remove any you don't need. The `modalities` field enables image and PDF support in the TUI.
150
-
151
- ### Step 4: Use a model
152
-
153
- ```bash
154
- opencode run "Hello world" --model=google/gemini-3-pro-high
155
- ```
156
-
157
- Or start the interactive TUI and select a model from the model picker:
158
-
159
- ```bash
160
- opencode
161
- ```
246
+ </details>
162
247
 
163
248
  ## Multi-account load balancing
164
249
 
@@ -166,11 +251,23 @@ The plugin supports multiple Google accounts to maximize rate limits and provide
166
251
 
167
252
  ### How it works
168
253
 
169
- - **Round-robin selection:** Each request uses the next account in the pool
170
- - **Automatic failover:** On HTTP `429` (rate limit), the plugin automatically switches to the next available account
171
- - **Smart cooldown:** Rate-limited accounts are temporarily cooled down and automatically become available again after the cooldown expires
172
- - **Single-account retry:** If you only have one account, the plugin waits for the rate limit to reset and retries automatically
173
- - **Toast notifications:** The TUI shows which account is being used and when switching occurs
254
+ - **Sticky account selection:** The plugin sticks to the same account for all requests until it hits a rate limit. This preserves Anthropic's prompt cache, which is organization-scoped.
255
+ - **Per-model-family rate limits:** Rate limits are tracked separately for Claude and Gemini models. If an account is rate-limited for Claude, it can still be used for Gemini requests.
256
+ - **Smart retry threshold:** Short rate limits (≤5s) are retried on the same account to avoid unnecessary switching.
257
+ - **Exponential backoff:** Consecutive rate limits trigger exponential backoff with increasing delays.
258
+ - **Quota-aware messages:** Rate limit toasts show quota reset times when available from the API.
259
+ - **Automatic failover:** On HTTP `429` (rate limit), the plugin automatically switches to the next available account for that model family.
260
+ - **Smart cooldown:** Rate-limited accounts are temporarily cooled down and automatically become available again after the cooldown expires.
261
+ - **Single-account retry:** If you only have one account, the plugin waits for the rate limit to reset and retries automatically.
262
+ - **Debounced notifications:** Toast notifications are debounced to avoid spam during streaming responses.
263
+
264
+ ### Quiet mode
265
+
266
+ To suppress account-related toast notifications (useful for streaming/recording):
267
+
268
+ ```bash
269
+ export OPENCODE_ANTIGRAVITY_QUIET=1
270
+ ```
174
271
 
175
272
  ### Adding accounts
176
273
 
@@ -204,15 +301,42 @@ The `/connect` command in the TUI adds accounts non-destructively — it will ne
204
301
  - If Google revokes a refresh token (`invalid_grant`), that account is automatically removed from the pool
205
302
  - Rerun `opencode auth login` to re-add the account
206
303
 
304
+ ## Architecture & Flow
305
+
306
+ For contributors and advanced users, see the detailed documentation:
307
+
308
+ - **[Claude Model Flow](docs/CLAUDE_MODEL_FLOW.md)** - Full request/response flow, improvements, and fixes
309
+ - **[Antigravity API Spec](docs/ANTIGRAVITY_API_SPEC.md)** - API reference and schema support matrix
310
+
311
+ ## Streaming & thinking
312
+
313
+ This plugin supports **real-time SSE streaming**, meaning you see thinking blocks and text output incrementally as they are generated.
314
+
315
+ ### Claude Thinking & Tools
316
+
317
+ For models like `claude-opus-4-5-thinking`:
318
+
319
+ - **Interleaved Thinking:** The plugin automatically enables `anthropic-beta: interleaved-thinking-2025-05-14`. This allows Claude to think *between* tool calls and after tool results, improving complex reasoning.
320
+ - **Smart System Hints:** A system instruction is silently added to encourage the model to "think" before and during tool use.
321
+ - **Multi-turn Stability:** Thinking signatures are cached and restored using a stable `sessionId`, preventing "invalid signature" errors in long conversations.
322
+ - **Thinking Budget Safety:** If a thinking budget is enabled, the plugin ensures output token limits are high enough to avoid budget-related errors.
323
+ - **Tool Use:** Tool calls and responses are assigned proper IDs, and tool calling is set to validated mode for better Claude compatibility.
324
+
325
+ **Troubleshooting:** If you see signature errors in multi-turn tool loops, restart `opencode` to reset the plugin session/signature cache.
326
+
207
327
  ## Debugging
208
328
 
209
- Enable verbose logging:
329
+ Enable debug logging via environment variable:
210
330
 
211
331
  ```bash
212
332
  export OPENCODE_ANTIGRAVITY_DEBUG=1
213
333
  ```
214
334
 
215
- Logs are written to the current directory (e.g., `antigravity-debug-<timestamp>.log`).
335
+ - **Level 1 (`1` or `true`):** Basic logging of URLs, headers, status codes, and request/response previews.
336
+ - **Level 2 (`2` or `verbose`):** Verbose logging including full request and response bodies (up to 50KB).
337
+ - **TUI Reasoning View:** Debug logs are injected into the model's "thinking/reasoning" blocks in the Opencode TUI (requires thinking-capable models).
338
+ - **Log Files:** Logs are written to `~/.config/opencode/antigravity-logs/antigravity-debug-<timestamp>.log`. Override with `OPENCODE_ANTIGRAVITY_LOG_DIR`.
339
+ - **Auto-Stripping:** Injected debug blocks are automatically stripped from outgoing requests to prevent leaking into conversation history.
216
340
 
217
341
  ## Development
218
342
 
@@ -0,0 +1,3 @@
1
+ export declare function invalidatePackage(packageName?: string): boolean;
2
+ export declare function invalidateCache(): boolean;
3
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../src/hooks/auto-update-checker/cache.ts"],"names":[],"mappings":"AA+CA,wBAAgB,iBAAiB,CAAC,WAAW,GAAE,MAAqB,GAAG,OAAO,CAsC7E;AAED,wBAAgB,eAAe,IAAI,OAAO,CAGzC"}
@@ -0,0 +1,71 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { CACHE_DIR, PACKAGE_NAME } from "./constants";
4
+ function stripTrailingCommas(json) {
5
+ return json.replace(/,(\s*[}\]])/g, "$1");
6
+ }
7
+ function removeFromBunLock(packageName) {
8
+ const lockPath = path.join(CACHE_DIR, "bun.lock");
9
+ if (!fs.existsSync(lockPath))
10
+ return false;
11
+ try {
12
+ const content = fs.readFileSync(lockPath, "utf-8");
13
+ const lock = JSON.parse(stripTrailingCommas(content));
14
+ let modified = false;
15
+ if (lock.workspaces?.[""]?.dependencies?.[packageName]) {
16
+ delete lock.workspaces[""].dependencies[packageName];
17
+ modified = true;
18
+ }
19
+ if (lock.packages?.[packageName]) {
20
+ delete lock.packages[packageName];
21
+ modified = true;
22
+ }
23
+ if (modified) {
24
+ fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2));
25
+ console.log(`[auto-update-checker] Removed from bun.lock: ${packageName}`);
26
+ }
27
+ return modified;
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
33
+ export function invalidatePackage(packageName = PACKAGE_NAME) {
34
+ try {
35
+ const pkgDir = path.join(CACHE_DIR, "node_modules", packageName);
36
+ const pkgJsonPath = path.join(CACHE_DIR, "package.json");
37
+ let packageRemoved = false;
38
+ let dependencyRemoved = false;
39
+ let lockRemoved = false;
40
+ if (fs.existsSync(pkgDir)) {
41
+ fs.rmSync(pkgDir, { recursive: true, force: true });
42
+ console.log(`[auto-update-checker] Package removed: ${pkgDir}`);
43
+ packageRemoved = true;
44
+ }
45
+ if (fs.existsSync(pkgJsonPath)) {
46
+ const content = fs.readFileSync(pkgJsonPath, "utf-8");
47
+ const pkgJson = JSON.parse(content);
48
+ if (pkgJson.dependencies?.[packageName]) {
49
+ delete pkgJson.dependencies[packageName];
50
+ fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
51
+ console.log(`[auto-update-checker] Dependency removed from package.json: ${packageName}`);
52
+ dependencyRemoved = true;
53
+ }
54
+ }
55
+ lockRemoved = removeFromBunLock(packageName);
56
+ if (!packageRemoved && !dependencyRemoved && !lockRemoved) {
57
+ console.log(`[auto-update-checker] Package not found, nothing to invalidate: ${packageName}`);
58
+ return false;
59
+ }
60
+ return true;
61
+ }
62
+ catch (err) {
63
+ console.error("[auto-update-checker] Failed to invalidate package:", err);
64
+ return false;
65
+ }
66
+ }
67
+ export function invalidateCache() {
68
+ console.warn("[auto-update-checker] WARNING: invalidateCache is deprecated, use invalidatePackage");
69
+ return invalidatePackage();
70
+ }
71
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../../src/hooks/auto-update-checker/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWtD,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAgB,CAAC;QACrE,IAAI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
+ import type { UpdateCheckResult } from "./types";
2
+ export declare function isLocalDevMode(directory: string): boolean;
3
+ export declare function getLocalDevPath(directory: string): string | null;
4
+ export declare function getLocalDevVersion(directory: string): string | null;
5
+ export interface PluginEntryInfo {
6
+ entry: string;
7
+ isPinned: boolean;
8
+ pinnedVersion: string | null;
9
+ configPath: string;
10
+ }
11
+ export declare function findPluginEntry(directory: string): PluginEntryInfo | null;
12
+ export declare function getCachedVersion(): string | null;
13
+ export declare function updatePinnedVersion(configPath: string, oldEntry: string, newVersion: string): boolean;
14
+ export declare function getLatestVersion(): Promise<string | null>;
15
+ export declare function checkForUpdate(directory: string): Promise<UpdateCheckResult>;
16
+ //# sourceMappingURL=checker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../../src/hooks/auto-update-checker/checker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA4C,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAe3F,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEzD;AAkBD,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAuBhE;AA4BD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAanE;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA2BzE;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAwBhD;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAgDrG;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmB/D;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA2BlF"}