@cratis/pi 8.10.3 → 8.12.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.
@@ -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,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.
@@ -1772,6 +1772,31 @@
1772
1772
  ],
1773
1773
  "languages": []
1774
1774
  },
1775
+ {
1776
+ "id": "cratis/migrate/arc-24-to-25",
1777
+ "description": "Temporary: move a C# application from Arc 24 to Arc 25; remove when the upgrade is merged.",
1778
+ "composes": [],
1779
+ "availableTargets": [
1780
+ "cratis-migrate-arc-24-to-25"
1781
+ ],
1782
+ "languages": [
1783
+ "csharp"
1784
+ ],
1785
+ "migration": {
1786
+ "product": "arc",
1787
+ "from": 24,
1788
+ "to": 25,
1789
+ "packages": {
1790
+ "nuget": [
1791
+ "Cratis.Arc",
1792
+ "Cratis"
1793
+ ],
1794
+ "npm": [
1795
+ "@cratis/arc"
1796
+ ]
1797
+ }
1798
+ }
1799
+ },
1775
1800
  {
1776
1801
  "id": "cratis/modeling/screenplay-stage",
1777
1802
  "composes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "8.10.3",
3
+ "version": "8.12.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 {