@akanjs/devkit 3.3.0-rc.8 → 3.3.0-rc.80

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 (356) hide show
  1. package/DEV_RUNTIME_KNOBS.md +1 -1
  2. package/README.ko.md +7 -1
  3. package/README.md +7 -1
  4. package/akanApp/akanApp.host.test.ts +3 -1
  5. package/akanApp/akanApp.host.ts +26 -2
  6. package/akanApp/akanApp.host.wiring.test.ts +111 -0
  7. package/akanApp/devHostPolicy.ts +5 -0
  8. package/akanApp/devMetadataRestart.ts +93 -0
  9. package/akanApp/devRecycler.test.ts +2 -0
  10. package/akanApp/devRecycler.ts +9 -0
  11. package/akanConfig/akanBin.ts +4 -0
  12. package/akanConfig/akanConfig.test.ts +307 -18
  13. package/akanConfig/akanConfig.ts +104 -210
  14. package/akanConfig/akanPreview.test.ts +28 -0
  15. package/akanConfig/akanPreview.ts +24 -0
  16. package/akanConfig/akanWorkers.test.ts +73 -0
  17. package/akanConfig/akanWorkers.ts +61 -0
  18. package/akanConfig/desktopServerConfig.ts +96 -0
  19. package/akanConfig/dockerImage.ts +233 -0
  20. package/akanConfig/index.ts +3 -0
  21. package/akanConfig/nativeFileSettings.ts +33 -0
  22. package/akanConfig/types.ts +4 -0
  23. package/app/appBin.test.ts +63 -0
  24. package/app/appBin.ts +50 -0
  25. package/app/applicationBuildReporter.test.ts +51 -1
  26. package/app/applicationBuildReporter.ts +6 -1
  27. package/app/applicationBuildRunner.test.ts +436 -5
  28. package/app/applicationBuildRunner.ts +237 -37
  29. package/app/clientServerBoundary.test.ts +115 -0
  30. package/app/clientServerBoundary.ts +89 -0
  31. package/app/dictionarySizes.test.ts +40 -0
  32. package/app/dictionarySizes.ts +95 -0
  33. package/app/routeFilesReport.test.ts +59 -0
  34. package/app/routeFilesReport.ts +46 -0
  35. package/app/routeJsBudget.ts +18 -4
  36. package/artifact/implicitRootLayout.test.ts +19 -0
  37. package/artifact/implicitRootLayout.ts +16 -2
  38. package/artifact/implicitRootLayoutRender.test.tsx +7 -2
  39. package/artifact/storeBootstrap.test.ts +28 -0
  40. package/artifact/storeBootstrap.ts +64 -8
  41. package/biome.base.json +7 -5
  42. package/codeAgent/index.ts +1 -34
  43. package/codeAgent/skills/akan-agent/SKILL.md +2 -2
  44. package/codeAgent/skills/akan-debug/SKILL.md +11 -5
  45. package/codeAgent/skills/akan-deps/SKILL.md +10 -3
  46. package/codeAgent/skills/akan-err/SKILL.md +13 -8
  47. package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
  48. package/codeAgent/skills/akan-module/SKILL.md +2 -2
  49. package/codeAgent/skills/akan-page/SKILL.md +65 -30
  50. package/codeAgent/skills/akan-query/SKILL.md +13 -20
  51. package/codeAgent/skills/akan-runtime/SKILL.md +21 -1
  52. package/codeAgent/skills/akan-service/SKILL.md +21 -20
  53. package/codeAgent/skills/akan-transport/SKILL.md +5 -14
  54. package/codeAgent/skills/akan-ui/SKILL.md +16 -21
  55. package/codeAgent/skills/akan-validate/SKILL.md +8 -2
  56. package/commandDecorators/command.ts +28 -12
  57. package/commandDecorators/commandBuilder.ts +8 -1
  58. package/commandDecorators/commandDecorators.test.ts +70 -3
  59. package/commandDecorators/helpFormatter.ts +14 -12
  60. package/context/akanContext.ts +2 -0
  61. package/csrE2e/devHmrLatency.e2e.test.ts +1 -1
  62. package/csrE2e/ssrRegistry.e2e.test.ts +108 -22
  63. package/docs/apiReference.test.ts +25 -0
  64. package/docs/apiReference.ts +38 -5
  65. package/docs/declarationReader.ts +30 -0
  66. package/executors/appExecutor.ts +26 -12
  67. package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
  68. package/executors/clientRuntimeKeys.fixture.json +393 -0
  69. package/executors/clientRuntimeKeys.test.ts +1690 -0
  70. package/executors/executor.ts +14 -6
  71. package/executors/executors.test.ts +155 -1
  72. package/executors/pkgExecutor.ts +2 -1
  73. package/executors/sysExecutor.ts +112 -8
  74. package/executors/workspaceExecutor.ts +7 -4
  75. package/frontendBuild/allRoutesBuilder.ts +99 -7
  76. package/frontendBuild/autoImportSync.ts +3 -2
  77. package/frontendBuild/buildRouteClient.test.ts +684 -6
  78. package/frontendBuild/clientBuildTypes.ts +26 -0
  79. package/frontendBuild/clientEntriesBundler.test.ts +79 -0
  80. package/frontendBuild/clientEntriesBundler.ts +70 -1
  81. package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
  82. package/frontendBuild/clientEntryDiscovery.ts +134 -12
  83. package/frontendBuild/clientEntryGroups.test.ts +77 -0
  84. package/frontendBuild/clientEntryGroups.ts +61 -0
  85. package/frontendBuild/csrDevArtifactWriter.ts +2 -2
  86. package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
  87. package/frontendBuild/csrDevModuleCompiler.ts +44 -8
  88. package/frontendBuild/csrDevPatcher.test.ts +4 -5
  89. package/frontendBuild/csrDevPatcher.ts +37 -11
  90. package/frontendBuild/csrDevTypes.ts +9 -0
  91. package/frontendBuild/cssCandidateCache.test.ts +12 -0
  92. package/frontendBuild/cssCandidateCache.ts +5 -3
  93. package/frontendBuild/cssCompiler.test.ts +14 -0
  94. package/frontendBuild/devBarrelImports.test.ts +124 -0
  95. package/frontendBuild/devBarrelImports.ts +81 -21
  96. package/frontendBuild/devChangePlanner.ts +0 -1
  97. package/frontendBuild/devRegistryBundler.ts +4 -2
  98. package/frontendBuild/devRouteRuntime.test.ts +492 -0
  99. package/frontendBuild/devRouteRuntime.ts +167 -0
  100. package/frontendBuild/dictionaryAssetBuilder.test.ts +408 -0
  101. package/frontendBuild/dictionaryAssetBuilder.ts +185 -17
  102. package/frontendBuild/dictionaryConstants.ts +136 -0
  103. package/frontendBuild/dictionaryOwnParts.ts +88 -0
  104. package/frontendBuild/dictionaryPackState.ts +131 -0
  105. package/frontendBuild/dictionaryPacking.test.ts +207 -0
  106. package/frontendBuild/dictionaryPacking.ts +160 -0
  107. package/frontendBuild/dictionaryRoutes.test.ts +251 -0
  108. package/frontendBuild/dictionaryRoutes.ts +227 -0
  109. package/frontendBuild/frontendBuild.test.ts +5 -3
  110. package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
  111. package/frontendBuild/pagesBundleBuilder.ts +78 -2
  112. package/frontendBuild/precompressArtifacts.test.ts +22 -0
  113. package/frontendBuild/precompressArtifacts.ts +34 -8
  114. package/frontendBuild/registryMetadataFingerprint.ts +3 -3
  115. package/frontendBuild/renderedEntries.ts +144 -0
  116. package/frontendBuild/routeClientBuilder.ts +407 -43
  117. package/frontendBuild/routeHandoffs.test.ts +155 -0
  118. package/frontendBuild/routeHandoffs.ts +117 -0
  119. package/frontendBuild/routeModulePreloads.test.ts +32 -0
  120. package/frontendBuild/routeModulePreloads.ts +20 -11
  121. package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
  122. package/frontendBuild/routeRuntimeCheck.ts +248 -0
  123. package/frontendBuild/routeRuntimePays.test.ts +143 -0
  124. package/frontendBuild/routeRuntimePays.ts +117 -0
  125. package/frontendBuild/ssrBaseArtifactBuilder.ts +30 -35
  126. package/frontendBuild/ssrDevBundler.test.ts +150 -1
  127. package/frontendBuild/ssrDevBundler.ts +66 -11
  128. package/frontendBuild/vendorFileImports.test.ts +254 -0
  129. package/frontendBuild/vendorFileImports.ts +163 -0
  130. package/frontendBuild/vendorNarrowing.test.ts +47 -3
  131. package/frontendBuild/vendorNarrowing.ts +38 -2
  132. package/frontendBuild/vendorSpecifiers.ts +2 -0
  133. package/frontendBuild/workerChunks.ts +61 -0
  134. package/guideline/agentAssets.ts +1 -1
  135. package/incrementalBuilder/buildBatch.proc.ts +27 -1
  136. package/incrementalBuilder/buildBatchProtocol.ts +1 -0
  137. package/incrementalBuilder/builderWatch.ts +11 -1
  138. package/incrementalBuilder/incrementalBuilder.proc.test.ts +159 -0
  139. package/incrementalBuilder/incrementalBuilder.proc.ts +31 -3
  140. package/incrementalBuilder/pendingMetadata.test.ts +27 -0
  141. package/incrementalBuilder/pendingMetadata.ts +19 -0
  142. package/integration/devResourceProbe.ts +14 -0
  143. package/integration/devStability.integration.test.ts +46 -21
  144. package/integration/renderAdmissionSoak.ts +6 -0
  145. package/integration/ssrMemoryProbe.ts +5 -0
  146. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  147. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  148. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  149. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  150. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  151. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  152. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  153. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  154. package/lint/biomeBase.test.ts +50 -3
  155. package/lint/biomeBase.ts +1 -1
  156. package/lint/biomeCheck.test.ts +162 -0
  157. package/lint/biomeCheck.ts +131 -0
  158. package/lint/linter.test.ts +16 -11
  159. package/lint/no-arbitrary-color.grit +5 -0
  160. package/lint/no-conditional-st-hook.grit +5 -1
  161. package/lint/no-daisyui-legacy-class.grit +8 -0
  162. package/lint/no-document-cookie.grit +3 -0
  163. package/lint/no-inline-color.grit +10 -2
  164. package/lint/no-oversized-list-limit.grit +2 -0
  165. package/lint/no-raw-palette-class.grit +7 -0
  166. package/lint/no-unpublished-form-setter.grit +2 -0
  167. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  168. package/lint/no-web-storage.grit +3 -0
  169. package/lint/withheldEnvFile.ts +17 -0
  170. package/mobile/desktopBin.ts +2 -2
  171. package/mobile/desktopServerStage.test.ts +18 -3
  172. package/mobile/desktopServerStage.ts +7 -2
  173. package/mobile/nativeApp.test.ts +13 -5
  174. package/mobile/nativeApp.ts +9 -4
  175. package/mobile/nativeConfig.test.ts +17 -1
  176. package/mobile/nativeConfig.ts +11 -6
  177. package/mobile/nativePublicEnv.ts +1 -1
  178. package/mobile/serverBundleSecrets.ts +43 -0
  179. package/package.json +11 -12
  180. package/packageExports.test.ts +3 -2
  181. package/preview/PreviewView.ts +43 -6
  182. package/preview/previewView.test.ts +31 -0
  183. package/quality/dictionaryKeys.test.ts +356 -0
  184. package/quality/dictionaryKeys.ts +488 -0
  185. package/quality/objectImportReport.test.ts +36 -0
  186. package/quality/objectImportReport.ts +105 -0
  187. package/quality/qualityScanner.ts +1 -1
  188. package/quality/routeRuntimeReport.test.ts +91 -0
  189. package/quality/routeRuntimeReport.ts +121 -0
  190. package/quality/runtimeConstantFacts.ts +71 -0
  191. package/quality/runtimeConstantGraph.ts +123 -0
  192. package/quality/runtimeConstantReads.ts +116 -0
  193. package/quality/runtimeImports.test.ts +190 -0
  194. package/quality/runtimeImports.ts +233 -0
  195. package/quality/runtimeKeyNames.ts +46 -0
  196. package/quality/runtimeLexicalScope.ts +132 -0
  197. package/quality/runtimeMarkerReach.test.ts +84 -0
  198. package/quality/runtimeMarkerReach.ts +255 -0
  199. package/quality/runtimeModuleFacts.ts +290 -0
  200. package/quality/runtimeNameTable.test.ts +172 -0
  201. package/quality/runtimeNameTable.ts +477 -0
  202. package/quality/runtimeScopeReport.test.ts +123 -0
  203. package/quality/runtimeScopeReport.ts +167 -0
  204. package/quality/runtimeSliceKey.ts +269 -0
  205. package/quality/runtimeSyntax.ts +133 -0
  206. package/quality/runtimeTable.fixture.ts +189 -0
  207. package/quality/runtimeUse.test.ts +737 -0
  208. package/quality/runtimeUse.ts +696 -0
  209. package/quality/runtimeUseReadable.test.ts +393 -0
  210. package/quality/ssrScanner.test.ts +13 -0
  211. package/quality/ssrScanner.ts +1 -1
  212. package/quality/translatorBindings.ts +187 -0
  213. package/test/fakeTerminal.ts +45 -0
  214. package/test/secretEnvFixture.ts +134 -0
  215. package/test/testHelpers.ts +11 -0
  216. package/transforms/barrelAnalyzer.ts +24 -2
  217. package/transforms/barrelImportsPlugin.ts +121 -32
  218. package/transforms/exportReach.test.ts +162 -0
  219. package/transforms/exportReach.ts +308 -0
  220. package/transforms/frameworkObjects.fixture.tsx +58 -0
  221. package/transforms/frameworkObjects.test.ts +54 -0
  222. package/transforms/modelReference.test.ts +196 -0
  223. package/transforms/modelReference.ts +39 -0
  224. package/transforms/moduleParts.test.ts +225 -0
  225. package/transforms/moduleParts.ts +418 -0
  226. package/transforms/objectImportEdits.ts +150 -0
  227. package/transforms/objectMemberImports.test.ts +633 -0
  228. package/transforms/objectMemberImports.ts +571 -0
  229. package/transforms/objectMemberLookup.ts +150 -0
  230. package/transforms/objectModule.test.ts +307 -0
  231. package/transforms/objectModule.ts +482 -0
  232. package/transforms/objectModuleAnalyzer.ts +104 -0
  233. package/transforms/partImports.test.ts +76 -0
  234. package/transforms/partImports.ts +110 -0
  235. package/transforms/partModules.test.ts +187 -0
  236. package/transforms/partModules.ts +90 -0
  237. package/transforms/partPurity.ts +124 -0
  238. package/transforms/reactIconImports.test.ts +231 -0
  239. package/transforms/reactIconImports.ts +325 -0
  240. package/transforms/routeConstants.ts +122 -0
  241. package/transforms/routeRuntime.test.ts +835 -0
  242. package/transforms/routeRuntime.ts +703 -0
  243. package/transforms/routeRuntimeEdits.ts +92 -0
  244. package/transforms/routeRuntimeGraph.ts +66 -0
  245. package/transforms/routeRuntimePlan.ts +244 -0
  246. package/transforms/secretEnvDeclaration.test.ts +211 -0
  247. package/transforms/secretEnvDeclaration.ts +219 -0
  248. package/transforms/secretEnvFile.test.ts +117 -0
  249. package/transforms/secretEnvFile.ts +113 -0
  250. package/transforms/secretEnvName.test.ts +54 -0
  251. package/transforms/secretEnvName.ts +29 -0
  252. package/transforms/secretEnvSource.test.ts +152 -0
  253. package/transforms/secretEnvSource.ts +197 -0
  254. package/transforms/serverEnvEvaluationError.ts +11 -0
  255. package/transforms/serverEnvPlugin.test.ts +155 -1
  256. package/transforms/serverEnvPlugin.ts +123 -19
  257. package/transforms/serverEnvProfile.test.ts +129 -2
  258. package/transforms/serverEnvProfile.ts +133 -43
  259. package/transforms/serverEnvSecrets.test.ts +268 -0
  260. package/transforms/signalDescriptors.test.ts +280 -0
  261. package/transforms/signalDescriptors.ts +227 -0
  262. package/transforms/thisFreeExports.ts +87 -0
  263. package/transforms/transforms.test.ts +177 -0
  264. package/transforms/tsconfigPackageResolver.test.ts +1 -0
  265. package/tunnel/createTunnel.ts +5 -1
  266. package/tunnel/ssh2Module.test.ts +37 -0
  267. package/tunnel/ssh2Module.ts +28 -0
  268. package/tunnel/sshTunnel.ts +4 -2
  269. package/typecheck/projectTypecheck.test.ts +32 -1
  270. package/typecheck/projectTypecheck.ts +3 -3
  271. package/typecheck/typeChecker.test.ts +49 -0
  272. package/typecheck/typeChecker.ts +9 -7
  273. package/typecheck/withheldDiagnostics.ts +41 -0
  274. package/util/devInstallCommand.ts +7 -0
  275. package/util/jsonFormatter.test.ts +13 -9
  276. package/workflow/executor.ts +6 -2
  277. package/workflow/index.ts +1 -0
  278. package/workflow/plan.ts +36 -7
  279. package/workflow/types.ts +1 -1
  280. package/workflow/uiTarget.ts +50 -0
  281. package/workspace/envSeed.test.ts +30 -1
  282. package/workspace/envSeed.ts +30 -1
  283. package/workspace/mainCheckout.test.ts +55 -0
  284. package/workspace/mainCheckout.ts +38 -0
  285. package/workspace/scanInfo.test.ts +39 -0
  286. package/workspace/scanInfo.ts +55 -6
  287. package/workspace/slicePlanner.ts +2 -1
  288. package/workspace/workspaceLayout.test.ts +22 -1
  289. package/workspace/workspaceLayout.ts +3 -3
  290. package/CHANGELOG.md +0 -2903
  291. package/codeAgent/agent/AkanCodeCompaction.ts +0 -49
  292. package/codeAgent/agent/AkanCodeServices.ts +0 -122
  293. package/codeAgent/agent/AkanContextFiles.ts +0 -94
  294. package/codeAgent/agent/CodeAgent.ts +0 -626
  295. package/codeAgent/agent/CodeAgentAllowed.ts +0 -35
  296. package/codeAgent/agent/CodeAgentAsks.ts +0 -66
  297. package/codeAgent/agent/CodeAgentCommandLine.ts +0 -372
  298. package/codeAgent/agent/CodeAgentEventMapper.ts +0 -225
  299. package/codeAgent/agent/CodeAgentGate.ts +0 -258
  300. package/codeAgent/agent/CodeAgentProxy.ts +0 -83
  301. package/codeAgent/agent/CodeAgentRpcHost.ts +0 -109
  302. package/codeAgent/agent/CodeAgentRpcListener.ts +0 -195
  303. package/codeAgent/agent/CodeAgentStreamPrinter.ts +0 -86
  304. package/codeAgent/agent/CodeAgentSuspended.ts +0 -85
  305. package/codeAgent/agent/CodeAgentUi.ts +0 -47
  306. package/codeAgent/agent/CodeMailbox.ts +0 -148
  307. package/codeAgent/agent/CodeSessionFork.ts +0 -56
  308. package/codeAgent/agent/CodeSessionIndex.ts +0 -78
  309. package/codeAgent/agent/SubagentPool.ts +0 -219
  310. package/codeAgent/agent/WorkspaceTrust.ts +0 -200
  311. package/codeAgent/agent/akanCodeCompaction.test.ts +0 -36
  312. package/codeAgent/agent/akanCodeModel.ts +0 -47
  313. package/codeAgent/agent/akanCodeServices.test.ts +0 -54
  314. package/codeAgent/agent/akanContextFiles.test.ts +0 -116
  315. package/codeAgent/agent/akanSystemPrompt.ts +0 -50
  316. package/codeAgent/agent/codeAgent.test.ts +0 -337
  317. package/codeAgent/agent/codeAgentCommandLine.test.ts +0 -212
  318. package/codeAgent/agent/codeAgentContract.test.ts +0 -755
  319. package/codeAgent/agent/codeAgentHosts.ts +0 -30
  320. package/codeAgent/agent/codeAgentProxy.test.ts +0 -126
  321. package/codeAgent/agent/codeAgentRpcListener.test.ts +0 -215
  322. package/codeAgent/agent/codeAgentSuspended.test.ts +0 -47
  323. package/codeAgent/agent/codeMailbox.test.ts +0 -76
  324. package/codeAgent/agent/codeSessionFork.test.ts +0 -58
  325. package/codeAgent/agent/codeSessionIndex.test.ts +0 -77
  326. package/codeAgent/agent/consoleToStderr.ts +0 -8
  327. package/codeAgent/agent/jsonLines.ts +0 -29
  328. package/codeAgent/agent/stringArg.ts +0 -5
  329. package/codeAgent/feedback/DevLogFeedback.ts +0 -82
  330. package/codeAgent/feedback/PreviewFeedback.ts +0 -46
  331. package/codeAgent/feedback/TurnFeedback.ts +0 -98
  332. package/codeAgent/feedback/VerifyFeedback.ts +0 -39
  333. package/codeAgent/tools/AkanCli.ts +0 -51
  334. package/codeAgent/tools/AkanCodePlugins.ts +0 -142
  335. package/codeAgent/tools/AkanEditScope.ts +0 -53
  336. package/codeAgent/tools/AkanEnvKeys.ts +0 -50
  337. package/codeAgent/tools/AkanToolPack.ts +0 -86
  338. package/codeAgent/tools/AkanVerifier.ts +0 -30
  339. package/codeAgent/tools/AskToolPack.ts +0 -99
  340. package/codeAgent/tools/DeepSeekWeb.ts +0 -127
  341. package/codeAgent/tools/MailToolPack.ts +0 -76
  342. package/codeAgent/tools/McpClient.ts +0 -209
  343. package/codeAgent/tools/McpOAuth.ts +0 -233
  344. package/codeAgent/tools/McpOAuthLoopback.ts +0 -64
  345. package/codeAgent/tools/McpServerConfig.ts +0 -131
  346. package/codeAgent/tools/McpSignIn.ts +0 -158
  347. package/codeAgent/tools/McpTokenStore.ts +0 -128
  348. package/codeAgent/tools/McpToolPack.ts +0 -206
  349. package/codeAgent/tools/SessionToolPack.ts +0 -91
  350. package/codeAgent/tools/WebToolPack.ts +0 -315
  351. package/codeAgent/tools/akanCodePlugins.test.ts +0 -954
  352. package/codeAgent/tools/askToolPack.test.ts +0 -116
  353. package/codeAgent/tools/deepSeekWeb.test.ts +0 -113
  354. package/codeAgent/tools/mcpOAuth.test.ts +0 -648
  355. package/codeAgent/tools/mcpServerConfig.test.ts +0 -341
  356. package/piDependencyPins.test.ts +0 -45
@@ -1,35 +1,2 @@
1
- // Importing this barrel loads the engine (~122MiB resident); a host needing cheap pieces imports the owning module.
2
- // agent/consoleToStderr is deliberately absent: it takes over globalThis.console, so an RPC entry imports it first.
3
-
4
- export * from "../preview";
5
- export * from "./agent/AkanCodeCompaction";
6
- export * from "./agent/AkanCodeServices";
7
- export * from "./agent/akanCodeModel";
1
+ export * from "./agent/AkanCodeEnv";
8
2
  export * from "./agent/akanCodePaths";
9
- export * from "./agent/akanSystemPrompt";
10
- export * from "./agent/CodeAgent";
11
- export * from "./agent/CodeAgentAsks";
12
- export * from "./agent/CodeAgentEventMapper";
13
- export * from "./agent/CodeAgentGate";
14
- export * from "./agent/CodeAgentRpcHost";
15
- export * from "./agent/CodeAgentStreamPrinter";
16
- export * from "./agent/CodeAgentUi";
17
- export * from "./agent/CodeMailbox";
18
- export * from "./agent/CodeSessionFork";
19
- export * from "./agent/CodeSessionIndex";
20
- export * from "./agent/SubagentPool";
21
- export * from "./feedback/DevLogFeedback";
22
- export * from "./feedback/PreviewFeedback";
23
- export * from "./feedback/TurnFeedback";
24
- export * from "./feedback/VerifyFeedback";
25
- export * from "./tools/AkanCli";
26
- export * from "./tools/AkanCodePlugins";
27
- export * from "./tools/AkanEditScope";
28
- export * from "./tools/AkanEnvKeys";
29
- export * from "./tools/AkanToolPack";
30
- export * from "./tools/AkanVerifier";
31
- export * from "./tools/MailToolPack";
32
- export * from "./tools/McpClient";
33
- export * from "./tools/McpToolPack";
34
- export * from "./tools/SessionToolPack";
35
- export * from "./tools/WebToolPack";
@@ -42,8 +42,8 @@ agent nothing, and only the current page's declarations are live.
42
42
  param or a list row's title included, is left out and read with `readState` or `readScreen`, so instructions say
43
43
  "read `searchParams`", never "the query is in the route context". A search param rides inline when a store
44
44
  declares its key with `search()`; of the others at most four short ones do. A zone's `label` and a value
45
- published with `st.expose`, `st.useState` or `useAgentResource` ride whole: publish an id or a count there, never
46
- text a user wrote.
45
+ published with `st.expose`, `st.useState` or `useAgentResource` follow the same rule: free text there is read
46
+ with `readScreen` of the zone or `readState(name)`.
47
47
  - A tool value is capped at 20,000 characters.
48
48
  - Route guidance is `<Agent.Guide instructions="…" />`; model-facing text is English.
49
49
 
@@ -14,7 +14,7 @@ the server errors logged meanwhile, console errors and warnings, and layout smel
14
14
  - It uses the dev server that answers for this app and checkout. With none, it starts one for the run and
15
15
  stops it after; `--keep` leaves it up for the next preview. It never starts a second server beside a
16
16
  running one.
17
- - Paths are comma-separated (`akan preview <app> /board,/board/new`) and get the default locale when they lack
17
+ - Paths are space- or comma-separated (`akan preview <app> /board /board/new`) and get the default locale when they lack
18
18
  one, unless the app sets `localePrefix: "as-needed"` and `--csr` is off. What the server answers outside a
19
19
  locale opens as written, with no locale and no CSR boot query: a `/_akan` route such as Studio
20
20
  (`/_akan/studio?view=runtime`), a route under the API prefix, `/__csr`, `/__rsc`, `/.well-known`,
@@ -24,11 +24,17 @@ the server errors logged meanwhile, console errors and warnings, and layout smel
24
24
  opens its path and query the same way, always on the app's dev server, with a note when it names another
25
25
  server: use it for an endpoint mounted outside the API prefix. A page `--changed` finds opens as a page even at
26
26
  a server route's path, under the same locale rule, and `/en` and `/en/` open once.
27
- `--changed` adds the pages your uncommitted page and layout edits reach. A dynamic route needs a concrete
28
- path (`/memo/1`); `akan context --app <app>` lists every route with its params and search names.
27
+ `--changed` adds the pages your uncommitted page and layout edits reach. A dynamic route opens at the first
28
+ `preview.examples` path of `akan.config.ts` that fits it (`["/memo/1"]`, no locale), else type a concrete
29
+ one; `akan context --app <app>` lists every route with its params and search names.
30
+ - A page behind a sign-in opens through `preview.signIn({ origin, as })` in `akan.config.ts`, called once per
31
+ run: it returns the sign-in `Response` (its `Set-Cookie` pairs become every page's cookies) or the cookies by
32
+ name, and reads the account from `process.env`. `--as <name>` reaches it as `as`; `--anonymous` skips it.
33
+ With none declared a guarded page shows its redirect: add it, or say "not opened signed in".
29
34
  - The viewport is a 390x844 phone; `--desktop` is 1280x800. `--csr` loads each page in the CSR boot the native
30
- shells load. `--screenshot` saves a PNG per page under `local/apps/<app>/runtime/preview/`, for a model
31
- that reads images. `--format json` gives the same report as data.
35
+ shells load. `--screenshot` saves a PNG per page under `local/apps/<app>/runtime/preview/`. `--format json`
36
+ gives the same report as data. `--wait-for <selector>` holds a page that draws after its first client read
37
+ until the selector matches, and fails it at `--timeout`.
32
38
 
33
39
  ### Which platforms that covers
34
40
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: akan-deps
3
- description: "Fix an import, dependency, or barrel problem in an Akan workspace — barrels are generated, and a third-party package may not be imported from most files."
3
+ description: "Fix an import, dependency, or barrel problem, or a file akan sync refuses, in an Akan workspace — barrels are generated, and a third-party package may not be imported from most files."
4
4
  ---
5
5
 
6
6
  # Akan imports, deps and barrels
@@ -8,13 +8,20 @@ description: "Fix an import, dependency, or barrel problem in an Akan workspace
8
8
  ## Barrels are generated
9
9
 
10
10
  Every `index.ts` under `ui/`, `webkit/`, `srvkit/`, `common/`, `plugin/` and `lib/**` is scanner output, as
11
- are `cnst.ts`, `db.ts`, `dict.ts`, `sig.ts`, `srv.ts`, `st.ts`, `useClient.ts`, `useServer.ts`, `client.ts`
12
- and `server.ts`. Do not hand-edit them and do not rely on their exact contents.
11
+ are `cnst.ts`, `db.ts`, `dict.ts`, `sig.ts`, `srv.ts`, `st.ts`, `useClient.ts`, `usePage.ts`, `useServer.ts`,
12
+ `client.ts`, `server.ts`, `lib/__lib/` and `lib/__client/`. Do not hand-edit them and do not rely on their exact
13
+ contents.
13
14
 
14
15
  **If an import "cannot be found" but the file exists, the barrel is stale** — run `akan sync <app-or-lib>`,
15
16
  or `repair_generated`. A `ui/<Folder>/index.tsx` that builds a namespace is hand-written source; the
16
17
  distinguishing test is that a generated barrel contains nothing but `export * from "./X";` lines.
17
18
 
19
+ ## What sync refuses
20
+
21
+ `akan sync` refuses a root file or folder its allowlist lacks, a hand-written file or test in `lib/`'s root, a
22
+ module file named off the pattern, and an `index.tsx` / `.jsx` / `.mts` beside a generated barrel. The allowlists,
23
+ the module file names and what sync does to `package.json` are the `syncRule` reference.
24
+
18
25
  ## Where a dependency is declared
19
26
 
20
27
  Add the package to the `package.json` of the app or lib that imports it —
@@ -24,16 +24,21 @@ import path at all**, so keep throwing code out of them entirely rather than rea
24
24
 
25
25
  ## Where each error belongs
26
26
 
27
- - a state-machine precondition → `document.ts`
28
- - a cross-document rule → `service.ts`
29
- - request-level policy → a guard in `signal.ts`
30
-
31
- Best-effort code returns a sentinel (`null`, `undefined`, `{}`) instead of throwing. `try/catch` is rare and
32
- always converts an exception into a decision: a guard catches, warns, and returns `false`; an adapter
33
- catches, logs, and returns `null`. A store action never catches — let the framework toast the `Err`, or list it in
34
- the store's `static silent` when no screen waits on it and its caller handles the rejection.
27
+ Which file throws which error, and the sentinel best-effort code returns instead, are the `server` rule.
28
+ `try/catch` is rare and always converts an exception into a decision: a guard catches, warns, and returns `false`, or throws a keyed `Err.Forbidden` the caller must read; an adapter
29
+ catches, logs (`logger.error`), and returns `null`; a UI `try/finally` resets a spinner. A store action never
30
+ catches — let the framework toast the `Err`, or list it in the store's `static silent` when no screen waits on it
31
+ and its caller handles the rejection.
35
32
  Client-side validation failure is `msg.error("<key>")` plus an early return, never a throw.
36
33
 
34
+ An `srvkit/` adapter belongs to no module: its keys go in the app's or lib's own service dictionary,
35
+ `lib/_<name>/<name>.dictionary.ts`, thrown as `new Err("<name>.error.<key>")` with `Err` from `"../lib/dict"`.
36
+
37
+ **An endpoint names the errors it throws on purpose** — `errors: { 409: ["ticket.error.locked"] }` in its signal
38
+ option, with keys its dictionary defines and never `base.error.*`. That is the status's OpenAPI response and a line
39
+ of the MCP tool's description; outside production a thrown key it leaves out warns once. A caller narrows with
40
+ `Err.is(error, "ticket.error.locked")`.
41
+
37
42
  **A failure another process reported travels as itself.** A server-to-server `fetch.<endpoint>(…, { origin })`
38
43
  restores the remote `Err` with its class, key and data. Rethrow it as-is — wrapping it in a `new Error`
39
44
  discards what the endpoint chose to say, and a bare `Error` is generalized to "Internal Server Error" on the
@@ -23,7 +23,7 @@ an endpoint with a real guard is published, one with none is refused, and so is
23
23
  - `option.setMcp({ … })` in the app's `lib/option.ts`, never `main.ts`; `AKAN_MCP=false` takes the surface off.
24
24
  - `JWT_SECRET` is required outside `local`.
25
25
  - Every published entry needs a `.desc()`; model-facing text is English.
26
- - Never make a refusal message more helpful. A client branches on the code a failure carries
26
+ - A client branches on the code a failure carries
27
27
  (`_meta["akanjs/failure"]`, or a JSON-RPC error's `data.code`), never on its text.
28
28
 
29
29
  ## Pages for the host
@@ -36,8 +36,8 @@ module. Collection-level helpers go `static` on the full model.
36
36
  - Keep business decisions in constant, document and service; API exposure in signal; client coordination in
37
37
  store; rendering in UI.
38
38
  - Never hand-edit a generated registry file — `cnst.ts`, `db.ts`, `dict.ts`, `option.ts`, `sig.ts`, `srv.ts`,
39
- `st.ts`, `useClient.ts`, `useServer.ts`, and every `index.ts` barrel. They are scanner output; run
40
- `akan sync <app>` or `repair_generated`.
39
+ `st.ts`, `useClient.ts`, `usePage.ts`, `useServer.ts`, the files under `lib/__lib/` and `lib/__client/`, and every
40
+ `index.ts` barrel. They are scanner output; run `akan sync <app>` or `repair_generated`.
41
41
  - Read the module's `<module>.abstract.md` before changing it, and update it when an invariant or workflow
42
42
  changes — not for formatting.
43
43
 
@@ -25,53 +25,88 @@ export default page()
25
25
 
26
26
  ## Steps
27
27
 
28
- 1. Place the file: `<route>.tsx` or `<dir>/_index.tsx` serves the path, `_layout.tsx` nests a layout (`layout()`;
29
- the root one is `rootLayout()`), `[id]` is a dynamic segment, `(group)` groups without a segment.
30
- 2. Name every `[x]` segment with `.param("x", Type)` and read a query key only with `.search("k", Type)`. Values
31
- arrive typed: `ID` / `String` → string, `Int` / `Float` → number, `Boolean`, `Date` → Dayjs, an `enumOf` class →
32
- its union, `[T]` → array. A path value the type refuses answers not-found, and a search value that fails is
33
- dropped. `lang` reaches every stage and is never declared.
34
- 3. Gate with `.guard(() => signedIn())` on the `_layout.tsx`, and repeat a stricter guard on a page that needs more.
35
- `.guard((_, { path }) => signedIn({ path }))` sends a refused visitor to `/signin?redirect=<path>`.
36
- 4. In `.render()`: `usePage()`, then fetch, then return. Hand `fetch.init*` / `view*` / `edit*` fields to sections
37
- unawaited; await only what the shell reads, in one `Promise.all`.
38
- 5. `.head()` takes JSX (or a function returning it), never a metadata object.
39
- 6. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
28
+ File names, stages, the `.render()` order and what a route file must never do are the `page` rule, loaded with any
29
+ `page/` file.
30
+
31
+ 1. `.param()` / `.search()` values arrive typed: `ID` / `String` → string, `Int` / `Float` → number, `Boolean`,
32
+ `Date` → Dayjs, an `enumOf` class → its union, `[T]` → array. A path value the type refuses answers not-found,
33
+ and a search value that fails is dropped.
34
+ 2. Gate in the `_layout.tsx`'s `.guard()` (below).
35
+ 3. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
40
36
  `export default override({ Slot: AppComponent })`, no logic. Nested ones merge slot by slot, the closest winning;
41
37
  `componentRule` lists the slots.
42
38
 
43
- ## API at a glance
39
+ ## Guards
44
40
 
45
- `page`, `layout` and `router` come from `akanjs/client`, `Link` from `akanjs/ui`, `usePageLocation` from
46
- `akanjs/webkit`, and `fetch`, `usePage` and the model namespaces from `@apps/<app>/client`. A stage receives the
47
- declared params and search keys plus `lang`.
41
+ - `.guard(fn)` runs before any of the route renders, once per chain (a second throws when the module loads). `fn`
42
+ may be `async` and gets the typed arguments and `lang` (a layout's without `children`), then `{ path }`. It refuses
43
+ with `router.redirect(href)`, `router.notFound()` or `getSelf({ unauthorize })`. Call `signedIn()` inside an arrow:
44
+ `.guard(signedIn)` would take the route's arguments as its option.
45
+ - `path` is where the visitor was going, in-app with its search (`undefined` while MCP lists the screen):
46
+ `.guard((_, { path }) => signedIn({ path }))` sends a refused visitor to `/signin?redirect=<path>`. It is a
47
+ redirect target, never an admission rule (CSR asks a guard again only when the route or an argument it declared
48
+ moves), handed only to `router.push` / `router.redirect`: a raw `//host` in it would take `window.location` off
49
+ the site.
50
+ - On the server every guard of the chain runs, root layout first, before any layout body and before the arguments
51
+ are checked, so a not-found is a 404 even after an awaited query. A guard's query the server refuses with 403 or
52
+ 404 (an owner check) answers not-found, so the page never confirms the record exists.
53
+ - Keeping a person on a page (an unsaved form) is `useNavigationGuard(() => !isDirty)` from `akanjs/webkit`, not
54
+ `.guard()`.
55
+
56
+ ## API at a glance
48
57
 
49
58
  - Data-driven title: `.head(async ({ id }) => <title>{((await fetch.book(id)) as Book | null)?.title}</title>)`,
50
59
  where `Book` is the `common/` interface for the query's `Any` return (`akan-service`).
51
60
  - Async page: `.render(async ({ id }) => { const book = (await fetch.book(id)) as Book | null; if (!book) return router.notFound(); … })`;
52
61
  the same query in `.head()` and `.render()` is one request.
62
+ - A page whose render calls `fetch.*` is rendered for every request (`X-Akan-Cache-Reason: dynamic-request-api`):
63
+ the call carries the visitor's session and address. `fetch.book(id, { forwardVisitor: false })`, for an endpoint
64
+ that answers everyone alike, lets the server keep the page.
53
65
  - Loading: `.loading(() => <Skeleton />)` on a page or layout is what that level shows until its `.render()` and the
54
66
  levels below it resolve; the levels above it stream first.
67
+ - A page left on screen while its next path loads (`/chat/a` to `/chat/b` under an awaiting layout):
68
+ `.loading(fn, { atPress: true })` shows the fallback after 150 ms of waiting on the server (`{ atPress: { delayMs } }`).
69
+ `page()` only; never on Back, Forward or a held page. It is the path being left's fallback: draw it from no argument.
55
70
  - `router.notFound()` from `.guard()`, `.head()` or `.render()` answers 404 with the nearest layout's `.notFound()`
56
71
  above it (an unmatched URL: the deepest layout covering it), else the built-in 404.
57
72
  - A layout's own 404 and error views: `.notFound(({ pathname }) => …)` and `.error(({ error }) => …)` on `layout()`
58
- or `rootLayout()`. A `<title>` and `<meta>` at the top of what they return replace the page's head:
59
- `.notFound(() => <><title>Not found</title>…</>)`, except below a `.loading()`, where the head is already out.
73
+ or `rootLayout()`. What they return is drawn as that layout's own `.render()` children, inside its frame, so it
74
+ holds only the content (no second `<main>` or header). A `<title>` and `<meta>` at the top of it replace the
75
+ page's head: `.notFound(() => <><title>Not found</title>…</>)`, except below a `.loading()`, where the head is
76
+ already out.
60
77
  - `<Link href="/books/OL45804W">`: write the path without the locale; Link adds it, or leaves it off for the default
61
78
  locale under `i18n.localePrefix: "as-needed"`. It renders an `<a>` and takes its attributes; `activeClassName`
62
- marks the current one.
79
+ marks the current one from the press, before its page arrives; an `active` prop from a layout's render is late.
80
+ `replace` and `scrollToTop={false}` change its push; it has no `shallow`, so a shallow one is an `onClick` that
81
+ calls `event.preventDefault()` and `router.push(href, { shallow: true })`.
82
+ - A page still loading, SSR or CSR: `pendingClassName` / `data-pending` on its `Link`, and `usePendingNavigation()`
83
+ (`akanjs/client`) for its `{ path, searchParams }`, `null` once it is drawn or shows its `.loading()`, and for a page
84
+ already held.
63
85
  - From a handler: `router.push(href)` / `router.replace(href)`; in a server stage, `router.redirect(href)`.
64
- - A client filter kept in the URL without reloading the page: ``router.replace(`/books?q=${q}`, { shallow: true,
65
- scrollToTop: false })`` in a `"use client"` component, read back with `usePageLocation().searchParams`. Shallow
66
- holds only while the path stays the same; a server `.search()` sees the value at the next full navigation.
86
+ - A page state a push opens in the query (a record in `?id=`): close it with `router.backOrReplace(href)`, never
87
+ `router.back()` or a `renderMode` branch. A CSR or native stack rewrites a push that keeps the pathname rather than
88
+ stacking it, and the address may be opened directly.
89
+ - A client filter kept in the URL without reloading the page: the URL is the state, in a `"use client"` component.
67
90
 
68
- ## Never
91
+ ```tsx
92
+ const { searchParams } = usePageLocation(); // akanjs/webkit
93
+ const genre = typeof searchParams.genre === "string" ? searchParams.genre : "all";
94
+ const setGenre = (next: string) => router.replace(`/books?genre=${next}`, { shallow: true, scrollToTop: false });
95
+ ```
69
96
 
70
- - A `fetch.<mutation>()` while rendering — it throws `base.error.mutationInRender`, because opening a link would
71
- perform it. Send writes from a user action.
72
- - `useState`, `useEffect`, comments, a named export beside the chain, or the legacy `export default async function`.
73
- - Editing a lib page through its link in `page/(libs)/` — edit the lib's own `page/` source.
97
+ `searchParams` follows the replace and the back and forward buttons, and the server render reads the request's
98
+ query from it, so the first HTML already shows the filter the URL names. A text box is the same: `value` from
99
+ `searchParams` and a replace on every `onChange`, which writes `searchParams` before it returns, so no keystroke
100
+ lags. Never keep the filter in `useState`, with or without a `popstate` listener: a shallow back draws no page, so
101
+ the copy stays on the old value while the URL moves. Shallow holds only while the path stays the same; a server
102
+ `.search()` sees the value at the next full navigation.
103
+ - On a web page's first render `st.use.searchParams()` is still the server's empty snapshot, synced right after
104
+ hydration, so an effect that needs the query on its first run takes the page's `.search()` value as a prop.
105
+ - A `Link` renders its page ahead of the click, guards included: on hover, on keyboard focus, or as it shows with
106
+ `prefetch="viewport"` (production only). A page whose render should happen once per visit (a view counted through
107
+ `duringRender`, an expensive report) sets `.config({ prefetch: false })`; on a `_layout.tsx` it covers every page
108
+ below, and a page there opts back in with `prefetch: true`.
74
109
 
75
- Full detail: `get_guideline` with `pageRule` (guards in depth, heads, MCP apps, CSR root layouts, lib pages), or
76
- `ssrRule` for what may render on the server. Every stage's signature, the router's methods, Link's props and every
77
- import path are in the `akanApi-*` references below.
110
+ `pageRule` holds what neither this skill nor the `page` rule says: client-navigation and navigation guards, head
111
+ merging, the script policy, CSR root layouts, lib pages, `devOnly`, the legacy shape. `ssrRule`: what may render on
112
+ the server; `akan-mcp`: `.prompt()` and `.app()`.
@@ -5,35 +5,28 @@ description: "Write filters, slices and list loading: query descriptors, init pa
5
5
 
6
6
  # Akan queries and slices
7
7
 
8
+ The `module` rule, loaded with every `lib/` file, holds the musts: a slice returns a query, at most 500 rows, soft
9
+ removal and `purge`, the hookless `updateById` / `removeById`, secret projections, the cascade direction and when a
10
+ search slice is safe. This skill adds what it does not say.
11
+
8
12
  ## Filters and slices
9
13
 
10
- - A filter in `<model>.document.ts` declares its args; a slice in `<model>.signal.ts` serves it to stores. A slice
11
- `exec` returns a `query<Filter>(…)` descriptor — never a `list<Filter>` array — and you cannot chain sort or
12
- limit on it.
14
+ - A filter in `<model>.document.ts` declares its args; a slice in `<model>.signal.ts` serves it to stores. The
15
+ `query<Filter>(…)` descriptor a slice returns takes no chained sort or limit.
13
16
  - Page through the store: `initX(…, { sort, page, limit })`, then `st.do.loadMoreOf<Model>()` while
14
17
  `hasMoreOf<Model>`. Never compare `count > page * limit`.
15
- - Never ask for more than 500 rows: the server serves at most 500 per request and drops the rest silently.
16
- A figure over the whole set belongs in an insight or an endpoint.
17
- - The root slice takes a filter name and its args, never a raw query, and its `root:` guard is always `Admin`.
18
+ - The root slice takes a filter name and its args, never a raw query.
18
19
  - No value is `q.empty`, never `q.missing`.
19
- - A projection is bare on the facade (`pickById(id, { secret: true })`) and under `select` on a filter accessor —
20
- the only way to read a `field.secret` value.
21
20
 
22
- ## Writes and removal
21
+ ## Writes
23
22
 
24
- - Removal is soft: reads see live rows unless `{ withRemoved: true }`. The one hard delete is `purge<Filter>` /
25
- `purgeMany`, for data past retention.
26
- - A filter's `remove*` / `update*`, `updateById` and `removeById` run no hooks and no cascade. A model with a
27
- cascade or `_postRemove` removes through `remove<Model>(id)`.
28
- - Load a set once (`load<Model>Many`, one filter query) and create one with `create<Model>Many(rows)` instead of one
29
- call per item in a loop — lint fails a per-item service call an endpoint reaches. `create<Model>Many` runs every
30
- row's `_preCreate` before writing any, so a check there does not see the batch's own rows.
23
+ - A filter's `update*` runs no hooks and no cascade, like its `remove*`.
24
+ - `create<Model>Many(rows)` runs every row's `_preCreate` before writing any, so a check there does not see the
25
+ batch's own rows.
31
26
 
32
- ## Search and cascade
27
+ ## Search
33
28
 
34
29
  - `q.search(text, { prefix: true })` sits in a filter at an AND position, over fields with the `text` role. Blank
35
- input matches nothing — never a passthrough. A search slice only over data safe to enumerate.
36
- - `cascade` names a direction, and the wrong one loses data: `removeRef` on the owner's relation, `removeWith` on
37
- the child's reference to its owner.
30
+ input matches nothing — never a passthrough.
38
31
 
39
32
  Full detail: `get_guideline` with `queryRule`, and `workspaceRecipes` for a worked slice.
@@ -15,9 +15,10 @@ the agent guide's Path Rules table.
15
15
  | --- | --- |
16
16
  | API only, or no CSR bundle for native apps | `web: false`, `web: { csr: false }` |
17
17
  | Move the API or websocket mount | `new AkanApp({ prefix, websocketPrefix })` in `main.ts`, mirrored in `api: { … }`; read with `getApiPrefix()` / `getWsPrefix()` |
18
- | The production image | `docker: string \| { image, preRuns, postRuns, command }` |
18
+ | The production image | `docker: string \| { image, preRuns, installRuns, postRuns, command, crossBuild, baseSetup, env, variants }` |
19
19
  | iOS, Android, desktop | the `native` section; `desktop: { server: true }` carries the server |
20
20
  | SQLite, several databases, a cluster | `database: { modes: [...] }` (`single`, `multiple`, `cluster`), picked by `AKAN_DATABASE_MODE` |
21
+ | A secret of `env/env.server.<env>.ts` in a deployed server | nothing to declare: `akan build` leaves it out and the server reads it from a variable named after its key path; `akan secret-env <app> --env <env>` lists them |
21
22
  | URLs without `/<locale>/`: one language, or paths fixed from outside (OAuth callback, QR code, mail link) | `i18n: { localePrefix: "as-needed" }` — the default locale's pages and `<Link>` hrefs drop the prefix, other locales keep it |
22
23
 
23
24
  ## Running and logs
@@ -28,6 +29,25 @@ the agent guide's Path Rules table.
28
29
  - Run a build without Docker with `cd dist/apps/<app> && bun main.js`: it boots with the env the Dockerfile sets,
29
30
  read from `akan.env.json` beside it, and a variable you set yourself (`PORT=3000`) wins.
30
31
 
32
+ ## Secrets in a deployed server
33
+
34
+ - Write secrets in `env/env.server.<env>.ts` as before. `akan build` replaces each string under a secret-named key,
35
+ and each URL carrying a password, with a read of an environment variable: `security.sso.google.clientSecret` is
36
+ `SECURITY__SSO__GOOGLE__CLIENT_SECRET`, an array holding a secret is one JSON variable, `security.jwtSecret` is
37
+ `JWT_SECRET`. The built files hold the names (`AKAN_ENV_NAMES` in `akan.env.json`), never the values.
38
+ - `akan secret-env <app> --env <env>` prints the variables, never a value. `--out <file> --format k8s --name <name>`
39
+ writes a Kubernetes Secret for `envFrom`, `--format dotenv` a file for `bun --env-file`. Never write it
40
+ under `dist/` or a tracked path, and delete it once applied.
41
+ - A server with one of them unset exits at boot, naming each: set them before the image rolls out. Images built
42
+ before 3.3.0 still hold the values: rotate them.
43
+ - A secret the env file computes or imports stops the build, whatever its length: write the string at the key, or
44
+ `process.env.<NAME>` there, which the build leaves as that read. A secret string a plain key or the app's code
45
+ holds as well stops it too when long and mixed, and is a warning when short. A key the name rule misses
46
+ (`stripeKey`) stays in the image unless read from `process.env`.
47
+ - The build loads the env file to list the secrets, with the shell's variables only when it cannot load without
48
+ them; a file that throws as it loads stops the build by error class and line.
49
+ - `akan start`, `akan test`, `akan build --profile …` and desktop and mobile builds read the env file as written.
50
+
31
51
  ## Native and desktop
32
52
 
33
53
  A `start-*` command loads its pages from a running `akan start`; a desktop app carrying its server starts it itself.
@@ -5,35 +5,29 @@ description: "Add a service module — behaviour not centred on one stored model
5
5
 
6
6
  # Akan service modules
7
7
 
8
- Behaviour that is not centred on a single stored model lives in a **service module**: the folder is
9
- `lib/_<service>/` and its abstract file is `<service>.abstract.md` — the folder carries the underscore, the
10
- abstract drops it. Its UI surface is limited to `<Service>.Util.tsx` and `<Service>.Zone.tsx`, and its
11
- dictionary is a `serviceDictionary`.
8
+ Behaviour not centred on one stored model lives in a **service module**, `lib/_<service>/`, whose abstract is
9
+ `<service>.abstract.md` (no underscore). Its UI surface is limited to `<Service>.Util.tsx` and
10
+ `<Service>.Zone.tsx`, and its dictionary is a `serviceDictionary`.
12
11
 
13
12
  ## Rules
14
13
 
15
14
  - Read the module's `*.abstract.md` **before** changing it — it states the invariants the code cannot show.
16
15
  Update it when an invariant, workflow, or public behaviour changes; not for formatting or imports.
17
16
  - Keep the public surface in the signal layer and the decisions in the service.
18
- - Service methods stay a few lines: load → chain → `return await ….save()`. Write `return await` explicitly
19
- in tail position. Side effects belong in `_preUpdate` / `_postCreate`, not inline. Fire-and-forget is
20
- explicitly `void`-ed.
17
+ - Service methods stay a few lines: load → chain → `return await ….save()`. Side effects belong in
18
+ `_preUpdate` / `_postCreate`, not inline. Fire-and-forget is explicitly `void`-ed.
21
19
  - Return `null` / `false` for "not allowed" or "not found" and let the signal decide whether that is an
22
20
  error.
23
- - `serve(name, { serverMode: "batch" }, …)` mounts the module, endpoints included, only in a `batch` or `all`
24
- process; a `federation` replica, the one serving requests in a split deployment, skips it. The app's own
25
- `lib/_<app>/` service is scaffolded with it for cron and queue work. Leave it off a service a page calls, as
26
- `akan create-service` does.
21
+ - `serve(name, { serverMode: "batch" }, …)`, on the app's own `lib/_<app>/` for cron and queue work, mounts the
22
+ module, endpoints included, only in a `batch` or `all` process, never on a `federation` replica. A service a page
23
+ calls leaves it off, as `akan create-service` does.
27
24
 
28
25
  ## Reaching other things
29
26
 
30
27
  Inside a service, in preference order: `service<srv.XService>()` for another module's service,
31
28
  `plug(AdapterClass)` for an adapter, `use<T>()` only for an `option.ts`-registered legacy singleton, and
32
- `env(...)` for config. Injection resolves by field name — a field named `<refName>Service` finds the service
33
- registered under `<refName>`, and the `Service` suffix is required.
34
-
35
- An external API or piece of infrastructure is an `adapt()` class in `srvkit/`, injected with `plug`. It
36
- self-registers, so do **not** add it to `lib/option.ts`.
29
+ `env(...)` for config. Injection resolves by field name: a field named `<refName>Service` finds the service
30
+ registered under `<refName>`. The adapter's place and the field-name suffix are the `server` rule.
37
31
 
38
32
  ## Recipe: pages backed by an external HTTP API
39
33
 
@@ -70,11 +64,15 @@ interface ApiWork {
70
64
  export class OpenlibraryService extends serve("openlibrary" as const, ({ plug }) => ({ bookApi: plug(BookApi) })) {
71
65
  async getBook(id: string) {
72
66
  const work = await this.bookApi.get<ApiWork>(`works/${id}.json`);
73
- return work && { id, title: work.title };
67
+ return work && this.toBook(id, work);
68
+ }
69
+ // TypeScript `private`: lint refuses `#private` in a service.
70
+ private toBook(id: string, work: ApiWork) {
71
+ return { id, title: work.title };
74
72
  }
75
73
  }
76
74
 
77
- // lib/_openlibrary/openlibrary.signal.ts — Any answers plain JSON; nullable lets it answer null for "not found"
75
+ // lib/_openlibrary/openlibrary.signal.ts — Any answers plain JSON
78
76
  import { Any } from "akanjs/base";
79
77
  import { endpoint, internal, Public } from "akanjs/signal";
80
78
 
@@ -106,5 +104,8 @@ The page calls it as `await fetch.book(id)` (`fetch` from `@apps/<app>/client`)
106
104
  `common/`, or return a scalar (`akan create-scalar`) for a typed wire shape. A query that answers `null` without
107
105
  `nullable: true` fails the render, naming the endpoint.
108
106
 
109
- Full detail: `get_guideline` with `modelService`. The exact signatures of serve, adapt, endpoint and
110
- serviceDictionary, and every import path, are in the `akanApi-*` references below.
107
+ The adapter turns every failure into `null`, a not-found page. One the page must show as an error throws
108
+ `new Err("<app>.error.<key>")`, `Err` from `"../lib/dict"` and the key in `lib/_<app>/<app>.dictionary.ts`'s
109
+ `.error({})`; `new Error` fails the build (`no-throw-raw-error`).
110
+
111
+ The signatures of serve, adapt, endpoint and serviceDictionary, and every import path: the `akanApi-*` references.
@@ -7,21 +7,14 @@ description: "Guard and tune endpoints on the wire: writing a Can<Verb><Model> g
7
7
 
8
8
  ## Guards
9
9
 
10
- - Every custom `query` / `mutation` / `pubsub` / `message` names its own `guards: [...]`; every `slice()` takes an
11
- explicit guard map with `root: Admin`. `Public` belongs on a slice `get:`, and on a mutation only for an act that
12
- must work signed out (sign-up, sign-in, token refresh, an OAuth route), which also declares a `rateLimit`.
10
+ - Which guards each endpoint and slice names, `Public`, `static scope`, `static name`, the acting user and the
11
+ service's second check are the `auth` rule, loaded with every `signal.ts` and `srvkit/` file.
13
12
  - A resource guard is a `Can<Verb><Model>` class in the model library's `srvkit/guards.ts` that fails closed:
14
13
  no resource named, or a load that throws, is `false` (after a `logger.warn`). Admin bypass goes first.
15
- - Every guard declares `static scope`: `"account"` reads only the caller (`SignedIn`, `Admin`, roles), and
16
- `"resource"` needs the call's arguments (every `Can<Verb><Model>`). Keep `static name = "User";` with a comment.
17
- - Guards read `context.get<T>("account")`, serve HTTP and websocket alike, and stay side-effect free. The acting
18
- user comes from `.with(Self)` / `.with(CurrentUserId)` / `.with(Me)`, the address from `.with(Ip)` — never a
19
- client-supplied id. The service re-checks ownership: two independent gates.
20
14
 
21
15
  ## Endpoint options
22
16
 
23
- - `{ timeout: <ms> }` is the deadline on both ends; undeclared, the client quits at 30 s and the handler is not
24
- cancelled.
17
+ - `{ timeout: <ms> }` is the deadline on both ends.
25
18
  - `{ cache }` only on a `query` with no internal argument, capped at one day; `invalidate(endpoint, args?)` drops
26
19
  it early through a plugged `EndpointCacheControl`.
27
20
  - `{ rateLimit: { calls, windowMs?, by? } }` per endpoint, `option.setRateLimit` per app, `plug(RateLimit)` for a
@@ -34,9 +27,7 @@ description: "Guard and tune endpoints on the wire: writing a Can<Verb><Model> g
34
27
 
35
28
  ## Bodies and other servers
36
29
 
37
- - `.body()` / `.param()` take scalars, model refs or `enumOf(...)`; `Int` / `Float`, never `Number`; bytes are
38
- `Binary`, never `Any`; `Upload` only in a `fileUpload: true` mutation.
39
- - Server to server, `fetch.clone({ origin })` opens no socket without `connect: true`, retries through `retry`,
40
- and rethrows a remote `Err` as it is — never wrap or re-key it.
30
+ - `.body()` / `.param()` take scalars, model refs or `enumOf(...)`; the types they refuse are the `server` rule.
31
+ - Server to server, `fetch.clone({ origin })` opens no socket without `connect: true` and retries through `retry`.
41
32
 
42
33
  Full detail: `get_guideline` with `transportRule`, or `mcpRule` for what a guard's scope does to an MCP listing.
@@ -1,30 +1,33 @@
1
1
  ---
2
2
  name: akan-ui
3
- description: "Build Akan pages and components: the server-by-default rule, the Unit/View vs Template/Zone/Util split, forms, and what never to hand-roll."
3
+ description: "A module's components: the Unit/View vs Template/Zone/Util split, forms, and what never to hand-roll. A page or a model-free ui/ component needs only the ssr, style and tsx rules."
4
4
  ---
5
5
 
6
6
  # Akan UI
7
7
 
8
- A new View / Unit / Template / Zone / Util for an existing module comes from the `create-ui` workflow (the
9
- `akan-scaffold` skill). Edit the scaffolded component instead of authoring one from scratch.
10
-
11
- ## The boundary is mechanical, not a judgement call
12
-
13
- | role | side | directive |
14
- | --- | --- | --- |
15
- | `<Model>.Unit.tsx`, `<Model>.View.tsx` | server | never `"use client"` |
16
- | `<Model>.Template.tsx`, `<Model>.Zone.tsx`, `<Model>.Util.tsx` | client | `"use client"` on line 1 |
17
- | `page/**` | server | never |
8
+ A page, or a `ui/` component bound to no model, needs nothing more from here: the `ssr`, `style` and `tsx` rules
9
+ loaded with the file are its contract. The rest is for a module's own components, lists and forms.
18
10
 
19
11
  **Server is the default and `"use client"` is a cost you justify per component.** A component earns the
20
12
  directive only by using a hook, a JSX event handler, the store, a browser global, or a client-only package.
21
- Rendering markup, reading a param, calling `l()`, and mapping over data are all server work. Measure with
22
- `akan quality ssr`; treat 50% server share as the floor and a falling share as a regression.
13
+ Rendering markup, reading a param, calling `l()`, and mapping over data are all server work.
23
14
 
24
15
  Four moves that keep markup on the server: wrap the interaction and render `children` untouched; split a
25
16
  compound component so only the provider holds state; fetch in the route and pass the result into a `Zone` as
26
17
  an `init` prop; push the boundary down to the leaf that needs it.
27
18
 
19
+ ## A module's components
20
+
21
+ A new View / Unit / Template / Zone / Util for an existing module comes from the `create-ui` workflow (the
22
+ `akan-scaffold` skill). Edit the scaffolded component instead of authoring one from scratch. The boundary is
23
+ mechanical by role, not a judgement call:
24
+
25
+ | role | side | directive |
26
+ | --- | --- | --- |
27
+ | `<Model>.Unit.tsx`, `<Model>.View.tsx` | server | never `"use client"` |
28
+ | `<Model>.Template.tsx`, `<Model>.Zone.tsx`, `<Model>.Util.tsx` | client | `"use client"` on line 1 |
29
+ | `page/**` | server | never |
30
+
28
31
  ## Never hand-roll these
29
32
 
30
33
  - loading / empty / list states → `Load.Units` / `Load.View` / `Load.Edit` with `renderItem`, `renderList`,
@@ -45,14 +48,6 @@ an `init` prop; push the boundary down to the leaf that needs it.
45
48
  Conditional render is `cond ? <X/> : null`. **Never `{cond && <X/>}`** — in a `className` context it renders
46
49
  the literal string `"false"`.
47
50
 
48
- ## Classes
49
-
50
- Never hand-order Tailwind classes; the formatter sorts them and its output is correct. Stay inside the
51
- semantic token vocabulary — `bg-primary`, `text-foreground/70` — because a raw palette class (`bg-blue-500`),
52
- an arbitrary colour (`bg-[#3b82f6]`), a daisyUI legacy class, and a colour literal in `style={{…}}` all
53
- render no CSS and fail lint. Reach for `cn` only for a conditional or to merge an incoming `className`, and
54
- merge the caller last.
55
-
56
51
  ## Forms
57
52
 
58
53
  Store-driven end to end: `value={xForm.field}` with `onChange={st.do.setFieldOnX}`, **the setter passed by
@@ -29,8 +29,14 @@ Raw `tsc` misses the generated barrels and reports false errors. Do not reach fo
29
29
  **Apply the real fix the rule intends. Do not silence the checker.** No blanket lint-disable, no throwaway
30
30
  re-export, no export-in-place trick, no `as any`, no non-null assertion. Gaming a check is a defect, not a
31
31
  fix. When a suppression is genuinely right it carries a reason:
32
- `// biome-ignore lint/<rule>: <why>` — and a grit plugin diagnostic is suppressed as `lint/plugin`, not the
33
- bare `plugin` category Biome's own message suggests.
32
+ `// biome-ignore lint/<rule>: <why>` — and a grit plugin diagnostic is suppressed as `lint/plugin`
33
+ (`// biome-ignore-all lint/plugin: <why>` for a whole file), not the bare `plugin` category Biome's own message
34
+ suggests. The grit plugins scope `apps/` and `libs/`, never `pkgs/`.
35
+
36
+ - **`biome.json` is strict JSON** — a comment breaks config resolution without an error (Biome falls back to
37
+ discovery and aborts on a nested config); rename it `biome.jsonc` to document a disabled rule.
38
+ - **`akan lint` prints up to 200 diagnostics** (`--max-diagnostics <n>`, `0` = all); Biome's own uncounted 20 reads
39
+ as progress when the mix merely changed.
34
40
 
35
41
  Common classes and their real fix:
36
42