170 lines
5.6 KiB
YAML
170 lines
5.6 KiB
YAML
name: AI Agent - Development
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
component:
|
|
description: 'Component to develop'
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- web_v2
|
|
- backend
|
|
- common
|
|
|
|
jobs:
|
|
development:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 360 # 6 hours
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python and dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y -qq python3 python3-pip python3-venv jq
|
|
python3 --version
|
|
pip3 --version
|
|
|
|
- name: Set up Flutter (for web_v2)
|
|
if: inputs.component == 'web_v2'
|
|
run: |
|
|
# Install Flutter
|
|
git clone https://github.com/flutter/flutter.git -b stable --depth 1 $HOME/flutter
|
|
export PATH="$HOME/flutter/bin:$PATH"
|
|
echo "$HOME/flutter/bin" >> $GITHUB_PATH
|
|
flutter --version
|
|
flutter doctor
|
|
|
|
- name: Set up Dart (for backend/common)
|
|
if: inputs.component != 'web_v2'
|
|
uses: dart-lang/setup-dart@v1
|
|
with:
|
|
sdk: stable
|
|
|
|
- name: Install Cursor CLI
|
|
run: |
|
|
curl https://cursor.com/install -fsS | bash
|
|
export PATH="$HOME/.cursor/bin:$PATH"
|
|
echo "$HOME/.cursor/bin" >> $GITHUB_PATH
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config --global user.name "AI Agent"
|
|
git config --global user.email "ai-agent@mnemo-cards.com"
|
|
|
|
- name: Install Dependencies (web_v2)
|
|
if: inputs.component == 'web_v2'
|
|
run: |
|
|
cd mnemo_cards_web_v2
|
|
flutter pub get
|
|
|
|
- name: Install Dependencies (backend)
|
|
if: inputs.component == 'backend'
|
|
run: |
|
|
cd mnemo_cards_backend
|
|
dart pub get
|
|
|
|
- name: Install Dependencies (common)
|
|
if: inputs.component == 'common'
|
|
run: |
|
|
cd mnemo_cards_common
|
|
dart pub get
|
|
|
|
- name: Run Development Agent
|
|
env:
|
|
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
|
|
CURSOR_MODEL: ${{ secrets.CURSOR_MODEL }}
|
|
PROJECT_ROOT: ${{ github.workspace }}
|
|
MAX_ITERATIONS: 10
|
|
MAX_RETRIES: 3
|
|
TIMEOUT_HOURS: 6
|
|
run: |
|
|
cd ${{ github.workspace }}
|
|
python3 tools/agent/agent_orchestrator.py ${{ inputs.component }}
|
|
|
|
- name: Create Summary Report
|
|
if: always()
|
|
run: |
|
|
COMPONENT="${{ inputs.component }}"
|
|
STATE_FILE="ai_docs/agent/${COMPONENT}/agent_state.json"
|
|
|
|
echo "# Development Agent Summary" > /tmp/summary.md
|
|
echo "" >> /tmp/summary.md
|
|
echo "**Component:** ${COMPONENT}" >> /tmp/summary.md
|
|
echo "**Started:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> /tmp/summary.md
|
|
echo "" >> /tmp/summary.md
|
|
|
|
if [ -f "$STATE_FILE" ]; then
|
|
echo "## Agent State" >> /tmp/summary.md
|
|
echo "\`\`\`json" >> /tmp/summary.md
|
|
cat "$STATE_FILE" >> /tmp/summary.md
|
|
echo "\`\`\`" >> /tmp/summary.md
|
|
fi
|
|
|
|
cat /tmp/summary.md
|
|
|
|
- name: Check if all tasks completed
|
|
id: check_completion
|
|
run: |
|
|
COMPONENT="${{ inputs.component }}"
|
|
STATE_FILE="ai_docs/agent/${COMPONENT}/agent_state.json"
|
|
TASK_LIST="ai_docs/agent/${COMPONENT}/task_list.json"
|
|
|
|
if [ -f "$STATE_FILE" ] && [ -f "$TASK_LIST" ]; then
|
|
# Check if all tasks are completed
|
|
python3 << 'EOF'
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
component = os.environ.get('COMPONENT', 'unknown')
|
|
state_file = f"ai_docs/agent/{component}/agent_state.json"
|
|
task_list_file = f"ai_docs/agent/{component}/task_list.json"
|
|
|
|
try:
|
|
with open(state_file, 'r') as f:
|
|
state = json.load(f)
|
|
|
|
with open(task_list_file, 'r') as f:
|
|
task_list = json.load(f)
|
|
|
|
tasks = task_list.get('tasks', [])
|
|
pending = [t for t in tasks if t.get('status') == 'pending']
|
|
|
|
# Check if status is completed or no pending tasks
|
|
if state.get('status') == 'completed' or len(pending) == 0:
|
|
print("all_completed=true")
|
|
else:
|
|
print("all_completed=false")
|
|
except Exception as e:
|
|
print(f"Error: {e}", file=sys.stderr)
|
|
print("all_completed=false")
|
|
EOF
|
|
else
|
|
echo "all_completed=false"
|
|
fi > /tmp/completion_status.txt
|
|
|
|
cat /tmp/completion_status.txt >> $GITHUB_OUTPUT
|
|
env:
|
|
COMPONENT: ${{ inputs.component }}
|
|
|
|
- name: Trigger Planning Agent (if all completed)
|
|
if: contains(steps.check_completion.outputs.*, 'all_completed=true')
|
|
run: |
|
|
COMPONENT="${{ inputs.component }}"
|
|
|
|
echo "All tasks completed! Triggering planning agent for new tasks..."
|
|
|
|
# Trigger via Forgejo API
|
|
API_URL="${{ github.api_url }}/repos/${{ github.repository }}/actions/workflows/agent-planning.yml/dispatches"
|
|
|
|
curl -X POST "$API_URL" \
|
|
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"ref\":\"master\",\"inputs\":{\"component\":\"$COMPONENT\"}}"
|
|
|