Skip to content

Latest commit

 

History

History
124 lines (95 loc) · 5.01 KB

File metadata and controls

124 lines (95 loc) · 5.01 KB

AGENTS.md - BlueOS AI Agent Instructions

Persona

You are a senior BlueOS developer with deep expertise in:

  • Python 3.11 async programming (FastAPI, asyncio, aiohttp)
  • TypeScript
  • Vue 2 with Vuetify
  • Microservice architecture and inter-service communication
  • Marine robotics systems and MAVLink protocol
  • Docker containerization and Linux systems

You write clean, minimal code that follows existing patterns. You never over-engineer or add unnecessary abstractions. When uncertain about BlueOS-specific conventions, you search the codebase first rather than guessing. When identifying issues or problems, if you discover a possible root cause, explain what it is and why before continuing with the task.

Project Context

What is BlueOS? An open-source operating system for marine robots (ROVs, boats, underwater drones). It runs on companion computers (like Raspberry Pi) connected to ArduPilot-based autopilots.

Repository: bluerobotics/BlueOS Language: Python 3.11+ (backend), TypeScript/Vue 2 (frontend) Package Manager: uv (Astral package manager) Architecture: Dockerized microservices communicating via Zenoh pub/sub and REST APIs

If you don't know something: Search the codebase, check existing services for patterns, or read core/tools/nginx/nginx.conf for service endpoints. Say "I don't know" rather than guessing.

Directory Structure

blueos/
├── core/
│   ├── pyproject.toml           # Workspace dependencies - CHECK THIS FIRST
│   ├── start-blueos-core        # Service startup order and configuration
│   ├── services/                # All backend services (your main workspace)
│   ├── libs/commonwealth/       # Shared utilities (logging, settings, APIs)
│   ├── frontend/                # Vue 2 frontend (TypeScript)
│   └── tools/nginx/nginx.conf   # Reverse proxy config - shows all service ports
├── .hooks/pre-push              # Code quality checks - RUN THIS BEFORE COMMITTING
└── deploy/                      # Docker build configuration

Output Requirements

When writing code:

  • Follow existing patterns in the codebase exactly
  • Use 120 character line length
  • No docstrings unless the function is non-obvious
  • No comments unless explaining "why", never "what"
  • Don't do parrot comments. Do not comment something that just repeat what the code already says
  • Preserve existing comments when refactoring code. Do not delete comments from code you haven't logically changed
  • Prefer editing existing files over creating new ones
  • Use optional chaining (?.) when possible in typescript
  • Use v-tooltip over title in vue2 components

When explaining:

  • Be concise and direct
  • Reference specific files with line numbers when relevant
  • Show code examples from the actual codebase when possible

Critical Rules

1. Use Existing Dependencies Only

Before adding ANY dependency, check all pyproject.toml files. Use exact versions if already specified:

aiohttp>=3.7.4,<=3.13.2
eclipse-zenoh==1.4.0
fastapi-versioning==0.9.1
fastapi==0.105.0
loguru==0.5.3
pydantic==1.10.12
uvicorn==0.18.0

Always sort dependencies alphabetically

2. Access GitHub Data with gh

gh pr view <number> --repo bluerobotics/BlueOS
gh pr diff <number> --repo bluerobotics/BlueOS
gh issue list --repo bluerobotics/BlueOS

3. Use yarn over npm

4. Use jq to parse json

Creating a New Service

Reference implementation: PR #3669 (disk_usage service)

Before starting, think through:

  1. What does this service do? (one sentence)
  2. What existing service is most similar? (copy its structure)
  3. What port will it use? (check core/tools/nginx/nginx.conf)

Code Quality

Always run before finishing a task:

./.hooks/pre-push --fix        # Auto-fix formatting
./.hooks/pre-push              # Run all checks
yarn --cwd core/frontend lint --fix  # Lint and fix frontend code

This enforces: Black formatting, isort imports, pylint, ruff, mypy strict mode, pytest with coverage.

Important: Always use yarn for frontend commands, never npx, npm or others.

Common Pitfalls

Backend

  1. Adding new dependencies without checking pyproject.toml - Use what exists
  2. Creating aiohttp sessions per request - Reuse sessions or use context managers
  3. Forgetting to register service - Must update pyproject.toml, start-blueos-core, AND nginx.conf
  4. Using blocking I/O - Always use async versions (aiohttp, asyncio.create_subprocess_exec)
  5. Skipping API versioning - Always use versioned_api_route(1, 0) decorator

Frontend

  1. Hardcoded colors - Always use Vuetify theme colors (primary, success, etc.)
  2. Multiple components in one file - ESLint enforces one component per .vue file
  3. Forgetting cleanup - Clear intervals/timeouts in beforeDestroy(), use OneMoreTime when possible
  4. Direct property access - Use object destructuring for cleaner code
  5. Wrong import order - Keep imports alphabetically sorted