@drakulavich/oura-cli 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.5.1] - 2026-09-05
10
+
11
+ Fixes from the 0.5.0 exploratory testing sessions: the seam between citty and the command runner, and the sync window.
12
+
13
+ ### Changed
14
+ - `sync` JSON: `import.counts` is replaced by `import.fetched` (rows the API returned per table) and `import.added` (net growth: days or samples the table did not hold before; a revised row for a day already stored counts as fetched, not new). The text summary prints `sleep 28 (+0)` in the same spirit, so a repeat run no longer looks like it imported 28 days. (#51)
15
+ - `sync --from YYYY-MM-DD [--to YYYY-MM-DD]` re-fetches an explicit window for every collection, for recovery after an interrupted run or a deliberate backfill. `--to` defaults to today and requires `--from`. (#53)
16
+
17
+ ### Fixed
18
+ - `sync` resumes every collection from its own last stored day instead of a single watermark taken from the three daily tables. A run interrupted after those tables (Ctrl-C, a crash) used to advance the watermark and leave the other six collections with a permanent gap that no later sync could fill. (#53)
19
+ - First sync fetches exactly 30 inclusive days, as documented, not 31. (#46)
20
+ - `fetch sleep-periods --day D` and `sync` no longer miss the requested day's sleep periods, and `fetch workout --from A --to B` no longer drops workouts on day B: Oura treats `start_date` as exclusive for `sleep` and `end_date` as exclusive for `workout`, and the request bounds are now shifted accordingly. (#58)
21
+ - Two `oura-cli` processes on the same cache no longer fail with `database is locked`: connections wait up to 5 s for a lock, `PRAGMA journal_mode = WAL` is only issued when the file is not already in WAL mode (that statement itself needs an exclusive lock), and a lock that does outlast the wait reports a hint naming the cause. (#56)
22
+ - `~/.oura-cli/` and a newly created cache file are created with `0700` / `0600` permissions, matching the token file; existing files are left alone. (#60)
23
+ - `doctor --offline` reports the token check as `skip` rather than `ok`. The new status keeps `ok: true` and produces no next step, but an agent gating on the JSON can now tell "not checked" from "passed"; `docs/schemas/doctor.json` lists the value. (#59)
24
+ - README: bundle size, the sync wording above, the token-missing message shape, and the `fetch sleep` pipe example, which read a readiness contributor (`hrv_balance`) off the sleep collection and printed `null` for every row. (#62)
25
+ - A token containing whitespace or a line break (for example a token file with a second line) is rejected as `TOKEN_INVALID` (exit 2) naming the source; previously it reached the API layer and came back as `UNKNOWN` with the token quoted in the message. Every error message and hint is now passed through the secret redactor. (#47)
26
+ - `DB_ERROR` (exit 4) is reachable: a corrupt cache file, an unusable `--db` path or a failing query in `db *`, `sync` and `report` now report `DB_ERROR` with a hint instead of `UNKNOWN` / exit 1. (#48)
27
+ - Errors raised before a command runs — unknown command, missing positional, no command on a pipe — use the same envelope as every other error: JSON on stderr when piped, text on a TTY, nothing on stdout, `--no-color` honoured. The commands removed in 0.5.0 (`db reset`, `db import`, `sleep|readiness|activity|hr|spo2|stress|workout …`) point at `fetch`/`sync`. `--help` and a bare `oura-cli` on a TTY still show usage, and `--version` now answers even when other flags are present (it used to exit 1 with usage unless it was the only argument), but not when it sits in another flag's value position. (#49)
28
+ - Undeclared flags and extra positionals are `BAD_ARGS` instead of being ignored, for every command including `describe`, `manifest`, `healthcheck` and `login`: `fetch sleep --dayz 7` no longer returns today's data with exit 0, and `db trends -5` no longer falls back to the 30-day default. (#50, part of #52)
29
+ - Global flags placed before the subcommand are no longer moved past a `--` separator, and `oura-cli constructor` (any `Object.prototype` name) is an unknown command instead of a silent exit 0.
30
+
9
31
  ## [0.5.0] - 2026-09-05
10
32
 
11
33
  ### Breaking
@@ -307,6 +329,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
307
329
  - Local SQLite cache at `~/.oura-cli/oura.db`.
308
330
  - Auth via `oura-cli login`, `OURA_TOKEN`, `OURA_TOKEN_PATH`, or `~/.oura-token`.
309
331
 
332
+ [0.5.1]: https://github.com/drakulavich/oura-cli/releases/tag/v0.5.1
333
+ [0.5.0]: https://github.com/drakulavich/oura-cli/releases/tag/v0.5.0
310
334
  [0.4.4]: https://github.com/drakulavich/oura-cli/releases/tag/v0.4.4
311
335
  [0.4.3]: https://github.com/drakulavich/oura-cli/releases/tag/v0.4.3
312
336
  [0.4.2]: https://github.com/drakulavich/oura-cli/releases/tag/v0.4.2
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  - **Offline-first.** Everything caches into `~/.oura-cli/oura.db` after one `oura-cli sync`. Reports keep working when your internet doesn't.
18
18
  - **Real terminal reports.** `oura-cli report` writes a weekly or monthly digest with averages, trend deltas, and "you slept poorly Tuesday" callouts. No dashboards, no logging in.
19
19
  - **Pipe-friendly.** Output auto-switches to stable JSON when stdout isn't a terminal. Analyse with `jq`, plot with `gnuplot`, or feed it into your own scripts.
20
- - **Single 100 kB binary, MIT, no telemetry.** Built on Bun; zero native dependencies.
20
+ - **Single ~110 kB binary, MIT, no telemetry.** Built on Bun; zero native dependencies.
21
21
 
22
22
  ## Install
23
23
 
@@ -50,18 +50,18 @@ Four commands get you there:
50
50
  ```bash
51
51
  oura-cli login # paste your PAT — input is hidden, nothing echoes to the terminal
52
52
  oura-cli doctor # confirm the token works and the local database is ready
53
- oura-cli sync # first sync backfills the last 30 days; later syncs are incremental
53
+ oura-cli sync # first sync fetches the last 30 days; later syncs resume from the last stored day
54
54
  oura-cli report # weekly digest in the terminal
55
55
  ```
56
56
 
57
- Subsequent `oura-cli sync` only pulls new days, and `oura-cli db today` / `oura-cli db week` read the local cache instantly, no API call.
57
+ Subsequent `oura-cli sync` re-fetches each collection from its own last stored day (Oura revises recent days, so the overlap is deliberate) and reports rows fetched (+new). `oura-cli sync --from 2026-08-01 [--to 2026-08-07]` re-fetches an explicit window for every collection instead — for example after an interrupted sync. `oura-cli db today` / `oura-cli db week` read the local cache instantly, no API call.
58
58
 
59
59
  ### If something looks wrong
60
60
 
61
61
  | What you see | What to run |
62
62
  |---|---|
63
63
  | `No Oura data is available for this report yet.` | `oura-cli sync` |
64
- | `No Oura access token at ~/.oura-token` | `oura-cli login` |
64
+ | `No Oura access token at /…/.oura-token` | `oura-cli login` |
65
65
  | `Oura API 401` | `oura-cli login` with a fresh PAT |
66
66
  | `db today` empty right after a sync | Normal — Oura publishes a day's summary after that night's sleep syncs from the ring. |
67
67
  | Anything else | `oura-cli doctor` |
@@ -123,7 +123,7 @@ Collections: `sleep readiness activity hr spo2 stress workout sleep-periods cv-a
123
123
  Output auto-switches to JSON the moment you pipe it:
124
124
 
125
125
  ```bash
126
- oura-cli fetch sleep --days 7 | jq '.[] | {day, score, hrv: .contributors.hrv_balance}'
126
+ oura-cli fetch sleep --days 7 | jq '.[] | {day, score, deep: .contributors.deep_sleep}'
127
127
  oura-cli db trends 90 > trends.json
128
128
  ```
129
129
 
@@ -163,7 +163,7 @@ This tool reads your personal health data — handle the token with care.
163
163
  | Sleep model | Oura V2 `sleep` | `sleep_model` |
164
164
  | Cardiovascular age | Oura V2 `cardiovascular_age` | `cardiovascular_age` |
165
165
 
166
- Runtime: [Bun](https://bun.sh). Storage: built-in `bun:sqlite`. CLI parsing: [citty](https://github.com/unjs/citty). Output styling: [chalk](https://github.com/chalk/chalk). One 100 kB `dist/index.js`, no native deps.
166
+ Runtime: [Bun](https://bun.sh). Storage: built-in `bun:sqlite`. CLI parsing: [citty](https://github.com/unjs/citty). Output styling: [chalk](https://github.com/chalk/chalk). One ~110 kB `dist/index.js`, no native deps.
167
167
 
168
168
  ## Automation (LLM agents, scripts, MCP)
169
169