- README with usage instructions - Gitea Action to handle issues via SSH to VPS - Supports skill hints in issue body (skill: role-pa, etc) - Labels: urgent, research, writing, code, waiting
75 lines
2.7 KiB
YAML
75 lines
2.7 KiB
YAML
name: Handle Issue with mAi
|
|
|
|
on:
|
|
issues:
|
|
types: [opened, labeled]
|
|
|
|
jobs:
|
|
handle-issue:
|
|
runs-on: ubuntu-latest
|
|
if: >
|
|
github.event.action == 'opened' ||
|
|
(github.event.action == 'labeled' && github.event.label.name == 'urgent')
|
|
|
|
steps:
|
|
- name: Process issue with mAi
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.VPS_HOST }}
|
|
username: ${{ secrets.VPS_USER }}
|
|
key: ${{ secrets.VPS_SSH_KEY }}
|
|
port: ${{ secrets.VPS_PORT }}
|
|
script: |
|
|
# Source environment
|
|
source ~/.config/mai/gitea.env
|
|
export PATH="$HOME/.nix-profile/bin:$HOME/.local/bin:$PATH"
|
|
|
|
# Issue details
|
|
REPO="${{ github.repository }}"
|
|
ISSUE_NUMBER="${{ github.event.issue.number }}"
|
|
ISSUE_TITLE="${{ github.event.issue.title }}"
|
|
|
|
# Comment that we're starting
|
|
curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"body":"🤖 mAi is on it..."}' \
|
|
"$GITEA_URL/api/v1/repos/$REPO/issues/$ISSUE_NUMBER/comments"
|
|
|
|
# Add in-progress label
|
|
curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"labels":["in-progress"]}' \
|
|
"$GITEA_URL/api/v1/repos/$REPO/issues/$ISSUE_NUMBER/labels" || true
|
|
|
|
# Get full issue body
|
|
ISSUE_BODY=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/issues/$ISSUE_NUMBER" | jq -r '.body // ""')
|
|
|
|
# Extract skill hint if present
|
|
SKILL=$(echo "$ISSUE_BODY" | grep -oP 'skill:\s*\K\S+' | head -1)
|
|
SKILL_PROMPT=""
|
|
if [ -n "$SKILL" ]; then
|
|
SKILL_PROMPT="Use the /$SKILL skill. "
|
|
fi
|
|
|
|
# Run Claude
|
|
cd ~/dev
|
|
claude -p "${SKILL_PROMPT}You are mAi, a personal AI assistant.
|
|
|
|
Work on this task: $REPO#$ISSUE_NUMBER
|
|
Title: $ISSUE_TITLE
|
|
|
|
$ISSUE_BODY
|
|
|
|
Complete the task and post your results as a comment on the issue.
|
|
Use the Gitea API: POST $GITEA_URL/api/v1/repos/$REPO/issues/$ISSUE_NUMBER/comments
|
|
with body: {\"body\": \"your response here\"}
|
|
|
|
When done, remove the in-progress label and add 'done' label." \
|
|
--dangerously-skip-permissions \
|
|
2>&1 | tee -a ~/dev/mAI/worker/action.log
|
|
|
|
# Fallback: remove in-progress if still there
|
|
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/issues/$ISSUE_NUMBER/labels/in-progress" || true
|