Skip to content

feat(cli): ambient claim reminder in minted directories#1583

Closed
shapirodaniel wants to merge 2 commits into
stack/mint-and-claim/a1/05-remint-guardrailfrom
stack/mint-and-claim/a1/06-ambient-reminder
Closed

feat(cli): ambient claim reminder in minted directories#1583
shapirodaniel wants to merge 2 commits into
stack/mint-and-claim/a1/05-remint-guardrailfrom
stack/mint-and-claim/a1/06-ambient-reminder

Conversation

@shapirodaniel

@shapirodaniel shapirodaniel commented Jul 22, 2026

Copy link
Copy Markdown

Description

this PR adds terminal reminders on sanity commands run inside a mint-and-claim provisioned directory, containing a .env with pre-claimed project metadata. high level,

  • we maintain pre-claim project metadata on ~/.config/sanity/config.json and a project-scoped ledger
  • we nudge statelessly whenever possible, and check upstream claim status apis when necessary
  • we fallback to ledger data if we can't reach upstreams, ex. when transient failures prevent claim state reconciliation

Stack

(each PR reviews against its base; merge bottom-up only):

  1. stack/mint-and-claim/a1/01-terminal-presentation
  2. stack/mint-and-claim/a1/02-mint-core
  3. stack/mint-and-claim/a1/03-claim-reminders
  4. stack/mint-and-claim/a1/04-init-signpost
  5. stack/mint-and-claim/a1/05-remint-guardrail
  6. stack/mint-and-claim/a1/06-ambient-reminder ← this diff
  7. stack/mint-and-claim/a1/07-logout-env-token

What to review

The ambient block in runClaimNudges and lookupClaimStateViaProject (the org read) in the mint service.

Testing

Layer-scoped unit tests included (test:source ≥ 1:1); every layer validated standalone (full typecheck + targeted tests at each checkout).

pr1583-ambient-reminder

🤖 Generated with Claude Code


Note

Low Risk
CLI-only UX and read-only claim checks on every command in minted dirs; fail-open behavior limits incorrect registry updates.

Overview
Adds a stateless ambient reminder when you run any sanity command inside a minted project directory: if .env has both SANITY_PROJECT_ID and SANITY_AUTH_TOKEN and the project is still on the unclaimed ledger, a dim expiry line (with claim URL) prints on every invocation—unless a tiered waterfall nudge already used the single reminder slot.

Claim state for that line is checked via new lookupClaimStateViaProject, which hits the project-scoped API with the robot token and treats organizationId === oSystemUnclaimed as claimable (404 → expired, 401/network → fail open). That path avoids the provision lookup rate budget used by escalated nudges.

Tiered nudge copy is split one sentence per line; claimed/expired handling is centralized in shared helpers. Unit tests cover the org read and ambient behavior (tier precedence, no token after claim handoff, ledger fallback).

Reviewed by Cursor Bugbot for commit e02db89. Bugbot is set up for automated code reviews on this repo. Configure here.

@shapirodaniel

Copy link
Copy Markdown
Author

bugbot run

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against stack/mint-and-claim/a1/05-remint-guardrail (61c95822)

@sanity/cli

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 2.2 KB -
Internal (gzip) 838 B -
Bundled (raw) 11.20 MB -
Bundled (gzip) 2.11 MB -
Import time 865ms +2ms, +0.2%

bin:sanity

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.90 MB -
Bundled (gzip) 1.78 MB -
Import time 2.09s +1ms, +0.0%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against stack/mint-and-claim/a1/05-remint-guardrail (61c95822)

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 114.1 KB -
Internal (gzip) 29.2 KB -
Bundled (raw) 21.76 MB -
Bundled (gzip) 3.46 MB -
Import time 765ms -2ms, -0.3%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-build

Compared against stack/mint-and-claim/a1/05-remint-guardrail (61c95822)

@sanity/cli-build/_internal/build

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 113.8 KB -
Internal (gzip) 28.7 KB -
Bundled (raw) 17.76 MB -
Bundled (gzip) 3.56 MB -
Import time 1.11s -5ms, -0.5%

@sanity/cli-build/_internal/env

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 1.8 KB -
Internal (gzip) 644 B -
Bundled (raw) 1.31 MB -
Bundled (gzip) 333.8 KB -
Import time 121ms +1ms, +0.7%

@sanity/cli-build/_internal/extract

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 8.6 KB -
Internal (gzip) 2.7 KB -
Bundled (raw) 155.0 KB -
Bundled (gzip) 39.5 KB -
Import time 241ms -0ms, -0.0%

🗺️ ./_internal/env · ./_internal/extract · @sanity/cli-build:./_internal/build treemap too large to embed · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against stack/mint-and-claim/a1/05-remint-guardrail (61c95822)

Metric Value vs stack/mint-and-claim/a1/05-remint-guardrail (61c9582)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 89fceb8. Configure here.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/actions/init/initAction.ts 90.2% (+ 0.1%)
packages/@sanity/cli/src/actions/init/newCommandBanner.ts 100.0% (new)
packages/@sanity/cli/src/commands/new.ts 100.0% (new)
packages/@sanity/cli/src/commands/projects/mint.ts 99.1% (new)
packages/@sanity/cli/src/hooks/prerun/claimReminders.ts 88.9% (new)
packages/@sanity/cli/src/services/mintProject.ts 76.8% (new)
packages/@sanity/cli/src/util/claimNudges.ts 96.8% (new)
packages/@sanity/cli/src/util/envFile.ts 100.0% (new)
packages/@sanity/cli/src/util/flowOutput.ts 78.9% (new)
packages/@sanity/cli/src/util/newCommandSplash.ts 100.0% (new)
packages/@sanity/cli/src/util/terminalLink.ts 100.0% (new)

Comparing 11 changed files against main @ f6fd22ccd40bb8346e8ecdb5e0cfe54d62f54823

Overall Coverage

Metric Coverage
Statements 78.6% (+ 0.0%)
Branches 70.1% (- 0.2%)
Functions 74.5% (+ 0.2%)
Lines 79.1% (+ 0.0%)

@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from 2a8a9ef to 6fd1ab1 Compare July 22, 2026 16:01
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 89fceb8 to 0c76d83 Compare July 22, 2026 16:01
@shapirodaniel

Copy link
Copy Markdown
Author

bugbot run

Comment thread packages/@sanity/cli/src/services/mintProject.ts Outdated
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from a3c5b99 to 8638226 Compare July 22, 2026 17:03
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from aae0c9c to 16b3d9a Compare July 22, 2026 17:03
@shapirodaniel

Copy link
Copy Markdown
Author

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 16b3d9a. Configure here.

@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from 902df26 to 55e28fe Compare July 22, 2026 17:58
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 88b6a10 to 8c23560 Compare July 22, 2026 17:58
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from 01432a6 to 84d2fe6 Compare July 22, 2026 18:16
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from c92f162 to 563ef34 Compare July 22, 2026 18:16
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from 200134d to 5160e89 Compare July 22, 2026 18:23
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from e2e0180 to 97b4f4d Compare July 22, 2026 18:23
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from 2f1e555 to fe566bc Compare July 22, 2026 18:33
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 09a38ca to a5d9ee8 Compare July 22, 2026 18:33
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from 6037bb7 to 9f18054 Compare July 22, 2026 19:05
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 7fccfad to 076ca58 Compare July 22, 2026 19:05
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from e8cf817 to 72fb947 Compare July 22, 2026 20:41
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from d8e149d to c6fb008 Compare July 22, 2026 20:41
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from b1dc8c0 to d2d61a0 Compare July 22, 2026 21:04
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 0147139 to 07cd654 Compare July 22, 2026 21:04
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from ad4dd7b to 1e0fdca Compare July 22, 2026 21:14
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from f9f492c to 68fdc80 Compare July 22, 2026 21:14
@shapirodaniel

Copy link
Copy Markdown
Author

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 841af5d. Configure here.

@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from ef9239f to 890f1e0 Compare July 22, 2026 21:21
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 841af5d to 890f1e0 Compare July 22, 2026 21:21
@shapirodaniel shapirodaniel reopened this Jul 22, 2026
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 890f1e0 to 818801c Compare July 22, 2026 21:30
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from c16606b to 182305a Compare July 22, 2026 21:34
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from 5e024e7 to 9c79ff8 Compare July 22, 2026 21:34
@shapirodaniel

Copy link
Copy Markdown
Author

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9c79ff8. Configure here.

When the working directory's .env points at a registered unclaimed project
and no other reminder fired, every CLI invocation prints one dim stateless
line (project id, time left, claim URL) on stderr. No dedupe marker, no
network — the tiered waterfall remains the only state-writing path, and
still wins the single reminder slot per invocation.

Co-Authored-By: Claude Fable 5 <[email protected]>
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/05-remint-guardrail branch from c0c3a4d to 61c9582 Compare July 22, 2026 21:56
@shapirodaniel
shapirodaniel force-pushed the stack/mint-and-claim/a1/06-ambient-reminder branch from a1d8d81 to f15a4f1 Compare July 22, 2026 21:56
@shapirodaniel
shapirodaniel marked this pull request as ready for review July 22, 2026 22:47
@shapirodaniel
shapirodaniel requested a review from a team as a code owner July 22, 2026 22:47
@shapirodaniel

Copy link
Copy Markdown
Author

all feedback addressed on #1592, canceling this PR to consolidate after offline sync

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