-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-prompts.sh
More file actions
executable file
·131 lines (107 loc) · 3.61 KB
/
Copy pathtest-prompts.sh
File metadata and controls
executable file
·131 lines (107 loc) · 3.61 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
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Running OpenCode prompt test suite..."
echo ""
# Check server is running
echo "Checking AFM server..."
if ! curl -s http://localhost:8080/v1/models 2>/dev/null | grep -q "afm"; then
echo "FAILED: AFM server not running on http://localhost:8080"
echo "Start the server with: ./start-afm-server.sh"
exit 1
fi
echo "Server OK"
echo ""
TEST_RESULTS=()
FAILED=0
test_prompt() {
local PROMPT="$1"
local EXPECTED_CMD="$2"
local CATEGORY="$3"
echo "Testing [$CATEGORY]: $PROMPT"
OUTPUT=$(timeout 30 opencode run --model localcode-afm/afm "$PROMPT" 2>&1 || true)
if echo "$OUTPUT" | grep -q "permission requested"; then
if [ -n "$EXPECTED_CMD" ]; then
if echo "$OUTPUT" | grep -q "$EXPECTED_CMD"; then
echo " ✓ Shows approval UI with correct command"
TEST_RESULTS+=("PASS: [$CATEGORY] $PROMPT")
else
echo " ✗ Shows UI but wrong command"
echo " Expected: $EXPECTED_CMD"
TEST_RESULTS+=("FAIL: [$CATEGORY] $PROMPT - wrong command")
((FAILED++))
fi
else
echo " ✓ Shows approval UI"
TEST_RESULTS+=("PASS: [$CATEGORY] $PROMPT")
fi
else
echo " ✗ No approval UI found"
TEST_RESULTS+=("FAIL: [$CATEGORY] $PROMPT - no approval UI")
((FAILED++))
fi
echo ""
}
echo "=== File Operations ==="
test_prompt "list all files in current directory" "find" "file_list"
test_prompt "list python files" "find" "file_filter"
test_prompt "show me the largest files" "find" "file_size"
echo "=== Search Commands ==="
test_prompt "grep for hello in this directory" "grep" "search_grep"
test_prompt "find files named test" "find" "search_find"
echo "=== System Commands ==="
test_prompt "show git status" "git" "system_git"
test_prompt "check if port 8080 is in use" "lsof" "system_port"
echo "=== Count/Stats ==="
test_prompt "count all files in this directory" "find" "count_files"
test_prompt "show line counts for code files" "wc" "count_lines"
echo "=== Simple Commands ==="
test_prompt "echo hello world" "echo" "simple_echo"
echo "=== Raycast Script Tests ==="
echo "Testing Raycast script..."
RAYCAST_SCRIPT="raycast-extension/scripts/lc.sh"
if [ ! -f "$RAYCAST_SCRIPT" ]; then
echo " ✗ Raycast script not found"
exit 1
fi
# Check script has valid metadata header
if ! head -10 "$RAYCAST_SCRIPT" | grep -q "@raycast.schemaVersion 1"; then
echo " ✗ Missing Raycast metadata header"
exit 1
fi
echo " ✓ Script has valid Raycast metadata"
# Test script with echo command (uses server)
OUTPUT=$(bash "$RAYCAST_SCRIPT" "echo hello" 2>&1)
if echo "$OUTPUT" | grep -q "Copied:"; then
echo " ✓ Script returns 'Copied:' confirmation"
else
echo " ✗ Script did not return copy confirmation"
echo " Output: $OUTPUT"
exit 1
fi
# Test with list files prompt
OUTPUT=$(bash "$RAYCAST_SCRIPT" "list all files" 2>&1)
if echo "$OUTPUT" | grep -q "Copied:"; then
echo " ✓ Script works with 'list all files' prompt"
else
echo " ✗ Script failed with 'list all files' prompt"
exit 1
fi
echo ""
echo ""
echo "========================================"
echo "Test Results Summary"
echo "========================================"
for result in "${TEST_RESULTS[@]}"; do
echo "$result"
done
echo ""
echo "Total: $((${#TEST_RESULTS[@]} - FAILED))/${#TEST_RESULTS[@]} passed"
if [ $FAILED -gt 0 ]; then
echo ""
echo "FAILED: $FAILED test(s)"
exit 1
fi
echo ""
echo "All tests passed!"