@softspark/ai-toolkit 4.17.0 → 4.19.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.
@@ -16,6 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import argparse
18
18
  import copy
19
+ import importlib
19
20
  import json
20
21
  import os
21
22
  import re
@@ -1324,6 +1325,28 @@ def _parse_args(argv: list[str]) -> argparse.Namespace:
1324
1325
  return args
1325
1326
 
1326
1327
 
1328
+ def _remove_editor_hook_configs(target: Path) -> None:
1329
+ """Strip toolkit hook entries from editor configs that have no other cleanup.
1330
+
1331
+ Best effort by design: a missing generator or an unreadable config must not
1332
+ abort an uninstall that has already removed the primary surfaces.
1333
+ """
1334
+ for module_name, label in (
1335
+ ("generate_cursor_hooks", "Cursor"),
1336
+ ("generate_gemini_hooks", "Gemini"),
1337
+ ):
1338
+ try:
1339
+ module = importlib.import_module(module_name)
1340
+ cleanup = getattr(module, "cleanup", None)
1341
+ if cleanup is None:
1342
+ continue
1343
+ cleanup(target)
1344
+ except (ImportError, OSError, RuntimeError, ValueError) as error:
1345
+ print(f" WARN could not clean {label} hooks: {error}")
1346
+ else:
1347
+ print(f" Cleaned: {label} hook entries")
1348
+
1349
+
1327
1350
  def main(argv: list[str] | None = None) -> None:
1328
1351
  args = _parse_args(sys.argv[1:] if argv is None else argv)
1329
1352
  explicit_target = args.target or args.legacy_target
@@ -1412,6 +1435,12 @@ def main(argv: list[str] | None = None) -> None:
1412
1435
  for surface in copilot:
1413
1436
  _preflight(target, claude, [], [surface])
1414
1437
  _remove_copilot(surface)
1438
+ # Cursor and Gemini hook configs were never cleaned: uninstall knew
1439
+ # only Codex and Copilot, so `.cursor/hooks.json` and the hooks block in
1440
+ # `.gemini/settings.json` survived an uninstall. Both cleanups strip
1441
+ # only entries tagged `ai-toolkit`, leaving user-authored and
1442
+ # plugin-pack entries and any unrelated settings in place.
1443
+ _remove_editor_hook_configs(target)
1415
1444
  if recovery_root is not None and recovery_components:
1416
1445
  # The recovery API preflights its complete tree before the first
1417
1446
  # unlink. A later I/O fault can still leave recovery partially