- Remove a medical condition
- list - Show current user profile (activity level and medical conditions)
- clear - Remove all medical conditionsWeight Command:
- Supports multiple units with automatic conversion
- Examples: "200lbs", "90kg", "200", "12oz", "2000g"
- Uses your configured unit system as default when no unit specified
Summary Command:
-
--weight-chart - Show only weight trend chart
- --fast-chart - Show only fast duration chart
- --calorie-chart - Show only daily calorie intake chart
- --exercise-chart - Show only daily exercise calories burned chartSetup Command:
-
--units - Configure unit system preference (imperial/metric)
- --weight-unit - Configure weight unit preference (lbs/kg)
- --timezone - Configure timezone preference for accurate date calculations
- --supabase - Configure Supabase cloud storage
- --local - Switch to local file storageClean Command:
-
--config - Also delete API key configurationFile Structure
$3
`
fasting/
āāā bin/
ā āāā cli.js
āāā lib/
ā āāā index.js
ā āāā fasting.js
ā āāā weight.js
ā āāā units.js # NEW: Unit parsing and conversion
ā āāā calorie-estimator.js
ā āāā meal-recommender.js # NEW: AI-powered meal recommendations
ā āāā exercise-estimator.js
ā āāā charts.js
ā āāā storage.js
ā āāā supabase.js
ā āāā fast.js
ā āāā exercise.js
ā āāā config.js
āāā tests/ # Comprehensive test suite
ā āāā units.test.js # NEW: Unit system tests
ā āāā config-units.test.js # NEW: Unit configuration tests
ā āāā exercise-duration.test.js # NEW: Duration parsing tests
ā āāā meal-recommender.test.js # NEW: Recommendation tests
ā āāā ...
āāā .env.example
āāā README.md
`$3
`
~/.config/fasting/
āāā config.json # API key, settings, activity level, and medical conditions
āāā meals.json # Meal and drink logs
āāā weight.json # Weight history
āāā fasts.json # Fast tracking history
āāā exercises.json # Exercise logs
`How It Works
$3
The app tracks your intermittent fasting periods:1. Start a fast - Records timestamp and creates an active fast entry
2. End a fast - Calculates duration and stores completed fast data
3. Custom timing - Specify exact start/end times for accurate tracking
4. History & stats - View all past fasts with duration analysis
$3
Comprehensive imperial and metric unit support:1. Automatic detection - Recognizes unit types (weight, volume) and systems (imperial, metric)
2. Smart conversion - Converts between units automatically (lbs ā kg, oz ā ml, etc.)
3. User preferences - Configure your preferred unit system during setup
4. Flexible input - Accept various formats ("500ml", "16oz", "2 cups", "1.5 hours")
5. AI integration - Provides unit-aware prompts to AI for better estimates
$3
Accurate timezone handling for proper date calculations:1. Timezone awareness - All timestamps are stored using your configured timezone
2. Today's data - "Today's" meals, exercises, and summaries respect your local timezone
3. Flexible configuration - Choose from common timezones or specify custom ones
4. Automatic detection - Defaults to your system timezone if not configured
5. Cross-timezone consistency - Maintains accurate data even when traveling
$3
Comprehensive user profile management for personalized recommendations:1. Activity Level: Set your activity level (sedentary, moderate, active) to get appropriate calorie and exercise recommendations
2. Medical Conditions: Add conditions like "high blood pressure" or "diabetes" for health-conscious recommendations
3. Personalized AI: All OpenAI calls include your profile for tailored suggestions
4. Smart Recommendations: Meal, exercise, and drink suggestions consider your health profile and activity level
5. Profile Management: Easy commands to view, update, and manage your profile settings
$3
Automatic calorie estimation using OpenAI's GPT-4o model with personalized context:1. The description (and optional size) is sent to OpenAI's API with unit system and user profile context
2. The AI estimates calories based on your activity level, medical conditions, and specified portion size
3. Size parsing handles both imperial and metric measurements automatically
4. Personalized estimates consider your health profile for appropriate portion sizing
5. You can specify portion sizes with
--size for more accurate estimates
6. You can still manually override with the -c flag if needed$3
Comprehensive recommendation system for meals, exercises, and drinks based on your profile:1. Profile-aware analysis - Considers your activity level, medical conditions, fasting status, recent meals, weight, and history
2. Multi-type recommendations - Get suggestions for meals, exercises, or drinks based on your needs
3. Health-conscious suggestions - Recommendations consider medical conditions for heart-healthy, diabetic-friendly options
4. Activity-appropriate content - Exercise intensity and meal portions matched to your activity level
5. Unit-aware portions - All measurements provided in your configured unit system
6. Personalized advice - Includes tailored advice based on your health profile and goals
7. Fallback support - Works even without OpenAI API key with sensible default recommendations
Recommendation Features:
- Health profile integration: Activity level and medical conditions inform all suggestions
- Contextual awareness: Knows if you're fasting, your recent meals, exercises, and intake
- Multi-category support: Meals ("sandwiches", "salads"), exercises ("cardio", "strength"), drinks ("smoothies", "teas")
- Advanced filtering: Calorie targets, dietary restrictions, exercise intensity, equipment availability
- Rich information: Includes prep time, ingredients, nutrition notes, exercise instructions, and safety tips
- Beautiful formatting: Well-structured output with clear sections and helpful tips
$3
- Weight trends - ASCII line charts showing weight changes over time
- Fast durations - Bar charts displaying recent fast lengths vs. 16h target
- Daily calories - Line charts showing calorie intake trends over time with averages
- Exercise calories - Line charts showing daily calories burned through exercise
- Comprehensive summary - All-in-one dashboard with current fast status, today's meals, exercises, statistics, and charts$3
The app estimates calories burned using OpenAI's GPT-4o model with personalized context:1. Log exercise - Provide exercise description and duration in minutes
2. Personalized AI estimation - Uses your activity level, medical conditions, weight, and exercise details for accurate calorie burn calculation
3. Health-aware recommendations - Exercise suggestions consider your medical conditions for safe, appropriate workouts
4. Activity-matched intensity - Recommendations match your current activity level for progressive fitness
5. Manual override - Use
-c flag to specify exact calories burned if needed
6. Daily tracking - View total calories burned per day with trend analysis$3
The app supports optional cloud storage using Supabase for data synchronization across devices:1. Setup - Run
fasting setup --supabase to configure cloud storage
2. Automatic sync - All data (meals, exercises, weight, fasts) stored in Supabase
3. Cross-device access - Access your data from multiple devices with the same configuration
4. Local fallback - Switch back to local storage anytime with fasting setup --localRequired Supabase Configuration:
- Supabase URL
- Service Role Key
Environment Variables (optional):
`bash
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
FASTING_STORAGE_MODE=supabase # or 'local'
`$3
Imperial System:
- Drinks: "32oz", "16oz", "8oz", "2 cups", "1 pint", "1 quart"
- Meals: "6oz", "8oz", "1lb", "2 slices", "large portion", "small bowl", "1 cup"
Metric System:
- Drinks: "500ml", "250ml", "1l", "1.5l"
- Meals: "150g", "250g", "500g", "1kg", "large portion", "small bowl"
Duration Examples:
- Minutes: "30", "45", "30 minutes", "45min"
- Hours: "1.5 hours", "2h", "1 hour 30 minutes"
Weight Examples:
- Imperial: "200lbs", "12oz", "2lbs"
- Metric: "90kg", "500g", "1.5kg"
$3
The app stores all data in
~/.config/fasting/ for secure, persistent access:- Configuration: Run
fasting setup to configure or update your API key
- Data Storage: All meals, drinks, and weight data are stored locally
- Data Export: Use fasting export to create a backup zip file at ~/fasting.zip
- Data Restore: Extract the zip file with unzip ~/fasting.zip -d ~ to restore data
- Environment Variable: You can use OPENAI_API_KEY as an alternative (takes precedence)
- Clean Data: Use fasting clean to delete meals/weight data
- Full Reset: Use fasting clean --config to delete everything including API key$3
`bash
Delete meals, weight, and fast data (keeps API key)
fasting cleanDelete everything including API key configuration
fasting clean --config
`If the OpenAI API is unavailable, the app falls back to default estimates (200 calories for meals, 50 for drinks).
Node.js Module API
This package can also be used as a Node.js module in your own applications:
`javascript
import {
logMeal, logDrink, getTodaysEntries, getCalorieHistory,
logWeight, getWeightHistory,
startFast, endFast, getCurrentFast, getFastHistory, getFastStats,
logExercise, getTodaysExercises, getExerciseHistory
} from '@profullstack/fasting';// NEW: Import recommendation and unit functions
import { generateMealRecommendations, formatRecommendations } from '@profullstack/fasting/lib/meal-recommender.js';
import { generateExerciseRecommendations, formatExerciseRecommendations } from '@profullstack/fasting/lib/exercise-recommender.js';
import { generateDrinkRecommendations, formatDrinkRecommendations } from '@profullstack/fasting/lib/drink-recommender.js';
import { parseSize, convertVolume, getSizeExamples } from '@profullstack/fasting/lib/units.js';
import { getUnitSystem, setUnitSystem, getActivityLevel, setActivityLevel, getMedicalConditions, addMedicalCondition, getUserProfile } from '@profullstack/fasting/lib/config.js';
// Fast tracking
startFast(); // Start fast now
startFast('2023-12-01 18:00'); // Start fast at specific time
const currentFast = getCurrentFast(); // Get active fast
const completedFast = endFast(); // End current fast
// Log meals and drinks programmatically
logMeal('Grilled chicken breast', 350);
logDrink('Orange juice', 120);
// Get today's entries
const todaysEntries = getTodaysEntries();
console.log(todaysEntries);
// Weight tracking
logWeight(175.5);
const weightHistory = getWeightHistory();
// Fast history and statistics
const fastHistory = getFastHistory(); // Completed fasts only
const fastStats = getFastStats(); // Statistics summary
// Calorie history
const calorieHistory = getCalorieHistory(); // Daily calorie totals
// Exercise tracking
logExercise('Running', 30, 300); // description, duration (min), calories burned
const todaysExercises = getTodaysExercises(); // Today's exercises
const exerciseHistory = getExerciseHistory(); // Daily exercise calorie totals
// NEW: User profile management
setActivityLevel('active'); // or 'sedentary', 'moderate'
const activityLevel = getActivityLevel();
addMedicalCondition('high blood pressure');
addMedicalCondition('diabetes');
const conditions = getMedicalConditions(); // ['high blood pressure', 'diabetes']
const profile = getUserProfile(); // Complete user profile
// NEW: AI-powered personalized recommendations
const mealRecommendations = await generateMealRecommendations('sandwiches', {
mealType: 'lunch',
calorieTarget: 400,
dietaryRestrictions: 'vegetarian'
});
const formattedMeals = formatRecommendations(mealRecommendations);
const exerciseRecommendations = await generateExerciseRecommendations('cardio', {
duration: 30,
intensity: 'moderate',
location: 'home'
});
const formattedExercises = formatExerciseRecommendations(exerciseRecommendations);
const drinkRecommendations = await generateDrinkRecommendations('smoothies', {
purpose: 'post-workout',
calorieTarget: 200
});
const formattedDrinks = formatDrinkRecommendations(drinkRecommendations);
// NEW: Unit system management
setUnitSystem('metric'); // or 'imperial'
const currentSystem = getUnitSystem();
// NEW: Unit parsing and conversion
const parsed = parseSize('500ml', 'volume');
const converted = convertVolume(16, 'fl oz', 'ml'); // 473.18
const examples = getSizeExamples('volume'); // ['250ml', '500ml', '1l', '1.5l']
`$3
Fast Tracking:
-
startFast(startTime?) - Start a new fast (optional custom start time)
- endFast(endTime?) - End current fast (optional custom end time)
- getCurrentFast() - Get active fast or null
- getFastHistory() - Get all completed fasts
- getFastStats() - Get fast statistics (average, longest, etc.)Meal & Weight Tracking:
-
logMeal(description, calories) - Log a meal with description and calorie count
- logDrink(description, calories) - Log a drink with description and calorie count
- getTodaysEntries() - Get all meals and drinks logged today
- getCalorieHistory() - Get daily calorie totals grouped by date
- logWeight(weight) - Log weight in pounds
- getWeightHistory() - Get complete weight history with timestampsExercise Tracking:
-
logExercise(description, duration, caloriesBurned) - Log exercise with description, duration (minutes), and calories burned
- getTodaysExercises() - Get all exercises logged today
- getExerciseHistory() - Get daily exercise calorie totals grouped by dateNEW: AI-Powered Personalized Recommendations:
-
generateMealRecommendations(preference, options) - Generate personalized meal recommendations
- formatRecommendations(recommendations) - Format meal recommendations for display
- generateExerciseRecommendations(preference, options) - Generate personalized exercise recommendations
- formatExerciseRecommendations(recommendations) - Format exercise recommendations for display
- generateDrinkRecommendations(preference, options) - Generate personalized drink recommendations
- formatDrinkRecommendations(recommendations) - Format drink recommendations for displayNEW: User Profile Management:
-
getActivityLevel() - Get current activity level ('sedentary', 'moderate', 'active')
- setActivityLevel(level) - Set activity level preference
- getMedicalConditions() - Get array of medical conditions
- addMedicalCondition(condition) - Add a medical condition
- removeMedicalCondition(condition) - Remove a medical condition
- setMedicalConditions(conditions) - Set medical conditions array
- getUserProfile() - Get complete user profile objectNEW: Unit System Management:
-
getUnitSystem() - Get current unit system ('imperial' or 'metric')
- setUnitSystem(system) - Set unit system preference
- parseSize(input, type) - Parse size input with unit detection
- convertVolume(value, fromUnit, toUnit) - Convert between volume units
- getSizeExamples(type) - Get size examples for current unit systemNote: When using the module API, you need to provide calorie counts manually for basic functions. Automatic calorie estimation and AI recommendations via OpenAI are available through both CLI commands and the new recommendation API functions.
Development & Testing
$3
The project includes comprehensive unit tests for all functionality:
`bash
Run all tests (core tests only, faster)
pnpm testRun all tests including AI tests (requires OpenAI API key, slower)
pnpm test:aiRun specific test suites
pnpm test:fast # Fast tracking tests
pnpm test:charts # Chart generation tests
pnpm test:fasting # Meal/drink logging tests
pnpm test:weight # Weight tracking tests
pnpm test:calorie-chart # Calorie chart tests
pnpm test:exercise # Exercise tracking tests
`$3
Core Tests (Fast, No API Required):
- Fast Tracking: Start/end fasts, duration calculation, history management
- Charts: Weight line charts, fast bar charts, summary tables
- Meal/Drink Logging: Entry creation, today's entries filtering
- Weight Tracking: Weight logging, history retrieval, trend analysis
- Calorie Charts: Daily calorie aggregation, chart generation, history tracking
- Exercise Tracking: Exercise logging, calorie burn estimation, daily aggregation, chart generation
- Unit System Tests: Imperial/metric unit parsing, conversion, and configuration
- Duration Parsing: Flexible duration format handling (minutes, hours, mixed formats)
- Unit Conversion: Volume and weight conversions between imperial and metric
- Configuration Management: Unit system preferences, backward compatibility
- User Profile Tests: Activity level validation, medical condition management, profile integration
AI Tests (Slower, Requires OpenAI API Key):
- Meal Recommendations: AI response formatting, JSON parsing, fallback handling
- Exercise Recommendations: Exercise suggestion formatting, intensity handling, equipment filtering
- Drink Recommendations: Beverage suggestion formatting, purpose-based filtering
Test Organization:
- Core tests run by default with
pnpm test (11 test files, ~66 tests)
- AI tests only run with pnpm test:ai flag (14 test files, ~69 tests)
- Separation rationale: AI tests require OpenAI API key and take longer to run
- CI/CD friendly: Core tests can run in environments without API keysTest Statistics:
- 14 total test files with 69+ total tests
- 100% pass rate with comprehensive error handling validation
- Isolated testing environment - Uses temporary directories to avoid interfering with real user data
- Integration testing - Validates system consistency and cross-module functionality
All tests use isolated temporary directories to avoid interfering with real user data.
$3
The project includes a git pre-commit hook that runs syntax checks before allowing commits:
`bash
The hook runs automatically on git commit
git commit -m "Your commit message"To manually run the pre-commit check
pnpm run pre-commit
`The pre-commit hook performs:
- Full test suite - Runs all unit tests to ensure code quality
- Comprehensive validation - Tests all functionality including async operations, storage, and charts
- Quality assurance - Prevents broken code from being committed
To bypass the pre-commit hook (not recommended):
`bash
git commit --no-verify -m "Your commit message"
`$3
The project includes example scripts demonstrating usage:
`bash
Run CLI usage example
pnpm exampleRun API usage example
pnpm example:api
`Example Files:
-
examples/basic-usage.js - Demonstrates CLI commands and workflow
- examples/api-usage.js - Shows programmatic Node.js module usagePublishing
$3
`bash
Patch version (bug fixes): 1.0.2 -> 1.0.3
pnpm version patchMinor version (new features): 1.0.2 -> 1.1.0
pnpm version minorMajor version (breaking changes): 1.0.2 -> 2.0.0
pnpm version majorSpecific version
pnpm version 1.2.3
`$3
`bash
Complete workflow
pnpm test # Run tests first
pnpm version patch # Bump version
pnpm publish --access public # Publish to npm
git push && git push --tags # Push to gitDry run to see what would be published
pnpm publish --dry-run
``