feat(nutrition): add nutrition#1427
Conversation
|
@greptileai review Auto-nudge from |
Greptile SummaryThis PR introduces a new
Confidence Score: 5/5Safe to merge; all novel commands are well-structured, the cross-source name-match fix is correct, and the handwritten SQLite layer is properly isolated from generator-emitted files. All seven novel commands follow consistent patterns, use parameterised queries, handle partial failures gracefully, and were validated 83/83 against the live USDA API. The previous nameOverlap guard fix is correctly implemented. The remaining findings are minor usability gaps in cite, find, and log remove. No files require special attention; Important Files Changed
|
|
@greptileai review Auto-nudge from |
nutrition
One agent-native CLI over USDA FoodData Central and NutritionValue.org - with cross-source enrichment, protein-density comparison, nutrient ranking, and a local SQLite cache no other nutrition tool ships.
API: nutrition | Category: food-and-dining | Press version: 4.27.1
Spec: USDA FoodData Central OpenAPI (
https://fdc.nal.usda.gov/api-spec/fdc_api.json)Publication Path
New print — combo aggregator CLI unifying two peer sources (USDA FoodData Central official API + NutritionValue.org server-rendered HTML) behind one food model, keyed on the shared FDC id.
CLI Shape
Novel Commands
enrichrankcomparefindlogmealciteWhat This CLI Does
Look up any food's nutrition from USDA's ~600K-food database, then enrich it with NutritionValue.org's derived analytics (net carbs, omega-6/omega-3 ratio) that the USDA API never exposes. Compare foods on a per-100kcal protein-density basis, rank foods by any nutrient, filter by compound thresholds, and log a daily diary against targets — all offline-cached, cited, and agent-native.
Because NutritionValue.org's food ids are the same USDA FDC ids, the two sources join exactly:
enrich <fdcId>returns the authoritative USDA nutrients plus NutritionValue's derived fields for the same food. USDA auth uses a free api.data.gov key (FDC_API_KEYorUSDA_API_KEY), falling back to the publicDEMO_KEY; NutritionValue commands need no key.Manuscripts
Validation Results
Publish Live Gate
Full live dogfood reran at publish time against the real USDA FoodData Central API and passed 83/83. All 7 novel commands were exercised end-to-end (enrich, rank, compare, find, meal, cite, log). Proof: Phase 5 Acceptance.
Notes
Two generator retro candidates were recorded under
.printing-press-patches/(dual x-auth-env-vars collidingtoml:"api_key"tags; an unregisteredauth set-tokensubcommand), both fixed in-tree. NutritionValue.org is accessed politely (browser User-Agent, adaptive rate limiter under 1 req/s, no bulk crawling) via a hand-authored HTML-extraction source client.Review Response
Greptile confidence 4/5, 3 P2 findings addressed:
nameOverlapsingle-token match (hand-authored): fixed in8d28c07— added a minimum-2-shared-token guard to the NutritionValue.org fallback so a lone shared token can't attach the wrong food's analytics; added two focused tests.internal/cache/cache.goandinternal/client/client.go(both generator-emitted,DO NOT EDIT): theoretical 64-bit collision; filed as a Printing Press generator retro candidate (widen the template cache-key hashes to 16 bytes) rather than diverging this printed CLI's generated code.