@akanjs/devkit 3.2.0-rc.9 → 3.3.0-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 (341) hide show
  1. package/CHANGELOG.md +57 -516
  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 +132 -3
  7. package/akanApp/akanApp.host.ts +146 -1216
  8. package/akanApp/akanApp.host.wiring.test.ts +727 -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 +392 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +196 -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/processRss.ts +61 -0
  22. package/akanConfig/akanConfig.test.ts +45 -17
  23. package/akanConfig/akanConfig.ts +10 -10
  24. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  25. package/akanConfig/productionLockfile.ts +1 -1
  26. package/apiReport/apiReport.test.ts +34 -3
  27. package/apiReport/apiReportDiff.ts +35 -1
  28. package/apiReport/apiReportPolicy.ts +3 -2
  29. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +2 -49
  30. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +71 -8
  31. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +60 -21
  32. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  33. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +17 -1
  34. package/{routeJsBudget.ts → app/routeJsBudget.ts} +9 -3
  35. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  36. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  37. package/artifact/implicitRootLayout.test.ts +71 -3
  38. package/artifact/implicitRootLayout.ts +9 -3
  39. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  40. package/biome.base.json +2 -1
  41. package/cloud/cloudApi.test.ts +1 -1
  42. package/cloud/configLock.test.ts +1 -1
  43. package/cloud/globalConfig.test.ts +1 -1
  44. package/cloud/globalConfig.ts +1 -1
  45. package/cloud/updatePackUpload.test.ts +1 -1
  46. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  47. package/codeAgent/agent/AkanCodeServices.ts +23 -0
  48. package/codeAgent/agent/akanCodePaths.ts +1 -1
  49. package/codeAgent/agent/akanCodeServices.test.ts +54 -0
  50. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  51. package/codeAgent/agent/codeAgent.test.ts +1 -1
  52. package/codeAgent/skills/akan-debug/SKILL.md +8 -5
  53. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  54. package/codeAgent/skills/akan-mcp/SKILL.md +19 -1
  55. package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
  56. package/codeAgent/skills/akan-validate/SKILL.md +3 -3
  57. package/codeAgent/tools/AkanCli.ts +1 -1
  58. package/codeAgent/tools/AkanToolPack.ts +2 -2
  59. package/codeAgent/tools/akanCodePlugins.test.ts +1 -1
  60. package/commandDecorators/command.ts +35 -6
  61. package/commandDecorators/commandBuilder.ts +1 -1
  62. package/commandDecorators/commandDecorators.test.ts +107 -6
  63. package/commandDecorators/targetMeta.ts +2 -0
  64. package/commandDecorators/workspaceVersionCheck.test.ts +70 -1
  65. package/commandDecorators/workspaceVersionCheck.ts +64 -14
  66. package/context/akanContext.ts +576 -0
  67. package/context/akanContextInspection.ts +296 -0
  68. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  69. package/{akanMcpContract.ts → context/akanMcpContract.ts} +16 -256
  70. package/context/doctor/agentGuideCheck.ts +81 -0
  71. package/context/doctor/configLeftoverCheck.ts +35 -0
  72. package/context/doctor/doctorFindings.ts +70 -0
  73. package/context/doctor/generatedFreshness.ts +56 -0
  74. package/context/doctor/moduleShapeCheck.ts +88 -0
  75. package/context/doctor/recipeDuplicateCheck.ts +42 -0
  76. package/context/doctor/recipeIndexCheck.ts +87 -0
  77. package/context/doctor/rootShapeCheck.ts +55 -0
  78. package/context/doctor/workflowScope.ts +97 -0
  79. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  80. package/context/safeRead.ts +9 -0
  81. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  82. package/devkitUtils.test.ts +39 -5
  83. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  84. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  85. package/docs/errorCodeReference.test.ts +282 -0
  86. package/docs/errorCodeReference.ts +71 -0
  87. package/docs/errorCodeScan.ts +551 -0
  88. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  89. package/executors/appExecutor.ts +448 -0
  90. package/executors/commandExecutionError.ts +53 -0
  91. package/executors/executor.ts +527 -0
  92. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  93. package/{executors.test.ts → executors/executors.test.ts} +76 -15
  94. package/executors/index.ts +8 -0
  95. package/executors/libExecutor.ts +23 -0
  96. package/executors/moduleExecutor.ts +18 -0
  97. package/executors/pkgExecutor.ts +129 -0
  98. package/executors/sysExecutor.ts +301 -0
  99. package/executors/workspaceExecutor.ts +277 -0
  100. package/frontendBuild/allRoutesBuilder.test.ts +1 -1
  101. package/frontendBuild/autoImportSync.test.ts +1 -1
  102. package/frontendBuild/autoImportSync.ts +1 -1
  103. package/frontendBuild/buildRouteClient.test.ts +1 -1
  104. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  105. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  106. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  107. package/frontendBuild/cssCompiler.test.ts +3 -2
  108. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  109. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  110. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  111. package/frontendBuild/fontOptimizer.test.ts +1 -1
  112. package/frontendBuild/fontPruner.test.ts +1 -1
  113. package/frontendBuild/frontendBuild.test.ts +3 -3
  114. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  115. package/frontendBuild/hmrWatcher.test.ts +1 -1
  116. package/frontendBuild/hmrWatcher.ts +22 -1
  117. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  118. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  119. package/frontendBuild/nativeCore.test.ts +1 -1
  120. package/frontendBuild/optionalPeers.test.ts +36 -8
  121. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  122. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  123. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  124. package/frontendBuild/precompressArtifacts.ts +19 -6
  125. package/frontendBuild/serverGraphFile.ts +1 -1
  126. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  127. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  128. package/frontendBuild/vendorImportScanner.test.ts +1 -1
  129. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  130. package/frontendBuild/watchRootResolver.test.ts +1 -1
  131. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  132. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  133. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  134. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  135. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  136. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  137. package/{prompter.ts → guideline/prompter.ts} +2 -3
  138. package/incrementalBuilder/buildBatch.proc.ts +14 -4
  139. package/incrementalBuilder/buildBatchProtocol.ts +2 -0
  140. package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
  141. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  142. package/incrementalBuilder/builderBoot.ts +106 -0
  143. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  144. package/incrementalBuilder/builderChannel.test.ts +1 -1
  145. package/incrementalBuilder/builderChannel.ts +11 -0
  146. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  147. package/incrementalBuilder/builderLanes.ts +157 -0
  148. package/incrementalBuilder/builderWatch.ts +213 -0
  149. package/incrementalBuilder/csrRegistry.ts +234 -0
  150. package/incrementalBuilder/incrementalBuilder.proc.test.ts +101 -7
  151. package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
  152. package/incrementalBuilder/ssrRegistry.ts +282 -0
  153. package/index.ts +22 -22
  154. package/integration/devStability.integration.test.ts +62 -56
  155. package/integration/devStabilityHarness.test.ts +1 -1
  156. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  157. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  158. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  159. package/lint/gritRules.test.ts +1 -1
  160. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  161. package/lint/no-import-common-err.grit +31 -0
  162. package/lint/no-init-fetch-in-client.grit +1 -1
  163. package/mobile/desktopBin.test.ts +1 -1
  164. package/mobile/desktopRelease.test.ts +1 -1
  165. package/mobile/desktopServerStage.test.ts +2 -2
  166. package/mobile/desktopServerStage.ts +1 -1
  167. package/mobile/nativeApi.test.ts +1 -1
  168. package/mobile/nativeApp.test.ts +1 -1
  169. package/mobile/nativeConfig.test.ts +1 -1
  170. package/mobile/nativePluginFolders.test.ts +1 -1
  171. package/mobile/nativePublicEnv.test.ts +1 -1
  172. package/mobile/nativeWebDir.test.ts +1 -1
  173. package/mobile/serverBundleSecrets.test.ts +1 -1
  174. package/mobile/tarWriter.test.ts +1 -1
  175. package/mobile/updatePackFolder.test.ts +1 -1
  176. package/package.json +173 -9
  177. package/packageExports.test.ts +20 -2
  178. package/piDependencyPins.test.ts +1 -1
  179. package/pipeline/PipelineDefinition.ts +1 -1
  180. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  181. package/platformTest/LinuxDockerTarget.ts +1 -1
  182. package/platformTest/PlatformTestRun.test.ts +1 -1
  183. package/platformTest/TestSnapshot.test.ts +1 -1
  184. package/platformTest/WindowsSshTarget.ts +1 -1
  185. package/preview/previewView.test.ts +23 -1
  186. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  187. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  188. package/quality/bareErrorScanner.ts +126 -0
  189. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  190. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  191. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  192. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  193. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  194. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  195. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  196. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  197. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +41 -1
  198. package/{qualityScanner.ts → quality/qualityScanner.ts} +25 -91
  199. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  200. package/quality/workspaceSourceFiles.ts +82 -0
  201. package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
  202. package/{subspace.ts → subspace/subspace.ts} +5 -5
  203. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  204. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  205. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  206. package/transforms/barrelAnalyzer.ts +31 -10
  207. package/transforms/browserDirnamePlugin.test.ts +1 -1
  208. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  209. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  210. package/transforms/pureLazyMarker.test.ts +1 -1
  211. package/transforms/serverEnvPlugin.test.ts +1 -1
  212. package/transforms/serverEnvProfile.test.ts +1 -1
  213. package/transforms/sideEffectImportOrder.test.ts +1 -1
  214. package/transforms/transforms.test.ts +52 -2
  215. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  216. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  217. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  218. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  219. package/typecheck/projectTypecheck.test.ts +23 -1
  220. package/typecheck/projectTypecheck.ts +10 -2
  221. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  222. package/{typeChecker.ts → typecheck/typeChecker.ts} +5 -4
  223. package/typecheck/typecheck.proc.ts +6 -2
  224. package/typecheck/typecheckFailure.ts +1 -1
  225. package/util/errorReport.ts +66 -0
  226. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  227. package/workflow/constantSource.ts +187 -0
  228. package/workflow/dictionarySource.ts +184 -0
  229. package/workflow/executor.ts +6 -9
  230. package/workflow/fieldExpression.ts +153 -0
  231. package/workflow/fieldLabel.ts +61 -0
  232. package/workflow/fieldOrder.ts +117 -0
  233. package/workflow/fieldType.ts +2 -1
  234. package/workflow/guardCatalog.test.ts +1 -1
  235. package/workflow/keyRename.ts +1 -1
  236. package/workflow/moduleIndex.test.ts +2 -2
  237. package/workflow/moduleIndex.ts +2 -2
  238. package/workflow/modulePaths.ts +27 -0
  239. package/workflow/mutationScaffold.ts +7 -15
  240. package/workflow/mutationSource.ts +2 -1
  241. package/workflow/plan.ts +2 -1
  242. package/workflow/primitiveReport.ts +78 -0
  243. package/workflow/rolloutGate.test.ts +1 -1
  244. package/workflow/rolloutGate.ts +1 -1
  245. package/workflow/serviceSource.ts +33 -0
  246. package/workflow/signalSource.ts +96 -0
  247. package/workflow/source.ts +50 -1100
  248. package/workflow/sourceAst.ts +30 -0
  249. package/workflow/sourceImports.ts +105 -0
  250. package/workflow/sourceText.ts +13 -0
  251. package/workflow/templateSource.ts +30 -0
  252. package/workflow/testSource.ts +31 -0
  253. package/workflow/types.ts +1 -1
  254. package/workflow/uiPolicy.ts +1 -1
  255. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  256. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  257. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  258. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  259. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  260. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  261. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  262. package/{libSource.ts → workspace/libSource.ts} +1 -1
  263. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  264. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  265. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  266. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
  267. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
  268. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  269. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  270. package/akanContext.ts +0 -1083
  271. package/executors.ts +0 -1749
  272. /package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +0 -0
  273. /package/{akanMcpToolError.ts → context/akanMcpToolError.ts} +0 -0
  274. /package/{moduleFieldNames.test.ts → context/moduleFieldNames.test.ts} +0 -0
  275. /package/{moduleFieldNames.ts → context/moduleFieldNames.ts} +0 -0
  276. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  277. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  278. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  279. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  280. /package/{linter.ts → lint/linter.ts} +0 -0
  281. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  282. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  283. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  284. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  285. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  286. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  287. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  288. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  289. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  290. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  291. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  292. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  293. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  294. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  295. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  296. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  297. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  298. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  299. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  300. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  301. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  302. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  303. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  304. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  305. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  306. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  307. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  308. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  309. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  310. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  311. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  312. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  313. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  314. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  315. /package/{writePath.ts → quality/writePath.ts} +0 -0
  316. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  317. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  318. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  319. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  320. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  321. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  322. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  323. /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
  324. /package/{fileSys.ts → util/fileSys.ts} +0 -0
  325. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  326. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  327. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  328. /package/{semver.ts → util/semver.ts} +0 -0
  329. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  330. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  331. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  332. /package/{spinner.ts → util/spinner.ts} +0 -0
  333. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  334. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  335. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  336. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  337. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  338. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  339. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  340. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  341. /package/{types.ts → workspace/types.ts} +0 -0
@@ -0,0 +1,35 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import type { AkanSysContext } from "../akanContext";
4
+ import { safeReadText } from "../safeRead";
5
+ import type { DoctorFindings } from "./doctorFindings";
6
+
7
+ export class ConfigLeftoverCheck {
8
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
9
+ const sysPaths = systems.map((sys) => sys.path);
10
+ for (const leftover of await ConfigLeftoverCheck.#leftovers(workspace, sysPaths))
11
+ findings.push({ severity: "warning", code: "config-leftover", ...leftover });
12
+ }
13
+
14
+ //? Older templates wrote these for Next.js: nothing installs or reads them, and editors warn about the plugin.
15
+ static async #leftovers(workspace: WorkspaceExecutor, sysPaths: string[]) {
16
+ const leftovers: { path: string; message: string }[] = [];
17
+ for (const sysPath of sysPaths) {
18
+ const tsconfigPath = `${sysPath}/tsconfig.json`;
19
+ const tsconfig = await safeReadText(path.join(workspace.workspaceRoot, tsconfigPath));
20
+ if (tsconfig && (/"name"\s*:\s*"next"/.test(tsconfig) || tsconfig.includes(".next/types")))
21
+ leftovers.push({
22
+ path: tsconfigPath,
23
+ message: `${tsconfigPath} still names the Next.js TS plugin or .next/types, which Akan never uses — delete the "next" plugin entry and the ".next/types/**/*.ts" include.`,
24
+ });
25
+ }
26
+ const bunfig = await safeReadText(path.join(workspace.workspaceRoot, "bunfig.toml"));
27
+ if (bunfig?.includes("bun-plugin-tailwind"))
28
+ leftovers.push({
29
+ path: "bunfig.toml",
30
+ message:
31
+ "bunfig.toml still loads bun-plugin-tailwind, which is not installed and which Akan never uses (it compiles Tailwind itself) — delete the [serve.static] section, which Akan never reads.",
32
+ });
33
+ return leftovers;
34
+ }
35
+ }
@@ -0,0 +1,70 @@
1
+ import type { WorkspaceExecutor } from "../../executors";
2
+ import type { RepairAction } from "../../workflow";
3
+ import type { AkanDiagnostic, AkanDoctorResult, AkanWorkspaceContext } from "../akanContext";
4
+ import { generatedFreshnessFromStates } from "./generatedFreshness";
5
+ import { isWorkflowRelatedDiagnostic } from "./workflowScope";
6
+
7
+ export const repairAction = (
8
+ kind: RepairAction["kind"],
9
+ command: string,
10
+ reason: string,
11
+ safeToRun: boolean,
12
+ ): RepairAction => ({
13
+ kind,
14
+ command,
15
+ reason,
16
+ safeToRun,
17
+ });
18
+
19
+ export class DoctorFindings {
20
+ readonly #diagnostics: AkanDiagnostic[] = [];
21
+ readonly #repairActions: RepairAction[] = [
22
+ repairAction("generated", "akan repair generated --app <app-or-lib>", "Refresh generated Akan files.", true),
23
+ repairAction(
24
+ "format",
25
+ "akan repair format --target <app-or-lib-or-pkg>",
26
+ "Run the formatter/linter repair path.",
27
+ true,
28
+ ),
29
+ ];
30
+
31
+ report(diagnostic: AkanDiagnostic, action: RepairAction) {
32
+ this.#diagnostics.push({ ...diagnostic, repairActions: [action] });
33
+ this.#repairActions.push(action);
34
+ }
35
+
36
+ push(diagnostic: AkanDiagnostic) {
37
+ this.#diagnostics.push(diagnostic);
38
+ }
39
+
40
+ async result(
41
+ workspace: WorkspaceExecutor,
42
+ context: AkanWorkspaceContext,
43
+ { strict, workflowPaths }: { strict: boolean; workflowPaths: string[] },
44
+ ): Promise<AkanDoctorResult> {
45
+ const scopedDiagnostics = this.#diagnostics.map((diagnostic) => ({
46
+ ...diagnostic,
47
+ scope: workflowPaths.length
48
+ ? isWorkflowRelatedDiagnostic(diagnostic, workflowPaths)
49
+ ? ("workflow" as const)
50
+ : ("baseline" as const)
51
+ : diagnostic.scope,
52
+ context: workflowPaths.length ? { ...diagnostic.context, paths: workflowPaths } : diagnostic.context,
53
+ }));
54
+ const workflowDiagnostics = scopedDiagnostics.filter((diagnostic) => diagnostic.scope === "workflow");
55
+ const baselineDiagnostics = scopedDiagnostics.filter((diagnostic) => diagnostic.scope === "baseline");
56
+ return {
57
+ schemaVersion: 1,
58
+ repoName: context.repoName,
59
+ root: context.root,
60
+ strict,
61
+ status: scopedDiagnostics.some((diagnostic) => diagnostic.severity === "error") ? "failed" : "passed",
62
+ diagnostics: scopedDiagnostics,
63
+ generatedFiles: context.generatedFiles,
64
+ generatedFilesFreshness: await generatedFreshnessFromStates(workspace),
65
+ validationCommands: context.validationCommands,
66
+ repairActions: this.#repairActions,
67
+ ...(workflowPaths.length ? { baselineDiagnostics, workflowDiagnostics } : {}),
68
+ };
69
+ }
70
+ }
@@ -0,0 +1,56 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import { type GeneratedSyncState, workflowSyncDir } from "../../workflow";
4
+ import type { GeneratedFilesFreshness } from "../akanContext";
5
+ import { safeReadDir, safeReadJson } from "../safeRead";
6
+
7
+ const unknownGeneratedFilesFreshness: GeneratedFilesFreshness = {
8
+ status: "unknown" as const,
9
+ message: "Run sync before validation so generated Akan files match the current source conventions.",
10
+ refreshCommand: "akan sync <app-or-lib>",
11
+ verifyingCommands: ["akan verify <app-or-lib>"],
12
+ };
13
+
14
+ const readGeneratedSyncStates = async (workspace: WorkspaceExecutor) => {
15
+ const syncDir = path.join(workspace.workspaceRoot, workflowSyncDir);
16
+ const entries = await safeReadDir(syncDir);
17
+ const states = await Promise.all(
18
+ entries
19
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
20
+ .map((entry) => safeReadJson<GeneratedSyncState>(path.join(syncDir, entry.name))),
21
+ );
22
+ return states.filter(
23
+ (state): state is GeneratedSyncState =>
24
+ !!state && state.schemaVersion === 1 && typeof state.target === "string" && typeof state.syncedAt === "string",
25
+ );
26
+ };
27
+
28
+ export const generatedFreshnessFromStates = async (workspace: WorkspaceExecutor): Promise<GeneratedFilesFreshness> => {
29
+ const states = await readGeneratedSyncStates(workspace);
30
+ if (states.length === 0) return unknownGeneratedFilesFreshness;
31
+ const targets = states
32
+ .sort((a, b) => a.target.localeCompare(b.target))
33
+ .map((state) => ({
34
+ target: state.target,
35
+ status: state.status === "passed" ? ("fresh" as const) : ("stale" as const),
36
+ lastSyncedAt: state.syncedAt,
37
+ runId: state.runId,
38
+ generatedFiles: state.generatedFiles.map((file) => file.path),
39
+ reason:
40
+ state.status === "passed"
41
+ ? `Generated files were refreshed by ${state.command}.`
42
+ : `Last generated repair command failed: ${state.command}.`,
43
+ }));
44
+ const lastFresh = targets
45
+ .filter((target) => target.status === "fresh" && target.lastSyncedAt)
46
+ .sort((a, b) => (b.lastSyncedAt ?? "").localeCompare(a.lastSyncedAt ?? ""))[0];
47
+ return {
48
+ status: targets.some((target) => target.status === "fresh") ? "fresh" : "stale",
49
+ message: lastFresh
50
+ ? `Generated files were refreshed for ${lastFresh.target} at ${lastFresh.lastSyncedAt}.`
51
+ : "Generated sync state exists, but the last recorded repair did not pass.",
52
+ refreshCommand: "akan sync <app-or-lib>",
53
+ verifyingCommands: ["akan verify <app-or-lib>"],
54
+ targets,
55
+ };
56
+ };
@@ -0,0 +1,88 @@
1
+ import path from "node:path";
2
+ import { capitalize } from "akanjs/common";
3
+ import type { WorkspaceExecutor } from "../../executors";
4
+ import type { AkanModuleContext, AkanSysContext } from "../akanContext";
5
+ import { unlabeledFieldNames } from "../moduleFieldNames";
6
+ import { safeReadText } from "../safeRead";
7
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
8
+
9
+ const moduleShapeFiles = (module: AkanModuleContext) => {
10
+ if (module.kind === "service") {
11
+ return [`${module.name}.dictionary.ts`, `${module.name}.service.ts`, `${module.name}.signal.ts`];
12
+ }
13
+ if (module.kind === "scalar") return [`${module.name}.constant.ts`, `${module.name}.dictionary.ts`];
14
+ return [
15
+ `${module.name}.constant.ts`,
16
+ `${module.name}.dictionary.ts`,
17
+ `${module.name}.service.ts`,
18
+ `${module.name}.store.ts`,
19
+ `${module.name}.signal.ts`,
20
+ ];
21
+ };
22
+
23
+ export class ModuleShapeCheck {
24
+ static async run(
25
+ workspace: WorkspaceExecutor,
26
+ systems: AkanSysContext[],
27
+ findings: DoctorFindings,
28
+ { strict }: { strict: boolean },
29
+ ) {
30
+ for (const sys of systems) {
31
+ for (const module of sys.modules) {
32
+ const moduleShapeCommand = `akan repair module-shape --app ${sys.name} --module ${module.name}`;
33
+ if (!module.abstract.exists)
34
+ findings.report(
35
+ {
36
+ severity: strict ? "error" : "warning",
37
+ code: "module-abstract-missing",
38
+ path: module.abstract.path,
39
+ message: `${capitalize(module.kind)} module ${sys.name}:${module.name} should include ${module.abstract.path}`,
40
+ },
41
+ repairAction(
42
+ "module-shape",
43
+ moduleShapeCommand,
44
+ "Create the missing module abstract or inspect required source files.",
45
+ false,
46
+ ),
47
+ );
48
+ const missingFiles = moduleShapeFiles(module).filter((filename) => !module.files.includes(filename));
49
+ if (missingFiles.length)
50
+ findings.report(
51
+ {
52
+ severity: "error",
53
+ code: "module-shape-invalid",
54
+ path: module.path,
55
+ message: `${capitalize(module.kind)} module ${sys.name}:${module.name} is missing required files: ${missingFiles.join(", ")}`,
56
+ },
57
+ repairAction("module-shape", moduleShapeCommand, "Review missing required module source files.", false),
58
+ );
59
+ if (module.kind !== "service" && module.files.includes(`${module.name}.dictionary.ts`)) {
60
+ const constantPath = path.join(workspace.workspaceRoot, module.path, `${module.name}.constant.ts`);
61
+ const dictionaryPath = path.join(workspace.workspaceRoot, module.path, `${module.name}.dictionary.ts`);
62
+ const [constantContent, dictionaryContent] = await Promise.all([
63
+ safeReadText(constantPath),
64
+ safeReadText(dictionaryPath),
65
+ ]);
66
+ if (constantContent && dictionaryContent) {
67
+ for (const fieldName of unlabeledFieldNames(constantContent, dictionaryContent)) {
68
+ findings.report(
69
+ {
70
+ severity: "warning",
71
+ code: "dictionary-label-missing",
72
+ path: `${module.path}/${module.name}.dictionary.ts`,
73
+ message: `Dictionary labels for ${sys.name}:${module.name}.${fieldName} were not found.`,
74
+ },
75
+ repairAction(
76
+ "dictionary",
77
+ `akan repair dictionary --app ${sys.name} --module ${module.name}`,
78
+ "Add missing dictionary labels for source constant fields.",
79
+ false,
80
+ ),
81
+ );
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,42 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import type { AkanSysContext } from "../akanContext";
4
+ import { collectRecipeSources, findInlineRecipeDuplicates, scanRecipes } from "../recipeScanner";
5
+ import type { DoctorFindings } from "./doctorFindings";
6
+
7
+ export class RecipeDuplicateCheck {
8
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
9
+ //* Advisory only (warning): promoted to lint only if inline re-authoring actually recurs.
10
+ for (const sys of systems) {
11
+ const sources = await collectRecipeSources(path.join(workspace.workspaceRoot, sys.path, "ui"), "ui");
12
+ if (sources.length === 0) continue;
13
+ const recipes = scanRecipes(sources);
14
+ const files: { path: string; content: string }[] = [];
15
+ const glob = new Bun.Glob("**/*.tsx");
16
+ for await (const abs of glob.scan({ cwd: path.join(workspace.workspaceRoot, sys.path), absolute: true })) {
17
+ if (/[\\/](node_modules|\.akan|dist)[\\/]|[\\/]v1[\\/]/.test(abs) || /\.(test|spec)\.tsx$/.test(abs)) continue;
18
+ files.push({
19
+ path: abs,
20
+ content: await Bun.file(abs)
21
+ .text()
22
+ .catch(() => ""),
23
+ });
24
+ }
25
+ const duplicates = findInlineRecipeDuplicates(recipes, files);
26
+ if (duplicates.length === 0) continue;
27
+ const preview = duplicates
28
+ .slice(0, 3)
29
+ .map(
30
+ (duplicate) =>
31
+ `${path.relative(workspace.workspaceRoot, duplicate.path).replaceAll(path.sep, "/")}:${duplicate.line}`,
32
+ )
33
+ .join(", ");
34
+ findings.push({
35
+ severity: "warning",
36
+ code: "recipe-inline-duplicate",
37
+ path: path.posix.join(sys.path, "ui/Recipe"),
38
+ message: `${sys.name}: ${duplicates.length} inline className(s) re-author a recipe fingerprint (${preview}${duplicates.length > 3 ? ", …" : ""}) — consume the recipe instead.`,
39
+ });
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,87 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import type { AkanSysContext } from "../akanContext";
4
+ import { collectRecipeSources, scanRecipes } from "../recipeScanner";
5
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
6
+
7
+ export class RecipeIndexCheck {
8
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
9
+ // Doctor never writes, so this is what catches a committed stale recipe index (lint and sync self-heal the tree).
10
+ const scanNames = async (uiDirPath: string, basename?: string) =>
11
+ new Set(scanRecipes(await collectRecipeSources(uiDirPath, "ui", basename)).map((info) => info.name));
12
+ const declaredByImport = new Map<string, Set<string>>();
13
+ declaredByImport.set("akanjs/ui", await scanNames(path.join(workspace.workspaceRoot, "pkgs/akanjs/ui"), "recipe"));
14
+ for (const sys of systems)
15
+ declaredByImport.set(`@${sys.path}/ui`, await scanNames(path.join(workspace.workspaceRoot, sys.path, "ui")));
16
+ // Section slice anchors the heading to a full line — the same string appears back-ticked in prose.
17
+ const sectionOf = (content: string, heading: string) => {
18
+ const match = new RegExp(`^${heading}$`, "m").exec(content);
19
+ if (!match) return "";
20
+ const section = content.slice(match.index);
21
+ const sectionEnd = section.indexOf("\n## ", 1);
22
+ return sectionEnd === -1 ? section : section.slice(0, sectionEnd);
23
+ };
24
+ // `Import from \`<path>\`:` groups with their `- \`name\`` items, so each name checks against its owner.
25
+ const listedByImport = (body: string) => {
26
+ const groups = new Map<string, Set<string>>();
27
+ let current: Set<string> | null = null;
28
+ for (const line of body.split("\n")) {
29
+ const group = /^Import from `([^`]+)`:/.exec(line);
30
+ if (group) {
31
+ current = groups.get(group[1]) ?? new Set();
32
+ groups.set(group[1], current);
33
+ continue;
34
+ }
35
+ const item = /^- `([A-Za-z0-9_$]+)`/.exec(line);
36
+ if (item && current) current.add(item[1]);
37
+ else if (!item) current = null;
38
+ }
39
+ return groups;
40
+ };
41
+ const pushIndexDiagnostic = (indexPath: string, missing: string[], stale: string[], repairCommand: string) => {
42
+ if (missing.length === 0 && stale.length === 0) return;
43
+ const parts = [
44
+ missing.length > 0 ? `${missing.length} declared but unlisted (${missing.slice(0, 5).join(", ")})` : "",
45
+ stale.length > 0 ? `${stale.length} listed but gone (${stale.slice(0, 5).join(", ")})` : "",
46
+ ].filter(Boolean);
47
+ findings.report(
48
+ {
49
+ severity: "error",
50
+ code: "recipe-index-stale",
51
+ path: indexPath,
52
+ message: `${indexPath} recipe index is out of date — ${parts.join("; ")}. Agents read this list as authoritative.`,
53
+ },
54
+ repairAction("generated", repairCommand, "Regenerate the recipe index from the scanned recipes.", true),
55
+ );
56
+ };
57
+ const frameworkDeclared = declaredByImport.get("akanjs/ui") ?? new Set<string>();
58
+ if (frameworkDeclared.size > 0) {
59
+ const agentsMd = await Bun.file(path.join(workspace.workspaceRoot, "AGENTS.md"))
60
+ .text()
61
+ .catch(() => "");
62
+ const listed = listedByImport(sectionOf(agentsMd, "## Recipes")).get("akanjs/ui") ?? new Set<string>();
63
+ pushIndexDiagnostic(
64
+ "AGENTS.md",
65
+ [...frameworkDeclared].filter((name) => !listed.has(name)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)),
66
+ [...listed].filter((name) => !frameworkDeclared.has(name)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)),
67
+ "akan agent install agents-md",
68
+ );
69
+ }
70
+ for (const sys of systems) {
71
+ const own = declaredByImport.get(`@${sys.path}/ui`) ?? new Set<string>();
72
+ const scopeMd = await Bun.file(path.join(workspace.workspaceRoot, sys.path, "AGENTS.md"))
73
+ .text()
74
+ .catch(() => "");
75
+ const groups = listedByImport(sectionOf(scopeMd, "## Recipes In Scope"));
76
+ const ownListed = groups.get(`@${sys.path}/ui`) ?? new Set<string>();
77
+ const missing = [...own].filter((name) => !ownListed.has(name)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
78
+ // Every listed name — the scope's own and its dependency libs' — must still exist at its owner.
79
+ const stale = [...groups.entries()]
80
+ .flatMap(([importFrom, names]) =>
81
+ [...names].filter((name) => !(declaredByImport.get(importFrom) ?? new Set()).has(name)),
82
+ )
83
+ .sort();
84
+ pushIndexDiagnostic(`${sys.path}/AGENTS.md`, missing, stale, `akan sync ${sys.name}`);
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,55 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import {
4
+ barrelFacetDirs,
5
+ facetIndexShadowOf,
6
+ isScannedRootEntry,
7
+ rootAllowedDirs,
8
+ rootAllowedFiles,
9
+ rootEntryHintOf,
10
+ } from "../../workspace/workspaceLayout";
11
+ import type { AkanSysContext } from "../akanContext";
12
+ import { safeReadDir } from "../safeRead";
13
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
14
+
15
+ export class RootShapeCheck {
16
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
17
+ for (const sys of systems) {
18
+ const sysPath = path.join(workspace.workspaceRoot, sys.path);
19
+ for (const entry of await safeReadDir(sysPath)) {
20
+ if (!isScannedRootEntry(sys.type, entry.name)) continue;
21
+ const allowed = entry.isDirectory()
22
+ ? rootAllowedDirs[sys.type].has(entry.name)
23
+ : rootAllowedFiles[sys.type].has(entry.name);
24
+ const rootEntryHint = rootEntryHintOf(sys.type, entry.name);
25
+ if (!allowed)
26
+ findings.report(
27
+ {
28
+ severity: "error",
29
+ code: `${sys.type}-root-unknown-entry`,
30
+ path: `${sys.path}/${entry.name}`,
31
+ message: `Unexpected ${entry.isDirectory() ? "folder" : "file"} in ${sys.type} root: ${sys.path}/${entry.name}${
32
+ rootEntryHint ? ` (${rootEntryHint})` : ""
33
+ }`,
34
+ },
35
+ repairAction(
36
+ "module-shape",
37
+ `akan repair module-shape --app ${sys.name}`,
38
+ `Review ${sys.type} root shape and remove or move the unknown entry.`,
39
+ false,
40
+ ),
41
+ );
42
+ }
43
+ for (const facet of barrelFacetDirs)
44
+ for (const entry of await safeReadDir(path.join(sysPath, facet))) {
45
+ const shadow = entry.isDirectory() ? null : facetIndexShadowOf(`${facet}/${entry.name}`);
46
+ if (!shadow) continue;
47
+ const entryPath = `${sys.path}/${facet}/${entry.name}`;
48
+ findings.report(
49
+ { severity: "error", code: "facet-index-shadowed", path: entryPath, message: `${entryPath} ${shadow}` },
50
+ repairAction("generated", `akan sync ${sys.name}`, `Delete ${entryPath} by hand, then sync.`, false),
51
+ );
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,97 @@
1
+ import path from "node:path";
2
+ import { isRecord } from "akanjs/common";
3
+ import type { WorkspaceExecutor } from "../../executors";
4
+ import {
5
+ type WorkflowApplyReport,
6
+ type WorkflowPlan,
7
+ type WorkflowRunArtifact,
8
+ workflowPathsForPlan,
9
+ workflowRunArtifactPath,
10
+ } from "../../workflow";
11
+ import type { AkanDiagnostic } from "../akanContext";
12
+ import { safeReadJson } from "../safeRead";
13
+
14
+ const isWorkflowPlan = (value: unknown): value is WorkflowPlan =>
15
+ typeof value === "object" &&
16
+ value !== null &&
17
+ "schemaVersion" in value &&
18
+ value.schemaVersion === 1 &&
19
+ "mode" in value &&
20
+ value.mode === "plan" &&
21
+ "inputs" in value &&
22
+ isRecord(value.inputs) &&
23
+ "predictedChanges" in value &&
24
+ Array.isArray(value.predictedChanges) &&
25
+ value.predictedChanges.every((change) => isRecord(change) && typeof change.target === "string");
26
+
27
+ const isPathList = (value: unknown) =>
28
+ Array.isArray(value) && value.every((file) => isRecord(file) && typeof file.path === "string");
29
+
30
+ const isWorkflowApplyReport = (value: unknown): value is WorkflowApplyReport =>
31
+ typeof value === "object" &&
32
+ value !== null &&
33
+ "schemaVersion" in value &&
34
+ value.schemaVersion === 1 &&
35
+ "mode" in value &&
36
+ (value.mode === "apply" || value.mode === "dry-run") &&
37
+ "changedFiles" in value &&
38
+ isPathList(value.changedFiles) &&
39
+ "generatedFiles" in value &&
40
+ isPathList(value.generatedFiles) &&
41
+ "plan" in value &&
42
+ isWorkflowPlan(value.plan);
43
+
44
+ const isWorkflowRunArtifact = (value: unknown): value is WorkflowRunArtifact =>
45
+ typeof value === "object" && value !== null && "schemaVersion" in value && value.schemaVersion === 1;
46
+
47
+ const workflowPathsForArtifact = (artifact: WorkflowRunArtifact) => {
48
+ if (isWorkflowPlan(artifact)) return workflowPathsForPlan(artifact);
49
+ if (isWorkflowApplyReport(artifact)) {
50
+ return [
51
+ ...artifact.changedFiles.map((file) => file.path),
52
+ ...artifact.generatedFiles.map((file) => file.path),
53
+ ...workflowPathsForPlan(artifact.plan),
54
+ ];
55
+ }
56
+ if ("mode" in artifact && artifact.mode === "validate" && isWorkflowPlan(artifact.plan))
57
+ return workflowPathsForPlan(artifact.plan);
58
+ return [];
59
+ };
60
+
61
+ export const loadWorkflowContextPaths = async (
62
+ workspace: WorkspaceExecutor,
63
+ runIdOrPlan: string | null,
64
+ changedFiles: string[],
65
+ ) => {
66
+ const paths = [...changedFiles];
67
+ if (!runIdOrPlan) return paths;
68
+ const inputPath = path.isAbsolute(runIdOrPlan) ? runIdOrPlan : path.join(workspace.workspaceRoot, runIdOrPlan);
69
+ const artifact =
70
+ (await safeReadJson<WorkflowRunArtifact | WorkflowPlan>(inputPath)) ??
71
+ (await safeReadJson<WorkflowRunArtifact>(path.join(workspace.workspaceRoot, workflowRunArtifactPath(runIdOrPlan))));
72
+ if (artifact && isWorkflowRunArtifact(artifact)) paths.push(...workflowPathsForArtifact(artifact));
73
+ return [...new Set(paths.filter(Boolean))];
74
+ };
75
+
76
+ const withoutPlaceholders = (value: string) =>
77
+ value
78
+ .split("<")
79
+ .map((part, index) => (index === 0 ? part : part.slice(part.indexOf(">") + 1)))
80
+ .join("");
81
+
82
+ const pathKey = (value: string) =>
83
+ withoutPlaceholders(value.replaceAll("\\", "/").replaceAll("*", ""))
84
+ .replace(/\/+/g, "/")
85
+ .replace(/^\/|\/$/g, "");
86
+
87
+ export const isWorkflowRelatedDiagnostic = (diagnostic: AkanDiagnostic, workflowPaths: string[]) => {
88
+ if (!diagnostic.path) return false;
89
+ const diagnosticPath = pathKey(diagnostic.path);
90
+ return workflowPaths.some((workflowPath) => {
91
+ const candidate = pathKey(workflowPath);
92
+ if (!candidate) return false;
93
+ return (
94
+ diagnosticPath.startsWith(candidate) || candidate.startsWith(diagnosticPath) || diagnosticPath.includes(candidate)
95
+ );
96
+ });
97
+ };
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
+ import { tempDirs } from "../test/testHelpers";
4
5
  import { collectRecipeSources, findInlineRecipeDuplicates, type RecipeInfo, scanRecipes } from "./recipeScanner";
5
- import { tempDirs } from "./testHelpers";
6
6
 
7
7
  const byName = (recipes: RecipeInfo[], name: string) => recipes.find((recipe) => recipe.name === name);
8
8
 
@@ -0,0 +1,9 @@
1
+ import { readdir } from "node:fs/promises";
2
+ import { FileSys } from "../util/fileSys";
3
+
4
+ export const safeReadDir = async (dirPath: string) =>
5
+ (await readdir(dirPath, { withFileTypes: true }).catch(() => [])).sort((a, b) => a.name.localeCompare(b.name));
6
+
7
+ export const safeReadText = (filePath: string) => FileSys.readText(filePath).catch(() => null);
8
+
9
+ export const safeReadJson = <T>(filePath: string) => FileSys.readJson<T>(filePath).catch(() => null);
@@ -43,7 +43,7 @@ interface CsrE2eServer {
43
43
 
44
44
  const DEFAULT_PORT = 8391;
45
45
  const RELOAD_MARKER = "__akanE2eBootMarker";
46
- //? Longer than the frame's navigation lock (360ms after a transition commits, `webkit/useCsrValues.ts`).
46
+ //? Longer than the frame's navigation lock (360ms after a transition commits, `webkit/useCsrNavigation.ts`).
47
47
  const SETTLE_MS = 450;
48
48
 
49
49
  /** Drives a page of a running `akan start` in a headless `Bun.WebView`: CSR (`?csr=true` + a mobile target) or SSR. */
@@ -1,12 +1,12 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { realpath } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { ApplicationBuildReporter } from "./applicationBuildReporter";
5
- import { resolveSignalTestPreloadPath } from "./applicationTestPreload";
6
- import { TypeScriptDependencyScanner } from "./dependencyScanner";
4
+ import { ApplicationBuildReporter } from "./app/applicationBuildReporter";
5
+ import { resolveSignalTestPreloadPath } from "./app/applicationTestPreload";
7
6
  import { AppExecutor, WorkspaceExecutor } from "./executors";
8
- import { tempDirs, writeText as write } from "./testHelpers";
9
- import type { PackageJson, TsConfigJson } from "./types";
7
+ import { tempDirs, writeText as write } from "./test/testHelpers";
8
+ import { TypeScriptDependencyScanner } from "./workspace/dependencyScanner";
9
+ import type { PackageJson, TsConfigJson } from "./workspace/types";
10
10
 
11
11
  const makeTempRoot = tempDirs("akan-devkit-utils-");
12
12
 
@@ -199,6 +199,40 @@ describe("ApplicationBuildReporter", () => {
199
199
  );
200
200
  });
201
201
 
202
+ test("shows the first 20 errors of an aggregate, counts the rest, and follows its cause", () => {
203
+ const many = new AggregateError(
204
+ Array.from({ length: 23 }, (_, index) => new Error(`log ${index + 1}`)),
205
+ "server graph failed",
206
+ { cause: new Error("plugin licenseNotices") },
207
+ );
208
+ expect(ApplicationBuildReporter.formatError(many).split("\n")).toEqual([
209
+ "server graph failed",
210
+ ...Array.from({ length: 20 }, (_, index) => ` log ${index + 1}`),
211
+ " …and 3 more",
212
+ "Caused by: plugin licenseNotices",
213
+ ]);
214
+ });
215
+
216
+ test("ends a cause or an aggregate that loops back on itself", () => {
217
+ const looped = new Error("upload failed");
218
+ looped.cause = new Error("socket closed", { cause: looped });
219
+ expect(ApplicationBuildReporter.formatError(looped).split("\n")).toEqual([
220
+ "upload failed",
221
+ "Caused by: socket closed",
222
+ "Caused by: [circular]",
223
+ ]);
224
+
225
+ const shared = new Error("disk full");
226
+ const aggregate = new AggregateError([shared, shared], "two writes failed");
227
+ aggregate.errors.push(aggregate);
228
+ expect(ApplicationBuildReporter.formatError(aggregate).split("\n")).toEqual([
229
+ "two writes failed",
230
+ " disk full",
231
+ " disk full",
232
+ " [circular]",
233
+ ]);
234
+ });
235
+
202
236
  test("says where the bundler placed each reason, relative to the workspace root", async () => {
203
237
  const root = await makeTempRoot();
204
238
  const refuseWith = (message: string) => ({
@@ -1,15 +1,15 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { AgentAssets } from "./agentAssets";
3
+ import { AgentAssets } from "../guideline/agentAssets";
4
4
  import { ApiReference } from "./apiReference";
5
5
 
6
- const akanjsDir = path.resolve(import.meta.dir, "../../akanjs");
7
- const target = ApiReference.target(path.resolve(import.meta.dir, "../cli"));
6
+ const akanjsDir = path.resolve(import.meta.dir, "../../../akanjs");
7
+ const target = ApiReference.target(path.resolve(import.meta.dir, "../../cli"));
8
8
 
9
9
  describe("ApiReference", () => {
10
10
  const rendered = ApiReference.render(akanjsDir);
11
11
 
12
- test("the committed guideline matches the akanjs sources; regenerate with bun pkgs/@akanjs/devkit/apiReference.ts", async () => {
12
+ test("the committed guideline matches the akanjs sources; regenerate with bun pkgs/@akanjs/devkit/docs/apiReference.ts", async () => {
13
13
  expect(await Bun.file(target).text()).toBe(rendered);
14
14
  });
15
15
 
@@ -234,7 +234,7 @@ export class ApiReference {
234
234
  }
235
235
 
236
236
  if (import.meta.main) {
237
- const akanjsDir = path.resolve(import.meta.dir, "../../akanjs");
238
- const target = ApiReference.target(path.resolve(import.meta.dir, "../cli"));
237
+ const akanjsDir = path.resolve(import.meta.dir, "../../../akanjs");
238
+ const target = ApiReference.target(path.resolve(import.meta.dir, "../../cli"));
239
239
  await Bun.write(target, ApiReference.render(akanjsDir));
240
240
  }