Commit graph

77 commits

Author SHA1 Message Date
Claude
aba8d42123 Add Linux installation guide with all AI agent options
Covers Debian/Ubuntu, Fedora, Arch. Includes:
- Gemini CLI (recommended free: 1000 req/day, SSE direct)
- Claude Desktop (official Linux beta via apt, stdio)
- ChatGPT/Codex CLI (paid only, noted as unavailable on Linux)
- Built-in AI Coach (free API keys + Ollama offline)
- systemd service for auto-start
- venv vs system-wide install options
- No tzdata needed (Linux has system timezone DB)
2026-08-03 06:44:44 +00:00
Claude
37c152060a Comprehensive Windows install guide with all AI agent options
Covers four AI integration paths:
- Gemini CLI (recommended free: 1000 req/day, SSE+stdio)
- Claude Desktop (free account, stdio only)
- ChatGPT Desktop (paid only, stdio)
- Built-in AI Coach (simplest: free API keys from OpenRouter/Groq/
  Google AI Studio/Hugging Face/Ollama)

Includes full troubleshooting table for all known Windows issues.
2026-08-03 06:42:02 +00:00
Claude
c1f01ea72f Add installation guides: Giordano fix + full Windows install
- docs/GIORDANO-FIX.md: step-by-step for next session with Giordano
- docs/INSTALL-WINDOWS.md: complete clean install guide for any Windows machine
2026-08-03 06:22:11 +00:00
Claude
b63e5f7f5b Switch from mcp SDK to standalone fastmcp package
The mcp SDK v2.0.0 (2026-07-28) renamed FastMCP to MCPServer
and removed the mcp.server.fastmcp import path entirely.
The standalone fastmcp package (PrefectHQ, v3.x) is the actively
maintained framework with identical @mcp.tool() decorator API.

- pyproject.toml: [mcp] extra now requires fastmcp>=3.0.0
- server.py: import changed from mcp.server.fastmcp to fastmcp
- mcp_stdio.py: unchanged (imports from diligence.mcp.server)
2026-08-03 03:53:23 +00:00
Claude
00fcc9f0c6 Pin mcp<2.0.0: v2 removed FastMCP from mcp.server.fastmcp
MCP SDK v2.0.0 extracted FastMCP into a separate package,
breaking the import at mcp.server.fastmcp.FastMCP. Pin to
v1.x until the server code is updated for the v2 API.
2026-08-03 03:45:18 +00:00
Claude
8aab7c0c4a Add stdio MCP launcher for Claude Desktop
Claude Desktop's config file only supports stdio transport.
This script launches the MCP server in stdio mode, connecting
to the already-running Diligence backend at localhost:8000.
2026-08-03 03:33:42 +00:00
Claude
aeb0b438cc Fix Windows crash: add tzdata dependency, harden timezone fallback
On Windows, Python's zoneinfo module has no system timezone database.
Without the tzdata package, ZoneInfo('UTC') raises ZoneInfoNotFoundError,
crashing both /api/points/today and /api/nutrition/today (Home and Keto
pages show 'failed to load').

Two fixes:
1. Add tzdata>=2024.1 to pyproject.toml dependencies so pip install
   pulls it automatically
2. Harden dates.py with _safe_tz() that falls back to datetime.timezone.utc
   (always available, no tzdata needed) as the ultimate fallback
2026-08-03 02:20:57 +00:00
Claude
3beca1ca2f Add missing schema migrations for timezone columns
Existing databases (from pre-July-5 installs) were missing:
- users.timezone (v4.2)
- nutrition_goals.diet_style and timezone_str (v4.3)

create_all only adds these to brand-new databases. The migration
system now detects and adds them on startup, matching the pattern
used for all other schema additions.
2026-08-03 02:12:44 +00:00
Claude
62a5d3bfcb docs: add bibliography and source index for seed data
12 sources documented with URLs, licenses, record counts,
fields used, provenance notes, and citation info.
Licensing summary table confirms exercise + food libraries
are fully redistributable (MIT + public domain).
2026-07-19 02:26:38 +00:00
Claude
2ff0b1c6ce feat: add seed data — 2,079 exercises + 8,068 foods with lifestyle pattern tags
Exercise library:
- Merged hasaneyldrm/exercises-dataset (1,324, MIT, 10 languages)
  with yuhonas/free-exercise-db (873, public domain)
- 112 overlap exercises enriched from both sources
- Unified schema: body_part, equipment, target_muscle, force,
  level, mechanic, multilingual instructions
- Categories: strength (1,871), flexibility (105), plyometrics (60), cardio (43)

Food library:
- Merged USDA Foundation Foods (363) + SR Legacy (7,793)
- 25 USDA categories, 99% macronutrient completeness
- Lifestyle pattern tags: Mediterranean, DASH, Blue Zones,
  plant-based, anti-inflammatory, keto
- Framed as lifestyle choices, not weight loss schemes

See data/seed/INVENTORY.md for full details.
2026-07-19 02:22:56 +00:00
Claude
79d444f884 Rebuild frontend for pip install — all v4 changes included
Built with Node 22 / Vite. Includes DW brand theme, ChatCoach,
category-grouped integrations, AgentConnect with all providers,
Dashboard checklist, Settings help section, gear icon.
2026-07-13 23:41:55 +00:00
Claude
8728776f21 AgentConnect: cover all AI providers + external agents; Settings: Help section
AgentConnect.jsx rewritten:
- Option 1: Built-in AI Coach — lists all 8 providers with free tier
  badges and 'Get key' links, step-by-step setup instructions
- Option 2: External AI Agent (MCP) — Claude Desktop (with Windows
  path), Claude Code CLI, Cursor, Windsurf/other
- Page renamed from 'Connect Your AI Agent' to 'Connect AI'

Settings.jsx:
- Added Help & Support section: Report a Bug (GitHub Issues),
  Ask a Question (GitHub Discussions), Star on GitHub
2026-07-13 23:27:36 +00:00
Claude
e1b213a54e Fix: move useState(showChecklist) before conditional returns
React hooks must be called unconditionally on every render. The
checklist useState was at line 89, after 'if (loading) return' at
line 70 — hooks violation crashed the entire React app (blank screen).
Moved to line 38 with the other state declarations.
2026-07-13 23:21:16 +00:00
Claude
befcc3346a Fix: add missing today_for_user, day_start_utc imports to points_engine 2026-07-13 23:17:49 +00:00
Claude
04e2af1a85 UX overhaul: navigation, category grouping, setup guidance, checklist
Fix 1: list_providers returns category, warning, sync_status
Fix 2: Gear icon in header (offset from HelpButton) links to /settings
Fix 3: Integrations page grouped by category (Devices → AI → Nutrition →
       Notifications) with section headers, explanatory text, sync status
       badges, COROS/coming-soon handling, link to /agent, hash-scroll
Fix 4: Coach page two-path setup (built-in prominent, external agent
       subtle link to /agent), anchor to #ai-coaching
Fix 5: Settings 'all 11 providers' → 'All integrations', AI Agent link
Fix 6: AgentConnect back-link to integrations
Fix 7: Dashboard getting-started checklist (dismiss to localStorage)
2026-07-13 23:01:57 +00:00
Claude
c56d6d5816 Fix: add missing get_week_boundaries() to dates.py
points_engine.py imports this for weekly point tracking but the
function was missing from the restructured codebase.
2026-07-13 22:24:55 +00:00
Claude
ad3da57174 Fix: add backwards-compat CSS aliases for removed variable names
Theme overhaul removed --surface, --surface-2, --border, --r-md but
SettingsIntegrations.jsx and other pages still reference them. Cards
were rendering but invisible (transparent background/border).

Added aliases: --surface/--surface-2 → --card, --border → --card-border,
--r-md → --r
2026-07-13 22:20:08 +00:00
Claude
2411fc5b99 docs: add beta tester guide with Claude Desktop setup instructions 2026-07-05 01:13:18 +00:00
Claude
c37543b009 feat: timezone auto-detection, branding fix, frontend rebuild
Timezone:
- Add diligence/utils/dates.py with today_for_user(), now_for_user(), day_start_utc()
- Replace all 20 date.today() calls across 10 files with timezone-aware helpers
- Remove hardcoded Asia/Bangkok offset hack in nutrition router
- Change defaults from Asia/Bangkok to UTC in user model, nutrition model, config
- Add timezone field to RegisterRequest schema
- Set user.timezone from browser detection during registration
- Frontend sends Intl.DateTimeFormat().resolvedOptions().timeZone on register

Branding:
- Login page: Fitness Rewards -> Diligence, updated tagline and emoji
- index.html title: Fitness Rewards -> Diligence

Frontend rebuild:
- Fresh Vite build with all changes (index-CsKoBN0D.js)
- Nav bar, timezone detection, and branding all verified in built bundle
2026-07-04 07:16:23 +00:00
Claude
40c8485aa7 feat: MCP server for pip install path
- diligence/mcp/server.py: 14 MCP tools (adapted from mcp-connector/)
- diligence/mcp/__init__.py: background thread startup
- CLI starts MCP on port 3001 automatically (--no-mcp to disable)
- Graceful fallback if mcp package not installed
- Agent config endpoint returns correct port for pip path
2026-07-01 04:54:56 +00:00
Claude
df39a8dc08 feat: Agent Connect page + /api/agent/config endpoint
- New AgentConnect.jsx page with MCP URL, token, setup instructions
- Claude Desktop config snippet with copy button
- Claude Code CLI command with copy button
- Agent capabilities overview
- Added to bottom nav bar (6th item, plug icon)
- Backend /api/agent/config endpoint returns deployment-aware MCP details
- Nav padding adjusted for 6 items
- Frontend rebuilt with new page
2026-07-01 03:45:34 +00:00
Claude
a6e6e2f54f v2.0: dual deployment — pip install (SQLite) + Docker (PostgreSQL)
Architecture:
- Moved backend/app/ to diligence/ Python package
- Dialect-agnostic models (Uuid + JSON, no PostgreSQL imports)
- Auto-detect database: empty DATABASE_URL → SQLite at ~/.diligence/data.db
- Cross-dialect migrations (inspector-based, no raw PostgreSQL DDL)
- FastAPI serves pre-built React frontend for pip path
- CLI entry point: diligence [--port] [--no-browser] [--data-dir]
- pyproject.toml with optional deps: [postgres], [mcp], [dev]
- Docker path unchanged: docker compose up -d

pip install path: pip install . && diligence
Docker path: ./setup.sh && docker compose up -d
2026-07-01 03:30:12 +00:00
Claude
0ce1463de8 Fix setup.ps1: correct execution order and add API_TOKEN generation
Bug: API_TOKEN replacement ran before .env existed, and before the
existence check. On a clean clone the script errored immediately.

Fixed flow: banner → existence check → generate SECRET_KEY →
generate API_TOKEN → copy .env.example → replace both keys.

Also adds MCP connection info to output (matching setup.sh).
2026-06-26 23:37:11 +00:00
Claude
214e3e0111 Fix: AI chat router prefix /ai -> /api/ai (match other routers) 2026-06-22 00:29:52 +00:00
Claude
f2954af400 Fix: ai_provider reads actual DB schema (config_key/config_value rows)
Root cause: ai_provider.py assumed a single JSON blob in an
'encrypted_value' column, but IntegrationConfig stores each credential
as a separate row with config_key + config_value columns.

Fixes:
- Query groups rows by provider, decrypts each config_value separately
- Correct decrypt_value(secret_key, ciphertext) argument order
- Filter by user_id so providers are per-user
- Callers (ai_chat.py, chat()) now pass user_id through
2026-06-22 00:27:19 +00:00
Claude
5294745704 Fix: replace all settings.algorithm references with hardcoded ALGORITHM
SEC-11 removed algorithm from Settings but missed 3 call sites:
- auth.py line 68: jwt.decode in get_current_user
- integrations.py lines 58, 120: jwt.decode in OAuth callbacks

All now use ALGORITHM constant or inline 'HS256'.
2026-06-22 00:17:58 +00:00
Claude
4e8b321ef8 Fix: SyntaxError in main.py — comma after allow_credentials=False
The SEC-06 replacement swallowed the trailing comma into the comment:
  allow_credentials=False  # comment,  ← comma in comment
Fixed to:
  allow_credentials=False,  # comment  ← comma after value
2026-06-22 00:08:28 +00:00
Claude
d087e0a5a1 Fix: restore App.jsx and properly add ChatCoach import, route, nav
Previous commit wiped App.jsx due to emoji encoding error in the
patch script. Restored from Stream A commit (c075eb9), then applied
ChatCoach changes using a file-based Python script to handle unicode.

- import ChatCoach from './pages/ChatCoach' (line 21)
- NavLink /chat with brain emoji + 'Coach' label (line 95)
- Route /chat -> ProtectedRoute -> ChatCoach (line 125)
2026-06-22 00:03:43 +00:00
Claude
4eb70dc178 Deprioritize WHOOP: code against API docs, first user validates
WHOOP developer registration requires device ownership. Sync service
will be built against their documented API; first WHOOP-owning user
serves as the integration tester. Focus on Garmin and Oura first.
2026-06-21 23:51:30 +00:00
Claude
e9957c552a Add OUTSTANDING.md — remaining work for cofounder review 2026-06-21 23:36:14 +00:00
Claude
0670bca9b1 Stream C frontend: ChatCoach page, nav update, README with AI providers + agent configs
Frontend:
- ChatCoach.jsx: streaming chat UI with SSE, provider indicator, suggestion
  chips, 'no AI configured' state with setup link
- App.jsx: import + /chat route + nav bar (More → Coach with brain emoji)
- api.js: getAIStatus() method

Documentation:
- README.md: 'Built-in AI Coach' section with 8-provider table, external
  agent config snippets for Claude Desktop, Claude Code, Cursor, Windsurf,
  and COROS multi-MCP pattern
- AGENT_GUIDE.md: multi-device integration, Strava AI/ML warning,
  provider-agnostic statement

Nav bar: Home | Log | Keto | Programs | Coach
Settings still reachable at /settings (linked from Coach setup prompt)
2026-06-21 23:28:07 +00:00
Claude
3ab88a3d2a Stream B: Device sync base class + provider registry (already committed)
Abstract base class for device sync services (device_sync_base.py):
- Standard OAuth token management with automatic refresh
- Credential decryption from integration_configs table
- Activity import pipeline with deduplication by external_id
- Webhook validation and handling interface
- get_valid_token(), get_credentials(), import_activity() helpers

Garmin, WHOOP, and Oura sync service implementations follow when
API credentials are obtained (Scot action items):
- Apply for Garmin Developer Program (DiligenceWorks Pte. Ltd.)
- Register WHOOP developer app at developer.whoop.com
- Register Oura app at cloud.ouraring.com
2026-06-21 23:16:58 +00:00
Claude
9a8e6ce1eb Stream C: Multi-provider AI coaching backend + 20-provider registry
AI coaching service (backend/app/services/ai_provider.py):
- Two code paths: OpenAI-compatible (6 providers) + Anthropic (Claude)
- Streaming SSE responses via httpx async
- System prompt built from AGENT_GUIDE + live user context
- Graceful error handling for all provider failures
- Gemini adapter for Google's generateContent API

Chat endpoint (backend/app/routers/ai_chat.py):
- POST /api/ai/chat — SSE streaming response
- GET /api/ai/status — check configured provider
- History capped at 20 messages, content at 4K chars

Provider registry expanded to 20 providers:
- 9 device integrations (strava, polar, garmin, whoop, oura, coros, fitbit, withings, suunto)
- 8 AI providers (openai, openrouter, huggingface, groq, ollama, claude, gemini, custom_ai)
- 3 other (usda, nutritionix, telegram)
- Categorized: device, ai_provider, nutrition, notifications
- COROS: MCP bridge approach (no API integration needed)
- Strava: AI/ML warning per their ToS

Frontend ChatCoach.jsx to follow in next commit.
2026-06-21 23:16:17 +00:00
Claude
6e082ce58f Stream D: Security hardening — 10 fixes from QA review
- SEC-05: Fail fast if SECRET_KEY is default 'change-me-in-production'
- SEC-06: CORS allow_credentials=False (Bearer tokens don't need it)
- SEC-08: Input validation on auth schemas (min/max length, username pattern)
- SEC-10: .dockerignore files (root, backend, mcp-connector)
- SEC-11: Hardcode ALGORITHM='HS256' as constant, remove from settings
- CQ-01: Gate crawl scheduler on CRAWL_ENABLED env var (default false)
- OS-02: CONTRIBUTING.md
- OS-03: CHANGELOG.md with v1.0.0 entry
- setup.ps1: Add API_TOKEN generation (Windows parity with setup.sh)
2026-06-21 23:13:53 +00:00
Claude
c075eb9257 Stream A: DW brand theme — Instrument Sans + IBM Plex Mono, light/dark mode, all hardcoded colors replaced
- Replace Solar Momentum palette with DiligenceWorks brand identity
- Typography: Outfit → Instrument Sans, Plus Jakarta Sans → IBM Plex Mono (data/stats)
- CSS variables: --orange* → --accent*, new DW blue #2952CC / #6B9BFF
- Dark mode: prefers-color-scheme media query + manual data-theme override
- Border radii: 14/10/20px → 8/6/12px (professional, less playful)
- Font weights: 800/900 → 600/700 (DW uses lighter weights)
- Fixed 30+ hardcoded hex values across 16 files (UI-06)
- Gate banners, progress bars, category chips all use CSS variables
2026-06-21 23:12:25 +00:00
Claude
83e715dbc4 README: platform-specific install guides for Windows 11 (WSL2/Hyper-V/BIOS), macOS (Apple Silicon/Intel/Homebrew), Linux 2026-06-16 03:36:06 +00:00
Claude
dfc5ab3c9d Add Windows setup (setup.ps1), expand README with cross-platform install, Claude Desktop example, backup/restore, architecture diagram, .dockerignore 2026-06-16 03:25:03 +00:00
Claude
e34ae36774 Add navigation links to Settings page for Meal Plans, Integrations, Rewards, Week View 2026-06-16 02:04:44 +00:00
Claude
69320e1e82 Fix all 7 launch blockers from security/QA review
SEC-16: Add frontend ports mapping (80:80) to docker-compose.yml
UI-01:  Add routes for Welcome, SettingsIntegrations, MealPlan in App.jsx
SEC-01: Remove traceback leak from auth error responses
SEC-02: Fix require_admin to use is_admin column (was undefined ADMIN_USERNAME)
SEC-03: Add API_TOKEN auth for MCP connector -> backend communication
SEC-04: OAuth state now uses signed JWT tokens (was raw user UUID)
OS-01:  First registered user gets admin immediately during registration

10 files changed, 97 insertions(+), 25 deletions(-)
2026-06-16 01:50:09 +00:00
Claude
50eae17c34 Fix: split CREATE INDEX migration into separate statements (asyncpg multi-statement restriction) 2026-06-15 14:45:43 +00:00
Claude
c133a463ec Deliver Step 9: agent-card.json, SKILL.md, USDA lookup, integrations dynamic config, Welcome/Integrations/MealPlan pages, API methods, README, routes 2026-06-15 14:40:34 +00:00
Claude
6fb5d759ef Deliver Steps 3-8: integration config, meal plans, provider registry, MCP connector (14 tools), B2A files, nginx proxy, AGENT_GUIDE, LICENSE 2026-06-15 14:34:09 +00:00
Claude
cb892564d9 Deliver Step 1: Backend cleanup — secrets scrubbed, is_admin column, Telegram optional, crypto service, v4-v7 migrations, .env.example, setup.sh 2026-06-15 14:29:53 +00:00
Claude
8e630233f6 Add 3-day fast operational protocol (hour-by-hour) 2026-04-16 15:16:24 +00:00
Claude
d4bac82644 Week 1: bilingual EN/Thai meal plan with full recipes inline
Meal plan now includes:
- Bilingual headers throughout (day names, meal labels, notes)
- Full recipes for all 11 meals inline with bilingual ingredient tables
- Thai translation of every cooking step
- Bilingual prep schedule and substitution rules

Shopping list already had bilingual item tables; added Thai to intro and cost sections.
2026-04-16 14:28:11 +00:00
Claude
bd5f82cf3c Correct Week 1 budget with verified Makro Thailand prices
Previous estimate of ~8,500 baht was USA-centric. Real Makro pricing:
- Chicken thighs boneless trimmed: 40 THB/kg (was estimated ~5x higher)
- Pork shoulder: 100 THB/kg
- Salmon frozen: 380 THB/kg
- Coconut cream UHT 250ml: 30 THB
- Aro macadamia 500g: 400 THB

New totals: ~5500-6000 THB week 1 (one-off pantry), ~3500-4500 THB ongoing.
2026-04-12 12:11:29 +00:00
Claude
3e5f38fe5a Week 1 meal plan + shopping list (expanded to 34 dairy-free recipes)
- Rebuild recipes/INDEX.md with all 83 recipes from 9 sources
- Update recipes.json + CSV with new Whole30/Paleo additions
- Add content/meal-plans/week-01/MEAL-PLAN.md (4 new recipes integrated)
- Add content/meal-plans/week-01/SHOPPING-LIST.md (bilingual EN/Thai, Makro-organized)
- Commit .recipe-candidates-dairy-free.json for future crawls
2026-04-12 12:05:04 +00:00
Claude
32ec2b744e Add recipes.json + CSV extract for fitness app ingestion (64 recipes) 2026-04-12 10:57:16 +00:00
Claude
6cb025ed97 Add 64 keto recipes (crawled from Diet Doctor via JSON-LD, filtered by macros) 2026-04-12 10:48:38 +00:00
claude
5dd5d39ca6 Feature: nutrition module (keto macros + intermittent fasting + electrolytes)
Backend:
- models/nutrition.py: NutritionGoal, Fast, ElectrolyteLog tables
- schemas/nutrition.py: Pydantic schemas for new endpoints
- routers/nutrition.py: /api/nutrition/{today,goals,fasts,electrolytes}
- main.py: register router + migration for new tables + seed keto point rules

Frontend:
- pages/Nutrition.jsx: macro bars, fast timer, eating window, electrolyte quick-add
- App.jsx: /nutrition route + Keto nav tab
- api.js: nutrition endpoints

Points schema for fasts (tier-based partial credit):
16:8=25, 18:6=40, 20:4=60, 24h=200, 36h=350, 48h=500, 72h=1000

Defaults tuned for Scot: 135kg M 44yo strict keto, 12:00-20:00 window,
Asia/Bangkok timezone, 2400/2600 cal rest/training, 20g net carb cap.
2026-04-12 05:13:52 +00:00