@akanjs/cli 3.0.0-alpha.8 → 3.0.0-alpha.9

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 (74) hide show
  1. package/.build-stamp +1 -1
  2. package/{agent.command-pggr92jj.js → agent.command-f0gqkfgz.js} +7 -6
  3. package/{application.command-692yap1d.js → application.command-x903m2qq.js} +5 -4
  4. package/buildBatch.proc.js +2 -1
  5. package/{capacitorApp-p0z5yab2.js → capacitorApp-9xswcgx7.js} +3 -2
  6. package/{cloud.command-wqfsyzv2.js → cloud.command-zs6kyf83.js} +8 -7
  7. package/{context.command-9bxtdn0w.js → context.command-fmepgjzg.js} +14 -13
  8. package/getDirname-m9s0cmhq.js +8 -0
  9. package/{guideline.command-nfqahxex.js → guideline.command-n6sw0a0c.js} +5 -4
  10. package/guidelines/conventions/conventions.generate.json +25 -0
  11. package/guidelines/conventions/conventions.instruction.md +668 -0
  12. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
  13. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +972 -0
  14. package/incrementalBuilder.proc.js +2 -1
  15. package/index-1577bej2.js +7 -0
  16. package/{index-bz2sfzzt.js → index-3vta1tqa.js} +4 -4
  17. package/{index-p3f4q532.js → index-4m0bphac.js} +3 -3
  18. package/{index-w6wbb612.js → index-5sn5w2mt.js} +13 -13
  19. package/{index-5dw57f0d.js → index-62955kn5.js} +6 -6
  20. package/{index-mssqn2sq.js → index-774gcx29.js} +43 -4
  21. package/{index-xhgtkekh.js → index-779ske1y.js} +1 -1
  22. package/{index-js368gk9.js → index-82jrh4hj.js} +5 -5
  23. package/{index-a1e0j63x.js → index-d43t8af2.js} +2 -2
  24. package/{index-gex7c8kd.js → index-eyyf2149.js} +34 -6
  25. package/{index-azv0xjb5.js → index-gcv8ncfh.js} +2 -2
  26. package/{index-7myvn0f0.js → index-j37qq1f2.js} +1 -1
  27. package/{index-ztpw544k.js → index-jf2ya7r2.js} +3 -3
  28. package/{index-vtj3zps1.js → index-jhpa13zj.js} +7 -7
  29. package/{index-6rhabeev.js → index-kdh76j26.js} +4 -2
  30. package/{index-5pmx7bkg.js → index-qzdjd4ct.js} +3 -3
  31. package/{index-2c3e2xh8.js → index-rxkpk7n4.js} +1 -1
  32. package/{index-4hek879p.js → index-xmmzf150.js} +1 -1
  33. package/{index-gmy45vz2.js → index-y4vkyhvv.js} +3 -3
  34. package/{index-vg0sj9nc.js → index-z8ptfkzv.js} +56 -18
  35. package/index.js +19 -18
  36. package/{library.command-md9715jz.js → library.command-cv9gdbmg.js} +4 -3
  37. package/{localRegistry.command-exkbamyj.js → localRegistry.command-d8fg36zc.js} +7 -6
  38. package/{module.command-w5aaddxk.js → module.command-qyr1s9cn.js} +7 -6
  39. package/{package.command-yfkrcy0z.js → package.command-wsjx0k47.js} +4 -3
  40. package/package.json +2 -2
  41. package/{page.command-echbavp4.js → page.command-rdzg65rm.js} +4 -3
  42. package/{primitive.command-9fbhspw2.js → primitive.command-89g38b53.js} +8 -7
  43. package/{quality.command-3pnt9yep.js → quality.command-0cs2z92d.js} +3 -2
  44. package/{repair.command-carj4vax.js → repair.command-6fphxfwj.js} +6 -5
  45. package/{scalar.command-51ryzypc.js → scalar.command-xfer69s6.js} +6 -5
  46. package/templates/crudPages/[__model__Id]/edit/page.tsx +1 -1
  47. package/templates/crudPages/new/page.tsx +1 -1
  48. package/templates/crudSinglePage/page.tsx +1 -1
  49. package/templates/module/__Model__.Util.tsx +1 -1
  50. package/templates/module/__Model__.Zone.tsx +3 -5
  51. package/templates/workspaceRoot/AGENTS.md.template +0 -972
  52. package/templates/workspaceRoot/biome.json.template +3 -244
  53. package/{workflow.command-91wmvm8k.js → workflow.command-2ygfqt4f.js} +13 -12
  54. package/{workspace.command-wa10mfd9.js → workspace.command-88m0zs64.js} +35 -33
  55. package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
  56. package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -34
  57. package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
  58. package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
  59. package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
  60. package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
  61. package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
  62. package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
  63. package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
  64. package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -19
  65. package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -62
  66. package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
  67. package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
  68. package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
  69. package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -99
  70. package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
  71. package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
  72. package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
  73. package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
  74. package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
@@ -1,17 +0,0 @@
1
- ---
2
- description: Akan domain module file roles and naming conventions
3
- globs: apps/**/lib/**/*.{ts,tsx},libs/**/lib/**/*.{ts,tsx}
4
- alwaysApply: false
5
- ---
6
-
7
- # Domain Module Conventions
8
-
9
- - Organize business concepts as domain folders under `lib/`; keep related schema, service, signal, store, and UI files together.
10
- - Use lowercase logic files such as `<model>.constant.ts`, `<model>.document.ts`, `<model>.service.ts`, `<model>.signal.ts`, `<model>.dictionary.ts`, and `<model>.store.ts`.
11
- - Use PascalCase React component files such as `<Model>.Template.tsx`, `<Model>.Unit.tsx`, `<Model>.View.tsx`, `<Model>.Zone.tsx`, and `<Model>.Util.tsx`.
12
- - Treat `constant.ts`, `dictionary.ts`, and `signal.ts` as shared contract files that should avoid platform-specific dependencies.
13
- - Keep backend persistence/query logic in `.document.ts` and domain business orchestration in `.service.ts`.
14
- - Keep frontend state in `.store.ts`; use `Template` for forms, `Unit` for list/card items, `View` for details, `Zone` for composed page sections, and `Util` for domain-specific UI helpers.
15
- - Move reusable workflow state and actions from client UI into `<model>.store.ts` when they span loading state, selected lists, messages, or multi-step actions; consume them as `st.use.someState()` and `st.do.someAction()`.
16
- - Keep `Util` components thin when a store action exists: render controls, call `st.do.*`, read `st.use.*`, and leave orchestration in the store.
17
- - When adding or formalizing a public workflow such as importing an existing project, update the module `*.abstract.md` with the invariant or behavior change.
@@ -1,12 +0,0 @@
1
- ---
2
- description: Formatting and linting conventions
3
- alwaysApply: true
4
- ---
5
-
6
- # Formatting And Linting
7
-
8
- - Use Biome as the formatter and linter.
9
- - Format with `bun run akan lint <appName>` from the repo root.
10
- - Keep formatting consistent with `biome.json`: 2-space indentation, 120 line width, and double quotes for JS/TS.
11
- - Avoid adding new `console` usage except accepted methods such as `console.error`, `console.info`, and `console.warn`.
12
- - Do not make broad formatting-only changes in unrelated files.
@@ -1,19 +0,0 @@
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 `cn()`. 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`, `common/**`, and `apps/akan/env/**` — `common/` and `env/` have no legal `Err` import path, so keep throwing code out of them.
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 return a value from a store action** (`no-return-in-store-action.grit`). Every method of a `store(...)` class dispatches through `st.do.<action>()`, which is typed `void` / `Promise<void>`, so the value is unreachable — write it into state with `this.set({ ... })`. A bare `return;` guard, a `return` inside a nested callback, a getter, and a `static` helper are all still fine.
16
- - **Never redeclare a generated CRUD endpoint name** in `*.signal.ts` (`no-redeclare-predefined-endpoint.grit`).
17
- - **No deep imports past a barrel** (`no-deep-internal-import.grit`). Cross-module constant references such as `../map/map.constant` are the sanctioned exception.
18
- - **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`).
19
- - `noArrayIndexKey` and `useExhaustiveDependencies` are **off** on purpose: `key={idx}` for embedded scalars and short dependency arrays are intentional, not oversights.
@@ -1,62 +0,0 @@
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
- - An action returns nothing — `st.do.<action>()` is typed `void` / `Promise<void>`, so hand the result to `this.set({...})` rather than returning it (`no-return-in-store-action.grit`); a bare `return;` guard stays fine.
49
- - **Never `import type { RootStore } from "../st"`** — it crashes `akan build` with a Bun SSR segfault.
50
- - Store actions do not `try/catch`; let the framework toast the `Err`.
51
-
52
- ## `<model>.dictionary.ts`
53
-
54
- Fixed chain, with empty stages still written: `.of() → .model() → .insight() → .query() → .sort() → .enum() → .slice() → .endpoint() → .error() → .translate()`.
55
-
56
- - Every label is `t(["English", "한국어"])`, and nearly every one also carries `.desc([en, ko])`.
57
- - Name every argument in `.arg()`, including framework-supplied `skip` / `limit` / `sort`.
58
- - Use `modelDictionary`, `scalarDictionary`, or `serviceDictionary` to match the module kind.
59
-
60
- ## `<module>.abstract.md`
61
-
62
- 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.
@@ -1,15 +0,0 @@
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 `다.`.
@@ -1,21 +0,0 @@
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.
@@ -1,17 +0,0 @@
1
- ---
2
- description: Akan.js monorepo structure and ownership conventions
3
- alwaysApply: true
4
- ---
5
-
6
- # Repo Overview
7
-
8
- - Akan.js is a full-stack TypeScript framework for building all-stack applications at once.
9
- - Write one line and deploy across web, app, server, database, and infrastructure.
10
- - Akan prioritizes actual business code by abstracting technical implementation details as much as possible.
11
- - The goal is minimal code, high performance, and type-safe services that can deploy to web, mobile, server, and DB infrastructure together.
12
- - This is a Bun-first Akan.js monorepo.
13
- - Main top-level areas are `apps/`, `libs/`, `pkgs/`, and `infra/`.
14
- - `apps/<app>` contains app-level pages, domain code, UI, env files, and `akan.config.ts`.
15
- - `libs/*` contains shared domain and utility libraries.
16
- - `pkgs/akanjs/*` contains framework, runtime, and tooling facets published through the single `akanjs` package. Prefer extending existing Akan facets before adding new framework-level patterns.
17
- - `infra/` contains Helm, deployment templates, edge configs, and Jenkins env/secret scripts.
@@ -1,99 +0,0 @@
1
- ---
2
- description: Akan scalar and constant model conventions
3
- globs: **/*.constant.ts
4
- alwaysApply: false
5
- ---
6
-
7
- # Scalar Modeling
8
-
9
- - Define Akan models in `.constant.ts` files with `via` from `akanjs/constant`.
10
- - Use `Int` for whole-number counts and quantities; use `Float` only for values that need decimals.
11
- - Use `ID` for document references and prefer explicit structured fields over `Any` unless the content is genuinely flexible.
12
- - For date defaults, prefer a function such as `default: () => dayjs()` so the value is created at runtime.
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.
59
-
60
- ### Cascade Remove — the `cascade` option
61
-
62
- **The value names the direction, and getting it wrong is a data loss.** The two actions can sit on the same field
63
- shape, so `cascade` never means "related" — it means one of exactly these:
64
-
65
- - `removeRef` — *when I am removed, remove what this field points at.* Declared on the relation the owner holds:
66
- `image: field(File, { cascade: "removeRef" })`, arrays included. Only a relation accepts it; a primitive, a bare
67
- `ID`, and a scalar each fail the class build, because none of them names a document to remove.
68
- - `removeWith` — *when what this field points at is removed, remove me.* Declared on the child's own reference to
69
- its owner, so the owner never learns about its children and a lib model can be extended by an app's. Three forms:
70
- a relation (`agentSession: field(AgentSession, { cascade: "removeWith" })`), an id with `ref`
71
- (`field(ID, { ref: "agentSession", cascade: "removeWith" })`), or a polymorphic id with `refPath`
72
- (`field(ID, { refPath: "parentType", cascade: "removeWith" })`). An array, a Map, `ref` together with `refPath`,
73
- and a field naming no owner each fail the class build.
74
- - **A `refPath` must name an `enumOf` field.** A free-form owner type is unknowable at build time, so every model's
75
- removal would have to sweep the polymorphic table on the chance it is the owner. The enum names the candidates and
76
- the reverse index reaches only them.
77
- - **A cascade goes through the target's service, never its model** — unless it provably makes no difference. The
78
- service path is what runs the target's `_postRemove`, which is where a module puts the side effect the removal has
79
- to carry (`FileService._postRemove` deletes the stored blob there).
80
- - **Bulk is decided at boot, per target model, for both directions.** When the target has no `remove` schema hook, no
81
- `_pre`/`_postRemove` (its own or a lib's), no cascade of its own, and no children, one `removeManyByQuery` leaves
82
- exactly the rows the loop would, so the framework takes it. Adding a `_postRemove` to that model silently flips it
83
- back to one document at a time — the boot log (`info` summary, `verbose` per edge) is the only place that shows.
84
- - **The plan is sealed after every service is live**, so a `listenPost("remove")` registered in `onInit` still counts
85
- and a `removeRef` target the app never mounted fails the boot rather than the first removal. An unmounted
86
- `removeWith` owner fails the boot too; an unmounted `refPath` candidate only warns, since that list spans optional
87
- modules by design.
88
- - **Nothing checks whether another document still references the same target.** `File` in particular is deduped by
89
- `origin`, so two parents can share one row; declaring `removeRef` says the field owns its target exclusively, and
90
- that judgement is the declaring model's to make.
91
- - Removal is soft (`removedAt`) but the storage delete a `_postRemove` performs is not — a cascade is not
92
- restorable, and reviving the owner does not revive what went with it.
93
- - A `removeWith` declaration **auto-creates its index** (`{ removedAt, fk }`, or `{ removedAt, typeKey, fk }` when
94
- polymorphic). Every non-base field lives in the `_doc` JSON column, so the lookup would otherwise scan the table
95
- on every owner removal.
96
- - **Query-level removes fire no hooks and therefore no cascade.** `removeManyByQuery` / `updateManyByQuery`, the generated `remove<Filter>` / `update<Filter>`, and the facade's `removeById` / `updateById` stamp
97
- `removedAt` in one atomic UPDATE, so nothing downstream runs. Remove one document at a time when it cascades.
98
- - Cascades are **idempotent**: `removedAt IS NULL` is ANDed into every query-level write, so a retry after a partial
99
- failure re-stamps nothing. Cycles are cut by a visited set carried down the whole chain, with a depth cap of 16.
@@ -1,13 +0,0 @@
1
- ---
2
- description: Secret and environment file safety conventions
3
- globs: .env,**/.env,**/*.env,infra/**/*,**/*secret*,**/*Secret*,**/*credential*,**/*Credential*
4
- alwaysApply: false
5
- ---
6
-
7
- # Secrets And Env Safety
8
-
9
- - Never print, summarize, commit, or expose real secret values, credentials, tokens, private keys, or `.env` contents.
10
- - If env keys are needed for documentation, list only key names and example placeholders, not live values.
11
- - Preserve the existing env/secret flow through root scripts such as `bun run downloadEnv`, `bun run uploadEnv`, `bun run downloadSecret`, and `bun run uploadSecret`.
12
- - When editing infra env or secret scripts, keep Jenkins and deployment assumptions intact unless the task explicitly asks to change them.
13
- - Treat generated env/secret artifacts as sensitive even when they are not named `.env`.
@@ -1,83 +0,0 @@
1
- ---
2
- description: Akan service, signal, and adapter conventions
3
- globs: apps/**/lib/**/*.{service,signal}.ts,libs/**/lib/**/*.{service,signal}.ts,apps/**/server/**/*.ts,libs/**/server/**/*.ts
4
- alwaysApply: false
5
- ---
6
-
7
- # Service And Signal Conventions
8
-
9
- - Keep domain business operations in `.service.ts` classes built with `serve(...)`.
10
- - Keep execution contracts and triggers in `.signal.ts` classes built with `internal(...)`, `slice(...)`, and `endpoint(...)`.
11
- - Use `Internal` for internal triggers such as init, interval, cron, or queue jobs.
12
- - Use `Slice` for typed data views that feed client stores and zones; keep each slice focused on one purpose.
13
- - Use `Endpoint` for query and mutation contracts exposed to callers.
14
- - Connect external APIs or infrastructure through adapters, usually under `srvkit/`, and inject them into services instead of importing vendor clients directly into domain logic.
15
-
16
- ## Guards And Transports
17
-
18
- - Guards run on both HTTP and websocket calls. Read the caller with `context.get<T>("account")` (`pkgs/akanjs/signal/signalContext.ts`) instead of branching on `getHttpContext()` / `getWebSocketContext()`.
19
- - Slice-level `guards` only reach the generated query/mutation endpoints. A `pubsub`/`message` endpoint is unguarded unless it declares its own `guards` in its signal option.
20
- - A pubsub room is authorized once, at subscribe. When a socket's credential changes the framework re-runs each room's guards and unsubscribes the ones that now fail (`SignalResolver.revalidateWsRooms`), so guards must stay side-effect free and safe to re-run.
21
- - A websocket carries its credential in the handshake snapshot on `ws.data` (`AppWsData`); clients that hold the token in memory send it with `fetch.setJwt(...)`, which forwards an auth frame over the socket.
22
-
23
- ## Authorization Defaults
24
-
25
- - **Every `slice()` takes an explicit `{ guards: {…} }` second argument, and `root:` is always `Admin`.**
26
- - **Every custom `mutation` / `query` / `message` names its own `guards: [...]` array.** Never rely on the slice default. `Public` belongs on a slice `get:`, never on a mutation.
27
- - The acting user arrives via `.with(Self)` / `.with(CurrentUserId)` / `.with(Me)`. Never trust a client-supplied id.
28
- - Services re-check ownership even when a guard already gated the call — two independent gates.
29
- - Guard class shape, fail-closed rules, and the `static name = "User"` requirement live in the srvkit adapters and guards rule.
30
-
31
- ## Service Method Shape
32
-
33
- - Keep methods to a few lines: load → chain → `return await ….save()`. Write `return await` explicitly in tail position; do not "optimize" it away.
34
- - Side effects belong in `override async _preUpdate` / `_postCreate`, not inline. Fire-and-forget is explicitly `void`-ed.
35
- - Order deliberately: load every referenced document, then save, then notify.
36
- - Return `null` / `false` for "not allowed" or "not found" and let the signal decide whether that is an error.
37
- - `XInternal` → `XSlice` → `XEndpoint` are all declared even when empty, and `exec` is a one-liner delegating to the service.
38
-
39
- ## Signal Body Types
40
-
41
- - `.body(...)` / `.param(...)` args accept `ConstantFieldTypeInput` only: scalars, model refs, or `enumOf(...)`.
42
- - Numbers must use `Int` or `Float` — `Number` is rejected (`pkgs/akanjs/signal/endpointInfo.ts`).
43
- - `Upload` is valid only inside a mutation flagged for file upload: `mutation([cnst.File], { fileUpload: true }).body("files", [Upload])` (see `libs/shared/lib/file/file.signal.ts`). It is not a model field type.
44
-
45
- ## Reserved Endpoint Names
46
-
47
- - Auto-generated CRUD endpoints (e.g. `create<Model>`, `update<Model>`, `remove<Model>`) already exist for every model. Do not declare an `Endpoint`/`Slice` with a name that collides with them.
48
- - The service layer surfaces such a collision as a typecheck error, but the signal layer can pass sync/typecheck/build and fail only at runtime — so treat name collisions as errors regardless of whether the build is green.
49
-
50
- ## Slices, Queries, and Hydration
51
-
52
- - A slice's `exec` returns a `QueryOf` (an opaque query descriptor, `pkgs/akanjs/constant/types.ts`); you **cannot** chain `.sort()`/`.limit()` on it.
53
- - Apply ordering/paging via the store `init` fetch option instead: `initX(..., { sort, page, limit })` (`pkgs/akanjs/fetch/fetchType/sliceFetch.type.ts`).
54
- - Generated list accessors like `listBy(...)` return `Promise<Doc[]>`. For a chainable builder (`.sort().skip().limit().select()`) use the model facade's `findMany`/`findOne` (`FindManyChain`, `pkgs/akanjs/document/into.ts`).
55
- - **Hydrated vs raw:** server queries return hydrated `cnst.<Model>` instances (with `set`/`save`/`refresh`); client fetch results are raw `GetStateObject` plain data (functions stripped, `pkgs/akanjs/base/types.ts`).
56
-
57
- ## Text Search In A Filter — `q.search()`
58
-
59
- - Text search is a filter query node like any other: `bySearch: filter().arg("text", String).query((text, q) =>
60
- q.search(text, { prefix: true }))`. The generated `listBySearch` / `countBySearch` / `queryBySearch` /
61
- `insightBySearch` come for free — you do **not** need a slice to make search usable.
62
- - **Only add a search slice when the model's data is safe to enumerate.** A filter is server-side; a slice is a
63
- client-callable endpoint, so on a model whose slice `get:` is `Public` a search slice hands anyone a way to walk the
64
- table. Leave that decision to the mounting app.
65
- - `q.search()` compiles to a JOIN, not a WHERE fragment, so it **must sit at an AND position**. Nesting it under
66
- `q.any()` or `q.not()` throws, and it is rejected in `updateOneByQuery` / `updateManyByQuery` — a query-level write
67
- takes no join, so ignoring the node would silently widen the write to every other matching row.
68
- - Blank or whitespace-only input matches **nothing**. Never "fix" that into a passthrough: a passthrough turns a
69
- search endpoint into a full listing.
70
- - Order by relevance with the built-in `relevance` sort key. It is an empty sort map, which the store reads as
71
- "unspecified": score order when a search join is present, `createdAt` descending otherwise. That fallback is the
72
- compiler's own, not a model-defined default — redefining `latest` on the model does not change it.
73
- - **A slice endpoint never reaches "unspecified".** The resolver fills `latest` before the query is built, so a
74
- client asking for the score order has to name `relevance`; leaving `sort` off gets `latest`, not relevance.
75
- - Scope a search with `columns` (`q.search(text, { columns: ["title"] })`) and re-weight with `weights`, a tuple of
76
- finite numbers positional over `["title", "desc", "tag", "filter"]`.
77
-
78
- ## Service / Signal Injection
79
-
80
- - Injected dependencies resolve by field-name convention: a field named `<refName>Service` resolves to the service registered under `<refName>`, and `<refName>Signal` likewise (`pkgs/akanjs/service/injectInfo.ts`).
81
- - The `Service`/`Signal` suffix is required — the injector strips it to derive the registry lookup key. Name the field after the target refName plus the suffix, not arbitrarily.
82
- - Preference order inside a service: `service<srv.XService>()` for another module's service · `plug(AdapterClass)` or `plug(StorageAdaptorRole)` for an adapter · `use<T>()` only to reach an `option.ts`-registered legacy singleton · `env(...)` for config.
83
- - New adapters are `adapt("name" as const, ({ use, env, plug, memory }) => ({…}))` classes in `srvkit/` that self-register — do not add them to `lib/option.ts`. See the srvkit adapters and guards rule.
@@ -1,50 +0,0 @@
1
- ---
2
- description: srvkit adapter (adapt/plug), guard, and error-handling conventions
3
- globs: apps/**/srvkit/**/*.ts,libs/**/srvkit/**/*.ts
4
- alwaysApply: false
5
- ---
6
-
7
- # Adapters — `adapt()` And `plug()`
8
-
9
- An injected singleton is an `adapt()` class in `srvkit/`. Write new adapters this way.
10
-
11
- ```ts
12
- export class AdminNoti extends adapt("adminNoti" as const, ({ use, env, plug, memory }) => ({
13
- discordApi: use<DiscordApi>(),
14
- workspaceRoot: env(() => `~/build/${getEnv().environment}`),
15
- masterHost: plug(MasterHost),
16
- tokenMap: memory(Map, { of: String }),
17
- })) {}
18
- ```
19
-
20
- - Inject it with `plug(TheClass)` from a service or from another adapter. Destructure only the injectors you use, and write the registration key `as const`.
21
- - **Do not register an `adapt()` class in `lib/option.ts`.** It self-registers, and `plug(Class)` uses the class itself as the token. `option.ts` is now only for legacy constructor-style adapters and for widening the options type.
22
- - `this.logger` is provided; never construct a `Logger` inside an `adapt()` class. Lifecycle work goes in `override async onInit()`.
23
- - `#private` is the house style here — the `#private` lint ban covers only `*.constant.ts`, `*.document.ts`, `*.service.ts`, and `*.store.ts`.
24
- - **`adapt()` is for singletons only.** A per-use value object stays a plain class you `new` at the call site. Ask whether there is exactly one per process that a service needs injected; if not, it is a plain class.
25
- - **Legacy shape — recognise it, do not copy it.** Plain classes with `constructor(options: XOptions)`, registered in `lib/option.ts` as `options.x ? new XApi(options.x) : null` and injected with `use<T>()`, still work. Migrate one to `adapt()` only when you are already changing it.
26
- - Preference order inside a service: `service<srv.XService>()` for another module's service · `plug(AdapterClass)` or `plug(StorageAdaptorRole)` for an adapter · `use<T>()` only to reach an `option.ts`-registered legacy singleton · `env(...)` for config.
27
-
28
- Conventions that hold for both shapes:
29
-
30
- - Route every remote call through one private `#api<T>(path, init?)` with `signal: AbortSignal.timeout(20_000)`.
31
- - Paginate with `for (let page = 1; ; page += 1)` broken by `if (pageItems.length < 100) break;`.
32
- - Resolve secrets as `process.env.X ?? options.x ?? deterministicGenerator(...)` **inside a function**, never at module scope.
33
- - Extend a function by appending an optional trailing parameter with a default, never by changing arity.
34
- - Parameters: up to three required primitives positional; optional flags in a trailing `{ … } = {}`; four or more parameters, or any two same-typed strings, in one named destructured object.
35
- - Release locks in `finally`. Load heavy optional dependencies through a module-level memoized promise (`sharpLoad ??= import("sharp")`).
36
-
37
- # Guards (`srvkit/guards.ts`)
38
-
39
- - Resource guards are `Can<Verb><Model>` classes that `implements Guard` with an `async canPass(context)`.
40
- - They **fail closed**: no resource named ⇒ `false`; a load that throws ⇒ `logger.warn` then `false`. Admin bypass goes first.
41
- - Keep `static name = "User";` on guard classes. `fetch` serializes guard names and the API explorer filters on them; it looks like dead code, and deleting it breaks the UI. Comment it so the next reader knows.
42
- - Guards ship with the library that owns the model and are imported by its own signals through the package path, so a mounting app inherits authorization and cannot forget it.
43
- - Services re-check ownership even when a guard already gated the call — two independent gates.
44
- - This file earns real comments: explain what would leak without each guard.
45
-
46
- # Error Placement
47
-
48
- - State-machine preconditions throw in `document.ts`; cross-document rules throw in `service.ts`; request-level policy belongs in signal guards.
49
- - Best-effort code returns a sentinel (`null`, `undefined`, `[0, 0]`, `{}`). There are no Result/Either wrappers.
50
- - `try/catch` is rare and always converts an exception into a decision, never swallows one. Guards catch → `logger.warn` → `return false`; adapters catch → `logger.error` → `return null`; UI uses `try/finally` to reset a spinner. A bodyless `catch {}` is acceptable only with a one-line reason.
@@ -1,59 +0,0 @@
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.
@@ -1,16 +0,0 @@
1
- ---
2
- description: TypeScript and import conventions
3
- globs: **/*.{ts,tsx}
4
- alwaysApply: false
5
- ---
6
-
7
- # TypeScript And Imports
8
-
9
- - Use Bun and ESM assumptions from the root `tsconfig.json`.
10
- - Prefer path aliases over deep relative imports when crossing package boundaries.
11
- - Use `akanjs/*` for framework facets, `@apps/*` for apps, `@libs/*` for shared libs, and `@contract/*` for contract code.
12
- - Respect existing client/server entrypoints such as `@libs/shared/client`, `@libs/shared/server`, `@apps/myapp/client`, and `@apps/myapp/server`.
13
- - Let Biome organize imports instead of manually reshuffling unrelated imports.
14
- - Namespace the generated barrels in backend `.ts` files: `import * as cnst from "../cnst"`, `* as db`, `* as srv`. Use `import type * as srv` in services so the runtime graph stays lazy, and a value import in signals.
15
- - In `.tsx` files use one flat named import from the package client path (`import { cnst, fetch, st, Task, usePage } from "@apps/myapp/client"`) — never a relative `../` import.
16
- - Never import a third-party package from a page, a barrel, or a module file; re-export it through a one-line shim in `base/`, `webkit/`, or `ui/` first.