@cratis/pi 8.11.0 → 8.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +1 -1
  2. package/package/corpus/harnesses/pi/extensions/shared/skillSelection.ts +2 -2
  3. package/package/corpus/rules/profiles.md +1 -1
  4. package/package/corpus/skills/cratis-ai-corpus-authoring/SKILL.md +1 -1
  5. package/package/corpus/skills/cratis-ai-corpus-authoring/references/checklist.md +1 -1
  6. package/package/corpus/skills/cratis-arc-localize-application/SKILL.md +50 -0
  7. package/package/corpus/skills/cratis-arc-localize-application/references/csharp.md +52 -0
  8. package/package/corpus/skills/cratis-arc-localize-application/references/go.md +44 -0
  9. package/package/corpus/skills/cratis-arc-localize-application/references/typescript-switcher.md +59 -0
  10. package/package/corpus/skills/cratis-arc-localize-application/references/typescript-tooling.md +82 -0
  11. package/package/corpus/skills/cratis-arc-localize-application/references/typescript.md +151 -0
  12. package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +1 -1
  13. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +2 -0
  14. package/package/corpus/skills/cratis-components-theme-application/references/localization.md +1 -0
  15. package/package/corpus/skills/cratis-migrate-arc-24-to-25/SKILL.md +48 -0
  16. package/package/corpus/skills/cratis-migrate-arc-24-to-25/references/csharp.md +30 -0
  17. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +1 -1
  18. package/package/profile-catalog.json +60 -0
  19. package/package.json +1 -1
  20. package/src/index.ts +6 -1
@@ -11,7 +11,7 @@ Select `profiles` and `languages` in `.cratis/ai.json` that cover exactly what t
11
11
 
12
12
  - **Base.** `cratis/application` for a product built on Cratis; `cratis/engineering` for a Cratis library or tool. Narrow an application through `languages`, not `cratis/application/<lang>` profiles, which omit the skills for running and diagnosing it.
13
13
  - **List every language written**, frontend included (`csharp,typescript`), because a composed profile for an unlisted language is dropped silently.
14
- - **Add per tool.** `cratis/stage` to render or run a model, `cratis/studio` to work in Studio through its MCP server, `cratis/chronicle/mcp` to inspect a running store, `cratis/screenplay` to model where the selection lacks it. A selected profile is not model-first opt-in.
14
+ - **Add per tool.** `cratis/stage` to render or run a model, `cratis/studio` to work in Studio through its MCP server, `cratis/chronicle/mcp` to inspect a running store, `cratis/screenplay` to model where the selection lacks it. A selected profile is not model-first opt-in. **Only during an upgrade:** the matching `cratis/migrate/<product>-<from>-to-<to>` profile; reinstall without it once the upgrade is merged.
15
15
  - **Select explicitly.** `cratis/application` composes neither `cratis/arc/typescript` nor `cratis/arc/go`, which a TypeScript or Go backend needs; no profile composes `cratis/codescene`, `cratis/playwright` or `cratis/orchestration`. Python has no application SDK skills; `cratis/language/<lang>` adds conventions, not SDK skills.
16
16
 
17
17
  When changing the catalog or rule frontmatter (`cratis-ai-corpus-authoring`):
@@ -60,7 +60,7 @@ export function selectedProfileIds(configuration: AiConfiguration): Set<string>
60
60
  /**
61
61
  * The skills the packaged `@cratis/pi` makes available for a repository, resolved from `.cratis/ai.json` and the
62
62
  * profile catalog exactly as `selectedSkillPaths` in `@cratis/pi` does (a repository without `ai.json` gets every
63
- * catalog skill, because that is what the package loads for it). Undefined when the selection cannot be resolved,
63
+ * catalog skill except migration-profile targets, because that is what the package loads for it). Undefined when the selection cannot be resolved,
64
64
  * so a caller hints nothing rather than guessing.
65
65
  *
66
66
  * This mirrors `Source/Pi.Plugin/src/index.ts`, which cannot import from the corpus in both the repository and
@@ -72,7 +72,7 @@ export function selectedSkillNames(cwd: string): string[] | undefined {
72
72
  if (profiles === undefined) return undefined;
73
73
  const configurationPath = join(cwd, '.cratis', 'ai.json');
74
74
  if (!existsSync(configurationPath)) {
75
- return [...new Set(profiles.flatMap(profile => profile.availableTargets ?? []))].sort();
75
+ return [...new Set(profiles.filter(profile => !profile.id.startsWith('cratis/migrate/')).flatMap(profile => profile.availableTargets ?? []))].sort();
76
76
  }
77
77
  const configuration = JSON.parse(readFileSync(configurationPath, 'utf8')) as AiConfiguration;
78
78
  const selected = resolveProfiles(configuration, profiles, false);
@@ -10,7 +10,7 @@ Select `profiles` and `languages` in `.cratis/ai.json` that cover exactly what t
10
10
 
11
11
  - **Base.** `cratis/application` for a product built on Cratis; `cratis/engineering` for a Cratis library or tool. Narrow an application through `languages`, not `cratis/application/<lang>` profiles, which omit the skills for running and diagnosing it.
12
12
  - **List every language written**, frontend included (`csharp,typescript`), because a composed profile for an unlisted language is dropped silently.
13
- - **Add per tool.** `cratis/stage` to render or run a model, `cratis/studio` to work in Studio through its MCP server, `cratis/chronicle/mcp` to inspect a running store, `cratis/screenplay` to model where the selection lacks it. A selected profile is not model-first opt-in.
13
+ - **Add per tool.** `cratis/stage` to render or run a model, `cratis/studio` to work in Studio through its MCP server, `cratis/chronicle/mcp` to inspect a running store, `cratis/screenplay` to model where the selection lacks it. A selected profile is not model-first opt-in. **Only during an upgrade:** the matching `cratis/migrate/<product>-<from>-to-<to>` profile; reinstall without it once the upgrade is merged.
14
14
  - **Select explicitly.** `cratis/application` composes neither `cratis/arc/typescript` nor `cratis/arc/go`, which a TypeScript or Go backend needs; no profile composes `cratis/codescene`, `cratis/playwright` or `cratis/orchestration`. Python has no application SDK skills; `cratis/language/<lang>` adds conventions, not SDK skills.
15
15
 
16
16
  When changing the catalog or rule frontmatter (`cratis-ai-corpus-authoring`):
@@ -83,7 +83,7 @@ Start from a reader request, the corpus checkout and access to each product's re
83
83
  - **Gaps:** a capability missing from one SDK goes in that SDK's reference ("Not supported in this SDK: X. Do Y instead."). A language with no reference gets one neutral `SKILL.md` sentence with the boundary and the alternative, for example "Python has no application SDK: call the owning service through its HTTP API"; add `references/python.md` only for a verified boundary. A C#-only capability gets one short neutral note.
84
84
  - **Host code:** never in `SKILL.md`; native code, imports and wiring live only in language references.
85
85
  - **Long files:** above about 100 lines, open with the title, a blank line and `## Contents` listing the H2 headings exactly, in order, as plain bullets.
86
- - **Timeless text:** no Cratis or dependency versions, package pins, "introduced in" or older behavior; no source paths, line numbers, commits or issue numbers; no paths that exist only in the corpus checkout.
86
+ - **Timeless text:** no Cratis or dependency versions, package pins, "introduced in" or older behavior, except in a `cratis-migrate-*` skill, which names the versions it moves between; no source paths, line numbers, commits or issue numbers; no paths that exist only in the corpus checkout.
87
87
  - **Defaults:** omit arguments whose value equals the default; show a non-default form only with the need that calls for it.
88
88
  - **Links between skills:** link another skill only when every selection that installs this one also installs it; otherwise name it in backticks with its installing profile. Name rules in backticks, never by link.
89
89
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  - [ ] One owner per task; the description selects it without promising siblings that may not be installed.
6
6
  - [ ] `SKILL.md` is language-neutral, has one default path and one catalog line (what and when) per operation, attribute and option of the latest release; SDK-specific skills carry the exact routing line, and gaps sit in the owning SDK reference.
7
- - [ ] Each supported SDK, checked separately against its latest release tag, has a reference covering its catalog lines, with no unsupported inference, source citations, release history, version numbers, pinned installs, "introduced in", old-release comparisons or explicit default arguments. Still-supported guidance is rewritten to current idioms, not deleted.
7
+ - [ ] Each supported SDK, checked separately against its latest release tag, has a reference covering its catalog lines, with no unsupported inference, source citations, release history, version numbers, pinned installs, "introduced in", old-release comparisons or explicit default arguments; a `cratis-migrate-*` skill may name the versions it moves between and still cites no source. Still-supported guidance is rewritten to current idioms, not deleted.
8
8
  - [ ] A reader can start, pick the native example, observe success and recover. Examples parse or run where practical, with limits recorded; fragments are labeled, and the pattern is taught rather than delegated to external docs.
9
9
  - [ ] Agents state inputs, permitted reads and writes, handoffs, stop conditions and a verifiable return; review-only roles are `readonly` without `Edit` or `Write`; frontmatter uses only `name`, `description`, `tools`, `readonly`, `modelTier` and, for a reviewer that must differ from the writer's provider, `reviewIndependence: different-provider`. Agents, hooks and prompts install for every profile, so each names a safe fallback or stop when a skill, rule or tool it names is absent.
10
10
  - [ ] Rules pay their loading cost: scoped globs are narrow, Copilot `applyTo` is a plain glob string, `general.md` stays within its byte ceiling, shared safety stays inline, and a destination exists before a recipe is removed.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: cratis-arc-localize-application
3
+ description: Use when an Arc application with a React frontend must show screens, refusals and widget text in more than one language, add a language, add a language switcher or hand translation files to a translation service. Not for the backend culture settings alone (use cratis-arc-host-application), a single-language literal-tree setup (use cratis-arc-react-bind-slice) or restyling Components (use cratis-components-theme-application).
4
+ compatibility: Needs an Arc backend and an Arc React frontend. The optional localization tooling needs a Node.js version its package supports.
5
+ ---
6
+
7
+ # Localize an Arc application
8
+
9
+ One shared policy, English beside each slice, one locale root. Three facts decide the rest:
10
+
11
+ - **English is the only built-in language.** Every other language is an opt-in catalog: files the application owns, or an optional pack such as `@cratis/arc.locale.nb` and `@cratis/components.locale.nb`. Packs are never downloaded; a missing one falls back to English.
12
+ - **The nearest Arc locale decides the language.** Read it from the `<Arc locale>` root (or the request on the server). Never pick it from the browser or a message's wording.
13
+ - **Language and regional format are independent.** The UI language never selects date, number, currency or time zone format; set the format locale separately.
14
+
15
+ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Node server `package.json` → typescript, `*.kt` → kotlin, `*.java` → java, `go.mod` → go, `mix.exs` → elixir). The React frontend is always in `typescript.md`, plus `typescript-switcher.md` and `typescript-tooling.md`. Kotlin, Java and Elixir backends have no released localization: do the frontend steps and expect English server text. Python has no Arc SDK: localize the service that owns the Arc routes.
16
+
17
+ ## Default path
18
+
19
+ 1. **Declare the languages once.** Put the supported languages and the default in a shared `localization.json` at the application root, and enable localization on the backend from the same list. Done when a supported `Accept-Language` returns a matching `Content-Language`.
20
+ 2. **Write English beside each slice** in `messages.en.json`: flat full message IDs mapped to ICU MessageFormat strings. Show text with the locale's `t(id, values)`, never with a literal. Map each refusal the application authors to an ID by its descriptor (`reason/reasonDetail`). Done when no component renders a literal sentence or server `message`.
21
+ 3. **Mount once.** Create one locale store with one catalog registry, pass it to `<Arc locale>` at the root and register every feature the root can show; loaders are lazy per language, not per route. Done when the network panel requests no language outside the selected one, its parents, the default and English.
22
+ 4. **Add a language.** Add one translated file per feature, sparse overrides for platform text, and an optional pack for platform text. Omit untranslated keys so they fall back to English. Done when `cratis-l10n check` (or your own check) passes and the screen shows the language.
23
+ 5. **Add the switcher and verify on an open route.** Never reload to switch. Done when the switch checks pass, including a late refusal and an unsaved draft.
24
+ 6. **Optional: generate loaders and types** with the `cratis-l10n` tool, hand translation files to a translation service and diagnose a missing pack. Hand-written wiring is equally valid.
25
+
26
+ ## Rules
27
+
28
+ - **Match descriptors, never prose.** Server text can be reworded or translated. Show framework and mapped refusals from the descriptor; show unmapped authored text as written.
29
+ - **Widget text and accessible names stay configurable.** Supply Components' labels and accessible names through the catalog or `value.messages`, and name custom controls from the catalog, so assistive technology matches the screen.
30
+ - **Tag foreign text.** Text in another language than the UI carries its own `lang`.
31
+ - **Never keep a user's language in process-wide server state**; requests would share it.
32
+ - **Never write `Accept-Language` yourself.** The root sends it; a hand-written header replaces it.
33
+
34
+ ## Catalog
35
+
36
+ | Piece | Use it when |
37
+ | --- | --- |
38
+ | Shared `localization.json` | Backend and frontend must agree on languages and default. |
39
+ | `messages.en.json` per slice | Texts belong to one feature; English is the source. |
40
+ | `locales/<tag>/<area>.json` | A language translates one feature's texts. |
41
+ | `locales/<tag>/overrides.json` | Reword a few platform (`arc.*`, `components.*`) texts. |
42
+ | Optional pack | A maintained translation of platform text exists for the language. |
43
+ | `value.catalog` on Components | Components-owned labels must follow the UI language. |
44
+ | Format locale | Dates and numbers follow a regional convention other than the UI language. |
45
+ | `LanguageSelector` | The user picks the language; use your own control only when it cannot fit. |
46
+ | `cratis-l10n build`, `add`, `export`, `check` | Generate loaders and types, add a language, write exchange files, validate. |
47
+
48
+ ## Related skills
49
+
50
+ Nearest skill: `cratis-arc-react-bind-slice` (single-language literal trees). Backend culture options: `cratis-arc-host-application`. Forms: `cratis-components-submit-form`. Provider and messages: `cratis-components-theme-application`. Accessibility: `cratis-components-accessibility`.
@@ -0,0 +1,52 @@
1
+ # Localize a C# Arc backend
2
+
3
+ ## Contents
4
+
5
+ - Enable localization
6
+ - What changes on the server
7
+ - Refusals
8
+ - Avoid
9
+
10
+ The frontend steps are in `typescript.md`. Language tags and the resource name below are illustrative.
11
+
12
+ ## Enable localization
13
+
14
+ Set `ArcOptions.Localization` (or `Cratis:Arc:Localization` in configuration) to the same languages as the frontend's `localization.json`. The host does not read that file, so keep the two lists equal by hand or in one build step you own.
15
+
16
+ ```csharp
17
+ builder.AddCratisArc(configureOptions: options =>
18
+ {
19
+ options.Localization = new()
20
+ {
21
+ SupportedUICultures = ["en", "nb"],
22
+ DefaultUICulture = "en"
23
+ };
24
+ });
25
+ ```
26
+
27
+ - Use distinct canonical .NET culture names and include the default. Invalid options stop startup.
28
+ - Without `Localization` Arc negotiates nothing and sends no `Content-Language`.
29
+ - Matching is exact, alias, supported parent, then a unique regional descendant: `nb-NO` selects a supported `nb` and `nb` selects a lone supported `nb-NO`, but `fr-CA` does not select `fr-FR`. Add an alias only when you want one; `Aliases` maps for example `no` to `nb`.
30
+ - Default source is `Accept-Language`. Add `Providers` (`QueryString`, `Cookie`, `AcceptLanguage`, in priority order) only when you need them; the cookie provider makes responses non-cacheable.
31
+ - The Arc client sends a `_cratisUiCulture` hint on stream URLs for you. If you use ASP.NET Core WebSockets, call `UseWebSockets()` before request localization.
32
+ - `UseCratisArc()` installs the middleware. Call `app.UseCratisRequestLocalization()` earlier only when earlier middleware needs the culture. Never run a second request-localization policy.
33
+ - The self-hosted `ArcApplication` listener applies the same policy.
34
+
35
+ Done when a request with `Accept-Language: nb` returns `Content-Language: nb` and an unsupported language returns the default.
36
+
37
+ ## What changes on the server
38
+
39
+ The selection sets `CultureInfo.CurrentUICulture` for the request only. Formatting stays on `CultureInfo.InvariantCulture` unless you set `FormattingCulture`, and then it is fixed for every request: a client's language never selects a format or a time zone. Do not copy `CurrentUICulture` into `CurrentCulture`.
40
+
41
+ ## Refusals
42
+
43
+ - The server keeps sending a stable `reason`, `reasonDetail` and English `message`. The client maps these to its catalog. There is no server catalog package; the client supplies the text.
44
+ - Server-side localized text only helps for rules that run on the server. Generated proxies run a copy of the rule in the browser by default, so see `cratis-arc-generate-proxies` for the client validation setting.
45
+ - For an application-specific message, resolve the resource inside a lambda so it is read at validation time, after the culture is known: `.WithMessage(_ => ValidationMessages.NameRequired)`. FluentValidation's built-in messages already follow the UI culture.
46
+ - Give each application-specific refusal a stable `reasonDetail` (see `cratis-arc-validate-command`) and a frontend catalog ID. Never make the client branch on message text.
47
+
48
+ ## Avoid
49
+
50
+ - Setting `DefaultThreadCurrentUICulture` for the process.
51
+ - A language list on the server that differs from the frontend list.
52
+ - Putting personal data or secrets in a refusal message or its arguments: refusals travel to the client and may be logged.
@@ -0,0 +1,44 @@
1
+ # Localize an Arc.Go backend
2
+
3
+ The frontend steps are in `typescript.md`. This reference applies to Arc.Go releases that include `arc.Options.Localization`. Tags and IDs below are illustrative.
4
+
5
+ ## Enable localization
6
+
7
+ ```go
8
+ b, err := arc.NewBuilder(arc.Options{
9
+ Localization: &arc.LocalizationOptions{
10
+ Languages: []string{"en", "nb"},
11
+ Default: "en",
12
+ Aliases: map[string]string{"no": "nb"},
13
+ },
14
+ })
15
+ ```
16
+
17
+ - Languages must be distinct BCP 47 base tags and the default must be one of them.
18
+ - Arc does not read `localization.json`. To share it with the frontend, decode its `languages` and `default` fields into `arc.LocalizationOptions` before building.
19
+ - `Accept-Language` is the default source. `Providers` can add `arc.QueryString` (`ui-culture`) and `arc.Cookie` (`.AspNetCore.Culture`, format `c=en|uic=fr`); the cookie provider makes every response non-cacheable.
20
+ - With localization on, every response sets `Content-Language`. The selection never changes number or date formats, time zones, JSON or stored data.
21
+ - With `Localization` nil, nothing is negotiated.
22
+
23
+ ## Messages the server renders
24
+
25
+ Read the tag with `arc.UILanguage(ctx)` (empty when none). Outside HTTP derive one context per recipient with `arc.WithUILanguage(ctx, recipientLanguage)`. Register catalogs before `Build` and look a message up after it:
26
+
27
+ ```go
28
+ err = b.AddCatalog(arc.MessageCatalog{
29
+ "en": {"app.notice.saved": "Saved"},
30
+ "nb": {"app.notice.saved": "Lagret"},
31
+ })
32
+ // after Build:
33
+ text, found := app.Message(ctx, "app.notice.saved")
34
+ ```
35
+
36
+ Use stable, namespaced IDs. `Message` falls back from the tag to its parent and then to the default, and returns `found == false` when no catalog has the ID. Duplicate IDs for one language are rejected. Arc ships no Go language packs and does not interpret template syntax, so you format any values yourself.
37
+
38
+ ## Refusals
39
+
40
+ On a localized host framework findings keep their English `message` and add `reason`, `reasonDetail` and named `messageArguments`; the client formats them from its catalog. Application validators may set `validation.Result.MessageArguments` with strings, booleans or finite numbers. Never put raw request values, secrets or diagnostics in them. Unlocalized hosts keep the previous findings.
41
+
42
+ ## Other stacks
43
+
44
+ Kotlin, Java and Elixir follow the same shared contract (the Arc localization specification: tag matching, `Accept-Language`, the `_cratisUiCulture` stream hint, cookie and response headers). Use their API only after the SDK documents it; until then rely on the frontend steps and English server text.
@@ -0,0 +1,59 @@
1
+ # Language switcher and switch verification
2
+
3
+ ## Contents
4
+
5
+ - Add the switcher
6
+ - Accessibility
7
+ - Verify a switch on an open route
8
+ - Avoid
9
+
10
+ Language tags and labels below are illustrative.
11
+
12
+ ## Add the switcher
13
+
14
+ Under `<Arc locale>`, `LanguageSelector` from `@cratis/components/Localization` needs no props. It lists Arc's supported languages by their own names (for example `English`, `norsk bokmål`), with no flags, and asks Arc to switch without a reload. It renders nothing when it has no options, for example when `<Arc>` has no locale and you pass no props.
15
+
16
+ ```tsx
17
+ <Arc locale={locale}>
18
+ <ArcComponentsProvider value={{ catalog }} toaster>
19
+ <LanguageSelector />
20
+ <App />
21
+ </ArcComponentsProvider>
22
+ </Arc>
23
+ ```
24
+
25
+ - `variant="segmented"` renders a native radio group instead of a native `select`.
26
+ - `labels={{ fr: 'Français' }}` replaces one language's displayed name.
27
+ - For application-owned state, pass `value`, `options` and `onChange` (the mounted `CratisComponentsProvider` then needs `value.locale` from the same state).
28
+ - For a custom control, read `useLanguage()` (`language`, `options`, `setLanguage`) and keep the accessibility rules below. Without Arc, `LanguageProvider` is the controlled source.
29
+ - Outside React call `await locale.setLanguage(tag)`. It returns `false` when the tag is unsupported, its catalog fails to load or a newer request supersedes it; `setLocale(tag)` is fire-and-forget.
30
+
31
+ ## Accessibility
32
+
33
+ - The control has an accessible name. The default comes from the Components `languageSelector.label` message, so it follows the UI language. Set `label`, `pt.root['aria-label']`, `pt.root['aria-labelledby']` or a visible `<label>` for `pt.root.id` when the product words it differently. Keep the name in the catalog, not a literal in code.
34
+ - Each option carries its own `lang` and `dir`, so a screen reader pronounces a language name correctly; keep that on a custom control.
35
+ - The native `select` announces its own change, so no live region is needed; do not add one.
36
+ - Keyboard: the `select` works with the platform keys. `segmented` moves between languages with the arrow keys and keeps focus on the control after a switch.
37
+ - A switch must not move focus away or reload. Do not announce it by stealing focus; the document `lang` updates with the root.
38
+ - Automated results are not certification: check keyboard-only use, a screen reader, zoom reflow and right-to-left layouts by hand. See `cratis-components-accessibility`.
39
+
40
+ ## Verify a switch on an open route
41
+
42
+ Switching rereads the open route in the new language: queries refresh, live subscriptions reconnect, and local React state and input values stay. Prove that on a route with a form:
43
+
44
+ 1. **Open route.** Open a route with visible texts, a Components control and a form. Switch. Done when every visible text, the paginator or other Components labels and the `<html lang>` value use the new language, and an untranslated key shows English instead of its ID.
45
+ 2. **Unsaved draft.** Type into fields without submitting, then switch. Done when the values, focus order and field errors remain, the form is not submitted again and its validation is not rerun.
46
+ 3. **Late refusal.** Submit a command that the server refuses, switch before or while the reply arrives, then let it arrive. Done when the refusal shows once in the new language (mapped by `reason/reasonDetail`, with foreign-language text carrying its own `lang`) and the form still holds the draft. Switch back and confirm it reformats again.
47
+ 4. **Streams.** With a live query open, confirm the connection re-established and data is shown in the new language where the server localizes it.
48
+ 5. **Reload.** Reload. Done when the stored choice (`storageKey`) or the initial language wins, and a refusal's language matches the screen.
49
+ 6. **Fallback.** Remove one translated key or the optional pack in a scratch build. Done when English appears for it without errors, then restore.
50
+
51
+ A custom `fieldContainerComponent` or `errorDisplayComponent` receives `errorLanguage`; apply it to the error text, not the surrounding controls.
52
+
53
+ ## Avoid
54
+
55
+ - Reloading the page to switch.
56
+ - Remounting the root on a switch: the draft is lost.
57
+ - Rendering `result.message` or branching on message text instead of descriptors.
58
+ - Showing the language name in the current UI language only; it must be readable by someone who cannot read the current one.
59
+ - Flags as language icons.
@@ -0,0 +1,82 @@
1
+ # The `cratis-l10n` tool, translation services and missing packs
2
+
3
+ ## Contents
4
+
5
+ - Prerequisites
6
+ - Layout the tool reads
7
+ - Commands
8
+ - Run it
9
+ - Translation service file masks
10
+ - Checks to run
11
+ - Diagnose a missing pack
12
+ - Upgrades
13
+
14
+ The tool is optional: the same wiring written by hand is valid (see Register by hand in `typescript.md`). Paths, tags and names are illustrative.
15
+
16
+ ## Prerequisites
17
+
18
+ `cratis-l10n` is an npm executable included in `@cratis/arc` (not a `cratis` subcommand). It and the Vite `localization()` plugin from `@cratis/arc.vite` need Node.js 22.15 or later on 22.x, 23.5 or later on 23.x, or 24 and later. The requirement applies to the tooling only, not the browser. Run `node --version` first.
19
+
20
+ ## Layout the tool reads
21
+
22
+ | File | Purpose |
23
+ | --- | --- |
24
+ | `localization.json` | `languages`, `default` and optionally `generatedDir`. |
25
+ | `Features/<Feature>/<Slice>/messages.en.json` | English beside the slice: flat full IDs to ICU strings. |
26
+ | `Shell/messages.en.json` | Shared `app.common.*` English. |
27
+ | `locales/<tag>/<feature>.json` | Translations of `app.<feature>.*`. |
28
+ | `locales/<tag>/overrides.json` | Sparse override of `arc.*` and `components.*` texts. |
29
+ | `locales/en/*.json`, `locales/en/.revision.json` | Exchange templates; only `export` writes them. The application always loads English from the slice files. |
30
+ | `generated/` | Generated TypeScript; keep out of version control. |
31
+
32
+ ## Commands
33
+
34
+ Run from the application root, or add `--root <dir>`.
35
+
36
+ | Command | Does |
37
+ | --- | --- |
38
+ | `cratis-l10n build` | Writes `localization-types.ts` (`MessageId`, `MessageParameters`) and `localization-loaders.ts` (`catalogLoaders`, `overrideLoaders`, `packLoaders`). |
39
+ | `cratis-l10n add <tag>` | Adds a language and seeds missing keys with English; existing translations stay. |
40
+ | `cratis-l10n export` | Writes the English templates and their revision. Rerun after changing English or IDs, before sending files out. |
41
+ | `cratis-l10n check` | Validates IDs, ICU syntax, placeholder names and types, and coverage. |
42
+
43
+ `check` exits `0` for success (warnings included), `1` for validation errors and `2` for usage or I/O errors. Missing entries in partial catalogs and stale template revisions are warnings.
44
+
45
+ ## Run it
46
+
47
+ With Vite, register `localization()` from `@cratis/arc.vite` in `vite.config.ts`: it generates before a build and regenerates as you edit catalogs, translations or the policy in dev. Without Vite, use `"prebuild": "cratis-l10n build"` and `"check:l10n": "cratis-l10n check"` in `package.json`, and run `check:l10n` in CI. Use a bundler that supports literal dynamic JSON imports and enable `resolveJsonModule`.
48
+
49
+ ## Translation service file masks
50
+
51
+ The service exchanges the files `export` writes. Use these masks in the service's own syntax (placeholder names differ per service, so take them from its documentation):
52
+
53
+ - Source: `locales/en/*.json`. Exclude `locales/en/.revision.json`.
54
+ - Translation: the same file name under `locales/<tag>/`, so `locales/en/hours.json` becomes `locales/nb/hours.json`.
55
+ - Use canonical tags for the directory (`pt-BR`, not `pt_br`), which may need the service's language-code mapping.
56
+ - Keep ICU placeholders and plural syntax untouched; `check` fails on a renamed placeholder.
57
+ - Do not send `overrides.json` unless you want translators to own platform wording.
58
+
59
+ After import: run `cratis-l10n check`, then `cratis-l10n build`. If English changed since the export, rerun `export` and resend; a stale revision is only a warning, so treat it as a blocker for release yourself.
60
+
61
+ ## Checks to run
62
+
63
+ 1. `cratis-l10n check` (exit code, warnings read).
64
+ 2. The project's type check and build, because `MessageId` and `MessageParameters` help only through your own typed wrapper around `t`; `t` itself accepts any string, so a typo is not a compile error.
65
+ 3. The switch checks in `typescript-switcher.md` for one language.
66
+ 4. On the backend, the culture-selection checks in `csharp.md` or `go.md`.
67
+
68
+ ## Diagnose a missing pack
69
+
70
+ A pack is optional and never downloaded, so a missing one is not an error: the language falls back to English.
71
+
72
+ 1. Check that the package is published and installed: `npm ls @cratis/arc.locale.nb`. `@cratis/arc.locale.nb` and `@cratis/components.locale.nb` may not be published yet; if `npm view` finds nothing, the pack does not exist for you yet.
73
+ 2. The generator adds a pack to `packLoaders` only when it is installed, listed in the application's `dependencies`, named `@cratis/arc.locale.<tag>` or `@cratis/components.locale.<tag>`, and the tag is a configured language or its parent. Check each.
74
+ 3. `build` reports a missing pack as an English fallback. Read its warnings.
75
+ 4. Use `packLoaders.arc` in the Arc registry and `packLoaders.components` in a separate Components registry, whose `registry.load(tag)` result is passed as `value.catalog` (see `typescript.md`). For a Components pack the generator compares the pack's same-minor `coreRange` with the installed `@cratis/components` at build time; it warns and omits the loader when the range excludes it or the version cannot be determined, so rerun `build` after updating either package. The generated Components loader needs an Arc release that includes the fix for Cratis/Arc#4079; on an older Arc, and in hosts that do not use the generated loaders, register the pack directly: `{ nb: () => import('@cratis/components.locale.nb') }`.
76
+ 5. A pack is refused, with an error reported, when it is malformed, when its manifest locale is invalid, or when its same-minor range excludes your installed core version. A different English template revision only warns and the pack still loads. Pass `onDiagnostic` to read the reports, and upgrade the pack and the library together.
77
+ 6. The tag must be in `localization.json`. A pack for an unlisted language is never loaded.
78
+ 7. If the pack cannot be installed, put the texts you need in `locales/<tag>/overrides.json`.
79
+
80
+ ## Upgrades
81
+
82
+ After upgrading `@cratis/arc` or `@cratis/components`, run `cratis-l10n build` and `check`: new platform texts are English until the pack or your overrides cover them. A changed English text or ID needs a new `export` before translators work again.
@@ -0,0 +1,151 @@
1
+ # Localize an Arc React frontend
2
+
3
+ ## Contents
4
+
5
+ - Prerequisites
6
+ - Step 1: declare the languages
7
+ - Step 2: write English and use it
8
+ - Step 3: mount once
9
+ - Step 4: add a language
10
+ - Components text
11
+ - Regional format
12
+ - Register by hand
13
+ - Related references
14
+
15
+ ## Prerequisites
16
+
17
+ `@cratis/arc` and `@cratis/arc.react` in the project, and `resolveJsonModule` enabled in `tsconfig.json` because the catalogs are imported as JSON. Language tags, IDs and names below are illustrative, and the same tags (`en`, `nb`) are used in `csharp.md` and `go.md`. The backend side is in `csharp.md` or `go.md`; the switcher and its checks are in `typescript-switcher.md`; the optional tool and translation-service handoff are in `typescript-tooling.md`.
18
+
19
+ ## Step 1: declare the languages
20
+
21
+ ```json
22
+ {
23
+ "languages": ["en", "nb"],
24
+ "default": "en"
25
+ }
26
+ ```
27
+
28
+ Save it as `localization.json` in the frontend root. Use canonical tags and include the default. The backend list must name the same languages, or the server will answer in a language the client cannot show. Done when the file parses and both sides list the same tags.
29
+
30
+ ## Step 2: write English and use it
31
+
32
+ Write each slice's texts next to it, as `messages.en.json` with flat, full IDs: `app.<feature>.<name>`. Values are ICU MessageFormat strings; placeholders are named.
33
+
34
+ ```json
35
+ {
36
+ "app.hours.title": "Hours",
37
+ "app.hours.saved": "Saved {count, plural, one {# entry} other {# entries}}."
38
+ }
39
+ ```
40
+
41
+ Read texts from the locale in a component, and from the injected `LocaleService` (from `@cratis/arc/localization`) in a view model:
42
+
43
+ ```tsx
44
+ import { useLocale } from '@cratis/arc.react';
45
+
46
+ export function Title() {
47
+ const t = useLocale()?.t;
48
+ return <h1>{t?.('app.hours.title')}</h1>;
49
+ }
50
+ ```
51
+
52
+ `t` is `undefined` when the root has no locale and returns `undefined` for an unknown ID, so keep the optional chaining. Done when the screen renders `Hours` and a typo in the ID renders nothing instead of the ID.
53
+
54
+ Map each refusal the application authors to an ID by its descriptor, `<reason>/<reasonDetail>`, exactly as it arrives on the result:
55
+
56
+ ```tsx
57
+ <CommandForm command={RegisterHours} validationDescriptors={{ 'constraintViolation/UniqueHours': 'app.hours.duplicate' }} />
58
+ ```
59
+
60
+ Set the same mapping on `CommandFormDefaults` to cover every form. For a dialog or toast, keep the command result in state and render `CommandFeedback` from `@cratis/arc.react/commands` with the same mapping; for custom rendering call `useCommandFeedbackFormatter(descriptors)`. Never render `result.message` directly: it is server text in the server's language. Known framework failures are translated without a mapping; an unmapped authored message shows as written.
61
+
62
+ ## Step 3: mount once
63
+
64
+ Create one locale store at module level and pass it to the single `<Arc>` root. Render after `ready` resolves, because `t` has no catalog until the first load finishes. The store's registry holds everything `useLocale().t` translates, and its loaders are lazy per language, not per route: register every feature map the root can show (here `catalogLoaders.hours` and the shared `catalogLoaders.common`). To keep a route's catalog out of the root, give it its own `createCatalogRegistry` and `await registry.load(tag)`; that translator is not bound to `useLocale().t` and you call it yourself.
65
+
66
+ ```tsx
67
+ import { createCatalogRegistry } from '@cratis/arc/localization/catalog';
68
+ import { createLocale } from '@cratis/arc/localization';
69
+ import { Arc } from '@cratis/arc.react';
70
+ import { createRoot } from 'react-dom/client';
71
+ import policy from './localization.json';
72
+ import { catalogLoaders, overrideLoaders, packLoaders } from './generated/localization-loaders';
73
+
74
+ const registry = createCatalogRegistry({
75
+ default: policy.default,
76
+ catalog: [packLoaders.arc, overrideLoaders, catalogLoaders.common, catalogLoaders.hours],
77
+ });
78
+ export const locale = createLocale({
79
+ supported: policy.languages,
80
+ defaultLocale: policy.default,
81
+ catalogRegistry: registry,
82
+ storageKey: 'ui-language',
83
+ });
84
+
85
+ const root = createRoot(document.getElementById('root')!);
86
+ void locale.ready.then(() => root.render(<Arc locale={locale}><App /></Arc>));
87
+ ```
88
+
89
+ The `generated/` files come from the tool (keep that directory out of version control); without it, see Register by hand. Each language loader runs only when that language is requested, so a French file is not fetched for an English user. `storageKey` remembers the user's choice. Add `detectBrowserLanguage: true` only to start from the browser's language, and `initialLocale` for a language stored in the user's profile. Done when `locale.getSnapshot().locale` is the expected tag and the network panel shows no request for a language outside the selected one, its parents, the default and English.
90
+
91
+ ## Step 4: add a language
92
+
93
+ 1. Add the tag to `localization.json` and to the backend list.
94
+ 2. Add `locales/<tag>/<feature>.json` per feature; the second segment of the ID names the file (`app.hours.*` → `hours.json`; use canonical tags for directories, such as `pt-BR`). `cratis-l10n add <tag>` creates them with English filled in; for a partial translation, delete the keys you have not translated so the runtime falls back (the tag, its parent `nb-NO` → `nb`, then English).
95
+ 3. Optionally reword platform text in `locales/<tag>/overrides.json` using `arc.*` and `components.*` IDs. An application file beats a pack for the same ID.
96
+ 4. Optionally install a maintained pack, for example `@cratis/arc.locale.nb` (and `@cratis/components.locale.nb` for Components). Packs are optional: without one that language shows English platform text. If a pack is not published yet, the install fails; leave it out and rely on `overrides.json`.
97
+
98
+ Done when `await locale.setLanguage('nb')` returns `true`, the screen shows the translated text and an untranslated key shows English. A `false` result means the tag is unsupported or its catalog failed to load.
99
+
100
+ ## Components text
101
+
102
+ Mount `ArcComponentsProvider` from `@cratis/components/Localization` inside `<Arc>` in place of `CratisComponentsProvider`; never mount both. It follows Arc's UI language and format locale. Give it a catalog for the current language and load a fresh one whenever the language changes:
103
+
104
+ ```tsx
105
+ const components = createCatalogRegistry({
106
+ default: 'en',
107
+ catalog: [packLoaders.components, overrideLoaders],
108
+ });
109
+
110
+ function Shell({ children }: { children: React.ReactNode }) {
111
+ const language = useLocale()?.locale ?? 'en';
112
+ const [catalog, setCatalog] = useState<ComponentsCatalog>();
113
+ useEffect(() => {
114
+ let current = true;
115
+ void components.load(language).then(loaded => { if (current) setCatalog(loaded); });
116
+ return () => { current = false; };
117
+ }, [language]);
118
+ const value = useMemo(() => ({ catalog }), [catalog]);
119
+ return <ArcComponentsProvider value={value} toaster>{children}</ArcComponentsProvider>;
120
+ }
121
+ ```
122
+
123
+ Prefer the generated `packLoaders.components`, as shown: its loader takes the pack's default export, and `cratis-l10n build` checks the pack's same-minor `coreRange` against the installed `@cratis/components` and omits an incompatible pack. The generated Components loader needs an Arc release that includes the fix for Cratis/Arc#4079. On an older Arc, or in a host that does not use the generated loaders, register the pack directly instead: `{ nb: () => import('@cratis/components.locale.nb') }`. If no Components pack exists for the language, keep only your overrides. `ComponentsCatalog` is exported from `@cratis/components/Localization`. Components' labels, including accessible names and overlay content, come from the catalog; English fills the gaps. Reword one label with `value.messages` (for example `messages: { paginator: { page: n => `Side ${n}` } }`); function-valued keys stay functions. Keep `value` stable. Without Arc's locale, put the language on `CratisComponentsProvider` (`value.locale`, `value.catalog`) and own the language state yourself. See `cratis-components-theme-application` for the label groups.
124
+
125
+ ## Regional format
126
+
127
+ `createLocale({ formatLocale: 'nb-NO' })` pins date and number formatting. Without it, formatting follows the UI language. On the provider, `value.formatLocale` overrides only the format. Use it when users expect a regional convention that differs from the UI language, for example English text with day-month dates. Never derive a format from the UI language yourself. Done when changing the UI language leaves a pinned date format unchanged.
128
+
129
+ ## Register by hand
130
+
131
+ Without the tool, write the generated shape yourself: dynamic imports of JSON, one loader per tag.
132
+
133
+ ```tsx
134
+ const registry = createCatalogRegistry({
135
+ default: 'en',
136
+ catalog: [
137
+ { 'app.hours.title': 'Hours' },
138
+ { nb: () => import('./locales/nb/hours.json') },
139
+ { nb: async () => {
140
+ const { default: messages, manifest } = await import('@cratis/arc.locale.nb');
141
+ return { messages, manifest };
142
+ } },
143
+ ],
144
+ });
145
+ ```
146
+
147
+ A bare dictionary is the application's English. A tag map holds loaders; a pack loader returns `{ messages, manifest }`, and Arc refuses a pack whose manifest range does not include its core version (it reports it and continues in English). Pass `onDiagnostic` to receive those reports instead of the console. Your bundler must support literal dynamic JSON imports.
148
+
149
+ ## Related references
150
+
151
+ Open `typescript-switcher.md` for the switcher and checks, and `typescript-tooling.md` for `cratis-l10n`, translation-service file masks and a missing pack.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cratis-arc-react-bind-slice
3
- description: Use when a developer mounts the Arc React host, binds a generated query or command proxy in a React component, sets the UI language (locale, translations) of a React application, coordinates several command editors with one Save/Discard (CommandScope), or reads identity, availability or slice context in React, including folder-derived slice locations from the Arc Vite SliceLocationPlugin. Not for a standard table (use cratis-components-display-list), a form that collects command input (use cratis-components-submit-form), view-model classes (use cratis-arc-react-separate-view-model) or producing the proxies (use cratis-arc-generate-proxies).
3
+ description: Use when a developer mounts the Arc React host, binds a generated query or command proxy in a React component, sets up a single-language literal-tree UI language of a React application (several languages, packs, a switcher or `cratis-l10n` belong to cratis-arc-localize-application), coordinates several command editors with one Save/Discard (CommandScope), or reads identity, availability or slice context in React, including folder-derived slice locations from the Arc Vite SliceLocationPlugin. Not for a standard table (use cratis-components-display-list), a form that collects command input (use cratis-components-submit-form), view-model classes (use cratis-arc-react-separate-view-model) or producing the proxies (use cratis-arc-generate-proxies).
4
4
  compatibility: Requires react, react-dom, reflect-metadata, @cratis/arc, @cratis/arc.react and @cratis/fundamentals, plus proxies generated for React.
5
5
  ---
6
6
 
@@ -8,6 +8,8 @@
8
8
  - Outside React
9
9
  - Avoid
10
10
 
11
+ For several languages, multi-file catalogs, optional packs, a language switcher or the `cratis-l10n` tool, use `cratis-arc-localize-application`; this page keeps the literal-tree path (`defineTranslations`).
12
+
11
13
  This is the home for the client side of the UI language: the texts of the application's own screens and the language Arc sends to the backend. Texts and formats of Cratis Components controls follow it through `ArcComponentsProvider`; see `cratis-components-theme-application` (`references/localization.md`). The backend decides which cultures it honours; see Request localization in `cratis-arc-host-application`. Language tags, text keys and the storage key below are illustrative.
12
14
 
13
15
  ## Default path
@@ -59,6 +59,7 @@ export const App = () => (
59
59
 
60
60
  ## Message packs
61
61
 
62
+ - This is the legacy built-in registration. It still works and is deprecated: Arc and Components are moving to English as the only built-in language, with other languages as opt-in catalogs or packs the application supplies through `value.catalog`. For a new language or a new application, follow `cratis-arc-localize-application`.
62
63
  - Components ships two packs: English and Norwegian Bokmål.
63
64
  - `nb-NO`, `nb` and `no` select Bokmål. Every other language gets English labels.
64
65
  - The English fallback affects Components labels only. `locale` and `formatLocale` keep the values you set, so React Aria texts and formats still follow them.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: cratis-migrate-arc-24-to-25
3
+ description: Use when upgrading a C# application from Cratis Arc 24 to Arc 25, including a build or restore that fails on Swashbuckle or Microsoft.OpenApi after raising `Cratis` or `Cratis.Arc.*`, and a controller query that MCP refuses or the query hub reports unauthorized after the raise. Not for other Arc majors, new applications (`cratis-platform-start-application`) or the general upgrade loop of versions, kernel order and deployment (`cratis-platform-upgrade-application`).
4
+ ---
5
+
6
+ # Move a C# application from Arc 24 to Arc 25
7
+
8
+ Temporary guidance for one upgrade. Reinstall the AI corpus without this profile once the upgrade is merged. Run it inside the loop of `cratis-platform-upgrade-application`, which owns version pairing, kernel order and deployment.
9
+
10
+ ## What changed
11
+
12
+ Moving to the latest Arc 25 release brings two changes that can break an application. The first applies to hosts that serve a Swagger document. The second applies to hosts that expose MVC controller queries beyond HTTP. Arc's generated command and query documents are unchanged.
13
+
14
+ | Symptom | Cause | Who is affected |
15
+ | --- | --- | --- |
16
+ | Restore reports a package downgrade for `Swashbuckle.AspNetCore` or `Microsoft.OpenApi` | A direct or central pin below the versions Arc now requires: Swashbuckle.AspNetCore 11.0.1 and the Microsoft.OpenApi version the selected Arc release depends on (3.11.1 for the latest Arc 25). A Microsoft.OpenApi 3.0.x pin is below that floor too | Hosts that reference `Cratis` or `Cratis.Arc.Swagger`; `Cratis` includes `Cratis.Arc.Swagger` |
17
+ | Restore warns that `Cratis.Arc.OpenApi` needs Microsoft.OpenApi below 3 | `Cratis.Arc.OpenApi` stays on Microsoft.OpenApi 2 and targets .NET 10 only, so it cannot share a host with `Cratis.Arc.Swagger` or `Cratis` | Hosts that combine them |
18
+ | A Swashbuckle filter, written by the application, no longer compiles | Media types are interfaces now | Applications with their own `IOperationFilter`, `ISchemaFilter`, `IDocumentFilter` or `IRequestBodyFilter` |
19
+ | MCP refuses to run a controller query, or a query-pipeline call such as a query-hub subscription to it returns unauthorized, although the same action works over its HTTP route | Authorization that only MVC can enforce is never run by the query pipeline: an MVC authorization filter, a filter factory Arc cannot classify, authorization added to the mapped route (such as `RequireAuthorization(...)`), or a fallback authorization policy covering a route with no authorization of its own (MCP does not apply the fallback policy, so it refuses such a query) | Applications with MVC controller queries that are exposed through MCP or the query hub |
20
+
21
+ A host that uses neither `Cratis` nor `Cratis.Arc.Swagger`, has no Swashbuckle filters of its own and exposes no MVC controller query through MCP or the query hub has nothing to change here beyond the version raise.
22
+
23
+ ## Inventory before the bump
24
+
25
+ 1. List the versions of `Cratis`, `Cratis.Arc.*`, `Swashbuckle.AspNetCore*` and `Microsoft.OpenApi` in every `.csproj` and `Directory.Packages.props`.
26
+ 2. List every class that implements one of the four filter interfaces above.
27
+ 3. List every controller query that is exposed through MCP or the query hub, with the authorization it has today.
28
+ 4. For a Swagger host, start the application and save `/swagger/v1/swagger.json`; for a `Cratis.Arc.OpenApi` host, save `/openapi/v1.json`. Done when the file is on disk and holds the command and query routes.
29
+
30
+ ## Order
31
+
32
+ 1. **Resolve the document generator.** Keep what the host uses. One host uses `Cratis.Arc.Swagger` (through `Cratis` or directly) or `Cratis.Arc.OpenApi`, never both. A host that keeps `Cratis.Arc.OpenApi` references the individual Arc packages instead of `Cratis` and stays on .NET 10, because the package supports no other runtime. Done when the project files name one generator.
33
+ 2. **Raise the packages.** Raise every Arc package, NuGet and npm, to the latest Arc 25 release in one change, as `cratis-platform-upgrade-application` describes. For a Swagger host, raise `Swashbuckle.AspNetCore` to 11.0.1 or later, and remove every `Microsoft.OpenApi` pin or raise it to at least the version the selected Arc release depends on (3.11.1 for the latest Arc 25), which includes a 3.0.x pin. Done when `dotnet restore` ends without a downgrade warning or error.
34
+ 3. **Rewrite the application's own filters.** Read `references/<language>.md` for the application's backend (`.csproj` → csharp); this profile installs only the C# reference. Done when the project builds.
35
+ 4. **Authorize controller queries in Arc.** For each query from the inventory that is exposed beyond plain HTTP, replace the MVC authorization filter, filter factory or `RequireAuthorization(...)` on the mapped route with an equivalent `[Authorize(Policy = "...")]` or `[Authorize(Roles = "...")]` declaration. Remove the MVC-only form: Arc refuses the query while it remains, even when the same rule is also declared. For MCP, also make any fallback policy that covers the route explicit on the query. A declaration on the action replaces the controller's declaration, so an action policy must include every restriction the controller declares. If an attribute cannot express the same access, keep the original HTTP protection and expose a separately protected operation for MCP or the query hub (for MCP, an `IMcpToolAuthorizer`). Done when no listed query depends on MVC-only authorization.
36
+ 5. **Rebuild and regenerate the proxies** as `cratis-platform-upgrade-application` describes.
37
+
38
+ ## Verify
39
+
40
+ 1. `dotnet restore`, then `dotnet build` with warnings as errors, which turns a leftover version-constraint warning into a failure.
41
+ 2. Run the specs.
42
+ 3. Start the application and diff the new document against the saved one. Arc's command and query operations are expected to match. A difference in the application's own operations or schemas comes from Swashbuckle or OpenAPI.NET; judge it against their guides, and stop and report a difference in Arc's operations.
43
+ 4. For each listed controller query, on every transport that exposes it (HTTP, the query hub and MCP), call it as a caller who holds every required permission, then as callers who each lack one of them. Done when the permitted caller is served and every other caller is refused on every transport.
44
+ 5. No event, projection or read-model behavior changes in this move, so no replay is needed. If the raised `Cratis` brings a newer Chronicle client, apply the kernel order from `cratis-platform-upgrade-application`.
45
+
46
+ ## Finish
47
+
48
+ Merge the upgrade, then reinstall the AI corpus with the previous profile list: `cratis ai install --profiles <previous> --harnesses <previous> --languages <previous>`. Done when `.cratis/ai.json` no longer lists `cratis/migrate/arc-24-to-25` and this skill is gone.
@@ -0,0 +1,30 @@
1
+ # Rewrite Swashbuckle filters for Swashbuckle 11
2
+
3
+ Prerequisite: the application has its own class implementing `IOperationFilter`, `ISchemaFilter`, `IDocumentFilter` or `IRequestBodyFilter`, and the packages are on Swashbuckle.AspNetCore 11 and Microsoft.OpenApi 3.
4
+
5
+ `Content` of `OpenApiRequestBody` and `OpenApiResponse` is nullable and is an `IDictionary<string, IOpenApiMediaType>`, and `IOpenApiMediaType.Schema` is read-only. Test for the content, then replace the entry with a new `OpenApiMediaType` that carries over the old metadata, instead of assigning the schema:
6
+
7
+ ```csharp
8
+ using System.Collections.Generic;
9
+ using Microsoft.OpenApi;
10
+
11
+ if (response.Content is not { } content || !content.TryGetValue("application/json", out var existing)) return;
12
+
13
+ content["application/json"] = new OpenApiMediaType
14
+ {
15
+ Schema = schema,
16
+ ItemSchema = existing.ItemSchema,
17
+ Example = existing.Example,
18
+ Examples = existing.Examples,
19
+ Encoding = existing.Encoding,
20
+ ItemEncoding = existing.ItemEncoding,
21
+ PrefixEncoding = existing.PrefixEncoding,
22
+ Extensions = existing.Extensions is null ? null : new Dictionary<string, IOpenApiExtension>(existing.Extensions)
23
+ };
24
+ ```
25
+
26
+ Observe: the filter compiles and the generated document shows the schema on that media type with its examples, encoding and extensions unchanged.
27
+
28
+ - To add JSON content that is missing, add `new OpenApiMediaType { Schema = schema }` when `Content` is not null.
29
+ - A compile error that is not about media types: follow the Swashbuckle.AspNetCore guide "Migrating to Swashbuckle.AspNetCore v11" and the OpenAPI.NET "Upgrade guide to OpenAPI.NET 3.0".
30
+ - A filter that compiles but changes the document unexpectedly: diff the document as the skill's verify step describes, then check the same guides for the property involved.
@@ -33,7 +33,7 @@ Read `references/<language>.md` for the application's backend (`.csproj` → csh
33
33
  Work on a branch. Names and paths are illustrative.
34
34
 
35
35
  1. **Baseline.** Make build, specs and the application's smoke check pass on the current versions, and record the versions in use: Cratis packages, kernel image, AuthProxy image, CLI.
36
- 2. **Plan every boundary.** For each product, list the majors between the current and the target version and read that product's upgrade notes for each one, in order. Read the release notes too when only a minor changes: a default can change inside a major. Classify each step with the table below before changing anything.
36
+ 2. **Plan every boundary.** For each product, list the majors between the current and the target version and read that product's upgrade notes for each one, in order. Read the release notes too when only a minor changes: a default can change inside a major. Classify each step with the table below before changing anything. When `cratis ai profiles list --all` offers a `cratis/migrate/<product>-<from>-to-<to>` profile for a boundary, install it next to the current profiles for the upgrade and remove it when the upgrade is merged.
37
37
  3. **Decide the kernel order.** If the change raises the .NET Chronicle client, no environment may run a kernel older than that client: within a major, upgrade the kernel first; across a major, move kernel and clients together unless the upgrade notes state that the boundary keeps the wire contract. For any other client, test the new client release against the kernel version each environment runs. The kernel upgrade itself is `cratis-chronicle-deploy-kernel`, `references/upgrade-and-recovery.md`.
38
38
  4. **Do the steps that come before the bump.** Some product-specific steps (next section) run on the current release. Entered from the major directly before it, a Components major starts with an import migration that is applied and verified while the old package is still installed. On a direct jump across more than one major the migrator does not run on the old package: make the preparatory import edits by hand, and run the migrator only after the target is installed. Do these, repeat the baseline checks and keep the result as a checkpoint: source, manifest and lockfile together.
39
39
  5. **Raise every Cratis package in one change.** Backend: all packages of each product to one release, with `Cratis` deciding the Arc and Chronicle pair on .NET. Frontend: every `@cratis/*` package, in releases whose declared peer ranges accept each other, then install and commit the lockfile. Details are in the language reference.
@@ -28,6 +28,7 @@
28
28
  "cratis-arc-host-application",
29
29
  "cratis-arc-invoke-command",
30
30
  "cratis-arc-isolate-tenant",
31
+ "cratis-arc-localize-application",
31
32
  "cratis-arc-page-query",
32
33
  "cratis-arc-select-backend-sdk",
33
34
  "cratis-arc-validate-command",
@@ -153,6 +154,7 @@
153
154
  "cratis-arc-host-application",
154
155
  "cratis-arc-invoke-command",
155
156
  "cratis-arc-isolate-tenant",
157
+ "cratis-arc-localize-application",
156
158
  "cratis-arc-page-query",
157
159
  "cratis-arc-select-backend-sdk",
158
160
  "cratis-arc-validate-command",
@@ -207,6 +209,7 @@
207
209
  "cratis-arc-host-application",
208
210
  "cratis-arc-invoke-command",
209
211
  "cratis-arc-isolate-tenant",
212
+ "cratis-arc-localize-application",
210
213
  "cratis-arc-page-query",
211
214
  "cratis-arc-validate-command",
212
215
  "cratis-authproxy-configure",
@@ -255,6 +258,7 @@
255
258
  "cratis-arc-host-application",
256
259
  "cratis-arc-invoke-command",
257
260
  "cratis-arc-isolate-tenant",
261
+ "cratis-arc-localize-application",
258
262
  "cratis-arc-page-query",
259
263
  "cratis-arc-validate-command",
260
264
  "cratis-authproxy-configure",
@@ -292,6 +296,7 @@
292
296
  "cratis-arc-generate-proxies",
293
297
  "cratis-arc-host-application",
294
298
  "cratis-arc-invoke-command",
299
+ "cratis-arc-localize-application",
295
300
  "cratis-arc-page-query",
296
301
  "cratis-arc-validate-command",
297
302
  "cratis-chronicle-connect-application",
@@ -337,6 +342,7 @@
337
342
  "cratis-arc-host-application",
338
343
  "cratis-arc-invoke-command",
339
344
  "cratis-arc-isolate-tenant",
345
+ "cratis-arc-localize-application",
340
346
  "cratis-arc-page-query",
341
347
  "cratis-arc-validate-command",
342
348
  "cratis-authproxy-configure",
@@ -382,6 +388,7 @@
382
388
  "cratis-arc-host-application",
383
389
  "cratis-arc-invoke-command",
384
390
  "cratis-arc-isolate-tenant",
391
+ "cratis-arc-localize-application",
385
392
  "cratis-arc-page-query",
386
393
  "cratis-arc-select-backend-sdk",
387
394
  "cratis-arc-validate-command",
@@ -424,6 +431,7 @@
424
431
  "cratis-arc-host-application",
425
432
  "cratis-arc-invoke-command",
426
433
  "cratis-arc-isolate-tenant",
434
+ "cratis-arc-localize-application",
427
435
  "cratis-arc-page-query",
428
436
  "cratis-arc-select-backend-sdk",
429
437
  "cratis-arc-validate-command",
@@ -468,6 +476,7 @@
468
476
  "cratis-arc-host-application",
469
477
  "cratis-arc-invoke-command",
470
478
  "cratis-arc-isolate-tenant",
479
+ "cratis-arc-localize-application",
471
480
  "cratis-arc-page-query",
472
481
  "cratis-arc-select-backend-sdk",
473
482
  "cratis-arc-validate-command",
@@ -513,6 +522,7 @@
513
522
  "cratis-arc-generate-proxies",
514
523
  "cratis-arc-host-application",
515
524
  "cratis-arc-invoke-command",
525
+ "cratis-arc-localize-application",
516
526
  "cratis-arc-page-query",
517
527
  "cratis-arc-validate-command",
518
528
  "cratis-chronicle-connect-application",
@@ -561,6 +571,7 @@
561
571
  "cratis-arc-host-application",
562
572
  "cratis-arc-invoke-command",
563
573
  "cratis-arc-isolate-tenant",
574
+ "cratis-arc-localize-application",
564
575
  "cratis-arc-page-query",
565
576
  "cratis-arc-select-backend-sdk",
566
577
  "cratis-arc-validate-command",
@@ -604,6 +615,7 @@
604
615
  "cratis-arc-host-application",
605
616
  "cratis-arc-invoke-command",
606
617
  "cratis-arc-isolate-tenant",
618
+ "cratis-arc-localize-application",
607
619
  "cratis-arc-page-query",
608
620
  "cratis-arc-select-backend-sdk",
609
621
  "cratis-arc-validate-command",
@@ -633,6 +645,7 @@
633
645
  "cratis-arc-identity-and-tenancy-kotlin",
634
646
  "cratis-arc-invoke-command",
635
647
  "cratis-arc-isolate-tenant",
648
+ "cratis-arc-localize-application",
636
649
  "cratis-arc-page-query",
637
650
  "cratis-arc-select-backend-sdk",
638
651
  "cratis-arc-spring-data-kotlin",
@@ -664,6 +677,7 @@
664
677
  "cratis-arc-generate-proxies",
665
678
  "cratis-arc-host-application",
666
679
  "cratis-arc-invoke-command",
680
+ "cratis-arc-localize-application",
667
681
  "cratis-arc-page-query",
668
682
  "cratis-arc-validate-command",
669
683
  "cratis-code-review",
@@ -696,6 +710,7 @@
696
710
  "cratis-arc-host-application",
697
711
  "cratis-arc-invoke-command",
698
712
  "cratis-arc-isolate-tenant",
713
+ "cratis-arc-localize-application",
699
714
  "cratis-arc-page-query",
700
715
  "cratis-arc-validate-command",
701
716
  "cratis-code-review",
@@ -740,6 +755,7 @@
740
755
  "cratis-arc-host-application",
741
756
  "cratis-arc-invoke-command",
742
757
  "cratis-arc-isolate-tenant",
758
+ "cratis-arc-localize-application",
743
759
  "cratis-arc-page-query",
744
760
  "cratis-arc-select-backend-sdk",
745
761
  "cratis-arc-validate-command",
@@ -768,6 +784,7 @@
768
784
  "cratis-arc-host-application",
769
785
  "cratis-arc-invoke-command",
770
786
  "cratis-arc-isolate-tenant",
787
+ "cratis-arc-localize-application",
771
788
  "cratis-arc-page-query",
772
789
  "cratis-arc-select-backend-sdk",
773
790
  "cratis-arc-validate-command",
@@ -835,6 +852,7 @@
835
852
  ],
836
853
  "availableTargets": [
837
854
  "cratis-arc-diagnose-live-query",
855
+ "cratis-arc-localize-application",
838
856
  "cratis-arc-react-bind-slice",
839
857
  "cratis-arc-react-separate-view-model",
840
858
  "cratis-code-review",
@@ -870,6 +888,7 @@
870
888
  "cratis-arc-host-application",
871
889
  "cratis-arc-invoke-command",
872
890
  "cratis-arc-isolate-tenant",
891
+ "cratis-arc-localize-application",
873
892
  "cratis-arc-page-query",
874
893
  "cratis-arc-select-backend-sdk",
875
894
  "cratis-arc-storage-typescript",
@@ -1417,6 +1436,7 @@
1417
1436
  "cratis-arc-host-application",
1418
1437
  "cratis-arc-invoke-command",
1419
1438
  "cratis-arc-isolate-tenant",
1439
+ "cratis-arc-localize-application",
1420
1440
  "cratis-arc-page-query",
1421
1441
  "cratis-arc-select-backend-sdk",
1422
1442
  "cratis-arc-validate-command",
@@ -1462,6 +1482,7 @@
1462
1482
  "cratis-arc-generate-proxies",
1463
1483
  "cratis-arc-host-application",
1464
1484
  "cratis-arc-invoke-command",
1485
+ "cratis-arc-localize-application",
1465
1486
  "cratis-arc-page-query",
1466
1487
  "cratis-arc-validate-command",
1467
1488
  "cratis-platform-deliver-slice",
@@ -1489,6 +1510,7 @@
1489
1510
  "cratis-arc-generate-proxies",
1490
1511
  "cratis-arc-host-application",
1491
1512
  "cratis-arc-invoke-command",
1513
+ "cratis-arc-localize-application",
1492
1514
  "cratis-arc-page-query",
1493
1515
  "cratis-arc-validate-command",
1494
1516
  "cratis-chronicle-connect-application",
@@ -1523,6 +1545,7 @@
1523
1545
  "cratis-arc-generate-proxies",
1524
1546
  "cratis-arc-host-application",
1525
1547
  "cratis-arc-invoke-command",
1548
+ "cratis-arc-localize-application",
1526
1549
  "cratis-arc-page-query",
1527
1550
  "cratis-arc-validate-command",
1528
1551
  "cratis-chronicle-connect-application",
@@ -1557,6 +1580,7 @@
1557
1580
  "cratis-arc-generate-proxies",
1558
1581
  "cratis-arc-host-application",
1559
1582
  "cratis-arc-invoke-command",
1583
+ "cratis-arc-localize-application",
1560
1584
  "cratis-arc-page-query",
1561
1585
  "cratis-arc-validate-command",
1562
1586
  "cratis-chronicle-connect-application",
@@ -1591,6 +1615,7 @@
1591
1615
  "cratis-arc-generate-proxies",
1592
1616
  "cratis-arc-host-application",
1593
1617
  "cratis-arc-invoke-command",
1618
+ "cratis-arc-localize-application",
1594
1619
  "cratis-arc-page-query",
1595
1620
  "cratis-arc-validate-command",
1596
1621
  "cratis-chronicle-connect-application",
@@ -1772,6 +1797,31 @@
1772
1797
  ],
1773
1798
  "languages": []
1774
1799
  },
1800
+ {
1801
+ "id": "cratis/migrate/arc-24-to-25",
1802
+ "description": "Temporary: move a C# application from Arc 24 to Arc 25; remove when the upgrade is merged.",
1803
+ "composes": [],
1804
+ "availableTargets": [
1805
+ "cratis-migrate-arc-24-to-25"
1806
+ ],
1807
+ "languages": [
1808
+ "csharp"
1809
+ ],
1810
+ "migration": {
1811
+ "product": "arc",
1812
+ "from": 24,
1813
+ "to": 25,
1814
+ "packages": {
1815
+ "nuget": [
1816
+ "Cratis.Arc",
1817
+ "Cratis"
1818
+ ],
1819
+ "npm": [
1820
+ "@cratis/arc"
1821
+ ]
1822
+ }
1823
+ }
1824
+ },
1775
1825
  {
1776
1826
  "id": "cratis/modeling/screenplay-stage",
1777
1827
  "composes": [
@@ -1931,6 +1981,7 @@
1931
1981
  "cratis-arc-host-application",
1932
1982
  "cratis-arc-invoke-command",
1933
1983
  "cratis-arc-isolate-tenant",
1984
+ "cratis-arc-localize-application",
1934
1985
  "cratis-arc-migrate-relational-schema",
1935
1986
  "cratis-arc-page-query",
1936
1987
  "cratis-arc-react-bind-slice",
@@ -2034,6 +2085,7 @@
2034
2085
  "cratis-arc-host-application",
2035
2086
  "cratis-arc-invoke-command",
2036
2087
  "cratis-arc-isolate-tenant",
2088
+ "cratis-arc-localize-application",
2037
2089
  "cratis-arc-page-query",
2038
2090
  "cratis-arc-validate-command",
2039
2091
  "cratis-chronicle-cli-operations",
@@ -2119,6 +2171,7 @@
2119
2171
  "cratis-arc-generate-proxies",
2120
2172
  "cratis-arc-host-application",
2121
2173
  "cratis-arc-invoke-command",
2174
+ "cratis-arc-localize-application",
2122
2175
  "cratis-arc-page-query",
2123
2176
  "cratis-arc-validate-command",
2124
2177
  "cratis-chronicle-connect-application",
@@ -2153,6 +2206,7 @@
2153
2206
  "cratis-arc-generate-proxies",
2154
2207
  "cratis-arc-host-application",
2155
2208
  "cratis-arc-invoke-command",
2209
+ "cratis-arc-localize-application",
2156
2210
  "cratis-arc-page-query",
2157
2211
  "cratis-arc-validate-command",
2158
2212
  "cratis-chronicle-connect-application",
@@ -2194,6 +2248,7 @@
2194
2248
  "cratis-arc-generate-proxies",
2195
2249
  "cratis-arc-host-application",
2196
2250
  "cratis-arc-invoke-command",
2251
+ "cratis-arc-localize-application",
2197
2252
  "cratis-arc-page-query",
2198
2253
  "cratis-arc-validate-command",
2199
2254
  "cratis-chronicle-connect-application",
@@ -2234,6 +2289,7 @@
2234
2289
  "cratis-arc-generate-proxies",
2235
2290
  "cratis-arc-host-application",
2236
2291
  "cratis-arc-invoke-command",
2292
+ "cratis-arc-localize-application",
2237
2293
  "cratis-arc-page-query",
2238
2294
  "cratis-arc-validate-command",
2239
2295
  "cratis-chronicle-connect-application",
@@ -2279,6 +2335,7 @@
2279
2335
  "cratis-arc-generate-proxies",
2280
2336
  "cratis-arc-host-application",
2281
2337
  "cratis-arc-invoke-command",
2338
+ "cratis-arc-localize-application",
2282
2339
  "cratis-arc-page-query",
2283
2340
  "cratis-arc-validate-command",
2284
2341
  "cratis-choreography-run-workflow",
@@ -2319,6 +2376,7 @@
2319
2376
  "cratis-arc-generate-proxies",
2320
2377
  "cratis-arc-host-application",
2321
2378
  "cratis-arc-invoke-command",
2379
+ "cratis-arc-localize-application",
2322
2380
  "cratis-arc-page-query",
2323
2381
  "cratis-arc-validate-command",
2324
2382
  "cratis-chronicle-connect-application",
@@ -2361,6 +2419,7 @@
2361
2419
  "cratis-arc-generate-proxies",
2362
2420
  "cratis-arc-host-application",
2363
2421
  "cratis-arc-invoke-command",
2422
+ "cratis-arc-localize-application",
2364
2423
  "cratis-arc-page-query",
2365
2424
  "cratis-arc-validate-command",
2366
2425
  "cratis-chronicle-connect-application",
@@ -2399,6 +2458,7 @@
2399
2458
  "cratis-arc-generate-proxies",
2400
2459
  "cratis-arc-host-application",
2401
2460
  "cratis-arc-invoke-command",
2461
+ "cratis-arc-localize-application",
2402
2462
  "cratis-arc-page-query",
2403
2463
  "cratis-arc-validate-command",
2404
2464
  "cratis-chronicle-connect-application",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "8.11.0",
3
+ "version": "8.13.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [
package/src/index.ts CHANGED
@@ -29,8 +29,13 @@ function skillPathsOf(selected: Profile[]): string[] {
29
29
  .map(skillPath);
30
30
  }
31
31
 
32
+ /** A migration profile is installed on demand for one upgrade, so a repository with no selection never loads it. */
33
+ function isMigrationProfile(profile: Profile): boolean {
34
+ return profile.id.startsWith('cratis/migrate/');
35
+ }
36
+
32
37
  function allSkillPaths(): string[] {
33
- return skillPathsOf(profiles);
38
+ return skillPathsOf(profiles.filter(profile => !isMigrationProfile(profile)));
34
39
  }
35
40
 
36
41
  function supportsLanguage(profile: Profile, languages: Set<string>): boolean {