update-chattolib.skill 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ## @id update-chattolib
  2. ## @name Update Chattolib
  3. ## @description Performs a full vendor refresh of chattolib: downloads the newest (or specified) version, refreshes vendor/, updates docs, and verifies.
  4. ## @usage update-chattolib [SPEC]
  5. ## e.g.: `update-chattolib "chattolib[realtime]==0.5.0b4"`
  6. ## `update-chattolib` (uses CHATTOLIB_SPEC from vendor_chattolib.sh)
  7. ##
  8. ## This skill wraps the steps from vendor_chattolib.sh + AGENTS.md
  9. ## so that no vendor files are ever edited manually.
  10. # --- Configuration ---
  11. # PLUGIN_DIR is the project root (set by opencode/Paseo)
  12. PLUGIN_DIR="${PROJECT_DIR:-.}"
  13. SPEC="${1:-}"
  14. # --- Execution ---
  15. # 1. Determine the SPEC value
  16. if [ -z "$SPEC" ]; then
  17. SPEC=$(grep 'CHATTOLIB_SPEC=' "$PLUGIN_DIR/vendor_chattolib.sh" | head -1 | sed 's/.*CHATTOLIB_SPEC="\([^"]*\)".*/\1/')
  18. echo "🔍 No SPEC given — using: $SPEC"
  19. else
  20. echo "🔧 Using specified SPEC: $SPEC"
  21. fi
  22. # 2. Determine the new version number (for docs)
  23. VERSION=$(echo "$SPEC" | sed -n 's/.*==\([0-9][^ ]*\).*/\1/p' || true)
  24. if [ -z "$VERSION" ]; then
  25. VERSION=$(echo "$SPEC" | sed -n 's/.*>= \([0-9][^ ]*\).*/\1/p' || true)
  26. if [ -z "$VERSION" ]; then
  27. VERSION="latest"
  28. fi
  29. fi
  30. echo "📦 New chattolib version: $VERSION"
  31. # 3. Run the vendor refresh
  32. echo "🔄 Starting vendor refresh..."
  33. cd "$PLUGIN_DIR"
  34. if [ -n "$SPEC" ]; then
  35. CHATTOLIB_SPEC="$SPEC" ./vendor_chattolib.sh
  36. else
  37. ./vendor_chattolib.sh
  38. fi
  39. # 4. Update docs (version in AGENTS.md + README.md)
  40. echo "📝 Updating version in docs..."
  41. # AGENTS.md
  42. OLD_VER=$(grep -o '0\.5\.0[^ ]*\.post[0-9]' "$PLUGIN_DIR/AGENTS.md" | head -1)
  43. if [ -n "$OLD_VER" ]; then
  44. sed -i "s/chattolib\[realtime\] $OLD_VER/chattolib[realtime] $VERSION/g" "$PLUGIN_DIR/AGENTS.md"
  45. echo " AGENTS.md: $OLD_VER → $VERSION"
  46. fi
  47. # README.md
  48. OLD_VER=$(grep -o '0\.5\.0[^ ]*\.post[0-9]' "$PLUGIN_DIR/README.md" | head -1)
  49. if [ -n "$OLD_VER" ]; then
  50. sed -i "s/chattolib\[realtime\] $OLD_VER/chattolib[realtime] $VERSION/g" "$PLUGIN_DIR/README.md"
  51. echo " README.md: $OLD_VER → $VERSION"
  52. fi
  53. # 5. Check lint + typecheck
  54. echo "🔍 Lint & typecheck..."
  55. cd "$PLUGIN_DIR"
  56. uv run ruff check . 2>&1 | tail -1
  57. uv run ruff format . 2>&1 | tail -1
  58. uv run basedpyright 2>&1 | tail -1
  59. # 6. Run tests (requires hermes-agent PYTHONPATH)
  60. HERMES_PATH="$HERMES_AGENT_PATH"
  61. if [ -z "$HERMES_PATH" ]; then
  62. for d in ../hermes-agent ../../hermes-agent hermes-agent; do
  63. if [ -d "$d/gateway" ]; then
  64. HERMES_PATH="$d"
  65. break
  66. fi
  67. done
  68. fi
  69. if [ -d "$HERMES_PATH/gateway" ]; then
  70. echo "🧪 Running tests..."
  71. PYTHONPATH="$HERMES_PATH" uv run --with pyyaml pytest -x -q 2>&1 | tail -3
  72. else
  73. echo " ⚠️ hermes-agent not found at $HERMES_PATH — skipping tests"
  74. fi
  75. # 7. Commit note
  76. echo "✅ Done! Version is $VERSION."
  77. echo "💡 Now run 'git diff vendor_chattolib.sh' to update the SPEC floor in vendor_chattolib.sh if needed."