@jcorpac/skill-vault 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.
- package/README.md +1 -1
- package/SKILL.md +6 -6
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/mcp_server.py +191 -37
- package/scripts/skill_router.py +114 -9
- package/scripts/skill_vault.py +533 -95
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ python scripts/skill_vault.py verify --fix
|
|
|
89
89
|
| `skill-vault import <name>` | Copy vaulted skills into a project's `.agents/skills` or `skills/` directory. |
|
|
90
90
|
| `skill-vault optimize` | Prune/mount active skills using workspace file fingerprints. |
|
|
91
91
|
| `skill-vault config` | Inspect or customize core skills, fingerprints, category rules, and `--set-routing` thresholds. |
|
|
92
|
-
| `skill-vault reindex` / `verify` | Rebuild `INDEX.md` + `search_index.json` and audit archive integrity. |
|
|
92
|
+
| `skill-vault reindex` / `verify` | Rebuild `INDEX.md` + `search_index.json` and audit archive integrity or L2 compatibility (`--compat --fix`, including runtime-in-place protection). |
|
|
93
93
|
| `skill-vault uninstall` | Safely restore all archived skills to L1 and remove Skill Vault wiring & files (`eject` alias). |
|
|
94
94
|
|
|
95
95
|
---
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: skill-vault
|
|
3
|
-
version: 2.0
|
|
3
|
+
version: 2.1.0
|
|
4
4
|
description: >-
|
|
5
5
|
Universal agent-agnostic skill router and tiered storage manager.
|
|
6
6
|
Background hooks automatically inject relevant vaulted skills on demand;
|
|
@@ -12,13 +12,13 @@ description: >-
|
|
|
12
12
|
**Skill Vault** keeps active L1 context minimal (core skills only) while preserving instant, zero-approval access to all vaulted L2 domain skills:
|
|
13
13
|
|
|
14
14
|
1. **Background Lifecycle Hooks (Primary Path)**:
|
|
15
|
-
- `SessionStart` incrementally syncs newly installed/updated plugin skills, refreshes `search_index.json`, and
|
|
16
|
-
- `PreInvocation` / `UserPromptSubmit` / `BeforeAgent` scores
|
|
15
|
+
- `SessionStart` incrementally syncs newly installed/updated plugin skills, refreshes `search_index.json`, and caches workspace fingerprints.
|
|
16
|
+
- `PreInvocation` / `UserPromptSubmit` / `BeforeAgent` scores prompts via BM25 (<100ms), injects top skills/pointers from L2, and adds **0 tokens** on unrelated turns.
|
|
17
17
|
2. **Read-Only MCP Fallback (Mid-Turn Discovery)**:
|
|
18
18
|
- If a task pivots mid-turn to a specialized domain not present in context, call the `skill-vault` MCP tools:
|
|
19
19
|
- `list_skills(category?, include_descriptions?)` — List all vaulted L2 skill names grouped by category in one call.
|
|
20
20
|
- `search_skills(query, category?, limit?, offset?)` — Search vaulted L2 skills by keyword, intent, or list categories.
|
|
21
|
-
- `load_skill(name, file?)` — Read a
|
|
21
|
+
- `load_skill(name, file?, section?, start_line?)` — Read a skill's `SKILL.md` (full, section, or lines) or companion file.
|
|
22
22
|
- Never mutate L1 active directories or run shell commands solely to browse archived skills when MCP tools are available.
|
|
23
23
|
|
|
24
24
|
---
|
|
@@ -38,7 +38,7 @@ skill-vault search "<query>" [--category "<Category>"] [--limit 10]
|
|
|
38
38
|
# Inspect background routing telemetry (0-token turn rate, latency, top skills)
|
|
39
39
|
skill-vault stats [--limit 100]
|
|
40
40
|
|
|
41
|
-
# Scan plugins/active
|
|
41
|
+
# Scan plugins/active dirs, ingest updates, and prune non-core skills
|
|
42
42
|
skill-vault sync [--dry-run] [--keep-active]
|
|
43
43
|
|
|
44
44
|
# Re-classify 'General & Utility Skills' using built-in + custom rules
|
|
@@ -56,6 +56,6 @@ skill-vault config --set-routing show_ui_notice true
|
|
|
56
56
|
skill-vault archive <name> --category "<Category>"
|
|
57
57
|
skill-vault restore <name>
|
|
58
58
|
skill-vault import <name> --dest "./.agents/skills"
|
|
59
|
-
skill-vault verify --fix
|
|
59
|
+
skill-vault verify [--compat] [--fix]
|
|
60
60
|
skill-vault uninstall [--dry-run]
|
|
61
61
|
```
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skill-vault",
|
|
3
3
|
"displayName": "Skill Vault",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "Automatic background skill router, cold-storage archive, and read-only JIT MCP server for AI coding agents.",
|
|
6
6
|
"author": "jcorpac",
|
|
7
7
|
"homepage": "https://github.com/jcorpac/skill-vault#readme",
|
package/scripts/mcp_server.py
CHANGED
|
@@ -20,7 +20,7 @@ if str(SCRIPT_DIR) not in sys.path:
|
|
|
20
20
|
import skill_router # noqa: E402
|
|
21
21
|
|
|
22
22
|
SERVER_NAME = "skill-vault"
|
|
23
|
-
SERVER_VERSION = "2.0
|
|
23
|
+
SERVER_VERSION = "2.1.0"
|
|
24
24
|
MAX_READ_BYTES = 102400 # 100 KB safety cap per tool call
|
|
25
25
|
|
|
26
26
|
TOOLS_SPEC = [
|
|
@@ -94,8 +94,8 @@ TOOLS_SPEC = [
|
|
|
94
94
|
{
|
|
95
95
|
"name": "load_skill",
|
|
96
96
|
"description": (
|
|
97
|
-
"Load
|
|
98
|
-
"companion file (e.g. 'references/guide.md') inside that skill's directory."
|
|
97
|
+
"Load SKILL.md instructions (full, by heading section, or by line range) for a vaulted skill, "
|
|
98
|
+
"or read a specific companion file (e.g. 'references/guide.md') inside that skill's directory."
|
|
99
99
|
),
|
|
100
100
|
"inputSchema": {
|
|
101
101
|
"type": "object",
|
|
@@ -108,6 +108,18 @@ TOOLS_SPEC = [
|
|
|
108
108
|
"type": "string",
|
|
109
109
|
"description": "Optional relative path to a companion file inside the skill folder.",
|
|
110
110
|
},
|
|
111
|
+
"section": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "Optional Markdown heading name/substring to extract a single section from SKILL.md (case-insensitive).",
|
|
114
|
+
},
|
|
115
|
+
"start_line": {
|
|
116
|
+
"type": "integer",
|
|
117
|
+
"description": "Optional 1-based start line to read a line range from SKILL.md or a companion file.",
|
|
118
|
+
},
|
|
119
|
+
"end_line": {
|
|
120
|
+
"type": "integer",
|
|
121
|
+
"description": "Optional 1-based inclusive end line for line-range reads.",
|
|
122
|
+
},
|
|
111
123
|
},
|
|
112
124
|
"required": ["name"],
|
|
113
125
|
},
|
|
@@ -409,6 +421,76 @@ def _find_skill_entry(index_data, skill_name):
|
|
|
409
421
|
return None
|
|
410
422
|
|
|
411
423
|
|
|
424
|
+
def _extract_markdown_section(content, section_query):
|
|
425
|
+
"""Extract a single Markdown heading section outside fenced code blocks."""
|
|
426
|
+
lines = content.splitlines()
|
|
427
|
+
headings = []
|
|
428
|
+
in_fence = False
|
|
429
|
+
fence_marker = None
|
|
430
|
+
for idx, line in enumerate(lines):
|
|
431
|
+
stripped = line.lstrip()
|
|
432
|
+
if stripped.startswith("```") or stripped.startswith("~~~"):
|
|
433
|
+
marker = stripped[:3]
|
|
434
|
+
if not in_fence:
|
|
435
|
+
in_fence = True
|
|
436
|
+
fence_marker = marker
|
|
437
|
+
elif marker == fence_marker:
|
|
438
|
+
in_fence = False
|
|
439
|
+
fence_marker = None
|
|
440
|
+
continue
|
|
441
|
+
if in_fence:
|
|
442
|
+
continue
|
|
443
|
+
m = re.match(r"^(#{1,6})\s+(.+?)\s*#*\s*$", line)
|
|
444
|
+
if m:
|
|
445
|
+
level = len(m.group(1))
|
|
446
|
+
title = " ".join(m.group(2).split())
|
|
447
|
+
if title:
|
|
448
|
+
headings.append((idx, level, title))
|
|
449
|
+
|
|
450
|
+
all_titles = [t for _, _, t in headings]
|
|
451
|
+
q_lower = section_query.strip().lower()
|
|
452
|
+
matched = None
|
|
453
|
+
for idx, level, title in headings:
|
|
454
|
+
if title.lower() == q_lower:
|
|
455
|
+
matched = (idx, level, title)
|
|
456
|
+
break
|
|
457
|
+
if matched is None:
|
|
458
|
+
for idx, level, title in headings:
|
|
459
|
+
if q_lower in title.lower():
|
|
460
|
+
matched = (idx, level, title)
|
|
461
|
+
break
|
|
462
|
+
if matched is None:
|
|
463
|
+
return None, 0, 0, None, all_titles
|
|
464
|
+
|
|
465
|
+
start_idx, m_level, m_title = matched
|
|
466
|
+
end_idx = len(lines)
|
|
467
|
+
for idx, level, _ in headings:
|
|
468
|
+
if idx > start_idx and level <= m_level:
|
|
469
|
+
end_idx = idx
|
|
470
|
+
break
|
|
471
|
+
section_text = "\n".join(lines[start_idx:end_idx])
|
|
472
|
+
return section_text, start_idx + 1, end_idx, m_title, all_titles
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
def _slice_lines(content, start_line=None, end_line=None):
|
|
476
|
+
"""Slice 1-based inclusive line range from text content."""
|
|
477
|
+
lines = content.splitlines()
|
|
478
|
+
total = len(lines)
|
|
479
|
+
s = max(1, start_line if start_line is not None else 1)
|
|
480
|
+
e = min(total, end_line) if end_line is not None else total
|
|
481
|
+
if total == 0 or s > total:
|
|
482
|
+
return "", s, min(e, total), total
|
|
483
|
+
return "\n".join(lines[s - 1 : e]), s, e, total
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
def _cap_utf8_text(text, max_bytes=MAX_READ_BYTES):
|
|
487
|
+
raw = text.encode("utf-8", errors="replace")
|
|
488
|
+
if len(raw) <= max_bytes:
|
|
489
|
+
return text
|
|
490
|
+
capped = raw[:max_bytes].decode("utf-8", errors="replace")
|
|
491
|
+
return capped + f"\n\n[... truncated at {max_bytes} bytes ...]"
|
|
492
|
+
|
|
493
|
+
|
|
412
494
|
def _handle_load_skill(args, base_dir, archive_dir):
|
|
413
495
|
skill_name = str(args.get("name") or "").strip()
|
|
414
496
|
if not skill_name:
|
|
@@ -418,6 +500,31 @@ def _handle_load_skill(args, base_dir, archive_dir):
|
|
|
418
500
|
if rel_file is not None:
|
|
419
501
|
rel_file = str(rel_file).strip() or None
|
|
420
502
|
|
|
503
|
+
section = args.get("section")
|
|
504
|
+
if section is not None:
|
|
505
|
+
section = str(section).strip() or None
|
|
506
|
+
|
|
507
|
+
start_line = None
|
|
508
|
+
if args.get("start_line") is not None and args.get("start_line") != "":
|
|
509
|
+
try:
|
|
510
|
+
start_line = int(args["start_line"])
|
|
511
|
+
except (TypeError, ValueError):
|
|
512
|
+
return _tool_result("Error: 'start_line' must be a positive integer.", is_error=True)
|
|
513
|
+
if start_line < 1:
|
|
514
|
+
return _tool_result("Error: 'start_line' must be a positive integer.", is_error=True)
|
|
515
|
+
|
|
516
|
+
end_line = None
|
|
517
|
+
if args.get("end_line") is not None and args.get("end_line") != "":
|
|
518
|
+
try:
|
|
519
|
+
end_line = int(args["end_line"])
|
|
520
|
+
except (TypeError, ValueError):
|
|
521
|
+
return _tool_result("Error: 'end_line' must be a positive integer.", is_error=True)
|
|
522
|
+
if end_line < 1:
|
|
523
|
+
return _tool_result("Error: 'end_line' must be a positive integer.", is_error=True)
|
|
524
|
+
|
|
525
|
+
if start_line is not None and end_line is not None and end_line < start_line:
|
|
526
|
+
return _tool_result("Error: 'end_line' must be >= 'start_line'.", is_error=True)
|
|
527
|
+
|
|
421
528
|
index_data = _load_index(base_dir, archive_dir)
|
|
422
529
|
entry = _find_skill_entry(index_data, skill_name)
|
|
423
530
|
if not entry:
|
|
@@ -427,71 +534,118 @@ def _handle_load_skill(args, base_dir, archive_dir):
|
|
|
427
534
|
is_error=True,
|
|
428
535
|
)
|
|
429
536
|
|
|
430
|
-
|
|
537
|
+
archive_skill_dir = None
|
|
431
538
|
if entry.get("resolved_path") and Path(entry["resolved_path"]).exists():
|
|
432
|
-
|
|
539
|
+
archive_skill_dir = Path(entry["resolved_path"]).resolve()
|
|
433
540
|
elif entry.get("archived_path"):
|
|
434
541
|
cand = skill_router._resolve_archived_skill_dir(base_dir, archive_dir, entry["archived_path"])
|
|
435
542
|
if cand.exists():
|
|
436
|
-
|
|
543
|
+
archive_skill_dir = cand.resolve()
|
|
437
544
|
|
|
438
|
-
if not
|
|
545
|
+
if not archive_skill_dir or not archive_skill_dir.exists():
|
|
439
546
|
return _tool_result(
|
|
440
547
|
f"Error: Archived directory for skill '{skill_name}' does not exist on disk.",
|
|
441
548
|
is_error=True,
|
|
442
549
|
)
|
|
443
550
|
|
|
551
|
+
runtime_dir = None
|
|
552
|
+
if entry.get("runtime_dir"):
|
|
553
|
+
cand_rt = Path(entry["runtime_dir"])
|
|
554
|
+
if cand_rt.exists() and cand_rt.is_dir():
|
|
555
|
+
runtime_dir = cand_rt.resolve()
|
|
556
|
+
|
|
444
557
|
if rel_file:
|
|
445
|
-
# Strict path traversal check
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
)
|
|
453
|
-
target = (skill_dir / req_path).resolve()
|
|
454
|
-
if skill_dir not in target.parents:
|
|
455
|
-
return _tool_result(
|
|
456
|
-
"Error: Path traversal denied; companion file must reside inside the skill directory.",
|
|
457
|
-
is_error=True,
|
|
458
|
-
)
|
|
459
|
-
except Exception as exc:
|
|
460
|
-
return _tool_result(f"Error resolving path: {exc}", is_error=True)
|
|
558
|
+
# Strict path traversal check across candidate roots (runtime_dir then archive_skill_dir)
|
|
559
|
+
req_path = Path(rel_file)
|
|
560
|
+
if req_path.is_absolute():
|
|
561
|
+
return _tool_result(
|
|
562
|
+
"Error: Absolute paths are not allowed; provide a relative path inside the skill directory.",
|
|
563
|
+
is_error=True,
|
|
564
|
+
)
|
|
461
565
|
|
|
462
|
-
if
|
|
566
|
+
roots = [runtime_dir, archive_skill_dir] if runtime_dir and runtime_dir != archive_skill_dir else [archive_skill_dir]
|
|
567
|
+
target = None
|
|
568
|
+
for root_dir in roots:
|
|
569
|
+
try:
|
|
570
|
+
cand_target = (root_dir / req_path).resolve()
|
|
571
|
+
if root_dir not in cand_target.parents:
|
|
572
|
+
return _tool_result(
|
|
573
|
+
"Error: Path traversal denied; companion file must reside inside the skill directory.",
|
|
574
|
+
is_error=True,
|
|
575
|
+
)
|
|
576
|
+
except Exception as exc:
|
|
577
|
+
return _tool_result(f"Error resolving path: {exc}", is_error=True)
|
|
578
|
+
if cand_target.exists() and cand_target.is_file():
|
|
579
|
+
target = cand_target
|
|
580
|
+
break
|
|
581
|
+
|
|
582
|
+
if target is None:
|
|
463
583
|
return _tool_result(
|
|
464
584
|
f"Error: Companion file '{rel_file}' not found inside '{entry['name']}'.",
|
|
465
585
|
is_error=True,
|
|
466
586
|
)
|
|
467
587
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
text
|
|
473
|
-
|
|
588
|
+
lines_info = ""
|
|
589
|
+
if start_line is not None or end_line is not None:
|
|
590
|
+
full_text = target.read_text(encoding="utf-8", errors="replace")
|
|
591
|
+
text, s, e, total_lines = _slice_lines(full_text, start_line, end_line)
|
|
592
|
+
text = _cap_utf8_text(text)
|
|
593
|
+
lines_info = f"Lines: {s}-{e} of {total_lines}\n"
|
|
594
|
+
else:
|
|
595
|
+
raw = target.read_bytes()
|
|
596
|
+
truncated = len(raw) > MAX_READ_BYTES
|
|
597
|
+
text = raw[:MAX_READ_BYTES].decode("utf-8", errors="replace")
|
|
598
|
+
if truncated:
|
|
599
|
+
text += f"\n\n[... truncated at {MAX_READ_BYTES} bytes ...]"
|
|
600
|
+
header = f"# {entry['name']} :: {rel_file}\n{lines_info}\n"
|
|
474
601
|
return _tool_result(header + text)
|
|
475
602
|
|
|
476
|
-
skill_md =
|
|
603
|
+
skill_md = archive_skill_dir / "SKILL.md"
|
|
477
604
|
if not skill_md.exists():
|
|
478
605
|
return _tool_result(
|
|
479
606
|
f"Error: SKILL.md missing for skill '{entry['name']}'.",
|
|
480
607
|
is_error=True,
|
|
481
608
|
)
|
|
482
609
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
610
|
+
section_line = ""
|
|
611
|
+
if section is not None or start_line is not None or end_line is not None:
|
|
612
|
+
full_text = skill_md.read_text(encoding="utf-8", errors="replace")
|
|
613
|
+
total_lines = len(full_text.splitlines())
|
|
614
|
+
if section is not None:
|
|
615
|
+
sec_text, s, e, m_title, all_titles = _extract_markdown_section(full_text, section)
|
|
616
|
+
if sec_text is None:
|
|
617
|
+
avail = ", ".join(all_titles[:30]) if all_titles else "(none)"
|
|
618
|
+
return _tool_result(
|
|
619
|
+
f"Error: Section '{section}' not found in '{entry['name']}'. Available headings: {avail}",
|
|
620
|
+
is_error=True,
|
|
621
|
+
)
|
|
622
|
+
content = _cap_utf8_text(sec_text)
|
|
623
|
+
section_line = f"Section: {m_title} (lines {s}-{e} of {total_lines})\n"
|
|
624
|
+
else:
|
|
625
|
+
sliced, s, e, total_lines = _slice_lines(full_text, start_line, end_line)
|
|
626
|
+
content = _cap_utf8_text(sliced)
|
|
627
|
+
section_line = f"Lines: {s}-{e} of {total_lines}\n"
|
|
628
|
+
else:
|
|
629
|
+
raw = skill_md.read_bytes()
|
|
630
|
+
truncated = len(raw) > MAX_READ_BYTES
|
|
631
|
+
content = raw[:MAX_READ_BYTES].decode("utf-8", errors="replace")
|
|
632
|
+
if truncated:
|
|
633
|
+
content += f"\n\n[... truncated at {MAX_READ_BYTES} bytes ...]"
|
|
488
634
|
|
|
635
|
+
effective_dir = runtime_dir or archive_skill_dir
|
|
636
|
+
extra_rt = (
|
|
637
|
+
f"Archive Directory: {archive_skill_dir}\n"
|
|
638
|
+
if runtime_dir and runtime_dir != archive_skill_dir
|
|
639
|
+
else ""
|
|
640
|
+
)
|
|
489
641
|
companions = entry.get("companion_files", [])
|
|
490
642
|
comp_line = ", ".join(companions) if companions else "(none)"
|
|
491
643
|
header = (
|
|
492
644
|
f"Skill: {entry['name']}\n"
|
|
493
645
|
f"Category: {entry.get('category', 'General & Utility Skills')}\n"
|
|
494
|
-
f"Directory: {
|
|
646
|
+
f"Directory: {effective_dir}\n"
|
|
647
|
+
f"{extra_rt}"
|
|
648
|
+
f"{section_line}"
|
|
495
649
|
f"Companion Files: {comp_line}\n"
|
|
496
650
|
f"---\n"
|
|
497
651
|
)
|
package/scripts/skill_router.py
CHANGED
|
@@ -503,6 +503,24 @@ def build_search_index(archive_dir, manifest, base_dir=None, resolve_path_fn=Non
|
|
|
503
503
|
entry["resolved_path"] = str(skill_dir)
|
|
504
504
|
entry["aliases"] = [name]
|
|
505
505
|
|
|
506
|
+
raw_rt = item.get("runtime_dir")
|
|
507
|
+
if raw_rt:
|
|
508
|
+
rt_cand = None
|
|
509
|
+
if resolve_path_fn is not None:
|
|
510
|
+
rt_cand = Path(resolve_path_fn(raw_rt))
|
|
511
|
+
else:
|
|
512
|
+
p_rt = Path(raw_rt)
|
|
513
|
+
if p_rt.is_absolute():
|
|
514
|
+
rt_cand = p_rt
|
|
515
|
+
elif base_dir is not None and (Path(base_dir) / p_rt).exists():
|
|
516
|
+
rt_cand = (Path(base_dir) / p_rt).resolve()
|
|
517
|
+
else:
|
|
518
|
+
rt_cand = _resolve_archived_skill_dir(base_dir, archive_path, raw_rt)
|
|
519
|
+
if rt_cand and rt_cand.exists() and rt_cand.is_dir():
|
|
520
|
+
entry["runtime_dir"] = str(rt_cand.resolve())
|
|
521
|
+
if not entry.get("companion_files"):
|
|
522
|
+
entry["companion_files"] = _list_companion_files(rt_cand)
|
|
523
|
+
|
|
506
524
|
ckey = entry["canonical_key"]
|
|
507
525
|
if ckey not in deduped:
|
|
508
526
|
deduped[ckey] = entry
|
|
@@ -665,6 +683,7 @@ def search_index(
|
|
|
665
683
|
"description": entry.get("description", ""),
|
|
666
684
|
"archived_path": entry.get("archived_path", ""),
|
|
667
685
|
"resolved_path": entry.get("resolved_path", ""),
|
|
686
|
+
"runtime_dir": entry.get("runtime_dir", ""),
|
|
668
687
|
"skill_md_bytes": entry.get("skill_md_bytes", 0),
|
|
669
688
|
"companion_files": entry.get("companion_files", []),
|
|
670
689
|
"aliases": entry.get("aliases", [entry["name"]]),
|
|
@@ -825,6 +844,7 @@ def search_index(
|
|
|
825
844
|
"description": entry.get("description", ""),
|
|
826
845
|
"archived_path": entry.get("archived_path", ""),
|
|
827
846
|
"resolved_path": entry.get("resolved_path", ""),
|
|
847
|
+
"runtime_dir": entry.get("runtime_dir", ""),
|
|
828
848
|
"skill_md_bytes": entry.get("skill_md_bytes", 0),
|
|
829
849
|
"companion_files": entry.get("companion_files", []),
|
|
830
850
|
"aliases": entry.get("aliases", [entry["name"]]),
|
|
@@ -851,19 +871,89 @@ def _resolve_skill_md_for_candidate(cand, archive_dir, base_dir=None):
|
|
|
851
871
|
return None, None
|
|
852
872
|
|
|
853
873
|
|
|
874
|
+
def _extract_markdown_headings(text, max_headings=12):
|
|
875
|
+
"""Extract top-level (h1-h3) Markdown headings outside fenced code blocks."""
|
|
876
|
+
headings = []
|
|
877
|
+
seen = set()
|
|
878
|
+
in_fence = False
|
|
879
|
+
fence_marker = None
|
|
880
|
+
for line in text.splitlines():
|
|
881
|
+
stripped = line.lstrip()
|
|
882
|
+
if stripped.startswith("```") or stripped.startswith("~~~"):
|
|
883
|
+
marker = stripped[:3]
|
|
884
|
+
if not in_fence:
|
|
885
|
+
in_fence = True
|
|
886
|
+
fence_marker = marker
|
|
887
|
+
elif marker == fence_marker:
|
|
888
|
+
in_fence = False
|
|
889
|
+
fence_marker = None
|
|
890
|
+
continue
|
|
891
|
+
if in_fence:
|
|
892
|
+
continue
|
|
893
|
+
m = re.match(r"^#{1,3}\s+(.+?)\s*#*\s*$", line)
|
|
894
|
+
if m:
|
|
895
|
+
title = " ".join(m.group(1).split())
|
|
896
|
+
if title and title.lower() not in seen:
|
|
897
|
+
seen.add(title.lower())
|
|
898
|
+
headings.append(title)
|
|
899
|
+
if len(headings) >= max_headings:
|
|
900
|
+
break
|
|
901
|
+
return headings
|
|
902
|
+
|
|
903
|
+
|
|
854
904
|
def _truncate_skill_body(text, max_chars, skill_name):
|
|
855
|
-
"""Truncate overly long SKILL.md cleanly on a line boundary with MCP
|
|
905
|
+
"""Truncate overly long SKILL.md cleanly on a line boundary with omitted section outline and MCP hint."""
|
|
856
906
|
if len(text) <= max_chars:
|
|
857
907
|
return text, False
|
|
858
|
-
|
|
908
|
+
|
|
909
|
+
total_lines = text.count("\n") + 1
|
|
910
|
+
|
|
911
|
+
def _build_notice(snippet_text):
|
|
912
|
+
shown_lines = snippet_text.count("\n") + 1
|
|
913
|
+
tail = text[len(snippet_text):]
|
|
914
|
+
omitted = _extract_markdown_headings(tail, max_headings=10)
|
|
915
|
+
if omitted:
|
|
916
|
+
parts = []
|
|
917
|
+
h_len = 0
|
|
918
|
+
for h in omitted:
|
|
919
|
+
add_len = len(h) + (2 if parts else 0)
|
|
920
|
+
if h_len + add_len > 250 and parts:
|
|
921
|
+
parts.append("...")
|
|
922
|
+
break
|
|
923
|
+
parts.append(h)
|
|
924
|
+
h_len += add_len
|
|
925
|
+
headings_str = ", ".join(parts)
|
|
926
|
+
return (
|
|
927
|
+
f"\n\n[... truncated at line {shown_lines}/{total_lines} ({len(snippet_text)}/{len(text)} chars) — "
|
|
928
|
+
f"OMITTED SECTIONS: {headings_str}. Call MCP load_skill(name=\"{skill_name}\", section=\"<heading>\") "
|
|
929
|
+
f"or load_skill(name=\"{skill_name}\", start_line={shown_lines + 1}) before executing omitted steps ...]"
|
|
930
|
+
)
|
|
931
|
+
return (
|
|
932
|
+
f"\n\n[... truncated at line {shown_lines}/{total_lines} ({len(snippet_text)}/{len(text)} chars); "
|
|
933
|
+
f"call MCP load_skill(name=\"{skill_name}\", start_line={shown_lines + 1}) if remaining sections are needed ...]"
|
|
934
|
+
)
|
|
935
|
+
|
|
936
|
+
cutoff = max(max_chars - 560, min(max_chars // 2, 500))
|
|
859
937
|
snippet = text[:cutoff]
|
|
860
938
|
last_nl = snippet.rfind("\n")
|
|
861
939
|
if last_nl > cutoff * 0.6:
|
|
862
940
|
snippet = snippet[:last_nl]
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
941
|
+
|
|
942
|
+
notice = _build_notice(snippet)
|
|
943
|
+
if len(snippet) + len(notice) > max_chars:
|
|
944
|
+
excess = len(snippet) + len(notice) - max_chars
|
|
945
|
+
new_cut = max(0, len(snippet) - excess)
|
|
946
|
+
snippet = snippet[:new_cut]
|
|
947
|
+
last_nl = snippet.rfind("\n")
|
|
948
|
+
if last_nl > new_cut * 0.5:
|
|
949
|
+
snippet = snippet[:last_nl]
|
|
950
|
+
notice = _build_notice(snippet)
|
|
951
|
+
if len(snippet) + len(notice) > max_chars:
|
|
952
|
+
snippet = snippet[: max(0, max_chars - len(notice))]
|
|
953
|
+
notice = _build_notice(snippet)
|
|
954
|
+
if len(snippet) + len(notice) > max_chars:
|
|
955
|
+
return (snippet + notice)[:max_chars], True
|
|
956
|
+
|
|
867
957
|
return snippet + notice, True
|
|
868
958
|
|
|
869
959
|
|
|
@@ -963,8 +1053,15 @@ def route_prompt(
|
|
|
963
1053
|
if raw_text:
|
|
964
1054
|
budget = min(max_single_chars, remaining_chars)
|
|
965
1055
|
body_text, truncated = _truncate_skill_body(raw_text, budget, cand["name"])
|
|
1056
|
+
rt_dir = cand.get("runtime_dir")
|
|
1057
|
+
effective_dir = (
|
|
1058
|
+
Path(rt_dir).resolve()
|
|
1059
|
+
if rt_dir and Path(rt_dir).exists()
|
|
1060
|
+
else skill_dir
|
|
1061
|
+
)
|
|
966
1062
|
item = dict(cand)
|
|
967
|
-
item["skill_dir"] = str(
|
|
1063
|
+
item["skill_dir"] = str(effective_dir)
|
|
1064
|
+
item["archive_dir"] = str(skill_dir)
|
|
968
1065
|
item["skill_md_path"] = str(md_path)
|
|
969
1066
|
item["content"] = body_text
|
|
970
1067
|
item["truncated"] = truncated
|
|
@@ -974,7 +1071,13 @@ def route_prompt(
|
|
|
974
1071
|
if len(pointer_items) < max_pointers:
|
|
975
1072
|
item = dict(cand)
|
|
976
1073
|
_, skill_dir = _resolve_skill_md_for_candidate(cand, archive_dir, base_dir)
|
|
977
|
-
|
|
1074
|
+
rt_dir = cand.get("runtime_dir")
|
|
1075
|
+
if rt_dir and Path(rt_dir).exists():
|
|
1076
|
+
item["skill_dir"] = str(Path(rt_dir).resolve())
|
|
1077
|
+
item["archive_dir"] = str(skill_dir) if skill_dir else cand.get("resolved_path", "")
|
|
1078
|
+
else:
|
|
1079
|
+
item["skill_dir"] = str(skill_dir) if skill_dir else cand.get("resolved_path", "")
|
|
1080
|
+
item["skill_md_path"] = str(Path(skill_dir) / "SKILL.md") if skill_dir else cand.get("archived_path", "")
|
|
978
1081
|
pointer_items.append(item)
|
|
979
1082
|
|
|
980
1083
|
if not inline_items and not pointer_items:
|
|
@@ -1010,7 +1113,9 @@ def route_prompt(
|
|
|
1010
1113
|
for item in pointer_items:
|
|
1011
1114
|
desc = item.get("description", "").strip()
|
|
1012
1115
|
short_desc = desc[:130] + "..." if len(desc) > 130 else desc
|
|
1013
|
-
skill_md_loc =
|
|
1116
|
+
skill_md_loc = item.get("skill_md_path") or (
|
|
1117
|
+
str(Path(item["skill_dir"]) / "SKILL.md") if item.get("skill_dir") else item.get("archived_path", "")
|
|
1118
|
+
)
|
|
1014
1119
|
sections.append(
|
|
1015
1120
|
f'- **{item["name"]}** [{item["category"]}]: {short_desc} (`{skill_md_loc}`)'
|
|
1016
1121
|
)
|
package/scripts/skill_vault.py
CHANGED
|
@@ -10,6 +10,7 @@ import argparse
|
|
|
10
10
|
from datetime import datetime
|
|
11
11
|
import fnmatch
|
|
12
12
|
import hashlib
|
|
13
|
+
import io
|
|
13
14
|
import json
|
|
14
15
|
import os
|
|
15
16
|
from pathlib import Path
|
|
@@ -885,6 +886,191 @@ class SkillVault:
|
|
|
885
886
|
pass
|
|
886
887
|
return protected
|
|
887
888
|
|
|
889
|
+
def _collect_bin_shim_targets(self):
|
|
890
|
+
"""Read small launcher shims in antigravity/bin or base_dir/bin to detect path-bound scripts."""
|
|
891
|
+
app_data = os.environ.get("ANTIGRAVITY_APP_DATA_DIR")
|
|
892
|
+
agy_bin = (Path(app_data) / "bin") if app_data else (Path.home() / ".gemini" / "antigravity" / "bin")
|
|
893
|
+
bin_dirs = []
|
|
894
|
+
for cand in (agy_bin, self.base_dir / "bin", self.get_root_dir() / "bin"):
|
|
895
|
+
if cand.exists() and cand.is_dir():
|
|
896
|
+
res = cand.resolve()
|
|
897
|
+
if res not in bin_dirs:
|
|
898
|
+
bin_dirs.append(res)
|
|
899
|
+
|
|
900
|
+
shims = []
|
|
901
|
+
for bdir in bin_dirs:
|
|
902
|
+
try:
|
|
903
|
+
for fp in bdir.iterdir():
|
|
904
|
+
if not fp.is_file():
|
|
905
|
+
continue
|
|
906
|
+
if fp.suffix.lower() not in {".cmd", ".bat", ".sh", ""}:
|
|
907
|
+
continue
|
|
908
|
+
try:
|
|
909
|
+
if fp.stat().st_size > 4096:
|
|
910
|
+
continue
|
|
911
|
+
txt = fp.read_text(encoding="utf-8", errors="ignore").lower()
|
|
912
|
+
shims.append((fp.name, txt))
|
|
913
|
+
except OSError:
|
|
914
|
+
pass
|
|
915
|
+
except OSError:
|
|
916
|
+
pass
|
|
917
|
+
return shims
|
|
918
|
+
|
|
919
|
+
def assess_skill_compat(self, skill_dir, original_path=None, bin_shim_targets=None, max_single_chars=None):
|
|
920
|
+
"""Inspect a skill directory for path dependencies, cross-skill refs, truncation size, and guardrails."""
|
|
921
|
+
skill_dir = Path(skill_dir)
|
|
922
|
+
if max_single_chars is None:
|
|
923
|
+
max_single_chars = int(self.load_config().get("routing", {}).get("max_single_skill_chars", 9000))
|
|
924
|
+
else:
|
|
925
|
+
max_single_chars = int(max_single_chars)
|
|
926
|
+
|
|
927
|
+
companion_files = []
|
|
928
|
+
if skill_dir.exists():
|
|
929
|
+
for root, dirs, files in os.walk(skill_dir):
|
|
930
|
+
rp = Path(root)
|
|
931
|
+
dirs[:] = sorted(
|
|
932
|
+
d for d in dirs
|
|
933
|
+
if d not in {"__pycache__", ".git", "node_modules"}
|
|
934
|
+
and not (rp / d / "SKILL.md").exists()
|
|
935
|
+
)
|
|
936
|
+
for fname in sorted(files):
|
|
937
|
+
if rp == skill_dir and fname == "SKILL.md":
|
|
938
|
+
continue
|
|
939
|
+
companion_files.append((rp / fname).relative_to(skill_dir).as_posix())
|
|
940
|
+
|
|
941
|
+
has_companions = len(companion_files) > 0
|
|
942
|
+
skill_md = skill_dir / "SKILL.md"
|
|
943
|
+
skill_md_bytes = 0
|
|
944
|
+
md_text = ""
|
|
945
|
+
if skill_md.exists():
|
|
946
|
+
try:
|
|
947
|
+
skill_md_bytes = skill_md.stat().st_size
|
|
948
|
+
md_text = skill_md.read_text(encoding="utf-8", errors="replace")
|
|
949
|
+
except OSError:
|
|
950
|
+
pass
|
|
951
|
+
oversized_skill_md = skill_md_bytes > max_single_chars
|
|
952
|
+
|
|
953
|
+
traversal_re = re.compile(
|
|
954
|
+
r"(?:%~dp0\s*\.\.[\\/]\.\.|(?:\.\.[\\/]){2,}|"
|
|
955
|
+
r"path\.resolve\(\s*__dirname\s*,\s*['\"](?:\.\.[\\/]){2,}|\.parents\[\s*[234]\s*\])",
|
|
956
|
+
re.IGNORECASE,
|
|
957
|
+
)
|
|
958
|
+
plugin_env_re = re.compile(
|
|
959
|
+
r"\b(?:PLUGIN_DIR_NAME|CLAUDE_PLUGIN_ROOT|PLUGIN_DIR|PLUGIN_DATA|plugin_data)\b"
|
|
960
|
+
)
|
|
961
|
+
script_exts = {".py", ".js", ".ts", ".sh", ".cmd", ".bat", ".ps1", ".toml"}
|
|
962
|
+
|
|
963
|
+
path_reasons = []
|
|
964
|
+
for rel in companion_files:
|
|
965
|
+
fp = skill_dir / rel
|
|
966
|
+
if not rel.startswith("scripts/") and fp.suffix.lower() not in script_exts:
|
|
967
|
+
continue
|
|
968
|
+
try:
|
|
969
|
+
if fp.stat().st_size > 262144:
|
|
970
|
+
continue
|
|
971
|
+
ftxt = fp.read_text(encoding="utf-8", errors="ignore")
|
|
972
|
+
except OSError:
|
|
973
|
+
continue
|
|
974
|
+
if traversal_re.search(ftxt):
|
|
975
|
+
path_reasons.append(f"script_parent_traversal: {rel}")
|
|
976
|
+
if plugin_env_re.search(ftxt):
|
|
977
|
+
path_reasons.append(f"script_plugin_root_ref: {rel}")
|
|
978
|
+
|
|
979
|
+
if original_path and bin_shim_targets:
|
|
980
|
+
orig_fwd = str(Path(original_path)).lower().replace("\\", "/")
|
|
981
|
+
orig_bck = str(Path(original_path)).lower().replace("/", "\\")
|
|
982
|
+
for shim_name, shim_txt in bin_shim_targets:
|
|
983
|
+
for pat in (orig_fwd, orig_bck):
|
|
984
|
+
pos = shim_txt.find(pat)
|
|
985
|
+
if pos != -1:
|
|
986
|
+
end_pos = pos + len(pat)
|
|
987
|
+
if end_pos == len(shim_txt) or shim_txt[end_pos] in ("/", "\\", "\"", "'", " ", "\t", "\r", "\n"):
|
|
988
|
+
path_reasons.append(f"path_shim_target: bin/{shim_name}")
|
|
989
|
+
break
|
|
990
|
+
|
|
991
|
+
cross_re = re.compile(
|
|
992
|
+
r"(?:\.\./[a-zA-Z0-9._-]+(?:/[a-zA-Z0-9._-]+)*|"
|
|
993
|
+
r"\$\{?CLAUDE_PLUGIN_ROOT\}?|\$PLUGIN_DIR|<PLUGIN_DIR>|@skill:[a-zA-Z0-9._-]+)"
|
|
994
|
+
)
|
|
995
|
+
cross_skill_refs = []
|
|
996
|
+
seen_refs = set()
|
|
997
|
+
for m in cross_re.finditer(md_text):
|
|
998
|
+
val = m.group(0)
|
|
999
|
+
if val not in seen_refs:
|
|
1000
|
+
seen_refs.add(val)
|
|
1001
|
+
cross_skill_refs.append(val)
|
|
1002
|
+
if len(cross_skill_refs) >= 15:
|
|
1003
|
+
break
|
|
1004
|
+
|
|
1005
|
+
if has_companions and re.search(
|
|
1006
|
+
r"(?:\$\{?CLAUDE_PLUGIN_ROOT\}?|\$PLUGIN_DIR|<PLUGIN_DIR>|\.\./[a-zA-Z0-9._-]+/scripts/)",
|
|
1007
|
+
md_text,
|
|
1008
|
+
):
|
|
1009
|
+
path_reasons.append("skill_plugin_path_ref: SKILL.md")
|
|
1010
|
+
|
|
1011
|
+
# Deduplicate while preserving order
|
|
1012
|
+
path_reasons = list(dict.fromkeys(path_reasons))
|
|
1013
|
+
|
|
1014
|
+
guard_re = re.compile(
|
|
1015
|
+
r"(?:trigger:\s*always_on|MANDATORY:\s*Execute FIRST|CRITICAL RULE|STOP AND VERIFY)"
|
|
1016
|
+
)
|
|
1017
|
+
guardrail_signals = list(dict.fromkeys(m.group(0) for m in guard_re.finditer(md_text[:2000])))
|
|
1018
|
+
|
|
1019
|
+
path_dependent = bool(path_reasons)
|
|
1020
|
+
needs_runtime_in_place = bool(path_dependent and has_companions)
|
|
1021
|
+
return {
|
|
1022
|
+
"path_dependent": path_dependent,
|
|
1023
|
+
"needs_runtime_in_place": needs_runtime_in_place,
|
|
1024
|
+
"has_companions": has_companions,
|
|
1025
|
+
"path_reasons": path_reasons,
|
|
1026
|
+
"cross_skill_refs": cross_skill_refs,
|
|
1027
|
+
"oversized_skill_md": oversized_skill_md,
|
|
1028
|
+
"skill_md_bytes": skill_md_bytes,
|
|
1029
|
+
"guardrail_signals": guardrail_signals,
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
def _prune_skill_runtime_in_place(self, active_path):
|
|
1033
|
+
"""Remove SKILL.md only so L1 context drops to 0 while path-dependent companions stay in place."""
|
|
1034
|
+
active_path = Path(active_path)
|
|
1035
|
+
if not active_path.exists():
|
|
1036
|
+
return False
|
|
1037
|
+
skill_md = active_path / "SKILL.md"
|
|
1038
|
+
if skill_md.exists():
|
|
1039
|
+
skill_md.unlink()
|
|
1040
|
+
try:
|
|
1041
|
+
has_remaining = any(active_path.iterdir())
|
|
1042
|
+
except OSError:
|
|
1043
|
+
has_remaining = False
|
|
1044
|
+
if not has_remaining:
|
|
1045
|
+
try:
|
|
1046
|
+
active_path.rmdir()
|
|
1047
|
+
except OSError:
|
|
1048
|
+
pass
|
|
1049
|
+
return False
|
|
1050
|
+
return True
|
|
1051
|
+
|
|
1052
|
+
def _materialize_runtime_companions(self, archived_dir, target_dir):
|
|
1053
|
+
"""Copy companion files from L2 to target_dir without creating SKILL.md."""
|
|
1054
|
+
archived_dir = Path(archived_dir).resolve()
|
|
1055
|
+
target_dir = Path(target_dir).resolve()
|
|
1056
|
+
if (target_dir / "SKILL.md").exists():
|
|
1057
|
+
return False
|
|
1058
|
+
target_dir.mkdir(parents=True, exist_ok=True)
|
|
1059
|
+
|
|
1060
|
+
def _ignore_skill_md_and_nested(curr_dir, names):
|
|
1061
|
+
curr_path = Path(curr_dir).resolve()
|
|
1062
|
+
ignored = []
|
|
1063
|
+
if curr_path == archived_dir:
|
|
1064
|
+
for n in names:
|
|
1065
|
+
if n == "SKILL.md":
|
|
1066
|
+
ignored.append(n)
|
|
1067
|
+
elif (curr_path / n).is_dir() and (curr_path / n / "SKILL.md").exists():
|
|
1068
|
+
ignored.append(n)
|
|
1069
|
+
return ignored
|
|
1070
|
+
|
|
1071
|
+
shutil.copytree(archived_dir, target_dir, dirs_exist_ok=True, ignore=_ignore_skill_md_and_nested)
|
|
1072
|
+
return True
|
|
1073
|
+
|
|
888
1074
|
def make_portable_path(self, abs_path):
|
|
889
1075
|
"""Convert path to relative from base_dir or root_dir if possible."""
|
|
890
1076
|
resolved = Path(abs_path).resolve()
|
|
@@ -1223,6 +1409,7 @@ class SkillVault:
|
|
|
1223
1409
|
|
|
1224
1410
|
core_set = self.get_core_skills(protect_skills)
|
|
1225
1411
|
hook_protected = self.get_hook_protected_skills()
|
|
1412
|
+
bin_shims = self._collect_bin_shim_targets()
|
|
1226
1413
|
|
|
1227
1414
|
active_skills = self.get_active_skills()
|
|
1228
1415
|
manifest = self.load_manifest()
|
|
@@ -1271,7 +1458,12 @@ class SkillVault:
|
|
|
1271
1458
|
elif is_hook_dep:
|
|
1272
1459
|
protected_hooks.append(name)
|
|
1273
1460
|
elif not keep_active:
|
|
1274
|
-
|
|
1461
|
+
compat = (
|
|
1462
|
+
self.assess_skill_compat(active_path, original_path=active_path, bin_shim_targets=bin_shims)
|
|
1463
|
+
if not data.get("single_skill_dir")
|
|
1464
|
+
else {"needs_runtime_in_place": False, "path_reasons": []}
|
|
1465
|
+
)
|
|
1466
|
+
to_prune.append((name, data, compat))
|
|
1275
1467
|
|
|
1276
1468
|
print("Scan Results:")
|
|
1277
1469
|
print(f" * New skills to ingest into vault: {len(to_ingest_new)}")
|
|
@@ -1289,8 +1481,11 @@ class SkillVault:
|
|
|
1289
1481
|
for name in sorted(protected_hooks):
|
|
1290
1482
|
print(f" [Protected (Hook Dependency)] {name}")
|
|
1291
1483
|
print(f" * Non-core active skills to prune: {len(to_prune)}")
|
|
1292
|
-
for name,
|
|
1293
|
-
|
|
1484
|
+
for name, data, compat in to_prune:
|
|
1485
|
+
if compat.get("needs_runtime_in_place"):
|
|
1486
|
+
print(f" [PRUNE (Runtime-in-Place)] {name} (Remove SKILL.md only; keep scripts at {data['path']})")
|
|
1487
|
+
else:
|
|
1488
|
+
print(f" [PRUNE] {name} (Will be removed from active context to prevent context bloat)")
|
|
1294
1489
|
print("")
|
|
1295
1490
|
|
|
1296
1491
|
if dry_run:
|
|
@@ -1324,7 +1519,7 @@ class SkillVault:
|
|
|
1324
1519
|
}
|
|
1325
1520
|
total_ingested += 1
|
|
1326
1521
|
|
|
1327
|
-
for name, data in to_prune:
|
|
1522
|
+
for name, data, compat in to_prune:
|
|
1328
1523
|
active_path = Path(data["path"])
|
|
1329
1524
|
if data.get("single_skill_dir"):
|
|
1330
1525
|
for sub in active_path.iterdir():
|
|
@@ -1335,6 +1530,18 @@ class SkillVault:
|
|
|
1335
1530
|
else:
|
|
1336
1531
|
sub.unlink()
|
|
1337
1532
|
print(f"[Pruned] Emptied single-skill directory: {active_path}")
|
|
1533
|
+
elif compat.get("needs_runtime_in_place"):
|
|
1534
|
+
kept_rt = self._prune_skill_runtime_in_place(active_path)
|
|
1535
|
+
if kept_rt and name in manifest_map:
|
|
1536
|
+
manifest_map[name]["runtime_dir"] = self.make_portable_path(active_path)
|
|
1537
|
+
manifest_map[name]["relocation_mode"] = "runtime_in_place"
|
|
1538
|
+
reasons_str = ", ".join(compat.get("path_reasons", [])[:3])
|
|
1539
|
+
print(
|
|
1540
|
+
f"[Pruned (Runtime-in-Place)] Removed SKILL.md only; kept companion files at: "
|
|
1541
|
+
f"{active_path} ({reasons_str})"
|
|
1542
|
+
)
|
|
1543
|
+
else:
|
|
1544
|
+
print(f"[Pruned] Removed active folder: {active_path}")
|
|
1338
1545
|
else:
|
|
1339
1546
|
if active_path.exists():
|
|
1340
1547
|
shutil.rmtree(active_path)
|
|
@@ -1441,6 +1648,7 @@ class SkillVault:
|
|
|
1441
1648
|
manifest = self.load_manifest()
|
|
1442
1649
|
manifest_map = {item["name"]: item for item in manifest}
|
|
1443
1650
|
hook_protected = self.get_hook_protected_skills()
|
|
1651
|
+
bin_shims = self._collect_bin_shim_targets()
|
|
1444
1652
|
|
|
1445
1653
|
skills_to_archive = []
|
|
1446
1654
|
if name:
|
|
@@ -1475,8 +1683,16 @@ class SkillVault:
|
|
|
1475
1683
|
if skill_name in hook_protected:
|
|
1476
1684
|
print(f"[Protected (Hook Dependency)] Preserving active '{skill_name}' (referenced by plugin hooks/MCP; use --force to override)")
|
|
1477
1685
|
else:
|
|
1478
|
-
|
|
1479
|
-
|
|
1686
|
+
compat = self.assess_skill_compat(active_path, original_path=active_path, bin_shim_targets=bin_shims)
|
|
1687
|
+
if compat.get("needs_runtime_in_place"):
|
|
1688
|
+
kept_rt = self._prune_skill_runtime_in_place(active_path)
|
|
1689
|
+
if kept_rt and skill_name in manifest_map:
|
|
1690
|
+
manifest_map[skill_name]["runtime_dir"] = self.make_portable_path(active_path)
|
|
1691
|
+
manifest_map[skill_name]["relocation_mode"] = "runtime_in_place"
|
|
1692
|
+
print(f"[Cleaned (Runtime-in-Place)] Removed SKILL.md only; kept companion files at: {active_path}")
|
|
1693
|
+
else:
|
|
1694
|
+
shutil.rmtree(active_path)
|
|
1695
|
+
print(f"[Cleaned] Removed older active directory: {active_path}")
|
|
1480
1696
|
continue
|
|
1481
1697
|
elif recency > 0:
|
|
1482
1698
|
print(f"[Archived] Overwriting older L2 archive with newer active L1 version: {active_path} -> {dest_dir}")
|
|
@@ -1508,8 +1724,16 @@ class SkillVault:
|
|
|
1508
1724
|
if skill_name in hook_protected and not force:
|
|
1509
1725
|
print(f"[Protected (Hook Dependency)] Preserving active '{skill_name}' (referenced by plugin hooks/MCP; use --force to override)")
|
|
1510
1726
|
else:
|
|
1511
|
-
|
|
1512
|
-
|
|
1727
|
+
compat = self.assess_skill_compat(active_path, original_path=active_path, bin_shim_targets=bin_shims)
|
|
1728
|
+
if compat.get("needs_runtime_in_place") and not force:
|
|
1729
|
+
kept_rt = self._prune_skill_runtime_in_place(active_path)
|
|
1730
|
+
if kept_rt:
|
|
1731
|
+
manifest_map[skill_name]["runtime_dir"] = self.make_portable_path(active_path)
|
|
1732
|
+
manifest_map[skill_name]["relocation_mode"] = "runtime_in_place"
|
|
1733
|
+
print(f"[Cleaned (Runtime-in-Place)] Removed SKILL.md only; kept companion files at: {active_path}")
|
|
1734
|
+
else:
|
|
1735
|
+
shutil.rmtree(active_path)
|
|
1736
|
+
print(f"[Cleaned] Removed active directory: {active_path}")
|
|
1513
1737
|
|
|
1514
1738
|
self.save_manifest(list(manifest_map.values()))
|
|
1515
1739
|
self.reindex()
|
|
@@ -1920,12 +2144,20 @@ class SkillVault:
|
|
|
1920
2144
|
if archived_path.exists() and (archived_path / "SKILL.md").exists():
|
|
1921
2145
|
folder_name = archived_path.name
|
|
1922
2146
|
if folder_name not in manifest_by_folder or item.get("name") == folder_name:
|
|
1923
|
-
|
|
2147
|
+
entry = {
|
|
1924
2148
|
"name": folder_name,
|
|
1925
2149
|
"category": item.get("category") or "General & Utility Skills",
|
|
1926
2150
|
"original_path": item.get("original_path", self.make_portable_path(self.skills_dir / folder_name)),
|
|
1927
2151
|
"archived_path": self.make_portable_path(archived_path),
|
|
1928
2152
|
}
|
|
2153
|
+
if item.get("runtime_dir"):
|
|
2154
|
+
rt_path = self.resolve_original_path(item["runtime_dir"], skill_name=folder_name)
|
|
2155
|
+
if not rt_path.exists():
|
|
2156
|
+
rt_path = self.resolve_portable_path(item["runtime_dir"])
|
|
2157
|
+
if rt_path.exists() and rt_path.is_dir() and not (rt_path / "SKILL.md").exists():
|
|
2158
|
+
entry["runtime_dir"] = item["runtime_dir"]
|
|
2159
|
+
entry["relocation_mode"] = item.get("relocation_mode") or "runtime_in_place"
|
|
2160
|
+
manifest_by_folder[folder_name] = entry
|
|
1929
2161
|
|
|
1930
2162
|
disk_skills = self.get_archived_skill_folders()
|
|
1931
2163
|
for name, data in disk_skills.items():
|
|
@@ -2241,108 +2473,312 @@ class SkillVault:
|
|
|
2241
2473
|
print(f" * {rc}")
|
|
2242
2474
|
print("")
|
|
2243
2475
|
|
|
2244
|
-
def verify(self, fix=False):
|
|
2245
|
-
"""Perform a
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
disk_skills = self.get_archived_skill_folders()
|
|
2253
|
-
manifest = self.load_manifest()
|
|
2254
|
-
manifest_map = {m["name"]: m for m in manifest}
|
|
2255
|
-
indexed_skills = self.parse_index_file()
|
|
2476
|
+
def verify(self, fix=False, compat=False, as_json=False):
|
|
2477
|
+
"""Perform a bi-directional integrity check and optional L2 compatibility audit."""
|
|
2478
|
+
if not as_json:
|
|
2479
|
+
print("==================================================")
|
|
2480
|
+
print(" SKILL VAULT INTEGRITY AUDIT")
|
|
2481
|
+
print(f" Base Directory: {self.base_dir}")
|
|
2482
|
+
print(f" Archive Store: {self.archive_dir}")
|
|
2483
|
+
print("==================================================\n")
|
|
2256
2484
|
|
|
2257
|
-
|
|
2258
|
-
|
|
2485
|
+
def _audit_integrity():
|
|
2486
|
+
disk_skills_local = self.get_archived_skill_folders()
|
|
2487
|
+
manifest_local = self.load_manifest()
|
|
2488
|
+
manifest_map_local = {m["name"]: m for m in manifest_local}
|
|
2489
|
+
indexed_local = self.parse_index_file()
|
|
2259
2490
|
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
issues.append(f"[Disk Error] Folder '{name}' in archive is missing SKILL.md")
|
|
2263
|
-
elif d["size"] == 0:
|
|
2264
|
-
issues.append(f"[Disk Error] SKILL.md in '{name}' is 0 bytes (empty file)")
|
|
2491
|
+
issues_local = []
|
|
2492
|
+
warnings_local = []
|
|
2265
2493
|
|
|
2266
|
-
|
|
2267
|
-
|
|
2494
|
+
for name, d in disk_skills_local.items():
|
|
2495
|
+
if not d["has_skill_md"]:
|
|
2496
|
+
issues_local.append(f"[Disk Error] Folder '{name}' in archive is missing SKILL.md")
|
|
2497
|
+
elif d["size"] == 0:
|
|
2498
|
+
issues_local.append(f"[Disk Error] SKILL.md in '{name}' is 0 bytes (empty file)")
|
|
2268
2499
|
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
for name in sorted(unmanifested_disk):
|
|
2272
|
-
issues.append(f"[Uncataloged on Disk] '{name}' exists in archive folder but NOT in backup_manifest.json")
|
|
2500
|
+
disk_names = set(disk_skills_local.keys())
|
|
2501
|
+
manifest_names = set(manifest_map_local.keys())
|
|
2273
2502
|
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
for name in sorted(
|
|
2277
|
-
|
|
2503
|
+
for name in sorted(disk_names - manifest_names):
|
|
2504
|
+
issues_local.append(f"[Uncataloged on Disk] '{name}' exists in archive folder but NOT in backup_manifest.json")
|
|
2505
|
+
for name in sorted(manifest_names - disk_names):
|
|
2506
|
+
issues_local.append(f"[Phantom Manifest Entry] '{name}' listed in backup_manifest.json but NOT found on disk")
|
|
2278
2507
|
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
unindexed_manifest = manifest_names - index_names
|
|
2302
|
-
if unindexed_manifest:
|
|
2303
|
-
for name in sorted(unindexed_manifest):
|
|
2304
|
-
issues.append(f"[Manifest/Index Mismatch] '{name}' is in backup_manifest.json but NOT in INDEX.md")
|
|
2305
|
-
|
|
2306
|
-
for name, data in indexed_skills.items():
|
|
2307
|
-
link_path_str = data.get("link_path")
|
|
2308
|
-
if link_path_str:
|
|
2309
|
-
if link_path_str.startswith("file:///"):
|
|
2310
|
-
pass
|
|
2311
|
-
else:
|
|
2508
|
+
for item in manifest_local:
|
|
2509
|
+
name = item["name"]
|
|
2510
|
+
archived_path = self.resolve_portable_path(item.get("archived_path", ""))
|
|
2511
|
+
if not archived_path.exists():
|
|
2512
|
+
issues_local.append(f"[Broken Manifest Path] '{name}' archived_path does not exist: {archived_path}")
|
|
2513
|
+
elif not (archived_path / "SKILL.md").exists():
|
|
2514
|
+
issues_local.append(f"[Missing SKILL.md] '{name}' archived_path has no SKILL.md: {archived_path}")
|
|
2515
|
+
if not item.get("category"):
|
|
2516
|
+
warnings_local.append(f"[Missing Category] '{name}' in manifest has no category assigned")
|
|
2517
|
+
|
|
2518
|
+
index_names = set(indexed_local.keys())
|
|
2519
|
+
for name in sorted(disk_names - index_names):
|
|
2520
|
+
issues_local.append(f"[Unindexed on Disk] '{name}' exists on disk but is NOT listed in INDEX.md")
|
|
2521
|
+
for name in sorted(index_names - disk_names):
|
|
2522
|
+
issues_local.append(f"[Phantom Index Entry] '{name}' listed in INDEX.md but does NOT exist on disk")
|
|
2523
|
+
for name in sorted(manifest_names - index_names):
|
|
2524
|
+
issues_local.append(f"[Manifest/Index Mismatch] '{name}' is in backup_manifest.json but NOT in INDEX.md")
|
|
2525
|
+
|
|
2526
|
+
for name, data in indexed_local.items():
|
|
2527
|
+
link_path_str = data.get("link_path")
|
|
2528
|
+
if link_path_str and not link_path_str.startswith("file:///"):
|
|
2312
2529
|
target_file = (self.archive_dir / link_path_str).resolve()
|
|
2313
2530
|
if not target_file.exists():
|
|
2314
|
-
|
|
2531
|
+
issues_local.append(f"[Broken Index Link] '{name}' link target missing: {target_file}")
|
|
2315
2532
|
|
|
2316
|
-
|
|
2317
|
-
print(f" * Physical Folders on Disk: {len(disk_skills)}")
|
|
2318
|
-
print(f" * Entries in backup_manifest.json: {len(manifest)}")
|
|
2319
|
-
print(f" * Entries in INDEX.md: {len(indexed_skills)}\n")
|
|
2533
|
+
return disk_skills_local, manifest_local, indexed_local, issues_local, warnings_local
|
|
2320
2534
|
|
|
2321
|
-
|
|
2322
|
-
print("[OK] 100% Integrity Verified! Disk, manifest, and index are in perfect sync.\n")
|
|
2323
|
-
return 0
|
|
2535
|
+
disk_skills, manifest, indexed_skills, issues, warnings = _audit_integrity()
|
|
2324
2536
|
|
|
2325
|
-
if
|
|
2326
|
-
print(
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
print("")
|
|
2537
|
+
if not as_json:
|
|
2538
|
+
print("Component Counts:")
|
|
2539
|
+
print(f" * Physical Folders on Disk: {len(disk_skills)}")
|
|
2540
|
+
print(f" * Entries in backup_manifest.json: {len(manifest)}")
|
|
2541
|
+
print(f" * Entries in INDEX.md: {len(indexed_skills)}\n")
|
|
2330
2542
|
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2543
|
+
if not issues and not warnings and not compat:
|
|
2544
|
+
print("[OK] 100% Integrity Verified! Disk, manifest, and index are in perfect sync.\n")
|
|
2545
|
+
return 0
|
|
2546
|
+
|
|
2547
|
+
if warnings:
|
|
2548
|
+
print(f"Warnings ({len(warnings)}):")
|
|
2549
|
+
for w in warnings:
|
|
2550
|
+
print(f" [!] {w}")
|
|
2551
|
+
print("")
|
|
2552
|
+
|
|
2553
|
+
if issues:
|
|
2554
|
+
print(f"Discrepancies / Errors ({len(issues)}):")
|
|
2555
|
+
for iss in issues:
|
|
2556
|
+
print(f" [X] {iss}")
|
|
2557
|
+
print("")
|
|
2336
2558
|
|
|
2337
|
-
|
|
2559
|
+
integrity_repaired = False
|
|
2560
|
+
if issues and fix:
|
|
2561
|
+
if not as_json:
|
|
2338
2562
|
print("[Self-Healing] Applying automatic repairs (--fix enabled)...")
|
|
2339
|
-
|
|
2563
|
+
self.reindex()
|
|
2564
|
+
integrity_repaired = True
|
|
2565
|
+
if not as_json:
|
|
2340
2566
|
print("[Self-Healing] Reindexed and resynchronized successfully.\n")
|
|
2567
|
+
if not compat and not as_json:
|
|
2341
2568
|
return 0
|
|
2342
|
-
|
|
2569
|
+
disk_skills, manifest, indexed_skills, issues, warnings = _audit_integrity()
|
|
2570
|
+
|
|
2571
|
+
if not compat:
|
|
2572
|
+
if as_json:
|
|
2573
|
+
print(
|
|
2574
|
+
json.dumps(
|
|
2575
|
+
{
|
|
2576
|
+
"counts": {
|
|
2577
|
+
"disk": len(disk_skills),
|
|
2578
|
+
"manifest": len(manifest),
|
|
2579
|
+
"index": len(indexed_skills),
|
|
2580
|
+
},
|
|
2581
|
+
"issues": issues,
|
|
2582
|
+
"warnings": warnings,
|
|
2583
|
+
"integrity_repaired": integrity_repaired,
|
|
2584
|
+
"ok": not issues,
|
|
2585
|
+
},
|
|
2586
|
+
indent=2,
|
|
2587
|
+
)
|
|
2588
|
+
)
|
|
2589
|
+
return 0 if not issues else 1
|
|
2590
|
+
if issues:
|
|
2343
2591
|
print("Tip: Run with '--fix' (e.g. 'python skill_vault.py verify --fix') to automatically repair discrepancies.\n")
|
|
2344
2592
|
return 1
|
|
2593
|
+
return 0
|
|
2594
|
+
|
|
2595
|
+
# Compatibility audit across vaulted skills
|
|
2596
|
+
bin_shims = self._collect_bin_shim_targets()
|
|
2597
|
+
active_skills = self.get_active_skills()
|
|
2598
|
+
base_res = self.base_dir.resolve()
|
|
2599
|
+
root_res = self.get_root_dir().resolve()
|
|
2600
|
+
|
|
2601
|
+
def _can_safely_materialize(orig_path):
|
|
2602
|
+
orig_res = Path(orig_path).resolve()
|
|
2603
|
+
anchor = None
|
|
2604
|
+
rel_parts = ()
|
|
2605
|
+
for cand_anchor in (base_res, root_res):
|
|
2606
|
+
try:
|
|
2607
|
+
rel = orig_res.relative_to(cand_anchor)
|
|
2608
|
+
anchor = cand_anchor
|
|
2609
|
+
rel_parts = rel.parts
|
|
2610
|
+
break
|
|
2611
|
+
except ValueError:
|
|
2612
|
+
continue
|
|
2613
|
+
if anchor is None or (orig_res / "SKILL.md").exists():
|
|
2614
|
+
return False
|
|
2615
|
+
if len(rel_parts) >= 2 and rel_parts[0].lower() == "plugins":
|
|
2616
|
+
plugin_dir = anchor / rel_parts[0] / rel_parts[1]
|
|
2617
|
+
if not plugin_dir.exists() or not plugin_dir.is_dir():
|
|
2618
|
+
return False
|
|
2619
|
+
return True
|
|
2620
|
+
|
|
2621
|
+
path_dependent_broken = []
|
|
2622
|
+
runtime_in_place_active = []
|
|
2623
|
+
cross_skill_refs = []
|
|
2624
|
+
oversized = []
|
|
2625
|
+
vaulted_guardrails = []
|
|
2626
|
+
|
|
2627
|
+
for item in manifest:
|
|
2628
|
+
name = item["name"]
|
|
2629
|
+
archived_path = self.resolve_portable_path(item.get("archived_path", ""))
|
|
2630
|
+
if not (archived_path / "SKILL.md").exists():
|
|
2631
|
+
continue
|
|
2632
|
+
orig_path = self.resolve_original_path(item.get("original_path", ""), skill_name=name)
|
|
2633
|
+
is_active_l1 = (orig_path / "SKILL.md").exists() or (name in active_skills)
|
|
2634
|
+
|
|
2635
|
+
info = self.assess_skill_compat(archived_path, original_path=orig_path, bin_shim_targets=bin_shims)
|
|
2636
|
+
|
|
2637
|
+
rt_ok = False
|
|
2638
|
+
rt_path = None
|
|
2639
|
+
if item.get("runtime_dir"):
|
|
2640
|
+
rt_path = self.resolve_original_path(item["runtime_dir"], skill_name=name)
|
|
2641
|
+
if not rt_path.exists():
|
|
2642
|
+
rt_path = self.resolve_portable_path(item["runtime_dir"])
|
|
2643
|
+
try:
|
|
2644
|
+
rt_ok = (
|
|
2645
|
+
rt_path.exists()
|
|
2646
|
+
and rt_path.is_dir()
|
|
2647
|
+
and not (rt_path / "SKILL.md").exists()
|
|
2648
|
+
and any(rt_path.iterdir())
|
|
2649
|
+
)
|
|
2650
|
+
except OSError:
|
|
2651
|
+
rt_ok = False
|
|
2652
|
+
|
|
2653
|
+
if info["needs_runtime_in_place"] and not is_active_l1:
|
|
2654
|
+
if rt_ok:
|
|
2655
|
+
runtime_in_place_active.append({
|
|
2656
|
+
"name": name,
|
|
2657
|
+
"runtime_dir": str(rt_path),
|
|
2658
|
+
"reasons": info["path_reasons"],
|
|
2659
|
+
})
|
|
2660
|
+
else:
|
|
2661
|
+
path_dependent_broken.append({
|
|
2662
|
+
"name": name,
|
|
2663
|
+
"item": item,
|
|
2664
|
+
"archived_path": archived_path,
|
|
2665
|
+
"orig_path": orig_path,
|
|
2666
|
+
"reasons": info["path_reasons"],
|
|
2667
|
+
})
|
|
2345
2668
|
|
|
2669
|
+
if info["cross_skill_refs"]:
|
|
2670
|
+
cross_skill_refs.append({"name": name, "refs": info["cross_skill_refs"]})
|
|
2671
|
+
if info["oversized_skill_md"]:
|
|
2672
|
+
oversized.append({"name": name, "bytes": info["skill_md_bytes"]})
|
|
2673
|
+
if info["guardrail_signals"] and not is_active_l1:
|
|
2674
|
+
vaulted_guardrails.append({"name": name, "signals": info["guardrail_signals"]})
|
|
2675
|
+
|
|
2676
|
+
repaired_compat = []
|
|
2677
|
+
remaining_broken = []
|
|
2678
|
+
if fix and path_dependent_broken:
|
|
2679
|
+
for entry in path_dependent_broken:
|
|
2680
|
+
orig_path = entry["orig_path"]
|
|
2681
|
+
if _can_safely_materialize(orig_path):
|
|
2682
|
+
self._materialize_runtime_companions(entry["archived_path"], orig_path)
|
|
2683
|
+
entry["item"]["runtime_dir"] = self.make_portable_path(orig_path)
|
|
2684
|
+
entry["item"]["relocation_mode"] = "runtime_in_place"
|
|
2685
|
+
repaired_compat.append({"name": entry["name"], "runtime_dir": str(orig_path)})
|
|
2686
|
+
runtime_in_place_active.append({
|
|
2687
|
+
"name": entry["name"],
|
|
2688
|
+
"runtime_dir": str(orig_path),
|
|
2689
|
+
"reasons": entry["reasons"],
|
|
2690
|
+
})
|
|
2691
|
+
else:
|
|
2692
|
+
remaining_broken.append(entry)
|
|
2693
|
+
if repaired_compat:
|
|
2694
|
+
self.save_manifest(manifest)
|
|
2695
|
+
if not as_json:
|
|
2696
|
+
self.reindex()
|
|
2697
|
+
else:
|
|
2698
|
+
old_stdout = sys.stdout
|
|
2699
|
+
sys.stdout = io.StringIO()
|
|
2700
|
+
try:
|
|
2701
|
+
self.reindex()
|
|
2702
|
+
finally:
|
|
2703
|
+
sys.stdout = old_stdout
|
|
2704
|
+
else:
|
|
2705
|
+
remaining_broken = path_dependent_broken
|
|
2706
|
+
|
|
2707
|
+
remaining_broken_pub = [
|
|
2708
|
+
{"name": e["name"], "original_path": str(e["orig_path"]), "reasons": e["reasons"]}
|
|
2709
|
+
for e in remaining_broken
|
|
2710
|
+
]
|
|
2711
|
+
|
|
2712
|
+
if as_json:
|
|
2713
|
+
print(
|
|
2714
|
+
json.dumps(
|
|
2715
|
+
{
|
|
2716
|
+
"counts": {
|
|
2717
|
+
"disk": len(disk_skills),
|
|
2718
|
+
"manifest": len(manifest),
|
|
2719
|
+
"index": len(indexed_skills),
|
|
2720
|
+
},
|
|
2721
|
+
"issues": issues,
|
|
2722
|
+
"warnings": warnings,
|
|
2723
|
+
"integrity_repaired": integrity_repaired,
|
|
2724
|
+
"compat": {
|
|
2725
|
+
"path_dependent_broken": remaining_broken_pub,
|
|
2726
|
+
"runtime_in_place_active": runtime_in_place_active,
|
|
2727
|
+
"repaired": repaired_compat,
|
|
2728
|
+
"cross_skill_refs": cross_skill_refs,
|
|
2729
|
+
"oversized": oversized,
|
|
2730
|
+
"vaulted_guardrails": vaulted_guardrails,
|
|
2731
|
+
},
|
|
2732
|
+
"ok": (not issues) and (not remaining_broken_pub),
|
|
2733
|
+
},
|
|
2734
|
+
indent=2,
|
|
2735
|
+
)
|
|
2736
|
+
)
|
|
2737
|
+
return 0 if (not issues and not remaining_broken_pub) else 1
|
|
2738
|
+
|
|
2739
|
+
print("==================================================")
|
|
2740
|
+
print(" L2 COMPATIBILITY AUDIT SUMMARY")
|
|
2741
|
+
print("==================================================")
|
|
2742
|
+
print(f" * Path-Dependent Skills Missing Runtime-in-Place: {len(remaining_broken_pub)}")
|
|
2743
|
+
for e in remaining_broken_pub:
|
|
2744
|
+
print(f" [X] {e['name']} -> {e['original_path']} ({', '.join(e['reasons'][:3])})")
|
|
2745
|
+
|
|
2746
|
+
if repaired_compat:
|
|
2747
|
+
print(f" * Materialized Runtime-in-Place (--fix): {len(repaired_compat)}")
|
|
2748
|
+
for r in repaired_compat:
|
|
2749
|
+
print(f" [FIXED] {r['name']} -> {r['runtime_dir']} (companions restored without SKILL.md)")
|
|
2750
|
+
|
|
2751
|
+
print(f" * Runtime-in-Place Protected Skills: {len(runtime_in_place_active)}")
|
|
2752
|
+
for r in runtime_in_place_active[:10]:
|
|
2753
|
+
print(f" [OK] {r['name']} -> {r['runtime_dir']}")
|
|
2754
|
+
if len(runtime_in_place_active) > 10:
|
|
2755
|
+
print(f" ... (+{len(runtime_in_place_active) - 10} more)")
|
|
2756
|
+
|
|
2757
|
+
print(f" * Cross-Skill / Plugin References: {len(cross_skill_refs)}")
|
|
2758
|
+
for c in cross_skill_refs[:10]:
|
|
2759
|
+
print(f" [!] {c['name']}: {', '.join(c['refs'][:4])}")
|
|
2760
|
+
if len(cross_skill_refs) > 10:
|
|
2761
|
+
print(f" ... (+{len(cross_skill_refs) - 10} more)")
|
|
2762
|
+
|
|
2763
|
+
print(f" * Oversized SKILL.md (truncated on inline): {len(oversized)}")
|
|
2764
|
+
for o in sorted(oversized, key=lambda x: -x["bytes"])[:10]:
|
|
2765
|
+
print(f" [!] {o['name']}: {o['bytes']} bytes")
|
|
2766
|
+
if len(oversized) > 10:
|
|
2767
|
+
print(f" ... (+{len(oversized) - 10} more)")
|
|
2768
|
+
|
|
2769
|
+
print(f" * Vaulted Always-On / Guardrail Skills: {len(vaulted_guardrails)}")
|
|
2770
|
+
for g in vaulted_guardrails[:10]:
|
|
2771
|
+
print(f" [!] {g['name']}: {', '.join(g['signals'])}")
|
|
2772
|
+
if len(vaulted_guardrails) > 10:
|
|
2773
|
+
print(f" ... (+{len(vaulted_guardrails) - 10} more)")
|
|
2774
|
+
print("")
|
|
2775
|
+
|
|
2776
|
+
if remaining_broken_pub and not fix:
|
|
2777
|
+
print("Tip: Run with '--compat --fix' to materialize runtime-in-place companion files without L1 SKILL.md bloat.\n")
|
|
2778
|
+
|
|
2779
|
+
if issues or remaining_broken_pub:
|
|
2780
|
+
return 1
|
|
2781
|
+
print("[OK] L2 Compatibility Audit passed with no unresolved path-dependent skills.\n")
|
|
2346
2782
|
return 0
|
|
2347
2783
|
|
|
2348
2784
|
def search(self, query, category=None, limit=10, as_json=False):
|
|
@@ -2986,7 +3422,7 @@ class SkillVault:
|
|
|
2986
3422
|
plugin_meta = {
|
|
2987
3423
|
"name": "skill-vault",
|
|
2988
3424
|
"displayName": "Skill Vault",
|
|
2989
|
-
"version": "2.0
|
|
3425
|
+
"version": "2.1.0",
|
|
2990
3426
|
"description": "Automatic background skill router, cold-storage archive, and read-only JIT MCP server.",
|
|
2991
3427
|
"author": "jcorpac",
|
|
2992
3428
|
"license": "MIT",
|
|
@@ -3375,8 +3811,10 @@ def main():
|
|
|
3375
3811
|
p_idx = subparsers.add_parser("reindex", help="Rebuild INDEX.md, search_index.json, and sync manifest")
|
|
3376
3812
|
|
|
3377
3813
|
# Verify / Integrity Check
|
|
3378
|
-
p_ver = subparsers.add_parser("verify", help="Verify archive integrity
|
|
3814
|
+
p_ver = subparsers.add_parser("verify", help="Verify archive integrity and L2 compatibility")
|
|
3379
3815
|
p_ver.add_argument("--fix", action="store_true", help="Automatically repair any detected discrepancies")
|
|
3816
|
+
p_ver.add_argument("--compat", action="store_true", help="Audit L2 compatibility (path dependencies, cross-skill refs, oversized SKILL.md, guardrails)")
|
|
3817
|
+
p_ver.add_argument("--json", action="store_true", help="Output structured JSON")
|
|
3380
3818
|
|
|
3381
3819
|
# Search
|
|
3382
3820
|
p_srch = subparsers.add_parser("search", help="Search archived skills by keyword, intent, or domain")
|
|
@@ -3508,7 +3946,7 @@ def main():
|
|
|
3508
3946
|
elif args.command == "reindex":
|
|
3509
3947
|
mgr.reindex()
|
|
3510
3948
|
elif args.command == "verify":
|
|
3511
|
-
sys.exit(mgr.verify(fix=args.fix))
|
|
3949
|
+
sys.exit(mgr.verify(fix=args.fix, compat=args.compat, as_json=args.json))
|
|
3512
3950
|
elif args.command == "search":
|
|
3513
3951
|
mgr.search(query=args.query, category=args.category, limit=args.limit, as_json=args.json)
|
|
3514
3952
|
elif args.command == "route":
|