From 75d88f441c8c9b01768e96c9b50b9832111ed072 Mon Sep 17 00:00:00 2001 From: Patedam Date: Mon, 9 Mar 2026 22:07:48 -0400 Subject: [PATCH] coding guidelines, agents and gemini.md --- Provider/.agents/rules/coding-guidelines.md | 124 ++++++++++++++++++++ Provider/.agents/rules/how-to-write-tdd.md | 3 +- Provider/AGENTS.md | 85 ++++++++++++++ Provider/GEMINI.md | 105 +++++++++++++++++ 4 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 Provider/.agents/rules/coding-guidelines.md create mode 100644 Provider/AGENTS.md create mode 100644 Provider/GEMINI.md diff --git a/Provider/.agents/rules/coding-guidelines.md b/Provider/.agents/rules/coding-guidelines.md new file mode 100644 index 0000000..7e3c478 --- /dev/null +++ b/Provider/.agents/rules/coding-guidelines.md @@ -0,0 +1,124 @@ +# Calendink Coding Guidelines + +These rules apply to all code in this workspace. + +--- + +## Backend — C++ / ESP-IDF + +### Philosophy: C-with-Utilities +Write **C-style code** using C++ convenience features. No classes, no methods, no RAII, no exceptions. + +**Use freely:** `template`, `auto`, `constexpr`, `enum class`, type aliases from `types.hpp` +**Avoid:** classes, constructors/destructors, `std::` containers, inheritance, virtual functions, RAII wrappers + +`goto` for cleanup/shutdown paths in `app_main` is acceptable. + +### Unity Build +All `.cpp` files are `#include`-ed into `main.cpp` as a single translation unit. **Do not register new source files in CMakeLists.txt.** + +- Use `unity.cpp` aggregators per API group (e.g., `api/tasks/unity.cpp`) +- Mark all file-scoped symbols with `internal` (defined as `static` in `types.hpp`) +- Use `.hpp` for declarations shared across included files only + +### API Handler Pattern +```cpp +// METHOD /api/path — What it does +// Body: { "field": value } (if applicable) + +internal esp_err_t api_foo_post_handler(httpd_req_t *req) { + httpd_resp_set_type(req, "application/json"); + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + // 1. Parse request + // 2. Call store function + // 3. Build cJSON response + // Always cJSON_Delete() objects and free() printed strings — no leaks +} + +internal const httpd_uri_t api_foo_post_uri = { .uri = "/api/foo", .method = HTTP_POST, .handler = api_foo_post_handler, .user_ctx = NULL }; +``` + +### Store / Handler Separation +Data operations in `store.cpp` / `store.hpp`. HTTP parsing in endpoint files. Never mix them. + +### Logging +**Always use `ESP_LOGI` / `ESP_LOGW` / `ESP_LOGE`** — never `printf()`. + +Since this is a Unity Build (single translation unit), the log tag must be unique per file to avoid redefinition. Name it after the module, not a generic `TAG`: +```cpp +// In each file, use a unique local name: +internal const char *kTagHttpServer = "HTTP_SERVER"; +internal const char *kTagMain = "MAIN"; +internal const char *kTagMDNS = "MDNS"; +``` + +### Type Aliases +Use `types.hpp` aliases: `uint8`, `uint16`, `uint32`, `uint64`, `int8`–`int64`, `internal` + +### Seed Data +`seed_users()` and `seed_tasks()` must be guarded: +```cpp +#ifndef NDEBUG + seed_users(); + seed_tasks(); +#endif +``` + +### Data Persistence +All task/user data is currently **in-RAM only** (intentional — NVS/LittleFS persistence is a future milestone). Do not add persistence without a TDD. + +--- + +## Frontend — Svelte 5 + TailwindCSS v4 + +### Styling: Tailwind Only +Use TailwindCSS exclusively. **No `