From 1db98be556d0f984b0249f4c29ec749b02640f0e Mon Sep 17 00:00:00 2001 From: Hector Ros Date: Tue, 20 Jan 2026 01:23:30 +0100 Subject: [PATCH] Initial agent implementation - Node.js Alpine base with Claude Code CLI - MCP configuration for backend communication - Git and development tools pre-installed - K8s deployment manifests - CI/CD workflow for automatic builds Co-Authored-By: Claude Sonnet 4.5 (1M context) --- .dockerignore | 5 ++++ .gitea/workflows/build.yml | 26 +++++++++++++++++++++ .gitignore | 3 +++ Dockerfile | 26 +++++++++++++++++++++ README.md | 47 ++++++++++++++++++++++++++++++++++++++ mcp-config.json | 12 ++++++++++ 6 files changed, 119 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 mcp-config.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e59b4d0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +.git +.gitignore +*.md +*.log diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..9e0b03f --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build and Push Agent + +on: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build Docker image + run: docker build -t git.fuq.tv/admin/aiworker-agent:${{ gitea.sha }} . + + - name: Tag as latest + run: docker tag git.fuq.tv/admin/aiworker-agent:${{ gitea.sha }} git.fuq.tv/admin/aiworker-agent:latest + + - name: Login to Gitea registry + run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.fuq.tv -u admin --password-stdin + + - name: Push images + run: | + docker push git.fuq.tv/admin/aiworker-agent:${{ gitea.sha }} + docker push git.fuq.tv/admin/aiworker-agent:latest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac1e8f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +*.log +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2570da1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM node:20-alpine + +# Install system dependencies +RUN apk add --no-cache \ + git \ + bash \ + curl \ + openssh-client \ + ca-certificates + +# Install Claude Code CLI +RUN npm install -g @anthropic-ai/claude-code + +# Install common development tools +RUN npm install -g \ + typescript \ + ts-node + +# Create workspace directory +WORKDIR /workspace + +# Copy MCP configuration +COPY mcp-config.json /root/.claude/config.json + +# Keep container running and ready for commands +CMD ["tail", "-f", "/dev/null"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c42eb0 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# AiWorker Agent + +Claude Code agent running in Kubernetes pods to autonomously complete development tasks. + +## Architecture + +The agent: +- Runs in K8s namespace `agents` +- Communicates with backend via MCP protocol +- Has access to Git repositories via Gitea +- Reports progress and status to backend API + +## Local Development + +This is a containerized agent meant to run in Kubernetes. For local testing: + +```bash +docker build -t aiworker-agent:local . +docker run -it --rm \ + -e ANTHROPIC_API_KEY=your_key \ + -e BACKEND_URL=http://localhost:3000 \ + aiworker-agent:local \ + /bin/bash +``` + +## Deployment + +See `k8s/agents/README.md` for deployment instructions. + +## MCP Tools + +The agent uses these MCP tools to communicate with the backend: +- `get_next_task` - Get next task from queue +- `update_task_status` - Update task state +- `create_branch` - Create Git branch for task +- `create_pull_request` - Create PR when task is complete +- `ask_user_question` - Request user input when needed + +## Environment Variables + +- `ANTHROPIC_API_KEY` - Claude API key +- `BACKEND_URL` - Backend API URL +- `MCP_SERVER_URL` - MCP server URL +- `GITEA_URL` - Gitea URL +- `GITEA_TOKEN` - Gitea access token +- `POD_NAME` - Pod name (auto-injected by K8s) +- `NAMESPACE` - Namespace (auto-injected by K8s) diff --git a/mcp-config.json b/mcp-config.json new file mode 100644 index 0000000..4685df6 --- /dev/null +++ b/mcp-config.json @@ -0,0 +1,12 @@ +{ + "mcpServers": { + "aiworker-backend": { + "command": "node", + "args": ["-e", "console.log('MCP client placeholder')"], + "env": { + "BACKEND_URL": "http://backend.control-plane.svc.cluster.local:3000", + "MCP_SERVER_URL": "http://backend.control-plane.svc.cluster.local:3100" + } + } + } +}