router.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env bash
  2. #############################################################################
  3. # Task Management Skill Router
  4. # Routes to task-cli.ts with proper path resolution and command handling
  5. #############################################################################
  6. set -e
  7. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  8. CLI_SCRIPT="$SCRIPT_DIR/scripts/task-cli.ts"
  9. MIGRATE_SCRIPT="$SCRIPT_DIR/scripts/migrate-schema.ts"
  10. # Show help
  11. show_help() {
  12. cat << 'HELP'
  13. 📋 Task Management Skill
  14. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  15. Usage: router.sh [COMMAND] [OPTIONS]
  16. COMMANDS:
  17. status [feature] Show task status summary
  18. next [feature] Show next eligible tasks
  19. parallel [feature] Show parallelizable tasks
  20. deps <feature> <seq> Show dependency tree
  21. blocked [feature] Show blocked tasks
  22. complete <feature> <seq> "msg" Mark subtask complete
  23. validate [feature] Validate JSON files
  24. context <feature> Show bounded context breakdown
  25. contracts <feature> Show contract dependencies
  26. migrate <feature> [options] Migrate to enhanced schema
  27. help Show this help message
  28. MIGRATION OPTIONS:
  29. --dry-run Preview migration changes
  30. --lines-only Add only line-number precision
  31. EXAMPLES:
  32. ./router.sh status
  33. ./router.sh status my-feature
  34. ./router.sh next
  35. ./router.sh deps my-feature 05
  36. ./router.sh complete my-feature 05 "Implemented auth module"
  37. ./router.sh validate
  38. ./router.sh context my-feature
  39. ./router.sh contracts my-feature
  40. ./router.sh migrate my-feature
  41. ./router.sh migrate my-feature --dry-run
  42. FEATURES:
  43. ✓ Track progress across all features
  44. ✓ Find next eligible tasks (dependencies satisfied)
  45. ✓ Identify blocked tasks
  46. ✓ Mark subtasks complete with summaries
  47. ✓ Validate task integrity
  48. ✓ Show bounded context breakdown
  49. ✓ Show contract dependencies
  50. ✓ Migrate to enhanced schema
  51. For more info, see: .opencode/skills/task-management/SKILL.md
  52. HELP
  53. }
  54. # Check if CLI script exists
  55. if [ ! -f "$CLI_SCRIPT" ]; then
  56. echo "❌ Error: task-cli.ts not found at $CLI_SCRIPT"
  57. exit 1
  58. fi
  59. # Find project root
  60. find_project_root() {
  61. local dir
  62. dir="$(pwd)"
  63. while [ "$dir" != "/" ]; do
  64. if [ -d "$dir/.git" ] || [ -f "$dir/package.json" ]; then
  65. echo "$dir"
  66. return 0
  67. fi
  68. dir="$(dirname "$dir")"
  69. done
  70. pwd
  71. return 1
  72. }
  73. # Handle help
  74. if [ "$1" = "help" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  75. show_help
  76. exit 0
  77. fi
  78. # If no arguments, show help
  79. if [ $# -eq 0 ]; then
  80. show_help
  81. exit 0
  82. fi
  83. PROJECT_ROOT="$(find_project_root)"
  84. # Route commands
  85. case "$1" in
  86. migrate)
  87. cd "$PROJECT_ROOT" && npx ts-node "$MIGRATE_SCRIPT" "$@"
  88. ;;
  89. *)
  90. # Run the task CLI with all arguments
  91. cd "$PROJECT_ROOT" && npx ts-node "$CLI_SCRIPT" "$@"
  92. ;;
  93. esac