Spaces:
Runtime error
Runtime error
| name: CloudWaddie Agent | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| prompt: | |
| description: "Custom prompt" | |
| required: false | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| agent: | |
| runs-on: ubuntu-latest | |
| environment: sisyphus-env | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'issue_comment' && | |
| contains(github.event.comment.body || '', '@cloudwaddie-ai') && | |
| (github.event.comment.user.login || '') != 'cloudwaddie-ai' && | |
| contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association || '')) | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config user.name "cloudwaddie-ai" | |
| git config user.email "cloudwaddie-ai@users.noreply.github.com" | |
| - name: Setup Runtime | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y --no-install-recommends tmux jq | |
| curl -fsSL https://bun.sh/install | bash | |
| echo "$HOME/.bun/bin" >> $GITHUB_PATH | |
| - name: Clone and Build oh-my-opencode | |
| run: | | |
| export PATH="$HOME/.bun/bin:$PATH" | |
| git clone https://github.com/code-yeongyu/oh-my-opencode.git .tmp-omo | |
| cd .tmp-omo | |
| bun install | |
| bun run build | |
| mv dist ../dist | |
| mv node_modules ../node_modules | |
| mv package.json ../package.json | |
| cd .. | |
| rm -rf .tmp-omo | |
| - name: Setup OpenCode & Copilot | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| export PATH="$HOME/.bun/bin:$HOME/.opencode/bin:$PATH" | |
| # Install OpenCode CLI | |
| curl -fsSL https://opencode.ai/install | bash | |
| echo "$HOME/.opencode/bin" >> $GITHUB_PATH | |
| # Initialize Config | |
| bun run dist/cli/index.js install --no-tui --gemini=no --chatgpt=no --claude=no | |
| CONFIG_PATH=~/.config/opencode/opencode.json | |
| OMO_CONFIG=~/.config/opencode/oh-my-opencode.json | |
| # Setup Copilot Provider with the Token directly in config | |
| jq --arg token "$GH_TOKEN" '.provider = { | |
| "github-copilot": { | |
| "name": "GitHub Copilot", | |
| "npm": "@opencode-ai/provider-github-copilot", | |
| "options": { "token": $token } | |
| } | |
| } | .model = "github-copilot/gemini-3-flash-preview"' "$CONFIG_PATH" > "$CONFIG_PATH.tmp" && mv "$CONFIG_PATH.tmp" "$CONFIG_PATH" | |
| # Assign agents to requested models | |
| jq '.agents.Sisyphus.model = "github-copilot/gemini-3-flash-preview" | | |
| .agents.Oracle.model = "opencode/grok-code" | | |
| .agents.Librarian.model = "opencode/big-pickle"' \ | |
| "$OMO_CONFIG" > "$OMO_CONFIG.tmp" && mv "$OMO_CONFIG.tmp" "$OMO_CONFIG" | |
| - name: Collect Context | |
| id: context | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| ISSUE_NUM="${{ github.event.issue.number }}" | |
| REPO="${{ github.repository }}" | |
| ISSUE_DATA=$(gh api "repos/$REPO/issues/${ISSUE_NUM}") | |
| echo "type=$(echo "$ISSUE_DATA" | jq -e '.pull_request' > /dev/null && echo 'pr' || echo 'issue')" >> $GITHUB_OUTPUT | |
| echo "number=$ISSUE_NUM" >> $GITHUB_OUTPUT | |
| echo "title=$(echo "$ISSUE_DATA" | jq -r '.title')" >> $GITHUB_OUTPUT | |
| echo "author=${{ github.event.comment.user.login }}" >> $GITHUB_OUTPUT | |
| echo "comment_id=${{ github.event.comment.id }}" >> $GITHUB_OUTPUT | |
| echo "comment<<EOF" >> $GITHUB_OUTPUT | |
| echo "${{ github.event.comment.body }}" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Feedback (Eyes) | |
| if: steps.context.outputs.comment_id != '' | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \ | |
| -X POST -f content="eyes" || true | |
| - name: Run CloudWaddie Agent & Post Reply | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| export PATH="$HOME/.opencode/bin:$HOME/.bun/bin:$PATH" | |
| PROMPT=$(cat <<'EOF' | |
| <ultrawork-mode> | |
| [CODE RED] You are @cloudwaddie-ai. | |
| ## MODEL CONFIG | |
| - Main engine: github-copilot/gemini-3-flash-preview | |
| - Sub-agents: Grok Code / Big Pickle | |
| ## RULES | |
| - You are running in a GitHub Action. | |
| - Your response will be posted as a GitHub comment. | |
| - Deliver FULL implementations. | |
| </ultrawork-mode> | |
| --- | |
| Context: ${{ steps.context.outputs.title }} (#${{ steps.context.outputs.number }}) | |
| User Request: ${{ steps.context.outputs.comment }} | |
| EOF | |
| ) | |
| # 1. Capture agent output to a file | |
| # stdbuf ensures we don't miss output due to buffering | |
| stdbuf -oL -eL bun run dist/cli/index.js run "$PROMPT" > agent_reply.md 2>&1 | |
| # 2. Post that file as a comment on the Issue/PR | |
| # We use a heredoc pattern to safely handle multiline markdown | |
| gh issue comment ${{ steps.context.outputs.number }} --body-file agent_reply.md | |
| - name: Feedback (Done) | |
| if: always() | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| if [[ -n "${{ steps.context.outputs.comment_id }}" ]]; then | |
| gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \ | |
| -X POST -f content="+1" || true | |
| fi | |