File size: 5,361 Bytes
f10f153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
---
title: A2A-SIN-Code-plugin Agent
sdk: docker
app_port: 7860
pinned: false
---

# A2A-SIN-Code-plugin Agent

**Status:** πŸš€ Production Ready  
**Version:** 1.0.0  
**Team:** Team - Coder  
**Manager:** SIN-Zeus

---

## 🎯 Overview

A2A-SIN-Code-plugin is an **autonomous cloud coder** that receives tasks via A2A protocol and executes them using the `opencode` CLI. It runs on Hugging Face Spaces (CPU-Basic) and works exclusively on the OpenSIN-Code repository.

## πŸš€ Features

- **A2A Protocol:** Full JSON-RPC 2.0 compliance
- **opencode CLI:** Uses Antigravity-powered opencode for all code generation
- **GitHub Integration:** Automatic commits to assigned branches
- **Gradio UI:** Operator dashboard for manual task submission and monitoring
- **Health Checks:** `/health` endpoint for fleet monitoring
- **Type-Specific:** Specialized prompts for plugin tasks

## πŸ—οΈ Architecture

### Request Flow
```
SIN-Zeus β†’ A2A JSON-RPC β†’ Gradio/FastAPI β†’ opencode CLI β†’ GitHub Commit
```

### Components
- **FastAPI Backend:** `/a2a/v1` endpoint, health checks, agent-card
- **Gradio Frontend:** Manual task submission, status, logs
- **Coder Agent:** Task queue, opencode integration, GitHub ops

### Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `OPENCODE_API_KEY` | Yes | OpenCode API key |
| `GITHUB_TOKEN` | Yes | GitHub PAT with repo access |
| `HF_TOKEN` | No | Hugging Face token (for deployment) |
| `TELEGRAM_TOKEN` | No | Telegram notifications |

## πŸ“‘ Interfaces

| Interface | URL | Protocol |
|-----------|-----|----------|
| **Gradio UI** | Space URL | HTTP |
| **A2A API** | `/a2a/v1` | JSON-RPC 2.0 |
| **Health** | `/health` | HTTP JSON |
| **Agent Card** | `/.well-known/agent-card.json` | JSON |
| **Dashboard** | https://a2a.delqhi.com/agents/sin-code-plugin | Web |

## πŸ”§ Usage

### Via A2A (Standard)
```bash
curl -X POST https://delqhi-a2a-sin-code-plugin.hf.space/a2a/v1 \
  -H 'content-type: application/json' \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "message/send",
    "params": {
      "message": {
        "role": "user",
        "parts": [
          {
            "type": "data",
            "data": {
              "description": "Fix the plugin manifest schema validation",
              "type": "plugin",
              "issue_number": 1065
            }
          }
        ]
      }
    }
  }'
```

### Via Gradio UI
1. Open the Space URL
2. Fill in task description, select type, enter branch name
3. Click "πŸš€ Submit Task"
4. View status and logs

## πŸ“Š Sample Task Flow

1. **Receive Task:** A2A message with description "Create a new MCP for WhatsApp"
2. **Generate Code:** Call `opencode run` with specialized prompt
3. **Create Files:** Agent writes files to repository (through opencode)
4. **Commit:** Automatic commit to target branch with issue reference
5. **Report:** Status updated in task store, can create PR via separate step

## πŸ› οΈ Supported Task Types

| Type | Description |
|------|-------------|
| `plugin` | OpenCode plugins (MCP servers) |
| `command` | CLI commands (sin-* binaries) |
| `tool` | Reusable utility functions |
| `backend` | API, database, business logic |
| `frontend` | UI components, Next.js, React |
| `fullstack` | Both frontend + backend |

## πŸ“ Development

### Local Testing
```bash
# Prepare environment
export OPENCODE_API_KEY="your-key"
export GITHUB_TOKEN="your-token"
export REPO_DIR="/path/to/OpenSIN-Code"

# Run locally
python app.py

# Access at http://localhost:7860
```

### Building Docker Image
```bash
docker build -t delqhi/a2a-sin-code-plugin:latest .
docker run -p 7860:7860 -e OPENCODE_API_KEY -e GITHUB_TOKEN delqhi/a2a-sin-code-plugin
```

## πŸ” Security

- **API Keys:** Use Hugging Face Space secrets, never hardcoded
- **GitHub Token:** Scoped to specific repository (OpenSIN-Code)
- **Network:** Outbound only to opencode API and GitHub
- **No Persistent Storage:** Ephemeral filesystem (HF Space default)

## πŸ“ˆ Monitoring

- **Gradio UI:** Real-time task status and logs
- **HF Space:** Logs via HF dashboard
- **Dashboard:** https://a2a.delqhi.com/agents/sin-code-plugin
- **Telegram:** Optional notifications

## πŸš€ Deployment

### To Hugging Face Spaces

```bash
# Create Space (CPU-Basic required)
huggingface-cli repo create delqhi-a2a-sin-code-plugin --type space --space-sdk docker

# Set secrets
huggingface-cli variable set OPENCODE_API_KEY "$OPENCODE_API_KEY" --repo delqhi-a2a-sin-code-plugin --type space
huggingface-cli variable set GITHUB_TOKEN "$GITHUB_TOKEN" --repo delqhi-a2a-sin-code-plugin --type space

# Push code
git init
git remote add origin https://huggingface.co/spaces/delqhi/delqhi-a2a-sin-code-plugin
git add .
git commit -m "Deploy A2A-SIN-Code-plugin v1.0.0"
git push --force origin main

# Set hardware to CPU-Basic (via HF UI or API)
```

**IMPORTANT:** Set hardware to `cpu-basic` in Space settings. Never use GPU/ZeroGPU for coding agents.

## πŸ“ž Support

- **Dashboard:** https://a2a.delqhi.com/agents/sin-code-plugin
- **Docs Tab:** [Google Docs](https://docs.google.com/document/d/1RtoHn4I0GntuEEOHHkqoh_dMuGzgMwQz7_8oxAOpQbw/edit?tab=t.t.56da546b17b8ef18)
- **Team Manager:** SIN-Zeus

---

**Last Updated:** 2026-04-07  
**Agent:** A2A-SIN-Code-plugin v1.0.0
**Owner:** Team - Coder / SIN-Zeus