Skip to content

feat(cli): create --currency and --usd-rate seed what the app bills in - #440

Merged
tortuvshin merged 8 commits into
mainfrom
feat/create-currency
Oct 26, 2026
Merged

tortuvshin merged 8 commits into
mainfrom
feat/create-currency

Conversation

@tortuvshin

Copy link
Copy Markdown
Member

Why

The scaffold's composition root always seeded currency: "USD", usdRateMicros: 1_000_000, and the row is seeded once. A product that sells in another currency had to know to edit lib/intelligo.ts before the dev server first started. Nothing said so until it was too late, and the ledger was then in USD.

  • intelligo create my-app --currency MNT --usd-rate 3450 writes currency: "MNT", usdRateMicros: 3_450_000_000 into the ensureBillingSettingsRow call. The values reach the template through __CURRENCY__ / __USD_RATE_MICROS__.
  • The CLI never guesses a rate. A currency other than USD without --usd-rate, a non-positive rate, a code that is not ISO 4217, or USD with a rate other than 1 is refused before any question is asked.
  • Without the flags the call renders as before, USD at 1, through substitute()'s defaults. An existing app re-generates to a byte-identical file, and apps/app/lib/intelligo.ts is unchanged.
  • app-scaffold template 1.25.0. The credits-and-money docs say to decide before the first boot.

Stacked on #439, which adds the default-variable mechanism; it retargets to main once that merges.

doctor does not check the currency. The choice lives in the composition root, which doctor does not read, and the database row is authoritative once seeded. A check would have to guess intent, so it was left out.

Review

  • AI-assisted: an agent wrote part of this diff
  • Touches a high-risk path (the "High risk" section of .github/CODEOWNERS); the review-window check holds it for 24 hours after it is first seen as high-risk

Read line by line: packages/cli/src/commands/create.ts (currencyVariables) and create-flow.ts (flag parsing). Changed assertion: template-versions.json pins 1.25.0.

Checklist

  • One concern, with a conventional commit subject
  • A test that fails without the change (a case in tests/architecture/ for a boundary change)
  • pnpm type-check && pnpm lint && pnpm test pass locally
  • Public API (exports, CLI flags and output, environment variables, the schema) changes only as RELEASES.md allows: removals and changes of meaning wait for a major, after a deprecation
  • A CHANGELOG.md entry under [Unreleased] for anything a consumer notices
  • No product vocabulary in a package; installed registry components are not edited (a seam in packages/registry/base/ instead)

Every item ships messages/mn/<item>.json beside its English file. An
architecture test holds each translation to the English keys and ICU
arguments (a plural branch's body is text, not an argument), so a key
added in English fails until it is translated. intelligo sync merges a
shipped translation like English: untouched values take the new text,
reworded ones are kept.

intelligo create --locales en,mn routes those locales, the first as the
default, through __LOCALES__ and __DEFAULT_LOCALE__ in the scaffold's
i18n/routing.ts. substitute() fills both with English when a recorded
app has no value, so an app made before the flag re-generates to the
same file. app-scaffold template 1.24.0.
The composition root's ensureBillingSettingsRow call takes the currency
and its rate per USD from __CURRENCY__ and __USD_RATE_MICROS__. The row
is seeded once, so the choice belongs before the first boot, where the
scaffold put USD unasked. A currency other than USD without a rate is
refused, as is a code that is not ISO 4217, before any question is
asked. Without the flags the call renders as before, USD at 1, so an
existing app re-generates to the same file. app-scaffold template 1.25.0.
@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
intelligo-web 53ea247 Commit Preview URL

Branch Preview URL
Oct 25 2026, 04:18 PM

# Conflicts:
#	CHANGELOG.md
#	apps/app/intelligo.manifest.json
#	apps/website/src/data/proof.json
#	packages/cli/src/__tests__/template-versions.json
#	packages/cli/templates/manifest.json
@tortuvshin
tortuvshin changed the base branch from feat/registry-mongolian to main October 26, 2026 14:54
…at/create-currency

# Conflicts:
#	CHANGELOG.md
#	apps/app/intelligo.manifest.json
#	apps/website/src/data/proof.json
#	packages/cli/src/__tests__/template-versions.json
#	packages/cli/templates/manifest.json
…nsport (#436)

mastraStreamTurn({ agent, maxSteps, memory, streamOptions }) is a
streamTurn that runs a turn with agent.stream and renders it through
@mastra/ai-sdk, so auth, admission, persistence and settlement stay the
transport's.

Usage settles from every finished step, summed from onStepFinish:
Mastra's totalUsage rejects on a stopped or failed run, and never
settles when the reader cancels, which left the turn waiting or
settled at zero. memory: true scopes Mastra memory to the conversation
under the workspace and the user and sends only the new message, as
Mastra's chat route does. The chat item's server config now points at
the item instead of a hand-written binding.

Pinned against a real Mastra agent on a mock model: a two-step tool
loop settles both steps, a stopped turn settles the finished one, a
turn that spent nothing fails, and the binding's own options win over
streamOptions.
@tortuvshin
tortuvshin merged commit 164122c into main Oct 26, 2026
9 of 11 checks passed
@tortuvshin
tortuvshin deleted the feat/create-currency branch October 26, 2026 14:58
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