This PR introduces utility scripts designed to resolve agent context window overloading. (#319)
* Implemented scripts and a Python utility to optimize agent skills, preventing context window overload, and document their usage. * feat(infra): add skills optimization scripts with bundle support and fixed archive logic * Removed Linux / Mac optimize-skills * Removed the Linux Section * feat(infra): final robust skill optimization suite with Library Mode * Removed * Updated the read me changed the optimisation to activation-skills * Updated ReadMe * docs: trim activation script README diff --------- Co-authored-by: sck_0 <samujackson1337@gmail.com>
This commit is contained in:
46
tools/scripts/get-bundle-skills.py
Normal file
46
tools/scripts/get-bundle-skills.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
def get_bundle_skills(bundle_queries):
|
||||
bundles_path = Path(__file__).parent.parent.parent / "docs" / "users" / "bundles.md"
|
||||
if not bundles_path.exists():
|
||||
print(f"Error: {bundles_path} not found", file=sys.stderr)
|
||||
return []
|
||||
|
||||
content = bundles_path.read_text(encoding="utf-8")
|
||||
|
||||
# Split by bundle headers
|
||||
sections = re.split(r'\n### ', content)
|
||||
|
||||
selected_skills = set()
|
||||
|
||||
for query in bundle_queries:
|
||||
query = query.lower().strip('"\'')
|
||||
found = False
|
||||
for section in sections:
|
||||
header_line = section.split('\n')[0].lower()
|
||||
if query in header_line:
|
||||
found = True
|
||||
# Extract skill names from bullet points: - [`skill-name`](../../skills/skill-name/)
|
||||
skills = re.findall(r'- \[`([^`]+)`\]', section)
|
||||
selected_skills.update(skills)
|
||||
|
||||
if not found:
|
||||
# If query not found in any header, check if it's a skill name itself
|
||||
# (Just in case the user passed a skill name instead of a bundle)
|
||||
selected_skills.add(query)
|
||||
|
||||
return sorted(list(selected_skills))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
# Default to Essentials if no query
|
||||
queries = ["essentials"]
|
||||
else:
|
||||
queries = sys.argv[1:]
|
||||
|
||||
skills = get_bundle_skills(queries)
|
||||
if skills:
|
||||
print(" ".join(skills))
|
||||
Reference in New Issue
Block a user