@akanjs/cli 2.4.1 → 2.4.2-rc.1

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 (66) hide show
  1. package/.build-stamp +1 -1
  2. package/{agent.command-sa12ccz3.js → agent.command-ash7wabs.js} +7 -7
  3. package/{application.command-jv63vv7z.js → application.command-zm47j93m.js} +5 -5
  4. package/{applicationBuildRunner-vzjdgv1g.js → applicationBuildRunner-554a2vnk.js} +6 -1
  5. package/{applicationReleasePackager-brvth6rs.js → applicationReleasePackager-pjbxc793.js} +1 -1
  6. package/buildBatch.proc.js +3 -3
  7. package/{capacitorApp-wnxzrppx.js → capacitorApp-wc75rvfm.js} +3 -3
  8. package/{cloud.command-8z2nc6b2.js → cloud.command-vwpzten0.js} +10 -10
  9. package/{context.command-0m854xme.js → context.command-j0kq87xa.js} +15 -15
  10. package/{dependencyScanner-m4x5maek.js → dependencyScanner-f6grrep3.js} +2 -2
  11. package/{guideline.command-dsdpae45.js → guideline.command-1m4jwhv0.js} +5 -5
  12. package/incrementalBuilder.proc.js +22 -14
  13. package/{index-eja0sbm6.js → index-0wgpfp7t.js} +6 -6
  14. package/{index-1b9f27pm.js → index-2nb022xv.js} +3 -3
  15. package/{index-n2mp0f48.js → index-31183bxt.js} +6 -6
  16. package/{index-p9f1rpbp.js → index-31e8cwjq.js} +5 -5
  17. package/{index-x53a5nya.js → index-46tjzh6s.js} +1 -1
  18. package/{index-61keag0s.js → index-67546d0j.js} +4 -1
  19. package/{index-q4sc46ec.js → index-79v9jwqe.js} +3 -3
  20. package/{index-m0vg9n8z.js → index-7k9sj7j5.js} +3 -2
  21. package/{index-e3b8ms64.js → index-8dsjmcbp.js} +11 -11
  22. package/{index-2v10yr8g.js → index-ckywhpvp.js} +1 -1
  23. package/{index-d2e2y85b.js → index-cp26p7qd.js} +4 -4
  24. package/{index-eqxmxan6.js → index-ehjhzg5y.js} +1 -1
  25. package/{index-phj3ewxv.js → index-en4zpzdm.js} +2 -2
  26. package/{index-qacv44mm.js → index-f1x6fe2e.js} +1 -1
  27. package/{index-m04as81s.js → index-mpj63mbw.js} +4 -4
  28. package/{index-3a4vntr0.js → index-n08vr4hh.js} +2 -2
  29. package/{index-5vvwc0cz.js → index-nsj2ftxj.js} +1 -1
  30. package/{index-0t7pwff2.js → index-s6nk9815.js} +182 -64
  31. package/{index-hk58kr1m.js → index-smt4re0s.js} +1 -1
  32. package/{index-zw4aqvwh.js → index-t5rn8q9f.js} +4 -4
  33. package/{index-h6pevatb.js → index-tnngmzgf.js} +7 -7
  34. package/{index-eay4t1te.js → index-xdf6rxyt.js} +3 -3
  35. package/{index-81epkybm.js → index-xjkjcbhd.js} +3 -3
  36. package/index.js +19 -19
  37. package/{library.command-fhx5ce8n.js → library.command-39eq3brk.js} +4 -4
  38. package/{localRegistry.command-18f61945.js → localRegistry.command-34zvgkys.js} +9 -9
  39. package/{module.command-29wvnb56.js → module.command-vwahdkzr.js} +8 -8
  40. package/{package.command-46r1dncm.js → package.command-wkwd5x5p.js} +5 -5
  41. package/package.json +2 -2
  42. package/{page.command-vxvqdzc0.js → page.command-9w85hrg0.js} +4 -4
  43. package/{primitive.command-yk622wmt.js → primitive.command-2hnr8h7f.js} +9 -9
  44. package/{quality.command-p0mb5xwt.js → quality.command-4kerz7mh.js} +3 -3
  45. package/{repair.command-nptckp6w.js → repair.command-zmwshmvr.js} +6 -6
  46. package/{routeSourceValidator-wbhmbwpj.js → routeSourceValidator-cncd92fv.js} +39 -0
  47. package/{scalar.command-bss14hez.js → scalar.command-9kanb73t.js} +7 -7
  48. package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +27 -1
  49. package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +14 -0
  50. package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +1 -1
  51. package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +13 -7
  52. package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +23 -3
  53. package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +18 -0
  54. package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +61 -0
  55. package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +15 -0
  56. package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +21 -0
  57. package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +47 -3
  58. package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +69 -0
  59. package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +50 -0
  60. package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +3 -0
  61. package/templates/workspaceRoot/.gitignore.template +1 -0
  62. package/templates/workspaceRoot/AGENTS.md.template +140 -14
  63. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +19 -0
  64. package/templates/workspaceRoot/docs/GENERATED.md.template +1 -1
  65. package/{workflow.command-7fhqb33d.js → workflow.command-4areq0ex.js} +12 -12
  66. package/{workspace.command-xkcec7ky.js → workspace.command-02x93b10.js} +22 -22
@@ -1,21 +1,21 @@
1
1
  // @bun
2
2
  import {
3
3
  ModuleScript
4
- } from "./index-h6pevatb.js";
5
- import"./index-qacv44mm.js";
4
+ } from "./index-tnngmzgf.js";
5
+ import"./index-f1x6fe2e.js";
6
6
  import"./index-ss469dec.js";
7
7
  import {
8
8
  renderPrimitiveReport
9
- } from "./index-2v10yr8g.js";
10
- import"./index-eqxmxan6.js";
11
- import"./index-5vvwc0cz.js";
9
+ } from "./index-ckywhpvp.js";
10
+ import"./index-ehjhzg5y.js";
11
+ import"./index-nsj2ftxj.js";
12
12
  import {
13
13
  Module,
14
14
  Sys,
15
15
  command
16
- } from "./index-phj3ewxv.js";
17
- import"./index-0t7pwff2.js";
18
- import"./index-61keag0s.js";
16
+ } from "./index-en4zpzdm.js";
17
+ import"./index-s6nk9815.js";
18
+ import"./index-67546d0j.js";
19
19
  import"./index-6pz1j0zj.js";
20
20
  import"./index-r24hmh0q.js";
21
21
 
@@ -1,15 +1,15 @@
1
1
  // @bun
2
2
  import {
3
3
  PackageScript
4
- } from "./index-p9f1rpbp.js";
4
+ } from "./index-31e8cwjq.js";
5
5
  import {
6
6
  Pkg,
7
7
  Workspace,
8
8
  command
9
- } from "./index-phj3ewxv.js";
10
- import"./index-0t7pwff2.js";
11
- import"./index-x53a5nya.js";
12
- import"./index-61keag0s.js";
9
+ } from "./index-en4zpzdm.js";
10
+ import"./index-s6nk9815.js";
11
+ import"./index-46tjzh6s.js";
12
+ import"./index-67546d0j.js";
13
13
  import"./index-6pz1j0zj.js";
14
14
  import"./index-r24hmh0q.js";
15
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/cli",
3
- "version": "2.4.1",
3
+ "version": "2.4.2-rc.1",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -34,7 +34,7 @@
34
34
  "@langchain/openai": "^1.4.6",
35
35
  "@tailwindcss/node": "^4.3.0",
36
36
  "@trapezedev/project": "^7.1.4",
37
- "akanjs": "2.4.1",
37
+ "akanjs": "2.4.2-rc.1",
38
38
  "chalk": "^5.6.2",
39
39
  "commander": "^14.0.3",
40
40
  "daisyui": "5.5.23",
@@ -1,14 +1,14 @@
1
1
  // @bun
2
2
  import {
3
3
  PageScript
4
- } from "./index-qacv44mm.js";
4
+ } from "./index-f1x6fe2e.js";
5
5
  import {
6
6
  App,
7
7
  Module,
8
8
  command
9
- } from "./index-phj3ewxv.js";
10
- import"./index-0t7pwff2.js";
11
- import"./index-61keag0s.js";
9
+ } from "./index-en4zpzdm.js";
10
+ import"./index-s6nk9815.js";
11
+ import"./index-67546d0j.js";
12
12
  import"./index-6pz1j0zj.js";
13
13
  import"./index-r24hmh0q.js";
14
14
 
@@ -1,21 +1,21 @@
1
1
  // @bun
2
2
  import {
3
3
  PrimitiveScript
4
- } from "./index-m04as81s.js";
5
- import"./index-h6pevatb.js";
6
- import"./index-qacv44mm.js";
4
+ } from "./index-mpj63mbw.js";
5
+ import"./index-tnngmzgf.js";
6
+ import"./index-f1x6fe2e.js";
7
7
  import"./index-ss469dec.js";
8
8
  import {
9
9
  renderPrimitiveReport
10
- } from "./index-2v10yr8g.js";
11
- import"./index-eqxmxan6.js";
12
- import"./index-5vvwc0cz.js";
10
+ } from "./index-ckywhpvp.js";
11
+ import"./index-ehjhzg5y.js";
12
+ import"./index-nsj2ftxj.js";
13
13
  import {
14
14
  Workspace,
15
15
  command
16
- } from "./index-phj3ewxv.js";
17
- import"./index-0t7pwff2.js";
18
- import"./index-61keag0s.js";
16
+ } from "./index-en4zpzdm.js";
17
+ import"./index-s6nk9815.js";
18
+ import"./index-67546d0j.js";
19
19
  import"./index-6pz1j0zj.js";
20
20
  import"./index-r24hmh0q.js";
21
21
 
@@ -4,9 +4,9 @@ import {
4
4
  command,
5
5
  runner,
6
6
  script
7
- } from "./index-phj3ewxv.js";
8
- import"./index-0t7pwff2.js";
9
- import"./index-61keag0s.js";
7
+ } from "./index-en4zpzdm.js";
8
+ import"./index-s6nk9815.js";
9
+ import"./index-67546d0j.js";
10
10
  import"./index-6pz1j0zj.js";
11
11
  import"./index-r24hmh0q.js";
12
12
 
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  RepairRunner
4
- } from "./index-81epkybm.js";
5
- import"./index-eay4t1te.js";
6
- import"./index-2v10yr8g.js";
4
+ } from "./index-xjkjcbhd.js";
5
+ import"./index-xdf6rxyt.js";
6
+ import"./index-ckywhpvp.js";
7
7
  import {
8
8
  Workspace,
9
9
  command,
10
10
  script
11
- } from "./index-phj3ewxv.js";
12
- import"./index-0t7pwff2.js";
13
- import"./index-61keag0s.js";
11
+ } from "./index-en4zpzdm.js";
12
+ import"./index-s6nk9815.js";
13
+ import"./index-67546d0j.js";
14
14
  import"./index-6pz1j0zj.js";
15
15
  import"./index-r24hmh0q.js";
16
16
 
@@ -100,6 +100,45 @@ class RouteSourceValidator {
100
100
  if (exported.has("metadata") && exported.has("generateMetadata")) {
101
101
  throw new Error(`[route-convention] metadata and generateMetadata cannot both be exported in ${filePath}`);
102
102
  }
103
+ return { devOnly: RouteSourceValidator.#readDevOnly(sourceFile, filePath) };
104
+ }
105
+ static #readDevOnly(sourceFile, filePath) {
106
+ for (const statement of sourceFile.statements) {
107
+ if (!ts.isVariableStatement(statement))
108
+ continue;
109
+ const isExported = ts.getModifiers(statement)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
110
+ if (!isExported)
111
+ continue;
112
+ for (const declaration of statement.declarationList.declarations) {
113
+ if (!ts.isIdentifier(declaration.name) || declaration.name.text !== "pageConfig")
114
+ continue;
115
+ const initializer = RouteSourceValidator.#unwrapExpression(declaration.initializer);
116
+ if (!initializer || !ts.isObjectLiteralExpression(initializer))
117
+ continue;
118
+ for (const property of initializer.properties) {
119
+ if (!ts.isPropertyAssignment(property))
120
+ continue;
121
+ const name = property.name;
122
+ const key = ts.isIdentifier(name) ? name.text : ts.isStringLiteral(name) ? name.text : null;
123
+ if (key !== "devOnly")
124
+ continue;
125
+ const value = RouteSourceValidator.#unwrapExpression(property.initializer);
126
+ if (value?.kind === ts.SyntaxKind.TrueKeyword)
127
+ return true;
128
+ if (value?.kind === ts.SyntaxKind.FalseKeyword)
129
+ return false;
130
+ throw new Error(`[route-convention] pageConfig.devOnly must be a literal true or false in ${filePath} \u2014 the build reads it without evaluating the module`);
131
+ }
132
+ }
133
+ }
134
+ return false;
135
+ }
136
+ static #unwrapExpression(expression) {
137
+ let current = expression;
138
+ while (current && (ts.isAsExpression(current) || ts.isSatisfiesExpression(current) || ts.isParenthesizedExpression(current))) {
139
+ current = current.expression;
140
+ }
141
+ return current;
103
142
  }
104
143
  static validateOverridesSourceExports(source, filePath) {
105
144
  const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
@@ -1,19 +1,19 @@
1
1
  // @bun
2
2
  import {
3
3
  ScalarScript
4
- } from "./index-d2e2y85b.js";
4
+ } from "./index-cp26p7qd.js";
5
5
  import"./index-ss469dec.js";
6
6
  import {
7
7
  renderPrimitiveReport
8
- } from "./index-2v10yr8g.js";
9
- import"./index-eqxmxan6.js";
10
- import"./index-5vvwc0cz.js";
8
+ } from "./index-ckywhpvp.js";
9
+ import"./index-ehjhzg5y.js";
10
+ import"./index-nsj2ftxj.js";
11
11
  import {
12
12
  Sys,
13
13
  command
14
- } from "./index-phj3ewxv.js";
15
- import"./index-0t7pwff2.js";
16
- import"./index-61keag0s.js";
14
+ } from "./index-en4zpzdm.js";
15
+ import"./index-s6nk9815.js";
16
+ import"./index-67546d0j.js";
17
17
  import"./index-6pz1j0zj.js";
18
18
  import"./index-r24hmh0q.js";
19
19
 
@@ -14,4 +14,30 @@ alwaysApply: false
14
14
  - Dynamic segments use `[id]`; route groups use directories like `(user)`, `(public)`, `(tab)`, or `(detail)`.
15
15
  - Page modules should usually export `default`, `pageConfig`, `head`, `generateHead`, or `Loading`.
16
16
  - Prefer `export default function Page` or `export default async function Page` for page components.
17
- - Before changing route behavior, check `pkgs/akanjs/server/src/routeTree.tsx` and nearby routes for the expected pattern.
17
+ - Before changing route behavior, check nearby routes for the expected pattern.
18
+
19
+ ## Page Body Shape
20
+
21
+ ```tsx
22
+ interface PageProps {
23
+ params: { taskId: string };
24
+ }
25
+
26
+ export default async function Page({ params }: PageProps) {
27
+ const { l } = usePage();
28
+ getSelf({ unauthorize: "/signin" });
29
+ const { taskId } = params;
30
+ const [{ task }] = await Promise.all([fetch.viewTask(taskId)]);
31
+ return <Task.View.General task={task} />;
32
+ }
33
+
34
+ export const pageConfig = { transition: "stack" } satisfies PageConfig;
35
+ ```
36
+
37
+ - There is no `loader=` / `render=` page prop. Pages are `export default async function Page`.
38
+ - Declare `interface PageProps { params: {...}; searchParams?: {...} }` immediately above the default export.
39
+ - Body order: `usePage()`, auth, destructure params, fetch, return.
40
+ - Run independent fetches through `Promise.all`, even when there is only one.
41
+ - Gate auth at `_layout.tsx`; repeating `getSelf({ unauthorize: "/signin" })` in the page is fine and common.
42
+ - Keep `async` even when nothing is awaited — it marks a real server page.
43
+ - No `useState`, no `useEffect`, and no comments in page files.
@@ -17,3 +17,17 @@ alwaysApply: false
17
17
  - Module `*.test.ts`, `*.test.tsx`, `*.spec.ts`, and `*.spec.tsx` files are allowed.
18
18
  - `ui/index.ts`, `webkit/index.ts`, `srvkit/index.ts`, `common/index.ts`, and module `lib/**/index.ts` files are generated by `akan sync`; do not hand-edit or track them.
19
19
  - Generated facet indexes export only 1-depth files/folders with `export * from "./name";`.
20
+
21
+ ## Layer Placement
22
+
23
+ | Folder | Admission test | Naming |
24
+ |---|---|---|
25
+ | `common/` | pure, isomorphic, zero-dependency; may import only sibling `common/*` and `akanjs/base`. Cannot import `Err`, so keep throwing code out of it. | camelCase file, filename equals the single export |
26
+ | `webkit/` | touches `window` / `navigator` / Capacitor, or is a React hook | `use<Thing>.tsx` — `.tsx` even with no JSX |
27
+ | `srvkit/` | touches `node:*`, `Bun`, `process.env`, a secret, or a server SDK | camelCase file, PascalCase class |
28
+ | `ui/` | renders JSX and is not bound to one model | PascalCase component, camelCase sidecar (`swipeCard.util.ts`) |
29
+
30
+ - Hooks return a named object of async closures, never a tuple.
31
+ - Only layer-root `index.ts` barrels are generated. A `ui/<Folder>/index.tsx` that builds a namespace is hand-written source; the distinguishing test is that a generated barrel contains nothing but `export * from "./X";` lines.
32
+ - `ui/<Folder>/index_.tsx` (trailing underscore) is the `"use client"` + `lazy()` boundary, with a server-safe `index.tsx` beside it. Collapsing the pair into one file breaks RSC.
33
+ - Never add a sibling helper file inside `lib/<model>/`; helpers belong in one of the folders above.
@@ -12,6 +12,6 @@ alwaysApply: false
12
12
  - Let server page/layout files own route-level concerns: `usePage`, headers, static layout, and `akanjs/ui` `Tab` composition.
13
13
  - Keep interactive loading, submit/import actions, local form inputs, and `router.push` inside client `Util`, `Template`, or `Zone` components.
14
14
  - Prefer server-rendered `Tab` shells for static mode selection; put one client component inside each `Tab.Panel` instead of managing the selected mode with extra `useState`.
15
- - In domain UI, `Template`, `Zone`, and `Util` components are usually client components; `Unit` and `View` components are usually server components.
15
+ - In domain UI the boundary is mechanical, not a judgment call: `Template`, `Zone`, and `Util` are always client components with `"use client"` on line 1; `Unit` and `View` are always server components and never carry the directive. `usePage()` is still legal in server files.
16
16
  - Preserve established domain file roles such as `.document.ts`, `.service.ts`, `.store.ts`, `.constant.ts`, and `.client.ts`.
17
17
  - When unsure, inspect nearby files in the same app or package before introducing a new boundary pattern.
@@ -1,19 +1,25 @@
1
1
  ---
2
- description: Never comment in code except TODO/FIXME/XXX or deletion warnings
2
+ description: Do not narrate code; document only what the code cannot say
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
6
  # Comments
7
7
 
8
- - Never add comments in code by default.
9
- - Prefer clear names and structure so the code needs no explanation.
10
- - Do not narrate what the code already says.
8
+ Do not narrate code. Do document the thing the code cannot say. Both halves are the rule.
9
+
10
+ - Never add a comment that restates the identifier, the signature, or the control flow.
11
+ - Prefer clear names and structure so ordinary logic needs no explanation.
11
12
  - Do not add JSDoc, section banners, or "why/how" comments for ordinary logic.
12
- - Comments are allowed only for these purposes:
13
+ - Comment density tracks the layer, not the author: pages carry none, product `lib/` and `ui/` code stays under 1 %, and `srvkit/` adapters and `guards.ts` carry as much as the external constraints require.
14
+ - A comment is warranted for: a vendor spec or protocol quirk; an infrastructure constraint; a third-party library gotcha; security reasoning; why a rule that looks arbitrary is correct; a math derivation; a domain field's business meaning; a state transition above a document chain method; why an obvious alternative was rejected.
15
+ - In-code markers:
13
16
  1. `TODO` — unfinished work that must be tracked in-code
14
17
  2. `FIXME` — known broken or incorrect behavior that must be fixed
15
18
  3. `XXX` — dangerous / surprising hazard that a reader must not miss
16
- 4. Deletion caution warn why removing a line or block would break something non-obvious
19
+ 4. `//!`disabled or must-fix code
20
+ 5. `//?` — an explanatory aside
21
+ 6. `//*` — a design note
22
+ 7. Deletion caution — warn why removing a line or block would break something non-obvious
17
23
  - Keep allowed comments one short line when possible.
24
+ - Every suppression carries a reason: `// biome-ignore lint/<rule>: <why>`. Never a bare disable block.
18
25
  - Match nearby file style: if the surrounding code has few comments, keep it that way.
19
-
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Coding style conventions for classes and functions
2
+ description: Coding style conventions for classes, functions, files, and types
3
3
  globs: **/*.{ts,tsx}
4
4
  alwaysApply: false
5
5
  ---
@@ -8,7 +8,7 @@ alwaysApply: false
8
8
 
9
9
  - For large units of work, prefer declaring a class and running the flow through an instance instead of scattering many standalone functions.
10
10
  - Prefer class methods or `static` methods over unrelated top-level helper functions when the logic belongs to a class-level workflow.
11
- - Prefer ECMAScript `#private` fields and methods over TypeScript `private`; `*.service.ts` files are the main exception where `private` methods are encouraged.
11
+ - Prefer ECMAScript `#private` fields and methods over TypeScript `private`, except in the four suffixes where `#private` is lint-banned (`*.constant.ts`, `*.document.ts`, `*.service.ts`, `*.store.ts`) those use TypeScript `private`. `#private` is the house style under `srvkit/`, including `adapt()` classes.
12
12
  - In files that declare a class, avoid top-level functions or variables when they can reasonably live inside the class.
13
13
  - Prefer `const` function expressions over `function` declarations unless hoisting, overloads, generators, or framework conventions make `function` the better fit.
14
14
  - Prefer declaring only one class per file; split the file when two or more class declarations are needed.
@@ -17,8 +17,28 @@ alwaysApply: false
17
17
  - Except for React component files or convention files, TypeScript filenames should use camelCase.
18
18
  - In React components, keep one-off `className` strings inline. Only extract class name constants when the class is reused, conditionally composed, or too large to read comfortably in JSX.
19
19
 
20
+ # File Size And Duplication
21
+
22
+ - Keep files small. The house median is well under 50 lines; split a component before it reaches ~150 lines rather than adding section comments.
23
+ - Ship every scaffold file even when it is empty — `export class XInternal extends internal(srv.x, () => ({})) {}`, empty dictionary stages, the `// state` / `// action` markers in an empty store. They mark where things go.
24
+ - Never add a sibling helper file inside `lib/<model>/`. Helpers go to `common/`, `webkit/`, `srvkit/`, or `ui/`.
25
+ - Prefer duplication to premature abstraction at the leaf. Near-identical sibling modules and per-vendor pages are deliberately copied, not parameterised. Copy the file and change the literals; share enums by import only.
26
+
27
+ # TypeScript Shape
28
+
29
+ - Use `interface` for object shapes and `type` only for unions and aliases.
30
+ - Declare `interface <ComponentName>Props` immediately above the component with no blank line between, and put `className?: string` first. Name it for the component (`CardProps`, `WorldProps`), never for the model. Do not export it unless a sibling imports it.
31
+ - Never use a non-null assertion. Narrow with `?.`, an early return, or a type predicate such as `.filter((id): id is string => !!id)`.
32
+ - Escape with `as unknown as T`. Never `as any`.
33
+ - Never annotate a component's return type. Annotate a helper only when the return is a union, a tuple, or a type predicate.
34
+ - Use `as const` on every `enumOf(...)` array, every `via(Model, [...] as const, …)` Light tuple, and every module-scope lookup map. Never use the TypeScript `enum` keyword.
35
+ - Async functions carry no `Async` suffix.
36
+
20
37
  # Test Code
21
38
 
22
39
  - Write TypeScript tests with Bun's test runner and import `describe`, `expect`, and `test` from `bun:test`.
23
40
  - Keep tests colocated with the source they cover using `*.test.ts` or `*.spec.ts`, following the existing nearby pattern.
24
- - Prefer focused behavior tests for public contracts and edge cases over implementation-detail assertions.
41
+ - Prefer focused behavior tests for public contracts and edge cases over implementation-detail assertions.
42
+ - Split signal tests in two. `<model>.signal.spec.ts` holds reusable fixtures built on `sampleOf(cnst.XInput)` with explicit `Promise<cnst.X>` return types and **no assertions**. `<model>.signal.test.ts` holds the assertions: `describe("<Model> Signal")`, `let` fixtures at describe scope, one `beforeAll`, story-ordered `it`s, and negatives via `await expect(p).rejects.toThrow()`.
43
+ - `lib/user/user.signal.spec.ts` is the one place agent types are re-exported and re-typed; import `UserAgent` / `AdminAgent` from there rather than from the shared lib directly.
44
+ - A placeholder `it` with a descriptive title is an acceptable floor. Write a real suite when the behaviour is security-relevant.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Lint rules that break the build, including several whose correct output looks wrong
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Lint-Enforced Rules (These Break The Build)
7
+
8
+ Enforced by `biome.json` and the Akan grit plugins registered in `biome.json`. Several of them produce output that looks wrong; do not "fix" it back.
9
+
10
+ - **Never hand-order Tailwind classes.** `nursery/useSortedClasses` is an error and also sorts the string arguments to `clsx()` and `cva()`. Sorter output such as `font-bold text-2xl text-base-content` or `border-base-content/5 border-t` is correct. Write the classes in any order, run the formatter, leave the result.
11
+ - **Never `throw new Error`.** Throw `new Err("<module>.error.<key>")` and register the key as `[en, ko]` in that module's dictionary `.error({})`. Import `Err` from `"../dict"` on the server and from `"@libs/<lib>/client"` or `"@apps/<app>/client"` in UI. `no-throw-raw-error.grit` exempts `*.test.ts`, `*.spec.ts`, `*.constant.ts`, and `common/**` — `common/` has no legal `Err` import path, so keep throwing code out of it.
12
+ - **Never import a third-party package** from `page/**`, from any barrel, or from any `*.{constant,dictionary,document,service,signal,store}.ts` / `*.{Template,Unit,Util,View,Zone}.tsx` (`no-import-external-library.grit`). Re-export the symbol through a lib first. One-line re-export shims such as `libs/<lib>/base/<pkg>.ts` and `libs/<lib>/webkit/<hook>.ts` exist for exactly this reason — they are load-bearing, not cruft. Do not delete them.
13
+ - **`#private` is banned in exactly four file suffixes:** `*.constant.ts`, `*.document.ts`, `*.service.ts`, and `*.store.ts` (`no-js-private-class-method.grit`). The rule is scoped by file path, not by class shape, so `#private` remains the house style everywhere under `srvkit/`, including `adapt()` adapter classes.
14
+ - **No `console.log` / `console.debug`.** Only `assert`, `error`, `info`, and `warn` are allowed. Server code uses the injected `this.logger.*` or `new Logger("ClassName")`.
15
+ - **Never redeclare a generated CRUD endpoint name** in `*.signal.ts` (`no-redeclare-predefined-endpoint.grit`).
16
+ - **No deep imports past a barrel** (`no-deep-internal-import.grit`). Cross-module constant references such as `../map/map.constant` are the sanctioned exception.
17
+ - **Server-component discipline** is enforced on `page/**`, `*.Unit.tsx`, and `*.View.tsx` (`no-import-client-functions.grit`, `no-use-client-in-server.grit`, `non-scalar-props-restricted.grit`).
18
+ - `noArrayIndexKey` and `useExhaustiveDependencies` are **off** on purpose: `key={idx}` for embedded scalars and short dependency arrays are intentional, not oversights.
@@ -0,0 +1,61 @@
1
+ ---
2
+ description: Per-file shape for constant, document, service, signal, store, dictionary, and abstract files
3
+ globs: apps/**/lib/**/*.{ts,tsx,md},libs/**/lib/**/*.{ts,tsx,md}
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Module File Playbook
8
+
9
+ ## `<model>.constant.ts`
10
+
11
+ Five classes in order with one blank line between them and `enumOf("camelName", [...] as const)` classes above: `XInput → XObject → LightX → X → XInsight`. Write `XInsight` even when it is empty.
12
+
13
+ - Put display and predicate logic on `LightX` (`isNew()`, `canWrite(user?)`, `formatTimes()`, `isCancellable()`) — the Light class is the one both server and client hold, so shared logic belongs there instead of in a util module. This is the most commonly missed rule in the codebase.
14
+ - Collection-level helpers go `static` on the full model.
15
+ - Defaults are a literal for scalars and a thunk for anything constructed. Arrays are `field([T])`; optional is the postfix `.optional()`.
16
+ - Give any field whose business meaning is not obvious a short trailing comment.
17
+
18
+ ## `<model>.document.ts`
19
+
20
+ Fixed order: `XFilter extends from(...)` → `X extends by(...)` → `XModel extends into(...)`, with `sort: {}` always present.
21
+
22
+ - Chain methods validate → mutate → `return this`, and never `save()`; the caller saves, so chains compose (`org.removeUser(id).removeInvite(id).save()`).
23
+ - Put a one-line comment above each chain method stating the transition.
24
+ - Atomic counters live on the Model class with the updater-callback form, returning `!!modifiedCount`.
25
+ - Indexes and derived totals go in `static override _onSchema`, not in the service.
26
+
27
+ ## `<model>.service.ts`
28
+
29
+ - Keep methods to a few lines: load → chain → `return await ….save()`. Write `return await` explicitly in tail position; do not "optimize" it away.
30
+ - Side effects belong in `override async _preUpdate` / `_postCreate`, not inline.
31
+ - Fire-and-forget is explicitly `void`-ed.
32
+ - Order deliberately: load every referenced document, then save, then notify.
33
+ - Return `null` / `false` for "not allowed" or "not found" and let the signal decide whether that is an error.
34
+
35
+ ## `<model>.signal.ts`
36
+
37
+ - `XInternal` → `XSlice` → `XEndpoint`, all three declared even when empty. `exec` is a one-liner delegating to the service.
38
+ - Every `slice()` takes an explicit `{ guards: {…} }` second argument, and `root:` is always `Admin`.
39
+ - Every custom `mutation` / `query` / `message` names its own `guards: [...]` array. `Public` belongs on a slice `get:`, never on a mutation.
40
+ - The acting user arrives via `.with(Self)` / `.with(CurrentUserId)` / `.with(Me)`. Never trust a client-supplied id.
41
+
42
+ ## `<model>.store.ts`
43
+
44
+ - Write a custom action only for a toast, an optimistic update, or a multi-field write; most stores need none, because state and CRUD actions are generated.
45
+ - The body is three lines: `await fetch.X` → `this.setX(...)` → toast. The optimistic shape is mutate the client model, `void fetch.*`, then commit.
46
+ - Use `this.pick(...)` when the value must exist, `this.get()` when it may not, and `this.set({...})` to write.
47
+ - Mutate lists through the collection API (`this.set({ xList: xList.set(x).save() })`), not array spread.
48
+ - **Never `import type { RootStore } from "../st"`** — it crashes `akan build` with a Bun SSR segfault.
49
+ - Store actions do not `try/catch`; let the framework toast the `Err`.
50
+
51
+ ## `<model>.dictionary.ts`
52
+
53
+ Fixed chain, with empty stages still written: `.of() → .model() → .insight() → .query() → .sort() → .enum() → .slice() → .endpoint() → .error() → .translate()`.
54
+
55
+ - Every label is `t(["English", "한국어"])`, and nearly every one also carries `.desc([en, ko])`.
56
+ - Name every argument in `.arg()`, including framework-supplied `skip` / `limit` / `sort`.
57
+ - Use `modelDictionary`, `scalarDictionary`, or `serviceDictionary` to match the module kind.
58
+
59
+ ## `<module>.abstract.md`
60
+
61
+ A title line, one declarative sentence naming what the module owns, a `## Rules` list of two to five invariants the code cannot show, and an optional workflow arrow chain (`draft -> signed -> active -> completed`). Never restate field lists or types. Update it whenever an invariant or workflow changes.
@@ -0,0 +1,15 @@
1
+ ---
2
+ description: Naming conventions for components, methods, slices, booleans, and language choice
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Naming And Language
7
+
8
+ - Component exports are role names — `Card`, `Sticker`, `General`, `Preview`, `Admin`, `World`, `Mesh`, `Remove`. The model comes from the namespace (`<Floor.Unit.Card>`), so never write `FloorCard`. `Util` exports are the endpoint verb minus the model noun (`Serve`, `Refund`, `Complete`, `Terminate`).
9
+ - Layer the verbs: the document chain method drops the model (`sign()`, `approve()`), the service keeps the bare verb, and the signal, store, and dictionary re-add it (`signScContract`). This keeps custom endpoints clear of generated CRUD and makes `st.do.X` read the same as `fetch.X`.
10
+ - Slice and filter names are prepositional: `inOrg`, `inProject`, `inPeriod`, `byStatuses`, `ofPortfolio`. Never `getXInY`, never `listX`.
11
+ - Handlers are `onX` props taking inline arrows. Do not extract a `handleX`.
12
+ - Booleans are `is*` / `has*` / `can*` / `show*` / `disable*`. Counters are `*Num`, indices are `idx`, collections are `*List` or plural. `SCREAMING_SNAKE` is unused; module-scope tables are camelCase + `as const`.
13
+ - Keep existing domain vocabulary and its typos. Transliterated domain terms and misspelled identifiers already in use are load-bearing — renaming them silently breaks callers that match on the name.
14
+ - Identifiers, type names, endpoint names, and log messages are **English, always**. Everything a user reads goes through `l("model.field")` or `l.trans({ en, ko })` — never a hard-coded string in JSX, never `window.alert`.
15
+ - Dictionary entries are `[en, ko]` pairs, and nearly every label also carries a `.desc([en, ko])` even when it repeats the label. English labels are Title Case, Korean is the plain domain term, and `.error()` Korean ends in `다.`.
@@ -0,0 +1,21 @@
1
+ ---
2
+ description: React component, form, and Tailwind/daisyUI styling conventions
3
+ globs: **/*.tsx
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # React Components And Styling
8
+
9
+ - Components are `export const X = ({ … }: XProps) => { return (…); };` — arrow const with a block body. `export default` is reserved for pages, layouts, and `lazy()` targets.
10
+ - Never `React.FC`, never `defaultProps`, never `PropsWithChildren`. Defaults go in the destructuring (`prefix = ""`); children are typed `children: ReactNode`.
11
+ - `"use client"` on line 1 above the imports is mechanical by file role: every `.Zone.tsx`, `.Template.tsx`, and `.Util.tsx` has it; no `.Unit.tsx` or `.View.tsx` ever does. `usePage()` is legal in server files.
12
+ - Conditional render is `cond ? <X/> : null`. Never `{cond && <X/>}` — in a `className` context it renders the literal string `"false"`. Early `return null` is for guard clauses only.
13
+ - Never hand-roll loading, empty, or list states. Use `Load.Units` / `Load.View` / `Load.Edit` with `renderItem`, `renderList`, `renderView`, and `renderEmpty`; `<Empty />` for a bare placeholder; and `Model.New` / `Model.Edit` / `Model.SureToRemove` for CRUD modals.
14
+ - Avoid hooks. `useState` is for modal-open, tab, draft-input, and drag state only — never for server data. `useEffect` must be a genuine effect such as subscribe-with-cleanup or one-shot init. Prefer `Tab` over a `useState` mode switch. `.Template.tsx` files contain zero `useState`.
15
+ - Forms are entirely store-driven: `value={xForm.field}` with `onChange={st.do.setFieldOnX}`, the setter passed by reference. Always use `Field.*`, never a bare `<input>` for a model field. Nested rows use `st.do.writeOnX("payments.3.name", v)` plus the generated `add<Field>OnX` / `sub<Field>OnX`.
16
+ - Read with `st.use.*` and write with `st.do.*`. Client components do not call `fetch.*`.
17
+ - Static class strings stay plain strings. Reach for `clsx` only for a conditional or to merge an incoming `className`, and merge the caller last: `clsx("base classes", conditional, className)`. `clsx` comes from `akanjs/client`. No `twMerge`, no `cn()`.
18
+ - Multi-slot components take extra named props (`wrapperClassName`, `bodyClassName`), never a `classNames` object.
19
+ - Use daisyUI semantic tokens with opacity modifiers (`text-base-content/60`, `border-base-content/10`, `bg-base-100/70`, `bg-primary/10`). Never use `dark:` — theming is the daisyUI theme block in `page/*/styles.css`. Raw hex belongs only in marketing surfaces; match the neighbouring files.
20
+ - Hoist enum→class lookups to a module-scope `as const` map typed `{ [key in cnst.XStatus["value"]]: string }`. Do not use `Record<...>`. Escalate the map to `webkit/` when a second module needs it.
21
+ - Use `<Link>` from `akanjs/ui` for internal navigation; `<a>` only for `mailto:` and external links.
@@ -7,8 +7,52 @@ alwaysApply: false
7
7
  # Scalar Modeling
8
8
 
9
9
  - Define Akan models in `.constant.ts` files with `via` from `akanjs/constant`.
10
- - Import custom scalar helpers such as `ID`, `Int`, `Float`, `JSON`, `Upload`, `Any`, `enumOf`, or `dayjs` from `akanjs/base` when the model needs them.
11
10
  - Use `Int` for whole-number counts and quantities; use `Float` only for values that need decimals.
12
- - Use `ID` for document references and prefer explicit structured fields over `JSON` unless the content is genuinely flexible.
11
+ - Use `ID` for document references and prefer explicit structured fields over `Any` unless the content is genuinely flexible.
13
12
  - For date defaults, prefer a function such as `default: () => dayjs()` so the value is created at runtime.
14
- - Follow the established model layering pattern: `Input`, `Object`, `Light<Model>`, full `<Model>`, and `<Model>Insight` when the domain needs those views.
13
+ - Follow the established model layering pattern in this order: `Input`, `Object`, `Light<Model>`, full `<Model>`, and `<Model>Insight`. Write all five, and write `<Model>Insight` even when it is empty.
14
+ - Put display and predicate logic on the `Light<Model>` class (`isNew()`, `canWrite(user?)`, `formatTimes()`) rather than in a util module — the Light class is the one both server and client hold. Collection-level helpers go `static` on the full model.
15
+ - Defaults are a literal for scalars and a thunk for anything constructed. Arrays are `field([T])`; optional is the postfix `.optional()`.
16
+ - Give any field whose business meaning is not obvious a short trailing comment.
17
+
18
+ ## Scalar & Field Type Reference
19
+
20
+ - **Import from `akanjs/base`** (real classes/helpers, not globals): `Int`, `Float`, `ID`, `Any`, `Upload`, `enumOf`, and the `dayjs` factory. There is **no `JSON` scalar** — use `Any` for open/flexible payloads.
21
+ - **Use the JS globals directly (no import needed)**: `String`, `Boolean`, `Date`. They are monkey-patched to behave like scalars, so `field(String)` typechecks.
22
+ - **`Number` is not a valid field/body type.** `NumberConstructor` is intentionally not augmented, so `field(Number)` / `.body("x", Number)` fails to typecheck. Use `Int` or `Float` instead.
23
+ - Runtime resolution of every scalar (globals included) goes through `PrimitiveRegistry` by `refName` (`pkgs/akanjs/base/primitiveRegistry.ts`).
24
+
25
+ ## Text Search Fields — the `text` role
26
+
27
+ - A field joins the full-text index by declaring one of five roles: `field(String, { text: "title" })`, and likewise
28
+ `"desc"`, `"tag"`, `"thumb"`, `"filter"`. Nothing else opts a field in, and there is no per-model switch.
29
+ - Pick the role by what the value *is*, because `bm25` weights them positionally (`title` 10, `tag` 3, `desc` 1,
30
+ `filter` 0): `title` is the one line a human scans for, `desc` is prose, `tag` is a keyword list, `filter` is a
31
+ scoping value (status, owner, role) that must be matchable but must never outrank a real title hit.
32
+ - `thumb` is mirrored for rendering a hit and is **not** indexed — never expect it to match.
33
+ - **A `secret`, `hidden`, or `resolve()` field with `text` throws at class-build time**, not at query time. That is
34
+ deliberate: the mirror is plaintext, so an indexed secret would leak through search. Do not work around it. The
35
+ same throw covers a `text` field *underneath* one of those — a scalar's own field is reachable through its parent,
36
+ so `f.secret(Noti)` where `Noti.label` carries a role is rejected at the parent, not silently indexed.
37
+ - The role works on a relation too (`image: field(File, { text: "thumb" })`) and on an array (`playing: field([String],
38
+ { text: "tag" })`); an array of objects indexes by leaf key, including an array leaf (`works[*].tags`). A field
39
+ inside a `Map` indexes nothing: there is no fixed path to extract it from.
40
+ - Declaring roles is all the wiring there is. Mirror rows are maintained by SQL triggers — not document hooks —
41
+ because `updateOneByQuery` and friends fire no hooks, and most searchable-field mutations go through exactly that
42
+ path.
43
+ - Search runs on sqlite/libsql only. `q.search()` against Postgres throws, loudly, rather than returning every row.
44
+ - `AKAN_SEARCH_ENABLED=0` switches the index off process-wide; unset means on. It never deletes mirror data, and
45
+ re-enabling reconciles every ref. **Give every process the same value** — a process cannot drop triggers for models
46
+ it does not mount, so a mixed fleet leaves stale triggers behind.
47
+ - The tokenizer is `AKAN_SEARCH_TOKENIZER` (or `database.search.tokenizer`, which wins), defaulting to
48
+ `unicode61 remove_diacritics 2`. Changing it rebuilds the index from the mirror on the next boot — the model
49
+ tables are never re-read — so it is a safe knob, unlike a `text` role change, which re-reads every row. The
50
+ rebuild takes no cross-process claim, so a fleet restarted at once repeats it in every process; stagger the
51
+ restart when the mirror is large.
52
+
53
+ ## Image & File Fields
54
+
55
+ - **Do not declare `Upload` as a model field.** `Upload` is a signal-body-only primitive. Models reference the `File` model instead.
56
+ - Declare an image/file field as a relation to `File`: `image: field(File).optional()` for one, `images: field([File])` for many (see `libs/shared/lib/user/user.constant.ts`, `libs/shared/lib/banner/banner.constant.ts`).
57
+ - The store then auto-generates an `upload<Field>On<Model>(fileList)` action that calls the framework upload mutation and polls file status until it leaves `"uploading"` (`pkgs/akanjs/store/action.ts`).
58
+ - Storage is wired through the `StorageAdaptor` DI role (default `BlobStorage`, `pkgs/akanjs/service/predefinedAdaptor/storage.adaptor.ts`); the reference implementation is the `file` lib (`libs/shared/lib/file/*`). Do not hand-roll data-URL fallbacks.