返回 Skill 列表
extension
分类: 开发与工程无需 API Key

detecting-agent-environment

用于检测执行环境(CI/CD与本地、网络访问、可用端口、超时)的工具和模式。当需要根据代理运行的位置调整脚本或工作流,或者在创建需要环境感知行为的帮助脚本时使用。

person作者: jakexiaohubgithub

Agent Helper Scripts

Utilities for GitHub Copilot agents working on Y-Not Radio site.

Environment Detection

Use detect-environment.sh to adapt scripts to different environments:

# Source the utility
source bin/agent-helpers/detect-environment.sh

# Print environment info
print_environment

# Check environment
if detect_ci; then
  echo "Running in CI/CD"
  # Use optimized workflow
fi

if ! detect_network; then
  echo "Network restricted - cannot pull packages"
  exit 1
fi

# Get appropriate timeout
TIMEOUT=$(get_timeout "service_ready")
timeout $TIMEOUT bash -c 'until service_ready; do sleep 5; done'

Creating New Helper Scripts

When creating helper scripts:

  1. Source environment detection

    source "$(dirname "$0")/detect-environment.sh"
    print_environment
    
  2. Use appropriate timeouts

    TIMEOUT=$(get_timeout "npm_install")
    timeout $TIMEOUT npm install
    
  3. Provide clear output

    echo "✅ Success message"
    echo "⚠️  Warning message"
    echo "❌ Error message"
    
  4. Exit with proper codes

    exit 0  # Success
    exit 1  # Failure
    
  5. Log to .agent-tmp/

    mkdir -p .agent-tmp
    command 2>&1 | tee .agent-tmp/command.log
    

Related Skills

Before creating scripts or PRs, see:

  • testing-pr-changes skill - Success criteria and testing workflows
  • agent-automation-infrastructure skill - Current automation state and pre-built images

Performance Baselines

Scripts should respect these baselines:

| Operation | Expected | Warning | Failure | |-----------|----------|---------|---------| | Container start | < 60s | 60-120s | > 120s | | npm install | < 120s | 120-300s | > 300s | | Service ready | < 180s | 180-360s | > 360s |

If exceeding "Warning" thresholds, report performance issues in PR.