mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-13 14:23:58 +00:00
Remove standalone nanobot/heartbeat/ service and replace it with an auto-registered system cron job on gateway startup. Key behaviors preserved: - HeartbeatConfig (enabled, interval_s, keep_recent_messages) remains in GatewayConfig for backward compatibility. - On startup, if enabled, a system cron job "heartbeat" is registered with schedule derived from interval_s. - HEARTBEAT.md is checked on each tick; empty/template-identical files skip to avoid wasting LLM calls. - Post-run evaluate_response and session history truncation (keep_recent_messages) are retained. - Delivery target selection, deliverable filtering, and preamble guidance are preserved. Files removed: - nanobot/heartbeat/__init__.py - nanobot/heartbeat/service.py - tests/heartbeat/* - tests/agent/test_heartbeat_service.py Templates and docs updated to reflect cron-based usage.
91 lines
2.5 KiB
Bash
Executable File
91 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")" || exit 1
|
|
|
|
count_top_level_py_lines() {
|
|
local dir="$1"
|
|
if [ ! -d "$dir" ]; then
|
|
echo 0
|
|
return
|
|
fi
|
|
find "$dir" -maxdepth 1 -type f -name "*.py" -print0 | xargs -0 cat 2>/dev/null | wc -l | tr -d ' '
|
|
}
|
|
|
|
count_recursive_py_lines() {
|
|
local dir="$1"
|
|
if [ ! -d "$dir" ]; then
|
|
echo 0
|
|
return
|
|
fi
|
|
find "$dir" -type f -name "*.py" -print0 | xargs -0 cat 2>/dev/null | wc -l | tr -d ' '
|
|
}
|
|
|
|
count_skill_lines() {
|
|
local dir="$1"
|
|
if [ ! -d "$dir" ]; then
|
|
echo 0
|
|
return
|
|
fi
|
|
find "$dir" -type f \( -name "*.md" -o -name "*.py" -o -name "*.sh" \) -print0 | xargs -0 cat 2>/dev/null | wc -l | tr -d ' '
|
|
}
|
|
|
|
print_row() {
|
|
local label="$1"
|
|
local count="$2"
|
|
printf " %-16s %6s lines\n" "$label" "$count"
|
|
}
|
|
|
|
echo "nanobot line count"
|
|
echo "=================="
|
|
echo ""
|
|
|
|
echo "Core runtime"
|
|
echo "------------"
|
|
core_agent=$(count_top_level_py_lines "nanobot/agent")
|
|
core_bus=$(count_top_level_py_lines "nanobot/bus")
|
|
core_config=$(count_top_level_py_lines "nanobot/config")
|
|
core_cron=$(count_top_level_py_lines "nanobot/cron")
|
|
core_session=$(count_top_level_py_lines "nanobot/session")
|
|
|
|
print_row "agent/" "$core_agent"
|
|
print_row "bus/" "$core_bus"
|
|
print_row "config/" "$core_config"
|
|
print_row "cron/" "$core_cron"
|
|
print_row "session/" "$core_session"
|
|
|
|
core_total=$((core_agent + core_bus + core_config + core_cron + core_session))
|
|
|
|
echo ""
|
|
echo "Separate buckets"
|
|
echo "----------------"
|
|
extra_tools=$(count_recursive_py_lines "nanobot/agent/tools")
|
|
extra_skills=$(count_skill_lines "nanobot/skills")
|
|
extra_api=$(count_recursive_py_lines "nanobot/api")
|
|
extra_cli=$(count_recursive_py_lines "nanobot/cli")
|
|
extra_channels=$(count_recursive_py_lines "nanobot/channels")
|
|
extra_utils=$(count_recursive_py_lines "nanobot/utils")
|
|
|
|
print_row "tools/" "$extra_tools"
|
|
print_row "skills/" "$extra_skills"
|
|
print_row "api/" "$extra_api"
|
|
print_row "cli/" "$extra_cli"
|
|
print_row "channels/" "$extra_channels"
|
|
print_row "utils/" "$extra_utils"
|
|
|
|
extra_total=$((extra_tools + extra_skills + extra_api + extra_cli + extra_channels + extra_utils))
|
|
|
|
echo ""
|
|
echo "Totals"
|
|
echo "------"
|
|
print_row "core total" "$core_total"
|
|
print_row "extra total" "$extra_total"
|
|
|
|
echo ""
|
|
echo "Notes"
|
|
echo "-----"
|
|
echo " - agent/ only counts top-level Python files under nanobot/agent"
|
|
echo " - tools/ is counted separately from nanobot/agent/tools"
|
|
echo " - skills/ counts .md, .py, and .sh files"
|
|
echo " - not included here: command/, providers/, security/, templates/, nanobot.py, root files"
|