-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarp-engine-staged
More file actions
executable file
·193 lines (158 loc) · 5.45 KB
/
warp-engine-staged
File metadata and controls
executable file
·193 lines (158 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env bash
# Warp Engine Staged - Create agents with staging and prompt refinement
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
NC='\033[0m' # No Color
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
# Activate virtual environment
if [ -d ".venv" ]; then
source .venv/bin/activate
else
echo -e "${RED}Virtual environment not found. Run ./install.sh first.${NC}"
exit 1
fi
# Check for .env
if [ ! -f ".env" ]; then
echo -e "${RED}Configuration not found. Run ./install.sh first.${NC}"
exit 1
fi
source .env
# Display banner
clear
echo -e "${MAGENTA}"
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ WARP ENGINE - STAGED AGENT CREATION ║"
echo "║ Meta-Tagged Intelligent Code Evolution ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo -e "${NC}"
echo -e "${CYAN}This system features:${NC}"
echo " • ${GREEN}Prompt Refinement${NC} - Transforms raw prompts into perfect instructions"
echo " • ${GREEN}Staging System${NC} - Meta-tags every step for understanding"
echo " • ${GREEN}Code Injection${NC} - Smart markers for mechanical evolution"
echo " • ${GREEN}Meta Lookup${NC} - Knows exactly where everything is"
echo ""
echo -e "${YELLOW}The protocol is limited to 3 prompts per agent (plan/execute/refine)${NC}"
echo -e "${YELLOW}All processing is local and deterministic${NC}"
echo ""
# Main function
case "${1:-}" in
create)
echo -e "${GREEN}📝 Enter your agent request:${NC}"
echo -e "${CYAN}(Describe what you want the agent to do in natural language)${NC}"
echo ""
read -r -p "> " USER_PROMPT
echo ""
echo -e "${BLUE}Processing your request...${NC}"
echo ""
python3 -c "
import sys
sys.path.insert(0, 'src')
from warpengine.agent_builder.enhanced_generator import EnhancedAgentBuilder
builder = EnhancedAgentBuilder()
user_prompt = '''$USER_PROMPT'''
try:
print('🚀 Creating agent with staging and refinement...\n')
slug = builder.create_agent_with_staging(
user_prompt=user_prompt,
show_refinement=True
)
print(f'\n✅ Agent created successfully!')
print(f' Name: {slug}')
print(f' Location: src/warpengine/agents/{slug}/')
print(f' Binary: ./bin/{slug}')
print(f'\nRun your agent:')
print(f' echo \"your input\" | ./bin/{slug}')
except Exception as e:
print(f'❌ Error: {e}')
"
;;
analyze)
AGENT="${2:-}"
if [ -z "$AGENT" ]; then
echo -e "${RED}Usage: $0 analyze <agent_slug>${NC}"
exit 1
fi
echo -e "${BLUE}Analyzing agent: $AGENT${NC}"
echo ""
python3 -c "
import sys
sys.path.insert(0, 'src')
from warpengine.staging import StageManager, MetaLookupSystem
from warpengine.registry.registry import get_agent
agent_slug = '$AGENT'
# Get agent from registry
agent = get_agent(agent_slug)
if not agent:
print(f'❌ Agent not found: {agent_slug}')
sys.exit(1)
print(f'📦 Agent: {agent[\"name\"]}')
print(f' Slug: {agent_slug}')
print(f' Type: {agent.get(\"type\", \"unknown\")}')
print(f' Description: {agent.get(\"description\", \"No description\")}')
# Get staging history
stage_manager = StageManager()
stages = stage_manager.get_agent_stages(agent_slug)
print(f'\n📊 Staging History:')
if stages:
for stage in stages:
print(f' • {stage.tag.value} ({stage.timestamp})')
else:
print(' No staging history found')
# Analyze code structure
meta_lookup = MetaLookupSystem()
entity = meta_lookup.find_entity(agent_slug, 'agent')
if entity:
print(f'\n📄 Code Analysis:')
print(f' File: {entity.file_path}')
print(f' Lines: {entity.line_end}')
# Check for markers
content = entity.file_path.read_text()
if 'WARP_ENGINE_AGENT_BEGIN' in content:
print(' ✅ Code markers present')
else:
print(' ⚠️ No code markers found')
"
;;
list-stages)
echo -e "${BLUE}📊 All Staging Records:${NC}"
echo ""
python3 -c "
import sys
sys.path.insert(0, 'src')
from warpengine.staging import StageManager
stage_manager = StageManager()
# Get latest stages by type
from warpengine.staging import StageTag
for tag in StageTag:
latest = stage_manager.get_latest_stage(tag)
if latest:
print(f'{tag.value}:')
print(f' ID: {latest.id[:8]}...')
print(f' Time: {latest.timestamp}')
if 'agent_slug' in latest.data:
print(f' Agent: {latest.data[\"agent_slug\"]}')
print()
"
;;
*)
echo "Usage: $0 {create|analyze|list-stages}"
echo ""
echo "Commands:"
echo " create - Create a new agent with staging and refinement"
echo " analyze - Analyze an existing agent's staging history"
echo " list-stages - List all staging records"
echo ""
echo "Examples:"
echo " $0 create"
echo " $0 analyze research_agent"
echo " $0 list-stages"
exit 1
;;
esac