Add autonomous planner agent with safety rules and PROACTIVE auto-triggering

- Created autonomous-planner.md agent file with context-aware workflow suggestions
- Implemented safety-rules.json for safe/risky operation classification
- Updated all installers (auto-installer.sh, interactive-install-claude.sh) to include autonomous planner
- Updated agent counts: 40→41 total agents, 8→9 PROACTIVELY coordinators, 4→5 Bonus agents
- Updated documentation (README.md, MASTER-PROMPT.md, extra-tools/README.md)
- Added test-autonomous-planner.sh TDD test suite
- Auto-triggers on: code changes, tests passing, deployments, safe task execution
This commit is contained in:
Gemini AI
2026-01-18 03:04:06 +04:00
Unverified
parent 63218683d4
commit 61e5713549
8 changed files with 799 additions and 24 deletions

258
test-autonomous-planner.sh Normal file
View File

@@ -0,0 +1,258 @@
#!/usr/bin/env bash
################################################################################
# TDD Test Suite for Autonomous Planner Agent
# Tests autonomous planning, safety rules, and action tracking
################################################################################
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Test counters
TESTS_RUN=0
TESTS_PASSED=0
TESTS_FAILED=0
# Test agent file
AGENT_FILE="agents/bonus/autonomous-planner.md"
SAFETY_RULES_FILE="skills/autonomous-planner/safety-rules.json"
################################################################################
# Test Helper Functions
################################################################################
test_start() {
local test_name="$1"
TESTS_RUN=$((TESTS_RUN + 1))
echo -e "\n${BLUE}[TEST $TESTS_RUN]${NC} $test_name"
}
test_pass() {
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN} ✓ PASS${NC}"
}
test_fail() {
local reason="$1"
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED} ✗ FAIL${NC}: $reason"
}
test_info() {
echo -e "${YELLOW} INFO${NC}: $1"
}
################################################################################
# Test Suite 1: Agent File Structure
################################################################################
test_agent_file_exists() {
test_start "Agent file exists"
if [ -f "$AGENT_FILE" ]; then
test_pass
else
test_fail "File not found: $AGENT_FILE"
fi
}
test_agent_has_yaml_frontmatter() {
test_start "Agent has YAML frontmatter"
if grep -q "^---$" "$AGENT_FILE" 2>/dev/null; then
test_pass
else
test_fail "No YAML frontmatter found"
fi
}
test_agent_has_name() {
test_start "Agent has name in YAML"
if grep -q "^name:" "$AGENT_FILE" 2>/dev/null; then
test_pass
else
test_fail "No 'name:' field in YAML"
fi
}
test_agent_has_trigger() {
test_start "Agent has auto-trigger configuration"
if grep -q "autotrigger:" "$AGENT_FILE" 2>/dev/null; then
test_pass
else
test_fail "No 'autotrigger:' field"
fi
}
test_agent_has_category() {
test_start "Agent is in bonus category"
if grep -q "category: bonus" "$AGENT_FILE" 2>/dev/null; then
test_pass
else
test_fail "Not in bonus category"
fi
}
################################################################################
# Test Suite 2: Agent Content
################################################################################
test_agent_has_workflow_planning() {
test_start "Agent mentions workflow planning"
if grep -i "workflow planning\|context-aware\|next steps" "$AGENT_FILE" 2>/dev/null | tr -d '[:space:]' | head -1 | grep -q "."; then
test_pass
else
test_fail "No workflow planning content found"
fi
}
test_agent_has_safety_rules() {
test_start "Agent mentions safety rules"
if grep -i "safety\|confirmation\|auto-execute" "$AGENT_FILE" 2>/dev/null | tr -d '[:space:]' | head -1 | grep -q "."; then
test_pass
else
test_fail "No safety rules content found"
fi
}
test_agent_has_action_tracking() {
test_start "Agent mentions action history tracking"
if grep -i "history\|tracking\|learn from" "$AGENT_FILE" 2>/dev/null | tr -d '[:space:]' | head -1 | grep -q "."; then
test_pass
else
test_fail "No action tracking content found"
fi
}
test_agent_has_trigger_conditions() {
test_start "Agent has trigger conditions"
if grep "code changes\|tests pass\|deployment" "$AGENT_FILE" 2>/dev/null | tr -d '[:space:]' | head -1 | grep -q "."; then
test_pass
else
test_fail "No trigger conditions found"
fi
}
################################################################################
# Test Suite 3: Safety Rules Configuration
################################################################################
test_safety_rules_file_exists() {
test_start "Safety rules file exists"
if [ -f "$SAFETY_RULES_FILE" ]; then
test_pass
else
test_fail "File not found: $SAFETY_RULES_FILE"
fi
}
test_safety_rules_is_valid_json() {
test_start "Safety rules is valid JSON"
if python3 -m json.tool "$SAFETY_RULES_FILE" > /dev/null 2>&1; then
test_pass
else
test_fail "Invalid JSON format"
fi
}
test_safety_rules_has_safe_operations() {
test_start "Safety rules defines safe operations"
if grep -q "safe_operations\|auto_execute" "$SAFETY_RULES_FILE" 2>/dev/null; then
test_pass
else
test_fail "No safe operations defined"
fi
}
test_safety_rules_has_risky_operations() {
test_start "Safety rules defines risky operations"
if grep -q "risky_operations\|require_confirmation" "$SAFETY_RULES_FILE" 2>/dev/null; then
test_pass
else
test_fail "No risky operations defined"
fi
}
################################################################################
# Test Suite 4: Integration
################################################################################
test_agent_count_increased() {
test_start "Total agent count updated to 41"
local total_agents=$(find agents -name "*.md" 2>/dev/null | wc -l)
if [ "$total_agents" -eq 41 ]; then
test_pass
else
test_fail "Expected 41 agents, found $total_agents"
fi
}
test_bonus_category_count() {
test_start "Bonus category has 5 agents"
local bonus_count=$(find agents/bonus -name "*.md" 2>/dev/null | wc -l)
if [ "$bonus_count" -eq 5 ]; then
test_pass
else
test_fail "Expected 5 bonus agents, found $bonus_count"
fi
}
################################################################################
# Main Test Runner
################################################################################
main() {
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Autonomous Planner Agent - TDD Test Suite ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
# Test Suite 1: Agent File Structure
echo -e "\n${YELLOW}=== Suite 1: Agent File Structure ===${NC}"
test_agent_file_exists
test_agent_has_yaml_frontmatter
test_agent_has_name
test_agent_has_trigger
test_agent_has_category
# Test Suite 2: Agent Content
echo -e "\n${YELLOW}=== Suite 2: Agent Content ===${NC}"
test_agent_has_workflow_planning
test_agent_has_safety_rules
test_agent_has_action_tracking
test_agent_has_trigger_conditions
# Test Suite 3: Safety Rules Configuration
echo -e "\n${YELLOW}=== Suite 3: Safety Rules Configuration ===${NC}"
test_safety_rules_file_exists
test_safety_rules_is_valid_json
test_safety_rules_has_safe_operations
test_safety_rules_has_risky_operations
# Test Suite 4: Integration
echo -e "\n${YELLOW}=== Suite 4: Integration ===${NC}"
test_agent_count_increased
test_bonus_category_count
# Summary
echo -e "\n${BLUE}═══════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Test Results:${NC}"
echo -e " Total Tests: $TESTS_RUN"
echo -e "${GREEN} Passed: $TESTS_PASSED${NC}"
if [ $TESTS_FAILED -gt 0 ]; then
echo -e "${RED} Failed: $TESTS_FAILED${NC}"
fi
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
if [ $TESTS_FAILED -eq 0 ]; then
echo -e "\n${GREEN}✓ All tests passed!${NC}"
exit 0
else
echo -e "\n${RED}✗ Some tests failed. Fix issues and re-run.${NC}"
exit 1
fi
}
main "$@"