Add skills

This commit is contained in:
2026-03-22 23:21:49 +02:00
parent 4cbbbae1ef
commit c09d9151ca
104 changed files with 23879 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
{
"skill_name": "skill-migrator",
"evals": [
{
"id": 1,
"name": "basic-non-interactive-migration",
"prompt": "Migrate all skills from ~/.agents to the global opencode skills directory without any interactive prompts. Use the skill-migrator skill.",
"expected_output": "The agent should use the migrate.sh script with --all and --yes flags to perform a non-interactive migration. No prompts should be displayed.",
"assertions": [
"Agent identifies the correct script path",
"Agent uses --all flag to select all skills",
"Agent uses --yes flag to auto-confirm",
"Migration completes without interactive prompts"
]
},
{
"id": 2,
"name": "migration-with-conflict-resolution",
"prompt": "Migrate skills from ~/.agents to the global skills directory. Some skills may already exist at the destination. Use the skill-migrator to handle conflicts by skipping existing skills automatically.",
"expected_output": "The agent should use --conflict-strategy skip to automatically handle conflicts without prompting.",
"assertions": [
"Agent uses --conflict-strategy skip flag",
"Agent includes --all and --yes for non-interactive mode",
"Existing skills are skipped without prompts"
]
},
{
"id": 3,
"name": "dry-run-preview",
"prompt": "Preview what would be migrated from ~/.agents without actually making any changes. Show what skills would be migrated and how conflicts would be handled.",
"expected_output": "The agent should use --dry-run flag to preview changes without making them.",
"assertions": [
"Agent uses --dry-run flag",
"Agent may also use --all to preview all skills",
"No actual file changes are made",
"Preview output shows discovered skills"
]
},
{
"id": 4,
"name": "local-project-installation",
"prompt": "Migrate skills from ~/.agents to the local project directory (.opencode/skills/) instead of the global directory. Make it non-interactive.",
"expected_output": "The agent should use --local flag along with non-interactive flags.",
"assertions": [
"Agent uses --local flag",
"Agent uses --all and --yes for non-interactive mode",
"Target directory is the local .opencode/skills/ directory"
]
},
{
"id": 5,
"name": "backup-conflict-strategy",
"prompt": "Migrate skills from ~/.agents. If any skills already exist, create backups of the existing ones before overwriting them. Do this without any prompts.",
"expected_output": "The agent should use --conflict-strategy backup to create backups before overwriting.",
"assertions": [
"Agent uses --conflict-strategy backup",
"Agent includes --all and --yes",
"Existing skills are backed up with timestamps"
]
}
]
}

View File

@@ -0,0 +1,231 @@
#!/bin/bash
#
# Skill Migrator Test Script
# Tests the non-interactive mode functionality
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MIGRATE_SCRIPT="$HOME/.config/opencode/skills/skill-migrator/scripts/migrate.sh"
TEST_DIR="$HOME/.agents-test"
echo "========================================"
echo " SKILL MIGRATOR TEST SUITE"
echo "========================================"
echo ""
# Setup: Create test skills
setup_test_env() {
echo "Setting up test environment..."
rm -rf "$TEST_DIR"
mkdir -p "$TEST_DIR"
# Create a test skill
mkdir -p "$TEST_DIR/test-skill-1"
cat > "$TEST_DIR/test-skill-1/SKILL.md" << 'EOF'
---
name: test-skill-1
description: Test skill 1 for migration testing
---
# Test Skill 1
This is a test skill.
EOF
# Create another test skill
mkdir -p "$TEST_DIR/test-skill-2"
cat > "$TEST_DIR/test-skill-2/SKILL.md" << 'EOF'
---
name: test-skill-2
description: Test skill 2 for migration testing
---
# Test Skill 2
This is another test skill.
EOF
echo "✓ Test environment created"
echo ""
}
# Test 1: Basic non-interactive migration
test_basic_migration() {
echo "Test 1: Basic Non-Interactive Migration"
echo "----------------------------------------"
# Clean target
rm -rf "$HOME/.config/opencode/skills/test-skill-1"
rm -rf "$HOME/.config/opencode/skills/test-skill-2"
# Run migration with non-interactive flags
if "$MIGRATE_SCRIPT" "$TEST_DIR" --all --yes; then
echo "✓ Migration completed successfully"
else
echo "✗ Migration failed"
return 1
fi
# Verify skills were migrated
if [[ -d "$HOME/.config/opencode/skills/test-skill-1" && -d "$HOME/.config/opencode/skills/test-skill-2" ]]; then
echo "✓ Skills migrated to correct location"
else
echo "✗ Skills not found in target directory"
return 1
fi
echo ""
}
# Test 2: Skip conflict strategy
test_skip_strategy() {
echo "Test 2: Skip Conflict Strategy"
echo "-------------------------------"
# Modify source skill
echo "# Modified" >> "$TEST_DIR/test-skill-1/SKILL.md"
# Run migration with skip strategy
if "$MIGRATE_SCRIPT" "$TEST_DIR" --all --yes --conflict-strategy skip; then
echo "✓ Migration with skip strategy completed"
else
echo "✗ Migration failed"
return 1
fi
# Verify original skill was NOT overwritten
if ! grep -q "# Modified" "$HOME/.config/opencode/skills/test-skill-1/SKILL.md"; then
echo "✓ Existing skill was skipped (not overwritten)"
else
echo "✗ Existing skill was overwritten (should have been skipped)"
return 1
fi
echo ""
}
# Test 3: Overwrite conflict strategy
test_overwrite_strategy() {
echo "Test 3: Overwrite Conflict Strategy"
echo "------------------------------------"
# Run migration with overwrite strategy
if "$MIGRATE_SCRIPT" "$TEST_DIR" --all --yes --conflict-strategy overwrite; then
echo "✓ Migration with overwrite strategy completed"
else
echo "✗ Migration failed"
return 1
fi
# Verify skill WAS overwritten
if grep -q "# Modified" "$HOME/.config/opencode/skills/test-skill-1/SKILL.md"; then
echo "✓ Existing skill was overwritten"
else
echo "✗ Existing skill was not overwritten"
return 1
fi
echo ""
}
# Test 4: Backup conflict strategy
test_backup_strategy() {
echo "Test 4: Backup Conflict Strategy"
echo "---------------------------------"
# Run migration with backup strategy
if "$MIGRATE_SCRIPT" "$TEST_DIR" --all --yes --conflict-strategy backup; then
echo "✓ Migration with backup strategy completed"
else
echo "✗ Migration failed"
return 1
fi
# Verify backup was created
if ls "$HOME/.config/opencode/skills/test-skill-1.backup."* 1> /dev/null 2>&1; then
echo "✓ Backup was created"
else
echo "✗ Backup not found"
return 1
fi
echo ""
}
# Test 5: Dry run
test_dry_run() {
echo "Test 5: Dry Run Mode"
echo "---------------------"
# Create a new test skill that doesn't exist yet
mkdir -p "$TEST_DIR/test-skill-3"
cat > "$TEST_DIR/test-skill-3/SKILL.md" << 'EOF'
---
name: test-skill-3
description: Test skill 3 for dry run testing
---
# Test Skill 3
This skill should not be migrated in dry run.
EOF
# Run migration with dry-run
if "$MIGRATE_SCRIPT" "$TEST_DIR" --all --dry-run; then
echo "✓ Dry run completed"
else
echo "✗ Dry run failed"
return 1
fi
# Verify skill was NOT actually migrated
if [[ ! -d "$HOME/.config/opencode/skills/test-skill-3" ]]; then
echo "✓ Dry run correctly made no changes"
else
echo "✗ Skill was migrated (should not happen in dry run)"
return 1
fi
echo ""
}
# Cleanup
cleanup() {
echo "Cleaning up..."
rm -rf "$TEST_DIR"
rm -rf "$HOME/.config/opencode/skills/test-skill-1"
rm -rf "$HOME/.config/opencode/skills/test-skill-2"
rm -rf "$HOME/.config/opencode/skills/test-skill-3"
rm -f "$HOME/.config/opencode/skills/test-skill-1.backup."*
echo "✓ Cleanup complete"
echo ""
}
# Run all tests
main() {
setup_test_env
local failed=0
test_basic_migration || ((failed++))
test_skip_strategy || ((failed++))
test_overwrite_strategy || ((failed++))
test_backup_strategy || ((failed++))
test_dry_run || ((failed++))
cleanup
echo "========================================"
echo " TEST RESULTS"
echo "========================================"
if [[ $failed -eq 0 ]]; then
echo "✓ All tests passed!"
exit 0
else
echo "$failed test(s) failed"
exit 1
fi
}
main "$@"