@jcorpac/skill-vault 1.7.0 → 1.8.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.
- package/README.md +3 -0
- package/SKILL.md +17 -1
- package/package.json +1 -1
- package/scripts/skill_vault.py +324 -18
package/README.md
CHANGED
|
@@ -112,6 +112,9 @@ python scripts/skill_vault.py verify
|
|
|
112
112
|
| `skill-vault config --sync-prompt` | Dynamically update `SKILL.md`'s router description with your vault's categories. |
|
|
113
113
|
| `skill-vault verify` | Audit bi-directional consistency across disk, manifest, and index. |
|
|
114
114
|
| `skill-vault verify --fix` | Audit and automatically self-heal all detected discrepancies. |
|
|
115
|
+
| `skill-vault uninstall` | Cleanly restore all archived skills to L1 (preserving newer L1 versions), verify, and remove archive + `skill-vault` (alias: `eject`). |
|
|
116
|
+
| `skill-vault uninstall --dry-run` | Preview the uninstall restoration and cleanup plan without modifying files. |
|
|
117
|
+
| `skill-vault uninstall --keep-archive` | Restore all skills to L1 and remove `skill-vault`, while preserving/relocating `skill_archive`. |
|
|
115
118
|
|
|
116
119
|
---
|
|
117
120
|
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: skill-vault
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.8.0
|
|
4
4
|
description: >-
|
|
5
5
|
Universal agent-agnostic skill router, lifecycle manager, and tiered storage engine for AI coding agents.
|
|
6
6
|
ALWAYS use this skill whenever a task involves specialized domain skills, frameworks, or tools not currently loaded in active context memory (L1), or when managing skill context bloat.
|
|
@@ -204,6 +204,22 @@ Any individual skill's `SKILL.md` frontmatter can also declare:
|
|
|
204
204
|
- `core: true` (or `pinned: true` / `always_active: true`) to automatically protect that skill during `sync` and `optimize`.
|
|
205
205
|
- `category: "<Category>"` to pin its vault category without needing `--category` flags.
|
|
206
206
|
|
|
207
|
+
### M. Clean Uninstallation & Safe Decommissioning (`uninstall` / `eject`)
|
|
208
|
+
To cleanly remove or replace `skill-vault` without losing any archived skills or overwriting newer active L1 versions:
|
|
209
|
+
```bash
|
|
210
|
+
# Preview restoration and cleanup plan without modifying files
|
|
211
|
+
python scripts/skill_vault.py uninstall --dry-run
|
|
212
|
+
|
|
213
|
+
# Restore all archived skills to L1 (preserving newer L1 versions), verify SKILL.md files, and remove archive + skill-vault
|
|
214
|
+
python scripts/skill_vault.py uninstall
|
|
215
|
+
|
|
216
|
+
# Keep skill_archive as a backup (relocates it out of skills/skill-vault if nested)
|
|
217
|
+
python scripts/skill_vault.py uninstall --keep-archive
|
|
218
|
+
|
|
219
|
+
# Restore all skills and clear archive, while keeping the skill-vault folder itself
|
|
220
|
+
python scripts/skill_vault.py uninstall --keep-skill
|
|
221
|
+
```
|
|
222
|
+
|
|
207
223
|
---
|
|
208
224
|
|
|
209
225
|
## 3. Environment & OS Compatibility Guidelines
|
package/package.json
CHANGED
package/scripts/skill_vault.py
CHANGED
|
@@ -334,7 +334,14 @@ def get_skill_metadata(skill_dir):
|
|
|
334
334
|
|
|
335
335
|
latest_mtime = 0.0
|
|
336
336
|
try:
|
|
337
|
-
files = [
|
|
337
|
+
files = []
|
|
338
|
+
if skill_dir.exists():
|
|
339
|
+
for root, dirs, filenames in os.walk(skill_dir):
|
|
340
|
+
root_path = Path(root)
|
|
341
|
+
# Do not bleed mtimes from nested sibling skill folders inside a single_skill_dir
|
|
342
|
+
dirs[:] = [d for d in dirs if not (root_path / d / "SKILL.md").exists()]
|
|
343
|
+
for fname in filenames:
|
|
344
|
+
files.append(root_path / fname)
|
|
338
345
|
if files:
|
|
339
346
|
latest_mtime = max(f.stat().st_mtime for f in files)
|
|
340
347
|
elif skill_dir.exists():
|
|
@@ -619,13 +626,22 @@ class SkillVault:
|
|
|
619
626
|
for folder in base.iterdir():
|
|
620
627
|
if folder.is_dir():
|
|
621
628
|
skill_md = folder / "SKILL.md"
|
|
622
|
-
|
|
629
|
+
has_md = skill_md.exists()
|
|
630
|
+
candidate = {
|
|
623
631
|
"name": folder.name,
|
|
624
632
|
"folder": folder,
|
|
625
633
|
"skill_md": skill_md,
|
|
626
|
-
"has_skill_md":
|
|
627
|
-
"size": skill_md.stat().st_size if
|
|
634
|
+
"has_skill_md": has_md,
|
|
635
|
+
"size": skill_md.stat().st_size if has_md else 0,
|
|
628
636
|
}
|
|
637
|
+
existing = folders.get(folder.name)
|
|
638
|
+
if existing is None:
|
|
639
|
+
folders[folder.name] = candidate
|
|
640
|
+
elif has_md and (
|
|
641
|
+
not existing["has_skill_md"]
|
|
642
|
+
or compare_skill_recency(folder, existing["folder"]) > 0
|
|
643
|
+
):
|
|
644
|
+
folders[folder.name] = candidate
|
|
629
645
|
return folders
|
|
630
646
|
|
|
631
647
|
def load_manifest(self):
|
|
@@ -678,11 +694,40 @@ class SkillVault:
|
|
|
678
694
|
return target
|
|
679
695
|
return None
|
|
680
696
|
|
|
697
|
+
def get_root_dir(self):
|
|
698
|
+
"""Return the top-level environment or workspace root directory.
|
|
699
|
+
|
|
700
|
+
When base_dir is an installed skill directory nested inside 'skills/skill-vault',
|
|
701
|
+
returns the parent of 'skills' (e.g. ~/.gemini/config or workspace root).
|
|
702
|
+
"""
|
|
703
|
+
if self.base_dir.name == "skill-vault" and self.base_dir.parent.name == "skills":
|
|
704
|
+
return self.base_dir.parent.parent
|
|
705
|
+
return self.base_dir
|
|
706
|
+
|
|
707
|
+
def get_skill_vault_dir(self):
|
|
708
|
+
"""Locate the installed skill-vault skill directory if present (excluding git repo roots)."""
|
|
709
|
+
if self.base_dir.name == "skill-vault" and self.base_dir.parent.name == "skills":
|
|
710
|
+
if not (self.base_dir / ".git").exists():
|
|
711
|
+
return self.base_dir
|
|
712
|
+
root_dir = self.get_root_dir()
|
|
713
|
+
for rel in ["skills/skill-vault", ".agents/skills/skill-vault", ".claude/skills/skill-vault"]:
|
|
714
|
+
cand = (root_dir / rel).resolve()
|
|
715
|
+
if cand.exists() and not (cand / ".git").exists():
|
|
716
|
+
return cand
|
|
717
|
+
return None
|
|
718
|
+
|
|
681
719
|
def make_portable_path(self, abs_path):
|
|
682
|
-
"""Convert path to relative from base_dir if possible."""
|
|
720
|
+
"""Convert path to relative from base_dir or root_dir if possible."""
|
|
721
|
+
resolved = Path(abs_path).resolve()
|
|
683
722
|
try:
|
|
684
|
-
return str(
|
|
723
|
+
return str(resolved.relative_to(self.base_dir))
|
|
685
724
|
except ValueError:
|
|
725
|
+
root_dir = self.get_root_dir()
|
|
726
|
+
if root_dir != self.base_dir:
|
|
727
|
+
try:
|
|
728
|
+
return str(resolved.relative_to(root_dir))
|
|
729
|
+
except ValueError:
|
|
730
|
+
pass
|
|
686
731
|
return str(abs_path)
|
|
687
732
|
|
|
688
733
|
def resolve_portable_path(self, path_str):
|
|
@@ -690,7 +735,69 @@ class SkillVault:
|
|
|
690
735
|
p = Path(path_str)
|
|
691
736
|
if p.is_absolute():
|
|
692
737
|
return p
|
|
693
|
-
|
|
738
|
+
cand = (self.base_dir / p).resolve()
|
|
739
|
+
if not cand.exists():
|
|
740
|
+
root_dir = self.get_root_dir()
|
|
741
|
+
if root_dir != self.base_dir:
|
|
742
|
+
root_cand = (root_dir / p).resolve()
|
|
743
|
+
if root_cand.exists():
|
|
744
|
+
return root_cand
|
|
745
|
+
return cand
|
|
746
|
+
|
|
747
|
+
def resolve_original_path(self, path_str, skill_name=None):
|
|
748
|
+
"""Resolve a stored original_path to an active L1 Path outside skills/skill-vault."""
|
|
749
|
+
root_dir = self.get_root_dir()
|
|
750
|
+
sv_dir = self.get_skill_vault_dir()
|
|
751
|
+
if not path_str:
|
|
752
|
+
skills_root = root_dir / "skills" if root_dir != self.base_dir else self.skills_dir
|
|
753
|
+
return (skills_root / (skill_name or "unknown-skill")).resolve()
|
|
754
|
+
|
|
755
|
+
p = Path(path_str)
|
|
756
|
+
if p.is_absolute():
|
|
757
|
+
resolved = p.resolve()
|
|
758
|
+
if sv_dir and (sv_dir in resolved.parents or resolved == sv_dir):
|
|
759
|
+
try:
|
|
760
|
+
rel = resolved.relative_to(sv_dir)
|
|
761
|
+
return (root_dir / rel).resolve()
|
|
762
|
+
except ValueError:
|
|
763
|
+
pass
|
|
764
|
+
return resolved
|
|
765
|
+
|
|
766
|
+
return (root_dir / p).resolve()
|
|
767
|
+
|
|
768
|
+
def _copy_skill_safely(self, src_dir, dst_dir):
|
|
769
|
+
"""Copy a skill folder from src_dir to dst_dir without deleting nested sibling skills."""
|
|
770
|
+
src_dir = Path(src_dir).resolve()
|
|
771
|
+
dst_dir = Path(dst_dir).resolve()
|
|
772
|
+
dst_dir.parent.mkdir(parents=True, exist_ok=True)
|
|
773
|
+
|
|
774
|
+
def _ignore_nested_skills(curr_dir, names):
|
|
775
|
+
curr_path = Path(curr_dir).resolve()
|
|
776
|
+
if curr_path == src_dir:
|
|
777
|
+
return [
|
|
778
|
+
n for n in names
|
|
779
|
+
if (curr_path / n).is_dir() and (curr_path / n / "SKILL.md").exists()
|
|
780
|
+
]
|
|
781
|
+
return []
|
|
782
|
+
|
|
783
|
+
if dst_dir.exists():
|
|
784
|
+
nested_skill_dirs = {
|
|
785
|
+
sub.name for sub in dst_dir.iterdir()
|
|
786
|
+
if sub.is_dir() and (sub / "SKILL.md").exists()
|
|
787
|
+
}
|
|
788
|
+
if nested_skill_dirs or dst_dir.name == "skills":
|
|
789
|
+
for item in list(dst_dir.iterdir()):
|
|
790
|
+
if item.name in nested_skill_dirs:
|
|
791
|
+
continue
|
|
792
|
+
if item.is_dir():
|
|
793
|
+
shutil.rmtree(item)
|
|
794
|
+
else:
|
|
795
|
+
item.unlink()
|
|
796
|
+
shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True, ignore=_ignore_nested_skills)
|
|
797
|
+
return
|
|
798
|
+
shutil.rmtree(dst_dir)
|
|
799
|
+
|
|
800
|
+
shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True, ignore=_ignore_nested_skills)
|
|
694
801
|
|
|
695
802
|
def parse_index_file(self):
|
|
696
803
|
"""Parse INDEX.md and return extracted skills with categories and link targets."""
|
|
@@ -1036,6 +1143,8 @@ class SkillVault:
|
|
|
1036
1143
|
if data.get("single_skill_dir"):
|
|
1037
1144
|
for sub in active_path.iterdir():
|
|
1038
1145
|
if sub.is_dir():
|
|
1146
|
+
if (sub / "SKILL.md").exists():
|
|
1147
|
+
continue
|
|
1039
1148
|
shutil.rmtree(sub)
|
|
1040
1149
|
else:
|
|
1041
1150
|
sub.unlink()
|
|
@@ -1250,31 +1359,208 @@ class SkillVault:
|
|
|
1250
1359
|
print("No matching skills found to restore.")
|
|
1251
1360
|
return
|
|
1252
1361
|
|
|
1362
|
+
disk_skills = self.get_archived_skill_folders()
|
|
1363
|
+
|
|
1253
1364
|
for item in targets:
|
|
1254
|
-
|
|
1255
|
-
|
|
1365
|
+
skill_name = item["name"]
|
|
1366
|
+
archived_path = self.resolve_portable_path(item.get("archived_path", ""))
|
|
1367
|
+
disk_cand = disk_skills.get(skill_name)
|
|
1368
|
+
if disk_cand and disk_cand["has_skill_md"]:
|
|
1369
|
+
if not (archived_path / "SKILL.md").exists() or compare_skill_recency(disk_cand["folder"], archived_path) > 0:
|
|
1370
|
+
archived_path = disk_cand["folder"]
|
|
1256
1371
|
|
|
1257
|
-
|
|
1372
|
+
original_path = self.resolve_original_path(item.get("original_path", ""), skill_name=skill_name)
|
|
1373
|
+
|
|
1374
|
+
if not (archived_path / "SKILL.md").exists():
|
|
1258
1375
|
print(f"[Error] Missing archive source: {archived_path}")
|
|
1259
1376
|
continue
|
|
1260
1377
|
|
|
1261
|
-
original_path.
|
|
1262
|
-
if original_path.exists():
|
|
1378
|
+
if (original_path / "SKILL.md").exists():
|
|
1263
1379
|
recency = compare_skill_recency(archived_path, original_path)
|
|
1264
1380
|
if recency > 0 or force:
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
print(f"[Restored] Updated L1 with newer L2 version: {item['name']} -> {original_path}")
|
|
1381
|
+
self._copy_skill_safely(archived_path, original_path)
|
|
1382
|
+
print(f"[Restored] Updated L1 with newer L2 version: {skill_name} -> {original_path}")
|
|
1268
1383
|
continue
|
|
1269
1384
|
else:
|
|
1270
|
-
print(f"[Skip] Target L1 skill '{
|
|
1385
|
+
print(f"[Skip] Target L1 skill '{skill_name}' is already newer than or equal to L2 archive (use --force to overwrite)")
|
|
1271
1386
|
continue
|
|
1272
1387
|
|
|
1273
|
-
|
|
1274
|
-
print(f"[Restored] {
|
|
1388
|
+
self._copy_skill_safely(archived_path, original_path)
|
|
1389
|
+
print(f"[Restored] {skill_name} -> {original_path}")
|
|
1275
1390
|
|
|
1276
1391
|
print("Restoration complete.")
|
|
1277
1392
|
|
|
1393
|
+
def uninstall(self, dry_run=False, force=False, keep_archive=False, keep_skill=False):
|
|
1394
|
+
"""Cleanly restore all archived skills to L1 without overwriting newer L1 versions and remove skill-vault."""
|
|
1395
|
+
root_dir = self.get_root_dir()
|
|
1396
|
+
sv_dir = self.get_skill_vault_dir()
|
|
1397
|
+
manifest = self.load_manifest()
|
|
1398
|
+
manifest_map = {item["name"]: item for item in manifest if "name" in item}
|
|
1399
|
+
disk_skills = self.get_archived_skill_folders()
|
|
1400
|
+
|
|
1401
|
+
candidates = []
|
|
1402
|
+
manifested_arch_paths = set()
|
|
1403
|
+
for item in manifest:
|
|
1404
|
+
skill_name = item["name"]
|
|
1405
|
+
archived_path = self.resolve_portable_path(item.get("archived_path", ""))
|
|
1406
|
+
disk_cand = disk_skills.get(skill_name)
|
|
1407
|
+
if disk_cand and disk_cand["has_skill_md"]:
|
|
1408
|
+
if not (archived_path / "SKILL.md").exists() or compare_skill_recency(disk_cand["folder"], archived_path) > 0:
|
|
1409
|
+
archived_path = disk_cand["folder"]
|
|
1410
|
+
if archived_path.exists():
|
|
1411
|
+
manifested_arch_paths.add(archived_path.resolve())
|
|
1412
|
+
original_path = self.resolve_original_path(item.get("original_path", ""), skill_name=skill_name)
|
|
1413
|
+
candidates.append((skill_name, archived_path, original_path, False))
|
|
1414
|
+
|
|
1415
|
+
# Rescue any unmanifested skills physically sitting in the archive
|
|
1416
|
+
for folder_name, data in sorted(disk_skills.items()):
|
|
1417
|
+
if folder_name in manifest_map or not data["has_skill_md"]:
|
|
1418
|
+
continue
|
|
1419
|
+
if data["folder"].resolve() in manifested_arch_paths:
|
|
1420
|
+
continue
|
|
1421
|
+
original_path = self.resolve_original_path(f"skills/{folder_name}", skill_name=folder_name)
|
|
1422
|
+
candidates.append((folder_name, data["folder"], original_path, True))
|
|
1423
|
+
|
|
1424
|
+
to_restore = []
|
|
1425
|
+
to_upgrade = []
|
|
1426
|
+
to_preserve = []
|
|
1427
|
+
missing_sources = []
|
|
1428
|
+
|
|
1429
|
+
for skill_name, archived_path, original_path, unmanifested in candidates:
|
|
1430
|
+
has_archived = (archived_path / "SKILL.md").exists()
|
|
1431
|
+
has_active = (original_path / "SKILL.md").exists()
|
|
1432
|
+
|
|
1433
|
+
if not has_archived:
|
|
1434
|
+
if has_active:
|
|
1435
|
+
to_preserve.append((skill_name, archived_path, original_path, "Active L1 present; archive source missing"))
|
|
1436
|
+
else:
|
|
1437
|
+
missing_sources.append((skill_name, archived_path, original_path))
|
|
1438
|
+
continue
|
|
1439
|
+
|
|
1440
|
+
if has_active:
|
|
1441
|
+
recency = compare_skill_recency(archived_path, original_path)
|
|
1442
|
+
if recency > 0 or force:
|
|
1443
|
+
reason = "Forced overwrite" if (force and recency <= 0) else "Newer L2 archive version"
|
|
1444
|
+
to_upgrade.append((skill_name, archived_path, original_path, reason))
|
|
1445
|
+
else:
|
|
1446
|
+
to_preserve.append((skill_name, archived_path, original_path, "L1 version is newer or equal"))
|
|
1447
|
+
else:
|
|
1448
|
+
reason = "Unmanifested archive folder rescued" if unmanifested else "Missing from active L1"
|
|
1449
|
+
to_restore.append((skill_name, archived_path, original_path, reason))
|
|
1450
|
+
|
|
1451
|
+
print("==================================================")
|
|
1452
|
+
print(" SKILL VAULT CLEAN UNINSTALL / DECOMMISSION")
|
|
1453
|
+
print(f" Base Directory: {self.base_dir}")
|
|
1454
|
+
print(f" Root Directory: {root_dir}")
|
|
1455
|
+
print(f" Archive Store: {self.archive_dir}")
|
|
1456
|
+
print(f" Skill Folder: {sv_dir if sv_dir else '(None detected)'}")
|
|
1457
|
+
print("==================================================\n")
|
|
1458
|
+
|
|
1459
|
+
print(f"Restoration Plan ({len(candidates)} total archived/discovered skill(s)):")
|
|
1460
|
+
print(f" * Restore to active L1: {len(to_restore)}")
|
|
1461
|
+
for name, _, dst, reason in to_restore:
|
|
1462
|
+
print(f" [RESTORE] {name} -> {dst} ({reason})")
|
|
1463
|
+
|
|
1464
|
+
print(f" * Upgrade active L1 (newer in L2): {len(to_upgrade)}")
|
|
1465
|
+
for name, _, dst, reason in to_upgrade:
|
|
1466
|
+
print(f" [UPGRADE] {name} -> {dst} ({reason})")
|
|
1467
|
+
|
|
1468
|
+
print(f" * Preserve active L1 (newer/equal): {len(to_preserve)}")
|
|
1469
|
+
for name, _, dst, reason in to_preserve:
|
|
1470
|
+
print(f" [PRESERVE] {name} -> {dst} ({reason})")
|
|
1471
|
+
|
|
1472
|
+
if missing_sources:
|
|
1473
|
+
print(f" * Missing archive sources: {len(missing_sources)}")
|
|
1474
|
+
for name, src, _ in missing_sources:
|
|
1475
|
+
print(f" [ERROR] {name} (missing {src})")
|
|
1476
|
+
|
|
1477
|
+
print("\nCleanup Plan:")
|
|
1478
|
+
if keep_archive:
|
|
1479
|
+
if sv_dir and not keep_skill and self.archive_dir.exists() and (sv_dir in self.archive_dir.parents):
|
|
1480
|
+
print(f" * Archive: Relocate {self.archive_dir} -> {root_dir / 'skill_archive'}")
|
|
1481
|
+
else:
|
|
1482
|
+
print(f" * Archive: Keep {self.archive_dir}")
|
|
1483
|
+
else:
|
|
1484
|
+
print(f" * Archive: Remove {self.archive_dir}")
|
|
1485
|
+
|
|
1486
|
+
if keep_skill or not sv_dir:
|
|
1487
|
+
print(f" * Skill: Keep {sv_dir if sv_dir else '(None detected)'}")
|
|
1488
|
+
else:
|
|
1489
|
+
print(f" * Skill: Remove {sv_dir}")
|
|
1490
|
+
print("")
|
|
1491
|
+
|
|
1492
|
+
if missing_sources:
|
|
1493
|
+
print("[Abort] One or more archive sources are missing. Nothing was modified or deleted.")
|
|
1494
|
+
return 1
|
|
1495
|
+
|
|
1496
|
+
if dry_run:
|
|
1497
|
+
print("[Dry Run] Uninstall preview complete. No files were modified or removed.")
|
|
1498
|
+
return 0
|
|
1499
|
+
|
|
1500
|
+
for name, src, dst, _ in to_restore:
|
|
1501
|
+
self._copy_skill_safely(src, dst)
|
|
1502
|
+
print(f"[Restored] {name} -> {dst}")
|
|
1503
|
+
|
|
1504
|
+
for name, src, dst, _ in to_upgrade:
|
|
1505
|
+
self._copy_skill_safely(src, dst)
|
|
1506
|
+
print(f"[Upgraded] {name} -> {dst}")
|
|
1507
|
+
|
|
1508
|
+
# Verification gate before deleting archive or skill-vault folder
|
|
1509
|
+
dirs_to_delete = []
|
|
1510
|
+
if not keep_archive and self.archive_dir.exists():
|
|
1511
|
+
dirs_to_delete.append(self.archive_dir.resolve())
|
|
1512
|
+
if sv_dir and not keep_skill and sv_dir.exists():
|
|
1513
|
+
dirs_to_delete.append(sv_dir.resolve())
|
|
1514
|
+
|
|
1515
|
+
verification_errors = []
|
|
1516
|
+
for skill_name, _, original_path, _ in to_restore + to_upgrade + to_preserve:
|
|
1517
|
+
orig_resolved = Path(original_path).resolve()
|
|
1518
|
+
skill_md = orig_resolved / "SKILL.md"
|
|
1519
|
+
if not skill_md.exists() or skill_md.stat().st_size == 0:
|
|
1520
|
+
verification_errors.append(f"Missing or empty SKILL.md for '{skill_name}' at {skill_md}")
|
|
1521
|
+
continue
|
|
1522
|
+
for del_dir in dirs_to_delete:
|
|
1523
|
+
if orig_resolved == del_dir or del_dir in orig_resolved.parents:
|
|
1524
|
+
verification_errors.append(
|
|
1525
|
+
f"Destination '{orig_resolved}' for '{skill_name}' is inside '{del_dir}' which is scheduled for deletion"
|
|
1526
|
+
)
|
|
1527
|
+
|
|
1528
|
+
if verification_errors:
|
|
1529
|
+
print("\n[Abort] Verification failed. Preserving archive and skill-vault to prevent data loss:")
|
|
1530
|
+
for err in verification_errors:
|
|
1531
|
+
print(f" [X] {err}")
|
|
1532
|
+
return 1
|
|
1533
|
+
|
|
1534
|
+
# Relocate or delete archive
|
|
1535
|
+
if keep_archive:
|
|
1536
|
+
if sv_dir and not keep_skill and self.archive_dir.exists() and (sv_dir in self.archive_dir.parents):
|
|
1537
|
+
relocated = (root_dir / "skill_archive").resolve()
|
|
1538
|
+
if self.archive_dir.resolve() != relocated:
|
|
1539
|
+
shutil.copytree(self.archive_dir, relocated, dirs_exist_ok=True)
|
|
1540
|
+
cwd_resolved = Path.cwd().resolve()
|
|
1541
|
+
if cwd_resolved == self.archive_dir.resolve() or self.archive_dir.resolve() in cwd_resolved.parents:
|
|
1542
|
+
os.chdir(root_dir)
|
|
1543
|
+
shutil.rmtree(self.archive_dir)
|
|
1544
|
+
print(f"[Relocated] Archive preserved at: {relocated}")
|
|
1545
|
+
else:
|
|
1546
|
+
if self.archive_dir.exists():
|
|
1547
|
+
cwd_resolved = Path.cwd().resolve()
|
|
1548
|
+
if cwd_resolved == self.archive_dir.resolve() or self.archive_dir.resolve() in cwd_resolved.parents:
|
|
1549
|
+
os.chdir(root_dir)
|
|
1550
|
+
shutil.rmtree(self.archive_dir)
|
|
1551
|
+
print(f"[Removed] Archive directory: {self.archive_dir}")
|
|
1552
|
+
|
|
1553
|
+
if sv_dir and not keep_skill and sv_dir.exists():
|
|
1554
|
+
cwd_resolved = Path.cwd().resolve()
|
|
1555
|
+
if cwd_resolved == sv_dir.resolve() or sv_dir.resolve() in cwd_resolved.parents:
|
|
1556
|
+
os.chdir(root_dir)
|
|
1557
|
+
shutil.rmtree(sv_dir)
|
|
1558
|
+
print(f"[Removed] Skill-vault directory: {sv_dir}")
|
|
1559
|
+
|
|
1560
|
+
total_safe = len(to_restore) + len(to_upgrade) + len(to_preserve)
|
|
1561
|
+
print(f"\n[OK] Clean uninstall complete! {total_safe} skill(s) verified safe in active L1 locations.")
|
|
1562
|
+
return 0
|
|
1563
|
+
|
|
1278
1564
|
def reindex(self):
|
|
1279
1565
|
"""Rebuild INDEX.md grouped by manifest categories with portable relative links."""
|
|
1280
1566
|
manifest = self.load_manifest()
|
|
@@ -1993,6 +2279,17 @@ def main():
|
|
|
1993
2279
|
p_cfg.add_argument("--add-category-rule", nargs=2, action="append", metavar=("CATEGORY", "KEYWORD"), help="Add an inference keyword rule for a category")
|
|
1994
2280
|
p_cfg.add_argument("--sync-prompt", action="store_true", help="Synchronize SKILL.md router description with archived categories")
|
|
1995
2281
|
|
|
2282
|
+
# Uninstall / Eject
|
|
2283
|
+
p_uninst = subparsers.add_parser(
|
|
2284
|
+
"uninstall",
|
|
2285
|
+
aliases=["eject"],
|
|
2286
|
+
help="Cleanly restore all archived skills to L1 (preserving newer L1 versions) and remove skill-vault",
|
|
2287
|
+
)
|
|
2288
|
+
p_uninst.add_argument("--dry-run", action="store_true", help="Preview restoration and removal plan without modifying files")
|
|
2289
|
+
p_uninst.add_argument("--force", action="store_true", help="Overwrite active L1 skills even if L1 copy is newer")
|
|
2290
|
+
p_uninst.add_argument("--keep-archive", action="store_true", help="Preserve skill_archive (relocating it out of skill-vault if nested)")
|
|
2291
|
+
p_uninst.add_argument("--keep-skill", action="store_true", help="Restore all skills and remove archive, but keep the skill-vault skill folder")
|
|
2292
|
+
|
|
1996
2293
|
args = parser.parse_args()
|
|
1997
2294
|
mgr = SkillVault(base_dir=args.base_dir)
|
|
1998
2295
|
|
|
@@ -2061,6 +2358,15 @@ def main():
|
|
|
2061
2358
|
add_category_rule=args.add_category_rule,
|
|
2062
2359
|
sync_prompt=args.sync_prompt,
|
|
2063
2360
|
)
|
|
2361
|
+
elif args.command in ("uninstall", "eject"):
|
|
2362
|
+
sys.exit(
|
|
2363
|
+
mgr.uninstall(
|
|
2364
|
+
dry_run=args.dry_run,
|
|
2365
|
+
force=args.force,
|
|
2366
|
+
keep_archive=args.keep_archive,
|
|
2367
|
+
keep_skill=args.keep_skill,
|
|
2368
|
+
)
|
|
2369
|
+
)
|
|
2064
2370
|
|
|
2065
2371
|
|
|
2066
2372
|
if __name__ == "__main__":
|