đ€ AI Contributor Guide
Welcome, autonomous agent! This document explains the project layout, coding conventions, and the extra steps youâan AI systemâshould follow when proposing changes to **BGÂ Analyzer**.
> **If your modification changes userâvisible behaviour or usage instructions, you must also update** `README.md`, sample configuration files, and any other helper docs needed to keep everything in sync.
---
1 · Repository Map
| Path | What youâll find | Typical agent tasks | | ------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------ | | `/bg_analyzer/ingest/` | Parsers that convert device exports (CGM, pump, pen, food logs) into a common schema | Add a new `*.py` parser, expand the schema, write unit tests | | `/bg_analyzer/analysis/` | Core algorithms for event filtering and ICR/ICF estimation | Optimise maths, add new metrics or contextâaware models | | `/bg_analyzer/report/` | Renderers that turn analysis results into Markdown & JSON | Create new output formats, tweak visualisation | | `/cli.py` | Clickâbased commandâline interface entry point | Extend CLI flags, improve UX messages | | `/samples/` | Example CSV files for manual and CI tests | Add fresh samples when supporting new devices | | `/tests/` | Pytest suite & fixtures | Write tests for every new behaviour | | `/docs/` | Longerâform design/architecture docs (optional) | Add detailed specs, diagrams |
---
2 · Workflow for Agents
1. **Sync and plan** *Read open issues or create one describing the change.* Reference it in your PR. If anything is unclear, add a bullet to `QUESTIONS.md` so the product owner can respond. 2. **Create a feature branch** `feature/<shortâslug>` or `fix/<shortâslug>`. 3. **Write the code**
* Follow existing folder conventions. * Add/modify docstrings in *Googleâstyle* format. * Maintain type hints (`mypy` passes). * Keep functions <50Â LOC where feasible. 4. **Update documentation**
* If UX or CLI changes, update `README.md`. * If developerâfacing behaviour changes, update `agents.md` or create a doc under `/docs/`. * Refresh examples in `/samples/` if data format changes. * When a question in `QUESTIONS.md` is answered, reflect it in the docs and remove that bullet. 5. **Validate**
* Run `preâcommit run --all-files` (black, isort, flake8, mypy, etc.). * Run `pytest âq`âtests must pass and coverage â„ 90âŻ%. * Execute `python cli.py --help` to ensure CLI still works. 6. **Commit** Use *Conventional Commits*: `feat(ingest): add Abbott Libre CSV parser` `fix(analysis): handle zeroâcarb corrections` 7. **Pull Request**
* Title = concise, imperative. * Body = *What + Why + How*, link the issue. * Checklist ticked (tests, docs, coverage). * Update `ROADMAP.md` task status in the same PR (move card or tick box). * Tag `@maintainers` for review.
---
3 · Design Principles
* **Localâfirst privacy**: never send raw health data to external APIs unless an integration is explicitly enabled. * **Predictability over complexity**: favour transparent calculations before opaque ML. Include comments & references if statistical methods are added. * **User empathy**: error messages must be actionable and nonâalarmist; analytics should default to safe, conservative suggestions.
---
4 · Updating Helper Files
When your change alters:
| Change type | Docs to update | | ----------------------- | --------------------------------------------------------------------------------- | | CLI flag, config option | `README.md` (Quick Start & Expected CSV columns) | | Device/data source | `README.md` (Capabilities) + `/samples/` | | Repo structure | `agents.md` + `/docs/architecture.md` | | Algorithms/metrics | `README.md` (Current capabilities) + Possibly a new doc under `/docs/algorithms/` |
Failing to update docs will trigger **CI DocâCheck** and block merge.
---
5 · Test & Documentation Utilities
* **Generate latest user report**: `make demo-report`Â â writes to `reports/`. * **Open coverage HTML**: `make cov`. * **Lint markdown**: `mdformat -i *.md` (runs in preâcommit).
---
6 · Semantic Versioning & Changelog
The project follows **SemVer**. The `CHANGELOG.md` is autoâgenerated from Conventional Commits during release (`npm version`âstyle script). When you merge to `main`, CI may tag a version bump. *Breaking changes require a `!` in the commit scope.*
---
Happy coding, fellow agent â keep the loops tight, the tests green, and the docs fresh! đ