Skip to content

feat: Add Weekly Period#41

Merged
sahil-noon merged 4 commits into
mainfrom
260703-wkly-add-weekly-period
Jul 3, 2026
Merged

feat: Add Weekly Period#41
sahil-noon merged 4 commits into
mainfrom
260703-wkly-add-weekly-period

Conversation

@sahil-noon

Copy link
Copy Markdown
Collaborator

Meta

Change ID Type Confidence Plan Review
wkly feat 4.9/5.0 16/16 tasks, 23/23 acceptance ✓ ✓ 1 cycle
Impact +/− Net
raw +751 / −48 +703
true +303 / −39 +264
└ impl +91 / −36 +55
└ tests +212 / −3 +209

excludes fab/, docs/ · generated by fab-kit v2.13.3

Pipeline: intake ✓ → apply ✓ → review ✓ → hydrate ✓ → ship → review-pr

Summary

tu currently supports only daily and monthly granularity, forcing users to drop down to raw ccusage weekly for 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

  • Grammar: w/weekly tokens + wh shorthand (src/node/core/cli.ts)
  • Weekly aggregation (src/node/core/fetcher.ts)
  • Period-to-aggregator mapping (fetcher.ts + cli.ts wiring)
  • currentLabel weekly case (fetcher.ts)
  • Help text (cli.ts FULL_HELP)
  • Shell completions (src/node/core/completions.ts — all three shells)
  • Spec update (docs/specs/usage.md)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts and route aggregation via aggregateForPeriod(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.

Comment thread src/node/core/fetcher.ts
Comment on lines +281 to +285
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);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@sahil-noon sahil-noon marked this pull request as ready for review July 3, 2026 13:11
sahil87 added 4 commits July 3, 2026 18:48
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.
@sahil87 sahil87 force-pushed the 260703-wkly-add-weekly-period branch from c02b255 to 19e2c64 Compare July 3, 2026 13:19
@sahil-noon sahil-noon merged commit b0b461b into main Jul 3, 2026
2 checks passed
@sahil-noon sahil-noon deleted the 260703-wkly-add-weekly-period branch July 3, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants