Skip to content

Feature/wrap up#33

Merged
magmacomputing merged 9 commits into
mainfrom
feature/wrap-up
May 25, 2026
Merged

Feature/wrap up#33
magmacomputing merged 9 commits into
mainfrom
feature/wrap-up

Conversation

@magmacomputing
Copy link
Copy Markdown
Owner

@magmacomputing magmacomputing commented May 24, 2026

Duration balancing / formatting
Small fixes

Summary by CodeRabbit

  • New Features

    • Added Duration.balance() for calendar-aware unit roll-up and Duration.format() for localized, plural-aware duration strings.
    • Added a global numberFormat/init intl option and new Intl helpers for improved number and unit formatting.
  • Bug Fixes

    • Fixed parser edge case with relative weekday modifiers and period aliases.
    • Fixed CI build failures by falling back when proprietary licensing resources are unavailable.
  • Documentation

    • Added Duration Logic guide and updated v2.11.0 release notes and docs.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

📝 Walkthrough

Walkthrough

Adds Duration.balance() and Duration.format(), memoized Intl helpers, cascading intl.numberFormat support in Tempo.init, a lexer permissiveness fix for per*-prefixed tokens, licensing JWS handling refactor, removal of premium plugin/term helpers, resolve-types updates, docs/changelog/package bumps to v2.11.0, and related tests with explicit locale initialization.

Changes

Duration Formatting and Intl Configuration

Layer / File(s) Summary
Changelogs, versions, CI metadata
CHANGELOG.md, package.json, packages/library/CHANGELOG.md, packages/library/package.json, packages/tempo/package.json, .coderabbit.yaml
Add v2.11.0 release notes, bump root/library/tempo versions to 2.11.0, and add PR title instruction for coderabbit.
Library Intl Utilities for Number Formatting
packages/library/src/common/international.library.ts, packages/library/src/common/string.library.ts, packages/library/CHANGELOG.md, packages/library/package.json
Add memoized getNF factory, formatNumber, formatUnit, and small string utilities (reveal/conceal) to support localized numeric and unit formatting with fallbacks.
Duration Type and IntlOptions Definitions & Docs
packages/tempo/src/tempo.type.ts, packages/tempo/CHANGELOG.md, packages/tempo/doc/releases/v2.x.md, packages/tempo/doc/tempo.duration.md, packages/tempo/doc/tempo.config.md
Extend Duration with balance() and format() typings, add IntlOptions.numberFormat, and add comprehensive Duration Logic documentation and release notes.
Duration balance() and format() Core Implementation
packages/tempo/src/module/module.duration.ts
Rewrite toDuration() to accept context (relativeTo, locale, numberFormat) and attach non-enumerable balance() (nominal/strict) and format() (largest-unit, locale-aware) methods; pass context through duration()/since().
Intl Configuration Merging
packages/tempo/src/support/support.intl.ts, .vitepress/config.ts
Deep-merge numberFormat alongside relativeTime in resolveIntl() and add VitePress sidebar entry for Duration Logic.
Licensing JWS resolution refactor
packages/tempo/src/tempo.class.ts
Capture pending JWS locally in Tempo.init, resolve after importing #tempo/license, and clear license status conditionally on error to avoid race conditions.
Support license and post-build type resolver
packages/tempo/src/support/support.license.ts, packages/tempo/bin/resolve-types.ts
Make Validator.verify() return invalid when crypto engine is missing; update resolve-types to map #tempo/license to support/support.license.js, adjust #library -> dist/lib/ mapping, and simplify copy/rewrite flow.
Remove premium plugin/term helpers
packages/tempo/src/plugin/plugin.util.ts, packages/tempo/src/plugin/term/term.util.ts, packages/tempo/src/plugin/term/term.index.ts
Remove definePremiumPlugin and definePremiumTerm exports and related registration/commentary; update re-exports and imports (reveal added where used).
Lexer Enhancement for Weekday parsing
packages/tempo/src/engine/engine.lexer.ts
Allow per*-prefixed tokens in parseWeekday() rest validation so relative weekday modifiers and period-alias strings coexist.
Tests and locale initialization
packages/tempo/test/plugins/duration.balance.test.ts, packages/tempo/test/*
Add tests for balance()/format() and update multiple suites to call Tempo.init({ locale: 'en-US' }) for deterministic locale-sensitive assertions.
Docs reorg and examples
packages/tempo/doc/tempo-vs-temporal.md, packages/tempo/doc/tempo.weekday.md, packages/tempo/doc/tempo.plugin.md, packages/tempo/doc/tempo.term.md
Reorganize log-stamp content, shorten until/since examples with links to Duration Guide, replace premium-guidance with commercial distribution instructions, and adjust weekday examples to symbolic modifiers.
Rollup & small cleanups
packages/tempo/rollup.config.js, other minor EOF/comment edits
Remove a top-level comment and a blank line in rollup config and perform minor formatting tweaks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • magmacomputing/magma#30: Related licensing system changes touching Tempo licensing/JWS resolution and license-state plumbing.
  • magmacomputing/magma#31: Related edits to support.license Validator behaviour and licensing verification logic.

Poem

🐰 I hop through code with nimble cheer,

I balance units, make formats clear,
Intl helpers cached and bright,
Locale set true — tests pass at night,
v2.11.0 — a joyful leap!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'Feature/wrap up' is vague and does not meaningfully describe the actual changes. The changeset encompasses version 2.11.0 release with duration balancing/formatting, multiple Intl utilities, documentation updates, licensing refactoring, and test fixtures—far more than what 'wrap up' conveys. Use a more descriptive title following conventional commit format (e.g., 'feat: release v2.11.0 with duration balancing and formatting' or 'chore: v2.11.0 release with duration utilities and licensing updates').
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/wrap-up

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@magmacomputing
Copy link
Copy Markdown
Owner Author

@coderabbitai please set reviews.auto_title_instructions

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/tempo/src/module/module.duration.ts`:
- Around line 59-67: The decomposition uses Math.floor and % which misbehaves
for negative totalDays; change the logic in module.duration.ts (where years,
months, weeks are computed from totalDays) to use truncating division and
subtraction instead of floor+mod. Specifically, compute each unit with
Math.trunc(totalDays / 365) (and similarly for 30 and 7 for months/weeks), then
subtract years * 365 (etc.) from totalDays to get the remainder; apply the same
pattern for months and weeks so negative durations correctly distribute across
units.
- Around line 97-105: The .format() branch in
packages/tempo/src/module/module.duration.ts currently only checks years→seconds
and then returns '0' if none match, which drops sub-second-only durations;
update the conditional sequence in the formatting logic (the method that
contains the lines checking this.years/this.months/...this.seconds) to also
check this.milliseconds, this.microseconds, and this.nanoseconds (in that order
or smallest-first as desired) and set val and u accordingly so sub-second
durations are formatted instead of returning '0'. Ensure the same identifying
symbols (this.milliseconds, this.microseconds, this.nanoseconds, and the
existing val/u variables) are used and that the final fallback only triggers
when truly zero.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a48302e-4525-4436-b462-331c277a59fa

📥 Commits

Reviewing files that changed from the base of the PR and between f532814 and c9e8544.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (23)
  • CHANGELOG.md
  • package.json
  • packages/library/CHANGELOG.md
  • packages/library/package.json
  • packages/library/src/common/international.library.ts
  • packages/tempo/.vitepress/config.ts
  • packages/tempo/CHANGELOG.md
  • packages/tempo/doc/releases/v2.x.md
  • packages/tempo/doc/tempo-vs-temporal.md
  • packages/tempo/doc/tempo.config.md
  • packages/tempo/doc/tempo.duration.md
  • packages/tempo/doc/tempo.weekday.md
  • packages/tempo/package.json
  • packages/tempo/src/engine/engine.lexer.ts
  • packages/tempo/src/module/module.duration.ts
  • packages/tempo/src/support/support.intl.ts
  • packages/tempo/src/tempo.class.ts
  • packages/tempo/src/tempo.type.ts
  • packages/tempo/test/discrete/compact.time.test.ts
  • packages/tempo/test/engine/layout.order.test.ts
  • packages/tempo/test/instance/instance.since.test.ts
  • packages/tempo/test/plugins/duration.balance.test.ts
  • packages/tempo/test/plugins/slick.shorthand.test.ts

Comment thread packages/tempo/src/module/module.duration.ts Outdated
Comment thread packages/tempo/src/module/module.duration.ts
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@magmacomputing, I'll fetch the current CodeRabbit configuration and schema to help set reviews.auto_title_instructions properly.


🛠 Debug Information Gathered


@magmacomputing, I can see that reviews.auto_title_instructions is currently set to an empty string in your .coderabbit.yaml. This field accepts a text prompt that guides how CodeRabbit generates automatic PR titles.

Could you provide the value you'd like to set? For example:

"Generate a concise PR title that starts with a conventional commit type (feat, fix, chore, etc.) followed by a short imperative description of the change."

Once you share the desired instructions, I can update your .coderabbit.yaml directly or show you the exact diff to apply.

@magmacomputing
Copy link
Copy Markdown
Owner Author

@coderabbitai: please set reviews.auto_title_instructions to
"Generate a concise PR title that starts with a conventional commit type (feat, fix, chore, etc.) followed by a short imperative description of the change."

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the current .coderabbit.yaml
cat .coderabbit.yaml

Length of output: 534


🏁 Script executed:

#!/bin/bash
# Get the current file SHA for the API update
gh api repos/magmacomputing/magma/contents/.coderabbit.yaml \
  --jq '{sha: .sha, content: .content}' 2>/dev/null

# Prepare new file content
NEW_CONTENT=$(cat <<'EOF'
# .coderabbit.yaml
reviews:
  auto_title_instructions: "Generate a concise PR title that starts with a conventional commit type (feat, fix, chore, etc.) followed by a short imperative description of the change."
  path_filters:
    # Use "! " at the start of a pattern to EXCLUDE it from the review
    - "!**/doc/api/**"            # Ignore ONLY the generated TypeDoc API documentation
    - "!**/docs/**"               # Ignore other generated documentation artifacts
    - "!**/.vitepress/cache/**"   # Ignore VitePress cache
    - "!**/.vitepress/dist/**"    # Ignore VitePress build output
    - "!**/dist/**"               # Ignore all build artifacts
    - "!**/vendor/**"             # Ignore third-party code
EOF
)

# Get SHA
SHA=$(gh api repos/magmacomputing/magma/contents/.coderabbit.yaml --jq '.sha')

# Encode content to base64
ENCODED=$(echo "$NEW_CONTENT" | base64 -w 0)

# Update the file on the feature/wrap-up branch
gh api repos/magmacomputing/magma/contents/.coderabbit.yaml \
  --method PUT \
  --field message="chore: set auto_title_instructions in .coderabbit.yaml" \
  --field content="$ENCODED" \
  --field sha="$SHA" \
  --field branch="feature/wrap-up" \
  --jq '.commit.html_url'

Length of output: 888


@magmacomputing, done! I've updated .coderabbit.yaml on the feature/wrap-up branch with the following change:

reviews:
  auto_title_instructions: "Generate a concise PR title that starts with a conventional commit type (feat, fix, chore, etc.) followed by a short imperative description of the change."
  path_filters:
    ...

You can view the commit here: 92db727

Once this PR is merged into main, CodeRabbit will apply these instructions when auto-generating PR titles for future pull requests.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/tempo/src/plugin/term/term.index.ts`:
- Line 11: The public barrel export removed definePremiumTerm which is a
breaking change; restore backwards compatibility by re-exporting a deprecated
shim named definePremiumTerm from this module (term.index.ts) that forwards to
the new implementation (e.g., call or re-export the appropriate symbol used by
defineTerm/defineRange/getTermRange), mark it as deprecated in comments, and
keep the existing export line (export { defineTerm, defineRange, getTermRange })
while adding export { definePremiumTerm } so existing imports continue to work
without changing consumers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3e551310-9b1d-4df1-9b02-570805d56a0f

📥 Commits

Reviewing files that changed from the base of the PR and between 92db727 and 50b25d1.

📒 Files selected for processing (10)
  • packages/library/src/common/string.library.ts
  • packages/tempo/bin/resolve-types.ts
  • packages/tempo/doc/tempo.plugin.md
  • packages/tempo/doc/tempo.term.md
  • packages/tempo/rollup.config.js
  • packages/tempo/src/module/module.duration.ts
  • packages/tempo/src/plugin/plugin.util.ts
  • packages/tempo/src/plugin/term/term.index.ts
  • packages/tempo/src/plugin/term/term.util.ts
  • packages/tempo/src/support/support.license.ts
💤 Files with no reviewable changes (1)
  • packages/tempo/src/plugin/term/term.util.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/tempo/rollup.config.js

Comment thread packages/tempo/src/plugin/term/term.index.ts
@magmacomputing magmacomputing merged commit 330a12a into main May 25, 2026
2 checks passed
@magmacomputing magmacomputing deleted the feature/wrap-up branch May 25, 2026 03:30
@coderabbitai coderabbitai Bot mentioned this pull request May 26, 2026
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.

1 participant