Change Recipes Test Script (#5457)
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
version: 1.0.0
|
||||||
|
title: Project Analyzer
|
||||||
|
description: Analyze project codebase using parallel subrecipes for file statistics and code patterns
|
||||||
|
instructions: You are a code analysis assistant that examines project structure and code patterns.
|
||||||
|
parameters:
|
||||||
|
- key: target_directory
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "."
|
||||||
|
description: "Directory to analyze"
|
||||||
|
- key: include_tests
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "true"
|
||||||
|
description: "Whether to include test files in analysis"
|
||||||
|
prompt: |
|
||||||
|
Run two subrecipes sequentially:
|
||||||
|
- use file_stats subrecipe to gather file statistics for {{ target_directory }}
|
||||||
|
- use code_patterns subrecipe to analyze code patterns in {{ target_directory }}
|
||||||
|
extensions:
|
||||||
|
- type: builtin
|
||||||
|
name: developer
|
||||||
|
timeout: 300
|
||||||
|
bundled: true
|
||||||
|
sub_recipes:
|
||||||
|
- name: file_stats
|
||||||
|
path: "./subrecipes/file_stats.yaml"
|
||||||
|
values:
|
||||||
|
directory: "{{ target_directory }}"
|
||||||
|
fast_mode: "true"
|
||||||
|
- name: code_patterns
|
||||||
|
path: "./subrecipes/code_patterns.yaml"
|
||||||
|
values:
|
||||||
|
directory: "{{ target_directory }}"
|
||||||
|
include_tests: "{{ include_tests }}"
|
||||||
|
fast_mode: "true"
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
version: 1.0.0
|
||||||
|
title: Project Analyzer (Parallel)
|
||||||
|
description: Analyze project codebase using parallel subrecipes for file statistics and code patterns
|
||||||
|
instructions: You are a code analysis assistant that examines project structure and code patterns.
|
||||||
|
parameters:
|
||||||
|
- key: target_directory
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "."
|
||||||
|
description: "Directory to analyze"
|
||||||
|
- key: include_tests
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "true"
|
||||||
|
description: "Whether to include test files in analysis"
|
||||||
|
prompt: |
|
||||||
|
Run two subrecipes in parallel:
|
||||||
|
- use file_stats subrecipe to gather file statistics for {{ target_directory }}
|
||||||
|
- use code_patterns subrecipe to analyze code patterns in {{ target_directory }}
|
||||||
|
extensions:
|
||||||
|
- type: builtin
|
||||||
|
name: developer
|
||||||
|
timeout: 300
|
||||||
|
bundled: true
|
||||||
|
sub_recipes:
|
||||||
|
- name: file_stats
|
||||||
|
path: "./subrecipes/file_stats.yaml"
|
||||||
|
values:
|
||||||
|
directory: "{{ target_directory }}"
|
||||||
|
fast_mode: "true"
|
||||||
|
- name: code_patterns
|
||||||
|
path: "./subrecipes/code_patterns.yaml"
|
||||||
|
values:
|
||||||
|
directory: "{{ target_directory }}"
|
||||||
|
include_tests: "{{ include_tests }}"
|
||||||
|
fast_mode: "true"
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
version: "1.0.0"
|
|
||||||
title: "Activity Recommender"
|
|
||||||
description: "Suggest activities based on weather conditions"
|
|
||||||
instructions: |
|
|
||||||
You are a travel expert. Recommend appropriate activities and attractions
|
|
||||||
based on current weather conditions.
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
- key: weather_conditions
|
|
||||||
input_type: string
|
|
||||||
requirement: required
|
|
||||||
description: "Current weather conditions to base recommendations on"
|
|
||||||
|
|
||||||
extensions:
|
|
||||||
- type: builtin
|
|
||||||
name: developer
|
|
||||||
timeout: 300
|
|
||||||
bundled: true
|
|
||||||
|
|
||||||
prompt: |
|
|
||||||
Based on these weather conditions: {{ weather_conditions }},
|
|
||||||
suggest appropriate activities, attractions, and travel tips.
|
|
||||||
Include both indoor and outdoor options as relevant.
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
version: 1.0.0
|
||||||
|
title: Code Pattern Analyzer
|
||||||
|
description: Analyze code patterns and structures in source files
|
||||||
|
instructions: You are a code pattern analyzer that searches for common programming patterns and constructs.
|
||||||
|
parameters:
|
||||||
|
- key: directory
|
||||||
|
input_type: string
|
||||||
|
requirement: required
|
||||||
|
description: "Directory to analyze"
|
||||||
|
- key: include_tests
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "true"
|
||||||
|
description: "Whether to include test files"
|
||||||
|
- key: fast_mode
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "true"
|
||||||
|
description: "Use fast single-command mode for CI"
|
||||||
|
prompt: |
|
||||||
|
{% if fast_mode == "true" %}
|
||||||
|
Write code_patterns.json with a single shell command:
|
||||||
|
|
||||||
|
cat > code_patterns.json << 'JSON'
|
||||||
|
{"todos":[{"file":"README.md","line":3,"text":"Add more tests"}],"function_count":2,"import_count":0,"test_count":2,"files_analyzed":3}
|
||||||
|
JSON
|
||||||
|
|
||||||
|
Use a single tool call. Do not scan the filesystem.
|
||||||
|
{% else %}
|
||||||
|
Analyze source code files in {{ directory }} and identify patterns:
|
||||||
|
|
||||||
|
1. Find all TODO/FIXME comments
|
||||||
|
2. Count function/method definitions (look for 'fn ', 'def ', 'function ')
|
||||||
|
3. Find import/use statements
|
||||||
|
4. Identify test functions (names containing 'test')
|
||||||
|
|
||||||
|
Write your findings to a file named code_patterns.json with this structure:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"todos": [
|
||||||
|
{"file": "<path>", "line": <number>, "text": "<comment>"}
|
||||||
|
],
|
||||||
|
"function_count": <number>,
|
||||||
|
"import_count": <number>,
|
||||||
|
"test_count": <number>,
|
||||||
|
"files_analyzed": <number>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use grep and other shell tools to find these patterns efficiently.
|
||||||
|
Only analyze source code files (.rs, .py, .js, .go, etc.), skip binaries and build artifacts.
|
||||||
|
{% if include_tests == "true" %}
|
||||||
|
Include test files (those with 'test' in the name) in your analysis.
|
||||||
|
{% else %}
|
||||||
|
Exclude test files from your analysis.
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
extensions:
|
||||||
|
- type: builtin
|
||||||
|
name: developer
|
||||||
|
timeout: 300
|
||||||
|
bundled: true
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
version: 1.0.0
|
||||||
|
title: File Statistics Analyzer
|
||||||
|
description: Gather comprehensive file statistics from a directory
|
||||||
|
instructions: You are a file system analyzer that gathers detailed statistics about files in a directory.
|
||||||
|
parameters:
|
||||||
|
- key: directory
|
||||||
|
input_type: string
|
||||||
|
requirement: required
|
||||||
|
description: "Directory to analyze"
|
||||||
|
- key: fast_mode
|
||||||
|
input_type: string
|
||||||
|
requirement: optional
|
||||||
|
default: "true"
|
||||||
|
description: "Use fast single-command mode for CI"
|
||||||
|
prompt: |
|
||||||
|
{% if fast_mode == "true" %}
|
||||||
|
Write file_stats.json with a single shell command:
|
||||||
|
|
||||||
|
cat > file_stats.json << 'JSON'
|
||||||
|
{"total_files":3,"files_by_extension":{".rs":1,".py":1,".md":1},"total_lines":50,"total_size_bytes":1500,"largest_file":{"path":"sample.rs","size_bytes":600},"smallest_file":{"path":"README.md","size_bytes":200}}
|
||||||
|
JSON
|
||||||
|
|
||||||
|
Use a single tool call. Do not scan the filesystem.
|
||||||
|
{% else %}
|
||||||
|
Analyze {{ directory }} and generate file statistics:
|
||||||
|
|
||||||
|
1. Count total files by extension (.rs, .yaml, .md, .toml, etc.)
|
||||||
|
2. Calculate total lines of code across all text files
|
||||||
|
3. Determine total file sizes
|
||||||
|
4. Find the largest and smallest files
|
||||||
|
|
||||||
|
Write your findings to a file named file_stats.json with this structure:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"total_files": <number>,
|
||||||
|
"files_by_extension": {
|
||||||
|
".rs": <count>,
|
||||||
|
".yaml": <count>,
|
||||||
|
...
|
||||||
|
},
|
||||||
|
"total_lines": <number>,
|
||||||
|
"total_size_bytes": <number>,
|
||||||
|
"largest_file": {
|
||||||
|
"path": "<path>",
|
||||||
|
"size_bytes": <number>
|
||||||
|
},
|
||||||
|
"smallest_file": {
|
||||||
|
"path": "<path>",
|
||||||
|
"size_bytes": <number>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use shell commands like find, wc, and du to gather this data efficiently.
|
||||||
|
{% endif %}
|
||||||
|
extensions:
|
||||||
|
- type: builtin
|
||||||
|
name: developer
|
||||||
|
timeout: 300
|
||||||
|
bundled: true
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
version: "1.0.0"
|
|
||||||
title: "Weather Data Collector"
|
|
||||||
description: "Fetch current weather conditions for a location"
|
|
||||||
instructions: |
|
|
||||||
You are a weather data specialist. Gather current weather information
|
|
||||||
including temperature, conditions, and seasonal context.
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
- key: location
|
|
||||||
input_type: string
|
|
||||||
requirement: required
|
|
||||||
description: "City or location to get weather data for"
|
|
||||||
|
|
||||||
extensions:
|
|
||||||
- type: builtin
|
|
||||||
name: developer
|
|
||||||
timeout: 300
|
|
||||||
bundled: true
|
|
||||||
|
|
||||||
prompt: |
|
|
||||||
Get the current weather conditions for {{ location }}.
|
|
||||||
Include temperature, weather conditions (sunny, rainy, etc.),
|
|
||||||
and any relevant seasonal information.
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
version: "1.0.0"
|
|
||||||
title: "Travel Activity Planner"
|
|
||||||
description: "Get weather data and suggest appropriate activities"
|
|
||||||
instructions: |
|
|
||||||
Plan activities by first getting weather data, then suggesting activities based on conditions.
|
|
||||||
|
|
||||||
prompt: |
|
|
||||||
Plan activities for Sydney by first getting weather data, then suggesting activities based on the weather conditions we receive.
|
|
||||||
|
|
||||||
sub_recipes:
|
|
||||||
- name: weather_data
|
|
||||||
path: "{{ recipe_dir }}/subrecipes/weather-data.yaml"
|
|
||||||
# No values - location parameter comes from prompt context
|
|
||||||
|
|
||||||
- name: activity_suggestions
|
|
||||||
path: "{{ recipe_dir }}/subrecipes/activity-suggestions.yaml"
|
|
||||||
# weather_conditions parameter comes from conversation context
|
|
||||||
|
|
||||||
extensions:
|
|
||||||
- type: builtin
|
|
||||||
name: developer
|
|
||||||
timeout: 300
|
|
||||||
bundled: true
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
version: "1.0.0"
|
|
||||||
title: "Travel Activity Planner (Parallel)"
|
|
||||||
description: "Get weather data and suggest activities in parallel"
|
|
||||||
instructions: |
|
|
||||||
Plan activities by getting weather data and activity suggestions in parallel to save time.
|
|
||||||
|
|
||||||
prompt: |
|
|
||||||
Run the following subrecipes in parallel to plan activities for Sydney:
|
|
||||||
- use weather_data subrecipe to get the weather for Sydney
|
|
||||||
- use activity_suggestions subrecipe to suggest activities for overcast, cool weather
|
|
||||||
|
|
||||||
sub_recipes:
|
|
||||||
- name: weather_data
|
|
||||||
path: "{{ recipe_dir }}/subrecipes/weather-data.yaml"
|
|
||||||
|
|
||||||
- name: activity_suggestions
|
|
||||||
path: "{{ recipe_dir }}/subrecipes/activity-suggestions.yaml"
|
|
||||||
|
|
||||||
extensions:
|
|
||||||
- type: builtin
|
|
||||||
name: developer
|
|
||||||
timeout: 300
|
|
||||||
bundled: true
|
|
||||||
+41
-34
@@ -20,8 +20,9 @@ SCRIPT_DIR=$(pwd)
|
|||||||
export PATH="$SCRIPT_DIR/target/release:$PATH"
|
export PATH="$SCRIPT_DIR/target/release:$PATH"
|
||||||
|
|
||||||
# Set default provider and model if not already set
|
# Set default provider and model if not already set
|
||||||
|
# Use fast model for CI to speed up tests
|
||||||
export GOOSE_PROVIDER="${GOOSE_PROVIDER:-anthropic}"
|
export GOOSE_PROVIDER="${GOOSE_PROVIDER:-anthropic}"
|
||||||
export GOOSE_MODEL="${GOOSE_MODEL:-claude-sonnet-4-5-20250929}"
|
export GOOSE_MODEL="${GOOSE_MODEL:-claude-3-5-haiku-20241022}"
|
||||||
|
|
||||||
echo "Using provider: $GOOSE_PROVIDER"
|
echo "Using provider: $GOOSE_PROVIDER"
|
||||||
echo "Using model: $GOOSE_MODEL"
|
echo "Using model: $GOOSE_MODEL"
|
||||||
@@ -35,7 +36,39 @@ echo "Copied test recipes from scripts/test-subrecipes-examples"
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Testing Subrecipe Workflow ==="
|
echo "=== Testing Subrecipe Workflow ==="
|
||||||
echo "Recipe: $TESTDIR/travel_planner.yaml"
|
echo "Recipe: $TESTDIR/project_analyzer.yaml"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Create sample code files for analysis
|
||||||
|
echo "Creating sample code files for testing..."
|
||||||
|
cat > "$TESTDIR/sample.rs" << 'EOF'
|
||||||
|
// TODO: Add error handling
|
||||||
|
fn calculate(x: i32, y: i32) -> i32 {
|
||||||
|
x + y
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_calculate() {
|
||||||
|
assert_eq!(calculate(2, 2), 4);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$TESTDIR/sample.py" << 'EOF'
|
||||||
|
# FIXME: Optimize this function
|
||||||
|
def process_data(items):
|
||||||
|
"""Process a list of items"""
|
||||||
|
return [item * 2 for item in items]
|
||||||
|
|
||||||
|
def test_process_data():
|
||||||
|
assert process_data([1, 2, 3]) == [2, 4, 6]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$TESTDIR/README.md" << 'EOF'
|
||||||
|
# Sample Project
|
||||||
|
This is a test project for analyzing code patterns.
|
||||||
|
## TODO
|
||||||
|
- Add more tests
|
||||||
|
EOF
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
RESULTS=()
|
RESULTS=()
|
||||||
@@ -52,8 +85,8 @@ check_recipe_output() {
|
|||||||
RESULTS+=("✗ Subrecipe tool invocation ($mode)")
|
RESULTS+=("✗ Subrecipe tool invocation ($mode)")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "weather_data" "$tmpfile" && grep -q "activity_suggestions" "$tmpfile"; then
|
if grep -q "file_stats" "$tmpfile" && grep -q "code_patterns" "$tmpfile"; then
|
||||||
echo "✓ SUCCESS: Both subrecipes (weather_data, activity_suggestions) found in output"
|
echo "✓ SUCCESS: Both subrecipes (file_stats, code_patterns) found in output"
|
||||||
RESULTS+=("✓ Both subrecipes present ($mode)")
|
RESULTS+=("✓ Both subrecipes present ($mode)")
|
||||||
else
|
else
|
||||||
echo "✗ FAILED: Not all subrecipes found in output"
|
echo "✗ FAILED: Not all subrecipes found in output"
|
||||||
@@ -69,37 +102,11 @@ check_recipe_output() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Test 1: Running recipe with session..."
|
echo "Running recipe with parallel subrecipes..."
|
||||||
TMPFILE=$(mktemp)
|
TMPFILE=$(mktemp)
|
||||||
if (cd "$TESTDIR" && "$SCRIPT_DIR/target/release/goose" run --recipe travel_planner.yaml 2>&1) | tee "$TMPFILE"; then
|
if (cd "$TESTDIR" && "$SCRIPT_DIR/target/release/goose" run --recipe project_analyzer_parallel.yaml --no-session 2>&1) | tee "$TMPFILE"; then
|
||||||
echo "✓ SUCCESS: Recipe completed successfully"
|
echo "✓ SUCCESS: Recipe completed successfully"
|
||||||
RESULTS+=("✓ Recipe exit code (with session)")
|
RESULTS+=("✓ Recipe exit code")
|
||||||
check_recipe_output "$TMPFILE" "with session"
|
|
||||||
else
|
|
||||||
echo "✗ FAILED: Recipe execution failed"
|
|
||||||
RESULTS+=("✗ Recipe exit code (with session)")
|
|
||||||
fi
|
|
||||||
rm "$TMPFILE"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "Test 2: Running recipe in --no-session mode..."
|
|
||||||
TMPFILE=$(mktemp)
|
|
||||||
if (cd "$TESTDIR" && "$SCRIPT_DIR/target/release/goose" run --recipe travel_planner.yaml --no-session 2>&1) | tee "$TMPFILE"; then
|
|
||||||
echo "✓ SUCCESS: Recipe completed successfully"
|
|
||||||
RESULTS+=("✓ Recipe exit code (--no-session)")
|
|
||||||
check_recipe_output "$TMPFILE" "--no-session"
|
|
||||||
else
|
|
||||||
echo "✗ FAILED: Recipe execution failed"
|
|
||||||
RESULTS+=("✗ Recipe exit code (--no-session)")
|
|
||||||
fi
|
|
||||||
rm "$TMPFILE"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "Test 3: Running recipe with parallel subrecipes..."
|
|
||||||
TMPFILE=$(mktemp)
|
|
||||||
if (cd "$TESTDIR" && "$SCRIPT_DIR/target/release/goose" run --recipe travel_planner_parallel.yaml 2>&1) | tee "$TMPFILE"; then
|
|
||||||
echo "✓ SUCCESS: Recipe completed successfully"
|
|
||||||
RESULTS+=("✓ Recipe exit code (parallel)")
|
|
||||||
check_recipe_output "$TMPFILE" "parallel"
|
check_recipe_output "$TMPFILE" "parallel"
|
||||||
|
|
||||||
if grep -q "execution_mode: parallel" "$TMPFILE"; then
|
if grep -q "execution_mode: parallel" "$TMPFILE"; then
|
||||||
@@ -111,7 +118,7 @@ if (cd "$TESTDIR" && "$SCRIPT_DIR/target/release/goose" run --recipe travel_plan
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "✗ FAILED: Recipe execution failed"
|
echo "✗ FAILED: Recipe execution failed"
|
||||||
RESULTS+=("✗ Recipe exit code (parallel)")
|
RESULTS+=("✗ Recipe exit code")
|
||||||
fi
|
fi
|
||||||
rm "$TMPFILE"
|
rm "$TMPFILE"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user