mirror of
https://github.com/hanzoskill/auto-updater.git
synced 2026-10-30 21:10:06 +00:00
3.5 KiB
3.5 KiB
Agent Implementation Guide
When asked to set up auto-updates, follow this procedure.
Step 1: Detect Installation Type
# Check if installed via npm globally
npm list -g bot 2>/dev/null && echo "npm-global"
# Check if installed via source (git)
[ -d ~/.bot/.git ] || [ -f /opt/bot/.git/config ] && echo "source-install"
# Check pnpm
pnpm list -g bot 2>/dev/null && echo "pnpm-global"
# Check bun
bun pm ls -g 2>/dev/null | grep bot && echo "bun-global"
Step 2: Create the Update Script (Optional)
For complex setups, create a helper script at ~/.bot/scripts/auto-update.sh:
#!/bin/bash
set -e
LOG_FILE="${HOME}/.bot/logs/auto-update.log"
mkdir -p "$(dirname "$LOG_FILE")"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$LOG_FILE"
}
log "Starting auto-update..."
# Capture starting versions
BOT_VERSION_BEFORE=$(bot --version 2>/dev/null || echo "unknown")
# Update Bot
log "Updating Bot..."
if command -v npm &> /dev/null && npm list -g bot &> /dev/null; then
npm update -g bot@latest 2>&1 | tee -a "$LOG_FILE"
elif command -v pnpm &> /dev/null && pnpm list -g bot &> /dev/null; then
pnpm update -g bot@latest 2>&1 | tee -a "$LOG_FILE"
elif command -v bun &> /dev/null; then
bun update -g bot@latest 2>&1 | tee -a "$LOG_FILE"
else
log "Running bot update (source install)"
bot update 2>&1 | tee -a "$LOG_FILE" || true
fi
# Run doctor for migrations
log "Running doctor..."
bot doctor --yes 2>&1 | tee -a "$LOG_FILE" || true
# Capture new version
BOT_VERSION_AFTER=$(bot --version 2>/dev/null || echo "unknown")
# Update skills
log "Updating skills via Skills..."
SKILL_OUTPUT=$(skills update --all 2>&1) || true
echo "$SKILL_OUTPUT" >> "$LOG_FILE"
log "Auto-update complete."
# Output summary for agent to parse
echo "---UPDATE_SUMMARY_START---"
echo "bot_before: $BOT_VERSION_BEFORE"
echo "bot_after: $BOT_VERSION_AFTER"
echo "skill_output: $SKILL_OUTPUT"
echo "---UPDATE_SUMMARY_END---"
Step 3: Add Cron Job
The recommended approach is to use Bot's built-in cron with an isolated session:
bot cron add \
--name "Daily Auto-Update" \
--cron "0 4 * * *" \
--tz "America/Los_Angeles" \
--session isolated \
--wake now \
--deliver \
--message "Run the daily auto-update routine:
1. Check and update Bot:
- For npm installs: npm update -g bot@latest
- For source installs: bot update
- Then run: bot doctor --yes
2. Update all skills:
- Run: skills update --all
3. Report back with:
- Bot version before/after
- List of skills that were updated (name + old version → new version)
- Any errors encountered
Format the summary clearly for the user."
Step 4: Verify Setup
# Confirm cron job was added
bot cron list
# Test the update commands work
bot --version
skills list
Customization Prompts
Users may want to customize:
Different time:
--cron "0 6 * * *" # 6 AM instead of 4 AM
Different timezone:
--tz "Europe/London"
Specific provider delivery:
--provider telegram --to "@username"
Weekly instead of daily:
--cron "0 4 * * 0" # Sundays at 4 AM
Error Handling
If updates fail, the agent should:
- Log the error clearly
- Still report partial success (if skills updated but Bot didn't, or vice versa)
- Suggest manual intervention if needed
Common errors to handle:
EACCES: Permission denied → suggestsudoor fixing permissions- Network timeouts → retry once, then report
- Git conflicts (source installs) → suggest
bot update --force