diff --git a/.claude/statusline-command.sh b/.claude/statusline-command.sh index 896de96e..d9e14438 100755 --- a/.claude/statusline-command.sh +++ b/.claude/statusline-command.sh @@ -1,176 +1,238 @@ - #!/bin/bash -# Read JSON input from stdin +# RuVector Intelligence Statusline +# Multi-line display showcasing self-learning capabilities + INPUT=$(cat) MODEL=$(echo "$INPUT" | jq -r '.model.display_name // "Claude"') CWD=$(echo "$INPUT" | jq -r '.workspace.current_dir // .cwd') DIR=$(basename "$CWD") -# Replace claude-code-flow with branded name -if [ "$DIR" = "claude-code-flow" ]; then - DIR="🌊 Claude Flow" -fi - # Get git branch BRANCH=$(cd "$CWD" 2>/dev/null && git branch --show-current 2>/dev/null) -# Start building statusline -printf "\033[1m$MODEL\033[0m in \033[36m$DIR\033[0m" -[ -n "$BRANCH" ] && printf " on \033[33mβŽ‡ $BRANCH\033[0m" +# Colors +RESET="\033[0m" +BOLD="\033[1m" +CYAN="\033[36m" +YELLOW="\033[33m" +GREEN="\033[32m" +MAGENTA="\033[35m" +BLUE="\033[34m" +RED="\033[31m" +DIM="\033[2m" -# Claude-Flow integration +# ═══════════════════════════════════════════════════════════════════════════════ +# LINE 1: Model, Directory, Git +# ═══════════════════════════════════════════════════════════════════════════════ +printf "${BOLD}${MODEL}${RESET} in ${CYAN}${DIR}${RESET}" +[ -n "$BRANCH" ] && printf " on ${YELLOW}βŽ‡ ${BRANCH}${RESET}" +echo + +# ═══════════════════════════════════════════════════════════════════════════════ +# LINE 2: RuVector Intelligence Stats +# ═══════════════════════════════════════════════════════════════════════════════ +# Check multiple locations for intelligence file +INTEL_FILE="" +for INTEL_PATH in "$CWD/.ruvector/intelligence.json" \ + "$CWD/npm/packages/ruvector/.ruvector/intelligence.json" \ + "$HOME/.ruvector/intelligence.json"; do + if [ -f "$INTEL_PATH" ]; then + INTEL_FILE="$INTEL_PATH" + break + fi +done + +if [ -n "$INTEL_FILE" ]; then + # Extract learning metrics + INTEL=$(cat "$INTEL_FILE" 2>/dev/null) + + # Detect schema version (v2 has .learning.qTables, v1 has .patterns) + HAS_LEARNING=$(echo "$INTEL" | jq -r 'has("learning")' 2>/dev/null) + + if [ "$HAS_LEARNING" = "true" ]; then + # v2 Schema: Multi-algorithm learning engine + PATTERN_COUNT=$(echo "$INTEL" | jq -r '[.learning.qTables // {} | to_entries[].value | to_entries | length] | add // 0' 2>/dev/null) + ACTIVE_ALGOS=$(echo "$INTEL" | jq -r '[.learning.stats // {} | to_entries[] | select(.value.updates > 0)] | length' 2>/dev/null) + TOTAL_ALGOS=$(echo "$INTEL" | jq -r '[.learning.stats // {} | keys] | length' 2>/dev/null) + BEST_ALGO=$(echo "$INTEL" | jq -r ' + .learning.stats // {} | to_entries + | map(select(.value.updates > 0)) + | sort_by(-.value.convergenceScore) + | .[0].key // "none" + ' 2>/dev/null) + BEST_SCORE=$(echo "$INTEL" | jq -r ".learning.stats.\"$BEST_ALGO\".convergenceScore // 0" 2>/dev/null | awk '{printf "%.0f", $1 * 100}') + TOTAL_UPDATES=$(echo "$INTEL" | jq -r '[.learning.stats // {} | to_entries[].value.updates] | add // 0' 2>/dev/null) + MEMORY_COUNT=$(echo "$INTEL" | jq -r '.memory.entries | length // 0' 2>/dev/null) + TRAJ_COUNT=$(echo "$INTEL" | jq -r '.learning.trajectories | length // 0' 2>/dev/null) + ROUTING_ALGO=$(echo "$INTEL" | jq -r '.learning.configs."agent-routing".algorithm // "double-q"' 2>/dev/null) + LEARNING_RATE=$(echo "$INTEL" | jq -r '.learning.configs."agent-routing".learningRate // 0.1' 2>/dev/null) + EPSILON=$(echo "$INTEL" | jq -r '.learning.configs."agent-routing".epsilon // 0.1' 2>/dev/null) + TOP_AGENTS=$(echo "$INTEL" | jq -r ' + .learning.qTables // {} | to_entries | + map(.value | to_entries | sort_by(-.value) | .[0] | select(.value > 0)) | + map(.key) | unique | .[0:3] | join(", ") + ' 2>/dev/null) + SCHEMA="v2" + else + # v1 Schema: Simple patterns/memories + PATTERN_COUNT=$(echo "$INTEL" | jq -r '.patterns | length // 0' 2>/dev/null) + MEMORY_COUNT=$(echo "$INTEL" | jq -r '.memories | length // 0' 2>/dev/null) + ACTIVE_ALGOS=0 + TOTAL_ALGOS=0 + BEST_ALGO="none" + BEST_SCORE=0 + TOTAL_UPDATES=0 + TRAJ_COUNT=0 + ROUTING_ALGO="q-learning" + LEARNING_RATE="0.1" + EPSILON="0.1" + TOP_AGENTS="" + SCHEMA="v1" + fi + + # Build Line 2 + printf "${MAGENTA}🧠 RuVector${RESET}" + + # Patterns learned + if [ "$PATTERN_COUNT" != "null" ] && [ "$PATTERN_COUNT" -gt 0 ]; then + printf " ${GREEN}β—†${RESET} ${PATTERN_COUNT} patterns" + else + printf " ${DIM}β—‡ learning${RESET}" + fi + + # Active algorithms + if [ "$ACTIVE_ALGOS" != "null" ] && [ "$ACTIVE_ALGOS" -gt 0 ]; then + printf " ${CYAN}βš™${RESET} ${ACTIVE_ALGOS}/${TOTAL_ALGOS} algos" + fi + + # Best algorithm with convergence + if [ "$BEST_ALGO" != "none" ] && [ "$BEST_ALGO" != "null" ]; then + # Shorten algorithm name + case "$BEST_ALGO" in + "double-q") SHORT_ALGO="DQ" ;; + "q-learning") SHORT_ALGO="QL" ;; + "actor-critic") SHORT_ALGO="AC" ;; + "decision-transformer") SHORT_ALGO="DT" ;; + "monte-carlo") SHORT_ALGO="MC" ;; + "td-lambda") SHORT_ALGO="TD" ;; + *) SHORT_ALGO="${BEST_ALGO:0:3}" ;; + esac + + # Color based on convergence + if [ "$BEST_SCORE" -ge 80 ]; then + SCORE_COLOR="$GREEN" + elif [ "$BEST_SCORE" -ge 50 ]; then + SCORE_COLOR="$YELLOW" + else + SCORE_COLOR="$RED" + fi + printf " ${SCORE_COLOR}β˜…${SHORT_ALGO}:${BEST_SCORE}%%${RESET}" + fi + + # Memory entries + if [ "$MEMORY_COUNT" != "null" ] && [ "$MEMORY_COUNT" -gt 0 ]; then + printf " ${BLUE}⬑${RESET} ${MEMORY_COUNT} mem" + fi + + # Trajectories + if [ "$TRAJ_COUNT" != "null" ] && [ "$TRAJ_COUNT" -gt 0 ]; then + printf " ${YELLOW}↝${RESET} ${TRAJ_COUNT} traj" + fi + + echo + + # ═══════════════════════════════════════════════════════════════════════════════ + # LINE 3: Agent Routing & Session Performance + # ═══════════════════════════════════════════════════════════════════════════════ + + # Compression stats (v2 only) + COMPRESSION=$(echo "$INTEL" | jq -r '.tensorCompress.compressionRatio // 0' 2>/dev/null | awk '{printf "%.0f", $1 * 100}') + + printf "${BLUE}🎯 Routing${RESET}" + + # Show routing algorithm + case "$ROUTING_ALGO" in + "double-q") ALGO_ICON="⚑DQ" ;; + "sarsa") ALGO_ICON="πŸ”„SA" ;; + "actor-critic") ALGO_ICON="🎭AC" ;; + *) ALGO_ICON="$ROUTING_ALGO" ;; + esac + printf " ${CYAN}${ALGO_ICON}${RESET}" + + # Learning rate + LR_PCT=$(echo "$LEARNING_RATE" | awk '{printf "%.0f", $1 * 100}') + printf " lr:${LR_PCT}%%" + + # Exploration rate + EPS_PCT=$(echo "$EPSILON" | awk '{printf "%.0f", $1 * 100}') + printf " Ξ΅:${EPS_PCT}%%" + + # Top learned agents + if [ -n "$TOP_AGENTS" ] && [ "$TOP_AGENTS" != "null" ] && [ "$TOP_AGENTS" != "" ]; then + printf " ${GREEN}β†’${RESET} ${TOP_AGENTS}" + fi + + # Session info + if [ "$TOTAL_UPDATES" != "null" ] && [ "$TOTAL_UPDATES" -gt 0 ]; then + printf " ${DIM}β”‚${RESET} ${YELLOW}↻${RESET}${TOTAL_UPDATES}" + fi + + # Compression ratio + if [ "$COMPRESSION" != "null" ] && [ "$COMPRESSION" -gt 0 ]; then + printf " ${MAGENTA}β—Š${RESET}${COMPRESSION}%% comp" + fi + + echo + +else + # No intelligence file - show initialization hint + printf "${DIM}🧠 RuVector: run 'npx ruvector hooks session-start' to initialize${RESET}\n" +fi + +# ═══════════════════════════════════════════════════════════════════════════════ +# LINE 4: Claude Flow Integration (if available) +# ═══════════════════════════════════════════════════════════════════════════════ FLOW_DIR="$CWD/.claude-flow" if [ -d "$FLOW_DIR" ]; then - printf " β”‚" + printf "${DIM}⚑ Flow:${RESET}" - # 1. Swarm Configuration & Topology + # Swarm config if [ -f "$FLOW_DIR/swarm-config.json" ]; then STRATEGY=$(jq -r '.defaultStrategy // empty' "$FLOW_DIR/swarm-config.json" 2>/dev/null) + AGENT_COUNT=$(jq -r '.agentProfiles | length' "$FLOW_DIR/swarm-config.json" 2>/dev/null) + if [ -n "$STRATEGY" ]; then - # Map strategy to topology icon case "$STRATEGY" in - "balanced") TOPO_ICON="⚑mesh" ;; - "conservative") TOPO_ICON="⚑hier" ;; - "aggressive") TOPO_ICON="⚑ring" ;; - *) TOPO_ICON="⚑$STRATEGY" ;; + "balanced") TOPO="mesh" ;; + "conservative") TOPO="hier" ;; + "aggressive") TOPO="ring" ;; + *) TOPO="$STRATEGY" ;; esac - printf " \033[35m$TOPO_ICON\033[0m" + printf " ${MAGENTA}${TOPO}${RESET}" + fi - # Count agent profiles as "configured agents" - AGENT_COUNT=$(jq -r '.agentProfiles | length' "$FLOW_DIR/swarm-config.json" 2>/dev/null) - if [ -n "$AGENT_COUNT" ] && [ "$AGENT_COUNT" != "null" ] && [ "$AGENT_COUNT" -gt 0 ]; then - printf " \033[35mπŸ€– $AGENT_COUNT\033[0m" - fi + if [ -n "$AGENT_COUNT" ] && [ "$AGENT_COUNT" != "null" ] && [ "$AGENT_COUNT" -gt 0 ]; then + printf " ${CYAN}πŸ€–${AGENT_COUNT}${RESET}" fi fi - # 2. Real-time System Metrics - if [ -f "$FLOW_DIR/metrics/system-metrics.json" ]; then - # Get latest metrics (last entry in array) - LATEST=$(jq -r '.[-1]' "$FLOW_DIR/metrics/system-metrics.json" 2>/dev/null) - - if [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then - # Memory usage - MEM_PERCENT=$(echo "$LATEST" | jq -r '.memoryUsagePercent // 0' | awk '{printf "%.0f", $1}') - if [ -n "$MEM_PERCENT" ] && [ "$MEM_PERCENT" != "null" ]; then - # Color-coded memory (green <60%, yellow 60-80%, red >80%) - if [ "$MEM_PERCENT" -lt 60 ]; then - MEM_COLOR="\033[32m" # Green - elif [ "$MEM_PERCENT" -lt 80 ]; then - MEM_COLOR="\033[33m" # Yellow - else - MEM_COLOR="\033[31m" # Red - fi - printf " ${MEM_COLOR}πŸ’Ύ ${MEM_PERCENT}%\033[0m" - fi - - # CPU load - CPU_LOAD=$(echo "$LATEST" | jq -r '.cpuLoad // 0' | awk '{printf "%.0f", $1 * 100}') - if [ -n "$CPU_LOAD" ] && [ "$CPU_LOAD" != "null" ]; then - # Color-coded CPU (green <50%, yellow 50-75%, red >75%) - if [ "$CPU_LOAD" -lt 50 ]; then - CPU_COLOR="\033[32m" # Green - elif [ "$CPU_LOAD" -lt 75 ]; then - CPU_COLOR="\033[33m" # Yellow - else - CPU_COLOR="\033[31m" # Red - fi - printf " ${CPU_COLOR}βš™ ${CPU_LOAD}%\033[0m" - fi - fi - fi - - # 3. Session State - if [ -f "$FLOW_DIR/session-state.json" ]; then - SESSION_ID=$(jq -r '.sessionId // empty' "$FLOW_DIR/session-state.json" 2>/dev/null) - ACTIVE=$(jq -r '.active // false' "$FLOW_DIR/session-state.json" 2>/dev/null) - - if [ "$ACTIVE" = "true" ] && [ -n "$SESSION_ID" ]; then - # Show abbreviated session ID - SHORT_ID=$(echo "$SESSION_ID" | cut -d'-' -f1) - printf " \033[34mπŸ”„ $SHORT_ID\033[0m" - fi - fi - - # 4. Performance Metrics from task-metrics.json - if [ -f "$FLOW_DIR/metrics/task-metrics.json" ]; then - # Parse task metrics for success rate, avg time, and streak - METRICS=$(jq -r ' - # Calculate metrics - (map(select(.success == true)) | length) as $successful | - (length) as $total | - (if $total > 0 then ($successful / $total * 100) else 0 end) as $success_rate | - (map(.duration // 0) | add / length) as $avg_duration | - # Calculate streak (consecutive successes from end) - (reverse | - reduce .[] as $task (0; - if $task.success == true then . + 1 else 0 end - ) - ) as $streak | - { - success_rate: $success_rate, - avg_duration: $avg_duration, - streak: $streak, - total: $total - } | @json - ' "$FLOW_DIR/metrics/task-metrics.json" 2>/dev/null) - - if [ -n "$METRICS" ] && [ "$METRICS" != "null" ]; then - # Success Rate - SUCCESS_RATE=$(echo "$METRICS" | jq -r '.success_rate // 0' | awk '{printf "%.0f", $1}') - TOTAL_TASKS=$(echo "$METRICS" | jq -r '.total // 0') - - if [ -n "$SUCCESS_RATE" ] && [ "$TOTAL_TASKS" -gt 0 ]; then - # Color-code: Green (>80%), Yellow (60-80%), Red (<60%) - if [ "$SUCCESS_RATE" -gt 80 ]; then - SUCCESS_COLOR="\033[32m" # Green - elif [ "$SUCCESS_RATE" -ge 60 ]; then - SUCCESS_COLOR="\033[33m" # Yellow - else - SUCCESS_COLOR="\033[31m" # Red - fi - printf " ${SUCCESS_COLOR}🎯 ${SUCCESS_RATE}%\033[0m" - fi - - # Average Time - AVG_TIME=$(echo "$METRICS" | jq -r '.avg_duration // 0') - if [ -n "$AVG_TIME" ] && [ "$TOTAL_TASKS" -gt 0 ]; then - # Format smartly: seconds, minutes, or hours - if [ $(echo "$AVG_TIME < 60" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then - TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fs", $1}') - elif [ $(echo "$AVG_TIME < 3600" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then - TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fm", $1/60}') - else - TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fh", $1/3600}') - fi - printf " \033[36m⏱️ $TIME_STR\033[0m" - fi - - # Streak (only show if > 0) - STREAK=$(echo "$METRICS" | jq -r '.streak // 0') - if [ -n "$STREAK" ] && [ "$STREAK" -gt 0 ]; then - printf " \033[91mπŸ”₯ $STREAK\033[0m" - fi - fi - fi - - # 5. Active Tasks (check for task files) + # Active tasks if [ -d "$FLOW_DIR/tasks" ]; then TASK_COUNT=$(find "$FLOW_DIR/tasks" -name "*.json" -type f 2>/dev/null | wc -l) if [ "$TASK_COUNT" -gt 0 ]; then - printf " \033[36mπŸ“‹ $TASK_COUNT\033[0m" + printf " ${YELLOW}πŸ“‹${TASK_COUNT}${RESET}" fi fi - # 6. Check for hooks activity - if [ -f "$FLOW_DIR/hooks-state.json" ]; then - HOOKS_ACTIVE=$(jq -r '.enabled // false' "$FLOW_DIR/hooks-state.json" 2>/dev/null) - if [ "$HOOKS_ACTIVE" = "true" ]; then - printf " \033[35mπŸ”—\033[0m" + # Session state + if [ -f "$FLOW_DIR/session-state.json" ]; then + ACTIVE=$(jq -r '.active // false' "$FLOW_DIR/session-state.json" 2>/dev/null) + if [ "$ACTIVE" = "true" ]; then + printf " ${GREEN}●${RESET}" fi fi + + echo fi - -echo diff --git a/npm/packages/ruvector/.ruvector/intelligence.json b/npm/packages/ruvector/.ruvector/intelligence.json index 2d8992b6..96802ea1 100644 --- a/npm/packages/ruvector/.ruvector/intelligence.json +++ b/npm/packages/ruvector/.ruvector/intelligence.json @@ -1,12 +1,1927 @@ { + "patterns": { + "cmd_shell_general|success": { + "state": "cmd_shell_general", + "action": "success", + "q_value": 0.6919318625861607, + "visits": 19, + "last_update": 1767195615 + }, + "edit_ts_in_project|successful-edit": { + "state": "edit_ts_in_project", + "action": "successful-edit", + "q_value": 0.19, + "visits": 2, + "last_update": 1767195588 + }, + "cmd_javascript_build|success": { + "state": "cmd_javascript_build", + "action": "success", + "q_value": 0.08000000000000002, + "visits": 1, + "last_update": 1767195506 + }, + "cmd_javascript_test|success": { + "state": "cmd_javascript_test", + "action": "success", + "q_value": 0.08000000000000002, + "visits": 1, + "last_update": 1767195588 + } + }, + "memories": [ + { + "id": "mem_1767195493", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195493 + }, + { + "id": "mem_1767195504", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195504 + }, + { + "id": "mem_1767195505", + "memory_type": "edit", + "content": "successful edit of ts in project", + "embedding": [ + 0, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0, + 0, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0, + 0, + 0, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0, + 0, + 0, + 0, + 0, + 0, + 0.3086066999241838, + 0.1543033499620919, + 0, + 0, + 0, + 0, + 0, + 0.3086066999241838, + 0.1543033499620919, + 0.3086066999241838, + 0, + 0, + 0, + 0, + 0, + 0, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0.1543033499620919, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0.1543033499620919, + 0.3086066999241838, + 0, + 0.1543033499620919, + 0, + 0, + 0.3086066999241838, + 0.1543033499620919, + 0, + 0, + 0.1543033499620919, + 0, + 0, + 0.1543033499620919 + ], + "metadata": {}, + "timestamp": 1767195505 + }, + { + "id": "mem_1767195505", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195505 + }, + { + "id": "mem_1767195505", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195505 + }, + { + "id": "mem_1767195506", + "memory_type": "command", + "content": "npm run build succeeded", + "embedding": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.1796053020267749, + 0, + 0, + 0.1796053020267749, + 0, + 0.1796053020267749, + 0, + 0.1796053020267749, + 0, + 0, + 0.3592106040535498, + 0, + 0.3592106040535498, + 0, + 0, + 0, + 0.1796053020267749, + 0, + 0, + 0, + 0, + 0.1796053020267749, + 0, + 0, + 0, + 0, + 0, + 0, + 0.1796053020267749, + 0, + 0, + 0, + 0.1796053020267749, + 0.1796053020267749, + 0.1796053020267749, + 0, + 0, + 0, + 0.1796053020267749, + 0.1796053020267749, + 0, + 0.1796053020267749, + 0.3592106040535498, + 0.1796053020267749, + 0, + 0.3592106040535498, + 0, + 0, + 0.1796053020267749, + 0 + ], + "metadata": {}, + "timestamp": 1767195506 + }, + { + "id": "mem_1767195506", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195506 + }, + { + "id": "mem_1767195517", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195517 + }, + { + "id": "mem_1767195529", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195529 + }, + { + "id": "mem_1767195530", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195530 + }, + { + "id": "mem_1767195538", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195538 + }, + { + "id": "mem_1767195539", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195539 + }, + { + "id": "mem_1767195550", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195550 + }, + { + "id": "mem_1767195550", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195550 + }, + { + "id": "mem_1767195551", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195551 + }, + { + "id": "mem_1767195563", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195563 + }, + { + "id": "mem_1767195564", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195564 + }, + { + "id": "mem_1767195574", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195574 + }, + { + "id": "mem_1767195575", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195575 + }, + { + "id": "mem_1767195588", + "memory_type": "edit", + "content": "successful edit of ts in project", + "embedding": [ + 0, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0, + 0, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0, + 0, + 0, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0, + 0, + 0, + 0, + 0, + 0, + 0.3086066999241838, + 0.1543033499620919, + 0, + 0, + 0, + 0, + 0, + 0.3086066999241838, + 0.1543033499620919, + 0.3086066999241838, + 0, + 0, + 0, + 0, + 0, + 0, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0.1543033499620919, + 0.1543033499620919, + 0, + 0.1543033499620919, + 0.1543033499620919, + 0.1543033499620919, + 0.3086066999241838, + 0, + 0.1543033499620919, + 0, + 0, + 0.3086066999241838, + 0.1543033499620919, + 0, + 0, + 0.1543033499620919, + 0, + 0, + 0.1543033499620919 + ], + "metadata": {}, + "timestamp": 1767195588 + }, + { + "id": "mem_1767195588", + "memory_type": "command", + "content": "npm test succeeded", + "embedding": [ + 0.21320071635561041, + 0, + 0, + 0, + 0, + 0, + 0, + 0.21320071635561041, + 0.21320071635561041, + 0, + 0, + 0, + 0, + 0.21320071635561041, + 0, + 0, + 0.21320071635561041, + 0, + 0, + 0, + 0, + 0.21320071635561041, + 0, + 0, + 0.21320071635561041, + 0, + 0, + 0.21320071635561041, + 0, + 0.21320071635561041, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.21320071635561041, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.21320071635561041, + 0, + 0.21320071635561041, + 0, + 0.21320071635561041, + 0, + 0, + 0.21320071635561041, + 0, + 0.42640143271122083, + 0, + 0, + 0, + 0.42640143271122083, + 0, + 0, + 0, + 0 + ], + "metadata": {}, + "timestamp": 1767195588 + }, + { + "id": "mem_1767195589", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195589 + }, + { + "id": "mem_1767195615", + "memory_type": "command", + "content": " succeeded", + "embedding": [ + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0.31622776601683794, + 0, + 0.31622776601683794, + 0, + 0, + 0, + 0, + 0.31622776601683794 + ], + "metadata": {}, + "timestamp": 1767195615 + } + ], + "trajectories": [ + { + "id": "traj_1767195493", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195493 + }, + { + "id": "traj_1767195504", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195504 + }, + { + "id": "traj_1767195505", + "state": "edit_ts_in_project", + "action": "successful-edit", + "outcome": "completed", + "reward": 1, + "timestamp": 1767195505 + }, + { + "id": "traj_1767195505", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195505 + }, + { + "id": "traj_1767195505", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195505 + }, + { + "id": "traj_1767195506", + "state": "cmd_javascript_build", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195506 + }, + { + "id": "traj_1767195506", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195506 + }, + { + "id": "traj_1767195517", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195517 + }, + { + "id": "traj_1767195529", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195529 + }, + { + "id": "traj_1767195530", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195530 + }, + { + "id": "traj_1767195538", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195538 + }, + { + "id": "traj_1767195539", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195539 + }, + { + "id": "traj_1767195550", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195550 + }, + { + "id": "traj_1767195550", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195550 + }, + { + "id": "traj_1767195551", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195551 + }, + { + "id": "traj_1767195563", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195563 + }, + { + "id": "traj_1767195564", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195564 + }, + { + "id": "traj_1767195574", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195574 + }, + { + "id": "traj_1767195575", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195575 + }, + { + "id": "traj_1767195588", + "state": "edit_ts_in_project", + "action": "successful-edit", + "outcome": "completed", + "reward": 1, + "timestamp": 1767195588 + }, + { + "id": "traj_1767195588", + "state": "cmd_javascript_test", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195588 + }, + { + "id": "traj_1767195589", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195589 + }, + { + "id": "traj_1767195615", + "state": "cmd_shell_general", + "action": "success", + "outcome": "completed", + "reward": 0.8, + "timestamp": 1767195615 + } + ], + "errors": {}, + "file_sequences": [], + "agents": {}, + "edges": [], + "stats": { + "total_patterns": 4, + "total_memories": 23, + "total_trajectories": 23, + "total_errors": 0, + "session_count": 6, + "last_session": 1767195588 + }, "learning": { "qTables": { "typescript": { "coder": 0.1 + }, + "edit_ts": { + "typescript-developer": 0.1 } }, "qTables2": { - "typescript": {} + "typescript": {}, + "edit_ts": { + "typescript-developer": 0.185 + } }, "criticValues": {}, "trajectories": [], @@ -27,10 +1942,10 @@ }, "double-q": { "algorithm": "double-q", - "updates": 1, - "avgReward": 1, - "convergenceScore": 0.5, - "lastUpdate": 1767193942801 + "updates": 4, + "avgReward": 0.9625, + "convergenceScore": 0.5263157894736842, + "lastUpdate": 1767195588626 }, "actor-critic": { "algorithm": "actor-critic", @@ -119,16 +2034,10 @@ } }, "rewardHistory": [ - 1 + 1, + 0.95, + 1, + 0.9 ] - }, - "stats": { - "total_patterns": 0, - "total_memories": 0, - "total_trajectories": 0, - "total_errors": 0, - "session_count": 2, - "last_session": 1767194641 - }, - "trajectories": [] + } } \ No newline at end of file diff --git a/npm/packages/ruvector/bin/cli.js b/npm/packages/ruvector/bin/cli.js index f7c9516f..9d730185 100755 --- a/npm/packages/ruvector/bin/cli.js +++ b/npm/packages/ruvector/bin/cli.js @@ -2233,12 +2233,7 @@ class Intelligence { } load() { - try { - if (fs.existsSync(this.intelPath)) { - return JSON.parse(fs.readFileSync(this.intelPath, 'utf-8')); - } - } catch {} - return { + const defaults = { patterns: {}, memories: [], trajectories: [], @@ -2248,6 +2243,25 @@ class Intelligence { edges: [], stats: { total_patterns: 0, total_memories: 0, total_trajectories: 0, total_errors: 0, session_count: 0, last_session: 0 } }; + try { + if (fs.existsSync(this.intelPath)) { + const data = JSON.parse(fs.readFileSync(this.intelPath, 'utf-8')); + // Merge with defaults to ensure all fields exist + return { + patterns: data.patterns || defaults.patterns, + memories: data.memories || defaults.memories, + trajectories: data.trajectories || defaults.trajectories, + errors: data.errors || defaults.errors, + file_sequences: data.file_sequences || defaults.file_sequences, + agents: data.agents || defaults.agents, + edges: data.edges || defaults.edges, + stats: { ...defaults.stats, ...(data.stats || {}) }, + // Preserve learning data if present + learning: data.learning || undefined + }; + } + } catch {} + return defaults; } save() { @@ -2374,11 +2388,14 @@ class Intelligence { // Q-learning operations - enhanced with SONA trajectory tracking getQ(state, action) { const key = `${state}|${action}`; + if (!this.data.patterns) this.data.patterns = {}; return this.data.patterns[key]?.q_value ?? 0; } updateQ(state, action, reward) { const key = `${state}|${action}`; + if (!this.data.patterns) this.data.patterns = {}; + if (!this.data.stats) this.data.stats = { total_patterns: 0, total_memories: 0, total_trajectories: 0, total_errors: 0, session_count: 0, last_session: 0 }; if (!this.data.patterns[key]) { this.data.patterns[key] = { state, action, q_value: 0, visits: 0, last_update: 0 }; } @@ -2398,6 +2415,8 @@ class Intelligence { learn(state, action, outcome, reward) { const id = `traj_${this.now()}`; this.updateQ(state, action, reward); + if (!this.data.trajectories) this.data.trajectories = []; + if (!this.data.stats) this.data.stats = { total_patterns: 0, total_memories: 0, total_trajectories: 0, total_errors: 0, session_count: 0, last_session: 0 }; this.data.trajectories.push({ id, state, action, outcome, reward, timestamp: this.now() }); if (this.data.trajectories.length > 1000) this.data.trajectories.splice(0, 200); this.data.stats.total_trajectories = this.data.trajectories.length; diff --git a/npm/packages/ruvector/package.json b/npm/packages/ruvector/package.json index 7d1b56e1..a49f56d2 100644 --- a/npm/packages/ruvector/package.json +++ b/npm/packages/ruvector/package.json @@ -1,6 +1,6 @@ { "name": "ruvector", - "version": "0.1.69", + "version": "0.1.70", "description": "High-performance vector database for Node.js with automatic native/WASM fallback", "main": "dist/index.js", "types": "dist/index.d.ts",