router.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/usr/bin/env bash
  2. #############################################################################
  3. # Context Manager Skill Router
  4. # Routes to context management operations with proper path resolution
  5. #############################################################################
  6. set -e
  7. # SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  8. # Show help
  9. show_help() {
  10. cat << 'HELP'
  11. 📚 Context Manager Skill
  12. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  13. Usage: router.sh [OPERATION] [OPTIONS]
  14. OPERATIONS:
  15. discover [target] Find context files by topic or path
  16. fetch [libraries] [topics] Fetch external documentation
  17. harvest [source] Extract context from summary files
  18. extract [file] [what] Extract specific information from context
  19. compress [target] [size] Compress large context files
  20. organize [target] Reorganize context by concern
  21. cleanup [target] [days] Remove stale or temporary files
  22. process [goal] [scope] Guided workflow for context processing
  23. help Show this help message
  24. EXAMPLES:
  25. ./router.sh discover authentication
  26. ./router.sh fetch "Drizzle ORM" "modular schemas"
  27. ./router.sh harvest ANALYSIS.md
  28. ./router.sh extract code-quality.md "naming conventions"
  29. ./router.sh compress .opencode/context/ 100KB
  30. ./router.sh organize .opencode/context/
  31. ./router.sh cleanup .tmp/ 7
  32. ./router.sh process "organize authentication context" .opencode/context/
  33. FEATURES:
  34. ✓ Discover context files efficiently
  35. ✓ Fetch external documentation
  36. ✓ Extract and harvest context
  37. ✓ Compress large files
  38. ✓ Organize by concern
  39. ✓ Clean up stale files
  40. ✓ Guided workflows
  41. For detailed documentation, see: .opencode/skills/context-manager/SKILL.md
  42. HELP
  43. }
  44. # If no arguments, show help
  45. if [ $# -eq 0 ]; then
  46. show_help
  47. exit 0
  48. fi
  49. # Handle help
  50. if [ "$1" = "help" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  51. show_help
  52. exit 0
  53. fi
  54. # Find project root
  55. find_project_root() {
  56. local dir
  57. dir="$(pwd)"
  58. while [ "$dir" != "/" ]; do
  59. if [ -d "$dir/.git" ] || [ -f "$dir/package.json" ]; then
  60. echo "$dir"
  61. return 0
  62. fi
  63. dir="$(dirname "$dir")"
  64. done
  65. pwd
  66. return 1
  67. }
  68. # PROJECT_ROOT="$(find_project_root)"
  69. # Route to appropriate operation
  70. OPERATION="$1"
  71. shift
  72. case "$OPERATION" in
  73. discover)
  74. echo "📍 DISCOVER: Finding context files..."
  75. echo "Target: $*"
  76. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  77. ;;
  78. fetch)
  79. echo "📥 FETCH: Retrieving external documentation..."
  80. echo "Libraries: $*"
  81. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  82. ;;
  83. harvest)
  84. echo "🌾 HARVEST: Extracting context from summaries..."
  85. echo "Source: $*"
  86. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  87. ;;
  88. extract)
  89. echo "🔍 EXTRACT: Pulling key information..."
  90. echo "Target: $*"
  91. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  92. ;;
  93. compress)
  94. echo "🗜️ COMPRESS: Reducing file sizes..."
  95. echo "Target: $*"
  96. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  97. ;;
  98. organize)
  99. echo "📂 ORGANIZE: Restructuring context..."
  100. echo "Target: $*"
  101. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  102. ;;
  103. cleanup)
  104. echo "🧹 CLEANUP: Removing stale files..."
  105. echo "Target: $*"
  106. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  107. ;;
  108. process)
  109. echo "⚙️ PROCESS: Guided workflow..."
  110. echo "Goal: $*"
  111. echo "See .opencode/skills/context-manager/SKILL.md for full documentation"
  112. ;;
  113. *)
  114. echo "❌ Unknown operation: $OPERATION"
  115. echo ""
  116. show_help
  117. exit 1
  118. ;;
  119. esac