mirror of
https://github.com/microsoft/SkillOpt.git
synced 2026-07-08 08:59:22 +08:00
Adds a thin OpenClaw shell wrapping the SkillOpt-Sleep engine. Enables nightly validation-gated skill improvement cycles for OpenClaw agents. Components: - skillopt_sleep_openclaw.py: DeepSeek V4 Pro + Ollama nomic-embed-text backend, mirroring the Claude/Codex/Copilot backend pattern. - run_sleep.py: CLI entry point supporting dry-run and pre-built task files. - run_sleep_cron.sh: bash wrapper for nightly cron invocation. - slash_sleep.py: /sleep command (status / run / adopt / reject / cost). - config.json: engine config tuned for our stack. - SKILL.md: OpenClaw skill manifest. - tests/: 14 held-out tasks across 3 categories (research-cron, devops, wiki). OpenClaw is the 4th ecosystem in which SkillOpt-Sleep can be deployed, joining Claude Code, Codex, and Copilot. The shell follows the same single-engine / thin-shell pattern as the existing three plugins. End-to-end tested: pipeline runs against real OpenClaw session transcripts, gate correctly rejects non-improvements, staging artifacts land in ~/.skillopt-sleep/staging/<night>/. Cost: ~$0.02/night on DeepSeek V4 Pro.
77 lines
2.2 KiB
Bash
Executable File
77 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# run_sleep_cron.sh — wrapper for cron-driven nightly sleep cycle
|
|
#
|
|
# Usage: bash run_sleep_cron.sh [category1 category2 ...]
|
|
# No args: run on all categories in tests/
|
|
# With args: run only on listed categories (research-cron, devops, wiki)
|
|
#
|
|
# Cron (3am MYT daily):
|
|
# 0 3 * * * cd /home/ethanclaw/.openclaw/workspace/skills/skillopt-sleep && bash run_sleep_cron.sh >> ~/.skillopt-sleep/nightly.log 2>&1
|
|
|
|
set -euo pipefail
|
|
|
|
SKILL_DIR="/home/ethanclaw/.openclaw/workspace/skills/skillopt-sleep"
|
|
TESTS_DIR="$SKILL_DIR/tests"
|
|
LOG_DIR="$HOME/.skillopt-sleep/logs"
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
|
LOG_FILE="$LOG_DIR/night-$TIMESTAMP.log"
|
|
|
|
# category → test file map
|
|
declare -A CATEGORIES=(
|
|
["research-cron"]="research-cron-tasks.json"
|
|
["devops"]="devops-tasks.json"
|
|
["wiki"]="wiki-tasks.json"
|
|
)
|
|
|
|
# Determine which categories to run
|
|
if [ $# -eq 0 ]; then
|
|
CATS=("research-cron" "devops" "wiki")
|
|
else
|
|
CATS=("$@")
|
|
fi
|
|
|
|
{
|
|
echo "=========================================="
|
|
echo "SkillOpt-Sleep nightly — $TIMESTAMP"
|
|
echo "Categories: ${CATS[*]}"
|
|
echo "=========================================="
|
|
} | tee -a "$LOG_FILE"
|
|
|
|
# Pre-flight: check DeepSeek API key
|
|
if ! grep -q "DEEPSEEK_API_KEY=" "$HOME/.openclaw/.env" 2>/dev/null; then
|
|
echo "ERROR: DEEPSEEK_API_KEY not found in ~/.openclaw/.env" | tee -a "$LOG_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
EXIT_CODE=0
|
|
for cat in "${CATS[@]}"; do
|
|
tasks_file="$TESTS_DIR/${CATEGORIES[$cat]:-}"
|
|
if [ ! -f "$tasks_file" ]; then
|
|
echo "SKIP: $cat (no tasks file: $tasks_file)" | tee -a "$LOG_FILE"
|
|
continue
|
|
fi
|
|
|
|
echo "" | tee -a "$LOG_FILE"
|
|
echo "--- [$cat] starting cycle ---" | tee -a "$LOG_FILE"
|
|
|
|
cd "$SKILL_DIR"
|
|
if python3 run_sleep.py --tasks "$tasks_file" 2>&1 | tee -a "$LOG_FILE"; then
|
|
echo "--- [$cat] OK ---" | tee -a "$LOG_FILE"
|
|
else
|
|
EC=$?
|
|
echo "--- [$cat] FAILED (exit $EC) ---" | tee -a "$LOG_FILE"
|
|
EXIT_CODE=$EC
|
|
fi
|
|
done
|
|
|
|
{
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "Done. Exit: $EXIT_CODE"
|
|
echo "=========================================="
|
|
} | tee -a "$LOG_FILE"
|
|
|
|
exit $EXIT_CODE
|