-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsetup.py
More file actions
672 lines (612 loc) · 15.7 KB
/
setup.py
File metadata and controls
672 lines (612 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
import os
import shutil
import sys
import time
from pathlib import Path
# ==========================================
# 🎯 SkillPointer
# Infinite Context. Zero Token Tax.
# ==========================================
class Colors:
HEADER = "\033[95m"
BLUE = "\033[94m"
CYAN = "\033[96m"
GREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
# Global configuration state
CONFIG = {
"agent_name": "OpenCode",
"active_skills_dir": Path.home() / ".config" / "opencode" / "skills",
"hidden_library_dir": Path.home() / ".opencode-skill-libraries",
}
# Advanced Heuristic Engine for Universal Categorization
DOMAIN_HEURISTICS = {
"security": [
"attack",
"injection",
"vulnerability",
"xss",
"penetration",
"privilege",
"fuzzing",
"auth",
"jwt",
"oauth",
"bypass",
"malware",
"forensics",
"hacker",
"wireshark",
"nmap",
"security",
"exploit",
"encryption",
],
"code-review": [
"code-review",
"code review",
"codereview",
"requesting-code-review",
"code-review-excellence",
"pr-review",
"review-agent",
"reviewer",
"review-bot",
"static-analysis",
"quality-gate",
"sonarqube",
],
"git": [
"git",
"github",
"gitlab",
"pull-request",
"merge-request",
"commit",
"branch",
"rebase",
"cherry-pick",
"stash",
"tag",
"release",
"conventional-commits",
],
"ai-ml": [
"ai-",
"ml-",
"llm",
"agent",
"gpt",
"claude",
"gemini",
"openai",
"anthropic",
"prompt",
"rag",
"diffusion",
"huggingface",
"pytorch",
"tensorflow",
"comfy",
"flux",
"machine-learning",
"deep-learning",
"vision",
"nlp",
],
"web-dev": [
"angular",
"react",
"vue",
"tailwind",
"frontend",
"css",
"html",
"nextjs",
"svelte",
"astro",
"web",
"dom",
"ui-patterns",
"vercel",
"shopify",
"styles",
"sass",
"less",
"bootstrap",
],
"backend-dev": [
"api",
"nestjs",
"express",
"django",
"flask",
"fastapi",
"spring",
"laravel",
"node",
"graphql",
"rest",
"grpc",
"backend",
"server",
"microservice",
"go-",
"rust-",
],
"devops": [
"aws",
"azure",
"docker",
"kubernetes",
"ci-cd",
"terraform",
"ansible",
"github-actions",
"gitlab",
"jenkins",
"devops",
"cloud",
"linux",
"ubuntu",
"k8s",
"bash",
"deploy",
"nginx",
],
"database": [
"sql",
"mysql",
"postgres",
"mongo",
"redis",
"database",
"schema",
"prisma",
"orm",
"nosql",
"supabase",
"neon",
"db-",
"sqlite",
],
"design": [
"ui",
"ux",
"design",
"figma",
"avatar",
"background-removal",
"svg",
"animation",
"motion",
"framer",
"photoshop",
"illustrator",
"creative",
],
"automation": [
"automation",
"zapier",
"make",
"n8n",
"selenium",
"playwright",
"puppeteer",
"bot",
"workflow",
"scraper",
"cron",
],
"mobile": [
"ios",
"android",
"react-native",
"flutter",
"swift",
"kotlin",
"mobile",
"xcode",
"mobile-",
],
"game-dev": [
"game",
"unity",
"unreal",
"godot",
"phaser",
"3d",
"vr",
"ar",
"raylib",
"pygame",
],
"business": [
"business",
"founder",
"sales",
"marketing",
"seo",
"growth",
"product",
"agile",
"scrum",
"jira",
"b2b",
"crm",
],
"writing": [
"writing",
"copywriting",
"blog",
"documentation",
"readme",
"study",
"teardown",
"content",
"journalism",
],
"3d-graphics": [
"blender",
"threejs",
"webgl",
"rendering",
"3d-",
"mesh",
"texture",
"shader",
],
"aerospace": [
"satellite",
"orbit",
"space",
"aerodynamics",
"avionic",
"spacecraft",
],
"agents": [
"multi-agent",
"swarm",
"autonomous",
"orchestration",
"chain",
"autogen",
"crewai",
],
"animation": [
"gsap",
"lottie",
"keyframe",
"transition",
"tween",
"rigging",
],
"architecture": [
"pattern",
"clean-code",
"system-design",
"solid-",
"ddd",
"architect",
],
"biomedical": [
"dna",
"protein",
"medical",
"health",
"genomics",
"bioinfo",
"clinical",
],
"blockchain": [
"crypto",
"web3",
"solidity",
"smart-contract",
"ethereum",
"bitcoin",
"nft",
"staking",
],
"compliance": [
"gdpr",
"hipaa",
"soc2",
"audit",
"policy",
"legal",
"privacy",
],
"data-science": [
"pandas",
"numpy",
"matplotlib",
"scikit",
"jupyter",
"visualization",
"data-",
"etl",
],
"education": [
"learning",
"course",
"tutor",
"student",
"curriculum",
"teaching",
"university",
],
"finance": [
"trading",
"stock",
"portfolio",
"banking",
"ledger",
"investment",
"fintech",
],
"marketing": [
"ads",
"campaign",
"social-media",
"brand",
"analytics",
"funnel",
"email-marketing",
],
"mcp": [
"mcp-",
"model-context-protocol",
"server-",
"client-",
],
"media-production": [
"video",
"audio",
"podcast",
"editing",
"streaming",
"ffmpeg",
"obs",
],
"programming": [
"python",
"javascript",
"typescript",
"java",
"cpp",
"ruby",
"php",
"csharp",
"swift",
"kotlin",
"algorithm",
"data-structure",
],
"prompt-engineering": [
"system-prompt",
"few-shot",
"chain-of-thought",
"prompt-",
"meta-prompt",
],
"quantum": [
"qubit",
"qiskit",
"quantum-",
"superposition",
"entanglement",
],
"robotics": [
"ros",
"arduino",
"raspberry",
"hardware",
"sensor",
"firmware",
"robot",
],
"simulation": [
"physics",
"modeling",
"sim-",
"digital-twin",
"solver",
],
"testing": [
"test-",
"unit-test",
"jest",
"pytest",
"cypress",
"quality",
"qa-",
],
"tooling": [
"cli",
"prettier",
"eslint",
"bundler",
"npm",
"pip",
"extension",
"plugin",
],
}
def print_banner():
print(f"\n{Colors.BOLD}{Colors.CYAN} 🎯 SkillPointer {Colors.ENDC}")
print(f"{Colors.BLUE} Infinite Context. Zero Token Tax.\n{Colors.ENDC}")
def get_category_for_skill(skill_name: str) -> str:
# Detect exact search within quotes
exact_match = False
if skill_name.startswith('"') and skill_name.endswith('"'):
exact_match = True
name_lower = skill_name[1:-1].strip().lower().replace("_", "-").replace(" ", "-")
else:
name_lower = skill_name.lower().replace("_", "-")
has_pr_term = any(
term in name_lower for term in ("pr-review", "pull-request", "merge-request")
)
if "review" in name_lower and has_pr_term:
return "code-review"
for category, keywords in DOMAIN_HEURISTICS.items():
if exact_match:
# Exact match: the full term must match one of the keywords
if name_lower in keywords:
return category
else:
# Substring match: a known keyword is contained within the term
if any(kw in name_lower for kw in keywords):
return category
return "_uncategorized"
def setup_directories():
agent_name = CONFIG["agent_name"]
active_skills_dir = CONFIG["active_skills_dir"]
hidden_library_dir = CONFIG["hidden_library_dir"]
if not active_skills_dir.exists():
print(
f"{Colors.FAIL}✖ Error: {agent_name} skills directory not found at {active_skills_dir}{Colors.ENDC}"
)
print(
f"{Colors.WARNING}Please ensure {agent_name} is installed and configured.{Colors.ENDC}"
)
return False
hidden_library_dir.mkdir(parents=True, exist_ok=True)
return True
def migrate_skills():
active_skills_dir = CONFIG["active_skills_dir"]
hidden_library_dir = CONFIG["hidden_library_dir"]
print(f"{Colors.BOLD}📦 Phase 1: Analyzing and Migrating Skills...{Colors.ENDC}\n")
category_counts = {}
moved_count = 0
pointer_count = 0
for folder in list(active_skills_dir.iterdir()):
if not folder.is_dir():
continue
# Ignore existing pointers
if folder.name.endswith("-category-pointer"):
pointer_count += 1
continue
# Ignore empty folders
if not any(folder.iterdir()):
continue
category = get_category_for_skill(folder.name)
cat_dir = hidden_library_dir / category
cat_dir.mkdir(parents=True, exist_ok=True)
dest = cat_dir / folder.name
if dest.exists():
shutil.rmtree(dest)
shutil.move(str(folder), str(cat_dir))
category_counts[category] = category_counts.get(category, 0) + 1
moved_count += 1
# Visually print a few for effect, but not all to avoid spam
if moved_count <= 5 or moved_count % 50 == 0:
print(
f"{Colors.GREEN} ↳ Mapped '{folder.name}' ➔ {category}/{Colors.ENDC}"
)
if moved_count > 5:
print(
f"{Colors.GREEN} ...and {moved_count - 5} more skills safely migrated.{Colors.ENDC}"
)
print(
f"\n{Colors.BLUE}✔ Successfully migrated {moved_count} raw skills into the hidden vault at {hidden_library_dir}{Colors.ENDC}\n"
)
return category_counts
def generate_pointers(category_counts):
active_skills_dir = CONFIG["active_skills_dir"]
hidden_library_dir = CONFIG["hidden_library_dir"]
print(
f"{Colors.BOLD}⚡ Phase 2: Generating Dynamic Category Pointers...{Colors.ENDC}\n"
)
pointer_template = """---
name: {category_name}-category-pointer
description: Triggers when encountering any task related to {category_name}. This is a pointer to a library of specialized skills.
---
# {category_title} Capability Library 🎯
You do not have all {category_title} skills loaded immediately in your background context. Instead, you have access to a rich library of {count} highly-specialized skills on your local filesystem.
## Instructions
1. When you need to perform a task related to {category_name}, you MUST use your file reading tools (like `list_dir` and `view_file` or `read_file`) to browse the hidden library directory: `{library_path}`
2. Locate the specific Markdown files related to the exact sub-task you need.
3. Read the relevant Markdown file(s) into your context.
4. Follow the specific instructions and best practices found within those files to complete the user's request.
## Available Knowledge
This library contains {count} specialized skills covering various aspects of {category_title}.
**Hidden Library Path:** `{library_path}`
*Reminder: Do not guess best practices or blindly search GitHub. Always consult your local library files first.*
"""
created_pointers = 0
total_skills_indexed = 0
# We will scan the hidden_library_dir completely to ensure we include skills added previously or manually
for cat_dir in hidden_library_dir.iterdir():
if not cat_dir.is_dir():
continue
cat = cat_dir.name
# Count actual SKILL.md files inside
count = sum(1 for p in cat_dir.rglob("SKILL.md"))
if count == 0:
continue
total_skills_indexed += count
pointer_name = f"{cat}-category-pointer"
pointer_dir = active_skills_dir / pointer_name
pointer_dir.mkdir(parents=True, exist_ok=True)
cat_title = cat.replace("-", " ").title()
content = pointer_template.format(
category_name=cat,
category_title=cat_title,
count=count,
library_path=str(cat_dir.absolute()).replace(
"\\", "/"
), # Ensure cross-platform path format in markdown
)
with open(pointer_dir / "SKILL.md", "w", encoding="utf-8") as f:
f.write(content)
created_pointers += 1
print(
f"{Colors.CYAN} ⊕ Created {pointer_name} ➔ Indexes {count} skills.{Colors.ENDC}"
)
print(
f"\n{Colors.BLUE}✔ Successfully generated {created_pointers} ultra-lightweight pointers indexing {total_skills_indexed} total skills.{Colors.ENDC}"
)
def main():
import argparse
parser = argparse.ArgumentParser(description="SkillPointer Setup - Infinite Context. Zero Token Tax.")
parser.add_argument("--agent", choices=["opencode", "claude"], default="opencode",
help="Target AI agent (opencode or claude)")
args, unknown = parser.parse_known_args()
if args.agent == "claude":
CONFIG["agent_name"] = "Claude Code"
CONFIG["active_skills_dir"] = Path.home() / ".claude" / "skills"
CONFIG["hidden_library_dir"] = Path.home() / ".skillpointer-vault"
# Handle 'install' argument for compatibility with Install.bat/vbs
if unknown and unknown[0] == "install":
pass
print_banner()
if not setup_directories():
return
time.sleep(1)
category_counts = migrate_skills()
time.sleep(1)
generate_pointers(category_counts)
print(
f"\n{Colors.BOLD}{Colors.GREEN}=========================================={Colors.ENDC}"
)
print(
f"{Colors.BOLD}{Colors.GREEN}✨ Setup Complete! Your AI is now optimized. ✨{Colors.ENDC}"
)
print(
f"{Colors.BOLD}{Colors.GREEN}=========================================={Colors.ENDC}"
)
print(f"Your active skills directory now only contains optimized Pointers.")
print(
"When you prompt your AI, its context window will be completely empty, but it will dynamically fetch from your massive library exactly when needed."
)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"\n{Colors.WARNING}Setup cancelled by user.{Colors.ENDC}")
except Exception as e:
print(f"\n{Colors.FAIL}An unexpected error occurred: {e}{Colors.ENDC}")