@akanjs/cli 3.0.0-alpha.4 → 3.0.0-alpha.6

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 (59) hide show
  1. package/.build-stamp +1 -1
  2. package/{abstractCompactor-rk6twzvj.js → abstractCompactor-e5yq60qz.js} +2 -2
  3. package/{agent.command-jfz8yfwy.js → agent.command-b0fcx3r2.js} +7 -7
  4. package/{application.command-mxyqtd6p.js → application.command-cezdnvtq.js} +5 -5
  5. package/{applicationBuildRunner-cwk52sb7.js → applicationBuildRunner-ha3y8ew8.js} +4 -4
  6. package/{applicationReleasePackager-yrrhbkv3.js → applicationReleasePackager-gg8ccbeh.js} +1 -1
  7. package/buildBatch.proc.js +4 -4
  8. package/{capacitorApp-j357ak1g.js → capacitorApp-jaksw4cy.js} +3 -3
  9. package/{cloud.command-f87dwe52.js → cloud.command-6xvsd487.js} +9 -9
  10. package/{context.command-z5bf8bn7.js → context.command-ajn1b683.js} +15 -15
  11. package/{guideline.command-1m1ctar3.js → guideline.command-9ew6aqhm.js} +5 -5
  12. package/guidelines/ssrRule/ssrRule.generate.json +31 -0
  13. package/guidelines/ssrRule/ssrRule.instruction.md +108 -0
  14. package/incrementalBuilder.proc.js +3 -3
  15. package/{index-3pgtw35d.js → index-0cj2zxbm.js} +1 -1
  16. package/{index-jtm86byd.js → index-47qxw1tz.js} +28 -22
  17. package/{index-vhv3xnjz.js → index-60a3jfcz.js} +6 -6
  18. package/{index-b978vs2e.js → index-6npsfpxr.js} +3 -3
  19. package/{index-csqk9z5j.js → index-c94nq3c1.js} +3 -3
  20. package/{index-cn24dcqn.js → index-exhpp31y.js} +2 -2
  21. package/{index-y0k42k04.js → index-hk9rbcsz.js} +1 -1
  22. package/{index-hjzr8ja1.js → index-hrwzz2wf.js} +1 -1
  23. package/{index-rh16j3c7.js → index-j9cxndc0.js} +3 -2
  24. package/{index-jk9q6pse.js → index-jkynkyfk.js} +1 -1
  25. package/{index-4yp06pn1.js → index-jn9vfpwz.js} +9 -31
  26. package/{index-4zgs8g1w.js → index-m4kpmmtj.js} +1 -1
  27. package/{index-e3qskyt2.js → index-meh7mmz9.js} +2 -2
  28. package/{index-6pz1j0zj.js → index-mxvakhsm.js} +6 -2
  29. package/{index-n0z3f2xg.js → index-nfxq39kj.js} +4 -4
  30. package/{index-r4w8cry5.js → index-pfrt7qwh.js} +4 -4
  31. package/{index-cap2k2ch.js → index-qb61h0k7.js} +52 -17
  32. package/{index-xwgm94zr.js → index-qp089jp0.js} +1 -1
  33. package/{index-tq1y56tp.js → index-r7nqv8qj.js} +35 -12
  34. package/{index-1s71fwrq.js → index-vkqxw0ek.js} +11 -11
  35. package/{index-fmgbwsr5.js → index-wrrb8rxk.js} +4 -4
  36. package/{index-xj8bks3p.js → index-zbx0jheb.js} +4 -4
  37. package/{index-ybybkec0.js → index-zr2wvx69.js} +6 -6
  38. package/index.js +19 -19
  39. package/{library.command-pwfx8dx2.js → library.command-aa1g8nsa.js} +4 -4
  40. package/{localRegistry.command-r4zjx5py.js → localRegistry.command-jha3sn50.js} +8 -8
  41. package/{module.command-0t3ewata.js → module.command-b1zzgqde.js} +8 -8
  42. package/{package.command-7hmkxvpa.js → package.command-9qv6vr9s.js} +4 -4
  43. package/package.json +2 -2
  44. package/{page.command-st6r4s0q.js → page.command-k16pw244.js} +4 -4
  45. package/{primitive.command-1qkxpzsn.js → primitive.command-s60dn1ae.js} +9 -9
  46. package/{quality.command-hy5vt1bh.js → quality.command-p3vaze52.js} +456 -71
  47. package/{repair.command-nakkq2zp.js → repair.command-mfv749ha.js} +6 -6
  48. package/{scalar.command-fjq272gs.js → scalar.command-hs3nwzv1.js} +7 -7
  49. package/templates/lib/db.ts +3 -1
  50. package/templates/lib/useClient.ts +9 -3
  51. package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +3 -2
  52. package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +1 -0
  53. package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +59 -0
  54. package/templates/workspaceRoot/AGENTS.md.template +155 -15
  55. package/templates/workspaceRoot/biome.json.template +22 -0
  56. package/{workflow.command-jswbgk90.js → workflow.command-z0e0fk0z.js} +12 -12
  57. package/{workspace.command-h9wwcjpt.js → workspace.command-3ydyy991.js} +21 -21
  58. package/templates/libRoot/base/baseLogic.ts +0 -14
  59. package/templates/libRoot/base/index.ts +0 -8
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  RepairRunner
4
- } from "./index-b978vs2e.js";
5
- import"./index-4yp06pn1.js";
6
- import"./index-4zgs8g1w.js";
4
+ } from "./index-6npsfpxr.js";
5
+ import"./index-jn9vfpwz.js";
6
+ import"./index-m4kpmmtj.js";
7
7
  import {
8
8
  Workspace,
9
9
  command,
10
10
  script
11
- } from "./index-jk9q6pse.js";
12
- import"./index-jtm86byd.js";
13
- import"./index-6pz1j0zj.js";
11
+ } from "./index-jkynkyfk.js";
12
+ import"./index-47qxw1tz.js";
13
+ import"./index-mxvakhsm.js";
14
14
  import"./index-xys926f2.js";
15
15
  import"./index-67546d0j.js";
16
16
  import"./index-r24hmh0q.js";
@@ -1,19 +1,19 @@
1
1
  // @bun
2
2
  import {
3
3
  ScalarScript
4
- } from "./index-fmgbwsr5.js";
4
+ } from "./index-wrrb8rxk.js";
5
5
  import"./index-ss469dec.js";
6
- import"./index-3pgtw35d.js";
6
+ import"./index-0cj2zxbm.js";
7
7
  import {
8
8
  renderPrimitiveReport
9
- } from "./index-4zgs8g1w.js";
10
- import"./index-xwgm94zr.js";
9
+ } from "./index-m4kpmmtj.js";
10
+ import"./index-qp089jp0.js";
11
11
  import {
12
12
  Sys,
13
13
  command
14
- } from "./index-jk9q6pse.js";
15
- import"./index-jtm86byd.js";
16
- import"./index-6pz1j0zj.js";
14
+ } from "./index-jkynkyfk.js";
15
+ import"./index-47qxw1tz.js";
16
+ import"./index-mxvakhsm.js";
17
17
  import"./index-67546d0j.js";
18
18
  import"./index-r24hmh0q.js";
19
19
 
@@ -16,7 +16,9 @@ ${databaseModules.map((module) => `import * as ${module}Db from "./${module}/${m
16
16
  ${libs.map((lib) => `export { db as ${lib} } from "@libs/${lib}/server";`).join("\n")}
17
17
 
18
18
  ${databaseModules.map((module) => `class ${capitalize(module)}Input extends by(cnst.${capitalize(module)}Input) {}`).join("\n")}
19
+ ${databaseModules.map((module) => `class ${capitalize(module)}Insight extends by(cnst.${capitalize(module)}Insight) {}`).join("\n")}
19
20
  ${databaseModules.length ? `export type { ${databaseModules.map((module) => `${capitalize(module)}Input`).join(", ")} };` : ""}
21
+ ${databaseModules.length ? `export type { ${databaseModules.map((module) => `${capitalize(module)}Insight`).join(", ")} };` : ""}
20
22
 
21
23
  ${scalarModules.map((module) => `export type * from "./__scalar/${module}/${module}.document";`).join("\n")}
22
24
  ${databaseModules.map((module) => `export type * from "./${module}/${module}.document";`).join("\n")}
@@ -24,7 +26,7 @@ ${databaseModules.map((module) => `export type * from "./${module}/${module}.doc
24
26
  ${databaseModules
25
27
  .map((module) => {
26
28
  const names = { Module: module.charAt(0).toUpperCase() + module.slice(1) };
27
- return `export const ${module} = DatabaseRegistry.buildModel("${module}" as const, ${names.Module}Input, ${module}Db.${names.Module}, ${module}Db.${names.Module}Model, cnst.${names.Module}, cnst.${names.Module}Insight, ${module}Db.${names.Module}Filter);`;
29
+ return `export const ${module} = DatabaseRegistry.buildModel("${module}" as const, ${names.Module}Input, ${module}Db.${names.Module}, ${module}Db.${names.Module}Model, cnst.${names.Module}, ${names.Module}Insight, ${module}Db.${names.Module}Filter);`;
28
30
  })
29
31
  .join("\n")}
30
32
  ${scalarModules.map((module) => `export const ${module} = DatabaseRegistry.buildScalar("${module}" as const, ${capitalize(module)});`).join("\n")}
@@ -1,16 +1,22 @@
1
1
  import type { AppInfo, LibInfo } from "akanjs";
2
2
 
3
3
  export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: { [key: string]: string } = {}) {
4
+ const isApp = (scanInfo?.type ?? "lib") === "app";
4
5
  return `
5
6
  import { makePageProto, registerClientRuntime } from "akanjs/client";
6
7
  import { FetchClient } from "akanjs/fetch";
7
8
  import * as cnst from "./cnst";
8
- import { getAllDictionary } from "./dict" with { type: "macro" };
9
- import type * as dict from "./dict";
9
+ ${isApp ? `import { getAllDictionary } from "./dict" with { type: "macro" };\n` : ""}import type * as dict from "./dict";
10
10
  import { getSerializedSignal } from "./sig" with { type: "macro" };
11
11
  import type * as signal from "./sig";
12
12
 
13
- const dictionary = process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? getAllDictionary() : {};
13
+ ${
14
+ isApp
15
+ ? `const dictionary = process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? getAllDictionary() : {};`
16
+ : `// dict.ts is cumulative, so a lib dictionary is a subset of the mounting app's. Translator state is global,
17
+ // so the app's seed already resolves l() here — seeding again would ship the same payload a second time.
18
+ const dictionary = {};`
19
+ }
14
20
  const pageProto = makePageProto<typeof dict>(dictionary);
15
21
  const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal(), { Err: pageProto.Err });
16
22
  export const runtime = registerClientRuntime({ ...pageProto, ...fetchProto }, { scope: ${JSON.stringify(scanInfo?.type ?? "lib")} });
@@ -6,8 +6,9 @@ alwaysApply: false
6
6
 
7
7
  # Akan Sync Conventions
8
8
 
9
- - `apps/<appName>` root may only contain these files: `akan.app.json`, `akan.config.ts`, `capacitor.config.ts`, `client.ts`, `main.ts`, `package.json`, `server.ts`, `tsconfig.json`.
10
- - `apps/<appName>` root may only contain these folders: `.akan`, `android`, `common`, `env`, `ios`, `lib`, `page`, `private`, `public`, `script`, `srvkit`, `ui`, `webkit`.
9
+ - `apps/<appName>` root may only contain these files: `AGENTS.md`, `CLAUDE.md`, `akan.app.json`, `akan.config.ts`, `capacitor.config.ts`, `client.ts`, `main.ts`, `package.json`, `server.ts`, `tsconfig.json`.
10
+ - `apps/<appName>` root may only contain these folders: `.akan`, `android`, `common`, `env`, `ios`, `lib`, `mobile`, `page`, `plugin`, `private`, `public`, `script`, `secrets`, `srvkit`, `ui`, `webkit`.
11
+ - `akan sync` maintains a scoped agent guide per app/lib (`apps/<app>/AGENTS.md` / `libs/<lib>/AGENTS.md`); the `akan:agent` block in it is generated, content outside the markers is hand-editable, and `akan lint` fails when the block is stale.
11
12
  - Do not add `apps/*/base`; place shared app utilities under `apps/*/common`.
12
13
  - `apps/*/lib` and `libs/*/lib` root files are limited to generated/support files: `cnst.ts`, `db.ts`, `dict.ts`, `option.ts`, `sig.ts`, `srv.ts`, `st.ts`, `useClient.ts`, `useServer.ts`.
13
14
  - Domain module folders are `lib/<model>` for database modules, `lib/_<service>` for service modules, and `lib/__scalar/<scalar>` for scalar modules.
@@ -15,3 +15,4 @@ alwaysApply: false
15
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.
18
+ - The boundary is only half the rule: how *little* ends up on the client is the other half. See `ssr-first.mdc`.
@@ -0,0 +1,59 @@
1
+ ---
2
+ description: SSR-first rendering rules — keep JSX on the server and justify every "use client"
3
+ globs: apps/**/*.tsx,libs/**/*.tsx
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # SSR First — Server Rendering Is The Default
8
+
9
+ Akan is SSR-first. A JSX element rendered on the server ships as HTML and costs nothing to hydrate; an element
10
+ behind `"use client"` ships twice — as markup and as bundled JS that re-runs in the browser. The boundary question
11
+ is not which file *may* be client, it is **how little** ends up on the client side.
12
+
13
+ - **The default is server. `"use client"` is a cost you justify per component, not a habit.** A component earns the
14
+ directive only by using a client-only capability: a React hook, a JSX event handler, the store (`st.use.*` /
15
+ `st.do.*`), a browser global, or a client-only third-party package. Rendering markup, mapping over data, reading a
16
+ route param, and calling `l()` are server work — `usePage()` and `l()` never force a boundary.
17
+ - The file role decides *where* the boundary sits (`Template`/`Zone`/`Util` are client, `Unit`/`View` are server);
18
+ it does not decide how much markup sits behind it. A `Zone` that hoards markup is still an SSR regression.
19
+ - Measure with `akan quality ssr` (`--format json` for tooling). It reports the server render share per app and lib.
20
+ Treat **50% server share as the floor** and a falling share as a regression to justify or revert.
21
+
22
+ ## What `akan quality ssr` Flags
23
+
24
+ - `akan.ssr.unnecessary-use-client` — the directive is there but nothing in the file needs it. Delete it.
25
+ - `akan.ssr.client-static-component` — a component in a client file renders real markup with zero client-only
26
+ capability: pure server work sitting in the bundle.
27
+ - `akan.ssr.client-static-markup` — a large subtree wraps one or two interactive touches. Split it.
28
+ - `akan.ssr.client-mount-load` — a `useEffect(…, [])` loads server data the page could fetch first.
29
+ - `akan.ssr.module-missing-server-view` — a module renders only from `Template`/`Zone`/`Util`, with no `Unit`/`View`.
30
+ - `akan.ssr.template-client-state` — a `Template` holds form state in `useState` instead of the store.
31
+
32
+ A third-party client package and the `ui/<Folder>/index_.tsx` + `lazy()` boundary both justify the directive and are
33
+ not flagged. Interaction-driven `fetch.*` inside an `onClick` is not flagged either — only mount-time loads are.
34
+
35
+ ## Server-Side Implementation Playbook
36
+
37
+ 1. **Wrap the interaction, not the UI.** The smallest useful client component adds one behaviour and renders
38
+ `children` untouched, so the markup inside never reaches the bundle:
39
+ `export const ClickWrapper = ({ children, onPick }: ClickWrapperProps) => <div onClick={onPick}>{children}</div>;`
40
+ 2. **Split compound components so panels stay on the server.** A tab or accordion needs client state only for
41
+ *which* part is visible. `Tab` / `Tab.Menus` / `Tab.Menu` / `Tab.Panel` from `akanjs/ui` is the shape: only the
42
+ provider and menu hold state, and `<Tab.Panel>` renders children as-is, so a server `Unit`/`View` passed in stays
43
+ server-rendered. Never one client file with a mode `useState` and every panel body inlined.
44
+ 3. **Sync state instead of fetching it.** The page calls `fetch.initTaskInTodo()` / `fetch.viewTask(id)` and passes
45
+ the serializable result into a `Zone`; `Load.Units` / `Load.View` hydrate the store from it. Never a
46
+ `useEffect(…, [])` that fetches on mount.
47
+ 4. **Push the boundary down to the leaf that needs it.** A store-reading `Zone` holds zero markup and delegates to a
48
+ server `View`: `export const Self = () => <Task.View.General task={st.use.task()} />;`
49
+ 5. **Hand the promise across, not the awaited value.** `ClientInit` / `ClientView` are `PromiseOrObject<T>`, so a
50
+ page may pass an unawaited `fetch.initTaskInTodo()` and `Load.*` resolves it behind a skeleton.
51
+ 6. **Use named `ReactNode` slots, not just `children`.** `Layout.Navbar` takes `title`, `back`, `left`, `right`, and
52
+ `children`, so a client shell composes server content in five places.
53
+ 7. **Let the server do the derived work.** Display and predicate logic lives on `LightTask` (`isNew()`,
54
+ `canWrite(user?)`); enum→class lookups live in a module-scope `as const` map.
55
+ 8. **Gate auth on the server.** Check the session in `_layout.tsx` and redirect there, before any HTML is sent.
56
+ 9. **Prefer CSS over client state for pure visibility.** A `data-*` attribute plus `group-data-[…]` variants, or
57
+ `<details>`/`<summary>`, keeps both branches server-rendered.
58
+ 10. **Keep the heavy island out of the first load.** Put a large client-only widget behind the
59
+ `ui/<Folder>/index_.tsx` + `lazy()` pair.
@@ -74,11 +74,12 @@ Use the local module shape before adding a new abstraction.
74
74
  9. Keep page and layout files server-oriented: route-level `usePage`, headers, static layout, and `akanjs/ui` `Tab` composition belong there.
75
75
  10. Put interactive loading, submit/import actions, local form state, and `router.push` in client `Util`, `Template`, or `Zone` components.
76
76
  11. Prefer `Tab` for static mode selection instead of extra `useState`; render one focused client component inside each `Tab.Panel`.
77
- 12. Keep server-only logic out of client surfaces and client-only code out of server imports.
78
- 13. Treat `AKAN_PUBLIC_*` env vars as public. Never put secrets in them.
79
- 14. Add or update tests when behavior, contracts, or CLI output changes.
80
- 15. Update `*.abstract.md` when business invariants, workflows, or public behavior change.
81
- 16. Run the smallest relevant verification command after changes.
77
+ 12. Default to server rendering. Add `"use client"` only for a real client-only capability, and keep markup out of the component that carries it — see **SSR First** below.
78
+ 13. Keep server-only logic out of client surfaces and client-only code out of server imports.
79
+ 14. Treat `AKAN_PUBLIC_*` env vars as public. Never put secrets in them.
80
+ 15. Add or update tests when behavior, contracts, or CLI output changes.
81
+ 16. Update `*.abstract.md` when business invariants, workflows, or public behavior change.
82
+ 17. Run the smallest relevant verification command after changes. After touching any `.tsx`, that includes `akan quality ssr`.
82
83
 
83
84
  ## Common Commands
84
85
 
@@ -111,7 +112,11 @@ akan typecheck <%= appName %>
111
112
  # 3. Test — Run the test code (lib/*/*.signal.test.ts or others)
112
113
  akan test <%= appName %>
113
114
 
114
- # 4. Full production build bundles the app, runs all type/lint checks combined
115
+ # 4. SSR balanceonly after touching .tsx files. Reports the server render share
116
+ # per app/lib and flags client code that should render on the server.
117
+ akan quality ssr
118
+
119
+ # 5. Full production build — bundles the app, runs all type/lint checks combined
115
120
  akan build <%= appName %>
116
121
  ```
117
122
 
@@ -128,6 +133,8 @@ akan create-scalar <scalar-name> <%= appName %> # Add a scalar module (
128
133
  akan create-service <service-name> <%= appName %> # Add a service module (lib/_<service-name>/)
129
134
  akan test <%= appName %> # Run the test code (lib/*/*.signal.test.ts or others)
130
135
  akan lint <%= appName %> # Lint only (no typecheck)
136
+ akan quality scan # All code-quality warnings + SSR balance
137
+ akan quality ssr # SSR balance and client-boundary warnings only
131
138
  ```
132
139
 
133
140
  **CLI argument conventions.** Two argument styles, and mixing them up is a common mistake:
@@ -240,7 +247,7 @@ final fallback when no CLI command covers the change.
240
247
  | Add a reusable value type (e.g., Address, WorkHistory) | `lib/__scalar/<type>/` → constant, dictionary, abstract | `akan sync <name>` |
241
248
  | Create a new URL-visitable page | `page/` → `_index.tsx`, `_layout.tsx`, `[param]/_index.tsx` | Rebuild (akan start auto-detects) |
242
249
  | Change the app color theme / design tokens | `apps/<app>/page/styles.css` → override the semantic token values under `:root, [data-theme="dark"]` and `[data-theme="light"]` (`--primary`, `--background`, `--foreground`, …) | akan start hot-reloads |
243
- | Add a form or reusable UI component | `ui/` → PascalCase `.tsx` with `"use client"` if needed | `akan sync <name>` |
250
+ | Add a form or reusable UI component | `ui/` → PascalCase `.tsx`, **no** `"use client"` unless it uses a hook, event handler, store, or browser API | `akan sync <name>` |
244
251
  | Add a React hook or browser helper | `webkit/` → camelCase `.ts` with `"use client"` | `akan sync <name>` |
245
252
  | Add a server-only guard, middleware, or adaptor | `srvkit/` → PascalCase `.ts` | `akan sync <name>` |
246
253
  | Add a pure helper (no DOM, no server API) | `common/` → camelCase `.ts` | `akan sync <name>` |
@@ -253,6 +260,7 @@ final fallback when no CLI command covers the change.
253
260
  | Create a file without running sync | New files won't appear in barrel exports. Imports like `import * as cnst from "../cnst"` will fail. | Always run `akan sync <name>` after creating, renaming, or deleting any module file |
254
261
  | Use JS `#private` in `*.constant.ts`, `*.document.ts`, `*.service.ts`, or `*.store.ts` | `no-js-private-class-method.grit` bans `#private` in exactly those four file suffixes. The rule is scoped by file path, not class shape — `#private` stays the house style under `srvkit/`, including `adapt()` classes. | `private _methodName()` in those four files; `#methodName()` in `srvkit/` |
255
262
  | Use `console.log()` | Biome lint forbids `console.log`. Only `console.error`, `console.info`, `console.warn` are allowed. | Use one of the three allowed console methods, or `this.logger.*` / `new Logger("ClassName")` on the server |
263
+ | Write a `//!` marker in `ui/`, `webkit/`, `common/`, `page/**/*.tsx`, `*.constant.ts`, `*.store.ts`, or a module component file | `no-bang-comment-in-client.grit` bans it. Bun classifies `//!` and `/*!` as legal comments and keeps them through minification, so the note ships to every visitor. | `// FIXME:` in browser-reachable code; `//!` stays legal in server, `srvkit/`, and CLI files |
256
264
  | `throw new Error("...")` | `no-throw-raw-error.grit` bans raw errors outside tests, `*.constant.ts`, and `common/`. Raw errors carry no dictionary key, so they cannot be localized or toasted. | `throw new Err("task.error.<key>")` plus an `[en, ko]` entry in the module dictionary's `.error({})` |
257
265
  | Hand-order Tailwind classes, or reorder them to "fix" a diff | `useSortedClasses` is an error and also sorts the string arguments to `cn()`. Sorter output like `font-bold text-2xl` looks wrong but is correct. | Write classes in any order and let `akan lint` sort them |
258
266
  | A colour outside the semantic vocabulary — `bg-red-500`, `bg-[#3b82f6]`, `btn-primary`, `text-base-content`, `style={{ color: "#fff" }}` | The theme closes the vocabulary, so these produce **no CSS at all** — the element renders unstyled, and without the lint rules there is no error and no warning either. Raw-palette, arbitrary-colour, daisyUI-legacy and inline-colour rules all catch this. | Semantic tokens: `bg-primary`, `text-foreground/70`, `border-border`. A genuinely fixed colour takes a `// biome-ignore lint/plugin: <reason>` |
@@ -262,6 +270,120 @@ final fallback when no CLI command covers the change.
262
270
  | Use "use client" or `useState`/`useEffect` in pages/*.tsx, *.Unit.tsx, and *.View.tsx files | Server code cannot use React hooks. Wrap in a separate `"use client"` component. | Move hook logic to `webkit/` or a `"use client"` UI component |
263
271
  | Use `<a>` tag for internal navigation between pages | Akan.js uses `<Link>` from `akanjs/ui` for client-side navigation — avoids full page reloads. | `import { Link } from "akanjs/ui"` and use `<Link href="/task">...</Link>` |
264
272
  | Name a custom `Endpoint`/`Slice` like a generated CRUD op — `create<Model>`, `update<Model>`, `remove<Model>`, `view<Model>`, `edit<Model>`, `merge<Model>` | These names are already auto-generated. A collision can pass sync/typecheck/build and only fail at runtime. | Pick a distinct verb, e.g. `startTask`/`archiveTask`, never `createTask` for a custom endpoint |
273
+ | Add `"use client"` to a file that renders markup but uses no hook, event handler, store, or browser API | The directive is a cost, not a formality: everything behind it ships twice, as HTML and as JS that re-runs in the browser. | Delete the directive. `akan quality ssr` flags this as `akan.ssr.unnecessary-use-client` |
274
+ | Put a large static subtree inside a client component that only needs one `onClick` | The whole subtree lands in the bundle for the sake of one handler. | Keep the handler in a small client shell and pass the static markup in as `children`, or move it to a `Unit`/`View` |
275
+ | Load server data with `useEffect(() => { void st.do.initTaskInTodo(); }, [])` | The page renders an empty shell, hydrates, then round-trips for data the server already had. | `await fetch.initTaskInTodo()` in the page and pass `init` to the `Zone` |
276
+
277
+ ## SSR First — Server Rendering Is The Default
278
+
279
+ Akan is SSR-first. Every JSX element that renders on the server ships as HTML and costs nothing to hydrate; every
280
+ element behind `"use client"` ships twice — as markup and as bundled JS that must re-run in the browser. The
281
+ boundary question is not which file *may* be client, it is **how little** ends up on the client side.
282
+
283
+ **The default is server. `"use client"` is a cost you justify per component, not a habit.** A component earns the
284
+ directive only by using a client-only capability: a React hook, a JSX event handler, the store (`st.use.*` /
285
+ `st.do.*`), a browser global, or a client-only third-party package. Rendering markup, mapping over data, reading a
286
+ route param, and calling `l()` are all server work — `usePage()` and `l()` are legal in server components and never
287
+ force a boundary.
288
+
289
+ The file role decides *where* the boundary sits (`Template`/`Zone`/`Util` are client, `Unit`/`View` are server); it
290
+ does not decide how much markup sits behind it. A `Zone` that hoards markup is still an SSR regression.
291
+
292
+ Measure with `akan quality ssr` (`--format json` for tooling). It reports the server render share per app and lib —
293
+ server-rendered JSX elements over total — plus the warnings below. Treat **50% server share as the floor** and a
294
+ falling share as a regression to justify or revert.
295
+
296
+ | Rule | Means |
297
+ |---|---|
298
+ | `akan.ssr.unnecessary-use-client` | The directive is there but nothing in the file needs it. Delete it. |
299
+ | `akan.ssr.client-static-component` | A component in a client file renders real markup with zero client-only capability — pure server work sitting in the bundle. |
300
+ | `akan.ssr.client-static-markup` | A large subtree wraps one or two interactive touches. Split it: interaction stays client, markup goes server. |
301
+ | `akan.ssr.client-mount-load` | A `useEffect(…, [])` loads server data. The page can fetch it before the first byte. |
302
+ | `akan.ssr.module-missing-server-view` | A module renders only from `Template`/`Zone`/`Util` and has no `Unit`/`View` at all. |
303
+ | `akan.ssr.template-client-state` | A `Template` holds form state in `useState` instead of the store. |
304
+
305
+ A third-party client package and the `ui/<Folder>/index_.tsx` + `lazy()` boundary both justify the directive and are
306
+ not flagged. Interaction-driven `fetch.*` inside an `onClick` is not flagged either — only mount-time loads are,
307
+ because those are the ones the server could have performed.
308
+
309
+ ### Server-Side Implementation Playbook
310
+
311
+ **① Wrap the interaction, not the UI.** The smallest useful client component adds one behaviour and renders
312
+ `children` untouched, so the markup inside never reaches the bundle.
313
+
314
+ ```tsx
315
+ // apps/<%= appName %>/ui/ClickWrapper.tsx
316
+ "use client";
317
+ export const ClickWrapper = ({ children, onPick }: ClickWrapperProps) => <div onClick={onPick}>{children}</div>;
318
+
319
+ // in a server page — Task.Unit.Card stays server-rendered
320
+ <ClickWrapper onPick={…}>
321
+ <Task.Unit.Card task={task} />
322
+ </ClickWrapper>
323
+ ```
324
+
325
+ **② Split compound components so panels stay on the server.** A tab, accordion, or disclosure needs client state
326
+ only for *which* part is visible — never for what the parts contain. `Tab` / `Tab.Menus` / `Tab.Menu` / `Tab.Panel`
327
+ from `akanjs/ui` is the reference shape: only the provider and menu hold state, and `<Tab.Panel>` renders its
328
+ children as-is, so a server `Unit`/`View` passed in stays server-rendered.
329
+
330
+ ```tsx
331
+ <Tab defaultMenu="detail">
332
+ <Tab.Menus>
333
+ <Tab.Menu menu="detail">{l("task.detail")}</Tab.Menu>
334
+ <Tab.Menu menu="history">{l("task.history")}</Tab.Menu>
335
+ </Tab.Menus>
336
+ <Tab.Panel menu="detail">
337
+ <Task.View.General task={task} />
338
+ </Tab.Panel>
339
+ </Tab>
340
+ ```
341
+
342
+ Never collapse this into one `"use client"` file with a mode `useState` and every panel body inlined.
343
+
344
+ **③ Sync state instead of fetching it.** A server component cannot hold state, so render the initial data on the
345
+ server and hand it across the boundary as a serializable object. That is what `init` / `view` props are: the page
346
+ calls `fetch.initTaskInTodo()` / `fetch.viewTask(id)`, passes the result into a `Zone`, and `Load.Units` /
347
+ `Load.View` hydrate the store from it.
348
+
349
+ ```tsx
350
+ export default async function Page() {
351
+ const [{ taskInitInTodo }] = await Promise.all([fetch.initTaskInTodo()]);
352
+ return <Task.Zone.Card init={taskInitInTodo} sliceName="taskInTodo" />;
353
+ }
354
+ ```
355
+
356
+ **④ Push the boundary down to the leaf that needs it.** When a `Zone` reads the store, it should hold *zero* markup
357
+ and delegate to a server `View`, so the whole detail surface renders server-side wherever a page uses the `View`
358
+ directly.
359
+
360
+ ```tsx
361
+ "use client";
362
+ export const Self = () => <Task.View.General task={st.use.task()} />;
363
+ ```
364
+
365
+ **⑤ Hand the promise across, not the awaited value.** `ClientInit` / `ClientView` are `PromiseOrObject<T>`, so a
366
+ page may pass an unawaited `fetch.initTaskInTodo()` and `Load.*` resolves it behind a skeleton. `await` blocks the
367
+ shell for data the page needs immediately; passing the promise streams the rest. Independent fetches still go
368
+ through one `Promise.all`.
369
+
370
+ **⑥ Use named `ReactNode` slots, not just `children`.** A client shell can take several server-rendered subtrees:
371
+ `Layout.Navbar` accepts `title`, `back`, `left`, `right`, and `children`, so it composes server content in five
372
+ places instead of absorbing it.
373
+
374
+ **⑦ Let the server do the derived work.** Display and predicate logic belongs on `LightTask` (`isNew()`,
375
+ `canWrite(user?)`, `formatTimes()`), and enum→class lookups belong in a module-scope `as const` map. Both sides call
376
+ the same method, so a client component that exists only to compute a label is markup in the wrong place.
377
+
378
+ **⑧ Gate auth on the server.** Check the session in `_layout.tsx` and redirect there, before any HTML is sent. A
379
+ client-side auth check costs a hydration round-trip and flashes the wrong UI first.
380
+
381
+ **⑨ Prefer CSS over client state for pure visibility.** A `data-*` attribute plus `group-data-[…]` variants, or
382
+ `<details>`/`<summary>`, keeps both branches server-rendered. Reach for `useState` when the state is real, not when
383
+ a Tailwind variant would do.
384
+
385
+ **⑩ Keep the heavy island out of the first load.** A large client-only widget goes behind the
386
+ `ui/<Folder>/index_.tsx` + `lazy()` pair so the server renders the page around it.
265
387
 
266
388
  ## Code Style
267
389
 
@@ -367,6 +489,9 @@ Do not narrate code. Do document the thing the code cannot say. Both halves are
367
489
  - Markers: `TODO` unfinished work · `FIXME` known broken behavior · `XXX` hazard a reader must not miss · `//!`
368
490
  disabled or must-fix code · `//?` an explanatory aside · `//*` a design note · deletion caution, warning why
369
491
  removing a line would break something non-obvious.
492
+ - `//!` is for server, `srvkit/`, and CLI files only. Bun's bundler treats `//!` and `/*!` as legal comments and
493
+ keeps them through minification, so in browser-reachable code the note ships verbatim to every visitor. Use
494
+ `// FIXME:` there — `no-bang-comment-in-client.grit` enforces it.
370
495
  - Keep allowed comments to one short line, and give every suppression a reason:
371
496
  `// biome-ignore lint/<rule>: <why>`. Never a bare disable block.
372
497
  - Match nearby file style: if the surrounding code has few comments, keep it that way.
@@ -533,7 +658,7 @@ export class TaskService extends serve(db.task, ({ plug }) => ({
533
658
  For a custom adapter class (not a predefined role), pass the class itself, e.g. `ipfsApi: plug(IpfsApi)`
534
659
  (see `libs/shared/lib/file/file.service.ts`). Injecting a file/image field is usually simpler than calling
535
660
  storage directly: declare `image: field(File).optional()` (or `images: field([File])`) on the model and let the
536
- store's generated `upload<Field>On<Model>(fileList)` action handle the upload. Add `{ cascade: "remove" }` to that
661
+ store's generated `upload<Field>On<Model>(fileList)` action handle the upload. Add `{ cascade: "removeRef" }` to that
537
662
  field when the file belongs to the model alone, and removing the model removes the file and its stored object.
538
663
 
539
664
  ---
@@ -751,12 +876,23 @@ A short list of things the type system does not always catch:
751
876
  `secret` / `hidden` / `resolve()` fields with `text` throw at class-build time — the mirror is plaintext. Search
752
877
  runs on sqlite/libsql only; `q.search()` against Postgres throws. `thumb` is mirrored for rendering and is not
753
878
  indexed.
754
- - **`cascade: "remove"` takes a relation's target down with its owner.** Declare it on the relation itself
755
- `image: field(File, { cascade: "remove" })`, arrays included. The removal runs through the **target's service**,
756
- so the target's own `_postRemove` runs too; that is how removing a model also deletes the file's stored object.
757
- Only a relation accepts it: a `String`, an `ID`, or a scalar throws while the class is being built. Nothing
758
- checks for other references to the same target, so declaring it asserts exclusive ownership. Document removal is
759
- soft but the storage delete is not, and query-level removal fires no hooks and therefore no cascade.
879
+ - **`cascade` names a direction, and the wrong one is a data loss.** Both actions can sit on the same field shape,
880
+ so the value has to say which end goes away. `cascade: "removeRef"` on the relation an owner holds
881
+ (`image: field(File, { cascade: "removeRef" })`, arrays included) removes the target when the owner is removed;
882
+ only a relation accepts it. `cascade: "removeWith"` on a child's own reference to its owner
883
+ (`field(ID, { ref: "agentSession", cascade: "removeWith" })`, or a relation, or `refPath` for a polymorphic
884
+ owner whose type field must be an `enumOf`) removes the child when the owner is the owner never learns its
885
+ children exist. The removal runs through the **target's service** so its `_postRemove` runs too, unless the
886
+ target provably has no removal side effect, in which case the boot-time plan collapses it into one query. A
887
+ `removeWith` field gets its index automatically. Nothing checks for other references to the same target, so
888
+ `removeRef` asserts exclusive ownership. Removal is soft but a storage delete is not, and a query-level removal
889
+ fires no hooks and therefore no cascade.
890
+ - **Removal is always soft, and `delete` is reserved.** `remove(id)`, the facade's `removeMany(query)`, and the
891
+ store's `removeManyByQuery` all stamp `removedAt`; the framework has no hard delete for a model table.
892
+ - **The model facade spells out `Many`/`One` on its writes** — `updateOne`, `updateMany`, `removeOne`, `removeMany`
893
+ — because a bare `update`/`remove` would read like the document-path `update(id)` / `doc.remove()` while hitting
894
+ every match. Reads keep the short `find`/`findOne` pair, and counting is `count(query)` (`countDocuments` is
895
+ `@deprecated`).
760
896
  - **`q.search()` is a filter node, not a slice requirement.** Prefer
761
897
  `bySearch: filter().arg("text", String).query((text, q) => q.search(text, { prefix: true }))` — the generated
762
898
  `listBySearch` / `countBySearch` / `queryBySearch` / `insightBySearch` come for free. Only add a search slice when
@@ -834,8 +970,12 @@ akan sync automatically generates APIs across all layers. Only write custom logi
834
970
  | `pick[Query](args)`, `pickId[Query](args)` | Find one (throw if not found) |
835
971
  | `exists[Query](args)`, `count[Query](args)` | Existence check and count |
836
972
  | `insight[Query](args)`, `query[Query](args)` | Insight and raw query |
973
+ | `remove[Query](args)`, `removeOne[Query](args)` | Query-level soft remove — all matches, or the newest one (`createdAt` desc, not caller-chosen) |
974
+ | `update[Query](args).set(patch)`, `updateOne[Query](args).set(patch)` | Query-level update — the patch lands on a terminal `.set()`, because a filter's trailing args may be optional |
975
+
976
+ **Rule**: Define `Filter` with `.query()` conditions in `document.ts`. akan sync auto-generates all 14 query helper methods per filter. Write `Document` chain methods only for state transitions with validation.
837
977
 
838
- **Rule**: Define `Filter` with `.query()` conditions in `document.ts`. akan sync auto-generates all 10 query helper methods per filter. Write `Document` chain methods only for state transitions with validation.
978
+ **The four query-level writes fire no hooks**, so no `_pre`/`_postRemove` and no cascade run — same as `updateManyByQuery`. Reach for them when the model carries no removal side effect; otherwise remove documents one at a time. A filter keyed after its own model (filter `chat` on model `chat`) is rejected at boot, because `removeChat`/`updateChat` would otherwise shadow the generated single-document CRUD.
839
979
 
840
980
  ## Generated Context
841
981
 
@@ -166,6 +166,28 @@
166
166
  "includes": ["**/*.signal.ts"],
167
167
  "plugins": ["./node_modules/@akanjs/devkit/lint/no-redeclare-predefined-endpoint.grit"]
168
168
  },
169
+ {
170
+ "includes": [
171
+ "**/ui/**/*.ts",
172
+ "**/ui/**/*.tsx",
173
+ "**/webkit/**/*.ts",
174
+ "**/webkit/**/*.tsx",
175
+ "**/common/**/*.ts",
176
+ "**/page/**/*.tsx",
177
+ "**/*.constant.ts",
178
+ "**/*.store.ts",
179
+ "**/*.Template.tsx",
180
+ "**/*.Unit.tsx",
181
+ "**/*.Util.tsx",
182
+ "**/*.View.tsx",
183
+ "**/*.Zone.tsx",
184
+ "!**/*.test.ts",
185
+ "!**/*.test.tsx",
186
+ "!**/*.spec.ts",
187
+ "!**/*.spec.tsx"
188
+ ],
189
+ "plugins": ["./node_modules/@akanjs/devkit/lint/no-bang-comment-in-client.grit"]
190
+ },
169
191
  {
170
192
  "includes": [
171
193
  "**/*.constant.ts",
@@ -1,31 +1,31 @@
1
1
  // @bun
2
2
  import {
3
3
  WorkflowRunner
4
- } from "./index-csqk9z5j.js";
4
+ } from "./index-c94nq3c1.js";
5
5
  import {
6
6
  PrimitiveScript
7
- } from "./index-r4w8cry5.js";
7
+ } from "./index-pfrt7qwh.js";
8
8
  import {
9
9
  ModuleScript
10
- } from "./index-vhv3xnjz.js";
11
- import"./index-hjzr8ja1.js";
10
+ } from "./index-60a3jfcz.js";
11
+ import"./index-hrwzz2wf.js";
12
12
  import {
13
13
  ScalarScript
14
- } from "./index-fmgbwsr5.js";
14
+ } from "./index-wrrb8rxk.js";
15
15
  import"./index-ss469dec.js";
16
- import"./index-3pgtw35d.js";
17
- import"./index-4yp06pn1.js";
16
+ import"./index-0cj2zxbm.js";
17
+ import"./index-jn9vfpwz.js";
18
18
  import {
19
19
  createWorkflowStepRegistry
20
- } from "./index-4zgs8g1w.js";
21
- import"./index-xwgm94zr.js";
20
+ } from "./index-m4kpmmtj.js";
21
+ import"./index-qp089jp0.js";
22
22
  import {
23
23
  Workspace,
24
24
  command,
25
25
  script
26
- } from "./index-jk9q6pse.js";
27
- import"./index-jtm86byd.js";
28
- import"./index-6pz1j0zj.js";
26
+ } from "./index-jkynkyfk.js";
27
+ import"./index-47qxw1tz.js";
28
+ import"./index-mxvakhsm.js";
29
29
  import"./index-xys926f2.js";
30
30
  import"./index-67546d0j.js";
31
31
  import"./index-r24hmh0q.js";
@@ -1,48 +1,48 @@
1
1
  // @bun
2
2
  import {
3
3
  ContextScript
4
- } from "./index-1s71fwrq.js";
5
- import"./index-b978vs2e.js";
6
- import"./index-csqk9z5j.js";
7
- import"./index-r4w8cry5.js";
8
- import"./index-vhv3xnjz.js";
9
- import"./index-hjzr8ja1.js";
4
+ } from "./index-vkqxw0ek.js";
5
+ import"./index-6npsfpxr.js";
6
+ import"./index-c94nq3c1.js";
7
+ import"./index-pfrt7qwh.js";
8
+ import"./index-60a3jfcz.js";
9
+ import"./index-hrwzz2wf.js";
10
10
  import {
11
11
  CloudScript
12
- } from "./index-ybybkec0.js";
12
+ } from "./index-zr2wvx69.js";
13
13
  import {
14
14
  getLatestPackageVersion,
15
15
  getNpmRegistryUrl
16
- } from "./index-xj8bks3p.js";
16
+ } from "./index-zbx0jheb.js";
17
17
  import {
18
18
  PackageScript
19
- } from "./index-e3qskyt2.js";
20
- import"./index-fmgbwsr5.js";
19
+ } from "./index-meh7mmz9.js";
20
+ import"./index-wrrb8rxk.js";
21
21
  import"./index-ss469dec.js";
22
- import"./index-y0k42k04.js";
22
+ import"./index-hk9rbcsz.js";
23
23
  import {
24
24
  GlobalConfig
25
- } from "./index-3pgtw35d.js";
25
+ } from "./index-0cj2zxbm.js";
26
26
  import {
27
27
  AgentScript
28
- } from "./index-n0z3f2xg.js";
29
- import"./index-4yp06pn1.js";
30
- import"./index-4zgs8g1w.js";
31
- import"./index-xwgm94zr.js";
28
+ } from "./index-nfxq39kj.js";
29
+ import"./index-jn9vfpwz.js";
30
+ import"./index-m4kpmmtj.js";
31
+ import"./index-qp089jp0.js";
32
32
  import {
33
33
  ApplicationScript
34
- } from "./index-tq1y56tp.js";
34
+ } from "./index-r7nqv8qj.js";
35
35
  import"./index-76rn3g2c.js";
36
36
  import {
37
37
  LibraryScript
38
- } from "./index-cn24dcqn.js";
38
+ } from "./index-exhpp31y.js";
39
39
  import {
40
40
  Exec,
41
41
  Workspace,
42
42
  command,
43
43
  runner,
44
44
  script
45
- } from "./index-jk9q6pse.js";
45
+ } from "./index-jkynkyfk.js";
46
46
  import"./index-fgc8r6dj.js";
47
47
  import {
48
48
  ThemeValidator,
@@ -59,8 +59,8 @@ import {
59
59
  collectScopeRecipeSources,
60
60
  extractAgentBlock,
61
61
  renderScopeAgentBlock
62
- } from "./index-jtm86byd.js";
63
- import"./index-6pz1j0zj.js";
62
+ } from "./index-47qxw1tz.js";
63
+ import"./index-mxvakhsm.js";
64
64
  import {
65
65
  collectRecipeSources,
66
66
  scanRecipes
@@ -1,14 +0,0 @@
1
- interface Dict {
2
- libName: string;
3
- }
4
- export default function getContent(scanInfo: null, dict: Dict) {
5
- return `
6
- // 현 디렉토리에서는 프로젝트 내 전체적으로 사용되는 로직을 구현하며, 따라서 백/프론트 비의존적인 pure js 코드만 구현 가능합니다.
7
- // common폴더와 다른점은, base 코드는 시스템 전체에서 import되어 사용되므로, 가장 핵심적인 로직과 추상화된 기능만 구현해야합니다.
8
- // @${dict.libName}/base에서는 서버/클라이언트 관련 라이브러리(@*/server, @*/server, @*/client, @*/client)를 모두 import할 수 없으며, @*/base 라이브러리만 import 가능합니다.
9
-
10
- export const someBaseLogic = () => {
11
- //
12
- };
13
- `;
14
- }
@@ -1,8 +0,0 @@
1
- interface Dict {
2
- [key: string]: string;
3
- }
4
- export default function getContent(scanInfo: null, dict: Dict = {}) {
5
- return `
6
- export * from "./baseLogic";
7
- `;
8
- }