feat: Add Weekly Period#41
Conversation
There was a problem hiding this comment.
Pull request overview
Adds weekly as a first-class CLI period in tu, implemented as a client-side rollup from daily entries (mirroring existing monthly aggregation) so it works across cache, multi-machine merge, --user, --by-machine, and watch flows.
Changes:
- Add weekly label + aggregation helpers in
fetcher.tsand route aggregation viaaggregateForPeriod(period, entries). - Extend CLI grammar (
w/weekly,wh) and thread weekly through snapshot/history dispatch paths. - Update completions, docs/specs + memory docs, and add/extend tests for weekly behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/node/core/fetcher.ts | Adds weekly label/aggregation + aggregateForPeriod routing; updates currentLabel for weekly. |
| src/node/core/cli.ts | Wires weekly grammar and replaces scattered monthly-only aggregation branches with aggregateForPeriod. |
| src/node/core/completions.ts | Adds w/weekly and wh tokens to bash/zsh/fish completions. |
| src/node/core/tests/fetcher.test.ts | Adds coverage for weekLabel, aggregateWeekly, aggregateForPeriod, and weekly currentLabel. |
| src/node/core/tests/cli-parser.test.ts | Adds parsing tests for w/weekly and wh (and equivalences). |
| src/node/core/tests/completions.test.ts | Updates token-coverage assertions to include weekly tokens. |
| docs/specs/usage.md | Documents weekly period, wh, snapshot semantics, and week-label convention. |
| docs/memory/cli/data-pipeline.md | Updates the CLI/data pipeline “memory” doc to include weekly semantics and routing. |
| fab/changes/260703-wkly-add-weekly-period/plan.md | Captures implementation plan/acceptance for the weekly feature. |
| fab/changes/260703-wkly-add-weekly-period/intake.md | Captures intake rationale/decisions (Sunday-start label alignment, routing approach). |
| fab/changes/260703-wkly-add-weekly-period/.status.yaml | Tracks fab change status/metadata for this feature. |
| fab/changes/260703-wkly-add-weekly-period/.history.jsonl | Records fab stage transition history for this feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function weekLabel(dailyLabel: string): string { | ||
| const d = new Date(`${dailyLabel}T00:00:00Z`); | ||
| d.setUTCDate(d.getUTCDate() - d.getUTCDay()); // getUTCDay(): 0 = Sunday | ||
| return d.toISOString().slice(0, 10); | ||
| } |
There was a problem hiding this comment.
Fixed — weekLabel now guards against an Invalid Date (Number.isNaN(d.getTime())) and falls back to returning the original label instead of throwing a RangeError from toISOString(), so a single malformed label no longer crashes weekly aggregation (graceful degradation). Added tests covering empty, non-date, and out-of-range labels. (5075b19)
Adds w/weekly tokens and wh shorthand to parseDataArgs, mirrors aggregateMonthly with a client-side aggregateWeekly (Sunday-start, ISO week-start date label), and threads it through the period-to- aggregator wiring so cache, multi-machine merge, and watch work without extra plumbing. Updates help text, shell completions, and the grammar spec.
c02b255 to
19e2c64
Compare
Meta
wklyexcludes
fab/,docs/· generated by fab-kit v2.13.3Pipeline: intake ✓ → apply ✓ → review ✓ → hydrate ✓ → ship → review-pr
Summary
tucurrently supports only daily and monthly granularity, forcing users to drop down to rawccusage weeklyfor weekly views — which only sees the local machine and loses tu's multi-machine merge, fetch cache, and watch mode. This adds weekly as a first-class period, aggregated client-side from daily entries (mirroring the existing monthly aggregation) so it inherits the cache, multi-mode merge, and watch support for free.Changes
w/weeklytokens +whshorthand (src/node/core/cli.ts)src/node/core/fetcher.ts)currentLabelweekly case (fetcher.ts)FULL_HELP)src/node/core/completions.ts— all three shells)docs/specs/usage.md)