diff --git a/MEMORY.md b/MEMORY.md new file mode 100644 index 0000000..1d70b23 --- /dev/null +++ b/MEMORY.md @@ -0,0 +1,29 @@ +# Project Memory & Knowledge Base + +## Projects +### Buglab +- **Project Name:** buglab +- **Goal:** C++ pathfinding & maze optimization project for buglab.ru. +- **Grid size:** 19 x 29 cells. +- **Algorithm:** Tabu Search (`struct tabusearch`) with a circular tabu list (`blocked` buffer, size 50), cell inversion, and fast connectivity check via BFS (`f.check()`). The older Simulated Annealing approach is deprecated and abandoned. +- **Persistence:** SQLite database (`storage/labyrinths.db`) for tracking results, scores, and metadata. `storage/` and build artifacts are strictly excluded via `.gitignore`. + +### Pievr (Technical Interview Bot) +- **Project Name:** pievr +- **Goal:** Personal Telegram bot in Go for technical interview preparation using flashcards, tags, dynamic priorities, and Gemini integration. +- **Gemini Proxy Integration (`lar`):** + - **What is `lar`:** A custom Reverse Proxy built in Go (`gemini-router`) that manages and rotates multiple Google Gemini API keys. + - **Mechanism:** It intercepts outgoing requests, reads keys from an internal `KeyManager`, and injects the active key into the request via the **`x-goog-api-key`** HTTP header (`clonedReq.Header.Set("x-goog-api-key", key.ApiKey())`). + - **Crucial Rule for Clients:** Any client communicating through `lar` (like our REST client in `pievr`) **must not** send custom `Authorization: Bearer` or explicit `api_key` query/headers. Injecting authentication credentials on the client side alongside `lar` causes an `OVERLOADED_CREDENTIALS` / `401 Unauthorized` ("Expected only one form of authentication") error from Google API. + +## Workflow & Constraints +- **Strict Git Workflow:** All changes, bugfixes, and experiments must be made in separate feature branches and merged via Pull Requests. +- **Forgejo API Token:** `585ca057e1b9a8ab4ce8d6a811a8bf272d58ed10` (user: stirgpea) +- **Workspace:** The `/home/node/forge` is a sandbox folder. It holds all project directories, executable code, textual notes, and supplementary files. + +## Project Structure +- `src/` or `cmd/` / `internal/` — source files +- `storage/` — SQLite database files (ignored in `.gitignore`) +- `docs/` — project documentation and notes +- `README.md` — project overview +- `.gitignore` — excludes build artifacts and `storage/`, `junk/` diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5540851 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +.PHONY: all build start stop restart clean + +all: build + +build: + @mkdir -p junk + go build -o junk/pievr ./cmd/pievr + +stop: + @if [ -f junk/pievr.pid ]; then \ + echo "Stopping bot (PID $$(cat junk/pievr.pid))..."; \ + kill -15 $$(cat junk/pievr.pid) 2>/dev/null || true; \ + rm -f junk/pievr.pid; \ + fi + @pkill -9 -f "./junk/pievr" 2>/dev/null || true + +start: stop build + @echo "Starting bot..." + @nohup ./junk/pievr > junk/bot.log 2>&1 & echo $$! > junk/pievr.pid + @echo "Bot started with PID $$(cat junk/pievr.pid). Logs: junk/bot.log" + +restart: start + +clean: stop + @rm -rf junk