@jcorpac/skill-vault 1.6.0 → 1.7.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 CHANGED
@@ -104,6 +104,12 @@ python scripts/skill_vault.py verify
104
104
  | `skill-vault import <name> --vault-dir <path>` | Import from an explicit source vault (defaults to global archive or base). |
105
105
  | `skill-vault import <name> --force` | Overwrite existing project skill regardless of recency. |
106
106
  | `skill-vault import <name> --dry-run` | Preview what would be imported without copying files. |
107
+ | `skill-vault config --show` | Inspect effective core skills, stack fingerprints, and category rules. |
108
+ | `skill-vault config --init` | Write `skill_archive/vault_config.json` with universal defaults for customization. |
109
+ | `skill-vault config --add-core <name>` | Add a skill to protected Core Foundation Skills (or use `--remove-core`). |
110
+ | `skill-vault config --add-fingerprint "<Cat>" "<pat>"` | Add a workspace file/glob fingerprint to a skill category. |
111
+ | `skill-vault config --add-category-rule "<Cat>" "<kw>"` | Add a keyword rule for automatic skill categorization. |
112
+ | `skill-vault config --sync-prompt` | Dynamically update `SKILL.md`'s router description with your vault's categories. |
107
113
  | `skill-vault verify` | Audit bi-directional consistency across disk, manifest, and index. |
108
114
  | `skill-vault verify --fix` | Audit and automatically self-heal all detected discrepancies. |
109
115
 
@@ -116,6 +122,8 @@ python scripts/skill_vault.py verify
116
122
  3. **Zero Runtime Dependencies**: The core engine requires only Python 3 standard library (`os`, `sys`, `json`, `re`, `shutil`, `hashlib`, `argparse`, `pathlib`).
117
123
  4. **Self-Healing Integrity**: Detects orphaned folders, phantom manifest entries, broken markdown links, and duplicate aliases.
118
124
  5. **Recency & Version Prioritization**: Automatically protects newer versions when archiving, restoring, or optimizing by evaluating semantic version tags (`version:`) with filesystem timestamp (`mtime`) fallbacks. Use `--force` to override.
125
+ 6. **Universal Cross-Ecosystem Stack Detection**: Includes built-in workspace fingerprinting and category inference across Frontend, Backend, Cloud/DevOps, Databases, Mobile, AI/ML, Testing/Security, Data Engineering, and Science — fully extensible via `vault_config.json` and `SKILL.md` frontmatter (`core: true`, `category:`).
126
+ 7. **Dynamic Router Prompt Syncing**: `reindex` and `config --sync-prompt` automatically keep `skill-vault`'s `SKILL.md` frontmatter description synchronized with the exact skills and categories in the user's own vault.
119
127
 
120
128
  ---
121
129
 
package/SKILL.md CHANGED
@@ -1,17 +1,10 @@
1
1
  ---
2
2
  name: skill-vault
3
+ version: 1.7.0
3
4
  description: >-
4
- Universal agent-agnostic skill router and tiered storage manager for 210+ specialized domain skills in cold storage.
5
- ALWAYS use this skill whenever the task involves domains or tools not in active memory, including:
6
- (1) AlloyDB (Omni, replication, vector, tuning),
7
- (2) Cloud SQL (Postgres, MySQL, backup/DR, performance),
8
- (3) BigQuery & Data Warehouse (dbt, Dataform, optimization),
9
- (4) GCP & Data Engineering (Airflow/Composer, Spanner, Dataproc, GCS),
10
- (5) Gemini API & AI Agents (ADK, Live API, Omni Flash, evals),
11
- (6) Science & Biomedicine (AlphaFold, AlphaGenome, Foldseek, ChEMBL, PDB, PyMOL, PubMed, variant analysis),
12
- (7) Android Development, or
13
- (8) General Utilities.
14
- Search or restore skills on demand via 'python scripts/skill_vault.py search "<keyword>"', view 'skill_archive/INDEX.md', or run 'restore <name>'.
5
+ Universal agent-agnostic skill router, lifecycle manager, and tiered storage engine for AI coding agents.
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.
7
+ Search cold storage (L2) on demand via 'python scripts/skill_vault.py search "<keyword>"', view 'skill_archive/INDEX.md', or dynamically mount skills via 'restore', 'import', or 'optimize'.
15
8
  ---
16
9
 
17
10
  # Skill Vault: Universal Agent Skill Lifecycle & Storage Manager
@@ -137,7 +130,7 @@ python scripts/skill_vault.py optimize
137
130
  python scripts/skill_vault.py optimize --dry-run
138
131
 
139
132
  # Optimize for a specific workspace folder and protect custom skills
140
- python scripts/skill_vault.py optimize --workspace "C:\Projects\my-repo" --protect my-custom-skill
133
+ python scripts/skill_vault.py optimize --workspace "./my-repo" --protect my-custom-skill
141
134
  ```
142
135
 
143
136
  ### I. Recency & Version Prioritization Protocol
@@ -185,6 +178,32 @@ python scripts/skill_vault.py sync --dry-run
185
178
  python scripts/skill_vault.py sync --keep-active
186
179
  ```
187
180
 
181
+ ### L. Universal Stack Customization & Dynamic Router Sync (`config`)
182
+ Skill Vault supports cross-ecosystem workspace fingerprinting and auto-categorization out of the box (Frontend, Backend, Cloud/DevOps, Databases, Mobile, AI/ML, Testing/Security, Data Engineering, and Science), and can be customized per user or repository via `skill_archive/vault_config.json` or `SKILL.md` frontmatter tags:
183
+
184
+ ```bash
185
+ # Inspect active core skills, stack fingerprints, and category rules
186
+ python scripts/skill_vault.py config --show
187
+
188
+ # Initialize skill_archive/vault_config.json with universal defaults
189
+ python scripts/skill_vault.py config --init
190
+
191
+ # Protect or unprotect specific core foundation skills from auto-archiving/pruning
192
+ python scripts/skill_vault.py config --add-core <skill_name>
193
+ python scripts/skill_vault.py config --remove-core <skill_name>
194
+
195
+ # Add custom workspace file/glob fingerprints and category keyword rules
196
+ python scripts/skill_vault.py config --add-fingerprint "<Category>" "<pattern>"
197
+ python scripts/skill_vault.py config --add-category-rule "<Category>" "<keyword>"
198
+
199
+ # Dynamically update SKILL.md's router description with currently indexed categories
200
+ python scripts/skill_vault.py config --sync-prompt
201
+ ```
202
+
203
+ Any individual skill's `SKILL.md` frontmatter can also declare:
204
+ - `core: true` (or `pinned: true` / `always_active: true`) to automatically protect that skill during `sync` and `optimize`.
205
+ - `category: "<Category>"` to pin its vault category without needing `--category` flags.
206
+
188
207
  ---
189
208
 
190
209
  ## 3. Environment & OS Compatibility Guidelines
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcorpac/skill-vault",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Universal Agent Skill Router, Lifecycle Manager, and Tiered Storage Engine for AI Coding Agents.",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -26,6 +26,62 @@ DEFAULT_CORE_SKILLS = {
26
26
 
27
27
  # Workspace fingerprint signatures mapping to skill categories
28
28
  WORKSPACE_FINGERPRINTS = {
29
+ "Frontend & Web Development": [
30
+ "package.json",
31
+ "tsconfig.json",
32
+ "next.config.*",
33
+ "vite.config.*",
34
+ "angular.json",
35
+ "svelte.config.*",
36
+ "tailwind.config.*",
37
+ ],
38
+ "Backend & APIs": [
39
+ "pyproject.toml",
40
+ "requirements.txt",
41
+ "go.mod",
42
+ "Cargo.toml",
43
+ "pom.xml",
44
+ "Gemfile",
45
+ "composer.json",
46
+ "openapi.yaml",
47
+ "swagger.json",
48
+ ],
49
+ "Cloud & DevOps": [
50
+ "Dockerfile",
51
+ "docker-compose.yml",
52
+ "docker-compose.yaml",
53
+ "*.tf",
54
+ "Chart.yaml",
55
+ "Pulumi.yaml",
56
+ "serverless.yml",
57
+ ],
58
+ "Databases & Storage": [
59
+ "schema.prisma",
60
+ "drizzle.config.*",
61
+ "alembic.ini",
62
+ "flyway.conf",
63
+ "*.sql",
64
+ ],
65
+ "Mobile & Cross-Platform": [
66
+ "pubspec.yaml",
67
+ "Podfile",
68
+ "Package.swift",
69
+ "app.json",
70
+ "metro.config.js",
71
+ ],
72
+ "AI, LLM & Machine Learning": [
73
+ "*.ipynb",
74
+ "MLproject",
75
+ "conda.yaml",
76
+ "dvc.yaml",
77
+ ],
78
+ "Testing, QA & Security": [
79
+ "playwright.config.*",
80
+ "cypress.config.*",
81
+ "vitest.config.*",
82
+ "jest.config.*",
83
+ "pytest.ini",
84
+ ],
29
85
  "BigQuery & Data Warehouse": [
30
86
  "dbt_project.yml",
31
87
  "dataform.json",
@@ -67,6 +123,186 @@ WORKSPACE_FINGERPRINTS = {
67
123
  ],
68
124
  }
69
125
 
126
+ DEFAULT_WORKSPACE_FINGERPRINTS = WORKSPACE_FINGERPRINTS
127
+
128
+ # Default keyword rules for auto-categorizing skills across universal ecosystems
129
+ DEFAULT_CATEGORY_RULES = {
130
+ "Knowledge & Wiki Architecture": [
131
+ "egm-",
132
+ "wiki",
133
+ "documentation architecture",
134
+ ],
135
+ "Gemini API & AI Agents": [
136
+ "gemini",
137
+ "adk",
138
+ "live-api",
139
+ "live api",
140
+ "llm agent",
141
+ "vertex ai",
142
+ "vertex",
143
+ ],
144
+ "Android Development": [
145
+ "android",
146
+ "gradle",
147
+ "apk",
148
+ "adb",
149
+ "jetpack compose",
150
+ ],
151
+ "BigQuery & Data Warehouse": [
152
+ "bigquery",
153
+ "dbt",
154
+ "dataform",
155
+ "data warehouse",
156
+ "lakehouse",
157
+ ],
158
+ "AlloyDB": [
159
+ "alloydb",
160
+ "omni",
161
+ ],
162
+ "Databases & Storage": [
163
+ "prisma",
164
+ "drizzle",
165
+ "sqlalchemy",
166
+ "redis",
167
+ "mongodb",
168
+ "dynamodb",
169
+ "cassandra",
170
+ "clickhouse",
171
+ "supabase",
172
+ "sqlite",
173
+ "vector db",
174
+ "pinecone",
175
+ "qdrant",
176
+ ],
177
+ "Cloud SQL": [
178
+ "cloud sql",
179
+ "cloudsql",
180
+ "postgres",
181
+ "postgresql",
182
+ "mysql",
183
+ ],
184
+ "Science & Biomedicine": [
185
+ "protein",
186
+ "alphafold",
187
+ "pdb",
188
+ "dna",
189
+ "rna",
190
+ "chembl",
191
+ "bioinformatics",
192
+ "variant",
193
+ "genome",
194
+ "pymol",
195
+ "foldseek",
196
+ "pubmed",
197
+ ],
198
+ "GCP & Data Engineering": [
199
+ "gcp",
200
+ "airflow",
201
+ "composer",
202
+ "spanner",
203
+ "dataflow",
204
+ "dataproc",
205
+ "pubsub",
206
+ "cloud storage",
207
+ "cloud run",
208
+ ],
209
+ "Testing, QA & Security": [
210
+ "playwright",
211
+ "cypress",
212
+ "jest",
213
+ "vitest",
214
+ "pytest",
215
+ "selenium",
216
+ "e2e",
217
+ "unit test",
218
+ "tdd",
219
+ "owasp",
220
+ "pentest",
221
+ "vulnerability",
222
+ "security audit",
223
+ ],
224
+ "Mobile & Cross-Platform": [
225
+ "flutter",
226
+ "dart",
227
+ "swift",
228
+ "swiftui",
229
+ "ios",
230
+ "xcode",
231
+ "react native",
232
+ "expo",
233
+ "kotlin multiplatform",
234
+ ],
235
+ "Frontend & Web Development": [
236
+ "react",
237
+ "nextjs",
238
+ "next.js",
239
+ "vue",
240
+ "svelte",
241
+ "angular",
242
+ "tailwind",
243
+ "css",
244
+ "frontend",
245
+ "vite",
246
+ "webpack",
247
+ "dom",
248
+ "a11y",
249
+ "accessibility",
250
+ ],
251
+ "Cloud & DevOps": [
252
+ "aws",
253
+ "azure",
254
+ "kubernetes",
255
+ "k8s",
256
+ "helm",
257
+ "docker",
258
+ "terraform",
259
+ "pulumi",
260
+ "ansible",
261
+ "github actions",
262
+ "ci/cd",
263
+ "cloudflare",
264
+ "vercel",
265
+ "netlify",
266
+ "devops",
267
+ "prometheus",
268
+ "grafana",
269
+ ],
270
+ "AI, LLM & Machine Learning": [
271
+ "openai",
272
+ "anthropic",
273
+ "claude",
274
+ "langchain",
275
+ "llamaindex",
276
+ "huggingface",
277
+ "pytorch",
278
+ "tensorflow",
279
+ "rag",
280
+ "embeddings",
281
+ "fine-tuning",
282
+ "machine learning",
283
+ "deep learning",
284
+ ],
285
+ "Backend & APIs": [
286
+ "fastapi",
287
+ "flask",
288
+ "django",
289
+ "express",
290
+ "nestjs",
291
+ "graphql",
292
+ "rest api",
293
+ "grpc",
294
+ "golang",
295
+ "rust",
296
+ "spring boot",
297
+ "rails",
298
+ "microservice",
299
+ "backend",
300
+ "oauth",
301
+ "jwt",
302
+ "stripe",
303
+ ],
304
+ }
305
+
70
306
 
71
307
  def parse_version_tuple(ver_str):
72
308
  """Parse version string into a comparable numeric tuple, e.g. 'v20' -> (20,), '1.1.5' -> (1, 1, 5)."""
@@ -175,8 +411,103 @@ class SkillVault:
175
411
  self.archive_dir = self.base_dir / "skill_archive"
176
412
  self.manifest_file = self.archive_dir / "backup_manifest.json"
177
413
  self.index_file = self.archive_dir / "INDEX.md"
414
+ self.config_file = self.archive_dir / "vault_config.json"
178
415
  self.skills_dir = self.base_dir / "skills"
179
416
 
417
+ def _load_raw_config(self):
418
+ """Read raw vault_config.json without creating files or merging defaults."""
419
+ if self.config_file.exists():
420
+ try:
421
+ with open(self.config_file, "r", encoding="utf-8") as f:
422
+ data = json.load(f)
423
+ return data if isinstance(data, dict) else {}
424
+ except Exception as e:
425
+ print(f"[Warning] Failed to parse {self.config_file}: {e}")
426
+ return {}
427
+
428
+ def load_config(self):
429
+ """Load vault_config.json if present and merge with universal defaults."""
430
+ user_cfg = self._load_raw_config()
431
+
432
+ disabled_core = set(user_cfg.get("disabled_core_skills", []))
433
+ core_skills = (set(DEFAULT_CORE_SKILLS) | set(user_cfg.get("core_skills", []))) - disabled_core
434
+
435
+ merged_fp = {cat: list(pats) for cat, pats in WORKSPACE_FINGERPRINTS.items()}
436
+ for cat, pats in user_cfg.get("workspace_fingerprints", {}).items():
437
+ if cat in merged_fp:
438
+ merged_fp[cat] = list(dict.fromkeys(list(pats) + merged_fp[cat]))
439
+ else:
440
+ merged_fp[cat] = list(pats)
441
+
442
+ custom_rules = user_cfg.get("category_rules", {})
443
+ merged_rules = {}
444
+ # Evaluate non-default custom categories first so user overrides take precedence
445
+ for cat, kws in custom_rules.items():
446
+ if cat not in DEFAULT_CATEGORY_RULES:
447
+ merged_rules[cat] = list(kws)
448
+ for cat, kws in custom_rules.items():
449
+ if cat in DEFAULT_CATEGORY_RULES:
450
+ merged_rules[cat] = list(dict.fromkeys(list(kws) + list(DEFAULT_CATEGORY_RULES[cat])))
451
+ for cat, kws in DEFAULT_CATEGORY_RULES.items():
452
+ if cat not in merged_rules:
453
+ merged_rules[cat] = list(kws)
454
+
455
+ return {
456
+ "core_skills": sorted(core_skills),
457
+ "disabled_core_skills": sorted(disabled_core),
458
+ "workspace_fingerprints": merged_fp,
459
+ "category_rules": merged_rules,
460
+ }
461
+
462
+ def save_config(self, config_data):
463
+ """Persist configuration to vault_config.json."""
464
+ self.archive_dir.mkdir(parents=True, exist_ok=True)
465
+ with open(self.config_file, "w", encoding="utf-8") as f:
466
+ json.dump(config_data, f, indent=2, ensure_ascii=False)
467
+
468
+ def get_core_skills(self, extra_protected=None):
469
+ """Return effective set of protected core skill names."""
470
+ core_set = set(self.load_config()["core_skills"])
471
+ if extra_protected:
472
+ core_set.update(extra_protected)
473
+ return core_set
474
+
475
+ def parse_skill_frontmatter_field(self, skill_md_path, field_name):
476
+ """Extract a single scalar field from SKILL.md YAML frontmatter."""
477
+ skill_md_path = Path(skill_md_path)
478
+ if not skill_md_path.exists():
479
+ return None
480
+ try:
481
+ content = skill_md_path.read_text(encoding="utf-8", errors="ignore")
482
+ fm_match = re.search(r"^---\s*\n(.*?)\n---", content, re.DOTALL)
483
+ if fm_match:
484
+ pattern = rf"^{re.escape(field_name)}:\s*([^\n]+)"
485
+ match = re.search(pattern, fm_match.group(1), re.MULTILINE | re.IGNORECASE)
486
+ if match:
487
+ val = match.group(1).strip().strip("'\"")
488
+ return val if val else None
489
+ except Exception:
490
+ pass
491
+ return None
492
+
493
+ def is_core_skill_frontmatter(self, skill_md_path):
494
+ """Return True if SKILL.md frontmatter marks the skill as core/pinned/always_active."""
495
+ for field in ("core", "pinned", "always_active"):
496
+ val = self.parse_skill_frontmatter_field(skill_md_path, field)
497
+ if val and val.strip().lower() in {"true", "yes", "1"}:
498
+ return True
499
+ return False
500
+
501
+ def _keyword_matches(self, keyword, text, normalized_text):
502
+ """Match a category keyword against skill name/description text safely."""
503
+ kw = str(keyword).lower().strip()
504
+ if not kw:
505
+ return False
506
+ if kw.isalpha() and len(kw) <= 4:
507
+ pattern = rf"(?<![a-z]){re.escape(kw)}(?![a-z])"
508
+ return bool(re.search(pattern, text) or re.search(pattern, normalized_text))
509
+ return kw in text or kw in normalized_text
510
+
180
511
  def init(self):
181
512
  """Bootstrap standard directory structure for a new workspace or repository."""
182
513
  self.skills_dir.mkdir(parents=True, exist_ok=True)
@@ -402,8 +733,10 @@ class SkillVault:
402
733
  """Inspect workspace files and return matched skill categories."""
403
734
  target_ws = Path(workspace_path).resolve() if workspace_path else Path.cwd().resolve()
404
735
  matched = {}
736
+ config = self.load_config()
737
+ fingerprints = config["workspace_fingerprints"]
405
738
 
406
- for category, patterns in WORKSPACE_FINGERPRINTS.items():
739
+ for category, patterns in fingerprints.items():
407
740
  for pat in patterns:
408
741
  if "*" in pat:
409
742
  matches = list(target_ws.glob(pat)) + list(target_ws.glob(f"**/{pat}"))[:5]
@@ -415,6 +748,36 @@ class SkillVault:
415
748
  matched.setdefault(category, []).append(pat)
416
749
  break
417
750
 
751
+ # Inspect categories present in manifest for workspace filename/directory keyword matches
752
+ manifest = self.load_manifest()
753
+ manifest_categories = {m.get("category") for m in manifest if m.get("category")}
754
+ unmatched_cats = [c for c in sorted(manifest_categories) if c not in matched]
755
+ if unmatched_cats and target_ws.exists():
756
+ stop_words = {"and", "the", "skills", "general", "utility"}
757
+ ignored_dirs = {".git", "node_modules", "__pycache__", ".venv", "venv", ".tox", "dist", "build"}
758
+ ws_tokens = {}
759
+ for root, dirs, files in os.walk(target_ws):
760
+ dirs[:] = [d for d in dirs if d not in ignored_dirs]
761
+ rel_depth = len(Path(root).relative_to(target_ws).parts)
762
+ if rel_depth > 3:
763
+ dirs[:] = []
764
+ continue
765
+ for entry_name in dirs + files:
766
+ tokens = {t for t in re.split(r"[-_.\s]+", entry_name.lower()) if t}
767
+ for tok in tokens:
768
+ ws_tokens.setdefault(tok, entry_name)
769
+
770
+ for cat in unmatched_cats:
771
+ words = [
772
+ w.lower()
773
+ for w in re.findall(r"[a-zA-Z0-9]+", cat)
774
+ if len(w) > 2 and w.lower() not in stop_words
775
+ ]
776
+ for w in words:
777
+ if w in ws_tokens:
778
+ matched.setdefault(cat, []).append(ws_tokens[w])
779
+ break
780
+
418
781
  return matched
419
782
 
420
783
  def optimize(self, workspace_path=None, protected_skills=None, dry_run=False, force=False):
@@ -424,9 +787,7 @@ class SkillVault:
424
787
  prioritizing newer versions when versions overlap.
425
788
  """
426
789
  target_ws = Path(workspace_path).resolve() if workspace_path else Path.cwd().resolve()
427
- core_set = set(DEFAULT_CORE_SKILLS)
428
- if protected_skills:
429
- core_set.update(protected_skills)
790
+ core_set = self.get_core_skills(protected_skills)
430
791
 
431
792
  print("==================================================")
432
793
  print(" SKILL VAULT AUTO-OPTIMIZATION")
@@ -452,10 +813,15 @@ class SkillVault:
452
813
  to_keep = []
453
814
 
454
815
  for name, data in active_map.items():
816
+ skill_md_path = Path(data["path"]) / "SKILL.md"
455
817
  if name in core_set:
456
818
  to_keep.append((name, "Core Foundation Skill"))
819
+ elif self.is_core_skill_frontmatter(skill_md_path):
820
+ to_keep.append((name, "Core Foundation Skill (Pinned in Frontmatter)"))
457
821
  else:
458
- skill_cat = manifest_by_name.get(name, {}).get("category", "General & Utility Skills")
822
+ skill_cat = manifest_by_name.get(name, {}).get("category") or self.infer_category(
823
+ name, data["description"], skill_md_path
824
+ )
459
825
  if skill_cat in detected_categories:
460
826
  to_keep.append((name, f"Matched Stack ({skill_cat})"))
461
827
  else:
@@ -528,23 +894,38 @@ class SkillVault:
528
894
 
529
895
  # --- Sync & Ingestion Engine ---
530
896
 
531
- def infer_category(self, skill_name, skill_desc=""):
532
- """Infer an appropriate category for a new skill based on name and description keywords."""
897
+ def infer_category(self, skill_name, skill_desc="", skill_md_path=None):
898
+ """Infer an appropriate category for a skill via frontmatter, custom rules, or universal defaults."""
899
+ resolved_md = Path(skill_md_path) if skill_md_path else None
900
+ if resolved_md is None:
901
+ active_dir = self.find_active_skill(skill_name)
902
+ if active_dir:
903
+ resolved_md = active_dir / "SKILL.md"
904
+
905
+ if resolved_md is not None:
906
+ explicit_cat = self.parse_skill_frontmatter_field(resolved_md, "category")
907
+ if explicit_cat:
908
+ return explicit_cat
909
+
910
+ if skill_name in self.get_core_skills() or skill_name in [
911
+ "gmail",
912
+ "gcalendar",
913
+ "gslides",
914
+ "gdocs",
915
+ "gdrive",
916
+ "gsheets",
917
+ ]:
918
+ return "General & Utility Skills"
919
+
920
+ rules = self.load_config()["category_rules"]
533
921
  text = f"{skill_name} {skill_desc}".lower()
534
- if any(k in text for k in ["gemini", "adk", "live api", "llm agent", "vertex ai"]):
535
- return "Gemini API & AI Agents"
536
- if any(k in text for k in ["android", "gradle", "apk", "adb"]):
537
- return "Android Development"
538
- if any(k in text for k in ["bigquery", "dbt", "dataform", "data warehouse", "lakehouse"]):
539
- return "BigQuery & Data Warehouse"
540
- if any(k in text for k in ["alloydb", "omni"]):
541
- return "AlloyDB"
542
- if any(k in text for k in ["cloud sql", "postgres", "mysql"]):
543
- return "Cloud SQL"
544
- if any(k in text for k in ["protein", "alphafold", "pdb", "dna", "rna", "chembl", "bioinformatics", "variant", "genome", "pymol"]):
545
- return "Science & Biomedicine"
546
- if any(k in text for k in ["gcp", "airflow", "composer", "spanner", "dataflow", "dataproc", "pubsub", "cloud storage"]):
547
- return "GCP & Data Engineering"
922
+ normalized_text = re.sub(r"[-_]+", " ", text)
923
+
924
+ for cat, keywords in rules.items():
925
+ for kw in keywords:
926
+ if self._keyword_matches(kw, text, normalized_text):
927
+ return cat
928
+
548
929
  return "General & Utility Skills"
549
930
 
550
931
  def sync(self, dry_run=False, keep_active=False, force=False, protect_skills=None):
@@ -556,9 +937,7 @@ class SkillVault:
556
937
  print(f" Vault Store: {self.archive_dir}")
557
938
  print("==================================================\n")
558
939
 
559
- core_set = set(DEFAULT_CORE_SKILLS)
560
- if protect_skills:
561
- core_set.update(protect_skills)
940
+ core_set = self.get_core_skills(protect_skills)
562
941
 
563
942
  active_skills = self.get_active_skills()
564
943
  manifest = self.load_manifest()
@@ -571,8 +950,13 @@ class SkillVault:
571
950
  retained_core = []
572
951
 
573
952
  for name, data in sorted(active_skills.items()):
953
+ if name == "skill-vault":
954
+ retained_core.append(name)
955
+ continue
956
+
574
957
  active_path = Path(data["path"])
575
- is_core = name in core_set
958
+ skill_md_path = active_path / "SKILL.md"
959
+ is_core = (name in core_set) or self.is_core_skill_frontmatter(skill_md_path)
576
960
 
577
961
  if name in manifest_map:
578
962
  item = manifest_map[name]
@@ -582,11 +966,17 @@ class SkillVault:
582
966
 
583
967
  recency = compare_skill_recency(active_path, archived_path)
584
968
  if recency > 0 or force:
585
- to_ingest_update.append((name, data, item.get("category") or self.infer_category(name, data["description"])))
969
+ to_ingest_update.append(
970
+ (
971
+ name,
972
+ data,
973
+ item.get("category") or self.infer_category(name, data["description"], skill_md_path),
974
+ )
975
+ )
586
976
  else:
587
977
  in_sync.append(name)
588
978
  else:
589
- assigned_cat = self.infer_category(name, data["description"])
979
+ assigned_cat = self.infer_category(name, data["description"], skill_md_path)
590
980
  to_ingest_new.append((name, data, assigned_cat))
591
981
 
592
982
  if is_core:
@@ -617,7 +1007,10 @@ class SkillVault:
617
1007
  total_ingested = 0
618
1008
  items_to_write = to_ingest_new + to_ingest_update
619
1009
  for name, data, cat in items_to_write:
620
- active_path = Path(data["path"])
1010
+ active_path = Path(data["path"]).resolve()
1011
+ if self.archive_dir in active_path.parents or active_path == self.base_dir:
1012
+ continue
1013
+
621
1014
  if name in manifest_map and manifest_map[name].get("archived_path"):
622
1015
  dest = self.resolve_portable_path(manifest_map[name]["archived_path"])
623
1016
  else:
@@ -798,7 +1191,12 @@ class SkillVault:
798
1191
  shutil.copytree(active_path, dest_dir)
799
1192
 
800
1193
  existing_cat = manifest_map.get(skill_name, {}).get("category")
801
- assigned_cat = category_name or existing_cat or "General & Utility Skills"
1194
+ inferred_cat = self.infer_category(
1195
+ skill_name,
1196
+ self.parse_skill_description(active_path / "SKILL.md"),
1197
+ active_path / "SKILL.md",
1198
+ )
1199
+ assigned_cat = category_name or existing_cat or inferred_cat
802
1200
 
803
1201
  manifest_map[skill_name] = {
804
1202
  "name": skill_name,
@@ -938,8 +1336,224 @@ class SkillVault:
938
1336
  f.write("\n".join(lines).strip() + "\n")
939
1337
 
940
1338
  self.save_manifest(list(manifest_by_folder.values()))
1339
+ updated_routers = self.sync_router_md()
1340
+ for r_path in updated_routers:
1341
+ print(f"[Router Synced] Updated SKILL.md frontmatter: {r_path}")
941
1342
  print(f"[Reindexed] {total_count} skills across {len(categories)} categories (Base: {self.base_dir}).")
942
1343
 
1344
+ def build_router_description(self):
1345
+ """Build a dynamic SKILL.md router description from the current archive manifest."""
1346
+ manifest = self.load_manifest()
1347
+ if not manifest:
1348
+ return (
1349
+ "Universal agent-agnostic skill router, lifecycle manager, and tiered storage engine for AI coding agents.\n"
1350
+ " 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.\n"
1351
+ " Search cold storage (L2) on demand via 'python scripts/skill_vault.py search \"<keyword>\"', view 'skill_archive/INDEX.md', or dynamically mount skills via 'restore', 'import', or 'optimize'."
1352
+ )
1353
+
1354
+ grouped = {}
1355
+ for item in manifest:
1356
+ cat = item.get("category") or "General & Utility Skills"
1357
+ grouped.setdefault(cat, []).append(item["name"])
1358
+
1359
+ sorted_cats = sorted(
1360
+ grouped.keys(),
1361
+ key=lambda c: (c == "General & Utility Skills", c.lower()),
1362
+ )
1363
+ cat_entries = []
1364
+ for idx, cat in enumerate(sorted_cats, start=1):
1365
+ samples = ", ".join(sorted(grouped[cat], key=str.lower)[:4])
1366
+ cat_entries.append(f"({idx}) {cat} ({samples})")
1367
+ formatted_categories = ",\n ".join(cat_entries)
1368
+
1369
+ return (
1370
+ f"Universal agent-agnostic skill router and tiered storage manager for {len(manifest)} specialized domain skill(s) in cold storage.\n"
1371
+ f" ALWAYS use this skill whenever the task involves domains or tools not in active memory, including:\n"
1372
+ f" {formatted_categories}.\n"
1373
+ f" Search or restore skills on demand via 'python scripts/skill_vault.py search \"<keyword>\"', view 'skill_archive/INDEX.md', or run 'restore <name>'."
1374
+ )
1375
+
1376
+ def _get_router_skill_md_candidates(self):
1377
+ """Locate candidate SKILL.md files belonging to skill-vault within base_dir."""
1378
+ raw_candidates = [
1379
+ self.skills_dir / "skill-vault" / "SKILL.md",
1380
+ self.base_dir / ".agents" / "skills" / "skill-vault" / "SKILL.md",
1381
+ self.base_dir / ".claude" / "skills" / "skill-vault" / "SKILL.md",
1382
+ ]
1383
+ if self.archive_dir.exists():
1384
+ raw_candidates.append(self.base_dir / "SKILL.md")
1385
+
1386
+ seen = set()
1387
+ candidates = []
1388
+ for cand in raw_candidates:
1389
+ resolved = cand.resolve()
1390
+ if resolved not in seen:
1391
+ seen.add(resolved)
1392
+ candidates.append(cand)
1393
+ return candidates
1394
+
1395
+ def sync_router_md(self, target_skill_md=None, force=False):
1396
+ """Synchronize skill-vault's SKILL.md frontmatter description with the active vault categories."""
1397
+ candidates = [Path(target_skill_md)] if target_skill_md else self._get_router_skill_md_candidates()
1398
+ new_desc = self.build_router_description()
1399
+ new_desc_block = f"description: >-\n {new_desc}"
1400
+ desc_pattern = re.compile(
1401
+ r"^description:\s*(?:>[-+]?|\|[-+]?)?\s*\n?.*?(?=\n[a-zA-Z0-9_-]+:|\Z)",
1402
+ re.DOTALL | re.MULTILINE,
1403
+ )
1404
+
1405
+ updated = []
1406
+ for cand in candidates:
1407
+ if not cand.exists() or self.parse_skill_name(cand) != "skill-vault":
1408
+ continue
1409
+
1410
+ current_desc = self.parse_skill_description(cand)
1411
+ if not force and "Universal agent-agnostic skill router" not in current_desc:
1412
+ continue
1413
+
1414
+ content = cand.read_text(encoding="utf-8", errors="replace")
1415
+ fm_match = re.match(r"^(---\s*\n)(.*?)(\n---(?:\s*\n|\s*\Z))", content, re.DOTALL)
1416
+ if not fm_match:
1417
+ continue
1418
+
1419
+ fm_text = fm_match.group(2)
1420
+ if desc_pattern.search(fm_text):
1421
+ new_fm = desc_pattern.sub(lambda _: new_desc_block, fm_text, count=1)
1422
+ else:
1423
+ new_fm = fm_text.rstrip() + "\n" + new_desc_block
1424
+
1425
+ new_content = fm_match.group(1) + new_fm + fm_match.group(3) + content[fm_match.end():]
1426
+ if new_content != content:
1427
+ cand.write_text(new_content, encoding="utf-8")
1428
+ updated.append(cand)
1429
+
1430
+ return updated
1431
+
1432
+ def manage_config(
1433
+ self,
1434
+ show=False,
1435
+ init_config=False,
1436
+ add_core=None,
1437
+ remove_core=None,
1438
+ add_fingerprint=None,
1439
+ add_category_rule=None,
1440
+ sync_prompt=False,
1441
+ ):
1442
+ """Inspect or update vault_config.json and dynamically synchronize the router prompt."""
1443
+ def _normalize_pairs(pairs):
1444
+ if not pairs:
1445
+ return []
1446
+ if len(pairs) == 2 and isinstance(pairs[0], str) and isinstance(pairs[1], str):
1447
+ return [pairs]
1448
+ return pairs
1449
+
1450
+ fp_pairs = _normalize_pairs(add_fingerprint)
1451
+ rule_pairs = _normalize_pairs(add_category_rule)
1452
+ mutating = bool(init_config or add_core or remove_core or fp_pairs or rule_pairs)
1453
+
1454
+ if init_config:
1455
+ effective = self.load_config()
1456
+ self.save_config(effective)
1457
+ print(f"[Config Initialized] Wrote vault configuration to: {self.config_file}")
1458
+
1459
+ if add_core or remove_core or fp_pairs or rule_pairs:
1460
+ raw_cfg = self._load_raw_config()
1461
+
1462
+ if add_core:
1463
+ core_list = list(raw_cfg.get("core_skills", []))
1464
+ disabled_list = list(raw_cfg.get("disabled_core_skills", []))
1465
+ for skill in add_core:
1466
+ s = skill.strip()
1467
+ if not s:
1468
+ continue
1469
+ if s in disabled_list:
1470
+ disabled_list.remove(s)
1471
+ if s not in core_list and s not in DEFAULT_CORE_SKILLS:
1472
+ core_list.append(s)
1473
+ elif s not in core_list and self.config_file.exists():
1474
+ core_list.append(s)
1475
+ raw_cfg["core_skills"] = core_list
1476
+ if disabled_list or "disabled_core_skills" in raw_cfg:
1477
+ raw_cfg["disabled_core_skills"] = disabled_list
1478
+ print(f"[Config Updated] Added core skill(s): {', '.join(add_core)}")
1479
+
1480
+ if remove_core:
1481
+ core_list = list(raw_cfg.get("core_skills", []))
1482
+ disabled_list = list(raw_cfg.get("disabled_core_skills", []))
1483
+ for skill in remove_core:
1484
+ s = skill.strip()
1485
+ if not s:
1486
+ continue
1487
+ if s in core_list:
1488
+ core_list.remove(s)
1489
+ if s in DEFAULT_CORE_SKILLS and s not in disabled_list:
1490
+ disabled_list.append(s)
1491
+ raw_cfg["core_skills"] = core_list
1492
+ raw_cfg["disabled_core_skills"] = disabled_list
1493
+ print(f"[Config Updated] Removed core skill(s): {', '.join(remove_core)}")
1494
+
1495
+ if fp_pairs:
1496
+ fp_map = dict(raw_cfg.get("workspace_fingerprints", {}))
1497
+ for cat, pat in fp_pairs:
1498
+ c = cat.strip()
1499
+ p = pat.strip()
1500
+ if not c or not p:
1501
+ continue
1502
+ pats = list(fp_map.get(c, []))
1503
+ if p not in pats:
1504
+ pats.append(p)
1505
+ fp_map[c] = pats
1506
+ print(f"[Config Updated] Added workspace fingerprint: [{c}] -> '{p}'")
1507
+ raw_cfg["workspace_fingerprints"] = fp_map
1508
+
1509
+ if rule_pairs:
1510
+ rule_map = dict(raw_cfg.get("category_rules", {}))
1511
+ for cat, kw in rule_pairs:
1512
+ c = cat.strip()
1513
+ k = kw.strip()
1514
+ if not c or not k:
1515
+ continue
1516
+ kws = list(rule_map.get(c, []))
1517
+ if k not in kws:
1518
+ kws.append(k)
1519
+ # Place updated custom category first so overrides take precedence
1520
+ rule_map = {c: kws, **{existing_c: existing_kws for existing_c, existing_kws in rule_map.items() if existing_c != c}}
1521
+ print(f"[Config Updated] Added category rule: [{c}] <- '{k}'")
1522
+ raw_cfg["category_rules"] = rule_map
1523
+
1524
+ self.save_config(raw_cfg)
1525
+
1526
+ if sync_prompt:
1527
+ updated = self.sync_router_md(force=True)
1528
+ if updated:
1529
+ for p in updated:
1530
+ print(f"[Router Synced] Updated SKILL.md frontmatter: {p}")
1531
+ else:
1532
+ print("[Router Sync] No matching skill-vault SKILL.md found to update.")
1533
+
1534
+ if show or (not mutating and not sync_prompt):
1535
+ effective = self.load_config()
1536
+ config_status = "Custom (vault_config.json present)" if self.config_file.exists() else "Built-in Universal Defaults (no vault_config.json)"
1537
+ router_cands = [str(p) for p in self._get_router_skill_md_candidates() if p.exists()]
1538
+ print("==================================================")
1539
+ print(" SKILL VAULT CONFIGURATION")
1540
+ print(f" Base Directory: {self.base_dir}")
1541
+ print(f" Config File: {self.config_file}")
1542
+ print(f" Mode: {config_status}")
1543
+ print("==================================================\n")
1544
+ print(f"Protected Core Skills ({len(effective['core_skills'])}):")
1545
+ print(f" {', '.join(effective['core_skills'])}\n")
1546
+ print(f"Workspace Fingerprint Categories ({len(effective['workspace_fingerprints'])}):")
1547
+ for cat, pats in effective["workspace_fingerprints"].items():
1548
+ print(f" * {cat}: {len(pats)} pattern(s)")
1549
+ print(f"\nCategory Inference Rules ({len(effective['category_rules'])}):")
1550
+ for cat, kws in effective["category_rules"].items():
1551
+ print(f" * {cat}: {len(kws)} keyword(s)")
1552
+ print(f"\nRouter SKILL.md Candidates Found: {len(router_cands)}")
1553
+ for rc in router_cands:
1554
+ print(f" * {rc}")
1555
+ print("")
1556
+
943
1557
  def verify(self, fix=False):
944
1558
  """Perform a comprehensive bi-directional integrity check across Disk, Manifest, and INDEX.md."""
945
1559
  print("==================================================")
@@ -1369,6 +1983,16 @@ def main():
1369
1983
  p_imp.add_argument("--force", action="store_true", help="Overwrite existing skill in project regardless of recency")
1370
1984
  p_imp.add_argument("--dry-run", action="store_true", help="Preview skills that would be imported without copying")
1371
1985
 
1986
+ # Config
1987
+ p_cfg = subparsers.add_parser("config", help="Inspect or customize vault_config.json and sync SKILL.md router prompt")
1988
+ p_cfg.add_argument("--show", action="store_true", help="Show active configuration and defaults")
1989
+ p_cfg.add_argument("--init", action="store_true", dest="init_config", help="Write current configuration defaults to vault_config.json")
1990
+ p_cfg.add_argument("--add-core", nargs="+", metavar="SKILL", help="Add one or more skills to protected core skills")
1991
+ p_cfg.add_argument("--remove-core", nargs="+", metavar="SKILL", help="Remove one or more skills from protected core skills")
1992
+ p_cfg.add_argument("--add-fingerprint", nargs=2, action="append", metavar=("CATEGORY", "PATTERN"), help="Add a workspace file/glob fingerprint for a category")
1993
+ p_cfg.add_argument("--add-category-rule", nargs=2, action="append", metavar=("CATEGORY", "KEYWORD"), help="Add an inference keyword rule for a category")
1994
+ p_cfg.add_argument("--sync-prompt", action="store_true", help="Synchronize SKILL.md router description with archived categories")
1995
+
1372
1996
  args = parser.parse_args()
1373
1997
  mgr = SkillVault(base_dir=args.base_dir)
1374
1998
 
@@ -1427,6 +2051,16 @@ def main():
1427
2051
  dry_run=args.dry_run,
1428
2052
  )
1429
2053
  )
2054
+ elif args.command == "config":
2055
+ mgr.manage_config(
2056
+ show=args.show,
2057
+ init_config=args.init_config,
2058
+ add_core=args.add_core,
2059
+ remove_core=args.remove_core,
2060
+ add_fingerprint=args.add_fingerprint,
2061
+ add_category_rule=args.add_category_rule,
2062
+ sync_prompt=args.sync_prompt,
2063
+ )
1430
2064
 
1431
2065
 
1432
2066
  if __name__ == "__main__":