Registry / database / sleep-compiler

sleep-compiler

JSON →
library1.4.0jsnpmunverified

A command-line sleep tracker that logs, analyzes, and reports sleep patterns. Version 1.4.0 is the latest stable release. Data is stored locally in SQLite at ~/.sleep-compiler/sleep.db with no cloud dependencies. Key differentiators: it operates entirely offline, supports active sleep sessions (sleep now / wake now), generates reports with quality thresholds and consistency scores, and exports CSV. Alternatives like Sleep as Android require a mobile app; sleep-compiler runs in the terminal for developers and privacy-conscious users.

npm install sleep-compiler
INSTALL
IMPORT
SIG · SLEEP-COMPILER
S
sleep-compiler
databasejavascriptv1.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import sleepCompiler from 'sleep-compiler'
const sleepCompiler = require('sleep-compiler')
Package is ESM-only as of v1.4.0
logSleep
import { logSleep } from 'sleep-compiler'
import logSleep from 'sleep-compiler'
Named export, not default
getReport
import { getReport } from 'sleep-compiler'
const getReport = require('sleep-compiler').getReport
ESM named import; CommonJS require will fail

Demonstrates logging a sleep entry and retrieving a report programmatically using named imports.

// Log sleep entry and generate a 7-day report import { logSleep, getReport } from 'sleep-compiler'; async function main() { // Log sleep for last night await logSleep({ sleepTime: '23:30', wakeTime: '07:15', date: '2024-03-15' }); // Get report for last 7 days const report = await getReport({ days: 7 }); console.log(report); } main().catch(err => console.error(err));
sleep-compiler --version
Debug
Known issues
breakingIn v1.4.0, the API changed from CommonJS to ESM-only. require() will throw an error.
fix
Use import statements instead of require(). Update your package.json to include "type": "module" or use .mjs extension.
affects: >=1.4.0
gotchaThe `sleep now` command saves a pending session to ~/.sleep-compiler/pending-sleep.json. If this file is deleted before running `wake now`, the session is lost.
fix
Do not manually modify or delete files in ~/.sleep-compiler/. Use the status command to check active sessions.
affects: >=1.0.0
gotchaTimes must be in 24-hour format (HH:MM). Using 12-hour format with AM/PM will cause parsing errors.
fix
Always provide times in 24-hour format, e.g., '23:30' for 11:30 PM or '07:15' for 7:15 AM.
affects: >=1.0.0
deprecatedThe `--format csv` option for export was added in v1.3.0 and is stable. The old export command without format is deprecated.
fix
Use `sleep-compiler export --format csv` instead of `sleep-compiler export`.
affects: >=1.3.0 <1.4.0
Errors
Common errors & fixes
Error: No pending sleep found. Run `sleep-compiler sleep now` first.
Attempted to run `wake now` without an active sleep session.
fix
Start a sleep session with `sleep-compiler sleep now` before calling `wake now`.
SyntaxError: Cannot use import statement outside a module
Trying to use ESM imports in a CommonJS context without proper configuration.
fix
Add "type": "module" to package.json or rename file to .mjs.
Error: Invalid sleep time format. Use HH:MM in 24h format.
Provided sleep or wake time in wrong format, e.g., using 12-hour with AM/PM.
fix
Use 24-hour format: hours 00-23, minutes 00-59. Example: '23:30'.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
better-sqlite3requiredLocal SQLite database storage
commanderrequiredCommand-line interface parsing
Agent activity
3 hits · last 30 days
node
2
OpenAI (training)
1
Resources
sleep-compiler — npm install sleep-compiler · libregistry