@akanjs/cli 3.0.0-alpha.10 → 3.0.0-alpha.101

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 (135) hide show
  1. package/.build-stamp +1 -1
  2. package/README.ko.md +1 -1
  3. package/README.md +1 -1
  4. package/{abstractCompactor-e5yq60qz.js → abstractCompactor-byytxs22.js} +3 -5
  5. package/{agent.command-f0gqkfgz.js → agent.command-v1a4746v.js} +11 -13
  6. package/{application.command-x903m2qq.js → application.command-fzdcnzhg.js} +65 -38
  7. package/{applicationBuildRunner-ha3y8ew8.js → applicationBuildRunner-s4gsk728.js} +27 -23
  8. package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-28v9vbzk.js} +8 -9
  9. package/buildBatch.proc.js +12 -14
  10. package/capacitorApp-8d6d4zkm.js +12 -0
  11. package/{cloud.command-zs6kyf83.js → cloud.command-wygy2z05.js} +15 -18
  12. package/commandManifest.json +1 -1
  13. package/{context.command-fmepgjzg.js → context.command-4vdt1aqq.js} +19 -23
  14. package/dependencyScanner-shs82ynp.js +8 -0
  15. package/devTui-qnf1txdz.js +553 -0
  16. package/devTuiView-yzct2cq6.js +9 -0
  17. package/getDirname-dr3jz1xg.js +7 -0
  18. package/{guideline.command-n6sw0a0c.js → guideline.command-p92dq6ts.js} +16 -18
  19. package/guidelines/agentRule/agentRule.generate.json +31 -0
  20. package/guidelines/agentRule/agentRule.instruction.md +533 -0
  21. package/guidelines/conventions/conventions.instruction.md +447 -197
  22. package/guidelines/cssRule/cssRule.instruction.md +7 -0
  23. package/guidelines/framework/framework.generate.json +3 -2
  24. package/guidelines/framework/framework.instruction.md +1 -9
  25. package/guidelines/mcpRule/mcpRule.generate.json +35 -0
  26. package/guidelines/mcpRule/mcpRule.instruction.md +366 -0
  27. package/guidelines/modelStore/modelStore.instruction.md +12 -0
  28. package/guidelines/modelTemplate/modelTemplate.instruction.md +5 -0
  29. package/guidelines/queryRule/queryRule.generate.json +31 -0
  30. package/guidelines/queryRule/queryRule.instruction.md +178 -0
  31. package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
  32. package/guidelines/runtimeRule/runtimeRule.instruction.md +220 -0
  33. package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
  34. package/guidelines/transportRule/transportRule.generate.json +31 -0
  35. package/guidelines/transportRule/transportRule.instruction.md +60 -0
  36. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +51 -760
  37. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
  38. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
  39. package/incrementalBuilder.proc.js +26 -25
  40. package/{index-jf2ya7r2.js → index-0amdxycf.js} +8 -8
  41. package/{index-779ske1y.js → index-1yxtbmbj.js} +27 -27
  42. package/{index-eyyf2149.js → index-29sxqfaw.js} +36 -37
  43. package/index-3d9y066c.js +76 -0
  44. package/{index-76rn3g2c.js → index-47pj3aee.js} +4 -4
  45. package/index-5svjba73.js +159 -0
  46. package/{index-1577bej2.js → index-6wwzs1bc.js} +2 -2
  47. package/{index-gcv8ncfh.js → index-7d6vny25.js} +16 -12
  48. package/{index-y4vkyhvv.js → index-8p8p0cf8.js} +14 -14
  49. package/{index-wnp7hwq7.js → index-92zztqy1.js} +7 -7
  50. package/{index-fgc8r6dj.js → index-a5vmm6x4.js} +3 -1
  51. package/{index-xys926f2.js → index-by5gpp8x.js} +4 -4
  52. package/{index-0cj2zxbm.js → index-c69j78kk.js} +12 -11
  53. package/{index-rxkpk7n4.js → index-fc1bh0a7.js} +4 -4
  54. package/{index-d43t8af2.js → index-gq44bqjt.js} +58 -25
  55. package/{index-774gcx29.js → index-gtmz74tj.js} +41 -34
  56. package/{index-j37qq1f2.js → index-h7yw2z9n.js} +7 -7
  57. package/{index-bjpxzr6s.js → index-hwkygn9s.js} +51 -3
  58. package/{index-xmmzf150.js → index-hyywke0f.js} +1 -1
  59. package/{index-46tjzh6s.js → index-kcxmv48c.js} +29 -29
  60. package/{index-xjd3rqzj.js → index-n68jx79w.js} +6 -15
  61. package/{index-qb61h0k7.js → index-p5neav9b.js} +1098 -1360
  62. package/{index-67546d0j.js → index-q0y2jq9j.js} +14 -2
  63. package/{index-3vta1tqa.js → index-qkk27bk6.js} +32 -32
  64. package/{index-z8ptfkzv.js → index-qsq3q8fy.js} +975 -242
  65. package/{index-qzdjd4ct.js → index-srdssqj7.js} +18 -18
  66. package/{index-j9cxndc0.js → index-w8kmx1b6.js} +20 -11
  67. package/{index-82jrh4hj.js → index-yks023mb.js} +13 -13
  68. package/{index-5sn5w2mt.js → index-yza7zkpt.js} +94 -61
  69. package/{index-jhpa13zj.js → index-zmjppp25.js} +57 -57
  70. package/{index-kdh76j26.js → index-znynzt5w.js} +100 -32
  71. package/{index-4m0bphac.js → index-zxgr3s8s.js} +31 -30
  72. package/{index-62955kn5.js → index-zz5jyd94.js} +1002 -128
  73. package/index.js +22 -25
  74. package/{library.command-cv9gdbmg.js → library.command-s4fszngs.js} +11 -10
  75. package/{localRegistry.command-d8fg36zc.js → localRegistry.command-gyw4da9z.js} +20 -23
  76. package/{module.command-qyr1s9cn.js → module.command-6n7dwvav.js} +13 -16
  77. package/{package.command-wsjx0k47.js → package.command-gr82ypnr.js} +8 -10
  78. package/package.json +5 -7
  79. package/{page.command-rdzg65rm.js → page.command-7gvgb3jb.js} +7 -9
  80. package/{primitive.command-89g38b53.js → primitive.command-tk5ckw38.js} +13 -16
  81. package/{quality.command-0cs2z92d.js → quality.command-38v81baf.js} +226 -105
  82. package/recipeScanner-fpagtgc1.js +11 -0
  83. package/{repair.command-6fphxfwj.js → repair.command-5xbwvsxp.js} +12 -14
  84. package/{routeSourceValidator-e4jmbfcx.js → routeSourceValidator-ze6x894c.js} +0 -2
  85. package/{scalar.command-xfer69s6.js → scalar.command-0epwcr5k.js} +11 -14
  86. package/subspace.command-e2t36xb2.js +755 -0
  87. package/templates/app/env/env.client.debug.ts.template +1 -5
  88. package/templates/app/env/env.client.develop.ts.template +1 -5
  89. package/templates/app/env/env.client.local.ts.template +1 -5
  90. package/templates/app/env/env.client.main.ts.template +1 -5
  91. package/templates/app/env/env.client.testing.ts.template +1 -5
  92. package/templates/app/env/env.client.type.ts +2 -6
  93. package/templates/app/env/env.server.debug.ts.template +1 -5
  94. package/templates/app/env/env.server.develop.ts.template +1 -5
  95. package/templates/app/env/env.server.local.ts.template +1 -5
  96. package/templates/app/env/env.server.main.ts.template +1 -5
  97. package/templates/app/main.ts +3 -1
  98. package/templates/appSample/lib/task/task.signal.ts +11 -6
  99. package/templates/appSample/srvkit/AuthGuard.ts +9 -5
  100. package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
  101. package/templates/crudPages/[__model__Id]/edit/page.tsx +5 -5
  102. package/templates/crudPages/[__model__Id]/page.tsx +10 -13
  103. package/templates/crudPages/new/page.tsx +5 -5
  104. package/templates/crudPages/page.tsx +9 -9
  105. package/templates/crudSinglePage/page.tsx +11 -7
  106. package/templates/env/_env.server.type.ts +7 -5
  107. package/templates/lib/db.ts +1 -1
  108. package/templates/lib/dict.ts +1 -1
  109. package/templates/lib/sig.ts +5 -1
  110. package/templates/lib/srv.ts +6 -2
  111. package/templates/module/__model__.dictionary.ts +4 -1
  112. package/templates/module/__model__.signal.ts +2 -3
  113. package/templates/module/__model__.store.ts +1 -2
  114. package/templates/workspaceRoot/.gitignore.template +0 -1
  115. package/templates/workspaceRoot/.husky/pre-commit.template +16 -0
  116. package/templates/workspaceRoot/.vscode/settings.json.template +1 -1
  117. package/templates/workspaceRoot/AGENTS.md.template +4 -0
  118. package/templates/workspaceRoot/CLAUDE.md.template +19 -0
  119. package/templates/workspaceRoot/biome.json.template +2 -1
  120. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +10 -14
  121. package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
  122. package/templates/workspaceRoot/package.json.template +2 -4
  123. package/typeChecker-3xgrzc2v.js +7 -0
  124. package/typecheck.proc.js +4 -5
  125. package/{workflow.command-2ygfqt4f.js → workflow.command-kphbr7eh.js} +22 -25
  126. package/{workspace.command-vbgpjkf9.js → workspace.command-j1gatz3d.js} +96 -81
  127. package/capacitorApp-9xswcgx7.js +0 -61
  128. package/dependencyScanner-f6grrep3.js +0 -9
  129. package/getDirname-m9s0cmhq.js +0 -8
  130. package/index-mxvakhsm.js +0 -66
  131. package/index-r24hmh0q.js +0 -4
  132. package/recipeScanner-tghkzrrt.js +0 -12
  133. package/typeChecker-kravn7ns.js +0 -8
  134. /package/{index-0wae5ebk.js → index-meh558jy.js} +0 -0
  135. /package/{index-ss469dec.js → index-nz8prx9g.js} +0 -0
@@ -55,6 +55,13 @@ Screen code is invariant — a plain `<Button variant="primary">` never changes.
55
55
  - Switching themes is toggling the `data-theme` attribute. Keep every token defined in both the dark and light blocks.
56
56
  - Radius uses `rounded-box` (cards/modals), `rounded-field` (buttons/inputs), `rounded-selector` (toggles/checkboxes).
57
57
 
58
+ ## Lib-Owned Tokens (`libs/<lib>/ui/tokens.css`)
59
+ - A lib that needs colors of its own — vendor brand colors pinned by someone else's guide (Kakao `#fee500`, Naver `#1ec800`), fixed in-game surfaces — declares them **once** in `libs/<lib>/ui/tokens.css`. Never copy the block into each app's stylesheet.
60
+ - The file is collected automatically: every app whose page graph reaches that lib compiles it, ordered **ahead of** the app's own stylesheets, so the app wins on any variable both declare. There is nothing to import and no sync step to remember; two libs both declaring one variable resolve in lib-name order, so do not rely on that.
61
+ - Declare plain custom properties under `:root`, not a Tailwind `@theme` extension: the color vocabulary is closed per stylesheet, so `bg-kakao` would generate no CSS. Reference them as `bg-[var(--kakao)]` / `text-[var(--kakao-foreground)]`, which `no-arbitrary-color` allows by design (a `var()` reference is not an arbitrary color literal).
62
+ - Theme-following colors still belong to the app: a lib token is for a color that must **not** change with `data-theme`.
63
+ - An `@import` the CSS pipeline cannot resolve fails the build; it is never dropped. A stylesheet under `page/` that no route imports is compiled by nothing and warns at build time.
64
+
58
65
  ## Codegen Rules
59
66
  - Do not hardcode hex or raw-palette colors (`bg-red-500`, `#ff0000`); use semantic tokens.
60
67
  - Do not put inline color literals in `style={{ }}`; use token classes.
@@ -20,11 +20,12 @@
20
20
  ],
21
21
  "update": {
22
22
  "filePath": "./framework.instruction.md",
23
- "contents": ["purpose", "file ownership", "current API patterns", "codegen rules", "validation checklist"],
23
+ "contents": ["file ownership", "current API patterns", "codegen rules", "theming and UI customization"],
24
24
  "rules": [
25
25
  "Use current Akan APIs only",
26
26
  "Keep output parseable for codegen",
27
- "Include ownership boundaries and review checklist"
27
+ "Include ownership boundaries",
28
+ "Carry no meta about this document itself — it renders into every workspace's always-loaded AGENTS.md"
28
29
  ]
29
30
  },
30
31
  "page": "apps/akan/page/(docs)/docs/intro/fundamentals.tsx"
@@ -1,8 +1,5 @@
1
1
  # Akan.js Framework Guide
2
2
 
3
- ## Purpose
4
- Use this as the compact framework context for AI codegen. It should explain how Akan turns convention-based files into a full-stack app without teaching every API in one place.
5
-
6
3
  ## Ownership
7
4
  - `apps/<app>` contains app code, pages, env files, module folders, UI, webkit, srvkit, and common utilities.
8
5
  - `libs/<lib>` contains reusable domain and utility libraries consumed by apps.
@@ -26,10 +23,5 @@ Use this as the compact framework context for AI codegen. It should explain how
26
23
  When a request implies a distinct look and feel, do not stop at colors — customize both the theme and, when needed, the components.
27
24
 
28
25
  - **Theme (`apps/<app>/page/styles.css`).** The app imports Tailwind and `akanjs/ui/styles.css`, then overrides semantic token *values* per theme under `:root, [data-theme="dark"]` and `[data-theme="light"]` (`--background`, `--foreground`, `--primary`, `--muted`, `--border`, … each with a `-foreground` pair for text). The framework maps them to Tailwind color names, so `bg-primary` / `text-foreground` follow the `data-theme` attribute; corner rounding uses `--radius-box` / `--radius-field`. Fetch `get_guideline` with `cssRule` for the full token set before a deep theme pass.
26
+ - **Lib tokens (`libs/<lib>/ui/tokens.css`).** Colors a lib's own components pin — a vendor brand color, a fixed surface — are declared once there as plain `:root` custom properties and compiled into every app that reaches the lib, ahead of the app's stylesheets. Reference them as `bg-[var(--kakao)]`; never copy the block into each app.
29
27
  - **Components (`page/**/_overrides.tsx`).** When a default `akanjs/ui` component (Button, Modal, Table, Input, Select, …) is too restrictive for the design, re-skin it per route instead of forking, wrapping, or fighting it with utility classes. Write a drop-in replacement in `apps/<app>/ui/` typed against the slot contract (`AkanModalComponent`, or `AkanUiOverrides["<Slot>"]`), composing the framework's headless parts, then bind it in a `page/**/_overrides.tsx` manifest with a single `export default override({ Slot: BrandComponent })`. Overrides cascade down the route tree like layouts (closest ancestor wins). Fetch `get_guideline` with `componentRule` and read the `references/ui/customize` docs page for the slot list and patterns.
30
-
31
- ## Review Checklist
32
- - The instruction points to current docs pages, not removed docs routes.
33
- - Generated examples use current Akan builder APIs and scanner-friendly filenames.
34
- - The output contract tells the model which file paths to return.
35
- - The guide avoids broad framework essays when a concrete file rule is better.
@@ -0,0 +1,35 @@
1
+ {
2
+ "title": "MCP Exposure Rule",
3
+ "description": "How Akan signals reach AI agents over MCP — guard-derived exposure, refusals, prompts, and resources",
4
+ "group": "core",
5
+ "codegenPriority": 4,
6
+ "deprecated": false,
7
+ "scans": [
8
+ {
9
+ "type": "example",
10
+ "description": "Signal files whose slices and endpoints declare the guards MCP exposure is derived from",
11
+ "path": "{apps,libs}/*/lib/*/*.signal.ts",
12
+ "sample": 4
13
+ }
14
+ ],
15
+ "update": {
16
+ "filePath": "./mcpRule.instruction.md",
17
+ "contents": [
18
+ "exposure rule",
19
+ "configuration",
20
+ "declaring endpoints",
21
+ "refusals and wire behaviour",
22
+ "prompts",
23
+ "rolling out to an app",
24
+ "choosing what to open",
25
+ "writing instructions",
26
+ "verifying an app"
27
+ ],
28
+ "rules": [
29
+ "Use current Akan APIs only",
30
+ "State the rule before the reason, and keep the reason to one clause",
31
+ "Name the env spelling beside every option field",
32
+ "Keep it workspace-neutral — no app or repo names"
33
+ ]
34
+ }
35
+ }
@@ -0,0 +1,366 @@
1
+ # Akan MCP Exposure Guideline
2
+
3
+ ## Purpose
4
+ Use this when writing a `*.signal.ts`, configuring `option.setMcp(...)`, debugging a tool an agent cannot see, or
5
+ opening an app's service to agents end to end — the rollout checklist and the exposure design rules are at the end.
6
+ The always-loaded convention set carries the short version; this is the full contract.
7
+
8
+ ## Exposure Rule
9
+
10
+ Every signal is served to AI agents as an MCP server on `POST /mcp`. **`/mcp` is mounted by default and exposure
11
+ follows an endpoint's guards — there is no per-endpoint opt-in, and nothing to write in a signal file.** An endpoint
12
+ that declares a real guard is published; one that declares none is refused, and so is a mutation whose only guard is
13
+ `Public`. `AKAN_MCP=false` takes the whole surface off. The reasoning is that the guards are already the
14
+ authorization decision and `filterForAccount` re-reads them per caller on every listing, so a second per-endpoint
15
+ switch says nothing the guards do not — while guaranteeing that every endpoint added later is invisible to agents
16
+ until somebody remembers it.
17
+
18
+ ## Keeping An Endpoint Off The Shelf — `mcp: false`
19
+
20
+ Guards answer "may an agent call this". They do not answer "does this belong on a shelf", and those are different
21
+ questions: a step of a UI-driven state machine (`requestPhoneCodeForSignin`, `setPasswordInPrepareUser`) is
22
+ perfectly guarded, perfectly callable, and a model would only ever call it by mistake. **`mcp: false` is that
23
+ second answer, and it is an opt-*out*: everything still publishes by default, so an endpoint added later is
24
+ visible without anyone remembering it.**
25
+
26
+ ```ts
27
+ requestPhoneCodeForSignin: mutation(Boolean, { guards: [Every], mcp: false }),
28
+ inTodo: init({ guards: [SignedIn], mcp: false }), // the slice's list and insight together
29
+ export class FileSlice extends slice(srv.file, {
30
+ guards: { root: Admin, get: SignedIn, cru: SignedIn },
31
+ mcp: { cru: false }, // reads yes, generated writes no
32
+ }) {}
33
+ ```
34
+
35
+ - **It is curation, not authorization.** HTTP serves the endpoint exactly as before and the guards are still the
36
+ only thing deciding who may call it. Never write `mcp: false` where you meant a guard.
37
+ - **The `mcp` map on `slice()` mirrors the `guards` map above it** — same keys (`root`, `get`, `cru`, `create`,
38
+ `update`, `remove`), same fallbacks (`create`/`update`/`remove` inherit `cru`), and the same scope: it narrows
39
+ the root slice and the generated CRUD, and never reaches a named slice or a custom endpoint. Those declare
40
+ their own `mcp` beside their own `guards`. The bare `mcp: false` is every key at once, still within that scope.
41
+ - **`mcp: true` is the default and is a no-op**; write it only to say out loud that an entry is deliberately on
42
+ the shelf. It does not override a shape refusal (an `Any` return stays refused) and it cannot publish something
43
+ the guard rules keep out.
44
+ - **Reach for it by cost, not by taste.** Every entry inlines the schema of every model it mentions, so a plain
45
+ 21-field model with one named slice costs 12.6KB across its eight entries. `mcp: { cru: false }` on that model
46
+ takes it to 4.7KB — the write entries carry both the input *and* the full model, and are 63% of it.
47
+
48
+ ## Configuration
49
+ Settings live in the app's `lib/option.ts` — `option.setMcp({ … })`, taking `enabled`, `readOnly`, `path`,
50
+ `version`, `instructions`, `allowedOrigins`, `pageSize`, `language`, `legacyTextBlock`, and `auth`. **Not `main.ts`**: the gateway
51
+ there only spawns children, and `option.ts` is the app-authored file `server.ts` already hands to the process that
52
+ mounts `/mcp`. Every lib's option is read in mount order with the app's last, so an app tightens what a library
53
+ declared without restating it. Each field also has an env spelling (`AKAN_MCP`, `AKAN_MCP_READONLY`,
54
+ `AKAN_MCP_PATH`, `AKAN_MCP_VERSION`, `AKAN_MCP_INSTRUCTIONS`, `AKAN_MCP_ALLOWED_ORIGINS`, `AKAN_MCP_PAGE_SIZE`,
55
+ `AKAN_MCP_LANGUAGE`, `AKAN_MCP_LEGACY_TEXT`, `AKAN_MCP_AUTH_SERVERS`, `AKAN_MCP_SCOPES`, `AKAN_MCP_RESOURCE`) for a
56
+ deployment that configures what the source does not, which the option overrides.
57
+ The two booleans answer to `AKAN_PUBLIC_MCP` / `AKAN_PUBLIC_MCP_READONLY` too, the same pairing `AKAN_OPENAPI`
58
+ has, and a value written in code wins over the env of the same name — an explicit `undefined` is not a value.
59
+ `AKAN_MCP_PATH` is normalized to a leading `/`, because the route key and the OAuth metadata path are both built by
60
+ concatenation.
61
+
62
+ ## Declaring Endpoints
63
+ ```typescript
64
+ // apps/<app>/lib/option.ts
65
+ export const option = new AkanOption<ModulesOptions>().setMcp({
66
+ instructions: "Domain tools for this app. Start from taskInTodo.",
67
+ language: "en",
68
+ });
69
+ ```
70
+
71
+ ```typescript
72
+ // <model>.signal.ts — every one of these is an MCP tool or prompt, with no `mcp:` option anywhere
73
+ export class TaskSlice extends slice(
74
+ srv.task,
75
+ { guards: { root: Admin, get: SignedIn, cru: SignedIn } },
76
+ (init) => ({
77
+ // its own guards: the map above reaches base CRUD and the root slice, never a named slice — so a named slice
78
+ // that names none is refused rather than published, which is the one shape to watch for.
79
+ inTodo: init({ guards: [SignedIn] }).exec(function () {
80
+ return this.taskService.queryByStatuses(["todo"]);
81
+ }),
82
+ }),
83
+ ) {}
84
+
85
+ export class TaskEndpoint extends endpoint(srv.task, ({ mutation, prompt }) => ({
86
+ startTask: mutation(cnst.Task, { guards: [SignedIn] })
87
+ .param("taskId", ID)
88
+ .exec(async function (taskId) {
89
+ return await this.taskService.startTask(taskId);
90
+ }),
91
+ reviewTask: prompt({ guards: [SignedIn] })
92
+ .param("taskId", ID)
93
+ .exec(async function (taskId) {
94
+ const task = await this.taskService.getTask(taskId);
95
+ return [Msg.user(`Review this task and suggest next steps.`), Msg.resource(`akan://task/${taskId}`, task)];
96
+ }),
97
+ })) {}
98
+ ```
99
+
100
+ ## Refusals And Wire Behaviour
101
+ - **`mcp: false` is read first**, because it is the one answer nobody had to derive — somebody stated it. Its
102
+ reason says "HTTP still serves it", because that is the sentence that stops the next reader treating it as a lock.
103
+ - **The refusals are fail-closed**: **an endpoint that declares no `guards` at all** (nobody decided who may reach
104
+ it), **a mutation with no real `guards`** (`[Public]` is having none, spelled out — it answers true
105
+ unconditionally), `pubsub` and `message` (their internal args read a socket an MCP request does not have), an
106
+ `Any` or `Upload` return, a file upload, **an argument typed `Any` that must be filled**, and the generated
107
+ **`light<Model>` read** — it returns the same document as `<Model>` under the same guards, in a shape trimmed
108
+ for a page's payload, so publishing both put two entries per model in a listing an agent pays for every turn
109
+ and gave it nothing but the word "light" to choose between them.
110
+ A `prompt` refuses two more, because its `arguments` is one string per name with no schema beside it: a **list
111
+ argument**, which could never carry a second value, and **any `Any` argument** — a tool leaves that out of its
112
+ schema, and a prompt has no schema to leave it out of.
113
+ - **The boot log sizes the catalogue and says which signals it went to** — `MCP catalogue: tools=48 … · listing
114
+ 214KB` and `MCP catalogue cost: user 27/71KB · file 6/22KB · …`, heaviest first. Read it before narrowing
115
+ anything: the number is nobody's intuition, because MCP has no shared component section and forbids a `$ref`
116
+ across entries, so **every entry inlines the full schema of every model it mentions** and a listing is re-sent
117
+ whole to every agent that connects, before its first turn. Past 100KB it says so as a `warn`.
118
+ - **Every refusal is named in the boot log**: one `warn` per endpoint plus a `MCP catalogue: tools=… prompts=…`
119
+ count. Read that line first when a tool you expected is missing — and it is the *only* place the answer exists,
120
+ because there is no absent opt-in to notice. The API explorer badges the same rule per endpoint (`MCP` /
121
+ `MCP refused`), from the same shared implementation the catalogue runs.
122
+ - **An `Any` argument is left out of the published schema** rather than described as `{}` — it tells a model
123
+ nothing — and a value sent for one is refused by name, so the endpoint reads it as omitted. That is what happens
124
+ to the root list's raw `query` descriptor: read as sent, it would be an arbitrary filter over every model you
125
+ publish. Declare a named filter slice when an agent should narrow a list.
126
+ - **A nullable model return publishes no `outputSchema`**, and its empty answer ships as the text `null` with no
127
+ `structuredContent`. That field is an object by definition, so `null` cannot ride in it any more than an array
128
+ can — a list is wrapped as `{ items: … }` for the same reason — and a declared schema obliges every result to
129
+ match it, so a client SDK throws on the first call that finds nothing. A nullable *list* keeps its schema, and a
130
+ scalar return has no structured half at all: it ships as the value itself, not as JSON.
131
+ - **An `outputSchema` names no `hidden`, `secret`, or `visual` field.** Every response has the first two stripped,
132
+ so publishing them promises a property no answer can carry — and on a model like `user` the names are the leak.
133
+ Your *input* schema keeps all three: they are legal to send, and the same model describes a request body.
134
+ - **A `field.visual` is stripped from every MCP result.** It is the marker for a field the page renders and no
135
+ question is answered from — a blur placeholder, a rendered HTML body — and it is cost rather than secrecy, so
136
+ nothing is refused over one. The strip happens in the MCP dispatcher rather than in `resolveReturn`, which every
137
+ ordinary HTTP response also passes through: the whole point is that a browser still receives it. That is also why
138
+ the readable schema drops it — a non-optional visual field would otherwise be listed `required` and a validating
139
+ client would refuse a result that correctly omits it.
140
+ - **A structured result ships twice by default**, once as `structuredContent` and once as the same JSON in the text
141
+ block, which is what the spec asks of a server for clients predating the structured field. It is also a flat
142
+ doubling of what every model-returning tool costs a model. `option.setMcp({ legacyTextBlock: false })` — or
143
+ `AKAN_MCP_LEGACY_TEXT=false` — leaves a one-line pointer in the text block instead, for a deployment whose
144
+ clients read the structured half. A scalar return is unaffected: it has no structured half to point at, so it
145
+ ships as the value itself either way.
146
+ - A refused endpoint answers the *same* "unknown tool" as one that does not exist. Never make that
147
+ message more helpful — the difference is what enumerates your private surface. Every 401 and 403 is generalized
148
+ the same way, the framework's `Access denied by guard: Admin` and an app's `No authentication with roles: admin`
149
+ alike: the caller reads `You are not permitted to perform this action.`, because either sentence names your
150
+ authorization structure to the one caller barred from it. A domain `Err` at any other status resolves through
151
+ the dictionary and keeps its own words, placeholders filled.
152
+ - The `readOnly` / `destructive` / `idempotent` hints a client renders are derived from the endpoint type and key
153
+ and are not configurable. Clients are told to distrust hints; they are never a gate.
154
+ - **`AKAN_MCP_READONLY=true` is the read-only-deployment valve, not the exposure switch.** It drops every mutation
155
+ whatever it declared, and reports each one in the boot log like any other refusal.
156
+ - OAuth resource metadata is published at `/.well-known/oauth-protected-resource` (and at that path plus the mount
157
+ path, the spelling most clients try first). `auth.authorizationServers` / `AKAN_MCP_AUTH_SERVERS`,
158
+ `auth.scopes` / `AKAN_MCP_SCOPES`, `auth.resource` / `AKAN_MCP_RESOURCE` and `auth.verify` configure it;
159
+ `insufficient_scope` is enforced only once scopes are declared. Naming an issuer changes three things at once: a
160
+ request with no credential is answered 401 from `initialize` on (an MCP client starts its OAuth flow on nothing
161
+ else), a token carrying no `aud` is refused (that issuer mints for its other resources too), and the challenge
162
+ carries no `error` code (RFC 6750 §3.1 reserves it for a credential that was presented). A server naming no
163
+ issuer keeps anonymous access and accepts a first-party token, which is bound by app and environment instead.
164
+ - **The boot log names every published entry with no dictionary `.desc()`.** An agent picks a tool by its
165
+ description, so a missing one is a broken tool. What the framework generates has no text of its own and borrows
166
+ the model's: the generated list reads the `.of()` label, and the base CRUD tools append the model's `.desc()` to
167
+ their generated `Get X`. Write that model `.desc()` — it is the only text those entries can carry. There is no
168
+ `akan quality scan` rule for this any more: a source scanner found the exposure only as an `mcp:` literal, and
169
+ with exposure derived from the guards the resolved catalogue is the only place that can answer.
170
+ - A browser-hosted client needs `allowedOrigins` **and** the CORS answer the server sends back for those origins.
171
+ Every other MCP client sends no `Origin` at all, and the one that does is matched against the forwarded host so
172
+ a proxy does not turn each call into a 403 — which is only as trustworthy as an edge that *overwrites* that
173
+ header. `AKAN_MCP_RESOURCE` pins the resource identifier where you cannot guarantee it.
174
+ - **A `resources/read` uri that does not decode** — a stray `%` — is `Unknown resource`, not a server failure.
175
+ - **A caller's own mistake is reported as one** and never as a server failure: an argument that is missing,
176
+ unparseable or **undeclared** comes back as `isError` naming it — `additionalProperties: false` travels in the
177
+ published schema and nothing on the wire enforces it — and so does a document that is not there, as
178
+ `No <model> found for the arguments given.` A `prompt`, having no `isError` to carry a refusal, answers `-32602`.
179
+ Only a real failure logs a stack; an agent can drive the rest at will.
180
+ - **Three revisions are spoken**: the modern `2026-07-28` and the legacy `2025-11-25` / `2025-06-18`, which are
181
+ wire-identical over the POST-only surface this implements — a client whose proposal is not listed is told to
182
+ disconnect. An unknown proposal is answered at whichever end of that list it is closer to, and an unimplemented
183
+ method answers `404` to a modern client but `200` to a legacy one, whose era spends `404` on "your session is
184
+ gone".
185
+ - **A modern-era request mirrors `MCP-Protocol-Version` and `Mcp-Method` into headers** (plus `Mcp-Name` when the
186
+ body names one), and one that leaves a mirror out is refused just like one that contradicts the body: a gateway
187
+ rule keyed on a header never fires for the request that omitted it. Legacy requests are not checked. Capabilities
188
+ are derived from the catalogue, so a server with no prompts does not advertise `prompts`.
189
+ - **An expired, wrongly-audienced or unverifiable bearer token is refused up front**, so an agent is told to
190
+ authenticate rather than that the tool does not exist. The signature is checked through `auth.verify`, which the
191
+ module that mints the tokens supplies (`libs/shared` does, from the app's signing secret); without a verifier the
192
+ claims are read unverified and a token signed wrong, like an opaque one, degrades to an anonymous caller.
193
+ - **`/mcp` reads the `Authorization` header and nothing else.** The `cookie` header is deleted from the request
194
+ before the account middleware runs, so a same-site page cannot drive `tools/call` on the visitor's ambient session
195
+ — the request class `CrossSiteGuard` shields every mutation from, which this route never passes through.
196
+ - **Resource URIs**: `akan://<model>/{id}`, `akan://<model>/list` for the model's own list, and
197
+ `akan://<model>/list/<sliceKey>` for a slice's. The root list takes no third segment on purpose — any token
198
+ there is one a slice could also be named. **Those three are the whole set**, so only the generated reads that
199
+ publish are addressable: a custom endpoint keeps its tool and gets no resource template, and the refused
200
+ `light<Model>` read has no address either.
201
+ - **The catalogue is one language**, `en` unless `language` says otherwise: it is built once at boot and cached by
202
+ clients, so there is no `Accept-Language` negotiation.
203
+
204
+ ## Authentication — The Authorization Server Is The Same Process
205
+
206
+ `libs/shared/lib/_oauth` is an OAuth 2.1 authorization server (RFC 8414 metadata, PKCE `S256` only, RFC 7591
207
+ registration, Client ID Metadata Documents, RFC 9207 `iss`) served by the app that serves `/mcp`. Its `option.ts`
208
+ names the issuer and hands `McpAuth` a verifier, so mounting the lib is all an app does; the protocol engine it
209
+ delegates to lives in `akanjs/server` (`OAuthAuthorize`, `OAuthToken`, `OAuthRegistration`, `OAuthClientIdMetadata`,
210
+ `OAuthPkce`, `OAuthRedirect`, `OAuthMetadata`, `OAuthErrors`) and is unit-tested without a container.
211
+
212
+ - **Endpoints, at the origin's root:** `GET /.well-known/oauth-authorization-server`, `GET /oauth/authorize`,
213
+ `POST /oauth/token` (form-encoded), `POST /oauth/register`. The consent step is `libs/shared/page/oauth/consent`
214
+ — a server-rendered page whose two forms post to `/api/approveOAuthConsent/<requestId>` and
215
+ `/api/denyOAuthConsent/<requestId>` and follow the 302 back to the client. All of it is `mcp: false`.
216
+ - **The flow:** `POST /mcp` with no token → 401 with `resource_metadata` → the client reads the PRM, then the AS
217
+ metadata, registers (or uses a pre-registered / URL `client_id`), opens `/oauth/authorize` in a browser → the
218
+ server parks the request and redirects to the consent page (via `signinPath?redirect=` when anonymous) → the user
219
+ allows → `redirect_uri?code&state&iss` → the client posts the code and its PKCE verifier to `/oauth/token` → an
220
+ access token (1h, `aud` = the MCP resource, `iss`, `client_id`, `sub`, and the account's `self`/`me`) plus a
221
+ rotating refresh token (30d; reuse revokes the family). The token is the app's own access JWT, so
222
+ `AccountMiddleware` and every guard read it exactly as a browser session; nothing is scoped.
223
+ - **Invariants:** an authorization request lives ten minutes, binds to the first signed-in account that opens it,
224
+ and is decided once; a code lives sixty seconds and is consumed on first exchange even if that exchange fails; a
225
+ redirect URI must be registered and match exactly, loopback ports excepted (RFC 8252 §7.3); a refresh token is
226
+ bound to the client it was issued to. A `client_id` that is an HTTPS URL with a path is fetched as a metadata
227
+ document, never from the server's own network.
228
+ - **Per-app configuration** goes in `env.server.*` under `oauth`: `consentPath` and `signinPath` (with the basePath
229
+ when the app has one — `/office/oauth/consent`), `clients` (pre-registered, with an optional `clientSecret`),
230
+ `dynamicRegistration` (on by default: Claude Code and claude.ai register themselves), `allowedRedirectSchemes`
231
+ (`["cursor"]` by default, for Cursor's desktop callback), `accessTokenSeconds` (3600), `issuer` and `resource` (only when a tunnel or an edge
232
+ makes the derived origin wrong), `enabled: false` to take the server and the `/mcp` credential requirement away
233
+ together. The signin page must honour `?redirect=` to return the user to the consent page.
234
+ - **Clients:** Claude Code — `claude mcp add --transport http <name> <origin>/mcp` and nothing else; it registers,
235
+ opens the browser to `http://localhost:<port>/callback`, refreshes on 401. claude.ai — a custom connector by URL
236
+ (needs public HTTPS; DCR or the Advanced-settings client id/secret; callback
237
+ `https://claude.ai/api/mcp/auth_callback`). Cursor — the URL alone (DCR with a `cursor://` redirect), or a
238
+ pre-registered client in `mcp.json` `auth` with `http://localhost:8787/callback` /
239
+ `https://www.cursor.com/agents/mcp/oauth/callback` registered. A first-party browser token no longer opens `/mcp`
240
+ once the issuer is named; `--header "Authorization: Bearer …"` needs a token minted with `aud`.
241
+ - **`JWT_SECRET`** (or `security.jwtSecret`) is required outside `local`; the boot refuses without it, because the
242
+ derived fallback is seeded from the app, environment and repo names and forges an admin token for anyone who
243
+ knows them. `AKAN_ALLOW_DERIVED_JWT_SECRET=1` accepts that risk explicitly.
244
+
245
+ ## `prompt()`
246
+ **`prompt()`** is invoked by the *user* — a client renders it as a slash command — not chosen by the model. `exec`
247
+ returns `PromptMessage[]`, or a bare string that is wrapped into one user message; build them with `Msg.user` /
248
+ `Msg.assistant` / `Msg.link` / `Msg.resource` / `Msg.image` / `Msg.imageOf`. It takes `.param()` and `.search()`
249
+ only, because `prompts/get` sends a flat string map. **An embedded payload is masked by the model you name** —
250
+ `Msg.resource(uri, task, { model: cnst.LightTask })`, or `Msg.mask(cnst.LightTask, task)` for one piece of an
251
+ assembly. Taking the model as an argument is what makes a `{ ...doc }` spread maskable, since that and `toJSON()`
252
+ arrive with the class already gone; a value with no model named whose `hidden`/`secret` fields are populated is
253
+ **refused**, one level into a plain object too. **A `prompt` is also mounted as a
254
+ plain HTTP `GET` whether or not you enabled MCP**, because that route is what lets a web UI preview one — and it
255
+ is in your OpenAPI document like any other `GET`, answering the one fixed `PromptMessage[]` shape. MCP exposure
256
+ gates the catalogue, not the surface, so guard it
257
+ like any other read — and a prompt declaring no
258
+ `guards` at all is named in the boot log, while an explicit `[Public]` is a decision and stays quiet. Every `Msg` builder takes
259
+ optional `annotations` last (`audience`, `priority` 0..1, `lastModified`) — give the instruction a high `priority`
260
+ and its attachments a low one, or a client with a full window drops blocks by position and keeps the attachment
261
+ over the ask.
262
+
263
+ ## Progress Reporting
264
+ **`McpProgress.report(n, { total, message })`** reports progress from anywhere inside a call, a service or adapter
265
+ frames down included, and is a no-op when nobody is streaming — so the same code runs unchanged over HTTP, a
266
+ websocket, and in tests. `McpProgress.streaming` says whether anyone is reading, for a report whose message
267
+ costs something to assemble.
268
+
269
+ ## Rolling MCP Out To An App
270
+
271
+ The goal of exposing a service over MCP is that a person uses it through an agent instead of through the page:
272
+ one browser consent (the app's own sign-in included), then an hour-long access token and a thirty-day rotating
273
+ refresh token stand in for every later sign-in. The token is the app's own access JWT, so what an agent may do is
274
+ exactly what that person may do over HTTP — nothing is widened and nothing is scoped. Do these in order; steps 2
275
+ and 3 are the ones whose omission shows up as a 404 or a doubled basePath on the consent page.
276
+
277
+ 1. **Mount the lib that carries the authorization server** (`libs/shared`) and confirm `lib/_oauth`,
278
+ `page/oauth/consent` and `srvkit/oauthServer.ts` are present. Its `option.ts` declares `auth` for `setMcp`, and
279
+ `setMcp` merges field by field in mount order with the app last — the app never restates `auth`.
280
+ 2. **`akan.config.ts`: `syncPageLibs: true`** (or the lib's name in an array). `akan sync <app>` links the consent
281
+ route under every basePath the app declares; the link folder is generated and never committed.
282
+ 3. **`env.server.*` → `oauth`.** `consentPath` / `signinPath` carry the basePath the browser sees
283
+ (`/office/oauth/consent`, `/office/signin`) and are omitted for an app without one. The server hands the
284
+ sign-in page `?redirect=` as the app's router names the route — basePath removed — because `router.push` puts
285
+ the locale and basePath back; the app adds nothing. `issuer` (`AKAN_MCP_AUTH_SERVERS` for the resource side)
286
+ only behind a tunnel or an edge that renames the host, `resource` (`AKAN_MCP_RESOURCE`) only when `path` moved
287
+ off `/mcp`, `clients` + `dynamicRegistration: false` only for a deployment that closes registration.
288
+ 4. **The sign-in page honours `?redirect=`** by passing it unchanged to the password and SSO controls — a
289
+ router-space path, never prefixed by hand. Accepting it needs only `startsWith("/") && !startsWith("//")`.
290
+ 5. **`lib/option.ts`: `option.setMcp({ instructions, legacyTextBlock: false })`** (`AKAN_MCP_INSTRUCTIONS`,
291
+ `AKAN_MCP_LEGACY_TEXT`). Leave `readOnly` (`AKAN_MCP_READONLY`) off when the point is to let people *use* the
292
+ service; it is the valve for a deployment that must not write, not the way to curate.
293
+ 6. **`JWT_SECRET`** (or `security.jwtSecret`) in every deployment outside `local`; the boot refuses without it.
294
+ 7. **Read the boot log** — `MCP catalogue: tools=… · listing …KB`, the `MCP catalogue cost:` line, one `warn` per
295
+ refusal, and the list of published entries with no `.desc()`. A tool missing from it is missing everywhere.
296
+ 8. **Connect once per app** — `claude mcp add --transport http <name> <issuer>/mcp`; a second entry for the same
297
+ server with a pre-registered client tests a registration mode, it does not add anything a user needs.
298
+
299
+ ## Choosing What To Open
300
+
301
+ One rule: **an endpoint is open to an agent when the same person could do the same thing from the page, under
302
+ the same guards.** What stays closed is closed because no agent has a reason to call it, not because of who may
303
+ — and that is the only thing `mcp: false` says.
304
+
305
+ | Endpoint | Decision |
306
+ |---|---|
307
+ | Domain read slices (`inOrg`, `inProject`, `inSelf`, `byStatuses`) | Open. A named slice publishes only when it declares its **own** `guards`; the `slice()` map reaches the root slice and the generated CRUD, never a named slice. A search slice only on data that may be enumerated. |
308
+ | The root slice and generated CRUD | Published by default; `root:` is `Admin`, so a user token never lists it. Take the cost line first: `mcp: { cru: false }` keeps the reads and drops the writes of a model whose write entries are most of its bytes; `mcp: false` for an internal or sensitive model. |
309
+ | Domain mutations (`startTask`, `completeTicket`) | Open when a person would ask an agent to do it for them; a resource guard is mandatory. An act that cannot be undone — signing, paying, sending, removing — either stays off or says so in its `.desc()`: MCP has no approval card. |
310
+ | Steps of a UI state machine (`requestPhoneCodeForSignin`, `setPasswordInPrepareUser`, a prepare-user flow) | `mcp: false`. Perfectly guarded, and only ever called by mistake. |
311
+ | Authentication, SSO, and the OAuth protocol endpoints | Already `mcp: false` where they are declared. |
312
+ | File upload, an `Any` / `Upload` return, a required `Any` argument, `pubsub` / `message`, `light<Model>` | Refused by the framework; nothing to write. |
313
+ | Admin-only endpoints | Leave the `Admin` guard; an account-scope guard hides the entry from every caller it refuses. |
314
+
315
+ - **Scope is what makes hiding possible.** `static scope: "account"` (a role check) is evaluated with no arguments
316
+ and filters the listing per caller; `"resource"` (`Can<Verb><Model>`, ownership) needs `context.getArg()`, stays
317
+ listed, and stops the call. Marking a resource guard `"account"` would make the listing lie — the marker has no
318
+ default for that reason.
319
+ - **Identity comes from the internal args** (`.with(Self)`, `.with(Account)`, `.with(Me)`), never from an id the
320
+ client sent, and the service re-checks ownership behind the guard.
321
+ - **An admin who signs in on the consent page mints an admin token.** A connector created under an admin account
322
+ passes `Admin` guards; treat that as an operational decision, and read the request's subject type when in doubt.
323
+ - **Return what answers the question.** A count-or-summary endpoint taking an id beats a document; a nullable model
324
+ return publishes no `outputSchema`, so prefer a non-null return plus an `Err`. Bulky page-only fields are
325
+ `field.visual`. Narrow a list with a named filter slice, never with the root list's raw `query`.
326
+
327
+ ## Writing `instructions`
328
+
329
+ `*.abstract.md` and `<Agent.Guide>` never reach an MCP client. Exactly three texts do: `instructions`, every
330
+ published entry's `.desc()`, and a `prompt()`. All three are English, whatever the users speak — the reader is a
331
+ model, and the catalogue is built once in one `language` and cached by clients.
332
+
333
+ - **`instructions` is the workflow.** Five to eight sentences, in this order: what the app is and what its nouns
334
+ mean; **which tool to call first** and which ids the rest take; how a name becomes an id; what a write confirms
335
+ before it runs and which writes cannot be undone; what this server does *not* do and where that is done instead.
336
+
337
+ ```ts
338
+ instructions: [
339
+ "Operations tools for a back-office that runs consulting projects.",
340
+ "An org is one company; a project belongs to an org; a ticket is one unit of work on a project.",
341
+ "Start from orgInSelf, then projectInOrg and ticketInProject; every other tool takes the ids those return.",
342
+ "Prefer ticketStatusInProject for 'how is it going' and ticketInProject only when the user asks for detail.",
343
+ "createTicket, startTicket and completeTicket write on the caller's behalf: confirm the project and title first.",
344
+ "Nothing here signs, invoices or uploads a file; those are deliberate acts on the record's own page.",
345
+ ].join(" "),
346
+ ```
347
+ - **`.desc()` is the reason to pick one tool** — what it returns and when to use it, two clauses. An id argument's
348
+ `.desc()` names the tool that returns it (`From projectInOrg`). The generated CRUD borrows the model's `.of()`
349
+ label and `.desc()`, which is the only text those entries can carry.
350
+ - **`prompt()` is a workflow the user invokes** as a slash command, not one the model chooses — a weekly report,
351
+ an onboarding check. Put the ask in `Msg.user` at a high `priority` and the attachments in `Msg.resource` masked
352
+ by their `Light` model at a low one.
353
+
354
+ ## Verifying An App
355
+
356
+ - `akan lint <app>`, `akan typecheck <app>`, `akan sync <app>`, then the boot log above.
357
+ - The lib's own suites run wherever it is mounted: the OAuth signal test (metadata, registration, both `authorize`
358
+ redirects, code exchange, `/mcp` with the minted token and the refusal of a first-party or forged one, refresh
359
+ rotation) and the refresh-session and option unit tests.
360
+ - **One exposure test per app**, in a `lib/<model>.signal.test.ts`: list `tools/list` with a user token and pin the
361
+ names with `toEqual`, and assert the curated and admin-only ones with `not.toContain`. Exposure is derived from
362
+ the guards, so a guard change fails this test first — which is the point. The framework's own pattern is
363
+ `pkgs/akanjs/server/mcp/mcp.integration.test.ts`.
364
+ - Live: connect a client, consent, call a tool, `claude mcp logout`, authenticate again. `AKAN_PUBLIC_LOG_LEVEL=debug`
365
+ prints one `OAuth token request grant_type=… client_id=…` line per token call; two refreshes in the same second
366
+ both answering 200 is the grace window working, not a fault.
@@ -21,6 +21,18 @@ Generate client state coordination for a module. Store connects generated fetch
21
21
  - Do not perform persistence logic in React components when a store action can own it.
22
22
  - Do not call private or internal signal operations from UI state.
23
23
 
24
+ ## Form Draft Recovery
25
+ - `<model>FormDraft`, `restore<Model>FormDraft`, `discard<Model>FormDraft` and `load<Model>FormDraft` are
26
+ generated. Do not hand-write a draft action, and do not write `<model>Form` to browser storage yourself.
27
+ - The draft key carries the signed-in user, derived by hashing the auth token's payload with `iat`, `exp`, `nbf`
28
+ and `jti` removed. **Do not put a claim that changes on every issue into the JWT.** One would rotate the key on
29
+ every silent token refresh, and the symptom is a form that never recovers anything: the draft was written under
30
+ a key nothing looks for again, and it lingers until the seven-day sweep.
31
+ - `field.secret` and `field.hidden` values are never written to a draft, so they come back empty. That is the
32
+ intended trade — a user retypes a password — and is not something to work around.
33
+ - A model whose form holds a large `field.visual` body can pass the 256KB per-draft cap, and a draft over it is
34
+ dropped with a warning rather than truncated.
35
+
24
36
  ## Review Checklist
25
37
  - The instruction points to current docs pages, not removed docs routes.
26
38
  - Generated examples use current Akan builder APIs and scanner-friendly filenames.
@@ -17,6 +17,11 @@ Generate form and interaction fragments bound to store form state and generated
17
17
  - Do not call service or signal directly from inputs.
18
18
  - Do not duplicate validation that belongs in constants or service invariants.
19
19
  - Do not build page layout here when Zone should compose it.
20
+ - Do not persist typed values yourself. The edit shells (`Load.Edit`, `Model.EditModal`, `Model.New`) save the
21
+ whole `<model>Form` and recover it on the next open; a Template that reaches for `localStorage` or a per-field
22
+ cache saves a fragment of a form and restores it over whatever the server just returned.
23
+ - The `Field.*` `cache` prop and the `Input` `cacheKey` prop are deprecated and store nothing. Turn recovery off
24
+ with `draft={false}` on the shell, or name a scope with `draft="<scope>"`; do not reintroduce a field-level one.
20
25
 
21
26
  ## Review Checklist
22
27
  - The instruction points to current docs pages, not removed docs routes.
@@ -0,0 +1,31 @@
1
+ {
2
+ "title": "Query Rule",
3
+ "description": "Akan data access — filters, slices and hydration, full-text search, and cascade removal",
4
+ "group": "core",
5
+ "codegenPriority": 4,
6
+ "deprecated": false,
7
+ "scans": [
8
+ {
9
+ "type": "example",
10
+ "description": "Filter and model declarations that drive the generated query surface",
11
+ "path": "{apps,libs}/*/lib/*/*.document.ts",
12
+ "sample": 4
13
+ },
14
+ {
15
+ "type": "example",
16
+ "description": "Slice declarations that expose a query to a client store",
17
+ "path": "{apps,libs}/*/lib/*/*.signal.ts",
18
+ "sample": 4
19
+ }
20
+ ],
21
+ "update": {
22
+ "filePath": "./queryRule.instruction.md",
23
+ "contents": ["slices and hydration", "generated filter methods", "text search", "cascade removal"],
24
+ "rules": [
25
+ "Use current Akan APIs only",
26
+ "State the rule and the reason it exists, never restate a type signature",
27
+ "Say which generated methods fire hooks and which do not",
28
+ "Keep it workspace-neutral — no app or repo names"
29
+ ]
30
+ }
31
+ }