@softspark/ai-toolkit 2.0.1 → 2.1.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.
@@ -21,7 +21,6 @@ import json
21
21
  import os
22
22
  import shutil
23
23
  import sys
24
- from datetime import datetime, timezone
25
24
  from pathlib import Path
26
25
 
27
26
  sys.path.insert(0, str(Path(__file__).resolve().parent))
@@ -36,14 +35,16 @@ from paths import (
36
35
  )
37
36
 
38
37
 
39
- MIGRATED_MARKER = LEGACY_DATA_DIR / ".migrated"
40
-
41
-
42
38
  def needs_migration() -> bool:
43
- """Check if legacy directory exists and hasn't been migrated yet."""
39
+ """Check if legacy directory exists and needs migration.
40
+
41
+ Returns True only when ~/.ai-toolkit/ exists AND contains real data
42
+ (not just an empty dir). After migration the directory is removed entirely.
43
+ """
44
44
  if not LEGACY_DATA_DIR.is_dir():
45
45
  return False
46
- if MIGRATED_MARKER.is_file():
46
+ # Empty dir (or only hidden files) — nothing to migrate
47
+ if not any(LEGACY_DATA_DIR.iterdir()):
47
48
  return False
48
49
  # Don't migrate if AI_TOOLKIT_HOME is set (custom setup)
49
50
  if os.environ.get("AI_TOOLKIT_HOME"):
@@ -77,11 +78,10 @@ def migrate_home_directory(dry_run: bool = False) -> bool:
77
78
  else:
78
79
  # Clean move
79
80
  shutil.move(str(LEGACY_DATA_DIR), str(TOOLKIT_DATA_DIR))
80
- # Recreate legacy dir for marker
81
- LEGACY_DATA_DIR.mkdir(parents=True, exist_ok=True)
82
81
 
83
- # Write migration marker
84
- _write_marker()
82
+ # Remove legacy directory entirely
83
+ if LEGACY_DATA_DIR.exists():
84
+ shutil.rmtree(str(LEGACY_DATA_DIR), ignore_errors=True)
85
85
 
86
86
  print(f" Migrated: {TOOLKIT_DATA_DIR}")
87
87
  return True
@@ -103,21 +103,6 @@ def _merge_directories(src: Path, dst: Path) -> None:
103
103
  shutil.move(str(item), str(dest_item))
104
104
 
105
105
 
106
- def _write_marker() -> None:
107
- """Write .migrated marker pointing to new location."""
108
- LEGACY_DATA_DIR.mkdir(parents=True, exist_ok=True)
109
- now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
110
- marker_data = {
111
- "migrated_to": str(TOOLKIT_DATA_DIR),
112
- "migrated_at": now,
113
- "message": "ai-toolkit data has moved to ~/.softspark/ai-toolkit/. "
114
- "This directory is kept as a marker. Safe to delete.",
115
- }
116
- with open(MIGRATED_MARKER, "w", encoding="utf-8") as f:
117
- json.dump(marker_data, f, indent=2)
118
- f.write("\n")
119
-
120
-
121
106
  def migrate_project_configs(dry_run: bool = False) -> int:
122
107
  """Rename .ai-toolkit.json → .softspark-toolkit.json in registered projects.
123
108
 
@@ -231,8 +216,7 @@ def main() -> None:
231
216
 
232
217
  if success:
233
218
  print()
234
- print("Migration complete. The old ~/.ai-toolkit/ directory contains only a")
235
- print("migration marker and can be safely deleted.")
219
+ print("Migration complete. ~/.ai-toolkit/ has been removed.")
236
220
  elif not dry_run:
237
221
  print("Migration skipped.")
238
222