@akanjs/devkit 3.2.0-rc.9 → 3.2.1-rc.0

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 (353) hide show
  1. package/CHANGELOG.md +0 -529
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/README.ko.md +3 -2
  4. package/README.md +4 -2
  5. package/akanApp/BackendImportGraph.test.ts +1 -1
  6. package/akanApp/akanApp.host.test.ts +152 -6
  7. package/akanApp/akanApp.host.ts +187 -1220
  8. package/akanApp/akanApp.host.wiring.test.ts +931 -0
  9. package/akanApp/builderGap.ts +68 -0
  10. package/akanApp/builderRequestRelay.test.ts +93 -0
  11. package/akanApp/builderRequestRelay.ts +100 -0
  12. package/akanApp/builderRssRecycler.ts +182 -0
  13. package/akanApp/devBackend.ts +394 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +200 -0
  16. package/akanApp/devIdleSuspend.test.ts +221 -0
  17. package/akanApp/devIdleSuspend.ts +192 -0
  18. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  19. package/akanApp/devRecycler.test.ts +66 -0
  20. package/akanApp/devRecycler.ts +305 -0
  21. package/akanApp/devStartTimeline.test.ts +115 -0
  22. package/akanApp/devStartTimeline.ts +69 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +45 -17
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiReport.test.ts +34 -3
  29. package/apiReport/apiReportDiff.ts +35 -1
  30. package/apiReport/apiReportPolicy.ts +3 -2
  31. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +2 -49
  32. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +71 -8
  33. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +60 -21
  34. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  35. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +17 -1
  36. package/{routeJsBudget.ts → app/routeJsBudget.ts} +9 -3
  37. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  38. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  39. package/artifact/implicitRootLayout.test.ts +71 -3
  40. package/artifact/implicitRootLayout.ts +9 -3
  41. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  42. package/biome.base.json +2 -1
  43. package/cloud/cloudApi.test.ts +1 -1
  44. package/cloud/configLock.test.ts +1 -1
  45. package/cloud/globalConfig.test.ts +1 -1
  46. package/cloud/globalConfig.ts +1 -1
  47. package/cloud/updatePackUpload.test.ts +1 -1
  48. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  49. package/codeAgent/agent/AkanCodeServices.ts +23 -0
  50. package/codeAgent/agent/akanCodePaths.ts +1 -1
  51. package/codeAgent/agent/akanCodeServices.test.ts +54 -0
  52. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  53. package/codeAgent/agent/codeAgent.test.ts +1 -1
  54. package/codeAgent/skills/akan-debug/SKILL.md +8 -5
  55. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  56. package/codeAgent/skills/akan-mcp/SKILL.md +19 -1
  57. package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
  58. package/codeAgent/skills/akan-validate/SKILL.md +3 -3
  59. package/codeAgent/tools/AkanCli.ts +1 -1
  60. package/codeAgent/tools/AkanToolPack.ts +2 -2
  61. package/codeAgent/tools/akanCodePlugins.test.ts +1 -1
  62. package/commandDecorators/command.ts +35 -6
  63. package/commandDecorators/commandBuilder.ts +1 -1
  64. package/commandDecorators/commandDecorators.test.ts +107 -6
  65. package/commandDecorators/targetMeta.ts +2 -0
  66. package/commandDecorators/workspaceVersionCheck.test.ts +70 -1
  67. package/commandDecorators/workspaceVersionCheck.ts +64 -14
  68. package/context/akanContext.ts +576 -0
  69. package/context/akanContextInspection.ts +296 -0
  70. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  71. package/{akanMcpContract.ts → context/akanMcpContract.ts} +16 -256
  72. package/context/doctor/agentGuideCheck.ts +81 -0
  73. package/context/doctor/configLeftoverCheck.ts +35 -0
  74. package/context/doctor/doctorFindings.ts +70 -0
  75. package/context/doctor/generatedFreshness.ts +56 -0
  76. package/context/doctor/moduleShapeCheck.ts +88 -0
  77. package/context/doctor/recipeDuplicateCheck.ts +42 -0
  78. package/context/doctor/recipeIndexCheck.ts +87 -0
  79. package/context/doctor/rootShapeCheck.ts +55 -0
  80. package/context/doctor/workflowScope.ts +97 -0
  81. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  82. package/context/safeRead.ts +9 -0
  83. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  84. package/devkitUtils.test.ts +39 -5
  85. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  86. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  87. package/docs/errorCodeReference.test.ts +282 -0
  88. package/docs/errorCodeReference.ts +71 -0
  89. package/docs/errorCodeScan.ts +551 -0
  90. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  91. package/executors/appExecutor.ts +463 -0
  92. package/executors/commandExecutionError.ts +53 -0
  93. package/executors/executor.ts +527 -0
  94. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  95. package/{executors.test.ts → executors/executors.test.ts} +106 -18
  96. package/executors/index.ts +8 -0
  97. package/executors/libExecutor.ts +23 -0
  98. package/executors/moduleExecutor.ts +18 -0
  99. package/executors/pkgExecutor.ts +129 -0
  100. package/executors/sysExecutor.ts +301 -0
  101. package/executors/workspaceExecutor.ts +277 -0
  102. package/frontendBuild/allRoutesBuilder.test.ts +1 -1
  103. package/frontendBuild/autoImportSync.test.ts +1 -1
  104. package/frontendBuild/autoImportSync.ts +1 -1
  105. package/frontendBuild/buildCacheStamp.test.ts +42 -0
  106. package/frontendBuild/buildCacheStamp.ts +23 -0
  107. package/frontendBuild/buildRouteClient.test.ts +1 -1
  108. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  109. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  110. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  111. package/frontendBuild/cssCandidateCache.test.ts +70 -1
  112. package/frontendBuild/cssCandidateCache.ts +17 -10
  113. package/frontendBuild/cssCompiler.test.ts +3 -2
  114. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  115. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  116. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  117. package/frontendBuild/fontOptimizer.test.ts +145 -4
  118. package/frontendBuild/fontOptimizer.ts +103 -18
  119. package/frontendBuild/fontPruner.test.ts +1 -1
  120. package/frontendBuild/frontendBuild.test.ts +3 -3
  121. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  122. package/frontendBuild/hmrWatcher.test.ts +1 -1
  123. package/frontendBuild/hmrWatcher.ts +22 -1
  124. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  125. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  126. package/frontendBuild/nativeCore.test.ts +1 -1
  127. package/frontendBuild/optionalPeers.test.ts +36 -8
  128. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  129. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  130. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  131. package/frontendBuild/precompressArtifacts.ts +19 -6
  132. package/frontendBuild/serverGraphFile.ts +1 -1
  133. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  134. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
  135. package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
  136. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  137. package/frontendBuild/vendorImportScanner.test.ts +1 -1
  138. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  139. package/frontendBuild/watchRootResolver.test.ts +1 -1
  140. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  141. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  142. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  143. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  144. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  145. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  146. package/{prompter.ts → guideline/prompter.ts} +2 -3
  147. package/incrementalBuilder/buildBatch.proc.ts +16 -5
  148. package/incrementalBuilder/buildBatchProtocol.ts +3 -0
  149. package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
  150. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  151. package/incrementalBuilder/builderBoot.ts +113 -0
  152. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  153. package/incrementalBuilder/builderChannel.test.ts +1 -1
  154. package/incrementalBuilder/builderChannel.ts +19 -2
  155. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  156. package/incrementalBuilder/builderLanes.ts +157 -0
  157. package/incrementalBuilder/builderWatch.ts +213 -0
  158. package/incrementalBuilder/csrRegistry.ts +234 -0
  159. package/incrementalBuilder/incrementalBuilder.host.test.ts +16 -0
  160. package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
  161. package/incrementalBuilder/incrementalBuilder.proc.test.ts +142 -7
  162. package/incrementalBuilder/incrementalBuilder.proc.ts +82 -823
  163. package/incrementalBuilder/ssrRegistry.ts +282 -0
  164. package/index.ts +22 -22
  165. package/integration/devStability.integration.test.ts +62 -56
  166. package/integration/devStabilityHarness.test.ts +1 -1
  167. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  168. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  169. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  170. package/lint/gritRules.test.ts +1 -1
  171. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  172. package/lint/no-import-common-err.grit +31 -0
  173. package/lint/no-init-fetch-in-client.grit +1 -1
  174. package/mobile/desktopBin.test.ts +1 -1
  175. package/mobile/desktopRelease.test.ts +1 -1
  176. package/mobile/desktopServerStage.test.ts +2 -2
  177. package/mobile/desktopServerStage.ts +1 -1
  178. package/mobile/nativeApi.test.ts +1 -1
  179. package/mobile/nativeApp.test.ts +1 -1
  180. package/mobile/nativeConfig.test.ts +1 -1
  181. package/mobile/nativePluginFolders.test.ts +1 -1
  182. package/mobile/nativePublicEnv.test.ts +1 -1
  183. package/mobile/nativePublicEnv.ts +2 -1
  184. package/mobile/nativeWebDir.test.ts +1 -1
  185. package/mobile/serverBundleSecrets.test.ts +1 -1
  186. package/mobile/tarWriter.test.ts +1 -1
  187. package/mobile/updatePackFolder.test.ts +1 -1
  188. package/package.json +173 -9
  189. package/packageExports.test.ts +20 -2
  190. package/piDependencyPins.test.ts +1 -1
  191. package/pipeline/PipelineDefinition.ts +1 -1
  192. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  193. package/platformTest/LinuxDockerTarget.ts +1 -1
  194. package/platformTest/PlatformTestRun.test.ts +1 -1
  195. package/platformTest/TestSnapshot.test.ts +1 -1
  196. package/platformTest/WindowsSshTarget.ts +1 -1
  197. package/preview/previewView.test.ts +23 -1
  198. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  199. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  200. package/quality/bareErrorScanner.ts +126 -0
  201. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  202. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  203. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  204. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  205. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  206. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  207. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  208. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  209. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +41 -1
  210. package/{qualityScanner.ts → quality/qualityScanner.ts} +25 -91
  211. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  212. package/quality/workspaceSourceFiles.ts +82 -0
  213. package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
  214. package/{subspace.ts → subspace/subspace.ts} +5 -5
  215. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  216. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  217. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  218. package/transforms/barrelAnalyzer.ts +31 -10
  219. package/transforms/browserDirnamePlugin.test.ts +1 -1
  220. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  221. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  222. package/transforms/pureLazyMarker.test.ts +1 -1
  223. package/transforms/serverEnvPlugin.test.ts +1 -1
  224. package/transforms/serverEnvProfile.test.ts +1 -1
  225. package/transforms/sideEffectImportOrder.test.ts +1 -1
  226. package/transforms/transforms.test.ts +52 -2
  227. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  228. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  229. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  230. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  231. package/typecheck/projectTypecheck.test.ts +23 -1
  232. package/typecheck/projectTypecheck.ts +10 -2
  233. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  234. package/{typeChecker.ts → typecheck/typeChecker.ts} +5 -4
  235. package/typecheck/typecheck.proc.ts +6 -2
  236. package/typecheck/typecheckFailure.ts +1 -1
  237. package/util/errorReport.ts +66 -0
  238. package/{fileSys.test.ts → util/fileSys.test.ts} +13 -0
  239. package/{fileSys.ts → util/fileSys.ts} +2 -2
  240. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  241. package/workflow/constantSource.ts +187 -0
  242. package/workflow/dictionarySource.ts +184 -0
  243. package/workflow/executor.ts +6 -9
  244. package/workflow/fieldExpression.ts +153 -0
  245. package/workflow/fieldLabel.ts +61 -0
  246. package/workflow/fieldOrder.ts +117 -0
  247. package/workflow/fieldType.ts +2 -1
  248. package/workflow/guardCatalog.test.ts +1 -1
  249. package/workflow/keyRename.ts +1 -1
  250. package/workflow/moduleIndex.test.ts +2 -2
  251. package/workflow/moduleIndex.ts +2 -2
  252. package/workflow/modulePaths.ts +27 -0
  253. package/workflow/mutationScaffold.ts +7 -15
  254. package/workflow/mutationSource.ts +2 -1
  255. package/workflow/plan.ts +2 -1
  256. package/workflow/primitiveReport.ts +78 -0
  257. package/workflow/rolloutGate.test.ts +1 -1
  258. package/workflow/rolloutGate.ts +1 -1
  259. package/workflow/serviceSource.ts +33 -0
  260. package/workflow/signalSource.ts +96 -0
  261. package/workflow/source.ts +50 -1100
  262. package/workflow/sourceAst.ts +30 -0
  263. package/workflow/sourceImports.ts +105 -0
  264. package/workflow/sourceText.ts +13 -0
  265. package/workflow/templateSource.ts +30 -0
  266. package/workflow/testSource.ts +31 -0
  267. package/workflow/types.ts +1 -1
  268. package/workflow/uiPolicy.ts +1 -1
  269. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  270. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  271. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  272. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  273. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  274. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  275. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  276. package/{libSource.ts → workspace/libSource.ts} +1 -1
  277. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  278. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  279. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  280. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
  281. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
  282. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  283. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  284. package/akanContext.ts +0 -1083
  285. package/executors.ts +0 -1749
  286. /package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +0 -0
  287. /package/{akanMcpToolError.ts → context/akanMcpToolError.ts} +0 -0
  288. /package/{moduleFieldNames.test.ts → context/moduleFieldNames.test.ts} +0 -0
  289. /package/{moduleFieldNames.ts → context/moduleFieldNames.ts} +0 -0
  290. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  291. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  292. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  293. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  294. /package/{linter.ts → lint/linter.ts} +0 -0
  295. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  296. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  297. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  298. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  299. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  300. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  301. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  302. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  303. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  304. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  305. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  306. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  307. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  308. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  309. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  310. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  311. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  312. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  313. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  314. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  315. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  316. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  317. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  318. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  319. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  320. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  321. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  322. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  323. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  324. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  325. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  326. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  327. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  328. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  329. /package/{writePath.ts → quality/writePath.ts} +0 -0
  330. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  331. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  332. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  333. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  334. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  335. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  336. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  337. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  338. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  339. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  340. /package/{semver.ts → util/semver.ts} +0 -0
  341. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  342. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  343. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  344. /package/{spinner.ts → util/spinner.ts} +0 -0
  345. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  346. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  347. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  348. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  349. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  350. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  351. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  352. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  353. /package/{types.ts → workspace/types.ts} +0 -0
@@ -2,14 +2,9 @@ import path from "node:path";
2
2
  import { toError } from "akanjs/common";
3
3
  import { BUILD_ENV_FILE } from "akanjs/server/lifecycle/buildEnv";
4
4
  import type { BunPlugin } from "bun";
5
- import { ProductionLockfile } from "./akanConfig/productionLockfile";
6
- import type {
7
- ApplicationBuildPhaseResult,
8
- ApplicationBuildProgressReporter,
9
- ApplicationBuildResult,
10
- } from "./applicationBuildReporter";
11
- import type { App } from "./commandDecorators";
12
- import { parseEnvFile, WorkspaceExecutor } from "./executors";
5
+ import { ProductionLockfile } from "../akanConfig/productionLockfile";
6
+ import type { App } from "../commandDecorators";
7
+ import { parseEnvFile, WorkspaceExecutor } from "../executors";
13
8
  import {
14
9
  AllRoutesBuilder,
15
10
  CsrArtifactBuilder,
@@ -18,13 +13,18 @@ import {
18
13
  precompressArtifacts,
19
14
  SsrBaseArtifactBuilder,
20
15
  VendorImportScanner,
21
- } from "./frontendBuild";
16
+ } from "../frontendBuild";
17
+ import { createServerEnvPlugin } from "../transforms/serverEnvPlugin";
18
+ import { ServerEnvProfile } from "../transforms/serverEnvProfile";
19
+ import { ProjectTypecheck } from "../typecheck/projectTypecheck";
20
+ import { Spinner } from "../util/spinner";
21
+ import type { BaseDevEnv, PackageJson } from "../workspace/types";
22
+ import type {
23
+ ApplicationBuildPhaseResult,
24
+ ApplicationBuildProgressReporter,
25
+ ApplicationBuildResult,
26
+ } from "./applicationBuildReporter";
22
27
  import { RouteJsBudget, type RouteJsBudgetMode, type RouteJsBudgetStatus, type RouteJsSize } from "./routeJsBudget";
23
- import { Spinner } from "./spinner";
24
- import { createServerEnvPlugin } from "./transforms/serverEnvPlugin";
25
- import { ServerEnvProfile } from "./transforms/serverEnvProfile";
26
- import { ProjectTypecheck } from "./typecheck/projectTypecheck";
27
- import type { BaseDevEnv, PackageJson } from "./types";
28
28
 
29
29
  export interface TypecheckOptions {
30
30
  clean?: boolean;
@@ -45,11 +45,15 @@ export type BuildPhaseId =
45
45
  | "budget"
46
46
  | "metadata";
47
47
 
48
+ type RouteJsMeasure = RouteJsBudgetStatus & { sizes: RouteJsSize[] };
49
+
48
50
  export type BuildPhaseResult = ApplicationBuildPhaseResult & { id: BuildPhaseId };
49
51
  export type BuildResult = ApplicationBuildResult;
50
52
  export type BuildProgressReporter = ApplicationBuildProgressReporter;
51
53
  export interface ApplicationBuildRunnerOptions {
52
54
  fast?: boolean;
55
+ /** `akan verify`'s build stops after the SSR route compile and the route JS budget, so its `dist/` is not deployable. */
56
+ verify?: boolean;
53
57
  reporter?: BuildProgressReporter;
54
58
  /** The backend env the build is for, when it is not the workspace's own (a mobile or desktop build's `--env`). */
55
59
  environment?: string;
@@ -101,6 +105,7 @@ export const AKAN_OPTIONAL_BACKEND_EXTERNALS = ["bullmq", "ioredis", "postgres",
101
105
  export class ApplicationBuildRunner {
102
106
  #app: App;
103
107
  #fast: boolean;
108
+ #verify: boolean;
104
109
  #reporter?: BuildProgressReporter;
105
110
  #environment?: string;
106
111
  #profile?: string;
@@ -112,10 +117,18 @@ export class ApplicationBuildRunner {
112
117
 
113
118
  constructor(
114
119
  app: App,
115
- { fast = false, reporter, environment, profile, budget = "report" }: ApplicationBuildRunnerOptions = {},
120
+ {
121
+ fast = false,
122
+ verify = false,
123
+ reporter,
124
+ environment,
125
+ profile,
126
+ budget = "report",
127
+ }: ApplicationBuildRunnerOptions = {},
116
128
  ) {
117
129
  this.#app = app;
118
- this.#fast = fast;
130
+ this.#fast = fast || verify;
131
+ this.#verify = verify;
119
132
  this.#reporter = reporter;
120
133
  this.#environment = environment;
121
134
  this.#profile = profile;
@@ -177,6 +190,11 @@ export class ApplicationBuildRunner {
177
190
  ? "skipped"
178
191
  : "disabled by akan.config.ts web.ssr",
179
192
  );
193
+ if (this.#verify) {
194
+ const routeJs = await this.#runBudgetPhase(environment);
195
+ await this.#app.dist.writeJson("akan.build.json", { profile: "verify", builtAt: new Date().toISOString() });
196
+ return this.#resultOf(environment, routeJs);
197
+ }
180
198
  await this.#runPhase(
181
199
  "csr",
182
200
  "Building CSR assets",
@@ -201,13 +219,21 @@ export class ApplicationBuildRunner {
201
219
  ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}`
202
220
  : "no files",
203
221
  );
204
- const routeJs = await this.#runPhase(
222
+ const routeJs = await this.#runBudgetPhase(environment);
223
+ await this.#runPhase("metadata", "Writing production metadata", () => this.buildAppMeta());
224
+ return this.#resultOf(environment, routeJs);
225
+ }
226
+
227
+ #runBudgetPhase(environment: string) {
228
+ return this.#runPhase(
205
229
  "budget",
206
230
  "Measuring route JS",
207
231
  () => this.#measureRouteJs(environment),
208
232
  (result) => result?.summary ?? (this.#budget === "off" ? "off for this build" : "no server pages"),
209
233
  );
210
- await this.#runPhase("metadata", "Writing production metadata", () => this.buildAppMeta());
234
+ }
235
+
236
+ #resultOf(environment: string, routeJs: RouteJsMeasure | null): BuildResult {
211
237
  return {
212
238
  phases: this.#phases,
213
239
  ...(routeJs ? { routeJs: routeJs.sizes } : {}),
@@ -341,6 +367,13 @@ export class ApplicationBuildRunner {
341
367
  return this.#serverEnv;
342
368
  }
343
369
 
370
+ //? `bun main.js` in dist/apps/<app> is a documented way to run a build, and a verify output has no CSR bundle or
371
+ //? production env file, so its main.js refuses to boot before any app module runs.
372
+ #verifyBanner() {
373
+ const message = `dist/apps/${this.#app.name} holds the partial output of akan verify, not a build. Run \`akan build ${this.#app.name}\` first.`;
374
+ return `console.error(${JSON.stringify(message)});process.exit(1);`;
375
+ }
376
+
344
377
  async #buildBackend() {
345
378
  const { externalLibs, web, baseDevEnv, branches } = await this.#app.getConfig();
346
379
  const backendEntryPoints = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
@@ -362,7 +395,11 @@ export class ApplicationBuildRunner {
362
395
  };
363
396
  //* Built apart so main.js keeps its own module copies; splitting moves lazy vendor `import()`s out of the boot parse.
364
397
  const [mainResult, serverResult] = [
365
- await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[0]] }),
398
+ await this.#buildOrThrow("backend", {
399
+ ...backendConfig,
400
+ entrypoints: [backendEntryPoints[0]],
401
+ ...(this.#verify ? { banner: this.#verifyBanner() } : {}),
402
+ }),
366
403
  await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[1]], splitting: true }),
367
404
  ];
368
405
  // Nothing spawns the RSC worker without SSR, so an api-only image does not carry it.
@@ -450,12 +487,14 @@ void run().catch((error) => {
450
487
  return { base, allRoutes };
451
488
  }
452
489
 
453
- //? After `compress`: a route is measured by the brotli bytes it is served as, read from the `.br` sidecars.
454
- async #measureRouteJs(environment: string): Promise<(RouteJsBudgetStatus & { sizes: RouteJsSize[] }) | null> {
490
+ //? After `compress`: a route is measured by the brotli bytes it is served as, read from the `.br` sidecars, which a
491
+ //? verify build skips writing and measures in memory instead.
492
+ async #measureRouteJs(environment: string): Promise<RouteJsMeasure | null> {
455
493
  if (this.#budget === "off" || !this.#modulesByRoute) return null;
456
494
  const sizes = await RouteJsBudget.measure(
457
495
  path.join(this.#app.dist.cwdPath, ".akan/artifact"),
458
496
  this.#modulesByRoute,
497
+ { precompressed: !this.#verify },
459
498
  );
460
499
  const budgetPath = path.join(this.#app.cwdPath, RouteJsBudget.fileName);
461
500
  const { summary: status, warnings } = await RouteJsBudget.check(sizes, {
@@ -23,7 +23,7 @@ export async function resolveSignalTestPreloadPath(target: SignalTestPreloadTarg
23
23
  path.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH),
24
24
  path.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH),
25
25
  path.join(path.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH),
26
- path.resolve(import.meta.dir, "../../akanjs", SIGNAL_TEST_PRELOAD_PATH),
26
+ path.resolve(import.meta.dir, "../../../akanjs", SIGNAL_TEST_PRELOAD_PATH),
27
27
  );
28
28
 
29
29
  const uniqueCandidates = [...new Set(candidates)];
@@ -1,7 +1,9 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
+ import type { App } from "../commandDecorators";
4
+ import { precompressArtifacts } from "../frontendBuild/precompressArtifacts";
5
+ import { tempDirs, writeText as write } from "../test/testHelpers";
3
6
  import { RouteJsBudget, type RouteJsSize } from "./routeJsBudget";
4
- import { tempDirs, writeText as write } from "./testHelpers";
5
7
 
6
8
  const makeTempRoot = tempDirs("akan-route-js-");
7
9
  const size = (routeId: string, brotliKB: number): RouteJsSize => ({
@@ -31,6 +33,20 @@ describe("RouteJsBudget", () => {
31
33
  ]);
32
34
  });
33
35
 
36
+ test("sizes a file without its sidecar as precompressArtifacts compresses it, for a build that skips that step", async () => {
37
+ const distPath = await makeTempRoot();
38
+ const artifactDir = path.join(distPath, ".akan/artifact");
39
+ await write(path.join(artifactDir, "client/page.js"), `export const x = ${JSON.stringify("page ".repeat(900))};`);
40
+ await write(path.join(artifactDir, "client/tiny.js"), "t".repeat(200));
41
+ const modulesByRoute = { "/:lang": ["/_akan/client/page.js", "/_akan/client/tiny.js"] };
42
+
43
+ const inMemory = await RouteJsBudget.measure(artifactDir, modulesByRoute, { precompressed: false });
44
+ await precompressArtifacts({ dist: { cwdPath: distPath }, verbose: () => undefined } as unknown as App);
45
+
46
+ expect(inMemory).toEqual(await RouteJsBudget.measure(artifactDir, modulesByRoute));
47
+ expect(inMemory[0]?.brotliBytes).toBeLessThan(inMemory[0]?.rawBytes ?? 0);
48
+ });
49
+
34
50
  test("fails only a route past its entry plus the larger of 1% and 4KB, and leaves a route without one to the report", () => {
35
51
  const budget = RouteJsBudget.parse(
36
52
  JSON.stringify({ routeJsBrotliKB: { "/:lang": 100, "/:lang/memo": 120, "/:lang/feed": 500 } }),
@@ -1,7 +1,8 @@
1
1
  import path from "node:path";
2
2
  import { toError } from "akanjs/common";
3
- import { FontPruner } from "./frontendBuild/fontPruner";
4
- import { JsonFormatter } from "./jsonFormatter";
3
+ import { FontPruner } from "../frontendBuild/fontPruner";
4
+ import { servedBrotliBytesOf } from "../frontendBuild/precompressArtifacts";
5
+ import { JsonFormatter } from "../util/jsonFormatter";
5
6
 
6
7
  export interface RouteJsSize {
7
8
  routeId: string;
@@ -58,11 +59,16 @@ export class RouteJsBudget {
58
59
  static readonly #absoluteSlack = 4096;
59
60
 
60
61
  //? A file under 1 KB has no `.br` sidecar (precompressArtifacts skips it), so it is served, and counted, raw.
61
- static async measure(artifactDir: string, modulesByRoute: Record<string, string[]>): Promise<RouteJsSize[]> {
62
+ static async measure(
63
+ artifactDir: string,
64
+ modulesByRoute: Record<string, string[]>,
65
+ { precompressed = true }: { precompressed?: boolean } = {},
66
+ ): Promise<RouteJsSize[]> {
62
67
  const sizeByUrl = new Map<string, { raw: number; brotli: number }>();
63
68
  const sizeOf = async (url: string) => {
64
69
  const file = path.join(artifactDir, url.replace(/^\/_akan\//, ""));
65
70
  const raw = Bun.file(file).size;
71
+ if (!precompressed) return { raw, brotli: await servedBrotliBytesOf(artifactDir, file) };
66
72
  const sidecar = Bun.file(`${file}.br`);
67
73
  return { raw, brotli: (await sidecar.exists()) ? sidecar.size : raw };
68
74
  };
@@ -20,6 +20,23 @@ describe("RouteSourceValidator", () => {
20
20
  expect(() => validate(source, "layout", true)).not.toThrow();
21
21
  });
22
22
 
23
+ test("refuses an export only the generated root layout defines on an app's root layout, which it would ignore", () => {
24
+ const layout = "export default function Layout({ children }) { return children; }";
25
+ for (const source of [
26
+ `${layout}\nexport const LevelBoundary = ({ children }) => children;`,
27
+ `${layout}\nexport { Boundary as LevelBoundary } from "./boundary";`,
28
+ `${layout}\nexport function McpAppRoot({ children }) { return children; }`,
29
+ ]) {
30
+ const name = source.includes("McpAppRoot") ? "McpAppRoot" : "LevelBoundary";
31
+ expect(() => validate(source, "layout", true)).toThrow(
32
+ `unsupported export "${name}" in page/_layout.tsx: ${name} belongs to the root layout Akan.js generates, which never reads one from an app's layout`,
33
+ );
34
+ expect(() => validate(source, "layout")).toThrow(
35
+ new RegExp(`unsupported export "${name}" in page/_layout\\.tsx$`),
36
+ );
37
+ }
38
+ });
39
+
23
40
  test("rejects root-layout-only exports on a nested layout and on a page", () => {
24
41
  const source = ["export default function Layout() { return null; }", "export const wsConnect = true;"].join("\n");
25
42
 
@@ -1,4 +1,4 @@
1
- import { getRouteExports } from "akanjs/common";
1
+ import { GENERATED_ROOT_LAYOUT_EXPORTS, getRouteExports } from "akanjs/common";
2
2
  import ts from "typescript";
3
3
 
4
4
  /** What the build needs out of a route module without evaluating it. */
@@ -43,6 +43,10 @@ export class RouteSourceValidator {
43
43
  const allowed = getRouteExports(kind, { rootLayout: options.rootLayout });
44
44
  const exported = new Set<string>();
45
45
  const assertExport = (name: string) => {
46
+ if (options.rootLayout && GENERATED_ROOT_LAYOUT_EXPORTS.has(name))
47
+ throw new Error(
48
+ `[route-convention] unsupported export "${name}" in ${filePath}: ${name} belongs to the root layout Akan.js generates, which never reads one from an app's layout`,
49
+ );
46
50
  if (!allowed.has(name)) {
47
51
  throw new Error(`[route-convention] unsupported export "${name}" in ${filePath}`);
48
52
  }
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { tempDirs, writeText as write } from "../testHelpers";
3
+ import { tempDirs, writeText as write } from "../test/testHelpers";
4
4
  import { resolveSsrPageEntries } from "./implicitRootLayout";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-implicit-root-layout-");
@@ -53,11 +53,74 @@ describe("resolveSsrPageEntries", () => {
53
53
  // Its guard runs from that level too, ahead of this one, and an MCP view takes its providers from there.
54
54
  expect(generatedSource).toContain("export const guard = userLayout.guard;");
55
55
  expect(generatedSource).not.toContain("McpAppRoot");
56
+ expect(generatedSource).not.toContain("LevelBoundary");
56
57
  expect(generatedSource).toContain(
57
58
  "<UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>",
58
59
  );
59
60
  });
60
61
 
62
+ test("bounds the System root layout's own content inside System.Provider, for a server render only", async () => {
63
+ const appRoot = await makeTempRoot();
64
+ await write(path.join(appRoot, "env", "env.client.ts"), "export const env = {};\n");
65
+ await write(
66
+ path.join(appRoot, "page", "_layout.tsx"),
67
+ "export default function Layout({ children }) { return children; }\n",
68
+ );
69
+ await write(
70
+ path.join(appRoot, "page", "(home)", "_layout.tsx"),
71
+ "export default function Layout({ children }) { return children; }\n",
72
+ );
73
+
74
+ const entries = await resolveSsrPageEntries({
75
+ appCwdPath: appRoot,
76
+ appName: "demo",
77
+ pageKeys: ["./_layout.tsx", "./(home)/_layout.tsx", "./(home)/_index.tsx"],
78
+ });
79
+
80
+ const source = await Bun.file(
81
+ entries.find((entry) => entry.key === "./__root_layout.tsx")?.moduleAbsPath ?? "",
82
+ ).text();
83
+ expect(source).toContain('import { RouteLevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";');
84
+ expect(source).toContain(
85
+ " const layout = <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;\n return (\n <System.Provider",
86
+ );
87
+ expect(source).toContain(
88
+ ' >\n {process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? layout : <RouteLevelBoundary>{layout}</RouteLevelBoundary>}\n </System.Provider>',
89
+ );
90
+ expect(source.match(/<RouteLevelBoundary>/g)).toHaveLength(1);
91
+ expect(source.slice(source.indexOf("export function McpAppRoot"))).not.toContain("RouteLevelBoundary");
92
+
93
+ const nested = await Bun.file(
94
+ entries.find((entry) => entry.key === "./(home)/__root_layout.tsx")?.moduleAbsPath ?? "",
95
+ ).text();
96
+ expect(nested).not.toContain("RouteLevelBoundary");
97
+ });
98
+
99
+ test("leaves the boundary out of a CSR build, which an MCP App view's namespace import of the layout shares", async () => {
100
+ const appRoot = await makeTempRoot();
101
+ await write(path.join(appRoot, "env", "env.client.ts"), "export const env = {};\n");
102
+ await write(path.join(appRoot, "page", "_layout.tsx"), "export default ({ children }) => children;\n");
103
+ const entries = await resolveSsrPageEntries({
104
+ appCwdPath: appRoot,
105
+ appName: "demo",
106
+ pageKeys: ["./_layout.tsx", "./_index.tsx"],
107
+ });
108
+ const source = await Bun.file(
109
+ entries.find((entry) => entry.key === "./__root_layout.tsx")?.moduleAbsPath ?? "",
110
+ ).text();
111
+ const compiled = (renderEnv: "csr" | "ssr") =>
112
+ new Bun.Transpiler({
113
+ loader: "tsx",
114
+ define: { "process.env.AKAN_PUBLIC_RENDER_ENV": JSON.stringify(renderEnv) },
115
+ trimUnusedImports: true,
116
+ }).transformSync(source);
117
+
118
+ expect(compiled("csr")).toContain("export const LevelBoundary = undefined;");
119
+ expect(compiled("csr")).not.toMatch(/\bRouteLevelBoundary\b(?!\.tsx)/);
120
+ expect(compiled("ssr")).toContain("export const LevelBoundary = RouteLevelBoundary;");
121
+ expect(compiled("ssr")).toMatch(/import \{ ?RouteLevelBoundary ?\} from "akanjs\/webkit\/RouteLevelBoundary\.tsx"/);
122
+ });
123
+
61
124
  test("keeps system provider for grouped root boundaries without an ancestor root", async () => {
62
125
  const appRoot = await makeTempRoot();
63
126
  const pageRoot = path.join(appRoot, "page");
@@ -87,6 +150,9 @@ describe("resolveSsrPageEntries", () => {
87
150
  );
88
151
  expect(generatedSource).toContain("export function McpAppRoot({ children, params, path }: McpAppRootProps) {");
89
152
  expect(generatedSource).toContain("<System.App");
153
+ expect(generatedSource).toContain(
154
+ 'export const LevelBoundary = process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? undefined : RouteLevelBoundary;',
155
+ );
90
156
  expect(generatedSource).toContain('import { allDictionary } from "../dict/useDict.ts";');
91
157
  expect(generatedSource).toContain(
92
158
  'allDictionary={process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? allDictionary : undefined}',
@@ -170,7 +236,9 @@ describe("resolveSsrPageEntries", () => {
170
236
  expect(userSource).toContain('process.env.AKAN_PUBLIC_RENDER_ENV === "csr"');
171
237
  expect(userSource).toContain("? await UserLayout({ params, searchParams, children })");
172
238
  expect(userSource).toContain(": <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;");
173
- expect(userSource).toContain(" {layout}\n </System.Provider>");
239
+ expect(userSource).toContain(
240
+ ' {process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? layout : <RouteLevelBoundary>{layout}</RouteLevelBoundary>}\n </System.Provider>',
241
+ );
174
242
 
175
243
  const signRoot = entries.find((entry) => entry.key === "./(sign)/__root_layout.tsx");
176
244
  const signSource = await Bun.file(signRoot?.moduleAbsPath ?? "").text();
@@ -178,7 +246,7 @@ describe("resolveSsrPageEntries", () => {
178
246
  expect(signSource).toContain("export default function GeneratedLayout(");
179
247
  expect(signSource).not.toContain("await UserLayout(");
180
248
  expect(signSource).toContain(
181
- " <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>\n </System.Provider>",
249
+ " const layout = <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;\n",
182
250
  );
183
251
  });
184
252
 
@@ -199,8 +199,9 @@ async function writeGeneratedRootLayoutFile(opts: {
199
199
  ? await UserLayout({ params, searchParams, children })
200
200
  : ${userLayoutElement};
201
201
  `
202
- : "";
203
- const layoutChild = isAsyncUserLayout ? "{layout}" : userLayoutElement;
202
+ : opts.includeSystemProvider
203
+ ? ` const layout = ${userLayoutElement};\n`
204
+ : "";
204
205
  const layoutReturn = isAsyncUserLayout ? "layout" : userLayoutElement;
205
206
  //? Under an ancestor root boundary the route tree merges that root's head itself; merging it here would repeat it.
206
207
  const headLayouts = opts.includeSystemProvider ? "[inheritedLayout, userLayout]" : "[userLayout]";
@@ -225,12 +226,16 @@ ${layoutSignature}({ children, params, searchParams }: LayoutProps) {
225
226
  ${layoutBinding} return `;
226
227
  //? System from its file, not the barrel: a dev registry compiles every module the barrel names, and with them the
227
228
  //? optional peers (react-icons) an app drawing none of those components never installs.
229
+ //? The root level's boundary sits inside System.Provider, beside the bridge that starts the router its retry calls.
230
+ //? A CSR render has none: RenderLayer draws a failed level there, and a route control also carries a digest.
231
+ //? Its export is undefined there too, so the `import * as root` of an MCP App view, built as CSR, drops it.
228
232
  const source = opts.includeSystemProvider
229
233
  ? `import type { LayoutModule, LayoutProps, PageProps } from "akanjs/client";
230
234
  import { assertGuardOnChain, loadFonts, RouteGuards, resolveRouteModule, RouteHead } from "akanjs/client";
231
235
  import type { ReactNode } from "react";
232
236
  import { System } from "${ROOT_LAYOUT_SYSTEM.specifier}";
233
237
  import type { McpAppRootProps } from "akanjs/webkit";
238
+ import { RouteLevelBoundary } from "akanjs/webkit/RouteLevelBoundary.tsx";
234
239
  import { env } from "@apps/${opts.appName}/env/env.client";
235
240
  import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
236
241
  ${storeImport}${inheritedImport}${userImport}
@@ -242,6 +247,7 @@ const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${d
242
247
  export const theme = userLayout.theme ?? inheritedLayout.theme;
243
248
  export const viewport = userLayout.viewport ?? inheritedLayout.viewport;
244
249
  export const manifest = userLayout.manifest ?? inheritedLayout.manifest;
250
+ export const LevelBoundary = process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? undefined : RouteLevelBoundary;
245
251
 
246
252
  ${layoutExports}(
247
253
  <System.Provider
@@ -259,7 +265,7 @@ ${layoutExports}(
259
265
  wsConnect={userLayout.wsConnect ?? inheritedLayout.wsConnect}
260
266
  allDictionary={process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? allDictionary : undefined}
261
267
  >
262
- ${layoutChild}
268
+ {process.env.AKAN_PUBLIC_RENDER_ENV === "csr" ? layout : <RouteLevelBoundary>{layout}</RouteLevelBoundary>}
263
269
  </System.Provider>
264
270
  );
265
271
  }