Closed
Labels
featureNew feature or enhancementNew feature or enhancement
Description
Overview
Two complementary features for keeping users informed:
- CLI update prompts - notify users when a newer CLI version is available
- Admin broadcast emails - let admins send announcements to user groups
Feature 1: CLI Update Prompts
Approach: Hybrid (client-side check + backend notice)
A. Client-side npm registry check (primary)
Similar to how gh CLI does it:
- On each CLI invocation, spawn a non-blocking background check against the npm registry
- Cache the result locally (
~/.nemar/update-check.json) with a TTL (e.g., 24 hours) - If a newer version exists, print a yellow banner after command output:
A new version of nemar is available: 0.7.17 -> 0.8.0
Run `bun install -g nemar` to update
Implementation:
- New module:
src/lib/update-check.ts - Check URL:
https://registry.npmjs.org/nemar/latest(tiny JSON response) - Compare with semver (skip pre-release versions like
-dev) - Cache file:
~/.nemar/update-check.jsonwith{ lastCheck, latestVersion } - Environment variable
NEMAR_NO_UPDATE_CHECK=1to disable (for CI/scripts) - The check must never block or slow down the CLI; fire-and-forget with result used on next run
B. Backend notice field (supplementary)
Add an optional notice field to key API responses (e.g., auth status, dataset list):
{
"data": { ... },
"notice": {
"message": "NEMAR CLI v0.8.0 is available with major improvements. Run `bun install -g nemar` to update.",
"level": "info",
"id": "update-0.8.0"
}
}- Backend stores active notices in a D1 table or KV
- CLI displays notices it hasn't shown before (track dismissed notice IDs locally)
- Useful for messages beyond just version updates (maintenance windows, breaking changes, etc.)
- Admin can set/clear notices via
nemar admin notice set/clear
Notice levels: info (blue), warning (yellow), critical (red, can't dismiss)
Feature 2: Admin Broadcast Emails
Design
Extend the existing Resend email service to support broadcast emails.
New admin command
# Send to all approved users
nemar admin notify --to all --subject "New feature: dataset cloning" --body "We've added..."
# Send to admins only
nemar admin notify --to admins --subject "Maintenance window" --body "..."
# Send to specific role
nemar admin notify --to members --subject "..." --body "..."
# Preview (dry run, shows recipient count)
nemar admin notify --to all --subject "..." --body "..." --dry-run
# From a file (for longer messages)
nemar admin notify --to all --subject "..." --body-file announcement.mdBackend endpoint
POST /admin/notify
{
"target": "all" | "admins" | "members",
"subject": "...",
"body": "...", // Plain text or simple markdown
"dry_run": false
}
Response:
{
"sent_to": 42,
"skipped_opted_out": 3,
"failed": 0
}Email preferences extension
Extend the existing email_preferences JSON column:
{
"user_approval": true,
"publication_request": true,
"announcements": true // new; defaults to true
}Users who set announcements: false are skipped (except for critical level notices).
Safeguards
- Owner/admin only (role check)
- Confirmation prompt in CLI before sending ("Send to 42 users? [y/N]")
--dry-runflag to preview- Rate limit: max 1 broadcast per hour (prevent accidental double-sends)
- Log broadcasts in D1 (
admin_notificationstable) for audit trail
Implementation Plan
Phase 1: CLI update check (client-side)
-
src/lib/update-check.tswith npm registry check + cache - Hook into CLI entry point (non-blocking)
-
NEMAR_NO_UPDATE_CHECKenv var support - Display update banner after command output
Phase 2: Backend notices
- D1 migration for
noticestable - Admin endpoints:
POST /admin/notices,DELETE /admin/notices/:id - CLI commands:
nemar admin notice set,nemar admin notice clear - Middleware to attach active notice to API responses
- CLI display logic with local dismissal tracking
Phase 3: Admin broadcast emails
- D1 migration for
admin_notificationsaudit table - Extend
email_preferenceswithannouncementscategory -
POST /admin/notifyendpoint with role filtering -
nemar admin notifyCLI command with dry-run and confirmation - Email template for announcements
Open Questions
- Should the backend notice system use D1 or KV? (KV is simpler for key-value notices, D1 better for audit)
- Should broadcast emails support HTML/markdown rendering or plain text only?
- Should there be a
nemar preferencescommand for users to manage their own email preferences from the CLI?
Metadata
Metadata
Assignees
Labels
featureNew feature or enhancementNew feature or enhancement
Activity
Add CLI update prompts, system notices, and admin broadcast
Address PR review findings for #279
Add CLI update prompts, system notices, and admin broadcast (#280)
neuromechanist commentedon Mar 11, 2026
Implemented in PR #280. All three phases complete: CLI update check, system notices, admin broadcast emails. Migrations 0016/0017 applied to D1.