Files
DebianAI/AGENTS.md
2026-06-10 19:16:19 +02:00

2.8 KiB

Repository Guidelines

Project Structure & Module Organization

This repository contains a small Go HTTP wrapper for running AI CLI prompts on a Debian host. The active service entry point is main.go; it exposes POST /run, POST /runCodex, and POST /runGemini. /run is a backward-compatible alias for /runCodex. daiapi.service is the systemd unit, and go.mod defines the local module. old-python/ contains the previous Python implementation for reference only.

Build, Test, and Development Commands

  • gofmt -w main.go: format Go source before committing.
  • go test ./...: run all Go tests; currently reports no test files.
  • go build ./...: verify the module builds.
  • go build -o daiapi .: build the service binary used by daiapi.service.
  • PORT=8000 ./daiapi: run locally on port 8000.
  • curl -X POST localhost:8000/runCodex -H 'Content-Type: application/json' -d '{"prompt":"Say hello"}': smoke-test Codex.
  • curl -X POST localhost:8000/runGemini -H 'Content-Type: application/json' -d '{"prompt":"Say hello"}': smoke-test Gemini.

API Behavior

Codex endpoints accept {"prompt":"..."} and return the original response shape: success, answer, usage, and stderr. Keep /run and /runCodex behavior identical. Gemini uses the same request body and returns success, answer, usage, stdout, stderr, exitCode, and optional error. Use exec.Command or exec.CommandContext with argument slices; never pass prompts through shell strings.

Coding Style & Naming Conventions

Use standard Go formatting and idioms. Keep imports, indentation, and struct tags managed by gofmt. Use short lower-camel-case names for handlers and locals, such as runCodexHandler, runGeminiHandler, and finalText. Keep helpers unexported unless there is a concrete external need.

Testing Guidelines

Add Go tests beside the code as *_test.go files, using testing and net/http/httptest. Prefer handler-level tests for request validation, status codes, JSON response shape, and CLI error handling. Isolate external command invocation so tests do not require real Codex or Gemini credentials.

Commit & Pull Request Guidelines

The current history uses short initial-commit messages only, so use concise imperative subjects, for example Add Gemini endpoint tests. Pull requests should explain API behavior changes, list manual verification commands, and call out deployment impact such as changes to daiapi.service, environment variables, PATH requirements, ports, or CLI arguments.

Security & Configuration Notes

The service executes prompts through local CLI tools. Codex runs with --full-auto and access to /tmp; Gemini must be available in the service PATH. Keep PORT and secrets in /etc/daiapi/daiapi.env, and do not commit host-specific credentials or expanded environment files.