@tiens.nguyen/gu-cli 1.0.845 → 1.0.846

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 (2) hide show
  1. package/gu_browser.py +26 -5
  2. package/package.json +1 -1
package/gu_browser.py CHANGED
@@ -221,6 +221,22 @@ def _is_gu(ext_id, entry):
221
221
  return False
222
222
 
223
223
 
224
+ # Chrome keeps an EMPTY record ({}) for an extension ID it once saw (e.g. removed, or a store page
225
+ # visited) — no location, path or manifest. That is not an install (task #401: the agent said
226
+ # "installed but not connected" when the user had never clicked "Add to Chrome").
227
+ _RECORD_KEYS = ("location", "path", "manifest", "state", "install_time", "first_install_time", "disable_reasons")
228
+
229
+
230
+ def _is_real_record(entry, profile_dir=None, ext_id=None):
231
+ if not any(k in entry for k in _RECORD_KEYS):
232
+ return False
233
+ path = entry.get("path")
234
+ if profile_dir and isinstance(path, str) and path and not os.path.isabs(path):
235
+ # a store install lives in <profile>/Extensions/<id>/<version>
236
+ return os.path.isdir(os.path.join(profile_dir, "Extensions", path))
237
+ return True
238
+
239
+
224
240
  def find_installs(roots=None):
225
241
  """→ [{browser, profile, id, kind: "store"|"developer", enabled}] for every browser profile with
226
242
  the gu extension. Reads the profiles' Preferences only — gu never writes a browser's files."""
@@ -239,7 +255,8 @@ def find_installs(roots=None):
239
255
  except (OSError, ValueError, AttributeError):
240
256
  continue
241
257
  for ext_id, e in settings.items():
242
- if ext_id in seen or not isinstance(e, dict) or not _is_gu(ext_id, e):
258
+ if ext_id in seen or not isinstance(e, dict) or not _is_gu(ext_id, e) \
259
+ or not _is_real_record(e, os.path.join(d, prof), ext_id):
243
260
  continue
244
261
  seen.add(ext_id)
245
262
  reasons = e.get("disable_reasons")
@@ -250,10 +267,14 @@ def find_installs(roots=None):
250
267
 
251
268
 
252
269
  def diagnose(installs):
253
- """→ "missing" (not in any browser), "disabled" (only turned-off copies) or "installed"."""
254
- if not installs:
255
- return "missing"
256
- return "installed" if any(i["enabled"] for i in installs) else "disabled"
270
+ """→ "missing" (not in any browser), "disabled" (only turned-off copies) or "installed".
271
+ A turned-off DEVELOPER (unpacked) copy alone counts as missing: the fix is the store's
272
+ "Add to Chrome", not switching an old unpacked copy back on."""
273
+ if any(i["enabled"] for i in installs):
274
+ return "installed"
275
+ if any(i.get("kind") == "store" for i in installs):
276
+ return "disabled"
277
+ return "missing"
257
278
 
258
279
 
259
280
  def _offered_path():
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gu-cli",
3
- "version": "1.0.845",
3
+ "version": "1.0.846",
4
4
  "description": "Gu CLI — the gu terminal plus the local worker that runs agent / OCR / PDF / embedding jobs on your Mac (Ollama / MLX / OpenAI-compatible).",
5
5
  "type": "module",
6
6
  "license": "MIT",